!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&&-1i;)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"+t+""}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=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);sn;){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>>=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;ea[0]&&e[1]=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>6|192:(55296==(64512&i)&&r+1>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>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>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>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_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"})}(o,r):"Error",s=this.serviceName+": "+a+" ("+i+").",u=new Ka(i,s),c=0,h=Object.keys(r);c>>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>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 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>>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"}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/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");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")&&(t=t.replace(ht,">")),-1!=t.indexOf('"')&&(t=t.replace(lt,""")),-1!=t.indexOf("'")&&(t=t.replace(ft,"'")),-1!=t.indexOf("\0")&&(t=t.replace(pt,"�"))),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("
");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;eparseFloat(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>>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>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;a2*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"),o=o.join("")}return o=i.createElement(o),a&&(h(a)?o.className=a:d(a)?o.className=a.join(" "):Bn(o,a)),2'),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>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 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=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>>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>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;nt.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 0this.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=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>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=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)return null;for(var t=[],e=this.pieceNum_;e=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;it.getLength())return!1;for(;eDu.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"),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 .firebaseio.com instead"),n&&"undefined"!==n||"localhost"===e.domain||nu("Cannot parse Firebase url. Please use https://.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;nXu/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;rthis.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;edocument.domain="'+document.domain+'";<\/script>');var o=""+i+"";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=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>>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(2parseFloat(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>>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;oe.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;i2*t.c&&dy(t))}function dy(t){if(t.c!=t.a.length){for(var e=0,n=0;e>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=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=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&&0r)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=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(te.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),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=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;ht.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(0e.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"},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=this.RESUME_TOKEN_MAX_AGE_MICROS||0h.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),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=":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 0i?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)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(0this.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() 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=",">","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;sr.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, 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=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>6,128|63&r);else if(55296==(64512&r))if(n>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][;base64],");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;eDate.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 with the name of a component - i.e. auth, database, etc):\n\nhttps://www.gstatic.com/firebasejs/5.0.0/firebase-.js\n"),fl.registerVersion("firebase","7.8.0","cdn"),fl}); //# sourceMappingURL=firebase.js.map