function checkSetup(){window.firebase&&firebase.app instanceof Function&&firebase.app().options||window.alert("You have not configured and imported the Firebase SDK. Make sure you go through the codelab setup instructions and make sure you are running the codelab using `firebase serve`")}function initFirebaseAuth(){saveMessagingDeviceToken()}function requestNotificationsPermissions(){firebase.messaging().requestPermission().then(function(){saveMessagingDeviceToken()}).catch(function(){})}function saveMessagingDeviceToken(){try{firebase.messaging().getToken().then(function(n){if(n){console.log("Got FCM device token:",n);var t=n;let i=window.localStorage.getItem("TokenWebsite");(i!=t||i==""||i==null||i==undefined)&&(window.localStorage.getItem("TokenWebsite",t),InsTokenByUser(t))}else requestNotificationsPermissions()}).catch(function(){})}catch(n){}}function InsTokenByUser(n){$.post("/Common/InsertTokenDevice",{Token:n,TypeDevice:1},function(){window.localStorage.setItem("TokenWebsite",n);window.location.reload()})}function sendNotification(n){var t=firebase.database().ref("Users").orderByKey();t.once("value").then(function(t){var r=[],i,u;for(!t.val()||t.forEach(function(n){var t=n.val();r.push({fcmToken:t.fcmToken})}),i=0;i<r.length;i++)u={notification:{title:"Thông báo sở tư pháp",body:n,click_action:window.location.href},to:r[i].fcmToken},$.ajax({type:"POST",url:"https://fcm.googleapis.com/fcm/send",headers:{"Content-Type":"application/json",Authorization:"key=AAAAiWeF7vQ:APA91bHOuuaz_FhmP2qurcFxq248OdaLhopFDa_lNw5ylplgy7YAKLjMrcDzJtSG9rByer3FNEhGUs6jg9hfjST6gNJ5pPuI3LOvGQ9f-Rb-To3kjIp3rTi96ZF4n2OOPjS5RCN9N8aD"},data:JSON.stringify(u),success:function(){console.log("Đã push")}})})}!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):n.firebase=t()}(this,function(){"use strict";function hi(){}function n(t){if(!(this instanceof n))throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0;this._handled=!1;this._value=void 0;this._deferreds=[];ht(t,this)}function st(t,i){for(;3===t._state;)t=t._value;0!==t._state?(t._handled=!0,n._immediateFn(function(){var n=1===t._state?i.onFulfilled:i.onRejected,r;if(null!==n){try{r=n(t._value)}catch(t){return void c(i.promise,t)}k(i.promise,r)}else(1===t._state?k:c)(i.promise,t._value)})):t._deferreds.push(i)}function k(t,i){var r,u,f;try{if(i===t)throw new TypeError("A promise cannot be resolved with itself.");if(i&&("object"==typeof i||"function"==typeof i)){if(r=i.then,i instanceof n)return t._state=3,t._value=i,void d(t);if("function"==typeof r)return void ht((u=r,f=i,function(){u.apply(f,arguments)}),t)}t._state=1;t._value=i;d(t)}catch(i){c(t,i)}}function c(n,t){n._state=2;n._value=t;d(n)}function d(t){2===t._state&&0===t._deferreds.length&&n._immediateFn(function(){t._handled||n._unhandledRejectionFn(t._value)});for(var i=0,r=t._deferreds.length;i<r;i++)st(t,t._deferreds[i]);t._deferreds=null}function ht(n,t){var i=!1;try{n(function(n){i||(i=!0,k(t,n))},function(n){i||(i=!0,c(t,n))})}catch(n){if(i)return;i=!0;c(t,n)}}function v(n,t){return n(t={exports:{}},t.exports),t.exports}function o(n,t){if(!(t instanceof Object))return t;switch(t.constructor){case Date:return new Date(t.getTime());case Object:void 0===n&&(n={});break;case Array:n=[];break;default:return t}for(var i in t)t.hasOwnProperty(i)&&(n[i]=o(n[i],t[i]));return n}function ri(n,t,i){n[t]=i}function hr(n,t){var i=new ei(n,t);return i.subscribe.bind(i)}function ot(){}function h(n,t){throw si.create(n,t);}var b,g,ni,et,ii,p,ei,si;!function(n){function f(n){if("string"!=typeof n&&(n=String(n)),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(n))throw new TypeError("Invalid character in header field name");return n.toLowerCase()}function c(n){return"string"!=typeof n&&(n=String(n)),n}function e(n){var t={next:function(){var t=n.shift();return{done:void 0===t,value:t}}};return i.iterable&&(t[Symbol.iterator]=function(){return t}),t}function t(n){this.map={};n instanceof t?n.forEach(function(n,t){this.append(t,n)},this):Array.isArray(n)?n.forEach(function(n){this.append(n[0],n[1])},this):n&&Object.getOwnPropertyNames(n).forEach(function(t){this.append(t,n[t])},this)}function o(n){if(n.bodyUsed)return Promise.reject(new TypeError("Already read"));n.bodyUsed=!0}function l(n){return new Promise(function(t,i){n.onload=function(){t(n.result)};n.onerror=function(){i(n.error)}})}function b(n){var t=new FileReader,i=l(t);return t.readAsArrayBuffer(n),i}function a(n){if(n.slice)return n.slice(0);var t=new Uint8Array(n.byteLength);return t.set(new Uint8Array(n)),t.buffer}function v(){return this.bodyUsed=!1,this._initBody=function(n){if(this._bodyInit=n,n)if("string"==typeof n)this._bodyText=n;else if(i.blob&&Blob.prototype.isPrototypeOf(n))this._bodyBlob=n;else if(i.formData&&FormData.prototype.isPrototypeOf(n))this._bodyFormData=n;else if(i.searchParams&&URLSearchParams.prototype.isPrototypeOf(n))this._bodyText=n.toString();else if(i.arrayBuffer&&i.blob&&p(n))this._bodyArrayBuffer=a(n.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer]);else{if(!i.arrayBuffer||!ArrayBuffer.prototype.isPrototypeOf(n)&&!w(n))throw new Error("unsupported BodyInit type");this._bodyArrayBuffer=a(n)}else this._bodyText="";this.headers.get("content-type")||("string"==typeof n?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):i.searchParams&&URLSearchParams.prototype.isPrototypeOf(n)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},i.blob&&(this.blob=function(){var n=o(this);if(n)return n;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?o(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(b)}),this.text=function(){var t,n,i,r=o(this);if(r)return r;if(this._bodyBlob)return t=this._bodyBlob,n=new FileReader,i=l(n),n.readAsText(t),i;if(this._bodyArrayBuffer)return Promise.resolve(function(n){for(var i=new Uint8Array(n),r=new Array(i.length),t=0;t<i.length;t++)r[t]=String.fromCharCode(i[t]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},i.formData&&(this.formData=function(){return this.text().then(k)}),this.json=function(){return this.text().then(JSON.parse)},this}function u(n,i){var f,e,r=(i=i||{}).body;if(n instanceof u){if(n.bodyUsed)throw new TypeError("Already read");this.url=n.url;this.credentials=n.credentials;i.headers||(this.headers=new t(n.headers));this.method=n.method;this.mode=n.mode;r||null==n._bodyInit||(r=n._bodyInit,n.bodyUsed=!0)}else this.url=String(n);if(this.credentials=i.credentials||this.credentials||"omit",!i.headers&&this.headers||(this.headers=new t(i.headers)),this.method=(f=i.method||this.method||"GET",e=f.toUpperCase(),s.indexOf(e)>-1?e:f),this.mode=i.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&r)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(r)}function k(n){var t=new FormData;return n.trim().split("&").forEach(function(n){if(n){var i=n.split("="),r=i.shift().replace(/\+/g," "),u=i.join("=").replace(/\+/g," ");t.append(decodeURIComponent(r),decodeURIComponent(u))}}),t}function r(n,i){i||(i={});this.type="default";this.status=void 0===i.status?200:i.status;this.ok=this.status>=200&&this.status<300;this.statusText="statusText"in i?i.statusText:"OK";this.headers=new t(i.headers);this.url=i.url||"";this._initBody(n)}var i,s,h;if(!n.fetch){if(i={searchParams:"URLSearchParams"in n,iterable:"Symbol"in n&&"iterator"in Symbol,blob:"FileReader"in n&&"Blob"in n&&function(){try{return new Blob,!0}catch(n){return!1}}(),formData:"FormData"in n,arrayBuffer:"ArrayBuffer"in n},i.arrayBuffer)var y=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],p=function(n){return n&&DataView.prototype.isPrototypeOf(n)},w=ArrayBuffer.isView||function(n){return n&&y.indexOf(Object.prototype.toString.call(n))>-1};t.prototype.append=function(n,t){n=f(n);t=c(t);var i=this.map[n];this.map[n]=i?i+","+t:t};t.prototype.delete=function(n){delete this.map[f(n)]};t.prototype.get=function(n){return n=f(n),this.has(n)?this.map[n]:null};t.prototype.has=function(n){return this.map.hasOwnProperty(f(n))};t.prototype.set=function(n,t){this.map[f(n)]=c(t)};t.prototype.forEach=function(n,t){for(var i in this.map)this.map.hasOwnProperty(i)&&n.call(t,this.map[i],i,this)};t.prototype.keys=function(){var n=[];return this.forEach(function(t,i){n.push(i)}),e(n)};t.prototype.values=function(){var n=[];return this.forEach(function(t){n.push(t)}),e(n)};t.prototype.entries=function(){var n=[];return this.forEach(function(t,i){n.push([i,t])}),e(n)};i.iterable&&(t.prototype[Symbol.iterator]=t.prototype.entries);s=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];u.prototype.clone=function(){return new u(this,{body:this._bodyInit})};v.call(u.prototype);v.call(r.prototype);r.prototype.clone=function(){return new r(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new t(this.headers),url:this.url})};r.error=function(){var n=new r(null,{status:0,statusText:""});return n.type="error",n};h=[301,302,303,307,308];r.redirect=function(n,t){if(-1===h.indexOf(t))throw new RangeError("Invalid status code");return new r(null,{status:t,headers:{location:n}})};n.Headers=t;n.Request=u;n.Response=r;n.fetch=function(n,f){return new Promise(function(e,o){var h=new u(n,f),s=new XMLHttpRequest;s.onload=function(){var u,n,i={status:s.status,statusText:s.statusText,headers:(u=s.getAllResponseHeaders()||"",n=new t,u.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(t){var i=t.split(":"),r=i.shift().trim(),u;r&&(u=i.join(":").trim(),n.append(r,u))}),n)},f;i.url="responseURL"in s?s.responseURL:i.headers.get("X-Request-URL");f="response"in s?s.response:s.responseText;e(new r(f,i))};s.onerror=function(){o(new TypeError("Network request failed"))};s.ontimeout=function(){o(new TypeError("Network request failed"))};s.open(h.method,h.url,!0);"include"===h.credentials?s.withCredentials=!0:"omit"===h.credentials&&(s.withCredentials=!1);"responseType"in s&&i.blob&&(s.responseType="blob");h.headers.forEach(function(n,t){s.setRequestHeader(t,n)});s.send(void 0===h._bodyInit?null:h._bodyInit)})};n.fetch.polyfill=!0}}("undefined"!=typeof self?self:void 0);b=setTimeout;n.prototype.catch=function(n){return this.then(null,n)};n.prototype.then=function(n,t){var i=new this.constructor(hi);return st(this,new function(n,t,i){this.onFulfilled="function"==typeof n?n:null;this.onRejected="function"==typeof t?t:null;this.promise=i}(n,t,i)),i};n.prototype.finally=function(n){var t=this.constructor;return this.then(function(i){return t.resolve(n()).then(function(){return i})},function(i){return t.resolve(n()).then(function(){return t.reject(i)})})};n.all=function(t){return new n(function(n,i){function e(t,u){try{if(u&&("object"==typeof u||"function"==typeof u)){var o=u.then;if("function"==typeof o)return void o.call(u,function(n){e(t,n)},i)}r[t]=u;0==--f&&n(r)}catch(t){i(t)}}var r,f,u;if(!t||void 0===t.length)throw new TypeError("Promise.all accepts an array");if(r=Array.prototype.slice.call(t),0===r.length)return n([]);for(f=r.length,u=0;u<r.length;u++)e(u,r[u])})};n.resolve=function(t){return t&&"object"==typeof t&&t.constructor===n?t:new n(function(n){n(t)})};n.reject=function(t){return new n(function(n,i){i(t)})};n.race=function(t){return new n(function(n,i){for(var r=0,u=t.length;r<u;r++)t[r].then(n,i)})};n._immediateFn="function"==typeof setImmediate&&function(n){setImmediate(n)}||function(n){b(n,0)};n._unhandledRejectionFn=function(n){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",n)};g=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("unable to locate global object");}();g.Promise||(g.Promise=n);var i=v(function(n){var t=n.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=t)}),r=v(function(n){var t=n.exports={version:"2.5.5"};"number"==typeof __e&&(__e=t)}),u=(r.version,function(n){return"object"==typeof n?null!==n:"function"==typeof n}),ct=function(n){if(!u(n))throw TypeError(n+" is not an object!");return n},lt=function(n){try{return!!n()}catch(n){return!0}},nt=!lt(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a}),tt=i.document,ci=u(tt)&&u(tt.createElement),li=!nt&&!lt(function(){return 7!=Object.defineProperty((n="div",ci?tt.createElement(n):{}),"a",{get:function(){return 7}}).a;var n}),ai=Object.defineProperty,vi={f:nt?Object.defineProperty:function(n,t,i){if(ct(n),t=function(n,t){if(!u(n))return n;var i,r;if(t&&"function"==typeof(i=n.toString)&&!u(r=i.call(n))||"function"==typeof(i=n.valueOf)&&!u(r=i.call(n))||!t&&"function"==typeof(i=n.toString)&&!u(r=i.call(n)))return r;throw TypeError("Can't convert object to primitive value");}(t,!0),ct(i),li)try{return ai(n,t,i)}catch(n){}if("get"in i||"set"in i)throw TypeError("Accessors not supported!");return"value"in i&&(n[t]=i.value),n}},e=nt?function(n,t,i){return vi.f(n,t,function(n,t){return{enumerable:!(1&n),configurable:!(2&n),writable:!(4&n),value:t}}(1,i))}:function(n,t,i){return n[t]=i,n},yi={}.hasOwnProperty,at=function(n,t){return yi.call(n,t)},pi=0,wi=Math.random(),vt=function(n){return"Symbol(".concat(void 0===n?"":n,")_",(++pi+wi).toString(36))},bi=v(function(n){var t=vt("src"),u=Function.toString,f=(""+u).split("toString");r.inspectSource=function(n){return u.call(n)};(n.exports=function(n,r,u,o){var s="function"==typeof u;s&&(at(u,"name")||e(u,"name",r));n[r]!==u&&(s&&(at(u,t)||e(u,t,n[r]?""+n[r]:f.join(String(r)))),n===i?n[r]=u:o?n[r]?n[r]=u:e(n,r,u):(delete n[r],e(n,r,u)))})(Function.prototype,"toString",function(){return"function"==typeof this&&this[t]||u.call(this)})}),it=function(n,t,i){if(function(n){if("function"!=typeof n)throw TypeError(n+" is not a function!");}(n),void 0===t)return n;switch(i){case 1:return function(i){return n.call(t,i)};case 2:return function(i,r){return n.call(t,i,r)};case 3:return function(i,r,u){return n.call(t,i,r,u)}}return function(){return n.apply(t,arguments)}},t=function(n,u,f){var s,a,o,v,w=n&t.F,l=n&t.G,b=n&t.S,y=n&t.P,k=n&t.B,h=l?i:b?i[u]||(i[u]={}):(i[u]||{}).prototype,c=l?r:r[u]||(r[u]={}),p=c.prototype||(c.prototype={});for(s in l&&(f=u),f)o=((a=!w&&h&&void 0!==h[s])?h:f)[s],v=k&&a?it(o,i):y&&"function"==typeof o?it(Function.call,o):o,h&&bi(h,s,o,n&t.U),c[s]!=o&&e(c,s,v),y&&p[s]!=o&&(p[s]=o)};i.core=r;t.F=1;t.G=2;t.S=4;t.P=8;t.B=16;t.W=32;t.U=64;t.R=128;var f=t,ki={}.toString,rt=function(n){return ki.call(n).slice(8,-1)},di=Object("z").propertyIsEnumerable(0)?Object:function(n){return"String"==rt(n)?n.split(""):Object(n)},yt=function(n){if(void 0==n)throw TypeError("Can't call method on  "+n);return n},gi=Math.ceil,nr=Math.floor,tr=Math.min,pt=function(n){return n>0?tr(function(n){return isNaN(n=+n)?0:(n>0?nr:gi)(n)}(n),9007199254740991):0},wt=Array.isArray||function(n){return"Array"==rt(n)},bt=i["__core-js_shared__"]||(i["__core-js_shared__"]={}),ir=function(n){return bt[n]||(bt[n]={})},y=v(function(n){var t=ir("wks"),r=i.Symbol,u="function"==typeof r;(n.exports=function(n){return t[n]||(t[n]=u&&r[n]||(u?r:vt)("Symbol."+n))}).store=t}),rr=y("species"),ur=function(n,t){return new(function(n){var t;return wt(n)&&("function"!=typeof(t=n.constructor)||t!==Array&&!wt(t.prototype)||(t=void 0),u(t)&&null===(t=t[rr])&&(t=void 0)),void 0===t?Array:t}(n))(t)},kt=function(n,t){var r=1==n,e=2==n,o=3==n,i=4==n,u=6==n,s=5==n||u,f=t||ur;return function(t,h,c){for(var a,v,w=Object(yt(t)),y=di(w),k=it(h,c,3),b=pt(y.length),l=0,p=r?f(t,b):e?f(t,0):void 0;b>l;l++)if((s||l in y)&&(v=k(a=y[l],l,w),n))if(r)p[l]=v;else if(v)switch(n){case 3:return!0;case 5:return a;case 6:return l;case 2:p.push(a)}else if(i)return!1;return u?-1:o||i?i:p}},ut=y("unscopables"),ft=Array.prototype;void 0==ft[ut]&&e(ft,ut,{});var dt=function(n){ft[ut][n]=!0},fr=kt(5),gt=!0;"find"in[]&&Array(1).find(function(){gt=!1});f(f.P+f.F*gt,"Array",{find:function(n){return fr(this,n,arguments.length>1?arguments[1]:void 0)}});dt("find");r.Array.find;ni=kt(6);et=!0;"findIndex"in[]&&Array(1).findIndex(function(){et=!1});f(f.P+f.F*et,"Array",{findIndex:function(n){return ni(this,n,arguments.length>1?arguments[1]:void 0)}});dt("findIndex");r.Array.findIndex;var er=y("match"),or=function(n,t,i){if(u(r=t)&&(void 0!==(f=r[er])?f:"RegExp"==rt(r)))throw TypeError("String#"+i+" doesn't accept regex!");var r,f;return String(yt(n))},sr=y("match"),ti="".startsWith;f(f.P+f.F*function(n){var t=/./;try{"/./"[n](t)}catch(i){try{return t[sr]=!1,!"/./"[n](t)}catch(n){}}return!0}("startsWith"),"String",{startsWith:function(n){var t=or(this,n,"startsWith"),i=pt(Math.min(arguments.length>1?arguments[1]:void 0,t.length)),r=String(n);return ti?ti.call(t,r,i):t.slice(i,i+r.length)===r}});r.String.startsWith;ii=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i])};var ui="FirebaseError",fi=Error.captureStackTrace,l=function(){return function(n,t){if(this.code=n,this.message=t,fi)fi(this,p.prototype.create);else{var i=Error.apply(this,arguments);this.name=ui;Object.defineProperty(this,"stack",{get:function(){return i.stack}})}}}();l.prototype=Object.create(Error.prototype);l.prototype.constructor=l;l.prototype.name=ui;p=function(){function n(n,t,i){this.service=n;this.serviceName=t;this.errors=i;this.pattern=/\{\$([^}]+)}/g}return n.prototype.create=function(n,t){var r,u,f,e,i;void 0===t&&(t={});u=this.errors[n];f=this.service+"/"+n;r=void 0===u?"Error":u.replace(this.pattern,function(n,i){var r=t[i];return void 0!==r?r.toString():"<"+i+"?>"});r=this.serviceName+": "+r+" ("+f+").";e=new l(f,r);for(i in t)t.hasOwnProperty(i)&&"_"!==i.slice(-1)&&(e[i]=t[i]);return e},n}();!function(n){function t(){var t=n.call(this)||this,i;for(t.chain_=[],t.buf_=[],t.W_=[],t.pad_=[],t.inbuf_=0,t.total_=0,t.blockSize=64,t.pad_[0]=128,i=1;i<t.blockSize;++i)t.pad_[i]=0;return t.reset(),t}(function(n,t){function i(){this.constructor=n}ii(n,t);n.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)})(t,n);t.prototype.reset=function(){this.chain_[0]=1732584193;this.chain_[1]=4023233417;this.chain_[2]=2562383102;this.chain_[3]=271733878;this.chain_[4]=3285377520;this.inbuf_=0;this.total_=0};t.prototype.compress_=function(n,t){var r,i,o;if(t||(t=0),r=this.W_,"string"==typeof n)for(i=0;i<16;i++)r[i]=n.charCodeAt(t)<<24|n.charCodeAt(t+1)<<16|n.charCodeAt(t+2)<<8|n.charCodeAt(t+3),t+=4;else for(i=0;i<16;i++)r[i]=n[t]<<24|n[t+1]<<16|n[t+2]<<8|n[t+3],t+=4;for(i=16;i<80;i++)o=r[i-3]^r[i-8]^r[i-14]^r[i-16],r[i]=4294967295&(o<<1|o>>>31);var s,h,c=this.chain_[0],u=this.chain_[1],f=this.chain_[2],e=this.chain_[3],l=this.chain_[4];for(i=0;i<80;i++)i<40?i<20?(s=e^u&(f^e),h=1518500249):(s=u^f^e,h=1859775393):i<60?(s=u&f|e&(u|f),h=2400959708):(s=u^f^e,h=3395469782),o=(c<<5|c>>>27)+s+l+h+r[i]&4294967295,l=e,e=f,f=4294967295&(u<<30|u>>>2),u=c,c=o;this.chain_[0]=this.chain_[0]+c&4294967295;this.chain_[1]=this.chain_[1]+u&4294967295;this.chain_[2]=this.chain_[2]+f&4294967295;this.chain_[3]=this.chain_[3]+e&4294967295;this.chain_[4]=this.chain_[4]+l&4294967295};t.prototype.update=function(n,t){if(null!=n){void 0===t&&(t=n.length);for(var f=t-this.blockSize,i=0,u=this.buf_,r=this.inbuf_;i<t;){if(0==r)for(;i<=f;)this.compress_(n,i),i+=this.blockSize;if("string"==typeof n){for(;i<t;)if(u[r]=n.charCodeAt(i),++i,++r==this.blockSize){this.compress_(u);r=0;break}}else for(;i<t;)if(u[r]=n[i],++i,++r==this.blockSize){this.compress_(u);r=0;break}}this.inbuf_=r;this.total_+=t}};t.prototype.digest=function(){var r=[],u=8*this.total_,n,i,t;for(this.inbuf_<56?this.update(this.pad_,56-this.inbuf_):this.update(this.pad_,this.blockSize-(this.inbuf_-56)),n=this.blockSize-1;n>=56;n--)this.buf_[n]=255&u,u/=256;for(this.compress_(this.buf_),i=0,n=0;n<5;n++)for(t=24;t>=0;t-=8)r[i]=this.chain_[n]>>t&255,++i;return r}}(function(){return function(){this.blockSize=-1}}());ei=function(){function n(n,t){var i=this;this.observers=[];this.unsubscribes=[];this.observerCount=0;this.task=Promise.resolve();this.finalized=!1;this.onNoObservers=t;this.task.then(function(){n(i)}).catch(function(n){i.error(n)})}return n.prototype.next=function(n){this.forEachObserver(function(t){t.next(n)})},n.prototype.error=function(n){this.forEachObserver(function(t){t.error(n)});this.close(n)},n.prototype.complete=function(){this.forEachObserver(function(n){n.complete()});this.close()},n.prototype.subscribe=function(n,t,i){var r,u=this,f;if(void 0===n&&void 0===t&&void 0===i)throw new Error("Missing Observer.");return void 0===(r=function(n,t){var i,r,u;if("object"!=typeof n||null===n)return!1;for(i=0,r=t;i<r.length;i++)if(u=r[i],u in n&&"function"==typeof n[u])return!0;return!1}(n,["next","error","complete"])?n:{next:n,error:t,complete:i}).next&&(r.next=ot),void 0===r.error&&(r.error=ot),void 0===r.complete&&(r.complete=ot),f=this.unsubscribeOne.bind(this,this.observers.length),this.finalized&&this.task.then(function(){try{u.finalError?r.error(u.finalError):r.complete()}catch(n){}}),this.observers.push(r),f},n.prototype.unsubscribeOne=function(n){void 0!==this.observers&&void 0!==this.observers[n]&&(delete this.observers[n],this.observerCount-=1,0===this.observerCount&&void 0!==this.onNoObservers&&this.onNoObservers(this))},n.prototype.forEachObserver=function(n){if(!this.finalized)for(var t=0;t<this.observers.length;t++)this.sendOne(t,n)},n.prototype.sendOne=function(n,t){var i=this;this.task.then(function(){if(void 0!==i.observers&&void 0!==i.observers[n])try{t(i.observers[n])}catch(n){"undefined"!=typeof console&&console.error&&console.error(n)}})},n.prototype.close=function(n){var t=this;this.finalized||(this.finalized=!0,void 0!==n&&(this.finalError=n),this.task.then(function(){t.observers=void 0;t.onNoObservers=void 0}))},n}();var oi=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},w="[DEFAULT]",a=[],s=function(){function n(n,t,i){this.firebase_=i;this.isDeleted_=!1;this.services_={};this.name_=t.name;this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled||!1;this.options_=o(void 0,n);this.INTERNAL={getUid:function(){return null},getToken:function(){return Promise.resolve(null)},addAuthTokenListener:function(n){a.push(n);setTimeout(function(){return n(null)},0)},removeAuthTokenListener:function(n){a=a.filter(function(t){return t!==n})}}}return Object.defineProperty(n.prototype,"automaticDataCollectionEnabled",{get:function(){return this.checkDestroyed_(),this._automaticDataCollectionEnabled},set:function(n){this.checkDestroyed_();this._automaticDataCollectionEnabled=n},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"name",{get:function(){return this.checkDestroyed_(),this.name_},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"options",{get:function(){return this.checkDestroyed_(),this.options_},enumerable:!0,configurable:!0}),n.prototype.delete=function(){var n=this;return new Promise(function(t){n.checkDestroyed_();t()}).then(function(){n.firebase_.INTERNAL.removeApp(n.name_);var t=[];return Object.keys(n.services_).forEach(function(i){Object.keys(n.services_[i]).forEach(function(r){t.push(n.services_[i][r])})}),Promise.all(t.map(function(n){return n.INTERNAL.delete()}))}).then(function(){n.isDeleted_=!0;n.services_={}})},n.prototype._getService=function(n,t){if(void 0===t&&(t=w),this.checkDestroyed_(),this.services_[n]||(this.services_[n]={}),!this.services_[n][t]){var i=t!==w?t:void 0,r=this.firebase_.INTERNAL.factories[n](this,this.extendApp.bind(this),i);this.services_[n][t]=r}return this.services_[n][t]},n.prototype.extendApp=function(n){var t=this;o(this,n);n.INTERNAL&&n.INTERNAL.addAuthTokenListener&&(a.forEach(function(n){t.INTERNAL.addAuthTokenListener(n)}),a=[])},n.prototype.checkDestroyed_=function(){this.isDeleted_&&h("app-deleted",{name:this.name_})},n}();return s.prototype.name&&s.prototype.options||s.prototype.delete||console.log("dc"),si=new p("app","Firebase",{"no-app":"No Firebase App '{$name}' has been created - call Firebase App.initializeApp()","bad-app-name":"Illegal App name: '{$name}","duplicate-app":"Firebase App named '{$name}' already exists","app-deleted":"Firebase App named '{$name}' already deleted","duplicate-service":"Firebase service named '{$name}' already registered","sa-not-supported":"Initializing the Firebase SDK with a service account is only allowed in a Node.js environment. On client devices, you should instead initialize the SDK with an api key and auth domain","invalid-app-argument":"firebase.{$name}() takes either no argument or a Firebase App instance."}),function b(){function u(t){return oi(n,t=t||w)||h("no-app",{name:t}),n[t]}function f(){return Object.keys(n).map(function(t){return n[t]})}function e(n,t){Object.keys(i).forEach(function(i){var u=c(n,i);null!==u&&r[u]&&r[u](t,n)})}function c(n,t){if("serverAuth"===t)return null;var i=t;return n.options,i}var n={},i={},r={},t={__esModule:!0,initializeApp:function(i,r){var c,f,u,o;return(void 0===r&&(r={}),"object"!=typeof r||null===r)&&(c=r,r={name:c}),f=r,void 0===f.name&&(f.name=w),u=f.name,"string"==typeof u&&u||h("bad-app-name",{name:u+""}),oi(n,u)&&h("duplicate-app",{name:u}),o=new s(i,f,t),n[u]=o,e(o,"create"),o},app:u,apps:null,Promise:Promise,SDK_VERSION:"5.0.0",INTERNAL:{registerService:function(n,e,c,l,a){i[n]&&h("duplicate-service",{name:n});i[n]=e;l&&(r[n]=l,f().forEach(function(n){l("create",n)}));var v=function(t){return void 0===t&&(t=u()),"function"!=typeof t[n]&&h("invalid-app-argument",{name:n}),t[n]()};return void 0!==c&&o(v,c),t[n]=v,s.prototype[n]=function(){for(var i=[],t=0;t<arguments.length;t++)i[t]=arguments[t];return this._getService.bind(this,n).apply(this,a?i:[])},v},createFirebaseNamespace:b,extendNamespace:function(n){o(t,n)},createSubscribe:hr,ErrorFactory:p,removeApp:function(t){e(n[t],"delete");delete n[t]},factories:i,useAsService:c,Promise:Promise,deepExtend:o}};return ri(t,"default",t),Object.defineProperty(t,"apps",{get:f}),ri(u,"App",s),t}()});!function(n,t){"use strict";try{t=t&&t.hasOwnProperty("default")?t.default:t;var i="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};(function(){function b(n){return"string"==typeof n}function krt(n){return"boolean"==typeof n}function ti(){}function uu(n){var t=typeof n,i;if("object"==t){if(!n)return"null";if(n instanceof Array)return"array";if(n instanceof Object)return t;if(i=Object.prototype.toString.call(n),"[object Window]"==i)return"object";if("[object Array]"==i||"number"==typeof n.length&&void 0!==n.splice&&void 0!==n.propertyIsEnumerable&&!n.propertyIsEnumerable("splice"))return"array";if("[object Function]"==i||void 0!==n.call&&void 0!==n.propertyIsEnumerable&&!n.propertyIsEnumerable("call"))return"function"}else if("function"==t&&void 0===n.call)return"object";return t}function drt(n){return null===n}function er(n){return"array"==uu(n)}function wf(n){var t=uu(n);return"array"==t||"object"==t&&"number"==typeof n.length}function ut(n){return"function"==uu(n)}function vt(n){var t=typeof n;return"object"==t&&null!=n||"function"==t}function grt(n){return n.call.apply(n.bind,arguments)}function nut(n,t){if(!n)throw Error();if(2<arguments.length){var i=Array.prototype.slice.call(arguments,2);return function(){var r=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(r,i),n.apply(t,r)}}return function(){return n.apply(t,arguments)}}function o(){return(o=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?grt:nut).apply(null,arguments)}function yo(n){var t=Array.prototype.slice.call(arguments,1);return function(){var i=t.slice();return i.push.apply(i,arguments),n.apply(this,i)}}function c(n,t){function i(){}i.prototype=t.prototype;n.lb=t.prototype;n.prototype=new i;n.prototype.constructor=n;n.cd=function(n,i){for(var u=Array(arguments.length-2),r=2;r<arguments.length;r++)u[r-2]=arguments[r];return t.prototype[i].apply(n,u)}}function hw(n){n.prototype.then=n.prototype.then;n.prototype.$goog_Thenable=!0}function cw(n){if(!n)return!1;try{return!!n.$goog_Thenable}catch(n){return!1}}function ct(n){if(Error.captureStackTrace)Error.captureStackTrace(this,ct);else{var t=Error().stack;t&&(this.stack=t)}n&&(this.message=String(n))}function yc(n,t){for(var r="",u=(n=n.split("%s")).length-1,i=0;i<u;i++)r+=n[i]+(i<t.length?t[i]:"%s");ct.call(this,r+n[u])}function bf(n){throw new yc("Failure"+(n?": "+n:""),Array.prototype.slice.call(arguments,1));}function pc(n,t){this.c=n;this.f=t;this.b=0;this.a=null}function lw(n,t){n.f(t);100>n.b&&(n.b++,t.next=n.a,n.a=t)}function aw(){this.b=this.a=null}function tut(){var n=el,t=null;return n.a&&(t=n.a,n.a=n.a.next,n.a||(n.b=null),t.next=null),t}function bc(){this.next=this.b=this.a=null}function or(n,t){return 0<=vw(n,t)}function po(n,t){var i;return(i=0<=(t=vw(n,t)))&&Array.prototype.splice.call(n,t,1),i}function dt(n,t){!function(n,t){var i=n.length,r=b(n)?n.split(""):n;for(--i;0<=i;--i)i in r&&t.call(void 0,r[i],i,n)}(n,function(i,r){t.call(void 0,i,r,n)&&1==Array.prototype.splice.call(n,r,1).length&&0})}function dc(){return Array.prototype.concat.apply([],arguments)}function sr(n){var i=n.length,r,t;if(0<i){for(r=Array(i),t=0;t<i;t++)r[t]=n[t];return r}return[]}function yw(n){for(var t=n.split("%s"),i="",r=Array.prototype.slice.call(arguments,1);r.length&&1<t.length;)i+=t.shift()+r.shift();return i+t.join("%s")}function nl(n){return hut.test(n)?(-1!=n.indexOf("&")&&(n=n.replace(rut,"&amp;")),-1!=n.indexOf("<")&&(n=n.replace(uut,"&lt;")),-1!=n.indexOf(">")&&(n=n.replace(fut,"&gt;")),-1!=n.indexOf('"')&&(n=n.replace(eut,"&quot;")),-1!=n.indexOf("'")&&(n=n.replace(out,"&#39;")),-1!=n.indexOf("\0")&&(n=n.replace(sut,"&#0;")),n):n}function y(n,t){return-1!=n.indexOf(t)}function tl(n,t){return n<t?-1:n>t?1:0}function g(n){return y(eu,n)}function pw(n,t){for(var i in n)t.call(void 0,n[i],i,n)}function kf(n){for(var t in n)return!1;return!0}function df(n){var t,i={};for(t in n)i[t]=n[t];return i}function hi(n){for(var t,i,u,r=1;r<arguments.length;r++){for(t in i=arguments[r])n[t]=i[t];for(u=0;u<fl.length;u++)t=fl[u],Object.prototype.hasOwnProperty.call(i,t)&&(n[t]=i[t])}}function ww(n){r.setTimeout(function(){throw n;},0)}function bo(n,t){wo||function(){if(r.Promise&&r.Promise.resolve){var n=r.Promise.resolve(void 0);wo=function(){n.then(bw)}}else wo=function(){var n=bw;!ut(r.setImmediate)||r.Window&&r.Window.prototype&&!g("Edge")&&r.Window.prototype.setImmediate==r.setImmediate?(ul||(ul=function(){var t=r.MessageChannel;if(void 0===t&&"undefined"!=typeof window&&window.postMessage&&window.addEventListener&&!g("Presto")&&(t=function(){var n=document.createElement("IFRAME"),t,r,i;n.style.display="none";n.src="";document.documentElement.appendChild(n);t=n.contentWindow;(n=t.document).open();n.write("");n.close();r="callImmediate"+Math.random();i="file:"==t.location.protocol?"*":t.location.protocol+"//"+t.location.host;n=o(function(n){"*"!=i&&n.origin!=i||n.data!=r||this.port1.onmessage()},this);t.addEventListener("message",n,!1);this.port1={};this.port2={postMessage:function(){t.postMessage(r,i)}}}),void 0!==t&&!g("Trident")&&!g("MSIE")){var u=new t,n={},i=n;return u.port1.onmessage=function(){if(void 0!==n.next){var t=(n=n.next).tb;n.tb=null;t()}},function(n){i.next={tb:n};i=i.next;u.port2.postMessage(0)}}return"undefined"!=typeof document&&"onreadystatechange"in document.createElement("SCRIPT")?function(n){var t=document.createElement("SCRIPT");t.onreadystatechange=function(){t.onreadystatechange=null;t.parentNode.removeChild(t);t=null;n();n=null};document.documentElement.appendChild(t)}:function(n){r.setTimeout(n,0)}}()),ul(n)):r.setImmediate(n)}}();ko||(wo(),ko=!0);el.add(n,t)}function bw(){for(var n;n=tut();){try{n.a.call(n.b)}catch(n){ww(n)}lw(wc,n)}ko=!1}function l(n,t){if(this.a=hr,this.i=void 0,this.f=this.b=this.c=null,this.g=this.h=!1,n!=ti)try{var i=this;n.call(t,function(n){cr(i,gf,n)},function(n){if(!(n instanceof ou))try{if(n instanceof Error)throw n;throw Error("Promise rejected.");}catch(n){}cr(i,ci,n)})}catch(n){cr(this,ci,n)}}function kw(){this.next=this.f=this.b=this.g=this.a=null;this.c=!1}function sl(n,t,i){var r=ol.get();return r.g=n,r.b=t,r.f=i,r}function e(n){if(n instanceof l)return n;var t=new l(ti);return cr(t,gf,n),t}function k(n){return new l(function(t,i){i(n)})}function dw(n,t,i){nb(n,t,i,null)||bo(yo(t,n))}function hl(n,t){n.b||n.a!=gf&&n.a!=ci||tb(n);n.f?n.f.next=t:n.b=t;n.f=t}function gw(n,t,i,r){var u=sl(null,null,null);return u.a=new l(function(n,f){u.g=t?function(i){try{var u=t.call(r,i);n(u)}catch(n){f(n)}}:n;u.b=i?function(t){try{var u=i.call(r,t);void 0===u&&t instanceof ou?f(t):n(u)}catch(n){f(n)}}:f}),u.a.c=n,hl(n,u),u.a}function cr(n,t,i){n.a==hr&&(n===i&&(t=ci,i=new TypeError("Promise cannot resolve to itself")),n.a=1,nb(i,n.Lc,n.Mc,n)||(n.i=i,n.a=t,n.c=null,tb(n),t!=ci||i instanceof ou||function(n,t){n.g=!0;bo(function(){n.g&&cl.call(null,t)})}(n,i)))}function nb(n,t,i,r){if(n instanceof l)return hl(n,sl(t||ti,i||null,r)),!0;if(cw(n))return n.then(t,i,r),!0;if(vt(n))try{var u=n.then;if(ut(u))return function(n,t,i,r,u){function e(n){f||(f=!0,r.call(u,n))}var f=!1;try{t.call(n,function(n){f||(f=!0,i.call(u,n))},e)}catch(n){e(n)}}(n,u,t,i,r),!0}catch(n){return i.call(r,n),!0}return!1}function tb(n){n.h||(n.h=!0,bo(n.Ub,n))}function ib(n){var t=null;return n.b&&(t=n.b,n.b=t.next,t.next=null),n.b||(n.f=null),t}function rb(n,t,i,r){if(i==ci&&t.b&&!t.c)for(;n&&n.g;n=n.c)n.g=!1;if(t.a)t.a.c=null,ub(t,i,r);else try{t.c?t.g.call(t.f):ub(t,i,r)}catch(n){cl.call(null,n)}lw(ol,t)}function ub(n,t,i){t==gf?n.g.call(n.f,i):n.b&&n.b.call(n.f,i)}function ou(n){ct.call(this,n)}function go(){0!=ns&&(ll[this[vo]||(this[vo]=++sw)]=this);this.pa=this.pa;this.ja=this.ja}function fb(n){if(!n.pa&&(n.pa=!0,n.ua(),0!=ns)){var t=n[vo]||(n[vo]=++sw);if(0!=ns&&n.ja&&0<n.ja.length)throw Error(n+" did not empty its onDisposeCallbacks queue. This probably means it overrode dispose() or disposeInternal() without calling the superclass' method.");delete ll[t]}}function al(n){return al[" "](n),n}function sb(){var n=r.document;if(n)return n.documentMode}function cb(n){return function(n,t){var i=hb;return Object.prototype.hasOwnProperty.call(i,n)?i[n]:i[n]=t(n)}(n,function(){for(var t,i,r=0,f=gc(String(ts)).split("."),e=gc(String(n)).split("."),o=Math.max(f.length,e.length),u=0;0==r&&u<o;u++){t=f[u]||"";i=e[u]||"";do{if(t=/(\d*)(\D*)(.*)/.exec(t)||["","","",""],i=/(\d*)(\D*)(.*)/.exec(i)||["","","",""],0==t[0].length&&0==i[0].length)break;r=tl(0==t[1].length?0:parseInt(t[1],10),0==i[1].length?0:parseInt(i[1],10))||tl(0==t[2].length,0==i[2].length)||tl(t[2],i[2]);t=t[3];i=i[3]}while(0==r)}return 0<=r})}function yt(n,t){this.type=n;this.b=this.target=t;this.Gb=!0}function lr(n,t){var r,i,u;if(yt.call(this,n?n.type:""),this.relatedTarget=this.b=this.target=null,this.button=this.screenY=this.screenX=this.clientY=this.clientX=0,this.key="",this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.pointerId=0,this.pointerType="",this.a=null,n){if(r=this.type=n.type,i=n.changedTouches?n.changedTouches[0]:null,this.target=n.target||n.srcElement,this.b=t,t=n.relatedTarget){if(ob){n:{try{al(t.nodeName);u=!0;break n}catch(n){}u=!1}u||(t=null)}}else"mouseover"==r?t=n.fromElement:"mouseout"==r&&(t=n.toElement);this.relatedTarget=t;null===i?(this.clientX=void 0!==n.clientX?n.clientX:n.pageX,this.clientY=void 0!==n.clientY?n.clientY:n.pageY,this.screenX=n.screenX||0,this.screenY=n.screenY||0):(this.clientX=void 0!==i.clientX?i.clientX:i.pageX,this.clientY=void 0!==i.clientY?i.clientY:i.pageY,this.screenX=i.screenX||0,this.screenY=i.screenY||0);this.button=n.button;this.key=n.key||"";this.ctrlKey=n.ctrlKey;this.altKey=n.altKey;this.shiftKey=n.shiftKey;this.metaKey=n.metaKey;this.pointerId=n.pointerId||0;this.pointerType=b(n.pointerType)?n.pointerType:ab[n.pointerType]||"";this.a=n;n.defaultPrevented&&this.preventDefault()}}function fs(n){n.na=!0;n.listener=null;n.proxy=null;n.src=null;n.La=null}function es(n){this.src=n;this.a={};this.b=0}function yl(n,t){var i=t.type;i in n.a&&po(n.a[i],t)&&(fs(t),0==n.a[i].length&&(delete n.a[i],n.b--))}function pl(n,t,i,r){for(var f,u=0;u<n.length;++u)if(f=n[u],!f.na&&f.listener==t&&f.capture==!!i&&f.La==r)return u;return-1}function ii(n,t,i,r,u){if(r&&r.once)wl(n,t,i,r,u);else if(er(t))for(var f=0;f<t.length;f++)ii(n,t[f],i,r,u);else i=bl(i),n&&n[hu]?db(n,t,i,vt(r)?!!r.capture:!!r,u):yb(n,t,i,!1,r,u)}function yb(n,t,i,r,u,f){if(!t)throw Error("Invalid event type");var o=vt(u)?!!u.capture:!!u,e=hs(n);if(e||(n[os]=e=new es(n)),!(i=e.add(t,i,r,o,f)).proxy)if(r=function(){var t=wut,n=lb?function(i){return t.call(n.src,n.listener,i)}:function(i){if(!(i=t.call(n.src,n.listener,i)))return i};return n}(),i.proxy=r,r.src=n,r.listener=i,n.addEventListener)put||(u=o),void 0===u&&(u=!1),n.addEventListener(t.toString(),r,u);else if(n.attachEvent)n.attachEvent(wb(t.toString()),r);else{if(!n.addListener||!n.removeListener)throw Error("addEventListener and attachEvent are unavailable.");n.addListener(r)}}function wl(n,t,i,r,u){if(er(t))for(var f=0;f<t.length;f++)wl(n,t[f],i,r,u);else i=bl(i),n&&n[hu]?kl(n,t,i,vt(r)?!!r.capture:!!r,u):yb(n,t,i,!0,r,u)}function pt(n,t,i,r,u){if(er(t))for(var f=0;f<t.length;f++)pt(n,t[f],i,r,u);else r=vt(r)?!!r.capture:!!r,i=bl(i),n&&n[hu]?(n=n.m,(t=String(t).toString())in n.a&&-1<(i=pl(f=n.a[t],i,r,u))&&(fs(f[i]),Array.prototype.splice.call(f,i,1),0==f.length&&(delete n.a[t],n.b--))):n&&(n=hs(n))&&(t=n.a[t.toString()],n=-1,t&&(n=pl(t,i,r,u)),(i=-1<n?t[n]:null)&&pb(i))}function pb(n){var t,i,r;"number"!=typeof n&&n&&!n.na&&(t=n.src,t&&t[hu]?yl(t.m,n):(i=n.type,r=n.proxy,t.removeEventListener?t.removeEventListener(i,r,n.capture):t.detachEvent?t.detachEvent(wb(i),r):t.addListener&&t.removeListener&&t.removeListener(r),(i=hs(t))?(yl(i,n),0==i.b&&(i.src=null,t[os]=null)):fs(n)))}function wb(n){return n in ss?ss[n]:ss[n]="on"+n}function bb(n,t,i,r){var f=!0,u;if((n=hs(n))&&(t=n.a[t.toString()]))for(t=t.concat(),n=0;n<t.length;n++)u=t[n],u&&u.capture==i&&!u.na&&(u=kb(u,r),f=f&&!1!==u);return f}function kb(n,t){var i=n.listener,r=n.La||n.src;return n.Ia&&pb(n),i.call(r,t)}function wut(n,t){var f,i,u,e;if(n.na)return!0;if(!lb){if(!t)n:{for(t=["window","event"],f=r,i=0;i<t.length;i++)if(null==(f=f[t[i]])){t=null;break n}t=f}if(t=new lr(i=t,this),f=!0,!(0>i.keyCode||void 0!=i.returnValue)){n:{if(u=!1,0==i.keyCode)try{i.keyCode=-1;break n}catch(n){u=!0}(u||void 0==i.returnValue)&&(i.returnValue=!0)}for(i=[],u=t.b;u;u=u.parentNode)i.push(u);for(n=n.type,u=i.length-1;0<=u;u--)t.b=i[u],e=bb(i[u],n,!0,t),f=f&&e;for(u=0;u<i.length;u++)t.b=i[u],e=bb(i[u],n,!1,t),f=f&&e}return f}return kb(n,new lr(t,this))}function hs(n){return(n=n[os])instanceof es?n:null}function bl(n){return ut(n)?n:(n[cs]||(n[cs]=function(t){return n.handleEvent(t)}),n[cs])}function ft(){go.call(this);this.m=new es(this);this.Nb=this;this.Ua=null}function db(n,t,i,r,u){n.m.add(String(t),i,!1,r,u)}function kl(n,t,i,r,u){n.m.add(String(t),i,!0,r,u)}function ls(n,t,i,r){var f,e,u,o,s;if(!(t=n.m.a[String(t)]))return!0;for(t=t.concat(),f=!0,e=0;e<t.length;++e)u=t[e],u&&!u.na&&u.capture==i&&(o=u.listener,s=u.La||u.src,u.Ia&&yl(n.m,u),f=!1!==o.call(s,r)&&f);return f&&0!=r.Gb}function dl(n,t,i){if(ut(n))i&&(n=o(n,i));else{if(!n||"function"!=typeof n.handleEvent)throw Error("Invalid listener argument");n=o(n.handleEvent,n)}return 2147483647<Number(t)?-1:r.setTimeout(n,t||0)}function ar(n){var t=null;return new l(function(i,r){-1==(t=dl(function(){i(void 0)},n))&&r(Error("Failed to schedule timer."))}).s(function(n){throw r.clearTimeout(t),n;})}function gb(n){if(n.S&&"function"==typeof n.S)return n.S();if(b(n))return n.split("");if(wf(n)){for(var t=[],r=n.length,i=0;i<r;i++)t.push(n[i]);return t}for(i in t=[],r=0,n)t[r++]=n[i];return t}function nk(n){var t,i,r;if(n.U&&"function"==typeof n.U)return n.U();if(!n.S||"function"!=typeof n.S){if(wf(n)||b(n)){for(t=[],n=n.length,i=0;i<n;i++)t.push(i);return t}for(r in t=[],i=0,n)t[i++]=r;return t}}function cu(n){var i,t;if(this.b={},this.a=[],this.c=0,i=arguments.length,1<i){if(i%2)throw Error("Uneven number of arguments");for(t=0;t<i;t+=2)this.set(arguments[t],arguments[t+1])}else if(n)if(n instanceof cu)for(i=n.U(),t=0;t<i.length;t++)this.set(i[t],n.get(i[t]));else for(t in n)this.set(t,n[t])}function gl(n){var t,i,r,u;if(n.c!=n.a.length){for(t=0,i=0;t<n.a.length;)r=n.a[t],vr(n.b,r)&&(n.a[i++]=r),t++;n.a.length=i}if(n.c!=n.a.length){for(u={},i=t=0;t<n.a.length;)vr(u,r=n.a[t])||(n.a[i++]=r,u[r]=1),t++;n.a.length=i}}function vr(n,t){return Object.prototype.hasOwnProperty.call(n,t)}function lu(n,t){if(this.b=this.m=this.c="",this.i=null,this.h=this.g="",this.f=!1,n instanceof lu){this.f=void 0!==t?t:n.f;ta(this,n.c);this.m=n.m;this.b=n.b;tk(this,n.i);this.g=n.g;t=n.a;var i=new au;i.c=t.c;t.a&&(i.a=new cu(t.a),i.b=t.b);ik(this,i);this.h=n.h}else n&&(i=String(n).match(na))?(this.f=!!t,ta(this,i[1]||"",!0),this.m=ne(i[2]||""),this.b=ne(i[3]||"",!0),tk(this,i[4]),this.g=ne(i[5]||"",!0),ik(this,i[6]||"",!0),this.h=ne(i[7]||"")):(this.f=!!t,this.a=new au(null,this.f))}function ta(n,t,i){n.c=i?ne(t,!0):t;n.c&&(n.c=n.c.replace(/:$/,""))}function tk(n,t){if(t){if(t=Number(t),isNaN(t)||0>t)throw Error("Bad port number "+t);n.i=t}else n.i=null}function ik(n,t,i){t instanceof au?(n.a=t,function(n,t){t&&!n.f&&(di(n),n.c=null,n.a.forEach(function(n,t){var i=t.toLowerCase();t!=i&&(vi(this,t),ok(this,i,n))},n));n.f=t}(n.a,n.f)):(i||(t=te(t,gut)),n.a=new au(t,n.f))}function d(n,t,i){n.a.set(t,i)}function ki(n,t){return n.a.get(t)}function ai(n){return n instanceof lu?new lu(n):new lu(n,void 0)}function rk(n,t){var i=new lu(null,void 0);return ta(i,"https"),n&&(i.b=n),t&&(i.g=t),i}function ne(n,t){return n?t?decodeURI(n.replace(/%25/g,"%2525")):decodeURIComponent(n):""}function te(n,t,i){return b(n)?(n=encodeURI(n).replace(t,but),i&&(n=n.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),n):null}function but(n){return"%"+((n=n.charCodeAt(0))>>4&15).toString(16)+(15&n).toString(16)}function au(n,t){this.b=this.a=null;this.c=n||null;this.f=!!t}function di(n){n.a||(n.a=new cu,n.b=0,n.c&&function(n,t){var i,r,u,f;if(n)for(n=n.split("&"),i=0;i<n.length;i++)r=n[i].indexOf("="),u=null,0<=r?(f=n[i].substring(0,r),u=n[i].substring(r+1)):f=n[i],t(f,u?decodeURIComponent(u.replace(/\+/g," ")):"")}(n.c,function(t,i){n.add(decodeURIComponent(t.replace(/\+/g," ")),i)}))}function fk(n){var u=nk(n),i,t,f,r;if(void 0===u)throw Error("Keys are undefined");for(i=new au(null,void 0),n=gb(n),t=0;t<u.length;t++)f=u[t],r=n[t],er(r)?ok(i,f,r):i.add(f,r);return i}function vi(n,t){di(n);t=vu(n,t);vr(n.a.b,t)&&(n.c=null,n.b-=n.a.get(t).length,vr((n=n.a).b,t)&&(delete n.b[t],n.c--,n.a.length>2*n.c&&gl(n)))}function ek(n,t){return di(n),t=vu(n,t),vr(n.a.b,t)}function ok(n,t,i){vi(n,t);0<i.length&&(n.c=null,n.a.set(vu(n,t),sr(i)),n.b+=i.length)}function vu(n,t){return t=String(t),n.f&&(t=t.toLowerCase()),t}function yr(){this.a="";this.b=ia}function hk(n){return n instanceof yr&&n.constructor===yr&&n.b===ia?n.a:(bf("expected object of type Const, got '"+n+"'"),"type_error:Const")}function ie(n){var t=new yr;return t.a=n,t}function yu(){this.a="";this.b=lk}function ck(n){return n instanceof yu&&n.constructor===yu&&n.b===lk?n.a:(bf("expected object of type TrustedResourceUrl, got '"+n+"' of type "+uu(n)),"type_error:TrustedResourceUrl")}function ra(n,t){var i=hk(n);if(!ift.test(i))throw Error("Invalid TrustedResourceUrl format: "+i);return function(n){var t=new yu;return t.a=n,t}(n=i.replace(tft,function(n,r){if(!Object.prototype.hasOwnProperty.call(t,r))throw Error('Found marker, "'+r+'", in format string, "'+i+'", but no valid label mapping found in args: '+JSON.stringify(t));return(n=t[r])instanceof yr?hk(n):encodeURIComponent(String(n))}))}function ri(){this.a="";this.b=fa}function as(n){return n instanceof ri&&n.constructor===ri&&n.b===fa?n.a:(bf("expected object of type SafeUrl, got '"+n+"' of type "+uu(n)),"type_error:SafeUrl")}function ak(n){return n instanceof ri?n:(n=n.ma?n.la():String(n),ua.test(n)||(n="about:invalid#zClosurez"),ea(n))}function ea(n){var t=new ri;return t.a=n,t}function pu(){this.a="";this.b=oa}function vs(n){var t=new pu;return t.a=n,t}function re(n){var t=document;return b(n)?t.getElementById(n):n}function vk(n,t){pw(t,function(t,i){t&&t.ma&&(t=t.la());"style"==i?n.style.cssText=t:"class"==i?n.className=t:"for"==i?n.htmlFor=t:sa.hasOwnProperty(i)?n.setAttribute(sa[i],t):0==i.lastIndexOf("aria-",0)||0==i.lastIndexOf("data-",0)?n.setAttribute(i,t):n[i]=t})}function rft(){var i=arguments,u=document,t=String(i[0]),n=i[1],r;return!sk&&n&&(n.name||n.type)&&((t=["<",t],n.name&&t.push(' name="',nl(n.name),'"'),n.type)&&(t.push(' type="',nl(n.type),'"'),r={},hi(r,n),delete r.type,n=r),t.push(">"),t=t.join("")),t=u.createElement(t),n&&(b(n)?t.className=n:er(n)?t.className=n.join(" "):vk(t,n)),2<i.length&&function(n,t,i){function f(i){i&&t.appendChild(b(i)?n.createTextNode(i):i)}for(var r,u=2;u<i.length;u++)r=i[u],!wf(r)||vt(r)&&0<r.nodeType?f(r):st(uft(r)?sr(r):r,f)}(u,t,i),t}function uft(n){if(n&&"number"==typeof n.length){if(vt(n))return"function"==typeof n.item||"string"==typeof n.item;if(ut(n))return"function"==typeof n.item}return!1}function yk(n){var t=[];return function n(t,i,r){var u,f,e;if(null==i)r.push("null");else{if("object"==typeof i){if(er(i)){for(u=i,i=u.length,r.push("["),f="",e=0;e<i;e++)r.push(f),n(t,u[e],r),f=",";return void r.push("]")}if(!(i instanceof String||i instanceof Number||i instanceof Boolean)){for(u in r.push("{"),f="",i)Object.prototype.hasOwnProperty.call(i,u)&&"function"!=typeof(e=i[u])&&(r.push(f),wk(u,r),r.push(":"),n(t,e,r),f=",");return void r.push("}")}i=i.valueOf()}switch(typeof i){case"string":wk(i,r);break;case"number":r.push(isFinite(i)&&!isNaN(i)?String(i):"null");break;case"boolean":r.push(String(i));break;case"function":r.push("null");break;default:throw Error("Unknown type: "+typeof i);}}}(new function(){},n,t),t.join("")}function wk(n,t){t.push('"',n.replace(pk,function(n){var t=ha[n];return t||(t="\\u"+(65536|n.charCodeAt(0)).toString(16).substr(1),ha[n]=t),t}),'"')}function ca(){var n=nt();return gt&&!!li&&11==li||/Edge\/\d+/.test(n)}function wu(){return r.window&&r.window.location.href||self&&self.location&&self.location.href||""}function bk(n,t){t=t||r.window;var i="about:blank";n&&(i=as(ak(n)));t.location.href=i}function kk(n){return!!((n=(n||nt()).toLowerCase()).match(/android/)||n.match(/webos/)||n.match(/iphone|ipad|ipod/)||n.match(/blackberry/)||n.match(/windows phone/)||n.match(/iemobile/))}function pr(n){n=n||r.window;try{n.close()}catch(n){}}function dk(n,t,i){var u=Math.floor(1e9*Math.random()).toString(),f,e,r;t=t||500;i=i||600;f=(window.screen.availHeight-i)/2;e=(window.screen.availWidth-t)/2;for(r in t={width:t,height:i,top:0<f?f:0,left:0<e?e:0,location:!0,resizable:!0,statusbar:!0,toolbar:!1},i=nt().toLowerCase(),u&&(t.target=u,y(i,"crios/")&&(t.target="_blank")),bu(nt())==ys&&(n=n||"http://localhost",t.scrollbars=!0),i=n||"",(n=t)||(n={}),u=window,t=i instanceof ri?i:ak(void 0!==i.href?i.href:String(i)),i=n.target||i.target,f=[],n)switch(r){case"width":case"height":case"top":case"left":f.push(r+"="+n[r]);break;case"target":case"noopener":case"noreferrer":break;default:f.push(r+"="+(n[r]?1:0))}if(r=f.join(","),(g("iPhone")&&!g("iPod")&&!g("iPad")||g("iPad")||g("iPod"))&&u.navigator&&u.navigator.standalone&&i&&"_self"!=i?(r=u.document.createElement("A"),t instanceof ri||t instanceof ri||(t=t.ma?t.la():String(t),ua.test(t)||(t="about:invalid#zClosurez"),t=ea(t)),r.href=as(t),r.setAttribute("target",i),n.noreferrer&&r.setAttribute("rel","noreferrer"),(n=document.createEvent("MouseEvent")).initMouseEvent("click",!0,!0,u,1),r.dispatchEvent(n),r={}):n.noreferrer?(r=u.open("",i,r),n=as(t),r&&(lut&&y(n,";")&&(n="'"+n.replace(/'/g,"%27")+"'"),r.opener=null,ie("b/12014412, meta tag with sanitized URL"),n=vs(n='<meta name="referrer" content="no-referrer"><meta http-equiv="refresh" content="0; url='+nl(n)+'">'),r.document.write(function(n){return n instanceof pu&&n.constructor===pu&&n.b===oa?n.a:(bf("expected object of type SafeHtml, got '"+n+"' of type "+uu(n)),"type_error:SafeHtml")}(n)),r.document.close())):(r=u.open(as(t),i,r))&&n.noopener&&(r.opener=null),r)try{r.focus()}catch(n){}return r}function la(){var n=null;return new l(function(t){"complete"==r.document.readyState?t():(n=function(){t()},wl(window,"load",n))}).s(function(t){throw pt(window,"load",n),t;})}function aa(n){return n=n||nt(),!("file:"!==fe()||!n.toLowerCase().match(/iphone|ipad|ipod|android/))}function va(){var n=r.window;try{return!(!n||n==n.top)}catch(n){return!1}}function yi(){return"object"!=typeof r.window&&"function"==typeof r.importScripts}function ui(){return h.INTERNAL.hasOwnProperty("reactNative")?"ReactNative":h.INTERNAL.hasOwnProperty("node")?"Node":yi()?"Worker":"Browser"}function nd(){var n=ui();return"ReactNative"===n||"Node"===n}function bu(n){var t=n.toLowerCase();return y(t,"opera/")||y(t,"opr/")||y(t,"opios/")?"Opera":y(t,"iemobile")?"IEMobile":y(t,"msie")||y(t,"trident/")?"IE":y(t,"edge/")?"Edge":y(t,"firefox/")?ys:y(t,"silk/")?"Silk":y(t,"blackberry")?"Blackberry":y(t,"webos")?"Webos":!y(t,"safari/")||y(t,"chrome/")||y(t,"crios/")||y(t,"android")?!y(t,"chrome/")&&!y(t,"crios/")||y(t,"edge/")?y(t,"android")?"Android":(n=n.match(/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/))&&2==n.length?n[1]:"Other":ya:"Safari"}function ku(n,t){t=t||[];var r,i=[],u={};for(r in pa)u[pa[r]]=!0;for(r=0;r<t.length;r++)void 0!==u[t[r]]&&(delete u[t[r]],i.push(t[r]));return i.sort(),(t=i).length||(t=["FirebaseCore-web"]),"Browser"===(i=ui())?i=bu(u=nt()):"Worker"===i&&(i=bu(u=nt())+"-"+i),i+"/JsCore/"+n+"/"+t.join(",")}function nt(){return r.navigator&&r.navigator.userAgent||""}function p(n,t){n=n.split(".");t=t||r;for(var i=0;i<n.length&&"object"==typeof t&&null!=t;i++)t=t[n[i]];return i!=n.length&&(t=void 0),t}function wa(){try{var n=r.localStorage,t=gu();if(n)return n.setItem(t,"1"),n.removeItem(t),!ca()||!!r.indexedDB}catch(n){return yi()&&!!r.indexedDB}return!1}function wr(){return(ue()||"chrome-extension:"===fe()||aa())&&!nd()&&wa()&&!yi()}function ue(){return"http:"===fe()||"https:"===fe()}function fe(){return r.location&&r.location.protocol||null}function ee(n){return!kk(n=n||nt())&&bu(n)!=ys}function oe(n){return void 0===n?null:yk(n)}function td(n){var t,i={};for(t in n)n.hasOwnProperty(t)&&null!==n[t]&&void 0!==n[t]&&(i[t]=n[t]);return i}function du(n){if(null!==n)return JSON.parse(n)}function gu(n){return n||Math.floor(1e9*Math.random()).toString()}function id(n){return"Safari"!=bu(n=n||nt())&&!n.toLowerCase().match(/iphone|ipad|ipod/)}function rd(){var n=r.___jsl,t,i;if(n&&n.H)for(t in n.H)if(n.H[t].r=n.H[t].r||[],n.H[t].L=n.H[t].L||[],n.H[t].r=n.H[t].L.concat(),n.CP)for(i=0;i<n.CP.length;i++)n.CP[i]=null}function gi(n,t){if(n>t)throw Error("Short delay should be less than long delay!");this.a=n;this.c=t;n=nt();t=ui();this.b=kk(n)||"ReactNative"===t}function ba(){var n=r.document;return!n||void 0===n.visibilityState||"visible"==n.visibilityState}function se(n){try{var t=new Date(parseInt(n,10));if(!isNaN(t.getTime())&&!/[^0-9]/.test(n))return t.toUTCString()}catch(n){}return null}function ud(){return!(!p("fireauth.oauthhelper",r)&&!p("fireauth.iframe",r))}function nr(n){da[n]||(da[n]=!0,"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn(n))}function f(n,t,i){ka?Object.defineProperty(n,t,{configurable:!0,enumerable:!0,value:i}):n[t]=i}function ht(n,t){if(t)for(var i in t)t.hasOwnProperty(i)&&f(n,i,t[i])}function pi(n){var t={};return ht(t,n),t}function ga(n){var t=n,i;if("object"==typeof n&&null!=n)for(i in t="length"in n?[]:{},n)f(t,i,ga(n[i]));return t}function i(n,t){this.code=nf+n;this.message=t||ed[n]||""}function fd(n){var t=n&&n.code;return t?new i(t.substring(nf.length),n.message):null}function nv(n){var t=n[vft],r,u;if(void 0===t)throw new i("missing-continue-uri");if("string"!=typeof t||"string"==typeof t&&!t.length)throw new i("invalid-continue-uri");if(this.h=t,this.b=this.a=null,this.g=!1,r=n[od],r&&"object"==typeof r)if(t=r[ld],u=r[hd],r=r[cd],"string"==typeof t&&t.length){if(this.a=t,void 0!==u&&"boolean"!=typeof u)throw new i("argument-error",hd+" property must be a boolean when specified.");if(this.g=!!u,void 0!==r&&("string"!=typeof r||"string"==typeof r&&!r.length))throw new i("argument-error",cd+" property must be a non empty string when specified.");this.b=r||null}else{if(void 0!==t)throw new i("argument-error",ld+" property must be a non empty string when specified.");if(void 0!==u||void 0!==r)throw new i("missing-android-pkg-name");}else if(void 0!==r)throw new i("argument-error",od+" property must be a non null object when specified.");if(this.f=null,(t=n[sd])&&"object"==typeof t){if("string"==typeof(t=t[ad])&&t.length)this.f=t;else if(void 0!==t)throw new i("argument-error",ad+" property must be a non empty string when specified.");}else if(void 0!==t)throw new i("argument-error",sd+" property must be a non null object when specified.");if(void 0!==(n=n[tv])&&"boolean"!=typeof n)throw new i("argument-error",tv+" property must be a boolean when specified.");this.c=!!n}function iv(n){var t={},i;for(i in t.continueUrl=n.h,t.canHandleCodeInApp=n.c,(t.androidPackageName=n.a)&&(t.androidMinimumVersion=n.b,t.androidInstallApp=n.g),t.iOSBundleId=n.f,t)null===t[i]&&delete t[i];return t}function yft(n){var t="";return function(n,t){function i(t){for(;r<n.length;){var i=n.charAt(r++),u=ce[i];if(null!=u)return u;if(!/^[\s\xa0]*$/.test(i))throw Error("Unknown base64 encoding at char: "+i);}return t}var r;for(!function(){if(!he){he={};ce={};for(var n=0;65>n;n++)he[n]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(n),ce[he[n]]=n,62<=n&&(ce["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.".charAt(n)]=n)}}(),r=0;;){var e=i(-1),o=i(0),u=i(64),f=i(64);if(64===f&&-1===e)break;t(e<<2|o>>4);64!=u&&(t(o<<4&240|u>>2),64!=f&&t(u<<6&192|f))}}(n,function(n){t+=String.fromCharCode(n)}),t}function vd(n){this.c=n.sub;this.a=n.provider_id||n.firebase&&n.firebase.sign_in_provider||null;this.b=!!n.is_anonymous||"anonymous"==this.a}function yd(n){return(n=pd(n))&&n.sub&&n.iss&&n.aud&&n.exp?new vd(n):null}function pd(n){if(!n||3!=(n=n.split(".")).length)return null;for(var i=(4-(n=n[1]).length%4)%4,t=0;t<i;t++)n+=".";try{return JSON.parse(yft(n))}catch(n){}return null}function uv(n){for(var t in rv)if(rv[t].Na==n)return rv[t];return null}function fv(n){var t={},i;t["facebook.com"]=bd;t["google.com"]=dd;t["github.com"]=kd;t["twitter.com"]=gd;i=n&&n[ev];try{if(i)return t[i]?new t[i](n):new fi(n);if(void 0!==n[bs])return new ov(n)}catch(n){}return null}function ov(n){var i=n[ev],t;if(!i&&n[bs]&&(t=yd(n[bs]),t&&t.a&&(i=t.a)),!i)throw Error("Invalid additional user info!");"anonymous"!=i&&"custom"!=i||(i=null);t=!1;void 0!==n.isNewUser?t=!!n.isNewUser:"identitytoolkit#SignupNewUserResponse"===n.kind&&(t=!0);f(this,"providerId",i);f(this,"isNewUser",t)}function fi(n){ov.call(this,n);f(this,"profile",ga((n=du(n.rawUserInfo||"{}"))||{}))}function bd(n){if(fi.call(this,n),"facebook.com"!=this.providerId)throw Error("Invalid provider ID!");}function kd(n){if(fi.call(this,n),"github.com"!=this.providerId)throw Error("Invalid provider ID!");f(this,"username",this.profile&&this.profile.login||null)}function dd(n){if(fi.call(this,n),"google.com"!=this.providerId)throw Error("Invalid provider ID!");}function gd(n){if(fi.call(this,n),"twitter.com"!=this.providerId)throw Error("Invalid provider ID!");f(this,"username",n.screenName||null)}function ng(n){var t=ai(n),i=ki(t,"link"),r=ki(ai(i),"link");return ki(ai(t=ki(t,"deep_link_id")),"link")||t||r||i||n}function ks(n,t){return n.then(function(n){if(n[kt]){var r=yd(n[kt]);if(!r||t!=r.c)throw new i("user-mismatch");return n}throw new i("user-mismatch");}).s(function(n){throw n&&n.code&&n.code==nf+"user-not-found"?new i("user-mismatch"):n;})}function tf(n,t,r){if(t.idToken||t.accessToken)t.idToken&&f(this,"idToken",t.idToken),t.accessToken&&f(this,"accessToken",t.accessToken);else{if(!t.oauthToken||!t.oauthTokenSecret)throw new i("internal-error","failed to construct a credential");f(this,"accessToken",t.oauthToken);f(this,"secret",t.oauthTokenSecret)}f(this,"providerId",n);f(this,"signInMethod",r)}function sv(n){var t={};return n.idToken&&(t.id_token=n.idToken),n.accessToken&&(t.access_token=n.accessToken),n.secret&&(t.oauth_token_secret=n.secret),t.providerId=n.providerId,{postBody:fk(t).toString(),requestUri:"http://localhost"}}function le(n,t){this.Ac=t||[];ht(this,{providerId:n,isOAuthProvider:!0});this.vb={};this.$a=(uv(n)||{}).Ma||null;this.Ya=null}function lt(n){le.call(this,n,ws);this.a=[]}function br(){lt.call(this,"facebook.com")}function tg(n){if(!n)throw new i("argument-error","credential failed: expected 1 argument (the OAuth access token).");var t=n;return vt(n)&&(t=n.accessToken),(new br).credential(null,t)}function kr(){lt.call(this,"github.com")}function ig(n){if(!n)throw new i("argument-error","credential failed: expected 1 argument (the OAuth access token).");var t=n;return vt(n)&&(t=n.accessToken),(new kr).credential(null,t)}function dr(){lt.call(this,"google.com");this.ta("profile")}function rg(n,t){var i=n;return vt(n)&&(i=n.idToken,t=n.accessToken),(new dr).credential(i,t)}function rf(){le.call(this,"twitter.com",wd)}function ug(n,t){var r=n;if(vt(r)||(r={oauthToken:n,oauthTokenSecret:t}),!r.oauthToken||!r.oauthTokenSecret)throw new i("argument-error","credential failed: expected 2 arguments (the OAuth access token and secret).");return new tf("twitter.com",r,"twitter.com")}function uf(n,t,i){this.a=n;this.b=t;f(this,"providerId","password");f(this,"signInMethod",i===wt.EMAIL_LINK_SIGN_IN_METHOD?wt.EMAIL_LINK_SIGN_IN_METHOD:wt.EMAIL_PASSWORD_SIGN_IN_METHOD)}function wt(){ht(this,{providerId:"password",isOAuthProvider:!1})}function fg(n,t){if(!(t=eg(t)))throw new i("argument-error","Invalid email link!");return new uf(n,t,wt.EMAIL_LINK_SIGN_IN_METHOD)}function eg(n){var t=ki((n=new function(n){this.a=ai(n)}(n=ng(n))).a,"oobCode")||null;return"signIn"===(ki(n.a,"mode")||null)&&t?t:null}function ff(n){if(!(n.Sa&&n.Ra||n.Fa&&n.$))throw new i("internal-error");this.a=n;f(this,"providerId","phone");f(this,"signInMethod","phone")}function hv(n){return n.a.Fa&&n.a.$?{temporaryProof:n.a.Fa,phoneNumber:n.a.$}:{sessionInfo:n.a.Sa,code:n.a.Ra}}function tr(n){try{this.a=n||h.auth()}catch(n){throw new i("argument-error","Either an instance of firebase.auth.Auth must be passed as an argument to the firebase.auth.PhoneAuthProvider constructor, or the default firebase App instance must be initialized via firebase.initializeApp().");}ht(this,{providerId:"phone",isOAuthProvider:!1})}function og(n,t){if(!n)throw new i("missing-verification-id");if(!t)throw new i("missing-verification-code");return new ff({Sa:n,Ra:t})}function ds(n){var i,t,r;if(n.temporaryProof&&n.phoneNumber)return new ff({Fa:n.temporaryProof,$:n.phoneNumber});if(i=n&&n.providerId,!i||"password"===i)return null;t=n&&n.oauthAccessToken;r=n&&n.oauthTokenSecret;n=n&&n.oauthIdToken;try{switch(i){case"google.com":return rg(n,t);case"facebook.com":return tg(t);case"github.com":return ig(t);case"twitter.com":return ug(t,r);default:return new lt(i).credential(n,t)}}catch(n){return null}}function cv(n){if(!n.isOAuthProvider)throw new i("invalid-oauth-provider");}function wi(n,t,r,u,f){if(this.b=n,this.c=t||null,this.f=r||null,this.g=u||null,this.a=f||null,!this.f&&!this.a)throw new i("invalid-auth-event");if(this.f&&this.a)throw new i("invalid-auth-event");if(this.f&&!this.g)throw new i("invalid-auth-event");}function sg(n){return(n=n||{}).type?new wi(n.type,n.eventId,n.urlResponse,n.sessionId,n.error&&fd(n.error)):null}function lv(){this.b=null;this.a=[]}function av(n){var u="unauthorized-domain",r=void 0,t=ai(n);n=t.b;"chrome-extension"==(t=t.c)?r=yw("This chrome extension ID (chrome-extension://%s) is not authorized to run this operation. Add it to the OAuth redirect domains list in the Firebase console -> Auth section -> Sign in method tab.",n):"http"==t||"https"==t?r=yw("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.",n):u="operation-not-supported-in-this-environment";i.call(this,u,r)}function ae(n,t,r){i.call(this,n,r);(n=t||{}).wb&&f(this,"email",n.wb);n.$&&f(this,"phoneNumber",n.$);n.credential&&f(this,"credential",n.credential)}function nh(n){var t,r;if(n.code){if(t=n.code||"",0==t.indexOf(nf)&&(t=t.substring(nf.length)),r={credential:ds(n)},n.email)r.wb=n.email;else{if(!n.phoneNumber)return new i(t,n.message||void 0);r.$=n.phoneNumber}return new ae(t,r,n.message)}return null}function ve(){}function cg(n){return n.c||(n.c=n.b())}function th(){}function lg(n){var i,t,r;if(!n.f&&"undefined"==typeof XMLHttpRequest&&"undefined"!=typeof ActiveXObject){for(i=["MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"],t=0;t<i.length;t++){r=i[t];try{return new ActiveXObject(r),n.f=r}catch(n){}}throw Error("Could not create ActiveXObject. ActiveX might be disabled, or MSXML might not be installed");}return n.f}function ih(){}function ag(){this.a=new XDomainRequest;this.readyState=0;this.onreadystatechange=null;this.responseText="";this.status=-1;this.statusText="";this.a.onload=o(this.bc,this);this.a.onerror=o(this.Bb,this);this.a.onprogress=o(this.cc,this);this.a.ontimeout=o(this.fc,this)}function yv(n,t){n.readyState=t;n.onreadystatechange&&n.onreadystatechange()}function pv(n,t,i){this.reset(n,t,i,void 0,void 0)}function wv(n){this.f=n;this.b=this.c=this.a=null}function ye(n,t){this.name=n;this.value=t}function kv(n){var i,t,r;return(pe||(pe=new wv(""),rh[""]=pe,pe.c=pft),i=rh[n])||(i=new wv(n),t=n.lastIndexOf("."),r=n.substr(t+1),(t=kv(n.substr(0,t))).b||(t.b={}),t.b[r]=i,i.a=t,rh[n]=i),i}function bt(n,t){n&&n.log(wft,t,void 0)}function uh(n){this.f=n}function dv(n){ft.call(this);this.i=n;this.readyState=fh;this.status=0;this.responseText=this.statusText="";this.onreadystatechange=null;this.g=new Headers;this.b=null;this.h="GET";this.c="";this.a=!1;this.f=kv("goog.net.FetchXmlHttp")}function ef(n){n.onreadystatechange&&n.onreadystatechange.call(n)}function we(n){ft.call(this);this.headers=new cu;this.C=n||null;this.c=!1;this.w=this.a=null;this.h=this.N=this.l="";this.f=this.I=this.i=this.G=!1;this.g=0;this.u=null;this.o=gv;this.v=this.O=!1}function bft(n,t,i,u,f){if(n.a)throw Error("[goog.net.XhrIo] Object is active with another request="+n.l+"; newUri="+t);i=i?i.toUpperCase():"GET";n.l=t;n.h="";n.N=i;n.G=!1;n.c=!0;n.a=n.C?n.C.a():vv.a();n.w=n.C?cg(n.C):cg(vv);n.a.onreadystatechange=o(n.Fb,n);try{bt(n.b,bi(n,"Opening Xhr"));n.I=!0;n.a.open(i,String(t),!0);n.I=!1}catch(t){return bt(n.b,bi(n,"Error opening Xhr: "+t.message)),void wg(n,t)}t=u||"";var e=new cu(n.headers);f&&function(n,t){if(n.forEach&&"function"==typeof n.forEach)n.forEach(t,void 0);else if(wf(n)||b(n))st(n,t,void 0);else for(var r=nk(n),u=gb(n),f=u.length,i=0;i<f;i++)t.call(void 0,u[i],r&&r[i],n)}(f,function(n,t){e.set(t,n)});f=function(n){n:{for(var t=kft,u=n.length,r=b(n)?n.split(""):n,i=0;i<u;i++)if(i in r&&t.call(void 0,r[i],i,n)){t=i;break n}t=-1}return 0>t?null:b(n)?n.charAt(t):n[t]}(e.U());u=r.FormData&&t instanceof r.FormData;!or(pg,i)||f||u||e.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");e.forEach(function(n,t){this.a.setRequestHeader(t,n)},n);n.o&&(n.a.responseType=n.o);"withCredentials"in n.a&&n.a.withCredentials!==n.O&&(n.a.withCredentials=n.O);try{dg(n);0<n.g&&(n.v=function(n){return gt&&cb(9)&&"number"==typeof n.timeout&&void 0!==n.ontimeout}(n.a),bt(n.b,bi(n,"Will abort after "+n.g+"ms if incomplete, xhr2 "+n.v)),n.v?(n.a.timeout=n.g,n.a.ontimeout=o(n.Ga,n)):n.u=dl(n.Ga,n.g,n));bt(n.b,bi(n,"Sending request"));n.i=!0;n.a.send(t);n.i=!1}catch(t){bt(n.b,bi(n,"Send error: "+t.message));wg(n,t)}}function kft(n){return"content-type"==n.toLowerCase()}function wg(n,t){n.c=!1;n.a&&(n.f=!0,n.a.abort(),n.f=!1);n.h=t;bg(n);eh(n)}function bg(n){n.G||(n.G=!0,n.dispatchEvent("complete"),n.dispatchEvent("error"))}function kg(n){var i,u,f,e,t,o,s;if(n.c&&void 0!==vc)if(n.w[1]&&4==be(n)&&2==oh(n))bt(n.b,bi(n,"Local request error detected and ignored"));else if(n.i&&4==be(n))dl(n.Fb,0,n);else if(n.dispatchEvent("readystatechange"),4==be(n)){bt(n.b,bi(n,"Request complete"));n.c=!1;try{u=oh(n);n:switch(u){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:f=!0;break n;default:f=!1}if((i=f)||((e=0===u)&&(t=String(n.l).match(na)[1]||null,!t&&r.self&&r.self.location&&(o=r.self.location.protocol,t=o.substr(0,o.length-1)),e=!yg.test(t?t.toLowerCase():"")),i=e),i)n.dispatchEvent("complete"),n.dispatchEvent("success");else{try{s=2<be(n)?n.a.statusText:""}catch(i){bt(n.b,"Can not get status: "+i.message);s=""}n.h=s+" ["+oh(n)+"]";bg(n)}}finally{eh(n)}}}function eh(n,t){if(n.a){dg(n);var i=n.a,r=n.w[0]?ti:null;n.a=null;n.w=null;t||n.dispatchEvent("ready");try{i.onreadystatechange=r}catch(t){(n=n.b)&&n.log(vg,"Problem encountered resetting onreadystatechange: "+t.message,void 0)}}}function dg(n){n.a&&n.v&&(n.a.ontimeout=null);n.u&&(r.clearTimeout(n.u),n.u=null)}function be(n){return n.a?n.a.readyState:0}function oh(n){try{return 2<be(n)?n.a.status:-1}catch(n){return-1}}function bi(n,t){return t+" ["+n.N+" "+n.l+" "+oh(n)+"]"}function ir(n,t){this.g=[];this.v=n;this.u=t||null;this.f=this.a=!1;this.c=void 0;this.l=this.w=this.i=!1;this.h=0;this.b=null;this.m=0}function ke(n,t,i){n.a=!0;n.c=i;n.f=!t;nn(n)}function sh(n){if(n.a){if(!n.l)throw new hh(n);n.l=!1}}function ny(n,t,i,r){n.g.push([t,i,r]);n.a&&nn(n)}function gg(n){return iut(n.g,function(n){return ut(n[1])})}function nn(n){var t,f,u,i;for(n.h&&n.a&&gg(n)&&(t=n.h,f=ge[t],f&&(r.clearTimeout(f.a),delete ge[t]),n.h=0),n.b&&(n.b.m--,delete n.b),t=n.c,u=f=!1;n.g.length&&!n.i;){var e=n.g.shift(),s=e[0],h=e[1];if(e=e[2],s=n.f?h:s)try{i=s.call(e||n.u,t);void 0!==i&&(n.f=n.f&&(i==t||i instanceof Error),n.c=t=i);(cw(t)||"function"==typeof r.Promise&&t instanceof r.Promise)&&(u=!0,n.i=!0)}catch(u){t=u;n.f=!0;gg(n)||(f=!0)}}n.c=t;u&&(i=o(n.o,n,!0),u=o(n.o,n,!1),t instanceof ir?(ny(t,i,u),t.w=!0):t.then(i,u));f&&(t=new tn(t),ge[t.a]=t,n.h=t.a)}function hh(){ct.call(this)}function de(){ct.call(this)}function tn(n){this.a=r.setTimeout(o(this.c,this),0);this.b=n}function ty(n){var r={},s=r.document||document,e=ck(n),t=document.createElement("SCRIPT"),u={Hb:t,Ga:void 0},i=new ir(dft,u),f=null,o=null!=r.timeout?r.timeout:5e3;return 0<o&&(f=window.setTimeout(function(){ch(t,!0);var n=new iy(un,"Timeout reached for loading script "+e);sh(i);ke(i,!1,n)},o),u.Ga=f),t.onload=t.onreadystatechange=function(){t.readyState&&"loaded"!=t.readyState&&"complete"!=t.readyState||(ch(t,r.dd||!1,f),i.C())},t.onerror=function(){ch(t,!0,f);var n=new iy(rn,"Error while loading script "+e);sh(i);ke(i,!1,n)},hi(u=r.attributes||{},{type:"text/javascript",charset:"UTF-8"}),vk(t,u),t.src=ck(n),function(n){var t;return(t=(n||document).getElementsByTagName("HEAD"))&&0!=t.length?t[0]:n.documentElement}(s).appendChild(t),i}function dft(){if(this&&this.Hb){var n=this.Hb;n&&"SCRIPT"==n.tagName&&ch(n,!0,this.Ga)}}function ch(n,t,i){null!=i&&r.clearTimeout(i);n.onload=ti;n.onerror=ti;n.onreadystatechange=ti;t&&window.setTimeout(function(){n&&n.parentNode&&n.parentNode.removeChild(n)},0)}function iy(n,t){var i="Jsloader error (code #"+n+")";t&&(i+=": "+t);ct.call(this,i);this.code=n}function lh(n){this.f=n}function ei(n,t,u){if(this.b=n,n=t||{},this.i=n.secureTokenEndpoint||"https://securetoken.googleapis.com/v1/token",this.m=n.secureTokenTimeout||gft,this.f=df(n.secureTokenHeaders||net),this.g=n.firebaseEndpoint||"https://www.googleapis.com/identitytoolkit/v3/relyingparty/",this.h=n.firebaseTimeout||tet,this.a=df(n.firebaseHeaders||iet),u&&(this.a["X-Client-Version"]=u,this.f["X-Client-Version"]=u),u="Node"==ui(),!(u=r.XMLHttpRequest||u&&h.INTERNAL.node&&h.INTERNAL.node.XMLHttpRequest)&&!yi())throw new i("internal-error","The XMLHttpRequest compatibility library was not found.");this.c=void 0;this.c=yi()?new uh(self):nd()?new lh(u):new ih}function fn(n,t){t?n.a["X-Firebase-Locale"]=t:delete n.a["X-Firebase-Locale"]}function en(n,t){t?(n.a["X-Client-Version"]=t,n.f["X-Client-Version"]=t):(delete n.a["X-Client-Version"],delete n.f["X-Client-Version"])}function on(n,t,i,u,f,e,s){(function(){var n=nt();return!((n=bu(n)!=ya?null:(n=n.match(/\sChrome\/(\d+)/i))&&2==n.length?parseInt(n[1],10):null)&&30>n||gt&&li&&!(9<li))})()||yi()?n=o(n.o,n):(ry||(ry=new l(function(n,t){!function(n,t){if(((window.gapi||{}).client||{}).request)n();else{r[uy]=function(){((window.gapi||{}).client||{}).request?n():t(Error("CORS_UNSUPPORTED"))};var i=ra(sn,{onload:uy});!function(n,t){ny(n,null,t,void 0)}(ty(i),function(){t(Error("CORS_UNSUPPORTED"))})}}(n,t)})),n=o(n.l,n));n(t,i,u,f,e,s)}function gr(n){if(!hg.test(n.email))throw new i("invalid-email");}function hn(n){"email"in n&&gr(n)}function oi(n){if(!n[kt])throw new i("internal-error");}function fy(n){if(n.phoneNumber||n.temporaryProof){if(!n.phoneNumber||!n.temporaryProof)throw new i("internal-error");}else{if(!n.sessionInfo)throw new i("missing-verification-id");if(!n.code)throw new i("missing-verification-code");}}function ey(n){if(!n.requestUri||!n.sessionId&&!n.postBody)throw new i("internal-error");}function ln(n){var t=null;if(n.needConfirmation?(n.code="account-exists-with-different-credential",t=nh(n)):"FEDERATED_USER_ID_ALREADY_LINKED"==n.errorMessage?(n.code="credential-already-in-use",t=nh(n)):"EMAIL_EXISTS"==n.errorMessage?(n.code="email-already-in-use",t=nh(n)):n.errorMessage&&(t=dn(n.errorMessage)),t)throw t;if(!n[kt])throw new i("internal-error");}function an(n,t){return t.returnIdpCredential=!0,a(n,get,t)}function vn(n,t){return t.returnIdpCredential=!0,a(n,tot,t)}function yn(n,t){return t.returnIdpCredential=!0,t.autoCreate=!1,a(n,not,t)}function oy(n){if(!n.oobCode)throw new i("invalid-action-code");}function a(n,t,r){if(!function(n,t){var i,r;if(!t||!t.length)return!0;if(!n)return!1;for(i=0;i<t.length;i++)if(r=n[t[i]],void 0===r||null===r||""===r)return!1;return!0}(r,t.T))return k(new i("internal-error"));var u,f=t.Eb||"POST";return e(r).then(t.B).then(function(){return t.R&&(r.returnSecureToken=!0),function(n,t,r,u,f,e){var o=ai(n.g+t),h,s;if(d(o,"key",n.b),e&&d(o,"cb",fu().toString()),h="GET"==r,h)for(s in u)u.hasOwnProperty(s)&&d(o,s,u[s]);return new l(function(t,e){on(n,o.toString(),function(n){n?n.error?e(sy(n,f||{})):t(n):e(new i("network-request-failed"))},r,h?void 0:yk(td(u)),n.a,n.h.get())})}(n,t.endpoint,f,r,t.Tb,t.rb||!1)}).then(function(n){return u=n}).then(t.J).then(function(){if(!t.da)return u;if(!(t.da in u))throw new i("internal-error");return u[t.da]})}function dn(n){return sy({error:{errors:[{message:n}],code:400,message:n}})}function sy(n,t){var r=(n.error&&n.error.errors&&n.error.errors[0]||{}).reason||"",u={keyInvalid:"invalid-api-key",ipRefererBlocked:"app-not-authorized"},f;if(r=u[r]?new i(u[r]):null)return r;for(f in r=n.error&&n.error.message||"",hi(u={INVALID_CUSTOM_TOKEN:"invalid-custom-token",CREDENTIAL_MISMATCH:"custom-token-mismatch",MISSING_CUSTOM_TOKEN:"internal-error",INVALID_IDENTIFIER:"invalid-email",MISSING_CONTINUE_URI:"internal-error",INVALID_EMAIL:"invalid-email",INVALID_PASSWORD:"wrong-password",USER_DISABLED:"user-disabled",MISSING_PASSWORD:"internal-error",EMAIL_EXISTS:"email-already-in-use",PASSWORD_LOGIN_DISABLED:"operation-not-allowed",INVALID_IDP_RESPONSE:"invalid-credential",FEDERATED_USER_ID_ALREADY_LINKED:"credential-already-in-use",INVALID_MESSAGE_PAYLOAD:"invalid-message-payload",INVALID_RECIPIENT_EMAIL:"invalid-recipient-email",INVALID_SENDER:"invalid-sender",EMAIL_NOT_FOUND:"user-not-found",EXPIRED_OOB_CODE:"expired-action-code",INVALID_OOB_CODE:"invalid-action-code",MISSING_OOB_CODE:"internal-error",CREDENTIAL_TOO_OLD_LOGIN_AGAIN:"requires-recent-login",INVALID_ID_TOKEN:"invalid-user-token",TOKEN_EXPIRED:"user-token-expired",USER_NOT_FOUND:"user-token-expired",CORS_UNSUPPORTED:"cors-unsupported",DYNAMIC_LINK_NOT_ACTIVATED:"dynamic-link-not-activated",INVALID_APP_ID:"invalid-app-id",TOO_MANY_ATTEMPTS_TRY_LATER:"too-many-requests",WEAK_PASSWORD:"weak-password",OPERATION_NOT_ALLOWED:"operation-not-allowed",USER_CANCELLED:"user-cancelled",CAPTCHA_CHECK_FAILED:"captcha-check-failed",INVALID_APP_CREDENTIAL:"invalid-app-credential",INVALID_CODE:"invalid-verification-code",INVALID_PHONE_NUMBER:"invalid-phone-number",INVALID_SESSION_INFO:"invalid-verification-id",INVALID_TEMPORARY_PROOF:"invalid-credential",MISSING_APP_CREDENTIAL:"missing-app-credential",MISSING_CODE:"missing-verification-code",MISSING_PHONE_NUMBER:"missing-phone-number",MISSING_SESSION_INFO:"missing-verification-id",QUOTA_EXCEEDED:"quota-exceeded",SESSION_EXPIRED:"code-expired",INVALID_CONTINUE_URI:"invalid-continue-uri",MISSING_ANDROID_PACKAGE_NAME:"missing-android-pkg-name",MISSING_IOS_BUNDLE_ID:"missing-ios-bundle-id",UNAUTHORIZED_DOMAIN:"unauthorized-continue-uri",INVALID_OAUTH_CLIENT_ID:"invalid-oauth-client-id",INVALID_CERT_HASH:"invalid-cert-hash"},t||{}),t=(t=r.match(/^[^\s]+\s*:\s*(.*)$/))&&1<t.length?t[1]:void 0,u)if(0===r.indexOf(f))return new i(u[f],t);return!t&&n&&(t=oe(n)),new i("internal-error",t)}function to(n){for(var t in ah)if(ah[t].id===n)return{firebaseEndpoint:(n=ah[t]).Za,secureTokenEndpoint:n.fb};return null}function eot(n){this.b=n;this.a=null;this.bb=function(n){return(cy||(cy=new l(function(n,t){function u(){rd();p("gapi.load")("gapi.iframes",{callback:n,ontimeout:function(){rd();t(Error("Network Error"))},timeout:sot.get()})}if(p("gapi.iframes.Iframe"))n();else if(p("gapi.load"))u();else{var i="__iframefcb"+Math.floor(1e6*Math.random()).toString();r[i]=function(){p("gapi.load")?u():t(Error("Network Error"))};e(ty(i=ra(oot,{onload:i}))).s(function(){t(Error("Network Error"))})}}).s(function(n){throw cy=null,n;}))).then(function(){return new l(function(t,i){p("gapi.iframes.getContext")().open({where:document.body,url:n.b,messageHandlersFilter:p("gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER"),attributes:{style:{position:"absolute",top:"-100px",width:"1px",height:"1px"}},dontclear:!0},function(r){function u(){clearTimeout(f);t()}n.a=r;n.a.restyle({setHideOnLeave:!1});var f=setTimeout(function(){i(Error("Network Error"))},hot.get());r.ping(u).then(u,function(){i(Error("Network Error"))})})})})}(this)}function gn(n,t,i){this.i=n;this.g=t;this.h=i;this.f=null;this.a=rk(this.i,"/__/auth/iframe");d(this.a,"apiKey",this.g);d(this.a,"appName",this.h);this.b=null;this.c=[]}function ntt(n,t,i,r,u){this.o=n;this.l=t;this.c=i;this.m=r;this.h=this.g=this.i=null;this.a=u;this.f=null}function ly(n){try{return h.app(n).auth().xa()}catch(n){return[]}}function ttt(n,t,i,r,u){this.l=n;this.f=t;this.b=i;this.c=r||null;this.h=u||null;this.o=this.u=this.v=null;this.g=[];this.m=this.a=null}function itt(n){var t=wu();return function(n){return a(n,pet,{}).then(function(n){return n.authorizedDomains||[]})}(n).then(function(n){var u,o,f;n:{for(u=ai(t),o=u.c,u=u.b,f=0;f<n.length;f++){var i=n[f],r=u,e=o;if(0==i.indexOf("chrome-extension://")?r=ai(i).b==r&&"chrome-extension"==e:"http"!=e&&"https"!=e?r=!1:gk.test(i)?r=r==i:(i=i.split(".").join("\\."),r=new RegExp("^(.+\\."+i+"|"+i+")$","i").test(r)),r){n=!0;break n}}n=!1}if(!n)throw new av(wu());})}function rtt(n){return n.m?n.m:(n.m=la().then(function(){if(!n.u){var i=n.c,r=n.h,u=ly(n.b),t=new gn(n.l,n.f,n.b);t.f=i;t.b=r;t.c=sr(u||[]);n.u=t.toString()}n.i=new eot(n.u),function(n){if(!n.i)throw Error("IfcHandler must be initialized!");!function(n,t){n.bb.then(function(){n.a.register("authEvent",t,p("gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER"))})}(n.i,function(t){var i={},r;if(t&&t.authEvent){for(r=!1,t=sg(t.authEvent),i=0;i<n.g.length;i++)r=n.g[i](t)||r;return(i={}).status=r?"ACK":"ERROR",e(i)}return i.status="ERROR",e(i)})}(n)}),n.m)}function utt(n){return n.o||(n.v=n.c?ku(n.c,ly(n.b)):null,n.o=new ei(n.f,to(n.h),n.v)),n.o}function io(n,t,i,r,u,f,e,o,s,h){return(n=new ntt(n,t,i,r,u)).i=f,n.g=e,n.h=o,n.b=df(s||null),n.f=h,n.toString()}function ftt(n){if(this.a=n||h.INTERNAL.reactNative&&h.INTERNAL.reactNative.AsyncStorage,!this.a)throw new i("internal-error","The React Native compatibility library was not found.");this.type="asyncStorage"}function ett(){if(!stt())throw new i("web-storage-unsupported");this.f={};this.a=[];this.b=0;this.g=r.indexedDB;this.type="indexedDB"}function ott(n){return new l(function(t,i){var r=n.g.open("firebaseLocalStorageDb",1);r.onerror=function(n){try{n.preventDefault()}catch(n){}i(Error(n.target.error))};r.onupgradeneeded=function(n){n=n.target.result;try{n.createObjectStore("firebaseLocalStorage",{keyPath:"fbase_key"})}catch(n){i(n)}};r.onsuccess=function(r){(r=r.target.result).objectStoreNames.contains("firebaseLocalStorage")?t(r):function(n){return new l(function(t,i){var r=n.g.deleteDatabase("firebaseLocalStorageDb");r.onsuccess=function(){t()};r.onerror=function(n){i(Error(n.target.error))}})}(n).then(function(){return ott(n)}).then(function(n){t(n)}).s(function(n){i(n)})}})}function vh(n){return n.h||(n.h=ott(n)),n.h}function stt(){try{return!!r.indexedDB}catch(n){return!1}}function ro(n){return n.objectStore("firebaseLocalStorage")}function uo(n,t){return n.transaction(["firebaseLocalStorage"],t?"readwrite":"readonly")}function of(n){return new l(function(t,i){n.onsuccess=function(n){n&&n.target?t(n.target.result):t()};n.onerror=function(n){i(Error(n.target.errorCode))}})}function htt(n){var t=this,i=null;this.a=[];this.type="indexedDB";this.c=n;this.b=e().then(function(){return stt()?(hy||(hy=new ett),(i=hy).set("__sak","!").then(function(){return i.get("__sak")}).then(function(n){if("!"!==n)throw Error("indexedDB not supported!");return i.P("__sak")}).then(function(){return i}).s(function(){return t.c})):t.c}).then(function(n){return t.type=n.type,n.Y(function(n){st(t.a,function(t){t(n)})}),n})}function fo(){this.a={};this.type="inMemory"}function yh(){if(!function(){var n="Node"==ui();if(!(n=ctt()||n&&h.INTERNAL.node&&h.INTERNAL.node.localStorage))return!1;try{return n.setItem("__sak","1"),n.removeItem("__sak"),!0}catch(n){return!1}}()){if("Node"==ui())throw new i("internal-error","The LocalStorage compatibility library was not found.");throw new i("web-storage-unsupported");}this.a=ctt()||h.INTERNAL.node.localStorage;this.type="localStorage"}function ctt(){try{var n=r.localStorage,t=gu();return n&&(n.setItem(t,"1"),n.removeItem(t)),n}catch(n){return null}}function ay(){this.type="nullStorage"}function vy(){if(!function(){var n="Node"==ui();if(!(n=ltt()||n&&h.INTERNAL.node&&h.INTERNAL.node.sessionStorage))return!1;try{return n.setItem("__sak","1"),n.removeItem("__sak"),!0}catch(n){return!1}}()){if("Node"==ui())throw new i("internal-error","The SessionStorage compatibility library was not found.");throw new i("web-storage-unsupported");}this.a=ltt()||h.INTERNAL.node.sessionStorage;this.type="sessionStorage"}function ltt(){try{var n=r.sessionStorage,t=gu();return n&&(n.setItem(t,"1"),n.removeItem(t)),n}catch(n){return null}}function att(){var n=!(id(nt())||!va()),t=ee(),i=wa();this.o=n;this.h=t;this.m=i;this.a={};yy||(yy=new function(){var n={};n.Browser=cot;n.Node=lot;n.ReactNative=aot;n.Worker=vot;this.a=n[ui()]});n=yy;try{this.g=!ca()&&ud()||!r.indexedDB?new n.a.A:new htt(yi()?new fo:new n.a.A)}catch(n){this.g=new fo;this.h=!0}try{this.i=new n.a.Qa}catch(n){this.i=new fo}this.l=new fo;this.f=o(this.Lb,this);this.b={}}function eo(){return py||(py=new att),py}function nu(n,t){switch(t){case"session":return n.i;case"none":return n.l;default:return n.g}}function hf(n,t){return"firebase:"+n.name+(t?":"+t:"")}function cf(n,t,i){return i=hf(t,i),"local"==t.A&&(n.b[i]=null),nu(n,t.A).P(i)}function wy(n){n.c&&(clearInterval(n.c),n.c=null)}function wh(n,t){this.b=-1;this.b=vtt;this.f=r.Uint8Array?new Uint8Array(this.b):Array(this.b);this.g=this.c=0;this.a=[];this.i=n;this.h=t;this.m=r.Int32Array?new Int32Array(64):Array(64);void 0!==by||(by=r.Int32Array?new Int32Array(tp):tp);this.reset()}function gy(n){for(var e,o,a,i=n.f,f=n.m,t=0,r=0;r<i.length;)f[t++]=i[r]<<24|i[r+1]<<16|i[r+2]<<8|i[r+3],r=4*t;for(i=16;64>i;i++)r=0|f[i-15],t=0|f[i-2],e=(0|f[i-16])+((r>>>7|r<<25)^(r>>>18|r<<14)^r>>>3)|0,o=(0|f[i-7])+((t>>>17|t<<15)^(t>>>19|t<<13)^t>>>10)|0,f[i]=e+o|0;t=0|n.a[0];r=0|n.a[1];var s=0|n.a[2],l=0|n.a[3],u=0|n.a[4],h=0|n.a[5],c=0|n.a[6];for(e=0|n.a[7],i=0;64>i;i++)a=((t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10))+(t&r^t&s^r&s)|0,o=(e=e+((u>>>6|u<<26)^(u>>>11|u<<21)^(u>>>25|u<<7))|0)+((o=(o=u&h^~u&c)+(0|by[i])|0)+(0|f[i])|0)|0,e=c,c=h,h=u,u=l+o|0,l=s,s=r,r=t,t=o+a|0;n.a[0]=n.a[0]+t|0;n.a[1]=n.a[1]+r|0;n.a[2]=n.a[2]+s|0;n.a[3]=n.a[3]+l|0;n.a[4]=n.a[4]+u|0;n.a[5]=n.a[5]+h|0;n.a[6]=n.a[6]+c|0;n.a[7]=n.a[7]+e|0}function np(n,t,i){var f,r,u;if(void 0===i&&(i=t.length),f=0,r=n.c,b(t))for(;f<i;)n.f[r++]=t.charCodeAt(f++),r==n.b&&(gy(n),r=0);else{if(!wf(t))throw Error("message must be string or array");for(;f<i;){if(u=t[f++],!("number"==typeof u&&0<=u&&255>=u&&u==(0|u)))throw Error("message must be a byte array");n.f[r++]=u;r==n.b&&(gy(n),r=0)}}n.c=r;n.g+=i}function ptt(){wh.call(this,8,wtt)}function btt(n,t,i,r,u){this.l=n;this.i=t;this.m=i;this.o=r||null;this.u=u||null;this.h=t+":"+i;this.v=new function(){this.a=eo()};this.g=new function(n){this.a=n;this.b=eo()}(this.h);this.f=null;this.b=[];this.a=this.c=null}function bh(n){return new i("invalid-cordova-configuration",n)}function pot(n){var t=new ptt,r,i,u;for(np(t,n),n=[],r=8*t.g,56>t.c?np(t,dy,56-t.c):np(t,dy,t.b-(t.c-56)),i=63;56<=i;i--)t.f[i]=255&r,r/=256;for(gy(t),i=r=0;i<t.i;i++)for(u=24;0<=u;u-=8)n[r++]=t.a[i]>>u&255;return function(n){return kc(n,function(n){return 1<(n=n.toString(16)).length?n:"0"+n}).join("")}(n)}function ktt(n,t){for(var i=0;i<n.b.length;i++)try{n.b[i](t)}catch(n){}}function dtt(n){return n.f||(n.f=n.ga().then(function(){return new l(function(t){n.va(function u(i){return t(i),n.Ka(u),!1}),function(n){function u(i){f=!0;e&&e.cancel();ip(n).then(function(r){var f=t,u;r&&i&&i.url&&(u=null,-1!=(f=ng(i.url)).indexOf("/__/auth/callback")&&(u=(u="object"==typeof(u=du(ki(u=ai(f),"firebaseError")||null))?fd(u):null)?new wi(r.b,r.c,null,null,u):new wi(r.b,r.c,f,r.g)),f=u||t);ktt(n,f)})}var t=new wi("unknown",null,null,null,new i("no-auth-event")),f=!1,e=ar(500).then(function(){return ip(n).then(function(){f||ktt(n,t)})}),o=r.handleOpenURL;r.handleOpenURL=function(n){if(0==n.toLowerCase().indexOf(p("BuildInfo.packageName",r).toLowerCase()+"://")&&u({url:n}),"function"==typeof o)try{o(n)}catch(n){console.error(n)}};gs||(gs=new lv);gs.subscribe(u)}(n)})})),n.f}function ip(n){var t=null;return function(n){return n.b.get(ph,n.a).then(function(n){return sg(n)})}(n.g).then(function(i){return t=i,cf((i=n.g).b,ph,i.a)}).then(function(){return t})}function rp(n){return cf(n.b,kh,n.a)}function rr(n,t,i){this.v=n;this.m=t;this.l=i;this.h=[];this.f=!1;this.i=o(this.o,this);this.c=new gh;this.u=new sit;this.g=new function(n){this.a=n;this.b=eo()}(this.m+":"+this.l);this.b={};this.b.unknown=this.c;this.b.signInViaRedirect=this.c;this.b.linkViaRedirect=this.c;this.b.reauthViaRedirect=this.c;this.b.signInViaPopup=this.u;this.b.linkViaPopup=this.u;this.b.reauthViaPopup=this.u;this.a=gtt(this.v,this.m,this.l,no)}function gtt(n,t,i,r){var u=h.SDK_VERSION||null;return aa()?new btt(n,t,i,u,r):new ttt(n,t,i,u,r)}function nit(n){n.f||(n.f=!0,n.a.va(n.i));var t=n.a;return n.a.ga().s(function(i){throw n.a==t&&n.reset(),i;})}function tit(n){n.a.Ib()&&nit(n).s(function(t){var r=new wi("unknown",null,null,null,new i("operation-not-supported-in-this-environment"));up(t)&&n.o(r)});n.a.Db()||eit(n.c)}function uit(n,t,i,r,u,f){return n.a.zb(t,i,r,function(){n.f||(n.f=!0,n.a.va(n.i))},function(){n.reset()},u,f)}function up(n){return!(!n||"auth/cordova-not-ready"!=n.code)}function fit(n,t,i){var r=t+":"+i;return dh[r]||(dh[r]=new rr(n,t,i)),dh[r]}function gh(){this.b=null;this.f=[];this.c=[];this.a=null;this.g=!1}function eit(n){n.g||(n.g=!0,lf(n,!1,null,null))}function oit(n,t){if(n.b=function(){return e(t)},n.f.length)for(var i=0;i<n.f.length;i++)n.f[i](t)}function lf(n,t,i,r){t?r?function(n,t){if(n.b=function(){return k(t)},n.c.length)for(var i=0;i<n.c.length;i++)n.c[i](t)}(n,r):oit(n,i):oit(n,{user:null});n.f=[];n.c=[]}function sit(){}function hit(){this.pb=!1;Object.defineProperty(this,"appVerificationDisabled",{get:function(){return this.pb},set:function(n){this.pb=n},enumerable:!1})}function fp(n,t){this.a=t;f(this,"verificationId",n)}function ep(n,t,i,r){return new tr(n).Ta(t,i).then(function(n){return new fp(n,r)})}function op(n,t,i){if(this.h=n,this.i=t,this.g=i,this.c=3e4,this.f=96e4,this.b=null,this.a=this.c,this.f<this.c)throw Error("Proactive refresh lower bound greater than upper bound!");}function sp(n){this.f=n;this.b=this.a=null;this.c=0}function cit(n,t){var i=t[kt],r=t.refreshToken;t=lit(t.expiresIn);n.b=i;n.c=t;n.a=r}function lit(n){return fu()+1e3*parseInt(n,10)}function wot(n,t){return function(n,t){return new l(function(r,u){"refresh_token"==t.grant_type&&t.refresh_token||"authorization_code"==t.grant_type&&t.code?on(n,n.i+"?key="+encodeURIComponent(n.b),function(n){n?n.error?u(sy(n)):n.access_token&&n.refresh_token?r(n):u(new i("internal-error")):u(new i("network-request-failed"))},"POST",fk(t).toString(),n.f,n.m.get()):u(new i("internal-error"))})}(n.f,t).then(function(t){return n.b=t.access_token,n.c=lit(t.expires_in),n.a=t.refresh_token,{accessToken:n.b,expirationTime:n.c,refreshToken:n.a}}).s(function(t){throw"auth/user-token-expired"==t.code&&(n.a=null),t;})}function nc(n,t){this.a=n||null;this.b=t||null;ht(this,{lastSignInTime:se(t||null),creationTime:se(n||null)})}function oo(n,t){for(var i in yt.call(this,n),t)this[i]=t[i]}function at(n,t,i){this.G=[];this.l=n.apiKey;this.o=n.appName;this.u=n.authDomain||null;n=h.SDK_VERSION?ku(h.SDK_VERSION):null;this.b=new ei(this.l,to(no),n);this.h=new sp(this.b);ap(this,t[kt]);cit(this.h,t);f(this,"refreshToken",this.h.a);yit(this,i||{});ft.call(this);this.I=!1;this.u&&wr()&&(this.a=fit(this.u,this.l,this.o));this.N=[];this.i=null;this.w=function(n){return new op(function(){return n.F(!0)},function(n){return!(!n||"auth/network-request-failed"!=n.code)},function(){var t=n.h.c-fu()-3e5;return 0<t?t:0})}(this);this.V=o(this.Ha,this);var r=this;this.ka=null;this.sa=function(n){r.oa(n.g)};this.X=null;this.O=[];this.ra=function(n){so(r,n.c)};this.W=null}function hp(n,t){n.X&&pt(n.X,"languageCodeChanged",n.sa);(n.X=t)&&ii(t,"languageCodeChanged",n.sa)}function so(n,t){n.O=t;en(n.b,h.SDK_VERSION?ku(h.SDK_VERSION,n.O):null)}function cp(n,t){n.W&&pt(n.W,"frameworkChanged",n.ra);(n.W=t)&&ii(t,"frameworkChanged",n.ra)}function ait(n){try{return h.app(n.o).auth()}catch(t){throw new i("internal-error","No firebase.auth.Auth instance is available for the Firebase App '"+n.o+"'!");}}function vit(n){n.C||n.w.b||(n.w.start(),pt(n,"tokenChanged",n.V),ii(n,"tokenChanged",n.V))}function lp(n){pt(n,"tokenChanged",n.V);n.w.stop()}function ap(n,t){n.qa=t;f(n,"_lat",t)}function tu(n){for(var i=[],t=0;t<n.N.length;t++)i.push(n.N[t](n));return function(n){return new l(function(t){var r=n.length,u=[],f,i;if(r)for(f=function(n,i,f){r--;u[n]=i?{Zb:!0,value:f}:{Zb:!1,reason:f};0==r&&t(u)},i=0;i<n.length;i++)dw(n[i],yo(f,i,!0),yo(f,i,!1));else t(u)})}(i).then(function(){return n})}function ho(n){n.a&&!n.I&&(n.I=!0,n.a.subscribe(n))}function yit(n,t){ht(n,{uid:t.uid,displayName:t.displayName||null,photoURL:t.photoURL||null,email:t.email||null,emailVerified:t.emailVerified||!1,phoneNumber:t.phoneNumber||null,isAnonymous:t.isAnonymous||!1,metadata:new nc(t.createdAt,t.lastLoginAt),providerData:[]})}function pit(){}function vp(n){return e().then(function(){if(n.C)throw new i("app-deleted");})}function yp(n){return kc(n.providerData,function(n){return n.providerId})}function pp(n,t){t&&(wit(n,t.providerId),n.providerData.push(t))}function wit(n,t){dt(n.providerData,function(n){return n.providerId==t})}function ur(n,t,i){("uid"!=t||i)&&n.hasOwnProperty(t)&&f(n,t,i)}function tc(n,t){n!=t&&(ht(n,{uid:t.uid,displayName:t.displayName,photoURL:t.photoURL,email:t.email,emailVerified:t.emailVerified,phoneNumber:t.phoneNumber,isAnonymous:t.isAnonymous,providerData:[]}),t.metadata?f(n,"metadata",function(n){return new nc(n.a,n.b)}(t.metadata)):f(n,"metadata",new nc),st(t.providerData,function(t){pp(n,t)}),function(n,t){n.b=t.b;n.a=t.a;n.c=t.c}(n.h,t.h),f(n,"refreshToken",n.h.a))}function wp(n){return n.F().then(function(t){var i=n.isAnonymous;return function(n,t){return a(n.b,cet,{idToken:t}).then(o(n.uc,n))}(n,t).then(function(){return i||ur(n,"isAnonymous",!1),t})})}function iu(n,t){t[kt]&&n.qa!=t[kt]&&(cit(n.h,t),n.dispatchEvent(new oo("tokenChanged")),ap(n,t[kt]),ur(n,"refreshToken",n.h.a))}function ic(n,t){return wp(n).then(function(){if(or(yp(n),t))return tu(n).then(function(){throw new i("provider-already-linked");})})}function rc(n,t,i){return pi({user:n,credential:ds(t),additionalUserInfo:t=fv(t),operationType:i})}function bit(n,t){return iu(n,t),n.reload().then(function(){return n})}function kit(n,t,r,u,f){var e;if(!wr())return k(new i("operation-not-supported-in-this-environment"));if(n.i&&!f)return k(n.i);var o=uv(r.providerId),s=gu(n.uid+":::"),c=null;return(!ee()||va())&&n.u&&r.isOAuthProvider&&(c=io(n.u,n.l,n.o,t,r,null,s,h.SDK_VERSION||null)),e=dk(c,o&&o.Ba,o&&o.Aa),u=u().then(function(){if(git(n),!f)return n.F().then(function(){})}).then(function(){return uit(n.a,e,t,r,s,!!c)}).then(function(){return new l(function(r,u){n.ha(t,null,new i("cancelled-popup-request"),n.g||null);n.f=r;n.v=u;n.g=s;n.c=n.a.Ea(n,t,e,s)})}).then(function(n){return e&&pr(e),n?pi(n):null}).s(function(n){throw e&&pr(e),n;}),tt(n,u,f)}function dit(n,t,r,u,f){if(!wr())return k(new i("operation-not-supported-in-this-environment"));if(n.i&&!f)return k(n.i);var e=null,o=gu(n.uid+":::");return u=u().then(function(){if(git(n),!f)return n.F().then(function(){})}).then(function(){return n.aa=o,tu(n)}).then(function(t){return n.ba&&(t=(t=n.ba).b.set(uc,n.D(),t.a)),t}).then(function(){return n.a.Ca(t,r,o)}).s(function(t){if(e=t,n.ba)return trt(n.ba);throw e;}).then(function(){if(e)throw e;}),tt(n,u,f)}function git(n){if(!n.a||!n.I){if(n.a&&!n.I)throw new i("internal-error");throw new i("auth-domain-config-required");}}function tt(n,t,i){var r=function(n,t,i){return n.i&&!i?(t.cancel(),k(n.i)):t.s(function(t){throw!t||"auth/user-disabled"!=t.code&&"auth/user-token-expired"!=t.code||(n.i||n.dispatchEvent(new oo("userInvalidated")),n.i=t),t;})}(n,t,i);return n.G.push(r),r.ia(function(){po(n.G,r)}),r}function nrt(n){var r,t,i;return n.apiKey?(r={apiKey:n.apiKey,authDomain:n.authDomain,appName:n.appName},t={},!(n.stsTokenManager&&n.stsTokenManager.accessToken&&n.stsTokenManager.expirationTime))?null:(t[kt]=n.stsTokenManager.accessToken,t.refreshToken=n.stsTokenManager.refreshToken||null,t.expiresIn=(n.stsTokenManager.expirationTime-fu())/1e3,i=new at(r,t,n),n.providerData&&st(n.providerData,function(n){n&&pp(i,pi(n))}),n.redirectEventId&&(i.aa=n.redirectEventId),i):null}function trt(n){return cf(n.b,uc,n.a)}function bp(n){this.a=n;this.b=eo();this.c=null;this.f=function(n){var t=si("local"),i=si("session"),u=si("none");return function(n,t,i){var u=hf(t,i),f=nu(n,t.A);return n.get(t,i).then(function(e){var o=null;try{o=du(r.localStorage.getItem(u))}catch(n){}if(o&&!e)return r.localStorage.removeItem(u),n.set(t,o,i);o&&e&&"localStorage"!=f.type&&r.localStorage.removeItem(u)})}(n.b,t,n.a).then(function(){return n.b.get(i,n.a)}).then(function(r){return r?i:n.b.get(u,n.a).then(function(i){return i?u:n.b.get(t,n.a).then(function(i){return i?t:n.b.get(fc,n.a).then(function(n){return n?si(n):t})})})}).then(function(t){return n.c=t,kp(n,t.A)}).s(function(){n.c||(n.c=t)})}(this);this.b.addListener(si("local"),this.a,o(this.g,this))}function kp(n,t){var i,r=[];for(i in sf)sf[i]!==t&&r.push(cf(n.b,si(sf[i]),n.a));return r.push(cf(n.b,fc,n.a)),function(n){return new l(function(t,i){var u=n.length,f=[];if(u)for(var e=function(n,i){u--;f[n]=i;0==u&&t(f)},o=function(n){i(n)},r=0;r<n.length;r++)dw(n[r],yo(e,r),o);else t(f)})}(r)}function si(n){return{name:"authUser",A:n}}function irt(n,t){return af(n,function(){return n.b.set(n.c,t.D(),n.a)})}function rrt(n){return af(n,function(){return cf(n.b,n.c,n.a)})}function urt(n,t){return af(n,function(){return n.b.get(n.c,n.a).then(function(n){return n&&t&&(n.authDomain=t),nrt(n||{})})})}function af(n,t){return n.f=n.f.then(t,t),n.f}function ni(n){if(this.l=!1,f(this,"settings",new hit),f(this,"app",n),!v(this).options||!v(this).options.apiKey)throw new i("invalid-api-key");n=h.SDK_VERSION?ku(h.SDK_VERSION):null;this.b=new ei(v(this).options&&v(this).options.apiKey,to(no),n);this.N=[];this.o=[];this.I=[];this.Pb=h.INTERNAL.createSubscribe(o(this.ic,this));this.O=void 0;this.Qb=h.INTERNAL.createSubscribe(o(this.jc,this));vf(this,null);this.h=new bp(v(this).options.apiKey+":"+v(this).name);this.w=new function(n){this.a=n;this.b=eo()}(v(this).options.apiKey+":"+v(this).name);this.V=w(this,function(n){var t=v(n).options.authDomain,i=function(n){var t=function(n,t){return n.b.get(uc,n.a).then(function(n){return n&&t&&(n.authDomain=t),nrt(n||{})})}(n.w,v(n).options.authDomain).then(function(t){return(n.C=t)&&(t.ba=n.w),trt(n.w)});return w(n,t)}(n).then(function(){return urt(n.h,t)}).then(function(t){return t?(t.ba=n.w,n.C&&(n.C.aa||null)==(t.aa||null)?t:t.reload().then(function(){return irt(n.h,t).then(function(){return t})}).s(function(i){return"auth/network-request-failed"==i.code?t:rrt(n.h)})):null}).then(function(t){vf(n,t||null)});return w(n,i)}(this));this.i=w(this,function(n){return n.V.then(function(){return n.fa()}).s(function(){}).then(function(){if(!n.l)return n.ka()}).s(function(){}).then(function(){if(!n.l){n.X=!0;var t=n.h;t.b.addListener(si("local"),t.a,n.ka)}})}(this));this.X=!1;this.ka=o(this.Jc,this);this.Ha=o(this.Z,this);this.qa=o(this.Yb,this);this.ra=o(this.gc,this);this.sa=o(this.hc,this),function(n){var t=v(n).options.authDomain,i=v(n).options.apiKey;t&&wr()&&(n.Ob=n.V.then(function(){if(!n.l){if(n.a=fit(t,i,v(n).name),n.a.subscribe(n),s(n)&&ho(s(n)),n.C){ho(n.C);var r=n.C;r.oa(n.ea());hp(r,n);so(r=n.C,n.G);cp(r,n);n.C=null}return n.a}}))}(this);this.INTERNAL={};this.INTERNAL.delete=o(this.delete,this);this.INTERNAL.logFramework=o(this.qc,this);this.u=0;ft.call(this),function(n){Object.defineProperty(n,"lc",{get:function(){return this.ea()},set:function(n){this.oa(n)},enumerable:!1});n.W=null}(this);this.G=[]}function frt(n){yt.call(this,"languageCodeChanged");this.g=n}function ert(n){yt.call(this,"frameworkChanged");this.c=n}function dp(n){return n.Ob||k(new i("auth-domain-config-required"))}function ort(n,t){var i={};return i.apiKey=v(n).options.apiKey,i.authDomain=v(n).options.authDomain,i.appName=v(n).name,n.V.then(function(){return function(n,t,i,r){var u=new at(n,t);return i&&(u.ba=i),r&&so(u,r),u.reload().then(function(){return u})}(i,t,n.w,n.xa())}).then(function(t){return s(n)&&t.uid==s(n).uid?(tc(s(n),t),n.Z(t)):(vf(n,t),ho(t),n.Z(t))}).then(function(){lo(n)})}function vf(n,t){s(n)&&(function(n,t){dt(n.N,function(n){return n==t})}(s(n),n.Ha),pt(s(n),"tokenChanged",n.qa),pt(s(n),"userDeleted",n.ra),pt(s(n),"userInvalidated",n.sa),lp(s(n)));t&&(t.N.push(n.Ha),ii(t,"tokenChanged",n.qa),ii(t,"userDeleted",n.ra),ii(t,"userInvalidated",n.sa),0<n.u&&vit(t));f(n,"currentUser",t);t&&(t.oa(n.ea()),hp(t,n),so(t,n.G),cp(t,n))}function co(n,t){var i=null,r=null;return w(n,t.then(function(t){return i=ds(t),r=fv(t),ort(n,t)}).then(function(){return pi({user:s(n),credential:i,additionalUserInfo:r,operationType:"signIn"})}))}function v(n){return n.app}function s(n){return n.currentUser}function ec(n){return s(n)&&s(n)._lat||null}function lo(n){if(n.X){for(var t=0;t<n.o.length;t++)n.o[t]&&n.o[t](ec(n));if(n.O!==n.getUid()&&n.I.length)for(n.O=n.getUid(),t=0;t<n.I.length;t++)n.I[t]&&n.I[t](ec(n))}}function w(n,t){return n.N.push(t),t.ia(function(){po(n.N,t)}),t}function ao(){}function yf(){this.a={};this.b=1e12}function gp(n,t){return(t=srt(t))&&n.a[t]||null}function srt(n){return(n=void 0===n?1e12:n)?n.toString():null}function sc(n,t){this.g=!1;this.c=t;this.a=this.b=null;this.h="invisible"!==this.c.size;this.f=re(n);var i=this;this.i=function(){i.execute()};this.h?this.execute():ii(this.f,"click",this.i)}function nw(n){if(n.g)throw Error("reCAPTCHA mock was already deleted!");}function tw(){}function iw(){this.b=r.grecaptcha?1/0:0;this.f=null;this.a="__rcb"+Math.floor(1e6*Math.random()).toString()}function rw(n,t,u,e,o,s,h){var a,c,l;if(f(this,"type","recaptcha"),this.c=this.f=null,this.C=!1,this.l=t,this.g=null,h?(hc||(hc=new tw),h=hc):(cc||(cc=new iw),h=cc),this.o=h,this.a=u||{theme:"light",type:"image"},this.h=[],this.a[vrt])throw new i("argument-error","sitekey should not be provided for reCAPTCHA as one is automatically provisioned for the current project.");if(this.i="invisible"===this.a[bot],!r.document)throw new i("operation-not-supported-in-this-environment","RecaptchaVerifier is only supported in a browser HTTP/HTTPS environment with DOM support.");if(!re(t)||!this.i&&re(t).hasChildNodes())throw new i("argument-error","reCAPTCHA container is either not found or already contains inner elements!");this.u=new ei(n,s||null,o||null);this.v=e||function(){return null};a=this;this.m=[];c=this.a[lrt];this.a[lrt]=function(n){if(yrt(a,n),"function"==typeof c)c(n);else if("string"==typeof c){var t=p(c,r);"function"==typeof t&&t(n)}};l=this.a[art];this.a[art]=function(){if(yrt(a,null),"function"==typeof l)l();else if("string"==typeof l){var n=p(l,r);"function"==typeof n&&n()}}}function yrt(n,t){for(var i=0;i<n.m.length;i++)try{n.m[i](t)}catch(n){}}function uw(n,t){return n.h.push(t),t.ia(function(){po(n.h,t)}),t}function lc(n){if(n.C)throw new i("internal-error","RecaptchaVerifier instance has been destroyed.");}function fw(n,t,r){var f=!1,e,u;try{this.b=r||h.app()}catch(n){throw new i("argument-error","No firebase.app.App instance is currently initialized.");}if(!this.b.options||!this.b.options.apiKey)throw new i("invalid-api-key");r=this.b.options.apiKey;e=this;u=null;try{u=this.b.auth().xa()}catch(n){}try{f=this.b.auth().settings.appVerificationDisabledForTesting}catch(n){}u=h.SDK_VERSION?ku(h.SDK_VERSION,u):null;rw.call(this,r,n,t,function(){try{var n=e.b.auth().ea()}catch(t){n=null}return n},u,to(no),f)}function prt(n,t,r,u){n:{r=Array.prototype.slice.call(r);for(var f=0,e=!1,o=0;o<t.length;o++)if(t[o].optional)e=!0;else{if(e)throw new i("internal-error","Argument validator encountered a required argument after an optional argument.");f++}if(e=t.length,r.length<f||e<r.length)u="Expected "+(f==e?1==f?"1 argument":f+" arguments":f+"-"+e+" arguments")+" but got "+r.length+".";else{for(f=0;f<r.length;f++)if(e=t[f].optional&&void 0===r[f],!t[f].M(r[f])&&!e){if(t=t[f],0>f||f>=ew.length)throw new i("internal-error","Argument validator received an unsupported number of arguments.");r=ew[f];u=(u?"":r+" argument ")+(t.name?'"'+t.name+'" ':"")+"must be "+t.K+".";break n}u=null}}if(u)throw new i("argument-error",n+" failed: "+u);}function u(n,t){return{name:n||"",K:"a valid string",optional:!!t,M:b}}function ow(n,t){return{name:n||"",K:"a boolean",optional:!!t,M:krt}}function it(n,t){return{name:n||"",K:"a valid object",optional:!!t,M:vt}}function pf(n,t){return{name:n||"",K:"a function",optional:!!t,M:ut}}function fr(n,t){return{name:n||"",K:"null",optional:!!t,M:drt}}function ru(n){return{name:n?n+"Credential":"credential",K:n?"a valid "+n+" credential":"a valid credential",optional:!1,M:function(t){if(!t)return!1;var i=!n||t.providerId===n;return!(!t.ya||!i)}}}function ac(){return{name:"applicationVerifier",K:"an implementation of firebase.auth.ApplicationVerifier",optional:!1,M:function(n){return!!(n&&b(n.type)&&ut(n.verify))}}}function et(n,t,i,r){return{name:i||"",K:n.K+" or "+t.K,optional:!!r,M:function(i){return n.M(i)||t.M(i)}}}function rt(n,t){var i,r;for(i in t)r=t[i].name,n[r]=brt(r,n[i],t[i].j)}function wrt(n,t){var i,r,u;for(i in t)r=t[i].name,r!==i&&(u=t[i].qb,Object.defineProperty(n,r,{get:function(){return this[i]},set:function(n){prt(r,[u],[n],!0);this[i]=n},enumerable:!0}))}function ot(n,t,i,r){n[t]=brt(t,i,r)}function brt(n,t,i){function u(){var n=Array.prototype.slice.call(arguments);return prt(f,i,n),t.apply(this,n)}if(!i)return t;var r,f=function(n){return(n=n.split("."))[n.length-1]}(n);for(r in t)u[r]=t[r];for(r in t.prototype)u.prototype[r]=t.prototype[r];return u}var n,h=t.default,vc=vc||{},r=this,vo="closure_uid_"+(1e9*Math.random()>>>0),sw=0,fu=Date.now||function(){return+new Date},wc,gc,il,rl,ul,wo,fl,ko,el,ol,cl,ns,ll,is,rs,us,li,hb,vl,ab,hu,vb,os,ss,cs,na,sk,ia,ua,fa,oa,sa,ha,pk,gk,ys,ya,pa,ka,da,ps,nf,ed,he,ce,bs,ev,gs,vv,hg,rh,pe,fh,gv,yg,pg,ge,rn,un,sn,uy,cn,no,ah,by,ph,dy,tp,wtt,kh,iit,rit,dh,uc,fc,oc,hc,hrt,crt,cc,ew;c(ct,Error);ct.prototype.name="CustomError";c(yc,ct);yc.prototype.name="AssertionError";pc.prototype.get=function(){if(0<this.b){this.b--;var n=this.a;this.a=n.next;n.next=null}else n=this.c();return n};wc=new pc(function(){return new bc},function(n){n.reset()});aw.prototype.add=function(n,t){var i=wc.get();i.set(n,t);this.b?this.b.next=i:this.a=i;this.b=i};bc.prototype.set=function(n,t){this.a=n;this.b=t;this.next=null};bc.prototype.reset=function(){this.next=this.b=this.a=null};var vw=Array.prototype.indexOf?function(n,t){return Array.prototype.indexOf.call(n,t,void 0)}:function(n,t){if(b(n))return b(t)&&1==t.length?n.indexOf(t,0):-1;for(var i=0;i<n.length;i++)if(i in n&&n[i]===t)return i;return-1},st=Array.prototype.forEach?function(n,t,i){Array.prototype.forEach.call(n,t,i)}:function(n,t,i){for(var f=n.length,u=b(n)?n.split(""):n,r=0;r<f;r++)r in u&&t.call(i,u[r],r,n)},kc=Array.prototype.map?function(n,t){return Array.prototype.map.call(n,t,void 0)}:function(n,t){for(var r=n.length,u=Array(r),f=b(n)?n.split(""):n,i=0;i<r;i++)i in f&&(u[i]=t.call(void 0,f[i],i,n));return u},iut=Array.prototype.some?function(n,t){return Array.prototype.some.call(n,t,void 0)}:function(n,t){for(var u=n.length,r=b(n)?n.split(""):n,i=0;i<u;i++)if(i in r&&t.call(void 0,r[i],i,n))return!0;return!1};gc=String.prototype.trim?function(n){return n.trim()}:function(n){return/^[\s\xa0]*([\s\S]*?)[\s\xa0]*$/.exec(n)[1]};var eu,rut=/&/g,uut=/</g,fut=/>/g,eut=/"/g,out=/'/g,sut=/\x00/g,hut=/[\x00&<>"']/;n:{if(il=r.navigator,il&&(rl=il.userAgent,rl)){eu=rl;break n}eu=""}fl="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");ko=!1;el=new aw;var hr=0,gf=2,ci=3;kw.prototype.reset=function(){this.f=this.b=this.g=this.a=null;this.c=!1};ol=new pc(function(){return new kw},function(n){n.reset()});l.prototype.then=function(n,t,i){return gw(this,ut(n)?n:null,ut(t)?t:null,i)};hw(l);(n=l.prototype).ia=function(n,t){return(n=sl(n,n,t)).c=!0,hl(this,n),this};n.s=function(n,t){return gw(this,null,n,t)};n.cancel=function(n){this.a==hr&&bo(function(){!function n(t,i){var r;if(t.a==hr)if(t.c){if(r=t.c,r.b){for(var u=0,e=null,o=null,f=r.b;f&&(f.c||(u++,f.a==t&&(e=f),!(e&&1<u)));f=f.next)e||(o=f);e&&(r.a==hr&&1==u?n(r,i):(o?((u=o).next==r.f&&(r.f=u),u.next=u.next.next):ib(r),rb(r,e,ci,i)))}t.c=null}else cr(t,ci,i)}(this,new ou(n))},this)};n.Lc=function(n){this.a=hr;cr(this,gf,n)};n.Mc=function(n){this.a=hr;cr(this,ci,n)};n.Ub=function(){for(var n;n=ib(this);)rb(this,n,this.a,this.i);this.h=!1};cl=ww;c(ou,ct);ou.prototype.name="cancel";ns=0;ll={};go.prototype.pa=!1;go.prototype.ua=function(){if(this.ja)for(;this.ja.length;)this.ja.shift()()};al[" "]=ti;var ts,su,cut=g("Opera"),gt=g("Trident")||g("MSIE"),eb=g("Edge"),lut=eb||gt,ob=g("Gecko")&&!(y(eu.toLowerCase(),"webkit")&&!g("Edge"))&&!(g("Trident")||g("MSIE"))&&!g("Edge"),aut=y(eu.toLowerCase(),"webkit")&&!g("Edge");n:{if(is="",rs=(su=eu,ob?/rv:([^\);]+)(\)|;)/.exec(su):eb?/Edge\/([\d\.]+)/.exec(su):gt?/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(su):aut?/WebKit\/(\S+)/.exec(su):cut?/(?:Version)[ \/]?(\S+)/.exec(su):void 0),(rs&&(is=rs?rs[1]:""),gt)&&(us=sb(),null!=us&&us>parseFloat(is))){ts=String(us);break n}ts=is}hb={};vl=r.document;li=vl&&gt?sb()||("CSS1Compat"==vl.compatMode?parseInt(ts,10):5):void 0;var vut=Object.freeze||function(n){return n},lb=!gt||9<=Number(li),yut=gt&&!cb("9"),put=function(){if(!r.addEventListener||!Object.defineProperty)return!1;var n=!1,t=Object.defineProperty({},"passive",{get:function(){n=!0}});return r.addEventListener("test",ti,t),r.removeEventListener("test",ti,t),n}();yt.prototype.preventDefault=function(){this.Gb=!1};c(lr,yt);ab=vut({2:"touch",3:"pen",4:"mouse"});lr.prototype.preventDefault=function(){lr.lb.preventDefault.call(this);var n=this.a;if(n.preventDefault)n.preventDefault();else if(n.returnValue=!1,yut)try{(n.ctrlKey||112<=n.keyCode&&123>=n.keyCode)&&(n.keyCode=-1)}catch(n){}};lr.prototype.f=function(){return this.a};hu="closure_listenable_"+(1e6*Math.random()|0);vb=0;es.prototype.add=function(n,t,i,r,u){var f=n.toString(),e;return(n=this.a[f])||(n=this.a[f]=[],this.b++),e=pl(n,t,r,u),-1<e?(t=n[e],i||(t.Ia=!1)):((t=new function(n,t,i,r,u){this.listener=n;this.proxy=null;this.src=t;this.type=i;this.capture=!!r;this.La=u;this.key=++vb;this.na=this.Ia=!1}(t,this.src,f,!!r,u)).Ia=i,n.push(t)),t};os="closure_lm_"+(1e6*Math.random()|0);ss={};cs="__closure_events_fn_"+(1e9*Math.random()>>>0);c(ft,go);ft.prototype[hu]=!0;ft.prototype.addEventListener=function(n,t,i,r){ii(this,n,t,i,r)};ft.prototype.removeEventListener=function(n,t,i,r){pt(this,n,t,i,r)};ft.prototype.dispatchEvent=function(n){var r,i=this.Ua,f,t,u,e;if(i)for(r=[];i;i=i.Ua)r.push(i);if(i=this.Nb,f=n.type||n,b(n)?n=new yt(n,i):n instanceof yt?n.target=n.target||i:(t=n,hi(n=new yt(f,i),t)),t=!0,r)for(u=r.length-1;0<=u;u--)e=n.b=r[u],t=ls(e,f,!0,n)&&t;if(t=ls(e=n.b=i,f,!0,n)&&t,t=ls(e,f,!1,n)&&t,r)for(u=0;u<r.length;u++)t=ls(e=n.b=r[u],f,!1,n)&&t;return t};ft.prototype.ua=function(){var i,n,r,t;if(ft.lb.ua.call(this),this.m){n=this.m;for(i in n.a){for(r=n.a[i],t=0;t<r.length;t++)fs(r[t]);delete n.a[i];n.b--}}this.Ua=null};(n=cu.prototype).S=function(){gl(this);for(var t=[],n=0;n<this.a.length;n++)t.push(this.b[this.a[n]]);return t};n.U=function(){return gl(this),this.a.concat()};n.clear=function(){this.b={};this.c=this.a.length=0};n.get=function(n,t){return vr(this.b,n)?this.b[n]:t};n.set=function(n,t){vr(this.b,n)||(this.c++,this.a.push(n));this.b[n]=t};n.forEach=function(n,t){for(var u,f,r=this.U(),i=0;i<r.length;i++)u=r[i],f=this.get(u),n.call(t,f,u,this)};na=/^(?:([^:/?#.]+):)?(?:\/\/(?:([^/?#]*)@)?([^/#?]*?)(?::([0-9]+))?(?=[/#?]|$))?([^?#]+)?(?:\?([^#]*))?(?:#([\s\S]*))?$/;lu.prototype.toString=function(){var t=[],i=this.c,n;return i&&t.push(te(i,uk,!0),":"),n=this.b,(n||"file"==i)&&(t.push("//"),(i=this.m)&&t.push(te(i,uk,!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.g)&&(this.b&&"/"!=n.charAt(0)&&t.push("/"),t.push(te(n,"/"==n.charAt(0)?dut:kut,!0))),(n=this.a.toString())&&t.push("?",n),(n=this.h)&&t.push("#",te(n,nft)),t.join("")};var uk=/[#\/\?@]/g,kut=/[#\?:]/g,dut=/[#\?]/g,gut=/[#\?@]/g,nft=/#/g;(n=au.prototype).add=function(n,t){di(this);this.c=null;n=vu(this,n);var i=this.a.get(n);return i||this.a.set(n,i=[]),i.push(t),this.b+=1,this};n.clear=function(){this.a=this.c=null;this.b=0};n.forEach=function(n,t){di(this);this.a.forEach(function(i,r){st(i,function(i){n.call(t,i,r,this)},this)},this)};n.U=function(){var u,t;di(this);for(var f=this.a.S(),i=this.a.U(),r=[],n=0;n<i.length;n++)for(u=f[n],t=0;t<u.length;t++)r.push(i[n]);return r};n.S=function(n){var t,i;if(di(this),t=[],b(n))ek(this,n)&&(t=dc(t,this.a.get(vu(this,n))));else for(n=this.a.S(),i=0;i<n.length;i++)t=dc(t,n[i]);return t};n.set=function(n,t){return di(this),this.c=null,ek(this,n=vu(this,n))&&(this.b-=this.a.get(n).length),this.a.set(n,[t]),this.b+=1,this};n.get=function(n,t){return 0<(n=n?this.S(n):[]).length?String(n[0]):t};n.toString=function(){var n,e,t,r;if(this.c)return this.c;if(!this.a)return"";for(var u=[],f=this.a.U(),i=0;i<f.length;i++)for(n=f[i],e=encodeURIComponent(String(n)),n=this.S(n),t=0;t<n.length;t++)r=e,""!==n[t]&&(r+="="+encodeURIComponent(String(n[t]))),u.push(r);return this.c=u.join("&")};sk=!gt||9<=Number(li);yr.prototype.ma=!0;yr.prototype.la=function(){return this.a};yr.prototype.toString=function(){return"Const{"+this.a+"}"};ia={};ie("");yu.prototype.ma=!0;yu.prototype.la=function(){return this.a};yu.prototype.toString=function(){return"TrustedResourceUrl{"+this.a+"}"};var tft=/%{(\w+)}/g,ift=/^(?:https:)?\/\/[0-9a-z.:[\]-]+\/|^\/[^\/\\]|^about:blank#/i,lk={};ri.prototype.ma=!0;ri.prototype.la=function(){return this.a};ri.prototype.toString=function(){return"SafeUrl{"+this.a+"}"};ua=/^(?:(?:https?|mailto|ftp):|[^:/?#]*(?:[/?#]|$))/i;fa={};ea("about:blank");pu.prototype.ma=!0;pu.prototype.la=function(){return this.a};pu.prototype.toString=function(){return"SafeHtml{"+this.a+"}"};oa={};vs("<!DOCTYPE html>");vs("");vs("<br>");sa={cellpadding:"cellPadding",cellspacing:"cellSpacing",colspan:"colSpan",frameborder:"frameBorder",height:"height",maxlength:"maxLength",nonce:"nonce",role:"role",rowspan:"rowSpan",type:"type",usemap:"useMap",valign:"vAlign",width:"width"};ha={'"':'\\"',"\\":"\\\\","/":"\\/","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\v":"\\u000b"};pk=/\uffff/.test("￿")?/[\\"\x00-\x1f\x7f-\uffff]/g:/[\\"\x00-\x1f\x7f-\xff]/g;gk=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;ys="Firefox";ya="Chrome";pa={Sc:"FirebaseCore-web",Uc:"FirebaseUI-web"};gi.prototype.get=function(){var n=r.navigator;return!n||"boolean"!=typeof n.onLine||!ue()&&"chrome-extension:"!==fe()&&void 0===n.connection||n.onLine?this.b?this.c:this.a:Math.min(5e3,this.a)};da={};try{ps={};Object.defineProperty(ps,"abcd",{configurable:!0,enumerable:!0,value:1});Object.defineProperty(ps,"abcd",{configurable:!0,enumerable:!0,value:2});ka=2==ps.abcd}catch(su){ka=!1}var fft="EMAIL_SIGNIN",eft="email",oft="newEmail",sft="requestType",hft="email",cft="fromEmail",lft="data",aft="operation";c(i,Error);i.prototype.D=function(){return{code:this.code,message:this.message}};i.prototype.toJSON=function(){return this.D()};nf="auth/";ed={"argument-error":"","app-not-authorized":"This app, identified by the domain where it's hosted, is not authorized to use Firebase Authentication with the provided API key. Review your key configuration in the Google API console.","app-not-installed":"The requested mobile application corresponding to the identifier (Android package name or iOS bundle ID) provided is not installed on this device.","captcha-check-failed":"The reCAPTCHA response token provided is either invalid, expired, already used or the domain associated with it does not match the list of whitelisted domains.","code-expired":"The SMS code has expired. Please re-send the verification code to try again.","cordova-not-ready":"Cordova framework is not ready.","cors-unsupported":"This browser is not supported.","credential-already-in-use":"This credential is already associated with a different user account.","custom-token-mismatch":"The custom token corresponds to a different audience.","requires-recent-login":"This operation is sensitive and requires recent authentication. Log in again before retrying this request.","dynamic-link-not-activated":"Please activate Dynamic Links in the Firebase Console and agree to the terms and conditions.","email-already-in-use":"The email address is already in use by another account.","expired-action-code":"The action code has expired. ","cancelled-popup-request":"This operation has been cancelled due to another conflicting popup being opened.","internal-error":"An internal error has occurred.","invalid-app-credential":"The phone verification request contains an invalid application verifier. The reCAPTCHA token response is either invalid or expired.","invalid-app-id":"The mobile app identifier is not registed for the current project.","invalid-user-token":"This user's credential isn't valid for this project. This can happen if the user's token has been tampered with, or if the user isn't for the project associated with this API key.","invalid-auth-event":"An internal error has occurred.","invalid-verification-code":"The SMS verification code used to create the phone auth credential is invalid. Please resend the verification code sms and be sure use the verification code provided by the user.","invalid-continue-uri":"The continue URL provided in the request is invalid.","invalid-cordova-configuration":"The following Cordova plugins must be installed to enable OAuth sign-in: cordova-plugin-buildinfo, cordova-universal-links-plugin, cordova-plugin-browsertab, cordova-plugin-inappbrowser and cordova-plugin-customurlscheme.","invalid-custom-token":"The custom token format is incorrect. Please check the documentation.","invalid-email":"The email address is badly formatted.","invalid-api-key":"Your API key is invalid, please check you have copied it correctly.","invalid-cert-hash":"The SHA-1 certificate hash provided is invalid.","invalid-credential":"The supplied auth credential is malformed or has expired.","invalid-persistence-type":"The specified persistence type is invalid. It can only be local, session or none.","invalid-message-payload":"The email template corresponding to this action contains invalid characters in its message. Please fix by going to the Auth email templates section in the Firebase Console.","invalid-oauth-provider":"EmailAuthProvider is not supported for this operation. This operation only supports OAuth providers.","invalid-oauth-client-id":"The OAuth client ID provided is either invalid or does not match the specified API key.","unauthorized-domain":"This domain is not authorized for OAuth operations for your Firebase project. Edit the list of authorized domains from the Firebase console.","invalid-action-code":"The action code is invalid. This can happen if the code is malformed, expired, or has already been used.","wrong-password":"The password is invalid or the user does not have a password.","invalid-phone-number":"The format of the phone number provided is incorrect. Please enter the phone number in a format that can be parsed into E.164 format. E.164 phone numbers are written in the format [+][country code][subscriber number including area code].","invalid-recipient-email":"The email corresponding to this action failed to send as the provided recipient email address is invalid.","invalid-sender":"The email template corresponding to this action contains an invalid sender email or name. Please fix by going to the Auth email templates section in the Firebase Console.","invalid-verification-id":"The verification ID used to create the phone auth credential is invalid.","missing-android-pkg-name":"An Android Package Name must be provided if the Android App is required to be installed.","auth-domain-config-required":"Be sure to include authDomain when calling firebase.initializeApp(), by following the instructions in the Firebase console.","missing-app-credential":"The phone verification request is missing an application verifier assertion. A reCAPTCHA response token needs to be provided.","missing-verification-code":"The phone auth credential was created with an empty SMS verification code.","missing-continue-uri":"A continue URL must be provided in the request.","missing-iframe-start":"An internal error has occurred.","missing-ios-bundle-id":"An iOS Bundle ID must be provided if an App Store ID is provided.","missing-phone-number":"To send verification codes, provide a phone number for the recipient.","missing-verification-id":"The phone auth credential was created with an empty verification ID.","app-deleted":"This instance of FirebaseApp has been deleted.","account-exists-with-different-credential":"An account already exists with the same email address but different sign-in credentials. Sign in using a provider associated with this email address.","network-request-failed":"A network error (such as timeout, interrupted connection or unreachable host) has occurred.","no-auth-event":"An internal error has occurred.","no-such-provider":"User was not linked to an account with the given provider.","null-user":"A null user object was provided as the argument for an operation which requires a non-null user object.","operation-not-allowed":"The given sign-in provider is disabled for this Firebase project. Enable it in the Firebase console, under the sign-in method tab of the Auth section.","operation-not-supported-in-this-environment":'This operation is not supported in the environment this application is running on. "location.protocol" must be http, https or chrome-extension and web storage must be enabled.',"popup-blocked":"Unable to establish a connection with the popup. It may have been blocked by the browser.","popup-closed-by-user":"The popup has been closed by the user before finalizing the operation.","provider-already-linked":"User can only be linked to one identity for the given provider.","quota-exceeded":"The project's quota for this operation has been exceeded.","redirect-cancelled-by-user":"The redirect operation has been cancelled by the user before finalizing.","redirect-operation-pending":"A redirect sign-in operation is already pending.",timeout:"The operation has timed out.","user-token-expired":"The user's credential is no longer valid. The user must sign in again.","too-many-requests":"We have blocked all requests from this device due to unusual activity. Try again later.","unauthorized-continue-uri":"The domain of the continue URL is not whitelisted.  Please whitelist the domain in the Firebase console.","unsupported-persistence-type":"The current environment does not support the specified persistence type.","user-cancelled":"User did not grant your application the permissions it requested.","user-not-found":"There is no user record corresponding to this identifier. The user may have been deleted.","user-disabled":"The user account has been disabled by an administrator.","user-mismatch":"The supplied credentials do not correspond to the previously signed in user.","user-signed-out":"","weak-password":"The password must be 6 characters long or more.","web-storage-unsupported":"This browser is not supported or 3rd party cookies and data may be disabled."};var od="android",tv="handleCodeInApp",sd="iOS",vft="url",hd="installApp",cd="minimumVersion",ld="packageName",ad="bundleId";he=null;ce=null;vd.prototype.f=function(){return this.b};var wd="oauth_consumer_key oauth_nonce oauth_signature oauth_signature_method oauth_timestamp oauth_token oauth_version".split(" "),ws=["client_id","response_type","scope","redirect_uri","state"],rv={Tc:{Ma:"locale",Ba:500,Aa:600,Na:"facebook.com",eb:ws},Vc:{Ma:null,Ba:500,Aa:620,Na:"github.com",eb:ws},Wc:{Ma:"hl",Ba:515,Aa:680,Na:"google.com",eb:ws},bd:{Ma:"lang",Ba:485,Aa:705,Na:"twitter.com",eb:wd}};bs="idToken";ev="providerId";c(fi,ov);c(bd,fi);c(kd,fi);c(dd,fi);c(gd,fi);tf.prototype.ya=function(n){return an(n,sv(this))};tf.prototype.c=function(n,t){var i=sv(this);return i.idToken=t,vn(n,i)};tf.prototype.f=function(n,t){return ks(yn(n,sv(this)),t)};tf.prototype.D=function(){var n={providerId:this.providerId,signInMethod:this.signInMethod};return this.idToken&&(n.oauthIdToken=this.idToken),this.accessToken&&(n.oauthAccessToken=this.accessToken),this.secret&&(n.oauthTokenSecret=this.secret),n};le.prototype.Da=function(n){return this.vb=df(n),this};c(lt,le);lt.prototype.ta=function(n){return or(this.a,n)||this.a.push(n),this};lt.prototype.Ab=function(){return sr(this.a)};lt.prototype.credential=function(n,t){if(!n&&!t)throw new i("argument-error","credential failed: must provide the ID token and/or the access token.");return new tf(this.providerId,{idToken:n||null,accessToken:t||null},this.providerId)};c(br,lt);f(br,"PROVIDER_ID","facebook.com");f(br,"FACEBOOK_SIGN_IN_METHOD","facebook.com");c(kr,lt);f(kr,"PROVIDER_ID","github.com");f(kr,"GITHUB_SIGN_IN_METHOD","github.com");c(dr,lt);f(dr,"PROVIDER_ID","google.com");f(dr,"GOOGLE_SIGN_IN_METHOD","google.com");c(rf,le);f(rf,"PROVIDER_ID","twitter.com");f(rf,"TWITTER_SIGN_IN_METHOD","twitter.com");uf.prototype.ya=function(n){return this.signInMethod==wt.EMAIL_LINK_SIGN_IN_METHOD?a(n,set,{email:this.a,oobCode:this.b}):a(n,kn,{email:this.a,password:this.b})};uf.prototype.c=function(n,t){return this.signInMethod==wt.EMAIL_LINK_SIGN_IN_METHOD?a(n,het,{idToken:t,email:this.a,oobCode:this.b}):a(n,bn,{idToken:t,email:this.a,password:this.b})};uf.prototype.f=function(n,t){return ks(this.ya(n),t)};uf.prototype.D=function(){return{email:this.a,password:this.b,signInMethod:this.signInMethod}};ht(wt,{PROVIDER_ID:"password"});ht(wt,{EMAIL_LINK_SIGN_IN_METHOD:"emailLink"});ht(wt,{EMAIL_PASSWORD_SIGN_IN_METHOD:"password"});ff.prototype.ya=function(n){return n.Ta(hv(this))};ff.prototype.c=function(n,t){var i=hv(this);return i.idToken=t,a(n,uot,i)};ff.prototype.f=function(n,t){var i=hv(this);return i.operation="REAUTH",ks(n=a(n,fot,i),t)};ff.prototype.D=function(){var n={providerId:"phone"};return this.a.Sa&&(n.verificationId=this.a.Sa),this.a.Ra&&(n.verificationCode=this.a.Ra),this.a.Fa&&(n.temporaryProof=this.a.Fa),this.a.$&&(n.phoneNumber=this.a.$),n};tr.prototype.Ta=function(n,t){var r=this.a.b;return e(t.verify()).then(function(u){if(!b(u))throw new i("argument-error","An implementation of firebase.auth.ApplicationVerifier.prototype.verify() must return a firebase.Promise that resolves with a string.");switch(t.type){case"recaptcha":return function(n,t){return a(n,ket,t)}(r,{phoneNumber:n,recaptchaToken:u}).then(function(n){return"function"==typeof t.reset&&t.reset(),n},function(n){throw"function"==typeof t.reset&&t.reset(),n;});default:throw new i("argument-error",'Only firebase.auth.ApplicationVerifiers with type="recaptcha" are currently supported.');}})};ht(tr,{PROVIDER_ID:"phone"});ht(tr,{PHONE_SIGN_IN_METHOD:"phone"});wi.prototype.D=function(){return{type:this.b,eventId:this.c,urlResponse:this.f,sessionId:this.g,error:this.a&&this.a.D()}};gs=null;lv.prototype.subscribe=function(n){var t=this;this.a.push(n);this.b||(this.b=function(n){for(var i=0;i<t.a.length;i++)t.a[i](n)},"function"==typeof(n=p("universalLinks.subscribe",r))&&n(null,this.b))};lv.prototype.unsubscribe=function(n){dt(this.a,function(t){return t==n})};c(av,i);c(ae,i);ae.prototype.D=function(){var n={code:this.code,message:this.message},t;return this.email&&(n.email=this.email),this.phoneNumber&&(n.phoneNumber=this.phoneNumber),t=this.credential&&this.credential.D(),t&&hi(n,t),n};ae.prototype.toJSON=function(){return this.D()};hg=/^[+a-zA-Z0-9_.!#$%&'*\/=?^`{|}~-]+@([a-zA-Z0-9-]+\.)+[a-zA-Z0-9]{2,63}$/;ve.prototype.c=null;c(th,ve);th.prototype.a=function(){var n=lg(this);return n?new ActiveXObject(n):new XMLHttpRequest};th.prototype.b=function(){var n={};return lg(this)&&(n[0]=!0,n[1]=!0),n};vv=new th;c(ih,ve);ih.prototype.a=function(){var n=new XMLHttpRequest;if("withCredentials"in n)return n;if("undefined"!=typeof XDomainRequest)return new ag;throw Error("Unsupported browser");};ih.prototype.b=function(){return{}};(n=ag.prototype).open=function(n,t,i){if(null!=i&&!i)throw Error("Only async requests are supported.");this.a.open(n,t)};n.send=function(n){if(n){if("string"!=typeof n)throw Error("Only string data is supported");this.a.send(n)}else this.a.send()};n.abort=function(){this.a.abort()};n.setRequestHeader=function(){};n.getResponseHeader=function(n){return"content-type"==n.toLowerCase()?this.a.contentType:""};n.bc=function(){this.status=200;this.responseText=this.a.responseText;yv(this,4)};n.Bb=function(){this.status=500;this.responseText="";yv(this,4)};n.fc=function(){this.Bb()};n.cc=function(){this.status=200;yv(this,1)};n.getAllResponseHeaders=function(){return"content-type: "+this.a.contentType};pv.prototype.a=null;pv.prototype.reset=function(){delete this.a};ye.prototype.toString=function(){return this.name};var vg=new ye("SEVERE",1e3),bv=new ye("WARNING",900),pft=new ye("CONFIG",700),wft=new ye("FINE",500);wv.prototype.log=function(n,t,i){if(n.value>=function n(t){return t.c?t.c:t.a?n(t.a):(bf("Root logger has no level set."),null)}(this).value)for(ut(t)&&(t=t()),n=new pv(n,String(t),this.f),i&&(n.a=i),i=this;i;)i=i.a};rh={};pe=null;c(uh,ve);uh.prototype.a=function(){return new dv(this.f)};uh.prototype.b=function(n){return function(){return n}}({});c(dv,ft);fh=0;(n=dv.prototype).open=function(n,t){if(this.readyState!=fh)throw this.abort(),Error("Error reopening a connection");this.h=n;this.c=t;this.readyState=1;ef(this)};n.send=function(n){if(1!=this.readyState)throw this.abort(),Error("need to call open() first. ");this.a=!0;var t={headers:this.g,method:this.h,credentials:void 0,cache:void 0};n&&(t.body=n);this.i.fetch(new Request(this.c,t)).then(this.ec.bind(this),this.Cb.bind(this))};n.abort=function(){this.responseText="";this.g=new Headers;this.status=0;1<=this.readyState&&this.a&&4!=this.readyState&&(this.readyState=4,this.a=!1,ef(this));this.readyState=fh};n.ec=function(n){this.a&&(this.b||(this.b=n.headers,this.readyState=2,ef(this)),this.a&&(this.readyState=3,ef(this),this.a&&n.text().then(this.dc.bind(this,n),this.Cb.bind(this))))};n.dc=function(n,t){this.a&&(this.status=n.status,this.statusText=n.statusText,this.responseText=t,this.readyState=4,ef(this))};n.Cb=function(n){var t=this.f;t&&t.log(bv,"Failed to fetch url "+this.c,n instanceof Error?n:Error(n));this.a&&(this.readyState=4,ef(this))};n.setRequestHeader=function(n,t){this.g.append(n,t)};n.getResponseHeader=function(n){return this.b?this.b.get(n.toLowerCase())||"":((n=this.f)&&n.log(bv,"Attempting to get response header but no headers have been received for url: "+this.c,void 0),"")};n.getAllResponseHeaders=function(){var t,i,n;if(!this.b)return t=this.f,t&&t.log(bv,"Attempting to get all response headers but no headers have been received for url: "+this.c,void 0),"";for(t=[],i=this.b.entries(),n=i.next();!n.done;)n=n.value,t.push(n[0]+": "+n[1]),n=i.next();return t.join("\r\n")};c(we,ft);gv="";we.prototype.b=kv("goog.net.XhrIo");yg=/^https?$/i;pg=["POST","PUT"];(n=we.prototype).Ga=function(){void 0!==vc&&this.a&&(this.h="Timed out after "+this.g+"ms, aborting",bt(this.b,bi(this,this.h)),this.dispatchEvent("timeout"),this.abort(8))};n.abort=function(){this.a&&this.c&&(bt(this.b,bi(this,"Aborting")),this.c=!1,this.f=!0,this.a.abort(),this.f=!1,this.dispatchEvent("complete"),this.dispatchEvent("abort"),eh(this))};n.ua=function(){this.a&&(this.c&&(this.c=!1,this.f=!0,this.a.abort(),this.f=!1),eh(this,!0));we.lb.ua.call(this)};n.Fb=function(){this.pa||(this.I||this.i||this.f?kg(this):this.tc())};n.tc=function(){kg(this)};n.getResponse=function(){try{if(!this.a)return null;if("response"in this.a)return this.a.response;switch(this.o){case gv:case"text":return this.a.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in this.a)return this.a.mozResponseArrayBuffer}var n=this.b;return n&&n.log(vg,"Response type "+this.o+" is not supported on this browser",void 0),null}catch(n){return bt(this.b,"Can not get response: "+n.message),null}};ir.prototype.cancel=function(n){if(this.a)this.c instanceof ir&&this.c.cancel();else{if(this.b){var t=this.b;delete this.b;n?t.cancel(n):(t.m--,0>=t.m&&t.cancel())}this.v?this.v.call(this.u,this):this.l=!0;this.a||(n=new de(this),sh(this),ke(this,!1,n))}};ir.prototype.o=function(n,t){this.i=!1;ke(this,n,t)};ir.prototype.C=function(){sh(this);ke(this,!0,null)};ir.prototype.then=function(n,t,i){var r,u,f=new l(function(n,t){r=n;u=t});return ny(this,r,function(n){n instanceof de?f.cancel():u(n)}),f.then(n,t,i)};hw(ir);c(hh,ct);hh.prototype.message="Deferred has already fired";hh.prototype.name="AlreadyCalledError";c(de,ct);de.prototype.message="Deferred was canceled";de.prototype.name="CanceledError";tn.prototype.c=function(){throw delete ge[this.a],this.b;};ge={};rn=0;un=1;c(iy,ct);c(lh,ve);lh.prototype.a=function(){return new this.f};lh.prototype.b=function(){return{}};var ry,kt="idToken",gft=new gi(3e4,6e4),net={"Content-Type":"application/x-www-form-urlencoded"},tet=new gi(3e4,6e4),iet={"Content-Type":"application/json"};ei.prototype.o=function(n,t,u,f,e,o){var s,h;if(yi()&&(void 0===r.fetch||void 0===r.Headers||void 0===r.Request))throw new i("operation-not-supported-in-this-environment","fetch, Headers and Request native APIs or equivalent Polyfills must be available to support HTTP requests from a Worker environment.");s=new we(this.c);o&&(s.g=Math.max(0,o),h=setTimeout(function(){s.dispatchEvent("timeout")},o));db(s,"complete",function(){h&&clearTimeout(h);var n=null;try{n=JSON.parse(function(n){try{return n.a?n.a.responseText:""}catch(t){return bt(n.b,"Can not get responseText: "+t.message),""}}(this))||null}catch(t){n=null}t&&t(n)});kl(s,"ready",function(){h&&clearTimeout(h);fb(this)});kl(s,"timeout",function(){h&&clearTimeout(h);fb(this);t&&t(null)});bft(s,n,u,f,e)};sn=ie("https://apis.google.com/js/client.js?onload=%{onload}");uy="__fcb"+Math.floor(1e6*Math.random()).toString();ei.prototype.l=function(n,t,i,r,u){var f=this;ry.then(function(){window.gapi.client.setApiKey(f.b);var e=window.gapi.auth.getToken();window.gapi.auth.setToken(null);window.gapi.client.request({path:n,method:i,body:r,headers:u,authType:"none",callback:function(n){window.gapi.auth.setToken(e);t&&t(n)}})}).s(function(n){t&&t({error:{message:n&&n.message||"CORS_UNSUPPORTED"}})})};ei.prototype.Pa=function(){return a(this,det,{})};ei.prototype.mb=function(n,t){return a(this,wn,{idToken:n,email:t})};ei.prototype.nb=function(n,t){return a(this,bn,{idToken:n,password:t})};cn={displayName:"DISPLAY_NAME",photoUrl:"PHOTO_URL"};(n=ei.prototype).ob=function(n,t){var i={idToken:n},r=[];return pw(cn,function(n,u){var f=t[u];null===f?r.push(n):u in t&&(i[u]=f)}),r.length&&(i.deleteAttribute=r),a(this,wn,i)};n.hb=function(n,t){return hi(n={requestType:"PASSWORD_RESET",email:n},t),a(this,yet,n)};n.ib=function(n,t){return hi(n={requestType:"EMAIL_SIGNIN",email:n},t),a(this,aet,n)};n.gb=function(n,t){return hi(n={requestType:"VERIFY_EMAIL",idToken:n},t),a(this,vet,n)};n.Ta=function(n){return a(this,rot,n)};n.Xa=function(n,t){return a(this,bet,{oobCode:n,newPassword:t})};n.Ja=function(n){return a(this,uet,{oobCode:n})};n.Va=function(n){return a(this,ret,{oobCode:n})};var ret={endpoint:"setAccountInfo",B:oy,da:"email"},uet={endpoint:"resetPassword",B:oy,J:function(n){var t=n.requestType;if(!t||!n.email&&"EMAIL_SIGNIN"!=t)throw new i("internal-error");}},fet={endpoint:"signupNewUser",B:function(n){if(gr(n),!n.password)throw new i("weak-password");},J:oi,R:!0},pn={endpoint:"createAuthUri"},eet={endpoint:"deleteAccount",T:["idToken"]},oet={endpoint:"setAccountInfo",T:["idToken","deleteProvider"],B:function(n){if(!er(n.deleteProvider))throw new i("internal-error");}},set={endpoint:"emailLinkSignin",T:["email","oobCode"],B:gr,J:oi,R:!0},het={endpoint:"emailLinkSignin",T:["idToken","email","oobCode"],B:gr,J:oi,R:!0},cet={endpoint:"getAccountInfo"},aet={endpoint:"getOobConfirmationCode",T:["requestType"],B:function(n){if("EMAIL_SIGNIN"!=n.requestType)throw new i("internal-error");gr(n)},da:"email"},vet={endpoint:"getOobConfirmationCode",T:["idToken","requestType"],B:function(n){if("VERIFY_EMAIL"!=n.requestType)throw new i("internal-error");},da:"email"},yet={endpoint:"getOobConfirmationCode",T:["requestType"],B:function(n){if("PASSWORD_RESET"!=n.requestType)throw new i("internal-error");gr(n)},da:"email"},pet={rb:!0,endpoint:"getProjectConfig",Eb:"GET"},wet={rb:!0,endpoint:"getRecaptchaParam",Eb:"GET",J:function(n){if(!n.recaptchaSiteKey)throw new i("internal-error");}},bet={endpoint:"resetPassword",B:oy,da:"email"},ket={endpoint:"sendVerificationCode",T:["phoneNumber","recaptchaToken"],da:"sessionInfo"},wn={endpoint:"setAccountInfo",T:["idToken"],B:hn,R:!0},bn={endpoint:"setAccountInfo",T:["idToken"],B:function(n){if(hn(n),!n.password)throw new i("weak-password");},J:oi,R:!0},det={endpoint:"signupNewUser",J:oi,R:!0},get={endpoint:"verifyAssertion",B:ey,J:ln,R:!0},not={endpoint:"verifyAssertion",B:ey,J:function(n){if(n.errorMessage&&"USER_NOT_FOUND"==n.errorMessage)throw new i("user-not-found");if(n.errorMessage)throw dn(n.errorMessage);if(!n[kt])throw new i("internal-error");},R:!0},tot={endpoint:"verifyAssertion",B:function(n){if(ey(n),!n.idToken)throw new i("internal-error");},J:ln,R:!0},iot={endpoint:"verifyCustomToken",B:function(n){if(!n.token)throw new i("invalid-custom-token");},J:oi,R:!0},kn={endpoint:"verifyPassword",B:function(n){if(gr(n),!n.password)throw new i("wrong-password");},J:oi,R:!0},rot={endpoint:"verifyPhoneNumber",B:fy,J:oi},uot={endpoint:"verifyPhoneNumber",B:function(n){if(!n.idToken)throw new i("internal-error");fy(n)},J:function(n){if(n.temporaryProof)throw n.code="credential-already-in-use",nh(n);oi(n)}},fot={Tb:{USER_NOT_FOUND:"user-not-found"},endpoint:"verifyPhoneNumber",B:fy,J:oi};ah={Yc:{Za:"https://www.googleapis.com/identitytoolkit/v3/relyingparty/",fb:"https://securetoken.googleapis.com/v1/token",id:"p"},$c:{Za:"https://staging-www.sandbox.googleapis.com/identitytoolkit/v3/relyingparty/",fb:"https://staging-securetoken.sandbox.googleapis.com/v1/token",id:"s"},ad:{Za:"https://www-googleapis-test.sandbox.google.com/identitytoolkit/v3/relyingparty/",fb:"https://test-securetoken.sandbox.googleapis.com/v1/token",id:"t"}};no=to("__EID__")?"__EID__":void 0;var hy,oot=ie("https://apis.google.com/js/api.js?onload=%{onload}"),sot=new gi(3e4,6e4),hot=new gi(5e3,15e3),cy=null;gn.prototype.toString=function(){return this.f?d(this.a,"v",this.f):vi(this.a.a,"v"),this.b?d(this.a,"eid",this.b):vi(this.a.a,"eid"),this.c.length?d(this.a,"fw",this.c.join(",")):vi(this.a.a,"fw"),this.a.toString()};ntt.prototype.toString=function(){var n=rk(this.o,"/__/auth/handler"),i,t,u,f,e,r;if(d(n,"apiKey",this.l),d(n,"appName",this.c),d(n,"authType",this.m),this.a.isOAuthProvider){i=this.a;try{t=h.app(this.c).auth().ea()}catch(n){t=null}for(u in i.Ya=t,d(n,"providerId",this.a.providerId),t=td((i=this.a).vb))t[u]=t[u].toString();for(u=i.Ac,t=df(t),f=0;f<u.length;f++)e=u[f],e in t&&delete t[e];i.$a&&i.Ya&&!t[i.$a]&&(t[i.$a]=i.Ya);kf(t)||d(n,"customParameters",oe(t))}if("function"==typeof this.a.Ab&&(i=this.a.Ab()).length&&d(n,"scopes",i.join(",")),this.i?d(n,"redirectUrl",this.i):vi(n.a,"redirectUrl"),this.g?d(n,"eventId",this.g):vi(n.a,"eventId"),this.h?d(n,"v",this.h):vi(n.a,"v"),this.b)for(r in this.b)this.b.hasOwnProperty(r)&&!ki(n,r)&&d(n,r,this.b[r]);return this.f?d(n,"eid",this.f):vi(n.a,"eid"),(r=ly(this.c)).length&&d(n,"fw",r.join(",")),n.toString()};(n=ttt.prototype).Ea=function(n,t,r){var f=new i("popup-closed-by-user"),e=new i("web-storage-unsupported"),o=this,u=!1;return this.ga().then(function(){(function(n){var t={type:"webStorageSupport"};return rtt(n).then(function(){return function(n,t){return n.bb.then(function(){return new l(function(i){n.a.send(t.type,t,i,p("gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER"))})})}(n.i,t)}).then(function(n){if(n&&n.length&&void 0!==n[0].webStorageSupport)return n[0].webStorageSupport;throw Error();})})(o).then(function(i){i||(n&&pr(n),t(e),u=!0)})}).s(function(){}).then(function(){if(!u)return function(n){return new l(function(t){return function i(){ar(2e3).then(function(){if(n&&!n.closed)return i();t()})}()})}(n)}).then(function(){if(!u)return ar(r).then(function(){t(f)})})};n.Ib=function(){var n=nt();return!ee(n)&&!id(n)};n.Db=function(){return!1};n.zb=function(n,t,r,u,f,o,s){if(!n)return k(new i("popup-blocked"));if(s&&!ee())return this.ga().s(function(t){pr(n);f(t)}),u(),e();this.a||(this.a=itt(utt(this)));var h=this;return this.a.then(function(){var t=h.ga().s(function(t){throw pr(n),f(t),t;});return u(),t}).then(function(){(cv(r),s)||bk(io(h.l,h.f,h.b,t,r,null,o,h.c,void 0,h.h),n)}).s(function(n){throw"auth/network-request-failed"==n.code&&(h.a=null),n;})};n.Ca=function(n,t,i){this.a||(this.a=itt(utt(this)));var r=this;return this.a.then(function(){cv(t);bk(io(r.l,r.f,r.b,n,t,wu(),i,r.c,void 0,r.h))}).s(function(n){throw"auth/network-request-failed"==n.code&&(r.a=null),n;})};n.ga=function(){var n=this;return rtt(this).then(function(){return n.i.bb}).s(function(){throw n.a=null,new i("network-request-failed");})};n.Mb=function(){return!0};n.va=function(n){this.g.push(n)};n.Ka=function(n){dt(this.g,function(t){return t==n})};(n=ftt.prototype).get=function(n){return e(this.a.getItem(n)).then(function(n){return n&&du(n)})};n.set=function(n,t){return e(this.a.setItem(n,oe(t)))};n.P=function(n){return e(this.a.removeItem(n))};n.Y=function(){};n.ca=function(){};(n=ett.prototype).set=function(n,t){var r,u=!1,i=this;return vh(this).then(function(t){return of((t=ro(uo(r=t,!0))).get(n))}).then(function(f){var e=ro(uo(r,!0));return f?(f.value=t,of(e.put(f))):(i.b++,u=!0,(f={}).fbase_key=n,f.value=t,of(e.add(f)))}).then(function(){i.f[n]=t}).ia(function(){u&&i.b--})};n.get=function(n){return vh(this).then(function(t){return of(ro(uo(t,!1)).get(n))}).then(function(n){return n&&n.value})};n.P=function(n){var i=!1,t=this;return vh(this).then(function(r){return i=!0,t.b++,of(ro(uo(r,!0)).delete(n))}).then(function(){delete t.f[n]}).ia(function(){i&&t.b--})};n.Kc=function(){var n=this;return vh(this).then(function(n){var t=ro(uo(n,!1));return t.getAll?of(t.getAll()):new l(function(n,i){var r=[],u=t.openCursor();u.onsuccess=function(t){(t=t.target.result)?(r.push(t.value),t.continue()):n(r)};u.onerror=function(n){i(Error(n.target.errorCode))}})}).then(function(t){var r={},i=[];if(0==n.b){for(i=0;i<t.length;i++)r[t[i].fbase_key]=t[i].value;i=function n(t,i){var r,u=[];for(r in t)r in i?typeof t[r]!=typeof i[r]?u.push(r):"object"==typeof t[r]&&null!=t[r]&&null!=i[r]?0<n(t[r],i[r]).length&&u.push(r):t[r]!==i[r]&&u.push(r):u.push(r);for(r in i)r in t||u.push(r);return u}(n.f,r);n.f=r}return i})};n.Y=function(n){0==this.a.length&&function(n){n.c&&n.c.cancel("STOP_EVENT"),function t(){return n.c=ar(800).then(o(n.Kc,n)).then(function(t){0<t.length&&st(n.a,function(n){n(t)})}).then(t).s(function(n){"STOP_EVENT"!=n.message&&t()}),n.c}()}(this);this.a.push(n)};n.ca=function(n){dt(this.a,function(t){return t==n});0==this.a.length&&this.c&&this.c.cancel("STOP_EVENT")};(n=htt.prototype).get=function(n){return this.b.then(function(t){return t.get(n)})};n.set=function(n,t){return this.b.then(function(i){return i.set(n,t)})};n.P=function(n){return this.b.then(function(t){return t.P(n)})};n.Y=function(n){this.a.push(n)};n.ca=function(n){dt(this.a,function(t){return t==n})};(n=fo.prototype).get=function(n){return e(this.a[n])};n.set=function(n,t){return this.a[n]=t,e()};n.P=function(n){return delete this.a[n],e()};n.Y=function(){};n.ca=function(){};(n=yh.prototype).get=function(n){var t=this;return e().then(function(){return du(t.a.getItem(n))})};n.set=function(n,t){var i=this;return e().then(function(){var r=oe(t);null===r?i.P(n):i.a.setItem(n,r)})};n.P=function(n){var t=this;return e().then(function(){t.a.removeItem(n)})};n.Y=function(n){r.window&&ii(r.window,"storage",n)};n.ca=function(n){r.window&&pt(r.window,"storage",n)};(n=ay.prototype).get=function(){return e(null)};n.set=function(){return e()};n.P=function(){return e()};n.Y=function(){};n.ca=function(){};(n=vy.prototype).get=function(n){var t=this;return e().then(function(){return du(t.a.getItem(n))})};n.set=function(n,t){var i=this;return e().then(function(){var r=oe(t);null===r?i.P(n):i.a.setItem(n,r)})};n.P=function(n){var t=this;return e().then(function(){t.a.removeItem(n)})};n.Y=function(){};n.ca=function(){};var yy,py,cot={A:yh,Qa:vy},lot={A:yh,Qa:vy},aot={A:ftt,Qa:ay},vot={A:yh,Qa:ay},sf={Xc:"local",NONE:"none",Zc:"session"};(n=att.prototype).get=function(n,t){return nu(this,n.A).get(hf(n,t))};n.set=function(n,t,i){var r=hf(n,i),f=this,u=nu(this,n.A);return u.set(r,t).then(function(){return u.get(r)}).then(function(t){"local"==n.A&&(f.b[r]=t)})};n.addListener=function(n,t,i){n=hf(n,t);this.m&&(this.b[n]=r.localStorage.getItem(n));kf(this.a)&&(nu(this,"local").Y(this.f),this.h||(ca()||!ud())&&r.indexedDB||!this.m||function(n){wy(n);n.c=setInterval(function(){var i,t,u;for(i in n.a)t=r.localStorage.getItem(i),u=n.b[i],t!=u&&(n.b[i]=t,t=new lr({type:"storage",key:i,target:window,oldValue:u,newValue:t,a:!0}),n.Lb(t))},1e3)}(this));this.a[n]||(this.a[n]=[]);this.a[n].push(i)};n.removeListener=function(n,t,i){n=hf(n,t);this.a[n]&&(dt(this.a[n],function(n){return n==i}),0==this.a[n].length&&delete this.a[n]);kf(this.a)&&(nu(this,"local").ca(this.f),wy(this))};n.Lb=function(n){var t,i,u,e,f;if(n&&n.f){if(t=n.a.key,null==t)for(i in this.a)u=this.b[i],void 0===u&&(u=null),e=r.localStorage.getItem(i),e!==u&&(this.b[i]=e,this.Wa(i));else if(0==t.indexOf("firebase:")&&this.a[t]){if(void 0!==n.a.a?nu(this,"local").ca(this.f):wy(this),this.o)if(i=r.localStorage.getItem(t),(u=n.a.newValue)!==i)null!==u?r.localStorage.setItem(t,u):r.localStorage.removeItem(t);else if(this.b[t]===u&&void 0===n.a.a)return;f=this;i=function(){void 0===n.a.a&&f.b[t]===r.localStorage.getItem(t)||(f.b[t]=r.localStorage.getItem(t),f.Wa(t))};gt&&li&&10==li&&r.localStorage.getItem(t)!==n.a.newValue&&n.a.newValue!==n.a.oldValue?setTimeout(i,10):i()}}else st(n,o(this.Wa,this))};n.Wa=function(n){this.a[n]&&st(this.a[n],function(n){n()})};ph={name:"authEvent",A:"local"};c(wh,function(){this.b=-1});for(var vtt=64,yot=vtt-1,ytt=[],ky=0;ky<yot;ky++)ytt[ky]=0;dy=dc(128,ytt);wh.prototype.reset=function(){this.g=this.c=0;this.a=r.Int32Array?new Int32Array(this.h):sr(this.h)};tp=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];c(ptt,wh);wtt=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];(n=btt.prototype).ga=function(){return this.za?this.za:this.za=(aa(void 0)?la().then(function(){return new l(function(n,t){var i=r.document,u=setTimeout(function(){t(Error("Cordova framework is not ready."))},1e3);i.addEventListener("deviceready",function(){clearTimeout(u);n()},!1)})}):k(Error("Cordova must run in an Android or iOS file scheme."))).then(function(){if("function"!=typeof p("universalLinks.subscribe",r))throw bh("cordova-universal-links-plugin is not installed");if(void 0===p("BuildInfo.packageName",r))throw bh("cordova-plugin-buildinfo is not installed");if("function"!=typeof p("cordova.plugins.browsertab.openUrl",r))throw bh("cordova-plugin-browsertab is not installed");if("function"!=typeof p("cordova.InAppBrowser.open",r))throw bh("cordova-plugin-inappbrowser is not installed");},function(){throw new i("cordova-not-ready");})};n.Ea=function(n,t){return t(new i("operation-not-supported-in-this-environment")),e()};n.zb=function(){return k(new i("operation-not-supported-in-this-environment"))};n.Mb=function(){return!1};n.Ib=function(){return!0};n.Db=function(){return!0};n.Ca=function(n,t,u){if(this.c)return k(new i("redirect-operation-pending"));var f=this,s=r.document,h=null,c=null,o=null,a=null;return this.c=e().then(function(){return cv(t),dtt(f)}).then(function(){return function(n,t,u,f){var o=function(){for(var n=20,t=[];0<n;)t.push("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".charAt(Math.floor(62*Math.random()))),n--;return t.join("")}(),l=new wi(t,f,null,o,new i("no-auth-event")),s=p("BuildInfo.packageName",r),h,e,c;if("string"!=typeof s)throw new i("invalid-cordova-configuration");if(h=p("BuildInfo.displayName",r),e={},nt().toLowerCase().match(/iphone|ipad|ipod/))e.ibi=s;else{if(!nt().toLowerCase().match(/android/))return k(new i("operation-not-supported-in-this-environment"));e.apn=s}return h&&(e.appDisplayName=h),o=pot(o),e.sessionId=o,c=io(n.l,n.i,n.m,t,u,null,f,n.o,e,n.u),n.ga().then(function(){var t=n.h;return n.v.a.set(ph,l.D(),t)}).then(function(){var u=p("cordova.plugins.browsertab.isAvailable",r),t;if("function"!=typeof u)throw new i("invalid-cordova-configuration");t=null;u(function(u){if(u){if("function"!=typeof(t=p("cordova.plugins.browsertab.openUrl",r)))throw new i("invalid-cordova-configuration");t(c)}else{if("function"!=typeof(t=p("cordova.InAppBrowser.open",r)))throw new i("invalid-cordova-configuration");u=!(!(u=nt()).match(/(iPad|iPhone|iPod).*OS 7_\d/i)&&!u.match(/(iPad|iPhone|iPod).*OS 8_\d/i));n.a=t(c,u?"_blank":"_system","location=yes")}})})}(f,n,t,u)}).then(function(){return new l(function(n,t){c=function(){var t=p("cordova.plugins.browsertab.close",r);return n(),"function"==typeof t&&t(),f.a&&"function"==typeof f.a.close&&(f.a.close(),f.a=null),!1};f.va(c);o=function(){h||(h=ar(2e3).then(function(){t(new i("redirect-cancelled-by-user"))}))};a=function(){ba()&&o()};s.addEventListener("resume",o,!1);nt().toLowerCase().match(/android/)||s.addEventListener("visibilitychange",a,!1)}).s(function(n){return ip(f).then(function(){throw n;})})}).ia(function(){o&&s.removeEventListener("resume",o,!1);a&&s.removeEventListener("visibilitychange",a,!1);h&&h.cancel();c&&f.Ka(c);f.c=null})};n.va=function(n){this.b.push(n);dtt(this).s(function(t){"auth/invalid-cordova-configuration"===t.code&&(t=new wi("unknown",null,null,null,new i("no-auth-event")),n(t))})};n.Ka=function(n){dt(this.b,function(t){return t==n})};kh={name:"pendingRedirect",A:"session"};rr.prototype.reset=function(){this.f=!1;this.a.Ka(this.i);this.a=gtt(this.v,this.m,this.l)};rr.prototype.subscribe=function(n){if(or(this.h,n)||this.h.push(n),!this.f){var t=this;(function(n){return n.b.get(kh,n.a).then(function(n){return"pending"==n})})(this.g).then(function(n){n?rp(t.g).then(function(){nit(t).s(function(n){var r=new wi("unknown",null,null,null,new i("operation-not-supported-in-this-environment"));up(n)&&t.o(r)})}):tit(t)}).s(function(){tit(t)})}};rr.prototype.unsubscribe=function(n){dt(this.h,function(t){return t==n})};rr.prototype.o=function(n){var t,r,u;if(!n)throw new i("invalid-auth-event");for(t=!1,r=0;r<this.h.length;r++)if(u=this.h[r],u.sb(n.b,n.c)){(t=this.b[n.b])&&t.h(n,u);t=!0;break}return eit(this.c),t};iit=new gi(2e3,1e4);rit=new gi(3e4,6e4);rr.prototype.fa=function(){return this.c.fa()};rr.prototype.Ca=function(n,t,r){var f,u=this;return function(n){return n.b.set(kh,"pending",n.a)}(this.g).then(function(){return u.a.Ca(n,t,r).s(function(n){if(up(n))throw new i("operation-not-supported-in-this-environment");return f=n,rp(u.g).then(function(){throw f;})}).then(function(){return u.a.Mb()?new l(function(){}):rp(u.g).then(function(){return u.fa()}).then(function(){}).s(function(){})})})};rr.prototype.Ea=function(n,t,i,r){return this.a.Ea(i,function(i){n.ha(t,null,i,r)},iit.get())};dh={};gh.prototype.reset=function(){this.b=null;this.a&&(this.a.cancel(),this.a=null)};gh.prototype.h=function(n,t){if(n){this.reset();this.g=!0;var r=n.b,u=n.c,f=n.a&&"auth/web-storage-unsupported"==n.a.code,o=n.a&&"auth/operation-not-supported-in-this-environment"==n.a.code;"unknown"!=r||f||o?n.a?(lf(this,!0,null,n.a),e()):t.wa(r,u)?function(n,t,i){i=i.wa(t.b,t.c);var u=t.f,f=t.g,r=!!t.b.match(/Redirect$/);i(u,f).then(function(t){lf(n,r,t,null)}).s(function(t){lf(n,r,null,t)})}(this,n,t):k(new i("invalid-auth-event")):(lf(this,!1,null,null),e())}else k(new i("invalid-auth-event"))};gh.prototype.fa=function(){var n=this;return new l(function(t,r){n.b?n.b().then(t,r):(n.f.push(t),n.c.push(r),function(n){var t=new i("timeout");n.a&&n.a.cancel();n.a=ar(rit.get()).then(function(){n.b||lf(n,!0,null,t)})}(n))})};sit.prototype.h=function(n,t){if(n){var r=n.b,u=n.c;n.a?(t.ha(n.b,null,n.a,n.c),e()):t.wa(r,u)?function(n,t){var i=n.c,r=n.b;t.wa(r,i)(n.f,n.g).then(function(n){t.ha(r,n,null,i)}).s(function(n){t.ha(r,null,n,i)})}(n,t):k(new i("invalid-auth-event"))}else k(new i("invalid-auth-event"))};fp.prototype.confirm=function(n){return n=og(this.verificationId,n),this.a(n)};op.prototype.start=function(){this.a=this.c,function n(t,i){t.stop();t.b=ar(function(n,t){return t?(n.a=n.c,n.g()):(t=n.a,n.a*=2,n.a>n.f&&(n.a=n.f),t)}(t,i)).then(function(){return n=r.document,t=null,ba()||!n?e():new l(function(i){t=function(){ba()&&(n.removeEventListener("visibilitychange",t,!1),i())};n.addEventListener("visibilitychange",t,!1)}).s(function(i){throw n.removeEventListener("visibilitychange",t,!1),i;});var n,t}).then(function(){return t.h()}).then(function(){n(t,!0)}).s(function(i){t.i(i)&&n(t,!1)})}(this,!0)};op.prototype.stop=function(){this.b&&(this.b.cancel(),this.b=null)};sp.prototype.D=function(){return{apiKey:this.f.b,refreshToken:this.a,accessToken:this.b,expirationTime:this.c}};sp.prototype.getToken=function(n){return n=!!n,this.b&&!this.a?k(new i("user-token-expired")):n||!this.b||fu()>this.c-3e4?this.a?wot(this,{grant_type:"refresh_token",refresh_token:this.a}):e(null):e({accessToken:this.b,expirationTime:this.c,refreshToken:this.a})};nc.prototype.D=function(){return{lastLoginAt:this.b,createdAt:this.a}};c(oo,yt);c(at,ft);at.prototype.oa=function(n){this.ka=n;fn(this.b,n)};at.prototype.ea=function(){return this.ka};at.prototype.xa=function(){return sr(this.O)};at.prototype.Ha=function(){this.w.b&&(this.w.stop(),this.w.start())};f(at.prototype,"providerId","firebase");(n=at.prototype).reload=function(){var n=this;return tt(this,vp(this).then(function(){return wp(n).then(function(){return tu(n)}).then(pit)}))};n.ac=function(n){return this.F(n).then(function(n){return new function(n){var t=pd(n);if(!(t&&t.exp&&t.auth_time&&t.iat))throw new i("internal-error","An internal error occurred. The token obtained by Firebase appears to be malformed. Please retry the operation.");ht(this,{token:n,expirationTime:se(1e3*t.exp),authTime:se(1e3*t.auth_time),issuedAtTime:se(1e3*t.iat),signInProvider:t.firebase&&t.firebase.sign_in_provider?t.firebase.sign_in_provider:null,claims:t})}(n)})};n.F=function(n){var t=this;return tt(this,vp(this).then(function(){return t.h.getToken(n)}).then(function(n){if(!n)throw new i("internal-error");return n.accessToken!=t.qa&&(ap(t,n.accessToken),t.dispatchEvent(new oo("tokenChanged"))),ur(t,"refreshToken",n.refreshToken),n.accessToken}))};n.uc=function(n){if(!(n=n.users)||!n.length)throw new i("internal-error");yit(this,{uid:(n=n[0]).localId,displayName:n.displayName,photoURL:n.photoUrl,email:n.email,emailVerified:!!n.emailVerified,phoneNumber:n.phoneNumber,lastLoginAt:n.lastLoginAt,createdAt:n.createdAt});for(var r=function(n){return(n=n.providerUserInfo)&&n.length?kc(n,function(n){return new function(n,t,i,r,u,f){ht(this,{uid:n,displayName:r||null,photoURL:u||null,email:i||null,phoneNumber:f||null,providerId:t})}(n.rawId,n.providerId,n.email,n.displayName,n.photoUrl,n.phoneNumber)}):[]}(n),t=0;t<r.length;t++)pp(this,r[t]);ur(this,"isAnonymous",!(this.email&&n.passwordHash||this.providerData&&this.providerData.length))};n.cb=function(n){var t=this,i=null;return tt(this,n.f(this.b,this.uid).then(function(n){return iu(t,n),i=rc(t,n,"reauthenticate"),t.i=null,t.reload()}).then(function(){return i}),!0)};n.vc=function(n){return nr("firebase.User.prototype.reauthenticateWithCredential is deprecated. Please use firebase.User.prototype.reauthenticateAndRetrieveDataWithCredential instead."),this.cb(n).then(function(){})};n.ab=function(n){var t=this,i=null;return tt(this,ic(this,n.providerId).then(function(){return t.F()}).then(function(i){return n.c(t.b,i)}).then(function(n){return i=rc(t,n,"link"),bit(t,n)}).then(function(){return i}))};n.mc=function(n){return nr("firebase.User.prototype.linkWithCredential is deprecated. Please use firebase.User.prototype.linkAndRetrieveDataWithCredential instead."),this.ab(n).then(function(n){return n.user})};n.nc=function(n,t){var i=this;return tt(this,ic(this,"phone").then(function(){return ep(ait(i),n,t,o(i.ab,i))}))};n.wc=function(n,t){var i=this;return tt(this,e().then(function(){return ep(ait(i),n,t,o(i.cb,i))}),!0)};n.mb=function(n){var t=this;return tt(this,this.F().then(function(i){return t.b.mb(i,n)}).then(function(n){return iu(t,n),t.reload()}))};n.Pc=function(n){var t=this;return tt(this,this.F().then(function(i){return n.c(t.b,i)}).then(function(n){return iu(t,n),t.reload()}))};n.nb=function(n){var t=this;return tt(this,this.F().then(function(i){return t.b.nb(i,n)}).then(function(n){return iu(t,n),t.reload()}))};n.ob=function(n){if(void 0===n.displayName&&void 0===n.photoURL)return vp(this);var t=this;return tt(this,this.F().then(function(i){return t.b.ob(i,{displayName:n.displayName,photoUrl:n.photoURL})}).then(function(n){return iu(t,n),ur(t,"displayName",n.displayName||null),ur(t,"photoURL",n.photoUrl||null),st(t.providerData,function(n){"password"===n.providerId&&(f(n,"displayName",t.displayName),f(n,"photoURL",t.photoURL))}),tu(t)}).then(pit))};n.Nc=function(n){var t=this;return tt(this,wp(this).then(function(r){return or(yp(t),n)?function(n,t,i){return a(n,oet,{idToken:t,deleteProvider:i})}(t.b,r,[n]).then(function(n){var i={};return st(n.providerUserInfo||[],function(n){i[n.providerId]=!0}),st(yp(t),function(n){i[n]||wit(t,n)}),i[tr.PROVIDER_ID]||f(t,"phoneNumber",null),tu(t)}):tu(t).then(function(){throw new i("no-such-provider");})}))};n.delete=function(){var n=this;return tt(this,this.F().then(function(t){return a(n.b,eet,{idToken:t})}).then(function(){n.dispatchEvent(new oo("userDeleted"))})).then(function(){for(var t=0;t<n.G.length;t++)n.G[t].cancel("app-deleted");hp(n,null);cp(n,null);n.G=[];n.C=!0;lp(n);f(n,"refreshToken",null);n.a&&n.a.unsubscribe(n)})};n.sb=function(n,t){return!!("linkViaPopup"==n&&(this.g||null)==t&&this.f||"reauthViaPopup"==n&&(this.g||null)==t&&this.f||"linkViaRedirect"==n&&(this.aa||null)==t||"reauthViaRedirect"==n&&(this.aa||null)==t)};n.ha=function(n,t,i,r){"linkViaPopup"!=n&&"reauthViaPopup"!=n||r!=(this.g||null)||(i&&this.v?this.v(i):t&&!i&&this.f&&this.f(t),this.c&&(this.c.cancel(),this.c=null),delete this.f,delete this.v)};n.wa=function(n,t){return"linkViaPopup"==n&&t==(this.g||null)?o(this.xb,this):"reauthViaPopup"==n&&t==(this.g||null)?o(this.yb,this):"linkViaRedirect"==n&&(this.aa||null)==t?o(this.xb,this):"reauthViaRedirect"==n&&(this.aa||null)==t?o(this.yb,this):null};n.oc=function(n){var t=this;return kit(this,"linkViaPopup",n,function(){return ic(t,n.providerId).then(function(){return tu(t)})},!1)};n.xc=function(n){return kit(this,"reauthViaPopup",n,function(){return e()},!0)};n.pc=function(n){var t=this;return dit(this,"linkViaRedirect",n,function(){return ic(t,n.providerId)},!1)};n.yc=function(n){return dit(this,"reauthViaRedirect",n,function(){return e()},!0)};n.xb=function(n,t){var i=this,r;return this.c&&(this.c.cancel(),this.c=null),r=null,tt(this,this.F().then(function(r){return vn(i.b,{requestUri:n,sessionId:t,idToken:r})}).then(function(n){return r=rc(i,n,"link"),bit(i,n)}).then(function(){return r}))};n.yb=function(n,t){var i=this,r;return this.c&&(this.c.cancel(),this.c=null),r=null,tt(this,e().then(function(){return ks(yn(i.b,{requestUri:n,sessionId:t}),i.uid)}).then(function(n){return r=rc(i,n,"reauthenticate"),iu(i,n),i.i=null,i.reload()}).then(function(){return r}),!0)};n.gb=function(n){var t=this,i=null;return tt(this,this.F().then(function(t){return i=t,void 0===n||kf(n)?{}:iv(new nv(n))}).then(function(n){return t.b.gb(i,n)}).then(function(n){if(t.email!=n)return t.reload()}).then(function(){}))};n.toJSON=function(){return this.D()};n.D=function(){var n={uid:this.uid,displayName:this.displayName,photoURL:this.photoURL,email:this.email,emailVerified:this.emailVerified,phoneNumber:this.phoneNumber,isAnonymous:this.isAnonymous,providerData:[],apiKey:this.l,appName:this.o,authDomain:this.u,stsTokenManager:this.h.D(),redirectEventId:this.aa||null};return this.metadata&&hi(n,this.metadata.D()),st(this.providerData,function(t){n.providerData.push(function(n){var t,i={};for(t in n)n.hasOwnProperty(t)&&(i[t]=n[t]);return i}(t))}),n};uc={name:"redirectUser",A:"session"};bp.prototype.g=function(){var n=this,t=si("local");af(this,function(){return e().then(function(){return n.c&&"local"!=n.c.A?n.b.get(t,n.a):null}).then(function(i){if(i)return kp(n,"local").then(function(){n.c=t})})})};fc={name:"persistence",A:"session"};bp.prototype.jb=function(n){var r=null,t=this;return function(n){var u=new i("invalid-persistence-type"),r=new i("unsupported-persistence-type"),t;n:{for(t in sf)if(sf[t]==n){t=!0;break n}t=!1}if(!t||"string"!=typeof n)throw u;switch(ui()){case"ReactNative":if("session"===n)throw r;break;case"Node":if("none"!==n)throw r;break;default:if(!wa()&&"none"!==n)throw r;}}(n),af(this,function(){return n!=t.c.A?t.b.get(t.c,t.a).then(function(i){return r=i,kp(t,n)}).then(function(){if(t.c=si(n),r)return t.b.set(t.c,r,t.a)}):e()})};c(ni,ft);c(frt,yt);c(ert,yt);(n=ni.prototype).jb=function(n){return w(this,n=this.h.jb(n))};n.oa=function(n){this.W===n||this.l||(this.W=n,fn(this.b,this.W),this.dispatchEvent(new frt(this.ea())))};n.ea=function(){return this.W};n.Qc=function(){var n=r.navigator;this.oa(n&&(n.languages&&n.languages[0]||n.language||n.userLanguage)||null)};n.qc=function(n){this.G.push(n);en(this.b,h.SDK_VERSION?ku(h.SDK_VERSION,this.G):null);this.dispatchEvent(new ert(this.G))};n.xa=function(){return sr(this.G)};n.toJSON=function(){return{apiKey:v(this).options.apiKey,authDomain:v(this).options.authDomain,appName:v(this).name,currentUser:s(this)&&s(this).D()}};n.sb=function(n,t){switch(n){case"unknown":case"signInViaRedirect":return!0;case"signInViaPopup":return this.g==t&&!!this.f;default:return!1}};n.ha=function(n,t,i,r){"signInViaPopup"==n&&this.g==r&&(i&&this.v?this.v(i):t&&!i&&this.f&&this.f(t),this.c&&(this.c.cancel(),this.c=null),delete this.f,delete this.v)};n.wa=function(n,t){return"signInViaRedirect"==n||"signInViaPopup"==n&&this.g==t&&this.f?o(this.Xb,this):null};n.Xb=function(n,t){var i=this;n={requestUri:n,sessionId:t};this.c&&(this.c.cancel(),this.c=null);var r=null,u=null,f=an(i.b,n).then(function(n){return r=ds(n),u=fv(n),n});return w(this,n=i.V.then(function(){return f}).then(function(n){return ort(i,n)}).then(function(){return pi({user:s(i),credential:r,additionalUserInfo:u,operationType:"signIn"})}))};n.Hc=function(n){var r;if(!wr())return k(new i("operation-not-supported-in-this-environment"));var t=this,u=uv(n.providerId),f=gu(),e=null;return(!ee()||va())&&v(this).options.authDomain&&n.isOAuthProvider&&(e=io(v(this).options.authDomain,v(this).options.apiKey,v(this).name,"signInViaPopup",n,null,f,h.SDK_VERSION||null)),r=dk(e,u&&u.Ba,u&&u.Aa),w(this,u=dp(this).then(function(t){return uit(t,r,"signInViaPopup",n,f,!!e)}).then(function(){return new l(function(n,u){t.ha("signInViaPopup",null,new i("cancelled-popup-request"),t.g);t.f=n;t.v=u;t.g=f;t.c=t.a.Ea(t,"signInViaPopup",r,f)})}).then(function(n){return r&&pr(r),n?pi(n):null}).s(function(n){throw r&&pr(r),n;}))};n.Ic=function(n){if(!wr())return k(new i("operation-not-supported-in-this-environment"));var t=this;return w(this,dp(this).then(function(){return af(n=t.h,function(){return n.b.set(fc,n.c.A,n.a)});var n}).then(function(){return t.a.Ca("signInViaRedirect",n)}))};n.fa=function(){if(!wr())return k(new i("operation-not-supported-in-this-environment"));var n=this;return w(this,dp(this).then(function(){return n.a.fa()}).then(function(n){return n?pi(n):null}))};n.Oc=function(n){var t,r,u;return n?(t=this,r={},r.apiKey=v(this).options.apiKey,r.authDomain=v(this).options.authDomain,r.appName=v(this).name,u=function(n,t,i,r){t=t||{apiKey:n.l,authDomain:n.u,appName:n.o};var f=n.h,u={};return u[kt]=f.b,u.refreshToken=f.a,u.expiresIn=(f.c-fu())/1e3,t=new at(t,u),i&&(t.ba=i),r&&so(t,r),tc(t,n),t}(n,r,t.w,t.xa()),w(this,this.i.then(function(){if(v(t).options.apiKey!=n.l)return u.reload()}).then(function(){return s(t)&&n.uid==s(t).uid?(tc(s(t),n),t.Z(n)):(vf(t,u),ho(u),t.Z(u))}).then(function(){lo(t)}))):k(new i("null-user"))};n.kb=function(){var n=this;return w(this,this.i.then(function(){return s(n)?(vf(n,null),rrt(n.h).then(function(){lo(n)})):e()}))};n.Jc=function(){var n=this;return urt(this.h,v(this).options.authDomain).then(function(t){var i,r;if(!n.l){if((i=s(n)&&t)&&(i=s(n).uid,r=t.uid,i=void 0!==i&&null!==i&&""!==i&&void 0!==r&&null!==r&&""!==r&&i==r),i)return tc(s(n),t),s(n).F();(s(n)||t)&&(vf(n,t),t&&(ho(t),t.ba=n.w),n.a&&n.a.subscribe(n),lo(n))}})};n.Z=function(n){return irt(this.h,n)};n.Yb=function(){lo(this);this.Z(s(this))};n.gc=function(){this.kb()};n.hc=function(){this.kb()};n.ic=function(n){var t=this;this.addAuthTokenListener(function(){n.next(s(t))})};n.jc=function(n){var t=this;!function(n,t){n.I.push(t);w(n,n.i.then(function(){!n.l&&or(n.I,t)&&n.O!==n.getUid()&&(n.O=n.getUid(),t(ec(n)))}))}(this,function(){n.next(s(t))})};n.sc=function(n,t,i){var r=this;return this.X&&h.Promise.resolve().then(function(){ut(n)?n(s(r)):ut(n.next)&&n.next(s(r))}),this.Pb(n,t,i)};n.rc=function(n,t,i){var r=this;return this.X&&h.Promise.resolve().then(function(){r.O=r.getUid();ut(n)?n(s(r)):ut(n.next)&&n.next(s(r))}),this.Qb(n,t,i)};n.$b=function(n){var t=this;return w(this,this.i.then(function(){return s(t)?s(t).F(n).then(function(n){return{accessToken:n}}):null}))};n.Jb=function(n){var t=this;return this.i.then(function(){return co(t,a(t.b,iot,{token:n}))}).then(function(n){var i=n.user;return ur(i,"isAnonymous",!1),t.Z(i),n})};n.Bc=function(n){return nr("firebase.auth.Auth.prototype.signInAndRetrieveDataWithCustomToken is deprecated. Please use firebase.auth.Auth.prototype.signInWithCustomToken instead."),this.Jb(n)};n.Cc=function(n,t){return nr("firebase.auth.Auth.prototype.signInAndRetrieveDataWithEmailAndPassword is deprecated. Please use firebase.auth.Auth.prototype.signInWithEmailAndPassword instead."),this.Kb(n,t)};n.Kb=function(n,t){var i=this;return this.i.then(function(){return co(i,a(i.b,kn,{email:n,password:t}))})};n.ub=function(n,t){var i=this;return this.i.then(function(){return co(i,a(i.b,fet,{email:n,password:t}))})};n.Sb=function(n,t){return nr("firebase.auth.Auth.prototype.createUserAndRetrieveDataWithEmailAndPassword is deprecated. Please use firebase.auth.Auth.prototype.createUserWithEmailAndPassword instead."),this.ub(n,t)};n.Ec=function(n){return nr("firebase.auth.Auth.prototype.signInWithCredential is deprecated. Please use firebase.auth.Auth.prototype.signInAndRetrieveDataWithCredential instead."),this.Oa(n).then(function(n){return n.user})};n.Oa=function(n){var t=this;return this.i.then(function(){return co(t,n.ya(t.b))})};n.Pa=function(){var n=this;return this.i.then(function(){var t=s(n);return t&&t.isAnonymous?pi({user:t,credential:null,additionalUserInfo:pi({providerId:null,isNewUser:!1}),operationType:"signIn"}):co(n,n.b.Pa()).then(function(t){var i=t.user;return ur(i,"isAnonymous",!0),n.Z(i),t})})};n.Dc=function(){return nr("firebase.auth.Auth.prototype.signInAnonymouslyAndRetrieveData is deprecated. Please use firebase.auth.Auth.prototype.signInAnonymously instead."),this.Pa()};n.getUid=function(){return s(this)&&s(this).uid||null};n.Rb=function(n){this.addAuthTokenListener(n);this.u++;0<this.u&&s(this)&&vit(s(this))};n.zc=function(n){var t=this;st(this.o,function(i){i==n&&t.u--});0>this.u&&(this.u=0);0==this.u&&s(this)&&lp(s(this));this.removeAuthTokenListener(n)};n.addAuthTokenListener=function(n){var t=this;this.o.push(n);w(this,this.i.then(function(){t.l||or(t.o,n)&&n(ec(t))}))};n.removeAuthTokenListener=function(n){dt(this.o,function(t){return t==n})};n.delete=function(){this.l=!0;for(var n=0;n<this.N.length;n++)this.N[n].cancel("app-deleted");return this.N=[],this.h&&(n=this.h).b.removeListener(si("local"),n.a,this.ka),this.a&&this.a.unsubscribe(this),h.Promise.resolve()};n.Vb=function(n){return nr("firebase.auth.Auth.prototype.fetchProvidersForEmail is deprecated. Please use firebase.auth.Auth.prototype.fetchSignInMethodsForEmail instead."),w(this,function(n,t){return a(n,pn,{identifier:t,continueUri:ue()?wu():"http://localhost"}).then(function(n){return n.allProviders||[]})}(this.b,n))};n.Wb=function(n){return w(this,function(n,t){return a(n,pn,{identifier:t,continueUri:ue()?wu():"http://localhost"}).then(function(n){return n.signinMethods||[]})}(this.b,n))};n.kc=function(n){return!!eg(n)};n.ib=function(n,t){var r=this;return w(this,e().then(function(){var n=new nv(t);if(!n.c)throw new i("argument-error",tv+" must be true when sending sign in link to email");return iv(n)}).then(function(t){return r.b.ib(n,t)}).then(function(){}))};n.Rc=function(n){return this.Ja(n).then(function(n){return n.data.email})};n.Xa=function(n,t){return w(this,this.b.Xa(n,t).then(function(){}))};n.Ja=function(n){return w(this,this.b.Ja(n).then(function(n){return new function(n){var t={},i=n[eft],r=n[oft];if(!(n=n[sft])||n!=fft&&!i)throw Error("Invalid provider user info!");t[cft]=r||null;t[hft]=i||null;f(this,aft,n);f(this,lft,ga(t))}(n)}))};n.Va=function(n){return w(this,this.b.Va(n).then(function(){}))};n.hb=function(n,t){var i=this;return w(this,e().then(function(){return void 0===t||kf(t)?{}:iv(new nv(t))}).then(function(t){return i.b.hb(n,t)}).then(function(){}))};n.Gc=function(n,t){return w(this,ep(this,n,t,o(this.Oa,this)))};n.Fc=function(n,t){var i=this;return w(this,e().then(function(){var r=fg(n,t||wu());return i.Oa(r)}))};ao.prototype.render=function(){};ao.prototype.reset=function(){};ao.prototype.getResponse=function(){};ao.prototype.execute=function(){};oc=null;yf.prototype.render=function(n,t){return this.a[this.b.toString()]=new sc(n,t),this.b++};yf.prototype.reset=function(n){var t=gp(this,n);n=srt(n);t&&n&&(t.delete(),delete this.a[n])};yf.prototype.getResponse=function(n){return(n=gp(this,n))?n.getResponse():null};yf.prototype.execute=function(n){(n=gp(this,n))&&n.execute()};sc.prototype.getResponse=function(){return nw(this),this.b};sc.prototype.execute=function(){nw(this);var n=this;this.a||(this.a=setTimeout(function(){n.b=function(){for(var n=50,t=[];0<n;)t.push("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".charAt(Math.floor(62*Math.random()))),n--;return t.join("")}();var t=n.c.callback,i=n.c["expired-callback"];if(t)try{t(n.b)}catch(n){}n.a=setTimeout(function(){if(n.a=null,n.b=null,i)try{i()}catch(n){}n.h&&n.execute()},6e4)},500))};sc.prototype.delete=function(){nw(this);this.g=!0;clearTimeout(this.a);this.a=null;pt(this.f,"click",this.i)};tw.prototype.g=function(){return oc||(oc=new yf),e(oc)};tw.prototype.c=function(){};hc=null;hrt=ie("https://www.google.com/recaptcha/api.js?onload=%{onload}&render=explicit&hl=%{hl}");crt=new gi(3e4,6e4);iw.prototype.g=function(n){var t=this;return new l(function(u,f){var o=setTimeout(function(){f(new i("network-request-failed"))},crt.get());!r.grecaptcha||n!==t.f&&!t.b?(r[t.a]=function(){if(r.grecaptcha){t.f=n;var e=r.grecaptcha.render;r.grecaptcha.render=function(n,i){return n=e(n,i),t.b++,n};clearTimeout(o);u(r.grecaptcha)}else clearTimeout(o),f(new i("internal-error"));delete r[t.a]},e(ty(ra(hrt,{onload:t.a,hl:n||""}))).s(function(){clearTimeout(o);f(new i("internal-error","Unable to load external reCAPTCHA dependencies!"))})):(clearTimeout(o),u(r.grecaptcha))})};iw.prototype.c=function(){this.b--};cc=null;var lrt="callback",art="expired-callback",vrt="sitekey",bot="size";(n=rw.prototype).za=function(){var n=this;return this.f?this.f:this.f=uw(this,e().then(function(){if(ue()&&!yi())return la();throw new i("operation-not-supported-in-this-environment","RecaptchaVerifier is only supported in a browser HTTP/HTTPS environment.");}).then(function(){return n.o.g(n.v())}).then(function(t){return n.g=t,a(n.u,wet,{})}).then(function(t){n.a[vrt]=t.recaptchaSiteKey}).s(function(t){throw n.f=null,t;}))};n.render=function(){lc(this);var n=this;return uw(this,this.za().then(function(){var t,i;return null===n.c&&(t=n.l,n.i||(i=re(t),t=rft("DIV"),i.appendChild(t)),n.c=n.g.render(t,n.a)),n.c}))};n.verify=function(){lc(this);var n=this;return uw(this,this.render().then(function(t){return new l(function(i){var u=n.g.getResponse(t),r;u?i(u):(r=function(t){t&&(function(n,t){dt(n.m,function(n){return n==t})}(n,r),i(t))},n.m.push(r),n.i&&n.g.execute(n.c))})}))};n.reset=function(){lc(this);null!==this.c&&this.g.reset(this.c)};n.clear=function(){var n,t;for(lc(this),this.C=!0,this.o.c(),n=0;n<this.h.length;n++)this.h[n].cancel("RecaptchaVerifier instance has been destroyed.");if(!this.i)for(n=re(this.l);t=n.firstChild;)n.removeChild(t)};c(fw,rw);ew="First Second Third Fourth Fifth Sixth Seventh Eighth Ninth".split(" ");rt(ni.prototype,{Va:{name:"applyActionCode",j:[u("code")]},Ja:{name:"checkActionCode",j:[u("code")]},Xa:{name:"confirmPasswordReset",j:[u("code"),u("newPassword")]},ub:{name:"createUserWithEmailAndPassword",j:[u("email"),u("password")]},Sb:{name:"createUserAndRetrieveDataWithEmailAndPassword",j:[u("email"),u("password")]},Vb:{name:"fetchProvidersForEmail",j:[u("email")]},Wb:{name:"fetchSignInMethodsForEmail",j:[u("email")]},fa:{name:"getRedirectResult",j:[]},kc:{name:"isSignInWithEmailLink",j:[u("emailLink")]},rc:{name:"onAuthStateChanged",j:[et(it(),pf(),"nextOrObserver"),pf("opt_error",!0),pf("opt_completed",!0)]},sc:{name:"onIdTokenChanged",j:[et(it(),pf(),"nextOrObserver"),pf("opt_error",!0),pf("opt_completed",!0)]},hb:{name:"sendPasswordResetEmail",j:[u("email"),et(it("opt_actionCodeSettings",!0),fr(null,!0),"opt_actionCodeSettings",!0)]},ib:{name:"sendSignInLinkToEmail",j:[u("email"),it("actionCodeSettings")]},jb:{name:"setPersistence",j:[u("persistence")]},Oa:{name:"signInAndRetrieveDataWithCredential",j:[ru()]},Pa:{name:"signInAnonymously",j:[]},Dc:{name:"signInAnonymouslyAndRetrieveData",j:[]},Ec:{name:"signInWithCredential",j:[ru()]},Jb:{name:"signInWithCustomToken",j:[u("token")]},Bc:{name:"signInAndRetrieveDataWithCustomToken",j:[u("token")]},Kb:{name:"signInWithEmailAndPassword",j:[u("email"),u("password")]},Fc:{name:"signInWithEmailLink",j:[u("email"),u("emailLink",!0)]},Cc:{name:"signInAndRetrieveDataWithEmailAndPassword",j:[u("email"),u("password")]},Gc:{name:"signInWithPhoneNumber",j:[u("phoneNumber"),ac()]},Hc:{name:"signInWithPopup",j:[{name:"authProvider",K:"a valid Auth provider",optional:!1,M:function(n){return!!(n&&n.providerId&&n.hasOwnProperty&&n.hasOwnProperty("isOAuthProvider"))}}]},Ic:{name:"signInWithRedirect",j:[{name:"authProvider",K:"a valid Auth provider",optional:!1,M:function(n){return!!(n&&n.providerId&&n.hasOwnProperty&&n.hasOwnProperty("isOAuthProvider"))}}]},Oc:{name:"updateCurrentUser",j:[et({name:"user",K:"an instance of Firebase User",optional:!1,M:function(n){return!!(n&&n instanceof at)}},fr(),"user")]},kb:{name:"signOut",j:[]},toJSON:{name:"toJSON",j:[u(null,!0)]},Qc:{name:"useDeviceLanguage",j:[]},Rc:{name:"verifyPasswordResetCode",j:[u("code")]}});wrt(ni.prototype,{lc:{name:"languageCode",qb:et(u(),fr(),"languageCode")}});ni.Persistence=sf;ni.Persistence.LOCAL="local";ni.Persistence.SESSION="session";ni.Persistence.NONE="none";rt(at.prototype,{"delete":{name:"delete",j:[]},ac:{name:"getIdTokenResult",j:[ow("opt_forceRefresh",!0)]},F:{name:"getIdToken",j:[ow("opt_forceRefresh",!0)]},ab:{name:"linkAndRetrieveDataWithCredential",j:[ru()]},mc:{name:"linkWithCredential",j:[ru()]},nc:{name:"linkWithPhoneNumber",j:[u("phoneNumber"),ac()]},oc:{name:"linkWithPopup",j:[{name:"authProvider",K:"a valid Auth provider",optional:!1,M:function(n){return!!(n&&n.providerId&&n.hasOwnProperty&&n.hasOwnProperty("isOAuthProvider"))}}]},pc:{name:"linkWithRedirect",j:[{name:"authProvider",K:"a valid Auth provider",optional:!1,M:function(n){return!!(n&&n.providerId&&n.hasOwnProperty&&n.hasOwnProperty("isOAuthProvider"))}}]},cb:{name:"reauthenticateAndRetrieveDataWithCredential",j:[ru()]},vc:{name:"reauthenticateWithCredential",j:[ru()]},wc:{name:"reauthenticateWithPhoneNumber",j:[u("phoneNumber"),ac()]},xc:{name:"reauthenticateWithPopup",j:[{name:"authProvider",K:"a valid Auth provider",optional:!1,M:function(n){return!!(n&&n.providerId&&n.hasOwnProperty&&n.hasOwnProperty("isOAuthProvider"))}}]},yc:{name:"reauthenticateWithRedirect",j:[{name:"authProvider",K:"a valid Auth provider",optional:!1,M:function(n){return!!(n&&n.providerId&&n.hasOwnProperty&&n.hasOwnProperty("isOAuthProvider"))}}]},reload:{name:"reload",j:[]},gb:{name:"sendEmailVerification",j:[et(it("opt_actionCodeSettings",!0),fr(null,!0),"opt_actionCodeSettings",!0)]},toJSON:{name:"toJSON",j:[u(null,!0)]},Nc:{name:"unlink",j:[u("provider")]},mb:{name:"updateEmail",j:[u("email")]},nb:{name:"updatePassword",j:[u("password")]},Pc:{name:"updatePhoneNumber",j:[ru("phone")]},ob:{name:"updateProfile",j:[it("profile")]}});rt(yf.prototype,{execute:{name:"execute"},render:{name:"render"},reset:{name:"reset"},getResponse:{name:"getResponse"}});rt(ao.prototype,{execute:{name:"execute"},render:{name:"render"},reset:{name:"reset"},getResponse:{name:"getResponse"}});rt(l.prototype,{ia:{name:"finally"},s:{name:"catch"},then:{name:"then"}});wrt(hit.prototype,{appVerificationDisabled:{name:"appVerificationDisabledForTesting",qb:ow("appVerificationDisabledForTesting")}});rt(fp.prototype,{confirm:{name:"confirm",j:[u("verificationCode")]}});ot(wt,"credential",function(n,t){return new uf(n,t)},[u("email"),u("password")]);rt(br.prototype,{ta:{name:"addScope",j:[u("scope")]},Da:{name:"setCustomParameters",j:[it("customOAuthParameters")]}});ot(br,"credential",tg,[et(u(),it(),"token")]);ot(wt,"credentialWithLink",fg,[u("email"),u("emailLink")]);rt(kr.prototype,{ta:{name:"addScope",j:[u("scope")]},Da:{name:"setCustomParameters",j:[it("customOAuthParameters")]}});ot(kr,"credential",ig,[et(u(),it(),"token")]);rt(dr.prototype,{ta:{name:"addScope",j:[u("scope")]},Da:{name:"setCustomParameters",j:[it("customOAuthParameters")]}});ot(dr,"credential",rg,[et(u(),et(it(),fr()),"idToken"),et(u(),fr(),"accessToken",!0)]);rt(rf.prototype,{Da:{name:"setCustomParameters",j:[it("customOAuthParameters")]}});ot(rf,"credential",ug,[et(u(),it(),"token"),u("secret",!0)]);rt(lt.prototype,{ta:{name:"addScope",j:[u("scope")]},credential:{name:"credential",j:[et(u(),fr(),"idToken",!0),et(u(),fr(),"accessToken",!0)]},Da:{name:"setCustomParameters",j:[it("customOAuthParameters")]}});ot(tr,"credential",og,[u("verificationId"),u("verificationCode")]);rt(tr.prototype,{Ta:{name:"verifyPhoneNumber",j:[u("phoneNumber"),ac()]}});rt(i.prototype,{toJSON:{name:"toJSON",j:[u(null,!0)]}});rt(ae.prototype,{toJSON:{name:"toJSON",j:[u(null,!0)]}});rt(av.prototype,{toJSON:{name:"toJSON",j:[u(null,!0)]}});rt(fw.prototype,{clear:{name:"clear",j:[]},render:{name:"render",j:[]},verify:{name:"verify",j:[]}}),function(){if(void 0===h||!h.INTERNAL||!h.INTERNAL.registerService)throw Error("Cannot find the firebase namespace; be sure to include firebase-app.js before this library.");var n={Auth:ni,Error:i};ot(n,"EmailAuthProvider",wt,[]);ot(n,"FacebookAuthProvider",br,[]);ot(n,"GithubAuthProvider",kr,[]);ot(n,"GoogleAuthProvider",dr,[]);ot(n,"TwitterAuthProvider",rf,[]);ot(n,"OAuthProvider",lt,[u("providerId")]);ot(n,"PhoneAuthProvider",tr,[{name:"auth",K:"an instance of Firebase Auth",optional:!0,M:function(n){return!!(n&&n instanceof ni)}}]);ot(n,"RecaptchaVerifier",fw,[et(u(),{name:"",K:"an HTML element",optional:!1,M:function(n){return!!(n&&n instanceof Element)}},"recaptchaContainer"),it("recaptchaParameters",!0),{name:"app",K:"an instance of Firebase App",optional:!0,M:function(n){return!!(n&&n instanceof h.app.App)}}]);h.INTERNAL.registerService("auth",function(n,t){return t({INTERNAL:{getUid:o((n=new ni(n)).getUid,n),getToken:o(n.$b,n),addAuthTokenListener:o(n.Rb,n),removeAuthTokenListener:o(n.zc,n)}}),n},n,function(n,t){if("create"===n)try{t.auth()}catch(n){}});h.INTERNAL.extendNamespace({User:at})}()}).call(void 0!==i?i:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})}catch(n){throw console.error(n),new Error("Cannot instantiate firebase-auth - be sure to load firebase-app.js first.");}}(this.firebase=this.firebase||{},firebase);!function(n,t){"use strict";var gu,ef,k,ai,f,ei,ae,l,yu,lo,ao,ku,du,si,vo;try{t=t&&t.hasOwnProperty("default")?t.default:t;gu=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i])};function it(n,t){function i(){this.constructor=n}gu(n,t);n.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}function yo(n,t){function o(e){return function(o){return function(e){if(f)throw new TypeError("Generator is already executing.");for(;r;)try{if(f=1,u&&(i=u[2&e[0]?"return":e[0]?"throw":"next"])&&!(i=i.call(u,e[1])).done)return i;switch(u=0,i&&(e=[0,i.value]),e[0]){case 0:case 1:i=e;break;case 4:return r.label++,{value:e[1],done:!1};case 5:r.label++;u=e[1];e=[0];continue;case 7:e=r.ops.pop();r.trys.pop();continue;default:if(!(i=(i=r.trys).length>0&&i[i.length-1])&&(6===e[0]||2===e[0])){r=0;continue}if(3===e[0]&&(!i||e[1]>i[0]&&e[1]<i[3])){r.label=e[1];break}if(6===e[0]&&r.label<i[1]){r.label=i[1];i=e;break}if(i&&r.label<i[2]){r.label=i[2];r.ops.push(e);break}i[2]&&r.ops.pop();r.trys.pop();continue}e=t.call(n,r)}catch(n){e=[6,n];u=0}finally{f=i=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,o])}}var f,u,i,e,r={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return e={next:o(0),"throw":o(1),"return":o(2)},"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e}var pt={NODE_CLIENT:!1,NODE_ADMIN:!1,SDK_VERSION:"${JSCORE_VERSION}"},i=function(n,t){if(!n)throw ii(t);},ii=function(n){return new Error("Firebase Database ("+pt.SDK_VERSION+") INTERNAL ASSERT FAILED: "+n)},nf=function(n){for(var t,i=[],r=0,u=0;u<n.length;u++)t=n.charCodeAt(u),t<128?i[r++]=t:t<2048?(i[r++]=t>>6|192,i[r++]=63&t|128):55296==(64512&t)&&u+1<n.length&&56320==(64512&n.charCodeAt(u+1))?(t=65536+((1023&t)<<10)+(1023&n.charCodeAt(++u)),i[r++]=t>>18|240,i[r++]=t>>12&63|128,i[r++]=t>>6&63|128,i[r++]=63&t|128):(i[r++]=t>>12|224,i[r++]=t>>6&63|128,i[r++]=63&t|128);return i},pr={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(n,t){if(!Array.isArray(n))throw Error("encodeByteArray takes an array as a parameter");this.init_();for(var r=t?this.byteToCharMapWebSafe_:this.byteToCharMap_,u=[],i=0;i<n.length;i+=3){var f=n[i],e=i+1<n.length,o=e?n[i+1]:0,s=i+2<n.length,h=s?n[i+2]:0,a=f>>2,v=(3&f)<<4|o>>4,c=(15&o)<<2|h>>6,l=63&h;s||(l=64,e||(c=64));u.push(r[a],r[v],r[c],r[l])}return u.join("")},encodeString:function(n,t){return this.HAS_NATIVE_SUPPORT&&!t?btoa(n):this.encodeByteArray(nf(n),t)},decodeString:function(n,t){return this.HAS_NATIVE_SUPPORT&&!t?atob(n):function(n){for(var t,f,e,o,r=[],i=0,u=0;i<n.length;)t=n[i++],t<128?r[u++]=String.fromCharCode(t):t>191&&t<224?(f=n[i++],r[u++]=String.fromCharCode((31&t)<<6|63&f)):t>239&&t<365?(e=((7&t)<<18|(63&(f=n[i++]))<<12|(63&(o=n[i++]))<<6|63&n[i++])-65536,r[u++]=String.fromCharCode(55296+(e>>10)),r[u++]=String.fromCharCode(56320+(1023&e))):(f=n[i++],o=n[i++],r[u++]=String.fromCharCode((15&t)<<12|(63&f)<<6|63&o));return r.join("")}(this.decodeStringToByteArray(n,t))},decodeStringToByteArray:function(n,t){var h,c,l;this.init_();for(var r=t?this.charToByteMapWebSafe_:this.charToByteMap_,u=[],i=0;i<n.length;){var s=r[n.charAt(i++)],e=i<n.length?r[n.charAt(i)]:0,f=++i<n.length?r[n.charAt(i)]:64,o=++i<n.length?r[n.charAt(i)]:64;if(++i,null==s||null==e||null==f||null==o)throw Error();h=s<<2|e>>4;(u.push(h),64!=f)&&(c=e<<4&240|f>>2,(u.push(c),64!=o)&&(l=f<<6&192|o,u.push(l)))}return u},init_:function(){if(!this.byteToCharMap_){this.byteToCharMap_={};this.charToByteMap_={};this.byteToCharMapWebSafe_={};this.charToByteMapWebSafe_={};for(var n=0;n<this.ENCODED_VALS.length;n++)this.byteToCharMap_[n]=this.ENCODED_VALS.charAt(n),this.charToByteMap_[this.byteToCharMap_[n]]=n,this.byteToCharMapWebSafe_[n]=this.ENCODED_VALS_WEBSAFE.charAt(n),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[n]]=n,n>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(n)]=n,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(n)]=n)}}},tf=function(n){try{return pr.decodeString(n,!0)}catch(n){console.error("base64Decode failed: ",n)}return null};function po(n){return function n(t,i){var u,r;if(!(i instanceof Object))return i;switch(i.constructor){case Date:return u=i,new Date(u.getTime());case Object:void 0===t&&(t={});break;case Array:t=[];break;default:return i}for(r in i)i.hasOwnProperty(r)&&(t[r]=n(t[r],i[r]));return t}(void 0,n)}var rt=function(){function n(){var n=this;this.promise=new Promise(function(t,i){n.resolve=t;n.reject=i})}return n.prototype.wrapCallback=function(n){var t=this;return function(i,r){i?t.reject(i):t.resolve(r);"function"==typeof n&&(t.promise.catch(function(){}),1===n.length?n(i):n(i,r))}},n}(),rf=function(){return"undefined"!=typeof window&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test("undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:"")},ut=function(){return!0===pt.NODE_CLIENT||!0===pt.NODE_ADMIN},uf="FirebaseError",ff=Error.captureStackTrace,hi=function(){return function(n,t){if(this.code=n,this.message=t,ff)ff(this,ef.prototype.create);else{var i=Error.apply(this,arguments);this.name=uf;Object.defineProperty(this,"stack",{get:function(){return i.stack}})}}}();hi.prototype=Object.create(Error.prototype);hi.prototype.constructor=hi;hi.prototype.name=uf;ef=function(){function n(n,t,i){this.service=n;this.serviceName=t;this.errors=i;this.pattern=/\{\$([^}]+)}/g}return n.prototype.create=function(n,t){var r,u,f,e,i;void 0===t&&(t={});u=this.errors[n];f=this.service+"/"+n;r=void 0===u?"Error":u.replace(this.pattern,function(n,i){var r=t[i];return void 0!==r?r.toString():"<"+i+"?>"});r=this.serviceName+": "+r+" ("+f+").";e=new hi(f,r);for(i in t)t.hasOwnProperty(i)&&"_"!==i.slice(-1)&&(e[i]=t[i]);return e},n}();function ci(n){return JSON.parse(n)}function a(n){return JSON.stringify(n)}var of=function(n){var r={},t={},u={},f="",i;try{i=n.split(".");r=ci(tf(i[0])||"");t=ci(tf(i[1])||"");f=i[2];u=t.d||{};delete t.d}catch(n){}return{header:r,claims:t,data:u,signature:f}},d=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},p=function(n,t){if(Object.prototype.hasOwnProperty.call(n,t))return n[t]},s=function(n,t){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&t(i,n[i])},wr=function(n){return t={},s(n,function(n,i){t[n]=i}),t;var t},li=function(n){for(var t in n)return!1;return!0},rr=function(n){var t=0,i;for(i in n)t++;return t},ur=function(n,t,i){var u={},r;for(r in n)u[r]=t.call(i,n[r],r,n);return u},sf=function(n,t,i){for(var r in n)if(t.call(i,n[r],r,n))return r},hf=function(n){for(var t in n)return t},wo=function(n){function t(){var t=n.call(this)||this,i;for(t.chain_=[],t.buf_=[],t.W_=[],t.pad_=[],t.inbuf_=0,t.total_=0,t.blockSize=64,t.pad_[0]=128,i=1;i<t.blockSize;++i)t.pad_[i]=0;return t.reset(),t}return it(t,n),t.prototype.reset=function(){this.chain_[0]=1732584193;this.chain_[1]=4023233417;this.chain_[2]=2562383102;this.chain_[3]=271733878;this.chain_[4]=3285377520;this.inbuf_=0;this.total_=0},t.prototype.compress_=function(n,t){var r,i,o;if(t||(t=0),r=this.W_,"string"==typeof n)for(i=0;i<16;i++)r[i]=n.charCodeAt(t)<<24|n.charCodeAt(t+1)<<16|n.charCodeAt(t+2)<<8|n.charCodeAt(t+3),t+=4;else for(i=0;i<16;i++)r[i]=n[t]<<24|n[t+1]<<16|n[t+2]<<8|n[t+3],t+=4;for(i=16;i<80;i++)o=r[i-3]^r[i-8]^r[i-14]^r[i-16],r[i]=4294967295&(o<<1|o>>>31);var s,h,c=this.chain_[0],u=this.chain_[1],f=this.chain_[2],e=this.chain_[3],l=this.chain_[4];for(i=0;i<80;i++)i<40?i<20?(s=e^u&(f^e),h=1518500249):(s=u^f^e,h=1859775393):i<60?(s=u&f|e&(u|f),h=2400959708):(s=u^f^e,h=3395469782),o=(c<<5|c>>>27)+s+l+h+r[i]&4294967295,l=e,e=f,f=4294967295&(u<<30|u>>>2),u=c,c=o;this.chain_[0]=this.chain_[0]+c&4294967295;this.chain_[1]=this.chain_[1]+u&4294967295;this.chain_[2]=this.chain_[2]+f&4294967295;this.chain_[3]=this.chain_[3]+e&4294967295;this.chain_[4]=this.chain_[4]+l&4294967295},t.prototype.update=function(n,t){if(null!=n){void 0===t&&(t=n.length);for(var f=t-this.blockSize,i=0,u=this.buf_,r=this.inbuf_;i<t;){if(0==r)for(;i<=f;)this.compress_(n,i),i+=this.blockSize;if("string"==typeof n){for(;i<t;)if(u[r]=n.charCodeAt(i),++i,++r==this.blockSize){this.compress_(u);r=0;break}}else for(;i<t;)if(u[r]=n[i],++i,++r==this.blockSize){this.compress_(u);r=0;break}}this.inbuf_=r;this.total_+=t}},t.prototype.digest=function(){var r=[],u=8*this.total_,n,i,t;for(this.inbuf_<56?this.update(this.pad_,56-this.inbuf_):this.update(this.pad_,this.blockSize-(this.inbuf_-56)),n=this.blockSize-1;n>=56;n--)this.buf_[n]=255&u,u/=256;for(this.compress_(this.buf_),i=0,n=0;n<5;n++)for(t=24;t>=0;t-=8)r[i]=this.chain_[n]>>t&255,++i;return r},t}(function(){return function(){this.blockSize=-1}}()),u=function(n,t,i,r){var u;if(r<t?u="at least "+t:r>i&&(u=0===i?"none":"no more than "+i),u)throw new Error(n+" failed: Was called with "+r+(1===r?" argument.":" arguments.")+" Expects "+u+".");};function nt(n,t,i){var r="",u;switch(t){case 1:r=i?"first":"First";break;case 2:r=i?"second":"Second";break;case 3:r=i?"third":"Third";break;case 4:r=i?"fourth":"Fourth";break;default:throw new Error("errorPrefix called with argumentNumber > 4.  Need to update it?");}return u=n+" failed: ",u+(r+" argument ")}function v(n,t,i,r){if((!r||i)&&"function"!=typeof i)throw new Error(nt(n,t,r)+"must be a valid function.");}function cf(n,t,i,r){if((!r||i)&&("object"!=typeof i||null===i))throw new Error(nt(n,t,r)+"must be a valid context object.");}ai=function(n){for(var r,t=0,i=0;i<n.length;i++)r=n.charCodeAt(i),r<128?t++:r<2048?t+=2:r>=55296&&r<=56319?(t+=4,i++):t+=3;return t};!function(n){n[n.DEBUG=0]="DEBUG";n[n.VERBOSE=1]="VERBOSE";n[n.INFO=2]="INFO";n[n.WARN=3]="WARN";n[n.ERROR=4]="ERROR";n[n.SILENT=5]="SILENT"}(k||(k={}));var bo=k.INFO,ko=function(n,t){for(var u,i=[],r=2;r<arguments.length;r++)i[r-2]=arguments[r];if(!(t<n.logLevel)){u=(new Date).toISOString();switch(t){case k.DEBUG:case k.VERBOSE:console.log.apply(console,["["+u+"]  "+n.name+":"].concat(i));break;case k.INFO:console.info.apply(console,["["+u+"]  "+n.name+":"].concat(i));break;case k.WARN:console.warn.apply(console,["["+u+"]  "+n.name+":"].concat(i));break;case k.ERROR:console.error.apply(console,["["+u+"]  "+n.name+":"].concat(i));break;default:throw new Error("Attempted to log a message with an invalid logType (value: "+t+")");}}},go=function(){function n(n){this.name=n;this._logLevel=bo;this._logHandler=ko}return Object.defineProperty(n.prototype,"logLevel",{get:function(){return this._logLevel},set:function(n){if(!(n in k))throw new TypeError("Invalid value assigned to `logLevel`");this._logLevel=n},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"logHandler",{get:function(){return this._logHandler},set:function(n){if("function"!=typeof n)throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=n},enumerable:!0,configurable:!0}),n.prototype.debug=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];this._logHandler.apply(this,[this,k.DEBUG].concat(t))},n.prototype.log=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];this._logHandler.apply(this,[this,k.VERBOSE].concat(t))},n.prototype.info=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];this._logHandler.apply(this,[this,k.INFO].concat(t))},n.prototype.warn=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];this._logHandler.apply(this,[this,k.WARN].concat(t))},n.prototype.error=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];this._logHandler.apply(this,[this,k.ERROR].concat(t))},n}(),ns=function(){function n(n){this.domStorage_=n;this.prefix_="firebase:"}return n.prototype.set=function(n,t){null==t?this.domStorage_.removeItem(this.prefixedName_(n)):this.domStorage_.setItem(this.prefixedName_(n),a(t))},n.prototype.get=function(n){var t=this.domStorage_.getItem(this.prefixedName_(n));return null==t?null:ci(t)},n.prototype.remove=function(n){this.domStorage_.removeItem(this.prefixedName_(n))},n.prototype.prefixedName_=function(n){return this.prefix_+n},n.prototype.toString=function(){return this.domStorage_.toString()},n}(),ts=function(){function n(){this.cache_={};this.isInMemoryStorage=!0}return n.prototype.set=function(n,t){null==t?delete this.cache_[n]:this.cache_[n]=t},n.prototype.get=function(n){return d(this.cache_,n)?this.cache_[n]:null},n.prototype.remove=function(n){delete this.cache_[n]},n}(),lf=function(n){try{if("undefined"!=typeof window&&void 0!==window[n]){var t=window[n];return t.setItem("firebase:sentinel","cache"),t.removeItem("firebase:sentinel"),new ns(t)}}catch(n){}return new ts},wt=lf("localStorage"),br=lf("sessionStorage"),ri=new go("@firebase/database"),af=(vo=1,function(){return vo++}),vf=function(n){var u=function(n){for(var t,e,r=[],u=0,f=0;f<n.length;f++)t=n.charCodeAt(f),t>=55296&&t<=56319&&(e=t-55296,i(++f<n.length,"Surrogate pair missing trail surrogate."),t=65536+(e<<10)+(n.charCodeAt(f)-56320)),t<128?r[u++]=t:t<2048?(r[u++]=t>>6|192,r[u++]=63&t|128):t<65536?(r[u++]=t>>12|224,r[u++]=t>>6&63|128,r[u++]=63&t|128):(r[u++]=t>>18|240,r[u++]=t>>12&63|128,r[u++]=t>>6&63|128,r[u++]=63&t|128);return r}(n),t=new wo,r;return t.update(u),r=t.digest(),pr.encodeByteArray(r)},vi=function(){for(var r,t,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];for(r="",t=0;t<n.length;t++)r+=Array.isArray(n[t])||n[t]&&"object"==typeof n[t]&&"number"==typeof n[t].length?vi.apply(null,n[t]):"object"==typeof n[t]?a(n[t]):n[t],r+=" ";return r},bt=null,yf=!0,pf=function(n,t){i(!t||!0===n||!1===n,"Can't turn on custom loggers persistently.");!0===n?(ri.logLevel=k.VERBOSE,bt=ri.log.bind(ri),t&&br.set("logging_enabled",!0)):"function"==typeof n?bt=n:(bt=null,br.remove("logging_enabled"))},w=function(){for(var i,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];(!0===yf&&(yf=!1,null===bt&&!0===br.get("logging_enabled")&&pf(!0)),bt)&&(i=vi.apply(null,t),bt(i))},yi=function(n){return function(){for(var i=[],t=0;t<arguments.length;t++)i[t]=arguments[t];w.apply(void 0,[n].concat(i))}},kr=function(){for(var i,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];i="FIREBASE INTERNAL ERROR: "+vi.apply(void 0,t);ri.error(i)},ot=function(){for(var i,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];i="FIREBASE FATAL ERROR: "+vi.apply(void 0,t);throw ri.error(i),new Error(i);},b=function(){for(var i,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];i="FIREBASE WARNING: "+vi.apply(void 0,t);ri.warn(i)},fr=function(n){return"number"==typeof n&&(n!=n||n==Number.POSITIVE_INFINITY||n==Number.NEGATIVE_INFINITY)},kt="[MIN_NAME]",lt="[MAX_NAME]",dt=function(n,t){if(n===t)return 0;if(n===kt||t===lt)return-1;if(t===kt||n===lt)return 1;var r=df(n),i=df(t);return null!==r?null!==i?r-i==0?n.length-t.length:r-i:-1:null!==i?1:n<t?-1:1},is=function(n,t){return n===t?0:n<t?-1:1},pi=function(n,t){if(t&&n in t)return t[n];throw new Error("Missing required key ("+n+") in object: "+a(t));},dr=function(n){var t,u,i,r;if("object"!=typeof n||null===n)return a(n);t=[];for(u in n)t.push(u);for(t.sort(),i="{",r=0;r<t.length;r++)0!==r&&(i+=","),i+=a(t[r]),i+=":",i+=dr(n[t[r]]);return i+"}"},wf=function(n,t){var r=n.length,u,i;if(r<=t)return[n];for(u=[],i=0;i<r;i+=t)i+t>r?u.push(n.substring(i,r)):u.push(n.substring(i,i+t));return u},bf=function(n,t){if(Array.isArray(n))for(var i=0;i<n.length;++i)t(i,n[i]);else s(n,function(n,i){return t(i,n)})},kf=function(n){var o,r,u,h,t,f,c,s,e;for(i(!fr(n),"Invalid JSON number"),0===n?(r=0,u=0,o=1/n==-1/0?1:0):(o=n<0,(n=Math.abs(n))>=Math.pow(2,-1022)?(r=(h=Math.min(Math.floor(Math.log(n)/Math.LN2),1023))+1023,u=Math.round(n*Math.pow(2,52-h)-Math.pow(2,52))):(r=0,u=Math.round(n/Math.pow(2,-1074)))),f=[],t=52;t;t-=1)f.push(u%2?1:0),u=Math.floor(u/2);for(t=11;t;t-=1)f.push(r%2?1:0),r=Math.floor(r/2);for(f.push(o?1:0),f.reverse(),c=f.join(""),s="",t=0;t<64;t+=8)e=parseInt(c.substr(t,8),2).toString(16),1===e.length&&(e="0"+e),s+=e;return s.toLowerCase()},rs=new RegExp("^-?\\d{1,10}$"),df=function(n){if(rs.test(n)){var t=Number(n);if(t>=-2147483648&&t<=2147483647)return t}return null},ui=function(n){try{n()}catch(n){setTimeout(function(){var t=n.stack||"";throw b("Exception was thrown by user callback.",t),n;},Math.floor(0))}},us=function(){return("object"==typeof window&&window.navigator&&window.navigator.userAgent||"").search(/googlebot|google webmaster tools|bingbot|yahoo! slurp|baiduspider|yandexbot|duckduckbot/i)>=0},wi=function(n,t){var i=setTimeout(n,t);return"object"==typeof i&&i.unref&&i.unref(),i},r=function(){function n(n,t){if(void 0===t){this.pieces_=n.split("/");for(var r=0,i=0;i<this.pieces_.length;i++)this.pieces_[i].length>0&&(this.pieces_[r]=this.pieces_[i],r++);this.pieces_.length=r;this.pieceNum_=0}else this.pieces_=n,this.pieceNum_=t}return Object.defineProperty(n,"Empty",{get:function(){return new n("")},enumerable:!0,configurable:!0}),n.prototype.getFront=function(){return this.pieceNum_>=this.pieces_.length?null:this.pieces_[this.pieceNum_]},n.prototype.getLength=function(){return this.pieces_.length-this.pieceNum_},n.prototype.popFront=function(){var t=this.pieceNum_;return t<this.pieces_.length&&t++,new n(this.pieces_,t)},n.prototype.getBack=function(){return this.pieceNum_<this.pieces_.length?this.pieces_[this.pieces_.length-1]:null},n.prototype.toString=function(){for(var t="",n=this.pieceNum_;n<this.pieces_.length;n++)""!==this.pieces_[n]&&(t+="/"+this.pieces_[n]);return t||"/"},n.prototype.toUrlEncodedString=function(){for(var t="",n=this.pieceNum_;n<this.pieces_.length;n++)""!==this.pieces_[n]&&(t+="/"+encodeURIComponent(String(this.pieces_[n])));return t||"/"},n.prototype.slice=function(n){return void 0===n&&(n=0),this.pieces_.slice(this.pieceNum_+n)},n.prototype.parent=function(){if(this.pieceNum_>=this.pieces_.length)return null;for(var i=[],t=this.pieceNum_;t<this.pieces_.length-1;t++)i.push(this.pieces_[t]);return new n(i,0)},n.prototype.child=function(t){for(var u,r=[],i=this.pieceNum_;i<this.pieces_.length;i++)r.push(this.pieces_[i]);if(t instanceof n)for(i=t.pieceNum_;i<t.pieces_.length;i++)r.push(t.pieces_[i]);else for(u=t.split("/"),i=0;i<u.length;i++)u[i].length>0&&r.push(u[i]);return new n(r,0)},n.prototype.isEmpty=function(){return this.pieceNum_>=this.pieces_.length},n.relativePath=function(t,i){var r=t.getFront(),u=i.getFront();if(null===r)return i;if(r===u)return n.relativePath(t.popFront(),i.popFront());throw new Error("INTERNAL ERROR: innerPath ("+i+") is not within outerPath ("+t+")");},n.comparePaths=function(n,t){for(var f,r=n.slice(),u=t.slice(),i=0;i<r.length&&i<u.length;i++)if(f=dt(r[i],u[i]),0!==f)return f;return r.length===u.length?0:r.length<u.length?-1:1},n.prototype.equals=function(n){if(this.getLength()!==n.getLength())return!1;for(var t=this.pieceNum_,i=n.pieceNum_;t<=this.pieces_.length;t++,i++)if(this.pieces_[t]!==n.pieces_[i])return!1;return!0},n.prototype.contains=function(n){var t=this.pieceNum_,i=n.pieceNum_;if(this.getLength()>n.getLength())return!1;for(;t<this.pieces_.length;){if(this.pieces_[t]!==n.pieces_[i])return!1;++t;++i}return!0},n}(),fs=function(){function n(n,t){this.errorPrefix_=t;this.parts_=n.slice();this.byteLength_=Math.max(1,this.parts_.length);for(var i=0;i<this.parts_.length;i++)this.byteLength_+=ai(this.parts_[i]);this.checkValid_()}return Object.defineProperty(n,"MAX_PATH_DEPTH",{get:function(){return 32},enumerable:!0,configurable:!0}),Object.defineProperty(n,"MAX_PATH_LENGTH_BYTES",{get:function(){return 768},enumerable:!0,configurable:!0}),n.prototype.push=function(n){this.parts_.length>0&&(this.byteLength_+=1);this.parts_.push(n);this.byteLength_+=ai(n);this.checkValid_()},n.prototype.pop=function(){var n=this.parts_.pop();this.byteLength_-=ai(n);this.parts_.length>0&&(this.byteLength_-=1)},n.prototype.checkValid_=function(){if(this.byteLength_>n.MAX_PATH_LENGTH_BYTES)throw new Error(this.errorPrefix_+"has a key path longer than "+n.MAX_PATH_LENGTH_BYTES+" bytes ("+this.byteLength_+").");if(this.parts_.length>n.MAX_PATH_DEPTH)throw new Error(this.errorPrefix_+"path specified exceeds the maximum depth that can be written ("+n.MAX_PATH_DEPTH+") or object contains a cycle "+this.toErrorString());},n.prototype.toErrorString=function(){return 0==this.parts_.length?"":"in property '"+this.parts_.join(".")+"'"},n}(),gf="long_polling",ne=function(){function n(n,t,i,r,u){void 0===u&&(u="");this.secure=t;this.namespace=i;this.webSocketOnly=r;this.persistenceKey=u;this.host=n.toLowerCase();this.domain=this.host.substr(this.host.indexOf(".")+1);this.internalHost=wt.get("host:"+n)||this.host}return n.prototype.needsQueryParam=function(){return this.host!==this.internalHost||this.isCustomHost()},n.prototype.isCacheableHost=function(){return"s-"===this.internalHost.substr(0,2)},n.prototype.isDemoHost=function(){return"firebaseio-demo.com"===this.domain},n.prototype.isCustomHost=function(){return"firebaseio.com"!==this.domain&&"firebaseio-demo.com"!==this.domain},n.prototype.updateHost=function(n){n!==this.internalHost&&(this.internalHost=n,this.isCacheableHost()&&wt.set("host:"+this.host,this.internalHost))},n.prototype.connectionURL=function(n,t){var r,u;if(i("string"==typeof n,"typeof type must == string"),i("object"==typeof t,"typeof params must == object"),"websocket"===n)r=(this.secure?"wss://":"ws://")+this.internalHost+"/.ws?";else{if(n!==gf)throw new Error("Unknown connection type: "+n);r=(this.secure?"https://":"http://")+this.internalHost+"/.lp?"}return this.needsQueryParam()&&(t.ns=this.namespace),u=[],s(t,function(n,t){u.push(n+"="+t)}),r+u.join("&")},n.prototype.toString=function(){var n=this.toURLString();return this.persistenceKey&&(n+="<"+this.persistenceKey+">"),n},n.prototype.toURLString=function(){return(this.secure?"https://":"http://")+this.host},n}(),er,gr,te=function(n){var t=es(n),i=t.subdomain,u;return"firebase"===t.domain&&ot(t.host+" is no longer supported. Please use <YOUR FIREBASE>.firebaseio.com instead"),i&&"undefined"!=i||"localhost"===t.domain||ot("Cannot parse Firebase url. Please use https://<YOUR FIREBASE>.firebaseio.com"),t.secure||"undefined"!=typeof window&&window.location&&window.location.protocol&&-1!==window.location.protocol.indexOf("https:")&&b("Insecure Firebase access from a secure page. Please use https in calls to new Firebase()."),u="ws"===t.scheme||"wss"===t.scheme,{repoInfo:new ne(t.host,t.secure,i,u),path:new r(t.pathString)}},es=function(n){var f="",e="",o="",c="",l=!0,s="https",a=443,t,u,i,h,r;return"string"==typeof n&&(t=n.indexOf("//"),t>=0&&(s=n.substring(0,t-1),n=n.substring(t+2)),u=n.indexOf("/"),-1===u&&(u=n.length),i=n.indexOf("?"),-1===i&&(i=n.length),f=n.substring(0,Math.min(u,i)),u<i&&(c=function(n){for(var i,u="",r=n.split("/"),t=0;t<r.length;t++)if(r[t].length>0){i=r[t];try{i=decodeURIComponent(i.replace(/\+/g," "))}catch(n){}u+="/"+i}return u}(n.substring(u,i))),h=function(n){var f={},t,u,i,r;for(n.startsWith("?")&&(n=n.substring(1)),t=0,u=n.split("&");t<u.length;t++)i=u[t],0!==i.length&&(r=i.split("="),2===r.length?f[decodeURIComponent(r[0])]=decodeURIComponent(r[1]):b("Invalid query segment '"+i+"' in query '"+n+"'"));return f}(n.substring(Math.min(n.length,i))),(t=f.indexOf(":"))>=0?(l="https"===s||"wss"===s,a=parseInt(f.substring(t+1),10)):t=n.length,r=f.split("."),3===r.length?(e=r[1],o=r[0].toLowerCase()):2===r.length?e=r[0]:"localhost"===r[0].slice(0,t).toLowerCase()&&(e="localhost"),""===o&&"ns"in h&&(o=h.ns)),{host:f,port:a,domain:e,subdomain:o,secure:l,scheme:s,pathString:c}},os=/[\[\].#$\/\u0000-\u001F\u007F]/,ss=/[\[\].#$\u0000-\u001F\u007F]/,or=function(n){return"string"==typeof n&&0!==n.length&&!os.test(n)},ie=function(n){return"string"==typeof n&&0!==n.length&&!ss.test(n)},bi=function(n){return null===n||"string"==typeof n||"number"==typeof n&&!fr(n)||n&&"object"==typeof n&&d(n,".sv")},at=function(n,t,i,r,u){u&&void 0===i||ki(nt(n,t,u),i,r)},ki=function(n,t,i){var u=i instanceof r?new fs(i,n):i,f,e;if(void 0===t)throw new Error(n+"contains undefined "+u.toErrorString());if("function"==typeof t)throw new Error(n+"contains a function "+u.toErrorString()+" with contents = "+t.toString());if(fr(t))throw new Error(n+"contains "+t.toString()+" "+u.toErrorString());if("string"==typeof t&&t.length>10485760/3&&ai(t)>10485760)throw new Error(n+"contains a string greater than 10485760 utf8 bytes "+u.toErrorString()+" ('"+t.substring(0,50)+"...')");if(t&&"object"==typeof t&&(f=!1,e=!1,s(t,function(t,i){if(".value"===t)f=!0;else if(".priority"!==t&&".sv"!==t&&(e=!0,!or(t)))throw new Error(n+" contains an invalid key ("+t+") "+u.toErrorString()+'.  Keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]"');u.push(t);ki(n,i,u);u.pop()}),f&&e))throw new Error(n+' contains ".value" child '+u.toErrorString()+" in addition to actual children.");},re=function(n,t,i,u,f){var e,o;if(!f||void 0!==i){if(e=nt(n,t,f),!i||"object"!=typeof i||Array.isArray(i))throw new Error(e+" must be an object containing the children to replace.");o=[];s(i,function(n,t){var i=new r(n);if(ki(e,t,u.child(i)),".priority"===i.getBack()&&!bi(t))throw new Error(e+"contains an invalid value for '"+i.toString()+"', which must be a valid Firebase priority (a string, finite number, server value, or null).");o.push(i)}),function(n,t){for(var f,e,u,o,i=0;i<t.length;i++)for(e=(f=t[i]).slice(),u=0;u<e.length;u++)if((".priority"!==e[u]||u!==e.length-1)&&!or(e[u]))throw new Error(n+"contains an invalid key ("+e[u]+") in path "+f.toString()+'. Keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]"');for(t.sort(r.comparePaths),o=null,i=0;i<t.length;i++){if(f=t[i],null!==o&&o.contains(f))throw new Error(n+"contains a path "+o.toString()+" that is ancestor of another path "+f.toString());o=f}}(e,o)}},nu=function(n,t,i,r){if(!r||void 0!==i){if(fr(i))throw new Error(nt(n,t,r)+"is "+i.toString()+", but must be a valid Firebase priority (a string, finite number, server value, or null).");if(!bi(i))throw new Error(nt(n,t,r)+"must be a valid Firebase priority (a string, finite number, server value, or null).");}},tu=function(n,t,i,r){if(!r||void 0!==i)switch(i){case"value":case"child_added":case"child_removed":case"child_changed":case"child_moved":break;default:throw new Error(nt(n,t,r)+'must be a valid event type = "value", "child_added", "child_removed", "child_changed", or "child_moved".');}},iu=function(n,t,i,r){if(!(r&&void 0===i||or(i)))throw new Error(nt(n,t,r)+'was an invalid key = "'+i+'".  Firebase keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]").');},di=function(n,t,i,r){if(!(r&&void 0===i||ie(i)))throw new Error(nt(n,t,r)+'was an invalid path = "'+i+'". Paths must be non-empty strings and can\'t contain ".", "#", "$", "[", or "]"');},tt=function(n,t){if(".info"===t.getFront())throw new Error(n+" failed = Can't modify data under /.info/");},ue=function(n,t,i){var r=i.path.toString();if("string"!=typeof i.repoInfo.host||0===i.repoInfo.host.length||!or(i.repoInfo.namespace)&&"localhost"!==i.repoInfo.host.split(":")[0]||0!==r.length&&!function(n){return n&&(n=n.replace(/^\/*\.info(\/|$)/,"/")),ie(n)}(r))throw new Error(nt(n,t,!1)+'must be a valid firebase URL and the path can\'t contain ".", "#", "$", "[", or "]".');},hs=function(){function n(n,t){this.repo_=n;this.path_=t}return n.prototype.cancel=function(n){u("OnDisconnect.cancel",0,1,arguments.length);v("OnDisconnect.cancel",1,n,!0);var t=new rt;return this.repo_.onDisconnectCancel(this.path_,t.wrapCallback(n)),t.promise},n.prototype.remove=function(n){u("OnDisconnect.remove",0,1,arguments.length);tt("OnDisconnect.remove",this.path_);v("OnDisconnect.remove",1,n,!0);var t=new rt;return this.repo_.onDisconnectSet(this.path_,null,t.wrapCallback(n)),t.promise},n.prototype.set=function(n,t){u("OnDisconnect.set",1,2,arguments.length);tt("OnDisconnect.set",this.path_);at("OnDisconnect.set",1,n,this.path_,!1);v("OnDisconnect.set",2,t,!0);var i=new rt;return this.repo_.onDisconnectSet(this.path_,n,i.wrapCallback(t)),i.promise},n.prototype.setWithPriority=function(n,t,i){u("OnDisconnect.setWithPriority",2,3,arguments.length);tt("OnDisconnect.setWithPriority",this.path_);at("OnDisconnect.setWithPriority",1,n,this.path_,!1);nu("OnDisconnect.setWithPriority",2,t,!1);v("OnDisconnect.setWithPriority",3,i,!0);var r=new rt;return this.repo_.onDisconnectSetWithPriority(this.path_,n,t,r.wrapCallback(i)),r.promise},n.prototype.update=function(n,t){var r,i,f;if(u("OnDisconnect.update",1,2,arguments.length),tt("OnDisconnect.update",this.path_),Array.isArray(n)){for(r={},i=0;i<n.length;++i)r[""+i]=n[i];n=r;b("Passing an Array to firebase.database.onDisconnect().update() is deprecated. Use set() if you want to overwrite the existing data, or an Object with integer keys if you really do want to only update some of the children.")}return re("OnDisconnect.update",1,n,this.path_,!1),v("OnDisconnect.update",2,t,!0),f=new rt,this.repo_.onDisconnectUpdate(this.path_,n,f.wrapCallback(t)),f.promise},n}(),cs=function(){function n(n,t){this.committed=n;this.snapshot=t}return n.prototype.toJSON=function(){return u("TransactionResult.toJSON",0,1,arguments.length),{committed:this.committed,snapshot:this.snapshot.toJSON()}},n}(),ls=(ku="-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz",du=0,si=[],function(n){var t,f=n===du,u,r;for(du=n,u=new Array(8),t=7;t>=0;t--)u[t]=ku.charAt(n%64),n=Math.floor(n/64);if(i(0===n,"Cannot push at time == 0"),r=u.join(""),f){for(t=11;t>=0&&63===si[t];t--)si[t]=0;si[t]++}else for(t=0;t<12;t++)si[t]=Math.floor(64*Math.random());for(t=0;t<12;t++)r+=ku.charAt(si[t]);return i(20===r.length,"nextPushId: Length should be 20."),r}),o=function(){function n(n,t){this.name=n;this.node=t}return n.Wrap=function(t,i){return new n(t,i)},n}(),sr=function(){function n(){}return n.prototype.getCompare=function(){return this.compare.bind(this)},n.prototype.indexedValueChanged=function(n,t){var i=new o(kt,n),r=new o(kt,t);return 0!==this.compare(i,r)},n.prototype.minPost=function(){return o.MIN},n}(),fe=function(n){function t(){return null!==n&&n.apply(this,arguments)||this}return it(t,n),Object.defineProperty(t,"__EMPTY_NODE",{get:function(){return er},set:function(n){er=n},enumerable:!0,configurable:!0}),t.prototype.compare=function(n,t){return dt(n.name,t.name)},t.prototype.isDefinedOn=function(){throw ii("KeyIndex.isDefinedOn not expected to be called.");},t.prototype.indexedValueChanged=function(){return!1},t.prototype.minPost=function(){return o.MIN},t.prototype.maxPost=function(){return new o(lt,er)},t.prototype.makePost=function(n){return i("string"==typeof n,"KeyIndex indexValue must always be a string."),new o(n,er)},t.prototype.toString=function(){return".key"},t}(sr),vt=new fe,ee,oe,se,he=function(n){return"number"==typeof n?"number:"+kf(n):"string:"+n},ce=function(n){if(n.isLeafNode()){var t=n.val();i("string"==typeof t||"number"==typeof t||"object"==typeof t&&d(t,".sv"),"Priority must be a string or number.")}else i(n===gr||n.isEmpty(),"priority of unexpected type.");i(n===gr||n.getPriority().isEmpty(),"Priority nodes can't have a priority of their own.")},fi=function(){function n(t,r){void 0===r&&(r=n.__childrenNodeConstructor.EMPTY_NODE);this.value_=t;this.priorityNode_=r;this.lazyHash_=null;i(void 0!==this.value_&&null!==this.value_,"LeafNode shouldn't be created with null/undefined value.");ce(this.priorityNode_)}return Object.defineProperty(n,"__childrenNodeConstructor",{get:function(){return ee},set:function(n){ee=n},enumerable:!0,configurable:!0}),n.prototype.isLeafNode=function(){return!0},n.prototype.getPriority=function(){return this.priorityNode_},n.prototype.updatePriority=function(t){return new n(this.value_,t)},n.prototype.getImmediateChild=function(t){return".priority"===t?this.priorityNode_:n.__childrenNodeConstructor.EMPTY_NODE},n.prototype.getChild=function(t){return t.isEmpty()?this:".priority"===t.getFront()?this.priorityNode_:n.__childrenNodeConstructor.EMPTY_NODE},n.prototype.hasChild=function(){return!1},n.prototype.getPredecessorChildName=function(){return null},n.prototype.updateImmediateChild=function(t,i){return".priority"===t?this.updatePriority(i):i.isEmpty()&&".priority"!==t?this:n.__childrenNodeConstructor.EMPTY_NODE.updateImmediateChild(t,i).updatePriority(this.priorityNode_)},n.prototype.updateChild=function(t,r){var u=t.getFront();return null===u?r:r.isEmpty()&&".priority"!==u?this:(i(".priority"!==u||1===t.getLength(),".priority must be the last token in a path"),this.updateImmediateChild(u,n.__childrenNodeConstructor.EMPTY_NODE.updateChild(t.popFront(),r)))},n.prototype.isEmpty=function(){return!1},n.prototype.numChildren=function(){return 0},n.prototype.forEachChild=function(){return!1},n.prototype.val=function(n){return n&&!this.getPriority().isEmpty()?{".value":this.getValue(),".priority":this.getPriority().val()}:this.getValue()},n.prototype.hash=function(){var n,t;return null===this.lazyHash_&&(n="",this.priorityNode_.isEmpty()||(n+="priority:"+he(this.priorityNode_.val())+":"),t=typeof this.value_,n+=t+":",n+="number"===t?kf(this.value_):this.value_,this.lazyHash_=vf(n)),this.lazyHash_},n.prototype.getValue=function(){return this.value_},n.prototype.compareTo=function(t){return t===n.__childrenNodeConstructor.EMPTY_NODE?1:t instanceof n.__childrenNodeConstructor?-1:(i(t.isLeafNode(),"Unknown node type"),this.compareToLeafNode_(t))},n.prototype.compareToLeafNode_=function(t){var e=typeof t.value_,r=typeof this.value_,u=n.VALUE_TYPE_ORDER.indexOf(e),f=n.VALUE_TYPE_ORDER.indexOf(r);return i(u>=0,"Unknown leaf type: "+e),i(f>=0,"Unknown leaf type: "+r),u===f?"object"===r?0:this.value_<t.value_?-1:this.value_===t.value_?0:1:f-u},n.prototype.withIndex=function(){return this},n.prototype.isIndexed=function(){return!0},n.prototype.equals=function(n){if(n===this)return!0;if(n.isLeafNode()){var t=n;return this.value_===t.value_&&this.priorityNode_.equals(t.priorityNode_)}return!1},n.VALUE_TYPE_ORDER=["object","boolean","number","string"],n}(),le,gi,h=new(function(n){function t(){return null!==n&&n.apply(this,arguments)||this}return it(t,n),t.prototype.compare=function(n,t){var r=n.node.getPriority(),u=t.node.getPriority(),i=r.compareTo(u);return 0===i?dt(n.name,t.name):i},t.prototype.isDefinedOn=function(n){return!n.getPriority().isEmpty()},t.prototype.indexedValueChanged=function(n,t){return!n.getPriority().equals(t.getPriority())},t.prototype.minPost=function(){return o.MIN},t.prototype.maxPost=function(){return new o(lt,new fi("[PRIORITY-POST]",se))},t.prototype.makePost=function(n,t){var i=oe(n);return new o(t,new fi("[PRIORITY-POST]",i))},t.prototype.toString=function(){return".priority"},t}(sr)),hr=function(){function n(n,t,i,r,u){void 0===u&&(u=null);this.isReverse_=r;this.resultGenerator_=u;this.nodeStack_=[];for(var f=1;!n.isEmpty();)if(n=n,f=t?i(n.key,t):1,r&&(f*=-1),f<0)n=this.isReverse_?n.left:n.right;else{if(0===f){this.nodeStack_.push(n);break}this.nodeStack_.push(n);n=this.isReverse_?n.right:n.left}}return n.prototype.getNext=function(){if(0===this.nodeStack_.length)return null;var t,n=this.nodeStack_.pop();if(t=this.resultGenerator_?this.resultGenerator_(n.key,n.value):{key:n.key,value:n.value},this.isReverse_)for(n=n.left;!n.isEmpty();)this.nodeStack_.push(n),n=n.right;else for(n=n.right;!n.isEmpty();)this.nodeStack_.push(n),n=n.left;return t},n.prototype.hasNext=function(){return this.nodeStack_.length>0},n.prototype.peek=function(){if(0===this.nodeStack_.length)return null;var n=this.nodeStack_[this.nodeStack_.length-1];return this.resultGenerator_?this.resultGenerator_(n.key,n.value):{key:n.key,value:n.value}},n}(),ft=function(){function n(t,i,r,u,f){this.key=t;this.value=i;this.color=null!=r?r:n.RED;this.left=null!=u?u:yt.EMPTY_NODE;this.right=null!=f?f:yt.EMPTY_NODE}return n.prototype.copy=function(t,i,r,u,f){return new n(null!=t?t:this.key,null!=i?i:this.value,null!=r?r:this.color,null!=u?u:this.left,null!=f?f:this.right)},n.prototype.count=function(){return this.left.count()+1+this.right.count()},n.prototype.isEmpty=function(){return!1},n.prototype.inorderTraversal=function(n){return this.left.inorderTraversal(n)||n(this.key,this.value)||this.right.inorderTraversal(n)},n.prototype.reverseTraversal=function(n){return this.right.reverseTraversal(n)||n(this.key,this.value)||this.left.reverseTraversal(n)},n.prototype.min_=function(){return this.left.isEmpty()?this:this.left.min_()},n.prototype.minKey=function(){return this.min_().key},n.prototype.maxKey=function(){return this.right.isEmpty()?this.key:this.right.maxKey()},n.prototype.insert=function(n,t,i){var u,r;return(r=(u=i(n,(r=this).key))<0?r.copy(null,null,null,r.left.insert(n,t,i),null):0===u?r.copy(null,t,null,null,null):r.copy(null,null,null,null,r.right.insert(n,t,i))).fixUp_()},n.prototype.removeMin_=function(){if(this.left.isEmpty())return yt.EMPTY_NODE;var n=this;return n.left.isRed_()||n.left.left.isRed_()||(n=n.moveRedLeft_()),(n=n.copy(null,null,null,n.left.removeMin_(),null)).fixUp_()},n.prototype.remove=function(n,t){var i,r;if(t(n,(i=this).key)<0)i.left.isEmpty()||i.left.isRed_()||i.left.left.isRed_()||(i=i.moveRedLeft_()),i=i.copy(null,null,null,i.left.remove(n,t),null);else{if(i.left.isRed_()&&(i=i.rotateRight_()),i.right.isEmpty()||i.right.isRed_()||i.right.left.isRed_()||(i=i.moveRedRight_()),0===t(n,i.key)){if(i.right.isEmpty())return yt.EMPTY_NODE;r=i.right.min_();i=i.copy(r.key,r.value,null,null,i.right.removeMin_())}i=i.copy(null,null,null,null,i.right.remove(n,t))}return i.fixUp_()},n.prototype.isRed_=function(){return this.color},n.prototype.fixUp_=function(){var n=this;return n.right.isRed_()&&!n.left.isRed_()&&(n=n.rotateLeft_()),n.left.isRed_()&&n.left.left.isRed_()&&(n=n.rotateRight_()),n.left.isRed_()&&n.right.isRed_()&&(n=n.colorFlip_()),n},n.prototype.moveRedLeft_=function(){var n=this.colorFlip_();return n.right.left.isRed_()&&(n=(n=(n=n.copy(null,null,null,null,n.right.rotateRight_())).rotateLeft_()).colorFlip_()),n},n.prototype.moveRedRight_=function(){var n=this.colorFlip_();return n.left.left.isRed_()&&(n=(n=n.rotateRight_()).colorFlip_()),n},n.prototype.rotateLeft_=function(){var t=this.copy(null,null,n.RED,null,this.right.left);return this.right.copy(null,null,this.color,t,null)},n.prototype.rotateRight_=function(){var t=this.copy(null,null,n.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,t)},n.prototype.colorFlip_=function(){var n=this.left.copy(null,null,!this.left.color,null,null),t=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,n,t)},n.prototype.checkMaxDepth_=function(){var n=this.check_();return Math.pow(2,n)<=this.count()+1},n.prototype.check_=function(){var n;if(this.isRed_()&&this.left.isRed_())throw new Error("Red node has red child("+this.key+","+this.value+")");if(this.right.isRed_())throw new Error("Right child of ("+this.key+","+this.value+") is red");if((n=this.left.check_())!==this.right.check_())throw new Error("Black depths differ");return n+(this.isRed_()?0:1)},n.RED=!0,n.BLACK=!1,n}(),as=function(){function n(){}return n.prototype.copy=function(){return this},n.prototype.insert=function(n,t){return new ft(n,t,null)},n.prototype.remove=function(){return this},n.prototype.count=function(){return 0},n.prototype.isEmpty=function(){return!0},n.prototype.inorderTraversal=function(){return!1},n.prototype.reverseTraversal=function(){return!1},n.prototype.minKey=function(){return null},n.prototype.maxKey=function(){return null},n.prototype.check_=function(){return 0},n.prototype.isRed_=function(){return!1},n}(),yt=function(){function n(t,i){void 0===i&&(i=n.EMPTY_NODE);this.comparator_=t;this.root_=i}return n.prototype.insert=function(t,i){return new n(this.comparator_,this.root_.insert(t,i,this.comparator_).copy(null,null,ft.BLACK,null,null))},n.prototype.remove=function(t){return new n(this.comparator_,this.root_.remove(t,this.comparator_).copy(null,null,ft.BLACK,null,null))},n.prototype.get=function(n){for(var i,t=this.root_;!t.isEmpty();){if(0===(i=this.comparator_(n,t.key)))return t.value;i<0?t=t.left:i>0&&(t=t.right)}return null},n.prototype.getPredecessorKey=function(n){for(var i,t=this.root_,r=null;!t.isEmpty();){if(0===(i=this.comparator_(n,t.key))){if(t.left.isEmpty())return r?r.key:null;for(t=t.left;!t.right.isEmpty();)t=t.right;return t.key}i<0?t=t.left:i>0&&(r=t,t=t.right)}throw new Error("Attempted to find predecessor key for a nonexistent key.  What gives?");},n.prototype.isEmpty=function(){return this.root_.isEmpty()},n.prototype.count=function(){return this.root_.count()},n.prototype.minKey=function(){return this.root_.minKey()},n.prototype.maxKey=function(){return this.root_.maxKey()},n.prototype.inorderTraversal=function(n){return this.root_.inorderTraversal(n)},n.prototype.reverseTraversal=function(n){return this.root_.reverseTraversal(n)},n.prototype.getIterator=function(n){return new hr(this.root_,null,this.comparator_,!1,n)},n.prototype.getIteratorFrom=function(n,t){return new hr(this.root_,n,this.comparator_,!1,t)},n.prototype.getReverseIteratorFrom=function(n,t){return new hr(this.root_,n,this.comparator_,!0,t)},n.prototype.getReverseIterator=function(n){return new hr(this.root_,null,this.comparator_,!0,n)},n.EMPTY_NODE=new as,n}(),vs=Math.log(2),ys=function(){function n(n){var t,i,r;this.count=(t=n+1,parseInt(Math.log(t)/vs,10));this.current_=this.count-1;r=(i=this.count,parseInt(Array(i+1).join("1"),2));this.bits_=n+1&r}return n.prototype.nextBitIsOne=function(){var n=!(this.bits_&1<<this.current_);return this.current_--,n},n}(),cr=function(n,t,i,r){n.sort(t);var u=function(t,r){var f,e,o=r-t;if(0==o)return null;if(1==o)return f=n[t],e=i?i(f):f,new ft(e,f.node,ft.BLACK,null,null);var s=parseInt(o/2,10)+t,h=u(t,s),c=u(s+1,r);return f=n[s],e=i?i(f):f,new ft(e,f.node,ft.BLACK,h,c)},f=function(t){for(var c,f,r=null,h=null,e=n.length,o=function(t,r){var o=e-t,s=e;e-=t;var h=u(o+1,s),f=n[o],c=i?i(f):f;l(new ft(c,f.node,r,null,h))},l=function(n){r?(r.left=n,r=n):(h=n,r=n)},s=0;s<t.count;++s)c=t.nextBitIsOne(),f=Math.pow(2,t.count-(s+1)),c?o(f,ft.BLACK):(o(f,ft.BLACK),o(f,ft.RED));return h}(new ys(n.length));return new yt(r||t,f)},gt={},lr=function(){function n(n,t){this.indexes_=n;this.indexSet_=t}return Object.defineProperty(n,"Default",{get:function(){return i(gt&&h,"ChildrenNode.ts has not been loaded"),le=le||new n({".priority":gt},{".priority":h})},enumerable:!0,configurable:!0}),n.prototype.get=function(n){var t=p(this.indexes_,n);if(!t)throw new Error("No index defined for "+n);return t===gt?null:t},n.prototype.hasIndex=function(n){return d(this.indexSet_,n.toString())},n.prototype.addIndex=function(t,r){var e,s,h;i(t!==vt,"KeyIndex always exists and isn't meant to be added to the IndexMap.");for(var c,l=[],f=!1,a=r.getIterator(o.Wrap),u=a.getNext();u;)f=f||t.isDefinedOn(u.node),l.push(u),u=a.getNext();return c=f?cr(l,t.getCompare()):gt,e=t.toString(),s=wr(this.indexSet_),s[e]=t,h=wr(this.indexes_),h[e]=c,new n(h,s)},n.prototype.addToIndexes=function(t,r){var u=this;return new n(ur(this.indexes_,function(n,f){var h=p(u.indexSet_,f),l,s;if(i(h,"Missing index implementation for "+f),n===gt){if(h.isDefinedOn(t.node)){for(var c=[],a=r.getIterator(o.Wrap),e=a.getNext();e;)e.name!=t.name&&c.push(e),e=a.getNext();return c.push(t),cr(c,h.getCompare())}return gt}return l=r.get(t.name),s=n,l&&(s=s.remove(new o(t.name,l))),s.insert(t,t.node)}),this.indexSet_)},n.prototype.removeFromIndexes=function(t,i){return new n(ur(this.indexes_,function(n){if(n===gt)return n;var r=i.get(t.name);return r?n.remove(new o(t.name,r)):n}),this.indexSet_)},n}();function ps(n,t){return dt(n.name,t.name)}function ru(n,t){return dt(n,t)}f=function(){function n(n,t,r){this.children_=n;this.priorityNode_=t;this.indexMap_=r;this.lazyHash_=null;this.priorityNode_&&ce(this.priorityNode_);this.children_.isEmpty()&&i(!this.priorityNode_||this.priorityNode_.isEmpty(),"An empty node cannot have a priority")}return Object.defineProperty(n,"EMPTY_NODE",{get:function(){return gi||(gi=new n(new yt(ru),null,lr.Default))},enumerable:!0,configurable:!0}),n.prototype.isLeafNode=function(){return!1},n.prototype.getPriority=function(){return this.priorityNode_||gi},n.prototype.updatePriority=function(t){return this.children_.isEmpty()?this:new n(this.children_,t,this.indexMap_)},n.prototype.getImmediateChild=function(n){if(".priority"===n)return this.getPriority();var t=this.children_.get(n);return null===t?gi:t},n.prototype.getChild=function(n){var t=n.getFront();return null===t?this:this.getImmediateChild(t).getChild(n.popFront())},n.prototype.hasChild=function(n){return null!==this.children_.get(n)},n.prototype.updateImmediateChild=function(t,r){if(i(r,"We should always be passing snapshot nodes"),".priority"===t)return this.updatePriority(r);var e=new o(t,r),u=void 0,f=void 0;return r.isEmpty()?(u=this.children_.remove(t),f=this.indexMap_.removeFromIndexes(e,this.children_)):(u=this.children_.insert(t,r),f=this.indexMap_.addToIndexes(e,this.children_)),new n(u,u.isEmpty()?gi:this.priorityNode_,f)},n.prototype.updateChild=function(n,t){var r=n.getFront(),u;return null===r?t:(i(".priority"!==n.getFront()||1===n.getLength(),".priority must be the last token in a path"),u=this.getImmediateChild(r).updateChild(n.popFront(),t),this.updateImmediateChild(r,u))},n.prototype.isEmpty=function(){return this.children_.isEmpty()},n.prototype.numChildren=function(){return this.children_.count()},n.prototype.val=function(t){var f,e;if(this.isEmpty())return null;var i={},o=0,r=0,u=!0;if(this.forEachChild(h,function(f,e){i[f]=e.val(t);o++;u&&n.INTEGER_REGEXP_.test(f)?r=Math.max(r,Number(f)):u=!1}),!t&&u&&r<2*o){f=[];for(e in i)f[e]=i[e];return f}return t&&!this.getPriority().isEmpty()&&(i[".priority"]=this.getPriority().val()),i},n.prototype.hash=function(){if(null===this.lazyHash_){var n="";this.getPriority().isEmpty()||(n+="priority:"+he(this.getPriority().val())+":");this.forEachChild(h,function(t,i){var r=i.hash();""!==r&&(n+=":"+t+":"+r)});this.lazyHash_=""===n?"":vf(n)}return this.lazyHash_},n.prototype.getPredecessorChildName=function(n,t,i){var u=this.resolveIndex_(i),r;return u?(r=u.getPredecessorKey(new o(n,t)),r?r.name:null):this.children_.getPredecessorKey(n)},n.prototype.getFirstChildName=function(n){var i=this.resolveIndex_(n),t;return i?(t=i.minKey(),t&&t.name):this.children_.minKey()},n.prototype.getFirstChild=function(n){var t=this.getFirstChildName(n);return t?new o(t,this.children_.get(t)):null},n.prototype.getLastChildName=function(n){var i=this.resolveIndex_(n),t;return i?(t=i.maxKey(),t&&t.name):this.children_.maxKey()},n.prototype.getLastChild=function(n){var t=this.getLastChildName(n);return t?new o(t,this.children_.get(t)):null},n.prototype.forEachChild=function(n,t){var i=this.resolveIndex_(n);return i?i.inorderTraversal(function(n){return t(n.name,n.node)}):this.children_.inorderTraversal(t)},n.prototype.getIterator=function(n){return this.getIteratorFrom(n.minPost(),n)},n.prototype.getIteratorFrom=function(n,t){var u=this.resolveIndex_(t),i,r;if(u)return u.getIteratorFrom(n,function(n){return n});for(i=this.children_.getIteratorFrom(n.name,o.Wrap),r=i.peek();null!=r&&t.compare(r,n)<0;)i.getNext(),r=i.peek();return i},n.prototype.getReverseIterator=function(n){return this.getReverseIteratorFrom(n.maxPost(),n)},n.prototype.getReverseIteratorFrom=function(n,t){var u=this.resolveIndex_(t),i,r;if(u)return u.getReverseIteratorFrom(n,function(n){return n});for(i=this.children_.getReverseIteratorFrom(n.name,o.Wrap),r=i.peek();null!=r&&t.compare(r,n)>0;)i.getNext(),r=i.peek();return i},n.prototype.compareTo=function(n){return this.isEmpty()?n.isEmpty()?0:-1:n.isLeafNode()||n.isEmpty()?1:n===ei?-1:0},n.prototype.withIndex=function(t){if(t===vt||this.indexMap_.hasIndex(t))return this;var i=this.indexMap_.addIndex(t,this.children_);return new n(this.children_,this.priorityNode_,i)},n.prototype.isIndexed=function(n){return n===vt||this.indexMap_.hasIndex(n)},n.prototype.equals=function(n){var r;if(n===this)return!0;if(n.isLeafNode())return!1;if(r=n,this.getPriority().equals(r.getPriority())){if(this.children_.count()===r.children_.count()){for(var u=this.getIterator(h),f=r.getIterator(h),t=u.getNext(),i=f.getNext();t&&i;){if(t.name!==i.name||!t.node.equals(i.node))return!1;t=u.getNext();i=f.getNext()}return null===t&&null===i}return!1}return!1},n.prototype.resolveIndex_=function(n){return n===vt?null:this.indexMap_.get(n.toString())},n.INTEGER_REGEXP_=/^(0|[1-9]\d*)$/,n}();ei=new(function(n){function t(){return n.call(this,new yt(ru),f.EMPTY_NODE,lr.Default)||this}return it(t,n),t.prototype.compareTo=function(n){return n===this?0:1},t.prototype.equals=function(n){return n===this},t.prototype.getPriority=function(){return this},t.prototype.getImmediateChild=function(){return f.EMPTY_NODE},t.prototype.isEmpty=function(){return!1},t}(f));Object.defineProperties(o,{MIN:{value:new o(kt,f.EMPTY_NODE)},MAX:{value:new o(lt,ei)}});fe.__EMPTY_NODE=f.EMPTY_NODE;fi.__childrenNodeConstructor=f;gr=ei,function(n){se=n}(ei);ae=!0;function c(n,t){var r,e,a,y;if(void 0===t&&(t=null),null===n)return f.EMPTY_NODE;if("object"==typeof n&&".priority"in n&&(t=n[".priority"]),i(null===t||"string"==typeof t||"number"==typeof t||"object"==typeof t&&".sv"in t,"Invalid priority type found: "+typeof t),"object"==typeof n&&".value"in n&&null!==n[".value"]&&(n=n[".value"]),"object"!=typeof n||".sv"in n)return new fi(n,c(t));if(n instanceof Array||!ae)return r=f.EMPTY_NODE,e=n,s(e,function(n,t){if(d(e,n)&&"."!==n.substring(0,1)){var i=c(t);!i.isLeafNode()&&i.isEmpty()||(r=r.updateImmediateChild(n,i))}}),r.updatePriority(c(t));var u=[],l=!1,v=n;return(s(v,function(n){if("string"!=typeof n||"."!==n.substring(0,1)){var t=c(v[n]);t.isEmpty()||(l=l||!t.getPriority().isEmpty(),u.push(new o(n,t)))}}),0==u.length)?f.EMPTY_NODE:(a=cr(u,ps,function(n){return n.name},ru),l)?(y=cr(u,h.getCompare()),new f(a,c(t),new lr({".priority":y},{".priority":h}))):new f(a,c(t),lr.Default)}!function(n){oe=n}(c);var uu,et,fu=new(function(n){function t(){return null!==n&&n.apply(this,arguments)||this}return it(t,n),t.prototype.compare=function(n,t){var i=n.node.compareTo(t.node);return 0===i?dt(n.name,t.name):i},t.prototype.isDefinedOn=function(){return!0},t.prototype.indexedValueChanged=function(n,t){return!n.equals(t)},t.prototype.minPost=function(){return o.MIN},t.prototype.maxPost=function(){return o.MAX},t.prototype.makePost=function(n,t){var i=c(n);return new o(t,i)},t.prototype.toString=function(){return".value"},t}(sr)),eu=function(n){function t(t){var r=n.call(this)||this;return r.indexPath_=t,i(!t.isEmpty()&&".priority"!==t.getFront(),"Can't create PathIndex with empty path or .priority key"),r}return it(t,n),t.prototype.extractChild=function(n){return n.getChild(this.indexPath_)},t.prototype.isDefinedOn=function(n){return!n.getChild(this.indexPath_).isEmpty()},t.prototype.compare=function(n,t){var r=this.extractChild(n.node),u=this.extractChild(t.node),i=r.compareTo(u);return 0===i?dt(n.name,t.name):i},t.prototype.makePost=function(n,t){var i=c(n),r=f.EMPTY_NODE.updateChild(this.indexPath_,i);return new o(t,r)},t.prototype.maxPost=function(){var n=f.EMPTY_NODE.updateChild(this.indexPath_,ei);return new o(lt,n)},t.prototype.toString=function(){return this.indexPath_.slice().join("/")},t}(sr),nr=function(){function n(n,t,i){this.node_=n;this.ref_=t;this.index_=i}return n.prototype.val=function(){return u("DataSnapshot.val",0,0,arguments.length),this.node_.val()},n.prototype.exportVal=function(){return u("DataSnapshot.exportVal",0,0,arguments.length),this.node_.val(!0)},n.prototype.toJSON=function(){return u("DataSnapshot.toJSON",0,1,arguments.length),this.exportVal()},n.prototype.exists=function(){return u("DataSnapshot.exists",0,0,arguments.length),!this.node_.isEmpty()},n.prototype.child=function(t){u("DataSnapshot.child",0,1,arguments.length);t=String(t);di("DataSnapshot.child",1,t,!1);var i=new r(t),f=this.ref_.child(i);return new n(this.node_.getChild(i),f,h)},n.prototype.hasChild=function(n){u("DataSnapshot.hasChild",1,1,arguments.length);di("DataSnapshot.hasChild",1,n,!1);var t=new r(n);return!this.node_.getChild(t).isEmpty()},n.prototype.getPriority=function(){return u("DataSnapshot.getPriority",0,0,arguments.length),this.node_.getPriority().val()},n.prototype.forEach=function(t){var i=this;return u("DataSnapshot.forEach",1,1,arguments.length),v("DataSnapshot.forEach",1,t,!1),!this.node_.isLeafNode()&&!!this.node_.forEachChild(this.index_,function(r,u){return t(new n(u,i.ref_.child(r),h))})},n.prototype.hasChildren=function(){return u("DataSnapshot.hasChildren",0,0,arguments.length),!this.node_.isLeafNode()&&!this.node_.isEmpty()},Object.defineProperty(n.prototype,"key",{get:function(){return this.ref_.getKey()},enumerable:!0,configurable:!0}),n.prototype.numChildren=function(){return u("DataSnapshot.numChildren",0,0,arguments.length),this.node_.numChildren()},n.prototype.getRef=function(){return u("DataSnapshot.ref",0,0,arguments.length),this.ref_},Object.defineProperty(n.prototype,"ref",{get:function(){return this.getRef()},enumerable:!0,configurable:!0}),n}(),ve=function(){function n(n,t,i,r){this.eventType=n;this.eventRegistration=t;this.snapshot=i;this.prevName=r}return n.prototype.getPath=function(){var n=this.snapshot.getRef();return"value"===this.eventType?n.path:n.getParent().path},n.prototype.getEventType=function(){return this.eventType},n.prototype.getEventRunner=function(){return this.eventRegistration.getEventRunner(this)},n.prototype.toString=function(){return this.getPath().toString()+":"+this.eventType+":"+a(this.snapshot.exportVal())},n}(),ye=function(){function n(n,t,i){this.eventRegistration=n;this.error=t;this.path=i}return n.prototype.getPath=function(){return this.path},n.prototype.getEventType=function(){return"cancel"},n.prototype.getEventRunner=function(){return this.eventRegistration.getEventRunner(this)},n.prototype.toString=function(){return this.path.toString()+":cancel"},n}(),pe=function(){function n(n,t,i){this.callback_=n;this.cancelCallback_=t;this.context_=i}return n.prototype.respondsTo=function(n){return"value"===n},n.prototype.createEvent=function(n,t){var i=t.getQueryParams().getIndex();return new ve("value",this,new nr(n.snapshotNode,t.getRef(),i))},n.prototype.getEventRunner=function(n){var t=this.context_,r,u;return"cancel"===n.getEventType()?(i(this.cancelCallback_,"Raising a cancel event on a listener with no cancel callback"),r=this.cancelCallback_,function(){r.call(t,n.error)}):(u=this.callback_,function(){u.call(t,n.snapshot)})},n.prototype.createCancelEvent=function(n,t){return this.cancelCallback_?new ye(this,n,t):null},n.prototype.matches=function(t){return t instanceof n&&(!t.callback_||!this.callback_||t.callback_===this.callback_&&t.context_===this.context_)},n.prototype.hasAnyCallback=function(){return null!==this.callback_},n}(),we=function(){function n(n,t,i){this.callbacks_=n;this.cancelCallback_=t;this.context_=i}return n.prototype.respondsTo=function(n){var t="children_added"===n?"child_added":n;return t="children_removed"===t?"child_removed":t,d(this.callbacks_,t)},n.prototype.createCancelEvent=function(n,t){return this.cancelCallback_?new ye(this,n,t):null},n.prototype.createEvent=function(n,t){i(null!=n.childName,"Child events should have a childName.");var r=t.getRef().child(n.childName),u=t.getQueryParams().getIndex();return new ve(n.type,this,new nr(n.snapshotNode,r,u),n.prevName)},n.prototype.getEventRunner=function(n){var t=this.context_,r,u;return"cancel"===n.getEventType()?(i(this.cancelCallback_,"Raising a cancel event on a listener with no cancel callback"),r=this.cancelCallback_,function(){r.call(t,n.error)}):(u=this.callbacks_[n.eventType],function(){u.call(t,n.snapshot,n.prevName)})},n.prototype.matches=function(t){var u,i,r;if(t instanceof n){if(!this.callbacks_||!t.callbacks_)return!0;if(this.context_===t.context_&&(u=rr(t.callbacks_),u===rr(this.callbacks_)))return 1===u?(i=hf(t.callbacks_),r=hf(this.callbacks_),!(r!==i||t.callbacks_[i]&&this.callbacks_[r]&&t.callbacks_[i]!==this.callbacks_[r])):function(n,t){for(var i in n)if(Object.prototype.hasOwnProperty.call(n,i)&&!t(i,n[i]))return!1;return!0}(this.callbacks_,function(n,i){return t.callbacks_[n]===i})}return!1},n.prototype.hasAnyCallback=function(){return null!==this.callbacks_},n}(),ou=function(){function n(n,t,i,r){this.repo=n;this.path=t;this.queryParams_=i;this.orderByCalled_=r}return Object.defineProperty(n,"__referenceConstructor",{get:function(){return i(uu,"Reference.ts has not been loaded"),uu},set:function(n){uu=n},enumerable:!0,configurable:!0}),n.validateQueryEndpoints_=function(n){var t=null,r=null,u,f;if(n.hasStart()&&(t=n.getIndexStartValue()),n.hasEnd()&&(r=n.getIndexEndValue()),n.getIndex()===vt){if(u="Query: When ordering by key, you may only pass one argument to startAt(), endAt(), or equalTo().",f="Query: When ordering by key, the argument passed to startAt(), endAt(),or equalTo() must be a string.",n.hasStart()){if(n.getIndexStartName()!=kt)throw new Error(u);if("string"!=typeof t)throw new Error(f);}if(n.hasEnd()){if(n.getIndexEndName()!=lt)throw new Error(u);if("string"!=typeof r)throw new Error(f);}}else if(n.getIndex()===h){if(null!=t&&!bi(t)||null!=r&&!bi(r))throw new Error("Query: When ordering by priority, the first argument passed to startAt(), endAt(), or equalTo() must be a valid priority value (null, a number, or a string).");}else if(i(n.getIndex()instanceof eu||n.getIndex()===fu,"unknown index type."),null!=t&&"object"==typeof t||null!=r&&"object"==typeof r)throw new Error("Query: First argument passed to startAt(), endAt(), or equalTo() cannot be an object.");},n.validateLimit_=function(n){if(n.hasStart()&&n.hasEnd()&&n.hasLimit()&&!n.hasAnchoredLimit())throw new Error("Query: Can't combine startAt(), endAt(), and limit(). Use limitToFirst() or limitToLast() instead.");},n.prototype.validateNoPreviousOrderByCall_=function(n){if(!0===this.orderByCalled_)throw new Error(n+": You can't combine multiple orderBy calls.");},n.prototype.getQueryParams=function(){return this.queryParams_},n.prototype.getRef=function(){return u("Query.ref",0,0,arguments.length),new n.__referenceConstructor(this.repo,this.path)},n.prototype.on=function(t,i,r,f){var e,o;if(u("Query.on",2,4,arguments.length),tu("Query.on",1,t,!1),v("Query.on",2,i,!1),e=n.getCancelAndContextArgs_("Query.on",r,f),"value"===t)this.onValueEvent(i,e.cancel,e.context);else o={},o[t]=i,this.onChildEvent(o,e.cancel,e.context);return i},n.prototype.onValueEvent=function(n,t,i){var r=new pe(n,t||null,i||null);this.repo.addEventCallbackForQuery(this,r)},n.prototype.onChildEvent=function(n,t,i){var r=new we(n,t,i);this.repo.addEventCallbackForQuery(this,r)},n.prototype.off=function(n,t,i){u("Query.off",0,3,arguments.length);tu("Query.off",1,n,!0);v("Query.off",2,t,!0);cf("Query.off",3,i,!0);var r=null,f=null;"value"===n?r=new pe(t||null,null,i||null):n&&(t&&((f={})[n]=t),r=new we(f,null,i||null));this.repo.removeEventCallbackForQuery(this,r)},n.prototype.once=function(t,i,r,f){var h=this,s;u("Query.once",1,4,arguments.length);tu("Query.once",1,t,!1);v("Query.once",2,i,!0);var e=n.getCancelAndContextArgs_("Query.once",r,f),c=!0,o=new rt;return o.promise.catch(function(){}),s=function(n){c&&(c=!1,h.off(t,s),i&&i.bind(e.context)(n),o.resolve(n))},this.on(t,s,function(n){h.off(t,s);e.cancel&&e.cancel.bind(e.context)(n);o.reject(n)}),o.promise},n.prototype.limitToFirst=function(t){if(u("Query.limitToFirst",1,1,arguments.length),"number"!=typeof t||Math.floor(t)!==t||t<=0)throw new Error("Query.limitToFirst: First argument must be a positive integer.");if(this.queryParams_.hasLimit())throw new Error("Query.limitToFirst: Limit was already set (by another call to limit, limitToFirst, or limitToLast).");return new n(this.repo,this.path,this.queryParams_.limitToFirst(t),this.orderByCalled_)},n.prototype.limitToLast=function(t){if(u("Query.limitToLast",1,1,arguments.length),"number"!=typeof t||Math.floor(t)!==t||t<=0)throw new Error("Query.limitToLast: First argument must be a positive integer.");if(this.queryParams_.hasLimit())throw new Error("Query.limitToLast: Limit was already set (by another call to limit, limitToFirst, or limitToLast).");return new n(this.repo,this.path,this.queryParams_.limitToLast(t),this.orderByCalled_)},n.prototype.orderByChild=function(t){var i,e,f;if(u("Query.orderByChild",1,1,arguments.length),"$key"===t)throw new Error('Query.orderByChild: "$key" is invalid.  Use Query.orderByKey() instead.');if("$priority"===t)throw new Error('Query.orderByChild: "$priority" is invalid.  Use Query.orderByPriority() instead.');if("$value"===t)throw new Error('Query.orderByChild: "$value" is invalid.  Use Query.orderByValue() instead.');if(di("Query.orderByChild",1,t,!1),this.validateNoPreviousOrderByCall_("Query.orderByChild"),i=new r(t),i.isEmpty())throw new Error("Query.orderByChild: cannot pass in empty path.  Use Query.orderByValue() instead.");return e=new eu(i),f=this.queryParams_.orderBy(e),n.validateQueryEndpoints_(f),new n(this.repo,this.path,f,!0)},n.prototype.orderByKey=function(){u("Query.orderByKey",0,0,arguments.length);this.validateNoPreviousOrderByCall_("Query.orderByKey");var t=this.queryParams_.orderBy(vt);return n.validateQueryEndpoints_(t),new n(this.repo,this.path,t,!0)},n.prototype.orderByPriority=function(){u("Query.orderByPriority",0,0,arguments.length);this.validateNoPreviousOrderByCall_("Query.orderByPriority");var t=this.queryParams_.orderBy(h);return n.validateQueryEndpoints_(t),new n(this.repo,this.path,t,!0)},n.prototype.orderByValue=function(){u("Query.orderByValue",0,0,arguments.length);this.validateNoPreviousOrderByCall_("Query.orderByValue");var t=this.queryParams_.orderBy(fu);return n.validateQueryEndpoints_(t),new n(this.repo,this.path,t,!0)},n.prototype.startAt=function(t,i){void 0===t&&(t=null);u("Query.startAt",0,2,arguments.length);at("Query.startAt",1,t,this.path,!0);iu("Query.startAt",2,i,!0);var r=this.queryParams_.startAt(t,i);if(n.validateLimit_(r),n.validateQueryEndpoints_(r),this.queryParams_.hasStart())throw new Error("Query.startAt: Starting point was already set (by another call to startAt or equalTo).");return void 0===t&&(t=null,i=null),new n(this.repo,this.path,r,this.orderByCalled_)},n.prototype.endAt=function(t,i){void 0===t&&(t=null);u("Query.endAt",0,2,arguments.length);at("Query.endAt",1,t,this.path,!0);iu("Query.endAt",2,i,!0);var r=this.queryParams_.endAt(t,i);if(n.validateLimit_(r),n.validateQueryEndpoints_(r),this.queryParams_.hasEnd())throw new Error("Query.endAt: Ending point was already set (by another call to endAt or equalTo).");return new n(this.repo,this.path,r,this.orderByCalled_)},n.prototype.equalTo=function(n,t){if(u("Query.equalTo",1,2,arguments.length),at("Query.equalTo",1,n,this.path,!1),iu("Query.equalTo",2,t,!0),this.queryParams_.hasStart())throw new Error("Query.equalTo: Starting point was already set (by another call to startAt or equalTo).");if(this.queryParams_.hasEnd())throw new Error("Query.equalTo: Ending point was already set (by another call to endAt or equalTo).");return this.startAt(n,t).endAt(n,t)},n.prototype.toString=function(){return u("Query.toString",0,0,arguments.length),this.repo.toString()+this.path.toUrlEncodedString()},n.prototype.toJSON=function(){return u("Query.toJSON",0,1,arguments.length),this.toString()},n.prototype.queryObject=function(){return this.queryParams_.getQueryObject()},n.prototype.queryIdentifier=function(){var t=this.queryObject(),n=dr(t);return"{}"===n?"default":n},n.prototype.isEqual=function(t){if(u("Query.isEqual",1,1,arguments.length),!(t instanceof n))throw new Error("Query.isEqual failed: First argument must be an instance of firebase.database.Query.");var i=this.repo===t.repo,r=this.path.equals(t.path),f=this.queryIdentifier()===t.queryIdentifier();return i&&r&&f},n.getCancelAndContextArgs_=function(n,t,i){var r={cancel:null,context:null};if(t&&i)r.cancel=t,v(n,3,r.cancel,!0),r.context=i,cf(n,4,r.context,!0);else if(t)if("object"==typeof t&&null!==t)r.context=t;else{if("function"!=typeof t)throw new Error(nt(n,3,!0)+" must either be a cancel callback or a context object.");r.cancel=t}return r},Object.defineProperty(n.prototype,"ref",{get:function(){return this.getRef()},enumerable:!0,configurable:!0}),n}(),be=function(){function n(){this.set={}}return n.prototype.add=function(n,t){this.set[n]=null===t||t},n.prototype.contains=function(n){return d(this.set,n)},n.prototype.get=function(n){if(this.contains(n))return this.set[n]},n.prototype.remove=function(n){delete this.set[n]},n.prototype.clear=function(){this.set={}},n.prototype.isEmpty=function(){return li(this.set)},n.prototype.count=function(){return rr(this.set)},n.prototype.each=function(n){s(this.set,function(t,i){return n(t,i)})},n.prototype.keys=function(){var n=[];return s(this.set,function(t){n.push(t)}),n},n}(),su=function(){function n(){this.value_=null;this.children_=null}return n.prototype.find=function(n){if(null!=this.value_)return this.value_.getChild(n);if(n.isEmpty()||null==this.children_)return null;var t=n.getFront();return n=n.popFront(),this.children_.contains(t)?this.children_.get(t).find(n):null},n.prototype.remember=function(t,i){var r,u;t.isEmpty()?(this.value_=i,this.children_=null):null!==this.value_?this.value_=this.value_.updateChild(t,i):(null==this.children_&&(this.children_=new be),r=t.getFront(),this.children_.contains(r)||this.children_.add(r,new n),u=this.children_.get(r),t=t.popFront(),u.remember(t,i))},n.prototype.forget=function(n){var i,u,t;return n.isEmpty()?(this.value_=null,this.children_=null,!0):null!==this.value_?this.value_.isLeafNode()?!1:(i=this.value_,this.value_=null,u=this,i.forEachChild(h,function(n,t){u.remember(new r(n),t)}),this.forget(n)):null!==this.children_?(t=n.getFront(),(n=n.popFront(),this.children_.contains(t))&&this.children_.get(t).forget(n)&&this.children_.remove(t),!!this.children_.isEmpty()&&(this.children_=null,!0)):!0},n.prototype.forEachTree=function(n,t){null!==this.value_?t(n,this.value_):this.forEachChild(function(i,u){var f=new r(n.toString()+"/"+i);u.forEachTree(f,t)})},n.prototype.forEachChild=function(n){null!==this.children_&&this.children_.each(function(t,i){n(t,i)})},n}(),ke=function(n,t){return n&&"object"==typeof n?(i(".sv"in n,"Unexpected leaf node or priority contents"),t[n[".sv"]]):n},oi=function(n,t){var i,o=n.getPriority().val(),r=ke(o,t),u,e,f;return n.isLeafNode()?(u=n,e=ke(u.getValue(),t),e!==u.getValue()||r!==u.getPriority().val()?new fi(e,c(r)):n):(f=n,i=f,r!==f.getPriority().val()&&(i=i.updatePriority(new fi(r))),f.forEachChild(h,function(n,r){var u=oi(r,t);u!==r&&(i=i.updateImmediateChild(n,u))}),i)};!function(n){n[n.OVERWRITE=0]="OVERWRITE";n[n.MERGE=1]="MERGE";n[n.ACK_USER_WRITE=2]="ACK_USER_WRITE";n[n.LISTEN_COMPLETE=3]="LISTEN_COMPLETE"}(et||(et={}));var hu,ar,st=function(){function n(n,t,r,u){this.fromUser=n;this.fromServer=t;this.queryId=r;this.tagged=u;i(!u||t,"Tagged queries must be from server.")}return n.User=new n(!0,!1,null,!1),n.Server=new n(!1,!0,null,!1),n.forServerTaggedQuery=function(t){return new n(!1,!0,t,!0)},n}(),ws=function(){function n(n,t,i){this.path=n;this.affectedTree=t;this.revert=i;this.type=et.ACK_USER_WRITE;this.source=st.User}return n.prototype.operationForChild=function(t){if(this.path.isEmpty()){if(null!=this.affectedTree.value)return i(this.affectedTree.children.isEmpty(),"affectedTree should not have overlapping affected paths."),this;var u=this.affectedTree.subtree(new r(t));return new n(r.Empty,u,this.revert)}return i(this.path.getFront()===t,"operationForChild called for unrelated child."),new n(this.path.popFront(),this.affectedTree,this.revert)},n}(),bs=function(){return hu||(hu=new yt(is)),hu},g=function(){function n(n,t){void 0===t&&(t=bs());this.value=n;this.children=t}return n.fromObject=function(t){var i=n.Empty;return s(t,function(n,t){i=i.set(new r(n),t)}),i},n.prototype.isEmpty=function(){return null===this.value&&this.children.isEmpty()},n.prototype.findRootMostMatchingPathAndValue=function(n,t){var u,f,i;return null!=this.value&&t(this.value)?{path:r.Empty,value:this.value}:n.isEmpty()?null:(u=n.getFront(),f=this.children.get(u),null!==f)?(i=f.findRootMostMatchingPathAndValue(n.popFront(),t),null!=i?{path:new r(u).child(i.path),value:i.value}:null):null},n.prototype.findRootMostValueAndPath=function(n){return this.findRootMostMatchingPathAndValue(n,function(){return!0})},n.prototype.subtree=function(t){if(t.isEmpty())return this;var r=t.getFront(),i=this.children.get(r);return null!==i?i.subtree(t.popFront()):n.Empty},n.prototype.set=function(t,i){if(t.isEmpty())return new n(i,this.children);var r=t.getFront(),u=(this.children.get(r)||n.Empty).set(t.popFront(),i),f=this.children.insert(r,u);return new n(this.value,f)},n.prototype.remove=function(t){var i,u,f,r;return t.isEmpty()?this.children.isEmpty()?n.Empty:new n(null,this.children):(i=t.getFront(),u=this.children.get(i),u)?(f=u.remove(t.popFront()),r=void 0,r=f.isEmpty()?this.children.remove(i):this.children.insert(i,f),null===this.value&&r.isEmpty()?n.Empty:new n(this.value,r)):this},n.prototype.get=function(n){if(n.isEmpty())return this.value;var i=n.getFront(),t=this.children.get(i);return t?t.get(n.popFront()):null},n.prototype.setTree=function(t,i){if(t.isEmpty())return i;var r=t.getFront(),u=(this.children.get(r)||n.Empty).setTree(t.popFront(),i),f=void 0;return f=u.isEmpty()?this.children.remove(r):this.children.insert(r,u),new n(this.value,f)},n.prototype.fold=function(n){return this.fold_(r.Empty,n)},n.prototype.fold_=function(n,t){var i={};return this.children.inorderTraversal(function(r,u){i[r]=u.fold_(n.child(r),t)}),t(n,this.value,i)},n.prototype.findOnPath=function(n,t){return this.findOnPath_(n,r.Empty,t)},n.prototype.findOnPath_=function(n,t,i){var f=!!this.value&&i(t,this.value),r,u;return f?f:n.isEmpty()?null:(r=n.getFront(),u=this.children.get(r),u?u.findOnPath_(n.popFront(),t.child(r),i):null)},n.prototype.foreachOnPath=function(n,t){return this.foreachOnPath_(n,r.Empty,t)},n.prototype.foreachOnPath_=function(t,i,r){if(t.isEmpty())return this;this.value&&r(i,this.value);var u=t.getFront(),f=this.children.get(u);return f?f.foreachOnPath_(t.popFront(),i.child(u),r):n.Empty},n.prototype.foreach=function(n){this.foreach_(r.Empty,n)},n.prototype.foreach_=function(n,t){this.children.inorderTraversal(function(i,r){r.foreach_(n.child(i),t)});this.value&&t(n,this.value)},n.prototype.foreachChild=function(n){this.children.inorderTraversal(function(t,i){i.value&&n(t,i.value)})},n.Empty=new n(null),n}(),de=function(){function n(n,t){this.source=n;this.path=t;this.type=et.LISTEN_COMPLETE}return n.prototype.operationForChild=function(){return this.path.isEmpty()?new n(this.source,r.Empty):new n(this.source,this.path.popFront())},n}(),vr=function(){function n(n,t,i){this.source=n;this.path=t;this.snap=i;this.type=et.OVERWRITE}return n.prototype.operationForChild=function(t){return this.path.isEmpty()?new n(this.source,r.Empty,this.snap.getImmediateChild(t)):new n(this.source,this.path.popFront(),this.snap)},n}(),cu=function(){function n(n,t,i){this.source=n;this.path=t;this.children=i;this.type=et.MERGE}return n.prototype.operationForChild=function(t){if(this.path.isEmpty()){var u=this.children.subtree(new r(t));return u.isEmpty()?null:u.value?new vr(this.source,r.Empty,u.value):new n(this.source,r.Empty,u)}return i(this.path.getFront()===t,"Can't get a merge for a child not on the path of the operation"),new n(this.source,this.path.popFront(),this.children)},n.prototype.toString=function(){return"Operation("+this.path+": "+this.source.toString()+" merge: "+this.children.toString()+")"},n}(),ht=function(){function n(n,t,i){this.node_=n;this.fullyInitialized_=t;this.filtered_=i}return n.prototype.isFullyInitialized=function(){return this.fullyInitialized_},n.prototype.isFiltered=function(){return this.filtered_},n.prototype.isCompleteForPath=function(n){if(n.isEmpty())return this.isFullyInitialized()&&!this.filtered_;var t=n.getFront();return this.isCompleteForChild(t)},n.prototype.isCompleteForChild=function(n){return this.isFullyInitialized()&&!this.filtered_||this.node_.hasChild(n)},n.prototype.getNode=function(){return this.node_},n}(),ge=function(){function n(n,t){this.eventCache_=n;this.serverCache_=t}return n.prototype.updateEventSnap=function(t,i,r){return new n(new ht(t,i,r),this.serverCache_)},n.prototype.updateServerSnap=function(t,i,r){return new n(this.eventCache_,new ht(t,i,r))},n.prototype.getEventCache=function(){return this.eventCache_},n.prototype.getCompleteEventSnap=function(){return this.eventCache_.isFullyInitialized()?this.eventCache_.getNode():null},n.prototype.getServerCache=function(){return this.serverCache_},n.prototype.getCompleteServerSnap=function(){return this.serverCache_.isFullyInitialized()?this.serverCache_.getNode():null},n.Empty=new n(new ht(f.EMPTY_NODE,!1,!1),new ht(f.EMPTY_NODE,!1,!1)),n}(),e=function(){function n(n,t,i,r,u){this.type=n;this.snapshotNode=t;this.childName=i;this.oldSnap=r;this.prevName=u}return n.valueChange=function(t){return new n(n.VALUE,t)},n.childAddedChange=function(t,i){return new n(n.CHILD_ADDED,i,t)},n.childRemovedChange=function(t,i){return new n(n.CHILD_REMOVED,i,t)},n.childChangedChange=function(t,i,r){return new n(n.CHILD_CHANGED,i,t,r)},n.childMovedChange=function(t,i){return new n(n.CHILD_MOVED,i,t)},n.CHILD_ADDED="child_added",n.CHILD_REMOVED="child_removed",n.CHILD_CHANGED="child_changed",n.CHILD_MOVED="child_moved",n.VALUE="value",n}(),lu=function(){function n(n){this.index_=n}return n.prototype.updateChild=function(n,t,r,u,f,o){i(n.isIndexed(this.index_),"A node must be indexed if only a child is updated");var s=n.getImmediateChild(t);return s.getChild(u).equals(r.getChild(u))&&s.isEmpty()==r.isEmpty()?n:(null!=o&&(r.isEmpty()?n.hasChild(t)?o.trackChildChange(e.childRemovedChange(t,s)):i(n.isLeafNode(),"A child remove without an old child only makes sense on a leaf node"):s.isEmpty()?o.trackChildChange(e.childAddedChange(t,r)):o.trackChildChange(e.childChangedChange(t,r,s))),n.isLeafNode()&&r.isEmpty()?n:n.updateImmediateChild(t,r).withIndex(this.index_))},n.prototype.updateFullNode=function(n,t,i){return null!=i&&(n.isLeafNode()||n.forEachChild(h,function(n,r){t.hasChild(n)||i.trackChildChange(e.childRemovedChange(n,r))}),t.isLeafNode()||t.forEachChild(h,function(t,r){if(n.hasChild(t)){var u=n.getImmediateChild(t);u.equals(r)||i.trackChildChange(e.childChangedChange(t,r,u))}else i.trackChildChange(e.childAddedChange(t,r))})),t.withIndex(this.index_)},n.prototype.updatePriority=function(n,t){return n.isEmpty()?f.EMPTY_NODE:n.updatePriority(t)},n.prototype.filtersNodes=function(){return!1},n.prototype.getIndexedFilter=function(){return this},n.prototype.getIndex=function(){return this.index_},n}(),ks=function(){function n(){this.changeMap_={}}return n.prototype.trackChildChange=function(n){var r=n.type,t=n.childName,u,f;if(i(r==e.CHILD_ADDED||r==e.CHILD_CHANGED||r==e.CHILD_REMOVED,"Only child changes supported for tracking"),i(".priority"!==t,"Only non-priority child changes can be tracked."),u=p(this.changeMap_,t),u)if(f=u.type,r==e.CHILD_ADDED&&f==e.CHILD_REMOVED)this.changeMap_[t]=e.childChangedChange(t,n.snapshotNode,u.snapshotNode);else if(r==e.CHILD_REMOVED&&f==e.CHILD_ADDED)delete this.changeMap_[t];else if(r==e.CHILD_REMOVED&&f==e.CHILD_CHANGED)this.changeMap_[t]=e.childRemovedChange(t,u.oldSnap);else if(r==e.CHILD_CHANGED&&f==e.CHILD_ADDED)this.changeMap_[t]=e.childAddedChange(t,n.snapshotNode);else{if(r!=e.CHILD_CHANGED||f!=e.CHILD_CHANGED)throw ii("Illegal combination of changes: "+n+" occurred after "+u);this.changeMap_[t]=e.childChangedChange(t,n.snapshotNode,u.oldSnap)}else this.changeMap_[t]=n},n.prototype.getChanges=function(){return function(n){var t=[],r=0,i;for(i in n)t[r++]=n[i];return t}(this.changeMap_)},n}(),no=new(function(){function n(){}return n.prototype.getCompleteChild=function(){return null},n.prototype.getChildAfterChild=function(){return null},n}()),au=function(){function n(n,t,i){void 0===i&&(i=null);this.writes_=n;this.viewCache_=t;this.optCompleteServerCache_=i}return n.prototype.getCompleteChild=function(n){var t=this.viewCache_.getEventCache(),i;return t.isCompleteForChild(n)?t.getNode().getImmediateChild(n):(i=null!=this.optCompleteServerCache_?new ht(this.optCompleteServerCache_,!0,!1):this.viewCache_.getServerCache(),this.writes_.calcCompleteChild(n,i))},n.prototype.getChildAfterChild=function(n,t,i){var u=null!=this.optCompleteServerCache_?this.optCompleteServerCache_:this.viewCache_.getCompleteServerSnap(),r=this.writes_.calcIndexedSlice(u,t,1,i,n);return 0===r.length?null:r[0]},n}(),ds=function(){return function(n,t){this.viewCache=n;this.changes=t}}(),gs=function(){function n(n){this.filter_=n}return n.prototype.assertIndexed=function(n){i(n.getEventCache().getNode().isIndexed(this.filter_.getIndex()),"Event snap not indexed");i(n.getServerCache().getNode().isIndexed(this.filter_.getIndex()),"Server snap not indexed")},n.prototype.applyOperation=function(t,r,u,f){var o,l,s=new ks,e,h,c,a;if(r.type===et.OVERWRITE)e=r,e.source.fromUser?o=this.applyUserOverwrite_(t,e.path,e.snap,u,f,s):(i(e.source.fromServer,"Unknown source."),l=e.source.tagged||t.getServerCache().isFiltered()&&!e.path.isEmpty(),o=this.applyServerOverwrite_(t,e.path,e.snap,u,f,l,s));else if(r.type===et.MERGE)h=r,h.source.fromUser?o=this.applyUserMerge_(t,h.path,h.children,u,f,s):(i(h.source.fromServer,"Unknown source."),l=h.source.tagged||t.getServerCache().isFiltered(),o=this.applyServerMerge_(t,h.path,h.children,u,f,l,s));else if(r.type===et.ACK_USER_WRITE)c=r,o=c.revert?this.revertUserWrite_(t,c.path,u,f,s):this.ackUserWrite_(t,c.path,c.affectedTree,u,f,s);else{if(r.type!==et.LISTEN_COMPLETE)throw ii("Unknown operation type: "+r.type);o=this.listenComplete_(t,r.path,u,s)}return a=s.getChanges(),n.maybeAddValueEvent_(t,o,a),new ds(o,a)},n.maybeAddValueEvent_=function(n,t,i){var r=t.getEventCache(),f,u;r.isFullyInitialized()&&(f=r.getNode().isLeafNode()||r.getNode().isEmpty(),u=n.getCompleteEventSnap(),(i.length>0||!n.getEventCache().isFullyInitialized()||f&&!r.getNode().equals(u)||!r.getNode().getPriority().equals(u.getPriority()))&&i.push(e.valueChange(t.getCompleteEventSnap())))},n.prototype.generateEventCacheAfterServerEvent_=function(n,t,r,u,e){var o=n.getEventCache(),h,c,b,s,a,v,y,l,p;if(null!=r.shadowingWrite(t))return n;if(h=void 0,c=void 0,t.isEmpty())if(i(n.getServerCache().isFullyInitialized(),"If change path is empty, we must have complete server data"),n.getServerCache().isFiltered()){var w=n.getCompleteServerSnap(),k=w instanceof f?w:f.EMPTY_NODE,d=r.calcCompleteEventChildren(k);h=this.filter_.updateFullNode(n.getEventCache().getNode(),d,e)}else b=r.calcCompleteEventCache(n.getCompleteServerSnap()),h=this.filter_.updateFullNode(n.getEventCache().getNode(),b,e);else s=t.getFront(),".priority"==s?(i(1==t.getLength(),"Can't have a priority with additional path components"),a=o.getNode(),c=n.getServerCache().getNode(),v=r.calcEventCacheAfterServerOverwrite(t,a,c),h=null!=v?this.filter_.updatePriority(a,v):o.getNode()):(y=t.popFront(),l=void 0,o.isCompleteForChild(s)?(c=n.getServerCache().getNode(),p=r.calcEventCacheAfterServerOverwrite(t,o.getNode(),c),l=null!=p?o.getNode().getImmediateChild(s).updateChild(y,p):o.getNode().getImmediateChild(s)):l=r.calcCompleteChild(s,n.getServerCache()),h=null!=l?this.filter_.updateChild(o.getNode(),s,l,y,u,e):o.getNode());return n.updateEventSnap(h,o.isFullyInitialized()||t.isEmpty(),this.filter_.filtersNodes())},n.prototype.applyServerOverwrite_=function(n,t,i,r,u,f,e){var h,o=n.getServerCache(),s=f?this.filter_:this.filter_.getIndexedFilter(),y,c,l,a,v,p;if(t.isEmpty())h=s.updateFullNode(o.getNode(),i,null);else if(s.filtersNodes()&&!o.isFiltered())y=o.getNode().updateChild(t,i),h=s.updateFullNode(o.getNode(),y,null);else{if(c=t.getFront(),!o.isCompleteForPath(t)&&t.getLength()>1)return n;l=t.popFront();a=o.getNode().getImmediateChild(c).updateChild(l,i);h=".priority"==c?s.updatePriority(o.getNode(),a):s.updateChild(o.getNode(),c,a,l,no,null)}return v=n.updateServerSnap(h,o.isFullyInitialized()||t.isEmpty(),s.filtersNodes()),p=new au(r,v,u),this.generateEventCacheAfterServerEvent_(v,t,r,p,e)},n.prototype.applyUserOverwrite_=function(n,t,i,r,u,e){var o,a,s=n.getEventCache(),y=new au(r,n,u),h,l,p;if(t.isEmpty())a=this.filter_.updateFullNode(n.getEventCache().getNode(),i,e),o=n.updateEventSnap(a,!0,this.filter_.filtersNodes());else if(h=t.getFront(),".priority"===h)a=this.filter_.updatePriority(n.getEventCache().getNode(),i),o=n.updateEventSnap(a,s.isFullyInitialized(),s.isFiltered());else{var c=t.popFront(),w=s.getNode().getImmediateChild(h),v=void 0;c.isEmpty()?v=i:(l=y.getCompleteChild(h),v=null!=l?".priority"===c.getBack()&&l.getChild(c.parent()).isEmpty()?l:l.updateChild(c,i):f.EMPTY_NODE);w.equals(v)?o=n:(p=this.filter_.updateChild(s.getNode(),h,v,c,y,e),o=n.updateEventSnap(p,s.isFullyInitialized(),this.filter_.filtersNodes()))}return o},n.cacheHasChild_=function(n,t){return n.getEventCache().isCompleteForChild(t)},n.prototype.applyUserMerge_=function(t,i,r,u,f,e){var s=this,o=t;return r.foreach(function(r,h){var c=i.child(r);n.cacheHasChild_(t,c.getFront())&&(o=s.applyUserOverwrite_(o,c,h,u,f,e))}),r.foreach(function(r,h){var c=i.child(r);n.cacheHasChild_(t,c.getFront())||(o=s.applyUserOverwrite_(o,c,h,u,f,e))}),o},n.prototype.applyMerge_=function(n,t){return t.foreach(function(t,i){n=n.updateChild(t,i)}),n},n.prototype.applyServerMerge_=function(n,t,i,u,f,e,o){var h=this,c,s,l;return n.getServerCache().getNode().isEmpty()&&!n.getServerCache().isFullyInitialized()?n:(s=n,c=t.isEmpty()?i:g.Empty.setTree(t,i),l=n.getServerCache().getNode(),c.children.inorderTraversal(function(t,i){if(l.hasChild(t)){var c=n.getServerCache().getNode().getImmediateChild(t),a=h.applyMerge_(c,i);s=h.applyServerOverwrite_(s,new r(t),a,u,f,e,o)}}),c.children.inorderTraversal(function(t,i){var v=!n.getServerCache().isCompleteForChild(t)&&null==i.value,c,a;l.hasChild(t)||v||(c=n.getServerCache().getNode().getImmediateChild(t),a=h.applyMerge_(c,i),s=h.applyServerOverwrite_(s,new r(t),a,u,f,e,o))}),s)},n.prototype.ackUserWrite_=function(n,t,i,u,f,e){var s,o,h,c;return null!=u.shadowingWrite(t)?n:(s=n.getServerCache().isFiltered(),o=n.getServerCache(),null!=i.value)?t.isEmpty()&&o.isFullyInitialized()||o.isCompleteForPath(t)?this.applyServerOverwrite_(n,t,o.getNode().getChild(t),u,f,s,e):t.isEmpty()?(h=g.Empty,o.getNode().forEachChild(vt,function(n,t){h=h.set(new r(n),t)}),this.applyServerMerge_(n,t,h,u,f,s,e)):n:(c=g.Empty,i.foreach(function(n){var i=t.child(n);o.isCompleteForPath(i)&&(c=c.set(n,o.getNode().getChild(i)))}),this.applyServerMerge_(n,t,c,u,f,s,e))},n.prototype.listenComplete_=function(n,t,i,r){var u=n.getServerCache(),f=n.updateServerSnap(u.getNode(),u.isFullyInitialized()||t.isEmpty(),u.isFiltered());return this.generateEventCacheAfterServerEvent_(f,t,i,no,r)},n.prototype.revertUserWrite_=function(n,t,u,e,o){var v,h,y,s,a;if(null!=u.shadowingWrite(t))return n;var p=new au(u,n,e),c=n.getEventCache().getNode(),l=void 0;return t.isEmpty()||".priority"===t.getFront()?(h=void 0,n.getServerCache().isFullyInitialized()?h=u.calcCompleteEventCache(n.getCompleteServerSnap()):(y=n.getServerCache().getNode(),i(y instanceof f,"serverChildren would be complete if leaf node"),h=u.calcCompleteEventChildren(y)),h=h,l=this.filter_.updateFullNode(c,h,o)):(s=t.getFront(),a=u.calcCompleteChild(s,n.getServerCache()),null==a&&n.getServerCache().isCompleteForChild(s)&&(a=c.getImmediateChild(s)),(l=null!=a?this.filter_.updateChild(c,s,a,t.popFront(),p,o):n.getEventCache().getNode().hasChild(s)?this.filter_.updateChild(c,s,f.EMPTY_NODE,t.popFront(),p,o):c).isEmpty()&&n.getServerCache().isFullyInitialized()&&(v=u.calcCompleteEventCache(n.getCompleteServerSnap())).isLeafNode()&&(l=this.filter_.updateFullNode(l,v,o))),v=n.getServerCache().isFullyInitialized()||null!=u.shadowingWrite(r.Empty),n.updateEventSnap(l,v,this.filter_.filtersNodes())},n}(),nh=function(){function n(n){this.query_=n;this.index_=this.query_.getQueryParams().getIndex()}return n.prototype.generateEventsForChanges=function(n,t,i){var f=this,r=[],u=[];return n.forEach(function(n){n.type===e.CHILD_CHANGED&&f.index_.indexedValueChanged(n.oldSnap,n.snapshotNode)&&u.push(e.childMovedChange(n.childName,n.snapshotNode))}),this.generateEventsForType_(r,e.CHILD_REMOVED,n,i,t),this.generateEventsForType_(r,e.CHILD_ADDED,n,i,t),this.generateEventsForType_(r,e.CHILD_MOVED,u,i,t),this.generateEventsForType_(r,e.CHILD_CHANGED,n,i,t),this.generateEventsForType_(r,e.VALUE,n,i,t),r},n.prototype.generateEventsForType_=function(n,t,i,r,u){var f=this,e=i.filter(function(n){return n.type===t});e.sort(this.compareChanges_.bind(this));e.forEach(function(t){var i=f.materializeSingleChange_(t,u);r.forEach(function(r){r.respondsTo(t.type)&&n.push(r.createEvent(i,f.query_))})})},n.prototype.materializeSingleChange_=function(n,t){return"value"===n.type||"child_removed"===n.type?n:(n.prevName=t.getPredecessorChildName(n.childName,n.snapshotNode,this.index_),n)},n.prototype.compareChanges_=function(n,t){if(null==n.childName||null==t.childName)throw ii("Should only compare child_ events.");var i=new o(n.childName,n.snapshotNode),r=new o(t.childName,t.snapshotNode);return this.index_.compare(i,r)},n}(),th=function(){function n(n,t){this.query_=n;this.eventRegistrations_=[];var r=this.query_.getQueryParams(),u=new lu(r.getIndex()),i=r.getNodeFilter();this.processor_=new gs(i);var e=t.getServerCache(),o=t.getEventCache(),s=u.updateFullNode(f.EMPTY_NODE,e.getNode(),null),h=i.updateFullNode(f.EMPTY_NODE,o.getNode(),null),c=new ht(s,e.isFullyInitialized(),u.filtersNodes()),l=new ht(h,o.isFullyInitialized(),i.filtersNodes());this.viewCache_=new ge(l,c);this.eventGenerator_=new nh(this.query_)}return n.prototype.getQuery=function(){return this.query_},n.prototype.getServerCache=function(){return this.viewCache_.getServerCache().getNode()},n.prototype.getCompleteServerCache=function(n){var t=this.viewCache_.getCompleteServerSnap();return t&&(this.query_.getQueryParams().loadsAllData()||!n.isEmpty()&&!t.getImmediateChild(n.getFront()).isEmpty())?t.getChild(n):null},n.prototype.isEmpty=function(){return 0===this.eventRegistrations_.length},n.prototype.addEventRegistration=function(n){this.eventRegistrations_.push(n)},n.prototype.removeEventRegistration=function(n,t){var e=[],o,r,u,f;if(t&&(i(null==n,"A cancel should cancel all event registrations."),o=this.query_.path,this.eventRegistrations_.forEach(function(n){t=t;var i=n.createCancelEvent(t,o);i&&e.push(i)})),n){for(r=[],u=0;u<this.eventRegistrations_.length;++u)if(f=this.eventRegistrations_[u],f.matches(n)){if(n.hasAnyCallback()){r=r.concat(this.eventRegistrations_.slice(u+1));break}}else r.push(f);this.eventRegistrations_=r}else this.eventRegistrations_=[];return e},n.prototype.applyOperation=function(n,t,r){n.type===et.MERGE&&null!==n.source.queryId&&(i(this.viewCache_.getCompleteServerSnap(),"We should always have a full cache before handling merges"),i(this.viewCache_.getCompleteEventSnap(),"Missing event cache, even though we have a server cache"));var f=this.viewCache_,u=this.processor_.applyOperation(f,n,t,r);return this.processor_.assertIndexed(u.viewCache),i(u.viewCache.getServerCache().isFullyInitialized()||!f.getServerCache().isFullyInitialized(),"Once a server snap is complete, it should never go back"),this.viewCache_=u.viewCache,this.generateEventsForChanges_(u.changes,u.viewCache.getEventCache().getNode(),null)},n.prototype.getInitialEvents=function(n){var t=this.viewCache_.getEventCache(),i=[];return t.getNode().isLeafNode()||t.getNode().forEachChild(h,function(n,t){i.push(e.childAddedChange(n,t))}),t.isFullyInitialized()&&i.push(e.valueChange(t.getNode())),this.generateEventsForChanges_(i,t.getNode(),n)},n.prototype.generateEventsForChanges_=function(n,t,i){var r=i?[i]:this.eventRegistrations_;return this.eventGenerator_.generateEventsForChanges(n,t,r)},n}(),to=function(){function n(){this.views_={}}return Object.defineProperty(n,"__referenceConstructor",{get:function(){return i(ar,"Reference.ts has not been loaded"),ar},set:function(n){i(!ar,"__referenceConstructor has already been defined");ar=n},enumerable:!0,configurable:!0}),n.prototype.isEmpty=function(){return li(this.views_)},n.prototype.applyOperation=function(n,t,r){var e=n.source.queryId,f,u;return null!==e?(f=p(this.views_,e),i(null!=f,"SyncTree gave us an op for an invalid query."),f.applyOperation(n,t,r)):(u=[],s(this.views_,function(i,f){u=u.concat(f.applyOperation(n,t,r))}),u)},n.prototype.addEventRegistration=function(n,t,i,r,u){var h=n.queryIdentifier(),e=p(this.views_,h),o,s,c;return e||(o=i.calcCompleteEventCache(u?r:null),s=!1,o?s=!0:r instanceof f?(o=i.calcCompleteEventChildren(r),s=!1):(o=f.EMPTY_NODE,s=!1),c=new ge(new ht(o,s,!1),new ht(r,u,!1)),e=new th(n,c),this.views_[h]=e),e.addEventRegistration(t),e.getInitialEvents(t)},n.prototype.removeEventRegistration=function(t,i,r){var o=t.queryIdentifier(),e=[],f=[],c=this.hasCompleteView(),h,u;return"default"===o?(h=this,s(this.views_,function(n,t){f=f.concat(t.removeEventRegistration(i,r));t.isEmpty()&&(delete h.views_[n],t.getQuery().getQueryParams().loadsAllData()||e.push(t.getQuery()))})):(u=p(this.views_,o),u&&(f=f.concat(u.removeEventRegistration(i,r)),u.isEmpty()&&(delete this.views_[o],u.getQuery().getQueryParams().loadsAllData()||e.push(u.getQuery())))),c&&!this.hasCompleteView()&&e.push(new n.__referenceConstructor(t.repo,t.path)),{removed:e,events:f}},n.prototype.getQueryViews=function(){var n=this;return Object.keys(this.views_).map(function(t){return n.views_[t]}).filter(function(n){return!n.getQuery().getQueryParams().loadsAllData()})},n.prototype.getCompleteServerCache=function(n){var t=null;return s(this.views_,function(i,r){t=t||r.getCompleteServerCache(n)}),t},n.prototype.viewForQuery=function(n){if(n.getQueryParams().loadsAllData())return this.getCompleteView();var t=n.queryIdentifier();return p(this.views_,t)},n.prototype.viewExistsForQuery=function(n){return null!=this.viewForQuery(n)},n.prototype.hasCompleteView=function(){return null!=this.getCompleteView()},n.prototype.getCompleteView=function(){var n,i,t;return(n=this.views_,(t=sf(n,function(n){return n.getQuery().getQueryParams().loadsAllData()},i))&&n[t])||null},n}(),io=function(){function n(n){this.writeTree_=n}return n.prototype.addWrite=function(t,i){var u,o;if(t.isEmpty())return new n(new g(i));if(u=this.writeTree_.findRootMostValueAndPath(t),null!=u){var e=u.path,f=u.value,s=r.relativePath(e,t);return f=f.updateChild(s,i),new n(this.writeTree_.set(e,f))}return o=new g(i),new n(this.writeTree_.setTree(t,o))},n.prototype.addWrites=function(n,t){var i=this;return s(t,function(t,r){i=i.addWrite(n.child(t),r)}),i},n.prototype.removeWrite=function(t){return t.isEmpty()?n.Empty:new n(this.writeTree_.setTree(t,g.Empty))},n.prototype.hasCompleteWrite=function(n){return null!=this.getCompleteNode(n)},n.prototype.getCompleteNode=function(n){var t=this.writeTree_.findRootMostValueAndPath(n);return null!=t?this.writeTree_.get(t.path).getChild(r.relativePath(t.path,n)):null},n.prototype.getCompleteChildren=function(){var n=[],t=this.writeTree_.value;return null!=t?t.isLeafNode()||t.forEachChild(h,function(t,i){n.push(new o(t,i))}):this.writeTree_.children.inorderTraversal(function(t,i){null!=i.value&&n.push(new o(t,i.value))}),n},n.prototype.childCompoundWrite=function(t){if(t.isEmpty())return this;var i=this.getCompleteNode(t);return new n(null!=i?new g(i):this.writeTree_.subtree(t))},n.prototype.isEmpty=function(){return this.writeTree_.isEmpty()},n.prototype.apply=function(t){return n.applySubtreeWrite_(r.Empty,this.writeTree_,t)},n.Empty=new n(new g(null)),n.applySubtreeWrite_=function(t,r,u){if(null!=r.value)return u.updateChild(t,r.value);var f=null;return r.children.inorderTraversal(function(r,e){".priority"===r?(i(null!==e.value,"Priority writes must always be leaf nodes"),f=e.value):u=n.applySubtreeWrite_(t.child(r),e,u)}),u.getChild(t).isEmpty()||null===f||(u=u.updateChild(t.child(".priority"),f)),u},n}(),ih=function(){function n(){this.visibleWrites_=io.Empty;this.allWrites_=[];this.lastWriteId_=-1}return n.prototype.childWrites=function(n){return new rh(n,this)},n.prototype.addOverwrite=function(n,t,r,u){i(r>this.lastWriteId_,"Stacking an older write on top of newer ones");void 0===u&&(u=!0);this.allWrites_.push({path:n,snap:t,writeId:r,visible:u});u&&(this.visibleWrites_=this.visibleWrites_.addWrite(n,t));this.lastWriteId_=r},n.prototype.addMerge=function(n,t,r){i(r>this.lastWriteId_,"Stacking an older merge on top of newer ones");this.allWrites_.push({path:n,children:t,writeId:r,visible:!0});this.visibleWrites_=this.visibleWrites_.addWrites(n,t);this.lastWriteId_=r},n.prototype.getWrite=function(n){for(var i,t=0;t<this.allWrites_.length;t++)if(i=this.allWrites_[t],i.writeId===n)return i;return null},n.prototype.removeWrite=function(n){var o=this,r=this.allWrites_.findIndex(function(t){return t.writeId===n}),t,f,c;i(r>=0,"removeWrite called with nonexistent writeId.");t=this.allWrites_[r];this.allWrites_.splice(r,1);for(var e=t.visible,h=!1,u=this.allWrites_.length-1;e&&u>=0;)f=this.allWrites_[u],f.visible&&(u>=r&&this.recordContainsPath_(f,t.path)?e=!1:t.path.contains(f.path)&&(h=!0)),u--;return e?h?(this.resetTree_(),!0):(t.snap?this.visibleWrites_=this.visibleWrites_.removeWrite(t.path):(c=t.children,s(c,function(n){o.visibleWrites_=o.visibleWrites_.removeWrite(t.path.child(n))})),!0):!1},n.prototype.getCompleteWriteData=function(n){return this.visibleWrites_.getCompleteNode(n)},n.prototype.calcCompleteEventCache=function(t,i,u,e){var h,l,c,o,s;return u||e?(h=this.visibleWrites_.childCompoundWrite(t),!e&&h.isEmpty())?i:e||null!=i||h.hasCompleteWrite(r.Empty)?(l=n.layerTree_(this.allWrites_,function(n){return(n.visible||e)&&(!u||!~u.indexOf(n.writeId))&&(n.path.contains(t)||t.contains(n.path))},t),s=i||f.EMPTY_NODE,l.apply(s)):null:(c=this.visibleWrites_.getCompleteNode(t),null!=c)?c:(o=this.visibleWrites_.childCompoundWrite(t),o.isEmpty())?i:null!=i||o.hasCompleteWrite(r.Empty)?(s=i||f.EMPTY_NODE,o.apply(s)):null},n.prototype.calcCompleteEventChildren=function(n,t){var i=f.EMPTY_NODE,u=this.visibleWrites_.getCompleteNode(n),e;return u?(u.isLeafNode()||u.forEachChild(h,function(n,t){i=i.updateImmediateChild(n,t)}),i):t?(e=this.visibleWrites_.childCompoundWrite(n),t.forEachChild(h,function(n,t){var u=e.childCompoundWrite(new r(n)).apply(t);i=i.updateImmediateChild(n,u)}),e.getCompleteChildren().forEach(function(n){i=i.updateImmediateChild(n.name,n.node)}),i):(this.visibleWrites_.childCompoundWrite(n).getCompleteChildren().forEach(function(n){i=i.updateImmediateChild(n.name,n.node)}),i)},n.prototype.calcEventCacheAfterServerOverwrite=function(n,t,r,u){var f,e;return(i(r||u,"Either existingEventSnap or existingServerSnap must exist"),f=n.child(t),this.visibleWrites_.hasCompleteWrite(f))?null:(e=this.visibleWrites_.childCompoundWrite(f),e.isEmpty()?u.getChild(t):e.apply(u.getChild(t)))},n.prototype.calcCompleteChild=function(n,t,i){var r=n.child(t),u=this.visibleWrites_.getCompleteNode(r);return null!=u?u:i.isCompleteForChild(t)?this.visibleWrites_.childCompoundWrite(r).apply(i.getNode().getImmediateChild(t)):null},n.prototype.shadowingWrite=function(n){return this.visibleWrites_.getCompleteNode(n)},n.prototype.calcIndexedSlice=function(n,t,i,u,f,e){var o,c=this.visibleWrites_.childCompoundWrite(n),l=c.getCompleteNode(r.Empty);if(null!=l)o=l;else{if(null==t)return[];o=c.apply(t)}if((o=o.withIndex(e)).isEmpty()||o.isLeafNode())return[];for(var h=[],v=e.getCompare(),a=f?o.getReverseIteratorFrom(i,e):o.getIteratorFrom(i,e),s=a.getNext();s&&h.length<u;)0!==v(s,i)&&h.push(s),s=a.getNext();return h},n.prototype.recordContainsPath_=function(n,t){return n.snap?n.path.contains(t):!!sf(n.children,function(i,r){return n.path.child(r).contains(t)})},n.prototype.resetTree_=function(){this.visibleWrites_=n.layerTree_(this.allWrites_,n.DefaultFilter_,r.Empty);this.lastWriteId_=this.allWrites_.length>0?this.allWrites_[this.allWrites_.length-1].writeId:-1},n.DefaultFilter_=function(n){return n.visible},n.layerTree_=function(n,t,i){for(var f,o,e,h,c,u=io.Empty,s=0;s<n.length;++s)if(f=n[s],t(f))if(o=f.path,e=void 0,f.snap)i.contains(o)?(e=r.relativePath(i,o),u=u.addWrite(e,f.snap)):o.contains(i)&&(e=r.relativePath(o,i),u=u.addWrite(r.Empty,f.snap.getChild(e)));else{if(!f.children)throw ii("WriteRecord should have .snap or .children");i.contains(o)?(e=r.relativePath(i,o),u=u.addWrites(e,f.children)):o.contains(i)&&((e=r.relativePath(o,i)).isEmpty()?u=u.addWrites(r.Empty,f.children):(h=p(f.children,e.getFront()),h&&(c=h.getChild(e.popFront()),u=u.addWrite(r.Empty,c))))}return u},n}(),rh=function(){function n(n,t){this.treePath_=n;this.writeTree_=t}return n.prototype.calcCompleteEventCache=function(n,t,i){return this.writeTree_.calcCompleteEventCache(this.treePath_,n,t,i)},n.prototype.calcCompleteEventChildren=function(n){return this.writeTree_.calcCompleteEventChildren(this.treePath_,n)},n.prototype.calcEventCacheAfterServerOverwrite=function(n,t,i){return this.writeTree_.calcEventCacheAfterServerOverwrite(this.treePath_,n,t,i)},n.prototype.shadowingWrite=function(n){return this.writeTree_.shadowingWrite(this.treePath_.child(n))},n.prototype.calcIndexedSlice=function(n,t,i,r,u){return this.writeTree_.calcIndexedSlice(this.treePath_,n,t,i,r,u)},n.prototype.calcCompleteChild=function(n,t){return this.writeTree_.calcCompleteChild(this.treePath_,n,t)},n.prototype.child=function(t){return new n(this.treePath_.child(t),this.writeTree_)},n}(),ro=function(){function n(n){this.listenProvider_=n;this.syncPointTree_=g.Empty;this.pendingWriteTree_=new ih;this.tagToQueryMap_={};this.queryToTagMap_={}}return n.prototype.applyUserOverwrite=function(n,t,i,r){return this.pendingWriteTree_.addOverwrite(n,t,i,r),r?this.applyOperationToSyncPoints_(new vr(st.User,n,t)):[]},n.prototype.applyUserMerge=function(n,t,i){this.pendingWriteTree_.addMerge(n,t,i);var r=g.fromObject(t);return this.applyOperationToSyncPoints_(new cu(st.User,n,r))},n.prototype.ackUserWrite=function(n,t){var u,i;return(void 0===t&&(t=!1),u=this.pendingWriteTree_.getWrite(n),this.pendingWriteTree_.removeWrite(n))?(i=g.Empty,null!=u.snap?i=i.set(r.Empty,!0):s(u.children,function(n,t){i=i.set(new r(n),t)}),this.applyOperationToSyncPoints_(new ws(u.path,i,t))):[]},n.prototype.applyServerOverwrite=function(n,t){return this.applyOperationToSyncPoints_(new vr(st.Server,n,t))},n.prototype.applyServerMerge=function(n,t){var i=g.fromObject(t);return this.applyOperationToSyncPoints_(new cu(st.Server,n,i))},n.prototype.applyListenComplete=function(n){return this.applyOperationToSyncPoints_(new de(st.Server,n))},n.prototype.applyTaggedQueryOverwrite=function(t,i,u){var f=this.queryKeyForTag_(u);if(null!=f){var e=n.parseQueryKey_(f),o=e.path,s=e.queryId,h=r.relativePath(o,t),c=new vr(st.forServerTaggedQuery(s),h,i);return this.applyTaggedOperation_(o,c)}return[]},n.prototype.applyTaggedQueryMerge=function(t,i,u){var f=this.queryKeyForTag_(u);if(f){var e=n.parseQueryKey_(f),o=e.path,s=e.queryId,h=r.relativePath(o,t),c=g.fromObject(i),l=new cu(st.forServerTaggedQuery(s),h,c);return this.applyTaggedOperation_(o,l)}return[]},n.prototype.applyTaggedListenComplete=function(t,i){var u=this.queryKeyForTag_(i);if(u){var f=n.parseQueryKey_(u),e=f.path,o=f.queryId,s=r.relativePath(e,t),h=new de(st.forServerTaggedQuery(o),s);return this.applyTaggedOperation_(e,h)}return[]},n.prototype.addEventRegistration=function(t,u){var s=t.path,e=null,h=!1,a,o,v,c,y,p,l,w;return this.syncPointTree_.foreachOnPath(s,function(n,t){var i=r.relativePath(n,s);e=e||t.getCompleteServerCache(i);h=h||t.hasCompleteView()}),o=this.syncPointTree_.get(s),(o?(h=h||o.hasCompleteView(),e=e||o.getCompleteServerCache(r.Empty)):(o=new to,this.syncPointTree_=this.syncPointTree_.set(s,o)),null!=e)?a=!0:(a=!1,e=f.EMPTY_NODE,this.syncPointTree_.subtree(s).foreachChild(function(n,t){var i=t.getCompleteServerCache(r.Empty);i&&(e=e.updateImmediateChild(n,i))})),v=o.viewExistsForQuery(t),v||t.getQueryParams().loadsAllData()||(c=n.makeQueryKey_(t),i(!(c in this.queryToTagMap_),"View does not exist, but we have a tag"),y=n.getNextQueryTag_(),this.queryToTagMap_[c]=y,this.tagToQueryMap_["_"+y]=c),p=this.pendingWriteTree_.childWrites(s),l=o.addEventRegistration(t,u,p,e,a),v||h||(w=o.viewForQuery(t),l=l.concat(this.setupListener_(t,w))),l},n.prototype.removeEventRegistration=function(t,i,r){var v=this,f=t.path,e=this.syncPointTree_.get(f),y=[],s,u,h,c,l,a,o;if(e&&("default"===t.queryIdentifier()||e.viewExistsForQuery(t))){if(s=e.removeEventRegistration(t,i,r),e.isEmpty()&&(this.syncPointTree_=this.syncPointTree_.remove(f)),u=s.removed,y=s.events,h=-1!==u.findIndex(function(n){return n.getQueryParams().loadsAllData()}),c=this.syncPointTree_.findOnPath(f,function(n,t){return t.hasCompleteView()}),h&&!c&&(l=this.syncPointTree_.subtree(f),!l.isEmpty()))for(a=this.collectDistinctViewsForSubTree_(l),o=0;o<a.length;++o){var p=a[o],w=p.getQuery(),b=this.createListenerForView_(p);this.listenProvider_.startListening(n.queryForListening_(w),this.tagForQuery_(w),b.hashFn,b.onComplete)}!c&&u.length>0&&!r&&(h?this.listenProvider_.stopListening(n.queryForListening_(t),null):u.forEach(function(t){var i=v.queryToTagMap_[n.makeQueryKey_(t)];v.listenProvider_.stopListening(n.queryForListening_(t),i)}));this.removeTags_(u)}return y},n.prototype.calcCompleteEventCache=function(n,t){var i=this.pendingWriteTree_,u=this.syncPointTree_.findOnPath(n,function(t,i){var f=r.relativePath(t,n),u=i.getCompleteServerCache(f);if(u)return u});return i.calcCompleteEventCache(n,u,t,!0)},n.prototype.collectDistinctViewsForSubTree_=function(n){return n.fold(function(n,t,i){if(t&&t.hasCompleteView())return[t.getCompleteView()];var r=[];return t&&(r=t.getQueryViews()),s(i,function(n,t){r=r.concat(t)}),r})},n.prototype.removeTags_=function(t){for(var r,u,f,i=0;i<t.length;++i)r=t[i],r.getQueryParams().loadsAllData()||(u=n.makeQueryKey_(r),f=this.queryToTagMap_[u],delete this.queryToTagMap_[u],delete this.tagToQueryMap_["_"+f])},n.queryForListening_=function(n){return n.getQueryParams().loadsAllData()&&!n.getQueryParams().isDefault()?n.getRef():n},n.prototype.setupListener_=function(t,r){var l=t.path,o=this.tagForQuery_(t),h=this.createListenerForView_(r),a=this.listenProvider_.startListening(n.queryForListening_(t),o,h.hashFn,h.onComplete),c=this.syncPointTree_.subtree(l),f,u,e;if(o)i(!c.value.hasCompleteView(),"If we're adding a query, it shouldn't be shadowed");else for(f=c.fold(function(n,t,i){if(!n.isEmpty()&&t&&t.hasCompleteView())return[t.getCompleteView().getQuery()];var r=[];return t&&(r=r.concat(t.getQueryViews().map(function(n){return n.getQuery()}))),s(i,function(n,t){r=r.concat(t)}),r}),u=0;u<f.length;++u)e=f[u],this.listenProvider_.stopListening(n.queryForListening_(e),this.tagForQuery_(e));return a},n.prototype.createListenerForView_=function(n){var i=this,t=n.getQuery(),r=this.tagForQuery_(t);return{hashFn:function(){return(n.getServerCache()||f.EMPTY_NODE).hash()},onComplete:function(n){if("ok"===n)return r?i.applyTaggedListenComplete(t.path,r):i.applyListenComplete(t.path);var u=function(n,t){var i="Unknown Error",r;return"too_big"===n?i="The data requested exceeds the maximum size that can be accessed with a single request.":"permission_denied"==n?i="Client doesn't have permission to access the desired data.":"unavailable"==n&&(i="The service is unavailable"),r=new Error(n+" at "+t.path.toString()+": "+i),r.code=n.toUpperCase(),r}(n,t);return i.removeEventRegistration(t,null,u)}}},n.makeQueryKey_=function(n){return n.path.toString()+"$"+n.queryIdentifier()},n.parseQueryKey_=function(n){var t=n.indexOf("$");return i(-1!==t&&t<n.length-1,"Bad queryKey."),{queryId:n.substr(t+1),path:new r(n.substr(0,t))}},n.prototype.queryKeyForTag_=function(n){return this.tagToQueryMap_["_"+n]},n.prototype.tagForQuery_=function(t){var i=n.makeQueryKey_(t);return p(this.queryToTagMap_,i)},n.getNextQueryTag_=function(){return n.nextQueryTag_++},n.prototype.applyTaggedOperation_=function(n,t){var r=this.syncPointTree_.get(n),u;return i(r,"Missing sync point for query tag that we're tracking"),u=this.pendingWriteTree_.childWrites(n),r.applyOperation(t,u,null)},n.prototype.applyOperationToSyncPoints_=function(n){return this.applyOperationHelper_(n,this.syncPointTree_,null,this.pendingWriteTree_.childWrites(r.Empty))},n.prototype.applyOperationHelper_=function(n,t,i,u){var f,c,l;if(n.path.isEmpty())return this.applyOperationDescendantsHelper_(n,t,i,u);f=t.get(r.Empty);null==i&&null!=f&&(i=f.getCompleteServerCache(r.Empty));var e=[],o=n.path.getFront(),s=n.operationForChild(o),h=t.children.get(o);return h&&s&&(c=i?i.getImmediateChild(o):null,l=u.child(o),e=e.concat(this.applyOperationHelper_(s,h,c,l))),f&&(e=e.concat(f.applyOperation(n,u,i))),e},n.prototype.applyOperationDescendantsHelper_=function(n,t,i,u){var o=this,e=t.get(r.Empty),f;return null==i&&null!=e&&(i=e.getCompleteServerCache(r.Empty)),f=[],t.children.inorderTraversal(function(t,r){var s=i?i.getImmediateChild(t):null,h=u.child(t),e=n.operationForChild(t);e&&(f=f.concat(o.applyOperationDescendantsHelper_(e,r,s,h)))}),e&&(f=f.concat(e.applyOperation(n,u,i))),f},n.nextQueryTag_=1,n}(),uh=function(){function n(){this.rootNode_=f.EMPTY_NODE}return n.prototype.getNode=function(n){return this.rootNode_.getChild(n)},n.prototype.updateSnapshot=function(n,t){this.rootNode_=this.rootNode_.updateChild(n,t)},n}(),fh=function(){function n(n){this.app_=n}return n.prototype.getToken=function(n){return this.app_.INTERNAL.getToken(n).then(null,function(n){return n&&"auth/token-not-initialized"===n.code?(w("Got auth/token-not-initialized error.  Treating as null token."),null):Promise.reject(n)})},n.prototype.addTokenChangeListener=function(n){this.app_.INTERNAL.addAuthTokenListener(n)},n.prototype.removeTokenChangeListener=function(n){this.app_.INTERNAL.removeAuthTokenListener(n)},n.prototype.notifyForInvalidToken=function(){var n='Provided authentication credentials for the app named "'+this.app_.name+'" are invalid. This usually indicates your app was not initialized correctly. ';n+="credential"in this.app_.options?'Make sure the "credential" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':"serviceAccount"in this.app_.options?'Make sure the "serviceAccount" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':'Make sure the "apiKey" and "databaseURL" properties provided to initializeApp() match the values provided for your app at https://console.firebase.google.com/.';b(n)},n}(),eh=function(){function n(){this.counters_={}}return n.prototype.incrementCounter=function(n,t){void 0===t&&(t=1);d(this.counters_,n)||(this.counters_[n]=0);this.counters_[n]+=t},n.prototype.get=function(){return po(this.counters_)},n}(),yr=function(){function n(){}return n.getCollection=function(n){var t=n.toString();return this.collections_[t]||(this.collections_[t]=new eh),this.collections_[t]},n.getOrCreateReporter=function(n,t){var i=n.toString();return this.reporters_[i]||(this.reporters_[i]=t()),this.reporters_[i]},n.collections_={},n.reporters_={},n}(),uo=function(){function n(n){this.collection_=n;this.last_=null}return n.prototype.get=function(){var t=this.collection_.get(),n=wr(t);return this.last_&&s(this.last_,function(t,i){n[t]=n[t]-i}),this.last_=t,n},n}(),fo=1e4,oh=3e4,sh=function(){function n(n,t){this.server_=t;this.statsToReport_={};this.statsListener_=new uo(n);var i=fo+(oh-fo)*Math.random();wi(this.reportStats_.bind(this),Math.floor(i))}return n.prototype.includeStat=function(n){this.statsToReport_[n]=!0},n.prototype.reportStats_=function(){var i=this,r=this.statsListener_.get(),n={},t=!1;s(r,function(r,u){u>0&&d(i.statsToReport_,r)&&(n[r]=u,t=!0)});t&&this.server_.reportStats(n);wi(this.reportStats_.bind(this),Math.floor(6e5*Math.random()))},n}(),hh=function(){function n(){this.eventLists_=[];this.recursionDepth_=0}return n.prototype.queueEvents=function(n){for(var r,u,t=null,i=0;i<n.length;i++)r=n[i],u=r.getPath(),null===t||u.equals(t.getPath())||(this.eventLists_.push(t),t=null),null===t&&(t=new ch(u)),t.add(r);t&&this.eventLists_.push(t)},n.prototype.raiseEventsAtPath=function(n,t){this.queueEvents(t);this.raiseQueuedEventsMatchingPredicate_(function(t){return t.equals(n)})},n.prototype.raiseEventsForChangedPath=function(n,t){this.queueEvents(t);this.raiseQueuedEventsMatchingPredicate_(function(t){return t.contains(n)||n.contains(t)})},n.prototype.raiseQueuedEventsMatchingPredicate_=function(n){var i,t,r;for(this.recursionDepth_++,i=!0,t=0;t<this.eventLists_.length;t++)r=this.eventLists_[t],r&&(n(r.getPath())?(this.eventLists_[t].raise(),this.eventLists_[t]=null):i=!1);i&&(this.eventLists_=[]);this.recursionDepth_--},n}(),ch=function(){function n(n){this.path_=n;this.events_=[]}return n.prototype.add=function(n){this.events_.push(n)},n.prototype.raise=function(){for(var t,i,n=0;n<this.events_.length;n++)t=this.events_[n],null!==t&&(this.events_[n]=null,i=t.getEventRunner(),bt&&w("event: "+t.toString()),ui(i))},n.prototype.getPath=function(){return this.path_},n}(),eo=function(){function n(n){this.allowedEvents_=n;this.listeners_={};i(Array.isArray(n)&&n.length>0,"Requires a non-empty array")}return n.prototype.trigger=function(n){for(var r,i,u=[],t=1;t<arguments.length;t++)u[t-1]=arguments[t];if(Array.isArray(this.listeners_[n]))for(r=this.listeners_[n].slice(),i=0;i<r.length;i++)r[i].callback.apply(r[i].context,u)},n.prototype.on=function(n,t,i){this.validateEventType_(n);this.listeners_[n]=this.listeners_[n]||[];this.listeners_[n].push({callback:t,context:i});var r=this.getInitialEvent(n);r&&t.apply(i,r)},n.prototype.off=function(n,t,i){this.validateEventType_(n);for(var u=this.listeners_[n]||[],r=0;r<u.length;r++)if(u[r].callback===t&&(!i||i===u[r].context))return void u.splice(r,1)},n.prototype.validateEventType_=function(n){i(this.allowedEvents_.find(function(t){return t===n}),"Unknown event: "+n)},n}(),lh=function(n){function t(){var i,t,r=n.call(this,["visible"])||this;return"undefined"!=typeof document&&void 0!==document.addEventListener&&(void 0!==document.hidden?(t="visibilitychange",i="hidden"):void 0!==document.mozHidden?(t="mozvisibilitychange",i="mozHidden"):void 0!==document.msHidden?(t="msvisibilitychange",i="msHidden"):void 0!==document.webkitHidden&&(t="webkitvisibilitychange",i="webkitHidden")),r.visible_=!0,t&&document.addEventListener(t,function(){var n=!document[i];n!==r.visible_&&(r.visible_=n,r.trigger("visible",n))},!1),r}return it(t,n),t.getInstance=function(){return new t},t.prototype.getInitialEvent=function(n){return i("visible"===n,"Unknown event type: "+n),[this.visible_]},t}(eo),oo=function(n){function t(){var t=n.call(this,["online"])||this;return t.online_=!0,"undefined"==typeof window||void 0===window.addEventListener||rf()||(window.addEventListener("online",function(){t.online_||(t.online_=!0,t.trigger("online",!0))},!1),window.addEventListener("offline",function(){t.online_&&(t.online_=!1,t.trigger("online",!1))},!1)),t}return it(t,n),t.getInstance=function(){return new t},t.prototype.getInitialEvent=function(n){return i("online"===n,"Unknown event type: "+n),[this.online_]},t.prototype.currentlyOnline=function(){return this.online_},t}(eo),ah=function(){function n(n){this.onMessage_=n;this.pendingResponses=[];this.currentResponseNum=0;this.closeAfterResponse=-1;this.onClose=null}return n.prototype.closeAfter=function(n,t){this.closeAfterResponse=n;this.onClose=t;this.closeAfterResponse<this.currentResponseNum&&(this.onClose(),this.onClose=null)},n.prototype.handleResponse=function(n,t){var u=this,r,i;for(this.pendingResponses[n]=t,r=function(){var t=i.pendingResponses[i.currentResponseNum],r,n;for(delete i.pendingResponses[i.currentResponseNum],r=function(n){t[n]&&ui(function(){u.onMessage_(t[n])})},n=0;n<t.length;++n)r(n);if(i.currentResponseNum===i.closeAfterResponse)return i.onClose&&(i.onClose(),i.onClose=null),"break";i.currentResponseNum++},i=this;this.pendingResponses[this.currentResponseNum];)if("break"===r())break},n}(),vh="pLPCommand",yh="pRTLPCB",vu=function(){function n(n,t,i,r){this.connId=n;this.repoInfo=t;this.transportSessionId=i;this.lastSessionId=r;this.bytesSent=0;this.bytesReceived=0;this.everConnected_=!1;this.log_=yi(n);this.stats_=yr.getCollection(t);this.urlFn=function(n){return t.connectionURL(gf,n)}}return n.prototype.open=function(n,t){var i=this;this.curSegmentNum=0;this.onDisconnect_=t;this.myPacketOrderer=new ah(n);this.isClosed_=!1;this.connectTimeoutTimer_=setTimeout(function(){i.log_("Timed out trying to connect.");i.onClosed_();i.connectTimeoutTimer_=null},Math.floor(3e4)),function(n){if(ut()||"complete"===document.readyState)n();else{var i=!1,t=function(){document.body?i||(i=!0,n()):setTimeout(t,Math.floor(10))};document.addEventListener?(document.addEventListener("DOMContentLoaded",t,!1),window.addEventListener("load",t,!1)):document.attachEvent&&(document.attachEvent("onreadystatechange",function(){"complete"===document.readyState&&t()}),window.attachEvent("onload",t))}}(function(){var n,t;i.isClosed_||(i.scriptTagHolder=new ph(function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var r=n[0],u=n[1],f=n[2];if(i.incrementIncomingBytes_(n),i.scriptTagHolder)if(i.connectTimeoutTimer_&&(clearTimeout(i.connectTimeoutTimer_),i.connectTimeoutTimer_=null),i.everConnected_=!0,"start"==r)i.id=u,i.password=f;else{if("close"!==r)throw new Error("Unrecognized command received: "+r);u?(i.scriptTagHolder.sendNewPolls=!1,i.myPacketOrderer.closeAfter(u,function(){i.onClosed_()})):i.onClosed_()}},function(){for(var r,u,n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];r=n[0];u=n[1];i.incrementIncomingBytes_(n);i.myPacketOrderer.handleResponse(r,u)},function(){i.onClosed_()},i.urlFn),n={start:"t"},n.ser=Math.floor(1e8*Math.random()),i.scriptTagHolder.uniqueCallbackIdentifier&&(n.cb=i.scriptTagHolder.uniqueCallbackIdentifier),n.v="5",i.transportSessionId&&(n.s=i.transportSessionId),i.lastSessionId&&(n.ls=i.lastSessionId),!ut()&&"undefined"!=typeof location&&location.href&&-1!==location.href.indexOf("firebaseio.com")&&(n.r="f"),t=i.urlFn(n),i.log_("Connecting via long-poll to "+t),i.scriptTagHolder.addTag(t,function(){}))})},n.prototype.start=function(){this.scriptTagHolder.startLongPoll(this.id,this.password);this.addDisconnectPingFrame(this.id,this.password)},n.forceAllow=function(){n.forceAllow_=!0},n.forceDisallow=function(){n.forceDisallow_=!0},n.isAvailable=function(){return n.forceAllow_||!n.forceDisallow_&&"undefined"!=typeof document&&null!=document.createElement&&!("object"==typeof window&&window.chrome&&window.chrome.extension&&!/^chrome/.test(window.location.href))&&!("object"==typeof Windows&&"object"==typeof Windows.UI)&&!ut()},n.prototype.markConnectionHealthy=function(){},n.prototype.shutdown_=function(){this.isClosed_=!0;this.scriptTagHolder&&(this.scriptTagHolder.close(),this.scriptTagHolder=null);this.myDisconnFrame&&(document.body.removeChild(this.myDisconnFrame),this.myDisconnFrame=null);this.connectTimeoutTimer_&&(clearTimeout(this.connectTimeoutTimer_),this.connectTimeoutTimer_=null)},n.prototype.onClosed_=function(){this.isClosed_||(this.log_("Longpoll is closing itself"),this.shutdown_(),this.onDisconnect_&&(this.onDisconnect_(this.everConnected_),this.onDisconnect_=null))},n.prototype.close=function(){this.isClosed_||(this.log_("Longpoll is being closed."),this.shutdown_())},n.prototype.send=function(n){var t=a(n);this.bytesSent+=t.length;this.stats_.incrementCounter("bytes_sent",t.length);for(var u,f=(u=nf(t),pr.encodeByteArray(u,!0)),i=wf(f,1840),r=0;r<i.length;r++)this.scriptTagHolder.enqueueSegment(this.curSegmentNum,i.length,i[r]),this.curSegmentNum++},n.prototype.addDisconnectPingFrame=function(n,t){if(!ut()){this.myDisconnFrame=document.createElement("iframe");var i={dframe:"t"};i.id=n;i.pw=t;this.myDisconnFrame.src=this.urlFn(i);this.myDisconnFrame.style.display="none";document.body.appendChild(this.myDisconnFrame)}},n.prototype.incrementIncomingBytes_=function(n){var t=a(n).length;this.bytesReceived+=t;this.stats_.incrementCounter("bytes_received",t)},n}(),ph=function(){function n(t,i,r,u){var f,e;if(this.onDisconnect=r,this.urlFn=u,this.outstandingRequests=new be,this.pendingSegs=[],this.currentSerial=Math.floor(1e8*Math.random()),this.sendNewPolls=!0,ut())this.commandCB=t,this.onMessageCB=i;else{this.uniqueCallbackIdentifier=af();window[vh+this.uniqueCallbackIdentifier]=t;window[yh+this.uniqueCallbackIdentifier]=i;this.myIFrame=n.createIFrame_();f="";this.myIFrame.src&&"javascript:"===this.myIFrame.src.substr(0,11)&&(f='<script>document.domain="'+document.domain+'";<\/script>');e="<html><body>"+f+"<\/body><\/html>";try{this.myIFrame.doc.open();this.myIFrame.doc.write(e);this.myIFrame.doc.close()}catch(n){w("frame writing exception");n.stack&&w(n.stack);w(n)}}}return n.createIFrame_=function(){var n=document.createElement("iframe"),t;if(n.style.display="none",!document.body)throw"Document body has not initialized. Wait to initialize Firebase until after the document is ready.";document.body.appendChild(n);try{n.contentWindow.document||w("No IE domain setting required")}catch(i){t=document.domain;n.src="javascript:void((function(){document.open();document.domain='"+t+"';document.close();})())"}return n.contentDocument?n.doc=n.contentDocument:n.contentWindow?n.doc=n.contentWindow.document:n.document&&(n.doc=n.document),n},n.prototype.close=function(){var i=this,t,u,r;(this.alive=!1,this.myIFrame&&(this.myIFrame.doc.body.innerHTML="",setTimeout(function(){null!==i.myIFrame&&(document.body.removeChild(i.myIFrame),i.myIFrame=null)},Math.floor(0))),ut()&&this.myID)&&(t={disconn:"t"},t.id=this.myID,t.pw=this.myPW,u=this.urlFn(t),n.nodeRestRequest(u));r=this.onDisconnect;r&&(this.onDisconnect=null,r())},n.prototype.startLongPoll=function(n,t){for(this.myID=n,this.myPW=t,this.alive=!0;this.newRequest_(););},n.prototype.newRequest_=function(){var n,r;if(this.alive&&this.sendNewPolls&&this.outstandingRequests.count()<(this.pendingSegs.length>0?2:1)){this.currentSerial++;n={};n.id=this.myID;n.pw=this.myPW;n.ser=this.currentSerial;for(var u=this.urlFn(n),t="",i=0;this.pendingSegs.length>0;){if(!(this.pendingSegs[0].d.length+30+t.length<=1870))break;r=this.pendingSegs.shift();t=t+"&seg"+i+"="+r.seg+"&ts"+i+"="+r.ts+"&d"+i+"="+r.d;i++}return u+=t,this.addLongPollTag_(u,this.currentSerial),!0}return!1},n.prototype.enqueueSegment=function(n,t,i){this.pendingSegs.push({seg:n,ts:t,d:i});this.alive&&this.newRequest_()},n.prototype.addLongPollTag_=function(n,t){var r=this,i,u;this.outstandingRequests.add(t,1);i=function(){r.outstandingRequests.remove(t);r.newRequest_()};u=setTimeout(i,Math.floor(25e3));this.addTag(n,function(){clearTimeout(u);i()})},n.prototype.addTag=function(n,t){var i=this;ut()?this.doNodeLongPoll(n,t):setTimeout(function(){try{if(!i.sendNewPolls)return;var r=i.myIFrame.doc.createElement("script");r.type="text/javascript";r.async=!0;r.src=n;r.onload=r.onreadystatechange=function(){var n=r.readyState;n&&"loaded"!==n&&"complete"!==n||(r.onload=r.onreadystatechange=null,r.parentNode&&r.parentNode.removeChild(r),t())};r.onerror=function(){w("Long-poll script failed to load: "+n);i.sendNewPolls=!1;i.close()};i.myIFrame.doc.body.appendChild(r)}catch(n){}},Math.floor(1))},n}(),tr=null;"undefined"!=typeof MozWebSocket?tr=MozWebSocket:"undefined"!=typeof WebSocket&&(tr=WebSocket);var ni=function(){function n(t,i,r,u){this.connId=t;this.keepaliveTimer=null;this.frames=null;this.totalFrames=0;this.bytesSent=0;this.bytesReceived=0;this.log_=yi(this.connId);this.stats_=yr.getCollection(i);this.connURL=n.connectionURL_(i,r,u)}return n.connectionURL_=function(n,t,i){var r={v:"5"};return!ut()&&"undefined"!=typeof location&&location.href&&-1!==location.href.indexOf("firebaseio.com")&&(r.r="f"),t&&(r.s=t),i&&(r.ls=i),n.connectionURL("websocket",r)},n.prototype.open=function(n,i){var r=this,f;this.onDisconnect=i;this.onMessage=n;this.log_("Websocket connecting to "+this.connURL);this.everConnected_=!1;wt.set("previous_websocket_failure",!0);try{if(ut()){var s=pt.NODE_ADMIN?"AdminNode":"Node",e={headers:{"User-Agent":"Firebase/5/"+t.SDK_VERSION+"/"+process.platform+"/"+s}},u=process.env,o=0==this.connURL.indexOf("wss://")?u.HTTPS_PROXY||u.https_proxy:u.HTTP_PROXY||u.http_proxy;o&&(e.proxy={origin:o});this.mySock=new tr(this.connURL,[],e)}else this.mySock=new tr(this.connURL)}catch(n){return this.log_("Error instantiating WebSocket."),f=n.message||n.data,f&&this.log_(f),void this.onClosed_()}this.mySock.onopen=function(){r.log_("Websocket connected.");r.everConnected_=!0};this.mySock.onclose=function(){r.log_("Websocket connection was disconnected.");r.mySock=null;r.onClosed_()};this.mySock.onmessage=function(n){r.handleIncomingFrame(n)};this.mySock.onerror=function(n){r.log_("WebSocket error.  Closing connection.");var t=n.message||n.data;t&&r.log_(t);r.onClosed_()}},n.prototype.start=function(){},n.forceDisallow=function(){n.forceDisallow_=!0},n.isAvailable=function(){var i=!1,t;return"undefined"!=typeof navigator&&navigator.userAgent&&(t=navigator.userAgent.match(/Android ([0-9]{0,}\.[0-9]{0,})/),t&&t.length>1&&parseFloat(t[1])<4.4&&(i=!0)),!i&&null!==tr&&!n.forceDisallow_},n.previouslyFailed=function(){return wt.isInMemoryStorage||!0===wt.get("previous_websocket_failure")},n.prototype.markConnectionHealthy=function(){wt.remove("previous_websocket_failure")},n.prototype.appendFrame_=function(n){var t,i;if(this.frames.push(n),this.frames.length==this.totalFrames){t=this.frames.join("");this.frames=null;i=ci(t);this.onMessage(i)}},n.prototype.handleNewFrameCount_=function(n){this.totalFrames=n;this.frames=[]},n.prototype.extractFrameCount_=function(n){if(i(null===this.frames,"We already have a frame buffer"),n.length<=6){var t=Number(n);if(!isNaN(t))return this.handleNewFrameCount_(t),null}return this.handleNewFrameCount_(1),n},n.prototype.handleIncomingFrame=function(n){var t,i;null!==this.mySock&&(t=n.data,(this.bytesReceived+=t.length,this.stats_.incrementCounter("bytes_received",t.length),this.resetKeepAlive(),null!==this.frames)?this.appendFrame_(t):(i=this.extractFrameCount_(t),null!==i&&this.appendFrame_(i)))},n.prototype.send=function(n){var i,t,r;for(this.resetKeepAlive(),i=a(n),this.bytesSent+=i.length,this.stats_.incrementCounter("bytes_sent",i.length),t=wf(i,16384),t.length>1&&this.sendString_(String(t.length)),r=0;r<t.length;r++)this.sendString_(t[r])},n.prototype.shutdown_=function(){this.isClosed_=!0;this.keepaliveTimer&&(clearInterval(this.keepaliveTimer),this.keepaliveTimer=null);this.mySock&&(this.mySock.close(),this.mySock=null)},n.prototype.onClosed_=function(){this.isClosed_||(this.log_("WebSocket is closing itself"),this.shutdown_(),this.onDisconnect&&(this.onDisconnect(this.everConnected_),this.onDisconnect=null))},n.prototype.close=function(){this.isClosed_||(this.log_("WebSocket is being closed"),this.shutdown_())},n.prototype.resetKeepAlive=function(){var n=this;clearInterval(this.keepaliveTimer);this.keepaliveTimer=setInterval(function(){n.mySock&&n.sendString_("0");n.resetKeepAlive()},Math.floor(45e3))},n.prototype.sendString_=function(n){try{this.mySock.send(n)}catch(n){this.log_("Exception thrown from WebSocket.send():",n.message||n.data,"Closing connection.");setTimeout(this.onClosed_.bind(this),0)}},n.responsesRequiredToBeHealthy=2,n.healthyTimeout=3e4,n}(),wh=function(){function n(n){this.initTransports_(n)}return Object.defineProperty(n,"ALL_TRANSPORTS",{get:function(){return[vu,ni]},enumerable:!0,configurable:!0}),n.prototype.initTransports_=function(t){var i=ni&&ni.isAvailable(),r=i&&!ni.previouslyFailed(),u;(t.webSocketOnly&&(i||b("wss:// URL used, but browser isn't known to support websockets.  Trying anyway."),r=!0),r)?this.transports_=[ni]:(u=this.transports_=[],bf(n.ALL_TRANSPORTS,function(n,t){t&&t.isAvailable()&&u.push(t)}))},n.prototype.initialTransport=function(){if(this.transports_.length>0)return this.transports_[0];throw new Error("No transports available");},n.prototype.upgradeTransport=function(){return this.transports_.length>1?this.transports_[1]:null},n}(),so=function(){function n(n,t,i,r,u,f,e){this.id=n;this.repoInfo_=t;this.onMessage_=i;this.onReady_=r;this.onDisconnect_=u;this.onKill_=f;this.lastSessionId=e;this.connectionCount=0;this.pendingDataMessages=[];this.state_=0;this.log_=yi("c:"+this.id+":");this.transportManager_=new wh(t);this.log_("Connection created");this.start_()}return n.prototype.start_=function(){var n=this,t=this.transportManager_.initialTransport(),r,u,i;this.conn_=new t(this.nextTransportId_(),this.repoInfo_,void 0,this.lastSessionId);this.primaryResponsesRequired_=t.responsesRequiredToBeHealthy||0;r=this.connReceiver_(this.conn_);u=this.disconnReceiver_(this.conn_);this.tx_=this.conn_;this.rx_=this.conn_;this.secondaryConn_=null;this.isHealthy_=!1;setTimeout(function(){n.conn_&&n.conn_.open(r,u)},Math.floor(0));i=t.healthyTimeout||0;i>0&&(this.healthyTimeout_=wi(function(){n.healthyTimeout_=null;n.isHealthy_||(n.conn_&&n.conn_.bytesReceived>102400?(n.log_("Connection exceeded healthy timeout but has received "+n.conn_.bytesReceived+" bytes.  Marking connection healthy."),n.isHealthy_=!0,n.conn_.markConnectionHealthy()):n.conn_&&n.conn_.bytesSent>10240?n.log_("Connection exceeded healthy timeout but has sent "+n.conn_.bytesSent+" bytes.  Leaving connection alive."):(n.log_("Closing unhealthy connection after timeout."),n.close()))},Math.floor(i)))},n.prototype.nextTransportId_=function(){return"c:"+this.id+":"+this.connectionCount++},n.prototype.disconnReceiver_=function(n){var t=this;return function(i){n===t.conn_?t.onConnectionLost_(i):n===t.secondaryConn_?(t.log_("Secondary connection lost."),t.onSecondaryConnectionLost_()):t.log_("closing an old connection")}},n.prototype.connReceiver_=function(n){var t=this;return function(i){2!=t.state_&&(n===t.rx_?t.onPrimaryMessageReceived_(i):n===t.secondaryConn_?t.onSecondaryMessageReceived_(i):t.log_("message on old connection"))}},n.prototype.sendRequest=function(n){var t={t:"d",d:n};this.sendData_(t)},n.prototype.tryCleanupConnection=function(){this.tx_===this.secondaryConn_&&this.rx_===this.secondaryConn_&&(this.log_("cleaning up and promoting a connection: "+this.secondaryConn_.connId),this.conn_=this.secondaryConn_,this.secondaryConn_=null)},n.prototype.onSecondaryControl_=function(n){if("t"in n){var t=n.t;"a"===t?this.upgradeIfSecondaryHealthy_():"r"===t?(this.log_("Got a reset on secondary, closing it"),this.secondaryConn_.close(),this.tx_!==this.secondaryConn_&&this.rx_!==this.secondaryConn_||this.close()):"o"===t&&(this.log_("got pong on secondary."),this.secondaryResponsesRequired_--,this.upgradeIfSecondaryHealthy_())}},n.prototype.onSecondaryMessageReceived_=function(n){var t=pi("t",n),i=pi("d",n);if("c"==t)this.onSecondaryControl_(i);else{if("d"!=t)throw new Error("Unknown protocol layer: "+t);this.pendingDataMessages.push(i)}},n.prototype.upgradeIfSecondaryHealthy_=function(){this.secondaryResponsesRequired_<=0?(this.log_("Secondary connection is healthy."),this.isHealthy_=!0,this.secondaryConn_.markConnectionHealthy(),this.proceedWithUpgrade_()):(this.log_("sending ping on secondary."),this.secondaryConn_.send({t:"c",d:{t:"p",d:{}}}))},n.prototype.proceedWithUpgrade_=function(){this.secondaryConn_.start();this.log_("sending client ack on secondary");this.secondaryConn_.send({t:"c",d:{t:"a",d:{}}});this.log_("Ending transmission on primary");this.conn_.send({t:"c",d:{t:"n",d:{}}});this.tx_=this.secondaryConn_;this.tryCleanupConnection()},n.prototype.onPrimaryMessageReceived_=function(n){var t=pi("t",n),i=pi("d",n);"c"==t?this.onControl_(i):"d"==t&&this.onDataMessage_(i)},n.prototype.onDataMessage_=function(n){this.onPrimaryResponse_();this.onMessage_(n)},n.prototype.onPrimaryResponse_=function(){this.isHealthy_||(this.primaryResponsesRequired_--,this.primaryResponsesRequired_<=0&&(this.log_("Primary connection is healthy."),this.isHealthy_=!0,this.conn_.markConnectionHealthy()))},n.prototype.onControl_=function(n){var t=pi("t",n),i,r;if("d"in n)if(i=n.d,"h"===t)this.onHandshake_(i);else if("n"===t){for(this.log_("recvd end transmission on primary"),this.rx_=this.secondaryConn_,r=0;r<this.pendingDataMessages.length;++r)this.onDataMessage_(this.pendingDataMessages[r]);this.pendingDataMessages=[];this.tryCleanupConnection()}else"s"===t?this.onConnectionShutdown_(i):"r"===t?this.onReset_(i):"e"===t?kr("Server Error: "+i):"o"===t?(this.log_("got pong on primary."),this.onPrimaryResponse_(),this.sendPingOnPrimaryIfNecessary_()):kr("Unknown control packet command: "+t)},n.prototype.onHandshake_=function(n){var t=n.ts,i=n.v,r=n.h;this.sessionId=n.s;this.repoInfo_.updateHost(r);0==this.state_&&(this.conn_.start(),this.onConnectionEstablished_(this.conn_,t),"5"!==i&&b("Protocol version mismatch detected"),this.tryStartUpgrade_())},n.prototype.tryStartUpgrade_=function(){var n=this.transportManager_.upgradeTransport();n&&this.startUpgrade_(n)},n.prototype.startUpgrade_=function(n){var t=this,i,r;this.secondaryConn_=new n(this.nextTransportId_(),this.repoInfo_,this.sessionId);this.secondaryResponsesRequired_=n.responsesRequiredToBeHealthy||0;i=this.connReceiver_(this.secondaryConn_);r=this.disconnReceiver_(this.secondaryConn_);this.secondaryConn_.open(i,r);wi(function(){t.secondaryConn_&&(t.log_("Timed out trying to upgrade."),t.secondaryConn_.close())},Math.floor(6e4))},n.prototype.onReset_=function(n){this.log_("Reset packet received.  New host: "+n);this.repoInfo_.updateHost(n);1===this.state_?this.close():(this.closeConnections_(),this.start_())},n.prototype.onConnectionEstablished_=function(n,t){var i=this;this.log_("Realtime connection established.");this.conn_=n;this.state_=1;this.onReady_&&(this.onReady_(t,this.sessionId),this.onReady_=null);0===this.primaryResponsesRequired_?(this.log_("Primary connection is healthy."),this.isHealthy_=!0):wi(function(){i.sendPingOnPrimaryIfNecessary_()},Math.floor(5e3))},n.prototype.sendPingOnPrimaryIfNecessary_=function(){this.isHealthy_||1!==this.state_||(this.log_("sending ping on primary."),this.sendData_({t:"c",d:{t:"p",d:{}}}))},n.prototype.onSecondaryConnectionLost_=function(){var n=this.secondaryConn_;this.secondaryConn_=null;this.tx_!==n&&this.rx_!==n||this.close()},n.prototype.onConnectionLost_=function(n){this.conn_=null;n||0!==this.state_?1===this.state_&&this.log_("Realtime connection lost."):(this.log_("Realtime connection failed."),this.repoInfo_.isCacheableHost()&&(wt.remove("host:"+this.repoInfo_.host),this.repoInfo_.internalHost=this.repoInfo_.host));this.close()},n.prototype.onConnectionShutdown_=function(n){this.log_("Connection shutdown command received. Shutting down...");this.onKill_&&(this.onKill_(n),this.onKill_=null);this.onDisconnect_=null;this.close()},n.prototype.sendData_=function(n){if(1!==this.state_)throw"Connection is not connected";this.tx_.send(n)},n.prototype.close=function(){2!==this.state_&&(this.log_("Closing realtime connection."),this.state_=2,this.closeConnections_(),this.onDisconnect_&&(this.onDisconnect_(),this.onDisconnect_=null))},n.prototype.closeConnections_=function(){this.log_("Shutting down all connections");this.conn_&&(this.conn_.close(),this.conn_=null);this.secondaryConn_&&(this.secondaryConn_.close(),this.secondaryConn_=null);this.healthyTimeout_&&(clearTimeout(this.healthyTimeout_),this.healthyTimeout_=null)},n}(),ho=function(){function n(){}return n.prototype.put=function(){},n.prototype.merge=function(){},n.prototype.refreshAuthToken=function(){},n.prototype.onDisconnectPut=function(){},n.prototype.onDisconnectMerge=function(){},n.prototype.onDisconnectCancel=function(){},n.prototype.reportStats=function(){},n}(),ir=1e3,bh=3e5,ti=function(n){function u(t,i,r,f,e,o){var s=n.call(this)||this;if(s.repoInfo_=t,s.onDataUpdate_=i,s.onConnectStatus_=r,s.onServerInfoUpdate_=f,s.authTokenProvider_=e,s.authOverride_=o,s.id=u.nextPersistentConnectionId_++,s.log_=yi("p:"+s.id+":"),s.interruptReasons_={},s.listens_={},s.outstandingPuts_=[],s.outstandingPutCount_=0,s.onDisconnectRequestQueue_=[],s.connected_=!1,s.reconnectDelay_=ir,s.maxReconnectDelay_=bh,s.securityDebugCallback_=null,s.lastSessionId=null,s.establishConnectionTimer_=null,s.visible_=!1,s.requestCBHash_={},s.requestNumber_=0,s.realtime_=null,s.authToken_=null,s.forceTokenRefresh_=!1,s.invalidAuthTokenCount_=0,s.firstConnection_=!0,s.lastConnectionAttemptTime_=null,s.lastConnectionEstablishedTime_=null,o&&!ut())throw new Error("Auth override specified in options, but not supported on non Node.js platforms");return s.scheduleConnect_(0),lh.getInstance().on("visible",s.onVisible_,s),-1===t.host.indexOf("fblocal")&&oo.getInstance().on("online",s.onOnline_,s),s}return it(u,n),u.prototype.sendRequest=function(n,t,r){var u=++this.requestNumber_,f={r:u,a:n,b:t};this.log_(a(f));i(this.connected_,"sendRequest call when we're not connected not allowed.");this.realtime_.sendRequest(f);r&&(this.requestCBHash_[u]=r)},u.prototype.listen=function(n,t,r,u){var e=n.queryIdentifier(),f=n.path.toString(),o;this.log_("Listen called for "+f+" "+e);this.listens_[f]=this.listens_[f]||{};i(n.getQueryParams().isDefault()||!n.getQueryParams().loadsAllData(),"listen() called for non-default but complete query");i(!this.listens_[f][e],"listen() called twice for same path/queryId.");o={onComplete:u,hashFn:t,query:n,tag:r};this.listens_[f][e]=o;this.connected_&&this.sendListen_(o)},u.prototype.sendListen_=function(n){var r=this,f=n.query,t=f.path.toString(),e=f.queryIdentifier(),i;this.log_("Listen on "+t+" for "+e);i={p:t};n.tag&&(i.q=f.queryObject(),i.t=n.tag);i.h=n.hashFn();this.sendRequest("q",i,function(i){var o=i.d,s=i.s;u.warnOnListenWarnings_(o,f);(r.listens_[t]&&r.listens_[t][e])===n&&(r.log_("listen response",i),"ok"!==s&&r.removeListen_(t,e),n.onComplete&&n.onComplete(s,o))})},u.warnOnListenWarnings_=function(n,t){var i,r,u;n&&"object"==typeof n&&d(n,"w")&&(i=p(n,"w"),Array.isArray(i)&&~i.indexOf("no_index")&&(r='".indexOn": "'+t.getQueryParams().getIndex().toString()+'"',u=t.path.toString(),b("Using an unspecified index. Your data will be downloaded and filtered on the client. Consider adding "+r+" at "+u+" to your security rules for better performance.")))},u.prototype.refreshAuthToken=function(n){this.authToken_=n;this.log_("Auth token refreshed");this.authToken_?this.tryAuth():this.connected_&&this.sendRequest("unauth",{},function(){});this.reduceReconnectDelayIfAdminCredential_(n)},u.prototype.reduceReconnectDelayIfAdminCredential_=function(n){var t;(n&&40===n.length||"object"==typeof(t=of(n).claims)&&!0===t.admin)&&(this.log_("Admin auth credential detected.  Reducing max reconnect time."),this.maxReconnectDelay_=3e4)},u.prototype.tryAuth=function(){var t,n,i=this;if(this.connected_&&this.authToken_){var r=this.authToken_,f=(t=of(r),n=t.claims,t.signature&&n&&"object"==typeof n&&n.hasOwnProperty("iat")?"auth":"gauth"),u={cred:r};null===this.authOverride_?u.noauth=!0:"object"==typeof this.authOverride_&&(u.authvar=this.authOverride_);this.sendRequest(f,u,function(n){var t=n.s,u=n.d||"error";i.authToken_===r&&("ok"===t?i.invalidAuthTokenCount_=0:i.onAuthRevoked_(t,u))})}},u.prototype.unlisten=function(n,t){var r=n.path.toString(),u=n.queryIdentifier();this.log_("Unlisten called for "+r+" "+u);i(n.getQueryParams().isDefault()||!n.getQueryParams().loadsAllData(),"unlisten() called for non-default but complete query");this.removeListen_(r,u)&&this.connected_&&this.sendUnlisten_(r,u,n.queryObject(),t)},u.prototype.sendUnlisten_=function(n,t,i,r){this.log_("Unlisten on "+n+" for "+t);var u={p:n};r&&(u.q=i,u.t=r);this.sendRequest("n",u)},u.prototype.onDisconnectPut=function(n,t,i){this.connected_?this.sendOnDisconnect_("o",n,t,i):this.onDisconnectRequestQueue_.push({pathString:n,action:"o",data:t,onComplete:i})},u.prototype.onDisconnectMerge=function(n,t,i){this.connected_?this.sendOnDisconnect_("om",n,t,i):this.onDisconnectRequestQueue_.push({pathString:n,action:"om",data:t,onComplete:i})},u.prototype.onDisconnectCancel=function(n,t){this.connected_?this.sendOnDisconnect_("oc",n,null,t):this.onDisconnectRequestQueue_.push({pathString:n,action:"oc",data:null,onComplete:t})},u.prototype.sendOnDisconnect_=function(n,t,i,r){var u={p:t,d:i};this.log_("onDisconnect "+n,u);this.sendRequest(n,u,function(n){r&&setTimeout(function(){r(n.s,n.d)},Math.floor(0))})},u.prototype.put=function(n,t,i,r){this.putInternal("p",n,t,i,r)},u.prototype.merge=function(n,t,i,r){this.putInternal("m",n,t,i,r)},u.prototype.putInternal=function(n,t,i,r,u){var f={p:t,d:i},e;void 0!==u&&(f.h=u);this.outstandingPuts_.push({action:n,request:f,onComplete:r});this.outstandingPutCount_++;e=this.outstandingPuts_.length-1;this.connected_?this.sendPut_(e):this.log_("Buffering put: "+t)},u.prototype.sendPut_=function(n){var t=this,i=this.outstandingPuts_[n].action,u=this.outstandingPuts_[n].request,r=this.outstandingPuts_[n].onComplete;this.outstandingPuts_[n].queued=this.connected_;this.sendRequest(i,u,function(u){t.log_(i+" response",u);delete t.outstandingPuts_[n];t.outstandingPutCount_--;0===t.outstandingPutCount_&&(t.outstandingPuts_=[]);r&&r(u.s,u.d)})},u.prototype.reportStats=function(n){var i=this,t;this.connected_&&(t={c:n},this.log_("reportStats",t),this.sendRequest("s",t,function(n){if("ok"!==n.s){var t=n.d;i.log_("reportStats","Error sending stats: "+t)}}))},u.prototype.onDataMessage_=function(n){if("r"in n){this.log_("from server: "+a(n));var t=n.r,i=this.requestCBHash_[t];i&&(delete this.requestCBHash_[t],i(n.b))}else{if("error"in n)throw"A server-side error has occurred: "+n.error;"a"in n&&this.onDataPush_(n.a,n.b)}},u.prototype.onDataPush_=function(n,t){this.log_("handleServerMessage",n,t);"d"===n?this.onDataUpdate_(t.p,t.d,!1,t.t):"m"===n?this.onDataUpdate_(t.p,t.d,!0,t.t):"c"===n?this.onListenRevoked_(t.p,t.q):"ac"===n?this.onAuthRevoked_(t.s,t.d):"sd"===n?this.onSecurityDebugPacket_(t):kr("Unrecognized action received from server: "+a(n)+"\nAre you using the latest client?")},u.prototype.onReady_=function(n,t){this.log_("connection ready");this.connected_=!0;this.lastConnectionEstablishedTime_=(new Date).getTime();this.handleTimestamp_(n);this.lastSessionId=t;this.firstConnection_&&this.sendConnectStats_();this.restoreState_();this.firstConnection_=!1;this.onConnectStatus_(!0)},u.prototype.scheduleConnect_=function(n){var t=this;i(!this.realtime_,"Scheduling a connect when we're already connected/ing?");this.establishConnectionTimer_&&clearTimeout(this.establishConnectionTimer_);this.establishConnectionTimer_=setTimeout(function(){t.establishConnectionTimer_=null;t.establishConnection_()},Math.floor(n))},u.prototype.onVisible_=function(n){n&&!this.visible_&&this.reconnectDelay_===this.maxReconnectDelay_&&(this.log_("Window became visible.  Reducing delay."),this.reconnectDelay_=ir,this.realtime_||this.scheduleConnect_(0));this.visible_=n},u.prototype.onOnline_=function(n){n?(this.log_("Browser went online."),this.reconnectDelay_=ir,this.realtime_||this.scheduleConnect_(0)):(this.log_("Browser went offline.  Killing connection."),this.realtime_&&this.realtime_.close())},u.prototype.onRealtimeDisconnect_=function(){if(this.log_("data client disconnected"),this.connected_=!1,this.realtime_=null,this.cancelSentTransactions_(),this.requestCBHash_={},this.shouldReconnect_()){this.visible_?this.lastConnectionEstablishedTime_&&((new Date).getTime()-this.lastConnectionEstablishedTime_>3e4&&(this.reconnectDelay_=ir),this.lastConnectionEstablishedTime_=null):(this.log_("Window isn't visible.  Delaying reconnect."),this.reconnectDelay_=this.maxReconnectDelay_,this.lastConnectionAttemptTime_=(new Date).getTime());var t=(new Date).getTime()-this.lastConnectionAttemptTime_,n=Math.max(0,this.reconnectDelay_-t);n=Math.random()*n;this.log_("Trying to reconnect in "+n+"ms");this.scheduleConnect_(n);this.reconnectDelay_=Math.min(this.maxReconnectDelay_,1.3*this.reconnectDelay_)}this.onConnectStatus_(!1)},u.prototype.establishConnection_=function(){var o;if(this.shouldReconnect_()){this.log_("Making a connection attempt");this.lastConnectionAttemptTime_=(new Date).getTime();this.lastConnectionEstablishedTime_=null;var s=this.onDataMessage_.bind(this),h=this.onReady_.bind(this),f=this.onRealtimeDisconnect_.bind(this),c=this.id+":"+u.nextConnectionId_++,n=this,l=this.lastSessionId,r=!1,t=null,e=function(){t?t.close():(r=!0,f())};this.realtime_={close:e,sendRequest:function(n){i(t,"sendRequest call when we're not connected not allowed.");t.sendRequest(n)}};o=this.forceTokenRefresh_;this.forceTokenRefresh_=!1;this.authTokenProvider_.getToken(o).then(function(i){r?w("getToken() completed but was canceled"):(w("getToken() completed. Creating connection."),n.authToken_=i&&i.accessToken,t=new so(c,n.repoInfo_,s,h,f,function(t){b(t+" ("+n.repoInfo_.toString()+")");n.interrupt("server_kill")},l))}).then(null,function(t){n.log_("Failed to get token: "+t);r||(pt.NODE_ADMIN&&b(t),e())})}},u.prototype.interrupt=function(n){w("Interrupting connection for reason: "+n);this.interruptReasons_[n]=!0;this.realtime_?this.realtime_.close():(this.establishConnectionTimer_&&(clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=null),this.connected_&&this.onRealtimeDisconnect_())},u.prototype.resume=function(n){w("Resuming connection for reason: "+n);delete this.interruptReasons_[n];li(this.interruptReasons_)&&(this.reconnectDelay_=ir,this.realtime_||this.scheduleConnect_(0))},u.prototype.handleTimestamp_=function(n){var t=n-(new Date).getTime();this.onServerInfoUpdate_({serverTimeOffset:t})},u.prototype.cancelSentTransactions_=function(){for(var n,t=0;t<this.outstandingPuts_.length;t++)n=this.outstandingPuts_[t],n&&"h"in n.request&&n.queued&&(n.onComplete&&n.onComplete("disconnect"),delete this.outstandingPuts_[t],this.outstandingPutCount_--);0===this.outstandingPutCount_&&(this.outstandingPuts_=[])},u.prototype.onListenRevoked_=function(n,t){var r,i;r=t?t.map(function(n){return dr(n)}).join("$"):"default";i=this.removeListen_(n,r);i&&i.onComplete&&i.onComplete("permission_denied")},u.prototype.removeListen_=function(n,t){var u,i=new r(n).toString();return void 0!==this.listens_[i]?(u=this.listens_[i][t],delete this.listens_[i][t],0===rr(this.listens_[i])&&delete this.listens_[i]):u=void 0,u},u.prototype.onAuthRevoked_=function(n,t){w("Auth token revoked: "+n+"/"+t);this.authToken_=null;this.forceTokenRefresh_=!0;this.realtime_.close();"invalid_token"!==n&&"permission_denied"!==n||(this.invalidAuthTokenCount_++,this.invalidAuthTokenCount_>=3&&(this.reconnectDelay_=3e4,this.authTokenProvider_.notifyForInvalidToken()))},u.prototype.onSecurityDebugPacket_=function(n){this.securityDebugCallback_?this.securityDebugCallback_(n):"msg"in n&&console.log("FIREBASE: "+n.msg.replace("\n","\nFIREBASE: "))},u.prototype.restoreState_=function(){var i=this,n,t;for(this.tryAuth(),s(this.listens_,function(n,t){s(t,function(n,t){i.sendListen_(t)})}),n=0;n<this.outstandingPuts_.length;n++)this.outstandingPuts_[n]&&this.sendPut_(n);for(;this.onDisconnectRequestQueue_.length;)t=this.onDisconnectRequestQueue_.shift(),this.sendOnDisconnect_(t.action,t.pathString,t.data,t.onComplete)},u.prototype.sendConnectStats_=function(){var n={},i="js";pt.NODE_ADMIN?i="admin_node":pt.NODE_CLIENT&&(i="node");n["sdk."+i+"."+t.SDK_VERSION.replace(/\./g,"-")]=1;rf()?n["framework.cordova"]=1:"object"==typeof navigator&&"ReactNative"===navigator.product&&(n["framework.reactnative"]=1);this.reportStats(n)},u.prototype.shouldReconnect_=function(){var n=oo.getInstance().currentlyOnline();return li(this.interruptReasons_)&&n},u.nextPersistentConnectionId_=0,u.nextConnectionId_=0,u}(ho),kh=function(n){function t(t,i,r){var u=n.call(this)||this;return u.repoInfo_=t,u.onDataUpdate_=i,u.authTokenProvider_=r,u.log_=yi("p:rest:"),u.listens_={},u}return it(t,n),t.prototype.reportStats=function(){throw new Error("Method not implemented.");},t.getListenId_=function(n,t){return void 0!==t?"tag$"+t:(i(n.getQueryParams().isDefault(),"should have a tag if it's not a default query."),n.path.toString())},t.prototype.listen=function(n,i,r,u){var s=this,f=n.path.toString(),e,o,h;this.log_("Listen called for "+f+" "+n.queryIdentifier());e=t.getListenId_(n,r);o={};this.listens_[e]=o;h=n.getQueryParams().toRestQueryStringParameters();this.restRequest_(f+".json",h,function(n,t){var i=t;(404===n&&(i=null,n=null),null===n&&s.onDataUpdate_(f,i,!1,r),p(s.listens_,e)===o)&&u(n?401==n?"permission_denied":"rest_error:"+n:"ok",null)})},t.prototype.unlisten=function(n,i){var r=t.getListenId_(n,i);delete this.listens_[r]},t.prototype.refreshAuthToken=function(){},t.prototype.restRequest_=function(n,t,i){var r=this;void 0===t&&(t={});t.format="export";this.authTokenProvider_.getToken(!1).then(function(u){var h=u&&u.accessToken,o,e,f;h&&(t.auth=h);e=(r.repoInfo_.secure?"https://":"http://")+r.repoInfo_.host+n+"?"+(o=[],s(t,function(n,t){Array.isArray(t)?t.forEach(function(t){o.push(encodeURIComponent(n)+"="+encodeURIComponent(t))}):o.push(encodeURIComponent(n)+"="+encodeURIComponent(t))}),o.length?"&"+o.join("&"):"");r.log_("Sending REST request for "+e);f=new XMLHttpRequest;f.onreadystatechange=function(){if(i&&4===f.readyState){r.log_("REST Response for "+e+" received. status:",f.status,"response:",f.responseText);var n=null;if(f.status>=200&&f.status<300){try{n=ci(f.responseText)}catch(n){b("Failed to parse JSON response for "+e+": "+f.responseText)}i(null,n)}else 401!==f.status&&404!==f.status&&b("Got unsuccessful REST response for "+e+" Status: "+f.status),i(f.status);i=null}};f.open("GET",e,!0);f.send()})},t}(ho),y=function(){function n(n,t,i){var r=this,f,u;if(this.repoInfo_=n,this.app=i,this.dataUpdateCount=0,this.statsListener_=null,this.eventQueue_=new hh,this.nextWriteId_=1,this.interceptServerDataCallback_=null,this.onDisconnect_=new su,this.persistentConnection_=null,f=new fh(i),this.stats_=yr.getCollection(n),t||us())this.server_=new kh(this.repoInfo_,this.onDataUpdate_.bind(this),f),setTimeout(this.onConnectStatus_.bind(this,!0),0);else{if(u=i.options.databaseAuthVariableOverride,void 0!==u&&null!==u){if("object"!=typeof u)throw new Error("Only objects are supported for option databaseAuthVariableOverride");try{a(u)}catch(n){throw new Error("Invalid authOverride provided: "+n);}}this.persistentConnection_=new ti(this.repoInfo_,this.onDataUpdate_.bind(this),this.onConnectStatus_.bind(this),this.onServerInfoUpdate_.bind(this),f,u);this.server_=this.persistentConnection_}f.addTokenChangeListener(function(n){r.server_.refreshAuthToken(n)});this.statsReporter_=yr.getOrCreateReporter(n,function(){return new sh(r.stats_,r.server_)});this.transactions_init_();this.infoData_=new uh;this.infoSyncTree_=new ro({startListening:function(n,t,i,u){var f=[],e=r.infoData_.getNode(n.path);return e.isEmpty()||(f=r.infoSyncTree_.applyServerOverwrite(n.path,e),setTimeout(function(){u("ok")},0)),f},stopListening:function(){}});this.updateInfo_("connected",!1);this.serverSyncTree_=new ro({startListening:function(n,t,i,u){return r.server_.listen(n,i,t,function(t,i){var f=u(t,i);r.eventQueue_.raiseEventsForChangedPath(n.path,f)}),[]},stopListening:function(n,t){r.server_.unlisten(n,t)}})}return n.prototype.toString=function(){return(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host},n.prototype.name=function(){return this.repoInfo_.namespace},n.prototype.serverTime=function(){var n=this.infoData_.getNode(new r(".info/serverTimeOffset")).val()||0;return(new Date).getTime()+n},n.prototype.generateServerValues=function(){return(n=(n={timestamp:this.serverTime()})||{}).timestamp=n.timestamp||(new Date).getTime(),n;var n},n.prototype.onDataUpdate_=function(n,t,i,u){var f,e,s,h,l,a,o;this.dataUpdateCount++;f=new r(n);t=this.interceptServerDataCallback_?this.interceptServerDataCallback_(n,t):t;e=[];u?i?(s=ur(t,function(n){return c(n)}),e=this.serverSyncTree_.applyTaggedQueryMerge(f,s,u)):(h=c(t),e=this.serverSyncTree_.applyTaggedQueryOverwrite(f,h,u)):i?(l=ur(t,function(n){return c(n)}),e=this.serverSyncTree_.applyServerMerge(f,l)):(a=c(t),e=this.serverSyncTree_.applyServerOverwrite(f,a));o=f;e.length>0&&(o=this.rerunTransactions_(f));this.eventQueue_.raiseEventsForChangedPath(o,e)},n.prototype.interceptServerData_=function(n){this.interceptServerDataCallback_=n},n.prototype.onConnectStatus_=function(n){this.updateInfo_("connected",n);!1===n&&this.runOnDisconnectEvents_()},n.prototype.onServerInfoUpdate_=function(n){var t=this;bf(n,function(n,i){t.updateInfo_(i,n)})},n.prototype.updateInfo_=function(n,t){var i=new r("/.info/"+n),u=c(t),f;this.infoData_.updateSnapshot(i,u);f=this.infoSyncTree_.applyServerOverwrite(i,u);this.eventQueue_.raiseEventsForChangedPath(i,f)},n.prototype.getNextWriteId_=function(){return this.nextWriteId_++},n.prototype.setWithPriority=function(n,t,i,r){var u=this,f;this.log_("set",{path:n.toString(),value:t,priority:i});var s=this.generateServerValues(),e=c(t,i),h=oi(e,s),o=this.getNextWriteId_(),l=this.serverSyncTree_.applyUserOverwrite(n,h,o,!0);this.eventQueue_.queueEvents(l);this.server_.put(n.toString(),e.val(!0),function(t,i){var f="ok"===t,e;f||b("set at "+n+" failed: "+t);e=u.serverSyncTree_.ackUserWrite(o,!f);u.eventQueue_.raiseEventsForChangedPath(n,e);u.callOnCompleteCallback(r,t,i)});f=this.abortTransactions_(n);this.rerunTransactions_(f);this.eventQueue_.raiseEventsForChangedPath(f,[])},n.prototype.update=function(n,t,i){var r=this,u,o;this.log_("update",{path:n.toString(),value:t});var f=!0,h=this.generateServerValues(),e={};(s(t,function(n,t){f=!1;var i=c(t);e[n]=oi(i,h)}),f)?(w("update() called with empty data.  Don't do anything."),this.callOnCompleteCallback(i,"ok")):(u=this.getNextWriteId_(),o=this.serverSyncTree_.applyUserMerge(n,e,u),this.eventQueue_.queueEvents(o),this.server_.merge(n.toString(),t,function(t,f){var o="ok"===t,e,s;o||b("update at "+n+" failed: "+t);e=r.serverSyncTree_.ackUserWrite(u,!o);s=e.length>0?r.rerunTransactions_(n):n;r.eventQueue_.raiseEventsForChangedPath(s,e);r.callOnCompleteCallback(i,t,f)}),s(t,function(t){var i=r.abortTransactions_(n.child(t));r.rerunTransactions_(i)}),this.eventQueue_.raiseEventsForChangedPath(n,[]))},n.prototype.runOnDisconnectEvents_=function(){var t=this,i,n;this.log_("onDisconnectEvents");i=this.generateServerValues();n=[],function(n,t){var i=new su;return n.forEachTree(new r(""),function(n,r){i.remember(n,oi(r,t))}),i}(this.onDisconnect_,i).forEachTree(r.Empty,function(i,r){n=n.concat(t.serverSyncTree_.applyServerOverwrite(i,r));var u=t.abortTransactions_(i);t.rerunTransactions_(u)});this.onDisconnect_=new su;this.eventQueue_.raiseEventsForChangedPath(r.Empty,n)},n.prototype.onDisconnectCancel=function(n,t){var i=this;this.server_.onDisconnectCancel(n.toString(),function(r,u){"ok"===r&&i.onDisconnect_.forget(n);i.callOnCompleteCallback(t,r,u)})},n.prototype.onDisconnectSet=function(n,t,i){var r=this,u=c(t);this.server_.onDisconnectPut(n.toString(),u.val(!0),function(t,f){"ok"===t&&r.onDisconnect_.remember(n,u);r.callOnCompleteCallback(i,t,f)})},n.prototype.onDisconnectSetWithPriority=function(n,t,i,r){var u=this,f=c(t,i);this.server_.onDisconnectPut(n.toString(),f.val(!0),function(t,i){"ok"===t&&u.onDisconnect_.remember(n,f);u.callOnCompleteCallback(r,t,i)})},n.prototype.onDisconnectUpdate=function(n,t,i){var r=this;if(li(t))return w("onDisconnect().update() called with empty data.  Don't do anything."),void this.callOnCompleteCallback(i,"ok");this.server_.onDisconnectMerge(n.toString(),t,function(u,f){"ok"===u&&s(t,function(t,i){var u=c(i);r.onDisconnect_.remember(n.child(t),u)});r.callOnCompleteCallback(i,u,f)})},n.prototype.addEventCallbackForQuery=function(n,t){var i;i=".info"===n.path.getFront()?this.infoSyncTree_.addEventRegistration(n,t):this.serverSyncTree_.addEventRegistration(n,t);this.eventQueue_.raiseEventsAtPath(n.path,i)},n.prototype.removeEventCallbackForQuery=function(n,t){var i;i=".info"===n.path.getFront()?this.infoSyncTree_.removeEventRegistration(n,t):this.serverSyncTree_.removeEventRegistration(n,t);this.eventQueue_.raiseEventsAtPath(n.path,i)},n.prototype.interrupt=function(){this.persistentConnection_&&this.persistentConnection_.interrupt("repo_interrupt")},n.prototype.resume=function(){this.persistentConnection_&&this.persistentConnection_.resume("repo_interrupt")},n.prototype.stats=function(n){var t,i;(void 0===n&&(n=!1),"undefined"!=typeof console)&&(n?(this.statsListener_||(this.statsListener_=new uo(this.stats_)),t=this.statsListener_.get()):t=this.stats_.get(),i=Object.keys(t).reduce(function(n,t){return Math.max(t.length,n)},0),s(t,function(n,t){for(var r=n.length;r<i+2;r++)n+=" ";console.log(n+t)}))},n.prototype.statsIncrementCounter=function(n){this.stats_.incrementCounter(n);this.statsReporter_.includeStat(n)},n.prototype.log_=function(){for(var i,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];i="";this.persistentConnection_&&(i=this.persistentConnection_.id+":");w.apply(void 0,[i].concat(t))},n.prototype.callOnCompleteCallback=function(n,t,i){n&&ui(function(){var r,u,f;"ok"==t?n(null):(r=(t||"error").toUpperCase(),u=r,i&&(u+=": "+i),f=new Error(u),f.code=r,n(f))})},Object.defineProperty(n.prototype,"database",{get:function(){return this.__database||(this.__database=new bu(this))},enumerable:!0,configurable:!0}),n}(),co=function(){function n(t){this.indexedFilter_=new lu(t.getIndex());this.index_=t.getIndex();this.startPost_=n.getStartPost_(t);this.endPost_=n.getEndPost_(t)}return n.prototype.getStartPost=function(){return this.startPost_},n.prototype.getEndPost=function(){return this.endPost_},n.prototype.matches=function(n){return this.index_.compare(this.getStartPost(),n)<=0&&this.index_.compare(n,this.getEndPost())<=0},n.prototype.updateChild=function(n,t,i,r,u,e){return this.matches(new o(t,i))||(i=f.EMPTY_NODE),this.indexedFilter_.updateChild(n,t,i,r,u,e)},n.prototype.updateFullNode=function(n,t,i){var r,u;return t.isLeafNode()&&(t=f.EMPTY_NODE),r=t.withIndex(this.index_),r=r.updatePriority(f.EMPTY_NODE),u=this,t.forEachChild(h,function(n,t){u.matches(new o(n,t))||(r=r.updateImmediateChild(n,f.EMPTY_NODE))}),this.indexedFilter_.updateFullNode(n,r,i)},n.prototype.updatePriority=function(n){return n},n.prototype.filtersNodes=function(){return!0},n.prototype.getIndexedFilter=function(){return this.indexedFilter_},n.prototype.getIndex=function(){return this.index_},n.getStartPost_=function(n){if(n.hasStart()){var t=n.getIndexStartName();return n.getIndex().makePost(n.getIndexStartValue(),t)}return n.getIndex().minPost()},n.getEndPost_=function(n){if(n.hasEnd()){var t=n.getIndexEndName();return n.getIndex().makePost(n.getIndexEndValue(),t)}return n.getIndex().maxPost()},n}(),dh=function(){function n(n){this.rangedFilter_=new co(n);this.index_=n.getIndex();this.limit_=n.getLimit();this.reverse_=!n.isViewFromLeft()}return n.prototype.updateChild=function(n,t,i,r,u,e){return this.rangedFilter_.matches(new o(t,i))||(i=f.EMPTY_NODE),n.getImmediateChild(t).equals(i)?n:n.numChildren()<this.limit_?this.rangedFilter_.getIndexedFilter().updateChild(n,t,i,r,u,e):this.fullLimitUpdateChild_(n,t,i,u,e)},n.prototype.updateFullNode=function(n,t,i){var r,u,o,e,a,h;if(t.isLeafNode()||t.isEmpty())r=f.EMPTY_NODE.withIndex(this.index_);else if(2*this.limit_<t.numChildren()&&t.isIndexed(this.index_))for(r=f.EMPTY_NODE.withIndex(this.index_),u=void 0,u=this.reverse_?t.getReverseIteratorFrom(this.rangedFilter_.getEndPost(),this.index_):t.getIteratorFrom(this.rangedFilter_.getStartPost(),this.index_),o=0;u.hasNext()&&o<this.limit_;){if(e=u.getNext(),!(this.reverse_?this.index_.compare(this.rangedFilter_.getStartPost(),e)<=0:this.index_.compare(e,this.rangedFilter_.getEndPost())<=0))break;r=r.updateImmediateChild(e.name,e.node);o++}else{r=(r=t.withIndex(this.index_)).updatePriority(f.EMPTY_NODE);var c=void 0,l=void 0,s=void 0;for(u=void 0,this.reverse_?(u=r.getReverseIterator(this.index_),c=this.rangedFilter_.getEndPost(),l=this.rangedFilter_.getStartPost(),a=this.index_.getCompare(),s=function(n,t){return a(t,n)}):(u=r.getIterator(this.index_),c=this.rangedFilter_.getStartPost(),l=this.rangedFilter_.getEndPost(),s=this.index_.getCompare()),o=0,h=!1;u.hasNext();)e=u.getNext(),!h&&s(c,e)<=0&&(h=!0),h&&o<this.limit_&&s(e,l)<=0?o++:r=r.updateImmediateChild(e.name,f.EMPTY_NODE)}return this.rangedFilter_.getIndexedFilter().updateFullNode(n,r,i)},n.prototype.updatePriority=function(n){return n},n.prototype.filtersNodes=function(){return!0},n.prototype.getIndexedFilter=function(){return this.rangedFilter_.getIndexedFilter()},n.prototype.getIndex=function(){return this.index_},n.prototype.fullLimitUpdateChild_=function(n,t,r,u,s){var a,w,c,y,h,k,p;this.reverse_?(w=this.index_.getCompare(),a=function(n,t){return w(t,n)}):a=this.index_.getCompare();c=n;i(c.numChildren()==this.limit_,"");var v=new o(t,r),l=this.reverse_?c.getFirstChild(this.index_):c.getLastChild(this.index_),b=this.rangedFilter_.matches(v);if(c.hasChild(t)){for(y=c.getImmediateChild(t),h=u.getChildAfterChild(this.index_,l,this.reverse_);null!=h&&(h.name==t||c.hasChild(h.name));)h=u.getChildAfterChild(this.index_,h,this.reverse_);return(k=null==h?1:a(h,v),b&&!r.isEmpty()&&k>=0)?(null!=s&&s.trackChildChange(e.childChangedChange(t,r,y)),c.updateImmediateChild(t,r)):(null!=s&&s.trackChildChange(e.childRemovedChange(t,y)),p=c.updateImmediateChild(t,f.EMPTY_NODE),null!=h&&this.rangedFilter_.matches(h)?(null!=s&&s.trackChildChange(e.childAddedChange(h.name,h.node)),p.updateImmediateChild(h.name,h.node)):p)}return r.isEmpty()?n:b&&a(l,v)>=0?(null!=s&&(s.trackChildChange(e.childRemovedChange(l.name,l.node)),s.trackChildChange(e.childAddedChange(t,r))),c.updateImmediateChild(t,r).updateImmediateChild(l.name,f.EMPTY_NODE)):n},n}(),gh=function(){function n(){this.limitSet_=!1;this.startSet_=!1;this.startNameSet_=!1;this.endSet_=!1;this.endNameSet_=!1;this.limit_=0;this.viewFrom_="";this.indexStartValue_=null;this.indexStartName_="";this.indexEndValue_=null;this.indexEndName_="";this.index_=h}return n.prototype.hasStart=function(){return this.startSet_},n.prototype.isViewFromLeft=function(){return""===this.viewFrom_?this.startSet_:this.viewFrom_===n.WIRE_PROTOCOL_CONSTANTS_.VIEW_FROM_LEFT},n.prototype.getIndexStartValue=function(){return i(this.startSet_,"Only valid if start has been set"),this.indexStartValue_},n.prototype.getIndexStartName=function(){return i(this.startSet_,"Only valid if start has been set"),this.startNameSet_?this.indexStartName_:kt},n.prototype.hasEnd=function(){return this.endSet_},n.prototype.getIndexEndValue=function(){return i(this.endSet_,"Only valid if end has been set"),this.indexEndValue_},n.prototype.getIndexEndName=function(){return i(this.endSet_,"Only valid if end has been set"),this.endNameSet_?this.indexEndName_:lt},n.prototype.hasLimit=function(){return this.limitSet_},n.prototype.hasAnchoredLimit=function(){return this.limitSet_&&""!==this.viewFrom_},n.prototype.getLimit=function(){return i(this.limitSet_,"Only valid if limit has been set"),this.limit_},n.prototype.getIndex=function(){return this.index_},n.prototype.copy_=function(){var t=new n;return t.limitSet_=this.limitSet_,t.limit_=this.limit_,t.startSet_=this.startSet_,t.indexStartValue_=this.indexStartValue_,t.startNameSet_=this.startNameSet_,t.indexStartName_=this.indexStartName_,t.endSet_=this.endSet_,t.indexEndValue_=this.indexEndValue_,t.endNameSet_=this.endNameSet_,t.indexEndName_=this.indexEndName_,t.index_=this.index_,t.viewFrom_=this.viewFrom_,t},n.prototype.limit=function(n){var t=this.copy_();return t.limitSet_=!0,t.limit_=n,t.viewFrom_="",t},n.prototype.limitToFirst=function(t){var i=this.copy_();return i.limitSet_=!0,i.limit_=t,i.viewFrom_=n.WIRE_PROTOCOL_CONSTANTS_.VIEW_FROM_LEFT,i},n.prototype.limitToLast=function(t){var i=this.copy_();return i.limitSet_=!0,i.limit_=t,i.viewFrom_=n.WIRE_PROTOCOL_CONSTANTS_.VIEW_FROM_RIGHT,i},n.prototype.startAt=function(n,t){var i=this.copy_();return i.startSet_=!0,void 0===n&&(n=null),i.indexStartValue_=n,null!=t?(i.startNameSet_=!0,i.indexStartName_=t):(i.startNameSet_=!1,i.indexStartName_=""),i},n.prototype.endAt=function(n,t){var i=this.copy_();return i.endSet_=!0,void 0===n&&(n=null),i.indexEndValue_=n,void 0!==t?(i.endNameSet_=!0,i.indexEndName_=t):(i.endNameSet_=!1,i.indexEndName_=""),i},n.prototype.orderBy=function(n){var t=this.copy_();return t.index_=n,t},n.prototype.getQueryObject=function(){var t=n.WIRE_PROTOCOL_CONSTANTS_,i={},r;return(this.startSet_&&(i[t.INDEX_START_VALUE]=this.indexStartValue_,this.startNameSet_&&(i[t.INDEX_START_NAME]=this.indexStartName_)),this.endSet_&&(i[t.INDEX_END_VALUE]=this.indexEndValue_,this.endNameSet_&&(i[t.INDEX_END_NAME]=this.indexEndName_)),this.limitSet_)&&(i[t.LIMIT]=this.limit_,r=this.viewFrom_,""===r&&(r=this.isViewFromLeft()?t.VIEW_FROM_LEFT:t.VIEW_FROM_RIGHT),i[t.VIEW_FROM]=r),this.index_!==h&&(i[t.INDEX]=this.index_.toString()),i},n.prototype.loadsAllData=function(){return!(this.startSet_||this.endSet_||this.limitSet_)},n.prototype.isDefault=function(){return this.loadsAllData()&&this.index_==h},n.prototype.getNodeFilter=function(){return this.loadsAllData()?new lu(this.getIndex()):this.hasLimit()?new dh(this):new co(this)},n.prototype.toRestQueryStringParameters=function(){var u,t=n.REST_QUERY_CONSTANTS_,r={};return this.isDefault()?r:(this.index_===h?u=t.PRIORITY_INDEX:this.index_===fu?u=t.VALUE_INDEX:this.index_===vt?u=t.KEY_INDEX:(i(this.index_ instanceof eu,"Unrecognized index type!"),u=this.index_.toString()),r[t.ORDER_BY]=a(u),this.startSet_&&(r[t.START_AT]=a(this.indexStartValue_),this.startNameSet_&&(r[t.START_AT]+=","+a(this.indexStartName_))),this.endSet_&&(r[t.END_AT]=a(this.indexEndValue_),this.endNameSet_&&(r[t.END_AT]+=","+a(this.indexEndName_))),this.limitSet_&&(this.isViewFromLeft()?r[t.LIMIT_TO_FIRST]=this.limit_:r[t.LIMIT_TO_LAST]=this.limit_),r)},n.WIRE_PROTOCOL_CONSTANTS_={INDEX_START_VALUE:"sp",INDEX_START_NAME:"sn",INDEX_END_VALUE:"ep",INDEX_END_NAME:"en",LIMIT:"l",VIEW_FROM:"vf",VIEW_FROM_LEFT:"l",VIEW_FROM_RIGHT:"r",INDEX:"i"},n.REST_QUERY_CONSTANTS_={ORDER_BY:"orderBy",PRIORITY_INDEX:"$priority",VALUE_INDEX:"$value",KEY_INDEX:"$key",START_AT:"startAt",END_AT:"endAt",LIMIT_TO_FIRST:"limitToFirst",LIMIT_TO_LAST:"limitToLast"},n.DEFAULT=new n,n}(),ct=function(n){function t(t,i){if(!(t instanceof y))throw new Error("new Reference() no longer supported - use app.database().");return n.call(this,t,i,gh.DEFAULT,!1)||this}return it(t,n),t.prototype.getKey=function(){return u("Reference.key",0,0,arguments.length),this.path.isEmpty()?null:this.path.getBack()},t.prototype.child=function(n){return u("Reference.child",1,1,arguments.length),"number"==typeof n?n=String(n):n instanceof r||(null===this.path.getFront()?function(n,t,i,r){i&&(i=i.replace(/^\/*\.info(\/|$)/,"/"));di(n,t,i,r)}("Reference.child",1,n,!1):di("Reference.child",1,n,!1)),new t(this.repo,this.path.child(n))},t.prototype.getParent=function(){u("Reference.parent",0,0,arguments.length);var n=this.path.parent();return null===n?null:new t(this.repo,n)},t.prototype.getRoot=function(){u("Reference.root",0,0,arguments.length);for(var n=this;null!==n.getParent();)n=n.getParent();return n},t.prototype.databaseProp=function(){return this.repo.database},t.prototype.set=function(n,t){u("Reference.set",1,2,arguments.length);tt("Reference.set",this.path);at("Reference.set",1,n,this.path,!1);v("Reference.set",2,t,!0);var i=new rt;return this.repo.setWithPriority(this.path,n,null,i.wrapCallback(t)),i.promise},t.prototype.update=function(n,t){var r,i,f;if(u("Reference.update",1,2,arguments.length),tt("Reference.update",this.path),Array.isArray(n)){for(r={},i=0;i<n.length;++i)r[""+i]=n[i];n=r;b("Passing an Array to Firebase.update() is deprecated. Use set() if you want to overwrite the existing data, or an Object with integer keys if you really do want to only update some of the children.")}return re("Reference.update",1,n,this.path,!1),v("Reference.update",2,t,!0),f=new rt,this.repo.update(this.path,n,f.wrapCallback(t)),f.promise},t.prototype.setWithPriority=function(n,t,i){if(u("Reference.setWithPriority",2,3,arguments.length),tt("Reference.setWithPriority",this.path),at("Reference.setWithPriority",1,n,this.path,!1),nu("Reference.setWithPriority",2,t,!1),v("Reference.setWithPriority",3,i,!0),".length"===this.getKey()||".keys"===this.getKey())throw"Reference.setWithPriority failed: "+this.getKey()+" is a read-only object.";var r=new rt;return this.repo.setWithPriority(this.path,n,t,r.wrapCallback(i)),r.promise},t.prototype.remove=function(n){return u("Reference.remove",0,1,arguments.length),tt("Reference.remove",this.path),v("Reference.remove",1,n,!0),this.set(null,n)},t.prototype.transaction=function(n,t,i){if(u("Reference.transaction",1,3,arguments.length),tt("Reference.transaction",this.path),v("Reference.transaction",1,n,!1),v("Reference.transaction",2,t,!0),function(n,t,i,r){if((!r||void 0!==i)&&"boolean"!=typeof i)throw new Error(nt(n,t,r)+"must be a boolean.");}("Reference.transaction",3,i,!0),".length"===this.getKey()||".keys"===this.getKey())throw"Reference.transaction failed: "+this.getKey()+" is a read-only object.";void 0===i&&(i=!0);var r=new rt;return"function"==typeof t&&r.promise.catch(function(){}),this.repo.startTransaction(this.path,n,function(n,i,u){n?r.reject(n):r.resolve(new cs(i,u));"function"==typeof t&&t(n,i,u)},i),r.promise},t.prototype.setPriority=function(n,t){u("Reference.setPriority",1,2,arguments.length);tt("Reference.setPriority",this.path);nu("Reference.setPriority",1,n,!1);v("Reference.setPriority",2,t,!0);var i=new rt;return this.repo.setWithPriority(this.path.child(".priority"),n,null,i.wrapCallback(t)),i.promise},t.prototype.push=function(n,t){u("Reference.push",0,2,arguments.length);tt("Reference.push",this.path);at("Reference.push",1,n,this.path,!0);v("Reference.push",2,t,!0);var i,o=this.repo.serverTime(),f=ls(o),r=this.child(f),e=this.child(f);return i=null!=n?r.set(n,t).then(function(){return e}):Promise.resolve(e),r.then=i.then.bind(i),r.catch=i.then.bind(i,void 0),"function"==typeof t&&i.catch(function(){}),r},t.prototype.onDisconnect=function(){return tt("Reference.onDisconnect",this.path),new hs(this.repo,this.path)},Object.defineProperty(t.prototype,"database",{get:function(){return this.databaseProp()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"key",{get:function(){return this.getKey()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"parent",{get:function(){return this.getParent()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"root",{get:function(){return this.getRoot()},enumerable:!0,configurable:!0}),t}(ou);ou.__referenceConstructor=ct;to.__referenceConstructor=ct;yu=function(){return function(){this.children={};this.childCount=0;this.value=null}}();lo=function(){function n(n,t,i){void 0===n&&(n="");void 0===t&&(t=null);void 0===i&&(i=new yu);this.name_=n;this.parent_=t;this.node_=i}return n.prototype.subTree=function(t){for(var u,f=t instanceof r?t:new r(t),i=this;null!==(u=f.getFront());)i=new n(u,i,p(i.node_.children,u)||new yu),f=f.popFront();return i},n.prototype.getValue=function(){return this.node_.value},n.prototype.setValue=function(n){i(void 0!==n,"Cannot set value to undefined");this.node_.value=n;this.updateParents_()},n.prototype.clear=function(){this.node_.value=null;this.node_.children={};this.node_.childCount=0;this.updateParents_()},n.prototype.hasChildren=function(){return this.node_.childCount>0},n.prototype.isEmpty=function(){return null===this.getValue()&&!this.hasChildren()},n.prototype.forEachChild=function(t){var i=this;s(this.node_.children,function(r,u){t(new n(r,i,u))})},n.prototype.forEachDescendant=function(n,t,i){t&&!i&&n(this);this.forEachChild(function(t){t.forEachDescendant(n,!0,i)});t&&i&&n(this)},n.prototype.forEachAncestor=function(n,t){for(var i=t?this:this.parent();null!==i;){if(n(i))return!0;i=i.parent()}return!1},n.prototype.forEachImmediateDescendantWithValue=function(n){this.forEachChild(function(t){null!==t.getValue()?n(t):t.forEachImmediateDescendantWithValue(n)})},n.prototype.path=function(){return new r(null===this.parent_?this.name_:this.parent_.path()+"/"+this.name_)},n.prototype.name=function(){return this.name_},n.prototype.parent=function(){return this.parent_},n.prototype.updateParents_=function(){null!==this.parent_&&this.parent_.updateChild_(this.name_,this)},n.prototype.updateChild_=function(n,t){var i=t.isEmpty(),r=d(this.node_.children,n);i&&r?(delete this.node_.children[n],this.node_.childCount--,this.updateParents_()):i||r||(this.node_.children[n]=t.node_,this.node_.childCount++,this.updateParents_())},n}();!function(n){n[n.RUN=0]="RUN";n[n.SENT=1]="SENT";n[n.COMPLETED=2]="COMPLETED";n[n.SENT_NEEDS_ABORT=3]="SENT_NEEDS_ABORT";n[n.NEEDS_ABORT=4]="NEEDS_ABORT"}(l||(l={}));y.MAX_TRANSACTION_RETRIES_=25;y.prototype.transactions_init_=function(){this.transactionQueueTree_=new lo};y.prototype.startTransaction=function(n,t,r,u){var a,v,e,y,o,k,w,b,s,tt;this.log_("transaction on "+n);a=function(){};v=new ct(this,n);v.on("value",a);if(e={path:n,update:t,onComplete:r,status:null,order:af(),applyLocally:u,retryCount:0,unwatcher:function(){v.off("value",a)},abortReason:null,currentWriteId:null,currentInputSnapshot:null,currentOutputSnapshotRaw:null,currentOutputSnapshotResolved:null},y=this.getLatestState_(n),e.currentInputSnapshot=y,o=e.update(y.val()),void 0===o){if(e.unwatcher(),e.currentOutputSnapshotRaw=null,e.currentOutputSnapshotResolved=null,e.onComplete){k=new nr(e.currentInputSnapshot,new ct(this,e.path),h);e.onComplete(null,!1,k)}}else{ki("transaction failed: Data returned ",o,e.path);e.status=l.RUN;w=this.transactionQueueTree_.subTree(n);b=w.getValue()||[];b.push(e);w.setValue(b);s=void 0;"object"==typeof o&&null!==o&&d(o,".priority")?(s=p(o,".priority"),i(bi(s),"Invalid priority returned by transaction. Priority must be a valid string, finite number, server value, or null.")):s=(this.serverSyncTree_.calcCompleteEventCache(n)||f.EMPTY_NODE).getPriority().val();s=s;var it=this.generateServerValues(),g=c(o,s),nt=oi(g,it);e.currentOutputSnapshotRaw=g;e.currentOutputSnapshotResolved=nt;e.currentWriteId=this.getNextWriteId_();tt=this.serverSyncTree_.applyUserOverwrite(n,nt,e.currentWriteId,e.applyLocally);this.eventQueue_.raiseEventsForChangedPath(n,tt);this.sendReadyTransactions_()}};y.prototype.getLatestState_=function(n,t){return this.serverSyncTree_.calcCompleteEventCache(n,t)||f.EMPTY_NODE};y.prototype.sendReadyTransactions_=function(n){var r=this,t;(void 0===n&&(n=this.transactionQueueTree_),n||this.pruneCompletedTransactionsBelowNode_(n),null!==n.getValue())?(t=this.buildTransactionQueue_(n),i(t.length>0,"Sending zero length transaction queue"),t.every(function(n){return n.status===l.RUN})&&this.sendTransactionQueue_(n.path(),t)):n.hasChildren()&&n.forEachChild(function(n){r.sendReadyTransactions_(n)})};y.prototype.sendTransactionQueue_=function(n,t){for(var f,a,v,e,u=this,y=t.map(function(n){return n.currentWriteId}),c=this.getLatestState_(n,y),o=c,p=c.hash(),s=0;s<t.length;s++)f=t[s],i(f.status===l.RUN,"tryToSendTransactionQueue_: items in queue should all be run."),f.status=l.SENT,f.retryCount++,a=r.relativePath(n,f.path),o=o.updateChild(a,f.currentOutputSnapshotRaw);v=o.val(!0);e=n;this.server_.put(e.toString(),v,function(i){var f,o,r;if(u.log_("transaction put response",{path:e.toString(),status:i}),f=[],"ok"===i){for(o=[],r=0;r<t.length;r++){if(t[r].status=l.COMPLETED,f=f.concat(u.serverSyncTree_.ackUserWrite(t[r].currentWriteId)),t[r].onComplete){var s=t[r].currentOutputSnapshotResolved,c=new ct(u,t[r].path),a=new nr(s,c,h);o.push(t[r].onComplete.bind(null,null,!0,a))}t[r].unwatcher()}for(u.pruneCompletedTransactionsBelowNode_(u.transactionQueueTree_.subTree(n)),u.sendReadyTransactions_(),u.eventQueue_.raiseEventsForChangedPath(n,f),r=0;r<o.length;r++)ui(o[r])}else{if("datastale"===i)for(r=0;r<t.length;r++)t[r].status=t[r].status===l.SENT_NEEDS_ABORT?l.NEEDS_ABORT:l.RUN;else for(b("transaction at "+e.toString()+" failed: "+i),r=0;r<t.length;r++)t[r].status=l.NEEDS_ABORT,t[r].abortReason=i;u.rerunTransactions_(n)}},p)};y.prototype.rerunTransactions_=function(n){var t=this.getAncestorTransactionNode_(n),i=t.path(),r=this.buildTransactionQueue_(t);return this.rerunTransactionQueue_(r,i),i};y.prototype.rerunTransactionQueue_=function(n,t){var w,o,a;if(0!==n.length){for(var k,v=[],e=[],b=n.filter(function(n){return n.status===l.RUN}).map(function(n){return n.currentWriteId}),f=0;f<n.length;f++){var u=n[f],tt=r.relativePath(t,u.path),p=!1,s=void 0;if(i(null!==tt,"rerunTransactionsUnderNode_: relativePath should not be null."),u.status===l.NEEDS_ABORT)p=!0,s=u.abortReason,e=e.concat(this.serverSyncTree_.ackUserWrite(u.currentWriteId,!0));else if(u.status===l.RUN)if(u.retryCount>=y.MAX_TRANSACTION_RETRIES_)p=!0,s="maxretry",e=e.concat(this.serverSyncTree_.ackUserWrite(u.currentWriteId,!0));else if(w=this.getLatestState_(u.path,b),u.currentInputSnapshot=w,o=n[f].update(w.val()),void 0!==o){ki("transaction failed: Data returned ",o,u.path);a=c(o);"object"==typeof o&&null!=o&&d(o,".priority")||(a=a.updatePriority(w.getPriority()));var g=u.currentWriteId,it=this.generateServerValues(),nt=oi(a,it);u.currentOutputSnapshotRaw=a;u.currentOutputSnapshotResolved=nt;u.currentWriteId=this.getNextWriteId_();b.splice(b.indexOf(g),1);e=(e=e.concat(this.serverSyncTree_.applyUserOverwrite(u.path,nt,u.currentWriteId,u.applyLocally))).concat(this.serverSyncTree_.ackUserWrite(g,!0))}else p=!0,s="nodata",e=e.concat(this.serverSyncTree_.ackUserWrite(u.currentWriteId,!0));if(this.eventQueue_.raiseEventsForChangedPath(t,e),e=[],p&&(n[f].status=l.COMPLETED,k=n[f].unwatcher,setTimeout(k,Math.floor(0)),n[f].onComplete))if("nodata"===s){var rt=new ct(this,n[f].path),ut=n[f].currentInputSnapshot,ft=new nr(ut,rt,h);v.push(n[f].onComplete.bind(null,null,!1,ft))}else v.push(n[f].onComplete.bind(null,new Error(s),!1,null))}for(this.pruneCompletedTransactionsBelowNode_(this.transactionQueueTree_),f=0;f<v.length;f++)ui(v[f]);this.sendReadyTransactions_()}};y.prototype.getAncestorTransactionNode_=function(n){for(var i,t=this.transactionQueueTree_;null!==(i=n.getFront())&&null===t.getValue();)t=t.subTree(i),n=n.popFront();return t};y.prototype.buildTransactionQueue_=function(n){var t=[];return this.aggregateTransactionQueuesForNode_(n,t),t.sort(function(n,t){return n.order-t.order}),t};y.prototype.aggregateTransactionQueuesForNode_=function(n,t){var u=this,r=n.getValue(),i;if(null!==r)for(i=0;i<r.length;i++)t.push(r[i]);n.forEachChild(function(n){u.aggregateTransactionQueuesForNode_(n,t)})};y.prototype.pruneCompletedTransactionsBelowNode_=function(n){var u=this,t=n.getValue(),r,i;if(t){for(r=0,i=0;i<t.length;i++)t[i].status!==l.COMPLETED&&(t[r]=t[i],r++);t.length=r;n.setValue(t.length>0?t:null)}n.forEachChild(function(n){u.pruneCompletedTransactionsBelowNode_(n)})};y.prototype.abortTransactions_=function(n){var i=this,r=this.getAncestorTransactionNode_(n).path(),t=this.transactionQueueTree_.subTree(n);return t.forEachAncestor(function(n){i.abortTransactionsOnNode_(n)}),this.abortTransactionsOnNode_(t),t.forEachDescendant(function(n){i.abortTransactionsOnNode_(n)}),r};y.prototype.abortTransactionsOnNode_=function(n){var r=n.getValue();if(null!==r){for(var f=[],e=[],u=-1,t=0;t<r.length;t++)r[t].status===l.SENT_NEEDS_ABORT||(r[t].status===l.SENT?(i(u===t-1,"All SENT items should be at beginning of queue."),u=t,r[t].status=l.SENT_NEEDS_ABORT,r[t].abortReason="set"):(i(r[t].status===l.RUN,"Unexpected transaction status in abort"),r[t].unwatcher(),e=e.concat(this.serverSyncTree_.ackUserWrite(r[t].currentWriteId,!0)),r[t].onComplete)&&f.push(r[t].onComplete.bind(null,new Error("set"),!1,null)));for(-1===u?n.setValue(null):r.length=u+1,this.eventQueue_.raiseEventsForChangedPath(n.path(),e),t=0;t<f.length;t++)ui(f[t])}};var pu,wu=function(){function n(){this.repos_={};this.useRestClient_=!1}return n.getInstance=function(){return pu||(pu=new n),pu},n.prototype.interrupt=function(){var n,t;for(n in this.repos_)for(t in this.repos_[n])this.repos_[n][t].interrupt()},n.prototype.resume=function(){var n,t;for(n in this.repos_)for(t in this.repos_[n])this.repos_[n][t].resume()},n.prototype.databaseFromApp=function(n,t){var r=t||n.options.databaseURL,i,u;return void 0===r&&ot("Can't determine Firebase Database URL.  Be sure to include databaseURL option when calling firebase.initializeApp()."),i=te(r),u=i.repoInfo,ue("Invalid Firebase Database URL",1,i),i.path.isEmpty()||ot("Database URL must point to the root of a Firebase Database (not including a child path)."),this.createRepo(u,n).database},n.prototype.deleteRepo=function(n){var t=p(this.repos_,n.app.name);t&&p(t,n.repoInfo_.toURLString())===n||ot("Database "+n.app.name+"("+n.repoInfo_+") has already been deleted.");n.interrupt();delete t[n.repoInfo_.toURLString()]},n.prototype.createRepo=function(n,t){var i=p(this.repos_,t.name),r;return i||(i={},this.repos_[t.name]=i),r=p(i,n.toURLString()),r&&ot("Database initialized multiple times. Please make sure the format of the database URL matches with each database() call."),r=new y(n,this.useRestClient_,t),i[n.toURLString()]=r,r},n.prototype.forceRestClient=function(n){this.useRestClient_=n},n}(),bu=function(){function n(n){this.repo_=n;n instanceof y||ot("Don't call new Database() directly - please use firebase.database().");this.root_=new ct(n,r.Empty);this.INTERNAL=new nc(this)}return Object.defineProperty(n.prototype,"app",{get:function(){return this.repo_.app},enumerable:!0,configurable:!0}),n.prototype.ref=function(n){return this.checkDeleted_("ref"),u("database.ref",0,1,arguments.length),n instanceof ct?this.refFromURL(n.toString()):void 0!==n?this.root_.child(n):this.root_},n.prototype.refFromURL=function(n){var t="database.refFromURL",i,r;return this.checkDeleted_(t),u(t,1,1,arguments.length),i=te(n),ue(t,1,i),r=i.repoInfo,r.host!==this.repo_.repoInfo_.host&&ot(t+": Host name does not match the current database: (found "+r.host+" but expected "+this.repo_.repoInfo_.host+")"),this.ref(i.path.toString())},n.prototype.checkDeleted_=function(n){null===this.repo_&&ot("Cannot call "+n+" on a deleted database.")},n.prototype.goOffline=function(){u("database.goOffline",0,0,arguments.length);this.checkDeleted_("goOffline");this.repo_.interrupt()},n.prototype.goOnline=function(){u("database.goOnline",0,0,arguments.length);this.checkDeleted_("goOnline");this.repo_.resume()},n.ServerValue={TIMESTAMP:{".sv":"timestamp"}},n}(),nc=function(){function n(n){this.database=n}return n.prototype.delete=function(){return i=this,r=void 0,n=function(){return yo(this,function(){return this.database.checkDeleted_("delete"),wu.getInstance().deleteRepo(this.database.repo_),this.database.repo_=null,this.database.root_=null,this.database.INTERNAL=null,this.database=null,[2]})},new((t=void 0)||(t=Promise))(function(u,f){function o(t){try{e(n.next(t))}catch(t){f(t)}}function s(t){try{e(n.throw(t))}catch(t){f(t)}}function e(n){n.done?u(n.value):new t(function(t){t(n.value)}).then(o,s)}e((n=n.apply(i,r||[])).next())});var i,r,t,n},n}(),tc=Object.freeze({forceLongPolling:function(){ni.forceDisallow();vu.forceAllow()},forceWebSockets:function(){vu.forceDisallow()},isWebSocketsAvailable:function(){return ni.isAvailable()},setSecurityDebugCallback:function(n,t){n.repo.persistentConnection_.securityDebugCallback_=t},stats:function(n,t){n.repo.stats(t)},statsIncrementCounter:function(n,t){n.repo.statsIncrementCounter(t)},dataUpdateCount:function(n){return n.repo.dataUpdateCount},interceptServerData:function(n,t){return n.repo.interceptServerData_(t)}}),ic=ti;ti.prototype.simpleListen=function(n,t){this.sendRequest("q",{p:n},t)};ti.prototype.echo=function(n,t){this.sendRequest("echo",{d:n},t)};var rc=so,uc=ne,fc=Object.freeze({DataConnection:ic,RealTimeConnection:rc,hijackHash:function(n){var t=ti.prototype.put;return ti.prototype.put=function(i,r,u,f){void 0!==f&&(f=n());t.call(this,i,r,u,f)},function(){ti.prototype.put=t}},ConnectionTarget:uc,queryIdentifier:function(n){return n.queryIdentifier()},listens:function(n){return n.repo.persistentConnection_.listens_},forceRestClient:function(n){wu.getInstance().forceRestClient(n)}}),ec=bu.ServerValue;ao=t.INTERNAL.registerService("database",function(n,t,i){return wu.getInstance().databaseFromApp(n,i)},{Reference:ct,Query:ou,Database:bu,enableLogging:pf,INTERNAL:tc,ServerValue:ec,TEST_ACCESS:fc},null,!0);ut()&&(module.exports=ao)}catch(n){throw console.error(n),new Error("Cannot instantiate firebase-database - be sure to load firebase-app.js first.");}}(this.firebase=this.firebase||{},firebase);!function(n,t){"use strict";var et,a,w,ct,g,nt,p,tt,lt,ft;try{t=t&&t.hasOwnProperty("default")?t.default:t;et=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i])};function c(n,t){function i(){this.constructor=n}et(n,t);n.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}a=Object.assign||function(n){for(var r,i,t=1,u=arguments.length;t<u;t++)for(i in r=arguments[t])Object.prototype.hasOwnProperty.call(r,i)&&(n[i]=r[i]);return n};function f(n,t,i,r){return new(i||(i=Promise))(function(u,f){function o(n){try{e(r.next(n))}catch(n){f(n)}}function s(n){try{e(r.throw(n))}catch(n){f(n)}}function e(n){n.done?u(n.value):new i(function(t){t(n.value)}).then(o,s)}e((r=r.apply(n,t||[])).next())})}function e(n,t){function o(e){return function(o){return function(e){if(f)throw new TypeError("Generator is already executing.");for(;r;)try{if(f=1,u&&(i=u[2&e[0]?"return":e[0]?"throw":"next"])&&!(i=i.call(u,e[1])).done)return i;switch(u=0,i&&(e=[0,i.value]),e[0]){case 0:case 1:i=e;break;case 4:return r.label++,{value:e[1],done:!1};case 5:r.label++;u=e[1];e=[0];continue;case 7:e=r.ops.pop();r.trys.pop();continue;default:if(!(i=(i=r.trys).length>0&&i[i.length-1])&&(6===e[0]||2===e[0])){r=0;continue}if(3===e[0]&&(!i||e[1]>i[0]&&e[1]<i[3])){r.label=e[1];break}if(6===e[0]&&r.label<i[1]){r.label=i[1];i=e;break}if(i&&r.label<i[2]){r.label=i[2];r.ops.push(e);break}i[2]&&r.ops.pop();r.trys.pop();continue}e=t.call(n,r)}catch(n){e=[6,n];u=0}finally{f=i=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,o])}}var f,u,i,e,r={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return e={next:o(0),"throw":o(1),"return":o(2)},"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e}var ot="FirebaseError",st=Error.captureStackTrace,l=function(){return function(n,t){if(this.code=n,this.message=t,st)st(this,w.prototype.create);else{var i=Error.apply(this,arguments);this.name=ot;Object.defineProperty(this,"stack",{get:function(){return i.stack}})}}}();l.prototype=Object.create(Error.prototype);l.prototype.constructor=l;l.prototype.name=ot;w=function(){function n(n,t,i){this.service=n;this.serviceName=t;this.errors=i;this.pattern=/\{\$([^}]+)}/g}return n.prototype.create=function(n,t){var r,u,f,e,i;void 0===t&&(t={});u=this.errors[n];f=this.service+"/"+n;r=void 0===u?"Error":u.replace(this.pattern,function(n,i){var r=t[i];return void 0!==r?r.toString():"<"+i+"?>"});r=this.serviceName+": "+r+" ("+f+").";e=new l(f,r);for(i in t)t.hasOwnProperty(i)&&"_"!==i.slice(-1)&&(e[i]=t[i]);return e},n}(),function(n){function t(){var t=n.call(this)||this,i;for(t.chain_=[],t.buf_=[],t.W_=[],t.pad_=[],t.inbuf_=0,t.total_=0,t.blockSize=64,t.pad_[0]=128,i=1;i<t.blockSize;++i)t.pad_[i]=0;return t.reset(),t}c(t,n);t.prototype.reset=function(){this.chain_[0]=1732584193;this.chain_[1]=4023233417;this.chain_[2]=2562383102;this.chain_[3]=271733878;this.chain_[4]=3285377520;this.inbuf_=0;this.total_=0};t.prototype.compress_=function(n,t){var r,i,o;if(t||(t=0),r=this.W_,"string"==typeof n)for(i=0;i<16;i++)r[i]=n.charCodeAt(t)<<24|n.charCodeAt(t+1)<<16|n.charCodeAt(t+2)<<8|n.charCodeAt(t+3),t+=4;else for(i=0;i<16;i++)r[i]=n[t]<<24|n[t+1]<<16|n[t+2]<<8|n[t+3],t+=4;for(i=16;i<80;i++)o=r[i-3]^r[i-8]^r[i-14]^r[i-16],r[i]=4294967295&(o<<1|o>>>31);var s,h,c=this.chain_[0],u=this.chain_[1],f=this.chain_[2],e=this.chain_[3],l=this.chain_[4];for(i=0;i<80;i++)i<40?i<20?(s=e^u&(f^e),h=1518500249):(s=u^f^e,h=1859775393):i<60?(s=u&f|e&(u|f),h=2400959708):(s=u^f^e,h=3395469782),o=(c<<5|c>>>27)+s+l+h+r[i]&4294967295,l=e,e=f,f=4294967295&(u<<30|u>>>2),u=c,c=o;this.chain_[0]=this.chain_[0]+c&4294967295;this.chain_[1]=this.chain_[1]+u&4294967295;this.chain_[2]=this.chain_[2]+f&4294967295;this.chain_[3]=this.chain_[3]+e&4294967295;this.chain_[4]=this.chain_[4]+l&4294967295};t.prototype.update=function(n,t){if(null!=n){void 0===t&&(t=n.length);for(var f=t-this.blockSize,i=0,u=this.buf_,r=this.inbuf_;i<t;){if(0==r)for(;i<=f;)this.compress_(n,i),i+=this.blockSize;if("string"==typeof n){for(;i<t;)if(u[r]=n.charCodeAt(i),++i,++r==this.blockSize){this.compress_(u);r=0;break}}else for(;i<t;)if(u[r]=n[i],++i,++r==this.blockSize){this.compress_(u);r=0;break}}this.inbuf_=r;this.total_+=t}};t.prototype.digest=function(){var r=[],u=8*this.total_,n,i,t;for(this.inbuf_<56?this.update(this.pad_,56-this.inbuf_):this.update(this.pad_,this.blockSize-(this.inbuf_-56)),n=this.blockSize-1;n>=56;n--)this.buf_[n]=255&u,u/=256;for(this.compress_(this.buf_),i=0,n=0;n<5;n++)for(t=24;t>=0;t-=8)r[i]=this.chain_[n]>>t&255,++i;return r}}(function(){return function(){this.blockSize=-1}}());function ht(n,t){var i=new ct(n,t);return i.subscribe.bind(i)}ct=function(){function n(n,t){var i=this;this.observers=[];this.unsubscribes=[];this.observerCount=0;this.task=Promise.resolve();this.finalized=!1;this.onNoObservers=t;this.task.then(function(){n(i)}).catch(function(n){i.error(n)})}return n.prototype.next=function(n){this.forEachObserver(function(t){t.next(n)})},n.prototype.error=function(n){this.forEachObserver(function(t){t.error(n)});this.close(n)},n.prototype.complete=function(){this.forEachObserver(function(n){n.complete()});this.close()},n.prototype.subscribe=function(n,t,i){var r,u=this,f;if(void 0===n&&void 0===t&&void 0===i)throw new Error("Missing Observer.");return void 0===(r=function(n,t){var i,r,u;if("object"!=typeof n||null===n)return!1;for(i=0,r=t;i<r.length;i++)if(u=r[i],u in n&&"function"==typeof n[u])return!0;return!1}(n,["next","error","complete"])?n:{next:n,error:t,complete:i}).next&&(r.next=b),void 0===r.error&&(r.error=b),void 0===r.complete&&(r.complete=b),f=this.unsubscribeOne.bind(this,this.observers.length),this.finalized&&this.task.then(function(){try{u.finalError?r.error(u.finalError):r.complete()}catch(n){}}),this.observers.push(r),f},n.prototype.unsubscribeOne=function(n){void 0!==this.observers&&void 0!==this.observers[n]&&(delete this.observers[n],this.observerCount-=1,0===this.observerCount&&void 0!==this.onNoObservers&&this.onNoObservers(this))},n.prototype.forEachObserver=function(n){if(!this.finalized)for(var t=0;t<this.observers.length;t++)this.sendOne(t,n)},n.prototype.sendOne=function(n,t){var i=this;this.task.then(function(){if(void 0!==i.observers&&void 0!==i.observers[n])try{t(i.observers[n])}catch(n){"undefined"!=typeof console&&console.error&&console.error(n)}})},n.prototype.close=function(n){var t=this;this.finalized||(this.finalized=!0,void 0!==n&&(this.finalError=n),this.task.then(function(){t.observers=void 0;t.onNoObservers=void 0}))},n}();function b(){}var u,o,s,i={AVAILABLE_IN_WINDOW:"only-available-in-window",AVAILABLE_IN_SW:"only-available-in-sw",SHOULD_BE_INHERITED:"should-be-overriden",BAD_SENDER_ID:"bad-sender-id",INCORRECT_GCM_SENDER_ID:"incorrect-gcm-sender-id",PERMISSION_DEFAULT:"permission-default",PERMISSION_BLOCKED:"permission-blocked",UNSUPPORTED_BROWSER:"unsupported-browser",NOTIFICATIONS_BLOCKED:"notifications-blocked",FAILED_DEFAULT_REGISTRATION:"failed-serviceworker-registration",SW_REGISTRATION_EXPECTED:"sw-registration-expected",GET_SUBSCRIPTION_FAILED:"get-subscription-failed",INVALID_SAVED_TOKEN:"invalid-saved-token",SW_REG_REDUNDANT:"sw-reg-redundant",TOKEN_SUBSCRIBE_FAILED:"token-subscribe-failed",TOKEN_SUBSCRIBE_NO_TOKEN:"token-subscribe-no-token",TOKEN_SUBSCRIBE_NO_PUSH_SET:"token-subscribe-no-push-set",TOKEN_UNSUBSCRIBE_FAILED:"token-unsubscribe-failed",TOKEN_UPDATE_FAILED:"token-update-failed",TOKEN_UPDATE_NO_TOKEN:"token-update-no-token",USE_SW_BEFORE_GET_TOKEN:"use-sw-before-get-token",INVALID_DELETE_TOKEN:"invalid-delete-token",DELETE_TOKEN_NOT_FOUND:"delete-token-not-found",DELETE_SCOPE_NOT_FOUND:"delete-scope-not-found",BG_HANDLER_FUNCTION_EXPECTED:"bg-handler-function-expected",NO_WINDOW_CLIENT_TO_MSG:"no-window-client-to-msg",UNABLE_TO_RESUBSCRIBE:"unable-to-resubscribe",NO_FCM_TOKEN_FOR_RESUBSCRIBE:"no-fcm-token-for-resubscribe",FAILED_TO_DELETE_TOKEN:"failed-to-delete-token",NO_SW_IN_REG:"no-sw-in-reg",BAD_SCOPE:"bad-scope",BAD_VAPID_KEY:"bad-vapid-key",BAD_SUBSCRIPTION:"bad-subscription",BAD_TOKEN:"bad-token",BAD_PUSH_SET:"bad-push-set",FAILED_DELETE_VAPID_KEY:"failed-delete-vapid-key",INVALID_PUBLIC_VAPID_KEY:"invalid-public-vapid-key",USE_PUBLIC_KEY_BEFORE_GET_TOKEN:"use-public-key-before-get-token",PUBLIC_KEY_DECRYPTION_FAILED:"public-vapid-key-decryption-failed"},pt=((u={})[i.AVAILABLE_IN_WINDOW]="This method is available in a Window context.",u[i.AVAILABLE_IN_SW]="This method is available in a service worker context.",u[i.SHOULD_BE_INHERITED]="This method should be overriden by extended classes.",u[i.BAD_SENDER_ID]="Please ensure that 'messagingSenderId' is set correctly in the options passed into firebase.initializeApp().",u[i.PERMISSION_DEFAULT]="The required permissions were not granted and dismissed instead.",u[i.PERMISSION_BLOCKED]="The required permissions were not granted and blocked instead.",u[i.UNSUPPORTED_BROWSER]="This browser doesn't support the API's required to use the firebase SDK.",u[i.NOTIFICATIONS_BLOCKED]="Notifications have been blocked.",u[i.FAILED_DEFAULT_REGISTRATION]="We are unable to register the default service worker. {$browserErrorMessage}",u[i.SW_REGISTRATION_EXPECTED]="A service worker registration was the expected input.",u[i.GET_SUBSCRIPTION_FAILED]="There was an error when trying to get any existing Push Subscriptions.",u[i.INVALID_SAVED_TOKEN]="Unable to access details of the saved token.",u[i.SW_REG_REDUNDANT]="The service worker being used for push was made redundant.",u[i.TOKEN_SUBSCRIBE_FAILED]="A problem occured while subscribing the user to FCM: {$message}",u[i.TOKEN_SUBSCRIBE_NO_TOKEN]="FCM returned no token when subscribing the user to push.",u[i.TOKEN_SUBSCRIBE_NO_PUSH_SET]="FCM returned an invalid response when getting an FCM token.",u[i.TOKEN_UNSUBSCRIBE_FAILED]="A problem occured while unsubscribing the user from FCM: {$message}",u[i.TOKEN_UPDATE_FAILED]="A problem occured while updating the user from FCM: {$message}",u[i.TOKEN_UPDATE_NO_TOKEN]="FCM returned no token when updating the user to push.",u[i.USE_SW_BEFORE_GET_TOKEN]="The useServiceWorker() method may only be called once and must be called before calling getToken() to ensure your service worker is used.",u[i.INVALID_DELETE_TOKEN]="You must pass a valid token into deleteToken(), i.e. the token from getToken().",u[i.DELETE_TOKEN_NOT_FOUND]="The deletion attempt for token could not be performed as the token was not found.",u[i.DELETE_SCOPE_NOT_FOUND]="The deletion attempt for service worker scope could not be performed as the scope was not found.",u[i.BG_HANDLER_FUNCTION_EXPECTED]="The input to setBackgroundMessageHandler() must be a function.",u[i.NO_WINDOW_CLIENT_TO_MSG]="An attempt was made to message a non-existant window client.",u[i.UNABLE_TO_RESUBSCRIBE]="There was an error while re-subscribing the FCM token for push messaging. Will have to resubscribe the user on next visit. {$message}",u[i.NO_FCM_TOKEN_FOR_RESUBSCRIBE]="Could not find an FCM token and as a result, unable to resubscribe. Will have to resubscribe the user on next visit.",u[i.FAILED_TO_DELETE_TOKEN]="Unable to delete the currently saved token.",u[i.NO_SW_IN_REG]="Even though the service worker registration was successful, there was a problem accessing the service worker itself.",u[i.INCORRECT_GCM_SENDER_ID]="Please change your web app manifest's 'gcm_sender_id' value to '103953800507' to use Firebase messaging.",u[i.BAD_SCOPE]="The service worker scope must be a string with at least one character.",u[i.BAD_VAPID_KEY]="The public VAPID key is not a Uint8Array with 65 bytes.",u[i.BAD_SUBSCRIPTION]="The subscription must be a valid PushSubscription.",u[i.BAD_TOKEN]="The FCM Token used for storage / lookup was not a valid token string.",u[i.BAD_PUSH_SET]="The FCM push set used for storage / lookup was not not a valid push set string.",u[i.FAILED_DELETE_VAPID_KEY]="The VAPID key could not be deleted.",u[i.INVALID_PUBLIC_VAPID_KEY]="The public VAPID key must be a string.",u[i.PUBLIC_KEY_DECRYPTION_FAILED]="The public VAPID key did not equal 65 bytes when decrypted.",u),r=new w("messaging","Messaging",pt),v=new Uint8Array([4,51,148,247,223,161,235,177,220,3,162,94,21,113,219,72,211,46,237,237,178,52,219,183,71,58,12,143,196,204,225,111,60,140,132,223,171,182,102,62,242,12,212,139,254,227,249,118,47,20,28,99,8,106,111,45,177,26,149,176,206,55,192,156,110]),k="https://fcm.googleapis.com";function d(n,t){if(null==n||null==t)return!1;if(n===t)return!0;if(n.byteLength!==t.byteLength)return!1;for(var r=new DataView(n),u=new DataView(t),i=0;i<n.byteLength;i++)if(r.getUint8(i)!==u.getUint8(i))return!1;return!0}function h(n){return function(n){var t=new Uint8Array(n);return btoa(String.fromCharCode.apply(null,t))}(n).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}!function(n){n.TYPE_OF_MSG="firebase-messaging-msg-type";n.DATA="firebase-messaging-msg-data"}(o||(o={})),function(n){n.PUSH_MSG_RECEIVED="push-msg-received";n.NOTIFICATION_CLICKED="notification-clicked"}(s||(s={}));g=function(){function n(){}return n.prototype.getToken=function(n,t,u){return f(this,void 0,void 0,function(){var s,c,o,l,a,y,f,p;return e(this,function(e){switch(e.label){case 0:s=h(t.getKey("p256dh"));c=h(t.getKey("auth"));o="authorized_entity="+n+"&endpoint="+t.endpoint+"&encryption_key="+s+"&encryption_auth="+c;u!==v&&(l=h(u),o+="&application_pub_key="+l);(a=new Headers).append("Content-Type","application/x-www-form-urlencoded");y={method:"POST",headers:a,body:o};e.label=1;case 1:return e.trys.push([1,4,,5]),[4,fetch(k+"/fcm/connect/subscribe",y)];case 2:return[4,e.sent().json()];case 3:return f=e.sent(),[3,5];case 4:throw e.sent(),r.create(i.TOKEN_SUBSCRIBE_FAILED);case 5:if(f.error)throw p=f.error.message,r.create(i.TOKEN_SUBSCRIBE_FAILED,{message:p});if(!f.token)throw r.create(i.TOKEN_SUBSCRIBE_NO_TOKEN);if(!f.pushSet)throw r.create(i.TOKEN_SUBSCRIBE_NO_PUSH_SET);return[2,{token:f.token,pushSet:f.pushSet}]}})})},n.prototype.updateToken=function(n,t,u,o,s){return f(this,void 0,void 0,function(){var l,a,c,y,p,w,f,b;return e(this,function(e){switch(e.label){case 0:l=h(o.getKey("p256dh"));a=h(o.getKey("auth"));c="push_set="+u+"&token="+t+"&authorized_entity="+n+"&endpoint="+o.endpoint+"&encryption_key="+l+"&encryption_auth="+a;s!==v&&(y=h(s),c+="&application_pub_key="+y);(p=new Headers).append("Content-Type","application/x-www-form-urlencoded");w={method:"POST",headers:p,body:c};e.label=1;case 1:return e.trys.push([1,4,,5]),[4,fetch(k+"/fcm/connect/subscribe",w)];case 2:return[4,e.sent().json()];case 3:return f=e.sent(),[3,5];case 4:throw e.sent(),r.create(i.TOKEN_UPDATE_FAILED);case 5:if(f.error)throw b=f.error.message,r.create(i.TOKEN_UPDATE_FAILED,{message:b});if(!f.token)throw r.create(i.TOKEN_UPDATE_NO_TOKEN);return[2,f.token]}})})},n.prototype.deleteToken=function(n,t,u){return f(this,void 0,void 0,function(){var f,o,s,h,c;return e(this,function(e){switch(e.label){case 0:f="authorized_entity="+n+"&token="+t+"&pushSet="+u;(o=new Headers).append("Content-Type","application/x-www-form-urlencoded");s={method:"POST",headers:o,body:f};e.label=1;case 1:return e.trys.push([1,4,,5]),[4,fetch(k+"/fcm/connect/unsubscribe",s)];case 2:return[4,e.sent().json()];case 3:if((h=e.sent()).error)throw c=h.error.message,r.create(i.TOKEN_UNSUBSCRIBE_FAILED,{message:c});return[3,5];case 4:throw e.sent(),r.create(i.TOKEN_UNSUBSCRIBE_FAILED);case 5:return[2]}})})},n}();function y(n){for(var u=(n+"=".repeat((4-n.length%4)%4)).replace(/\-/g,"+").replace(/_/g,"/"),i=atob(u),r=new Uint8Array(i.length),t=0;t<i.length;++t)r[t]=i.charCodeAt(t);return r}nt="undefined";p="fcm_token_object_Store";function wt(){var n=indexedDB.open(nt);n.onerror=function(){};n.onsuccess=function(){!function(n){if(n.objectStoreNames.contains(p)){var i=n.transaction(p).objectStore(p),r=new g,t=i.openCursor();t.onerror=function(n){console.warn("Unable to cleanup old IDB.",n)};t.onsuccess=function(){var u=t.result,i;u?(i=u.value,r.deleteToken(i.fcmSenderId,i.fcmToken,i.fcmPushSet),u.continue()):(n.close(),indexedDB.deleteDatabase(nt))}}}(n.result)}}tt=function(){function n(){this.dbPromise=null}return n.prototype.get=function(n){return this.createTransaction(function(t){return t.get(n)})},n.prototype.getIndex=function(n,t){return this.createTransaction(function(i){return i.index(n).get(t)})},n.prototype.put=function(n){return this.createTransaction(function(t){return t.put(n)},"readwrite")},n.prototype.delete=function(n){return this.createTransaction(function(t){return t.delete(n)},"readwrite")},n.prototype.closeDatabase=function(){return f(this,void 0,void 0,function(){return e(this,function(n){switch(n.label){case 0:return this.dbPromise?[4,this.dbPromise]:[3,2];case 1:n.sent().close();this.dbPromise=null;n.label=2;case 2:return[2]}})})},n.prototype.createTransaction=function(n,t){return void 0===t&&(t="readonly"),f(this,void 0,void 0,function(){var r,i,u,f;return e(this,function(e){switch(e.label){case 0:return[4,this.getDb()];case 1:return r=e.sent(),i=r.transaction(this.objectStoreName,t),u=i.objectStore(this.objectStoreName),[4,function(n){return new Promise(function(t,i){n.onsuccess=function(){t(n.result)};n.onerror=function(){i(n.error)}})}(n(u))];case 2:return f=e.sent(),[2,new Promise(function(n,t){i.oncomplete=function(){n(f)};i.onerror=function(){t(i.error)}})]}})})},n.prototype.getDb=function(){var n=this;return this.dbPromise||(this.dbPromise=new Promise(function(t,i){var r=indexedDB.open(n.dbName,n.dbVersion);r.onsuccess=function(){t(r.result)};r.onerror=function(){n.dbPromise=null;i(r.error)};r.onupgradeneeded=function(t){return n.onDbUpgrade(r,t)}})),this.dbPromise},n}();lt=function(n){function t(){var t=null!==n&&n.apply(this,arguments)||this;return t.dbName="fcm_token_details_db",t.dbVersion=3,t.objectStoreName="fcm_token_object_Store",t}return c(t,n),t.prototype.onDbUpgrade=function(n,t){var u=n.result,i,r;switch(t.oldVersion){case 0:(i=u.createObjectStore(this.objectStoreName,{keyPath:"swScope"})).createIndex("fcmSenderId","fcmSenderId",{unique:!1});i.createIndex("fcmToken","fcmToken",{unique:!0});case 1:wt();case 2:r=(i=n.transaction.objectStore(this.objectStoreName)).openCursor();r.onsuccess=function(){var i=r.result,n,t;i&&(n=i.value,t=a({},n),n.createTime||(t.createTime=Date.now()),"string"==typeof n.vapidKey&&(t.vapidKey=y(n.vapidKey)),"string"==typeof n.auth&&(t.auth=y(n.auth).buffer),"string"==typeof n.auth&&(t.p256dh=y(n.p256dh).buffer),i.update(t),i.continue())}}},t.prototype.getTokenDetailsFromToken=function(n){return f(this,void 0,void 0,function(){return e(this,function(){if(!n)throw r.create(i.BAD_TOKEN);return it({fcmToken:n}),[2,this.getIndex("fcmToken",n)]})})},t.prototype.getTokenDetailsFromSWScope=function(n){return f(this,void 0,void 0,function(){return e(this,function(){if(!n)throw r.create(i.BAD_SCOPE);return it({swScope:n}),[2,this.get(n)]})})},t.prototype.saveTokenDetails=function(n){return f(this,void 0,void 0,function(){return e(this,function(){if(!n.swScope)throw r.create(i.BAD_SCOPE);if(!n.vapidKey)throw r.create(i.BAD_VAPID_KEY);if(!n.endpoint||!n.auth||!n.p256dh)throw r.create(i.BAD_SUBSCRIPTION);if(!n.fcmSenderId)throw r.create(i.BAD_SENDER_ID);if(!n.fcmToken)throw r.create(i.BAD_TOKEN);if(!n.fcmPushSet)throw r.create(i.BAD_PUSH_SET);return it(n),[2,this.put(n)]})})},t.prototype.deleteToken=function(n){return f(this,void 0,void 0,function(){var t;return e(this,function(u){switch(u.label){case 0:return"string"!=typeof n||0===n.length?[2,Promise.reject(r.create(i.INVALID_DELETE_TOKEN))]:[4,this.getTokenDetailsFromToken(n)];case 1:if(!(t=u.sent()))throw r.create(i.DELETE_TOKEN_NOT_FOUND);return[4,this.delete(t.swScope)];case 2:return u.sent(),[2,t]}})})},t}(tt);function it(n){if(n.fcmToken&&("string"!=typeof n.fcmToken||0===n.fcmToken.length))throw r.create(i.BAD_TOKEN);if(n.swScope&&("string"!=typeof n.swScope||0===n.swScope.length))throw r.create(i.BAD_SCOPE);if(n.vapidKey&&(!(n.vapidKey instanceof Uint8Array)||65!==n.vapidKey.length))throw r.create(i.BAD_VAPID_KEY);if(n.endpoint&&("string"!=typeof n.endpoint||0===n.endpoint.length))throw r.create(i.BAD_SUBSCRIPTION);if(n.auth&&!(n.auth instanceof ArrayBuffer))throw r.create(i.BAD_SUBSCRIPTION);if(n.p256dh&&!(n.p256dh instanceof ArrayBuffer))throw r.create(i.BAD_SUBSCRIPTION);if(n.fcmSenderId&&("string"!=typeof n.fcmSenderId||0===n.fcmSenderId.length))throw r.create(i.BAD_SENDER_ID);if(n.fcmPushSet&&("string"!=typeof n.fcmPushSet||0===n.fcmPushSet.length))throw r.create(i.BAD_PUSH_SET);}var bt=function(n){function t(){var t=null!==n&&n.apply(this,arguments)||this;return t.dbName="fcm_vapid_details_db",t.dbVersion=1,t.objectStoreName="fcm_vapid_object_Store",t}return c(t,n),t.prototype.onDbUpgrade=function(n){n.result.createObjectStore(this.objectStoreName,{keyPath:"swScope"})},t.prototype.getVapidFromSWScope=function(n){return f(this,void 0,void 0,function(){var t;return e(this,function(u){switch(u.label){case 0:if("string"!=typeof n||0===n.length)throw r.create(i.BAD_SCOPE);return[4,this.get(n)];case 1:return[2,(t=u.sent())?t.vapidKey:void 0]}})})},t.prototype.saveVapidDetails=function(n,t){return f(this,void 0,void 0,function(){var u;return e(this,function(){if("string"!=typeof n||0===n.length)throw r.create(i.BAD_SCOPE);if(null===t||65!==t.length)throw r.create(i.BAD_VAPID_KEY);return u={swScope:n,vapidKey:t},[2,this.put(u)]})})},t.prototype.deleteVapidDetails=function(n){return f(this,void 0,void 0,function(){var t;return e(this,function(u){switch(u.label){case 0:return[4,this.getVapidFromSWScope(n)];case 1:if(!(t=u.sent()))throw r.create(i.DELETE_SCOPE_NOT_FOUND);return[4,this.delete(n)];case 2:return u.sent(),[2,t]}})})},t}(tt),rt="messagingSenderId",at=function(){function n(n){var t=this;if(!n.options[rt]||"string"!=typeof n.options[rt])throw r.create(i.BAD_SENDER_ID);this.messagingSenderId=n.options[rt];this.tokenDetailsModel=new lt;this.vapidDetailsModel=new bt;this.iidModel=new g;this.app=n;this.INTERNAL={"delete":function(){return t.delete()}}}return n.prototype.getToken=function(){return f(this,void 0,void 0,function(){var f,n,t,u,o;return e(this,function(e){switch(e.label){case 0:return"granted"!==(f=this.getNotificationPermission_())?"denied"===f?[2,Promise.reject(r.create(i.NOTIFICATIONS_BLOCKED))]:[2,Promise.resolve(null)]:[4,this.getSWRegistration_()];case 1:return n=e.sent(),[4,this.getPublicVapidKey_()];case 2:return t=e.sent(),[4,this.getPushSubscription(n,t)];case 3:return u=e.sent(),[4,this.tokenDetailsModel.getTokenDetailsFromSWScope(n.scope)];case 4:return(o=e.sent())?[2,this.manageExistingToken(n,u,t,o)]:[2,this.getNewToken(n,u,t)]}})})},n.prototype.manageExistingToken=function(n,t,i,r){return f(this,void 0,void 0,function(){return e(this,function(u){switch(u.label){case 0:return function(n,t,i){if(!d(t.buffer,i.vapidKey.buffer))return!1;var r=n.endpoint===i.endpoint,u=d(n.getKey("auth"),i.auth),f=d(n.getKey("p256dh"),i.p256dh);return r&&u&&f}(t,i,r)?Date.now()<r.createTime+6048e5?[2,r.fcmToken]:[2,this.updateToken(n,t,i,r)]:[4,this.deleteTokenFromDB(r.fcmToken)];case 1:return u.sent(),[2,this.getNewToken(n,t,i)]}})})},n.prototype.updateToken=function(n,t,i,r){return f(this,void 0,void 0,function(){var u,f,o;return e(this,function(e){switch(e.label){case 0:return e.trys.push([0,4,,6]),[4,this.iidModel.updateToken(this.messagingSenderId,r.fcmToken,r.fcmPushSet,t,i)];case 1:return u=e.sent(),f={swScope:n.scope,vapidKey:i,fcmSenderId:this.messagingSenderId,fcmToken:u,fcmPushSet:r.fcmPushSet,createTime:Date.now(),endpoint:t.endpoint,auth:t.getKey("auth"),p256dh:t.getKey("p256dh")},[4,this.tokenDetailsModel.saveTokenDetails(f)];case 2:return e.sent(),[4,this.vapidDetailsModel.saveVapidDetails(n.scope,i)];case 3:return e.sent(),[2,u];case 4:return o=e.sent(),[4,this.deleteToken(r.fcmToken)];case 5:throw e.sent(),o;case 6:return[2]}})})},n.prototype.getNewToken=function(n,t,i){return f(this,void 0,void 0,function(){var r,u;return e(this,function(f){switch(f.label){case 0:return[4,this.iidModel.getToken(this.messagingSenderId,t,i)];case 1:return r=f.sent(),u={swScope:n.scope,vapidKey:i,fcmSenderId:this.messagingSenderId,fcmToken:r.token,fcmPushSet:r.pushSet,createTime:Date.now(),endpoint:t.endpoint,auth:t.getKey("auth"),p256dh:t.getKey("p256dh")},[4,this.tokenDetailsModel.saveTokenDetails(u)];case 2:return f.sent(),[4,this.vapidDetailsModel.saveVapidDetails(n.scope,i)];case 3:return f.sent(),[2,r.token]}})})},n.prototype.deleteToken=function(n){return f(this,void 0,void 0,function(){var t,i;return e(this,function(r){switch(r.label){case 0:return[4,this.deleteTokenFromDB(n)];case 1:return r.sent(),[4,this.getSWRegistration_()];case 2:return(t=r.sent())?[4,t.pushManager.getSubscription()]:[3,4];case 3:if(i=r.sent())return[2,i.unsubscribe()];r.label=4;case 4:return[2,!0]}})})},n.prototype.deleteTokenFromDB=function(n){return f(this,void 0,void 0,function(){var t;return e(this,function(i){switch(i.label){case 0:return[4,this.tokenDetailsModel.deleteToken(n)];case 1:return t=i.sent(),[4,this.iidModel.deleteToken(t.fcmSenderId,t.fcmToken,t.fcmPushSet)];case 2:return i.sent(),[2]}})})},n.prototype.getPushSubscription=function(n,t){return n.pushManager.getSubscription().then(function(i){return i||n.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:t})})},n.prototype.requestPermission=function(){throw r.create(i.AVAILABLE_IN_WINDOW);},n.prototype.useServiceWorker=function(){throw r.create(i.AVAILABLE_IN_WINDOW);},n.prototype.usePublicVapidKey=function(){throw r.create(i.AVAILABLE_IN_WINDOW);},n.prototype.onMessage=function(){throw r.create(i.AVAILABLE_IN_WINDOW);},n.prototype.onTokenRefresh=function(){throw r.create(i.AVAILABLE_IN_WINDOW);},n.prototype.setBackgroundMessageHandler=function(){throw r.create(i.AVAILABLE_IN_SW);},n.prototype.delete=function(){return f(this,void 0,void 0,function(){return e(this,function(n){switch(n.label){case 0:return[4,Promise.all([this.tokenDetailsModel.closeDatabase(),this.vapidDetailsModel.closeDatabase()])];case 1:return n.sent(),[2]}})})},n.prototype.getNotificationPermission_=function(){return Notification.permission},n.prototype.getTokenDetailsModel=function(){return this.tokenDetailsModel},n.prototype.getVapidDetailsModel=function(){return this.vapidDetailsModel},n.prototype.getIIDModel=function(){return this.iidModel},n}(),kt=function(n){function t(t){var i=n.call(this,t)||this;return i.bgMessageHandler=null,self.addEventListener("push",function(n){i.onPush(n)}),self.addEventListener("pushsubscriptionchange",function(n){i.onSubChange(n)}),self.addEventListener("notificationclick",function(n){i.onNotificationClick(n)}),i}return c(t,n),t.prototype.onPush=function(n){n.waitUntil(this.onPush_(n))},t.prototype.onSubChange=function(n){n.waitUntil(this.onSubChange_(n))},t.prototype.onNotificationClick=function(n){n.waitUntil(this.onNotificationClick_(n))},t.prototype.onPush_=function(n){return f(this,void 0,void 0,function(){var t,i,f,o,u,r;return e(this,function(e){switch(e.label){case 0:if(!n.data)return[2];try{t=n.data.json()}catch(n){return[2]}return[4,this.hasVisibleClients_()];case 1:return e.sent()?[2,this.sendMessageToWindowClients_(t)]:(i=this.getNotificationData_(t))?(f=i.title||"",[4,this.getSWRegistration_()]):[3,3];case 2:return o=e.sent(),u=i.actions,r=Notification.maxActions,u&&r&&u.length>r&&console.warn("This browser only supports "+r+" actions.The remaining actions will not be displayed."),[2,o.showNotification(f,i)];case 3:return this.bgMessageHandler?[4,this.bgMessageHandler(t)]:[3,5];case 4:return e.sent(),[2];case 5:return[2]}})})},t.prototype.onSubChange_=function(){return f(this,void 0,void 0,function(){var n,u,t,f;return e(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.getSWRegistration_()];case 1:return n=e.sent(),[3,3];case 2:throw u=e.sent(),r.create(i.UNABLE_TO_RESUBSCRIBE,{message:u});case 3:return e.trys.push([3,5,,8]),[4,n.pushManager.getSubscription()];case 4:return e.sent(),[3,8];case 5:return t=e.sent(),[4,this.getTokenDetailsModel().getTokenDetailsFromSWScope(n.scope)];case 6:if(!(f=e.sent()))throw t;return[4,this.deleteToken(f.fcmToken)];case 7:throw e.sent(),t;case 8:return[2]}})})},t.prototype.onNotificationClick_=function(n){return f(this,void 0,void 0,function(){var i,r,t,u;return e(this,function(f){switch(f.label){case 0:return n.notification&&n.notification.data&&n.notification.data.FCM_MSG?n.action?[2]:(n.stopImmediatePropagation(),n.notification.close(),(i=n.notification.data.FCM_MSG).notification&&(r=i.notification.click_action)?[4,this.getWindowClient_(r)]:[2]):[2];case 1:return(t=f.sent())?[3,3]:[4,self.clients.openWindow(r)];case 2:return t=f.sent(),[3,5];case 3:return[4,t.focus()];case 4:t=f.sent();f.label=5;case 5:return t?(delete i.notification,u=vt(s.NOTIFICATION_CLICKED,i),[2,this.attemptToMessageClient_(t,u)]):[2]}})})},t.prototype.getNotificationData_=function(n){if(n&&"object"==typeof n.notification){var t,i=a({},n.notification);return i.data=a({},n.notification.data,((t={}).FCM_MSG=n,t)),i}},t.prototype.setBackgroundMessageHandler=function(n){if(!n||"function"!=typeof n)throw r.create(i.BG_HANDLER_FUNCTION_EXPECTED);this.bgMessageHandler=n},t.prototype.getWindowClient_=function(n){return f(this,void 0,void 0,function(){var u,i,r,t;return e(this,function(f){switch(f.label){case 0:return u=new URL(n,self.location.href).href,[4,ut()];case 1:for(i=f.sent(),r=null,t=0;t<i.length;t++)if(new URL(i[t].url,self.location.href).href===u){r=i[t];break}return[2,r]}})})},t.prototype.attemptToMessageClient_=function(n,t){return f(this,void 0,void 0,function(){return e(this,function(){if(!n)throw r.create(i.NO_WINDOW_CLIENT_TO_MSG);return n.postMessage(t),[2]})})},t.prototype.hasVisibleClients_=function(){return f(this,void 0,void 0,function(){return e(this,function(n){switch(n.label){case 0:return[4,ut()];case 1:return[2,n.sent().some(function(n){return"visible"===n.visibilityState})]}})})},t.prototype.sendMessageToWindowClients_=function(n){return f(this,void 0,void 0,function(){var t,i,r=this;return e(this,function(u){switch(u.label){case 0:return[4,ut()];case 1:return t=u.sent(),i=vt(s.PUSH_MSG_RECEIVED,n),[4,Promise.all(t.map(function(n){return r.attemptToMessageClient_(n,i)}))];case 2:return u.sent(),[2]}})})},t.prototype.getSWRegistration_=function(){return f(this,void 0,void 0,function(){return e(this,function(){return[2,self.registration]})})},t.prototype.getPublicVapidKey_=function(){return f(this,void 0,void 0,function(){var n,t;return e(this,function(u){switch(u.label){case 0:return[4,this.getSWRegistration_()];case 1:if(!(n=u.sent()))throw r.create(i.SW_REGISTRATION_EXPECTED);return[4,this.getVapidDetailsModel().getVapidFromSWScope(n.scope)];case 2:return null==(t=u.sent())?[2,v]:[2,t]}})})},t}(at);function ut(){return self.clients.matchAll({type:"window",includeUncontrolled:!0})}function vt(n,t){return(i={})[o.TYPE_OF_MSG]=n,i[o.DATA]=t,i;var i}ft=function(n){function t(t){var i=n.call(this,t)||this;return i.registrationToUse=null,i.publicVapidKeyToUse=null,i.manifestCheckPromise=null,i.messageObserver=null,i.tokenRefreshObserver=null,i.onMessageInternal=ht(function(n){i.messageObserver=n}),i.onTokenRefreshInternal=ht(function(n){i.tokenRefreshObserver=n}),i.setupSWMessageListener_(),i}return c(t,n),t.prototype.getToken=function(){var t=this;return this.manifestCheck_().then(function(){return n.prototype.getToken.call(t)})},t.prototype.manifestCheck_=function(){if(this.manifestCheckPromise)return this.manifestCheckPromise;var n=document.querySelector('link[rel="manifest"]');return this.manifestCheckPromise=n?fetch(n.href).then(function(n){return n.json()}).catch(function(){}).then(function(n){if(n&&n.gcm_sender_id&&"103953800507"!==n.gcm_sender_id)throw r.create(i.INCORRECT_GCM_SENDER_ID);}):Promise.resolve(),this.manifestCheckPromise},t.prototype.requestPermission=function(){return f(this,void 0,void 0,function(){return e(this,function(){return"granted"===Notification.permission?[2]:[2,new Promise(function(n,t){var u=function(u){return"granted"===u?n():t("denied"===u?r.create(i.PERMISSION_BLOCKED):r.create(i.PERMISSION_DEFAULT))},f=Notification.requestPermission(u);f&&f.then(u)})]})})},t.prototype.useServiceWorker=function(n){if(!(n instanceof ServiceWorkerRegistration))throw r.create(i.SW_REGISTRATION_EXPECTED);if(null!=this.registrationToUse)throw r.create(i.USE_SW_BEFORE_GET_TOKEN);this.registrationToUse=n},t.prototype.usePublicVapidKey=function(n){if("string"!=typeof n)throw r.create(i.INVALID_PUBLIC_VAPID_KEY);if(null!=this.publicVapidKeyToUse)throw r.create(i.USE_PUBLIC_KEY_BEFORE_GET_TOKEN);var t=y(n);if(65!==t.length)throw r.create(i.PUBLIC_KEY_DECRYPTION_FAILED);this.publicVapidKeyToUse=t},t.prototype.onMessage=function(n,t,i){return"function"==typeof n?this.onMessageInternal(n,t,i):this.onMessageInternal(n)},t.prototype.onTokenRefresh=function(n,t,i){return"function"==typeof n?this.onTokenRefreshInternal(n,t,i):this.onTokenRefreshInternal(n)},t.prototype.waitForRegistrationToActivate_=function(n){var t=n.installing||n.waiting||n.active;return new Promise(function(u,f){if(t)if("activated"!==t.state)if("redundant"!==t.state){var e=function(){if("activated"===t.state)u(n);else{if("redundant"!==t.state)return;f(r.create(i.SW_REG_REDUNDANT))}t.removeEventListener("statechange",e)};t.addEventListener("statechange",e)}else f(r.create(i.SW_REG_REDUNDANT));else u(n);else f(r.create(i.NO_SW_IN_REG))})},t.prototype.getSWRegistration_=function(){var n=this;return this.registrationToUse?this.waitForRegistrationToActivate_(this.registrationToUse):(this.registrationToUse=null,navigator.serviceWorker.register("/firebase-messaging-sw.js",{scope:"/firebase-cloud-messaging-push-scope"}).catch(function(n){throw r.create(i.FAILED_DEFAULT_REGISTRATION,{browserErrorMessage:n.message});}).then(function(t){return n.waitForRegistrationToActivate_(t).then(function(){return n.registrationToUse=t,t.update(),t})}))},t.prototype.getPublicVapidKey_=function(){return this.publicVapidKeyToUse?Promise.resolve(this.publicVapidKeyToUse):Promise.resolve(v)},t.prototype.setupSWMessageListener_=function(){var n=this;navigator.serviceWorker.addEventListener("message",function(t){var i,r;if(t.data&&t.data[o.TYPE_OF_MSG]){i=t.data;switch(i[o.TYPE_OF_MSG]){case s.PUSH_MSG_RECEIVED:case s.NOTIFICATION_CLICKED:r=i[o.DATA];n.messageObserver&&n.messageObserver.next(r)}}},!1)},t}(at);function yt(){return self&&"ServiceWorkerGlobalScope"in self?"PushManager"in self&&"Notification"in self&&ServiceWorkerRegistration.prototype.hasOwnProperty("showNotification")&&PushSubscription.prototype.hasOwnProperty("getKey"):"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window&&"fetch"in window&&ServiceWorkerRegistration.prototype.hasOwnProperty("showNotification")&&PushSubscription.prototype.hasOwnProperty("getKey")}!function(n){var t=function(n){if(!yt())throw r.create(i.UNSUPPORTED_BROWSER);return self&&"ServiceWorkerGlobalScope"in self?new kt(n):new ft(n)},u;t.isSupported=yt;u={Messaging:ft};n.INTERNAL.registerService("messaging",t,u)}(t)}catch(n){throw console.error(n),new Error("Cannot instantiate firebase-messaging - be sure to load firebase-app.js first.");}}(this.firebase=this.firebase||{},firebase);!function(n,t){"use strict";var r,rt,bi,ki,c,o,st,p,ht,l,tt,er,or,cr;try{t=t&&t.hasOwnProperty("default")?t.default:t;var fi="https://firebasestorage.googleapis.com",lr="https://firebasestorage.googleapis.com",ei="/v0",ar="/v0",vr=12e4,yr=6e4,pr=-9007199254740991,f=function(){function n(n,t){this.code_=oi(n);this.message_="Firebase Storage: "+t;this.serverResponse_=null;this.name_="FirebaseError"}return n.prototype.codeProp=function(){return this.code},n.prototype.codeEquals=function(n){return oi(n)===this.codeProp()},n.prototype.serverResponseProp=function(){return this.serverResponse_},n.prototype.setServerResponseProp=function(n){this.serverResponse_=n},Object.defineProperty(n.prototype,"name",{get:function(){return this.name_},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"code",{get:function(){return this.code_},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"message",{get:function(){return this.message_},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"serverResponse",{get:function(){return this.serverResponse_},enumerable:!0,configurable:!0}),n}(),u={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 oi(n){return"storage/"+n}function pt(){return new f(u.UNKNOWN,"An unknown error occurred, please check the error payload for server response.")}function si(){return new f(u.CANCELED,"User canceled the upload/download.")}function hi(){return new f(u.CANNOT_SLICE_BLOB,"Cannot slice blob for upload. Please retry the upload.")}function ci(n,t,i){return new f(u.INVALID_ARGUMENT,"Invalid argument in `"+t+"` at index "+n+": "+i)}function wt(){return new f(u.APP_DELETED,"The Firebase app was deleted.")}function k(n,t){return new f(u.INVALID_FORMAT,"String does not match format '"+n+"': "+t)}function it(n){throw new f(u.INTERNAL_ERROR,"Internal error: "+n);}r={RAW:"raw",BASE64:"base64",BASE64URL:"base64url",DATA_URL:"data_url"};function wr(n){switch(n){case r.RAW:case r.BASE64:case r.BASE64URL:case r.DATA_URL:return;default:throw"Expected one of the event types: ["+r.RAW+", "+r.BASE64+", "+r.BASE64URL+", "+r.DATA_URL+"].";}}rt=function(){return function(n,t){this.data=n;this.contentType=t||null}}();function li(n,t){switch(n){case r.RAW:return new rt(ai(t));case r.BASE64:case r.BASE64URL:return new rt(vi(n,t));case r.DATA_URL:return new rt(function(n){var t=new yi(n);return t.base64?vi(r.BASE64,t.rest):function(n){var t;try{t=decodeURIComponent(n)}catch(n){throw k(r.DATA_URL,"Malformed data URL.");}return ai(t)}(t.rest)}(t),function(n){return new yi(n).contentType}(t))}throw pt();}function ai(n){for(var t,i=[],r=0;r<n.length;r++)t=n.charCodeAt(r),t<=127?i.push(t):t<=2047?i.push(192|t>>6,128|63&t):55296==(64512&t)?r<n.length-1&&56320==(64512&n.charCodeAt(r+1))?(t=65536|(1023&t)<<10|1023&n.charCodeAt(++r),i.push(240|t>>18,128|t>>12&63,128|t>>6&63,128|63&t)):i.push(239,191,189):56320==(64512&t)?i.push(239,191,189):i.push(224|t>>12,128|t>>6&63,128|63&t);return new Uint8Array(i)}function vi(n,t){var f,s,e,h,u,o,i;switch(n){case r.BASE64:if(f=-1!==t.indexOf("-"),s=-1!==t.indexOf("_"),f||s)throw k(n,"Invalid character '"+(f?"-":"_")+"' found: is it base64url encoded?");break;case r.BASE64URL:if(e=-1!==t.indexOf("+"),h=-1!==t.indexOf("/"),e||h)throw k(n,"Invalid character '"+(e?"+":"/")+"' found: is it base64 encoded?");t=t.replace(/-/g,"+").replace(/_/g,"/")}try{u=atob(t)}catch(t){throw k(n,"Invalid character found");}for(o=new Uint8Array(u.length),i=0;i<u.length;i++)o[i]=u.charCodeAt(i);return o}var yi=function(){return function(n){var f,t,i,u;if(this.base64=!1,this.contentType=null,f=n.match(/^data:([^,]+)?,/),null===f)throw k(r.DATA_URL,"Must be formatted 'data:[<mediatype>][;base64],<data>");t=f[1]||null;null!=t&&(this.base64=(i=t,u=";base64",i.length>=u.length&&i.substring(i.length-u.length)===u),this.contentType=this.base64?t.substring(0,t.length-7):t);this.rest=n.substring(n.indexOf(",")+1)}}(),y,bt={STATE_CHANGED:"state_changed"},i={RUNNING:"running",PAUSING:"pausing",PAUSED:"paused",SUCCESS:"success",CANCELING:"canceling",CANCELED:"canceled",ERROR:"error"},s={RUNNING:"running",PAUSED:"paused",SUCCESS:"success",CANCELED:"canceled",ERROR:"error"};function kt(n){switch(n){case i.RUNNING:case i.PAUSING:case i.CANCELING:return s.RUNNING;case i.PAUSED:return s.PAUSED;case i.SUCCESS:return s.SUCCESS;case i.CANCELED:return s.CANCELED;case i.ERROR:default:return s.ERROR}}function br(n,t){return Object.prototype.hasOwnProperty.call(n,t)}function ut(n,t){for(var i in n)br(n,i)&&t(i,n[i])}function dt(n){if(null==n)return{};var t={};return ut(n,function(n,i){t[n]=i}),t}function gt(n){return new Promise(n)}function ni(n){return Promise.resolve(n)}function h(n){return null!=n}function a(n){return void 0!==n}function pi(n){return"function"==typeof n}function ft(n){return"object"==typeof n}function kr(n){return ft(n)&&null!==n}function d(n){return"string"==typeof n||n instanceof String}function wi(n){return et()&&n instanceof Blob}function et(){return"undefined"!=typeof Blob}!function(n){n[n.NO_ERROR=0]="NO_ERROR";n[n.NETWORK_ERROR=1]="NETWORK_ERROR";n[n.ABORT=2]="ABORT"}(y||(y={}));bi=function(){function n(){var n=this;this.sent_=!1;this.xhr_=new XMLHttpRequest;this.errorCode_=y.NO_ERROR;this.sendPromise_=gt(function(t){n.xhr_.addEventListener("abort",function(){n.errorCode_=y.ABORT;t(n)});n.xhr_.addEventListener("error",function(){n.errorCode_=y.NETWORK_ERROR;t(n)});n.xhr_.addEventListener("load",function(){t(n)})})}return n.prototype.send=function(n,t,i,r){var u=this;if(this.sent_)throw it("cannot .send() more than once");return(this.sent_=!0,this.xhr_.open(t,n,!0),h(r))&&ut(r,function(n,t){u.xhr_.setRequestHeader(n,t.toString())}),h(i)?this.xhr_.send(i):this.xhr_.send(),this.sendPromise_},n.prototype.getErrorCode=function(){if(!this.sent_)throw it("cannot .getErrorCode() before sending");return this.errorCode_},n.prototype.getStatus=function(){if(!this.sent_)throw it("cannot .getStatus() before sending");try{return this.xhr_.status}catch(n){return-1}},n.prototype.getResponseText=function(){if(!this.sent_)throw it("cannot .getResponseText() before sending");return this.xhr_.responseText},n.prototype.abort=function(){this.xhr_.abort()},n.prototype.getResponseHeader=function(n){return this.xhr_.getResponseHeader(n)},n.prototype.addUploadProgressListener=function(n){h(this.xhr_.upload)&&this.xhr_.upload.addEventListener("progress",n)},n.prototype.removeUploadProgressListener=function(n){h(this.xhr_.upload)&&this.xhr_.upload.removeEventListener("progress",n)},n}();ki=function(){function n(){}return n.prototype.createXhrIo=function(){return new bi},n}();function di(n){var t,i;try{t=JSON.parse(n)}catch(n){return null}return ft(i=t)&&!Array.isArray(i)?t:null}c=function(){function n(n,t){this.bucket=n;this.path_=t}return Object.defineProperty(n.prototype,"path",{get:function(){return this.path_},enumerable:!0,configurable:!0}),n.prototype.fullServerUrl=function(){var n=encodeURIComponent;return"/b/"+n(this.bucket)+"/o/"+n(this.path)},n.prototype.bucketOnlyServerUrl=function(){return"/b/"+encodeURIComponent(this.bucket)+"/o"},n.makeFromBucketSpec=function(t){var i,r;try{i=n.makeFromUrl(t)}catch(i){return new n(t,"")}if(""===i.path)return i;throw r=t,new f(u.INVALID_DEFAULT_BUCKET,"Invalid default bucket '"+r+"'.");},n.makeFromUrl=function(t){for(var r=null,i,o,c,s,h=[{regex:new RegExp("^gs://([A-Za-z0-9.\\-]+)(/(.*))?$","i"),indices:{bucket:1,path:3},postModify:function(n){"/"===n.path.charAt(n.path.length-1)&&(n.path_=n.path_.slice(0,-1))}},{regex:new RegExp("^https?://firebasestorage\\.googleapis\\.com/v[A-Za-z0-9_]+/b/([A-Za-z0-9.\\-]+)/o(/([^?#]*).*)?$","i"),indices:{bucket:1,path:3},postModify:function(n){n.path_=decodeURIComponent(n.path)}}],e=0;e<h.length;e++)if(i=h[e],o=i.regex.exec(t),o){c=o[i.indices.bucket];s=o[i.indices.path];s||(s="");r=new n(c,s);i.postModify(r);break}if(null==r)throw function(n){return new f(u.INVALID_URL,"Invalid URL '"+n+"'.")}(t);return r},n}();function gi(n){var t=n.lastIndexOf("/",n.length-2);return-1===t?n:n.slice(t+1)}function ot(n){return fi+ei+n}function nr(n){return fi+ar+n}function tr(n){var i=encodeURIComponent,t="?";return ut(n,function(n,r){var u=i(n)+"="+i(r);t=t+u+"&"}),t=t.slice(0,-1)}function dr(n,t){return t}o=function(){return function(n,t,i,r){this.server=n;this.local=t||n;this.writable=!!i;this.xform=r||dr}}();st=null;function gr(){var n,t,i;return st?st:(n=[],n.push(new o("bucket")),n.push(new o("generation")),n.push(new o("metageneration")),n.push(new o("name","fullPath",!0)),t=new o("name"),t.xform=function(n,t){return function(n){return!d(n)||n.length<2?n:gi(n=n)}(t)},n.push(t),i=new o("size"),i.xform=function(n,t){return h(t)?+t:t},n.push(i),n.push(new o("timeCreated")),n.push(new o("updated")),n.push(new o("md5Hash",null,!0)),n.push(new o("cacheControl",null,!0)),n.push(new o("contentDisposition",null,!0)),n.push(new o("contentEncoding",null,!0)),n.push(new o("contentLanguage",null,!0)),n.push(new o("contentType",null,!0)),n.push(new o("metadata","customMetadata",!0)),st=n)}function nu(n,t,i){for(var u,r={type:"file"},e=i.length,f=0;f<e;f++)u=i[f],r[u.local]=u.xform(r,t[u.server]);return function(n,t){Object.defineProperty(n,"ref",{get:function(){var i=n.bucket,r=n.fullPath,u=new c(i,r);return t.makeStorageReference(u)}})}(r,n),r}function ir(n,t,i){var r=di(t);return null===r?null:nu(n,r,i)}function tu(n,t){var i=di(t),r,u;return null===i?null:d(i.downloadTokens)?(r=i.downloadTokens,0===r.length)?null:(u=encodeURIComponent,r.split(",").map(function(t){var i=n.bucket,r=n.fullPath;return function(n){return lr+ei+n}("/b/"+u(i)+"/o/"+u(r))+tr({alt:"media",token:t})})[0]):null}function ti(n,t){for(var i,u={},f=t.length,r=0;r<f;r++)i=t[r],i.writable&&(u[i.server]=n[i.local]);return JSON.stringify(u)}function iu(n){var t,i;if(!(n&&ft(n)))throw"Expected Metadata object.";for(t in n)if(i=n[t],"customMetadata"===t){if(!ft(i))throw"Expected object for 'customMetadata' mapping.";}else if(kr(i))throw"Mapping for '"+t+"' cannot be an object.";}function e(n,t,i){for(var e,s,a,v,h,c,o=t.length,l=t.length,r=0;r<t.length;r++)if(t[r].optional){o=r;break}if(!(o<=i.length&&i.length<=l))throw e=o,s=l,a=n,v=i.length,e===s?(h=e,c=1===e?"argument":"arguments"):(h="between "+e+" and "+s,c="arguments"),new f(u.INVALID_ARGUMENT_COUNT,"Invalid argument count in `"+a+"`: Expected "+h+" "+c+", received "+v+".");for(r=0;r<i.length;r++)try{t[r].validator(i[r])}catch(t){throw t instanceof Error?ci(r,n,t.message):ci(r,n,t);}}p=function(){return function(n,t){var i=this;this.validator=function(t){i.optional&&!a(t)||n(t)};this.optional=!!t}}();function w(n,t){function r(n){if(!d(n))throw"Expected string.";}var i,u,f;return n?(u=r,f=n,i=function(n){u(n);f(n)}):i=r,new p(i,t)}function ii(n){return new p(iu,n)}function rr(){return new p(function(n){if(!(function(n){return"number"==typeof n||n instanceof Number}(n)&&n>=0))throw"Expected a number 0 or greater.";})}function ri(n,t){return new p(function(t){if(!(null===t||h(t)&&t instanceof Object))throw"Expected an Object.";void 0!==n&&null!==n&&n(t)},t)}function g(n){return new p(function(n){if(null!==n&&!pi(n))throw"Expected a Function.";},n)}function ru(){return"undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof WebKitBlobBuilder?WebKitBlobBuilder:void 0}ht=function(){function n(n,t){var i=0,r="";wi(n)?(this.data_=n,i=n.size,r=n.type):n instanceof ArrayBuffer?(t?this.data_=new Uint8Array(n):(this.data_=new Uint8Array(n.byteLength),this.data_.set(new Uint8Array(n))),i=this.data_.length):n instanceof Uint8Array&&(t?this.data_=n:(this.data_=new Uint8Array(n.length),this.data_.set(n)),i=n.length);this.size_=i;this.type_=r}return n.prototype.size=function(){return this.size_},n.prototype.type=function(){return this.type_},n.prototype.slice=function(t,i){var o,e,r,u,f;return wi(this.data_)?(o=this.data_,e=(u=t,f=i,(r=o).webkitSlice?r.webkitSlice(u,f):r.mozSlice?r.mozSlice(u,f):r.slice?r.slice(u,f):null),null===e?null:new n(e)):new n(new Uint8Array(this.data_.buffer,t,i-t),!0)},n.getBlob=function(){for(var o,u,f,e,s,i=[],t=0;t<arguments.length;t++)i[t]=arguments[t];return et()?(o=i.map(function(t){return t instanceof n?t.data_:t}),new n(function(){for(var r,u,i,n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];if(r=ru(),void 0!==r){for(u=new r,i=0;i<n.length;i++)u.append(n[i]);return u.getBlob()}if(et())return new Blob(n);throw Error("This browser doesn't seem to support creating Blobs");}.apply(null,o))):(u=i.map(function(n){return d(n)?li(r.RAW,n).data:n.data_}),f=0,u.forEach(function(n){f+=n.byteLength}),e=new Uint8Array(f),s=0,u.forEach(function(n){for(var t=0;t<n.length;t++)e[s++]=n[t]}),new n(e,!0))},n.prototype.uploadData=function(){return this.data_},n}();function ct(n,t){return-1!==n.indexOf(t)}l=function(){return function(n,t,i,r){this.url=n;this.method=t;this.handler=i;this.timeout=r;this.urlParams={};this.headers={};this.body=null;this.errorHandler=null;this.progressCallback=null;this.successCodes=[200];this.additionalRetryCodes=[]}}();function v(n){if(!n)throw pt();}function lt(n,t){return function(i,r){var u=ir(n,r,t);return v(null!==u),u}}function nt(n){return function(t,i){var r,e,o;return 401===t.getStatus()?r=new f(u.UNAUTHENTICATED,"User is not authenticated, please authenticate using Firebase Authentication and try again."):402===t.getStatus()?(o=n.bucket,r=new f(u.QUOTA_EXCEEDED,"Quota for bucket '"+o+"' exceeded, please view quota on https://firebase.google.com/pricing/.")):403===t.getStatus()?(e=n.path,r=new f(u.UNAUTHORIZED,"User does not have permission to access '"+e+"'.")):r=i,r.setServerResponseProp(i.serverResponseProp()),r}}function at(n){var t=nt(n);return function(i,r){var o,e=t(i,r);return 404===i.getStatus()&&(o=n.path,e=new f(u.OBJECT_NOT_FOUND,"Object '"+o+"' does not exist.")),e.setServerResponseProp(r.serverResponseProp()),e}}function ur(n,t,i){var u=ot(t.fullServerUrl()),f=n.maxOperationRetryTime(),r=new l(u,"GET",lt(n,i),f);return r.errorHandler=at(t),r}function uu(n,t,i){var u=ot(t.fullServerUrl()),f=n.maxOperationRetryTime(),r=new l(u,"GET",function(n,t){return function(i,r){var u=ir(n,r,t);return v(null!==u),tu(u,r)}}(n,i),f);return r.errorHandler=at(t),r}function fr(n,t,i){var r=dt(i);return r.fullPath=n.path,r.size=t.size(),r.contentType||(r.contentType=function(n,t){return n&&n.contentType||t&&t.type()||"application/octet-stream"}(null,t)),r}tt=function(){return function(n,t,i,r){this.current=n;this.total=t;this.finalized=!!i;this.metadata=r||null}}();function ui(n,t){var i;try{i=n.getResponseHeader("X-Goog-Upload-Status")}catch(n){v(!1)}return v(ct(t||["active"],i)),i}function fu(n,t,i,r,e,o,s,h){var c=new tt(0,0),y,a,b,v;if(s?(c.current=s.current,c.total=s.total):(c.current=0,c.total=r.size()),r.size()!==c.total)throw new f(u.SERVER_FILE_WRONG_SIZE,"Server recorded incorrect upload file size, please retry the upload.");y=c.total-c.current;a=y;e>0&&(a=Math.min(a,e));var p=c.current,k=p+a,d={"X-Goog-Upload-Command":a===y?"upload, finalize":"upload","X-Goog-Upload-Offset":c.current},w=r.slice(p,k);if(null===w)throw hi();return b=t.maxUploadRetryTime(),v=new l(i,"POST",function(n,i){var u,f=ui(n,["active","final"]),e=c.current+a,s=r.size();return u="final"===f?lt(t,o)(n,i):null,new tt(e,s,"final"===f,u)},b),v.headers=d,v.body=w.uploadData(),v.progressCallback=h||null,v.errorHandler=nt(n),v}er=function(){return function(n,t,i){if(pi(n)||h(t)||h(i))this.next=n,this.error=t||null,this.complete=i||null;else{var r=n;this.next=r.next||null;this.error=r.error||null;this.complete=r.complete||null}}}();or=function(){return function(n,t,i,r,u,f){this.bytesTransferred=n;this.totalBytes=t;this.state=i;this.metadata=r;this.task=u;this.ref=f}}();function b(n){return function(){for(var i=[],t=0;t<arguments.length;t++)i[t]=arguments[t];ni(!0).then(function(){n.apply(null,i)})}}var sr=function(){function n(n,t,r,f,e,o){void 0===o&&(o=null);var s=this;this.transferred_=0;this.needToFetchStatus_=!1;this.needToFetchMetadata_=!1;this.observers_=[];this.error_=null;this.uploadUrl_=null;this.request_=null;this.chunkMultiplier_=1;this.resolve_=null;this.reject_=null;this.ref_=n;this.authWrapper_=t;this.location_=r;this.blob_=e;this.metadata_=o;this.mappings_=f;this.resumable_=this.shouldDoResumable_(this.blob_);this.state_=i.RUNNING;this.errorHandler_=function(n){s.request_=null;s.chunkMultiplier_=1;n.codeEquals(u.CANCELED)?(s.needToFetchStatus_=!0,s.completeTransitions_()):(s.error_=n,s.transition_(i.ERROR))};this.metadataErrorHandler_=function(n){s.request_=null;n.codeEquals(u.CANCELED)?s.completeTransitions_():(s.error_=n,s.transition_(i.ERROR))};this.promise_=gt(function(n,t){s.resolve_=n;s.reject_=t;s.start_()});this.promise_.then(null,function(){})}return n.prototype.makeProgressCallback_=function(){var n=this,t=this.transferred_;return function(i){n.updateProgress_(t+i)}},n.prototype.shouldDoResumable_=function(n){return n.size()>262144},n.prototype.start_=function(){this.state_===i.RUNNING&&null===this.request_&&(this.resumable_?null===this.uploadUrl_?this.createResumable_():this.needToFetchStatus_?this.fetchStatus_():this.needToFetchMetadata_?this.fetchMetadata_():this.continueUpload_():this.oneShotUpload_())},n.prototype.resolveToken_=function(n){var t=this;this.authWrapper_.getAuthToken().then(function(r){switch(t.state_){case i.RUNNING:n(r);break;case i.CANCELING:t.transition_(i.CANCELED);break;case i.PAUSING:t.transition_(i.PAUSED)}})},n.prototype.createResumable_=function(){var n=this;this.resolveToken_(function(t){var r=function(n,t,i,r,u){var o=t.bucketOnlyServerUrl(),e=fr(t,r,u),s={name:e.fullPath},h=nr(o),c={"X-Goog-Upload-Protocol":"resumable","X-Goog-Upload-Command":"start","X-Goog-Upload-Header-Content-Length":r.size(),"X-Goog-Upload-Header-Content-Type":e.contentType,"Content-Type":"application/json; charset=utf-8"},a=ti(e,i),y=n.maxUploadRetryTime(),f=new l(h,"POST",function(n){var t;ui(n);try{t=n.getResponseHeader("X-Goog-Upload-URL")}catch(n){v(!1)}return v(d(t)),t},y);return f.urlParams=s,f.headers=c,f.body=a,f.errorHandler=nt(t),f}(n.authWrapper_,n.location_,n.mappings_,n.blob_,n.metadata_),i=n.authWrapper_.makeRequest(r,t);n.request_=i;i.getPromise().then(function(t){n.request_=null;n.uploadUrl_=t;n.needToFetchStatus_=!1;n.completeTransitions_()},n.errorHandler_)})},n.prototype.fetchStatus_=function(){var n=this,t=this.uploadUrl_;this.resolveToken_(function(i){var u=function(n,t,i,r){var f=n.maxUploadRetryTime(),u=new l(i,"POST",function(n){var i,u=ui(n,["active","final"]),t;try{i=n.getResponseHeader("X-Goog-Upload-Size-Received")}catch(n){v(!1)}return t=parseInt(i,10),v(!isNaN(t)),new tt(t,r.size(),"final"===u)},f);return u.headers={"X-Goog-Upload-Command":"query"},u.errorHandler=nt(t),u}(n.authWrapper_,n.location_,t,n.blob_),r=n.authWrapper_.makeRequest(u,i);n.request_=r;r.getPromise().then(function(t){t=t;n.request_=null;n.updateProgress_(t.current);n.needToFetchStatus_=!1;t.finalized&&(n.needToFetchMetadata_=!0);n.completeTransitions_()},n.errorHandler_)})},n.prototype.continueUpload_=function(){var n=this,t=262144*this.chunkMultiplier_,r=new tt(this.transferred_,this.blob_.size()),u=this.uploadUrl_;this.resolveToken_(function(f){var o,e;try{o=fu(n.location_,n.authWrapper_,u,n.blob_,t,n.mappings_,r,n.makeProgressCallback_())}catch(t){return n.error_=t,void n.transition_(i.ERROR)}e=n.authWrapper_.makeRequest(o,f);n.request_=e;e.getPromise().then(function(t){n.increaseMultiplier_();n.request_=null;n.updateProgress_(t.current);t.finalized?(n.metadata_=t.metadata,n.transition_(i.SUCCESS)):n.completeTransitions_()},n.errorHandler_)})},n.prototype.increaseMultiplier_=function(){262144*this.chunkMultiplier_<33554432&&(this.chunkMultiplier_*=2)},n.prototype.fetchMetadata_=function(){var n=this;this.resolveToken_(function(t){var u=ur(n.authWrapper_,n.location_,n.mappings_),r=n.authWrapper_.makeRequest(u,t);n.request_=r;r.getPromise().then(function(t){n.request_=null;n.metadata_=t;n.transition_(i.SUCCESS)},n.metadataErrorHandler_)})},n.prototype.oneShotUpload_=function(){var n=this;this.resolveToken_(function(t){var u=function(n,t,i,r,u){var c=t.bucketOnlyServerUrl(),s={"X-Goog-Upload-Protocol":"multipart"},e=function(){for(var n="",t=0;t<2;t++)n+=Math.random().toString().slice(2);return n}();s["Content-Type"]="multipart/related; boundary="+e;var o=fr(t,r,u),a="--"+e+"\r\nContent-Type: application/json; charset=utf-8\r\n\r\n"+ti(o,i)+"\r\n--"+e+"\r\nContent-Type: "+o.contentType+"\r\n\r\n",v="\r\n--"+e+"--",h=ht.getBlob(a,r,v);if(null===h)throw hi();var y={name:o.fullPath},p=nr(c),w=n.maxUploadRetryTime(),f=new l(p,"POST",lt(n,i),w);return f.urlParams=y,f.headers=s,f.body=h.uploadData(),f.errorHandler=nt(t),f}(n.authWrapper_,n.location_,n.mappings_,n.blob_,n.metadata_),r=n.authWrapper_.makeRequest(u,t);n.request_=r;r.getPromise().then(function(t){n.request_=null;n.metadata_=t;n.updateProgress_(n.blob_.size());n.transition_(i.SUCCESS)},n.errorHandler_)})},n.prototype.updateProgress_=function(n){var t=this.transferred_;this.transferred_=n;this.transferred_!==t&&this.notifyObservers_()},n.prototype.transition_=function(n){if(this.state_!==n)switch(n){case i.CANCELING:case i.PAUSING:this.state_=n;null!==this.request_&&this.request_.cancel();break;case i.RUNNING:var t=this.state_===i.PAUSED;this.state_=n;t&&(this.notifyObservers_(),this.start_());break;case i.PAUSED:this.state_=n;this.notifyObservers_();break;case i.CANCELED:this.error_=si();this.state_=n;this.notifyObservers_();break;case i.ERROR:case i.SUCCESS:this.state_=n;this.notifyObservers_()}},n.prototype.completeTransitions_=function(){switch(this.state_){case i.PAUSING:this.transition_(i.PAUSED);break;case i.CANCELING:this.transition_(i.CANCELED);break;case i.RUNNING:this.start_()}},Object.defineProperty(n.prototype,"snapshot",{get:function(){var n=kt(this.state_);return new or(this.transferred_,this.blob_.size(),n,this.metadata_,this,this.ref_)},enumerable:!0,configurable:!0}),n.prototype.on=function(n,t,i,r){function o(n){try{return void c(n)}catch(n){}try{if(l(n),!(a(n.next)||a(n.error)||a(n.complete)))throw"";return}catch(n){throw f;}}function s(n){return function(t,i){null!==n&&e("on",n,arguments);var f=new er(t,i,r);return u.addObserver_(f),function(){u.removeObserver_(f)}}}var u,h;void 0===t&&(t=void 0);void 0===i&&(i=void 0);void 0===r&&(r=void 0);var f="Expected a function or an Object with one of `next`, `error`, `complete` properties.",c=g(!0).validator,l=ri(null,!0).validator;return e("on",[w(function(){if(n!==bt.STATE_CHANGED)throw"Expected one of the event types: ["+bt.STATE_CHANGED+"].";}),ri(o,!0),g(!0),g(!0)],arguments),u=this,h=[ri(function(n){if(null===n)throw f;o(n)}),g(!0),g(!0)],(a(t)||a(i)||a(r))?s(null)(t,i,r):s(h)},n.prototype.then=function(n,t){return this.promise_.then(n,t)},n.prototype.catch=function(n){return this.then(null,n)},n.prototype.addObserver_=function(n){this.observers_.push(n);this.notifyObserver_(n)},n.prototype.removeObserver_=function(n){var t,i,r;t=this.observers_;i=n;-1!==(r=t.indexOf(i))&&t.splice(r,1)},n.prototype.notifyObservers_=function(){var n,t=this;this.finishPromise_();(n=this.observers_,Array.prototype.slice.call(n)).forEach(function(n){t.notifyObserver_(n)})},n.prototype.finishPromise_=function(){if(null!==this.resolve_){var n=!0;switch(kt(this.state_)){case s.SUCCESS:b(this.resolve_.bind(null,this.snapshot))();break;case s.CANCELED:case s.ERROR:b(this.reject_.bind(null,this.error_))();break;default:n=!1}n&&(this.resolve_=null,this.reject_=null)}},n.prototype.notifyObserver_=function(n){switch(kt(this.state_)){case s.RUNNING:case s.PAUSED:null!==n.next&&b(n.next.bind(n,this.snapshot))();break;case s.SUCCESS:null!==n.complete&&b(n.complete.bind(n))();break;case s.CANCELED:case s.ERROR:null!==n.error&&b(n.error.bind(n,this.error_))();break;default:null!==n.error&&b(n.error.bind(n,this.error_))()}},n.prototype.resume=function(){e("resume",[],arguments);var n=this.state_===i.PAUSED||this.state_===i.PAUSING;return n&&this.transition_(i.RUNNING),n},n.prototype.pause=function(){e("pause",[],arguments);var n=this.state_===i.RUNNING;return n&&this.transition_(i.PAUSING),n},n.prototype.cancel=function(){e("cancel",[],arguments);var n=this.state_===i.RUNNING||this.state_===i.PAUSING;return n&&this.transition_(i.CANCELING),n},n}(),vt=function(){function n(n,t){this.authWrapper=n;this.location=t instanceof c?t:c.makeFromUrl(t)}return n.prototype.toString=function(){return e("toString",[],arguments),"gs://"+this.location.bucket+"/"+this.location.path},n.prototype.newRef=function(t,i){return new n(t,i)},n.prototype.mappings=function(){return gr()},n.prototype.child=function(n){e("child",[w()],arguments);var t=function(n,t){var i=t.split("/").filter(function(n){return n.length>0}).join("/");return 0===n.length?i:n+"/"+i}(this.location.path,n),i=new c(this.location.bucket,t);return this.newRef(this.authWrapper,i)},Object.defineProperty(n.prototype,"parent",{get:function(){var n=function(n){if(0==n.length)return null;var t=n.lastIndexOf("/");return-1===t?"":n.slice(0,t)}(this.location.path),t;return null===n?null:(t=new c(this.location.bucket,n),this.newRef(this.authWrapper,t))},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"root",{get:function(){var n=new c(this.location.bucket,"");return this.newRef(this.authWrapper,n)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"bucket",{get:function(){return this.location.bucket},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"fullPath",{get:function(){return this.location.path},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"name",{get:function(){return gi(this.location.path)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"storage",{get:function(){return this.authWrapper.service()},enumerable:!0,configurable:!0}),n.prototype.put=function(n,t){return void 0===t&&(t=null),e("put",[new p(function(n){if(!(n instanceof Uint8Array||n instanceof ArrayBuffer||et()&&n instanceof Blob))throw"Expected Blob or File.";}),ii(!0)],arguments),this.throwIfRoot_("put"),new sr(this,this.authWrapper,this.location,this.mappings(),new ht(n),t)},n.prototype.putString=function(n,t,i){void 0===t&&(t=r.RAW);e("putString",[w(),w(wr,!0),ii(!0)],arguments);this.throwIfRoot_("putString");var u=li(t,n),f=dt(i);return!h(f.contentType)&&h(u.contentType)&&(f.contentType=u.contentType),new sr(this,this.authWrapper,this.location,this.mappings(),new ht(u.data,!0),f)},n.prototype.delete=function(){e("delete",[],arguments);this.throwIfRoot_("delete");var n=this;return this.authWrapper.getAuthToken().then(function(t){var i=function(n,t){var r=ot(t.fullServerUrl()),u=n.maxOperationRetryTime(),i=new l(r,"DELETE",function(){},u);return i.successCodes=[200,204],i.errorHandler=at(t),i}(n.authWrapper,n.location);return n.authWrapper.makeRequest(i,t).getPromise()})},n.prototype.getMetadata=function(){e("getMetadata",[],arguments);this.throwIfRoot_("getMetadata");var n=this;return this.authWrapper.getAuthToken().then(function(t){var i=ur(n.authWrapper,n.location,n.mappings());return n.authWrapper.makeRequest(i,t).getPromise()})},n.prototype.updateMetadata=function(n){e("updateMetadata",[ii()],arguments);this.throwIfRoot_("updateMetadata");var t=this;return this.authWrapper.getAuthToken().then(function(i){var r=function(n,t,i,r){var f=ot(t.fullServerUrl()),e=ti(i,r),o=n.maxOperationRetryTime(),u=new l(f,"PATCH",lt(n,r),o);return u.headers={"Content-Type":"application/json; charset=utf-8"},u.body=e,u.errorHandler=at(t),u}(t.authWrapper,t.location,n,t.mappings());return t.authWrapper.makeRequest(r,i).getPromise()})},n.prototype.getDownloadURL=function(){e("getDownloadURL",[],arguments);this.throwIfRoot_("getDownloadURL");var n=this;return this.authWrapper.getAuthToken().then(function(t){var i=uu(n.authWrapper,n.location,n.mappings());return n.authWrapper.makeRequest(i,t).getPromise().then(function(n){if(null===n)throw new f(u.NO_DOWNLOAD_URL,"The given file does not have any download URLs.");return n})})},n.prototype.throwIfRoot_=function(n){if(""===this.location.path)throw function(n){return new f(u.INVALID_ROOT_OPERATION,"The operation '"+n+"' cannot be performed on a root reference, create a non-root reference using child, such as .child('file.png').")}(n);},n}(),eu=function(){function n(n){this.promise_=function(n){return Promise.reject(n)}(n)}return n.prototype.getPromise=function(){return this.promise_},n.prototype.cancel=function(n){void 0===n&&(n=!1)},n}(),ou=function(){function n(){this.map_={};this.id_=pr}return n.prototype.addRequest=function(n){function r(){delete i.map_[t]}var t=this.id_,i;this.id_++;this.map_[t]=n;i=this;n.getPromise().then(r,r)},n.prototype.clear=function(){ut(this.map_,function(n,t){t&&t.cancel(!0)});this.map_={}},n}(),su=function(){function n(t,i,r,u,f){if(this.bucket_=null,this.deleted_=!1,this.app_=t,null!==this.app_){var e=this.app_.options;h(e)&&(this.bucket_=n.extractBucket_(e))}this.storageRefMaker_=i;this.requestMaker_=r;this.pool_=f;this.service_=u;this.maxOperationRetryTime_=vr;this.maxUploadRetryTime_=yr;this.requestMap_=new ou}return n.extractBucket_=function(n){var t=n.storageBucket||null;return null==t?null:c.makeFromBucketSpec(t).bucket},n.prototype.getAuthToken=function(){return null!==this.app_&&h(this.app_.INTERNAL)&&h(this.app_.INTERNAL.getToken)?this.app_.INTERNAL.getToken().then(function(n){return null!==n?n.accessToken:null},function(){return null}):ni(null)},n.prototype.bucket=function(){if(this.deleted_)throw wt();return this.bucket_},n.prototype.service=function(){return this.service_},n.prototype.makeStorageReference=function(n){return this.storageRefMaker_(this,n)},n.prototype.makeRequest=function(n,t){if(this.deleted_)return new eu(wt());var i=this.requestMaker_(n,t,this.pool_);return this.requestMap_.addRequest(i),i},n.prototype.deleteApp=function(){this.deleted_=!0;this.app_=null;this.requestMap_.clear()},n.prototype.maxUploadRetryTime=function(){return this.maxUploadRetryTime_},n.prototype.setMaxUploadRetryTime=function(n){this.maxUploadRetryTime_=n},n.prototype.maxOperationRetryTime=function(){return this.maxOperationRetryTime_},n.prototype.setMaxOperationRetryTime=function(n){this.maxOperationRetryTime_=n},n}(),hu=function(){function n(n,t,i,r,u,f,e,o,s,h,c){this.pendingXhr_=null;this.backoffId_=null;this.resolve_=null;this.reject_=null;this.canceled_=!1;this.appDelete_=!1;this.url_=n;this.method_=t;this.headers_=i;this.body_=r;this.successCodes_=u.slice();this.additionalRetryCodes_=f.slice();this.callback_=e;this.errorCallback_=o;this.progressCallback_=h;this.timeout_=s;this.pool_=c;var l=this;this.promise_=gt(function(n,t){l.resolve_=n;l.reject_=t;l.start_()})}return n.prototype.start_=function(){function t(t,i){var r,h=n.resolve_,e=n.reject_,o=i.xhr,s;if(i.wasSuccessCode)try{s=n.callback_(o,o.getResponseText());a(s)?h(s):h()}catch(n){e(n)}else null!==o?((r=pt()).setServerResponseProp(o.getResponseText()),n.errorCallback_?e(n.errorCallback_(o,r)):e(r)):i.canceled?e(r=n.appDelete_?wt():si()):e(r=new f(u.RETRY_LIMIT_EXCEEDED,"Max retry time for operation exceeded, please try again."))}var n=this;this.canceled_?t(0,new yt(!1,null,!0)):this.backoffId_=function(n,t,i){function h(){return 2===r}function c(){f||(f=!0,t.apply(null,arguments))}function o(t){u=setTimeout(function(){u=null;n(v,h())},t)}function v(n){for(var i,u=[],t=1;t<arguments.length;t++)u[t-1]=arguments[t];f||(n?c.apply(null,arguments):h()||s?c.apply(null,arguments):(e<64&&(e*=2),1===r?(r=2,i=0):i=1e3*(e+Math.random()),o(i)))}function a(n){l||(l=!0,f||(null!==u?(n||(r=2),clearTimeout(u),o(0)):n||(r=1)))}var e=1,u=null,s=!1,r=0,f=!1,l=!1;return o(0),setTimeout(function(){s=!0;a(!0)},i),a}(function(t,i){function u(t){var i=t.loaded,r=t.lengthComputable?t.total:-1;null!==n.progressCallback_&&n.progressCallback_(i,r)}if(i)t(!1,new yt(!1,null,!0));else{var r=n.pool_.createXhrIo();n.pendingXhr_=r;null!==n.progressCallback_&&r.addUploadProgressListener(u);r.send(n.url_,n.method_,n.body_,n.headers_).then(function(i){var f,r,e,o;null!==n.progressCallback_&&i.removeUploadProgressListener(u);n.pendingXhr_=null;f=(i=i).getErrorCode()===y.NO_ERROR;r=i.getStatus();f&&!n.isRetryStatusCode_(r)?(e=ct(n.successCodes_,r),t(!0,new yt(e,i))):(o=i.getErrorCode()===y.ABORT,t(!1,new yt(!1,null,o)))})}},t,this.timeout_)},n.prototype.getPromise=function(){return this.promise_},n.prototype.cancel=function(n){this.canceled_=!0;this.appDelete_=n||!1;null!==this.backoffId_&&this.backoffId_(!1);null!==this.pendingXhr_&&this.pendingXhr_.abort()},n.prototype.isRetryStatusCode_=function(n){var t=n>=500&&n<600,i=ct([408,429],n),r=ct(this.additionalRetryCodes_,n);return t||i||r},n}(),yt=function(){return function(n,t,i){this.wasSuccessCode=n;this.xhr=t;this.canceled=!!i}}();function cu(n,i,r){var f=tr(n.urlParams),e=n.url+f,u=dt(n.headers);return function(n,t){null!==t&&t.length>0&&(n.Authorization="Firebase "+t)}(u,i),function(n){var i=void 0!==t?t.SDK_VERSION:"AppManager";n["X-Firebase-Storage-Version"]="webjs/"+i}(u),new hu(e,n.method,u,n.body,n.successCodes,n.additionalRetryCodes,n.handler,n.errorHandler,n.timeout,n.progressCallback,r)}var hr=function(){function n(n,t,i){if(this.bucket_=null,this.authWrapper_=new su(n,function(n,t){return new vt(n,t)},cu,this,t),this.app_=n,null!=i)this.bucket_=c.makeFromBucketSpec(i);else{var r=this.authWrapper_.bucket();null!=r&&(this.bucket_=new c(r,""))}this.internals_=new lu(this)}return n.prototype.ref=function(n){if(e("ref",[w(function(n){if(/^[A-Za-z]+:\/\//.test(n))throw"Expected child path but got a URL, use refFromURL instead.";},!0)],arguments),null==this.bucket_)throw new Error("No Storage Bucket defined in Firebase Options.");var t=new vt(this.authWrapper_,this.bucket_);return null!=n?t.child(n):t},n.prototype.refFromURL=function(n){return e("refFromURL",[w(function(n){if(!/^[A-Za-z]+:\/\//.test(n))throw"Expected full URL but got a child path, use ref instead.";try{c.makeFromUrl(n)}catch(n){throw"Expected valid full URL but got an invalid one.";}},!1)],arguments),new vt(this.authWrapper_,n)},Object.defineProperty(n.prototype,"maxUploadRetryTime",{get:function(){return this.authWrapper_.maxUploadRetryTime()},enumerable:!0,configurable:!0}),n.prototype.setMaxUploadRetryTime=function(n){e("setMaxUploadRetryTime",[rr()],arguments);this.authWrapper_.setMaxUploadRetryTime(n)},Object.defineProperty(n.prototype,"maxOperationRetryTime",{get:function(){return this.authWrapper_.maxOperationRetryTime()},enumerable:!0,configurable:!0}),n.prototype.setMaxOperationRetryTime=function(n){e("setMaxOperationRetryTime",[rr()],arguments);this.authWrapper_.setMaxOperationRetryTime(n)},Object.defineProperty(n.prototype,"app",{get:function(){return this.app_},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"INTERNAL",{get:function(){return this.internals_},enumerable:!0,configurable:!0}),n}(),lu=function(){function n(n){this.service_=n}return n.prototype.delete=function(){return this.service_.authWrapper_.deleteApp(),ni(void 0)},n}(),au="storage";function vu(n,t,i){return new hr(n,new ki,i)}cr={TaskState:s,TaskEvent:bt,StringFormat:r,Storage:hr,Reference:vt};t.INTERNAL.registerService(au,vu,cr,void 0,!0)}catch(n){throw console.error(n),new Error("Cannot instantiate firebase-storage - be sure to load firebase-app.js first.");}}(this.firebase=this.firebase||{},firebase);"use strict";var config={apiKey:"AIzaSyDVcqMbE8qYqnRkwdXbn9epRtlt-UzCjQc",databaseURL:"https://chat-box-plugin.firebaseio.com",storageBucket:"chat-box-plugin.appspot.com",authDomain:"chat-box-plugin.firebaseapp.com",messagingSenderId:"590147350260",projectId:"chat-box-plugin"};firebase.initializeApp(config);checkSetup();initFirebaseAuth()