1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-09-20 10:51:56 +00:00
musix-oss/node_modules/firebase/firebase.js
2020-03-03 22:30:50 +02:00

3 lines
880 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

!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 g(t){var e=new FileReader,n=m(e);return e.readAsArrayBuffer(t),n}function v(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function b(){return this.bodyUsed=!1,this._initBody=function(t){if(this._bodyInit=t)if("string"==typeof t)this._bodyText=t;else if(a&&Blob.prototype.isPrototypeOf(t))this._bodyBlob=t;else if(r&&FormData.prototype.isPrototypeOf(t))this._bodyFormData=t;else if(e&&URLSearchParams.prototype.isPrototypeOf(t))this._bodyText=t.toString();else if(i&&a&&s(t))this._bodyArrayBuffer=v(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer]);else{if(!i||!ArrayBuffer.prototype.isPrototypeOf(t)&&!u(t))throw new Error("unsupported BodyInit type");this._bodyArrayBuffer=v(t)}else this._bodyText="";this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):e&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},a&&(this.blob=function(){var t=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(g)}),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 g(t){return"object"==typeof t?null!==t:"function"==typeof t}function r(t){return l?u.createElement(t):{}}function d(t){if(!g(t))throw TypeError(String(t)+" is not an object");return t}function o(t,e){if(!g(t))return t;var n,r;if(e&&"function"==typeof(n=t.toString)&&!g(r=n.call(t)))return r;if("function"==typeof(n=t.valueOf)&&!g(r=n.call(t)))return r;if(!e&&"function"==typeof(n=t.toString)&&!g(r=n.call(t)))return r;throw TypeError("Can't convert object to primitive value")}function v(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}function h(e,n){try{_(b,e,n)}catch(t){b[e]=n}return n}function c(t,e){return I.call(t,e)}function s(t){return"Symbol("+String(void 0===t?"":t)+")_"+(++C+N).toString(36)}function i(t){return c(k,t)||(A&&c(R,t)?k[t]=R[t]:k[t]=O("Symbol."+t)),k[t]}var b=n("object"==typeof globalThis&&globalThis)||n("object"==typeof window&&window)||n("object"==typeof self&&self)||n("object"==typeof t&&t)||Function("return this")(),a=!1,f=!m(function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}),u=b.document,l=g(u)&&g(u.createElement),p=!f&&!m(function(){return 7!=Object.defineProperty(r("div"),"a",{get:function(){return 7}}).a}),y=Object.defineProperty,w={f:f?y:function(t,e,n){if(d(t),e=o(e,!0),d(n),p)try{return y(t,e,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");return"value"in n&&(t[e]=n.value),t}},_=f?function(t,e,n){return w.f(t,e,v(1,n))}:function(t,e,n){return t[e]=n,t},E="__core-js_shared__",T=b[E]||h(E,{}),S=e(function(t){(t.exports=function(t,e){return T[t]||(T[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.6.2",mode:"global",copyright:"© 2020 Denis Pushkarev (zloirock.ru)"})}),I={}.hasOwnProperty,C=0,N=Math.random(),A=!!Object.getOwnPropertySymbols&&!m(function(){return!String(Symbol())}),D=A&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,k=S("wks"),R=b.Symbol,O=D?R:R&&R.withoutSetter||s,P={};P[i("toStringTag")]="z";var x="[object z]"===String(P),M=Function.toString;"function"!=typeof T.inspectSource&&(T.inspectSource=function(t){return M.call(t)});function L(t){return W[t]||(W[t]=s(t))}var F,U,V,q=T.inspectSource,B=b.WeakMap,j="function"==typeof B&&/native code/.test(q(B)),W=S("keys"),K={},Q=b.WeakMap;if(j){var H=new Q,z=H.get,G=H.has,Y=H.set;F=function(t,e){return Y.call(H,t,e),e},U=function(t){return z.call(H,t)||{}},V=function(t){return G.call(H,t)}}else{var X=L("state");K[X]=!0,F=function(t,e){return _(t,X,e),e},U=function(t){return c(t,X)?t[X]:{}},V=function(t){return c(t,X)}}function J(t){return tt.call(t).slice(8,-1)}var $={set:F,get:U,has:V,enforce:function(t){return V(t)?U(t):F(t,{})},getterFor:function(n){return function(t){var e;if(!g(t)||(e=U(t)).type!==n)throw TypeError("Incompatible receiver, "+n+" required");return e}}},Z=e(function(t){var e=$.get,s=$.enforce,u=String(String).split("String");(t.exports=function(t,e,n,r){var i=!!r&&!!r.unsafe,o=!!r&&!!r.enumerable,a=!!r&&!!r.noTargetGet;"function"==typeof n&&("string"!=typeof e||c(n,"name")||_(n,"name",e),s(n).source=u.join("string"==typeof e?e:"")),t!==b?(i?!a&&t[e]&&(o=!0):delete t[e],o?t[e]=n:_(t,e,n)):o?t[e]=n:h(e,n)})(Function.prototype,"toString",function(){return"function"==typeof this&&e(this).source||q(this)})}),tt={}.toString,et=i("toStringTag"),nt="Arguments"==J(function(){return arguments}()),rt=x?J:function(t){var e,n,r;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(n=function(t,e){try{return t[e]}catch(t){}}(e=Object(t),et))?n:nt?J(e):"Object"==(r=J(e))&&"function"==typeof e.callee?"Arguments":r},it=x?{}.toString:function(){return"[object "+rt(this)+"]"};x||Z(Object.prototype,"toString",it,{unsafe:!0});function ot(t){return isNaN(t=+t)?0:(0<t?Et:_t)(t)}function at(t){if(null==t)throw TypeError("Can't call method on "+t);return t}function st(s){return function(t,e){var n,r,i=String(at(t)),o=ot(e),a=i.length;return o<0||a<=o?s?"":void 0:(n=i.charCodeAt(o))<55296||56319<n||o+1===a||(r=i.charCodeAt(o+1))<56320||57343<r?s?i.charAt(o):n:s?i.slice(o,o+2):r-56320+(n-55296<<10)+65536}}function ut(t){return At(at(t))}function ct(t){return"function"==typeof t?t:void 0}function ht(t,e){return arguments.length<2?ct(Rt[t])||ct(b[t]):Rt[t]&&Rt[t][e]||b[t]&&b[t][e]}function lt(t){return 0<t?Ot(ot(t),9007199254740991):0}function ft(s){return function(t,e,n){var r,i=ut(t),o=lt(i.length),a=function(t,e){var n=ot(t);return n<0?Pt(n+e,0):xt(n,e)}(n,o);if(s&&e!=e){for(;a<o;)if((r=i[a++])!=r)return!0}else for(;a<o;a++)if((s||a in i)&&i[a]===e)return s||a||0;return!s&&-1}}function pt(t,e){var n,r=ut(t),i=0,o=[];for(n in r)!c(K,n)&&c(r,n)&&o.push(n);for(;e.length>i;)c(r,n=e[i++])&&(~Mt(o,n)||o.push(n));return o}function dt(t,e){for(var n=qt(e),r=w.f,i=kt.f,o=0;o<n.length;o++){var a=n[o];c(t,a)||r(t,a,i(e,a))}}function yt(t,e){var n=Wt[jt(t)];return n==Qt||n!=Kt&&("function"==typeof e?m(e):!!e)}function mt(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=zt(n,r))&&a.value:n[r],!Ht(u?r:s+(c?".":"#")+r,t.forced)&&void 0!==i){if(typeof o==typeof i)continue;dt(o,i)}(t.sham||i&&i.sham)&&_(o,"sham",!0),Z(n,r,o,t)}}function gt(t){return Object(at(t))}var vt,bt,wt,_t=Math.ceil,Et=Math.floor,Tt={codeAt:st(!1),charAt:st(!0)},St={}.propertyIsEnumerable,It=Object.getOwnPropertyDescriptor,Ct={f:It&&!St.call({1:2},1)?function(t){var e=It(this,t);return!!e&&e.enumerable}:St},Nt="".split,At=m(function(){return!Object("z").propertyIsEnumerable(0)})?function(t){return"String"==J(t)?Nt.call(t,""):Object(t)}:Object,Dt=Object.getOwnPropertyDescriptor,kt={f:f?Dt:function(t,e){if(t=ut(t),e=o(e,!0),p)try{return Dt(t,e)}catch(t){}if(c(t,e))return v(!Ct.f.call(t,e),t[e])}},Rt=b,Ot=Math.min,Pt=Math.max,xt=Math.min,Mt={includes:ft(!0),indexOf:ft(!1)}.indexOf,Lt=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Ft=Lt.concat("length","prototype"),Ut={f:Object.getOwnPropertyNames||function(t){return pt(t,Ft)}},Vt={f:Object.getOwnPropertySymbols},qt=ht("Reflect","ownKeys")||function(t){var e=Ut.f(d(t)),n=Vt.f;return n?e.concat(n(t)):e},Bt=/#|\.prototype\./,jt=yt.normalize=function(t){return String(t).replace(Bt,".").toLowerCase()},Wt=yt.data={},Kt=yt.NATIVE="N",Qt=yt.POLYFILL="P",Ht=yt,zt=kt.f,Gt=!m(function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype}),Yt=L("IE_PROTO"),Xt=Object.prototype,Jt=Gt?Object.getPrototypeOf:function(t){return t=gt(t),c(t,Yt)?t[Yt]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?Xt:null},$t=i("iterator"),Zt=!1;[].keys&&("next"in(wt=[].keys())?(bt=Jt(Jt(wt)))!==Object.prototype&&(vt=bt):Zt=!0),null==vt&&(vt={}),c(vt,$t)||_(vt,$t,function(){return this});function te(){}function ee(t){return"<script>"+t+"</"+ue+">"}var ne,re={IteratorPrototype:vt,BUGGY_SAFARI_ITERATORS:Zt},ie=Object.keys||function(t){return pt(t,Lt)},oe=f?Object.defineProperties:function(t,e){d(t);for(var n,r=ie(e),i=r.length,o=0;o<i;)w.f(t,n=r[o++],e[n]);return t},ae=ht("document","documentElement"),se="prototype",ue="script",ce=L("IE_PROTO"),he=function(){try{ne=document.domain&&new ActiveXObject("htmlfile")}catch(t){}he=ne?function(t){t.write(ee("")),t.close();var e=t.parentWindow.Object;return t=null,e}(ne):function(){var t,e=r("iframe");return e.style.display="none",ae.appendChild(e),e.src=String("javascript:"),(t=e.contentWindow.document).open(),t.write(ee("document.F=Object")),t.close(),t.F}();for(var t=Lt.length;t--;)delete he[se][Lt[t]];return he()};K[ce]=!0;function le(t,e,n){t&&!c(t=n?t:t.prototype,ge)&&me(t,ge,{configurable:!0,value:e})}function fe(){return this}function pe(){return this}function de(t,e,n,r,i,o,a){function s(t){if(t===i&&y)return y;if(!Ee&&t in p)return p[t];switch(t){case"keys":case Se:case Ie:return function(){return new n(this,t)}}return function(){return new n(this)}}!function(t,e,n){var r=e+" Iterator";t.prototype=ye(be,{next:v(1,n)}),le(t,r,!1),ve[r]=fe}(n,e,r);var u,c,h,l=e+" Iterator",f=!1,p=t.prototype,d=p[Te]||p["@@iterator"]||i&&p[i],y=!Ee&&d||s(i),m="Array"==e&&p.entries||d;if(m&&(u=Jt(m.call(new t)),_e!==Object.prototype&&u.next&&(Jt(u)!==_e&&(we?we(u,_e):"function"!=typeof u[Te]&&_(u,Te,pe)),le(u,l,!0))),i==Se&&d&&d.name!==Se&&(f=!0,y=function(){return d.call(this)}),p[Te]!==y&&_(p,Te,y),ve[e]=y,i)if(c={values:s(Se),keys:o?y:s("keys"),entries:s(Ie)},a)for(h in c)!Ee&&!f&&h in p||Z(p,h,c[h]);else mt({target:e,proto:!0,forced:Ee||f},c);return c}var ye=Object.create||function(t,e){var n;return null!==t?(te[se]=d(t),n=new te,te[se]=null,n[ce]=t):n=he(),void 0===e?n:oe(n,e)},me=w.f,ge=i("toStringTag"),ve={},be=re.IteratorPrototype,we=Object.setPrototypeOf||("__proto__"in{}?function(){var n,r=!1,t={};try{(n=Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set).call(t,[]),r=t instanceof Array}catch(t){}return function(t,e){return d(t),function(t){if(!g(t)&&null!==t)throw TypeError("Can't set "+String(t)+" as a prototype")}(e),r?n.call(t,e):t.__proto__=e,t}}():void 0),_e=re.IteratorPrototype,Ee=re.BUGGY_SAFARI_ITERATORS,Te=i("iterator"),Se="values",Ie="entries",Ce=Tt.charAt,Ne="String Iterator",Ae=$.set,De=$.getterFor(Ne);de(String,"String",function(t){Ae(this,{type:Ne,string:String(t),index:0})},function(){var t,e=De(this),n=e.string,r=e.index;return r>=n.length?{value:void 0,done:!0}:(t=Ce(n,r),e.index+=t.length,{value:t,done:!1})});var ke={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},Re=i("unscopables"),Oe=Array.prototype;null==Oe[Re]&&w.f(Oe,Re,{configurable:!0,value:ye(null)});function Pe(t){Oe[Re][t]=!0}var xe="Array Iterator",Me=$.set,Le=$.getterFor(xe),Fe=de(Array,"Array",function(t,e){Me(this,{type:xe,target:ut(t),index:0,kind:e})},function(){var t=Le(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");ve.Arguments=ve.Array,Pe("keys"),Pe("values"),Pe("entries");var Ue=i("iterator"),Ve=i("toStringTag"),qe=Fe.values;for(var Be in ke){var je=b[Be],We=je&&je.prototype;if(We){if(We[Ue]!==qe)try{_(We,Ue,qe)}catch(eu){We[Ue]=qe}if(We[Ve]||_(We,Ve,Be),ke[Be])for(var Ke in Fe)if(We[Ke]!==Fe[Ke])try{_(We,Ke,Fe[Ke])}catch(eu){We[Ke]=Fe[Ke]}}}function Qe(t,e,n){for(var r in e)Z(t,r,e[r],n);return t}function He(t){var e=ht(t),n=w.f;f&&e&&!e[tn]&&n(e,tn,{configurable:!0,get:function(){return this}})}function ze(t){if("function"!=typeof t)throw TypeError(String(t)+" is not a function");return t}function Ge(t,e,n){if(!(t instanceof e))throw TypeError("Incorrect "+(n?n+" ":"")+"invocation");return t}function Ye(t){return void 0!==t&&(ve.Array===t||nn[en]===t)}function Xe(r,i,t){if(ze(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 Je(t){if(null!=t)return t[rn]||t["@@iterator"]||ve[rt(t)]}function $e(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 Ze=b.Promise,tn=i("species"),en=i("iterator"),nn=Array.prototype,rn=i("iterator"),on=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=Xe(e,n,r?2:1);if(i)o=t;else{if("function"!=typeof(a=Je(t)))throw TypeError("Target is not iterable");if(Ye(a)){for(s=0,u=lt(t.length);s<u;s++)if((c=r?f(d(l=t[s])[0],l[1]):f(t[s]))&&c instanceof p)return c;return new p(!1)}o=a.call(t)}for(h=o.next;!(l=h.call(o)).done;)if("object"==typeof(c=$e(o,f,l.value,r))&&c&&c instanceof p)return c;return new p(!1)}).stop=function(t){return new p(!0,t)}}),an=i("iterator"),sn=!1;try{var un=0,cn={next:function(){return{done:!!un++}},return:function(){sn=!0}};cn[an]=function(){return this},Array.from(cn,function(){throw 2})}catch(eu){}function hn(t,e){if(!e&&!sn)return!1;var n=!1;try{var r={};r[an]=function(){return{next:function(){return{done:n=!0}}}},t(r)}catch(t){}return n}function ln(t,e){var n,r=d(t).constructor;return void 0===r||null==(n=d(r)[bn])?e:ze(n)}function fn(t){if(Dn.hasOwnProperty(t)){var e=Dn[t];delete Dn[t],e()}}function pn(t){return function(){fn(t)}}function dn(t){fn(t.data)}function yn(t){b.postMessage(t+"",En.protocol+"//"+En.host)}var mn,gn,vn,bn=i("species"),wn=ht("navigator","userAgent")||"",_n=/(iphone|ipod|ipad).*applewebkit/i.test(wn),En=b.location,Tn=b.setImmediate,Sn=b.clearImmediate,In=b.process,Cn=b.MessageChannel,Nn=b.Dispatch,An=0,Dn={},kn="onreadystatechange";Tn&&Sn||(Tn=function(t){for(var e=[],n=1;n<arguments.length;)e.push(arguments[n++]);return Dn[++An]=function(){("function"==typeof t?t:Function(t)).apply(void 0,e)},mn(An),An},Sn=function(t){delete Dn[t]},"process"==J(In)?mn=function(t){In.nextTick(pn(t))}:Nn&&Nn.now?mn=function(t){Nn.now(pn(t))}:Cn&&!_n?(vn=(gn=new Cn).port2,gn.port1.onmessage=dn,mn=Xe(vn.postMessage,vn,1)):!b.addEventListener||"function"!=typeof postMessage||b.importScripts||m(yn)?mn=kn in r("script")?function(t){ae.appendChild(r("script"))[kn]=function(){ae.removeChild(this),fn(t)}}:function(t){setTimeout(pn(t),0)}:(mn=yn,b.addEventListener("message",dn,!1)));var Rn,On,Pn,xn,Mn,Ln,Fn,Un,Vn={set:Tn,clear:Sn},qn=kt.f,Bn=Vn.set,jn=b.MutationObserver||b.WebKitMutationObserver,Wn=b.process,Kn=b.Promise,Qn="process"==J(Wn),Hn=qn(b,"queueMicrotask"),zn=Hn&&Hn.value;zn||(Rn=function(){var t,e;for(Qn&&(t=Wn.domain)&&t.exit();On;){e=On.fn,On=On.next;try{e()}catch(t){throw On?xn():Pn=void 0,t}}Pn=void 0,t&&t.enter()},xn=Qn?function(){Wn.nextTick(Rn)}:jn&&!_n?(Mn=!0,Ln=document.createTextNode(""),new jn(Rn).observe(Ln,{characterData:!0}),function(){Ln.data=Mn=!Mn}):Kn&&Kn.resolve?(Fn=Kn.resolve(void 0),Un=Fn.then,function(){Un.call(Fn,Rn)}):function(){Bn.call(b,Rn)});function Gn(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=ze(n),this.reject=ze(r)}function Yn(t,e){if(d(t),g(e)&&e.constructor===t)return e;var n=tr.f(t);return(0,n.resolve)(e),n.promise}function Xn(t){try{return{error:!1,value:t()}}catch(t){return{error:!0,value:t}}}var Jn,$n,Zn=zn||function(t){var e={fn:t,next:void 0};Pn&&(Pn.next=e),On||(On=e,xn()),Pn=e},tr={f:function(t){return new Gn(t)}},er=b.process,nr=er&&er.versions,rr=nr&&nr.v8;rr?$n=(Jn=rr.split("."))[0]+Jn[1]:wn&&(!(Jn=wn.match(/Edge\/(\d+)/))||74<=Jn[1])&&(Jn=wn.match(/Chrome\/(\d+)/))&&($n=Jn[1]);function ir(t){var e;return!(!g(t)||"function"!=typeof(e=t.then))&&e}function or(l,f,p){if(!f.notified){f.notified=!0;var d=f.reactions;Zn(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&&xr(l,f),f.rejection=1),!0===s?r=t:(h&&h.enter(),r=s(t),h&&(h.exit(),o=!0)),r===a.promise?c(_r("Promise-chain cycle")):(i=ir(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&&Or(l,f)})}}function ar(t,e,n){var r,i;Ar?((r=Er.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===Dr&&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 sr(e,n,r,i){return function(t){e(n,r,t,i)}}function ur(t,e,n,r){e.done||(e.done=!0,r&&(e=r),e.value=n,e.state=2,or(t,e,!0))}var cr,hr,lr,fr,pr=$n&&+$n,dr=Vn.set,yr=i("species"),mr="Promise",gr=$.get,vr=$.set,br=$.getterFor(mr),wr=Ze,_r=b.TypeError,Er=b.document,Tr=b.process,Sr=ht("fetch"),Ir=tr.f,Cr=Ir,Nr="process"==J(Tr),Ar=!!(Er&&Er.createEvent&&b.dispatchEvent),Dr="unhandledrejection",kr=Ht(mr,function(){if(!(q(wr)!==String(wr))){if(66===pr)return!0;if(!Nr&&"function"!=typeof PromiseRejectionEvent)return!0}if(51<=pr&&/native code/.test(wr))return!1;function t(t){t(function(){},function(){})}var e=wr.resolve(1);return(e.constructor={})[yr]=t,!(e.then(function(){})instanceof t)}),Rr=kr||!hn(function(t){wr.all(t).catch(function(){})}),Or=function(n,r){dr.call(b,function(){var t,e=r.value;if(Pr(r)&&(t=Xn(function(){Nr?Tr.emit("unhandledRejection",e,n):ar(Dr,n,e)}),r.rejection=Nr||Pr(r)?2:1,t.error))throw t.value})},Pr=function(t){return 1!==t.rejection&&!t.parent},xr=function(t,e){dr.call(b,function(){Nr?Tr.emit("rejectionHandled",t):ar("rejectionhandled",t,e.value)})},Mr=function(n,r,t,e){if(!r.done){r.done=!0,e&&(r=e);try{if(n===t)throw _r("Promise can't be resolved itself");var i=ir(t);i?Zn(function(){var e={done:!1};try{i.call(t,sr(Mr,n,e,r),sr(ur,n,e,r))}catch(t){ur(n,e,t,r)}}):(r.value=t,r.state=1,or(n,r,!1))}catch(t){ur(n,{done:!1},t,r)}}};kr&&(wr=function(t){Ge(this,wr,mr),ze(t),cr.call(this);var e=gr(this);try{t(sr(Mr,this,e),sr(ur,this,e))}catch(t){ur(this,e,t)}},(cr=function(t){vr(this,{type:mr,done:!1,notified:!1,parent:!1,reactions:[],rejection:!1,state:0,value:void 0})}).prototype=Qe(wr.prototype,{then:function(t,e){var n=br(this),r=Ir(ln(this,wr));return r.ok="function"!=typeof t||t,r.fail="function"==typeof e&&e,r.domain=Nr?Tr.domain:void 0,n.parent=!0,n.reactions.push(r),0!=n.state&&or(this,n,!1),r.promise},catch:function(t){return this.then(void 0,t)}}),hr=function(){var t=new cr,e=gr(t);this.promise=t,this.resolve=sr(Mr,t,e),this.reject=sr(ur,t,e)},tr.f=Ir=function(t){return t===wr||t===lr?new hr(t):Cr(t)},"function"==typeof Ze&&(fr=Ze.prototype.then,Z(Ze.prototype,"then",function(t,e){var n=this;return new wr(function(t,e){fr.call(n,t,e)}).then(t,e)},{unsafe:!0}),"function"==typeof Sr&&mt({global:!0,enumerable:!0,forced:!0},{fetch:function(t){return Yn(wr,Sr.apply(b,arguments))}}))),mt({global:!0,wrap:!0,forced:kr},{Promise:wr}),le(wr,mr,!1),He(mr),lr=ht(mr),mt({target:mr,stat:!0,forced:kr},{reject:function(t){var e=Ir(this);return e.reject.call(void 0,t),e.promise}}),mt({target:mr,stat:!0,forced:kr},{resolve:function(t){return Yn(this,t)}}),mt({target:mr,stat:!0,forced:Rr},{all:function(t){var s=this,e=Ir(s),u=e.resolve,c=e.reject,n=Xn(function(){var r=ze(s.resolve),i=[],o=0,a=1;on(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=Ir(n),i=r.reject,e=Xn(function(){var e=ze(n.resolve);on(t,function(t){e.call(n,t).then(r.resolve,i)})});return e.error&&i(e.value),r.promise}}),mt({target:"Promise",stat:!0},{allSettled:function(t){var s=this,e=tr.f(s),u=e.resolve,n=e.reject,r=Xn(function(){var r=ze(s.resolve),i=[],o=0,a=1;on(t,function(t){var e=o++,n=!1;i.push(void 0),a++,r.call(s,t).then(function(t){n||(n=!0,i[e]={status:"fulfilled",value:t},--a||u(i))},function(t){n||(n=!0,i[e]={status:"rejected",reason:t},--a||u(i))})}),--a||u(i)});return r.error&&n(r.value),e.promise}});var Lr=!!Ze&&m(function(){Ze.prototype.finally.call({then:function(){}},function(){})});mt({target:"Promise",proto:!0,real:!0,forced:Lr},{finally:function(e){var n=ln(this,ht("Promise")),t="function"==typeof e;return this.then(t?function(t){return Yn(n,e()).then(function(){return t})}:e,t?function(t){return Yn(n,e()).then(function(){throw t})}:e)}}),"function"!=typeof Ze||Ze.prototype.finally||Z(Ze.prototype,"finally",ht("Promise").prototype.finally);Rt.Promise;var Fr=$.set,Ur=$.getterFor("AggregateError"),Vr=function(t,e){var n=this;if(!(n instanceof Vr))return new Vr(t,e);we&&(n=we(new Error(e),Jt(n)));var r=[];return on(t,r.push,r),f?Fr(n,{errors:r,type:"AggregateError"}):n.errors=r,void 0!==e&&_(n,"message",String(e)),n};Vr.prototype=ye(Error.prototype,{constructor:v(5,Vr),message:v(5,""),name:v(5,"AggregateError")}),f&&w.f(Vr.prototype,"errors",{get:function(){return Ur(this).errors},configurable:!0}),mt({global:!0},{AggregateError:Vr}),mt({target:"Promise",stat:!0},{try:function(t){var e=tr.f(this),n=Xn(t);return(n.error?e.reject:e.resolve)(n.value),e.promise}});var qr="No one promise resolved";mt({target:"Promise",stat:!0},{any:function(t){var u=this,e=tr.f(u),c=e.resolve,h=e.reject,n=Xn(function(){var r=ze(u.resolve),i=[],o=0,a=1,s=!1;on(t,function(t){var e=o++,n=!1;i.push(void 0),a++,r.call(u,t).then(function(t){n||s||(s=!0,c(t))},function(t){n||s||(n=!0,i[e]=t,--a||h(new(ht("AggregateError"))(i,qr)))})}),--a||h(new(ht("AggregateError"))(i,qr))});return n.error&&h(n.value),e.promise}});function Br(t,e){var n;return Qr(t)&&("function"!=typeof(n=t.constructor)||n!==Array&&!Qr(n.prototype)?g(n)&&null===(n=n[Hr])&&(n=void 0):n=void 0),new(void 0===n?Array:n)(0===e?0:e)}function jr(p){var d=1==p,y=2==p,m=3==p,g=4==p,v=6==p,b=5==p||v;return function(t,e,n,r){for(var i,o,a=gt(t),s=At(a),u=Xe(e,n,3),c=lt(s.length),h=0,l=r||Br,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:zr.call(f,i)}else if(g)return!1;return v?-1:m||g?g:f}}function Wr(t){throw t}function Kr(t,e){var n=[][t],r=!!c(e=e||{},"ACCESSORS")&&e.ACCESSORS,i=c(e,0)?e[0]:Wr,o=c(e,1)?e[1]:void 0;return!!n&&!m(function(){if(r&&!f)return!0;function t(t){r?Yr(e,t,{enumerable:!0,get:Wr}):e[t]=1}var e={length:-1};t(1),t(2147483646),t(4294967294),n.call(e,i,o)})}var Qr=Array.isArray||function(t){return"Array"==J(t)},Hr=i("species"),zr=[].push,Gr={forEach:jr(0),map:jr(1),filter:jr(2),some:jr(3),every:jr(4),find:jr(5),findIndex:jr(6)},Yr=Object.defineProperty,Xr=Gr.find,Jr="find",$r=!0,Zr=Kr(Jr);Jr in[]&&Array(1)[Jr](function(){$r=!1}),mt({target:"Array",proto:!0,forced:$r||!Zr},{find:function(t,e){return Xr(this,t,1<arguments.length?e:void 0)}}),Pe(Jr);function ti(t,e,n){return Xe(ei,b[t].prototype[e],n)}var ei=Function.call,ni=(ti("Array","find"),Gr.findIndex),ri="findIndex",ii=!0,oi=Kr(ri);ri in[]&&Array(1)[ri](function(){ii=!1}),mt({target:"Array",proto:!0,forced:ii||!oi},{findIndex:function(t,e){return ni(this,t,1<arguments.length?e:void 0)}}),Pe(ri);function ai(t,e,n){var r=o(e);r in t?w.f(t,r,v(0,n)):t[r]=n}ti("Array","findIndex");var si=!hn(function(t){Array.from(t)});mt({target:"Array",stat:!0,forced:si},{from:function(t,e,n){var r,i,o,a,s,u,c=gt(t),h="function"==typeof this?this:Array,l=arguments.length,f=1<l?e:void 0,p=void 0!==f,d=Je(c),y=0;if(p&&(f=Xe(f,2<l?n:void 0,2)),null==d||h==Array&&Ye(d))for(i=new h(r=lt(c.length));y<r;y++)u=p?f(c[y],y):c[y],ai(i,y,u);else for(s=(a=d.call(c)).next,i=new h;!(o=s.call(a)).done;y++)u=p?$e(a,f,[o.value,y],!0):o.value,ai(i,y,u);return i.length=y,i}});Rt.Array.from;var ui,ci,hi=Gr.some,li=!!(ci=[]["some"])&&m(function(){ci.call(null,ui||function(){throw 1},1)}),fi=Kr("some");mt({target:"Array",proto:!0,forced:!li||!fi},{some:function(t,e){return hi(this,t,1<arguments.length?e:void 0)}});ti("Array","some");function pi(t){return g(t)&&c(Ni,rt(t))}var di,yi="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView,mi=w.f,gi=b.Int8Array,vi=gi&&gi.prototype,bi=b.Uint8ClampedArray,wi=bi&&bi.prototype,_i=gi&&Jt(gi),Ei=vi&&Jt(vi),Ti=Object.prototype,Si=(Ti.isPrototypeOf,i("toStringTag")),Ii=s("TYPED_ARRAY_TAG"),Ci=yi&&!!we&&"Opera"!==rt(b.opera),Ni={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8};for(di in Ni)b[di]||(Ci=!1);if((!Ci||"function"!=typeof _i||_i===Function.prototype)&&(_i=function(){throw TypeError("Incorrect invocation")},Ci))for(di in Ni)b[di]&&we(b[di],_i);if((!Ci||!Ei||Ei===Ti)&&(Ei=_i.prototype,Ci))for(di in Ni)b[di]&&we(b[di].prototype,Ei);if(Ci&&Jt(wi)!==Ei&&we(wi,Ei),f&&!c(Ei,Si))for(di in!0,mi(Ei,Si,{get:function(){return g(this)?this[Ii]:void 0}}),Ni)b[di]&&_(b[di],Ii,di);function Ai(){return Pi.call(Li(this))}var Di=function(t){if(pi(t))return t;throw TypeError("Target is not a typed array")},ki=function(t,e,n){if(f){if(n)for(var r in Ni){var i=b[r];i&&c(i.prototype,t)&&delete i.prototype[t]}Ei[t]&&!n||Z(Ei,t,n?e:Ci&&vi[t]||e)}},Ri=i("iterator"),Oi=b.Uint8Array,Pi=Fe.values,xi=Fe.keys,Mi=Fe.entries,Li=Di,Fi=ki,Ui=Oi&&Oi.prototype[Ri],Vi=!!Ui&&("values"==Ui.name||null==Ui.name);Fi("entries",function(){return Mi.call(Li(this))}),Fi("keys",function(){return xi.call(Li(this))}),Fi("values",Ai,!Vi),Fi(Ri,Ai,!Vi);var qi=Object.assign,Bi=Object.defineProperty,ji=!qi||m(function(){if(f&&1!==qi({b:1},qi(Bi({},"a",{enumerable:!0,get:function(){Bi(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var t={},e={},n=Symbol(),r="abcdefghijklmnopqrst";return t[n]=7,r.split("").forEach(function(t){e[t]=t}),7!=qi({},t)[n]||ie(qi({},e)).join("")!=r})?function(t,e){for(var n=gt(t),r=arguments.length,i=1,o=Vt.f,a=Ct.f;i<r;)for(var s,u=At(arguments[i++]),c=o?ie(u).concat(o(u)):ie(u),h=c.length,l=0;l<h;)s=c[l++],f&&!a.call(u,s)||(n[s]=u[s]);return n}:qi;mt({target:"Object",stat:!0,forced:Object.assign!==ji},{assign:ji});Rt.Object.assign;function Wi(s){return function(t){for(var e,n=ut(t),r=ie(n),i=r.length,o=0,a=[];o<i;)e=r[o++],f&&!Ki.call(n,e)||a.push(s?[e,n[e]]:n[e]);return a}}var Ki=Ct.f,Qi={entries:Wi(!0),values:Wi(!1)},Hi=Qi.entries;mt({target:"Object",stat:!0},{entries:function(t){return Hi(t)}});Rt.Object.entries;var zi=Qi.values;mt({target:"Object",stat:!0},{values:function(t){return zi(t)}});Rt.Object.values;function Gi(t){if(function(t){var e;return g(t)&&(void 0!==(e=t[Xi])?!!e:"RegExp"==J(t))}(t))throw TypeError("The method doesn't accept regular expressions");return t}function Yi(e){var n=/./;try{"/./"[e](n)}catch(t){try{return n[Ji]=!1,"/./"[e](n)}catch(t){}}return!1}var Xi=i("match"),Ji=i("match");mt({target:"String",proto:!0,forced:!Yi("includes")},{includes:function(t,e){return!!~String(at(this)).indexOf(Gi(t),1<arguments.length?e:void 0)}});ti("String","includes");var $i,Zi=kt.f,to="".startsWith,eo=Math.min,no=Yi("startsWith"),ro=!(no||(!($i=Zi(String.prototype,"startsWith"))||$i.writable));mt({target:"String",proto:!0,forced:!ro&&!no},{startsWith:function(t,e){var n=String(at(this));Gi(t);var r=lt(eo(1<arguments.length?e:void 0,n.length)),i=String(t);return to?to.call(n,i,r):n.slice(r,r+i.length)===i}});ti("String","startsWith");mt({target:"String",proto:!0},{repeat:"".repeat||function(t){var e=String(at(this)),n="",r=ot(t);if(r<0||r==1/0)throw RangeError("Wrong number of repetitions");for(;0<r;(r>>>=1)&&(e+=e))1&r&&(n+=e);return n}});ti("String","repeat");function io(t){if(!g(t))return!1;var e=t[so];return void 0!==e?!!e:Qr(t)}var oo,ao=i("species"),so=i("isConcatSpreadable"),uo=9007199254740991,co="Maximum allowed index exceeded",ho=51<=pr||!m(function(){var t=[];return t[so]=!1,t.concat()[0]!==t}),lo=(oo="concat",51<=pr||!m(function(){var t=[];return(t.constructor={})[ao]=function(){return{foo:1}},1!==t[oo](Boolean).foo}));mt({target:"Array",proto:!0,forced:!ho||!lo},{concat:function(t){var e,n,r,i,o,a=gt(this),s=Br(a,0),u=0;for(e=-1,r=arguments.length;e<r;e++)if(io(o=-1===e?a:arguments[e])){if(i=lt(o.length),uo<u+i)throw TypeError(co);for(n=0;n<i;n++,u++)n in o&&ai(s,u,o[n])}else{if(uo<=u)throw TypeError(co);ai(s,u++,o)}return s.length=u,s}});function fo(t){var e=Rt.Symbol||(Rt.Symbol={});c(e,t)||To(e,t,{value:Eo.f(t)})}function po(t,e){var n=Uo[t]=ye(Oo[No]);return Do(n,{type:Co,tag:t,description:e}),f||(n.description=e),n}function yo(e,t){d(e);var n=ut(t),r=ie(n).concat(Yo(n));return So(r,function(t){f&&!Go.call(n,t)||zo(e,t,n[t])}),e}function mo(t,e){var n=ut(t),r=o(e,!0);if(n!==Ro||!c(Uo,r)||c(Vo,r)){var i=xo(n,r);return!i||!c(Uo,r)||c(n,Io)&&n[Io][r]||(i.enumerable=!0),i}}function go(t){var e=Lo(ut(t)),n=[];return So(e,function(t){c(Uo,t)||c(K,t)||n.push(t)}),n}var vo=Ut.f,bo={}.toString,wo="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],_o={f:function(t){return wo&&"[object Window]"==bo.call(t)?function(t){try{return vo(t)}catch(t){return wo.slice()}}(t):vo(ut(t))}},Eo={f:i},To=w.f,So=Gr.forEach,Io=L("hidden"),Co="Symbol",No="prototype",Ao=i("toPrimitive"),Do=$.set,ko=$.getterFor(Co),Ro=Object[No],Oo=b.Symbol,Po=ht("JSON","stringify"),xo=kt.f,Mo=w.f,Lo=_o.f,Fo=Ct.f,Uo=S("symbols"),Vo=S("op-symbols"),qo=S("string-to-symbol-registry"),Bo=S("symbol-to-string-registry"),jo=S("wks"),Wo=b.QObject,Ko=!Wo||!Wo[No]||!Wo[No].findChild,Qo=f&&m(function(){return 7!=ye(Mo({},"a",{get:function(){return Mo(this,"a",{value:7}).a}})).a})?function(t,e,n){var r=xo(Ro,e);r&&delete Ro[e],Mo(t,e,n),r&&t!==Ro&&Mo(Ro,e,r)}:Mo,Ho=D?function(t){return"symbol"==typeof t}:function(t){return Object(t)instanceof Oo},zo=function(t,e,n){t===Ro&&zo(Vo,e,n),d(t);var r=o(e,!0);return d(n),c(Uo,r)?(n.enumerable?(c(t,Io)&&t[Io][r]&&(t[Io][r]=!1),n=ye(n,{enumerable:v(0,!1)})):(c(t,Io)||Mo(t,Io,v(1,{})),t[Io][r]=!0),Qo(t,r,n)):Mo(t,r,n)},Go=function(t){var e=o(t,!0),n=Fo.call(this,e);return!(this===Ro&&c(Uo,e)&&!c(Vo,e))&&(!(n||!c(this,e)||!c(Uo,e)||c(this,Io)&&this[Io][e])||n)},Yo=function(t){var e=t===Ro,n=Lo(e?Vo:ut(t)),r=[];return So(n,function(t){!c(Uo,t)||e&&!c(Ro,t)||r.push(Uo[t])}),r};if(A||(Z((Oo=function(t){if(this instanceof Oo)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===Ro&&r.call(Vo,t),c(this,Io)&&c(this[Io],n)&&(this[Io][n]=!1),Qo(this,n,v(1,t))};return f&&Ko&&Qo(Ro,n,{configurable:!0,set:r}),po(n,e)})[No],"toString",function(){return ko(this).tag}),Z(Oo,"withoutSetter",function(t){return po(s(t),t)}),Ct.f=Go,w.f=zo,kt.f=mo,Ut.f=_o.f=go,Vt.f=Yo,Eo.f=function(t){return po(i(t),t)},f&&(Mo(Oo[No],"description",{configurable:!0,get:function(){return ko(this).description}}),Z(Ro,"propertyIsEnumerable",Go,{unsafe:!0}))),mt({global:!0,wrap:!0,forced:!A,sham:!A},{Symbol:Oo}),So(ie(jo),function(t){fo(t)}),mt({target:Co,stat:!0,forced:!A},{for:function(t){var e=String(t);if(c(qo,e))return qo[e];var n=Oo(e);return qo[e]=n,Bo[n]=e,n},keyFor:function(t){if(!Ho(t))throw TypeError(t+" is not a symbol");if(c(Bo,t))return Bo[t]},useSetter:function(){Ko=!0},useSimple:function(){Ko=!1}}),mt({target:"Object",stat:!0,forced:!A,sham:!f},{create:function(t,e){return void 0===e?ye(t):yo(ye(t),e)},defineProperty:zo,defineProperties:yo,getOwnPropertyDescriptor:mo}),mt({target:"Object",stat:!0,forced:!A},{getOwnPropertyNames:go,getOwnPropertySymbols:Yo}),mt({target:"Object",stat:!0,forced:m(function(){Vt.f(1)})},{getOwnPropertySymbols:function(t){return Vt.f(gt(t))}}),Po){var Xo=!A||m(function(){var t=Oo();return"[null]"!=Po([t])||"{}"!=Po({a:t})||"{}"!=Po(Object(t))});mt({target:"JSON",stat:!0,forced:Xo},{stringify:function(t,e,n){for(var r,i=[t],o=1;o<arguments.length;)i.push(arguments[o++]);if((g(r=e)||void 0!==t)&&!Ho(t))return Qr(e)||(e=function(t,e){if("function"==typeof r&&(e=r.call(this,t,e)),!Ho(e))return e}),i[1]=e,Po.apply(null,i)}})}Oo[No][Ao]||_(Oo[No],Ao,Oo[No].valueOf),le(Oo,Co),K[Io]=!0,fo("asyncIterator");var Jo=w.f,$o=b.Symbol;if(!(!f||"function"!=typeof $o||"description"in $o.prototype&&void 0===$o().description)){var Zo={},ta=function(t){var e=arguments.length<1||void 0===t?void 0:String(t),n=this instanceof ta?new $o(e):void 0===e?$o():$o(e);return""===e&&(Zo[n]=!0),n};dt(ta,$o);var ea=ta.prototype=$o.prototype;ea.constructor=ta;var na=ea.toString,ra="Symbol(test)"==String($o("test")),ia=/^Symbol\((.*)\)[^)]+$/;Jo(ea,"description",{configurable:!0,get:function(){var t=g(this)?this.valueOf():this,e=na.call(t);if(c(Zo,t))return"";var n=ra?e.slice(7,-1):e.replace(ia,"$1");return""===n?void 0:n}}),mt({global:!0,forced:!0},{Symbol:ta})}fo("hasInstance"),fo("isConcatSpreadable"),fo("iterator"),fo("match"),fo("matchAll"),fo("replace"),fo("search"),fo("species"),fo("split"),fo("toPrimitive"),fo("toStringTag"),fo("unscopables"),le(Math,"Math",!0),le(b.JSON,"JSON",!0);Rt.Symbol;fo("asyncDispose"),fo("dispose"),fo("observable"),fo("patternMatch"),fo("replaceAll");Eo.f("iterator");function oa(r,t,e){function n(t){var n=u[t];Z(u,t,"add"==t?function(t){return n.call(this,0===t?0:t),this}:"delete"==t?function(t){return!(o&&!g(t))&&n.call(this,0===t?0:t)}:"get"==t?function(t){return o&&!g(t)?void 0:n.call(this,0===t?0:t)}:"has"==t?function(t){return!(o&&!g(t))&&n.call(this,0===t?0:t)}:function(t,e){return n.call(this,0===t?0:t,e),this})}var i=-1!==r.indexOf("Map"),o=-1!==r.indexOf("Weak"),a=i?"set":"add",s=b[r],u=s&&s.prototype,c=s,h={};if(Ht(r,"function"!=typeof s||!(o||u.forEach&&!m(function(){(new s).entries().next()}))))c=e.getConstructor(t,r,i,a),ua.REQUIRED=!0;else if(Ht(r,!0)){var l=new c,f=l[a](o?{}:-0,1)!=l,p=m(function(){l.has(1)}),d=hn(function(t){new s(t)}),y=!o&&m(function(){for(var t=new s,e=5;e--;)t[a](e,e);return!t.has(-0)});d||(((c=t(function(t,e){Ge(t,c,r);var n=function(t,e,n){var r,i;return we&&"function"==typeof(r=e.constructor)&&r!==n&&g(i=r.prototype)&&i!==n.prototype&&we(t,i),t}(new s,t,c);return null!=e&&on(e,n[a],n,i),n})).prototype=u).constructor=c),(p||y)&&(n("delete"),n("has"),i&&n("get")),(y||f)&&n(a),o&&u.clear&&delete u.clear}return h[r]=c,mt({global:!0,forced:c!=s},h),le(c,r),o||e.setStrong(c,r,i),c}function aa(t,e,n){var r,i,o,a,s=arguments.length,u=1<s?e:void 0;return ze(this),(r=void 0!==u)&&ze(u),null==t?new this:(i=[],r?(o=0,a=Xe(u,2<s?n:void 0,2),on(t,function(t){i.push(a(t,o++))})):on(t,i.push,i),new this(i))}var sa=!m(function(){return Object.isExtensible(Object.preventExtensions({}))}),ua=e(function(t){function n(t){e(t,r,{value:{objectID:"O"+ ++i,weakData:{}}})}var e=w.f,r=s("meta"),i=0,o=Object.isExtensible||function(){return!0},a=t.exports={REQUIRED:!1,fastKey:function(t,e){if(!g(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!c(t,r)){if(!o(t))return"F";if(!e)return"E";n(t)}return t[r].objectID},getWeakData:function(t,e){if(!c(t,r)){if(!o(t))return!0;if(!e)return!1;n(t)}return t[r].weakData},onFreeze:function(t){return sa&&a.REQUIRED&&o(t)&&!c(t,r)&&n(t),t}};K[r]=!0}),ca=(ua.REQUIRED,ua.fastKey,ua.getWeakData,ua.onFreeze,w.f),ha=ua.fastKey,la=$.set,fa=$.getterFor,pa={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=ha(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){Ge(t,a,n),la(t,{type:n,index:ye(null),first:void 0,last:void 0,size:0}),f||(t.size=0),null!=e&&on(e,t[i],t,r)}),s=fa(n),u=function(t,e){var n,r=s(t),i=ha(e);if("F"!==i)return r.index[i];for(n=r.first;n;n=n.next)if(n.key==e)return n};return Qe(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=Xe(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)}}),Qe(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&&ca(a.prototype,"size",{get:function(){return s(this).size}}),a},setStrong:function(t,e,n){var r=e+" Iterator",i=fa(e),o=fa(r);de(t,e,function(t,e){la(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),He(e)}};oa("Map",function(e){return function(t){return e(this,arguments.length?t:void 0)}},pa),Rt.Map;mt({target:"Map",stat:!0},{from:aa});function da(){for(var t=arguments.length,e=new Array(t);t--;)e[t]=arguments[t];return new this(e)}mt({target:"Map",stat:!0},{of:da});function ya(){for(var t,e=d(this),n=ze(e.delete),r=!0,i=0,o=arguments.length;i<o;i++)t=n.call(e,arguments[i]),r=r&&t;return!!r}mt({target:"Map",proto:!0,real:!0,forced:a},{deleteAll:function(){return ya.apply(this,arguments)}});function ma(t){return Map.prototype.entries.call(t)}mt({target:"Map",proto:!0,real:!0,forced:a},{every:function(t,e){var n=d(this),r=ma(n),i=Xe(t,1<arguments.length?e:void 0,3);return!on(r,function(t,e){if(!i(e,t,n))return on.stop()},void 0,!0,!0).stopped}}),mt({target:"Map",proto:!0,real:!0,forced:a},{filter:function(t,e){var n=d(this),r=ma(n),i=Xe(t,1<arguments.length?e:void 0,3),o=new(ln(n,ht("Map"))),a=ze(o.set);return on(r,function(t,e){i(e,t,n)&&a.call(o,t,e)},void 0,!0,!0),o}}),mt({target:"Map",proto:!0,real:!0,forced:a},{find:function(t,e){var n=d(this),r=ma(n),i=Xe(t,1<arguments.length?e:void 0,3);return on(r,function(t,e){if(i(e,t,n))return on.stop(e)},void 0,!0,!0).result}}),mt({target:"Map",proto:!0,real:!0,forced:a},{findKey:function(t,e){var n=d(this),r=ma(n),i=Xe(t,1<arguments.length?e:void 0,3);return on(r,function(t,e){if(i(e,t,n))return on.stop(t)},void 0,!0,!0).result}}),mt({target:"Map",stat:!0},{groupBy:function(t,n){var r=new this;ze(n);var i=ze(r.has),o=ze(r.get),a=ze(r.set);return on(t,function(t){var e=n(t);i.call(r,e)?o.call(r,e).push(t):a.call(r,e,[t])}),r}});mt({target:"Map",proto:!0,real:!0,forced:a},{includes:function(n){return on(ma(d(this)),function(t,e){if(function(t,e){return t===e||t!=t&&e!=e}(e,n))return on.stop()},void 0,!0,!0).stopped}}),mt({target:"Map",stat:!0},{keyBy:function(t,e){var n=new this;ze(e);var r=ze(n.set);return on(t,function(t){r.call(n,e(t),t)}),n}}),mt({target:"Map",proto:!0,real:!0,forced:a},{keyOf:function(n){return on(ma(d(this)),function(t,e){if(e===n)return on.stop(t)},void 0,!0,!0).result}}),mt({target:"Map",proto:!0,real:!0,forced:a},{mapKeys:function(t,e){var n=d(this),r=ma(n),i=Xe(t,1<arguments.length?e:void 0,3),o=new(ln(n,ht("Map"))),a=ze(o.set);return on(r,function(t,e){a.call(o,i(e,t,n),e)},void 0,!0,!0),o}}),mt({target:"Map",proto:!0,real:!0,forced:a},{mapValues:function(t,e){var n=d(this),r=ma(n),i=Xe(t,1<arguments.length?e:void 0,3),o=new(ln(n,ht("Map"))),a=ze(o.set);return on(r,function(t,e){a.call(o,t,i(e,t,n))},void 0,!0,!0),o}}),mt({target:"Map",proto:!0,real:!0,forced:a},{merge:function(t){for(var e=d(this),n=ze(e.set),r=0;r<arguments.length;)on(arguments[r++],n,e,!0);return e}}),mt({target:"Map",proto:!0,real:!0,forced:a},{reduce:function(n,t){var r=d(this),e=ma(r),i=arguments.length<2,o=i?void 0:t;if(ze(n),on(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}}),mt({target:"Map",proto:!0,real:!0,forced:a},{some:function(t,e){var n=d(this),r=ma(n),i=Xe(t,1<arguments.length?e:void 0,3);return on(r,function(t,e){if(i(e,t,n))return on.stop()},void 0,!0,!0).stopped}}),mt({target:"Map",proto:!0,real:!0,forced:a},{update:function(t,e,n){var r=d(this),i=arguments.length;ze(e);var o=r.has(t);if(!o&&i<3)throw TypeError("Updating absent value");var a=o?r.get(t):ze(2<i?n:void 0)(t,r);return r.set(t,e(a,t,r)),r}});function ga(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}mt({target:"Map",proto:!0,real:!0,forced:a},{upsert:ga}),mt({target:"Map",proto:!0,real:!0,forced:a},{updateOrInsert:ga});oa("Set",function(e){return function(t){return e(this,arguments.length?t:void 0)}},pa),Rt.Set;mt({target:"Set",stat:!0},{from:aa}),mt({target:"Set",stat:!0},{of:da});mt({target:"Set",proto:!0,real:!0,forced:a},{addAll:function(){return function(){for(var t=d(this),e=ze(t.add),n=0,r=arguments.length;n<r;n++)e.call(t,arguments[n]);return t}.apply(this,arguments)}}),mt({target:"Set",proto:!0,real:!0,forced:a},{deleteAll:function(){return ya.apply(this,arguments)}});function va(t){return Set.prototype.values.call(t)}mt({target:"Set",proto:!0,real:!0,forced:a},{every:function(t,e){var n=d(this),r=va(n),i=Xe(t,1<arguments.length?e:void 0,3);return!on(r,function(t){if(!i(t,t,n))return on.stop()},void 0,!1,!0).stopped}}),mt({target:"Set",proto:!0,real:!0,forced:a},{difference:function(t){var e=d(this),n=new(ln(e,ht("Set")))(e),r=ze(n.delete);return on(t,function(t){r.call(n,t)}),n}}),mt({target:"Set",proto:!0,real:!0,forced:a},{filter:function(t,e){var n=d(this),r=va(n),i=Xe(t,1<arguments.length?e:void 0,3),o=new(ln(n,ht("Set"))),a=ze(o.add);return on(r,function(t){i(t,t,n)&&a.call(o,t)},void 0,!1,!0),o}}),mt({target:"Set",proto:!0,real:!0,forced:a},{find:function(t,e){var n=d(this),r=va(n),i=Xe(t,1<arguments.length?e:void 0,3);return on(r,function(t){if(i(t,t,n))return on.stop(t)},void 0,!1,!0).result}}),mt({target:"Set",proto:!0,real:!0,forced:a},{intersection:function(t){var e=d(this),n=new(ln(e,ht("Set"))),r=ze(e.has),i=ze(n.add);return on(t,function(t){r.call(e,t)&&i.call(n,t)}),n}}),mt({target:"Set",proto:!0,real:!0,forced:a},{isDisjointFrom:function(t){var e=d(this),n=ze(e.has);return!on(t,function(t){if(!0===n.call(e,t))return on.stop()}).stopped}}),mt({target:"Set",proto:!0,real:!0,forced:a},{isSubsetOf:function(t){var e=function(t){var e=Je(t);if("function"!=typeof e)throw TypeError(String(t)+" is not iterable");return d(e.call(t))}(this),n=d(t),r=n.has;return"function"!=typeof r&&(n=new(ht("Set"))(t),r=ze(n.has)),!on(e,function(t){if(!1===r.call(n,t))return on.stop()},void 0,!1,!0).stopped}}),mt({target:"Set",proto:!0,real:!0,forced:a},{isSupersetOf:function(t){var e=d(this),n=ze(e.has);return!on(t,function(t){if(!1===n.call(e,t))return on.stop()}).stopped}}),mt({target:"Set",proto:!0,real:!0,forced:a},{join:function(t){var e=d(this),n=va(e),r=void 0===t?",":String(t),i=[];return on(n,i.push,i,!1,!0),i.join(r)}}),mt({target:"Set",proto:!0,real:!0,forced:a},{map:function(t,e){var n=d(this),r=va(n),i=Xe(t,1<arguments.length?e:void 0,3),o=new(ln(n,ht("Set"))),a=ze(o.add);return on(r,function(t){a.call(o,i(t,t,n))},void 0,!1,!0),o}}),mt({target:"Set",proto:!0,real:!0,forced:a},{reduce:function(e,t){var n=d(this),r=va(n),i=arguments.length<2,o=i?void 0:t;if(ze(e),on(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}}),mt({target:"Set",proto:!0,real:!0,forced:a},{some:function(t,e){var n=d(this),r=va(n),i=Xe(t,1<arguments.length?e:void 0,3);return on(r,function(t){if(i(t,t,n))return on.stop()},void 0,!1,!0).stopped}}),mt({target:"Set",proto:!0,real:!0,forced:a},{symmetricDifference:function(t){var e=d(this),n=new(ln(e,ht("Set")))(e),r=ze(n.delete),i=ze(n.add);return on(t,function(t){r.call(n,t)||i.call(n,t)}),n}}),mt({target:"Set",proto:!0,real:!0,forced:a},{union:function(t){var e=d(this),n=new(ln(e,ht("Set")))(e);return on(t,ze(n.add),n),n}});var ba=Math.floor;mt({target:"Number",stat:!0},{isInteger:function(t){return!g(t)&&isFinite(t)&&ba(t)===t}});Rt.Number.isInteger;var wa=function(t,e){return(wa=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 _a(t,e){function n(){this.constructor=t}wa(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var Ea=function(){return(Ea=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 Ta(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 Sa(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 Ia(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 Ca(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 Na(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Ca(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 Da(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 ka(t){try{return xa.decodeString(t,!0)}catch(t){console.error("base64Decode failed: ",t)}return null}var Ra={NODE_CLIENT:!1,NODE_ADMIN:!1,SDK_VERSION:"${JSCORE_VERSION}"},Oa=function(t,e){if(!t)throw Pa(e)},Pa=function(t){return new Error("Firebase Database ("+Ra.SDK_VERSION+") INTERNAL ASSERT FAILED: "+t)},xa={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(Da(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 Ma(t){return La(void 0,t)}function La(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]=La(t[n],e[n]));return t}var Fa=(Ua.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))}},Ua);function Ua(){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 qa(){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 ja(){return!0===Ra.NODE_ADMIN}var Wa,Ka=(_a(Qa,Wa=Error),Qa);function Qa(t,e){var n=Wa.call(this,e)||this;return n.code=t,n.name="FirebaseError",Object.setPrototypeOf(n,Qa.prototype),Error.captureStackTrace&&Error.captureStackTrace(n,Ha.prototype.create),n}var Ha=(za.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(Ga,function(t,e){var n=r[e];return null!=n?n.toString():"<"+e+"?>"})}(o,r):"Error",s=this.serviceName+": "+a+" ("+i+").",u=new Ka(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},za);function za(t,e,n){this.service=t,this.serviceName=e,this.errors=n}var Ga=/\{\$([^}]+)}/g;function Ya(t){return JSON.parse(t)}function Xa(t){return JSON.stringify(t)}function Ja(t){var e={},n={},r={},i="";try{var o=t.split(".");e=Ya(ka(o[0])||""),n=Ya(ka(o[1])||""),i=o[2],r=n.d||{},delete n.d}catch(t){}return{header:e,claims:n,data:r,signature:i}}function $a(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function Za(t,e){return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0}function ts(t){for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}function es(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 ns=(rs.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},rs.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},rs.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}},rs.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},rs);function rs(){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 is(t,e){var n=new os(t,e);return n.subscribe.bind(n)}var os=(as.prototype.next=function(e){this.forEachObserver(function(t){t.next(e)})},as.prototype.error=function(e){this.forEachObserver(function(t){t.error(e)}),this.close(e)},as.prototype.complete=function(){this.forEachObserver(function(t){t.complete()}),this.close()},as.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=ss),void 0===r.error&&(r.error=ss),void 0===r.complete&&(r.complete=ss);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},as.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))},as.prototype.forEachObserver=function(t){if(!this.finalized)for(var e=0;e<this.observers.length;e++)this.sendOne(e,t)},as.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)}})},as.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}))},as);function as(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 ss(){}function us(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 cs(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 hs(t,e,n,r){if((!r||n)&&"function"!=typeof n)throw new Error(cs(t,e,r)+"must be a valid function.")}function ls(t,e,n,r){if((!r||n)&&("object"!=typeof n||null===n))throw new Error(cs(t,e,r)+"must be a valid context object.")}function fs(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 ps=(ds.prototype.setInstantiationMode=function(t){return this.instantiationMode=t,this},ds.prototype.setMultipleInstances=function(t){return this.multipleInstances=t,this},ds.prototype.setServiceProps=function(t){return this.serviceProps=t,this},ds);function ds(t,e,n){this.name=t,this.instanceFactory=e,this.type=n,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY"}var ys="[DEFAULT]",ms=(gs.prototype.get=function(t){void 0===t&&(t=ys);var e=this.normalizeInstanceIdentifier(t);if(!this.instancesDeferred.has(e)){var n=new Fa;this.instancesDeferred.set(e,n);try{var r=this.getOrInitializeService(e);r&&n.resolve(r)}catch(t){}}return this.instancesDeferred.get(e).promise},gs.prototype.getImmediate=function(t){var e=Ea({identifier:ys,optional:!1},t),n=e.identifier,r=e.optional,i=this.normalizeInstanceIdentifier(n);try{var o=this.getOrInitializeService(i);if(o)return o;if(r)return null;throw Error("Service "+this.name+" is not available")}catch(t){if(r)return null;throw t}},gs.prototype.getComponent=function(){return this.component},gs.prototype.setComponent=function(t){var e,n;if(t.name!==this.name)throw Error("Mismatching Component "+t.name+" for Provider "+this.name+".");if(this.component)throw Error("Component for "+this.name+" has already been provided");if(function(t){return"EAGER"===t.instantiationMode}(this.component=t))try{this.getOrInitializeService(ys)}catch(t){}try{for(var r=Ia(this.instancesDeferred.entries()),i=r.next();!i.done;i=r.next()){var o=Ca(i.value,2),a=o[0],s=o[1],u=this.normalizeInstanceIdentifier(a);try{var c=this.getOrInitializeService(u);s.resolve(c)}catch(t){}}}catch(t){e={error:t}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}},gs.prototype.clearInstance=function(t){void 0===t&&(t=ys),this.instancesDeferred.delete(t),this.instances.delete(t)},gs.prototype.delete=function(){return Ta(this,void 0,void 0,function(){var e;return Sa(this,function(t){switch(t.label){case 0:return e=Array.from(this.instances.values()),[4,Promise.all(e.filter(function(t){return"INTERNAL"in t}).map(function(t){return t.INTERNAL.delete()}))];case 1:return t.sent(),[2]}})})},gs.prototype.isComponentSet=function(){return null!=this.component},gs.prototype.getOrInitializeService=function(t){var e=this.instances.get(t);return!e&&this.component&&(e=this.component.instanceFactory(this.container,function(t){return t===ys?void 0:t}(t)),this.instances.set(t,e)),e||null},gs.prototype.normalizeInstanceIdentifier=function(t){return this.component?this.component.multipleInstances?t:ys:t},gs);function gs(t,e){this.name=t,this.container=e,this.component=null,this.instances=new Map,this.instancesDeferred=new Map}var vs,bs,ws=(_s.prototype.addComponent=function(t){var e=this.getProvider(t.name);if(e.isComponentSet())throw new Error("Component "+t.name+" has already been registered with "+this.name);e.setComponent(t)},_s.prototype.addOrOverwriteComponent=function(t){this.getProvider(t.name).isComponentSet()&&this.providers.delete(t.name),this.addComponent(t)},_s.prototype.getProvider=function(t){if(this.providers.has(t))return this.providers.get(t);var e=new ms(t,this);return this.providers.set(t,e),e},_s.prototype.getProviders=function(){return Array.from(this.providers.values())},_s);function _s(t){this.name=t,this.providers=new Map}function Es(){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}(bs=vs=vs||{})[bs.DEBUG=0]="DEBUG",bs[bs.VERBOSE=1]="VERBOSE",bs[bs.INFO=2]="INFO",bs[bs.WARN=3]="WARN",bs[bs.ERROR=4]="ERROR",bs[bs.SILENT=5]="SILENT";function Ts(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 vs.DEBUG:case vs.VERBOSE:console.log.apply(console,Es(["["+i+"] "+t.name+":"],n));break;case vs.INFO:console.info.apply(console,Es(["["+i+"] "+t.name+":"],n));break;case vs.WARN:console.warn.apply(console,Es(["["+i+"] "+t.name+":"],n));break;case vs.ERROR:console.error.apply(console,Es(["["+i+"] "+t.name+":"],n));break;default:throw new Error("Attempted to log a message with an invalid logType (value: "+e+")")}}}var Ss,Is=vs.INFO,Cs=(Object.defineProperty(Ns.prototype,"logLevel",{get:function(){return this._logLevel},set:function(t){if(!(t in vs))throw new TypeError("Invalid value assigned to `logLevel`");this._logLevel=t},enumerable:!0,configurable:!0}),Object.defineProperty(Ns.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}),Ns.prototype.debug=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._logHandler.apply(this,Es([this,vs.DEBUG],t))},Ns.prototype.log=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._logHandler.apply(this,Es([this,vs.VERBOSE],t))},Ns.prototype.info=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._logHandler.apply(this,Es([this,vs.INFO],t))},Ns.prototype.warn=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._logHandler.apply(this,Es([this,vs.WARN],t))},Ns.prototype.error=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._logHandler.apply(this,Es([this,vs.ERROR],t))},Ns);function Ns(t){this.name=t,this._logLevel=Is,this._logHandler=Ts}var As,Ds=((Ss={})["no-app"]="No Firebase App '{$appName}' has been created - call Firebase App.initializeApp()",Ss["bad-app-name"]="Illegal App name: '{$appName}",Ss["duplicate-app"]="Firebase App named '{$appName}' already exists",Ss["app-deleted"]="Firebase App named '{$appName}' already deleted",Ss["invalid-app-argument"]="firebase.{$appName}() takes either no argument or a Firebase App instance.",Ss),ks=new Ha("app","Firebase",Ds),Rs="@firebase/app",Os="[DEFAULT]",Ps=((As={})[Rs]="fire-core",As["@firebase/analytics"]="fire-analytics",As["@firebase/auth"]="fire-auth",As["@firebase/database"]="fire-rtdb",As["@firebase/functions"]="fire-fn",As["@firebase/installations"]="fire-iid",As["@firebase/messaging"]="fire-fcm",As["@firebase/performance"]="fire-perf",As["@firebase/remote-config"]="fire-rc",As["@firebase/storage"]="fire-gcs",As["@firebase/firestore"]="fire-fst",As["fire-js"]="fire-js",As["firebase-wrapper"]="fire-js-all",As),xs=new Cs("@firebase/app"),Ms=(Object.defineProperty(Ls.prototype,"automaticDataCollectionEnabled",{get:function(){return this.checkDestroyed_(),this.automaticDataCollectionEnabled_},set:function(t){this.checkDestroyed_(),this.automaticDataCollectionEnabled_=t},enumerable:!0,configurable:!0}),Object.defineProperty(Ls.prototype,"name",{get:function(){return this.checkDestroyed_(),this.name_},enumerable:!0,configurable:!0}),Object.defineProperty(Ls.prototype,"options",{get:function(){return this.checkDestroyed_(),this.options_},enumerable:!0,configurable:!0}),Ls.prototype.delete=function(){var e=this;return new Promise(function(t){e.checkDestroyed_(),t()}).then(function(){return e.firebase_.INTERNAL.removeApp(e.name_),Promise.all(e.container.getProviders().map(function(t){return t.delete()}))}).then(function(){e.isDeleted_=!0})},Ls.prototype._getService=function(t,e){return void 0===e&&(e=Os),this.checkDestroyed_(),this.container.getProvider(t).getImmediate({identifier:e})},Ls.prototype._removeServiceInstance=function(t,e){void 0===e&&(e=Os),this.container.getProvider(t).clearInstance(e)},Ls.prototype._addComponent=function(e){try{this.container.addComponent(e)}catch(t){xs.debug("Component "+e.name+" failed to register with FirebaseApp "+this.name,t)}},Ls.prototype._addOrOverwriteComponent=function(t){this.container.addOrOverwriteComponent(t)},Ls.prototype.checkDestroyed_=function(){if(this.isDeleted_)throw ks.create("app-deleted",{appName:this.name_})},Ls);function Ls(t,e,n){var r,i,o=this;this.firebase_=n,this.isDeleted_=!1,this.name_=e.name,this.automaticDataCollectionEnabled_=e.automaticDataCollectionEnabled||!1,this.options_=Ma(t),this.container=new ws(e.name),this._addComponent(new ps("app",function(){return o},"PUBLIC"));try{for(var a=Ia(this.firebase_.INTERNAL.components.values()),s=a.next();!s.done;s=a.next()){var u=s.value;this._addComponent(u)}}catch(t){r={error:t}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}}Ms.prototype.name&&Ms.prototype.options||Ms.prototype.delete||console.log("dc");var Fs="7.8.0";function Us(u){var c={},h=new Map,l={__esModule:!0,initializeApp:function(t,e){void 0===e&&(e={});if("object"!=typeof e||null===e){e={name:e}}var n=e;void 0===n.name&&(n.name=Os);var r=n.name;if("string"!=typeof r||!r)throw ks.create("bad-app-name",{appName:String(r)});if($a(c,r))throw ks.create("duplicate-app",{appName:r});var i=new u(t,n,l);return c[r]=i},app:f,registerVersion:function(t,e,n){var r,i=null!==(r=Ps[t])&&void 0!==r?r:t;n&&(i+="-"+n);var o=i.match(/\s|\//),a=e.match(/\s|\//);if(o||a){var s=['Unable to register library "'+i+'" with version "'+e+'":'];return o&&s.push('library name "'+i+'" contains illegal characters (whitespace or "/")'),o&&a&&s.push("and"),a&&s.push('version name "'+e+'" contains illegal characters (whitespace or "/")'),void xs.warn(s.join(" "))}p(new ps(i+"-version",function(){return{library:i,version:e}},"VERSION"))},apps:null,SDK_VERSION:Fs,INTERNAL:{registerComponent:p,removeApp:function(t){delete c[t]},components:h,useAsService:function(t,e){return"serverAuth"!==e?e:null}}};function f(t){if(!$a(c,t=t||Os))throw ks.create("no-app",{appName:t});return c[t]}function p(n){var e,t,r=n.name;if(h.has(r))return xs.debug("There were multiple attempts to register component "+r+"."),"PUBLIC"===n.type?l[r]:null;if(h.set(r,n),"PUBLIC"===n.type){var i=function(t){if(void 0===t&&(t=f()),"function"!=typeof t[r])throw ks.create("invalid-app-argument",{appName:r});return t[r]()};void 0!==n.serviceProps&&La(i,n.serviceProps),l[r]=i,u.prototype[r]=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return this._getService.bind(this,r).apply(this,n.multipleInstances?t:[])}}try{for(var o=Ia(Object.keys(c)),a=o.next();!a.done;a=o.next()){var s=a.value;c[s]._addComponent(n)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}return"PUBLIC"===n.type?l[r]:null}return l.default=l,Object.defineProperty(l,"apps",{get:function(){return Object.keys(c).map(function(t){return c[t]})}}),f.App=u,l}var Vs=function t(){var e=Us(Ms);return e.INTERNAL=Ea(Ea({},e.INTERNAL),{createFirebaseNamespace:t,extendNamespace:function(t){La(e,t)},createSubscribe:is,ErrorFactory:Ha,deepExtend:La}),e}(),qs=(Bs.prototype.getPlatformInfoString=function(){return this.container.getProviders().map(function(t){if(function(t){var e,n=t.getComponent();return"VERSION"===(null===(e=n)||void 0===e?void 0:e.type)}(t)){var e=t.getImmediate();return e.library+"/"+e.version}return null}).filter(function(t){return t}).join(" ")},Bs);function Bs(t){this.container=t}if("object"==typeof self&&self.self===self&&void 0!==self.firebase){xs.warn("\n Warning: Firebase is already defined in the global scope. Please make sure\n Firebase library is only loaded once.\n ");var js=self.firebase.SDK_VERSION;js&&0<=js.indexOf("LITE")&&xs.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 Ws=Vs.initializeApp;Vs.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}}()&&xs.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 '),Ws.apply(void 0,t)};var Ks,Qs,fl=Vs;(Ks=fl).INTERNAL.registerComponent(new ps("platform-logger",function(t){return new qs(t)},"PRIVATE")),Ks.registerVersion(Rs,"0.5.3",Qs),Ks.registerVersion("fire-js","");fl.registerVersion("firebase","7.8.0","app");(function(){var t,o="function"==typeof Object.defineProperties?Object.defineProperty:function(t,e,n){t!=Array.prototype&&t!=Object.prototype&&(t[e]=n.value)},a="undefined"!=typeof window&&window===this?this:"undefined"!=typeof global&&null!=global?global:this;function c(t){var e="undefined"!=typeof Symbol&&Symbol.iterator&&t[Symbol.iterator];return e?e.call(t):{next:function(t){var e=0;return function(){return e<t.length?{done:!1,value:t[e++]}:{done:!0}}}(t)}}!function(t,e){if(e){var n=a;t=t.split(".");for(var r=0;r<t.length-1;r++){var i=t[r];i in n||(n[i]={}),n=n[i]}(e=e(r=n[t=t[t.length-1]]))!=r&&null!=e&&o(n,t,{configurable:!0,writable:!0,value:e})}}("Promise",function(t){function s(t){this.b=0,this.c=void 0,this.a=[];var e=this.f();try{t(e.resolve,e.reject)}catch(t){e.reject(t)}}function e(){this.a=null}function u(e){return e instanceof s?e:new s(function(t){t(e)})}if(t)return t;e.prototype.b=function(t){if(null==this.a){this.a=[];var e=this;this.c(function(){e.g()})}this.a.push(t)};var n=a.setTimeout;e.prototype.c=function(t){n(t,0)},e.prototype.g=function(){for(;this.a&&this.a.length;){var t=this.a;this.a=[];for(var e=0;e<t.length;++e){var n=t[e];t[e]=null;try{n()}catch(t){this.f(t)}}}this.a=null},e.prototype.f=function(t){this.c(function(){throw t})},s.prototype.f=function(){function t(e){return function(t){r||(r=!0,e.call(n,t))}}var n=this,r=!1;return{resolve:t(this.m),reject:t(this.g)}},s.prototype.m=function(t){if(t===this)this.g(new TypeError("A Promise cannot resolve to itself"));else if(t instanceof s)this.o(t);else{t:switch(typeof t){case"object":var e=null!=t;break t;case"function":e=!0;break t;default:e=!1}e?this.u(t):this.h(t)}},s.prototype.u=function(t){var e=void 0;try{e=t.then}catch(t){return void this.g(t)}"function"==typeof e?this.v(e,t):this.h(t)},s.prototype.g=function(t){this.i(2,t)},s.prototype.h=function(t){this.i(1,t)},s.prototype.i=function(t,e){if(0!=this.b)throw Error("Cannot settle("+t+", "+e+"): Promise already settled in state"+this.b);this.b=t,this.c=e,this.l()},s.prototype.l=function(){if(null!=this.a){for(var t=0;t<this.a.length;++t)i.b(this.a[t]);this.a=null}};var i=new e;return s.prototype.o=function(t){var e=this.f();t.La(e.resolve,e.reject)},s.prototype.v=function(t,e){var n=this.f();try{t.call(e,n.resolve,n.reject)}catch(t){n.reject(t)}},s.prototype.then=function(t,e){function n(e,t){return"function"==typeof e?function(t){try{r(e(t))}catch(t){i(t)}}:t}var r,i,o=new s(function(t,e){r=t,i=e});return this.La(n(t,r),n(e,i)),o},s.prototype.catch=function(t){return this.then(void 0,t)},s.prototype.La=function(t,e){function n(){switch(r.b){case 1:t(r.c);break;case 2:e(r.c);break;default:throw Error("Unexpected state: "+r.b)}}var r=this;null==this.a?i.b(n):this.a.push(n)},s.resolve=u,s.reject=function(n){return new s(function(t,e){e(n)})},s.race=function(i){return new s(function(t,e){for(var n=c(i),r=n.next();!r.done;r=n.next())u(r.value).La(t,e)})},s.all=function(t){var o=c(t),a=o.next();return a.done?u([]):new s(function(n,t){function e(e){return function(t){r[e]=t,0==--i&&n(r)}}for(var r=[],i=0;r.push(void 0),i++,u(a.value).La(e(r.length-1),t),!(a=o.next()).done;);})},s});var u=u||{},l=this||self;function h(t){return"string"==typeof t}function n(t){return"boolean"==typeof t}var s=/^[\w+/_-]+[=]{0,2}$/,f=null;function p(){}function r(t){var e=typeof t;if("object"==e){if(!t)return"null";if(t instanceof Array)return"array";if(t instanceof Object)return e;var n=Object.prototype.toString.call(t);if("[object Window]"==n)return"object";if("[object Array]"==n||"number"==typeof t.length&&void 0!==t.splice&&void 0!==t.propertyIsEnumerable&&!t.propertyIsEnumerable("splice"))return"array";if("[object Function]"==n||void 0!==t.call&&void 0!==t.propertyIsEnumerable&&!t.propertyIsEnumerable("call"))return"function"}else if("function"==e&&void 0===t.call)return"object";return e}function i(t){return null===t}function d(t){return"array"==r(t)}function y(t){var e=r(t);return"array"==e||"object"==e&&"number"==typeof t.length}function m(t){return"function"==r(t)}function g(t){var e=typeof t;return"object"==e&&null!=t||"function"==e}var e="closure_uid_"+(1e9*Math.random()>>>0),v=0;function b(t,e,n){return t.call.apply(t.bind,arguments)}function w(e,n,t){if(!e)throw Error();if(2<arguments.length){var r=Array.prototype.slice.call(arguments,2);return function(){var t=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(t,r),e.apply(n,t)}}return function(){return e.apply(n,arguments)}}function _(t,e,n){return(_=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?b:w).apply(null,arguments)}function 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).gd=function(t,e,n){for(var r=Array(arguments.length-2),i=2;i<arguments.length;i++)r[i-2]=arguments[i];return o.prototype[e].apply(t,r)}}function I(t){if(!t)return!1;try{return!!t.$goog_Thenable}catch(t){return!1}}function C(t){if(Error.captureStackTrace)Error.captureStackTrace(this,C);else{var e=Error().stack;e&&(this.stack=e)}t&&(this.message=String(t))}function N(t,e){for(var n="",r=(t=t.split("%s")).length-1,i=0;i<r;i++)n+=t[i]+(i<e.length?e[i]:"%s");C.call(this,n+t[r])}function A(t,e){throw new N("Failure"+(t?": "+t:""),Array.prototype.slice.call(arguments,1))}function D(t,e){this.c=t,this.f=e,this.b=0,this.a=null}function k(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",D.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 D(function(){return new P},function(t){t.reset()});function P(){this.next=this.b=this.a=null}function x(t,e){t:{try{var n=t&&t.ownerDocument,r=n&&(n.defaultView||n.parentWindow);if((r=r||l).Element&&r.Location){var i=r;break t}}catch(t){}i=null}if(i&&void 0!==i[e]&&(!t||!(t instanceof i[e])&&(t instanceof i.Location||t instanceof i.Element))){if(g(t))try{var o=t.constructor.displayName||t.constructor.name||Object.prototype.toString.call(t)}catch(t){o="<object could not be stringified>"}else o=void 0===t?"undefined":null===t?"null":typeof t;A("Argument is not a %s (or a non-Element, non-Location mock); got: %s",e,o)}}R.prototype.add=function(t,e){var n=O.get();n.set(t,e),this.b?this.b.next=n:this.a=n,this.b=n},P.prototype.set=function(t,e){this.a=t,this.b=e,this.next=null},P.prototype.reset=function(){this.next=this.b=this.a=null};var M=Array.prototype.indexOf?function(t,e){return Array.prototype.indexOf.call(t,e,void 0)}:function(t,e){if(h(t))return h(e)&&1==e.length?t.indexOf(e,0):-1;for(var n=0;n<t.length;n++)if(n in t&&t[n]===e)return n;return-1},L=Array.prototype.forEach?function(t,e,n){Array.prototype.forEach.call(t,e,n)}:function(t,e,n){for(var r=t.length,i=h(t)?t.split(""):t,o=0;o<r;o++)o in i&&e.call(n,i[o],o,t)};var F=Array.prototype.map?function(t,e){return Array.prototype.map.call(t,e,void 0)}:function(t,e){for(var n=t.length,r=Array(n),i=h(t)?t.split(""):t,o=0;o<n;o++)o in i&&(r[o]=e.call(void 0,i[o],o,t));return r},U=Array.prototype.some?function(t,e){return Array.prototype.some.call(t,e,void 0)}:function(t,e){for(var n=t.length,r=h(t)?t.split(""):t,i=0;i<n;i++)if(i in r&&e.call(void 0,r[i],i,t))return!0;return!1};function V(t,e){return 0<=M(t,e)}function q(t,e){var n;return(n=0<=(e=M(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 z="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function G(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<z.length;o++)n=z[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 gt(){this.a="",this.b=Et}function vt(t){return t instanceof gt&&t.constructor===gt&&t.b===Et?t.a:(A("expected object of type SafeUrl, got '"+t+"' of type "+r(t)),"type_error:SafeUrl")}gt.prototype.qa=!0,gt.prototype.pa=function(){return this.a.toString()},gt.prototype.toString=function(){return"SafeUrl{"+this.a+"}"};var bt=/^(?:(?:https?|mailto|ftp):|[^:/?#]*(?:[/?#]|$))/i;function wt(t){return t instanceof gt?t:(t="object"==typeof t&&t.qa?t.pa():String(t),bt.test(t)||(t="about:invalid#zClosurez"),Tt(t))}var _t,Et={};function Tt(t){var e=new gt;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=Dt}function At(t){return t instanceof Nt&&t.constructor===Nt&&t.b===Dt?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 Dt={};function kt(t){var e=new Nt;return e.a=t,e}kt("<!DOCTYPE html>");var Rt,Ot,Pt=kt("");function xt(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 Mt(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));x(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)}}(),Vt||(Ot(),Vt=!0),qt.add(t,e)}kt("<br>");var Vt=!1,qt=new R;function Bt(){for(var t;n=e=void 0,n=null,(e=qt).a&&(n=e.a,e.a=e.a.next,e.a||(e.b=null),n.next=null),t=n;){try{t.a.call(t.b)}catch(t){Lt(t)}k(O,t)}var e,n;Vt=!1}function jt(t,e){if(this.a=Wt,this.i=void 0,this.f=this.b=this.c=null,this.g=this.h=!1,t!=p)try{var n=this;t.call(e,function(t){ee(n,Kt,t)},function(t){if(!(t instanceof ue))try{if(t instanceof Error)throw t;throw Error("Promise rejected.")}catch(t){}ee(n,Qt,t)})}catch(t){ee(this,Qt,t)}}var Wt=0,Kt=2,Qt=3;function Ht(){this.next=this.f=this.b=this.g=this.a=null,this.c=!1}Ht.prototype.reset=function(){this.f=this.b=this.g=this.a=null,this.c=!1};var zt=new D(function(){return new Ht},function(t){t.reset()});function Gt(t,e,n){var r=zt.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=Gt(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,Gt(e||p,n||null,r)),!0;if(I(t))return t.then(e,n,r),!0;if(g(t))try{var i=t.then;if(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)}k(zt,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=Gt(t,t,e)).c=!0,Zt(this,t),this},t.s=function(t,e){return te(this,null,t,e)},t.cancel=function(t){this.a==Wt&&Ut(function(){!function t(e,n){if(e.a==Wt)if(e.c){var r=e.c;if(r.b){for(var i=0,o=null,a=null,s=r.b;s&&(s.c||(i++,s.a==e&&(o=s),!(o&&1<i)));s=s.next)o||(a=s);o&&(r.a==Wt&&1==i?t(r,n):(a?((i=a).next==r.f&&(r.f=i),i.next=i.next.next):ie(r),oe(r,o,Qt,n)))}e.c=null}else ee(e,Qt,n)}(this,new ue(t))},this)},t.Oc=function(t){this.a=Wt,ee(this,Kt,t)},t.Pc=function(t){this.a=Wt,ee(this,Qt,t)},t.Zb=function(){for(var t;t=ie(this);)oe(this,t,this.a,this.i);this.h=!1};var se=Lt;function ue(t){C.call(this,t)}function ce(){this.va=this.va,this.la=this.la}S(ue,C);var he=0;function le(t){if(!t.va&&(t.va=!0,t.za(),0!=he))t[e]||(t[e]=++v)}function fe(t){return fe[" "](t),t}ce.prototype.va=!(ue.prototype.name="cancel"),ce.prototype.za=function(){if(this.la)for(;this.la.length;)this.la.shift()()},fe[" "]=p;var pe,de,ye=Ct("Opera"),me=Ct("Trident")||Ct("MSIE"),ge=Ct("Edge"),ve=ge||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):ge?/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},De=!me||9<=Number(Ie),ke=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:xe[t.pointerType]||"",(this.a=t).defaultPrevented&&this.preventDefault()}}Oe.prototype.preventDefault=function(){this.Mb=!1},S(Pe,Oe);var xe=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,ke)try{(t.ctrlKey||112<=t.keyCode&&t.keyCode<=123)&&(t.keyCode=-1)}catch(t){}},Pe.prototype.f=function(){return this.a};var Me="closure_listenable_"+(1e6*Math.random()|0),Le=0;function Fe(t,e,n,r,i){this.listener=t,this.proxy=null,this.src=e,this.type=n,this.capture=!!r,this.Pa=i,this.key=++Le,this.ta=this.Ka=!1}function Ue(t){t.ta=!0,t.listener=null,t.proxy=null,t.src=null,t.Pa=null}function Ve(t){this.src=t,this.a={},this.b=0}function qe(t,e){var n=e.type;n in t.a&&q(t.a[n],e)&&(Ue(e),0==t.a[n].length&&(delete t.a[n],t.b--))}function Be(t,e,n,r){for(var i=0;i<t.length;++i){var o=t[i];if(!o.ta&&o.listener==e&&o.capture==!!n&&o.Pa==r)return i}return-1}Ve.prototype.add=function(t,e,n,r,i){var o=t.toString();(t=this.a[o])||(t=this.a[o]=[],this.b++);var a=Be(t,e,r,i);return-1<a?(e=t[a],n||(e.Ka=!1)):((e=new Fe(e,this.src,o,!!r,i)).Ka=n,t.push(e)),e};var je="closure_lm_"+(1e6*Math.random()|0),We={};function Ke(t,e,n,r,i){if(r&&r.once)He(t,e,n,r,i);else if(d(e))for(var o=0;o<e.length;o++)Ke(t,e[o],n,r,i);else n=en(n),t&&t[Me]?rn(t,e,n,g(r)?!!r.capture:!!r,i):Qe(t,e,n,!1,r,i)}function Qe(t,e,n,r,i,o){if(!e)throw Error("Invalid event type");var a=g(i)?!!i.capture:!!i,s=Ze(t);if(s||(t[je]=s=new Ve(t)),!(n=s.add(e,n,r,a,o)).proxy)if(r=function(){var e=$e,n=De?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[Me]?on(t,e,n,g(r)?!!r.capture:!!r,i):Qe(t,e,n,!0,r,i)}function ze(t,e,n,r,i){if(d(e))for(var o=0;o<e.length;o++)ze(t,e[o],n,r,i);else r=g(r)?!!r.capture:!!r,n=en(n),t&&t[Me]?(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)&&Ge(n))}function Ge(t){if("number"!=typeof t&&t&&!t.ta){var e=t.src;if(e&&e[Me])qe(e.u,t);else{var n=t.type,r=t.proxy;e.removeEventListener?e.removeEventListener(n,r,t.capture):e.detachEvent?e.detachEvent(Ye(n),r):e.addListener&&e.removeListener&&e.removeListener(r),(n=Ze(e))?(qe(n,t),0==n.b&&(n.src=null,e[je]=null)):Ue(t)}}}function Ye(t){return t in We?We[t]:We[t]="on"+t}function Xe(t,e,n,r){var i=!0;if((t=Ze(t))&&(e=t.a[e.toString()]))for(e=e.concat(),t=0;t<e.length;t++){var o=e[t];o&&o.capture==n&&!o.ta&&(o=Je(o,r),i=i&&!1!==o)}return i}function Je(t,e){var n=t.listener,r=t.Pa||t.src;return t.Ka&&Ge(t),n.call(r,e)}function $e(t,e){if(t.ta)return!0;if(De)return Je(t,new Pe(e,this));if(!e)t:{e=["window","event"];for(var n=l,r=0;r<e.length;r++)if(null==(n=n[e[r]])){e=null;break t}e=n}if(e=new Pe(r=e,this),n=!0,!(r.keyCode<0||null!=r.returnValue)){t:{var i=!1;if(0==r.keyCode)try{r.keyCode=-1;break t}catch(t){i=!0}!i&&null!=r.returnValue||(r.returnValue=!0)}for(r=[],i=e.b;i;i=i.parentNode)r.push(i);for(t=t.type,i=r.length-1;0<=i;i--){e.b=r[i];var o=Xe(r[i],t,!0,e);n=n&&o}for(i=0;i<r.length;i++)e.b=r[i],o=Xe(r[i],t,!1,e),n=n&&o}return n}function Ze(t){return(t=t[je])instanceof Ve?t:null}var tn="__closure_events_fn_"+(1e9*Math.random()>>>0);function en(e){return m(e)?e:(e[tn]||(e[tn]=function(t){return e.handleEvent(t)}),e[tn])}function nn(){ce.call(this),this.u=new Ve(this),(this.Sb=this).Xa=null}function rn(t,e,n,r,i){t.u.add(String(e),n,!1,r,i)}function on(t,e,n,r,i){t.u.add(String(e),n,!0,r,i)}function an(t,e,n,r){if(!(e=t.u.a[String(e)]))return!0;e=e.concat();for(var i=!0,o=0;o<e.length;++o){var a=e[o];if(a&&!a.ta&&a.capture==n){var s=a.listener,u=a.Pa||a.src;a.Ka&&qe(t.u,a),i=!1!==s.call(u,r)&&i}}return i&&0!=r.Mb}function sn(t,e,n){if(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[Me]=!0,nn.prototype.addEventListener=function(t,e,n,r){Ke(this,t,e,n,r)},nn.prototype.removeEventListener=function(t,e,n,r){ze(this,t,e,n,r)},nn.prototype.dispatchEvent=function(t){var e,n=this.Xa;if(n)for(e=[];n;n=n.Xa)e.push(n);n=this.Sb;var r=t.type||t;if(h(t))t=new Oe(t,n);else if(t instanceof Oe)t.target=t.target||n;else{var i=t;G(t=new Oe(r,n),i)}if(i=!0,e)for(var o=e.length-1;0<=o;o--){var a=t.b=e[o];i=an(a,r,!0,t)&&i}if(i=an(a=t.b=n,r,!0,t)&&i,i=an(a,r,!1,t)&&i,e)for(o=0;o<e.length;o++)i=an(a=t.b=e[o],r,!1,t)&&i;return i},nn.prototype.za=function(){if(nn.qb.za.call(this),this.u){var t,e=this.u;for(t in e.a){for(var n=e.a[t],r=0;r<n.length;r++)Ue(n[r]);delete e.a[t],e.b--}}this.Xa=null},(t=ln.prototype).U=function(){fn(this);for(var t=[],e=0;e<this.a.length;e++)t.push(this.b[this.a[e]]);return t},t.X=function(){return fn(this),this.a.concat()},t.clear=function(){this.b={},this.c=this.a.length=0},t.get=function(t,e){return pn(this.b,t)?this.b[t]:e},t.set=function(t,e){pn(this.b,t)||(this.c++,this.a.push(t)),this.b[t]=e},t.forEach=function(t,e){for(var n=this.X(),r=0;r<n.length;r++){var i=n[r],o=this.get(i);t.call(e,o,i,this)}};var dn=/^(?:([^:/?#.]+):)?(?:\/\/(?:([^/?#]*)@)?([^/#?]*?)(?::([0-9]+))?(?=[/#?]|$))?([^?#]+)?(?:\?([^#]*))?(?:#([\s\S]*))?$/;function 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,gn(this,t.l),this.c=t.c,vn(this,Fn(t.a)),this.g=t.g):t&&(n=String(t).match(dn))?(this.h=!!e,mn(this,n[1]||"",!0),this.i=Tn(n[2]||""),this.b=Tn(n[3]||"",!0),gn(this,n[4]),this.c=Tn(n[5]||"",!0),vn(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 gn(t,e){if(e){if(e=Number(e),isNaN(e)||e<0)throw Error("Bad port number "+e);t.l=e}else t.l=null}function vn(t,e,n){e instanceof Rn?(t.a=e,function(t,e){e&&!t.f&&(On(t),t.c=null,t.a.forEach(function(t,e){var n=e.toLowerCase();e!=n&&(xn(this,e),Ln(this,n,t))},t)),t.f=e}(t.a,t.h)):(n||(e=Sn(e,Dn)),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,kn)),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)gn(e,t.l);else if(n=!!t.c){if("/"!=r.charAt(0))if(this.b&&!this.c)r="/"+r;else{var i=e.c.lastIndexOf("/");-1!=i&&(r=e.c.substr(0,i+1)+r)}if(".."==(i=r)||"."==i)r="";else if(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?vn(e,Fn(t.a)):n=!!t.g,n&&(e.g=t.g),e};var Cn=/[#\/\?@]/g,Nn=/[#\?:]/g,An=/[#\?]/g,Dn=/[#\?@]/g,kn=/#/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 xn(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 Mn(t,e){return On(t),e=Un(t,e),pn(t.a.b,e)}function Ln(t,e,n){xn(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))Mn(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,Mn(this,t=Un(this,t))&&(this.b-=this.a.get(t).length),this.a.set(t,[e]),this.b+=1,this},t.get=function(t,e){return t&&0<(t=this.U(t)).length?String(t[0]):e},t.toString=function(){if(this.c)return this.c;if(!this.a)return"";for(var t=[],e=this.a.X(),n=0;n<e.length;n++){var r=e[n],i=encodeURIComponent(String(r));r=this.U(r);for(var o=0;o<r.length;o++){var a=i;""!==r[o]&&(a+="="+encodeURIComponent(String(r[o]))),t.push(a)}}return this.c=t.join("&")};var Vn=!me||9<=Number(Ie);function qn(t){var e=document;return h(t)?e.getElementById(t):t}function Bn(n,t){K(t,function(t,e){t&&"object"==typeof t&&t.qa&&(t=t.pa()),"style"==e?n.style.cssText=t:"class"==e?n.className=t:"for"==e?n.htmlFor=t:jn.hasOwnProperty(e)?n.setAttribute(jn[e],t):0==e.lastIndexOf("aria-",0)||0==e.lastIndexOf("data-",0)?n.setAttribute(e,t):n[e]=t})}var jn={cellpadding:"cellPadding",cellspacing:"cellSpacing",colspan:"colSpan",frameborder:"frameBorder",height:"height",maxlength:"maxLength",nonce:"nonce",role:"role",rowspan:"rowSpan",type:"type",usemap:"useMap",valign:"vAlign",width:"width"};function Wn(t,e,n){var r=arguments,i=document,o=String(r[0]),a=r[1];if(!Vn&&a&&(a.name||a.type)){if(o=["<",o],a.name&&o.push(' name="',Mt(a.name),'"'),a.type){o.push(' type="',Mt(a.type),'"');var s={};G(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)||g(o)&&0<o.nodeType?r(o):L(Kn(o)?W(o):o,r)}}(i,o,r),o}function Kn(t){if(t&&"number"==typeof t.length){if(g(t))return"function"==typeof t.item||"string"==typeof t.item;if(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 zn={'"':'\\"',"\\":"\\\\","/":"\\/","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\v":"\\u000b"},Gn=/\uffff/.test("￿")?/[\\"\x00-\x1f\x7f-\uffff]/g:/[\\"\x00-\x1f\x7f-\xff]/g;function Yn(t,e){e.push('"',t.replace(Gn,function(t){var e=zn[t];return e||(e="\\u"+(65536|t.charCodeAt(0)).toString(16).substr(1),zn[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=vt(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 gt?n:wt(void 0!==n.href?n.href:String(n)),n=t.target||n.target,i=[],t)switch(a){case"width":case"height":case"top":case"left":i.push(a+"="+t[a]);break;case"target":case"noopener":case"noreferrer":break;default:i.push(a+"="+(t[a]?1:0))}var a=i.join(",");if((Ct("iPhone")&&!Ct("iPod")&&!Ct("iPad")||Ct("iPad")||Ct("iPod"))&&r.navigator&&r.navigator.standalone&&n&&"_self"!=n?(x(a=r.document.createElement("A"),"HTMLAnchorElement"),e instanceof gt||e instanceof gt||(e="object"==typeof e&&e.qa?e.pa():String(e),bt.test(e)||(e="about:invalid#zClosurez"),e=Tt(e)),a.href=vt(e),a.setAttribute("target",n),t.noreferrer&&a.setAttribute("rel","noreferrer"),(t=document.createEvent("MouseEvent")).initMouseEvent("click",!0,!0,r,1),a.dispatchEvent(t),a={}):t.noreferrer?(a=r.open("",n,a),t=vt(e).toString(),a&&(ve&&yt(t,";")&&(t="'"+t.replace(/'/g,"%27")+"'"),a.opener=null,t=kt('<meta name="referrer" content="no-referrer"><meta http-equiv="refresh" content="0; url='+Mt(t)+'">'),a.document.write(At(t)),a.document.close())):(a=r.open(vt(e).toString(),n,a))&&t.noopener&&(a.opener=null),a)try{a.focus()}catch(t){}return a}var nr=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,rr=/^[^@]+@[^@]+$/;function ir(){var e=null;return new jt(function(t){"complete"==l.document.readyState?t():(e=function(){t()},He(window,"load",e))}).s(function(t){throw ze(window,"load",e),t})}function or(t){return t=t||yr(),!("file:"!==wr()&&"ionic:"!==wr()||!t.toLowerCase().match(/iphone|ipad|ipod|android/))}function ar(){var t=l.window;try{return!(!t||t==t.top)}catch(t){return!1}}function sr(){return void 0!==l.WorkerGlobalScope&&"function"==typeof l.importScripts}function ur(){return fl.INTERNAL.hasOwnProperty("reactNative")?"ReactNative":fl.INTERNAL.hasOwnProperty("node")?"Node":sr()?"Worker":"Browser"}function cr(){var t=ur();return"ReactNative"===t||"Node"===t}var hr="Firefox",lr="Chrome";function fr(t){var e=t.toLowerCase();return 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={Wc:"FirebaseCore-web",Yc:"FirebaseUI-web"};function dr(t,e){e=e||[];var n,r=[],i={};for(n in pr)i[pr[n]]=!0;for(n=0;n<e.length;n++)void 0!==i[e[n]]&&(delete i[e[n]],r.push(e[n]));return r.sort(),(e=r).length||(e=["FirebaseCore-web"]),"Browser"===(r=ur())?r=fr(i=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 gr(){try{var t=l.localStorage,e=Ir();if(t)return t.setItem(e,"1"),t.removeItem(e),!Xn()||!!l.indexedDB}catch(t){return sr()&&!!l.indexedDB}return!1}function vr(){return(br()||"chrome-extension:"===wr()||or())&&!cr()&&gr()&&!sr()}function br(){return"http:"===wr()||"https:"===wr()}function wr(){return l.location&&l.location.protocol||null}function _r(t){return!Zn(t=t||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 Dr(){var t=l.document;return!t||void 0===t.visibilityState||"visible"==t.visibilityState}function kr(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 xr(t){Pr[t]||(Pr[t]=!0,"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn(t))}try{var Mr={};Object.defineProperty(Mr,"abcd",{configurable:!0,enumerable:!0,value:1}),Object.defineProperty(Mr,"abcd",{configurable:!0,enumerable:!0,value:2}),Or=2==Mr.abcd}catch(t){Or=!1}function Lr(t,e,n){Or?Object.defineProperty(t,e,{configurable:!0,enumerable:!0,value:n}):t[e]=n}function Fr(t,e){if(e)for(var n in e)e.hasOwnProperty(n)&&Lr(t,n,e[n])}function Ur(t){var e={};return Fr(e,t),e}function Vr(t){var e=t;if("object"==typeof t&&null!=t)for(var n in e="length"in t?[]:{},t)Lr(e,n,Vr(t[n]));return e}function qr(t){var e={},n=t[jr],r=t[Wr];if(!(t=t[Kr])||t!=Br&&!n)throw Error("Invalid provider user info!");e[Hr]=r||null,e[Qr]=n||null,Lr(this,Gr,t),Lr(this,zr,Vr(e))}var Br="EMAIL_SIGNIN",jr="email",Wr="newEmail",Kr="requestType",Qr="email",Hr="fromEmail",zr="data",Gr="operation";function Yr(t,e){this.code=Jr+t,this.message=e||$r[t]||""}function Xr(t){var e=t&&t.code;return e?new Yr(e.substring(Jr.length),t.message):null}S(Yr,Error),Yr.prototype.A=function(){return{code:this.code,message:this.message}},Yr.prototype.toJSON=function(){return this.A()};var Jr="auth/",$r={"admin-restricted-operation":"This operation is restricted to administrators only.","argument-error":"","app-not-authorized":"This app, identified by the domain where it's hosted, is not authorized to use Firebase Authentication with the provided API key. Review your key configuration in the Google API console.","app-not-installed":"The requested mobile application corresponding to the identifier (Android package name or iOS bundle ID) provided is not installed on this device.","captcha-check-failed":"The reCAPTCHA response token provided is either invalid, expired, already used or the domain associated with it does not match the list of whitelisted domains.","code-expired":"The SMS code has expired. Please re-send the verification code to try again.","cordova-not-ready":"Cordova framework is not ready.","cors-unsupported":"This browser is not supported.","credential-already-in-use":"This credential is already associated with a different user account.","custom-token-mismatch":"The custom token corresponds to a different audience.","requires-recent-login":"This operation is sensitive and requires recent authentication. Log in again before retrying this request.","dynamic-link-not-activated":"Please activate Dynamic Links in the Firebase Console and agree to the terms and conditions.","email-already-in-use":"The email address is already in use by another account.","expired-action-code":"The action code has expired. ","cancelled-popup-request":"This operation has been cancelled due to another conflicting popup being opened.","internal-error":"An internal error has occurred.","invalid-app-credential":"The phone verification request contains an invalid application verifier. The reCAPTCHA token response is either invalid or expired.","invalid-app-id":"The mobile app identifier is not registed for the current project.","invalid-user-token":"This user's credential isn't valid for this project. This can happen if the user's token has been tampered with, or if the user isn't for the project associated with this API key.","invalid-auth-event":"An internal error has occurred.","invalid-verification-code":"The SMS verification code used to create the phone auth credential is invalid. Please resend the verification code sms and be sure use the verification code provided by the user.","invalid-continue-uri":"The continue URL provided in the request is invalid.","invalid-cordova-configuration":"The following Cordova plugins must be installed to enable OAuth sign-in: cordova-plugin-buildinfo, cordova-universal-links-plugin, cordova-plugin-browsertab, cordova-plugin-inappbrowser and cordova-plugin-customurlscheme.","invalid-custom-token":"The custom token format is incorrect. Please check the documentation.","invalid-dynamic-link-domain":"The provided dynamic link domain is not configured or authorized for the current project.","invalid-email":"The email address is badly formatted.","invalid-api-key":"Your API key is invalid, please check you have copied it correctly.","invalid-cert-hash":"The SHA-1 certificate hash provided is invalid.","invalid-credential":"The supplied auth credential is malformed or has expired.","invalid-message-payload":"The email template corresponding to this action contains invalid characters in its message. Please fix by going to the Auth email templates section in the Firebase Console.","invalid-oauth-provider":"EmailAuthProvider is not supported for this operation. This operation only supports OAuth providers.","invalid-oauth-client-id":"The OAuth client ID provided is either invalid or does not match the specified API key.","unauthorized-domain":"This domain is not authorized for OAuth operations for your Firebase project. Edit the list of authorized domains from the Firebase console.","invalid-action-code":"The action code is invalid. This can happen if the code is malformed, expired, or has already been used.","wrong-password":"The password is invalid or the user does not have a password.","invalid-persistence-type":"The specified persistence type is invalid. It can only be local, session or none.","invalid-phone-number":"The format of the phone number provided is incorrect. Please enter the phone number in a format that can be parsed into E.164 format. E.164 phone numbers are written in the format [+][country code][subscriber number including area code].","invalid-provider-id":"The specified provider ID is invalid.","invalid-recipient-email":"The email corresponding to this action failed to send as the provided recipient email address is invalid.","invalid-sender":"The email template corresponding to this action contains an invalid sender email or name. Please fix by going to the Auth email templates section in the Firebase Console.","invalid-verification-id":"The verification ID used to create the phone auth credential is invalid.","invalid-tenant-id":"The Auth instance's tenant ID is invalid.","missing-android-pkg-name":"An Android Package Name must be provided if the Android App is required to be installed.","auth-domain-config-required":"Be sure to include authDomain when calling firebase.initializeApp(), by following the instructions in the Firebase console.","missing-app-credential":"The phone verification request is missing an application verifier assertion. A reCAPTCHA response token needs to be provided.","missing-verification-code":"The phone auth credential was created with an empty SMS verification code.","missing-continue-uri":"A continue URL must be provided in the request.","missing-iframe-start":"An internal error has occurred.","missing-ios-bundle-id":"An iOS Bundle ID must be provided if an App Store ID is provided.","missing-or-invalid-nonce":"The request does not contain a valid nonce. This can occur if the SHA-256 hash of the provided raw nonce does not match the hashed nonce in the ID token payload.","missing-phone-number":"To send verification codes, provide a phone number for the recipient.","missing-verification-id":"The phone auth credential was created with an empty verification ID.","app-deleted":"This instance of FirebaseApp has been deleted.","account-exists-with-different-credential":"An account already exists with the same email address but different sign-in credentials. Sign in using a provider associated with this email address.","network-request-failed":"A network error (such as timeout, interrupted connection or unreachable host) has occurred.","no-auth-event":"An internal error has occurred.","no-such-provider":"User was not linked to an account with the given provider.","null-user":"A null user object was provided as the argument for an operation which requires a non-null user object.","operation-not-allowed":"The given sign-in provider is disabled for this Firebase project. Enable it in the Firebase console, under the sign-in method tab of the Auth section.","operation-not-supported-in-this-environment":'This operation is not supported in the environment this application is running on. "location.protocol" must be http, https or chrome-extension and web storage must be enabled.',"popup-blocked":"Unable to establish a connection with the popup. It may have been blocked by the browser.","popup-closed-by-user":"The popup has been closed by the user before finalizing the operation.","provider-already-linked":"User can only be linked to one identity for the given provider.","quota-exceeded":"The project's quota for this operation has been exceeded.","redirect-cancelled-by-user":"The redirect operation has been cancelled by the user before finalizing.","redirect-operation-pending":"A redirect sign-in operation is already pending.","rejected-credential":"The request contains malformed or mismatching credentials.","tenant-id-mismatch":"The provided tenant ID does not match the Auth instance's tenant ID",timeout:"The operation has timed out.","user-token-expired":"The user's credential is no longer valid. The user must sign in again.","too-many-requests":"We have blocked all requests from this device due to unusual activity. Try again later.","unauthorized-continue-uri":"The domain of the continue URL is not whitelisted. Please whitelist the domain in the Firebase console.","unsupported-persistence-type":"The current environment does not support the specified persistence type.","unsupported-tenant-operation":"This operation is not supported in a multi-tenant context.","user-cancelled":"The user did not grant your application the permissions it requested.","user-not-found":"There is no user record corresponding to this identifier. The user may have been deleted.","user-disabled":"The user account has been disabled by an administrator.","user-mismatch":"The supplied credentials do not correspond to the previously signed in user.","user-signed-out":"","weak-password":"The password must be 6 characters long or more.","web-storage-unsupported":"This browser is not supported or 3rd party cookies and data may be disabled."};function Zr(t){var e=wn(t=_n(t),ti)||null,n=wn(t,ei)||null,r=wn(t,ii)||null;if(r=r&&ai[r]||null,!e||!n||!r)throw new Yr("argument-error",ti+", "+ei+"and "+ii+" are required in a valid action code URL.");Fr(this,{apiKey:e,operation:r,code:n,continueUrl:wn(t,ni)||null,languageCode:wn(t,ri)||null,tenantId:wn(t,oi)||null})}var ti="apiKey",ei="oobCode",ni="continueUrl",ri="languageCode",ii="mode",oi="tenantId",ai={recoverEmail:"RECOVER_EMAIL",resetPassword:"PASSWORD_RESET",signIn:Br,verifyEmail:"VERIFY_EMAIL"};function si(t){try{return new Zr(t)}catch(t){return null}}function ui(t){var e=t[pi];if(void 0===e)throw new Yr("missing-continue-uri");if("string"!=typeof e||"string"==typeof e&&!e.length)throw new Yr("invalid-continue-uri");this.h=e,this.b=this.a=null,this.g=!1;var n=t[ci];if(n&&"object"==typeof n){e=n[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[gi])&&e.length)this.f=e;else if(void 0!==e)throw new Yr("argument-error",gi+" property must be a non empty string when specified.")}else if(void 0!==e)throw new Yr("argument-error",fi+" property must be a non null object when specified.");if(void 0!==(e=t[li])&&"boolean"!=typeof e)throw new Yr("argument-error",li+" property must be a boolean when specified.");if(this.c=!!e,void 0!==(t=t[hi])&&("string"!=typeof t||"string"==typeof t&&!t.length))throw new Yr("argument-error",hi+" property must be a non empty string when specified.");this.i=t||null}var ci="android",hi="dynamicLinkDomain",li="handleCodeInApp",fi="iOS",pi="url",di="installApp",yi="minimumVersion",mi="packageName",gi="bundleId";function vi(t){var e={};for(var n in e.continueUrl=t.h,e.canHandleCodeInApp=t.c,(e.androidPackageName=t.a)&&(e.androidMinimumVersion=t.b,e.androidInstallApp=t.g),e.iOSBundleId=t.f,e.dynamicLinkDomain=t.i,e)null===e[n]&&delete e[n];return e}var bi=null,wi=null;function _i(t){var e="";return function(r,t){function e(t){for(;i<r.length;){var e=r.charAt(i++),n=wi[e];if(null!=n)return n;if(!/^[\s\xa0]*$/.test(e))throw Error("Unknown base64 encoding at char: "+e)}return t}!function(){if(!bi){bi={},wi={};for(var t=0;t<65;t++)bi[t]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(t),62<=(wi[bi[t]]=t)&&(wi["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.".charAt(t)]=t)}}();for(var i=0;;){var n=e(-1),o=e(0),a=e(64),s=e(64);if(64===s&&-1===n)break;t(n<<2|o>>4),64!=a&&(t(o<<4&240|a>>2),64!=s&&t(a<<6&192|s))}}(t,function(t){e+=String.fromCharCode(t)}),e}function 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={bd:{cb:"https://www.googleapis.com/identitytoolkit/v3/relyingparty/",ib:"https://securetoken.googleapis.com/v1/token",id:"p"},dd:{cb:"https://staging-www.sandbox.googleapis.com/identitytoolkit/v3/relyingparty/",ib:"https://staging-securetoken.sandbox.googleapis.com/v1/token",id:"s"},ed:{cb:"https://www-googleapis-test.sandbox.google.com/identitytoolkit/v3/relyingparty/",ib:"https://test-securetoken.sandbox.googleapis.com/v1/token",id:"t"}};function Ni(t){for(var e in Ci)if(Ci[e].id===t)return{firebaseEndpoint:(t=Ci[e]).cb,secureTokenEndpoint:t.ib};return null}Ii=Ni("__EID__")?"__EID__":void 0;var Ai="oauth_consumer_key oauth_nonce oauth_signature oauth_signature_method oauth_timestamp oauth_token oauth_version".split(" "),Di=["client_id","response_type","scope","redirect_uri","state"],ki={Xc:{Ea:"locale",sa:700,ra:600,Fa:"facebook.com",Qa:Di},Zc:{Ea:null,sa:500,ra:750,Fa:"github.com",Qa:Di},$c:{Ea:"hl",sa:515,ra:680,Fa:"google.com",Qa:Di},fd:{Ea:"lang",sa:485,ra:705,Fa:"twitter.com",Qa:Ai},Vc:{Ea:"locale",sa:600,ra:600,Fa:"apple.com",Qa:[]}};function Ri(t){for(var e in ki)if(ki[e].Fa==t)return ki[e];return null}function Oi(t){var e={};e["facebook.com"]=Fi,e["google.com"]=Vi,e["github.com"]=Ui,e["twitter.com"]=qi;var n=t&&t[xi];try{if(n)return e[n]?new e[n](t):new Li(t);if(void 0!==t[Pi])return new Mi(t)}catch(t){}return null}var Pi="idToken",xi="providerId";function Mi(t){var e=t[xi];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){Mi.call(this,t),Lr(this,"profile",Vr((t=Sr(t.rawUserInfo||"{}"))||{}))}function Fi(t){if(Li.call(this,t),"facebook.com"!=this.providerId)throw Error("Invalid provider ID!")}function Ui(t){if(Li.call(this,t),"github.com"!=this.providerId)throw Error("Invalid provider ID!");Lr(this,"username",this.profile&&this.profile.login||null)}function Vi(t){if(Li.call(this,t),"google.com"!=this.providerId)throw Error("Invalid provider ID!")}function qi(t){if(Li.call(this,t),"twitter.com"!=this.providerId)throw Error("Invalid provider ID!");Lr(this,"username",t.screenName||null)}function Bi(t){var e=_n(t),n=wn(e,"link"),r=wn(_n(n),"link");return wn(_n(e=wn(e,"deep_link_id")),"link")||e||r||n||t}function ji(){}function Wi(t,n){return t.then(function(t){if(t[Oa]){var e=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 zi(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 Gi(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 zi(t.providerId,e,t.signInMethod)}catch(t){}}return null}function Xi(t,e){this.Fc=e||[],Fr(this,{providerId:t,isOAuthProvider:!0}),this.zb={},this.eb=(Ri(t)||{}).Ea||null,this.bb=null}function Ji(t){if("string"!=typeof t||0!=t.indexOf("saml."))throw new Yr("argument-error",'SAML provider IDs must be prefixed with "saml."');Xi.call(this,t,[])}function $i(t){Xi.call(this,t,Di),this.a=[]}function Zi(){$i.call(this,"facebook.com")}function to(t){if(!t)throw new Yr("argument-error","credential failed: expected 1 argument (the OAuth access token).");var e=t;return g(t)&&(e=t.accessToken),(new Zi).credential({accessToken:e})}function eo(){$i.call(this,"github.com")}function no(t){if(!t)throw new Yr("argument-error","credential failed: expected 1 argument (the OAuth access token).");var e=t;return g(t)&&(e=t.accessToken),(new eo).credential({accessToken:e})}function ro(){$i.call(this,"google.com"),this.ya("profile")}function io(t,e){var n=t;return g(t)&&(n=t.idToken,e=t.accessToken),(new ro).credential({idToken:n,accessToken:e})}function oo(){Xi.call(this,"twitter.com",Ai)}function ao(t,e){var n=t;if(g(n)||(n={oauthToken:t,oauthTokenSecret:e}),!n.oauthToken||!n.oauthTokenSecret)throw new Yr("argument-error","credential failed: expected 2 arguments (the OAuth access token and secret).");return new zi("twitter.com",n,"twitter.com")}function so(t,e,n){this.a=t,this.c=e,Lr(this,"providerId","password"),Lr(this,"signInMethod",n===co.EMAIL_LINK_SIGN_IN_METHOD?co.EMAIL_LINK_SIGN_IN_METHOD:co.EMAIL_PASSWORD_SIGN_IN_METHOD)}function uo(t){return t&&t.email&&t.password?new so(t.email,t.password,t.signInMethod):null}function co(){Fr(this,{providerId:"password",isOAuthProvider:!1})}function ho(t,e){if(!(e=lo(e)))throw new Yr("argument-error","Invalid email link!");return new so(t,e.code,co.EMAIL_LINK_SIGN_IN_METHOD)}function lo(t){return(t=si(t=Bi(t)))&&t.operation===Br?t:null}function fo(t){if(!(t.Va&&t.Ua||t.Ha&&t.ba))throw new Yr("internal-error");this.a=t,Lr(this,"providerId","phone"),Lr(this,"signInMethod","phone")}function po(e){if(e&&"phone"===e.providerId&&(e.verificationId&&e.verificationCode||e.temporaryProof&&e.phoneNumber)){var n={};return L(["verificationId","verificationCode","temporaryProof","phoneNumber"],function(t){e[t]&&(n[t]=e[t])}),new fo(n)}return null}function yo(t){return t.a.Ha&&t.a.ba?{temporaryProof:t.a.Ha,phoneNumber:t.a.ba}:{sessionInfo:t.a.Va,code:t.a.Ua}}function 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 go(t,e){if(!t)throw new Yr("missing-verification-id");if(!e)throw new Yr("missing-verification-code");return new fo({Va:t,Ua:e})}function vo(t){if(t.temporaryProof&&t.phoneNumber)return new fo({Ha:t.temporaryProof,ba:t.phoneNumber});var e=t&&t.providerId;if(!e||"password"===e)return null;var n=t&&t.oauthAccessToken,r=t&&t.oauthTokenSecret,i=t&&t.nonce,o=t&&t.oauthIdToken,a=t&&t.pendingToken;try{switch(e){case"google.com":return io(o,n);case"facebook.com":return to(n);case"github.com":return no(n);case"twitter.com":return ao(n,r);default:return n||r||o||a?a?0==e.indexOf("saml.")?new Ki(e,a):new zi(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,Mi),S(Fi,Li),S(Ui,Li),S(Vi,Li),S(qi,Li),Ki.prototype.na=function(t){return Xa(t,Qi(this))},Ki.prototype.b=function(t,e){var n=Qi(this);return n.idToken=e,Ja(t,n)},Ki.prototype.f=function(t,e){return Wi($a(t,Qi(this)),e)},Ki.prototype.A=function(){return{providerId:this.providerId,signInMethod:this.signInMethod,pendingToken:this.a}},zi.prototype.na=function(t){return Xa(t,Gi(this))},zi.prototype.b=function(t,e){var n=Gi(this);return n.idToken=e,Ja(t,n)},zi.prototype.f=function(t,e){return Wi($a(t,Gi(this)),e)},zi.prototype.A=function(){var t={providerId:this.providerId,signInMethod:this.signInMethod};return this.idToken&&(t.oauthIdToken=this.idToken),this.accessToken&&(t.oauthAccessToken=this.accessToken),this.secret&&(t.oauthTokenSecret=this.secret),this.nonce&&(t.nonce=this.nonce),this.a&&(t.pendingToken=this.a),t},Xi.prototype.Ga=function(t){return this.zb=H(t),this},S(Ji,Xi),S($i,Xi),$i.prototype.ya=function(t){return V(this.a,t)||this.a.push(t),this},$i.prototype.Hb=function(){return W(this.a)},$i.prototype.credential=function(t,e){var n;if(!(n=g(t)?{idToken:t.idToken||null,accessToken:t.accessToken||null,nonce:t.rawNonce||null}:{idToken:t||null,accessToken:e||null}).idToken&&!n.accessToken)throw new Yr("argument-error","credential failed: must provide the ID token and/or the access token.");return new zi(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,gs,{idToken:e,email:this.a,password:this.c})},so.prototype.f=function(t,e){return Wi(this.na(t),e)},so.prototype.A=function(){return{email:this.a,password:this.c,signInMethod:this.signInMethod}},Fr(co,{PROVIDER_ID:"password"}),Fr(co,{EMAIL_LINK_SIGN_IN_METHOD:"emailLink"}),Fr(co,{EMAIL_PASSWORD_SIGN_IN_METHOD:"password"}),fo.prototype.na=function(t){return t.Wa(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.Va&&(t.verificationId=this.a.Va),this.a.Ua&&(t.verificationCode=this.a.Ua),this.a.Ha&&(t.temporaryProof=this.a.Ha),this.a.ba&&(t.phoneNumber=this.a.ba),t},mo.prototype.Wa=function(e,n){var r=this.a.b;return Yt(n.verify()).then(function(t){if(!h(t))throw new Yr("argument-error","An implementation of firebase.auth.ApplicationVerifier.prototype.verify() must return a firebase.Promise that resolves with a string.");switch(n.type){case"recaptcha":return function(t,e){return Ns(t,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=xt("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=xt("This domain (%s) is not authorized to run this operation. Add it to the OAuth redirect domains list in the Firebase console -> Auth section -> Sign in method tab.",t):e="operation-not-supported-in-this-environment",Yr.call(this,e,n)}function Co(t,e,n){Yr.call(this,t,n),(t=e||{}).Ab&&Lr(this,"email",t.Ab),t.ba&&Lr(this,"phoneNumber",t.ba),t.credential&&Lr(this,"credential",t.credential),t.Qb&&Lr(this,"tenantId",t.Qb)}function No(t){if(t.code){var e=t.code||"";0==e.indexOf(Jr)&&(e=e.substring(Jr.length));var n={credential:vo(t),Qb:t.tenantId};if(t.email)n.Ab=t.email;else if(t.phoneNumber)n.ba=t.phoneNumber;else if(!n.credential)return new Yr(e,t.message||void 0);return new Co(e,n,t.message)}return null}function Ao(){}function Do(t){return t.c||(t.c=t.b())}function ko(){}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 xo(t,e){t.readyState=e,t.onreadystatechange&&t.onreadystatechange()}function Mo(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&&G(t,e),t},Co.prototype.toJSON=function(){return this.A()},Ao.prototype.c=null,S(ko,Ao),ko.prototype.a=function(){var t=Ro(this);return t?new ActiveXObject(t):new XMLHttpRequest},ko.prototype.b=function(){var t={};return Ro(this)&&(t[0]=!0,t[1]=!0),t},To=new ko,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,xo(this,4)},t.Ib=function(){this.status=500,this.response=this.responseText="",xo(this,4)},t.kc=function(){this.Ib()},t.gc=function(){this.status=200,xo(this,1)},t.getAllResponseHeaders=function(){return"content-type: "+this.a.contentType},Mo.prototype.a=null,Mo.prototype.reset=function(t,e,n,r,i){delete this.a},Fo.prototype.toString=function(){return this.name};var Uo=new Fo("SEVERE",1e3),Vo=new Fo("WARNING",900),qo=new Fo("CONFIG",700),Bo=new Fo("FINE",500);Lo.prototype.log=function(t,e,n){if(t.value>=function t(e){return e.c?e.c:e.a?t(e.a):(A("Root logger has no level set."),null)}(this).value)for(m(e)&&(e=e()),t=new Mo(t,String(e),this.f),n&&(t.a=n),n=this;n;)n=n.a};var jo,Wo={},Ko=null;function Qo(t){var e;if(Ko||(Ko=new Lo(""),(Wo[""]=Ko).c=qo),!(e=Wo[t])){e=new Lo(t);var n=t.lastIndexOf("."),r=t.substr(n+1);(n=Qo(t.substr(0,n))).b||(n.b={}),(n.b[r]=e).a=n,Wo[t]=e}return e}function Ho(t,e){t&&t.log(Bo,e,void 0)}function zo(t){this.f=t}function Go(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(zo,Ao),zo.prototype.a=function(){return new Go(this.f)},zo.prototype.b=(jo={},function(){return jo}),S(Go,nn);var Yo=0;function Xo(t){t.c.read().then(t.ec.bind(t)).catch(t.Oa.bind(t))}function Jo(t,e){e&&t.f&&(t.status=t.f.status,t.statusText=t.f.statusText),t.readyState=4,t.f=null,t.c=null,t.l=null,$o(t)}function $o(t){t.onreadystatechange&&t.onreadystatechange.call(t)}function Zo(t){nn.call(this),this.headers=new ln,this.B=t||null,this.c=!1,this.w=this.a=null,this.h=this.O=this.l="",this.f=this.J=this.i=this.I=!1,this.g=0,this.o=null,this.m=ta,this.v=this.P=!1}(t=Go.prototype).open=function(t,e){if(this.readyState!=Yo)throw this.abort(),Error("Error reopening a connection");this.m=t,this.g=e,this.readyState=1,$o(this)},t.send=function(t){if(1!=this.readyState)throw this.abort(),Error("need to call open() first. ");this.a=!0;var e={headers:this.i,method:this.m,credentials:void 0,cache:void 0};t&&(e.body=t),this.o.fetch(new Request(this.g,e)).then(this.jc.bind(this),this.Oa.bind(this))},t.abort=function(){this.response=this.responseText="",this.i=new Headers,this.status=0,this.c&&this.c.cancel("Request was aborted."),1<=this.readyState&&this.a&&4!=this.readyState&&(this.a=!1,Jo(this,!1)),this.readyState=Yo},t.jc=function(t){this.a&&(this.f=t,this.b||(this.b=t.headers,this.readyState=2,$o(this)),this.a&&(this.readyState=3,$o(this),this.a&&("arraybuffer"===this.responseType?t.arrayBuffer().then(this.hc.bind(this),this.Oa.bind(this)):void 0!==l.ReadableStream&&"body"in t?(this.response=this.responseText="",this.c=t.body.getReader(),this.l=new TextDecoder,Xo(this)):t.text().then(this.ic.bind(this),this.Oa.bind(this)))))},t.ec=function(t){if(this.a){var e=this.l.decode(t.value?t.value:new Uint8Array(0),{stream:!t.done});e&&(this.response=this.responseText+=e),t.done?Jo(this,!0):$o(this),3==this.readyState&&Xo(this)}},t.ic=function(t){this.a&&(this.response=this.responseText=t,Jo(this,!0))},t.hc=function(t){this.a&&(this.response=t,Jo(this,!0))},t.Oa=function(t){var e=this.h;e&&e.log(Vo,"Failed to fetch url "+this.g,t instanceof Error?t:Error(t)),this.a&&Jo(this,!0)},t.setRequestHeader=function(t,e){this.i.append(t,e)},t.getResponseHeader=function(t){return this.b?this.b.get(t.toLowerCase())||"":((t=this.h)&&t.log(Vo,"Attempting to get response header but no headers have been received for url: "+this.g,void 0),"")},t.getAllResponseHeaders=function(){if(!this.b){var t=this.h;return t&&t.log(Vo,"Attempting to get all response headers but no headers have been received for url: "+this.g,void 0),""}t=[];for(var e=this.b.entries(),n=e.next();!n.done;)n=n.value,t.push(n[0]+": "+n[1]),n=e.next();return t.join("\r\n")},S(Zo,nn);var ta="";Zo.prototype.b=Qo("goog.net.XhrIo");var ea=/^https?$/i,na=["POST","PUT"];function ra(e,t,n,r,i){if(e.a)throw Error("[goog.net.XhrIo] Object is active with another request="+e.l+"; newUri="+t);n=n?n.toUpperCase():"GET",e.l=t,e.h="",e.O=n,e.I=!1,e.c=!0,e.a=e.B?e.B.a():To.a(),e.w=e.B?Do(e.B):Do(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,!V(na,n)||i||r||o.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8"),o.forEach(function(t,e){this.a.setRequestHeader(e,t)},e),e.m&&(e.a.responseType=e.m),"withCredentials"in e.a&&e.a.withCredentials!==e.P&&(e.a.withCredentials=e.P);try{ca(e),0<e.g&&(e.v=function(t){return 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.Ia,e)):e.o=sn(e.Ia,e.g,e)),Ho(e.b,fa(e,"Sending request")),e.i=!0,e.a.send(t),e.i=!1}catch(t){Ho(e.b,fa(e,"Send error: "+t.message)),oa(e,t)}}function ia(t){return"content-type"==t.toLowerCase()}function oa(t,e){t.c=!1,t.a&&(t.f=!0,t.a.abort(),t.f=!1),t.h=e,aa(t),ua(t)}function aa(t){t.I||(t.I=!0,t.dispatchEvent("complete"),t.dispatchEvent("error"))}function sa(e){if(e.c&&void 0!==u)if(e.w[1]&&4==ha(e)&&2==la(e))Ho(e.b,fa(e,"Local request error detected and ignored"));else if(e.i&&4==ha(e))sn(e.Lb,0,e);else if(e.dispatchEvent("readystatechange"),4==ha(e)){Ho(e.b,fa(e,"Request complete")),e.c=!1;try{var t,n=la(e);t:switch(n){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var r=!0;break t;default:r=!1}if(!(t=r)){var i;if(i=0===n){var o=String(e.l).match(dn)[1]||null;if(!o&&l.self&&l.self.location){var a=l.self.location.protocol;o=a.substr(0,a.length-1)}i=!ea.test(o?o.toLowerCase():"")}t=i}if(t)e.dispatchEvent("complete"),e.dispatchEvent("success");else{try{var s=2<ha(e)?e.a.statusText:""}catch(t){Ho(e.b,"Can not get status: "+t.message),s=""}e.h=s+" ["+la(e)+"]",aa(e)}}finally{ua(e)}}}function ua(e,t){if(e.a){ca(e);var n=e.a,r=e.w[0]?p:null;e.a=null,e.w=null,t||e.dispatchEvent("ready");try{n.onreadystatechange=r}catch(t){(e=e.b)&&e.log(Uo,"Problem encountered resetting onreadystatechange: "+t.message,void 0)}}}function ca(t){t.a&&t.v&&(t.a.ontimeout=null),t.o&&(l.clearTimeout(t.o),t.o=null)}function ha(t){return t.a?t.a.readyState:0}function la(t){try{return 2<ha(t)?t.a.status:-1}catch(t){return-1}}function fa(t,e){return e+" ["+t.O+" "+t.l+" "+la(t)+"]"}function pa(t){var e=Sa;this.g=[],this.v=e,this.o=t||null,this.f=this.a=!1,this.c=void 0,this.u=this.w=this.i=!1,this.h=0,this.b=null,this.l=0}function da(t,e,n){t.a=!0,t.c=n,t.f=!e,va(t)}function 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&&va(t)}function ga(t){return U(t.g,function(t){return m(t[1])})}function va(e){if(e.h&&e.a&&ga(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,ga(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).Ia=function(){void 0!==u&&this.a&&(this.h="Timed out after "+this.g+"ms, aborting",Ho(this.b,fa(this,this.h)),this.dispatchEvent("timeout"),this.abort(8))},t.abort=function(){this.a&&this.c&&(Ho(this.b,fa(this,"Aborting")),this.c=!1,this.f=!0,this.a.abort(),this.f=!1,this.dispatchEvent("complete"),this.dispatchEvent("abort"),ua(this))},t.za=function(){this.a&&(this.c&&(this.c=!1,this.f=!0,this.a.abort(),this.f=!1),ua(this,!0)),Zo.qb.za.call(this)},t.Lb=function(){this.va||(this.J||this.i||this.f?sa(this):this.yc())},t.yc=function(){sa(this)},t.getResponse=function(){try{if(!this.a)return null;if("response"in this.a)return this.a.response;switch(this.m){case ta:case"text":return this.a.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in this.a)return this.a.mozResponseArrayBuffer}var t=this.b;return t&&t.log(Uo,"Response type "+this.m+" is not supported on this browser",void 0),null}catch(t){return Ho(this.b,"Can not get response: "+t.message),null}},pa.prototype.cancel=function(t){if(this.a)this.c instanceof pa&&this.c.cancel();else{if(this.b){var e=this.b;delete this.b,t?e.cancel(t):(e.l--,e.l<=0&&e.cancel())}this.v?this.v.call(this.o,this):this.u=!0,this.a||(t=new wa(this),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,Ia:void 0},a=new pa(o);return e=window.setTimeout(function(){Ia(i,!0);var t=new Aa(Na,"Timeout reached for loading script "+r);ya(a),da(a,!1,t)},5e3),o.Ia=e,i.onload=i.onreadystatechange=function(){i.readyState&&"loaded"!=i.readyState&&"complete"!=i.readyState||(Ia(i,!1,e),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)},G(o={},{type:"text/javascript",charset:"UTF-8"}),Bn(i,o),function(t,e){x(t,"HTMLScriptElement"),t.src=et(e),null===f&&(f=(e=(e=l.document).querySelector&&e.querySelector("script[nonce]"))&&(e=e.nonce||e.getAttribute("nonce"))&&s.test(e)?e:""),(e=f)&&t.setAttribute("nonce",e)}(i,t),function(t){var e;return(e=(t||document).getElementsByTagName("HEAD"))&&0!=e.length?e[0]:t.documentElement}(n).appendChild(i),a}function Sa(){if(this&&this.Nb){var t=this.Nb;t&&"SCRIPT"==t.tagName&&Ia(t,!0,this.Ia)}}function Ia(t,e,n){null!=n&&l.clearTimeout(n),t.onload=p,t.onerror=p,t.onreadystatechange=p,e&&window.setTimeout(function(){t&&t.parentNode&&t.parentNode.removeChild(t)},0)}var Ca=0,Na=1;function Aa(t,e){var n="Jsloader error (code #"+t+")";e&&(n+=": "+e),C.call(this,n),this.code=t}function Da(t){this.f=t}function ka(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||xa),this.h=t.firebaseEndpoint||"https://www.googleapis.com/identitytoolkit/v3/relyingparty/",this.i=t.firebaseTimeout||Ma,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 zo(self):cr()?this.f=new Da(n):this.f=new Oo,this.b=null}S(Aa,C),S(Da,Ao),Da.prototype.a=function(){return new this.f},Da.prototype.b=function(){return{}};var Ra,Oa="idToken",Pa=new Ar(3e4,6e4),xa={"Content-Type":"application/x-www-form-urlencoded"},Ma=new Ar(3e4,6e4),La={"Content-Type":"application/json"};function Fa(t,e){e?t.a["X-Firebase-Locale"]=e:delete t.a["X-Firebase-Locale"]}function Ua(t,e){e?(t.a["X-Client-Version"]=e,t.g["X-Client-Version"]=e):(delete t.a["X-Client-Version"],delete t.g["X-Client-Version"])}function Va(t,e,n,r,i,o,a){(t=function(){var t=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(qa,{onload:Ba})),function(){e(Error("CORS_UNSUPPORTED"))})}}(t,e)}),_(t.m,t)))(e,n,r,i,o,a)}ka.prototype.R=function(){return this.b},ka.prototype.o=function(t,n,e,r,i,o){if(sr()&&(void 0===l.fetch||void 0===l.Headers||void 0===l.Request))throw new Yr("operation-not-supported-in-this-environment","fetch, Headers and Request native APIs or equivalent Polyfills must be available to support HTTP requests from a Worker environment.");var a=new Zo(this.f);if(o){a.g=Math.max(0,o);var s=setTimeout(function(){a.dispatchEvent("timeout")},o)}rn(a,"complete",function(){s&&clearTimeout(s);var e=null;try{e=JSON.parse(function(e){try{return e.a?e.a.responseText:""}catch(t){return Ho(e.b,"Can not get responseText: "+t.message),""}}(this))||null}catch(t){e=null}n&&n(e)}),on(a,"ready",function(){s&&clearTimeout(s),le(this)}),on(a,"timeout",function(){s&&clearTimeout(s),le(this),n&&n(null)}),ra(a,t,e,r,i)};var qa=new Y($,"https://apis.google.com/js/client.js?onload=%{onload}"),Ba="__fcb"+Math.floor(1e6*Math.random()).toString();function ja(t){if(!h(t=t.email)||!rr.test(t))throw new Yr("invalid-email")}function Wa(t){"email"in t&&ja(t)}function Ka(t){if(!t[Oa])throw new Yr("internal-error")}function Qa(t){if(t.phoneNumber||t.temporaryProof){if(!t.phoneNumber||!t.temporaryProof)throw new Yr("internal-error")}else{if(!t.sessionInfo)throw new Yr("missing-verification-id");if(!t.code)throw new Yr("missing-verification-code")}}ka.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"}})})},ka.prototype.ob=function(){return Ns(this,vs,{})},ka.prototype.rb=function(t,e){return Ns(this,ms,{idToken:t,email:e})},ka.prototype.sb=function(t,e){return Ns(this,gs,{idToken:t,password:e})};var Ha={displayName:"DISPLAY_NAME",photoUrl:"PHOTO_URL"};function za(t){if(!t.requestUri||!t.sessionId&&!t.postBody&&!t.pendingToken)throw new Yr("internal-error")}function Ga(t,e){return e.oauthIdToken&&e.providerId&&0==e.providerId.indexOf("oidc.")&&!e.pendingToken&&(t.sessionId?e.nonce=t.sessionId:t.postBody&&(Mn(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=ka.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 G(t={requestType:"PASSWORD_RESET",email:t},e),Ns(this,ls,t)},t.lb=function(t,e){return G(t={requestType:"EMAIL_SIGNIN",email:t},e),Ns(this,cs,t)},t.jb=function(t,e){return G(t={requestType:"VERIFY_EMAIL",idToken:t},e),Ns(this,hs,t)},t.Wa=function(t){return Ns(this,Ss,t)},t.ab=function(t,e){return Ns(this,ds,{oobCode:t,newPassword:e})},t.Ma=function(t){return Ns(this,es,{oobCode:t})},t.Ya=function(t){return Ns(this,ts,{oobCode:t})};var ts={endpoint:"setAccountInfo",D:Za,fa:"email",F:!0},es={endpoint:"resetPassword",D:Za,K:function(t){var e=t.requestType;if(!e||!t.email&&"EMAIL_SIGNIN"!=e)throw new Yr("internal-error")},F:!0},ns={endpoint:"signupNewUser",D:function(t){if(ja(t),!t.password)throw new Yr("weak-password")},K:Ka,T:!0,F:!0},rs={endpoint:"createAuthUri",F:!0},is={endpoint:"deleteAccount",V:["idToken"]},os={endpoint:"setAccountInfo",V:["idToken","deleteProvider"],D:function(t){if(!d(t.deleteProvider))throw new Yr("internal-error")}},as={endpoint:"emailLinkSignin",V:["email","oobCode"],D:ja,K:Ka,T:!0,F:!0},ss={endpoint:"emailLinkSignin",V:["idToken","email","oobCode"],D:ja,K:Ka,T:!0},us={endpoint:"getAccountInfo"},cs={endpoint:"getOobConfirmationCode",V:["requestType"],D:function(t){if("EMAIL_SIGNIN"!=t.requestType)throw new Yr("internal-error");ja(t)},fa:"email",F:!0},hs={endpoint:"getOobConfirmationCode",V:["idToken","requestType"],D:function(t){if("VERIFY_EMAIL"!=t.requestType)throw new Yr("internal-error")},fa:"email",F:!0},ls={endpoint:"getOobConfirmationCode",V:["requestType"],D:function(t){if("PASSWORD_RESET"!=t.requestType)throw new Yr("internal-error");ja(t)},fa:"email",F:!0},fs={wb:!0,endpoint:"getProjectConfig",Kb:"GET"},ps={wb:!0,endpoint:"getRecaptchaParam",Kb:"GET",K:function(t){if(!t.recaptchaSiteKey)throw new Yr("internal-error")}},ds={endpoint:"resetPassword",D:Za,fa:"email",F:!0},ys={endpoint:"sendVerificationCode",V:["phoneNumber","recaptchaToken"],fa:"sessionInfo",F:!0},ms={endpoint:"setAccountInfo",V:["idToken"],D:Wa,T:!0},gs={endpoint:"setAccountInfo",V:["idToken"],D:function(t){if(Wa(t),!t.password)throw new Yr("weak-password")},K:Ka,T:!0},vs={endpoint:"signupNewUser",K:Ka,T:!0,F:!0},bs={endpoint:"verifyAssertion",D:za,Ra:Ga,K:Ya,T:!0,F:!0},ws={endpoint:"verifyAssertion",D:za,Ra:Ga,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(za(t),!t.idToken)throw new Yr("internal-error")},Ra:Ga,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){Va(t,a.toString(),function(t){t?t.error?n(Ds(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.Ra?e.Ra(n,r):r}).then(e.K).then(function(){if(!e.fa)return r;if(!(e.fa in r))throw new Yr("internal-error");return r[e.fa]})}function As(t){return Ds({error:{errors:[{message:t}],code:400,message:t}})}function Ds(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||"",G(r={INVALID_CUSTOM_TOKEN:"invalid-custom-token",CREDENTIAL_MISMATCH:"custom-token-mismatch",MISSING_CUSTOM_TOKEN:"internal-error",INVALID_IDENTIFIER:"invalid-email",MISSING_CONTINUE_URI:"internal-error",INVALID_EMAIL:"invalid-email",INVALID_PASSWORD:"wrong-password",USER_DISABLED:"user-disabled",MISSING_PASSWORD:"internal-error",EMAIL_EXISTS:"email-already-in-use",PASSWORD_LOGIN_DISABLED:"operation-not-allowed",INVALID_IDP_RESPONSE:"invalid-credential",INVALID_PENDING_TOKEN:"invalid-credential",FEDERATED_USER_ID_ALREADY_LINKED:"credential-already-in-use",MISSING_OR_INVALID_NONCE:"missing-or-invalid-nonce",INVALID_MESSAGE_PAYLOAD:"invalid-message-payload",INVALID_RECIPIENT_EMAIL:"invalid-recipient-email",INVALID_SENDER:"invalid-sender",EMAIL_NOT_FOUND:"user-not-found",RESET_PASSWORD_EXCEED_LIMIT:"too-many-requests",EXPIRED_OOB_CODE:"expired-action-code",INVALID_OOB_CODE:"invalid-action-code",MISSING_OOB_CODE:"internal-error",INVALID_PROVIDER_ID:"invalid-provider-id",CREDENTIAL_TOO_OLD_LOGIN_AGAIN:"requires-recent-login",INVALID_ID_TOKEN:"invalid-user-token",TOKEN_EXPIRED:"user-token-expired",USER_NOT_FOUND:"user-token-expired",CORS_UNSUPPORTED:"cors-unsupported",DYNAMIC_LINK_NOT_ACTIVATED:"dynamic-link-not-activated",INVALID_APP_ID:"invalid-app-id",TOO_MANY_ATTEMPTS_TRY_LATER:"too-many-requests",WEAK_PASSWORD:"weak-password",OPERATION_NOT_ALLOWED:"operation-not-allowed",USER_CANCELLED:"user-cancelled",CAPTCHA_CHECK_FAILED:"captcha-check-failed",INVALID_APP_CREDENTIAL:"invalid-app-credential",INVALID_CODE:"invalid-verification-code",INVALID_PHONE_NUMBER:"invalid-phone-number",INVALID_SESSION_INFO:"invalid-verification-id",INVALID_TEMPORARY_PROOF:"invalid-credential",MISSING_APP_CREDENTIAL:"missing-app-credential",MISSING_CODE:"missing-verification-code",MISSING_PHONE_NUMBER:"missing-phone-number",MISSING_SESSION_INFO:"missing-verification-id",QUOTA_EXCEEDED:"quota-exceeded",SESSION_EXPIRED:"code-expired",REJECTED_CREDENTIAL:"rejected-credential",INVALID_CONTINUE_URI:"invalid-continue-uri",MISSING_ANDROID_PACKAGE_NAME:"missing-android-pkg-name",MISSING_IOS_BUNDLE_ID:"missing-ios-bundle-id",UNAUTHORIZED_DOMAIN:"unauthorized-continue-uri",INVALID_DYNAMIC_LINK_DOMAIN:"invalid-dynamic-link-domain",INVALID_OAUTH_CLIENT_ID:"invalid-oauth-client-id",INVALID_CERT_HASH:"invalid-cert-hash",UNSUPPORTED_TENANT_OPERATION:"unsupported-tenant-operation",INVALID_TENANT_ID:"invalid-tenant-id",TENANT_ID_MISMATCH:"tenant-id-mismatch",ADMIN_ONLY_OPERATION:"admin-restricted-operation"},e||{}),e=(e=n.match(/^[^\s]+\s*:\s*([\s\S]*)$/))&&1<e.length?e[1]:void 0,r)if(0===n.indexOf(i))return new Yr(r[i],e);return!e&&t&&(e=Er(t)),new Yr("internal-error",e)}function ks(t){this.b=t,this.a=null,this.gb=function(o){return(xs=xs||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 xs=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),xs=null;function Ms(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().Ca()}catch(t){return[]}}function Us(t,e,n,r,i){this.u=t,this.f=e,this.b=n,this.c=r||null,this.h=i||null,this.m=this.o=this.v=null,this.g=[],this.l=this.a=null}function Vs(t){var s=Jn();return function(t){return Ns(t,fs,{}).then(function(t){return t.authorizedDomains||[]})}(t).then(function(t){t:{var e=_n(s),n=e.f;e=e.b;for(var r=0;r<t.length;r++){var i=t[r],o=e,a=n;if(o=0==i.indexOf("chrome-extension://")?_n(i).b==o&&"chrome-extension"==a:("http"==a||"https"==a)&&(nr.test(i)?o==i:(i=i.split(".").join("\\."),new RegExp("^(.+\\."+i+"|"+i+")$","i").test(o)))){t=!0;break t}}t=!1}if(!t)throw new Io(Jn())})}function qs(i){return i.l||(i.l=ir().then(function(){if(!i.o){var t=i.c,e=i.h,n=Fs(i.b),r=new Ms(i.u,i.f,i.b);r.f=t,r.b=e,r.c=W(n||[]),i.o=r.toString()}i.i=new ks(i.o),function(r){if(!r.i)throw Error("IfcHandler must be initialized!");!function(t,e){t.gb.then(function(){t.a.register("authEvent",e,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 ka(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)}Ms.prototype.toString=function(){return this.f?bn(this.a,"v",this.f):xn(this.a.a,"v"),this.b?bn(this.a,"eid",this.b):xn(this.a.a,"eid"),this.c.length?bn(this.a,"fw",this.c.join(",")):xn(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.bb=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.eb&&e.bb&&!n[e.eb]&&(n[e.eb]=e.bb),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):xn(t.a,"redirectUrl"),this.g?bn(t,"eventId",this.g):xn(t.a,"eventId"),this.i?bn(t,"v",this.i):xn(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):xn(t.a,"tid"),this.f?bn(t,"eid",this.f):xn(t.a,"eid"),(a=Fs(this.c)).length&&bn(t,"fw",a.join(",")),t.toString()},(t=Us.prototype).Fb=function(e,n,t){var r=new Yr("popup-closed-by-user"),i=new Yr("web-storage-unsupported"),o=this,a=!1;return this.ia().then(function(){(function(t){var e={type:"webStorageSupport"};return qs(t).then(function(){return function(e,n){return e.gb.then(function(){return new jt(function(t){e.a.send(n.type,n,t,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=Vs(Bs(this)));var u=this;return this.a.then(function(){var t=u.ia().s(function(t){throw tr(e),i(t),t});return r(),t}).then(function(){bo(n),a||$n(js(u.u,u.f,u.b,t,n,null,o,u.c,void 0,u.h,s),e)}).s(function(t){throw"auth/network-request-failed"==t.code&&(u.a=null),t})},t.Eb=function(t,e,n,r){this.a||(this.a=Vs(Bs(this)));var i=this;return this.a.then(function(){bo(e),$n(js(i.u,i.f,i.b,t,e,Jn(),n,i.c,void 0,i.h,r))}).s(function(t){throw"auth/network-request-failed"==t.code&&(i.a=null),t})},t.ia=function(){var t=this;return qs(this).then(function(){return t.i.gb}).s(function(){throw t.a=null,new Yr("network-request-failed")})},t.Rb=function(){return!0},t.Aa=function(t){this.g.push(t)},t.Na=function(e){B(this.g,function(t){return t==e})},(t=Ws.prototype).get=function(t){return Yt(this.a.getItem(t)).then(function(t){return t&&Sr(t)})},t.set=function(t,e){return Yt(this.a.setItem(t,Er(e)))},t.S=function(t){return Yt(this.a.removeItem(t))},t.$=function(){},t.ea=function(){};var Qs,Hs=[];function zs(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 Gs(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}(),zs(this.l,"keyChanged",function(t,n){return au(r).then(function(e){return 0<e.length&&L(r.a,function(t){t(e)}),{keyProcessed:V(e,n.key)}})}),zs(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 Gs(t)),Xs(r.g,"ping",null,!0).then(function(t){t[0].fulfilled&&V(t[0].value,"keyChanged")&&(r.o=!0)}).s(function(){}))})}function Zs(r){return new jt(function(e,n){var t=r.u.open("firebaseLocalStorageDb",1);t.onerror=function(t){try{t.preventDefault()}catch(t){}n(Error(t.target.error))},t.onupgradeneeded=function(t){t=t.target.result;try{t.createObjectStore("firebaseLocalStorage",{keyPath:"fbase_key"})}catch(t){n(t)}},t.onsuccess=function(t){(t=t.target.result).objectStoreNames.contains("firebaseLocalStorage")?e(t):function(r){return new jt(function(t,e){var n=r.u.deleteDatabase("firebaseLocalStorageDb");n.onsuccess=function(){t()},n.onerror=function(t){e(Error(t.target.error))}})}(r).then(function(){return Zs(r)}).then(function(t){e(t)}).s(function(t){n(t)})}})}function tu(t){return t.m||(t.m=Zs(t)),t.m}function eu(){try{return!!l.indexedDB}catch(t){return!1}}function nu(t){return t.objectStore("firebaseLocalStorage")}function ru(t,e){return t.transaction(["firebaseLocalStorage"],e?"readwrite":"readonly")}function iu(t){return new jt(function(e,n){t.onsuccess=function(t){t&&t.target?e(t.target.result):e()},t.onerror=function(t){n(t.target.error)}})}function ou(t,e){return t.g&&t.h&&function(){var t=l.navigator;return t&&t.serviceWorker&&t.serviceWorker.controller||null}()===t.h?Xs(t.g,"keyChanged",{key:e},t.o).then(function(){}).s(function(){}):Yt()}function au(r){return tu(r).then(function(t){var i=nu(ru(t,!1));return i.getAll?iu(i.getAll()):new jt(function(e,n){var r=[],t=i.openCursor();t.onsuccess=function(t){(t=t.target.result)?(r.push(t.value),t.continue()):e(r)},t.onerror=function(t){n(t.target.error)}})}).then(function(t){var e={},n=[];if(0==r.b){for(n=0;n<t.length;n++)e[t[n].fbase_key]=t[n].value;n=function t(e,n){var r,i=[];for(r in e)r in n?typeof e[r]!=typeof n[r]?i.push(r):"object"==typeof e[r]&&null!=e[r]&&null!=n[r]?0<t(e[r],n[r]).length&&i.push(r):e[r]!==n[r]&&i.push(r):i.push(r);for(r in n)r in e||i.push(r);return i}(r.c,e),r.c=e}return n})}function su(t){t.i&&t.i.cancel("STOP_EVENT"),t.f&&(clearTimeout(t.f),t.f=null)}function uu(t){var r=this,i=null;this.a=[],this.type="indexedDB",this.c=t,this.b=Yt().then(function(){if(eu()){var e=Ir(),n="__sak"+e;return Qs=Qs||new $s,(i=Qs).set(n,e).then(function(){return i.get(n)}).then(function(t){if(t!==e)throw Error("indexedDB not supported!");return i.S(n)}).then(function(){return i}).s(function(){return r.c})}return r.c}).then(function(t){return r.type=t.type,t.$(function(e){L(r.a,function(t){t(e)})}),t})}function cu(){this.a={},this.type="inMemory"}function hu(){if(!function(){var t="Node"==ur();if(!(t=lu()||t&&fl.INTERNAL.node&&fl.INTERNAL.node.localStorage))return!1;try{return t.setItem("__sak","1"),t.removeItem("__sak"),!0}catch(t){return!1}}()){if("Node"==ur())throw new Yr("internal-error","The LocalStorage compatibility library was not found.");throw new Yr("web-storage-unsupported")}this.a=lu()||fl.INTERNAL.node.localStorage,this.type="localStorage"}function lu(){try{var t=l.localStorage,e=Ir();return t&&(t.setItem(e,"1"),t.removeItem(e)),t}catch(t){return null}}function fu(){this.type="nullStorage"}function pu(){if(!function(){var t="Node"==ur();if(!(t=du()||t&&fl.INTERNAL.node&&fl.INTERNAL.node.sessionStorage))return!1;try{return t.setItem("__sak","1"),t.removeItem("__sak"),!0}catch(t){return!1}}()){if("Node"==ur())throw new Yr("internal-error","The SessionStorage compatibility library was not found.");throw new Yr("web-storage-unsupported")}this.a=du()||fl.INTERNAL.node.sessionStorage,this.type="sessionStorage"}function du(){try{var t=l.sessionStorage,e=Ir();return t&&(t.setItem(e,"1"),t.removeItem(e)),t}catch(t){return null}}function yu(){var t={};t.Browser=vu,t.Node=bu,t.ReactNative=wu,t.Worker=_u,this.a=t[ur()]}Ks.prototype.c=function(n){var r=n.data.eventType,i=n.data.eventId,t=this.a[r];if(t&&0<t.length){n.ports[0].postMessage({status:"ack",eventId:i,eventType:r,response:null});var e=[];L(t,function(t){e.push(Yt().then(function(){return t(n.origin,n.data.data)}))}),$t(e).then(function(t){var e=[];L(t,function(t){e.push({fulfilled:t.Gb,value:t.value,reason:t.reason?t.reason.message:void 0})}),L(e,function(t){for(var e in t)void 0===t[e]&&delete t[e]}),n.ports[0].postMessage({status:"done",eventId:i,eventType:r,response:e})})}},Gs.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&&ze(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,gu,vu={C:hu,Ta:pu},bu={C:hu,Ta:pu},wu={C:Ws,Ta:fu},_u={C:hu,Ta:fu},Eu={ad:"local",NONE:"none",cd:"session"};function Tu(){var t=!(Cr(yr())||!ar()),e=_r(),n=gr();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.Ta}catch(t){this.i=new cu}this.u=new cu,this.f=_(this.Pb,this),this.b={}}function Su(){return gu=gu||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 Du(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.$a(n))}else if(0==e.indexOf("firebase:")&&this.a[e]){if(void 0!==t.a.a?Iu(this,"local").ea(this.f):Au(this),this.m)if(n=l.localStorage.getItem(e),(r=t.a.newValue)!==n)null!==r?l.localStorage.setItem(e,r):l.localStorage.removeItem(e);else if(this.b[e]===r&&void 0===t.a.a)return;var o=this;n=function(){void 0===t.a.a&&o.b[e]===l.localStorage.getItem(e)||(o.b[e]=l.localStorage.getItem(e),o.$a(e))},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.$a,this))},t.$a=function(t){this.a[t]&&L(this.a[t],function(t){t()})};var ku,Ru={name:"authEvent",C:"local"};function Ou(){this.a=Su()}function Pu(t,e){this.b=xu,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!==ku||(ku=l.Int32Array?new Int32Array(Bu):Bu),this.reset()}S(Pu,function(){this.b=-1});for(var xu=64,Mu=xu-1,Lu=[],Fu=0;Fu<Mu;Fu++)Lu[Fu]=0;var Uu=j(128,Lu);function Vu(t){for(var e=t.f,n=t.l,r=0,i=0;i<e.length;)n[r++]=e[i]<<24|e[i+1]<<16|e[i+2]<<8|e[i+3],i=4*r;for(e=16;e<64;e++){i=0|n[e-15],r=0|n[e-2];var o=(0|n[e-16])+((i>>>7|i<<25)^(i>>>18|i<<14)^i>>>3)|0,a=(0|n[e-7])+((r>>>17|r<<15)^(r>>>19|r<<13)^r>>>10)|0;n[e]=o+a|0}r=0|t.a[0],i=0|t.a[1];var s=0|t.a[2],u=0|t.a[3],c=0|t.a[4],h=0|t.a[5],l=0|t.a[6];for(o=0|t.a[7],e=0;e<64;e++){var f=((r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10))+(r&i^r&s^i&s)|0;a=(o=o+((c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7))|0)+((a=(a=c&h^~c&l)+(0|ku[e])|0)+(0|n[e])|0)|0,o=l,l=h,h=c,c=u+a|0,u=s,s=i,i=r,r=a+f|0}t.a[0]=t.a[0]+r|0,t.a[1]=t.a[1]+i|0,t.a[2]=t.a[2]+s|0,t.a[3]=t.a[3]+u|0,t.a[4]=t.a[4]+c|0,t.a[5]=t.a[5]+h|0,t.a[6]=t.a[6]+l|0,t.a[7]=t.a[7]+o|0}function qu(t,e,n){void 0===n&&(n=e.length);var r=0,i=t.c;if(h(e))for(;r<n;)t.f[i++]=e.charCodeAt(r++),i==t.b&&(Vu(t),i=0);else{if(!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&&(Vu(t),i=0)}}t.c=i,t.g+=n}Pu.prototype.reset=function(){this.g=this.c=0,this.a=l.Int32Array?new Int32Array(this.h):W(this.h)};var Bu=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function ju(){Pu.call(this,8,Wu)}S(ju,Pu);var Wu=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];function Ku(t,e,n,r,i){this.u=t,this.i=e,this.l=n,this.m=r||null,this.o=i||null,this.h=e+":"+n,this.v=new Ou,this.g=new Du(this.h),this.f=null,this.b=[],this.a=this.c=null}function Qu(t){return new Yr("invalid-cordova-configuration",t)}function Hu(t){var e=new ju;qu(e,t),t=[];var n=8*e.g;e.c<56?qu(e,Uu,56-e.c):qu(e,Uu,e.b-(e.c-56));for(var r=63;56<=r;r--)e.f[r]=255&n,n/=256;for(Vu(e),r=n=0;r<e.i;r++)for(var i=24;0<=i;i-=8)t[n++]=e.a[r]>>i&255;return function(t){return F(t,function(t){return 1<(t=t.toString(16)).length?t:"0"+t}).join("")}(t)}function zu(t,e){for(var n=0;n<t.b.length;n++)try{t.b[n](e)}catch(t){}}function Gu(r){return r.f||(r.f=r.ia().then(function(){return new jt(function(n){r.Aa(function t(e){return n(e),r.Na(t),!1}),function(i){function e(r){t=!0,n&&n.cancel(),Yu(i).then(function(t){var e=o;if(t&&r&&r.url){var n=null;-1!=(e=Bi(r.url)).indexOf("/__/auth/callback")&&(n=(n="object"==typeof(n=Sr(wn(n=_n(e),"firebaseError")||null))?Xr(n):null)?new wo(t.c,t.b,null,null,n,null,t.R()):new wo(t.c,t.b,e,t.f,null,null,t.R())),e=n||o}zu(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||zu(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.Da?this.Da:this.Da=(or(void 0)?ir().then(function(){return new jt(function(t,e){var n=l.document,r=setTimeout(function(){e(Error("Cordova framework is not ready."))},1e3);n.addEventListener("deviceready",function(){clearTimeout(r),t()},!1)})}):Xt(Error("Cordova must run in an Android or iOS file scheme."))).then(function(){if("function"!=typeof 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),Gu(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.Aa(s),u=function(){a=a||un(2e3).then(function(){t(new Yr("redirect-cancelled-by-user"))})},c=function(){Dr()&&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.Na(s),i.c=null})},t.Aa=function(e){this.b.push(e),Gu(this).s(function(t){"auth/invalid-cordova-configuration"===t.code&&(t=new wo("unknown",null,null,null,new Yr("no-auth-event")),e(t))})},t.Na=function(e){B(this.b,function(t){return t==e})};var Ju={name:"pendingRedirect",C:"session"};function $u(t){return Nu(t.b,Ju,t.a)}function Zu(t,e,n){this.i={},this.v=0,this.B=t,this.u=e,this.m=n,this.h=[],this.f=!1,this.l=_(this.o,this),this.b=new pc,this.w=new vc,this.g=new Xu(this.u+":"+this.m),this.c={},this.c.unknown=this.b,this.c.signInViaRedirect=this.b,this.c.linkViaRedirect=this.b,this.c.reauthViaRedirect=this.b,this.c.signInViaPopup=this.w,this.c.linkViaPopup=this.w,this.c.reauthViaPopup=this.w,this.a=tc(this.B,this.u,this.m,Ii)}function tc(t,e,n,r){var i=fl.SDK_VERSION||null;return or()?new Ku(t,e,n,i,r):new Us(t,e,n,i,r)}function ec(e){e.f||(e.f=!0,e.a.Aa(e.l));var n=e.a;return e.a.ia().s(function(t){throw e.a==n&&e.reset(),t})}function nc(n){n.a.Ob()&&ec(n).s(function(t){var e=new wo("unknown",null,null,null,new Yr("operation-not-supported-in-this-environment"));uc(t)&&n.o(e)}),n.a.Jb()||dc(n.b)}function rc(n,t){V(n.h,t)||n.h.push(t),n.f||function(t){return t.b.get(Ju,t.a).then(function(t){return"pending"==t})}(n.g).then(function(t){t?$u(n.g).then(function(){ec(n).s(function(t){var e=new wo("unknown",null,null,null,new Yr("operation-not-supported-in-this-environment"));uc(t)&&n.o(e)})}):nc(n)}).s(function(){nc(n)})}function ic(t,e){B(t.h,function(t){return t==e})}Zu.prototype.reset=function(){this.f=!1,this.a.Na(this.l),this.a=tc(this.B,this.u,this.m),this.i={}},Zu.prototype.o=function(t){if(!t)throw new Yr("invalid-auth-event");if(6e5<=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.Aa(t.l))},function(){t.reset()},i,o,a)}function uc(t){return!(!t||"auth/cordova-not-ready"!=t.code)}function cc(e,t,n,r,i){var o;return function(t){return t.b.set(Ju,"pending",t.a)}(e.g).then(function(){return e.a.Eb(t,n,r,i).s(function(t){if(uc(t))throw new Yr("operation-not-supported-in-this-environment");return o=t,$u(e.g).then(function(){throw o})}).then(function(){return e.a.Rb()?new jt(function(){}):$u(e.g).then(function(){return e.oa()}).then(function(){}).s(function(){})})})}function hc(t,e,n,r,i){return t.a.Fb(r,function(t){e.ja(n,null,t,i)},oc.get())}Zu.prototype.oa=function(){return this.b.oa()};var lc={};function fc(t,e,n){var r=e+":"+n;return lc[r]||(lc[r]=new Zu(t,e,n)),lc[r]}function pc(){this.b=null,this.f=[],this.c=[],this.a=null,this.i=this.g=!1}function dc(t){t.g||(t.g=!0,gc(t,!1,null,null))}function yc(t){t.g&&!t.i&&gc(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 gc(t,e,n,r){e?r?function(t,e){if(t.b=function(){return Xt(e)},t.c.length)for(var n=0;n<t.c.length;n++)t.c[n](e)}(t,r):mc(t,n):mc(t,{user:null}),t.f=[],t.c=[]}function vc(){}function bc(){this.vb=!1,Object.defineProperty(this,"appVerificationDisabled",{get:function(){return this.vb},set:function(t){this.vb=t},enumerable:!1})}function wc(t,e){this.a=e,Lr(this,"verificationId",t)}function _c(t,e,n,r){return new mo(t).Wa(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:kr(1e3*e.exp),authTime:kr(1e3*e.auth_time),issuedAtTime:kr(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?Va(t,t.l+"?key="+encodeURIComponent(t.c),function(t){t?t.error?n(Ds(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 Dc(t,e){this.a=t||null,this.b=e||null,Fr(this,{lastSignInTime:kr(e||null),creationTime:kr(t||null)})}function kc(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 ka(this.l,Ni(Ii),t),this.b=new Ic(this.a),Vc(this,e[Oa]),Cc(this.b,e),Lr(this,"refreshToken",this.b.a),jc(this,n||{}),nn.call(this),this.J=!1,this.o&&vr()&&(this.i=fc(this.o,this.l,this.m)),this.O=[],this.h=null,this.w=function(e){return new 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.Ja,this);var r=this;this.ga=null,this.xa=function(t){r.ua(t.g)},this.Z=null,this.P=[],this.wa=function(t){xc(r,t.c)},this.Y=null}function Pc(t,e){t.Z&&ze(t.Z,"languageCodeChanged",t.xa),(t.Z=e)&&Ke(e,"languageCodeChanged",t.xa)}function xc(t,e){t.P=e,Ua(t.a,fl.SDK_VERSION?dr(fl.SDK_VERSION,t.P):null)}function Mc(t,e){t.Y&&ze(t.Y,"frameworkChanged",t.wa),(t.Y=e)&&Ke(e,"frameworkChanged",t.wa)}function Lc(e){try{return fl.app(e.m).auth()}catch(t){throw new Yr("internal-error","No firebase.auth.Auth instance is available for the Firebase App '"+e.m+"'!")}}function Fc(t){t.B||t.w.b||(t.w.start(),ze(t,"tokenChanged",t.W),Ke(t,"tokenChanged",t.W))}function Uc(t){ze(t,"tokenChanged",t.W),t.w.stop()}function Vc(t,e){t.ma=e,Lr(t,"_lat",e)}function qc(t){for(var e=[],n=0;n<t.O.length;n++)e.push(t.O[n](t));return $t(e).then(function(){return t})}function Bc(t){t.i&&!t.J&&(t.J=!0,rc(t.i,t))}function jc(t,e){Fr(t,{uid:e.uid,displayName:e.displayName||null,photoURL:e.photoURL||null,email:e.email||null,emailVerified:e.emailVerified||!1,phoneNumber:e.phoneNumber||null,isAnonymous:e.isAnonymous||!1,tenantId:e.tenantId||null,metadata:new Dc(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&&(zc(t,e.providerId),t.providerData.push(e))}function zc(t,e){B(t.providerData,function(t){return t.providerId==e})}function Gc(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 Dc(t.a,t.b)}(t.metadata)):Lr(e,"metadata",new Dc),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||Gc(n,"isAnonymous",!1),t})})}function Jc(t,e){e[Oa]&&t.ma!=e[Oa]&&(Cc(t.b,e),t.dispatchEvent(new Rc("tokenChanged")),Vc(t,e[Oa]),Gc(t,"refreshToken",t.b.a))}function $c(t,e){return Xc(t).then(function(){if(V(Qc(t),e))return qc(t).then(function(){throw new Yr("provider-already-linked")})})}function Zc(t,e,n){return Ur({user:t,credential:vo(e),additionalUserInfo:e=Oi(e),operationType:n})}function th(t,e){return Jc(t,e),t.reload().then(function(){return t})}function eh(n,r,t,e,i){if(!vr())return Xt(new Yr("operation-not-supported-in-this-environment"));if(n.h&&!i)return Xt(n.h);var o=Ri(t.providerId),a=Ir(n.uid+":::"),s=null;(!_r()||ar())&&n.o&&t.isOAuthProvider&&(s=js(n.o,n.l,n.m,r,t,null,a,fl.SDK_VERSION||null,null,null,n.tenantId));var u=er(s,o&&o.sa,o&&o.ra);return e=e().then(function(){if(rh(n),!i)return n.G().then(function(){})}).then(function(){return sc(n.i,u,r,t,a,!!s,n.tenantId)}).then(function(){return new jt(function(t,e){n.ja(r,null,new Yr("cancelled-popup-request"),n.g||null),n.f=t,n.v=e,n.g=a,n.c=hc(n.i,n,r,u,a)})}).then(function(t){return u&&tr(u),t?Ur(t):null}).s(function(t){throw u&&tr(u),t}),ih(n,e,i)}function nh(e,t,n,r,i){if(!vr())return Xt(new Yr("operation-not-supported-in-this-environment"));if(e.h&&!i)return Xt(e.h);var o=null,a=Ir(e.uid+":::");return r=r().then(function(){if(rh(e),!i)return e.G().then(function(){})}).then(function(){return e.ca=a,qc(e)}).then(function(t){return e.da&&(t=(t=e.da).b.set(sh,e.A(),t.a)),t}).then(function(){return cc(e.i,t,n,a,e.tenantId)}).s(function(t){if(o=t,e.da)return uh(e.da);throw o}).then(function(){if(o)throw o}),ih(e,r,i)}function rh(t){if(!t.i||!t.J){if(t.i&&!t.J)throw new Yr("internal-error");throw new Yr("auth-domain-config-required")}}function ih(t,e,n){var r=function(e,t,n){return e.h&&!n?(t.cancel(),Xt(e.h)):t.s(function(t){throw!t||"auth/user-disabled"!=t.code&&"auth/user-token-expired"!=t.code||(e.h||e.dispatchEvent(new Rc("userInvalidated")),e.h=t),t})}(t,e,n);return t.I.push(r),r.ka(function(){q(t.I,r)}),r}function oh(t){if(!t.apiKey)return null;var e={apiKey:t.apiKey,authDomain:t.authDomain,appName:t.appName},n={};if(!(t.stsTokenManager&&t.stsTokenManager.accessToken&&t.stsTokenManager.expirationTime))return null;n[Oa]=t.stsTokenManager.accessToken,n.refreshToken=t.stsTokenManager.refreshToken||null,n.expiresIn=(t.stsTokenManager.expirationTime-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?(gc(this,!0,null,t.a),Yt()):e.Ba(n,r)?function(e,t,n){n=n.Ba(t.c,t.b);var r=t.g,i=t.f,o=t.i,a=t.R(),s=!!t.c.match(/Redirect$/);n(r,i,a,o).then(function(t){gc(e,s,t,null)}).s(function(t){gc(e,s,null,t)})}(this,t,e):Xt(new Yr("invalid-auth-event")):(gc(this,!1,null,null),Yt())}else Xt(new Yr("invalid-auth-event"))},pc.prototype.oa=function(){var n=this;return new jt(function(t,e){n.b?n.b().then(t,e):(n.f.push(t),n.c.push(e),function(t){var e=new Yr("timeout");t.a&&t.a.cancel(),t.a=un(ac.get()).then(function(){t.b||(t.g=!0,gc(t,!0,null,e))})}(n))})},vc.prototype.h=function(t,e){if(t){var n=t.c,r=t.b;t.a?(e.ja(t.c,null,t.a,t.b),Yt()):e.Ba(n,r)?function(t,e){var n=t.b,r=t.c;e.Ba(r,n)(t.g,t.f,t.R(),t.i).then(function(t){e.ja(r,t,null,n)}).s(function(t){e.ja(r,null,t,n)})}(t,e):Xt(new Yr("invalid-auth-event"))}else Xt(new Yr("invalid-auth-event"))},wc.prototype.confirm=function(t){return t=go(this.verificationId,t),this.a(t)},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,Dr()||!e?Yt():new jt(function(t){n=function(){Dr()&&(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})},Dc.prototype.A=function(){return{lastLoginAt:this.b,createdAt:this.a}},S(Rc,Oe),S(Oc,nn),Oc.prototype.ua=function(t){this.ga=t,Fa(this.a,t)},Oc.prototype.ha=function(){return this.ga},Oc.prototype.Ca=function(){return W(this.P)},Oc.prototype.Ja=function(){this.w.b&&(this.w.stop(),this.w.start())},Lr(Oc.prototype,"providerId","firebase"),(t=Oc.prototype).reload=function(){var t=this;return ih(this,Kc(this).then(function(){return Xc(t).then(function(){return qc(t)}).then(Wc)}))},t.dc=function(t){return this.G(t).then(function(t){return new 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&&(Vc(e,t.accessToken),e.dispatchEvent(new Rc("tokenChanged"))),Gc(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 kc(t.rawId,t.providerId,t.email,t.displayName,t.photoUrl,t.phoneNumber)}):[]}(t),n=0;n<e.length;n++)Hc(this,e[n]);Gc(this,"isAnonymous",!(this.email&&t.passwordHash||this.providerData&&this.providerData.length))},t.Ac=function(t){return xr("firebase.User.prototype.reauthenticateAndRetrieveDataWithCredential is deprecated. Please use firebase.User.prototype.reauthenticateWithCredential instead."),this.hb(t)},t.hb=function(t){var e=this,n=null;return ih(this,t.f(this.a,this.uid).then(function(t){return Jc(e,t),n=Zc(e,t,"reauthenticate"),e.h=null,e.reload()}).then(function(){return n}),!0)},t.rc=function(t){return xr("firebase.User.prototype.linkAndRetrieveDataWithCredential is deprecated. Please use firebase.User.prototype.linkWithCredential instead."),this.fb(t)},t.fb=function(e){var n=this,r=null;return ih(this,$c(this,e.providerId).then(function(){return n.G()}).then(function(t){return e.b(n.a,t)}).then(function(t){return r=Zc(n,t,"link"),th(n,t)}).then(function(){return r}))},t.sc=function(t,e){var n=this;return ih(this,$c(this,"phone").then(function(){return _c(Lc(n),t,e,_(n.fb,n))}))},t.Bc=function(t,e){var n=this;return ih(this,Yt().then(function(){return _c(Lc(n),t,e,_(n.hb,n))}),!0)},t.rb=function(e){var n=this;return ih(this,this.G().then(function(t){return n.a.rb(t,e)}).then(function(t){return Jc(n,t),n.reload()}))},t.Sc=function(e){var n=this;return ih(this,this.G().then(function(t){return e.b(n.a,t)}).then(function(t){return Jc(n,t),n.reload()}))},t.sb=function(e){var n=this;return ih(this,this.G().then(function(t){return n.a.sb(t,e)}).then(function(t){return Jc(n,t),n.reload()}))},t.tb=function(e){if(void 0===e.displayName&&void 0===e.photoURL)return Kc(this);var n=this;return ih(this,this.G().then(function(t){return n.a.tb(t,{displayName:e.displayName,photoUrl:e.photoURL})}).then(function(t){return Jc(n,t),Gc(n,"displayName",t.displayName||null),Gc(n,"photoURL",t.photoUrl||null),L(n.providerData,function(t){"password"===t.providerId&&(Lr(t,"displayName",n.displayName),Lr(t,"photoURL",n.photoURL))}),qc(n)}).then(Wc))},t.Qc=function(e){var n=this;return ih(this,Xc(this).then(function(t){return V(Qc(n),e)?function(t,e,n){return Ns(t,os,{idToken:e,deleteProvider:n})}(n.a,t,[e]).then(function(t){var e={};return L(t.providerUserInfo||[],function(t){e[t.providerId]=!0}),L(Qc(n),function(t){e[t]||zc(n,t)}),e[mo.PROVIDER_ID]||Lr(n,"phoneNumber",null),qc(n)}):qc(n).then(function(){throw new Yr("no-such-provider")})}))},t.delete=function(){var e=this;return ih(this,this.G().then(function(t){return Ns(e.a,is,{idToken:t})}).then(function(){e.dispatchEvent(new Rc("userDeleted"))})).then(function(){for(var t=0;t<e.I.length;t++)e.I[t].cancel("app-deleted");Pc(e,null),Mc(e,null),e.I=[],e.B=!0,Uc(e),Lr(e,"refreshToken",null),e.i&&ic(e.i,e)})},t.xb=function(t,e){return!!("linkViaPopup"==t&&(this.g||null)==e&&this.f||"reauthViaPopup"==t&&(this.g||null)==e&&this.f||"linkViaRedirect"==t&&(this.ca||null)==e||"reauthViaRedirect"==t&&(this.ca||null)==e)},t.ja=function(t,e,n,r){"linkViaPopup"!=t&&"reauthViaPopup"!=t||r!=(this.g||null)||(n&&this.v?this.v(n):e&&!n&&this.f&&this.f(e),this.c&&(this.c.cancel(),this.c=null),delete this.f,delete this.v)},t.Ba=function(t,e){return"linkViaPopup"==t&&e==(this.g||null)?_(this.Bb,this):"reauthViaPopup"==t&&e==(this.g||null)?_(this.Cb,this):"linkViaRedirect"==t&&(this.ca||null)==e?_(this.Bb,this):"reauthViaRedirect"==t&&(this.ca||null)==e?_(this.Cb,this):null},t.tc=function(t){var e=this;return eh(this,"linkViaPopup",t,function(){return $c(e,t.providerId).then(function(){return qc(e)})},!1)},t.Cc=function(t){return eh(this,"reauthViaPopup",t,function(){return Yt()},!0)},t.uc=function(t){var e=this;return nh(this,"linkViaRedirect",t,function(){return $c(e,t.providerId)},!1)},t.Dc=function(t){return nh(this,"reauthViaRedirect",t,function(){return Yt()},!0)},t.Bb=function(e,n,t,r){var i=this;this.c&&(this.c.cancel(),this.c=null);var o=null;return t=this.G().then(function(t){return Ja(i.a,{requestUri:e,postBody:r,sessionId:n,idToken:t})}).then(function(t){return o=Zc(i,t,"link"),th(i,t)}).then(function(){return o}),ih(this,t)},t.Cb=function(t,e,n,r){var i=this;this.c&&(this.c.cancel(),this.c=null);var o=null;return ih(this,Yt().then(function(){return Wi($a(i.a,{requestUri:t,sessionId:e,postBody:r,tenantId:n}),i.uid)}).then(function(t){return o=Zc(i,t,"reauthenticate"),Jc(i,t),i.h=null,i.reload()}).then(function(){return o}),!0)},t.jb=function(e){var n=this,r=null;return ih(this,this.G().then(function(t){return r=t,void 0===e||Q(e)?{}:vi(new ui(e))}).then(function(t){return n.a.jb(r,t)}).then(function(t){if(n.email!=t)return n.reload()}).then(function(){}))},t.toJSON=function(){return this.A()},t.A=function(){var e={uid:this.uid,displayName:this.displayName,photoURL:this.photoURL,email:this.email,emailVerified:this.emailVerified,phoneNumber:this.phoneNumber,isAnonymous:this.isAnonymous,tenantId:this.tenantId,providerData:[],apiKey:this.l,appName:this.m,authDomain:this.o,stsTokenManager:this.b.A(),redirectEventId:this.ca||null};return this.metadata&&G(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 gh(t){if(this.l=!1,Lr(this,"settings",new bc),Lr(this,"app",t),!Ih(this).options||!Ih(this).options.apiKey)throw new Yr("invalid-api-key");t=fl.SDK_VERSION?dr(fl.SDK_VERSION):null,this.b=new ka(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=Dh(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 Dh(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 Dh(n,e)}(this)),this.i=Dh(this,function(e){return e.Y.then(function(){return _h(e)}).s(function(){}).then(function(){if(!e.l)return e.ma()}).s(function(){}).then(function(){if(!e.l){e.ga=!0;var t=e.h;t.b.addListener(fh("local"),t.a,e.ma)}})}(this)),this.ga=!1,this.ma=_(this.Nc,this),this.ub=_(this.aa,this),this.wa=_(this.bc,this),this.xa=_(this.mc,this),this.Ja=_(this.nc,this),this.a=null,function(e){var n=Ih(e).options.authDomain,r=Ih(e).options.apiKey;n&&vr()&&(e.Tb=e.Y.then(function(){if(!e.l){if(e.a=fc(n,r,Ih(e).name),rc(e.a,e),Ch(e)&&Bc(Ch(e)),e.B){Bc(e.B);var t=e.B;t.ua(e.ha()),Pc(t,e),xc(t=e.B,e.I),Mc(t,e),e.B=null}return e.a}}))}(this),this.INTERNAL={},this.INTERNAL.delete=_(this.delete,this),this.INTERNAL.logFramework=_(this.vc,this),this.o=0,nn.call(this),function(t){Object.defineProperty(t,"lc",{get:function(){return this.ha()},set:function(t){this.ua(t)},enumerable:!1}),t.Z=null,Object.defineProperty(t,"ti",{get:function(){return this.R()},set:function(t){this.nb(t)},enumerable:!1}),t.P=null}(this),this.I=[]}function vh(t){Oe.call(this,"languageCodeChanged"),this.g=t}function bh(t){Oe.call(this,"frameworkChanged"),this.c=t}function wh(t){return t.Tb||Xt(new Yr("auth-domain-config-required"))}function _h(t){if(!vr())return Xt(new Yr("operation-not-supported-in-this-environment"));var e=wh(t).then(function(){return t.a.oa()}).then(function(t){return t?Ur(t):null});return Dh(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&&xc(i,r),i.reload().then(function(){return i})}(n,t,e.w,e.Ca())}).then(function(t){return Ch(e)&&t.uid==Ch(e).uid?Yc(Ch(e),t):(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),ze(Ch(t),"tokenChanged",t.wa),ze(Ch(t),"userDeleted",t.xa),ze(Ch(t),"userInvalidated",t.Ja),Uc(Ch(t))),e&&(e.O.push(t.ub),Ke(e,"tokenChanged",t.wa),Ke(e,"userDeleted",t.xa),Ke(e,"userInvalidated",t.Ja),0<t.o&&Fc(e)),Lr(t,"currentUser",e),e&&(e.ua(t.ha()),Pc(e,t),xc(e,t.I),Mc(e,t))}function Sh(e,t){var n=null,r=null;return Dh(e,t.then(function(t){return n=vo(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 Dh(t,e){return t.O.push(e),e.ka(function(){q(t.O,e)}),e}function kh(){}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(!gr()&&"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(gh,nn),S(vh,Oe),S(bh,Oe),(t=gh.prototype).mb=function(t){return t=this.h.mb(t),Dh(this,t)},t.ua=function(t){this.Z===t||this.l||(this.Z=t,Fa(this.b,this.Z),this.dispatchEvent(new vh(this.ha())))},t.ha=function(){return this.Z},t.Tc=function(){var t=l.navigator;this.ua(t&&(t.languages&&t.languages[0]||t.language||t.userLanguage)||null)},t.vc=function(t){this.I.push(t),Ua(this.b,fl.SDK_VERSION?dr(fl.SDK_VERSION,this.I):null),this.dispatchEvent(new bh(this.I))},t.Ca=function(){return W(this.I)},t.nb=function(t){this.P===t||this.l||(this.P=t,this.b.b=this.P)},t.R=function(){return this.P},t.toJSON=function(){return{apiKey:Ih(this).options.apiKey,authDomain:Ih(this).options.authDomain,appName:Ih(this).name,currentUser:Ch(this)&&Ch(this).A()}},t.xb=function(t,e){switch(t){case"unknown":case"signInViaRedirect":return!0;case"signInViaPopup":return this.g==e&&!!this.f;default:return!1}},t.ja=function(t,e,n,r){"signInViaPopup"==t&&this.g==r&&(n&&this.v?this.v(n):e&&!n&&this.f&&this.f(e),this.c&&(this.c.cancel(),this.c=null),delete this.f,delete this.v)},t.Ba=function(t,e){return"signInViaRedirect"==t||"signInViaPopup"==t&&this.g==e&&this.f?_(this.ac,this):null},t.ac=function(t,e,n,r){var i=this;t={requestUri:t,postBody:r,sessionId:e,tenantId:n},this.c&&(this.c.cancel(),this.c=null);var o=null,a=null,s=Xa(i.b,t).then(function(t){return o=vo(t),a=Oi(t),t});return Dh(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(!vr())return Xt(new Yr("operation-not-supported-in-this-environment"));var n=this,t=Ri(e.providerId),r=Ir(),i=null;(!_r()||ar())&&Ih(this).options.authDomain&&e.isOAuthProvider&&(i=js(Ih(this).options.authDomain,Ih(this).options.apiKey,Ih(this).name,"signInViaPopup",e,null,r,fl.SDK_VERSION||null,null,null,this.R()));var o=er(i,t&&t.sa,t&&t.ra);return Dh(this,t=wh(this).then(function(t){return sc(t,o,"signInViaPopup",e,r,!!i,n.R())}).then(function(){return new jt(function(t,e){n.ja("signInViaPopup",null,new Yr("cancelled-popup-request"),n.g),n.f=t,n.v=e,n.g=r,n.c=hc(n.a,n,"signInViaPopup",o,r)})}).then(function(t){return o&&tr(o),t?Ur(t):null}).s(function(t){throw o&&tr(o),t}))},t.Mc=function(t){if(!vr())return Xt(new Yr("operation-not-supported-in-this-environment"));var e=this;return Dh(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&&xc(e,r),Yc(e,t),e}(t,n,e.w,e.Ca());return Dh(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 Dh(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),Dh(t,t.i.then(function(){!t.l&&V(t.J,e)&&t.W!==t.getUid()&&(t.W=t.getUid(),e(Nh(t)))}))}(this,function(){t.next(Ch(e))})},t.xc=function(t,e,n){var r=this;return this.ga&&Promise.resolve().then(function(){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 Dh(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 Gc(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.Sa=function(t){var e=this;return this.i.then(function(){return Sh(e,t.na(e.b))})},t.Gc=function(t){return xr("firebase.auth.Auth.prototype.signInAndRetrieveDataWithCredential is deprecated. Please use firebase.auth.Auth.prototype.signInWithCredential instead."),this.Sa(t)},t.ob=function(){var n=this;return this.i.then(function(){var t=Ch(n);return t&&t.isAnonymous?Ur({user:t,credential:null,additionalUserInfo:Ur({providerId:null,isNewUser:!1}),operationType:"signIn"}):Sh(n,n.b.ob()).then(function(t){var e=t.user;return Gc(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),Dh(this,this.i.then(function(){e.l||V(e.m,t)&&t(Nh(e))}))},t.removeAuthTokenListener=function(e){B(this.m,function(t){return t==e})},t.delete=function(){this.l=!0;for(var t=0;t<this.O.length;t++)this.O[t].cancel("app-deleted");return this.O=[],this.h&&(t=this.h).b.removeListener(fh("local"),t.a,this.ma),this.a&&(ic(this.a,this),yc(this.a.b)),Promise.resolve()},t.$b=function(t){return Dh(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 Dh(this,Yt().then(function(){var t=new ui(n);if(!t.c)throw new Yr("argument-error",li+" must be true when sending sign in link to email");return vi(t)}).then(function(t){return r.b.lb(e,t)}).then(function(){}))},t.Uc=function(t){return this.Ma(t).then(function(t){return t.data.email})},t.ab=function(t,e){return Dh(this,this.b.ab(t,e).then(function(){}))},t.Ma=function(t){return Dh(this,this.b.Ma(t).then(function(t){return new qr(t)}))},t.Ya=function(t){return Dh(this,this.b.Ya(t).then(function(){}))},t.kb=function(e,t){var n=this;return Dh(this,Yt().then(function(){return void 0===t||Q(t)?{}:vi(new ui(t))}).then(function(t){return n.b.kb(e,t)}).then(function(){}))},t.Kc=function(t,e){return Dh(this,_c(this,t,e,_(this.Sa,this)))},t.Jc=function(n,r){var i=this;return Dh(this,Yt().then(function(){var t=r||Jn(),e=ho(n,t);if(!(t=lo(t)))throw new Yr("argument-error","Invalid email link!");if(t.tenantId!==i.R())throw new Yr("tenant-id-mismatch");return i.Sa(e)}))},kh.prototype.render=function(){},kh.prototype.reset=function(){},kh.prototype.getResponse=function(){},kh.prototype.execute=function(){};var Oh=null;function Ph(t,e){return(e=xh(e))&&t.a[e]||null}function xh(t){return(t=void 0===t?1e12:t)?t.toString():null}function Mh(t,e){this.g=!1,this.c=e,this.a=this.b=null,this.h="invisible"!==this.c.size,this.f=qn(t);var n=this;this.i=function(){n.execute()},this.h?this.execute():Ke(this.f,"click",this.i)}function Lh(t){if(t.g)throw Error("reCAPTCHA mock was already deleted!")}function Fh(){}Rh.prototype.render=function(t,e){return this.a[this.b.toString()]=new Mh(t,e),this.b++},Rh.prototype.reset=function(t){var e=Ph(this,t);t=xh(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()},Mh.prototype.getResponse=function(){return Lh(this),this.b},Mh.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))},Mh.prototype.delete=function(){Lh(this),this.g=!0,clearTimeout(this.a),this.a=null,ze(this.f,"click",this.i)},Fh.prototype.g=function(){return Yt(Oh=Oh||new Rh)},Fh.prototype.c=function(){};var Uh=null;function Vh(){this.b=l.grecaptcha?1/0:0,this.f=null,this.a="__rcb"+Math.floor(1e6*Math.random()).toString()}var qh=new Y($,"https://www.google.com/recaptcha/api.js?onload=%{onload}&render=explicit&hl=%{hl}"),Bh=new Ar(3e4,6e4);Vh.prototype.g=function(i){var o=this;return new jt(function(t,e){var r=setTimeout(function(){e(new Yr("network-request-failed"))},Bh.get());!l.grecaptcha||i!==o.f&&!o.b?(l[o.a]=function(){if(l.grecaptcha){o.f=i;var n=l.grecaptcha.render;l.grecaptcha.render=function(t,e){return t=n(t,e),o.b++,t},clearTimeout(r),t(l.grecaptcha)}else clearTimeout(r),e(new Yr("internal-error"));delete l[o.a]},Yt(Ta(nt(qh,{onload:o.a,hl:i||""}))).s(function(){clearTimeout(r),e(new Yr("internal-error","Unable to load external reCAPTCHA dependencies!"))})):(clearTimeout(r),t(l.grecaptcha))})},Vh.prototype.c=function(){this.b--};var jh=null;function Wh(t,e,n,r,i,o,a){if(Lr(this,"type","recaptcha"),this.c=this.f=null,this.B=!1,this.u=e,this.g=null,a=a?Uh=Uh||new Fh:jh=jh||new Vh,this.m=a,this.a=n||{theme:"light",type:"image"},this.h=[],this.a[Hh])throw new Yr("argument-error","sitekey should not be provided for reCAPTCHA as one is automatically provisioned for the current project.");if(this.i="invisible"===this.a[zh],!l.document)throw new Yr("operation-not-supported-in-this-environment","RecaptchaVerifier is only supported in a browser HTTP/HTTPS environment with DOM support.");if(!qn(e)||!this.i&&qn(e).hasChildNodes())throw new Yr("argument-error","reCAPTCHA container is either not found or already contains inner elements!");this.o=new ka(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(Gh(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(Gh(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",zh="size";function Gh(t,e){for(var n=0;n<t.l.length;n++)try{t.l[n](e)}catch(t){}}function Yh(t,e){return t.h.push(e),e.ka(function(){q(t.h,e)}),e}function Xh(t){if(t.B)throw new Yr("internal-error","RecaptchaVerifier instance has been destroyed.")}function Jh(t,e,n){var r=!1;try{this.b=n||fl.app()}catch(t){throw new Yr("argument-error","No firebase.app.App instance is currently initialized.")}if(!this.b.options||!this.b.options.apiKey)throw new Yr("invalid-api-key");n=this.b.options.apiKey;var i=this,o=null;try{o=this.b.auth().Ca()}catch(t){}try{r=this.b.auth().settings.appVerificationDisabledForTesting}catch(t){}o=fl.SDK_VERSION?dr(fl.SDK_VERSION,o):null,Wh.call(this,n,t,e,function(){try{var e=i.b.auth().ha()}catch(t){e=null}return e},o,Ni(Ii),r)}function $h(t,e,n,r){t:{n=Array.prototype.slice.call(n);for(var i=0,o=!1,a=0;a<e.length;a++)if(e[a].optional)o=!0;else{if(o)throw new Yr("internal-error","Argument validator encountered a required argument after an optional argument.");i++}if(o=e.length,n.length<i||o<n.length)r="Expected "+(i==o?1==i?"1 argument":i+" arguments":i+"-"+o+" arguments")+" but got "+n.length+".";else{for(i=0;i<n.length;i++)if(o=e[i].optional&&void 0===n[i],!e[i].N(n[i])&&!o){if(e=e[i],i<0||i>=Zh.length)throw new Yr("internal-error","Argument validator received an unsupported number of arguments.");n=Zh[i],r=(r?"":n+" argument ")+(e.name?'"'+e.name+'" ':"")+"must be "+e.M+".";break t}r=null}}if(r)throw new Yr("argument-error",t+" failed: "+r)}(t=Wh.prototype).Da=function(){var e=this;return this.f?this.f:this.f=Yh(this,Yt().then(function(){if(br()&&!sr())return ir();throw new Yr("operation-not-supported-in-this-environment","RecaptchaVerifier is only supported in a browser HTTP/HTTPS environment.")}).then(function(){return e.m.g(e.v())}).then(function(t){return e.g=t,Ns(e.o,ps,{})}).then(function(t){e.a[Hh]=t.recaptchaSiteKey}).s(function(t){throw e.f=null,t}))},t.render=function(){Xh(this);var n=this;return Yh(this,this.Da().then(function(){if(null===n.c){var t=n.u;if(!n.i){var e=qn(t);t=Wn("DIV"),e.appendChild(t)}n.c=n.g.render(t,n.a)}return n.c}))},t.verify=function(){Xh(this);var i=this;return Yh(this,this.render().then(function(r){return new jt(function(e){var t=i.g.getResponse(r);if(t)e(t);else{var n=function(t){t&&(function(t,e){B(t.l,function(t){return t==e})}(i,n),e(t))};i.l.push(n),i.i&&i.g.execute(i.c)}})}))},t.reset=function(){Xh(this),null!==this.c&&this.g.reset(this.c)},t.clear=function(){Xh(this),this.B=!0,this.m.c();for(var t=0;t<this.h.length;t++)this.h[t].cancel("RecaptchaVerifier instance has been destroyed.");if(!this.i){t=qn(this.u);for(var e;e=t.firstChild;)t.removeChild(e)}},S(Jh,Wh);var Zh="First Second Third Fourth Fifth Sixth Seventh Eighth Ninth".split(" ");function tl(t,e){return{name:t||"",M:"a valid string",optional:!!e,N:h}}function el(t,e){return{name:t||"",M:"a boolean",optional:!!e,N:n}}function nl(t,e){return{name:t||"",M:"a valid object",optional:!!e,N:g}}function rl(t,e){return{name:t||"",M:"a function",optional:!!e,N: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].Za),enumerable:!0})}}function hl(t,e,n,r){t[e]=ll(e,n,r)}function ll(t,e,n){function r(){var t=Array.prototype.slice.call(arguments);return $h(o,n,t),e.apply(this,t)}if(!n)return e;var i,o=function(t){return(t=t.split("."))[t.length-1]}(t);for(i in e)r[i]=e[i];for(i in e.prototype)r.prototype[i]=e.prototype[i];return r}ul(gh.prototype,{Ya:{name:"applyActionCode",j:[tl("code")]},Ma:{name:"checkActionCode",j:[tl("code")]},ab:{name:"confirmPasswordReset",j:[tl("code"),tl("newPassword")]},Xb:{name:"createUserWithEmailAndPassword",j:[tl("email"),tl("password")]},$b:{name:"fetchSignInMethodsForEmail",j:[tl("email")]},oa:{name:"getRedirectResult",j:[]},qc:{name:"isSignInWithEmailLink",j:[tl("emailLink")]},wc:{name:"onAuthStateChanged",j:[sl(nl(),rl(),"nextOrObserver"),rl("opt_error",!0),rl("opt_completed",!0)]},xc:{name:"onIdTokenChanged",j:[sl(nl(),rl(),"nextOrObserver"),rl("opt_error",!0),rl("opt_completed",!0)]},kb:{name:"sendPasswordResetEmail",j:[tl("email"),sl(nl("opt_actionCodeSettings",!0),il(null,!0),"opt_actionCodeSettings",!0)]},lb:{name:"sendSignInLinkToEmail",j:[tl("email"),nl("actionCodeSettings")]},mb:{name:"setPersistence",j:[tl("persistence")]},Gc:{name:"signInAndRetrieveDataWithCredential",j:[ol()]},ob:{name:"signInAnonymously",j:[]},Sa:{name:"signInWithCredential",j:[ol()]},Hc:{name:"signInWithCustomToken",j:[tl("token")]},Ic:{name:"signInWithEmailAndPassword",j:[tl("email"),tl("password")]},Jc:{name:"signInWithEmailLink",j:[tl("email"),tl("emailLink",!0)]},Kc:{name:"signInWithPhoneNumber",j:[tl("phoneNumber"),al()]},Lc:{name:"signInWithPopup",j:[{name:"authProvider",M:"a valid Auth provider",optional:!1,N:function(t){return!!(t&&t.providerId&&t.hasOwnProperty&&t.hasOwnProperty("isOAuthProvider"))}}]},Mc:{name:"signInWithRedirect",j:[{name:"authProvider",M:"a valid Auth provider",optional:!1,N:function(t){return!!(t&&t.providerId&&t.hasOwnProperty&&t.hasOwnProperty("isOAuthProvider"))}}]},Rc:{name:"updateCurrentUser",j:[sl({name:"user",M:"an instance of Firebase User",optional:!1,N:function(t){return!!(t&&t instanceof Oc)}},il(),"user")]},pb:{name:"signOut",j:[]},toJSON:{name:"toJSON",j:[tl(null,!0)]},Tc:{name:"useDeviceLanguage",j:[]},Uc:{name:"verifyPasswordResetCode",j:[tl("code")]}}),cl(gh.prototype,{lc:{name:"languageCode",Za:sl(tl(),il(),"languageCode")},ti:{name:"tenantId",Za:sl(tl(),il(),"tenantId")}}),(gh.Persistence=Eu).LOCAL="local",gh.Persistence.SESSION="session",gh.Persistence.NONE="none",ul(Oc.prototype,{delete:{name:"delete",j:[]},dc:{name:"getIdTokenResult",j:[el("opt_forceRefresh",!0)]},G:{name:"getIdToken",j:[el("opt_forceRefresh",!0)]},rc:{name:"linkAndRetrieveDataWithCredential",j:[ol()]},fb:{name:"linkWithCredential",j:[ol()]},sc:{name:"linkWithPhoneNumber",j:[tl("phoneNumber"),al()]},tc:{name:"linkWithPopup",j:[{name:"authProvider",M:"a valid Auth provider",optional:!1,N:function(t){return!!(t&&t.providerId&&t.hasOwnProperty&&t.hasOwnProperty("isOAuthProvider"))}}]},uc:{name:"linkWithRedirect",j:[{name:"authProvider",M:"a valid Auth provider",optional:!1,N:function(t){return!!(t&&t.providerId&&t.hasOwnProperty&&t.hasOwnProperty("isOAuthProvider"))}}]},Ac:{name:"reauthenticateAndRetrieveDataWithCredential",j:[ol()]},hb:{name:"reauthenticateWithCredential",j:[ol()]},Bc:{name:"reauthenticateWithPhoneNumber",j:[tl("phoneNumber"),al()]},Cc:{name:"reauthenticateWithPopup",j:[{name:"authProvider",M:"a valid Auth provider",optional:!1,N:function(t){return!!(t&&t.providerId&&t.hasOwnProperty&&t.hasOwnProperty("isOAuthProvider"))}}]},Dc:{name:"reauthenticateWithRedirect",j:[{name:"authProvider",M:"a valid Auth provider",optional:!1,N:function(t){return!!(t&&t.providerId&&t.hasOwnProperty&&t.hasOwnProperty("isOAuthProvider"))}}]},reload:{name:"reload",j:[]},jb:{name:"sendEmailVerification",j:[sl(nl("opt_actionCodeSettings",!0),il(null,!0),"opt_actionCodeSettings",!0)]},toJSON:{name:"toJSON",j:[tl(null,!0)]},Qc:{name:"unlink",j:[tl("provider")]},rb:{name:"updateEmail",j:[tl("email")]},sb:{name:"updatePassword",j:[tl("password")]},Sc:{name:"updatePhoneNumber",j:[ol("phone")]},tb:{name:"updateProfile",j:[nl("profile")]}}),ul(Rh.prototype,{execute:{name:"execute"},render:{name:"render"},reset:{name:"reset"},getResponse:{name:"getResponse"}}),ul(kh.prototype,{execute:{name:"execute"},render:{name:"render"},reset:{name:"reset"},getResponse:{name:"getResponse"}}),ul(jt.prototype,{ka:{name:"finally"},s:{name:"catch"},then:{name:"then"}}),cl(bc.prototype,{appVerificationDisabled:{name:"appVerificationDisabledForTesting",Za:el("appVerificationDisabledForTesting")}}),ul(wc.prototype,{confirm:{name:"confirm",j:[tl("verificationCode")]}}),hl(ji,"fromJSON",function(t){t=h(t)?JSON.parse(t):t;for(var e,n=[Yi,uo,po,Hi],r=0;r<n.length;r++)if(e=n[r](t))return e;return null},[sl(tl(),nl(),"json")]),hl(co,"credential",function(t,e){return new so(t,e)},[tl("email"),tl("password")]),ul(so.prototype,{A:{name:"toJSON",j:[tl(null,!0)]}}),ul(Zi.prototype,{ya:{name:"addScope",j:[tl("scope")]},Ga:{name:"setCustomParameters",j:[nl("customOAuthParameters")]}}),hl(Zi,"credential",to,[sl(tl(),nl(),"token")]),hl(co,"credentialWithLink",ho,[tl("email"),tl("emailLink")]),ul(eo.prototype,{ya:{name:"addScope",j:[tl("scope")]},Ga:{name:"setCustomParameters",j:[nl("customOAuthParameters")]}}),hl(eo,"credential",no,[sl(tl(),nl(),"token")]),ul(ro.prototype,{ya:{name:"addScope",j:[tl("scope")]},Ga:{name:"setCustomParameters",j:[nl("customOAuthParameters")]}}),hl(ro,"credential",io,[sl(tl(),sl(nl(),il()),"idToken"),sl(tl(),il(),"accessToken",!0)]),ul(oo.prototype,{Ga:{name:"setCustomParameters",j:[nl("customOAuthParameters")]}}),hl(oo,"credential",ao,[sl(tl(),nl(),"token"),tl("secret",!0)]),ul($i.prototype,{ya:{name:"addScope",j:[tl("scope")]},credential:{name:"credential",j:[sl(tl(),sl(nl(),il()),"optionsOrIdToken"),sl(tl(),il(),"accessToken",!0)]},Ga:{name:"setCustomParameters",j:[nl("customOAuthParameters")]}}),ul(zi.prototype,{A:{name:"toJSON",j:[tl(null,!0)]}}),ul(Ki.prototype,{A:{name:"toJSON",j:[tl(null,!0)]}}),hl(mo,"credential",go,[tl("verificationId"),tl("verificationCode")]),ul(mo.prototype,{Wa:{name:"verifyPhoneNumber",j:[tl("phoneNumber"),al()]}}),ul(fo.prototype,{A:{name:"toJSON",j:[tl(null,!0)]}}),ul(Yr.prototype,{toJSON:{name:"toJSON",j:[tl(null,!0)]}}),ul(Co.prototype,{toJSON:{name:"toJSON",j:[tl(null,!0)]}}),ul(Io.prototype,{toJSON:{name:"toJSON",j:[tl(null,!0)]}}),ul(Jh.prototype,{clear:{name:"clear",j:[]},render:{name:"render",j:[]},verify:{name:"verify",j:[]}}),hl(Zr,"parseLink",si,[tl("link")]),function(){if(void 0===fl||!fl.INTERNAL||!fl.INTERNAL.registerComponent)throw Error("Cannot find the firebase namespace; be sure to include firebase-app.js before this library.");var t={ActionCodeInfo:{Operation:{EMAIL_SIGNIN:Br,PASSWORD_RESET:"PASSWORD_RESET",RECOVER_EMAIL:"RECOVER_EMAIL",VERIFY_EMAIL:"VERIFY_EMAIL"}},Auth:gh,AuthCredential:ji,Error:Yr};hl(t,"EmailAuthProvider",co,[]),hl(t,"FacebookAuthProvider",Zi,[]),hl(t,"GithubAuthProvider",eo,[]),hl(t,"GoogleAuthProvider",ro,[]),hl(t,"TwitterAuthProvider",oo,[]),hl(t,"OAuthProvider",$i,[tl("providerId")]),hl(t,"SAMLAuthProvider",Ji,[tl("providerId")]),hl(t,"PhoneAuthProvider",mo,[{name:"auth",M:"an instance of Firebase Auth",optional:!0,N:function(t){return!!(t&&t instanceof gh)}}]),hl(t,"RecaptchaVerifier",Jh,[sl(tl(),{name:"",M:"an HTML element",optional:!1,N:function(t){return!!(t&&t instanceof Element)}},"recaptchaContainer"),nl("recaptchaParameters",!0),{name:"app",M:"an instance of Firebase App",optional:!0,N:function(t){return!!(t&&t instanceof fl.app.App)}}]),hl(t,"ActionCodeURL",Zr,[]),fl.INTERNAL.registerComponent({name:"auth",instanceFactory:function(t){return new gh(t=t.getProvider("app").getImmediate())},multipleInstances:!1,serviceProps:t,instantiationMode:"LAZY",type:"PUBLIC"}),fl.INTERNAL.registerComponent({name:"auth-internal",instanceFactory:function(t){return{getUid:_((t=t.getProvider("auth").getImmediate()).getUid,t),getToken:_(t.cc,t),addAuthTokenListener:_(t.Wb,t),removeAuthTokenListener:_(t.Ec,t)}},multipleInstances:!1,instantiationMode:"LAZY",type:"PRIVATE"}),fl.registerVersion("@firebase/auth","0.13.4"),fl.INTERNAL.extendNamespace({User:Oc})}()}).apply("undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{});var Hs=(zs.prototype.set=function(t,e){null==e?this.domStorage_.removeItem(this.prefixedName_(t)):this.domStorage_.setItem(this.prefixedName_(t),Xa(e))},zs.prototype.get=function(t){var e=this.domStorage_.getItem(this.prefixedName_(t));return null==e?null:Ya(e)},zs.prototype.remove=function(t){this.domStorage_.removeItem(this.prefixedName_(t))},zs.prototype.prefixedName_=function(t){return this.prefix_+t},zs.prototype.toString=function(){return this.domStorage_.toString()},zs);function zs(t){this.domStorage_=t,this.prefix_="firebase:"}var Gs=(Ys.prototype.set=function(t,e){null==e?delete this.cache_[t]:this.cache_[t]=e},Ys.prototype.get=function(t){return $a(this.cache_,t)?this.cache_[t]:null},Ys.prototype.remove=function(t){delete this.cache_[t]},Ys);function Ys(){this.cache_={},this.isInMemoryStorage=!0}function Xs(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 Gs}function Js(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;Oa(++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 ns;n.update(e);var r=n.digest();return xa.encodeByteArray(r)}function $s(t,e){Oa(!e||!0===t||!1===t,"Can't turn on custom loggers persistently."),!0===t?(lu.logLevel=vs.VERBOSE,du=lu.log.bind(lu),e&&hu.set("logging_enabled",!0)):"function"==typeof t?du=t:(du=null,hu.remove("logging_enabled"))}function Zs(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(!0===yu&&(yu=!1,null===du&&!0===hu.get("logging_enabled")&&$s(!0)),du){var n=pu.apply(null,t);du(n)}}function tu(n){return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];Zs.apply(void 0,Na([n],t))}}function eu(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="FIREBASE INTERNAL ERROR: "+pu.apply(void 0,Na(t));lu.error(n)}function nu(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="FIREBASE FATAL ERROR: "+pu.apply(void 0,Na(t));throw lu.error(n),new Error(n)}function ru(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="FIREBASE WARNING: "+pu.apply(void 0,Na(t));lu.warn(n)}function iu(t){return"number"==typeof t&&(t!=t||t===Number.POSITIVE_INFINITY||t===Number.NEGATIVE_INFINITY)}function ou(t,e){return t===e?0:t<e?-1:1}function au(t,e){if(e&&t in e)return e[t];throw new Error("Missing required key ("+t+") in object: "+Xa(e))}function su(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 uu,cu=Xs("localStorage"),hu=Xs("sessionStorage"),lu=new Cs("@firebase/database"),fu=(uu=1,function(){return uu++}),pu=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n="",r=0;r<t.length;r++){var i=t[r];Array.isArray(i)||i&&"object"==typeof i&&"number"==typeof i.length?n+=pu.apply(null,i):n+="object"==typeof i?Xa(i):i,n+=" "}return n},du=null,yu=!0,mu="[MIN_NAME]",gu="[MAX_NAME]",vu=function(t,e){if(t===e)return 0;if(t===mu||e===gu)return-1;if(e===mu||t===gu)return 1;var n=Iu(t),r=Iu(e);return null!==n?null!==r?n-r==0?t.length-e.length:n-r:-1:null!==r?1:t<e?-1:1},bu=function(t){if("object"!=typeof t||null===t)return Xa(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+=Xa(e[i]),r+=":",r+=bu(t[e[i]]);return r+="}"};function wu(t,e){for(var n in t)t.hasOwnProperty(n)&&e(n,t[n])}function _u(t){var e,n,r,i,o;Oa(!iu(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))));var a=[];for(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();var s=a.join(""),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 Eu(t){try{t()}catch(e){setTimeout(function(){var t=e.stack||"";throw ru("Exception was thrown by user callback.",t),e},Math.floor(0))}}function Tu(t,e){var n=setTimeout(t,e);return"object"==typeof n&&n.unref&&n.unref(),n}var Su=new RegExp("^-?(0*)\\d{1,10}$"),Iu=function(t){if(Su.test(t)){var e=Number(t);if(-2147483648<=e&&e<=2147483647)return e}return null},Cu=(Object.defineProperty(Nu,"Empty",{get:function(){return new Nu("")},enumerable:!0,configurable:!0}),Nu.prototype.getFront=function(){return this.pieceNum_>=this.pieces_.length?null:this.pieces_[this.pieceNum_]},Nu.prototype.getLength=function(){return this.pieces_.length-this.pieceNum_},Nu.prototype.popFront=function(){var t=this.pieceNum_;return t<this.pieces_.length&&t++,new Nu(this.pieces_,t)},Nu.prototype.getBack=function(){return this.pieceNum_<this.pieces_.length?this.pieces_[this.pieces_.length-1]:null},Nu.prototype.toString=function(){for(var t="",e=this.pieceNum_;e<this.pieces_.length;e++)""!==this.pieces_[e]&&(t+="/"+this.pieces_[e]);return t||"/"},Nu.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||"/"},Nu.prototype.slice=function(t){return void 0===t&&(t=0),this.pieces_.slice(this.pieceNum_+t)},Nu.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 Nu(t,0)},Nu.prototype.child=function(t){for(var e=[],n=this.pieceNum_;n<this.pieces_.length;n++)e.push(this.pieces_[n]);if(t instanceof Nu)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 Nu(e,0)},Nu.prototype.isEmpty=function(){return this.pieceNum_>=this.pieces_.length},Nu.relativePath=function(t,e){var n=t.getFront(),r=e.getFront();if(null===n)return e;if(n===r)return Nu.relativePath(t.popFront(),e.popFront());throw new Error("INTERNAL ERROR: innerPath ("+e+") is not within outerPath ("+t+")")},Nu.comparePaths=function(t,e){for(var n=t.slice(),r=e.slice(),i=0;i<n.length&&i<r.length;i++){var o=vu(n[i],r[i]);if(0!==o)return o}return n.length===r.length?0:n.length<r.length?-1:1},Nu.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},Nu.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},Nu);function Nu(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 Au=(Object.defineProperty(Du,"MAX_PATH_DEPTH",{get:function(){return 32},enumerable:!0,configurable:!0}),Object.defineProperty(Du,"MAX_PATH_LENGTH_BYTES",{get:function(){return 768},enumerable:!0,configurable:!0}),Du.prototype.push=function(t){0<this.parts_.length&&(this.byteLength_+=1),this.parts_.push(t),this.byteLength_+=fs(t),this.checkValid_()},Du.prototype.pop=function(){var t=this.parts_.pop();this.byteLength_-=fs(t),0<this.parts_.length&&(this.byteLength_-=1)},Du.prototype.checkValid_=function(){if(this.byteLength_>Du.MAX_PATH_LENGTH_BYTES)throw new Error(this.errorPrefix_+"has a key path longer than "+Du.MAX_PATH_LENGTH_BYTES+" bytes ("+this.byteLength_+").");if(this.parts_.length>Du.MAX_PATH_DEPTH)throw new Error(this.errorPrefix_+"path specified exceeds the maximum depth that can be written ("+Du.MAX_PATH_DEPTH+") or object contains a cycle "+this.toErrorString())},Du.prototype.toErrorString=function(){return 0===this.parts_.length?"":"in property '"+this.parts_.join(".")+"'"},Du);function Du(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_+=fs(this.parts_[n]);this.checkValid_()}var ku="firebaseio.com",Ru="websocket",Ou="long_polling",Pu=(xu.prototype.needsQueryParam=function(){return this.host!==this.internalHost||this.isCustomHost()||this.includeNamespaceInQueryParams},xu.prototype.isCacheableHost=function(){return"s-"===this.internalHost.substr(0,2)},xu.prototype.isDemoHost=function(){return"firebaseio-demo.com"===this.domain},xu.prototype.isCustomHost=function(){return"firebaseio.com"!==this.domain&&"firebaseio-demo.com"!==this.domain},xu.prototype.updateHost=function(t){t!==this.internalHost&&(this.internalHost=t,this.isCacheableHost()&&cu.set("host:"+this.host,this.internalHost))},xu.prototype.connectionURL=function(t,e){var n;if(Oa("string"==typeof t,"typeof type must == string"),Oa("object"==typeof e,"typeof params must == object"),t===Ru)n=(this.secure?"wss://":"ws://")+this.internalHost+"/.ws?";else{if(t!==Ou)throw new Error("Unknown connection type: "+t);n=(this.secure?"https://":"http://")+this.internalHost+"/.lp?"}this.needsQueryParam()&&(e.ns=this.namespace);var r=[];return wu(e,function(t,e){r.push(t+"="+e)}),n+r.join("&")},xu.prototype.toString=function(){var t=this.toURLString();return this.persistenceKey&&(t+="<"+this.persistenceKey+">"),t},xu.prototype.toURLString=function(){return(this.secure?"https://":"http://")+this.host},xu);function xu(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=cu.get("host:"+t)||this.host}function Mu(t){var e=zu(t),n=e.namespace;"firebase"===e.domain&&nu(e.host+" is no longer supported. Please use <YOUR FIREBASE>.firebaseio.com instead"),n&&"undefined"!==n||"localhost"===e.domain||nu("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:")&&ru("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 Pu(e.host,e.secure,n,r,"",n!==e.subdomain),path:new Cu(e.pathString)}}function Lu(t){return"string"==typeof t&&0!==t.length&&!Gu.test(t)}function Fu(t){return"string"==typeof t&&0!==t.length&&!Yu.test(t)}function Uu(t){return null===t||"string"==typeof t||"number"==typeof t&&!iu(t)||t&&"object"==typeof t&&$a(t,".sv")}function Vu(t,e,n,r,i){i&&void 0===n||Ju(cs(t,e,i),n,r)}function qu(t,e,n,r,i){if(!i||void 0!==n){var o=cs(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=[];wu(n,function(t,e){var n=new Cu(t);if(Ju(o,e,r.child(n)),".priority"===n.getBack()&&!Uu(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(!Lu(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(Cu.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 Bu(t,e,n,r){if(!r||void 0!==n){if(iu(n))throw new Error(cs(t,e,r)+"is "+n.toString()+", but must be a valid Firebase priority (a string, finite number, server value, or null).");if(!Uu(n))throw new Error(cs(t,e,r)+"must be a valid Firebase priority (a string, finite number, server value, or null).")}}function ju(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(cs(t,e,r)+'must be a valid event type = "value", "child_added", "child_removed", "child_changed", or "child_moved".')}}function Wu(t,e,n,r){if(!(r&&void 0===n||Lu(n)))throw new Error(cs(t,e,r)+'was an invalid key = "'+n+'". Firebase keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]").')}function Ku(t,e,n,r){if(!(r&&void 0===n||Fu(n)))throw new Error(cs(t,e,r)+'was an invalid path = "'+n+'". Paths must be non-empty strings and can\'t contain ".", "#", "$", "[", or "]"')}function Qu(t,e){if(".info"===e.getFront())throw new Error(t+" failed = Can't modify data under /.info/")}function Hu(t,e,n){var r=n.path.toString();if("string"!=typeof n.repoInfo.host||0===n.repoInfo.host.length||!Lu(n.repoInfo.namespace)&&"localhost"!==n.repoInfo.host.split(":")[0]||0!==r.length&&!function(t){return t=t&&t.replace(/^\/*\.info(\/|$)/,"/"),Fu(t)}(r))throw new Error(cs(t,e,!1)+'must be a valid firebase URL and the path can\'t contain ".", "#", "$", "[", or "]".')}var zu=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=Ia(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]):ru("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}},Gu=/[\[\].#$\/\u0000-\u001F\u007F]/,Yu=/[\[\].#$\u0000-\u001F\u007F]/,Xu=10485760,Ju=function(n,t,e){var r=e instanceof Cu?new Au(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(iu(t))throw new Error(n+"contains "+t.toString()+" "+r.toErrorString());if("string"==typeof t&&t.length>Xu/3&&fs(t)>Xu)throw new Error(n+"contains a string greater than "+Xu+" utf8 bytes "+r.toErrorString()+" ('"+t.substring(0,50)+"...')");if(t&&"object"==typeof t){var i=!1,o=!1;if(wu(t,function(t,e){if(".value"===t)i=!0;else if(".priority"!==t&&".sv"!==t&&(o=!0,!Lu(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),Ju(n,e,r),r.pop()}),i&&o)throw new Error(n+' contains ".value" child '+r.toErrorString()+" in addition to actual children.")}},$u=(Zu.prototype.cancel=function(t){us("OnDisconnect.cancel",0,1,arguments.length),hs("OnDisconnect.cancel",1,t,!0);var e=new Fa;return this.repo_.onDisconnectCancel(this.path_,e.wrapCallback(t)),e.promise},Zu.prototype.remove=function(t){us("OnDisconnect.remove",0,1,arguments.length),Qu("OnDisconnect.remove",this.path_),hs("OnDisconnect.remove",1,t,!0);var e=new Fa;return this.repo_.onDisconnectSet(this.path_,null,e.wrapCallback(t)),e.promise},Zu.prototype.set=function(t,e){us("OnDisconnect.set",1,2,arguments.length),Qu("OnDisconnect.set",this.path_),Vu("OnDisconnect.set",1,t,this.path_,!1),hs("OnDisconnect.set",2,e,!0);var n=new Fa;return this.repo_.onDisconnectSet(this.path_,t,n.wrapCallback(e)),n.promise},Zu.prototype.setWithPriority=function(t,e,n){us("OnDisconnect.setWithPriority",2,3,arguments.length),Qu("OnDisconnect.setWithPriority",this.path_),Vu("OnDisconnect.setWithPriority",1,t,this.path_,!1),Bu("OnDisconnect.setWithPriority",2,e,!1),hs("OnDisconnect.setWithPriority",3,n,!0);var r=new Fa;return this.repo_.onDisconnectSetWithPriority(this.path_,t,e,r.wrapCallback(n)),r.promise},Zu.prototype.update=function(t,e){if(us("OnDisconnect.update",1,2,arguments.length),Qu("OnDisconnect.update",this.path_),Array.isArray(t)){for(var n={},r=0;r<t.length;++r)n[""+r]=t[r];t=n,ru("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.")}qu("OnDisconnect.update",1,t,this.path_,!1),hs("OnDisconnect.update",2,e,!0);var i=new Fa;return this.repo_.onDisconnectUpdate(this.path_,t,i.wrapCallback(e)),i.promise},Zu);function Zu(t,e){this.repo_=t,this.path_=e}var tc=(ec.prototype.toJSON=function(){return us("TransactionResult.toJSON",0,1,arguments.length),{committed:this.committed,snapshot:this.snapshot.toJSON()}},ec);function ec(t,e){this.committed=t,this.snapshot=e}var nc,rc,ic,oc=(nc="-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz",rc=0,ic=[],function(t){var e,n=t===rc;rc=t;var r=new Array(8);for(e=7;0<=e;e--)r[e]=nc.charAt(t%64),t=Math.floor(t/64);Oa(0===t,"Cannot push at time == 0");var i=r.join("");if(n){for(e=11;0<=e&&63===ic[e];e--)ic[e]=0;ic[e]++}else for(e=0;e<12;e++)ic[e]=Math.floor(64*Math.random());for(e=0;e<12;e++)i+=nc.charAt(ic[e]);return Oa(20===i.length,"nextPushId: Length should be 20."),i}),ac=(sc.Wrap=function(t,e){return new sc(t,e)},sc);function sc(t,e){this.name=t,this.node=e}var uc,cc=(hc.prototype.getCompare=function(){return this.compare.bind(this)},hc.prototype.indexedValueChanged=function(t,e){var n=new ac(mu,t),r=new ac(mu,e);return 0!==this.compare(n,r)},hc.prototype.minPost=function(){return ac.MIN},hc);function hc(){}var lc,fc=(_a(pc,lc=cc),Object.defineProperty(pc,"__EMPTY_NODE",{get:function(){return uc},set:function(t){uc=t},enumerable:!0,configurable:!0}),pc.prototype.compare=function(t,e){return vu(t.name,e.name)},pc.prototype.isDefinedOn=function(t){throw Pa("KeyIndex.isDefinedOn not expected to be called.")},pc.prototype.indexedValueChanged=function(t,e){return!1},pc.prototype.minPost=function(){return ac.MIN},pc.prototype.maxPost=function(){return new ac(gu,uc)},pc.prototype.makePost=function(t,e){return Oa("string"==typeof t,"KeyIndex indexValue must always be a string."),new ac(t,uc)},pc.prototype.toString=function(){return".key"},pc);function pc(){return null!==lc&&lc.apply(this,arguments)||this}var dc,yc=new fc;function mc(t){return"number"==typeof t?"number:"+_u(t):"string:"+t}function gc(t){if(t.isLeafNode()){var e=t.val();Oa("string"==typeof e||"number"==typeof e||"object"==typeof e&&$a(e,".sv"),"Priority must be a string or number.")}else Oa(t===dc||t.isEmpty(),"priority of unexpected type.");Oa(t===dc||t.getPriority().isEmpty(),"Priority nodes can't have a priority of their own.")}var vc,bc,wc,_c,Ec=(Object.defineProperty(Tc,"__childrenNodeConstructor",{get:function(){return vc},set:function(t){vc=t},enumerable:!0,configurable:!0}),Tc.prototype.isLeafNode=function(){return!0},Tc.prototype.getPriority=function(){return this.priorityNode_},Tc.prototype.updatePriority=function(t){return new Tc(this.value_,t)},Tc.prototype.getImmediateChild=function(t){return".priority"===t?this.priorityNode_:Tc.__childrenNodeConstructor.EMPTY_NODE},Tc.prototype.getChild=function(t){return t.isEmpty()?this:".priority"===t.getFront()?this.priorityNode_:Tc.__childrenNodeConstructor.EMPTY_NODE},Tc.prototype.hasChild=function(){return!1},Tc.prototype.getPredecessorChildName=function(t,e){return null},Tc.prototype.updateImmediateChild=function(t,e){return".priority"===t?this.updatePriority(e):e.isEmpty()&&".priority"!==t?this:Tc.__childrenNodeConstructor.EMPTY_NODE.updateImmediateChild(t,e).updatePriority(this.priorityNode_)},Tc.prototype.updateChild=function(t,e){var n=t.getFront();return null===n?e:e.isEmpty()&&".priority"!==n?this:(Oa(".priority"!==n||1===t.getLength(),".priority must be the last token in a path"),this.updateImmediateChild(n,Tc.__childrenNodeConstructor.EMPTY_NODE.updateChild(t.popFront(),e)))},Tc.prototype.isEmpty=function(){return!1},Tc.prototype.numChildren=function(){return 0},Tc.prototype.forEachChild=function(t,e){return!1},Tc.prototype.val=function(t){return t&&!this.getPriority().isEmpty()?{".value":this.getValue(),".priority":this.getPriority().val()}:this.getValue()},Tc.prototype.hash=function(){if(null===this.lazyHash_){var t="";this.priorityNode_.isEmpty()||(t+="priority:"+mc(this.priorityNode_.val())+":");var e=typeof this.value_;t+=e+":",t+="number"==e?_u(this.value_):this.value_,this.lazyHash_=Js(t)}return this.lazyHash_},Tc.prototype.getValue=function(){return this.value_},Tc.prototype.compareTo=function(t){return t===Tc.__childrenNodeConstructor.EMPTY_NODE?1:t instanceof Tc.__childrenNodeConstructor?-1:(Oa(t.isLeafNode(),"Unknown node type"),this.compareToLeafNode_(t))},Tc.prototype.compareToLeafNode_=function(t){var e=typeof t.value_,n=typeof this.value_,r=Tc.VALUE_TYPE_ORDER.indexOf(e),i=Tc.VALUE_TYPE_ORDER.indexOf(n);return Oa(0<=r,"Unknown leaf type: "+e),Oa(0<=i,"Unknown leaf type: "+n),r===i?"object"==n?0:this.value_<t.value_?-1:this.value_===t.value_?0:1:i-r},Tc.prototype.withIndex=function(){return this},Tc.prototype.isIndexed=function(){return!0},Tc.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},Tc.VALUE_TYPE_ORDER=["object","boolean","number","string"],Tc);function Tc(t,e){void 0===e&&(e=Tc.__childrenNodeConstructor.EMPTY_NODE),this.value_=t,this.priorityNode_=e,this.lazyHash_=null,Oa(void 0!==this.value_&&null!==this.value_,"LeafNode shouldn't be created with null/undefined value."),gc(this.priorityNode_)}function Sc(){return null!==_c&&_c.apply(this,arguments)||this}var Ic=new(_a(Sc,_c=cc),Sc.prototype.compare=function(t,e){var n=t.node.getPriority(),r=e.node.getPriority(),i=n.compareTo(r);return 0===i?vu(t.name,e.name):i},Sc.prototype.isDefinedOn=function(t){return!t.getPriority().isEmpty()},Sc.prototype.indexedValueChanged=function(t,e){return!t.getPriority().equals(e.getPriority())},Sc.prototype.minPost=function(){return ac.MIN},Sc.prototype.maxPost=function(){return new ac(gu,new Ec("[PRIORITY-POST]",wc))},Sc.prototype.makePost=function(t,e){var n=bc(t);return new ac(e,new Ec("[PRIORITY-POST]",n))},Sc.prototype.toString=function(){return".priority"},Sc),Cc=(Nc.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},Nc.prototype.hasNext=function(){return 0<this.nodeStack_.length},Nc.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}},Nc);function Nc(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 Ac=(Dc.prototype.copy=function(t,e,n,r,i){return new Dc(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)},Dc.prototype.count=function(){return this.left.count()+1+this.right.count()},Dc.prototype.isEmpty=function(){return!1},Dc.prototype.inorderTraversal=function(t){return this.left.inorderTraversal(t)||!!t(this.key,this.value)||this.right.inorderTraversal(t)},Dc.prototype.reverseTraversal=function(t){return this.right.reverseTraversal(t)||t(this.key,this.value)||this.left.reverseTraversal(t)},Dc.prototype.min_=function(){return this.left.isEmpty()?this:this.left.min_()},Dc.prototype.minKey=function(){return this.min_().key},Dc.prototype.maxKey=function(){return this.right.isEmpty()?this.key:this.right.maxKey()},Dc.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_()},Dc.prototype.removeMin_=function(){if(this.left.isEmpty())return Oc.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_()},Dc.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 Oc.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_()},Dc.prototype.isRed_=function(){return this.color},Dc.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},Dc.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},Dc.prototype.moveRedRight_=function(){var t=this.colorFlip_();return t.left.left.isRed_()&&(t=(t=t.rotateRight_()).colorFlip_()),t},Dc.prototype.rotateLeft_=function(){var t=this.copy(null,null,Dc.RED,null,this.right.left);return this.right.copy(null,null,this.color,t,null)},Dc.prototype.rotateRight_=function(){var t=this.copy(null,null,Dc.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,t)},Dc.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)},Dc.prototype.checkMaxDepth_=function(){var t=this.check_();return Math.pow(2,t)<=this.count()+1},Dc.prototype.check_=function(){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");var t=this.left.check_();if(t!==this.right.check_())throw new Error("Black depths differ");return t+(this.isRed_()?0:1)},Dc.RED=!0,Dc.BLACK=!1,Dc);function Dc(t,e,n,r,i){this.key=t,this.value=e,this.color=null!=n?n:Dc.RED,this.left=null!=r?r:Oc.EMPTY_NODE,this.right=null!=i?i:Oc.EMPTY_NODE}var kc=(Rc.prototype.copy=function(t,e,n,r,i){return this},Rc.prototype.insert=function(t,e,n){return new Ac(t,e,null)},Rc.prototype.remove=function(t,e){return this},Rc.prototype.count=function(){return 0},Rc.prototype.isEmpty=function(){return!0},Rc.prototype.inorderTraversal=function(t){return!1},Rc.prototype.reverseTraversal=function(t){return!1},Rc.prototype.minKey=function(){return null},Rc.prototype.maxKey=function(){return null},Rc.prototype.check_=function(){return 0},Rc.prototype.isRed_=function(){return!1},Rc);function Rc(){}var Oc=(Pc.prototype.insert=function(t,e){return new Pc(this.comparator_,this.root_.insert(t,e,this.comparator_).copy(null,null,Ac.BLACK,null,null))},Pc.prototype.remove=function(t){return new Pc(this.comparator_,this.root_.remove(t,this.comparator_).copy(null,null,Ac.BLACK,null,null))},Pc.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},Pc.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?")},Pc.prototype.isEmpty=function(){return this.root_.isEmpty()},Pc.prototype.count=function(){return this.root_.count()},Pc.prototype.minKey=function(){return this.root_.minKey()},Pc.prototype.maxKey=function(){return this.root_.maxKey()},Pc.prototype.inorderTraversal=function(t){return this.root_.inorderTraversal(t)},Pc.prototype.reverseTraversal=function(t){return this.root_.reverseTraversal(t)},Pc.prototype.getIterator=function(t){return new Cc(this.root_,null,this.comparator_,!1,t)},Pc.prototype.getIteratorFrom=function(t,e){return new Cc(this.root_,t,this.comparator_,!1,e)},Pc.prototype.getReverseIteratorFrom=function(t,e){return new Cc(this.root_,t,this.comparator_,!0,e)},Pc.prototype.getReverseIterator=function(t){return new Cc(this.root_,null,this.comparator_,!0,t)},Pc.EMPTY_NODE=new kc,Pc);function Pc(t,e){void 0===e&&(e=Pc.EMPTY_NODE),this.comparator_=t,this.root_=e}var xc=Math.log(2),Mc=(Lc.prototype.nextBitIsOne=function(){var t=!(this.bits_&1<<this.current_);return this.current_--,t},Lc);function Lc(t){var e;this.count=(e=t+1,parseInt(Math.log(e)/xc,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 Fc,Uc,Vc=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 Ac(r,n.node,Ac.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 Ac(r,n.node,Ac.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 Ac(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,Ac.BLACK):(r(a,Ac.BLACK),r(a,Ac.RED))}return n}(new Mc(c.length));return new Oc(e||t,n)},qc={},Bc=(Object.defineProperty(jc,"Default",{get:function(){return Oa(Ic,"ChildrenNode.ts has not been loaded"),Fc=Fc||new jc({".priority":qc},{".priority":Ic})},enumerable:!0,configurable:!0}),jc.prototype.get=function(t){var e=Za(this.indexes_,t);if(!e)throw new Error("No index defined for "+t);return e instanceof Oc?e:null},jc.prototype.hasIndex=function(t){return $a(this.indexSet_,t.toString())},jc.prototype.addIndex=function(t,e){Oa(t!==yc,"KeyIndex always exists and isn't meant to be added to the IndexMap.");for(var n,r=[],i=!1,o=e.getIterator(ac.Wrap),a=o.getNext();a;)i=i||t.isDefinedOn(a.node),r.push(a),a=o.getNext();n=i?Vc(r,t.getCompare()):qc;var s=t.toString(),u=Ea({},this.indexSet_);u[s]=t;var c=Ea({},this.indexes_);return c[s]=n,new jc(c,u)},jc.prototype.addToIndexes=function(u,c){var h=this;return new jc(es(this.indexes_,function(t,e){var n=Za(h.indexSet_,e);if(Oa(n,"Missing index implementation for "+e),t===qc){if(n.isDefinedOn(u.node)){for(var r=[],i=c.getIterator(ac.Wrap),o=i.getNext();o;)o.name!==u.name&&r.push(o),o=i.getNext();return r.push(u),Vc(r,n.getCompare())}return qc}var a=c.get(u.name),s=t;return a&&(s=s.remove(new ac(u.name,a))),s.insert(u,u.node)}),this.indexSet_)},jc.prototype.removeFromIndexes=function(n,r){return new jc(es(this.indexes_,function(t){if(t===qc)return t;var e=r.get(n.name);return e?t.remove(new ac(n.name,e)):t}),this.indexSet_)},jc);function jc(t,e){this.indexes_=t,this.indexSet_=e}function Wc(t,e){return vu(t.name,e.name)}function Kc(t,e){return vu(t,e)}var Qc,Hc=(Object.defineProperty(zc,"EMPTY_NODE",{get:function(){return Uc=Uc||new zc(new Oc(Kc),null,Bc.Default)},enumerable:!0,configurable:!0}),zc.prototype.isLeafNode=function(){return!1},zc.prototype.getPriority=function(){return this.priorityNode_||Uc},zc.prototype.updatePriority=function(t){return this.children_.isEmpty()?this:new zc(this.children_,t,this.indexMap_)},zc.prototype.getImmediateChild=function(t){if(".priority"===t)return this.getPriority();var e=this.children_.get(t);return null===e?Uc:e},zc.prototype.getChild=function(t){var e=t.getFront();return null===e?this:this.getImmediateChild(e).getChild(t.popFront())},zc.prototype.hasChild=function(t){return null!==this.children_.get(t)},zc.prototype.updateImmediateChild=function(t,e){if(Oa(e,"We should always be passing snapshot nodes"),".priority"===t)return this.updatePriority(e);var n=new ac(t,e),r=void 0,i=void 0;i=e.isEmpty()?(r=this.children_.remove(t),this.indexMap_.removeFromIndexes(n,this.children_)):(r=this.children_.insert(t,e),this.indexMap_.addToIndexes(n,this.children_));var o=r.isEmpty()?Uc:this.priorityNode_;return new zc(r,o,i)},zc.prototype.updateChild=function(t,e){var n=t.getFront();if(null===n)return e;Oa(".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)},zc.prototype.isEmpty=function(){return this.children_.isEmpty()},zc.prototype.numChildren=function(){return this.children_.count()},zc.prototype.val=function(n){if(this.isEmpty())return null;var r={},i=0,o=0,a=!0;if(this.forEachChild(Ic,function(t,e){r[t]=e.val(n),i++,a&&zc.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},zc.prototype.hash=function(){if(null===this.lazyHash_){var r="";this.getPriority().isEmpty()||(r+="priority:"+mc(this.getPriority().val())+":"),this.forEachChild(Ic,function(t,e){var n=e.hash();""!==n&&(r+=":"+t+":"+n)}),this.lazyHash_=""===r?"":Js(r)}return this.lazyHash_},zc.prototype.getPredecessorChildName=function(t,e,n){var r=this.resolveIndex_(n);if(r){var i=r.getPredecessorKey(new ac(t,e));return i?i.name:null}return this.children_.getPredecessorKey(t)},zc.prototype.getFirstChildName=function(t){var e=this.resolveIndex_(t);if(e){var n=e.minKey();return n&&n.name}return this.children_.minKey()},zc.prototype.getFirstChild=function(t){var e=this.getFirstChildName(t);return e?new ac(e,this.children_.get(e)):null},zc.prototype.getLastChildName=function(t){var e=this.resolveIndex_(t);if(e){var n=e.maxKey();return n&&n.name}return this.children_.maxKey()},zc.prototype.getLastChild=function(t){var e=this.getLastChildName(t);return e?new ac(e,this.children_.get(e)):null},zc.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)},zc.prototype.getIterator=function(t){return this.getIteratorFrom(t.minPost(),t)},zc.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,ac.Wrap),i=r.peek();null!=i&&e.compare(i,t)<0;)r.getNext(),i=r.peek();return r},zc.prototype.getReverseIterator=function(t){return this.getReverseIteratorFrom(t.maxPost(),t)},zc.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,ac.Wrap),i=r.peek();null!=i&&0<e.compare(i,t);)r.getNext(),i=r.peek();return r},zc.prototype.compareTo=function(t){return this.isEmpty()?t.isEmpty()?0:-1:t.isLeafNode()||t.isEmpty()?1:t===Yc?-1:0},zc.prototype.withIndex=function(t){if(t===yc||this.indexMap_.hasIndex(t))return this;var e=this.indexMap_.addIndex(t,this.children_);return new zc(this.children_,this.priorityNode_,e)},zc.prototype.isIndexed=function(t){return t===yc||this.indexMap_.hasIndex(t)},zc.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(Ic),r=e.getIterator(Ic),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},zc.prototype.resolveIndex_=function(t){return t===yc?null:this.indexMap_.get(t.toString())},zc.INTEGER_REGEXP_=/^(0|[1-9]\d*)$/,zc);function zc(t,e,n){this.children_=t,this.priorityNode_=e,this.indexMap_=n,this.lazyHash_=null,this.priorityNode_&&gc(this.priorityNode_),this.children_.isEmpty()&&Oa(!this.priorityNode_||this.priorityNode_.isEmpty(),"An empty node cannot have a priority")}function Gc(){return Qc.call(this,new Oc(Kc),Hc.EMPTY_NODE,Bc.Default)||this}var Yc=new(_a(Gc,Qc=Hc),Gc.prototype.compareTo=function(t){return t===this?0:1},Gc.prototype.equals=function(t){return t===this},Gc.prototype.getPriority=function(){return this},Gc.prototype.getImmediateChild=function(t){return Hc.EMPTY_NODE},Gc.prototype.isEmpty=function(){return!1},Gc);Object.defineProperties(ac,{MIN:{value:new ac(mu,Hc.EMPTY_NODE)},MAX:{value:new ac(gu,Yc)}}),fc.__EMPTY_NODE=Hc.EMPTY_NODE,Ec.__childrenNodeConstructor=Hc,dc=Yc,wc=Yc;var Xc,Jc=!0;function $c(r,t){if(void 0===t&&(t=null),null===r)return Hc.EMPTY_NODE;if("object"==typeof r&&".priority"in r&&(t=r[".priority"]),Oa(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 Ec(r,$c(t));if(r instanceof Array||!Jc){var i=Hc.EMPTY_NODE;return wu(r,function(t,e){if($a(r,t)&&"."!==t.substring(0,1)){var n=$c(e);!n.isLeafNode()&&n.isEmpty()||(i=i.updateImmediateChild(t,n))}}),i.updatePriority($c(t))}var o=[],a=!1;if(wu(r,function(t,e){if("."!==t.substring(0,1)){var n=$c(e);n.isEmpty()||(a=a||!n.getPriority().isEmpty(),o.push(new ac(t,n)))}}),0===o.length)return Hc.EMPTY_NODE;var e=Vc(o,Wc,function(t){return t.name},Kc);if(a){var n=Vc(o,Ic.getCompare());return new Hc(e,$c(t),new Bc({".priority":n},{".priority":Ic}))}return new Hc(e,$c(t),Bc.Default)}function Zc(){return null!==Xc&&Xc.apply(this,arguments)||this}bc=$c;var th,eh=new(_a(Zc,Xc=cc),Zc.prototype.compare=function(t,e){var n=t.node.compareTo(e.node);return 0===n?vu(t.name,e.name):n},Zc.prototype.isDefinedOn=function(t){return!0},Zc.prototype.indexedValueChanged=function(t,e){return!t.equals(e)},Zc.prototype.minPost=function(){return ac.MIN},Zc.prototype.maxPost=function(){return ac.MAX},Zc.prototype.makePost=function(t,e){var n=$c(t);return new ac(e,n)},Zc.prototype.toString=function(){return".value"},Zc),nh=(_a(rh,th=cc),rh.prototype.extractChild=function(t){return t.getChild(this.indexPath_)},rh.prototype.isDefinedOn=function(t){return!t.getChild(this.indexPath_).isEmpty()},rh.prototype.compare=function(t,e){var n=this.extractChild(t.node),r=this.extractChild(e.node),i=n.compareTo(r);return 0===i?vu(t.name,e.name):i},rh.prototype.makePost=function(t,e){var n=$c(t),r=Hc.EMPTY_NODE.updateChild(this.indexPath_,n);return new ac(e,r)},rh.prototype.maxPost=function(){var t=Hc.EMPTY_NODE.updateChild(this.indexPath_,Yc);return new ac(gu,t)},rh.prototype.toString=function(){return this.indexPath_.slice().join("/")},rh);function rh(t){var e=th.call(this)||this;return e.indexPath_=t,Oa(!t.isEmpty()&&".priority"!==t.getFront(),"Can't create PathIndex with empty path or .priority key"),e}var ih=(oh.prototype.val=function(){return us("DataSnapshot.val",0,0,arguments.length),this.node_.val()},oh.prototype.exportVal=function(){return us("DataSnapshot.exportVal",0,0,arguments.length),this.node_.val(!0)},oh.prototype.toJSON=function(){return us("DataSnapshot.toJSON",0,1,arguments.length),this.exportVal()},oh.prototype.exists=function(){return us("DataSnapshot.exists",0,0,arguments.length),!this.node_.isEmpty()},oh.prototype.child=function(t){us("DataSnapshot.child",0,1,arguments.length),t=String(t),Ku("DataSnapshot.child",1,t,!1);var e=new Cu(t),n=this.ref_.child(e);return new oh(this.node_.getChild(e),n,Ic)},oh.prototype.hasChild=function(t){us("DataSnapshot.hasChild",1,1,arguments.length),Ku("DataSnapshot.hasChild",1,t,!1);var e=new Cu(t);return!this.node_.getChild(e).isEmpty()},oh.prototype.getPriority=function(){return us("DataSnapshot.getPriority",0,0,arguments.length),this.node_.getPriority().val()},oh.prototype.forEach=function(n){var r=this;return us("DataSnapshot.forEach",1,1,arguments.length),hs("DataSnapshot.forEach",1,n,!1),!this.node_.isLeafNode()&&!!this.node_.forEachChild(this.index_,function(t,e){return n(new oh(e,r.ref_.child(t),Ic))})},oh.prototype.hasChildren=function(){return us("DataSnapshot.hasChildren",0,0,arguments.length),!this.node_.isLeafNode()&&!this.node_.isEmpty()},Object.defineProperty(oh.prototype,"key",{get:function(){return this.ref_.getKey()},enumerable:!0,configurable:!0}),oh.prototype.numChildren=function(){return us("DataSnapshot.numChildren",0,0,arguments.length),this.node_.numChildren()},oh.prototype.getRef=function(){return us("DataSnapshot.ref",0,0,arguments.length),this.ref_},Object.defineProperty(oh.prototype,"ref",{get:function(){return this.getRef()},enumerable:!0,configurable:!0}),oh);function oh(t,e,n){this.node_=t,this.ref_=e,this.index_=n}var ah=(sh.prototype.getPath=function(){var t=this.snapshot.getRef();return"value"===this.eventType?t.path:t.getParent().path},sh.prototype.getEventType=function(){return this.eventType},sh.prototype.getEventRunner=function(){return this.eventRegistration.getEventRunner(this)},sh.prototype.toString=function(){return this.getPath().toString()+":"+this.eventType+":"+Xa(this.snapshot.exportVal())},sh);function sh(t,e,n,r){this.eventType=t,this.eventRegistration=e,this.snapshot=n,this.prevName=r}var uh=(ch.prototype.getPath=function(){return this.path},ch.prototype.getEventType=function(){return"cancel"},ch.prototype.getEventRunner=function(){return this.eventRegistration.getEventRunner(this)},ch.prototype.toString=function(){return this.path.toString()+":cancel"},ch);function ch(t,e,n){this.eventRegistration=t,this.error=e,this.path=n}var hh=(lh.prototype.respondsTo=function(t){return"value"===t},lh.prototype.createEvent=function(t,e){var n=e.getQueryParams().getIndex();return new ah("value",this,new ih(t.snapshotNode,e.getRef(),n))},lh.prototype.getEventRunner=function(t){var e=this.context_;if("cancel"===t.getEventType()){Oa(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)}},lh.prototype.createCancelEvent=function(t,e){return this.cancelCallback_?new uh(this,t,e):null},lh.prototype.matches=function(t){return t instanceof lh&&(!t.callback_||!this.callback_||t.callback_===this.callback_&&t.context_===this.context_)},lh.prototype.hasAnyCallback=function(){return null!==this.callback_},lh);function lh(t,e,n){this.callback_=t,this.cancelCallback_=e,this.context_=n}var fh,ph=(dh.prototype.respondsTo=function(t){var e="children_added"===t?"child_added":t;return e="children_removed"===e?"child_removed":e,$a(this.callbacks_,e)},dh.prototype.createCancelEvent=function(t,e){return this.cancelCallback_?new uh(this,t,e):null},dh.prototype.createEvent=function(t,e){Oa(null!=t.childName,"Child events should have a childName.");var n=e.getRef().child(t.childName),r=e.getQueryParams().getIndex();return new ah(t.type,this,new ih(t.snapshotNode,n,r),t.prevName)},dh.prototype.getEventRunner=function(t){var e=this.context_;if("cancel"===t.getEventType()){Oa(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)}},dh.prototype.matches=function(e){var n=this;if(e instanceof dh){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},dh.prototype.hasAnyCallback=function(){return null!==this.callbacks_},dh);function dh(t,e,n){this.callbacks_=t,this.cancelCallback_=e,this.context_=n}var yh=(Object.defineProperty(mh,"__referenceConstructor",{get:function(){return Oa(fh,"Reference.ts has not been loaded"),fh},set:function(t){fh=t},enumerable:!0,configurable:!0}),mh.validateQueryEndpoints_=function(t){var e=null,n=null;if(t.hasStart()&&(e=t.getIndexStartValue()),t.hasEnd()&&(n=t.getIndexEndValue()),t.getIndex()===yc){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()!==mu)throw new Error(r);if("string"!=typeof e)throw new Error(i)}if(t.hasEnd()){if(t.getIndexEndName()!==gu)throw new Error(r);if("string"!=typeof n)throw new Error(i)}}else if(t.getIndex()===Ic){if(null!=e&&!Uu(e)||null!=n&&!Uu(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(Oa(t.getIndex()instanceof nh||t.getIndex()===eh,"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.")},mh.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.")},mh.prototype.validateNoPreviousOrderByCall_=function(t){if(!0===this.orderByCalled_)throw new Error(t+": You can't combine multiple orderBy calls.")},mh.prototype.getQueryParams=function(){return this.queryParams_},mh.prototype.getRef=function(){return us("Query.ref",0,0,arguments.length),new mh.__referenceConstructor(this.repo,this.path)},mh.prototype.on=function(t,e,n,r){us("Query.on",2,4,arguments.length),ju("Query.on",1,t,!1),hs("Query.on",2,e,!1);var i=mh.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},mh.prototype.onValueEvent=function(t,e,n){var r=new hh(t,e||null,n||null);this.repo.addEventCallbackForQuery(this,r)},mh.prototype.onChildEvent=function(t,e,n){var r=new ph(t,e,n);this.repo.addEventCallbackForQuery(this,r)},mh.prototype.off=function(t,e,n){us("Query.off",0,3,arguments.length),ju("Query.off",1,t,!0),hs("Query.off",2,e,!0),ls("Query.off",3,n,!0);var r=null,i=null;"value"===t?r=new hh(e||null,null,n||null):t&&(e&&((i={})[t]=e),r=new ph(i,null,n||null)),this.repo.removeEventCallbackForQuery(this,r)},mh.prototype.once=function(e,n,t,r){var i=this;us("Query.once",1,4,arguments.length),ju("Query.once",1,e,!1),hs("Query.once",2,n,!0);var o=mh.getCancelAndContextArgs_("Query.once",t,r),a=!0,s=new Fa;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},mh.prototype.limitToFirst=function(t){if(us("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 mh(this.repo,this.path,this.queryParams_.limitToFirst(t),this.orderByCalled_)},mh.prototype.limitToLast=function(t){if(us("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 mh(this.repo,this.path,this.queryParams_.limitToLast(t),this.orderByCalled_)},mh.prototype.orderByChild=function(t){if(us("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.');Ku("Query.orderByChild",1,t,!1),this.validateNoPreviousOrderByCall_("Query.orderByChild");var e=new Cu(t);if(e.isEmpty())throw new Error("Query.orderByChild: cannot pass in empty path. Use Query.orderByValue() instead.");var n=new nh(e),r=this.queryParams_.orderBy(n);return mh.validateQueryEndpoints_(r),new mh(this.repo,this.path,r,!0)},mh.prototype.orderByKey=function(){us("Query.orderByKey",0,0,arguments.length),this.validateNoPreviousOrderByCall_("Query.orderByKey");var t=this.queryParams_.orderBy(yc);return mh.validateQueryEndpoints_(t),new mh(this.repo,this.path,t,!0)},mh.prototype.orderByPriority=function(){us("Query.orderByPriority",0,0,arguments.length),this.validateNoPreviousOrderByCall_("Query.orderByPriority");var t=this.queryParams_.orderBy(Ic);return mh.validateQueryEndpoints_(t),new mh(this.repo,this.path,t,!0)},mh.prototype.orderByValue=function(){us("Query.orderByValue",0,0,arguments.length),this.validateNoPreviousOrderByCall_("Query.orderByValue");var t=this.queryParams_.orderBy(eh);return mh.validateQueryEndpoints_(t),new mh(this.repo,this.path,t,!0)},mh.prototype.startAt=function(t,e){void 0===t&&(t=null),us("Query.startAt",0,2,arguments.length),Vu("Query.startAt",1,t,this.path,!0),Wu("Query.startAt",2,e,!0);var n=this.queryParams_.startAt(t,e);if(mh.validateLimit_(n),mh.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 mh(this.repo,this.path,n,this.orderByCalled_)},mh.prototype.endAt=function(t,e){void 0===t&&(t=null),us("Query.endAt",0,2,arguments.length),Vu("Query.endAt",1,t,this.path,!0),Wu("Query.endAt",2,e,!0);var n=this.queryParams_.endAt(t,e);if(mh.validateLimit_(n),mh.validateQueryEndpoints_(n),this.queryParams_.hasEnd())throw new Error("Query.endAt: Ending point was already set (by another call to endAt or equalTo).");return new mh(this.repo,this.path,n,this.orderByCalled_)},mh.prototype.equalTo=function(t,e){if(us("Query.equalTo",1,2,arguments.length),Vu("Query.equalTo",1,t,this.path,!1),Wu("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)},mh.prototype.toString=function(){return us("Query.toString",0,0,arguments.length),this.repo.toString()+this.path.toUrlEncodedString()},mh.prototype.toJSON=function(){return us("Query.toJSON",0,1,arguments.length),this.toString()},mh.prototype.queryObject=function(){return this.queryParams_.getQueryObject()},mh.prototype.queryIdentifier=function(){var t=this.queryObject(),e=bu(t);return"{}"===e?"default":e},mh.prototype.isEqual=function(t){if(us("Query.isEqual",1,1,arguments.length),!(t instanceof mh))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},mh.getCancelAndContextArgs_=function(t,e,n){var r={cancel:null,context:null};if(e&&n)r.cancel=e,hs(t,3,r.cancel,!0),r.context=n,ls(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(cs(t,3,!0)+" must either be a cancel callback or a context object.");r.cancel=e}return r},Object.defineProperty(mh.prototype,"ref",{get:function(){return this.getRef()},enumerable:!0,configurable:!0}),mh);function mh(t,e,n,r){this.repo=t,this.path=e,this.queryParams_=n,this.orderByCalled_=r}var gh=(vh.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},vh.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 vh);var r=this.children.get(n);t=t.popFront(),r.remember(t,e)}},vh.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(Ic,function(t,e){n.remember(new Cu(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},vh.prototype.forEachTree=function(r,i){null!==this.value?i(r,this.value):this.forEachChild(function(t,e){var n=new Cu(r.toString()+"/"+t);e.forEachTree(n,i)})},vh.prototype.forEachChild=function(n){this.children.forEach(function(t,e){n(e,t)})},vh);function vh(){this.value=null,this.children=new Map}function bh(t,e){return t&&"object"==typeof t?(Oa(".sv"in t,"Unexpected leaf node or priority contents"),e[t[".sv"]]):t}var wh,_h,Eh=function(t,r){var i,e=t.getPriority().val(),n=bh(e,r);if(t.isLeafNode()){var o=t,a=bh(o.getValue(),r);return a!==o.getValue()||n!==o.getPriority().val()?new Ec(a,$c(n)):t}var s=t;return n!==(i=s).getPriority().val()&&(i=i.updatePriority(new Ec(n))),s.forEachChild(Ic,function(t,e){var n=Eh(e,r);n!==e&&(i=i.updateImmediateChild(t,n))}),i};(_h=wh=wh||{})[_h.OVERWRITE=0]="OVERWRITE",_h[_h.MERGE=1]="MERGE",_h[_h.ACK_USER_WRITE=2]="ACK_USER_WRITE",_h[_h.LISTEN_COMPLETE=3]="LISTEN_COMPLETE";var Th=(Sh.User=new Sh(!0,!1,null,!1),Sh.Server=new Sh(!1,!0,null,!1),Sh.forServerTaggedQuery=function(t){return new Sh(!1,!0,t,!0)},Sh);function Sh(t,e,n,r){this.fromUser=t,this.fromServer=e,this.queryId=n,this.tagged=r,Oa(!r||e,"Tagged queries must be from server.")}var Ih,Ch=(Nh.prototype.operationForChild=function(t){if(this.path.isEmpty()){if(null!=this.affectedTree.value)return Oa(this.affectedTree.children.isEmpty(),"affectedTree should not have overlapping affected paths."),this;var e=this.affectedTree.subtree(new Cu(t));return new Nh(Cu.Empty,e,this.revert)}return Oa(this.path.getFront()===t,"operationForChild called for unrelated child."),new Nh(this.path.popFront(),this.affectedTree,this.revert)},Nh);function Nh(t,e,n){this.path=t,this.affectedTree=e,this.revert=n,this.type=wh.ACK_USER_WRITE,this.source=Th.User}var Ah=(Dh.fromObject=function(t){var n=Dh.Empty;return wu(t,function(t,e){n=n.set(new Cu(t),e)}),n},Dh.prototype.isEmpty=function(){return null===this.value&&this.children.isEmpty()},Dh.prototype.findRootMostMatchingPathAndValue=function(t,e){if(null!=this.value&&e(this.value))return{path:Cu.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 Cu(n).child(i.path),value:i.value}},Dh.prototype.findRootMostValueAndPath=function(t){return this.findRootMostMatchingPathAndValue(t,function(){return!0})},Dh.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()):Dh.Empty},Dh.prototype.set=function(t,e){if(t.isEmpty())return new Dh(e,this.children);var n=t.getFront(),r=(this.children.get(n)||Dh.Empty).set(t.popFront(),e),i=this.children.insert(n,r);return new Dh(this.value,i)},Dh.prototype.remove=function(t){if(t.isEmpty())return this.children.isEmpty()?Dh.Empty:new Dh(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()?Dh.Empty:new Dh(this.value,i)}return this},Dh.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},Dh.prototype.setTree=function(t,e){if(t.isEmpty())return e;var n=t.getFront(),r=(this.children.get(n)||Dh.Empty).setTree(t.popFront(),e),i=void 0;return i=r.isEmpty()?this.children.remove(n):this.children.insert(n,r),new Dh(this.value,i)},Dh.prototype.fold=function(t){return this.fold_(Cu.Empty,t)},Dh.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)},Dh.prototype.findOnPath=function(t,e){return this.findOnPath_(t,Cu.Empty,e)},Dh.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},Dh.prototype.foreachOnPath=function(t,e){return this.foreachOnPath_(t,Cu.Empty,e)},Dh.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):Dh.Empty},Dh.prototype.foreach=function(t){this.foreach_(Cu.Empty,t)},Dh.prototype.foreach_=function(n,r){this.children.inorderTraversal(function(t,e){e.foreach_(n.child(t),r)}),this.value&&r(n,this.value)},Dh.prototype.foreachChild=function(n){this.children.inorderTraversal(function(t,e){e.value&&n(t,e.value)})},Dh.Empty=new Dh(null),Dh);function Dh(t,e){void 0===e&&(e=Ih=Ih||new Oc(ou)),this.value=t,this.children=e}var kh=(Rh.prototype.operationForChild=function(t){return this.path.isEmpty()?new Rh(this.source,Cu.Empty):new Rh(this.source,this.path.popFront())},Rh);function Rh(t,e){this.source=t,this.path=e,this.type=wh.LISTEN_COMPLETE}var Oh=(Ph.prototype.operationForChild=function(t){return this.path.isEmpty()?new Ph(this.source,Cu.Empty,this.snap.getImmediateChild(t)):new Ph(this.source,this.path.popFront(),this.snap)},Ph);function Ph(t,e,n){this.source=t,this.path=e,this.snap=n,this.type=wh.OVERWRITE}var xh=(Mh.prototype.operationForChild=function(t){if(this.path.isEmpty()){var e=this.children.subtree(new Cu(t));return e.isEmpty()?null:e.value?new Oh(this.source,Cu.Empty,e.value):new Mh(this.source,Cu.Empty,e)}return Oa(this.path.getFront()===t,"Can't get a merge for a child not on the path of the operation"),new Mh(this.source,this.path.popFront(),this.children)},Mh.prototype.toString=function(){return"Operation("+this.path+": "+this.source.toString()+" merge: "+this.children.toString()+")"},Mh);function Mh(t,e,n){this.source=t,this.path=e,this.children=n,this.type=wh.MERGE}var Lh=(Fh.prototype.isFullyInitialized=function(){return this.fullyInitialized_},Fh.prototype.isFiltered=function(){return this.filtered_},Fh.prototype.isCompleteForPath=function(t){if(t.isEmpty())return this.isFullyInitialized()&&!this.filtered_;var e=t.getFront();return this.isCompleteForChild(e)},Fh.prototype.isCompleteForChild=function(t){return this.isFullyInitialized()&&!this.filtered_||this.node_.hasChild(t)},Fh.prototype.getNode=function(){return this.node_},Fh);function Fh(t,e,n){this.node_=t,this.fullyInitialized_=e,this.filtered_=n}var Uh=(Vh.prototype.updateEventSnap=function(t,e,n){return new Vh(new Lh(t,e,n),this.serverCache_)},Vh.prototype.updateServerSnap=function(t,e,n){return new Vh(this.eventCache_,new Lh(t,e,n))},Vh.prototype.getEventCache=function(){return this.eventCache_},Vh.prototype.getCompleteEventSnap=function(){return this.eventCache_.isFullyInitialized()?this.eventCache_.getNode():null},Vh.prototype.getServerCache=function(){return this.serverCache_},Vh.prototype.getCompleteServerSnap=function(){return this.serverCache_.isFullyInitialized()?this.serverCache_.getNode():null},Vh.Empty=new Vh(new Lh(Hc.EMPTY_NODE,!1,!1),new Lh(Hc.EMPTY_NODE,!1,!1)),Vh);function Vh(t,e){this.eventCache_=t,this.serverCache_=e}var qh=(Bh.valueChange=function(t){return new Bh(Bh.VALUE,t)},Bh.childAddedChange=function(t,e){return new Bh(Bh.CHILD_ADDED,e,t)},Bh.childRemovedChange=function(t,e){return new Bh(Bh.CHILD_REMOVED,e,t)},Bh.childChangedChange=function(t,e,n){return new Bh(Bh.CHILD_CHANGED,e,t,n)},Bh.childMovedChange=function(t,e){return new Bh(Bh.CHILD_MOVED,e,t)},Bh.CHILD_ADDED="child_added",Bh.CHILD_REMOVED="child_removed",Bh.CHILD_CHANGED="child_changed",Bh.CHILD_MOVED="child_moved",Bh.VALUE="value",Bh);function Bh(t,e,n,r,i){this.type=t,this.snapshotNode=e,this.childName=n,this.oldSnap=r,this.prevName=i}var jh=(Wh.prototype.updateChild=function(t,e,n,r,i,o){Oa(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(qh.childRemovedChange(e,a)):Oa(t.isLeafNode(),"A child remove without an old child only makes sense on a leaf node"):a.isEmpty()?o.trackChildChange(qh.childAddedChange(e,n)):o.trackChildChange(qh.childChangedChange(e,n,a))),t.isLeafNode()&&n.isEmpty()?t:t.updateImmediateChild(e,n).withIndex(this.index_))},Wh.prototype.updateFullNode=function(r,n,i){return null!=i&&(r.isLeafNode()||r.forEachChild(Ic,function(t,e){n.hasChild(t)||i.trackChildChange(qh.childRemovedChange(t,e))}),n.isLeafNode()||n.forEachChild(Ic,function(t,e){if(r.hasChild(t)){var n=r.getImmediateChild(t);n.equals(e)||i.trackChildChange(qh.childChangedChange(t,e,n))}else i.trackChildChange(qh.childAddedChange(t,e))})),n.withIndex(this.index_)},Wh.prototype.updatePriority=function(t,e){return t.isEmpty()?Hc.EMPTY_NODE:t.updatePriority(e)},Wh.prototype.filtersNodes=function(){return!1},Wh.prototype.getIndexedFilter=function(){return this},Wh.prototype.getIndex=function(){return this.index_},Wh);function Wh(t){this.index_=t}var Kh=(Qh.prototype.trackChildChange=function(t){var e=t.type,n=t.childName;Oa(e===qh.CHILD_ADDED||e===qh.CHILD_CHANGED||e===qh.CHILD_REMOVED,"Only child changes supported for tracking"),Oa(".priority"!==n,"Only non-priority child changes can be tracked.");var r=this.changeMap.get(n);if(r){var i=r.type;if(e===qh.CHILD_ADDED&&i===qh.CHILD_REMOVED)this.changeMap.set(n,qh.childChangedChange(n,t.snapshotNode,r.snapshotNode));else if(e===qh.CHILD_REMOVED&&i===qh.CHILD_ADDED)this.changeMap.delete(n);else if(e===qh.CHILD_REMOVED&&i===qh.CHILD_CHANGED)this.changeMap.set(n,qh.childRemovedChange(n,r.oldSnap));else if(e===qh.CHILD_CHANGED&&i===qh.CHILD_ADDED)this.changeMap.set(n,qh.childAddedChange(n,t.snapshotNode));else{if(e!==qh.CHILD_CHANGED||i!==qh.CHILD_CHANGED)throw Pa("Illegal combination of changes: "+t+" occurred after "+r);this.changeMap.set(n,qh.childChangedChange(n,t.snapshotNode,r.oldSnap))}}else this.changeMap.set(n,t)},Qh.prototype.getChanges=function(){return Array.from(this.changeMap.values())},Qh);function Qh(){this.changeMap=new Map}function Hh(){}var zh=new(Hh.prototype.getCompleteChild=function(t){return null},Hh.prototype.getChildAfterChild=function(t,e,n){return null},Hh),Gh=(Yh.prototype.getCompleteChild=function(t){var e=this.viewCache_.getEventCache();if(e.isCompleteForChild(t))return e.getNode().getImmediateChild(t);var n=null!=this.optCompleteServerCache_?new Lh(this.optCompleteServerCache_,!0,!1):this.viewCache_.getServerCache();return this.writes_.calcCompleteChild(t,n)},Yh.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]},Yh);function Yh(t,e,n){void 0===n&&(n=null),this.writes_=t,this.viewCache_=e,this.optCompleteServerCache_=n}var Xh=function(t,e){this.viewCache=t,this.changes=e},Jh=($h.prototype.assertIndexed=function(t){Oa(t.getEventCache().getNode().isIndexed(this.filter_.getIndex()),"Event snap not indexed"),Oa(t.getServerCache().getNode().isIndexed(this.filter_.getIndex()),"Server snap not indexed")},$h.prototype.applyOperation=function(t,e,n,r){var i,o,a=new Kh;if(e.type===wh.OVERWRITE){var s=e;i=s.source.fromUser?this.applyUserOverwrite_(t,s.path,s.snap,n,r,a):(Oa(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===wh.MERGE){var u=e;i=u.source.fromUser?this.applyUserMerge_(t,u.path,u.children,n,r,a):(Oa(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===wh.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!==wh.LISTEN_COMPLETE)throw Pa("Unknown operation type: "+e.type);i=this.listenComplete_(t,e.path,n,a)}var h=a.getChanges();return $h.maybeAddValueEvent_(t,i,h),new Xh(i,h)},$h.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(qh.valueChange(e.getCompleteEventSnap()))}},$h.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(Oa(t.getServerCache().isFullyInitialized(),"If change path is empty, we must have complete server data"),t.getServerCache().isFiltered()){var u=t.getCompleteServerSnap(),c=u instanceof Hc?u:Hc.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){Oa(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 g=n.calcEventCacheAfterServerOverwrite(e,o.getNode(),s);m=null!=g?o.getNode().getImmediateChild(f).updateChild(y,g):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())},$h.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,zh,null)}var d=t.updateServerSnap(s,u.isFullyInitialized()||e.isEmpty(),c.filtersNodes()),y=new Gh(r,d,i);return this.generateEventCacheAfterServerEvent_(d,e,r,y,a)},$h.prototype.applyUserOverwrite_=function(t,e,n,r,i,o){var a,s,u=t.getEventCache(),c=new Gh(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):Hc.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},$h.cacheHasChild_=function(t,e){return t.getEventCache().isCompleteForChild(e)},$h.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);$h.cacheHasChild_(r,n.getFront())&&(c=u.applyUserOverwrite_(c,n,e,o,a,s))}),t.foreach(function(t,e){var n=i.child(t);$h.cacheHasChild_(r,n.getFront())||(c=u.applyUserOverwrite_(c,n,e,o,a,s))}),c},$h.prototype.applyMerge_=function(n,t){return t.foreach(function(t,e){n=n.updateChild(t,e)}),n},$h.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:Ah.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 Cu(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 Cu(t),i,a,s,u,c)}}),l},$h.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=Ah.Empty;return s.getNode().forEachChild(yc,function(t,e){u=u.set(new Cu(t),e)}),this.applyServerMerge_(t,r,u,n,i,a,o)}return t}var c=Ah.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)},$h.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,zh,r)},$h.prototype.revertUserWrite_=function(t,e,n,r,i){var o;if(null!=n.shadowingWrite(e))return t;var a=new Gh(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();Oa(h instanceof Hc,"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,Hc.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(Cu.Empty),t.updateEventSnap(u,o,this.filter_.filtersNodes())},$h);function $h(t){this.filter_=t}var Zh=(tl.prototype.generateEventsForChanges=function(t,e,n){var r=this,i=[],o=[];return t.forEach(function(t){t.type===qh.CHILD_CHANGED&&r.index_.indexedValueChanged(t.oldSnap,t.snapshotNode)&&o.push(qh.childMovedChange(t.childName,t.snapshotNode))}),this.generateEventsForType_(i,qh.CHILD_REMOVED,t,n,e),this.generateEventsForType_(i,qh.CHILD_ADDED,t,n,e),this.generateEventsForType_(i,qh.CHILD_MOVED,o,n,e),this.generateEventsForType_(i,qh.CHILD_CHANGED,t,n,e),this.generateEventsForType_(i,qh.VALUE,t,n,e),i},tl.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_))})})},tl.prototype.materializeSingleChange_=function(t,e){return"value"===t.type||"child_removed"===t.type||(t.prevName=e.getPredecessorChildName(t.childName,t.snapshotNode,this.index_)),t},tl.prototype.compareChanges_=function(t,e){if(null==t.childName||null==e.childName)throw Pa("Should only compare child_ events.");var n=new ac(t.childName,t.snapshotNode),r=new ac(e.childName,e.snapshotNode);return this.index_.compare(n,r)},tl);function tl(t){this.query_=t,this.index_=this.query_.getQueryParams().getIndex()}var el,nl=(rl.prototype.getQuery=function(){return this.query_},rl.prototype.getServerCache=function(){return this.viewCache_.getServerCache().getNode()},rl.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},rl.prototype.isEmpty=function(){return 0===this.eventRegistrations_.length},rl.prototype.addEventRegistration=function(t){this.eventRegistrations_.push(t)},rl.prototype.removeEventRegistration=function(t,n){var r=[];if(n){Oa(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},rl.prototype.applyOperation=function(t,e,n){t.type===wh.MERGE&&null!==t.source.queryId&&(Oa(this.viewCache_.getCompleteServerSnap(),"We should always have a full cache before handling merges"),Oa(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),Oa(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)},rl.prototype.getInitialEvents=function(t){var e=this.viewCache_.getEventCache(),n=[];return e.getNode().isLeafNode()||e.getNode().forEachChild(Ic,function(t,e){n.push(qh.childAddedChange(t,e))}),e.isFullyInitialized()&&n.push(qh.valueChange(e.getNode())),this.generateEventsForChanges_(n,e.getNode(),t)},rl.prototype.generateEventsForChanges_=function(t,e,n){var r=n?[n]:this.eventRegistrations_;return this.eventGenerator_.generateEventsForChanges(t,e,r)},rl);function rl(t,e){this.query_=t,this.eventRegistrations_=[];var n=this.query_.getQueryParams(),r=new jh(n.getIndex()),i=n.getNodeFilter();this.processor_=new Jh(i);var o=e.getServerCache(),a=e.getEventCache(),s=r.updateFullNode(Hc.EMPTY_NODE,o.getNode(),null),u=i.updateFullNode(Hc.EMPTY_NODE,a.getNode(),null),c=new Lh(s,o.isFullyInitialized(),r.filtersNodes()),h=new Lh(u,a.isFullyInitialized(),i.filtersNodes());this.viewCache_=new Uh(h,c),this.eventGenerator_=new Zh(this.query_)}var il=(Object.defineProperty(ol,"__referenceConstructor",{get:function(){return Oa(el,"Reference.ts has not been loaded"),el},set:function(t){Oa(!el,"__referenceConstructor has already been defined"),el=t},enumerable:!0,configurable:!0}),ol.prototype.isEmpty=function(){return 0===this.views.size},ol.prototype.applyOperation=function(t,e,n){var r,i,o=t.source.queryId;if(null!==o){var a=this.views.get(o);return Oa(null!=a,"SyncTree gave us an op for an invalid query."),a.applyOperation(t,e,n)}var s=[];try{for(var u=Ia(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},ol.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 Hc?n.calcCompleteEventChildren(r):Hc.EMPTY_NODE,!1);var c=new Uh(new Lh(s,u,!1),new Lh(r,i,!1));a=new nl(t,c),this.views.set(o,a)}return a.addEventRegistration(e),a.getInitialEvents(e)},ol.prototype.removeEventRegistration=function(t,e,n){var r,i,o=t.queryIdentifier(),a=[],s=[],u=this.hasCompleteView();if("default"===o)try{for(var c=Ia(this.views.entries()),h=c.next();!h.done;h=c.next()){var l=Ca(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 ol.__referenceConstructor(t.repo,t.path)),{removed:a,events:s}},ol.prototype.getQueryViews=function(){var e,t,n=[];try{for(var r=Ia(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},ol.prototype.getCompleteServerCache=function(t){var e,n,r=null;try{for(var i=Ia(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},ol.prototype.viewForQuery=function(t){if(t.getQueryParams().loadsAllData())return this.getCompleteView();var e=t.queryIdentifier();return this.views.get(e)},ol.prototype.viewExistsForQuery=function(t){return null!=this.viewForQuery(t)},ol.prototype.hasCompleteView=function(){return null!=this.getCompleteView()},ol.prototype.getCompleteView=function(){var e,t;try{for(var n=Ia(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},ol);function ol(){this.views=new Map}var al=(sl.prototype.addWrite=function(t,e){if(t.isEmpty())return new sl(new Ah(e));var n=this.writeTree_.findRootMostValueAndPath(t);if(null!=n){var r=n.path,i=n.value,o=Cu.relativePath(r,t);return i=i.updateChild(o,e),new sl(this.writeTree_.set(r,i))}var a=new Ah(e);return new sl(this.writeTree_.setTree(t,a))},sl.prototype.addWrites=function(n,t){var r=this;return wu(t,function(t,e){r=r.addWrite(n.child(t),e)}),r},sl.prototype.removeWrite=function(t){return t.isEmpty()?sl.Empty:new sl(this.writeTree_.setTree(t,Ah.Empty))},sl.prototype.hasCompleteWrite=function(t){return null!=this.getCompleteNode(t)},sl.prototype.getCompleteNode=function(t){var e=this.writeTree_.findRootMostValueAndPath(t);return null!=e?this.writeTree_.get(e.path).getChild(Cu.relativePath(e.path,t)):null},sl.prototype.getCompleteChildren=function(){var n=[],t=this.writeTree_.value;return null!=t?t.isLeafNode()||t.forEachChild(Ic,function(t,e){n.push(new ac(t,e))}):this.writeTree_.children.inorderTraversal(function(t,e){null!=e.value&&n.push(new ac(t,e.value))}),n},sl.prototype.childCompoundWrite=function(t){if(t.isEmpty())return this;var e=this.getCompleteNode(t);return new sl(null!=e?new Ah(e):this.writeTree_.subtree(t))},sl.prototype.isEmpty=function(){return this.writeTree_.isEmpty()},sl.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?(Oa(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}(Cu.Empty,this.writeTree_,t)},sl.Empty=new sl(new Ah(null)),sl);function sl(t){this.writeTree_=t}var ul=(cl.prototype.childWrites=function(t){return new hl(t,this)},cl.prototype.addOverwrite=function(t,e,n,r){Oa(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},cl.prototype.addMerge=function(t,e,n){Oa(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},cl.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},cl.prototype.removeWrite=function(e){var n=this,t=this.allWrites_.findIndex(function(t){return t.writeId===e});Oa(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):wu(r.children,function(t){n.visibleWrites_=n.visibleWrites_.removeWrite(r.path.child(t))}),!0)},cl.prototype.getCompleteWriteData=function(t){return this.visibleWrites_.getCompleteNode(t)},cl.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(Cu.Empty)){var o=cl.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||Hc.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(Cu.Empty)){var u=t||Hc.EMPTY_NODE;return s.apply(u)}return null},cl.prototype.calcCompleteEventChildren=function(t,e){var r=Hc.EMPTY_NODE,n=this.visibleWrites_.getCompleteNode(t);if(n)return n.isLeafNode()||n.forEachChild(Ic,function(t,e){r=r.updateImmediateChild(t,e)}),r;if(e){var i=this.visibleWrites_.childCompoundWrite(t);return e.forEachChild(Ic,function(t,e){var n=i.childCompoundWrite(new Cu(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},cl.prototype.calcEventCacheAfterServerOverwrite=function(t,e,n,r){Oa(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))},cl.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},cl.prototype.shadowingWrite=function(t){return this.visibleWrites_.getCompleteNode(t)},cl.prototype.calcIndexedSlice=function(t,e,n,r,i,o){var a,s=this.visibleWrites_.childCompoundWrite(t),u=s.getCompleteNode(Cu.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},cl.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},cl.prototype.resetTree_=function(){this.visibleWrites_=cl.layerTree_(this.allWrites_,cl.DefaultFilter_,Cu.Empty),0<this.allWrites_.length?this.lastWriteId_=this.allWrites_[this.allWrites_.length-1].writeId:this.lastWriteId_=-1},cl.DefaultFilter_=function(t){return t.visible},cl.layerTree_=function(t,e,n){for(var r=al.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=Cu.relativePath(n,a),r=r.addWrite(s,o.snap)):a.contains(n)&&(s=Cu.relativePath(a,n),r=r.addWrite(Cu.Empty,o.snap.getChild(s)));else{if(!o.children)throw Pa("WriteRecord should have .snap or .children");if(n.contains(a))s=Cu.relativePath(n,a),r=r.addWrites(s,o.children);else if(a.contains(n))if((s=Cu.relativePath(a,n)).isEmpty())r=r.addWrites(Cu.Empty,o.children);else{var u=Za(o.children,s.getFront());if(u){var c=u.getChild(s.popFront());r=r.addWrite(Cu.Empty,c)}}}}}return r},cl);function cl(){this.visibleWrites_=al.Empty,this.allWrites_=[],this.lastWriteId_=-1}var hl=(ll.prototype.calcCompleteEventCache=function(t,e,n){return this.writeTree_.calcCompleteEventCache(this.treePath_,t,e,n)},ll.prototype.calcCompleteEventChildren=function(t){return this.writeTree_.calcCompleteEventChildren(this.treePath_,t)},ll.prototype.calcEventCacheAfterServerOverwrite=function(t,e,n){return this.writeTree_.calcEventCacheAfterServerOverwrite(this.treePath_,t,e,n)},ll.prototype.shadowingWrite=function(t){return this.writeTree_.shadowingWrite(this.treePath_.child(t))},ll.prototype.calcIndexedSlice=function(t,e,n,r,i){return this.writeTree_.calcIndexedSlice(this.treePath_,t,e,n,r,i)},ll.prototype.calcCompleteChild=function(t,e){return this.writeTree_.calcCompleteChild(this.treePath_,t,e)},ll.prototype.child=function(t){return new ll(this.treePath_.child(t),this.writeTree_)},ll);function ll(t,e){this.treePath_=t,this.writeTree_=e}var pl=(dl.prototype.applyUserOverwrite=function(t,e,n,r){return this.pendingWriteTree_.addOverwrite(t,e,n,r),r?this.applyOperationToSyncPoints_(new Oh(Th.User,t,e)):[]},dl.prototype.applyUserMerge=function(t,e,n){this.pendingWriteTree_.addMerge(t,e,n);var r=Ah.fromObject(e);return this.applyOperationToSyncPoints_(new xh(Th.User,t,r))},dl.prototype.ackUserWrite=function(t,e){void 0===e&&(e=!1);var n=this.pendingWriteTree_.getWrite(t);if(this.pendingWriteTree_.removeWrite(t)){var r=Ah.Empty;return null!=n.snap?r=r.set(Cu.Empty,!0):wu(n.children,function(t,e){r=r.set(new Cu(t),e)}),this.applyOperationToSyncPoints_(new Ch(n.path,r,e))}return[]},dl.prototype.applyServerOverwrite=function(t,e){return this.applyOperationToSyncPoints_(new Oh(Th.Server,t,e))},dl.prototype.applyServerMerge=function(t,e){var n=Ah.fromObject(e);return this.applyOperationToSyncPoints_(new xh(Th.Server,t,n))},dl.prototype.applyListenComplete=function(t){return this.applyOperationToSyncPoints_(new kh(Th.Server,t))},dl.prototype.applyTaggedQueryOverwrite=function(t,e,n){var r=this.queryKeyForTag_(n);if(null==r)return[];var i=dl.parseQueryKey_(r),o=i.path,a=i.queryId,s=Cu.relativePath(o,t),u=new Oh(Th.forServerTaggedQuery(a),s,e);return this.applyTaggedOperation_(o,u)},dl.prototype.applyTaggedQueryMerge=function(t,e,n){var r=this.queryKeyForTag_(n);if(r){var i=dl.parseQueryKey_(r),o=i.path,a=i.queryId,s=Cu.relativePath(o,t),u=Ah.fromObject(e),c=new xh(Th.forServerTaggedQuery(a),s,u);return this.applyTaggedOperation_(o,c)}return[]},dl.prototype.applyTaggedListenComplete=function(t,e){var n=this.queryKeyForTag_(e);if(n){var r=dl.parseQueryKey_(n),i=r.path,o=r.queryId,a=Cu.relativePath(i,t),s=new kh(Th.forServerTaggedQuery(o),a);return this.applyTaggedOperation_(i,s)}return[]},dl.prototype.addEventRegistration=function(t,e){var r=t.path,i=null,o=!1;this.syncPointTree_.foreachOnPath(r,function(t,e){var n=Cu.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(Cu.Empty)):(a=new il,this.syncPointTree_=this.syncPointTree_.set(r,a)),null!=i?n=!0:(n=!1,i=Hc.EMPTY_NODE,this.syncPointTree_.subtree(r).foreachChild(function(t,e){var n=e.getCompleteServerCache(Cu.Empty);n&&(i=i.updateImmediateChild(t,n))}));var s=a.viewExistsForQuery(t);if(!s&&!t.getQueryParams().loadsAllData()){var u=dl.makeQueryKey_(t);Oa(!this.queryToTagMap.has(u),"View does not exist, but we have a tag");var c=dl.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},dl.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(dl.queryForListening_(y),this.tagForQuery_(y),m.hashFn,m.onComplete)}}!h&&0<u.length&&!n&&(c?this.listenProvider_.stopListening(dl.queryForListening_(t),null):u.forEach(function(t){var e=r.queryToTagMap.get(dl.makeQueryKey_(t));r.listenProvider_.stopListening(dl.queryForListening_(t),e)})),this.removeTags_(u)}return a},dl.prototype.calcCompleteEventCache=function(i,t){var e=this.pendingWriteTree_,n=this.syncPointTree_.findOnPath(i,function(t,e){var n=Cu.relativePath(t,i),r=e.getCompleteServerCache(n);if(r)return r});return e.calcCompleteEventCache(i,n,t,!0)},dl.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()),wu(n,function(t,e){r=r.concat(e)}),r})},dl.prototype.removeTags_=function(t){for(var e=0;e<t.length;++e){var n=t[e];if(!n.getQueryParams().loadsAllData()){var r=dl.makeQueryKey_(n),i=this.queryToTagMap.get(r);this.queryToTagMap.delete(r),this.tagToQueryMap.delete(i)}}},dl.queryForListening_=function(t){return t.getQueryParams().loadsAllData()&&!t.getQueryParams().isDefault()?t.getRef():t},dl.prototype.setupListener_=function(t,e){var n=t.path,r=this.tagForQuery_(t),i=this.createListenerForView_(e),o=this.listenProvider_.startListening(dl.queryForListening_(t),r,i.hashFn,i.onComplete),a=this.syncPointTree_.subtree(n);if(r)Oa(!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()}))),wu(n,function(t,e){r=r.concat(e)}),r}),u=0;u<s.length;++u){var c=s[u];this.listenProvider_.stopListening(dl.queryForListening_(c),this.tagForQuery_(c))}return o},dl.prototype.createListenerForView_=function(t){var n=this,r=t.getQuery(),i=this.tagForQuery_(r);return{hashFn:function(){return(t.getServerCache()||Hc.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)}}},dl.makeQueryKey_=function(t){return t.path.toString()+"$"+t.queryIdentifier()},dl.parseQueryKey_=function(t){var e=t.indexOf("$");return Oa(-1!==e&&e<t.length-1,"Bad queryKey."),{queryId:t.substr(e+1),path:new Cu(t.substr(0,e))}},dl.prototype.queryKeyForTag_=function(t){return this.tagToQueryMap.get(t)},dl.prototype.tagForQuery_=function(t){var e=dl.makeQueryKey_(t);return this.queryToTagMap.get(e)},dl.getNextQueryTag_=function(){return dl.nextQueryTag_++},dl.prototype.applyTaggedOperation_=function(t,e){var n=this.syncPointTree_.get(t);Oa(n,"Missing sync point for query tag that we're tracking");var r=this.pendingWriteTree_.childWrites(t);return n.applyOperation(e,r,null)},dl.prototype.applyOperationToSyncPoints_=function(t){return this.applyOperationHelper_(t,this.syncPointTree_,null,this.pendingWriteTree_.childWrites(Cu.Empty))},dl.prototype.applyOperationHelper_=function(t,e,n,r){if(t.path.isEmpty())return this.applyOperationDescendantsHelper_(t,e,n,r);var i=e.get(Cu.Empty);null==n&&null!=i&&(n=i.getCompleteServerCache(Cu.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},dl.prototype.applyOperationDescendantsHelper_=function(o,t,a,s){var u=this,e=t.get(Cu.Empty);null==a&&null!=e&&(a=e.getCompleteServerCache(Cu.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},dl.nextQueryTag_=1,dl);function dl(t){this.listenProvider_=t,this.syncPointTree_=Ah.Empty,this.pendingWriteTree_=new ul,this.tagToQueryMap=new Map,this.queryToTagMap=new Map}var yl=(ml.prototype.getNode=function(t){return this.rootNode_.getChild(t)},ml.prototype.updateSnapshot=function(t,e){this.rootNode_=this.rootNode_.updateChild(t,e)},ml);function ml(){this.rootNode_=Hc.EMPTY_NODE}var gl=(vl.prototype.getToken=function(t){return this.auth_?this.auth_.getToken(t).catch(function(t){return t&&"auth/token-not-initialized"===t.code?(Zs("Got auth/token-not-initialized error. Treating as null token."),null):Promise.reject(t)}):Promise.resolve(null)},vl.prototype.addTokenChangeListener=function(e){this.auth_?this.auth_.addAuthTokenListener(e):(setTimeout(function(){return e(null)},0),this.authProvider_.get().then(function(t){return t.addAuthTokenListener(e)}))},vl.prototype.removeTokenChangeListener=function(e){this.authProvider_.get().then(function(t){return t.removeAuthTokenListener(e)})},vl.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/.',ru(t)},vl);function vl(t,e){var n=this;this.app_=t,this.authProvider_=e,this.auth_=null,this.auth_=e.getImmediate({optional:!0}),this.auth_||e.get().then(function(t){return n.auth_=t})}var bl=(wl.prototype.incrementCounter=function(t,e){void 0===e&&(e=1),$a(this.counters_,t)||(this.counters_[t]=0),this.counters_[t]+=e},wl.prototype.get=function(){return Ma(this.counters_)},wl);function wl(){this.counters_={}}var _l=(El.getCollection=function(t){var e=t.toString();return this.collections_[e]||(this.collections_[e]=new bl),this.collections_[e]},El.getOrCreateReporter=function(t,e){var n=t.toString();return this.reporters_[n]||(this.reporters_[n]=e()),this.reporters_[n]},El.collections_={},El.reporters_={},El);function El(){}var Tl=(Sl.prototype.get=function(){var t=this.collection_.get(),n=Ea({},t);return this.last_&&wu(this.last_,function(t,e){n[t]=n[t]-e}),this.last_=t,n},Sl);function Sl(t){this.collection_=t,this.last_=null}var Il=(Cl.prototype.includeStat=function(t){this.statsToReport_[t]=!0},Cl.prototype.reportStats_=function(){var n=this,t=this.statsListener_.get(),r={},i=!1;wu(t,function(t,e){0<e&&$a(n.statsToReport_,t)&&(r[t]=e,i=!0)}),i&&this.server_.reportStats(r),Tu(this.reportStats_.bind(this),Math.floor(2*Math.random()*3e5))},Cl);function Cl(t,e){this.server_=e,this.statsToReport_={},this.statsListener_=new Tl(t);var n=1e4+2e4*Math.random();Tu(this.reportStats_.bind(this),Math.floor(n))}var Nl=(Al.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 Dl(i)),e.add(r)}e&&this.eventLists_.push(e)},Al.prototype.raiseEventsAtPath=function(e,t){this.queueEvents(t),this.raiseQueuedEventsMatchingPredicate_(function(t){return t.equals(e)})},Al.prototype.raiseEventsForChangedPath=function(e,t){this.queueEvents(t),this.raiseQueuedEventsMatchingPredicate_(function(t){return t.contains(e)||e.contains(t)})},Al.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_--},Al);function Al(){this.eventLists_=[],this.recursionDepth_=0}var Dl=(kl.prototype.add=function(t){this.events_.push(t)},kl.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();du&&Zs("event: "+e.toString()),Eu(n)}}},kl.prototype.getPath=function(){return this.path_},kl);function kl(t){this.path_=t,this.events_=[]}var Rl=(Ol.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=Na(this.listeners_[t]),i=0;i<r.length;i++)r[i].callback.apply(r[i].context,e)},Ol.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)},Ol.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)},Ol.prototype.validateEventType_=function(e){Oa(this.allowedEvents_.find(function(t){return t===e}),"Unknown event: "+e)},Ol);function Ol(t){this.allowedEvents_=t,this.listeners_={},Oa(Array.isArray(t)&&0<t.length,"Requires a non-empty array")}var Pl,xl=(_a(Ml,Pl=Rl),Ml.getInstance=function(){return new Ml},Ml.prototype.getInitialEvent=function(t){return Oa("visible"===t,"Unknown event type: "+t),[this.visible_]},Ml);function Ml(){var e,t,n=Pl.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 Ll,Fl=(_a(Ul,Ll=Rl),Ul.getInstance=function(){return new Ul},Ul.prototype.getInitialEvent=function(t){return Oa("online"===t,"Unknown event type: "+t),[this.online_]},Ul.prototype.currentlyOnline=function(){return this.online_},Ul);function Ul(){var t=Ll.call(this,["online"])||this;return t.online_=!0,"undefined"==typeof window||void 0===window.addEventListener||qa()||(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 Vl=(ql.prototype.closeAfter=function(t,e){this.closeAfterResponse=t,this.onClose=e,this.closeAfterResponse<this.currentResponseNum&&(this.onClose(),this.onClose=null)},ql.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]&&Eu(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(););},ql);function ql(t){this.onMessage_=t,this.pendingResponses=[],this.currentResponseNum=0,this.closeAfterResponse=-1,this.onClose=null}var Bl=(jl.prototype.open=function(t,e){var a=this;this.curSegmentNum=0,this.onDisconnect_=e,this.myPacketOrderer=new Vl(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 Wl(function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=Ca(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=Ca(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(ku)&&(t.r="f");var e=a.urlFn(t);a.log_("Connecting via long-poll to "+e),a.scriptTagHolder.addTag(e,function(){})}})},jl.prototype.start=function(){this.scriptTagHolder.startLongPoll(this.id,this.password),this.addDisconnectPingFrame(this.id,this.password)},jl.forceAllow=function(){jl.forceAllow_=!0},jl.forceDisallow=function(){jl.forceDisallow_=!0},jl.isAvailable=function(){return!!jl.forceAllow_||!(jl.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)},jl.prototype.markConnectionHealthy=function(){},jl.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)},jl.prototype.onClosed_=function(){this.isClosed_||(this.log_("Longpoll is closing itself"),this.shutdown_(),this.onDisconnect_&&(this.onDisconnect_(this.everConnected_),this.onDisconnect_=null))},jl.prototype.close=function(){this.isClosed_||(this.log_("Longpoll is being closed."),this.shutdown_())},jl.prototype.send=function(t){var e=Xa(t);this.bytesSent+=e.length,this.stats_.incrementCounter("bytes_sent",e.length);for(var n=function(t){var e=Da(t);return xa.encodeByteArray(e,!0)}(e),r=su(n,1840),i=0;i<r.length;i++)this.scriptTagHolder.enqueueSegment(this.curSegmentNum,r.length,r[i]),this.curSegmentNum++},jl.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)},jl.prototype.incrementIncomingBytes_=function(t){var e=Xa(t).length;this.bytesReceived+=e,this.stats_.incrementCounter("bytes_received",e)},jl);function jl(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_=tu(t),this.stats_=_l.getCollection(e),this.urlFn=function(t){return e.connectionURL(Ou,t)}}var Wl=(Kl.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||Zs("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},Kl.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())},Kl.prototype.startLongPoll=function(t,e){for(this.myID=t,this.myPW=e,this.alive=!0;this.newRequest_(););},Kl.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},Kl.prototype.enqueueSegment=function(t,e,n){this.pendingSegs.push({seg:t,ts:e,d:n}),this.alive&&this.newRequest_()},Kl.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()})},Kl.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(){Zs("Long-poll script failed to load: "+t),r.sendNewPolls=!1,r.close()},r.myIFrame.doc.body.appendChild(e)}catch(t){}},Math.floor(1))},Kl);function Kl(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=fu(),window["pLPCommand"+this.uniqueCallbackIdentifier]=t,window["pRTLPCB"+this.uniqueCallbackIdentifier]=e,this.myIFrame=Kl.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){Zs("frame writing exception"),t.stack&&Zs(t.stack),Zs(t)}}var Ql="";var Hl=null;"undefined"!=typeof MozWebSocket?Hl=MozWebSocket:"undefined"!=typeof WebSocket&&(Hl=WebSocket);var zl=(Gl.connectionURL_=function(t,e,n){var r={v:"5"};return"undefined"!=typeof location&&location.href&&-1!==location.href.indexOf(ku)&&(r.r="f"),e&&(r.s=e),n&&(r.ls=n),t.connectionURL(Ru,r)},Gl.prototype.open=function(t,e){var n=this;this.onDisconnect=e,this.onMessage=t,this.log_("Websocket connecting to "+this.connURL),this.everConnected_=!1,cu.set("previous_websocket_failure",!0);try{if(ja()){var r=Ra.NODE_ADMIN?"AdminNode":"Node",i={headers:{"User-Agent":"Firebase/5/"+Ql+"/"+process.platform+"/"+r}},o=process.env,a=0===this.connURL.indexOf("wss://")?o.HTTPS_PROXY||o.https_proxy:o.HTTP_PROXY||o.http_proxy;a&&(i.proxy={origin:a}),this.mySock=new Hl(this.connURL,[],i)}else this.mySock=new Hl(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_()}},Gl.prototype.start=function(){},Gl.forceDisallow=function(){Gl.forceDisallow_=!0},Gl.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!==Hl&&!Gl.forceDisallow_},Gl.previouslyFailed=function(){return cu.isInMemoryStorage||!0===cu.get("previous_websocket_failure")},Gl.prototype.markConnectionHealthy=function(){cu.remove("previous_websocket_failure")},Gl.prototype.appendFrame_=function(t){if(this.frames.push(t),this.frames.length===this.totalFrames){var e=this.frames.join("");this.frames=null;var n=Ya(e);this.onMessage(n)}},Gl.prototype.handleNewFrameCount_=function(t){this.totalFrames=t,this.frames=[]},Gl.prototype.extractFrameCount_=function(t){if(Oa(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},Gl.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)}}},Gl.prototype.send=function(t){this.resetKeepAlive();var e=Xa(t);this.bytesSent+=e.length,this.stats_.incrementCounter("bytes_sent",e.length);var n=su(e,16384);1<n.length&&this.sendString_(String(n.length));for(var r=0;r<n.length;r++)this.sendString_(n[r])},Gl.prototype.shutdown_=function(){this.isClosed_=!0,this.keepaliveTimer&&(clearInterval(this.keepaliveTimer),this.keepaliveTimer=null),this.mySock&&(this.mySock.close(),this.mySock=null)},Gl.prototype.onClosed_=function(){this.isClosed_||(this.log_("WebSocket is closing itself"),this.shutdown_(),this.onDisconnect&&(this.onDisconnect(this.everConnected_),this.onDisconnect=null))},Gl.prototype.close=function(){this.isClosed_||(this.log_("WebSocket is being closed"),this.shutdown_())},Gl.prototype.resetKeepAlive=function(){var t=this;clearInterval(this.keepaliveTimer),this.keepaliveTimer=setInterval(function(){t.mySock&&t.sendString_("0"),t.resetKeepAlive()},Math.floor(45e3))},Gl.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)}},Gl.responsesRequiredToBeHealthy=2,Gl.healthyTimeout=3e4,Gl);function Gl(t,e,n,r){this.connId=t,this.keepaliveTimer=null,this.frames=null,this.totalFrames=0,this.bytesSent=0,this.bytesReceived=0,this.log_=tu(this.connId),this.stats_=_l.getCollection(e),this.connURL=Gl.connectionURL_(e,n,r)}var Yl=(Object.defineProperty(Xl,"ALL_TRANSPORTS",{get:function(){return[Bl,zl]},enumerable:!0,configurable:!0}),Xl.prototype.initTransports_=function(t){var e,n,r=zl&&zl.isAvailable(),i=r&&!zl.previouslyFailed();if(t.webSocketOnly&&(r||ru("wss:// URL used, but browser isn't known to support websockets. Trying anyway."),i=!0),i)this.transports_=[zl];else{var o=this.transports_=[];try{for(var a=Ia(Xl.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}}}},Xl.prototype.initialTransport=function(){if(0<this.transports_.length)return this.transports_[0];throw new Error("No transports available")},Xl.prototype.upgradeTransport=function(){return 1<this.transports_.length?this.transports_[1]:null},Xl);function Xl(t){this.initTransports_(t)}var Jl=($l.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_=Tu(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)))},$l.prototype.nextTransportId_=function(){return"c:"+this.id+":"+this.connectionCount++},$l.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")}},$l.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"))}},$l.prototype.sendRequest=function(t){var e={t:"d",d:t};this.sendData_(e)},$l.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)},$l.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_())}},$l.prototype.onSecondaryMessageReceived_=function(t){var e=au("t",t),n=au("d",t);if("c"===e)this.onSecondaryControl_(n);else{if("d"!==e)throw new Error("Unknown protocol layer: "+e);this.pendingDataMessages.push(n)}},$l.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:{}}}))},$l.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()},$l.prototype.onPrimaryMessageReceived_=function(t){var e=au("t",t),n=au("d",t);"c"===e?this.onControl_(n):"d"===e&&this.onDataMessage_(n)},$l.prototype.onDataMessage_=function(t){this.onPrimaryResponse_(),this.onMessage_(t)},$l.prototype.onPrimaryResponse_=function(){this.isHealthy_||(this.primaryResponsesRequired_--,this.primaryResponsesRequired_<=0&&(this.log_("Primary connection is healthy."),this.isHealthy_=!0,this.conn_.markConnectionHealthy()))},$l.prototype.onControl_=function(t){var e=au("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?eu("Server Error: "+n):"o"===e?(this.log_("got pong on primary."),this.onPrimaryResponse_(),this.sendPingOnPrimaryIfNecessary_()):eu("Unknown control packet command: "+e)}},$l.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&&ru("Protocol version mismatch detected"),this.tryStartUpgrade_())},$l.prototype.tryStartUpgrade_=function(){var t=this.transportManager_.upgradeTransport();t&&this.startUpgrade_(t)},$l.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),Tu(function(){e.secondaryConn_&&(e.log_("Timed out trying to upgrade."),e.secondaryConn_.close())},Math.floor(6e4))},$l.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_())},$l.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):Tu(function(){n.sendPingOnPrimaryIfNecessary_()},Math.floor(5e3))},$l.prototype.sendPingOnPrimaryIfNecessary_=function(){this.isHealthy_||1!==this.state_||(this.log_("sending ping on primary."),this.sendData_({t:"c",d:{t:"p",d:{}}}))},$l.prototype.onSecondaryConnectionLost_=function(){var t=this.secondaryConn_;this.secondaryConn_=null,this.tx_!==t&&this.rx_!==t||this.close()},$l.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()&&(cu.remove("host:"+this.repoInfo_.host),this.repoInfo_.internalHost=this.repoInfo_.host)),this.close()},$l.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()},$l.prototype.sendData_=function(t){if(1!==this.state_)throw"Connection is not connected";this.tx_.send(t)},$l.prototype.close=function(){2!==this.state_&&(this.log_("Closing realtime connection."),this.state_=2,this.closeConnections_(),this.onDisconnect_&&(this.onDisconnect_(),this.onDisconnect_=null))},$l.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)},$l);function $l(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_=tu("c:"+this.id+":"),this.transportManager_=new Yl(e),this.log_("Connection created"),this.start_()}var Zl=(tf.prototype.put=function(t,e,n,r){},tf.prototype.merge=function(t,e,n,r){},tf.prototype.refreshAuthToken=function(t){},tf.prototype.onDisconnectPut=function(t,e,n){},tf.prototype.onDisconnectMerge=function(t,e,n){},tf.prototype.onDisconnectCancel=function(t,e){},tf.prototype.reportStats=function(t){},tf);function tf(){}var ef,nf=(_a(rf,ef=Zl),rf.prototype.sendRequest=function(t,e,n){var r=++this.requestNumber_,i={r:r,a:t,b:e};this.log_(Xa(i)),Oa(this.connected_,"sendRequest call when we're not connected not allowed."),this.realtime_.sendRequest(i),n&&(this.requestCBHash_[r]=n)},rf.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),Oa(t.getQueryParams().isDefault()||!t.getQueryParams().loadsAllData(),"listen() called for non-default but complete query"),Oa(!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)},rf.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;rf.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))})},rf.warnOnListenWarnings_=function(t,e){if(t&&"object"==typeof t&&$a(t,"w")){var n=Za(t,"w");if(Array.isArray(n)&&~n.indexOf("no_index")){var r='".indexOn": "'+e.getQueryParams().getIndex().toString()+'"',i=e.path.toString();ru("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.")}}},rf.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)},rf.prototype.reduceReconnectDelayIfAdminCredential_=function(t){(t&&40===t.length||function(t){var e=Ja(t).claims;return"object"==typeof e&&!0===e.admin}(t))&&(this.log_("Admin auth credential detected. Reducing max reconnect time."),this.maxReconnectDelay_=3e4)},rf.prototype.tryAuth=function(){var r=this;if(this.connected_&&this.authToken_){var i=this.authToken_,t=function(t){var e=Ja(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))})}},rf.prototype.unlisten=function(t,e){var n=t.path.toString(),r=t.queryIdentifier();this.log_("Unlisten called for "+n+" "+r),Oa(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)},rf.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)},rf.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})},rf.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})},rf.prototype.onDisconnectCancel=function(t,e){this.connected_?this.sendOnDisconnect_("oc",t,null,e):this.onDisconnectRequestQueue_.push({pathString:t,action:"oc",data:null,onComplete:e})},rf.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))})},rf.prototype.put=function(t,e,n,r){this.putInternal("p",t,e,n,r)},rf.prototype.merge=function(t,e,n,r){this.putInternal("m",t,e,n,r)},rf.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)},rf.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)})},rf.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)}})}},rf.prototype.onDataMessage_=function(t){if("r"in t){this.log_("from server: "+Xa(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)}},rf.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):eu("Unrecognized action received from server: "+Xa(t)+"\nAre you using the latest client?")},rf.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)},rf.prototype.scheduleConnect_=function(t){var e=this;Oa(!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))},rf.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},rf.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())},rf.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)},rf.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+":"+rf.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){Oa(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?Zs("getToken() completed but was canceled"):(Zs("getToken() completed. Creating connection."),o.authToken_=t&&t.accessToken,u=new Jl(i,o.repoInfo_,e,n,r,function(t){ru(t+" ("+o.repoInfo_.toString()+")"),o.interrupt("server_kill")},a))}).then(null,function(t){o.log_("Failed to get token: "+t),s||c()})}},rf.prototype.interrupt=function(t){Zs("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_())},rf.prototype.resume=function(t){Zs("Resuming connection for reason: "+t),delete this.interruptReasons_[t],ts(this.interruptReasons_)&&(this.reconnectDelay_=1e3,this.realtime_||this.scheduleConnect_(0))},rf.prototype.handleTimestamp_=function(t){var e=t-(new Date).getTime();this.onServerInfoUpdate_({serverTimeOffset:e})},rf.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_=[])},rf.prototype.onListenRevoked_=function(t,e){var n;n=e?e.map(function(t){return bu(t)}).join("$"):"default";var r=this.removeListen_(t,n);r&&r.onComplete&&r.onComplete("permission_denied")},rf.prototype.removeListen_=function(t,e){var n,r=new Cu(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},rf.prototype.onAuthRevoked_=function(t,e){Zs("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()))},rf.prototype.onSecurityDebugPacket_=function(t){this.securityDebugCallback_?this.securityDebugCallback_(t):"msg"in t&&console.log("FIREBASE: "+t.msg.replace("\n","\nFIREBASE: "))},rf.prototype.restoreState_=function(){var e,t,n,r;this.tryAuth();try{for(var i=Ia(this.listens.values()),o=i.next();!o.done;o=i.next()){var a=o.value;try{for(var s=(n=void 0,Ia(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)}},rf.prototype.sendConnectStats_=function(){var t={};t["sdk.js."+Ql.replace(/\./g,"-")]=1,qa()?t["framework.cordova"]=1:Ba()&&(t["framework.reactnative"]=1),this.reportStats(t)},rf.prototype.shouldReconnect_=function(){var t=Fl.getInstance().currentlyOnline();return ts(this.interruptReasons_)&&t},rf.nextPersistentConnectionId_=0,rf.nextConnectionId_=0,rf);function rf(t,e,n,r,i,o){var a=ef.call(this)||this;if(a.repoInfo_=t,a.onDataUpdate_=e,a.onConnectStatus_=n,a.onServerInfoUpdate_=r,a.authTokenProvider_=i,a.authOverride_=o,a.id=rf.nextPersistentConnectionId_++,a.log_=tu("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&&!ja())throw new Error("Auth override specified in options, but not supported on non Node.js platforms");return a.scheduleConnect_(0),xl.getInstance().on("visible",a.onVisible_,a),-1===t.host.indexOf("fblocal")&&Fl.getInstance().on("online",a.onOnline_,a),a}var of,af=(_a(sf,of=Zl),sf.prototype.reportStats=function(t){throw new Error("Method not implemented.")},sf.getListenId_=function(t,e){return void 0!==e?"tag$"+e:(Oa(t.getQueryParams().isDefault(),"should have a tag if it's not a default query."),t.path.toString())},sf.prototype.listen=function(t,e,r,i){var o=this,a=t.path.toString();this.log_("Listen called for "+a+" "+t.queryIdentifier());var s=sf.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),Za(o.listens_,s)===u&&i(t?401===t?"permission_denied":"rest_error:"+t:"ok",null)})},sf.prototype.unlisten=function(t,e){var n=sf.getListenId_(t,e);delete this.listens_[n]},sf.prototype.refreshAuthToken=function(t){},sf.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=Ya(r.responseText)}catch(t){ru("Failed to parse JSON response for "+n+": "+r.responseText)}a(null,t)}else 401!==r.status&&404!==r.status&&ru("Got unsuccessful REST response for "+n+" Status: "+r.status),a(r.status);a=null}},r.open("GET",n,!0),r.send()})},sf);function sf(t,e,n){var r=of.call(this)||this;return r.repoInfo_=t,r.onDataUpdate_=e,r.authTokenProvider_=n,r.log_=tu("p:rest:"),r.listens_={},r}var uf="repo_interrupt",cf=(hf.prototype.toString=function(){return(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host},hf.prototype.name=function(){return this.repoInfo_.namespace},hf.prototype.serverTime=function(){var t=this.infoData_.getNode(new Cu(".info/serverTimeOffset")).val()||0;return(new Date).getTime()+t},hf.prototype.generateServerValues=function(){return function(t){return(t=t||{}).timestamp=t.timestamp||(new Date).getTime(),t}({timestamp:this.serverTime()})},hf.prototype.onDataUpdate_=function(t,e,n,r){this.dataUpdateCount++;var i=new Cu(t);e=this.interceptServerDataCallback_?this.interceptServerDataCallback_(t,e):e;var o=[];if(r)if(n){var a=es(e,function(t){return $c(t)});o=this.serverSyncTree_.applyTaggedQueryMerge(i,a,r)}else{var s=$c(e);o=this.serverSyncTree_.applyTaggedQueryOverwrite(i,s,r)}else if(n){var u=es(e,function(t){return $c(t)});o=this.serverSyncTree_.applyServerMerge(i,u)}else{var c=$c(e);o=this.serverSyncTree_.applyServerOverwrite(i,c)}var h=i;0<o.length&&(h=this.rerunTransactions_(i)),this.eventQueue_.raiseEventsForChangedPath(h,o)},hf.prototype.interceptServerData_=function(t){this.interceptServerDataCallback_=t},hf.prototype.onConnectStatus_=function(t){this.updateInfo_("connected",t),!1===t&&this.runOnDisconnectEvents_()},hf.prototype.onServerInfoUpdate_=function(t){var n=this;wu(t,function(t,e){n.updateInfo_(t,e)})},hf.prototype.updateInfo_=function(t,e){var n=new Cu("/.info/"+t),r=$c(e);this.infoData_.updateSnapshot(n,r);var i=this.infoSyncTree_.applyServerOverwrite(n,r);this.eventQueue_.raiseEventsForChangedPath(n,i)},hf.prototype.getNextWriteId_=function(){return this.nextWriteId_++},hf.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=$c(t,e),s=Eh(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||ru("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,[])},hf.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(wu(t,function(t,e){r=!1;var n=$c(e);u[t]=Eh(n,i)}),r)Zs("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||ru("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)}),wu(t,function(t){var e=s.abortTransactions_(o.child(t));s.rerunTransactions_(e)}),this.eventQueue_.raiseEventsForChangedPath(o,[])}},hf.prototype.runOnDisconnectEvents_=function(){var r=this;this.log_("onDisconnectEvents");var t=this.generateServerValues(),e=function(t,n){var r=new gh;return t.forEachTree(new Cu(""),function(t,e){r.remember(t,Eh(e,n))}),r}(this.onDisconnect_,t),i=[];e.forEachTree(Cu.Empty,function(t,e){i=i.concat(r.serverSyncTree_.applyServerOverwrite(t,e));var n=r.abortTransactions_(t);r.rerunTransactions_(n)}),this.onDisconnect_=new gh,this.eventQueue_.raiseEventsForChangedPath(Cu.Empty,i)},hf.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)})},hf.prototype.onDisconnectSet=function(n,t,r){var i=this,o=$c(t);this.server_.onDisconnectPut(n.toString(),o.val(!0),function(t,e){"ok"===t&&i.onDisconnect_.remember(n,o),i.callOnCompleteCallback(r,t,e)})},hf.prototype.onDisconnectSetWithPriority=function(n,t,e,r){var i=this,o=$c(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)})},hf.prototype.onDisconnectUpdate=function(r,n,i){var o=this;if(ts(n))return Zs("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&&wu(n,function(t,e){var n=$c(e);o.onDisconnect_.remember(r.child(t),n)}),o.callOnCompleteCallback(i,t,e)})},hf.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)},hf.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)},hf.prototype.interrupt=function(){this.persistentConnection_&&this.persistentConnection_.interrupt(uf)},hf.prototype.resume=function(){this.persistentConnection_&&this.persistentConnection_.resume(uf)},hf.prototype.stats=function(t){if(void 0===t&&(t=!1),"undefined"!=typeof console){var e;e=t?(this.statsListener_||(this.statsListener_=new Tl(this.stats_)),this.statsListener_.get()):this.stats_.get();var i=Object.keys(e).reduce(function(t,e){return Math.max(e.length,t)},0);wu(e,function(t,e){for(var n=t,r=t.length;r<i+2;r++)n+=" ";console.log(n+e)})}},hf.prototype.statsIncrementCounter=function(t){this.stats_.incrementCounter(t),this.statsReporter_.includeStat(t)},hf.prototype.log_=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="";this.persistentConnection_&&(n=this.persistentConnection_.id+":"),Zs.apply(void 0,Na([n],t))},hf.prototype.callOnCompleteCallback=function(r,i,o){r&&Eu(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(hf.prototype,"database",{get:function(){return this.__database||(this.__database=new Df(this))},enumerable:!0,configurable:!0}),hf);function hf(t,e,n,r){var a=this;this.repoInfo_=t,this.app=n,this.dataUpdateCount=0,this.statsListener_=null,this.eventQueue_=new Nl,this.nextWriteId_=1,this.interceptServerDataCallback_=null,this.onDisconnect_=new gh,this.persistentConnection_=null;var i=new gl(n,r);if(this.stats_=_l.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 af(this.repoInfo_,this.onDataUpdate_.bind(this),i),setTimeout(this.onConnectStatus_.bind(this,!0),0);else{var o=n.options.databaseAuthVariableOverride;if(null!=o){if("object"!=typeof o)throw new Error("Only objects are supported for option databaseAuthVariableOverride");try{Xa(o)}catch(t){throw new Error("Invalid authOverride provided: "+t)}}this.persistentConnection_=new nf(this.repoInfo_,this.onDataUpdate_.bind(this),this.onConnectStatus_.bind(this),this.onServerInfoUpdate_.bind(this),i,o),this.server_=this.persistentConnection_}i.addTokenChangeListener(function(t){a.server_.refreshAuthToken(t)}),this.statsReporter_=_l.getOrCreateReporter(t,function(){return new Il(a.stats_,a.server_)}),this.transactionsInit_(),this.infoData_=new yl,this.infoSyncTree_=new pl({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 pl({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 lf=(ff.prototype.getStartPost=function(){return this.startPost_},ff.prototype.getEndPost=function(){return this.endPost_},ff.prototype.matches=function(t){return this.index_.compare(this.getStartPost(),t)<=0&&this.index_.compare(t,this.getEndPost())<=0},ff.prototype.updateChild=function(t,e,n,r,i,o){return this.matches(new ac(e,n))||(n=Hc.EMPTY_NODE),this.indexedFilter_.updateChild(t,e,n,r,i,o)},ff.prototype.updateFullNode=function(t,e,n){e.isLeafNode()&&(e=Hc.EMPTY_NODE);var r=e.withIndex(this.index_);r=r.updatePriority(Hc.EMPTY_NODE);var i=this;return e.forEachChild(Ic,function(t,e){i.matches(new ac(t,e))||(r=r.updateImmediateChild(t,Hc.EMPTY_NODE))}),this.indexedFilter_.updateFullNode(t,r,n)},ff.prototype.updatePriority=function(t,e){return t},ff.prototype.filtersNodes=function(){return!0},ff.prototype.getIndexedFilter=function(){return this.indexedFilter_},ff.prototype.getIndex=function(){return this.index_},ff.getStartPost_=function(t){if(t.hasStart()){var e=t.getIndexStartName();return t.getIndex().makePost(t.getIndexStartValue(),e)}return t.getIndex().minPost()},ff.getEndPost_=function(t){if(t.hasEnd()){var e=t.getIndexEndName();return t.getIndex().makePost(t.getIndexEndValue(),e)}return t.getIndex().maxPost()},ff);function ff(t){this.indexedFilter_=new jh(t.getIndex()),this.index_=t.getIndex(),this.startPost_=ff.getStartPost_(t),this.endPost_=ff.getEndPost_(t)}var pf=(df.prototype.updateChild=function(t,e,n,r,i,o){return this.rangedFilter_.matches(new ac(e,n))||(n=Hc.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)},df.prototype.updateFullNode=function(t,e,n){var r;if(e.isLeafNode()||e.isEmpty())r=Hc.EMPTY_NODE.withIndex(this.index_);else if(2*this.limit_<e.numChildren()&&e.isIndexed(this.index_)){r=Hc.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(Hc.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,Hc.EMPTY_NODE)}return this.rangedFilter_.getIndexedFilter().updateFullNode(t,r,n)},df.prototype.updatePriority=function(t,e){return t},df.prototype.filtersNodes=function(){return!0},df.prototype.getIndexedFilter=function(){return this.rangedFilter_.getIndexedFilter()},df.prototype.getIndex=function(){return this.index_},df.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;Oa(s.numChildren()===this.limit_,"");var u=new ac(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(qh.childChangedChange(e,n,l)),s.updateImmediateChild(e,n);null!=i&&i.trackChildChange(qh.childRemovedChange(e,l));var d=s.updateImmediateChild(e,Hc.EMPTY_NODE);return null!=f&&this.rangedFilter_.matches(f)?(null!=i&&i.trackChildChange(qh.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(qh.childRemovedChange(c.name,c.node)),i.trackChildChange(qh.childAddedChange(e,n))),s.updateImmediateChild(e,n).updateImmediateChild(c.name,Hc.EMPTY_NODE)):t},df);function df(t){this.rangedFilter_=new lf(t),this.index_=t.getIndex(),this.limit_=t.getLimit(),this.reverse_=!t.isViewFromLeft()}var yf=(mf.prototype.hasStart=function(){return this.startSet_},mf.prototype.isViewFromLeft=function(){return""===this.viewFrom_?this.startSet_:this.viewFrom_===mf.WIRE_PROTOCOL_CONSTANTS_.VIEW_FROM_LEFT},mf.prototype.getIndexStartValue=function(){return Oa(this.startSet_,"Only valid if start has been set"),this.indexStartValue_},mf.prototype.getIndexStartName=function(){return Oa(this.startSet_,"Only valid if start has been set"),this.startNameSet_?this.indexStartName_:mu},mf.prototype.hasEnd=function(){return this.endSet_},mf.prototype.getIndexEndValue=function(){return Oa(this.endSet_,"Only valid if end has been set"),this.indexEndValue_},mf.prototype.getIndexEndName=function(){return Oa(this.endSet_,"Only valid if end has been set"),this.endNameSet_?this.indexEndName_:gu},mf.prototype.hasLimit=function(){return this.limitSet_},mf.prototype.hasAnchoredLimit=function(){return this.limitSet_&&""!==this.viewFrom_},mf.prototype.getLimit=function(){return Oa(this.limitSet_,"Only valid if limit has been set"),this.limit_},mf.prototype.getIndex=function(){return this.index_},mf.prototype.copy_=function(){var t=new mf;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},mf.prototype.limit=function(t){var e=this.copy_();return e.limitSet_=!0,e.limit_=t,e.viewFrom_="",e},mf.prototype.limitToFirst=function(t){var e=this.copy_();return e.limitSet_=!0,e.limit_=t,e.viewFrom_=mf.WIRE_PROTOCOL_CONSTANTS_.VIEW_FROM_LEFT,e},mf.prototype.limitToLast=function(t){var e=this.copy_();return e.limitSet_=!0,e.limit_=t,e.viewFrom_=mf.WIRE_PROTOCOL_CONSTANTS_.VIEW_FROM_RIGHT,e},mf.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},mf.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},mf.prototype.orderBy=function(t){var e=this.copy_();return e.index_=t,e},mf.prototype.getQueryObject=function(){var t=mf.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_!==Ic&&(e[t.INDEX]=this.index_.toString()),e},mf.prototype.loadsAllData=function(){return!(this.startSet_||this.endSet_||this.limitSet_)},mf.prototype.isDefault=function(){return this.loadsAllData()&&this.index_===Ic},mf.prototype.getNodeFilter=function(){return this.loadsAllData()?new jh(this.getIndex()):this.hasLimit()?new pf(this):new lf(this)},mf.prototype.toRestQueryStringParameters=function(){var t,e=mf.REST_QUERY_CONSTANTS_,n={};return this.isDefault()||(t=this.index_===Ic?e.PRIORITY_INDEX:this.index_===eh?e.VALUE_INDEX:this.index_===yc?e.KEY_INDEX:(Oa(this.index_ instanceof nh,"Unrecognized index type!"),this.index_.toString()),n[e.ORDER_BY]=Xa(t),this.startSet_&&(n[e.START_AT]=Xa(this.indexStartValue_),this.startNameSet_&&(n[e.START_AT]+=","+Xa(this.indexStartName_))),this.endSet_&&(n[e.END_AT]=Xa(this.indexEndValue_),this.endNameSet_&&(n[e.END_AT]+=","+Xa(this.indexEndName_))),this.limitSet_&&(this.isViewFromLeft()?n[e.LIMIT_TO_FIRST]=this.limit_:n[e.LIMIT_TO_LAST]=this.limit_)),n},mf.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"},mf.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"},mf.DEFAULT=new mf,mf);function mf(){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_=Ic}var gf,vf=(_a(bf,gf=yh),bf.prototype.getKey=function(){return us("Reference.key",0,0,arguments.length),this.path.isEmpty()?null:this.path.getBack()},bf.prototype.child=function(t){return us("Reference.child",1,1,arguments.length),"number"==typeof t?t=String(t):t instanceof Cu||(null===this.path.getFront()?function(t,e,n,r){n=n&&n.replace(/^\/*\.info(\/|$)/,"/"),Ku(t,e,n,r)}("Reference.child",1,t,!1):Ku("Reference.child",1,t,!1)),new bf(this.repo,this.path.child(t))},bf.prototype.getParent=function(){us("Reference.parent",0,0,arguments.length);var t=this.path.parent();return null===t?null:new bf(this.repo,t)},bf.prototype.getRoot=function(){us("Reference.root",0,0,arguments.length);for(var t=this;null!==t.getParent();)t=t.getParent();return t},bf.prototype.databaseProp=function(){return this.repo.database},bf.prototype.set=function(t,e){us("Reference.set",1,2,arguments.length),Qu("Reference.set",this.path),Vu("Reference.set",1,t,this.path,!1),hs("Reference.set",2,e,!0);var n=new Fa;return this.repo.setWithPriority(this.path,t,null,n.wrapCallback(e)),n.promise},bf.prototype.update=function(t,e){if(us("Reference.update",1,2,arguments.length),Qu("Reference.update",this.path),Array.isArray(t)){for(var n={},r=0;r<t.length;++r)n[""+r]=t[r];t=n,ru("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.")}qu("Reference.update",1,t,this.path,!1),hs("Reference.update",2,e,!0);var i=new Fa;return this.repo.update(this.path,t,i.wrapCallback(e)),i.promise},bf.prototype.setWithPriority=function(t,e,n){if(us("Reference.setWithPriority",2,3,arguments.length),Qu("Reference.setWithPriority",this.path),Vu("Reference.setWithPriority",1,t,this.path,!1),Bu("Reference.setWithPriority",2,e,!1),hs("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 Fa;return this.repo.setWithPriority(this.path,t,e,r.wrapCallback(n)),r.promise},bf.prototype.remove=function(t){return us("Reference.remove",0,1,arguments.length),Qu("Reference.remove",this.path),hs("Reference.remove",1,t,!0),this.set(null,t)},bf.prototype.transaction=function(t,r,e){if(us("Reference.transaction",1,3,arguments.length),Qu("Reference.transaction",this.path),hs("Reference.transaction",1,t,!1),hs("Reference.transaction",2,r,!0),function(t,e,n,r){if((!r||void 0!==n)&&"boolean"!=typeof n)throw new Error(cs(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 Fa;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 tc(e,n)),"function"==typeof r&&r(t,e,n)},e),i.promise},bf.prototype.setPriority=function(t,e){us("Reference.setPriority",1,2,arguments.length),Qu("Reference.setPriority",this.path),Bu("Reference.setPriority",1,t,!1),hs("Reference.setPriority",2,e,!0);var n=new Fa;return this.repo.setWithPriority(this.path.child(".priority"),t,null,n.wrapCallback(e)),n.promise},bf.prototype.push=function(t,e){us("Reference.push",0,2,arguments.length),Qu("Reference.push",this.path),Vu("Reference.push",1,t,this.path,!0),hs("Reference.push",2,e,!0);var n,r=this.repo.serverTime(),i=oc(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},bf.prototype.onDisconnect=function(){return Qu("Reference.onDisconnect",this.path),new $u(this.repo,this.path)},Object.defineProperty(bf.prototype,"database",{get:function(){return this.databaseProp()},enumerable:!0,configurable:!0}),Object.defineProperty(bf.prototype,"key",{get:function(){return this.getKey()},enumerable:!0,configurable:!0}),Object.defineProperty(bf.prototype,"parent",{get:function(){return this.getParent()},enumerable:!0,configurable:!0}),Object.defineProperty(bf.prototype,"root",{get:function(){return this.getRoot()},enumerable:!0,configurable:!0}),bf);function bf(t,e){if(!(t instanceof cf))throw new Error("new Reference() no longer supported - use app.database().");return gf.call(this,t,e,yf.DEFAULT,!1)||this}yh.__referenceConstructor=vf,il.__referenceConstructor=vf;var wf,_f,Ef=function(){this.children={},this.childCount=0,this.value=null},Tf=(Sf.prototype.subTree=function(t){for(var e=t instanceof Cu?t:new Cu(t),n=this,r=e.getFront();null!==r;)n=new Sf(r,n,Za(n.node_.children,r)||new Ef),r=(e=e.popFront()).getFront();return n},Sf.prototype.getValue=function(){return this.node_.value},Sf.prototype.setValue=function(t){Oa(void 0!==t,"Cannot set value to undefined"),this.node_.value=t,this.updateParents_()},Sf.prototype.clear=function(){this.node_.value=null,this.node_.children={},this.node_.childCount=0,this.updateParents_()},Sf.prototype.hasChildren=function(){return 0<this.node_.childCount},Sf.prototype.isEmpty=function(){return null===this.getValue()&&!this.hasChildren()},Sf.prototype.forEachChild=function(n){var r=this;wu(this.node_.children,function(t,e){n(new Sf(t,r,e))})},Sf.prototype.forEachDescendant=function(e,t,n){t&&!n&&e(this),this.forEachChild(function(t){t.forEachDescendant(e,!0,n)}),t&&n&&e(this)},Sf.prototype.forEachAncestor=function(t,e){for(var n=e?this:this.parent();null!==n;){if(t(n))return!0;n=n.parent()}return!1},Sf.prototype.forEachImmediateDescendantWithValue=function(e){this.forEachChild(function(t){null!==t.getValue()?e(t):t.forEachImmediateDescendantWithValue(e)})},Sf.prototype.path=function(){return new Cu(null===this.parent_?this.name_:this.parent_.path()+"/"+this.name_)},Sf.prototype.name=function(){return this.name_},Sf.prototype.parent=function(){return this.parent_},Sf.prototype.updateParents_=function(){null!==this.parent_&&this.parent_.updateChild_(this.name_,this)},Sf.prototype.updateChild_=function(t,e){var n=e.isEmpty(),r=$a(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_())},Sf);function Sf(t,e,n){void 0===t&&(t=""),void 0===e&&(e=null),void 0===n&&(n=new Ef),this.name_=t,this.parent_=e,this.node_=n}(_f=wf=wf||{})[_f.RUN=0]="RUN",_f[_f.SENT=1]="SENT",_f[_f.COMPLETED=2]="COMPLETED",_f[_f.SENT_NEEDS_ABORT=3]="SENT_NEEDS_ABORT",_f[_f.NEEDS_ABORT=4]="NEEDS_ABORT",cf.MAX_TRANSACTION_RETRIES_=25,cf.prototype.transactionsInit_=function(){this.transactionQueueTree_=new Tf},cf.prototype.startTransaction=function(t,e,n,r){this.log_("transaction on "+t);function i(){}var o=new vf(this,t);o.on("value",i);var a={path:t,update:e,onComplete:n,status:null,order:fu(),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 ih(a.currentInputSnapshot,new vf(this,a.path),Ic);a.onComplete(null,!1,c)}}else{Ju("transaction failed: Data returned ",u,a.path),a.status=wf.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&&$a(u,".priority"))f=Za(u,".priority"),Oa(Uu(f),"Invalid priority returned by transaction. Priority must be a valid string, finite number, server value, or null.");else f=(this.serverSyncTree_.calcCompleteEventCache(t)||Hc.EMPTY_NODE).getPriority().val();f=f;var p=this.generateServerValues(),d=$c(u,f),y=Eh(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_()}},cf.prototype.getLatestState_=function(t,e){return this.serverSyncTree_.calcCompleteEventCache(t,e)||Hc.EMPTY_NODE},cf.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);Oa(0<n.length,"Sending zero length transaction queue"),n.every(function(t){return t.status===wf.RUN})&&this.sendTransactionQueue_(t.path(),n)}else t.hasChildren()&&t.forEachChild(function(t){e.sendReadyTransactions_(t)})},cf.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];Oa(o.status===wf.RUN,"tryToSendTransactionQueue_: items in queue should all be run."),o.status=wf.SENT,o.retryCount++;var a=Cu.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=wf.COMPLETED,e=e.concat(c.serverSyncTree_.ackUserWrite(u[r].currentWriteId)),u[r].onComplete){var i=u[r].currentOutputSnapshotResolved,o=new vf(c,u[r].path),a=new ih(i,o,Ic);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++)Eu(n[r])}else{if("datastale"===t)for(r=0;r<u.length;r++)u[r].status===wf.SENT_NEEDS_ABORT?u[r].status=wf.NEEDS_ABORT:u[r].status=wf.RUN;else{ru("transaction at "+l.toString()+" failed: "+t);for(r=0;r<u.length;r++)u[r].status=wf.NEEDS_ABORT,u[r].abortReason=t}c.rerunTransactions_(s)}},r)},cf.prototype.rerunTransactions_=function(t){var e=this.getAncestorTransactionNode_(t),n=e.path(),r=this.buildTransactionQueue_(e);return this.rerunTransactionQueue_(r,n),n},cf.prototype.rerunTransactionQueue_=function(t,e){if(0!==t.length){for(var n,r=[],i=[],o=t.filter(function(t){return t.status===wf.RUN}).map(function(t){return t.currentWriteId}),a=0;a<t.length;a++){var s=t[a],u=Cu.relativePath(e,s.path),c=!1,h=void 0;if(Oa(null!==u,"rerunTransactionsUnderNode_: relativePath should not be null."),s.status===wf.NEEDS_ABORT)c=!0,h=s.abortReason,i=i.concat(this.serverSyncTree_.ackUserWrite(s.currentWriteId,!0));else if(s.status===wf.RUN)if(s.retryCount>=cf.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){Ju("transaction failed: Data returned ",f,s.path);var p=$c(f);"object"==typeof f&&null!=f&&$a(f,".priority")||(p=p.updatePriority(l.getPriority()));var d=s.currentWriteId,y=this.generateServerValues(),m=Eh(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=wf.COMPLETED,n=t[a].unwatcher,setTimeout(n,Math.floor(0)),t[a].onComplete))if("nodata"===h){var g=new vf(this,t[a].path),v=t[a].currentInputSnapshot,b=new ih(v,g,Ic);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++)Eu(r[a]);this.sendReadyTransactions_()}},cf.prototype.getAncestorTransactionNode_=function(t){var e,n=this.transactionQueueTree_;for(e=t.getFront();null!==e&&null===n.getValue();)n=n.subTree(e),e=(t=t.popFront()).getFront();return n},cf.prototype.buildTransactionQueue_=function(t){var e=[];return this.aggregateTransactionQueuesForNode_(t,e),e.sort(function(t,e){return t.order-e.order}),e},cf.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)})},cf.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!==wf.COMPLETED&&(n[r]=n[i],r++);n.length=r,t.setValue(0<n.length?n:null)}t.forEachChild(function(t){e.pruneCompletedTransactionsBelowNode_(t)})},cf.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},cf.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===wf.SENT_NEEDS_ABORT);else if(e[o].status===wf.SENT)Oa(i===o-1,"All SENT items should be at beginning of queue."),e[i=o].status=wf.SENT_NEEDS_ABORT,e[o].abortReason="set";else if(Oa(e[o].status===wf.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++)Eu(n[o])}};var If,Cf="databaseURL",Nf=(Af.getInstance=function(){return If=If||new Af},Af.prototype.interrupt=function(){var e,t,n,r;try{for(var i=Ia(Object.keys(this.repos_)),o=i.next();!o.done;o=i.next()){var a=o.value;try{for(var s=(n=void 0,Ia(Object.keys(this.repos_[a]))),u=s.next();!u.done;u=s.next()){var c=u.value;this.repos_[a][c].interrupt()}}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}}},Af.prototype.resume=function(){var e,t,n,r;try{for(var i=Ia(Object.keys(this.repos_)),o=i.next();!o.done;o=i.next()){var a=o.value;try{for(var s=(n=void 0,Ia(Object.keys(this.repos_[a]))),u=s.next();!u.done;u=s.next()){var c=u.value;this.repos_[a][c].resume()}}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}}},Af.prototype.databaseFromApp=function(t,e,n){var r=n||t.options[Cf];void 0===r&&nu("Can't determine Firebase Database URL. Be sure to include "+Cf+" option when calling firebase.initializeApp().");var i=Mu(r),o=i.repoInfo,a=void 0;return"undefined"!=typeof process&&(a=process.env.FIREBASE_DATABASE_EMULATOR_HOST),a&&(r="http://"+a+"?ns="+o.namespace,o=(i=Mu(r)).repoInfo),Hu("Invalid Firebase Database URL",1,i),i.path.isEmpty()||nu("Database URL must point to the root of a Firebase Database (not including a child path)."),this.createRepo(o,t,e).database},Af.prototype.deleteRepo=function(t){var e=Za(this.repos_,t.app.name);e&&Za(e,t.repoInfo_.toURLString())===t||nu("Database "+t.app.name+"("+t.repoInfo_+") has already been deleted."),t.interrupt(),delete e[t.repoInfo_.toURLString()]},Af.prototype.createRepo=function(t,e,n){var r=Za(this.repos_,e.name);r||(r={},this.repos_[e.name]=r);var i=Za(r,t.toURLString());return i&&nu("Database initialized multiple times. Please make sure the format of the database URL matches with each database() call."),i=new cf(t,this.useRestClient_,e,n),r[t.toURLString()]=i},Af.prototype.forceRestClient=function(t){this.useRestClient_=t},Af);function Af(){this.repos_={},this.useRestClient_=!1}var Df=(Object.defineProperty(kf.prototype,"app",{get:function(){return this.repo_.app},enumerable:!0,configurable:!0}),kf.prototype.ref=function(t){return this.checkDeleted_("ref"),us("database.ref",0,1,arguments.length),t instanceof vf?this.refFromURL(t.toString()):void 0!==t?this.root_.child(t):this.root_},kf.prototype.refFromURL=function(t){var e="database.refFromURL";this.checkDeleted_(e),us(e,1,1,arguments.length);var n=Mu(t);Hu(e,1,n);var r=n.repoInfo;return r.host!==this.repo_.repoInfo_.host&&nu(e+": Host name does not match the current database: (found "+r.host+" but expected "+this.repo_.repoInfo_.host+")"),this.ref(n.path.toString())},kf.prototype.checkDeleted_=function(t){null===this.repo_&&nu("Cannot call "+t+" on a deleted database.")},kf.prototype.goOffline=function(){us("database.goOffline",0,0,arguments.length),this.checkDeleted_("goOffline"),this.repo_.interrupt()},kf.prototype.goOnline=function(){us("database.goOnline",0,0,arguments.length),this.checkDeleted_("goOnline"),this.repo_.resume()},kf.ServerValue={TIMESTAMP:{".sv":"timestamp"}},kf);function kf(t){(this.repo_=t)instanceof cf||nu("Don't call new Database() directly - please use firebase.database()."),this.root_=new vf(t,Cu.Empty),this.INTERNAL=new Rf(this)}var Rf=(Of.prototype.delete=function(){return Ta(this,void 0,void 0,function(){return Sa(this,function(t){return this.database.checkDeleted_("delete"),Nf.getInstance().deleteRepo(this.database.repo_),this.database.repo_=null,this.database.root_=null,this.database.INTERNAL=null,this.database=null,[2]})})},Of);function Of(t){this.database=t}var Pf=Object.freeze({__proto__:null,forceLongPolling:function(){zl.forceDisallow(),Bl.forceAllow()},forceWebSockets:function(){Bl.forceDisallow()},isWebSocketsAvailable:function(){return zl.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)}}),xf=nf;nf.prototype.simpleListen=function(t,e){this.sendRequest("q",{p:t},e)},nf.prototype.echo=function(t,e){this.sendRequest("echo",{d:t},e)};var Mf,Lf,Ff=Jl,Uf=Pu,Vf=Object.freeze({__proto__:null,DataConnection:xf,RealTimeConnection:Ff,hijackHash:function(i){var o=nf.prototype.put;return nf.prototype.put=function(t,e,n,r){void 0!==r&&(r=i()),o.call(this,t,e,n,r)},function(){nf.prototype.put=o}},ConnectionTarget:Uf,queryIdentifier:function(t){return t.queryIdentifier()},forceRestClient:function(t){Nf.getInstance().forceRestClient(t)}}),qf=Df.ServerValue;Mf=(Lf=fl).SDK_VERSION,Ql=Mf,Lf.INTERNAL.registerComponent(new ps("database",function(t,e){var n=t.getProvider("app").getImmediate(),r=t.getProvider("auth-internal");return Nf.getInstance().databaseFromApp(n,r,e)},"PUBLIC").setServiceProps({Reference:vf,Query:yh,Database:Df,DataSnapshot:ih,enableLogging:$s,INTERNAL:Pf,ServerValue:qf,TEST_ACCESS:Vf}).setMultipleInstances(!0)),Lf.registerVersion("@firebase/database","0.5.20");var Bf,jf="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},Wf=Wf||{},Kf=jf;function Qf(t){return"string"==typeof t}function Hf(t){return"number"==typeof t}function zf(t,e){t=t.split("."),e=e||Kf;for(var n=0;n<t.length;n++)if(null==(e=e[t[n]]))return null;return e}function Gf(){}function Yf(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 Xf(t){return"array"==Yf(t)}function Jf(t){var e=Yf(t);return"array"==e||"object"==e&&"number"==typeof t.length}function $f(t){var e=typeof t;return"object"==e&&null!=t||"function"==e}var Zf="closure_uid_"+(1e9*Math.random()>>>0),tp=0;function ep(t,e,n){return t.call.apply(t.bind,arguments)}function np(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 rp(t,e,n){return(rp=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?ep:np).apply(null,arguments)}function ip(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 op=Date.now||function(){return+new Date};function ap(t,o){function e(){}e.prototype=o.prototype,t.N=o.prototype,t.prototype=new e,(t.prototype.constructor=t).xb=function(t,e,n){for(var r=Array(arguments.length-2),i=2;i<arguments.length;i++)r[i-2]=arguments[i];return o.prototype[e].apply(t,r)}}function sp(){this.j=this.j,this.i=this.i}sp.prototype.j=!1,sp.prototype.la=function(){if(!this.j&&(this.j=!0,this.G(),0))this[Zf]||(this[Zf]=++tp)},sp.prototype.G=function(){if(this.i)for(;this.i.length;)this.i.shift()()};var up=Array.prototype.indexOf?function(t,e){return Array.prototype.indexOf.call(t,e,void 0)}:function(t,e){if(Qf(t))return Qf(e)&&1==e.length?t.indexOf(e,0):-1;for(var n=0;n<t.length;n++)if(n in t&&t[n]===e)return n;return-1},cp=Array.prototype.forEach?function(t,e,n){Array.prototype.forEach.call(t,e,n)}:function(t,e,n){for(var r=t.length,i=Qf(t)?t.split(""):t,o=0;o<r;o++)o in i&&e.call(n,i[o],o,t)};function hp(){return Array.prototype.concat.apply([],arguments)}function lp(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 fp(t){return/^[\s\xa0]*$/.test(t)}var pp,dp=String.prototype.trim?function(t){return t.trim()}:function(t){return/^[\s\xa0]*([\s\S]*?)[\s\xa0]*$/.exec(t)[1]};function yp(t,e){return-1!=t.indexOf(e)}function mp(t,e){return t<e?-1:e<t?1:0}t:{var gp=Kf.navigator;if(gp){var vp=gp.userAgent;if(vp){pp=vp;break t}}pp=""}function bp(t,e,n){for(var r in t)e.call(n,t[r],r,t)}function wp(t){var e,n={};for(e in t)n[e]=t[e];return n}var _p="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function Ep(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<_p.length;i++)e=_p[i],Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])}}function Tp(t){return Tp[" "](t),t}Tp[" "]=Gf;var Sp,Ip,Cp=yp(pp,"Opera"),Np=yp(pp,"Trident")||yp(pp,"MSIE"),Ap=yp(pp,"Edge"),Dp=Ap||Np,kp=yp(pp,"Gecko")&&!(yp(pp.toLowerCase(),"webkit")&&!yp(pp,"Edge"))&&!(yp(pp,"Trident")||yp(pp,"MSIE"))&&!yp(pp,"Edge"),Rp=yp(pp.toLowerCase(),"webkit")&&!yp(pp,"Edge");function Op(){var t=Kf.document;return t?t.documentMode:void 0}t:{var Pp="",xp=(Ip=pp,kp?/rv:([^\);]+)(\)|;)/.exec(Ip):Ap?/Edge\/([\d\.]+)/.exec(Ip):Np?/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(Ip):Rp?/WebKit\/(\S+)/.exec(Ip):Cp?/(?:Version)[ \/]?(\S+)/.exec(Ip):void 0);if(xp&&(Pp=xp?xp[1]:""),Np){var Mp=Op();if(null!=Mp&&Mp>parseFloat(Pp)){Sp=String(Mp);break t}}Sp=Pp}var Lp,Fp={};function Up(s){return function(t,e){var n=Fp;return Object.prototype.hasOwnProperty.call(n,t)?n[t]:n[t]=e(t)}(s,function(){for(var t=0,e=dp(String(Sp)).split("."),n=dp(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=mp(0==o[1].length?0:parseInt(o[1],10),0==a[1].length?0:parseInt(a[1],10))||mp(0==o[2].length,0==a[2].length)||mp(o[2],a[2]),o=o[3],a=a[3]}while(0==t)}return 0<=t})}var Vp=Kf.document;Lp=Vp&&Np?Op()||("CSS1Compat"==Vp.compatMode?parseInt(Sp,10):5):void 0;var qp=!Np||9<=Number(Lp),Bp=Np&&!Up("9"),jp=function(){if(!Kf.addEventListener||!Object.defineProperty)return!1;var t=!1,e=Object.defineProperty({},"passive",{get:function(){t=!0}});try{Kf.addEventListener("test",Gf,e),Kf.removeEventListener("test",Gf,e)}catch(t){}return t}();function Wp(t,e){this.type=t,this.a=this.target=e,this.Ia=!0}function Kp(t,e){if(Wp.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(kp){t:{try{Tp(e.nodeName);var i=!0;break t}catch(t){}i=!1}i||(e=null)}}else"mouseover"==n?e=t.fromElement:"mouseout"==n&&(e=t.toElement);this.relatedTarget=e,r?(this.clientX=void 0!==r.clientX?r.clientX:r.pageX,this.clientY=void 0!==r.clientY?r.clientY:r.pageY,this.screenX=r.screenX||0,this.screenY=r.screenY||0):(this.clientX=void 0!==t.clientX?t.clientX:t.pageX,this.clientY=void 0!==t.clientY?t.clientY:t.pageY,this.screenX=t.screenX||0,this.screenY=t.screenY||0),this.button=t.button,this.key=t.key||"",this.ctrlKey=t.ctrlKey,this.altKey=t.altKey,this.shiftKey=t.shiftKey,this.metaKey=t.metaKey,this.pointerId=t.pointerId||0,this.pointerType=Qf(t.pointerType)?t.pointerType:Qp[t.pointerType]||"",(this.c=t).defaultPrevented&&this.b()}}Wp.prototype.b=function(){this.Ia=!1},ap(Kp,Wp);var Qp={2:"touch",3:"pen",4:"mouse"};Kp.prototype.b=function(){Kp.N.b.call(this);var t=this.c;if(t.preventDefault)t.preventDefault();else if(t.returnValue=!1,Bp)try{(t.ctrlKey||112<=t.keyCode&&t.keyCode<=123)&&(t.keyCode=-1)}catch(t){}};var Hp="closure_listenable_"+(1e6*Math.random()|0),zp=0;function Gp(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=++zp,this.X=this.Z=!1}function Yp(t){t.X=!0,t.listener=null,t.proxy=null,t.src=null,t.da=null}function Xp(t){this.src=t,this.a={},this.b=0}function Jp(t,e){var n=e.type;if(n in t.a){var r,i=t.a[n],o=up(i,e);(r=0<=o)&&Array.prototype.splice.call(i,o,1),r&&(Yp(e),0==t.a[n].length&&(delete t.a[n],t.b--))}}function $p(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}Xp.prototype.add=function(t,e,n,r,i){var o=t.toString();(t=this.a[o])||(t=this.a[o]=[],this.b++);var a=$p(t,e,r,i);return-1<a?(e=t[a],n||(e.Z=!1)):((e=new Gp(e,this.src,o,!!r,i)).Z=n,t.push(e)),e};var Zp="closure_lm_"+(1e6*Math.random()|0),td={};function ed(t,e,n,r,i){if(r&&r.once)return function t(e,n,r,i,o){if(Xf(n)){for(var a=0;a<n.length;a++)t(e,n[a],r,i,o);return null}r=cd(r);return e&&e[Hp]?e.Aa(n,r,$f(i)?!!i.capture:!!i,o):nd(e,n,r,!0,i,o)}(t,e,n,r,i);if(Xf(e)){for(var o=0;o<e.length;o++)ed(t,e[o],n,r,i);return null}return n=cd(n),t&&t[Hp]?t.za(e,n,$f(r)?!!r.capture:!!r,i):nd(t,e,n,!1,r,i)}function nd(t,e,n,r,i,o){if(!e)throw Error("Invalid event type");var a=$f(i)?!!i.capture:!!i;if(a&&!qp)return null;var s=sd(t);if(s||(t[Zp]=s=new Xp(t)),(n=s.add(e,n,r,a,o)).proxy)return n;if(r=function(){var e=ad,n=qp?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)jp||(i=a),void 0===i&&(i=!1),t.addEventListener(e.toString(),r,i);else if(t.attachEvent)t.attachEvent(id(e.toString()),r);else{if(!t.addListener||!t.removeListener)throw Error("addEventListener and attachEvent are unavailable.");t.addListener(r)}return n}function rd(t){if(!Hf(t)&&t&&!t.X){var e=t.src;if(e&&e[Hp])Jp(e.c,t);else{var n=t.type,r=t.proxy;e.removeEventListener?e.removeEventListener(n,r,t.capture):e.detachEvent?e.detachEvent(id(n),r):e.addListener&&e.removeListener&&e.removeListener(r),(n=sd(e))?(Jp(n,t),0==n.b&&(n.src=null,e[Zp]=null)):Yp(t)}}}function id(t){return t in td?td[t]:td[t]="on"+t}function od(t,e){var n=t.listener,r=t.da||t.src;return t.Z&&rd(t),n.call(r,e)}function ad(t,e){return!!t.X||(qp?od(t,new Kp(e,this)):od(t,e=new Kp(e||zf("window.event"),this)))}function sd(t){return(t=t[Zp])instanceof Xp?t:null}var ud="__closure_events_fn_"+(1e9*Math.random()>>>0);function cd(e){return"function"==Yf(e)?e:(e[ud]||(e[ud]=function(t){return e.handleEvent(t)}),e[ud])}function hd(){sp.call(this),this.c=new Xp(this),(this.J=this).B=null}function ld(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&&Jp(t.c,a),i=!1!==s.call(u,r)&&i}}return i&&0!=r.Ia}ap(hd,sp),hd.prototype[Hp]=!0,(Bf=hd.prototype).addEventListener=function(t,e,n,r){ed(this,t,e,n,r)},Bf.removeEventListener=function(t,e,n,r){!function t(e,n,r,i,o){if(Xf(n))for(var a=0;a<n.length;a++)t(e,n[a],r,i,o);else i=$f(i)?!!i.capture:!!i,r=cd(r),e&&e[Hp]?(e=e.c,(n=String(n).toString())in e.a&&-1<(r=$p(a=e.a[n],r,i,o))&&(Yp(a[r]),Array.prototype.splice.call(a,r,1),0==a.length&&(delete e.a[n],e.b--))):(e=e&&sd(e))&&(n=e.a[n.toString()],e=-1,n&&(e=$p(n,r,i,o)),(r=-1<e?n[e]:null)&&rd(r))}(this,t,e,n,r)},Bf.dispatchEvent=function(t){var e,n=this.B;if(n)for(e=[];n;n=n.B)e.push(n);n=this.J;var r=t.type||t;if(Qf(t))t=new Wp(t,n);else if(t instanceof Wp)t.target=t.target||n;else{var i=t;Ep(t=new Wp(r,n),i)}if(i=!0,e)for(var o=e.length-1;0<=o;o--){var a=t.a=e[o];i=ld(a,r,!0,t)&&i}if(i=ld(a=t.a=n,r,!0,t)&&i,i=ld(a,r,!1,t)&&i,e)for(o=0;o<e.length;o++)i=ld(a=t.a=e[o],r,!1,t)&&i;return i},Bf.G=function(){if(hd.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++)Yp(n[r]);delete e.a[t],e.b--}}this.B=null},Bf.za=function(t,e,n,r){return this.c.add(String(t),e,!1,n,r)},Bf.Aa=function(t,e,n,r){return this.c.add(String(t),e,!0,n,r)};var fd=Kf.JSON.stringify;function pd(t,e){this.c=t,this.f=e,this.b=0,this.a=null}function dd(){this.b=this.a=null}pd.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 yd,md=new pd(function(){return new gd},function(t){t.reset()});function gd(){this.next=this.b=this.a=null}function vd(t){Kf.setTimeout(function(){throw t},0)}function bd(t,e){yd||function(){var t=Kf.Promise.resolve(void 0);yd=function(){t.then(Ed)}}(),wd||(yd(),wd=!0),_d.add(t,e)}dd.prototype.add=function(t,e){var n=md.get();n.set(t,e),this.b?this.b.next=n:this.a=n,this.b=n},gd.prototype.set=function(t,e){this.a=t,this.b=e,this.next=null};var wd=!(gd.prototype.reset=function(){this.next=this.b=this.a=null}),_d=new dd;function Ed(){for(var t;r=n=void 0,r=null,(n=_d).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){vd(t)}var e=md;e.f(t),e.b<100&&(e.b++,t.next=e.a,e.a=t)}var n,r;wd=!1}function Td(t,e){hd.call(this),this.b=t||1,this.a=e||Kf,this.f=rp(this.fb,this),this.g=op()}function Sd(t){t.ba=!1,t.L&&(t.a.clearTimeout(t.L),t.L=null)}function Id(t,e,n){if("function"==Yf(t))n&&(t=rp(t,n));else{if(!t||"function"!=typeof t.handleEvent)throw Error("Invalid listener argument");t=rp(t.handleEvent,t)}return 2147483647<Number(e)?-1:Kf.setTimeout(t,e||0)}function Cd(t,e,n){sp.call(this),this.f=null!=n?rp(t,n):t,this.c=e,this.b=rp(this.$a,this),this.a=[]}function Nd(t){t.U=Id(t.b,t.c),t.f.apply(null,t.a)}function Ad(t){sp.call(this),this.b=t,this.a={}}ap(Td,hd),(Bf=Td.prototype).ba=!1,Bf.L=null,Bf.fb=function(){if(this.ba){var t=op()-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&&(Sd(this),this.start()))}},Bf.start=function(){this.ba=!0,this.L||(this.L=this.a.setTimeout(this.f,this.b),this.g=op())},Bf.G=function(){Td.N.G.call(this),Sd(this),delete this.a},ap(Cd,sp),(Bf=Cd.prototype).ea=!1,Bf.U=null,Bf.Ta=function(t){this.a=arguments,this.U?this.ea=!0:Nd(this)},Bf.G=function(){Cd.N.G.call(this),this.U&&(Kf.clearTimeout(this.U),this.U=null,this.ea=!1,this.a=[])},Bf.$a=function(){this.U=null,this.ea&&(this.ea=!1,Nd(this))},ap(Ad,sp);var Dd=[];function kd(t,e,n,r){Xf(n)||(n&&(Dd[0]=n.toString()),n=Dd);for(var i=0;i<n.length;i++){var o=ed(e,n[i],r||t.handleEvent,!1,t.b||t);if(!o)break;t.a[o.key]=o}}function Rd(t){bp(t.a,function(t,e){this.a.hasOwnProperty(e)&&rd(t)},t),t.a={}}function Od(){}Ad.prototype.G=function(){Ad.N.G.call(this),Rd(this)},Ad.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var Pd=new hd;function xd(t){Wp.call(this,"serverreachability",t)}function Md(t){Pd.dispatchEvent(new xd(Pd,t))}function Ld(t){Wp.call(this,"statevent",t)}function Fd(t){Pd.dispatchEvent(new Ld(Pd,t))}function Ud(t){Wp.call(this,"timingevent",t)}function Vd(t,e){if("function"!=Yf(t))throw Error("Fn must not be null and must be a function");return Kf.setTimeout(function(){t()},e)}ap(xd,Wp),ap(Ld,Wp),ap(Ud,Wp);var qd={NO_ERROR:0,gb:1,nb:2,mb:3,jb:4,lb:5,ob:6,La:7,TIMEOUT:8,rb:9},Bd={ib:"complete",vb:"success",Ma:"error",La:"abort",tb:"ready",ub:"readystatechange",TIMEOUT:"timeout",pb:"incrementaldata",sb:"progress",kb:"downloadprogress",wb:"uploadprogress"};function jd(){}function Wd(t){var e;return(e=t.a)||(e=t.a={}),e}function Kd(){}jd.prototype.a=null;var Qd,Hd={OPEN:"a",hb:"b",Ma:"c",qb:"d"};function zd(){Wp.call(this,"d")}function Gd(){Wp.call(this,"c")}function Yd(){}function Xd(t,e,n){this.g=t,this.W=e,this.V=n||1,this.I=new Ad(this),this.O=Jd,t=Dp?125:void 0,this.P=new Td(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}ap(zd,Wp),ap(Gd,Wp),ap(Yd,jd),Qd=new Yd;var Jd=45e3,$d={},Zd={};function ty(t,e,n){t.F=1,t.f=Iy(vy(e)),t.l=n,t.H=!0,ny(t,null)}function ey(t,e,n,r){t.F=1,t.f=Iy(vy(e)),t.l=null,t.H=n,ny(t,r)}function ny(t,e){t.v=op(),oy(t),t.D=vy(t.f),Sy(t.D,"t",t.V),t.A=0,t.a=t.g.$(t.g.Y()?e:null),0<t.J&&(t.B=new Cd(rp(t.Ja,t,t.a),t.J)),kd(t.I,t.a,"readystatechange",t.cb),e=t.h?wp(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)),Md(1)}function ry(t,e,n){for(var r=!0;!t.m&&t.A<n.length;){var i=iy(t,n);if(i==Zd){4==e&&(t.c=4,Fd(14),r=!1);break}if(i==$d){t.c=4,Fd(15),r=!1;break}hy(t,i)}4==e&&0==n.length&&(t.c=1,Fd(16),r=!1),t.b=t.b&&r,r||(cy(t),uy(t))}function iy(t,e){var n=t.A,r=e.indexOf("\n",n);return-1==r?Zd:(n=Number(e.substring(n,r)),isNaN(n)?$d:(r+=1)+n>e.length?Zd:(e=e.substr(r,n),t.A=r+n,e))}function oy(t){t.R=op()+t.O,ay(t,t.O)}function ay(t,e){if(null!=t.i)throw Error("WatchDog timer not null");t.i=Vd(rp(t.ab,t),e)}function sy(t){t.i&&(Kf.clearTimeout(t.i),t.i=null)}function uy(t){t.g.Ca()||t.m||t.g.na(t)}function cy(t){sy(t);var e=t.B;e&&"function"==typeof e.la&&e.la(),t.B=null,Sd(t.P),Rd(t.I),t.a&&(e=t.a,t.a=null,e.abort(),e.la())}function hy(t,e){try{t.g.Fa(t,e),Md(4)}catch(t){}}function ly(t,e){if(t.forEach&&"function"==typeof t.forEach)t.forEach(e,void 0);else if(Jf(t)||Qf(t))cp(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(Jf(t)||Qf(t)){n=[];for(var r=t.length,i=0;i<r;i++)n.push(i)}else for(i in n=[],r=0,t)n[r++]=i;i=(r=function(t){if(t.C&&"function"==typeof t.C)return t.C();if(Qf(t))return t.split("");if(Jf(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 fy(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 fy)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 py(t,e){yy(t.b,e)&&(delete t.b[e],t.c--,t.a.length>2*t.c&&dy(t))}function dy(t){if(t.c!=t.a.length){for(var e=0,n=0;e<t.a.length;){var r=t.a[e];yy(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;)yy(i,r=t.a[e])||(i[t.a[n++]=r]=1),e++;t.a.length=n}}function yy(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(Bf=Xd.prototype).setTimeout=function(t){this.O=t},Bf.cb=function(t){t=t.target;var e=this.B;e&&3==gm(t)?e.Ta():this.Ja(t)},Bf.Ja=function(t){try{if(t==this.a)t:{var e=gm(this.a),n=this.a.ya(),r=this.a.T();if(!(e<3||3==e&&!Dp&&!this.a.aa())){this.m||4!=e||7==n||Md(8==n||r<=0?3:2),sy(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=vm(this.a,"X-HTTP-Initial-Response");if(a&&!fp(a)){var s=a;break e}}s=null}if(!s){this.b=!1,this.c=3,Fd(12),cy(this),uy(this);break t}this.s=!0,hy(this,s)}this.H?(ry(this,e,o),Dp&&this.b&&3==e&&(kd(this.I,this.P,"tick",this.bb),this.P.start())):hy(this,o),4==e&&cy(this),this.b&&!this.m&&(4==e?this.g.na(this):(this.b=!1,oy(this)))}else 400==i&&0<o.indexOf("Unknown SID")?(this.c=3,Fd(12)):(this.c=0,Fd(13)),cy(this),uy(this)}}}catch(t){}},Bf.bb=function(){if(this.a){var t=gm(this.a),e=this.a.aa();this.A<e.length&&(sy(this),ry(this,t,e),this.b&&4!=t&&oy(this))}},Bf.cancel=function(){this.m=!0,cy(this)},Bf.ab=function(){this.i=null;var t=op();0<=t-this.R?(2!=this.F&&(Md(3),Fd(17)),cy(this),this.c=2,uy(this)):ay(this,this.R-t)},(Bf=fy.prototype).C=function(){dy(this);for(var t=[],e=0;e<this.a.length;e++)t.push(this.b[this.a[e]]);return t},Bf.K=function(){return dy(this),this.a.concat()},Bf.get=function(t,e){return yy(this.b,t)?this.b[t]:e},Bf.set=function(t,e){yy(this.b,t)||(this.c++,this.a.push(t)),this.b[t]=e},Bf.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 my=/^(?:([^:/?#.]+):)?(?:\/\/(?:([^/?#]*)@)?([^/#?]*?)(?::([0-9]+))?(?=[/#?]|$))?([^?#]+)?(?:\?([^#]*))?(?:#([\s\S]*))?$/;function gy(t,e){var n;this.b=this.j=this.f="",this.i=null,this.g=this.a="",this.h=!1,t instanceof gy?(this.h=void 0!==e?e:t.h,by(this,t.f),this.j=t.j,wy(this,t.b),_y(this,t.i),this.a=t.a,Ey(this,Vy(t.c)),this.g=t.g):t&&(n=String(t).match(my))?(this.h=!!e,by(this,n[1]||"",!0),this.j=Cy(n[2]||""),wy(this,n[3]||"",!0),_y(this,n[4]),this.a=Cy(n[5]||"",!0),Ey(this,n[6]||"",!0),this.g=Cy(n[7]||"")):(this.h=!!e,this.c=new xy(null,this.h))}function vy(t){return new gy(t)}function by(t,e,n){t.f=n?Cy(e,!0):e,t.f&&(t.f=t.f.replace(/:$/,""))}function wy(t,e,n){t.b=n?Cy(e,!0):e}function _y(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 Ey(t,e,n){e instanceof xy?(t.c=e,function(t,e){e&&!t.f&&(My(t),t.c=null,t.a.forEach(function(t,e){var n=e.toLowerCase();e!=n&&(Ly(this,e),Uy(this,n,t))},t)),t.f=e}(t.c,t.h)):(n||(e=Ny(e,Oy)),t.c=new xy(e,t.h))}function Ty(t,e,n){t.c.set(e,n)}function Sy(t,e,n){Xf(n)||(n=[String(n)]),Uy(t.c,e,n)}function Iy(t){return Ty(t,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^op()).toString(36)),t}function Cy(t,e){return t?e?decodeURI(t.replace(/%25/g,"%2525")):decodeURIComponent(t):""}function Ny(t,e,n){return Qf(t)?(t=encodeURI(t).replace(e,Ay),n&&(t=t.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),t):null}function Ay(t){return"%"+((t=t.charCodeAt(0))>>4&15).toString(16)+(15&t).toString(16)}gy.prototype.toString=function(){var t=[],e=this.f;e&&t.push(Ny(e,Dy,!0),":");var n=this.b;return!n&&"file"!=e||(t.push("//"),(e=this.j)&&t.push(Ny(e,Dy,!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(Ny(n,"/"==n.charAt(0)?Ry:ky,!0))),(n=this.c.toString())&&t.push("?",n),(n=this.g)&&t.push("#",Ny(n,Py)),t.join("")},gy.prototype.resolve=function(t){var e=vy(this),n=!!t.f;n?by(e,t.f):n=!!t.j,n?e.j=t.j:n=!!t.b,n?wy(e,t.b):n=null!=t.i;var r=t.a;if(n)_y(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(yp(i,"./")||yp(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?Ey(e,Vy(t.c)):n=!!t.g,n&&(e.g=t.g),e};var Dy=/[#\/\?@]/g,ky=/[#\?:]/g,Ry=/[#\?]/g,Oy=/[#\?@]/g,Py=/#/g;function xy(t,e){this.b=this.a=null,this.c=t||null,this.f=!!e}function My(n){n.a||(n.a=new fy,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 Ly(t,e){My(t),e=qy(t,e),yy(t.a.b,e)&&(t.c=null,t.b-=t.a.get(e).length,py(t.a,e))}function Fy(t,e){return My(t),e=qy(t,e),yy(t.a.b,e)}function Uy(t,e,n){Ly(t,e),0<n.length&&(t.c=null,t.a.set(qy(t,e),lp(n)),t.b+=n.length)}function Vy(t){var e=new xy;return e.c=t.c,t.a&&(e.a=new fy(t.a),e.b=t.b),e}function qy(t,e){return e=String(e),t.f&&(e=e.toLowerCase()),e}function By(t){this.a=t,this.b=this.h=null,this.g=!1,this.i=null,this.c=-1,this.l=this.f=null}function jy(t){var e=t.a.F.a;if(null!=e)Fd(4),e?(Fd(10),km(t.a,t,!1)):(Fd(11),km(t.a,t,!0));else{t.b=new Xd(t,void 0,void 0),t.b.h=t.h,e=Mm(e=t.a,e.Y()?t.f:null,t.i),Fd(4),Sy(e,"TYPE","xmlhttp");var n=t.a.j,r=t.a.I;n&&r&&Ty(e,n,r),ey(t.b,e,!1,t.f)}}function Wy(){this.a=this.b=null}function Ky(){this.a=new fy}function Qy(t){var e=typeof t;return"object"==e&&t||"function"==e?"o"+(t[Zf]||(t[Zf]=++tp)):e.charAt(0)+t}function Hy(t,e){this.b=t,this.a=e}function zy(t){this.g=t||Gy,t=Kf.PerformanceNavigationTiming?0<(t=Kf.performance.getEntriesByType("navigation")).length&&("hq"==t[0].nextHopProtocol||"h2"==t[0].nextHopProtocol):!!(Kf.ka&&Kf.ka.Da&&Kf.ka.Da()&&Kf.ka.Da().yb),this.f=t?this.g:1,this.a=null,1<this.f&&(this.a=new Ky),this.b=null,this.c=[]}(Bf=xy.prototype).add=function(t,e){My(this),this.c=null,t=qy(this,t);var n=this.a.get(t);return n||this.a.set(t,n=[]),n.push(e),this.b+=1,this},Bf.forEach=function(n,r){My(this),this.a.forEach(function(t,e){cp(t,function(t){n.call(r,t,e,this)},this)},this)},Bf.K=function(){My(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},Bf.C=function(t){My(this);var e=[];if(Qf(t))Fy(this,t)&&(e=hp(e,this.a.get(qy(this,t))));else{t=this.a.C();for(var n=0;n<t.length;n++)e=hp(e,t[n])}return e},Bf.set=function(t,e){return My(this),this.c=null,Fy(this,t=qy(this,t))&&(this.b-=this.a.get(t).length),this.a.set(t,[e]),this.b+=1,this},Bf.get=function(t,e){return t&&0<(t=this.C(t)).length?String(t[0]):e},Bf.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("&")},ap(function(){},function(){}),(Bf=By.prototype).M=null,Bf.$=function(t){return this.a.$(t)},Bf.abort=function(){this.b&&(this.b.cancel(),this.b=null),this.c=-1},Bf.Ca=function(){return!1},Bf.Fa=function(t,e){if(this.c=t.o,0==this.M){if(!this.a.o&&(t=t.a)){var n=vm(t,"X-Client-Wire-Protocol");this.l=n||null,this.a.j&&(t=vm(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 Pm(e,2)}this.f=r[0]}else(e=this.a).m=this.c,Pm(e,2)}else 1==this.M&&(this.g?Fd(6):"11111"==e?(Fd(5),this.g=!0,(!Np||10<=Number(Lp))&&(this.c=200,this.b.cancel(),Fd(11),km(this.a,this,!0))):(Fd(7),this.g=!1))},Bf.na=function(){if(this.c=this.b.o,this.b.b)0==this.M?(this.M=1,jy(this)):1==this.M&&(this.g?(Fd(11),km(this.a,this,!0)):(Fd(10),km(this.a,this,!1)));else{0==this.M?Fd(8):1==this.M&&Fd(9);var t=this.a;t.m=this.c,Pm(t,2)}},Bf.Y=function(){return this.a.Y()},Bf.ma=function(){return this.a.ma()},Ky.prototype.add=function(t){this.a.set(Qy(t),t)},Ky.prototype.C=function(){return this.a.C()};var Gy=10;function Yy(t,e){!t.a&&(yp(e,"spdy")||yp(e,"quic")||yp(e,"h2"))&&(t.f=t.g,t.a=new Ky,t.b&&(Zy(t,t.b),t.b=null))}function Xy(t){return!!t.b||!!t.a&&t.a.a.c>=t.f}function Jy(t){return t.b?1:t.a?t.a.a.c:0}function $y(t,e){return t=t.b?t.b==e:!!t.a&&(e=Qy(e),yy(t.a.a.b,e))}function Zy(t,e){t.a?t.a.add(e):t.b=e}function tm(t,e){var n;t.b&&t.b==e?t.b=null:((n=t.a)&&(n=Qy(e),n=yy(t.a.a.b,n)),n&&py(t.a.a,Qy(e)))}function em(t){if(null!=t.b)return t.c.concat(t.b.j);if(null==t.a||0==t.a.a.c)return lp(t.c);var e=t.c;return cp(t.a.C(),function(t){e=e.concat(t.j)}),e}function nm(){}function rm(){this.a=new nm}function im(t,r,e){var i=e||"";try{ly(t,function(t,e){var n=t;$f(t)&&(n=fd(t)),r.push(i+e+"="+encodeURIComponent(n))})}catch(t){throw r.push(i+"type="+encodeURIComponent("_badmap")),t}}function om(t,e,n,r,i){try{e.onload=null,e.onerror=null,e.onabort=null,e.ontimeout=null,i(r)}catch(t){}}zy.prototype.cancel=function(){this.c=em(this),this.b?(this.b.cancel(),this.b=null):this.a&&0!=this.a.a.c&&(cp(this.a.C(),function(t){t.cancel()}),function(t){t.b={},t.a.length=0,t.c=0}(this.a.a))},nm.prototype.stringify=function(t){return Kf.JSON.stringify(t,void 0)},nm.prototype.parse=function(t){return Kf.JSON.parse(t,void 0)};var am=Kf.JSON.parse;function sm(t){hd.call(this),this.headers=new fy,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=um,this.D=this.F=!1}ap(sm,hd);var um="",cm=/^https?$/i,hm=["POST","PUT"];function lm(t){return"content-type"==t.toLowerCase()}function fm(t,e){t.b=!1,t.a&&(t.g=!0,t.a.abort(),t.g=!1),t.f=e,t.h=5,pm(t),ym(t)}function pm(t){t.v||(t.v=!0,t.dispatchEvent("complete"),t.dispatchEvent("error"))}function dm(t){if(t.b&&void 0!==Wf&&(!t.s[1]||4!=gm(t)||2!=t.T()))if(t.l&&4==gm(t))Id(t.Ea,0,t);else if(t.dispatchEvent("readystatechange"),4==gm(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(my)[1]||null;if(!o&&Kf.self&&Kf.self.location){var a=Kf.self.location.protocol;o=a.substr(0,a.length-1)}i=!cm.test(o?o.toLowerCase():"")}e=i}if(e)t.dispatchEvent("complete"),t.dispatchEvent("success");else{t.h=6;try{var s=2<gm(t)?t.a.statusText:""}catch(t){s=""}t.f=s+" ["+t.T()+"]",pm(t)}}finally{ym(t)}}}function ym(t,e){if(t.a){mm(t);var n=t.a,r=t.s[0]?Gf:null;t.a=null,t.s=null,e||t.dispatchEvent("ready");try{n.onreadystatechange=r}catch(t){}}}function mm(t){t.a&&t.D&&(t.a.ontimeout=null),t.m&&(Kf.clearTimeout(t.m),t.m=null)}function gm(t){return t.a?t.a.readyState:0}function vm(t,e){return t.a?t.a.getResponseHeader(e):null}function bm(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 bp(t,function(t,e){n+=e,n+=":",n+=t,n+="\r\n"}),n}(n),Qf(t)){if(e=encodeURIComponent(String(e)),e+=n=null!=n?"="+encodeURIComponent(String(n)):""){if((n=t.indexOf("#"))<0&&(n=t.length),(r=t.indexOf("?"))<0||n<r){r=n;var i=""}else i=t.substring(r+1,n);n=(t=[t.substr(0,r),i,t.substr(n)])[1],t[1]=e?n?n+"&"+e:e:n,t=t[0]+(t[1]?"?"+t[1]:"")+t[2]}return t}return Ty(t,e,n),t}function wm(t){this.f=[],this.F=new Wy,this.ga=this.pa=this.B=this.ha=this.a=this.I=this.j=this.V=this.g=this.J=this.i=null,this.Qa=this.P=0,this.Oa=!!zf("internalChannelParams.failFast",t),this.ia=this.w=this.s=this.l=this.h=this.c=null,this.oa=!0,this.m=this.ra=this.O=-1,this.S=this.v=this.A=0,this.Na=zf("internalChannelParams.baseRetryDelayMs",t)||5e3,this.Ra=zf("internalChannelParams.retryDelaySeedMs",t)||1e4,this.Pa=zf("internalChannelParams.forwardChannelMaxRetries",t)||2,this.qa=zf("internalChannelParams.forwardChannelRequestTimeoutMs",t)||2e4,this.Ka=t&&t.zb||void 0,this.D=void 0,this.R=t&&t.supportsCrossDomainXhr||!1,this.H="",this.b=new zy(t&&t.concurrentRequestLimit),this.ja=new rm,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 _m(t){if(Em(t),3==t.u){var e=t.P++,n=vy(t.B);Ty(n,"SID",t.H),Ty(n,"RID",e),Ty(n,"TYPE","terminate"),Cm(t,n),(e=new Xd(t,e,void 0)).F=2,e.f=Iy(vy(n)),n=!1,Kf.navigator&&Kf.navigator.sendBeacon&&(n=Kf.navigator.sendBeacon(e.f.toString(),"")),!n&&Kf.Image&&((new Image).src=e.f,n=!0),n||(e.a=e.g.$(null),e.a.ca(e.f)),e.v=op(),oy(e)}xm(t)}function Em(t){t.w&&(t.w.abort(),t.w=null),t.a&&(t.a.cancel(),t.a=null),t.l&&(Kf.clearTimeout(t.l),t.l=null),Rm(t),t.b.cancel(),t.h&&(Hf(t.h)&&Kf.clearTimeout(t.h),t.h=null)}function Tm(t,e){t.f.push(new Hy(t.Qa++,e)),3==t.u&&Sm(t)}function Sm(t){Xy(t.b)||t.h||(t.h=!0,bd(t.Ha,t),t.A=0)}function Im(t,e){var n;n=e?e.W:t.P++;var r=vy(t.B);Ty(r,"SID",t.H),Ty(r,"RID",n),Ty(r,"AID",t.O),Cm(t,r),t.g&&t.i&&bm(r,t.g,t.i),n=new Xd(t,n,t.A+1),null===t.g&&(n.h=t.i),e&&(t.f=e.j.concat(t.f)),e=Nm(t,n,1e3),n.setTimeout(Math.round(.5*t.qa)+Math.round(.5*t.qa*Math.random())),Zy(t.b,n),ty(n,r,e)}function Cm(t,n){t.c&&ly({},function(t,e){Ty(n,e,t)})}function Nm(t,e,n){n=Math.min(t.f.length,n);var r=t.c?rp(t.c.Sa,t.c,t):null;t:for(var i=t.f,o=-1;;){var a=["count="+n];-1==o?0<n?(o=i[0].b,a.push("ofs="+o)):o=0:a.push("ofs="+o);for(var s=!0,u=0;u<n;u++){var c=i[u].b,h=i[u].a;if((c-=o)<0)o=Math.max(0,i[u].b-100),s=!1;else try{im(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 Am(t){t.a||t.l||(t.S=1,bd(t.Ga,t),t.v=0)}function Dm(t){return!(t.a||t.l||3<=t.v)&&(t.S++,t.l=Vd(rp(t.Ga,t),Om(t,t.v)),t.v++,!0)}function km(t,e,n){var r=e.l;r&&Yy(t.b,r),t.ia=t.oa&&n,t.m=e.c,t.B=Mm(t,null,t.ha),Sm(t)}function Rm(t){null!=t.s&&(Kf.clearTimeout(t.s),t.s=null)}function Om(t,e){var n=t.Na+Math.floor(Math.random()*t.Ra);return t.ma()||(n*=2),n*e}function Pm(t,e){if(2==e){var n=null;t.c&&(n=null);var r=rp(t.eb,t);n||(n=new gy("//www.google.com/images/cleardot.gif"),Kf.location&&"http"==Kf.location.protocol||by(n,"https"),Iy(n)),function(t,e){var n=new Od;if(Kf.Image){var r=new Image;r.onload=ip(om,n,r,"TestLoadImage: loaded",!0,e),r.onerror=ip(om,n,r,"TestLoadImage: error",!1,e),r.onabort=ip(om,n,r,"TestLoadImage: abort",!1,e),r.ontimeout=ip(om,n,r,"TestLoadImage: timeout",!1,e),Kf.setTimeout(function(){r.ontimeout&&r.ontimeout()},1e4),r.src=t}else e(!1)}(n.toString(),r)}else Fd(2);t.u=0,t.c&&t.c.ta(e),xm(t),Em(t)}function xm(t){t.u=0,t.m=-1,t.c&&(0==em(t.b).length&&0==t.f.length||(t.b.c.length=0,lp(t.f),t.f.length=0),t.c.sa())}function Mm(t,e,n){var r=function(t){return t instanceof gy?vy(t):new gy(t,void 0)}(n);if(""!=r.b)e&&wy(r,e+"."+r.b),_y(r,r.i);else{var i,o=Kf.location;i=e?e+"."+o.hostname:o.hostname,r=function(t,e,n,r){var i=new gy(null,void 0);return t&&by(i,t),e&&wy(i,e),n&&_y(i,n),r&&(i.a=r),i}(o.protocol,i,+o.port,n)}return t.V&&bp(t.V,function(t,e){Ty(r,e,t)}),e=t.j,n=t.I,e&&n&&Ty(r,e,n),Ty(r,"VER",t.wa),Cm(t,r),r}function Lm(){}function Fm(){if(Np&&!(10<=Number(Lp)))throw Error("Environmental error: no available transport.")}function Um(t,e){hd.call(this),this.a=new wm(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)&&!fp(t)&&(this.a.g=t),this.l=e&&e.supportsCrossDomainXhr||!1,this.h=e&&e.sendRawJson||!1,(e=e&&e.httpSessionIdParam)&&!fp(e)&&(this.a.j=e,null!==(t=this.b)&&e in t&&(e in(t=this.b)&&delete t[e])),this.f=new Bm(this)}function Vm(t){zd.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 qm(){Gd.call(this),this.status=1}function Bm(t){this.a=t}(Bf=sm.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?Wd(this.H):Wd(Qd),this.a.onreadystatechange=rp(this.Ea,this);try{this.w=!0,this.a.open(e,String(t),!0),this.w=!1}catch(t){return void fm(this,t)}t=n||"";var i=new fy(this.headers);r&&ly(r,function(t,e){i.set(e,t)}),r=function(t){t:{for(var e=lm,n=t.length,r=Qf(t)?t.split(""):t,i=0;i<n;i++)if(i in r&&e.call(void 0,r[i],i,t)){e=i;break t}e=-1}return e<0?null:Qf(t)?t.charAt(e):t[e]}(i.K()),n=Kf.FormData&&t instanceof Kf.FormData,0<=up(hm,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{mm(this),0<this.o&&((this.D=function(t){return Np&&Up(9)&&Hf(t.timeout)&&void 0!==t.ontimeout}(this.a))?(this.a.timeout=this.o,this.a.ontimeout=rp(this.Ba,this)):this.m=Id(this.Ba,this.o,this)),this.l=!0,this.a.send(t),this.l=!1}catch(t){fm(this,t)}},Bf.Ba=function(){void 0!==Wf&&this.a&&(this.f="Timed out after "+this.o+"ms, aborting",this.h=8,this.dispatchEvent("timeout"),this.abort(8))},Bf.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"),ym(this))},Bf.G=function(){this.a&&(this.b&&(this.b=!1,this.g=!0,this.a.abort(),this.g=!1),ym(this,!0)),sm.N.G.call(this)},Bf.Ea=function(){this.j||(this.w||this.l||this.g?dm(this):this.Za())},Bf.Za=function(){dm(this)},Bf.T=function(){try{return 2<gm(this)?this.a.status:-1}catch(t){return-1}},Bf.aa=function(){try{return this.a?this.a.responseText:""}catch(t){return""}},Bf.Ua=function(t){if(this.a){var e=this.a.responseText;return t&&0==e.indexOf(t)&&(e=e.substring(t.length)),am(e)}},Bf.ya=function(){return this.h},Bf.Xa=function(){return Qf(this.f)?this.f:String(this.f)},(Bf=wm.prototype).wa=8,Bf.u=1,Bf.Ca=function(){return 0==this.u},Bf.Ha=function(t){if(this.h)if(this.h=null,1==this.u){if(!t){this.P=Math.floor(1e5*Math.random()),t=this.P++;var e,n=new Xd(this,t,void 0),r=this.i;if(this.J&&(r?Ep(r=wp(r),this.J):r=this.J),null===this.g&&(n.h=r),this.W)t:{for(var i=e=0;i<this.f.length;i++){var o=this.f[i];if(void 0===(o="__data__"in o.a&&Qf(o=o.a.__data__)?o.length:void 0))break;if(4096<(e+=o)){e=i;break t}if(4096===e||i===this.f.length-1){e=i+1;break t}}e=1e3}else e=1e3;e=Nm(this,n,e),Ty(i=vy(this.B),"RID",t),Ty(i,"CVER",22),this.o&&this.j&&Ty(i,"X-HTTP-Session-Id",this.j),Cm(this,i),this.g&&r&&bm(i,this.g,r),Zy(this.b,n),this.W?(Ty(i,"$req",e),Ty(i,"SID","null"),n.S=!0,ty(n,i,null)):ty(n,i,e),this.u=2}}else 3==this.u&&(t?Im(this,t):0==this.f.length||Xy(this.b)||Im(this))},Bf.Ga=function(){this.l=null,this.a=new Xd(this,"rpc",this.S),null===this.g&&(this.a.h=this.i),this.a.J=0;var t=vy(this.pa);Ty(t,"RID","rpc"),Ty(t,"SID",this.H),Ty(t,"CI",this.ia?"0":"1"),Ty(t,"AID",this.O),Cm(this,t),Ty(t,"TYPE","xmlhttp"),this.g&&this.i&&bm(t,this.g,this.i),this.D&&this.a.setTimeout(this.D),ey(this.a,t,!0,this.ga)},Bf.Fa=function(t,e){if(0!=this.u&&(this.a==t||$y(this.b,t)))if(this.m=t.o,!t.s&&$y(this.b,t)&&3==this.u){try{var n=this.ja.a.parse(e)}catch(t){n=null}if(Xf(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;Rm(this),this.a.cancel(),this.a=null}Dm(this),Fd(18)}}else this.ra=e[1],0<this.ra-this.O&&e[2]<37500&&this.ia&&0==this.v&&!this.s&&(this.s=Vd(rp(this.Ya,this),6e3));if(Jy(this.b)<=1&&this.fa){try{this.fa()}catch(t){}this.fa=void 0}}else Pm(this,11)}else if(!t.s&&this.a!=t||Rm(this),!fp(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])&&Hf(r)&&0<r&&(this.D=1.5*r),this.o&&(r=t.a)&&((i=vm(r,"X-Client-Wire-Protocol"))&&Yy(this.b,i),this.j&&(r=vm(r,"X-HTTP-Session-Id")))&&(this.I=r,Ty(this.B,this.j,r)),this.u=3,this.c&&this.c.va(),r=t,this.pa=Mm(this,this.Y()?this.ga:null,this.ha),r.s?(tm(this.b,r),(i=this.D)&&r.setTimeout(i),r.i&&(sy(r),oy(r)),this.a=r):Am(this),0<this.f.length&&Sm(this)}else"stop"!=r[0]&&"close"!=r[0]||Pm(this,7);else 3==this.u&&("stop"==r[0]||"close"==r[0]?"stop"==r[0]?Pm(this,7):_m(this):"noop"!=r[0]&&this.c&&this.c.ua(r),this.v=0)}},Bf.Ya=function(){null!=this.s&&(this.s=null,this.a.cancel(),this.a=null,Dm(this),Fd(19))},Bf.na=function(t){var e=null;if(this.a==t){Rm(this),this.a=null;var n=2}else{if(!$y(this.b,t))return;e=t.j,tm(this.b,t),n=1}if(this.m=t.o,0!=this.u)if(t.b)1==n?(e=op()-t.v,Pd.dispatchEvent(new Ud(Pd,t.l?t.l.length:0,e,this.A)),Sm(this)):Am(this);else{var r=t.c;if(3==r||0==r&&0<this.m||!(1==n&&function(t,e){return!(Jy(t.b)>=t.b.f-(t.h?1:0))&&(t.h?(t.f=e.j.concat(t.f),!0):!(1==t.u||2==t.u||t.A>=(t.Oa?0:t.Pa))&&(t.h=Vd(rp(t.Ha,t,e),Om(t,t.A)),t.A++,!0))}(this,t)||2==n&&Dm(this)))switch(e&&0<e.length&&(t=this.b,t.c=t.c.concat(e)),r){case 1:Pm(this,5);break;case 4:Pm(this,10);break;case 3:Pm(this,6);break;default:Pm(this,2)}}},Bf.eb=function(t){Fd(t?2:1)},Bf.$=function(t){if(t&&!this.R)throw Error("Can't create secondary domain capable XhrIo object.");return(t=new sm(this.Ka)).F=this.R,t},Bf.ma=function(){return!!this.c&&!0},Bf.Y=function(){return this.R},(Bf=Lm.prototype).va=function(){},Bf.ua=function(){},Bf.ta=function(){},Bf.sa=function(){},Bf.Sa=function(){},Fm.prototype.a=function(t,e){return new Um(t,e)},ap(Um,hd),(Bf=Um.prototype).addEventListener=function(t,e,n,r){Um.N.addEventListener.call(this,t,e,n,r)},Bf.removeEventListener=function(t,e,n,r){Um.N.removeEventListener.call(this,t,e,n,r)},Bf.Va=function(){this.a.c=this.f,this.l&&(this.a.R=!0);var t=this.a,e=this.m,n=this.g,r=this.b||void 0;Fd(0),t.ha=n,t.V=r||{},t.o&&(t.F.b=[],t.F.a=!1),t.w=new By(t),null===t.g&&(t.w.h=t.i),n=e,t.g&&t.i&&(n=bm(e,t.g,t.i)),(t=t.w).i=n,e=Mm(t.a,null,t.i),Fd(3),null!=(n=t.a.F.b)?(t.f=n[0],t.M=1,jy(t)):(Sy(e,"MODE","init"),!t.a.o&&t.a.j&&Sy(e,"X-HTTP-Session-Id",t.a.j),t.b=new Xd(t,void 0,void 0),t.b.h=t.h,ey(t.b,e,!1,null),t.M=0)},Bf.close=function(){_m(this.a)},Bf.Wa=function(t){if(Qf(t)){var e={};e.__data__=t,Tm(this.a,e)}else this.h?((e={}).__data__=fd(t),Tm(this.a,e)):Tm(this.a,t)},Bf.G=function(){this.a.c=null,delete this.f,_m(this.a),delete this.a,Um.N.G.call(this)},ap(Vm,zd),ap(qm,Gd),ap(Bm,Lm),Bm.prototype.va=function(){this.a.dispatchEvent("a")},Bm.prototype.ua=function(t){this.a.dispatchEvent(new Vm(t))},Bm.prototype.ta=function(t){this.a.dispatchEvent(new qm(t))},Bm.prototype.sa=function(){this.a.dispatchEvent("b")};var jm=ip(function(t,e){function n(){}n.prototype=t.prototype;var r=new n;return t.apply(r,Array.prototype.slice.call(arguments,1)),r},Fm);Fm.prototype.createWebChannel=Fm.prototype.a,Um.prototype.send=Um.prototype.Wa,Um.prototype.open=Um.prototype.Va,Um.prototype.close=Um.prototype.close,qd.NO_ERROR=0,qd.TIMEOUT=8,qd.HTTP_ERROR=6,Bd.COMPLETE="complete",(Kd.EventType=Hd).OPEN="a",Hd.CLOSE="b",Hd.ERROR="c",Hd.MESSAGE="d",hd.prototype.listen=hd.prototype.za,sm.prototype.listenOnce=sm.prototype.Aa,sm.prototype.getLastError=sm.prototype.Xa,sm.prototype.getLastErrorCode=sm.prototype.ya,sm.prototype.getStatus=sm.prototype.T,sm.prototype.getResponseJson=sm.prototype.Ua,sm.prototype.getResponseText=sm.prototype.aa,sm.prototype.send=sm.prototype.ca;var Wm,Km,Qm={createWebChannelTransport:jm,ErrorCode:qd,EventType:Bd,WebChannel:Kd,XhrIo:sm},Hm=Qm.createWebChannelTransport,zm=Qm.ErrorCode,Gm=Qm.EventType,Ym=Qm.WebChannel,Xm=Qm.XhrIo,Jm=fl.SDK_VERSION,$m=new Cs("@firebase/firestore");function Zm(){return $m.logLevel===vs.DEBUG?Wm.DEBUG:$m.logLevel===vs.SILENT?Wm.SILENT:Wm.ERROR}function tg(t){switch(t){case Wm.DEBUG:$m.logLevel=vs.DEBUG;break;case Wm.ERROR:$m.logLevel=vs.ERROR;break;case Wm.SILENT:$m.logLevel=vs.SILENT;break;default:$m.error("Firestore ("+Jm+"): Invalid value passed to `setLogLevel`")}}function eg(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];if($m.logLevel<=vs.DEBUG){var i=n.map(rg);$m.debug.apply($m,Aa(["Firestore ("+Jm+") ["+t+"]: "+e],i))}}function ng(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if($m.logLevel<=vs.ERROR){var r=e.map(rg);$m.error.apply($m,Aa(["Firestore ("+Jm+"): "+t],r))}}function rg(e){if("string"==typeof e)return e;var t=ag.getPlatform();try{return t.formatJSON(e)}catch(t){return e}}function ig(t){var e="FIRESTORE ("+Jm+") INTERNAL ASSERTION FAILED: "+t;throw ng(e),new Error(e)}function og(t,e){t||ig(e)}(Km=Wm=Wm||{})[Km.DEBUG=0]="DEBUG",Km[Km.ERROR=1]="ERROR",Km[Km.SILENT=2]="SILENT";var ag=(sg.setPlatform=function(t){sg.platform&&ig("Platform already defined"),sg.platform=t},sg.getPlatform=function(){return sg.platform||ig("Platform not set"),sg.platform},sg);function sg(){}function ug(){return ag.getPlatform().emptyByteString}var cg,hg={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"},lg=(_a(fg,cg=Error),fg);function fg(t,e){var n=cg.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 pg(t,e){function n(){var t="This constructor is private.";throw e&&(t+=" ",t+=e),new lg(hg.INVALID_ARGUMENT,t)}for(var r in n.prototype=t.prototype,t)t.hasOwnProperty(r)&&(n[r]=t[r]);return n}function dg(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function yg(t,e){return void 0!==t?t:e}function mg(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 gg(t,e){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e(n,t[n])}function vg(t){for(var e in og(null!=t&&"object"==typeof t,"isEmpty() expects object parameter."),t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}function bg(t,e){if(0!==e.length)throw new lg(hg.INVALID_ARGUMENT,"Function "+t+"() does not support arguments, but was called with "+Fg(e.length,"argument")+".")}function wg(t,e,n){if(e.length!==n)throw new lg(hg.INVALID_ARGUMENT,"Function "+t+"() requires "+Fg(n,"argument")+", but was called with "+Fg(e.length,"argument")+".")}function _g(t,e,n){if(e.length<n)throw new lg(hg.INVALID_ARGUMENT,"Function "+t+"() requires at least "+Fg(n,"argument")+", but was called with "+Fg(e.length,"argument")+".")}function Eg(t,e,n,r){if(e.length<n||e.length>r)throw new lg(hg.INVALID_ARGUMENT,"Function "+t+"() requires between "+n+" and "+r+" arguments, but was called with "+Fg(e.length,"argument")+".")}function Tg(t,e,n,r){Dg(t,e,Lg(n)+" argument",r)}function Sg(t,e,n,r){void 0!==r&&Tg(t,e,n,r)}function Ig(t,e,n,r){Dg(t,e,n+" option",r)}function Cg(t,e,n,r){void 0!==r&&Ig(t,e,n,r)}function Ng(t,e,n,r,i){void 0!==r&&function(t,e,n,r,i){if(!(r instanceof Array))throw new lg(hg.INVALID_ARGUMENT,"Function "+t+"() requires its "+e+" option to be an array, but it was: "+Rg(r));for(var o=0;o<r.length;++o)if(!i(r[o]))throw new lg(hg.INVALID_ARGUMENT,"Function "+t+"() requires all "+e+" elements to be "+n+", but the value at index "+o+" was: "+Rg(r[o]))}(t,e,n,r,i)}function Ag(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(Rg(u))}var c=Rg(r);throw new lg(hg.INVALID_ARGUMENT,"Invalid value "+c+" provided to function "+t+'() for option "'+n+'". Acceptable values: '+o.join(", "))}(t,0,n,r,i)}function Dg(t,e,n,r){if(!("object"===e?kg(r):"non-empty string"===e?"string"==typeof r&&""!==r:typeof r===e)){var i=Rg(r);throw new lg(hg.INVALID_ARGUMENT,"Function "+t+"() requires its "+n+" to be of type "+e+", but it was: "+i)}}function kg(t){return"object"==typeof t&&null!==t&&(Object.getPrototypeOf(t)===Object.prototype||null===Object.getPrototypeOf(t))}function Rg(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":ig("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 Og(t,e,n){if(void 0===n)throw new lg(hg.INVALID_ARGUMENT,"Function "+t+"() requires a valid "+Lg(e)+" argument, but it was undefined.")}function Pg(n,t,r){gg(t,function(t,e){if(r.indexOf(t)<0)throw new lg(hg.INVALID_ARGUMENT,"Unknown option '"+t+"' passed to function "+n+"(). Available options: "+r.join(", "))})}function xg(t,e,n,r){var i=Rg(r);return new lg(hg.INVALID_ARGUMENT,"Function "+t+"() requires its "+Lg(n)+" argument to be a "+e+", but it was: "+i)}function Mg(t,e,n){if(n<=0)throw new lg(hg.INVALID_ARGUMENT,'Function "'+t+'()" requires its '+Lg(e)+" argument to be a positive number, but it was: "+n+".")}function Lg(t){switch(t){case 1:return"first";case 2:return"second";case 3:return"third";default:return t+"th"}}function Fg(t,e){return t+" "+e+(1===t?"":"s")}var Ug=(Vg.newId=function(){for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e="",n=0;n<20;n++)e+=t.charAt(Math.floor(Math.random()*t.length));return og(20===e.length,"Invalid auto ID: "+e),e},Vg);function Vg(){}function qg(t,e){return t<e?-1:e<t?1:0}function Bg(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 jg(t){return t+"\0"}function Wg(){if("undefined"==typeof Uint8Array)throw new lg(hg.UNIMPLEMENTED,"Uint8Arrays are not available in this environment.")}function Kg(){if(!ag.getPlatform().base64Available)throw new lg(hg.UNIMPLEMENTED,"Blobs are unavailable in Firestore in this environment.")}var Qg=(Hg.fromBase64String=function(t){wg("Blob.fromBase64String",arguments,1),Tg("Blob.fromBase64String","string",1,t),Kg();try{return new Hg(ag.getPlatform().atob(t))}catch(t){throw new lg(hg.INVALID_ARGUMENT,"Failed to construct Blob from Base64 string: "+t)}},Hg.fromUint8Array=function(t){if(wg("Blob.fromUint8Array",arguments,1),Wg(),!(t instanceof Uint8Array))throw xg("Blob.fromUint8Array","Uint8Array",1,t);return new Hg(Array.prototype.map.call(t,function(t){return String.fromCharCode(t)}).join(""))},Hg.prototype.toBase64=function(){return wg("Blob.toBase64",arguments,0),Kg(),ag.getPlatform().btoa(this._binaryString)},Hg.prototype.toUint8Array=function(){wg("Blob.toUint8Array",arguments,0),Wg();for(var t=new Uint8Array(this._binaryString.length),e=0;e<this._binaryString.length;e++)t[e]=this._binaryString.charCodeAt(e);return t},Hg.prototype.toString=function(){return"Blob(base64: "+this.toBase64()+")"},Hg.prototype.isEqual=function(t){return this._binaryString===t._binaryString},Hg.prototype._approximateByteSize=function(){return 2*this._binaryString.length},Hg.prototype._compareTo=function(t){return qg(this._binaryString,t._binaryString)},Hg);function Hg(t){Kg(),this._binaryString=t}var zg=pg(Qg,"Use Blob.fromUint8Array() or Blob.fromBase64String() instead."),Gg=function(t,e,n,r,i){this.databaseId=t,this.persistenceKey=e,this.host=n,this.ssl=r,this.forceLongPolling=i},Yg="(default)",Xg=(Object.defineProperty(Jg.prototype,"isDefaultDatabase",{get:function(){return this.database===Yg},enumerable:!0,configurable:!0}),Jg.prototype.isEqual=function(t){return t instanceof Jg&&t.projectId===this.projectId&&t.database===this.database},Jg.prototype.compareTo=function(t){return qg(this.projectId,t.projectId)||qg(this.database,t.database)},Jg);function Jg(t,e){this.projectId=t,this.database=e||Yg}var $g=(Zg.prototype.setPreviousValue=function(t){return this.previousValue=Math.max(t,this.previousValue),this.previousValue},Zg.prototype.next=function(){var t=++this.previousValue;return this.writeNewSequenceNumber&&this.writeNewSequenceNumber(t),t},Zg.INVALID=-1,Zg);function Zg(t,e){var n=this;this.previousValue=t,e&&(e.sequenceNumberHandler=function(t){return n.setPreviousValue(t)},this.writeNewSequenceNumber=function(t){return e.writeSequenceNumber(t)})}var tv="__name__",ev=(Object.defineProperty(nv.prototype,"length",{get:function(){return this.len},enumerable:!0,configurable:!0}),nv.prototype.isEqual=function(t){return 0===nv.comparator(this,t)},nv.prototype.child=function(t){var e=this.segments.slice(this.offset,this.limit());return t instanceof nv?t.forEach(function(t){e.push(t)}):e.push(t),this.construct(e)},nv.prototype.limit=function(){return this.offset+this.length},nv.prototype.popFirst=function(t){return t=void 0===t?1:t,og(this.length>=t,"Can't call popFirst() with less segments"),this.construct(this.segments,this.offset+t,this.length-t)},nv.prototype.popLast=function(){return og(!this.isEmpty(),"Can't call popLast() on empty path"),this.construct(this.segments,this.offset,this.length-1)},nv.prototype.firstSegment=function(){return og(!this.isEmpty(),"Can't call firstSegment() on empty path"),this.segments[this.offset]},nv.prototype.lastSegment=function(){return this.get(this.length-1)},nv.prototype.get=function(t){return og(t<this.length,"Index out of range"),this.segments[this.offset+t]},nv.prototype.isEmpty=function(){return 0===this.length},nv.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},nv.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},nv.prototype.forEach=function(t){for(var e=this.offset,n=this.limit();e<n;e++)t(this.segments[e])},nv.prototype.toArray=function(){return this.segments.slice(this.offset,this.limit())},nv.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},nv);function nv(t,e,n){void 0===e?e=0:e>t.length&&ig("offset "+e+" out of range "+t.length),void 0===n?n=t.length-e:n>t.length-e&&ig("length "+n+" out of range "+(t.length-e)),this.segments=t,this.offset=e,this.len=n}var rv,iv=(_a(ov,rv=ev),ov.prototype.construct=function(t,e,n){return new ov(t,e,n)},ov.prototype.canonicalString=function(){return this.toArray().join("/")},ov.prototype.toString=function(){return this.canonicalString()},ov.fromString=function(t){if(0<=t.indexOf("//"))throw new lg(hg.INVALID_ARGUMENT,"Invalid path ("+t+"). Paths must not contain // in them.");return new ov(t.split("/").filter(function(t){return 0<t.length}))},ov.EMPTY_PATH=new ov([]),ov);function ov(){return null!==rv&&rv.apply(this,arguments)||this}var av,sv=/^[_a-zA-Z][_a-zA-Z0-9]*$/,uv=(_a(cv,av=ev),cv.prototype.construct=function(t,e,n){return new cv(t,e,n)},cv.isValidIdentifier=function(t){return sv.test(t)},cv.prototype.canonicalString=function(){return this.toArray().map(function(t){return t=t.replace("\\","\\\\").replace("`","\\`"),cv.isValidIdentifier(t)||(t="`"+t+"`"),t}).join(".")},cv.prototype.toString=function(){return this.canonicalString()},cv.prototype.isKeyField=function(){return 1===this.length&&this.get(0)===tv},cv.keyField=function(){return new cv([tv])},cv.fromServerFormat=function(t){for(var e=[],n="",r=0,i=function(){if(0===n.length)throw new lg(hg.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 lg(hg.INVALID_ARGUMENT,"Path has trailing escape character: "+t);var s=t[r+1];if("\\"!==s&&"."!==s&&"`"!==s)throw new lg(hg.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 lg(hg.INVALID_ARGUMENT,"Unterminated ` in path: "+t);return new cv(e)},cv.EMPTY_PATH=new cv([]),cv);function cv(){return null!==av&&av.apply(this,arguments)||this}var hv=(lv.prototype.hasCollectionId=function(t){return 2<=this.path.length&&this.path.get(this.path.length-2)===t},lv.prototype.isEqual=function(t){return null!==t&&0===iv.comparator(this.path,t.path)},lv.prototype.toString=function(){return this.path.toString()},lv.comparator=function(t,e){return iv.comparator(t.path,e.path)},lv.isDocumentKey=function(t){return t.length%2==0},lv.fromSegments=function(t){return new lv(new iv(t.slice()))},lv.fromPathString=function(t){return new lv(iv.fromString(t))},lv.EMPTY=new lv(new iv([])),lv);function lv(t){this.path=t,og(lv.isDocumentKey(t),"Invalid DocumentKey with an odd number of segments: "+t.toArray().join("/"))}var fv,pv,dv=function(){var n=this;this.promise=new Promise(function(t,e){n.resolve=t,n.reject=e})};(pv=fv=fv||{}).All="all",pv.ListenStreamIdle="listen_stream_idle",pv.ListenStreamConnectionBackoff="listen_stream_connection_backoff",pv.WriteStreamIdle="write_stream_idle",pv.WriteStreamConnectionBackoff="write_stream_connection_backoff",pv.OnlineStateTimeout="online_state_timeout",pv.ClientMetadataRefresh="client_metadata_refresh",pv.LruGarbageCollection="lru_garbage_collection",pv.RetryTransaction="retry_transaction";var yv=(mv.createAndSchedule=function(t,e,n,r,i){var o=new mv(t,e,Date.now()+n,r,i);return o.start(n),o},mv.prototype.start=function(t){var e=this;this.timerHandle=setTimeout(function(){return e.handleDelayElapsed()},t)},mv.prototype.skipDelay=function(){return this.handleDelayElapsed()},mv.prototype.cancel=function(t){null!==this.timerHandle&&(this.clearTimeout(),this.deferred.reject(new lg(hg.CANCELLED,"Operation cancelled"+(t?": "+t:""))))},mv.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()})},mv.prototype.clearTimeout=function(){null!==this.timerHandle&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)},mv);function mv(t,e,n,r,i){this.asyncQueue=t,this.timerId=e,this.targetTimeMs=n,this.op=r,this.removalCallback=i,this.deferred=new dv,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 gv=(Object.defineProperty(vv.prototype,"isShuttingDown",{get:function(){return this._isShuttingDown},enumerable:!0,configurable:!0}),vv.prototype.enqueueAndForget=function(t){this.enqueue(t)},vv.prototype.enqueueAndForgetEvenAfterShutdown=function(t){this.verifyNotFailed(),this.enqueueInternal(t)},vv.prototype.enqueueEvenAfterShutdown=function(t){return this.verifyNotFailed(),this.enqueueInternal(t)},vv.prototype.enqueueAndInitiateShutdown=function(e){return Ta(this,void 0,void 0,function(){return Sa(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]}})})},vv.prototype.enqueue=function(t){return this.verifyNotFailed(),this._isShuttingDown?new Promise(function(t){}):this.enqueueInternal(t)},vv.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 ng("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},vv.prototype.enqueueAfterDelay=function(t,e,n){var r=this;this.verifyNotFailed(),og(0<=e,"Attempted to schedule an operation with a negative delay of "+e),-1<this.timerIdsToSkip.indexOf(t)&&(e=0);var i=yv.createAndSchedule(this,t,e,n,function(t){return r.removeDelayedOperation(t)});return this.delayedOperations.push(i),i},vv.prototype.verifyNotFailed=function(){this.failure&&ig("AsyncQueue is already failed: "+(this.failure.stack||this.failure.message))},vv.prototype.verifyOperationInProgress=function(){og(this.operationInProgress,"verifyOpInProgress() called when no op in progress on this queue.")},vv.prototype.drain=function(){return this.enqueueEvenAfterShutdown(function(){return Promise.resolve()})},vv.prototype.containsDelayedOperation=function(t){for(var e=0,n=this.delayedOperations;e<n.length;e++)if(n[e].timerId===t)return!0;return!1},vv.prototype.runDelayedOperationsEarly=function(r){var i=this;return this.drain().then(function(){og(r===fv.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!==fv.All&&n.timerId===r)break}return i.drain()})},vv.prototype.skipDelaysForTimerId=function(t){this.timerIdsToSkip.push(t)},vv.prototype.removeDelayedOperation=function(t){var e=this.delayedOperations.indexOf(t);og(0<=e,"Delayed operation not found."),this.delayedOperations.splice(e,1)},vv);function vv(){this.tail=Promise.resolve(),this._isShuttingDown=!1,this.delayedOperations=[],this.failure=null,this.operationInProgress=!1,this.timerIdsToSkip=[]}var bv="",wv="",_v="",Ev="";function Tv(t){for(var e="",n=0;n<t.length;n++)0<e.length&&(e=Iv(e)),e=Sv(t.get(n),e);return Iv(e)}function Sv(t,e){for(var n=e,r=t.length,i=0;i<r;i++){var o=t.charAt(i);switch(o){case"\0":n+=bv+_v;break;case bv:n+=bv+Ev;break;default:n+=o}}return n}function Iv(t){return t+bv+wv}function Cv(t){var e=t.length;if(og(2<=e,"Invalid path "+t),2===e)return og(t.charAt(0)===bv&&t.charAt(1)===wv,"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(bv,o);switch((a<0||n<a)&&ig('Invalid encoded resource path: "'+t+'"'),t.charAt(a+1)){case wv:var s=t.substring(o,a),u=void 0;0===i.length?u=s:(u=i+=s,i=""),r.push(u);break;case _v:i+=t.substring(o,a),i+="\0";break;case Ev:i+=t.substring(o,a+1);break;default:ig('Invalid encoded resource path: "'+t+'"')}o=a+2}return new iv(r)}var Nv=(Av.now=function(){return Av.fromMillis(Date.now())},Av.fromDate=function(t){return Av.fromMillis(t.getTime())},Av.fromMillis=function(t){var e=Math.floor(t/1e3);return new Av(e,1e6*(t-1e3*e))},Av.prototype.toDate=function(){return new Date(this.toMillis())},Av.prototype.toMillis=function(){return 1e3*this.seconds+this.nanoseconds/1e6},Av.prototype._compareTo=function(t){return this.seconds===t.seconds?qg(this.nanoseconds,t.nanoseconds):qg(this.seconds,t.seconds)},Av.prototype.isEqual=function(t){return t.seconds===this.seconds&&t.nanoseconds===this.nanoseconds},Av.prototype.toString=function(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"},Av);function Av(t,e){if(this.seconds=t,(this.nanoseconds=e)<0)throw new lg(hg.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(1e9<=e)throw new lg(hg.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(t<-62135596800)throw new lg(hg.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t);if(253402300800<=t)throw new lg(hg.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t)}var Dv=(kv.fromMicroseconds=function(t){var e=Math.floor(t/1e6);return new kv(new Nv(e,t%1e6*1e3))},kv.fromTimestamp=function(t){return new kv(t)},kv.forDeletedDoc=function(){return kv.MIN},kv.prototype.compareTo=function(t){return this.timestamp._compareTo(t.timestamp)},kv.prototype.isEqual=function(t){return this.timestamp.isEqual(t.timestamp)},kv.prototype.toMicroseconds=function(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3},kv.prototype.toString=function(){return"SnapshotVersion("+this.timestamp.toString()+")"},kv.prototype.toTimestamp=function(){return this.timestamp},kv.MIN=new kv(new Nv(0,0)),kv);function kv(t){this.timestamp=t}var Rv=(Ov.prototype.insert=function(t,e){return new Ov(this.comparator,this.root.insert(t,e,this.comparator).copy(null,null,Mv.BLACK,null,null))},Ov.prototype.remove=function(t){return new Ov(this.comparator,this.root.remove(t,this.comparator).copy(null,null,Mv.BLACK,null,null))},Ov.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},Ov.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},Ov.prototype.isEmpty=function(){return this.root.isEmpty()},Object.defineProperty(Ov.prototype,"size",{get:function(){return this.root.size},enumerable:!0,configurable:!0}),Ov.prototype.minKey=function(){return this.root.minKey()},Ov.prototype.maxKey=function(){return this.root.maxKey()},Ov.prototype.inorderTraversal=function(t){return this.root.inorderTraversal(t)},Ov.prototype.forEach=function(n){this.inorderTraversal(function(t,e){return n(t,e),!1})},Ov.prototype.toString=function(){var n=[];return this.inorderTraversal(function(t,e){return n.push(t+":"+e),!1}),"{"+n.join(", ")+"}"},Ov.prototype.reverseTraversal=function(t){return this.root.reverseTraversal(t)},Ov.prototype.getIterator=function(){return new Pv(this.root,null,this.comparator,!1)},Ov.prototype.getIteratorFrom=function(t){return new Pv(this.root,t,this.comparator,!1)},Ov.prototype.getReverseIterator=function(){return new Pv(this.root,null,this.comparator,!0)},Ov.prototype.getReverseIteratorFrom=function(t){return new Pv(this.root,t,this.comparator,!0)},Ov);function Ov(t,e){this.comparator=t,this.root=e||Mv.EMPTY}var Pv=(xv.prototype.getNext=function(){og(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},xv.prototype.hasNext=function(){return 0<this.nodeStack.length},xv.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}},xv);function xv(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 Mv=(Lv.prototype.copy=function(t,e,n,r,i){return new Lv(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)},Lv.prototype.isEmpty=function(){return!1},Lv.prototype.inorderTraversal=function(t){return this.left.inorderTraversal(t)||t(this.key,this.value)||this.right.inorderTraversal(t)},Lv.prototype.reverseTraversal=function(t){return this.right.reverseTraversal(t)||t(this.key,this.value)||this.left.reverseTraversal(t)},Lv.prototype.min=function(){return this.left.isEmpty()?this:this.left.min()},Lv.prototype.minKey=function(){return this.min().key},Lv.prototype.maxKey=function(){return this.right.isEmpty()?this.key:this.right.maxKey()},Lv.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()},Lv.prototype.removeMin=function(){if(this.left.isEmpty())return Lv.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()},Lv.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 Lv.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()},Lv.prototype.isRed=function(){return this.color},Lv.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},Lv.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},Lv.prototype.moveRedRight=function(){var t=this.colorFlip();return t.left.left.isRed()&&(t=(t=t.rotateRight()).colorFlip()),t},Lv.prototype.rotateLeft=function(){var t=this.copy(null,null,Lv.RED,null,this.right.left);return this.right.copy(null,null,this.color,t,null)},Lv.prototype.rotateRight=function(){var t=this.copy(null,null,Lv.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,t)},Lv.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)},Lv.prototype.checkMaxDepth=function(){var t=this.check();return Math.pow(2,t)<=this.size+1},Lv.prototype.check=function(){if(this.isRed()&&this.left.isRed())throw ig("Red node has red child("+this.key+","+this.value+")");if(this.right.isRed())throw ig("Right child of ("+this.key+","+this.value+") is red");var t=this.left.check();if(t!==this.right.check())throw ig("Black depths differ");return t+(this.isRed()?0:1)},Lv.EMPTY=null,Lv.RED=!0,Lv.BLACK=!1,Lv);function Lv(t,e,n,r,i){this.key=t,this.value=e,this.color=null!=n?n:Lv.RED,this.left=null!=r?r:Lv.EMPTY,this.right=null!=i?i:Lv.EMPTY,this.size=this.left.size+1+this.right.size}var Fv=(Object.defineProperty(Uv.prototype,"key",{get:function(){throw ig("LLRBEmptyNode has no key.")},enumerable:!0,configurable:!0}),Object.defineProperty(Uv.prototype,"value",{get:function(){throw ig("LLRBEmptyNode has no value.")},enumerable:!0,configurable:!0}),Object.defineProperty(Uv.prototype,"color",{get:function(){throw ig("LLRBEmptyNode has no color.")},enumerable:!0,configurable:!0}),Object.defineProperty(Uv.prototype,"left",{get:function(){throw ig("LLRBEmptyNode has no left child.")},enumerable:!0,configurable:!0}),Object.defineProperty(Uv.prototype,"right",{get:function(){throw ig("LLRBEmptyNode has no right child.")},enumerable:!0,configurable:!0}),Uv.prototype.copy=function(t,e,n,r,i){return this},Uv.prototype.insert=function(t,e,n){return new Mv(t,e)},Uv.prototype.remove=function(t,e){return this},Uv.prototype.isEmpty=function(){return!0},Uv.prototype.inorderTraversal=function(t){return!1},Uv.prototype.reverseTraversal=function(t){return!1},Uv.prototype.minKey=function(){return null},Uv.prototype.maxKey=function(){return null},Uv.prototype.isRed=function(){return!1},Uv.prototype.checkMaxDepth=function(){return!0},Uv.prototype.check=function(){return 0},Uv);function Uv(){this.size=0}Mv.EMPTY=new Fv;var Vv=(qv.fromMapKeys=function(t){var e=new qv(t.comparator);return t.forEach(function(t){e=e.add(t)}),e},qv.prototype.has=function(t){return null!==this.data.get(t)},qv.prototype.first=function(){return this.data.minKey()},qv.prototype.last=function(){return this.data.maxKey()},Object.defineProperty(qv.prototype,"size",{get:function(){return this.data.size},enumerable:!0,configurable:!0}),qv.prototype.indexOf=function(t){return this.data.indexOf(t)},qv.prototype.forEach=function(n){this.data.inorderTraversal(function(t,e){return n(t),!1})},qv.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)}},qv.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},qv.prototype.firstAfterOrEqual=function(t){var e=this.data.getIteratorFrom(t);return e.hasNext()?e.getNext().key:null},qv.prototype.getIterator=function(){return new Bv(this.data.getIterator())},qv.prototype.getIteratorFrom=function(t){return new Bv(this.data.getIteratorFrom(t))},qv.prototype.add=function(t){return this.copy(this.data.remove(t).insert(t,!0))},qv.prototype.delete=function(t){return this.has(t)?this.copy(this.data.remove(t)):this},qv.prototype.isEmpty=function(){return this.data.isEmpty()},qv.prototype.unionWith=function(t){var e=this;return t.forEach(function(t){e=e.add(t)}),e},qv.prototype.isEqual=function(t){if(!(t instanceof qv))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},qv.prototype.toArray=function(){var e=[];return this.forEach(function(t){e.push(t)}),e},qv.prototype.toString=function(){var e=[];return this.forEach(function(t){return e.push(t)}),"SortedSet("+e.toString()+")"},qv.prototype.copy=function(t){var e=new qv(this.comparator);return e.data=t,e},qv);function qv(t){this.comparator=t,this.data=new Rv(this.comparator)}var Bv=(jv.prototype.getNext=function(){return this.iter.getNext().key},jv.prototype.hasNext=function(){return this.iter.hasNext()},jv);function jv(t){this.iter=t}var Wv=new Rv(hv.comparator);function Kv(){return Wv}function Qv(){return Kv()}var Hv=new Rv(hv.comparator);function zv(){return Hv}var Gv=new Rv(hv.comparator);function Yv(){return Gv}var Xv=new Vv(hv.comparator);function Jv(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=Xv,r=0,i=t;r<i.length;r++){var o=i[r];n=n.add(o)}return n}var $v=new Vv(qg);function Zv(){return $v}var tb=(eb.prototype.applyToRemoteDocument=function(t,e,n){e&&og(e.key.isEqual(t),"applyToRemoteDocument: key "+t+" should match maybeDoc key\n "+e.key);var r=n.mutationResults;og(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},eb.prototype.applyToLocalView=function(t,e){e&&og(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},eb.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},eb.prototype.keys=function(){return this.mutations.reduce(function(t,e){return t.add(e.key)},Jv())},eb.prototype.isEqual=function(t){return this.batchId===t.batchId&&Bg(this.mutations,t.mutations)&&Bg(this.baseMutations,t.baseMutations)},eb);function eb(t,e,n,r){this.batchId=t,this.localWriteTime=e,this.baseMutations=n,og(0<(this.mutations=r).length,"Cannot create an empty mutation batch")}var nb=(rb.from=function(t,e,n,r){og(t.mutations.length===n.length,"Mutations sent "+t.mutations.length+" must equal results received "+n.length);for(var i=Yv(),o=t.mutations,a=0;a<o.length;a++)i=i.insert(o[a].key,n[a].version);return new rb(t,e,n,r,i)},rb);function rb(t,e,n,r,i){this.batch=t,this.commitVersion=e,this.mutationResults=n,this.streamToken=r,this.docVersions=i}var ib=(ob.prototype.catch=function(t){return this.next(void 0,t)},ob.prototype.next=function(r,i){var o=this;return this.callbackAttached&&ig("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 ob(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)}})},ob.prototype.toPromise=function(){var n=this;return new Promise(function(t,e){n.next(t,e)})},ob.prototype.wrapUserFunction=function(t){try{var e=t();return e instanceof ob?e:ob.resolve(e)}catch(t){return ob.reject(t)}},ob.prototype.wrapSuccess=function(t,e){return t?this.wrapUserFunction(function(){return t(e)}):ob.resolve(e)},ob.prototype.wrapFailure=function(t,e){return t?this.wrapUserFunction(function(){return t(e)}):ob.reject(e)},ob.resolve=function(n){return new ob(function(t,e){t(n)})},ob.reject=function(n){return new ob(function(t,e){e(n)})},ob.waitFor=function(t){return new ob(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()})},ob.or=function(t){for(var n=ob.resolve(!1),e=function(e){n=n.next(function(t){return t?ob.resolve(t):e()})},r=0,i=t;r<i.length;r++)e(i[r]);return n},ob.forEach=function(t,n){var r=this,i=[];return t.forEach(function(t,e){i.push(n.call(r,t,e))}),this.waitFor(i)},ob);function ob(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 ab="SimpleDb",sb=(ub.openOrCreate=function(o,t,a){return og(ub.isAvailable(),"IndexedDB not supported in current environment."),eg(ab,"Opening database:",o),new ib(function(n,r){var i=window.indexedDB.open(o,t);i.onsuccess=function(t){var e=t.target.result;n(new ub(e))},i.onblocked=function(){r(new lg(hg.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 lg(hg.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){eg(ab,'Database "'+o+'" requires upgrade from version:',t.oldVersion);var e=t.target.result;a.createOrUpgrade(e,i.transaction,t.oldVersion,D_).next(function(){eg(ab,"Database upgrade to version "+D_+" complete")})}}).toPromise()},ub.delete=function(t){return eg(ab,"Removing database:",t),yb(window.indexedDB.deleteDatabase(t)).toPromise()},ub.isAvailable=function(){if("undefined"==typeof window||null==window.indexedDB)return!1;if(ub.isMockPersistence())return!0;if(void 0===window.navigator)return!1;var t=Va(),e=ub.getIOSVersion(t),n=0<e&&e<10,r=ub.getAndroidVersion(t),i=0<r&&r<4.5;return!(0<t.indexOf("MSIE ")||0<t.indexOf("Trident/")||0<t.indexOf("Edge/")||n||i)},ub.isMockPersistence=function(){var t;return"undefined"!=typeof process&&"YES"===(null===(t=process.env)||void 0===t?void 0:t.USE_MOCK_PERSISTENCE)},ub.getStore=function(t,e){return t.store(e)},ub.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)},ub.getAndroidVersion=function(t){var e=t.match(/Android ([\d.]+)/i),n=e?e[1].split(".").slice(0,2).join("."):"-1";return Number(n)},ub.prototype.setVersionChangeListener=function(e){this.db.onversionchange=function(t){return e(t)}},ub.prototype.runTransaction=function(r,c,h){return Ta(this,void 0,void 0,function(){var o,a,s,e,u,n;return Sa(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 Sa(this,function(t){switch(t.label){case 0:++s,e=lb.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),ib.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,eg(ab,"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]}})})},ub.prototype.close=function(){this.db.close()},ub);function ub(t){this.db=t,12.2===ub.getIOSVersion(Va())&&ng("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 cb=(Object.defineProperty(hb.prototype,"isDone",{get:function(){return this.shouldStop},enumerable:!0,configurable:!0}),Object.defineProperty(hb.prototype,"skipToKey",{get:function(){return this.nextKey},enumerable:!0,configurable:!0}),Object.defineProperty(hb.prototype,"cursor",{set:function(t){this.dbCursor=t},enumerable:!0,configurable:!0}),hb.prototype.done=function(){this.shouldStop=!0},hb.prototype.skip=function(t){this.nextKey=t},hb.prototype.delete=function(){return yb(this.dbCursor.delete())},hb);function hb(t){this.dbCursor=t,this.shouldStop=!1,this.nextKey=null}var lb=(fb.open=function(t,e,n){return new fb(t.transaction(n,e))},Object.defineProperty(fb.prototype,"completionPromise",{get:function(){return this.completionDeferred.promise},enumerable:!0,configurable:!0}),fb.prototype.abort=function(t){t&&this.completionDeferred.reject(t),this.aborted||(eg(ab,"Aborting transaction:",t?t.message:"Client-initiated abort"),this.aborted=!0,this.transaction.abort())},fb.prototype.store=function(t){var e=this.transaction.objectStore(t);return og(!!e,"Object store not part of transaction: "+t),new pb(e)},fb);function fb(t){var n=this;this.transaction=t,this.aborted=!1,this.completionDeferred=new dv,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=gb(t.target.error);n.completionDeferred.reject(e)}}var pb=(db.prototype.put=function(t,e){return yb(void 0!==e?(eg(ab,"PUT",this.store.name,t,e),this.store.put(e,t)):(eg(ab,"PUT",this.store.name,"<auto-key>",t),this.store.put(t)))},db.prototype.add=function(t){return eg(ab,"ADD",this.store.name,t,t),yb(this.store.add(t))},db.prototype.get=function(e){var n=this;return yb(this.store.get(e)).next(function(t){return void 0===t&&(t=null),eg(ab,"GET",n.store.name,e,t),t})},db.prototype.delete=function(t){return eg(ab,"DELETE",this.store.name,t),yb(this.store.delete(t))},db.prototype.count=function(){return eg(ab,"COUNT",this.store.name),yb(this.store.count())},db.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})},db.prototype.deleteAll=function(t,e){eg(ab,"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()})},db.prototype.iterate=function(t,e){var n;e?n=t:(n={},e=t);var r=this.cursor(n);return this.iterateCursor(r,e)},db.prototype.iterateSerial=function(i){var t=this.cursor({});return new ib(function(n,r){t.onerror=function(t){var e=gb(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()}})},db.prototype.iterateCursor=function(t,a){var s=[];return new ib(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 cb(e),r=a(e.primaryKey,e.value,n);if(r instanceof ib){var i=r.catch(function(t){return n.done(),ib.reject(t)});s.push(i)}n.isDone?o():null===n.skipToKey?e.continue():e.continue(n.skipToKey)}else o()}}).next(function(){return ib.waitFor(s)})},db.prototype.options=function(t,e){var n=void 0;return void 0!==t&&("string"==typeof t?n=t:(og(void 0===e,"3rd argument must not be defined if 2nd is a range."),e=t)),{index:n,range:e}},db.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)},db);function db(t){this.store=t}function yb(t){return new ib(function(n,r){t.onsuccess=function(t){var e=t.target.result;n(e)},t.onerror=function(t){var e=gb(t.target.error);r(e)}})}var mb=!1;function gb(t){var e=sb.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 lg("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 mb||(mb=!0,setTimeout(function(){throw r},0)),r}}return t}var vb=(bb.forUser=function(t,e,n,r){return og(""!==t.uid,"UserID must not be an empty string."),new bb(t.isAuthenticated()?t.uid:"",e,n,r)},bb.prototype.checkEmpty=function(t){var r=!0,e=IDBKeyRange.bound([this.userId,Number.NEGATIVE_INFINITY],[this.userId,Number.POSITIVE_INFINITY]);return Tb(t).iterate({index:F_.userMutationsIndex,range:e},function(t,e,n){r=!1,n.done()}).next(function(){return r})},bb.prototype.acknowledgeBatch=function(e,t,n){return this.getMutationQueueMetadata(e).next(function(t){return t.lastStreamToken=Eb(n),Ib(e).put(t)})},bb.prototype.getLastStreamToken=function(t){return this.getMutationQueueMetadata(t).next(function(t){return t.lastStreamToken})},bb.prototype.setLastStreamToken=function(e,n){return this.getMutationQueueMetadata(e).next(function(t){return t.lastStreamToken=Eb(n),Ib(e).put(t)})},bb.prototype.addMutationBatch=function(c,h,l,f){var p=this,d=Sb(c),y=Tb(c);return y.add({}).next(function(t){og("number"==typeof t,"Auto-generated key is not a number");for(var e=new tb(t,h,l,f),n=p.serializer.toDbMutationBatch(p.userId,e),r=[],i=new Vv(function(t,e){return qg(t.canonicalString(),e.canonicalString())}),o=0,a=f;o<a.length;o++){var s=a[o],u=V_.key(p.userId,s.key.path,t);i=i.add(s.key.path.popLast()),r.push(y.put(n)),r.push(d.put(u,V_.PLACEHOLDER))}return i.forEach(function(t){r.push(p.indexManager.addToCollectionParentIndex(c,t))}),c.addOnCommittedListener(function(){p.documentKeysByBatchId[t]=e.keys()}),ib.waitFor(r).next(function(){return e})})},bb.prototype.lookupMutationBatch=function(t,e){var n=this;return Tb(t).get(e).next(function(t){return t?(og(t.userId===n.userId,"Unexpected user '"+t.userId+"' for mutation batch "+e),n.serializer.fromDbMutationBatch(t)):null})},bb.prototype.lookupMutationKeys=function(t,n){var r=this;return this.documentKeysByBatchId[n]?ib.resolve(this.documentKeysByBatchId[n]):this.lookupMutationBatch(t,n).next(function(t){if(t){var e=t.keys();return r.documentKeysByBatchId[n]=e}return null})},bb.prototype.getNextMutationBatchAfterBatchId=function(t,e){var r=this,i=e+1,n=IDBKeyRange.lowerBound([this.userId,i]),o=null;return Tb(t).iterate({index:F_.userMutationsIndex,range:n},function(t,e,n){e.userId===r.userId&&(og(e.batchId>=i,"Should have found mutation after "+i),o=r.serializer.fromDbMutationBatch(e)),n.done()}).next(function(){return o})},bb.prototype.getHighestUnacknowledgedBatchId=function(t){var e=IDBKeyRange.upperBound([this.userId,Number.POSITIVE_INFINITY]),r=-1;return Tb(t).iterate({index:F_.userMutationsIndex,range:e,reverse:!0},function(t,e,n){r=e.batchId,n.done()}).next(function(){return r})},bb.prototype.getAllMutationBatches=function(t){var e=this,n=IDBKeyRange.bound([this.userId,-1],[this.userId,Number.POSITIVE_INFINITY]);return Tb(t).loadAll(F_.userMutationsIndex,n).next(function(t){return t.map(function(t){return e.serializer.fromDbMutationBatch(t)})})},bb.prototype.getAllMutationBatchesAffectingDocumentKey=function(s,u){var c=this,t=V_.prefixForPath(this.userId,u.path),e=IDBKeyRange.lowerBound(t),h=[];return Sb(s).iterate({range:e},function(e,t,n){var r=e[0],i=e[1],o=e[2],a=Cv(i);if(r===c.userId&&u.path.isEqual(a))return Tb(s).get(o).next(function(t){if(!t)throw ig("Dangling document-mutation reference found: "+e+" which points to "+o);og(t.userId===c.userId,"Unexpected user '"+t.userId+"' for mutation batch "+o),h.push(c.serializer.fromDbMutationBatch(t))});n.done()}).next(function(){return h})},bb.prototype.getAllMutationBatchesAffectingDocumentKeys=function(r,t){var u=this,c=new Vv(qg),i=[];return t.forEach(function(s){var t=V_.prefixForPath(u.userId,s.path),e=IDBKeyRange.lowerBound(t),n=Sb(r).iterate({range:e},function(t,e,n){var r=t[0],i=t[1],o=t[2],a=Cv(i);r===u.userId&&s.path.isEqual(a)?c=c.add(o):n.done()});i.push(n)}),ib.waitFor(i).next(function(){return u.lookupMutationBatches(r,c)})},bb.prototype.getAllMutationBatchesAffectingQuery=function(t,e){var s=this;og(!e.isDocumentQuery(),"Document queries shouldn't go down this path"),og(!e.isCollectionGroupQuery(),"CollectionGroup queries should be handled in LocalDocumentsView");var u=e.path,c=u.length+1,n=V_.prefixForPath(this.userId,u),r=IDBKeyRange.lowerBound(n),h=new Vv(qg);return Sb(t).iterate({range:r},function(t,e,n){var r=t[0],i=t[1],o=t[2],a=Cv(i);r===s.userId&&u.isPrefixOf(a)?a.length===c&&(h=h.add(o)):n.done()}).next(function(){return s.lookupMutationBatches(t,h)})},bb.prototype.lookupMutationBatches=function(t,e){var n=this,r=[],i=[];return e.forEach(function(e){i.push(Tb(t).get(e).next(function(t){if(null===t)throw ig("Dangling document-mutation reference found, which points to "+e);og(t.userId===n.userId,"Unexpected user '"+t.userId+"' for mutation batch "+e),r.push(n.serializer.fromDbMutationBatch(t))}))}),ib.waitFor(i).next(function(){return r})},bb.prototype.removeMutationBatch=function(e,n){var r=this;return _b(e.simpleDbTransaction,this.userId,n).next(function(t){return e.addOnCommittedListener(function(){r.removeCachedMutationKeys(n.batchId)}),ib.forEach(t,function(t){return r.referenceDelegate.removeMutationReference(e,t)})})},bb.prototype.removeCachedMutationKeys=function(t){delete this.documentKeysByBatchId[t]},bb.prototype.performConsistencyCheck=function(n){var o=this;return this.checkEmpty(n).next(function(t){if(!t)return ib.resolve();var e=IDBKeyRange.lowerBound(V_.prefixForUser(o.userId)),i=[];return Sb(n).iterate({range:e},function(t,e,n){if(t[0]===o.userId){var r=Cv(t[1]);i.push(r)}else n.done()}).next(function(){og(0===i.length,"Document leak -- detected dangling mutation references when queue is empty. Dangling keys: "+i.map(function(t){return t.canonicalString()}))})})},bb.prototype.containsKey=function(t,e){return wb(t,this.userId,e)},bb.prototype.getMutationQueueMetadata=function(t){var e=this;return Ib(t).get(this.userId).next(function(t){return t||new M_(e.userId,-1,"")})},bb);function bb(t,e,n,r){this.userId=t,this.serializer=e,this.indexManager=n,this.referenceDelegate=r,this.documentKeysByBatchId={}}function wb(t,o,e){var n=V_.prefixForPath(o,e.path),a=n[1],r=IDBKeyRange.lowerBound(n),s=!1;return Sb(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 _b(t,e,n){var r=t.store(F_.store),i=t.store(V_.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(){og(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=V_.key(e,f.key.path,n.batchId);o.push(i.delete(p)),c.push(f.key)}return ib.waitFor(o).next(function(){return c})}function Eb(t){return t instanceof Uint8Array?(og(sb.isMockPersistence(),"Persisting non-string stream tokens is only supported with mock persistence."),t.toString()):t}function Tb(t){return jE.getStore(t,F_.store)}function Sb(t){return jE.getStore(t,V_.store)}function Ib(t){return jE.getStore(t,M_.store)}var Cb,Nb;(Nb=Cb=Cb||{})[Nb.QueryCache=0]="QueryCache",Nb[Nb.SyncEngine=1]="SyncEngine";var Ab=(Db.prototype.next=function(){var t=this.nextId;return this.nextId+=2,t},Db.prototype.after=function(t){return this.seek(t+2),this.next()},Db.prototype.seek=function(t){og((1&t)===this.generatorId,"Cannot supply target ID from different generator ID"),this.nextId=t},Db.forTargetCache=function(){return new Db(Cb.QueryCache,2)},Db.forSyncEngine=function(){return new Db(Cb.SyncEngine)},Db);function Db(t,e){og((1&(this.generatorId=t))===t,"Generator ID "+t+" contains more than 1 reserved bits"),this.seek(void 0!==e?e:this.generatorId)}var kb=(Rb.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})})},Rb.prototype.getLastRemoteSnapshotVersion=function(t){return this.retrieveMetadata(t).next(function(t){return Dv.fromTimestamp(new Nv(t.lastRemoteSnapshotVersion.seconds,t.lastRemoteSnapshotVersion.nanoseconds))})},Rb.prototype.getHighestSequenceNumber=function(t){return xb(t.simpleDbTransaction)},Rb.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)})},Rb.prototype.addTargetData=function(e,n){var r=this;return this.saveTargetData(e,n).next(function(){return r.retrieveMetadata(e).next(function(t){return t.targetCount+=1,r.updateMetadataFromTargetData(n,t),r.saveMetadata(e,t)})})},Rb.prototype.updateTargetData=function(t,e){return this.saveTargetData(t,e)},Rb.prototype.removeTargetData=function(e,t){var n=this;return this.removeMatchingKeysForTargetId(e,t.targetId).next(function(){return Ob(e).delete(t.targetId)}).next(function(){return n.retrieveMetadata(e)}).next(function(t){return og(0<t.targetCount,"Removing from an empty target cache"),t.targetCount-=1,n.saveMetadata(e,t)})},Rb.prototype.removeTargets=function(r,i,o){var a=this,s=0,u=[];return Ob(r).iterate(function(t,e){var n=a.serializer.fromDbTarget(e);n.sequenceNumber<=i&&null===o.get(n.targetId)&&(s++,u.push(a.removeTargetData(r,n)))}).next(function(){return ib.waitFor(u)}).next(function(){return s})},Rb.prototype.forEachTarget=function(t,r){var i=this;return Ob(t).iterate(function(t,e){var n=i.serializer.fromDbTarget(e);r(n)})},Rb.prototype.retrieveMetadata=function(t){return Pb(t.simpleDbTransaction)},Rb.prototype.saveMetadata=function(t,e){return function(t){return jE.getStore(t,J_.store)}(t).put(J_.key,e)},Rb.prototype.saveTargetData=function(t,e){return Ob(t).put(this.serializer.toDbTarget(e))},Rb.prototype.updateMetadataFromTargetData=function(t,e){var n=!1;return t.targetId>e.highestTargetId&&(e.highestTargetId=t.targetId,n=!0),t.sequenceNumber>e.highestListenSequenceNumber&&(e.highestListenSequenceNumber=t.sequenceNumber,n=!0),n},Rb.prototype.getTargetCount=function(t){return this.retrieveMetadata(t).next(function(t){return t.targetCount})},Rb.prototype.getTargetData=function(t,i){var o=this,e=i.canonicalId(),n=IDBKeyRange.bound([e,Number.NEGATIVE_INFINITY],[e,Number.POSITIVE_INFINITY]),a=null;return Ob(t).iterate({range:n,index:z_.queryTargetsIndexName},function(t,e,n){var r=o.serializer.fromDbTarget(e);i.isEqual(r.target)&&(a=r,n.done())}).next(function(){return a})},Rb.prototype.addMatchingKeys=function(n,t,r){var i=this,o=[],a=Mb(n);return t.forEach(function(t){var e=Tv(t.path);o.push(a.put(new Y_(r,e))),o.push(i.referenceDelegate.addReference(n,t))}),ib.waitFor(o)},Rb.prototype.removeMatchingKeys=function(n,t,r){var i=this,o=Mb(n);return ib.forEach(t,function(t){var e=Tv(t.path);return ib.waitFor([o.delete([r,e]),i.referenceDelegate.removeReference(n,t)])})},Rb.prototype.removeMatchingKeysForTargetId=function(t,e){var n=Mb(t),r=IDBKeyRange.bound([e],[e+1],!1,!0);return n.delete(r)},Rb.prototype.getMatchingKeysForTargetId=function(t,e){var n=IDBKeyRange.bound([e],[e+1],!1,!0),r=Mb(t),o=Jv();return r.iterate({range:n,keysOnly:!0},function(t,e,n){var r=Cv(t[1]),i=new hv(r);o=o.add(i)}).next(function(){return o})},Rb.prototype.containsKey=function(t,e){var n=Tv(e.path),r=IDBKeyRange.bound([n],[jg(n)],!1,!0),i=0;return Mb(t).iterate({index:Y_.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})},Rb.prototype.getTargetDataForTarget=function(t,e){var n=this;return Ob(t).get(e).next(function(t){return t?n.serializer.fromDbTarget(t):null})},Rb);function Rb(t,e){this.referenceDelegate=t,this.serializer=e,this.targetIdGenerator=Ab.forTargetCache()}function Ob(t){return jE.getStore(t,z_.store)}function Pb(t){return sb.getStore(t,J_.store).get(J_.key).next(function(t){return og(null!==t,"Missing metadata row."),t})}function xb(t){return Pb(t).next(function(t){return t.highestListenSequenceNumber})}function Mb(t){return jE.getStore(t,Y_.store)}var Lb=(Fb.fromSet=function(t){return new Fb(t)},Fb.fromArray=function(t){var e=new Vv(uv.comparator);return t.forEach(function(t){return e=e.add(t)}),new Fb(e)},Fb.prototype.covers=function(e){var n=!1;return this.fields.forEach(function(t){t.isPrefixOf(e)&&(n=!0)}),n},Fb.prototype.isEqual=function(t){return this.fields.isEqual(t.fields)},Fb);function Fb(t){this.fields=t}var Ub=(Vb.prototype.isEqual=function(t){return this.field.isEqual(t.field)&&this.transform.isEqual(t.transform)},Vb);function Vb(t,e){this.field=t,this.transform=e}var qb,Bb,jb=function(t,e){this.version=t,this.transformResults=e};(Bb=qb=qb||{})[Bb.Set=0]="Set",Bb[Bb.Patch=1]="Patch",Bb[Bb.Transform=2]="Transform",Bb[Bb.Delete=3]="Delete",Bb[Bb.Verify=4]="Verify";var Wb=(Kb.exists=function(t){return new Kb(void 0,t)},Kb.updateTime=function(t){return new Kb(t)},Object.defineProperty(Kb.prototype,"isNone",{get:function(){return void 0===this.updateTime&&void 0===this.exists},enumerable:!0,configurable:!0}),Kb.prototype.isValidFor=function(t){return void 0!==this.updateTime?t instanceof o_&&t.version.isEqual(this.updateTime):void 0!==this.exists?this.exists===t instanceof o_:(og(this.isNone,"Precondition should be empty"),!0)},Kb.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},Kb.NONE=new Kb,Kb);function Kb(t,e){this.updateTime=t,this.exists=e,og(void 0===t||void 0===e,'Precondition can specify "exists" or "updateTime" but not both')}var Qb=(Hb.prototype.verifyKeyMatches=function(t){null!=t&&og(t.key.isEqual(this.key),"Can only apply a mutation to a document with the same key")},Hb.getPostMutationVersion=function(t){return t instanceof o_?t.version:Dv.MIN},Hb);function Hb(){}var zb,Gb=(_a(Yb,zb=Qb),Yb.prototype.applyToRemoteDocument=function(t,e){this.verifyKeyMatches(t),og(null==e.transformResults,"Transform results received by SetMutation.");var n=e.version;return new o_(this.key,n,{hasCommittedMutations:!0},this.value)},Yb.prototype.applyToLocalView=function(t,e,n){if(this.verifyKeyMatches(t),!this.precondition.isValidFor(t))return t;var r=Qb.getPostMutationVersion(t);return new o_(this.key,r,{hasLocalMutations:!0},this.value)},Yb.prototype.extractBaseValue=function(t){return null},Yb.prototype.isEqual=function(t){return t instanceof Yb&&this.key.isEqual(t.key)&&this.value.isEqual(t.value)&&this.precondition.isEqual(t.precondition)},Yb);function Yb(t,e,n){var r=zb.call(this)||this;return r.key=t,r.value=e,r.precondition=n,r.type=qb.Set,r}var Xb,Jb=(_a($b,Xb=Qb),$b.prototype.applyToRemoteDocument=function(t,e){if(this.verifyKeyMatches(t),og(null==e.transformResults,"Transform results received by PatchMutation."),!this.precondition.isValidFor(t))return new l_(this.key,e.version);var n=this.patchDocument(t);return new o_(this.key,e.version,{hasCommittedMutations:!0},n)},$b.prototype.applyToLocalView=function(t,e,n){if(this.verifyKeyMatches(t),!this.precondition.isValidFor(t))return t;var r=Qb.getPostMutationVersion(t),i=this.patchDocument(t);return new o_(this.key,r,{hasLocalMutations:!0},i)},$b.prototype.extractBaseValue=function(t){return null},$b.prototype.isEqual=function(t){return t instanceof $b&&this.key.isEqual(t.key)&&this.fieldMask.isEqual(t.fieldMask)&&this.precondition.isEqual(t.precondition)},$b.prototype.patchDocument=function(t){var e;return e=t instanceof o_?t.data():Jw.EMPTY,this.patchObject(e)},$b.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},$b);function $b(t,e,n,r){var i=Xb.call(this)||this;return i.key=t,i.data=e,i.fieldMask=n,i.precondition=r,i.type=qb.Patch,i}var Zb,tw=(_a(ew,Zb=Qb),ew.prototype.applyToRemoteDocument=function(t,e){if(this.verifyKeyMatches(t),og(null!=e.transformResults,"Transform results missing for TransformMutation."),!this.precondition.isValidFor(t))return new l_(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 o_(this.key,i,{hasCommittedMutations:!0},o)},ew.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 o_(this.key,r.version,{hasLocalMutations:!0},o)},ew.prototype.extractBaseValue=function(t){for(var e=null,n=0,r=this.fieldTransforms;n<r.length;n++){var i=r[n],o=t instanceof o_?t.field(i.field):void 0,a=i.transform.computeBaseValue(o||null);null!=a&&(e=null==e?Jw.EMPTY.set(i.field,a):e.set(i.field,a))}return e},ew.prototype.isEqual=function(t){return t instanceof ew&&this.key.isEqual(t.key)&&Bg(this.fieldTransforms,t.fieldTransforms)&&this.precondition.isEqual(t.precondition)},ew.prototype.requireDocument=function(t){return og(t instanceof o_,"Unknown MaybeDocument type "+t),og(t.key.isEqual(this.key),"Can only transform a document with the same key"),t},ew.prototype.serverTransformResults=function(t,e){var n=[];og(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 o_&&(a=t.field(i.field)),n.push(o.applyToRemoteDocument(a,e[r]))}return n},ew.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 o_&&(u=e.field(a.field)),null===u&&n instanceof o_&&(u=n.field(a.field)),r.push(s.applyToLocalView(u,t))}return r},ew.prototype.transformObject=function(t,e){og(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},ew);function ew(t,e){var n=Zb.call(this)||this;return n.key=t,n.fieldTransforms=e,n.type=qb.Transform,n.precondition=Wb.exists(!0),n}var nw,rw=(_a(iw,nw=Qb),iw.prototype.applyToRemoteDocument=function(t,e){return this.verifyKeyMatches(t),og(null==e.transformResults,"Transform results received by DeleteMutation."),new u_(this.key,e.version,{hasCommittedMutations:!0})},iw.prototype.applyToLocalView=function(t,e,n){return this.verifyKeyMatches(t),this.precondition.isValidFor(t)?(t&&og(t.key.isEqual(this.key),"Can only apply mutation to document with same key"),new u_(this.key,Dv.forDeletedDoc())):t},iw.prototype.extractBaseValue=function(t){return null},iw.prototype.isEqual=function(t){return t instanceof iw&&this.key.isEqual(t.key)&&this.precondition.isEqual(t.precondition)},iw);function iw(t,e){var n=nw.call(this)||this;return n.key=t,n.precondition=e,n.type=qb.Delete,n}var ow,aw,sw,uw,cw,hw=(_a(lw,ow=Qb),lw.prototype.applyToRemoteDocument=function(t,e){ig("VerifyMutation should only be used in Transactions.")},lw.prototype.applyToLocalView=function(t,e,n){ig("VerifyMutation should only be used in Transactions.")},lw.prototype.extractBaseValue=function(t){ig("VerifyMutation should only be used in Transactions.")},lw.prototype.isEqual=function(t){return t instanceof lw&&this.key.isEqual(t.key)&&this.precondition.isEqual(t.precondition)},lw);function lw(t,e){var n=ow.call(this)||this;return n.key=t,n.precondition=e,n.type=qb.Verify,n}(sw=aw=aw||{})[sw.NullValue=0]="NullValue",sw[sw.BooleanValue=1]="BooleanValue",sw[sw.NumberValue=2]="NumberValue",sw[sw.TimestampValue=3]="TimestampValue",sw[sw.StringValue=4]="StringValue",sw[sw.BlobValue=5]="BlobValue",sw[sw.RefValue=6]="RefValue",sw[sw.GeoPointValue=7]="GeoPointValue",sw[sw.ArrayValue=8]="ArrayValue",sw[sw.ObjectValue=9]="ObjectValue",(cw=uw=uw||{})[cw.Default=0]="Default",cw[cw.Estimate=1]="Estimate",cw[cw.Previous=2]="Previous";var fw=(pw.fromSnapshotOptions=function(t,e){switch(t.serverTimestamps){case"estimate":return new pw(uw.Estimate,e);case"previous":return new pw(uw.Previous,e);case"none":case void 0:return new pw(uw.Default,e);default:return ig("fromSnapshotOptions() called with invalid options.")}},pw);function pw(t,e){this.serverTimestampBehavior=t,this.timestampsInSnapshots=e}var dw=(yw.prototype.toString=function(){var t=this.value();return null===t?"null":t.toString()},yw.prototype.defaultCompareTo=function(t){return og(this.typeOrder!==t.typeOrder,"Default compareTo should not be used for values of same type."),qg(this.typeOrder,t.typeOrder)},yw);function yw(){}var mw,gw=(_a(vw,mw=dw),vw.prototype.value=function(t){return null},vw.prototype.isEqual=function(t){return t instanceof vw},vw.prototype.compareTo=function(t){return t instanceof vw?0:this.defaultCompareTo(t)},vw.prototype.approximateByteSize=function(){return 4},vw.INSTANCE=new vw,vw);function vw(){var t=mw.call(this)||this;return t.typeOrder=aw.NullValue,t.internalValue=null,t}var bw,ww=(_a(_w,bw=dw),_w.prototype.value=function(t){return this.internalValue},_w.prototype.isEqual=function(t){return t instanceof _w&&this.internalValue===t.internalValue},_w.prototype.compareTo=function(t){return t instanceof _w?qg(this,t):this.defaultCompareTo(t)},_w.prototype.approximateByteSize=function(){return 4},_w.of=function(t){return t?_w.TRUE:_w.FALSE},_w.TRUE=new _w(!0),_w.FALSE=new _w(!1),_w);function _w(t){var e=bw.call(this)||this;return e.internalValue=t,e.typeOrder=aw.BooleanValue,e}var Ew,Tw=(_a(Sw,Ew=dw),Sw.prototype.value=function(t){return this.internalValue},Sw.prototype.compareTo=function(t){return t instanceof Sw?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)},Sw.prototype.approximateByteSize=function(){return 8},Sw);function Sw(t){var e=Ew.call(this)||this;return e.internalValue=t,e.typeOrder=aw.NumberValue,e}function Iw(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e}var Cw,Nw=(_a(Aw,Cw=Tw),Aw.prototype.isEqual=function(t){return t instanceof Aw&&Iw(this.internalValue,t.internalValue)},Aw);function Aw(){return null!==Cw&&Cw.apply(this,arguments)||this}var Dw,kw=(_a(Rw,Dw=Tw),Rw.prototype.isEqual=function(t){return t instanceof Rw&&Iw(this.internalValue,t.internalValue)},Rw.NAN=new Rw(NaN),Rw.POSITIVE_INFINITY=new Rw(1/0),Rw.NEGATIVE_INFINITY=new Rw(-1/0),Rw);function Rw(){return null!==Dw&&Dw.apply(this,arguments)||this}var Ow,Pw=(_a(xw,Ow=dw),xw.prototype.value=function(t){return this.internalValue},xw.prototype.isEqual=function(t){return t instanceof xw&&this.internalValue===t.internalValue},xw.prototype.compareTo=function(t){return t instanceof xw?qg(this.internalValue,t.internalValue):this.defaultCompareTo(t)},xw.prototype.approximateByteSize=function(){return 2*this.internalValue.length},xw);function xw(t){var e=Ow.call(this)||this;return e.internalValue=t,e.typeOrder=aw.StringValue,e}var Mw,Lw=(_a(Fw,Mw=dw),Fw.prototype.value=function(t){return!t||t.timestampsInSnapshots?this.internalValue:this.internalValue.toDate()},Fw.prototype.isEqual=function(t){return t instanceof Fw&&this.internalValue.isEqual(t.internalValue)},Fw.prototype.compareTo=function(t){return t instanceof Fw?this.internalValue._compareTo(t.internalValue):t instanceof Vw?-1:this.defaultCompareTo(t)},Fw.prototype.approximateByteSize=function(){return 16},Fw);function Fw(t){var e=Mw.call(this)||this;return e.internalValue=t,e.typeOrder=aw.TimestampValue,e}var Uw,Vw=(_a(qw,Uw=dw),qw.prototype.value=function(t){return t&&t.serverTimestampBehavior===uw.Estimate?new Lw(this.localWriteTime).value(t):t&&t.serverTimestampBehavior===uw.Previous&&this.previousValue?this.previousValue.value(t):null},qw.prototype.isEqual=function(t){return t instanceof qw&&this.localWriteTime.isEqual(t.localWriteTime)},qw.prototype.compareTo=function(t){return t instanceof qw?this.localWriteTime._compareTo(t.localWriteTime):t instanceof Lw?1:this.defaultCompareTo(t)},qw.prototype.toString=function(){return"<ServerTimestamp localTime="+this.localWriteTime.toString()+">"},qw.prototype.approximateByteSize=function(){return 16+(this.previousValue?this.previousValue.approximateByteSize():0)},qw);function qw(t,e){var n=Uw.call(this)||this;return n.localWriteTime=t,n.previousValue=e,n.typeOrder=aw.TimestampValue,n}var Bw,jw=(_a(Ww,Bw=dw),Ww.prototype.value=function(t){return this.internalValue},Ww.prototype.isEqual=function(t){return t instanceof Ww&&this.internalValue.isEqual(t.internalValue)},Ww.prototype.compareTo=function(t){return t instanceof Ww?this.internalValue._compareTo(t.internalValue):this.defaultCompareTo(t)},Ww.prototype.approximateByteSize=function(){return this.internalValue._approximateByteSize()},Ww);function Ww(t){var e=Bw.call(this)||this;return e.internalValue=t,e.typeOrder=aw.BlobValue,e}var Kw,Qw=(_a(Hw,Kw=dw),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:hv.comparator(this.key,t.key)}return this.defaultCompareTo(t)},Hw.prototype.approximateByteSize=function(){return this.databaseId.projectId.length+this.databaseId.database.length+this.key.toString().length},Hw);function Hw(t,e){var n=Kw.call(this)||this;return n.databaseId=t,n.key=e,n.typeOrder=aw.RefValue,n}var zw,Gw=(_a(Yw,zw=dw),Yw.prototype.value=function(t){return this.internalValue},Yw.prototype.isEqual=function(t){return t instanceof Yw&&this.internalValue.isEqual(t.internalValue)},Yw.prototype.compareTo=function(t){return t instanceof Yw?this.internalValue._compareTo(t.internalValue):this.defaultCompareTo(t)},Yw.prototype.approximateByteSize=function(){return 16},Yw);function Yw(t){var e=zw.call(this)||this;return e.internalValue=t,e.typeOrder=aw.GeoPointValue,e}var Xw,Jw=(_a($w,Xw=dw),$w.prototype.value=function(n){var r={};return this.internalValue.inorderTraversal(function(t,e){r[t]=e.value(n)}),r},$w.prototype.forEach=function(t){this.internalValue.inorderTraversal(t)},$w.prototype.isEqual=function(t){if(t instanceof $w){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},$w.prototype.compareTo=function(t){if(t instanceof $w){for(var e=this.internalValue.getIterator(),n=t.internalValue.getIterator();e.hasNext()&&n.hasNext();){var r=e.getNext(),i=n.getNext(),o=qg(r.key,i.key)||r.value.compareTo(i.value);if(o)return o}return qg(e.hasNext(),n.hasNext())}return this.defaultCompareTo(t)},$w.prototype.set=function(t,e){if(og(!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 $w||(n=$w.EMPTY);var r=n.set(t.popFirst(),e);return this.setChild(t.firstSegment(),r)},$w.prototype.delete=function(t){if(og(!t.isEmpty(),"Cannot delete field for empty path on ObjectValue"),1===t.length)return new $w(this.internalValue.remove(t.firstSegment()));var e=this.child(t.firstSegment());if(e instanceof $w){var n=e.delete(t.popFirst());return new $w(this.internalValue.insert(t.firstSegment(),n))}return this},$w.prototype.contains=function(t){return null!==this.field(t)},$w.prototype.field=function(t){og(!t.isEmpty(),"Can't get field of empty path");var e=this;return t.forEach(function(t){e=e instanceof $w?e.internalValue.get(t):null}),e},$w.prototype.fieldMask=function(){var i=new Vv(uv.comparator);return this.internalValue.forEach(function(t,e){var n=new uv([t]);if(e instanceof $w){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)}),Lb.fromSet(i)},$w.prototype.approximateByteSize=function(){var n=0;return this.internalValue.inorderTraversal(function(t,e){n+=t.length+e.approximateByteSize()}),n},$w.prototype.toString=function(){return this.internalValue.toString()},$w.prototype.child=function(t){return this.internalValue.get(t)||void 0},$w.prototype.setChild=function(t,e){return new $w(this.internalValue.insert(t,e))},$w.EMPTY=new $w(new Rv(qg)),$w);function $w(t){var e=Xw.call(this)||this;return e.internalValue=t,e.typeOrder=aw.ObjectValue,e}var Zw,t_=(_a(e_,Zw=dw),e_.prototype.value=function(e){return this.internalValue.map(function(t){return t.value(e)})},e_.prototype.contains=function(t){for(var e=0,n=this.internalValue;e<n.length;e++)if(n[e].isEqual(t))return!0;return!1},e_.prototype.forEach=function(t){this.internalValue.forEach(t)},e_.prototype.isEqual=function(t){if(t instanceof e_){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},e_.prototype.compareTo=function(t){if(t instanceof e_){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 qg(this.internalValue.length,t.internalValue.length)}return this.defaultCompareTo(t)},e_.prototype.approximateByteSize=function(){return this.internalValue.reduce(function(t,e){return t+e.approximateByteSize()},0)},e_.prototype.toString=function(){return"["+this.internalValue.map(function(t){return t.toString()}).join(",")+"]"},e_);function e_(t){var e=Zw.call(this)||this;return e.internalValue=t,e.typeOrder=aw.ArrayValue,e}var n_=(r_.compareByKey=function(t,e){return hv.comparator(t.key,e.key)},r_);function r_(t,e){this.key=t,this.version=e}var i_,o_=(_a(a_,i_=n_),a_.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},a_.prototype.data=function(){var n=this;if(!this.objectValue){var r=Jw.EMPTY;gg(this.proto.fields||{},function(t,e){r=r.set(new uv([t]),n.converter(e))}),this.objectValue=r,this.fieldValueCache=void 0}return this.objectValue},a_.prototype.value=function(){return this.data().value()},a_.prototype.isEqual=function(t){return t instanceof a_&&this.key.isEqual(t.key)&&this.version.isEqual(t.version)&&this.hasLocalMutations===t.hasLocalMutations&&this.hasCommittedMutations===t.hasCommittedMutations&&this.data().isEqual(t.data())},a_.prototype.toString=function(){return"Document("+this.key+", "+this.version+", "+this.data().toString()+", {hasLocalMutations: "+this.hasLocalMutations+"}), {hasCommittedMutations: "+this.hasCommittedMutations+"})"},Object.defineProperty(a_.prototype,"hasPendingWrites",{get:function(){return this.hasLocalMutations||this.hasCommittedMutations},enumerable:!0,configurable:!0}),a_.prototype.getProtoField=function(t){og(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},a_.compareByField=function(t,e,n){var r=e.field(t),i=n.field(t);return null!==r&&null!==i?r.compareTo(i):ig("Trying to compare documents on fields that don't exist")},a_);function a_(t,e,n,r,i,o){var a=i_.call(this,t,e)||this;return a.objectValue=r,a.proto=i,a.converter=o,og(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 s_,u_=(_a(c_,s_=n_),c_.prototype.toString=function(){return"NoDocument("+this.key+", "+this.version+")"},Object.defineProperty(c_.prototype,"hasPendingWrites",{get:function(){return this.hasCommittedMutations},enumerable:!0,configurable:!0}),c_.prototype.isEqual=function(t){return t instanceof c_&&t.hasCommittedMutations===this.hasCommittedMutations&&t.version.isEqual(this.version)&&t.key.isEqual(this.key)},c_);function c_(t,e,n){var r=s_.call(this,t,e)||this;return r.hasCommittedMutations=!(!n||!n.hasCommittedMutations),r}var h_,l_=(_a(f_,h_=n_),f_.prototype.toString=function(){return"UnknownDocument("+this.key+", "+this.version+")"},Object.defineProperty(f_.prototype,"hasPendingWrites",{get:function(){return!0},enumerable:!0,configurable:!0}),f_.prototype.isEqual=function(t){return t instanceof f_&&t.version.isEqual(this.version)&&t.key.isEqual(this.key)},f_);function f_(){return null!==h_&&h_.apply(this,arguments)||this}var p_=(d_.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}},d_.prototype.has=function(t){return void 0!==this.get(t)},d_.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]]},d_.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},d_.prototype.forEach=function(s){gg(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)}})},d_.prototype.isEmpty=function(){return vg(this.inner)},d_);function d_(t){this.mapKeyFn=t,this.inner={}}var y_=(Object.defineProperty(m_.prototype,"readTime",{get:function(){return og(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){og(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}),m_.prototype.addEntry=function(t,e){this.assertNotApplied(),this.readTime=e,this.changes.set(t.key,t)},m_.prototype.removeEntry=function(t,e){this.assertNotApplied(),e&&(this.readTime=e),this.changes.set(t,null)},m_.prototype.getEntry=function(t,e){this.assertNotApplied();var n=this.changes.get(e);return void 0!==n?ib.resolve(n):this.getFromCache(t,e)},m_.prototype.getEntries=function(t,e){return this.getAllFromCache(t,e)},m_.prototype.apply=function(t){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(t)},m_.prototype.assertNotApplied=function(){og(!this.changesApplied,"Changes have already been applied.")},m_);function m_(){this.changes=new p_(function(t){return t.toString()}),this.changesApplied=!1}var g_,v_=(b_.prototype.addEntry=function(t,e,n){return E_(t).put(T_(e),n)},b_.prototype.removeEntry=function(t,e){var n=E_(t),r=T_(e);return n.delete(r)},b_.prototype.updateMetadata=function(e,n){var r=this;return this.getMetadata(e).next(function(t){return t.byteSize+=n,r.setMetadata(e,t)})},b_.prototype.getEntry=function(t,e){var n=this;return E_(t).get(T_(e)).next(function(t){return n.maybeDecodeDocument(t)})},b_.prototype.getSizedEntry=function(t,e){var n=this;return E_(t).get(T_(e)).next(function(t){var e=n.maybeDecodeDocument(t);return e?{maybeDocument:e,size:S_(t)}:null})},b_.prototype.getEntries=function(t,e){var r=this,i=Qv();return this.forEachDbEntry(t,e,function(t,e){var n=r.maybeDecodeDocument(e);i=i.insert(t,n)}).next(function(){return i})},b_.prototype.getSizedEntries=function(t,e){var r=this,i=Qv(),o=new Rv(hv.comparator);return this.forEachDbEntry(t,e,function(t,e){var n=r.maybeDecodeDocument(e);o=n?(i=i.insert(t,n),o.insert(t,S_(e))):(i=i.insert(t,null),o.insert(t,0))}).next(function(){return{maybeDocuments:i,sizeMap:o}})},b_.prototype.forEachDbEntry=function(t,e,i){if(e.isEmpty())return ib.resolve();var n=IDBKeyRange.bound(e.first().path.toArray(),e.last().path.toArray()),o=e.getIterator(),a=o.getNext();return E_(t).iterate({range:n},function(t,e,n){for(var r=hv.fromSegments(t);a&&hv.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})},b_.prototype.getDocumentsMatchingQuery=function(t,i,e){var o=this;og(!i.isCollectionGroupQuery(),"CollectionGroup queries should be handled in LocalDocumentsView");var a=zv(),s=i.path.length+1,n={};if(e.isEqual(Dv.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=W_.collectionReadTimeIndex}return E_(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 o_&&i.matches(r)&&(a=a.insert(r.key,r)):n.done()}}).next(function(){return a})},b_.prototype.getNewDocumentChanges=function(t,e){var r=this,i=Kv(),o=this.serializer.toDbTimestampKey(e),n=E_(t),a=IDBKeyRange.lowerBound(o,!0);return n.iterate({index:W_.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)}})},b_.prototype.getLastReadTime=function(t){var r=this,e=E_(t),i=Dv.MIN;return e.iterate({index:W_.readTimeIndex,reverse:!0},function(t,e,n){e.readTime&&(i=r.serializer.fromDbTimestampKey(e.readTime)),n.done()}).next(function(){return i})},b_.prototype.newChangeBuffer=function(t){return new b_.RemoteDocumentChangeBuffer(this,!!t&&t.trackRemovals)},b_.prototype.getSize=function(t){return this.getMetadata(t).next(function(t){return t.byteSize})},b_.prototype.getMetadata=function(t){return __(t).get(Q_.key).next(function(t){return og(!!t,"Missing document cache metadata"),t})},b_.prototype.setMetadata=function(t,e){return __(t).put(Q_.key,e)},b_.prototype.maybeDecodeDocument=function(t){if(t){var e=this.serializer.fromDbRemoteDocument(t);return e instanceof u_&&e.version.isEqual(Dv.forDeletedDoc())?null:e}return null},b_.RemoteDocumentChangeBuffer=(_a(w_,g_=y_),w_.prototype.applyChanges=function(a){var s=this,u=[],c=0,h=new Vv(function(t,e){return qg(t.canonicalString(),e.canonicalString())});return this.changes.forEach(function(t,e){var n=s.documentSizes.get(t);if(og(void 0!==n,"Cannot modify a document that wasn't read (for "+t+")"),e){og(!s.readTime.isEqual(Dv.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=S_(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 u_(t,Dv.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)),ib.waitFor(u)},w_.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)})},w_.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})},w_),b_);function b_(t,e){this.serializer=t,this.indexManager=e}function w_(t,e){var n=g_.call(this)||this;return n.documentCache=t,n.trackRemovals=e,n.documentSizes=new p_(function(t){return t.toString()}),n}function __(t){return jE.getStore(t,Q_.store)}function E_(t){return jE.getStore(t,W_.store)}function T_(t){return t.path.toArray()}function S_(t){var e;if(t.document)e=t.document;else if(t.unknownDocument)e=t.unknownDocument;else{if(!t.noDocument)throw ig("Unknown remote document type");e=t.noDocument}return JSON.stringify(e).length}var I_=(C_.prototype.addToCollectionParentIndex=function(t,e){return this.collectionParentIndex.add(e),ib.resolve()},C_.prototype.getCollectionParents=function(t,e){return ib.resolve(this.collectionParentIndex.getEntries(e))},C_);function C_(){this.collectionParentIndex=new N_}var N_=(A_.prototype.add=function(t){og(t.length%2==1,"Expected a collection path.");var e=t.lastSegment(),n=t.popLast(),r=this.index[e]||new Vv(iv.comparator),i=!r.has(n);return this.index[e]=r.add(n),i},A_.prototype.has=function(t){var e=t.lastSegment(),n=t.popLast(),r=this.index[e];return r&&r.has(n)},A_.prototype.getEntries=function(t){return(this.index[t]||new Vv(iv.comparator)).toArray()},A_);function A_(){this.index={}}var D_=9,k_=(R_.prototype.createOrUpgrade=function(t,e,n,r){var i=this;og(n<r&&0<=n&&r<=D_,"Unexpected schema upgrade from v"+n+" to v{toVersion}.");var o=new lb(e);n<1&&1<=r&&(function(t){t.createObjectStore(P_.store)}(t),function(t){t.createObjectStore(M_.store,{keyPath:M_.keyPath}),t.createObjectStore(F_.store,{keyPath:F_.keyPath,autoIncrement:!0}).createIndex(F_.userMutationsIndex,F_.userMutationsKeyPath,{unique:!0}),t.createObjectStore(V_.store)}(t),eE(t),function(t){t.createObjectStore(W_.store)}(t));var a=ib.resolve();return n<3&&3<=r&&(0!==n&&(function(t){t.deleteObjectStore(Y_.store),t.deleteObjectStore(z_.store),t.deleteObjectStore(J_.store)}(t),eE(t)),a=a.next(function(){return function(t){var e=t.store(J_.store),n=new J_(0,0,Dv.MIN.toTimestamp(),0);return e.put(J_.key,n)}(o)})),n<4&&4<=r&&(0!==n&&(a=a.next(function(){return function(r,i){return i.store(F_.store).loadAll().next(function(t){r.deleteObjectStore(F_.store),r.createObjectStore(F_.store,{keyPath:F_.keyPath,autoIncrement:!0}).createIndex(F_.userMutationsIndex,F_.userMutationsKeyPath,{unique:!0});var e=i.store(F_.store),n=t.map(function(t){return e.put(t)});return ib.waitFor(n)})}(t,o)})),a=a.next(function(){!function(t){t.createObjectStore(nE.store,{keyPath:nE.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(Q_.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(W_.store);e.createIndex(W_.readTimeIndex,W_.readTimeIndexPath,{unique:!1}),e.createIndex(W_.collectionReadTimeIndex,W_.collectionReadTimeIndexPath,{unique:!1})}(e)})),a},R_.prototype.addDocumentGlobal=function(e){var n=0;return e.store(W_.store).iterate(function(t,e){n+=S_(e)}).next(function(){var t=new Q_(n);return e.store(Q_.store).put(Q_.key,t)})},R_.prototype.removeAcknowledgedMutations=function(r){var i=this,t=r.store(M_.store),e=r.store(F_.store);return t.loadAll().next(function(t){return ib.forEach(t,function(n){var t=IDBKeyRange.bound([n.userId,-1],[n.userId,n.lastAcknowledgedBatchId]);return e.loadAll(F_.userMutationsIndex,t).next(function(t){return ib.forEach(t,function(t){og(t.userId===n.userId,"Cannot process batch "+t.batchId+" from unexpected user");var e=i.serializer.fromDbMutationBatch(t);return _b(r,n.userId,e).next(function(){})})})})})},R_.prototype.ensureSequenceNumbers=function(t){var a=t.store(Y_.store),e=t.store(W_.store);return xb(t).next(function(i){var o=[];return e.iterate(function(t,e){var n=new iv(t),r=function(t){return[0,Tv(t)]}(n);o.push(a.get(r).next(function(t){return t?ib.resolve():function(t){return a.put(new Y_(0,Tv(t),i))}(n)}))}).next(function(){return ib.waitFor(o)})})},R_.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:Tv(n)})}}t.createObjectStore(Z_.store,{keyPath:Z_.keyPath});var r=e.store(Z_.store),o=new N_;return e.store(W_.store).iterate({keysOnly:!0},function(t,e){var n=new iv(t);return i(n.popLast())}).next(function(){return e.store(V_.store).iterate({keysOnly:!0},function(t,e){t[0];var n=t[1],r=(t[2],Cv(n));return i(r.popLast())})})},R_);function R_(t){this.serializer=t}var O_=function(t,e){this.seconds=t,this.nanoseconds=e},P_=(x_.store="owner",x_.key="owner",x_);function x_(t,e,n){this.ownerId=t,this.allowTabSynchronization=e,this.leaseTimestampMs=n}var M_=(L_.store="mutationQueues",L_.keyPath="userId",L_);function L_(t,e,n){this.userId=t,this.lastAcknowledgedBatchId=e,this.lastStreamToken=n}var F_=(U_.store="mutations",U_.keyPath="batchId",U_.userMutationsIndex="userMutationsIndex",U_.userMutationsKeyPath=["userId","batchId"],U_);function U_(t,e,n,r,i){this.userId=t,this.batchId=e,this.localWriteTimeMs=n,this.baseMutations=r,this.mutations=i}var V_=(q_.prefixForUser=function(t){return[t]},q_.prefixForPath=function(t,e){return[t,Tv(e)]},q_.key=function(t,e,n){return[t,Tv(e),n]},q_.store="documentMutations",q_.PLACEHOLDER=new q_,q_);function q_(){}var B_=function(t,e){this.path=t,this.readTime=e},j_=function(t,e){this.path=t,this.version=e},W_=(K_.store="remoteDocuments",K_.readTimeIndex="readTimeIndex",K_.readTimeIndexPath="readTime",K_.collectionReadTimeIndex="collectionReadTimeIndex",K_.collectionReadTimeIndexPath=["parentPath","readTime"],K_);function K_(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 Q_=(H_.store="remoteDocumentGlobal",H_.key="remoteDocumentGlobalKey",H_);function H_(t){this.byteSize=t}var z_=(G_.store="targets",G_.keyPath="targetId",G_.queryTargetsIndexName="queryTargetsIndex",G_.queryTargetsKeyPath=["canonicalId","targetId"],G_);function G_(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 Y_=(X_.store="targetDocuments",X_.keyPath=["targetId","path"],X_.documentTargetsIndex="documentTargetsIndex",X_.documentTargetsKeyPath=["path","targetId"],X_);function X_(t,e,n){this.targetId=t,this.path=e,og(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 J_=($_.key="targetGlobalKey",$_.store="targetGlobal",$_);function $_(t,e,n,r){this.highestTargetId=t,this.highestListenSequenceNumber=e,this.lastRemoteSnapshotVersion=n,this.targetCount=r}var Z_=(tE.store="collectionParents",tE.keyPath=["collectionId","parent"],tE);function tE(t,e){this.collectionId=t,this.parent=e}function eE(t){t.createObjectStore(Y_.store,{keyPath:Y_.keyPath}).createIndex(Y_.documentTargetsIndex,Y_.documentTargetsKeyPath,{unique:!0}),t.createObjectStore(z_.store,{keyPath:z_.keyPath}).createIndex(z_.queryTargetsIndexName,z_.queryTargetsKeyPath,{unique:!0}),t.createObjectStore(J_.store)}var nE=(rE.store="clientMetadata",rE.keyPath="clientId",rE);function rE(t,e,n,r){this.clientId=t,this.updateTimeMs=e,this.networkEnabled=n,this.inForeground=r}var iE,oE,aE=Aa(Aa(Aa([M_.store,F_.store,V_.store,W_.store,z_.store,P_.store,J_.store,Y_.store],[nE.store]),[Q_.store]),[Z_.store]),sE=(uE.prototype.addToCollectionParentIndex=function(t,e){var n=this;if(og(e.length%2==1,"Expected a collection path."),this.collectionParentsCache.has(e))return ib.resolve();var r=e.lastSegment(),i=e.popLast();t.addOnCommittedListener(function(){n.collectionParentsCache.add(e)});var o={collectionId:r,parent:Tv(i)};return cE(t).put(o)},uE.prototype.getCollectionParents=function(t,i){var o=[],e=IDBKeyRange.bound([i,""],[jg(i),""],!1,!0);return cE(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(Cv(r.parent))}return o})},uE);function uE(){this.collectionParentsCache=new N_}function cE(t){return jE.getStore(t,Z_.store)}(oE=iE=iE||{})[oE.Listen=0]="Listen",oE[oE.ExistenceFilterMismatch=1]="ExistenceFilterMismatch",oE[oE.LimboResolution=2]="LimboResolution";var hE=(lE.prototype.withSequenceNumber=function(t){return new lE(this.target,this.targetId,this.purpose,t,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken)},lE.prototype.withResumeToken=function(t,e){return new lE(this.target,this.targetId,this.purpose,this.sequenceNumber,e,this.lastLimboFreeSnapshotVersion,t)},lE.prototype.withLastLimboFreeSnapshotVersion=function(t){return new lE(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,t,this.resumeToken)},lE.prototype.isEqual=function(t){return this.targetId===t.targetId&&this.purpose===t.purpose&&this.sequenceNumber===t.sequenceNumber&&this.snapshotVersion.isEqual(t.snapshotVersion)&&this.lastLimboFreeSnapshotVersion.isEqual(t.lastLimboFreeSnapshotVersion)&&this.resumeToken===t.resumeToken&&this.target.isEqual(t.target)},lE);function lE(t,e,n,r,i,o,a){void 0===i&&(i=Dv.MIN),void 0===o&&(o=Dv.MIN),void 0===a&&(a=ug()),this.target=t,this.targetId=e,this.purpose=n,this.sequenceNumber=r,this.snapshotVersion=i,this.lastLimboFreeSnapshotVersion=o,this.resumeToken=a}var fE=(pE.prototype.fromDbRemoteDocument=function(t){if(t.document)return this.remoteSerializer.fromDocument(t.document,!!t.hasCommittedMutations);if(t.noDocument){var e=hv.fromSegments(t.noDocument.path),n=this.fromDbTimestamp(t.noDocument.readTime);return new u_(e,n,{hasCommittedMutations:!!t.hasCommittedMutations})}return t.unknownDocument?(e=hv.fromSegments(t.unknownDocument.path),n=this.fromDbTimestamp(t.unknownDocument.version),new l_(e,n)):ig("Unexpected DbRemoteDocument")},pE.prototype.toDbRemoteDocument=function(t,e){var n=this.toDbTimestampKey(e),r=t.key.path.popLast().toArray();if(t instanceof o_){var i=t.proto?t.proto:this.remoteSerializer.toDocument(t),o=t.hasCommittedMutations;return new W_(null,null,i,o,n,r)}if(t instanceof u_){var a=t.key.path.toArray(),s=this.toDbTimestamp(t.version);return o=t.hasCommittedMutations,new W_(null,new B_(a,s),null,o,n,r)}if(t instanceof l_){a=t.key.path.toArray();var u=this.toDbTimestamp(t.version);return new W_(new j_(a,u),null,null,!0,n,r)}return ig("Unexpected MaybeDocument")},pE.prototype.toDbTimestampKey=function(t){var e=t.toTimestamp();return[e.seconds,e.nanoseconds]},pE.prototype.fromDbTimestampKey=function(t){var e=new Nv(t[0],t[1]);return Dv.fromTimestamp(e)},pE.prototype.toDbTimestamp=function(t){var e=t.toTimestamp();return new O_(e.seconds,e.nanoseconds)},pE.prototype.fromDbTimestamp=function(t){var e=new Nv(t.seconds,t.nanoseconds);return Dv.fromTimestamp(e)},pE.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 F_(t,e.batchId,e.localWriteTime.toMillis(),r,i)},pE.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=Nv.fromMillis(t.localWriteTimeMs);return new tb(t.batchId,i,n,r)},pE.prototype.toDbResourcePaths=function(t){var e=[];return t.forEach(function(t){e.push(Tv(t.path))}),e},pE.prototype.fromDbResourcePaths=function(t){for(var e=Jv(),n=0,r=t;n<r.length;n++){var i=r[n];e=e.add(new hv(Cv(i)))}return e},pE.prototype.fromDbTarget=function(t){var e,n=this.fromDbTimestamp(t.readTime),r=void 0!==t.lastLimboFreeSnapshotVersion?this.fromDbTimestamp(t.lastLimboFreeSnapshotVersion):Dv.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 hE(e,t.targetId,iE.Listen,t.lastListenSequenceNumber,n,r,i)},pE.prototype.toDbTarget=function(t){og(iE.Listen===t.purpose,"Only queries with purpose "+iE.Listen+" may be stored, got "+t.purpose);var e,n,r=this.toDbTimestamp(t.snapshotVersion),i=this.toDbTimestamp(t.lastLimboFreeSnapshotVersion);return e=t.target.isDocumentQuery()?this.remoteSerializer.toDocumentsTarget(t.target):this.remoteSerializer.toQueryTarget(t.target),n=t.resumeToken instanceof Uint8Array?(og(sb.isMockPersistence(),"Persisting non-string stream tokens is only supported with mock persistence ."),t.resumeToken.toString()):t.resumeToken,new z_(t.targetId,t.target.canonicalId(),r,n,t.sequenceNumber,i,e)},pE);function pE(t){this.remoteSerializer=t}var dE=(yE.prototype.getDocument=function(e,n){var r=this;return this.mutationQueue.getAllMutationBatchesAffectingDocumentKey(e,n).next(function(t){return r.getDocumentInternal(e,n,t)})},yE.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})},yE.prototype.applyLocalMutationsToDocuments=function(t,e,i){var o=Qv();return e.forEach(function(t,e){for(var n=0,r=i;n<r.length;n++)e=r[n].applyToLocalView(t,e);o=o.insert(t,e)}),o},yE.prototype.getDocuments=function(e,t){var n=this;return this.remoteDocumentCache.getEntries(e,t).next(function(t){return n.getLocalViewOfDocuments(e,t)})},yE.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=Kv();return e.forEach(function(t,e){e=e||new u_(t,Dv.forDeletedDoc()),n=n.insert(t,e)}),n})},yE.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)},yE.prototype.getDocumentsMatchingDocumentQuery=function(t,e){return this.getDocument(t,new hv(e)).next(function(t){var e=zv();return t instanceof o_&&(e=e.insert(t.key,t)),e})},yE.prototype.getDocumentsMatchingCollectionGroupQuery=function(n,r,i){var o=this;og(r.path.isEmpty(),"Currently we only support collection group queries at the root.");var a=r.collectionGroup,s=zv();return this.indexManager.getCollectionParents(n,a).next(function(t){return ib.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})})},yE.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 o_?h.insert(s,c):h.remove(s)}})}).next(function(){return h.forEach(function(t,e){n.matches(e)||(h=h.remove(t))}),h})},yE.prototype.addMissingBaseDocuments=function(t,e,n){for(var r=Jv(),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 Jb&&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 o_&&(c=c.insert(t,e))}),c})},yE);function yE(t,e,n){this.remoteDocumentCache=t,this.mutationQueue=e,this.indexManager=n}var mE="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.",gE=(vE.prototype.addOnCommittedListener=function(t){this.onCommittedListeners.push(t)},vE.prototype.raiseOnCommittedEvent=function(){this.onCommittedListeners.forEach(function(t){return t()})},vE);function vE(){this.onCommittedListeners=[]}var bE=(wE.prototype.isEmpty=function(){return this.refsByKey.isEmpty()},wE.prototype.addReference=function(t,e){var n=new _E(t,e);this.refsByKey=this.refsByKey.add(n),this.refsByTarget=this.refsByTarget.add(n)},wE.prototype.addReferences=function(t,e){var n=this;t.forEach(function(t){return n.addReference(t,e)})},wE.prototype.removeReference=function(t,e){this.removeRef(new _E(t,e))},wE.prototype.removeReferences=function(t,e){var n=this;t.forEach(function(t){return n.removeReference(t,e)})},wE.prototype.removeReferencesForId=function(t){var e=this,n=hv.EMPTY,r=new _E(n,t),i=new _E(n,t+1),o=[];return this.refsByTarget.forEachInRange([r,i],function(t){e.removeRef(t),o.push(t.key)}),o},wE.prototype.removeAllReferences=function(){var e=this;this.refsByKey.forEach(function(t){return e.removeRef(t)})},wE.prototype.removeRef=function(t){this.refsByKey=this.refsByKey.delete(t),this.refsByTarget=this.refsByTarget.delete(t)},wE.prototype.referencesForId=function(t){var e=hv.EMPTY,n=new _E(e,t),r=new _E(e,t+1),i=Jv();return this.refsByTarget.forEachInRange([n,r],function(t){i=i.add(t.key)}),i},wE.prototype.containsKey=function(t){var e=new _E(t,0),n=this.refsByKey.firstAfterOrEqual(e);return null!==n&&t.isEqual(n.key)},wE);function wE(){this.refsByKey=new Vv(_E.compareByKey),this.refsByTarget=new Vv(_E.compareByTargetId)}var _E=(EE.compareByKey=function(t,e){return hv.comparator(t.key,e.key)||qg(t.targetOrBatchId,e.targetOrBatchId)},EE.compareByTargetId=function(t,e){return qg(t.targetOrBatchId,e.targetOrBatchId)||hv.comparator(t.key,e.key)},EE);function EE(t,e){this.key=t,this.targetOrBatchId=e}var TE="LocalStore",SE=(IE.prototype.start=function(){return this.synchronizeLastDocumentChangeReadTime()},IE.prototype.handleUserChange=function(i){return Ta(this,void 0,void 0,function(){var e,m,n,r=this;return Sa(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 dE(r.remoteDocuments,e,r.persistence.getIndexManager()),e.getAllMutationBatches(d)}).next(function(t){for(var e=[],n=[],r=Jv(),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]}})})},IE.prototype.localWrite=function(s){var u,c=this,h=Nv.now(),t=s.reduce(function(t,e){return t.add(e.key)},Jv());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 Jb(i.key,o,o.fieldMask(),Wb.exists(!0)))}return c.mutationQueue.addMutationBatch(a,h,e,s)})}).then(function(t){var e=t.applyToLocalDocumentSet(u);return{batchId:t.batchId,changes:e}})},IE.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):ib.resolve(null)})})},IE.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)})})},IE.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 og(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)})})},IE.prototype.getHighestUnacknowledgedBatchId=function(){var e=this;return this.persistence.runTransaction("Get highest unacknowledged batch id","readonly-idempotent",function(t){return e.mutationQueue.getHighestUnacknowledgedBatchId(t)})},IE.prototype.getLastStreamToken=function(){var e=this;return this.persistence.runTransaction("Get last stream token","readonly-idempotent",function(t){return e.mutationQueue.getLastStreamToken(t)})},IE.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)})},IE.prototype.getLastRemoteSnapshotVersion=function(){var e=this;return this.persistence.runTransaction("Get last remote snapshot version","readonly-idempotent",function(t){return e.targetCache.getLastRemoteSnapshotVersion(t)})},IE.prototype.applyRemoteEvent=function(u){var c=this,h=u.snapshotVersion,l=this.targetDataByTarget;return this.persistence.runTransaction("Apply remote event","readwrite-primary-idempotent",function(o){var i=c.remoteDocuments.newChangeBuffer({trackRemovals:!0});l=c.targetDataByTarget;var a=[];mg(u.targetChanges,function(t,e){var n=l.get(t);if(n){a.push(c.targetCache.removeMatchingKeys(o,e.removedDocuments,t).next(function(){return c.targetCache.addMatchingKeys(o,e.addedDocuments,t)}));var r=e.resumeToken;if(0<r.length){var i=n.withResumeToken(r,h).withSequenceNumber(o.currentSequenceNumber);l=l.insert(t,i),IE.shouldPersistTargetData(n,i,e)&&a.push(c.targetCache.updateTargetData(o,i))}}});var s=Kv(),n=Jv();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 u_&&e.version.isEqual(Dv.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?(og(!Dv.MIN.isEqual(h),"Cannot add a document when the remote version is zero"),i.addEntry(e,h),s=s.insert(t,e)):eg(TE,"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(Dv.MIN)){var t=c.targetCache.getLastRemoteSnapshotVersion(o).next(function(t){return og(0<=h.compareTo(t),"Watch stream reverted to previous snapshot?? "+h+" < "+t),c.targetCache.setTargetsMetadata(o,o.currentSequenceNumber,h)});a.push(t)}return ib.waitFor(a).next(function(){return i.apply(o)}).next(function(){return c.localDocuments.getLocalViewOfDocuments(o,s)})}).then(function(t){return c.targetDataByTarget=l,t})},IE.shouldPersistTargetData=function(t,e,n){return og(0<e.resumeToken.length,"Attempted to persist target data with no resume token"),0===t.resumeToken.length||e.snapshotVersion.toMicroseconds()-t.snapshotVersion.toMicroseconds()>=this.RESUME_TOKEN_MAX_AGE_MICROS||0<n.addedDocuments.size+n.modifiedDocuments.size+n.removedDocuments.size},IE.prototype.notifyLocalViewChanges=function(t){for(var n=this,e=0,r=t;e<r.length;e++){var i=r[e],o=i.targetId;if(this.localViewReferences.addReferences(i.addedKeys,o),this.localViewReferences.removeReferences(i.removedKeys,o),!i.fromCache){var a=this.targetDataByTarget.get(o);og(null!==a,"Can't set limbo-free snapshot version for unknown target: "+o);var s=a.snapshotVersion,u=a.withLastLimboFreeSnapshotVersion(s);this.targetDataByTarget=this.targetDataByTarget.insert(o,u)}}return this.persistence.runTransaction("notifyLocalViewChanges","readwrite-idempotent",function(e){return ib.forEach(t,function(t){return ib.forEach(t.removedKeys,function(t){return n.persistence.referenceDelegate.removeReference(e,t)})})})},IE.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)})},IE.prototype.readDocument=function(e){var n=this;return this.persistence.runTransaction("read document","readonly-idempotent",function(t){return n.localDocuments.getDocument(t,e)})},IE.prototype.allocateTarget=function(r){var i=this;return this.persistence.runTransaction("Allocate target","readwrite-idempotent",function(e){var n;return i.targetCache.getTargetData(e,r).next(function(t){return t?(n=t,ib.resolve(n)):i.targetCache.allocateTargetId(e).next(function(t){return n=new hE(r,t,iE.Listen,e.currentSequenceNumber),i.targetCache.addTargetData(e,n).next(function(){return n})})})}).then(function(t){return null===i.targetDataByTarget.get(t.targetId)&&(i.targetDataByTarget=i.targetDataByTarget.insert(t.targetId,t),i.targetIdByTarget.set(r,t.targetId)),t})},IE.prototype.getTargetData=function(t,e){var n=this.targetIdByTarget.get(e);return void 0!==n?ib.resolve(this.targetDataByTarget.get(n)):this.targetCache.getTargetData(t,e)},IE.prototype.releaseTarget=function(n,r){var i=this,o=this.targetDataByTarget.get(n);og(null!==o,"Tried to release nonexistent target: "+n);var t=r?"readwrite-idempotent":"readwrite-primary-idempotent";return this.persistence.runTransaction("Release target",t,function(e){var t=i.localViewReferences.removeReferencesForId(n);return r?ib.resolve():ib.forEach(t,function(t){return i.persistence.referenceDelegate.removeReference(e,t)}).next(function(){i.persistence.referenceDelegate.removeTarget(e,o)})}).then(function(){i.targetDataByTarget=i.targetDataByTarget.remove(n),i.targetIdByTarget.delete(o.target)})},IE.prototype.executeQuery=function(t,n){var r=this,i=Dv.MIN,o=Jv();return this.persistence.runTransaction("Execute query","readonly-idempotent",function(e){return r.getTargetData(e,t.toTarget()).next(function(t){if(t)return i=t.lastLimboFreeSnapshotVersion,r.targetCache.getMatchingKeysForTargetId(e,t.targetId).next(function(t){o=t})}).next(function(){return r.queryEngine.getDocumentsMatchingQuery(e,t,n?i:Dv.MIN,n?o:Jv())}).next(function(t){return{documents:t,remoteKeys:o}})})},IE.prototype.remoteDocumentKeys=function(e){var n=this;return this.persistence.runTransaction("Remote document keys","readonly-idempotent",function(t){return n.targetCache.getMatchingKeysForTargetId(t,e)})},IE.prototype.getActiveClients=function(){return this.persistence.getActiveClients()},IE.prototype.removeCachedMutationBatchMetadata=function(t){this.mutationQueue.removeCachedMutationKeys(t)},IE.prototype.setNetworkEnabled=function(t){this.persistence.setNetworkEnabled(t)},IE.prototype.applyWriteToRemoteDocuments=function(t,i,o){var e=this,a=i.batch,n=a.keys(),s=ib.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);og(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):og(!t,"Mutation batch "+a+" applied to document "+t+" resulted in null"))})}),s.next(function(){return e.mutationQueue.removeMutationBatch(t,a)})},IE.prototype.collectGarbage=function(e){var n=this;return this.persistence.runTransaction("Collect garbage","readwrite-primary-idempotent",function(t){return e.collect(t,n.targetDataByTarget)})},IE.prototype.getTarget=function(e){var n=this,t=this.targetDataByTarget.get(e);return t?Promise.resolve(t.target):this.persistence.runTransaction("Get target data","readonly-idempotent",function(t){return n.targetCache.getTargetDataForTarget(t,e).next(function(t){return t?t.target:null})})},IE.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})},IE.prototype.synchronizeLastDocumentChangeReadTime=function(){return Ta(this,void 0,void 0,function(){var e,n=this;return Sa(this,function(t){switch(t.label){case 0:return[4,(e=this).persistence.runTransaction("Synchronize last document change read time","readonly-idempotent",function(t){return n.remoteDocuments.getLastReadTime(t)})];case 1:return e.lastDocumentChangeReadTime=t.sent(),[2]}})})},IE.RESUME_TOKEN_MAX_AGE_MICROS=3e8,IE);function IE(t,e,n){this.persistence=t,this.queryEngine=e,this.localViewReferences=new bE,this.targetDataByTarget=new Rv(qg),this.targetIdByTarget=new p_(function(t){return t.canonicalId()}),this.lastDocumentChangeReadTime=Dv.MIN,og(t.started,"LocalStore was passed an unstarted persistence implementation"),this.persistence.referenceDelegate.setInMemoryPins(this.localViewReferences),this.mutationQueue=t.getMutationQueue(n),this.remoteDocuments=t.getRemoteDocumentCache(),this.targetCache=t.getTargetCache(),this.localDocuments=new dE(this.remoteDocuments,this.mutationQueue,this.persistence.getIndexManager()),this.queryEngine.setLocalDocumentsView(this.localDocuments)}function CE(e){return Ta(this,void 0,void 0,function(){return Sa(this,function(t){if(e.code!==hg.FAILED_PRECONDITION||e.message!==mE)throw e;return eg(TE,"Unexpectedly lost primary lease"),[2]})})}function NE(t,e){var n=t[0],r=t[1],i=e[0],o=e[1],a=qg(n,i);return 0===a?qg(r,o):a}var AE=(DE.prototype.nextIndex=function(){return++this.previousIndex},DE.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();NE(e,n)<0&&(this.buffer=this.buffer.delete(n).add(e))}},Object.defineProperty(DE.prototype,"maxValue",{get:function(){return this.buffer.last()[0]},enumerable:!0,configurable:!0}),DE);function DE(t){this.maxElements=t,this.buffer=new Vv(NE),this.previousIndex=0}var kE={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0},RE=(OE.withCacheSize=function(t){return new OE(t,OE.DEFAULT_COLLECTION_PERCENTILE,OE.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)},OE.COLLECTION_DISABLED=-1,OE.MINIMUM_CACHE_SIZE_BYTES=1048576,OE.DEFAULT=new OE(OE.DEFAULT_CACHE_SIZE_BYTES=41943040,OE.DEFAULT_COLLECTION_PERCENTILE=10,OE.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3),OE.DISABLED=new OE(OE.COLLECTION_DISABLED,0,0),OE);function OE(t,e,n){this.cacheSizeCollectionThreshold=t,this.percentileToCollect=e,this.maximumSequenceNumbersToCollect=n}var PE=(xE.prototype.start=function(){og(null===this.gcTask,"Cannot start an already started LruScheduler"),this.garbageCollector.params.cacheSizeCollectionThreshold!==RE.COLLECTION_DISABLED&&this.scheduleGC()},xE.prototype.stop=function(){this.gcTask&&(this.gcTask.cancel(),this.gcTask=null)},Object.defineProperty(xE.prototype,"started",{get:function(){return null!==this.gcTask},enumerable:!0,configurable:!0}),xE.prototype.scheduleGC=function(){var t=this;og(null===this.gcTask,"Cannot schedule GC while a task is pending");var e=this.hasRun?3e5:6e4;eg("LruGarbageCollector","Garbage collection scheduled in "+e+"ms"),this.gcTask=this.asyncQueue.enqueueAfterDelay(fv.LruGarbageCollection,e,function(){return t.gcTask=null,t.hasRun=!0,t.localStore.collectGarbage(t.garbageCollector).then(function(){return t.scheduleGC()}).catch(CE)})},xE);function xE(t,e,n){this.garbageCollector=t,this.asyncQueue=e,this.localStore=n,this.hasRun=!1,this.gcTask=null}var ME=(LE.prototype.calculateTargetCount=function(t,e){return this.delegate.getSequenceNumberCount(t).next(function(t){return Math.floor(e/100*t)})},LE.prototype.nthSequenceNumber=function(t,e){var n=this;if(0===e)return ib.resolve($g.INVALID);var r=new AE(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})},LE.prototype.removeTargets=function(t,e,n){return this.delegate.removeTargets(t,e,n)},LE.prototype.removeOrphanedDocuments=function(t,e){return this.delegate.removeOrphanedDocuments(t,e)},LE.prototype.collect=function(e,n){var r=this;return this.params.cacheSizeCollectionThreshold===RE.COLLECTION_DISABLED?(eg("LruGarbageCollector","Garbage collection skipped; disabled"),ib.resolve(kE)):this.getCacheSize(e).next(function(t){return t<r.params.cacheSizeCollectionThreshold?(eg("LruGarbageCollector","Garbage collection skipped; Cache size "+t+" is lower than threshold "+r.params.cacheSizeCollectionThreshold),kE):r.runGarbageCollection(e,n)})},LE.prototype.getCacheSize=function(t){return this.delegate.getCacheSize(t)},LE.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?(eg("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(),Zm()<=Wm.DEBUG&&eg("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"),ib.resolve({didRun:!0,sequenceNumbersCollected:i,targetsRemoved:o,documentsRemoved:t})})},LE);function LE(t,e){this.delegate=t,this.params=e}var FE,UE="IndexedDbPersistence",VE="Another tab has exclusive access to the persistence layer. To allow shared access, make sure to invoke `enablePersistence()` with `synchronizeTabs:true` in all tabs.",qE=(_a(BE,FE=gE),BE);function BE(t,e){var n=FE.call(this)||this;return n.simpleDbTransaction=t,n.currentSequenceNumber=e,n}var jE=(WE.getStore=function(t,e){if(t instanceof qE)return sb.getStore(t.simpleDbTransaction,e);throw ig("IndexedDbPersistence must use instances of IndexedDbTransaction")},WE.createIndexedDbPersistence=function(n){return Ta(this,void 0,void 0,function(){var e;return Sa(this,function(t){switch(t.label){case 0:if(!WE.isAvailable())throw new lg(hg.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");return[4,(e=new WE(n.allowTabSynchronization,n.persistenceKey,n.clientId,n.platform,n.lruParams,n.queue,n.serializer,n.sequenceNumberSyncer)).start()];case 1:return t.sent(),[2,e]}})})},WE.prototype.start=function(){var e=this;return og(!this.started,"IndexedDbPersistence double-started!"),og(null!==this.window,"Expected 'window' to be defined"),sb.openOrCreate(this.dbName,D_,new k_(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",[J_.store],function(t){return xb(t)})}).then(function(t){e.listenSequence=new $g(t,e.sequenceNumberSyncer)}).then(function(){e._started=!0}).catch(function(t){return e.simpleDb&&e.simpleDb.close(),Promise.reject(t)})},WE.prototype.setPrimaryStateListener=function(n){var t=this;return this.primaryStateListener=function(e){return Ta(t,void 0,void 0,function(){return Sa(this,function(t){return this.started?[2,n(e)]:[2]})})},n(this.isPrimary)},WE.prototype.setDatabaseDeletedListener=function(n){var t=this;this.simpleDb.setVersionChangeListener(function(e){return Ta(t,void 0,void 0,function(){return Sa(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]}})})})},WE.prototype.setNetworkEnabled=function(t){var e=this;this.networkEnabled!==t&&(this.networkEnabled=t,this.queue.enqueueAndForget(function(){return Ta(e,void 0,void 0,function(){return Sa(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]}})})}))},WE.prototype.updateClientMetadataAndTryBecomePrimary=function(){var n=this;return this.simpleDb.runTransaction("readwrite-idempotent",aE,function(e){return QE(e).put(new nE(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 eg(UE,"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})},WE.prototype.verifyPrimaryLease=function(t){var e=this;return KE(t).get(P_.key).next(function(t){return ib.resolve(e.isLocalClient(t))})},WE.prototype.removeClientMetadata=function(t){return QE(t).delete(this.clientId)},WE.prototype.maybeGarbageCollectMultiClientState=function(){return Ta(this,void 0,void 0,function(){var i=this;return Sa(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=WE.getStore(t,nE.store);return r.loadAll().next(function(t){var e=i.filterActiveClients(t,18e5),n=t.filter(function(t){return-1===e.indexOf(t)});return ib.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]}})})},WE.prototype.scheduleClientMetadataAndPrimaryLeaseRefreshes=function(){var t=this;this.clientMetadataRefresher=this.queue.enqueueAfterDelay(fv.ClientMetadataRefresh,4e3,function(){return t.updateClientMetadataAndTryBecomePrimary().then(function(){return t.maybeGarbageCollectMultiClientState()}).then(function(){return t.scheduleClientMetadataAndPrimaryLeaseRefreshes()})})},WE.prototype.isLocalClient=function(t){return!!t&&t.ownerId===this.clientId},WE.prototype.canActAsPrimary=function(e){var i=this;return KE(e).get(P_.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 lg(hg.FAILED_PRECONDITION,VE);return!1}}return!(!i.networkEnabled||!i.inForeground)||QE(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&&eg(UE,"Client "+(t?"is":"is not")+" eligible for a primary lease."),t})},WE.prototype.shutdown=function(){return Ta(this,void 0,void 0,function(){var e=this;return Sa(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",[P_.store,nE.store],function(t){return e.releasePrimaryLeaseIfHeld(t).next(function(){return e.removeClientMetadata(t)})})];case 1:return t.sent(),this.simpleDb.close(),this.removeClientZombiedEntry(),[2]}})})},WE.prototype.filterActiveClients=function(t,e){var n=this;return t.filter(function(t){return n.isWithinAge(t.updateTimeMs,e)&&!n.isClientZombied(t.clientId)})},WE.prototype.getActiveClients=function(){var e=this;return this.simpleDb.runTransaction("readonly-idempotent",[nE.store],function(t){return QE(t).loadAll().next(function(t){return e.filterActiveClients(t,18e5).map(function(t){return t.clientId})})})},WE.clearPersistence=function(n){return Ta(this,void 0,void 0,function(){var e;return Sa(this,function(t){switch(t.label){case 0:return WE.isAvailable()?(e=n+WE.MAIN_DATABASE,[4,sb.delete(e)]):[2,Promise.resolve()];case 1:return t.sent(),[2]}})})},Object.defineProperty(WE.prototype,"started",{get:function(){return this._started},enumerable:!0,configurable:!0}),WE.prototype.getMutationQueue=function(t){return og(this.started,"Cannot initialize MutationQueue before persistence is started."),vb.forUser(t,this.serializer,this.indexManager,this.referenceDelegate)},WE.prototype.getTargetCache=function(){return og(this.started,"Cannot initialize TargetCache before persistence is started."),this.targetCache},WE.prototype.getRemoteDocumentCache=function(){return og(this.started,"Cannot initialize RemoteDocumentCache before persistence is started."),this.remoteDocumentCache},WE.prototype.getIndexManager=function(){return og(this.started,"Cannot initialize IndexManager before persistence is started."),this.indexManager},WE.prototype.runTransaction=function(n,t,r){var i=this;eg(UE,"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,aE,function(e){return o=new qE(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 ng("Failed to obtain primary lease for action '"+n+"'."),i.isPrimary=!1,i.queue.enqueueAndForget(function(){return i.primaryStateListener(!1)}),new lg(hg.FAILED_PRECONDITION,mE);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})},WE.prototype.verifyAllowTabSynchronization=function(t){var e=this;return KE(t).get(P_.key).next(function(t){if(null!==t&&e.isWithinAge(t.leaseTimestampMs,5e3)&&!e.isClientZombied(t.ownerId)&&!e.isLocalClient(t)&&!t.allowTabSynchronization)throw new lg(hg.FAILED_PRECONDITION,VE)})},WE.prototype.acquireOrExtendPrimaryLease=function(t){var e=new P_(this.clientId,this.allowTabSynchronization,Date.now());return KE(t).put(P_.key,e)},WE.isAvailable=function(){return sb.isAvailable()},WE.buildStoragePrefix=function(t){var e=t.databaseId.projectId;return t.databaseId.isDefaultDatabase||(e+="."+t.databaseId.database),"firestore/"+t.persistenceKey+"/"+e+"/"},WE.prototype.releasePrimaryLeaseIfHeld=function(t){var e=this,n=KE(t);return n.get(P_.key).next(function(t){return e.isLocalClient(t)?(eg(UE,"Releasing primary lease."),n.delete(P_.key)):ib.resolve()})},WE.prototype.isWithinAge=function(t,e){var n=Date.now();return!(t<n-e||n<t&&(ng("Detected an update time that is in the future: "+t+" > "+n),1))},WE.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)},WE.prototype.detachVisibilityHandler=function(){this.documentVisibilityHandler&&(og(null!==this.document&&"function"==typeof this.document.addEventListener,"Expected 'document.addEventListener' to be a function"),this.document.removeEventListener("visibilitychange",this.documentVisibilityHandler),this.documentVisibilityHandler=null)},WE.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))},WE.prototype.detachWindowUnloadHook=function(){this.windowUnloadHandler&&(og("function"==typeof this.window.removeEventListener,"Expected 'window.removeEventListener' to be a function"),this.window.removeEventListener("unload",this.windowUnloadHandler),this.windowUnloadHandler=null)},WE.prototype.isClientZombied=function(t){try{var e=null!==this.webStorage.getItem(this.zombiedClientLocalStorageKey(t));return eg(UE,"Client '"+t+"' "+(e?"is":"is not")+" zombied in LocalStorage"),e}catch(t){return ng(UE,"Failed to get zombied client id.",t),!1}},WE.prototype.markClientZombied=function(){try{this.webStorage.setItem(this.zombiedClientLocalStorageKey(this.clientId),String(Date.now()))}catch(t){ng("Failed to set zombie client id.",t)}},WE.prototype.removeClientZombiedEntry=function(){try{this.webStorage.removeItem(this.zombiedClientLocalStorageKey(this.clientId))}catch(t){}},WE.prototype.zombiedClientLocalStorageKey=function(t){return"firestore_zombie_"+this.persistenceKey+"_"+t},WE.MAIN_DATABASE="main",WE);function WE(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 HE(this,i),this.dbName=e+WE.MAIN_DATABASE,this.serializer=new fE(a),this.document=r.document,this.targetCache=new kb(this.referenceDelegate,this.serializer),this.indexManager=new sE,this.remoteDocumentCache=new v_(this.serializer,this.indexManager),!r.window||!r.window.localStorage)throw new lg(hg.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");this.window=r.window,this.webStorage=this.window.localStorage}function KE(t){return t.store(P_.store)}function QE(t){return t.store(nE.store)}var HE=(zE.prototype.getSequenceNumberCount=function(t){var n=this.orphanedDocmentCount(t);return this.db.getTargetCache().getTargetCount(t).next(function(e){return n.next(function(t){return e+t})})},zE.prototype.orphanedDocmentCount=function(t){var e=0;return this.forEachOrphanedDocumentSequenceNumber(t,function(t){e++}).next(function(){return e})},zE.prototype.forEachTarget=function(t,e){return this.db.getTargetCache().forEachTarget(t,e)},zE.prototype.forEachOrphanedDocumentSequenceNumber=function(t,n){return this.forEachOrphanedDocument(t,function(t,e){return n(e)})},zE.prototype.setInMemoryPins=function(t){this.inMemoryPins=t},zE.prototype.addReference=function(t,e){return GE(t,e)},zE.prototype.removeReference=function(t,e){return GE(t,e)},zE.prototype.removeTargets=function(t,e,n){return this.db.getTargetCache().removeTargets(t,e,n)},zE.prototype.removeMutationReference=function(t,e){return GE(t,e)},zE.prototype.isPinned=function(t,e){return this.inMemoryPins.containsKey(e)?ib.resolve(!0):function(e,n){var r=!1;return Ib(e).iterateSerial(function(t){return wb(e,t,n).next(function(t){return t&&(r=!0),ib.resolve(!t)})}).next(function(){return r})}(t,e)},zE.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),Mb(r).delete(function(t){return[0,Tv(t.path)]}(e))})});s.push(n)}}).next(function(){return ib.waitFor(s)}).next(function(){return a.apply(r)}).next(function(){return u})},zE.prototype.removeTarget=function(t,e){var n=e.withSequenceNumber(t.currentSequenceNumber);return this.db.getTargetCache().updateTargetData(t,n)},zE.prototype.updateLimboDocument=function(t,e){return GE(t,e)},zE.prototype.forEachOrphanedDocument=function(t,o){var a,e=Mb(t),s=$g.INVALID;return e.iterate({index:Y_.documentTargetsIndex},function(t,e){var n=t[0],r=(t[1],e.path),i=e.sequenceNumber;0===n?(s!==$g.INVALID&&o(new hv(Cv(a)),s),s=i,a=r):s=$g.INVALID}).next(function(){s!==$g.INVALID&&o(new hv(Cv(a)),s)})},zE.prototype.getCacheSize=function(t){return this.db.getRemoteDocumentCache().getSize(t)},zE);function zE(t,e){this.db=t,this.inMemoryPins=null,this.garbageCollector=new ME(this,e)}function GE(t,e){return Mb(t).put(function(t,e){return new Y_(0,Tv(t.path),e)}(e,t.currentSequenceNumber))}var YE=Number,XE=YE.MIN_SAFE_INTEGER||-(Math.pow(2,53)-1),JE=YE.MAX_SAFE_INTEGER||Math.pow(2,53)-1,$E=YE.isInteger||function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t};function ZE(t){return null==t}function tT(t){return $E(t)&&t<=JE&&XE<=t}var eT,nT,rT=(iT.prototype.canonicalId=function(){if(null===this.memoizedCanonicalId){var t=this.path.canonicalString();null!==this.collectionGroup&&(t+="|cg:"+this.collectionGroup),t+="|f:";for(var e=0,n=this.filters;e<n.length;e++)t+=n[e].canonicalId(),t+=",";t+="|ob:";for(var r=0,i=this.orderBy;r<i.length;r++)t+=i[r].canonicalId(),t+=",";ZE(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},iT.prototype.toString=function(){var t=this.path.canonicalString();return null!==this.collectionGroup&&(t+=" collectionGroup="+this.collectionGroup),0<this.filters.length&&(t+=", filters: ["+this.filters.join(", ")+"]"),ZE(this.limit)||(t+=", limit: "+this.limit),0<this.orderBy.length&&(t+=", orderBy: ["+this.orderBy.join(", ")+"]"),this.startAt&&(t+=", startAt: "+this.startAt.canonicalId()),this.endAt&&(t+=", endAt: "+this.endAt.canonicalId()),"Target("+t+")"},iT.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)},iT.prototype.isDocumentQuery=function(){return hv.isDocumentKey(this.path)&&null===this.collectionGroup&&0===this.filters.length},iT);function iT(t,e,n,r,i,o,a){void 0===e&&(e=null),void 0===n&&(n=[]),void 0===r&&(r=[]),void 0===i&&(i=null),void 0===o&&(o=null),void 0===a&&(a=null),this.path=t,this.collectionGroup=e,this.orderBy=n,this.filters=r,this.limit=i,this.startAt=o,this.endAt=a,this.memoizedCanonicalId=null}(nT=eT=eT||{}).First="F",nT.Last="L";var oT=(aT.atPath=function(t){return new aT(t)},Object.defineProperty(aT.prototype,"orderBy",{get:function(){if(null===this.memoizedOrderBy){var t=this.getInequalityFilterField(),e=this.getFirstOrderByField();if(null!==t&&null===e)t.isKeyField()?this.memoizedOrderBy=[xT]:this.memoizedOrderBy=[new OT(t),xT];else{og(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:AT.ASCENDING;this.memoizedOrderBy.push(a===AT.ASCENDING?xT:MT)}}}return this.memoizedOrderBy},enumerable:!0,configurable:!0}),aT.prototype.addFilter=function(t){og(null==this.getInequalityFilterField()||!(t instanceof lT)||!t.isInequality()||t.field.isEqual(this.getInequalityFilterField()),"Query must only have one inequality field."),og(!this.isDocumentQuery(),"No filtering allowed for document query");var e=this.filters.concat([t]);return new aT(this.path,this.collectionGroup,this.explicitOrderBy.slice(),e,this.limit,this.limitType,this.startAt,this.endAt)},aT.prototype.addOrderBy=function(t){og(!this.startAt&&!this.endAt,"Bounds must be set after orderBy");var e=this.explicitOrderBy.concat([t]);return new aT(this.path,this.collectionGroup,e,this.filters.slice(),this.limit,this.limitType,this.startAt,this.endAt)},aT.prototype.withLimitToFirst=function(t){return new aT(this.path,this.collectionGroup,this.explicitOrderBy.slice(),this.filters.slice(),t,eT.First,this.startAt,this.endAt)},aT.prototype.withLimitToLast=function(t){return new aT(this.path,this.collectionGroup,this.explicitOrderBy.slice(),this.filters.slice(),t,eT.Last,this.startAt,this.endAt)},aT.prototype.withStartAt=function(t){return new aT(this.path,this.collectionGroup,this.explicitOrderBy.slice(),this.filters.slice(),this.limit,this.limitType,t,this.endAt)},aT.prototype.withEndAt=function(t){return new aT(this.path,this.collectionGroup,this.explicitOrderBy.slice(),this.filters.slice(),this.limit,this.limitType,this.startAt,t)},aT.prototype.asCollectionQueryAtPath=function(t){return new aT(t,null,this.explicitOrderBy.slice(),this.filters.slice(),this.limit,this.limitType,this.startAt,this.endAt)},aT.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())},aT.prototype.canonicalId=function(){return this.toTarget().canonicalId()+"|lt:"+this.limitType},aT.prototype.toString=function(){return"Query(target="+this.toTarget().toString()+"; limitType="+this.limitType+")"},aT.prototype.isEqual=function(t){return this.toTarget().isEqual(t.toTarget())&&this.limitType===t.limitType},aT.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 og(n,"orderBy used that doesn't compare on key field"),0},aT.prototype.matches=function(t){return this.matchesPathAndCollectionGroup(t)&&this.matchesOrderBy(t)&&this.matchesFilters(t)&&this.matchesBounds(t)},aT.prototype.hasLimitToFirst=function(){return!ZE(this.limit)&&this.limitType===eT.First},aT.prototype.hasLimitToLast=function(){return!ZE(this.limit)&&this.limitType===eT.Last},aT.prototype.getFirstOrderByField=function(){return 0<this.explicitOrderBy.length?this.explicitOrderBy[0].field:null},aT.prototype.getInequalityFilterField=function(){for(var t=0,e=this.filters;t<e.length;t++){var n=e[t];if(n instanceof lT&&n.isInequality())return n.field}return null},aT.prototype.findFilterOperator=function(t){for(var e=0,n=this.filters;e<n.length;e++){var r=n[e];if(r instanceof lT&&0<=t.indexOf(r.op))return r.op}return null},aT.prototype.isDocumentQuery=function(){return this.toTarget().isDocumentQuery()},aT.prototype.isCollectionGroupQuery=function(){return null!==this.collectionGroup},aT.prototype.toTarget=function(){if(!this.memoizedTarget)if(this.limitType===eT.First)this.memoizedTarget=new rT(this.path,this.collectionGroup,this.orderBy,this.filters,this.limit,this.startAt,this.endAt);else{for(var t=[],e=0,n=this.orderBy;e<n.length;e++){var r=n[e],i=r.dir===AT.DESCENDING?AT.ASCENDING:AT.DESCENDING;t.push(new OT(r.field,i))}var o=this.endAt?new kT(this.endAt.position,!this.endAt.before):null,a=this.startAt?new kT(this.startAt.position,!this.startAt.before):null;this.memoizedTarget=new rT(this.path,this.collectionGroup,t,this.filters,this.limit,o,a)}return this.memoizedTarget},aT.prototype.matchesPathAndCollectionGroup=function(t){var e=t.key.path;return null!==this.collectionGroup?t.key.hasCollectionId(this.collectionGroup)&&this.path.isPrefixOf(e):hv.isDocumentKey(this.path)?this.path.isEqual(e):this.path.isImmediateParentOf(e)},aT.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},aT.prototype.matchesFilters=function(t){for(var e=0,n=this.filters;e<n.length;e++)if(!n[e].matches(t))return!1;return!0},aT.prototype.matchesBounds=function(t){return!(this.startAt&&!this.startAt.sortsBeforeDocument(this.orderBy,t)||this.endAt&&this.endAt.sortsBeforeDocument(this.orderBy,t))},aT.prototype.assertValidBound=function(t){og(t.position.length<=this.orderBy.length,"Bound is longer than orderBy")},aT);function aT(t,e,n,r,i,o,a,s){void 0===e&&(e=null),void 0===n&&(n=[]),void 0===r&&(r=[]),void 0===i&&(i=null),void 0===o&&(o=eT.First),void 0===a&&(a=null),void 0===s&&(s=null),this.path=t,this.collectionGroup=e,this.explicitOrderBy=n,this.filters=r,this.limit=i,this.limitType=o,this.startAt=a,this.endAt=s,this.memoizedOrderBy=null,this.memoizedTarget=null,this.startAt&&this.assertValidBound(this.startAt),this.endAt&&this.assertValidBound(this.endAt)}function sT(){}var uT=(cT.fromString=function(t){switch(t){case"<":return cT.LESS_THAN;case"<=":return cT.LESS_THAN_OR_EQUAL;case"==":return cT.EQUAL;case">=":return cT.GREATER_THAN_OR_EQUAL;case">":return cT.GREATER_THAN;case"array-contains":return cT.ARRAY_CONTAINS;case"in":return cT.IN;case"array-contains-any":return cT.ARRAY_CONTAINS_ANY;default:return ig("Unknown FieldFilter operator: "+t)}},cT.prototype.toString=function(){return this.name},cT.prototype.isEqual=function(t){return this.name===t.name},cT.LESS_THAN=new cT("<"),cT.LESS_THAN_OR_EQUAL=new cT("<="),cT.EQUAL=new cT("=="),cT.GREATER_THAN=new cT(">"),cT.GREATER_THAN_OR_EQUAL=new cT(">="),cT.ARRAY_CONTAINS=new cT("array-contains"),cT.IN=new cT("in"),cT.ARRAY_CONTAINS_ANY=new cT("array-contains-any"),cT);function cT(t){this.name=t}var hT,lT=(_a(fT,hT=sT),fT.create=function(t,e,n){if(t.isKeyField())return e===uT.IN?(og(n instanceof t_,"Comparing on key with IN, but filter value not an ArrayValue"),og(n.internalValue.every(function(t){return t instanceof Qw}),"Comparing on key with IN, but an array value was not a RefValue"),new gT(t,n)):(og(n instanceof Qw,"Comparing on key, but filter value not a RefValue"),og(e!==uT.ARRAY_CONTAINS&&e!==uT.ARRAY_CONTAINS_ANY,"'"+e.toString()+"' queries don't make sense on document keys."),new dT(t,e,n));if(n.isEqual(gw.INSTANCE)){if(e!==uT.EQUAL)throw new lg(hg.INVALID_ARGUMENT,"Invalid query. Null supports only equality comparisons.");return new fT(t,e,n)}if(n.isEqual(kw.NAN)){if(e!==uT.EQUAL)throw new lg(hg.INVALID_ARGUMENT,"Invalid query. NaN supports only equality comparisons.");return new fT(t,e,n)}return e===uT.ARRAY_CONTAINS?new wT(t,n):e===uT.IN?(og(n instanceof t_,"IN filter has invalid value: "+n.toString()),new TT(t,n)):e===uT.ARRAY_CONTAINS_ANY?(og(n instanceof t_,"ARRAY_CONTAINS_ANY filter has invalid value: "+n.toString()),new CT(t,n)):new fT(t,e,n)},fT.prototype.matches=function(t){var e=t.field(this.field);return null!==e&&this.value.typeOrder===e.typeOrder&&this.matchesComparison(e.compareTo(this.value))},fT.prototype.matchesComparison=function(t){switch(this.op){case uT.LESS_THAN:return t<0;case uT.LESS_THAN_OR_EQUAL:return t<=0;case uT.EQUAL:return 0===t;case uT.GREATER_THAN:return 0<t;case uT.GREATER_THAN_OR_EQUAL:return 0<=t;default:return ig("Unknown FieldFilter operator: "+this.op)}},fT.prototype.isInequality=function(){return 0<=[uT.LESS_THAN,uT.LESS_THAN_OR_EQUAL,uT.GREATER_THAN,uT.GREATER_THAN_OR_EQUAL].indexOf(this.op)},fT.prototype.canonicalId=function(){return this.field.canonicalString()+this.op.toString()+this.value.toString()},fT.prototype.isEqual=function(t){return t instanceof fT&&this.op.isEqual(t.op)&&this.field.isEqual(t.field)&&this.value.isEqual(t.value)},fT.prototype.toString=function(){return this.field.canonicalString()+" "+this.op+" "+this.value.value()},fT);function fT(t,e,n){var r=hT.call(this)||this;return r.field=t,r.op=e,r.value=n,r}var pT,dT=(_a(yT,pT=lT),yT.prototype.matches=function(t){var e=this.value,n=hv.comparator(t.key,e.key);return this.matchesComparison(n)},yT);function yT(){return null!==pT&&pT.apply(this,arguments)||this}var mT,gT=(_a(vT,mT=lT),vT.prototype.matches=function(e){return this.value.internalValue.some(function(t){return e.key.isEqual(t.key)})},vT);function vT(t,e){var n=mT.call(this,t,uT.IN,e)||this;return n.value=e,n}var bT,wT=(_a(_T,bT=lT),_T.prototype.matches=function(t){var e=t.field(this.field);return e instanceof t_&&e.contains(this.value)},_T);function _T(t,e){return bT.call(this,t,uT.ARRAY_CONTAINS,e)||this}var ET,TT=(_a(ST,ET=lT),ST.prototype.matches=function(t){var e=this.value,n=t.field(this.field);return null!==n&&e.contains(n)},ST);function ST(t,e){var n=ET.call(this,t,uT.IN,e)||this;return n.value=e,n}var IT,CT=(_a(NT,IT=lT),NT.prototype.matches=function(t){var e=this,n=t.field(this.field);return n instanceof t_&&n.internalValue.some(function(t){return e.value.contains(t)})},NT);function NT(t,e){var n=IT.call(this,t,uT.ARRAY_CONTAINS_ANY,e)||this;return n.value=e,n}var AT=(DT.prototype.toString=function(){return this.name},DT.ASCENDING=new DT("asc"),DT.DESCENDING=new DT("desc"),DT);function DT(t){this.name=t}var kT=(RT.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},RT.prototype.sortsBeforeDocument=function(t,e){og(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())og(o instanceof Qw,"Bound has a non-key value where the key path is being used."),n=hv.comparator(o.key,e.key);else{var a=e.field(i.field);og(null!==a,"Field should exist since document matched the orderBy already."),n=o.compareTo(a)}if(i.dir===AT.DESCENDING&&(n*=-1),0!==n)break}return this.before?n<=0:n<0},RT.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},RT);function RT(t,e){this.position=t,this.before=e}var OT=(PT.prototype.compare=function(t,e){var n=this.isKeyOrderBy?o_.compareByKey(t,e):o_.compareByField(this.field,t,e);switch(this.dir){case AT.ASCENDING:return n;case AT.DESCENDING:return-1*n;default:return ig("Unknown direction: "+this.dir)}},PT.prototype.canonicalId=function(){return this.field.canonicalString()+this.dir.toString()},PT.prototype.toString=function(){return this.field.canonicalString()+" ("+this.dir+")"},PT.prototype.isEqual=function(t){return this.dir===t.dir&&this.field.isEqual(t.field)},PT);function PT(t,e){this.field=t,void 0===e&&(e=AT.ASCENDING),this.dir=e,this.isKeyOrderBy=t.isKeyField()}var xT=new OT(uv.keyField(),AT.ASCENDING),MT=new OT(uv.keyField(),AT.DESCENDING),LT=(FT.prototype.setLocalDocumentsView=function(t){this.localDocumentsView=t},FT.prototype.getDocumentsMatchingQuery=function(e,r,i,o){var a=this;return og(void 0!==this.localDocumentsView,"setLocalDocumentsView() not called"),r.matchesAllDocuments()?this.executeFullCollectionScan(e,r):i.isEqual(Dv.MIN)?this.executeFullCollectionScan(e,r):this.localDocumentsView.getDocuments(e,o).next(function(t){var n=a.applyQuery(r,t);return(r.hasLimitToFirst()||r.hasLimitToLast())&&a.needsRefill(r.limitType,n,o,i)?a.executeFullCollectionScan(e,r):(Zm()<=Wm.DEBUG&&eg("IndexFreeQueryEngine","Re-using previous result from %s to execute query: %s",i.toString(),r.toString()),a.localDocumentsView.getDocumentsMatchingQuery(e,r,i).next(function(e){return n.forEach(function(t){e=e.insert(t.key,t)}),e}))})},FT.prototype.applyQuery=function(n,t){var r=new Vv(function(t,e){return n.docComparator(t,e)});return t.forEach(function(t,e){e instanceof o_&&n.matches(e)&&(r=r.add(e))}),r},FT.prototype.needsRefill=function(t,e,n,r){if(n.size!==e.size)return!0;var i=t===eT.First?e.last():e.first();return!!i&&(i.hasPendingWrites||0<i.version.compareTo(r))},FT.prototype.executeFullCollectionScan=function(t,e){return Zm()<=Wm.DEBUG&&eg("IndexFreeQueryEngine","Using full collection scan to execute query: %s",e.toString()),this.localDocumentsView.getDocumentsMatchingQuery(t,e,Dv.MIN)},FT);function FT(){}var UT=(VT.prototype.checkEmpty=function(t){return ib.resolve(0===this.mutationQueue.length)},VT.prototype.acknowledgeBatch=function(t,e,n){var r=e.batchId,i=this.indexOfExistingBatchId(r,"acknowledged");og(0===i,"Can only acknowledge the first batch in the mutation queue");var o=this.mutationQueue[i];return og(r===o.batchId,"Queue ordering failure: expected batch "+r+", got batch "+o.batchId),this.lastStreamToken=n,ib.resolve()},VT.prototype.getLastStreamToken=function(t){return ib.resolve(this.lastStreamToken)},VT.prototype.setLastStreamToken=function(t,e){return this.lastStreamToken=e,ib.resolve()},VT.prototype.addMutationBatch=function(t,e,n,r){og(0!==r.length,"Mutation batches should not be empty");var i=this.nextBatchId;this.nextBatchId++,0<this.mutationQueue.length&&og(this.mutationQueue[this.mutationQueue.length-1].batchId<i,"Mutation batchIDs must be monotonically increasing order");var o=new tb(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 _E(u.key,i)),this.indexManager.addToCollectionParentIndex(t,u.key.path.popLast())}return ib.resolve(o)},VT.prototype.lookupMutationBatch=function(t,e){return ib.resolve(this.findMutationBatch(e))},VT.prototype.lookupMutationKeys=function(t,e){var n=this.findMutationBatch(e);return og(null!=n,"Failed to find local mutation batch."),ib.resolve(n.keys())},VT.prototype.getNextMutationBatchAfterBatchId=function(t,e){var n=e+1,r=this.indexOfBatchId(n),i=r<0?0:r;return ib.resolve(this.mutationQueue.length>i?this.mutationQueue[i]:null)},VT.prototype.getHighestUnacknowledgedBatchId=function(){return ib.resolve(0===this.mutationQueue.length?-1:this.nextBatchId-1)},VT.prototype.getAllMutationBatches=function(t){return ib.resolve(this.mutationQueue.slice())},VT.prototype.getAllMutationBatchesAffectingDocumentKey=function(t,n){var r=this,e=new _E(n,0),i=new _E(n,Number.POSITIVE_INFINITY),o=[];return this.batchesByDocumentKey.forEachInRange([e,i],function(t){og(n.isEqual(t.key),"Should only iterate over a single key's batches");var e=r.findMutationBatch(t.targetOrBatchId);og(null!==e,"Batches in the index must exist in the main table"),o.push(e)}),ib.resolve(o)},VT.prototype.getAllMutationBatchesAffectingDocumentKeys=function(t,e){var r=this,i=new Vv(qg);return e.forEach(function(e){var t=new _E(e,0),n=new _E(e,Number.POSITIVE_INFINITY);r.batchesByDocumentKey.forEachInRange([t,n],function(t){og(e.isEqual(t.key),"For each key, should only iterate over a single key's batches"),i=i.add(t.targetOrBatchId)})}),ib.resolve(this.findMutationBatches(i))},VT.prototype.getAllMutationBatchesAffectingQuery=function(t,e){og(!e.isCollectionGroupQuery(),"CollectionGroup queries should be handled in LocalDocumentsView");var n=e.path,r=n.length+1,i=n;hv.isDocumentKey(i)||(i=i.child(""));var o=new _E(new hv(i),0),a=new Vv(qg);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),ib.resolve(this.findMutationBatches(a))},VT.prototype.findMutationBatches=function(t){var n=this,r=[];return t.forEach(function(t){var e=n.findMutationBatch(t);null!==e&&r.push(e)}),r},VT.prototype.removeMutationBatch=function(n,r){var i=this;og(0===this.indexOfExistingBatchId(r.batchId,"removed"),"Can only remove the first entry of the mutation queue"),this.mutationQueue.shift();var o=this.batchesByDocumentKey;return ib.forEach(r.mutations,function(t){var e=new _E(t.key,r.batchId);return o=o.delete(e),i.referenceDelegate.removeMutationReference(n,t.key)}).next(function(){i.batchesByDocumentKey=o})},VT.prototype.removeCachedMutationKeys=function(t){},VT.prototype.containsKey=function(t,e){var n=new _E(e,0),r=this.batchesByDocumentKey.firstAfterOrEqual(n);return ib.resolve(e.isEqual(r&&r.key))},VT.prototype.performConsistencyCheck=function(t){return 0===this.mutationQueue.length&&og(this.batchesByDocumentKey.isEmpty(),"Document leak -- detected dangling mutation references when queue is empty."),ib.resolve()},VT.prototype.indexOfExistingBatchId=function(t,e){var n=this.indexOfBatchId(t);return og(0<=n&&n<this.mutationQueue.length,"Batches must exist to be "+e),n},VT.prototype.indexOfBatchId=function(t){return 0===this.mutationQueue.length?0:t-this.mutationQueue[0].batchId},VT.prototype.findMutationBatch=function(t){var e=this.indexOfBatchId(t);if(e<0||e>=this.mutationQueue.length)return null;var n=this.mutationQueue[e];return og(n.batchId===t,"If found batch must match"),n},VT);function VT(t,e){this.indexManager=t,this.referenceDelegate=e,this.mutationQueue=[],this.nextBatchId=1,this.lastStreamToken=ug(),this.batchesByDocumentKey=new Vv(_E.compareByKey)}var qT,BT=(jT.prototype.addEntry=function(t,e,n){og(!n.isEqual(Dv.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())},jT.prototype.removeEntry=function(t){var e=this.docs.get(t);e&&(this.docs=this.docs.remove(t),this.size-=e.size)},jT.prototype.getEntry=function(t,e){var n=this.docs.get(e);return ib.resolve(n?n.maybeDocument:null)},jT.prototype.getEntries=function(t,e){var n=this,r=Qv();return e.forEach(function(t){var e=n.docs.get(t);r=r.insert(t,e?e.maybeDocument:null)}),ib.resolve(r)},jT.prototype.getDocumentsMatchingQuery=function(t,e,n){og(!e.isCollectionGroupQuery(),"CollectionGroup queries should be handled in LocalDocumentsView");for(var r=zv(),i=new hv(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 o_&&e.matches(c)&&(r=r.insert(c.key,c))}return ib.resolve(r)},jT.prototype.forEachDocumentKey=function(t,e){return ib.forEach(this.docs,function(t){return e(t)})},jT.prototype.getNewDocumentChanges=function(t,e){throw new Error("getNewDocumentChanges() is not supported with MemoryPersistence")},jT.prototype.getLastReadTime=function(t){return ib.resolve(Dv.MIN)},jT.prototype.newChangeBuffer=function(t){return new jT.RemoteDocumentChangeBuffer(this)},jT.prototype.getSize=function(t){return ib.resolve(this.size)},jT.RemoteDocumentChangeBuffer=(_a(WT,qT=y_),WT.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)}),ib.waitFor(i)},WT.prototype.getFromCache=function(t,e){return this.documentCache.getEntry(t,e)},WT.prototype.getAllFromCache=function(t,e){return this.documentCache.getEntries(t,e)},WT),jT);function jT(t,e){this.indexManager=t,this.sizer=e,this.docs=new Rv(hv.comparator),this.size=0}function WT(t){var e=qT.call(this)||this;return e.documentCache=t,e}var KT=(QT.prototype.forEachTarget=function(t,n){return this.targets.forEach(function(t,e){return n(e)}),ib.resolve()},QT.prototype.getLastRemoteSnapshotVersion=function(t){return ib.resolve(this.lastRemoteSnapshotVersion)},QT.prototype.getHighestSequenceNumber=function(t){return ib.resolve(this.highestSequenceNumber)},QT.prototype.allocateTargetId=function(t){var e=this.targetIdGenerator.after(this.highestTargetId);return this.highestTargetId=e,ib.resolve(e)},QT.prototype.setTargetsMetadata=function(t,e,n){return n&&(this.lastRemoteSnapshotVersion=n),e>this.highestSequenceNumber&&(this.highestSequenceNumber=e),ib.resolve()},QT.prototype.saveTargetData=function(t){this.targets.set(t.target,t);var e=t.targetId;e>this.highestTargetId&&(this.highestTargetId=e),t.sequenceNumber>this.highestSequenceNumber&&(this.highestSequenceNumber=t.sequenceNumber)},QT.prototype.addTargetData=function(t,e){return og(!this.targets.has(e.target),"Adding a target that already exists"),this.saveTargetData(e),this.targetCount+=1,ib.resolve()},QT.prototype.updateTargetData=function(t,e){return og(this.targets.has(e.target),"Updating a non-existent target"),this.saveTargetData(e),ib.resolve()},QT.prototype.removeTargetData=function(t,e){return og(0<this.targetCount,"Removing a target from an empty cache"),og(this.targets.has(e.target),"Removing a non-existent target from the cache"),this.targets.delete(e.target),this.references.removeReferencesForId(e.targetId),this.targetCount-=1,ib.resolve()},QT.prototype.removeTargets=function(n,r,i){var o=this,a=0,s=[];return this.targets.forEach(function(t,e){e.sequenceNumber<=r&&null===i.get(e.targetId)&&(o.targets.delete(t),s.push(o.removeMatchingKeysForTargetId(n,e.targetId)),a++)}),ib.waitFor(s).next(function(){return a})},QT.prototype.getTargetCount=function(t){return ib.resolve(this.targetCount)},QT.prototype.getTargetData=function(t,e){var n=this.targets.get(e)||null;return ib.resolve(n)},QT.prototype.getTargetDataForTarget=function(t,e){return ig("Not yet implemented.")},QT.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))}),ib.waitFor(i)},QT.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))}),ib.waitFor(i)},QT.prototype.removeMatchingKeysForTargetId=function(t,e){return this.references.removeReferencesForId(e),ib.resolve()},QT.prototype.getMatchingKeysForTargetId=function(t,e){var n=this.references.referencesForId(e);return ib.resolve(n)},QT.prototype.containsKey=function(t,e){return ib.resolve(this.references.containsKey(e))},QT);function QT(t){this.persistence=t,this.targets=new p_(function(t){return t.canonicalId()}),this.lastRemoteSnapshotVersion=Dv.MIN,this.highestTargetId=0,this.highestSequenceNumber=0,this.references=new bE,this.targetCount=0,this.targetIdGenerator=Ab.forTargetCache()}var HT=(zT.createLruPersistence=function(t,e){return new zT(t,function(t){return new ZT(t,e)})},zT.createEagerPersistence=function(t){return new zT(t,function(t){return new JT(t)})},zT.prototype.shutdown=function(){return this._started=!1,Promise.resolve()},Object.defineProperty(zT.prototype,"started",{get:function(){return this._started},enumerable:!0,configurable:!0}),zT.prototype.getActiveClients=function(){return Ta(this,void 0,void 0,function(){return Sa(this,function(t){return[2,[this.clientId]]})})},zT.prototype.setPrimaryStateListener=function(t){return t(!0)},zT.prototype.setDatabaseDeletedListener=function(){},zT.prototype.setNetworkEnabled=function(t){},zT.prototype.getIndexManager=function(){return this.indexManager},zT.prototype.getMutationQueue=function(t){var e=this.mutationQueues[t.toKey()];return e||(e=new UT(this.indexManager,this.referenceDelegate),this.mutationQueues[t.toKey()]=e),e},zT.prototype.getTargetCache=function(){return this.targetCache},zT.prototype.getRemoteDocumentCache=function(){return this.remoteDocumentCache},zT.prototype.runTransaction=function(t,e,n){var r=this;eg("MemoryPersistence","Starting transaction:",t);var i=new YT(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})},zT.prototype.mutationQueuesContainKey=function(e,n){return ib.or(function(t){var n=[];return gg(t,function(t,e){return n.push(e)}),n}(this.mutationQueues).map(function(t){return function(){return t.containsKey(e,n)}}))},zT);function zT(t,e){var n=this;this.clientId=t,this.mutationQueues={},this.listenSequence=new $g(0),this._started=!1,this._started=!0,this.referenceDelegate=e(this),this.targetCache=new KT(this);this.indexManager=new I_,this.remoteDocumentCache=new BT(this.indexManager,function(t){return n.referenceDelegate.documentSize(t)})}var GT,YT=(_a(XT,GT=gE),XT);function XT(t){var e=GT.call(this)||this;return e.currentSequenceNumber=t,e}var JT=(Object.defineProperty($T.prototype,"orphanedDocuments",{get:function(){if(this._orphanedDocuments)return this._orphanedDocuments;throw ig("orphanedDocuments is only valid during a transaction.")},enumerable:!0,configurable:!0}),$T.prototype.setInMemoryPins=function(t){this.inMemoryPins=t},$T.prototype.addReference=function(t,e){return this.orphanedDocuments.delete(e),ib.resolve()},$T.prototype.removeReference=function(t,e){return this.orphanedDocuments.add(e),ib.resolve()},$T.prototype.removeMutationReference=function(t,e){return this.orphanedDocuments.add(e),ib.resolve()},$T.prototype.removeTarget=function(t,e){var n=this,r=this.persistence.getTargetCache();return r.getMatchingKeysForTargetId(t,e.targetId).next(function(t){t.forEach(function(t){return n.orphanedDocuments.add(t)})}).next(function(){return r.removeTargetData(t,e)})},$T.prototype.onTransactionStarted=function(){this._orphanedDocuments=new Set},$T.prototype.onTransactionCommitted=function(t){var n=this,r=this.persistence.getRemoteDocumentCache().newChangeBuffer();return ib.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)})},$T.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)})},$T.prototype.documentSize=function(t){return 0},$T.prototype.isReferenced=function(t,e){var n=this;return ib.or([function(){return n.persistence.getTargetCache().containsKey(t,e)},function(){return n.persistence.mutationQueuesContainKey(t,e)},function(){return ib.resolve(n.inMemoryPins.containsKey(e))}])},$T);function $T(t){this.persistence=t,this.inMemoryPins=null,this._orphanedDocuments=null}var ZT=(tS.prototype.onTransactionStarted=function(){},tS.prototype.onTransactionCommitted=function(t){return ib.resolve()},tS.prototype.forEachTarget=function(t,e){return this.persistence.getTargetCache().forEachTarget(t,e)},tS.prototype.getSequenceNumberCount=function(t){var n=this.orphanedDocumentCount(t);return this.persistence.getTargetCache().getTargetCount(t).next(function(e){return n.next(function(t){return e+t})})},tS.prototype.orphanedDocumentCount=function(t){var e=0;return this.forEachOrphanedDocumentSequenceNumber(t,function(t){e++}).next(function(){return e})},tS.prototype.forEachOrphanedDocumentSequenceNumber=function(n,r){var i=this;return ib.forEach(this.orphanedSequenceNumbers,function(t,e){return i.isPinned(n,t,e).next(function(t){return t?ib.resolve():r(e)})})},tS.prototype.setInMemoryPins=function(t){this.inMemoryPins=t},tS.prototype.removeTargets=function(t,e,n){return this.persistence.getTargetCache().removeTargets(t,e,n)},tS.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})},tS.prototype.removeMutationReference=function(t,e){return this.orphanedSequenceNumbers.set(e,t.currentSequenceNumber),ib.resolve()},tS.prototype.removeTarget=function(t,e){var n=e.withSequenceNumber(t.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(t,n)},tS.prototype.addReference=function(t,e){return this.orphanedSequenceNumbers.set(e,t.currentSequenceNumber),ib.resolve()},tS.prototype.removeReference=function(t,e){return this.orphanedSequenceNumbers.set(e,t.currentSequenceNumber),ib.resolve()},tS.prototype.updateLimboDocument=function(t,e){return this.orphanedSequenceNumbers.set(e,t.currentSequenceNumber),ib.resolve()},tS.prototype.documentSize=function(t){var e=t.key.toString().length;return t instanceof o_&&(e+=t.data().approximateByteSize()),e},tS.prototype.isPinned=function(t,e,n){var r=this;return ib.or([function(){return r.persistence.mutationQueuesContainKey(t,e)},function(){return ib.resolve(r.inMemoryPins.containsKey(e))},function(){return r.persistence.getTargetCache().containsKey(t,e)},function(){var t=r.orphanedSequenceNumbers.get(e);return ib.resolve(void 0!==t&&n<t)}])},tS.prototype.getCacheSize=function(t){return this.persistence.getRemoteDocumentCache().getSize(t)},tS);function tS(t,e){this.persistence=t,this.inMemoryPins=null,this.orphanedSequenceNumbers=new p_(function(t){return Tv(t.path)}),this.garbageCollector=new ME(this,e)}var eS=(nS.prototype.reset=function(){this.currentBaseMs=0},nS.prototype.resetToMax=function(){this.currentBaseMs=this.maxDelayMs},nS.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&&eg("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)},nS.prototype.cancel=function(){null!==this.timerPromise&&(this.timerPromise.cancel(),this.timerPromise=null)},nS.prototype.jitterDelayMs=function(){return(Math.random()-.5)*this.currentBaseMs},nS);function nS(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 rS,iS,oS="PersistentStream";(iS=rS=rS||{})[iS.Initial=0]="Initial",iS[iS.Starting=1]="Starting",iS[iS.Open=2]="Open",iS[iS.Error=3]="Error",iS[iS.Backoff=4]="Backoff";var aS=(sS.prototype.isStarted=function(){return this.state===rS.Starting||this.state===rS.Open||this.state===rS.Backoff},sS.prototype.isOpen=function(){return this.state===rS.Open},sS.prototype.start=function(){this.state!==rS.Error?(og(this.state===rS.Initial,"Already started"),this.auth()):this.performBackoff()},sS.prototype.stop=function(){return Ta(this,void 0,void 0,function(){return Sa(this,function(t){switch(t.label){case 0:return this.isStarted()?[4,this.close(rS.Initial)]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})},sS.prototype.inhibitBackoff=function(){og(!this.isStarted(),"Can only inhibit backoff in a stopped state"),this.state=rS.Initial,this.backoff.reset()},sS.prototype.markIdle=function(){var t=this;this.isOpen()&&null===this.idleTimer&&(this.idleTimer=this.queue.enqueueAfterDelay(this.idleTimerId,6e4,function(){return t.handleIdleCloseTimer()}))},sS.prototype.sendRequest=function(t){this.cancelIdleCheck(),this.stream.send(t)},sS.prototype.handleIdleCloseTimer=function(){return Ta(this,void 0,void 0,function(){return Sa(this,function(t){return this.isOpen()?[2,this.close(rS.Initial)]:[2]})})},sS.prototype.cancelIdleCheck=function(){this.idleTimer&&(this.idleTimer.cancel(),this.idleTimer=null)},sS.prototype.close=function(e,n){return Ta(this,void 0,void 0,function(){return Sa(this,function(t){switch(t.label){case 0:return og(this.isStarted(),"Only started streams should be closed."),og(e===rS.Error||ZE(n),"Can't provide an error when not in an error state."),this.cancelIdleCheck(),this.backoff.cancel(),this.closeCount++,e!==rS.Error?this.backoff.reset():n&&n.code===hg.RESOURCE_EXHAUSTED?(ng(n.toString()),ng("Using maximum backoff delay to prevent overloading the backend."),this.backoff.resetToMax()):n&&n.code===hg.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]}})})},sS.prototype.tearDown=function(){},sS.prototype.auth=function(){var n=this;og(this.state===rS.Initial,"Must be in initial state to auth"),this.state=rS.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 lg(hg.UNKNOWN,"Fetching auth token failed: "+e.message);return n.handleStreamClose(t)})})},sS.prototype.startStream=function(t){var e=this;og(this.state===rS.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 og(e.state===rS.Starting,"Expected stream to be in state Starting, but was "+e.state),e.state=rS.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)})})},sS.prototype.performBackoff=function(){var t=this;og(this.state===rS.Error,"Should only perform backoff when in Error state"),this.state=rS.Backoff,this.backoff.backoffAndRun(function(){return Ta(t,void 0,void 0,function(){return Sa(this,function(t){return og(this.state===rS.Backoff,"Backoff elapsed but state is now: "+this.state),this.state=rS.Initial,this.start(),og(this.isStarted(),"PersistentStream should have started"),[2]})})})},sS.prototype.handleStreamClose=function(t){return og(this.isStarted(),"Can't handle server close on non-started stream"),eg(oS,"close with error: "+t),this.stream=null,this.close(rS.Error,t)},sS.prototype.getCloseGuardedDispatcher=function(e){var n=this;return function(t){n.queue.enqueueAndForget(function(){return n.closeCount===e?t():(eg(oS,"stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())})}},sS);function sS(t,e,n,r,i,o){this.queue=t,this.idleTimerId=n,this.connection=r,this.credentialsProvider=i,this.listener=o,this.state=rS.Initial,this.closeCount=0,this.idleTimer=null,this.stream=null,this.backoff=new eS(t,e)}var uS,cS=(_a(hS,uS=aS),hS.prototype.startRpc=function(t){return this.connection.openStream("Listen",t)},hS.prototype.onMessage=function(t){this.backoff.reset();var e=this.serializer.fromWatchChange(t),n=this.serializer.versionFromListenResponse(t);return this.listener.onWatchChange(e,n)},hS.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)},hS.prototype.unwatch=function(t){var e={};e.database=this.serializer.encodedDatabaseId,e.removeTarget=t,this.sendRequest(e)},hS);function hS(t,e,n,r,i){var o=uS.call(this,t,fv.ListenStreamConnectionBackoff,fv.ListenStreamIdle,e,n,i)||this;return o.serializer=r,o}var lS,fS=(_a(pS,lS=aS),Object.defineProperty(pS.prototype,"handshakeComplete",{get:function(){return this.handshakeComplete_},enumerable:!0,configurable:!0}),pS.prototype.start=function(){this.handshakeComplete_=!1,lS.prototype.start.call(this)},pS.prototype.tearDown=function(){this.handshakeComplete_&&this.writeMutations([])},pS.prototype.startRpc=function(t){return this.connection.openStream("Write",t)},pS.prototype.onMessage=function(t){if(og(!!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 og(!t.writeResults||0===t.writeResults.length,"Got mutation results for handshake"),this.handshakeComplete_=!0,this.listener.onHandshakeComplete()},pS.prototype.writeHandshake=function(){og(this.isOpen(),"Writing handshake requires an opened stream"),og(!this.handshakeComplete_,"Handshake already completed");var t={};t.database=this.serializer.encodedDatabaseId,this.sendRequest(t)},pS.prototype.writeMutations=function(t){var e=this;og(this.isOpen(),"Writing mutations requires an opened stream"),og(this.handshakeComplete_,"Handshake must be complete before writing mutations"),og(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)},pS);function pS(t,e,n,r,i){var o=lS.call(this,t,fv.WriteStreamConnectionBackoff,fv.WriteStreamIdle,e,n,i)||this;return o.serializer=r,o.handshakeComplete_=!1,o.lastStreamToken=ug(),o}var dS=(yS.prototype.newPersistentWriteStream=function(t){return new fS(this.queue,this.connection,this.credentials,this.serializer,t)},yS.prototype.newPersistentWatchStream=function(t){return new cS(this.queue,this.connection,this.credentials,this.serializer,t)},yS.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)})},yS.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=Kv();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);og(!!e,"Missing entity in write response for "+t),r.push(e)}),r})},yS.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===hg.UNAUTHENTICATED&&r.credentials.invalidateToken(),t})},yS.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===hg.UNAUTHENTICATED&&r.credentials.invalidateToken(),t})},yS);function yS(t,e,n,r){this.queue=t,this.connection=e,this.credentials=n,this.serializer=r}var mS,gS,vS,bS,wS=(_S.prototype.lookup=function(r){return Ta(this,void 0,void 0,function(){var e,n=this;return Sa(this,function(t){switch(t.label){case 0:if(this.ensureCommitNotCalled(),0<this.mutations.length)throw new lg(hg.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 u_||t instanceof o_?n.recordVersion(t):ig("Document in a transaction was a "+t.constructor.name)}),[2,e]}})})},_S.prototype.set=function(t,e){this.write(e.toMutations(t,this.precondition(t))),this.writtenDocs.add(t)},_S.prototype.update=function(t,e){try{this.write(e.toMutations(t,this.preconditionForUpdate(t)))}catch(t){this.lastWriteError=t}this.writtenDocs.add(t)},_S.prototype.delete=function(t){this.write([new rw(t,this.precondition(t))]),this.writtenDocs.add(t)},_S.prototype.commit=function(){return Ta(this,void 0,void 0,function(){var e,n=this;return Sa(this,function(t){switch(t.label){case 0:if(this.ensureCommitNotCalled(),this.lastWriteError)throw this.lastWriteError;return e=this.readVersions,this.mutations.forEach(function(t){e=e.remove(t.key)}),e.forEach(function(t,e){n.mutations.push(new hw(t,n.precondition(t)))}),[4,this.datastore.commit(this.mutations)];case 1:return t.sent(),this.committed=!0,[2]}})})},_S.prototype.recordVersion=function(t){var e;if(t instanceof o_)e=t.version;else{if(!(t instanceof u_))throw ig("Document in a transaction was a "+t.constructor.name);e=Dv.forDeletedDoc()}var n=this.readVersions.get(t.key);if(null!==n){if(!e.isEqual(n))throw new lg(hg.ABORTED,"Document version changed between two reads.")}else this.readVersions=this.readVersions.insert(t.key,e)},_S.prototype.precondition=function(t){var e=this.readVersions.get(t);return!this.writtenDocs.has(t)&&e?Wb.updateTime(e):Wb.NONE},_S.prototype.preconditionForUpdate=function(t){var e=this.readVersions.get(t);if(this.writtenDocs.has(t)||!e)return Wb.exists(!0);if(e.isEqual(Dv.forDeletedDoc()))throw new lg(hg.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return Wb.updateTime(e)},_S.prototype.write=function(t){this.ensureCommitNotCalled(),this.mutations=this.mutations.concat(t)},_S.prototype.ensureCommitNotCalled=function(){og(!this.committed,"A transaction object cannot be used after its update callback has been invoked.")},_S);function _S(t){this.datastore=t,this.readVersions=Yv(),this.mutations=[],this.committed=!1,this.lastWriteError=null,this.writtenDocs=new Set}(gS=mS=mS||{})[gS.Unknown=0]="Unknown",gS[gS.Online=1]="Online",gS[gS.Offline=2]="Offline",(bS=vS=vS||{})[bS.RemoteStore=0]="RemoteStore",bS[bS.SharedClientState=1]="SharedClientState";var ES,TS,SS=(IS.prototype.handleWatchStreamStart=function(){var t=this;0===this.watchStreamFailures&&(this.setAndBroadcast(mS.Unknown),og(null===this.onlineStateTimer,"onlineStateTimer shouldn't be started yet"),this.onlineStateTimer=this.asyncQueue.enqueueAfterDelay(fv.OnlineStateTimeout,1e4,function(){return t.onlineStateTimer=null,og(t.state===mS.Unknown,"Timer should be canceled if we transitioned to a different state."),t.logClientOfflineWarningIfNecessary("Backend didn't respond within 10 seconds."),t.setAndBroadcast(mS.Offline),Promise.resolve()}))},IS.prototype.handleWatchStreamFailure=function(t){this.state===mS.Online?(this.setAndBroadcast(mS.Unknown),og(0===this.watchStreamFailures,"watchStreamFailures must be 0"),og(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(mS.Offline)))},IS.prototype.set=function(t){this.clearOnlineStateTimer(),this.watchStreamFailures=0,t===mS.Online&&(this.shouldWarnClientIsOffline=!1),this.setAndBroadcast(t)},IS.prototype.setAndBroadcast=function(t){t!==this.state&&(this.state=t,this.onlineStateHandler(t))},IS.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?(ng(e),this.shouldWarnClientIsOffline=!1):eg("OnlineStateTracker",e)},IS.prototype.clearOnlineStateTimer=function(){null!==this.onlineStateTimer&&(this.onlineStateTimer.cancel(),this.onlineStateTimer=null)},IS);function IS(t,e){this.asyncQueue=t,this.onlineStateHandler=e,this.state=mS.Unknown,this.watchStreamFailures=0,this.onlineStateTimer=null,this.shouldWarnClientIsOffline=!0}function CS(t){switch(t){case hg.OK:return ig("Treated status OK as error");case hg.CANCELLED:case hg.UNKNOWN:case hg.DEADLINE_EXCEEDED:case hg.RESOURCE_EXHAUSTED:case hg.INTERNAL:case hg.UNAVAILABLE:case hg.UNAUTHENTICATED:return!1;case hg.INVALID_ARGUMENT:case hg.NOT_FOUND:case hg.ALREADY_EXISTS:case hg.PERMISSION_DENIED:case hg.FAILED_PRECONDITION:case hg.ABORTED:case hg.OUT_OF_RANGE:case hg.UNIMPLEMENTED:case hg.DATA_LOSS:return!0;default:return ig("Unknown status code: "+t)}}function NS(t){if(void 0===t)return ng("GRPC error has no .code"),hg.UNKNOWN;switch(t){case ES.OK:return hg.OK;case ES.CANCELLED:return hg.CANCELLED;case ES.UNKNOWN:return hg.UNKNOWN;case ES.DEADLINE_EXCEEDED:return hg.DEADLINE_EXCEEDED;case ES.RESOURCE_EXHAUSTED:return hg.RESOURCE_EXHAUSTED;case ES.INTERNAL:return hg.INTERNAL;case ES.UNAVAILABLE:return hg.UNAVAILABLE;case ES.UNAUTHENTICATED:return hg.UNAUTHENTICATED;case ES.INVALID_ARGUMENT:return hg.INVALID_ARGUMENT;case ES.NOT_FOUND:return hg.NOT_FOUND;case ES.ALREADY_EXISTS:return hg.ALREADY_EXISTS;case ES.PERMISSION_DENIED:return hg.PERMISSION_DENIED;case ES.FAILED_PRECONDITION:return hg.FAILED_PRECONDITION;case ES.ABORTED:return hg.ABORTED;case ES.OUT_OF_RANGE:return hg.OUT_OF_RANGE;case ES.UNIMPLEMENTED:return hg.UNIMPLEMENTED;case ES.DATA_LOSS:return hg.DATA_LOSS;default:return ig("Unknown status code: "+t)}}(TS=ES=ES||{})[TS.OK=0]="OK",TS[TS.CANCELLED=1]="CANCELLED",TS[TS.UNKNOWN=2]="UNKNOWN",TS[TS.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",TS[TS.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",TS[TS.NOT_FOUND=5]="NOT_FOUND",TS[TS.ALREADY_EXISTS=6]="ALREADY_EXISTS",TS[TS.PERMISSION_DENIED=7]="PERMISSION_DENIED",TS[TS.UNAUTHENTICATED=16]="UNAUTHENTICATED",TS[TS.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",TS[TS.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",TS[TS.ABORTED=10]="ABORTED",TS[TS.OUT_OF_RANGE=11]="OUT_OF_RANGE",TS[TS.UNIMPLEMENTED=12]="UNIMPLEMENTED",TS[TS.INTERNAL=13]="INTERNAL",TS[TS.UNAVAILABLE=14]="UNAVAILABLE",TS[TS.DATA_LOSS=15]="DATA_LOSS";var AS,DS,kS,RS,OS=(PS.emptySet=function(t){return new PS(t.comparator)},PS.prototype.has=function(t){return null!=this.keyedMap.get(t)},PS.prototype.get=function(t){return this.keyedMap.get(t)},PS.prototype.first=function(){return this.sortedSet.minKey()},PS.prototype.last=function(){return this.sortedSet.maxKey()},PS.prototype.isEmpty=function(){return this.sortedSet.isEmpty()},PS.prototype.indexOf=function(t){var e=this.keyedMap.get(t);return e?this.sortedSet.indexOf(e):-1},Object.defineProperty(PS.prototype,"size",{get:function(){return this.sortedSet.size},enumerable:!0,configurable:!0}),PS.prototype.forEach=function(n){this.sortedSet.inorderTraversal(function(t,e){return n(t),!1})},PS.prototype.add=function(t){var e=this.delete(t.key);return e.copy(e.keyedMap.insert(t.key,t),e.sortedSet.insert(t,null))},PS.prototype.delete=function(t){var e=this.get(t);return e?this.copy(this.keyedMap.remove(t),this.sortedSet.remove(e)):this},PS.prototype.isEqual=function(t){if(!(t instanceof PS))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},PS.prototype.toString=function(){var e=[];return this.forEach(function(t){e.push(t.toString())}),0===e.length?"DocumentSet ()":"DocumentSet (\n "+e.join(" \n")+"\n)"},PS.prototype.copy=function(t,e){var n=new PS;return n.comparator=this.comparator,n.keyedMap=t,n.sortedSet=e,n},PS);function PS(n){this.comparator=n?function(t,e){return n(t,e)||hv.comparator(t.key,e.key)}:function(t,e){return hv.comparator(t.key,e.key)},this.keyedMap=zv(),this.sortedSet=new Rv(this.comparator)}(DS=AS=AS||{})[DS.Added=0]="Added",DS[DS.Removed=1]="Removed",DS[DS.Modified=2]="Modified",DS[DS.Metadata=3]="Metadata",(RS=kS=kS||{})[RS.Local=0]="Local",RS[RS.Synced=1]="Synced";var xS=(MS.prototype.track=function(t){var e=t.doc.key,n=this.changeMap.get(e);n?t.type!==AS.Added&&n.type===AS.Metadata?this.changeMap=this.changeMap.insert(e,t):t.type===AS.Metadata&&n.type!==AS.Removed?this.changeMap=this.changeMap.insert(e,{type:n.type,doc:t.doc}):t.type===AS.Modified&&n.type===AS.Modified?this.changeMap=this.changeMap.insert(e,{type:AS.Modified,doc:t.doc}):t.type===AS.Modified&&n.type===AS.Added?this.changeMap=this.changeMap.insert(e,{type:AS.Added,doc:t.doc}):t.type===AS.Removed&&n.type===AS.Added?this.changeMap=this.changeMap.remove(e):t.type===AS.Removed&&n.type===AS.Modified?this.changeMap=this.changeMap.insert(e,{type:AS.Removed,doc:n.doc}):t.type===AS.Added&&n.type===AS.Removed?this.changeMap=this.changeMap.insert(e,{type:AS.Modified,doc:t.doc}):ig("unsupported combination of changes: "+JSON.stringify(t)+" after "+JSON.stringify(n)):this.changeMap=this.changeMap.insert(e,t)},MS.prototype.getChanges=function(){var n=[];return this.changeMap.inorderTraversal(function(t,e){n.push(e)}),n},MS);function MS(){this.changeMap=new Rv(hv.comparator)}var LS=(FS.fromInitialDocuments=function(t,e,n,r){var i=[];return e.forEach(function(t){i.push({type:AS.Added,doc:t})}),new FS(t,e,OS.emptySet(e),i,n,r,!0,!1)},Object.defineProperty(FS.prototype,"hasPendingWrites",{get:function(){return!this.mutatedKeys.isEmpty()},enumerable:!0,configurable:!0}),FS.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},FS);function FS(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 US=(VS.createSynthesizedRemoteEventForCurrentChange=function(t,e){var n,r=((n={})[t]=qS.createSynthesizedTargetChangeForCurrentChange(t,e),n);return new VS(Dv.MIN,r,Zv(),Kv(),Jv())},VS);function VS(t,e,n,r,i){this.snapshotVersion=t,this.targetChanges=e,this.targetMismatches=n,this.documentUpdates=r,this.resolvedLimboDocuments=i}var qS=(BS.createSynthesizedTargetChangeForCurrentChange=function(t,e){return new BS(ug(),e,Jv(),Jv(),Jv())},BS);function BS(t,e,n,r,i){this.resumeToken=t,this.current=e,this.addedDocuments=n,this.modifiedDocuments=r,this.removedDocuments=i}var jS,WS,KS=function(t,e,n,r){this.updatedTargetIds=t,this.removedTargetIds=e,this.key=n,this.newDoc=r},QS=function(t,e){this.targetId=t,this.existenceFilter=e};(WS=jS=jS||{})[WS.NoChange=0]="NoChange",WS[WS.Added=1]="Added",WS[WS.Removed=2]="Removed",WS[WS.Current=3]="Current",WS[WS.Reset=4]="Reset";var HS=function(t,e,n,r){void 0===n&&(n=ug()),void 0===r&&(r=null),this.state=t,this.targetIds=e,this.resumeToken=n,this.cause=r},zS=(Object.defineProperty(GS.prototype,"current",{get:function(){return this._current},enumerable:!0,configurable:!0}),Object.defineProperty(GS.prototype,"resumeToken",{get:function(){return this._resumeToken},enumerable:!0,configurable:!0}),Object.defineProperty(GS.prototype,"isPending",{get:function(){return 0!==this.pendingResponses},enumerable:!0,configurable:!0}),Object.defineProperty(GS.prototype,"hasPendingChanges",{get:function(){return this._hasPendingChanges},enumerable:!0,configurable:!0}),GS.prototype.updateResumeToken=function(t){0<t.length&&(this._hasPendingChanges=!0,this._resumeToken=t)},GS.prototype.toTargetChange=function(){var n=Jv(),r=Jv(),i=Jv();return this.documentChanges.forEach(function(t,e){switch(e){case AS.Added:n=n.add(t);break;case AS.Modified:r=r.add(t);break;case AS.Removed:i=i.add(t);break;default:ig("Encountered invalid change type: "+e)}}),new qS(this._resumeToken,this._current,n,r,i)},GS.prototype.clearPendingChanges=function(){this._hasPendingChanges=!1,this.documentChanges=$S()},GS.prototype.addDocumentChange=function(t,e){this._hasPendingChanges=!0,this.documentChanges=this.documentChanges.insert(t,e)},GS.prototype.removeDocumentChange=function(t){this._hasPendingChanges=!0,this.documentChanges=this.documentChanges.remove(t)},GS.prototype.recordPendingTargetRequest=function(){this.pendingResponses+=1},GS.prototype.recordTargetResponse=function(){this.pendingResponses-=1},GS.prototype.markCurrent=function(){this._hasPendingChanges=!0,this._current=!0},GS);function GS(){this.pendingResponses=0,this.documentChanges=$S(),this._resumeToken=ug(),this._current=!1,this._hasPendingChanges=!0}var YS=(XS.prototype.handleDocumentChange=function(t){for(var e=0,n=t.updatedTargetIds;e<n.length;e++){var r=n[e];t.newDoc instanceof o_?this.addDocumentToTarget(r,t.newDoc):t.newDoc instanceof u_&&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)},XS.prototype.handleTargetChange=function(n){var r=this;this.forEachTarget(n,function(t){var e=r.ensureTargetState(t);switch(n.state){case jS.NoChange:r.isActiveTarget(t)&&e.updateResumeToken(n.resumeToken);break;case jS.Added:e.recordTargetResponse(),e.isPending||e.clearPendingChanges(),e.updateResumeToken(n.resumeToken);break;case jS.Removed:e.recordTargetResponse(),e.isPending||r.removeTarget(t),og(!n.cause,"WatchChangeAggregator does not handle errored targets");break;case jS.Current:r.isActiveTarget(t)&&(e.markCurrent(),e.updateResumeToken(n.resumeToken));break;case jS.Reset:r.isActiveTarget(t)&&(r.resetTarget(t),e.updateResumeToken(n.resumeToken));break;default:ig("Unknown target watch change state: "+n.state)}})},XS.prototype.forEachTarget=function(t,e){0<t.targetIds.length?t.targetIds.forEach(e):mg(this.targetStates,e)},XS.prototype.handleExistenceFilter=function(t){var e=t.targetId,n=t.existenceFilter.count,r=this.targetDataForActiveTarget(e);if(r){var i=r.target;if(i.isDocumentQuery())if(0===n){var o=new hv(i.path);this.removeDocumentFromTarget(e,o,new u_(o,Dv.forDeletedDoc()))}else og(1===n,"Single document existence filter with count: "+n);else this.getCurrentDocumentCountForTarget(e)!==n&&(this.resetTarget(e),this.pendingTargetResets=this.pendingTargetResets.add(e))}},XS.prototype.createRemoteEvent=function(i){var o=this,a={};mg(this.targetStates,function(t,e){var n=o.targetDataForActiveTarget(t);if(n){if(e.current&&n.target.isDocumentQuery()){var r=new hv(n.target.path);null!==o.pendingDocumentUpdates.get(r)||o.targetContainsDocument(t,r)||o.removeDocumentFromTarget(t,r,new u_(r,i))}e.hasPendingChanges&&(a[t]=e.toTargetChange(),e.clearPendingChanges())}});var r=Jv();this.pendingDocumentTargetMapping.forEach(function(t,e){var n=!0;e.forEachWhile(function(t){var e=o.targetDataForActiveTarget(t);return!e||e.purpose===iE.LimboResolution||(n=!1)}),n&&(r=r.add(t))});var t=new US(i,a,this.pendingTargetResets,this.pendingDocumentUpdates,r);return this.pendingDocumentUpdates=Kv(),this.pendingDocumentTargetMapping=JS(),this.pendingTargetResets=new Vv(qg),t},XS.prototype.addDocumentToTarget=function(t,e){if(this.isActiveTarget(t)){var n=this.targetContainsDocument(t,e.key)?AS.Modified:AS.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))}},XS.prototype.removeDocumentFromTarget=function(t,e,n){if(this.isActiveTarget(t)){var r=this.ensureTargetState(t);this.targetContainsDocument(t,e)?r.addDocumentChange(e,AS.Removed):r.removeDocumentChange(e),this.pendingDocumentTargetMapping=this.pendingDocumentTargetMapping.insert(e,this.ensureDocumentTargetMapping(e).delete(t)),n&&(this.pendingDocumentUpdates=this.pendingDocumentUpdates.insert(e,n))}},XS.prototype.removeTarget=function(t){delete this.targetStates[t]},XS.prototype.getCurrentDocumentCountForTarget=function(t){var e=this.ensureTargetState(t).toTargetChange();return this.metadataProvider.getRemoteKeysForTarget(t).size+e.addedDocuments.size-e.removedDocuments.size},XS.prototype.recordPendingTargetRequest=function(t){this.ensureTargetState(t).recordPendingTargetRequest()},XS.prototype.ensureTargetState=function(t){return this.targetStates[t]||(this.targetStates[t]=new zS),this.targetStates[t]},XS.prototype.ensureDocumentTargetMapping=function(t){var e=this.pendingDocumentTargetMapping.get(t);return e||(e=new Vv(qg),this.pendingDocumentTargetMapping=this.pendingDocumentTargetMapping.insert(t,e)),e},XS.prototype.isActiveTarget=function(t){var e=null!==this.targetDataForActiveTarget(t);return e||eg("WatchChangeAggregator","Detected inactive target",t),e},XS.prototype.targetDataForActiveTarget=function(t){var e=this.targetStates[t];return e&&e.isPending?null:this.metadataProvider.getTargetDataForTarget(t)},XS.prototype.resetTarget=function(e){var n=this;og(!this.targetStates[e].isPending,"Should only reset active targets"),this.targetStates[e]=new zS,this.metadataProvider.getRemoteKeysForTarget(e).forEach(function(t){n.removeDocumentFromTarget(e,t,null)})},XS.prototype.targetContainsDocument=function(t,e){return this.metadataProvider.getRemoteKeysForTarget(t).has(e)},XS);function XS(t){this.metadataProvider=t,this.targetStates={},this.pendingDocumentUpdates=Kv(),this.pendingDocumentTargetMapping=JS(),this.pendingTargetResets=new Vv(qg)}function JS(){return new Rv(hv.comparator)}function $S(){return new Rv(hv.comparator)}var ZS="RemoteStore",tI=(eI.prototype.start=function(){return this.enableNetwork()},eI.prototype.enableNetwork=function(){return Ta(this,void 0,void 0,function(){var e;return Sa(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(mS.Unknown),[4,this.fillWritePipeline()];case 2:t.sent(),t.label=3;case 3:return[2]}})})},eI.prototype.disableNetwork=function(){return Ta(this,void 0,void 0,function(){return Sa(this,function(t){switch(t.label){case 0:return this.networkEnabled=!1,[4,this.disableNetworkInternal()];case 1:return t.sent(),this.onlineStateTracker.set(mS.Offline),[2]}})})},eI.prototype.disableNetworkInternal=function(){return Ta(this,void 0,void 0,function(){return Sa(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&&(eg(ZS,"Stopping write stream with "+this.writePipeline.length+" pending writes"),this.writePipeline=[]),this.cleanUpWatchStreamState(),[2]}})})},eI.prototype.shutdown=function(){return Ta(this,void 0,void 0,function(){return Sa(this,function(t){switch(t.label){case 0:return eg(ZS,"RemoteStore shutting down."),this.networkEnabled=!1,[4,this.disableNetworkInternal()];case 1:return t.sent(),this.connectivityMonitor.shutdown(),this.onlineStateTracker.set(mS.Unknown),[2]}})})},eI.prototype.listen=function(t){dg(this.listenTargets,t.targetId)||(this.listenTargets[t.targetId]=t,this.shouldStartWatchStream()?this.startWatchStream():this.watchStream.isOpen()&&this.sendWatchRequest(t))},eI.prototype.unlisten=function(t){og(dg(this.listenTargets,t),"unlisten called on target no currently watched: "+t),delete this.listenTargets[t],this.watchStream.isOpen()&&this.sendUnwatchRequest(t),vg(this.listenTargets)&&(this.watchStream.isOpen()?this.watchStream.markIdle():this.canUseNetwork()&&this.onlineStateTracker.set(mS.Unknown))},eI.prototype.getTargetDataForTarget=function(t){return this.listenTargets[t]||null},eI.prototype.getRemoteKeysForTarget=function(t){return this.syncEngine.getRemoteKeysForTarget(t)},eI.prototype.sendWatchRequest=function(t){this.watchChangeAggregator.recordPendingTargetRequest(t.targetId),this.watchStream.watch(t)},eI.prototype.sendUnwatchRequest=function(t){this.watchChangeAggregator.recordPendingTargetRequest(t),this.watchStream.unwatch(t)},eI.prototype.startWatchStream=function(){og(this.shouldStartWatchStream(),"startWatchStream() called when shouldStartWatchStream() is false."),this.watchChangeAggregator=new YS(this),this.watchStream.start(),this.onlineStateTracker.handleWatchStreamStart()},eI.prototype.shouldStartWatchStream=function(){return this.canUseNetwork()&&!this.watchStream.isStarted()&&!vg(this.listenTargets)},eI.prototype.canUseNetwork=function(){return this.isPrimary&&this.networkEnabled},eI.prototype.cleanUpWatchStreamState=function(){this.watchChangeAggregator=null},eI.prototype.onWatchStreamOpen=function(){return Ta(this,void 0,void 0,function(){var n=this;return Sa(this,function(t){return mg(this.listenTargets,function(t,e){n.sendWatchRequest(e)}),[2]})})},eI.prototype.onWatchStreamClose=function(e){return Ta(this,void 0,void 0,function(){return Sa(this,function(t){return void 0===e&&og(!this.shouldStartWatchStream(),"Watch stream was stopped gracefully while still needed."),this.cleanUpWatchStreamState(),this.shouldStartWatchStream()?(this.onlineStateTracker.handleWatchStreamFailure(e),this.startWatchStream()):this.onlineStateTracker.set(mS.Unknown),[2]})})},eI.prototype.onWatchStreamChange=function(n,r){return Ta(this,void 0,void 0,function(){var e;return Sa(this,function(t){switch(t.label){case 0:return this.onlineStateTracker.set(mS.Online),n instanceof HS&&n.state===jS.Removed&&n.cause?[2,this.handleTargetError(n)]:(n instanceof KS?this.watchChangeAggregator.handleDocumentChange(n):n instanceof QS?this.watchChangeAggregator.handleExistenceFilter(n):(og(n instanceof HS,"Expected watchChange to be an instance of WatchTargetChange"),this.watchChangeAggregator.handleTargetChange(n)),r.isEqual(Dv.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]}})})},eI.prototype.raiseWatchSnapshot=function(r){var i=this;og(!r.isEqual(Dv.MIN),"Can't raise event for unknown SnapshotVersion");var t=this.watchChangeAggregator.createRemoteEvent(r);return mg(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(ug(),e.snapshotVersion),i.sendUnwatchRequest(t);var n=new hE(e.target,t,iE.ExistenceFilterMismatch,e.sequenceNumber);i.sendWatchRequest(n)}}),this.syncEngine.applyRemoteEvent(t)},eI.prototype.handleTargetError=function(t){var n=this;og(!!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 Ta(n,void 0,void 0,function(){return Sa(this,function(t){return dg(this.listenTargets,e)?(delete this.listenTargets[e],this.watchChangeAggregator.removeTarget(e),[2,this.syncEngine.rejectListen(e,r)]):[2]})})})}),i},eI.prototype.fillWritePipeline=function(){return Ta(this,void 0,void 0,function(){var e,n;return Sa(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]}})})},eI.prototype.canAddToWritePipeline=function(){return this.canUseNetwork()&&this.writePipeline.length<10},eI.prototype.outstandingWrites=function(){return this.writePipeline.length},eI.prototype.addToWritePipeline=function(t){og(this.canAddToWritePipeline(),"addToWritePipeline called when pipeline is full"),this.writePipeline.push(t),this.writeStream.isOpen()&&this.writeStream.handshakeComplete&&this.writeStream.writeMutations(t.mutations)},eI.prototype.shouldStartWriteStream=function(){return this.canUseNetwork()&&!this.writeStream.isStarted()&&0<this.writePipeline.length},eI.prototype.startWriteStream=function(){og(this.shouldStartWriteStream(),"startWriteStream() called when shouldStartWriteStream() is false."),this.writeStream.start()},eI.prototype.onWriteStreamOpen=function(){return Ta(this,void 0,void 0,function(){return Sa(this,function(t){return this.writeStream.writeHandshake(),[2]})})},eI.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(CE)},eI.prototype.onMutationResult=function(t,e){var n=this;og(0<this.writePipeline.length,"Got result for empty write pipeline");var r=this.writePipeline.shift(),i=nb.from(r,t,e,this.writeStream.lastStreamToken);return this.syncEngine.applySuccessfulWrite(i).then(function(){return n.fillWritePipeline()})},eI.prototype.onWriteStreamClose=function(n){return Ta(this,void 0,void 0,function(){var e=this;return Sa(this,function(t){return void 0===n&&og(!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]})})},eI.prototype.handleHandshakeError=function(e){return Ta(this,void 0,void 0,function(){return Sa(this,function(t){return CS(e.code)?(eg(ZS,"RemoteStore error before completed handshake; resetting stream token: ",this.writeStream.lastStreamToken),this.writeStream.lastStreamToken=ug(),[2,this.localStore.setLastStreamToken(ug()).catch(CE)]):[2]})})},eI.prototype.handleWriteError=function(r){return Ta(this,void 0,void 0,function(){var e,n=this;return Sa(this,function(t){return function(t){return CS(t)&&t!==hg.ABORTED}(r.code)?(e=this.writePipeline.shift(),this.writeStream.inhibitBackoff(),[2,this.syncEngine.rejectFailedWrite(e.batchId,r).then(function(){return n.fillWritePipeline()})]):[2]})})},eI.prototype.createTransaction=function(){return new wS(this.datastore)},eI.prototype.restartNetwork=function(){return Ta(this,void 0,void 0,function(){return Sa(this,function(t){switch(t.label){case 0:return this.networkEnabled=!1,[4,this.disableNetworkInternal()];case 1:return t.sent(),this.onlineStateTracker.set(mS.Unknown),[4,this.enableNetwork()];case 2:return t.sent(),[2]}})})},eI.prototype.handleCredentialChange=function(){return Ta(this,void 0,void 0,function(){return Sa(this,function(t){switch(t.label){case 0:return this.canUseNetwork()?(eg(ZS,"RemoteStore restarting streams for new credential"),[4,this.restartNetwork()]):[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})},eI.prototype.applyPrimaryState=function(e){return Ta(this,void 0,void 0,function(){return Sa(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(mS.Unknown),t.label=4;case 4:return[2]}})})},eI);function eI(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 Ta(o,void 0,void 0,function(){return Sa(this,function(t){switch(t.label){case 0:return this.canUseNetwork()?(eg(ZS,"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 SS(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 nI=(Object.defineProperty(rI.prototype,"latitude",{get:function(){return this._lat},enumerable:!0,configurable:!0}),Object.defineProperty(rI.prototype,"longitude",{get:function(){return this._long},enumerable:!0,configurable:!0}),rI.prototype.isEqual=function(t){return this._lat===t._lat&&this._long===t._long},rI.prototype._compareTo=function(t){return qg(this._lat,t._lat)||qg(this._long,t._long)},rI);function rI(t,e){if(wg("GeoPoint",arguments,2),Tg("GeoPoint","number",1,t),Tg("GeoPoint","number",2,e),!isFinite(t)||t<-90||90<t)throw new lg(hg.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+t);if(!isFinite(e)||e<-180||180<e)throw new lg(hg.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+e);this._lat=t,this._long=e}var iI=(oI.prototype.applyToLocalView=function(t,e){return new Vw(e,t)},oI.prototype.applyToRemoteDocument=function(t,e){return e},oI.prototype.computeBaseValue=function(t){return null},oI.prototype.isEqual=function(t){return t instanceof oI},oI.instance=new oI,oI);function oI(){}var aI=(sI.prototype.applyToLocalView=function(t,e){return this.apply(t)},sI.prototype.applyToRemoteDocument=function(t,e){return this.apply(t)},sI.prototype.apply=function(t){for(var n=fI(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 t_(n)},sI.prototype.computeBaseValue=function(t){return null},sI.prototype.isEqual=function(t){return t instanceof sI&&Bg(t.elements,this.elements)},sI);function sI(t){this.elements=t}var uI=(cI.prototype.applyToLocalView=function(t,e){return this.apply(t)},cI.prototype.applyToRemoteDocument=function(t,e){return this.apply(t)},cI.prototype.apply=function(t){for(var n=fI(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 t_(n)},cI.prototype.computeBaseValue=function(t){return null},cI.prototype.isEqual=function(t){return t instanceof cI&&Bg(t.elements,this.elements)},cI);function cI(t){this.elements=t}var hI=(lI.prototype.applyToLocalView=function(t,e){var n=this.computeBaseValue(t);if(n instanceof Nw&&this.operand instanceof Nw){var r=n.internalValue+this.operand.internalValue;return new Nw(r)}return r=n.internalValue+this.operand.internalValue,new kw(r)},lI.prototype.applyToRemoteDocument=function(t,e){return og(null!==e,"Didn't receive transformResult for NUMERIC_ADD transform"),e},lI.prototype.computeBaseValue=function(t){return t instanceof Tw?t:new Nw(0)},lI.prototype.isEqual=function(t){return t instanceof lI&&this.operand.isEqual(t.operand)},lI);function lI(t){this.operand=t}function fI(t){return t instanceof t_?t.internalValue.slice():[]}var pI=(dI.prototype.isEqual=function(t){return t&&t.count===this.count},dI);function dI(t){this.count=t}var yI,mI,gI=((yI={})[AT.ASCENDING.name]="ASCENDING",yI[AT.DESCENDING.name]="DESCENDING",yI),vI=((mI={})[uT.LESS_THAN.name]="LESS_THAN",mI[uT.LESS_THAN_OR_EQUAL.name]="LESS_THAN_OR_EQUAL",mI[uT.GREATER_THAN.name]="GREATER_THAN",mI[uT.GREATER_THAN_OR_EQUAL.name]="GREATER_THAN_OR_EQUAL",mI[uT.EQUAL.name]="EQUAL",mI[uT.ARRAY_CONTAINS.name]="ARRAY_CONTAINS",mI[uT.IN.name]="IN",mI[uT.ARRAY_CONTAINS_ANY.name]="ARRAY_CONTAINS_ANY",mI),bI=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function wI(t,e){og(!ZE(t),e+" is missing")}function _I(t){return"number"==typeof t?t:"string"==typeof t?Number(t):ig("can't parse "+t)}var EI=(TI.prototype.emptyByteString=function(){return this.options.useProto3Json?"":new Uint8Array(0)},TI.prototype.unsafeCastProtoByteString=function(t){return t},TI.prototype.fromRpcStatus=function(t){var e=void 0===t.code?hg.UNKNOWN:NS(t.code);return new lg(e,t.message||"")},TI.prototype.toInt32Value=function(t){return this.options.useProto3Json||ZE(t)?t:{value:t}},TI.prototype.fromInt32Value=function(t){var e;return ZE(e="object"==typeof t?t.value:t)?null:e},TI.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}},TI.prototype.fromTimestamp=function(t){if("string"==typeof t)return this.fromIso8601String(t);og(!!t,"Cannot deserialize null or undefined timestamp.");var e=_I(t.seconds||"0"),n=t.nanos||0;return new Nv(e,n)},TI.prototype.fromIso8601String=function(t){var e=0,n=bI.exec(t);if(og(!!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 Nv(o,e)},TI.prototype.toBytes=function(t){return this.options.useProto3Json?t.toBase64():this.unsafeCastProtoByteString(t.toUint8Array())},TI.prototype.fromBlob=function(t){return"string"==typeof t?(og(this.options.useProto3Json,"Expected bytes to be passed in as Uint8Array, but got a string instead."),Qg.fromBase64String(t)):(og(!this.options.useProto3Json,"Expected bytes to be passed in as Uint8Array, but got a string instead."),Qg.fromUint8Array(t))},TI.prototype.toVersion=function(t){return this.toTimestamp(t.toTimestamp())},TI.prototype.fromVersion=function(t){return og(!!t,"Trying to deserialize version that isn't set"),Dv.fromTimestamp(this.fromTimestamp(t))},TI.prototype.toResourceName=function(t,e){return this.fullyQualifiedPrefixPath(t).child("documents").child(e).canonicalString()},TI.prototype.fromResourceName=function(t){var e=iv.fromString(t);return og(this.isValidResourceName(e),"Tried to deserialize invalid key "+e.toString()),e},TI.prototype.toName=function(t){return this.toResourceName(this.databaseId,t.path)},TI.prototype.fromName=function(t){var e=this.fromResourceName(t);return og(e.get(1)===this.databaseId.projectId,"Tried to deserialize key from different project: "+e.get(1)+" vs "+this.databaseId.projectId),og(!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 hv(this.extractLocalPathFromResourceName(e))},TI.prototype.toQueryPath=function(t){return this.toResourceName(this.databaseId,t)},TI.prototype.fromQueryPath=function(t){var e=this.fromResourceName(t);return 4===e.length?iv.EMPTY_PATH:this.extractLocalPathFromResourceName(e)},Object.defineProperty(TI.prototype,"encodedDatabaseId",{get:function(){return new iv(["projects",this.databaseId.projectId,"databases",this.databaseId.database]).canonicalString()},enumerable:!0,configurable:!0}),TI.prototype.fullyQualifiedPrefixPath=function(t){return new iv(["projects",t.projectId,"databases",t.database])},TI.prototype.extractLocalPathFromResourceName=function(t){return og(4<t.length&&"documents"===t.get(4),"tried to deserialize invalid key "+t.toString()),t.popFirst(5)},TI.prototype.isValidResourceName=function(t){return 4<=t.length&&"projects"===t.get(0)&&"databases"===t.get(2)},TI.prototype.toValue=function(t){if(t instanceof gw)return{nullValue:"NULL_VALUE"};if(t instanceof ww)return{booleanValue:t.value()};if(t instanceof Nw)return{integerValue:""+t.value()};if(t instanceof kw){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 Pw?{stringValue:t.value()}:t instanceof Jw?{mapValue:this.toMapValue(t)}:t instanceof t_?{arrayValue:this.toArrayValue(t)}:t instanceof Lw?{timestampValue:this.toTimestamp(t.internalValue)}:t instanceof Gw?{geoPointValue:{latitude:t.value().latitude,longitude:t.value().longitude}}:t instanceof jw?{bytesValue:this.toBytes(t.value())}:t instanceof Qw?{referenceValue:this.toResourceName(t.databaseId,t.key.path)}:ig("Unknown FieldValue "+JSON.stringify(t))},TI.prototype.fromValue=function(t){var e=this;if("nullValue"in t)return gw.INSTANCE;if("booleanValue"in t)return ww.of(t.booleanValue);if("integerValue"in t)return new Nw(_I(t.integerValue));if("doubleValue"in t){if(this.options.useProto3Json){if("NaN"===t.doubleValue)return kw.NAN;if("Infinity"===t.doubleValue)return kw.POSITIVE_INFINITY;if("-Infinity"===t.doubleValue)return kw.NEGATIVE_INFINITY}return new kw(t.doubleValue)}if("stringValue"in t)return new Pw(t.stringValue);if("mapValue"in t)return this.fromFields(t.mapValue.fields||{});if("arrayValue"in t){wI(t.arrayValue,"arrayValue");var n=t.arrayValue.values||[];return new t_(n.map(function(t){return e.fromValue(t)}))}if("timestampValue"in t)return wI(t.timestampValue,"timestampValue"),new Lw(this.fromTimestamp(t.timestampValue));if("geoPointValue"in t){wI(t.geoPointValue,"geoPointValue");var r=t.geoPointValue.latitude||0,i=t.geoPointValue.longitude||0;return new Gw(new nI(r,i))}if("bytesValue"in t){wI(t.bytesValue,"bytesValue");var o=this.fromBlob(t.bytesValue);return new jw(o)}if("referenceValue"in t){wI(t.referenceValue,"referenceValue");var a=this.fromResourceName(t.referenceValue),s=new Xg(a.get(1),a.get(3)),u=new hv(this.extractLocalPathFromResourceName(a));return new Qw(s,u)}return ig("Unknown Value proto "+JSON.stringify(t))},TI.prototype.toMutationDocument=function(t,e){return{name:this.toName(t),fields:this.toFields(e)}},TI.prototype.toDocument=function(t){return og(!t.hasLocalMutations,"Can't serialize documents with mutations."),{name:this.toName(t.key),fields:this.toFields(t.data()),updateTime:this.toTimestamp(t.version.toTimestamp())}},TI.prototype.fromDocument=function(t,e){var n=this,r=this.fromName(t.name),i=this.fromVersion(t.updateTime);return new o_(r,i,{hasCommittedMutations:!!e},void 0,t,function(t){return n.fromValue(t)})},TI.prototype.toFields=function(t){var n=this,r={};return t.forEach(function(t,e){r[t]=n.toValue(e)}),r},TI.prototype.fromFields=function(t){var n=this,e=t,r=Jw.EMPTY;return gg(e,function(t,e){r=r.set(new uv([t]),n.fromValue(e))}),r},TI.prototype.toMapValue=function(t){return{fields:this.toFields(t)}},TI.prototype.toArrayValue=function(t){var e=this,n=[];return t.forEach(function(t){n.push(e.toValue(t))}),{values:n}},TI.prototype.fromFound=function(t){var e=this;og(!!t.found,"Tried to deserialize a found document from a missing document."),wI(t.found.name,"doc.found.name"),wI(t.found.updateTime,"doc.found.updateTime");var n=this.fromName(t.found.name),r=this.fromVersion(t.found.updateTime);return new o_(n,r,{},void 0,t.found,function(t){return e.fromValue(t)})},TI.prototype.fromMissing=function(t){og(!!t.missing,"Tried to deserialize a missing document from a found document."),og(!!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 u_(e,n)},TI.prototype.fromMaybeDocument=function(t){return"found"in t?this.fromFound(t):"missing"in t?this.fromMissing(t):ig("invalid batch get response: "+JSON.stringify(t))},TI.prototype.toWatchTargetChangeState=function(t){switch(t){case jS.Added:return"ADD";case jS.Current:return"CURRENT";case jS.NoChange:return"NO_CHANGE";case jS.Removed:return"REMOVE";case jS.Reset:return"RESET";default:return ig("Unknown WatchTargetChangeState: "+t)}},TI.prototype.toTestWatchChange=function(t){if(t instanceof QS)return{filter:{count:t.existenceFilter.count,targetId:t.targetId}};if(t instanceof KS){if(t.newDoc instanceof o_){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 u_)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 HS){var n=void 0;return t.cause&&(n={code:function(t){if(void 0===t)return ES.OK;switch(t){case hg.OK:return ES.OK;case hg.CANCELLED:return ES.CANCELLED;case hg.UNKNOWN:return ES.UNKNOWN;case hg.DEADLINE_EXCEEDED:return ES.DEADLINE_EXCEEDED;case hg.RESOURCE_EXHAUSTED:return ES.RESOURCE_EXHAUSTED;case hg.INTERNAL:return ES.INTERNAL;case hg.UNAVAILABLE:return ES.UNAVAILABLE;case hg.UNAUTHENTICATED:return ES.UNAUTHENTICATED;case hg.INVALID_ARGUMENT:return ES.INVALID_ARGUMENT;case hg.NOT_FOUND:return ES.NOT_FOUND;case hg.ALREADY_EXISTS:return ES.ALREADY_EXISTS;case hg.PERMISSION_DENIED:return ES.PERMISSION_DENIED;case hg.FAILED_PRECONDITION:return ES.FAILED_PRECONDITION;case hg.ABORTED:return ES.ABORTED;case hg.OUT_OF_RANGE:return ES.OUT_OF_RANGE;case hg.UNIMPLEMENTED:return ES.UNIMPLEMENTED;case hg.DATA_LOSS:return ES.DATA_LOSS;default:return ig("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 ig("Unrecognized watch change: "+JSON.stringify(t))},TI.prototype.fromWatchChange=function(t){var e,n=this;if("targetChange"in t){wI(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 HS(r,i,o,s||null)}else if("documentChange"in t){wI(t.documentChange,"documentChange");var u=t.documentChange;wI(u.document,"documentChange.name"),wI(u.document.name,"documentChange.document.name"),wI(u.document.updateTime,"documentChange.document.updateTime");var c=this.fromName(u.document.name),h=this.fromVersion(u.document.updateTime),l=new o_(c,h,{},void 0,u.document,function(t){return n.fromValue(t)}),f=u.targetIds||[],p=u.removedTargetIds||[];e=new KS(f,p,l.key,l)}else if("documentDelete"in t){wI(t.documentDelete,"documentDelete");var d=t.documentDelete;wI(d.document,"documentDelete.document"),c=this.fromName(d.document),h=d.readTime?this.fromVersion(d.readTime):Dv.forDeletedDoc(),l=new u_(c,h),p=d.removedTargetIds||[],e=new KS([],p,l.key,l)}else if("documentRemove"in t){wI(t.documentRemove,"documentRemove");var y=t.documentRemove;wI(y.document,"documentRemove"),c=this.fromName(y.document),p=y.removedTargetIds||[],e=new KS([],p,c,null)}else{if(!("filter"in t))return ig("Unknown change type "+JSON.stringify(t));wI(t.filter,"filter");var m=t.filter;wI(m.targetId,"filter.targetId");var g=m.count||0,v=new pI(g),b=m.targetId;e=new QS(b,v)}return e},TI.prototype.fromWatchTargetChangeState=function(t){return"NO_CHANGE"===t?jS.NoChange:"ADD"===t?jS.Added:"REMOVE"===t?jS.Removed:"CURRENT"===t?jS.Current:"RESET"===t?jS.Reset:ig("Got unexpected TargetChange.state: "+t)},TI.prototype.versionFromListenResponse=function(t){if(!("targetChange"in t))return Dv.MIN;var e=t.targetChange;return e.targetIds&&e.targetIds.length?Dv.MIN:e.readTime?this.fromVersion(e.readTime):Dv.MIN},TI.prototype.toMutation=function(t){var e,n=this;if(t instanceof Gb)e={update:this.toMutationDocument(t.key,t.value)};else if(t instanceof rw)e={delete:this.toName(t.key)};else if(t instanceof Jb)e={update:this.toMutationDocument(t.key,t.data),updateMask:this.toDocumentMask(t.fieldMask)};else if(t instanceof tw)e={transform:{document:this.toName(t.key),fieldTransforms:t.fieldTransforms.map(function(t){return n.toFieldTransform(t)})}};else{if(!(t instanceof hw))return ig("Unknown mutation type "+t.type);e={verify:this.toName(t.key)}}return t.precondition.isNone||(e.currentDocument=this.toPrecondition(t.precondition)),e},TI.prototype.fromMutation=function(t){var e=this,n=t.currentDocument?this.fromPrecondition(t.currentDocument):Wb.NONE;if(t.update){wI(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 Jb(r,i,o,n)}return new Gb(r,i,n)}if(t.delete)return r=this.fromName(t.delete),new rw(r,n);if(t.transform){r=this.fromName(t.transform.document);var a=t.transform.fieldTransforms.map(function(t){return e.fromFieldTransform(t)});return og(!0===n.exists,'Transforms only support precondition "exists == true"'),new tw(r,a)}return t.verify?(r=this.fromName(t.verify),new hw(r,n)):ig("unknown mutation proto: "+JSON.stringify(t))},TI.prototype.toPrecondition=function(t){return og(!t.isNone,"Can't serialize an empty precondition"),void 0!==t.updateTime?{updateTime:this.toVersion(t.updateTime)}:void 0!==t.exists?{exists:t.exists}:ig("Unknown precondition")},TI.prototype.fromPrecondition=function(t){return void 0!==t.updateTime?Wb.updateTime(this.fromVersion(t.updateTime)):void 0!==t.exists?Wb.exists(t.exists):Wb.NONE},TI.prototype.fromWriteResult=function(t,e){var n=this,r=t.updateTime?this.fromVersion(t.updateTime):this.fromVersion(e);r.isEqual(Dv.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 jb(r,i)},TI.prototype.fromWriteResults=function(t,e){var n=this;return t&&0<t.length?(og(void 0!==e,"Received a write result without a commit time"),t.map(function(t){return n.fromWriteResult(t,e)})):[]},TI.prototype.toFieldTransform=function(t){var e=this,n=t.transform;if(n instanceof iI)return{fieldPath:t.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(n instanceof aI)return{fieldPath:t.field.canonicalString(),appendMissingElements:{values:n.elements.map(function(t){return e.toValue(t)})}};if(n instanceof uI)return{fieldPath:t.field.canonicalString(),removeAllFromArray:{values:n.elements.map(function(t){return e.toValue(t)})}};if(n instanceof hI)return{fieldPath:t.field.canonicalString(),increment:this.toValue(n.operand)};throw ig("Unknown transform: "+t.transform)},TI.prototype.fromFieldTransform=function(t){var e=this,n=null;if("setToServerValue"in t)og("REQUEST_TIME"===t.setToServerValue,"Unknown server value transform proto: "+JSON.stringify(t)),n=iI.instance;else if("appendMissingElements"in t){var r=t.appendMissingElements.values||[];n=new aI(r.map(function(t){return e.fromValue(t)}))}else if("removeAllFromArray"in t)r=t.removeAllFromArray.values||[],n=new uI(r.map(function(t){return e.fromValue(t)}));else if("increment"in t){var i=this.fromValue(t.increment);og(i instanceof Tw,"NUMERIC_ADD transform requires a NumberValue"),n=new hI(i)}else ig("Unknown transform proto: "+JSON.stringify(t));var o=uv.fromServerFormat(t.fieldPath);return new Ub(o,n)},TI.prototype.toDocumentsTarget=function(t){return{documents:[this.toQueryPath(t.path)]}},TI.prototype.fromDocumentsTarget=function(t){var e=t.documents.length;og(1===e,"DocumentsTarget contained other than 1 document: "+e);var n=t.documents[0];return oT.atPath(this.fromQueryPath(n)).toTarget()},TI.prototype.toQueryTarget=function(t){var e={structuredQuery:{}},n=t.path;null!==t.collectionGroup?(og(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}]):(og(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},TI.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){og(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 oT(e,i,s,a,u,eT.First,c,h).toTarget()},TI.prototype.toListenRequestLabels=function(t){var e=this.toLabel(t.purpose);return null==e?null:{"goog-listen-tags":e}},TI.prototype.toLabel=function(t){switch(t){case iE.Listen:return null;case iE.ExistenceFilterMismatch:return"existence-filter-mismatch";case iE.LimboResolution:return"limbo-document";default:return ig("Unrecognized query purpose: "+t)}},TI.prototype.toTarget=function(t){var e,n=t.target;return(e=n.isDocumentQuery()?{documents:this.toDocumentsTarget(n)}:{query:this.toQueryTarget(n)}).targetId=t.targetId,0<t.resumeToken.length&&(e.resumeToken=this.unsafeCastProtoByteString(t.resumeToken)),e},TI.prototype.toFilter=function(t){var e=this;if(0!==t.length){var n=t.map(function(t){return t instanceof lT?e.toUnaryOrFieldFilter(t):ig("Unrecognized filter: "+JSON.stringify(t))});return 1===n.length?n[0]:{compositeFilter:{op:"AND",filters:n}}}},TI.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)}):ig("Unknown filter: "+JSON.stringify(t)):[]},TI.prototype.toOrder=function(t){var e=this;if(0!==t.length)return t.map(function(t){return e.toPropertyOrder(t)})},TI.prototype.fromOrder=function(t){var e=this;return t.map(function(t){return e.fromPropertyOrder(t)})},TI.prototype.toCursor=function(t){var e=this;return{before:t.before,values:t.position.map(function(t){return e.toValue(t)})}},TI.prototype.fromCursor=function(t){var e=this,n=!!t.before,r=t.values.map(function(t){return e.fromValue(t)});return new kT(r,n)},TI.prototype.toDirection=function(t){return gI[t.name]},TI.prototype.fromDirection=function(t){switch(t){case"ASCENDING":return AT.ASCENDING;case"DESCENDING":return AT.DESCENDING;default:return}},TI.prototype.toOperatorName=function(t){return vI[t.name]},TI.prototype.fromOperatorName=function(t){switch(t){case"EQUAL":return uT.EQUAL;case"GREATER_THAN":return uT.GREATER_THAN;case"GREATER_THAN_OR_EQUAL":return uT.GREATER_THAN_OR_EQUAL;case"LESS_THAN":return uT.LESS_THAN;case"LESS_THAN_OR_EQUAL":return uT.LESS_THAN_OR_EQUAL;case"ARRAY_CONTAINS":return uT.ARRAY_CONTAINS;case"IN":return uT.IN;case"ARRAY_CONTAINS_ANY":return uT.ARRAY_CONTAINS_ANY;case"OPERATOR_UNSPECIFIED":return ig("Unspecified operator");default:return ig("Unknown operator")}},TI.prototype.toFieldPathReference=function(t){return{fieldPath:t.canonicalString()}},TI.prototype.fromFieldPathReference=function(t){return uv.fromServerFormat(t.fieldPath)},TI.prototype.toPropertyOrder=function(t){return{field:this.toFieldPathReference(t.field),direction:this.toDirection(t.dir)}},TI.prototype.fromPropertyOrder=function(t){return new OT(this.fromFieldPathReference(t.field),this.fromDirection(t.direction))},TI.prototype.fromFieldFilter=function(t){return lT.create(this.fromFieldPathReference(t.fieldFilter.field),this.fromOperatorName(t.fieldFilter.op),this.fromValue(t.fieldFilter.value))},TI.prototype.toUnaryOrFieldFilter=function(t){if(t.op===uT.EQUAL){if(t.value.isEqual(kw.NAN))return{unaryFilter:{field:this.toFieldPathReference(t.field),op:"IS_NAN"}};if(t.value.isEqual(gw.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)}}},TI.prototype.fromUnaryFilter=function(t){switch(t.unaryFilter.op){case"IS_NAN":var e=this.fromFieldPathReference(t.unaryFilter.field);return lT.create(e,uT.EQUAL,kw.NAN);case"IS_NULL":var n=this.fromFieldPathReference(t.unaryFilter.field);return lT.create(n,uT.EQUAL,gw.INSTANCE);case"OPERATOR_UNSPECIFIED":return ig("Unspecified filter");default:return ig("Unknown filter")}},TI.prototype.toDocumentMask=function(t){var e=[];return t.fields.forEach(function(t){return e.push(t.canonicalString())}),{fieldPaths:e}},TI.prototype.fromDocumentMask=function(t){var e=(t.fieldPaths||[]).map(function(t){return uv.fromServerFormat(t)});return Lb.fromArray(e)},TI);function TI(t,e){this.databaseId=t,this.options=e}var SI=function(){this.viewSnap=null,this.targetId=0,this.listeners=[]},II=(CI.prototype.listen=function(t){var e=t.query,n=!1,r=this.queries.get(e);return r||(n=!0,r=new SI,this.queries.set(e,r)),r.listeners.push(t),og(!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)},CI.prototype.unlisten=function(o){return Ta(this,void 0,void 0,function(){var e,n,r,i;return Sa(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]})})},CI.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()},CI.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)},CI.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()},CI.prototype.addSnapshotsInSyncListener=function(t){this.snapshotsInSyncListeners.add(t),t.next()},CI.prototype.removeSnapshotsInSyncListener=function(t){this.snapshotsInSyncListeners.delete(t)},CI.prototype.raiseSnapshotsInSyncEvent=function(){this.snapshotsInSyncListeners.forEach(function(t){t.next()})},CI);function CI(t){this.syncEngine=t,this.queries=new p_(function(t){return t.canonicalId()}),this.onlineState=mS.Unknown,this.snapshotsInSyncListeners=new Set,this.syncEngine.subscribe(this)}var NI=(AI.prototype.onViewSnapshot=function(t){if(og(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!==AS.Metadata&&e.push(i)}t=new LS(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},AI.prototype.onError=function(t){this.queryObserver.error(t)},AI.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},AI.prototype.shouldRaiseInitialEvent=function(t,e){if(og(!this.raisedInitialEvent,"Determining whether to raise first event but already had first event"),!t.fromCache)return!0;var n=e!==mS.Offline;return this.options.waitForSyncWhenOnline&&n?(og(t.fromCache,"Waiting for sync, but snapshot is not from cache"),!1):!t.docs.isEmpty()||e===mS.Offline},AI.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},AI.prototype.raiseInitialEvent=function(t){og(!this.raisedInitialEvent,"Trying to raise initial events for second time"),t=LS.fromInitialDocuments(t.query,t.docs,t.mutatedKeys,t.fromCache),this.raisedInitialEvent=!0,this.queryObserver.next(t)},AI);function AI(t,e,n){this.query=t,this.queryObserver=e,this.raisedInitialEvent=!1,this.snap=null,this.onlineState=mS.Unknown,this.options=n||{}}var DI=(kI.fromSnapshot=function(t,e){for(var n=Jv(),r=Jv(),i=0,o=e.docChanges;i<o.length;i++){var a=o[i];switch(a.type){case AS.Added:n=n.add(a.doc.key);break;case AS.Removed:r=r.add(a.doc.key)}}return new kI(t,e.fromCache,n,r)},kI);function kI(t,e,n,r){this.targetId=t,this.fromCache=e,this.addedKeys=n,this.removedKeys=r}var RI=function(t){this.key=t},OI=function(t){this.key=t},PI=(Object.defineProperty(xI.prototype,"syncedDocuments",{get:function(){return this._syncedDocuments},enumerable:!0,configurable:!0}),xI.prototype.computeDocChanges=function(t,e){var s=this,u=e?e.changeSet:new xS,c=e?e.documentSet:this.documentSet,h=e?e.mutatedKeys:this.mutatedKeys,l=c,f=!1,p=this.query.hasLimitToFirst()&&c.size===this.query.limit?c.last():null,d=this.query.hasLimitToLast()&&c.size===this.query.limit?c.first():null;if(t.inorderTraversal(function(t,e){var n=c.get(t),r=e instanceof o_?e:null;r&&(og(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:AS.Metadata,doc:r}),a=!0):s.shouldWaitForSyncedDocument(n,r)||(u.track({type:AS.Modified,doc:r}),a=!0,(p&&0<s.query.docComparator(r,p)||d&&s.query.docComparator(r,d)<0)&&(f=!0)):!n&&r?(u.track({type:AS.Added,doc:r}),a=!0):n&&!r&&(u.track({type:AS.Removed,doc:n}),a=!0,(p||d)&&(f=!0)),a&&(h=r?(l=l.add(r),o?h.add(t):h.delete(t)):(l=l.delete(t),h.delete(t)))}),this.query.hasLimitToFirst()||this.query.hasLimitToLast())for(;l.size>this.query.limit;){var n=this.query.hasLimitToFirst()?l.last():l.first();l=l.delete(n.key),h=h.delete(n.key),u.track({type:AS.Removed,doc:n})}return og(!f||!e,"View was refilled using docs that themselves needed refilling."),{documentSet:l,changeSet:u,needsRefill:f,mutatedKeys:h}},xI.prototype.shouldWaitForSyncedDocument=function(t,e){return t.hasLocalMutations&&e.hasCommittedMutations&&!e.hasLocalMutations},xI.prototype.applyChanges=function(t,e,n){var r=this;og(!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 AS.Added:return 1;case AS.Modified:case AS.Metadata:return 2;case AS.Removed:return 0;default:return ig("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?kS.Synced:kS.Local,u=s!==this.syncState;return this.syncState=s,0!==o.length||u?{snapshot:new LS(this.query,t.documentSet,i,o,t.mutatedKeys,s===kS.Local,u,!1),limboChanges:a}:{limboChanges:a}},xI.prototype.applyOnlineStateChange=function(t){return this.current&&t===mS.Offline?(this.current=!1,this.applyChanges({documentSet:this.documentSet,changeSet:new xS,mutatedKeys:this.mutatedKeys,needsRefill:!1},!1)):{limboChanges:[]}},xI.prototype.shouldBeInLimbo=function(t){return!this._syncedDocuments.has(t)&&!!this.documentSet.has(t)&&!this.documentSet.get(t).hasLocalMutations},xI.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 og(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)},xI.prototype.updateLimboDocuments=function(){var e=this;if(!this.current)return[];var n=this.limboDocuments;this.limboDocuments=Jv(),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 OI(t))}),this.limboDocuments.forEach(function(t){n.has(t)||r.push(new RI(t))}),r},xI.prototype.synchronizeWithPersistedState=function(t){this._syncedDocuments=t.remoteKeys,this.limboDocuments=Jv();var e=this.computeDocChanges(t.documents);return this.applyChanges(e,!0)},xI.prototype.computeInitialSnapshot=function(){return LS.fromInitialDocuments(this.query,this.documentSet,this.mutatedKeys,this.syncState===kS.Local)},xI);function xI(t,e){this.query=t,this._syncedDocuments=e,this.syncState=null,this.current=!1,this.limboDocuments=Jv(),this.mutatedKeys=Jv(),this.documentSet=new OS(t.docComparator.bind(t))}var MI=(LI.prototype.run=function(){this.runWithBackOff()},LI.prototype.runWithBackOff=function(){var t=this;this.backoff.backoffAndRun(function(){return Ta(t,void 0,void 0,function(){var e,n,r=this;return Sa(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]})})})},LI.prototype.tryRunUpdateFunction=function(t){try{var e=this.updateFunction(t);return!ZE(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}},LI.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)},LI.prototype.isRetryableTransactionError=function(t){if("FirebaseError"!==t.name)return!1;var e=t.code;return"aborted"===e||"failed-precondition"===e||!CS(e)},LI);function LI(t,e,n,r){this.asyncQueue=t,this.remoteStore=e,this.updateFunction=n,this.deferred=r,this.retries=5,this.backoff=new eS(this.asyncQueue,fv.RetryTransaction)}var FI="SyncEngine",UI=function(t,e,n){this.query=t,this.targetId=e,this.view=n},VI=function(t){this.key=t,this.receivedDocument=!1},qI=(Object.defineProperty(BI.prototype,"isPrimaryClient",{get:function(){return!0===this.isPrimary},enumerable:!0,configurable:!0}),BI.prototype.subscribe=function(t){og(null!==t,"SyncEngine listener cannot be null"),og(null===this.syncEngineListener,"SyncEngine already has a subscriber."),this.syncEngineListener=t},BI.prototype.listen=function(a){return Ta(this,void 0,void 0,function(){var e,n,r,i,o;return Sa(this,function(t){switch(t.label){case 0:return this.assertSubscribed("listen()"),(r=this.queryViewsByQuery.get(a))?(e=r.targetId,this.sharedClientState.addLocalQueryTarget(e),n=r.view.computeInitialSnapshot(),[3,4]):[3,1];case 1:return[4,this.localStore.allocateTarget(a.toTarget())];case 2:return i=t.sent(),o=this.sharedClientState.addLocalQueryTarget(i.targetId),e=i.targetId,[4,this.initializeViewAndComputeSnapshot(a,e,"current"===o)];case 3:n=t.sent(),this.isPrimary&&this.remoteStore.listen(i),t.label=4;case 4:return this.syncEngineListener.onWatchChange([n]),[2,e]}})})},BI.prototype.initializeViewAndComputeSnapshot=function(s,u,c){return Ta(this,void 0,void 0,function(){var e,n,r,i,o,a;return Sa(this,function(t){switch(t.label){case 0:return[4,this.localStore.executeQuery(s,!0)];case 1:return e=t.sent(),n=new PI(s,e.remoteKeys),r=n.computeDocChanges(e.documents),i=qS.createSynthesizedTargetChangeForCurrentChange(u,c&&this.onlineState!==mS.Offline),og(0===(o=n.applyChanges(r,!0===this.isPrimary,i)).limboChanges.length,"View returned limbo docs before target ack from the server."),og(!!o.snapshot,"applyChanges for new view should always return a snapshot"),a=new UI(s,u,n),this.queryViewsByQuery.set(s,a),this.queriesByTarget[u]||(this.queriesByTarget[u]=[]),this.queriesByTarget[u].push(s),[2,o.snapshot]}})})},BI.prototype.synchronizeViewAndComputeSnapshot=function(r){return Ta(this,void 0,void 0,function(){var e,n;return Sa(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]}})})},BI.prototype.unlisten=function(i){return Ta(this,void 0,void 0,function(){var e,n,r=this;return Sa(this,function(t){switch(t.label){case 0:return this.assertSubscribed("unlisten()"),og(!!(e=this.queryViewsByQuery.get(i)),"Trying to unlisten on query not found:"+i),1<(n=this.queriesByTarget[e.targetId]).length?(this.queriesByTarget[e.targetId]=n.filter(function(t){return!t.isEqual(i)}),this.queryViewsByQuery.delete(i),[2]):this.isPrimary?(this.sharedClientState.removeLocalQueryTarget(e.targetId),this.sharedClientState.isActiveQueryTarget(e.targetId)?[3,2]:[4,this.localStore.releaseTarget(e.targetId,!1).then(function(){r.sharedClientState.clearQueryState(e.targetId),r.remoteStore.unlisten(e.targetId),r.removeAndCleanupTarget(e.targetId)}).catch(CE)]):[3,3];case 1:t.sent(),t.label=2;case 2:return[3,5];case 3:return this.removeAndCleanupTarget(e.targetId),[4,this.localStore.releaseTarget(e.targetId,!0)];case 4:t.sent(),t.label=5;case 5:return[2]}})})},BI.prototype.write=function(n,r){return Ta(this,void 0,void 0,function(){var e;return Sa(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]}})})},BI.prototype.runTransaction=function(t,e,n){new MI(t,this.remoteStore,e,n).run()},BI.prototype.applyRemoteEvent=function(n){return Ta(this,void 0,void 0,function(){var e,r=this;return Sa(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(),gg(n.targetChanges,function(t,e){var n=r.limboResolutionsByTarget[Number(t)];n&&(og(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?og(n.receivedDocument,"Received change for limbo target document without add."):0<e.removedDocuments.size&&(og(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,CE(t.sent())];case 5:return t.sent(),[3,6];case 6:return[2]}})})},BI.prototype.applyOnlineStateChange=function(r,t){if(this.isPrimary&&t===vS.RemoteStore||!this.isPrimary&&t===vS.SharedClientState){this.assertSubscribed("applyOnlineStateChange()");var i=[];this.queryViewsByQuery.forEach(function(t,e){var n=e.view.applyOnlineStateChange(r);og(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)}},BI.prototype.rejectListen=function(s,u){return Ta(this,void 0,void 0,function(){var e,n,r,i,o,a=this;return Sa(this,function(t){switch(t.label){case 0:return this.assertSubscribed("rejectListens()"),this.sharedClientState.updateQueryState(s,"rejected",u),e=this.limboResolutionsByTarget[s],(n=e&&e.key)?(this.limboTargetsByKey=this.limboTargetsByKey.remove(n),delete this.limboResolutionsByTarget[s],r=(r=new Rv(hv.comparator)).insert(n,new u_(n,Dv.forDeletedDoc())),i=Jv().add(n),o=new US(Dv.MIN,{},new Vv(qg),r,i),[2,this.applyRemoteEvent(o)]):[3,1];case 1:return[4,this.localStore.releaseTarget(s,!1).then(function(){return a.removeAndCleanupTarget(s,u)}).catch(CE)];case 2:t.sent(),t.label=3;case 3:return[2]}})})},BI.prototype.applyBatchState=function(n,r,i){return Ta(this,void 0,void 0,function(){var e;return Sa(this,function(t){switch(t.label){case 0:return this.assertSubscribed("applyBatchState()"),[4,this.localStore.lookupMutationDocuments(n)];case 1:return null===(e=t.sent())?(eg(FI,"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)):ig("Unknown batchState: "+r),t.label=4;case 4:return[4,this.emitNewSnapsAndNotifyLocalStore(e)];case 5:return t.sent(),[2]}})})},BI.prototype.applySuccessfulWrite=function(r){return Ta(this,void 0,void 0,function(){var e,n;return Sa(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,CE(t.sent())];case 5:return t.sent(),[3,6];case 6:return[2]}})})},BI.prototype.rejectFailedWrite=function(n,r){return Ta(this,void 0,void 0,function(){var e;return Sa(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,CE(t.sent())];case 5:return t.sent(),[3,6];case 6:return[2]}})})},BI.prototype.registerPendingWritesCallback=function(r){return Ta(this,void 0,void 0,function(){var e,n;return Sa(this,function(t){switch(t.label){case 0:return this.remoteStore.canUseNetwork()||eg(FI,"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]}})})},BI.prototype.triggerPendingWritesCallbacks=function(t){(this.pendingWritesCallbacks.get(t)||[]).forEach(function(t){t.resolve()}),this.pendingWritesCallbacks.delete(t)},BI.prototype.rejectOutstandingPendingWritesCallbacks=function(e){this.pendingWritesCallbacks.forEach(function(t){t.forEach(function(t){t.reject(new lg(hg.CANCELLED,e))})}),this.pendingWritesCallbacks.clear()},BI.prototype.addMutationCallback=function(t,e){var n=this.mutationUserCallbacks[this.currentUser.toKey()];n=(n=n||new Rv(qg)).insert(t,e),this.mutationUserCallbacks[this.currentUser.toKey()]=n},BI.prototype.processUserCallback=function(t,e){var n=this.mutationUserCallbacks[this.currentUser.toKey()];if(n){var r=n.get(t);r&&(og(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}},BI.prototype.removeAndCleanupTarget=function(t,e){var n=this;void 0===e&&(e=null),this.sharedClientState.removeLocalQueryTarget(t),og(this.queriesByTarget[t]&&0!==this.queriesByTarget[t].length,"There are no queries mapped to target id "+t);for(var r=0,i=this.queriesByTarget[t];r<i.length;r++){var o=i[r];this.queryViewsByQuery.delete(o),e&&this.syncEngineListener.onWatchError(o,e)}if(delete this.queriesByTarget[t],this.isPrimary){var a=this.limboDocumentRefs.referencesForId(t);this.limboDocumentRefs.removeReferencesForId(t),a.forEach(function(t){n.limboDocumentRefs.containsKey(t)||n.removeLimboTarget(t)})}},BI.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])},BI.prototype.updateTrackedLimbos=function(t,e){for(var n=0,r=e;n<r.length;n++){var i=r[n];i instanceof RI?(this.limboDocumentRefs.addReference(i.key,t),this.trackLimboChange(i)):i instanceof OI?(eg(FI,"Document no longer in limbo: "+i.key),this.limboDocumentRefs.removeReference(i.key,t),this.limboDocumentRefs.containsKey(i.key)||this.removeLimboTarget(i.key)):ig("Unknown limbo change: "+JSON.stringify(i))}},BI.prototype.trackLimboChange=function(t){var e=t.key;if(!this.limboTargetsByKey.get(e)){eg(FI,"New document in limbo: "+e);var n=this.limboTargetIdGenerator.next(),r=oT.atPath(e.path);this.limboResolutionsByTarget[n]=new VI(e),this.remoteStore.listen(new hE(r.toTarget(),n,iE.LimboResolution,$g.INVALID)),this.limboTargetsByKey=this.limboTargetsByKey.insert(e,n)}},BI.prototype.currentLimboDocs=function(){return this.limboTargetsByKey},BI.prototype.emitNewSnapsAndNotifyLocalStore=function(r,u){return Ta(this,void 0,void 0,function(){var o,a,e,s=this;return Sa(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=DI.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]}})})},BI.prototype.assertSubscribed=function(t){og(null!==this.syncEngineListener,"Trying to call "+t+" before calling subscribe().")},BI.prototype.handleCredentialChange=function(r){return Ta(this,void 0,void 0,function(){var e,n;return Sa(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]}})})},BI.prototype.applyPrimaryState=function(c){return Ta(this,void 0,void 0,function(){var e,n,r,i,o,a,s,u=this;return Sa(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(),mg(this.queriesByTarget,function(t,e){u.sharedClientState.isLocalQueryTarget(t)?a.push(t):s=s.then(function(){return u.removeAndCleanupTarget(t),u.localStore.releaseTarget(t,!0)}),u.remoteStore.unlisten(t)}),[4,s]);case 4:return t.sent(),[4,this.synchronizeQueryViewsAndRaiseSnapshots(a)];case 5:return t.sent(),this.resetLimboDocuments(),[4,this.remoteStore.applyPrimaryState(!1)];case 6:t.sent(),t.label=7;case 7:return[2]}})})},BI.prototype.resetLimboDocuments=function(){var e=this;mg(this.limboResolutionsByTarget,function(t){e.remoteStore.unlisten(t)}),this.limboDocumentRefs.removeAllReferences(),this.limboResolutionsByTarget=[],this.limboTargetsByKey=new Rv(hv.comparator)},BI.prototype.synchronizeQueryViewsAndRaiseSnapshots=function(d){return Ta(this,void 0,void 0,function(){var e,n,r,i,o,a,s,u,c,h,l,f,p;return Sa(this,function(t){switch(t.label){case 0:e=[],n=[],r=0,i=d,t.label=1;case 1:return r<i.length?(o=i[r],a=void 0,(s=this.queriesByTarget[o])&&0!==s.length?[4,this.localStore.releaseTarget(o,!0)]:[3,8]):[3,14];case 2:return t.sent(),[4,this.localStore.allocateTarget(s[0].toTarget())];case 3:a=t.sent(),u=0,c=s,t.label=4;case 4:return u<c.length?(h=c[u],og(!!(l=this.queryViewsByQuery.get(h)),"No query view found for "+h),[4,this.synchronizeViewAndComputeSnapshot(l)]):[3,7];case 5:(f=t.sent()).snapshot&&n.push(f.snapshot),t.label=6;case 6:return u++,[3,4];case 7:return[3,12];case 8:return og(!0===this.isPrimary,"A secondary tab should never have an active target without an active query."),[4,this.localStore.getTarget(o)];case 9:return og(!!(p=t.sent()),"Target for id "+o+" not found"),[4,this.localStore.allocateTarget(p)];case 10:return a=t.sent(),[4,this.initializeViewAndComputeSnapshot(this.synthesizeTargetToQuery(p),o,!1)];case 11:t.sent(),t.label=12;case 12:e.push(a),t.label=13;case 13:return r++,[3,1];case 14:return this.syncEngineListener.onWatchChange(n),[2,e]}})})},BI.prototype.synthesizeTargetToQuery=function(t){return new oT(t.path,t.collectionGroup,t.orderBy,t.filters,t.limit,eT.First,t.startAt,t.endAt)},BI.prototype.getActiveClients=function(){return this.localStore.getActiveClients()},BI.prototype.applyTargetState=function(r,i,o){return Ta(this,void 0,void 0,function(){var e,n;return Sa(this,function(t){switch(t.label){case 0:if(this.isPrimary)return eg(FI,"Ignoring unexpected query state notification."),[2];if(!this.queriesByTarget[r])return[3,7];switch(i){case"current":case"not-current":return[3,1];case"rejected":return[3,4]}return[3,6];case 1:return[4,this.localStore.getNewDocumentChanges()];case 2:return e=t.sent(),n=US.createSynthesizedRemoteEventForCurrentChange(r,"current"===i),[4,this.emitNewSnapsAndNotifyLocalStore(e,n)];case 3:return t.sent(),[3,7];case 4:return[4,this.localStore.releaseTarget(r,!0)];case 5:return t.sent(),this.removeAndCleanupTarget(r,o),[3,7];case 6:ig("Unexpected target state: "+i),t.label=7;case 7:return[2]}})})},BI.prototype.applyActiveTargetsChange=function(l,f){return Ta(this,void 0,void 0,function(){var e,n,r,i,o,a,s,u,c,h=this;return Sa(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],og(!this.queriesByTarget[c],"Trying to add an already active target"),[4,this.localStore.getTarget(c)]):[3,6];case 2:return og(!!(r=t.sent()),"Query data for active target "+c+" not found"),[4,this.localStore.allocateTarget(r)];case 3:return i=t.sent(),[4,this.initializeViewAndComputeSnapshot(this.synthesizeTargetToQuery(r),i.targetId,!1)];case 4:t.sent(),this.remoteStore.listen(i),t.label=5;case 5:return e++,[3,1];case 6:o=function(e){return Sa(this,function(t){switch(t.label){case 0:return a.queriesByTarget[e]?[4,a.localStore.releaseTarget(e,!1).then(function(){h.remoteStore.unlisten(e),h.removeAndCleanupTarget(e)}).catch(CE)]:[2,"continue"];case 1:return t.sent(),[2]}})},a=this,s=0,u=f,t.label=7;case 7:return s<u.length?(c=u[s],[5,o(c)]):[3,10];case 8:t.sent(),t.label=9;case 9:return s++,[3,7];case 10:return[2]}})})},BI.prototype.enableNetwork=function(){return this.localStore.setNetworkEnabled(!0),this.remoteStore.enableNetwork()},BI.prototype.disableNetwork=function(){return this.localStore.setNetworkEnabled(!1),this.remoteStore.disableNetwork()},BI.prototype.getRemoteKeysForTarget=function(t){var e=this.limboResolutionsByTarget[t];if(e&&e.receivedDocument)return Jv().add(e.key);var n=Jv(),r=this.queriesByTarget[t];if(!r)return n;for(var i=0,o=r;i<o.length;i++){var a=o[i],s=this.queryViewsByQuery.get(a);og(!!s,"No query view found for "+a),n=n.unionWith(s.view.syncedDocuments)}return n},BI);function BI(t,e,n,r){this.localStore=t,this.remoteStore=e,this.sharedClientState=n,this.currentUser=r,this.syncEngineListener=null,this.queryViewsByQuery=new p_(function(t){return t.canonicalId()}),this.queriesByTarget={},this.limboTargetsByKey=new Rv(hv.comparator),this.limboResolutionsByTarget={},this.limboDocumentRefs=new bE,this.mutationUserCallbacks={},this.pendingWritesCallbacks=new Map,this.limboTargetIdGenerator=Ab.forSyncEngine(),this.isPrimary=void 0,this.onlineState=mS.Unknown}var jI=(WI.prototype.isAuthenticated=function(){return null!=this.uid},WI.prototype.toKey=function(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"},WI.prototype.isEqual=function(t){return t.uid===this.uid},WI.UNAUTHENTICATED=new WI(null),WI.GOOGLE_CREDENTIALS=new WI("google-credentials-uid"),WI.FIRST_PARTY=new WI("first-party-uid"),WI);function WI(t){this.uid=t}var KI="firestore_clients";function QI(t,e){return og(-1===e.indexOf("_"),"Client key cannot contain '_', but was '"+e+"'"),KI+"_"+t+"_"+e}var HI="firestore_mutations";function zI(t,e,n){var r=HI+"_"+t+"_"+n;return e.isAuthenticated()&&(r+="_"+e.uid),r}var GI="firestore_targets";function YI(t,e){return GI+"_"+t+"_"+e}var XI="firestore_online_state";var JI="firestore_sequence_number";var $I="SharedClientState",ZI=(tC.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 lg(r.error.code,r.error.message)),i?new tC(t,e,r.state,o):(ng($I,"Failed to parse mutation state for ID '"+e+"': "+n),null)},tC.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)},tC);function tC(t,e,n,r){this.user=t,this.batchId=e,this.state=n,og(void 0!==(this.error=r)==("rejected"===n),"MutationMetadata must contain an error iff state is 'rejected'")}var eC=(nC.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 lg(n.error.code,n.error.message)),r?new nC(t,n.state,i):(ng($I,"Failed to parse target state for ID '"+t+"': "+e),null)},nC.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)},nC);function nC(t,e,n){this.targetId=t,this.state=e,og(void 0!==(this.error=n)==("rejected"===e),"QueryTargetMetadata must contain an error iff state is 'rejected'")}var rC=(iC.fromWebStorageEntry=function(t,e){for(var n=JSON.parse(e),r="object"==typeof n&&n.activeTargetIds instanceof Array,i=Zv(),o=0;r&&o<n.activeTargetIds.length;++o)r=tT(n.activeTargetIds[o]),i=i.add(n.activeTargetIds[o]);return r?new iC(t,i):(ng($I,"Failed to parse client data for instance '"+t+"': "+e),null)},iC);function iC(t,e){this.clientId=t,this.activeTargetIds=e}var oC=(aC.fromWebStorageEntry=function(t){var e=JSON.parse(t);return"object"==typeof e&&e.onlineState in mS&&"string"==typeof e.clientId?new aC(e.clientId,mS[e.onlineState]):(ng($I,"Failed to parse online state: "+t),null)},aC);function aC(t,e){this.clientId=t,this.onlineState=e}var sC=(uC.prototype.addQueryTarget=function(t){this.activeTargetIds=this.activeTargetIds.add(t)},uC.prototype.removeQueryTarget=function(t){this.activeTargetIds=this.activeTargetIds.delete(t)},uC.prototype.toWebStorageJSON=function(){var t={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(t)},uC);function uC(){this.activeTargetIds=Zv()}var cC=(hC.isAvailable=function(t){return!(!t.window||null==t.window.localStorage)},hC.prototype.start=function(){return Ta(this,void 0,void 0,function(){var e,n,r,i,o,a,s,u,c,h,l,f=this;return Sa(this,function(t){switch(t.label){case 0:return og(!this.started,"WebStorageSharedClientState already started"),og(null!==this.syncEngine,"syncEngine property must be set before calling start()"),og(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(QI(this.persistenceKey,i)))&&(a=rC.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]}})})},hC.prototype.writeSequenceNumber=function(t){this.setItem(this.sequenceNumberKey,JSON.stringify(t))},hC.prototype.getAllActiveQueryTargets=function(){var n=Zv();return gg(this.activeClients,function(t,e){n=n.unionWith(e.activeTargetIds)}),n},hC.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},hC.prototype.addPendingMutation=function(t){this.persistMutationState(t,"pending")},hC.prototype.updateMutationState=function(t,e,n){this.persistMutationState(t,e,n),this.removeMutationState(t)},hC.prototype.addLocalQueryTarget=function(t){var e="not-current";if(this.isActiveQueryTarget(t)){var n=this.storage.getItem(YI(this.persistenceKey,t));if(n){var r=eC.fromWebStorageEntry(t,n);r&&(e=r.state)}}return this.localClientState.addQueryTarget(t),this.persistClientState(),e},hC.prototype.removeLocalQueryTarget=function(t){this.localClientState.removeQueryTarget(t),this.persistClientState()},hC.prototype.isLocalQueryTarget=function(t){return this.localClientState.activeTargetIds.has(t)},hC.prototype.clearQueryState=function(t){this.removeItem(YI(this.persistenceKey,t))},hC.prototype.updateQueryState=function(t,e,n){this.persistQueryTargetState(t,e,n)},hC.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)})},hC.prototype.setOnlineState=function(t){this.persistOnlineState(t)},hC.prototype.shutdown=function(){this.started&&(this.platform.window.removeEventListener("storage",this.storageListener),this.removeItem(this.localClientStorageKey),this.started=!1)},hC.prototype.getItem=function(t){var e=this.storage.getItem(t);return eg($I,"READ",t,e),e},hC.prototype.setItem=function(t,e){eg($I,"SET",t,e),this.storage.setItem(t,e)},hC.prototype.removeItem=function(t){eg($I,"REMOVE",t),this.storage.removeItem(t)},hC.prototype.handleWebStorageEvent=function(s){var t=this;if(s.storageArea===this.storage){if(eg($I,"EVENT",s.key,s.newValue),s.key===this.localClientStorageKey)return void ng("Received WebStorage notification for local change. Another client might have garbage-collected our state");this.queue.enqueueAndForget(function(){return Ta(t,void 0,void 0,function(){var e,n,r,i,o,a;return Sa(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&&(og(!!this.sequenceNumberHandler,"Missing sequenceNumberHandler"),(a=function(t){var e=$g.INVALID;if(null!=t)try{var n=JSON.parse(t);og("number"==typeof n,"Found non-numeric sequence number"),e=n}catch(t){ng($I,"Failed to read sequence number from WebStorage",t)}return e}(s.newValue))!==$g.INVALID&&this.sequenceNumberHandler(a));return[2]})})})}},Object.defineProperty(hC.prototype,"localClientState",{get:function(){return this.activeClients[this.localClientId]},enumerable:!0,configurable:!0}),hC.prototype.persistClientState=function(){this.setItem(this.localClientStorageKey,this.localClientState.toWebStorageJSON())},hC.prototype.persistMutationState=function(t,e,n){var r=new ZI(this.currentUser,t,e,n),i=zI(this.persistenceKey,this.currentUser,t);this.setItem(i,r.toWebStorageJSON())},hC.prototype.removeMutationState=function(t){var e=zI(this.persistenceKey,this.currentUser,t);this.removeItem(e)},hC.prototype.persistOnlineState=function(t){var e={clientId:this.localClientId,onlineState:mS[t]};this.storage.setItem(this.onlineStateKey,JSON.stringify(e))},hC.prototype.persistQueryTargetState=function(t,e,n){var r=YI(this.persistenceKey,t),i=new eC(t,e,n);this.setItem(r,i.toWebStorageJSON())},hC.prototype.fromWebStorageClientStateKey=function(t){var e=this.clientStateKeyRe.exec(t);return e?e[1]:null},hC.prototype.fromWebStorageClientState=function(t,e){var n=this.fromWebStorageClientStateKey(t);return og(null!==n,"Cannot parse client state key '"+t+"'"),rC.fromWebStorageEntry(n,e)},hC.prototype.fromWebStorageMutationMetadata=function(t,e){var n=this.mutationBatchKeyRe.exec(t);og(null!==n,"Cannot parse mutation batch key '"+t+"'");var r=Number(n[1]),i=void 0!==n[2]?n[2]:null;return ZI.fromWebStorageEntry(new jI(i),r,e)},hC.prototype.fromWebStorageQueryTargetMetadata=function(t,e){var n=this.queryTargetKeyRe.exec(t);og(null!==n,"Cannot parse query target key '"+t+"'");var r=Number(n[1]);return eC.fromWebStorageEntry(r,e)},hC.prototype.fromWebStorageOnlineState=function(t){return oC.fromWebStorageEntry(t)},hC.prototype.handleMutationBatchEvent=function(e){return Ta(this,void 0,void 0,function(){return Sa(this,function(t){return e.user.uid!==this.currentUser.uid?(eg($I,"Ignoring mutation for non-active user "+e.user.uid),[2]):[2,this.syncEngine.applyBatchState(e.batchId,e.state,e.error)]})})},hC.prototype.handleQueryTargetEvent=function(t){return this.syncEngine.applyTargetState(t.targetId,t.state,t.error)},hC.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 Ta(n,void 0,void 0,function(){return Sa(this,function(t){return r.has(e)||o.push(e),[2]})})}),r.forEach(function(e){return Ta(n,void 0,void 0,function(){return Sa(this,function(t){return i.has(e)||a.push(e),[2]})})}),this.syncEngine.applyActiveTargetsChange(o,a)},hC.prototype.handleOnlineStateEvent=function(t){this.activeClients[t.clientId]&&this.onlineStateHandler(t.onlineState)},hC);function hC(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=[],!hC.isAvailable(this.platform))throw new lg(hg.UNIMPLEMENTED,"LocalStorage is not available on this platform.");var o=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");this.storage=this.platform.window.localStorage,this.currentUser=i,this.localClientStorageKey=QI(this.persistenceKey,this.localClientId),this.sequenceNumberKey=function(t){return JI+"_"+t}(this.persistenceKey),this.activeClients[this.localClientId]=new sC,this.clientStateKeyRe=new RegExp("^"+KI+"_"+o+"_([^_]*)$"),this.mutationBatchKeyRe=new RegExp("^"+HI+"_"+o+"_(\\d+)(?:_(.*))?$"),this.queryTargetKeyRe=new RegExp("^"+GI+"_"+o+"_(\\d+)$"),this.onlineStateKey=function(t){return XI+"_"+t}(this.persistenceKey),this.platform.window.addEventListener("storage",this.storageListener)}var lC=(fC.prototype.addPendingMutation=function(t){},fC.prototype.updateMutationState=function(t,e,n){},fC.prototype.addLocalQueryTarget=function(t){return this.localState.addQueryTarget(t),this.queryState[t]||"not-current"},fC.prototype.updateQueryState=function(t,e,n){this.queryState[t]=e},fC.prototype.removeLocalQueryTarget=function(t){this.localState.removeQueryTarget(t)},fC.prototype.isLocalQueryTarget=function(t){return this.localState.activeTargetIds.has(t)},fC.prototype.clearQueryState=function(t){delete this.queryState[t]},fC.prototype.getAllActiveQueryTargets=function(){return this.localState.activeTargetIds},fC.prototype.isActiveQueryTarget=function(t){return this.localState.activeTargetIds.has(t)},fC.prototype.start=function(){return this.localState=new sC,Promise.resolve()},fC.prototype.handleUserChange=function(t,e,n){},fC.prototype.setOnlineState=function(t){},fC.prototype.shutdown=function(){},fC.prototype.writeSequenceNumber=function(t){},fC);function fC(){this.localState=new sC,this.queryState={},this.syncEngine=null,this.onlineStateHandler=null,this.sequenceNumberHandler=null}var pC="FirestoreClient",dC=(yC.prototype.lruParams=function(){return RE.withCacheSize(this.cacheSizeBytes)},yC);function yC(t,e){this.cacheSizeBytes=t,this.synchronizeTabs=e}var mC=function(){},gC=(vC.prototype.start=function(t){var n=this;this.verifyNotTerminated();var r=new dv,i=new dv,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},vC.prototype.enableNetwork=function(){var t=this;return this.verifyNotTerminated(),this.asyncQueue.enqueue(function(){return t.syncEngine.enableNetwork()})},vC.prototype.initializePersistence=function(t,e,n){var r=this;return t instanceof dC?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())},vC.prototype.canFallback=function(t){return t instanceof lg?t.code===hg.FAILED_PRECONDITION||t.code===hg.UNIMPLEMENTED:!("undefined"!=typeof DOMException&&t instanceof DOMException)||22===t.code||20===t.code||11===t.code},vC.prototype.verifyNotTerminated=function(){if(this.asyncQueue.isShuttingDown)throw new lg(hg.FAILED_PRECONDITION,"The client has already been terminated.")},vC.prototype.startIndexedDbPersistence=function(r,i){var t=this,o=jE.buildStoragePrefix(this.databaseInfo),a=new EI(this.databaseInfo.databaseId,{useProto3Json:!0});return Promise.resolve().then(function(){return Ta(t,void 0,void 0,function(){var e,n;return Sa(this,function(t){switch(t.label){case 0:if(i.synchronizeTabs&&!cC.isAvailable(this.platform))throw new lg(hg.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");return e=i.lruParams(),this.sharedClientState=i.synchronizeTabs?new cC(this.asyncQueue,this.platform,o,this.clientId,r):new lC,[4,jE.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]}})})})},vC.prototype.startMemoryPersistence=function(){return this.persistence=HT.createEagerPersistence(this.clientId),this.sharedClientState=new lC,Promise.resolve(null)},vC.prototype.initializeRest=function(c,h){var t=this;return eg(pC,"Initializing. user=",c.uid),this.platform.loadConnection(this.databaseInfo).then(function(u){return Ta(t,void 0,void 0,function(){var e,n,r,i,o,a,s=this;return Sa(this,function(t){switch(t.label){case 0:return e=new LT,this.localStore=new SE(this.persistence,e,c),[4,this.localStore.start()];case 1:return t.sent(),h&&(this.lruScheduler=new PE(h,this.asyncQueue,this.localStore)),n=this.platform.newConnectivityMonitor(),r=this.platform.newSerializer(this.databaseInfo.databaseId),i=new dS(this.asyncQueue,u,this.credentials,r),o=function(t){return s.syncEngine.applyOnlineStateChange(t,vS.RemoteStore)},a=function(t){return s.syncEngine.applyOnlineStateChange(t,vS.SharedClientState)},this.remoteStore=new tI(this.localStore,i,this.asyncQueue,o,n),this.syncEngine=new qI(this.localStore,this.remoteStore,this.sharedClientState,c),this.sharedClientState.onlineStateHandler=a,this.remoteStore.syncEngine=this.syncEngine,this.sharedClientState.syncEngine=this.syncEngine,this.eventMgr=new II(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 Ta(s,void 0,void 0,function(){return Sa(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 Ta(s,void 0,void 0,function(){return Sa(this,function(t){switch(t.label){case 0:return[4,this.terminate()];case 1:return t.sent(),[2]}})})})];case 5:return t.sent(),[2]}})})})},vC.prototype.handleCredentialChange=function(t){return this.asyncQueue.verifyOperationInProgress(),eg(pC,"Credential Changed. Current user: "+t.uid),this.syncEngine.handleCredentialChange(t)},vC.prototype.disableNetwork=function(){var t=this;return this.verifyNotTerminated(),this.asyncQueue.enqueue(function(){return t.syncEngine.disableNetwork()})},vC.prototype.terminate=function(){var t=this;return this.asyncQueue.enqueueAndInitiateShutdown(function(){return Ta(t,void 0,void 0,function(){return Sa(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]}})})})},vC.prototype.waitForPendingWrites=function(){var t=this;this.verifyNotTerminated();var e=new dv;return this.asyncQueue.enqueueAndForget(function(){return t.syncEngine.registerPendingWritesCallback(e)}),e.promise},vC.prototype.listen=function(t,e,n){var r=this;this.verifyNotTerminated();var i=new NI(t,e,n);return this.asyncQueue.enqueueAndForget(function(){return r.eventMgr.listen(i)}),i},vC.prototype.unlisten=function(t){var e=this;this.clientTerminated||this.asyncQueue.enqueueAndForget(function(){return e.eventMgr.unlisten(t)})},vC.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 o_)return t;if(t instanceof u_)return null;throw new lg(hg.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.)")})},vC.prototype.getDocumentsFromLocalCache=function(i){var t=this;return this.verifyNotTerminated(),this.asyncQueue.enqueue(function(){return Ta(t,void 0,void 0,function(){var e,n,r;return Sa(this,function(t){switch(t.label){case 0:return[4,this.localStore.executeQuery(i,!0)];case 1:return e=t.sent(),n=new PI(i,e.remoteKeys),r=n.computeDocChanges(e.documents),[2,n.applyChanges(r,!1).snapshot]}})})})},vC.prototype.write=function(t){var e=this;this.verifyNotTerminated();var n=new dv;return this.asyncQueue.enqueueAndForget(function(){return e.syncEngine.write(t,n)}),n.promise},vC.prototype.databaseId=function(){return this.databaseInfo.databaseId},vC.prototype.addSnapshotsInSyncListener=function(t){var e=this;this.verifyNotTerminated(),this.asyncQueue.enqueueAndForget(function(){return e.eventMgr.addSnapshotsInSyncListener(t),Promise.resolve()})},vC.prototype.removeSnapshotsInSyncListener=function(t){this.clientTerminated||this.eventMgr.removeSnapshotsInSyncListener(t)},Object.defineProperty(vC.prototype,"clientTerminated",{get:function(){return this.asyncQueue.isShuttingDown},enumerable:!0,configurable:!0}),vC.prototype.transaction=function(t){var e=this;this.verifyNotTerminated();var n=new dv;return this.asyncQueue.enqueueAndForget(function(){return e.syncEngine.runTransaction(e.asyncQueue,t,n),Promise.resolve()}),n.promise},vC);function vC(t,e,n,r){this.platform=t,this.databaseInfo=e,this.credentials=n,this.asyncQueue=r,this.clientId=Ug.newId()}var bC=(wC.prototype.next=function(t){this.scheduleEvent(this.observer.next,t)},wC.prototype.error=function(t){this.scheduleEvent(this.observer.error,t)},wC.prototype.mute=function(){this.muted=!0},wC.prototype.scheduleEvent=function(t,e){var n=this;this.muted||setTimeout(function(){n.muted||t(e)},0)},wC);function wC(t){this.observer=t,this.muted=!1}var _C=(EC.documentId=function(){return EC._DOCUMENT_ID},EC.prototype.isEqual=function(t){if(!(t instanceof EC))throw xg("isEqual","FieldPath",1,t);return this._internalPath.isEqual(t._internalPath)},EC._DOCUMENT_ID=new EC(uv.keyField().canonicalString()),EC);function EC(){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 lg(hg.INVALID_ARGUMENT,"Function "+t+"() requires its "+n+" argument to be an array with at least "+Fg(r,"element")+".")}("FieldPath",t,"fieldNames",1);for(var n=0;n<t.length;++n)if(Tg("FieldPath","string",n,t[n]),0===t[n].length)throw new lg(hg.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new uv(t)}var TC=new RegExp("[~\\*/\\[\\]]");var SC=function(t,e){this.user=e,this.type="OAuth",this.authHeaders={},this.authHeaders.Authorization="Bearer "+t},IC=(CC.prototype.getToken=function(){return Promise.resolve(null)},CC.prototype.invalidateToken=function(){},CC.prototype.setChangeListener=function(t){og(!this.changeListener,"Can only call setChangeListener() once."),(this.changeListener=t)(jI.UNAUTHENTICATED)},CC.prototype.removeChangeListener=function(){og(null!==this.changeListener,"removeChangeListener() when no listener registered"),this.changeListener=null},CC);function CC(){this.changeListener=null}var NC=(AC.prototype.getToken=function(){var e=this;og(null!=this.tokenListener,"getToken cannot be called after listener removed.");var n=this.tokenCounter,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then(function(t){if(e.tokenCounter!==n)throw new lg(hg.ABORTED,"getToken aborted due to token change.");return t?(og("string"==typeof t.accessToken,"Invalid tokenData returned from getToken():"+t),new SC(t.accessToken,e.currentUser)):null}):Promise.resolve(null)},AC.prototype.invalidateToken=function(){this.forceRefresh=!0},AC.prototype.setChangeListener=function(t){og(!this.changeListener,"Can only call setChangeListener() once."),this.changeListener=t,this.receivedInitialUser&&t(this.currentUser)},AC.prototype.removeChangeListener=function(){og(null!=this.tokenListener,"removeChangeListener() called twice"),og(null!==this.changeListener,"removeChangeListener() called when no listener registered"),this.auth&&this.auth.removeAuthTokenListener(this.tokenListener),this.tokenListener=null,this.changeListener=null},AC.prototype.getUser=function(){var t=this.auth&&this.auth.getUid();return og(null===t||"string"==typeof t,"Received invalid UID: "+t),new jI(t)},AC);function AC(t){var e=this;this.tokenListener=null,this.currentUser=jI.UNAUTHENTICATED,this.receivedInitialUser=!1,this.tokenCounter=0,this.changeListener=null,this.forceRefresh=!1,this.tokenListener=function(){e.tokenCounter++,e.currentUser=e.getUser(),e.receivedInitialUser=!0,e.changeListener&&e.changeListener(e.currentUser)},this.tokenCounter=0,this.auth=t.getImmediate({optional:!0}),this.auth?this.auth.addAuthTokenListener(this.tokenListener):(this.tokenListener(null),t.get().then(function(t){e.auth=t,e.tokenListener&&e.auth.addAuthTokenListener(e.tokenListener)},function(){}))}var DC=(Object.defineProperty(kC.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}),kC);function kC(t,e){this.gapi=t,this.sessionIndex=e,this.type="FirstParty",this.user=jI.FIRST_PARTY}var RC=(OC.prototype.getToken=function(){return Promise.resolve(new DC(this.gapi,this.sessionIndex))},OC.prototype.setChangeListener=function(t){t(jI.FIRST_PARTY)},OC.prototype.removeChangeListener=function(){},OC.prototype.invalidateToken=function(){},OC);function OC(t,e){this.gapi=t,this.sessionIndex=e}function PC(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 xC=(MC.delete=function(){return bg("FieldValue.delete",arguments),FC.instance},MC.serverTimestamp=function(){return bg("FieldValue.serverTimestamp",arguments),qC.instance},MC.arrayUnion=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return _g("FieldValue.arrayUnion",arguments,1),new WC(t)},MC.arrayRemove=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return _g("FieldValue.arrayRemove",arguments,1),new HC(t)},MC.increment=function(t){return Tg("FieldValue.increment","number",1,t),wg("FieldValue.increment",arguments,1),new YC(t)},MC.prototype.isEqual=function(t){return this===t},MC);function MC(t){this._methodName=t}var LC,FC=(_a(UC,LC=xC),UC.instance=new UC,UC);function UC(){return LC.call(this,"FieldValue.delete")||this}var VC,qC=(_a(BC,VC=xC),BC.instance=new BC,BC);function BC(){return VC.call(this,"FieldValue.serverTimestamp")||this}var jC,WC=(_a(KC,jC=xC),KC);function KC(t){var e=jC.call(this,"FieldValue.arrayUnion")||this;return e._elements=t,e}var QC,HC=(_a(zC,QC=xC),zC);function zC(t){var e=QC.call(this,"FieldValue.arrayRemove")||this;return e._elements=t,e}var GC,YC=(_a(XC,GC=xC),XC);function XC(t){var e=GC.call(this,"FieldValue.increment")||this;return e._operand=t,e}var JC=pg(xC,"Use FieldValue.<field>() instead."),$C=/^__.*__$/,ZC=(tN.prototype.toMutations=function(t,e){var n=[];return null!==this.fieldMask?n.push(new Jb(t,this.data,this.fieldMask,e)):n.push(new Gb(t,this.data,e)),0<this.fieldTransforms.length&&n.push(new tw(t,this.fieldTransforms)),n},tN);function tN(t,e,n){this.data=t,this.fieldMask=e,this.fieldTransforms=n}var eN,nN,rN=(iN.prototype.toMutations=function(t,e){var n=[new Jb(t,this.data,this.fieldMask,e)];return 0<this.fieldTransforms.length&&n.push(new tw(t,this.fieldTransforms)),n},iN);function iN(t,e,n){this.data=t,this.fieldMask=e,this.fieldTransforms=n}function oN(t){switch(t){case eN.Set:case eN.MergeSet:case eN.Update:return!0;case eN.Argument:case eN.ArrayArgument:return!1;default:throw ig("Unexpected case for UserDataSource: "+t)}}(nN=eN=eN||{})[nN.Set=0]="Set",nN[nN.Update=1]="Update",nN[nN.MergeSet=2]="MergeSet",nN[nN.Argument=3]="Argument",nN[nN.ArrayArgument=4]="ArrayArgument";var aN=(sN.prototype.childContextForField=function(t){var e=null==this.path?null:this.path.child(t),n=new sN(this.dataSource,this.methodName,e,!1,this.fieldTransforms,this.fieldMask);return n.validatePathSegment(t),n},sN.prototype.childContextForFieldPath=function(t){var e=null==this.path?null:this.path.child(t),n=new sN(this.dataSource,this.methodName,e,!1,this.fieldTransforms,this.fieldMask);return n.validatePath(),n},sN.prototype.childContextForArray=function(t){return new sN(this.dataSource,this.methodName,null,!0,this.fieldTransforms,this.fieldMask)},sN.prototype.createError=function(t){var e=null===this.path||this.path.isEmpty()?"":" (found in field "+this.path.toString()+")";return new lg(hg.INVALID_ARGUMENT,"Function "+this.methodName+"() called with invalid data. "+t+e)},sN.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)})},sN.prototype.validatePath=function(){if(null!==this.path)for(var t=0;t<this.path.length;t++)this.validatePathSegment(this.path.get(t))},sN.prototype.validatePathSegment=function(t){if(0===t.length)throw this.createError("Document fields must not be empty");if(oN(this.dataSource)&&$C.test(t))throw this.createError('Document fields cannot begin and end with "__"')},sN);function sN(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 uN=function(t,e){this.databaseId=t,this.key=e},cN=(hN.prototype.parseSetData=function(t,e){var n=new aN(eN.Set,t,uv.EMPTY_PATH);fN("Data must be an object, but it was:",n,e);var r=this.parseData(e,n);return new ZC(r,null,n.fieldTransforms)},hN.prototype.parseMergeData=function(t,e,n){var r=new aN(eN.MergeSet,t,uv.EMPTY_PATH);fN("Data must be an object, but it was:",r,e);var i,o,a=this.parseData(e,r);if(n){for(var s=new Vv(uv.comparator),u=0,c=n;u<c.length;u++){var h=c[u],l=void 0;if(h instanceof _C)l=h._internalPath;else{if("string"!=typeof h)throw ig("Expected stringOrFieldPath to be a string or a FieldPath");l=dN(t,h)}if(!r.contains(l))throw new lg(hg.INVALID_ARGUMENT,"Field '"+l+"' is specified in your field mask but missing from your input data.");s=s.add(l)}i=Lb.fromSet(s),o=r.fieldTransforms.filter(function(t){return i.covers(t.field)})}else i=Lb.fromArray(r.fieldMask),o=r.fieldTransforms;return new ZC(a,i,o)},hN.prototype.parseUpdateData=function(o,t){var a=this,s=new aN(eN.Update,o,uv.EMPTY_PATH);fN("Data must be an object, but it was:",s,t);var u=new Vv(uv.comparator),c=Jw.EMPTY;gg(t,function(t,e){var n=dN(o,t),r=s.childContextForFieldPath(n);if((e=a.runPreConverter(e,r))instanceof FC)u=u.add(n);else{var i=a.parseData(e,r);null!=i&&(u=u.add(n),c=c.set(n,i))}});var e=Lb.fromSet(u);return new rN(c,e,s.fieldTransforms)},hN.prototype.parseUpdateVarargs=function(t,e,n,r){var i=new aN(eN.Update,t,uv.EMPTY_PATH),o=[pN(t,e)],a=[n];if(r.length%2!=0)throw new lg(hg.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(pN(t,r[s])),a.push(r[s+1]);var u=new Vv(uv.comparator),c=Jw.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 FC)u=u.add(h);else{var p=this.parseData(f,l);null!=p&&(u=u.add(h),c=c.set(h,p))}}var d=Lb.fromSet(u);return new rN(c,d,i.fieldTransforms)},hN.prototype.parseQueryValue=function(t,e,n){void 0===n&&(n=!1);var r=new aN(n?eN.ArrayArgument:eN.Argument,t,uv.EMPTY_PATH),i=this.parseData(e,r);return og(null!=i,"Parsed data should not be null."),og(0===r.fieldTransforms.length,"Field transforms should have been disallowed."),i},hN.prototype.runPreConverter=function(t,e){try{return this.preConverter(t)}catch(t){var n=yN(t);throw e.createError(n)}},hN.prototype.parseData=function(t,e){if(lN(t=this.runPreConverter(t,e)))return fN("Unsupported field value:",e,t),this.parseObject(t,e);if(t instanceof xC)return this.parseSentinelFieldValue(t,e),null;if(e.path&&e.fieldMask.push(e.path),t instanceof Array){if(e.arrayElement&&e.dataSource!==eN.ArrayArgument)throw e.createError("Nested arrays are not supported");return this.parseArray(t,e)}return this.parseScalarValue(t,e)},hN.prototype.parseObject=function(t,r){var i=this,o=new Rv(qg);return vg(t)?r.path&&0<r.path.length&&r.fieldMask.push(r.path):gg(t,function(t,e){var n=i.parseData(e,r.childContextForField(t));null!=n&&(o=o.insert(t,n))}),new Jw(o)},hN.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=gw.INSTANCE),n.push(s),r++}return new t_(n)},hN.prototype.parseSentinelFieldValue=function(t,e){if(!oN(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 FC){if(e.dataSource!==eN.MergeSet)throw e.dataSource===eN.Update?(og(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 qC)e.fieldTransforms.push(new Ub(e.path,iI.instance));else if(t instanceof WC){var n=this.parseArrayTransformElements(t._methodName,t._elements),r=new aI(n);e.fieldTransforms.push(new Ub(e.path,r))}else if(t instanceof HC){n=this.parseArrayTransformElements(t._methodName,t._elements);var i=new uI(n);e.fieldTransforms.push(new Ub(e.path,i))}else if(t instanceof YC){var o=this.parseQueryValue("FieldValue.increment",t._operand),a=new hI(o);e.fieldTransforms.push(new Ub(e.path,a))}else ig("Unknown FieldValue type: "+t)},hN.prototype.parseScalarValue=function(t,e){if(null===t)return gw.INSTANCE;if("number"==typeof t)return tT(t)?new Nw(t):new kw(t);if("boolean"==typeof t)return ww.of(t);if("string"==typeof t)return new Pw(t);if(t instanceof Date)return new Lw(Nv.fromDate(t));if(t instanceof Nv)return new Lw(new Nv(t.seconds,1e3*Math.floor(t.nanoseconds/1e3)));if(t instanceof nI)return new Gw(t);if(t instanceof Qg)return new jw(t);if(t instanceof uN)return new Qw(t.databaseId,t.key);throw e.createError("Unsupported field value: "+Rg(t))},hN.prototype.parseArrayTransformElements=function(r,t){var i=this;return t.map(function(t,e){var n=new aN(eN.Argument,r,uv.EMPTY_PATH);return i.parseData(t,n.childContextForArray(e))})},hN);function hN(t){this.preConverter=t}function lN(t){return!("object"!=typeof t||null===t||t instanceof Array||t instanceof Date||t instanceof Nv||t instanceof nI||t instanceof Qg||t instanceof uN||t instanceof xC)}function fN(t,e,n){if(!lN(n)||!kg(n)){var r=Rg(n);throw"an object"===r?e.createError(t+" a custom object"):e.createError(t+" "+r)}}function pN(t,e){if(e instanceof _C)return e._internalPath;if("string"==typeof e)return dN(t,e);throw new lg(hg.INVALID_ARGUMENT,"Function "+t+"() called with invalid data. Field path arguments must be of type string or FieldPath.")}function dN(e,t){try{return function(e){if(0<=e.search(TC))throw new lg(hg.INVALID_ARGUMENT,"Invalid field path ("+e+"). Paths must not contain '~', '*', '/', '[', or ']'");try{return new(_C.bind.apply(_C,Aa([void 0],e.split("."))))}catch(t){throw new lg(hg.INVALID_ARGUMENT,"Invalid field path ("+e+"). Paths must not be empty, begin with '.', end with '.', or contain '..'")}}(t)._internalPath}catch(t){var n=yN(t);throw new lg(hg.INVALID_ARGUMENT,"Function "+e+"() called with invalid data. "+n)}}function yN(t){return t instanceof Error?t.message:t.toString()}var mN=RE.COLLECTION_DISABLED,gN=(vN.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},vN);function vN(t){if(void 0===t.host){if(void 0!==t.ssl)throw new lg(hg.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host="firestore.googleapis.com",this.ssl=!0}else Ig("settings","non-empty string","host",t.host),this.host=t.host,Cg("settings","boolean","ssl",t.ssl),this.ssl=yg(t.ssl,!0);if(Pg("settings",t,["host","ssl","credentials","timestampsInSnapshots","cacheSizeBytes","experimentalForceLongPolling"]),Cg("settings","object","credentials",t.credentials),this.credentials=t.credentials,Cg("settings","boolean","timestampsInSnapshots",t.timestampsInSnapshots),!0===t.timestampsInSnapshots?ng("\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&&ng("\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=yg(t.timestampsInSnapshots,!0),Cg("settings","number","cacheSizeBytes",t.cacheSizeBytes),void 0===t.cacheSizeBytes)this.cacheSizeBytes=RE.DEFAULT_CACHE_SIZE_BYTES;else{if(t.cacheSizeBytes!==mN&&t.cacheSizeBytes<RE.MINIMUM_CACHE_SIZE_BYTES)throw new lg(hg.INVALID_ARGUMENT,"cacheSizeBytes must be at least "+RE.MINIMUM_CACHE_SIZE_BYTES);this.cacheSizeBytes=t.cacheSizeBytes}Cg("settings","boolean","experimentalForceLongPolling",t.experimentalForceLongPolling),this.forceLongPolling=void 0!==t.experimentalForceLongPolling&&t.experimentalForceLongPolling}var bN=(wN.prototype.settings=function(t){if(wg("Firestore.settings",arguments,1),Tg("Firestore.settings","object",1,t),dg(t,"persistence"))throw new lg(hg.INVALID_ARGUMENT,'"persistence" is now specified with a separate call to firestore.enablePersistence().');var e=new gN(t);if(this._firestoreClient&&!this._settings.isEqual(e))throw new lg(hg.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 IC;switch(t.type){case"gapi":var e=t.client;return og(!("object"!=typeof e||null===e||!e.auth||!e.auth.getAuthHeaderValueForFirstParty),"unexpected gapi interface"),new RC(e,t.sessionIndex||"0");case"provider":return t.client;default:throw new lg(hg.INVALID_ARGUMENT,"makeCredentialsProvider failed due to invalid credential type")}}(e.credentials))},wN.prototype.enableNetwork=function(){return this.ensureClientConfigured(),this._firestoreClient.enableNetwork()},wN.prototype.disableNetwork=function(){return this.ensureClientConfigured(),this._firestoreClient.disableNetwork()},wN.prototype.enablePersistence=function(t){if(this._firestoreClient)throw new lg(hg.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&&ng("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=yg(void 0!==t.synchronizeTabs?t.synchronizeTabs:t.experimentalTabSynchronization,!1)),this.configureClient(new dC(this._settings.cacheSizeBytes,e))},wN.prototype.clearPersistence=function(){var t=this,n=jE.buildStoragePrefix(this.makeDatabaseInfo()),r=new dv;return this._queue.enqueueAndForgetEvenAfterShutdown(function(){return Ta(t,void 0,void 0,function(){var e;return Sa(this,function(t){switch(t.label){case 0:if(t.trys.push([0,2,,3]),void 0!==this._firestoreClient&&!this._firestoreClient.clientTerminated)throw new lg(hg.FAILED_PRECONDITION,"Persistence cannot be cleared after this Firestore instance is initialized.");return[4,jE.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},wN.prototype.terminate=function(){return this.app._removeServiceInstance("firestore"),this.INTERNAL.delete()},Object.defineProperty(wN.prototype,"_isTerminated",{get:function(){return this.ensureClientConfigured(),this._firestoreClient.clientTerminated},enumerable:!0,configurable:!0}),wN.prototype.waitForPendingWrites=function(){return this.ensureClientConfigured(),this._firestoreClient.waitForPendingWrites()},wN.prototype.onSnapshotsInSync=function(t){if(this.ensureClientConfigured(),PC(t))return this.onSnapshotsInSyncInternal(t);Tg("Firestore.onSnapshotsInSync","function",1,t);var e={next:t};return this.onSnapshotsInSyncInternal(e)},wN.prototype.onSnapshotsInSyncInternal=function(t){var e=this,n=new bC({next:function(){t.next&&t.next()},error:function(t){throw ig("Uncaught Error in onSnapshotsInSync")}});return this._firestoreClient.addSnapshotsInSyncListener(n),function(){n.mute(),e._firestoreClient.removeSnapshotsInSyncListener(n)}},wN.prototype.ensureClientConfigured=function(){return this._firestoreClient||this.configureClient(new mC),this._firestoreClient},wN.prototype.makeDatabaseInfo=function(){return new Gg(this._databaseId,this._persistenceKey,this._settings.host,this._settings.ssl,this._settings.forceLongPolling)},wN.prototype.configureClient=function(t){og(!!this._settings.host,"FirestoreSettings.host is not set"),og(!this._firestoreClient,"configureClient() called multiple times");var e=this.makeDatabaseInfo();return this._firestoreClient=new gC(ag.getPlatform(),e,this._credentials,this._queue),this._firestoreClient.start(t)},wN.prototype.createDataConverter=function(r){return new cN(function(t){if(t instanceof IN){var e=r,n=t.firestore._databaseId;if(!n.isEqual(e))throw new lg(hg.INVALID_ARGUMENT,"Document reference is for database "+n.projectId+"/"+n.database+" but should be for database "+e.projectId+"/"+e.database);return new uN(r,t._key)}return t})},wN.databaseIdFromApp=function(t){var e=t.options;if(!dg(e,"projectId"))throw new lg(hg.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');var n=e.projectId;if(!n||"string"!=typeof n)throw new lg(hg.INVALID_ARGUMENT,"projectId must be a string in FirebaseApp.options");return new Xg(n)},Object.defineProperty(wN.prototype,"app",{get:function(){if(!this._firebaseApp)throw new lg(hg.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._firebaseApp},enumerable:!0,configurable:!0}),wN.prototype.collection=function(t){return wg("Firestore.collection",arguments,1),Tg("Firestore.collection","non-empty string",1,t),this.ensureClientConfigured(),new VN(iv.fromString(t),this)},wN.prototype.doc=function(t){return wg("Firestore.doc",arguments,1),Tg("Firestore.doc","non-empty string",1,t),this.ensureClientConfigured(),IN.forPath(iv.fromString(t),this)},wN.prototype.collectionGroup=function(t){if(wg("Firestore.collectionGroup",arguments,1),Tg("Firestore.collectionGroup","non-empty string",1,t),0<=t.indexOf("/"))throw new lg(hg.INVALID_ARGUMENT,"Invalid collection ID '"+t+"' passed to function Firestore.collectionGroup(). Collection IDs must not contain '/'.");return this.ensureClientConfigured(),new xN(new oT(iv.EMPTY_PATH,t),this)},wN.prototype.runTransaction=function(e){var n=this;return wg("Firestore.runTransaction",arguments,1),Tg("Firestore.runTransaction","function",1,e),this.ensureClientConfigured().transaction(function(t){return e(new _N(n,t))})},wN.prototype.batch=function(){return this.ensureClientConfigured(),new TN(this)},Object.defineProperty(wN,"logLevel",{get:function(){switch(Zm()){case Wm.DEBUG:return"debug";case Wm.ERROR:return"error";case Wm.SILENT:return"silent";default:return ig("Unknown log level: "+Zm())}},enumerable:!0,configurable:!0}),wN.setLogLevel=function(t){switch(wg("Firestore.setLogLevel",arguments,1),Tg("Firestore.setLogLevel","non-empty string",1,t),t){case"debug":tg(Wm.DEBUG);break;case"error":tg(Wm.ERROR);break;case"silent":tg(Wm.SILENT);break;default:throw new lg(hg.INVALID_ARGUMENT,"Invalid log level: "+t)}},wN.prototype._areTimestampsInSnapshotsEnabled=function(){return this._settings.timestampsInSnapshots},wN);function wN(t,e){var n=this;if(this._firebaseApp=null,this._queue=new gv,this.INTERNAL={delete:function(){return Ta(n,void 0,void 0,function(){return Sa(this,function(t){switch(t.label){case 0:return this.ensureClientConfigured(),[4,this._firestoreClient.terminate()];case 1:return t.sent(),[2]}})})}},"object"==typeof t.options){var r=t;this._firebaseApp=r,this._databaseId=wN.databaseIdFromApp(r),this._persistenceKey=r.name,this._credentials=new NC(e)}else{var i=t;if(!i.projectId)throw new lg(hg.INVALID_ARGUMENT,"Must provide projectId");this._databaseId=new Xg(i.projectId,i.database),this._persistenceKey="[DEFAULT]",this._credentials=new IC}this._settings=new gN({}),this._dataConverter=this.createDataConverter(this._databaseId)}var _N=(EN.prototype.get=function(t){var n=this;wg("Transaction.get",arguments,1);var r=KN("Transaction.get",t,this._firestore);return this._transaction.lookup([r._key]).then(function(t){if(!t||1!==t.length)return ig("Mismatch in docs returned from document lookup.");var e=t[0];if(e instanceof u_)return new DN(n._firestore,r._key,null,!1,!1,r._converter);if(e instanceof o_)return new DN(n._firestore,r._key,e,!1,!1,r._converter);throw ig("BatchGetDocumentsRequest returned unexpected document type: "+e.constructor.name)})},EN.prototype.set=function(t,e,n){Eg("Transaction.set",arguments,2,3);var r=KN("Transaction.set",t,this._firestore);n=BN("Transaction.set",n);var i=QN(r._converter,e,"Transaction.set"),o=i[0],a=i[1],s=n.merge||n.mergeFields?this._firestore._dataConverter.parseMergeData(a,o,n.mergeFields):this._firestore._dataConverter.parseSetData(a,o);return this._transaction.set(r._key,s),this},EN.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 _C?(_g("Transaction.update",arguments,3),r=KN("Transaction.update",t,this._firestore),this._firestore._dataConverter.parseUpdateVarargs("Transaction.update",e,n,o)):(wg("Transaction.update",arguments,2),r=KN("Transaction.update",t,this._firestore),this._firestore._dataConverter.parseUpdateData("Transaction.update",e)),this._transaction.update(r._key,i),this},EN.prototype.delete=function(t){wg("Transaction.delete",arguments,1);var e=KN("Transaction.delete",t,this._firestore);return this._transaction.delete(e._key),this},EN);function EN(t,e){this._firestore=t,this._transaction=e}var TN=(SN.prototype.set=function(t,e,n){Eg("WriteBatch.set",arguments,2,3),this.verifyNotCommitted();var r=KN("WriteBatch.set",t,this._firestore);n=BN("WriteBatch.set",n);var i=QN(r._converter,e,"WriteBatch.set"),o=i[0],a=i[1],s=n.merge||n.mergeFields?this._firestore._dataConverter.parseMergeData(a,o,n.mergeFields):this._firestore._dataConverter.parseSetData(a,o);return this._mutations=this._mutations.concat(s.toMutations(r._key,Wb.NONE)),this},SN.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 _C?(_g("WriteBatch.update",arguments,3),r=KN("WriteBatch.update",t,this._firestore),this._firestore._dataConverter.parseUpdateVarargs("WriteBatch.update",e,n,o)):(wg("WriteBatch.update",arguments,2),r=KN("WriteBatch.update",t,this._firestore),this._firestore._dataConverter.parseUpdateData("WriteBatch.update",e)),this._mutations=this._mutations.concat(i.toMutations(r._key,Wb.exists(!0))),this},SN.prototype.delete=function(t){wg("WriteBatch.delete",arguments,1),this.verifyNotCommitted();var e=KN("WriteBatch.delete",t,this._firestore);return this._mutations=this._mutations.concat(new rw(e._key,Wb.NONE)),this},SN.prototype.commit=function(){return Ta(this,void 0,void 0,function(){return Sa(this,function(t){return this.verifyNotCommitted(),this._committed=!0,0<this._mutations.length?[2,this._firestore.ensureClientConfigured().write(this._mutations)]:[2]})})},SN.prototype.verifyNotCommitted=function(){if(this._committed)throw new lg(hg.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")},SN);function SN(t){this._firestore=t,this._mutations=[],this._committed=!1}var IN=(CN.forPath=function(t,e,n){if(t.length%2!=0)throw new lg(hg.INVALID_ARGUMENT,"Invalid document reference. Document references must have an even number of segments, but "+t.canonicalString()+" has "+t.length);return new CN(new hv(t),e,n)},Object.defineProperty(CN.prototype,"id",{get:function(){return this._key.path.lastSegment()},enumerable:!0,configurable:!0}),Object.defineProperty(CN.prototype,"parent",{get:function(){return new VN(this._key.path.popLast(),this.firestore,this._converter)},enumerable:!0,configurable:!0}),Object.defineProperty(CN.prototype,"path",{get:function(){return this._key.path.canonicalString()},enumerable:!0,configurable:!0}),CN.prototype.collection=function(t){if(wg("DocumentReference.collection",arguments,1),Tg("DocumentReference.collection","non-empty string",1,t),!t)throw new lg(hg.INVALID_ARGUMENT,"Must provide a non-empty collection name to collection()");var e=iv.fromString(t);return new VN(this._key.path.child(e),this.firestore)},CN.prototype.isEqual=function(t){if(!(t instanceof CN))throw xg("isEqual","DocumentReference",1,t);return this.firestore===t.firestore&&this._key.isEqual(t._key)&&this._converter===t._converter},CN.prototype.set=function(t,e){Eg("DocumentReference.set",arguments,1,2),e=BN("DocumentReference.set",e);var n=QN(this._converter,t,"DocumentReference.set"),r=n[0],i=n[1],o=e.merge||e.mergeFields?this.firestore._dataConverter.parseMergeData(i,r,e.mergeFields):this.firestore._dataConverter.parseSetData(i,r);return this._firestoreClient.write(o.toMutations(this._key,Wb.NONE))},CN.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 _C?(_g("DocumentReference.update",arguments,2),this.firestore._dataConverter.parseUpdateVarargs("DocumentReference.update",t,e,r)):(wg("DocumentReference.update",arguments,1),this.firestore._dataConverter.parseUpdateData("DocumentReference.update",t)),this._firestoreClient.write(n.toMutations(this._key,Wb.exists(!0)))},CN.prototype.delete=function(){return wg("DocumentReference.delete",arguments,0),this._firestoreClient.write([new rw(this._key,Wb.NONE)])},CN.prototype.onSnapshot=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];Eg("DocumentReference.onSnapshot",arguments,1,4);var n,r={includeMetadataChanges:!1},i=0;"object"!=typeof t[i]||PC(t[i])||(Pg("DocumentReference.onSnapshot",r=t[i],["includeMetadataChanges"]),Cg("DocumentReference.onSnapshot","boolean","includeMetadataChanges",r.includeMetadataChanges),i++);var o={includeMetadataChanges:r.includeMetadataChanges};return n=PC(t[i])?t[i]:(Tg("DocumentReference.onSnapshot","function",i,t[i]),Sg("DocumentReference.onSnapshot","function",i+1,t[i+1]),Sg("DocumentReference.onSnapshot","function",i+2,t[i+2]),{next:t[i],error:t[i+1],complete:t[i+2]}),this.onSnapshotInternal(o,n)},CN.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 bC({next:function(t){if(n.next){og(t.docs.size<=1,"Too many documents returned on a document query");var e=t.docs.get(r._key);n.next(new DN(r.firestore,r._key,e,t.fromCache,t.hasPendingWrites,r._converter))}},error:e}),o=this._firestoreClient.listen(oT.atPath(this._key.path),i,t);return function(){i.mute(),r._firestoreClient.unlisten(o)}},CN.prototype.get=function(n){var r=this;return Eg("DocumentReference.get",arguments,0,1),WN("DocumentReference.get",n),new Promise(function(e,t){n&&"cache"===n.source?r.firestore.ensureClientConfigured().getDocumentFromLocalCache(r._key).then(function(t){e(new DN(r.firestore,r._key,t,!0,t instanceof o_&&t.hasLocalMutations,r._converter))},t):r.getViaSnapshotListener(e,t,n)})},CN.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 lg(hg.UNAVAILABLE,"Failed to get document because the client is offline.")):t.exists&&t.metadata.fromCache&&r&&"server"===r.source?n(new lg(hg.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})},CN.prototype.withConverter=function(t){return new CN(this._key,this.firestore,t)},CN);function CN(t,e,n){this._key=t,this.firestore=e,this._converter=n,this._firestoreClient=this.firestore.ensureClientConfigured()}var NN=(AN.prototype.isEqual=function(t){return this.hasPendingWrites===t.hasPendingWrites&&this.fromCache===t.fromCache},AN);function AN(t,e){this.hasPendingWrites=t,this.fromCache=e}var DN=(kN.prototype.data=function(t){if(Eg("DocumentSnapshot.data",arguments,0,1),t=jN("DocumentSnapshot.data",t),this._document){if(this._converter){var e=new ON(this._firestore,this._key,this._document,this._fromCache,this._hasPendingWrites);return this._converter.fromFirestore(e,t)}return this.toJSObject(this._document.data(),fw.fromSnapshotOptions(t,this._firestore._areTimestampsInSnapshotsEnabled()))}},kN.prototype.get=function(t,e){if(Eg("DocumentSnapshot.get",arguments,1,2),e=jN("DocumentSnapshot.get",e),this._document){var n=this._document.data().field(pN("DocumentSnapshot.get",t));if(null!==n)return this.toJSValue(n,fw.fromSnapshotOptions(e,this._firestore._areTimestampsInSnapshotsEnabled()))}},Object.defineProperty(kN.prototype,"id",{get:function(){return this._key.path.lastSegment()},enumerable:!0,configurable:!0}),Object.defineProperty(kN.prototype,"ref",{get:function(){return new IN(this._key,this._firestore,this._converter)},enumerable:!0,configurable:!0}),Object.defineProperty(kN.prototype,"exists",{get:function(){return null!==this._document},enumerable:!0,configurable:!0}),Object.defineProperty(kN.prototype,"metadata",{get:function(){return new NN(this._hasPendingWrites,this._fromCache)},enumerable:!0,configurable:!0}),kN.prototype.isEqual=function(t){if(!(t instanceof kN))throw xg("isEqual","DocumentSnapshot",1,t);return this._firestore===t._firestore&&this._fromCache===t._fromCache&&this._key.isEqual(t._key)&&(null===this._document?null===t._document:this._document.isEqual(t._document))&&this._converter===t._converter},kN.prototype.toJSObject=function(t,n){var r=this,i={};return t.forEach(function(t,e){i[t]=r.toJSValue(e,n)}),i},kN.prototype.toJSValue=function(t,e){if(t instanceof Jw)return this.toJSObject(t,e);if(t instanceof t_)return this.toJSArray(t,e);if(t instanceof Qw){var n=t.value(e),r=this._firestore.ensureClientConfigured().databaseId();return t.databaseId.isEqual(r)||ng("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 IN(n,this._firestore,this._converter)}return t.value(e)},kN.prototype.toJSArray=function(t,e){var n=this;return t.internalValue.map(function(t){return n.toJSValue(t,e)})},kN);function kN(t,e,n,r,i,o){this._firestore=t,this._key=e,this._document=n,this._fromCache=r,this._hasPendingWrites=i,this._converter=o}var RN,ON=(_a(PN,RN=DN),PN.prototype.data=function(t){var e=RN.prototype.data.call(this,t);return og(void 0!==e,"Document in a QueryDocumentSnapshot should exist"),e},PN);function PN(){return null!==RN&&RN.apply(this,arguments)||this}var xN=(MN.prototype.where=function(t,e,n){var r;wg("Query.where",arguments,3),Og("Query.where",3,n),function(t,e,n,r){if(!e.some(function(t){return t===r}))throw new lg(hg.INVALID_ARGUMENT,"Invalid value "+Rg(r)+" provided to function "+t+"() for its "+Lg(n)+" argument. Acceptable values: "+e.join(", "))}("Query.where",["<","<=","==",">=",">","array-contains","in","array-contains-any"],2,e);var i=pN("Query.where",t),o=uT.fromString(e);if(i.isKeyField()){if(o===uT.ARRAY_CONTAINS||o===uT.ARRAY_CONTAINS_ANY)throw new lg(hg.INVALID_ARGUMENT,"Invalid Query. You can't perform '"+o.toString()+"' queries on FieldPath.documentId().");if(o===uT.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 t_(a)}else r=this.parseDocumentIdValue(n)}else o!==uT.IN&&o!==uT.ARRAY_CONTAINS_ANY||this.validateDisjunctiveFilterElements(n,o),r=this.firestore._dataConverter.parseQueryValue("Query.where",n,o===uT.IN);var h=lT.create(i,o,r);return this.validateNewFilter(h),new MN(this._query.addFilter(h),this.firestore,this._converter)},MN.prototype.orderBy=function(t,e){var n;if(Eg("Query.orderBy",arguments,1,2),Sg("Query.orderBy","non-empty string",2,e),void 0===e||"asc"===e)n=AT.ASCENDING;else{if("desc"!==e)throw new lg(hg.INVALID_ARGUMENT,"Function Query.orderBy() has unknown direction '"+e+"', expected 'asc' or 'desc'.");n=AT.DESCENDING}if(null!==this._query.startAt)throw new lg(hg.INVALID_ARGUMENT,"Invalid query. You must not call Query.startAt() or Query.startAfter() before calling Query.orderBy().");if(null!==this._query.endAt)throw new lg(hg.INVALID_ARGUMENT,"Invalid query. You must not call Query.endAt() or Query.endBefore() before calling Query.orderBy().");var r=pN("Query.orderBy",t),i=new OT(r,n);return this.validateNewOrderBy(i),new MN(this._query.addOrderBy(i),this.firestore,this._converter)},MN.prototype.limit=function(t){return wg("Query.limit",arguments,1),Tg("Query.limit","number",1,t),Mg("Query.limit",1,t),new MN(this._query.withLimitToFirst(t),this.firestore,this._converter)},MN.prototype.limitToLast=function(t){return wg("Query.limitToLast",arguments,1),Tg("Query.limitToLast","number",1,t),Mg("Query.limitToLast",1,t),new MN(this._query.withLimitToLast(t),this.firestore,this._converter)},MN.prototype.startAt=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];_g("Query.startAt",arguments,1);var r=this.boundFromDocOrFields("Query.startAt",t,e,!0);return new MN(this._query.withStartAt(r),this.firestore,this._converter)},MN.prototype.startAfter=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];_g("Query.startAfter",arguments,1);var r=this.boundFromDocOrFields("Query.startAfter",t,e,!1);return new MN(this._query.withStartAt(r),this.firestore,this._converter)},MN.prototype.endBefore=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];_g("Query.endBefore",arguments,1);var r=this.boundFromDocOrFields("Query.endBefore",t,e,!0);return new MN(this._query.withEndAt(r),this.firestore,this._converter)},MN.prototype.endAt=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];_g("Query.endAt",arguments,1);var r=this.boundFromDocOrFields("Query.endAt",t,e,!1);return new MN(this._query.withEndAt(r),this.firestore,this._converter)},MN.prototype.isEqual=function(t){if(!(t instanceof MN))throw xg("isEqual","Query",1,t);return this.firestore===t.firestore&&this._query.isEqual(t._query)},MN.prototype.withConverter=function(t){return new MN(this._query,this.firestore,t)},MN.prototype.boundFromDocOrFields=function(t,e,n,r){if(Og(t,1,e),e instanceof DN){if(0<n.length)throw new lg(hg.INVALID_ARGUMENT,"Too many arguments provided to "+t+"().");var i=e;if(!i.exists)throw new lg(hg.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)},MN.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 Qw(this.firestore._databaseId,e.key));else{var s=e.field(a.field);if(s instanceof Vw)throw new lg(hg.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 lg(hg.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 kT(r,n)},MN.prototype.boundFromFields=function(t,e,n){var r=this._query.explicitOrderBy;if(e.length>r.length)throw new lg(hg.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 lg(hg.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 lg(hg.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(!hv.isDocumentKey(s))throw new lg(hg.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 hv(s);i.push(new Qw(this.firestore._databaseId,u))}else{var c=this.firestore._dataConverter.parseQueryValue(t,a);i.push(c)}}return new kT(i,n)},MN.prototype.onSnapshot=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];Eg("Query.onSnapshot",arguments,1,4);var n,r={},i=0;return"object"!=typeof t[i]||PC(t[i])||(Pg("Query.onSnapshot",r=t[i],["includeMetadataChanges"]),Cg("Query.onSnapshot","boolean","includeMetadataChanges",r.includeMetadataChanges),i++),n=PC(t[i])?t[i]:(Tg("Query.onSnapshot","function",i,t[i]),Sg("Query.onSnapshot","function",i+1,t[i+1]),Sg("Query.onSnapshot","function",i+2,t[i+2]),{next:t[i],error:t[i+1],complete:t[i+2]}),this.validateHasExplicitOrderByForLimitToLast(this._query),this.onSnapshotInternal(r,n)},MN.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 bC({next:function(t){e.next&&e.next(new LN(n.firestore,n._query,t,n._converter))},error:r}),o=this.firestore.ensureClientConfigured(),a=o.listen(this._query,i,t);return function(){i.mute(),o.unlisten(a)}},MN.prototype.validateHasExplicitOrderByForLimitToLast=function(t){if(t.hasLimitToLast()&&0===t.explicitOrderBy.length)throw new lg(hg.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")},MN.prototype.get=function(n){var r=this;return Eg("Query.get",arguments,0,1),WN("Query.get",n),this.validateHasExplicitOrderByForLimitToLast(this._query),new Promise(function(e,t){n&&"cache"===n.source?r.firestore.ensureClientConfigured().getDocumentsFromLocalCache(r._query).then(function(t){e(new LN(r.firestore,r._query,t,r._converter))},t):r.getViaSnapshotListener(e,t,n)})},MN.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 lg(hg.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})},MN.prototype.parseDocumentIdValue=function(t){if("string"==typeof t){if(""===t)throw new lg(hg.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 lg(hg.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(!hv.isDocumentKey(e))throw new lg(hg.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 Qw(this.firestore._databaseId,new hv(e))}if(t instanceof IN){var n=t;return new Qw(this.firestore._databaseId,n._key)}throw new lg(hg.INVALID_ARGUMENT,"Invalid query. When querying with FieldPath.documentId(), you must provide a valid string or a DocumentReference, but it was: "+Rg(t)+".")},MN.prototype.validateDisjunctiveFilterElements=function(t,e){if(!Array.isArray(t)||0===t.length)throw new lg(hg.INVALID_ARGUMENT,"Invalid Query. A non-empty array is required for '"+e.toString()+"' filters.");if(10<t.length)throw new lg(hg.INVALID_ARGUMENT,"Invalid Query. '"+e.toString()+"' filters support a maximum of 10 elements in the value array.");if(0<=t.indexOf(null))throw new lg(hg.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 lg(hg.INVALID_ARGUMENT,"Invalid Query. '"+e.toString()+"' filters cannot contain 'NaN' in the value array.")},MN.prototype.validateNewFilter=function(t){if(t instanceof lT){var e=[uT.ARRAY_CONTAINS,uT.ARRAY_CONTAINS_ANY],n=[uT.IN,uT.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 lg(hg.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 lg(hg.INVALID_ARGUMENT,"Invalid query. You cannot use more than one '"+t.op.toString()+"' filter."):new lg(hg.INVALID_ARGUMENT,"Invalid query. You cannot use '"+t.op.toString()+"' filters with '"+s.toString()+"' filters.")}}},MN.prototype.validateNewOrderBy=function(t){if(null===this._query.getFirstOrderByField()){var e=this._query.getInequalityFilterField();null!==e&&this.validateOrderByAndInequalityMatch(e,t.field)}},MN.prototype.validateOrderByAndInequalityMatch=function(t,e){if(!e.isEqual(t))throw new lg(hg.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.")},MN);function MN(t,e,n){this._query=t,this.firestore=e,this._converter=n}var LN=(Object.defineProperty(FN.prototype,"docs",{get:function(){var e=[];return this.forEach(function(t){return e.push(t)}),e},enumerable:!0,configurable:!0}),Object.defineProperty(FN.prototype,"empty",{get:function(){return this._snapshot.docs.isEmpty()},enumerable:!0,configurable:!0}),Object.defineProperty(FN.prototype,"size",{get:function(){return this._snapshot.docs.size},enumerable:!0,configurable:!0}),FN.prototype.forEach=function(e,n){var r=this;Eg("QuerySnapshot.forEach",arguments,1,2),Tg("QuerySnapshot.forEach","function",1,e),this._snapshot.docs.forEach(function(t){e.call(n,r.convertToDocumentImpl(t))})},Object.defineProperty(FN.prototype,"query",{get:function(){return new xN(this._originalQuery,this._firestore,this._converter)},enumerable:!0,configurable:!0}),FN.prototype.docChanges=function(t){t&&(Pg("QuerySnapshot.docChanges",t,["includeMetadataChanges"]),Cg("QuerySnapshot.docChanges","boolean","includeMetadataChanges",t.includeMetadataChanges));var e=!(!t||!t.includeMetadataChanges);if(e&&this._snapshot.excludesMetadataChanges)throw new lg(hg.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===e||(this._cachedChanges=function(i,e,o,a){if(o.oldDocs.isEmpty()){var n,r=0;return o.docChanges.map(function(t){var e=new ON(i,t.doc.key,t.doc,o.fromCache,o.mutatedKeys.has(t.doc.key),a);return og(t.type===AS.Added,"Invalid event type for first snapshot"),og(!n||o.query.docComparator(n,t.doc)<0,"Got added events in wrong order"),n=t.doc,{type:"added",doc:e,oldIndex:-1,newIndex:r++}})}var s=o.oldDocs;return o.docChanges.filter(function(t){return e||t.type!==AS.Metadata}).map(function(t){var e=new ON(i,t.doc.key,t.doc,o.fromCache,o.mutatedKeys.has(t.doc.key),a),n=-1,r=-1;return t.type!==AS.Added&&(og(0<=(n=s.indexOf(t.doc.key)),"Index for document not found"),s=s.delete(t.doc.key)),t.type!==AS.Removed&&(r=(s=s.add(t.doc)).indexOf(t.doc.key)),{type:function(t){switch(t){case AS.Added:return"added";case AS.Modified:case AS.Metadata:return"modified";case AS.Removed:return"removed";default:return ig("Unknown change type: "+t)}}(t.type),doc:e,oldIndex:n,newIndex:r}})}(this._firestore,e,this._snapshot,this._converter),this._cachedChangesIncludeMetadataChanges=e),this._cachedChanges},FN.prototype.isEqual=function(t){if(!(t instanceof FN))throw xg("isEqual","QuerySnapshot",1,t);return this._firestore===t._firestore&&this._originalQuery.isEqual(t._originalQuery)&&this._snapshot.isEqual(t._snapshot)&&this._converter===t._converter},FN.prototype.convertToDocumentImpl=function(t){return new ON(this._firestore,t.key,t,this.metadata.fromCache,this._snapshot.mutatedKeys.has(t.key),this._converter)},FN);function FN(t,e,n,r){this._firestore=t,this._originalQuery=e,this._snapshot=n,this._converter=r,this._cachedChanges=null,this._cachedChangesIncludeMetadataChanges=null,this.metadata=new NN(n.hasPendingWrites,n.fromCache)}Aa(["length","forEach","map"],"undefined"!=typeof Symbol?[Symbol.iterator]:[]).forEach(function(t){try{Object.defineProperty(LN.prototype.docChanges,t,{get:function(){return function(){throw new lg(hg.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 UN,VN=(_a(qN,UN=xN),Object.defineProperty(qN.prototype,"id",{get:function(){return this._query.path.lastSegment()},enumerable:!0,configurable:!0}),Object.defineProperty(qN.prototype,"parent",{get:function(){var t=this._query.path.popLast();return t.isEmpty()?null:new IN(new hv(t),this.firestore)},enumerable:!0,configurable:!0}),Object.defineProperty(qN.prototype,"path",{get:function(){return this._query.path.canonicalString()},enumerable:!0,configurable:!0}),qN.prototype.doc=function(t){if(Eg("CollectionReference.doc",arguments,0,1),0===arguments.length&&(t=Ug.newId()),Tg("CollectionReference.doc","non-empty string",1,t),""===t)throw new lg(hg.INVALID_ARGUMENT,"Document path must be a non-empty string");var e=iv.fromString(t);return IN.forPath(this._query.path.child(e),this.firestore,this._converter)},qN.prototype.add=function(t){wg("CollectionReference.add",arguments,1),Tg("CollectionReference.add","object",1,t);var e=this.doc();return e.set(t).then(function(){return e})},qN.prototype.withConverter=function(t){return new qN(this._path,this.firestore,t)},qN);function qN(t,e,n){var r=UN.call(this,oT.atPath(t),e,n)||this;if((r._path=t).length%2!=1)throw new lg(hg.INVALID_ARGUMENT,"Invalid collection reference. Collection references must have an odd number of segments, but "+t.canonicalString()+" has "+t.length);return r}function BN(t,e){if(void 0===e)return{merge:!1};if(Pg(t,e,["merge","mergeFields"]),Cg(t,"boolean","merge",e.merge),Ng(t,"mergeFields","a string or a FieldPath",e.mergeFields,function(t){return"string"==typeof t||t instanceof _C}),void 0!==e.mergeFields&&void 0!==e.merge)throw new lg(hg.INVALID_ARGUMENT,"Invalid options passed to function "+t+'(): You cannot specify both "merge" and "mergeFields".');return e}function jN(t,e){return void 0===e?{}:(Pg(t,e,["serverTimestamps"]),Ag(t,0,"serverTimestamps",e.serverTimestamps,["estimate","previous","none"]),e)}function WN(t,e){Sg(t,"object",1,e),e&&(Pg(t,e,["source"]),Ag(t,0,"source",e.source,["default","server","cache"]))}function KN(t,e,n){if(e instanceof IN){if(e.firestore!==n)throw new lg(hg.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return e}throw xg(t,"DocumentReference",1,e)}function QN(t,e,n){var r;return t?(r=t.toFirestore(e),n="toFirestore() in "+n):r=e,[r,n]}var HN=pg(bN,"Use firebase.firestore() instead."),zN=pg(_N,"Use firebase.firestore().runTransaction() instead."),GN=pg(TN,"Use firebase.firestore().batch() instead."),YN=pg(IN,"Use firebase.firestore().doc() instead."),XN=pg(DN),JN=pg(ON),$N=pg(xN),ZN=pg(LN),tA=pg(VN,"Use firebase.firestore().collection() instead."),eA={Firestore:HN,GeoPoint:nI,Timestamp:Nv,Blob:zg,Transaction:zN,WriteBatch:GN,DocumentReference:YN,DocumentSnapshot:XN,Query:$N,QueryDocumentSnapshot:JN,QuerySnapshot:ZN,CollectionReference:tA,FieldPath:_C,FieldValue:JC,setLogLevel:bN.setLogLevel,CACHE_SIZE_UNLIMITED:mN};function nA(t){t.INTERNAL.registerComponent(new ps("firestore",function(t){var e=t.getProvider("app").getImmediate();return new bN(e,t.getProvider("auth-internal"))},"PUBLIC").setServiceProps(function(t){og(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}(eA)))}var rA=(iA.prototype.addCallback=function(t){},iA.prototype.shutdown=function(){},iA);function iA(){}var oA="ConnectivityMonitor",aA=(sA.prototype.addCallback=function(t){this.callbacks.push(t)},sA.prototype.shutdown=function(){window.removeEventListener("online",this.networkAvailableListener),window.removeEventListener("offline",this.networkUnavailableListener)},sA.prototype.configureNetworkMonitoring=function(){window.addEventListener("online",this.networkAvailableListener),window.addEventListener("offline",this.networkUnavailableListener)},sA.prototype.onNetworkAvailable=function(){eg(oA,"Network connectivity changed: AVAILABLE");for(var t=0,e=this.callbacks;t<e.length;t++)(0,e[t])(0)},sA.prototype.onNetworkUnavailable=function(){eg(oA,"Network connectivity changed: UNAVAILABLE");for(var t=0,e=this.callbacks;t<e.length;t++)(0,e[t])(1)},sA.isAvailable=function(){return"undefined"!=typeof window&&void 0!==window.addEventListener&&void 0!==window.removeEventListener},sA);function sA(){var t=this;this.networkAvailableListener=function(){return t.onNetworkAvailable()},this.networkUnavailableListener=function(){return t.onNetworkUnavailable()},this.callbacks=[],this.configureNetworkMonitoring()}var uA=(cA.prototype.onOpen=function(t){og(!this.wrappedOnOpen,"Called onOpen on stream twice!"),this.wrappedOnOpen=t},cA.prototype.onClose=function(t){og(!this.wrappedOnClose,"Called onClose on stream twice!"),this.wrappedOnClose=t},cA.prototype.onMessage=function(t){og(!this.wrappedOnMessage,"Called onMessage on stream twice!"),this.wrappedOnMessage=t},cA.prototype.close=function(){this.closeFn()},cA.prototype.send=function(t){this.sendFn(t)},cA.prototype.callOnOpen=function(){og(void 0!==this.wrappedOnOpen,"Cannot call onOpen because no callback was set"),this.wrappedOnOpen()},cA.prototype.callOnClose=function(t){og(void 0!==this.wrappedOnClose,"Cannot call onClose because no callback was set"),this.wrappedOnClose(t)},cA.prototype.callOnMessage=function(t){og(void 0!==this.wrappedOnMessage,"Cannot call onMessage because no callback was set"),this.wrappedOnMessage(t)},cA);function cA(t){this.sendFn=t.sendFn,this.closeFn=t.closeFn}var hA="Connection",lA={BatchGetDocuments:"batchGet",Commit:"commit"},fA="gl-js/ fire/"+Jm,pA=(dA.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"]=fA},dA.prototype.invokeRPC=function(s,r,u){var c=this,h=this.makeUrl(s);return new Promise(function(i,o){var a=new Xm;a.listenOnce(Gm.COMPLETE,function(){try{switch(a.getLastErrorCode()){case zm.NO_ERROR:var t=a.getResponseJson();eg(hA,"XHR received:",JSON.stringify(t)),i(t);break;case zm.TIMEOUT:eg(hA,'RPC "'+s+'" timed out'),o(new lg(hg.DEADLINE_EXCEEDED,"Request time out"));break;case zm.HTTP_ERROR:var e=a.getStatus();if(eg(hA,'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(hg).indexOf(e)?e:hg.UNKNOWN}(n.status);o(new lg(r,n.message))}else o(new lg(hg.UNKNOWN,"Server responded with status "+a.getStatus()))}else eg(hA,'RPC "'+s+'" failed'),o(new lg(hg.UNAVAILABLE,"Connection failed."));break;default:ig('RPC "'+s+'" failed with unanticipated webchannel error '+a.getLastErrorCode()+": "+a.getLastError()+", giving up.")}}finally{eg(hA,'RPC "'+s+'" completed.')}});var t=Ea({},r);delete t.database;var e=JSON.stringify(t);eg(hA,"XHR sending: ",h+" "+e);var n={"Content-Type":"text/plain"};c.modifyHeadersForRequest(n,u),a.send(h,"POST",e,n,15)})},dA.prototype.invokeStreamingRPC=function(t,e,n){return this.invokeRPC(t,e,n)},dA.prototype.openStream=function(t,e){var n=[this.baseUrl,"/","google.firestore.v1.Firestore","/",t,"/channel"],r=Hm(),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()||0<=Va().indexOf("Electron/")||function(){var t=Va();return 0<=t.indexOf("MSIE ")||0<=t.indexOf("Trident/")}()||0<=Va().indexOf("MSAppHost/")||function(){var t="object"==typeof chrome?chrome.runtime:"object"==typeof browser?browser.runtime:void 0;return"object"==typeof t&&void 0!==t.id}()||(i.httpHeadersOverwriteParam="$httpHeaders");var o=n.join("");function a(t,e){u.listen(t,function(t){try{e(t)}catch(t){setTimeout(function(){throw t},0)}})}eg(hA,"Creating WebChannel: "+o+" "+i);var u=r.createWebChannel(o,i),s=!1,c=!1,h=new uA({sendFn:function(t){c?eg(hA,"Not sending because WebChannel is closed:",t):(s||(eg(hA,"Opening WebChannel transport."),u.open(),s=!0),eg(hA,"WebChannel sending:",t),u.send(t))},closeFn:function(){return u.close()}});return a(Ym.EventType.OPEN,function(){c||eg(hA,"WebChannel transport opened.")}),a(Ym.EventType.CLOSE,function(){c||(c=!0,eg(hA,"WebChannel transport closed"),h.callOnClose())}),a(Ym.EventType.ERROR,function(t){c||(c=!0,eg(hA,"WebChannel transport errored:",t),h.callOnClose(new lg(hg.UNAVAILABLE,"The operation could not be completed")))}),a(Ym.EventType.MESSAGE,function(t){var e;if(!c){var n=t.data[0];og(!!n,"Got a webchannel message without data.");var r=n,i=r.error||(null===(e=r[0])||void 0===e?void 0:e.error);if(i){eg(hA,"WebChannel received error:",i);var o=i.status,a=function(t){var e=ES[t];if(void 0!==e)return NS(e)}(o),s=i.message;void 0===a&&(a=hg.INTERNAL,s="Unknown error status: "+o+" with message "+i.message),c=!0,h.callOnClose(new lg(a,s)),u.close()}else eg(hA,"WebChannel received:",n),h.callOnMessage(n)}}),setTimeout(function(){h.callOnOpen()},0),h},dA.prototype.makeUrl=function(t){var e=lA[t];return og(void 0!==e,"Unknown REST mapping for: "+t),this.baseUrl+"/v1/projects/"+this.databaseId.projectId+"/databases/"+this.databaseId.database+"/documents:"+e},dA);function dA(t){this.databaseId=t.databaseId;var e=t.ssl?"https":"http";this.baseUrl=e+"://"+t.host,this.forceLongPolling=t.forceLongPolling}var yA=(Object.defineProperty(mA.prototype,"document",{get:function(){return"undefined"!=typeof document?document:null},enumerable:!0,configurable:!0}),Object.defineProperty(mA.prototype,"window",{get:function(){return"undefined"!=typeof window?window:null},enumerable:!0,configurable:!0}),mA.prototype.loadConnection=function(t){return Promise.resolve(new pA(t))},mA.prototype.newConnectivityMonitor=function(){return aA.isAvailable()?new aA:new rA},mA.prototype.newSerializer=function(t){return new EI(t,{useProto3Json:!0})},mA.prototype.formatJSON=function(t){return JSON.stringify(t)},mA.prototype.atob=function(t){return atob(t)},mA.prototype.btoa=function(t){return btoa(t)},mA);function mA(){this.emptyByteString="",this.base64Available="undefined"!=typeof atob}ag.setPlatform(new yA);var gA;nA(gA=fl),gA.registerVersion("@firebase/firestore","1.10.0");var vA,bA={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"},wA=(_a(_A,vA=Error),_A);function _A(t,e,n){var r=vA.call(this,e)||this;return Object.setPrototypeOf(r,_A.prototype),r.code=t,r.details=n,r}function EA(t,e,n){var r=function(t){if(200<=t&&t<300)return"ok";switch(t){case 0:return"internal";case 400:return"invalid-argument";case 401:return"unauthenticated";case 403:return"permission-denied";case 404:return"not-found";case 409:return"aborted";case 429:return"resource-exhausted";case 499:return"cancelled";case 500:return"internal";case 501:return"unimplemented";case 503:return"unavailable";case 504:return"deadline-exceeded"}return"unknown"}(t),i=r,o=void 0;try{var a=e&&e.error;if(a){var s=a.status;if("string"==typeof s){if(!bA[s])return new wA("internal","internal");r=bA[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 wA(r,i,o)}var TA=(SA.prototype.getAuthToken=function(){return Ta(this,void 0,void 0,function(){var e;return Sa(this,function(t){switch(t.label){case 0:if(!this.auth)return[2,void 0];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.auth.getToken()];case 2:return(e=t.sent())?[2,e.accessToken]:[2,void 0];case 3:return t.sent(),[2,void 0];case 4:return[2]}})})},SA.prototype.getInstanceIdToken=function(){return Ta(this,void 0,void 0,function(){return Sa(this,function(t){if(!(this.messaging&&"Notification"in self&&"granted"===Notification.permission))return[2,void 0];try{return[2,this.messaging.getToken()]}catch(t){return[2,void 0]}return[2]})})},SA.prototype.getContext=function(){return Ta(this,void 0,void 0,function(){var e,n;return Sa(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}]}})})},SA);function SA(t,e){var n=this;this.auth=null,this.messaging=null,this.auth=t.getImmediate({optional:!0}),this.messaging=e.getImmediate({optional:!0}),this.auth||t.get().then(function(t){return n.auth=t},function(){}),this.messaging||e.get().then(function(t){return n.messaging=t},function(){})}function IA(t,e){var n={};for(var r in t)t.hasOwnProperty(r)&&(n[r]=e(t[r]));return n}var CA=(NA.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 IA(t,function(t){return e.encode(t)});throw new Error("Data cannot be encoded in JSON: "+t)},NA.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?IA(t,function(t){return e.decode(t)}):t},NA);function NA(){}var AA=(Object.defineProperty(DA.prototype,"app",{get:function(){return this.app_},enumerable:!0,configurable:!0}),DA.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},DA.prototype.useFunctionsEmulator=function(t){this.emulatorOrigin=t},DA.prototype.httpsCallable=function(e,n){var r=this;return function(t){return r.call(e,t,n||{})}},DA.prototype.postJSON=function(r,i,o){return Ta(this,void 0,void 0,function(){var e,n;return Sa(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}]}})})},DA.prototype.call=function(c,h,l){return Ta(this,void 0,void 0,function(){var e,n,r,i,o,a,s,u;return Sa(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 wA("deadline-exceeded","deadline-exceeded"))},n)})}(o),this.cancelAllRequests])];case 2:if(!(a=t.sent()))throw new wA("cancelled","Firebase Functions instance was deleted.");if(s=EA(a.status,a.json,this.serializer))throw s;if(!a.json)throw new wA("internal","Response is not valid JSON object.");if(void 0===(u=a.json.data)&&(u=a.json.result),void 0===u)throw new wA("internal","Response is missing data field.");return[2,{data:this.serializer.decode(u)}]}})})},DA);function DA(t,e,n,r){var i=this;void 0===r&&(r="us-central1"),this.app_=t,this.region_=r,this.serializer=new CA,this.emulatorOrigin=null,this.INTERNAL={delete:function(){return i.deleteService()}},this.contextProvider=new TA(e,n),this.cancelAllRequests=new Promise(function(t){i.deleteService=function(){return t()}})}function kA(t,e){var n=t.getProvider("app").getImmediate(),r=t.getProvider("auth-internal"),i=t.getProvider("messaging");return new AA(n,r,i,e)}var RA;function OA(n){return new Promise(function(t,e){n.onsuccess=function(){t(n.result)},n.onerror=function(){e(n.error)}})}function PA(n,r,i){var o,t=new Promise(function(t,e){OA(o=n[r].apply(n,i)).then(t,e)});return t.request=o,t}function xA(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 MA(e,n,r,t){t.forEach(function(t){t in r.prototype&&(e.prototype[t]=function(){return PA(this[n],t,arguments)})})}function LA(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 FA(e,n,r,t){t.forEach(function(t){t in r.prototype&&(e.prototype[t]=function(){return function(t,e,n){var r=PA(t,e,n);return r.then(function(t){if(t)return new VA(t,r.request)})}(this[n],t,arguments)})})}function UA(t){this._index=t}function VA(t,e){this._cursor=t,this._request=e}function qA(t){this._store=t}function BA(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 jA(t,e,n){this._db=t,this.oldVersion=e,this.transaction=new BA(n)}function WA(t){this._db=t}function KA(t,e,n){var r=PA(indexedDB,"open",[t,e]),i=r.request;return i&&(i.onupgradeneeded=function(t){n&&n(new jA(i.result,t.oldVersion,i.transaction))}),r.then(function(t){return new WA(t)})}function QA(t){return PA(indexedDB,"deleteDatabase",[t])}RA={Functions:AA},fl.INTERNAL.registerComponent(new ps("functions",kA,"PUBLIC").setServiceProps(RA).setMultipleInstances(!0)),fl.registerVersion("@firebase/functions","0.4.31"),xA(UA,"_index",["name","keyPath","multiEntry","unique"]),MA(UA,"_index",IDBIndex,["get","getKey","getAll","getAllKeys","count"]),FA(UA,"_index",IDBIndex,["openCursor","openKeyCursor"]),xA(VA,"_cursor",["direction","key","primaryKey","value"]),MA(VA,"_cursor",IDBCursor,["update","delete"]),["advance","continue","continuePrimaryKey"].forEach(function(n){n in IDBCursor.prototype&&(VA.prototype[n]=function(){var e=this,t=arguments;return Promise.resolve().then(function(){return e._cursor[n].apply(e._cursor,t),OA(e._request).then(function(t){if(t)return new VA(t,e._request)})})})}),qA.prototype.createIndex=function(){return new UA(this._store.createIndex.apply(this._store,arguments))},qA.prototype.index=function(){return new UA(this._store.index.apply(this._store,arguments))},xA(qA,"_store",["name","keyPath","indexNames","autoIncrement"]),MA(qA,"_store",IDBObjectStore,["put","add","delete","clear","get","getAll","getKey","getAllKeys","count"]),FA(qA,"_store",IDBObjectStore,["openCursor","openKeyCursor"]),LA(qA,"_store",IDBObjectStore,["deleteIndex"]),BA.prototype.objectStore=function(){return new qA(this._tx.objectStore.apply(this._tx,arguments))},xA(BA,"_tx",["objectStoreNames","mode"]),LA(BA,"_tx",IDBTransaction,["abort"]),jA.prototype.createObjectStore=function(){return new qA(this._db.createObjectStore.apply(this._db,arguments))},xA(jA,"_db",["name","version","objectStoreNames"]),LA(jA,"_db",IDBDatabase,["deleteObjectStore","close"]),WA.prototype.transaction=function(){return new BA(this._db.transaction.apply(this._db,arguments))},xA(WA,"_db",["name","version","objectStoreNames"]),LA(WA,"_db",IDBDatabase,["close"]),["openCursor","openKeyCursor"].forEach(function(i){[qA,UA].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)}})})}),[UA,qA].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 HA,zA=1e4,GA="w:0.4.1",YA="FIS_v2",XA="https://firebaseinstallations.googleapis.com/v1",JA=36e5,$A=((HA={})["missing-app-config-values"]='Missing App configuration value: "{$valueName}"',HA["not-registered"]="Firebase Installation is not registered.",HA["installation-not-found"]="Firebase Installation not found.",HA["request-failed"]='{$requestName} request failed with error "{$serverCode} {$serverStatus}: {$serverMessage}"',HA["app-offline"]="Could not process request. Application offline.",HA["delete-pending-registration"]="Can't delete installation while there is a pending registration request.",HA),ZA=new Ha("installations","Installations",$A);function tD(t){return t instanceof Ka&&t.code.includes("request-failed")}function eD(t){var e=t.projectId;return XA+"/projects/"+e+"/installations"}function nD(t){return{token:t.token,requestStatus:2,expiresIn:function(t){return Number(t.replace("s","000"))}(t.expiresIn),creationTime:Date.now()}}function rD(r,i){return Ta(this,void 0,void 0,function(){var e,n;return Sa(this,function(t){switch(t.label){case 0:return[4,i.json()];case 1:return e=t.sent(),n=e.error,[2,ZA.create("request-failed",{requestName:r,serverCode:n.code,serverMessage:n.message,serverStatus:n.status})]}})})}function iD(t){var e=t.apiKey;return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":e})}function oD(t,e){var n=e.refreshToken,r=iD(t);return r.append("Authorization",function(t){return YA+" "+t}(n)),r}function aD(n){return Ta(this,void 0,void 0,function(){var e;return Sa(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 sD(e){return new Promise(function(t){setTimeout(t,e)})}var uD=/^[cdef][\w-]{21}$/,cD="";function hD(){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,Na(t))).replace(/\+/g,"-").replace(/\//g,"_")}(t).substr(0,22)}(t);return uD.test(e)?e:cD}catch(t){return cD}}function lD(t){return t.appName+"!"+t.appId}var fD=new Map;function pD(t,e){var n=lD(t);dD(n,e),function(t,e){var n=mD();n&&n.postMessage({key:t,fid:e});gD()}(n,e)}function dD(t,e){var n,r,i=fD.get(t);if(i)try{for(var o=Ia(i),a=o.next();!a.done;a=o.next()){(0,a.value)(e)}}catch(t){n={error:t}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}}var yD=null;function mD(){return!yD&&"BroadcastChannel"in self&&((yD=new BroadcastChannel("[Firebase] FID Change")).onmessage=function(t){dD(t.data.key,t.data.fid)}),yD}function gD(){0===fD.size&&yD&&(yD.close(),yD=null)}var vD,bD,wD="firebase-installations-database",_D=1,ED="firebase-installations-store",TD=null;function SD(){return TD=TD||KA(wD,_D,function(t){switch(t.oldVersion){case 0:t.createObjectStore(ED)}})}function ID(a,s){return Ta(this,void 0,void 0,function(){var e,n,r,i,o;return Sa(this,function(t){switch(t.label){case 0:return e=lD(a),[4,SD()];case 1:return n=t.sent(),r=n.transaction(ED,"readwrite"),[4,(i=r.objectStore(ED)).get(e)];case 2:return o=t.sent(),[4,i.put(s,e)];case 3:return t.sent(),[4,r.complete];case 4:return t.sent(),o&&o.fid===s.fid||pD(a,s.fid),[2,s]}})})}function CD(i){return Ta(this,void 0,void 0,function(){var e,n,r;return Sa(this,function(t){switch(t.label){case 0:return e=lD(i),[4,SD()];case 1:return n=t.sent(),[4,(r=n.transaction(ED,"readwrite")).objectStore(ED).delete(e)];case 2:return t.sent(),[4,r.complete];case 3:return t.sent(),[2]}})})}function ND(s,u){return Ta(this,void 0,void 0,function(){var e,n,r,i,o,a;return Sa(this,function(t){switch(t.label){case 0:return e=lD(s),[4,SD()];case 1:return n=t.sent(),r=n.transaction(ED,"readwrite"),[4,(i=r.objectStore(ED)).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(),!a||o&&o.fid===a.fid||pD(s,a.fid),[2,a]}})})}function AD(i){return Ta(this,void 0,void 0,function(){var r,e,n;return Sa(this,function(t){switch(t.label){case 0:return[4,ND(i,function(t){var e=function(t){return kD(t||{fid:hD(),registrationStatus:0})}(t),n=function(t,e){{if(0!==e.registrationStatus)return 1===e.registrationStatus?{installationEntry:e,registrationPromise:function(o){return Ta(this,void 0,void 0,function(){var e,n,r,i;return Sa(this,function(t){switch(t.label){case 0:return[4,DD(o)];case 1:e=t.sent(),t.label=2;case 2:return 1!==e.registrationStatus?[3,5]:[4,sD(100)];case 3:return t.sent(),[4,DD(o)];case 4:return e=t.sent(),[3,2];case 5:return 0!==e.registrationStatus?[3,7]:[4,AD(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(ZA.create("app-offline"));return{installationEntry:e,registrationPromise:n}}var r={fid:e.fid,registrationStatus:1,registrationTime:Date.now()},i=function(r,i){return Ta(this,void 0,void 0,function(){var e,n;return Sa(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,7]),[4,function(s,t){var u=t.fid;return Ta(this,void 0,void 0,function(){var e,n,r,i,o,a;return Sa(this,function(t){switch(t.label){case 0:return e=eD(s),n=iD(s),r={fid:u,authVersion:YA,appId:s.appId,sdkVersion:GA},i={method:"POST",headers:n,body:JSON.stringify(r)},[4,aD(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:nD(a.authToken)}];case 3:return[4,rD("Create Installation",o)];case 4:throw t.sent()}})})}(r,i)];case 1:return e=t.sent(),[2,ID(r,e)];case 2:return tD(n=t.sent())&&409===n.serverCode?[4,CD(r)]:[3,4];case 3:return t.sent(),[3,6];case 4:return[4,ID(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!==cD?[3,3]:(n={},[4,r]);case 2:return[2,(n.installationEntry=t.sent(),n)];case 3:return[2,{installationEntry:e,registrationPromise:r}]}})})}function DD(t){return ND(t,function(t){if(!t)throw ZA.create("installation-not-found");return kD(t)})}function kD(t){return function(t){return 1===t.registrationStatus&&t.registrationTime+zA<Date.now()}(t)?{fid:t.fid,registrationStatus:0}:t}function RD(t,u){var c=t.appConfig,h=t.platformLoggerProvider;return Ta(this,void 0,void 0,function(){var e,n,r,i,o,a,s;return Sa(this,function(t){switch(t.label){case 0:return e=function(t,e){var n=e.fid;return eD(t)+"/"+n+"/authTokens:generate"}(c,u),n=oD(c,u),(r=h.getImmediate({optional:!0}))&&n.append("x-firebase-client",r.getPlatformInfoString()),i={installation:{sdkVersion:GA}},o={method:"POST",headers:n,body:JSON.stringify(i)},[4,aD(function(){return fetch(e,o)})];case 1:return(a=t.sent()).ok?[4,a.json()]:[3,3];case 2:return s=t.sent(),[2,nD(s)];case 3:return[4,rD("Generate Auth Token",a)];case 4:throw t.sent()}})})}function OD(i,o){return void 0===o&&(o=!1),Ta(this,void 0,void 0,function(){var r,e,n;return Sa(this,function(t){switch(t.label){case 0:return[4,ND(i.appConfig,function(t){if(!xD(t))throw ZA.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+JA}(t)}(e))return t;if(1===e.requestStatus)return r=function(r,i){return Ta(this,void 0,void 0,function(){var e,n;return Sa(this,function(t){switch(t.label){case 0:return[4,PD(r.appConfig)];case 1:e=t.sent(),t.label=2;case 2:return 1!==e.authToken.requestStatus?[3,5]:[4,sD(100)];case 3:return t.sent(),[4,PD(r.appConfig)];case 4:return e=t.sent(),[3,2];case 5:return 0===(n=e.authToken).requestStatus?[2,OD(r,i)]:[2,n]}})})}(i,o),t;if(!navigator.onLine)throw ZA.create("app-offline");var n=function(t){var e={requestStatus:1,requestTime:Date.now()};return Ea(Ea({},t),{authToken:e})}(t);return r=function(i,o){return Ta(this,void 0,void 0,function(){var e,n,r;return Sa(this,function(t){switch(t.label){case 0:return t.trys.push([0,3,,8]),[4,RD(i,o)];case 1:return e=t.sent(),r=Ea(Ea({},o),{authToken:e}),[4,ID(i.appConfig,r)];case 2:return t.sent(),[2,e];case 3:return!tD(n=t.sent())||401!==n.serverCode&&404!==n.serverCode?[3,5]:[4,CD(i.appConfig)];case 4:return t.sent(),[3,7];case 5:return r=Ea(Ea({},o),{authToken:{requestStatus:0}}),[4,ID(i.appConfig,r)];case 6:t.sent(),t.label=7;case 7:throw n;case 8:return[2]}})})}(i,n),n})];case 1:return e=t.sent(),r?[4,r]:[3,3];case 2:return n=t.sent(),[3,4];case 3:n=e.authToken,t.label=4;case 4:return[2,n]}})})}function PD(t){return ND(t,function(t){if(!xD(t))throw ZA.create("not-registered");return function(t){return 1===t.requestStatus&&t.requestTime+zA<Date.now()}(t.authToken)?Ea(Ea({},t),{authToken:{requestStatus:0}}):t})}function xD(t){return void 0!==t&&2===t.registrationStatus}function MD(e,n){return void 0===n&&(n=!1),Ta(this,void 0,void 0,function(){return Sa(this,function(t){switch(t.label){case 0:return[4,function(n){return Ta(this,void 0,void 0,function(){var e;return Sa(this,function(t){switch(t.label){case 0:return[4,AD(n)];case 1:return(e=t.sent().registrationPromise)?[4,e]:[3,3];case 2:t.sent(),t.label=3;case 3:return[2]}})})}(e.appConfig)];case 1:return t.sent(),[4,OD(e,n)];case 2:return[2,t.sent().token]}})})}function LD(o,a){return Ta(this,void 0,void 0,function(){var e,n,r,i;return Sa(this,function(t){switch(t.label){case 0:return e=function(t,e){var n=e.fid;return eD(t)+"/"+n}(o,a),n=oD(o,a),r={method:"DELETE",headers:n},[4,aD(function(){return fetch(e,r)})];case 1:return(i=t.sent()).ok?[3,3]:[4,rD("Delete Installation",i)];case 2:throw t.sent();case 3:return[2]}})})}function FD(t,e){var n=t.appConfig;return function(t,e){mD();var n=lD(t),r=fD.get(n);r||(r=new Set,fD.set(n,r)),r.add(e)}(n,e),function(){!function(t,e){var n=lD(t),r=fD.get(n);r&&(r.delete(e),0===r.size&&fD.delete(n),gD())}(n,e)}}function UD(t){return ZA.create("missing-app-config-values",{valueName:t})}(vD=fl).INTERNAL.registerComponent(new ps("installations",function(t){var e=t.getProvider("app").getImmediate(),n={appConfig:function(t){var e,n;if(!t||!t.options)throw UD("App Configuration");if(!t.name)throw UD("App Name");try{for(var r=Ia(["projectId","apiKey","appId"]),i=r.next();!i.done;i=r.next()){var o=i.value;if(!t.options[o])throw UD(o)}}catch(t){e={error:t}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}return{appName:t.name,projectId:t.options.projectId,apiKey:t.options.apiKey,appId:t.options.appId}}(e),platformLoggerProvider:t.getProvider("platform-logger")};return{app:e,getId:function(){return function(i){return Ta(this,void 0,void 0,function(){var e,n,r;return Sa(this,function(t){switch(t.label){case 0:return[4,AD(i.appConfig)];case 1:return e=t.sent(),n=e.installationEntry,(r=e.registrationPromise)?r.catch(console.error):OD(i).catch(console.error),[2,n.fid]}})})}(n)},getToken:function(t){return MD(n,t)},delete:function(){return function(r){return Ta(this,void 0,void 0,function(){var e,n;return Sa(this,function(t){switch(t.label){case 0:return[4,ND(e=r.appConfig,function(t){if(!t||0!==t.registrationStatus)return t})];case 1:if(!(n=t.sent()))return[3,6];if(1!==n.registrationStatus)return[3,2];throw ZA.create("delete-pending-registration");case 2:if(2!==n.registrationStatus)return[3,6];if(navigator.onLine)return[3,3];throw ZA.create("app-offline");case 3:return[4,LD(e,n)];case 4:return t.sent(),[4,CD(e)];case 5:t.sent(),t.label=6;case 6:return[2]}})})}(n)},onIdChange:function(t){return FD(n,t)}}},"PUBLIC")),vD.registerVersion("@firebase/installations","0.4.1");var VD=((bD={})["missing-app-config-values"]='Missing App configuration value: "{$valueName}"',bD["only-available-in-window"]="This method is available in a Window context.",bD["only-available-in-sw"]="This method is available in a service worker context.",bD["permission-default"]="The notification permission was not granted and dismissed instead.",bD["permission-blocked"]="The notification permission was not granted and blocked instead.",bD["unsupported-browser"]="This browser doesn't support the API's required to use the firebase SDK.",bD["failed-service-worker-registration"]="We are unable to register the default service worker. {$browserErrorMessage}",bD["token-subscribe-failed"]="A problem occured while subscribing the user to FCM: {$errorInfo}",bD["token-subscribe-no-token"]="FCM returned no token when subscribing the user to push.",bD["token-unsubscribe-failed"]="A problem occured while unsubscribing the user from FCM: {$errorInfo}",bD["token-update-failed"]="A problem occured while updating the user from FCM: {$errorInfo}",bD["token-update-no-token"]="FCM returned no token when updating the user to push.",bD["use-sw-after-get-token"]="The useServiceWorker() method may only be called once and must be called before calling getToken() to ensure your service worker is used.",bD["invalid-sw-registration"]="The input to useServiceWorker() must be a ServiceWorkerRegistration.",bD["invalid-bg-handler"]="The input to setBackgroundMessageHandler() must be a function.",bD["invalid-vapid-key"]="The public VAPID key must be a string.",bD["use-vapid-key-after-get-token"]="The usePublicVapidKey() method may only be called once and must be called before calling getToken() to ensure your VAPID key is used.",bD),qD=new Ha("messaging","Messaging",VD);function BD(t){return qD.create("missing-app-config-values",{valueName:t})}function jD(t){var e=new Uint8Array(t);return btoa(String.fromCharCode.apply(String,Na(e))).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}var WD="fcm_token_details_db",KD=5,QD="fcm_token_object_Store";function HD(s){return Ta(this,void 0,void 0,function(){var e,a,n=this;return Sa(this,function(t){switch(t.label){case 0:return"databases"in indexedDB?[4,indexedDB.databases()]:[3,2];case 1:if(e=t.sent(),!e.map(function(t){return t.name}).includes(WD))return[2,null];t.label=2;case 2:return a=null,[4,KA(WD,KD,function(o){return Ta(n,void 0,void 0,function(){var e,n,r,i;return Sa(this,function(t){switch(t.label){case 0:return o.oldVersion<2?[2]:o.objectStoreNames.contains(QD)?[4,(e=o.transaction.objectStore(QD)).index("fcmSenderId").get(s)]:[2];case 1:return n=t.sent(),[4,e.clear()];case 2:if(t.sent(),!n)return[2];if(2===o.oldVersion){if(!(r=n).auth||!r.p256dh||!r.endpoint)return[2];a={token:r.fcmToken,createTime:(i=r.createTime,null!=i?i:Date.now()),subscriptionOptions:{auth:r.auth,p256dh:r.p256dh,endpoint:r.endpoint,swScope:r.swScope,vapidKey:"string"==typeof r.vapidKey?r.vapidKey:jD(r.vapidKey)}}}else 3===o.oldVersion?a={token:(r=n).fcmToken,createTime:r.createTime,subscriptionOptions:{auth:jD(r.auth),p256dh:jD(r.p256dh),endpoint:r.endpoint,swScope:r.swScope,vapidKey:jD(r.vapidKey)}}:4===o.oldVersion&&(a={token:(r=n).fcmToken,createTime:r.createTime,subscriptionOptions:{auth:jD(r.auth),p256dh:jD(r.p256dh),endpoint:r.endpoint,swScope:r.swScope,vapidKey:jD(r.vapidKey)}});return[2]}})})})];case 3:return t.sent().close(),[4,QA(WD)];case 4:return t.sent(),[4,QA("fcm_vapid_details_db")];case 5:return t.sent(),[4,QA("undefined")];case 6:return t.sent(),[2,function(t){if(!t||!t.subscriptionOptions)return!1;var e=t.subscriptionOptions;return"number"==typeof t.createTime&&0<t.createTime&&"string"==typeof t.token&&0<t.token.length&&"string"==typeof e.auth&&0<e.auth.length&&"string"==typeof e.p256dh&&0<e.p256dh.length&&"string"==typeof e.endpoint&&0<e.endpoint.length&&"string"==typeof e.swScope&&0<e.swScope.length&&"string"==typeof e.vapidKey&&0<e.vapidKey.length}(a)?a:null]}})})}var zD="firebase-messaging-database",GD=1,YD="firebase-messaging-store",XD=null;function JD(){return XD=XD||KA(zD,GD,function(t){switch(t.oldVersion){case 0:t.createObjectStore(YD)}})}function $D(i){return Ta(this,void 0,void 0,function(){var e,n,r;return Sa(this,function(t){switch(t.label){case 0:return e=tk(i),[4,JD()];case 1:return[4,t.sent().transaction(YD).objectStore(YD).get(e)];case 2:return(n=t.sent())?[2,n]:[3,3];case 3:return[4,HD(i.appConfig.senderId)];case 4:return(r=t.sent())?[4,ZD(i,r)]:[3,6];case 5:return t.sent(),[2,r];case 6:return[2]}})})}function ZD(i,o){return Ta(this,void 0,void 0,function(){var e,n,r;return Sa(this,function(t){switch(t.label){case 0:return e=tk(i),[4,JD()];case 1:return n=t.sent(),[4,(r=n.transaction(YD,"readwrite")).objectStore(YD).put(o,e)];case 2:return t.sent(),[4,r.complete];case 3:return t.sent(),[2,o]}})})}function tk(t){return t.appConfig.appId}var ek="BDOU99-h67HcA6JeFXHbSNMu7e2yNNu3RzoMj8TM4W88jITfq7ZmPvIM1Iv-4_l2LxQcYwhqby2xGpWwzjfAnG4",nk="https://fcmregistrations.googleapis.com/v1",rk="FCM_MSG",ik="google.c.a.c_id";function ok(a,s){return Ta(this,void 0,void 0,function(){var e,n,r,i,o;return Sa(this,function(t){switch(t.label){case 0:return[4,sk(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(ak(a.appConfig)+"/"+s,n)];case 3:return[4,t.sent().json()];case 4:if((r=t.sent()).error)throw i=r.error.message,qD.create("token-unsubscribe-failed",{errorInfo:i});return[3,6];case 5:throw o=t.sent(),qD.create("token-unsubscribe-failed",{errorInfo:o});case 6:return[2]}})})}function ak(t){var e=t.projectId;return nk+"/projects/"+e+"/registrations"}function sk(t){var n=t.appConfig,r=t.installations;return Ta(this,void 0,void 0,function(){var e;return Sa(this,function(t){switch(t.label){case 0:return[4,r.getToken()];case 1:return e=t.sent(),[2,new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":n.apiKey,"x-goog-firebase-installations-auth":"FIS "+e})]}})})}function uk(t){var e=t.p256dh,n=t.auth,r=t.endpoint,i=t.vapidKey,o={web:{endpoint:r,auth:n,p256dh:e}};return i!==ek&&(o.web.applicationPubKey=i),o}var ck,hk;function lk(o,a,s){return Ta(this,void 0,void 0,function(){var e,n,r,i;return Sa(this,function(t){switch(t.label){case 0:if("granted"!==Notification.permission)throw qD.create("permission-blocked");return[4,function(n,r){return Ta(this,void 0,void 0,function(){var e;return Sa(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})]}})})}(a,s)];case 1:return e=t.sent(),[4,$D(o)];case 2:return n=t.sent(),r={vapidKey:s,swScope:a.scope,endpoint:e.endpoint,auth:jD(e.getKey("auth")),p256dh:jD(e.getKey("p256dh"))},n?[3,3]:[2,pk(o,r)];case 3:if(function(t,e){var n=e.vapidKey===t.vapidKey,r=e.endpoint===t.endpoint,i=e.auth===t.auth,o=e.p256dh===t.p256dh;return n&&r&&i&&o}(n.subscriptionOptions,r))return[3,8];t.label=4;case 4:return t.trys.push([4,6,,7]),[4,ok(o,n.token)];case 5:return t.sent(),[3,7];case 6:return i=t.sent(),console.warn(i),[3,7];case 7:return[2,pk(o,r)];case 8:return Date.now()>=n.createTime+6048e5?[2,function(i,o,a){return Ta(this,void 0,void 0,function(){var e,n,r;return Sa(this,function(t){switch(t.label){case 0:return t.trys.push([0,3,,5]),[4,function(s,u){return Ta(this,void 0,void 0,function(){var e,n,r,i,o,a;return Sa(this,function(t){switch(t.label){case 0:return[4,sk(s)];case 1:e=t.sent(),n=uk(u.subscriptionOptions),r={method:"PATCH",headers:e,body:JSON.stringify(n)},t.label=2;case 2:return t.trys.push([2,5,,6]),[4,fetch(ak(s.appConfig)+"/"+u.token,r)];case 3:return[4,t.sent().json()];case 4:return i=t.sent(),[3,6];case 5:throw o=t.sent(),qD.create("token-update-failed",{errorInfo:o});case 6:if(i.error)throw a=i.error.message,qD.create("token-update-failed",{errorInfo:a});if(!i.token)throw qD.create("token-update-no-token");return[2,i.token]}})})}(o,i)];case 1:return e=t.sent(),n=Ea({token:e,createTime:Date.now()},i),[4,ZD(o,n)];case 2:return t.sent(),[2,e];case 3:return r=t.sent(),[4,fk(o,a)];case 4:throw t.sent(),r;case 5:return[2]}})})}({token:n.token,createTime:Date.now(),subscriptionOptions:r},o,a)]:[2,n.token];case 9:return[2]}})})}function fk(r,i){return Ta(this,void 0,void 0,function(){var e,n;return Sa(this,function(t){switch(t.label){case 0:return[4,$D(r)];case 1:return(e=t.sent())?[4,ok(r,e.token)]:[3,4];case 2:return t.sent(),[4,function(i){return Ta(this,void 0,void 0,function(){var e,n,r;return Sa(this,function(t){switch(t.label){case 0:return e=tk(i),[4,JD()];case 1:return n=t.sent(),[4,(r=n.transaction(YD,"readwrite")).objectStore(YD).delete(e)];case 2:return t.sent(),[4,r.complete];case 3:return t.sent(),[2]}})})}(r)];case 3:t.sent(),t.label=4;case 4:return[4,i.pushManager.getSubscription()];case 5:return(n=t.sent())?[2,n.unsubscribe()]:[2,!0]}})})}function pk(r,i){return Ta(this,void 0,void 0,function(){var e,n;return Sa(this,function(t){switch(t.label){case 0:return[4,function(s,u){return Ta(this,void 0,void 0,function(){var e,n,r,i,o,a;return Sa(this,function(t){switch(t.label){case 0:return[4,sk(s)];case 1:e=t.sent(),n=uk(u),r={method:"POST",headers:e,body:JSON.stringify(n)},t.label=2;case 2:return t.trys.push([2,5,,6]),[4,fetch(ak(s.appConfig),r)];case 3:return[4,t.sent().json()];case 4:return i=t.sent(),[3,6];case 5:throw o=t.sent(),qD.create("token-subscribe-failed",{errorInfo:o});case 6:if(i.error)throw a=i.error.message,qD.create("token-subscribe-failed",{errorInfo:a});if(!i.token)throw qD.create("token-subscribe-no-token");return[2,i.token]}})})}(r,i)];case 1:return e=t.sent(),n={token:e,createTime:Date.now(),subscriptionOptions:i},[4,ZD(r,n)];case 2:return t.sent(),[2,n.token]}})})}function dk(t){return"object"==typeof t&&!!t&&ik in t}(hk=ck=ck||{}).PUSH_RECEIVED="push-received",hk.NOTIFICATION_CLICKED="notification-clicked";var yk=(Object.defineProperty(mk.prototype,"app",{get:function(){return this.firebaseDependencies.app},enumerable:!0,configurable:!0}),mk.prototype.getToken=function(){return Ta(this,void 0,void 0,function(){var e;return Sa(this,function(t){switch(t.label){case 0:return this.vapidKey||(this.vapidKey=ek),[4,this.getServiceWorkerRegistration()];case 1:return e=t.sent(),"default"!==Notification.permission?[3,3]:[4,Notification.requestPermission()];case 2:t.sent(),t.label=3;case 3:if("granted"!==Notification.permission)throw qD.create("permission-blocked");return[2,lk(this.firebaseDependencies,e,this.vapidKey)]}})})},mk.prototype.deleteToken=function(){return Ta(this,void 0,void 0,function(){var e;return Sa(this,function(t){switch(t.label){case 0:return[4,this.getServiceWorkerRegistration()];case 1:return e=t.sent(),[2,fk(this.firebaseDependencies,e)]}})})},mk.prototype.requestPermission=function(){return Ta(this,void 0,void 0,function(){var e;return Sa(this,function(t){switch(t.label){case 0:return"granted"===Notification.permission?[2]:[4,Notification.requestPermission()];case 1:if("granted"===(e=t.sent()))return[2];throw"denied"===e?qD.create("permission-blocked"):qD.create("permission-default")}})})},mk.prototype.usePublicVapidKey=function(t){if(null!==this.vapidKey)throw qD.create("use-vapid-key-after-get-token");if("string"!=typeof t||0===t.length)throw qD.create("invalid-vapid-key");this.vapidKey=t},mk.prototype.useServiceWorker=function(t){if(!(t instanceof ServiceWorkerRegistration))throw qD.create("invalid-sw-registration");if(this.swRegistration)throw qD.create("use-sw-after-get-token");this.swRegistration=t},mk.prototype.onMessage=function(t){var e=this;return this.onMessageCallback="function"==typeof t?t:t.next,function(){e.onMessageCallback=null}},mk.prototype.setBackgroundMessageHandler=function(){throw qD.create("only-available-in-sw")},mk.prototype.onTokenRefresh=function(){return function(){}},mk.prototype.getServiceWorkerRegistration=function(){return Ta(this,void 0,void 0,function(){var e,n;return Sa(this,function(t){switch(t.label){case 0:if(this.swRegistration)return[3,4];t.label=1;case 1:return t.trys.push([1,3,,4]),e=this,[4,navigator.serviceWorker.register("/firebase-messaging-sw.js",{scope:"/firebase-cloud-messaging-push-scope"})];case 2:return e.swRegistration=t.sent(),[3,4];case 3:throw n=t.sent(),qD.create("failed-service-worker-registration",{browserErrorMessage:n.message});case 4:return[2,this.swRegistration]}})})},mk.prototype.messageEventListener=function(o){var a;return Ta(this,void 0,void 0,function(){var e,n,r,i;return Sa(this,function(t){switch(t.label){case 0:return(null===(a=o.data)||void 0===a?void 0:a.firebaseMessaging)?(e=o.data.firebaseMessaging,n=e.type,r=e.payload,this.onMessageCallback&&n===ck.PUSH_RECEIVED&&this.onMessageCallback(r),dk(i=r.data)&&"1"===i["google.c.a.e"]?[4,this.logEvent(n,i)]:[3,2]):[2];case 1:t.sent(),t.label=2;case 2:return[2]}})})},mk.prototype.logEvent=function(n,r){return Ta(this,void 0,void 0,function(){var e;return Sa(this,function(t){switch(t.label){case 0:return e=function(t){switch(t){case ck.NOTIFICATION_CLICKED:return"notification_open";case ck.PUSH_RECEIVED:return"notification_foreground";default:throw new Error}}(n),[4,this.firebaseDependencies.analyticsProvider.get()];case 1:return t.sent().logEvent(e,{message_id:r[ik],message_name:r["google.c.a.c_l"],message_time:r["google.c.a.ts"],message_device_time:Math.floor(Date.now()/1e3)}),[2]}})})},mk);function mk(t){var e=this;this.firebaseDependencies=t,this.vapidKey=null,this.onMessageCallback=null,navigator.serviceWorker.addEventListener("message",function(t){return e.messageEventListener(t)})}var gk=(Object.defineProperty(vk.prototype,"app",{get:function(){return this.firebaseDependencies.app},enumerable:!0,configurable:!0}),vk.prototype.setBackgroundMessageHandler=function(t){if(!t||"function"!=typeof t)throw qD.create("invalid-bg-handler");this.bgMessageHandler=t},vk.prototype.getToken=function(){var n,r,i;return Ta(this,void 0,void 0,function(){var e;return Sa(this,function(t){switch(t.label){case 0:return this.vapidKey?[3,2]:[4,$D(this.firebaseDependencies)];case 1:e=t.sent(),this.vapidKey=null!=(i=null===(r=null===(n=e)||void 0===n?void 0:n.subscriptionOptions)||void 0===r?void 0:r.vapidKey)?i:ek,t.label=2;case 2:return[2,lk(this.firebaseDependencies,self.registration,this.vapidKey)]}})})},vk.prototype.deleteToken=function(){return fk(this.firebaseDependencies,self.registration)},vk.prototype.requestPermission=function(){throw qD.create("only-available-in-window")},vk.prototype.usePublicVapidKey=function(t){if(null!==this.vapidKey)throw qD.create("use-vapid-key-after-get-token");if("string"!=typeof t||0===t.length)throw qD.create("invalid-vapid-key");this.vapidKey=t},vk.prototype.useServiceWorker=function(){throw qD.create("only-available-in-window")},vk.prototype.onMessage=function(){throw qD.create("only-available-in-window")},vk.prototype.onTokenRefresh=function(){throw qD.create("only-available-in-window")},vk.prototype.onPush=function(i){return Ta(this,void 0,void 0,function(){var e,n,r;return Sa(this,function(t){switch(t.label){case 0:return(e=function(t){var e=t.data;if(!e)return null;try{return e.json()}catch(t){return null}}(i))?[4,bk()]:[2];case 1:return function(t){return t.some(function(t){return"visible"===t.visibilityState&&!t.url.startsWith("chrome-extension://")})}(n=t.sent())?[2,function(t,e){var n,r,i=wk(ck.PUSH_RECEIVED,e);try{for(var o=Ia(t),a=o.next();!a.done;a=o.next())a.value.postMessage(i)}catch(t){n={error:t}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}}(n,e)]:(r=function(t){var e;if(t&&"object"==typeof t.notification){var n=Ea({},t.notification);return n.data=Ea(Ea({},t.notification.data),((e={})[rk]=t,e)),n}}(e))?[4,function(t){var e,n=null!==(e=t.title)&&void 0!==e?e:"",r=t.actions,i=Notification.maxActions;return r&&i&&r.length>i&&console.warn("This browser only supports "+i+" actions. The remaining actions will not be displayed."),self.registration.showNotification(n,t)}(r)]:[3,3];case 2:return t.sent(),[3,5];case 3:return this.bgMessageHandler?[4,this.bgMessageHandler(e)]:[3,5];case 4:t.sent(),t.label=5;case 5:return[2]}})})},vk.prototype.onSubChange=function(n){var r,i,o;return Ta(this,void 0,void 0,function(){var e;return Sa(this,function(t){switch(t.label){case 0:return n.newSubscription?[3,2]:[4,fk(this.firebaseDependencies,self.registration)];case 1:return t.sent(),[2];case 2:return[4,$D(this.firebaseDependencies)];case 3:return e=t.sent(),[4,fk(this.firebaseDependencies,self.registration)];case 4:return t.sent(),[4,lk(this.firebaseDependencies,self.registration,(o=null===(i=null===(r=e)||void 0===r?void 0:r.subscriptionOptions)||void 0===i?void 0:i.vapidKey,null!=o?o:ek))];case 5:return t.sent(),[2]}})})},vk.prototype.onNotificationClick=function(o){var a,s;return Ta(this,void 0,void 0,function(){var e,n,r,i;return Sa(this,function(t){switch(t.label){case 0:return(e=null===(s=null===(a=o.notification)||void 0===a?void 0:a.data)||void 0===s?void 0:s[rk])?o.action?[2]:(o.stopImmediatePropagation(),o.notification.close(),(n=function(t){var e,n,r,i=null!==(n=null===(e=t.fcmOptions)||void 0===e?void 0:e.link)&&void 0!==n?n:null===(r=t.notification)||void 0===r?void 0:r.click_action;return i||(dk(t.data)?self.location.origin:null)}(e))?[4,function(u){return Ta(this,void 0,void 0,function(){var e,n,r,i,o,a,s;return Sa(this,function(t){switch(t.label){case 0:return e=new URL(u,self.location.href).href,[4,bk()];case 1:n=t.sent();try{for(r=Ia(n),i=r.next();!i.done;i=r.next())if(o=i.value,new URL(o.url,self.location.href).href===e)return[2,o]}catch(t){a={error:t}}finally{try{i&&!i.done&&(s=r.return)&&s.call(r)}finally{if(a)throw a.error}}return[2,null]}})})}(n)]:[2]):[2];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?(i=wk(ck.NOTIFICATION_CLICKED,e),[2,r.postMessage(i)]):[2]}})})},vk);function vk(t){var e=this;this.firebaseDependencies=t,this.vapidKey=null,this.bgMessageHandler=null,self.addEventListener("push",function(t){t.waitUntil(e.onPush(t))}),self.addEventListener("pushsubscriptionchange",function(t){t.waitUntil(e.onSubChange(t))}),self.addEventListener("notificationclick",function(t){t.waitUntil(e.onNotificationClick(t))})}function bk(){return self.clients.matchAll({type:"window",includeUncontrolled:!0})}function wk(t,e){return{firebaseMessaging:{type:t,payload:e}}}var _k={isSupported:Ek};function Ek(){return self&&"ServiceWorkerGlobalScope"in self?"indexedDB"in self&&null!==indexedDB&&"PushManager"in self&&"Notification"in self&&ServiceWorkerRegistration.prototype.hasOwnProperty("showNotification")&&PushSubscription.prototype.hasOwnProperty("getKey"):"indexedDB"in window&&null!==indexedDB&&navigator.cookieEnabled&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window&&"fetch"in window&&ServiceWorkerRegistration.prototype.hasOwnProperty("showNotification")&&PushSubscription.prototype.hasOwnProperty("getKey")}fl.INTERNAL.registerComponent(new ps("messaging",function(t){var e=t.getProvider("app").getImmediate(),n={app:e,appConfig:function(t){var e,n;if(!t||!t.options)throw BD("App Configuration Object");if(!t.name)throw BD("App Name");var r=t.options;try{for(var i=Ia(["projectId","apiKey","appId","messagingSenderId"]),o=i.next();!o.done;o=i.next()){var a=o.value;if(!r[a])throw BD(a)}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}return{appName:t.name,projectId:r.projectId,apiKey:r.apiKey,appId:r.appId,senderId:r.messagingSenderId}}(e),installations:t.getProvider("installations").getImmediate(),analyticsProvider:t.getProvider("analytics-internal")};if(!Ek())throw qD.create("unsupported-browser");return self&&"ServiceWorkerGlobalScope"in self?new gk(n):new yk(n)},"PUBLIC").setServiceProps(_k));var Tk="firebasestorage.googleapis.com",Sk="storageBucket",Ik=(Ck.prototype.codeProp=function(){return this.code},Ck.prototype.codeEquals=function(t){return Ak(t)===this.codeProp()},Ck.prototype.serverResponseProp=function(){return this.serverResponse_},Ck.prototype.setServerResponseProp=function(t){this.serverResponse_=t},Object.defineProperty(Ck.prototype,"name",{get:function(){return this.name_},enumerable:!0,configurable:!0}),Object.defineProperty(Ck.prototype,"code",{get:function(){return this.code_},enumerable:!0,configurable:!0}),Object.defineProperty(Ck.prototype,"message",{get:function(){return this.message_},enumerable:!0,configurable:!0}),Object.defineProperty(Ck.prototype,"serverResponse",{get:function(){return this.serverResponse_},enumerable:!0,configurable:!0}),Ck);function Ck(t,e){this.code_=Ak(t),this.message_="Firebase Storage: "+e,this.serverResponse_=null,this.name_="FirebaseError"}var Nk={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 Ak(t){return"storage/"+t}function Dk(){return new Ik(Nk.UNKNOWN,"An unknown error occurred, please check the error payload for server response.")}function kk(){return new Ik(Nk.CANCELED,"User canceled the upload/download.")}function Rk(){return new Ik(Nk.CANNOT_SLICE_BLOB,"Cannot slice blob for upload. Please retry the upload.")}function Ok(t,e,n){return new Ik(Nk.INVALID_ARGUMENT,"Invalid argument in `"+e+"` at index "+t+": "+n)}function Pk(){return new Ik(Nk.APP_DELETED,"The Firebase app was deleted.")}function xk(t,e){return new Ik(Nk.INVALID_FORMAT,"String does not match format '"+t+"': "+e)}function Mk(t){throw new Ik(Nk.INTERNAL_ERROR,"Internal error: "+t)}var Lk={RAW:"raw",BASE64:"base64",BASE64URL:"base64url",DATA_URL:"data_url"};function Fk(t){switch(t){case Lk.RAW:case Lk.BASE64:case Lk.BASE64URL:case Lk.DATA_URL:return;default:throw"Expected one of the event types: ["+Lk.RAW+", "+Lk.BASE64+", "+Lk.BASE64URL+", "+Lk.DATA_URL+"]."}}var Uk=function(t,e){this.data=t,this.contentType=e||null};function Vk(t,e){switch(t){case Lk.RAW:return new Uk(qk(e));case Lk.BASE64:case Lk.BASE64URL:return new Uk(Bk(t,e));case Lk.DATA_URL:return new Uk(function(t){var e=new jk(t);return e.base64?Bk(Lk.BASE64,e.rest):function(t){var e;try{e=decodeURIComponent(t)}catch(t){throw xk(Lk.DATA_URL,"Malformed data URL.")}return qk(e)}(e.rest)}(e),function(t){return new jk(t).contentType}(e))}throw Dk()}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 Bk(e,t){switch(e){case Lk.BASE64:var n=-1!==t.indexOf("-"),r=-1!==t.indexOf("_");if(n||r)throw xk(e,"Invalid character '"+(n?"-":"_")+"' found: is it base64url encoded?");break;case Lk.BASE64URL:var i=-1!==t.indexOf("+"),o=-1!==t.indexOf("/");if(i||o)throw xk(e,"Invalid character '"+(i?"+":"/")+"' found: is it base64 encoded?");t=t.replace(/-/g,"+").replace(/_/g,"/")}var a;try{a=atob(t)}catch(t){throw xk(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 jk=function(t){this.base64=!1,this.contentType=null;var e=t.match(/^data:([^,]+)?,/);if(null===e)throw xk(Lk.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 Wk,Kk,Qk={STATE_CHANGED:"state_changed"},Hk="running",zk="pausing",Gk="paused",Yk="success",Xk="canceling",Jk="canceled",$k="error",Zk={RUNNING:"running",PAUSED:"paused",SUCCESS:"success",CANCELED:"canceled",ERROR:"error"};function tR(t){switch(t){case Hk:case zk:case Xk:return Zk.RUNNING;case Gk:return Zk.PAUSED;case Yk:return Zk.SUCCESS;case Jk:return Zk.CANCELED;case $k:default:return Zk.ERROR}}function eR(t){return null!=t}function nR(t){return void 0!==t}function rR(t){return"function"==typeof t}function iR(t){return"object"==typeof t}function oR(t){return"string"==typeof t||t instanceof String}function aR(t){return"number"==typeof t||t instanceof Number}function sR(t){return uR()&&t instanceof Blob}function uR(){return"undefined"!=typeof Blob}(Kk=Wk=Wk||{})[Kk.NO_ERROR=0]="NO_ERROR",Kk[Kk.NETWORK_ERROR=1]="NETWORK_ERROR",Kk[Kk.ABORT=2]="ABORT";var cR=(hR.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),eR(r))for(var i in r)r.hasOwnProperty(i)&&this.xhr_.setRequestHeader(i,r[i].toString());return eR(n)?this.xhr_.send(n):this.xhr_.send(),this.sendPromise_},hR.prototype.getErrorCode=function(){if(!this.sent_)throw Mk("cannot .getErrorCode() before sending");return this.errorCode_},hR.prototype.getStatus=function(){if(!this.sent_)throw Mk("cannot .getStatus() before sending");try{return this.xhr_.status}catch(t){return-1}},hR.prototype.getResponseText=function(){if(!this.sent_)throw Mk("cannot .getResponseText() before sending");return this.xhr_.responseText},hR.prototype.abort=function(){this.xhr_.abort()},hR.prototype.getResponseHeader=function(t){return this.xhr_.getResponseHeader(t)},hR.prototype.addUploadProgressListener=function(t){eR(this.xhr_.upload)&&this.xhr_.upload.addEventListener("progress",t)},hR.prototype.removeUploadProgressListener=function(t){eR(this.xhr_.upload)&&this.xhr_.upload.removeEventListener("progress",t)},hR);function hR(){var e=this;this.sent_=!1,this.xhr_=new XMLHttpRequest,this.errorCode_=Wk.NO_ERROR,this.sendPromise_=new Promise(function(t){e.xhr_.addEventListener("abort",function(){e.errorCode_=Wk.ABORT,t(e)}),e.xhr_.addEventListener("error",function(){e.errorCode_=Wk.NETWORK_ERROR,t(e)}),e.xhr_.addEventListener("load",function(){t(e)})})}var lR=(fR.prototype.createXhrIo=function(){return new cR},fR);function fR(){}function pR(){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(uR())return new Blob(t);throw Error("This browser doesn't seem to support creating Blobs")}var dR=(yR.prototype.size=function(){return this.size_},yR.prototype.type=function(){return this.type_},yR.prototype.slice=function(t,e){if(sR(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 yR(n)}return new yR(new Uint8Array(this.data_.buffer,t,e-t),!0)},yR.getBlob=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(uR()){var n=t.map(function(t){return t instanceof yR?t.data_:t});return new yR(pR.apply(null,n))}var r=t.map(function(t){return oR(t)?Vk(Lk.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 yR(o,!0)},yR.prototype.uploadData=function(){return this.data_},yR);function yR(t,e){var n=0,r="";sR(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 mR=(Object.defineProperty(gR.prototype,"path",{get:function(){return this.path_},enumerable:!0,configurable:!0}),Object.defineProperty(gR.prototype,"isRoot",{get:function(){return 0===this.path.length},enumerable:!0,configurable:!0}),gR.prototype.fullServerUrl=function(){var t=encodeURIComponent;return"/b/"+t(this.bucket)+"/o/"+t(this.path)},gR.prototype.bucketOnlyServerUrl=function(){return"/b/"+encodeURIComponent(this.bucket)+"/o"},gR.makeFromBucketSpec=function(e){var t;try{t=gR.makeFromUrl(e)}catch(t){return new gR(e,"")}if(""===t.path)return t;throw function(t){return new Ik(Nk.INVALID_DEFAULT_BUCKET,"Invalid default bucket '"+t+"'.")}(e)},gR.makeFromUrl=function(t){for(var e=null,n="([A-Za-z0-9.\\-_]+)",r=new RegExp("^gs://"+n+"(/(.*))?$","i"),i=Tk.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 gR(c,h=h||""),s.postModify(e);break}}if(null==e)throw function(t){return new Ik(Nk.INVALID_URL,"Invalid URL '"+t+"'.")}(t);return e},gR);function gR(t,e){this.bucket=t,this.path_=e}function vR(t){var e;try{e=JSON.parse(t)}catch(t){return null}return function(t){return iR(t)&&!Array.isArray(t)}(e)?e:null}function bR(t){var e=t.lastIndexOf("/",t.length-2);return-1===e?t:t.slice(e+1)}function wR(t){return"https://"+Tk+"/v0"+t}function _R(t){var e=encodeURIComponent,n="?";for(var r in t){if(t.hasOwnProperty(r))n=n+(e(r)+"="+e(t[r]))+"&"}return n=n.slice(0,-1)}function ER(t,e){return e}var TR=function(t,e,n,r){this.server=t,this.local=e||t,this.writable=!!n,this.xform=r||ER},SR=null;function IR(){if(SR)return SR;var t=[];t.push(new TR("bucket")),t.push(new TR("generation")),t.push(new TR("metageneration")),t.push(new TR("name","fullPath",!0));var e=new TR("name");e.xform=function(t,e){return function(t){return!oR(t)||t.length<2?t:bR(t)}(e)},t.push(e);var n=new TR("size");return n.xform=function(t,e){return eR(e)?Number(e):e},t.push(n),t.push(new TR("timeCreated")),t.push(new TR("updated")),t.push(new TR("md5Hash",null,!0)),t.push(new TR("cacheControl",null,!0)),t.push(new TR("contentDisposition",null,!0)),t.push(new TR("contentEncoding",null,!0)),t.push(new TR("contentLanguage",null,!0)),t.push(new TR("contentType",null,!0)),t.push(new TR("metadata","customMetadata",!0)),SR=t}function CR(r,i){Object.defineProperty(r,"ref",{get:function(){var t=r.bucket,e=r.fullPath,n=new mR(t,e);return i.makeStorageReference(n)}})}function NR(t,e,n){var r=vR(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 CR(r,t),r}(t,r,n)}function AR(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 DR(t){if(!iR(t)||!t)throw"Expected Metadata object.";for(var e in t)if(t.hasOwnProperty(e)){var n=t[e];if("customMetadata"===e){if(!iR(n))throw"Expected object for 'customMetadata' mapping."}else if(iR(r=n)&&null!==r)throw"Mapping for '"+e+"' cannot be an object."}var r}var kR="maxResults",RR=1e3,OR="pageToken",PR="prefixes",xR="items";function MR(t,e){var n={prefixes:[],items:[],nextPageToken:e.nextPageToken},r=t.bucket();if(null===r)throw new Ik(Nk.NO_DEFAULT_BUCKET,"No default bucket found. Did you set the '"+Sk+"' property when initializing the app?");if(e[PR])for(var i=0,o=e[PR];i<o.length;i++){var a=o[i].replace(/\/$/,""),s=t.makeStorageReference(new mR(r,a));n.prefixes.push(s)}if(e[xR])for(var u=0,c=e[xR];u<c.length;u++){var h=c[u];s=t.makeStorageReference(new mR(r,h.name));n.items.push(s)}return n}function LR(t){if(!iR(t)||!t)throw"Expected ListOptions object.";for(var e in t)if(e===kR){if(!aR(n=t[kR])||!Number.isInteger(n)||t[kR]<=0)throw"Expected maxResults to be a positive number.";if(1e3<t[kR])throw"Expected maxResults to be less than or equal to "+RR+"."}else{if(e!==OR)throw"Unknown option: "+e;if(t[OR]&&!oR(t[OR]))throw"Expected pageToken to be string."}var n}var FR=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 UR(t){if(!t)throw Dk()}function VR(r,i){return function(t,e){var n=NR(r,e,i);return UR(null!==n),n}}function qR(r){return function(t,e){var n=function(t,e){var n=vR(e);return null===n?null:MR(t,n)}(r,e);return UR(null!==n),n}}function BR(r,i){return function(t,e){var n=NR(r,e,i);return UR(null!==n),function(r,t){var e=vR(t);if(null===e)return null;if(!oR(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 wR("/b/"+i(e)+"/o/"+i(n))+_R({alt:"media",token:t})})[0]}(n,e)}}function jR(r){return function(t,e){var n;return(n=401===t.getStatus()?new Ik(Nk.UNAUTHENTICATED,"User is not authenticated, please authenticate using Firebase Authentication and try again."):402===t.getStatus()?function(t){return new Ik(Nk.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 Ik(Nk.UNAUTHORIZED,"User does not have permission to access '"+t+"'.")}(r.path):e).setServerResponseProp(e.serverResponseProp()),n}}function WR(r){var i=jR(r);return function(t,e){var n=i(t,e);return 404===t.getStatus()&&(n=function(t){return new Ik(Nk.OBJECT_NOT_FOUND,"Object '"+t+"' does not exist.")}(r.path)),n.setServerResponseProp(e.serverResponseProp()),n}}function KR(t,e,n){var r=wR(e.fullServerUrl()),i=t.maxOperationRetryTime(),o=new FR(r,"GET",VR(t,n),i);return o.errorHandler=WR(e),o}function QR(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 HR(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=QR(e,r,i),c="--"+s+"\r\nContent-Type: application/json; charset=utf-8\r\n\r\n"+AR(u,n)+"\r\n--"+s+"\r\nContent-Type: "+u.contentType+"\r\n\r\n",h="\r\n--"+s+"--",l=dR.getBlob(c,r,h);if(null===l)throw Rk();var f={name:u.fullPath},p=wR(o),d=t.maxUploadRetryTime(),y=new FR(p,"POST",VR(t,n),d);return y.urlParams=f,y.headers=a,y.body=l.uploadData(),y.errorHandler=jR(e),y}var zR=function(t,e,n,r){this.current=t,this.total=e,this.finalized=!!n,this.metadata=r||null};function GR(t,e){var n=null;try{n=t.getResponseHeader("X-Goog-Upload-Status")}catch(t){UR(!1)}return UR(!!n&&-1!==(e||["active"]).indexOf(n)),n}function YR(t,e,n,r,i){var o=e.bucketOnlyServerUrl(),a=QR(e,r,i),s={name:a.fullPath},u=wR(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=AR(a,n),l=t.maxUploadRetryTime();var f=new FR(u,"POST",function(t){var e;GR(t);try{e=t.getResponseHeader("X-Goog-Upload-URL")}catch(t){UR(!1)}return UR(oR(e)),e},l);return f.urlParams=s,f.headers=c,f.body=h,f.errorHandler=jR(e),f}function XR(t,e,n,i){var r=t.maxUploadRetryTime(),o=new FR(n,"POST",function(t){var e=GR(t,["active","final"]),n=null;try{n=t.getResponseHeader("X-Goog-Upload-Size-Received")}catch(t){UR(!1)}n||UR(!1);var r=Number(n);return UR(!isNaN(r)),new zR(r,i.size(),"final"===e)},r);return o.headers={"X-Goog-Upload-Command":"query"},o.errorHandler=jR(e),o}function JR(t,a,e,s,n,u,r,i){var c=new zR(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 Ik(Nk.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 Rk();var y=a.maxUploadRetryTime(),m=new FR(e,"POST",function(t,e){var n,r=GR(t,["active","final"]),i=c.current+h,o=s.size();return n="final"===r?VR(a,u)(t,e):null,new zR(i,o,"final"===r,n)},y);return m.headers=p,m.body=d.uploadData(),m.progressCallback=i||null,m.errorHandler=jR(t),m}var $R=function(t,e,n){if(rR(t)||eR(e)||eR(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}},ZR=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 tO(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 Ik(Nk.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?Ok(o,e,t.message):Ok(o,e,t)}}var eO=function(e,t){var n=this;this.validator=function(t){n.optional&&!nR(t)||e(t)},this.optional=!!t};function nO(t,e){function n(t){if(!oR(t))throw"Expected string."}var r;return r=t?function(e,n){return function(t){e(t),n(t)}}(n,t):n,new eO(r,e)}function rO(){return new eO(function(t){if(!(t instanceof Uint8Array||t instanceof ArrayBuffer||uR()&&t instanceof Blob))throw"Expected Blob or File."})}function iO(t){return new eO(DR,t)}function oO(){return new eO(function(t){if(!(aR(t)&&0<=t))throw"Expected a number 0 or greater."})}function aO(e,t){return new eO(function(t){if(!(null===t||eR(t)&&t instanceof Object))throw"Expected an Object.";null!=e&&e(t)},t)}function sO(t){return new eO(function(t){if(!(null===t||rR(t)))throw"Expected a Function."},t)}function uO(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 cO=(hO.prototype.makeProgressCallback_=function(){var e=this,n=this.transferred_;return function(t){return e.updateProgress_(n+t)}},hO.prototype.shouldDoResumable_=function(t){return 262144<t.size()},hO.prototype.start_=function(){this.state_===Hk&&null===this.request_&&(this.resumable_?null===this.uploadUrl_?this.createResumable_():this.needToFetchStatus_?this.fetchStatus_():this.needToFetchMetadata_?this.fetchMetadata_():this.continueUpload_():this.oneShotUpload_())},hO.prototype.resolveToken_=function(e){var n=this;this.authWrapper_.getAuthToken().then(function(t){switch(n.state_){case Hk:e(t);break;case Xk:n.transition_(Jk);break;case zk:n.transition_(Gk)}})},hO.prototype.createResumable_=function(){var r=this;this.resolveToken_(function(t){var e=YR(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_)})},hO.prototype.fetchStatus_=function(){var r=this,i=this.uploadUrl_;this.resolveToken_(function(t){var e=XR(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_)})},hO.prototype.continueUpload_=function(){var r=this,i=262144*this.chunkMultiplier_,o=new zR(this.transferred_,this.blob_.size()),a=this.uploadUrl_;this.resolveToken_(function(t){var e;try{e=JR(r.location_,r.authWrapper_,a,r.blob_,i,r.mappings_,o,r.makeProgressCallback_())}catch(t){return r.error_=t,void r.transition_($k)}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_(Yk)):r.completeTransitions_()},r.errorHandler_)})},hO.prototype.increaseMultiplier_=function(){262144*this.chunkMultiplier_<33554432&&(this.chunkMultiplier_*=2)},hO.prototype.fetchMetadata_=function(){var r=this;this.resolveToken_(function(t){var e=KR(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_(Yk)},r.metadataErrorHandler_)})},hO.prototype.oneShotUpload_=function(){var r=this;this.resolveToken_(function(t){var e=HR(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_(Yk)},r.errorHandler_)})},hO.prototype.updateProgress_=function(t){var e=this.transferred_;this.transferred_=t,this.transferred_!==e&&this.notifyObservers_()},hO.prototype.transition_=function(t){if(this.state_!==t)switch(t){case Xk:case zk:this.state_=t,null!==this.request_&&this.request_.cancel();break;case Hk:var e=this.state_===Gk;this.state_=t,e&&(this.notifyObservers_(),this.start_());break;case Gk:this.state_=t,this.notifyObservers_();break;case Jk:this.error_=kk(),this.state_=t,this.notifyObservers_();break;case $k:case Yk:this.state_=t,this.notifyObservers_()}},hO.prototype.completeTransitions_=function(){switch(this.state_){case zk:this.transition_(Gk);break;case Xk:this.transition_(Jk);break;case Hk:this.start_()}},Object.defineProperty(hO.prototype,"snapshot",{get:function(){var t=tR(this.state_);return new ZR(this.transferred_,this.blob_.size(),t,this.metadata_,this,this.ref_)},enumerable:!0,configurable:!0}),hO.prototype.on=function(t,e,n,o){var r="Expected a function or an Object with one of `next`, `error`, `complete` properties.",i=sO(!0).validator,a=aO(null,!0).validator;function s(t){try{return void i(t)}catch(t){}try{if(a(t),!(nR(t.next)||nR(t.error)||nR(t.complete)))throw"";return}catch(t){throw r}}tO("on",[nO(function(){if(t!==Qk.STATE_CHANGED)throw"Expected one of the event types: ["+Qk.STATE_CHANGED+"]."}),aO(s,!0),sO(!0),sO(!0)],arguments);var u=this;function c(i){return function(t,e,n){null!==i&&tO("on",i,arguments);var r=new $R(t,e,o);return u.addObserver_(r),function(){u.removeObserver_(r)}}}var h=[aO(function(t){if(null===t)throw r;s(t)}),sO(!0),sO(!0)];return nR(e)||nR(n)||nR(o)?c(null)(e,n,o):c(h)},hO.prototype.then=function(t,e){return this.promise_.then(t,e)},hO.prototype.catch=function(t){return this.then(null,t)},hO.prototype.addObserver_=function(t){this.observers_.push(t),this.notifyObserver_(t)},hO.prototype.removeObserver_=function(t){var e=this.observers_.indexOf(t);-1!==e&&this.observers_.splice(e,1)},hO.prototype.notifyObservers_=function(){var e=this;this.finishPromise_(),this.observers_.slice().forEach(function(t){e.notifyObserver_(t)})},hO.prototype.finishPromise_=function(){if(null!==this.resolve_){var t=!0;switch(tR(this.state_)){case Zk.SUCCESS:uO(this.resolve_.bind(null,this.snapshot))();break;case Zk.CANCELED:case Zk.ERROR:uO(this.reject_.bind(null,this.error_))();break;default:t=!1}t&&(this.resolve_=null,this.reject_=null)}},hO.prototype.notifyObserver_=function(t){switch(tR(this.state_)){case Zk.RUNNING:case Zk.PAUSED:t.next&&uO(t.next.bind(t,this.snapshot))();break;case Zk.SUCCESS:t.complete&&uO(t.complete.bind(t))();break;case Zk.CANCELED:case Zk.ERROR:t.error&&uO(t.error.bind(t,this.error_))();break;default:t.error&&uO(t.error.bind(t,this.error_))()}},hO.prototype.resume=function(){tO("resume",[],arguments);var t=this.state_===Gk||this.state_===zk;return t&&this.transition_(Hk),t},hO.prototype.pause=function(){tO("pause",[],arguments);var t=this.state_===Hk;return t&&this.transition_(zk),t},hO.prototype.cancel=function(){tO("cancel",[],arguments);var t=this.state_===Hk||this.state_===zk;return t&&this.transition_(Xk),t},hO);function hO(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_=Hk,this.errorHandler_=function(t){a.request_=null,a.chunkMultiplier_=1,t.codeEquals(Nk.CANCELED)?(a.needToFetchStatus_=!0,a.completeTransitions_()):(a.error_=t,a.transition_($k))},this.metadataErrorHandler_=function(t){a.request_=null,t.codeEquals(Nk.CANCELED)?a.completeTransitions_():(a.error_=t,a.transition_($k))},this.promise_=new Promise(function(t,e){a.resolve_=t,a.reject_=e,a.start_()}),this.promise_.then(null,function(){})}var lO=(fO.prototype.toString=function(){return tO("toString",[],arguments),"gs://"+this.location.bucket+"/"+this.location.path},fO.prototype.newRef=function(t,e){return new fO(t,e)},fO.prototype.mappings=function(){return IR()},fO.prototype.child=function(t){tO("child",[nO()],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 mR(this.location.bucket,e);return this.newRef(this.authWrapper,n)},Object.defineProperty(fO.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 mR(this.location.bucket,t);return this.newRef(this.authWrapper,e)},enumerable:!0,configurable:!0}),Object.defineProperty(fO.prototype,"root",{get:function(){var t=new mR(this.location.bucket,"");return this.newRef(this.authWrapper,t)},enumerable:!0,configurable:!0}),Object.defineProperty(fO.prototype,"bucket",{get:function(){return this.location.bucket},enumerable:!0,configurable:!0}),Object.defineProperty(fO.prototype,"fullPath",{get:function(){return this.location.path},enumerable:!0,configurable:!0}),Object.defineProperty(fO.prototype,"name",{get:function(){return bR(this.location.path)},enumerable:!0,configurable:!0}),Object.defineProperty(fO.prototype,"storage",{get:function(){return this.authWrapper.service()},enumerable:!0,configurable:!0}),fO.prototype.put=function(t,e){return void 0===e&&(e=null),tO("put",[rO(),iO(!0)],arguments),this.throwIfRoot_("put"),new cO(this,this.authWrapper,this.location,this.mappings(),new dR(t),e)},fO.prototype.putString=function(t,e,n){void 0===e&&(e=Lk.RAW),tO("putString",[nO(),nO(Fk,!0),iO(!0)],arguments),this.throwIfRoot_("putString");var r=Vk(e,t),i=Object.assign({},n);return!eR(i.contentType)&&eR(r.contentType)&&(i.contentType=r.contentType),new cO(this,this.authWrapper,this.location,this.mappings(),new dR(r.data,!0),i)},fO.prototype.delete=function(){var n=this;return tO("delete",[],arguments),this.throwIfRoot_("delete"),this.authWrapper.getAuthToken().then(function(t){var e=function(t,e){var n=wR(e.fullServerUrl()),r=t.maxOperationRetryTime(),i=new FR(n,"DELETE",function(t,e){},r);return i.successCodes=[200,204],i.errorHandler=WR(e),i}(n.authWrapper,n.location);return n.authWrapper.makeRequest(e,t).getPromise()})},fO.prototype.listAll=function(){tO("listAll",[],arguments);var t={prefixes:[],items:[]};return this.listAllHelper(t).then(function(){return t})},fO.prototype.listAllHelper=function(o,a){return Ta(this,void 0,void 0,function(){var e,n,r,i;return Sa(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]}})})},fO.prototype.list=function(r){tO("list",[function(t){return new eO(LR,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=wR(e.bucketOnlyServerUrl()),s=t.maxOperationRetryTime(),u=new FR(a,"GET",qR(t),s);return u.urlParams=o,u.errorHandler=jR(e),u}(i.authWrapper,i.location,"/",e.pageToken,e.maxResults);return i.authWrapper.makeRequest(n,t).getPromise()})},fO.prototype.getMetadata=function(){var n=this;return tO("getMetadata",[],arguments),this.throwIfRoot_("getMetadata"),this.authWrapper.getAuthToken().then(function(t){var e=KR(n.authWrapper,n.location,n.mappings());return n.authWrapper.makeRequest(e,t).getPromise()})},fO.prototype.updateMetadata=function(n){var r=this;return tO("updateMetadata",[iO()],arguments),this.throwIfRoot_("updateMetadata"),this.authWrapper.getAuthToken().then(function(t){var e=function(t,e,n,r){var i=wR(e.fullServerUrl()),o=AR(n,r),a=t.maxOperationRetryTime(),s=new FR(i,"PATCH",VR(t,r),a);return s.headers={"Content-Type":"application/json; charset=utf-8"},s.body=o,s.errorHandler=WR(e),s}(r.authWrapper,r.location,n,r.mappings());return r.authWrapper.makeRequest(e,t).getPromise()})},fO.prototype.getDownloadURL=function(){var n=this;return tO("getDownloadURL",[],arguments),this.throwIfRoot_("getDownloadURL"),this.authWrapper.getAuthToken().then(function(t){var e=function(t,e,n){var r=wR(e.fullServerUrl()),i=t.maxOperationRetryTime(),o=new FR(r,"GET",BR(t,n),i);return o.errorHandler=WR(e),o}(n.authWrapper,n.location,n.mappings());return n.authWrapper.makeRequest(e,t).getPromise().then(function(t){if(null===t)throw new Ik(Nk.NO_DOWNLOAD_URL,"The given file does not have any download URLs.");return t})})},fO.prototype.throwIfRoot_=function(t){if(""===this.location.path)throw function(t){return new Ik(Nk.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)},fO);function fO(t,e){this.authWrapper=t,this.location=e instanceof mR?e:mR.makeFromUrl(e)}var pO=(dO.prototype.getPromise=function(){return this.promise_},dO.prototype.cancel=function(t){},dO);function dO(t){this.promise_=Promise.reject(t)}var yO=(mO.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)})},mO.prototype.clear=function(){this.map.forEach(function(t){t&&t.cancel(!0)}),this.map.clear()},mO);function mO(){this.map=new Map,this.id=-9007199254740991}var gO=(vO.extractBucket_=function(t){var e=t[Sk]||null;return null==e?null:mR.makeFromBucketSpec(e).bucket},vO.prototype.getAuthToken=function(){var t=this.authProvider_.getImmediate({optional:!0});return t?t.getToken().then(function(t){return null!==t?t.accessToken:null},function(){return null}):Promise.resolve(null)},vO.prototype.bucket=function(){if(this.deleted_)throw Pk();return this.bucket_},vO.prototype.service=function(){return this.service_},vO.prototype.makeStorageReference=function(t){return this.storageRefMaker_(this,t)},vO.prototype.makeRequest=function(t,e){if(this.deleted_)return new pO(Pk());var n=this.requestMaker_(t,e,this.pool_);return this.requestMap_.addRequest(n),n},vO.prototype.deleteApp=function(){this.deleted_=!0,this.app_=null,this.requestMap_.clear()},vO.prototype.maxUploadRetryTime=function(){return this.maxUploadRetryTime_},vO.prototype.setMaxUploadRetryTime=function(t){this.maxUploadRetryTime_=t},vO.prototype.maxOperationRetryTime=function(){return this.maxOperationRetryTime_},vO.prototype.setMaxOperationRetryTime=function(t){this.maxOperationRetryTime_=t},vO);function vO(t,e,n,r,i,o){if(this.bucket_=null,this.deleted_=!1,this.app_=t,null!==this.app_){var a=this.app_.options;eR(a)&&(this.bucket_=vO.extractBucket_(a))}this.authProvider_=e,this.storageRefMaker_=n,this.requestMaker_=r,this.pool_=o,this.service_=i,this.maxOperationRetryTime_=12e4,this.maxUploadRetryTime_=6e5,this.requestMap_=new yO}var bO=(wO.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());nR(a)?r(a):r()}catch(t){i(t)}else null!==o?((n=Dk()).setServerResponseProp(o.getResponseText()),s.errorCallback_?i(s.errorCallback_(o,n)):i(n)):e.canceled?i(n=s.appDelete_?Pk():kk()):i(n=new Ik(Nk.RETRY_LIMIT_EXCEEDED,"Max retry time for operation exceeded, please try again."))}this.canceled_?t(0,new _O(!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 _O(!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()===Wk.NO_ERROR,n=t.getStatus();if(e&&!s.isRetryStatusCode_(n)){var r=-1!==s.successCodes_.indexOf(n);o(!0,new _O(r,t))}else{var i=t.getErrorCode()===Wk.ABORT;o(!1,new _O(!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_)},wO.prototype.getPromise=function(){return this.promise_},wO.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()},wO.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},wO);function wO(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 _O=function(t,e,n){this.wasSuccessCode=t,this.xhr=e,this.canceled=!!n};function EO(t,e,n){var r=_R(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 bO(i,t.method,o,t.body,t.successCodes,t.additionalRetryCodes,t.handler,t.errorHandler,t.timeout,t.progressCallback,n)}var TO=(SO.prototype.ref=function(t){if(tO("ref",[nO(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 lO(this.authWrapper_,this.bucket_);return null!=t?e.child(t):e},SO.prototype.refFromURL=function(t){return tO("refFromURL",[nO(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{mR.makeFromUrl(t)}catch(t){throw"Expected valid full URL but got an invalid one."}},!1)],arguments),new lO(this.authWrapper_,t)},Object.defineProperty(SO.prototype,"maxUploadRetryTime",{get:function(){return this.authWrapper_.maxUploadRetryTime()},enumerable:!0,configurable:!0}),SO.prototype.setMaxUploadRetryTime=function(t){tO("setMaxUploadRetryTime",[oO()],arguments),this.authWrapper_.setMaxUploadRetryTime(t)},SO.prototype.setMaxOperationRetryTime=function(t){tO("setMaxOperationRetryTime",[oO()],arguments),this.authWrapper_.setMaxOperationRetryTime(t)},Object.defineProperty(SO.prototype,"app",{get:function(){return this.app_},enumerable:!0,configurable:!0}),Object.defineProperty(SO.prototype,"INTERNAL",{get:function(){return this.internals_},enumerable:!0,configurable:!0}),SO);function SO(t,e,n,r){if(this.bucket_=null,this.authWrapper_=new gO(t,e,function(t,e){return new lO(t,e)},EO,this,n),this.app_=t,null!=r)this.bucket_=mR.makeFromBucketSpec(r);else{var i=this.authWrapper_.bucket();null!=i&&(this.bucket_=new mR(i,""))}this.internals_=new IO(this)}var IO=(CO.prototype.delete=function(){return this.service_.authWrapper_.deleteApp(),Promise.resolve()},CO);function CO(t){this.service_=t}var NO,AO;function DO(t,e){var n=t.getProvider("app").getImmediate(),r=t.getProvider("auth-internal");return new TO(n,r,new lR,e)}AO={TaskState:Zk,TaskEvent:Qk,StringFormat:Lk,Storage:TO,Reference:lO},(NO=fl).INTERNAL.registerComponent(new ps("storage",DO,"PUBLIC").setServiceProps(AO).setMultipleInstances(!0)),NO.registerVersion("@firebase/storage","0.3.25");var kO,RO,OO,PO,xO="0.2.31",MO="FB-PERF-TRACE-MEASURE",LO="@firebase/performance/config",FO="@firebase/performance/configexpire",UO="Performance",VO=((kO={})["trace started"]="Trace {$traceName} was started before.",kO["trace stopped"]="Trace {$traceName} is not running.",kO["no window"]="Window is not available.",kO["no app id"]="App id is not available.",kO["no project id"]="Project id is not available.",kO["no api key"]="Api key is not available.",kO["invalid cc log"]="Attempted to queue invalid cc event",kO["FB not default"]="Performance can only start when Firebase app instance is the default one.",kO["RC response not ok"]="RC response is not ok",kO["invalid attribute name"]="Attribute name {$attributeName} is invalid.",kO["invalid attribute value"]="Attribute value {$attributeValue} is invalid.",kO["invalide custom metric name"]="Custom metric name {$customMetricName} is invalid",kO),qO=new Ha("performance",UO,VO),BO=(jO.prototype.getUrl=function(){return this.windowLocation.href.split("?")[0]},jO.prototype.mark=function(t){this.performance&&this.performance.mark&&this.performance.mark(t)},jO.prototype.measure=function(t,e,n){this.performance&&this.performance.measure&&this.performance.measure(t,e,n)},jO.prototype.getEntriesByType=function(t){return this.performance&&this.performance.getEntriesByType?this.performance.getEntriesByType(t):[]},jO.prototype.getEntriesByName=function(t){return this.performance&&this.performance.getEntriesByName?this.performance.getEntriesByName(t):[]},jO.prototype.getTimeOrigin=function(){return this.performance&&(this.performance.timeOrigin||this.performance.timing.navigationStart)},jO.prototype.requiredApisAvailable=function(){return!!(fetch&&Promise&&this.navigator&&this.navigator.cookieEnabled)},jO.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]})},jO.getInstance=function(){return void 0===RO&&(RO=new jO(OO)),RO},jO);function jO(t){if(!(this.window=t))throw qO.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 WO,KO,QO,HO=(zO.prototype.getAppId=function(){var t=this.firebaseAppInstance&&this.firebaseAppInstance.options&&this.firebaseAppInstance.options.appId;if(!t)throw qO.create("no app id");return t},zO.prototype.getProjectId=function(){var t=this.firebaseAppInstance&&this.firebaseAppInstance.options&&this.firebaseAppInstance.options.projectId;if(!t)throw qO.create("no project id");return t},zO.prototype.getApiKey=function(){var t=this.firebaseAppInstance&&this.firebaseAppInstance.options&&this.firebaseAppInstance.options.apiKey;if(!t)throw qO.create("no api key");return t},zO.getInstance=function(){return void 0===PO&&(PO=new zO),PO},zO);function zO(){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 GO(){return WO}(QO=KO=KO||{})[QO.UNKNOWN=0]="UNKNOWN",QO[QO.VISIBLE=1]="VISIBLE",QO[QO.HIDDEN=2]="HIDDEN";var YO=["firebase_","google_","ga_"],XO=new RegExp("^[a-zA-Z]\\w*$");function JO(){switch(BO.getInstance().document.visibilityState){case"visible":return KO.VISIBLE;case"hidden":return KO.HIDDEN;default:return KO.UNKNOWN}}var $O=new Cs(UO);$O.logLevel=vs.INFO;var ZO="0.0.1",tP={loggingEnabled:!0},eP="FIREBASE_INSTALLATIONS_AUTH";function nP(t){var e=function(){var t=BO.getInstance().localStorage;if(!t)return;var e=t.getItem(FO);if(!e||!function(t){return Number(t)>Date.now()}(e))return;var n=t.getItem(LO);if(!n)return;try{return JSON.parse(n)}catch(t){return}}();return e?(iP(e),Promise.resolve()):function(r){return function(){var t=HO.getInstance().installationsService.getToken();return t.then(function(t){}),t}().then(function(t){var e="https://firebaseremoteconfig.googleapis.com/v1/projects/"+HO.getInstance().getProjectId()+"/namespaces/fireperf:fetch?key="+HO.getInstance().getApiKey(),n=new Request(e,{method:"POST",headers:{Authorization:eP+" "+t},body:JSON.stringify({app_instance_id:r,app_instance_id_token:t,app_id:HO.getInstance().getAppId(),app_version:xO,sdk_version:ZO})});return fetch(n).then(function(t){if(t.ok)return t.json();throw qO.create("RC response not ok")})}).catch(function(){$O.info(rP)})}(t).then(function(t){return iP(t)}).then(function(t){return function(t){var e=BO.getInstance().localStorage;if(!t||!e)return;e.setItem(LO,JSON.stringify(t)),e.setItem(FO,String(Date.now()+60*HO.getInstance().configTimeToLive*60*1e3))}(t)},function(){})}var rP="Could not fetch config, will use default configs";function iP(t){if(!t)return t;var e=HO.getInstance(),n=t.entries||{};return void 0!==n.fpr_enabled?e.loggingEnabled="true"===String(n.fpr_enabled):e.loggingEnabled=tP.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=oP(e.tracesSamplingRate),e.logNetworkAfterSampling=oP(e.networkRequestsSamplingRate),t}function oP(t){return Math.random()<=t}var aP,sP=1;function uP(){return sP=2,aP=aP||function(){var n=BO.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=HO.getInstance().installationsService.getId();return t.then(function(t){WO=t}),t}()}).then(function(t){return nP(t)}).then(function(){return cP()},function(){return cP()})}function cP(){sP=3}var hP,lP=1e4,fP=5500,pP=3,dP=pP,yP=[],mP=!1;function gP(){mP||(!function r(t){setTimeout(function(){if(0!==dP){if(!yP.length)return r(lP);var t=Aa(yP);yP=[];var e=t.map(function(t){return{source_extension_json_proto3: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:HO.getInstance().logSource,log_event:e};fetch(HO.getInstance().logEndPointUrl,{method:"POST",body:JSON.stringify(n)}).then(function(t){return t.ok||$O.info("Call to Firebase backend failed."),t.json()}).then(function(t){var e=Number(t.next_request_wait_millis),n=isNaN(e)?lP:Math.max(lP,e);dP=pP,r(n)}).catch(function(){yP=Aa(t,yP),dP--,$O.info("Tries left: "+dP+"."),r(lP)})}},t)}(fP),mP=!0)}function vP(n){return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];!function(t){if(!t.eventTime||!t.message)throw qO.create("invalid cc log");yP=Aa(yP,[t])}({message:n.apply(void 0,t),eventTime:Date.now()})}}function bP(t,e){(hP=hP||vP(EP))(t,e)}function wP(t){var e=HO.getInstance();!e.instrumentationEnabled&&t.isAuto||(e.dataCollectionEnabled||t.isAuto)&&BO.getInstance().requiredApisAvailable()&&(t.isAuto&&JO()!==KO.VISIBLE||e.loggingEnabled&&e.logTraceAfterSampling&&(3===sP?_P(t):uP().then(function(){return _P(t)},function(){return _P(t)})))}function _P(t){GO()&&setTimeout(function(){return bP(t,1)},0)}function EP(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:TP(),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=t.counters);var n=t.getAttributes();0!==Object.keys(n).length&&(e.custom_attributes=n);var r={application_info:TP(),trace_metric:e};return JSON.stringify(r)}(t)}function TP(){return{google_app_id:HO.getInstance().getAppId(),app_instance_id:GO(),web_app_info:{sdk_version:xO,page_url:BO.getInstance().getUrl(),service_worker_status:function(){var t=BO.getInstance().navigator;return"serviceWorker"in t?t.serviceWorker.controller?2:3:1}(),visibility_state:JO(),effective_connection_type:function(){var t=BO.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}}var SP=["_fp","_fcp","_fid"];var IP=(CP.prototype.start=function(){if(1!==this.state)throw qO.create("trace started",{traceName:this.name});this.api.mark(this.traceStartMark),this.state=2},CP.prototype.stop=function(){if(2!==this.state)throw qO.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(),wP(this)},CP.prototype.record=function(t,e,n){if(this.durationUs=Math.floor(1e3*e),this.startTimeUs=Math.floor(1e3*t),n&&n.attributes&&(this.customAttributes=Ea({},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])))}wP(this)},CP.prototype.incrementMetric=function(t,e){void 0===e&&(e=1),void 0===this.counters[t]&&this.putMetric(t,0),this.counters[t]+=e},CP.prototype.putMetric=function(t,e){if(!function(t,e){return!(0===t.length||100<t.length)&&(e&&e.startsWith("_wt_")&&-1<SP.indexOf(t)||!t.startsWith("_"))}(t,this.name))throw qO.create("invalide custom metric name",{customMetricName:t});this.counters[t]=e},CP.prototype.getMetric=function(t){return this.counters[t]||0},CP.prototype.putAttribute=function(t,e){var n=function(e){return!(0===e.length||40<e.length||YO.some(function(t){return e.startsWith(t)})||!e.match(XO))}(t),r=function(t){return 0!==t.length&&t.length<=100}(e);if(n&&r)this.customAttributes[t]=e;else{if(!n)throw qO.create("invalid attribute name",{attributeName:t});if(!r)throw qO.create("invalid attribute value",{attributeValue:e})}},CP.prototype.getAttribute=function(t){return this.customAttributes[t]},CP.prototype.removeAttribute=function(t){void 0!==this.customAttributes[t]&&delete this.customAttributes[t]},CP.prototype.getAttributes=function(){return Ea({},this.customAttributes)},CP.prototype.setStartTime=function(t){this.startTimeUs=t},CP.prototype.setDuration=function(t){this.durationUs=t},CP.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())))},CP.createOobTrace=function(t,e,n){var r=BO.getInstance().getUrl();if(r){var i=new CP("_wt_"+r,!0),o=Math.floor(1e3*BO.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))}wP(i)}},CP.createUserTimingTrace=function(t){wP(new CP(t,!1,t))},CP);function CP(t,e,n){void 0===e&&(e=!1),this.name=t,this.isAuto=e,this.state=1,this.customAttributes={},this.counters={},this.api=BO.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||MO+"-"+this.randomId+"-"+this.name,n&&this.calculateTraceMetrics())}function NP(t){var e=t;if(e&&void 0!==e.responseStart){var n=BO.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=HO.getInstance();e.instrumentationEnabled&&t.url!==e.logEndPointUrl.split("?")[0]&&e.loggingEnabled&&e.logNetworkAfterSampling&&setTimeout(function(){return bP(t,0)},0)}({url:e.name&&e.name.split("?")[0],responsePayloadBytes:e.transferSize,startTimeUs:r,timeToResponseInitiatedUs:i,timeToResponseCompletedUs:o})}}var AP=5e3;function DP(){GO()&&(setTimeout(function(){return function(){var t=BO.getInstance(),e=t.getEntriesByType("navigation"),n=t.getEntriesByType("paint");if(t.onFirstInputDelay){var r=setTimeout(function(){IP.createOobTrace(e,n),r=void 0},AP);t.onFirstInputDelay(function(t){r&&(clearTimeout(r),IP.createOobTrace(e,n,t))})}else IP.createOobTrace(e,n)}()},0),setTimeout(function(){return function(){for(var t=BO.getInstance(),e=t.getEntriesByType("resource"),n=0,r=e;n<r.length;n++){NP(r[n])}t.setupObserver("resource",NP)}()},0),setTimeout(function(){return function(){for(var t=BO.getInstance(),e=t.getEntriesByType("measure"),n=0,r=e;n<r.length;n++){kP(r[n])}t.setupObserver("measure",kP)}()},0))}function kP(t){var e=t.name;e.substring(0,MO.length)!==MO&&IP.createUserTimingTrace(e)}var RP=(OP.prototype.trace=function(t){return new IP(t)},Object.defineProperty(OP.prototype,"instrumentationEnabled",{get:function(){return HO.getInstance().instrumentationEnabled},set:function(t){HO.getInstance().instrumentationEnabled=t},enumerable:!0,configurable:!0}),Object.defineProperty(OP.prototype,"dataCollectionEnabled",{get:function(){return HO.getInstance().dataCollectionEnabled},set:function(t){HO.getInstance().dataCollectionEnabled=t},enumerable:!0,configurable:!0}),OP);function OP(t){this.app=t,BO.getInstance().requiredApisAvailable()?(gP(),uP().then(DP,DP)):$O.info("Firebase Performance cannot start if browser does not support fetch and Promise or cookie is disabled.")}var PP;function xP(t,e){if("[DEFAULT]"!==t.name)throw qO.create("FB not default");if("undefined"==typeof window)throw qO.create("no window");return function(t){OO=t}(window),HO.getInstance().firebaseAppInstance=t,HO.getInstance().installationsService=e,new RP(t)}(PP=fl).INTERNAL.registerComponent(new ps("performance",function(t){var e=t.getProvider("app").getImmediate(),n=t.getProvider("installations").getImmediate();return xP(e,n)},"PUBLIC")),PP.registerVersion("@firebase/performance","0.2.31");var MP,LP,FP,UP,VP,qP="measurementId",BP="firebase_id",jP="origin",WP="https://www.googletagmanager.com/gtag/js";function KP(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===MP.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(MP.EVENT,e,n||{})}).catch(function(t){return console.error(t)})}else if(t===MP.CONFIG){(p[e]||Promise.resolve()).then(function(){f(MP.CONFIG,e,n)}).catch(function(t){return console.error(t)})}else f(MP.SET,e)}}(r,t),{gtagCore:r,wrappedGtag:window[e]}}(LP=MP=MP||{}).EVENT="event",LP.SET="set",LP.CONFIG="config",(UP=FP=FP||{}).ADD_PAYMENT_INFO="add_payment_info",UP.ADD_TO_CART="add_to_cart",UP.ADD_TO_WISHLIST="add_to_wishlist",UP.BEGIN_CHECKOUT="begin_checkout",UP.CHECKOUT_PROGRESS="checkout_progress",UP.EXCEPTION="exception",UP.GENERATE_LEAD="generate_lead",UP.LOGIN="login",UP.PAGE_VIEW="page_view",UP.PURCHASE="purchase",UP.REFUND="refund",UP.REMOVE_FROM_CART="remove_from_cart",UP.SCREEN_VIEW="screen_view",UP.SEARCH="search",UP.SELECT_CONTENT="select_content",UP.SET_CHECKOUT_OPTION="set_checkout_option",UP.SHARE="share",UP.SIGN_UP="sign_up",UP.TIMING_COMPLETE="timing_complete",UP.VIEW_ITEM="view_item",UP.VIEW_ITEM_LIST="view_item_list",UP.VIEW_PROMOTION="view_promotion",UP.VIEW_SEARCH_RESULTS="view_search_results";var QP,HP,zP=((VP={})["no-ga-id"]='"'+qP+'" field is empty in Firebase config. Firebase Analytics requires this field to contain a valid measurement ID.',VP["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.",VP["already-initialized"]="Firebase Analytics has already been initialized.settings() must be called before initializing any Analytics instanceor it will have no effect.",VP["interop-component-reg-failed"]="Firebase Analytics Interop Component failed to instantiate",VP),GP=new Ha("analytics","Analytics",zP),YP={},XP="dataLayer",JP="gtag",$P=!1;function ZP(t){if($P)throw GP.create("already-initialized");t.dataLayerName&&(XP=t.dataLayerName),t.gtagName&&(JP=t.gtagName)}function tx(t,e){var r=t.options[qP];if(!r)throw GP.create("no-ga-id");if(null!=YP[r])throw GP.create("already-exists",{id:r});if(!$P){!function(){for(var t=window.document.getElementsByTagName("script"),e=0,n=Object.values(t);e<n.length;e++){var r=n[e];if(r.src&&r.src.includes(WP))return r}return null}()&&function(t){var e=document.createElement("script");e.src=WP+"?l="+t,e.async=!0,document.head.appendChild(e)}(XP),function(t){var e=[];Array.isArray(window[t])?e=window[t]:window[t]=e}(XP);var n=KP(YP,XP,JP),i=n.wrappedGtag,o=n.gtagCore;HP=i,QP=o,$P=!0}return YP[r]=function(r,i,o){return Ta(this,void 0,void 0,function(){var e,n;return Sa(this,function(t){switch(t.label){case 0:return[4,i.getId()];case 1:return e=t.sent(),o("js",new Date),o(MP.CONFIG,r.options[qP],((n={})[BP]=e,n[jP]="firebase",n.update=!0,n)),[2]}})})}(t,e,QP),{app:t,logEvent:function(t,e,n){return function(t,e,n,r,i){var o=r||{};i&&i.global||(o=Ea(Ea({},r),{send_to:e})),t(MP.EVENT,n,o||{})}(HP,r,t,e,n)},setCurrentScreen:function(t,e){return function(t,e,n,r){r&&r.global?t(MP.SET,{screen_name:n}):t(MP.CONFIG,e,{update:!0,screen_name:n})}(HP,r,t,e)},setUserId:function(t,e){return function(t,e,n,r){r&&r.global?t(MP.SET,{user_id:n}):t(MP.CONFIG,e,{update:!0,user_id:n})}(HP,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(MP.SET,i)}else t(MP.CONFIG,e,{update:!0,user_properties:n})}(HP,r,t,e)},setAnalyticsCollectionEnabled:function(t){return function(t,e){window["ga-disable-"+t]=!e}(r,t)}}}var ex,nx="analytics";(ex=fl).INTERNAL.registerComponent(new ps(nx,function(t){return tx(t.getProvider("app").getImmediate(),t.getProvider("installations").getImmediate())},"PUBLIC").setServiceProps({settings:ZP,EventName:FP})),ex.INTERNAL.registerComponent(new ps("analytics-internal",function(t){try{return{logEvent:t.getProvider(nx).getImmediate().logEvent}}catch(t){throw GP.create("interop-component-reg-failed",{reason:t})}},"PRIVATE")),ex.registerVersion("@firebase/analytics","0.2.12");var rx,ix=(ox.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},ox.prototype.fetch=function(a){return Ta(this,void 0,void 0,function(){var e,n,r,i,o;return Sa(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]}})})},ox);function ox(t,e,n,r){this.client=t,this.storage=e,this.storageCache=n,this.logger=r}var ax=((rx={})["registration-window"]="Undefined window object. This SDK only supports usage in a browser environment.",rx["registration-project-id"]="Undefined project identifier. Check Firebase app initialization.",rx["registration-api-key"]="Undefined API key. Check Firebase app initialization.",rx["registration-app-id"]="Undefined app identifier. Check Firebase app initialization.",rx["storage-open"]="Error thrown when opening storage. Original error: {$originalErrorMessage}.",rx["storage-get"]="Error thrown when reading from storage. Original error: {$originalErrorMessage}.",rx["storage-set"]="Error thrown when writing to storage. Original error: {$originalErrorMessage}.",rx["storage-delete"]="Error thrown when deleting from storage. Original error: {$originalErrorMessage}.",rx["fetch-client-network"]="Fetch client failed to connect to a network. Check Internet connection. Original error: {$originalErrorMessage}.",rx["fetch-timeout"]='The config fetch request timed out. Configure timeout using "fetchTimeoutMillis" SDK setting.',rx["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}.',rx["fetch-client-parse"]="Fetch client could not parse response. Original error: {$originalErrorMessage}.",rx["fetch-status"]="Fetch server returned an HTTP error status. HTTP status: {$httpStatus}.",rx),sx=new Ha("remoteconfig","Remote Config",ax);var ux=(cx.prototype.fetch=function(w){return Ta(this,void 0,void 0,function(){var e,n,r,i,o,a,s,u,c,h,l,f,p,d,y,m,g,v,b;return Sa(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"),sx.create(p,{originalErrorMessage:f.message});case 6:if(d=l.status,y=l.headers.get("ETag")||void 0,200!==l.status)return[3,11];v=void 0,t.label=7;case 7:return t.trys.push([7,9,,10]),[4,l.json()];case 8:return v=t.sent(),[3,10];case 9:throw b=t.sent(),sx.create("fetch-client-parse",{originalErrorMessage:b.message});case 10:m=v.entries,g=v.state,t.label=11;case 11:if("INSTANCE_STATE_UNSPECIFIED"===g?d=500:"NO_CHANGE"===g?d=304:"NO_TEMPLATE"!==g&&"EMPTY_CONFIG"!==g||(m={}),304!==d&&200!==d)throw sx.create("fetch-status",{httpStatus:d});return[2,{status:d,eTag:y,config:m}]}})})},cx);function cx(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 hx=(lx.prototype.addEventListener=function(t){this.listeners.push(t)},lx.prototype.abort=function(){this.listeners.forEach(function(t){return t()})},lx);function lx(){this.listeners=[]}var fx=["1","true","t","yes","y","on"],px=(dx.prototype.asString=function(){return this._value},dx.prototype.asBoolean=function(){return"static"!==this._source&&0<=fx.indexOf(this._value.toLowerCase())},dx.prototype.asNumber=function(){if("static"===this._source)return 0;var t=Number(this._value);return isNaN(t)&&(t=0),t},dx.prototype.getSource=function(){return this._source},dx);function dx(t,e){void 0===e&&(e=""),this._source=t,this._value=e}var yx=(mx.prototype.setLogLevel=function(t){switch(t){case"debug":this._logger.logLevel=vs.DEBUG;break;case"silent":this._logger.logLevel=vs.SILENT;break;default:this._logger.logLevel=vs.ERROR}},Object.defineProperty(mx.prototype,"fetchTimeMillis",{get:function(){return this._storageCache.getLastSuccessfulFetchTimestampMillis()||-1},enumerable:!0,configurable:!0}),Object.defineProperty(mx.prototype,"lastFetchStatus",{get:function(){return this._storageCache.getLastFetchStatus()||"no-fetch-yet"},enumerable:!0,configurable:!0}),mx.prototype.activate=function(){return Ta(this,void 0,void 0,function(){var e,n,r;return Sa(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]}})})},mx.prototype.ensureInitialized=function(){var t=this;return this._initializePromise||(this._initializePromise=this._storageCache.loadFromStorage().then(function(){t._isInitializationComplete=!0})),this._initializePromise},mx.prototype.fetch=function(){return Ta(this,void 0,void 0,function(){var e,n,r,i=this;return Sa(this,function(t){switch(t.label){case 0:e=new hx,setTimeout(function(){return Ta(i,void 0,void 0,function(){return Sa(this,function(t){return e.abort(),[2]})})},this.settings.fetchTimeoutMillis),t.label=1;case 1:return t.trys.push([1,4,,6]),[4,this._client.fetch({cacheMaxAgeMillis:this.settings.minimumFetchIntervalMillis,signal:e})];case 2:return t.sent(),[4,this._storageCache.setLastFetchStatus("success")];case 3:return t.sent(),[3,6];case 4:return n=t.sent(),r=function(t,e){return t instanceof Ka&&-1!==t.code.indexOf(e)}(n,"fetch-throttle")?"throttle":"failure",[4,this._storageCache.setLastFetchStatus(r)];case 5:throw t.sent(),n;case 6:return[2]}})})},mx.prototype.fetchAndActivate=function(){return Ta(this,void 0,void 0,function(){return Sa(this,function(t){switch(t.label){case 0:return[4,this.fetch()];case 1:return t.sent(),[2,this.activate()]}})})},mx.prototype.getAll=function(){var n=this;return function(t,e){return void 0===t&&(t={}),void 0===e&&(e={}),Object.keys(Ea(Ea({},t),e))}(this._storageCache.getActiveConfig(),this.defaultConfig).reduce(function(t,e){return t[e]=n.getValue(e),t},{})},mx.prototype.getBoolean=function(t){return this.getValue(t).asBoolean()},mx.prototype.getNumber=function(t){return this.getValue(t).asNumber()},mx.prototype.getString=function(t){return this.getValue(t).asString()},mx.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 px("remote",e[t]):this.defaultConfig&&void 0!==this.defaultConfig[t]?new px("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 px("static"))},mx);function mx(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 gx(t,e){var n=t.target.error||void 0;return sx.create(e,{originalErrorMessage:n&&n.message})}var vx="app_namespace_store",bx="firebase_remote_config",wx=1;var _x=(Ex.prototype.getLastFetchStatus=function(){return this.get("last_fetch_status")},Ex.prototype.setLastFetchStatus=function(t){return this.set("last_fetch_status",t)},Ex.prototype.getLastSuccessfulFetchTimestampMillis=function(){return this.get("last_successful_fetch_timestamp_millis")},Ex.prototype.setLastSuccessfulFetchTimestampMillis=function(t){return this.set("last_successful_fetch_timestamp_millis",t)},Ex.prototype.getLastSuccessfulFetchResponse=function(){return this.get("last_successful_fetch_response")},Ex.prototype.setLastSuccessfulFetchResponse=function(t){return this.set("last_successful_fetch_response",t)},Ex.prototype.getActiveConfig=function(){return this.get("active_config")},Ex.prototype.setActiveConfig=function(t){return this.set("active_config",t)},Ex.prototype.getActiveConfigEtag=function(){return this.get("active_config_etag")},Ex.prototype.setActiveConfigEtag=function(t){return this.set("active_config_etag",t)},Ex.prototype.getThrottleMetadata=function(){return this.get("throttle_metadata")},Ex.prototype.setThrottleMetadata=function(t){return this.set("throttle_metadata",t)},Ex.prototype.deleteThrottleMetadata=function(){return this.delete("throttle_metadata")},Ex.prototype.get=function(s){return Ta(this,void 0,void 0,function(){var o,a=this;return Sa(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([vx],"readonly").objectStore(vx),r=a.createCompositeKey(s);try{var i=t.get(r);i.onerror=function(t){e(gx(t,"storage-get"))},i.onsuccess=function(t){var e=t.target.result;n(e?e.value:void 0)}}catch(t){e(sx.create("storage-get",{originalErrorMessage:t&&t.message}))}})]}})})},Ex.prototype.set=function(s,u){return Ta(this,void 0,void 0,function(){var o,a=this;return Sa(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([vx],"readwrite").objectStore(vx),r=a.createCompositeKey(s);try{var i=n.put({compositeKey:r,value:u});i.onerror=function(t){e(gx(t,"storage-set"))},i.onsuccess=function(){t()}}catch(t){e(sx.create("storage-set",{originalErrorMessage:t&&t.message}))}})]}})})},Ex.prototype.delete=function(s){return Ta(this,void 0,void 0,function(){var o,a=this;return Sa(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([vx],"readwrite").objectStore(vx),r=a.createCompositeKey(s);try{var i=n.delete(r);i.onerror=function(t){e(gx(t,"storage-delete"))},i.onsuccess=function(){t()}}catch(t){e(sx.create("storage-delete",{originalErrorMessage:t&&t.message}))}})]}})})},Ex.prototype.createCompositeKey=function(t){return[this.appId,this.appName,this.namespace,t].join()},Ex);function Ex(t,e,n,r){void 0===r&&(r=new Promise(function(e,n){var t=indexedDB.open(bx,wx);t.onerror=function(t){n(gx(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(vx,{keyPath:"compositeKey"})}}})),this.appId=t,this.appName=e,this.namespace=n,this.openDbPromise=r}var Tx=(Sx.prototype.getLastFetchStatus=function(){return this.lastFetchStatus},Sx.prototype.getLastSuccessfulFetchTimestampMillis=function(){return this.lastSuccessfulFetchTimestampMillis},Sx.prototype.getActiveConfig=function(){return this.activeConfig},Sx.prototype.loadFromStorage=function(){return Ta(this,void 0,void 0,function(){var e,n,r,i,o,a;return Sa(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]}})})},Sx.prototype.setLastFetchStatus=function(t){return this.lastFetchStatus=t,this.storage.setLastFetchStatus(t)},Sx.prototype.setLastSuccessfulFetchTimestampMillis=function(t){return this.lastSuccessfulFetchTimestampMillis=t,this.storage.setLastSuccessfulFetchTimestampMillis(t)},Sx.prototype.setActiveConfig=function(t){return this.activeConfig=t,this.storage.setActiveConfig(t)},Sx);function Sx(t){this.storage=t}var Ix=(Cx.prototype.fetch=function(n){return Ta(this,void 0,void 0,function(){var e;return Sa(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)]}})})},Cx.prototype.attemptFetch=function(i,t){var o=t.throttleEndTimeMillis,a=t.backoffCount;return Ta(this,void 0,void 0,function(){var e,n,r;return Sa(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(sx.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 Ka))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]}})})},Cx);function Cx(t,e){this.client=t,this.storage=e}var Nx,Ax="@firebase/remote-config";return(Nx=fl).INTERNAL.registerComponent(new ps("remoteConfig",function(t,e){var n=t.getProvider("app").getImmediate(),r=t.getProvider("installations").getImmediate();if("undefined"==typeof window)throw sx.create("registration-window");var i=n.options,o=i.projectId,a=i.apiKey,s=i.appId;if(!o)throw sx.create("registration-project-id");if(!a)throw sx.create("registration-api-key");if(!s)throw sx.create("registration-app-id");e=e||"firebase";var u=new _x(s,n.name,e),c=new Tx(u),h=new Cs(Ax);h.logLevel=vs.ERROR;var l=new ux(r,Nx.SDK_VERSION,e,o,a,s),f=new Ix(l,u),p=new ix(f,u,c,h),d=new yx(n,p,c,u,h);return d.ensureInitialized(),d},"PUBLIC").setMultipleInstances(!0)),Nx.registerVersion(Ax,"0.1.12"),console.warn("\nIt looks like you're using the development build of the Firebase JS SDK.\nWhen deploying Firebase apps to production, it is advisable to only import\nthe individual SDK components you intend to use.\n\nFor the CDN builds, these are available in the following manner\n(replace <PACKAGE> with the name of a component - i.e. auth, database, etc):\n\nhttps://www.gstatic.com/firebasejs/5.0.0/firebase-<PACKAGE>.js\n"),fl.registerVersion("firebase","7.8.0","cdn"),fl});
//# sourceMappingURL=firebase.js.map