!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(require("@firebase/app")):"function"==typeof define&&define.amd?define(["@firebase/app"],e):e((t=t||self).firebase)}(this,function(Vi){"use strict";try{(function(){Vi=Vi&&Vi.hasOwnProperty("default")?Vi.default:Vi;var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function t(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var u=function(){return(u=Object.assign||function(t){for(var e,n=1,r=arguments.length;ns[0]&&e[1]=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}}function _(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,o=n.call(t),s=[];try{for(;(void 0===e||0>6|192:(55296==(64512&i)&&r+1>18|240,e[n++]=i>>12&63|128):e[n++]=i>>12|224,e[n++]=i>>6&63|128),e[n++]=63&i|128)}return e}function a(t){try{return l.decodeString(t,!0)}catch(t){console.error("base64Decode failed: ",t)}return null}var h={NODE_CLIENT:!1,NODE_ADMIN:!1,SDK_VERSION:"${JSCORE_VERSION}"},C=function(t,e){if(!t)throw c(e)},c=function(t){return new Error("Firebase Database ("+h.SDK_VERSION+") INTERNAL ASSERT FAILED: "+t)},l={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:"function"==typeof atob,encodeByteArray:function(t,e){if(!Array.isArray(t))throw Error("encodeByteArray takes an array as a parameter");this.init_();for(var n=e?this.byteToCharMapWebSafe_:this.byteToCharMap_,r=[],i=0;i>2,c=(3&o)<<4|a>>4,p=(15&a)<<2|l>>6,d=63&l;h||(d=64,s||(p=64)),r.push(n[u],n[c],n[p],n[d])}return r.join("")},encodeString:function(t,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(t):this.encodeByteArray(s(t),e)},decodeString:function(t,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(t):function(t){for(var e=[],n=0,r=0;n>10)),e[r++]=String.fromCharCode(56320+(1023&s))}else{o=t[n++];var a=t[n++];e[r++]=String.fromCharCode((15&i)<<12|(63&o)<<6|63&a)}}return e.join("")}(this.decodeStringToByteArray(t,e))},decodeStringToByteArray:function(t,e){this.init_();for(var n=e?this.charToByteMapWebSafe_:this.charToByteMap_,r=[],i=0;i>4;if(r.push(l),64!==a){var u=s<<4&240|a>>2;if(r.push(u),64!==h){var c=a<<6&192|h;r.push(c)}}}return r},init_:function(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(var t=0;t=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(t)]=t,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(t)]=t)}}};function n(t){return function t(e,n){if(!(n instanceof Object))return n;switch(n.constructor){case Date:var r=n;return new Date(r.getTime());case Object:void 0===e&&(e={});break;case Array:e=[];break;default:return n}for(var i in n)n.hasOwnProperty(i)&&(e[i]=t(e[i],n[i]));return e}(void 0,t)}var p=(i.prototype.wrapCallback=function(n){var r=this;return function(t,e){t?r.reject(t):r.resolve(e),"function"==typeof n&&(r.promise.catch(function(){}),1===n.length?n(t):n(t,e))}},i);function i(){var n=this;this.reject=function(){},this.resolve=function(){},this.promise=new Promise(function(t,e){n.resolve=t,n.reject=e})}function d(){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:"")}function y(){return!0===h.NODE_ADMIN}var v,g=(t(m,v=Error),m);function m(t,e){var n=v.call(this,e)||this;return n.code=t,n.name="FirebaseError",Object.setPrototypeOf(n,m.prototype),Error.captureStackTrace&&Error.captureStackTrace(n,E.prototype.create),n}var E=(w.prototype.create=function(t){for(var e=[],n=1;n"})}(o,r):"Error",a=this.serviceName+": "+s+" ("+i+").",h=new g(i,a),l=0,u=Object.keys(r);l>>31)}var o,s,a=this.chain_[0],h=this.chain_[1],l=this.chain_[2],u=this.chain_[3],c=this.chain_[4];for(r=0;r<80;r++)s=r<40?r<20?(o=u^h&(l^u),1518500249):(o=h^l^u,1859775393):r<60?(o=h&l|u&(h|l),2400959708):(o=h^l^u,3395469782),i=(a<<5|a>>>27)+o+c+s+n[r]&4294967295,c=u,u=l,l=4294967295&(h<<30|h>>>2),h=a,a=i;this.chain_[0]=this.chain_[0]+a&4294967295,this.chain_[1]=this.chain_[1]+h&4294967295,this.chain_[2]=this.chain_[2]+l&4294967295,this.chain_[3]=this.chain_[3]+u&4294967295,this.chain_[4]=this.chain_[4]+c&4294967295},x.prototype.update=function(t,e){if(null!=t){void 0===e&&(e=t.length);for(var n=e-this.blockSize,r=0,i=this.buf_,o=this.inbuf_;r>i&255,++r;return t},x);function x(){this.chain_=[],this.buf_=[],this.W_=[],this.pad_=[],this.inbuf_=0,this.total_=0,this.blockSize=64,this.pad_[0]=128;for(var t=1;t 4. Need to update it?")}var i=t+" failed: ";return i+=r+" argument "}function A(t,e,n,r){if((!r||n)&&"function"!=typeof n)throw new Error(F(t,e,r)+"must be a valid function.")}function L(t,e,n,r){if((!r||n)&&("object"!=typeof n||null===n))throw new Error(F(t,e,r)+"must be a valid context object.")}function M(t){for(var e=0,n=0;n>6|192:(i<65536?e[n++]=i>>12|224:(e[n++]=i>>18|240,e[n++]=i>>12&63|128),e[n++]=i>>6&63|128),e[n++]=63&i|128)}return e}(t),n=new O;n.update(e);var r=n.digest();return l.encodeByteArray(r)}function X(t,e){C(!e||!0===t||!1===t,"Can't turn on custom loggers persistently."),!0===t?(lt.logLevel=W.VERBOSE,dt=lt.log.bind(lt),e&&ht.set("logging_enabled",!0)):"function"==typeof t?dt=t:(dt=null,ht.remove("logging_enabled"))}function $(){for(var t=[],e=0;e=Math.pow(2,-1022)?(n=(i=Math.min(Math.floor(Math.log(t)/Math.LN2),1023))+1023,Math.round(t*Math.pow(2,52-i)-Math.pow(2,52))):(n=0,Math.round(t/Math.pow(2,-1074)))),s=[],o=52;o;o-=1)s.push(r%2?1:0),r=Math.floor(r/2);for(o=11;o;o-=1)s.push(n%2?1:0),n=Math.floor(n/2);s.push(e?1:0),s.reverse(),a=s.join("");var h="";for(o=0;o<64;o+=8){var l=parseInt(a.substr(o,8),2).toString(16);1===l.length&&(l="0"+l),h+=l}return h.toLowerCase()}function Et(t){try{t()}catch(e){setTimeout(function(){var t=e.stack||"";throw et("Exception was thrown by user callback.",t),e},Math.floor(0))}}function wt(t,e){var n=setTimeout(t,e);return"object"==typeof n&&n.unref&&n.unref(),n}var bt=new RegExp("^-?\\d{1,10}$"),St=function(t){if(bt.test(t)){var e=Number(t);if(-2147483648<=e&&e<=2147483647)return e}return null},Tt=(Object.defineProperty(It,"Empty",{get:function(){return new It("")},enumerable:!0,configurable:!0}),It.prototype.getFront=function(){return this.pieceNum_>=this.pieces_.length?null:this.pieces_[this.pieceNum_]},It.prototype.getLength=function(){return this.pieces_.length-this.pieceNum_},It.prototype.popFront=function(){var t=this.pieceNum_;return t=this.pieces_.length)return null;for(var t=[],e=this.pieceNum_;e=this.pieces_.length},It.relativePath=function(t,e){var n=t.getFront(),r=e.getFront();if(null===n)return e;if(n===r)return It.relativePath(t.popFront(),e.popFront());throw new Error("INTERNAL ERROR: innerPath ("+e+") is not within outerPath ("+t+")")},It.comparePaths=function(t,e){for(var n=t.slice(),r=e.slice(),i=0;it.getLength())return!1;for(;eRt.MAX_PATH_LENGTH_BYTES)throw new Error(this.errorPrefix_+"has a key path longer than "+Rt.MAX_PATH_LENGTH_BYTES+" bytes ("+this.byteLength_+").");if(this.parts_.length>Rt.MAX_PATH_DEPTH)throw new Error(this.errorPrefix_+"path specified exceeds the maximum depth that can be written ("+Rt.MAX_PATH_DEPTH+") or object contains a cycle "+this.toErrorString())},Rt.prototype.toErrorString=function(){return 0==this.parts_.length?"":"in property '"+this.parts_.join(".")+"'"},Rt);function Rt(t,e){this.errorPrefix_=e,this.parts_=t.slice(),this.byteLength_=Math.max(1,this.parts_.length);for(var n=0;n"),t},kt.prototype.toURLString=function(){return(this.secure?"https://":"http://")+this.host},kt);function kt(t,e,n,r,i,o){void 0===i&&(i=""),void 0===o&&(o=!1),this.secure=e,this.namespace=n,this.webSocketOnly=r,this.persistenceKey=i,this.includeNamespaceInQueryParams=o,this.host=t.toLowerCase(),this.domain=this.host.substr(this.host.indexOf(".")+1),this.internalHost=at.get("host:"+t)||this.host}function Ft(t){var e=Kt(t),n=e.namespace;"firebase"===e.domain&&tt(e.host+" is no longer supported. Please use .firebaseio.com instead"),n&&"undefined"!=n||"localhost"===e.domain||tt("Cannot parse Firebase url. Please use https://.firebaseio.com"),e.secure||"undefined"!=typeof window&&window.location&&window.location.protocol&&-1!==window.location.protocol.indexOf("https:")&&et("Insecure Firebase access from a secure page. Please use https in calls to new Firebase().");var r="ws"===e.scheme||"wss"===e.scheme;return{repoInfo:new xt(e.host,e.secure,n,r,"",n!=e.subdomain),path:new Tt(e.pathString)}}function At(t){return"string"==typeof t&&0!==t.length&&!Yt.test(t)}function Lt(t){return"string"==typeof t&&0!==t.length&&!zt.test(t)}function Mt(t){return null===t||"string"==typeof t||"number"==typeof t&&!nt(t)||t&&"object"==typeof t&&N(t,".sv")}function Wt(t,e,n,r,i){i&&void 0===n||Xt(F(t,e,i),n,r)}function Qt(t,e,n,r,i){if(!i||void 0!==n){var o=F(t,e,i);if(!n||"object"!=typeof n||Array.isArray(n))throw new Error(o+" must be an object containing the children to replace.");var s=[];mt(n,function(t,e){var n=new Tt(t);if(Xt(o,e,r.child(n)),".priority"===n.getBack()&&!Mt(e))throw new Error(o+"contains an invalid value for '"+n.toString()+"', which must be a valid Firebase priority (a string, finite number, server value, or null).");s.push(n)}),function(t,e){var n,r;for(n=0;nGt/3&&M(t)>Gt)throw new Error(n+"contains a string greater than "+Gt+" utf8 bytes "+r.toErrorString()+" ('"+t.substring(0,50)+"...')");if(t&&"object"==typeof t){var i=!1,o=!1;if(mt(t,function(t,e){if(".value"===t)i=!0;else if(".priority"!==t&&".sv"!==t&&(o=!0,!At(t)))throw new Error(n+" contains an invalid key ("+t+") "+r.toErrorString()+'. Keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]"');r.push(t),Xt(n,e,r),r.pop()}),i&&o)throw new Error(n+' contains ".value" child '+r.toErrorString()+" in addition to actual children.")}},$t=(Jt.prototype.cancel=function(t){k("OnDisconnect.cancel",0,1,arguments.length),A("OnDisconnect.cancel",1,t,!0);var e=new p;return this.repo_.onDisconnectCancel(this.path_,e.wrapCallback(t)),e.promise},Jt.prototype.remove=function(t){k("OnDisconnect.remove",0,1,arguments.length),Bt("OnDisconnect.remove",this.path_),A("OnDisconnect.remove",1,t,!0);var e=new p;return this.repo_.onDisconnectSet(this.path_,null,e.wrapCallback(t)),e.promise},Jt.prototype.set=function(t,e){k("OnDisconnect.set",1,2,arguments.length),Bt("OnDisconnect.set",this.path_),Wt("OnDisconnect.set",1,t,this.path_,!1),A("OnDisconnect.set",2,e,!0);var n=new p;return this.repo_.onDisconnectSet(this.path_,t,n.wrapCallback(e)),n.promise},Jt.prototype.setWithPriority=function(t,e,n){k("OnDisconnect.setWithPriority",2,3,arguments.length),Bt("OnDisconnect.setWithPriority",this.path_),Wt("OnDisconnect.setWithPriority",1,t,this.path_,!1),qt("OnDisconnect.setWithPriority",2,e,!1),A("OnDisconnect.setWithPriority",3,n,!0);var r=new p;return this.repo_.onDisconnectSetWithPriority(this.path_,t,e,r.wrapCallback(n)),r.promise},Jt.prototype.update=function(t,e){if(k("OnDisconnect.update",1,2,arguments.length),Bt("OnDisconnect.update",this.path_),Array.isArray(t)){for(var n={},r=0;rthis.lastWriteId_,"Stacking an older write on top of newer ones"),void 0===r&&(r=!0),this.allWrites_.push({path:t,snap:e,writeId:n,visible:r}),r&&(this.visibleWrites_=this.visibleWrites_.addWrite(t,e)),this.lastWriteId_=n},lr.prototype.addMerge=function(t,e,n){C(n>this.lastWriteId_,"Stacking an older merge on top of newer ones"),this.allWrites_.push({path:t,children:e,writeId:n,visible:!0}),this.visibleWrites_=this.visibleWrites_.addWrites(t,e),this.lastWriteId_=n},lr.prototype.getWrite=function(t){for(var e=0;edocument.domain="'+document.domain+'";<\/script>');var o=""+i+"";try{this.myIFrame.doc.open(),this.myIFrame.doc.write(o),this.myIFrame.doc.close()}catch(t){$("frame writing exception"),t.stack&&$(t.stack),$(t)}}var Yr="";var zr=null;"undefined"!=typeof MozWebSocket?zr=MozWebSocket:"undefined"!=typeof WebSocket&&(zr=WebSocket);var Gr=(Xr.connectionURL_=function(t,e,n){var r={v:"5"};return"undefined"!=typeof location&&location.href&&-1!==location.href.indexOf(Pt)&&(r.r="f"),e&&(r.s=e),n&&(r.ls=n),t.connectionURL(Dt,r)},Xr.prototype.open=function(t,e){var n=this;this.onDisconnect=e,this.onMessage=t,this.log_("Websocket connecting to "+this.connURL),this.everConnected_=!1,at.set("previous_websocket_failure",!0);try{if(y()){var r=h.NODE_ADMIN?"AdminNode":"Node",i={headers:{"User-Agent":"Firebase/5/"+Yr+"/"+process.platform+"/"+r}},o=process.env,s=0==this.connURL.indexOf("wss://")?o.HTTPS_PROXY||o.https_proxy:o.HTTP_PROXY||o.http_proxy;s&&(i.proxy={origin:s}),this.mySock=new zr(this.connURL,[],i)}else this.mySock=new zr(this.connURL)}catch(t){this.log_("Error instantiating WebSocket.");var a=t.message||t.data;return a&&this.log_(a),void this.onClosed_()}this.mySock.onopen=function(){n.log_("Websocket connected."),n.everConnected_=!0},this.mySock.onclose=function(){n.log_("Websocket connection was disconnected."),n.mySock=null,n.onClosed_()},this.mySock.onmessage=function(t){n.handleIncomingFrame(t)},this.mySock.onerror=function(t){n.log_("WebSocket error. Closing connection.");var e=t.message||t.data;e&&n.log_(e),n.onClosed_()}},Xr.prototype.start=function(){},Xr.forceDisallow=function(){Xr.forceDisallow_=!0},Xr.isAvailable=function(){var t=!1;if("undefined"!=typeof navigator&&navigator.userAgent){var e=navigator.userAgent.match(/Android ([0-9]{0,}\.[0-9]{0,})/);e&&1=ui.MAX_TRANSACTION_RETRIES_)l=!0,u="maxretry",i=i.concat(this.serverSyncTree_.ackUserWrite(a.currentWriteId,!0));else{var c=this.getLatestState_(a.path,o);a.currentInputSnapshot=c;var p=t[s].update(c.val());if(void 0!==p){Xt("transaction failed: Data returned ",p,a.path);var d=$e(p);"object"==typeof p&&null!=p&&N(p,".priority")||(d=d.updatePriority(c.getPriority()));var f=a.currentWriteId,_=this.generateServerValues(),y=wn(d,_);a.currentOutputSnapshotRaw=d,a.currentOutputSnapshotResolved=y,a.currentWriteId=this.getNextWriteId_(),o.splice(o.indexOf(f),1),i=(i=i.concat(this.serverSyncTree_.applyUserOverwrite(a.path,y,a.currentWriteId,a.applyLocally))).concat(this.serverSyncTree_.ackUserWrite(f,!0))}else l=!0,u="nodata",i=i.concat(this.serverSyncTree_.ackUserWrite(a.currentWriteId,!0))}if(this.eventQueue_.raiseEventsForChangedPath(e,i),i=[],l&&(t[s].status=Ei.COMPLETED,n=t[s].unwatcher,setTimeout(n,Math.floor(0)),t[s].onComplete))if("nodata"===u){var v=new mi(this,t[s].path),g=t[s].currentInputSnapshot,m=new rn(g,v,Se);r.push(t[s].onComplete.bind(null,null,!1,m))}else r.push(t[s].onComplete.bind(null,new Error(u),!1,null))}this.pruneCompletedTransactionsBelowNode_(this.transactionQueueTree_);for(s=0;s