text: !function(t){var e={};function n(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(i,r,function(e){return t[e]}.bind(null,r));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=56)}([function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(3);e.default=class extends i.default{constructor(t,e){super(),this.m_rendered=!1,this.m_opened=!1,$(()=>{this.render(t,e||{}).then(t=>{this.m_dialog=$(t).popup({history:!1,overlayTheme:"b"}),this.m_dialog.on("popupafterclose",()=>this.m_opened=!1),this.m_dialog.on("popupafterclose",this.afterClose.bind(this)),this.m_dialog.on("popupafteropen",()=>this.m_opened=!0),this.m_dialog.on("popupafteropen",this.afterOpen.bind(this)),this.fixDateFields(),this.m_dialog.trigger("create"),this.m_rendered=!0,this.afterRender()})})}fixDateFields(){let t=this.m_dialog.find("input[type=date]");t.length<=0||"date"===t[0].type||t.each((t,e)=>{let n=e,i=n.id||"date-"+t,r=Date.parseFb($(n).val().toString());if("hidden"==n.type)return;n.type="hidden";let o=$('<select data-theme="a" data-inline="true" data-icon="false">',{id:i+"-month"});o.append(Date.MONTHS.map((t,e)=>$("<option>",{value:e+1,selected:e==r.getUTCMonth()}).text(t)));let s=$('<select data-theme="a" data-inline="true" data-icon="false">',{id:i+"-day"});for(let t=1;t<=r.daysInMonth();t++)s.append($("<option>",{value:t,selected:t==r.getUTCDate()}).text(t));let a=$('<select data-theme="a" data-inline="true" data-icon="false">',{id:i+"-year"});for(let t=2016;t<=2100;t++)a.append($("<option>",{value:t,selected:t==r.getUTCFullYear()}).text(t));function u(){let t=parseInt(o.val());return t>=10?t.toString():"0"+t.toString()}function c(){let t=parseInt(s.val());return t>=10?t.toString():"0"+t.toString()}function h(){let t=parseInt(a.val());return t>=1e3?t.toString():t>=100?"0"+t.toString():t>=10?"00"+t.toString():"000"+t.toString()}function l(){var t=h()+"-"+u()+"-"+c();console.log(t),$(n).val(Date.parseFb(t).toFbString())}a.on("change",l),o.on("change",()=>{!function(){var t=h()+"-"+u()+"-"+c(),e=Date.parseFb(t);if(e.getUTCMonth()!=o.val()+1){s.empty();for(let t=1;t<=e.daysInMonth();t++)s.append($("<option>",{value:t,selected:t==r.getUTCDate()}).text(t))}}(),l()}),s.on("change",l),$('<div style="min-height: 44px; width: 100%; position: relative"></div>').append($('<div class="ui-btn-left" data-role="controlgroup" data-theme="a" data-type="horizontal" data-mini="true"></div>').append(o,s,a)).insertAfter(n)})}afterRender(){this.m_dialog.parent().next().is(".ui-footer")&&this.m_dialog.append(this.m_dialog.parent().next()).enhanceWithin()}afterClose(){this.m_dialog.empty().remove(),$("#main").focus()}afterOpen(){}close(){return $(()=>{this.m_rendered?this.m_dialog.popup("close"):setTimeout(()=>this.close(),100)}),this}open(){return $(()=>{this.m_rendered?this.m_dialog.popup("open"):setTimeout(()=>this.open(),100)}),this}position(t){return!1===this.m_opened?this:($(()=>{this.m_rendered?this.m_dialog.popup("reposition",t||{positionTo:"window"}):setTimeout(()=>this.position(t),100)}),this)}get isMobile(){return"ontouchstart"in document.documentElement}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});class i{constructor(){$(()=>{$.mobile.loading()})}show(t){$(()=>{$.mobile.loading("show",{text:t||"",textVisible:!!t})})}hide(){$(()=>{$.mobile.loading("hide")})}static show(t){i.staticSpinner||(i.staticSpinner=new i),i.staticSpinner.show(t)}static hide(){i.staticSpinner||(i.staticSpinner=new i),i.staticSpinner.hide()}}e.default=i},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=function t(e){return class extends e{constructor(...t){super(...t),this.listeners={}}on(t,e,n){return this.listeners||(this.listeners={}),t in this.listeners==0&&(this.listeners[t]=[]),n&&e.bind(n),this.listeners[t].push(e),this}off(t,e){if(!this.listeners)return this;if(t in this.listeners==0)return this;if(e){let n=this.listeners[t].indexOf(e);n>=0&&this.listeners[t].splice(n,1)}else this.listeners[t]=[];return this}once(t,e,n){n&&e.bind(n);let i=(...n)=>{e(...n),this.off(t,i)};return this.on(t,i),this}emit(t,...e){if(!this.listeners)return this;if(t in this.listeners==0)return this;let n=new Array;for(let i of this.listeners[t])try{i(...e)}catch(t){n.push(t)}for(let t of n)throw t;return this}emitAsync(t,...e){if(!this.listeners)return Promise.resolve();let n=new Array;if(t in this.listeners==0)return Promise.resolve();for(let i of this.listeners[t])n.push(new Promise((t,n)=>{try{i(...e)}catch(t){return n(t)}t()}));return new Promise((t,e)=>{Promise.all(n).then(()=>{t()}).catch(t=>{e(t)})})}static Extend(e){return t(e)}}}(Object);e.default=i},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(2);e.default=class extends i.default{render(t,e){return new Promise((n,i)=>{e=e||{},ejs.renderFile(t,e,t=>{n(t)})})}}},function(t,e,n){"use strict";n.r(e),n(51)},function(t,e,n){"use strict";n.r(e),n(52)},function(t,e){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){(function(t){var i=void 0!==t&&t||"undefined"!=typeof self&&self||window,r=Function.prototype.apply;function o(t,e){this._id=t,this._clearFn=e}e.setTimeout=function(){return new o(r.call(setTimeout,i,arguments),clearTimeout)},e.setInterval=function(){return new o(r.call(setInterval,i,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t&&t.close()},o.prototype.unref=o.prototype.ref=function(){},o.prototype.close=function(){this._clearFn.call(i,this._id)},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},n(54),e.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==t&&t.setImmediate||this&&this.setImmediate,e.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==t&&t.clearImmediate||this&&this.clearImmediate}).call(this,n(6))},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(17),r=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o="[DEFAULT]",s=[],a=function(){function t(t,e,n){this.firebase_=n,this.isDeleted_=!1,this.services_={},this.name_=e.name,this._automaticDataCollectionEnabled=e.automaticDataCollectionEnabled||!1,this.options_=i.deepCopy(t),this.INTERNAL={getUid:function(){return null},getToken:function(){return Promise.resolve(null)},addAuthTokenListener:function(t){s.push(t),setTimeout(function(){return t(null)},0)},removeAuthTokenListener:function(t){s=s.filter(function(e){return e!==t})}}}return Object.defineProperty(t.prototype,"automaticDataCollectionEnabled",{get:function(){return this.checkDestroyed_(),this._automaticDataCollectionEnabled},set:function(t){this.checkDestroyed_(),this._automaticDataCollectionEnabled=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"name",{get:function(){return this.checkDestroyed_(),this.name_},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"options",{get:function(){return this.checkDestroyed_(),this.options_},enumerable:!0,configurable:!0}),t.prototype.delete=function(){var t=this;return new Promise(function(e){t.checkDestroyed_(),e()}).then(function(){t.firebase_.INTERNAL.removeApp(t.name_);var e=[];return Object.keys(t.services_).forEach(function(n){Object.keys(t.services_[n]).forEach(function(i){e.push(t.services_[n][i])})}),Promise.all(e.map(function(t){return t.INTERNAL.delete()}))}).then(function(){t.isDeleted_=!0,t.services_={}})},t.prototype._getService=function(t,e){if(void 0===e&&(e=o),this.checkDestroyed_(),this.services_[t]||(this.services_[t]={}),!this.services_[t][e]){var n=e!==o?e:void 0,i=this.firebase_.INTERNAL.factories[t](this,this.extendApp.bind(this),n);this.services_[t][e]=i}return this.services_[t][e]},t.prototype.extendApp=function(t){var e=this;i.deepExtend(this,t),t.INTERNAL&&t.INTERNAL.addAuthTokenListener&&(s.forEach(function(t){e.INTERNAL.addAuthTokenListener(t)}),s=[])},t.prototype.checkDestroyed_=function(){this.isDeleted_&&u("app-deleted",{name:this.name_})},t}();function u(t,e){throw c.create(t,e)}a.prototype.name&&a.prototype.options||a.prototype.delete||console.log("dc");var c=new i.ErrorFactory("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."}),h=function t(){var e={},n={},s={},c={__esModule:!0,initializeApp:function(t,n){(void 0===n&&(n={}),"object"!=typeof n||null===n)&&(n={name:n});var i=n;void 0===i.name&&(i.name=o);var s=i.name;"string"==typeof s&&s||u("bad-app-name",{name:s+""}),r(e,s)&&u("duplicate-app",{name:s});var h=new a(t,i,c);return e[s]=h,d(h,"create"),h},app:h,apps:null,Promise:Promise,SDK_VERSION:"5.0.4",INTERNAL:{registerService:function(t,e,r,o,d){n[t]&&u("duplicate-service",{name:t}),n[t]=e,o&&(s[t]=o,l().forEach(function(t){o("create",t)}));var f=function(e){return void 0===e&&(e=h()),"function"!=typeof e[t]&&u("invalid-app-argument",{name:t}),e[t]()};return void 0!==r&&i.deepExtend(f,r),c[t]=f,a.prototype[t]=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return this._getService.bind(this,t).apply(this,d?e:[])},f},createFirebaseNamespace:t,extendNamespace:function(t){i.deepExtend(c,t)},createSubscribe:i.createSubscribe,ErrorFactory:i.ErrorFactory,removeApp:function(t){d(e[t],"delete"),delete e[t]},factories:n,useAsService:f,Promise:Promise,deepExtend:i.deepExtend}};function h(t){return r(e,t=t||o)||u("no-app",{name:t}),e[t]}function l(){return Object.keys(e).map(function(t){return e[t]})}function d(t,e){Object.keys(n).forEach(function(n){var i=f(t,n);null!==i&&s[i]&&s[i](e,t)})}function f(t,e){if("serverAuth"===e)return null;var n=e;return t.options,n}return i.patchProperty(c,"default",c),Object.defineProperty(c,"apps",{get:l}),i.patchProperty(h,"App",a),c}();e.firebase=h,e.default=h},function(t,e,n){"use strict";n(55);var i,r=(i=n(8))&&"object"==typeof i&&"default"in i?i.default:i;t.exports=r},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(0);function r(t,e=!1){t.backDisabled=t.backDisabled||!1,t.nextDisabled=t.nextDisabled||!1,t.backText=t.backText||"Back",t.nextText=t.nextText||"Next",t.dismissible=e;for(let e=0;e<t.contents.length;e++)if("string"==typeof t.contents[e]){let n={type:"text",data:t.contents[e]};t.contents[e]=n}return t}window.mobile=function(){return"none"==$("#footer_info").css("display")};class o extends i.default{constructor(t,e=!1){if(t.length<=0)throw"No pages passed";super("wizard",r(t[0],e)),this.pages=t,this.pageIndex=0,this.dismissible=e}get NextEnabled(){return!this.nextButton.attr("disabled")}set NextEnabled(t){this.nextButton.attr("disabled",!t)}get BackEnabled(){return!this.backButton.attr("disabled")}set BackEnabled(t){this.backButton.attr("disabled",!t)}gotoPage(t){t=Math.min(this.pages.length-1,Math.max(0,t));let e=r(this.pages[t],this.dismissible);this.pageIndex=t,this.title.text(e.title),this.content.empty(),this.content.append(e.contents.map(t=>"image"==t.type?$(`<img src="${ejs.render(t.data,{})}" style="max-width: 100%; display: block; margin: 0 auto; max-height: 350px;">`):$("<p>").html(ejs.render(t.data,{})))),this.backButton.attr("disabled",e.backDisabled),this.nextButton.attr("disabled",e.nextDisabled),this.backButton.text(e.backText),this.nextButton.text(e.nextText),this.fixDateFields(),this.content.css("max-height",""),this.content.find("*").ready(()=>{this.m_dialog.trigger("create"),this.content.scrollTop(0),this.content_OnScroll(),this.emitAsync("page",e.id||e.title,this.pageIndex)})}afterRender(){super.afterRender(),this.title=this.m_dialog.find(".wizardTitle"),this.content=this.m_dialog.find(".wizardContent"),this.backButton=this.m_dialog.find(".wizardBackButton"),this.nextButton=this.m_dialog.find(".wizardNextButton"),this.scrollUp=this.m_dialog.find(".wizardScrollUp"),this.scrollDown=this.m_dialog.find(".wizardScrollDown");let t=this.m_dialog.css("background-color"),e=/^#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/i,n=/^#([a-f0-9])([a-f0-9])([a-f0-9])/i,i=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i,r=t;if(e.test(t)){let n=e.exec(t);r=`rgba(${parseInt(n[1],16)}, ${parseInt(n[2],16)}, ${parseInt(n[3],16)}, 0.5)`}else if(n.test(t)){let e=n.exec(t);r=`rgba(${parseInt(e[1]+e[1],16)}, ${parseInt(e[2]+e[2],16)}, ${parseInt(e[3]+e[3],16)}, 0.5)`}else if(i.test(t)){let e=i.exec(t);r=`rgba(${e[1]}, ${e[2]}, ${e[3]}, 0.5)`}this.scrollDown.css("background-color",r),this.scrollUp.css("background-color",r),this.backButton.on("click",()=>{this.gotoPage(this.pageIndex-1)}),this.nextButton.on("click",()=>{this.emit("beforepage",this.pages[this.pageIndex].id||this.pages[this.pageIndex].title,this.pageIndex),this.pageIndex+1>=this.pages.length?(this.close(),this.emit("done")):this.gotoPage(this.pageIndex+1)}),this.scrollDown.on("click",()=>{this.content.scrollTop(this.content.scrollTop()+this.content.height()/2)}),this.scrollUp.on("click",()=>{this.content.scrollTop(this.content.scrollTop()-this.content.height()/2)})}content_OnScroll(){this.content.scrollTop()>5?this.scrollUp.css("display","block"):this.scrollUp.css("display","none"),this.content.scrollTop()+this.content.outerHeight(!0)<this.content[0].scrollHeight-5?this.scrollDown.css("display","block"):this.scrollDown.css("display","none")}window_OnResize(){let t=.9*$(window).innerHeight(),e=this.m_dialog.find("[role=main]").outerHeight(!0)-this.m_dialog.find("[role=main]").height();this.m_dialog.css("height",t),this.m_dialog.css("width",Math.min(.9*$(window).innerWidth(),600)),this.content.css("height",t-this.m_dialog.find("[data-role=header]").outerHeight(!0)-this.backButton.outerHeight(!0)-e),this.scrollUp.css("width",this.content.css("width")),this.scrollDown.css("width",this.content.css("width")),this.scrollUp.css("left",this.content.position().left),this.scrollDown.css("left",this.content.position().left),this.scrollDown.css("top",this.content.innerHeight()-this.scrollDown.outerHeight(!0)+this.content.position().top)}afterOpen(){$(window).on("resize",this.window_OnResize.bind(this)),this.content.on("scroll",this.content_OnScroll.bind(this)),this.window_OnResize(),this.m_dialog.trigger("create"),this.position(),this.gotoPage(0)}}e.default=o,Object.defineProperty(window,"Wizard",{get:()=>o})},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(28);e.default=class extends i.default{constructor(){super("canvas"),this.m_ready=!1,this.m_drawing=!1,this.m_transactions=Array(),$(window).on("resize",this.window_OnResize.bind(this)),this.window_OnResize()}window_OnResize(){let t=.95*Math.min($(window).innerHeight(),$(window).innerWidth());this.Size.width=t,this.Size.height=t}onMouseMove(t){let e=this.m_dialog.find(".tooltip"),n=this.canvas[0].width/2,i=.8*this.canvas[0].height/2,r=t.offsetX-n,o=t.offsetY-i,s=.7*Math.min(this.canvas[0].width,this.canvas[0].height)/2;if(Math.sqrt(r*r+o*o)<=s){e.css({display:"",top:t.offsetY+30+"px",left:t.offsetX+25+"px"});let n=Math.atan2(o,r)+Math.PI/2,i=0,s={};n<0&&(n=2*Math.PI+n);for(let t of this.m_transactions)t.amount>=0||(t.category in s==0&&(s[t.category]=0),s[t.category]-=t.amount,i-=t.amount);let a=0;for(let t in s){let r=s[t];if((a+=2*Math.PI*r/i)>=n){e.text(t+" "+r.toCurrency());break}}}else e.css("display","none")}onPaint(t){this.m_ready=!0,this.paint(t)}afterClose(){this.m_dialog.find(".tooltip").remove(),super.afterClose()}paint(t){if(0!=this.m_ready&&this.m_transactions&&!(this.m_transactions.length<=0)&&!1===this.m_drawing){this.canvas.off("mousemove").on("mousemove",this.onMouseMove.bind(this)),this.m_drawing=!0;let e=0,n={};for(let t of this.m_transactions)t.amount>=0||(t.category in n==0&&(n[t.category]=0),n[t.category]-=t.amount,e-=t.amount);t.save(),t.clearRect(0,0,t.canvas.width,t.canvas.height);let i=.7*Math.min(t.canvas.width,t.canvas.height)/2;t.font=Math.round(.05*i)+'pt -apple-system, "SF Pro Display", BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif',t.textAlign="center",t.textBaseline="middle";let r=`${Date.parseFb(this.m_start).format("MMM d, yyyy")} to ${Date.parseFb(this.m_end).format("MMM d, yyyy")}`;this.m_dialog.find("[data-role=header] h3").text(r),t.translate(t.canvas.width/2,t.canvas.height/2*.8),t.rotate(-Math.PI/2);let o=0,s=["#4472c4","#ed7d31","#a5a5a5","#ffc000","#5b9bd5","#70ad47","#264478","#9e480e","#636363","#997300","#255e91","#43682b","#698ed0","#f1975a","#b7b7b7"];for(let r in n){let a=n[r],u=2*Math.PI*a/e;t.fillStyle=s[o++%s.length],t.beginPath(),t.moveTo(0,0),t.lineTo(i,0),t.arc(0,0,i,0,u),t.rotate(u),t.moveTo(0,0),t.lineTo(i,0),t.fill()}t.beginPath(),t.arc(0,0,i,0,360),t.stroke(),o=0,t.restore(),t.font=Math.round(.05*i)+'pt -apple-system, "SF Pro Display", BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif',t.textAlign="left",t.textBaseline="middle";let a=0;for(let e in n)a=Math.max(a,t.measureText(e).width);let u=a+25,c=Math.floor((t.canvas.width-40)/u),h=(t.canvas.width-c*u)/2,l=h;t.translate(h,.8*t.canvas.height+5);for(let e in n)t.fillStyle="black",t.fillText(e,15,-Math.round(.0625*i),a),t.fillText(n[e].toCurrency(),15,0,a),t.fillStyle=s[o++],t.fillRect(2.5,-12.5,10,10),l+=u,t.translate(u,0),o>0&&o%c==0&&(t.translate(h-l,Math.round(.15*i)),l=h);t.restore(),this.m_drawing=!1}}display(t){let e=new Array;for(let n in t)e.push(t[n]);this.displayList(e)}displayList(t){this.m_transactions=t,this.paint(this.context)}update(t,e){let n=this.m_transactions.map((e,n)=>e.id==t.id?n:-1).filter(t=>t>=0);this.m_transactions=this.m_transactions.filter((t,e)=>n.indexOf(e)<0),this.m_start<=t.date&&t.date<=this.m_end&&(this.m_transactions.push(t),this.window_OnResize())}clear(){}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});class i{constructor(){$(()=>{$.mobile.loading(),!1===$(".ui-loader-background").is("*")&&$("body").append($("<div>").addClass("ui-loader-background").css({width:"100%",height:"100%",top:0,left:0,padding:0,margin:0,background:"rgba(0, 0, 0, 0.3)",display:"none",position:"fixed","z-index":1e4}))})}show(t){return new Promise(e=>{$(".ui-loader-background").css("display","block"),$.mobile.loading("show",{text:t||"",textVisible:!!t}),e()})}hide(){$(()=>{$(".ui-loader-background").css("display","none"),$.mobile.loading("hide")})}static show(t){return i.staticSpinner||(i.staticSpinner=new i),i.staticSpinner.show(t)}static hide(){i.staticSpinner||(i.staticSpinner=new i),i.staticSpinner.hide()}}e.default=i},function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))(function(r,o){function s(t){try{u(i.next(t))}catch(t){o(t)}}function a(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){t.done?r(t.value):new n(function(e){e(t.value)}).then(s,a)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0});const r=n(9);e.firebase=r,n(5),n(4);const o=n(2);e.Records=class extends o.default{constructor(t){super(),this.ref=t,this.ref.on("child_added",this.childAddedHandler.bind(this)),this.ref.on("child_changed",this.childChangedHandler.bind(this)),this.ref.on("child_removed",this.childRemovedHandler.bind(this))}childAddedHandler(t,e){return i(this,void 0,void 0,function*(){let e=this.sanitizeAfterRead(t.val());e.id=t.key,this.onChildAdded(e)})}childChangedHandler(t,e){return i(this,void 0,void 0,function*(){let e=this.sanitizeAfterRead(t.val());e.id=t.key,this.onChildChanged(e)})}childRemovedHandler(t,e){return i(this,void 0,void 0,function*(){let e=this.sanitizeAfterRead(t.val());e.id=t.key,this.onChildRemoved(e)})}onChildSaved(t,e){return i(this,void 0,void 0,function*(){this.emitAsync("child_saved",this.sanitizeAfterRead(t),this.sanitizeAfterRead(e),this)})}onChildAdded(t){return i(this,void 0,void 0,function*(){this.emitAsync("child_added",t,this)})}onChildChanged(t){return i(this,void 0,void 0,function*(){this.emitAsync("child_changed",t,this)})}onBeforeChildRemoved(t){return i(this,void 0,void 0,function*(){this.emitAsync("child_before_removed",t,this)})}onChildRemoved(t){return i(this,void 0,void 0,function*(){this.emitAsync("child_removed",t,this)})}convertToArray(t){let e=Array();for(let n in t)e.push(t[n]);return e}sanitizeAfterRead(t){return t}sanitizeBeforeWrite(t){return t}loadRecords(){return i(this,void 0,void 0,function*(){let t=(yield this.ref.once("value")).val();for(let e in t)t[e].id=e,t[e]=this.sanitizeAfterRead(t[e]);return t})}loadRecordsByChild(t,e,n){return i(this,void 0,void 0,function*(){let i=this.ref.orderByChild(t);e&&(i=i.startAt(e)),n&&(i=i.endAt(n));let r=(yield i.once("value")).val();for(let t in r)r[t].id=t,r[t]=this.sanitizeAfterRead(r[t]);return r})}save(t,...e){return i(this,void 0,void 0,function*(){let e=t.id;if(delete t.id,t=this.sanitizeBeforeWrite(t),e){let n=yield this.load(e);return yield this.ref.child(e).set(t),t.id=e,this.onChildSaved(t,n),e}{let e=yield this.ref.push(t);return t.id=e.key,this.onChildSaved(t,null),t.id}})}load(t){return i(this,void 0,void 0,function*(){let e=(yield this.ref.child(t).once("value")).val();return null===e?null:(e.id=t,e=this.sanitizeAfterRead(e))})}remove(t,...e){return i(this,void 0,void 0,function*(){return"string"!=typeof t&&(t=t.id),this.onBeforeChildRemoved(t),yield this.ref.child(t).remove(),t})}}},function(t,e){class n{constructor(){this.hundreds=0,this.fifties=0,this.twenties=0,this.tens=0,this.fives=0,this.ones=0,this.cent25=0,this.cent10=0,this.cent5=0,this.cent1=0}static default(){return new n}add(t){this.hundreds+=t.hundreds,this.fifties+=t.fifties,this.twenties+=t.twenties,this.tens+=t.tens,this.fives+=t.fives,this.ones+=t.ones,this.cent25+=t.cent25,this.cent10+=t.cent10,this.cent5+=t.cent5,this.cent1+=t.cent1}getTotal(){return Math.roundTo(100*this.hundreds+50*this.fifties+20*this.twenties+10*this.tens+5*this.fives+this.ones+.25*this.cent25+.1*this.cent10+.05*this.cent5+.01*this.cent1,2)}}function i(){var t=Math.sign(this)<0?"-$":"$",e=Math.abs(this).toFixed(2);for(e.indexOf(".")<0&&(e+=".00");e.length-e.indexOf(".")<3;)e+="0";if(e.indexOf(".")>3){var n=e.indexOf(".");for(e=e.slice(0,n-3)+","+e.slice(n-3);(n=e.indexOf(","))>3;)e=e.slice(0,n-3)+","+e.slice(n-3)}return t+e}try{(0).toLocaleString("i"),Number.prototype.toCurrency=i}catch(t){"RangeError"===t.name?Number.prototype.toCurrency=function(){return this.toLocaleString("en-US",{style:"currency",currency:"USD"})}:Number.prototype.toCurrency=i}Number.prototype.toCash=function(){for(var t=n.default(),e=Math.roundTo(this,2);e>=100;)e=Math.roundTo(e-100,2),t.hundreds++;for(;e>=50;)e=Math.roundTo(e-50,2),t.fifties++;for(;e>=20;)e=Math.roundTo(e-20,2),t.twenties++;for(;e>=10;)e=Math.roundTo(e-10,2),t.tens++;for(;e>=5;)e=Math.roundTo(e-5,2),t.fives++;for(;e>=1;)e=Math.roundTo(e-1,2),t.ones++;for(;e>=.25;)e=Math.roundTo(e-.25,2),t.cent25++;for(;e>=.1;)e=Math.roundTo(e-.1,2),t.cent10++;for(;e>=.05;)e=Math.roundTo(e-.05,2),t.cent5++;for(;e>0;)e=Math.roundTo(e-.01,2),t.cent1++;return t}},function(t,e){var n;String.prototype.startsWith||(String.prototype.startsWith=function(t,e){return e=e||0,this.slice(e,t.length)===t}),function(t){t[t.Sunday=0]="Sunday",t[t.Monday=1]="Monday",t[t.Tuesday=2]="Tuesday",t[t.Wednesday=3]="Wednesday",t[t.Thursday=4]="Thursday",t[t.Friday=5]="Friday",t[t.Saturday=6]="Saturday"}(n||(n={})),Date.DAYSOFWEEK=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Date.ABBRDAYSOFWEEK=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Date.MONTHS=["January","February","March","April","May","June","July","August","September","October","November","December"],Date.ABBRMONTHS=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Date.WeekDays=n,Date.Iterator=function(t,e,n){return new class{constructor(t,e,n){this.date=t,this.comparer=e,this.operator=n,this.pointer=this.date}next(){let t;return t=this.comparer(this.pointer)?{done:!1,value:this.pointer}:{done:!0,value:null},this.pointer=this.operator(this.pointer),t}[Symbol.iterator](){return this}}(t,e,n)},Date.next=function(t){if("string"==typeof t&&(t=n[t]),t<0||7<t)throw"Invalid day of the week";let e=Date.today();for(;e.getUTCDay()!=t;)e=e.add("1 day");return e},Date.previous=function(t){if("string"==typeof t&&(t=n[t]),t<0||7<t)throw"Invalid day of the week";let e=Date.today();for(;e.getUTCDay()!=t;)e=e.subtract("1 day");return e},Date.today=function(){var t=new Date(Date.now());return new Date(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())},Date.parseFb=function(t){var e=6e4*new Date(Date.parse(t)).getTimezoneOffset();return new Date(Date.parse(t)+e)},Date.max=function(t,e){return Math.max(t.getTime(),e.getTime())==t.getTime()?t:e},Date.min=function(t,e){return Math.min(t.getTime(),e.getTime())==t.getTime()?t:e},Date.periodCalc=function(t,e){return Date.today().periodCalc(t,e)};class i{constructor(t){this.m_time="number"==typeof t?{millis:t,months:0,years:0,days:null}:i.parse(t)}getTimeStruct(){return this.m_time}getTime(){return this.m_time.millis+30.4375*this.m_time.months*24*3600*1e3+365.25*this.m_time.years*24*3600*1e3}get Time(){return this.getTime()}getTotalMilliseconds(){return this.getTime()}get TotalMilliseconds(){return this.getTime()}getTotalSeconds(){return this.getTime()/1e3}get TotalSeconds(){return this.getTime()/1e3}getTotalMinutes(){return this.getTotalSeconds()/60}get TotalMinutes(){return this.getTotalSeconds()/60}getTotalHours(){return this.getTotalMinutes()/60}get TotalHours(){return this.getTotalMinutes()/60}getTotalDays(){return this.getTotalHours()/24}get TotalDays(){return this.getTotalHours()/24}getTotalWeeks(){return this.getTotalDays()/7}get TotalWeeks(){return this.getTotalDays()/7}get Days(){return this.m_time.days?this.m_time.days.slice():null}toString(){var t="",e=Math.floor(this.getTotalWeeks()),n=Math.round(7*(this.getTotalWeeks()-e)*24*3600*1e3);0!=e&&(t=e+" week"+(1==e?"":"s"));var i=Math.floor(n/24/3600/1e3);n=Math.round(n-24*i*3600*1e3),0!=i&&(t+=(""==t?"":" ")+i+" day"+(1==i?"":"s"));var r=Math.floor(n/3600/1e3);n=Math.round(n-3600*r*1e3),0!=r&&(t+=(""==t?"":" ")+r+" hour"+(1==r?"":"s"));var o=Math.floor(n/60/1e3);n=Math.round(n-60*o*1e3),0!=o&&(t+=(""==t?"":" ")+o+" minute"+(1==o?"":"s"));var s=Math.roundTo(n/1e3,3);return 0!=s&&(t+=(""==t?"":" ")+s+" second"+(1==s?"":"s")),t}static parse(t){var e=/(\d+(?:\.\d+)?)\s*(year|yr|month|week|wk|day|dy|hour|hr|min|minute|second|sec)s?/gi,n=/^\s*(\d+)(?:st|nd|rd|th)?\s+(?:(?:and|&)\s+)?(\d+)(?:st|nd|rd|th)?\s*$/,i=/^(\d{2}):(\d{2}):(\d{2}(?:\.\d+)?)$/;if(1==i.test(t)){var r;if(null===(r=i.exec(t)))return{millis:0,months:0,years:0,days:null};var o=parseFloat(r[1]),s=parseFloat(r[2]);return{millis:1e3*parseFloat(r[3])+60*s*1e3+3600*o*1e3,months:0,years:0,days:null}}if(1==n.test(t))return null===(r=n.exec(t))?{millis:0,months:0,years:0,days:null}:{millis:0,months:0,years:0,days:[parseInt(r[1]),parseInt(r[2])]};for(var a,u=[],c=0,h=0,l=0;null!=(a=e.exec(t));)u.push({value:parseFloat(a[1]),unit:a[2].toLowerCase()});if(0==u.length)throw"Invalid date format";for(var d=0;d<u.length;d++)switch((a=u[d]).unit){case"year":case"yr":l+=a.value;break;case"month":h+=a.value;break;case"week":case"wk":c+=7*a.value*24*3600*1e3;break;case"day":case"dy":c+=24*a.value*3600*1e3;break;case"hour":case"hr":c+=3600*a.value*1e3;break;case"minute":case"min":c+=60*a.value*1e3;break;default:c+=1e3*a.value}return{millis:c,months:h,years:l,days:null}}}Date.Timespan=i,Date.prototype.toFbString=function(){return this.getUTCFullYear()+"-"+(this.getUTCMonth()<9?"0"+(this.getUTCMonth()+1):this.getUTCMonth()+1)+"-"+(this.getUTCDate()<10?"0":"")+this.getUTCDate()},Date.prototype.add=function(t){if("string"==typeof(t=t||new i(0))&&(t=new i(t)),"number"==typeof t&&(t=new i(t)),t.Days){var e=new Date(this.getTime()).add("1 day"),n=!1;do{t.Days.indexOf(e.getUTCDate())>=0?n=!0:e.getUTCDate()===e.daysInMonth()&&t.Days.find(t=>t>e.getUTCDate())?n=!0:e=e.add("1 day")}while(!1===n);return e}var r=new Date(t.getTimeStruct().millis+this.getTime());if(0!=t.getTimeStruct().years&&r.setUTCFullYear(r.getUTCFullYear()+t.getTimeStruct().years),0!=t.getTimeStruct().months)if(r.getUTCDate()>28){let e=r.getUTCDate()-1,n=r.subtract(e+" days");(r=(r=n.getTimezoneOffset()!==r.getTimezoneOffset()?n.add((n.getTimezoneOffset()-r.getTimezoneOffset())/60+" hours"):n).add(t.getTimeStruct().months+" months")).getUTCDate()+e>r.daysInMonth()?r.setUTCDate(r.daysInMonth()):r.setUTCDate(e+1)}else r.setUTCMonth(r.getUTCMonth()+t.getTimeStruct().months);return this.getTimezoneOffset()!=r.getTimezoneOffset()&&(r=new Date(r.getTime()+6e4*(r.getTimezoneOffset()-this.getTimezoneOffset()))),r},Date.prototype.subtract=function(t){if("string"==typeof(t=t||new i(0))&&(t=new i(t)),"number"==typeof t&&(t=new i(t)),t instanceof Date)return new i(this.getTime()-t.getTime());if(t.Days){var e=new Date(this.getTime()).subtract("1 day"),n=!1;do{t.Days.indexOf(e.getUTCDate())>=0?n=!0:e.getUTCDate()===e.daysInMonth()&&t.Days.find(t=>t>e.getUTCDate())?n=!0:e=e.subtract("1 day")}while(!1===n);return e}var r=new Date(this.getTime()-t.getTimeStruct().millis);if(0!=t.getTimeStruct().years&&r.setUTCFullYear(r.getUTCFullYear()-t.getTimeStruct().years),0!=t.getTimeStruct().months)if(r.getUTCDate()>28){let e=r.getUTCDate()-1,n=r.subtract(e+" days");(r=(r=n.getTimezoneOffset()!==r.getTimezoneOffset()?n.add((n.getTimezoneOffset()-r.getTimezoneOffset())/60+" hours"):n).subtract(t.getTimeStruct().months+" months")).getUTCDate()+e>r.daysInMonth()?r.setUTCDate(r.daysInMonth()):r.setUTCDate(e+1)}else r.setUTCMonth(r.getUTCMonth()-t.getTimeStruct().months);return r},Date.prototype.eq=Date.prototype.equals=function(t){return"string"==typeof(t=t||new Date)&&(t=Date.parseFb(t)),this.getTime()==t.getTime()},Date.prototype.lt=Date.prototype.lessThan=function(t){return"string"==typeof(t=t||new Date)&&(t=Date.parseFb(t)),this.getTime()<t.getTime()},Date.prototype.gt=Date.prototype.greaterThan=function(t){return"string"==typeof(t=t||new Date)&&(t=Date.parseFb(t)),this.getTime()>t.getTime()},Date.prototype.ge=Date.prototype.greaterThanEquals=function(t){return this.equals(t)||this.greaterThan(t)},Date.prototype.le=Date.prototype.lessThanEquals=function(t){return this.equals(t)||this.lessThan(t)},Date.prototype.periodCalc=function(t,e){for(var n=Date.parseFb(t);!0===n.add(e).le(this);)n=n.add(e);return n},Date.prototype.daysInMonth=function(){var t=this.getUTCMonth();if(1==t){var e=this.getUTCFullYear();return e%400==0?29:e%100==0?28:e%4==0?29:28}return t<7&&t%2==0?31:t>6&&t%2==1?31:30},Date.prototype.format=function(t){for(var e="";t.length>0;)if(1==t.startsWith("dddd"))e+=Date.DAYSOFWEEK[this.getUTCDay()],t=t.slice(4);else if(1==t.startsWith("ddd"))e+=Date.ABBRDAYSOFWEEK[this.getUTCDay()],t=t.slice(3);else if(1==t.startsWith("dd"))e+=(this.getUTCDate()<10?"0":"")+this.getUTCDate(),t=t.slice(2);else if(1==t.startsWith("d"))e+=this.getUTCDate(),t=t.slice(1);else if(1==t.startsWith("hh"))0==(n=this.getUTCHours()%12)&&(n=12),e+=(n<10?"0":"")+n,t=t.slice(2);else if(1==t.startsWith("h"))0==(n=this.getUTCHours()%12)&&(n=12),e+=n,t=t.slice(1);else if(1==t.startsWith("HH"))e+=((n=this.getUTCHours())<10?"0":"")+n,t=t.slice(2);else if(1==t.startsWith("H")){var n;e+=n=this.getUTCHours(),t=t.slice(1)}else if(1==t.startsWith("K")){var i=this.getTimezoneOffset(),r=Math.floor(Math.abs(i)/60),o=Math.round(Math.abs(i)-60*r);0==i?e+="Z":(e+=1==Math.sign(i)?"-":"+",e+=r+":"+(o<10?"0":"")+o),t=t.slice(1)}else if(1==t.startsWith("mm"))e+=((s=this.getUTCMinutes())<10?"0":"")+s,t=t.slice(2);else if(1==t.startsWith("m")){var s;e+=s=this.getUTCMinutes(),t=t.slice(1)}else if(1==t.startsWith("MMMM"))e+=Date.MONTHS[this.getUTCMonth()],t=t.slice(4);else if(1==t.startsWith("MMM"))e+=Date.ABBRMONTHS[this.getUTCMonth()],t=t.slice(3);else if(1==t.startsWith("MM")){var a=this.getUTCMonth()+1;e+=(a<10?"0":"")+a,t=t.slice(2)}else if(1==t.startsWith("M"))e+=this.getUTCMonth()+1,t=t.slice(1);else if(1==t.startsWith("ss"))e+=((u=this.getUTCSeconds())<10?"0":"")+u,t=t.slice(2);else if(1==t.startsWith("s")){var u;e+=u=this.getUTCSeconds(),t=t.slice(1)}else if(1==t.startsWith("yyyyy"))e+=(c=this.getUTCFullYear())<100?"0":"",e+=c<1e3?"0":"",e+=(c<1e4?"0":"")+c,t=t.slice(5);else if(1==t.startsWith("yyyy"))e+=(c=this.getUTCFullYear())<100?"0":"",e+=(c<1e3?"0":"")+c,t=t.slice(4);else if(1==t.startsWith("yyy"))e+=((c=this.getUTCFullYear())<100?"0":"")+c,t=t.slice(3);else if(1==t.startsWith("yy"))e+=((c=this.getUTCFullYear()%100)<10?"0":"")+c,t=t.slice(2);else if(1==t.startsWith("y")){var c;e+=c=this.getUTCFullYear()%100,t=t.slice(1)}else 1==t.startsWith("zzz")?(i=this.getTimezoneOffset(),r=Math.floor(Math.abs(i)/60),o=Math.round(Math.abs(i)-60*r),e+=(Math.sign(i)>=1?"-":"")+(r<10?"0":"")+r+":"+(o<10?"0":"")+o,t=t.slice(3)):1==t.startsWith("zz")?(i=this.getTimezoneOffset(),r=-Math.floor(i/60),e+=(Math.sign(r)<0?"-":"")+(Math.abs(r)<10?"0":"")+Math.abs(r),t=t.slice(2)):1==t.startsWith("z")?(i=this.getTimezoneOffset(),e+=r=-Math.floor(i/60),t=t.slice(1)):1==t.startsWith("\\")?(e+=t[1],t=t.slice(2)):(e+=t[0],t=t.slice(1));return e}},function(t,e,n){"use strict";n.r(e),n.d(e,"__extends",function(){return r}),n.d(e,"__assign",function(){return o}),n.d(e,"__rest",function(){return s}),n.d(e,"__decorate",function(){return a}),n.d(e,"__param",function(){return u}),n.d(e,"__metadata",function(){return c}),n.d(e,"__awaiter",function(){return h}),n.d(e,"__generator",function(){return l}),n.d(e,"__exportStar",function(){return d}),n.d(e,"__values",function(){return f}),n.d(e,"__read",function(){return p}),n.d(e,"__spread",function(){return v}),n.d(e,"__await",function(){return g}),n.d(e,"__asyncGenerator",function(){return y}),n.d(e,"__asyncDelegator",function(){return m}),n.d(e,"__asyncValues",function(){return _}),n.d(e,"__makeTemplateObject",function(){return b}),n.d(e,"__importStar",function(){return w}),n.d(e,"__importDefault",function(){return C});
  /*! *****************************************************************************
  Copyright (c) Microsoft Corporation. All rights reserved.
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  this file except in compliance with the License. You may obtain a copy of the
  License at http://www.apache.org/licenses/LICENSE-2.0
  
  THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  MERCHANTABLITY OR NON-INFRINGEMENT.
  
  See the Apache Version 2.0 License for specific language governing permissions
  and limitations under the License.
  ***************************************************************************** */
  var i=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])};function r(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var o=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t};function s(t,e){var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(t);r<i.length;r++)e.indexOf(i[r])<0&&(n[i[r]]=t[i[r]])}return n}function a(t,e,n,i){var r,o=arguments.length,s=o<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,i);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(s=(o<3?r(s):o>3?r(e,n,s):r(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s}function u(t,e){return function(n,i){e(n,i,t)}}function c(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}function h(t,e,n,i){return new(n||(n=Promise))(function(r,o){function s(t){try{u(i.next(t))}catch(t){o(t)}}function a(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){t.done?r(t.value):new n(function(e){e(t.value)}).then(s,a)}u((i=i.apply(t,e||[])).next())})}function l(t,e){var n,i,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,i&&(r=i[2&o[0]?"return":o[0]?"throw":"next"])&&!(r=r.call(i,o[1])).done)return r;switch(i=0,r&&(o=[0,r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,i=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=(r=s.trys).length>0&&r[r.length-1])&&(6===o[0]||2===o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){s.label=o[1];break}if(6===o[0]&&s.label<r[1]){s.label=r[1],r=o;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(o);break}r[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],i=0}finally{n=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}function d(t,e){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}function f(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}}function p(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var i,r,o=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(i=o.next()).done;)s.push(i.value)}catch(t){r={error:t}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return s}function v(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(p(arguments[e]));return t}function g(t){return this instanceof g?(this.v=t,this):new g(t)}function y(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,r=n.apply(t,e||[]),o=[];return i={},s("next"),s("throw"),s("return"),i[Symbol.asyncIterator]=function(){return this},i;function s(t){r[t]&&(i[t]=function(e){return new Promise(function(n,i){o.push([t,e,n,i])>1||a(t,e)})})}function a(t,e){try{(n=r[t](e)).value instanceof g?Promise.resolve(n.value.v).then(u,c):h(o[0][2],n)}catch(t){h(o[0][3],t)}var n}function u(t){a("next",t)}function c(t){a("throw",t)}function h(t,e){t(e),o.shift(),o.length&&a(o[0][0],o[0][1])}}function m(t){var e,n;return e={},i("next"),i("throw",function(t){throw t}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(i,r){t[i]&&(e[i]=function(e){return(n=!n)?{value:g(t[i](e)),done:"return"===i}:r?r(e):e})}}function _(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator];return e?e.call(t):f(t)}function b(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function w(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e}function C(t){return t&&t.__esModule?t:{default:t}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(16),r={NODE_CLIENT:!1,NODE_ADMIN:!1,SDK_VERSION:"${JSCORE_VERSION}"},o=function(t,e){if(!t)throw s(e)},s=function(t){return new Error("Firebase Database ("+r.SDK_VERSION+") INTERNAL ASSERT FAILED: "+t)},a=function(t){for(var e=[],n=0,i=0;i<t.length;i++){var r=t.charCodeAt(i);r<128?e[n++]=r:r<2048?(e[n++]=r>>6|192,e[n++]=63&r|128):55296==(64512&r)&&i+1<t.length&&56320==(64512&t.charCodeAt(i+1))?(r=65536+((1023&r)<<10)+(1023&t.charCodeAt(++i)),e[n++]=r>>18|240,e[n++]=r>>12&63|128,e[n++]=r>>6&63|128,e[n++]=63&r|128):(e[n++]=r>>12|224,e[n++]=r>>6&63|128,e[n++]=63&r|128)}return e},u={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_,i=[],r=0;r<t.length;r+=3){var o=t[r],s=r+1<t.length,a=s?t[r+1]:0,u=r+2<t.length,c=u?t[r+2]:0,h=o>>2,l=(3&o)<<4|a>>4,d=(15&a)<<2|c>>6,f=63&c;u||(f=64,s||(d=64)),i.push(n[h],n[l],n[d],n[f])}return i.join("")},encodeString:function(t,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(t):this.encodeByteArray(a(t),e)},decodeString:function(t,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(t):function(t){for(var e=[],n=0,i=0;n<t.length;){var r=t[n++];if(r<128)e[i++]=String.fromCharCode(r);else if(r>191&&r<224){var o=t[n++];e[i++]=String.fromCharCode((31&r)<<6|63&o)}else if(r>239&&r<365){var s=((7&r)<<18|(63&(o=t[n++]))<<12|(63&(a=t[n++]))<<6|63&t[n++])-65536;e[i++]=String.fromCharCode(55296+(s>>10)),e[i++]=String.fromCharCode(56320+(1023&s))}else{o=t[n++];var a=t[n++];e[i++]=String.fromCharCode((15&r)<<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_,i=[],r=0;r<t.length;){var o=n[t.charAt(r++)],s=r<t.length?n[t.charAt(r)]:0,a=++r<t.length?n[t.charAt(r)]:64,u=++r<t.length?n[t.charAt(r)]:64;if(++r,null==o||null==s||null==a||null==u)throw Error();var c=o<<2|s>>4;if(i.push(c),64!=a){var h=s<<4&240|a>>2;if(i.push(h),64!=u){var l=a<<6&192|u;i.push(l)}}}return i},init_:function(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(var t=0;t<this.ENCODED_VALS.length;t++)this.byteToCharMap_[t]=this.ENCODED_VALS.charAt(t),this.charToByteMap_[this.byteToCharMap_[t]]=t,this.byteToCharMapWebSafe_[t]=this.ENCODED_VALS_WEBSAFE.charAt(t),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[t]]=t,t>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(t)]=t,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(t)]=t)}}},c=function(t){try{return u.decodeString(t,!0)}catch(t){console.error("base64Decode failed: ",t)}return null};function h(t,e){if(!(e instanceof Object))return e;switch(e.constructor){case Date:return new Date(e.getTime());case Object:void 0===t&&(t={});break;case Array:t=[];break;default:return e}for(var n in e)e.hasOwnProperty(n)&&(t[n]=h(t[n],e[n]));return t}var l=function(){function t(){var t=this;this.promise=new Promise(function(e,n){t.resolve=e,t.reject=n})}return t.prototype.wrapCallback=function(t){var e=this;return function(n,i){n?e.reject(n):e.resolve(i),"function"==typeof t&&(e.promise.catch(function(){}),1===t.length?t(n):t(n,i))}},t}(),d=function(){return"undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:""},f="FirebaseError",p=Error.captureStackTrace,v=function(t,e){if(this.code=t,this.message=e,p)p(this,g.prototype.create);else try{throw Error.apply(this,arguments)}catch(t){this.name=f,Object.defineProperty(this,"stack",{get:function(){return t.stack}})}};v.prototype=Object.create(Error.prototype),v.prototype.constructor=v,v.prototype.name=f;var g=function(){function t(t,e,n){this.service=t,this.serviceName=e,this.errors=n,this.pattern=/\{\$([^}]+)}/g}return t.prototype.create=function(t,e){void 0===e&&(e={});var n,i=this.errors[t],r=this.service+"/"+t;n=void 0===i?"Error":i.replace(this.pattern,function(t,n){var i=e[n];return void 0!==i?i.toString():"<"+n+"?>"}),n=this.serviceName+": "+n+" ("+r+").";var o=new v(r,n);for(var s in e)e.hasOwnProperty(s)&&"_"!==s.slice(-1)&&(o[s]=e[s]);return o},t}();function y(t){return JSON.parse(t)}var m=function(t){var e={},n={},i={},r="";try{var o=t.split(".");e=y(c(o[0])||""),n=y(c(o[1])||""),r=o[2],i=n.d||{},delete n.d}catch(t){}return{header:e,claims:n,data:i,signature:r}},_=function(t,e){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e(n,t[n])},b=function(t,e){return _(e,function(e,n){t[e]=n}),t},w=function(t,e,n){for(var i in t)if(e.call(n,t[i],i,t))return i},C=function(t){function e(){var e=t.call(this)||this;e.chain_=[],e.buf_=[],e.W_=[],e.pad_=[],e.inbuf_=0,e.total_=0,e.blockSize=64,e.pad_[0]=128;for(var n=1;n<e.blockSize;++n)e.pad_[n]=0;return e.reset(),e}return i.__extends(e,t),e.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},e.prototype.compress_=function(t,e){e||(e=0);var n=this.W_;if("string"==typeof t)for(var i=0;i<16;i++)n[i]=t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|t.charCodeAt(e+3),e+=4;else for(i=0;i<16;i++)n[i]=t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3],e+=4;for(i=16;i<80;i++){var r=n[i-3]^n[i-8]^n[i-14]^n[i-16];n[i]=4294967295&(r<<1|r>>>31)}var o,s,a=this.chain_[0],u=this.chain_[1],c=this.chain_[2],h=this.chain_[3],l=this.chain_[4];for(i=0;i<80;i++)i<40?i<20?(o=h^u&(c^h),s=1518500249):(o=u^c^h,s=1859775393):i<60?(o=u&c|h&(u|c),s=2400959708):(o=u^c^h,s=3395469782),r=(a<<5|a>>>27)+o+l+s+n[i]&4294967295,l=h,h=c,c=4294967295&(u<<30|u>>>2),u=a,a=r;this.chain_[0]=this.chain_[0]+a&4294967295,this.chain_[1]=this.chain_[1]+u&4294967295,this.chain_[2]=this.chain_[2]+c&4294967295,this.chain_[3]=this.chain_[3]+h&4294967295,this.chain_[4]=this.chain_[4]+l&4294967295},e.prototype.update=function(t,e){if(null!=t){void 0===e&&(e=t.length);for(var n=e-this.blockSize,i=0,r=this.buf_,o=this.inbuf_;i<e;){if(0==o)for(;i<=n;)this.compress_(t,i),i+=this.blockSize;if("string"==typeof t){for(;i<e;)if(r[o]=t.charCodeAt(i),++i,++o==this.blockSize){this.compress_(r),o=0;break}}else for(;i<e;)if(r[o]=t[i],++i,++o==this.blockSize){this.compress_(r),o=0;break}}this.inbuf_=o,this.total_+=e}},e.prototype.digest=function(){var t=[],e=8*this.total_;this.inbuf_<56?this.update(this.pad_,56-this.inbuf_):this.update(this.pad_,this.blockSize-(this.inbuf_-56));for(var n=this.blockSize-1;n>=56;n--)this.buf_[n]=255&e,e/=256;this.compress_(this.buf_);var i=0;for(n=0;n<5;n++)for(var r=24;r>=0;r-=8)t[i]=this.chain_[n]>>r&255,++i;return t},e}(function(){this.blockSize=-1}),T=function(){function t(t,e){var n=this;this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=e,this.task.then(function(){t(n)}).catch(function(t){n.error(t)})}return t.prototype.next=function(t){this.forEachObserver(function(e){e.next(t)})},t.prototype.error=function(t){this.forEachObserver(function(e){e.error(t)}),this.close(t)},t.prototype.complete=function(){this.forEachObserver(function(t){t.complete()}),this.close()},t.prototype.subscribe=function(t,e,n){var i,r=this;if(void 0===t&&void 0===e&&void 0===n)throw new Error("Missing Observer.");void 0===(i=function(t,e){if("object"!=typeof t||null===t)return!1;for(var n=0,i=["next","error","complete"];n<i.length;n++){var r=i[n];if(r in t&&"function"==typeof t[r])return!0}return!1}(t)?t:{next:t,error:e,complete:n}).next&&(i.next=E),void 0===i.error&&(i.error=E),void 0===i.complete&&(i.complete=E);var o=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(function(){try{r.finalError?i.error(r.finalError):i.complete()}catch(t){}}),this.observers.push(i),o},t.prototype.unsubscribeOne=function(t){void 0!==this.observers&&void 0!==this.observers[t]&&(delete this.observers[t],this.observerCount-=1,0===this.observerCount&&void 0!==this.onNoObservers&&this.onNoObservers(this))},t.prototype.forEachObserver=function(t){if(!this.finalized)for(var e=0;e<this.observers.length;e++)this.sendOne(e,t)},t.prototype.sendOne=function(t,e){var n=this;this.task.then(function(){if(void 0!==n.observers&&void 0!==n.observers[t])try{e(n.observers[t])}catch(t){"undefined"!=typeof console&&console.error&&console.error(t)}})},t.prototype.close=function(t){var e=this;this.finalized||(this.finalized=!0,void 0!==t&&(this.finalError=t),this.task.then(function(){e.observers=void 0,e.onNoObservers=void 0}))},t}();function E(){}function S(t,e,n){var i="";switch(e){case 1:i=n?"first":"First";break;case 2:i=n?"second":"Second";break;case 3:i=n?"third":"Third";break;case 4:i=n?"fourth":"Fourth";break;default:throw new Error("errorPrefix called with argumentNumber > 4.  Need to update it?")}return t+" failed: "+(i+" argument ")}e.assert=o,e.assertionError=s,e.base64=u,e.base64Decode=c,e.base64Encode=function(t){var e=a(t);return u.encodeByteArray(e,!0)},e.CONSTANTS=r,e.deepCopy=function(t){return h(void 0,t)},e.deepExtend=h,e.patchProperty=function(t,e,n){t[e]=n},e.Deferred=l,e.getUA=d,e.isMobileCordova=function(){return"undefined"!=typeof window&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(d())},e.isNodeSdk=function(){return!0===r.NODE_CLIENT||!0===r.NODE_ADMIN},e.isReactNative=function(){return"object"==typeof navigator&&"ReactNative"===navigator.product},e.ErrorFactory=g,e.FirebaseError=v,e.patchCapture=function(t){var e=p;return p=t,e},e.jsonEval=y,e.stringify=function(t){return JSON.stringify(t)},e.decode=m,e.isAdmin=function(t){var e=m(t).claims;return"object"==typeof e&&!0===e.admin},e.issuedAtTime=function(t){var e=m(t).claims;return"object"==typeof e&&e.hasOwnProperty("iat")?e.iat:null},e.isValidFormat=function(t){var e=m(t),n=e.claims;return!!e.signature&&!!n&&"object"==typeof n&&n.hasOwnProperty("iat")},e.isValidTimestamp=function(t){var e,n,i=m(t).claims,r=Math.floor((new Date).getTime()/1e3);return"object"==typeof i&&(i.hasOwnProperty("nbf")?e=i.nbf:i.hasOwnProperty("iat")&&(e=i.iat),n=i.hasOwnProperty("exp")?i.exp:e+86400),r&&e&&n&&r>=e&&r<=n},e.clone=function(t){return b({},t)},e.contains=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.every=function(t,e){for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&!e(n,t[n]))return!1;return!0},e.extend=b,e.findKey=w,e.findValue=function(t,e,n){var i=w(t,e,n);return i&&t[i]},e.forEach=_,e.getAnyKey=function(t){for(var e in t)return e},e.getCount=function(t){var e=0;for(var n in t)e++;return e},e.getValues=function(t){var e=[],n=0;for(var i in t)e[n++]=t[i];return e},e.isEmpty=function(t){for(var e in t)return!1;return!0},e.isNonNullObject=function(t){return"object"==typeof t&&null!==t},e.map=function(t,e,n){var i={};for(var r in t)i[r]=e.call(n,t[r],r,t);return i},e.safeGet=function(t,e){if(Object.prototype.hasOwnProperty.call(t,e))return t[e]},e.querystring=function(t){var e=[];return _(t,function(t,n){Array.isArray(n)?n.forEach(function(n){e.push(encodeURIComponent(t)+"="+encodeURIComponent(n))}):e.push(encodeURIComponent(t)+"="+encodeURIComponent(n))}),e.length?"&"+e.join("&"):""},e.querystringDecode=function(t){var e={};return t.replace(/^\?/,"").split("&").forEach(function(t){if(t){var n=t.split("=");e[n[0]]=n[1]}}),e},e.Sha1=C,e.async=function(t,e){return function(){for(var n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];Promise.resolve(!0).then(function(){t.apply(void 0,n)}).catch(function(t){e&&e(t)})}},e.createSubscribe=function(t,e){var n=new T(t,e);return n.subscribe.bind(n)},e.errorPrefix=S,e.validateArgCount=function(t,e,n,i){var r;if(i<e?r="at least "+e:i>n&&(r=0===n?"none":"no more than "+n),r)throw new Error(t+" failed: Was called with "+i+(1===i?" argument.":" arguments.")+" Expects "+r+".")},e.validateCallback=function(t,e,n,i){if((!i||n)&&"function"!=typeof n)throw new Error(S(t,e,i)+"must be a valid function.")},e.validateContextObject=function(t,e,n,i){if((!i||n)&&("object"!=typeof n||null===n))throw new Error(S(t,e,i)+"must be a valid context object.")},e.validateNamespace=function(t,e,n,i){if((!i||n)&&"string"!=typeof n)throw new Error(S(t,e,i)+"must be a valid firebase namespace.")},e.stringLength=function(t){for(var e=0,n=0;n<t.length;n++){var i=t.charCodeAt(n);i<128?e++:i<2048?e+=2:i>=55296&&i<=56319?(e+=4,n++):e+=3}return e},e.stringToByteArray=function(t){for(var e=[],n=0,i=0;i<t.length;i++){var r=t.charCodeAt(i);if(r>=55296&&r<=56319){var s=r-55296;o(++i<t.length,"Surrogate pair missing trail surrogate."),r=65536+(s<<10)+(t.charCodeAt(i)-56320)}r<128?e[n++]=r:r<2048?(e[n++]=r>>6|192,e[n++]=63&r|128):r<65536?(e[n++]=r>>12|224,e[n++]=r>>6&63|128,e[n++]=63&r|128):(e[n++]=r>>18|240,e[n++]=r>>12&63|128,e[n++]=r>>6&63|128,e[n++]=63&r|128)}return e}},function(t,e){var n,i,r=t.exports={};function o(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function a(t){if(n===setTimeout)return setTimeout(t,0);if((n===o||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:o}catch(t){n=o}try{i="function"==typeof clearTimeout?clearTimeout:s}catch(t){i=s}}();var u,c=[],h=!1,l=-1;function d(){h&&u&&(h=!1,u.length?c=u.concat(c):l=-1,c.length&&f())}function f(){if(!h){var t=a(d);h=!0;for(var e=c.length;e;){for(u=c,c=[];++l<e;)u&&u[l].run();l=-1,e=c.length}u=null,h=!1,function(t){if(i===clearTimeout)return clearTimeout(t);if((i===s||!i)&&clearTimeout)return i=clearTimeout,clearTimeout(t);try{i(t)}catch(e){try{return i.call(null,t)}catch(e){return i.call(this,t)}}}(t)}}function p(t,e){this.fun=t,this.array=e}function v(){}r.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];c.push(new p(t,e)),1!==c.length||h||a(f)},p.prototype.run=function(){this.fun.apply(null,this.array)},r.title="browser",r.browser=!0,r.env={},r.argv=[],r.version="",r.versions={},r.on=v,r.addListener=v,r.once=v,r.off=v,r.removeListener=v,r.removeAllListeners=v,r.emit=v,r.prependListener=v,r.prependOnceListener=v,r.listeners=function(t){return[]},r.binding=function(t){throw new Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(t){throw new Error("process.chdir is not supported")},r.umask=function(){return 0}},function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))(function(r,o){function s(t){try{u(i.next(t))}catch(t){o(t)}}function a(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){t.done?r(t.value):new n(function(e){e(t.value)}).then(s,a)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0});const r=n(0),o=n(1);class s{constructor(){this.index=0,this.list={}}push(t){return this.list[this.index]=t,this.index++}remove(t){return t in this.list&&delete this.list[t]}toArray(){return Object.values(this.list)}}e.default=class extends r.default{constructor(t,e){super("setupwizard",{categories:t}),this.elements={},this.lists={income:new s,housing:new s,utilities:new s,transportation:new s,food:new s,other:new s},this.categoryMap={income:"Income",housing:"Housing",utilities:"Utilities",transportation:"Transportation",food:"Food"},this.addRecurring=e}removeItem(t,e){let n=this.lists[t],i=(this.elements[t],parseInt($(e.target).attr("index")));n.remove(i),$(e.target).remove()}addItem(t){let e=this.lists[t],n=this.elements[t],i={name:$(`#${t}Name`).val().toString(),amount:parseFloat($(`#${t}Amount`).val().toString()),start:$(`#${t}Start`).val().toString(),period:$(`#${t}Period`).val().toString(),deposit:"income"==t,category:"other"==t?$("#otherCategory").val().toString():this.categoryMap[t]},r=e.push(i);n.append($('<li data-icon="delete" class="ui-first-child ui-last-child">').append($(`<a href="#" class="ui-btn ui-btn-icon-right ui-icon-delete" index="${r}">${i.name} - ${i.amount.toCurrency()}</a>`).on("click",t=>this.removeItem("income",t)))).trigger("create"),$(`#${t}Name`).val("").focus(),$(`#${t}Amount`).val(""),$(`#${t}Period`).val("")}createTransactions(){return i(this,void 0,void 0,function*(){o.default.show();let t=new Array;for(var e in this.lists){let n=this.lists[e].toArray();for(let e of n){let n=Date.today().add("1 year").toFbString();t.push(this.addRecurring({name:e.name,amount:e.amount*(e.deposit?1:-1),start:e.start,end:n,period:e.period,category:e.category}))}}yield Promise.all(t),o.default.hide(),this.close()})}sizePanel(t,e){let n=$(window).innerHeight()-$(this.m_dialog).outerHeight(!0),i=e.newPanel.find(".ui-field-contain");i.height(i.height()+n),this.m_dialog.popup("reposition",{positionTo:"window"})}afterRender(){super.afterRender(),this.m_dialog.find("#btnSaveSetup").on("click",this.createTransactions.bind(this)),this.m_dialog.find("#btnCancelSetup").on("click",()=>this.close());for(let t in this.lists)this.elements[t]=$(`#${t}List`),$(`#${t}Add`).on("click",e=>this.addItem(t));this.m_dialog.find("[data-role=tabs]").on("tabsactivate",this.sizePanel.bind(this))}afterOpen(){super.afterOpen(),this.sizePanel(null,{oldTab:null,oldPanel:null,newPanel:$("#income"),newTab:null})}}},function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))(function(r,o){function s(t){try{u(i.next(t))}catch(t){o(t)}}function a(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){t.done?r(t.value):new n(function(e){e(t.value)}).then(s,a)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0});const r=n(10),o=n(1);e.default=function(t){var e=[{id:"entry",title:"Setup an Emergency Fund",backDisabled:!0,contents:["An emergency fund is simply money set aside for an emergency.This \n                wizard will help you save up an emergency fund as quickly as possible.","How much do you want to save?",'<div class="ui-field-contain"><input type="number" name="target" value="1000.00" data-theme="a"></div>',"What is the minimum amount you want left over in each pay period?",'<div class="ui-field-contain"><input type="number" name="minBalance" value="20.00" data-theme="a"></div>',"What category should the emergency fund go into?",`<div class="ui-field-contain"><select data-theme="a" name="category">${t.budget.Config.categories.map(t=>`<option value=${t}>${t}</option>`)}</select></div>`,"What name should the emergency fund transactions have?",'<div class="ui-field-contain"><input type="text" name="name" value="Emergency Fund" data-theme="a"></div>']},{id:"summary",title:"Setup an Emergency Fund",nextText:"Create Transactions",nextDisabled:!0,backDisabled:!0,contents:['<span id="waiting">Calculating...</span>',{type:"image",data:"/jquery.mobile/css/themes/default/images/ajax-loader.gif"}]}];let n=new r.default(e,!0),s=0,a=0,u="",c="",h=new Array,l=t.budget,d=Date.min(Date.parseFb(l.Transactions.Start),Date.periodCalc(l.Config.start,l.Config.length));n.on("beforepage",(e,n)=>{switch(e){case"entry":s=parseFloat($("[name=target]").val()),a=parseFloat($("[name=minBalance]").val()),u=$("[name=category]").val(),c=$("[name=name]").val();break;case"summary":if(h.length>0)for(let e of h)t.budget.saveTransaction({amount:-e.amount,cash:!0,category:u,date:e.date.toFbString(),name:c})}}),n.on("page",(e,r)=>i(this,void 0,void 0,function*(){switch(e){case"summary":t.turnOffUpdates(),o.default.show();let i=d,r=s,u=0,c=0;for(h=[];r>0&&c++<50;){yield l.gotoDate(i);let t=yield l.Transactions.getTotal();if(t-u>a){let e={date:i,amount:Math.min(r,t-u-a)};r-=e.amount,u+=e.amount,h.push(e)}i=i.add(l.Config.length)}if(o.default.hide(),n.content.empty(),t.turnOnUpdates(),yield l.gotoDate(d),h.map(t=>t.amount).reduce((t,e)=>e+t,0)!=s&&(h=[]),h.length>0){for(let t of h)n.content.append($(`<p>${t.date.format("MMM d, yyyy")}: ${t.amount.toCurrency()}</p>`));n.NextEnabled=!0}else n.content.append($("<p>Your goal cannot be accomplished in less than five years. Try again?</p>"));n.BackEnabled=!0}})),n.open()}},function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))(function(r,o){function s(t){try{u(i.next(t))}catch(t){o(t)}}function a(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){t.done?r(t.value):new n(function(e){e(t.value)}).then(s,a)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0});const r=n(10);n(4),e.default=function(t){return["navigationBar.png","addButton.png","newTransaction.png","newRecurring.png","workspace_overview_mobile.png","workspace_overview_desktop.png"].map(t=>$(`<img src="/images/introWizard/${t}/>"`)),new Promise((e,n)=>i(this,void 0,void 0,function*(){let n,o,s=yield t.root.child("tutorials/intro").once("value"),a=new r.default(s.val());a.on("done",()=>i(this,void 0,void 0,function*(){yield t.child("showWizard").set(!1),e()})),a.on("beforepage",(e,r)=>i(this,void 0,void 0,function*(){"setupScreen"==e&&(n=$("[name=budgetStart]").val().toString(),o=$("[name=budgetPeriod]").val().toString(),yield t.child("periods").set({start:n,length:o}))})),a.on("page",(t,e)=>{"setupScreen"==t&&$("[name=budgetPeriod]").on("validity",t=>{$(".wizardNextButton").attr("disabled",!$("[name=budgetPeriod").timespan("valid"))})}),a.open()}))}},function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))(function(r,o){function s(t){try{u(i.next(t))}catch(t){o(t)}}function a(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){t.done?r(t.value):new n(function(e){e(t.value)}).then(s,a)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0});const r=n(0),o=n(1);class s extends r.default{constructor(t,e,n){super("calender",{date:t}),this.onvalue=(()=>null),this.onvalue=e,this.date=t,this.options=n||{select:"day"}}static findFirstDisplayed(t){let e=t;for(;e.getUTCDate()>1;)e=e.subtract("1 day");for(;e.getUTCDay()>0;)e=e.subtract("1 day");return e}handle_cellOnClick(t){let e=$(t.target).hasClass("selected"),n=Date.parseFb($(t.target).attr("value"));if(e||!this.isMobile){switch(this.options.select){case"week":n=n.subtract(n.getUTCDay()+" days");break;case"period":n=n.periodCalc(this.options.start,this.options.period)}this.onvalue(n),this.close()}else this.highlightCells($(t.target))}handle_cellOnMouseOver(t){this.isMobile||this.highlightCells($(t.target))}highlightCells(t){switch($(".calender-table tbody td").removeClass("calender-hover").removeClass("selected"),this.options.select){case"day":t.addClass("calender-hover").addClass("selected");break;case"week":t.parent("tr").children("td").addClass("calender-hover").addClass("selected");break;case"period":let e=Date.parseFb(t.attr("value")).periodCalc(this.options.start,this.options.period);for(let t=e;t.lt(e.add(this.options.period));t=t.add("1 day"))$(".calender-table tbody td[value="+t.toFbString()+"]").addClass("calender-hover").addClass("selected")}}updateCalender(){return i(this,void 0,void 0,function*(){let t="";for(let e=s.findFirstDisplayed(this.date),n=0;n<6;n++,e=e.add("1 week"))t+=(yield this.render("calender-week",{date:this.date,start:e,week:n}));$(".calender-table tbody").empty().append($(t)),this.btnBackMonth.text(this.date.subtract("1 month").format("MMMM")),this.btnForwardMonth.text(this.date.add("1 month").format("MMMM")),this.monthLabel.text(this.date.format("MMMM")),this.btnBackYear.text(this.date.subtract("1 year").format("yyyy")),this.btnForwardYear.text(this.date.add("1 year").format("yyyy")),this.yearLabel.text(this.date.format("yyyy")),$(".calender-table tbody td").on("click",this.handle_cellOnClick.bind(this)),$(".calender-table tbody td").on("mouseover",this.handle_cellOnMouseOver.bind(this)),this.position()})}afterOpen(){o.default.hide(),this.btnBackMonth=$("#btnBackMonth"),this.btnBackYear=$("#btnBackYear"),this.btnForwardMonth=$("#btnForwardMonth"),this.btnForwardYear=$("#btnForwardYear"),this.monthLabel=$("#monthLabel"),this.yearLabel=$("#yearLabel"),this.btnToday=$("#btnCalToday"),this.btnBackMonth.on("click",()=>{this.date=this.date.subtract("1 month"),this.updateCalender()}),this.btnForwardMonth.on("click",()=>{this.date=this.date.add("1 month"),this.updateCalender()}),this.btnBackYear.on("click",()=>{this.date=this.date.subtract("1 year"),this.updateCalender()}),this.btnForwardYear.on("click",()=>{this.date=this.date.add("1 year"),this.updateCalender()}),this.btnToday.on("click",()=>{this.date=Date.today(),this.updateCalender()}),this.updateCalender(),this.isMobile&&setTimeout(()=>{let t=$(".calender-table tbody td[value="+this.date.toFbString()+"]");t.length>0&&this.highlightCells(t)},100)}}e.default=s},function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))(function(r,o){function s(t){try{u(i.next(t))}catch(t){o(t)}}function a(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){t.done?r(t.value):new n(function(e){e(t.value)}).then(s,a)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0});const r=n(0),o=n(1);e.default=class extends r.default{constructor(t){super("signup"),this.signup=t}afterOpen(){o.default.hide(),this.m_dialog.find("#registerEmail").val("").focus(),this.m_dialog.find("#registerPassword").val(""),this.m_dialog.find("#btnSignUp").on("click",()=>i(this,void 0,void 0,function*(){let t=this.m_dialog.find("#errors");function e(e){t.text(e).slideUp(0).slideDown(300).delay(1500).slideUp(300)}try{o.default.show(),yield this.signup(this.m_dialog.find("#registerEmail").val().toString(),this.m_dialog.find("#registerPassword").val().toString()),this.close()}catch(t){switch(t.code){case"auth/email-already-in-use":e("Email Already Registered");break;case"auth/invalid-email":e("Invalid Email"),$("#registerPassword").val(""),$("#registerEmail").focus().select();break;case"auth/weak-password":e("Weak Password"),$("#registerPassword").val("").focus();break;default:console.log(t),e("Unknown Error")}this.m_dialog.find("#registerPassword").val(""),this.m_dialog.find("#registerEmail").select().focus()}})),this.m_dialog.find("input").on("keypress",t=>{13==t.keyCode&&this.m_dialog.find("#btnSignUp").click()})}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(0);var r,o,s;!function(t){t.Asterisk="asterisk",t.Error="exclamation-triangle",t.Exclamation="exclamation-circle",t.Hand="ban",t.Information="info-circle",t.None="",t.Question="question-circle",t.Stop="ban",t.Warning="exclamation-circle"}(r=e.MessageBoxIcon||(e.MessageBoxIcon={})),function(t){t[t.None=0]="None",t[t.Abort=1]="Abort",t[t.Cancel=2]="Cancel",t[t.Ignore=3]="Ignore",t[t.No=4]="No",t[t.OK=5]="OK",t[t.Retry=6]="Retry",t[t.Yes=7]="Yes"}(o=e.DialogResult||(e.DialogResult={})),function(t){t[t.AbortRetryIgnore=0]="AbortRetryIgnore",t[t.OK=1]="OK",t[t.OKCancel=2]="OKCancel",t[t.RetryCancel=3]="RetryCancel",t[t.YesNo=4]="YesNo",t[t.YesNoCancel=5]="YesNoCancel"}(s=e.MessageBoxButtons||(e.MessageBoxButtons={}));let a=[[{text:"Abort",result:o.Abort},{text:"Retry",result:o.Retry},{text:"Ignore",result:o.Ignore}],[{text:"OK",result:o.OK}],[{text:"OK",result:o.OK},{text:"Cancel",result:o.Cancel}],[{text:"Retry",result:o.Retry},{text:"Cancel",result:o.Cancel}],[{text:"Yes",result:o.Yes},{text:"No",result:o.No}],[{text:"Yes",result:o.Yes},{text:"No",result:o.No},{text:"Cancel",result:o.Cancel}]];class u extends i.default{constructor(t,e,n,i){super("messagebox",{text:t,caption:e,buttons:n,icon:i})}afterOpen(){$(()=>{this.m_dialog.find("button").on("click",t=>{this.close(),this.resolver&&this.resolver(parseInt($(t.target).attr("result")))})})}static get Buttons(){return s}static get Icon(){return r}static get DialogResult(){return o}static show(t,e,n,i){let r=new u(t,e,a[n],i);return r.open(),new Promise((t,e)=>{r.resolver=t})}}e.default=u},function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))(function(r,o){function s(t){try{u(i.next(t))}catch(t){o(t)}}function a(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){t.done?r(t.value):new n(function(e){e(t.value)}).then(s,a)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0});const r=n(0),o=n(1);e.default=class extends r.default{constructor(t,e){super("forgotpassword"),this.sendreset=(()=>i(this,void 0,void 0,function*(){})),this.sendreset=t,this.username=e}afterOpen(){this.m_dialog.find("#email").val(this.username||""),o.default.hide(),this.m_dialog.find("#btnRetrieve").on("click",()=>i(this,void 0,void 0,function*(){let t=this.m_dialog.find("#errors");function e(e){t.text(e).slideUp(0).slideDown(300).delay(1500).slideUp(300)}try{let n=this.m_dialog.find("#email").val().toString();o.default.show(),this.close(),this.sendreset(n)}catch(t){switch(t.code){case"auth/invalid-email":case"auth/user-not-found":e("Invalid Account"),$("#email").focus().select();break;default:console.log(t),e("Unknown Error")}this.m_dialog.find("#email").select().focus()}})),this.m_dialog.find("input").on("keypress",t=>{13==t.keyCode&&this.m_dialog.find("#btnSignIn").click()})}}},function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))(function(r,o){function s(t){try{u(i.next(t))}catch(t){o(t)}}function a(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){t.done?r(t.value):new n(function(e){e(t.value)}).then(s,a)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0});const r=n(11);e.default=class extends r.default{listenToTransactions(t){return i(this,void 0,void 0,function*(){let e=Date.parseFb(t.Start).getUTCFullYear();this.m_start=`${e}-01-01`,this.m_end=t.End,t.on("added",t=>i(this,void 0,void 0,function*(){this.m_start<=t.date&&t.date<=this.m_end&&this.update(t)})),t.on("changed",t=>i(this,void 0,void 0,function*(){this.update(t)})),t.on("removed",t=>i(this,void 0,void 0,function*(){this.update(t)}));let n=yield t.loadRecordsByChild("date",this.m_start,this.m_end);this.display(n)})}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(0);e.default=class extends i.default{constructor(t,e){super(t,e)}turnOffUpdates(){}turnOnUpdates(){}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(27),r=n(2);e.default=class extends i.default{constructor(t,e={width:0,height:0},n){super(t,n),this.m_resizeTarget=new class extends r.default{constructor(t){super(),this.m_width=t?t.width:0,this.m_height=t?t.height:0}get width(){return this.m_width}set width(t){this.m_width=t,this.emit("changed",this)}get height(){return this.m_height}set height(t){this.m_height=t,this.emit("changed",this)}get calculatedWidth(){return this.valid?this.width<=1?$(window).innerWidth()*this.width:this.width:0}get calculatedHeight(){return this.valid?this.height<=1?$(window).innerHeight()*this.height:this.height:0}get valid(){return!(this.height<=0||this.width<=0)}}(e)}onResize(){if(this.m_resizeTarget.valid){this.m_dialog.width(this.m_resizeTarget.calculatedWidth),this.m_dialog.height(this.m_resizeTarget.calculatedHeight);let t=this.m_dialog.find("[data-role=header]").height();this.canvas[0].width=this.m_dialog.innerWidth(),this.canvas[0].height=this.m_dialog.innerHeight()-t,this.onPaint(this.context)}this.position()}afterRender(){super.afterRender(),this.canvas=this.m_dialog.find("canvas"),this.context=this.canvas[0].getContext("2d")}afterOpen(){this.m_resizeTarget.valid?this.onResize():this.onPaint(this.context),$(window).on("resize",this.onResize.bind(this)),this.m_resizeTarget.on("changed",this.onResize.bind(this))}afterClose(){$(window).off("resize",this.onResize.bind(this)),this.m_resizeTarget.off("changed")}onPaint(t){}get Size(){return this.m_resizeTarget}}},function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))(function(r,o){function s(t){try{u(i.next(t))}catch(t){o(t)}}function a(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){t.done?r(t.value):new n(function(e){e(t.value)}).then(s,a)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0});const r=n(11);e.default=class extends r.default{listenToTransactions(t){this.m_start=t.Start,this.m_end=t.End,t.on("addedinperiod",t=>i(this,void 0,void 0,function*(){this.update(t)})),t.on("changed",t=>i(this,void 0,void 0,function*(){this.update(t)})),t.on("removedinperiod",t=>i(this,void 0,void 0,function*(){this.m_transactions=this.m_transactions.filter(e=>e.id!=t.id),this.displayList(this.m_transactions)})),this.displayList(t.List)}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.AmChart=class{static makeChart(t,e){return AmCharts.makeChart(t,e)}}},function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))(function(r,o){function s(t){try{u(i.next(t))}catch(t){o(t)}}function a(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){t.done?r(t.value):new n(function(e){e(t.value)}).then(s,a)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0});const r=n(30);class o{constructor(t){this.m_update=!0,$(()=>{if("string"!=typeof t)if(void 0===t.attr("id")){let e="history_chart_"+Date.now().toString();t.attr("id",e),t=e}else t=t.attr("id");this.m_chart=r.AmChart.makeChart(t,o.chart_config)})}display(t,e,n){let i=[];this.m_transactions=t;for(let e in t)i.push(t[e]);i.sort((t,e)=>t.date<e.date?-1:t.date>e.date?1:0),this.displayList(i,e,n)}displayList(t,e,n){let i={},r=0;e=e||Date.today().subtract("2 weeks").toFbString(),n=n||Date.today().add("3 months").toDateString(),this.m_left=e,this.m_right=n;for(let e of t)r+=e.amount,i[e.date]=r;this.draw(i,e,n)}update(t){this.m_transactions||(this.m_transactions={}),this.m_right>t.date&&(this.m_transactions[t.id]=t,clearTimeout(this.m_waiter),this.m_waiter=window.setTimeout(()=>{this.display(this.m_transactions,this.m_left,this.m_right)},500))}remove(t){this.m_transactions||(this.m_transactions={}),t.id in this.m_transactions&&(delete this.m_transactions[t.id],clearTimeout(this.m_waiter),this.m_waiter=window.setTimeout(()=>{this.display(this.m_transactions,this.m_left,this.m_right)},500))}draw(t,e,n){$(()=>{if("none"!==$("#footer_info").css("display")&&Object.keys(t).length>0){this.m_chart.dataProvider=[];let i=0;if(e in t)i=t[e];else for(let n=Date.parseFb(Object.keys(t)[0]);n.le(e);n=n.add("1 day"))n.toFbString()in t&&(i=t[n.toFbString()]);for(let r=Date.parseFb(e);r.le(n);r=r.add("1 day"))r.toFbString()in t==0?t[r.toFbString()]=i:i=t[r.toFbString()];for(let i in t)e<=i&&i<=n&&this.m_chart.dataProvider.push({date:i,amount:Math.roundTo(t[i],2),description:Date.parseFb(i).format("MMM dd")+": "+t[i].toCurrency(),color:t[i]<0?"#ff0000":"#008800"});this.m_chart.dataProvider.sort((t,e)=>t.date<e.date?-1:t.date>e.date?1:0);let r=Date.parseFb(e),o=Date.parseFb(n);this.m_chart.validateData(),this.m_chart.zoomToDates(r,o)}})}clear(){console.log("TODO: clear the chart")}listenToTransactions(t){t.on("added",t=>i(this,void 0,void 0,function*(){0!=this.m_update&&this.update(t)})),t.on("changed",t=>i(this,void 0,void 0,function*(){0!=this.m_update&&this.update(t)})),t.on("removed",t=>i(this,void 0,void 0,function*(){0!=this.m_update&&this.remove(t)})),t.on("periodloaded",e=>i(this,void 0,void 0,function*(){if(0==this.m_update)return;let e=Date.parseFb(t.Start).subtract("3 weeks").toFbString(),n=Date.parseFb(t.End).add("3 months").toFbString(),i=yield t.loadRecords();this.display(i,e,n)}))}turnOffUpdates(){this.m_update=!1}turnOnUpdates(){this.m_update=!0}}o.chart_config={type:"serial",balloonDateFormat:"MMM DD",categoryField:"date",dataDateFormat:"YYYY-MM-DD",maxSelectedSeries:0,mouseWheelScrollEnabled:!0,zoomOutOnDataUpdate:!1,maxZoomFactor:19,zoomOutButtonTabIndex:-2,sequencedAnimation:!1,startEffect:"bounce",accessible:!1,autoDisplay:!0,hideBalloonTime:2e3,theme:"dark",categoryAxis:{position:"top",parseDates:!0},chartCursor:{enabled:!0,animationDuration:.25,bulletsEnabled:!1,categoryBalloonEnabled:!1,categoryBalloonAlpha:0,fullWidth:!1,leaveAfterTouch:!1,oneBalloonOnly:!0,selectionAlpha:1},chartScrollbar:{enabled:!0,dragIcon:"dragIconRoundSmall",graph:"AmGraph-1",gridAlpha:0,maximum:5e3,minimum:-500,oppositeAxis:!0,selectedBackgroundAlpha:0,updateOnReleaseOnly:!0},trendLines:[],graphs:[{balloonColor:"#FFFFFF",balloonText:"[[description]]",bullet:"square",bulletAxis:"ValueAxis-1",bulletBorderAlpha:1,bulletField:"amount",bulletHitAreaSize:2,color:"#000000",colorField:"color",columnWidth:0,descriptionField:"description",fillAlphas:.18,fillColorsField:"color",id:"AmGraph-1",lineAlpha:1,lineColorField:"color",lineThickness:2,minDistance:19,switchable:!1,title:"graph 1",type:"step",valueAxis:"ValueAxis-1",valueField:"amount"}],guides:[],valueAxes:[{id:"ValueAxis-1",title:""}],allLabels:[],balloon:{animationDuration:0,borderAlpha:.96,disableMouseEvents:!1,fixedPosition:!1,horizontalPadding:7},titles:[],dataProvider:[]},e.default=o},function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))(function(r,o){function s(t){try{u(i.next(t))}catch(t){o(t)}}function a(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){t.done?r(t.value):new n(function(e){e(t.value)}).then(s,a)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0});const r=n(0),o=n(1);e.default=class extends r.default{constructor(t,e,n){super("login_v2"),this.login=(()=>i(this,void 0,void 0,function*(){})),this.login=t,this.reset=e,this.signup=n}decodeQueryString(){let t={};if(location.search){let e=location.search.split(/[\?&]/g).filter(t=>t.length>0),n=/([^=]+)(?:\=(.*))?/;for(let i of e){let[e,r,o]=n.exec(i);o=o?decodeURIComponent(o):null,t[r]=o}}return t}afterOpen(){o.default.hide();let t=this.decodeQueryString();"email"in t&&this.m_dialog.find("#email").val(t.email),this.signup||this.m_dialog.find("#createAccount").hide(),this.reset||this.m_dialog.find("#forgotPassword").hide(),this.m_dialog.find("#btnSignIn").on("click",()=>i(this,void 0,void 0,function*(){let t=this.m_dialog.find("#errors");function e(e){t.text(e).slideUp(0).slideDown(300).delay(1500).slideUp(300)}try{yield this.login(this.m_dialog.find("#email").val().toString(),this.m_dialog.find("#password").val().toString()),o.default.show(),this.close()}catch(t){switch(t.code){case"auth/user-disabled":e("Account Disabled");break;case"auth/invalid-email":case"auth/user-not-found":case"auth/wrong-password":e("Invalid Login"),$("#password").val(""),$("#email").focus().select();break;default:console.log(t),e("Unknown Error")}this.m_dialog.find("#password").val(""),this.m_dialog.find("#email").select().focus()}})),this.m_dialog.find("input").on("keypress",t=>{13==t.keyCode&&this.m_dialog.find("#btnSignIn").click()}),this.m_dialog.find("#createAccount").on("click",t=>{t.preventDefault(),this.close(),this.signup()}),this.m_dialog.find("#forgotPassword").on("click",t=>{t.preventDefault(),this.reset(this.m_dialog.find("#email").val().toString()),this.close()})}}},function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))(function(r,o){function s(t){try{u(i.next(t))}catch(t){o(t)}}function a(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){t.done?r(t.value):new n(function(e){e(t.value)}).then(s,a)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0});const r=n(0);e.default=class extends r.default{constructor(t,e,n){super("config_v3",t),this.setTheme=(()=>{}),this.config=t,this.setTheme=n,this.saveConfig=e}updateButtons(){this.m_dialog.find(".category-moveup").removeClass("ui-disabled").first().addClass("ui-disabled"),this.m_dialog.find(".category-movedown").removeClass("ui-disabled").last().addClass("ui-disabled")}findListItem(t){return $(t.target).is("li")?$(t.target):$(t.target).parents("li")}categoryUp(t){let e=this.findListItem(t);e.insertBefore(e.prev("li")),this.updateButtons()}categoryDown(t){let e=this.findListItem(t);e.insertAfter(e.next("li")),this.updateButtons()}categoryDelete(t){this.findListItem(t).remove(),this.updateButtons()}categoryAdd(t){let e=$("#newCategory").val().toString();e&&this.categories.indexOf(e)<0&&(this.m_dialog.find("[data-role=listview]").append($("<li>",{class:"ui-li-static ui-body-inherit"}).text(e).attr("category",e).append($("<div>",{class:"split-custom-wrapper"}).append($('<a href="#" data-role="button" data-mini="true" class="category-delete split-custom-button ui-link ui-btn ui-icon-delete ui-btn-icon-notext ui-shadow ui-corner-all ui-mini" data-icon="delete" data-iconpos="notext" role="button"></a>').on("click",this.categoryDelete.bind(this)),$('<a href="#" data-role="button" data-mini="true" class="category-movedown split-custom-button ui-link ui-btn ui-icon-carat-d ui-btn-icon-notext ui-shadow ui-corner-all ui-mini" data-icon="delete" data-iconpos="notext" role="button"></a>').on("click",this.categoryDown.bind(this)),$('<a href="#" data-role="button" data-mini="true" class="category-moveup split-custom-button ui-link ui-btn ui-icon-carat-u ui-btn-icon-notext ui-shadow ui-corner-all ui-mini" data-icon="carat-u" data-iconpos="notext" role="button"></a>').on("click",this.categoryUp.bind(this))))),this.m_dialog.trigger("create"),this.updateButtons(),$("#newCategory").val(""),this.m_dialog.find("[data-role=listview]").scrollTop(this.m_dialog.find("[data-role=listview]").children("li").last().offset().top))}get categories(){return this.m_dialog.find("[data-role=listview]").children("li").toArray().map(t=>$(t).attr("category"))}afterRender(){super.afterRender(),this.m_dialog.find("#btnSave").on("click",()=>i(this,void 0,void 0,function*(){this.config.start=this.m_dialog.find("#date").val(),this.config.length=this.m_dialog.find("#period_length").val(),this.config.theme=this.m_dialog.find("#theme").val(),this.config.categories=this.categories,this.saveConfig(),this.close()})),this.m_dialog.find("[data-role=tabs]").on("tabsactivate",()=>{if(this.m_dialog.outerHeight(!0)>.95*$(window).innerHeight()){let t=parseInt(this.m_dialog.find("[data-role=listview]").parent().css("max-height"));t=t-this.m_dialog.outerHeight(!0)+.95*$(window).innerHeight(),this.m_dialog.find("[data-role=listview]").parent().css("max-height",t)}this.m_dialog.popup("reposition",{positionTo:"window"})}),this.m_dialog.find("#theme").on("change",()=>{this.setTheme(this.m_dialog.find("#theme").val())}),this.m_dialog.find("#btnAddCategory").on("click",this.categoryAdd.bind(this)),this.m_dialog.find(".category-moveup").on("click",this.categoryUp.bind(this)),this.m_dialog.find(".category-movedown").on("click",this.categoryDown.bind(this)),this.m_dialog.find(".category-delete").on("click",this.categoryDelete.bind(this)),this.updateButtons()}afterClose(){super.afterClose(),this.setTheme(this.config.theme)}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=class{constructor(t,e){$(()=>{this.element=$(t),this.element.panel(e)})}on(t,e){return $(()=>{this.element?this.element.on(t,null,null,e):setTimeout(()=>{this.on(t,e)},100)}),this}off(t,e){return $(()=>{this.element?this.element.off(t,null,e):setTimeout(()=>{this.off(t,e)},100)}),this}close(){return $(()=>{this.element?this.element.panel("close"):setTimeout(()=>{this.close()},100)}),this}open(){return $(()=>{this.element?this.element.panel("open"):setTimeout(()=>{this.open()},100)}),this}toggle(){return $(()=>{this.element?this.element.panel("toggle"):setTimeout(()=>{this.toggle()},100)}),this}}},function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))(function(r,o){function s(t){try{u(i.next(t))}catch(t){o(t)}}function a(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){t.done?r(t.value):new n(function(e){e(t.value)}).then(s,a)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0});const r=n(0);e.default=class extends r.default{constructor(t){super("search"),this.GotoPeriod=(t=>{console.log(t)}),this.transactions=t}afterRender(){super.afterRender(),this.m_dialog.css("height",.7*$(window).innerHeight()).css("width",.8*$(window).innerWidth())}afterOpen(){let t=this.m_dialog.find("#searchTextBox"),e=this.m_dialog.find("#searchButton"),n=this.m_dialog.find("#searchResults"),r=this.m_dialog.height(),o=this.m_dialog.find("[data-role=header]").outerHeight(!0),s=this.m_dialog.find(".ui-field-contain").outerHeight(!0);this.m_dialog.find("[role=main]").innerHeight(r-o),this.m_dialog.find("#searchTable").innerHeight(this.m_dialog.find("[role=main]").innerHeight()-o-s),t.focus(),e.on("click",()=>i(this,void 0,void 0,function*(){if(t.blur(),n.empty(),""==t.val())return;let e=yield this.transactions.search(t.val());(e=e.slice()).sort((t,e)=>Date.parseFb(t.date).getTime()-Date.parseFb(e.date).getTime());for(let t of e)this.render("searchresult",{item:t}).then(e=>{let i=$(e);n.append(i),i.on("click",()=>{this.GotoPeriod(t.date)}),i.on("mouseover",()=>{n.children("tr").css("background-color",""),i.css("background-color","#eef")})})})),t.on("keypress",t=>{13==t.keyCode&&e.click()})}}},function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))(function(r,o){function s(t){try{u(i.next(t))}catch(t){o(t)}}function a(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){t.done?r(t.value):new n(function(e){e(t.value)}).then(s,a)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0});const r=n(3);function o(t,e){var n=$(t).children(".in_date").attr("value"),i=$(e).children(".in_date").attr("value");return n<i?-1:n>i?1:0}e.default=class extends r.default{constructor(t){super(),this.m_transaction=null,this.m_transactions=null,this.m_update=!1,this.GotoTransaction=(t=>{console.log("GOTOTRANSACTION",t)}),$(()=>{this.m_element=$(t)})}handleItemClick(t){t.preventDefault();let e=$(t.target);0==e.is("tr")&&(e=e.parents("tr").children("td.in_date")),this.GotoTransaction(e.attr("value"))}display(t){let e=[];for(let n in t)e.push(t[n]);this.displayList(e)}displayList(t){(t=t.slice()).sort((t,e)=>Date.parseFb(t.date).getTime()-Date.parseFb(e.date).getTime());let e=t.map(t=>t.amount).reduce((t,e)=>t+e,0),n=t.filter(t=>!0===t.paid).map(t=>t.amount).reduce((t,e)=>t+e,0);this.render("info_v2",{items:t,title:t.length>0?t[0].name:"",sum:e,sumPaid:n}).then(t=>{this.m_element.empty().append($(t)),this.m_element.find("tr").on("click",this.handleItemClick.bind(this)),this.m_element.find("tr").on("mouseover",t=>{let e=$(t.target);0==e.is("tr")&&(e=e.parents("tr")),this.m_element.find("tr").css("background-color",""),e.css("background-color","#eef")}),this.m_element.find("tr").on("mouseout",()=>{this.m_element.find("tr").css("background-color","")})})}update(t){if(t)if(this.m_element.find(`tr[item=${t.id}]`).length>0)this.m_element.find(`tr[item=${t.id}] td.in_date`).text(Date.parseFb(t.date).format("MMM d, yyyy")),this.m_element.find(`tr[item=${t.id}] td.in_amount`).text(t.amount.toCurrency());else{let e=$(`<tr id="info_${t.id}" item="${t.id}" name="${t.name}" category="${t.category}">\n                    <td class="in_date" value="${t.date}">${Date.parseFb(t.date).format("MMM d, yyyy")}</td>\n                    <td class="in_amount" value="${t.amount}">${t.amount.toCurrency()}</td>\n                    </tr>`);e.on("click",this.handleItemClick.bind(this)),e.on("mouseout",()=>{this.m_element.find("tr").css("background-color","")}),e.on("mouseover",()=>{this.m_element.find("tr").css("background-color",""),e.css("background-color","#eef")}),this.m_element.find("tbody").append(e)}let e=this.m_element.find("tbody").first().children("tr").toArray(),n=0;for(let t of e)n+=parseFloat($(t).children(".in_amount").attr("value")||"0");e.sort(o),this.m_element.find("tbody").empty(),this.m_element.find("tbody").append(e),this.m_element.find(".info_total").text(`${n.toCurrency()}`)}clear(){this.m_element.empty(),this.m_transaction=null}loadFromTransaction(){return i(this,void 0,void 0,function*(){let t=yield this.m_transactions.getSame(this.m_transaction);this.displayList(t)})}setTransaction(t){this.m_transaction=t,this.m_transactions&&this.loadFromTransaction()}listenToTransactions(t){this.m_transactions=t,this.m_transactions.on("added",t=>{0!=this.m_update&&this.m_transaction&&this.m_transaction.category==t.category&&this.m_transaction.name==t.name&&this.update(t)}),this.m_transactions.on("changed",t=>{0!=this.m_update&&this.m_transaction&&this.m_transaction.category==t.category&&this.m_transaction.name==t.name&&this.update(t)}),this.m_transactions.on("removed",t=>{0!=this.m_update&&(this.m_element.find(`#info_${t.id}`).remove(),this.update())}),this.m_transaction&&this.m_update&&this.loadFromTransaction()}turnOffUpdates(){this.m_update=!1}turnOnUpdates(){this.m_update=!0}}},function(t,e){},function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))(function(r,o){function s(t){try{u(i.next(t))}catch(t){o(t)}}function a(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){t.done?r(t.value):new n(function(e){e(t.value)}).then(s,a)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0});const r=n(0);n(37);const o=n(1);e.default=class extends r.default{constructor(t,e,n,r,o){super("editrecurring_v2",{transaction:t,categories:r,names:o}),this.transaction=t,this.categories=r,this.saveTransaction=e||(()=>i(this,void 0,void 0,function*(){})),this.deleteTransaction=n||(()=>i(this,void 0,void 0,function*(){}))}afterOpen(){this.m_dialog.find("#period").on("validity",t=>{this.m_dialog.find("#btnSave").attr("disabled",!this.m_dialog.find("#period").timespan("valid"))}),this.m_dialog.find("#btnSave").on("click",()=>i(this,void 0,void 0,function*(){let t=$("#type").prop("checked");this.transaction.period=$("#period").val().toString(),this.transaction.start=$("#start").val().toString(),this.transaction.end=$("#end").val().toString(),this.transaction.category=$("#category").val().toString(),this.transaction.name=$("#name").val().toString(),this.transaction.amount=$("#amount").val()*(t?1:-1),this.transaction.cash=$("#cash").prop("checked")&&0==t,this.transaction.transfer=$("#transfer").prop("checked"),this.transaction.note=$("#note").val().toString(),this.transaction.scheduled=$("#scheduled").prop("checked"),o.default.show(),yield this.saveTransaction(this.transaction),o.default.hide(),this.close()})),this.m_dialog.find("#btnCancel").on("click",()=>{this.close()}),this.m_dialog.find("#btnDelete").on("click",()=>i(this,void 0,void 0,function*(){o.default.show(),yield this.deleteTransaction(this.transaction.id),o.default.hide(),this.close()})),this.m_dialog.find("input").on("keypress",t=>{13==t.charCode&&(t.preventDefault(),this.m_dialog.find("#btnSave").click())});let t=1*$(window).innerHeight(),e=this.m_dialog.outerHeight(!0);if(e>t){let n=e-t;this.m_dialog.find(".ui-field-contain").height(this.m_dialog.find(".ui-field-contain").height()-n),this.m_dialog.popup("reposition",{positionTo:"window"})}}}},function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))(function(r,o){function s(t){try{u(i.next(t))}catch(t){o(t)}}function a(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){t.done?r(t.value):new n(function(e){e(t.value)}).then(s,a)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0});const r=n(0),o=n(1);e.default=class extends r.default{constructor(t,e,n,r,o){super("edittransaction_v2",{transaction:t,categories:r,names:o}),this.transaction=t,this.saveTransaction=e||(()=>i(this,void 0,void 0,function*(){})),this.deleteTransaction=n||(()=>i(this,void 0,void 0,function*(){})),this.categories=r}afterOpen(){this.m_dialog.find("#btnSave").on("click",()=>i(this,void 0,void 0,function*(){let t=$("#type").prop("checked");this.transaction.date=$("#date").val().toString(),this.transaction.category=$("#category").val().toString(),this.transaction.name=$("#name").val().toString(),this.transaction.amount=$("#amount").val()*(t?1:-1),this.transaction.cash=$("#cash").prop("checked")&&0==t,this.transaction.transfer=$("#transfer").prop("checked"),this.transaction.paid=$("#paid").prop("checked"),this.transaction.scheduled=$("#scheduled").prop("checked"),this.transaction.note=$("#note").val().toString(),this.transaction.check=$("#checkNumber").val().toString(),o.default.show(),yield this.saveTransaction(this.transaction),o.default.hide(),this.close()})),this.m_dialog.find("#btnCancel").on("click",()=>{this.close()}),this.m_dialog.find("#btnDelete").on("click",()=>i(this,void 0,void 0,function*(){o.default.show(),yield this.deleteTransaction(this.transaction.id),o.default.hide(),this.close()})),this.m_dialog.find("input").on("keypress",t=>{13==t.charCode&&(t.preventDefault(),this.m_dialog.find("#btnSave").click())});let t=1*$(window).innerHeight(),e=this.m_dialog.outerHeight(!0);if(e>t){let n=e-t;this.m_dialog.find(".ui-field-contain").height(this.m_dialog.find(".ui-field-contain").height()-n),this.m_dialog.popup("reposition",{positionTo:"window"})}}}},function(t,e,n){"use strict";(function(t){var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))(function(r,o){function s(t){try{u(i.next(t))}catch(t){o(t)}}function a(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){t.done?r(t.value):new n(function(e){e(t.value)}).then(s,a)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0});const r=n(3),o=n(1),s=n(12),a=n(39),u=n(38),c="singletransaction";e.default=class extends r.default{constructor(t,e){super(),this.m_update=!0,this.SaveTransaction=(t=>i(this,void 0,void 0,function*(){return console.log("SAVETRANSACTION",t),null})),this.LoadTransaction=(t=>i(this,void 0,void 0,function*(){return console.log("LOADTRANSACTION:",t),null})),this.DeleteTransaction=(t=>i(this,void 0,void 0,function*(){return console.log("DELETETRANSACTION",t),null})),this.PreviewTransaction=(t=>i(this,void 0,void 0,function*(){return console.log("PREVIEWTRANSACTION",t),null})),this.LoadNames=(()=>i(this,void 0,void 0,function*(){return console.log("LOADNAMES"),[]})),this.SaveRecurring=(t=>i(this,void 0,void 0,function*(){return console.log("SAVERECURRING",t),null})),this.LoadRecurring=(t=>i(this,void 0,void 0,function*(){return console.log("LOADRECURRING:",t),null})),this.DeleteRecurring=(t=>i(this,void 0,void 0,function*(){return console.log("DELETERECURRING",t),null})),this.m_config=e,$(()=>{this.m_element=$(t).children("tbody"),this.m_tooltip=$(t).siblings(".tooltip"),$(window).on("resize",this.window_onResize)})}window_onResize(){let e=$(window).height()-$("[data-role=header]").height()-$("[data-role=footer]").height()-4+"px";t(()=>{$("#transaction_table").css({"max-height":e,height:e,"overflow-y":"scroll"}),$(".info_div").css({"max-height":e,height:e,"overflow-y":"scroll"})})}sorter(t,e){let n=this.m_config.categories.indexOf(t.category),i=this.m_config.categories.indexOf(e.category);return n!=i?n-i:t.name<e.name?-1:t.name>e.name?1:t.amount&&e.amount?e.amount-t.amount:0}rowSorter(t,e){return this.sorter({category:$(t).attr("category"),name:$(t).attr("name"),amount:parseFloat($(t).attr("amount"))},{category:$(e).attr("category"),name:$(e).attr("name"),amount:parseFloat($(e).attr("amount"))})}getRow(t){return $(t.target).is("tr")?$(t.target):$(t.target).parents("tr").first()}addListeners(){this.m_element.children("tr").off(),this.m_element.find("span.recurring").off(),this.m_element.find("[data-title]").off(),this.m_element.find("[data-title]").children().off(),this.m_element.children("tr").on("mouseover",this.onMouseOver.bind(this)),this.m_element.children("tr").on("mouseout",this.onMouseOut.bind(this)),this.m_element.children("tr").on("click",this.onClick.bind(this)),this.m_element.children("tr").on("dblclick",this.onDoubleClick.bind(this)),this.m_element.find("span.recurring").on("click",this.onRecurringClick.bind(this))}findTitleElement(t){return $(t.target).parent().jqmData("title")?$(t.target).parent():$(t.target)}onMouseOutTitle(t){let e=this.findTitleElement(t);e.jqmData("title")&&(e.data("titleShow",!1),this.m_tooltip.css("display","none"))}onMouseOverTitle(t){let e=this.findTitleElement(t);e.jqmData("title")&&(!0!==e.data("titleShow")&&(this.m_tooltip.text(e.jqmData("title")),this.m_tooltip.css({display:"",top:t.clientY-20+"px",left:t.clientX+"px"})),e.data("titleShow",!0))}editTransaction(t){return i(this,void 0,void 0,function*(){let e=yield this.LoadTransaction(t),n=yield this.LoadNames();null!=e&&new a.default(e,this.SaveTransaction,this.DeleteTransaction,this.m_config.categories,n).open()})}editRecurring(t){return i(this,void 0,void 0,function*(){let e=yield this.LoadRecurring(t),n=yield this.LoadNames();null!=e&&new u.default(e,this.SaveRecurring,this.DeleteRecurring,this.m_config.categories,n).open()})}get totalElement(){return $("#total_calc")}get balanceElement(){return $("#balance_calc")}get rows(){return this.m_element.children("tr")}onMouseOver(t){this.rows.css("background-color",""),this.rows.children("td").css("background-color",""),this.getRow(t).css("background-color","#eef"),this.getRow(t).children("td").css("background-color","#eef")}onMouseOut(){this.rows.css("background-color",""),this.rows.children("td").css("background-color","")}onDoubleClick(t){t.preventDefault();let e=this.getRow(t).attr("id");this.editTransaction(e)}onClick(t){t.preventDefault(),this.m_active_id=this.getRow(t).css("background-color","#eef").attr("id"),this.getRow(t).children("td").css("background-color","#eef"),this.PreviewTransaction(this.m_active_id)}onRecurringClick(t){t.preventDefault();let e=$(t.target);if(0==e.is("span.recurring")&&(e=e.parents("span.recurring")),!1===e.is("span.recurring"))return;let n=e.attr("recurring");this.editRecurring(n)}setTotal(t){$(()=>{this.totalElement.text("Budget Balance: "+t.toCurrency())})}setBalance(t){$(()=>{this.balanceElement.text("Bank Balance: "+t.toCurrency())})}editSelected(){this.m_active_id&&this.editTransaction(this.m_active_id)}display(t,e,n){let i=[];for(let e in t)i.push(t[e]);this.displayList(i,e,n)}updateRows(){let t=this.rows.toArray();if(this.m_element.empty(),t.sort(this.rowSorter.bind(this)),this.m_element.append(t),this.m_element.children("tr").length>0){let t=0,e=this.m_element.children("tr").first().attr("category"),n=this.m_element.children("tr").toArray();for(let i of n)$(i).attr("category")!=e&&(t=1-t,e=$(i).attr("category")),$(i).removeClass("row_0").removeClass("row_1").addClass("row_"+t)}this.addListeners(),this.window_onResize()}displayList(t,e,n){$(()=>{if(!this.m_element)return void setTimeout(()=>{this.displayList(t)},100);o.default.show(),e&&this.setTotal(e),n&&this.setBalance(n);let i=new Array;this.m_element.empty();for(let e of t)i.push(this.render(c,{item:e}).then(t=>{let e=$(t);this.m_element.append(e)}));Promise.all(i).then(()=>{this.updateRows(),s.default.hide()})})}update(t,e,n){$(()=>{e&&this.setTotal(e),n&&this.setBalance(n),this.m_element.children("#"+t.id).remove(),this.render(c,{item:t}).then(t=>{this.m_element.append($(t)),this.updateRows()})})}clear(){this.m_element.empty()}addTransaction(t){return i(this,void 0,void 0,function*(){let e={amount:0,category:this.m_config.categories[0],date:t,name:""},n=yield this.LoadNames();new a.default(e,this.SaveTransaction,()=>{},this.m_config.categories,n).open()})}addRecurring(t){return i(this,void 0,void 0,function*(){let e=t,n=Date.parseFb(e).add("1 year").toFbString(),i={amount:0,category:this.m_config.categories[0],end:n,name:"",period:"1 month",start:e},r=yield this.LoadNames();new u.default(i,this.SaveRecurring,()=>{},this.m_config.categories,r).open()})}listenToTransactions(t){t.on("addedinperiod",e=>i(this,void 0,void 0,function*(){if(0==this.m_update)return;let n=yield t.getTotal(),i=yield t.getBalance(n);this.update(e,n,i)})),t.on("addedbeforeperiod",e=>i(this,void 0,void 0,function*(){if(0==this.m_update)return;let e=yield t.getTotal(),n=yield t.getBalance(e);this.setTotal(e),this.setBalance(n)})),t.on("changed",e=>i(this,void 0,void 0,function*(){if(0==this.m_update)return;let n=yield t.getTotal(),i=yield t.getBalance(n);t.Start<=e.date&&e.date<=t.End?this.update(e,n,i):(this.m_element.children("#"+e.id).remove(),this.setTotal(n),this.setBalance(i))})),t.on("removedinperiod",e=>i(this,void 0,void 0,function*(){if(0==this.m_update)return;let n=yield t.getTotal(),i=yield t.getBalance(n);this.m_element.children("#"+e.id).remove(),this.setTotal(n),this.setBalance(i)})),t.on("removedbeforeperiod",e=>i(this,void 0,void 0,function*(){if(0==this.m_update)return;let n=yield t.getTotal(),i=yield t.getBalance(n);this.m_element.children("#"+e.id).remove(),this.setTotal(n),this.setBalance(i)})),t.on("periodloaded",(t,e,n)=>i(this,void 0,void 0,function*(){0!=this.m_update&&this.displayList(t,e,n)}))}turnOffUpdates(){this.m_update=!1}turnOnUpdates(){this.m_update=!0}}}).call(this,n(7).setImmediate)},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=class{constructor(t){$(()=>{this.element=$(t)}),this.m_disabled=!1}on(t,e){return $(()=>{this.element?this.element.on(t,null,null,e):setTimeout(()=>{this.on(t,e)},100)}),this}off(t,e){return $(()=>{this.element?this.element.off(t,null,e):setTimeout(()=>{this.off(t,e)},100)}),this}click(){return $(()=>{this.element?this.element.click():setTimeout(()=>{this.click()},100)}),this}get disabled(){return this.m_disabled}set disabled(t){this.m_disabled=t,$(()=>{this.element?t?this.element.addClass("ui-disabled"):this.element.removeClass("ui-disabled"):setTimeout(()=>{this.disabled=t},100)})}get visible(){return"none"!==this.element.css("display")}}},function(t,e,n){"use strict";(function(t){var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))(function(r,o){function s(t){try{u(i.next(t))}catch(t){o(t)}}function a(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){t.done?r(t.value):new n(function(e){e(t.value)}).then(s,a)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0});const r=n(9);n(5);const o=n(2);e.default=class extends o.default{constructor(e,n){super(),this.pointer=0;var i=new Array,o=0;if(window.localStorage&&null!==localStorage.getItem("budget.history")){let t=JSON.parse(localStorage.getItem("budget.history"))[r.auth().currentUser.uid];t&&(i.push(...t.items),o=t.pointer)}this.pointer=o,this.items=new Array(...i),this.transactions=e,this.recurring=n,t(()=>this.emitAsync("change"))}storeHistory(){if(window.localStorage){let t=JSON.parse(window.localStorage.getItem("budget.history")||"{}");t[r.auth().currentUser.uid]=this.toJSON(),window.localStorage.setItem("budget.history",JSON.stringify(t))}}push(t){this.items.splice(this.pointer),this.pointer++;let e=this.items.push(t);for(;this.items.length>100;)this.items.shift(),this.pointer--;return this.storeHistory(),this.emitAsync("change"),e}get canUndo(){return this.pointer>0}get canRedo(){return this.pointer<this.items.length}revertChange(t){return i(this,void 0,void 0,function*(){if(t.initial)switch(t.type){case"Recurring":yield this.recurring.save(t.initial);break;case"Transaction":yield this.transactions.save(t.initial)}})}redoChange(t){return i(this,void 0,void 0,function*(){if(t.final)switch(t.type){case"Recurring":yield this.recurring.save(t.final);break;case"Transaction":yield this.transactions.save(t.final)}})}revertCreate(t){return i(this,void 0,void 0,function*(){switch(t.type){case"Recurring":let e={amount:t.final.amount,cash:t.final.cash,category:t.final.category,end:t.final.end,id:t.final.id,name:t.final.name,note:t.final.note,period:t.final.period,start:t.final.start,transfer:t.final.transfer,delete:t.final.active};yield this.recurring.save(e);break;case"Transaction":yield this.transactions.remove(t.final)}})}redoCreate(t){return i(this,void 0,void 0,function*(){switch(t.type){case"Recurring":yield this.recurring.save(t.final);break;case"Transaction":yield this.transactions.save(t.final)}})}revertDelete(t){return i(this,void 0,void 0,function*(){switch(t.type){case"Recurring":let e={amount:t.final.amount,cash:t.final.cash,category:t.final.category,end:t.final.end,id:t.final.id,name:t.final.name,note:t.final.note,period:t.final.period,start:t.final.start,transfer:t.final.transfer,active:t.final.delete};yield this.recurring.save(e);break;case"Transaction":yield this.transactions.save(t.final)}})}redoDelete(t){return i(this,void 0,void 0,function*(){switch(t.type){case"Recurring":yield this.recurring.save(t.final);break;case"Transaction":yield this.transactions.remove(t.final)}})}undo(){return i(this,void 0,void 0,function*(){if(!this.canUndo)return;this.pointer--;let t=this.items[this.pointer];for(let e of t.items)switch(e.action){case"change":yield this.revertChange(e);break;case"create":yield this.revertCreate(e);break;case"delete":yield this.revertDelete(e)}this.emitAsync("change"),this.storeHistory()})}redo(){return i(this,void 0,void 0,function*(){if(!this.canRedo)return;let t=this.items[this.pointer];for(let e of t.items)switch(e.action){case"change":yield this.redoChange(e);break;case"create":yield this.redoCreate(e);break;case"delete":yield this.redoDelete(e)}this.pointer++,this.emitAsync("change"),this.storeHistory()})}clear(){this.items=[],this.pointer=0,this.emitAsync("change"),this.storeHistory()}toJSON(){return{pointer:this.pointer,items:this.items}}}}).call(this,n(7).setImmediate)},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(13);e.default=class extends i.Records{constructor(t){super(t)}sanitizeAfterRead(t){return null===t?null:(t.cash=t.cash||!1,t.note=t.note||null,t.transfer=t.transfer||!1,t.scheduled=t.scheduled||!1,t)}sanitizeBeforeWrite(t){return t.cash=t.cash?t.cash:null,t.note=void 0===t.note||""===t.note?null:t.note,t.transfer=t.transfer?t.transfer:null,t.scheduled=t.scheduled?t.scheduled:null,t}}},function(t,e){"padStart"in String.prototype==0&&(String.prototype.padStart=((t,e=" ")=>{let n=this;for(;n.length<t;)n=e+n;return n})),"padEnd"in String.prototype==0&&(String.prototype.padEnd=((t,e=" ")=>{let n=this;for(;n.length<t;)n+=e;return n}))},function(t,e){Math.roundTo=function(t,e){var n=Math.pow(10,Math.round(e));return Math.round(t*n)/n},"sign"in Math==0&&(Math.sign=function(t){return t<0?-1:t>0?1:0})},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});class i{constructor(){this.hundreds=0,this.fifties=0,this.twenties=0,this.tens=0,this.fives=0,this.ones=0,this.cent25=0,this.cent10=0,this.cent5=0,this.cent1=0}static default(){return new i}add(t){this.hundreds+=t.hundreds,this.fifties+=t.fifties,this.twenties+=t.twenties,this.tens+=t.tens,this.fives+=t.fives,this.ones+=t.ones,this.cent25+=t.cent25,this.cent10+=t.cent10,this.cent5+=t.cent5,this.cent1+=t.cent1}getTotal(){return Math.roundTo(100*this.hundreds+50*this.fifties+20*this.twenties+10*this.tens+5*this.fives+this.ones+.25*this.cent25+.1*this.cent10+.05*this.cent5+.01*this.cent1,2)}}e.default=i},function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))(function(r,o){function s(t){try{u(i.next(t))}catch(t){o(t)}}function a(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){t.done?r(t.value):new n(function(e){e(t.value)}).then(s,a)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0});const r=n(13),o=n(46);n(14),n(45),n(44);class s{}s.Added="added",s.AddedInPeriod="addedinperiod",s.AddedBeforePeriod="addedbeforeperiod",s.AddedAfterPeriod="addedafterperiod",s.Changed="changed",s.ChangedInPeriod="changedinperiod",s.ChangedBeforePeriod="changedbeforeperiod",s.ChangedAfterPeriod="changedafterperiod",s.Removed="removed",s.RemovedInPeriod="removedinperiod",s.RemovedBeforePeriod="removedbeforeperiod",s.RemovedAfterPeriod="removedafterperiod",s.Save="saved",s.SavedInPeriod="savedinperiod",s.SavedBeforePeriod="savedbeforeperiod",s.SavedAfterPeriod="savedafterperiod",e.default=class extends r.Records{constructor(t){super(t),this.records={}}sanitizeAfterRead(t){return t.cash=t.cash||!1,t.check=t.check||null,t.note=t.note||void 0,t.paid=t.paid||!1,t.scheduled=t.scheduled||!1,t.recurring=t.recurring||null,t.transfer=t.transfer||!1,t}sanitizeBeforeWrite(t){return t.cash=t.cash?t.cash:null,t.check=void 0===t.check||""===t.check?null:t.check,t.note=void 0===t.note||""===t.note?null:t.note,t.paid=t.paid?t.paid:null,t.scheduled=t.scheduled?t.scheduled:null,t.recurring=void 0===t.recurring||""===t.recurring?null:t.recurring,t.transfer=t.transfer?t.transfer:null,t}onChildAdded(t){return i(this,void 0,void 0,function*(){this.periodStart&&this.periodEnd&&(this.periodStart<=t.date&&t.date<=this.periodEnd?(this.records||(this.records={}),this.records[t.id]=t,this.emitAsync(s.AddedInPeriod,t,this)):t.date<this.periodStart?this.emitAsync(s.AddedBeforePeriod,t,this):this.emitAsync(s.AddedAfterPeriod,t,this),this.emitAsync(s.Added,t,this))})}onChildChanged(t){return i(this,void 0,void 0,function*(){this.periodStart&&this.periodEnd&&(this.periodStart<=t.date&&t.date<=this.periodEnd?(this.records[t.id]=t,this.emitAsync(s.ChangedInPeriod,t,this)):(t.id in this.records&&delete this.records[t.id],t.date<this.periodStart?this.emitAsync(s.ChangedBeforePeriod,t,this):this.emitAsync(s.ChangedAfterPeriod,t,this)),this.emitAsync(s.Changed,t,this))})}onChildRemoved(t){return i(this,void 0,void 0,function*(){this.periodStart&&this.periodEnd&&(t.id in this.records&&delete this.records[t.id],this.periodStart<=t.date&&t.date<=this.periodEnd?this.emitAsync(s.RemovedInPeriod,t,this):t.date<this.periodStart?this.emitAsync(s.RemovedBeforePeriod,t,this):this.emitAsync(s.RemovedAfterPeriod,t,this),this.emitAsync(s.Removed,t,this))})}onChildSaved(t,e){return i(this,void 0,void 0,function*(){this.periodStart&&this.periodEnd&&(this.periodStart<=t.date&&t.date<=this.periodEnd?this.records[t.id]=t:delete this.records[t.id])})}get TransactionList(){return Object.values(this.records)}get Records(){return this.records||{}}get List(){return this.TransactionList}get Start(){return this.periodStart}get End(){return this.periodEnd}get Cash(){let t=o.default.default();for(let e of this.TransactionList)!0===e.cash&&!0!==e.paid&&e.amount<0&&t.add(Math.abs(e.amount).toCash());return t}get Transfer(){return this.TransactionList.filter(t=>t.transfer&&!t.paid).map(t=>t.amount).reduce((t,e)=>t-e,0)}getSame(t){return i(this,void 0,void 0,function*(){let e=yield this.loadRecordsByChild("name",t.name,t.name);return this.convertToArray(e).filter(e=>e.category===t.category)})}loadPeriod(t,e){return i(this,void 0,void 0,function*(){this.periodStart=t,this.periodEnd=e,this.records=yield this.loadRecordsByChild("date",t,e);let n=yield this.getTotal(),i=yield this.getBalance(n);return this.emitAsync("periodloaded",this.TransactionList,n,i),this.records})}getRecurring(t){return i(this,void 0,void 0,function*(){return yield this.loadRecordsByChild("recurring",t,t)})}getTotal(){return i(this,void 0,void 0,function*(){if(!this.periodStart||!this.periodEnd)return Number.NaN;let t=yield this.loadRecordsByChild("date",null,this.periodEnd),e=0;for(let n in t)e+=t[n].amount;return e})}getBalance(t){return i(this,void 0,void 0,function*(){if(!this.periodStart||!this.periodEnd)return Number.NaN;let e=t=t||(yield this.getTotal());0==this.TransactionList.length&&(this.records=yield this.loadRecordsByChild("date",this.periodStart,this.periodEnd));for(let t of this.TransactionList)!0!==t.paid&&(e-=t.amount);return e})}search(t,e=!0,n=!1){return i(this,void 0,void 0,function*(){let i;return i="string"==typeof t?new RegExp(t,"i"):t,this.convertToArray(yield this.loadRecords()).filter(t=>!(!e||!i.test(t.name))||!(!n||!i.test(t.category)))})}LoadNames(){return i(this,void 0,void 0,function*(){let t=yield this.loadRecords();if(void 0==t||null==t)return[];let e=Object.values(yield this.loadRecords());if(e.length<=0)return[];let n=Array.from(new Set(e.map(t=>t.name)));return n.sort(),n})}Date2Excel(t){let e;return(e="string"==typeof t?Date.parseFb(t):t).getFullYear().toString().padStart(4,"0")+"/"+(e.getMonth()+1).toString().padStart(2,"0")+"/"+e.getDate().toString().padStart(2,"0")}getCsv(t,e){return i(this,void 0,void 0,function*(){let n=this.convertToArray(yield this.loadRecordsByChild("date",t,e)),i="Category,Name,Date,Cash,Transfer,Amount,Paid,Memo";n.sort((t,e)=>Date.parseFb(t.date).getTime()-Date.parseFb(e.date).getTime());for(let t of n)i+=`\r\n"${t.category.replace('"','""')}","${t.name.replace('"','""')}","${this.Date2Excel(t.date)}",${t.cash},${t.transfer},"${t.amount.toCurrency()}",${t.paid},${t.note?'"'+t.note+'"':""}`;return i})}}},function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))(function(r,o){function s(t){try{u(i.next(t))}catch(t){o(t)}}function a(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){t.done?r(t.value):new n(function(e){e(t.value)}).then(s,a)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.default=class{constructor(t){this.data={categories:["Income","Charity","Saving","Housing","Utilities","Food","Clothing","Transportation","Medical","Insurance","Personal","Recreation","Debt"],periods:{length:"2 weeks",start:"2016-06-24"},theme:"default"},this.ref=t}read(){return i(this,void 0,void 0,function*(){let t=yield this.ref.child("config").once("value");return t.val()&&(this.data=t.val()),this.data})}write(){return i(this,void 0,void 0,function*(){yield this.ref.child("config").set(this.data)})}get categories(){return this.data.categories}set categories(t){this.data.categories=t}get start(){return this.data.periods.start}set start(t){this.data.periods.start=t}get length(){return this.data.periods.length}set length(t){this.data.periods.length=t}get theme(){return this.data.theme||"default"}set theme(t){this.data.theme=t}calculatePeriod(t){"string"==typeof t&&(t=Date.parseFb(t));let e=t.periodCalc(this.start,this.length),n=e.add(this.length).subtract("1 day");return{start:e.toFbString(),end:n.toFbString()}}toJSON(){return this.data}}},function(t,e,n){"use strict";(function(t){var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))(function(r,o){function s(t){try{u(i.next(t))}catch(t){o(t)}}function a(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){t.done?r(t.value):new n(function(e){e(t.value)}).then(s,a)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),n(5),n(4);const r=n(2),o=n(48),s=n(47),a=n(43),u=n(42);n(15);const c=n(1);e.default=class extends r.default{constructor(t){super(),this.isReady=!1,this.root=t,this.config=new o.default(t),this.root.child("name").once("value").then(t=>{console.log("Running on:",t.val().toString())}),this.config.read().then(()=>{this.root.child("accounts").orderByChild("name").startAt("Primary").endAt("Primary").once("child_added").then(t=>{this.account=t.ref,this.transactions=new s.default(this.account.child("transactions")),this.recurring=new a.default(this.account.child("recurring")),this.history=new u.default(this.transactions,this.recurring),this.history.on("change",()=>{this.emitAsync("history_change")}),this.emitAsync("config_read")})}),this.readyPromise=new Promise((t,e)=>{this.readyResolver=t})}get CanUndo(){return this.history&&this.history.canUndo}get CanRedo(){return this.history&&this.history.canRedo}Undo(){return i(this,void 0,void 0,function*(){return yield this.history.undo()})}Redo(){return i(this,void 0,void 0,function*(){return yield this.history.redo()})}get Transactions(){return this.transactions}get Recurrings(){return this.recurring}get Config(){return this.config}get Start(){return this.transactions.Start}get End(){return this.transactions.End}ready(){return this.readyPromise}gotoDate(e){return i(this,void 0,void 0,function*(){c.default.show(),t(()=>i(this,void 0,void 0,function*(){this.period=this.config.calculatePeriod(e),yield this.transactions.loadPeriod(this.period.start,this.period.end),!1===this.isReady&&(this.isReady=!0,this.readyResolver(!0)),this.emitAsync("loadperiod",this.transactions.Records,this)}))})}getBackup(){return i(this,void 0,void 0,function*(){return(yield this.root.once("value")).val()})}setBackup(t){return i(this,void 0,void 0,function*(){yield this.account.set(t)})}saveTransaction(t){return i(this,void 0,void 0,function*(){let e=t.id?yield this.transactions.load(t.id):null,n={items:[{action:t.id?"change":"create",type:"Transaction",initial:e,final:t}]},i=yield this.Transactions.save(t);return n.items[0].final.id=i,this.history.push(n),i})}removeTransaction(t){return i(this,void 0,void 0,function*(){"string"==typeof t&&(t=yield this.transactions.load(t));let e=yield this.Transactions.remove(t);return this.history.push({items:[{action:"delete",type:"Transaction",final:t}]}),e})}saveRecurring(t){return i(this,void 0,void 0,function*(){let e,n=null,i=Date.periodCalc(this.config.start,this.config.length).toFbString();i<this.transactions.Start&&(i=this.transactions.Start),t.id&&((n=yield this.Recurrings.load(t.id)).active=i),e={items:[{action:t.id?"change":"create",type:"Recurring",initial:n,final:t}]},t.active=i;let r=yield this.Recurrings.save(t);return e.items[0].final.id=r,this.history.push(e),r})}removeRecurring(t){return i(this,void 0,void 0,function*(){"string"==typeof t&&(t=yield this.recurring.load(t));let e={items:[{action:"delete",type:"Recurring",final:t}]};if(t.id){let n=Date.periodCalc(this.config.start,this.config.length).toFbString();n<this.transactions.Start&&(n=this.transactions.Start),t.delete=n,yield this.Recurrings.save(t),this.history.push(e)}return t.id})}rollUpTo(t){return new Promise((e,n)=>i(this,void 0,void 0,function*(){let n=(yield this.account.child("transactions").orderByChild("date").startAt(this.config.start).endAt(t).once("value")).val(),i={};for(let e in n){let r=n[e];null==i[r.category]&&(i[r.category]={}),null==i[r.category][r.name]?(i[r.category][r.name]=r,i[r.category][r.name].date=t):i[r.category][r.name].amount+=r.amount}let r=[];for(let t in n)r.push(this.account.child("transactions").child(t).remove());for(let t in i)for(let e in i[t])r.push(new Promise((n,r)=>{this.account.child("transactions").push(i[t][e]).then(()=>{n()})}));yield Promise.all(r),e()}))}}}).call(this,n(7).setImmediate)},function(t,e,n){"use strict";n.r(e),n.d(e,"setLogLevel",function(){return u}),n.d(e,"Logger",function(){return a}),n.d(e,"LogLevel",function(){return i});var i,r=[];!function(t){t[t.DEBUG=0]="DEBUG",t[t.VERBOSE=1]="VERBOSE",t[t.INFO=2]="INFO",t[t.WARN=3]="WARN",t[t.ERROR=4]="ERROR",t[t.SILENT=5]="SILENT"}(i||(i={}));var o=i.INFO,s=function(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];if(!(e<t.logLevel)){var o=(new Date).toISOString();switch(e){case i.DEBUG:case i.VERBOSE:console.log.apply(console,["["+o+"]  "+t.name+":"].concat(n));break;case i.INFO:console.info.apply(console,["["+o+"]  "+t.name+":"].concat(n));break;case i.WARN:console.warn.apply(console,["["+o+"]  "+t.name+":"].concat(n));break;case i.ERROR:console.error.apply(console,["["+o+"]  "+t.name+":"].concat(n));break;default:throw new Error("Attempted to log a message with an invalid logType (value: "+e+")")}}},a=function(){function t(t){this.name=t,this._logLevel=o,this._logHandler=s,r.push(this)}return Object.defineProperty(t.prototype,"logLevel",{get:function(){return this._logLevel},set:function(t){if(!(t in i))throw new TypeError("Invalid value assigned to `logLevel`");this._logLevel=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"logHandler",{get:function(){return this._logHandler},set:function(t){if("function"!=typeof t)throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=t},enumerable:!0,configurable:!0}),t.prototype.debug=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._logHandler.apply(this,[this,i.DEBUG].concat(t))},t.prototype.log=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._logHandler.apply(this,[this,i.VERBOSE].concat(t))},t.prototype.info=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._logHandler.apply(this,[this,i.INFO].concat(t))},t.prototype.warn=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._logHandler.apply(this,[this,i.WARN].concat(t))},t.prototype.error=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._logHandler.apply(this,[this,i.ERROR].concat(t))},t}();function u(t){r.forEach(function(e){e.logLevel=t})}},function(t,e,n){"use strict";(function(i){Object.defineProperty(e,"__esModule",{value:!0});var r,o,s,a,u,c,h,l,d,f,p,v,g=n(17),y=n(50),m=n(16),_=(r=n(8))&&"object"==typeof r&&"default"in r?r.default:r,b=function(){function t(t){this.domStorage_=t,this.prefix_="firebase:"}return t.prototype.set=function(t,e){null==e?this.domStorage_.removeItem(this.prefixedName_(t)):this.domStorage_.setItem(this.prefixedName_(t),g.stringify(e))},t.prototype.get=function(t){var e=this.domStorage_.getItem(this.prefixedName_(t));return null==e?null:g.jsonEval(e)},t.prototype.remove=function(t){this.domStorage_.removeItem(this.prefixedName_(t))},t.prototype.prefixedName_=function(t){return this.prefix_+t},t.prototype.toString=function(){return this.domStorage_.toString()},t}(),w=function(){function t(){this.cache_={},this.isInMemoryStorage=!0}return t.prototype.set=function(t,e){null==e?delete this.cache_[t]:this.cache_[t]=e},t.prototype.get=function(t){return g.contains(this.cache_,t)?this.cache_[t]:null},t.prototype.remove=function(t){delete this.cache_[t]},t}(),C=function(t){try{if("undefined"!=typeof window&&void 0!==window[t]){var e=window[t];return e.setItem("firebase:sentinel","cache"),e.removeItem("firebase:sentinel"),new b(e)}}catch(t){}return new w},T=C("localStorage"),E=C("sessionStorage"),S=new y.Logger("@firebase/database"),I=(o=1,function(){return o++}),k=function(t){var e=g.stringToByteArray(t),n=new g.Sha1;n.update(e);var i=n.digest();return g.base64.encodeByteArray(i)},A=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n="",i=0;i<t.length;i++)Array.isArray(t[i])||t[i]&&"object"==typeof t[i]&&"number"==typeof t[i].length?n+=A.apply(null,t[i]):"object"==typeof t[i]?n+=g.stringify(t[i]):n+=t[i],n+=" ";return n},P=null,N=!0,D=function(t,e){g.assert(!e||!0===t||!1===t,"Can't turn on custom loggers persistently."),!0===t?(S.logLevel=y.LogLevel.VERBOSE,P=S.log.bind(S),e&&E.set("logging_enabled",!0)):"function"==typeof t?P=t:(P=null,E.remove("logging_enabled"))},R=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(!0===N&&(N=!1,null===P&&!0===E.get("logging_enabled")&&D(!0)),P){var n=A.apply(null,t);P(n)}},O=function(t){return function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];R.apply(void 0,[t].concat(e))}},x=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="FIREBASE INTERNAL ERROR: "+A.apply(void 0,t);S.error(n)},M=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="FIREBASE FATAL ERROR: "+A.apply(void 0,t);throw S.error(n),new Error(n)},L=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="FIREBASE WARNING: "+A.apply(void 0,t);S.warn(n)},F=function(t){return"number"==typeof t&&(t!=t||t==Number.POSITIVE_INFINITY||t==Number.NEGATIVE_INFINITY)},U="[MIN_NAME]",j="[MAX_NAME]",W=function(t,e){if(t===e)return 0;if(t===U||e===j)return-1;if(e===U||t===j)return 1;var n=Q(t),i=Q(e);return null!==n?null!==i?n-i==0?t.length-e.length:n-i:-1:null!==i?1:t<e?-1:1},B=function(t,e){return t===e?0:t<e?-1:1},$=function(t,e){if(e&&t in e)return e[t];throw new Error("Missing required key ("+t+") in object: "+g.stringify(e))},V=function(t){if("object"!=typeof t||null===t)return g.stringify(t);var e=[];for(var n in t)e.push(n);e.sort();for(var i="{",r=0;r<e.length;r++)0!==r&&(i+=","),i+=g.stringify(e[r]),i+=":",i+=V(t[e[r]]);return i+"}"},q=function(t,e){var n=t.length;if(n<=e)return[t];for(var i=[],r=0;r<n;r+=e)r+e>n?i.push(t.substring(r,n)):i.push(t.substring(r,r+e));return i},H=function(t,e){if(Array.isArray(t))for(var n=0;n<t.length;++n)e(n,t[n]);else g.forEach(t,function(t,n){return e(n,t)})},z=function(t){var e,n,i,r,o,s,a;for(g.assert(!F(t),"Invalid JSON number"),0===t?(n=0,i=0,e=1/t==-1/0?1:0):(e=t<0,(t=Math.abs(t))>=Math.pow(2,-1022)?(n=(r=Math.min(Math.floor(Math.log(t)/Math.LN2),1023))+1023,i=Math.round(t*Math.pow(2,52-r)-Math.pow(2,52))):(n=0,i=Math.round(t/Math.pow(2,-1074)))),s=[],o=52;o;o-=1)s.push(i%2?1:0),i=Math.floor(i/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 u="";for(o=0;o<64;o+=8){var c=parseInt(a.substr(o,8),2).toString(16);1===c.length&&(c="0"+c),u+=c}return u.toLowerCase()},K=new RegExp("^-?\\d{1,10}$"),Q=function(t){if(K.test(t)){var e=Number(t);if(e>=-2147483648&&e<=2147483647)return e}return null},Y=function(t){try{t()}catch(t){setTimeout(function(){var e=t.stack||"";throw L("Exception was thrown by user callback.",e),t},Math.floor(0))}},G=function(){return("object"==typeof window&&window.navigator&&window.navigator.userAgent||"").search(/googlebot|google webmaster tools|bingbot|yahoo! slurp|baiduspider|yandexbot|duckduckbot/i)>=0},X=function(t,e){var n=setTimeout(t,e);return"object"==typeof n&&n.unref&&n.unref(),n},J=function(){function t(t,e){if(void 0===e){this.pieces_=t.split("/");for(var n=0,i=0;i<this.pieces_.length;i++)this.pieces_[i].length>0&&(this.pieces_[n]=this.pieces_[i],n++);this.pieces_.length=n,this.pieceNum_=0}else this.pieces_=t,this.pieceNum_=e}return Object.defineProperty(t,"Empty",{get:function(){return new t("")},enumerable:!0,configurable:!0}),t.prototype.getFront=function(){return this.pieceNum_>=this.pieces_.length?null:this.pieces_[this.pieceNum_]},t.prototype.getLength=function(){return this.pieces_.length-this.pieceNum_},t.prototype.popFront=function(){var e=this.pieceNum_;return e<this.pieces_.length&&e++,new t(this.pieces_,e)},t.prototype.getBack=function(){return this.pieceNum_<this.pieces_.length?this.pieces_[this.pieces_.length-1]:null},t.prototype.toString=function(){for(var t="",e=this.pieceNum_;e<this.pieces_.length;e++)""!==this.pieces_[e]&&(t+="/"+this.pieces_[e]);return t||"/"},t.prototype.toUrlEncodedString=function(){for(var t="",e=this.pieceNum_;e<this.pieces_.length;e++)""!==this.pieces_[e]&&(t+="/"+encodeURIComponent(String(this.pieces_[e])));return t||"/"},t.prototype.slice=function(t){return void 0===t&&(t=0),this.pieces_.slice(this.pieceNum_+t)},t.prototype.parent=function(){if(this.pieceNum_>=this.pieces_.length)return null;for(var e=[],n=this.pieceNum_;n<this.pieces_.length-1;n++)e.push(this.pieces_[n]);return new t(e,0)},t.prototype.child=function(e){for(var n=[],i=this.pieceNum_;i<this.pieces_.length;i++)n.push(this.pieces_[i]);if(e instanceof t)for(i=e.pieceNum_;i<e.pieces_.length;i++)n.push(e.pieces_[i]);else{var r=e.split("/");for(i=0;i<r.length;i++)r[i].length>0&&n.push(r[i])}return new t(n,0)},t.prototype.isEmpty=function(){return this.pieceNum_>=this.pieces_.length},t.relativePath=function(e,n){var i=e.getFront(),r=n.getFront();if(null===i)return n;if(i===r)return t.relativePath(e.popFront(),n.popFront());throw new Error("INTERNAL ERROR: innerPath ("+n+") is not within outerPath ("+e+")")},t.comparePaths=function(t,e){for(var n=t.slice(),i=e.slice(),r=0;r<n.length&&r<i.length;r++){var o=W(n[r],i[r]);if(0!==o)return o}return n.length===i.length?0:n.length<i.length?-1:1},t.prototype.equals=function(t){if(this.getLength()!==t.getLength())return!1;for(var e=this.pieceNum_,n=t.pieceNum_;e<=this.pieces_.length;e++,n++)if(this.pieces_[e]!==t.pieces_[n])return!1;return!0},t.prototype.contains=function(t){var e=this.pieceNum_,n=t.pieceNum_;if(this.getLength()>t.getLength())return!1;for(;e<this.pieces_.length;){if(this.pieces_[e]!==t.pieces_[n])return!1;++e,++n}return!0},t}(),Z=function(){function t(t,e){this.errorPrefix_=e,this.parts_=t.slice(),this.byteLength_=Math.max(1,this.parts_.length);for(var n=0;n<this.parts_.length;n++)this.byteLength_+=g.stringLength(this.parts_[n]);this.checkValid_()}return Object.defineProperty(t,"MAX_PATH_DEPTH",{get:function(){return 32},enumerable:!0,configurable:!0}),Object.defineProperty(t,"MAX_PATH_LENGTH_BYTES",{get:function(){return 768},enumerable:!0,configurable:!0}),t.prototype.push=function(t){this.parts_.length>0&&(this.byteLength_+=1),this.parts_.push(t),this.byteLength_+=g.stringLength(t),this.checkValid_()},t.prototype.pop=function(){var t=this.parts_.pop();this.byteLength_-=g.stringLength(t),this.parts_.length>0&&(this.byteLength_-=1)},t.prototype.checkValid_=function(){if(this.byteLength_>t.MAX_PATH_LENGTH_BYTES)throw new Error(this.errorPrefix_+"has a key path longer than "+t.MAX_PATH_LENGTH_BYTES+" bytes ("+this.byteLength_+").");if(this.parts_.length>t.MAX_PATH_DEPTH)throw new Error(this.errorPrefix_+"path specified exceeds the maximum depth that can be written ("+t.MAX_PATH_DEPTH+") or object contains a cycle "+this.toErrorString())},t.prototype.toErrorString=function(){return 0==this.parts_.length?"":"in property '"+this.parts_.join(".")+"'"},t}(),tt="long_polling",et=function(){function t(t,e,n,i,r){void 0===r&&(r=""),this.secure=e,this.namespace=n,this.webSocketOnly=i,this.persistenceKey=r,this.host=t.toLowerCase(),this.domain=this.host.substr(this.host.indexOf(".")+1),this.internalHost=T.get("host:"+t)||this.host}return t.prototype.needsQueryParam=function(){return this.host!==this.internalHost||this.isCustomHost()},t.prototype.isCacheableHost=function(){return"s-"===this.internalHost.substr(0,2)},t.prototype.isDemoHost=function(){return"firebaseio-demo.com"===this.domain},t.prototype.isCustomHost=function(){return"firebaseio.com"!==this.domain&&"firebaseio-demo.com"!==this.domain},t.prototype.updateHost=function(t){t!==this.internalHost&&(this.internalHost=t,this.isCacheableHost()&&T.set("host:"+this.host,this.internalHost))},t.prototype.connectionURL=function(t,e){var n;if(g.assert("string"==typeof t,"typeof type must == string"),g.assert("object"==typeof e,"typeof params must == object"),"websocket"===t)n=(this.secure?"wss://":"ws://")+this.internalHost+"/.ws?";else{if(t!==tt)throw new Error("Unknown connection type: "+t);n=(this.secure?"https://":"http://")+this.internalHost+"/.lp?"}this.needsQueryParam()&&(e.ns=this.namespace);var i=[];return g.forEach(e,function(t,e){i.push(t+"="+e)}),n+i.join("&")},t.prototype.toString=function(){var t=this.toURLString();return this.persistenceKey&&(t+="<"+this.persistenceKey+">"),t},t.prototype.toURLString=function(){return(this.secure?"https://":"http://")+this.host},t}(),nt=function(t){var e=it(t),n=e.subdomain;"firebase"===e.domain&&M(e.host+" is no longer supported. Please use <YOUR FIREBASE>.firebaseio.com instead"),n&&"undefined"!=n||"localhost"===e.domain||M("Cannot parse Firebase url. Please use https://<YOUR FIREBASE>.firebaseio.com"),e.secure||"undefined"!=typeof window&&window.location&&window.location.protocol&&-1!==window.location.protocol.indexOf("https:")&&L("Insecure Firebase access from a secure page. Please use https in calls to new Firebase().");var i="ws"===e.scheme||"wss"===e.scheme;return{repoInfo:new et(e.host,e.secure,n,i),path:new J(e.pathString)}},it=function(t){var e="",n="",i="",r="",o=!0,s="https",a=443;if("string"==typeof t){var u=t.indexOf("//");u>=0&&(s=t.substring(0,u-1),t=t.substring(u+2));var c=t.indexOf("/");-1===c&&(c=t.length);var h=t.indexOf("?");-1===h&&(h=t.length),e=t.substring(0,Math.min(c,h)),c<h&&(r=function(t){for(var e="",n=t.split("/"),i=0;i<n.length;i++)if(n[i].length>0){var r=n[i];try{r=decodeURIComponent(r.replace(/\+/g," "))}catch(t){}e+="/"+r}return e}(t.substring(c,h)));var l=function(t){var e={};t.startsWith("?")&&(t=t.substring(1));for(var n=0,i=t.split("&");n<i.length;n++){var r=i[n];if(0!==r.length){var o=r.split("=");2===o.length?e[decodeURIComponent(o[0])]=decodeURIComponent(o[1]):L("Invalid query segment '"+r+"' in query '"+t+"'")}}return e}(t.substring(Math.min(t.length,h)));(u=e.indexOf(":"))>=0?(o="https"===s||"wss"===s,a=parseInt(e.substring(u+1),10)):u=t.length;var d=e.split(".");3===d.length?(n=d[1],i=d[0].toLowerCase()):2===d.length?n=d[0]:"localhost"===d[0].slice(0,u).toLowerCase()&&(n="localhost"),""===i&&"ns"in l&&(i=l.ns)}return{host:e,port:a,domain:n,subdomain:i,secure:o,scheme:s,pathString:r}},rt=/[\[\].#$\/\u0000-\u001F\u007F]/,ot=/[\[\].#$\u0000-\u001F\u007F]/,st=function(t){return"string"==typeof t&&0!==t.length&&!rt.test(t)},at=function(t){return"string"==typeof t&&0!==t.length&&!ot.test(t)},ut=function(t){return null===t||"string"==typeof t||"number"==typeof t&&!F(t)||t&&"object"==typeof t&&g.contains(t,".sv")},ct=function(t,e,n,i,r){r&&void 0===n||ht(g.errorPrefix(t,e,r),n,i)},ht=function(t,e,n){var i=n instanceof J?new Z(n,t):n;if(void 0===e)throw new Error(t+"contains undefined "+i.toErrorString());if("function"==typeof e)throw new Error(t+"contains a function "+i.toErrorString()+" with contents = "+e.toString());if(F(e))throw new Error(t+"contains "+e.toString()+" "+i.toErrorString());if("string"==typeof e&&e.length>10485760/3&&g.stringLength(e)>10485760)throw new Error(t+"contains a string greater than 10485760 utf8 bytes "+i.toErrorString()+" ('"+e.substring(0,50)+"...')");if(e&&"object"==typeof e){var r=!1,o=!1;if(g.forEach(e,function(e,n){if(".value"===e)r=!0;else if(".priority"!==e&&".sv"!==e&&(o=!0,!st(e)))throw new Error(t+" contains an invalid key ("+e+") "+i.toErrorString()+'.  Keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]"');i.push(e),ht(t,n,i),i.pop()}),r&&o)throw new Error(t+' contains ".value" child '+i.toErrorString()+" in addition to actual children.")}},lt=function(t,e,n,i,r){if(!r||void 0!==n){var o=g.errorPrefix(t,e,r);if(!n||"object"!=typeof n||Array.isArray(n))throw new Error(o+" must be an object containing the children to replace.");var s=[];g.forEach(n,function(t,e){var n=new J(t);if(ht(o,e,i.child(n)),".priority"===n.getBack()&&!ut(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,i;for(n=0;n<e.length;n++)for(var r=(i=e[n]).slice(),o=0;o<r.length;o++)if(".priority"===r[o]&&o===r.length-1);else if(!st(r[o]))throw new Error(t+"contains an invalid key ("+r[o]+") in path "+i.toString()+'. Keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]"');e.sort(J.comparePaths);var s=null;for(n=0;n<e.length;n++){if(i=e[n],null!==s&&s.contains(i))throw new Error(t+"contains a path "+s.toString()+" that is ancestor of another path "+i.toString());s=i}}(o,s)}},dt=function(t,e,n,i){if(!i||void 0!==n){if(F(n))throw new Error(g.errorPrefix(t,e,i)+"is "+n.toString()+", but must be a valid Firebase priority (a string, finite number, server value, or null).");if(!ut(n))throw new Error(g.errorPrefix(t,e,i)+"must be a valid Firebase priority (a string, finite number, server value, or null).")}},ft=function(t,e,n,i){if(!i||void 0!==n)switch(n){case"value":case"child_added":case"child_removed":case"child_changed":case"child_moved":break;default:throw new Error(g.errorPrefix(t,e,i)+'must be a valid event type = "value", "child_added", "child_removed", "child_changed", or "child_moved".')}},pt=function(t,e,n,i){if(!(i&&void 0===n||st(n)))throw new Error(g.errorPrefix(t,e,i)+'was an invalid key = "'+n+'".  Firebase keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]").')},vt=function(t,e,n,i){if(!(i&&void 0===n||at(n)))throw new Error(g.errorPrefix(t,e,i)+'was an invalid path = "'+n+'". Paths must be non-empty strings and can\'t contain ".", "#", "$", "[", or "]"')},gt=function(t,e){if(".info"===e.getFront())throw new Error(t+" failed = Can't modify data under /.info/")},yt=function(t,e,n){var i=n.path.toString();if("string"!=typeof n.repoInfo.host||0===n.repoInfo.host.length||!st(n.repoInfo.namespace)&&"localhost"!==n.repoInfo.host.split(":")[0]||0!==i.length&&!function(t){return t&&(t=t.replace(/^\/*\.info(\/|$)/,"/")),at(t)}(i))throw new Error(g.errorPrefix(t,e,!1)+'must be a valid firebase URL and the path can\'t contain ".", "#", "$", "[", or "]".')},mt=function(){function t(t,e){this.repo_=t,this.path_=e}return t.prototype.cancel=function(t){g.validateArgCount("OnDisconnect.cancel",0,1,arguments.length),g.validateCallback("OnDisconnect.cancel",1,t,!0);var e=new g.Deferred;return this.repo_.onDisconnectCancel(this.path_,e.wrapCallback(t)),e.promise},t.prototype.remove=function(t){g.validateArgCount("OnDisconnect.remove",0,1,arguments.length),gt("OnDisconnect.remove",this.path_),g.validateCallback("OnDisconnect.remove",1,t,!0);var e=new g.Deferred;return this.repo_.onDisconnectSet(this.path_,null,e.wrapCallback(t)),e.promise},t.prototype.set=function(t,e){g.validateArgCount("OnDisconnect.set",1,2,arguments.length),gt("OnDisconnect.set",this.path_),ct("OnDisconnect.set",1,t,this.path_,!1),g.validateCallback("OnDisconnect.set",2,e,!0);var n=new g.Deferred;return this.repo_.onDisconnectSet(this.path_,t,n.wrapCallback(e)),n.promise},t.prototype.setWithPriority=function(t,e,n){g.validateArgCount("OnDisconnect.setWithPriority",2,3,arguments.length),gt("OnDisconnect.setWithPriority",this.path_),ct("OnDisconnect.setWithPriority",1,t,this.path_,!1),dt("OnDisconnect.setWithPriority",2,e,!1),g.validateCallback("OnDisconnect.setWithPriority",3,n,!0);var i=new g.Deferred;return this.repo_.onDisconnectSetWithPriority(this.path_,t,e,i.wrapCallback(n)),i.promise},t.prototype.update=function(t,e){if(g.validateArgCount("OnDisconnect.update",1,2,arguments.length),gt("OnDisconnect.update",this.path_),Array.isArray(t)){for(var n={},i=0;i<t.length;++i)n[""+i]=t[i];t=n,L("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.")}lt("OnDisconnect.update",1,t,this.path_,!1),g.validateCallback("OnDisconnect.update",2,e,!0);var r=new g.Deferred;return this.repo_.onDisconnectUpdate(this.path_,t,r.wrapCallback(e)),r.promise},t}(),_t=function(){function t(t,e){this.committed=t,this.snapshot=e}return t.prototype.toJSON=function(){return g.validateArgCount("TransactionResult.toJSON",0,1,arguments.length),{committed:this.committed,snapshot:this.snapshot.toJSON()}},t}(),bt=(s="-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz",a=0,u=[],function(t){var e,n=t===a;a=t;var i=new Array(8);for(e=7;e>=0;e--)i[e]=s.charAt(t%64),t=Math.floor(t/64);g.assert(0===t,"Cannot push at time == 0");var r=i.join("");if(n){for(e=11;e>=0&&63===u[e];e--)u[e]=0;u[e]++}else for(e=0;e<12;e++)u[e]=Math.floor(64*Math.random());for(e=0;e<12;e++)r+=s.charAt(u[e]);return g.assert(20===r.length,"nextPushId: Length should be 20."),r}),wt=function(){function t(t,e){this.name=t,this.node=e}return t.Wrap=function(e,n){return new t(e,n)},t}(),Ct=function(){function t(){}return t.prototype.getCompare=function(){return this.compare.bind(this)},t.prototype.indexedValueChanged=function(t,e){var n=new wt(U,t),i=new wt(U,e);return 0!==this.compare(n,i)},t.prototype.minPost=function(){return wt.MIN},t}(),Tt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return m.__extends(e,t),Object.defineProperty(e,"__EMPTY_NODE",{get:function(){return c},set:function(t){c=t},enumerable:!0,configurable:!0}),e.prototype.compare=function(t,e){return W(t.name,e.name)},e.prototype.isDefinedOn=function(t){throw g.assertionError("KeyIndex.isDefinedOn not expected to be called.")},e.prototype.indexedValueChanged=function(t,e){return!1},e.prototype.minPost=function(){return wt.MIN},e.prototype.maxPost=function(){return new wt(j,c)},e.prototype.makePost=function(t,e){return g.assert("string"==typeof t,"KeyIndex indexValue must always be a string."),new wt(t,c)},e.prototype.toString=function(){return".key"},e}(Ct),Et=new Tt,St=function(t){return"number"==typeof t?"number:"+z(t):"string:"+t},It=function(t){if(t.isLeafNode()){var e=t.val();g.assert("string"==typeof e||"number"==typeof e||"object"==typeof e&&g.contains(e,".sv"),"Priority must be a string or number.")}else g.assert(t===h||t.isEmpty(),"priority of unexpected type.");g.assert(t===h||t.getPriority().isEmpty(),"Priority nodes can't have a priority of their own.")},kt=function(){function t(e,n){void 0===n&&(n=t.__childrenNodeConstructor.EMPTY_NODE),this.value_=e,this.priorityNode_=n,this.lazyHash_=null,g.assert(void 0!==this.value_&&null!==this.value_,"LeafNode shouldn't be created with null/undefined value."),It(this.priorityNode_)}return Object.defineProperty(t,"__childrenNodeConstructor",{get:function(){return l},set:function(t){l=t},enumerable:!0,configurable:!0}),t.prototype.isLeafNode=function(){return!0},t.prototype.getPriority=function(){return this.priorityNode_},t.prototype.updatePriority=function(e){return new t(this.value_,e)},t.prototype.getImmediateChild=function(e){return".priority"===e?this.priorityNode_:t.__childrenNodeConstructor.EMPTY_NODE},t.prototype.getChild=function(e){return e.isEmpty()?this:".priority"===e.getFront()?this.priorityNode_:t.__childrenNodeConstructor.EMPTY_NODE},t.prototype.hasChild=function(){return!1},t.prototype.getPredecessorChildName=function(t,e){return null},t.prototype.updateImmediateChild=function(e,n){return".priority"===e?this.updatePriority(n):n.isEmpty()&&".priority"!==e?this:t.__childrenNodeConstructor.EMPTY_NODE.updateImmediateChild(e,n).updatePriority(this.priorityNode_)},t.prototype.updateChild=function(e,n){var i=e.getFront();return null===i?n:n.isEmpty()&&".priority"!==i?this:(g.assert(".priority"!==i||1===e.getLength(),".priority must be the last token in a path"),this.updateImmediateChild(i,t.__childrenNodeConstructor.EMPTY_NODE.updateChild(e.popFront(),n)))},t.prototype.isEmpty=function(){return!1},t.prototype.numChildren=function(){return 0},t.prototype.forEachChild=function(t,e){return!1},t.prototype.val=function(t){return t&&!this.getPriority().isEmpty()?{".value":this.getValue(),".priority":this.getPriority().val()}:this.getValue()},t.prototype.hash=function(){if(null===this.lazyHash_){var t="";this.priorityNode_.isEmpty()||(t+="priority:"+St(this.priorityNode_.val())+":");var e=typeof this.value_;t+=e+":",t+="number"===e?z(this.value_):this.value_,this.lazyHash_=k(t)}return this.lazyHash_},t.prototype.getValue=function(){return this.value_},t.prototype.compareTo=function(e){return e===t.__childrenNodeConstructor.EMPTY_NODE?1:e instanceof t.__childrenNodeConstructor?-1:(g.assert(e.isLeafNode(),"Unknown node type"),this.compareToLeafNode_(e))},t.prototype.compareToLeafNode_=function(e){var n=typeof e.value_,i=typeof this.value_,r=t.VALUE_TYPE_ORDER.indexOf(n),o=t.VALUE_TYPE_ORDER.indexOf(i);return g.assert(r>=0,"Unknown leaf type: "+n),g.assert(o>=0,"Unknown leaf type: "+i),r===o?"object"===i?0:this.value_<e.value_?-1:this.value_===e.value_?0:1:o-r},t.prototype.withIndex=function(){return this},t.prototype.isIndexed=function(){return!0},t.prototype.equals=function(t){if(t===this)return!0;if(t.isLeafNode()){var e=t;return this.value_===e.value_&&this.priorityNode_.equals(e.priorityNode_)}return!1},t.VALUE_TYPE_ORDER=["object","boolean","number","string"],t}(),At=new(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return m.__extends(e,t),e.prototype.compare=function(t,e){var n=t.node.getPriority(),i=e.node.getPriority(),r=n.compareTo(i);return 0===r?W(t.name,e.name):r},e.prototype.isDefinedOn=function(t){return!t.getPriority().isEmpty()},e.prototype.indexedValueChanged=function(t,e){return!t.getPriority().equals(e.getPriority())},e.prototype.minPost=function(){return wt.MIN},e.prototype.maxPost=function(){return new wt(j,new kt("[PRIORITY-POST]",f))},e.prototype.makePost=function(t,e){var n=d(t);return new wt(e,new kt("[PRIORITY-POST]",n))},e.prototype.toString=function(){return".priority"},e}(Ct)),Pt=function(){function t(t,e,n,i,r){void 0===r&&(r=null),this.isReverse_=i,this.resultGenerator_=r,this.nodeStack_=[];for(var o=1;!t.isEmpty();)if(t=t,o=e?n(t.key,e):1,i&&(o*=-1),o<0)t=this.isReverse_?t.left:t.right;else{if(0===o){this.nodeStack_.push(t);break}this.nodeStack_.push(t),t=this.isReverse_?t.right:t.left}}return t.prototype.getNext=function(){if(0===this.nodeStack_.length)return null;var t,e=this.nodeStack_.pop();if(t=this.resultGenerator_?this.resultGenerator_(e.key,e.value):{key:e.key,value:e.value},this.isReverse_)for(e=e.left;!e.isEmpty();)this.nodeStack_.push(e),e=e.right;else for(e=e.right;!e.isEmpty();)this.nodeStack_.push(e),e=e.left;return t},t.prototype.hasNext=function(){return this.nodeStack_.length>0},t.prototype.peek=function(){if(0===this.nodeStack_.length)return null;var t=this.nodeStack_[this.nodeStack_.length-1];return this.resultGenerator_?this.resultGenerator_(t.key,t.value):{key:t.key,value:t.value}},t}(),Nt=function(){function t(e,n,i,r,o){this.key=e,this.value=n,this.color=null!=i?i:t.RED,this.left=null!=r?r:Rt.EMPTY_NODE,this.right=null!=o?o:Rt.EMPTY_NODE}return t.prototype.copy=function(e,n,i,r,o){return new t(null!=e?e:this.key,null!=n?n:this.value,null!=i?i:this.color,null!=r?r:this.left,null!=o?o:this.right)},t.prototype.count=function(){return this.left.count()+1+this.right.count()},t.prototype.isEmpty=function(){return!1},t.prototype.inorderTraversal=function(t){return this.left.inorderTraversal(t)||t(this.key,this.value)||this.right.inorderTraversal(t)},t.prototype.reverseTraversal=function(t){return this.right.reverseTraversal(t)||t(this.key,this.value)||this.left.reverseTraversal(t)},t.prototype.min_=function(){return this.left.isEmpty()?this:this.left.min_()},t.prototype.minKey=function(){return this.min_().key},t.prototype.maxKey=function(){return this.right.isEmpty()?this.key:this.right.maxKey()},t.prototype.insert=function(t,e,n){var i,r;return(r=(i=n(t,(r=this).key))<0?r.copy(null,null,null,r.left.insert(t,e,n),null):0===i?r.copy(null,e,null,null,null):r.copy(null,null,null,null,r.right.insert(t,e,n))).fixUp_()},t.prototype.removeMin_=function(){if(this.left.isEmpty())return Rt.EMPTY_NODE;var t=this;return t.left.isRed_()||t.left.left.isRed_()||(t=t.moveRedLeft_()),(t=t.copy(null,null,null,t.left.removeMin_(),null)).fixUp_()},t.prototype.remove=function(t,e){var n,i;if(e(t,(n=this).key)<0)n.left.isEmpty()||n.left.isRed_()||n.left.left.isRed_()||(n=n.moveRedLeft_()),n=n.copy(null,null,null,n.left.remove(t,e),null);else{if(n.left.isRed_()&&(n=n.rotateRight_()),n.right.isEmpty()||n.right.isRed_()||n.right.left.isRed_()||(n=n.moveRedRight_()),0===e(t,n.key)){if(n.right.isEmpty())return Rt.EMPTY_NODE;i=n.right.min_(),n=n.copy(i.key,i.value,null,null,n.right.removeMin_())}n=n.copy(null,null,null,null,n.right.remove(t,e))}return n.fixUp_()},t.prototype.isRed_=function(){return this.color},t.prototype.fixUp_=function(){var t=this;return t.right.isRed_()&&!t.left.isRed_()&&(t=t.rotateLeft_()),t.left.isRed_()&&t.left.left.isRed_()&&(t=t.rotateRight_()),t.left.isRed_()&&t.right.isRed_()&&(t=t.colorFlip_()),t},t.prototype.moveRedLeft_=function(){var t=this.colorFlip_();return t.right.left.isRed_()&&(t=(t=(t=t.copy(null,null,null,null,t.right.rotateRight_())).rotateLeft_()).colorFlip_()),t},t.prototype.moveRedRight_=function(){var t=this.colorFlip_();return t.left.left.isRed_()&&(t=(t=t.rotateRight_()).colorFlip_()),t},t.prototype.rotateLeft_=function(){var e=this.copy(null,null,t.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)},t.prototype.rotateRight_=function(){var e=this.copy(null,null,t.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)},t.prototype.colorFlip_=function(){var t=this.left.copy(null,null,!this.left.color,null,null),e=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,t,e)},t.prototype.checkMaxDepth_=function(){var t=this.check_();return Math.pow(2,t)<=this.count()+1},t.prototype.check_=function(){var t;if(this.isRed_()&&this.left.isRed_())throw new Error("Red node has red child("+this.key+","+this.value+")");if(this.right.isRed_())throw new Error("Right child of ("+this.key+","+this.value+") is red");if((t=this.left.check_())!==this.right.check_())throw new Error("Black depths differ");return t+(this.isRed_()?0:1)},t.RED=!0,t.BLACK=!1,t}(),Dt=function(){function t(){}return t.prototype.copy=function(t,e,n,i,r){return this},t.prototype.insert=function(t,e,n){return new Nt(t,e,null)},t.prototype.remove=function(t,e){return this},t.prototype.count=function(){return 0},t.prototype.isEmpty=function(){return!0},t.prototype.inorderTraversal=function(t){return!1},t.prototype.reverseTraversal=function(t){return!1},t.prototype.minKey=function(){return null},t.prototype.maxKey=function(){return null},t.prototype.check_=function(){return 0},t.prototype.isRed_=function(){return!1},t}(),Rt=function(){function t(e,n){void 0===n&&(n=t.EMPTY_NODE),this.comparator_=e,this.root_=n}return t.prototype.insert=function(e,n){return new t(this.comparator_,this.root_.insert(e,n,this.comparator_).copy(null,null,Nt.BLACK,null,null))},t.prototype.remove=function(e){return new t(this.comparator_,this.root_.remove(e,this.comparator_).copy(null,null,Nt.BLACK,null,null))},t.prototype.get=function(t){for(var e,n=this.root_;!n.isEmpty();){if(0===(e=this.comparator_(t,n.key)))return n.value;e<0?n=n.left:e>0&&(n=n.right)}return null},t.prototype.getPredecessorKey=function(t){for(var e,n=this.root_,i=null;!n.isEmpty();){if(0===(e=this.comparator_(t,n.key))){if(n.left.isEmpty())return i?i.key:null;for(n=n.left;!n.right.isEmpty();)n=n.right;return n.key}e<0?n=n.left:e>0&&(i=n,n=n.right)}throw new Error("Attempted to find predecessor key for a nonexistent key.  What gives?")},t.prototype.isEmpty=function(){return this.root_.isEmpty()},t.prototype.count=function(){return this.root_.count()},t.prototype.minKey=function(){return this.root_.minKey()},t.prototype.maxKey=function(){return this.root_.maxKey()},t.prototype.inorderTraversal=function(t){return this.root_.inorderTraversal(t)},t.prototype.reverseTraversal=function(t){return this.root_.reverseTraversal(t)},t.prototype.getIterator=function(t){return new Pt(this.root_,null,this.comparator_,!1,t)},t.prototype.getIteratorFrom=function(t,e){return new Pt(this.root_,t,this.comparator_,!1,e)},t.prototype.getReverseIteratorFrom=function(t,e){return new Pt(this.root_,t,this.comparator_,!0,e)},t.prototype.getReverseIterator=function(t){return new Pt(this.root_,null,this.comparator_,!0,t)},t.EMPTY_NODE=new Dt,t}(),Ot=Math.log(2),xt=function(){function t(t){var e;this.count=(e=t+1,parseInt(Math.log(e)/Ot,10)),this.current_=this.count-1;var n,i=(n=this.count,parseInt(Array(n+1).join("1"),2));this.bits_=t+1&i}return t.prototype.nextBitIsOne=function(){var t=!(this.bits_&1<<this.current_);return this.current_--,t},t}(),Mt=function(t,e,n,i){t.sort(e);var r=function(e,i){var o,s,a=i-e;if(0==a)return null;if(1==a)return o=t[e],s=n?n(o):o,new Nt(s,o.node,Nt.BLACK,null,null);var u=parseInt(a/2,10)+e,c=r(e,u),h=r(u+1,i);return o=t[u],s=n?n(o):o,new Nt(s,o.node,Nt.BLACK,c,h)},o=function(e){for(var i=null,o=null,s=t.length,a=function(e,i){var o=s-e,a=s;s-=e;var c=r(o+1,a),h=t[o],l=n?n(h):h;u(new Nt(l,h.node,i,null,c))},u=function(t){i?(i.left=t,i=t):(o=t,i=t)},c=0;c<e.count;++c){var h=e.nextBitIsOne(),l=Math.pow(2,e.count-(c+1));h?a(l,Nt.BLACK):(a(l,Nt.BLACK),a(l,Nt.RED))}return o}(new xt(t.length));return new Rt(i||e,o)},Lt={},Ft=function(){function t(t,e){this.indexes_=t,this.indexSet_=e}return Object.defineProperty(t,"Default",{get:function(){return g.assert(Lt&&At,"ChildrenNode.ts has not been loaded"),p=p||new t({".priority":Lt},{".priority":At})},enumerable:!0,configurable:!0}),t.prototype.get=function(t){var e=g.safeGet(this.indexes_,t);if(!e)throw new Error("No index defined for "+t);return e===Lt?null:e},t.prototype.hasIndex=function(t){return g.contains(this.indexSet_,t.toString())},t.prototype.addIndex=function(e,n){g.assert(e!==Et,"KeyIndex always exists and isn't meant to be added to the IndexMap.");for(var i,r=[],o=!1,s=n.getIterator(wt.Wrap),a=s.getNext();a;)o=o||e.isDefinedOn(a.node),r.push(a),a=s.getNext();i=o?Mt(r,e.getCompare()):Lt;var u=e.toString(),c=g.clone(this.indexSet_);c[u]=e;var h=g.clone(this.indexes_);return h[u]=i,new t(h,c)},t.prototype.addToIndexes=function(e,n){var i=this;return new t(g.map(this.indexes_,function(t,r){var o=g.safeGet(i.indexSet_,r);if(g.assert(o,"Missing index implementation for "+r),t===Lt){if(o.isDefinedOn(e.node)){for(var s=[],a=n.getIterator(wt.Wrap),u=a.getNext();u;)u.name!=e.name&&s.push(u),u=a.getNext();return s.push(e),Mt(s,o.getCompare())}return Lt}var c=n.get(e.name),h=t;return c&&(h=h.remove(new wt(e.name,c))),h.insert(e,e.node)}),this.indexSet_)},t.prototype.removeFromIndexes=function(e,n){return new t(g.map(this.indexes_,function(t){if(t===Lt)return t;var i=n.get(e.name);return i?t.remove(new wt(e.name,i)):t}),this.indexSet_)},t}();function Ut(t,e){return W(t.name,e.name)}function jt(t,e){return W(t,e)}var Wt=function(){function t(t,e,n){this.children_=t,this.priorityNode_=e,this.indexMap_=n,this.lazyHash_=null,this.priorityNode_&&It(this.priorityNode_),this.children_.isEmpty()&&g.assert(!this.priorityNode_||this.priorityNode_.isEmpty(),"An empty node cannot have a priority")}return Object.defineProperty(t,"EMPTY_NODE",{get:function(){return v||(v=new t(new Rt(jt),null,Ft.Default))},enumerable:!0,configurable:!0}),t.prototype.isLeafNode=function(){return!1},t.prototype.getPriority=function(){return this.priorityNode_||v},t.prototype.updatePriority=function(e){return this.children_.isEmpty()?this:new t(this.children_,e,this.indexMap_)},t.prototype.getImmediateChild=function(t){if(".priority"===t)return this.getPriority();var e=this.children_.get(t);return null===e?v:e},t.prototype.getChild=function(t){var e=t.getFront();return null===e?this:this.getImmediateChild(e).getChild(t.popFront())},t.prototype.hasChild=function(t){return null!==this.children_.get(t)},t.prototype.updateImmediateChild=function(e,n){if(g.assert(n,"We should always be passing snapshot nodes"),".priority"===e)return this.updatePriority(n);var i=new wt(e,n),r=void 0,o=void 0;return n.isEmpty()?(r=this.children_.remove(e),o=this.indexMap_.removeFromIndexes(i,this.children_)):(r=this.children_.insert(e,n),o=this.indexMap_.addToIndexes(i,this.children_)),new t(r,r.isEmpty()?v:this.priorityNode_,o)},t.prototype.updateChild=function(t,e){var n=t.getFront();if(null===n)return e;g.assert(".priority"!==t.getFront()||1===t.getLength(),".priority must be the last token in a path");var i=this.getImmediateChild(n).updateChild(t.popFront(),e);return this.updateImmediateChild(n,i)},t.prototype.isEmpty=function(){return this.children_.isEmpty()},t.prototype.numChildren=function(){return this.children_.count()},t.prototype.val=function(e){if(this.isEmpty())return null;var n={},i=0,r=0,o=!0;if(this.forEachChild(At,function(s,a){n[s]=a.val(e),i++,o&&t.INTEGER_REGEXP_.test(s)?r=Math.max(r,Number(s)):o=!1}),!e&&o&&r<2*i){var s=[];for(var a in n)s[a]=n[a];return s}return e&&!this.getPriority().isEmpty()&&(n[".priority"]=this.getPriority().val()),n},t.prototype.hash=function(){if(null===this.lazyHash_){var t="";this.getPriority().isEmpty()||(t+="priority:"+St(this.getPriority().val())+":"),this.forEachChild(At,function(e,n){var i=n.hash();""!==i&&(t+=":"+e+":"+i)}),this.lazyHash_=""===t?"":k(t)}return this.lazyHash_},t.prototype.getPredecessorChildName=function(t,e,n){var i=this.resolveIndex_(n);if(i){var r=i.getPredecessorKey(new wt(t,e));return r?r.name:null}return this.children_.getPredecessorKey(t)},t.prototype.getFirstChildName=function(t){var e=this.resolveIndex_(t);if(e){var n=e.minKey();return n&&n.name}return this.children_.minKey()},t.prototype.getFirstChild=function(t){var e=this.getFirstChildName(t);return e?new wt(e,this.children_.get(e)):null},t.prototype.getLastChildName=function(t){var e=this.resolveIndex_(t);if(e){var n=e.maxKey();return n&&n.name}return this.children_.maxKey()},t.prototype.getLastChild=function(t){var e=this.getLastChildName(t);return e?new wt(e,this.children_.get(e)):null},t.prototype.forEachChild=function(t,e){var n=this.resolveIndex_(t);return n?n.inorderTraversal(function(t){return e(t.name,t.node)}):this.children_.inorderTraversal(e)},t.prototype.getIterator=function(t){return this.getIteratorFrom(t.minPost(),t)},t.prototype.getIteratorFrom=function(t,e){var n=this.resolveIndex_(e);if(n)return n.getIteratorFrom(t,function(t){return t});for(var i=this.children_.getIteratorFrom(t.name,wt.Wrap),r=i.peek();null!=r&&e.compare(r,t)<0;)i.getNext(),r=i.peek();return i},t.prototype.getReverseIterator=function(t){return this.getReverseIteratorFrom(t.maxPost(),t)},t.prototype.getReverseIteratorFrom=function(t,e){var n=this.resolveIndex_(e);if(n)return n.getReverseIteratorFrom(t,function(t){return t});for(var i=this.children_.getReverseIteratorFrom(t.name,wt.Wrap),r=i.peek();null!=r&&e.compare(r,t)>0;)i.getNext(),r=i.peek();return i},t.prototype.compareTo=function(t){return this.isEmpty()?t.isEmpty()?0:-1:t.isLeafNode()||t.isEmpty()?1:t===Bt?-1:0},t.prototype.withIndex=function(e){if(e===Et||this.indexMap_.hasIndex(e))return this;var n=this.indexMap_.addIndex(e,this.children_);return new t(this.children_,this.priorityNode_,n)},t.prototype.isIndexed=function(t){return t===Et||this.indexMap_.hasIndex(t)},t.prototype.equals=function(t){if(t===this)return!0;if(t.isLeafNode())return!1;var e=t;if(this.getPriority().equals(e.getPriority())){if(this.children_.count()===e.children_.count()){for(var n=this.getIterator(At),i=e.getIterator(At),r=n.getNext(),o=i.getNext();r&&o;){if(r.name!==o.name||!r.node.equals(o.node))return!1;r=n.getNext(),o=i.getNext()}return null===r&&null===o}return!1}return!1},t.prototype.resolveIndex_=function(t){return t===Et?null:this.indexMap_.get(t.toString())},t.INTEGER_REGEXP_=/^(0|[1-9]\d*)$/,t}(),Bt=new(function(t){function e(){return t.call(this,new Rt(jt),Wt.EMPTY_NODE,Ft.Default)||this}return m.__extends(e,t),e.prototype.compareTo=function(t){return t===this?0:1},e.prototype.equals=function(t){return t===this},e.prototype.getPriority=function(){return this},e.prototype.getImmediateChild=function(t){return Wt.EMPTY_NODE},e.prototype.isEmpty=function(){return!1},e}(Wt));Object.defineProperties(wt,{MIN:{value:new wt(U,Wt.EMPTY_NODE)},MAX:{value:new wt(j,Bt)}}),Tt.__EMPTY_NODE=Wt.EMPTY_NODE,kt.__childrenNodeConstructor=Wt,h=Bt,f=Bt;var $t=!0;function Vt(t,e){if(void 0===e&&(e=null),null===t)return Wt.EMPTY_NODE;if("object"==typeof t&&".priority"in t&&(e=t[".priority"]),g.assert(null===e||"string"==typeof e||"number"==typeof e||"object"==typeof e&&".sv"in e,"Invalid priority type found: "+typeof e),"object"==typeof t&&".value"in t&&null!==t[".value"]&&(t=t[".value"]),"object"!=typeof t||".sv"in t)return new kt(t,Vt(e));if(t instanceof Array||!$t){var n=Wt.EMPTY_NODE,i=t;return g.forEach(i,function(t,e){if(g.contains(i,t)&&"."!==t.substring(0,1)){var r=Vt(e);!r.isLeafNode()&&r.isEmpty()||(n=n.updateImmediateChild(t,r))}}),n.updatePriority(Vt(e))}var r=[],o=!1,s=t;if(g.forEach(s,function(t,e){if("string"!=typeof t||"."!==t.substring(0,1)){var n=Vt(s[t]);n.isEmpty()||(o=o||!n.getPriority().isEmpty(),r.push(new wt(t,n)))}}),0==r.length)return Wt.EMPTY_NODE;var a=Mt(r,Ut,function(t){return t.name},jt);if(o){var u=Mt(r,At.getCompare());return new Wt(a,Vt(e),new Ft({".priority":u},{".priority":At}))}return new Wt(a,Vt(e),Ft.Default)}d=Vt;var qt,Ht,zt=new(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return m.__extends(e,t),e.prototype.compare=function(t,e){var n=t.node.compareTo(e.node);return 0===n?W(t.name,e.name):n},e.prototype.isDefinedOn=function(t){return!0},e.prototype.indexedValueChanged=function(t,e){return!t.equals(e)},e.prototype.minPost=function(){return wt.MIN},e.prototype.maxPost=function(){return wt.MAX},e.prototype.makePost=function(t,e){var n=Vt(t);return new wt(e,n)},e.prototype.toString=function(){return".value"},e}(Ct)),Kt=function(t){function e(e){var n=t.call(this)||this;return n.indexPath_=e,g.assert(!e.isEmpty()&&".priority"!==e.getFront(),"Can't create PathIndex with empty path or .priority key"),n}return m.__extends(e,t),e.prototype.extractChild=function(t){return t.getChild(this.indexPath_)},e.prototype.isDefinedOn=function(t){return!t.getChild(this.indexPath_).isEmpty()},e.prototype.compare=function(t,e){var n=this.extractChild(t.node),i=this.extractChild(e.node),r=n.compareTo(i);return 0===r?W(t.name,e.name):r},e.prototype.makePost=function(t,e){var n=Vt(t),i=Wt.EMPTY_NODE.updateChild(this.indexPath_,n);return new wt(e,i)},e.prototype.maxPost=function(){var t=Wt.EMPTY_NODE.updateChild(this.indexPath_,Bt);return new wt(j,t)},e.prototype.toString=function(){return this.indexPath_.slice().join("/")},e}(Ct),Qt=function(){function t(t,e,n){this.node_=t,this.ref_=e,this.index_=n}return t.prototype.val=function(){return g.validateArgCount("DataSnapshot.val",0,0,arguments.length),this.node_.val()},t.prototype.exportVal=function(){return g.validateArgCount("DataSnapshot.exportVal",0,0,arguments.length),this.node_.val(!0)},t.prototype.toJSON=function(){return g.validateArgCount("DataSnapshot.toJSON",0,1,arguments.length),this.exportVal()},t.prototype.exists=function(){return g.validateArgCount("DataSnapshot.exists",0,0,arguments.length),!this.node_.isEmpty()},t.prototype.child=function(e){g.validateArgCount("DataSnapshot.child",0,1,arguments.length),e=String(e),vt("DataSnapshot.child",1,e,!1);var n=new J(e),i=this.ref_.child(n);return new t(this.node_.getChild(n),i,At)},t.prototype.hasChild=function(t){g.validateArgCount("DataSnapshot.hasChild",1,1,arguments.length),vt("DataSnapshot.hasChild",1,t,!1);var e=new J(t);return!this.node_.getChild(e).isEmpty()},t.prototype.getPriority=function(){return g.validateArgCount("DataSnapshot.getPriority",0,0,arguments.length),this.node_.getPriority().val()},t.prototype.forEach=function(e){var n=this;return g.validateArgCount("DataSnapshot.forEach",1,1,arguments.length),g.validateCallback("DataSnapshot.forEach",1,e,!1),!this.node_.isLeafNode()&&!!this.node_.forEachChild(this.index_,function(i,r){return e(new t(r,n.ref_.child(i),At))})},t.prototype.hasChildren=function(){return g.validateArgCount("DataSnapshot.hasChildren",0,0,arguments.length),!this.node_.isLeafNode()&&!this.node_.isEmpty()},Object.defineProperty(t.prototype,"key",{get:function(){return this.ref_.getKey()},enumerable:!0,configurable:!0}),t.prototype.numChildren=function(){return g.validateArgCount("DataSnapshot.numChildren",0,0,arguments.length),this.node_.numChildren()},t.prototype.getRef=function(){return g.validateArgCount("DataSnapshot.ref",0,0,arguments.length),this.ref_},Object.defineProperty(t.prototype,"ref",{get:function(){return this.getRef()},enumerable:!0,configurable:!0}),t}(),Yt=function(){function t(t,e,n,i){this.eventType=t,this.eventRegistration=e,this.snapshot=n,this.prevName=i}return t.prototype.getPath=function(){var t=this.snapshot.getRef();return"value"===this.eventType?t.path:t.getParent().path},t.prototype.getEventType=function(){return this.eventType},t.prototype.getEventRunner=function(){return this.eventRegistration.getEventRunner(this)},t.prototype.toString=function(){return this.getPath().toString()+":"+this.eventType+":"+g.stringify(this.snapshot.exportVal())},t}(),Gt=function(){function t(t,e,n){this.eventRegistration=t,this.error=e,this.path=n}return t.prototype.getPath=function(){return this.path},t.prototype.getEventType=function(){return"cancel"},t.prototype.getEventRunner=function(){return this.eventRegistration.getEventRunner(this)},t.prototype.toString=function(){return this.path.toString()+":cancel"},t}(),Xt=function(){function t(t,e,n){this.callback_=t,this.cancelCallback_=e,this.context_=n}return t.prototype.respondsTo=function(t){return"value"===t},t.prototype.createEvent=function(t,e){var n=e.getQueryParams().getIndex();return new Yt("value",this,new Qt(t.snapshotNode,e.getRef(),n))},t.prototype.getEventRunner=function(t){var e=this.context_;if("cancel"===t.getEventType()){g.assert(this.cancelCallback_,"Raising a cancel event on a listener with no cancel callback");var n=this.cancelCallback_;return function(){n.call(e,t.error)}}var i=this.callback_;return function(){i.call(e,t.snapshot)}},t.prototype.createCancelEvent=function(t,e){return this.cancelCallback_?new Gt(this,t,e):null},t.prototype.matches=function(e){return e instanceof t&&(!e.callback_||!this.callback_||e.callback_===this.callback_&&e.context_===this.context_)},t.prototype.hasAnyCallback=function(){return null!==this.callback_},t}(),Jt=function(){function t(t,e,n){this.callbacks_=t,this.cancelCallback_=e,this.context_=n}return t.prototype.respondsTo=function(t){var e="children_added"===t?"child_added":t;return e="children_removed"===e?"child_removed":e,g.contains(this.callbacks_,e)},t.prototype.createCancelEvent=function(t,e){return this.cancelCallback_?new Gt(this,t,e):null},t.prototype.createEvent=function(t,e){g.assert(null!=t.childName,"Child events should have a childName.");var n=e.getRef().child(t.childName),i=e.getQueryParams().getIndex();return new Yt(t.type,this,new Qt(t.snapshotNode,n,i),t.prevName)},t.prototype.getEventRunner=function(t){var e=this.context_;if("cancel"===t.getEventType()){g.assert(this.cancelCallback_,"Raising a cancel event on a listener with no cancel callback");var n=this.cancelCallback_;return function(){n.call(e,t.error)}}var i=this.callbacks_[t.eventType];return function(){i.call(e,t.snapshot,t.prevName)}},t.prototype.matches=function(e){if(e instanceof t){if(!this.callbacks_||!e.callbacks_)return!0;if(this.context_===e.context_){var n=g.getCount(e.callbacks_);if(n===g.getCount(this.callbacks_)){if(1===n){var i=g.getAnyKey(e.callbacks_),r=g.getAnyKey(this.callbacks_);return!(r!==i||e.callbacks_[i]&&this.callbacks_[r]&&e.callbacks_[i]!==this.callbacks_[r])}return g.every(this.callbacks_,function(t,n){return e.callbacks_[t]===n})}}}return!1},t.prototype.hasAnyCallback=function(){return null!==this.callbacks_},t}(),Zt=function(){function t(t,e,n,i){this.repo=t,this.path=e,this.queryParams_=n,this.orderByCalled_=i}return Object.defineProperty(t,"__referenceConstructor",{get:function(){return g.assert(qt,"Reference.ts has not been loaded"),qt},set:function(t){qt=t},enumerable:!0,configurable:!0}),t.validateQueryEndpoints_=function(t){var e=null,n=null;if(t.hasStart()&&(e=t.getIndexStartValue()),t.hasEnd()&&(n=t.getIndexEndValue()),t.getIndex()===Et){var i="Query: When ordering by key, you may only pass one argument to startAt(), endAt(), or equalTo().",r="Query: When ordering by key, the argument passed to startAt(), endAt(),or equalTo() must be a string.";if(t.hasStart()){if(t.getIndexStartName()!=U)throw new Error(i);if("string"!=typeof e)throw new Error(r)}if(t.hasEnd()){if(t.getIndexEndName()!=j)throw new Error(i);if("string"!=typeof n)throw new Error(r)}}else if(t.getIndex()===At){if(null!=e&&!ut(e)||null!=n&&!ut(n))throw new Error("Query: When ordering by priority, the first argument passed to startAt(), endAt(), or equalTo() must be a valid priority value (null, a number, or a string).")}else if(g.assert(t.getIndex()instanceof Kt||t.getIndex()===zt,"unknown index type."),null!=e&&"object"==typeof e||null!=n&&"object"==typeof n)throw new Error("Query: First argument passed to startAt(), endAt(), or equalTo() cannot be an object.")},t.validateLimit_=function(t){if(t.hasStart()&&t.hasEnd()&&t.hasLimit()&&!t.hasAnchoredLimit())throw new Error("Query: Can't combine startAt(), endAt(), and limit(). Use limitToFirst() or limitToLast() instead.")},t.prototype.validateNoPreviousOrderByCall_=function(t){if(!0===this.orderByCalled_)throw new Error(t+": You can't combine multiple orderBy calls.")},t.prototype.getQueryParams=function(){return this.queryParams_},t.prototype.getRef=function(){return g.validateArgCount("Query.ref",0,0,arguments.length),new t.__referenceConstructor(this.repo,this.path)},t.prototype.on=function(e,n,i,r){g.validateArgCount("Query.on",2,4,arguments.length),ft("Query.on",1,e,!1),g.validateCallback("Query.on",2,n,!1);var o=t.getCancelAndContextArgs_("Query.on",i,r);if("value"===e)this.onValueEvent(n,o.cancel,o.context);else{var s={};s[e]=n,this.onChildEvent(s,o.cancel,o.context)}return n},t.prototype.onValueEvent=function(t,e,n){var i=new Xt(t,e||null,n||null);this.repo.addEventCallbackForQuery(this,i)},t.prototype.onChildEvent=function(t,e,n){var i=new Jt(t,e,n);this.repo.addEventCallbackForQuery(this,i)},t.prototype.off=function(t,e,n){g.validateArgCount("Query.off",0,3,arguments.length),ft("Query.off",1,t,!0),g.validateCallback("Query.off",2,e,!0),g.validateContextObject("Query.off",3,n,!0);var i=null,r=null;"value"===t?i=new Xt(e||null,null,n||null):t&&(e&&((r={})[t]=e),i=new Jt(r,null,n||null)),this.repo.removeEventCallbackForQuery(this,i)},t.prototype.once=function(e,n,i,r){var o=this;g.validateArgCount("Query.once",1,4,arguments.length),ft("Query.once",1,e,!1),g.validateCallback("Query.once",2,n,!0);var s=t.getCancelAndContextArgs_("Query.once",i,r),a=!0,u=new g.Deferred;u.promise.catch(function(){});var c=function(t){a&&(a=!1,o.off(e,c),n&&n.bind(s.context)(t),u.resolve(t))};return this.on(e,c,function(t){o.off(e,c),s.cancel&&s.cancel.bind(s.context)(t),u.reject(t)}),u.promise},t.prototype.limitToFirst=function(e){if(g.validateArgCount("Query.limitToFirst",1,1,arguments.length),"number"!=typeof e||Math.floor(e)!==e||e<=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 t(this.repo,this.path,this.queryParams_.limitToFirst(e),this.orderByCalled_)},t.prototype.limitToLast=function(e){if(g.validateArgCount("Query.limitToLast",1,1,arguments.length),"number"!=typeof e||Math.floor(e)!==e||e<=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 t(this.repo,this.path,this.queryParams_.limitToLast(e),this.orderByCalled_)},t.prototype.orderByChild=function(e){if(g.validateArgCount("Query.orderByChild",1,1,arguments.length),"$key"===e)throw new Error('Query.orderByChild: "$key" is invalid.  Use Query.orderByKey() instead.');if("$priority"===e)throw new Error('Query.orderByChild: "$priority" is invalid.  Use Query.orderByPriority() instead.');if("$value"===e)throw new Error('Query.orderByChild: "$value" is invalid.  Use Query.orderByValue() instead.');vt("Query.orderByChild",1,e,!1),this.validateNoPreviousOrderByCall_("Query.orderByChild");var n=new J(e);if(n.isEmpty())throw new Error("Query.orderByChild: cannot pass in empty path.  Use Query.orderByValue() instead.");var i=new Kt(n),r=this.queryParams_.orderBy(i);return t.validateQueryEndpoints_(r),new t(this.repo,this.path,r,!0)},t.prototype.orderByKey=function(){g.validateArgCount("Query.orderByKey",0,0,arguments.length),this.validateNoPreviousOrderByCall_("Query.orderByKey");var e=this.queryParams_.orderBy(Et);return t.validateQueryEndpoints_(e),new t(this.repo,this.path,e,!0)},t.prototype.orderByPriority=function(){g.validateArgCount("Query.orderByPriority",0,0,arguments.length),this.validateNoPreviousOrderByCall_("Query.orderByPriority");var e=this.queryParams_.orderBy(At);return t.validateQueryEndpoints_(e),new t(this.repo,this.path,e,!0)},t.prototype.orderByValue=function(){g.validateArgCount("Query.orderByValue",0,0,arguments.length),this.validateNoPreviousOrderByCall_("Query.orderByValue");var e=this.queryParams_.orderBy(zt);return t.validateQueryEndpoints_(e),new t(this.repo,this.path,e,!0)},t.prototype.startAt=function(e,n){void 0===e&&(e=null),g.validateArgCount("Query.startAt",0,2,arguments.length),ct("Query.startAt",1,e,this.path,!0),pt("Query.startAt",2,n,!0);var i=this.queryParams_.startAt(e,n);if(t.validateLimit_(i),t.validateQueryEndpoints_(i),this.queryParams_.hasStart())throw new Error("Query.startAt: Starting point was already set (by another call to startAt or equalTo).");return void 0===e&&(e=null,n=null),new t(this.repo,this.path,i,this.orderByCalled_)},t.prototype.endAt=function(e,n){void 0===e&&(e=null),g.validateArgCount("Query.endAt",0,2,arguments.length),ct("Query.endAt",1,e,this.path,!0),pt("Query.endAt",2,n,!0);var i=this.queryParams_.endAt(e,n);if(t.validateLimit_(i),t.validateQueryEndpoints_(i),this.queryParams_.hasEnd())throw new Error("Query.endAt: Ending point was already set (by another call to endAt or equalTo).");return new t(this.repo,this.path,i,this.orderByCalled_)},t.prototype.equalTo=function(t,e){if(g.validateArgCount("Query.equalTo",1,2,arguments.length),ct("Query.equalTo",1,t,this.path,!1),pt("Query.equalTo",2,e,!0),this.queryParams_.hasStart())throw new Error("Query.equalTo: Starting point was already set (by another call to startAt or equalTo).");if(this.queryParams_.hasEnd())throw new Error("Query.equalTo: Ending point was already set (by another call to endAt or equalTo).");return this.startAt(t,e).endAt(t,e)},t.prototype.toString=function(){return g.validateArgCount("Query.toString",0,0,arguments.length),this.repo.toString()+this.path.toUrlEncodedString()},t.prototype.toJSON=function(){return g.validateArgCount("Query.toJSON",0,1,arguments.length),this.toString()},t.prototype.queryObject=function(){return this.queryParams_.getQueryObject()},t.prototype.queryIdentifier=function(){var t=this.queryObject(),e=V(t);return"{}"===e?"default":e},t.prototype.isEqual=function(e){if(g.validateArgCount("Query.isEqual",1,1,arguments.length),!(e instanceof t))throw new Error("Query.isEqual failed: First argument must be an instance of firebase.database.Query.");var n=this.repo===e.repo,i=this.path.equals(e.path),r=this.queryIdentifier()===e.queryIdentifier();return n&&i&&r},t.getCancelAndContextArgs_=function(t,e,n){var i={cancel:null,context:null};if(e&&n)i.cancel=e,g.validateCallback(t,3,i.cancel,!0),i.context=n,g.validateContextObject(t,4,i.context,!0);else if(e)if("object"==typeof e&&null!==e)i.context=e;else{if("function"!=typeof e)throw new Error(g.errorPrefix(t,3,!0)+" must either be a cancel callback or a context object.");i.cancel=e}return i},Object.defineProperty(t.prototype,"ref",{get:function(){return this.getRef()},enumerable:!0,configurable:!0}),t}(),te=function(){function t(){this.set={}}return t.prototype.add=function(t,e){this.set[t]=null===e||e},t.prototype.contains=function(t){return g.contains(this.set,t)},t.prototype.get=function(t){return this.contains(t)?this.set[t]:void 0},t.prototype.remove=function(t){delete this.set[t]},t.prototype.clear=function(){this.set={}},t.prototype.isEmpty=function(){return g.isEmpty(this.set)},t.prototype.count=function(){return g.getCount(this.set)},t.prototype.each=function(t){g.forEach(this.set,function(e,n){return t(e,n)})},t.prototype.keys=function(){var t=[];return g.forEach(this.set,function(e){t.push(e)}),t},t}(),ee=function(){function t(){this.value_=null,this.children_=null}return t.prototype.find=function(t){if(null!=this.value_)return this.value_.getChild(t);if(t.isEmpty()||null==this.children_)return null;var e=t.getFront();return t=t.popFront(),this.children_.contains(e)?this.children_.get(e).find(t):null},t.prototype.remember=function(e,n){if(e.isEmpty())this.value_=n,this.children_=null;else if(null!==this.value_)this.value_=this.value_.updateChild(e,n);else{null==this.children_&&(this.children_=new te);var i=e.getFront();this.children_.contains(i)||this.children_.add(i,new t);var r=this.children_.get(i);e=e.popFront(),r.remember(e,n)}},t.prototype.forget=function(t){if(t.isEmpty())return this.value_=null,this.children_=null,!0;if(null!==this.value_){if(this.value_.isLeafNode())return!1;var e=this.value_;this.value_=null;var n=this;return e.forEachChild(At,function(t,e){n.remember(new J(t),e)}),this.forget(t)}if(null!==this.children_){var i=t.getFront();return t=t.popFront(),this.children_.contains(i)&&this.children_.get(i).forget(t)&&this.children_.remove(i),!!this.children_.isEmpty()&&(this.children_=null,!0)}return!0},t.prototype.forEachTree=function(t,e){null!==this.value_?e(t,this.value_):this.forEachChild(function(n,i){var r=new J(t.toString()+"/"+n);i.forEachTree(r,e)})},t.prototype.forEachChild=function(t){null!==this.children_&&this.children_.each(function(e,n){t(e,n)})},t}(),ne=function(t,e){return t&&"object"==typeof t?(g.assert(".sv"in t,"Unexpected leaf node or priority contents"),e[t[".sv"]]):t},ie=function(t,e){var n,i=t.getPriority().val(),r=ne(i,e);if(t.isLeafNode()){var o=t,s=ne(o.getValue(),e);return s!==o.getValue()||r!==o.getPriority().val()?new kt(s,Vt(r)):t}var a=t;return n=a,r!==a.getPriority().val()&&(n=n.updatePriority(new kt(r))),a.forEachChild(At,function(t,i){var r=ie(i,e);r!==i&&(n=n.updateImmediateChild(t,r))}),n};!function(t){t[t.OVERWRITE=0]="OVERWRITE",t[t.MERGE=1]="MERGE",t[t.ACK_USER_WRITE=2]="ACK_USER_WRITE",t[t.LISTEN_COMPLETE=3]="LISTEN_COMPLETE"}(Ht||(Ht={}));var re,oe,se=function(){function t(t,e,n,i){this.fromUser=t,this.fromServer=e,this.queryId=n,this.tagged=i,g.assert(!i||e,"Tagged queries must be from server.")}return t.User=new t(!0,!1,null,!1),t.Server=new t(!1,!0,null,!1),t.forServerTaggedQuery=function(e){return new t(!1,!0,e,!0)},t}(),ae=function(){function t(t,e,n){this.path=t,this.affectedTree=e,this.revert=n,this.type=Ht.ACK_USER_WRITE,this.source=se.User}return t.prototype.operationForChild=function(e){if(this.path.isEmpty()){if(null!=this.affectedTree.value)return g.assert(this.affectedTree.children.isEmpty(),"affectedTree should not have overlapping affected paths."),this;var n=this.affectedTree.subtree(new J(e));return new t(J.Empty,n,this.revert)}return g.assert(this.path.getFront()===e,"operationForChild called for unrelated child."),new t(this.path.popFront(),this.affectedTree,this.revert)},t}(),ue=function(){return re||(re=new Rt(B)),re},ce=function(){function t(t,e){void 0===e&&(e=ue()),this.value=t,this.children=e}return t.fromObject=function(e){var n=t.Empty;return g.forEach(e,function(t,e){n=n.set(new J(t),e)}),n},t.prototype.isEmpty=function(){return null===this.value&&this.children.isEmpty()},t.prototype.findRootMostMatchingPathAndValue=function(t,e){if(null!=this.value&&e(this.value))return{path:J.Empty,value:this.value};if(t.isEmpty())return null;var n=t.getFront(),i=this.children.get(n);if(null!==i){var r=i.findRootMostMatchingPathAndValue(t.popFront(),e);return null!=r?{path:new J(n).child(r.path),value:r.value}:null}return null},t.prototype.findRootMostValueAndPath=function(t){return this.findRootMostMatchingPathAndValue(t,function(){return!0})},t.prototype.subtree=function(e){if(e.isEmpty())return this;var n=e.getFront(),i=this.children.get(n);return null!==i?i.subtree(e.popFront()):t.Empty},t.prototype.set=function(e,n){if(e.isEmpty())return new t(n,this.children);var i=e.getFront(),r=(this.children.get(i)||t.Empty).set(e.popFront(),n),o=this.children.insert(i,r);return new t(this.value,o)},t.prototype.remove=function(e){if(e.isEmpty())return this.children.isEmpty()?t.Empty:new t(null,this.children);var n=e.getFront(),i=this.children.get(n);if(i){var r=i.remove(e.popFront()),o=void 0;return o=r.isEmpty()?this.children.remove(n):this.children.insert(n,r),null===this.value&&o.isEmpty()?t.Empty:new t(this.value,o)}return this},t.prototype.get=function(t){if(t.isEmpty())return this.value;var e=t.getFront(),n=this.children.get(e);return n?n.get(t.popFront()):null},t.prototype.setTree=function(e,n){if(e.isEmpty())return n;var i,r=e.getFront(),o=(this.children.get(r)||t.Empty).setTree(e.popFront(),n);return i=o.isEmpty()?this.children.remove(r):this.children.insert(r,o),new t(this.value,i)},t.prototype.fold=function(t){return this.fold_(J.Empty,t)},t.prototype.fold_=function(t,e){var n={};return this.children.inorderTraversal(function(i,r){n[i]=r.fold_(t.child(i),e)}),e(t,this.value,n)},t.prototype.findOnPath=function(t,e){return this.findOnPath_(t,J.Empty,e)},t.prototype.findOnPath_=function(t,e,n){var i=!!this.value&&n(e,this.value);if(i)return i;if(t.isEmpty())return null;var r=t.getFront(),o=this.children.get(r);return o?o.findOnPath_(t.popFront(),e.child(r),n):null},t.prototype.foreachOnPath=function(t,e){return this.foreachOnPath_(t,J.Empty,e)},t.prototype.foreachOnPath_=function(e,n,i){if(e.isEmpty())return this;this.value&&i(n,this.value);var r=e.getFront(),o=this.children.get(r);return o?o.foreachOnPath_(e.popFront(),n.child(r),i):t.Empty},t.prototype.foreach=function(t){this.foreach_(J.Empty,t)},t.prototype.foreach_=function(t,e){this.children.inorderTraversal(function(n,i){i.foreach_(t.child(n),e)}),this.value&&e(t,this.value)},t.prototype.foreachChild=function(t){this.children.inorderTraversal(function(e,n){n.value&&t(e,n.value)})},t.Empty=new t(null),t}(),he=function(){function t(t,e){this.source=t,this.path=e,this.type=Ht.LISTEN_COMPLETE}return t.prototype.operationForChild=function(e){return this.path.isEmpty()?new t(this.source,J.Empty):new t(this.source,this.path.popFront())},t}(),le=function(){function t(t,e,n){this.source=t,this.path=e,this.snap=n,this.type=Ht.OVERWRITE}return t.prototype.operationForChild=function(e){return this.path.isEmpty()?new t(this.source,J.Empty,this.snap.getImmediateChild(e)):new t(this.source,this.path.popFront(),this.snap)},t}(),de=function(){function t(t,e,n){this.source=t,this.path=e,this.children=n,this.type=Ht.MERGE}return t.prototype.operationForChild=function(e){if(this.path.isEmpty()){var n=this.children.subtree(new J(e));return n.isEmpty()?null:n.value?new le(this.source,J.Empty,n.value):new t(this.source,J.Empty,n)}return g.assert(this.path.getFront()===e,"Can't get a merge for a child not on the path of the operation"),new t(this.source,this.path.popFront(),this.children)},t.prototype.toString=function(){return"Operation("+this.path+": "+this.source.toString()+" merge: "+this.children.toString()+")"},t}(),fe=function(){function t(t,e,n){this.node_=t,this.fullyInitialized_=e,this.filtered_=n}return t.prototype.isFullyInitialized=function(){return this.fullyInitialized_},t.prototype.isFiltered=function(){return this.filtered_},t.prototype.isCompleteForPath=function(t){if(t.isEmpty())return this.isFullyInitialized()&&!this.filtered_;var e=t.getFront();return this.isCompleteForChild(e)},t.prototype.isCompleteForChild=function(t){return this.isFullyInitialized()&&!this.filtered_||this.node_.hasChild(t)},t.prototype.getNode=function(){return this.node_},t}(),pe=function(){function t(t,e){this.eventCache_=t,this.serverCache_=e}return t.prototype.updateEventSnap=function(e,n,i){return new t(new fe(e,n,i),this.serverCache_)},t.prototype.updateServerSnap=function(e,n,i){return new t(this.eventCache_,new fe(e,n,i))},t.prototype.getEventCache=function(){return this.eventCache_},t.prototype.getCompleteEventSnap=function(){return this.eventCache_.isFullyInitialized()?this.eventCache_.getNode():null},t.prototype.getServerCache=function(){return this.serverCache_},t.prototype.getCompleteServerSnap=function(){return this.serverCache_.isFullyInitialized()?this.serverCache_.getNode():null},t.Empty=new t(new fe(Wt.EMPTY_NODE,!1,!1),new fe(Wt.EMPTY_NODE,!1,!1)),t}(),ve=function(){function t(t,e,n,i,r){this.type=t,this.snapshotNode=e,this.childName=n,this.oldSnap=i,this.prevName=r}return t.valueChange=function(e){return new t(t.VALUE,e)},t.childAddedChange=function(e,n){return new t(t.CHILD_ADDED,n,e)},t.childRemovedChange=function(e,n){return new t(t.CHILD_REMOVED,n,e)},t.childChangedChange=function(e,n,i){return new t(t.CHILD_CHANGED,n,e,i)},t.childMovedChange=function(e,n){return new t(t.CHILD_MOVED,n,e)},t.CHILD_ADDED="child_added",t.CHILD_REMOVED="child_removed",t.CHILD_CHANGED="child_changed",t.CHILD_MOVED="child_moved",t.VALUE="value",t}(),ge=function(){function t(t){this.index_=t}return t.prototype.updateChild=function(t,e,n,i,r,o){g.assert(t.isIndexed(this.index_),"A node must be indexed if only a child is updated");var s=t.getImmediateChild(e);return s.getChild(i).equals(n.getChild(i))&&s.isEmpty()==n.isEmpty()?t:(null!=o&&(n.isEmpty()?t.hasChild(e)?o.trackChildChange(ve.childRemovedChange(e,s)):g.assert(t.isLeafNode(),"A child remove without an old child only makes sense on a leaf node"):s.isEmpty()?o.trackChildChange(ve.childAddedChange(e,n)):o.trackChildChange(ve.childChangedChange(e,n,s))),t.isLeafNode()&&n.isEmpty()?t:t.updateImmediateChild(e,n).withIndex(this.index_))},t.prototype.updateFullNode=function(t,e,n){return null!=n&&(t.isLeafNode()||t.forEachChild(At,function(t,i){e.hasChild(t)||n.trackChildChange(ve.childRemovedChange(t,i))}),e.isLeafNode()||e.forEachChild(At,function(e,i){if(t.hasChild(e)){var r=t.getImmediateChild(e);r.equals(i)||n.trackChildChange(ve.childChangedChange(e,i,r))}else n.trackChildChange(ve.childAddedChange(e,i))})),e.withIndex(this.index_)},t.prototype.updatePriority=function(t,e){return t.isEmpty()?Wt.EMPTY_NODE:t.updatePriority(e)},t.prototype.filtersNodes=function(){return!1},t.prototype.getIndexedFilter=function(){return this},t.prototype.getIndex=function(){return this.index_},t}(),ye=function(){function t(){this.changeMap_={}}return t.prototype.trackChildChange=function(t){var e=t.type,n=t.childName;g.assert(e==ve.CHILD_ADDED||e==ve.CHILD_CHANGED||e==ve.CHILD_REMOVED,"Only child changes supported for tracking"),g.assert(".priority"!==n,"Only non-priority child changes can be tracked.");var i=g.safeGet(this.changeMap_,n);if(i){var r=i.type;if(e==ve.CHILD_ADDED&&r==ve.CHILD_REMOVED)this.changeMap_[n]=ve.childChangedChange(n,t.snapshotNode,i.snapshotNode);else if(e==ve.CHILD_REMOVED&&r==ve.CHILD_ADDED)delete this.changeMap_[n];else if(e==ve.CHILD_REMOVED&&r==ve.CHILD_CHANGED)this.changeMap_[n]=ve.childRemovedChange(n,i.oldSnap);else if(e==ve.CHILD_CHANGED&&r==ve.CHILD_ADDED)this.changeMap_[n]=ve.childAddedChange(n,t.snapshotNode);else{if(e!=ve.CHILD_CHANGED||r!=ve.CHILD_CHANGED)throw g.assertionError("Illegal combination of changes: "+t+" occurred after "+i);this.changeMap_[n]=ve.childChangedChange(n,t.snapshotNode,i.oldSnap)}}else this.changeMap_[n]=t},t.prototype.getChanges=function(){return g.getValues(this.changeMap_)},t}(),me=new(function(){function t(){}return t.prototype.getCompleteChild=function(t){return null},t.prototype.getChildAfterChild=function(t,e,n){return null},t}()),_e=function(){function t(t,e,n){void 0===n&&(n=null),this.writes_=t,this.viewCache_=e,this.optCompleteServerCache_=n}return t.prototype.getCompleteChild=function(t){var e=this.viewCache_.getEventCache();if(e.isCompleteForChild(t))return e.getNode().getImmediateChild(t);var n=null!=this.optCompleteServerCache_?new fe(this.optCompleteServerCache_,!0,!1):this.viewCache_.getServerCache();return this.writes_.calcCompleteChild(t,n)},t.prototype.getChildAfterChild=function(t,e,n){var i=null!=this.optCompleteServerCache_?this.optCompleteServerCache_:this.viewCache_.getCompleteServerSnap(),r=this.writes_.calcIndexedSlice(i,e,1,n,t);return 0===r.length?null:r[0]},t}(),be=function(t,e){this.viewCache=t,this.changes=e},we=function(){function t(t){this.filter_=t}return t.prototype.assertIndexed=function(t){g.assert(t.getEventCache().getNode().isIndexed(this.filter_.getIndex()),"Event snap not indexed"),g.assert(t.getServerCache().getNode().isIndexed(this.filter_.getIndex()),"Server snap not indexed")},t.prototype.applyOperation=function(e,n,i,r){var o,s,a=new ye;if(n.type===Ht.OVERWRITE){var u=n;u.source.fromUser?o=this.applyUserOverwrite_(e,u.path,u.snap,i,r,a):(g.assert(u.source.fromServer,"Unknown source."),s=u.source.tagged||e.getServerCache().isFiltered()&&!u.path.isEmpty(),o=this.applyServerOverwrite_(e,u.path,u.snap,i,r,s,a))}else if(n.type===Ht.MERGE){var c=n;c.source.fromUser?o=this.applyUserMerge_(e,c.path,c.children,i,r,a):(g.assert(c.source.fromServer,"Unknown source."),s=c.source.tagged||e.getServerCache().isFiltered(),o=this.applyServerMerge_(e,c.path,c.children,i,r,s,a))}else if(n.type===Ht.ACK_USER_WRITE){var h=n;o=h.revert?this.revertUserWrite_(e,h.path,i,r,a):this.ackUserWrite_(e,h.path,h.affectedTree,i,r,a)}else{if(n.type!==Ht.LISTEN_COMPLETE)throw g.assertionError("Unknown operation type: "+n.type);o=this.listenComplete_(e,n.path,i,a)}var l=a.getChanges();return t.maybeAddValueEvent_(e,o,l),new be(o,l)},t.maybeAddValueEvent_=function(t,e,n){var i=e.getEventCache();if(i.isFullyInitialized()){var r=i.getNode().isLeafNode()||i.getNode().isEmpty(),o=t.getCompleteEventSnap();(n.length>0||!t.getEventCache().isFullyInitialized()||r&&!i.getNode().equals(o)||!i.getNode().getPriority().equals(o.getPriority()))&&n.push(ve.valueChange(e.getCompleteEventSnap()))}},t.prototype.generateEventCacheAfterServerEvent_=function(t,e,n,i,r){var o=t.getEventCache();if(null!=n.shadowingWrite(e))return t;var s=void 0,a=void 0;if(e.isEmpty())if(g.assert(t.getServerCache().isFullyInitialized(),"If change path is empty, we must have complete server data"),t.getServerCache().isFiltered()){var u=t.getCompleteServerSnap(),c=u instanceof Wt?u:Wt.EMPTY_NODE,h=n.calcCompleteEventChildren(c);s=this.filter_.updateFullNode(t.getEventCache().getNode(),h,r)}else{var l=n.calcCompleteEventCache(t.getCompleteServerSnap());s=this.filter_.updateFullNode(t.getEventCache().getNode(),l,r)}else{var d=e.getFront();if(".priority"==d){g.assert(1==e.getLength(),"Can't have a priority with additional path components");var f=o.getNode();a=t.getServerCache().getNode();var p=n.calcEventCacheAfterServerOverwrite(e,f,a);s=null!=p?this.filter_.updatePriority(f,p):o.getNode()}else{var v=e.popFront(),y=void 0;if(o.isCompleteForChild(d)){a=t.getServerCache().getNode();var m=n.calcEventCacheAfterServerOverwrite(e,o.getNode(),a);y=null!=m?o.getNode().getImmediateChild(d).updateChild(v,m):o.getNode().getImmediateChild(d)}else y=n.calcCompleteChild(d,t.getServerCache());s=null!=y?this.filter_.updateChild(o.getNode(),d,y,v,i,r):o.getNode()}}return t.updateEventSnap(s,o.isFullyInitialized()||e.isEmpty(),this.filter_.filtersNodes())},t.prototype.applyServerOverwrite_=function(t,e,n,i,r,o,s){var a,u=t.getServerCache(),c=o?this.filter_:this.filter_.getIndexedFilter();if(e.isEmpty())a=c.updateFullNode(u.getNode(),n,null);else if(c.filtersNodes()&&!u.isFiltered()){var h=u.getNode().updateChild(e,n);a=c.updateFullNode(u.getNode(),h,null)}else{var l=e.getFront();if(!u.isCompleteForPath(e)&&e.getLength()>1)return t;var d=e.popFront(),f=u.getNode().getImmediateChild(l).updateChild(d,n);a=".priority"==l?c.updatePriority(u.getNode(),f):c.updateChild(u.getNode(),l,f,d,me,null)}var p=t.updateServerSnap(a,u.isFullyInitialized()||e.isEmpty(),c.filtersNodes()),v=new _e(i,p,r);return this.generateEventCacheAfterServerEvent_(p,e,i,v,s)},t.prototype.applyUserOverwrite_=function(t,e,n,i,r,o){var s,a,u=t.getEventCache(),c=new _e(i,t,r);if(e.isEmpty())a=this.filter_.updateFullNode(t.getEventCache().getNode(),n,o),s=t.updateEventSnap(a,!0,this.filter_.filtersNodes());else{var h=e.getFront();if(".priority"===h)a=this.filter_.updatePriority(t.getEventCache().getNode(),n),s=t.updateEventSnap(a,u.isFullyInitialized(),u.isFiltered());else{var l=e.popFront(),d=u.getNode().getImmediateChild(h),f=void 0;if(l.isEmpty())f=n;else{var p=c.getCompleteChild(h);f=null!=p?".priority"===l.getBack()&&p.getChild(l.parent()).isEmpty()?p:p.updateChild(l,n):Wt.EMPTY_NODE}if(d.equals(f))s=t;else{var v=this.filter_.updateChild(u.getNode(),h,f,l,c,o);s=t.updateEventSnap(v,u.isFullyInitialized(),this.filter_.filtersNodes())}}}return s},t.cacheHasChild_=function(t,e){return t.getEventCache().isCompleteForChild(e)},t.prototype.applyUserMerge_=function(e,n,i,r,o,s){var a=this,u=e;return i.foreach(function(i,c){var h=n.child(i);t.cacheHasChild_(e,h.getFront())&&(u=a.applyUserOverwrite_(u,h,c,r,o,s))}),i.foreach(function(i,c){var h=n.child(i);t.cacheHasChild_(e,h.getFront())||(u=a.applyUserOverwrite_(u,h,c,r,o,s))}),u},t.prototype.applyMerge_=function(t,e){return e.foreach(function(e,n){t=t.updateChild(e,n)}),t},t.prototype.applyServerMerge_=function(t,e,n,i,r,o,s){var a=this;if(t.getServerCache().getNode().isEmpty()&&!t.getServerCache().isFullyInitialized())return t;var u,c=t;u=e.isEmpty()?n:ce.Empty.setTree(e,n);var h=t.getServerCache().getNode();return u.children.inorderTraversal(function(e,n){if(h.hasChild(e)){var u=t.getServerCache().getNode().getImmediateChild(e),l=a.applyMerge_(u,n);c=a.applyServerOverwrite_(c,new J(e),l,i,r,o,s)}}),u.children.inorderTraversal(function(e,n){var u=!t.getServerCache().isCompleteForChild(e)&&null==n.value;if(!h.hasChild(e)&&!u){var l=t.getServerCache().getNode().getImmediateChild(e),d=a.applyMerge_(l,n);c=a.applyServerOverwrite_(c,new J(e),d,i,r,o,s)}}),c},t.prototype.ackUserWrite_=function(t,e,n,i,r,o){if(null!=i.shadowingWrite(e))return t;var s=t.getServerCache().isFiltered(),a=t.getServerCache();if(null!=n.value){if(e.isEmpty()&&a.isFullyInitialized()||a.isCompleteForPath(e))return this.applyServerOverwrite_(t,e,a.getNode().getChild(e),i,r,s,o);if(e.isEmpty()){var u=ce.Empty;return a.getNode().forEachChild(Et,function(t,e){u=u.set(new J(t),e)}),this.applyServerMerge_(t,e,u,i,r,s,o)}return t}var c=ce.Empty;return n.foreach(function(t,n){var i=e.child(t);a.isCompleteForPath(i)&&(c=c.set(t,a.getNode().getChild(i)))}),this.applyServerMerge_(t,e,c,i,r,s,o)},t.prototype.listenComplete_=function(t,e,n,i){var r=t.getServerCache(),o=t.updateServerSnap(r.getNode(),r.isFullyInitialized()||e.isEmpty(),r.isFiltered());return this.generateEventCacheAfterServerEvent_(o,e,n,me,i)},t.prototype.revertUserWrite_=function(t,e,n,i,r){var o;if(null!=n.shadowingWrite(e))return t;var s=new _e(n,t,i),a=t.getEventCache().getNode(),u=void 0;if(e.isEmpty()||".priority"===e.getFront()){var c=void 0;if(t.getServerCache().isFullyInitialized())c=n.calcCompleteEventCache(t.getCompleteServerSnap());else{var h=t.getServerCache().getNode();g.assert(h instanceof Wt,"serverChildren would be complete if leaf node"),c=n.calcCompleteEventChildren(h)}c=c,u=this.filter_.updateFullNode(a,c,r)}else{var l=e.getFront(),d=n.calcCompleteChild(l,t.getServerCache());null==d&&t.getServerCache().isCompleteForChild(l)&&(d=a.getImmediateChild(l)),(u=null!=d?this.filter_.updateChild(a,l,d,e.popFront(),s,r):t.getEventCache().getNode().hasChild(l)?this.filter_.updateChild(a,l,Wt.EMPTY_NODE,e.popFront(),s,r):a).isEmpty()&&t.getServerCache().isFullyInitialized()&&(o=n.calcCompleteEventCache(t.getCompleteServerSnap())).isLeafNode()&&(u=this.filter_.updateFullNode(u,o,r))}return o=t.getServerCache().isFullyInitialized()||null!=n.shadowingWrite(J.Empty),t.updateEventSnap(u,o,this.filter_.filtersNodes())},t}(),Ce=function(){function t(t){this.query_=t,this.index_=this.query_.getQueryParams().getIndex()}return t.prototype.generateEventsForChanges=function(t,e,n){var i=this,r=[],o=[];return t.forEach(function(t){t.type===ve.CHILD_CHANGED&&i.index_.indexedValueChanged(t.oldSnap,t.snapshotNode)&&o.push(ve.childMovedChange(t.childName,t.snapshotNode))}),this.generateEventsForType_(r,ve.CHILD_REMOVED,t,n,e),this.generateEventsForType_(r,ve.CHILD_ADDED,t,n,e),this.generateEventsForType_(r,ve.CHILD_MOVED,o,n,e),this.generateEventsForType_(r,ve.CHILD_CHANGED,t,n,e),this.generateEventsForType_(r,ve.VALUE,t,n,e),r},t.prototype.generateEventsForType_=function(t,e,n,i,r){var o=this,s=n.filter(function(t){return t.type===e});s.sort(this.compareChanges_.bind(this)),s.forEach(function(e){var n=o.materializeSingleChange_(e,r);i.forEach(function(i){i.respondsTo(e.type)&&t.push(i.createEvent(n,o.query_))})})},t.prototype.materializeSingleChange_=function(t,e){return"value"===t.type||"child_removed"===t.type?t:(t.prevName=e.getPredecessorChildName(t.childName,t.snapshotNode,this.index_),t)},t.prototype.compareChanges_=function(t,e){if(null==t.childName||null==e.childName)throw g.assertionError("Should only compare child_ events.");var n=new wt(t.childName,t.snapshotNode),i=new wt(e.childName,e.snapshotNode);return this.index_.compare(n,i)},t}(),Te=function(){function t(t,e){this.query_=t,this.eventRegistrations_=[];var n=this.query_.getQueryParams(),i=new ge(n.getIndex()),r=n.getNodeFilter();this.processor_=new we(r);var o=e.getServerCache(),s=e.getEventCache(),a=i.updateFullNode(Wt.EMPTY_NODE,o.getNode(),null),u=r.updateFullNode(Wt.EMPTY_NODE,s.getNode(),null),c=new fe(a,o.isFullyInitialized(),i.filtersNodes()),h=new fe(u,s.isFullyInitialized(),r.filtersNodes());this.viewCache_=new pe(h,c),this.eventGenerator_=new Ce(this.query_)}return t.prototype.getQuery=function(){return this.query_},t.prototype.getServerCache=function(){return this.viewCache_.getServerCache().getNode()},t.prototype.getCompleteServerCache=function(t){var e=this.viewCache_.getCompleteServerSnap();return e&&(this.query_.getQueryParams().loadsAllData()||!t.isEmpty()&&!e.getImmediateChild(t.getFront()).isEmpty())?e.getChild(t):null},t.prototype.isEmpty=function(){return 0===this.eventRegistrations_.length},t.prototype.addEventRegistration=function(t){this.eventRegistrations_.push(t)},t.prototype.removeEventRegistration=function(t,e){var n=[];if(e){g.assert(null==t,"A cancel should cancel all event registrations.");var i=this.query_.path;this.eventRegistrations_.forEach(function(t){e=e;var r=t.createCancelEvent(e,i);r&&n.push(r)})}if(t){for(var r=[],o=0;o<this.eventRegistrations_.length;++o){var s=this.eventRegistrations_[o];if(s.matches(t)){if(t.hasAnyCallback()){r=r.concat(this.eventRegistrations_.slice(o+1));break}}else r.push(s)}this.eventRegistrations_=r}else this.eventRegistrations_=[];return n},t.prototype.applyOperation=function(t,e,n){t.type===Ht.MERGE&&null!==t.source.queryId&&(g.assert(this.viewCache_.getCompleteServerSnap(),"We should always have a full cache before handling merges"),g.assert(this.viewCache_.getCompleteEventSnap(),"Missing event cache, even though we have a server cache"));var i=this.viewCache_,r=this.processor_.applyOperation(i,t,e,n);return this.processor_.assertIndexed(r.viewCache),g.assert(r.viewCache.getServerCache().isFullyInitialized()||!i.getServerCache().isFullyInitialized(),"Once a server snap is complete, it should never go back"),this.viewCache_=r.viewCache,this.generateEventsForChanges_(r.changes,r.viewCache.getEventCache().getNode(),null)},t.prototype.getInitialEvents=function(t){var e=this.viewCache_.getEventCache(),n=[];return e.getNode().isLeafNode()||e.getNode().forEachChild(At,function(t,e){n.push(ve.childAddedChange(t,e))}),e.isFullyInitialized()&&n.push(ve.valueChange(e.getNode())),this.generateEventsForChanges_(n,e.getNode(),t)},t.prototype.generateEventsForChanges_=function(t,e,n){var i=n?[n]:this.eventRegistrations_;return this.eventGenerator_.generateEventsForChanges(t,e,i)},t}(),Ee=function(){function t(){this.views_={}}return Object.defineProperty(t,"__referenceConstructor",{get:function(){return g.assert(oe,"Reference.ts has not been loaded"),oe},set:function(t){g.assert(!oe,"__referenceConstructor has already been defined"),oe=t},enumerable:!0,configurable:!0}),t.prototype.isEmpty=function(){return g.isEmpty(this.views_)},t.prototype.applyOperation=function(t,e,n){var i=t.source.queryId;if(null!==i){var r=g.safeGet(this.views_,i);return g.assert(null!=r,"SyncTree gave us an op for an invalid query."),r.applyOperation(t,e,n)}var o=[];return g.forEach(this.views_,function(i,r){o=o.concat(r.applyOperation(t,e,n))}),o},t.prototype.addEventRegistration=function(t,e,n,i,r){var o=t.queryIdentifier(),s=g.safeGet(this.views_,o);if(!s){var a=n.calcCompleteEventCache(r?i:null),u=!1;a?u=!0:i instanceof Wt?(a=n.calcCompleteEventChildren(i),u=!1):(a=Wt.EMPTY_NODE,u=!1);var c=new pe(new fe(a,u,!1),new fe(i,r,!1));s=new Te(t,c),this.views_[o]=s}return s.addEventRegistration(e),s.getInitialEvents(e)},t.prototype.removeEventRegistration=function(e,n,i){var r=e.queryIdentifier(),o=[],s=[],a=this.hasCompleteView();if("default"===r){var u=this;g.forEach(this.views_,function(t,e){s=s.concat(e.removeEventRegistration(n,i)),e.isEmpty()&&(delete u.views_[t],e.getQuery().getQueryParams().loadsAllData()||o.push(e.getQuery()))})}else{var c=g.safeGet(this.views_,r);c&&(s=s.concat(c.removeEventRegistration(n,i)),c.isEmpty()&&(delete this.views_[r],c.getQuery().getQueryParams().loadsAllData()||o.push(c.getQuery())))}return a&&!this.hasCompleteView()&&o.push(new t.__referenceConstructor(e.repo,e.path)),{removed:o,events:s}},t.prototype.getQueryViews=function(){var t=this;return Object.keys(this.views_).map(function(e){return t.views_[e]}).filter(function(t){return!t.getQuery().getQueryParams().loadsAllData()})},t.prototype.getCompleteServerCache=function(t){var e=null;return g.forEach(this.views_,function(n,i){e=e||i.getCompleteServerCache(t)}),e},t.prototype.viewForQuery=function(t){if(t.getQueryParams().loadsAllData())return this.getCompleteView();var e=t.queryIdentifier();return g.safeGet(this.views_,e)},t.prototype.viewExistsForQuery=function(t){return null!=this.viewForQuery(t)},t.prototype.hasCompleteView=function(){return null!=this.getCompleteView()},t.prototype.getCompleteView=function(){return g.findValue(this.views_,function(t){return t.getQuery().getQueryParams().loadsAllData()})||null},t}(),Se=function(){function t(t){this.writeTree_=t}return t.prototype.addWrite=function(e,n){if(e.isEmpty())return new t(new ce(n));var i=this.writeTree_.findRootMostValueAndPath(e);if(null!=i){var r=i.path,o=i.value,s=J.relativePath(r,e);return o=o.updateChild(s,n),new t(this.writeTree_.set(r,o))}var a=new ce(n);return new t(this.writeTree_.setTree(e,a))},t.prototype.addWrites=function(t,e){var n=this;return g.forEach(e,function(e,i){n=n.addWrite(t.child(e),i)}),n},t.prototype.removeWrite=function(e){return e.isEmpty()?t.Empty:new t(this.writeTree_.setTree(e,ce.Empty))},t.prototype.hasCompleteWrite=function(t){return null!=this.getCompleteNode(t)},t.prototype.getCompleteNode=function(t){var e=this.writeTree_.findRootMostValueAndPath(t);return null!=e?this.writeTree_.get(e.path).getChild(J.relativePath(e.path,t)):null},t.prototype.getCompleteChildren=function(){var t=[],e=this.writeTree_.value;return null!=e?e.isLeafNode()||e.forEachChild(At,function(e,n){t.push(new wt(e,n))}):this.writeTree_.children.inorderTraversal(function(e,n){null!=n.value&&t.push(new wt(e,n.value))}),t},t.prototype.childCompoundWrite=function(e){if(e.isEmpty())return this;var n=this.getCompleteNode(e);return new t(null!=n?new ce(n):this.writeTree_.subtree(e))},t.prototype.isEmpty=function(){return this.writeTree_.isEmpty()},t.prototype.apply=function(e){return t.applySubtreeWrite_(J.Empty,this.writeTree_,e)},t.Empty=new t(new ce(null)),t.applySubtreeWrite_=function(e,n,i){if(null!=n.value)return i.updateChild(e,n.value);var r=null;return n.children.inorderTraversal(function(n,o){".priority"===n?(g.assert(null!==o.value,"Priority writes must always be leaf nodes"),r=o.value):i=t.applySubtreeWrite_(e.child(n),o,i)}),i.getChild(e).isEmpty()||null===r||(i=i.updateChild(e.child(".priority"),r)),i},t}(),Ie=function(){function t(){this.visibleWrites_=Se.Empty,this.allWrites_=[],this.lastWriteId_=-1}return t.prototype.childWrites=function(t){return new ke(t,this)},t.prototype.addOverwrite=function(t,e,n,i){g.assert(n>this.lastWriteId_,"Stacking an older write on top of newer ones"),void 0===i&&(i=!0),this.allWrites_.push({path:t,snap:e,writeId:n,visible:i}),i&&(this.visibleWrites_=this.visibleWrites_.addWrite(t,e)),this.lastWriteId_=n},t.prototype.addMerge=function(t,e,n){g.assert(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},t.prototype.getWrite=function(t){for(var e=0;e<this.allWrites_.length;e++){var n=this.allWrites_[e];if(n.writeId===t)return n}return null},t.prototype.removeWrite=function(t){var e=this,n=this.allWrites_.findIndex(function(e){return e.writeId===t});g.assert(n>=0,"removeWrite called with nonexistent writeId.");var i=this.allWrites_[n];this.allWrites_.splice(n,1);for(var r=i.visible,o=!1,s=this.allWrites_.length-1;r&&s>=0;){var a=this.allWrites_[s];a.visible&&(s>=n&&this.recordContainsPath_(a,i.path)?r=!1:i.path.contains(a.path)&&(o=!0)),s--}if(r){if(o)return this.resetTree_(),!0;if(i.snap)this.visibleWrites_=this.visibleWrites_.removeWrite(i.path);else{var u=i.children;g.forEach(u,function(t){e.visibleWrites_=e.visibleWrites_.removeWrite(i.path.child(t))})}return!0}return!1},t.prototype.getCompleteWriteData=function(t){return this.visibleWrites_.getCompleteNode(t)},t.prototype.calcCompleteEventCache=function(e,n,i,r){if(i||r){var o=this.visibleWrites_.childCompoundWrite(e);if(!r&&o.isEmpty())return n;if(r||null!=n||o.hasCompleteWrite(J.Empty)){var s=t.layerTree_(this.allWrites_,function(t){return(t.visible||r)&&(!i||!~i.indexOf(t.writeId))&&(t.path.contains(e)||e.contains(t.path))},e);return c=n||Wt.EMPTY_NODE,s.apply(c)}return null}var a=this.visibleWrites_.getCompleteNode(e);if(null!=a)return a;var u=this.visibleWrites_.childCompoundWrite(e);if(u.isEmpty())return n;if(null!=n||u.hasCompleteWrite(J.Empty)){var c=n||Wt.EMPTY_NODE;return u.apply(c)}return null},t.prototype.calcCompleteEventChildren=function(t,e){var n=Wt.EMPTY_NODE,i=this.visibleWrites_.getCompleteNode(t);if(i)return i.isLeafNode()||i.forEachChild(At,function(t,e){n=n.updateImmediateChild(t,e)}),n;if(e){var r=this.visibleWrites_.childCompoundWrite(t);return e.forEachChild(At,function(t,e){var i=r.childCompoundWrite(new J(t)).apply(e);n=n.updateImmediateChild(t,i)}),r.getCompleteChildren().forEach(function(t){n=n.updateImmediateChild(t.name,t.node)}),n}return this.visibleWrites_.childCompoundWrite(t).getCompleteChildren().forEach(function(t){n=n.updateImmediateChild(t.name,t.node)}),n},t.prototype.calcEventCacheAfterServerOverwrite=function(t,e,n,i){g.assert(n||i,"Either existingEventSnap or existingServerSnap must exist");var r=t.child(e);if(this.visibleWrites_.hasCompleteWrite(r))return null;var o=this.visibleWrites_.childCompoundWrite(r);return o.isEmpty()?i.getChild(e):o.apply(i.getChild(e))},t.prototype.calcCompleteChild=function(t,e,n){var i=t.child(e),r=this.visibleWrites_.getCompleteNode(i);return null!=r?r:n.isCompleteForChild(e)?this.visibleWrites_.childCompoundWrite(i).apply(n.getNode().getImmediateChild(e)):null},t.prototype.shadowingWrite=function(t){return this.visibleWrites_.getCompleteNode(t)},t.prototype.calcIndexedSlice=function(t,e,n,i,r,o){var s,a=this.visibleWrites_.childCompoundWrite(t),u=a.getCompleteNode(J.Empty);if(null!=u)s=u;else{if(null==e)return[];s=a.apply(e)}if((s=s.withIndex(o)).isEmpty()||s.isLeafNode())return[];for(var c=[],h=o.getCompare(),l=r?s.getReverseIteratorFrom(n,o):s.getIteratorFrom(n,o),d=l.getNext();d&&c.length<i;)0!==h(d,n)&&c.push(d),d=l.getNext();return c},t.prototype.recordContainsPath_=function(t,e){return t.snap?t.path.contains(e):!!g.findKey(t.children,function(n,i){return t.path.child(i).contains(e)})},t.prototype.resetTree_=function(){this.visibleWrites_=t.layerTree_(this.allWrites_,t.DefaultFilter_,J.Empty),this.allWrites_.length>0?this.lastWriteId_=this.allWrites_[this.allWrites_.length-1].writeId:this.lastWriteId_=-1},t.DefaultFilter_=function(t){return t.visible},t.layerTree_=function(t,e,n){for(var i=Se.Empty,r=0;r<t.length;++r){var o=t[r];if(e(o)){var s=o.path,a=void 0;if(o.snap)n.contains(s)?(a=J.relativePath(n,s),i=i.addWrite(a,o.snap)):s.contains(n)&&(a=J.relativePath(s,n),i=i.addWrite(J.Empty,o.snap.getChild(a)));else{if(!o.children)throw g.assertionError("WriteRecord should have .snap or .children");if(n.contains(s))a=J.relativePath(n,s),i=i.addWrites(a,o.children);else if(s.contains(n))if((a=J.relativePath(s,n)).isEmpty())i=i.addWrites(J.Empty,o.children);else{var u=g.safeGet(o.children,a.getFront());if(u){var c=u.getChild(a.popFront());i=i.addWrite(J.Empty,c)}}}}}return i},t}(),ke=function(){function t(t,e){this.treePath_=t,this.writeTree_=e}return t.prototype.calcCompleteEventCache=function(t,e,n){return this.writeTree_.calcCompleteEventCache(this.treePath_,t,e,n)},t.prototype.calcCompleteEventChildren=function(t){return this.writeTree_.calcCompleteEventChildren(this.treePath_,t)},t.prototype.calcEventCacheAfterServerOverwrite=function(t,e,n){return this.writeTree_.calcEventCacheAfterServerOverwrite(this.treePath_,t,e,n)},t.prototype.shadowingWrite=function(t){return this.writeTree_.shadowingWrite(this.treePath_.child(t))},t.prototype.calcIndexedSlice=function(t,e,n,i,r){return this.writeTree_.calcIndexedSlice(this.treePath_,t,e,n,i,r)},t.prototype.calcCompleteChild=function(t,e){return this.writeTree_.calcCompleteChild(this.treePath_,t,e)},t.prototype.child=function(e){return new t(this.treePath_.child(e),this.writeTree_)},t}(),Ae=function(){function t(t){this.listenProvider_=t,this.syncPointTree_=ce.Empty,this.pendingWriteTree_=new Ie,this.tagToQueryMap_={},this.queryToTagMap_={}}return t.prototype.applyUserOverwrite=function(t,e,n,i){return this.pendingWriteTree_.addOverwrite(t,e,n,i),i?this.applyOperationToSyncPoints_(new le(se.User,t,e)):[]},t.prototype.applyUserMerge=function(t,e,n){this.pendingWriteTree_.addMerge(t,e,n);var i=ce.fromObject(e);return this.applyOperationToSyncPoints_(new de(se.User,t,i))},t.prototype.ackUserWrite=function(t,e){void 0===e&&(e=!1);var n=this.pendingWriteTree_.getWrite(t);if(this.pendingWriteTree_.removeWrite(t)){var i=ce.Empty;return null!=n.snap?i=i.set(J.Empty,!0):g.forEach(n.children,function(t,e){i=i.set(new J(t),e)}),this.applyOperationToSyncPoints_(new ae(n.path,i,e))}return[]},t.prototype.applyServerOverwrite=function(t,e){return this.applyOperationToSyncPoints_(new le(se.Server,t,e))},t.prototype.applyServerMerge=function(t,e){var n=ce.fromObject(e);return this.applyOperationToSyncPoints_(new de(se.Server,t,n))},t.prototype.applyListenComplete=function(t){return this.applyOperationToSyncPoints_(new he(se.Server,t))},t.prototype.applyTaggedQueryOverwrite=function(e,n,i){var r=this.queryKeyForTag_(i);if(null!=r){var o=t.parseQueryKey_(r),s=o.path,a=o.queryId,u=J.relativePath(s,e),c=new le(se.forServerTaggedQuery(a),u,n);return this.applyTaggedOperation_(s,c)}return[]},t.prototype.applyTaggedQueryMerge=function(e,n,i){var r=this.queryKeyForTag_(i);if(r){var o=t.parseQueryKey_(r),s=o.path,a=o.queryId,u=J.relativePath(s,e),c=ce.fromObject(n),h=new de(se.forServerTaggedQuery(a),u,c);return this.applyTaggedOperation_(s,h)}return[]},t.prototype.applyTaggedListenComplete=function(e,n){var i=this.queryKeyForTag_(n);if(i){var r=t.parseQueryKey_(i),o=r.path,s=r.queryId,a=J.relativePath(o,e),u=new he(se.forServerTaggedQuery(s),a);return this.applyTaggedOperation_(o,u)}return[]},t.prototype.addEventRegistration=function(e,n){var i=e.path,r=null,o=!1;this.syncPointTree_.foreachOnPath(i,function(t,e){var n=J.relativePath(t,i);r=r||e.getCompleteServerCache(n),o=o||e.hasCompleteView()});var s,a=this.syncPointTree_.get(i);a?(o=o||a.hasCompleteView(),r=r||a.getCompleteServerCache(J.Empty)):(a=new Ee,this.syncPointTree_=this.syncPointTree_.set(i,a)),null!=r?s=!0:(s=!1,r=Wt.EMPTY_NODE,this.syncPointTree_.subtree(i).foreachChild(function(t,e){var n=e.getCompleteServerCache(J.Empty);n&&(r=r.updateImmediateChild(t,n))}));var u=a.viewExistsForQuery(e);if(!u&&!e.getQueryParams().loadsAllData()){var c=t.makeQueryKey_(e);g.assert(!(c in this.queryToTagMap_),"View does not exist, but we have a tag");var h=t.getNextQueryTag_();this.queryToTagMap_[c]=h,this.tagToQueryMap_["_"+h]=c}var l=this.pendingWriteTree_.childWrites(i),d=a.addEventRegistration(e,n,l,r,s);if(!u&&!o){var f=a.viewForQuery(e);d=d.concat(this.setupListener_(e,f))}return d},t.prototype.removeEventRegistration=function(e,n,i){var r=this,o=e.path,s=this.syncPointTree_.get(o),a=[];if(s&&("default"===e.queryIdentifier()||s.viewExistsForQuery(e))){var u=s.removeEventRegistration(e,n,i);s.isEmpty()&&(this.syncPointTree_=this.syncPointTree_.remove(o));var c=u.removed;a=u.events;var h=-1!==c.findIndex(function(t){return t.getQueryParams().loadsAllData()}),l=this.syncPointTree_.findOnPath(o,function(t,e){return e.hasCompleteView()});if(h&&!l){var d=this.syncPointTree_.subtree(o);if(!d.isEmpty())for(var f=this.collectDistinctViewsForSubTree_(d),p=0;p<f.length;++p){var v=f[p],g=v.getQuery(),y=this.createListenerForView_(v);this.listenProvider_.startListening(t.queryForListening_(g),this.tagForQuery_(g),y.hashFn,y.onComplete)}}!l&&c.length>0&&!i&&(h?this.listenProvider_.stopListening(t.queryForListening_(e),null):c.forEach(function(e){var n=r.queryToTagMap_[t.makeQueryKey_(e)];r.listenProvider_.stopListening(t.queryForListening_(e),n)})),this.removeTags_(c)}return a},t.prototype.calcCompleteEventCache=function(t,e){var n=this.pendingWriteTree_,i=this.syncPointTree_.findOnPath(t,function(e,n){var i=J.relativePath(e,t),r=n.getCompleteServerCache(i);if(r)return r});return n.calcCompleteEventCache(t,i,e,!0)},t.prototype.collectDistinctViewsForSubTree_=function(t){return t.fold(function(t,e,n){if(e&&e.hasCompleteView())return[e.getCompleteView()];var i=[];return e&&(i=e.getQueryViews()),g.forEach(n,function(t,e){i=i.concat(e)}),i})},t.prototype.removeTags_=function(e){for(var n=0;n<e.length;++n){var i=e[n];if(!i.getQueryParams().loadsAllData()){var r=t.makeQueryKey_(i),o=this.queryToTagMap_[r];delete this.queryToTagMap_[r],delete this.tagToQueryMap_["_"+o]}}},t.queryForListening_=function(t){return t.getQueryParams().loadsAllData()&&!t.getQueryParams().isDefault()?t.getRef():t},t.prototype.setupListener_=function(e,n){var i=e.path,r=this.tagForQuery_(e),o=this.createListenerForView_(n),s=this.listenProvider_.startListening(t.queryForListening_(e),r,o.hashFn,o.onComplete),a=this.syncPointTree_.subtree(i);if(r)g.assert(!a.value.hasCompleteView(),"If we're adding a query, it shouldn't be shadowed");else for(var u=a.fold(function(t,e,n){if(!t.isEmpty()&&e&&e.hasCompleteView())return[e.getCompleteView().getQuery()];var i=[];return e&&(i=i.concat(e.getQueryViews().map(function(t){return t.getQuery()}))),g.forEach(n,function(t,e){i=i.concat(e)}),i}),c=0;c<u.length;++c){var h=u[c];this.listenProvider_.stopListening(t.queryForListening_(h),this.tagForQuery_(h))}return s},t.prototype.createListenerForView_=function(t){var e=this,n=t.getQuery(),i=this.tagForQuery_(n);return{hashFn:function(){return(t.getServerCache()||Wt.EMPTY_NODE).hash()},onComplete:function(t){if("ok"===t)return i?e.applyTaggedListenComplete(n.path,i):e.applyListenComplete(n.path);var r=function(t,e){var n="Unknown Error";"too_big"===t?n="The data requested exceeds the maximum size that can be accessed with a single request.":"permission_denied"==t?n="Client doesn't have permission to access the desired data.":"unavailable"==t&&(n="The service is unavailable");var i=new Error(t+" at "+e.path.toString()+": "+n);return i.code=t.toUpperCase(),i}(t,n);return e.removeEventRegistration(n,null,r)}}},t.makeQueryKey_=function(t){return t.path.toString()+"$"+t.queryIdentifier()},t.parseQueryKey_=function(t){var e=t.indexOf("$");return g.assert(-1!==e&&e<t.length-1,"Bad queryKey."),{queryId:t.substr(e+1),path:new J(t.substr(0,e))}},t.prototype.queryKeyForTag_=function(t){return this.tagToQueryMap_["_"+t]},t.prototype.tagForQuery_=function(e){var n=t.makeQueryKey_(e);return g.safeGet(this.queryToTagMap_,n)},t.getNextQueryTag_=function(){return t.nextQueryTag_++},t.prototype.applyTaggedOperation_=function(t,e){var n=this.syncPointTree_.get(t);g.assert(n,"Missing sync point for query tag that we're tracking");var i=this.pendingWriteTree_.childWrites(t);return n.applyOperation(e,i,null)},t.prototype.applyOperationToSyncPoints_=function(t){return this.applyOperationHelper_(t,this.syncPointTree_,null,this.pendingWriteTree_.childWrites(J.Empty))},t.prototype.applyOperationHelper_=function(t,e,n,i){if(t.path.isEmpty())return this.applyOperationDescendantsHelper_(t,e,n,i);var r=e.get(J.Empty);null==n&&null!=r&&(n=r.getCompleteServerCache(J.Empty));var o=[],s=t.path.getFront(),a=t.operationForChild(s),u=e.children.get(s);if(u&&a){var c=n?n.getImmediateChild(s):null,h=i.child(s);o=o.concat(this.applyOperationHelper_(a,u,c,h))}return r&&(o=o.concat(r.applyOperation(t,i,n))),o},t.prototype.applyOperationDescendantsHelper_=function(t,e,n,i){var r=this,o=e.get(J.Empty);null==n&&null!=o&&(n=o.getCompleteServerCache(J.Empty));var s=[];return e.children.inorderTraversal(function(e,o){var a=n?n.getImmediateChild(e):null,u=i.child(e),c=t.operationForChild(e);c&&(s=s.concat(r.applyOperationDescendantsHelper_(c,o,a,u)))}),o&&(s=s.concat(o.applyOperation(t,i,n))),s},t.nextQueryTag_=1,t}(),Pe=function(){function t(){this.rootNode_=Wt.EMPTY_NODE}return t.prototype.getNode=function(t){return this.rootNode_.getChild(t)},t.prototype.updateSnapshot=function(t,e){this.rootNode_=this.rootNode_.updateChild(t,e)},t}(),Ne=function(){function t(t){this.app_=t}return t.prototype.getToken=function(t){return this.app_.INTERNAL.getToken(t).then(null,function(t){return t&&"auth/token-not-initialized"===t.code?(R("Got auth/token-not-initialized error.  Treating as null token."),null):Promise.reject(t)})},t.prototype.addTokenChangeListener=function(t){this.app_.INTERNAL.addAuthTokenListener(t)},t.prototype.removeTokenChangeListener=function(t){this.app_.INTERNAL.removeAuthTokenListener(t)},t.prototype.notifyForInvalidToken=function(){var t='Provided authentication credentials for the app named "'+this.app_.name+'" are invalid. This usually indicates your app was not initialized correctly. ';"credential"in this.app_.options?t+='Make sure the "credential" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':"serviceAccount"in this.app_.options?t+='Make sure the "serviceAccount" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':t+='Make sure the "apiKey" and "databaseURL" properties provided to initializeApp() match the values provided for your app at https://console.firebase.google.com/.',L(t)},t}(),De=function(){function t(){this.counters_={}}return t.prototype.incrementCounter=function(t,e){void 0===e&&(e=1),g.contains(this.counters_,t)||(this.counters_[t]=0),this.counters_[t]+=e},t.prototype.get=function(){return g.deepCopy(this.counters_)},t}(),Re=function(){function t(){}return t.getCollection=function(t){var e=t.toString();return this.collections_[e]||(this.collections_[e]=new De),this.collections_[e]},t.getOrCreateReporter=function(t,e){var n=t.toString();return this.reporters_[n]||(this.reporters_[n]=e()),this.reporters_[n]},t.collections_={},t.reporters_={},t}(),Oe=function(){function t(t){this.collection_=t,this.last_=null}return t.prototype.get=function(){var t=this.collection_.get(),e=g.clone(t);return this.last_&&g.forEach(this.last_,function(t,n){e[t]=e[t]-n}),this.last_=t,e},t}(),xe=1e4,Me=3e4,Le=function(){function t(t,e){this.server_=e,this.statsToReport_={},this.statsListener_=new Oe(t);var n=xe+(Me-xe)*Math.random();X(this.reportStats_.bind(this),Math.floor(n))}return t.prototype.includeStat=function(t){this.statsToReport_[t]=!0},t.prototype.reportStats_=function(){var t=this,e=this.statsListener_.get(),n={},i=!1;g.forEach(e,function(e,r){r>0&&g.contains(t.statsToReport_,e)&&(n[e]=r,i=!0)}),i&&this.server_.reportStats(n),X(this.reportStats_.bind(this),Math.floor(2*Math.random()*3e5))},t}(),Fe=function(){function t(){this.eventLists_=[],this.recursionDepth_=0}return t.prototype.queueEvents=function(t){for(var e=null,n=0;n<t.length;n++){var i=t[n],r=i.getPath();null===e||r.equals(e.getPath())||(this.eventLists_.push(e),e=null),null===e&&(e=new Ue(r)),e.add(i)}e&&this.eventLists_.push(e)},t.prototype.raiseEventsAtPath=function(t,e){this.queueEvents(e),this.raiseQueuedEventsMatchingPredicate_(function(e){return e.equals(t)})},t.prototype.raiseEventsForChangedPath=function(t,e){this.queueEvents(e),this.raiseQueuedEventsMatchingPredicate_(function(e){return e.contains(t)||t.contains(e)})},t.prototype.raiseQueuedEventsMatchingPredicate_=function(t){this.recursionDepth_++;for(var e=!0,n=0;n<this.eventLists_.length;n++){var i=this.eventLists_[n];i&&(t(i.getPath())?(this.eventLists_[n].raise(),this.eventLists_[n]=null):e=!1)}e&&(this.eventLists_=[]),this.recursionDepth_--},t}(),Ue=function(){function t(t){this.path_=t,this.events_=[]}return t.prototype.add=function(t){this.events_.push(t)},t.prototype.raise=function(){for(var t=0;t<this.events_.length;t++){var e=this.events_[t];if(null!==e){this.events_[t]=null;var n=e.getEventRunner();P&&R("event: "+e.toString()),Y(n)}}},t.prototype.getPath=function(){return this.path_},t}(),je=function(){function t(t){this.allowedEvents_=t,this.listeners_={},g.assert(Array.isArray(t)&&t.length>0,"Requires a non-empty array")}return t.prototype.trigger=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(Array.isArray(this.listeners_[t]))for(var i=this.listeners_[t].slice(),r=0;r<i.length;r++)i[r].callback.apply(i[r].context,e)},t.prototype.on=function(t,e,n){this.validateEventType_(t),this.listeners_[t]=this.listeners_[t]||[],this.listeners_[t].push({callback:e,context:n});var i=this.getInitialEvent(t);i&&e.apply(n,i)},t.prototype.off=function(t,e,n){this.validateEventType_(t);for(var i=this.listeners_[t]||[],r=0;r<i.length;r++)if(i[r].callback===e&&(!n||n===i[r].context))return void i.splice(r,1)},t.prototype.validateEventType_=function(t){g.assert(this.allowedEvents_.find(function(e){return e===t}),"Unknown event: "+t)},t}(),We=function(t){function e(){var e,n,i=t.call(this,["visible"])||this;return"undefined"!=typeof document&&void 0!==document.addEventListener&&(void 0!==document.hidden?(n="visibilitychange",e="hidden"):void 0!==document.mozHidden?(n="mozvisibilitychange",e="mozHidden"):void 0!==document.msHidden?(n="msvisibilitychange",e="msHidden"):void 0!==document.webkitHidden&&(n="webkitvisibilitychange",e="webkitHidden")),i.visible_=!0,n&&document.addEventListener(n,function(){var t=!document[e];t!==i.visible_&&(i.visible_=t,i.trigger("visible",t))},!1),i}return m.__extends(e,t),e.getInstance=function(){return new e},e.prototype.getInitialEvent=function(t){return g.assert("visible"===t,"Unknown event type: "+t),[this.visible_]},e}(je),Be=function(t){function e(){var e=t.call(this,["online"])||this;return e.online_=!0,"undefined"==typeof window||void 0===window.addEventListener||g.isMobileCordova()||(window.addEventListener("online",function(){e.online_||(e.online_=!0,e.trigger("online",!0))},!1),window.addEventListener("offline",function(){e.online_&&(e.online_=!1,e.trigger("online",!1))},!1)),e}return m.__extends(e,t),e.getInstance=function(){return new e},e.prototype.getInitialEvent=function(t){return g.assert("online"===t,"Unknown event type: "+t),[this.online_]},e.prototype.currentlyOnline=function(){return this.online_},e}(je),$e=function(){function t(t){this.onMessage_=t,this.pendingResponses=[],this.currentResponseNum=0,this.closeAfterResponse=-1,this.onClose=null}return t.prototype.closeAfter=function(t,e){this.closeAfterResponse=t,this.onClose=e,this.closeAfterResponse<this.currentResponseNum&&(this.onClose(),this.onClose=null)},t.prototype.handleResponse=function(t,e){var n=this;this.pendingResponses[t]=e;for(var i=function(){var t=r.pendingResponses[r.currentResponseNum];delete r.pendingResponses[r.currentResponseNum];for(var e=function(e){t[e]&&Y(function(){n.onMessage_(t[e])})},i=0;i<t.length;++i)e(i);if(r.currentResponseNum===r.closeAfterResponse)return r.onClose&&(r.onClose(),r.onClose=null),"break";r.currentResponseNum++},r=this;this.pendingResponses[this.currentResponseNum]&&"break"!==i(););},t}(),Ve="pLPCommand",qe="pRTLPCB",He=function(){function t(t,e,n,i){this.connId=t,this.repoInfo=e,this.transportSessionId=n,this.lastSessionId=i,this.bytesSent=0,this.bytesReceived=0,this.everConnected_=!1,this.log_=O(t),this.stats_=Re.getCollection(e),this.urlFn=function(t){return e.connectionURL(tt,t)}}return t.prototype.open=function(t,e){var n=this;this.curSegmentNum=0,this.onDisconnect_=e,this.myPacketOrderer=new $e(t),this.isClosed_=!1,this.connectTimeoutTimer_=setTimeout(function(){n.log_("Timed out trying to connect."),n.onClosed_(),n.connectTimeoutTimer_=null},Math.floor(3e4)),function(t){if(g.isNodeSdk()||"complete"===document.readyState)t();else{var e=!1,n=function(){document.body?e||(e=!0,t()):setTimeout(n,Math.floor(10))};document.addEventListener?(document.addEventListener("DOMContentLoaded",n,!1),window.addEventListener("load",n,!1)):document.attachEvent&&(document.attachEvent("onreadystatechange",function(){"complete"===document.readyState&&n()}),window.attachEvent("onload",n))}}(function(){if(!n.isClosed_){n.scriptTagHolder=new ze(function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var i=t[0],r=t[1],o=t[2];if(n.incrementIncomingBytes_(t),n.scriptTagHolder)if(n.connectTimeoutTimer_&&(clearTimeout(n.connectTimeoutTimer_),n.connectTimeoutTimer_=null),n.everConnected_=!0,"start"==i)n.id=r,n.password=o;else{if("close"!==i)throw new Error("Unrecognized command received: "+i);r?(n.scriptTagHolder.sendNewPolls=!1,n.myPacketOrderer.closeAfter(r,function(){n.onClosed_()})):n.onClosed_()}},function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var i=t[0],r=t[1];n.incrementIncomingBytes_(t),n.myPacketOrderer.handleResponse(i,r)},function(){n.onClosed_()},n.urlFn);var t={start:"t"};t.ser=Math.floor(1e8*Math.random()),n.scriptTagHolder.uniqueCallbackIdentifier&&(t.cb=n.scriptTagHolder.uniqueCallbackIdentifier),t.v="5",n.transportSessionId&&(t.s=n.transportSessionId),n.lastSessionId&&(t.ls=n.lastSessionId),!g.isNodeSdk()&&"undefined"!=typeof location&&location.href&&-1!==location.href.indexOf("firebaseio.com")&&(t.r="f");var e=n.urlFn(t);n.log_("Connecting via long-poll to "+e),n.scriptTagHolder.addTag(e,function(){})}})},t.prototype.start=function(){this.scriptTagHolder.startLongPoll(this.id,this.password),this.addDisconnectPingFrame(this.id,this.password)},t.forceAllow=function(){t.forceAllow_=!0},t.forceDisallow=function(){t.forceDisallow_=!0},t.isAvailable=function(){return t.forceAllow_||!t.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)&&!g.isNodeSdk()},t.prototype.markConnectionHealthy=function(){},t.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)},t.prototype.onClosed_=function(){this.isClosed_||(this.log_("Longpoll is closing itself"),this.shutdown_(),this.onDisconnect_&&(this.onDisconnect_(this.everConnected_),this.onDisconnect_=null))},t.prototype.close=function(){this.isClosed_||(this.log_("Longpoll is being closed."),this.shutdown_())},t.prototype.send=function(t){var e=g.stringify(t);this.bytesSent+=e.length,this.stats_.incrementCounter("bytes_sent",e.length);for(var n=g.base64Encode(e),i=q(n,1840),r=0;r<i.length;r++)this.scriptTagHolder.enqueueSegment(this.curSegmentNum,i.length,i[r]),this.curSegmentNum++},t.prototype.addDisconnectPingFrame=function(t,e){if(!g.isNodeSdk()){this.myDisconnFrame=document.createElement("iframe");var n={dframe:"t"};n.id=t,n.pw=e,this.myDisconnFrame.src=this.urlFn(n),this.myDisconnFrame.style.display="none",document.body.appendChild(this.myDisconnFrame)}},t.prototype.incrementIncomingBytes_=function(t){var e=g.stringify(t).length;this.bytesReceived+=e,this.stats_.incrementCounter("bytes_received",e)},t}(),ze=function(){function t(e,n,i,r){if(this.onDisconnect=i,this.urlFn=r,this.outstandingRequests=new te,this.pendingSegs=[],this.currentSerial=Math.floor(1e8*Math.random()),this.sendNewPolls=!0,g.isNodeSdk())this.commandCB=e,this.onMessageCB=n;else{this.uniqueCallbackIdentifier=I(),window[Ve+this.uniqueCallbackIdentifier]=e,window[qe+this.uniqueCallbackIdentifier]=n,this.myIFrame=t.createIFrame_();var o="";this.myIFrame.src&&"javascript:"===this.myIFrame.src.substr(0,"javascript:".length)&&(o='<script>document.domain="'+document.domain+'";<\/script>');var s="<html><body>"+o+"</body></html>";try{this.myIFrame.doc.open(),this.myIFrame.doc.write(s),this.myIFrame.doc.close()}catch(t){R("frame writing exception"),t.stack&&R(t.stack),R(t)}}}return t.createIFrame_=function(){var t=document.createElement("iframe");if(t.style.display="none",!document.body)throw"Document body has not initialized. Wait to initialize Firebase until after the document is ready.";document.body.appendChild(t);try{t.contentWindow.document||R("No IE domain setting required")}catch(n){var e=document.domain;t.src="javascript:void((function(){document.open();document.domain='"+e+"';document.close();})())"}return t.contentDocument?t.doc=t.contentDocument:t.contentWindow?t.doc=t.contentWindow.document:t.document&&(t.doc=t.document),t},t.prototype.close=function(){var e=this;if(this.alive=!1,this.myIFrame&&(this.myIFrame.doc.body.innerHTML="",setTimeout(function(){null!==e.myIFrame&&(document.body.removeChild(e.myIFrame),e.myIFrame=null)},Math.floor(0))),g.isNodeSdk()&&this.myID){var n={disconn:"t"};n.id=this.myID,n.pw=this.myPW;var i=this.urlFn(n);t.nodeRestRequest(i)}var r=this.onDisconnect;r&&(this.onDisconnect=null,r())},t.prototype.startLongPoll=function(t,e){for(this.myID=t,this.myPW=e,this.alive=!0;this.newRequest_(););},t.prototype.newRequest_=function(){if(this.alive&&this.sendNewPolls&&this.outstandingRequests.count()<(this.pendingSegs.length>0?2:1)){this.currentSerial++;var t={};t.id=this.myID,t.pw=this.myPW,t.ser=this.currentSerial;for(var e=this.urlFn(t),n="",i=0;this.pendingSegs.length>0&&this.pendingSegs[0].d.length+30+n.length<=1870;){var r=this.pendingSegs.shift();n=n+"&seg"+i+"="+r.seg+"&ts"+i+"="+r.ts+"&d"+i+"="+r.d,i++}return e+=n,this.addLongPollTag_(e,this.currentSerial),!0}return!1},t.prototype.enqueueSegment=function(t,e,n){this.pendingSegs.push({seg:t,ts:e,d:n}),this.alive&&this.newRequest_()},t.prototype.addLongPollTag_=function(t,e){var n=this;this.outstandingRequests.add(e,1);var i=function(){n.outstandingRequests.remove(e),n.newRequest_()},r=setTimeout(i,Math.floor(25e3));this.addTag(t,function(){clearTimeout(r),i()})},t.prototype.addTag=function(t,e){var n=this;g.isNodeSdk()?this.doNodeLongPoll(t,e):setTimeout(function(){try{if(!n.sendNewPolls)return;var i=n.myIFrame.doc.createElement("script");i.type="text/javascript",i.async=!0,i.src=t,i.onload=i.onreadystatechange=function(){var t=i.readyState;t&&"loaded"!==t&&"complete"!==t||(i.onload=i.onreadystatechange=null,i.parentNode&&i.parentNode.removeChild(i),e())},i.onerror=function(){R("Long-poll script failed to load: "+t),n.sendNewPolls=!1,n.close()},n.myIFrame.doc.body.appendChild(i)}catch(t){}},Math.floor(1))},t}(),Ke=null;"undefined"!=typeof MozWebSocket?Ke=MozWebSocket:"undefined"!=typeof WebSocket&&(Ke=WebSocket);var Qe=function(){function t(e,n,i,r){this.connId=e,this.keepaliveTimer=null,this.frames=null,this.totalFrames=0,this.bytesSent=0,this.bytesReceived=0,this.log_=O(this.connId),this.stats_=Re.getCollection(n),this.connURL=t.connectionURL_(n,i,r)}return t.connectionURL_=function(t,e,n){var i={v:"5"};return!g.isNodeSdk()&&"undefined"!=typeof location&&location.href&&-1!==location.href.indexOf("firebaseio.com")&&(i.r="f"),e&&(i.s=e),n&&(i.ls=n),t.connectionURL("websocket",i)},t.prototype.open=function(t,e){var n=this;this.onDisconnect=e,this.onMessage=t,this.log_("Websocket connecting to "+this.connURL),this.everConnected_=!1,T.set("previous_websocket_failure",!0);try{if(g.isNodeSdk()){var r=g.CONSTANTS.NODE_ADMIN?"AdminNode":"Node",o={headers:{"User-Agent":"Firebase/5/"+_.SDK_VERSION+"/"+i.platform+"/"+r}},s=i.env,a=0==this.connURL.indexOf("wss://")?s.HTTPS_PROXY||s.https_proxy:s.HTTP_PROXY||s.http_proxy;a&&(o.proxy={origin:a}),this.mySock=new Ke(this.connURL,[],o)}else this.mySock=new Ke(this.connURL)}catch(t){this.log_("Error instantiating WebSocket.");var u=t.message||t.data;return u&&this.log_(u),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_()}},t.prototype.start=function(){},t.forceDisallow=function(){t.forceDisallow_=!0},t.isAvailable=function(){var e=!1;if("undefined"!=typeof navigator&&navigator.userAgent){var n=navigator.userAgent.match(/Android ([0-9]{0,}\.[0-9]{0,})/);n&&n.length>1&&parseFloat(n[1])<4.4&&(e=!0)}return!e&&null!==Ke&&!t.forceDisallow_},t.previouslyFailed=function(){return T.isInMemoryStorage||!0===T.get("previous_websocket_failure")},t.prototype.markConnectionHealthy=function(){T.remove("previous_websocket_failure")},t.prototype.appendFrame_=function(t){if(this.frames.push(t),this.frames.length==this.totalFrames){var e=this.frames.join("");this.frames=null;var n=g.jsonEval(e);this.onMessage(n)}},t.prototype.handleNewFrameCount_=function(t){this.totalFrames=t,this.frames=[]},t.prototype.extractFrameCount_=function(t){if(g.assert(null===this.frames,"We already have a frame buffer"),t.length<=6){var e=Number(t);if(!isNaN(e))return this.handleNewFrameCount_(e),null}return this.handleNewFrameCount_(1),t},t.prototype.handleIncomingFrame=function(t){if(null!==this.mySock){var e=t.data;if(this.bytesReceived+=e.length,this.stats_.incrementCounter("bytes_received",e.length),this.resetKeepAlive(),null!==this.frames)this.appendFrame_(e);else{var n=this.extractFrameCount_(e);null!==n&&this.appendFrame_(n)}}},t.prototype.send=function(t){this.resetKeepAlive();var e=g.stringify(t);this.bytesSent+=e.length,this.stats_.incrementCounter("bytes_sent",e.length);var n=q(e,16384);n.length>1&&this.sendString_(String(n.length));for(var i=0;i<n.length;i++)this.sendString_(n[i])},t.prototype.shutdown_=function(){this.isClosed_=!0,this.keepaliveTimer&&(clearInterval(this.keepaliveTimer),this.keepaliveTimer=null),this.mySock&&(this.mySock.close(),this.mySock=null)},t.prototype.onClosed_=function(){this.isClosed_||(this.log_("WebSocket is closing itself"),this.shutdown_(),this.onDisconnect&&(this.onDisconnect(this.everConnected_),this.onDisconnect=null))},t.prototype.close=function(){this.isClosed_||(this.log_("WebSocket is being closed"),this.shutdown_())},t.prototype.resetKeepAlive=function(){var t=this;clearInterval(this.keepaliveTimer),this.keepaliveTimer=setInterval(function(){t.mySock&&t.sendString_("0"),t.resetKeepAlive()},Math.floor(45e3))},t.prototype.sendString_=function(t){try{this.mySock.send(t)}catch(t){this.log_("Exception thrown from WebSocket.send():",t.message||t.data,"Closing connection."),setTimeout(this.onClosed_.bind(this),0)}},t.responsesRequiredToBeHealthy=2,t.healthyTimeout=3e4,t}(),Ye=function(){function t(t){this.initTransports_(t)}return Object.defineProperty(t,"ALL_TRANSPORTS",{get:function(){return[He,Qe]},enumerable:!0,configurable:!0}),t.prototype.initTransports_=function(e){var n=Qe&&Qe.isAvailable(),i=n&&!Qe.previouslyFailed();if(e.webSocketOnly&&(n||L("wss:// URL used, but browser isn't known to support websockets.  Trying anyway."),i=!0),i)this.transports_=[Qe];else{var r=this.transports_=[];H(t.ALL_TRANSPORTS,function(t,e){e&&e.isAvailable()&&r.push(e)})}},t.prototype.initialTransport=function(){if(this.transports_.length>0)return this.transports_[0];throw new Error("No transports available")},t.prototype.upgradeTransport=function(){return this.transports_.length>1?this.transports_[1]:null},t}(),Ge=function(){function t(t,e,n,i,r,o,s){this.id=t,this.repoInfo_=e,this.onMessage_=n,this.onReady_=i,this.onDisconnect_=r,this.onKill_=o,this.lastSessionId=s,this.connectionCount=0,this.pendingDataMessages=[],this.state_=0,this.log_=O("c:"+this.id+":"),this.transportManager_=new Ye(e),this.log_("Connection created"),this.start_()}return t.prototype.start_=function(){var t=this,e=this.transportManager_.initialTransport();this.conn_=new e(this.nextTransportId_(),this.repoInfo_,void 0,this.lastSessionId),this.primaryResponsesRequired_=e.responsesRequiredToBeHealthy||0;var n=this.connReceiver_(this.conn_),i=this.disconnReceiver_(this.conn_);this.tx_=this.conn_,this.rx_=this.conn_,this.secondaryConn_=null,this.isHealthy_=!1,setTimeout(function(){t.conn_&&t.conn_.open(n,i)},Math.floor(0));var r=e.healthyTimeout||0;r>0&&(this.healthyTimeout_=X(function(){t.healthyTimeout_=null,t.isHealthy_||(t.conn_&&t.conn_.bytesReceived>102400?(t.log_("Connection exceeded healthy timeout but has received "+t.conn_.bytesReceived+" bytes.  Marking connection healthy."),t.isHealthy_=!0,t.conn_.markConnectionHealthy()):t.conn_&&t.conn_.bytesSent>10240?t.log_("Connection exceeded healthy timeout but has sent "+t.conn_.bytesSent+" bytes.  Leaving connection alive."):(t.log_("Closing unhealthy connection after timeout."),t.close()))},Math.floor(r)))},t.prototype.nextTransportId_=function(){return"c:"+this.id+":"+this.connectionCount++},t.prototype.disconnReceiver_=function(t){var e=this;return function(n){t===e.conn_?e.onConnectionLost_(n):t===e.secondaryConn_?(e.log_("Secondary connection lost."),e.onSecondaryConnectionLost_()):e.log_("closing an old connection")}},t.prototype.connReceiver_=function(t){var e=this;return function(n){2!=e.state_&&(t===e.rx_?e.onPrimaryMessageReceived_(n):t===e.secondaryConn_?e.onSecondaryMessageReceived_(n):e.log_("message on old connection"))}},t.prototype.sendRequest=function(t){var e={t:"d",d:t};this.sendData_(e)},t.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)},t.prototype.onSecondaryControl_=function(t){if("t"in t){var e=t.t;"a"===e?this.upgradeIfSecondaryHealthy_():"r"===e?(this.log_("Got a reset on secondary, closing it"),this.secondaryConn_.close(),this.tx_!==this.secondaryConn_&&this.rx_!==this.secondaryConn_||this.close()):"o"===e&&(this.log_("got pong on secondary."),this.secondaryResponsesRequired_--,this.upgradeIfSecondaryHealthy_())}},t.prototype.onSecondaryMessageReceived_=function(t){var e=$("t",t),n=$("d",t);if("c"==e)this.onSecondaryControl_(n);else{if("d"!=e)throw new Error("Unknown protocol layer: "+e);this.pendingDataMessages.push(n)}},t.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:{}}}))},t.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()},t.prototype.onPrimaryMessageReceived_=function(t){var e=$("t",t),n=$("d",t);"c"==e?this.onControl_(n):"d"==e&&this.onDataMessage_(n)},t.prototype.onDataMessage_=function(t){this.onPrimaryResponse_(),this.onMessage_(t)},t.prototype.onPrimaryResponse_=function(){this.isHealthy_||(this.primaryResponsesRequired_--,this.primaryResponsesRequired_<=0&&(this.log_("Primary connection is healthy."),this.isHealthy_=!0,this.conn_.markConnectionHealthy()))},t.prototype.onControl_=function(t){var e=$("t",t);if("d"in t){var n=t.d;if("h"===e)this.onHandshake_(n);else if("n"===e){this.log_("recvd end transmission on primary"),this.rx_=this.secondaryConn_;for(var i=0;i<this.pendingDataMessages.length;++i)this.onDataMessage_(this.pendingDataMessages[i]);this.pendingDataMessages=[],this.tryCleanupConnection()}else"s"===e?this.onConnectionShutdown_(n):"r"===e?this.onReset_(n):"e"===e?x("Server Error: "+n):"o"===e?(this.log_("got pong on primary."),this.onPrimaryResponse_(),this.sendPingOnPrimaryIfNecessary_()):x("Unknown control packet command: "+e)}},t.prototype.onHandshake_=function(t){var e=t.ts,n=t.v,i=t.h;this.sessionId=t.s,this.repoInfo_.updateHost(i),0==this.state_&&(this.conn_.start(),this.onConnectionEstablished_(this.conn_,e),"5"!==n&&L("Protocol version mismatch detected"),this.tryStartUpgrade_())},t.prototype.tryStartUpgrade_=function(){var t=this.transportManager_.upgradeTransport();t&&this.startUpgrade_(t)},t.prototype.startUpgrade_=function(t){var e=this;this.secondaryConn_=new t(this.nextTransportId_(),this.repoInfo_,this.sessionId),this.secondaryResponsesRequired_=t.responsesRequiredToBeHealthy||0;var n=this.connReceiver_(this.secondaryConn_),i=this.disconnReceiver_(this.secondaryConn_);this.secondaryConn_.open(n,i),X(function(){e.secondaryConn_&&(e.log_("Timed out trying to upgrade."),e.secondaryConn_.close())},Math.floor(6e4))},t.prototype.onReset_=function(t){this.log_("Reset packet received.  New host: "+t),this.repoInfo_.updateHost(t),1===this.state_?this.close():(this.closeConnections_(),this.start_())},t.prototype.onConnectionEstablished_=function(t,e){var n=this;this.log_("Realtime connection established."),this.conn_=t,this.state_=1,this.onReady_&&(this.onReady_(e,this.sessionId),this.onReady_=null),0===this.primaryResponsesRequired_?(this.log_("Primary connection is healthy."),this.isHealthy_=!0):X(function(){n.sendPingOnPrimaryIfNecessary_()},Math.floor(5e3))},t.prototype.sendPingOnPrimaryIfNecessary_=function(){this.isHealthy_||1!==this.state_||(this.log_("sending ping on primary."),this.sendData_({t:"c",d:{t:"p",d:{}}}))},t.prototype.onSecondaryConnectionLost_=function(){var t=this.secondaryConn_;this.secondaryConn_=null,this.tx_!==t&&this.rx_!==t||this.close()},t.prototype.onConnectionLost_=function(t){this.conn_=null,t||0!==this.state_?1===this.state_&&this.log_("Realtime connection lost."):(this.log_("Realtime connection failed."),this.repoInfo_.isCacheableHost()&&(T.remove("host:"+this.repoInfo_.host),this.repoInfo_.internalHost=this.repoInfo_.host)),this.close()},t.prototype.onConnectionShutdown_=function(t){this.log_("Connection shutdown command received. Shutting down..."),this.onKill_&&(this.onKill_(t),this.onKill_=null),this.onDisconnect_=null,this.close()},t.prototype.sendData_=function(t){if(1!==this.state_)throw"Connection is not connected";this.tx_.send(t)},t.prototype.close=function(){2!==this.state_&&(this.log_("Closing realtime connection."),this.state_=2,this.closeConnections_(),this.onDisconnect_&&(this.onDisconnect_(),this.onDisconnect_=null))},t.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)},t}(),Xe=function(){function t(){}return t.prototype.put=function(t,e,n,i){},t.prototype.merge=function(t,e,n,i){},t.prototype.refreshAuthToken=function(t){},t.prototype.onDisconnectPut=function(t,e,n){},t.prototype.onDisconnectMerge=function(t,e,n){},t.prototype.onDisconnectCancel=function(t,e){},t.prototype.reportStats=function(t){},t}(),Je=1e3,Ze=3e5,tn=function(t){function e(n,i,r,o,s,a){var u=t.call(this)||this;if(u.repoInfo_=n,u.onDataUpdate_=i,u.onConnectStatus_=r,u.onServerInfoUpdate_=o,u.authTokenProvider_=s,u.authOverride_=a,u.id=e.nextPersistentConnectionId_++,u.log_=O("p:"+u.id+":"),u.interruptReasons_={},u.listens_={},u.outstandingPuts_=[],u.outstandingPutCount_=0,u.onDisconnectRequestQueue_=[],u.connected_=!1,u.reconnectDelay_=Je,u.maxReconnectDelay_=Ze,u.securityDebugCallback_=null,u.lastSessionId=null,u.establishConnectionTimer_=null,u.visible_=!1,u.requestCBHash_={},u.requestNumber_=0,u.realtime_=null,u.authToken_=null,u.forceTokenRefresh_=!1,u.invalidAuthTokenCount_=0,u.firstConnection_=!0,u.lastConnectionAttemptTime_=null,u.lastConnectionEstablishedTime_=null,a&&!g.isNodeSdk())throw new Error("Auth override specified in options, but not supported on non Node.js platforms");return u.scheduleConnect_(0),We.getInstance().on("visible",u.onVisible_,u),-1===n.host.indexOf("fblocal")&&Be.getInstance().on("online",u.onOnline_,u),u}return m.__extends(e,t),e.prototype.sendRequest=function(t,e,n){var i=++this.requestNumber_,r={r:i,a:t,b:e};this.log_(g.stringify(r)),g.assert(this.connected_,"sendRequest call when we're not connected not allowed."),this.realtime_.sendRequest(r),n&&(this.requestCBHash_[i]=n)},e.prototype.listen=function(t,e,n,i){var r=t.queryIdentifier(),o=t.path.toString();this.log_("Listen called for "+o+" "+r),this.listens_[o]=this.listens_[o]||{},g.assert(t.getQueryParams().isDefault()||!t.getQueryParams().loadsAllData(),"listen() called for non-default but complete query"),g.assert(!this.listens_[o][r],"listen() called twice for same path/queryId.");var s={onComplete:i,hashFn:e,query:t,tag:n};this.listens_[o][r]=s,this.connected_&&this.sendListen_(s)},e.prototype.sendListen_=function(t){var n=this,i=t.query,r=i.path.toString(),o=i.queryIdentifier();this.log_("Listen on "+r+" for "+o);var s={p:r};t.tag&&(s.q=i.queryObject(),s.t=t.tag),s.h=t.hashFn(),this.sendRequest("q",s,function(s){var a=s.d,u=s.s;e.warnOnListenWarnings_(a,i),(n.listens_[r]&&n.listens_[r][o])===t&&(n.log_("listen response",s),"ok"!==u&&n.removeListen_(r,o),t.onComplete&&t.onComplete(u,a))})},e.warnOnListenWarnings_=function(t,e){if(t&&"object"==typeof t&&g.contains(t,"w")){var n=g.safeGet(t,"w");if(Array.isArray(n)&&~n.indexOf("no_index")){var i='".indexOn": "'+e.getQueryParams().getIndex().toString()+'"',r=e.path.toString();L("Using an unspecified index. Your data will be downloaded and filtered on the client. Consider adding "+i+" at "+r+" to your security rules for better performance.")}}},e.prototype.refreshAuthToken=function(t){this.authToken_=t,this.log_("Auth token refreshed"),this.authToken_?this.tryAuth():this.connected_&&this.sendRequest("unauth",{},function(){}),this.reduceReconnectDelayIfAdminCredential_(t)},e.prototype.reduceReconnectDelayIfAdminCredential_=function(t){(t&&40===t.length||g.isAdmin(t))&&(this.log_("Admin auth credential detected.  Reducing max reconnect time."),this.maxReconnectDelay_=3e4)},e.prototype.tryAuth=function(){var t=this;if(this.connected_&&this.authToken_){var e=this.authToken_,n=g.isValidFormat(e)?"auth":"gauth",i={cred:e};null===this.authOverride_?i.noauth=!0:"object"==typeof this.authOverride_&&(i.authvar=this.authOverride_),this.sendRequest(n,i,function(n){var i=n.s,r=n.d||"error";t.authToken_===e&&("ok"===i?t.invalidAuthTokenCount_=0:t.onAuthRevoked_(i,r))})}},e.prototype.unlisten=function(t,e){var n=t.path.toString(),i=t.queryIdentifier();this.log_("Unlisten called for "+n+" "+i),g.assert(t.getQueryParams().isDefault()||!t.getQueryParams().loadsAllData(),"unlisten() called for non-default but complete query"),this.removeListen_(n,i)&&this.connected_&&this.sendUnlisten_(n,i,t.queryObject(),e)},e.prototype.sendUnlisten_=function(t,e,n,i){this.log_("Unlisten on "+t+" for "+e);var r={p:t};i&&(r.q=n,r.t=i),this.sendRequest("n",r)},e.prototype.onDisconnectPut=function(t,e,n){this.connected_?this.sendOnDisconnect_("o",t,e,n):this.onDisconnectRequestQueue_.push({pathString:t,action:"o",data:e,onComplete:n})},e.prototype.onDisconnectMerge=function(t,e,n){this.connected_?this.sendOnDisconnect_("om",t,e,n):this.onDisconnectRequestQueue_.push({pathString:t,action:"om",data:e,onComplete:n})},e.prototype.onDisconnectCancel=function(t,e){this.connected_?this.sendOnDisconnect_("oc",t,null,e):this.onDisconnectRequestQueue_.push({pathString:t,action:"oc",data:null,onComplete:e})},e.prototype.sendOnDisconnect_=function(t,e,n,i){var r={p:e,d:n};this.log_("onDisconnect "+t,r),this.sendRequest(t,r,function(t){i&&setTimeout(function(){i(t.s,t.d)},Math.floor(0))})},e.prototype.put=function(t,e,n,i){this.putInternal("p",t,e,n,i)},e.prototype.merge=function(t,e,n,i){this.putInternal("m",t,e,n,i)},e.prototype.putInternal=function(t,e,n,i,r){var o={p:e,d:n};void 0!==r&&(o.h=r),this.outstandingPuts_.push({action:t,request:o,onComplete:i}),this.outstandingPutCount_++;var s=this.outstandingPuts_.length-1;this.connected_?this.sendPut_(s):this.log_("Buffering put: "+e)},e.prototype.sendPut_=function(t){var e=this,n=this.outstandingPuts_[t].action,i=this.outstandingPuts_[t].request,r=this.outstandingPuts_[t].onComplete;this.outstandingPuts_[t].queued=this.connected_,this.sendRequest(n,i,function(i){e.log_(n+" response",i),delete e.outstandingPuts_[t],e.outstandingPutCount_--,0===e.outstandingPutCount_&&(e.outstandingPuts_=[]),r&&r(i.s,i.d)})},e.prototype.reportStats=function(t){var e=this;if(this.connected_){var n={c:t};this.log_("reportStats",n),this.sendRequest("s",n,function(t){if("ok"!==t.s){var n=t.d;e.log_("reportStats","Error sending stats: "+n)}})}},e.prototype.onDataMessage_=function(t){if("r"in t){this.log_("from server: "+g.stringify(t));var e=t.r,n=this.requestCBHash_[e];n&&(delete this.requestCBHash_[e],n(t.b))}else{if("error"in t)throw"A server-side error has occurred: "+t.error;"a"in t&&this.onDataPush_(t.a,t.b)}},e.prototype.onDataPush_=function(t,e){this.log_("handleServerMessage",t,e),"d"===t?this.onDataUpdate_(e.p,e.d,!1,e.t):"m"===t?this.onDataUpdate_(e.p,e.d,!0,e.t):"c"===t?this.onListenRevoked_(e.p,e.q):"ac"===t?this.onAuthRevoked_(e.s,e.d):"sd"===t?this.onSecurityDebugPacket_(e):x("Unrecognized action received from server: "+g.stringify(t)+"\nAre you using the latest client?")},e.prototype.onReady_=function(t,e){this.log_("connection ready"),this.connected_=!0,this.lastConnectionEstablishedTime_=(new Date).getTime(),this.handleTimestamp_(t),this.lastSessionId=e,this.firstConnection_&&this.sendConnectStats_(),this.restoreState_(),this.firstConnection_=!1,this.onConnectStatus_(!0)},e.prototype.scheduleConnect_=function(t){var e=this;g.assert(!this.realtime_,"Scheduling a connect when we're already connected/ing?"),this.establishConnectionTimer_&&clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=setTimeout(function(){e.establishConnectionTimer_=null,e.establishConnection_()},Math.floor(t))},e.prototype.onVisible_=function(t){t&&!this.visible_&&this.reconnectDelay_===this.maxReconnectDelay_&&(this.log_("Window became visible.  Reducing delay."),this.reconnectDelay_=Je,this.realtime_||this.scheduleConnect_(0)),this.visible_=t},e.prototype.onOnline_=function(t){t?(this.log_("Browser went online."),this.reconnectDelay_=Je,this.realtime_||this.scheduleConnect_(0)):(this.log_("Browser went offline.  Killing connection."),this.realtime_&&this.realtime_.close())},e.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_=Je),this.lastConnectionEstablishedTime_=null):(this.log_("Window isn't visible.  Delaying reconnect."),this.reconnectDelay_=this.maxReconnectDelay_,this.lastConnectionAttemptTime_=(new Date).getTime());var t=(new Date).getTime()-this.lastConnectionAttemptTime_,e=Math.max(0,this.reconnectDelay_-t);e=Math.random()*e,this.log_("Trying to reconnect in "+e+"ms"),this.scheduleConnect_(e),this.reconnectDelay_=Math.min(this.maxReconnectDelay_,1.3*this.reconnectDelay_)}this.onConnectStatus_(!1)},e.prototype.establishConnection_=function(){if(this.shouldReconnect_()){this.log_("Making a connection attempt"),this.lastConnectionAttemptTime_=(new Date).getTime(),this.lastConnectionEstablishedTime_=null;var t=this.onDataMessage_.bind(this),n=this.onReady_.bind(this),i=this.onRealtimeDisconnect_.bind(this),r=this.id+":"+e.nextConnectionId_++,o=this,s=this.lastSessionId,a=!1,u=null,c=function(){u?u.close():(a=!0,i())};this.realtime_={close:c,sendRequest:function(t){g.assert(u,"sendRequest call when we're not connected not allowed."),u.sendRequest(t)}};var h=this.forceTokenRefresh_;this.forceTokenRefresh_=!1,this.authTokenProvider_.getToken(h).then(function(e){a?R("getToken() completed but was canceled"):(R("getToken() completed. Creating connection."),o.authToken_=e&&e.accessToken,u=new Ge(r,o.repoInfo_,t,n,i,function(t){L(t+" ("+o.repoInfo_.toString()+")"),o.interrupt("server_kill")},s))}).then(null,function(t){o.log_("Failed to get token: "+t),a||(g.CONSTANTS.NODE_ADMIN&&L(t),c())})}},e.prototype.interrupt=function(t){R("Interrupting connection for reason: "+t),this.interruptReasons_[t]=!0,this.realtime_?this.realtime_.close():(this.establishConnectionTimer_&&(clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=null),this.connected_&&this.onRealtimeDisconnect_())},e.prototype.resume=function(t){R("Resuming connection for reason: "+t),delete this.interruptReasons_[t],g.isEmpty(this.interruptReasons_)&&(this.reconnectDelay_=Je,this.realtime_||this.scheduleConnect_(0))},e.prototype.handleTimestamp_=function(t){var e=t-(new Date).getTime();this.onServerInfoUpdate_({serverTimeOffset:e})},e.prototype.cancelSentTransactions_=function(){for(var t=0;t<this.outstandingPuts_.length;t++){var e=this.outstandingPuts_[t];e&&"h"in e.request&&e.queued&&(e.onComplete&&e.onComplete("disconnect"),delete this.outstandingPuts_[t],this.outstandingPutCount_--)}0===this.outstandingPutCount_&&(this.outstandingPuts_=[])},e.prototype.onListenRevoked_=function(t,e){var n;n=e?e.map(function(t){return V(t)}).join("$"):"default";var i=this.removeListen_(t,n);i&&i.onComplete&&i.onComplete("permission_denied")},e.prototype.removeListen_=function(t,e){var n,i=new J(t).toString();return void 0!==this.listens_[i]?(n=this.listens_[i][e],delete this.listens_[i][e],0===g.getCount(this.listens_[i])&&delete this.listens_[i]):n=void 0,n},e.prototype.onAuthRevoked_=function(t,e){R("Auth token revoked: "+t+"/"+e),this.authToken_=null,this.forceTokenRefresh_=!0,this.realtime_.close(),"invalid_token"!==t&&"permission_denied"!==t||(this.invalidAuthTokenCount_++,this.invalidAuthTokenCount_>=3&&(this.reconnectDelay_=3e4,this.authTokenProvider_.notifyForInvalidToken()))},e.prototype.onSecurityDebugPacket_=function(t){this.securityDebugCallback_?this.securityDebugCallback_(t):"msg"in t&&console.log("FIREBASE: "+t.msg.replace("\n","\nFIREBASE: "))},e.prototype.restoreState_=function(){var t=this;this.tryAuth(),g.forEach(this.listens_,function(e,n){g.forEach(n,function(e,n){t.sendListen_(n)})});for(var e=0;e<this.outstandingPuts_.length;e++)this.outstandingPuts_[e]&&this.sendPut_(e);for(;this.onDisconnectRequestQueue_.length;){var n=this.onDisconnectRequestQueue_.shift();this.sendOnDisconnect_(n.action,n.pathString,n.data,n.onComplete)}},e.prototype.sendConnectStats_=function(){var t={},e="js";g.CONSTANTS.NODE_ADMIN?e="admin_node":g.CONSTANTS.NODE_CLIENT&&(e="node"),t["sdk."+e+"."+_.SDK_VERSION.replace(/\./g,"-")]=1,g.isMobileCordova()?t["framework.cordova"]=1:g.isReactNative()&&(t["framework.reactnative"]=1),this.reportStats(t)},e.prototype.shouldReconnect_=function(){var t=Be.getInstance().currentlyOnline();return g.isEmpty(this.interruptReasons_)&&t},e.nextPersistentConnectionId_=0,e.nextConnectionId_=0,e}(Xe),en=function(t){function e(e,n,i){var r=t.call(this)||this;return r.repoInfo_=e,r.onDataUpdate_=n,r.authTokenProvider_=i,r.log_=O("p:rest:"),r.listens_={},r}return m.__extends(e,t),e.prototype.reportStats=function(t){throw new Error("Method not implemented.")},e.getListenId_=function(t,e){return void 0!==e?"tag$"+e:(g.assert(t.getQueryParams().isDefault(),"should have a tag if it's not a default query."),t.path.toString())},e.prototype.listen=function(t,n,i,r){var o=this,s=t.path.toString();this.log_("Listen called for "+s+" "+t.queryIdentifier());var a=e.getListenId_(t,i),u={};this.listens_[a]=u;var c=t.getQueryParams().toRestQueryStringParameters();this.restRequest_(s+".json",c,function(t,e){var n=e;404===t&&(n=null,t=null),null===t&&o.onDataUpdate_(s,n,!1,i),g.safeGet(o.listens_,a)===u&&r(t?401==t?"permission_denied":"rest_error:"+t:"ok",null)})},e.prototype.unlisten=function(t,n){var i=e.getListenId_(t,n);delete this.listens_[i]},e.prototype.refreshAuthToken=function(t){},e.prototype.restRequest_=function(t,e,n){var i=this;void 0===e&&(e={}),e.format="export",this.authTokenProvider_.getToken(!1).then(function(r){var o=r&&r.accessToken;o&&(e.auth=o);var s=(i.repoInfo_.secure?"https://":"http://")+i.repoInfo_.host+t+"?"+g.querystring(e);i.log_("Sending REST request for "+s);var a=new XMLHttpRequest;a.onreadystatechange=function(){if(n&&4===a.readyState){i.log_("REST Response for "+s+" received. status:",a.status,"response:",a.responseText);var t=null;if(a.status>=200&&a.status<300){try{t=g.jsonEval(a.responseText)}catch(t){L("Failed to parse JSON response for "+s+": "+a.responseText)}n(null,t)}else 401!==a.status&&404!==a.status&&L("Got unsuccessful REST response for "+s+" Status: "+a.status),n(a.status);n=null}},a.open("GET",s,!0),a.send()})},e}(Xe),nn=function(){function t(t,e,n){var i=this;this.repoInfo_=t,this.app=n,this.dataUpdateCount=0,this.statsListener_=null,this.eventQueue_=new Fe,this.nextWriteId_=1,this.interceptServerDataCallback_=null,this.onDisconnect_=new ee,this.persistentConnection_=null;var r=new Ne(n);if(this.stats_=Re.getCollection(t),e||G())this.server_=new en(this.repoInfo_,this.onDataUpdate_.bind(this),r),setTimeout(this.onConnectStatus_.bind(this,!0),0);else{var o=n.options.databaseAuthVariableOverride;if(void 0!==o&&null!==o){if("object"!=typeof o)throw new Error("Only objects are supported for option databaseAuthVariableOverride");try{g.stringify(o)}catch(t){throw new Error("Invalid authOverride provided: "+t)}}this.persistentConnection_=new tn(this.repoInfo_,this.onDataUpdate_.bind(this),this.onConnectStatus_.bind(this),this.onServerInfoUpdate_.bind(this),r,o),this.server_=this.persistentConnection_}r.addTokenChangeListener(function(t){i.server_.refreshAuthToken(t)}),this.statsReporter_=Re.getOrCreateReporter(t,function(){return new Le(i.stats_,i.server_)}),this.transactions_init_(),this.infoData_=new Pe,this.infoSyncTree_=new Ae({startListening:function(t,e,n,r){var o=[],s=i.infoData_.getNode(t.path);return s.isEmpty()||(o=i.infoSyncTree_.applyServerOverwrite(t.path,s),setTimeout(function(){r("ok")},0)),o},stopListening:function(){}}),this.updateInfo_("connected",!1),this.serverSyncTree_=new Ae({startListening:function(t,e,n,r){return i.server_.listen(t,n,e,function(e,n){var o=r(e,n);i.eventQueue_.raiseEventsForChangedPath(t.path,o)}),[]},stopListening:function(t,e){i.server_.unlisten(t,e)}})}return t.prototype.toString=function(){return(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host},t.prototype.name=function(){return this.repoInfo_.namespace},t.prototype.serverTime=function(){var t=this.infoData_.getNode(new J(".info/serverTimeOffset")).val()||0;return(new Date).getTime()+t},t.prototype.generateServerValues=function(){return(t=(t={timestamp:this.serverTime()})||{}).timestamp=t.timestamp||(new Date).getTime(),t;var t},t.prototype.onDataUpdate_=function(t,e,n,i){this.dataUpdateCount++;var r=new J(t);e=this.interceptServerDataCallback_?this.interceptServerDataCallback_(t,e):e;var o=[];if(i)if(n){var s=g.map(e,function(t){return Vt(t)});o=this.serverSyncTree_.applyTaggedQueryMerge(r,s,i)}else{var a=Vt(e);o=this.serverSyncTree_.applyTaggedQueryOverwrite(r,a,i)}else if(n){var u=g.map(e,function(t){return Vt(t)});o=this.serverSyncTree_.applyServerMerge(r,u)}else{var c=Vt(e);o=this.serverSyncTree_.applyServerOverwrite(r,c)}var h=r;o.length>0&&(h=this.rerunTransactions_(r)),this.eventQueue_.raiseEventsForChangedPath(h,o)},t.prototype.interceptServerData_=function(t){this.interceptServerDataCallback_=t},t.prototype.onConnectStatus_=function(t){this.updateInfo_("connected",t),!1===t&&this.runOnDisconnectEvents_()},t.prototype.onServerInfoUpdate_=function(t){var e=this;H(t,function(t,n){e.updateInfo_(n,t)})},t.prototype.updateInfo_=function(t,e){var n=new J("/.info/"+t),i=Vt(e);this.infoData_.updateSnapshot(n,i);var r=this.infoSyncTree_.applyServerOverwrite(n,i);this.eventQueue_.raiseEventsForChangedPath(n,r)},t.prototype.getNextWriteId_=function(){return this.nextWriteId_++},t.prototype.setWithPriority=function(t,e,n,i){var r=this;this.log_("set",{path:t.toString(),value:e,priority:n});var o=this.generateServerValues(),s=Vt(e,n),a=ie(s,o),u=this.getNextWriteId_(),c=this.serverSyncTree_.applyUserOverwrite(t,a,u,!0);this.eventQueue_.queueEvents(c),this.server_.put(t.toString(),s.val(!0),function(e,n){var o="ok"===e;o||L("set at "+t+" failed: "+e);var s=r.serverSyncTree_.ackUserWrite(u,!o);r.eventQueue_.raiseEventsForChangedPath(t,s),r.callOnCompleteCallback(i,e,n)});var h=this.abortTransactions_(t);this.rerunTransactions_(h),this.eventQueue_.raiseEventsForChangedPath(h,[])},t.prototype.update=function(t,e,n){var i=this;this.log_("update",{path:t.toString(),value:e});var r=!0,o=this.generateServerValues(),s={};if(g.forEach(e,function(t,e){r=!1;var n=Vt(e);s[t]=ie(n,o)}),r)R("update() called with empty data.  Don't do anything."),this.callOnCompleteCallback(n,"ok");else{var a=this.getNextWriteId_(),u=this.serverSyncTree_.applyUserMerge(t,s,a);this.eventQueue_.queueEvents(u),this.server_.merge(t.toString(),e,function(e,r){var o="ok"===e;o||L("update at "+t+" failed: "+e);var s=i.serverSyncTree_.ackUserWrite(a,!o),u=s.length>0?i.rerunTransactions_(t):t;i.eventQueue_.raiseEventsForChangedPath(u,s),i.callOnCompleteCallback(n,e,r)}),g.forEach(e,function(e){var n=i.abortTransactions_(t.child(e));i.rerunTransactions_(n)}),this.eventQueue_.raiseEventsForChangedPath(t,[])}},t.prototype.runOnDisconnectEvents_=function(){var t=this;this.log_("onDisconnectEvents");var e=this.generateServerValues(),n=[];(function(t,e){var n=new ee;return t.forEachTree(new J(""),function(t,i){n.remember(t,ie(i,e))}),n})(this.onDisconnect_,e).forEachTree(J.Empty,function(e,i){n=n.concat(t.serverSyncTree_.applyServerOverwrite(e,i));var r=t.abortTransactions_(e);t.rerunTransactions_(r)}),this.onDisconnect_=new ee,this.eventQueue_.raiseEventsForChangedPath(J.Empty,n)},t.prototype.onDisconnectCancel=function(t,e){var n=this;this.server_.onDisconnectCancel(t.toString(),function(i,r){"ok"===i&&n.onDisconnect_.forget(t),n.callOnCompleteCallback(e,i,r)})},t.prototype.onDisconnectSet=function(t,e,n){var i=this,r=Vt(e);this.server_.onDisconnectPut(t.toString(),r.val(!0),function(e,o){"ok"===e&&i.onDisconnect_.remember(t,r),i.callOnCompleteCallback(n,e,o)})},t.prototype.onDisconnectSetWithPriority=function(t,e,n,i){var r=this,o=Vt(e,n);this.server_.onDisconnectPut(t.toString(),o.val(!0),function(e,n){"ok"===e&&r.onDisconnect_.remember(t,o),r.callOnCompleteCallback(i,e,n)})},t.prototype.onDisconnectUpdate=function(t,e,n){var i=this;if(g.isEmpty(e))return R("onDisconnect().update() called with empty data.  Don't do anything."),void this.callOnCompleteCallback(n,"ok");this.server_.onDisconnectMerge(t.toString(),e,function(r,o){"ok"===r&&g.forEach(e,function(e,n){var r=Vt(n);i.onDisconnect_.remember(t.child(e),r)}),i.callOnCompleteCallback(n,r,o)})},t.prototype.addEventCallbackForQuery=function(t,e){var n;n=".info"===t.path.getFront()?this.infoSyncTree_.addEventRegistration(t,e):this.serverSyncTree_.addEventRegistration(t,e),this.eventQueue_.raiseEventsAtPath(t.path,n)},t.prototype.removeEventCallbackForQuery=function(t,e){var n;n=".info"===t.path.getFront()?this.infoSyncTree_.removeEventRegistration(t,e):this.serverSyncTree_.removeEventRegistration(t,e),this.eventQueue_.raiseEventsAtPath(t.path,n)},t.prototype.interrupt=function(){this.persistentConnection_&&this.persistentConnection_.interrupt("repo_interrupt")},t.prototype.resume=function(){this.persistentConnection_&&this.persistentConnection_.resume("repo_interrupt")},t.prototype.stats=function(t){if(void 0===t&&(t=!1),"undefined"!=typeof console){var e;t?(this.statsListener_||(this.statsListener_=new Oe(this.stats_)),e=this.statsListener_.get()):e=this.stats_.get();var n=Object.keys(e).reduce(function(t,e){return Math.max(e.length,t)},0);g.forEach(e,function(t,e){for(var i=t.length;i<n+2;i++)t+=" ";console.log(t+e)})}},t.prototype.statsIncrementCounter=function(t){this.stats_.incrementCounter(t),this.statsReporter_.includeStat(t)},t.prototype.log_=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="";this.persistentConnection_&&(n=this.persistentConnection_.id+":"),R.apply(void 0,[n].concat(t))},t.prototype.callOnCompleteCallback=function(t,e,n){t&&Y(function(){if("ok"==e)t(null);else{var i=(e||"error").toUpperCase(),r=i;n&&(r+=": "+n);var o=new Error(r);o.code=i,t(o)}})},Object.defineProperty(t.prototype,"database",{get:function(){return this.__database||(this.__database=new fn(this))},enumerable:!0,configurable:!0}),t}(),rn=function(){function t(e){this.indexedFilter_=new ge(e.getIndex()),this.index_=e.getIndex(),this.startPost_=t.getStartPost_(e),this.endPost_=t.getEndPost_(e)}return t.prototype.getStartPost=function(){return this.startPost_},t.prototype.getEndPost=function(){return this.endPost_},t.prototype.matches=function(t){return this.index_.compare(this.getStartPost(),t)<=0&&this.index_.compare(t,this.getEndPost())<=0},t.prototype.updateChild=function(t,e,n,i,r,o){return this.matches(new wt(e,n))||(n=Wt.EMPTY_NODE),this.indexedFilter_.updateChild(t,e,n,i,r,o)},t.prototype.updateFullNode=function(t,e,n){e.isLeafNode()&&(e=Wt.EMPTY_NODE);var i=e.withIndex(this.index_);i=i.updatePriority(Wt.EMPTY_NODE);var r=this;return e.forEachChild(At,function(t,e){r.matches(new wt(t,e))||(i=i.updateImmediateChild(t,Wt.EMPTY_NODE))}),this.indexedFilter_.updateFullNode(t,i,n)},t.prototype.updatePriority=function(t,e){return t},t.prototype.filtersNodes=function(){return!0},t.prototype.getIndexedFilter=function(){return this.indexedFilter_},t.prototype.getIndex=function(){return this.index_},t.getStartPost_=function(t){if(t.hasStart()){var e=t.getIndexStartName();return t.getIndex().makePost(t.getIndexStartValue(),e)}return t.getIndex().minPost()},t.getEndPost_=function(t){if(t.hasEnd()){var e=t.getIndexEndName();return t.getIndex().makePost(t.getIndexEndValue(),e)}return t.getIndex().maxPost()},t}(),on=function(){function t(t){this.rangedFilter_=new rn(t),this.index_=t.getIndex(),this.limit_=t.getLimit(),this.reverse_=!t.isViewFromLeft()}return t.prototype.updateChild=function(t,e,n,i,r,o){return this.rangedFilter_.matches(new wt(e,n))||(n=Wt.EMPTY_NODE),t.getImmediateChild(e).equals(n)?t:t.numChildren()<this.limit_?this.rangedFilter_.getIndexedFilter().updateChild(t,e,n,i,r,o):this.fullLimitUpdateChild_(t,e,n,r,o)},t.prototype.updateFullNode=function(t,e,n){var i;if(e.isLeafNode()||e.isEmpty())i=Wt.EMPTY_NODE.withIndex(this.index_);else if(2*this.limit_<e.numChildren()&&e.isIndexed(this.index_)){i=Wt.EMPTY_NODE.withIndex(this.index_);var r=void 0;r=this.reverse_?e.getReverseIteratorFrom(this.rangedFilter_.getEndPost(),this.index_):e.getIteratorFrom(this.rangedFilter_.getStartPost(),this.index_);for(var o=0;r.hasNext()&&o<this.limit_;){var s=r.getNext();if(!(this.reverse_?this.index_.compare(this.rangedFilter_.getStartPost(),s)<=0:this.index_.compare(s,this.rangedFilter_.getEndPost())<=0))break;i=i.updateImmediateChild(s.name,s.node),o++}}else{i=(i=e.withIndex(this.index_)).updatePriority(Wt.EMPTY_NODE);var a=void 0,u=void 0,c=void 0;if(r=void 0,this.reverse_){r=i.getReverseIterator(this.index_),a=this.rangedFilter_.getEndPost(),u=this.rangedFilter_.getStartPost();var h=this.index_.getCompare();c=function(t,e){return h(e,t)}}else r=i.getIterator(this.index_),a=this.rangedFilter_.getStartPost(),u=this.rangedFilter_.getEndPost(),c=this.index_.getCompare();o=0;for(var l=!1;r.hasNext();)s=r.getNext(),!l&&c(a,s)<=0&&(l=!0),l&&o<this.limit_&&c(s,u)<=0?o++:i=i.updateImmediateChild(s.name,Wt.EMPTY_NODE)}return this.rangedFilter_.getIndexedFilter().updateFullNode(t,i,n)},t.prototype.updatePriority=function(t,e){return t},t.prototype.filtersNodes=function(){return!0},t.prototype.getIndexedFilter=function(){return this.rangedFilter_.getIndexedFilter()},t.prototype.getIndex=function(){return this.index_},t.prototype.fullLimitUpdateChild_=function(t,e,n,i,r){var o;if(this.reverse_){var s=this.index_.getCompare();o=function(t,e){return s(e,t)}}else o=this.index_.getCompare();var a=t;g.assert(a.numChildren()==this.limit_,"");var u=new wt(e,n),c=this.reverse_?a.getFirstChild(this.index_):a.getLastChild(this.index_),h=this.rangedFilter_.matches(u);if(a.hasChild(e)){for(var l=a.getImmediateChild(e),d=i.getChildAfterChild(this.index_,c,this.reverse_);null!=d&&(d.name==e||a.hasChild(d.name));)d=i.getChildAfterChild(this.index_,d,this.reverse_);var f=null==d?1:o(d,u);if(h&&!n.isEmpty()&&f>=0)return null!=r&&r.trackChildChange(ve.childChangedChange(e,n,l)),a.updateImmediateChild(e,n);null!=r&&r.trackChildChange(ve.childRemovedChange(e,l));var p=a.updateImmediateChild(e,Wt.EMPTY_NODE);return null!=d&&this.rangedFilter_.matches(d)?(null!=r&&r.trackChildChange(ve.childAddedChange(d.name,d.node)),p.updateImmediateChild(d.name,d.node)):p}return n.isEmpty()?t:h&&o(c,u)>=0?(null!=r&&(r.trackChildChange(ve.childRemovedChange(c.name,c.node)),r.trackChildChange(ve.childAddedChange(e,n))),a.updateImmediateChild(e,n).updateImmediateChild(c.name,Wt.EMPTY_NODE)):t},t}(),sn=function(){function t(){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_=At}return t.prototype.hasStart=function(){return this.startSet_},t.prototype.isViewFromLeft=function(){return""===this.viewFrom_?this.startSet_:this.viewFrom_===t.WIRE_PROTOCOL_CONSTANTS_.VIEW_FROM_LEFT},t.prototype.getIndexStartValue=function(){return g.assert(this.startSet_,"Only valid if start has been set"),this.indexStartValue_},t.prototype.getIndexStartName=function(){return g.assert(this.startSet_,"Only valid if start has been set"),this.startNameSet_?this.indexStartName_:U},t.prototype.hasEnd=function(){return this.endSet_},t.prototype.getIndexEndValue=function(){return g.assert(this.endSet_,"Only valid if end has been set"),this.indexEndValue_},t.prototype.getIndexEndName=function(){return g.assert(this.endSet_,"Only valid if end has been set"),this.endNameSet_?this.indexEndName_:j},t.prototype.hasLimit=function(){return this.limitSet_},t.prototype.hasAnchoredLimit=function(){return this.limitSet_&&""!==this.viewFrom_},t.prototype.getLimit=function(){return g.assert(this.limitSet_,"Only valid if limit has been set"),this.limit_},t.prototype.getIndex=function(){return this.index_},t.prototype.copy_=function(){var e=new t;return e.limitSet_=this.limitSet_,e.limit_=this.limit_,e.startSet_=this.startSet_,e.indexStartValue_=this.indexStartValue_,e.startNameSet_=this.startNameSet_,e.indexStartName_=this.indexStartName_,e.endSet_=this.endSet_,e.indexEndValue_=this.indexEndValue_,e.endNameSet_=this.endNameSet_,e.indexEndName_=this.indexEndName_,e.index_=this.index_,e.viewFrom_=this.viewFrom_,e},t.prototype.limit=function(t){var e=this.copy_();return e.limitSet_=!0,e.limit_=t,e.viewFrom_="",e},t.prototype.limitToFirst=function(e){var n=this.copy_();return n.limitSet_=!0,n.limit_=e,n.viewFrom_=t.WIRE_PROTOCOL_CONSTANTS_.VIEW_FROM_LEFT,n},t.prototype.limitToLast=function(e){var n=this.copy_();return n.limitSet_=!0,n.limit_=e,n.viewFrom_=t.WIRE_PROTOCOL_CONSTANTS_.VIEW_FROM_RIGHT,n},t.prototype.startAt=function(t,e){var n=this.copy_();return n.startSet_=!0,void 0===t&&(t=null),n.indexStartValue_=t,null!=e?(n.startNameSet_=!0,n.indexStartName_=e):(n.startNameSet_=!1,n.indexStartName_=""),n},t.prototype.endAt=function(t,e){var n=this.copy_();return n.endSet_=!0,void 0===t&&(t=null),n.indexEndValue_=t,void 0!==e?(n.endNameSet_=!0,n.indexEndName_=e):(n.endNameSet_=!1,n.indexEndName_=""),n},t.prototype.orderBy=function(t){var e=this.copy_();return e.index_=t,e},t.prototype.getQueryObject=function(){var e=t.WIRE_PROTOCOL_CONSTANTS_,n={};if(this.startSet_&&(n[e.INDEX_START_VALUE]=this.indexStartValue_,this.startNameSet_&&(n[e.INDEX_START_NAME]=this.indexStartName_)),this.endSet_&&(n[e.INDEX_END_VALUE]=this.indexEndValue_,this.endNameSet_&&(n[e.INDEX_END_NAME]=this.indexEndName_)),this.limitSet_){n[e.LIMIT]=this.limit_;var i=this.viewFrom_;""===i&&(i=this.isViewFromLeft()?e.VIEW_FROM_LEFT:e.VIEW_FROM_RIGHT),n[e.VIEW_FROM]=i}return this.index_!==At&&(n[e.INDEX]=this.index_.toString()),n},t.prototype.loadsAllData=function(){return!(this.startSet_||this.endSet_||this.limitSet_)},t.prototype.isDefault=function(){return this.loadsAllData()&&this.index_==At},t.prototype.getNodeFilter=function(){return this.loadsAllData()?new ge(this.getIndex()):this.hasLimit()?new on(this):new rn(this)},t.prototype.toRestQueryStringParameters=function(){var e,n=t.REST_QUERY_CONSTANTS_,i={};return this.isDefault()?i:(this.index_===At?e=n.PRIORITY_INDEX:this.index_===zt?e=n.VALUE_INDEX:this.index_===Et?e=n.KEY_INDEX:(g.assert(this.index_ instanceof Kt,"Unrecognized index type!"),e=this.index_.toString()),i[n.ORDER_BY]=g.stringify(e),this.startSet_&&(i[n.START_AT]=g.stringify(this.indexStartValue_),this.startNameSet_&&(i[n.START_AT]+=","+g.stringify(this.indexStartName_))),this.endSet_&&(i[n.END_AT]=g.stringify(this.indexEndValue_),this.endNameSet_&&(i[n.END_AT]+=","+g.stringify(this.indexEndName_))),this.limitSet_&&(this.isViewFromLeft()?i[n.LIMIT_TO_FIRST]=this.limit_:i[n.LIMIT_TO_LAST]=this.limit_),i)},t.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"},t.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"},t.DEFAULT=new t,t}(),an=function(t){function e(e,n){if(!(e instanceof nn))throw new Error("new Reference() no longer supported - use app.database().");return t.call(this,e,n,sn.DEFAULT,!1)||this}return m.__extends(e,t),e.prototype.getKey=function(){return g.validateArgCount("Reference.key",0,0,arguments.length),this.path.isEmpty()?null:this.path.getBack()},e.prototype.child=function(t){return g.validateArgCount("Reference.child",1,1,arguments.length),"number"==typeof t?t=String(t):t instanceof J||(null===this.path.getFront()?((n=t)&&(n=n.replace(/^\/*\.info(\/|$)/,"/")),vt("Reference.child",1,n,!1)):vt("Reference.child",1,t,!1)),new e(this.repo,this.path.child(t));var n},e.prototype.getParent=function(){g.validateArgCount("Reference.parent",0,0,arguments.length);var t=this.path.parent();return null===t?null:new e(this.repo,t)},e.prototype.getRoot=function(){g.validateArgCount("Reference.root",0,0,arguments.length);for(var t=this;null!==t.getParent();)t=t.getParent();return t},e.prototype.databaseProp=function(){return this.repo.database},e.prototype.set=function(t,e){g.validateArgCount("Reference.set",1,2,arguments.length),gt("Reference.set",this.path),ct("Reference.set",1,t,this.path,!1),g.validateCallback("Reference.set",2,e,!0);var n=new g.Deferred;return this.repo.setWithPriority(this.path,t,null,n.wrapCallback(e)),n.promise},e.prototype.update=function(t,e){if(g.validateArgCount("Reference.update",1,2,arguments.length),gt("Reference.update",this.path),Array.isArray(t)){for(var n={},i=0;i<t.length;++i)n[""+i]=t[i];t=n,L("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.")}lt("Reference.update",1,t,this.path,!1),g.validateCallback("Reference.update",2,e,!0);var r=new g.Deferred;return this.repo.update(this.path,t,r.wrapCallback(e)),r.promise},e.prototype.setWithPriority=function(t,e,n){if(g.validateArgCount("Reference.setWithPriority",2,3,arguments.length),gt("Reference.setWithPriority",this.path),ct("Reference.setWithPriority",1,t,this.path,!1),dt("Reference.setWithPriority",2,e,!1),g.validateCallback("Reference.setWithPriority",3,n,!0),".length"===this.getKey()||".keys"===this.getKey())throw"Reference.setWithPriority failed: "+this.getKey()+" is a read-only object.";var i=new g.Deferred;return this.repo.setWithPriority(this.path,t,e,i.wrapCallback(n)),i.promise},e.prototype.remove=function(t){return g.validateArgCount("Reference.remove",0,1,arguments.length),gt("Reference.remove",this.path),g.validateCallback("Reference.remove",1,t,!0),this.set(null,t)},e.prototype.transaction=function(t,e,n){if(g.validateArgCount("Reference.transaction",1,3,arguments.length),gt("Reference.transaction",this.path),g.validateCallback("Reference.transaction",1,t,!1),g.validateCallback("Reference.transaction",2,e,!0),function(t,e,n,i){if(void 0!==n&&"boolean"!=typeof n)throw new Error(g.errorPrefix("Reference.transaction",3,!0)+"must be a boolean.")}(0,0,n),".length"===this.getKey()||".keys"===this.getKey())throw"Reference.transaction failed: "+this.getKey()+" is a read-only object.";void 0===n&&(n=!0);var i=new g.Deferred;return"function"==typeof e&&i.promise.catch(function(){}),this.repo.startTransaction(this.path,t,function(t,n,r){t?i.reject(t):i.resolve(new _t(n,r)),"function"==typeof e&&e(t,n,r)},n),i.promise},e.prototype.setPriority=function(t,e){g.validateArgCount("Reference.setPriority",1,2,arguments.length),gt("Reference.setPriority",this.path),dt("Reference.setPriority",1,t,!1),g.validateCallback("Reference.setPriority",2,e,!0);var n=new g.Deferred;return this.repo.setWithPriority(this.path.child(".priority"),t,null,n.wrapCallback(e)),n.promise},e.prototype.push=function(t,e){g.validateArgCount("Reference.push",0,2,arguments.length),gt("Reference.push",this.path),ct("Reference.push",1,t,this.path,!0),g.validateCallback("Reference.push",2,e,!0);var n,i=this.repo.serverTime(),r=bt(i),o=this.child(r),s=this.child(r);return n=null!=t?o.set(t,e).then(function(){return s}):Promise.resolve(s),o.then=n.then.bind(n),o.catch=n.then.bind(n,void 0),"function"==typeof e&&n.catch(function(){}),o},e.prototype.onDisconnect=function(){return gt("Reference.onDisconnect",this.path),new mt(this.repo,this.path)},Object.defineProperty(e.prototype,"database",{get:function(){return this.databaseProp()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"key",{get:function(){return this.getKey()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return this.getParent()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"root",{get:function(){return this.getRoot()},enumerable:!0,configurable:!0}),e}(Zt);Zt.__referenceConstructor=an,Ee.__referenceConstructor=an;var un,cn=function(){this.children={},this.childCount=0,this.value=null},hn=function(){function t(t,e,n){void 0===t&&(t=""),void 0===e&&(e=null),void 0===n&&(n=new cn),this.name_=t,this.parent_=e,this.node_=n}return t.prototype.subTree=function(e){for(var n,i=e instanceof J?e:new J(e),r=this;null!==(n=i.getFront());)r=new t(n,r,g.safeGet(r.node_.children,n)||new cn),i=i.popFront();return r},t.prototype.getValue=function(){return this.node_.value},t.prototype.setValue=function(t){g.assert(void 0!==t,"Cannot set value to undefined"),this.node_.value=t,this.updateParents_()},t.prototype.clear=function(){this.node_.value=null,this.node_.children={},this.node_.childCount=0,this.updateParents_()},t.prototype.hasChildren=function(){return this.node_.childCount>0},t.prototype.isEmpty=function(){return null===this.getValue()&&!this.hasChildren()},t.prototype.forEachChild=function(e){var n=this;g.forEach(this.node_.children,function(i,r){e(new t(i,n,r))})},t.prototype.forEachDescendant=function(t,e,n){e&&!n&&t(this),this.forEachChild(function(e){e.forEachDescendant(t,!0,n)}),e&&n&&t(this)},t.prototype.forEachAncestor=function(t,e){for(var n=e?this:this.parent();null!==n;){if(t(n))return!0;n=n.parent()}return!1},t.prototype.forEachImmediateDescendantWithValue=function(t){this.forEachChild(function(e){null!==e.getValue()?t(e):e.forEachImmediateDescendantWithValue(t)})},t.prototype.path=function(){return new J(null===this.parent_?this.name_:this.parent_.path()+"/"+this.name_)},t.prototype.name=function(){return this.name_},t.prototype.parent=function(){return this.parent_},t.prototype.updateParents_=function(){null!==this.parent_&&this.parent_.updateChild_(this.name_,this)},t.prototype.updateChild_=function(t,e){var n=e.isEmpty(),i=g.contains(this.node_.children,t);n&&i?(delete this.node_.children[t],this.node_.childCount--,this.updateParents_()):n||i||(this.node_.children[t]=e.node_,this.node_.childCount++,this.updateParents_())},t}();!function(t){t[t.RUN=0]="RUN",t[t.SENT=1]="SENT",t[t.COMPLETED=2]="COMPLETED",t[t.SENT_NEEDS_ABORT=3]="SENT_NEEDS_ABORT",t[t.NEEDS_ABORT=4]="NEEDS_ABORT"}(un||(un={})),nn.MAX_TRANSACTION_RETRIES_=25,nn.prototype.transactions_init_=function(){this.transactionQueueTree_=new hn},nn.prototype.startTransaction=function(t,e,n,i){this.log_("transaction on "+t);var r=function(){},o=new an(this,t);o.on("value",r);var s={path:t,update:e,onComplete:n,status:null,order:I(),applyLocally:i,retryCount:0,unwatcher:function(){o.off("value",r)},abortReason:null,currentWriteId:null,currentInputSnapshot:null,currentOutputSnapshotRaw:null,currentOutputSnapshotResolved:null},a=this.getLatestState_(t);s.currentInputSnapshot=a;var u=s.update(a.val());if(void 0===u){if(s.unwatcher(),s.currentOutputSnapshotRaw=null,s.currentOutputSnapshotResolved=null,s.onComplete){var c=new Qt(s.currentInputSnapshot,new an(this,s.path),At);s.onComplete(null,!1,c)}}else{ht("transaction failed: Data returned ",u,s.path),s.status=un.RUN;var h=this.transactionQueueTree_.subTree(t),l=h.getValue()||[];l.push(s),h.setValue(l);var d=void 0;"object"==typeof u&&null!==u&&g.contains(u,".priority")?(d=g.safeGet(u,".priority"),g.assert(ut(d),"Invalid priority returned by transaction. Priority must be a valid string, finite number, server value, or null.")):d=(this.serverSyncTree_.calcCompleteEventCache(t)||Wt.EMPTY_NODE).getPriority().val(),d=d;var f=this.generateServerValues(),p=Vt(u,d),v=ie(p,f);s.currentOutputSnapshotRaw=p,s.currentOutputSnapshotResolved=v,s.currentWriteId=this.getNextWriteId_();var y=this.serverSyncTree_.applyUserOverwrite(t,v,s.currentWriteId,s.applyLocally);this.eventQueue_.raiseEventsForChangedPath(t,y),this.sendReadyTransactions_()}},nn.prototype.getLatestState_=function(t,e){return this.serverSyncTree_.calcCompleteEventCache(t,e)||Wt.EMPTY_NODE},nn.prototype.sendReadyTransactions_=function(t){var e=this;if(void 0===t&&(t=this.transactionQueueTree_),t||this.pruneCompletedTransactionsBelowNode_(t),null!==t.getValue()){var n=this.buildTransactionQueue_(t);g.assert(n.length>0,"Sending zero length transaction queue"),n.every(function(t){return t.status===un.RUN})&&this.sendTransactionQueue_(t.path(),n)}else t.hasChildren()&&t.forEachChild(function(t){e.sendReadyTransactions_(t)})},nn.prototype.sendTransactionQueue_=function(t,e){for(var n=this,i=e.map(function(t){return t.currentWriteId}),r=this.getLatestState_(t,i),o=r,s=r.hash(),a=0;a<e.length;a++){var u=e[a];g.assert(u.status===un.RUN,"tryToSendTransactionQueue_: items in queue should all be run."),u.status=un.SENT,u.retryCount++;var c=J.relativePath(t,u.path);o=o.updateChild(c,u.currentOutputSnapshotRaw)}var h=o.val(!0),l=t;this.server_.put(l.toString(),h,function(i){n.log_("transaction put response",{path:l.toString(),status:i});var r=[];if("ok"===i){for(var o=[],s=0;s<e.length;s++){if(e[s].status=un.COMPLETED,r=r.concat(n.serverSyncTree_.ackUserWrite(e[s].currentWriteId)),e[s].onComplete){var a=e[s].currentOutputSnapshotResolved,u=new an(n,e[s].path),c=new Qt(a,u,At);o.push(e[s].onComplete.bind(null,null,!0,c))}e[s].unwatcher()}for(n.pruneCompletedTransactionsBelowNode_(n.transactionQueueTree_.subTree(t)),n.sendReadyTransactions_(),n.eventQueue_.raiseEventsForChangedPath(t,r),s=0;s<o.length;s++)Y(o[s])}else{if("datastale"===i)for(s=0;s<e.length;s++)e[s].status===un.SENT_NEEDS_ABORT?e[s].status=un.NEEDS_ABORT:e[s].status=un.RUN;else for(L("transaction at "+l.toString()+" failed: "+i),s=0;s<e.length;s++)e[s].status=un.NEEDS_ABORT,e[s].abortReason=i;n.rerunTransactions_(t)}},s)},nn.prototype.rerunTransactions_=function(t){var e=this.getAncestorTransactionNode_(t),n=e.path(),i=this.buildTransactionQueue_(e);return this.rerunTransactionQueue_(i,n),n},nn.prototype.rerunTransactionQueue_=function(t,e){if(0!==t.length){for(var n,i=[],r=[],o=t.filter(function(t){return t.status===un.RUN}).map(function(t){return t.currentWriteId}),s=0;s<t.length;s++){var a=t[s],u=J.relativePath(e,a.path),c=!1,h=void 0;if(g.assert(null!==u,"rerunTransactionsUnderNode_: relativePath should not be null."),a.status===un.NEEDS_ABORT)c=!0,h=a.abortReason,r=r.concat(this.serverSyncTree_.ackUserWrite(a.currentWriteId,!0));else if(a.status===un.RUN)if(a.retryCount>=nn.MAX_TRANSACTION_RETRIES_)c=!0,h="maxretry",r=r.concat(this.serverSyncTree_.ackUserWrite(a.currentWriteId,!0));else{var l=this.getLatestState_(a.path,o);a.currentInputSnapshot=l;var d=t[s].update(l.val());if(void 0!==d){ht("transaction failed: Data returned ",d,a.path);var f=Vt(d);"object"==typeof d&&null!=d&&g.contains(d,".priority")||(f=f.updatePriority(l.getPriority()));var p=a.currentWriteId,v=this.generateServerValues(),y=ie(f,v);a.currentOutputSnapshotRaw=f,a.currentOutputSnapshotResolved=y,a.currentWriteId=this.getNextWriteId_(),o.splice(o.indexOf(p),1),r=(r=r.concat(this.serverSyncTree_.applyUserOverwrite(a.path,y,a.currentWriteId,a.applyLocally))).concat(this.serverSyncTree_.ackUserWrite(p,!0))}else c=!0,h="nodata",r=r.concat(this.serverSyncTree_.ackUserWrite(a.currentWriteId,!0))}if(this.eventQueue_.raiseEventsForChangedPath(e,r),r=[],c&&(t[s].status=un.COMPLETED,n=t[s].unwatcher,setTimeout(n,Math.floor(0)),t[s].onComplete))if("nodata"===h){var m=new an(this,t[s].path),_=t[s].currentInputSnapshot,b=new Qt(_,m,At);i.push(t[s].onComplete.bind(null,null,!1,b))}else i.push(t[s].onComplete.bind(null,new Error(h),!1,null))}for(this.pruneCompletedTransactionsBelowNode_(this.transactionQueueTree_),s=0;s<i.length;s++)Y(i[s]);this.sendReadyTransactions_()}},nn.prototype.getAncestorTransactionNode_=function(t){for(var e,n=this.transactionQueueTree_;null!==(e=t.getFront())&&null===n.getValue();)n=n.subTree(e),t=t.popFront();return n},nn.prototype.buildTransactionQueue_=function(t){var e=[];return this.aggregateTransactionQueuesForNode_(t,e),e.sort(function(t,e){return t.order-e.order}),e},nn.prototype.aggregateTransactionQueuesForNode_=function(t,e){var n=this,i=t.getValue();if(null!==i)for(var r=0;r<i.length;r++)e.push(i[r]);t.forEachChild(function(t){n.aggregateTransactionQueuesForNode_(t,e)})},nn.prototype.pruneCompletedTransactionsBelowNode_=function(t){var e=this,n=t.getValue();if(n){for(var i=0,r=0;r<n.length;r++)n[r].status!==un.COMPLETED&&(n[i]=n[r],i++);n.length=i,t.setValue(n.length>0?n:null)}t.forEachChild(function(t){e.pruneCompletedTransactionsBelowNode_(t)})},nn.prototype.abortTransactions_=function(t){var e=this,n=this.getAncestorTransactionNode_(t).path(),i=this.transactionQueueTree_.subTree(t);return i.forEachAncestor(function(t){e.abortTransactionsOnNode_(t)}),this.abortTransactionsOnNode_(i),i.forEachDescendant(function(t){e.abortTransactionsOnNode_(t)}),n},nn.prototype.abortTransactionsOnNode_=function(t){var e=t.getValue();if(null!==e){for(var n=[],i=[],r=-1,o=0;o<e.length;o++)e[o].status===un.SENT_NEEDS_ABORT||(e[o].status===un.SENT?(g.assert(r===o-1,"All SENT items should be at beginning of queue."),r=o,e[o].status=un.SENT_NEEDS_ABORT,e[o].abortReason="set"):(g.assert(e[o].status===un.RUN,"Unexpected transaction status in abort"),e[o].unwatcher(),i=i.concat(this.serverSyncTree_.ackUserWrite(e[o].currentWriteId,!0)),e[o].onComplete&&n.push(e[o].onComplete.bind(null,new Error("set"),!1,null))));for(-1===r?t.setValue(null):e.length=r+1,this.eventQueue_.raiseEventsForChangedPath(t.path(),i),o=0;o<n.length;o++)Y(n[o])}};var ln,dn=function(){function t(){this.repos_={},this.useRestClient_=!1}return t.getInstance=function(){return ln||(ln=new t),ln},t.prototype.interrupt=function(){for(var t in this.repos_)for(var e in this.repos_[t])this.repos_[t][e].interrupt()},t.prototype.resume=function(){for(var t in this.repos_)for(var e in this.repos_[t])this.repos_[t][e].resume()},t.prototype.databaseFromApp=function(t,e){var n=e||t.options.databaseURL;void 0===n&&M("Can't determine Firebase Database URL.  Be sure to include databaseURL option when calling firebase.initializeApp().");var i=nt(n),r=i.repoInfo;return yt("Invalid Firebase Database URL",1,i),i.path.isEmpty()||M("Database URL must point to the root of a Firebase Database (not including a child path)."),this.createRepo(r,t).database},t.prototype.deleteRepo=function(t){var e=g.safeGet(this.repos_,t.app.name);e&&g.safeGet(e,t.repoInfo_.toURLString())===t||M("Database "+t.app.name+"("+t.repoInfo_+") has already been deleted."),t.interrupt(),delete e[t.repoInfo_.toURLString()]},t.prototype.createRepo=function(t,e){var n=g.safeGet(this.repos_,e.name);n||(n={},this.repos_[e.name]=n);var i=g.safeGet(n,t.toURLString());return i&&M("Database initialized multiple times. Please make sure the format of the database URL matches with each database() call."),i=new nn(t,this.useRestClient_,e),n[t.toURLString()]=i,i},t.prototype.forceRestClient=function(t){this.useRestClient_=t},t}(),fn=function(){function t(t){this.repo_=t,t instanceof nn||M("Don't call new Database() directly - please use firebase.database()."),this.root_=new an(t,J.Empty),this.INTERNAL=new pn(this)}return Object.defineProperty(t.prototype,"app",{get:function(){return this.repo_.app},enumerable:!0,configurable:!0}),t.prototype.ref=function(t){return this.checkDeleted_("ref"),g.validateArgCount("database.ref",0,1,arguments.length),t instanceof an?this.refFromURL(t.toString()):void 0!==t?this.root_.child(t):this.root_},t.prototype.refFromURL=function(t){var e="database.refFromURL";this.checkDeleted_(e),g.validateArgCount(e,1,1,arguments.length);var n=nt(t);yt(e,1,n);var i=n.repoInfo;return i.host!==this.repo_.repoInfo_.host&&M(e+": Host name does not match the current database: (found "+i.host+" but expected "+this.repo_.repoInfo_.host+")"),this.ref(n.path.toString())},t.prototype.checkDeleted_=function(t){null===this.repo_&&M("Cannot call "+t+" on a deleted database.")},t.prototype.goOffline=function(){g.validateArgCount("database.goOffline",0,0,arguments.length),this.checkDeleted_("goOffline"),this.repo_.interrupt()},t.prototype.goOnline=function(){g.validateArgCount("database.goOnline",0,0,arguments.length),this.checkDeleted_("goOnline"),this.repo_.resume()},t.ServerValue={TIMESTAMP:{".sv":"timestamp"}},t}(),pn=function(){function t(t){this.database=t}return t.prototype.delete=function(){return m.__awaiter(this,void 0,void 0,function(){return m.__generator(this,function(t){return this.database.checkDeleted_("delete"),dn.getInstance().deleteRepo(this.database.repo_),this.database.repo_=null,this.database.root_=null,this.database.INTERNAL=null,this.database=null,[2]})})},t}(),vn=Object.freeze({forceLongPolling:function(){Qe.forceDisallow(),He.forceAllow()},forceWebSockets:function(){He.forceDisallow()},isWebSocketsAvailable:function(){return Qe.isAvailable()},setSecurityDebugCallback:function(t,e){t.repo.persistentConnection_.securityDebugCallback_=e},stats:function(t,e){t.repo.stats(e)},statsIncrementCounter:function(t,e){t.repo.statsIncrementCounter(e)},dataUpdateCount:function(t){return t.repo.dataUpdateCount},interceptServerData:function(t,e){return t.repo.interceptServerData_(e)}}),gn=tn;tn.prototype.simpleListen=function(t,e){this.sendRequest("q",{p:t},e)},tn.prototype.echo=function(t,e){this.sendRequest("echo",{d:t},e)};var yn=Ge,mn=et,_n=Object.freeze({DataConnection:gn,RealTimeConnection:yn,hijackHash:function(t){var e=tn.prototype.put;return tn.prototype.put=function(n,i,r,o){void 0!==o&&(o=t()),e.call(this,n,i,r,o)},function(){tn.prototype.put=e}},ConnectionTarget:mn,queryIdentifier:function(t){return t.queryIdentifier()},listens:function(t){return t.repo.persistentConnection_.listens_},forceRestClient:function(t){dn.getInstance().forceRestClient(t)}}),bn=fn.ServerValue;function wn(e){var n=e.INTERNAL.registerService("database",function(t,e,n){return dn.getInstance().databaseFromApp(t,n)},{Reference:an,Query:Zt,Database:fn,enableLogging:D,INTERNAL:vn,ServerValue:bn,TEST_ACCESS:_n},null,!0);g.isNodeSdk()&&(t.exports=n)}wn(_),e.registerDatabase=wn,e.Database=fn,e.Query=Zt,e.Reference=an,e.enableLogging=D,e.ServerValue=bn,e.DataSnapshot=Qt,e.OnDisconnect=mt}).call(this,n(18))},function(t,e,n){(function(t){(function(){var t,e=n(8).default,i=i||{},r=this;function o(t){return"string"==typeof t}function s(t){return"boolean"==typeof t}function a(){}function u(t){var e=typeof t;if("object"==e){if(!t)return"null";if(t instanceof Array)return"array";if(t instanceof Object)return e;var n=Object.prototype.toString.call(t);if("[object Window]"==n)return"object";if("[object Array]"==n||"number"==typeof t.length&&void 0!==t.splice&&void 0!==t.propertyIsEnumerable&&!t.propertyIsEnumerable("splice"))return"array";if("[object Function]"==n||void 0!==t.call&&void 0!==t.propertyIsEnumerable&&!t.propertyIsEnumerable("call"))return"function"}else if("function"==e&&void 0===t.call)return"object";return e}function c(t){return null===t}function h(t){return"array"==u(t)}function l(t){var e=u(t);return"array"==e||"object"==e&&"number"==typeof t.length}function d(t){return"function"==u(t)}function f(t){var e=typeof t;return"object"==e&&null!=t||"function"==e}var p="closure_uid_"+(1e9*Math.random()>>>0),v=0;function g(t,e,n){return t.call.apply(t.bind,arguments)}function y(t,e,n){if(!t)throw Error();if(2<arguments.length){var i=Array.prototype.slice.call(arguments,2);return function(){var n=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(n,i),t.apply(e,n)}}return function(){return t.apply(e,arguments)}}function m(t,e,n){return(m=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?g:y).apply(null,arguments)}function _(t,e){var n=Array.prototype.slice.call(arguments,1);return function(){var e=n.slice();return e.push.apply(e,arguments),t.apply(this,e)}}var b=Date.now||function(){return+new Date};function w(t,e){function n(){}n.prototype=e.prototype,t.lb=e.prototype,t.prototype=new n,t.prototype.constructor=t,t.cd=function(t,n,i){for(var r=Array(arguments.length-2),o=2;o<arguments.length;o++)r[o-2]=arguments[o];return e.prototype[n].apply(t,r)}}function C(t){t.prototype.then=t.prototype.then,t.prototype.$goog_Thenable=!0}function T(t){if(!t)return!1;try{return!!t.$goog_Thenable}catch(t){return!1}}function E(t){if(Error.captureStackTrace)Error.captureStackTrace(this,E);else{var e=Error().stack;e&&(this.stack=e)}t&&(this.message=String(t))}function S(t,e){for(var n="",i=(t=t.split("%s")).length-1,r=0;r<i;r++)n+=t[r]+(r<e.length?e[r]:"%s");E.call(this,n+t[i])}function I(t,e){throw new S("Failure"+(t?": "+t:""),Array.prototype.slice.call(arguments,1))}function k(t,e){this.c=t,this.f=e,this.b=0,this.a=null}function A(t,e){t.f(e),100>t.b&&(t.b++,e.next=t.a,t.a=e)}function P(){this.b=this.a=null}w(E,Error),E.prototype.name="CustomError",w(S,E),S.prototype.name="AssertionError",k.prototype.get=function(){if(0<this.b){this.b--;var t=this.a;this.a=t.next,t.next=null}else t=this.c();return t};var N=new k(function(){return new R},function(t){t.reset()});function D(){var t=pt,e=null;return t.a&&(e=t.a,t.a=t.a.next,t.a||(t.b=null),e.next=null),e}function R(){this.next=this.b=this.a=null}P.prototype.add=function(t,e){var n=N.get();n.set(t,e),this.b?this.b.next=n:this.a=n,this.b=n},R.prototype.set=function(t,e){this.a=t,this.b=e,this.next=null},R.prototype.reset=function(){this.next=this.b=this.a=null};var O=Array.prototype.indexOf?function(t,e){return Array.prototype.indexOf.call(t,e,void 0)}:function(t,e){if(o(t))return o(e)&&1==e.length?t.indexOf(e,0):-1;for(var n=0;n<t.length;n++)if(n in t&&t[n]===e)return n;return-1},x=Array.prototype.forEach?function(t,e,n){Array.prototype.forEach.call(t,e,n)}:function(t,e,n){for(var i=t.length,r=o(t)?t.split(""):t,s=0;s<i;s++)s in r&&e.call(n,r[s],s,t)},M=Array.prototype.map?function(t,e){return Array.prototype.map.call(t,e,void 0)}:function(t,e){for(var n=t.length,i=Array(n),r=o(t)?t.split(""):t,s=0;s<n;s++)s in r&&(i[s]=e.call(void 0,r[s],s,t));return i},L=Array.prototype.some?function(t,e){return Array.prototype.some.call(t,e,void 0)}:function(t,e){for(var n=t.length,i=o(t)?t.split(""):t,r=0;r<n;r++)if(r in i&&e.call(void 0,i[r],r,t))return!0;return!1};function F(t,e){return 0<=O(t,e)}function U(t,e){var n;return(n=0<=(e=O(t,e)))&&Array.prototype.splice.call(t,e,1),n}function j(t,e){!function(t,e){var n=t.length,i=o(t)?t.split(""):t;for(--n;0<=n;--n)n in i&&e.call(void 0,i[n],n,t)}(t,function(n,i){e.call(void 0,n,i,t)&&Array.prototype.splice.call(t,i,1).length})}function W(t){return Array.prototype.concat.apply([],arguments)}function B(t){var e=t.length;if(0<e){for(var n=Array(e),i=0;i<e;i++)n[i]=t[i];return n}return[]}function $(t,e){for(var n=t.split("%s"),i="",r=Array.prototype.slice.call(arguments,1);r.length&&1<n.length;)i+=n.shift()+r.shift();return i+n.join("%s")}var V=String.prototype.trim?function(t){return t.trim()}:function(t){return/^[\s\xa0]*([\s\S]*?)[\s\xa0]*$/.exec(t)[1]};function q(t){return J.test(t)?(-1!=t.indexOf("&")&&(t=t.replace(z,"&amp;")),-1!=t.indexOf("<")&&(t=t.replace(K,"&lt;")),-1!=t.indexOf(">")&&(t=t.replace(Q,"&gt;")),-1!=t.indexOf('"')&&(t=t.replace(Y,"&quot;")),-1!=t.indexOf("'")&&(t=t.replace(G,"&#39;")),-1!=t.indexOf("\0")&&(t=t.replace(X,"&#0;")),t):t}var H,z=/&/g,K=/</g,Q=/>/g,Y=/"/g,G=/'/g,X=/\x00/g,J=/[\x00&<>"']/;function Z(t,e){return-1!=t.indexOf(e)}function tt(t,e){return t<e?-1:t>e?1:0}t:{var et=r.navigator;if(et){var nt=et.userAgent;if(nt){H=nt;break t}}H=""}function it(t){return Z(H,t)}function rt(t,e){for(var n in t)e.call(void 0,t[n],n,t)}function ot(t){for(var e in t)return!1;return!0}function st(t){var e,n={};for(e in t)n[e]=t[e];return n}var at,ut,ct="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function ht(t,e){for(var n,i,r=1;r<arguments.length;r++){for(n in i=arguments[r])t[n]=i[n];for(var o=0;o<ct.length;o++)n=ct[o],Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n])}}function lt(t){r.setTimeout(function(){throw t},0)}function dt(t,e){ut||function(){if(r.Promise&&r.Promise.resolve){var t=r.Promise.resolve(void 0);ut=function(){t.then(vt)}}else ut=function(){var t=vt;!d(r.setImmediate)||r.Window&&r.Window.prototype&&!it("Edge")&&r.Window.prototype.setImmediate==r.setImmediate?(at||(at=function(){var t=r.MessageChannel;if(void 0===t&&"undefined"!=typeof window&&window.postMessage&&window.addEventListener&&!it("Presto")&&(t=function(){var t=document.createElement("IFRAME");t.style.display="none",t.src="",document.documentElement.appendChild(t);var e=t.contentWindow;(t=e.document).open(),t.write(""),t.close();var n="callImmediate"+Math.random(),i="file:"==e.location.protocol?"*":e.location.protocol+"//"+e.location.host;t=m(function(t){"*"!=i&&t.origin!=i||t.data!=n||this.port1.onmessage()},this),e.addEventListener("message",t,!1),this.port1={},this.port2={postMessage:function(){e.postMessage(n,i)}}}),void 0!==t&&!it("Trident")&&!it("MSIE")){var e=new t,n={},i=n;return e.port1.onmessage=function(){if(void 0!==n.next){var t=(n=n.next).tb;n.tb=null,t()}},function(t){i.next={tb:t},i=i.next,e.port2.postMessage(0)}}return"undefined"!=typeof document&&"onreadystatechange"in document.createElement("SCRIPT")?function(t){var e=document.createElement("SCRIPT");e.onreadystatechange=function(){e.onreadystatechange=null,e.parentNode.removeChild(e),e=null,t(),t=null},document.documentElement.appendChild(e)}:function(t){r.setTimeout(t,0)}}()),at(t)):r.setImmediate(t)}}(),ft||(ut(),ft=!0),pt.add(t,e)}var ft=!1,pt=new P;function vt(){for(var t;t=D();){try{t.a.call(t.b)}catch(t){lt(t)}A(N,t)}ft=!1}function gt(t,e){if(this.a=yt,this.i=void 0,this.f=this.b=this.c=null,this.g=this.h=!1,t!=a)try{var n=this;t.call(e,function(t){At(n,mt,t)},function(t){if(!(t instanceof Mt))try{if(t instanceof Error)throw t;throw Error("Promise rejected.")}catch(t){}At(n,_t,t)})}catch(t){At(this,_t,t)}}var yt=0,mt=2,_t=3;function bt(){this.next=this.f=this.b=this.g=this.a=null,this.c=!1}bt.prototype.reset=function(){this.f=this.b=this.g=this.a=null,this.c=!1};var wt=new k(function(){return new bt},function(t){t.reset()});function Ct(t,e,n){var i=wt.get();return i.g=t,i.b=e,i.f=n,i}function Tt(t){if(t instanceof gt)return t;var e=new gt(a);return At(e,mt,t),e}function Et(t){return new gt(function(e,n){n(t)})}function St(t,e,n){Pt(t,e,n,null)||dt(_(e,t))}function It(t,e){t.b||t.a!=mt&&t.a!=_t||Nt(t),t.f?t.f.next=e:t.b=e,t.f=e}function kt(t,e,n,i){var r=Ct(null,null,null);return r.a=new gt(function(t,o){r.g=e?function(n){try{var r=e.call(i,n);t(r)}catch(t){o(t)}}:t,r.b=n?function(e){try{var r=n.call(i,e);void 0===r&&e instanceof Mt?o(e):t(r)}catch(t){o(t)}}:o}),r.a.c=t,It(t,r),r.a}function At(t,e,n){t.a==yt&&(t===n&&(e=_t,n=new TypeError("Promise cannot resolve to itself")),t.a=1,Pt(n,t.Lc,t.Mc,t)||(t.i=n,t.a=e,t.c=null,Nt(t),e!=_t||n instanceof Mt||function(t,e){t.g=!0,dt(function(){t.g&&xt.call(null,e)})}(t,n)))}function Pt(t,e,n,i){if(t instanceof gt)return It(t,Ct(e||a,n||null,i)),!0;if(T(t))return t.then(e,n,i),!0;if(f(t))try{var r=t.then;if(d(r))return function(t,e,n,i,r){function o(t){s||(s=!0,i.call(r,t))}var s=!1;try{e.call(t,function(t){s||(s=!0,n.call(r,t))},o)}catch(t){o(t)}}(t,r,e,n,i),!0}catch(t){return n.call(i,t),!0}return!1}function Nt(t){t.h||(t.h=!0,dt(t.Ub,t))}function Dt(t){var e=null;return t.b&&(e=t.b,t.b=e.next,e.next=null),t.b||(t.f=null),e}function Rt(t,e,n,i){if(n==_t&&e.b&&!e.c)for(;t&&t.g;t=t.c)t.g=!1;if(e.a)e.a.c=null,Ot(e,n,i);else try{e.c?e.g.call(e.f):Ot(e,n,i)}catch(t){xt.call(null,t)}A(wt,e)}function Ot(t,e,n){e==mt?t.g.call(t.f,n):t.b&&t.b.call(t.f,n)}gt.prototype.then=function(t,e,n){return kt(this,d(t)?t:null,d(e)?e:null,n)},C(gt),(t=gt.prototype).ia=function(t,e){return(t=Ct(t,t,e)).c=!0,It(this,t),this},t.s=function(t,e){return kt(this,null,t,e)},t.cancel=function(t){this.a==yt&&dt(function(){!function t(e,n){if(e.a==yt)if(e.c){var i=e.c;if(i.b){for(var r=0,o=null,s=null,a=i.b;a&&(a.c||(r++,a.a==e&&(o=a),!(o&&1<r)));a=a.next)o||(s=a);o&&(i.a==yt&&1==r?t(i,n):(s?((r=s).next==i.f&&(i.f=r),r.next=r.next.next):Dt(i),Rt(i,o,_t,n)))}e.c=null}else At(e,_t,n)}(this,new Mt(t))},this)},t.Lc=function(t){this.a=yt,At(this,mt,t)},t.Mc=function(t){this.a=yt,At(this,_t,t)},t.Ub=function(){for(var t;t=Dt(this);)Rt(this,t,this.a,this.i);this.h=!1};var xt=lt;function Mt(t){E.call(this,t)}function Lt(){0!=Ft&&(Ut[this[p]||(this[p]=++v)]=this),this.pa=this.pa,this.ja=this.ja}w(Mt,E),Mt.prototype.name="cancel";var Ft=0,Ut={};function jt(t){if(!t.pa&&(t.pa=!0,t.ua(),0!=Ft)){var e=t[p]||(t[p]=++v);if(0!=Ft&&t.ja&&0<t.ja.length)throw Error(t+" did not empty its onDisposeCallbacks queue. This probably means it overrode dispose() or disposeInternal() without calling the superclass' method.");delete Ut[e]}}function Wt(t){return Wt[" "](t),t}Lt.prototype.pa=!1,Lt.prototype.ua=function(){if(this.ja)for(;this.ja.length;)this.ja.shift()()},Wt[" "]=a;var Bt,$t,Vt=it("Opera"),qt=it("Trident")||it("MSIE"),Ht=it("Edge"),zt=Ht||qt,Kt=it("Gecko")&&!(Z(H.toLowerCase(),"webkit")&&!it("Edge"))&&!(it("Trident")||it("MSIE"))&&!it("Edge"),Qt=Z(H.toLowerCase(),"webkit")&&!it("Edge");function Yt(){var t=r.document;return t?t.documentMode:void 0}t:{var Gt="",Xt=($t=H,Kt?/rv:([^\);]+)(\)|;)/.exec($t):Ht?/Edge\/([\d\.]+)/.exec($t):qt?/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec($t):Qt?/WebKit\/(\S+)/.exec($t):Vt?/(?:Version)[ \/]?(\S+)/.exec($t):void 0);if(Xt&&(Gt=Xt?Xt[1]:""),qt){var Jt=Yt();if(null!=Jt&&Jt>parseFloat(Gt)){Bt=String(Jt);break t}}Bt=Gt}var Zt,te={};function ee(t){return function(t,e){var n=te;return Object.prototype.hasOwnProperty.call(n,t)?n[t]:n[t]=e()}(t,function(){for(var e=0,n=V(String(Bt)).split("."),i=V(String(t)).split("."),r=Math.max(n.length,i.length),o=0;0==e&&o<r;o++){var s=n[o]||"",a=i[o]||"";do{if(s=/(\d*)(\D*)(.*)/.exec(s)||["","","",""],a=/(\d*)(\D*)(.*)/.exec(a)||["","","",""],0==s[0].length&&0==a[0].length)break;e=tt(0==s[1].length?0:parseInt(s[1],10),0==a[1].length?0:parseInt(a[1],10))||tt(0==s[2].length,0==a[2].length)||tt(s[2],a[2]),s=s[3],a=a[3]}while(0==e)}return 0<=e})}var ne=r.document;Zt=ne&&qt?Yt()||("CSS1Compat"==ne.compatMode?parseInt(Bt,10):5):void 0;var ie=Object.freeze||function(t){return t},re=!qt||9<=Number(Zt),oe=qt&&!ee("9"),se=function(){if(!r.addEventListener||!Object.defineProperty)return!1;var t=!1,e=Object.defineProperty({},"passive",{get:function(){t=!0}});return r.addEventListener("test",a,e),r.removeEventListener("test",a,e),t}();function ae(t,e){this.type=t,this.b=this.target=e,this.Gb=!0}function ue(t,e){if(ae.call(this,t?t.type:""),this.relatedTarget=this.b=this.target=null,this.button=this.screenY=this.screenX=this.clientY=this.clientX=0,this.key="",this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.pointerId=0,this.pointerType="",this.a=null,t){var n=this.type=t.type,i=t.changedTouches?t.changedTouches[0]:null;if(this.target=t.target||t.srcElement,this.b=e,e=t.relatedTarget){if(Kt){t:{try{Wt(e.nodeName);var r=!0;break t}catch(t){}r=!1}r||(e=null)}}else"mouseover"==n?e=t.fromElement:"mouseout"==n&&(e=t.toElement);this.relatedTarget=e,null===i?(this.clientX=void 0!==t.clientX?t.clientX:t.pageX,this.clientY=void 0!==t.clientY?t.clientY:t.pageY,this.screenX=t.screenX||0,this.screenY=t.screenY||0):(this.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=t.button,this.key=t.key||"",this.ctrlKey=t.ctrlKey,this.altKey=t.altKey,this.shiftKey=t.shiftKey,this.metaKey=t.metaKey,this.pointerId=t.pointerId||0,this.pointerType=o(t.pointerType)?t.pointerType:ce[t.pointerType]||"",this.a=t,t.defaultPrevented&&this.preventDefault()}}ae.prototype.preventDefault=function(){this.Gb=!1},w(ue,ae);var ce=ie({2:"touch",3:"pen",4:"mouse"});ue.prototype.preventDefault=function(){ue.lb.preventDefault.call(this);var t=this.a;if(t.preventDefault)t.preventDefault();else if(t.returnValue=!1,oe)try{(t.ctrlKey||112<=t.keyCode&&123>=t.keyCode)&&(t.keyCode=-1)}catch(t){}},ue.prototype.f=function(){return this.a};var he="closure_listenable_"+(1e6*Math.random()|0),le=0;function de(t){t.na=!0,t.listener=null,t.proxy=null,t.src=null,t.La=null}function fe(t){this.src=t,this.a={},this.b=0}function pe(t,e){var n=e.type;n in t.a&&U(t.a[n],e)&&(de(e),0==t.a[n].length&&(delete t.a[n],t.b--))}function ve(t,e,n,i){for(var r=0;r<t.length;++r){var o=t[r];if(!o.na&&o.listener==e&&o.capture==!!n&&o.La==i)return r}return-1}fe.prototype.add=function(t,e,n,i,r){var o=t.toString();(t=this.a[o])||(t=this.a[o]=[],this.b++);var s=ve(t,e,i,r);return-1<s?(e=t[s],n||(e.Ia=!1)):((e=new function(t,e,n,i,r){this.listener=t,this.proxy=null,this.src=e,this.type=n,this.capture=!!i,this.La=r,this.key=++le,this.na=this.Ia=!1}(e,this.src,o,!!i,r)).Ia=n,t.push(e)),e};var ge="closure_lm_"+(1e6*Math.random()|0),ye={};function me(t,e,n,i,r){if(i&&i.once)be(t,e,n,i,r);else if(h(e))for(var o=0;o<e.length;o++)me(t,e[o],n,i,r);else n=Pe(n),t&&t[he]?De(t,e,n,f(i)?!!i.capture:!!i,r):_e(t,e,n,!1,i,r)}function _e(t,e,n,i,r,o){if(!e)throw Error("Invalid event type");var s=f(r)?!!r.capture:!!r,a=ke(t);if(a||(t[ge]=a=new fe(t)),!(n=a.add(e,n,i,s,o)).proxy)if(i=function(){var t=Ie,e=re?function(n){return t.call(e.src,e.listener,n)}:function(n){if(!(n=t.call(e.src,e.listener,n)))return n};return e}(),n.proxy=i,i.src=t,i.listener=n,t.addEventListener)se||(r=s),void 0===r&&(r=!1),t.addEventListener(e.toString(),i,r);else if(t.attachEvent)t.attachEvent(Te(e.toString()),i);else{if(!t.addListener||!t.removeListener)throw Error("addEventListener and attachEvent are unavailable.");t.addListener(i)}}function be(t,e,n,i,r){if(h(e))for(var o=0;o<e.length;o++)be(t,e[o],n,i,r);else n=Pe(n),t&&t[he]?Re(t,e,n,f(i)?!!i.capture:!!i,r):_e(t,e,n,!0,i,r)}function we(t,e,n,i,r){if(h(e))for(var o=0;o<e.length;o++)we(t,e[o],n,i,r);else i=f(i)?!!i.capture:!!i,n=Pe(n),t&&t[he]?(t=t.m,(e=String(e).toString())in t.a&&-1<(n=ve(o=t.a[e],n,i,r))&&(de(o[n]),Array.prototype.splice.call(o,n,1),0==o.length&&(delete t.a[e],t.b--))):t&&(t=ke(t))&&(e=t.a[e.toString()],t=-1,e&&(t=ve(e,n,i,r)),(n=-1<t?e[t]:null)&&Ce(n))}function Ce(t){if("number"!=typeof t&&t&&!t.na){var e=t.src;if(e&&e[he])pe(e.m,t);else{var n=t.type,i=t.proxy;e.removeEventListener?e.removeEventListener(n,i,t.capture):e.detachEvent?e.detachEvent(Te(n),i):e.addListener&&e.removeListener&&e.removeListener(i),(n=ke(e))?(pe(n,t),0==n.b&&(n.src=null,e[ge]=null)):de(t)}}}function Te(t){return t in ye?ye[t]:ye[t]="on"+t}function Ee(t,e,n,i){var r=!0;if((t=ke(t))&&(e=t.a[e.toString()]))for(e=e.concat(),t=0;t<e.length;t++){var o=e[t];o&&o.capture==n&&!o.na&&(o=Se(o,i),r=r&&!1!==o)}return r}function Se(t,e){var n=t.listener,i=t.La||t.src;return t.Ia&&Ce(t),n.call(i,e)}function Ie(t,e){if(t.na)return!0;if(!re){if(!e)t:{e=["window","event"];for(var n=r,i=0;i<e.length;i++)if(null==(n=n[e[i]])){e=null;break t}e=n}if(e=new ue(i=e,this),n=!0,!(0>i.keyCode||void 0!=i.returnValue)){t:{var o=!1;if(0==i.keyCode)try{i.keyCode=-1;break t}catch(t){o=!0}(o||void 0==i.returnValue)&&(i.returnValue=!0)}for(i=[],o=e.b;o;o=o.parentNode)i.push(o);for(t=t.type,o=i.length-1;0<=o;o--){e.b=i[o];var s=Ee(i[o],t,!0,e);n=n&&s}for(o=0;o<i.length;o++)e.b=i[o],s=Ee(i[o],t,!1,e),n=n&&s}return n}return Se(t,new ue(e,this))}function ke(t){return(t=t[ge])instanceof fe?t:null}var Ae="__closure_events_fn_"+(1e9*Math.random()>>>0);function Pe(t){return d(t)?t:(t[Ae]||(t[Ae]=function(e){return t.handleEvent(e)}),t[Ae])}function Ne(){Lt.call(this),this.m=new fe(this),this.Nb=this,this.Ua=null}function De(t,e,n,i,r){t.m.add(String(e),n,!1,i,r)}function Re(t,e,n,i,r){t.m.add(String(e),n,!0,i,r)}function Oe(t,e,n,i){if(!(e=t.m.a[String(e)]))return!0;e=e.concat();for(var r=!0,o=0;o<e.length;++o){var s=e[o];if(s&&!s.na&&s.capture==n){var a=s.listener,u=s.La||s.src;s.Ia&&pe(t.m,s),r=!1!==a.call(u,i)&&r}}return r&&0!=i.Gb}function xe(t,e,n){if(d(t))n&&(t=m(t,n));else{if(!t||"function"!=typeof t.handleEvent)throw Error("Invalid listener argument");t=m(t.handleEvent,t)}return 2147483647<Number(e)?-1:r.setTimeout(t,e||0)}function Me(t){var e=null;return new gt(function(n,i){-1==(e=xe(function(){n(void 0)},t))&&i(Error("Failed to schedule timer."))}).s(function(t){throw r.clearTimeout(e),t})}function Le(t){if(t.S&&"function"==typeof t.S)return t.S();if(o(t))return t.split("");if(l(t)){for(var e=[],n=t.length,i=0;i<n;i++)e.push(t[i]);return e}for(i in e=[],n=0,t)e[n++]=t[i];return e}function Fe(t){if(t.U&&"function"==typeof t.U)return t.U();if(!t.S||"function"!=typeof t.S){if(l(t)||o(t)){var e=[];t=t.length;for(var n=0;n<t;n++)e.push(n);return e}for(var i in e=[],n=0,t)e[n++]=i;return e}}function Ue(t,e){this.b={},this.a=[],this.c=0;var n=arguments.length;if(1<n){if(n%2)throw Error("Uneven number of arguments");for(var i=0;i<n;i+=2)this.set(arguments[i],arguments[i+1])}else if(t)if(t instanceof Ue)for(n=t.U(),i=0;i<n.length;i++)this.set(n[i],t.get(n[i]));else for(i in t)this.set(i,t[i])}function je(t){if(t.c!=t.a.length){for(var e=0,n=0;e<t.a.length;){var i=t.a[e];We(t.b,i)&&(t.a[n++]=i),e++}t.a.length=n}if(t.c!=t.a.length){var r={};for(n=e=0;e<t.a.length;)We(r,i=t.a[e])||(t.a[n++]=i,r[i]=1),e++;t.a.length=n}}function We(t,e){return Object.prototype.hasOwnProperty.call(t,e)}w(Ne,Lt),Ne.prototype[he]=!0,Ne.prototype.addEventListener=function(t,e,n,i){me(this,t,e,n,i)},Ne.prototype.removeEventListener=function(t,e,n,i){we(this,t,e,n,i)},Ne.prototype.dispatchEvent=function(t){var e,n=this.Ua;if(n)for(e=[];n;n=n.Ua)e.push(n);n=this.Nb;var i=t.type||t;if(o(t))t=new ae(t,n);else if(t instanceof ae)t.target=t.target||n;else{var r=t;ht(t=new ae(i,n),r)}if(r=!0,e)for(var s=e.length-1;0<=s;s--){var a=t.b=e[s];r=Oe(a,i,!0,t)&&r}if(r=Oe(a=t.b=n,i,!0,t)&&r,r=Oe(a,i,!1,t)&&r,e)for(s=0;s<e.length;s++)r=Oe(a=t.b=e[s],i,!1,t)&&r;return r},Ne.prototype.ua=function(){if(Ne.lb.ua.call(this),this.m){var t,e=this.m;for(t in e.a){for(var n=e.a[t],i=0;i<n.length;i++)de(n[i]);delete e.a[t],e.b--}}this.Ua=null},(t=Ue.prototype).S=function(){je(this);for(var t=[],e=0;e<this.a.length;e++)t.push(this.b[this.a[e]]);return t},t.U=function(){return je(this),this.a.concat()},t.clear=function(){this.b={},this.c=this.a.length=0},t.get=function(t,e){return We(this.b,t)?this.b[t]:e},t.set=function(t,e){We(this.b,t)||(this.c++,this.a.push(t)),this.b[t]=e},t.forEach=function(t,e){for(var n=this.U(),i=0;i<n.length;i++){var r=n[i],o=this.get(r);t.call(e,o,r,this)}};var Be=/^(?:([^:/?#.]+):)?(?:\/\/(?:([^/?#]*)@)?([^/#?]*?)(?::([0-9]+))?(?=[/#?]|$))?([^?#]+)?(?:\?([^#]*))?(?:#([\s\S]*))?$/;function $e(t,e){if(this.b=this.m=this.c="",this.i=null,this.h=this.g="",this.f=!1,t instanceof $e){this.f=void 0!==e?e:t.f,Ve(this,t.c),this.m=t.m,this.b=t.b,qe(this,t.i),this.g=t.g,e=t.a;var n=new on;n.c=e.c,e.a&&(n.a=new Ue(e.a),n.b=e.b),He(this,n),this.h=t.h}else t&&(n=String(t).match(Be))?(this.f=!!e,Ve(this,n[1]||"",!0),this.m=Ge(n[2]||""),this.b=Ge(n[3]||"",!0),qe(this,n[4]),this.g=Ge(n[5]||"",!0),He(this,n[6]||"",!0),this.h=Ge(n[7]||"")):(this.f=!!e,this.a=new on(null,this.f))}function Ve(t,e,n){t.c=n?Ge(e,!0):e,t.c&&(t.c=t.c.replace(/:$/,""))}function qe(t,e){if(e){if(e=Number(e),isNaN(e)||0>e)throw Error("Bad port number "+e);t.i=e}else t.i=null}function He(t,e,n){e instanceof on?(t.a=e,function(t,e){e&&!t.f&&(sn(t),t.c=null,t.a.forEach(function(t,e){var n=e.toLowerCase();e!=n&&(un(this,e),hn(this,n,t))},t)),t.f=e}(t.a,t.f)):(n||(e=Xe(e,nn)),t.a=new on(e,t.f))}function ze(t,e,n){t.a.set(e,n)}function Ke(t,e){return t.a.get(e)}function Qe(t){return t instanceof $e?new $e(t):new $e(t,void 0)}function Ye(t,e){var n=new $e(null,void 0);return Ve(n,"https"),t&&(n.b=t),e&&(n.g=e),n}function Ge(t,e){return t?e?decodeURI(t.replace(/%25/g,"%2525")):decodeURIComponent(t):""}function Xe(t,e,n){return o(t)?(t=encodeURI(t).replace(e,Je),n&&(t=t.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),t):null}function Je(t){return"%"+((t=t.charCodeAt(0))>>4&15).toString(16)+(15&t).toString(16)}$e.prototype.toString=function(){var t=[],e=this.c;e&&t.push(Xe(e,Ze,!0),":");var n=this.b;return(n||"file"==e)&&(t.push("//"),(e=this.m)&&t.push(Xe(e,Ze,!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(Xe(n,"/"==n.charAt(0)?en:tn,!0))),(n=this.a.toString())&&t.push("?",n),(n=this.h)&&t.push("#",Xe(n,rn)),t.join("")};var Ze=/[#\/\?@]/g,tn=/[#\?:]/g,en=/[#\?]/g,nn=/[#\?@]/g,rn=/#/g;function on(t,e){this.b=this.a=null,this.c=t||null,this.f=!!e}function sn(t){t.a||(t.a=new Ue,t.b=0,t.c&&function(t,e){if(t){t=t.split("&");for(var n=0;n<t.length;n++){var i=t[n].indexOf("="),r=null;if(0<=i){var o=t[n].substring(0,i);r=t[n].substring(i+1)}else o=t[n];e(o,r?decodeURIComponent(r.replace(/\+/g," ")):"")}}}(t.c,function(e,n){t.add(decodeURIComponent(e.replace(/\+/g," ")),n)}))}function an(t){var e=Fe(t);if(void 0===e)throw Error("Keys are undefined");var n=new on(null,void 0);t=Le(t);for(var i=0;i<e.length;i++){var r=e[i],o=t[i];h(o)?hn(n,r,o):n.add(r,o)}return n}function un(t,e){sn(t),e=ln(t,e),We(t.a.b,e)&&(t.c=null,t.b-=t.a.get(e).length,We((t=t.a).b,e)&&(delete t.b[e],t.c--,t.a.length>2*t.c&&je(t)))}function cn(t,e){return sn(t),e=ln(t,e),We(t.a.b,e)}function hn(t,e,n){un(t,e),0<n.length&&(t.c=null,t.a.set(ln(t,e),B(n)),t.b+=n.length)}function ln(t,e){return e=String(e),t.f&&(e=e.toLowerCase()),e}(t=on.prototype).add=function(t,e){sn(this),this.c=null,t=ln(this,t);var n=this.a.get(t);return n||this.a.set(t,n=[]),n.push(e),this.b+=1,this},t.clear=function(){this.a=this.c=null,this.b=0},t.forEach=function(t,e){sn(this),this.a.forEach(function(n,i){x(n,function(n){t.call(e,n,i,this)},this)},this)},t.U=function(){sn(this);for(var t=this.a.S(),e=this.a.U(),n=[],i=0;i<e.length;i++)for(var r=t[i],o=0;o<r.length;o++)n.push(e[i]);return n},t.S=function(t){sn(this);var e=[];if(o(t))cn(this,t)&&(e=W(e,this.a.get(ln(this,t))));else{t=this.a.S();for(var n=0;n<t.length;n++)e=W(e,t[n])}return e},t.set=function(t,e){return sn(this),this.c=null,cn(this,t=ln(this,t))&&(this.b-=this.a.get(t).length),this.a.set(t,[e]),this.b+=1,this},t.get=function(t,e){return 0<(t=t?this.S(t):[]).length?String(t[0]):e},t.toString=function(){if(this.c)return this.c;if(!this.a)return"";for(var t=[],e=this.a.U(),n=0;n<e.length;n++){var i=e[n],r=encodeURIComponent(String(i));i=this.S(i);for(var o=0;o<i.length;o++){var s=r;""!==i[o]&&(s+="="+encodeURIComponent(String(i[o]))),t.push(s)}}return this.c=t.join("&")};var dn=!qt||9<=Number(Zt);function fn(){this.a="",this.b=vn}function pn(t){return t instanceof fn&&t.constructor===fn&&t.b===vn?t.a:(I("expected object of type Const, got '"+t+"'"),"type_error:Const")}fn.prototype.ma=!0,fn.prototype.la=function(){return this.a},fn.prototype.toString=function(){return"Const{"+this.a+"}"};var vn={};function gn(t){var e=new fn;return e.a=t,e}function yn(){this.a="",this.b=Cn}function mn(t){return t instanceof yn&&t.constructor===yn&&t.b===Cn?t.a:(I("expected object of type TrustedResourceUrl, got '"+t+"' of type "+u(t)),"type_error:TrustedResourceUrl")}function _n(t,e){var n=pn(t);if(!wn.test(n))throw Error("Invalid TrustedResourceUrl format: "+n);return function(t){var e=new yn;return e.a=t,e}(t=n.replace(bn,function(t,i){if(!Object.prototype.hasOwnProperty.call(e,i))throw Error('Found marker, "'+i+'", in format string, "'+n+'", but no valid label mapping found in args: '+JSON.stringify(e));return(t=e[i])instanceof fn?pn(t):encodeURIComponent(String(t))}))}gn(""),yn.prototype.ma=!0,yn.prototype.la=function(){return this.a},yn.prototype.toString=function(){return"TrustedResourceUrl{"+this.a+"}"};var bn=/%{(\w+)}/g,wn=/^(?:https:)?\/\/[0-9a-z.:[\]-]+\/|^\/[^\/\\]|^about:blank#/i,Cn={};function Tn(){this.a="",this.b=kn}function En(t){return t instanceof Tn&&t.constructor===Tn&&t.b===kn?t.a:(I("expected object of type SafeUrl, got '"+t+"' of type "+u(t)),"type_error:SafeUrl")}Tn.prototype.ma=!0,Tn.prototype.la=function(){return this.a},Tn.prototype.toString=function(){return"SafeUrl{"+this.a+"}"};var Sn=/^(?:(?:https?|mailto|ftp):|[^:/?#]*(?:[/?#]|$))/i;function In(t){return t instanceof Tn?t:(t=t.ma?t.la():String(t),Sn.test(t)||(t="about:invalid#zClosurez"),An(t))}var kn={};function An(t){var e=new Tn;return e.a=t,e}function Pn(){this.a="",this.b=Nn}An("about:blank"),Pn.prototype.ma=!0,Pn.prototype.la=function(){return this.a},Pn.prototype.toString=function(){return"SafeHtml{"+this.a+"}"};var Nn={};function Dn(t){var e=new Pn;return e.a=t,e}function Rn(t){var e=document;return o(t)?e.getElementById(t):t}function On(t,e){rt(e,function(e,n){e&&e.ma&&(e=e.la()),"style"==n?t.style.cssText=e:"class"==n?t.className=e:"for"==n?t.htmlFor=e:xn.hasOwnProperty(n)?t.setAttribute(xn[n],e):0==n.lastIndexOf("aria-",0)||0==n.lastIndexOf("data-",0)?t.setAttribute(n,e):t[n]=e})}Dn("<!DOCTYPE html>"),Dn(""),Dn("<br>");var xn={cellpadding:"cellPadding",cellspacing:"cellSpacing",colspan:"colSpan",frameborder:"frameBorder",height:"height",maxlength:"maxLength",nonce:"nonce",role:"role",rowspan:"rowSpan",type:"type",usemap:"useMap",valign:"vAlign",width:"width"};function Mn(t){if(t&&"number"==typeof t.length){if(f(t))return"function"==typeof t.item||"string"==typeof t.item;if(d(t))return"function"==typeof t.item}return!1}function Ln(t){var e=[];return function t(e,n,i){if(null==n)i.push("null");else{if("object"==typeof n){if(h(n)){var r=n;n=r.length,i.push("[");for(var o="",s=0;s<n;s++)i.push(o),t(e,r[s],i),o=",";return void i.push("]")}if(!(n instanceof String||n instanceof Number||n instanceof Boolean)){for(r in i.push("{"),o="",n)Object.prototype.hasOwnProperty.call(n,r)&&"function"!=typeof(s=n[r])&&(i.push(o),jn(r,i),i.push(":"),t(e,s,i),o=",");return void i.push("}")}n=n.valueOf()}switch(typeof n){case"string":jn(n,i);break;case"number":i.push(isFinite(n)&&!isNaN(n)?String(n):"null");break;case"boolean":i.push(String(n));break;case"function":i.push("null");break;default:throw Error("Unknown type: "+typeof n)}}}(new function(){},t,e),e.join("")}var Fn={'"':'\\"',"\\":"\\\\","/":"\\/","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\v":"\\u000b"},Un=/\uffff/.test("")?/[\\"\x00-\x1f\x7f-\uffff]/g:/[\\"\x00-\x1f\x7f-\xff]/g;function jn(t,e){e.push('"',t.replace(Un,function(t){var e=Fn[t];return e||(e="\\u"+(65536|t.charCodeAt(0)).toString(16).substr(1),Fn[t]=e),e}),'"')}function Wn(){var t=ri();return qt&&!!Zt&&11==Zt||/Edge\/\d+/.test(t)}function Bn(){return r.window&&r.window.location.href||self&&self.location&&self.location.href||""}function $n(t,e){e=e||r.window;var n="about:blank";t&&(n=En(In(t))),e.location.href=n}function Vn(t){return!!((t=(t||ri()).toLowerCase()).match(/android/)||t.match(/webos/)||t.match(/iphone|ipad|ipod/)||t.match(/blackberry/)||t.match(/windows phone/)||t.match(/iemobile/))}function qn(t){t=t||r.window;try{t.close()}catch(t){}}function Hn(t,e,n){var i=Math.floor(1e9*Math.random()).toString();e=e||500,n=n||600;var r=(window.screen.availHeight-n)/2,o=(window.screen.availWidth-e)/2;for(s in e={width:e,height:n,top:0<r?r:0,left:0<o?o:0,location:!0,resizable:!0,statusbar:!0,toolbar:!1},n=ri().toLowerCase(),i&&(e.target=i,Z(n,"crios/")&&(e.target="_blank")),ei(ri())==Zn&&(t=t||"http://localhost",e.scrollbars=!0),n=t||"",(t=e)||(t={}),i=window,e=n instanceof Tn?n:In(void 0!==n.href?n.href:String(n)),n=t.target||n.target,r=[],t)switch(s){case"width":case"height":case"top":case"left":r.push(s+"="+t[s]);break;case"target":case"noopener":case"noreferrer":break;default:r.push(s+"="+(t[s]?1:0))}var s=r.join(",");if((it("iPhone")&&!it("iPod")&&!it("iPad")||it("iPad")||it("iPod"))&&i.navigator&&i.navigator.standalone&&n&&"_self"!=n?(s=i.document.createElement("A"),e instanceof Tn||e instanceof Tn||(e=e.ma?e.la():String(e),Sn.test(e)||(e="about:invalid#zClosurez"),e=An(e)),s.href=En(e),s.setAttribute("target",n),t.noreferrer&&s.setAttribute("rel","noreferrer"),(t=document.createEvent("MouseEvent")).initMouseEvent("click",!0,!0,i,1),s.dispatchEvent(t),s={}):t.noreferrer?(s=i.open("",n,s),t=En(e),s&&(zt&&Z(t,";")&&(t="'"+t.replace(/'/g,"%27")+"'"),s.opener=null,gn("b/12014412, meta tag with sanitized URL"),t=Dn(t='<meta name="referrer" content="no-referrer"><meta http-equiv="refresh" content="0; url='+q(t)+'">'),s.document.write(function(t){return t instanceof Pn&&t.constructor===Pn&&t.b===Nn?t.a:(I("expected object of type SafeHtml, got '"+t+"' of type "+u(t)),"type_error:SafeHtml")}(t)),s.document.close())):(s=i.open(En(e),n,s))&&t.noopener&&(s.opener=null),s)try{s.focus()}catch(t){}return s}var zn=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;function Kn(){var t=null;return new gt(function(e){"complete"==r.document.readyState?e():(t=function(){e()},be(window,"load",t))}).s(function(e){throw we(window,"load",t),e})}function Qn(t){return t=t||ri(),!("file:"!==ci()||!t.toLowerCase().match(/iphone|ipad|ipod|android/))}function Yn(){var t=r.window;try{return!(!t||t==t.top)}catch(t){return!1}}function Gn(){return"object"!=typeof r.window&&"function"==typeof r.importScripts}function Xn(){return e.INTERNAL.hasOwnProperty("reactNative")?"ReactNative":e.INTERNAL.hasOwnProperty("node")?"Node":Gn()?"Worker":"Browser"}function Jn(){var t=Xn();return"ReactNative"===t||"Node"===t}var Zn="Firefox",ti="Chrome";function ei(t){var e=t.toLowerCase();return Z(e,"opera/")||Z(e,"opr/")||Z(e,"opios/")?"Opera":Z(e,"iemobile")?"IEMobile":Z(e,"msie")||Z(e,"trident/")?"IE":Z(e,"edge/")?"Edge":Z(e,"firefox/")?Zn:Z(e,"silk/")?"Silk":Z(e,"blackberry")?"Blackberry":Z(e,"webos")?"Webos":!Z(e,"safari/")||Z(e,"chrome/")||Z(e,"crios/")||Z(e,"android")?!Z(e,"chrome/")&&!Z(e,"crios/")||Z(e,"edge/")?Z(e,"android")?"Android":(t=t.match(/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/))&&2==t.length?t[1]:"Other":ti:"Safari"}var ni={Sc:"FirebaseCore-web",Uc:"FirebaseUI-web"};function ii(t,e){e=e||[];var n,i=[],r={};for(n in ni)r[ni[n]]=!0;for(n=0;n<e.length;n++)void 0!==r[e[n]]&&(delete r[e[n]],i.push(e[n]));return i.sort(),(e=i).length||(e=["FirebaseCore-web"]),"Browser"===(i=Xn())?i=ei(r=ri()):"Worker"===i&&(i=ei(r=ri())+"-"+i),i+"/JsCore/"+t+"/"+e.join(",")}function ri(){return r.navigator&&r.navigator.userAgent||""}function oi(t,e){t=t.split("."),e=e||r;for(var n=0;n<t.length&&"object"==typeof e&&null!=e;n++)e=e[t[n]];return n!=t.length&&(e=void 0),e}function si(){try{var t=r.localStorage,e=pi();if(t)return t.setItem(e,"1"),t.removeItem(e),!Wn()||!!r.indexedDB}catch(t){return Gn()&&!!r.indexedDB}return!1}function ai(){return(ui()||"chrome-extension:"===ci()||Qn())&&!Jn()&&si()&&!Gn()}function ui(){return"http:"===ci()||"https:"===ci()}function ci(){return r.location&&r.location.protocol||null}function hi(t){return!Vn(t=t||ri())&&ei(t)!=Zn}function li(t){return void 0===t?null:Ln(t)}function di(t){var e,n={};for(e in t)t.hasOwnProperty(e)&&null!==t[e]&&void 0!==t[e]&&(n[e]=t[e]);return n}function fi(t){if(null!==t)return JSON.parse(t)}function pi(t){return t||Math.floor(1e9*Math.random()).toString()}function vi(t){return"Safari"!=ei(t=t||ri())&&!t.toLowerCase().match(/iphone|ipad|ipod/)}function gi(){var t=r.___jsl;if(t&&t.H)for(var e in t.H)if(t.H[e].r=t.H[e].r||[],t.H[e].L=t.H[e].L||[],t.H[e].r=t.H[e].L.concat(),t.CP)for(var n=0;n<t.CP.length;n++)t.CP[n]=null}function yi(t,e){if(t>e)throw Error("Short delay should be less than long delay!");this.a=t,this.c=e,t=ri(),e=Xn(),this.b=Vn(t)||"ReactNative"===e}function mi(){var t=r.document;return!t||void 0===t.visibilityState||"visible"==t.visibilityState}function _i(t){try{var e=new Date(parseInt(t,10));if(!isNaN(e.getTime())&&!/[^0-9]/.test(t))return e.toUTCString()}catch(t){}return null}function bi(){return!(!oi("fireauth.oauthhelper",r)&&!oi("fireauth.iframe",r))}yi.prototype.get=function(){var t=r.navigator;return!t||"boolean"!=typeof t.onLine||!ui()&&"chrome-extension:"!==ci()&&void 0===t.connection||t.onLine?this.b?this.c:this.a:Math.min(5e3,this.a)};var wi,Ci={};function Ti(t){Ci[t]||(Ci[t]=!0,"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn(t))}try{var Ei={};Object.defineProperty(Ei,"abcd",{configurable:!0,enumerable:!0,value:1}),Object.defineProperty(Ei,"abcd",{configurable:!0,enumerable:!0,value:2}),wi=2==Ei.abcd}catch($t){wi=!1}function Si(t,e,n){wi?Object.defineProperty(t,e,{configurable:!0,enumerable:!0,value:n}):t[e]=n}function Ii(t,e){if(e)for(var n in e)e.hasOwnProperty(n)&&Si(t,n,e[n])}function ki(t){var e={};return Ii(e,t),e}function Ai(t){var e=t;if("object"==typeof t&&null!=t)for(var n in e="length"in t?[]:{},t)Si(e,n,Ai(t[n]));return e}function Pi(t,e){this.code=Di+t,this.message=e||Ri[t]||""}function Ni(t){var e=t&&t.code;return e?new Pi(e.substring(Di.length),t.message):null}w(Pi,Error),Pi.prototype.D=function(){return{code:this.code,message:this.message}},Pi.prototype.toJSON=function(){return this.D()};var Di="auth/",Ri={"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."};function Oi(t){var e=t[Fi];if(void 0===e)throw new Pi("missing-continue-uri");if("string"!=typeof e||"string"==typeof e&&!e.length)throw new Pi("invalid-continue-uri");this.h=e,this.b=this.a=null,this.g=!1;var n=t[xi];if(n&&"object"==typeof n){e=n[Wi];var i=n[Ui];if(n=n[ji],"string"==typeof e&&e.length){if(this.a=e,void 0!==i&&"boolean"!=typeof i)throw new Pi("argument-error",Ui+" property must be a boolean when specified.");if(this.g=!!i,void 0!==n&&("string"!=typeof n||"string"==typeof n&&!n.length))throw new Pi("argument-error",ji+" property must be a non empty string when specified.");this.b=n||null}else{if(void 0!==e)throw new Pi("argument-error",Wi+" property must be a non empty string when specified.");if(void 0!==i||void 0!==n)throw new Pi("missing-android-pkg-name")}}else if(void 0!==n)throw new Pi("argument-error",xi+" property must be a non null object when specified.");if(this.f=null,(e=t[Li])&&"object"==typeof e){if("string"==typeof(e=e[Bi])&&e.length)this.f=e;else if(void 0!==e)throw new Pi("argument-error",Bi+" property must be a non empty string when specified.")}else if(void 0!==e)throw new Pi("argument-error",Li+" property must be a non null object when specified.");if(void 0!==(t=t[Mi])&&"boolean"!=typeof t)throw new Pi("argument-error",Mi+" property must be a boolean when specified.");this.c=!!t}var xi="android",Mi="handleCodeInApp",Li="iOS",Fi="url",Ui="installApp",ji="minimumVersion",Wi="packageName",Bi="bundleId";function $i(t){var e={};for(var n in e.continueUrl=t.h,e.canHandleCodeInApp=t.c,(e.androidPackageName=t.a)&&(e.androidMinimumVersion=t.b,e.androidInstallApp=t.g),e.iOSBundleId=t.f,e)null===e[n]&&delete e[n];return e}var Vi=null,qi=null;function Hi(t){this.c=t.sub,b(),this.a=t.provider_id||t.firebase&&t.firebase.sign_in_provider||null,this.b=!!t.is_anonymous||"anonymous"==this.a}function zi(t){return(t=Ki(t))&&t.sub&&t.iss&&t.aud&&t.exp?new Hi(t):null}function Ki(t){if(!t)return null;if(3!=(t=t.split(".")).length)return null;for(var e=(4-(t=t[1]).length%4)%4,n=0;n<e;n++)t+=".";try{return JSON.parse(function(t){var e="";return function(t,e){function n(e){for(;i<t.length;){var n=t.charAt(i++),r=qi[n];if(null!=r)return r;if(!/^[\s\xa0]*$/.test(n))throw Error("Unknown base64 encoding at char: "+n)}return e}!function(){if(!Vi){Vi={},qi={};for(var t=0;65>t;t++)Vi[t]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(t),qi[Vi[t]]=t,62<=t&&(qi["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.".charAt(t)]=t)}}();for(var i=0;;){var r=n(-1),o=n(0),s=n(64),a=n(64);if(64===a&&-1===r)break;e(r<<2|o>>4),64!=s&&(e(o<<4&240|s>>2),64!=a&&e(s<<6&192|a))}}(t,function(t){e+=String.fromCharCode(t)}),e}(t))}catch(t){}return null}Hi.prototype.f=function(){return this.b};var Qi="oauth_consumer_key oauth_nonce oauth_signature oauth_signature_method oauth_timestamp oauth_token oauth_version".split(" "),Yi=["client_id","response_type","scope","redirect_uri","state"],Gi={Tc:{Ma:"locale",Ba:500,Aa:600,Na:"facebook.com",eb:Yi},Vc:{Ma:null,Ba:500,Aa:620,Na:"github.com",eb:Yi},Wc:{Ma:"hl",Ba:515,Aa:680,Na:"google.com",eb:Yi},bd:{Ma:"lang",Ba:485,Aa:705,Na:"twitter.com",eb:Qi}};function Xi(t){for(var e in Gi)if(Gi[e].Na==t)return Gi[e];return null}function Ji(t){var e={};e["facebook.com"]=ir,e["google.com"]=or,e["github.com"]=rr,e["twitter.com"]=sr;var n=t&&t[tr];try{if(n)return e[n]?new e[n](t):new nr(t);if(void 0!==t[Zi])return new er(t)}catch(t){}return null}var Zi="idToken",tr="providerId";function er(t){var e=t[tr];if(!e&&t[Zi]){var n=zi(t[Zi]);n&&n.a&&(e=n.a)}if(!e)throw Error("Invalid additional user info!");"anonymous"!=e&&"custom"!=e||(e=null),n=!1,void 0!==t.isNewUser?n=!!t.isNewUser:"identitytoolkit#SignupNewUserResponse"===t.kind&&(n=!0),Si(this,"providerId",e),Si(this,"isNewUser",n)}function nr(t){er.call(this,t),Si(this,"profile",Ai((t=fi(t.rawUserInfo||"{}"))||{}))}function ir(t){if(nr.call(this,t),"facebook.com"!=this.providerId)throw Error("Invalid provider ID!")}function rr(t){if(nr.call(this,t),"github.com"!=this.providerId)throw Error("Invalid provider ID!");Si(this,"username",this.profile&&this.profile.login||null)}function or(t){if(nr.call(this,t),"google.com"!=this.providerId)throw Error("Invalid provider ID!")}function sr(t){if(nr.call(this,t),"twitter.com"!=this.providerId)throw Error("Invalid provider ID!");Si(this,"username",t.screenName||null)}function ar(t){var e=Qe(t),n=Ke(e,"link"),i=Ke(Qe(n),"link");return Ke(Qe(e=Ke(e,"deep_link_id")),"link")||e||i||n||t}function ur(t,e){return t.then(function(t){if(t[$o]){var n=zi(t[$o]);if(!n||e!=n.c)throw new Pi("user-mismatch");return t}throw new Pi("user-mismatch")}).s(function(t){throw t&&t.code&&t.code==Di+"user-not-found"?new Pi("user-mismatch"):t})}function cr(t,e,n){if(e.idToken||e.accessToken)e.idToken&&Si(this,"idToken",e.idToken),e.accessToken&&Si(this,"accessToken",e.accessToken);else{if(!e.oauthToken||!e.oauthTokenSecret)throw new Pi("internal-error","failed to construct a credential");Si(this,"accessToken",e.oauthToken),Si(this,"secret",e.oauthTokenSecret)}Si(this,"providerId",t),Si(this,"signInMethod",n)}function hr(t){var e={};return t.idToken&&(e.id_token=t.idToken),t.accessToken&&(e.access_token=t.accessToken),t.secret&&(e.oauth_token_secret=t.secret),e.providerId=t.providerId,{postBody:an(e).toString(),requestUri:"http://localhost"}}function lr(t,e){this.Ac=e||[],Ii(this,{providerId:t,isOAuthProvider:!0}),this.vb={},this.$a=(Xi(t)||{}).Ma||null,this.Ya=null}function dr(t){lr.call(this,t,Yi),this.a=[]}function fr(){dr.call(this,"facebook.com")}function pr(t){if(!t)throw new Pi("argument-error","credential failed: expected 1 argument (the OAuth access token).");var e=t;return f(t)&&(e=t.accessToken),(new fr).credential(null,e)}function vr(){dr.call(this,"github.com")}function gr(t){if(!t)throw new Pi("argument-error","credential failed: expected 1 argument (the OAuth access token).");var e=t;return f(t)&&(e=t.accessToken),(new vr).credential(null,e)}function yr(){dr.call(this,"google.com"),this.ta("profile")}function mr(t,e){var n=t;return f(t)&&(n=t.idToken,e=t.accessToken),(new yr).credential(n,e)}function _r(){lr.call(this,"twitter.com",Qi)}function br(t,e){var n=t;if(f(n)||(n={oauthToken:t,oauthTokenSecret:e}),!n.oauthToken||!n.oauthTokenSecret)throw new Pi("argument-error","credential failed: expected 2 arguments (the OAuth access token and secret).");return new cr("twitter.com",n,"twitter.com")}function wr(t,e,n){this.a=t,this.b=e,Si(this,"providerId","password"),Si(this,"signInMethod",n===Cr.EMAIL_LINK_SIGN_IN_METHOD?Cr.EMAIL_LINK_SIGN_IN_METHOD:Cr.EMAIL_PASSWORD_SIGN_IN_METHOD)}function Cr(){Ii(this,{providerId:"password",isOAuthProvider:!1})}function Tr(t,e){if(!(e=Er(e)))throw new Pi("argument-error","Invalid email link!");return new wr(t,e,Cr.EMAIL_LINK_SIGN_IN_METHOD)}function Er(t){var e=Ke((t=new function(t){this.a=Qe(t)}(t=ar(t))).a,"oobCode")||null;return"signIn"===(Ke(t.a,"mode")||null)&&e?e:null}function Sr(t){if(!(t.Sa&&t.Ra||t.Fa&&t.$))throw new Pi("internal-error");this.a=t,Si(this,"providerId","phone"),Si(this,"signInMethod","phone")}function Ir(t){return t.a.Fa&&t.a.$?{temporaryProof:t.a.Fa,phoneNumber:t.a.$}:{sessionInfo:t.a.Sa,code:t.a.Ra}}function kr(t){try{this.a=t||e.auth()}catch(t){throw new Pi("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().")}Ii(this,{providerId:"phone",isOAuthProvider:!1})}function Ar(t,e){if(!t)throw new Pi("missing-verification-id");if(!e)throw new Pi("missing-verification-code");return new Sr({Sa:t,Ra:e})}function Pr(t){if(t.temporaryProof&&t.phoneNumber)return new Sr({Fa:t.temporaryProof,$:t.phoneNumber});var e=t&&t.providerId;if(!e||"password"===e)return null;var n=t&&t.oauthAccessToken,i=t&&t.oauthTokenSecret;t=t&&t.oauthIdToken;try{switch(e){case"google.com":return mr(t,n);case"facebook.com":return pr(n);case"github.com":return gr(n);case"twitter.com":return br(n,i);default:return new dr(e).credential(t,n)}}catch(t){return null}}function Nr(t){if(!t.isOAuthProvider)throw new Pi("invalid-oauth-provider")}function Dr(t,e,n,i,r){if(this.b=t,this.c=e||null,this.f=n||null,this.g=i||null,this.a=r||null,!this.f&&!this.a)throw new Pi("invalid-auth-event");if(this.f&&this.a)throw new Pi("invalid-auth-event");if(this.f&&!this.g)throw new Pi("invalid-auth-event")}function Rr(t){return(t=t||{}).type?new Dr(t.type,t.eventId,t.urlResponse,t.sessionId,t.error&&Ni(t.error)):null}function Or(){this.b=null,this.a=[]}w(nr,er),w(ir,nr),w(rr,nr),w(or,nr),w(sr,nr),cr.prototype.ya=function(t){return os(t,hr(this))},cr.prototype.c=function(t,e){var n=hr(this);return n.idToken=e,ss(t,n)},cr.prototype.f=function(t,e){return ur(as(t,hr(this)),e)},cr.prototype.D=function(){var t={providerId:this.providerId,signInMethod:this.signInMethod};return this.idToken&&(t.oauthIdToken=this.idToken),this.accessToken&&(t.oauthAccessToken=this.accessToken),this.secret&&(t.oauthTokenSecret=this.secret),t},lr.prototype.Da=function(t){return this.vb=st(t),this},w(dr,lr),dr.prototype.ta=function(t){return F(this.a,t)||this.a.push(t),this},dr.prototype.Ab=function(){return B(this.a)},dr.prototype.credential=function(t,e){if(!t&&!e)throw new Pi("argument-error","credential failed: must provide the ID token and/or the access token.");return new cr(this.providerId,{idToken:t||null,accessToken:e||null},this.providerId)},w(fr,dr),Si(fr,"PROVIDER_ID","facebook.com"),Si(fr,"FACEBOOK_SIGN_IN_METHOD","facebook.com"),w(vr,dr),Si(vr,"PROVIDER_ID","github.com"),Si(vr,"GITHUB_SIGN_IN_METHOD","github.com"),w(yr,dr),Si(yr,"PROVIDER_ID","google.com"),Si(yr,"GOOGLE_SIGN_IN_METHOD","google.com"),w(_r,lr),Si(_r,"PROVIDER_ID","twitter.com"),Si(_r,"TWITTER_SIGN_IN_METHOD","twitter.com"),wr.prototype.ya=function(t){return this.signInMethod==Cr.EMAIL_LINK_SIGN_IN_METHOD?Ls(t,vs,{email:this.a,oobCode:this.b}):Ls(t,Rs,{email:this.a,password:this.b})},wr.prototype.c=function(t,e){return this.signInMethod==Cr.EMAIL_LINK_SIGN_IN_METHOD?Ls(t,gs,{idToken:e,email:this.a,oobCode:this.b}):Ls(t,Is,{idToken:e,email:this.a,password:this.b})},wr.prototype.f=function(t,e){return ur(this.ya(t),e)},wr.prototype.D=function(){return{email:this.a,password:this.b,signInMethod:this.signInMethod}},Ii(Cr,{PROVIDER_ID:"password"}),Ii(Cr,{EMAIL_LINK_SIGN_IN_METHOD:"emailLink"}),Ii(Cr,{EMAIL_PASSWORD_SIGN_IN_METHOD:"password"}),Sr.prototype.ya=function(t){return t.Ta(Ir(this))},Sr.prototype.c=function(t,e){var n=Ir(this);return n.idToken=e,Ls(t,xs,n)},Sr.prototype.f=function(t,e){var n=Ir(this);return n.operation="REAUTH",ur(t=Ls(t,Ms,n),e)},Sr.prototype.D=function(){var t={providerId:"phone"};return this.a.Sa&&(t.verificationId=this.a.Sa),this.a.Ra&&(t.verificationCode=this.a.Ra),this.a.Fa&&(t.temporaryProof=this.a.Fa),this.a.$&&(t.phoneNumber=this.a.$),t},kr.prototype.Ta=function(t,e){var n=this.a.b;return Tt(e.verify()).then(function(i){if(!o(i))throw new Pi("argument-error","An implementation of firebase.auth.ApplicationVerifier.prototype.verify() must return a firebase.Promise that resolves with a string.");switch(e.type){case"recaptcha":return function(t,e){return Ls(n,Es,e)}(0,{phoneNumber:t,recaptchaToken:i}).then(function(t){return"function"==typeof e.reset&&e.reset(),t},function(t){throw"function"==typeof e.reset&&e.reset(),t});default:throw new Pi("argument-error",'Only firebase.auth.ApplicationVerifiers with type="recaptcha" are currently supported.')}})},Ii(kr,{PROVIDER_ID:"phone"}),Ii(kr,{PHONE_SIGN_IN_METHOD:"phone"}),Dr.prototype.D=function(){return{type:this.b,eventId:this.c,urlResponse:this.f,sessionId:this.g,error:this.a&&this.a.D()}};var xr=null;function Mr(t){var e="unauthorized-domain",n=void 0,i=Qe(t);t=i.b,"chrome-extension"==(i=i.c)?n=$("This chrome extension ID (chrome-extension://%s) is not authorized to run this operation. Add it to the OAuth redirect domains list in the Firebase console -> Auth section -> Sign in method tab.",t):"http"==i||"https"==i?n=$("This domain (%s) is not authorized to run this operation. Add it to the OAuth redirect domains list in the Firebase console -> Auth section -> Sign in method tab.",t):e="operation-not-supported-in-this-environment",Pi.call(this,e,n)}function Lr(t,e,n){Pi.call(this,t,n),(t=e||{}).wb&&Si(this,"email",t.wb),t.$&&Si(this,"phoneNumber",t.$),t.credential&&Si(this,"credential",t.credential)}function Fr(t){if(t.code){var e=t.code||"";0==e.indexOf(Di)&&(e=e.substring(Di.length));var n={credential:Pr(t)};if(t.email)n.wb=t.email;else{if(!t.phoneNumber)return new Pi(e,t.message||void 0);n.$=t.phoneNumber}return new Lr(e,n,t.message)}return null}Or.prototype.subscribe=function(t){var e=this;this.a.push(t),this.b||(this.b=function(t){for(var n=0;n<e.a.length;n++)e.a[n](t)},"function"==typeof(t=oi("universalLinks.subscribe",r))&&t(null,this.b))},Or.prototype.unsubscribe=function(t){j(this.a,function(e){return e==t})},w(Mr,Pi),w(Lr,Pi),Lr.prototype.D=function(){var t={code:this.code,message:this.message};this.email&&(t.email=this.email),this.phoneNumber&&(t.phoneNumber=this.phoneNumber);var e=this.credential&&this.credential.D();return e&&ht(t,e),t},Lr.prototype.toJSON=function(){return this.D()};var Ur,jr=/^[+a-zA-Z0-9_.!#$%&'*\/=?^`{|}~-]+@([a-zA-Z0-9-]+\.)+[a-zA-Z0-9]{2,63}$/;function Wr(){}function Br(t){return t.c||(t.c=t.b())}function $r(){}function Vr(t){if(!t.f&&"undefined"==typeof XMLHttpRequest&&"undefined"!=typeof ActiveXObject){for(var e=["MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"],n=0;n<e.length;n++){var i=e[n];try{return new ActiveXObject(i),t.f=i}catch(t){}}throw Error("Could not create ActiveXObject. ActiveX might be disabled, or MSXML might not be installed")}return t.f}function qr(){}function Hr(){this.a=new XDomainRequest,this.readyState=0,this.onreadystatechange=null,this.responseText="",this.status=-1,this.statusText="",this.a.onload=m(this.bc,this),this.a.onerror=m(this.Bb,this),this.a.onprogress=m(this.cc,this),this.a.ontimeout=m(this.fc,this)}function zr(t,e){t.readyState=e,t.onreadystatechange&&t.onreadystatechange()}function Kr(t,e,n){this.reset(t,e,n,void 0,void 0)}function Qr(t){this.f=t,this.b=this.c=this.a=null}function Yr(t,e){this.name=t,this.value=e}Wr.prototype.c=null,w($r,Wr),$r.prototype.a=function(){var t=Vr(this);return t?new ActiveXObject(t):new XMLHttpRequest},$r.prototype.b=function(){var t={};return Vr(this)&&(t[0]=!0,t[1]=!0),t},Ur=new $r,w(qr,Wr),qr.prototype.a=function(){var t=new XMLHttpRequest;if("withCredentials"in t)return t;if("undefined"!=typeof XDomainRequest)return new Hr;throw Error("Unsupported browser")},qr.prototype.b=function(){return{}},(t=Hr.prototype).open=function(t,e,n){if(null!=n&&!n)throw Error("Only async requests are supported.");this.a.open(t,e)},t.send=function(t){if(t){if("string"!=typeof t)throw Error("Only string data is supported");this.a.send(t)}else this.a.send()},t.abort=function(){this.a.abort()},t.setRequestHeader=function(){},t.getResponseHeader=function(t){return"content-type"==t.toLowerCase()?this.a.contentType:""},t.bc=function(){this.status=200,this.responseText=this.a.responseText,zr(this,4)},t.Bb=function(){this.status=500,this.responseText="",zr(this,4)},t.fc=function(){this.Bb()},t.cc=function(){this.status=200,zr(this,1)},t.getAllResponseHeaders=function(){return"content-type: "+this.a.contentType},Kr.prototype.a=null,Kr.prototype.reset=function(t,e,n,i,r){i||b(),delete this.a},Yr.prototype.toString=function(){return this.name};var Gr=new Yr("SEVERE",1e3),Xr=new Yr("WARNING",900),Jr=new Yr("CONFIG",700),Zr=new Yr("FINE",500);Qr.prototype.log=function(t,e,n){if(t.value>=function t(e){return e.c?e.c:e.a?t(e.a):(I("Root logger has no level set."),null)}(this).value)for(d(e)&&(e=e()),t=new Kr(t,String(e),this.f),n&&(t.a=n),n=this;n;)n=n.a};var to={},eo=null;function no(t){var e;if(eo||(eo=new Qr(""),to[""]=eo,eo.c=Jr),!(e=to[t])){e=new Qr(t);var n=t.lastIndexOf("."),i=t.substr(n+1);(n=no(t.substr(0,n))).b||(n.b={}),n.b[i]=e,e.a=n,to[t]=e}return e}function io(t,e){t&&t.log(Zr,e,void 0)}function ro(t){this.f=t}function oo(t){Ne.call(this),this.i=t,this.readyState=so,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=no("goog.net.FetchXmlHttp")}w(ro,Wr),ro.prototype.a=function(){return new oo(this.f)},ro.prototype.b=function(t){return function(){return t}}({}),w(oo,Ne);var so=0;function ao(t){t.onreadystatechange&&t.onreadystatechange.call(t)}function uo(t){Ne.call(this),this.headers=new Ue,this.C=t||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=co,this.v=this.O=!1}(t=oo.prototype).open=function(t,e){if(this.readyState!=so)throw this.abort(),Error("Error reopening a connection");this.h=t,this.c=e,this.readyState=1,ao(this)},t.send=function(t){if(1!=this.readyState)throw this.abort(),Error("need to call open() first. ");this.a=!0;var e={headers:this.g,method:this.h,credentials:void 0,cache:void 0};t&&(e.body=t),this.i.fetch(new Request(this.c,e)).then(this.ec.bind(this),this.Cb.bind(this))},t.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,ao(this)),this.readyState=so},t.ec=function(t){this.a&&(this.b||(this.b=t.headers,this.readyState=2,ao(this)),this.a&&(this.readyState=3,ao(this),this.a&&t.text().then(this.dc.bind(this,t),this.Cb.bind(this))))},t.dc=function(t,e){this.a&&(this.status=t.status,this.statusText=t.statusText,this.responseText=e,this.readyState=4,ao(this))},t.Cb=function(t){var e=this.f;e&&e.log(Xr,"Failed to fetch url "+this.c,t instanceof Error?t:Error(t)),this.a&&(this.readyState=4,ao(this))},t.setRequestHeader=function(t,e){this.g.append(t,e)},t.getResponseHeader=function(t){return this.b?this.b.get(t.toLowerCase())||"":((t=this.f)&&t.log(Xr,"Attempting to get response header but no headers have been received for url: "+this.c,void 0),"")},t.getAllResponseHeaders=function(){if(!this.b){var t=this.f;return t&&t.log(Xr,"Attempting to get all response headers but no headers have been received for url: "+this.c,void 0),""}t=[];for(var e=this.b.entries(),n=e.next();!n.done;)n=n.value,t.push(n[0]+": "+n[1]),n=e.next();return t.join("\r\n")},w(uo,Ne);var co="";uo.prototype.b=no("goog.net.XhrIo");var ho=/^https?$/i,lo=["POST","PUT"];function fo(t,e,n,i,s){if(t.a)throw Error("[goog.net.XhrIo] Object is active with another request="+t.l+"; newUri="+e);n=n?n.toUpperCase():"GET",t.l=e,t.h="",t.N=n,t.G=!1,t.c=!0,t.a=t.C?t.C.a():Ur.a(),t.w=t.C?Br(t.C):Br(Ur),t.a.onreadystatechange=m(t.Fb,t);try{io(t.b,Co(t,"Opening Xhr")),t.I=!0,t.a.open(n,String(e),!0),t.I=!1}catch(e){return io(t.b,Co(t,"Error opening Xhr: "+e.message)),void vo(t,e)}e=i||"";var a=new Ue(t.headers);s&&function(t,e){if(t.forEach&&"function"==typeof t.forEach)t.forEach(e,void 0);else if(l(t)||o(t))x(t,e,void 0);else for(var n=Fe(t),i=Le(t),r=i.length,s=0;s<r;s++)e.call(void 0,i[s],n&&n[s],t)}(s,function(t,e){a.set(e,t)}),s=function(t){t:{for(var e=po,n=t.length,i=o(t)?t.split(""):t,r=0;r<n;r++)if(r in i&&e.call(void 0,i[r],r,t)){e=r;break t}e=-1}return 0>e?null:o(t)?t.charAt(e):t[e]}(a.U()),i=r.FormData&&e instanceof r.FormData,!F(lo,n)||s||i||a.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8"),a.forEach(function(t,e){this.a.setRequestHeader(e,t)},t),t.o&&(t.a.responseType=t.o),"withCredentials"in t.a&&t.a.withCredentials!==t.O&&(t.a.withCredentials=t.O);try{_o(t),0<t.g&&(t.v=function(t){return qt&&ee(9)&&"number"==typeof t.timeout&&void 0!==t.ontimeout}(t.a),io(t.b,Co(t,"Will abort after "+t.g+"ms if incomplete, xhr2 "+t.v)),t.v?(t.a.timeout=t.g,t.a.ontimeout=m(t.Ga,t)):t.u=xe(t.Ga,t.g,t)),io(t.b,Co(t,"Sending request")),t.i=!0,t.a.send(e),t.i=!1}catch(e){io(t.b,Co(t,"Send error: "+e.message)),vo(t,e)}}function po(t){return"content-type"==t.toLowerCase()}function vo(t,e){t.c=!1,t.a&&(t.f=!0,t.a.abort(),t.f=!1),t.h=e,go(t),mo(t)}function go(t){t.G||(t.G=!0,t.dispatchEvent("complete"),t.dispatchEvent("error"))}function yo(t){if(t.c&&void 0!==i)if(t.w[1]&&4==bo(t)&&2==wo(t))io(t.b,Co(t,"Local request error detected and ignored"));else if(t.i&&4==bo(t))xe(t.Fb,0,t);else if(t.dispatchEvent("readystatechange"),4==bo(t)){io(t.b,Co(t,"Request complete")),t.c=!1;try{var e,n=wo(t);t:switch(n){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var o=!0;break t;default:o=!1}if(!(e=o)){var s;if(s=0===n){var a=String(t.l).match(Be)[1]||null;if(!a&&r.self&&r.self.location){var u=r.self.location.protocol;a=u.substr(0,u.length-1)}s=!ho.test(a?a.toLowerCase():"")}e=s}if(e)t.dispatchEvent("complete"),t.dispatchEvent("success");else{try{var c=2<bo(t)?t.a.statusText:""}catch(e){io(t.b,"Can not get status: "+e.message),c=""}t.h=c+" ["+wo(t)+"]",go(t)}}finally{mo(t)}}}function mo(t,e){if(t.a){_o(t);var n=t.a,i=t.w[0]?a:null;t.a=null,t.w=null,e||t.dispatchEvent("ready");try{n.onreadystatechange=i}catch(e){(t=t.b)&&t.log(Gr,"Problem encountered resetting onreadystatechange: "+e.message,void 0)}}}function _o(t){t.a&&t.v&&(t.a.ontimeout=null),t.u&&(r.clearTimeout(t.u),t.u=null)}function bo(t){return t.a?t.a.readyState:0}function wo(t){try{return 2<bo(t)?t.a.status:-1}catch(t){return-1}}function Co(t,e){return e+" ["+t.N+" "+t.l+" "+wo(t)+"]"}function To(t,e){this.g=[],this.v=t,this.u=e||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 Eo(t,e,n){t.a=!0,t.c=n,t.f=!e,Ao(t)}function So(t){if(t.a){if(!t.l)throw new Po(t);t.l=!1}}function Io(t,e,n,i){t.g.push([e,n,i]),t.a&&Ao(t)}function ko(t){return L(t.g,function(t){return d(t[1])})}function Ao(t){if(t.h&&t.a&&ko(t)){var e=t.h,n=Ro[e];n&&(r.clearTimeout(n.a),delete Ro[e]),t.h=0}t.b&&(t.b.m--,delete t.b),e=t.c;for(var i=n=!1;t.g.length&&!t.i;){var o=t.g.shift(),s=o[0],a=o[1];if(o=o[2],s=t.f?a:s)try{var u=s.call(o||t.u,e);void 0!==u&&(t.f=t.f&&(u==e||u instanceof Error),t.c=e=u),(T(e)||"function"==typeof r.Promise&&e instanceof r.Promise)&&(i=!0,t.i=!0)}catch(i){e=i,t.f=!0,ko(t)||(n=!0)}}t.c=e,i&&(u=m(t.o,t,!0),i=m(t.o,t,!1),e instanceof To?(Io(e,u,i),e.w=!0):e.then(u,i)),n&&(e=new Do(e),Ro[e.a]=e,t.h=e.a)}function Po(){E.call(this)}function No(){E.call(this)}function Do(t){this.a=r.setTimeout(m(this.c,this),0),this.b=t}(t=uo.prototype).Ga=function(){void 0!==i&&this.a&&(this.h="Timed out after "+this.g+"ms, aborting",io(this.b,Co(this,this.h)),this.dispatchEvent("timeout"),this.abort(8))},t.abort=function(){this.a&&this.c&&(io(this.b,Co(this,"Aborting")),this.c=!1,this.f=!0,this.a.abort(),this.f=!1,this.dispatchEvent("complete"),this.dispatchEvent("abort"),mo(this))},t.ua=function(){this.a&&(this.c&&(this.c=!1,this.f=!0,this.a.abort(),this.f=!1),mo(this,!0)),uo.lb.ua.call(this)},t.Fb=function(){this.pa||(this.I||this.i||this.f?yo(this):this.tc())},t.tc=function(){yo(this)},t.getResponse=function(){try{if(!this.a)return null;if("response"in this.a)return this.a.response;switch(this.o){case co:case"text":return this.a.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in this.a)return this.a.mozResponseArrayBuffer}var t=this.b;return t&&t.log(Gr,"Response type "+this.o+" is not supported on this browser",void 0),null}catch(t){return io(this.b,"Can not get response: "+t.message),null}},To.prototype.cancel=function(t){if(this.a)this.c instanceof To&&this.c.cancel();else{if(this.b){var e=this.b;delete this.b,t?e.cancel(t):(e.m--,0>=e.m&&e.cancel())}this.v?this.v.call(this.u,this):this.l=!0,this.a||(t=new No(this),So(this),Eo(this,!1,t))}},To.prototype.o=function(t,e){this.i=!1,Eo(this,t,e)},To.prototype.C=function(){So(this),Eo(this,!0,null)},To.prototype.then=function(t,e,n){var i,r,o=new gt(function(t,e){i=t,r=e});return Io(this,i,function(t){t instanceof No?o.cancel():r(t)}),o.then(t,e,n)},C(To),w(Po,E),Po.prototype.message="Deferred has already fired",Po.prototype.name="AlreadyCalledError",w(No,E),No.prototype.message="Deferred was canceled",No.prototype.name="CanceledError",Do.prototype.c=function(){throw delete Ro[this.a],this.b};var Ro={};function Oo(t){var e={},n=e.document||document,i=mn(t),r=document.createElement("SCRIPT"),o={Hb:r,Ga:void 0},s=new To(xo,o),a=null,u=null!=e.timeout?e.timeout:5e3;return 0<u&&(a=window.setTimeout(function(){Mo(r,!0);var t=new Uo(Fo,"Timeout reached for loading script "+i);So(s),Eo(s,!1,t)},u),o.Ga=a),r.onload=r.onreadystatechange=function(){r.readyState&&"loaded"!=r.readyState&&"complete"!=r.readyState||(Mo(r,e.dd||!1,a),s.C())},r.onerror=function(){Mo(r,!0,a);var t=new Uo(Lo,"Error while loading script "+i);So(s),Eo(s,!1,t)},ht(o=e.attributes||{},{type:"text/javascript",charset:"UTF-8"}),On(r,o),r.src=mn(t),function(t){var e;return(e=(t||document).getElementsByTagName("HEAD"))&&0!=e.length?e[0]:t.documentElement}(n).appendChild(r),s}function xo(){if(this&&this.Hb){var t=this.Hb;t&&"SCRIPT"==t.tagName&&Mo(t,!0,this.Ga)}}function Mo(t,e,n){null!=n&&r.clearTimeout(n),t.onload=a,t.onerror=a,t.onreadystatechange=a,e&&window.setTimeout(function(){t&&t.parentNode&&t.parentNode.removeChild(t)},0)}var Lo=0,Fo=1;function Uo(t,e){var n="Jsloader error (code #"+t+")";e&&(n+=": "+e),E.call(this,n),this.code=t}function jo(t){this.f=t}function Wo(t,n,i){if(this.b=t,t=n||{},this.i=t.secureTokenEndpoint||"https://securetoken.googleapis.com/v1/token",this.m=t.secureTokenTimeout||Vo,this.f=st(t.secureTokenHeaders||qo),this.g=t.firebaseEndpoint||"https://www.googleapis.com/identitytoolkit/v3/relyingparty/",this.h=t.firebaseTimeout||Ho,this.a=st(t.firebaseHeaders||zo),i&&(this.a["X-Client-Version"]=i,this.f["X-Client-Version"]=i),i="Node"==Xn(),!(i=r.XMLHttpRequest||i&&e.INTERNAL.node&&e.INTERNAL.node.XMLHttpRequest)&&!Gn())throw new Pi("internal-error","The XMLHttpRequest compatibility library was not found.");this.c=void 0,Gn()?this.c=new ro(self):Jn()?this.c=new jo(i):this.c=new qr}w(Uo,E),w(jo,Wr),jo.prototype.a=function(){return new this.f},jo.prototype.b=function(){return{}};var Bo,$o="idToken",Vo=new yi(3e4,6e4),qo={"Content-Type":"application/x-www-form-urlencoded"},Ho=new yi(3e4,6e4),zo={"Content-Type":"application/json"};function Ko(t,e){e?t.a["X-Firebase-Locale"]=e:delete t.a["X-Firebase-Locale"]}function Qo(t,e){e?(t.a["X-Client-Version"]=e,t.f["X-Client-Version"]=e):(delete t.a["X-Client-Version"],delete t.f["X-Client-Version"])}function Yo(t,e,n,i,o,s,a){(function(){var t=ri();return!((t=ei(t)!=ti?null:(t=t.match(/\sChrome\/(\d+)/i))&&2==t.length?parseInt(t[1],10):null)&&30>t||qt&&Zt&&!(9<Zt))})()||Gn()?t=m(t.o,t):(Bo||(Bo=new gt(function(t,e){!function(t,e){if(((window.gapi||{}).client||{}).request)t();else{r[Xo]=function(){((window.gapi||{}).client||{}).request?t():e(Error("CORS_UNSUPPORTED"))};var n=_n(Go,{onload:Xo});!function(t,e){Io(Oo(n),null,e,void 0)}(0,function(){e(Error("CORS_UNSUPPORTED"))})}}(t,e)})),t=m(t.l,t)),t(e,n,i,o,s,a)}Wo.prototype.o=function(t,e,n,i,o,s){if(Gn()&&(void 0===r.fetch||void 0===r.Headers||void 0===r.Request))throw new Pi("operation-not-supported-in-this-environment","fetch, Headers and Request native APIs or equivalent Polyfills must be available to support HTTP requests from a Worker environment.");var a=new uo(this.c);if(s){a.g=Math.max(0,s);var u=setTimeout(function(){a.dispatchEvent("timeout")},s)}De(a,"complete",function(){u&&clearTimeout(u);var t=null;try{t=JSON.parse(function(t){try{return t.a?t.a.responseText:""}catch(e){return io(t.b,"Can not get responseText: "+e.message),""}}(this))||null}catch(e){t=null}e&&e(t)}),Re(a,"ready",function(){u&&clearTimeout(u),jt(this)}),Re(a,"timeout",function(){u&&clearTimeout(u),jt(this),e&&e(null)}),fo(a,t,n,i,o)};var Go=gn("https://apis.google.com/js/client.js?onload=%{onload}"),Xo="__fcb"+Math.floor(1e6*Math.random()).toString();function Jo(t){if(!jr.test(t.email))throw new Pi("invalid-email")}function Zo(t){"email"in t&&Jo(t)}function ts(t){if(!t[$o])throw new Pi("internal-error")}function es(t){if(t.phoneNumber||t.temporaryProof){if(!t.phoneNumber||!t.temporaryProof)throw new Pi("internal-error")}else{if(!t.sessionInfo)throw new Pi("missing-verification-id");if(!t.code)throw new Pi("missing-verification-code")}}Wo.prototype.l=function(t,e,n,i,r){var o=this;Bo.then(function(){window.gapi.client.setApiKey(o.b);var s=window.gapi.auth.getToken();window.gapi.auth.setToken(null),window.gapi.client.request({path:t,method:n,body:i,headers:r,authType:"none",callback:function(t){window.gapi.auth.setToken(s),e&&e(t)}})}).s(function(t){e&&e({error:{message:t&&t.message||"CORS_UNSUPPORTED"}})})},Wo.prototype.Pa=function(){return Ls(this,ks,{})},Wo.prototype.mb=function(t,e){return Ls(this,Ss,{idToken:t,email:e})},Wo.prototype.nb=function(t,e){return Ls(this,Is,{idToken:t,password:e})};var ns={displayName:"DISPLAY_NAME",photoUrl:"PHOTO_URL"};function is(t){if(!t.requestUri||!t.sessionId&&!t.postBody)throw new Pi("internal-error")}function rs(t){var e=null;if(t.needConfirmation?(t.code="account-exists-with-different-credential",e=Fr(t)):"FEDERATED_USER_ID_ALREADY_LINKED"==t.errorMessage?(t.code="credential-already-in-use",e=Fr(t)):"EMAIL_EXISTS"==t.errorMessage?(t.code="email-already-in-use",e=Fr(t)):t.errorMessage&&(e=Fs(t.errorMessage)),e)throw e;if(!t[$o])throw new Pi("internal-error")}function os(t,e){return e.returnIdpCredential=!0,Ls(t,As,e)}function ss(t,e){return e.returnIdpCredential=!0,Ls(t,Ns,e)}function as(t,e){return e.returnIdpCredential=!0,e.autoCreate=!1,Ls(t,Ps,e)}function us(t){if(!t.oobCode)throw new Pi("invalid-action-code")}(t=Wo.prototype).ob=function(t,e){var n={idToken:t},i=[];return rt(ns,function(t,r){var o=e[r];null===o?i.push(t):r in e&&(n[r]=o)}),i.length&&(n.deleteAttribute=i),Ls(this,Ss,n)},t.hb=function(t,e){return ht(t={requestType:"PASSWORD_RESET",email:t},e),Ls(this,bs,t)},t.ib=function(t,e){return ht(t={requestType:"EMAIL_SIGNIN",email:t},e),Ls(this,ms,t)},t.gb=function(t,e){return ht(t={requestType:"VERIFY_EMAIL",idToken:t},e),Ls(this,_s,t)},t.Ta=function(t){return Ls(this,Os,t)},t.Xa=function(t,e){return Ls(this,Ts,{oobCode:t,newPassword:e})},t.Ja=function(t){return Ls(this,hs,{oobCode:t})},t.Va=function(t){return Ls(this,cs,{oobCode:t})};var cs={endpoint:"setAccountInfo",B:us,da:"email"},hs={endpoint:"resetPassword",B:us,J:function(t){var e=t.requestType;if(!e||!t.email&&"EMAIL_SIGNIN"!=e)throw new Pi("internal-error")}},ls={endpoint:"signupNewUser",B:function(t){if(Jo(t),!t.password)throw new Pi("weak-password")},J:ts,R:!0},ds={endpoint:"createAuthUri"},fs={endpoint:"deleteAccount",T:["idToken"]},ps={endpoint:"setAccountInfo",T:["idToken","deleteProvider"],B:function(t){if(!h(t.deleteProvider))throw new Pi("internal-error")}},vs={endpoint:"emailLinkSignin",T:["email","oobCode"],B:Jo,J:ts,R:!0},gs={endpoint:"emailLinkSignin",T:["idToken","email","oobCode"],B:Jo,J:ts,R:!0},ys={endpoint:"getAccountInfo"},ms={endpoint:"getOobConfirmationCode",T:["requestType"],B:function(t){if("EMAIL_SIGNIN"!=t.requestType)throw new Pi("internal-error");Jo(t)},da:"email"},_s={endpoint:"getOobConfirmationCode",T:["idToken","requestType"],B:function(t){if("VERIFY_EMAIL"!=t.requestType)throw new Pi("internal-error")},da:"email"},bs={endpoint:"getOobConfirmationCode",T:["requestType"],B:function(t){if("PASSWORD_RESET"!=t.requestType)throw new Pi("internal-error");Jo(t)},da:"email"},ws={rb:!0,endpoint:"getProjectConfig",Eb:"GET"},Cs={rb:!0,endpoint:"getRecaptchaParam",Eb:"GET",J:function(t){if(!t.recaptchaSiteKey)throw new Pi("internal-error")}},Ts={endpoint:"resetPassword",B:us,da:"email"},Es={endpoint:"sendVerificationCode",T:["phoneNumber","recaptchaToken"],da:"sessionInfo"},Ss={endpoint:"setAccountInfo",T:["idToken"],B:Zo,R:!0},Is={endpoint:"setAccountInfo",T:["idToken"],B:function(t){if(Zo(t),!t.password)throw new Pi("weak-password")},J:ts,R:!0},ks={endpoint:"signupNewUser",J:ts,R:!0},As={endpoint:"verifyAssertion",B:is,J:rs,R:!0},Ps={endpoint:"verifyAssertion",B:is,J:function(t){if(t.errorMessage&&"USER_NOT_FOUND"==t.errorMessage)throw new Pi("user-not-found");if(t.errorMessage)throw Fs(t.errorMessage);if(!t[$o])throw new Pi("internal-error")},R:!0},Ns={endpoint:"verifyAssertion",B:function(t){if(is(t),!t.idToken)throw new Pi("internal-error")},J:rs,R:!0},Ds={endpoint:"verifyCustomToken",B:function(t){if(!t.token)throw new Pi("invalid-custom-token")},J:ts,R:!0},Rs={endpoint:"verifyPassword",B:function(t){if(Jo(t),!t.password)throw new Pi("wrong-password")},J:ts,R:!0},Os={endpoint:"verifyPhoneNumber",B:es,J:ts},xs={endpoint:"verifyPhoneNumber",B:function(t){if(!t.idToken)throw new Pi("internal-error");es(t)},J:function(t){if(t.temporaryProof)throw t.code="credential-already-in-use",Fr(t);ts(t)}},Ms={Tb:{USER_NOT_FOUND:"user-not-found"},endpoint:"verifyPhoneNumber",B:es,J:ts};function Ls(t,e,n){if(!function(t,e){if(!e||!e.length)return!0;if(!t)return!1;for(var n=0;n<e.length;n++){var i=t[e[n]];if(void 0===i||null===i||""===i)return!1}return!0}(n,e.T))return Et(new Pi("internal-error"));var i,r=e.Eb||"POST";return Tt(n).then(e.B).then(function(){return e.R&&(n.returnSecureToken=!0),function(t,e,n,i,r,o){var s=Qe(t.g+e);ze(s,"key",t.b),o&&ze(s,"cb",b().toString());var a="GET"==n;if(a)for(var u in i)i.hasOwnProperty(u)&&ze(s,u,i[u]);return new gt(function(e,o){Yo(t,s.toString(),function(t){t?t.error?o(Us(t,r||{})):e(t):o(new Pi("network-request-failed"))},n,a?void 0:Ln(di(i)),t.a,t.h.get())})}(t,e.endpoint,r,n,e.Tb,e.rb||!1)}).then(function(t){return i=t}).then(e.J).then(function(){if(!e.da)return i;if(!(e.da in i))throw new Pi("internal-error");return i[e.da]})}function Fs(t){return Us({error:{errors:[{message:t}],code:400,message:t}})}function Us(t,e){var n=(t.error&&t.error.errors&&t.error.errors[0]||{}).reason||"",i={keyInvalid:"invalid-api-key",ipRefererBlocked:"app-not-authorized"};if(n=i[n]?new Pi(i[n]):null)return n;for(var r in n=t.error&&t.error.message||"",ht(i={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"},e||{}),e=(e=n.match(/^[^\s]+\s*:\s*(.*)$/))&&1<e.length?e[1]:void 0,i)if(0===n.indexOf(r))return new Pi(i[r],e);return!e&&t&&(e=li(t)),new Pi("internal-error",e)}var js,Ws={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"}};function Bs(t){for(var e in Ws)if(Ws[e].id===t)return{firebaseEndpoint:(t=Ws[e]).Za,secureTokenEndpoint:t.fb};return null}function $s(t){this.b=t,this.a=null,this.bb=function(t){return(Ks||(Ks=new gt(function(t,e){function n(){gi(),oi("gapi.load")("gapi.iframes",{callback:t,ontimeout:function(){gi(),e(Error("Network Error"))},timeout:Hs.get()})}if(oi("gapi.iframes.Iframe"))t();else if(oi("gapi.load"))n();else{var i="__iframefcb"+Math.floor(1e6*Math.random()).toString();r[i]=function(){oi("gapi.load")?n():e(Error("Network Error"))},Tt(Oo(i=_n(qs,{onload:i}))).s(function(){e(Error("Network Error"))})}}).s(function(t){throw Ks=null,t}))).then(function(){return new gt(function(e,n){oi("gapi.iframes.getContext")().open({where:document.body,url:t.b,messageHandlersFilter:oi("gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER"),attributes:{style:{position:"absolute",top:"-100px",width:"1px",height:"1px"}},dontclear:!0},function(i){function r(){clearTimeout(o),e()}t.a=i,t.a.restyle({setHideOnLeave:!1});var o=setTimeout(function(){n(Error("Network Error"))},zs.get());i.ping(r).then(r,function(){n(Error("Network Error"))})})})})}(this)}js=Bs("__EID__")?"__EID__":void 0;var Vs,qs=gn("https://apis.google.com/js/api.js?onload=%{onload}"),Hs=new yi(3e4,6e4),zs=new yi(5e3,15e3),Ks=null;function Qs(t,e,n){this.i=t,this.g=e,this.h=n,this.f=null,this.a=Ye(this.i,"/__/auth/iframe"),ze(this.a,"apiKey",this.g),ze(this.a,"appName",this.h),this.b=null,this.c=[]}function Ys(t,e,n,i,r){this.o=t,this.l=e,this.c=n,this.m=i,this.h=this.g=this.i=null,this.a=r,this.f=null}function Gs(t){try{return e.app(t).auth().xa()}catch(t){return[]}}function Xs(t,e,n,i,r){this.l=t,this.f=e,this.b=n,this.c=i||null,this.h=r||null,this.o=this.u=this.v=null,this.g=[],this.m=this.a=null}function Js(t){var e=Bn();return function(t){return Ls(t,ws,{}).then(function(t){return t.authorizedDomains||[]})}(t).then(function(t){t:{var n=Qe(e),i=n.c;n=n.b;for(var r=0;r<t.length;r++){var o=t[r],s=n,a=i;if(0==o.indexOf("chrome-extension://")?s=Qe(o).b==s&&"chrome-extension"==a:"http"!=a&&"https"!=a?s=!1:zn.test(o)?s=s==o:(o=o.split(".").join("\\."),s=new RegExp("^(.+\\."+o+"|"+o+")$","i").test(s)),s){t=!0;break t}}t=!1}if(!t)throw new Mr(Bn())})}function Zs(t){return t.m?t.m:(t.m=Kn().then(function(){if(!t.u){var e=t.c,n=t.h,i=Gs(t.b),r=new Qs(t.l,t.f,t.b);r.f=e,r.b=n,r.c=B(i||[]),t.u=r.toString()}t.i=new $s(t.u),function(t){if(!t.i)throw Error("IfcHandler must be initialized!");!function(t,e){t.bb.then(function(){t.a.register("authEvent",e,oi("gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER"))})}(t.i,function(e){var n={};if(e&&e.authEvent){var i=!1;for(e=Rr(e.authEvent),n=0;n<t.g.length;n++)i=t.g[n](e)||i;return(n={}).status=i?"ACK":"ERROR",Tt(n)}return n.status="ERROR",Tt(n)})}(t)}),t.m)}function ta(t){return t.o||(t.v=t.c?ii(t.c,Gs(t.b)):null,t.o=new Wo(t.f,Bs(t.h),t.v)),t.o}function ea(t,e,n,i,r,o,s,a,u,c){return(t=new Ys(t,e,n,i,r)).i=o,t.g=s,t.h=a,t.b=st(u||null),t.f=c,t.toString()}function na(t){if(this.a=t||e.INTERNAL.reactNative&&e.INTERNAL.reactNative.AsyncStorage,!this.a)throw new Pi("internal-error","The React Native compatibility library was not found.");this.type="asyncStorage"}function ia(){if(!oa())throw new Pi("web-storage-unsupported");this.f={},this.a=[],this.b=0,this.g=r.indexedDB,this.type="indexedDB"}function ra(t){return t.h||(t.h=function t(e){return new gt(function(n,i){var r=e.g.open("firebaseLocalStorageDb",1);r.onerror=function(t){try{t.preventDefault()}catch(t){}i(Error(t.target.error))},r.onupgradeneeded=function(t){t=t.target.result;try{t.createObjectStore("firebaseLocalStorage",{keyPath:"fbase_key"})}catch(t){i(t)}},r.onsuccess=function(r){(r=r.target.result).objectStoreNames.contains("firebaseLocalStorage")?n(r):function(t){return new gt(function(e,n){var i=t.g.deleteDatabase("firebaseLocalStorageDb");i.onsuccess=function(){e()},i.onerror=function(t){n(Error(t.target.error))}})}(e).then(function(){return t(e)}).then(function(t){n(t)}).s(function(t){i(t)})}})}(t)),t.h}function oa(){try{return!!r.indexedDB}catch(t){return!1}}function sa(t){return t.objectStore("firebaseLocalStorage")}function aa(t,e){return t.transaction(["firebaseLocalStorage"],e?"readwrite":"readonly")}function ua(t){return new gt(function(e,n){t.onsuccess=function(t){t&&t.target?e(t.target.result):e()},t.onerror=function(t){n(Error(t.target.errorCode))}})}function ca(t){var e=this,n=null;this.a=[],this.type="indexedDB",this.c=t,this.b=Tt().then(function(){return oa()?(Vs||(Vs=new ia),(n=Vs).set("__sak","!").then(function(){return n.get("__sak")}).then(function(t){if("!"!==t)throw Error("indexedDB not supported!");return n.P("__sak")}).then(function(){return n}).s(function(){return e.c})):e.c}).then(function(t){return e.type=t.type,t.Y(function(t){x(e.a,function(e){e(t)})}),t})}function ha(){this.a={},this.type="inMemory"}function la(){if(!function(){var t="Node"==Xn();if(!(t=da()||t&&e.INTERNAL.node&&e.INTERNAL.node.localStorage))return!1;try{return t.setItem("__sak","1"),t.removeItem("__sak"),!0}catch(t){return!1}}()){if("Node"==Xn())throw new Pi("internal-error","The LocalStorage compatibility library was not found.");throw new Pi("web-storage-unsupported")}this.a=da()||e.INTERNAL.node.localStorage,this.type="localStorage"}function da(){try{var t=r.localStorage,e=pi();return t&&(t.setItem(e,"1"),t.removeItem(e)),t}catch(t){return null}}function fa(){this.type="nullStorage"}function pa(){if(!function(){var t="Node"==Xn();if(!(t=va()||t&&e.INTERNAL.node&&e.INTERNAL.node.sessionStorage))return!1;try{return t.setItem("__sak","1"),t.removeItem("__sak"),!0}catch(t){return!1}}()){if("Node"==Xn())throw new Pi("internal-error","The SessionStorage compatibility library was not found.");throw new Pi("web-storage-unsupported")}this.a=va()||e.INTERNAL.node.sessionStorage,this.type="sessionStorage"}function va(){try{var t=r.sessionStorage,e=pi();return t&&(t.setItem(e,"1"),t.removeItem(e)),t}catch(t){return null}}Qs.prototype.toString=function(){return this.f?ze(this.a,"v",this.f):un(this.a.a,"v"),this.b?ze(this.a,"eid",this.b):un(this.a.a,"eid"),this.c.length?ze(this.a,"fw",this.c.join(",")):un(this.a.a,"fw"),this.a.toString()},Ys.prototype.toString=function(){var t=Ye(this.o,"/__/auth/handler");if(ze(t,"apiKey",this.l),ze(t,"appName",this.c),ze(t,"authType",this.m),this.a.isOAuthProvider){var n=this.a;try{var i=e.app(this.c).auth().ea()}catch(t){i=null}for(var r in n.Ya=i,ze(t,"providerId",this.a.providerId),i=di((n=this.a).vb))i[r]=i[r].toString();r=n.Ac,i=st(i);for(var o=0;o<r.length;o++){var s=r[o];s in i&&delete i[s]}n.$a&&n.Ya&&!i[n.$a]&&(i[n.$a]=n.Ya),ot(i)||ze(t,"customParameters",li(i))}if("function"==typeof this.a.Ab&&(n=this.a.Ab()).length&&ze(t,"scopes",n.join(",")),this.i?ze(t,"redirectUrl",this.i):un(t.a,"redirectUrl"),this.g?ze(t,"eventId",this.g):un(t.a,"eventId"),this.h?ze(t,"v",this.h):un(t.a,"v"),this.b)for(var a in this.b)this.b.hasOwnProperty(a)&&!Ke(t,a)&&ze(t,a,this.b[a]);return this.f?ze(t,"eid",this.f):un(t.a,"eid"),(a=Gs(this.c)).length&&ze(t,"fw",a.join(",")),t.toString()},(t=Xs.prototype).Ea=function(t,e,n){var i=new Pi("popup-closed-by-user"),r=new Pi("web-storage-unsupported"),o=this,s=!1;return this.ga().then(function(){(function(t){var e={type:"webStorageSupport"};return Zs(t).then(function(){return function(t,e){return t.bb.then(function(){return new gt(function(n){t.a.send(e.type,e,n,oi("gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER"))})})}(t.i,e)}).then(function(t){if(t&&t.length&&void 0!==t[0].webStorageSupport)return t[0].webStorageSupport;throw Error()})})(o).then(function(n){n||(t&&qn(t),e(r),s=!0)})}).s(function(){}).then(function(){if(!s)return function(t){return new gt(function(e){return function n(){Me(2e3).then(function(){if(t&&!t.closed)return n();e()})}()})}(t)}).then(function(){if(!s)return Me(n).then(function(){e(i)})})},t.Ib=function(){var t=ri();return!hi(t)&&!vi(t)},t.Db=function(){return!1},t.zb=function(t,e,n,i,r,o,s){if(!t)return Et(new Pi("popup-blocked"));if(s&&!hi())return this.ga().s(function(e){qn(t),r(e)}),i(),Tt();this.a||(this.a=Js(ta(this)));var a=this;return this.a.then(function(){var e=a.ga().s(function(e){throw qn(t),r(e),e});return i(),e}).then(function(){Nr(n),s||$n(ea(a.l,a.f,a.b,e,n,null,o,a.c,void 0,a.h),t)}).s(function(t){throw"auth/network-request-failed"==t.code&&(a.a=null),t})},t.Ca=function(t,e,n){this.a||(this.a=Js(ta(this)));var i=this;return this.a.then(function(){Nr(e),$n(ea(i.l,i.f,i.b,t,e,Bn(),n,i.c,void 0,i.h))}).s(function(t){throw"auth/network-request-failed"==t.code&&(i.a=null),t})},t.ga=function(){var t=this;return Zs(this).then(function(){return t.i.bb}).s(function(){throw t.a=null,new Pi("network-request-failed")})},t.Mb=function(){return!0},t.va=function(t){this.g.push(t)},t.Ka=function(t){j(this.g,function(e){return e==t})},(t=na.prototype).get=function(t){return Tt(this.a.getItem(t)).then(function(t){return t&&fi(t)})},t.set=function(t,e){return Tt(this.a.setItem(t,li(e)))},t.P=function(t){return Tt(this.a.removeItem(t))},t.Y=function(){},t.ca=function(){},(t=ia.prototype).set=function(t,e){var n,i=!1,r=this;return ra(this).then(function(e){return ua((e=sa(aa(n=e,!0))).get(t))}).then(function(o){var s=sa(aa(n,!0));return o?(o.value=e,ua(s.put(o))):(r.b++,i=!0,(o={}).fbase_key=t,o.value=e,ua(s.add(o)))}).then(function(){r.f[t]=e}).ia(function(){i&&r.b--})},t.get=function(t){return ra(this).then(function(e){return ua(sa(aa(e,!1)).get(t))}).then(function(t){return t&&t.value})},t.P=function(t){var e=!1,n=this;return ra(this).then(function(i){return e=!0,n.b++,ua(sa(aa(i,!0)).delete(t))}).then(function(){delete n.f[t]}).ia(function(){e&&n.b--})},t.Kc=function(){var t=this;return ra(this).then(function(t){var e=sa(aa(t,!1));return e.getAll?ua(e.getAll()):new gt(function(t,n){var i=[],r=e.openCursor();r.onsuccess=function(e){(e=e.target.result)?(i.push(e.value),e.continue()):t(i)},r.onerror=function(t){n(Error(t.target.errorCode))}})}).then(function(e){var n={},i=[];if(0==t.b){for(i=0;i<e.length;i++)n[e[i].fbase_key]=e[i].value;i=function t(e,n){var i,r=[];for(i in e)i in n?typeof e[i]!=typeof n[i]?r.push(i):"object"==typeof e[i]&&null!=e[i]&&null!=n[i]?0<t(e[i],n[i]).length&&r.push(i):e[i]!==n[i]&&r.push(i):r.push(i);for(i in n)i in e||r.push(i);return r}(t.f,n),t.f=n}return i})},t.Y=function(t){0==this.a.length&&function(t){t.c&&t.c.cancel("STOP_EVENT"),function e(){return t.c=Me(800).then(m(t.Kc,t)).then(function(e){0<e.length&&x(t.a,function(t){t(e)})}).then(e).s(function(t){"STOP_EVENT"!=t.message&&e()}),t.c}()}(this),this.a.push(t)},t.ca=function(t){j(this.a,function(e){return e==t}),0==this.a.length&&this.c&&this.c.cancel("STOP_EVENT")},(t=ca.prototype).get=function(t){return this.b.then(function(e){return e.get(t)})},t.set=function(t,e){return this.b.then(function(n){return n.set(t,e)})},t.P=function(t){return this.b.then(function(e){return e.P(t)})},t.Y=function(t){this.a.push(t)},t.ca=function(t){j(this.a,function(e){return e==t})},(t=ha.prototype).get=function(t){return Tt(this.a[t])},t.set=function(t,e){return this.a[t]=e,Tt()},t.P=function(t){return delete this.a[t],Tt()},t.Y=function(){},t.ca=function(){},(t=la.prototype).get=function(t){var e=this;return Tt().then(function(){return fi(e.a.getItem(t))})},t.set=function(t,e){var n=this;return Tt().then(function(){var i=li(e);null===i?n.P(t):n.a.setItem(t,i)})},t.P=function(t){var e=this;return Tt().then(function(){e.a.removeItem(t)})},t.Y=function(t){r.window&&me(r.window,"storage",t)},t.ca=function(t){r.window&&we(r.window,"storage",t)},(t=fa.prototype).get=function(){return Tt(null)},t.set=function(){return Tt()},t.P=function(){return Tt()},t.Y=function(){},t.ca=function(){},(t=pa.prototype).get=function(t){var e=this;return Tt().then(function(){return fi(e.a.getItem(t))})},t.set=function(t,e){var n=this;return Tt().then(function(){var i=li(e);null===i?n.P(t):n.a.setItem(t,i)})},t.P=function(t){var e=this;return Tt().then(function(){e.a.removeItem(t)})},t.Y=function(){},t.ca=function(){};var ga,ya,ma={A:la,Qa:pa},_a={A:la,Qa:pa},ba={A:na,Qa:fa},wa={A:la,Qa:fa},Ca={Xc:"local",NONE:"none",Zc:"session"};function Ta(){var t=!(vi(ri())||!Yn()),e=hi(),n=si();this.o=t,this.h=e,this.m=n,this.a={},ga||(ga=new function(){var t={};t.Browser=ma,t.Node=_a,t.ReactNative=ba,t.Worker=wa,this.a=t[Xn()]}),t=ga;try{this.g=!Wn()&&bi()||!r.indexedDB?new t.a.A:new ca(Gn()?new ha:new t.a.A)}catch(t){this.g=new ha,this.h=!0}try{this.i=new t.a.Qa}catch(t){this.i=new ha}this.l=new ha,this.f=m(this.Lb,this),this.b={}}function Ea(){return ya||(ya=new Ta),ya}function Sa(t,e){switch(e){case"session":return t.i;case"none":return t.l;default:return t.g}}function Ia(t,e){return"firebase:"+t.name+(e?":"+e:"")}function ka(t,e,n){return n=Ia(e,n),"local"==e.A&&(t.b[n]=null),Sa(t,e.A).P(n)}function Aa(t){t.c&&(clearInterval(t.c),t.c=null)}(t=Ta.prototype).get=function(t,e){return Sa(this,t.A).get(Ia(t,e))},t.set=function(t,e,n){var i=Ia(t,n),r=this,o=Sa(this,t.A);return o.set(i,e).then(function(){return o.get(i)}).then(function(e){"local"==t.A&&(r.b[i]=e)})},t.addListener=function(t,e,n){t=Ia(t,e),this.m&&(this.b[t]=r.localStorage.getItem(t)),ot(this.a)&&(Sa(this,"local").Y(this.f),this.h||(Wn()||!bi())&&r.indexedDB||!this.m||function(t){Aa(t),t.c=setInterval(function(){for(var e in t.a){var n=r.localStorage.getItem(e),i=t.b[e];n!=i&&(t.b[e]=n,n=new ue({type:"storage",key:e,target:window,oldValue:i,newValue:n,a:!0}),t.Lb(n))}},1e3)}(this)),this.a[t]||(this.a[t]=[]),this.a[t].push(n)},t.removeListener=function(t,e,n){t=Ia(t,e),this.a[t]&&(j(this.a[t],function(t){return t==n}),0==this.a[t].length&&delete this.a[t]),ot(this.a)&&(Sa(this,"local").ca(this.f),Aa(this))},t.Lb=function(t){if(t&&t.f){var e=t.a.key;if(null==e)for(var n in this.a){var i=this.b[n];void 0===i&&(i=null);var o=r.localStorage.getItem(n);o!==i&&(this.b[n]=o,this.Wa(n))}else if(0==e.indexOf("firebase:")&&this.a[e]){if(void 0!==t.a.a?Sa(this,"local").ca(this.f):Aa(this),this.o)if(n=r.localStorage.getItem(e),(i=t.a.newValue)!==n)null!==i?r.localStorage.setItem(e,i):r.localStorage.removeItem(e);else if(this.b[e]===i&&void 0===t.a.a)return;var s=this;n=function(){void 0===t.a.a&&s.b[e]===r.localStorage.getItem(e)||(s.b[e]=r.localStorage.getItem(e),s.Wa(e))},qt&&Zt&&10==Zt&&r.localStorage.getItem(e)!==t.a.newValue&&t.a.newValue!==t.a.oldValue?setTimeout(n,10):n()}}else x(t,m(this.Wa,this))},t.Wa=function(t){this.a[t]&&x(this.a[t],function(t){t()})};var Pa,Na={name:"authEvent",A:"local"};function Da(t,e){this.b=-1,this.b=Ra,this.f=r.Uint8Array?new Uint8Array(this.b):Array(this.b),this.g=this.c=0,this.a=[],this.i=t,this.h=e,this.m=r.Int32Array?new Int32Array(64):Array(64),void 0!==Pa||(Pa=r.Int32Array?new Int32Array(ja):ja),this.reset()}w(Da,function(){this.b=-1});for(var Ra=64,Oa=Ra-1,xa=[],Ma=0;Ma<Oa;Ma++)xa[Ma]=0;var La=W(128,xa);function Fa(t){for(var e=t.f,n=t.m,i=0,r=0;r<e.length;)n[i++]=e[r]<<24|e[r+1]<<16|e[r+2]<<8|e[r+3],r=4*i;for(e=16;64>e;e++){r=0|n[e-15],i=0|n[e-2];var o=(0|n[e-16])+((r>>>7|r<<25)^(r>>>18|r<<14)^r>>>3)|0,s=(0|n[e-7])+((i>>>17|i<<15)^(i>>>19|i<<13)^i>>>10)|0;n[e]=o+s|0}i=0|t.a[0],r=0|t.a[1];var a=0|t.a[2],u=0|t.a[3],c=0|t.a[4],h=0|t.a[5],l=0|t.a[6];for(o=0|t.a[7],e=0;64>e;e++){var d=((i>>>2|i<<30)^(i>>>13|i<<19)^(i>>>22|i<<10))+(i&r^i&a^r&a)|0;s=(o=o+((c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7))|0)+((s=(s=c&h^~c&l)+(0|Pa[e])|0)+(0|n[e])|0)|0,o=l,l=h,h=c,c=u+s|0,u=a,a=r,r=i,i=s+d|0}t.a[0]=t.a[0]+i|0,t.a[1]=t.a[1]+r|0,t.a[2]=t.a[2]+a|0,t.a[3]=t.a[3]+u|0,t.a[4]=t.a[4]+c|0,t.a[5]=t.a[5]+h|0,t.a[6]=t.a[6]+l|0,t.a[7]=t.a[7]+o|0}function Ua(t,e,n){void 0===n&&(n=e.length);var i=0,r=t.c;if(o(e))for(;i<n;)t.f[r++]=e.charCodeAt(i++),r==t.b&&(Fa(t),r=0);else{if(!l(e))throw Error("message must be string or array");for(;i<n;){var s=e[i++];if(!("number"==typeof s&&0<=s&&255>=s&&s==(0|s)))throw Error("message must be a byte array");t.f[r++]=s,r==t.b&&(Fa(t),r=0)}}t.c=r,t.g+=n}Da.prototype.reset=function(){this.g=this.c=0,this.a=r.Int32Array?new Int32Array(this.h):B(this.h)};var ja=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function Wa(){Da.call(this,8,Ba)}w(Wa,Da);var Ba=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];function $a(t,e,n,i,r){this.l=t,this.i=e,this.m=n,this.o=i||null,this.u=r||null,this.h=e+":"+n,this.v=new function(){this.a=Ea()},this.g=new function(t){this.a=t,this.b=Ea()}(this.h),this.f=null,this.b=[],this.a=this.c=null}function Va(t){return new Pi("invalid-cordova-configuration",t)}function qa(t,e){for(var n=0;n<t.b.length;n++)try{t.b[n](e)}catch(t){}}function Ha(t){return t.f||(t.f=t.ga().then(function(){return new gt(function(e){t.va(function n(i){return e(i),t.Ka(n),!1}),function(t){function e(e){i=!0,o&&o.cancel(),za(t).then(function(i){var r=n;if(i&&e&&e.url){var o=null;-1!=(r=ar(e.url)).indexOf("/__/auth/callback")&&(o=(o="object"==typeof(o=fi(Ke(o=Qe(r),"firebaseError")||null))?Ni(o):null)?new Dr(i.b,i.c,null,null,o):new Dr(i.b,i.c,r,i.g)),r=o||n}qa(t,r)})}var n=new Dr("unknown",null,null,null,new Pi("no-auth-event")),i=!1,o=Me(500).then(function(){return za(t).then(function(){i||qa(t,n)})}),s=r.handleOpenURL;r.handleOpenURL=function(t){if(0==t.toLowerCase().indexOf(oi("BuildInfo.packageName",r).toLowerCase()+"://")&&e({url:t}),"function"==typeof s)try{s(t)}catch(t){console.error(t)}},xr||(xr=new Or),xr.subscribe(e)}(t)})})),t.f}function za(t){var e=null;return function(t){return t.b.get(Na,t.a).then(function(t){return Rr(t)})}(t.g).then(function(n){return e=n,ka((n=t.g).b,Na,n.a)}).then(function(){return e})}(t=$a.prototype).ga=function(){return this.za?this.za:this.za=(Qn(void 0)?Kn().then(function(){return new gt(function(t,e){var n=r.document,i=setTimeout(function(){e(Error("Cordova framework is not ready."))},1e3);n.addEventListener("deviceready",function(){clearTimeout(i),t()},!1)})}):Et(Error("Cordova must run in an Android or iOS file scheme."))).then(function(){if("function"!=typeof oi("universalLinks.subscribe",r))throw Va("cordova-universal-links-plugin is not installed");if(void 0===oi("BuildInfo.packageName",r))throw Va("cordova-plugin-buildinfo is not installed");if("function"!=typeof oi("cordova.plugins.browsertab.openUrl",r))throw Va("cordova-plugin-browsertab is not installed");if("function"!=typeof oi("cordova.InAppBrowser.open",r))throw Va("cordova-plugin-inappbrowser is not installed")},function(){throw new Pi("cordova-not-ready")})},t.Ea=function(t,e){return e(new Pi("operation-not-supported-in-this-environment")),Tt()},t.zb=function(){return Et(new Pi("operation-not-supported-in-this-environment"))},t.Mb=function(){return!1},t.Ib=function(){return!0},t.Db=function(){return!0},t.Ca=function(t,e,n){if(this.c)return Et(new Pi("redirect-operation-pending"));var i=this,o=r.document,s=null,a=null,u=null,c=null;return this.c=Tt().then(function(){return Nr(e),Ha(i)}).then(function(){return function(t,e,n,i){var o=function(){for(var t=20,e=[];0<t;)e.push("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".charAt(Math.floor(62*Math.random()))),t--;return e.join("")}(),s=new Dr(e,i,null,o,new Pi("no-auth-event")),a=oi("BuildInfo.packageName",r);if("string"!=typeof a)throw new Pi("invalid-cordova-configuration");var u=oi("BuildInfo.displayName",r),c={};if(ri().toLowerCase().match(/iphone|ipad|ipod/))c.ibi=a;else{if(!ri().toLowerCase().match(/android/))return Et(new Pi("operation-not-supported-in-this-environment"));c.apn=a}u&&(c.appDisplayName=u),o=function(t){var e=new Wa;Ua(e,t),t=[];var n=8*e.g;56>e.c?Ua(e,La,56-e.c):Ua(e,La,e.b-(e.c-56));for(var i=63;56<=i;i--)e.f[i]=255&n,n/=256;for(Fa(e),i=n=0;i<e.i;i++)for(var r=24;0<=r;r-=8)t[n++]=e.a[i]>>r&255;return function(t){return M(t,function(t){return 1<(t=t.toString(16)).length?t:"0"+t}).join("")}(t)}(o),c.sessionId=o;var h=ea(t.l,t.i,t.m,e,n,null,i,t.o,c,t.u);return t.ga().then(function(){var e=t.h;return t.v.a.set(Na,s.D(),e)}).then(function(){var e=oi("cordova.plugins.browsertab.isAvailable",r);if("function"!=typeof e)throw new Pi("invalid-cordova-configuration");var n=null;e(function(e){if(e){if("function"!=typeof(n=oi("cordova.plugins.browsertab.openUrl",r)))throw new Pi("invalid-cordova-configuration");n(h)}else{if("function"!=typeof(n=oi("cordova.InAppBrowser.open",r)))throw new Pi("invalid-cordova-configuration");e=!(!(e=ri()).match(/(iPad|iPhone|iPod).*OS 7_\d/i)&&!e.match(/(iPad|iPhone|iPod).*OS 8_\d/i)),t.a=n(h,e?"_blank":"_system","location=yes")}})})}(i,t,e,n)}).then(function(){return new gt(function(t,e){a=function(){var e=oi("cordova.plugins.browsertab.close",r);return t(),"function"==typeof e&&e(),i.a&&"function"==typeof i.a.close&&(i.a.close(),i.a=null),!1},i.va(a),u=function(){s||(s=Me(2e3).then(function(){e(new Pi("redirect-cancelled-by-user"))}))},c=function(){mi()&&u()},o.addEventListener("resume",u,!1),ri().toLowerCase().match(/android/)||o.addEventListener("visibilitychange",c,!1)}).s(function(t){return za(i).then(function(){throw t})})}).ia(function(){u&&o.removeEventListener("resume",u,!1),c&&o.removeEventListener("visibilitychange",c,!1),s&&s.cancel(),a&&i.Ka(a),i.c=null})},t.va=function(t){this.b.push(t),Ha(this).s(function(e){"auth/invalid-cordova-configuration"===e.code&&(e=new Dr("unknown",null,null,null,new Pi("no-auth-event")),t(e))})},t.Ka=function(t){j(this.b,function(e){return e==t})};var Ka={name:"pendingRedirect",A:"session"};function Qa(t){return ka(t.b,Ka,t.a)}function Ya(t,e,n){this.v=t,this.m=e,this.l=n,this.h=[],this.f=!1,this.i=m(this.o,this),this.c=new ou,this.u=new cu,this.g=new function(t){this.a=t,this.b=Ea()}(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=Ga(this.v,this.m,this.l,js)}function Ga(t,n,i,r){var o=e.SDK_VERSION||null;return Qn()?new $a(t,n,i,o,r):new Xs(t,n,i,o,r)}function Xa(t){t.f||(t.f=!0,t.a.va(t.i));var e=t.a;return t.a.ga().s(function(n){throw t.a==e&&t.reset(),n})}function Ja(t){t.a.Ib()&&Xa(t).s(function(e){var n=new Dr("unknown",null,null,null,new Pi("operation-not-supported-in-this-environment"));nu(e)&&t.o(n)}),t.a.Db()||su(t.c)}Ya.prototype.reset=function(){this.f=!1,this.a.Ka(this.i),this.a=Ga(this.v,this.m,this.l)},Ya.prototype.subscribe=function(t){if(F(this.h,t)||this.h.push(t),!this.f){var e=this;(function(t){return t.b.get(Ka,t.a).then(function(t){return"pending"==t})})(this.g).then(function(t){t?Qa(e.g).then(function(){Xa(e).s(function(t){var n=new Dr("unknown",null,null,null,new Pi("operation-not-supported-in-this-environment"));nu(t)&&e.o(n)})}):Ja(e)}).s(function(){Ja(e)})}},Ya.prototype.unsubscribe=function(t){j(this.h,function(e){return e==t})},Ya.prototype.o=function(t){if(!t)throw new Pi("invalid-auth-event");for(var e=!1,n=0;n<this.h.length;n++){var i=this.h[n];if(i.sb(t.b,t.c)){(e=this.b[t.b])&&e.h(t,i),e=!0;break}}return su(this.c),e};var Za=new yi(2e3,1e4),tu=new yi(3e4,6e4);function eu(t,e,n,i,r,o){return t.a.zb(e,n,i,function(){t.f||(t.f=!0,t.a.va(t.i))},function(){t.reset()},r,o)}function nu(t){return!(!t||"auth/cordova-not-ready"!=t.code)}Ya.prototype.fa=function(){return this.c.fa()},Ya.prototype.Ca=function(t,e,n){var i,r=this;return function(t){return t.b.set(Ka,"pending",t.a)}(this.g).then(function(){return r.a.Ca(t,e,n).s(function(t){if(nu(t))throw new Pi("operation-not-supported-in-this-environment");return i=t,Qa(r.g).then(function(){throw i})}).then(function(){return r.a.Mb()?new gt(function(){}):Qa(r.g).then(function(){return r.fa()}).then(function(){}).s(function(){})})})},Ya.prototype.Ea=function(t,e,n,i){return this.a.Ea(n,function(n){t.ha(e,null,n,i)},Za.get())};var iu={};function ru(t,e,n){var i=e+":"+n;return iu[i]||(iu[i]=new Ya(t,e,n)),iu[i]}function ou(){this.b=null,this.f=[],this.c=[],this.a=null,this.g=!1}function su(t){t.g||(t.g=!0,uu(t,!1,null,null))}function au(t,e){if(t.b=function(){return Tt(e)},t.f.length)for(var n=0;n<t.f.length;n++)t.f[n](e)}function uu(t,e,n,i){e?i?function(t,e){if(t.b=function(){return Et(e)},t.c.length)for(var n=0;n<t.c.length;n++)t.c[n](e)}(t,i):au(t,n):au(t,{user:null}),t.f=[],t.c=[]}function cu(){}function hu(){this.pb=!1,Object.defineProperty(this,"appVerificationDisabled",{get:function(){return this.pb},set:function(t){this.pb=t},enumerable:!1})}function lu(t,e){this.a=e,Si(this,"verificationId",t)}function du(t,e,n,i){return new kr(t).Ta(e,n).then(function(t){return new lu(t,i)})}function fu(t,e,n){if(this.h=t,this.i=e,this.g=n,this.c=3e4,this.f=96e4,this.b=null,this.a=this.c,this.f<this.c)throw Error("Proactive refresh lower bound greater than upper bound!")}function pu(t){this.f=t,this.b=this.a=null,this.c=0}function vu(t,e){var n=e[$o],i=e.refreshToken;e=gu(e.expiresIn),t.b=n,t.c=e,t.a=i}function gu(t){return b()+1e3*parseInt(t,10)}function yu(t,e){this.a=t||null,this.b=e||null,Ii(this,{lastSignInTime:_i(e||null),creationTime:_i(t||null)})}function mu(t,e){for(var n in ae.call(this,t),e)this[n]=e[n]}function _u(t,n,i){this.G=[],this.l=t.apiKey,this.o=t.appName,this.u=t.authDomain||null,t=e.SDK_VERSION?ii(e.SDK_VERSION):null,this.b=new Wo(this.l,Bs(js),t),this.h=new pu(this.b),Iu(this,n[$o]),vu(this.h,n),Si(this,"refreshToken",this.h.a),Pu(this,i||{}),Ne.call(this),this.I=!1,this.u&&ai()&&(this.a=ru(this.u,this.l,this.o)),this.N=[],this.i=null,this.w=function(t){return new fu(function(){return t.F(!0)},function(t){return!(!t||"auth/network-request-failed"!=t.code)},function(){var e=t.h.c-b()-3e5;return 0<e?e:0})}(this),this.V=m(this.Ha,this);var r=this;this.ka=null,this.sa=function(t){r.oa(t.g)},this.X=null,this.O=[],this.ra=function(t){wu(r,t.c)},this.W=null}function bu(t,e){t.X&&we(t.X,"languageCodeChanged",t.sa),(t.X=e)&&me(e,"languageCodeChanged",t.sa)}function wu(t,n){t.O=n,Qo(t.b,e.SDK_VERSION?ii(e.SDK_VERSION,t.O):null)}function Cu(t,e){t.W&&we(t.W,"frameworkChanged",t.ra),(t.W=e)&&me(e,"frameworkChanged",t.ra)}function Tu(t){try{return e.app(t.o).auth()}catch(e){throw new Pi("internal-error","No firebase.auth.Auth instance is available for the Firebase App '"+t.o+"'!")}}function Eu(t){t.C||t.w.b||(t.w.start(),we(t,"tokenChanged",t.V),me(t,"tokenChanged",t.V))}function Su(t){we(t,"tokenChanged",t.V),t.w.stop()}function Iu(t,e){t.qa=e,Si(t,"_lat",e)}function ku(t){for(var e=[],n=0;n<t.N.length;n++)e.push(t.N[n](t));return function(t){return new gt(function(e){var n=t.length,i=[];if(n)for(var r=function(t,r,o){n--,i[t]=r?{Zb:!0,value:o}:{Zb:!1,reason:o},0==n&&e(i)},o=0;o<t.length;o++)St(t[o],_(r,o,!0),_(r,o,!1));else e(i)})}(e).then(function(){return t})}function Au(t){t.a&&!t.I&&(t.I=!0,t.a.subscribe(t))}function Pu(t,e){Ii(t,{uid:e.uid,displayName:e.displayName||null,photoURL:e.photoURL||null,email:e.email||null,emailVerified:e.emailVerified||!1,phoneNumber:e.phoneNumber||null,isAnonymous:e.isAnonymous||!1,metadata:new yu(e.createdAt,e.lastLoginAt),providerData:[]})}function Nu(){}function Du(t){return Tt().then(function(){if(t.C)throw new Pi("app-deleted")})}function Ru(t){return M(t.providerData,function(t){return t.providerId})}function Ou(t,e){e&&(xu(t,e.providerId),t.providerData.push(e))}function xu(t,e){j(t.providerData,function(t){return t.providerId==e})}function Mu(t,e,n){("uid"!=e||n)&&t.hasOwnProperty(e)&&Si(t,e,n)}function Lu(t,e){t!=e&&(Ii(t,{uid:e.uid,displayName:e.displayName,photoURL:e.photoURL,email:e.email,emailVerified:e.emailVerified,phoneNumber:e.phoneNumber,isAnonymous:e.isAnonymous,providerData:[]}),e.metadata?Si(t,"metadata",function(t){return new yu(t.a,t.b)}(e.metadata)):Si(t,"metadata",new yu),x(e.providerData,function(e){Ou(t,e)}),function(t,e){t.b=e.b,t.a=e.a,t.c=e.c}(t.h,e.h),Si(t,"refreshToken",t.h.a))}function Fu(t){return t.F().then(function(e){var n=t.isAnonymous;return function(t,e){return Ls(t.b,ys,{idToken:e}).then(m(t.uc,t))}(t,e).then(function(){return n||Mu(t,"isAnonymous",!1),e})})}function Uu(t,e){e[$o]&&t.qa!=e[$o]&&(vu(t.h,e),t.dispatchEvent(new mu("tokenChanged")),Iu(t,e[$o]),Mu(t,"refreshToken",t.h.a))}function ju(t,e){return Fu(t).then(function(){if(F(Ru(t),e))return ku(t).then(function(){throw new Pi("provider-already-linked")})})}function Wu(t,e,n){return ki({user:t,credential:Pr(e),additionalUserInfo:e=Ji(e),operationType:n})}function Bu(t,e){return Uu(t,e),t.reload().then(function(){return t})}function $u(t,n,i,r,o){if(!ai())return Et(new Pi("operation-not-supported-in-this-environment"));if(t.i&&!o)return Et(t.i);var s=Xi(i.providerId),a=pi(t.uid+":::"),u=null;(!hi()||Yn())&&t.u&&i.isOAuthProvider&&(u=ea(t.u,t.l,t.o,n,i,null,a,e.SDK_VERSION||null));var c=Hn(u,s&&s.Ba,s&&s.Aa);return r=r().then(function(){if(qu(t),!o)return t.F().then(function(){})}).then(function(){return eu(t.a,c,n,i,a,!!u)}).then(function(){return new gt(function(e,i){t.ha(n,null,new Pi("cancelled-popup-request"),t.g||null),t.f=e,t.v=i,t.g=a,t.c=t.a.Ea(t,n,c,a)})}).then(function(t){return c&&qn(c),t?ki(t):null}).s(function(t){throw c&&qn(c),t}),Hu(t,r,o)}function Vu(t,e,n,i,r){if(!ai())return Et(new Pi("operation-not-supported-in-this-environment"));if(t.i&&!r)return Et(t.i);var o=null,s=pi(t.uid+":::");return i=i().then(function(){if(qu(t),!r)return t.F().then(function(){})}).then(function(){return t.aa=s,ku(t)}).then(function(e){return t.ba&&(e=(e=t.ba).b.set(Ku,t.D(),e.a)),e}).then(function(){return t.a.Ca(e,n,s)}).s(function(e){if(o=e,t.ba)return Qu(t.ba);throw o}).then(function(){if(o)throw o}),Hu(t,i,r)}function qu(t){if(!t.a||!t.I){if(t.a&&!t.I)throw new Pi("internal-error");throw new Pi("auth-domain-config-required")}}function Hu(t,e,n){var i=function(t,e,n){return t.i&&!n?(e.cancel(),Et(t.i)):e.s(function(e){throw!e||"auth/user-disabled"!=e.code&&"auth/user-token-expired"!=e.code||(t.i||t.dispatchEvent(new mu("userInvalidated")),t.i=e),e})}(t,e,n);return t.G.push(i),i.ia(function(){U(t.G,i)}),i}function zu(t){if(!t.apiKey)return null;var e={apiKey:t.apiKey,authDomain:t.authDomain,appName:t.appName},n={};if(!(t.stsTokenManager&&t.stsTokenManager.accessToken&&t.stsTokenManager.expirationTime))return null;n[$o]=t.stsTokenManager.accessToken,n.refreshToken=t.stsTokenManager.refreshToken||null,n.expiresIn=(t.stsTokenManager.expirationTime-b())/1e3;var i=new _u(e,n,t);return t.providerData&&x(t.providerData,function(t){t&&Ou(i,ki(t))}),t.redirectEventId&&(i.aa=t.redirectEventId),i}ou.prototype.reset=function(){this.b=null,this.a&&(this.a.cancel(),this.a=null)},ou.prototype.h=function(t,e){if(t){this.reset(),this.g=!0;var n=t.b,i=t.c,r=t.a&&"auth/web-storage-unsupported"==t.a.code,o=t.a&&"auth/operation-not-supported-in-this-environment"==t.a.code;"unknown"!=n||r||o?t.a?(uu(this,!0,null,t.a),Tt()):e.wa(n,i)?function(t,e,n){n=n.wa(e.b,e.c);var i=e.f,r=e.g,o=!!e.b.match(/Redirect$/);n(i,r).then(function(e){uu(t,o,e,null)}).s(function(e){uu(t,o,null,e)})}(this,t,e):Et(new Pi("invalid-auth-event")):(uu(this,!1,null,null),Tt())}else Et(new Pi("invalid-auth-event"))},ou.prototype.fa=function(){var t=this;return new gt(function(e,n){t.b?t.b().then(e,n):(t.f.push(e),t.c.push(n),function(t){var e=new Pi("timeout");t.a&&t.a.cancel(),t.a=Me(tu.get()).then(function(){t.b||uu(t,!0,null,e)})}(t))})},cu.prototype.h=function(t,e){if(t){var n=t.b,i=t.c;t.a?(e.ha(t.b,null,t.a,t.c),Tt()):e.wa(n,i)?function(t,e){var n=t.c,i=t.b;e.wa(i,n)(t.f,t.g).then(function(t){e.ha(i,t,null,n)}).s(function(t){e.ha(i,null,t,n)})}(t,e):Et(new Pi("invalid-auth-event"))}else Et(new Pi("invalid-auth-event"))},lu.prototype.confirm=function(t){return t=Ar(this.verificationId,t),this.a(t)},fu.prototype.start=function(){this.a=this.c,function t(e,n){e.stop(),e.b=Me(function(t,e){return e?(t.a=t.c,t.g()):(e=t.a,t.a*=2,t.a>t.f&&(t.a=t.f),e)}(e,n)).then(function(){return t=r.document,e=null,mi()||!t?Tt():new gt(function(n){e=function(){mi()&&(t.removeEventListener("visibilitychange",e,!1),n())},t.addEventListener("visibilitychange",e,!1)}).s(function(n){throw t.removeEventListener("visibilitychange",e,!1),n});var t,e}).then(function(){return e.h()}).then(function(){t(e,!0)}).s(function(n){e.i(n)&&t(e,!1)})}(this,!0)},fu.prototype.stop=function(){this.b&&(this.b.cancel(),this.b=null)},pu.prototype.D=function(){return{apiKey:this.f.b,refreshToken:this.a,accessToken:this.b,expirationTime:this.c}},pu.prototype.getToken=function(t){return t=!!t,this.b&&!this.a?Et(new Pi("user-token-expired")):t||!this.b||b()>this.c-3e4?this.a?function(t,e){return function(t,e){return new gt(function(n,i){"refresh_token"==e.grant_type&&e.refresh_token||"authorization_code"==e.grant_type&&e.code?Yo(t,t.i+"?key="+encodeURIComponent(t.b),function(t){t?t.error?i(Us(t)):t.access_token&&t.refresh_token?n(t):i(new Pi("internal-error")):i(new Pi("network-request-failed"))},"POST",an(e).toString(),t.f,t.m.get()):i(new Pi("internal-error"))})}(t.f,e).then(function(e){return t.b=e.access_token,t.c=gu(e.expires_in),t.a=e.refresh_token,{accessToken:t.b,expirationTime:t.c,refreshToken:t.a}}).s(function(e){throw"auth/user-token-expired"==e.code&&(t.a=null),e})}(this,{grant_type:"refresh_token",refresh_token:this.a}):Tt(null):Tt({accessToken:this.b,expirationTime:this.c,refreshToken:this.a})},yu.prototype.D=function(){return{lastLoginAt:this.b,createdAt:this.a}},w(mu,ae),w(_u,Ne),_u.prototype.oa=function(t){this.ka=t,Ko(this.b,t)},_u.prototype.ea=function(){return this.ka},_u.prototype.xa=function(){return B(this.O)},_u.prototype.Ha=function(){this.w.b&&(this.w.stop(),this.w.start())},Si(_u.prototype,"providerId","firebase"),(t=_u.prototype).reload=function(){var t=this;return Hu(this,Du(this).then(function(){return Fu(t).then(function(){return ku(t)}).then(Nu)}))},t.ac=function(t){return this.F(t).then(function(t){return new function(t){var e=Ki(t);if(!(e&&e.exp&&e.auth_time&&e.iat))throw new Pi("internal-error","An internal error occurred. The token obtained by Firebase appears to be malformed. Please retry the operation.");Ii(this,{token:t,expirationTime:_i(1e3*e.exp),authTime:_i(1e3*e.auth_time),issuedAtTime:_i(1e3*e.iat),signInProvider:e.firebase&&e.firebase.sign_in_provider?e.firebase.sign_in_provider:null,claims:e})}(t)})},t.F=function(t){var e=this;return Hu(this,Du(this).then(function(){return e.h.getToken(t)}).then(function(t){if(!t)throw new Pi("internal-error");return t.accessToken!=e.qa&&(Iu(e,t.accessToken),e.dispatchEvent(new mu("tokenChanged"))),Mu(e,"refreshToken",t.refreshToken),t.accessToken}))},t.uc=function(t){if(!(t=t.users)||!t.length)throw new Pi("internal-error");Pu(this,{uid:(t=t[0]).localId,displayName:t.displayName,photoURL:t.photoUrl,email:t.email,emailVerified:!!t.emailVerified,phoneNumber:t.phoneNumber,lastLoginAt:t.lastLoginAt,createdAt:t.createdAt});for(var e=function(t){return(t=t.providerUserInfo)&&t.length?M(t,function(t){return new function(t,e,n,i,r,o){Ii(this,{uid:t,displayName:i||null,photoURL:r||null,email:n||null,phoneNumber:o||null,providerId:e})}(t.rawId,t.providerId,t.email,t.displayName,t.photoUrl,t.phoneNumber)}):[]}(t),n=0;n<e.length;n++)Ou(this,e[n]);Mu(this,"isAnonymous",!(this.email&&t.passwordHash||this.providerData&&this.providerData.length))},t.cb=function(t){var e=this,n=null;return Hu(this,t.f(this.b,this.uid).then(function(t){return Uu(e,t),n=Wu(e,t,"reauthenticate"),e.i=null,e.reload()}).then(function(){return n}),!0)},t.vc=function(t){return Ti("firebase.User.prototype.reauthenticateWithCredential is deprecated. Please use firebase.User.prototype.reauthenticateAndRetrieveDataWithCredential instead."),this.cb(t).then(function(){})},t.ab=function(t){var e=this,n=null;return Hu(this,ju(this,t.providerId).then(function(){return e.F()}).then(function(n){return t.c(e.b,n)}).then(function(t){return n=Wu(e,t,"link"),Bu(e,t)}).then(function(){return n}))},t.mc=function(t){return Ti("firebase.User.prototype.linkWithCredential is deprecated. Please use firebase.User.prototype.linkAndRetrieveDataWithCredential instead."),this.ab(t).then(function(t){return t.user})},t.nc=function(t,e){var n=this;return Hu(this,ju(this,"phone").then(function(){return du(Tu(n),t,e,m(n.ab,n))}))},t.wc=function(t,e){var n=this;return Hu(this,Tt().then(function(){return du(Tu(n),t,e,m(n.cb,n))}),!0)},t.mb=function(t){var e=this;return Hu(this,this.F().then(function(n){return e.b.mb(n,t)}).then(function(t){return Uu(e,t),e.reload()}))},t.Pc=function(t){var e=this;return Hu(this,this.F().then(function(n){return t.c(e.b,n)}).then(function(t){return Uu(e,t),e.reload()}))},t.nb=function(t){var e=this;return Hu(this,this.F().then(function(n){return e.b.nb(n,t)}).then(function(t){return Uu(e,t),e.reload()}))},t.ob=function(t){if(void 0===t.displayName&&void 0===t.photoURL)return Du(this);var e=this;return Hu(this,this.F().then(function(n){return e.b.ob(n,{displayName:t.displayName,photoUrl:t.photoURL})}).then(function(t){return Uu(e,t),Mu(e,"displayName",t.displayName||null),Mu(e,"photoURL",t.photoUrl||null),x(e.providerData,function(t){"password"===t.providerId&&(Si(t,"displayName",e.displayName),Si(t,"photoURL",e.photoURL))}),ku(e)}).then(Nu))},t.Nc=function(t){var e=this;return Hu(this,Fu(this).then(function(n){return F(Ru(e),t)?function(t,e,n){return Ls(t,ps,{idToken:e,deleteProvider:n})}(e.b,n,[t]).then(function(t){var n={};return x(t.providerUserInfo||[],function(t){n[t.providerId]=!0}),x(Ru(e),function(t){n[t]||xu(e,t)}),n[kr.PROVIDER_ID]||Si(e,"phoneNumber",null),ku(e)}):ku(e).then(function(){throw new Pi("no-such-provider")})}))},t.delete=function(){var t=this;return Hu(this,this.F().then(function(e){return Ls(t.b,fs,{idToken:e})}).then(function(){t.dispatchEvent(new mu("userDeleted"))})).then(function(){for(var e=0;e<t.G.length;e++)t.G[e].cancel("app-deleted");bu(t,null),Cu(t,null),t.G=[],t.C=!0,Su(t),Si(t,"refreshToken",null),t.a&&t.a.unsubscribe(t)})},t.sb=function(t,e){return!!("linkViaPopup"==t&&(this.g||null)==e&&this.f||"reauthViaPopup"==t&&(this.g||null)==e&&this.f||"linkViaRedirect"==t&&(this.aa||null)==e||"reauthViaRedirect"==t&&(this.aa||null)==e)},t.ha=function(t,e,n,i){"linkViaPopup"!=t&&"reauthViaPopup"!=t||i!=(this.g||null)||(n&&this.v?this.v(n):e&&!n&&this.f&&this.f(e),this.c&&(this.c.cancel(),this.c=null),delete this.f,delete this.v)},t.wa=function(t,e){return"linkViaPopup"==t&&e==(this.g||null)?m(this.xb,this):"reauthViaPopup"==t&&e==(this.g||null)?m(this.yb,this):"linkViaRedirect"==t&&(this.aa||null)==e?m(this.xb,this):"reauthViaRedirect"==t&&(this.aa||null)==e?m(this.yb,this):null},t.oc=function(t){var e=this;return $u(this,"linkViaPopup",t,function(){return ju(e,t.providerId).then(function(){return ku(e)})},!1)},t.xc=function(t){return $u(this,"reauthViaPopup",t,function(){return Tt()},!0)},t.pc=function(t){var e=this;return Vu(this,"linkViaRedirect",t,function(){return ju(e,t.providerId)},!1)},t.yc=function(t){return Vu(this,"reauthViaRedirect",t,function(){return Tt()},!0)},t.xb=function(t,e){var n=this;this.c&&(this.c.cancel(),this.c=null);var i=null;return Hu(this,this.F().then(function(i){return ss(n.b,{requestUri:t,sessionId:e,idToken:i})}).then(function(t){return i=Wu(n,t,"link"),Bu(n,t)}).then(function(){return i}))},t.yb=function(t,e){var n=this;this.c&&(this.c.cancel(),this.c=null);var i=null;return Hu(this,Tt().then(function(){return ur(as(n.b,{requestUri:t,sessionId:e}),n.uid)}).then(function(t){return i=Wu(n,t,"reauthenticate"),Uu(n,t),n.i=null,n.reload()}).then(function(){return i}),!0)},t.gb=function(t){var e=this,n=null;return Hu(this,this.F().then(function(e){return n=e,void 0===t||ot(t)?{}:$i(new Oi(t))}).then(function(t){return e.b.gb(n,t)}).then(function(t){if(e.email!=t)return e.reload()}).then(function(){}))},t.toJSON=function(){return this.D()},t.D=function(){var t={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&&ht(t,this.metadata.D()),x(this.providerData,function(e){t.providerData.push(function(t){var e,n={};for(e in t)t.hasOwnProperty(e)&&(n[e]=t[e]);return n}(e))}),t};var Ku={name:"redirectUser",A:"session"};function Qu(t){return ka(t.b,Ku,t.a)}function Yu(t){this.a=t,this.b=Ea(),this.c=null,this.f=function(t){var e=Ju("local"),n=Ju("session"),i=Ju("none");return function(t,e,n){var i=Ia(e,n),o=Sa(t,e.A);return t.get(e,n).then(function(s){var a=null;try{a=fi(r.localStorage.getItem(i))}catch(t){}if(a&&!s)return r.localStorage.removeItem(i),t.set(e,a,n);a&&s&&"localStorage"!=o.type&&r.localStorage.removeItem(i)})}(t.b,e,t.a).then(function(){return t.b.get(n,t.a)}).then(function(r){return r?n:t.b.get(i,t.a).then(function(n){return n?i:t.b.get(e,t.a).then(function(n){return n?e:t.b.get(Xu,t.a).then(function(t){return t?Ju(t):e})})})}).then(function(e){return t.c=e,Gu(t,e.A)}).s(function(){t.c||(t.c=e)})}(this),this.b.addListener(Ju("local"),this.a,m(this.g,this))}function Gu(t,e){var n,i=[];for(n in Ca)Ca[n]!==e&&i.push(ka(t.b,Ju(Ca[n]),t.a));return i.push(ka(t.b,Xu,t.a)),function(t){return new gt(function(e,n){var i=t.length,r=[];if(i)for(var o=function(t,n){i--,r[t]=n,0==i&&e(r)},s=function(t){n(t)},a=0;a<t.length;a++)St(t[a],_(o,a),s);else e(r)})}(i)}Yu.prototype.g=function(){var t=this,e=Ju("local");nc(this,function(){return Tt().then(function(){return t.c&&"local"!=t.c.A?t.b.get(e,t.a):null}).then(function(n){if(n)return Gu(t,"local").then(function(){t.c=e})})})};var Xu={name:"persistence",A:"session"};function Ju(t){return{name:"authUser",A:t}}function Zu(t,e){return nc(t,function(){return t.b.set(t.c,e.D(),t.a)})}function tc(t){return nc(t,function(){return ka(t.b,t.c,t.a)})}function ec(t,e){return nc(t,function(){return t.b.get(t.c,t.a).then(function(t){return t&&e&&(t.authDomain=e),zu(t||{})})})}function nc(t,e){return t.f=t.f.then(e,e),t.f}function ic(t){if(this.l=!1,Si(this,"settings",new hu),Si(this,"app",t),!hc(this).options||!hc(this).options.apiKey)throw new Pi("invalid-api-key");t=e.SDK_VERSION?ii(e.SDK_VERSION):null,this.b=new Wo(hc(this).options&&hc(this).options.apiKey,Bs(js),t),this.N=[],this.o=[],this.I=[],this.Pb=e.INTERNAL.createSubscribe(m(this.ic,this)),this.O=void 0,this.Qb=e.INTERNAL.createSubscribe(m(this.jc,this)),uc(this,null),this.h=new Yu(hc(this).options.apiKey+":"+hc(this).name),this.w=new function(t){this.a=t,this.b=Ea()}(hc(this).options.apiKey+":"+hc(this).name),this.V=pc(this,function(t){var e=hc(t).options.authDomain,n=function(t){var e=function(t,e){return t.b.get(Ku,t.a).then(function(t){return t&&e&&(t.authDomain=e),zu(t||{})})}(t.w,hc(t).options.authDomain).then(function(e){return(t.C=e)&&(e.ba=t.w),Qu(t.w)});return pc(t,e)}(t).then(function(){return ec(t.h,e)}).then(function(e){return e?(e.ba=t.w,t.C&&(t.C.aa||null)==(e.aa||null)?e:e.reload().then(function(){return Zu(t.h,e).then(function(){return e})}).s(function(n){return"auth/network-request-failed"==n.code?e:tc(t.h)})):null}).then(function(e){uc(t,e||null)});return pc(t,n)}(this)),this.i=pc(this,function(t){return t.V.then(function(){return t.fa()}).s(function(){}).then(function(){if(!t.l)return t.ka()}).s(function(){}).then(function(){if(!t.l){t.X=!0;var e=t.h;e.b.addListener(Ju("local"),e.a,t.ka)}})}(this)),this.X=!1,this.ka=m(this.Jc,this),this.Ha=m(this.Z,this),this.qa=m(this.Yb,this),this.ra=m(this.gc,this),this.sa=m(this.hc,this),function(t){var e=hc(t).options.authDomain,n=hc(t).options.apiKey;e&&ai()&&(t.Ob=t.V.then(function(){if(!t.l){if(t.a=ru(e,n,hc(t).name),t.a.subscribe(t),lc(t)&&Au(lc(t)),t.C){Au(t.C);var i=t.C;i.oa(t.ea()),bu(i,t),wu(i=t.C,t.G),Cu(i,t),t.C=null}return t.a}}))}(this),this.INTERNAL={},this.INTERNAL.delete=m(this.delete,this),this.INTERNAL.logFramework=m(this.qc,this),this.u=0,Ne.call(this),function(t){Object.defineProperty(t,"lc",{get:function(){return this.ea()},set:function(t){this.oa(t)},enumerable:!1}),t.W=null}(this),this.G=[]}function rc(t){ae.call(this,"languageCodeChanged"),this.g=t}function oc(t){ae.call(this,"frameworkChanged"),this.c=t}function sc(t){return t.Ob||Et(new Pi("auth-domain-config-required"))}function ac(t,e){var n={};return n.apiKey=hc(t).options.apiKey,n.authDomain=hc(t).options.authDomain,n.appName=hc(t).name,t.V.then(function(){return function(t,e,n,i){var r=new _u(t,e);return n&&(r.ba=n),i&&wu(r,i),r.reload().then(function(){return r})}(n,e,t.w,t.xa())}).then(function(e){return lc(t)&&e.uid==lc(t).uid?(Lu(lc(t),e),t.Z(e)):(uc(t,e),Au(e),t.Z(e))}).then(function(){fc(t)})}function uc(t,e){lc(t)&&(function(t,e){j(t.N,function(t){return t==e})}(lc(t),t.Ha),we(lc(t),"tokenChanged",t.qa),we(lc(t),"userDeleted",t.ra),we(lc(t),"userInvalidated",t.sa),Su(lc(t))),e&&(e.N.push(t.Ha),me(e,"tokenChanged",t.qa),me(e,"userDeleted",t.ra),me(e,"userInvalidated",t.sa),0<t.u&&Eu(e)),Si(t,"currentUser",e),e&&(e.oa(t.ea()),bu(e,t),wu(e,t.G),Cu(e,t))}function cc(t,e){var n=null,i=null;return pc(t,e.then(function(e){return n=Pr(e),i=Ji(e),ac(t,e)}).then(function(){return ki({user:lc(t),credential:n,additionalUserInfo:i,operationType:"signIn"})}))}function hc(t){return t.app}function lc(t){return t.currentUser}function dc(t){return lc(t)&&lc(t)._lat||null}function fc(t){if(t.X){for(var e=0;e<t.o.length;e++)t.o[e]&&t.o[e](dc(t));if(t.O!==t.getUid()&&t.I.length)for(t.O=t.getUid(),e=0;e<t.I.length;e++)t.I[e]&&t.I[e](dc(t))}}function pc(t,e){return t.N.push(e),e.ia(function(){U(t.N,e)}),e}function vc(){}function gc(){this.a={},this.b=1e12}Yu.prototype.jb=function(t){var e=null,n=this;return function(t){var e=new Pi("invalid-persistence-type"),n=new Pi("unsupported-persistence-type");t:{for(i in Ca)if(Ca[i]==t){var i=!0;break t}i=!1}if(!i||"string"!=typeof t)throw e;switch(Xn()){case"ReactNative":if("session"===t)throw n;break;case"Node":if("none"!==t)throw n;break;default:if(!si()&&"none"!==t)throw n}}(t),nc(this,function(){return t!=n.c.A?n.b.get(n.c,n.a).then(function(i){return e=i,Gu(n,t)}).then(function(){if(n.c=Ju(t),e)return n.b.set(n.c,e,n.a)}):Tt()})},w(ic,Ne),w(rc,ae),w(oc,ae),(t=ic.prototype).jb=function(t){return pc(this,t=this.h.jb(t))},t.oa=function(t){this.W===t||this.l||(this.W=t,Ko(this.b,this.W),this.dispatchEvent(new rc(this.ea())))},t.ea=function(){return this.W},t.Qc=function(){var t=r.navigator;this.oa(t&&(t.languages&&t.languages[0]||t.language||t.userLanguage)||null)},t.qc=function(t){this.G.push(t),Qo(this.b,e.SDK_VERSION?ii(e.SDK_VERSION,this.G):null),this.dispatchEvent(new oc(this.G))},t.xa=function(){return B(this.G)},t.toJSON=function(){return{apiKey:hc(this).options.apiKey,authDomain:hc(this).options.authDomain,appName:hc(this).name,currentUser:lc(this)&&lc(this).D()}},t.sb=function(t,e){switch(t){case"unknown":case"signInViaRedirect":return!0;case"signInViaPopup":return this.g==e&&!!this.f;default:return!1}},t.ha=function(t,e,n,i){"signInViaPopup"==t&&this.g==i&&(n&&this.v?this.v(n):e&&!n&&this.f&&this.f(e),this.c&&(this.c.cancel(),this.c=null),delete this.f,delete this.v)},t.wa=function(t,e){return"signInViaRedirect"==t||"signInViaPopup"==t&&this.g==e&&this.f?m(this.Xb,this):null},t.Xb=function(t,e){var n=this;t={requestUri:t,sessionId:e},this.c&&(this.c.cancel(),this.c=null);var i=null,r=null,o=os(n.b,t).then(function(t){return i=Pr(t),r=Ji(t),t});return pc(this,t=n.V.then(function(){return o}).then(function(t){return ac(n,t)}).then(function(){return ki({user:lc(n),credential:i,additionalUserInfo:r,operationType:"signIn"})}))},t.Hc=function(t){if(!ai())return Et(new Pi("operation-not-supported-in-this-environment"));var n=this,i=Xi(t.providerId),r=pi(),o=null;(!hi()||Yn())&&hc(this).options.authDomain&&t.isOAuthProvider&&(o=ea(hc(this).options.authDomain,hc(this).options.apiKey,hc(this).name,"signInViaPopup",t,null,r,e.SDK_VERSION||null));var s=Hn(o,i&&i.Ba,i&&i.Aa);return pc(this,i=sc(this).then(function(e){return eu(e,s,"signInViaPopup",t,r,!!o)}).then(function(){return new gt(function(t,e){n.ha("signInViaPopup",null,new Pi("cancelled-popup-request"),n.g),n.f=t,n.v=e,n.g=r,n.c=n.a.Ea(n,"signInViaPopup",s,r)})}).then(function(t){return s&&qn(s),t?ki(t):null}).s(function(t){throw s&&qn(s),t}))},t.Ic=function(t){if(!ai())return Et(new Pi("operation-not-supported-in-this-environment"));var e=this;return pc(this,sc(this).then(function(){return nc(t=e.h,function(){return t.b.set(Xu,t.c.A,t.a)});var t}).then(function(){return e.a.Ca("signInViaRedirect",t)}))},t.fa=function(){if(!ai())return Et(new Pi("operation-not-supported-in-this-environment"));var t=this;return pc(this,sc(this).then(function(){return t.a.fa()}).then(function(t){return t?ki(t):null}))},t.Oc=function(t){if(!t)return Et(new Pi("null-user"));var e=this,n={};n.apiKey=hc(this).options.apiKey,n.authDomain=hc(this).options.authDomain,n.appName=hc(this).name;var i=function(t,e,n,i){e=e||{apiKey:t.l,authDomain:t.u,appName:t.o};var r=t.h,o={};return o[$o]=r.b,o.refreshToken=r.a,o.expiresIn=(r.c-b())/1e3,e=new _u(e,o),n&&(e.ba=n),i&&wu(e,i),Lu(e,t),e}(t,n,e.w,e.xa());return pc(this,this.i.then(function(){if(hc(e).options.apiKey!=t.l)return i.reload()}).then(function(){return lc(e)&&t.uid==lc(e).uid?(Lu(lc(e),t),e.Z(t)):(uc(e,i),Au(i),e.Z(i))}).then(function(){fc(e)}))},t.kb=function(){var t=this;return pc(this,this.i.then(function(){return lc(t)?(uc(t,null),tc(t.h).then(function(){fc(t)})):Tt()}))},t.Jc=function(){var t=this;return ec(this.h,hc(this).options.authDomain).then(function(e){if(!t.l){var n;if(n=lc(t)&&e){n=lc(t).uid;var i=e.uid;n=void 0!==n&&null!==n&&""!==n&&void 0!==i&&null!==i&&""!==i&&n==i}if(n)return Lu(lc(t),e),lc(t).F();(lc(t)||e)&&(uc(t,e),e&&(Au(e),e.ba=t.w),t.a&&t.a.subscribe(t),fc(t))}})},t.Z=function(t){return Zu(this.h,t)},t.Yb=function(){fc(this),this.Z(lc(this))},t.gc=function(){this.kb()},t.hc=function(){this.kb()},t.ic=function(t){var e=this;this.addAuthTokenListener(function(){t.next(lc(e))})},t.jc=function(t){var e=this;!function(t,e){t.I.push(e),pc(t,t.i.then(function(){!t.l&&F(t.I,e)&&t.O!==t.getUid()&&(t.O=t.getUid(),e(dc(t)))}))}(this,function(){t.next(lc(e))})},t.sc=function(t,n,i){var r=this;return this.X&&e.Promise.resolve().then(function(){d(t)?t(lc(r)):d(t.next)&&t.next(lc(r))}),this.Pb(t,n,i)},t.rc=function(t,n,i){var r=this;return this.X&&e.Promise.resolve().then(function(){r.O=r.getUid(),d(t)?t(lc(r)):d(t.next)&&t.next(lc(r))}),this.Qb(t,n,i)},t.$b=function(t){var e=this;return pc(this,this.i.then(function(){return lc(e)?lc(e).F(t).then(function(t){return{accessToken:t}}):null}))},t.Jb=function(t){var e=this;return this.i.then(function(){return cc(e,Ls(e.b,Ds,{token:t}))}).then(function(t){var n=t.user;return Mu(n,"isAnonymous",!1),e.Z(n),t})},t.Bc=function(t){return Ti("firebase.auth.Auth.prototype.signInAndRetrieveDataWithCustomToken is deprecated. Please use firebase.auth.Auth.prototype.signInWithCustomToken instead."),this.Jb(t)},t.Cc=function(t,e){return Ti("firebase.auth.Auth.prototype.signInAndRetrieveDataWithEmailAndPassword is deprecated. Please use firebase.auth.Auth.prototype.signInWithEmailAndPassword instead."),this.Kb(t,e)},t.Kb=function(t,e){var n=this;return this.i.then(function(){return cc(n,Ls(n.b,Rs,{email:t,password:e}))})},t.ub=function(t,e){var n=this;return this.i.then(function(){return cc(n,Ls(n.b,ls,{email:t,password:e}))})},t.Sb=function(t,e){return Ti("firebase.auth.Auth.prototype.createUserAndRetrieveDataWithEmailAndPassword is deprecated. Please use firebase.auth.Auth.prototype.createUserWithEmailAndPassword instead."),this.ub(t,e)},t.Ec=function(t){return Ti("firebase.auth.Auth.prototype.signInWithCredential is deprecated. Please use firebase.auth.Auth.prototype.signInAndRetrieveDataWithCredential instead."),this.Oa(t).then(function(t){return t.user})},t.Oa=function(t){var e=this;return this.i.then(function(){return cc(e,t.ya(e.b))})},t.Pa=function(){var t=this;return this.i.then(function(){var e=lc(t);return e&&e.isAnonymous?ki({user:e,credential:null,additionalUserInfo:ki({providerId:null,isNewUser:!1}),operationType:"signIn"}):cc(t,t.b.Pa()).then(function(e){var n=e.user;return Mu(n,"isAnonymous",!0),t.Z(n),e})})},t.Dc=function(){return Ti("firebase.auth.Auth.prototype.signInAnonymouslyAndRetrieveData is deprecated. Please use firebase.auth.Auth.prototype.signInAnonymously instead."),this.Pa()},t.getUid=function(){return lc(this)&&lc(this).uid||null},t.Rb=function(t){this.addAuthTokenListener(t),this.u++,0<this.u&&lc(this)&&Eu(lc(this))},t.zc=function(t){var e=this;x(this.o,function(n){n==t&&e.u--}),0>this.u&&(this.u=0),0==this.u&&lc(this)&&Su(lc(this)),this.removeAuthTokenListener(t)},t.addAuthTokenListener=function(t){var e=this;this.o.push(t),pc(this,this.i.then(function(){e.l||F(e.o,t)&&t(dc(e))}))},t.removeAuthTokenListener=function(t){j(this.o,function(e){return e==t})},t.delete=function(){this.l=!0;for(var t=0;t<this.N.length;t++)this.N[t].cancel("app-deleted");return this.N=[],this.h&&(t=this.h).b.removeListener(Ju("local"),t.a,this.ka),this.a&&this.a.unsubscribe(this),e.Promise.resolve()},t.Vb=function(t){return Ti("firebase.auth.Auth.prototype.fetchProvidersForEmail is deprecated. Please use firebase.auth.Auth.prototype.fetchSignInMethodsForEmail instead."),pc(this,function(t,e){return Ls(t,ds,{identifier:e,continueUri:ui()?Bn():"http://localhost"}).then(function(t){return t.allProviders||[]})}(this.b,t))},t.Wb=function(t){return pc(this,function(t,e){return Ls(t,ds,{identifier:e,continueUri:ui()?Bn():"http://localhost"}).then(function(t){return t.signinMethods||[]})}(this.b,t))},t.kc=function(t){return!!Er(t)},t.ib=function(t,e){var n=this;return pc(this,Tt().then(function(){var t=new Oi(e);if(!t.c)throw new Pi("argument-error",Mi+" must be true when sending sign in link to email");return $i(t)}).then(function(e){return n.b.ib(t,e)}).then(function(){}))},t.Rc=function(t){return this.Ja(t).then(function(t){return t.data.email})},t.Xa=function(t,e){return pc(this,this.b.Xa(t,e).then(function(){}))},t.Ja=function(t){return pc(this,this.b.Ja(t).then(function(t){return new function(t){var e={},n=t.email,i=t.newEmail;if(!(t=t.requestType)||"EMAIL_SIGNIN"!=t&&!n)throw Error("Invalid provider user info!");e.fromEmail=i||null,e.email=n||null,Si(this,"operation",t),Si(this,"data",Ai(e))}(t)}))},t.Va=function(t){return pc(this,this.b.Va(t).then(function(){}))},t.hb=function(t,e){var n=this;return pc(this,Tt().then(function(){return void 0===e||ot(e)?{}:$i(new Oi(e))}).then(function(e){return n.b.hb(t,e)}).then(function(){}))},t.Gc=function(t,e){return pc(this,du(this,t,e,m(this.Oa,this)))},t.Fc=function(t,e){var n=this;return pc(this,Tt().then(function(){var i=Tr(t,e||Bn());return n.Oa(i)}))},vc.prototype.render=function(){},vc.prototype.reset=function(){},vc.prototype.getResponse=function(){},vc.prototype.execute=function(){};var yc=null;function mc(t,e){return(e=_c(e))&&t.a[e]||null}function _c(t){return(t=void 0===t?1e12:t)?t.toString():null}function bc(t,e){this.g=!1,this.c=e,this.a=this.b=null,this.h="invisible"!==this.c.size,this.f=Rn(t);var n=this;this.i=function(){n.execute()},this.h?this.execute():me(this.f,"click",this.i)}function wc(t){if(t.g)throw Error("reCAPTCHA mock was already deleted!")}function Cc(){}gc.prototype.render=function(t,e){return this.a[this.b.toString()]=new bc(t,e),this.b++},gc.prototype.reset=function(t){var e=mc(this,t);t=_c(t),e&&t&&(e.delete(),delete this.a[t])},gc.prototype.getResponse=function(t){return(t=mc(this,t))?t.getResponse():null},gc.prototype.execute=function(t){(t=mc(this,t))&&t.execute()},bc.prototype.getResponse=function(){return wc(this),this.b},bc.prototype.execute=function(){wc(this);var t=this;this.a||(this.a=setTimeout(function(){t.b=function(){for(var t=50,e=[];0<t;)e.push("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".charAt(Math.floor(62*Math.random()))),t--;return e.join("")}();var e=t.c.callback,n=t.c["expired-callback"];if(e)try{e(t.b)}catch(t){}t.a=setTimeout(function(){if(t.a=null,t.b=null,n)try{n()}catch(t){}t.h&&t.execute()},6e4)},500))},bc.prototype.delete=function(){wc(this),this.g=!0,clearTimeout(this.a),this.a=null,we(this.f,"click",this.i)},Cc.prototype.g=function(){return yc||(yc=new gc),Tt(yc)},Cc.prototype.c=function(){};var Tc=null;function Ec(){this.b=r.grecaptcha?1/0:0,this.f=null,this.a="__rcb"+Math.floor(1e6*Math.random()).toString()}var Sc=gn("https://www.google.com/recaptcha/api.js?onload=%{onload}&render=explicit&hl=%{hl}"),Ic=new yi(3e4,6e4);Ec.prototype.g=function(t){var e=this;return new gt(function(n,i){var o=setTimeout(function(){i(new Pi("network-request-failed"))},Ic.get());!r.grecaptcha||t!==e.f&&!e.b?(r[e.a]=function(){if(r.grecaptcha){e.f=t;var s=r.grecaptcha.render;r.grecaptcha.render=function(t,n){return t=s(t,n),e.b++,t},clearTimeout(o),n(r.grecaptcha)}else clearTimeout(o),i(new Pi("internal-error"));delete r[e.a]},Tt(Oo(_n(Sc,{onload:e.a,hl:t||""}))).s(function(){clearTimeout(o),i(new Pi("internal-error","Unable to load external reCAPTCHA dependencies!"))})):(clearTimeout(o),n(r.grecaptcha))})},Ec.prototype.c=function(){this.b--};var kc=null;function Ac(t,e,n,i,o,s,a){if(Si(this,"type","recaptcha"),this.c=this.f=null,this.C=!1,this.l=e,this.g=null,a?(Tc||(Tc=new Cc),a=Tc):(kc||(kc=new Ec),a=kc),this.o=a,this.a=n||{theme:"light",type:"image"},this.h=[],this.a[Dc])throw new Pi("argument-error","sitekey should not be provided for reCAPTCHA as one is automatically provisioned for the current project.");if(this.i="invisible"===this.a[Rc],!r.document)throw new Pi("operation-not-supported-in-this-environment","RecaptchaVerifier is only supported in a browser HTTP/HTTPS environment with DOM support.");if(!Rn(e)||!this.i&&Rn(e).hasChildNodes())throw new Pi("argument-error","reCAPTCHA container is either not found or already contains inner elements!");this.u=new Wo(t,s||null,o||null),this.v=i||function(){return null};var u=this;this.m=[];var c=this.a[Pc];this.a[Pc]=function(t){if(Oc(u,t),"function"==typeof c)c(t);else if("string"==typeof c){var e=oi(c,r);"function"==typeof e&&e(t)}};var h=this.a[Nc];this.a[Nc]=function(){if(Oc(u,null),"function"==typeof h)h();else if("string"==typeof h){var t=oi(h,r);"function"==typeof t&&t()}}}var Pc="callback",Nc="expired-callback",Dc="sitekey",Rc="size";function Oc(t,e){for(var n=0;n<t.m.length;n++)try{t.m[n](e)}catch(t){}}function xc(t,e){return t.h.push(e),e.ia(function(){U(t.h,e)}),e}function Mc(t){if(t.C)throw new Pi("internal-error","RecaptchaVerifier instance has been destroyed.")}function Lc(t,n,i){var r=!1;try{this.b=i||e.app()}catch(t){throw new Pi("argument-error","No firebase.app.App instance is currently initialized.")}if(!this.b.options||!this.b.options.apiKey)throw new Pi("invalid-api-key");i=this.b.options.apiKey;var o=this,s=null;try{s=this.b.auth().xa()}catch(t){}try{r=this.b.auth().settings.appVerificationDisabledForTesting}catch(t){}s=e.SDK_VERSION?ii(e.SDK_VERSION,s):null,Ac.call(this,i,t,n,function(){try{var t=o.b.auth().ea()}catch(e){t=null}return t},s,Bs(js),r)}function Fc(t,e,n,i){t:{n=Array.prototype.slice.call(n);for(var r=0,o=!1,s=0;s<e.length;s++)if(e[s].optional)o=!0;else{if(o)throw new Pi("internal-error","Argument validator encountered a required argument after an optional argument.");r++}if(o=e.length,n.length<r||o<n.length)i="Expected "+(r==o?1==r?"1 argument":r+" arguments":r+"-"+o+" arguments")+" but got "+n.length+".";else{for(r=0;r<n.length;r++)if(o=e[r].optional&&void 0===n[r],!e[r].M(n[r])&&!o){if(e=e[r],0>r||r>=Uc.length)throw new Pi("internal-error","Argument validator received an unsupported number of arguments.");n=Uc[r],i=(i?"":n+" argument ")+(e.name?'"'+e.name+'" ':"")+"must be "+e.K+".";break t}i=null}}if(i)throw new Pi("argument-error",t+" failed: "+i)}(t=Ac.prototype).za=function(){var t=this;return this.f?this.f:this.f=xc(this,Tt().then(function(){if(ui()&&!Gn())return Kn();throw new Pi("operation-not-supported-in-this-environment","RecaptchaVerifier is only supported in a browser HTTP/HTTPS environment.")}).then(function(){return t.o.g(t.v())}).then(function(e){return t.g=e,Ls(t.u,Cs,{})}).then(function(e){t.a[Dc]=e.recaptchaSiteKey}).s(function(e){throw t.f=null,e}))},t.render=function(){Mc(this);var t=this;return xc(this,this.za().then(function(){if(null===t.c){var e=t.l;if(!t.i){var n=Rn(e);e=function(t,e,n){var i=arguments,r=document,s=String(i[0]),a=i[1];if(!dn&&a&&(a.name||a.type)){if(s=["<",s],a.name&&s.push(' name="',q(a.name),'"'),a.type){s.push(' type="',q(a.type),'"');var u={};ht(u,a),delete u.type,a=u}s.push(">"),s=s.join("")}return s=r.createElement(s),a&&(o(a)?s.className=a:h(a)?s.className=a.join(" "):On(s,a)),2<i.length&&function(t,e,n){function i(n){n&&e.appendChild(o(n)?t.createTextNode(n):n)}for(var r=2;r<n.length;r++){var s=n[r];!l(s)||f(s)&&0<s.nodeType?i(s):x(Mn(s)?B(s):s,i)}}(r,s,i),s}("DIV"),n.appendChild(e)}t.c=t.g.render(e,t.a)}return t.c}))},t.verify=function(){Mc(this);var t=this;return xc(this,this.render().then(function(e){return new gt(function(n){var i=t.g.getResponse(e);if(i)n(i);else{var r=function(e){e&&(function(t,e){j(t.m,function(t){return t==e})}(t,r),n(e))};t.m.push(r),t.i&&t.g.execute(t.c)}})}))},t.reset=function(){Mc(this),null!==this.c&&this.g.reset(this.c)},t.clear=function(){Mc(this),this.C=!0,this.o.c();for(var t=0;t<this.h.length;t++)this.h[t].cancel("RecaptchaVerifier instance has been destroyed.");if(!this.i){t=Rn(this.l);for(var e;e=t.firstChild;)t.removeChild(e)}},w(Lc,Ac);var Uc="First Second Third Fourth Fifth Sixth Seventh Eighth Ninth".split(" ");function jc(t,e){return{name:t||"",K:"a valid string",optional:!!e,M:o}}function Wc(t,e){return{name:t||"",K:"a boolean",optional:!!e,M:s}}function Bc(t,e){return{name:t||"",K:"a valid object",optional:!!e,M:f}}function $c(t,e){return{name:t||"",K:"a function",optional:!!e,M:d}}function Vc(t,e){return{name:t||"",K:"null",optional:!!e,M:c}}function qc(t){return{name:t?t+"Credential":"credential",K:t?"a valid "+t+" credential":"a valid credential",optional:!1,M:function(e){if(!e)return!1;var n=!t||e.providerId===t;return!(!e.ya||!n)}}}function Hc(){return{name:"applicationVerifier",K:"an implementation of firebase.auth.ApplicationVerifier",optional:!1,M:function(t){return!!(t&&o(t.type)&&d(t.verify))}}}function zc(t,e,n,i){return{name:n||"",K:t.K+" or "+e.K,optional:!!i,M:function(n){return t.M(n)||e.M(n)}}}function Kc(t,e){for(var n in e){var i=e[n].name;t[i]=Gc(i,t[n],e[n].j)}}function Qc(t,e){for(var n in e){var i=e[n].name;if(i!==n){var r=e[n].qb;Object.defineProperty(t,i,{get:function(){return this[n]},set:function(t){Fc(i,[r],[t],!0),this[n]=t},enumerable:!0})}}}function Yc(t,e,n,i){t[e]=Gc(e,n,i)}function Gc(t,e,n){function i(){var t=Array.prototype.slice.call(arguments);return Fc(o,n,t),e.apply(this,t)}if(!n)return e;var r,o=function(t){return(t=t.split("."))[t.length-1]}(t);for(r in e)i[r]=e[r];for(r in e.prototype)i.prototype[r]=e.prototype[r];return i}Kc(ic.prototype,{Va:{name:"applyActionCode",j:[jc("code")]},Ja:{name:"checkActionCode",j:[jc("code")]},Xa:{name:"confirmPasswordReset",j:[jc("code"),jc("newPassword")]},ub:{name:"createUserWithEmailAndPassword",j:[jc("email"),jc("password")]},Sb:{name:"createUserAndRetrieveDataWithEmailAndPassword",j:[jc("email"),jc("password")]},Vb:{name:"fetchProvidersForEmail",j:[jc("email")]},Wb:{name:"fetchSignInMethodsForEmail",j:[jc("email")]},fa:{name:"getRedirectResult",j:[]},kc:{name:"isSignInWithEmailLink",j:[jc("emailLink")]},rc:{name:"onAuthStateChanged",j:[zc(Bc(),$c(),"nextOrObserver"),$c("opt_error",!0),$c("opt_completed",!0)]},sc:{name:"onIdTokenChanged",j:[zc(Bc(),$c(),"nextOrObserver"),$c("opt_error",!0),$c("opt_completed",!0)]},hb:{name:"sendPasswordResetEmail",j:[jc("email"),zc(Bc("opt_actionCodeSettings",!0),Vc(null,!0),"opt_actionCodeSettings",!0)]},ib:{name:"sendSignInLinkToEmail",j:[jc("email"),Bc("actionCodeSettings")]},jb:{name:"setPersistence",j:[jc("persistence")]},Oa:{name:"signInAndRetrieveDataWithCredential",j:[qc()]},Pa:{name:"signInAnonymously",j:[]},Dc:{name:"signInAnonymouslyAndRetrieveData",j:[]},Ec:{name:"signInWithCredential",j:[qc()]},Jb:{name:"signInWithCustomToken",j:[jc("token")]},Bc:{name:"signInAndRetrieveDataWithCustomToken",j:[jc("token")]},Kb:{name:"signInWithEmailAndPassword",j:[jc("email"),jc("password")]},Fc:{name:"signInWithEmailLink",j:[jc("email"),jc("emailLink",!0)]},Cc:{name:"signInAndRetrieveDataWithEmailAndPassword",j:[jc("email"),jc("password")]},Gc:{name:"signInWithPhoneNumber",j:[jc("phoneNumber"),Hc()]},Hc:{name:"signInWithPopup",j:[{name:"authProvider",K:"a valid Auth provider",optional:!1,M:function(t){return!!(t&&t.providerId&&t.hasOwnProperty&&t.hasOwnProperty("isOAuthProvider"))}}]},Ic:{name:"signInWithRedirect",j:[{name:"authProvider",K:"a valid Auth provider",optional:!1,M:function(t){return!!(t&&t.providerId&&t.hasOwnProperty&&t.hasOwnProperty("isOAuthProvider"))}}]},Oc:{name:"updateCurrentUser",j:[zc({name:"user",K:"an instance of Firebase User",optional:!1,M:function(t){return!!(t&&t instanceof _u)}},Vc(),"user")]},kb:{name:"signOut",j:[]},toJSON:{name:"toJSON",j:[jc(null,!0)]},Qc:{name:"useDeviceLanguage",j:[]},Rc:{name:"verifyPasswordResetCode",j:[jc("code")]}}),Qc(ic.prototype,{lc:{name:"languageCode",qb:zc(jc(),Vc(),"languageCode")}}),ic.Persistence=Ca,ic.Persistence.LOCAL="local",ic.Persistence.SESSION="session",ic.Persistence.NONE="none",Kc(_u.prototype,{delete:{name:"delete",j:[]},ac:{name:"getIdTokenResult",j:[Wc("opt_forceRefresh",!0)]},F:{name:"getIdToken",j:[Wc("opt_forceRefresh",!0)]},ab:{name:"linkAndRetrieveDataWithCredential",j:[qc()]},mc:{name:"linkWithCredential",j:[qc()]},nc:{name:"linkWithPhoneNumber",j:[jc("phoneNumber"),Hc()]},oc:{name:"linkWithPopup",j:[{name:"authProvider",K:"a valid Auth provider",optional:!1,M:function(t){return!!(t&&t.providerId&&t.hasOwnProperty&&t.hasOwnProperty("isOAuthProvider"))}}]},pc:{name:"linkWithRedirect",j:[{name:"authProvider",K:"a valid Auth provider",optional:!1,M:function(t){return!!(t&&t.providerId&&t.hasOwnProperty&&t.hasOwnProperty("isOAuthProvider"))}}]},cb:{name:"reauthenticateAndRetrieveDataWithCredential",j:[qc()]},vc:{name:"reauthenticateWithCredential",j:[qc()]},wc:{name:"reauthenticateWithPhoneNumber",j:[jc("phoneNumber"),Hc()]},xc:{name:"reauthenticateWithPopup",j:[{name:"authProvider",K:"a valid Auth provider",optional:!1,M:function(t){return!!(t&&t.providerId&&t.hasOwnProperty&&t.hasOwnProperty("isOAuthProvider"))}}]},yc:{name:"reauthenticateWithRedirect",j:[{name:"authProvider",K:"a valid Auth provider",optional:!1,M:function(t){return!!(t&&t.providerId&&t.hasOwnProperty&&t.hasOwnProperty("isOAuthProvider"))}}]},reload:{name:"reload",j:[]},gb:{name:"sendEmailVerification",j:[zc(Bc("opt_actionCodeSettings",!0),Vc(null,!0),"opt_actionCodeSettings",!0)]},toJSON:{name:"toJSON",j:[jc(null,!0)]},Nc:{name:"unlink",j:[jc("provider")]},mb:{name:"updateEmail",j:[jc("email")]},nb:{name:"updatePassword",j:[jc("password")]},Pc:{name:"updatePhoneNumber",j:[qc("phone")]},ob:{name:"updateProfile",j:[Bc("profile")]}}),Kc(gc.prototype,{execute:{name:"execute"},render:{name:"render"},reset:{name:"reset"},getResponse:{name:"getResponse"}}),Kc(vc.prototype,{execute:{name:"execute"},render:{name:"render"},reset:{name:"reset"},getResponse:{name:"getResponse"}}),Kc(gt.prototype,{ia:{name:"finally"},s:{name:"catch"},then:{name:"then"}}),Qc(hu.prototype,{appVerificationDisabled:{name:"appVerificationDisabledForTesting",qb:Wc("appVerificationDisabledForTesting")}}),Kc(lu.prototype,{confirm:{name:"confirm",j:[jc("verificationCode")]}}),Yc(Cr,"credential",function(t,e){return new wr(t,e)},[jc("email"),jc("password")]),Kc(fr.prototype,{ta:{name:"addScope",j:[jc("scope")]},Da:{name:"setCustomParameters",j:[Bc("customOAuthParameters")]}}),Yc(fr,"credential",pr,[zc(jc(),Bc(),"token")]),Yc(Cr,"credentialWithLink",Tr,[jc("email"),jc("emailLink")]),Kc(vr.prototype,{ta:{name:"addScope",j:[jc("scope")]},Da:{name:"setCustomParameters",j:[Bc("customOAuthParameters")]}}),Yc(vr,"credential",gr,[zc(jc(),Bc(),"token")]),Kc(yr.prototype,{ta:{name:"addScope",j:[jc("scope")]},Da:{name:"setCustomParameters",j:[Bc("customOAuthParameters")]}}),Yc(yr,"credential",mr,[zc(jc(),zc(Bc(),Vc()),"idToken"),zc(jc(),Vc(),"accessToken",!0)]),Kc(_r.prototype,{Da:{name:"setCustomParameters",j:[Bc("customOAuthParameters")]}}),Yc(_r,"credential",br,[zc(jc(),Bc(),"token"),jc("secret",!0)]),Kc(dr.prototype,{ta:{name:"addScope",j:[jc("scope")]},credential:{name:"credential",j:[zc(jc(),Vc(),"idToken",!0),zc(jc(),Vc(),"accessToken",!0)]},Da:{name:"setCustomParameters",j:[Bc("customOAuthParameters")]}}),Yc(kr,"credential",Ar,[jc("verificationId"),jc("verificationCode")]),Kc(kr.prototype,{Ta:{name:"verifyPhoneNumber",j:[jc("phoneNumber"),Hc()]}}),Kc(Pi.prototype,{toJSON:{name:"toJSON",j:[jc(null,!0)]}}),Kc(Lr.prototype,{toJSON:{name:"toJSON",j:[jc(null,!0)]}}),Kc(Mr.prototype,{toJSON:{name:"toJSON",j:[jc(null,!0)]}}),Kc(Lc.prototype,{clear:{name:"clear",j:[]},render:{name:"render",j:[]},verify:{name:"verify",j:[]}}),function(){if(void 0===e||!e.INTERNAL||!e.INTERNAL.registerService)throw Error("Cannot find the firebase namespace; be sure to include firebase-app.js before this library.");var t={Auth:ic,Error:Pi};Yc(t,"EmailAuthProvider",Cr,[]),Yc(t,"FacebookAuthProvider",fr,[]),Yc(t,"GithubAuthProvider",vr,[]),Yc(t,"GoogleAuthProvider",yr,[]),Yc(t,"TwitterAuthProvider",_r,[]),Yc(t,"OAuthProvider",dr,[jc("providerId")]),Yc(t,"PhoneAuthProvider",kr,[{name:"auth",K:"an instance of Firebase Auth",optional:!0,M:function(t){return!!(t&&t instanceof ic)}}]),Yc(t,"RecaptchaVerifier",Lc,[zc(jc(),{name:"",K:"an HTML element",optional:!1,M:function(t){return!!(t&&t instanceof Element)}},"recaptchaContainer"),Bc("recaptchaParameters",!0),{name:"app",K:"an instance of Firebase App",optional:!0,M:function(t){return!!(t&&t instanceof e.app.App)}}]),e.INTERNAL.registerService("auth",function(t,e){return e({INTERNAL:{getUid:m((t=new ic(t)).getUid,t),getToken:m(t.$b,t),addAuthTokenListener:m(t.Rb,t),removeAuthTokenListener:m(t.zc,t)}}),t},t,function(t,e){if("create"===t)try{e.auth()}catch(t){}}),e.INTERNAL.extendNamespace({User:_u})}()}).call(void 0!==t?t:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})}).call(this,n(6))},function(t,e){!function(t){"use strict";if(!t.fetch){var e={searchParams:"URLSearchParams"in t,iterable:"Symbol"in t&&"iterator"in Symbol,blob:"FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in t,arrayBuffer:"ArrayBuffer"in t};if(e.arrayBuffer)var n=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],i=function(t){return t&&DataView.prototype.isPrototypeOf(t)},r=ArrayBuffer.isView||function(t){return t&&n.indexOf(Object.prototype.toString.call(t))>-1};h.prototype.append=function(t,e){t=a(t),e=u(e);var n=this.map[t];this.map[t]=n?n+","+e:e},h.prototype.delete=function(t){delete this.map[a(t)]},h.prototype.get=function(t){return t=a(t),this.has(t)?this.map[t]:null},h.prototype.has=function(t){return this.map.hasOwnProperty(a(t))},h.prototype.set=function(t,e){this.map[a(t)]=u(e)},h.prototype.forEach=function(t,e){for(var n in this.map)this.map.hasOwnProperty(n)&&t.call(e,this.map[n],n,this)},h.prototype.keys=function(){var t=[];return this.forEach(function(e,n){t.push(n)}),c(t)},h.prototype.values=function(){var t=[];return this.forEach(function(e){t.push(e)}),c(t)},h.prototype.entries=function(){var t=[];return this.forEach(function(e,n){t.push([n,e])}),c(t)},e.iterable&&(h.prototype[Symbol.iterator]=h.prototype.entries);var o=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];g.prototype.clone=function(){return new g(this,{body:this._bodyInit})},v.call(g.prototype),v.call(m.prototype),m.prototype.clone=function(){return new m(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new h(this.headers),url:this.url})},m.error=function(){var t=new m(null,{status:0,statusText:""});return t.type="error",t};var s=[301,302,303,307,308];m.redirect=function(t,e){if(-1===s.indexOf(e))throw new RangeError("Invalid status code");return new m(null,{status:e,headers:{location:t}})},t.Headers=h,t.Request=g,t.Response=m,t.fetch=function(t,n){return new Promise(function(i,r){var o=new g(t,n),s=new XMLHttpRequest;s.onload=function(){var t,e,n={status:s.status,statusText:s.statusText,headers:(t=s.getAllResponseHeaders()||"",e=new h,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(t){var n=t.split(":"),i=n.shift().trim();if(i){var r=n.join(":").trim();e.append(i,r)}}),e)};n.url="responseURL"in s?s.responseURL:n.headers.get("X-Request-URL");var r="response"in s?s.response:s.responseText;i(new m(r,n))},s.onerror=function(){r(new TypeError("Network request failed"))},s.ontimeout=function(){r(new TypeError("Network request failed"))},s.open(o.method,o.url,!0),"include"===o.credentials?s.withCredentials=!0:"omit"===o.credentials&&(s.withCredentials=!1),"responseType"in s&&e.blob&&(s.responseType="blob"),o.headers.forEach(function(t,e){s.setRequestHeader(e,t)}),s.send(void 0===o._bodyInit?null:o._bodyInit)})},t.fetch.polyfill=!0}function a(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function u(t){return"string"!=typeof t&&(t=String(t)),t}function c(t){var n={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return e.iterable&&(n[Symbol.iterator]=function(){return n}),n}function h(t){this.map={},t instanceof h?t.forEach(function(t,e){this.append(e,t)},this):Array.isArray(t)?t.forEach(function(t){this.append(t[0],t[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}function l(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function d(t){return new Promise(function(e,n){t.onload=function(){e(t.result)},t.onerror=function(){n(t.error)}})}function f(t){var e=new FileReader,n=d(e);return e.readAsArrayBuffer(t),n}function p(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function v(){return this.bodyUsed=!1,this._initBody=function(t){if(this._bodyInit=t,t)if("string"==typeof t)this._bodyText=t;else if(e.blob&&Blob.prototype.isPrototypeOf(t))this._bodyBlob=t;else if(e.formData&&FormData.prototype.isPrototypeOf(t))this._bodyFormData=t;else if(e.searchParams&&URLSearchParams.prototype.isPrototypeOf(t))this._bodyText=t.toString();else if(e.arrayBuffer&&e.blob&&i(t))this._bodyArrayBuffer=p(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer]);else{if(!e.arrayBuffer||!ArrayBuffer.prototype.isPrototypeOf(t)&&!r(t))throw new Error("unsupported BodyInit type");this._bodyArrayBuffer=p(t)}else this._bodyText="";this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):e.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},e.blob&&(this.blob=function(){var t=l(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?l(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(f)}),this.text=function(){var t,e,n,i=l(this);if(i)return i;if(this._bodyBlob)return t=this._bodyBlob,n=d(e=new FileReader),e.readAsText(t),n;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),n=new Array(e.length),i=0;i<e.length;i++)n[i]=String.fromCharCode(e[i]);return n.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},e.formData&&(this.formData=function(){return this.text().then(y)}),this.json=function(){return this.text().then(JSON.parse)},this}function g(t,e){var n,i,r=(e=e||{}).body;if(t instanceof g){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new h(t.headers)),this.method=t.method,this.mode=t.mode,r||null==t._bodyInit||(r=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"omit",!e.headers&&this.headers||(this.headers=new h(e.headers)),this.method=(i=(n=e.method||this.method||"GET").toUpperCase(),o.indexOf(i)>-1?i:n),this.mode=e.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 y(t){var e=new FormData;return t.trim().split("&").forEach(function(t){if(t){var n=t.split("="),i=n.shift().replace(/\+/g," "),r=n.join("=").replace(/\+/g," ");e.append(decodeURIComponent(i),decodeURIComponent(r))}}),e}function m(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new h(e.headers),this.url=e.url||"",this._initBody(t)}}("undefined"!=typeof self?self:this)},function(t,e,n){(function(t,e){!function(t,n){"use strict";if(!t.setImmediate){var i,r,o,s,a,u=1,c={},h=!1,l=t.document,d=Object.getPrototypeOf&&Object.getPrototypeOf(t);d=d&&d.setTimeout?d:t,"[object process]"==={}.toString.call(t.process)?i=function(t){e.nextTick(function(){p(t)})}:function(){if(t.postMessage&&!t.importScripts){var e=!0,n=t.onmessage;return t.onmessage=function(){e=!1},t.postMessage("","*"),t.onmessage=n,e}}()?(s="setImmediate$"+Math.random()+"$",a=function(e){e.source===t&&"string"==typeof e.data&&0===e.data.indexOf(s)&&p(+e.data.slice(s.length))},t.addEventListener?t.addEventListener("message",a,!1):t.attachEvent("onmessage",a),i=function(e){t.postMessage(s+e,"*")}):t.MessageChannel?((o=new MessageChannel).port1.onmessage=function(t){p(t.data)},i=function(t){o.port2.postMessage(t)}):l&&"onreadystatechange"in l.createElement("script")?(r=l.documentElement,i=function(t){var e=l.createElement("script");e.onreadystatechange=function(){p(t),e.onreadystatechange=null,r.removeChild(e),e=null},r.appendChild(e)}):i=function(t){setTimeout(p,0,t)},d.setImmediate=function(t){"function"!=typeof t&&(t=new Function(""+t));for(var e=new Array(arguments.length-1),n=0;n<e.length;n++)e[n]=arguments[n+1];var r={callback:t,args:e};return c[u]=r,i(u),u++},d.clearImmediate=f}function f(t){delete c[t]}function p(t){if(h)setTimeout(p,0,t);else{var e=c[t];if(e){h=!0;try{!function(t){var e=t.callback,i=t.args;switch(i.length){case 0:e();break;case 1:e(i[0]);break;case 2:e(i[0],i[1]);break;case 3:e(i[0],i[1],i[2]);break;default:e.apply(n,i)}}(e)}finally{f(t),h=!1}}}}}("undefined"==typeof self?void 0===t?this:t:self)}).call(this,n(6),n(18))},function(t,e,n){"use strict";n.r(e),function(t,e){n(53);var i=setTimeout;function r(){}function o(t){if(!(this instanceof o))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=[],h(t,this)}function s(t,e){for(;3===t._state;)t=t._value;0!==t._state?(t._handled=!0,o._immediateFn(function(){var n=1===t._state?e.onFulfilled:e.onRejected;if(null!==n){var i;try{i=n(t._value)}catch(t){return void u(e.promise,t)}a(e.promise,i)}else(1===t._state?a:u)(e.promise,t._value)})):t._deferreds.push(e)}function a(t,e){try{if(e===t)throw new TypeError("A promise cannot be resolved with itself.");if(e&&("object"==typeof e||"function"==typeof e)){var n=e.then;if(e instanceof o)return t._state=3,t._value=e,void c(t);if("function"==typeof n)return void h((i=n,r=e,function(){i.apply(r,arguments)}),t)}t._state=1,t._value=e,c(t)}catch(e){u(t,e)}var i,r}function u(t,e){t._state=2,t._value=e,c(t)}function c(t){2===t._state&&0===t._deferreds.length&&o._immediateFn(function(){t._handled||o._unhandledRejectionFn(t._value)});for(var e=0,n=t._deferreds.length;e<n;e++)s(t,t._deferreds[e]);t._deferreds=null}function h(t,e){var n=!1;try{t(function(t){n||(n=!0,a(e,t))},function(t){n||(n=!0,u(e,t))})}catch(t){if(n)return;n=!0,u(e,t)}}o.prototype.catch=function(t){return this.then(null,t)},o.prototype.then=function(t,e){var n=new this.constructor(r);return s(this,new function(t,e,n){this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof e?e:null,this.promise=n}(t,e,n)),n},o.prototype.finally=function(t){var e=this.constructor;return this.then(function(n){return e.resolve(t()).then(function(){return n})},function(n){return e.resolve(t()).then(function(){return e.reject(n)})})},o.all=function(t){return new o(function(e,n){if(!t||void 0===t.length)throw new TypeError("Promise.all accepts an array");var i=Array.prototype.slice.call(t);if(0===i.length)return e([]);var r=i.length;function o(t,s){try{if(s&&("object"==typeof s||"function"==typeof s)){var a=s.then;if("function"==typeof a)return void a.call(s,function(e){o(t,e)},n)}i[t]=s,0==--r&&e(i)}catch(t){n(t)}}for(var s=0;s<i.length;s++)o(s,i[s])})},o.resolve=function(t){return t&&"object"==typeof t&&t.constructor===o?t:new o(function(e){e(t)})},o.reject=function(t){return new o(function(e,n){n(t)})},o.race=function(t){return new o(function(e,n){for(var i=0,r=t.length;i<r;i++)t[i].then(e,n)})},o._immediateFn="function"==typeof t&&function(e){t(e)}||function(t){i(t,0)},o._unhandledRejectionFn=function(t){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",t)};var l=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==e)return e;throw new Error("unable to locate global object")}();function d(t,e){return t(e={exports:{}},e.exports),e.exports}l.Promise||(l.Promise=o);var f=d(function(t){var e=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=e)}),p=d(function(t){var e=t.exports={version:"2.5.5"};"number"==typeof __e&&(__e=e)}),v=(p.version,function(t){return"object"==typeof t?null!==t:"function"==typeof t}),g=function(t){if(!v(t))throw TypeError(t+" is not an object!");return t},y=function(t){try{return!!t()}catch(t){return!0}},m=!y(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a}),_=f.document,b=v(_)&&v(_.createElement),w=function(t){return b?_.createElement(t):{}},C=!m&&!y(function(){return 7!=Object.defineProperty(w("div"),"a",{get:function(){return 7}}).a}),T=function(t,e){if(!v(t))return t;var n,i;if(e&&"function"==typeof(n=t.toString)&&!v(i=n.call(t)))return i;if("function"==typeof(n=t.valueOf)&&!v(i=n.call(t)))return i;if(!e&&"function"==typeof(n=t.toString)&&!v(i=n.call(t)))return i;throw TypeError("Can't convert object to primitive value")},E=Object.defineProperty,S={f:m?Object.defineProperty:function(t,e,n){if(g(t),e=T(e,!0),g(n),C)try{return E(t,e,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported!");return"value"in n&&(t[e]=n.value),t}},I=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},k=m?function(t,e,n){return S.f(t,e,I(1,n))}:function(t,e,n){return t[e]=n,t},A={}.hasOwnProperty,P=function(t,e){return A.call(t,e)},N=0,D=Math.random(),R=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++N+D).toString(36))},O=d(function(t){var e=R("src"),n=Function.toString,i=(""+n).split("toString");p.inspectSource=function(t){return n.call(t)},(t.exports=function(t,n,r,o){var s="function"==typeof r;s&&(P(r,"name")||k(r,"name",n)),t[n]!==r&&(s&&(P(r,e)||k(r,e,t[n]?""+t[n]:i.join(String(n)))),t===f?t[n]=r:o?t[n]?t[n]=r:k(t,n,r):(delete t[n],k(t,n,r)))})(Function.prototype,"toString",function(){return"function"==typeof this&&this[e]||n.call(this)})}),x=function(t,e,n){if(function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!")}(t),void 0===e)return t;switch(n){case 1:return function(n){return t.call(e,n)};case 2:return function(n,i){return t.call(e,n,i)};case 3:return function(n,i,r){return t.call(e,n,i,r)}}return function(){return t.apply(e,arguments)}},M=function(t,e,n){var i,r,o,s,a=t&M.F,u=t&M.G,c=t&M.S,h=t&M.P,l=t&M.B,d=u?f:c?f[e]||(f[e]={}):(f[e]||{}).prototype,v=u?p:p[e]||(p[e]={}),g=v.prototype||(v.prototype={});for(i in u&&(n=e),n)o=((r=!a&&d&&void 0!==d[i])?d:n)[i],s=l&&r?x(o,f):h&&"function"==typeof o?x(Function.call,o):o,d&&O(d,i,o,t&M.U),v[i]!=o&&k(v,i,s),h&&g[i]!=o&&(g[i]=o)};f.core=p,M.F=1,M.G=2,M.S=4,M.P=8,M.B=16,M.W=32,M.U=64,M.R=128;var L=M,F={}.toString,U=function(t){return F.call(t).slice(8,-1)},j=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==U(t)?t.split(""):Object(t)},W=function(t){if(void 0==t)throw TypeError("Can't call method on  "+t);return t},B=function(t){return Object(W(t))},$=Math.ceil,V=Math.floor,q=function(t){return isNaN(t=+t)?0:(t>0?V:$)(t)},H=Math.min,z=function(t){return t>0?H(q(t),9007199254740991):0},K=Array.isArray||function(t){return"Array"==U(t)},Q=f["__core-js_shared__"]||(f["__core-js_shared__"]={}),Y=function(t){return Q[t]||(Q[t]={})},G=d(function(t){var e=Y("wks"),n=f.Symbol,i="function"==typeof n;(t.exports=function(t){return e[t]||(e[t]=i&&n[t]||(i?n:R)("Symbol."+t))}).store=e}),X=G("species"),J=function(t,e){return new(function(t){var e;return K(t)&&("function"!=typeof(e=t.constructor)||e!==Array&&!K(e.prototype)||(e=void 0),v(e)&&null===(e=e[X])&&(e=void 0)),void 0===e?Array:e}(t))(e)},Z=function(t,e){var n=1==t,i=2==t,r=3==t,o=4==t,s=6==t,a=5==t||s,u=e||J;return function(e,c,h){for(var l,d,f=B(e),p=j(f),v=x(c,h,3),g=z(p.length),y=0,m=n?u(e,g):i?u(e,0):void 0;g>y;y++)if((a||y in p)&&(d=v(l=p[y],y,f),t))if(n)m[y]=d;else if(d)switch(t){case 3:return!0;case 5:return l;case 6:return y;case 2:m.push(l)}else if(o)return!1;return s?-1:r||o?o:m}},tt=G("unscopables"),et=Array.prototype;void 0==et[tt]&&k(et,tt,{});var nt=function(t){et[tt][t]=!0},it=Z(5),rt=!0;"find"in[]&&Array(1).find(function(){rt=!1}),L(L.P+L.F*rt,"Array",{find:function(t){return it(this,t,arguments.length>1?arguments[1]:void 0)}}),nt("find"),p.Array.find;var ot=Z(6),st=!0;"findIndex"in[]&&Array(1).findIndex(function(){st=!1}),L(L.P+L.F*st,"Array",{findIndex:function(t){return ot(this,t,arguments.length>1?arguments[1]:void 0)}}),nt("findIndex"),p.Array.findIndex;var at=function(t){return j(W(t))},ut=Math.max,ct=Math.min,ht=Y("keys"),lt=function(t){return ht[t]||(ht[t]=R(t))},dt=(!1,function(t,e,n){var i=at(t),r=z(i.length),o=function(t,e){return(t=q(t))<0?ut(t+e,0):ct(t,e)}(n,r);for(0;r>o;o++)if(o in i&&i[o]===e)return o||0;return-1}),ft=lt("IE_PROTO"),pt=function(t,e){var n,i=at(t),r=0,o=[];for(n in i)n!=ft&&P(i,n)&&o.push(n);for(;e.length>r;)P(i,n=e[r++])&&(~dt(o,n)||o.push(n));return o},vt="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(","),gt=Object.keys||function(t){return pt(t,vt)},yt={f:Object.getOwnPropertySymbols},mt={f:{}.propertyIsEnumerable},_t=Object.assign,bt=!_t||y(function(){var t={},e={},n=Symbol(),i="abcdefghijklmnopqrst";return t[n]=7,i.split("").forEach(function(t){e[t]=t}),7!=_t({},t)[n]||Object.keys(_t({},e)).join("")!=i})?function(t,e){for(var n=B(t),i=arguments.length,r=1,o=yt.f,s=mt.f;i>r;)for(var a,u=j(arguments[r++]),c=o?gt(u).concat(o(u)):gt(u),h=c.length,l=0;h>l;)s.call(u,a=c[l++])&&(n[a]=u[a]);return n}:_t;L(L.S+L.F,"Object",{assign:bt}),p.Object.assign;var wt=G("match"),Ct=G("match"),Tt="".startsWith;L(L.P+L.F*function(t){var e=/./;try{"/./"[t](e)}catch(n){try{return e[Ct]=!1,!"/./"[t](e)}catch(t){}}return!0}("startsWith"),"String",{startsWith:function(t){var e=function(t,e,n){if(v(i=e)&&(void 0!==(r=i[wt])?r:"RegExp"==U(i)))throw TypeError("String#"+n+" doesn't accept regex!");var i,r;return String(W(t))}(this,t,"startsWith"),n=z(Math.min(arguments.length>1?arguments[1]:void 0,e.length)),i=String(t);return Tt?Tt.call(e,i,n):e.slice(n,n+i.length)===i}}),p.String.startsWith,L(L.P,"String",{repeat:function(t){var e=String(W(this)),n="",i=q(t);if(i<0||i==1/0)throw RangeError("Count can't be negative");for(;i>0;(i>>>=1)&&(e+=e))1&i&&(n+=e);return n}}),p.String.repeat;var Et=d(function(t){var e=R("meta"),n=S.f,i=0,r=Object.isExtensible||function(){return!0},o=!y(function(){return r(Object.preventExtensions({}))}),s=function(t){n(t,e,{value:{i:"O"+ ++i,w:{}}})},a=t.exports={KEY:e,NEED:!1,fastKey:function(t,n){if(!v(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!P(t,e)){if(!r(t))return"F";if(!n)return"E";s(t)}return t[e].i},getWeak:function(t,n){if(!P(t,e)){if(!r(t))return!0;if(!n)return!1;s(t)}return t[e].w},onFreeze:function(t){return o&&a.NEED&&r(t)&&!P(t,e)&&s(t),t}}}),St=(Et.KEY,Et.NEED,Et.fastKey,Et.getWeak,Et.onFreeze,S.f),It=G("toStringTag"),kt=function(t,e,n){t&&!P(t=n?t:t.prototype,It)&&St(t,It,{configurable:!0,value:e})},At={f:G},Pt=S.f,Nt=function(t){var e=p.Symbol||(p.Symbol=f.Symbol||{});"_"==t.charAt(0)||t in e||Pt(e,t,{value:At.f(t)})},Dt=m?Object.defineProperties:function(t,e){g(t);for(var n,i=gt(e),r=i.length,o=0;r>o;)S.f(t,n=i[o++],e[n]);return t},Rt=f.document,Ot=Rt&&Rt.documentElement,xt=lt("IE_PROTO"),Mt=function(){},Lt=function(){var t,e=w("iframe"),n=vt.length;for(e.style.display="none",Ot.appendChild(e),e.src="javascript:",(t=e.contentWindow.document).open(),t.write("<script>document.F=Object<\/script>"),t.close(),Lt=t.F;n--;)delete Lt.prototype[vt[n]];return Lt()},Ft=Object.create||function(t,e){var n;return null!==t?(Mt.prototype=g(t),n=new Mt,Mt.prototype=null,n[xt]=t):n=Lt(),void 0===e?n:Dt(n,e)},Ut=vt.concat("length","prototype"),jt={f:Object.getOwnPropertyNames||function(t){return pt(t,Ut)}},Wt=jt.f,Bt={}.toString,$t="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],Vt={f:function(t){return $t&&"[object Window]"==Bt.call(t)?function(t){try{return Wt(t)}catch(t){return $t.slice()}}(t):Wt(at(t))}},qt=Object.getOwnPropertyDescriptor,Ht={f:m?qt:function(t,e){if(t=at(t),e=T(e,!0),C)try{return qt(t,e)}catch(t){}if(P(t,e))return I(!mt.f.call(t,e),t[e])}},zt=Et.KEY,Kt=Ht.f,Qt=S.f,Yt=Vt.f,Gt=f.Symbol,Xt=f.JSON,Jt=Xt&&Xt.stringify,Zt=G("_hidden"),te=G("toPrimitive"),ee={}.propertyIsEnumerable,ne=Y("symbol-registry"),ie=Y("symbols"),re=Y("op-symbols"),oe=Object.prototype,se="function"==typeof Gt,ae=f.QObject,ue=!ae||!ae.prototype||!ae.prototype.findChild,ce=m&&y(function(){return 7!=Ft(Qt({},"a",{get:function(){return Qt(this,"a",{value:7}).a}})).a})?function(t,e,n){var i=Kt(oe,e);i&&delete oe[e],Qt(t,e,n),i&&t!==oe&&Qt(oe,e,i)}:Qt,he=function(t){var e=ie[t]=Ft(Gt.prototype);return e._k=t,e},le=se&&"symbol"==typeof Gt.iterator?function(t){return"symbol"==typeof t}:function(t){return t instanceof Gt},de=function(t,e,n){return t===oe&&de(re,e,n),g(t),e=T(e,!0),g(n),P(ie,e)?(n.enumerable?(P(t,Zt)&&t[Zt][e]&&(t[Zt][e]=!1),n=Ft(n,{enumerable:I(0,!1)})):(P(t,Zt)||Qt(t,Zt,I(1,{})),t[Zt][e]=!0),ce(t,e,n)):Qt(t,e,n)},fe=function(t,e){g(t);for(var n,i=function(t){var e=gt(t),n=yt.f;if(n)for(var i,r=n(t),o=mt.f,s=0;r.length>s;)o.call(t,i=r[s++])&&e.push(i);return e}(e=at(e)),r=0,o=i.length;o>r;)de(t,n=i[r++],e[n]);return t},pe=function(t){var e=ee.call(this,t=T(t,!0));return!(this===oe&&P(ie,t)&&!P(re,t))&&(!(e||!P(this,t)||!P(ie,t)||P(this,Zt)&&this[Zt][t])||e)},ve=function(t,e){if(t=at(t),e=T(e,!0),t!==oe||!P(ie,e)||P(re,e)){var n=Kt(t,e);return!n||!P(ie,e)||P(t,Zt)&&t[Zt][e]||(n.enumerable=!0),n}},ge=function(t){for(var e,n=Yt(at(t)),i=[],r=0;n.length>r;)P(ie,e=n[r++])||e==Zt||e==zt||i.push(e);return i},ye=function(t){for(var e,n=t===oe,i=Yt(n?re:at(t)),r=[],o=0;i.length>o;)!P(ie,e=i[o++])||n&&!P(oe,e)||r.push(ie[e]);return r};se||(O((Gt=function(){if(this instanceof Gt)throw TypeError("Symbol is not a constructor!");var t=R(arguments.length>0?arguments[0]:void 0),e=function(n){this===oe&&e.call(re,n),P(this,Zt)&&P(this[Zt],t)&&(this[Zt][t]=!1),ce(this,t,I(1,n))};return m&&ue&&ce(oe,t,{configurable:!0,set:e}),he(t)}).prototype,"toString",function(){return this._k}),Ht.f=ve,S.f=de,jt.f=Vt.f=ge,mt.f=pe,yt.f=ye,m&&O(oe,"propertyIsEnumerable",pe,!0),At.f=function(t){return he(G(t))}),L(L.G+L.W+L.F*!se,{Symbol:Gt});for(var me="hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),_e=0;me.length>_e;)G(me[_e++]);for(var be=gt(G.store),we=0;be.length>we;)Nt(be[we++]);L(L.S+L.F*!se,"Symbol",{for:function(t){return P(ne,t+="")?ne[t]:ne[t]=Gt(t)},keyFor:function(t){if(!le(t))throw TypeError(t+" is not a symbol!");for(var e in ne)if(ne[e]===t)return e},useSetter:function(){ue=!0},useSimple:function(){ue=!1}}),L(L.S+L.F*!se,"Object",{create:function(t,e){return void 0===e?Ft(t):fe(Ft(t),e)},defineProperty:de,defineProperties:fe,getOwnPropertyDescriptor:ve,getOwnPropertyNames:ge,getOwnPropertySymbols:ye}),Xt&&L(L.S+L.F*(!se||y(function(){var t=Gt();return"[null]"!=Jt([t])||"{}"!=Jt({a:t})||"{}"!=Jt(Object(t))})),"JSON",{stringify:function(t){for(var e,n,i=[t],r=1;arguments.length>r;)i.push(arguments[r++]);if(n=e=i[1],(v(e)||void 0!==t)&&!le(t))return K(e)||(e=function(t,e){if("function"==typeof n&&(e=n.call(this,t,e)),!le(e))return e}),i[1]=e,Jt.apply(Xt,i)}}),Gt.prototype[te]||k(Gt.prototype,te,Gt.prototype.valueOf),kt(Gt,"Symbol"),kt(Math,"Math",!0),kt(f.JSON,"JSON",!0);var Ce=G("toStringTag"),Te="Arguments"==U(function(){return arguments}()),Ee={};Ee[G("toStringTag")]="z",Ee+""!="[object z]"&&O(Object.prototype,"toString",function(){return"[object "+(void 0===(t=this)?"Undefined":null===t?"Null":"string"==typeof(n=function(t,e){try{return t[e]}catch(t){}}(e=Object(t),Ce))?n:Te?U(e):"Object"==(i=U(e))&&"function"==typeof e.callee?"Arguments":i)+"]";var t,e,n,i},!0),Nt("asyncIterator"),Nt("observable"),p.Symbol;var Se={},Ie={};k(Ie,G("iterator"),function(){return this});var ke=lt("IE_PROTO"),Ae=Object.prototype,Pe=Object.getPrototypeOf||function(t){return t=B(t),P(t,ke)?t[ke]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?Ae:null},Ne=G("iterator"),De=!([].keys&&"next"in[].keys()),Re=function(){return this},Oe=function(t,e,n,i,r,o,s){!function(t,e,n){t.prototype=Ft(Ie,{next:I(1,n)}),kt(t,e+" Iterator")}(n,e,i);var a,u,c,h=function(t){if(!De&&t in p)return p[t];switch(t){case"keys":case"values":return function(){return new n(this,t)}}return function(){return new n(this,t)}},l=e+" Iterator",d="values"==r,f=!1,p=t.prototype,v=p[Ne]||p["@@iterator"]||r&&p[r],g=v||h(r),y=r?d?h("entries"):g:void 0,m="Array"==e&&p.entries||v;if(m&&(c=Pe(m.call(new t)))!==Object.prototype&&c.next&&(kt(c,l,!0),"function"!=typeof c[Ne]&&k(c,Ne,Re)),d&&v&&"values"!==v.name&&(f=!0,g=function(){return v.call(this)}),(De||f||!p[Ne])&&k(p,Ne,g),Se[e]=g,Se[l]=Re,r)if(a={values:d?g:h("values"),keys:o?g:h("keys"),entries:y},s)for(u in a)u in p||O(p,u,a[u]);else L(L.P+L.F*(De||f),e,a);return a},xe=(!0,function(t,e){var n,i,r=String(W(t)),o=q(e),s=r.length;return o<0||o>=s?"":(n=r.charCodeAt(o))<55296||n>56319||o+1===s||(i=r.charCodeAt(o+1))<56320||i>57343?r.charAt(o):r.slice(o,o+2)});Oe(String,"String",function(t){this._t=String(t),this._i=0},function(){var t,e=this._t,n=this._i;return n>=e.length?{value:void 0,done:!0}:(t=xe(e,n),this._i+=t.length,{value:t,done:!1})});var Me=function(t,e){return{value:e,done:!!t}},Le=Oe(Array,"Array",function(t,e){this._t=at(t),this._i=0,this._k=e},function(){var t=this._t,e=this._k,n=this._i++;return!t||n>=t.length?(this._t=void 0,Me(1)):Me(0,"keys"==e?n:"values"==e?t[n]:[n,t[n]])},"values");Se.Arguments=Se.Array,nt("keys"),nt("values"),nt("entries");for(var Fe=G("iterator"),Ue=G("toStringTag"),je=Se.Array,We={CSSRuleList:!0,CSSStyleDeclaration:!1,CSSValueList:!1,ClientRectList:!1,DOMRectList:!1,DOMStringList:!1,DOMTokenList:!0,DataTransferItemList:!1,FileList:!1,HTMLAllCollection:!1,HTMLCollection:!1,HTMLFormElement:!1,HTMLSelectElement:!1,MediaList:!0,MimeTypeArray:!1,NamedNodeMap:!1,NodeList:!0,PaintRequestList:!1,Plugin:!1,PluginArray:!1,SVGLengthList:!1,SVGNumberList:!1,SVGPathSegList:!1,SVGPointList:!1,SVGStringList:!1,SVGTransformList:!1,SourceBufferList:!1,StyleSheetList:!0,TextTrackCueList:!1,TextTrackList:!1,TouchList:!1},Be=gt(We),$e=0;$e<Be.length;$e++){var Ve,qe=Be[$e],He=We[qe],ze=f[qe],Ke=ze&&ze.prototype;if(Ke&&(Ke[Fe]||k(Ke,Fe,je),Ke[Ue]||k(Ke,Ue,qe),Se[qe]=je,He))for(Ve in Le)Ke[Ve]||O(Ke,Ve,Le[Ve],!0)}At.f("iterator")}.call(this,n(7).setImmediate,n(6))},function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))(function(r,o){function s(t){try{u(i.next(t))}catch(t){o(t)}}function a(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){t.done?r(t.value):new n(function(e){e(t.value)}).then(s,a)}u((i=i.apply(t,e||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0});const r=n(9);n(5),n(4),n(15),n(14);const o=n(49),s=n(41),a=n(3),u=n(40),c=n(36),h=n(1),l=n(12),d=n(35),f=n(34),p=n(33),v=n(32),g=n(31),y=n(29),m=n(26),_=n(25),b=n(24),w=n(23),C=n(22),T=n(21),E=n(20),S=n(19);window.setup=S.default,window.MessageBox=b.default;class I extends a.default{constructor(){super(),this.app=r.initializeApp({apiKey:"AIzaSyDhs0mPVlovk6JHnEdv6HeU2jy3M8VRoSk",authDomain:"budget-dacac.firebaseapp.com",databaseURL:"https://budget-dacac.firebaseio.com",storageBucket:"budget-dacac.appspot.com"}),$(()=>{this.btnSearch=new s.default("#btnSearch").on("click",this.btnSearch_onClick.bind(this)),this.btnToday=new s.default("#btnToday").on("click",this.btnToday_onClick.bind(this)),this.btnPrev=new s.default("#btnPrev").on("click",this.btnPrev_onClick.bind(this)),this.periodMenu=new s.default("#periodMenu").on("click",this.periodMenu_onClick.bind(this)),this.btnNext=new s.default("#btnNext").on("click",this.btnNext_onClick.bind(this)),this.btnEditTransaction=new s.default("#btnEditTransaction").on("click",this.btnEditTransaction_onClick.bind(this)),this.btnAddTransaction=new s.default("#btnAddTransaction").on("click",this.btnAddTransaction_onClick.bind(this)),this.btnLogout=new s.default("#btnLogout").on("click",this.btnLogout_onClick.bind(this)),this.btnConfig=new s.default("#btnConfig").on("click",this.btnConfig_onClick.bind(this)),this.btnDownload=new s.default("#btnDownload").on("click",this.btnDownload_onClick.bind(this)),this.btnUpload=new s.default("#btnUpload").on("click",this.btnUpload_onClick.bind(this)),this.btnDownloadAsCsv=new s.default("#btnDownloadAsCsv").on("click",this.btnDownloadAsCsv_onClick.bind(this)),this.btnDowloadPeriodAsCsv=new s.default("#btnDowloadPeriodAsCsv").on("click",this.btnDowloadPeriodAsCsv_onClick.bind(this)),this.btnNewRecurring=new s.default("#btnNewRecurring").on("click",this.btnNewRecurring_onClick.bind(this)),this.btnReport=new s.default("#btnReport").on("click",this.btnReport_onClick.bind(this)),this.btnYtdReport=new s.default("#btnYtdReport").on("click",this.btnYtdReport_onClick.bind(this)),this.btnCash=new s.default("#btnCash").on("click",this.btnCash_onClick.bind(this)),this.btnTransfer=new s.default("#btnTransfer").on("click",this.btnTransfer_onClick.bind(this)),this.btnUndo=new s.default("#btnUndo").on("click",this.btnUndo_onClick.bind(this)),this.btnRedo=new s.default("#btnRedo").on("click",this.btnRedo_onClick.bind(this)),this.pnlMenu=new f.default("#menu_panel"),this.previewer=new c.default(".info_div"),this.btnWizardEmergencyFund=new s.default("#btnWizardEmergencyFund").on("click",this.btnWizardEmergencyFund_Click.bind(this)),this.btnWizardSetup=new s.default("#btnWizardSetup").on("click",this.btnWizardSetup_Click.bind(this)),this.btnUndo.disabled=!0,this.btnRedo.disabled=!0,this.chart=new g.default("chart_div"),this.previewer.GotoTransaction=(t=>{this.budget.gotoDate(t)}),r.auth().onAuthStateChanged(this.firebase_onAuthStateChanged.bind(this)),$(window).on("resize",()=>{"ontouchstart"in document.documentElement==0?$("#btnEditTransaction").hide():$("#btnEditTransaction").show()}),"ontouchstart"in document.documentElement==0?$("#btnEditTransaction").hide():$("#btnEditTransaction").show()}),$(document).on("keydown",t=>{if(t.ctrlKey||t.metaKey)switch(t.key){case"f":case"F":t.preventDefault(),this.btnSearch.click();break;case"z":case"Z":t.preventDefault(),this.btnUndo.click();break;case"y":case"Y":t.preventDefault(),this.btnRedo.click();break;case"ArrowLeft":t.preventDefault(),this.btnPrev.click();break;case"ArrowRight":t.preventDefault(),this.btnNext.click()}})}periodLoaded(){return i(this,void 0,void 0,function*(){this.periodStart=this.budget.Start,this.periodEnd=this.budget.End,$("#periodMenu").text(`${Date.parseFb(this.periodStart).format("MMM d")} - ${Date.parseFb(this.periodEnd).format("MMM d")}`),this.periodStart<=this.budget.Config.start?this.btnPrev.disabled=!0:this.btnPrev.disabled=!1,$("[data-role=header] h1").text(`${Date.parseFb(this.periodStart).format("MMM d")} - ${Date.parseFb(this.periodEnd).format("MMM d")}`),$("#transaction_list").scrollTop(0),$(".info_div").scrollTop(0)})}download(t,e,n){let i=new Blob([t],{type:n});if(window.navigator.msSaveBlob)window.navigator.msSaveBlob(i,e);else{let t=window.document.createElement("a");t.href=window.URL.createObjectURL(i),t.download=e,t.style.display="none",document.body.appendChild(t),t.click(),document.body.removeChild(t)}}btnWizardSetup_Click(t){t.preventDefault(),this.pnlMenu.close(),new S.default(this.budget.Config.categories,this.budget.saveRecurring.bind(this.budget)).open()}btnWizardEmergencyFund_Click(t){t.preventDefault(),this.pnlMenu.close(),E.default(this)}btnUndo_onClick(t){return i(this,void 0,void 0,function*(){this.budget&&this.budget.CanUndo&&(h.default.show(),yield this.budget.Undo(),h.default.hide(),this.pnlMenu.close())})}btnRedo_onClick(t){return i(this,void 0,void 0,function*(){this.budget&&this.budget.CanRedo&&(h.default.show(),yield this.budget.Redo(),h.default.hide(),this.pnlMenu.close())})}btnSearch_onClick(t){this.pnlMenu.close();let e=new d.default(this.budget.Transactions);e.GotoPeriod=(t=>i(this,void 0,void 0,function*(){e.close(),yield this.budget.gotoDate(t)})),e.open()}btnToday_onClick(t){return i(this,void 0,void 0,function*(){t.preventDefault(),yield this.budget.gotoDate(Date.today())})}btnPrev_onClick(t){return i(this,void 0,void 0,function*(){t.preventDefault(),this.periodStart>this.budget.Config.start&&(yield this.budget.gotoDate(Date.parseFb(this.periodStart).subtract(this.budget.Config.length)))})}periodMenu_onClick(t){return i(this,void 0,void 0,function*(){t.preventDefault(),new C.default(Date.parseFb(this.periodStart),t=>this.budget.gotoDate(t),{select:"period",start:this.budget.Config.start,period:this.budget.Config.length}).open()})}btnNext_onClick(t){return i(this,void 0,void 0,function*(){t.preventDefault(),yield this.budget.gotoDate(Date.parseFb(this.periodStart).add(this.budget.Config.length))})}btnEditTransaction_onClick(t){this.transactionList.editSelected()}btnAddTransaction_onClick(t){this.transactionList.addTransaction(this.periodStart)}btnLogout_onClick(t){t.preventDefault(),this.pnlMenu.close(),this.logout()}btnNewRecurring_onClick(t){this.transactionList.addRecurring(this.periodStart)}btnConfig_onClick(t){this.pnlMenu.close(),new p.default(this.budget.Config,()=>{this.budget.Config.write(),this.config_onRead()},this.setTheme.bind(this)).open()}btnReport_onClick(t){this.pnlMenu.close();let e=new y.default;e.listenToTransactions(this.budget.Transactions),e.open()}btnYtdReport_onClick(t){this.pnlMenu.close();let e=new m.default;e.listenToTransactions(this.budget.Transactions),e.open()}btnDownloadAsCsv_onClick(t){return i(this,void 0,void 0,function*(){let t=yield this.budget.Transactions.getCsv(),e=`budget-${Date.today().toFbString()}.csv`;this.download(t,e,"text/csv"),this.pnlMenu.close()})}btnDowloadPeriodAsCsv_onClick(t){return i(this,void 0,void 0,function*(){let t=yield this.budget.Transactions.getCsv(this.periodStart,this.periodEnd),e=`budget-${Date.parseFb(this.periodStart).format("MMM d")} to ${Date.parseFb(this.periodEnd).format("MMM d")}.csv`;this.download(t,e,"text/csv"),this.pnlMenu.close()})}btnDownload_onClick(t){return i(this,void 0,void 0,function*(){let t=yield this.budget.getBackup(),e=JSON.stringify(t),n="budget-"+Date.today().toFbString()+".json";this.download(e,n,"application/json"),this.pnlMenu.close()})}btnUpload_onClick(t){return i(this,void 0,void 0,function*(){let t=$('<input type="file" accept=".json" style="display:none">');$("body").append(t),t.on("change",()=>{let e=t[0].files;if(e.length>0){let t=new FileReader;t.addEventListener("load",n=>i(this,void 0,void 0,function*(){let n;try{"accounts"in(n=JSON.parse(t.result))&&"budget"in n.accounts&&(yield b.default.show("Overwrite your budget?","Are You Sure?",b.MessageBoxButtons.YesNo,b.MessageBoxIcon.Warning))==b.DialogResult.Yes&&(yield this.budget.setBackup(n.accounts.budget),window.location.reload())}catch(t){console.log("ERROR reading from:",e[0].name)}})),t.readAsText(e[0])}}),t.click()})}btnCash_onClick(t){t.preventDefault(),this.pnlMenu.close();let e="",n=this.budget.Transactions.Cash;n.hundreds&&(e+=`${n.hundreds} x $100 Bills (${(100*n.hundreds).toCurrency()})<br/>`),n.fifties&&(e+=`${n.fifties} x $50 Bills (${(50*n.fifties).toCurrency()})<br/>`),n.twenties&&(e+=`${n.twenties} x $20 Bills (${(20*n.twenties).toCurrency()})<br/>`),n.tens&&(e+=`${n.tens} x $10 Bills (${(10*n.tens).toCurrency()})<br/>`),n.fives&&(e+=`${n.fives} x $5 Bills (${(5*n.fives).toCurrency()})<br/>`),n.ones&&(e+=`${n.ones} x $1 Bills (${(1*n.ones).toCurrency()})<br/>`),n.cent25&&(e+=`${n.cent25} x Quarters (${(.25*n.cent25).toCurrency()})<br/>`),n.cent10&&(e+=`${n.cent10} x Dimes (${(.1*n.cent25).toCurrency()})<br/>`),n.cent5&&(e+=`${n.cent5} x Nickels (${(.05*n.cent5).toCurrency()})<br/>`),n.cent1&&(e+=`${n.cent1} x Pennies (${(.01*n.cent1).toCurrency()})<br/>`),""==e?e="No Cash Withdrawals":e+=`TOTAL: ${n.getTotal().toCurrency()}`,b.default.show(e,"Cash Withdrawal",b.default.Buttons.OK,b.MessageBoxIcon.Information)}btnTransfer_onClick(t){t.preventDefault(),this.pnlMenu.close();let e=this.budget.Transactions.Transfer,n="No Transfers";e<0&&(n="Transfer from Savings"),e>0&&(n="Transfer into Savings"),b.default.show(`Total: ${Math.abs(e).toCurrency()}`,n,b.default.Buttons.OK,b.default.Icon.Information)}transactionList_PreviewTransaction(t){return i(this,void 0,void 0,function*(){let e=yield this.budget.Transactions.load(t),n=yield this.budget.Transactions.getSame(e);return null!=n&&this.previewer.setTransaction(e),n||[]})}config_onRead(){return i(this,void 0,void 0,function*(){if(this.setTheme(this.budget.Config.theme),this.transactionList=new u.default("#tblTransactions",this.budget.Config),this.transactionList.LoadTransaction=(t=>this.budget.Transactions.load(t)),this.transactionList.SaveTransaction=(t=>this.budget.saveTransaction(t)),this.transactionList.DeleteTransaction=(t=>i(this,void 0,void 0,function*(){return this.budget.removeTransaction(t)})),this.transactionList.LoadRecurring=(t=>this.budget.Recurrings.load(t)),this.transactionList.SaveRecurring=(t=>this.budget.saveRecurring(t)),this.transactionList.DeleteRecurring=(t=>this.budget.removeRecurring(t)),this.transactionList.LoadNames=(()=>i(this,void 0,void 0,function*(){return this.budget.Transactions.LoadNames()})),this.periodStart){let{start:t,end:e}=this.budget.Config.calculatePeriod(this.periodStart);this.periodStart=t,this.periodEnd=e}else{let{start:t,end:e}=this.budget.Config.calculatePeriod(Date.today());this.periodStart=t,this.periodEnd=e}this.transactionList.PreviewTransaction=(t=>this.transactionList_PreviewTransaction(t)),yield this.budget.gotoDate(this.periodStart)})}setTheme(t){t=t||"default",$("#theme").attr("href",`/jquery.mobile/css/themes/${t}/budget.min.css`),$("#theme-icons").attr("href",`/jquery.mobile/css/themes/${t}/jquery.mobile.icons.min.css`),$("#theme-extras").attr("href",`/jquery.mobile/css/themes/${t}/extras.css`)}firebase_onAuthStateChanged(t){$(()=>i(this,void 0,void 0,function*(){if(null===t)this.budget=null,h.default.hide(),this.transactionList&&this.transactionList.clear(),this.pnlMenu.close(),new v.default(this.login.bind(this),this.resetPassword.bind(this),this.signup.bind(this)).open();else{l.default.show();let e=(yield r.database().ref(t.uid).child("config").once("value")).val();null!==e&&1!=e.showWizard||(l.default.hide(),yield T.default(r.database().ref(t.uid).child("config")),l.default.show()),this.budget=new o.default(r.database().ref(t.uid)),this.budget.on("config_read",this.config_onRead.bind(this)),this.budget.on("history_change",()=>{this.btnUndo.disabled=!this.budget.CanUndo,this.btnRedo.disabled=!this.budget.CanRedo}),this.budget.ready().then(()=>{this.previewer.listenToTransactions(this.budget.Transactions),this.transactionList.listenToTransactions(this.budget.Transactions),this.chart.listenToTransactions(this.budget.Transactions),this.budget.on("loadperiod",this.periodLoaded.bind(this)),this.budget.gotoDate(Date.today())})}}))}sendResetEmail(t){return i(this,void 0,void 0,function*(){r.auth().sendPasswordResetEmail(t,{url:`${location.origin}?email=${encodeURIComponent(t)}`}),h.default.hide(),yield b.default.show("The password reset has been sent. Check your inbox for instructions.","Reset Email Sent",b.MessageBoxButtons.OK,b.MessageBoxIcon.Information),new v.default(this.login.bind(this),this.resetPassword.bind(this),this.signup.bind(this)).open()})}registerAccount(t,e){return i(this,void 0,void 0,function*(){yield r.auth().createUserWithEmailAndPassword(t,e),setTimeout(()=>i(this,void 0,void 0,function*(){yield b.default.show(`Thank you for signing up ${t}. Please login now.`,"Welcome",b.MessageBoxButtons.OK,b.MessageBoxIcon.Information),new v.default(this.login.bind(this),this.resetPassword.bind(this),this.signup.bind(this)).open()}),0)})}signup(){$(()=>{new w.default(this.registerAccount.bind(this)).open()})}resetPassword(t){$(()=>{new _.default(this.sendResetEmail.bind(this),t).open()})}login(t,e){return new Promise((n,o)=>{$(()=>i(this,void 0,void 0,function*(){try{console.log("logging in..."),yield r.auth().signInWithEmailAndPassword(t,e),console.log("no error heard"),n()}catch(t){console.log(t),o(t)}}))})}logout(){this.periodStart=null,$(()=>{r.auth().signOut()})}turnOffUpdates(){this.transactionList.turnOffUpdates(),this.chart.turnOffUpdates(),this.previewer.turnOffUpdates()}turnOnUpdates(){this.transactionList.turnOnUpdates(),this.chart.turnOnUpdates(),this.previewer.turnOnUpdates()}}e.default=I,window.viewer=new I}]);