1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,660365,317875,562682,313171,e=>{"use strict";var t,n,r,i,a,o,s,u,c,l,h,f,d,v,y,p,m,g,_,k,b,w,I,T,E=e.i(120786),S=e.i(271645);e.i(101967);var C=e.i(611814),x=e.i(571836),A=e.i(618566),D=e.i(651682),R=e.i(843476),N=e.i(991865),O=e.i(292955),P=e.i(780646),L=e.i(540316),M=e.i(296137),U=e.i(247167),F=e.i(467034),V=e.i(38981),B=e.i(376495),j=e.i(680700),q=e.i(402048),z=e.i(64217),K=e.i(108487),G=e.i(500075),H=e.i(302393),W=e.i(198554),Q=e.i(251461),J=e.i(299749),X=function(e){for(var t=[],n=0,r=0;r<e.length;r++){var i=e.charCodeAt(r);i<128?t[n++]=i:(i<2048?t[n++]=i>>6|192:((64512&i)==55296&&r+1<e.length&&(64512&e.charCodeAt(r+1))==56320?(i=65536+((1023&i)<<10)+(1023&e.charCodeAt(++r)),t[n++]=i>>18|240,t[n++]=i>>12&63|128):t[n++]=i>>12|224,t[n++]=i>>6&63|128),t[n++]=63&i|128)}return t},Y=function(e){for(var t=[],n=0,r=0;n<e.length;){var i=e[n++];if(i<128)t[r++]=String.fromCharCode(i);else if(i>191&&i<224){var a=e[n++];t[r++]=String.fromCharCode((31&i)<<6|63&a)}else if(i>239&&i<365){var o=((7&i)<<18|(63&e[n++])<<12|(63&e[n++])<<6|63&e[n++])-65536;t[r++]=String.fromCharCode(55296+(o>>10)),t[r++]=String.fromCharCode(56320+(1023&o))}else{var s=e[n++],u=e[n++];t[r++]=String.fromCharCode((15&i)<<12|(63&s)<<6|63&u)}}return t.join("")},$={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(e,t){if(!Array.isArray(e))throw Error("encodeByteArray takes an array as a parameter");this.init_();for(var n=t?this.byteToCharMapWebSafe_:this.byteToCharMap_,r=[],i=0;i<e.length;i+=3){var a=e[i],o=i+1<e.length,s=o?e[i+1]:0,u=i+2<e.length,c=u?e[i+2]:0,l=a>>2,h=(3&a)<<4|s>>4,f=(15&s)<<2|c>>6,d=63&c;!u&&(d=64,o||(f=64)),r.push(n[l],n[h],n[f],n[d])}return r.join("")},encodeString:function(e,t){return this.HAS_NATIVE_SUPPORT&&!t?btoa(e):this.encodeByteArray(X(e),t)},decodeString:function(e,t){return this.HAS_NATIVE_SUPPORT&&!t?atob(e):Y(this.decodeStringToByteArray(e,t))},decodeStringToByteArray:function(e,t){this.init_();for(var n=t?this.charToByteMapWebSafe_:this.charToByteMap_,r=[],i=0;i<e.length;){var a=n[e.charAt(i++)],o=i<e.length?n[e.charAt(i)]:0,s=++i<e.length?n[e.charAt(i)]:64,u=++i<e.length?n[e.charAt(i)]:64;if(++i,null==a||null==o||null==s||null==u)throw new Z;var c=a<<2|o>>4;if(r.push(c),64!==s){var l=o<<4&240|s>>2;if(r.push(l),64!==u){var h=s<<6&192|u;r.push(h)}}}return r},init_:function(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(var e=0;e<this.ENCODED_VALS.length;e++)this.byteToCharMap_[e]=this.ENCODED_VALS.charAt(e),this.charToByteMap_[this.byteToCharMap_[e]]=e,this.byteToCharMapWebSafe_[e]=this.ENCODED_VALS_WEBSAFE.charAt(e),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[e]]=e,e>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(e)]=e,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(e)]=e)}}},Z=function(e){function t(){var e;return(0,O._)(this,t),e=(0,V._)(this,t,arguments),e.name="DecodeBase64StringError",e}return(0,z._)(t,e),t}((0,H._)(Error)),ee=function(e){var t=X(e);return $.encodeByteArray(t,!0)},et=function(e){return ee(e).replace(/\./g,"")},en=function(e){try{return $.decodeString(e,!0)}catch(e){console.error("base64Decode failed: ",e)}return null},er=function(){if(void 0!==U.default&&void 0!==U.default.env){var e=U.default.env.__FIREBASE_DEFAULTS__;if(e)return JSON.parse(e)}},ei=function(){if("u">typeof document){try{e=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch(e){return}var e,t=e&&en(e[1]);return t&&JSON.parse(t)}},ea=function(){try{return("u">typeof self?self:"u">typeof window?window:e.g).__FIREBASE_DEFAULTS__||er()||ei()}catch(e){console.info("Unable to get __FIREBASE_DEFAULTS__ due to: ".concat(e));return}},eo=function(e){var t,n;return null==(n=null==(t=ea())?void 0:t.emulatorHosts)?void 0:n[e]},es=function(e){var t=eo(e);if(t){var n=t.lastIndexOf(":");if(n<=0||n+1===t.length)throw Error("Invalid host ".concat(t," with no separate hostname and port!"));var r=parseInt(t.substring(n+1),10);return"["===t[0]?[t.substring(1,n-1),r]:[t.substring(0,n),r]}},eu=function(){var e;return null==(e=ea())?void 0:e.config},ec=function(e){var t;
1return null==(t=ea())?void 0:t["_".concat(e)]},el=function(){function e(){var t=this;(0,O._)(this,e),this.reject=function(){},this.resolve=function(){},this.promise=new Promise(function(e,n){t.resolve=e,t.reject=n})}return(0,P._)(e,[{key:"wrapCallback",value:function(e){var t=this;return function(n,r){n?t.reject(n):t.resolve(r),"function"==typeof e&&(t.promise.catch(function(){}),1===e.length?e(n):e(n,r))}}}]),e}();function eh(){return"u">typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:""}function ef(){return!function(){var t,n=null==(t=ea())?void 0:t.forceEnvironment;if("node"===n)return!0;if("browser"===n)return!1;try{return"[object process]"===Object.prototype.toString.call(e.g.process)}catch(e){return!1}}()&&!!navigator.userAgent&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}function ed(){try{return("u"<typeof indexedDB?"undefined":(0,G._)(indexedDB))==="object"}catch(e){return!1}}var ev=function(e){function t(e,n,r){var i;return(0,O._)(this,t),(i=(0,V._)(this,t,[n])).code=e,i.customData=r,i.name="FirebaseError",Object.setPrototypeOf(i,t.prototype),Error.captureStackTrace&&Error.captureStackTrace(i,ey.prototype.create),i}return(0,z._)(t,e),t}((0,H._)(Error)),ey=function(){function e(t,n,r){(0,O._)(this,e),this.service=t,this.serviceName=n,this.errors=r}return(0,P._)(e,[{key:"create",value:function(e){for(var t,n,r=arguments.length,i=Array(r>1?r-1:0),a=1;a<r;a++)i[a-1]=arguments[a];var o=i[0]||{},s="".concat(this.service,"/").concat(e),u=this.errors[e],c=u?(t=u,n=o,t.replace(ep,function(e,t){var r=n[t];return null!=r?String(r):"<".concat(t,"?>")})):"Error",l="".concat(this.serviceName,": ").concat(c," (").concat(s,").");return new ev(s,l,o)}}]),e}(),ep=/\{\$([^}]+)}/g;function em(e,t){if(e===t)return!0;var n=Object.keys(e),r=Object.keys(t),i=!0,a=!1,o=void 0;try{for(var s,u=n[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var c=s.value;if(!r.includes(c))return!1;var l=e[c],h=t[c];if(eg(l)&&eg(h)){if(!em(l,h))return!1}else if(l!==h)return!1}}catch(e){a=!0,o=e}finally{try{i||null==u.return||u.return()}finally{if(a)throw o}}var f=!0,d=!1,v=void 0;try{for(var y,p=r[Symbol.iterator]();!(f=(y=p.next()).done);f=!0){var m=y.value;if(!n.includes(m))return!1}}catch(e){d=!0,v=e}finally{try{f||null==p.return||p.return()}finally{if(d)throw v}}return!0}function eg(e){return null!==e&&(void 0===e?"undefined":(0,G._)(e))==="object"}function e_(e){var t=[],n=!0,r=!1,i=void 0;try{for(var a,o=Object.entries(e)[Symbol.iterator]();!(n=(a=o.next()).done);n=!0)!function(){var e=(0,D._)(a.value,2),n=e[0],r=e[1];Array.isArray(r)?r.forEach(function(e){t.push(encodeURIComponent(n)+"="+encodeURIComponent(e))}):t.push(encodeURIComponent(n)+"="+encodeURIComponent(r))}()}catch(e){r=!0,i=e}finally{try{n||null==o.return||o.return()}finally{if(r)throw i}}return t.length?"&"+t.join("&"):""}function ek(e){var t={};return e.replace(/^\?/,"").split("&").forEach(function(e){if(e){var n=(0,D._)(e.split("="),2),r=n[0],i=n[1];t[decodeURIComponent(r)]=decodeURIComponent(i)}}),t}function eb(e){var t=e.indexOf("?");if(!t)return"";var n=e.indexOf("#",t);return e.substring(t,n>0?n:void 0)}(0,P._)(function e(){(0,O._)(this,e),this.chain_=[],this.buf_=[],this.W_=[],this.pad_=[],this.inbuf_=0,this.total_=0,this.blockSize=64,this.pad_[0]=128;for(var t=1;t<this.blockSize;++t)this.pad_[t]=0;this.reset()},[{key:"reset",value:function(){this.chain_[0]=0x67452301,this.chain_[1]=0xefcdab89,this.chain_[2]=0x98badcfe,this.chain_[3]=0x10325476,this.chain_[4]=0xc3d2e1f0,this.inbuf_=0,this.total_=0}},{key:"compress_",value:function(e,t){t||(t=0);var n,r,i=this.W_;if("string"==typeof e)for(var a=0;a<16;a++)i[a]=e.charCodeAt(t)<<24|e.charCodeAt(t+1)<<16|e.charCodeAt(t+2)<<8|e.charCodeAt(t+3),t+=4;else for(var o=0;o<16;o++)i[o]=e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3],t+=4;for(var s=16;s<80;s++){var u=i[s-3]^i[s-8]^i[s-14]^i[s-16];i[s]=(u<<1|u>>>31)&0xffffffff}for(var c=this.chain_[0],l=this.chain_[1],h=this.chain_[2],f=this.chain_[3],d=this.chain_[4],v=0;v<80;v++){v<40?v<20?(n=f^l&(h^f),r=0x5a827999):(n=l^h^f,r=0x6ed9eba1):v<60?(n=l&h|f&(l|h),r=0x8f1bbcdc):(n=l^h^f,r=0xca62c1d6);var y=(c<<5|c>>>27)+n+d+r+i[v]|0;d=f,f=h,h=(l<<30|l>>>2)&0xffffffff,l=c,c=y}this.chain_[0]=this.chain_[0]+c|0,this.chain_[1]=this.chain_[1]+l|0,this.chain_[2]=this.chain_[2]+h|0,this.chain_[3]=this.chain_[3]+f|0,this.chain_[4]=this.chain_[4]+d|0}},{key:"update",value:function(e,t){if(null!=e){void 0===t&&(t=e.length);for(var n=t-this.blockSize,r=0,i=this.buf_,a=this.inbuf_;r<t;){if(0===a)for(;r<=n;)this.compress_(e,r),r+=this.blockSize;if("string"==typeof e){for(;r<t;)if(i[a]=e.charCodeAt(r),++a,++r,a===this.blockSize){this.compress_(i),a=0;break}}else for(;r<t;)if(i[a]=e[r],++a,++r,a===this.blockSize){this.compress_(i),a=0;break}}this.inbuf_=a,this.total_+=t}}},{key:"digest",value:function(){var e=[],t=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&t,t/=256;this.compress_(this.buf_);for(var r=0,i=0;i<5;i++)for(var a=24;a>=0;a-=8)e[r]=this.chain_[i]>>a&255,++r;return e}}]);var ew=function(){function e(t,n){var r=this;(0,O._)(this,e),this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Prom
1ise.resolve(),this.finalized=!1,this.onNoObservers=n,this.task.then(function(){t(r)}).catch(function(e){r.error(e)})}return(0,P._)(e,[{key:"next",value:function(e){this.forEachObserver(function(t){t.next(e)})}},{key:"error",value:function(e){this.forEachObserver(function(t){t.error(e)}),this.close(e)}},{key:"complete",value:function(){this.forEachObserver(function(e){e.complete()}),this.close()}},{key:"subscribe",value:function(e,t,n){var r,i=this;if(void 0===e&&void 0===t&&void 0===n)throw Error("Missing Observer.");void 0===(r=!function(e,t){if((void 0===e?"undefined":(0,G._)(e))!=="object"||null===e)return!1;var n=!0,r=!1,i=void 0;try{for(var a,o=t[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){var s=a.value;if(s in e&&"function"==typeof e[s])return!0}}catch(e){r=!0,i=e}finally{try{n||null==o.return||o.return()}finally{if(r)throw i}}return!1}(e,["next","error","complete"])?{next:e,error:t,complete:n}:e).next&&(r.next=eI),void 0===r.error&&(r.error=eI),void 0===r.complete&&(r.complete=eI);var a=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(function(){try{i.finalError?r.error(i.finalError):r.complete()}catch(e){}}),this.observers.push(r),a}},{key:"unsubscribeOne",value:function(e){void 0!==this.observers&&void 0!==this.observers[e]&&(delete this.observers[e],this.observerCount-=1,0===this.observerCount&&void 0!==this.onNoObservers&&this.onNoObservers(this))}},{key:"forEachObserver",value:function(e){if(!this.finalized)for(var t=0;t<this.observers.length;t++)this.sendOne(t,e)}},{key:"sendOne",value:function(e,t){var n=this;this.task.then(function(){if(void 0!==n.observers&&void 0!==n.observers[e])try{t(n.observers[e])}catch(e){"u">typeof console&&console.error&&console.error(e)}})}},{key:"close",value:function(e){var t=this;this.finalized||(this.finalized=!0,void 0!==e&&(this.finalError=e),this.task.then(function(){t.observers=void 0,t.onNoObservers=void 0}))}}]),e}();function eI(){}function eT(e){return e&&e._delegate?e._delegate:e}var eE=function(){function e(t,n,r){(0,O._)(this,e),this.name=t,this.instanceFactory=n,this.type=r,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}return(0,P._)(e,[{key:"setInstantiationMode",value:function(e){return this.instantiationMode=e,this}},{key:"setMultipleInstances",value:function(e){return this.multipleInstances=e,this}},{key:"setServiceProps",value:function(e){return this.serviceProps=e,this}},{key:"setInstanceCreatedCallback",value:function(e){return this.onInstanceCreated=e,this}}]),e}(),eS="[DEFAULT]",eC=function(){function e(t,n){(0,O._)(this,e),this.name=t,this.container=n,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}return(0,P._)(e,[{key:"get",value:function(e){var t=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(t)){var n=new el;if(this.instancesDeferred.set(t,n),this.isInitialized(t)||this.shouldAutoInitialize())try{var r=this.getOrInitializeService({instanceIdentifier:t});r&&n.resolve(r)}catch(e){}}return this.instancesDeferred.get(t).promise}},{key:"getImmediate",value:function(e){var t,n=this.normalizeInstanceIdentifier(null==e?void 0:e.identifier),r=null!=(t=null==e?void 0:e.optional)&&t;if(this.isInitialized(n)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:n})}catch(e){if(r)return null;throw e}if(r)return null;throw Error("Service ".concat(this.name," is not available"))}},{key:"getComponent",value:function(){return this.component}},{key:"setComponent",value:function(e){if(e.name!==this.name)throw Error("Mismatching Component ".concat(e.name," for Provider ").concat(this.name,"."));if(this.component)throw Error("Component for ".concat(this.name," has already been provided"));if(this.component=e,this.shouldAutoInitialize()){if("EAGER"===e.instantiationMode)try{this.getOrInitializeService({instanceIdentifier:eS})}catch(e){}var t=!0,n=!1,r=void 0;try{for(var i,a=this.instancesDeferred.entries()[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var o=(0,D._)(i.value,2),s=o[0],u=o[1],c=this.normalizeInstanceIdentifier(s);try{var l=this.getOrInitializeService({instanceIdentifier:c});u.resolve(l)}catch(e){}}}catch(e){n=!0,r=e}finally{try{t||null==a.return||a.return()}finally{if(n)throw r}}}}},{key:"clearInstance",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:eS;this.instancesDeferred.delete(e),this.instancesOptions.delete(e),this.instances.delete(e)}},{key:"delete",value:function(){return(0,N._)(function(){var e;return(0,M._)(this,function(t){switch(t.label){case 0:return e=Array.from(this.instances.values()),[4,Promise.all((0,L._)(e.f
1ilter(function(e){return"INTERNAL"in e}).map(function(e){return e.INTERNAL.delete()})).concat((0,L._)(e.filter(function(e){return"_delete"in e}).map(function(e){return e._delete()}))))];case 1:return t.sent(),[2]}})}).call(this)}},{key:"isComponentSet",value:function(){return null!=this.component}},{key:"isInitialized",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:eS;return this.instances.has(e)}},{key:"getOptions",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:eS;return this.instancesOptions.get(e)||{}}},{key:"initialize",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.options,n=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(n))throw Error("".concat(this.name,"(").concat(n,") has already been initialized"));if(!this.isComponentSet())throw Error("Component ".concat(this.name," has not been registered yet"));var r=this.getOrInitializeService({instanceIdentifier:n,options:void 0===t?{}:t}),i=!0,a=!1,o=void 0;try{for(var s,u=this.instancesDeferred.entries()[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var c=(0,D._)(s.value,2),l=c[0],h=c[1],f=this.normalizeInstanceIdentifier(l);n===f&&h.resolve(r)}}catch(e){a=!0,o=e}finally{try{i||null==u.return||u.return()}finally{if(a)throw o}}return r}},{key:"onInit",value:function(e,t){var n,r=this.normalizeInstanceIdentifier(t),i=null!=(n=this.onInitCallbacks.get(r))?n:new Set;i.add(e),this.onInitCallbacks.set(r,i);var a=this.instances.get(r);return a&&e(a,r),function(){i.delete(e)}}},{key:"invokeOnInitCallbacks",value:function(e,t){var n=this.onInitCallbacks.get(t);if(n){var r=!0,i=!1,a=void 0;try{for(var o,s=n[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var u=o.value;try{u(e,t)}catch(e){}}}catch(e){i=!0,a=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw a}}}}},{key:"getOrInitializeService",value:function(e){var t,n=e.instanceIdentifier,r=e.options,i=void 0===r?{}:r,a=this.instances.get(n);if(!a&&this.component&&(a=this.component.instanceFactory(this.container,{instanceIdentifier:(t=n)===eS?void 0:t,options:i}),this.instances.set(n,a),this.instancesOptions.set(n,i),this.invokeOnInitCallbacks(a,n),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,n,a)}catch(e){}return a||null}},{key:"normalizeInstanceIdentifier",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:eS;return this.component?this.component.multipleInstances?e:eS:e}},{key:"shouldAutoInitialize",value:function(){return!!this.component&&"EXPLICIT"!==this.component.instantiationMode}}]),e}(),ex=function(){function e(t){(0,O._)(this,e),this.name=t,this.providers=new Map}return(0,P._)(e,[{key:"addComponent",value:function(e){var t=this.getProvider(e.name);if(t.isComponentSet())throw Error("Component ".concat(e.name," has already been registered with ").concat(this.name));t.setComponent(e)}},{key:"addOrOverwriteComponent",value:function(e){this.getProvider(e.name).isComponentSet()&&this.providers.delete(e.name),this.addComponent(e)}},{key:"getProvider",value:function(e){if(this.providers.has(e))return this.providers.get(e);var t=new eC(e,this);return this.providers.set(e,t),t}},{key:"getProviders",value:function(){return Array.from(this.providers.values())}}]),e}(),eA=[];(n=i||(i={}))[n.DEBUG=0]="DEBUG",n[n.VERBOSE=1]="VERBOSE",n[n.INFO=2]="INFO",n[n.WARN=3]="WARN",n[n.ERROR=4]="ERROR",n[n.SILENT=5]="SILENT";var eD={debug:i.DEBUG,verbose:i.VERBOSE,info:i.INFO,warn:i.WARN,error:i.ERROR,silent:i.SILENT},eR=i.INFO,eN=(a={},(0,J._)(a,i.DEBUG,"log"),(0,J._)(a,i.VERBOSE,"log"),(0,J._)(a,i.INFO,"info"),(0,J._)(a,i.WARN,"warn"),(0,J._)(a,i.ERROR,"error"),a),eO=function(e,t){for(var n,r=arguments.length,i=Array(r>2?r-2:0),a=2;a<r;a++)i[a-2]=arguments[a];if(!(t<e.logLevel)){var o=new Date().toISOString(),s=eN[t];if(s)(n=console)[s].apply(n,["[".concat(o,"] ").concat(e.name,":")].concat((0,L._)(i)));else throw Error("Attempted to log a message with an invalid logType (value: ".concat(t,")"))}},eP=function(){function e(t){(0,O._)(this,e),this.name=t,this._logLevel=eR,this._logHandler=eO,this._userLogHandler=null,eA.push(this)}return(0,P._)(e,[{key:"logLevel",get:function(){return this._logLevel},set:function(e){if(!(e in i))throw TypeError('Invalid value "'.concat(e,'" assigned to `logLevel`'));this._logLevel=e}},{key:"setLogLevel",value:function(e){this._logLevel="string"==typeof e?eD[e]:e}},{key:"logHandler",get:function(){return this._logHandler},set:function(e){if("function"!=typeof e)throw TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e}},{key:"userLogHandler",get:function(){return this._userLogHandler},set:function(e){this._userLogHandler=e}},{key:"debug",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];this._userLogHandler&&this._userLogHandler.apply(this,[this,i.DEBUG].concat((0,L._)(t))),this._logHandler.apply(this,[this,i.DEBUG].concat((0,L._)(t)))}},{key:"log",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];this._userLogHandler&&this._userLogHandler.apply(this,[this,i.VERBOSE].concat((0,L._)(t))),this._logHandler.apply(this,[this,i.VERBOSE].concat((0,L._)(t)))}},{key:"info",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];this._userLogHandler&&this._userLogHandler.apply(this,[this,i.INFO].concat((0,L._)(t))),this._logHandler.apply(this,[this,i.INFO].concat((0,L._)(t)))}},{key:"warn",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];this._userLogHandler&&this._userLogHandler.apply(this,[this,i.WARN].concat((0,L._)(t))),this._logHandler.apply(this,[this,i.WARN].concat((0,L._)(t)))}},{key:"error",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];this._userLogHandler&&this._userLogHandler.apply(this,[this,i.ERROR].concat((0,L._)(t))),this._logHandler.apply(this,[this,i.ERROR].concat((0,L._)(t)))}}]),e}(),eL=e.i(92808),eM=new WeakMap,eU=new WeakMap,eF=new WeakMap,eV=new WeakMap,eB=new WeakMap,ej={get:function(e,t,n){if((0,K._)(e,IDBTransaction)){if
1("done"===t)return eU.get(e);if("objectStoreNames"===t)return e.objectStoreNames||eF.get(e);if("store"===t)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return eq(e[t])},set:function(e,t,n){return e[t]=n,!0},has:function(e,t){return!!(0,K._)(e,IDBTransaction)&&("done"===t||"store"===t)||t in e}};function eq(e){if((0,K._)(e,IDBRequest)){var t;return(t=new Promise(function(t,n){var r=function(){e.removeEventListener("success",i),e.removeEventListener("error",a)},i=function(){t(eq(e.result)),r()},a=function(){n(e.error),r()};e.addEventListener("success",i),e.addEventListener("error",a)})).then(function(t){(0,K._)(t,IDBCursor)&&eM.set(t,e)}).catch(function(){}),eB.set(t,e),t}if(eV.has(e))return eV.get(e);var n=function(e){return"function"==typeof e?e!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?(s||(s=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(e)?function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return e.apply(ez(this),n),eq(eM.get(this))}:function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return eq(e.apply(ez(this),n))}:function(t){for(var n=arguments.length,r=Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];var a=e.call.apply(e,[ez(this),t].concat((0,L._)(r)));return eF.set(a,t.sort?t.sort():[t]),eq(a)}:((0,K._)(e,IDBTransaction)&&function(e){if(!eU.has(e)){var t=new Promise(function(t,n){var r=function(){e.removeEventListener("complete",i),e.removeEventListener("error",a),e.removeEventListener("abort",a)},i=function(){t(),r()},a=function(){n(e.error||new DOMException("AbortError","AbortError")),r()};e.addEventListener("complete",i),e.addEventListener("error",a),e.addEventListener("abort",a)});eU.set(e,t)}}(e),(o||(o=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])).some(function(t){return(0,K._)(e,t)}))?new Proxy(e,ej):e}(e);return n!==e&&(eV.set(e,n),eB.set(n,e)),n}var ez=function(e){return eB.get(e)},eK=["get","getKey","getAll","getAllKeys","count"],eG=["put","add","delete","clear"],eH=new Map;function eW(e,t){if((0,K._)(e,IDBDatabase)&&!(t in e)&&"string"==typeof t){if(eH.get(t))return eH.get(t);var n=t.replace(/FromIndex$/,""),r=t!==n,i=eG.includes(n);if(n in(r?IDBIndex:IDBObjectStore).prototype&&(i||eK.includes(n))){var a=function(e){for(var t=arguments.length,a=Array(t>1?t-1:0),o=1;o<t;o++)a[o-1]=arguments[o];return(0,N._)(function(){var t,o,s;return(0,M._)(this,function(u){switch(u.label){case 0:return s=(o=this.transaction(e,i?"readwrite":"readonly")).store,r&&(s=s.index(a.shift())),[4,Promise.all([(t=s)[n].apply(t,(0,L._)(a)),i&&o.done])];case 1:return[2,u.sent()[0]]}})}).call(this)};return eH.set(t,a),a}}}t=ej,ej=(0,eL._)((0,E._)({},t),{get:function(e,n,r){return eW(e,n)||t.get(e,n,r)},has:function(e,n){return!!eW(e,n)||t.has(e,n)}});var eQ=function(){function e(t){(0,O._)(this,e),this.container=t}return(0,P._)(e,[{key:"getPlatformInfoString",value:function(){return this.container.getProviders().map(function(e){if((null==(t=e.getComponent())?void 0:t.type)!=="VERSION")return null;var t,n=e.getImmediate();return"".concat(n.library,"/").concat(n.version)}).filter(function(e){return e}).join(" ")}}]),e}(),eJ="@firebase/app",eX="0.10.17",eY=new eP("@firebase/app"),e$="[DEFAULT]",eZ=(u={},(0,J._)(u,eJ,"fire-core"),(0,J._)(u,"@firebase/app-compat","fire-core-compat"),(0,J._)(u,"@firebase/analytics","fire-analytics"),(0,J._)(u,"@firebase/analytics-compat","fire-analytics-compat"),(0,J._)(u,"@firebase/app-check","fire-app-check"),(0,J._)(u,"@firebase/app-check-compat","fire-app-check-compat"),(0,J._)(u,"@firebase/auth","fire-auth"),(0,J._)(u,"@firebase/auth-compat","fire-auth-compat"),(0,J._)(u,"@firebase/database","fire-rtdb"),(0,J._)(u,"@firebase/data-connect","fire-data-connect"),(0,J._)(u,"@firebase/database-compat","fire-rtdb-compat"),(0,J._)(u,"@firebase/functions","fire-fn"),(0,J._)(u,"@firebase/functions-compat","fire-fn-compat"),(0,J._)(u,"@firebase/installations","fire-iid"),(0,J._)(u,"@firebase/installations-compat","fire-iid-compat"),(0,J._)(u,"@firebase/messaging","fire-fcm"),(0,J._)(u,"@firebase/messaging-compat","fire-fcm-compat"),(0,J._)(u,"@firebase/performance","fire-perf"),(0,J._)(u,"@firebase/performance-compat","fire-perf-compat"),(0,J._)(u,"@firebase/remote-config","fire-rc"),(0,J._)(u,"@firebase/remote-config-compat","fire-rc-compat"),(0,J._)(u,"@firebase/storage","fire-gcs"),(0,J._)(u,"@firebase/storage-compat","fire-gcs-compat"),(0,J._)(u,"@firebase/firestore","fire-fst"),(0,J._)(u,"@firebase/firestore-compat","fire-fst-compat"),(0,J._)(u,"@firebase/vertexai","fire-vertex"),(0,J._)(u,"fire-js","fire-js"),(0,J._)(u,"firebase","fire-js-all"),u),e0=new Map,e1=new Map,e2=new Map;function e3(e,t){try{e.container.addComponent(t)}catch(n){eY.debug("Component ".concat(t.name," failed to register with FirebaseApp ").concat(e.name),n)}}function e4(e){var t=e.name;if(e2.has(t))return eY.debug("There were multiple attempts to register component ".concat(t,".")),!1;e2.set(t,e);var n=!0,r=!1,i=void 0;try{for(var a,o=e0.values()[Symbol.iterator]();!(n=(a=o.next()).done);
1n=!0){var s=a.value;e3(s,e)}}catch(e){r=!0,i=e}finally{try{n||null==o.return||o.return()}finally{if(r)throw i}}var u=!0,c=!1,l=void 0;try{for(var h,f=e1.values()[Symbol.iterator]();!(u=(h=f.next()).done);u=!0){var d=h.value;e3(d,e)}}catch(e){c=!0,l=e}finally{try{u||null==f.return||f.return()}finally{if(c)throw l}}return!0}function e5(e,t){var n=e.container.getProvider("heartbeat").getImmediate({optional:!0});return n&&n.triggerHeartbeat(),e.container.getProvider(t)}function e6(e){return void 0!==e.settings}var e8=new ey("app","Firebase",(c={},(0,J._)(c,"no-app","No Firebase App '{$appName}' has been created - call initializeApp() first"),(0,J._)(c,"bad-app-name","Illegal App name: '{$appName}'"),(0,J._)(c,"duplicate-app","Firebase App named '{$appName}' already exists with different options or config"),(0,J._)(c,"app-deleted","Firebase App named '{$appName}' already deleted"),(0,J._)(c,"server-app-deleted","Firebase Server App has been deleted"),(0,J._)(c,"no-options","Need to provide options, when not being deployed to hosting via source."),(0,J._)(c,"invalid-app-argument","firebase.{$appName}() takes either no argument or a Firebase App instance."),(0,J._)(c,"invalid-log-argument","First argument to `onLog` must be null or a function."),(0,J._)(c,"idb-open","Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}."),(0,J._)(c,"idb-get","Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}."),(0,J._)(c,"idb-set","Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}."),(0,J._)(c,"idb-delete","Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}."),(0,J._)(c,"finalization-registry-not-supported","FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry."),(0,J._)(c,"invalid-server-app-environment","FirebaseServerApp is not for use in browser environments."),c)),e7=function(){function e(t,n,r){var i=this;(0,O._)(this,e),this._isDeleted=!1,this._options=Object.assign({},t),this._config=Object.assign({},n),this._name=n.name,this._automaticDataCollectionEnabled=n.automaticDataCollectionEnabled,this._container=r,this.container.addComponent(new eE("app",function(){return i},"PUBLIC"))}return(0,P._)(e,[{key:"automaticDataCollectionEnabled",get:function(){return this.checkDestroyed(),this._automaticDataCollectionEnabled},set:function(e){this.checkDestroyed(),this._automaticDataCollectionEnabled=e}},{key:"name",get:function(){return this.checkDestroyed(),this._name}},{key:"options",get:function(){return this.checkDestroyed(),this._options}},{key:"config",get:function(){return this.checkDestroyed(),this._config}},{key:"container",get:function(){return this._container}},{key:"isDeleted",get:function(){return this._isDeleted},set:function(e){this._isDeleted=e}},{key:"checkDestroyed",value:function(){if(this.isDeleted)throw e8.create("app-deleted",{appName:this._name})}}]),e}();function e9(e,t,n,r){(0,O._)(this,e9);var i,a=void 0!==t.automaticDataCollectionEnabled&&t.automaticDataCollectionEnabled,o={name:n,automaticDataCollectionEnabled:a};return i=void 0!==e.apiKey?(0,V._)(this,e9,[e,o,r]):(0,V._)(this,e9,[e.options,o,r]),(0,Q._)(i)._serverConfig=Object.assign({automaticDataCollectionEnabled:a},t),(0,Q._)(i)._finalizationRegistry=null,"u">typeof FinalizationRegistry&&((0,Q._)(i)._finalizationRegistry=new FinalizationRegistry(function(){(0,Q._)(i).automaticCleanup()})),(0,Q._)(i)._refCount=0,(0,Q._)(i).incRefCount((0,Q._)(i)._serverConfig.releaseOnDeref),(0,Q._)(i)._serverConfig.releaseOnDeref=void 0,t.releaseOnDeref=void 0,tr(eJ,eX,"serverapp"),(0,Q._)(i)}(0,z._)(e9,e7),(0,P._)(e9,[{key:"toJSON",value:function(){}},{key:"refCount",get:function(){return this._refCount}},{key:"incRefCount",value:function(e){this.isDeleted||(this._refCount++,void 0!==e&&null!==this._finalizationRegistry&&this._finalizationRegistry.register(e,this))}},{key:"decRefCount",value:function(){return this.isDeleted?0:--this._refCount}},{key:"automaticCleanup",value:function(){var e;e=this,(0,N._)(function(){var t,n;return(0,M._)(this,function(r){switch(r.label){case 0:if(t=!1,n=e.name,e0.has(n)?(t=!0,e0.delete(n)):e1.has(n)&&0>=e.decRefCount()&&(e1.delete(n),t=!0),!t)return[3,2];return[4,Promise.all(e.container.getProviders().map(function(e){return e.delete()}))];case 1:r.sent(),e.isDeleted=!0,r.label=2;case 2:return[2]}})})()}},{key:"settings",get:function(){return this.checkDestroyed(),this._serverConfig}},{key:"checkDestroyed",value:function(){if(this.isDeleted)throw e8.create("server-app-deleted")}}]);var te="11.1.0";function tt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e;(void 0===t?"undefined":(0,G._)(t))!=="object"&&(t={name:t});var r=Object.assign({name:e$,automaticDataCollectionEnabled:!1},t),i=r.name;if("string"!=typeof i||!i)throw e8.create("bad-app-name",{appName:String(i)});if(n||(n=eu()),!n)throw e8.create("no-options");var a=e0.get(i);if(a)if(em(n,a.options)&&em(r,a.config))return a;else throw e8.create("duplicate-app",{appName:i});
1var o=new ex(i),s=!0,u=!1,c=void 0;try{for(var l,h=e2.values()[Symbol.iterator]();!(s=(l=h.next()).done);s=!0){var f=l.value;o.addComponent(f)}}catch(e){u=!0,c=e}finally{try{s||null==h.return||h.return()}finally{if(u)throw c}}var d=new e7(n,r,o);return e0.set(i,d),d}function tn(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:e$,t=e0.get(e);if(!t&&e===e$&&eu())return tt();if(!t)throw e8.create("no-app",{appName:e});return t}function tr(e,t,n){var r,i=null!=(r=eZ[e])?r:e;n&&(i+="-".concat(n));var a=i.match(/\s|\//),o=t.match(/\s|\//);if(a||o){var s=['Unable to register library "'.concat(i,'" with version "').concat(t,'":')];a&&s.push('library name "'.concat(i,'" contains illegal characters (whitespace or "/")')),a&&o&&s.push("and"),o&&s.push('version name "'.concat(t,'" contains illegal characters (whitespace or "/")')),eY.warn(s.join(" "));return}e4(new eE("".concat(i,"-version"),function(){return{library:i,version:t}},"VERSION"))}var ti="firebase-heartbeat-store",ta=null;function to(){return ta||(ta=(function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.blocked,i=n.upgrade,a=n.blocking,o=n.terminated,s=indexedDB.open(e,t),u=eq(s);return i&&s.addEventListener("upgradeneeded",function(e){i(eq(s.result),e.oldVersion,e.newVersion,eq(s.transaction),e)}),r&&s.addEventListener("blocked",function(e){return r(e.oldVersion,e.newVersion,e)}),u.then(function(e){o&&e.addEventListener("close",function(){return o()}),a&&e.addEventListener("versionchange",function(e){return a(e.oldVersion,e.newVersion,e)})}).catch(function(){}),u})("firebase-heartbeat-database",1,{upgrade:function(e,t){if(0===t)try{e.createObjectStore(ti)}catch(e){console.warn(e)}}}).catch(function(e){throw e8.create("idb-open",{originalErrorMessage:e.message})})),ta}function ts(e,t){return(0,N._)(function(){var n,r,i;return(0,M._)(this,function(a){switch(a.label){case 0:return a.trys.push([0,4,,5]),[4,to()];case 1:return[4,(n=a.sent().transaction(ti,"readwrite")).objectStore(ti).put(t,tu(e))];case 2:return a.sent(),[4,n.done];case 3:return a.sent(),[3,5];case 4:return r=a.sent(),(0,K._)(r,ev)?eY.warn(r.message):(i=e8.create("idb-set",{originalErrorMessage:null==r?void 0:r.message}),eY.warn(i.message)),[3,5];case 5:return[2]}})})()}function tu(e){return"".concat(e.name,"!").concat(e.options.appId)}var tc=function(){function e(t){var n=this;(0,O._)(this,e),this.container=t,this._heartbeatsCache=null;var r=this.container.getProvider("app").getImmediate();this._storage=new th(r),this._heartbeatsCachePromise=this._storage.read().then(function(e){return n._heartbeatsCache=e,e})}return(0,P._)(e,[{key:"triggerHeartbeat",value:function(){return(0,N._)(function(){var e,t,n,r,i,a;return(0,M._)(this,function(o){switch(o.label){case 0:if(o.trys.push([0,3,,4]),n=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),r=tl(),(null==(e=this._heartbeatsCache)?void 0:e.heartbeats)!=null)return[3,2];return i=this,[4,this._heartbeatsCachePromise];case 1:if(i._heartbeatsCache=o.sent(),(null==(t=this._heartbeatsCache)?void 0:t.heartbeats)==null)return[2];o.label=2;case 2:if(this._heartbeatsCache.lastSentHeartbeatDate===r||this._heartbeatsCache.heartbeats.some(function(e){return e.date===r}))return[2];return this._heartbeatsCache.heartbeats.push({date:r,agent:n}),this._heartbeatsCache.heartbeats=this._heartbeatsCache.heartbeats.filter(function(e){var t=new Date(e.date).valueOf();return Date.now()-t<=2592e6}),[2,this._storage.overwrite(this._heartbeatsCache)];case 3:return a=o.sent(),eY.warn(a),[3,4];case 4:return[2]}})}).call(this)}},{key:"getHeartbeatsHeader",value:function(){return(0,N._)(function(){var e,t,n,r,i,a,o;return(0,M._)(this,function(s){switch(s.label){case 0:if(s.trys.push([0,6,,7]),null!==this._heartbeatsCache)return[3,2];return[4,this._heartbeatsCachePromise];case 1:s.sent(),s.label=2;case 2:if((null==(e=this._heartbeatsCache)?void 0:e.heartbeats)==null||0===this._heartbeatsCache.heartbeats.length)return[2,""];if(t=tl(),r=(n=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1024,n=[],r=e.slice(),i=!0,a=!1,o=void 0;try{for(var s,u=e[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var c=function(){var e=s.value,i=n.find(function(t){return t.agent===e.agent});if(i){if(i.dates.push(e.date),tf(n)>t)return i.dates.pop(),"break"}else if(n.push({agent:e.agent,dates:[e.date]}),tf(n)>t)return n.pop(),"break";r=r.slice(1)}();if("break"===c)break}}catch(e){a=!0,o=e}finally{try{i||null==u.return||u.return()}finally{if(a)throw o}}return{heartbeatsToSend:n,unsentEntries:r}}(this._heartbeatsCache.heartbeats)).heartbeatsToSend,i=n.unsentEntries,a=et(JSON.stringify({version:2,heartbeats:r})),this._heartbeatsCache.lastSentHeartbeatDate=t,!(i.length>0))return[3,4];return this._heartbeatsCache.heartbeats=i,[4,this._storage.overwrite(this._heartbeatsCache)];case 3:return s.sent(),[3,5];case 4:this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache),s.label=5;case 5:return[2,a];case 6:return o=s.sent(),eY.warn(o),[2,""];case 7:return[2]}})}).call(this)}}]),e}();function tl(){return new Date().toISOString().substring(0,10)}var th=function(){function e(t){(0,O._)(this,e),this.app=t,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}return(0,P._)(e,[{key:"runIndexedDBEnvironmentCheck",value:function(){return(0,N._)(function(){return(0,M._)(this,function(e){return ed()?[2,new Promise(function(e,t){try{var n=!0,r="validate-browser-context-for-indexeddb-analytics-module",i=self.indexedDB.open(r);i.onsuccess=function(){i.result.close(),n||self.indexedDB.deleteDatabase(r),e(!0)},i.onupgradeneeded=function(){n=!1},i.onerror=function(){var e;t((null==(e=i.error)?void 0:e.message)||"")}}catch(e){t(e)}}).then(function(){return!0}).catch(function(){return!1})]:[2,!1]})})()}},{key:"read",value:function(){return(0,N._)(function(){var e;return(0,M._)(this,function(t){switch(t.label){case 0:return[4,this._canUseIndexedDBPromise];case 1:if(t.sent())return[3,2];return[2,{heartbeats:[]}];case 2:var n;return[4,(n=this.app,(0,N._)(function(){var e,t,r,i;return(0,M._)(this,function(a){switch(a.label){case 0:return a.trys.push([0,4,,5]),[4,to()];case 1:return[4,(e=a.sent().transaction(ti)).objectStore(ti).get(tu(n))];case 2:return t=a.sent(),[4,e.done];case 3:return a.sent(),[2,t];case 4:return r=a.sent(),(0,K._)(r,ev)?eY.warn(r.message):(i=e8.create("idb-get",{originalErrorMessage:null==r?void 0:r.message}),eY.warn(i.message)),[3,5];case 5:return[2]}})})())];case 3:if(null==(e=t.sent())?void 0:e.heartbeats)return[2,e];return[2,{heartbeats:[]}];case 4:return[2]}})}).call(this)}}
1,{key:"overwrite",value:function(e){return(0,N._)(function(){var t,n;return(0,M._)(this,function(r){switch(r.label){case 0:return[4,this._canUseIndexedDBPromise];case 1:if(r.sent())return[3,2];return[2];case 2:return[4,this.read()];case 3:return n=r.sent(),[2,ts(this.app,{lastSentHeartbeatDate:null!=(t=e.lastSentHeartbeatDate)?t:n.lastSentHeartbeatDate,heartbeats:e.heartbeats})];case 4:return[2]}})}).call(this)}},{key:"add",value:function(e){return(0,N._)(function(){var t,n;return(0,M._)(this,function(r){switch(r.label){case 0:return[4,this._canUseIndexedDBPromise];case 1:if(r.sent())return[3,2];return[2];case 2:return[4,this.read()];case 3:return n=r.sent(),[2,ts(this.app,{lastSentHeartbeatDate:null!=(t=e.lastSentHeartbeatDate)?t:n.lastSentHeartbeatDate,heartbeats:(0,L._)(n.heartbeats).concat((0,L._)(e.heartbeats))})];case 4:return[2]}})}).call(this)}}]),e}();function tf(e){return et(JSON.stringify({version:2,heartbeats:e})).length}e4(new eE("platform-logger",function(e){return new eQ(e)},"PRIVATE")),e4(new eE("heartbeat",function(e){return new tc(e)},"PRIVATE")),tr(eJ,eX,""),tr(eJ,eX,"esm2017"),tr("fire-js","");var td="u">typeof globalThis?globalThis:"u">typeof window?window:e.g,tv={};(function(){function e(){this.blockSize=-1,this.blockSize=64,this.g=[,,,,],this.B=Array(this.blockSize),this.o=this.h=0,this.s()}var t=function(){this.blockSize=-1};function n(){}function r(e,t,n){n||(n=0);var r=Array(16);if("string"==typeof t)for(var i=0;16>i;++i)r[i]=t.charCodeAt(n++)|t.charCodeAt(n++)<<8|t.charCodeAt(n++)<<16|t.charCodeAt(n++)<<24;else for(i=0;16>i;++i)r[i]=t[n++]|t[n++]<<8|t[n++]<<16|t[n++]<<24;t=e.g[0],n=e.g[1],i=e.g[2];var a=e.g[3],o=t+(a^n&(i^a))+r[0]+0xd76aa478|0;o=a+(i^(t=n+(o<<7|o>>>25))&(n^i))+r[1]+0xe8c7b756|0,o=i+(n^(a=t+(o<<12|o>>>20))&(t^n))+r[2]+0x242070db|0,o=n+(t^(i=a+(o<<17|o>>>15))&(a^t))+r[3]+0xc1bdceee|0,o=t+(a^(n=i+(o<<22|o>>>10))&(i^a))+r[4]+0xf57c0faf|0,o=a+(i^(t=n+(o<<7|o>>>25))&(n^i))+r[5]+0x4787c62a|0,o=i+(n^(a=t+(o<<12|o>>>20))&(t^n))+r[6]+0xa8304613|0,o=n+(t^(i=a+(o<<17|o>>>15))&(a^t))+r[7]+0xfd469501|0,o=t+(a^(n=i+(o<<22|o>>>10))&(i^a))+r[8]+0x698098d8|0,o=a+(i^(t=n+(o<<7|o>>>25))&(n^i))+r[9]+0x8b44f7af|0,o=i+(n^(a=t+(o<<12|o>>>20))&(t^n))+r[10]+0xffff5bb1|0,o=n+(t^(i=a+(o<<17|o>>>15))&(a^t))+r[11]+0x895cd7be|0,o=t+(a^(n=i+(o<<22|o>>>10))&(i^a))+r[12]+0x6b901122|0,o=a+(i^(t=n+(o<<7|o>>>25))&(n^i))+r[13]+0xfd987193|0,o=i+(n^(a=t+(o<<12|o>>>20))&(t^n))+r[14]+0xa679438e|0,o=n+(t^(i=a+(o<<17|o>>>15))&(a^t))+r[15]+0x49b40821|0,n=i+(o<<22|o>>>10),o=t+(i^a&(n^i))+r[1]+0xf61e2562|0,t=n+(o<<5|o>>>27),o=a+(n^i&(t^n))+r[6]+0xc040b340|0,a=t+(o<<9|o>>>23),o=i+(t^n&(a^t))+r[11]+0x265e5a51|0,i=a+(o<<14|o>>>18),o=n+(a^t&(i^a))+r[0]+0xe9b6c7aa|0,n=i+(o<<20|o>>>12),o=t+(i^a&(n^i))+r[5]+0xd62f105d|0,t=n+(o<<5|o>>>27),o=a+(n^i&(t^n))+r[10]+0x2441453|0,a=t+(o<<9|o>>>23),o=i+(t^n&(a^t))+r[15]+0xd8a1e681|0,i=a+(o<<14|o>>>18),o=n+(a^t&(i^a))+r[4]+0xe7d3fbc8|0,n=i+(o<<20|o>>>12),o=t+(i^a&(n^i))+r[9]+0x21e1cde6|0,t=n+(o<<5|o>>>27),o=a+(n^i&(t^n))+r[14]+0xc33707d6|0,a=t+(o<<9|o>>>23),o=i+(t^n&(a^t))+r[3]+0xf4d50d87|0,i=a+(o<<14|o>>>18),o=n+(a^t&(i^a))+r[8]+0x455a14ed|0,n=i+(o<<20|o>>>12),o=t+(i^a&(n^i))+r[13]+0xa9e3e905|0,t=n+(o<<5|o>>>27),o=a+(n^i&(t^n))+r[2]+0xfcefa3f8|0,a=t+(o<<9|o>>>23),o=i+(t^n&(a^t))+r[7]+0x676f02d9|0,i=a+(o<<14|o>>>18),o=n+(a^t&(i^a))+r[12]+0x8d2a4c8a|0,o=t+((n=i+(o<<20|o>>>12))^i^a)+r[5]+0xfffa3942|0,o=a+((t=n+(o<<4|o>>>28))^n^i)+r[8]+0x8771f681|0,o=i+((a=t+(o<<11|o>>>21))^t^n)+r[11]+0x6d9d6122|0,o=n+((i=a+(o<<16|o>>>16))^a^t)+r[14]+0xfde5380c|0,o=t+((n=i+(o<<23|o>>>9))^i^a)+r[1]+0xa4beea44|0,o=a+((t=n+(o<<4|o>>>28))^n^i)+r[4]+0x4bdecfa9|0,o=i+((a=t+(o<<11|o>>>21))^t^n)+r[7]+0xf6bb4b60|0,o=n+((i=a+(o<<16|o>>>16))^a^t)+r[10]+0xbebfbc70|0,o=t+((n=i+(o<<23|o>>>9))^i^a)+r[13]+0x289b7ec6|0,o=a+((t=n+(o<<4|o>>>28))^n^i)+r[0]+0xeaa127fa|0,o=i+((a=t+(o<<11|o>>>21))^t^n)+r[3]+0xd4ef3085|0,o=n+((i=a+(o<<16|o>>>16))^a^t)+r[6]+0x4881d05|0,o=t+((n=i+(o<<23|o>>>9))^i^a)+r[9]+0xd9d4d039|0,o=a+((t=n+(o<<4|o>>>28))^n^i)+r[12]+0xe6db99e5|0,o=i+((a=t+(o<<11|o>>>21))^t^n)+r[15]+0x1fa27cf8|0,o=n+((i=a+(o<<16|o>>>16))^a^t)+r[2]+0xc4ac5665|0,n=i+(o<<23|o>>>9),o=t+(i^(n|~a))+r[0]+0xf4292244|0,t=n+(o<<6|o>>>26),o=a+(n^(t|~i))+r[7]+0x432aff97|0,a=t+(o<<10|o>>>22),o=i+(t^(a|~n))+r[14]+0xab9423a7|0,i=a+(o<<15|o>>>17),o=n+(a^(i|~t))+r[5]+0xfc93a039|0,n=i+(o<<21|o>>>11),o=t+(i^(n|~a))+r[12]+0x655b59c3|0,t=n+(o<<6|o>>>26),o=a+(n^(t|~i))+r[3]+0x8f0ccc92|0,a=t+(o<<10|o>>>22),o=i+(t^(a|~n))+r[10]+0xffeff47d|0,i=a+(o<<15|o>>>17),o=n+(a^(i|~t))+r[1]+0x85845dd1|0,n=i+(o<<21|o>>>11),o=t+(i^(n|~a))+r[8]+0x6fa87e4f|0,t=n+(o<<6|o>>>26),o=a+(n^(t|~i))+r[15]+0xfe2ce6e0|0,a=t+(o<<10|o>>>22),o=i+(t^(a|~n))+r[6]+0xa3014314|0,i=a+(o<<15|o>>>17),o=n+(a^(i|~t))+r[13]+0x4e0811a1|0,n=i+(o<<21|o>>>11),o=t+(i^(n|~a))+r[4]+0xf7537e82|0,t=n+(o<<6|o>>>
126),o=a+(n^(t|~i))+r[11]+0xbd3af235|0,a=t+(o<<10|o>>>22),o=i+(t^(a|~n))+r[2]+0x2ad7d2bb|0,i=a+(o<<15|o>>>17),o=n+(a^(i|~t))+r[9]+0xeb86d391|0,e.g[0]=e.g[0]+t|0,e.g[1]=e.g[1]+(i+(o<<21|o>>>11))|0,e.g[2]=e.g[2]+i|0,e.g[3]=e.g[3]+a|0}function i(e,t){this.h=t;for(var n=[],r=!0,i=e.length-1;0<=i;i--){var a=0|e[i];r&&a==t||(n[i]=a,r=!1)}this.g=n}n.prototype=t.prototype,e.D=t.prototype,e.prototype=new n,e.prototype.constructor=e,e.C=function(e,n,r){for(var i=Array(arguments.length-2),a=2;a<arguments.length;a++)i[a-2]=arguments[a];return t.prototype[n].apply(e,i)},e.prototype.s=function(){this.g[0]=0x67452301,this.g[1]=0xefcdab89,this.g[2]=0x98badcfe,this.g[3]=0x10325476,this.o=this.h=0},e.prototype.u=function(e,t){void 0===t&&(t=e.length);for(var n=t-this.blockSize,i=this.B,a=this.h,o=0;o<t;){if(0==a)for(;o<=n;)r(this,e,o),o+=this.blockSize;if("string"==typeof e){for(;o<t;)if(i[a++]=e.charCodeAt(o++),a==this.blockSize){r(this,i),a=0;break}}else for(;o<t;)if(i[a++]=e[o++],a==this.blockSize){r(this,i),a=0;break}}this.h=a,this.o+=t},e.prototype.v=function(){var e=Array((56>this.h?this.blockSize:2*this.blockSize)-this.h);e[0]=128;for(var t=1;t<e.length-8;++t)e[t]=0;var n=8*this.o;for(t=e.length-8;t<e.length;++t)e[t]=255&n,n/=256;for(this.u(e),e=Array(16),t=n=0;4>t;++t)for(var r=0;32>r;r+=8)e[n++]=this.g[t]>>>r&255;return e};var a,o={};function s(e){var t;return -128<=e&&128>e?(t=function(e){return new i([0|e],0>e?-1:0)},Object.prototype.hasOwnProperty.call(o,e)?o[e]:o[e]=t(e)):new i([0|e],0>e?-1:0)}function u(e){if(isNaN(e)||!isFinite(e))return c;if(0>e)return p(u(-e));for(var t=[],n=1,r=0;e>=n;r++)t[r]=e/n|0,n*=0x100000000;return new i(t,0)}var c=s(0),f=s(1),d=s(0x1000000);function v(e){if(0!=e.h)return!1;for(var t=0;t<e.g.length;t++)if(0!=e.g[t])return!1;return!0}function y(e){return -1==e.h}function p(e){for(var t=e.g.length,n=[],r=0;r<t;r++)n[r]=~e.g[r];return new i(n,~e.h).add(f)}function m(e,t){return e.add(p(t))}function g(e,t){for(;(65535&e[t])!=e[t];)e[t+1]+=e[t]>>>16,e[t]&=65535,t++}function _(e,t){this.g=e,this.h=t}function k(e,t){if(v(t))throw Error("division by zero");if(v(e))return new _(c,c);if(y(e))return t=k(p(e),t),new _(p(t.g),p(t.h));if(y(t))return t=k(e,p(t)),new _(p(t.g),t.h);if(30<e.g.length){if(y(e)||y(t))throw Error("slowDivide_ only works with positive integers.");for(var n=f,r=t;0>=r.l(e);)n=b(n),r=b(r);var i=w(n,1),a=w(r,1);for(r=w(r,2),n=w(n,2);!v(r);){var o=a.add(r);0>=o.l(e)&&(i=i.add(n),a=o),r=w(r,1),n=w(n,1)}return t=m(e,i.j(t)),new _(i,t)}for(i=c;0<=e.l(t);){for(r=48>=(r=Math.ceil(Math.log(n=Math.max(1,Math.floor(e.m()/t.m())))/Math.LN2))?1:Math.pow(2,r-48),o=(a=u(n)).j(t);y(o)||0<o.l(e);)n-=r,o=(a=u(n)).j(t);v(a)&&(a=f),i=i.add(a),e=m(e,o)}return new _(i,e)}function b(e){for(var t=e.g.length+1,n=[],r=0;r<t;r++)n[r]=e.i(r)<<1|e.i(r-1)>>>31;return new i(n,e.h)}function w(e,t){var n=t>>5;t%=32;for(var r=e.g.length-n,a=[],o=0;o<r;o++)a[o]=0<t?e.i(o+n)>>>t|e.i(o+n+1)<<32-t:e.i(o+n);return new i(a,e.h)}(a=i.prototype).m=function(){if(y(this))return-p(this).m();for(var e=0,t=1,n=0;n<this.g.length;n++){var r=this.i(n);e+=(0<=r?r:0x100000000+r)*t,t*=0x100000000}return e},a.toString=function(e){if(2>(e=e||10)||36<e)throw Error("radix out of range: "+e);if(v(this))return"0";if(y(this))return"-"+p(this).toString(e);for(var t=u(Math.pow(e,6)),n=this,r="";;){var i=k(n,t).g,a=((0<(n=m(n,i.j(t))).g.length?n.g[0]:n.h)>>>0).toString(e);if(v(n=i))return a+r;for(;6>a.length;)a="0"+a;r=a+r}},a.i=function(e){return 0>e?0:e<this.g.length?this.g[e]:this.h},a.l=function(e){return y(e=m(this,e))?-1:+!v(e)},a.abs=function(){return y(this)?p(this):this},a.add=function(e){for(var t=Math.max(this.g.length,e.g.length),n=[],r=0,a=0;a<=t;a++){var o=r+(65535&this.i(a))+(65535&e.i(a)),s=(o>>>16)+(this.i(a)>>>16)+(e.i(a)>>>16);r=s>>>16,o&=65535,s&=65535,n[a]=s<<16|o}return new i(n,-0x80000000&n[n.length-1]?-1:0)},a.j=function(e){if(v(this)||v(e))return c;if(y(this))return y(e)?p(this).j(p(e)):p(p(this).j(e));if(y(e))return p(this.j(p(e)));if(0>this.l(d)&&0>e.l(d))return u(this.m()*e.m());for(var t=this.g.length+e.g.length,n=[],r=0;r<2*t;r++)n[r]=0;for(r=0;r<this.g.length;r++)for(var a=0;a<e.g.length;a++){var o=this.i(r)>>>16,s=65535&this.i(r),l=e.i(a)>>>16,h=65535&e.i(a);n[2*r+2*a]+=s*h,g(n,2*r+2*a),n[2*r+2*a+1]+=o*h,g(n,2*r+2*a+1),n[2*r+2*a+1]+=s*l,g(n,2*r+2*a+1),n[2*r+2*a+2]+=o*l,g(n,2*r+2*a+2)}for(r=0;r<t;r++)n[r]=n[2*r+1]<<16|n[2*r];for(r=t;r<2*t;r++)n[r]=0;return new i(n,0)},a.A=function(e){return k(this,e).h},a.and=function(e){for(var t=Math.max(this.g.length,e.g.length),n=[],r=0;r<t;r++)n[r]=this.i(r)&e.i(r);return new i(n,this.h&e.h)},a.or=function(e){for(var t=Math.max(this.g.length,e.g.length),n=[],r=0;r<t;r++)n[r]=this.i(r)|e.i(r);return new i(n,this.h|e.h)},a.xor=function(e){for(var t=Math.max(this.g.length,e.g.length),n=[],r=0;r<t;r++)n[r]=this.i(r)^e.i(r);return new i(n,this.h^e.h)},e.prototype.digest=e.prototype.v,e.prototype.reset=e.prototype.s,e.prototype.update=e.prototype.u,h=tv.Md5=e,i.prototype.add=i.prototype.add,i.prototype.multiply=i.prototype.j,i.prototype.modulo=i.prototype.A,i.prototype.compare=i.prototype.l,i.prototype.toNumber=i.prototype.m,i.prototype.toString=i.prototype.toString,i.prototype.getBits=i.prototype.i,i.fromNumber=u,i.fromString=function e(t,n){if(0==t.length)throw Error("number format error: empty string");if(2>(n=n||10)||36<n)throw Error("radix out of range: "+n);
1if("-"==t.charAt(0))return p(e(t.substring(1),n));if(0<=t.indexOf("-"))throw Error('number format error: interior "-" character');for(var r=u(Math.pow(n,8)),i=c,a=0;a<t.length;a+=8){var o=Math.min(8,t.length-a),s=parseInt(t.substring(a,a+o),n);8>o?(o=u(Math.pow(n,o)),i=i.j(o).add(u(s))):i=(i=i.j(r)).add(u(s))}return i},l=tv.Integer=i}).apply(void 0!==td?td:"u">typeof self?self:"u">typeof window?window:{});var ty="u">typeof globalThis?globalThis:"u">typeof window?window:e.g,tp={};(function(){var e,t,n,r="function"==typeof Object.defineProperties?Object.defineProperty:function(e,t,n){return e==Array.prototype||e==Object.prototype||(e[t]=n.value),e},i=function(e){e=["object"==("u"<typeof globalThis?"undefined":(0,G._)(globalThis))&&globalThis,e,"object"==("u"<typeof window?"undefined":(0,G._)(window))&&window,"object"==("u"<typeof self?"undefined":(0,G._)(self))&&self,"object"==(void 0===ty?"undefined":(0,G._)(ty))&&ty];for(var t=0;t<e.length;++t){var n=e[t];if(n&&n.Math==Math)return n}throw Error("Cannot find global object")}(this);!function(e,t){if(t)e:{var n=i;e=e.split(".");for(var a=0;a<e.length-1;a++){var o=e[a];if(!(o in n))break e;n=n[o]}(t=t(a=n[e=e[e.length-1]]))!=a&&null!=t&&r(n,e,{configurable:!0,writable:!0,value:t})}}("Array.prototype.values",function(e){return e||function(){var e,t,n,r,i;return e=this,t=function(e,t){return t},(0,K._)(e,String)&&(e+=""),n=0,r=!1,(i={next:function(){if(!r&&n<e.length){var i=n++;return{value:t(i,e[i]),done:!1}}return r=!0,{done:!0,value:void 0}}})[Symbol.iterator]=function(){return i},i}});var a=a||{},o=this||self;function s(e){var t=void 0===e?"undefined":(0,G._)(e);return"array"==(t="object"!=t?t:e?Array.isArray(e)?"array":t:"null")||"object"==t&&"number"==typeof e.length}function u(e){var t=void 0===e?"undefined":(0,G._)(e);return"object"==t&&null!=e||"function"==t}function c(e,t,n){return e.call.apply(e.bind,arguments)}function l(e,t,n){if(!e)throw Error();if(2<arguments.length){var r=Array.prototype.slice.call(arguments,2);return function(){var n=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(n,r),e.apply(t,n)}}return function(){return e.apply(t,arguments)}}function h(e,t,n){return(h=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?c:l).apply(null,arguments)}function k(e,t){var n=Array.prototype.slice.call(arguments,1);return function(){var t=n.slice();return t.push.apply(t,arguments),e.apply(this,t)}}function b(e,t){function n(){}n.prototype=t.prototype,e.aa=t.prototype,e.prototype=new n,e.prototype.constructor=e,e.Qb=function(e,n,r){for(var i=Array(arguments.length-2),a=2;a<arguments.length;a++)i[a-2]=arguments[a];return t.prototype[n].apply(e,i)}}function w(e){var t=e.length;if(0<t){for(var n=Array(t),r=0;r<t;r++)n[r]=e[r];return n}return[]}function I(e,t){for(var n=1;n<arguments.length;n++){var r=arguments[n];if(s(r)){var i=e.length||0,a=r.length||0;e.length=i+a;for(var o=0;o<a;o++)e[i+o]=r[o]}else e.push(r)}}var T=function(){function e(t,n){(0,O._)(this,e),this.i=t,this.j=n,this.h=0,this.g=null}return(0,P._)(e,[{key:"get",value:function(){var e;return 0<this.h?(this.h--,e=this.g,this.g=e.next,e.next=null):e=this.i(),e}}]),e}();function E(e){return/^[\s\xa0]*$/.test(e)}function S(){var e=o.navigator;return e&&(e=e.userAgent)?e:""}function C(e){return C[" "](e),e}C[" "]=function(){};var x=-1!=S().indexOf("Gecko")&&(-1==S().toLowerCase().indexOf("webkit")||-1!=S().indexOf("Edge"))&&-1==S().indexOf("Trident")&&-1==S().indexOf("MSIE")&&-1==S().indexOf("Edge");function A(e,t,n){for(var r in e)t.call(n,e[r],r,e)}function R(e){var t={};for(var n in e)t[n]=e[n];return t}var N="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function L(e,t){for(var n,r,i=1;i<arguments.length;i++){for(n in r=arguments[i])e[n]=r[n];for(var a=0;a<N.length;a++)n=N[a],Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}}var M,U=function(){function e(){(0,O._)(this,e),this.h=this.g=null}return(0,P._)(e,[{key:"add",value:function(e,t){var n=F.get();n.set(e,t),this.h?this.h.next=n:this.g=n,this.h=n}}]),e}(),F=new T(function(){return new B},function(e){return e.reset()}),B=function(){function e(){(0,O._)(this,e),this.next=this.g=this.h=null}return(0,P._)(e,[{key:"set",value:function(e,t){this.h=e,this.g=t,this.next=null}},{key:"reset",value:function(){this.next=this.g=this.h=null}}]),e}(),H=!1,W=new U,Q=function(){var e=o.Promise.resolve(void 0);M=function(){e.then(J)}},J=function(){for(var e,t;e=null,W.g&&(e=W.g,W.g=W.g.next,W.g||(W.h=null),e.next=null),t=e;){try{t.h.call(t.g)}catch(e){!function(e){o.setTimeout(function(){throw e},0)}(e)}F.j(t),100>F.h&&(F.h++,t.next=F.g,F.g=t)}H=!1};function X(){this.s=this.s,this.C=this.C}function Y(e,t){this.type=e,this.g=this.target=t,this.defaultPrevented=!1}X.prototype.s=!1,X.prototype.ma=function(){this.s||(this.s=!0,this.N())},X.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()},Y.prototype.h=function(){this.defaultPrevented=!0};var $=function(){if(!o.addEventListener||!Object.defineProperty)return!1;var e=!1,t=Object.defineProperty({},"passive",{get:function(){e=!0}});try{var n=function(){};o.addEventListener("test",n,t),o.removeEventListener("test",n,t)}catch(e){}return e}();function Z(e,t){if(Y.call(this,e?e.type:""),this.relatedTarget=this.g=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.state=null,this.pointerId=0,this.pointerType="",this.i=null,e){var n=this.type=e.type,r=e.changedTouches&&e.changedTouches.length?e.changedTouches[0]:null;if(this.target=e.target||e.srcElement,this.g=t,t=e.relatedTarget){if(x){e:{try{C(t.nodeName);var i=!0;break e}catch(e){}i=!1}i||(t=null)}}
vendor: 1,851 bytes, line 1
1else"mouseover"==n?t=e.fromElement:"mouseout"==n&&(t=e.toElement);this.relatedTarget=t,r?(this.clientX=void 0!==r.clientX?r.clientX:r.pageX,this.clientY=void 0!==r.clientY?r.clientY:r.pageY,this.screenX=r.screenX||0,this.screenY=r.screenY||0):(this.clientX=void 0!==e.clientX?e.clientX:e.pageX,this.clientY=void 0!==e.clientY?e.clientY:e.pageY,this.screenX=e.screenX||0,this.screenY=e.screenY||0),this.button=e.button,this.key=e.key||"",this.ctrlKey=e.ctrlKey,this.altKey=e.altKey,this.shiftKey=e.shiftKey,this.metaKey=e.metaKey,this.pointerId=e.pointerId||0,this.pointerType="string"==typeof e.pointerType?e.pointerType:ee[e.pointerType]||"",this.state=e.state,this.i=e,e.defaultPrevented&&Z.aa.h.call(this)}}b(Z,Y);var ee={2:"touch",3:"pen",4:"mouse"};Z.prototype.h=function(){Z.aa.h.call(this);var e=this.i;e.preventDefault?e.preventDefault():e.returnValue=!1};var et="closure_listenable_"+(1e6*Math.random()|0),en=0;function er(e,t,n,r,i){this.listener=e,this.proxy=null,this.src=t,this.type=n,this.capture=!!r,this.ha=i,this.key=++en,this.da=this.fa=!1}function ei(e){e.da=!0,e.listener=null,e.proxy=null,e.src=null,e.ha=null}function ea(e){this.src=e,this.g={},this.h=0}function eo(e,t){var n=t.type;if(n in e.g){var r,i=e.g[n],a=Array.prototype.indexOf.call(i,t,void 0);(r=0<=a)&&Array.prototype.splice.call(i,a,1),r&&(ei(t),0==e.g[n].length&&(delete e.g[n],e.h--))}}function es(e,t,n,r){for(var i=0;i<e.length;++i){var a=e[i];if(!a.da&&a.listener==t&&!!n==a.capture&&a.ha==r)return i}return -1}ea.prototype.add=function(e,t,n,r,i){var a=e.toString();(e=this.g[a])||(e=this.g[a]=[],this.h++);var o=es(e,t,r,i);return -1<o?(t=e[o],n||(t.fa=!1)):((t=new er(t,this.src,a,!!r,i)).fa=n,e.push(t)),t};var eu="closure_lm_"+(1e6*Math.random()|0),ec={};function el(e,t,n,r,i,a){if(!t)throw Error("Invalid event type");var o=u(i)?!!i.capture:!!i,s=ev(e);
1if(s||(e[eu]=s=new ea(e)),(n=s.add(t,n,r,o,a)).proxy)return n;if(r=function e(t){return ed.call(e.src,e.listener,t)},n.proxy=r,r.src=e,r.listener=n,e.addEventListener)$||(i=o),void 0===i&&(i=!1),e.addEventListener(t.toString(),r,i);else if(e.attachEvent)e.attachEvent(ef(t.toString()),r);else if(e.addListener&&e.removeListener)e.addListener(r);else throw Error("addEventListener and attachEvent are unavailable.");return n}function eh(e){if("number"!=typeof e&&e&&!e.da){var t=e.src;if(t&&t[et])eo(t.i,e);else{var n=e.type,r=e.proxy;t.removeEventListener?t.removeEventListener(n,r,e.capture):t.detachEvent?t.detachEvent(ef(n),r):t.addListener&&t.removeListener&&t.removeListener(r),(n=ev(t))?(eo(n,e),0==n.h&&(n.src=null,t[eu]=null)):ei(e)}}}function ef(e){return e in ec?ec[e]:ec[e]="on"+e}function ed(e,t){if(e.da)e=!0;else{t=new Z(t,this);var n=e.listener,r=e.ha||e.src;e.fa&&eh(e),e=n.call(r,t)}return e}function ev(e){return e=e[eu],(0,K._)(e,ea)?e:null}var ey="__closure_events_fn_"+(1e9*Math.random()>>>0);function ep(e){return"function"==typeof e?e:(e[ey]||(e[ey]=function(t){return e.handleEvent(t)}),e[ey])}function em(){X.call(this),this.i=new ea(this),this.M=this,this.F=null}function eg(e,t){var n,r=e.F;if(r)for(n=[];r;r=r.F)n.push(r);if(e=e.M,r=t.type||t,"string"==typeof t)t=new Y(t,e);else if((0,K._)(t,Y))t.target=t.target||e;else{var i=t;L(t=new Y(r,e),i)}if(i=!0,n)for(var a=n.length-1;0<=a;a--){var o=t.g=n[a];i=e_(o,r,!0,t)&&i}if(i=e_(o=t.g=e,r,!0,t)&&i,i=e_(o,r,!1,t)&&i,n)for(a=0;a<n.length;a++)i=e_(o=t.g=n[a],r,!1,t)&&i}function e_(e,t,n,r){if(!(t=e.i.g[String(t)]))return!0;t=t.concat();for(var i=!0,a=0;a<t.length;++a){var o=t[a];if(o&&!o.da&&o.capture==n){var s=o.listener,u=o.ha||o.src;o.fa&&eo(e.i,o),i=!1!==s.call(u,r)&&i}}return i&&!r.defaultPrevented}function ek(e,t,n){if("function"==typeof e)n&&(e=h(e,n));else if(e&&"function"==typeof e.handleEvent)e=h(e.handleEvent,e);else throw Error("Invalid listener argument");return 0x7fffffff<Number(t)?-1:o.setTimeout(e,t||0)}b(em,X),em.prototype[et]=!0,em.prototype.removeEventListener=function(e,t,n,r){!function e(t,n,r,i,a){if(Array.isArray(n))for(var o=0;o<n.length;o++)e(t,n[o],r,i,a);else(i=u(i)?!!i.capture:!!i,r=ep(r),t&&t[et])?(t=t.i,(n=String(n).toString())in t.g&&-1<(r=es(o=t.g[n],r,i,a))&&(ei(o[r]),Array.prototype.splice.call(o,r,1),0==o.length&&(delete t.g[n],t.h--))):t&&(t=ev(t))&&(n=t.g[n.toString()],t=-1,n&&(t=es(n,r,i,a)),(r=-1<t?n[t]:null)&&eh(r))}(this,e,t,n,r)},em.prototype.N=function(){if(em.aa.N.call(this),this.i){var e,t=this.i;for(e in t.g){for(var n=t.g[e],r=0;r<n.length;r++)ei(n[r]);delete t.g[e],t.h--}}this.F=null},em.prototype.K=function(e,t,n,r){return this.i.add(String(e),t,!1,n,r)},em.prototype.L=function(e,t,n,r){return this.i.add(String(e),t,!0,n,r)};var eb=function(e){function t(e,n){var r;return(0,O._)(this,t),(r=(0,V._)(this,t)).m=e,r.l=n,r.h=null,r.i=!1,r.g=null,r}return(0,z._)(t,e),(0,P._)(t,[{key:"j",value:function(e){this.h=arguments,this.g?this.i=!0:function e(t){t.g=ek(function(){t.g=null,t.i&&(t.i=!1,e(t))},t.l);var n=t.h;t.h=null,t.m.apply(null,n)}(this)}},{key:"N",value:function(){(0,j._)((0,q._)(t.prototype),"N",this).call(this),this.g&&(o.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}]),t}(X);function ew(e){X.call(this),this.h=e,this.g={}}b(ew,X);var eI=[];function eT(e){A(e.g,function(e,t){this.g.hasOwnProperty(t)&&eh(e)},e),e.g={}}ew.prototype.N=function(){ew.aa.N.call(this),eT(this)},ew.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var eE=o.JSON.stringify,eS=o.JSON.parse,eC=function(){function e(){(0,O._)(this,e)}return(0,P._)(e,[{key:"stringify",value:function(e){return o.JSON.stringify(e,void 0)}},{key:"parse",value:function(e){return o.JSON.parse(e,void 0)}}]),e}();function ex(){}function eA(e){return e.h||(e.h=e.i())}function eD(){}ex.prototype.h=null;var eR={OPEN:"a",kb:"b",Ja:"c",wb:"d"};function eN(){Y.call(this,"d")}function eO(){Y.call(this,"c")}b(eN,Y),b(eO,Y);var eP={},eL=null;function eM(){return eL=eL||new em}function eU(e){Y.call(this,eP.La,e)}function eF(e){var t=eM();eg(t,new eU(t))}function eV(e,t){Y.call(this,eP.STAT_EVENT,e),this.stat=t}function eB(e){var t=eM();eg(t,new eV(t,e))}function ej(e,t){Y.call(this,eP.Ma,e),this.size=t}function eq(e,t){if("function"!=typeof e)throw Error("Fn must not be null and must be a function");return o.setTimeout(function(){e()},t)}function ez(){this.g=!0}function eK(e,t,n,r){e.info(function(){return"XMLHTTP TEXT ("+t+"): "+function(e,t){if(!e.g)return t;if(!t)return null;try{var n=JSON.parse(t);if(n){for(e=0;e<n.length;e++)if(Array.isArray(n[e])){var r=n[e];if(!(2>r.length)){var i=r[1];if(Array.isArray(i)&&!(1>i.length)){var a=i[0];if("noop"!=a&&"stop"!=a&&"close"!=a)for(var o=1;o<i.length;o++)i[o]=""}}}}return eE(n)}catch(e){return t}}(e,n)+(r?" "+r:"")})}eP.La="serverreachability",b(eU,Y),eP.STAT_EVENT="statevent",b(eV,Y),eP.Ma="timingevent",b(ej,Y),ez.prototype.xa=function(){this.g=!1},ez.prototype.info=function(){};var eG={NO_ERROR:0,gb:1,tb:2,sb:3,nb:4,rb:5,ub:6,Ia:7,TIMEOUT:8,xb:9},eH={lb:"complete",Hb:"success",Ja:"error",Ia:"abort",zb:"ready",Ab:"readystatechange",TIMEOUT:"timeout",vb:"incrementaldata",yb:"progress",ob:"downloadprogress",Pb:"uploadprogress"};function eW(){}function eQ(e,t,n,r){this.j=e,this.i=t,this.l=n,this.R=r||1,this.U=new ew(this),this.I=45e3,this.H=null,this.o=!1,this.m=this.A=this.v=this.L=this.F=this.S=this.B=null,this.D=[],this.g=null,this.C=0,this.s=this.u=null,this.X=-1,this.J=!1,this.O=0,this.M=null,this.W=this.K=this.T=this.P=!1,this.h=new eJ}function eJ(){this.i=null,this.g="",this.h=!1}b(eW,ex),eW.prototype.g=function(){return new XMLHttpRequest},eW.prototype.i=function(){return{}},t=new eW;var eX={},eY={};function e$(e,t,n){e.L=1,e.v=td(tu(t)),e.m=n,e.P=!0,eZ(e,null)}function eZ(e,t){e.F=Date.now(),e1(e),e.A=tu(e.v);var n,r,i,a,o,s,c=e.A,l=e.R;Array.isArray(l)||(l=[String(l)]),tx(c.i,"t",l),e.C=0,c=e.j.J,e.h=new eJ,e.g=ni(e.j,c?t:null,!e.m),
10<e.O&&(e.M=new eb(h(e.Y,e,e.g),e.O)),t=e.U,c=e.g,l=e.ca;var f="readystatechange";Array.isArray(f)||(f&&(eI[0]=f.toString()),f=eI);for(var d=0;d<f.length;d++){var v=function e(t,n,r,i,a){if(i&&i.once)return function e(t,n,r,i,a){if(Array.isArray(n)){for(var o=0;o<n.length;o++)e(t,n[o],r,i,a);return null}return r=ep(r),t&&t[et]?t.L(n,r,u(i)?!!i.capture:!!i,a):el(t,n,r,!0,i,a)}(t,n,r,i,a);if(Array.isArray(n)){for(var o=0;o<n.length;o++)e(t,n[o],r,i,a);return null}return r=ep(r),t&&t[et]?t.K(n,r,u(i)?!!i.capture:!!i,a):el(t,n,r,!1,i,a)}(c,f[d],l||t.handleEvent,!1,t.h||t);if(!v)break;t.g[v.key]=v}t=e.H?R(e.H):{},e.m?(e.u||(e.u="POST"),t["Content-Type"]="application/x-www-form-urlencoded",e.g.ea(e.A,e.u,e.m,t)):(e.u="GET",e.g.ea(e.A,e.u,null,t)),eF(),n=e.i,r=e.u,i=e.A,a=e.l,o=e.R,s=e.m,n.info(function(){if(n.g)if(s)for(var e="",t=s.split("&"),u=0;u<t.length;u++){var c=t[u].split("=");if(1<c.length){var l=c[0];c=c[1];var h=l.split("_");e=2<=h.length&&"type"==h[1]?e+(l+"=")+c+"&":e+(l+"=redacted&")}}else e=null;else e=s;return"XMLHTTP REQ ("+a+") [attempt "+o+"]: "+r+"\n"+i+"\n"+e})}function e0(e){return!!e.g&&"GET"==e.u&&2!=e.L&&e.j.Ca}function e1(e){e.S=Date.now()+e.I,e2(e,e.I)}function e2(e,t){if(null!=e.B)throw Error("WatchDog timer not null");e.B=eq(h(e.ba,e),t)}function e3(e){e.B&&(o.clearTimeout(e.B),e.B=null)}function e4(e){0==e.j.G||e.J||t9(e.j,e)}function e5(e){e3(e);var t=e.M;t&&"function"==typeof t.ma&&t.ma(),e.M=null,eT(e.U),e.g&&(t=e.g,e.g=null,t.abort(),t.ma())}function e6(e,t){try{var n=e.j;if(0!=n.G&&(n.g==e||tt(n.h,e))){if(!e.K&&tt(n.h,e)&&3==n.G){try{var r=n.Da.g.parse(t)}catch(e){r=null}if(Array.isArray(r)&&3==r.length){var i=r;if(0==i[0]){e:if(!n.u){if(n.g)if(n.g.F+3e3<e.F)t7(n),t$(n);else break e;t5(n),eB(18)}}else n.za=i[1],0<n.za-n.T&&37500>i[2]&&n.F&&0==n.v&&!n.C&&(n.C=eq(h(n.Za,n),6e3));if(1>=te(n.h)&&n.ca){try{n.ca()}catch(e){}n.ca=void 0}}else nt(n,11)}else if((e.K||n.g==e)&&t7(n),!E(t))for(i=n.Da.g.parse(t),t=0;t<i.length;t++){var a=i[t];if(n.T=a[0],a=a[1],2==n.G)if("c"==a[0]){n.K=a[1],n.ia=a[2];var o=a[3];null!=o&&(n.la=o,n.j.info("VER="+n.la));var s=a[4];null!=s&&(n.Aa=s,n.j.info("SVER="+n.Aa));var u=a[5];null!=u&&"number"==typeof u&&0<u&&(n.L=r=1.5*u,n.j.info("backChannelRequestTimeoutMs_="+r)),r=n;var c=e.g;if(c){var l=c.g?c.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(l){var f=r.h;f.g||-1==l.indexOf("spdy")&&-1==l.indexOf("quic")&&-1==l.indexOf("h2")||(f.j=f.l,f.g=new Set,f.h&&(tn(f,f.h),f.h=null))}if(r.D){var d=c.g?c.g.getResponseHeader("X-HTTP-Session-Id"):null;d&&(r.ya=d,tf(r.I,r.D,d))}}if(n.G=3,n.l&&n.l.ua(),n.ba&&(n.R=Date.now()-e.F,n.j.info("Handshake RTT: "+n.R+"ms")),(r=n).qa=nr(r,r.J?r.ia:null,r.W),e.K){tr(r.h,e);var v=r.L;v&&(e.I=v),e.B&&(e3(e),e1(e)),r.g=e}else t4(r);0<n.i.length&&t0(n)}else"stop"!=a[0]&&"close"!=a[0]||nt(n,7);else 3==n.G&&("stop"==a[0]||"close"==a[0]?"stop"==a[0]?nt(n,7):tY(n):"noop"!=a[0]&&n.l&&n.l.ta(a),n.v=0)}}eF(4)}catch(e){}}eQ.prototype.ca=function(e){e=e.target;var t=this.M;t&&3==tW(e)?t.j():this.Y(e)},eQ.prototype.Y=function(e){try{if(e==this.g)e:{var t=tW(this.g),n=this.g.Ba(),r=this.g.Z();if(!(3>t)&&(3!=t||this.g&&(this.h.h||this.g.oa()||tQ(this.g)))){this.J||4!=t||7==n||(8==n||0>=r?eF(3):eF(2)),e3(this);var i=this.g.Z();this.X=i;t:if(e0(this)){var a=tQ(this.g);e="";var s=a.length,u=4==tW(this.g);if(!this.h.i){if("u"<typeof TextDecoder){e5(this),e4(this);var c="";break t}this.h.i=new o.TextDecoder}for(n=0;n<s;n++)this.h.h=!0,e+=this.h.i.decode(a[n],{stream:!(u&&n==s-1)});a.length=0,this.h.g+=e,this.C=0,c=this.h.g}else c=this.g.oa();if(this.o=200==i,l=this.i,h=this.u,f=this.A,d=this.l,v=this.R,y=i,l.info(function(){return"XMLHTTP RESP ("+d+") [ attempt "+v+"]: "+h+"\n"+f+"\n"+t+" "+y}),this.o){if(this.T&&!this.K){t:{if(this.g){var l,h,f,d,v,y,p,m=this.g;if((p=m.g?m.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!E(p)){var g=p;break t}}g=null}if(i=g)eK(this.i,this.l,i,"Initial handshake response via X-HTTP-Initial-Response"),this.K=!0,e6(this,i);else{this.o=!1,this.s=3,eB(12),e5(this),e4(this);break e}}if(this.P){for(i=!0;!this.J&&this.C<c.length;)if((_=function(e,t){var n=e.C,r=t.indexOf("\n",n);return -1==r?eY:isNaN(n=Number(t.substring(n,r)))?eX:(r+=1)+n>t.length?eY:(t=t.slice(r,r+n),e.C=r+n,t)}(this,c))==eY){4==t&&(this.s=4,eB(14),i=!1),eK(this.i,this.l,null,"[Incomplete Response]");break}else if(_==eX){this.s=4,eB(15),eK(this.i,this.l,c,"[Invalid Chunk]"),i=!1;break}else eK(this.i,this.l,_,null),e6(this,_);if(e0(this)&&0!=this.C&&(this.h.g=this.h.g.slice(this.C),this.C=0),4!=t||0!=c.length||this.h.h||(this.s=1,eB(16),i=!1),this.o=this.o&&i,i){if(0<c.length&&!this.W){this.W=!0;var _,k=this.j;k.g==this&&k.ba&&!k.M&&(k.j.info("Great, no buffering proxy detected. Bytes received: "+c.length),t6(k),k.M=!0,eB(11))}}else eK(this.i,this.l,c,"[Invalid Chunked Response]"),e5(this),e4(this)}else eK(this.i,this.l,c,null),e6(this,c);4==t&&e5(this),this.o&&!this.J&&(4==t?t9(this.j,this):(this.o=!1,e1(this)))}else(function(e){var t={};e=(e.g&&2<=tW(e)&&e.g.getAllResponseHeaders()||"").split("\r\n");for(var n=0;n<e.length;n++)if(!E(e[n])){var r=function(e){var t=1;e=e.split(":");for(var n=[];0<t&&e.length;)n.push(e.shift()),t--;return e.length&&n.push(e.join(":")),n}(e[n]),i=r[0];if("string"==typeof(r=r[1])){r=r.trim();var a=t[i]||[];t[i]=a,a.push(r)}}var o=function(e){return e.join(", ")};for(var s in t)o.call(void 0,t[s],s,t)})(this.g),400==i&&0<c.indexOf("Unknown SID")?(this.s=3,eB(12)):(this.s=0,eB(13)),e5(this),e4(this)}}}catch(e){}finally{}},eQ.prototype.cancel=function(){this.J=!0,e5(this)},eQ.prototype.ba=function(){this.B=null;var e,t,n=Date.now();0<=n-this.S?(e=this.i,t=this.A,e.info(function(){return"TIMEOUT: "+t}),2!=this.L&&(eF(),eB(17)),e5(this),this.s=2,e4(this)):e2(this,this.S-n)};var e8=function e(t,n){(0,O._)(this,e),this.g=t,this.map=n};function e7(e){this.l=e||10,e=o.PerformanceNavigationTiming?0<(e=o.performance.getEntriesByType("navigation")).length&&("hq"==e[0].nextHopProtocol||"h2"==e[0].nextHopProtocol):!!(o.chrome&&o.chrome.loadTimes&&o.chrome.loadTimes()&&o.chrome.loadTimes().wasFetchedViaSpdy),this.j=e?this.l:1,this.g=null,1<this.j&&(this.g=new Set),this.h=null,this.i=[]}function e9(e){return!!e.h||!!e.g&&e.g.size>=e.j}function te(e){return e.h?1:e.g?e.g.size:0}function tt(e,t){return e.h?e.h==t:!!e.g&&e.g.has(t)}function tn(e,t){e.g?e.g.add(t):e.h=t}function tr(e,t){e.h&&e.h==t?e.h=null:e.g&&e.g.has(t)&&e.g.delete(t)}function ti(e){if(null!=e.h)return e.i.concat(e.h.D);if(null!=e.g&&0!==e.g.size){var t=e.i,n=!0,r=!1,i=void 0;try{for(var a,o=e.g.values()[Symbol.iterator]();!(n=(a=o.next()).done);
1n=!0){var s=a.value;t=t.concat(s.D)}}catch(e){r=!0,i=e}finally{try{n||null==o.return||o.return()}finally{if(r)throw i}}return t}return w(e.i)}function ta(e,t){if(e.forEach&&"function"==typeof e.forEach)e.forEach(t,void 0);else if(s(e)||"string"==typeof e)Array.prototype.forEach.call(e,t,void 0);else for(var n=function(e){if(e.na&&"function"==typeof e.na)return e.na();if(!e.V||"function"!=typeof e.V){if("u">typeof Map&&(0,K._)(e,Map))return Array.from(e.keys());if(!("u">typeof Set&&(0,K._)(e,Set))){if(s(e)||"string"==typeof e){var t=[];e=e.length;for(var n=0;n<e;n++)t.push(n);return t}for(var r in t=[],n=0,e)t[n++]=r;return t}}}(e),r=function(e){if(e.V&&"function"==typeof e.V)return e.V();if("u">typeof Map&&(0,K._)(e,Map)||"u">typeof Set&&(0,K._)(e,Set))return Array.from(e.values());if("string"==typeof e)return e.split("");if(s(e)){for(var t=[],n=e.length,r=0;r<n;r++)t.push(e[r]);return t}for(r in t=[],n=0,e)t[n++]=e[r];return t}(e),i=r.length,a=0;a<i;a++)t.call(void 0,r[a],n&&n[a],e)}e7.prototype.cancel=function(){if(this.i=ti(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&0!==this.g.size){var e=!0,t=!1,n=void 0;try{for(var r,i=this.g.values()[Symbol.iterator]();!(e=(r=i.next()).done);e=!0)r.value.cancel()}catch(e){t=!0,n=e}finally{try{e||null==i.return||i.return()}finally{if(t)throw n}}this.g.clear()}};var to=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function ts(e){if(this.g=this.o=this.j="",this.s=null,this.m=this.l="",this.h=!1,(0,K._)(e,ts)){this.h=e.h,tc(this,e.j),this.o=e.o,this.g=e.g,tl(this,e.s),this.l=e.l;var t=e.i,n=new tT;n.i=t.i,t.g&&(n.g=new Map(t.g),n.h=t.h),th(this,n),this.m=e.m}else e&&(t=String(e).match(to))?(this.h=!1,tc(this,t[1]||"",!0),this.o=tv(t[2]||""),this.g=tv(t[3]||"",!0),tl(this,t[4]),this.l=tv(t[5]||"",!0),th(this,t[6]||"",!0),this.m=tv(t[7]||"")):(this.h=!1,this.i=new tT(null,this.h))}function tu(e){return new ts(e)}function tc(e,t,n){e.j=n?tv(t,!0):t,e.j&&(e.j=e.j.replace(/:$/,""))}function tl(e,t){if(t){if(isNaN(t=Number(t))||0>t)throw Error("Bad port number "+t);e.s=t}else e.s=null}function th(e,t,n){var r,i;(0,K._)(t,tT)?(e.i=t,r=e.i,(i=e.h)&&!r.j&&(tE(r),r.i=null,r.g.forEach(function(e,t){var n=t.toLowerCase();t!=n&&(tS(this,t),tx(this,n,e))},r)),r.j=i):(n||(t=tm(t,tw)),e.i=new tT(t,e.h))}function tf(e,t,n){e.i.set(t,n)}function td(e){return tf(e,"zx",Math.floor(0x80000000*Math.random()).toString(36)+Math.abs(Math.floor(0x80000000*Math.random())^Date.now()).toString(36)),e}function tv(e,t){return e?t?decodeURI(e.replace(/%25/g,"%2525")):decodeURIComponent(e):""}function tm(e,t,n){return"string"==typeof e?(e=encodeURI(e).replace(t,tg),n&&(e=e.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),e):null}function tg(e){return"%"+((e=e.charCodeAt(0))>>4&15).toString(16)+(15&e).toString(16)}ts.prototype.toString=function(){var e=[],t=this.j;t&&e.push(tm(t,t_,!0),":");var n=this.g;return(n||"file"==t)&&(e.push("//"),(t=this.o)&&e.push(tm(t,t_,!0),"@"),e.push(encodeURIComponent(String(n)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),null!=(n=this.s)&&e.push(":",String(n))),(n=this.l)&&(this.g&&"/"!=n.charAt(0)&&e.push("/"),e.push(tm(n,"/"==n.charAt(0)?tb:tk,!0))),(n=this.i.toString())&&e.push("?",n),(n=this.m)&&e.push("#",tm(n,tI)),e.join("")};var t_=/[#\/\?@]/g,tk=/[#\?:]/g,tb=/[#\?]/g,tw=/[#\?@]/g,tI=/#/g;function tT(e,t){this.h=this.g=null,this.i=e||null,this.j=!!t}function tE(e){e.g||(e.g=new Map,e.h=0,e.i&&function(e,t){if(e){e=e.split("&");for(var n=0;n<e.length;n++){var r=e[n].indexOf("="),i=null;if(0<=r){var a=e[n].substring(0,r);i=e[n].substring(r+1)}else a=e[n];t(a,i?decodeURIComponent(i.replace(/\+/g," ")):"")}}}(e.i,function(t,n){e.add(decodeURIComponent(t.replace(/\+/g," ")),n)}))}function tS(e,t){tE(e),t=tA(e,t),e.g.has(t)&&(e.i=null,e.h-=e.g.get(t).length,e.g.delete(t))}function tC(e,t){return tE(e),t=tA(e,t),e.g.has(t)}function tx(e,t,n){tS(e,t),0<n.length&&(e.i=null,e.g.set(tA(e,t),w(n)),e.h+=n.length)}function tA(e,t){return t=String(t),e.j&&(t=t.toLowerCase()),t}function tD(e,t,n,r,i){try{i&&(i.onload=null,i.onerror=null,i.onabort=null,i.ontimeout=null),r(n)}catch(e){}}function tR(){this.g=new eC}function tN(e){this.l=e.Ub||null,this.j=e.eb||!1}function tO(e,t){em.call(this),this.D=e,this.o=t,this.m=void 0,this.status=this.readyState=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.u=new Headers,this.h=null,this.B="GET",this.A="",this.g=!1,this.v=this.j=this.l=null}function tP(e){e.j.read().then(e.Pa.bind(e)).catch(e.ga.bind(e))}function tL(e){e.readyState=4,e.l=null,e.j=null,e.v=null,tM(e)}function tM(e){e.onreadystatechange&&e.onreadystatechange.call(e)}function tU(e){var t="";return A(e,function(e,n){t+=n,t+=":",t+=e,t+="\r\n"}),t}function tF(e,t,n){e:{for(r in n){var r=!1;break e}r=!0}r||(n=tU(n),"string"==typeof e?null!=n&&encodeURIComponent(String(n)):tf(e,t,n))}function tV(e){em.call(this),this.headers=new Map,this.o=e||null,this.h=!1,this.v=this.g=null,this.D="",this.m=0,this.l="",this.j=this.B=this.u=this.A=!1,this.I=null,this.H="",this.J=!1}(n=tT.prototype).add=function(e,t){tE(this),this.i=null,e=tA(this,e);var n=this.g.get(e);return n||this.g.set(e,n=[]),n.push(t),this.h+=1,this}
1,n.forEach=function(e,t){tE(this),this.g.forEach(function(n,r){n.forEach(function(n){e.call(t,n,r,this)},this)},this)},n.na=function(){tE(this);for(var e=Array.from(this.g.values()),t=Array.from(this.g.keys()),n=[],r=0;r<t.length;r++)for(var i=e[r],a=0;a<i.length;a++)n.push(t[r]);return n},n.V=function(e){tE(this);var t=[];if("string"==typeof e)tC(this,e)&&(t=t.concat(this.g.get(tA(this,e))));else{e=Array.from(this.g.values());for(var n=0;n<e.length;n++)t=t.concat(e[n])}return t},n.set=function(e,t){return tE(this),this.i=null,tC(this,e=tA(this,e))&&(this.h-=this.g.get(e).length),this.g.set(e,[t]),this.h+=1,this},n.get=function(e,t){return e&&0<(e=this.V(e)).length?String(e[0]):t},n.toString=function(){if(this.i)return this.i;if(!this.g)return"";for(var e=[],t=Array.from(this.g.keys()),n=0;n<t.length;n++){var r=t[n],i=encodeURIComponent(String(r)),a=this.V(r);for(r=0;r<a.length;r++){var o=i;""!==a[r]&&(o+="="+encodeURIComponent(String(a[r]))),e.push(o)}}return this.i=e.join("&")},b(tN,ex),tN.prototype.g=function(){return new tO(this.l,this.j)},tN.prototype.i=(e={},function(){return e}),b(tO,em),(n=tO.prototype).open=function(e,t){if(0!=this.readyState)throw this.abort(),Error("Error reopening a connection");this.B=e,this.A=t,this.readyState=1,tM(this)},n.send=function(e){if(1!=this.readyState)throw this.abort(),Error("need to call open() first. ");this.g=!0;var t={headers:this.u,method:this.B,credentials:this.m,cache:void 0};e&&(t.body=e),(this.D||o).fetch(new Request(this.A,t)).then(this.Sa.bind(this),this.ga.bind(this))},n.abort=function(){this.response=this.responseText="",this.u=new Headers,this.status=0,this.j&&this.j.cancel("Request was aborted.").catch(function(){}),1<=this.readyState&&this.g&&4!=this.readyState&&(this.g=!1,tL(this)),this.readyState=0},n.Sa=function(e){if(this.g&&(this.l=e,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=e.headers,this.readyState=2,tM(this)),this.g&&(this.readyState=3,tM(this),this.g)))if("arraybuffer"===this.responseType)e.arrayBuffer().then(this.Qa.bind(this),this.ga.bind(this));else if(void 0!==o.ReadableStream&&"body"in e){if(this.j=e.body.getReader(),this.o){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.v=new TextDecoder;tP(this)}else e.text().then(this.Ra.bind(this),this.ga.bind(this))},n.Pa=function(e){if(this.g){if(this.o&&e.value)this.response.push(e.value);else if(!this.o){var t=e.value?e.value:new Uint8Array(0);(t=this.v.decode(t,{stream:!e.done}))&&(this.response=this.responseText+=t)}e.done?tL(this):tM(this),3==this.readyState&&tP(this)}},n.Ra=function(e){this.g&&(this.response=this.responseText=e,tL(this))},n.Qa=function(e){this.g&&(this.response=e,tL(this))},n.ga=function(){this.g&&tL(this)},n.setRequestHeader=function(e,t){this.u.append(e,t)},n.getResponseHeader=function(e){return this.h&&this.h.get(e.toLowerCase())||""},n.getAllResponseHeaders=function(){if(!this.h)return"";for(var e=[],t=this.h.entries(),n=t.next();!n.done;)e.push((n=n.value)[0]+": "+n[1]),n=t.next();return e.join("\r\n")},Object.defineProperty(tO.prototype,"withCredentials",{get:function(){return"include"===this.m},set:function(e){this.m=e?"include":"same-origin"}}),b(tV,em);var tB=/^https?$/i,tj=["POST","PUT"];function tq(e,t){e.h=!1,e.g&&(e.j=!0,e.g.abort(),e.j=!1),e.l=t,e.m=5,tz(e),tG(e)}function tz(e){e.A||(e.A=!0,eg(e,"complete"),eg(e,"error"))}function tK(e){if(e.h&&void 0!==a&&(!e.v[1]||4!=tW(e)||2!=e.Z())){if(e.u&&4==tW(e))ek(e.Ea,0,e);else if(eg(e,"readystatechange"),4==tW(e)){e.h=!1;try{var t,n,r=e.Z();switch(r){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var i=!0;break;default:i=!1}if(!(t=i)){if(n=0===r){var s=String(e.D).match(to)[1]||null;!s&&o.self&&o.self.location&&(s=o.self.location.protocol.slice(0,-1)),n=!tB.test(s?s.toLowerCase():"")}t=n}if(t)eg(e,"complete"),eg(e,"success");else{e.m=6;try{var u=2<tW(e)?e.g.statusText:""}catch(e){u=""}e.l=u+" ["+e.Z()+"]",tz(e)}}finally{tG(e)}}}}function tG(e,t){if(e.g){tH(e);var n=e.g,r=e.v[0]?function(){}:null;e.g=null,e.v=null,t||eg(e,"ready");try{n.onreadystatechange=r}catch(e){}}}function tH(e){e.I&&(o.clearTimeout(e.I),e.I=null)}function tW(e){return e.g?e.g.readyState:0}function tQ(e){try{if(!e.g)return null;if("response"in e.g)return e.g.response;switch(e.H){case"":case"text":return e.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in e.g)return e.g.mozResponseArrayBuffer}return null}catch(e){return null}}
1function tJ(e,t,n){return n&&n.internalChannelParams&&n.internalChannelParams[e]||t}function tX(e){this.Aa=0,this.i=[],this.j=new ez,this.ia=this.qa=this.I=this.W=this.g=this.ya=this.D=this.H=this.m=this.S=this.o=null,this.Ya=this.U=0,this.Va=tJ("failFast",!1,e),this.F=this.C=this.u=this.s=this.l=null,this.X=!0,this.za=this.T=-1,this.Y=this.v=this.B=0,this.Ta=tJ("baseRetryDelayMs",5e3,e),this.cb=tJ("retryDelaySeedMs",1e4,e),this.Wa=tJ("forwardChannelMaxRetries",2,e),this.wa=tJ("forwardChannelRequestTimeoutMs",2e4,e),this.pa=e&&e.xmlHttpFactory||void 0,this.Xa=e&&e.Tb||void 0,this.Ca=e&&e.useFetchStreams||!1,this.L=void 0,this.J=e&&e.supportsCrossDomainXhr||!1,this.K="",this.h=new e7(e&&e.concurrentRequestLimit),this.Da=new tR,this.P=e&&e.fastHandshake||!1,this.O=e&&e.encodeInitMessageHeaders||!1,this.P&&this.O&&(this.O=!1),this.Ua=e&&e.Rb||!1,e&&e.xa&&this.j.xa(),e&&e.forceLongPolling&&(this.X=!1),this.ba=!this.P&&this.X&&e&&e.detectBufferingProxy||!1,this.ja=void 0,e&&e.longPollingTimeout&&0<e.longPollingTimeout&&(this.ja=e.longPollingTimeout),this.ca=void 0,this.R=0,this.M=!1,this.ka=this.A=null}function tY(e){if(tZ(e),3==e.G){var t=e.U++,n=tu(e.I);if(tf(n,"SID",e.K),tf(n,"RID",t),tf(n,"TYPE","terminate"),t2(e,n),(t=new eQ(e,e.j,t)).L=2,t.v=td(tu(n)),n=!1,o.navigator&&o.navigator.sendBeacon)try{n=o.navigator.sendBeacon(t.v.toString(),"")}catch(e){}!n&&o.Image&&((new Image).src=t.v,n=!0),n||(t.g=ni(t.j,null),t.g.ea(t.v)),t.F=Date.now(),e1(t)}nn(e)}function t$(e){e.g&&(t6(e),e.g.cancel(),e.g=null)}function tZ(e){t$(e),e.u&&(o.clearTimeout(e.u),e.u=null),t7(e),e.h.cancel(),e.s&&("number"==typeof e.s&&o.clearTimeout(e.s),e.s=null)}function t0(e){if(!e9(e.h)&&!e.s){e.s=!0;var t=e.Ga;M||Q(),H||(M(),H=!0),W.add(t,e),e.B=0}}function t1(e,t){var n=t?t.l:e.U++,r=tu(e.I);tf(r,"SID",e.K),tf(r,"RID",n),tf(r,"AID",e.T),t2(e,r),e.m&&e.o&&tF(r,e.m,e.o),n=new eQ(e,e.j,n,e.B+1),null===e.m&&(n.H=e.o),t&&(e.i=t.D.concat(e.i)),t=t3(e,n,1e3),n.I=Math.round(.5*e.wa)+Math.round(.5*e.wa*Math.random()),tn(e.h,n),e$(n,r,t)}function t2(e,t){e.H&&A(e.H,function(e,n){tf(t,n,e)}),e.l&&ta({},function(e,n){tf(t,n,e)})}function t3(e,t,n){n=Math.min(e.i.length,n);for(var r=e.l?h(e.l.Na,e.l,e):null,i=e.i,a=-1;;){var o=["count="+n];-1==a?0<n?(a=i[0].g,o.push("ofs="+a)):a=0:o.push("ofs="+a);for(var s=!0,c=0;c<n;c++){var l=i[c].g,f=i[c].map;if(0>(l-=a))a=Math.max(0,i[c].g-100),s=!1;else try{!function(e,t,n){var r=n||"";try{ta(e,function(e,n){var i=e;u(e)&&(i=eE(e)),t.push(r+n+"="+encodeURIComponent(i))})}catch(e){throw t.push(r+"type="+encodeURIComponent("_badmap")),e}}(f,o,"req"+l+"_")}catch(e){r&&r(f)}}if(s){r=o.join("&");break}}return t.D=e=e.i.splice(0,n),r}function t4(e){if(!e.g&&!e.u){e.Y=1;var t=e.Fa;M||Q(),H||(M(),H=!0),W.add(t,e),e.v=0}}function t5(e){return!e.g&&!e.u&&!(3<=e.v)&&(e.Y++,e.u=eq(h(e.Fa,e),ne(e,e.v)),e.v++,!0)}function t6(e){null!=e.A&&(o.clearTimeout(e.A),e.A=null)}function t8(e){e.g=new eQ(e,e.j,"rpc",e.Y),null===e.m&&(e.g.H=e.o),e.g.O=0;var t=tu(e.qa);tf(t,"RID","rpc"),tf(t,"SID",e.K),tf(t,"AID",e.T),tf(t,"CI",e.F?"0":"1"),!e.F&&e.ja&&tf(t,"TO",e.ja),tf(t,"TYPE","xmlhttp"),t2(e,t),e.m&&e.o&&tF(t,e.m,e.o),e.L&&(e.g.I=e.L);var n=e.g;e=e.ia,n.L=1,n.v=td(tu(t)),n.m=null,n.P=!0,eZ(n,e)}function t7(e){null!=e.C&&(o.clearTimeout(e.C),e.C=null)}function t9(e,t){var n,r=null;if(e.g==t){t7(e),t6(e),e.g=null;var i=2}else{if(!tt(e.h,t))return;r=t.D,tr(e.h,t),i=1}if(0!=e.G){if(t.o)if(1==i){r=t.m?t.m.length:0,t=Date.now()-t.F;var a=e.B;eg(i=eM(),new ej(i,r)),t0(e)}else t4(e);else if(3==(a=t.s)||0==a&&0<t.X||!(1==i&&(n=t,!(te(e.h)>=e.h.j-!!e.s)&&(e.s?(e.i=n.D.concat(e.i),!0):1!=e.G&&2!=e.G&&!(e.B>=(e.Va?0:e.Wa))&&(e.s=eq(h(e.Ga,e,n),ne(e,e.B)),e.B++,!0)))||2==i&&t5(e)))switch(r&&0<r.length&&((t=e.h).i=t.i.concat(r)),a){case 1:nt(e,5);break;case 4:nt(e,10);break;case 3:nt(e,6);break;default:nt(e,2)}}}function ne(e,t){var n=e.Ta+Math.floor(Math.random()*e.cb);return e.isActive()||(n*=2),n*t}function nt(e,t){if(e.j.info("Error code "+t),2==t){var n,r,i,a,s=h(e.fb,e),u=e.Xa,c=!u;u=new ts(u||"//www.google.com/images/cleardot.gif"),o.location&&"http"==o.location.protocol||tc(u,"https"),td(u),c?function(e,t){var n=new ez;if(o.Image){var r=new Image;r.onload=k(tD,n,"TestLoadImage: loaded",!0,t,r),r.onerror=k(tD,n,"TestLoadImage: error",!1,t,r),r.onabort=k(tD,n,"TestLoadImage: abort",!1,t,r),r.ontimeout=k(tD,n,"TestLoadImage: timeout",!1,t,r),o.setTimeout(function(){r.ontimeout&&r.ontimeout()},1e4),r.src=e}else t(!1)}(u.toString(),s):(n=u.toString(),r=new ez,i=new AbortController,a=setTimeout(function(){i.abort(),tD(r,"TestPingServer: timeout",!1,s)},1e4),fetch(n,{signal:i.signal}).then(function(e){clearTimeout(a),e.ok?tD(r,"TestPingServer: ok",!0,s):tD(r,"TestPingServer: server error",!1,s)}).catch(function(){clearTimeout(a),tD(r,"TestPingServer: error",!1,s)}))}else eB(2);e.G=0,e.l&&e.l.sa(t),nn(e),tZ(e)}function nn(e){if(e.G=0,e.ka=[],e.l){var t=ti(e.h);
1(0!=t.length||0!=e.i.length)&&(I(e.ka,t),I(e.ka,e.i),e.h.i.length=0,w(e.i),e.i.length=0),e.l.ra()}}function nr(e,t,n){var r=(0,K._)(n,ts)?tu(n):new ts(n);if(""!=r.g)t&&(r.g=t+"."+r.g),tl(r,r.s);else{var i=o.location;r=i.protocol,t=t?t+"."+i.hostname:i.hostname,i=+i.port;var a=new ts(null);r&&tc(a,r),t&&(a.g=t),i&&tl(a,i),n&&(a.l=n),r=a}return n=e.D,t=e.ya,n&&t&&tf(r,n,t),tf(r,"VER",e.la),t2(e,r),r}function ni(e,t,n){if(t&&!e.J)throw Error("Can't create secondary domain capable XhrIo object.");return(t=new tV(e.Ca&&!e.pa?new tN({eb:n}):e.pa)).Ha(e.J),t}function na(){}function no(){}function ns(e,t){em.call(this),this.g=new tX(t),this.l=e,this.h=t&&t.messageUrlParams||null,e=t&&t.messageHeaders||null,t&&t.clientProtocolHeaderRequired&&(e?e["X-Client-Protocol"]="webchannel":e={"X-Client-Protocol":"webchannel"}),this.g.o=e,e=t&&t.initMessageHeaders||null,t&&t.messageContentType&&(e?e["X-WebChannel-Content-Type"]=t.messageContentType:e={"X-WebChannel-Content-Type":t.messageContentType}),t&&t.va&&(e?e["X-WebChannel-Client-Profile"]=t.va:e={"X-WebChannel-Client-Profile":t.va}),this.g.S=e,(e=t&&t.Sb)&&!E(e)&&(this.g.m=e),this.v=t&&t.supportsCrossDomainXhr||!1,this.u=t&&t.sendRawJson||!1,(t=t&&t.httpSessionIdParam)&&!E(t)&&(this.g.D=t,null!==(e=this.h)&&t in e&&t in(e=this.h)&&delete e[t]),this.j=new nl(this)}function nu(e){eN.call(this),e.__headers__&&(this.headers=e.__headers__,this.statusCode=e.__status__,delete e.__headers__,delete e.__status__);var t=e.__sm__;if(t){e:{for(var n in t){e=n;break e}e=void 0}(this.i=e)&&(e=this.i,t=null!==t&&e in t?t[e]:void 0),this.data=t}else this.data=e}function nc(){eO.call(this),this.status=1}function nl(e){this.g=e}(n=tV.prototype).Ha=function(e){this.J=e},n.ea=function(e,n,r,i){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.D+"; newUri="+e);n=n?n.toUpperCase():"GET",this.D=e,this.l="",this.m=0,this.A=!1,this.h=!0,this.g=this.o?this.o.g():t.g(),this.v=this.o?eA(this.o):eA(t),this.g.onreadystatechange=h(this.Ea,this);try{this.B=!0,this.g.open(n,String(e),!0),this.B=!1}catch(e){tq(this,e);return}e=r||"",r=new Map(this.headers);var a=!0,s=!1,u=void 0;if(i)if(Object.getPrototypeOf(i)===Object.prototype)for(var c in i)r.set(c,i[c]);else if("function"==typeof i.keys&&"function"==typeof i.get)try{for(var l,f=i.keys()[Symbol.iterator]();!(a=(l=f.next()).done);a=!0){var d=l.value;r.set(d,i.get(d))}}catch(e){s=!0,u=e}finally{try{a||null==f.return||f.return()}finally{if(s)throw u}}else throw Error("Unknown input type for opt_headers: "+String(i));i=Array.from(r.keys()).find(function(e){return"content-type"==e.toLowerCase()}),c=o.FormData&&(0,K._)(e,o.FormData),!(0<=Array.prototype.indexOf.call(tj,n,void 0))||i||c||r.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");var v=!0,y=!1,p=void 0;try{for(var m,g=r[Symbol.iterator]();!(v=(m=g.next()).done);v=!0){var _=(0,D._)(m.value,2),k=_[0],b=_[1];this.g.setRequestHeader(k,b)}}catch(e){y=!0,p=e}finally{try{v||null==g.return||g.return()}finally{if(y)throw p}}this.H&&(this.g.responseType=this.H),"withCredentials"in this.g&&this.g.withCredentials!==this.J&&(this.g.withCredentials=this.J);try{tH(this),this.u=!0,this.g.send(e),this.u=!1}catch(e){tq(this,e)}},n.abort=function(e){this.g&&this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1,this.m=e||7,eg(this,"complete"),eg(this,"abort"),tG(this))},n.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),tG(this,!0)),tV.aa.N.call(this)},n.Ea=function(){this.s||(this.B||this.u||this.j?tK(this):this.bb())},n.bb=function(){tK(this)},n.isActive=function(){return!!this.g},n.Z=function(){try{return 2<tW(this)?this.g.status:-1}catch(e){return -1}},n.oa=function(){try{return this.g?this.g.responseText:""}catch(e){return""}},n.Oa=function(e){if(this.g){var t=this.g.responseText;return e&&0==t.indexOf(e)&&(t=t.substring(e.length)),eS(t)}},n.Ba=function(){return this.m},n.Ka=function(){return"string"==typeof this.l?this.l:String(this.l)},(n=tX.prototype).la=8,n.G=1,n.connect=function(e,t,n,r){eB(0),this.W=e,this.H=t||{},n&&void 0!==r&&(this.H.OSID=n,this.H.OAID=r),this.F=this.X,this.I=nr(this,null,this.W),t0(this)},n.Ga=function(e){if(this.s)if(this.s=null,1==this.G){if(!e){this.U=Math.floor(1e5*Math.random()),e=this.U++;var t=new eQ(this,this.j,e),n=this.o;if(this.S&&(n?L(n=R(n),this.S):n=this.S),null!==this.m||this.O||(t.H=n,n=null),this.P)e:{for(var r=0,i=0;i<this.i.length;i++){t:{var a=this.i[i];if("__data__"in a.map&&"string"==typeof(a=a.map.__data__)){a=a.length;break t}a=void 0}if(void 0===a)break;if(4096<(r+=a)){r=i;break e}if(4096===r||i===this.i.length-1){r=i+1;break e}}r=1e3}else r=1e3;
1r=t3(this,t,r),tf(i=tu(this.I),"RID",e),tf(i,"CVER",22),this.D&&tf(i,"X-HTTP-Session-Id",this.D),t2(this,i),n&&(this.O?r="headers="+encodeURIComponent(String(tU(n)))+"&"+r:this.m&&tF(i,this.m,n)),tn(this.h,t),this.Ua&&tf(i,"TYPE","init"),this.P?(tf(i,"$req",r),tf(i,"SID","null"),t.T=!0,e$(t,i,null)):e$(t,i,r),this.G=2}}else 3==this.G&&(e?t1(this,e):0==this.i.length||e9(this.h)||t1(this))},n.Fa=function(){if(this.u=null,t8(this),this.ba&&!(this.M||null==this.g||0>=this.R)){var e=2*this.R;this.j.info("BP detection timer enabled: "+e),this.A=eq(h(this.ab,this),e)}},n.ab=function(){this.A&&(this.A=null,this.j.info("BP detection timeout reached."),this.j.info("Buffering proxy detected and switch to long-polling!"),this.F=!1,this.M=!0,eB(10),t$(this),t8(this))},n.Za=function(){null!=this.C&&(this.C=null,t$(this),t5(this),eB(19))},n.fb=function(e){e?(this.j.info("Successfully pinged google.com"),eB(2)):(this.j.info("Failed to ping google.com"),eB(1))},n.isActive=function(){return!!this.l&&this.l.isActive(this)},(n=na.prototype).ua=function(){},n.ta=function(){},n.sa=function(){},n.ra=function(){},n.isActive=function(){return!0},n.Na=function(){},no.prototype.g=function(e,t){return new ns(e,t)},b(ns,em),ns.prototype.m=function(){this.g.l=this.j,this.v&&(this.g.J=!0),this.g.connect(this.l,this.h||void 0)},ns.prototype.close=function(){tY(this.g)},ns.prototype.o=function(e){var t=this.g;if("string"==typeof e){var n={};n.__data__=e,e=n}else this.u&&((n={}).__data__=eE(e),e=n);t.i.push(new e8(t.Ya++,e)),3==t.G&&t0(t)},ns.prototype.N=function(){this.g.l=null,delete this.j,tY(this.g),delete this.g,ns.aa.N.call(this)},b(nu,eN),b(nc,eO),b(nl,na),nl.prototype.ua=function(){eg(this.g,"a")},nl.prototype.ta=function(e){eg(this.g,new nu(e))},nl.prototype.sa=function(e){eg(this.g,new nc)},nl.prototype.ra=function(){eg(this.g,"b")},no.prototype.createWebChannel=no.prototype.g,ns.prototype.send=ns.prototype.o,ns.prototype.open=ns.prototype.m,ns.prototype.close=ns.prototype.close,_=tp.createWebChannelTransport=function(){return new no},g=tp.getStatEventTarget=function(){return eM()},m=tp.Event=eP,p=tp.Stat={mb:0,pb:1,qb:2,Jb:3,Ob:4,Lb:5,Mb:6,Kb:7,Ib:8,Nb:9,PROXY:10,NOPROXY:11,Gb:12,Cb:13,Db:14,Bb:15,Eb:16,Fb:17,ib:18,hb:19,jb:20},eG.NO_ERROR=0,eG.TIMEOUT=8,eG.HTTP_ERROR=6,y=tp.ErrorCode=eG,eH.COMPLETE="complete",v=tp.EventType=eH,eD.EventType=eR,eR.OPEN="a",eR.CLOSE="b",eR.ERROR="c",eR.MESSAGE="d",em.prototype.listen=em.prototype.K,d=tp.WebChannel=eD,tp.FetchXmlHttpFactory=tN,tV.prototype.listenOnce=tV.prototype.L,tV.prototype.getLastError=tV.prototype.Ka,tV.prototype.getLastErrorCode=tV.prototype.Ba,tV.prototype.getStatus=tV.prototype.Z,tV.prototype.getResponseJson=tV.prototype.Oa,tV.prototype.getResponseText=tV.prototype.oa,tV.prototype.send=tV.prototype.ea,tV.prototype.setWithCredentials=tV.prototype.Ha,f=tp.XhrIo=tV}).apply(void 0!==ty?ty:"u">typeof self?self:"u">typeof window?window:{});var tm="@firebase/firestore",tg=function(){function e(t){(0,O._)(this,e),this.uid=t}return(0,P._)(e,[{key:"isAuthenticated",value:function(){return null!=this.uid}},{key:"toKey",value:function(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}},{key:"isEqual",value:function(e){return e.uid===this.uid}}]),e}();tg.UNAUTHENTICATED=new tg(null),tg.GOOGLE_CREDENTIALS=new tg("google-credentials-uid"),tg.FIRST_PARTY=new tg("first-party-uid"),tg.MOCK_USER=new tg("mock-user");var t_="11.0.2",tk=new eP("@firebase/firestore");function tb(){return tk.logLevel}function tw(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];if(tk.logLevel<=i.DEBUG){var a=n.map(tE);tk.debug.apply(tk,["Firestore (".concat(t_,"): ").concat(e)].concat((0,L._)(a)))}}function tI(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];if(tk.logLevel<=i.ERROR){var a=n.map(tE);tk.error.apply(tk,["Firestore (".concat(t_,"): ").concat(e)].concat((0,L._)(a)))}}function tT(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];if(tk.logLevel<=i.WARN){var a=n.map(tE);
1tk.warn.apply(tk,["Firestore (".concat(t_,"): ").concat(e)].concat((0,L._)(a)))}}function tE(e){if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(t){return e}}function tS(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Unexpected state",t="FIRESTORE (".concat(t_,") INTERNAL ASSERTION FAILED: ")+e;throw tI(t),Error(t)}var tC={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"},tx=function(e){function t(e,n){var r;return(0,O._)(this,t),(r=(0,V._)(this,t,[e,n])).code=e,r.message=n,r.toString=function(){return"".concat(r.name,": [code=").concat(r.code,"]: ").concat(r.message)},r}return(0,z._)(t,e),t}(ev),tA=function e(){var t=this;(0,O._)(this,e),this.promise=new Promise(function(e,n){t.resolve=e,t.reject=n})},tD=function e(t,n){(0,O._)(this,e),this.user=n,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization","Bearer ".concat(t))},tR=function(){function e(){(0,O._)(this,e)}return(0,P._)(e,[{key:"getToken",value:function(){return Promise.resolve(null)}},{key:"invalidateToken",value:function(){}},{key:"start",value:function(e,t){e.enqueueRetryable(function(){return t(tg.UNAUTHENTICATED)})}},{key:"shutdown",value:function(){}}]),e}(),tN=function(){function e(t){(0,O._)(this,e),this.token=t,this.changeListener=null}return(0,P._)(e,[{key:"getToken",value:function(){return Promise.resolve(this.token)}},{key:"invalidateToken",value:function(){}},{key:"start",value:function(e,t){var n=this;this.changeListener=t,e.enqueueRetryable(function(){return t(n.token.user)})}},{key:"shutdown",value:function(){this.changeListener=null}}]),e}(),tO=function(){function e(t){(0,O._)(this,e),this.t=t,this.currentUser=tg.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}return(0,P._)(e,[{key:"start",value:function(e,t){var n=this;void 0===this.o||tS();var r=this.i,i=function(e){return n.i!==r?(r=n.i,t(e)):Promise.resolve()},a=new tA;this.o=function(){n.i++,n.currentUser=n.u(),a.resolve(),a=new tA,e.enqueueRetryable(function(){return i(n.currentUser)})};var o=function(){var t=a;e.enqueueRetryable(function(){return(0,N._)(function(){return(0,M._)(this,function(e){switch(e.label){case 0:return[4,t.promise];case 1:return e.sent(),[4,i(this.currentUser)];case 2:return e.sent(),[2]}})}).call(n)})},s=function(e){tw("FirebaseAuthCredentialsProvider","Auth detected"),n.auth=e,n.o&&(n.auth.addAuthTokenListener(n.o),o())};this.t.onInit(function(e){return s(e)}),setTimeout(function(){if(!n.auth){var e=n.t.getImmediate({optional:!0});e?s(e):(tw("FirebaseAuthCredentialsProvider","Auth not yet detected"),a.resolve(),a=new tA)}},0),o()}},{key:"getToken",value:function(){var e=this,t=this.i,n=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(n).then(function(n){return e.i!==t?(tw("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),e.getToken()):n?("string"==typeof n.accessToken||tS(),new tD(n.accessToken,e.currentUser)):null}):Promise.resolve(null)}},{key:"invalidateToken",value:function(){this.forceRefresh=!0}},{key:"shutdown",value:function(){this.auth&&this.o&&this.auth.removeAuthTokenListener(this.o),this.o=void 0}},{key:"u",value:function(){var e=this.auth&&this.auth.getUid();return null===e||"string"==typeof e||tS(),new tg(e)}}]),e}(),tP=function(){function e(t,n,r){(0,O._)(this,e),this.l=t,this.h=n,this.P=r,this.type="FirstParty",this.user=tg.FIRST_PARTY,this.T=new Map}return(0,P._)(e,[{key:"I",value:function(){return this.P?this.P():null}},{key:"headers",get:function(){this.T.set("X-Goog-AuthUser",this.l);var e=this.I();return e&&this.T.set("Authorization",e),this.h&&this.T.set("X-Goog-Iam-Authorization-Token",this.h),this.T}}]),e}(),tL=function(){function e(t,n,r){(0,O._)(this,e),this.l=t,this.h=n,this.P=r}return(0,P._)(e,[{key:"getToken",value:function(){return Promise.resolve(new tP(this.l,this.h,this.P))}},{key:"start",value:function(e,t){e.enqueueRetryable(function(){return t(tg.FIRST_PARTY)})}},{key:"shutdown",value:function(){}},{key:"invalidateToken",value:function(){}}]),e}(),tM=function e(t){(0,O._)(this,e),this.value=t,this.type="AppCheck",this.headers=new Map,t&&t.length>0&&this.headers.set("x-firebase-appcheck",this.value)},tU=function(){function e(t){(0,O._)(this,e),this.A=t,this.forceRefresh=!1,this.appCheck=null,this.R=null}return(0,P._)(e,[{key:"start",value:function(e,t){var n=this;void 0===this.o||tS();var r=function(e){null!=e.error&&tw("FirebaseAppCheckTokenProvider","Error getting App Check token; using placeholder token instead. Error: ".concat(e.error.message));var r=e.token!==n.R;return n.R=e.token,tw("FirebaseAppCheckTokenProvider","Received ".concat(r?"new":"existing"," token.")),r?t(e.token):Promise.resolve()};this.o=function(t){e.enqueueRetryable(function(){return r(t)})};var i=function(e){tw("FirebaseAppCheckTokenProvider","AppCheck detected"),n.appCheck=e,n.o&&n.appCheck.addTokenListener(n.o)};this.A.onInit(function(e){return i(e)}),setTimeout(function(){if(!n.appCheck){var e=n.A.getImmediate({optional:!0});e?i(e):tw("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}},0)}},{key:"getToken",value:function(){var e=this,t=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(t).then(function(t){return t?("string"==typeof t.token||tS(),e.R=t.token,new tM(t.token)):null}):Promise.resolve(null)}},{key:"invalidateToken",value:function(){this.forceRefresh=!0}},{key:"shutdown",value:function(){this.appCheck&&this.o&&this.appCheck.removeTokenListener(this.o),this.o=void 0}}]),e}();(0,P._)(function e(){(0,O._)(this,e)},[{key:"getToken",value:function(){return Promise.resolve(new tM(""))}},{key:"invalidateToken",value:function(){}},{key:"start",value:function(e,t){}},{key:"shutdown",value:function(){}}]);var tF=function(){function e(){(0,O._)(this,e)}return(0,P._)(e,null,[{key:"newId",value:function(){for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t=Math.floor(256/e.length)*e.length,n="";n.length<20;)for(var r=function(){var e="u">typeof self&&(self.crypto||self.msCrypto),t=new Uint8Array(40);if(e&&"function"==typeof e.getRandomValues)e.getRandomValues(t);else for(var n=0;n<40;
1n++)t[n]=Math.floor(256*Math.random());return t}(),i=0;i<r.length;++i)n.length<20&&r[i]<t&&(n+=e.charAt(r[i]%e.length));return n}}]),e}();function tV(e,t){return e<t?-1:+(e>t)}function tB(e,t,n){return e.length===t.length&&e.every(function(e,r){return n(e,t[r])})}var tj=function(){function e(t,n){if((0,O._)(this,e),this.seconds=t,this.nanoseconds=n,n<0||n>=1e9)throw new tx(tC.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+n);if(t<-0xe7791f700||t>=0x3afff44180)throw new tx(tC.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t)}return(0,P._)(e,[{key:"toDate",value:function(){return new Date(this.toMillis())}},{key:"toMillis",value:function(){return 1e3*this.seconds+this.nanoseconds/1e6}},{key:"_compareTo",value:function(e){return this.seconds===e.seconds?tV(this.nanoseconds,e.nanoseconds):tV(this.seconds,e.seconds)}},{key:"isEqual",value:function(e){return e.seconds===this.seconds&&e.nanoseconds===this.nanoseconds}},{key:"toString",value:function(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}},{key:"toJSON",value:function(){return{seconds:this.seconds,nanoseconds:this.nanoseconds}}},{key:"valueOf",value:function(){return String(this.seconds- -0xe7791f700).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}],[{key:"now",value:function(){return e.fromMillis(Date.now())}},{key:"fromDate",value:function(t){return e.fromMillis(t.getTime())}},{key:"fromMillis",value:function(t){var n=Math.floor(t/1e3),r=Math.floor(1e6*(t-1e3*n));return new e(n,r)}}]),e}(),tq=function(){function e(t){(0,O._)(this,e),this.timestamp=t}return(0,P._)(e,[{key:"compareTo",value:function(e){return this.timestamp._compareTo(e.timestamp)}},{key:"isEqual",value:function(e){return this.timestamp.isEqual(e.timestamp)}},{key:"toMicroseconds",value:function(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}},{key:"toString",value:function(){return"SnapshotVersion("+this.timestamp.toString()+")"}},{key:"toTimestamp",value:function(){return this.timestamp}}],[{key:"fromTimestamp",value:function(t){return new e(t)}},{key:"min",value:function(){return new e(new tj(0,0))}},{key:"max",value:function(){return new e(new tj(0x3afff4417f,0x3b9ac9ff))}}]),e}(),tz=function(){function e(t,n,r){(0,O._)(this,e),void 0===n?n=0:n>t.length&&tS(),void 0===r?r=t.length-n:r>t.length-n&&tS(),this.segments=t,this.offset=n,this.len=r}return(0,P._)(e,[{key:"length",get:function(){return this.len}},{key:"isEqual",value:function(t){return 0===e.comparator(this,t)}},{key:"child",value:function(t){var n=this.segments.slice(this.offset,this.limit());return(0,K._)(t,e)?t.forEach(function(e){n.push(e)}):n.push(t),this.construct(n)}},{key:"limit",value:function(){return this.offset+this.length}},{key:"popFirst",value:function(e){return e=void 0===e?1:e,this.construct(this.segments,this.offset+e,this.length-e)}},{key:"popLast",value:function(){return this.construct(this.segments,this.offset,this.length-1)}},{key:"firstSegment",value:function(){return this.segments[this.offset]}},{key:"lastSegment",value:function(){return this.get(this.length-1)}},{key:"get",value:function(e){return this.segments[this.offset+e]}},{key:"isEmpty",value:function(){return 0===this.length}},{key:"isPrefixOf",value:function(e){if(e.length<this.length)return!1;for(var t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}},{key:"isImmediateParentOf",value:function(e){if(this.length+1!==e.length)return!1;for(var t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}},{key:"forEach",value:function(e){for(var t=this.offset,n=this.limit();t<n;t++)e(this.segments[t])}},{key:"toArray",value:function(){return this.segments.slice(this.offset,this.limit())}}],[{key:"comparator",value:function(e,t){for(var n=Math.min(e.length,t.length),r=0;r<n;r++){var i=e.get(r),a=t.get(r);if(i<a)return -1;if(i>a)return 1}return e.length<t.length?-1:+(e.length>t.length)}}]),e}(),tK=function(e){function t(){return(0,O._)(this,t),(0,V._)(this,t,arguments)}
1return(0,z._)(t,e),(0,P._)(t,[{key:"construct",value:function(e,n,r){return new t(e,n,r)}},{key:"canonicalString",value:function(){return this.toArray().join("/")}},{key:"toString",value:function(){return this.canonicalString()}},{key:"toUriEncodedString",value:function(){return this.toArray().map(encodeURIComponent).join("/")}}],[{key:"fromString",value:function(){for(var e=arguments.length,n=Array(e),r=0;r<e;r++)n[r]=arguments[r];var i=[],a=!0,o=!1,s=void 0;try{for(var u,c=n[Symbol.iterator]();!(a=(u=c.next()).done);a=!0){var l=u.value;if(l.indexOf("//")>=0)throw new tx(tC.INVALID_ARGUMENT,"Invalid segment (".concat(l,"). Paths must not contain // in them."));i.push.apply(i,(0,L._)(l.split("/").filter(function(e){return e.length>0})))}}catch(e){o=!0,s=e}finally{try{a||null==c.return||c.return()}finally{if(o)throw s}}return new t(i)}},{key:"emptyPath",value:function(){return new t([])}}]),t}(tz),tG=/^[_a-zA-Z][_a-zA-Z0-9]*$/,tH=function(e){function t(){return(0,O._)(this,t),(0,V._)(this,t,arguments)}return(0,z._)(t,e),(0,P._)(t,[{key:"c
1onstruct",value:function(e,n,r){return new t(e,n,r)}},{key:"canonicalString",value:function(){return this.toArray().map(function(e){return e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),t.isValidIdentifier(e)||(e="`"+e+"`"),e}).join(".")}},{key:"toString",value:function(){return this.canonicalString()}},{key:"isKeyField",value:function(){return 1===this.length&&"__name__"===this.get(0)}}],[{key:"isValidIdentifier",value:function(e){return tG.test(e)}},{key:"keyField",value:function(){return new t(["__name__"])}},{key:"fromServerFormat",value:function(e){for(var n=[],r="",i=0,a=function(){if(0===r.length)throw new tx(tC.INVALID_ARGUMENT,"Invalid field path (".concat(e,"). Paths must not be empty, begin with '.', end with '.', or contain '..'"));n.push(r),r=""},o=!1;i<e.length;){var s=e[i];if("\\"===s){if(i+1===e.length)throw new tx(tC.INVALID_ARGUMENT,"Path has trailing escape character: "+e);var u=e[i+1];if("\\"!==u&&"."!==u&&"`"!==u)throw new tx(tC.INVALID_ARGUMENT,"Path has invalid escape sequence: "+e);r+=u,i+=2}else"`"===s?o=!o:"."!==s||o?r+=s:a(),i++}if(a(),o)throw new tx(tC.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new t(n)}},{key:"emptyPath",value:function(){return new t([])}}]),t}(tz),tW=function(){function e(t){(0,O._)(this,e),this.path=t}return(0,P._)(e,[{key:"collectionGroup",get:function(){return this.path.popLast().lastSegment()}},{key:"hasCollectionId",value:function(e){return this.path.length>=2&&this.path.get(this.path.length-2)===e}},{key:"getCollectionGroup",value:function(){return this.path.get(this.path.length-2)}},{key:"getCollectionPath",value:function(){return this.path.popLast()}},{key:"isEqual",value:function(e){return null!==e&&0===tK.comparator(this.path,e.path)}},{key:"toString",value:function(){return this.path.toString()}}],[{key:"fromPath",value:function(t){return new e(tK.fromString(t))}},{key:"fromName",value:function(t){return new e(tK.fromString(t).popFirst(5))}},{key:"empty",value:function(){return new e(tK.emptyPath())}},{key:"comparator",value:function(e,t){return tK.comparator(e.path,t.path)}},{key:"isDocumentKey",value:function(e){return e.length%2==0}},{key:"fromSegments",value:function(t){return new e(new tK(t.slice()))}}]),e}(),tQ=function e(t,n,r,i){(0,O._)(this,e),this.indexId=t,this.collectionGroup=n,this.fields=r,this.indexState=i};function tJ(e){return e.fields.find(function(e){return 2===e.kind})}function tX(e){return e.fields.filter(function(e){return 2!==e.kind})}tQ.UNKNOWN_ID=-1;var tY=function e(t,n){(0,O._)(this,e),this.fieldPath=t,this.kind=n},t$=function(){function e(t,n){(0,O._)(this,e),this.sequenceNumber=t,this.offset=n}return(0,P._)(e,null,[{key:"empty",value:function(){return new e(0,t1.min())}}]),e}();function tZ(e,t){var n=e.toTimestamp().seconds,r=e.toTimestamp().nanoseconds+1;return new t1(tq.fromTimestamp(1e9===r?new tj(n+1,0):new tj(n,r)),tW.empty(),t)}function t0(e){return new t1(e.readTime,e.key,-1)}var t1=function(){function e(t,n,r){(0,O._)(this,e),this.readTime=t,this.documentKey=n,this.largestBatchId=r}return(0,P._)(e,null,[{key:"min",value:function(){return new e(tq.min(),tW.empty(),-1)}},{key:"max",value:function(){return new e(tq.max(),tW.empty(),-1)}}]),e}();function t2(e,t){var n=e.readTime.compareTo(t.readTime);return 0!==n||0!==(n=tW.comparator(e.documentKey,t.documentKey))?n:tV(e.largestBatchId,t.largestBatchId)}var t3="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.",t4=function(){function e(){(0,O._)(this,e),this.onCommittedListeners=[]}return(0,P._)(e,[{key:"addOnCommittedListener",value:function(e){this.onCommittedListeners.push(e)}},{key:"raiseOnCommittedEvent",value:function(){this.onCommittedListeners.forEach(function(e){return e()})}}]),e}();function t5(e){return(0,N._)(function(){return(0,M._)(this,function(t){if(e.code!==tC.FAILED_PRECONDITION||e.message!==t3)throw e;return tw("LocalStore","Unexpectedly lost primary lease"),[2]})})()}var t6=function(){function e(t){var n=this;(0,O._)(this,e),this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,t(function(e){n.isDone=!0,n.result=e,n.nextCallback&&n.nextCallback(e)},function(e){n.isDone=!0,n.error=e,n.catchCallback&&n.catchCallback(e)})}return(0,P._)(e,[{key:"catch",value:function(e){return this.next(void 0,e)}},{key:"next",value:function(t,n){var r=this;return this.callbackAttached&&tS(),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(n,this.error):this.wrapSuccess(t,this.result):new e(function(e,i){r.nextCallback=function(n){r.wrapSuccess(t,n).next(e,i)},r.catchCallback=function(t){r.wrapFailure(n,t).next(e,i)}})}},{key:"toPromise",value:function(){var e=this;return new Promise(function(t,n){e.next(t,n)})}},{key:"wrapUserFunction",value:function(t){try{var n=t();return(0,K._)(n,e)?n:e.resolve(n)}catch(t){return e.reject(t)}}},{key:"wrapSuccess",value:function(t,n){return t?this.wrapUserFunction(function(){return t(n)}):e.resolve(n)}},{key:"wrapFailure",value:function(t,n){return t?this.wrapUserFunction(function(){return t(n)}):e.reject(n)}}],[{key:"resolve",value:function(t){return new e(function(e,n){e(t)})}}
1,{key:"reject",value:function(t){return new e(function(e,n){n(t)})}},{key:"waitFor",value:function(t){return new e(function(e,n){var r=0,i=0,a=!1;t.forEach(function(t){++r,t.next(function(){++i,a&&i===r&&e()},function(e){return n(e)})}),a=!0,i===r&&e()})}},{key:"or",value:function(t){var n=e.resolve(!1),r=!0,i=!1,a=void 0;try{for(var o,s=t[Symbol.iterator]();!(r=(o=s.next()).done);r=!0)!function(){var t=o.value;n=n.next(function(n){return n?e.resolve(n):t()})}()}catch(e){i=!0,a=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw a}}return n}},{key:"forEach",value:function(e,t){var n=this,r=[];return e.forEach(function(e,i){r.push(t.call(n,e,i))}),this.waitFor(r)}},{key:"mapArray",value:function(t,n){return new e(function(e,r){for(var i=function(i){n(t[i]).next(function(t){o[i]=t,++s===a&&e(o)},function(e){return r(e)})},a=t.length,o=Array(a),s=0,u=0;u<a;u++)i(u)})}},{key:"doWhile",value:function(t,n){return new e(function(e,r){var i=function(){!0===t()?n().next(function(){i()},r):e()};i()})}}]),e}(),t8=function(){function e(t,n){var r=this;(0,O._)(this,e),this.action=t,this.transaction=n,this.aborted=!1,this.V=new tA,this.transaction.oncomplete=function(){r.V.resolve()},this.transaction.onabort=function(){n.error?r.V.reject(new nt(t,n.error)):r.V.resolve()},this.transaction.onerror=function(e){var n=no(e.target.error);r.V.reject(new nt(t,n))}}return(0,P._)(e,[{key:"m",get:function(){return this.V.promise}},{key:"abort",value:function(e){e&&this.V.reject(e),this.aborted||(tw("SimpleDb","Aborting transaction:",e?e.message:"Client-initiated abort"),this.aborted=!0,this.transaction.abort())}},{key:"g",value:function(){var e=this.transaction;this.aborted||"function"!=typeof e.commit||e.commit()}},{key:"store",value:function(e){return new nr(this.transaction.objectStore(e))}}],[{key:"open",value:function(t,n,r,i){try{return new e(n,t.transaction(i,r))}catch(e){throw new nt(n,e)}}}]),e}(),t7=function(){function e(t,n,r){(0,O._)(this,e),this.name=t,this.version=n,this.F=r,12.2===e.D(eh())&&tI("Firestore persistence suffers from a bug in iOS 12.2 Safari that may cause your app to stop working. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.")}return(0,P._)(e,[{key:"M",value:function(e){return(0,N._)(function(){var t,n;return(0,M._)(this,function(r){switch(r.label){case 0:if(t=this,this.db)return[3,2];return tw("SimpleDb","Opening database:",this.name),n=this,[4,new Promise(function(n,r){var i=indexedDB.open(t.name,t.version);i.onsuccess=function(e){n(e.target.result)},i.onblocked=function(){r(new nt(e,"Cannot upgrade IndexedDB schema while another tab is open. Close all tabs that access Firestore and reload this page to proceed."))},i.onerror=function(t){var n=t.target.error;"VersionError"===n.name?r(new tx(tC.FAILED_PRECONDITION,"A newer version of the Firestore SDK was previously used and so the persisted data is not compatible with the version of the SDK you are now using. The SDK will operate with persistence disabled. If you need persistence, please re-upgrade to a newer version of the SDK or else clear the persisted IndexedDB data for your app to start fresh.")):"InvalidStateError"===n.name?r(new tx(tC.FAILED_PRECONDITION,"Unable to open an IndexedDB connection. This could be due to running in a private browsing session on a browser whose private browsing sessions do not support IndexedDB: "+n)):r(new nt(e,n))},i.onupgradeneeded=function(e){tw("SimpleDb",'Database "'+t.name+'" requires upgrade from version:',e.oldVersion);var n=e.target.result;t.F.O(n,i.transaction,e.oldVersion,t.version).next(function(){tw("SimpleDb","Database upgrade to version "+t.version+" complete")})}})];case 1:n.db=r.sent(),r.label=2;case 2:return[2,(this.N&&(this.db.onversionchange=function(e){return t.N(e)}),this.db)]}})}).call(this)}},{key:"L",value:function(e){this.N=e,this.db&&(this.db.onversionchange=function(t){return e(t)})}},{key:"runTransaction",value:function(e,t,n,r){return(0,N._)(function(){var i,a,o,s,u;return(0,M._)(this,function(c){switch(c.label){case 0:a=function(){var t,a,u,c,l;return(0,M._)(this,function(h){switch(h.label){case 0:++s,h.label=1;case 1:return h.trys.push([1,4,,5]),[4,i.M(e)];case 2:return i.db=h.sent(),a=r(t=t8.open(i.db,e,o?"readonly":"readwrite",n)).next(function(e){return t.g(),e}).catch(function(e){return t.abort(e),t6.reject(e)}).toPromise(),u={},a.catch(function(){}),[4,t.m];case 3:return[2,(u.v=(h.sent(),a),u)];case 4:if(l="FirebaseError"!==(c=h.sent()).name&&s<3,tw("SimpleDb","Transaction failed with error:",c.message,"Retrying:",l),i.close(),!l)return[2,{v:Promise.reject(c)}];return[3,5];case 5:return[2]}})},o="readonly"===t,s=0,c.label=1;case 1:return i=this,[5,(0,W._)(a())];case 2:if(u=c.sent(),"object"===(0,G._)(u))return[2,u.v];c.label=3;case 3:return[3,1];case 4:return[2]}})}).call(this)}},{key:"close",value:function(){this.db&&this.db.close(),this.db=void 0}}],[{key:"delete",value:function(e){return tw("SimpleDb","Removing database:",e),ni(window.indexedDB.deleteDatabase(e)).toPromise()}},{key:"p",value:function(){if(!ed())return!1;if(e.S())return!0;var t=eh(),n=e.D(t),r=t9(t);return!(t.indexOf("MSIE ")>0||t.indexOf("Trident/")>0||t.indexOf("Edge/")>0||0<n&&n<10||0<r&&r<4.5)}},{key:"S",value:function(){var e;return void 0!==U.default&&"YES"===(null==(e=U.default.__PRIVATE_env)?void 0:e.v)}
1},{key:"C",value:function(e,t){return e.store(t)}},{key:"D",value:function(e){var t=e.match(/i(?:phone|pad|pod) os ([\d_]+)/i);return Number(t?t[1].split("_").slice(0,2).join("."):"-1")}}]),e}();function t9(e){var t=e.match(/Android ([\d.]+)/i);return Number(t?t[1].split(".").slice(0,2).join("."):"-1")}var ne=function(){function e(t){(0,O._)(this,e),this.B=t,this.k=!1,this.q=null}return(0,P._)(e,[{key:"isDone",get:function(){return this.k}},{key:"K",get:function(){return this.q}},{key:"cursor",set:function(e){this.B=e}},{key:"done",value:function(){this.k=!0}},{key:"$",value:function(e){this.q=e}},{key:"delete",value:function(){return ni(this.B.delete())}}]),e}(),nt=function(e){function t(e,n){var r;return(0,O._)(this,t),(r=(0,V._)(this,t,[tC.UNAVAILABLE,"IndexedDB transaction '".concat(e,"' failed: ").concat(n)])).name="IndexedDbTransactionError",r}return(0,z._)(t,e),t}(tx);function nn(e){return"IndexedDbTransactionError"===e.name}var nr=function(){function e(t){(0,O._)(this,e),this.store=t}return(0,P._)(e,[{key:"put",value:function(e,t){var n;return void 0!==t?(tw("SimpleDb","PUT",this.store.name,e,t),n=this.store.put(t,e)):(tw("SimpleDb","PUT",this.store.name,"<auto-key>",e),n=this.store.put(e)),ni(n)}},{key:"add",value:function(e){return tw("SimpleDb","ADD",this.store.name,e,e),ni(this.store.add(e))}},{key:"get",value:function(e){var t=this;return ni(this.store.get(e)).next(function(n){return void 0===n&&(n=null),tw("SimpleDb","GET",t.store.name,e,n),n})}},{key:"delete",value:function(e){return tw("SimpleDb","DELETE",this.store.name,e),ni(this.store.delete(e))}},{key:"count",value:function(){return tw("SimpleDb","COUNT",this.store.name),ni(this.store.count())}},{key:"U",value:function(e,t){var n=this.options(e,t),r=n.index?this.store.index(n.index):this.store;if("function"==typeof r.getAll){var i=r.getAll(n.range);return new t6(function(e,t){i.onerror=function(e){t(e.target.error)},i.onsuccess=function(t){e(t.target.result)}})}var a=this.cursor(n),o=[];return this.W(a,function(e,t){o.push(t)}).next(function(){return o})}},{key:"G",value:function(e,t){var n=this.store.getAll(e,null===t?void 0:t);return new t6(function(e,t){n.onerror=function(e){t(e.target.error)},n.onsuccess=function(t){e(t.target.result)}})}},{key:"j",value:function(e,t){tw("SimpleDb","DELETE ALL",this.store.name);var n=this.options(e,t);n.H=!1;var r=this.cursor(n);return this.W(r,function(e,t,n){return n.delete()})}},{key:"J",value:function(e,t){t?n=e:(n={},t=e);var n,r=this.cursor(n);return this.W(r,t)}},{key:"Y",value:function(e){var t=this.cursor({});return new t6(function(n,r){t.onerror=function(e){r(no(e.target.error))},t.onsuccess=function(t){var r=t.target.result;r?e(r.primaryKey,r.value).next(function(e){e?r.continue():n()}):n()}})}},{key:"W",value:function(e,t){var n=[];return new t6(function(r,i){e.onerror=function(e){i(e.target.error)},e.onsuccess=function(e){var i=e.target.result;if(!i)return void r();var a=new ne(i),o=t(i.primaryKey,i.value,a);if((0,K._)(o,t6)){var s=o.catch(function(e){return a.done(),t6.reject(e)});n.push(s)}a.isDone?r():null===a.K?i.continue():i.continue(a.K)}}).next(function(){return t6.waitFor(n)})}},{key:"options",value:function(e,t){var n;return void 0!==e&&("string"==typeof e?n=e:t=e),{index:n,range:t}}},{key:"cursor",value:function(e){var t="next";if(e.reverse&&(t="prev"),e.index){var n=this.store.index(e.index);return e.H?n.openKeyCursor(e.range,t):n.openCursor(e.range,t)}return this.store.openCursor(e.range,t)}}]),e}();function ni(e){return new t6(function(t,n){e.onsuccess=function(e){t(e.target.result)},e.onerror=function(e){n(no(e.target.error))}})}var na=!1;function no(e){var t=t7.D(eh());if(t>=12.2&&t<13){var n="An internal error was encountered in the Indexed Database server";if(e.message.indexOf(n)>=0){var r=new tx("internal","IOS_INDEXEDDB_BUG1: IndexedDb has thrown '".concat(n,"'. This is likely due to an unavoidable bug in iOS. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround."));return na||(na=!0,setTimeout(function(){throw r},0)),r}}return e}var ns=function(){function e(t,n){(0,O._)(this,e),this.asyncQueue=t,this.Z=n,this.task=null}return(0,P._)(e,[{key:"start",value:function(){this.X(15e3)}},{key:"stop",value:function(){this.task&&(this.task.cancel(),this.task=null)}},{key:"started",get:function(){return null!==this.task}},{key:"X",value:function(e){var t=this;tw("IndexBackfiller","Scheduled in ".concat(e,"ms")),this.task=this.asyncQueue.enqueueAfterDelay("index_backfill",e,function(){return(0,N._)(function(){var e,t,n,r;return(0,M._)(this,function(i){switch(i.label){case 0:this.task=null,i.label=1;
1case 1:return i.trys.push([1,3,,7]),e=["IndexBackfiller"],n=(t="Documents written: ").concat,[4,this.Z.ee()];case 2:return tw.apply(void 0,e.concat([n.apply(t,[i.sent()])])),[3,7];case 3:if(!nn(r=i.sent()))return[3,4];return tw("IndexBackfiller","Ignoring IndexedDB error during index backfill: ",r),[3,6];case 4:return[4,t5(r)];case 5:i.sent(),i.label=6;case 6:return[3,7];case 7:return[4,this.X(6e4)];case 8:return i.sent(),[2]}})}).call(t)})}}]),e}(),nu=function(){function e(t,n){(0,O._)(this,e),this.localStore=t,this.persistence=n}return(0,P._)(e,[{key:"ee",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:50;return(0,N._)(function(){var t;return(0,M._)(this,function(n){return t=this,[2,this.persistence.runTransaction("Backfill Indexes","readwrite-primary",function(n){return t.te(n,e)})]})}).call(this)}},{key:"te",value:function(e,t){var n=this,r=new Set,i=t,a=!0;return t6.doWhile(function(){return!0===a&&i>0},function(){return n.localStore.indexManager.getNextCollectionGroupToUpdate(e).next(function(t){if(null!==t&&!r.has(t))return tw("IndexBackfiller","Processing collection: ".concat(t)),n.ne(e,t,i).next(function(e){i-=e,r.add(t)});a=!1})}).next(function(){return t-i})}},{key:"ne",value:function(e,t,n){var r=this;return this.localStore.indexManager.getMinOffsetFromCollectionGroup(e,t).next(function(i){return r.localStore.localDocuments.getNextDocuments(e,t,i,n).next(function(n){var a=n.changes;return r.localStore.indexManager.updateIndexEntries(e,a).next(function(){return r.re(i,n)}).next(function(n){return tw("IndexBackfiller","Updating offset: ".concat(n)),r.localStore.indexManager.updateCollectionGroup(e,t,n)}).next(function(){return a.size})})})}},{key:"re",value:function(e,t){var n=e;
1return t.changes.forEach(function(e,t){var r=t0(t);t2(r,n)>0&&(n=r)}),new t1(n.readTime,n.documentKey,Math.max(t.batchId,e.largestBatchId))}}]),e}(),nc=function(){function e(t,n){var r=this;(0,O._)(this,e),this.previousValue=t,n&&(n.sequenceNumberHandler=function(e){return r.ie(e)},this.se=function(e){return n.writeSequenceNumber(e)})}return(0,P._)(e,[{key:"ie",value:function(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}},{key:"next",value:function(){var e=++this.previousValue;return this.se&&this.se(e),e}}]),e}();function nl(e){return null==e}function nh(e){return 0===e&&1/e==-1/0}function nf(e){return"number"==typeof e&&Number.isInteger(e)&&!nh(e)&&e<=Number.MAX_SAFE_INTEGER&&e>=Number.MIN_SAFE_INTEGER}function nd(e){for(var t="",n=0;n<e.length;n++)t.length>0&&(t+="\x01\x01"),t=function(e,t){for(var n=t,r=e.length,i=0;i<r;i++){var a=e.charAt(i);switch(a){case"\0":n+="\x01\x10";break;case"\x01":n+="\x01\x11";break;default:n+=a}}return n}(e.get(n),t);return t+"\x01\x01"}nc.oe=-1;function nv(e){var t=e.length;if(t>=2||tS(),2===t)return"\x01"===e.charAt(0)&&"\x01"===e.charAt(1)||tS(),tK.emptyPath();for(var n=t-2,r=[],i="",a=0;a<t;){var o=e.indexOf("\x01",a);switch((o<0||o>n)&&tS(),e.charAt(o+1)){case"\x01":var s=e.substring(a,o),u=void 0;0===i.length?u=s:(i+=s,u=i,i=""),r.push(u);break;case"\x10":i+=e.substring(a,o),i+="\0";break;case"\x11":i+=e.substring(a,o+1);break;default:tS()}a=o+2}return new tK(r)}var ny=["userId","batchId"],np={},nm=["prefixPath","collectionGroup","readTime","documentId"],ng=["prefixPath","collectionGroup","documentId"],n_=["collectionGroup","readTime","prefixPath","documentId"],nk=["canonicalId","targetId"],nb=["targetId","path"],nw=["path","targetId"],nI=["collectionId","parent"],nT=["indexId","uid"],nE=["uid","sequenceNumber"],nS=["indexId","uid","arrayValue","directionalValue","orderedDocumentKey","documentKey"],nC=["indexId","uid","orderedDocumentKey"],nx=["userId","collectionPath","documentId"],nA=["userId","collectionPath","largestBatchId"],nD=["userId","collectionGroup","largestBatchId"],nR=(0,L._)((0,L._)((0,L._)((0,L._)(["mutationQueues","mutations","documentMutations","remoteDocuments","targets","owner","targetGlobal","targetDocuments"]).concat(["clientMetadata"])).concat(["remoteDocumentGlobal"])).concat(["collectionParents"])).concat(["bundles","namedQueries"]),nN=(0,L._)(nR).concat(["documentOverlays"]),nO=["mutationQueues","mutations","documentMutations","remoteDocumentsV14","targets","owner","targetGlobal","targetDocuments","clientMetadata","remoteDocumentGlobal","collectionParents","bundles","namedQueries","documentOverlays"],nP=(0,L._)(nO).concat(["indexConfiguration","indexState","indexEntries"]),nL=(0,L._)(nP).concat(["globals"]),nM=function(e){function t(e,n){var r;return(0,O._)(this,t),(r=(0,V._)(this,t))._e=e,r.currentSequenceNumber=n,r}return(0,z._)(t,e),t}(t4);function nU(e,t){return t7.C(e._e,t)}function nF(e){var t=0;for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}function nV(e,t){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t(n,e[n])}function nB(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}var nj=function(){function e(t,n){(0,O._)(this,e),this.comparator=t,this.root=n||nz.EMPTY}return(0,P._)(e,[{key:"insert",value:function(t,n){return new e(this.comparator,this.root.insert(t,n,this.comparator).copy(null,null,nz.BLACK,null,null))}},{key:"remove",value:function(t){return new e(this.comparator,this.root.remove(t,this.comparator).copy(null,null,nz.BLACK,null,null))}},{key:"get",value:function(e){for(var t=this.root;!t.isEmpty();){var n=this.comparator(e,t.key);if(0===n)return t.value;n<0?t=t.left:n>0&&(t=t.right)}return null}},{key:"indexOf",value:function(e){for(var t=0,n=this.root;!n.isEmpty();){var r=this.comparator(e,n.key);if(0===r)return t+n.left.size;r<0?n=n.left:(t+=n.left.size+1,n=n.right)}return -1}},{key:"isEmpty",value:function(){return this.root.isEmpty()}},{key:"size",get:function(){return this.root.size}},{key:"minKey",value:function(){return this.root.minKey()}},{key:"maxKey",value:function(){return this.root.maxKey()}},{key:"inorderTraversal",value:function(e){return this.root.inorderTraversal(e)}}
1,{key:"forEach",value:function(e){this.inorderTraversal(function(t,n){return e(t,n),!1})}},{key:"toString",value:function(){var e=[];return this.inorderTraversal(function(t,n){return e.push("".concat(t,":").concat(n)),!1}),"{".concat(e.join(", "),"}")}},{key:"reverseTraversal",value:function(e){return this.root.reverseTraversal(e)}},{key:"getIterator",value:function(){return new nq(this.root,null,this.comparator,!1)}},{key:"getIteratorFrom",value:function(e){return new nq(this.root,e,this.comparator,!1)}},{key:"getReverseIterator",value:function(){return new nq(this.root,null,this.comparator,!0)}},{key:"getReverseIteratorFrom",value:function(e){return new nq(this.root,e,this.comparator,!0)}}]),e}(),nq=function(){function e(t,n,r,i){(0,O._)(this,e),this.isReverse=i,this.nodeStack=[];for(var a=1;!t.isEmpty();)if(a=n?r(t.key,n):1,n&&i&&(a*=-1),a<0)t=this.isReverse?t.left:t.right;else{if(0===a){this.nodeStack.push(t);break}this.nodeStack.push(t),t=this.isReverse?t.right:t.left}}return(0,P._)(e,[{key:"getNext",value:function(){var e=this.nodeStack.pop(),t={key:e.key,value:e.value};if(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}},{key:"hasNext",value:function(){return this.nodeStack.length>0}},{key:"peek",value:function(){if(0===this.nodeStack.length)return null;var e=this.nodeStack[this.nodeStack.length-1];return{key:e.key,value:e.value}}}]),e}(),nz=function(){function e(t,n,r,i,a){(0,O._)(this,e),this.key=t,this.value=n,this.color=null!=r?r:e.RED,this.left=null!=i?i:e.EMPTY,this.right=null!=a?a:e.EMPTY,this.size=this.left.size+1+this.right.size}return(0,P._)(e,[{key:"copy",value:function(t,n,r,i,a){return new e(null!=t?t:this.key,null!=n?n:this.value,null!=r?r:this.color,null!=i?i:this.left,null!=a?a:this.right)}},{key:"isEmpty",value:function(){return!1}},{key:"inorderTraversal",value:function(e){return this.left.inorderTraversal(e)||e(this.key,this.value)||this.right.inorderTraversal(e)}},{key:"reverseTraversal",value:function(e){return this.right.reverseTraversal(e)||e(this.key,this.value)||this.left.reverseTraversal(e)}},{key:"min",value:function(){return this.left.isEmpty()?this:this.left.min()}},{key:"minKey",value:function(){return this.min().key}},{key:"maxKey",value:function(){return this.right.isEmpty()?this.key:this.right.maxKey()}},{key:"insert",value:function(e,t,n){var r=this,i=n(e,r.key);return(r=i<0?r.copy(null,null,null,r.left.insert(e,t,n),null):0===i?r.copy(null,t,null,null,null):r.copy(null,null,null,null,r.right.insert(e,t,n))).fixUp()}},{key:"removeMin",value:function(){if(this.left.isEmpty())return e.EMPTY;var t=this;return t.left.isRed()||t.left.left.isRed()||(t=t.moveRedLeft()),(t=t.copy(null,null,null,t.left.removeMin(),null)).fixUp()}},{key:"remove",value:function(t,n){var r,i=this;if(0>n(t,i.key))i.left.isEmpty()||i.left.isRed()||i.left.left.isRed()||(i=i.moveRedLeft()),i=i.copy(null,null,null,i.left.remove(t,n),null);else{if(i.left.isRed()&&(i=i.rotateRight()),i.right.isEmpty()||i.right.isRed()||i.right.left.isRed()||(i=i.moveRedRight()),0===n(t,i.key)){if(i.right.isEmpty())return e.EMPTY;r=i.right.min(),i=i.copy(r.key,r.value,null,null,i.right.removeMin())}i=i.copy(null,null,null,null,i.right.remove(t,n))}return i.fixUp()}},{key:"isRed",value:function(){return this.color}},{key:"fixUp",value:function(){var e=this;return e.right.isRed()&&!e.left.isRed()&&(e=e.rotateLeft()),e.left.isRed()&&e.left.left.isRed()&&(e=e.rotateRight()),e.left.isRed()&&e.right.isRed()&&(e=e.colorFlip()),e}},{key:"moveRedLeft",value:function(){var e=this.colorFlip();return e.right.left.isRed()&&(e=(e=(e=e.copy(null,null,null,null,e.right.rotateRight())).rotateLeft()).colorFlip()),e}},{key:"moveRedRight",value:function(){var e=this.colorFlip();return e.left.left.isRed()&&(e=(e=e.rotateRight()).colorFlip()),e}},{key:"rotateLeft",value:function(){var t=this.copy(null,null,e.RED,null,this.right.left);return this.right.copy(null,null,this.color,t,null)}},{key:"rotateRight",value:function(){var t=this.copy(null,null,e.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,t)}},{key:"colorFlip",value:function(){var e=this.left.copy(null,null,!this.left.color,null,null),t=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,t)}},{key:"checkMaxDepth",value:function(){return Math.pow(2,this.check())<=this.size+1}},{key:"check",value:function(){if(this.isRed()&&this.left.isRed()||this.right.isRed())throw tS();var e=this.left.check();if(e!==this.right.check())throw tS();return e+ +!this.isRed()}}]),e}();
1nz.EMPTY=null,nz.RED=!0,nz.BLACK=!1,nz.EMPTY=new(function(){function e(){(0,O._)(this,e),this.size=0}return(0,P._)(e,[{key:"key",get:function(){throw tS()}},{key:"value",get:function(){throw tS()}},{key:"color",get:function(){throw tS()}},{key:"left",get:function(){throw tS()}},{key:"right",get:function(){throw tS()}},{key:"copy",value:function(e,t,n,r,i){return this}},{key:"insert",value:function(e,t,n){return new nz(e,t)}},{key:"remove",value:function(e,t){return this}},{key:"isEmpty",value:function(){return!0}},{key:"inorderTraversal",value:function(e){return!1}},{key:"reverseTraversal",value:function(e){return!1}},{key:"minKey",value:function(){return null}},{key:"maxKey",value:function(){return null}},{key:"isRed",value:function(){return!1}},{key:"checkMaxDepth",value:function(){return!0}},{key:"check",value:function(){return 0}}]),e}());var nK=function(){function e(t){(0,O._)(this,e),this.comparator=t,this.data=new nj(this.comparator)}return(0,P._)(e,[{key:"has",value:function(e){return null!==this.data.get(e)}},{key:"first",value:function(){return this.data.minKey()}},{key:"last",value:function(){return this.data.maxKey()}},{key:"size",get:function(){return this.data.size}},{key:"indexOf",value:function(e){return this.data.indexOf(e)}},{key:"forEach",value:function(e){this.data.inorderTraversal(function(t,n){return e(t),!1})}},{key:"forEachInRange",value:function(e,t){for(var n=this.data.getIteratorFrom(e[0]);n.hasNext();){var r=n.getNext();if(this.comparator(r.key,e[1])>=0)return;t(r.key)}}},{key:"forEachWhile",value:function(e,t){var n;for(n=void 0!==t?this.data.getIteratorFrom(t):this.data.getIterator();n.hasNext();)if(!e(n.getNext().key))return}},{key:"firstAfterOrEqual",value:function(e){var t=this.data.getIteratorFrom(e);return t.hasNext()?t.getNext().key:null}},{key:"getIterator",value:function(){return new nG(this.data.getIterator())}},{key:"getIteratorFrom",value:function(e){return new nG(this.data.getIteratorFrom(e))}},{key:"add",value:function(e){return this.copy(this.data.remove(e).insert(e,!0))}},{key:"delete",value:function(e){return this.has(e)?this.copy(this.data.remove(e)):this}},{key:"isEmpty",value:function(){return this.data.isEmpty()}},{key:"unionWith",value:function(e){var t=this;return t.size<e.size&&(t=e,e=this),e.forEach(function(e){t=t.add(e)}),t}},{key:"isEqual",value:function(t){if(!(0,K._)(t,e)||this.size!==t.size)return!1;for(var n=this.data.getIterator(),r=t.data.getIterator();n.hasNext();){var i=n.getNext().key,a=r.getNext().key;if(0!==this.comparator(i,a))return!1}return!0}},{key:"toArray",value:function(){var e=[];return this.forEach(function(t){e.push(t)}),e}},{key:"toString",value:function(){var e=[];return this.forEach(function(t){return e.push(t)}),"SortedSet("+e.toString()+")"}},{key:"copy",value:function(t){var n=new e(this.comparator);return n.data=t,n}}]),e}(),nG=function(){function e(t){(0,O._)(this,e),this.iter=t}return(0,P._)(e,[{key:"getNext",value:function(){return this.iter.getNext().key}},{key:"hasNext",value:function(){return this.iter.hasNext()}}]),e}();function nH(e){return e.hasNext()?e.getNext():void 0}var nW=function(){function e(t){(0,O._)(this,e),this.fields=t,t.sort(tH.comparator)}return(0,P._)(e,[{key:"unionWith",value:function(t){var n=new nK(tH.comparator),r=!0,i=!1,a=void 0;try{for(var o,s=this.fields[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var u=o.value;n=n.add(u)}}catch(e){i=!0,a=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw a}}var c=!0,l=!1,h=void 0;try{for(var f,d=t[Symbol.iterator]();!(c=(f=d.next()).done);c=!0){var v=f.value;n=n.add(v)}}catch(e){l=!0,h=e}finally{try{c||null==d.return||d.return()}finally{if(l)throw h}}return new e(n.toArray())}},{key:"covers",value:function(e){var t=!0,n=!1,r=void 0;try{for(var i,a=this.fields[Symbol.iterator]();!(t=(i=a.next()).done);t=!0)if(i.value.isPrefixOf(e))return!0}catch(e){n=!0,r=e}finally{try{t||null==a.return||a.return()}finally{if(n)throw r}}return!1}},{key:"isEqual",value:function(e){return tB(this.fields,e.fields,function(e,t){return e.isEqual(t)})}}],[{key:"empty",value:function(){return new e([])}}]),e}(),nQ=function(e){function t(){var e;return(0,O._)(this,t),e=(0,V._)(this,t,arguments),e.name="Base64DecodeError",e}return(0,z._)(t,e),t}((0,H._)(Error)),nJ=function(){function e(t){(0,O._)(this,e),this.binaryString=t}return(0,P._)(e,[{key:Symbol.iterator,value:function(){var e=this,t=0;return{next:function(){return t<e.binaryString.length?{value:e.binaryString.charCodeAt(t++),done:!1}:{value:void 0,done:!0}}}}},{key:"toBase64",value:function(){return btoa(this.binaryString)}},{key:"toUint8Array",value:function(){for(var e=this.binaryString,t=new Uint8Array(e.length),n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}},{key:"approximateByteSize",value:function(){return 2*this.binaryString.length}},{key:"compareTo",value:function(e){return tV(this.binaryString,e.binaryString)}},{key:"isEqual",value:function(e){return this.binaryString===e.binaryString}}],[{key:"fromBase64String",value:function(t){return new e(function(e){try{return atob(e)}catch(e){throw"u">typeof DOMException&&(0,K._)(e,DOMException)?new nQ("Invalid base64 string: "+e):e}}(t))}},{key:"fromUint8Array",value:function(t){return new e(function(e){for(var t="",n=0;n<e.length;++n)t+=String.fromCharCode(e[n]);return t}(t))}}]),e}();nJ.EMPTY_BYTE_STRING=new nJ("");var nX=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function nY(e){if(e||tS(),"string"==typeof e){var t=0,n=nX.exec(e);if(n||tS(),n[1]){var r=n[1];t=Number(r=(r+"000000000").substr(0,9))}return{seconds:Math.floor(new Date(e).getTime()/1e3),nanos:t}}return{seconds:n$(e.seconds),nanos:n$(e.nanos)}}function n$(e){return"number"==typeof e?e:"string"==typeof e?Number(e):0}function nZ(e){return"string"==typeof e?nJ.fromBase64String(e):nJ.fromUint8Array(e)}function n0(e){var t,n;return"server_timestamp"===(null==(n=((null==(t=null==e?void 0:e.mapValue)?void 0:t.fields)||{}).__type__)?void 0:n.stringValue)}function n1(e){var t=e.mapValue.fields.__previous_value__;return n0(t)?n1(t):t}function n2(e){var t=nY(e.mapValue.fields.__local_write_time__.timestampValue);return new tj(t.seconds,t.nanos)}var n3=function e(t,n,r,i,a,o,s,u,c){(0,O._)(this,e),this.databaseId=t,this.appId=n,this.persistenceKey=r,this.host=i,this.ssl=a,this.forceLongPolling=o,this.autoDetectLongPolling=s,this.longPollingOptions=u,this.useFetchStreams=c},n4=function(){function e(t,n){(0,O._)(this,e),this.projectId=t,this.database=n||"(default)"}return(0,P._)(e,[{key:"isDefaultDatabase",get:function(){return"(default)"===this.database}},{key:"isEqual",value:function(t){return(0,K._)(t,e)&&t.projectId===this.projectId&&t.database===this.database}}],[{key:"empty",value:function(){return new e("","")}}]),e}(),n5={mapValue:{fields:{__type__:{stringValue:"__max__"}}}},n6={nullValue:"NULL_VALUE"};function n8(e){return"nullValue"in e?0:"booleanValue"in e?1:"integerValue"in e||"doubleValue"in e?2:"timestampValue"in e?3:"stringValue"in e?5:"bytesValue"in e?6:"referenceValue"in e?7:"geoPointValue"in e?8:"arrayValue"in e?9:"mapValue"in e?n0(e)?4:rf(e)?0x1fffffffffffff:rl(e)?10:11:tS()}function n7(e,t){if(e===t)return!0;var n=n8(e);if(n!==n8(t))return!1;switch(n){case 0:case 0x1fffffffffffff:return!0;case 1:return e.booleanValue===t.booleanValue;case 4:return n2(e).isEqual(n2(t));case 3:if("string"==typeof e.timestampValue&&"string"==typeof t.timestampValue&&e.timestampValue.length===t.timestampValue.length)return e.timestampValue===t.timestampValue;var r=nY(e.timestampValue),i=nY(t.timestampValue);return r.seconds===i.seconds&&r.nanos===i.nanos;case 5:return e.stringValue===t.stringValue;case 6:return nZ(e.bytesValue).isEqual(nZ(t.bytesValue));case 7:return e.referenceValue===t.referenceValue;case 8:return n$(e.geoPointValue.latitude)===n$(t.geoPointValue.latitude)&&n$(e.geoPointValue.longitude)===n$(t.geoPointValue.longitude);case 2:if("integerValue"in e&&"integerValue"in t)return n$(e.integerValue)===n$(t.integerValue);if("doubleValue"in e&&"doubleValue"in t){var a=n$(e.doubleValue),o=n$(t.doubleValue);return a===o?nh(a)===nh(o):isNaN(a)&&isNaN(o)}return!1;case 9:return tB(e.arrayValue.values||[],t.arrayValue.values||[],n7);case 10:case 11:var s=e.mapValue.fields||{},u=t.mapValue.fields||{};if(nF(s)!==nF(u))return!1;for(var c in s)if(s.hasOwnProperty(c)&&(void 0===u[c]||!n7(s[c],u[c])))return!1;return!0;default:return tS()}}function n9(e,t){return void 0!==(e.values||[]).find(function(e){return n7(e,t)})}function re(e,t){if(e===t)return 0;var n,r,i,a,o,s,u,c,l,h,f,d,v,y,p,m,g,_,k,b,w=n8(e),I=n8(t);if(w!==I)return tV(w,I);switch(w){case 0:case 0x1fffffffffffff:return 0;case 1:return tV(e.booleanValue,t.booleanValue);case 2:return(n=n$(e.integerValue||e.doubleValue))<(r=n$(t.integerValue||t.doubleValue))?-1:n>r?1:n===r?0:isNaN(n)?isNaN(r)?0:-1:1;case 3:return rt(e.timestampValue,t.timestampValue);case 4:return rt(n2(e),n2(t));case 5:return tV(e.stringValue,t.stringValue);case 6:return i=e.bytesValue,a=t.bytesValue,o=nZ(i),s=nZ(a),o.compareTo(s);case 7:return function(e,t){for(var n=e.split("/"),r=t.split("/"),i=0;i<n.length&&i<r.length;i++){var a=tV(n[i],r[i]);if(0!==a)return a}return tV(n.length,r.length)}(e.referenceValue,t.referenceValue);case 8:return u=e.geoPointValue,c=t.geoPointValue,0!==(l=tV(n$(u.latitude),n$(c.latitude)))?l:tV(n$(u.longitude),n$(c.longitude));case 9:return rn(e.arrayValue,t.arrayValue);case 10:return h=e.mapValue,f=t.mapValue,m=h.fields||{},g=f.fields||{},_=null==(d=m.value)?void 0:d.arrayValue,k=null==(v=g.value)?void 0:v.arrayValue,0!==(b=tV((null==(y=null==_?void 0:_.values)?void 0:y.length)||0,(null==(p=null==k?void 0:k.values)?void 0:p.length)||0))?b:rn(_,k);case 11:return function(e,t){if(e===n5.mapValue&&t===n5.mapValue)return 0;if(e===n5.mapValue)return 1;if(t===n5.mapValue)return -1;var n=e.fields||{},r=Object.keys(n),i=t.fields||{},a=Object.keys(i);r.sort(),a.sort();for(var o=0;o<r.length&&o<a.length;++o){var s=tV(r[o],a[o]);if(0!==s)return s;var u=re(n[r[o]],i[a[o]]);if(0!==u)return u}return tV(r.length,a.length)}(e.mapValue,t.mapValue);default:throw tS()}}function rt(e,t){if("string"==typeof e&&"string"==typeof t&&e.length===t.length)return tV(e,t);var n=nY(e),r=nY(t),i=tV(n.seconds,r.seconds);return 0!==i?i:tV(n.nanos,r.nanos)}function rn(e,t){for(var n=e.values||[],r=t.values||[],i=0;i<n.length&&i<r.length;++i){var a=re(n[i],r[i]);if(a)return a}return tV(n.length,r.length)}function rr(e){var t,n,r;return"nullValue"in e?"null":"booleanValue"in e?""+e.booleanValue:"integerValue"in e?""+e.integerValue:"doubleValue"in e?""+e.doubleValue:"timestampValue"in e?(t=nY(e.timestampValue),"time(".concat(t.seconds,",").concat(t.nanos,")")):"stringValue"in e?e.stringValue:"bytesValue"in e?nZ(e.bytesValue).toBase64():"referenceValue"in e?(n=e.referenceValue,tW.fromName(n).toString()):"geoPointValue"in e?(r=e.geoPointValue,"geo(".concat(r.latitude,",").concat(r.longitude,")")):"arrayValue"in e?function(e){var t="[",n=!0,r=!0,i=!1,a=void 0;try{for(var o,s=(e.values||[])[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var u=o.value;n?n=!1:t+=",",t+=rr(u)}}catch(e){i=!0,a=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw a}}return t+"]"}(e.arrayValue):"mapValue"in e?function(e){var t=Object.keys(e.fields||{}).sort(),n="{",r=!0,i=!0,a=!1,o=void 0;try{for(var s,u=t[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var c=s.value;r?r=!1:n+=",",n+="".concat(c,":").concat(rr(e.fields[c]))}}catch(e){a=!0,o=e}finally{try{i||null==u.return||u.return()}finally{if(a)throw o}}return n+"}"}(e.mapValue):tS()}function ri(e,t){return{referenceValue:"projects/".concat(e.projectId,"/databases/").concat(e.database,"/documents/").concat(t.path.canonicalString())}}function ra(e){return!!e&&"integerValue"in e}function ro(e){return!!e&&"arrayValue"in e}function rs(e){return!!e&&"nullValue"in e}function ru(e){return!!e&&"doubleValue"in e&&isNaN(Number(e.doubleValue))}function rc(e){return!!e&&"mapValue"in e}function rl(e){var t,n;return"__vector__"===(null==(n=((null==(t=null==e?void 0:e.mapValue)?void 0:t.fields)||{}).__type__)?void 0:n.stringValue)}function rh(e){if(e.geoPointValue)return{geoPointValue:Object.assign({},e.geoPointValue)};if(e.timestampValue&&"object"==(0,G._)(e.timestampValue))return{timestampValue:Object.assign({},e.timestampValue)};if(e.mapValue){var t={mapValue:{fields:{}}};return nV(e.mapValue.fields,function(e,n){return t.mapValue.fields[e]=rh(n)}),t}if(e.arrayValue){for(var n={arrayValue:{values:[]}},r=0;r<(e.arrayValue.values||[]).length;++r)n.arrayValue.values[r]=rh(e.arrayValue.values[r]);return n}return Object.assign({},e)}function rf(e){return"__max__"===(((e.mapValue||{}).fields||{}).__type__||{}).stringValue}var rd={mapValue:{fields:{__type__:{stringValue:"__vector__"},value:{arrayValue:{}}}}};function rv(e,t){var n=re(e.value,t.value);return 0!==n?n:e.inclusive&&!t.inclusive?-1:!e.inclusive&&t.inclusive?1:0}function ry(e,t){var n=re(e.value,t.value);return 0!==n?n:e.inclusive&&!t.inclusive?1:!e.inclusive&&t.inclusive?-1:0}var rp=function(){function e(t){(0,O._)(this,e),this.value=t}return(0,P._)(e,[{key:"field",value:function(e){if(e.isEmpty())return this.value;
1for(var t=this.value,n=0;n<e.length-1;++n)if(!rc(t=(t.mapValue.fields||{})[e.get(n)]))return null;return(t=(t.mapValue.fields||{})[e.lastSegment()])||null}},{key:"set",value:function(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=rh(t)}},{key:"setAll",value:function(e){var t=this,n=tH.emptyPath(),r={},i=[];e.forEach(function(e,a){if(!n.isImmediateParentOf(a)){var o=t.getFieldsMap(n);t.applyChanges(o,r,i),r={},i=[],n=a.popLast()}e?r[a.lastSegment()]=rh(e):i.push(a.lastSegment())});var a=this.getFieldsMap(n);this.applyChanges(a,r,i)}},{key:"delete",value:function(e){var t=this.field(e.popLast());rc(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}},{key:"isEqual",value:function(e){return n7(this.value,e.value)}},{key:"getFieldsMap",value:function(e){var t=this.value;t.mapValue.fields||(t.mapValue={fields:{}});for(var n=0;n<e.length;++n){var r=t.mapValue.fields[e.get(n)];rc(r)&&r.mapValue.fields||(r={mapValue:{fields:{}}},t.mapValue.fields[e.get(n)]=r),t=r}return t.mapValue.fields}},{key:"applyChanges",value:function(e,t,n){nV(t,function(t,n){return e[t]=n});var r=!0,i=!1,a=void 0;try{for(var o,s=n[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var u=o.value;delete e[u]}}catch(e){i=!0,a=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw a}}}},{key:"clone",value:function(){return new e(rh(this.value))}}],[{key:"empty",value:function(){return new e({mapValue:{}})}}]),e}(),rm=function(){function e(t,n,r,i,a,o,s){(0,O._)(this,e),this.key=t,this.documentType=n,this.version=r,this.readTime=i,this.createTime=a,this.data=o,this.documentState=s}return(0,P._)(e,[{key:"convertToFoundDocument",value:function(e,t){return this.createTime.isEqual(tq.min())&&(2===this.documentType||0===this.documentType)&&(this.createTime=e),this.version=e,this.documentType=1,this.data=t,this.documentState=0,this}},{key:"convertToNoDocument",value:function(e){return this.version=e,this.documentType=2,this.data=rp.empty(),this.documentState=0,this}},{key:"convertToUnknownDocument",value:function(e){return this.version=e,this.documentType=3,this.data=rp.empty(),this.documentState=2,this}},{key:"setHasCommittedMutations",value:function(){return this.documentState=2,this}},{key:"setHasLocalMutations",value:function(){return this.documentState=1,this.version=tq.min(),this}},{key:"setReadTime",value:function(e){return this.readTime=e,this}},{key:"hasLocalMutations",get:function(){return 1===this.documentState}},{key:"hasCommittedMutations",get:function(){return 2===this.documentState}},{key:"hasPendingWrites",get:function(){return this.hasLocalMutations||this.hasCommittedMutations}},{key:"isValidDocument",value:function(){return 0!==this.documentType}},{key:"isFoundDocument",value:function(){return 1===this.documentType}},{key:"isNoDocument",value:function(){return 2===this.documentType}},{key:"isUnknownDocument",value:function(){return 3===this.documentType}},{key:"isEqual",value:function(t){return(0,K._)(t,e)&&this.key.isEqual(t.key)&&this.version.isEqual(t.version)&&this.documentType===t.documentType&&this.documentState===t.documentState&&this.data.isEqual(t.data)}},{key:"mutableCopy",value:function(){return new e(this.key,this.documentType,this.version,this.readTime,this.createTime,this.data.clone(),this.documentState)}},{key:"toString",value:function(){return"Document(".concat(this.key,", ").concat(this.version,", ").concat(JSON.stringify(this.data.value),", {createTime: ").concat(this.createTime,"}), {documentType: ").concat(this.documentType,"}), {documentState: ").concat(this.documentState,"})")}}],[{key:"newInvalidDocument",value:function(t){return new e(t,0,tq.min(),tq.min(),tq.min(),rp.empty(),0)}},{key:"newFoundDocument",value:function(t,n,r,i){return new e(t,1,n,tq.min(),r,i,0)}},{key:"newNoDocument",value:function(t,n){return new e(t,2,n,tq.min(),tq.min(),rp.empty(),0)}},{key:"newUnknownDocument",value:function(t,n){return new e(t,3,n,tq.min(),tq.min(),rp.empty(),2)}}]),e}(),rg=function e(t,n){(0,O._)(this,e),this.position=t,this.inclusive=n};function r_(e,t,n){for(var r=0,i=0;i<e.position.length;i++){var a=t[i],o=e.position[i];if(r=a.field.isKeyField()?tW.comparator(tW.fromName(o.referenceValue),n.key):re(o,n.data.field(a.field)),"desc"===a.dir&&(r*=-1),0!==r)break}return r}function rk(e,t){if(null===e)return null===t;if(null===t||e.inclusive!==t.inclusive||e.position.length!==t.position.length)return!1;for(var n=0;n<e.position.length;n++)if(!n7(e.position[n],t.position[n]))return!1;return!0}var rb=function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"asc";(0,O._)(this,e),this.field=t,this.dir=n},rw=function e(){(0,O._)(this,e)},rI=function(e){function t(e,n,r){var i;return(0,O._)(this,t),(i=(0,V._)(this,t)).field=e,i.op=n,i.value=r,i}return(0,z._)(t,e),(0,P._)(t,[{key:"matches",value:function(e){var t=e.data.field(this.field);return"!="===this.op?null!==t&&this.matchesComparison(re(t,this.value)):null!==t&&n8(this.value)===n8(t)&&this.matchesComparison(re(t,this.value))}},{key:"matchesComparison",value:function(e){switch(this.op){case"<":return e<0;case"<=":return e<=0;case"==":return 0===e;case"!=":return 0!==e;case">":return e>0;case">=":return e>=0;default:return tS()}}},{key:"isInequality",value:function(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}},{key:"getFlattenedFilters",value:function(){return[this]}},{key:"getFilters",value:function(){return[this]}}],[{key:"create",value:function(e,n,r){return e.isKeyField()?"in"===n||"not-in"===n?this.createKeyFieldInFilter(e,n,r):new rD(e,n,r):"array-contains"===n?new rP(e,r):"in"===n?new rL(e,r):"not-in"===n?new rM(e,r):"array-contains-any"===n?new rU(e,r):new t(e,n,r)}},{key:"createKeyFieldInFilter",value:function(e,t,n){return"in"===t?new rR(e,n):new rN(e,n)}}]),t}(rw),rT=function(e){function t(e,n){var r;return(0,O._)(this,t),(r=(0,V._)(this,t)).filters=e,r.op=n,r.ae=null,r}return(0,z._)(t,e),(0,P._)(t,[{key:"matches",value:function(e){return rE(this)?void 0===this.filters.find(function(t){return!t.matches(e)}):void 0!==this.filters.find(function(t){return t.matches(e)})}},{key:"getFlattenedFilters",value:function(){return null!==this.ae||(this.ae=this.filters.reduce(function(e,t){return e.concat(t.getFlattenedFilters())},[])),this.ae}},{key:"getFilters",value:function(){return Object.assign([],this.filters)}}],[{key:"create",value:function(e,n){return new t(e,n)}}]),t}(rw);function rE(e){return"and"===e.op}function rS(e){return"or"===e.op}function rC(e){return rx(e)&&rE(e)}function rx(e){var t=!0,n=!1,r=void 0;try{for(var i,a=e.filters[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var o=i.value;if((0,K._)(o,rT))return!1}}catch(e){n=!0,r=e}finally{try{t||null==a.return||a.return()}finally{if(n)throw r}}return!0}function rA(e,t){var n=e.filters.concat(t);return rT.create(n,e.op)}var rD=function(e){function t(e,n,r){var i;return(0,O._)(this,t),(i=(0,V._)(this,t,[e,n,r])).key=tW.fromName(r.referenceValue),i}return(0,z._)(t,e),(0,P._)(t,[{key:"matches",value:function(e){var t=tW.comparator(e.key,this.key);return this.matchesComparison(t)}}]),t}(rI),rR=function(e){function t(e,n){var r;return(0,O._)(this,t),(r=(0,V._)(this,t,[e,"in",n])).keys=rO("in",n),r}return(0,z._)(t,e),(0,P._)(t,[{key:"matches",value:function(e){return this.keys.some(function(t){return t.isEqual(e.key)})}}]),t}(rI),rN=function(e){function t(e,n){var r;return(0,O._)(this,t),(r=(0,V._)(this,t,[e,"not-in",n])).keys=rO("not-in",n),r}return(0,z._)(t,e),(0,P._)(t,[{key:"matches",value:function(e){return!this.keys.some(function(t){return t.isEqual(e.key)})}}]),t}(rI);function rO(e,t){var n;return((null==(n=t.arrayValue)?void 0:n.values)||[]).map(function(e){return tW.fromName(e.referenceValue)})}var rP=function(e){function t(e,n){return(0,O._)(this,t),(0,V._)(this,t,[e,"array-contains",n])}return(0,z._)(t,e),(0,P._)(t,[{key:"matches",value:function(e){var t=e.data.field(this.field);return ro(t)&&n9(t.arrayValue,this.value)}}]),t}(rI),rL=function(e){function t(e,n){return(0,O._)(this,t),(0,V._)(this,t,[e,"in",n])}return(0,z._)(t,e),(0,P._)(t,[{key:"matches",value:function(e){var t=e.data.field(this.field);return null!==t&&n9(this.value.arrayValue,t)}}]),t}(rI),rM=function(e){function t(e,n){return(0,O._)(this,t),(0,V._)(this,t,[e,"not-in",n])}return(0,z._)(t,e),(0,P._)(t,[{key:"matches",value:function(e){if(n9(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;var t=e.data.field(this.field);return null!==t&&!n9(this.value.arrayValue,t)}}]),t}(rI),rU=function(e){function t(e,n){return(0,O._)(this,t),(0,V._)(this,t,[e,"array-contains-any",n])}return(0,z._)(t,e),(0,P._)(t,[{key:"matches",value:function(e){var t=this,n=e.data.field(this.field);return!(!ro(n)||!n.arrayValue.values)&&n.arrayValue.values.some(function(e){return n9(t.value.arrayValue,e)})}}]),t}(rI),rF=function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,o=arguments.length>
15&&void 0!==arguments[5]?arguments[5]:null,s=arguments.length>6&&void 0!==arguments[6]?arguments[6]:null;(0,O._)(this,e),this.path=t,this.collectionGroup=n,this.orderBy=r,this.filters=i,this.limit=a,this.startAt=o,this.endAt=s,this.ue=null};function rV(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null,o=arguments.length>6&&void 0!==arguments[6]?arguments[6]:null;return new rF(e,t,n,r,i,a,o)}function rB(e){if(null===e.ue){var t=e.path.canonicalString();null!==e.collectionGroup&&(t+="|cg:"+e.collectionGroup),t+="|f:",t+=e.filters.map(function(e){return function e(t){if((0,K._)(t,rI))return t.field.canonicalString()+t.op.toString()+rr(t.value);if(rC(t))return t.filters.map(function(t){return e(t)}).join(",");var n=t.filters.map(function(t){return e(t)}).join(",");return"".concat(t.op,"(").concat(n,")")}(e)}).join(","),t+="|ob:",t+=e.orderBy.map(function(e){return e.field.canonicalString()+e.dir}).join(","),nl(e.limit)||(t+="|l:",t+=e.limit),e.startAt&&(t+="|lb:",t+=e.startAt.inclusive?"b:":"a:",t+=e.startAt.position.map(function(e){return rr(e)}).join(",")),e.endAt&&(t+="|ub:",t+=e.endAt.inclusive?"a:":"b:",t+=e.endAt.position.map(function(e){return rr(e)}).join(",")),e.ue=t}return e.ue}function rj(e,t){if(e.limit!==t.limit||e.orderBy.length!==t.orderBy.length)return!1;for(var n,r,i=0;i<e.orderBy.length;i++)if(n=e.orderBy[i],r=t.orderBy[i],!(n.dir===r.dir&&n.field.isEqual(r.field)))return!1;if(e.filters.length!==t.filters.length)return!1;for(var a=0;a<e.filters.length;a++)if(!function e(t,n){return(0,K._)(t,rI)?(0,K._)(n,rI)&&t.op===n.op&&t.field.isEqual(n.field)&&n7(t.value,n.value):(0,K._)(t,rT)?!!(0,K._)(n,rT)&&t.op===n.op&&t.filters.length===n.filters.length&&t.filters.reduce(function(t,r,i){return t&&e(r,n.filters[i])},!0):void tS()}(e.filters[a],t.filters[a]))return!1;return e.collectionGroup===t.collectionGroup&&!!e.path.isEqual(t.path)&&!!rk(e.startAt,t.startAt)&&rk(e.endAt,t.endAt)}function rq(e){return tW.isDocumentKey(e.path)&&null===e.collectionGroup&&0===e.filters.length}function rz(e,t){return e.filters.filter(function(e){return(0,K._)(e,rI)&&e.field.isEqual(t)})}function rK(e,t,n){var r=n6,i=!0,a=!0,o=!1,s=void 0;try{for(var u,c=rz(e,t)[Symbol.iterator]();!(a=(u=c.next()).done);a=!0){var l,h=u.value,f=n6,d=!0;switch(h.op){case"<":case"<=":l=h.value,f="nullValue"in l?n6:"booleanValue"in l?{booleanValue:!1}:"integerValue"in l||"doubleValue"in l?{doubleValue:NaN}:"timestampValue"in l?{timestampValue:{seconds:Number.MIN_SAFE_INTEGER}}:"stringValue"in l?{stringValue:""}:"bytesValue"in l?{bytesValue:""}:"referenceValue"in l?ri(n4.empty(),tW.empty()):"geoPointValue"in l?{geoPointValue:{latitude:-90,longitude:-180}}:"arrayValue"in l?{arrayValue:{}}:"mapValue"in l?rl(l)?rd:{mapValue:{}}:tS();break;case"==":case"in":case">=":f=h.value;break;case">":f=h.value,d=!1;break;case"!=":case"not-in":f=n6}0>rv({value:r,inclusive:i},{value:f,inclusive:d})&&(r=f,i=d)}}catch(e){o=!0,s=e}finally{try{a||null==c.return||c.return()}finally{if(o)throw s}}if(null!==n){for(var v=0;v<e.orderBy.length;++v)if(e.orderBy[v].field.isEqual(t)){var y=n.position[v];0>rv({value:r,inclusive:i},{value:y,inclusive:n.inclusive})&&(r=y,i=n.inclusive);break}}return{value:r,inclusive:i}}function rG(e,t,n){var r=n5,i=!0,a=!0,o=!1,s=void 0;try{for(var u,c=rz(e,t)[Symbol.iterator]();!(a=(u=c.next()).done);a=!0){var l,h=u.value,f=n5,d=!0;switch(h.op){case">=":case">":l=h.value,f="nullValue"in l?{booleanValue:!1}:"booleanValue"in l?{doubleValue:NaN}:"integerValue"in l||"doubleValue"in l?{timestampValue:{seconds:Number.MIN_SAFE_INTEGER}}:"timestampValue"in l?{stringValue:""}:"stringValue"in l?{bytesValue:""}:"bytesValue"in l?ri(n4.empty(),tW.empty()):"referenceValue"in l?{geoPointValue:{latitude:-90,longitude:-180}}:"geoPointValue"in l?{arrayValue:{}}:"arrayValue"in l?rd:"mapValue"in l?rl(l)?{mapValue:{}}:n5:tS(),d=!1;break;case"==":case"in":case"<=":f=h.value;break;case"<":f=h.value,d=!1;break;case"!=":case"not-in":f=n5}ry({value:r,inclusive:i},{value:f,inclusive:d})>0&&(r=f,i=d)}}catch(e){o=!0,s=e}finally{try{a||null==c.return||c.return()}finally{if(o)throw s}}if(null!==n){for(var v=0;v<e.orderBy.length;++v)if(e.orderBy[v].field.isEqual(t)){var y=n.position[v];ry({value:r,inclusive:i},{value:y,inclusive:n.inclusive})>0&&(r=y,i=n.inclusive);break}}return{value:r,inclusive:i}}var rH=function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"F",s=arguments.length>6&&void 0!==arguments[6]?arguments[6]:null,u=arguments.length>7&&void 0!==arguments[7]?arguments[7]:null;(0,O._)(this,e),this.path=t,this.collectionGroup=n,this.explicitOrderBy=r,this.filters=i,this.limit=a,this.limitType=o,this.startAt=s,this.endAt=u,this.ce=null,this.le=null,this.he=null,this.startAt,this.endAt};function rW(e){return new rH(e)}function rQ(e){return 0===e.filters.length&&null===e.limit&&null==e.startAt&&null==e.endAt&&(0===e.explicitOrderBy.length||1===e.explicitOrderBy.length&&e.explicitOrderBy[0].field.isKeyField())}function rJ(e){return null!==e.collectionGroup}function rX(e){if(null===e.ce){e.ce=[];var t,n=new Set,r=!0,i=!1,a=void 0;try{for(var o,s=e.explicitOrderBy[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var u=o.value;e.ce.push(u),n.add(u.field.canonicalString())}}catch(e){i=!0,a=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw a}}var c=e.explicitOrderBy.length>0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";
1(t=new nK(tH.comparator),e.filters.forEach(function(e){e.getFlattenedFilters().forEach(function(e){e.isInequality()&&(t=t.add(e.field))})}),t).forEach(function(t){n.has(t.canonicalString())||t.isKeyField()||e.ce.push(new rb(t,c))}),n.has(tH.keyField().canonicalString())||e.ce.push(new rb(tH.keyField(),c))}return e.ce}function rY(e){return e.le||(e.le=function(e,t){if("F"===e.limitType)return rV(e.path,e.collectionGroup,t,e.filters,e.limit,e.startAt,e.endAt);t=t.map(function(e){var t="desc"===e.dir?"asc":"desc";return new rb(e.field,t)});var n=e.endAt?new rg(e.endAt.position,e.endAt.inclusive):null,r=e.startAt?new rg(e.startAt.position,e.startAt.inclusive):null;return rV(e.path,e.collectionGroup,t,e.filters,e.limit,n,r)}(e,rX(e))),e.le}function r$(e,t){var n=e.filters.concat([t]);return new rH(e.path,e.collectionGroup,e.explicitOrderBy.slice(),n,e.limit,e.limitType,e.startAt,e.endAt)}function rZ(e,t,n){return new rH(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),t,n,e.startAt,e.endAt)}function r0(e,t){return rj(rY(e),rY(t))&&e.limitType===t.limitType}function r1(e){return"".concat(rB(rY(e)),"|lt:").concat(e.limitType)}function r2(e){var t,n;return"Query(target=".concat((n=(t=rY(e)).path.canonicalString(),null!==t.collectionGroup&&(n+=" collectionGroup="+t.collectionGroup),t.filters.length>0&&(n+=", filters: [".concat(t.filters.map(function(e){return function e(t){return(0,K._)(t,rI)?"".concat(t.field.canonicalString()," ").concat(t.op," ").concat(rr(t.value)):(0,K._)(t,rT)?t.op.toString()+" {"+t.getFilters().map(e).join(" ,")+"}":"Filter"}(e)}).join(", "),"]")),nl(t.limit)||(n+=", limit: "+t.limit),t.orderBy.length>0&&(n+=", orderBy: [".concat(t.orderBy.map(function(e){return"".concat(e.field.canonicalString()," (").concat(e.dir,")")}).join(", "),"]")),t.startAt&&(n+=", startAt: ",n+=t.startAt.inclusive?"b:":"a:",n+=t.startAt.position.map(function(e){return rr(e)}).join(",")),t.endAt&&(n+=", endAt: ",n+=t.endAt.inclusive?"a:":"b:",n+=t.endAt.position.map(function(e){return rr(e)}).join(",")),"Target(".concat(n,")")),"; limitType=").concat(e.limitType,")")}function r3(e,t){var n,r,i,a,o,s,u;return t.isFoundDocument()&&(n=t.key.path,null!==e.collectionGroup?t.key.hasCollectionId(e.collectionGroup)&&e.path.isPrefixOf(n):tW.isDocumentKey(e.path)?e.path.isEqual(n):e.path.isImmediateParentOf(n))&&function(e,t){var n=!0,r=!1,i=void 0;try{for(var a,o=rX(e)[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){var s=a.value;if(!s.field.isKeyField()&&null===t.data.field(s.field))return!1}}catch(e){r=!0,i=e}finally{try{n||null==o.return||o.return()}finally{if(r)throw i}}return!0}(e,t)&&function(e,t){var n=!0,r=!1,i=void 0;try{for(var a,o=e.filters[Symbol.iterator]();!(n=(a=o.next()).done);n=!0)if(!a.value.matches(t))return!1}catch(e){r=!0,i=e}finally{try{n||null==o.return||o.return()}finally{if(r)throw i}}return!0}(e,t)&&(r=e,i=t,(!r.startAt||(a=r.startAt,o=r_(a,rX(r),i),a.inclusive?!!(o<=0):!!(o<0)))&&(!r.endAt||(s=r.endAt,u=r_(s,rX(r),i),s.inclusive?!!(u>=0):!!(u>0))))}function r4(e){return e.collectionGroup||(e.path.length%2==1?e.path.lastSegment():e.path.get(e.path.length-2))}function r5(e){return function(t,n){var r=!1,i=!0,a=!1,o=void 0;try{for(var s,u=rX(e)[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var c=s.value,l=function(e,t,n){var r,i,a,o=e.field.isKeyField()?tW.comparator(t.key,n.key):(r=e.field,i=t.data.field(r),a=n.data.field(r),null!==i&&null!==a?re(i,a):tS());switch(e.dir){case"asc":return o;case"desc":return -1*o;default:return tS()}}(c,t,n);if(0!==l)return l;r=r||c.field.isKeyField()}}catch(e){a=!0,o=e}finally{try{i||null==u.return||u.return()}finally{if(a)throw o}}return 0}}var r6=function(){function e(t,n){(0,O._)(this,e),this.mapKeyFn=t,this.equalsFn=n,this.inner={},this.innerSize=0}return(0,P._)(e,[{key:"get",value:function(e){var t=this.mapKeyFn(e),n=this.inner[t],r=!0,i=!1,a=void 0;if(void 0!==n)try{for(var o,s=n[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var u=(0,D._)(o.value,2),c=u[0],l=u[1];if(this.equalsFn(c,e))return l}}catch(e){i=!0,a=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw a}}}},{key:"has",value:function(e){return void 0!==this.get(e)}},{key:"set",value:function(e,t){var n=this.mapKeyFn(e),r=this.inner[n];if(void 0===r)return this.inner[n]=[[e,t]],void this.innerSize++;for(var i=0;i<r.length;i++)if(this.equalsFn(r[i][0],e))return void(r[i]=[e,t]);
1r.push([e,t]),this.innerSize++}},{key:"delete",value:function(e){var t=this.mapKeyFn(e),n=this.inner[t];if(void 0===n)return!1;for(var r=0;r<n.length;r++)if(this.equalsFn(n[r][0],e))return 1===n.length?delete this.inner[t]:n.splice(r,1),this.innerSize--,!0;return!1}},{key:"forEach",value:function(e){nV(this.inner,function(t,n){var r=!0,i=!1,a=void 0;try{for(var o,s=n[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var u=(0,D._)(o.value,2),c=u[0],l=u[1];e(c,l)}}catch(e){i=!0,a=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw a}}})}},{key:"isEmpty",value:function(){return nB(this.inner)}},{key:"size",value:function(){return this.innerSize}}]),e}(),r8=new nj(tW.comparator),r7=new nj(tW.comparator);function r9(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=r7,i=!0,a=!1,o=void 0;try{for(var s,u=t[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var c=s.value;r=r.insert(c.key,c)}}catch(e){a=!0,o=e}finally{try{i||null==u.return||u.return()}finally{if(a)throw o}}return r}function ie(){return new r6(function(e){return e.toString()},function(e,t){return e.isEqual(t)})}var it=new nj(tW.comparator),ir=new nK(tW.comparator);function ii(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=ir,i=!0,a=!1,o=void 0;try{for(var s,u=t[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var c=s.value;r=r.add(c)}}catch(e){a=!0,o=e}finally{try{i||null==u.return||u.return()}finally{if(a)throw o}}return r}var ia=new nK(tV);function io(e,t){if(e.useProto3Json){if(isNaN(t))return{doubleValue:"NaN"};if(t===1/0)return{doubleValue:"Infinity"};if(t===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:nh(t)?"-0":t}}function is(e){return{integerValue:""+e}}function iu(e,t){return nf(t)?is(t):io(e,t)}var ic=function e(){(0,O._)(this,e),this._=void 0},il=function(e){function t(){return(0,O._)(this,t),(0,V._)(this,t,arguments)}return(0,z._)(t,e),t}(ic),ih=function(e){function t(e){var n;return(0,O._)(this,t),(n=(0,V._)(this,t)).elements=e,n}return(0,z._)(t,e),t}(ic);function id(e,t){var n=ig(t),r=!0,i=!1,a=void 0;try{for(var o,s=e.elements[Symbol.iterator]();!(r=(o=s.next()).done);r=!0)!function(){var e=o.value;n.some(function(t){return n7(t,e)})||n.push(e)}()}catch(e){i=!0,a=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw a}}return{arrayValue:{values:n}}}var iv=function(e){function t(e){var n;return(0,O._)(this,t),(n=(0,V._)(this,t)).elements=e,n}return(0,z._)(t,e),t}(ic);function iy(e,t){var n=ig(t),r=!0,i=!1,a=void 0;try{for(var o,s=e.elements[Symbol.iterator]();!(r=(o=s.next()).done);r=!0)!function(){var e=o.value;n=n.filter(function(t){return!n7(t,e)})}()}catch(e){i=!0,a=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw a}}return{arrayValue:{values:n}}}var ip=function(e){function t(e,n){var r;return(0,O._)(this,t),(r=(0,V._)(this,t)).serializer=e,r.Pe=n,r}return(0,z._)(t,e),t}(ic);function im(e){return n$(e.integerValue||e.doubleValue)}function ig(e){return ro(e)&&e.arrayValue.values?e.arrayValue.values.slice():[]}var i_=function e(t,n){(0,O._)(this,e),this.field=t,this.transform=n},ik=function e(t,n){(0,O._)(this,e),this.version=t,this.transformResults=n},ib=function(){function e(t,n){(0,O._)(this,e),this.updateTime=t,this.exists=n}return(0,P._)(e,[{key:"isNone",get:function(){return void 0===this.updateTime&&void 0===this.exists}},{key:"isEqual",value:function(e){return this.exists===e.exists&&(this.updateTime?!!e.updateTime&&this.updateTime.isEqual(e.updateTime):!e.updateTime)}}],[{key:"none",value:function(){return new e}},{key:"exists",value:function(t){return new e(void 0,t)}},{key:"updateTime",value:function(t){return new e(t)}}]),e}();function iw(e,t){return void 0!==e.updateTime?t.isFoundDocument()&&t.version.isEqual(e.updateTime):void 0===e.exists||e.exists===t.isFoundDocument()}var iI=function e(){(0,O._)(this,e)};function iT(e,t){if(!e.hasLocalMutations||t&&0===t.fields.length)return null;if(null===t)return e.isNoDocument()?new iN(e.key,ib.none()):new iC(e.key,e.data,ib.none());var n=e.data,r=rp.empty(),i=new nK(tH.comparator),a=!0,o=!1,s=void 0;try{for(var u,c=t.fields[Symbol.iterator]();!(a=(u=c.next()).done);a=!0){var l=u.value;if(!i.has(l)){var h=n.field(l);null===h&&l.length>1&&(l=l.popLast(),h=n.field(l)),null===h?r.delete(l):r.set(l,h),i=i.add(l)}}}catch(e){o=!0,s=e}finally{try{a||null==c.return||c.return()}finally{if(o)throw s}}return new ix(e.key,r,new nW(i.toArray()),ib.none())}function iE(e,t,n,r){return(0,K._)(e,iC)?function(e,t,n,r){if(!iw(e.precondition,t))return n;var i=e.value.clone(),a=iR(e.fieldTransforms,r,t);return i.setAll(a),t.convertToFoundDocument(t.version,i).setHasLocalMutations(),null}(e,t,n,r):(0,K._)(e,ix)?function(e,t,n,r){if(!iw(e.precondition,t))return n;var i=iR(e.fieldTransforms,r,t),a=t.data;return(a.setAll(iA(e)),a.setAll(i),t.convertToFoundDocument(t.version,a).setHasLocalMutations(),null===n)?null:n.unionWith(e.fieldMask.fields).unionWith(e.fieldTransforms.map(function(e){return e.field}))}(e,t,n,r):iw(e.precondition,t)?(t.convertToNoDocument(t.version).setHasLocalMutations(),null):n}function iS(e,t){var n,r;return e.type===t.type&&!!e.key.isEqual(t.key)&&!!e.precondition.isEqual(t.precondition)&&(n=e.fieldTransforms,r=t.fieldTransforms,!!(void 0===n&&void 0===r||!(!n||!r)&&tB(n,r,function(e,t){var n,r;return e.field.isEqual(t.field)&&(n=e.transform,r=t.transform,(0,K._)(n,ih)&&(0,K._)(r,ih)||(0,K._)(n,iv)&&(0,K._)(r,iv)?tB(n.elements,r.elements,n7):(0,K._)(n,ip)&&(0,K._)(r,ip)?n7(n.Pe,r.Pe):(0,K._)(n,il)&&(0,K._)(r,il))})))&&(0===e.type?e.value.isEqual(t.value):1!==e.type||e.data.isEqual(t.data)&&e.fieldMask.isEqual(t.fieldMask))}var iC=function(e){function t(e,n,r){var i,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];return(0,O._)(this,t),(i=(0,V._)(this,t)).key=e,i.value=n,i.precondition=r,i.fieldTransforms=a,i.type=0,i}return(0,z._)(t,e),(0,P._)(t,[{key:"getFieldMask",value:function(){return null}}]),t}(iI),ix=function(e){function t(e,n,r,i){var a,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[];return(0,O._)(this,t),(a=(0,V._)(this,t)).key=e,a.data=n,a.fieldMask=r,a.prec
1ondition=i,a.fieldTransforms=o,a.type=1,a}return(0,z._)(t,e),(0,P._)(t,[{key:"getFieldMask",value:function(){return this.fieldMask}}]),t}(iI);function iA(e){var t=new Map;return e.fieldMask.fields.forEach(function(n){if(!n.isEmpty()){var r=e.data.field(n);t.set(n,r)}}),t}function iD(e,t,n){var r=new Map;e.length===n.length||tS();for(var i=0;i<n.length;i++){var a,o=e[i],s=o.transform,u=t.data.field(o.field);r.set(o.field,(a=n[i],(0,K._)(s,ih)?id(s,u):(0,K._)(s,iv)?iy(s,u):a))}return r}function iR(e,t,n){var r=new Map,i=!0,a=!1,o=void 0;try{for(var s,u=e[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var c=s.value,l=c.transform,h=n.data.field(c.field);r.set(c.field,function(e,t,n){var r,i,a,o;return(0,K._)(e,il)?(r=t,i={fields:{__type__:{stringValue:"server_timestamp"},__local_write_time__:{timestampValue:{seconds:n.seconds,nanos:n.nanoseconds}}}},r&&n0(r)&&(r=n1(r)),r&&(i.fields.__previous_value__=r),{mapValue:i}):(0,K._)(e,ih)?id(e,t):(0,K._)(e,iv)?iy(e,t):(o=im(a=function(e,t){return(0,K._)(e,ip)?ra(t)||t&&"doubleValue"in t?t:{integerValue:0}:null}(e,t))+im(e.Pe),ra(a)&&ra(e.Pe)?is(o):io(e.serializer,o))}(l,h,t))}}catch(e){a=!0,o=e}finally{try{i||null==u.return||u.return()}finally{if(a)throw o}}return r}var iN=function(e){function t(e,n){var r;return(0,O._)(this,t),(r=(0,V._)(this,t)).key=e,r.precondition=n,r.type=2,r.fieldTransforms=[],r}return(0,z._)(t,e),(0,P._)(t,[{key:"getFieldMask",value:function(){return null}}]),t}(iI),iO=function(e){function t(e,n){var r;return(0,O._)(this,t),(r=(0,V._)(this,t)).key=e,r.precondition=n,r.type=3,r.fieldTransforms=[],r}return(0,z._)(t,e),(0,P._)(t,[{key:"getFieldMask",value:function(){return null}}]),t}(iI),iP=function(){function e(t,n,r,i){(0,O._)(this,e),this.batchId=t,this.localWriteTime=n,this.baseMutations=r,this.mutations=i}return(0,P._)(e,[{key:"applyToRemoteDocument",value:function(e,t){for(var n=t.mutationResults,r=0;r<this.mutations.length;r++){var i=this.mutations[r];i.key.isEqual(e.key)&&function(e,t,n){var r,i;(0,K._)(e,iC)?(r=e.value.clone(),i=iD(e.fieldTransforms,t,n.transformResults),r.setAll(i),t.convertToFoundDocument(n.version,r).setHasCommittedMutations()):(0,K._)(e,ix)?function(e,t,n){if(!iw(e.precondition,t))return t.convertToUnknownDocument(n.version);var r=iD(e.fieldTransforms,t,n.transformResults),i=t.data;i.setAll(iA(e)),i.setAll(r),t.convertToFoundDocument(n.version,i).setHasCommittedMutations()}(e,t,n):t.convertToNoDocument(n.version).setHasCommittedMutations()}(i,e,n[r])}}},{key:"applyToLocalView",value:function(e,t){var n=!0,r=!1,i=void 0;try{for(var a,o=this.baseMutations[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){var s=a.value;s.key.isEqual(e.key)&&(t=iE(s,e,t,this.localWriteTime))}}catch(e){r=!0,i=e}finally{try{n||null==o.return||o.return()}finally{if(r)throw i}}var u=!0,c=!1,l=void 0;try{for(var h,f=this.mutations[Symbol.iterator]();!(u=(h=f.next()).done);u=!0){var d=h.value;d.key.isEqual(e.key)&&(t=iE(d,e,t,this.localWriteTime))}}catch(e){c=!0,l=e}finally{try{u||null==f.return||f.return()}finally{if(c)throw l}}return t}},{key:"applyToLocalDocumentSet",value:function(e,t){var n=this,r=ie();return this.mutations.forEach(function(i){var a=e.get(i.key),o=a.overlayedDocument,s=n.applyToLocalView(o,a.mutatedFields),u=iT(o,s=t.has(i.key)?null:s);null!==u&&r.set(i.key,u),o.isValidDocument()||o.convertToNoDocument(tq.min())}),r}},{key:"keys",value:function(){return this.mutations.reduce(function(e,t){return e.add(t.key)},ii())}},{key:"isEqual",value:function(e){return this.batchId===e.batchId&&tB(this.mutations,e.mutations,function(e,t){return iS(e,t)})&&tB(this.baseMutations,e.baseMutations,function(e,t){return iS(e,t)})}}]),e}(),iL=function(){function e(t,n,r,i){(0,O._)(this,e),this.batch=t,this.commitVersion=n,this.mutationResults=r,this.docVersions=i}return(0,P._)(e,null,[{key:"from",value:function(t,n,r){t.mutations.length===r.length||tS();for(var i=it,a=t.mutations,o=0;o<a.length;o++)i=i.insert(a[o].key,r[o].version);return new e(t,n,r,i)}}]),e}(),iM=function(){function e(t,n){(0,O._)(this,e),this.largestBatchId=t,this.mutation=n}return(0,P._)(e,[{key:"getKey",value:function(){return this.mutation.key}},{key:"isEqual",value:function(e){return null!==e&&this.mutation===e.mutation}},{key:"toString",value:function(){return"Overlay{\n largestBatchId: ".concat(this.largestBatchId,",\n mutation: ").concat(this.mutation.toString(),"\n }")}}]),e}(),iU=function e(t,n){(0,O._)(this,e),this.count=t,this.unchangedNames=n};function iF(e){switch(e){default:return tS();case tC.CANCELLED:case tC.UNKNOWN:case tC.DEADLINE_EXCEEDED:case tC.RESOURCE_EXHAUSTED:case tC.INTERNAL:case tC.UNAVAILABLE:case tC.UNAUTHENTICATED:return!1;case tC.INVALID_ARGUMENT:case tC.NOT_FOUND:case tC.ALREADY_EXISTS:case tC.PERMISSION_DENIED:case tC.FAILED_PRECONDITION:case tC.ABORTED:case tC.OUT_OF_RANGE:case tC.UNIMPLEMENT
1ED:case tC.DATA_LOSS:return!0}}function iV(e){if(void 0===e)return tI("GRPC error has no .code"),tC.UNKNOWN;switch(e){case k.OK:return tC.OK;case k.CANCELLED:return tC.CANCELLED;case k.UNKNOWN:return tC.UNKNOWN;case k.DEADLINE_EXCEEDED:return tC.DEADLINE_EXCEEDED;case k.RESOURCE_EXHAUSTED:return tC.RESOURCE_EXHAUSTED;case k.INTERNAL:return tC.INTERNAL;case k.UNAVAILABLE:return tC.UNAVAILABLE;case k.UNAUTHENTICATED:return tC.UNAUTHENTICATED;case k.INVALID_ARGUMENT:return tC.INVALID_ARGUMENT;case k.NOT_FOUND:return tC.NOT_FOUND;case k.ALREADY_EXISTS:return tC.ALREADY_EXISTS;case k.PERMISSION_DENIED:return tC.PERMISSION_DENIED;case k.FAILED_PRECONDITION:return tC.FAILED_PRECONDITION;case k.ABORTED:return tC.ABORTED;case k.OUT_OF_RANGE:return tC.OUT_OF_RANGE;case k.UNIMPLEMENTED:return tC.UNIMPLEMENTED;case k.DATA_LOSS:return tC.DATA_LOSS;default:return tS()}}(b=k||(k={}))[b.OK=0]="OK",b[b.CANCELLED=1]="CANCELLED",b[b.UNKNOWN=2]="UNKNOWN",b[b.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",b[b.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",b[b.NOT_FOUND=5]="NOT_FOUND",b[b.ALREADY_EXISTS=6]="ALREADY_EXISTS",b[b.PERMISSION_DENIED=7]="PERMISSION_DENIED",b[b.UNAUTHENTICATED=16]="UNAUTHENTICATED",b[b.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",b[b.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",b[b.ABORTED=10]="ABORTED",b[b.OUT_OF_RANGE=11]="OUT_OF_RANGE",b[b.UNIMPLEMENTED=12]="UNIMPLEMENTED",b[b.INTERNAL=13]="INTERNAL",b[b.UNAVAILABLE=14]="UNAVAILABLE",b[b.DATA_LOSS=15]="DATA_LOSS";var iB=null,ij=new l([0xffffffff,0xffffffff],0);function iq(e){var t=(new TextEncoder).encode(e),n=new h;return n.update(t),new Uint8Array(n.digest())}function iz(e){var t=new DataView(e.buffer),n=t.getUint32(0,!0),r=t.getUint32(4,!0),i=t.getUint32(8,!0),a=t.getUint32(12,!0);return[new l([n,r],0),new l([i,a],0)]}var iK=function(){function e(t,n,r){if((0,O._)(this,e),this.bitmap=t,this.padding=n,this.hashCount=r,n<0||n>=8)throw new iG("Invalid padding: ".concat(n));if(r<0||t.length>0&&0===this.hashCount)throw new iG("Invalid hash count: ".concat(r));if(0===t.length&&0!==n)throw new iG("Invalid padding when bitmap length is 0: ".concat(n));this.Te=8*t.length-n,this.Ie=l.fromNumber(this.Te)}return(0,P._)(e,[{key:"Ee",value:function(e,t,n){var r=e.add(t.multiply(l.fromNumber(n)));return 1===r.compare(ij)&&(r=new l([r.getBits(0),r.getBits(1)],0)),r.modulo(this.Ie).toNumber()}},{key:"de",value:function(e){return 0!=(this.bitmap[Math.floor(e/8)]&1<<e%8)}},{key:"mightContain",value:function(e){if(0===this.Te)return!1;for(var t=iq(e),n=(0,D._)(iz(t),2),r=n[0],i=n[1],a=0;a<this.hashCount;a++){var o=this.Ee(r,i,a);if(!this.de(o))return!1}return!0}},{key:"insert",value:function(e){if(0!==this.Te)for(var t=iq(e),n=(0,D._)(iz(t),2),r=n[0],i=n[1],a=0;a<this.hashCount;a++){var o=this.Ee(r,i,a);this.Ae(o)}}},{key:"Ae",value:function(e){var t=Math.floor(e/8);this.bitmap[t]|=1<<e%8}}],[{key:"create",value:function(t,n,r){var i=new e(new Uint8Array(Math.ceil(t/8)),t%8==0?0:8-t%8,n);return r.forEach(function(e){return i.insert(e)}),i}}]),e}(),iG=function(e){function t(){var e;return(0,O._)(this,t),e=(0,V._)(this,t,arguments),e.name="BloomFilterError",e}return(0,z._)(t,e),t}((0,H._)(Error)),iH=function(){function e(t,n,r,i,a){(0,O._)(this,e),this.snapshotVersion=t,this.targetChanges=n,this.targetMismatches=r,this.documentUpdates=i,this.resolvedLimboDocuments=a}return(0,P._)(e,null,[{key:"createSynthesizedRemoteEventForCurrentChange",value:function(t,n,r){var i=new Map;return i.set(t,iW.createSynthesizedTargetChangeForCurrentChange(t,n,r)),new e(tq.min(),i,new nj(tV),r8,ii())}}]),e}(),iW=function(){function e(t,n,r,i,a){(0,O._)(this,e),this.resumeToken=t,this.current=n,this.addedDocuments=r,this.modifiedDocuments=i,this.removedDocuments=a}return(0,P._)(e,null,[{key:"createSynthesizedTargetChangeForCurrentChange",value:function(t,n,r){return new e(r,n,ii(),ii(),ii())}}]),e}(),iQ=function e(t,n,r,i){(0,O._)(this,e),this.Re=t,this.removedTargetIds=n,this.key=r,this.Ve=i},iJ=function e(t,n){(0,O._)(this,e),this.targetId=t,this.me=n},iX=function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:nJ.EMPTY_BYTE_STRING,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;(0,O._)(this,e),this.state=t,this.targetIds=n,this.resumeToken=r,this.cause=i},iY=function(){function e(){(0,O._)(this,e),this.fe=0,this.ge=i0(),this.pe=nJ.EMPTY_BYTE_STRING,this.ye=!1,this.we=!0}return(0,P._)(e,[{key:"current",get:function(){return this.ye}},{key:"resumeToken",get:function(){return this.pe}},{key:"Se",get:function(){return 0!==this.fe}},{key:"be",get:function(){return this.we}},{key:"De",value:function(e){e.approximateByteSize()>0&&(this.we=!0,this.pe=e)}},{key:"ve",value:function(){var e=ii(),t=ii(),n=ii();return this.ge.forEach(function(r,i){switch(i){case 0:e=e.add(r);break;case 2:t=t.add(r);break;case 1:n=n.add(r);break;default:tS()}}),new iW(this.pe,this.ye,e,t,n)}},{key:"Ce",value:function(){this.we=!1,this.ge=i0()}},{key:"Fe",value:function(e,t){this.we=!0,this.ge=this.ge.insert(e,t)}},{key:"Me",value:function(e){this.we=!0,this.ge=this.ge.remove(e)}},{key:"xe",value:function(){this.fe+=1}},{key:"Oe",value:function(){this.fe-=1,this.fe>=0||tS()}},{key:"Ne",value:function(){this.we=!0,this.ye=!0}}]),e}(),i$=function(){function e(t){(0,O._)(this,e),this.Le=t,this.Be=new Map,this.ke=r8,this.qe=iZ(),this.Qe=iZ(),this.Ke=new nj(tV)}return(0,P._)(e,[{key:"$e",value:function(e){var t=!0,n=!1,r=void 0;try{for(var i,a=e.Re[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var o=i.value;e.Ve&&e.Ve.isFoundDocument()?this.Ue(o,e.Ve):this.We(o,e.key,e.Ve)}}catch(e){n=!0,r=e}finally{try{t||null==a.return||a.return()}finally{if(n)throw r}}
1var s=!0,u=!1,c=void 0;try{for(var l,h=e.removedTargetIds[Symbol.iterator]();!(s=(l=h.next()).done);s=!0){var f=l.value;this.We(f,e.key,e.Ve)}}catch(e){u=!0,c=e}finally{try{s||null==h.return||h.return()}finally{if(u)throw c}}}},{key:"Ge",value:function(e){var t=this;this.forEachTarget(e,function(n){var r=t.ze(n);switch(e.state){case 0:t.je(n)&&r.De(e.resumeToken);break;case 1:r.Oe(),r.Se||r.Ce(),r.De(e.resumeToken);break;case 2:r.Oe(),r.Se||t.removeTarget(n);break;case 3:t.je(n)&&(r.Ne(),r.De(e.resumeToken));break;case 4:t.je(n)&&(t.He(n),r.De(e.resumeToken));break;default:tS()}})}},{key:"forEachTarget",value:function(e,t){var n=this;e.targetIds.length>0?e.targetIds.forEach(t):this.Be.forEach(function(e,r){n.je(r)&&t(r)})}},{key:"Je",value:function(e){var t=e.targetId,n=e.me.count,r=this.Ye(t);if(r){var i=r.target;if(rq(i))if(0===n){var a=new tW(i.path);this.We(t,a,rm.newNoDocument(a,tq.min()))}else 1===n||tS();else{var o=this.Ze(t);if(o!==n){var s,u,c,l,h,f,d,v,y,p,m=this.Xe(e),g=m?this.et(m,e,o):1;0!==g&&(this.He(t),this.Ke=this.Ke.insert(t,2===g?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch")),null==iB||iB.tt((s=e.me,u=this.Le.nt(),y={localCacheCount:o,existenceFilterCount:s.count,databaseId:u.database,projectId:u.projectId},(p=s.unchangedNames)&&(y.bloomFilter={applied:0===g,hashCount:null!=(c=null==p?void 0:p.hashCount)?c:0,bitmapLength:null!=(f=null==(h=null==(l=null==p?void 0:p.bits)?void 0:l.bitmap)?void 0:h.length)?f:0,padding:null!=(v=null==(d=null==p?void 0:p.bits)?void 0:d.padding)?v:0,mightContain:function(e){var t;return null!=(t=null==m?void 0:m.mightContain(e))&&t}}),y))}}}}},{key:"Xe",value:function(e){var t,n,r=e.me.unchangedNames;if(!r||!r.bits)return null;var i=r.bits,a=i.bitmap,o=i.padding,s=r.hashCount;try{t=nZ(void 0===a?"":a).toUint8Array()}catch(e){if((0,K._)(e,nQ))return tT("Decoding the base64 bloom filter in existence filter failed ("+e.message+"); ignoring the bloom filter and falling back to full re-query."),null;throw e}try{n=new iK(t,void 0===o?0:o,void 0===s?0:s)}catch(e){return tT((0,K._)(e,iG)?"BloomFilter error: ":"Applying bloom filter failed: ",e),null}return 0===n.Te?null:n}},{key:"et",value:function(e,t,n){return 2*(t.me.count!==n-this.rt(e,t.targetId))}},{key:"rt",value:function(e,t){var n=this,r=this.Le.getRemoteKeysForTarget(t),i=0;return r.forEach(function(r){var a=n.Le.nt(),o="projects/".concat(a.projectId,"/databases/").concat(a.database,"/documents/").concat(r.path.canonicalString());e.mightContain(o)||(n.We(t,r,null),i++)}),i}},{key:"it",value:function(e){var t=this,n=new Map;this.Be.forEach(function(r,i){var a=t.Ye(i);if(a){if(r.current&&rq(a.target)){var o=new tW(a.target.path);t.st(o).has(i)||t.ot(i,o)||t.We(i,o,rm.newNoDocument(o,e))}r.be&&(n.set(i,r.ve()),r.Ce())}});var r=ii();this.Qe.forEach(function(e,n){var i=!0;n.forEachWhile(function(e){var n=t.Ye(e);return!n||"TargetPurposeLimboResolution"===n.purpose||(i=!1,!1)}),i&&(r=r.add(e))}),this.ke.forEach(function(t,n){return n.setReadTime(e)});var i=new iH(e,n,this.Ke,this.ke,r);return this.ke=r8,this.qe=iZ(),this.Qe=iZ(),this.Ke=new nj(tV),i}},{key:"Ue",value:function(e,t){if(this.je(e)){var n=2*!!this.ot(e,t.key);this.ze(e).Fe(t.key,n),this.ke=this.ke.insert(t.key,t),this.qe=this.qe.insert(t.key,this.st(t.key).add(e)),this.Qe=this.Qe.insert(t.key,this._t(t.key).add(e))}}},{key:"We",value:function(e,t,n){if(this.je(e)){var r=this.ze(e);this.ot(e,t)?r.Fe(t,1):r.Me(t),this.Qe=this.Qe.insert(t,this._t(t).delete(e)),this.Qe=this.Qe.insert(t,this._t(t).add(e)),n&&(this.ke=this.ke.insert(t,n))}}},{key:"removeTarget",value:function(e){this.Be.delete(e)}},{key:"Ze",value:function(e){var t=this.ze(e).ve();return this.Le.getRemoteKeysForTarget(e).size+t.addedDocuments.size-t.removedDocuments.size}},{key:"xe",value:function(e){this.ze(e).xe()}},{key:"ze",value:function(e){var t=this.Be.get(e);return t||(t=new iY,this.Be.set(e,t)),t}},{key:"_t",value:function(e){var t=this.Qe.get(e);return t||(t=new nK(tV),this.Qe=this.Qe.insert(e,t)),t}},{key:"st",value:function(e){var t=this.qe.get(e);return t||(t=new nK(tV),this.qe=this.qe.insert(e,t)),t}},{key:"je",value:function(e){var t=null!==this.Ye(e);return t||tw("WatchChangeAggregator","Detected inactive target",e),t}},{key:"Ye",value:function(e){var t=this.Be.get(e);return t&&t.Se?null:this.Le.ut(e)}},{key:"He",value:function(e){var t=this;this.Be.set(e,new iY),this.Le.getRemoteKeysForTarget(e).forEach(function(n){t.We(e,n,null)})}},{key:"ot",value:function(e,t){return this.Le.getRemoteKeysForTarget(e).has(t)}}]),e}();function iZ(){return new nj(tW.comparator)}function i0(){return new nj(tW.comparator)}var i1={asc:"ASCENDING",desc:"DESCENDING"},i2={"<":"LESS_THAN","<=":"LESS_THAN_OR_EQUAL",">":"GREATER_THAN",">=":"GREATER_THAN_OR_EQUAL","==":"EQUAL","!=":"NOT_EQUAL","array-contains":"ARRAY_CONTAINS",in:"IN","not-in":"NOT_IN","array-contains-any":"ARRAY_CONTAINS_ANY"},i3={and:"AND",or:"OR"},i4=function e(t,n){(0,O._)(this,e),this.databaseId=t,this.useProto3Json=n};function i5(e,t){return e.useProto3Json||nl(t)?t:{value:t}}function i6(e,t){return e.useProto3Json?"".concat(new Date(1e3*t.seconds).toISOString().replace(/\.\d*/,"").replace("Z",""),".").concat(("000000000"+t.nanoseconds).slice(-9),"Z"):{seconds:""+t.seconds,nanos:t.nanoseconds}}function i8(e,t){return e.useProto3Json?t.toBase64():t.toUint8Array()}function i7(e){var t;return e||tS(),tq.fromTimestamp(new tj((t=nY(e)).seconds,t.nanos))}function i9(e,t){return ae(e,t).canonicalString()}function ae(e,t){var n=new tK(["projects",e.projectId,"databases",e.database]).child("documents");return void 0===t?n:n.child(t)}function at(e){var t=tK.fromString(e);return am(t)||tS(),t}function an(e,t){return i9(e.databaseId,t.path)}function ar(e,t){var n=at(t);if(n.get(1)!==e.databaseId.projectId)throw new tx(tC.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+n.get(1)+" vs "+e.databaseId.projectId);if(n.get(3)!==e.databaseId.database)throw new tx(tC.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+n.get(3)+" vs "+e.databaseId.database);return new tW(as(n))}function ai(e,t){return i9(e.databaseId,t)}function aa(e){var t=at(e);return 4===t.length?tK.emptyPath():as(t)}function ao(e){return new tK(["projects",e.databaseId.projectId,"databases",e.databaseId.database]).canonicalString()}function as(e){return e.length>4&&"documents"===e.get(4)||tS(),e.popFirst(5)}function au(e,t,n){return{name:an(e,t),fields:n.value.mapValue.fields}}function ac(e,t,n){var r=ar(e,t.name),i=i7(t.updateTime),a=t.createTime?i7(t.createTime):tq.min(),o=new rp({mapValue:{fields:t.fields}}),s=rm.newFoundDocument(r,i,a,o);return n&&s.setHasCommittedMutations(),n?s.setHasCommittedMutations():s}function al(e,t){var n,r,i,a;if((0,K._)(t,iC))n={update:au(e,t.key,t.value)};else if((0,K._)(t,iN))n={delete:an(e,t.key)};else if((0,K._)(t,ix)){n={update:au(e,t.key,t.data),updateMask:(i=t.fieldMask,a=[],i.fields.forEach(function(e){return a.push(e.canonicalString())}),{fieldPaths:a})}}else{if(!(0,K._)(t,iO))return tS();n={verify:an(e,t.key)}}return t.fieldTransforms.length>0&&(n.updateTransforms=t.fieldTransforms.map(function(e){var t=e.transform;if((0,K._)(t,il))return{fieldPath:e.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if((0,K._)(t,ih))return{fieldPath:e.field.canonicalString(),appendMissingElements:{values:t.elements}};if((0,K._)(t,iv))return{fieldPath:e.field.canonicalString(),removeAllFromArray:{values:t.elements}};if((0,K._)(t,ip))return{fieldPath:e.field.canonicalString(),increment:t.Pe};throw tS()})),t.precondition.isNone||(n.currentDocument=void 0!==(r=t.precondition).updateTime?{updateTime:i6(e,r.updateTime.toTimestamp())}:void 0!==r.exists?{exists:r.exists}:tS()),n}function ah(e,t){var n,r=t.currentDocument?void 0!==(n=t.currentDocument).updateTime?ib.updateTime(i7(n.updateTime)):void 0!==n.exists?ib.exists(n.exists):ib.none():ib.none(),i=t.updateTransforms?t.updateTransforms.map(function(t){var n=null;return"setToServerValue"in t?("REQUEST_TIME"===t.setToServerValue||tS(),n=new il):"appendMissingElements"in t?n=new ih(t.appendMissingElements.values||[]):"removeAllFromArray"in t?n=new iv(t.removeAllFromArray.values||[]):"increment"in t?n=new ip(e,t.increment):tS(),new i_(tH.fromServerFormat(t.fieldPath),n)}):[];if(t.update){t.update.name;var a=ar(e,t.update.name),o=new rp({mapValue:{fields:t.update.fields}});return t.updateMask?new ix(a,o,new nW((t.updateMask.fieldPaths||[]).map(function(e){return tH.fromServerFormat(e)})),r,i):new iC(a,o,r,i)}return t.delete?new iN(ar(e,t.delete),r):t.verify?new iO(ar(e,t.verify),r):tS()}function af(e,t){return{documents:[ai(e,t.path)]}}function ad(e,t){var n,r,i,a={structuredQuery:{}},o=t.path;null!==t.collectionGroup?(i=o,a.structuredQuery.from=[{collectionId:t.collectionGroup,allDescendants:!0}]):(i=o.popLast(),a.structuredQuery.from=[{collectionId:o.lastSegment()}]),a.parent=ai(e,i);var s=function(e){if(0!==e.length)return function e(t){var n,r;return(0,K._)(t,rI)?function(e){if("=="===e.op){if(ru(e.value))return{unaryFilter:{field:ay(e.field),op:"IS_NAN"}};if(rs(e.value))return{unaryFilter:{field:ay(e.field),op:"IS_NULL"}}}else if("!="===e.op){if(ru(e.value))return{unaryFilter:{field:ay(e.field),op:"IS_NOT_NA
1N"}};if(rs(e.value))return{unaryFilter:{field:ay(e.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:ay(e.field),op:i2[e.op],value:e.value}}}(t):(0,K._)(t,rT)?1===(r=(n=t).getFilters().map(function(t){return e(t)})).length?r[0]:{compositeFilter:{op:i3[n.op],filters:r}}:tS()}(rT.create(e,"and"))}(t.filters);s&&(a.structuredQuery.where=s);var u=function(e){if(0!==e.length)return e.map(function(e){return{field:ay(e.field),direction:i1[e.dir]}})}(t.orderBy);u&&(a.structuredQuery.orderBy=u);var c=i5(e,t.limit);return null!==c&&(a.structuredQuery.limit=c),t.startAt&&(a.structuredQuery.startAt={before:(n=t.startAt).inclusive,values:n.position}),t.endAt&&(a.structuredQuery.endAt={before:!(r=t.endAt).inclusive,values:r.position}),{ct:a,parent:i}}function av(e){var t,n,r,i,a,o,s,u=aa(e.parent),c=e.structuredQuery,l=c.from?c.from.length:0,h=null;if(l>0){1===l||tS();var f=c.from[0];f.allDescendants?h=f.collectionId:u=u.child(f.collectionId)}var d=[];c.where&&(t=function e(t){return void 0!==t.unaryFilter?function(e){switch(e.unaryFilter.op){case"IS_NAN":var t=ap(e.unaryFilter.field);return rI.create(t,"==",{doubleValue:NaN});case"IS_NULL":var n=ap(e.unaryFilter.field);return rI.create(n,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":var r=ap(e.unaryFilter.field);return rI.create(r,"!=",{doubleValue:NaN});case"IS_NOT_NULL":var i=ap(e.unaryFilter.field);return rI.create(i,"!=",{nullValue:"NULL_VALUE"});default:return tS()}}(t):void 0!==t.fieldFilter?rI.create(ap(t.fieldFilter.field),function(e){switch(e){case"EQUAL":return"==";case"NOT_EQUAL":return"!=";case"GREATER_THAN":return">";case"GREATER_THAN_OR_EQUAL":return">=";case"LESS_THAN":return"<";case"LESS_THAN_OR_EQUAL":return"<=";case"ARRAY_CONTAINS":return"array-contains";case"IN":return"in";case"NOT_IN":return"not-in";case"ARRAY_CONTAINS_ANY":return"array-contains-any";default:return tS()}}(t.fieldFilter.op),t.fieldFilter.value):void 0!==t.compositeFilter?rT.create(t.compositeFilter.filters.map(function(t){return e(t)}),function(e){switch(e){case"AND":return"and";case"OR":return"or";default:return tS()}}(t.compositeFilter.op)):tS()}(c.where),d=(0,K._)(t,rT)&&rC(t)?t.getFilters():[t]);var v=[];c.orderBy&&(v=c.orderBy.map(function(e){return new rb(ap(e.field),function(e){switch(e){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(e.direction))}));var y=null;c.limit&&(y=nl(r="object"==(void 0===(n=c.limit)?"undefined":(0,G._)(n))?n.value:n)?null:r);var p=null;c.startAt&&(a=!!(i=c.startAt).before,p=new rg(i.values||[],a));var m=null;return c.endAt&&(s=!(o=c.endAt).before,m=new rg(o.values||[],s)),new rH(u,h,v,d,y,"F",p,m)}function ay(e){return{fieldPath:e.canonicalString()}}function ap(e){return tH.fromServerFormat(e.fieldPath)}function am(e){return e.length>=4&&"projects"===e.get(0)&&"databases"===e.get(2)}var ag=function(){function e(t,n,r,i){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:tq.min(),o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:tq.min(),s=arguments.length>6&&void 0!==arguments[6]?arguments[6]:nJ.EMPTY_BYTE_STRING,u=arguments.length>7&&void 0!==arguments[7]?arguments[7]:null;(0,O._)(this,e),this.target=t,this.targetId=n,this.purpose=r,this.sequenceNumber=i,this.snapshotVersion=a,this.lastLimboFreeSnapshotVersion=o,this.resumeToken=s,this.expectedCount=u}return(0,P._)(e,[{key:"withSequenceNumber",value:function(t){return new e(this.target,this.targetId,this.purpose,t,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}},{key:"withResumeToken",value:function(t,n){return new e(this.target,this.targetId,this.purpose,this.sequenceNumber,n,this.lastLimboFreeSnapshotVersion,t,null)}},{key:"withExpectedCount",value:function(t){return new e(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,t)}},{key:"withLastLimboFreeSnapshotVersion",value:function(t){return new e(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,t,this.resumeToken,this.expectedCount)}}]),e}(),a_=function e(t){(0,O._)(this,e),this.ht=t};function ak(e,t){var n,r=t.key,i={prefixPath:r.getCollectionPath().popLast().toArray(),collectionGroup:r.collectionGroup,documentId:r.path.lastSegment(),readTime:ab(t.readTime),hasCommittedMutations:t.hasCommittedMutations};if(t.isFoundDocument())i.document={name:an(n=e.ht,t.key),fields:t.data.value.mapValue.fields,updateTime:i6(n,t.version.toTimestamp()),createTime:i6(n,t.createTime.toTimestamp())};else if(t.isNoDocument())i.noDocument={path:r.path.toArray(),readTime:aw(t.version)};else{if(!t.isUnknownDocument())return tS();i.unknownDocument={path:r.path.toArray(),version:aw(t.version)}}return i}function ab(e){var t=e.toTimestamp();return[t.seconds,t.nanoseconds]}function aw(e){var t=e.toTimestamp();return{seconds:t.seconds,nanoseconds:t.nanoseconds}}function aI(e){var t=new tj(e.seconds,e.nanoseconds);return tq.fromTimestamp(t)}function aT(e,t){for(var n=(t.baseMutations||[]).map(function(t){return ah(e.ht,t)}),r=0;r<t.mutations.length-1;++r){var i=t.mutations[r];r+1<t.mutations.length&&void 0!==t.mutations[r+1].transform&&(i.updateTransforms=t.mutations[r+1].transform.fieldTransforms,t.mutations.splice(r+1,1),++r)}var a=t.mutations.map(function(t){return ah(e.ht,t)}),o=tj.fromMillis(t.localWriteTimeMs);return new iP(t.batchId,o,n,a)}function aE(e){var t,n=aI(e.readTime),r=void 0!==e.lastLimboFreeSnapshotVersion?aI(e.lastLimboFreeSnapshotVersion):tq.min();return new ag(void 0!==e.query.documents?(1===(t=e.query).documents.length||tS(),rY(rW(aa(t.documents[0])))):rY(av(e.query)),e.targetId,"TargetPurposeListen",e.lastListenSequenceNumber,n,r,nJ.fromBase64String(e.resumeToken))}function aS(e,t){var n,r=aw(t.snapshotVersion),i=aw(t.lastLimboFreeSnapshotVersion);n=rq(t.target)?af(e.ht,t.target):ad(e.ht,t.target).ct;var a=t.resumeToken.toBase64();return{targetId:t.targetId,canonicalId:rB(t.target),readTime:r,resumeToken:a,lastListenSequenceNumber:t.sequenceNumber,lastLimboFreeSnapshotVersion:i,query:n}}function aC(e){var t=av({parent:e.parent,structuredQuery:e.structuredQuery});return"LAST"===e.limitType?rZ(t,t.limit,"L"):t}function ax(e,t){return new iM(t.largestBatchId,ah(e.ht,t.overlayMutation))}function aA(e,t){var n=t.path.lastSegment();return[e,nd(t.path.popLast()),n]}function aD(e,t,n,r){return{indexId:e,uid:t,sequenceNumber:n,readTime:aw(r.readTime),documentKey:nd(r.documentKey.path),largestBatchId:r.largestBatchId}}var aR=function(){function e(){(0,O._)(this,e)}return(0,P._)(e,[{key:"getBundleMetadata",value:function(e,t){return aN(e).get(t).next(function(e){if(e)return{id:e.bundleId,createTime:aI(e.createTime),version:e.version}})}},{key:"saveBundleMetadata",value:function(e,t){return aN(e).put({bundleId:t.id,createTime:aw(i7(t.createTime)),version:t.version})}}
1,{key:"getNamedQuery",value:function(e,t){return aO(e).get(t).next(function(e){if(e)return{name:e.name,query:aC(e.bundledQuery),readTime:aI(e.readTime)}})}},{key:"saveNamedQuery",value:function(e,t){return aO(e).put({name:t.name,readTime:aw(i7(t.readTime)),bundledQuery:t.bundledQuery})}}]),e}();function aN(e){return nU(e,"bundles")}function aO(e){return nU(e,"namedQueries")}var aP=function(){function e(t,n){(0,O._)(this,e),this.serializer=t,this.userId=n}return(0,P._)(e,[{key:"getOverlay",value:function(e,t){var n=this;return aL(e).get(aA(this.userId,t)).next(function(e){return e?ax(n.serializer,e):null})}},{key:"getOverlays",value:function(e,t){var n=this,r=ie();return t6.forEach(t,function(t){return n.getOverlay(e,t).next(function(e){null!==e&&r.set(t,e)})}).next(function(){return r})}},{key:"saveOverlays",value:function(e,t,n){var r=this,i=[];return n.forEach(function(n,a){var o=new iM(t,a);i.push(r.Tt(e,o))}),t6.waitFor(i)}},{key:"removeOverlaysForBatchId",value:function(e,t,n){var r=this,i=new Set;t.forEach(function(e){return i.add(nd(e.getCollectionPath()))});var a=[];return i.forEach(function(t){var i=IDBKeyRange.bound([r.userId,t,n],[r.userId,t,n+1],!1,!0);a.push(aL(e).j("collectionPathOverlayIndex",i))}),t6.waitFor(a)}},{key:"getOverlaysForCollection",value:function(e,t,n){var r=this,i=ie(),a=nd(t),o=IDBKeyRange.bound([this.userId,a,n],[this.userId,a,1/0],!0);return aL(e).U("collectionPathOverlayIndex",o).next(function(e){var t=!0,n=!1,a=void 0;try{for(var o,s=e[Symbol.iterator]();!(t=(o=s.next()).done);t=!0){var u=o.value,c=ax(r.serializer,u);i.set(c.getKey(),c)}}catch(e){n=!0,a=e}finally{try{t||null==s.return||s.return()}finally{if(n)throw a}}return i})}},{key:"getOverlaysForCollectionGroup",value:function(e,t,n,r){var i,a=this,o=ie(),s=IDBKeyRange.bound([this.userId,t,n],[this.userId,t,1/0],!0);return aL(e).J({index:"collectionGroupOverlayIndex",range:s},function(e,t,n){var s=ax(a.serializer,t);o.size()<r||s.largestBatchId===i?(o.set(s.getKey(),s),i=s.largestBatchId):n.done()}).next(function(){return o})}},{key:"Tt",value:function(e,t){var n,r,i;return aL(e).put((n=this.serializer,r=this.userId,i=(0,D._)(aA(r,t.mutation.key),3),{userId:r,collectionPath:(i[0],i[1]),documentId:i[2],collectionGroup:t.mutation.key.getCollectionGroup(),largestBatchId:t.largestBatchId,overlayMutation:al(n.ht,t.mutation)}))}}],[{key:"Pt",value:function(t,n){return new e(t,n.uid||"")}}]),e}();function aL(e){return nU(e,"documentOverlays")}var aM=function(){function e(){(0,O._)(this,e)}return(0,P._)(e,[{key:"It",value:function(e){return nU(e,"globals")}},{key:"getSessionToken",value:function(e){return this.It(e).get("sessionToken").next(function(e){var t=null==e?void 0:e.value;return t?nJ.fromUint8Array(t):nJ.EMPTY_BYTE_STRING})}},{key:"setSessionToken",value:function(e,t){return this.It(e).put({name:"sessionToken",value:t.toUint8Array()})}}]),e}(),aU=function(){function e(){(0,O._)(this,e)}return(0,P._)(e,[{key:"Et",value:function(e,t){this.dt(e,t),t.At()}},{key:"dt",value:function(e,t){if("nullValue"in e)this.Rt(t,5);else if("booleanValue"in e)this.Rt(t,10),t.Vt(+!!e.booleanValue);else if("integerValue"in e)this.Rt(t,15),t.Vt(n$(e.integerValue));else if("doubleValue"in e){var n=n$(e.doubleValue);isNaN(n)?this.Rt(t,13):(this.Rt(t,15),nh(n)?t.Vt(0):t.Vt(n))}else if("timestampValue"in e){var r=e.timestampValue;this.Rt(t,20),"string"==typeof r&&(r=nY(r)),t.ft("".concat(r.seconds||"")),t.Vt(r.nanos||0)}else if("stringValue"in e)this.gt(e.stringValue,t),this.yt(t);else if("bytesValue"in e)this.Rt(t,30),t.wt(nZ(e.bytesValue)),this.yt(t);else if("referenceValue"in e)this.St(e.referenceValue,t);else if("geoPointValue"in e){var i=e.geoPointValue;this.Rt(t,45),t.Vt(i.latitude||0),t.Vt(i.longitude||0)}else"mapValue"in e?rf(e)?this.Rt(t,Number.MAX_SAFE_INTEGER):rl(e)?this.bt(e.mapValue,t):(this.Dt(e.mapValue,t),this.yt(t)):"arrayValue"in e?(this.vt(e.arrayValue,t),this.yt(t)):tS()}},{key:"gt",value:function(e,t){this.Rt(t,25),this.Ct(e,t)}},{key:"Ct",value:function(e,t){t.ft(e)}},{key:"Dt",value:function(e,t){var n=e.fields||{};this.Rt(t,55);var r=!0,i=!1,a=void 0;try{for(var o,s=Object.keys(n)[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var u=o.value;this.gt(u,t),this.dt(n[u],t)}}catch(e){i=!0,a=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw a}}}},{key:"bt",value:function(e,t){var n,r,i=e.fields||{};this.Rt(t,53);var a="value",o=(null==(r=null==(n=i[a].arrayValue)?void 0:n.values)?void 0:r.length)||0;this.Rt(t,15),t.Vt(n$(o)),this.gt(a,t),this.dt(i[a],t)}},{key:"vt",value:function(e,t){var n=e.values||[];this.Rt(t,50);var r=!0,i=!1,a=void 0;try{for(var o,s=n[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var u=o.value;this.dt(u,t)}}catch(e){i=!0,a=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw a}}}},{key:"St",value:function(e,t){var n=this;this.Rt(t,37),tW.fromName(e).path.forEach(function(e){n.Rt(t,60),n.Ct(e,t)})}},{key:"Rt",value:function(e,t){e.Vt(t)}},{key:"yt",value:function(e){e.Vt(2)}}]),e}();function aF(e){return Math.ceil((64-function(e){for(var t=0,n=0;n<8;++n){var r=function(e){if(0===e)return 8;var t=0;return e>>4==0&&(t+=4,e<<=4),e>>6==0&&(t+=2,e<<=2),e>>7==0&&(t+=1),t}(255&e[n]);if(t+=r,8!==r)break}return t}(e))/8)}aU.Ft=new aU;var aV=function(){function e(){(0,O._)(this,e),this.buffer=new Uint8Array(1024),this.position=0}return(0,P._)(e,[{key:"Mt",value:function(e){for(var t=e[Symbol.iterator](),n=t.next();!n.done;)this.xt(n.value),n=t.next();this.Ot()}},{key:"Nt",value:function(e){for(var t=e[Symbol.iterator](),n=t.next();!n.done;)this.Lt(n.value),n=t.next();this.Bt()}},{key:"kt",value:function(e){var t=!0,n=!1,r=void 0;try{for(var i,a=e[Symbol.iterator]();!(t=(i=a.next()).done);
1t=!0){var o=i.value,s=o.charCodeAt(0);if(s<128)this.xt(s);else if(s<2048)this.xt(960|s>>>6),this.xt(128|63&s);else if(o<"\uD800"||"\uDBFF"<o)this.xt(480|s>>>12),this.xt(128|63&s>>>6),this.xt(128|63&s);else{var u=o.codePointAt(0);this.xt(240|u>>>18),this.xt(128|63&u>>>12),this.xt(128|63&u>>>6),this.xt(128|63&u)}}}catch(e){n=!0,r=e}finally{try{t||null==a.return||a.return()}finally{if(n)throw r}}this.Ot()}},{key:"qt",value:function(e){var t=!0,n=!1,r=void 0;try{for(var i,a=e[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var o=i.value,s=o.charCodeAt(0);if(s<128)this.Lt(s);else if(s<2048)this.Lt(960|s>>>6),this.Lt(128|63&s);else if(o<"\uD800"||"\uDBFF"<o)this.Lt(480|s>>>12),this.Lt(128|63&s>>>6),this.Lt(128|63&s);else{var u=o.codePointAt(0);this.Lt(240|u>>>18),this.Lt(128|63&u>>>12),this.Lt(128|63&u>>>6),this.Lt(128|63&u)}}}catch(e){n=!0,r=e}finally{try{t||null==a.return||a.return()}finally{if(n)throw r}}this.Bt()}},{key:"Qt",value:function(e){var t=this.Kt(e),n=aF(t);this.$t(1+n),this.buffer[this.position++]=255&n;for(var r=t.length-n;r<t.length;++r)this.buffer[this.position++]=255&t[r]}},{key:"Ut",value:function(e){var t=this.Kt(e),n=aF(t);this.$t(1+n),this.buffer[this.position++]=~(255&n);for(var r=t.length-n;r<t.length;++r)this.buffer[this.position++]=~(255&t[r])}},{key:"Wt",value:function(){this.Gt(255),this.Gt(255)}},{key:"zt",value:function(){this.jt(255),this.jt(255)}},{key:"reset",value:function(){this.position=0}},{key:"seed",value:function(e){this.$t(e.length),this.buffer.set(e,this.position),this.position+=e.length}},{key:"Ht",value:function(){return this.buffer.slice(0,this.position)}},{key:"Kt",value:function(e){var t,n=((t=new DataView(new ArrayBuffer(8))).setFloat64(0,e,!1),new Uint8Array(t.buffer)),r=0!=(128&n[0]);n[0]^=r?255:128;for(var i=1;i<n.length;++i)n[i]^=255*!!r;return n}},{key:"xt",value:function(e){var t=255&e;0===t?(this.Gt(0),this.Gt(255)):255===t?(this.Gt(255),this.Gt(0)):this.Gt(t)}},{key:"Lt",value:function(e){var t=255&e;0===t?(this.jt(0),this.jt(255)):255===t?(this.jt(255),this.jt(0)):this.jt(e)}},{key:"Ot",value:function(){this.Gt(0),this.Gt(1)}},{key:"Bt",value:function(){this.jt(0),this.jt(1)}},{key:"Gt",value:function(e){this.$t(1),this.buffer[this.position++]=e}},{key:"jt",value:function(e){this.$t(1),this.buffer[this.position++]=~e}},{key:"$t",value:function(e){var t=e+this.position;if(!(t<=this.buffer.length)){var n=2*this.buffer.length;n<t&&(n=t);var r=new Uint8Array(n);r.set(this.buffer),this.buffer=r}}}]),e}(),aB=function(){function e(t){(0,O._)(this,e),this.Jt=t}return(0,P._)(e,[{key:"wt",value:function(e){this.Jt.Mt(e)}},{key:"ft",value:function(e){this.Jt.kt(e)}},{key:"Vt",value:function(e){this.Jt.Qt(e)}},{key:"At",value:function(){this.Jt.Wt()}}]),e}(),aj=function(){function e(t){(0,O._)(this,e),this.Jt=t}return(0,P._)(e,[{key:"wt",value:function(e){this.Jt.Nt(e)}},{key:"ft",value:function(e){this.Jt.qt(e)}},{key:"Vt",value:function(e){this.Jt.Ut(e)}},{key:"At",value:function(){this.Jt.zt()}}]),e}(),aq=function(){function e(){(0,O._)(this,e),this.Jt=new aV,this.Yt=new aB(this.Jt),this.Zt=new aj(this.Jt)}return(0,P._)(e,[{key:"seed",value:function(e){this.Jt.seed(e)}},{key:"Xt",value:function(e){return 0===e?this.Yt:this.Zt}},{key:"Ht",value:function(){return this.Jt.Ht()}},{key:"reset",value:function(){this.Jt.reset()}}]),e}(),az=function(){function e(t,n,r,i){(0,O._)(this,e),this.indexId=t,this.documentKey=n,this.arrayValue=r,this.directionalValue=i}return(0,P._)(e,[{key:"en",value:function(){var t=this.directionalValue.length,n=0===t||255===this.directionalValue[t-1]?t+1:t,r=new Uint8Array(n);return r.set(this.directionalValue,0),n!==t?r.set([0],this.directionalValue.length):++r[r.length-1],new e(this.indexId,this.documentKey,this.arrayValue,r)}}]),e}();function aK(e,t){var n=e.indexId-t.indexId;return 0!==n||0!==(n=aG(e.arrayValue,t.arrayValue))||0!==(n=aG(e.directionalValue,t.directionalValue))?n:tW.comparator(e.documentKey,t.documentKey)}function aG(e,t){for(var n=0;n<e.length&&n<t.length;++n){var r=e[n]-t[n];if(0!==r)return r}return e.length-t.length}var aH=function(){function e(t){(0,O._)(this,e),this.tn=new nK(function(e,t){return tH.comparator(e.field,t.field)}),this.collectionId=null!=t.collectionGroup?t.collectionGroup:t.path.lastSegment(),this.nn=t.orderBy,this.rn=[];var n=!0,r=!1,i=void 0;try{for(var a,o=t.filters[Symbol.iterator]();!(n=(a=o.next()).done);
1n=!0){var s=a.value;s.isInequality()?this.tn=this.tn.add(s):this.rn.push(s)}}catch(e){r=!0,i=e}finally{try{n||null==o.return||o.return()}finally{if(r)throw i}}}return(0,P._)(e,[{key:"sn",get:function(){return this.tn.size>1}},{key:"on",value:function(e){if(e.collectionGroup===this.collectionId||tS(),this.sn)return!1;var t=tJ(e);if(void 0!==t&&!this._n(t))return!1;for(var n=tX(e),r=new Set,i=0,a=0;i<n.length&&this._n(n[i]);++i)r=r.add(n[i].fieldPath.canonicalString());if(i===n.length)return!0;if(this.tn.size>0){var o=this.tn.getIterator().getNext();if(!r.has(o.field.canonicalString())){var s=n[i];if(!this.an(o,s)||!this.un(this.nn[a++],s))return!1}++i}for(;i<n.length;++i){var u=n[i];if(a>=this.nn.length||!this.un(this.nn[a++],u))return!1}return!0}},{key:"cn",value:function(){if(this.sn)return null;var e=new nK(tH.comparator),t=[],n=!0,r=!1,i=void 0;try{for(var a,o=this.rn[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){var s=a.value;if(!s.field.isKeyField())if("array-contains"===s.op||"array-contains-any"===s.op)t.push(new tY(s.field,2));else{if(e.has(s.field))continue;e=e.add(s.field),t.push(new tY(s.field,0))}}}catch(e){r=!0,i=e}finally{try{n||null==o.return||o.return()}finally{if(r)throw i}}var u=!0,c=!1,l=void 0;try{for(var h,f=this.nn[Symbol.iterator]();!(u=(h=f.next()).done);u=!0){var d=h.value;d.field.isKeyField()||e.has(d.field)||(e=e.add(d.field),t.push(new tY(d.field,+("asc"!==d.dir))))}}catch(e){c=!0,l=e}finally{try{u||null==f.return||f.return()}finally{if(c)throw l}}return new tQ(tQ.UNKNOWN_ID,this.collectionId,t,t$.empty())}},{key:"_n",value:function(e){var t=!0,n=!1,r=void 0;try{for(var i,a=this.rn[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var o=i.value;if(this.an(o,e))return!0}}catch(e){n=!0,r=e}finally{try{t||null==a.return||a.return()}finally{if(n)throw r}}return!1}},{key:"an",value:function(e,t){if(void 0===e||!e.field.isEqual(t.fieldPath))return!1;var n="array-contains"===e.op||"array-contains-any"===e.op;return 2===t.kind===n}},{key:"un",value:function(e,t){return!!e.field.isEqual(t.fieldPath)&&(0===t.kind&&"asc"===e.dir||1===t.kind&&"desc"===e.dir)}}]),e}();function aW(e){return(0,K._)(e,rI)}function aQ(e){return(0,K._)(e,rT)&&rC(e)}function aJ(e){return aW(e)||aQ(e)||function(e){if((0,K._)(e,rT)&&rS(e)){var t=!0,n=!1,r=void 0;try{for(var i,a=e.getFilters()[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var o=i.value;if(!aW(o)&&!aQ(o))return!1}}catch(e){n=!0,r=e}finally{try{t||null==a.return||a.return()}finally{if(n)throw r}}return!0}return!1}(e)}function aX(e,t){return(0,K._)(e,rI)||(0,K._)(e,rT)||tS(),(0,K._)(t,rI)||(0,K._)(t,rT)||tS(),a$((0,K._)(e,rI)?(0,K._)(t,rI)?rT.create([e,t],"and"):aY(e,t):(0,K._)(t,rI)?aY(t,e):function(e,t){if(e.filters.length>0&&t.filters.length>0||tS(),rE(e)&&rE(t))return rA(e,t.getFilters());var n=rS(e)?e:t,r=rS(e)?t:e,i=n.filters.map(function(e){return aX(e,r)});return rT.create(i,"or")}(e,t))}function aY(e,t){if(rE(t))return rA(t,e.getFilters());var n=t.filters.map(function(t){return aX(e,t)});return rT.create(n,"or")}function a$(e){if((0,K._)(e,rI)||(0,K._)(e,rT)||tS(),(0,K._)(e,rI))return e;var t=e.getFilters();if(1===t.length)return a$(t[0]);if(rx(e))return e;var n=t.map(function(e){return a$(e)}),r=[];return n.forEach(function(t){(0,K._)(t,rI)?r.push(t):(0,K._)(t,rT)&&(t.op===e.op?r.push.apply(r,(0,L._)(t.filters)):r.push(t))}),1===r.length?r[0]:rT.create(r,e.op)}var aZ=function(){function e(){(0,O._)(this,e),this.ln=new a0}return(0,P._)(e,[{key:"addToCollectionParentIndex",value:function(e,t){return this.ln.add(t),t6.resolve()}},{key:"getCollectionParents",value:function(e,t){return t6.resolve(this.ln.getEntries(t))}},{key:"addFieldIndex",value:function(e,t){return t6.resolve()}},{key:"deleteFieldIndex",value:function(e,t){return t6.resolve()}},{key:"deleteAllFieldIndexes",value:function(e){return t6.resolve()}},{key:"createTargetIndexes",value:function(e,t){return t6.resolve()}},{key:"getDocumentsMatchingTarget",value:function(e,t){return t6.resolve(null)}},{key:"getIndexType",value:function(e,t){return t6.resolve(0)}},{key:"getFieldIndexes",value:function(e,t){return t6.resolve([])}},{key:"getNextCollectionGroupToUpdate",value:function(e){return t6.resolve(null)}},{key:"getMinOffset",value:function(e,t){return t6.resolve(t1.min())}},{key:"getMinOffsetFromCollectionGroup",value:function(e,t){return t6.resolve(t1.min())}},{key:"updateCollectionGroup",value:function(e,t,n){return t6.resolve()}},{key:"updateIndexEntries",value:function(e,t){return t6.resolve()}}]),e}(),a0=function(){function e(){(0,O._)(this,e),this.index={}}return(0,P._)(e,[{key:"add",value:function(e){var t=e.lastSegment(),n=e.popLast(),r=this.index[t]||new nK(tK.comparator),i=!r.has(n);return this.index[t]=r.add(n),i}},{key:"has",value:function(e){var t=e.lastSegment(),n=e.popLast(),r=this.index[t];return r&&r.has(n)}},{key:"getEntries",value:function(e){return(this.index[e]||new nK(tK.comparator)).toArray()}}]),e}(),a1=new Uint8Array(0),a2=function(){function e(t,n){(0,O._)(this,e),this.databaseId=n,this.hn=new a0,this.Pn=new r6(function(e){return rB(e)},function(e,t){return rj(e,t)}),this.uid=t.uid||""}return(0,P._)(e,[{key:"addToCollectionParentIndex",value:function(e,t){var n=this;if(!this.hn.has(t)){var r=t.lastSegment(),i=t.popLast();e.addOnCommittedListener(function(){n.hn.add(t)});var a={collectionId:r,parent:nd(i)};return a3(e).put(a)}return t6.resolve()}},{key:"getCollectionParents",value:function(e,t){var n=[],r=IDBKeyRange.bound([t,""],[t+"\0",""],!1,!0);return a3(e).U(r).next(function(e){var r=!0,i=!1,a=void 0;try{for(var o,s=e[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var u=o.value;if(u.collectionId!==t)break;n.push(nv(u.parent))}}catch(e){i=!0,a=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw a}}return n})}},{key:"addFieldIndex",value:function(e,t){var n=this,r=a5(e),i={indexId:t.indexId,collectionGroup:t.collectionGroup,fields:t.fields.map(function(e){return[e.fieldPath.canonicalString(),e.kind]})};delete i.indexId;var a=r.add(i);if(t.indexState){var o=a6(e);return a.next(function(e){o.put(aD(e,n.uid,t.indexState.sequenceNumber,t.indexState.offset))})}return a.next()}},{key:"deleteFieldIndex",value:function(e,t){var n=a5(e),r=a6(e),i=a4(e);return n.delete(t.indexId).next(function(){return r.delete(IDBKeyRange.bound([t.indexId],[t.indexId+1],!1,!0))}).next(function(){return i.delete(IDBKeyRange.bound([t.indexId],[t.indexId+1],!1,!0))})}},{key:"deleteAllFieldIndexes",value:function(e){var t=a5(e),n=a4(e),r=a6(e);return t.j().next(function(){return n.j()}).next(function(){return r.j()})}},{key:"createTargetIndexes",value:function(e,t){var n=this;
1return t6.forEach(this.Tn(t),function(t){return n.getIndexType(e,t).next(function(r){if(0===r||1===r){var i=new aH(t).cn();if(null!=i)return n.addFieldIndex(e,i)}})})}},{key:"getDocumentsMatchingTarget",value:function(e,t){var n=this,r=a4(e),i=!0,a=new Map;return t6.forEach(this.Tn(t),function(t){return n.In(e,t).next(function(e){i&&(i=!!e),a.set(t,e)})}).next(function(){if(i){var e=ii(),o=[];return t6.forEach(a,function(i,a){tw("IndexedDbIndexManager","Using index ".concat("id=".concat(i.indexId,"|cg=").concat(i.collectionGroup,"|f=").concat(i.fields.map(function(e){return"".concat(e.fieldPath,":").concat(e.kind)}).join(","))," to execute ").concat(rB(t)));var s=function(e,t){var n=tJ(t);if(void 0===n)return null;var r=!0,i=!1,a=void 0;try{for(var o,s=rz(e,n.fieldPath)[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var u=o.value;switch(u.op){case"array-contains-any":return u.value.arrayValue.values||[];case"array-contains":return[u.value]}}}catch(e){i=!0,a=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw a}}return null}(a,i),u=function(e,t){var n=new Map,r=!0,i=!1,a=void 0,o=!0,s=!1,u=void 0;try{for(var c,l=tX(t)[Symbol.iterator]();!(o=(c=l.next()).done);o=!0){var h=c.value;try{for(var f,d=rz(e,h.fieldPath)[Symbol.iterator]();!(r=(f=d.next()).done);r=!0){var v=f.value;switch(v.op){case"==":case"in":n.set(h.fieldPath.canonicalString(),v.value);break;case"not-in":case"!=":return n.set(h.fieldPath.canonicalString(),v.value),Array.from(n.values())}}}catch(e){i=!0,a=e}finally{try{r||null==d.return||d.return()}finally{if(i)throw a}}}}catch(e){s=!0,u=e}finally{try{o||null==l.return||l.return()}finally{if(s)throw u}}return null}(a,i),c=function(e,t){var n=[],r=!0,i=!0,a=!1,o=void 0;try{for(var s,u=tX(t)[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var c=s.value,l=0===c.kind?rK(e,c.fieldPath,e.startAt):rG(e,c.fieldPath,e.startAt);n.push(l.value),r&&(r=l.inclusive)}}catch(e){a=!0,o=e}finally{try{i||null==u.return||u.return()}finally{if(a)throw o}}return new rg(n,r)}(a,i),l=function(e,t){var n=[],r=!0,i=!0,a=!1,o=void 0;try{for(var s,u=tX(t)[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var c=s.value,l=0===c.kind?rG(e,c.fieldPath,e.endAt):rK(e,c.fieldPath,e.endAt);n.push(l.value),r&&(r=l.inclusive)}}catch(e){a=!0,o=e}finally{try{i||null==u.return||u.return()}finally{if(a)throw o}}return new rg(n,r)}(a,i),h=n.En(i,a,c),f=n.En(i,a,l),d=n.dn(i,a,u),v=n.An(i.indexId,s,h,c.inclusive,f,l.inclusive,d);return t6.forEach(v,function(n){return r.G(n,t.limit).next(function(t){t.forEach(function(t){var n=tW.fromSegments(t.documentKey);e.has(n)||(e=e.add(n),o.push(n))})})})}).next(function(){return o})}return t6.resolve(null)})}},{key:"Tn",value:function(e){var t=this.Pn.get(e);return t||(t=0===e.filters.length?[e]:(function(e){if(0===e.getFilters().length)return[];var t=function e(t){if((0,K._)(t,rI)||(0,K._)(t,rT)||tS(),(0,K._)(t,rI))return t;if(1===t.filters.length)return e(t.filters[0]);var n=t.filters.map(function(t){return e(t)}),r=rT.create(n,t.op);return aJ(r=a$(r))?r:((0,K._)(r,rT)||tS(),rE(r)||tS(),r.filters.length>1||tS(),r.filters.reduce(function(e,t){return aX(e,t)}))}(function e(t){if((0,K._)(t,rI)||(0,K._)(t,rT)||tS(),(0,K._)(t,rI)){if((0,K._)(t,rL)){var n,r,i=(null==(r=null==(n=t.value.arrayValue)?void 0:n.values)?void 0:r.map(function(e){return rI.create(t.field,"==",e)}))||[];return rT.create(i,"or")}return t}var a=t.filters.map(function(t){return e(t)});return rT.create(a,t.op)}(e));return aJ(t)||tS(),aW(t)||aQ(t)?[t]:t.getFilters()})(rT.create(e.filters,"and")).map(function(t){return rV(e.path,e.collectionGroup,e.orderBy,t.getFilters(),e.limit,e.startAt,e.endAt)}),this.Pn.set(e,t)),t}},{key:"An",value:function(e,t,n,r,i,a,o){for(var s,u=this,c=(null!=t?t.length:1)*Math.max(n.length,i.length),l=c/(null!=t?t.length:1),h=[],f=0;f<c;++f)s=this,function(c){var f=t?s.Rn(t[c/l]):a1,d=s.Vn(e,f,n[c%l],r),v=s.mn(e,f,i[c%l],a),y=o.map(function(t){return u.Vn(e,f,t,!0)});h.push.apply(h,(0,L._)(s.createRange(d,v,y)))}(f);return h}},{key:"Vn",value:function(e,t,n,r){var i=new az(e,tW.empty(),t,n);return r?i:i.en()}},{key:"mn",value:function(e,t,n,r){var i=new az(e,tW.empty(),t,n);return r?i.en():i}},{key:"In",value:function(e,t){var n=new aH(t),r=null!=t.collectionGroup?t.collectionGroup:t.path.lastSegment();return this.getFieldIndexes(e,r).next(function(e){var t=null,r=!0,i=!1,a=void 0;try{for(var o,s=e[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var u=o.value;n.on(u)&&(!t||u.fields.length>t.fields.length)&&(t=u)}}catch(e){i=!0,a=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw a}}return t})}},{key:"getIndexType",value:function(e,t){var n=this,r=2,i=this.Tn(t);
1return t6.forEach(i,function(t){return n.In(e,t).next(function(e){e?0!==r&&e.fields.length<function(e){var t=new nK(tH.comparator),n=!1,r=!0,i=!1,a=void 0,o=!0,s=!1,u=void 0;try{for(var c,l=e.filters[Symbol.iterator]();!(o=(c=l.next()).done);o=!0){var h=c.value;try{for(var f,d=h.getFlattenedFilters()[Symbol.iterator]();!(r=(f=d.next()).done);r=!0){var v=f.value;v.field.isKeyField()||("array-contains"===v.op||"array-contains-any"===v.op?n=!0:t=t.add(v.field))}}catch(e){i=!0,a=e}finally{try{r||null==d.return||d.return()}finally{if(i)throw a}}}}catch(e){s=!0,u=e}finally{try{o||null==l.return||l.return()}finally{if(s)throw u}}var y=!0,p=!1,m=void 0;try{for(var g,_=e.orderBy[Symbol.iterator]();!(y=(g=_.next()).done);y=!0){var k=g.value;k.field.isKeyField()||(t=t.add(k.field))}}catch(e){p=!0,m=e}finally{try{y||null==_.return||_.return()}finally{if(p)throw m}}return t.size+ +!!n}(t)&&(r=1):r=0})}).next(function(){return null!==t.limit&&i.length>1&&2===r?1:r})}},{key:"fn",value:function(e,t){var n=new aq,r=!0,i=!1,a=void 0;try{for(var o,s=tX(e)[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var u=o.value,c=t.data.field(u.fieldPath);if(null==c)return null;var l=n.Xt(u.kind);aU.Ft.Et(c,l)}}catch(e){i=!0,a=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw a}}return n.Ht()}},{key:"Rn",value:function(e){var t=new aq;return aU.Ft.Et(e,t.Xt(0)),t.Ht()}},{key:"gn",value:function(e,t){var n,r=new aq;return aU.Ft.Et(ri(this.databaseId,t),r.Xt(0===(n=tX(e)).length?0:n[n.length-1].kind)),r.Ht()}},{key:"dn",value:function(e,t,n){if(null===n)return[];var r=[];r.push(new aq);var i=0,a=!0,o=!1,s=void 0;try{for(var u,c=tX(e)[Symbol.iterator]();!(a=(u=c.next()).done);a=!0){var l=u.value,h=n[i++],f=!0,d=!1,v=void 0;try{for(var y,p=r[Symbol.iterator]();!(f=(y=p.next()).done);f=!0){var m=y.value;if(this.pn(t,l.fieldPath)&&ro(h))r=this.yn(r,l,h);else{var g=m.Xt(l.kind);aU.Ft.Et(h,g)}}}catch(e){d=!0,v=e}finally{try{f||null==p.return||p.return()}finally{if(d)throw v}}}}catch(e){o=!0,s=e}finally{try{a||null==c.return||c.return()}finally{if(o)throw s}}return this.wn(r)}},{key:"En",value:function(e,t,n){return this.dn(e,t,n.position)}},{key:"wn",value:function(e){for(var t=[],n=0;n<e.length;++n)t[n]=e[n].Ht();return t}},{key:"yn",value:function(e,t,n){var r=(0,L._)(e),i=[],a=!0,o=!1,s=void 0,u=!0,c=!1,l=void 0;try{for(var h,f=(n.arrayValue.values||[])[Symbol.iterator]();!(u=(h=f.next()).done);u=!0){var d=h.value;try{for(var v,y=r[Symbol.iterator]();!(a=(v=y.next()).done);a=!0){var p=v.value,m=new aq;m.seed(p.Ht()),aU.Ft.Et(d,m.Xt(t.kind)),i.push(m)}}catch(e){o=!0,s=e}finally{try{a||null==y.return||y.return()}finally{if(o)throw s}}}}catch(e){c=!0,l=e}finally{try{u||null==f.return||f.return()}finally{if(c)throw l}}return i}},{key:"pn",value:function(e,t){return!!e.filters.find(function(e){return(0,K._)(e,rI)&&e.field.isEqual(t)&&("in"===e.op||"not-in"===e.op)})}},{key:"getFieldIndexes",value:function(e,t){var n=this,r=a5(e),i=a6(e);return(t?r.U("collectionGroupIndex",IDBKeyRange.bound(t,t)):r.U()).next(function(e){var t=[];return t6.forEach(e,function(e){return i.get([e.indexId,n.uid]).next(function(n){var r,i;t.push((r=n?new t$(n.sequenceNumber,new t1(aI(n.readTime),new tW(nv(n.documentKey)),n.largestBatchId)):t$.empty(),i=e.fields.map(function(e){var t=(0,D._)(e,2),n=t[0],r=t[1];return new tY(tH.fromServerFormat(n),r)}),new tQ(e.indexId,e.collectionGroup,i,r)))})}).next(function(){return t})})}},{key:"getNextCollectionGroupToUpdate",value:function(e){return this.getFieldIndexes(e).next(function(e){return 0===e.length?null:(e.sort(function(e,t){var n=e.indexState.sequenceNumber-t.indexState.sequenceNumber;return 0!==n?n:tV(e.collectionGroup,t.collectionGroup)}),e[0].collectionGroup)})}},{key:"updateCollectionGroup",value:function(e,t,n){var r=this,i=a5(e),a=a6(e);return this.Sn(e).next(function(e){return i.U("collectionGroupIndex",IDBKeyRange.bound(t,t)).next(function(t){return t6.forEach(t,function(t){return a.put(aD(t.indexId,r.uid,e,n))})})})}},{key:"updateIndexEntries",value:function(e,t){var n=this,r=new Map;return t6.forEach(t,function(t,i){var a=r.get(t.collectionGroup);return(a?t6.resolve(a):n.getFieldIndexes(e,t.collectionGroup)).next(function(a){return r.set(t.collectionGroup,a),t6.forEac
1h(a,function(r){return n.bn(e,t,r).next(function(t){var a=n.Dn(i,r);return t.isEqual(a)?t6.resolve():n.vn(e,i,r,t,a)})})})})}},{key:"Cn",value:function(e,t,n,r){return a4(e).put({indexId:r.indexId,uid:this.uid,arrayValue:r.arrayValue,directionalValue:r.directionalValue,orderedDocumentKey:this.gn(n,t.key),documentKey:t.key.path.toArray()})}},{key:"Fn",value:function(e,t,n,r){return a4(e).delete([r.indexId,this.uid,r.arrayValue,r.directionalValue,this.gn(n,t.key),t.key.path.toArray()])}},{key:"bn",value:function(e,t,n){var r=a4(e),i=new nK(aK);return r.J({index:"documentKeyIndex",range:IDBKeyRange.only([n.indexId,this.uid,this.gn(n,t)])},function(e,r){i=i.add(new az(n.indexId,t,r.arrayValue,r.directionalValue))}).next(function(){return i})}},{key:"Dn",value:function(e,t){var n=new nK(aK),r=this.fn(t,e);if(null==r)return n;var i=tJ(t);if(null!=i){var a=e.data.field(i.fieldPath),o=!0,s=!1,u=void 0;if(ro(a))try{for(var c,l=(a.arrayValue.values||[])[Symbol.iterator]();!(o=(c=l.next()).done);o=!0){var h=c.value;n=n.add(new az(t.indexId,e.key,this.Rn(h),r))}}catch(e){s=!0,u=e}finally{try{o||null==l.return||l.return()}finally{if(s)throw u}}}else n=n.add(new az(t.indexId,e.key,a1,r));return n}},{key:"vn",value:function(e,t,n,r,i){var a=this;tw("IndexedDbIndexManager","Updating index entries for document '%s'",t.key);var o=[];return function(e,t,n,r,i){for(var a=e.getIterator(),o=t.getIterator(),s=nH(a),u=nH(o);s||u;){var c=!1,l=!1;if(s&&u){var h=n(s,u);h<0?l=!0:h>0&&(c=!0)}else null!=s?l=!0:c=!0;c?(r(u),u=nH(o)):l?(i(s),s=nH(a)):(s=nH(a),u=nH(o))}}(r,i,aK,function(r){o.push(a.Cn(e,t,n,r))},function(r){o.push(a.Fn(e,t,n,r))}),t6.waitFor(o)}},{key:"Sn",value:function(e){var t=1;return a6(e).J({index:"sequenceNumberIndex",reverse:!0,range:IDBKeyRange.upperBound([this.uid,Number.MAX_SAFE_INTEGER])},function(e,n,r){r.done(),t=n.sequenceNumber+1}).next(function(){return t})}},{key:"createRange",value:function(e,t,n){n=n.sort(function(e,t){return aK(e,t)}).filter(function(e,t,n){return!t||0!==aK(e,n[t-1])});var r=[];r.push(e);var i=!0,a=!1,o=void 0;try{for(var s,u=n[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var c=s.value,l=aK(c,e),h=aK(c,t);if(0===l)r[0]=e.en();else if(l>0&&h<0)r.push(c),r.push(c.en());else if(h>0)break}}catch(e){a=!0,o=e}finally{try{i||null==u.return||u.return()}finally{if(a)throw o}}r.push(t);for(var f=[],d=0;d<r.length;d+=2){if(this.Mn(r[d],r[d+1]))return[];var v=[r[d].indexId,this.uid,r[d].arrayValue,r[d].directionalValue,a1,[]],y=[r[d+1].indexId,this.uid,r[d+1].arrayValue,r[d+1].directionalValue,a1,[]];f.push(IDBKeyRange.bound(v,y))}return f}},{key:"Mn",value:function(e,t){return aK(e,t)>0}},{key:"getMinOffsetFromCollectionGroup",value:function(e,t){return this.getFieldIndexes(e,t).next(a8)}},{key:"getMinOffset",value:function(e,t){var n=this;return t6.mapArray(this.Tn(t),function(t){return n.In(e,t).next(function(e){return e||tS()})}).next(a8)}}]),e}();function a3(e){return nU(e,"collectionParents")}function a4(e){return nU(e,"indexEntries")}function a5(e){return nU(e,"indexConfiguration")}function a6(e){return nU(e,"indexState")}function a8(e){0!==e.length||tS();for(var t=e[0].indexState.offset,n=t.largestBatchId,r=1;r<e.length;r++){var i=e[r].indexState.offset;0>t2(i,t)&&(t=i),n<i.largestBatchId&&(n=i.largestBatchId)}return new t1(t.readTime,t.documentKey,n)}var a7={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0},a9=function(){function e(t,n,r){(0,O._)(this,e),this.cacheSizeCollectionThreshold=t,this.percentileToCollect=n,this.maximumSequenceNumbersToCollect=r}return(0,P._)(e,null,[{key:"withCacheSize",value:function(t){return new e(t,e.DEFAULT_COLLECTION_PERCENTILE,e.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}}]),e}();function oe(e,t,n){var r=e.store("mutations"),i=e.store("documentMutations"),a=[],o=IDBKeyRange.only(n.batchId),s=0,u=r.J({range:o},function(e,t,n){return s++,n.delete()});a.push(u.next(function(){1===s||tS()}));var c=[],l=!0,h=!1,f=void 0;try{for(var d,v=n.mutations[Symbol.iterator]();!(l=(d=v.next()).done);l=!0){var y,p,m=d.value,g=(y=m.key.path,p=n.batchId,[t,nd(y),p]);a.push(i.delete(g)),c.push(m.key)}}catch(e){h=!0,f=e}finally{try{l||null==v.return||v.return()}finally{if(h)throw f}}return t6.waitFor(a).next(function(){return c})}function ot(e){var t;if(!e)return 0;if(e.document)t=e.document;else if(e.unknownDocument)t=e.unknownDocument;else{if(!e.noDocument)throw tS();t=e.noDocument}return JSON.stringify(t).length}
1a9.DEFAULT_COLLECTION_PERCENTILE=10,a9.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,a9.DEFAULT=new a9(0x2800000,a9.DEFAULT_COLLECTION_PERCENTILE,a9.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),a9.DISABLED=new a9(-1,0,0);var on=function(){function e(t,n,r,i){(0,O._)(this,e),this.userId=t,this.serializer=n,this.indexManager=r,this.referenceDelegate=i,this.xn={}}return(0,P._)(e,[{key:"checkEmpty",value:function(e){var t=!0,n=IDBKeyRange.bound([this.userId,-1/0],[this.userId,1/0]);return oi(e).J({index:"userMutationsIndex",range:n},function(e,n,r){t=!1,r.done()}).next(function(){return t})}},{key:"addMutationBatch",value:function(e,t,n,r){var i=this,a=oa(e),o=oi(e);return o.add({}).next(function(s){"number"==typeof s||tS();var u=new iP(s,t,n,r),c=(y=i.serializer,p=i.userId,m=u.baseMutations.map(function(e){return al(y.ht,e)}),g=u.mutations.map(function(e){return al(y.ht,e)}),{userId:p,batchId:u.batchId,localWriteTimeMs:u.localWriteTime.toMillis(),baseMutations:m,mutations:g}),l=[],h=new nK(function(e,t){return tV(e.canonicalString(),t.canonicalString())}),f=!0,d=!1,v=void 0;try{for(var y,p,m,g,_,k=r[Symbol.iterator]();!(f=(_=k.next()).done);f=!0){var b,w,I=_.value,T=(b=i.userId,w=I.key.path,[b,nd(w),s]);h=h.add(I.key.path.popLast()),l.push(o.put(c)),l.push(a.put(T,np))}}catch(e){d=!0,v=e}finally{try{f||null==k.return||k.return()}finally{if(d)throw v}}return h.forEach(function(t){l.push(i.indexManager.addToCollectionParentIndex(e,t))}),e.addOnCommittedListener(function(){i.xn[s]=u.keys()}),t6.waitFor(l).next(function(){return u})})}},{key:"lookupMutationBatch",value:function(e,t){var n=this;return oi(e).get(t).next(function(e){return e?(e.userId===n.userId||tS(),aT(n.serializer,e)):null})}},{key:"On",value:function(e,t){var n=this;return this.xn[t]?t6.resolve(this.xn[t]):this.lookupMutationBatch(e,t).next(function(e){if(e){var r=e.keys();return n.xn[t]=r,r}return null})}},{key:"getNextMutationBatchAfterBatchId",value:function(e,t){var n=this,r=t+1,i=IDBKeyRange.lowerBound([this.userId,r]),a=null;return oi(e).J({index:"userMutationsIndex",range:i},function(e,t,i){t.userId===n.userId&&(t.batchId>=r||tS(),a=aT(n.serializer,t)),i.done()}).next(function(){return a})}},{key:"getHighestUnacknowledgedBatchId",value:function(e){var t=IDBKeyRange.upperBound([this.userId,1/0]),n=-1;return oi(e).J({index:"userMutationsIndex",range:t,reverse:!0},function(e,t,r){n=t.batchId,r.done()}).next(function(){return n})}},{key:"getAllMutationBatches",value:function(e){var t=this,n=IDBKeyRange.bound([this.userId,-1],[this.userId,1/0]);return oi(e).U("userMutationsIndex",n).next(function(e){return e.map(function(e){return aT(t.serializer,e)})})}},{key:"getAllMutationBatchesAffectingDocumentKey",value:function(e,t){var n=this,r=[this.userId,nd(t.path)],i=IDBKeyRange.lowerBound(r),a=[];return oa(e).J({range:i},function(r,i,o){var s=(0,D._)(r,3),u=s[0],c=s[1],l=s[2],h=nv(c);if(u===n.userId&&t.path.isEqual(h))return oi(e).get(l).next(function(e){if(!e)throw tS();e.userId===n.userId||tS(),a.push(aT(n.serializer,e))});o.done()}).next(function(){return a})}},{key:"getAllMutationBatchesAffectingDocumentKeys",value:function(e,t){var n=this,r=new nK(tV),i=[];return t.forEach(function(t){var a=[n.userId,nd(t.path)],o=IDBKeyRange.lowerBound(a),s=oa(e).J({range:o},function(e,i,a){var o=(0,D._)(e,3),s=o[0],u=o[1],c=o[2],l=nv(u);s===n.userId&&t.path.isEqual(l)?r=r.add(c):a.done()});i.push(s)}),t6.waitFor(i).next(function(){return n.Nn(e,r)})}},{key:"getAllMutationBatchesAffectingQuery",value:function(e,t){var n=this,r=t.path,i=r.length+1,a=[this.userId,nd(r)],o=IDBKeyRange.lowerBound(a),s=new nK(tV);return oa(e).J({range:o},function(e,t,a){var o=(0,D._)(e,3),u=o[0],c=o[1],l=o[2],h=nv(c);u===n.userId&&r.isPrefixOf(h)?h.length===i&&(s=s.add(l)):a.done()}).next(function(){return n.Nn(e,s)})}},{key:"Nn",value:function(e,t){var n=this,r=[],i=[];return t.forEach(function(t){i.push(oi(e).get(t).next(function(e){if(null===e)throw tS();e.userId===n.userId||tS(),r.push(aT(n.serializer,e))}))}),t6.waitFor(i).next(function(){return r})}},{key:"removeMutationBatch",value:function(e,t){var n=this;return oe(e._e,this.userId,t).next(function(r){return e.addOnCommittedListener(function(){n.Ln(t.batchId)}
1),t6.forEach(r,function(t){return n.referenceDelegate.markPotentiallyOrphaned(e,t)})})}},{key:"Ln",value:function(e){delete this.xn[e]}},{key:"performConsistencyCheck",value:function(e){var t=this;return this.checkEmpty(e).next(function(n){if(!n)return t6.resolve();var r=IDBKeyRange.lowerBound([t.userId]),i=[];return oa(e).J({range:r},function(e,n,r){if(e[0]===t.userId){var a=nv(e[1]);i.push(a)}else r.done()}).next(function(){0===i.length||tS()})})}},{key:"containsKey",value:function(e,t){return or(e,this.userId,t)}},{key:"Bn",value:function(e){var t=this;return oo(e).get(this.userId).next(function(e){return e||{userId:t.userId,lastAcknowledgedBatchId:-1,lastStreamToken:""}})}}],[{key:"Pt",value:function(t,n,r,i){return""!==t.uid||tS(),new e(t.isAuthenticated()?t.uid:"",n,r,i)}}]),e}();function or(e,t,n){var r=[t,nd(n.path)],i=r[1],a=IDBKeyRange.lowerBound(r),o=!1;return oa(e).J({range:a,H:!0},function(e,n,r){var a=(0,D._)(e,3),s=a[0],u=a[1];a[2],s===t&&u===i&&(o=!0),r.done()}).next(function(){return o})}function oi(e){return nU(e,"mutations")}function oa(e){return nU(e,"documentMutations")}function oo(e){return nU(e,"mutationQueues")}var os=function(){function e(t){(0,O._)(this,e),this.kn=t}return(0,P._)(e,[{key:"next",value:function(){return this.kn+=2,this.kn}}],[{key:"qn",value:function(){return new e(0)}},{key:"Qn",value:function(){return new e(-1)}}]),e}(),ou=function(){function e(t,n){(0,O._)(this,e),this.referenceDelegate=t,this.serializer=n}return(0,P._)(e,[{key:"allocateTargetId",value:function(e){var t=this;return this.Kn(e).next(function(n){var r=new os(n.highestTargetId);return n.highestTargetId=r.next(),t.$n(e,n).next(function(){return n.highestTargetId})})}},{key:"getLastRemoteSnapshotVersion",value:function(e){return this.Kn(e).next(function(e){return tq.fromTimestamp(new tj(e.lastRemoteSnapshotVersion.seconds,e.lastRemoteSnapshotVersion.nanoseconds))})}},{key:"getHighestSequenceNumber",value:function(e){return this.Kn(e).next(function(e){return e.highestListenSequenceNumber})}},{key:"setTargetsMetadata",value:function(e,t,n){var r=this;return this.Kn(e).next(function(i){return i.highestListenSequenceNumber=t,n&&(i.lastRemoteSnapshotVersion=n.toTimestamp()),t>i.highestListenSequenceNumber&&(i.highestListenSequenceNumber=t),r.$n(e,i)})}},{key:"addTargetData",value:function(e,t){var n=this;return this.Un(e,t).next(function(){return n.Kn(e).next(function(r){return r.targetCount+=1,n.Wn(t,r),n.$n(e,r)})})}},{key:"updateTargetData",value:function(e,t){return this.Un(e,t)}},{key:"removeTargetData",value:function(e,t){var n=this;return this.removeMatchingKeysForTargetId(e,t.targetId).next(function(){return oc(e).delete(t.targetId)}).next(function(){return n.Kn(e)}).next(function(t){return t.targetCount>0||tS(),t.targetCount-=1,n.$n(e,t)})}},{key:"removeTargets",value:function(e,t,n){var r=this,i=0,a=[];return oc(e).J(function(o,s){var u=aE(s);u.sequenceNumber<=t&&null===n.get(u.targetId)&&(i++,a.push(r.removeTargetData(e,u)))}).next(function(){return t6.waitFor(a)}).next(function(){return i})}},{key:"forEachTarget",value:function(e,t){return oc(e).J(function(e,n){t(aE(n))})}},{key:"Kn",value:function(e){return ol(e).get("targetGlobalKey").next(function(e){return null!==e||tS(),e})}},{key:"$n",value:function(e,t){return ol(e).put("targetGlobalKey",t)}},{key:"Un",value:function(e,t){return oc(e).put(aS(this.serializer,t))}},{key:"Wn",value:function(e,t){var n=!1;return e.targetId>t.highestTargetId&&(t.highestTargetId=e.targetId,n=!0),e.sequenceNumber>t.highestListenSequenceNumber&&(t.highestListenSequenceNumber=e.sequenceNumber,n=!0),n}},{key:"getTargetCount",value:function(e){return this.Kn(e).next(function(e){return e.targetCount})}},{key:"getTargetData",value:function(e,t){var n=rB(t),r=IDBKeyRange.bound([n,-1/0],[n,1/0]),i=null;return oc(e).J({range:r,index:"queryTargetsIndex"},function(e,n,r){var a=aE(n);rj(t,a.target)&&(i=a,r.done())}).next(function(){return i})}},{key:"addMatchingKeys",value:function(e,t,n){var r=this,i=[],a=oh(e);return t.forEach(function(t){var o=nd(t.path);i.push(a.put({targetId:n,path:o})),i.push(r.referenceDelegate.addReference(e,n,t))}),t6.waitFor(i)}},{key:"removeMatchingKeys",value:function(e,t,n){var r=this,i=oh(e);
1return t6.forEach(t,function(t){var a=nd(t.path);return t6.waitFor([i.delete([n,a]),r.referenceDelegate.removeReference(e,n,t)])})}},{key:"removeMatchingKeysForTargetId",value:function(e,t){var n=oh(e),r=IDBKeyRange.bound([t],[t+1],!1,!0);return n.delete(r)}},{key:"getMatchingKeysForTargetId",value:function(e,t){var n=IDBKeyRange.bound([t],[t+1],!1,!0),r=oh(e),i=ii();return r.J({range:n,H:!0},function(e,t,n){var r=new tW(nv(e[1]));i=i.add(r)}).next(function(){return i})}},{key:"containsKey",value:function(e,t){var n=nd(t.path),r=IDBKeyRange.bound([n],[n+"\0"],!1,!0),i=0;return oh(e).J({index:"documentTargetsIndex",H:!0,range:r},function(e,t,n){var r=(0,D._)(e,2),a=r[0];r[1],0!==a&&(i++,n.done())}).next(function(){return i>0})}},{key:"ut",value:function(e,t){return oc(e).get(t).next(function(e){return e?aE(e):null})}}]),e}();function oc(e){return nU(e,"targets")}function ol(e){return nU(e,"targetGlobal")}function oh(e){return nU(e,"targetDocuments")}function of(e,t){var n=(0,D._)(e,2),r=n[0],i=n[1],a=(0,D._)(t,2),o=a[0],s=a[1],u=tV(r,o);return 0===u?tV(i,s):u}var od=function(){function e(t){(0,O._)(this,e),this.Gn=t,this.buffer=new nK(of),this.zn=0}return(0,P._)(e,[{key:"jn",value:function(){return++this.zn}},{key:"Hn",value:function(e){var t=[e,this.jn()];if(this.buffer.size<this.Gn)this.buffer=this.buffer.add(t);else{var n=this.buffer.last();0>of(t,n)&&(this.buffer=this.buffer.delete(n).add(t))}}},{key:"maxValue",get:function(){return this.buffer.last()[0]}}]),e}(),ov=function(){function e(t,n,r){(0,O._)(this,e),this.garbageCollector=t,this.asyncQueue=n,this.localStore=r,this.Jn=null}return(0,P._)(e,[{key:"start",value:function(){-1!==this.garbageCollector.params.cacheSizeCollectionThreshold&&this.Yn(6e4)}},{key:"stop",value:function(){this.Jn&&(this.Jn.cancel(),this.Jn=null)}},{key:"started",get:function(){return null!==this.Jn}},{key:"Yn",value:function(e){var t=this;tw("LruGarbageCollector","Garbage collection scheduled in ".concat(e,"ms")),this.Jn=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",e,function(){return(0,N._)(function(){var e;return(0,M._)(this,function(t){switch(t.label){case 0:this.Jn=null,t.label=1;case 1:return t.trys.push([1,3,,7]),[4,this.localStore.collectGarbage(this.garbageCollector)];case 2:return t.sent(),[3,7];case 3:if(!nn(e=t.sent()))return[3,4];return tw("LruGarbageCollector","Ignoring IndexedDB error during garbage collection: ",e),[3,6];case 4:return[4,t5(e)];case 5:t.sent(),t.label=6;case 6:return[3,7];case 7:return[4,this.Yn(3e5)];case 8:return t.sent(),[2]}})}).call(t)})}}]),e}(),oy=function(){function e(t,n){(0,O._)(this,e),this.Zn=t,this.params=n}return(0,P._)(e,[{key:"calculateTargetCount",value:function(e,t){return this.Zn.Xn(e).next(function(e){return Math.floor(t/100*e)})}},{key:"nthSequenceNumber",value:function(e,t){var n=this;if(0===t)return t6.resolve(nc.oe);var r=new od(t);return this.Zn.forEachTarget(e,function(e){return r.Hn(e.sequenceNumber)}).next(function(){return n.Zn.er(e,function(e){return r.Hn(e)})}).next(function(){return r.maxValue})}},{key:"removeTargets",value:function(e,t,n){return this.Zn.removeTargets(e,t,n)}},{key:"removeOrphanedDocuments",value:function(e,t){return this.Zn.removeOrphanedDocuments(e,t)}},{key:"collect",value:function(e,t){var n=this;return -1===this.params.cacheSizeCollectionThreshold?(tw("LruGarbageCollector","Garbage collection skipped; disabled"),t6.resolve(a7)):this.getCacheSize(e).next(function(r){return r<n.params.cacheSizeCollectionThreshold?(tw("LruGarbageCollector","Garbage collection skipped; Cache size ".concat(r," is lower than threshold ").concat(n.params.cacheSizeCollectionThreshold)),a7):n.tr(e,t)})}},{key:"getCacheSize",value:function(e){return this.Zn.getCacheSize(e)}},{key:"tr",value:function(e,t){var n,r,a,o,s,u,c,l=this,h=Date.now();return this.calculateTargetCount(e,this.params.percentileToCollect).next(function(t){return t>l.params.maximumSequenceNumbersToCollect?(tw("LruGarbageCollector","Capping sequence numbers to collect down to the maximum of ".concat(l.params.maximumSequenceNumbersToCollect," from ").concat(t)),r=l.params.maximumSequenceNumbersToCollect):r=t,o=Date.now(),l.nthSequenceNumber(e,r)}).next(function(r){return n=r,s=Date.now(),l.removeTargets(e,n,t)}).next(function(t){return a=t,u=Date.now(),l.removeOrphanedDocuments(e,n)}).next(function(e){return c=Date.now(),tb()<=i.DEBUG&&tw("LruGarbageCollector","LRU Garbage Collection\n Counted targets in ".concat(o-h,"ms\n Determined least recently used ").concat(r," in ")+(s-o)+"ms\n"+" Removed ".concat(a," targets in ")+(u-s)+"ms\n"+" Removed ".concat(e," documents in ")+(c-u)+"ms\n"+"Total Duration: ".concat(c-h,"ms")),t6.resolve({didRun:!0,sequenceNumbersCollected:r,targetsRemoved:a,documentsRemoved:e})})}}]),e}(),op=function(){function e(t,n){(0,O._)(this,e),this.db=t,this.garbageCollector=new oy(this,n)}return(0,P._)(e,[{key:"Xn",value:function(e){var t=this.nr(e);return this.db.getTargetCache().getTargetCount(e).next(function(e){return t.next(function(t){return e+t})})}},{key:"nr",value:function(e){var t=0;return this.er(e,function(e){t++}).next(function(){return t})}}
1,{key:"forEachTarget",value:function(e,t){return this.db.getTargetCache().forEachTarget(e,t)}},{key:"er",value:function(e,t){return this.rr(e,function(e,n){return t(n)})}},{key:"addReference",value:function(e,t,n){return om(e,n)}},{key:"removeReference",value:function(e,t,n){return om(e,n)}},{key:"removeTargets",value:function(e,t,n){return this.db.getTargetCache().removeTargets(e,t,n)}},{key:"markPotentiallyOrphaned",value:function(e,t){return om(e,t)}},{key:"ir",value:function(e,t){var n;return n=!1,oo(e).Y(function(r){return or(e,r,t).next(function(e){return e&&(n=!0),t6.resolve(!e)})}).next(function(){return n})}},{key:"removeOrphanedDocuments",value:function(e,t){var n=this,r=this.db.getRemoteDocumentCache().newChangeBuffer(),i=[],a=0;return this.rr(e,function(o,s){if(s<=t){var u=n.ir(e,o).next(function(t){if(!t)return a++,r.getEntry(e,o).next(function(){return r.removeEntry(o,tq.min()),oh(e).delete([0,nd(o.path)])})});i.push(u)}}).next(function(){return t6.waitFor(i)}).next(function(){return r.apply(e)}).next(function(){return a})}},{key:"removeTarget",value:function(e,t){var n=t.withSequenceNumber(e.currentSequenceNumber);return this.db.getTargetCache().updateTargetData(e,n)}},{key:"updateLimboDocument",value:function(e,t){return om(e,t)}},{key:"rr",value:function(e,t){var n,r=oh(e),i=nc.oe;return r.J({index:"documentTargetsIndex"},function(e,r){var a=(0,D._)(e,2),o=a[0],s=(a[1],r.path),u=r.sequenceNumber;0===o?(i!==nc.oe&&t(new tW(nv(n)),i),i=u,n=s):i=nc.oe}).next(function(){i!==nc.oe&&t(new tW(nv(n)),i)})}},{key:"getCacheSize",value:function(e){return this.db.getRemoteDocumentCache().getSize(e)}}]),e}();function om(e,t){var n;return oh(e).put((n=e.currentSequenceNumber,{targetId:0,path:nd(t.path),sequenceNumber:n}))}var og=function(){function e(){(0,O._)(this,e),this.changes=new r6(function(e){return e.toString()},function(e,t){return e.isEqual(t)}),this.changesApplied=!1}return(0,P._)(e,[{key:"addEntry",value:function(e){this.assertNotApplied(),this.changes.set(e.key,e)}},{key:"removeEntry",value:function(e,t){this.assertNotApplied(),this.changes.set(e,rm.newInvalidDocument(e).setReadTime(t))}},{key:"getEntry",value:function(e,t){this.assertNotApplied();var n=this.changes.get(t);return void 0!==n?t6.resolve(n):this.getFromCache(e,t)}},{key:"getEntries",value:function(e,t){return this.getAllFromCache(e,t)}},{key:"apply",value:function(e){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(e)}},{key:"assertNotApplied",value:function(){}}]),e}(),o_=function(){function e(t){(0,O._)(this,e),this.serializer=t}return(0,P._)(e,[{key:"setIndexManager",value:function(e){this.indexManager=e}},{key:"addEntry",value:function(e,t,n){return ow(e).put(n)}},{key:"removeEntry",value:function(e,t,n){var r;return ow(e).delete([(r=t.path.toArray()).slice(0,r.length-2),r[r.length-2],ab(n),r[r.length-1]])}},{key:"updateMetadata",value:function(e,t){var n=this;return this.getMetadata(e).next(function(r){return r.byteSize+=t,n.sr(e,r)})}},{key:"getEntry",value:function(e,t){var n=this,r=rm.newInvalidDocument(t);return ow(e).J({index:"documentKeyIndex",range:IDBKeyRange.only(oI(t))},function(e,i){r=n._r(t,i)}).next(function(){return r})}},{key:"ar",value:function(e,t){var n=this,r={size:0,document:rm.newInvalidDocument(t)};return ow(e).J({index:"documentKeyIndex",range:IDBKeyRange.only(oI(t))},function(e,i){r={document:n._r(t,i),size:ot(i)}}).next(function(){return r})}},{key:"getEntries",value:function(e,t){var n=this,r=r8;return this.ur(e,t,function(e,t){var i=n._r(e,t);r=r.insert(e,i)}).next(function(){return r})}},{key:"cr",value:function(e,t){var n=this,r=r8,i=new nj(tW.comparator);return this.ur(e,t,function(e,t){var a=n._r(e,t);r=r.insert(e,a),i=i.insert(e,ot(t))}).next(function(){return{documents:r,lr:i}})}},{key:"ur",value:function(e,t,n){if(t.isEmpty())return t6.resolve();var r=new nK(oE);t.forEach(function(e){return r=r.add(e)});var i=IDBKeyRange.bound(oI(r.first()),oI(r.last())),a=r.getIterator(),o=a.getNext();return ow(e).J({index:"documentKeyIndex",range:i},function(e,t,r){for(var i=tW.fromSegments((0,L._)(t.prefixPath).concat([t.collectionGroup,t.documentId]));o&&0>oE(o,i);)n(o,null),o=a.getNext();o&&o.isEqual(i)&&(n(o,t),o=a.hasNext()?a.getNext():null),o?r.$(oI(o)):r.done()}).next(function(){for(;o;)n(o,null),o=a.hasNext()?a.getNext():null})}},{key:"getDocumentsMatchingQuery",value:function(e,t,n,r,i){var a=this,o=t.path,s=[o.popLast().toArray(),o.lastSegment(),ab(n.readTime),n.documentKey.path.isEmpty()?"":n.documentKey.path.lastSegment()],u=[o.popLast().toArray(),o.lastSegment(),[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],""];return ow(e).U(IDBKeyRange.bound(s,u,!0)).next(function(e){null==i||i.incrementDocumentReadCount(e.length);var n=r8,o=!0,s=!1,u=void 0;try{for(var c,l=e[Symbol.iterator]();!(o=(c=l.next()).done);o=!0){var h=c.value,f=a._r(tW.fromSegments(h.prefixPath.concat(h.collectionGroup,h.documentId)),h);
1f.isFoundDocument()&&(r3(t,f)||r.has(f.key))&&(n=n.insert(f.key,f))}}catch(e){s=!0,u=e}finally{try{o||null==l.return||l.return()}finally{if(s)throw u}}return n})}},{key:"getAllFromCollectionGroup",value:function(e,t,n,r){var i=this,a=r8,o=oT(t,n),s=oT(t,t1.max());return ow(e).J({index:"collectionGroupIndex",range:IDBKeyRange.bound(o,s,!0)},function(e,t,n){var o=i._r(tW.fromSegments(t.prefixPath.concat(t.collectionGroup,t.documentId)),t);(a=a.insert(o.key,o)).size===r&&n.done()}).next(function(){return a})}},{key:"newChangeBuffer",value:function(e){return new ok(this,!!e&&e.trackRemovals)}},{key:"getSize",value:function(e){return this.getMetadata(e).next(function(e){return e.byteSize})}},{key:"getMetadata",value:function(e){return ob(e).get("remoteDocumentGlobalKey").next(function(e){return e||tS(),e})}},{key:"sr",value:function(e,t){return ob(e).put("remoteDocumentGlobalKey",t)}},{key:"_r",value:function(e,t){if(t){var n=function(e,t){if(t.document)n=ac(e.ht,t.document,!!t.hasCommittedMutations);else if(t.noDocument){var n,r,i,a=tW.fromSegments(t.noDocument.path),o=aI(t.noDocument.readTime);n=rm.newNoDocument(a,o),t.hasCommittedMutations&&n.setHasCommittedMutations()}else{if(!t.unknownDocument)return tS();var s=tW.fromSegments(t.unknownDocument.path),u=aI(t.unknownDocument.version);n=rm.newUnknownDocument(s,u)}return t.readTime&&n.setReadTime((i=new tj((r=t.readTime)[0],r[1]),tq.fromTimestamp(i))),n}(this.serializer,t);if(!(n.isNoDocument()&&n.version.isEqual(tq.min())))return n}return rm.newInvalidDocument(e)}}]),e}(),ok=function(e){function t(e,n){var r;return(0,O._)(this,t),(r=(0,V._)(this,t)).hr=e,r.trackRemovals=n,r.Pr=new r6(function(e){return e.toString()},function(e,t){return e.isEqual(t)}),r}return(0,z._)(t,e),(0,P._)(t,[{key:"applyChanges",value:function(e){var t=this,n=[],r=0,i=new nK(function(e,t){return tV(e.canonicalString(),t.canonicalString())});
1return this.changes.forEach(function(a,o){var s=t.Pr.get(a);if(n.push(t.hr.removeEntry(e,a,s.readTime)),o.isValidDocument()){var u=ak(t.hr.serializer,o);i=i.add(a.path.popLast());var c=ot(u);r+=c-s.size,n.push(t.hr.addEntry(e,a,u))}else if(r-=s.size,t.trackRemovals){var l=ak(t.hr.serializer,o.convertToNoDocument(tq.min()));n.push(t.hr.addEntry(e,a,l))}}),i.forEach(function(r){n.push(t.hr.indexManager.addToCollectionParentIndex(e,r))}),n.push(this.hr.updateMetadata(e,r)),t6.waitFor(n)}},{key:"getFromCache",value:function(e,t){var n=this;return this.hr.ar(e,t).next(function(e){return n.Pr.set(t,{size:e.size,readTime:e.document.readTime}),e.document})}},{key:"getAllFromCache",value:function(e,t){var n=this;return this.hr.cr(e,t).next(function(e){var t=e.documents;return e.lr.forEach(function(e,r){n.Pr.set(e,{size:r,readTime:t.get(e).readTime})}),t})}}]),t}(og);function ob(e){return nU(e,"remoteDocumentGlobal")}function ow(e){return nU(e,"remoteDocumentsV14")}function oI(e){var t=e.path.toArray();return[t.slice(0,t.length-2),t[t.length-2],t[t.length-1]]}function oT(e,t){var n=t.documentKey.path.toArray();return[e,ab(t.readTime),n.slice(0,n.length-2),n.length>0?n[n.length-1]:""]}function oE(e,t){for(var n=e.path.toArray(),r=t.path.toArray(),i=0,a=0;a<n.length-2&&a<r.length-2;++a)if(i=tV(n[a],r[a]))return i;return(i=tV(n.length,r.length))||(i=tV(n[n.length-2],r[r.length-2]))||tV(n[n.length-1],r[r.length-1])}var oS=function e(t,n){(0,O._)(this,e),this.overlayedDocument=t,this.mutatedFields=n},oC=function(){function e(t,n,r,i){(0,O._)(this,e),this.remoteDocumentCache=t,this.mutationQueue=n,this.documentOverlayCache=r,this.indexManager=i}return(0,P._)(e,[{key:"getDocument",value:function(e,t){var n=this,r=null;return this.documentOverlayCache.getOverlay(e,t).next(function(i){return r=i,n.remoteDocumentCache.getEntry(e,t)}).next(function(e){return null!==r&&iE(r.mutation,e,nW.empty(),tj.now()),e})}},{key:"getDocuments",value:function(e,t){var n=this;return this.remoteDocumentCache.getEntries(e,t).next(function(t){return n.getLocalViewOfDocuments(e,t,ii()).next(function(){return t})})}},{key:"getLocalViewOfDocuments",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ii(),i=ie();return this.populateOverlays(e,i,t).next(function(){return n.computeViews(e,t,i,r).next(function(e){var t=r9();return e.forEach(function(e,n){t=t.insert(e,n.overlayedDocument)}),t})})}},{key:"getOverlayedDocuments",value:function(e,t){var n=this,r=ie();return this.populateOverlays(e,r,t).next(function(){return n.computeViews(e,t,r,ii())})}},{key:"populateOverlays",value:function(e,t,n){var r=[];return n.forEach(function(e){t.has(e)||r.push(e)}),this.documentOverlayCache.getOverlays(e,r).next(function(e){e.forEach(function(e,n){t.set(e,n)})})}},{key:"computeViews",value:function(e,t,n,r){var i=r8,a=ie(),o=ie();return t.forEach(function(e,t){var o=n.get(t.key);r.has(t.key)&&(void 0===o||(0,K._)(o.mutation,ix))?i=i.insert(t.key,t):void 0!==o?(a.set(t.key,o.mutation.getFieldMask()),iE(o.mutation,t,o.mutation.getFieldMask(),tj.now())):a.set(t.key,nW.empty())}),this.recalculateAndSaveOverlays(e,i).next(function(e){return e.forEach(function(e,t){return a.set(e,t)}),t.forEach(function(e,t){var n;return o.set(e,new oS(t,null!=(n=a.get(e))?n:null))}),o})}},{key:"recalculateAndSaveOverlays",value:function(e,t){var n=this,r=ie(),i=new nj(function(e,t){return e-t}),a=ii();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,t).next(function(e){var n=!0,a=!1,o=void 0;try{for(var s,u=e[Symbol.iterator]();!(n=(s=u.next()).done);n=!0)!function(){var e=s.value;e.keys().forEach(function(n){var a=t.get(n);if(null!==a){var o=r.get(n)||nW.empty();o=e.applyToLocalView(a,o),r.set(n,o);var s=(i.get(e.batchId)||ii()).add(n);i=i.insert(e.batchId,s)}})}()}catch(e){a=!0,o=e}finally{try{n||null==u.return||u.return()}finally{if(a)throw o}}}).next(function(){for(var o=[],s=i.getReverseIterator();s.hasNext();)!function(){var i=s.getNext(),u=i.key,c=i.value,l=ie();c.forEach(function(e){if(!a.has(e)){var n=iT(t.get(e),r.get(e));null!==n&&l.set(e,n),a=a.add(e)}}),o.push(n.documentOverlayCache.saveOverlays(e,u,l))}();return t6.waitFor(o)}).next(function(){return r})}},{key:"recalculateAndSaveOverlaysForDocumentKeys",value:function(e,t){var n=this;return this.remoteDocumentCache.getEntries(e,t).next(function(t){return n.recalculateAndSaveOverlays(e,t)})}},{key:"getDocumentsMatchingQuery",value:function(e,t,n,r){return tW.isDocumentKey(t.path)&&null===t.collectionGroup&&0===t.filters.length?this.getDocumentsMatchingDocumentQuery(e,t.path):rJ(t)?this.getDocumentsMatchingCollectionGroupQuery(e,t,n,r):this.getDocumentsMatchingCollectionQuery(e,t,n,r)}},{key:"getNextDocuments",value:function(e,t,n,r){var i=this;return this.remoteDocumentCache.getAllFromCollectionGroup(e,t,n,r).next(function(a){var o=r-a.size>0?i.documentOverlayCache.getOverlaysForCollectionGroup(e,t,n.largestBatchId,r-a.size):t6.resolve(ie()),s=-1,u=a;
1return o.next(function(t){return t6.forEach(t,function(t,n){return s<n.largestBatchId&&(s=n.largestBatchId),a.get(t)?t6.resolve():i.remoteDocumentCache.getEntry(e,t).next(function(e){u=u.insert(t,e)})}).next(function(){return i.populateOverlays(e,t,a)}).next(function(){return i.computeViews(e,u,t,ii())}).next(function(e){var t;return{batchId:s,changes:(t=r7,e.forEach(function(e,n){return t=t.insert(e,n.overlayedDocument)}),t)}})})})}},{key:"getDocumentsMatchingDocumentQuery",value:function(e,t){return this.getDocument(e,new tW(t)).next(function(e){var t=r9();return e.isFoundDocument()&&(t=t.insert(e.key,e)),t})}},{key:"getDocumentsMatchingCollectionGroupQuery",value:function(e,t,n,r){var i=this,a=t.collectionGroup,o=r9();return this.indexManager.getCollectionParents(e,a).next(function(s){return t6.forEach(s,function(s){var u=new rH(s.child(a),null,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,t.startAt,t.endAt);return i.getDocumentsMatchingCollectionQuery(e,u,n,r).next(function(e){e.forEach(function(e,t){o=o.insert(e,t)})})}).next(function(){return o})})}},{key:"getDocumentsMatchingCollectionQuery",value:function(e,t,n,r){var i,a=this;return this.documentOverlayCache.getOverlaysForCollection(e,t.path,n.largestBatchId).next(function(o){return i=o,a.remoteDocumentCache.getDocumentsMatchingQuery(e,t,n,i,r)}).next(function(e){i.forEach(function(t,n){var r=n.getKey();null===e.get(r)&&(e=e.insert(r,rm.newInvalidDocument(r)))});var n=r9();return e.forEach(function(e,r){var a=i.get(e);void 0!==a&&iE(a.mutation,r,nW.empty(),tj.now()),r3(t,r)&&(n=n.insert(e,r))}),n})}}]),e}(),ox=function(){function e(t){(0,O._)(this,e),this.serializer=t,this.Tr=new Map,this.Ir=new Map}return(0,P._)(e,[{key:"getBundleMetadata",value:function(e,t){return t6.resolve(this.Tr.get(t))}},{key:"saveBundleMetadata",value:function(e,t){return this.Tr.set(t.id,{id:t.id,version:t.version,createTime:i7(t.createTime)}),t6.resolve()}},{key:"getNamedQuery",value:function(e,t){return t6.resolve(this.Ir.get(t))}},{key:"saveNamedQuery",value:function(e,t){return this.Ir.set(t.name,{name:t.name,query:aC(t.bundledQuery),readTime:i7(t.readTime)}),t6.resolve()}}]),e}(),oA=function(){function e(){(0,O._)(this,e),this.overlays=new nj(tW.comparator),this.Er=new Map}return(0,P._)(e,[{key:"getOverlay",value:function(e,t){return t6.resolve(this.overlays.get(t))}},{key:"getOverlays",value:function(e,t){var n=this,r=ie();return t6.forEach(t,function(t){return n.getOverlay(e,t).next(function(e){null!==e&&r.set(t,e)})}).next(function(){return r})}},{key:"saveOverlays",value:function(e,t,n){var r=this;return n.forEach(function(n,i){r.Tt(e,t,i)}),t6.resolve()}},{key:"removeOverlaysForBatchId",value:function(e,t,n){var r=this,i=this.Er.get(n);return void 0!==i&&(i.forEach(function(e){return r.overlays=r.overlays.remove(e)}),this.Er.delete(n)),t6.resolve()}},{key:"getOverlaysForCollection",value:function(e,t,n){for(var r=ie(),i=t.length+1,a=new tW(t.child("")),o=this.overlays.getIteratorFrom(a);o.hasNext();){var s=o.getNext().value,u=s.getKey();if(!t.isPrefixOf(u.path))break;u.path.length===i&&s.largestBatchId>n&&r.set(s.getKey(),s)}return t6.resolve(r)}},{key:"getOverlaysForCollectionGroup",value:function(e,t,n,r){for(var i=new nj(function(e,t){return e-t}),a=this.overlays.getIterator();a.hasNext();){var o=a.getNext().value;if(o.getKey().getCollectionGroup()===t&&o.largestBatchId>n){var s=i.get(o.largestBatchId);null===s&&(s=ie(),i=i.insert(o.largestBatchId,s)),s.set(o.getKey(),o)}}for(var u=ie(),c=i.getIterator();c.hasNext()&&(c.getNext().value.forEach(function(e,t){return u.set(e,t)}),!(u.size()>=r)););return t6.resolve(u)}},{key:"Tt",value:function(e,t,n){var r=this.overlays.get(n.key);if(null!==r){var i=this.Er.get(r.largestBatchId).delete(n.key);this.Er.set(r.largestBatchId,i)}this.overlays=this.overlays.insert(n.key,new iM(t,n));var a=this.Er.get(t);void 0===a&&(a=ii(),this.Er.set(t,a)),this.Er.set(t,a.add(n.key))}}]),e}(),oD=function(){function e(){(0,O._)(this,e),this.sessionToken=nJ.EMPTY_BYTE_STRING}return(0,P._)(e,[{key:"getSessionToken",value:function(e){return t6.resolve(this.sessionToken)}},{key:"setSessionToken",value:function(e,t){return this.sessionToken=t,t6.resolve()}}]),e}(),oR=function(){function e(){(0,O._)(this,e),this.dr=new nK(oN.Ar),this.Rr=new nK(oN.Vr)}return(0,P._)(e,[{key:"isEmpty",value:function(){return this.dr.isEmpty()}},{key:"addReference",value:function(e,t){var n=new oN(e,t);this.dr=this.dr.add(n),this.Rr=this.Rr.add(n)}},{key:"mr",value:function(e,t){var n=this;e.forEach(function(e){return n.addReference(e,t)})}},{key:"removeReference",value:function(e,t){this.gr(new oN(e,t))}},{key:"pr",value:function(e,t){var n=this;e.forEach(function(e){return n.removeReference(e,t)})}},{key:"yr",value:function(e){var t=this,n=new tW(new tK([])),r=new oN(n,e),i=new oN(n,e+1),a=[];return this.Rr.forEachInRange([r,i],function(e){t.gr(e),a.push(e.key)}),a}},{key:"wr",value:function(){var e=this;this.dr.forEach(function(t){return e.gr(t)})}},{key:"gr",value:function(e){this.dr=this.dr.delete(e),this.Rr=this.Rr.delete(e)}},{key:"Sr",value:function(e){var t=new tW(new tK([])),n=new oN(t,e),r=new oN(t,e+1),i=ii();return this.Rr.forEachInRange([n,r],function(e){i=i.add(e.key)}),i}},{key:"containsKey",value:function(e){var t=new oN(e,0),n=this.dr.firstAfterOrEqual(t);return null!==n&&e.isEqual(n.key)}}]),e}(),oN=function(){function e(t,n){(0,O._)(this,e),this.key=t,this.br=n}return(0,P._)(e,null,[{key:"Ar",value:function(e,t){return tW.comparator(e.key,t.key)||tV(e.br,t.br)}},{key:"Vr",value:function(e,t){return tV(e.br,t.br)||tW.comparator(e.key,t.key)}}]),e}(),oO=function(){function e(t,n){(0,O._)(this,e),this.indexManager=t,this.referenceDelegate=n,this.mutation
1Queue=[],this.Dr=1,this.vr=new nK(oN.Ar)}return(0,P._)(e,[{key:"checkEmpty",value:function(e){return t6.resolve(0===this.mutationQueue.length)}},{key:"addMutationBatch",value:function(e,t,n,r){var i=this.Dr;this.Dr++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];var a=new iP(i,t,n,r);this.mutationQueue.push(a);var o=!0,s=!1,u=void 0;try{for(var c,l=r[Symbol.iterator]();!(o=(c=l.next()).done);o=!0){var h=c.value;this.vr=this.vr.add(new oN(h.key,i)),this.indexManager.addToCollectionParentIndex(e,h.key.path.popLast())}}catch(e){s=!0,u=e}finally{try{o||null==l.return||l.return()}finally{if(s)throw u}}return t6.resolve(a)}},{key:"lookupMutationBatch",value:function(e,t){return t6.resolve(this.Cr(t))}},{key:"getNextMutationBatchAfterBatchId",value:function(e,t){var n=this.Fr(t+1),r=n<0?0:n;return t6.resolve(this.mutationQueue.length>r?this.mutationQueue[r]:null)}},{key:"getHighestUnacknowledgedBatchId",value:function(){return t6.resolve(0===this.mutationQueue.length?-1:this.Dr-1)}},{key:"getAllMutationBatches",value:function(e){return t6.resolve(this.mutationQueue.slice())}},{key:"getAllMutationBatchesAffectingDocumentKey",value:function(e,t){var n=this,r=new oN(t,0),i=new oN(t,1/0),a=[];return this.vr.forEachInRange([r,i],function(e){var t=n.Cr(e.br);a.push(t)}),t6.resolve(a)}},{key:"getAllMutationBatchesAffectingDocumentKeys",value:function(e,t){var n=this,r=new nK(tV);return t.forEach(function(e){var t=new oN(e,0),i=new oN(e,1/0);n.vr.forEachInRange([t,i],function(e){r=r.add(e.br)})}),t6.resolve(this.Mr(r))}},{key:"getAllMutationBatchesAffectingQuery",value:function(e,t){var n=t.path,r=n.length+1,i=n;tW.isDocumentKey(i)||(i=i.child(""));var a=new oN(new tW(i),0),o=new nK(tV);return this.vr.forEachWhile(function(e){var t=e.key.path;return!!n.isPrefixOf(t)&&(t.length===r&&(o=o.add(e.br)),!0)},a),t6.resolve(this.Mr(o))}},{key:"Mr",value:function(e){var t=this,n=[];return e.forEach(function(e){var r=t.Cr(e);null!==r&&n.push(r)}),n}},{key:"removeMutationBatch",value:function(e,t){var n=this;0===this.Or(t.batchId,"removed")||tS(),this.mutationQueue.shift();var r=this.vr;return t6.forEach(t.mutations,function(i){var a=new oN(i.key,t.batchId);return r=r.delete(a),n.referenceDelegate.markPotentiallyOrphaned(e,i.key)}).next(function(){n.vr=r})}},{key:"Ln",value:function(e){}},{key:"containsKey",value:function(e,t){var n=new oN(t,0),r=this.vr.firstAfterOrEqual(n);return t6.resolve(t.isEqual(r&&r.key))}},{key:"performConsistencyCheck",value:function(e){return this.mutationQueue.length,t6.resolve()}},{key:"Or",value:function(e,t){return this.Fr(e)}},{key:"Fr",value:function(e){return 0===this.mutationQueue.length?0:e-this.mutationQueue[0].batchId}},{key:"Cr",value:function(e){var t=this.Fr(e);return t<0||t>=this.mutationQueue.length?null:this.mutationQueue[t]}}]),e}(),oP=function(){function e(t){(0,O._)(this,e),this.Nr=t,this.docs=new nj(tW.comparator),this.size=0}return(0,P._)(e,[{key:"setIndexManager",value:function(e){this.indexManager=e}},{key:"addEntry",value:function(e,t){var n=t.key,r=this.docs.get(n),i=r?r.size:0,a=this.Nr(t);return this.docs=this.docs.insert(n,{document:t.mutableCopy(),size:a}),this.size+=a-i,this.indexManager.addToCollectionParentIndex(e,n.path.popLast())}},{key:"removeEntry",value:function(e){var t=this.docs.get(e);t&&(this.docs=this.docs.remove(e),this.size-=t.size)}},{key:"getEntry",value:function(e,t){var n=this.docs.get(t);return t6.resolve(n?n.document.mutableCopy():rm.newInvalidDocument(t))}},{key:"getEntries",value:function(e,t){var n=this,r=r8;return t.forEach(function(e){var t=n.docs.get(e);r=r.insert(e,t?t.document.mutableCopy():rm.newInvalidDocument(e))}),t6.resolve(r)}},{key:"getDocumentsMatchingQuery",value:function(e,t,n,r){for(var i=r8,a=t.path,o=new tW(a.child("")),s=this.docs.getIteratorFrom(o);s.hasNext();){var u=s.getNext(),c=u.key,l=u.value.document;if(!a.isPrefixOf(c.path))break;c.path.length>a.length+1||0>=t2(t0(l),n)||(r.has(l.key)||r3(t,l))&&(i=i.insert(l.key,l.mutableCopy()))}return t6.resolve(i)}},{key:"getAllFromCollectionGroup",value:function(e,t,n,r){tS()}}
1,{key:"Lr",value:function(e,t){return t6.forEach(this.docs,function(e){return t(e)})}},{key:"newChangeBuffer",value:function(e){return new oL(this)}},{key:"getSize",value:function(e){return t6.resolve(this.size)}}]),e}(),oL=function(e){function t(e){var n;return(0,O._)(this,t),(n=(0,V._)(this,t)).hr=e,n}return(0,z._)(t,e),(0,P._)(t,[{key:"applyChanges",value:function(e){var t=this,n=[];return this.changes.forEach(function(r,i){i.isValidDocument()?n.push(t.hr.addEntry(e,i)):t.hr.removeEntry(r)}),t6.waitFor(n)}},{key:"getFromCache",value:function(e,t){return this.hr.getEntry(e,t)}},{key:"getAllFromCache",value:function(e,t){return this.hr.getEntries(e,t)}}]),t}(og),oM=function(){function e(t){(0,O._)(this,e),this.persistence=t,this.Br=new r6(function(e){return rB(e)},rj),this.lastRemoteSnapshotVersion=tq.min(),this.highestTargetId=0,this.kr=0,this.qr=new oR,this.targetCount=0,this.Qr=os.qn()}return(0,P._)(e,[{key:"forEachTarget",value:function(e,t){return this.Br.forEach(function(e,n){return t(n)}),t6.resolve()}},{key:"getLastRemoteSnapshotVersion",value:function(e){return t6.resolve(this.lastRemoteSnapshotVersion)}},{key:"getHighestSequenceNumber",value:function(e){return t6.resolve(this.kr)}},{key:"allocateTargetId",value:function(e){return this.highestTargetId=this.Qr.next(),t6.resolve(this.highestTargetId)}},{key:"setTargetsMetadata",value:function(e,t,n){return n&&(this.lastRemoteSnapshotVersion=n),t>this.kr&&(this.kr=t),t6.resolve()}},{key:"Un",value:function(e){this.Br.set(e.target,e);var t=e.targetId;t>this.highestTargetId&&(this.Qr=new os(t),this.highestTargetId=t),e.sequenceNumber>this.kr&&(this.kr=e.sequenceNumber)}},{key:"addTargetData",value:function(e,t){return this.Un(t),this.targetCount+=1,t6.resolve()}},{key:"updateTargetData",value:function(e,t){return this.Un(t),t6.resolve()}},{key:"removeTargetData",value:function(e,t){return this.Br.delete(t.target),this.qr.yr(t.targetId),this.targetCount-=1,t6.resolve()}},{key:"removeTargets",value:function(e,t,n){var r=this,i=0,a=[];return this.Br.forEach(function(o,s){s.sequenceNumber<=t&&null===n.get(s.targetId)&&(r.Br.delete(o),a.push(r.removeMatchingKeysForTargetId(e,s.targetId)),i++)}),t6.waitFor(a).next(function(){return i})}},{key:"getTargetCount",value:function(e){return t6.resolve(this.targetCount)}},{key:"getTargetData",value:function(e,t){var n=this.Br.get(t)||null;return t6.resolve(n)}},{key:"addMatchingKeys",value:function(e,t,n){return this.qr.mr(t,n),t6.resolve()}},{key:"removeMatchingKeys",value:function(e,t,n){this.qr.pr(t,n);var r=this.persistence.referenceDelegate,i=[];return r&&t.forEach(function(t){i.push(r.markPotentiallyOrphaned(e,t))}),t6.waitFor(i)}},{key:"removeMatchingKeysForTargetId",value:function(e,t){return this.qr.yr(t),t6.resolve()}},{key:"getMatchingKeysForTargetId",value:function(e,t){var n=this.qr.Sr(t);return t6.resolve(n)}},{key:"containsKey",value:function(e,t){return t6.resolve(this.qr.containsKey(t))}}]),e}(),oU=function(){function e(t,n){var r=this;(0,O._)(this,e),this.Kr={},this.overlays={},this.$r=new nc(0),this.Ur=!1,this.Ur=!0,this.Wr=new oD,this.referenceDelegate=t(this),this.Gr=new oM(this),this.indexManager=new aZ,this.remoteDocumentCache=new oP(function(e){return r.referenceDelegate.zr(e)}),this.serializer=new a_(n),this.jr=new ox(this.serializer)}return(0,P._)(e,[{key:"start",value:function(){return Promise.resolve()}},{key:"shutdown",value:function(){return this.Ur=!1,Promise.resolve()}},{key:"started",get:function(){return this.Ur}},{key:"setDatabaseDeletedListener",value:function(){}},{key:"setNetworkEnabled",value:function(){}},{key:"getIndexManager",value:function(e){return this.indexManager}},{key:"getDocumentOverlayCache",value:function(e){var t=this.overlays[e.toKey()];return t||(t=new oA,this.overlays[e.toKey()]=t),t}},{key:"getMutationQueue",value:function(e,t){var n=this.Kr[e.toKey()];return n||(n=new oO(t,this.referenceDelegate),this.Kr[e.toKey()]=n),n}},{key:"getGlobalsCache",value:function(){return this.Wr}},{key:"getTargetCache",value:function(){return this.Gr}},{key:"getRemoteDocumentCache",value:function(){return this.remoteDocumentCache}},{key:"getBundleCache",value:function(){return this.jr}},{key:"runTransaction",value:function(e,t,n){var r=this;tw("MemoryPersistence","Starting transaction:",e);var i=new oF(this.$r.next());return this.referenceDelegate.Hr(),n(i).next(function(e){return r.referenceDelegate.Jr(i).next(function(){return e})}).toPromise().then(function(e){return i.raiseOnCommittedEvent(),e})}},{key:"Yr",value:function(e,t){return t6.or(Object.values(this.Kr).map(function(n){return function(){return n.containsKey(e,t)}}))}}]),e}(),oF=function(e){function t(e){var n;return(0,O._)(this,t),(n=(0,V._)(this,t)).currentSequenceNumber=e,n}return(0,z._)(t,e),t}(t4),oV=function(){function e(t){(0,O._)(this,e),this.persistence=t,this.Zr=new oR,this.Xr=null}return(0,P._)(e,[{key:"ti",get:function(){if(this.Xr)return this.Xr;throw tS()}},{key:"addReference",value:function(e,t,n){return this.Zr.addReference(n,t),this.ti.delete(n.toString()),t6.resolve()}},{key:"removeReference",value:function(e,t,n){return this.Zr.removeReference(n,t),this.ti.add(n.toString()),t6.resolve()}},{key:"markPotentiallyOrphaned",value:function(e,t){return this.ti.add(t.toString()),t6.resolve()}},{key:"removeTarget",value:function(e,t){var n=this;
1this.Zr.yr(t.targetId).forEach(function(e){return n.ti.add(e.toString())});var r=this.persistence.getTargetCache();return r.getMatchingKeysForTargetId(e,t.targetId).next(function(e){e.forEach(function(e){return n.ti.add(e.toString())})}).next(function(){return r.removeTargetData(e,t)})}},{key:"Hr",value:function(){this.Xr=new Set}},{key:"Jr",value:function(e){var t=this,n=this.persistence.getRemoteDocumentCache().newChangeBuffer();return t6.forEach(this.ti,function(r){var i=tW.fromPath(r);return t.ni(e,i).next(function(e){e||n.removeEntry(i,tq.min())})}).next(function(){return t.Xr=null,n.apply(e)})}},{key:"updateLimboDocument",value:function(e,t){var n=this;return this.ni(e,t).next(function(e){e?n.ti.delete(t.toString()):n.ti.add(t.toString())})}},{key:"zr",value:function(e){return 0}},{key:"ni",value:function(e,t){var n=this;return t6.or([function(){return t6.resolve(n.Zr.containsKey(t))},function(){return n.persistence.getTargetCache().containsKey(e,t)},function(){return n.persistence.Yr(e,t)}])}}],[{key:"ei",value:function(t){return new e(t)}}]),e}(),oB=function(){function e(t,n){(0,O._)(this,e),this.persistence=t,this.ri=new r6(function(e){return nd(e.path)},function(e,t){return e.isEqual(t)}),this.garbageCollector=new oy(this,n)}return(0,P._)(e,[{key:"Hr",value:function(){}},{key:"Jr",value:function(e){return t6.resolve()}},{key:"forEachTarget",value:function(e,t){return this.persistence.getTargetCache().forEachTarget(e,t)}},{key:"Xn",value:function(e){var t=this.nr(e);return this.persistence.getTargetCache().getTargetCount(e).next(function(e){return t.next(function(t){return e+t})})}},{key:"nr",value:function(e){var t=0;return this.er(e,function(e){t++}).next(function(){return t})}},{key:"er",value:function(e,t){var n=this;return t6.forEach(this.ri,function(r,i){return n.ir(e,r,i).next(function(e){return e?t6.resolve():t(i)})})}},{key:"removeTargets",value:function(e,t,n){return this.persistence.getTargetCache().removeTargets(e,t,n)}},{key:"removeOrphanedDocuments",value:function(e,t){var n=this,r=0,i=this.persistence.getRemoteDocumentCache(),a=i.newChangeBuffer();return i.Lr(e,function(i){return n.ir(e,i,t).next(function(e){e||(r++,a.removeEntry(i,tq.min()))})}).next(function(){return a.apply(e)}).next(function(){return r})}},{key:"markPotentiallyOrphaned",value:function(e,t){return this.ri.set(t,e.currentSequenceNumber),t6.resolve()}},{key:"removeTarget",value:function(e,t){var n=t.withSequenceNumber(e.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(e,n)}},{key:"addReference",value:function(e,t,n){return this.ri.set(n,e.currentSequenceNumber),t6.resolve()}},{key:"removeReference",value:function(e,t,n){return this.ri.set(n,e.currentSequenceNumber),t6.resolve()}},{key:"updateLimboDocument",value:function(e,t){return this.ri.set(t,e.currentSequenceNumber),t6.resolve()}},{key:"zr",value:function(e){var t=e.key.toString().length;return e.isFoundDocument()&&(t+=function e(t){switch(n8(t)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:var n,r,i=n1(t);return i?16+e(i):16;case 5:return 2*t.stringValue.length;case 6:return nZ(t.bytesValue).approximateByteSize();case 7:return t.referenceValue.length;case 9:return(t.arrayValue.values||[]).reduce(function(t,n){return t+e(n)},0);case 10:case 11:return n=t.mapValue,r=0,nV(n.fields,function(t,n){r+=t.length+e(n)}),r;default:throw tS()}}(e.data.value)),t}},{key:"ir",value:function(e,t,n){var r=this;return t6.or([function(){return r.persistence.Yr(e,t)},function(){return r.persistence.getTargetCache().containsKey(e,t)},function(){var e=r.ri.get(t);return t6.resolve(void 0!==e&&e>n)}])}},{key:"getCacheSize",value:function(e){return this.persistence.getRemoteDocumentCache().getSize(e)}}],[{key:"ei",value:function(t,n){return new e(t,n)}}]),e}(),oj=function(){function e(t){(0,O._)(this,e),this.serializer=t}return(0,P._)(e,[{key:"O",value:function(e,t,n,r){var i=this,a=new t8("createOrUpgrade",t);n<1&&r>=1&&(e.createObjectStore("owner"),e.createObjectStore("mutationQueues",{keyPath:"userId"}),e.createObjectStore("mutations",{keyPath:"batchId",autoIncrement:!0}).createIndex("userMutationsIndex",ny,{unique:!0}),e.createObjectStore("documentMutations"),oq(e),e.createObjectStore("remoteDocuments"));var o=t6.resolve();return n<3&&r>=3&&(0!==n&&(e.deleteObjectStore("targetDocuments"),e.deleteObjectStore("targets"),e.deleteObjectStore("targetGlobal"),oq(e)),o=o.next(function(){var e,t;return e=a.store("targetGlobal"),t={highestTargetId:0,highestListenSequenceNumber:0,lastRemoteSnapshotVersion:tq.min().toTimestamp(),targetCount:0},e.put("targetGlobalKey",t)})),n<4&&r>=4&&(0!==n&&(o=o.next(function(){return a.store("mutations").U().next(function(t){e.deleteObjectStore("mutations"),e.createObjectStore("mutations",{keyPath:"batchId",autoIncrement:!0}).createIndex("userMutationsIndex",ny,{unique:!0});var n=a.store("mutations"),r=t.map(function(e){return n.put(e)});return t6.waitFor(r)})}
1)),o=o.next(function(){e.createObjectStore("clientMetadata",{keyPath:"clientId"})})),n<5&&r>=5&&(o=o.next(function(){return i.ii(a)})),n<6&&r>=6&&(o=o.next(function(){return e.createObjectStore("remoteDocumentGlobal"),i.si(a)})),n<7&&r>=7&&(o=o.next(function(){return i.oi(a)})),n<8&&r>=8&&(o=o.next(function(){return i._i(e,a)})),n<9&&r>=9&&(o=o.next(function(){e.objectStoreNames.contains("remoteDocumentChanges")&&e.deleteObjectStore("remoteDocumentChanges")})),n<10&&r>=10&&(o=o.next(function(){return i.ai(a)})),n<11&&r>=11&&(o=o.next(function(){e.createObjectStore("bundles",{keyPath:"bundleId"}),e.createObjectStore("namedQueries",{keyPath:"name"})})),n<12&&r>=12&&(o=o.next(function(){var t;(t=e.createObjectStore("documentOverlays",{keyPath:nx})).createIndex("collectionPathOverlayIndex",nA,{unique:!1}),t.createIndex("collectionGroupOverlayIndex",nD,{unique:!1})})),n<13&&r>=13&&(o=o.next(function(){var t;(t=e.createObjectStore("remoteDocumentsV14",{keyPath:nm})).createIndex("documentKeyIndex",ng),t.createIndex("collectionGroupIndex",n_)}).next(function(){return i.ui(e,a)}).next(function(){return e.deleteObjectStore("remoteDocuments")})),n<14&&r>=14&&(o=o.next(function(){return i.ci(e,a)})),n<15&&r>=15&&(o=o.next(function(){e.createObjectStore("indexConfiguration",{keyPath:"indexId",autoIncrement:!0}).createIndex("collectionGroupIndex","collectionGroup",{unique:!1}),e.createObjectStore("indexState",{keyPath:nT}).createIndex("sequenceNumberIndex",nE,{unique:!1}),e.createObjectStore("indexEntries",{keyPath:nS}).createIndex("documentKeyIndex",nC,{unique:!1})})),n<16&&r>=16&&(o=o.next(function(){t.objectStore("indexState").clear()}).next(function(){t.objectStore("indexEntries").clear()})),n<17&&r>=17&&(o=o.next(function(){e.createObjectStore("globals",{keyPath:"name"})})),o}},{key:"si",value:function(e){var t=0;return e.store("remoteDocuments").J(function(e,n){t+=ot(n)}).next(function(){var n={byteSize:t};return e.store("remoteDocumentGlobal").put("remoteDocumentGlobalKey",n)})}},{key:"ii",value:function(e){var t=this,n=e.store("mutationQueues"),r=e.store("mutations");return n.U().next(function(n){return t6.forEach(n,function(n){var i=IDBKeyRange.bound([n.userId,-1],[n.userId,n.lastAcknowledgedBatchId]);return r.U("userMutationsIndex",i).next(function(r){return t6.forEach(r,function(r){r.userId===n.userId||tS();var i=aT(t.serializer,r);return oe(e,n.userId,i).next(function(){})})})})})}},{key:"oi",value:function(e){var t=e.store("targetDocuments"),n=e.store("remoteDocuments");return e.store("targetGlobal").get("targetGlobalKey").next(function(e){var r=[];return n.J(function(n,i){var a=new tK(n),o=[0,nd(a)];r.push(t.get(o).next(function(n){return n?t6.resolve():t.put({targetId:0,path:nd(a),sequenceNumber:e.highestListenSequenceNumber})}))}).next(function(){return t6.waitFor(r)})})}},{key:"_i",value:function(e,t){e.createObjectStore("collectionParents",{keyPath:nI});var n=t.store("collectionParents"),r=new a0,i=function(e){if(r.add(e)){var t=e.lastSegment(),i=e.popLast();return n.put({collectionId:t,parent:nd(i)})}};return t.store("remoteDocuments").J({H:!0},function(e,t){return i(new tK(e).popLast())}).next(function(){return t.store("documentMutations").J({H:!0},function(e,t){var n=(0,D._)(e,3),r=(n[0],n[1]);return n[2],i(nv(r).popLast())})})}},{key:"ai",value:function(e){var t=this,n=e.store("targets");return n.J(function(e,r){var i=aE(r),a=aS(t.serializer,i);return n.put(a)})}},{key:"ui",value:function(e,t){var n=t.store("remoteDocuments"),r=[];return n.J(function(e,n){var i=t.store("remoteDocumentsV14"),a=(n.document?new tW(tK.fromString(n.document.name).popFirst(5)):n.noDocument?tW.fromSegments(n.noDocument.path):n.unknownDocument?tW.fromSegments(n.unknownDocument.path):tS()).path.toArray(),o={prefixPath:a.slice(0,a.length-2),collectionGroup:a[a.length-2],documentId:a[a.length-1],readTime:n.readTime||[0,0],unknownDocument:n.unknownDocument,noDocument:n.noDocument,document:n.document,hasCommittedMutations:!!n.hasCommittedMutations};r.push(i.put(o))}).next(function(){return t6.waitFor(r)})}},{key:"ci",value:function(e,t){var n=this,r=t.store("mutations"),i=new o_(this.serializer),a=new oU(oV.ei,this.serializer.ht);return r.U().next(function(e){var r=new Map;
1return e.forEach(function(e){var t,i=null!=(t=r.get(e.userId))?t:ii();aT(n.serializer,e).keys().forEach(function(e){return i=i.add(e)}),r.set(e.userId,i)}),t6.forEach(r,function(e,r){var o=new tg(r),s=aP.Pt(n.serializer,o),u=a.getIndexManager(o);return new oC(i,on.Pt(o,n.serializer,u,a.referenceDelegate),s,u).recalculateAndSaveOverlaysForDocumentKeys(new nM(t,nc.oe),e).next()})})}}]),e}();function oq(e){e.createObjectStore("targetDocuments",{keyPath:nb}).createIndex("documentTargetsIndex",nw,{unique:!0}),e.createObjectStore("targets",{keyPath:"targetId"}).createIndex("queryTargetsIndex",nk,{unique:!0}),e.createObjectStore("targetGlobal")}var oz="Failed to obtain exclusive access to the persistence layer. To allow shared access, multi-tab synchronization has to be enabled in all tabs. If you are using `experimentalForceOwningTab:true`, make sure that only one tab has persistence enabled at any given time.",oK=function(){function e(t,n,r,i,a,o,s,u,c,l){var h=arguments.length>10&&void 0!==arguments[10]?arguments[10]:17;if((0,O._)(this,e),this.allowTabSynchronization=t,this.persistenceKey=n,this.clientId=r,this.li=a,this.window=o,this.document=s,this.hi=c,this.Pi=l,this.Ti=h,this.$r=null,this.Ur=!1,this.isPrimary=!1,this.networkEnabled=!0,this.Ii=null,this.inForeground=!1,this.Ei=null,this.di=null,this.Ai=-1/0,this.Ri=function(e){return Promise.resolve()},!e.p())throw new tx(tC.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");this.referenceDelegate=new op(this,i),this.Vi=n+"main",this.serializer=new a_(u),this.mi=new t7(this.Vi,this.Ti,new oj(this.serializer)),this.Wr=new aM,this.Gr=new ou(this.referenceDelegate,this.serializer),this.remoteDocumentCache=new o_(this.serializer),this.jr=new aR,this.window&&this.window.localStorage?this.fi=this.window.localStorage:(this.fi=null,!1===l&&tI("IndexedDbPersistence","LocalStorage is unavailable. As a result, persistence may not work reliably. In particular enablePersistence() could fail immediately after refreshing the page."))}return(0,P._)(e,[{key:"start",value:function(){var e=this;return this.gi().then(function(){if(!e.isPrimary&&!e.allowTabSynchronization)throw new tx(tC.FAILED_PRECONDITION,oz);return e.pi(),e.yi(),e.wi(),e.runTransaction("getHighestListenSequenceNumber","readonly",function(t){return e.Gr.getHighestSequenceNumber(t)})}).then(function(t){e.$r=new nc(t,e.hi)}).then(function(){e.Ur=!0}).catch(function(t){return e.mi&&e.mi.close(),Promise.reject(t)})}},{key:"Si",value:function(e){var t=this;return this.Ri=function(n){return(0,N._)(function(){return(0,M._)(this,function(t){return this.started?[2,e(n)]:[2]})}).call(t)},e(this.isPrimary)}},{key:"setDatabaseDeletedListener",value:function(e){this.mi.L(function(t){return(0,N._)(function(){return(0,M._)(this,function(n){switch(n.label){case 0:if(null!==t.newVersion)return[3,2];return[4,e()];case 1:n.sent(),n.label=2;case 2:return[2]}})})()})}},{key:"setNetworkEnabled",value:function(e){var t=this;this.networkEnabled!==e&&(this.networkEnabled=e,this.li.enqueueAndForget(function(){return(0,N._)(function(){return(0,M._)(this,function(e){switch(e.label){case 0:if(!this.started)return[3,2];return[4,this.gi()];case 1:e.sent(),e.label=2;case 2:return[2]}})}).call(t)}))}},{key:"gi",value:function(){var e=this;return this.runTransaction("updateClientMetadataAndTryBecomePrimary","readwrite",function(t){return oH(t).put({clientId:e.clientId,updateTimeMs:Date.now(),networkEnabled:e.networkEnabled,inForeground:e.inForeground}).next(function(){if(e.isPrimary)return e.bi(t).next(function(t){t||(e.isPrimary=!1,e.li.enqueueRetryable(function(){return e.Ri(!1)}))})}).next(function(){return e.Di(t)}).next(function(n){return e.isPrimary&&!n?e.vi(t).next(function(){return!1}):!!n&&e.Ci(t).next(function(){return!0})})}).catch(function(t){if(nn(t))return tw("IndexedDbPersistence","Failed to extend owner lease: ",t),e.isPrimary;if(!e.allowTabSynchronization)throw t;return tw("IndexedDbPersistence","Releasing owner lease after error during lease refresh",t),!1}).then(function(t){e.isPrimary!==t&&e.li.enqueueRetryable(function(){return e.Ri(t)}),e.isPrimary=t})}},{key:"bi",value:function(e){var t=this;return oG(e).get("owner").next(function(e){return t6.resolve(t.Fi(e))})}},{key:"Mi",value:function(e){return oH(e).delete(this.clientId)}},{key:"xi",value:function(){return(0,N._)(function(){var e,t,n,r,i,a,o,s;return(0,M._)(this,function(u){switch(u.label){case 0:if(e=this,!(this.isPrimary&&!this.Oi(this.Ai,18e5)))return[3,2];return this.Ai=Date.now(),[4,this.runTransaction("maybeGarbageCollectMultiClientState","readwrite-primary",function(t){var n=nU(t,"clientMetadata");return n.U().next(function(t){var r=e.Ni(t,18e5),i=t.filter(function(e){return -1===r.indexOf(e)});
1return t6.forEach(i,function(e){return n.delete(e.clientId)}).next(function(){return i})})}).catch(function(){return[]})];case 1:if(t=u.sent(),n=!0,r=!1,i=void 0,this.fi)try{for(a=t[Symbol.iterator]();!(n=(o=a.next()).done);n=!0)s=o.value,this.fi.removeItem(this.Li(s.clientId))}catch(e){r=!0,i=e}finally{try{n||null==a.return||a.return()}finally{if(r)throw i}}u.label=2;case 2:return[2]}})}).call(this)}},{key:"wi",value:function(){var e=this;this.di=this.li.enqueueAfterDelay("client_metadata_refresh",4e3,function(){return e.gi().then(function(){return e.xi()}).then(function(){return e.wi()})})}},{key:"Fi",value:function(e){return!!e&&e.ownerId===this.clientId}},{key:"Di",value:function(e){var t=this;return this.Pi?t6.resolve(!0):oG(e).get("owner").next(function(n){if(null!==n&&t.Oi(n.leaseTimestampMs,5e3)&&!t.Bi(n.ownerId)){if(t.Fi(n)&&t.networkEnabled)return!0;if(!t.Fi(n)){if(!n.allowTabSynchronization)throw new tx(tC.FAILED_PRECONDITION,oz);return!1}}return!(!t.networkEnabled||!t.inForeground)||oH(e).U().next(function(e){return void 0===t.Ni(e,5e3).find(function(e){if(t.clientId!==e.clientId){var n=!t.networkEnabled&&e.networkEnabled,r=!t.inForeground&&e.inForeground,i=t.networkEnabled===e.networkEnabled;if(n||r&&i)return!0}return!1})})}).next(function(e){return t.isPrimary!==e&&tw("IndexedDbPersistence","Client ".concat(e?"is":"is not"," eligible for a primary lease.")),e})}},{key:"shutdown",value:function(){return(0,N._)(function(){var e;return(0,M._)(this,function(t){switch(t.label){case 0:return e=this,this.Ur=!1,this.ki(),this.di&&(this.di.cancel(),this.di=null),this.qi(),this.Qi(),[4,this.mi.runTransaction("shutdown","readwrite",["owner","clientMetadata"],function(t){var n=new nM(t,nc.oe);return e.vi(n).next(function(){return e.Mi(n)})})];case 1:return t.sent(),this.mi.close(),this.Ki(),[2]}})}).call(this)}},{key:"Ni",value:function(e,t){var n=this;return e.filter(function(e){return n.Oi(e.updateTimeMs,t)&&!n.Bi(e.clientId)})}},{key:"$i",value:function(){var e=this;return this.runTransaction("getActiveClients","readonly",function(t){return oH(t).U().next(function(t){return e.Ni(t,18e5).map(function(e){return e.clientId})})})}},{key:"started",get:function(){return this.Ur}},{key:"getGlobalsCache",value:function(){return this.Wr}},{key:"getMutationQueue",value:function(e,t){return on.Pt(e,this.serializer,t,this.referenceDelegate)}},{key:"getTargetCache",value:function(){return this.Gr}},{key:"getRemoteDocumentCache",value:function(){return this.remoteDocumentCache}},{key:"getIndexManager",value:function(e){return new a2(e,this.serializer.ht.databaseId)}},{key:"getDocumentOverlayCache",value:function(e){return aP.Pt(this.serializer,e)}},{key:"getBundleCache",value:function(){return this.jr}},{key:"runTransaction",value:function(e,t,n){var r,i,a=this;tw("IndexedDbPersistence","Starting transaction:",e);var o=17===(r=this.Ti)?nL:16===r||15===r?nP:14===r||13===r?nO:12===r?nN:11===r?nR:void tS();return this.mi.runTransaction(e,"readonly"===t?"readonly":"readwrite",o,function(r){return i=new nM(r,a.$r?a.$r.next():nc.oe),"readwrite-primary"===t?a.bi(i).next(function(e){return!!e||a.Di(i)}).next(function(t){if(!t)throw tI("Failed to obtain primary lease for action '".concat(e,"'.")),a.isPrimary=!1,a.li.enqueueRetryable(function(){return a.Ri(!1)}),new tx(tC.FAILED_PRECONDITION,t3);return n(i)}).next(function(e){return a.Ci(i).next(function(){return e})}):a.Ui(i).next(function(){return n(i)})}).then(function(e){return i.raiseOnCommittedEvent(),e})}},{key:"Ui",value:function(e){var t=this;return oG(e).get("owner").next(function(e){if(null!==e&&t.Oi(e.leaseTimestampMs,5e3)&&!t.Bi(e.ownerId)&&!t.Fi(e)&&!(t.Pi||t.allowTabSynchronization&&e.allowTabSynchronization))throw new tx(tC.FAILED_PRECONDITION,oz)})}},{key:"Ci",value:function(e){var t={ownerId:this.clientId,allowTabSynchronization:this.allowTabSynchronization,leaseTimestampMs:Date.now()};return oG(e).put("owner",t)}},{key:"vi",value:function(e){var t=this,n=oG(e);return n.get("owner").next(function(e){return t.Fi(e)?(tw("IndexedDbPersistence","Releasing primary lease."),n.delete("owner")):t6.resolve()})}},{key:"Oi",value:function(e,t){var n=Date.now();return!(e<n-t)&&(!(e>n)||(tI("Detected an update time that is in the future: ".concat(e," > ").concat(n)),!1))}},{key:"pi",value:function(){var e=this;null!==this.document&&"function"==typeof this.document.addEventListener&&(this.Ei=function(){e.li.enqueueAndForget(function(){return e.inForeground="visible"===e.document.visibilityState,e.gi()})},this.document.addEventListener("visibilitychange",this.Ei),this.inForeground="visible"===this.document.visibilityState)}},{key:"qi",value:function(){this.Ei&&(this.document.removeEventListener("visibilitychange",this.Ei),this.Ei=null)}},{key:"yi",value:function(){var e,t=this;"function"==typeof(null==(e=this.window)?void 0:e.addEventListener)&&(this.Ii=function(){t.ki();var e=/(?:Version|Mobile)\/1[456]/;ef()&&(navigator.appVersion.match(e)||navigator.userAgent.match(e))&&t.li.enterRestrictedMode(!0),t.li.enqueueAndForget(function(){return t.shutdown()})},this.window.addEventListener("pagehide",this.Ii))}},{key:"Qi",value:function(){this.Ii&&(this.window.removeEventListener("pagehide",this.Ii),this.Ii=null)}},{key:"Bi",value:function(e){var t;try{var n=null!==(null==(t=this.fi)?void 0:t.getItem(this.Li(e)));return tw("IndexedDbPersistence","Client '".concat(e,"' ").concat(n?"is":"is not"," zombied in LocalStorage")),n}catch(e){return tI("IndexedDbPersistence","Failed to get zombied client id.",e),!1}}},{key:"ki",value:function(){if(this.fi)try{this.fi.setItem(this.Li(this.clientId),String(Date.now()))}catch(e){tI("Failed to set zombie client id.",e)}}},{key:"Ki",value:function(){if(this.fi)try{this.fi.removeItem(this.Li(this.clientId))}catch(e){}}},{key:"Li",value:function(e){return"firestore_zombie_".concat(this.persistenceKey,"_").concat(e)}}],[{key:"p",value:function(){return t7.p()}}]),e}();function oG(e){return nU(e,"owner")}function oH(e){return nU(e,"clientMetadata")}function oW(e,t){var n=e.projectId;return e.isDefaultDatabase||(n+="."+e.database),"firestore/"+t+"/"+n+"/"}var oQ=function(){function e(t,n,r,i){(0,O._)(this,e),this.targetId=t,this.fromCache=n,this.Wi=r,this.Gi=i}return(0,P._)(e,null,[{key:"zi",value:function(t,n){var r=ii(),i=ii(),a=!0,o=!1,s=void 0;try{for(var u,c=n.docChanges[Symbol.iterator]();!(a=(u=c.next()).done);a=!0){var l=u.value;switch(l.type){case 0:r=r.add(l.doc.key);break;case 1:i=i.add(l.doc.key)}}}catch(e){o=!0,s=e}finally{try{a||null==c.return||c.return()}finally{if(o)throw s}}return new e(t,n.fromCache,r,i)}}]),e}(),oJ=function(){function e(){(0,O._)(this,e),this._documentReadCount=0}return(0,P._)(e,[{key:"documentReadCount",get:function(){return this._documentReadCount}},{key:"incrementDocumentReadCount",value:function(e){this._documentReadCount+=e}}]),e}(),oX=function(){function e(){(0,O._)(this,e),this.ji=!1,this.Hi=!1,this.Ji=100,this.Yi=ef()?8:t9(eh())>0?6:4}return(0,P._)(e,[{key:"initialize",value:function(e,t){this.Zi=e,this.indexManager=t,this.ji=!0}},{key:"getDocumentsMatchingQuery",value:function(e,t,n,r){var i=this,a={result:null};return this.Xi(e,t).next(function(e){a.result=e}).next(function(){if(!a.result)return i.es(e,t,r,n).next(function(e){a.result=e})}).next(function(){if(!a.result){var n=new oJ;return i.ts(e,t,n).next(function(r){if(a.result=r,i.Hi)return i.ns(e,t,n,r.size)})}}).next(function(){return a.result})}},{key:"ns",value:function(e,t,n,r){return n.documentReadCount<this.Ji?(tb()<=i.DEBUG&&tw("QueryEngine","SDK will not create cache indexes for query:",r2(t),"since it only creates cache indexes for collection contains","more than or equal to",this.Ji,"documents"),t6.resolve()):(tb()<=i.DEBUG&&tw("QueryEngine","Query:",r2(t),"scans",n.documentReadCount,"local documents and returns",r,"documents as results."),n.documentReadCount>this.Yi*r?(tb()<=i.DEBUG&&tw("QueryEngine","The SDK decides to create cache indexes for query:",r2(t),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(e,rY(t))):t6.resolve())}},{key:"Xi",value:function(e,t){var n=this;if(rQ(t))return t6.resolve(null);var r=rY(t);return this.indexManager.getIndexType(e,r).next(function(i){return 0===i?null:(null!==t.limit&&1===i&&(r=rY(t=rZ(t,null,"F"))),n.indexManager.getDocumentsMatchingTarget(e,r).next(function(i){var a=ii.apply(void 0,(0,L._)(i));return n.Zi.getDocuments(e,a).next(function(i){return n.indexManager.getMinOffset(e,r).next(function(r){var o=n.rs(t,i);return n.ss(t,o,a,r.readTime)?n.Xi(e,rZ(t,null,"F")):n.os(e,o,t,r)})})}))})}},{key:"es",value:function(e,t,n,r){var a=this;return rQ(t)||r.isEqual(tq.min())?t6.resolve(null):this.Zi.getDocuments(e,n).next(function(o){var s=a.rs(t,o);return a.ss(t,s,n,r)?t6.resolve(null):(tb()<=i.DEBUG&&tw("QueryEngine","Re-using previous result from %s to execute query: %s",r.toString(),r2(t)),a.os(e,s,t,tZ(r,-1)).next(function(e){return e}))})}},{key:"rs",value:function(e,t){var n=new nK(r5(e));return t.forEach(function(t,r){r3(e,r)&&(n=n.add(r))}),n}},{key:"ss",value:function(e,t,n,r){if(null===e.limit)return!1;if(n.size!==t.size)return!0;var i="F"===e.limitType?t.last():t.first();return!!i&&(i.hasPendingWrites||i.version.compareTo(r)>0)}},{key:"ts",value:function(e,t,n){return tb()<=i.DEBUG&&tw("QueryEngine","Using full collection scan to execute query:",r2(t)),this.Zi.getDocumentsMatchingQuery(e,t,t1.min(),n)}},{key:"os",value:function(e,t,n,r){return this.Zi.getDocumentsMatchingQuery(e,n,r).next(function(e){return t.forEach(function(t){e=e.insert(t.key,t)}),e})}}]),e}(),oY=function(){function e(t,n,r,i){(0,O._)(this,e),this.persistence=t,this._s=n,this.serializer
1=i,this.us=new nj(tV),this.cs=new r6(function(e){return rB(e)},rj),this.ls=new Map,this.hs=t.getRemoteDocumentCache(),this.Gr=t.getTargetCache(),this.jr=t.getBundleCache(),this.Ps(r)}return(0,P._)(e,[{key:"Ps",value:function(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new oC(this.hs,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.hs.setIndexManager(this.indexManager),this._s.initialize(this.localDocuments,this.indexManager)}},{key:"collectGarbage",value:function(e){var t=this;return this.persistence.runTransaction("Collect garbage","readwrite-primary",function(n){return e.collect(n,t.us)})}}]),e}();function o$(e,t){return(0,N._)(function(){var n;return(0,M._)(this,function(r){switch(r.label){case 0:return[4,(n=e).persistence.runTransaction("Handle user change","readonly",function(e){var r;return n.mutationQueue.getAllMutationBatches(e).next(function(i){return r=i,n.Ps(t),n.mutationQueue.getAllMutationBatches(e)}).next(function(t){var i=[],a=[],o=ii(),s=!0,u=!1,c=void 0;try{for(var l,h=r[Symbol.iterator]();!(s=(l=h.next()).done);s=!0){var f=l.value;i.push(f.batchId);var d=!0,v=!1,y=void 0;try{for(var p,m=f.mutations[Symbol.iterator]();!(d=(p=m.next()).done);d=!0){var g=p.value;o=o.add(g.key)}}catch(e){v=!0,y=e}finally{try{d||null==m.return||m.return()}finally{if(v)throw y}}}}catch(e){u=!0,c=e}finally{try{s||null==h.return||h.return()}finally{if(u)throw c}}var _=!0,k=!1,b=void 0;try{for(var w,I=t[Symbol.iterator]();!(_=(w=I.next()).done);_=!0){var T=w.value;a.push(T.batchId);var E=!0,S=!1,C=void 0;try{for(var x,A=T.mutations[Symbol.iterator]();!(E=(x=A.next()).done);E=!0){var D=x.value;o=o.add(D.key)}}catch(e){S=!0,C=e}finally{try{E||null==A.return||A.return()}finally{if(S)throw C}}}}catch(e){k=!0,b=e}finally{try{_||null==I.return||I.return()}finally{if(k)throw b}}return n.localDocuments.getDocuments(e,o).next(function(e){return{Ts:e,removedBatchIds:i,addedBatchIds:a}})})})];case 1:return[2,r.sent()]}})})()}function oZ(e){return e.persistence.runTransaction("Get last remote snapshot version","readonly",function(t){return e.Gr.getLastRemoteSnapshotVersion(t)})}function o0(e,t,n){var r=ii(),i=ii();return n.forEach(function(e){return r=r.add(e)}),t.getEntries(e,r).next(function(e){var r=r8;return n.forEach(function(n,a){var o=e.get(n);a.isFoundDocument()!==o.isFoundDocument()&&(i=i.add(n)),a.isNoDocument()&&a.version.isEqual(tq.min())?(t.removeEntry(n,a.readTime),r=r.insert(n,a)):!o.isValidDocument()||a.version.compareTo(o.version)>0||0===a.version.compareTo(o.version)&&o.hasPendingWrites?(t.addEntry(a),r=r.insert(n,a)):tw("LocalStore","Ignoring outdated watch update for ",n,". Current version:",o.version," Watch version:",a.version)}),{Is:r,Es:i}})}function o1(e,t){return e.persistence.runTransaction("Allocate target","readwrite",function(n){var r;return e.Gr.getTargetData(n,t).next(function(i){return i?(r=i,t6.resolve(r)):e.Gr.allocateTargetId(n).next(function(i){return r=new ag(t,i,"TargetPurposeListen",n.currentSequenceNumber),e.Gr.addTargetData(n,r).next(function(){return r})})})}).then(function(n){var r=e.us.get(n.targetId);return(null===r||n.snapshotVersion.compareTo(r.snapshotVersion)>0)&&(e.us=e.us.insert(n.targetId,n),e.cs.set(t,n.targetId)),n})}function o2(e,t,n){return(0,N._)(function(){var r,i,a,o;return(0,M._)(this,function(s){switch(s.label){case 0:i=(r=e).us.get(t),a=n?"readwrite":"readwrite-primary",s.label=1;case 1:if(s.trys.push([1,4,,5]),n)return[3,3];return[4,r.persistence.runTransaction("Release target",a,function(e){return r.persistence.referenceDelegate.removeTarget(e,i)})];case 2:s.sent(),s.label=3;case 3:return[3,5];case 4:if(!nn(o=s.sent()))throw o;return tw("LocalStore","Failed to update sequence numbers for target ".concat(t,": ").concat(o)),[3,5];case 5:return r.us=r.us.remove(t),r.cs.delete(i.target),[2]}})})()}function o3(e,t,n){var r=tq.min(),i=ii();return e.persistence.runTransaction("Execute query","readwrite",function(a){var o,s;return(o=rY(t),void 0!==(s=e.cs.get(o))?t6.resolve(e.us.get(s)):e.Gr.getTargetData(a,o)).next(function(t){if(t)return r=t.lastLimboFreeSnapshotVersion,e.Gr.getMatchingKeysForTargetId(a,t.targetId).next(function(e){i=e})}).next(function(){return e._s.getDocumentsMatchingQuery(a,t,n?r:tq.min(),n?i:ii())}).next(function(n){return o6(e,r4(t),n),{documents:n,ds:i}})})}function o4(e,t){var n=e.Gr,r=e.us.get(t);return r?Promise.resolve(r.target):e.persistence.runTransaction("Get target data","readonly",function(e){return n.ut(e,t).next(function(e){return e?e.target:null})})}function o5(e,t){var n=e.ls.get(t)||tq.min();return e.persistence.runTransaction("Get new document changes","readonly",function(r){return e.hs.getAllFromCollectionGroup(r,t,tZ(n,-1),Number.MAX_SAFE_INTEGER)}).then(function(n){return o6(e,t,n),n})}function o6(e,t,n){var r=e.ls.get(t)||tq.min();
1n.forEach(function(e,t){t.readTime.compareTo(r)>0&&(r=t.readTime)}),e.ls.set(t,r)}function o8(e,t){return"firestore_clients_".concat(e,"_").concat(t)}function o7(e,t,n){var r="firestore_mutations_".concat(e,"_").concat(n);return t.isAuthenticated()&&(r+="_".concat(t.uid)),r}function o9(e,t){return"firestore_targets_".concat(e,"_").concat(t)}var se=function(){function e(t,n,r,i){(0,O._)(this,e),this.user=t,this.batchId=n,this.state=r,this.error=i}return(0,P._)(e,[{key:"gs",value:function(){var e={state:this.state,updateTimeMs:Date.now()};return this.error&&(e.error={code:this.error.code,message:this.error.message}),JSON.stringify(e)}}],[{key:"fs",value:function(t,n,r){var i,a=JSON.parse(r),o="object"==(void 0===a?"undefined":(0,G._)(a))&&-1!==["pending","acknowledged","rejected"].indexOf(a.state)&&(void 0===a.error||"object"==(0,G._)(a.error));return o&&a.error&&(o="string"==typeof a.error.message&&"string"==typeof a.error.code)&&(i=new tx(a.error.code,a.error.message)),o?new e(t,n,a.state,i):(tI("SharedClientState","Failed to parse mutation state for ID '".concat(n,"': ").concat(r)),null)}}]),e}(),st=function(){function e(t,n,r){(0,O._)(this,e),this.targetId=t,this.state=n,this.error=r}return(0,P._)(e,[{key:"gs",value:function(){var e={state:this.state,updateTimeMs:Date.now()};return this.error&&(e.error={code:this.error.code,message:this.error.message}),JSON.stringify(e)}}],[{key:"fs",value:function(t,n){var r,i=JSON.parse(n),a="object"==(void 0===i?"undefined":(0,G._)(i))&&-1!==["not-current","current","rejected"].indexOf(i.state)&&(void 0===i.error||"object"==(0,G._)(i.error));return a&&i.error&&(a="string"==typeof i.error.message&&"string"==typeof i.error.code)&&(r=new tx(i.error.code,i.error.message)),a?new e(t,i.state,r):(tI("SharedClientState","Failed to parse target state for ID '".concat(t,"': ").concat(n)),null)}}]),e}(),sn=function(){function e(t,n){(0,O._)(this,e),this.clientId=t,this.activeTargetIds=n}return(0,P._)(e,null,[{key:"fs",value:function(t,n){for(var r=JSON.parse(n),i="object"==(void 0===r?"undefined":(0,G._)(r))&&(0,K._)(r.activeTargetIds,Array),a=ia,o=0;i&&o<r.activeTargetIds.length;++o)i=nf(r.activeTargetIds[o]),a=a.add(r.activeTargetIds[o]);return i?new e(t,a):(tI("SharedClientState","Failed to parse client data for instance '".concat(t,"': ").concat(n)),null)}}]),e}(),sr=function(){function e(t,n){(0,O._)(this,e),this.clientId=t,this.onlineState=n}return(0,P._)(e,null,[{key:"fs",value:function(t){var n=JSON.parse(t);return"object"==(void 0===n?"undefined":(0,G._)(n))&&-1!==["Unknown","Online","Offline"].indexOf(n.onlineState)&&"string"==typeof n.clientId?new e(n.clientId,n.onlineState):(tI("SharedClientState","Failed to parse online state: ".concat(t)),null)}}]),e}(),si=function(){function e(){(0,O._)(this,e),this.activeTargetIds=ia}return(0,P._)(e,[{key:"ps",value:function(e){this.activeTargetIds=this.activeTargetIds.add(e)}},{key:"ys",value:function(e){this.activeTargetIds=this.activeTargetIds.delete(e)}},{key:"gs",value:function(){return JSON.stringify({activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()})}}]),e}(),sa=function(){function e(t,n,r,i,a){(0,O._)(this,e),this.window=t,this.li=n,this.persistenceKey=r,this.ws=i,this.syncEngine=null,this.onlineStateHandler=null,this.sequenceNumberHandler=null,this.Ss=this.bs.bind(this),this.Ds=new nj(tV),this.started=!1,this.vs=[];var o,s,u,c=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");this.storage=this.window.localStorage,this.currentUser=a,this.Cs=o8(this.persistenceKey,this.ws),this.Fs=(o=this.persistenceKey,"firestore_sequence_number_".concat(o)),this.Ds=this.Ds.insert(this.ws,new si),this.Ms=new RegExp("^firestore_clients_".concat(c,"_([^_]*)$")),this.xs=new RegExp("^firestore_mutations_".concat(c,"_(\\d+)(?:_(.*))?$")),this.Os=new RegExp("^firestore_targets_".concat(c,"_(\\d+)$")),this.Ns=(s=this.persistenceKey,"firestore_online_state_".concat(s)),this.Ls=(u=this.persistenceKey,"firestore_bundle_loaded_v2_".concat(u)),this.window.addEventListener("storage",this.Ss)}return(0,P._)(e,[{key:"start",value:function(){return(0,N._)(function(){var e,t,n,r,i,a,o,s,u,c,l,h,f,d,v,y,p,m;return(0,M._)(this,function(g){switch(g.label){case 0:return e=this,[4,this.syncEngine.$i()];case 1:t=g.sent(),n=!0,r=!1,i=void 0;try{for(a=t[Symbol.iterator]();!(n=(o=a.next()).done);
1n=!0)(s=o.value)!==this.ws&&(u=this.getItem(o8(this.persistenceKey,s)))&&(c=sn.fs(s,u))&&(this.Ds=this.Ds.insert(c.clientId,c))}catch(e){r=!0,i=e}finally{try{n||null==a.return||a.return()}finally{if(r)throw i}}this.Bs(),(l=this.storage.getItem(this.Ns))&&(h=this.ks(l))&&this.qs(h),f=!0,d=!1,v=void 0;try{for(y=this.vs[Symbol.iterator]();!(f=(p=y.next()).done);f=!0)m=p.value,this.bs(m)}catch(e){d=!0,v=e}finally{try{f||null==y.return||y.return()}finally{if(d)throw v}}return this.vs=[],this.window.addEventListener("pagehide",function(){return e.shutdown()}),this.started=!0,[2]}})}).call(this)}},{key:"writeSequenceNumber",value:function(e){this.setItem(this.Fs,JSON.stringify(e))}},{key:"getAllActiveQueryTargets",value:function(){return this.Qs(this.Ds)}},{key:"isActiveQueryTarget",value:function(e){var t=!1;return this.Ds.forEach(function(n,r){r.activeTargetIds.has(e)&&(t=!0)}),t}},{key:"addPendingMutation",value:function(e){this.Ks(e,"pending")}},{key:"updateMutationState",value:function(e,t,n){this.Ks(e,t,n),this.$s(e)}},{key:"addLocalQueryTarget",value:function(e){var t=!(arguments.length>1)||void 0===arguments[1]||arguments[1],n="not-current";if(this.isActiveQueryTarget(e)){var r=this.storage.getItem(o9(this.persistenceKey,e));if(r){var i=st.fs(e,r);i&&(n=i.state)}}return t&&this.Us.ps(e),this.Bs(),n}},{key:"removeLocalQueryTarget",value:function(e){this.Us.ys(e),this.Bs()}},{key:"isLocalQueryTarget",value:function(e){return this.Us.activeTargetIds.has(e)}},{key:"clearQueryState",value:function(e){this.removeItem(o9(this.persistenceKey,e))}},{key:"updateQueryState",value:function(e,t,n){this.Ws(e,t,n)}},{key:"handleUserChange",value:function(e,t,n){var r=this;t.forEach(function(e){r.$s(e)}),this.currentUser=e,n.forEach(function(e){r.addPendingMutation(e)})}},{key:"setOnlineState",value:function(e){this.Gs(e)}},{key:"notifyBundleLoaded",value:function(e){this.zs(e)}},{key:"shutdown",value:function(){this.started&&(this.window.removeEventListener("storage",this.Ss),this.removeItem(this.Cs),this.started=!1)}},{key:"getItem",value:function(e){var t=this.storage.getItem(e);return tw("SharedClientState","READ",e,t),t}},{key:"setItem",value:function(e,t){tw("SharedClientState","SET",e,t),this.storage.setItem(e,t)}},{key:"removeItem",value:function(e){tw("SharedClientState","REMOVE",e),this.storage.removeItem(e)}},{key:"bs",value:function(e){var t=this;if(e.storageArea===this.storage){if(tw("SharedClientState","EVENT",e.key,e.newValue),e.key===this.Cs)return void tI("Received WebStorage notification for local change. Another client might have garbage-collected our state");this.li.enqueueRetryable(function(){return(0,N._)(function(){var t,n,r,i,a,o,s;return(0,M._)(this,function(u){switch(u.label){case 0:if(t=this,!this.started)return[3,8];if(null===e.key)return[3,7];if(!this.Ms.test(e.key))return[3,1];if(null==e.newValue)return n=this.js(e.key),[2,this.Hs(n,null)];if(r=this.Js(e.key,e.newValue))return[2,this.Hs(r.clientId,r)];return[3,7];case 1:if(!this.xs.test(e.key))return[3,2];if(null!==e.newValue&&(i=this.Ys(e.key,e.newValue)))return[2,this.Zs(i)];return[3,7];case 2:if(!this.Os.test(e.key))return[3,3];if(null!==e.newValue&&(a=this.Xs(e.key,e.newValue)))return[2,this.eo(a)];return[3,7];case 3:if(e.key!==this.Ns)return[3,4];if(null!==e.newValue&&(o=this.ks(e.newValue)))return[2,this.qs(o)];return[3,7];case 4:if(e.key!==this.Fs)return[3,5];return(s=function(e){var t=nc.oe;if(null!=e)try{var n=JSON.parse(e);"number"==typeof n||tS(),t=n}catch(e){tI("SharedClientState","Failed to read sequence number from WebStorage",e)}return t}(e.newValue))!==nc.oe&&this.sequenceNumberHandler(s),[3,7];case 5:if(e.key!==this.Ls)return[3,7];return[4,Promise.all(this.no(e.newValue).map(function(e){return t.syncEngine.ro(e)}))];case 6:u.sent(),u.label=7;case 7:return[3,9];case 8:this.vs.push(e),u.label=9;case 9:return[2]}})}).call(t)})}}},{key:"Us",get:function(){return this.Ds.get(this.ws)}},{key:"Bs",value:function(){this.setItem(this.Cs,this.Us.gs())}},{key:"Ks",value:function(e,t,n){var r=new se(this.currentUser,e,t,n),i=o7(this.persistenceKey,this.currentUser,e);this.setItem(i,r.gs())}},{key:"$s",value:function(e){var t=o7(this.persistenceKey,this.currentUser,e);this.removeItem(t)}},{key:"Gs",value:function(e){var t={clientId:this.ws,onlineState:e};this.storage.setItem(this.Ns,JSON.stringify(t))}},{key:"Ws",value:function(e,t,n){var r=o9(this.persistenceKey,e),i=new st(e,t,n);this.setItem(r,i.gs())}},{key:"zs",value:function(e){var t=JSON.stringify(Array.from(e));this.setItem(this.Ls,t)}},{key:"js",value:function(e){var t=this.Ms.exec(e);return t?t[1]:null}},{key:"Js",value:function(e,t){var n=this.js(e);return sn.fs(n,t)}},{key:"Ys",value:function(e,t){var n=this.xs.exec(e),r=Number(n[1]),i=void 0!==n[2]?n[2]:null;return se.fs(new tg(i),r,t)}},{key:"Xs",value:function(e,t){var n=Number(this.Os.exec(e)[1]);return st.fs(n,t)}},{key:"ks",value:function(e){return sr.fs(e)}},{key:"no",value:function(e){return JSON.parse(e)}},{key:"Zs",value:function(e){return(0,N._)(function(){return(0,M._)(this,function(t){return e.user.uid===this.currentUser.uid?[2,this.syncEngine.io(e.batchId,e.state,e.error)]:(tw("SharedCl
1ientState","Ignoring mutation for non-active user ".concat(e.user.uid)),[2])})}).call(this)}},{key:"eo",value:function(e){return this.syncEngine.so(e.targetId,e.state,e.error)}},{key:"Hs",value:function(e,t){var n=this,r=t?this.Ds.insert(e,t):this.Ds.remove(e),i=this.Qs(this.Ds),a=this.Qs(r),o=[],s=[];return a.forEach(function(e){i.has(e)||o.push(e)}),i.forEach(function(e){a.has(e)||s.push(e)}),this.syncEngine.oo(o,s).then(function(){n.Ds=r})}},{key:"qs",value:function(e){this.Ds.get(e.clientId)&&this.onlineStateHandler(e.onlineState)}},{key:"Qs",value:function(e){var t=ia;return e.forEach(function(e,n){t=t.unionWith(n.activeTargetIds)}),t}}],[{key:"p",value:function(e){return!(!e||!e.localStorage)}}]),e}(),so=function(){function e(){(0,O._)(this,e),this._o=new si,this.ao={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}return(0,P._)(e,[{key:"addPendingMutation",value:function(e){}},{key:"updateMutationState",value:function(e,t,n){}},{key:"addLocalQueryTarget",value:function(e){var t=!(arguments.length>1)||void 0===arguments[1]||arguments[1];return t&&this._o.ps(e),this.ao[e]||"not-current"}},{key:"updateQueryState",value:function(e,t,n){this.ao[e]=t}},{key:"removeLocalQueryTarget",value:function(e){this._o.ys(e)}},{key:"isLocalQueryTarget",value:function(e){return this._o.activeTargetIds.has(e)}},{key:"clearQueryState",value:function(e){delete this.ao[e]}},{key:"getAllActiveQueryTargets",value:function(){return this._o.activeTargetIds}},{key:"isActiveQueryTarget",value:function(e){return this._o.activeTargetIds.has(e)}},{key:"start",value:function(){return this._o=new si,Promise.resolve()}},{key:"handleUserChange",value:function(e,t,n){}},{key:"setOnlineState",value:function(e){}},{key:"shutdown",value:function(){}},{key:"writeSequenceNumber",value:function(e){}},{key:"notifyBundleLoaded",value:function(e){}}]),e}(),ss=function(){function e(){(0,O._)(this,e)}return(0,P._)(e,[{key:"uo",value:function(e){}},{key:"shutdown",value:function(){}}]),e}(),su=function(){function e(){var t=this;(0,O._)(this,e),this.co=function(){return t.lo()},this.ho=function(){return t.Po()},this.To=[],this.Io()}return(0,P._)(e,[{key:"uo",value:function(e){this.To.push(e)}},{key:"shutdown",value:function(){window.removeEventListener("online",this.co),window.removeEventListener("offline",this.ho)}},{key:"Io",value:function(){window.addEventListener("online",this.co),window.addEventListener("offline",this.ho)}},{key:"lo",value:function(){tw("ConnectivityMonitor","Network connectivity changed: AVAILABLE");var e=!0,t=!1,n=void 0;try{for(var r,i=this.To[Symbol.iterator]();!(e=(r=i.next()).done);e=!0)(0,r.value)(0)}catch(e){t=!0,n=e}finally{try{e||null==i.return||i.return()}finally{if(t)throw n}}}},{key:"Po",value:function(){tw("ConnectivityMonitor","Network connectivity changed: UNAVAILABLE");var e=!0,t=!1,n=void 0;try{for(var r,i=this.To[Symbol.iterator]();!(e=(r=i.next()).done);e=!0)(0,r.value)(1)}catch(e){t=!0,n=e}finally{try{e||null==i.return||i.return()}finally{if(t)throw n}}}}],[{key:"p",value:function(){return"u">typeof window&&void 0!==window.addEventListener&&void 0!==window.removeEventListener}}]),e}(),sc=null;function sl(){return null===sc?sc=0x10000000+Math.round(0x80000000*Math.random()):sc++,"0x"+sc.toString(16)}var sh={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery"},sf=function(){function e(t){(0,O._)(this,e),this.Eo=t.Eo,this.Ao=t.Ao}return(0,P._)(e,[{key:"Ro",value:function(e){this.Vo=e}},{key:"mo",value:function(e){this.fo=e}},{key:"po",value:function(e){this.yo=e}},{key:"onMessage",value:function(e){this.wo=e}},{key:"close",value:function(){this.Ao()}},{key:"send",value:function(e){this.Eo(e)}},{key:"So",value:function(){this.Vo()}},{key:"bo",value:function(){this.fo()}},{key:"Do",value:function(e){this.yo(e)}},{key:"vo",value:function(e){this.wo(e)}}]),e}(),sd="WebChannelConnection",sv=function(e){function t(e){var n;return(0,O._)(this,t),(n=(0,V._)(this,t,[e])).forceLongPolling=e.forceLongPolling,n.autoDetectLongPolling=e.autoDetectLongPolling,n.useFetchStreams=e.useFetchStreams,n.longPollingOptions=e.longPollingOptions,n}return(0,z._)(t,e),(0,P._)(t,[{key:"Bo",value:function(e,t,n,r){var i=sl();return new Promise(function(a,o){var s=new f;s.setWithCredentials(!0),s.listenOnce(v.COMPLETE,function(){try{
1switch(s.getLastErrorCode()){case y.NO_ERROR:var t=s.getResponseJson();tw(sd,"XHR for RPC '".concat(e,"' ").concat(i," received:"),JSON.stringify(t)),a(t);break;case y.TIMEOUT:tw(sd,"RPC '".concat(e,"' ").concat(i," timed out")),o(new tx(tC.DEADLINE_EXCEEDED,"Request time out"));break;case y.HTTP_ERROR:var n=s.getStatus();if(tw(sd,"RPC '".concat(e,"' ").concat(i," failed with status:"),n,"response text:",s.getResponseText()),n>0){var r=s.getResponseJson();Array.isArray(r)&&(r=r[0]);var u=null==r?void 0:r.error;if(u&&u.status&&u.message){var c,l=(c=u.status.toLowerCase().replace(/_/g,"-"),Object.values(tC).indexOf(c)>=0?c:tC.UNKNOWN);o(new tx(l,u.message))}else o(new tx(tC.UNKNOWN,"Server responded with status "+s.getStatus()))}else o(new tx(tC.UNAVAILABLE,"Connection failed."));break;default:tS()}}finally{tw(sd,"RPC '".concat(e,"' ").concat(i," completed."))}});var u=JSON.stringify(r);tw(sd,"RPC '".concat(e,"' ").concat(i," sending request:"),r),s.send(t,"POST",u,n,15)})}},{key:"qo",value:function(e,t,n){var r=sl(),i=[this.Fo,"/","google.firestore.v1.Firestore","/",e,"/channel"],a=_(),o=g(),s={httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:"projects/".concat(this.databaseId.projectId,"/databases/").concat(this.databaseId.database)},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling,detectBufferingProxy:this.autoDetectLongPolling},u=this.longPollingOptions.timeoutSeconds;void 0!==u&&(s.longPollingTimeout=Math.round(1e3*u)),this.useFetchStreams&&(s.useFetchStreams=!0),this.Lo(s.initMessageHeaders,t,n),s.encodeInitMessageHeaders=!0;var c=i.join("");tw(sd,"Creating RPC '".concat(e,"' stream ").concat(r,": ").concat(c),s);var l=a.createWebChannel(c,s),h=!1,f=!1,v=new sf({Eo:function(t){f?tw(sd,"Not sending because RPC '".concat(e,"' stream ").concat(r," is closed:"),t):(h||(tw(sd,"Opening RPC '".concat(e,"' stream ").concat(r," transport.")),l.open(),h=!0),tw(sd,"RPC '".concat(e,"' stream ").concat(r," sending:"),t),l.send(t))},Ao:function(){return l.close()}}),y=function(e,t,n){e.listen(t,function(e){try{n(e)}catch(e){setTimeout(function(){throw e},0)}})};return y(l,d.EventType.OPEN,function(){f||(tw(sd,"RPC '".concat(e,"' stream ").concat(r," transport opened.")),v.So())}),y(l,d.EventType.CLOSE,function(){f||(f=!0,tw(sd,"RPC '".concat(e,"' stream ").concat(r," transport closed")),v.Do())}),y(l,d.EventType.ERROR,function(t){f||(f=!0,tT(sd,"RPC '".concat(e,"' stream ").concat(r," transport errored:"),t),v.Do(new tx(tC.UNAVAILABLE,"The operation could not be completed")))}),y(l,d.EventType.MESSAGE,function(t){var n;if(!f){var i=t.data[0];i||tS();var a=(null==i?void 0:i.error)||(null==(n=i[0])?void 0:n.error);if(a){tw(sd,"RPC '".concat(e,"' stream ").concat(r," received error:"),a);var o=a.status,s=function(e){var t=k[e];if(void 0!==t)return iV(t)}(o),u=a.message;void 0===s&&(s=tC.INTERNAL,u="Unknown error status: "+o+" with message "+a.message),f=!0,v.Do(new tx(s,u)),l.close()}else tw(sd,"RPC '".concat(e,"' stream ").concat(r," received:"),i),v.vo(i)}}),y(o,m.STAT_EVENT,function(t){t.stat===p.PROXY?tw(sd,"RPC '".concat(e,"' stream ").concat(r," detected buffering proxy")):t.stat===p.NOPROXY&&tw(sd,"RPC '".concat(e,"' stream ").concat(r," detected no buffering proxy"))}),setTimeout(function(){v.bo()},0),v}}]),t}(function(){function e(t){(0,O._)(this,e),this.databaseInfo=t,this.databaseId=t.databaseId;var n=t.ssl?"https":"http",r=encodeURIComponent(this.databaseId.projectId),i=encodeURIComponent(this.databaseId.database);this.Fo=n+"://"+t.host,this.Mo="projects/".concat(r,"/databases/").concat(i),this.xo="(default)"===this.databaseId.database?"project_id=".concat(r):"project_id=".concat(r,"&database_id=").concat(i)}return(0,P._)(e,[{key:"Co",get:function(){return!1}},{key:"Oo",value:function(e,t,n,r,i){var a=sl(),o=this.No(e,t.toUriEncodedString());tw("RestConnection","Sending RPC '".concat(e,"' ").concat(a,":"),o,n);var s={"google-cloud-resource-prefix":this.Mo,"x-goog-request-params":this.xo};return this.Lo(s,r,i),this.Bo(e,o,s,n).then(function(t){return tw("RestConnection","Received RPC '".concat(e,"' ").concat(a,": "),t),t},function(t){throw tT("RestConnection","RPC '".concat(e,"' ").concat(a," failed with error: "),t,"url: ",o,"request:",n),t})}},{key:"ko",value:function(e,t,n,r,i,a){return this.Oo(e,t,n,r,i)}},{key:"Lo",value:function(e,t,n){e["X-Goog-Api-Client"]="gl-js/ fire/"+t_,e["Content-Type"]="text/plain",this.databaseInfo.appId&&(e["X-Firebase-GMPID"]=this.databaseInfo.appId),t&&t.headers.forEac
1h(function(t,n){return e[n]=t}),n&&n.headers.forEach(function(t,n){return e[n]=t})}},{key:"No",value:function(e,t){var n=sh[e];return"".concat(this.Fo,"/v1/").concat(t,":").concat(n)}},{key:"terminate",value:function(){}}]),e}());function sy(){return"u">typeof window?window:null}function sp(){return"u">typeof document?document:null}function sm(e){return new i4(e,!0)}var sg=function(){function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e3,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1.5,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:6e4;(0,O._)(this,e),this.li=t,this.timerId=n,this.Qo=r,this.Ko=i,this.$o=a,this.Uo=0,this.Wo=null,this.Go=Date.now(),this.reset()}return(0,P._)(e,[{key:"reset",value:function(){this.Uo=0}},{key:"zo",value:function(){this.Uo=this.$o}},{key:"jo",value:function(e){var t=this;this.cancel();var n=Math.floor(this.Uo+this.Ho()),r=Math.max(0,Date.now()-this.Go),i=Math.max(0,n-r);i>0&&tw("ExponentialBackoff","Backing off for ".concat(i," ms (base delay: ").concat(this.Uo," ms, delay with jitter: ").concat(n," ms, last attempt: ").concat(r," ms ago)")),this.Wo=this.li.enqueueAfterDelay(this.timerId,i,function(){return t.Go=Date.now(),e()}),this.Uo*=this.Ko,this.Uo<this.Qo&&(this.Uo=this.Qo),this.Uo>this.$o&&(this.Uo=this.$o)}},{key:"Jo",value:function(){null!==this.Wo&&(this.Wo.skipDelay(),this.Wo=null)}},{key:"cancel",value:function(){null!==this.Wo&&(this.Wo.cancel(),this.Wo=null)}},{key:"Ho",value:function(){return(Math.random()-.5)*this.Uo}}]),e}(),s_=function(){function e(t,n,r,i,a,o,s,u){(0,O._)(this,e),this.li=t,this.Yo=r,this.Zo=i,this.connection=a,this.authCredentialsProvider=o,this.appCheckCredentialsProvider=s,this.listener=u,this.state=0,this.Xo=0,this.e_=null,this.t_=null,this.stream=null,this.n_=0,this.r_=new sg(t,n)}return(0,P._)(e,[{key:"i_",value:function(){return 1===this.state||5===this.state||this.s_()}},{key:"s_",value:function(){return 2===this.state||3===this.state}},{key:"start",value:function(){this.n_=0,4!==this.state?this.auth():this.o_()}},{key:"stop",value:function(){return(0,N._)(function(){return(0,M._)(this,function(e){switch(e.label){case 0:if(!this.i_())return[3,2];return[4,this.close(0)];case 1:e.sent(),e.label=2;case 2:return[2]}})}).call(this)}},{key:"__",value:function(){this.state=0,this.r_.reset()}},{key:"a_",value:function(){var e=this;this.s_()&&null===this.e_&&(this.e_=this.li.enqueueAfterDelay(this.Yo,6e4,function(){return e.u_()}))}},{key:"c_",value:function(e){this.l_(),this.stream.send(e)}},{key:"u_",value:function(){return(0,N._)(function(){return(0,M._)(this,function(e){return this.s_()?[2,this.close(0)]:[2]})}).call(this)}},{key:"l_",value:function(){this.e_&&(this.e_.cancel(),this.e_=null)}},{key:"h_",value:function(){this.t_&&(this.t_.cancel(),this.t_=null)}},{key:"close",value:function(e,t){return(0,N._)(function(){return(0,M._)(this,function(n){switch(n.label){case 0:return this.l_(),this.h_(),this.r_.cancel(),this.Xo++,4!==e?this.r_.reset():t&&t.code===tC.RESOURCE_EXHAUSTED?(tI(t.toString()),tI("Using maximum backoff delay to prevent overloading the backend."),this.r_.zo()):t&&t.code===tC.UNAUTHENTICATED&&3!==this.state&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),null!==this.stream&&(this.P_(),this.stream.close(),this.stream=null),this.state=e,[4,this.listener.po(t)];case 1:return n.sent(),[2]}})}).call(this)}},{key:"P_",value:function(){}},{key:"auth",value:function(){var e=this;this.state=1;var t=this.T_(this.Xo),n=this.Xo;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then(function(t){var r=(0,D._)(t,2),i=r[0],a=r[1];e.Xo===n&&e.I_(i,a)},function(n){t(function(){var t=new tx(tC.UNKNOWN,"Fetching auth token failed: "+n.message);return e.E_(t)})})}},{key:"I_",value:function(e,t){var n=this,r=this.T_(this.Xo);this.stream=this.d_(e,t),this.stream.Ro(function(){r(function(){return n.listener.Ro()})}),this.stream.mo(function(){r(function(){return n.state=2,n.t_=n.li.enqueueAfterDelay(n.Zo,1e4,function(){return n.s_()&&(n.state=3),Promise.resolve()}),n.listener.mo()})}),this.stream.po(function(e){r(function(){return n.E_(e)})}),this.stream.onMessage(function(e){r(function(){return 1==++n.n_?n.A_(e):n.onNext(e)})})}},{key:"o_",value:function(){var e=this;this.state=5,this.r_.jo(function(){return(0,N._)(function(){return(0,M._)(this,function(e){return this.state=0,this.start(),[2]})}).call(e)})}},{key:"E_",value:function(e){return tw("PersistentStream","close with error: ".concat(e)),this.stream=null,this.close(4,e)}},{key:"T_",value:function(e){var t=this;return function(n){t.li.enqueueAndForget(function(){return t.Xo===e?n():(tw("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())})}}}]),e}(),sk=function(e){function t(e,n,r,i,a,o){var s;return(0,O._)(this,t),(s=(0,V._)(this,t,[e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",n,r,i,o])).serializer
1=a,s}return(0,z._)(t,e),(0,P._)(t,[{key:"d_",value:function(e,t){return this.connection.qo("Listen",e,t)}},{key:"A_",value:function(e){return this.onNext(e)}},{key:"onNext",value:function(e){this.r_.reset();var t=function(e,t){var n;if("targetChange"in t){t.targetChange;var r,i,a="NO_CHANGE"===(r=t.targetChange.targetChangeType||"NO_CHANGE")?0:"ADD"===r?1:"REMOVE"===r?2:"CURRENT"===r?3:"RESET"===r?4:tS(),o=t.targetChange.targetIds||[],s=(i=t.targetChange.resumeToken,e.useProto3Json?(void 0===i||"string"==typeof i||tS(),nJ.fromBase64String(i||"")):(void 0===i||(0,K._)(i,F.Buffer)||(0,K._)(i,Uint8Array)||tS(),nJ.fromUint8Array(i||new Uint8Array))),u=t.targetChange.cause;n=new iX(a,o,s,u&&new tx(void 0===u.code?tC.UNKNOWN:iV(u.code),u.message||"")||null)}else if("documentChange"in t){t.documentChange;var c=t.documentChange;c.document,c.document.name,c.document.updateTime;var l=ar(e,c.document.name),h=i7(c.document.updateTime),f=c.document.createTime?i7(c.document.createTime):tq.min(),d=new rp({mapValue:{fields:c.document.fields}}),v=rm.newFoundDocument(l,h,f,d);n=new iQ(c.targetIds||[],c.removedTargetIds||[],v.key,v)}else if("documentDelete"in t){t.documentDelete;var y=t.documentDelete;y.document;var p=ar(e,y.document),m=y.readTime?i7(y.readTime):tq.min(),g=rm.newNoDocument(p,m);n=new iQ([],y.removedTargetIds||[],g.key,g)}else if("documentRemove"in t){t.documentRemove;var _=t.documentRemove;_.document;var k=ar(e,_.document);n=new iQ([],_.removedTargetIds||[],k,null)}else{if(!("filter"in t))return tS();t.filter;var b=t.filter;b.targetId;var w=b.count,I=new iU(void 0===w?0:w,b.unchangedNames);n=new iJ(b.targetId,I)}return n}(this.serializer,e),n=function(e){if(!("targetChange"in e))return tq.min();var t=e.targetChange;return t.targetIds&&t.targetIds.length?tq.min():t.readTime?i7(t.readTime):tq.min()}(e);return this.listener.R_(t,n)}},{key:"V_",value:function(e){var t,n={};n.database=ao(this.serializer),n.addTarget=function(e,t){var n,r=t.target;if((n=rq(r)?{documents:af(e,r)}:{query:ad(e,r).ct}).targetId=t.targetId,t.resumeToken.approximateByteSize()>0){n.resumeToken=i8(e,t.resumeToken);var i=i5(e,t.expectedCount);null!==i&&(n.expectedCount=i)}else if(t.snapshotVersion.compareTo(tq.min())>0){n.readTime=i6(e,t.snapshotVersion.toTimestamp());var a=i5(e,t.expectedCount);null!==a&&(n.expectedCount=a)}return n}(this.serializer,e);var r=(this.serializer,null==(t=function(e){switch(e){case"TargetPurposeListen":return null;case"TargetPurposeExistenceFilterMismatch":return"existence-filter-mismatch";case"TargetPurposeExistenceFilterMismatchBloom":return"existence-filter-mismatch-bloom";case"TargetPurposeLimboResolution":return"limbo-document";default:return tS()}}(e.purpose))?null:{"goog-listen-tags":t});r&&(n.labels=r),this.c_(n)}},{key:"m_",value:function(e){var t={};t.database=ao(this.serializer),t.removeTarget=e,this.c_(t)}}]),t}(s_),sb=function(e){function t(e,n,r,i,a,o){var s;return(0,O._)(this,t),(s=(0,V._)(this,t,[e,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",n,r,i,o])).serializer=a,s}return(0,z._)(t,e),(0,P._)(t,[{key:"f_",get:function(){return this.n_>0}},{key:"start",value:function(){this.lastStreamToken=void 0,(0,j._)((0,q._)(t.prototype),"start",this).call(this)}},{key:"P_",value:function(){this.f_&&this.g_([])}},{key:"d_",value:function(e,t){return this.connection.qo("Write",e,t)}},{key:"A_",value:function(e){return e.streamToken||tS(),this.lastStreamToken=e.streamToken,e.writeResults&&0!==e.writeResults.length&&tS(),this.listener.p_()}},{key:"onNext",value:function(e){e.streamToken||tS(),this.lastStreamToken=e.streamToken,this.r_.reset();var t,n,r=(t=e.writeResults,n=e.commitTime,t&&t.length>0?(void 0!==n||tS(),t.map(function(e){var t;return(t=e.updateTime?i7(e.updateTime):i7(n)).isEqual(tq.min())&&(t=i7(n)),new ik(t,e.transformResults||[])})):[]),i=i7(e.commitTime);return this.listener.y_(i,r)}},{key:"w_",value:function(){var e={};e.database=ao(this.serializer),this.c_(e)}},{key:"g_",value:function(e){var t=this,n={streamToken:this.lastStreamToken,writes:e.map(function(e){return al(t.serializer,e)})};this.c_(n)}}]),t}(s_),sw=function(e){function t(e,n,r,i){var a;return(0,O._)(this,t),(a=(0,V._)(this,t)).authCredentials=e,a.appCheckCredentials=n,a.connection=r,a.serializer
1=i,a.S_=!1,a}return(0,z._)(t,e),(0,P._)(t,[{key:"b_",value:function(){if(this.S_)throw new tx(tC.FAILED_PRECONDITION,"The client has already been terminated.")}},{key:"Oo",value:function(e,t,n,r){var i=this;return this.b_(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(function(a){var o=(0,D._)(a,2),s=o[0],u=o[1];return i.connection.Oo(e,ae(t,n),r,s,u)}).catch(function(e){throw"FirebaseError"===e.name?(e.code===tC.UNAUTHENTICATED&&(i.authCredentials.invalidateToken(),i.appCheckCredentials.invalidateToken()),e):new tx(tC.UNKNOWN,e.toString())})}},{key:"ko",value:function(e,t,n,r,i){var a=this;return this.b_(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(function(o){var s=(0,D._)(o,2),u=s[0],c=s[1];return a.connection.ko(e,ae(t,n),r,u,c,i)}).catch(function(e){throw"FirebaseError"===e.name?(e.code===tC.UNAUTHENTICATED&&(a.authCredentials.invalidateToken(),a.appCheckCredentials.invalidateToken()),e):new tx(tC.UNKNOWN,e.toString())})}},{key:"terminate",value:function(){this.S_=!0,this.connection.terminate()}}]),t}(function e(){(0,O._)(this,e)}),sI=function(){function e(t,n){(0,O._)(this,e),this.asyncQueue=t,this.onlineStateHandler=n,this.state="Unknown",this.D_=0,this.v_=null,this.C_=!0}return(0,P._)(e,[{key:"F_",value:function(){var e=this;0===this.D_&&(this.M_("Unknown"),this.v_=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,function(){return e.v_=null,e.x_("Backend didn't respond within 10 seconds."),e.M_("Offline"),Promise.resolve()}))}},{key:"O_",value:function(e){"Online"===this.state?this.M_("Unknown"):(this.D_++,this.D_>=1&&(this.N_(),this.x_("Connection failed 1 times. Most recent error: ".concat(e.toString())),this.M_("Offline")))}},{key:"set",value:function(e){this.N_(),this.D_=0,"Online"===e&&(this.C_=!1),this.M_(e)}},{key:"M_",value:function(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}},{key:"x_",value:function(e){var t="Could not reach Cloud Firestore backend. ".concat(e,"\nThis typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.");this.C_?(tI(t),this.C_=!1):tw("OnlineStateTracker",t)}},{key:"N_",value:function(){null!==this.v_&&(this.v_.cancel(),this.v_=null)}}]),e}(),sT=function e(t,n,r,i,a){var o=this;(0,O._)(this,e),this.localStore=t,this.datastore=n,this.asyncQueue=r,this.remoteSyncer={},this.L_=[],this.B_=new Map,this.k_=new Set,this.q_=[],this.Q_=a,this.Q_.uo(function(e){r.enqueueAndForget(function(){return(0,N._)(function(){return(0,M._)(this,function(e){switch(e.label){case 0:var t;if(!sO(this))return[3,2];return tw("RemoteStore","Restarting streams for network reachability change."),[4,(t=this,(0,N._)(function(){var e;return(0,M._)(this,function(n){switch(n.label){case 0:return(e=t).k_.add(4),[4,sS(e)];case 1:return n.sent(),e.K_.set("Unknown"),e.k_.delete(4),[4,sE(e)];case 2:return n.sent(),[2]}})})())];case 1:e.sent(),e.label=2;case 2:return[2]}})}).call(o)})}),this.K_=new sI(r,i)};function sE(e){return(0,N._)(function(){var t,n,r,i,a,o;return(0,M._)(this,function(s){switch(s.label){case 0:if(t=!0,n=!1,r=void 0,!sO(e))return[3,8];s.label=1;case 1:s.trys.push([1,6,7,8]),i=e.q_[Symbol.iterator](),s.label=2;case 2:if(t=(a=i.next()).done)return[3,5];return[4,(0,a.value)(!0)];case 3:s.sent(),s.label=4;case 4:return t=!0,[3,2];case 5:return[3,8];case 6:return o=s.sent(),n=!0,r=o,[3,8];case 7:try{t||null==i.return||i.return()}finally{if(n)throw r}return[7];case 8:return[2]}})})()}function sS(e){return(0,N._)(function(){var t,n,r,i,a,o;return(0,M._)(this,function(s){switch(s.label){case 0:t=!0,n=!1,r=void 0,s.label=1;case 1:s.trys.push([1,6,7,8]),i=e.q_[Symbol.iterator](),s.label=2;case 2:if(t=(a=i.next()).done)return[3,5];return[4,(0,a.value)(!1)];case 3:s.sent(),s.label=4;case 4:return t=!0,[3,2];case 5:return[3,8];case 6:return o=s.sent(),n=!0,r=o,[3,8];case 7:try{t||null==i.return||i.return()}finally{if(n)throw r}return[7];case 8:return[2]}})})()}function sC(e,t){e.B_.has(t.targetId)||(e.B_.set(t.targetId,t),sN(e)?sR(e):sJ(e).s_()&&sA(e,t))}function sx(e,t){var n=sJ(e);e.B_.delete(t),n.s_()&&sD(e,t),0===e.B_.size&&(n.s_()?n.a_():sO(e)&&e.K_.set("Unknown"))}function sA(e,t){if(e.U_.xe(t.targetId),t.resumeToken.approximateByteSize()>0||t.snapshotVersion.compareTo(tq.min())>0){var n=e.remoteSyncer.getRemoteKeysForTarget(t.targetId).size;t=t.withExpectedCount(n)}sJ(e).V_(t)}function sD(e,t){e.U_.xe(t),sJ(e).m_(t)}function sR(e){e.U_=new i$({getRemoteKeysForTarget:function(t){return e.remoteSyncer.getRemoteKeysForTarget(t)},ut:function(t){return e.B_.get(t)||null},nt:function(){return e.datastore.serializer.databaseId}}),sJ(e).start(),e.K_.F_()}function sN(e){return sO(e)&&!sJ(e).i_()&&e.B_.size>0}function sO(e){return 0===e.k_.size}function sP(e){return(0,N._)(function(){return(0,M._)(this,function(t){return e.K_.set("Online"),[2]})})()}function sL(e){return(0,N._)(function(){return(0,M._)(this,function(t){return e.B_.forEach(function(t,n){sA(e,t)}),[2]})})()}function sM(e,t){return(0,N._)(function(){return(0,M._)(this,function(n){return e.U_=void 0,sN(e)?(e.K_.O_(t),sR(e)):e.K_.set("Unknown"),[2]})})()}function sU(e,t,n){return(0,N._)(function(){var r,i,a;return(0,M._)(this,function(o){var s;switch(o.label){case 0:if(e.K_.set("Online"),!(0,K._)(t,iX)||2!==t.state||!t.cause)return[3,6];o.label=1;case 1:return o.trys.push([1,3,,5]),[4,(0,N._)(function(){var n,r,i,a,o,s,u,c;return(0,M._)(this,function(l){switch(l.label){case 0:n=t.cause,r=!0,i=!1,a=void 0,l.label=1;case 1:l.trys.push([1,7,8,9]),o=t.targetIds[Symbol.iterator](),l.label=2;case 2:if(r=(s=o.next()).done)return[3,6];if(u=s.value,!e.B_.has(u))return[3,4];return[4,e.remoteSyncer.rejectListen(u,n)];case 3:l.sent(),e.B_.delete(u),e.U_.removeTarget(u),l.label=4;case 4:l.label=5;case 5:return r=!0,[3,2];case 6:return[3,9];case 7:return c=l.sent(),i=!0,a=c,[3,9];case 8:try{r||null==o.return||o.return()}finally{if(i)throw a}
1return[7];case 9:return[2]}})})()];case 2:case 4:return o.sent(),[3,5];case 3:return r=o.sent(),tw("RemoteStore","Failed to remove targets %s: %s ",t.targetIds.join(","),r),[4,sF(e,r)];case 5:return[3,13];case 6:if((0,K._)(t,iQ)?e.U_.$e(t):(0,K._)(t,iJ)?e.U_.Je(t):e.U_.Ge(t),n.isEqual(tq.min()))return[3,13];o.label=7;case 7:return o.trys.push([7,11,,13]),[4,oZ(e.localStore)];case 8:if(i=o.sent(),!(n.compareTo(i)>=0))return[3,10];return[4,((s=e.U_.it(n)).targetChanges.forEach(function(t,r){if(t.resumeToken.approximateByteSize()>0){var i=e.B_.get(r);i&&e.B_.set(r,i.withResumeToken(t.resumeToken,n))}}),s.targetMismatches.forEach(function(t,n){var r=e.B_.get(t);r&&(e.B_.set(t,r.withResumeToken(nJ.EMPTY_BYTE_STRING,r.snapshotVersion)),sD(e,t),sA(e,new ag(r.target,t,n,r.sequenceNumber)))}),e.remoteSyncer.applyRemoteEvent(s))];case 9:o.sent(),o.label=10;case 10:return[3,13];case 11:return tw("RemoteStore","Failed to raise snapshot:",a=o.sent()),[4,sF(e,a)];case 12:return o.sent(),[3,13];case 13:return[2]}})})()}function sF(e,t,n){return(0,N._)(function(){return(0,M._)(this,function(r){switch(r.label){case 0:if(!nn(t))throw t;return e.k_.add(1),[4,sS(e)];case 1:return r.sent(),e.K_.set("Offline"),n||(n=function(){return oZ(e.localStore)}),e.asyncQueue.enqueueRetryable(function(){return(0,N._)(function(){return(0,M._)(this,function(t){switch(t.label){case 0:return tw("RemoteStore","Retrying IndexedDB access"),[4,n()];case 1:return t.sent(),e.k_.delete(1),[4,sE(e)];case 2:return t.sent(),[2]}})})()}),[2]}})})()}function sV(e,t){return t().catch(function(n){return sF(e,n,t)})}function sB(e){return(0,N._)(function(){var t,n,r,i,a;return(0,M._)(this,function(o){var s,u,c,l,h,f;switch(o.label){case 0:n=sX(t=e),r=t.L_.length>0?t.L_[t.L_.length-1].batchId:-1,o.label=1;case 1:if(!(sO(s=t)&&s.L_.length<10))return[3,7];o.label=2;case 2:return o.trys.push([2,4,,6]),[4,(u=t.localStore,c=r,u.persistence.runTransaction("Get next mutation batch","readonly",function(e){return void 0===c&&(c=-1),u.mutationQueue.getNextMutationBatchAfterBatchId(e,c)}))];case 3:if(null===(i=o.sent()))return 0===t.L_.length&&n.a_(),[3,7];return r=i.batchId,l=t,h=i,l.L_.push(h),(f=sX(l)).s_()&&f.f_&&f.g_(h.mutations),[3,6];case 4:return a=o.sent(),[4,sF(t,a)];case 5:return o.sent(),[3,6];case 6:return[3,1];case 7:return sj(t)&&sq(t),[2]}})})()}function sj(e){return sO(e)&&!sX(e).i_()&&e.L_.length>0}function sq(e){sX(e).start()}function sz(e){return(0,N._)(function(){return(0,M._)(this,function(t){return sX(e).w_(),[2]})})()}function sK(e){return(0,N._)(function(){var t,n,r,i,a,o,s;return(0,M._)(this,function(u){t=sX(e),n=!0,r=!1,i=void 0;try{for(a=e.L_[Symbol.iterator]();!(n=(o=a.next()).done);n=!0)s=o.value,t.g_(s.mutations)}catch(e){r=!0,i=e}finally{try{n||null==a.return||a.return()}finally{if(r)throw i}}return[2]})})()}function sG(e,t,n){return(0,N._)(function(){var r,i;return(0,M._)(this,function(a){switch(a.label){case 0:return r=e.L_.shift(),i=iL.from(r,t,n),[4,sV(e,function(){return e.remoteSyncer.applySuccessfulWrite(i)})];case 1:return a.sent(),[4,sB(e)];case 2:return a.sent(),[2]}})})()}function sH(e,t){return(0,N._)(function(){return(0,M._)(this,function(n){switch(n.label){case 0:if(!(t&&sX(e).f_))return[3,2];return[4,(0,N._)(function(){var n;return(0,M._)(this,function(r){switch(r.label){case 0:var i;if(!(iF(i=t.code)&&i!==tC.ABORTED))return[3,3];return n=e.L_.shift(),sX(e).__(),[4,sV(e,function(){return e.remoteSyncer.rejectFailedWrite(n.batchId,t)})];case 1:return r.sent(),[4,sB(e)];case 2:r.sent(),r.label=3;case 3:return[2]}})})()];case 1:n.sent(),n.label=2;case 2:return sj(e)&&sq(e),[2]}})})()}function sW(e,t){return(0,N._)(function(){var n,r;return(0,M._)(this,function(i){switch(i.label){case 0:return(n=e).asyncQueue.verifyOperationInProgress(),tw("RemoteStore","RemoteStore received new credentials"),r=sO(n),n.k_.add(3),[4,sS(n)];case 1:return i.sent(),r&&n.K_.set("Unknown"),[4,n.remoteSyncer.handleCredentialChange(t)];case 2:return i.sent(),n.k_.delete(3),[4,sE(n)];case 3:return i.sent(),[2]}})})()}function sQ(e,t){return(0,N._)(function(){var n;return(0,M._)(this,function(r){switch(r.label){case 0:if(n=e,!t)return[3,2];return n.k_.delete(2),[4,sE(n)];case 1:return r.sent(),[3,5];case 2:if(t)return[3,4];return n.k_.add(2),[4,sS(n)];case 3:r.sent(),n.K_.set("Unknown"),r.label=4;case 4:r.label=5;case 5:return[2]}})})()}function sJ(e){var t,n,r;return e.W_||(t=e.datastore,n=e.asyncQueue,r={Ro:sP.bind(null,e),mo:sL.bind(null,e),po:sM.bind(null,e),R_:sU.bind(null,e)},t.b_(),e.W_=new sk(n,t.connection,t.authCredentials,t.appCheckCredentials,t.serializer,r),e.q_.push(function(t){return(0,N._)(function(){return(0,M._)(this,function(n){switch(n.label){case 0:if(!t)return[3,1];return e.W_.__(),sN(e)?sR(e):e.K_.set("Unknown"),[3,3];case 1:return[4,e.W_.stop()];case 2:n.sent(),e.U_=void 0,n.label=3;case 3:return[2]}})})()})),e.W_}function sX(e){var t,n,r;return e.G_||(t=e.datastore,n=e.asyncQueue,r={Ro:function(){return Promise.resolve()},mo:sz.bind(null,e),po:sH.bind(null,e),p_:sK.bind(null,e),y_:sG.bind(null,e)}
1,t.b_(),e.G_=new sb(n,t.connection,t.authCredentials,t.appCheckCredentials,t.serializer,r),e.q_.push(function(t){return(0,N._)(function(){return(0,M._)(this,function(n){switch(n.label){case 0:if(!t)return[3,2];return e.G_.__(),[4,sB(e)];case 1:return n.sent(),[3,4];case 2:return[4,e.G_.stop()];case 3:n.sent(),e.L_.length>0&&(tw("RemoteStore","Stopping write stream with ".concat(e.L_.length," pending writes")),e.L_=[]),n.label=4;case 4:return[2]}})})()})),e.G_}var sY=function(){function e(t,n,r,i,a){(0,O._)(this,e),this.asyncQueue=t,this.timerId=n,this.targetTimeMs=r,this.op=i,this.removalCallback=a,this.deferred=new tA,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch(function(e){})}return(0,P._)(e,[{key:"promise",get:function(){return this.deferred.promise}},{key:"start",value:function(e){var t=this;this.timerHandle=setTimeout(function(){return t.handleDelayElapsed()},e)}},{key:"skipDelay",value:function(){return this.handleDelayElapsed()}},{key:"cancel",value:function(e){null!==this.timerHandle&&(this.clearTimeout(),this.deferred.reject(new tx(tC.CANCELLED,"Operation cancelled"+(e?": "+e:""))))}},{key:"handleDelayElapsed",value:function(){var e=this;this.asyncQueue.enqueueAndForget(function(){return null!==e.timerHandle?(e.clearTimeout(),e.op().then(function(t){return e.deferred.resolve(t)})):Promise.resolve()})}},{key:"clearTimeout",value:function(){null!==this.timerHandle&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}}],[{key:"createAndSchedule",value:function(t,n,r,i,a){var o=new e(t,n,Date.now()+r,i,a);return o.start(r),o}}]),e}();function s$(e,t){if(tI("AsyncQueue","".concat(t,": ").concat(e)),nn(e))return new tx(tC.UNAVAILABLE,"".concat(t,": ").concat(e));throw e}var sZ=function(){function e(t){(0,O._)(this,e),this.comparator=t?function(e,n){return t(e,n)||tW.comparator(e.key,n.key)}:function(e,t){return tW.comparator(e.key,t.key)},this.keyedMap=r9(),this.sortedSet=new nj(this.comparator)}return(0,P._)(e,[{key:"has",value:function(e){return null!=this.keyedMap.get(e)}},{key:"get",value:function(e){return this.keyedMap.get(e)}},{key:"first",value:function(){return this.sortedSet.minKey()}},{key:"last",value:function(){return this.sortedSet.maxKey()}},{key:"isEmpty",value:function(){return this.sortedSet.isEmpty()}},{key:"indexOf",value:function(e){var t=this.keyedMap.get(e);return t?this.sortedSet.indexOf(t):-1}},{key:"size",get:function(){return this.sortedSet.size}},{key:"forEach",value:function(e){this.sortedSet.inorderTraversal(function(t,n){return e(t),!1})}},{key:"add",value:function(e){var t=this.delete(e.key);return t.copy(t.keyedMap.insert(e.key,e),t.sortedSet.insert(e,null))}},{key:"delete",value:function(e){var t=this.get(e);return t?this.copy(this.keyedMap.remove(e),this.sortedSet.remove(t)):this}},{key:"isEqual",value:function(t){if(!(0,K._)(t,e)||this.size!==t.size)return!1;for(var n=this.sortedSet.getIterator(),r=t.sortedSet.getIterator();n.hasNext();){var i=n.getNext().key,a=r.getNext().key;if(!i.isEqual(a))return!1}return!0}},{key:"toString",value:function(){var e=[];return this.forEach(function(t){e.push(t.toString())}),0===e.length?"DocumentSet ()":"DocumentSet (\n "+e.join(" \n")+"\n)"}},{key:"copy",value:function(t,n){var r=new e;return r.comparator=this.comparator,r.keyedMap=t,r.sortedSet=n,r}}],[{key:"emptySet",value:function(t){return new e(t.comparator)}}]),e}(),s0=function(){function e(){(0,O._)(this,e),this.z_=new nj(tW.comparator)}return(0,P._)(e,[{key:"track",value:function(e){var t=e.doc.key,n=this.z_.get(t);n?0!==e.type&&3===n.type?this.z_=this.z_.insert(t,e):3===e.type&&1!==n.type?this.z_=this.z_.insert(t,{type:n.type,doc:e.doc}):2===e.type&&2===n.type?this.z_=this.z_.insert(t,{type:2,doc:e.doc}):2===e.type&&0===n.type?this.z_=this.z_.insert(t,{type:0,doc:e.doc}):1===e.type&&0===n.type?this.z_=this.z_.remove(t):1===e.type&&2===n.type?this.z_=this.z_.insert(t,{type:1,doc:n.doc}):0===e.type&&1===n.type?this.z_=this.z_.insert(t,{type:2,doc:e.doc}):tS():this.z_=this.z_.insert(t,e)}},{key:"j_",value:function(){var e=[];return this.z_.inorderTraversal(function(t,n){e.push(n)}),e}}]),e}(),s1=function(){function e(t,n,r,i,a,o,s,u,c){(0,O._)(this,e),this.query=t,this.docs=n,this.oldDocs=r,this.docChanges=i,this.mutatedKeys=a,this.fromCache=o,this.syncStateChanged=s,this.excludesMetadataChanges=u,this.hasCachedResults=c}return(0,P._)(e,[{key:"hasPendingWrites",get:function(){return!this.mutatedKeys.isEmpty()}},{key:"isEqual",value:function(e){if(!(this.fromCache===e.fromCache&&this.hasCachedResults===e.hasCachedResults&&this.syncStateChanged===e.syncStateChanged&&this.mutatedKeys.isEqual(e.mutatedKeys)&&r0(this.query,e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;var t=this.docChanges,n=e.docChanges;if(t.length!==n.length)return!1;for(var r=0;r<t.length;r++)if(t[r].type!==n[r].type||!t[r].doc.isEqual(n[r].doc))return!1;return!0}}],[{key:"fromInitialDocuments",value:function(t,n,r,i,a){var o=[];
1return n.forEach(function(e){o.push({type:0,doc:e})}),new e(t,n,sZ.emptySet(n),o,r,i,!0,!1,a)}}]),e}(),s2=function(){function e(){(0,O._)(this,e),this.H_=void 0,this.J_=[]}return(0,P._)(e,[{key:"Y_",value:function(){return this.J_.some(function(e){return e.Z_()})}}]),e}(),s3=function(){function e(){(0,O._)(this,e),this.queries=s4(),this.onlineState="Unknown",this.X_=new Set}return(0,P._)(e,[{key:"terminate",value:function(){var e,t;e=new tx(tC.ABORTED,"Firestore shutting down"),t=this.queries,this.queries=s4(),t.forEach(function(t,n){var r=!0,i=!1,a=void 0;try{for(var o,s=n.J_[Symbol.iterator]();!(r=(o=s.next()).done);r=!0)o.value.onError(e)}catch(e){i=!0,a=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw a}}})}}]),e}();function s4(){return new r6(function(e){return r1(e)},r0)}function s5(e,t){return(0,N._)(function(){var n,r,i,a,o;return(0,M._)(this,function(s){switch(s.label){case 0:n=e,r=3,i=t.query,(a=n.queries.get(i))?!a.Y_()&&t.Z_()&&(r=2):(a=new s2,r=+!t.Z_()),s.label=1;case 1:switch(s.trys.push([1,9,,10]),r){case 0:return[3,2];case 1:return[3,4];case 2:return[3,6]}return[3,8];case 2:return[4,n.onListen(i,!0)];case 3:case 5:return a.H_=s.sent(),[3,8];case 4:return[4,n.onListen(i,!1)];case 6:return[4,n.onFirstRemoteStoreListen(i)];case 7:s.sent(),s.label=8;case 8:return[3,10];case 9:return o=s$(s.sent(),"Initialization of query '".concat(r2(t.query),"' failed")),[2,void t.onError(o)];case 10:return n.queries.set(i,a),a.J_.push(t),t.ea(n.onlineState),a.H_&&t.ta(a.H_)&&s9(n),[2]}})})()}function s6(e,t){return(0,N._)(function(){var n,r,i,a,o;return(0,M._)(this,function(s){switch(n=e,r=t.query,i=3,(a=n.queries.get(r))&&(o=a.J_.indexOf(t))>=0&&(a.J_.splice(o,1),0===a.J_.length?i=+!t.Z_():!a.Y_()&&t.Z_()&&(i=2)),i){case 0:return[2,(n.queries.delete(r),n.onUnlisten(r,!0))];case 1:return[2,(n.queries.delete(r),n.onUnlisten(r,!1))];case 2:return[2,n.onLastRemoteStoreUnlisten(r)];default:return[2]}})})()}function s8(e,t){var n=!1,r=!0,i=!1,a=void 0;try{for(var o,s=t[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var u=o.value,c=u.query,l=e.queries.get(c);if(l){var h=!0,f=!1,d=void 0;try{for(var v,y=l.J_[Symbol.iterator]();!(h=(v=y.next()).done);h=!0)v.value.ta(u)&&(n=!0)}catch(e){f=!0,d=e}finally{try{h||null==y.return||y.return()}finally{if(f)throw d}}l.H_=u}}}catch(e){i=!0,a=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw a}}n&&s9(e)}
1function s7(e,t,n){var r=e.queries.get(t),i=!0,a=!1,o=void 0;if(r)try{for(var s,u=r.J_[Symbol.iterator]();!(i=(s=u.next()).done);i=!0)s.value.onError(n)}catch(e){a=!0,o=e}finally{try{i||null==u.return||u.return()}finally{if(a)throw o}}e.queries.delete(t)}function s9(e){e.X_.forEach(function(e){e.next()})}(I=w||(w={})).na="default",I.Cache="cache";var ue=function(){function e(t,n,r){(0,O._)(this,e),this.query=t,this.ra=n,this.ia=!1,this.sa=null,this.onlineState="Unknown",this.options=r||{}}return(0,P._)(e,[{key:"ta",value:function(e){if(!this.options.includeMetadataChanges){var t=[],n=!0,r=!1,i=void 0;try{for(var a,o=e.docChanges[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){var s=a.value;3!==s.type&&t.push(s)}}catch(e){r=!0,i=e}finally{try{n||null==o.return||o.return()}finally{if(r)throw i}}e=new s1(e.query,e.docs,e.oldDocs,t,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}var u=!1;return this.ia?this.oa(e)&&(this.ra.next(e),u=!0):this._a(e,this.onlineState)&&(this.aa(e),u=!0),this.sa=e,u}},{key:"onError",value:function(e){this.ra.error(e)}},{key:"ea",value:function(e){this.onlineState=e;var t=!1;return this.sa&&!this.ia&&this._a(this.sa,e)&&(this.aa(this.sa),t=!0),t}},{key:"_a",value:function(e,t){return!(e.fromCache&&this.Z_())||(!this.options.ua||"Offline"===t)&&(!e.docs.isEmpty()||e.hasCachedResults||"Offline"===t)}},{key:"oa",value:function(e){if(e.docChanges.length>0)return!0;var t=this.sa&&this.sa.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&!0===this.options.includeMetadataChanges}},{key:"aa",value:function(e){e=s1.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.ia=!0,this.ra.next(e)}},{key:"Z_",value:function(){return this.options.source!==w.Cache}}]),e}(),ut=function(){function e(t,n){(0,O._)(this,e),this.ca=t,this.byteLength=n}return(0,P._)(e,[{key:"la",value:function(){return"metadata"in this.ca}}]),e}(),un=function(){function e(t){(0,O._)(this,e),this.serializer=t}return(0,P._)(e,[{key:"As",value:function(e){return ar(this.serializer,e)}},{key:"Rs",value:function(e){return e.metadata.exists?ac(this.serializer,e.document,!1):rm.newNoDocument(this.As(e.metadata.name),this.Vs(e.metadata.readTime))}},{key:"Vs",value:function(e){return i7(e)}}]),e}();(0,P._)(function e(t,n,r){var i;(0,O._)(this,e),this.ha=t,this.localStore=n,this.serializer=r,this.queries=[],this.documents=[],this.collectionGroups=new Set,this.progress={taskState:"Running",documentsLoaded:0,bytesLoaded:0,totalDocuments:(i=t).totalDocuments,totalBytes:i.totalBytes}},[{key:"Pa",value:function(e){this.progress.bytesLoaded+=e.byteLength;var t=this.progress.documentsLoaded;if(e.ca.namedQuery)this.queries.push(e.ca.namedQuery);else if(e.ca.documentMetadata){this.documents.push({metadata:e.ca.documentMetadata}),e.ca.documentMetadata.exists||++t;var n=tK.fromString(e.ca.documentMetadata.name);this.collectionGroups.add(n.get(n.length-2))}else e.ca.document&&(this.documents[this.documents.length-1].document=e.ca.document,++t);return t!==this.progress.documentsLoaded?(this.progress.documentsLoaded=t,Object.assign({},this.progress)):null}},{key:"Ta",value:function(e){var t=new Map,n=new un(this.serializer),r=!0,i=!1,a=void 0;try{for(var o,s=e[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var u=o.value;if(u.metadata.queries){var c=n.As(u.metadata.name),l=!0,h=!1,f=void 0;try{for(var d,v=u.metadata.queries[Symbol.iterator]();!(l=(d=v.next()).done);l=!0){var y=d.value,p=(t.get(y)||ii()).add(c);t.set(y,p)}}catch(e){h=!0,f=e}finally{try{l||null==v.return||v.return()}finally{if(h)throw f}}}}}catch(e){i=!0,a=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw a}}return t}},{key:"complete",value:function(){return(0,N._)(function(){var e,t,n,r,i,a,o,s,u;return(0,M._)(this,function(c){switch(c.label){case 0:var l,h,f,d;return[4,(l=this.localStore,h=new un(this.serializer),f=this.documents,d=this.ha.id,(0,N._)(function(){var e,t,n,r,i,a,o,s,u,c,v,y,p;return(0,M._)(this,function(m){switch(m.label){case 0:e=l,t=ii(),n=r8,r=!0,i=!1,a=void 0;try{for(o=f[Symbol.iterator]();!(r=(s=o.next()).done);r=!0)u=s.value,c=h.As(u.metadata.name),u.document&&(t=t.add(c)),(v=h.Rs(u)).setReadTime(h.Vs(u.metadata.readTime)),n=n.insert(c,v)}catch(e){i=!0,a=e}finally{try{r||null==o.return||o.return()}finally{if(i)throw a}}return y=e.hs.newChangeBuffer({trackRemovals:!0}),[4,o1(e,rY(rW(tK.fromString("__bundle__/docs/".concat(d)))))];case 1:return p=m.sent(),[2,e.persistence.runTransaction("Apply bundle documents","readwrite",function(r){return o0(r,y,n).next(function(e){return y.apply(r),e}).next(function(n){return e.Gr.removeMatchingKeysForTargetId(r,p.targetId).next(function(){return e.Gr.addMatchingKeys(r,t,p.targetId)}).next(function(){return e.localDocuments.getLocalViewOfDocuments(r,n.Is,n.Es)}).next(function(){return n.Is})})})]}})})())];case 1:e=c.sent(),t=this.Ta(this.documents),n=!0,r=!1,i=void 0,c.label=2;case 2:c.trys.push([2,7,8,9]),a=this.queries[Symbol.iterator](),c.label=3;case 3:if(n=(o=a.next()).done)return[3,6];return s=o.value,[4,function(e,t){return(0,N._)(function(e,t){var n,r,i,a=arguments;return(0,M._)(this,function(o){switch(o.label){case 0:return n=a.length>2&&void 0!==a[2]?a[2]:ii(),[4,o1(e,rY(aC(t.bundledQuery)))];case 1:return r=o.sent(),[2,(i=e).persistence.runTransaction("Save named query","readwrite",function(e){var a=i7(t.readTime);if(r.snapshotVersion.compareTo(a)>=0)return i.jr.saveNamedQuery(e,t);var o=r.withResumeToken(nJ.EMPTY_BYTE_STRING,a);return i.us=i.us.insert(o.targetId,o),i.Gr.updateTargetData(e,o).next(function(){return i.Gr.removeMatchingKeysForTargetId(e,r.targetId)}).next(function(){return i.Gr.addMatchingKeys(e,n,r.targetId)}).next(function(){return i.jr.saveNamedQuery(e,t)})})]}})}).apply(this,arguments)}(this.localStore,s,t.get(s.name))];case 4:c.sent(),c.label=5;case 5:return n=!0,[3,3];case 6:return[3,9];case 7:return u=c.sent(),r=!0,i=u,[3,9];case 8:try{n||null==a.return||a.return()}finally{if(r)throw i}
1return[7];case 9:return[2,(this.progress.taskState="Success",{progress:this.progress,Ia:this.collectionGroups,Ea:e})]}})}).call(this)}}]);var ur=function e(t){(0,O._)(this,e),this.key=t},ui=function e(t){(0,O._)(this,e),this.key=t},ua=function(){function e(t,n){(0,O._)(this,e),this.query=t,this.da=n,this.Aa=null,this.hasCachedResults=!1,this.current=!1,this.Ra=ii(),this.mutatedKeys=ii(),this.Va=r5(t),this.ma=new sZ(this.Va)}return(0,P._)(e,[{key:"fa",get:function(){return this.da}},{key:"ga",value:function(e,t){var n=this,r=t?t.pa:new s0,i=t?t.ma:this.ma,a=t?t.mutatedKeys:this.mutatedKeys,o=i,s=!1,u="F"===this.query.limitType&&i.size===this.query.limit?i.last():null,c="L"===this.query.limitType&&i.size===this.query.limit?i.first():null;if(e.inorderTraversal(function(e,t){var l=i.get(e),h=r3(n.query,t)?t:null,f=!!l&&n.mutatedKeys.has(l.key),d=!!h&&(h.hasLocalMutations||n.mutatedKeys.has(h.key)&&h.hasCommittedMutations),v=!1;l&&h?l.data.isEqual(h.data)?f!==d&&(r.track({type:3,doc:h}),v=!0):n.ya(l,h)||(r.track({type:2,doc:h}),v=!0,(u&&n.Va(h,u)>0||c&&0>n.Va(h,c))&&(s=!0)):!l&&h?(r.track({type:0,doc:h}),v=!0):l&&!h&&(r.track({type:1,doc:l}),v=!0,(u||c)&&(s=!0)),v&&(h?(o=o.add(h),a=d?a.add(e):a.delete(e)):(o=o.delete(e),a=a.delete(e)))}),null!==this.query.limit)for(;o.size>this.query.limit;){var l="F"===this.query.limitType?o.last():o.first();o=o.delete(l.key),a=a.delete(l.key),r.track({type:1,doc:l})}return{ma:o,pa:r,ss:s,mutatedKeys:a}}},{key:"ya",value:function(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}},{key:"applyChanges",value:function(e,t,n,r){var i=this,a=this.ma;this.ma=e.ma,this.mutatedKeys=e.mutatedKeys;var o=e.pa.j_();o.sort(function(e,t){var n,r,a;return n=e.type,r=t.type,(a=function(e){switch(e){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return tS()}})(n)-a(r)||i.Va(e.doc,t.doc)}),this.wa(n),r=null!=r&&r;var s=t&&!r?this.Sa():[],u=0===this.Ra.size&&this.current&&!r?1:0,c=u!==this.Aa;return(this.Aa=u,0!==o.length||c)?{snapshot:new s1(this.query,e.ma,a,o,e.mutatedKeys,0===u,c,!1,!!n&&n.resumeToken.approximateByteSize()>0),ba:s}:{ba:s}}},{key:"ea",value:function(e){return this.current&&"Offline"===e?(this.current=!1,this.applyChanges({ma:this.ma,pa:new s0,mutatedKeys:this.mutatedKeys,ss:!1},!1)):{ba:[]}}},{key:"Da",value:function(e){return!this.da.has(e)&&!!this.ma.has(e)&&!this.ma.get(e).hasLocalMutations}},{key:"wa",value:function(e){var t=this;e&&(e.addedDocuments.forEach(function(e){return t.da=t.da.add(e)}),e.modifiedDocuments.forEach(function(e){}),e.removedDocuments.forEach(function(e){return t.da=t.da.delete(e)}),this.current=e.current)}},{key:"Sa",value:function(){var e=this;if(!this.current)return[];var t=this.Ra;this.Ra=ii(),this.ma.forEach(function(t){e.Da(t.key)&&(e.Ra=e.Ra.add(t.key))});var n=[];return t.forEach(function(t){e.Ra.has(t)||n.push(new ui(t))}),this.Ra.forEach(function(e){t.has(e)||n.push(new ur(e))}),n}},{key:"va",value:function(e){this.da=e.ds,this.Ra=ii();var t=this.ga(e.documents);return this.applyChanges(t,!0)}},{key:"Ca",value:function(){return s1.fromInitialDocuments(this.query,this.ma,this.mutatedKeys,0===this.Aa,this.hasCachedResults)}}]),e}(),uo=function e(t,n,r){(0,O._)(this,e),this.query=t,this.targetId=n,this.view=r},us=function e(t){(0,O._)(this,e),this.key=t,this.Fa=!1},uu=function(){function e(t,n,r,i,a,o){(0,O._)(this,e),this.localStore=t,this.remoteStore=n,this.eventManager=r,this.sharedClientState=i,this.currentUser=a,this.maxConcurrentLimboResolutions=o,this.Ma={},this.xa=new r6(function(e){return r1(e)},r0),this.Oa=new Map,this.Na=new Set,this.La=new nj(tW.comparator),this.Ba=new Map,this.ka=new oR,this.qa={},this.Qa=new Map,this.Ka=os.Qn(),this.onlineState="Unknown",this.$a=void 0}return(0,P._)(e,[{key:"isPrimaryClient",get:function(){return!0===this.$a}}]),e}();function uc(e,t){return(0,N._)(function(e,t){var n,r,i,a,o=arguments;return(0,M._)(this,function(s){switch(s.label){case 0:if(n=!(o.length>2)||void 0===o[2]||o[2],!(a=(r=uM(e)).xa.get(t)))return[3,1];return r.sharedClientState.addLocalQueryTarget(a.targetId),i=a.view.Ca(),[3,3];case 1:return[4,uh(r,t,n,!0)];case 2:i=s.sent(),s.label=3;case 3:return[2,i]}})}).apply(this,arguments)}function ul(e,t){return(0,N._)(function(){return(0,M._)(this,function(n){switch(n.label){case 0:return[4,uh(uM(e),t,!0,!1)];case 1:return n.sent(),[2]}})})()}function uh(e,t,n,r){return(0,N._)(function(){var i,a,o,s;return(0,M._)(this,function(u){switch(u.label){case 0:return[4,o1(e.localStore,rY(t))];
1case 1:if(a=(i=u.sent()).targetId,o=e.sharedClientState.addLocalQueryTarget(a,n),!r)return[3,3];return[4,uf(e,t,a,"current"===o,i.resumeToken)];case 2:s=u.sent(),u.label=3;case 3:return[2,(e.isPrimaryClient&&n&&sC(e.remoteStore,i),s)]}})})()}function uf(e,t,n,r,i){return(0,N._)(function(){var a,o,s,u,c,l;return(0,M._)(this,function(h){switch(h.label){case 0:return e.Ua=function(t,n,r){return(0,N._)(function(){var i,a,o,s;return(0,M._)(this,function(u){switch(u.label){case 0:if(!(i=t.view.ga(n)).ss)return[3,2];return[4,o3(e.localStore,t.query,!1).then(function(e){var n=e.documents;return t.view.ga(n,i)})];case 1:i=u.sent(),u.label=2;case 2:return a=r&&r.targetChanges.get(t.targetId),o=r&&null!=r.targetMismatches.get(t.targetId),s=t.view.applyChanges(i,e.isPrimaryClient,a,o),[2,(uT(e,t.targetId,s.ba),s.snapshot)]}})})()},[4,o3(e.localStore,t,!0)];case 1:return s=(o=new ua(t,(a=h.sent()).ds)).ga(a.documents),u=iW.createSynthesizedTargetChangeForCurrentChange(n,r&&"Offline"!==e.onlineState,i),c=o.applyChanges(s,e.isPrimaryClient,u),uT(e,n,c.ba),l=new uo(t,n,o),[2,(e.xa.set(t,l),e.Oa.has(n)?e.Oa.get(n).push(t):e.Oa.set(n,[t]),c.snapshot)]}})})()}function ud(e,t,n){return(0,N._)(function(){var r,i,a;return(0,M._)(this,function(o){switch(o.label){case 0:if(i=(r=e).xa.get(t),(a=r.Oa.get(i.targetId)).length>1)return[2,(r.Oa.set(i.targetId,a.filter(function(e){return!r0(e,t)})),void r.xa.delete(t))];if(!r.isPrimaryClient)return[3,3];if(r.sharedClientState.removeLocalQueryTarget(i.targetId),r.sharedCl
1ientState.isActiveQueryTarget(i.targetId))return[3,2];return[4,o2(r.localStore,i.targetId,!1).then(function(){r.sharedClientState.clearQueryState(i.targetId),n&&sx(r.remoteStore,i.targetId),uw(r,i.targetId)}).catch(t5)];case 1:o.sent(),o.label=2;case 2:return[3,5];case 3:return uw(r,i.targetId),[4,o2(r.localStore,i.targetId,!0)];case 4:o.sent(),o.label=5;case 5:return[2]}})})()}function uv(e,t){return(0,N._)(function(){var n,r,i;return(0,M._)(this,function(a){return r=(n=e).xa.get(t),i=n.Oa.get(r.targetId),n.isPrimaryClient&&1===i.length&&(n.sharedClientState.removeLocalQueryTarget(r.targetId),sx(n.remoteStore,r.targetId)),[2]})})()}function uy(e,t){return(0,N._)(function(){var n,r;return(0,M._)(this,function(i){switch(i.label){case 0:n=e,i.label=1;case 1:var a,o,s,u;return i.trys.push([1,4,,6]),[4,(a=n.localStore,s=(o=t).snapshotVersion,u=a.us,a.persistence.runTransaction("Apply remote event","readwrite-primary",function(e){var t=a.hs.newChangeBuffer({trackRemovals:!0});u=a.us;var n=[];o.targetChanges.forEach(function(t,r){var i=u.get(r);if(i){n.push(a.Gr.removeMatchingKeys(e,t.removedDocuments,r).next(function(){return a.Gr.addMatchingKeys(e,t.addedDocuments,r)}));var c,l=i.withSequenceNumber(e.currentSequenceNumber);null!==o.targetMismatches.get(r)?l=l.withResumeToken(nJ.EMPTY_BYTE_STRING,tq.min()).withLastLimboFreeSnapshotVersion(tq.min()):t.resumeToken.approximateByteSize()>0&&(l=l.withResumeToken(t.resumeToken,s)),u=u.insert(r,l),c=l,(0===i.resumeToken.approximateByteSize()||c.snapshotVersion.toMicroseconds()-i.snapshotVersion.toMicroseconds()>=3e8||t.addedDocuments.size+t.modifiedDocuments.size+t.removedDocuments.size>0)&&n.push(a.Gr.updateTargetData(e,l))}});var r=r8,i=ii();if(o.documentUpdates.forEach(function(t){o.resolvedLimboDocuments.has(t)&&n.push(a.persistence.referenceDelegate.updateLimboDocument(e,t))}),n.push(o0(e,t,o.documentUpdates).next(function(e){r=e.Is,i=e.Es})),!s.isEqual(tq.min())){var c=a.Gr.getLastRemoteSnapshotVersion(e).next(function(t){return a.Gr.setTargetsMetadata(e,e.currentSequenceNumber,s)});n.push(c)}return t6.waitFor(n).next(function(){return t.apply(e)}).next(function(){return a.localDocuments.getLocalViewOfDocuments(e,r,i)}).next(function(){return r})}).then(function(e){return a.us=u,e}))];
1case 2:return r=i.sent(),t.targetChanges.forEach(function(e,t){var r=n.Ba.get(t);r&&(e.addedDocuments.size+e.modifiedDocuments.size+e.removedDocuments.size<=1||tS(),e.addedDocuments.size>0?r.Fa=!0:e.modifiedDocuments.size>0?r.Fa||tS():e.removedDocuments.size>0&&(r.Fa||tS(),r.Fa=!1))}),[4,uS(n,r,t)];case 3:case 5:return i.sent(),[3,6];case 4:return[4,t5(i.sent())];case 6:return[2]}})})()}function up(e,t,n){if(e.isPrimaryClient&&0===n||!e.isPrimaryClient&&1===n){var r,i,a=[];e.xa.forEach(function(e,n){var r=n.view.ea(t);r.snapshot&&a.push(r.snapshot)}),(r=e.eventManager).onlineState=t,i=!1,r.queries.forEach(function(e,n){var r=!0,a=!1,o=void 0;try{for(var s,u=n.J_[Symbol.iterator]();!(r=(s=u.next()).done);r=!0)s.value.ea(t)&&(i=!0)}catch(e){a=!0,o=e}finally{try{r||null==u.return||u.return()}finally{if(a)throw o}}}),i&&s9(r),a.length&&e.Ma.R_(a),e.onlineState=t,e.isPrimaryClient&&e.sharedClientState.setOnlineState(t)}}function um(e,t,n){return(0,N._)(function(){var r,i,a,o,s,u;return(0,M._)(this,function(c){switch(c.label){case 0:if((r=e).sharedClientState.updateQueryState(t,"rejected",n),!(a=(i=r.Ba.get(t))&&i.key))return[3,2];return o=(o=new nj(tW.comparator)).insert(a,rm.newNoDocument(a,tq.min())),s=ii().add(a),u=new iH(tq.min(),new Map,new nj(tV),o,s),[4,uy(r,u)];case 1:return c.sent(),r.La=r.La.remove(a),r.Ba.delete(t),uE(r),[3,4];case 2:return[4,o2(r.localStore,t,!1).then(function(){return uw(r,t,n)}).catch(t5)];case 3:c.sent(),c.label=4;case 4:return[2]}})})()}function ug(e,t){return(0,N._)(function(){var n,r,i;return(0,M._)(this,function(a){switch(a.label){case 0:n=e,r=t.batch.batchId,a.label=1;case 1:var o,s;return a.trys.push([1,4,,6]),[4,(o=n.localStore,s=t,o.persistence.runTransaction("Acknowledge batch","readwrite-primary",function(e){var t,n,r,i=s.batch.keys(),a=o.hs.newChangeBuffer({trackRemovals:!0});
1return(n=(t=s.batch).keys(),r=t6.resolve(),n.forEach(function(n){r=r.next(function(){return a.getEntry(e,n)}).next(function(e){var r=s.docVersions.get(n);null!==r||tS(),0>e.version.compareTo(r)&&(t.applyToRemoteDocument(e,s),e.isValidDocument()&&(e.setReadTime(s.commitVersion),a.addEntry(e)))})}),r.next(function(){return o.mutationQueue.removeMutationBatch(e,t)})).next(function(){return a.apply(e)}).next(function(){return o.mutationQueue.performConsistencyCheck(e)}).next(function(){return o.documentOverlayCache.removeOverlaysForBatchId(e,i,s.batch.batchId)}).next(function(){return o.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(e,function(e){for(var t=ii(),n=0;n<e.mutationResults.length;++n)e.mutationResults[n].transformResults.length>0&&(t=t.add(e.batch.mutations[n].key));return t}(s))}).next(function(){return o.localDocuments.getDocuments(e,i)})}))];case 2:return i=a.sent(),ub(n,r,null),uk(n,r),n.sharedClientState.updateMutationState(r,"acknowledged"),[4,uS(n,i)];case 3:case 5:return a.sent(),[3,6];case 4:return[4,t5(a.sent())];case 6:return[2]}})})()}function u_(e,t,n){return(0,N._)(function(){var r,i;return(0,M._)(this,function(a){switch(a.label){case 0:r=e,a.label=1;case 1:var o;return a.trys.push([1,4,,6]),[4,(o=r.localStore,o.persistence.runTransaction("Reject batch","readwrite-primary",function(e){var n;return o.mutationQueue.lookupMutationBatch(e,t).next(function(t){return null!==t||tS(),n=t.keys(),o.mutationQueue.removeMutationBatch(e,t)}).next(function(){return o.mutationQueue.performConsistencyCheck(e)}).next(function(){return o.documentOverlayCache.removeOverlaysForBatchId(e,n,t)}).next(function(){return o.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(e,n)}).next(function(){return o.localDocuments.getDocuments(e,n)})}))];case 2:return i=a.sent(),ub(r,t,n),uk(r,t),r.sharedClientState.updateMutationState(t,"rejected",n),[4,uS(r,i)];case 3:case 5:return a.sent(),[3,6];case 4:return[4,t5(a.sent())];case 6:return[2]}})})()}function uk(e,t){(e.Qa.get(t)||[]).forEach(function(e){e.resolve()}),e.Qa.delete(t)}function ub(e,t,n){var r=e.qa[e.currentUser.toKey()];if(r){var i=r.get(t);i&&(n?i.reject(n):i.resolve(),r=r.remove(t)),e.qa[e.currentUser.toKey()]=r}}function uw(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;e.sharedClientState.removeLocalQueryTarget(t);var r=!0,i=!1,a=void 0;try{for(var o,s=e.Oa.get(t)[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var u=o.value;e.xa.delete(u),n&&e.Ma.Wa(u,n)}}catch(e){i=!0,a=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw a}}e.Oa.delete(t),e.isPrimaryClient&&e.ka.yr(t).forEach(function(t){e.ka.containsKey(t)||uI(e,t)})}function uI(e,t){e.Na.delete(t.path.canonicalString());var n=e.La.get(t);null!==n&&(sx(e.remoteStore,n),e.La=e.La.remove(t),e.Ba.delete(n),uE(e))}function uT(e,t,n){var r=!0,i=!1,a=void 0;try{for(var o,s=n[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var u=o.value;(0,K._)(u,ur)?(e.ka.addReference(u.key,t),function(e,t){var n=t.key,r=n.path.canonicalString();e.La.get(n)||e.Na.has(r)||(tw("SyncEngine","New document in limbo: "+n),e.Na.add(r),uE(e))}(e,u)):(0,K._)(u,ui)?(tw("SyncEngine","Document no longer in limbo: "+u.key),e.ka.removeReference(u.key,t),e.ka.containsKey(u.key)||uI(e,u.key)):tS()}}catch(e){i=!0,a=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw a}}}function uE(e){for(;e.Na.size>0&&e.La.size<e.maxConcurrentLimboResolutions;){var t=e.Na.values().next().value;e.Na.delete(t);var n=new tW(tK.fromString(t)),r=e.Ka.next();e.Ba.set(r,new us(n)),e.La=e.La.insert(n,r),sC(e.remoteStore,new ag(rY(rW(n.path)),r,"TargetPurposeLimboResolution",nc.oe))}}function uS(e,t,n){return(0,N._)(function(){var r,i,a,o;return(0,M._)(this,function(s){switch(s.label){case 0:if(i=[],a=[],o=[],(r=e).xa.isEmpty())return[3,3];return r.xa.forEach(function(e,s){o.push(r.Ua(s,t,n).then(function(e){var t;if((e||n)&&r.isPrimaryClient){var o=e?!e.fromCache:null==(t=null==n?void 0:n.targetChanges.get(s.targetId))?void 0:t.current;
1r.sharedClientState.updateQueryState(s.targetId,o?"current":"not-current")}if(e){i.push(e);var u=oQ.zi(s.targetId,e);a.push(u)}}))}),[4,Promise.all(o)];case 1:var u,c;return s.sent(),r.Ma.R_(i),[4,(u=r.localStore,c=a,(0,N._)(function(){var e,t,n,r,i,a,o,s,l,h,f,d;return(0,M._)(this,function(v){switch(v.label){case 0:e=u,v.label=1;case 1:return v.trys.push([1,3,,4]),[4,e.persistence.runTransaction("notifyLocalViewChanges","readwrite",function(t){return t6.forEach(c,function(n){return t6.forEach(n.Wi,function(r){return e.persistence.referenceDelegate.addReference(t,n.targetId,r)}).next(function(){return t6.forEach(n.Gi,function(r){return e.persistence.referenceDelegate.removeReference(t,n.targetId,r)})})})})];case 2:return v.sent(),[3,4];case 3:if(!nn(t=v.sent()))throw t;return tw("LocalStore","Failed to update sequence numbers: "+t),[3,4];case 4:n=!0,r=!1,i=void 0;try{for(a=c[Symbol.iterator]();!(n=(o=a.next()).done);n=!0)l=(s=o.value).targetId,s.fromCache||(f=(h=e.us.get(l)).snapshotVersion,d=h.withLastLimboFreeSnapshotVersion(f),e.us=e.us.insert(l,d))}catch(e){r=!0,i=e}finally{try{n||null==a.return||a.return()}finally{if(r)throw i}}return[2]}})})())];case 2:s.sent(),s.label=3;case 3:return[2]}})})()}function uC(e,t){return(0,N._)(function(){var n,r;return(0,M._)(this,function(i){switch(i.label){case 0:if((n=e).currentUser.isEqual(t))return[3,3];return tw("SyncEngine","User change. New user:",t.toKey()),[4,o$(n.localStore,t)];case 1:var a;return r=i.sent(),n.currentUser=t,(a=n).Qa.forEach(function(e){e.forEach(function(e){e.reject(new tx(tC.CANCELLED,"'waitForPendingWrites' promise is rejected due to a user change."))})}),a.Qa.clear(),n.sharedClientState.handleUserChange(t,r.removedBatchIds,r.addedBatchIds),[4,uS(n,r.Ts)];case 2:i.sent(),i.label=3;case 3:return[2]}})})()}function ux(e,t){var n=e.Ba.get(t);if(n&&n.Fa)return ii().add(n.key);var r=ii(),i=e.Oa.get(t);if(!i)return r;var a=!0,o=!1,s=void 0;try{for(var u,c=i[Symbol.iterator]();!(a=(u=c.next()).done);a=!0){var l=u.value,h=e.xa.get(l);r=r.unionWith(h.view.fa)}}catch(e){o=!0,s=e}finally{try{a||null==c.return||c.return()}finally{if(o)throw s}}return r}function uA(e,t){return(0,N._)(function(){var n;return(0,M._)(this,function(r){return[2,o5((n=e).localStore,t).then(function(e){return uS(n,e)})]})})()}function uD(e,t,n,r){return(0,N._)(function(){var i,a;return(0,M._)(this,function(o){var s,u,c;switch(o.label){case 0:return[4,(s=(i=e).localStore,u=s.mutationQueue,s.persistence.runTransaction("Lookup mutation documents","readonly",function(e){return u.On(e,t).next(function(t){return t?s.localDocuments.getDocuments(e,t):t6.resolve(null)})}))];case 1:if(null===(a=o.sent()))return[3,6];if("pending"!==n)return[3,3];return[4,sB(i.remoteStore)];case 2:return o.sent(),[3,4];case 3:"acknowledged"===n||"rejected"===n?(ub(i,t,r||null),uk(i,t),c=i.localStore,c.mutationQueue.Ln(t)):tS(),o.label=4;case 4:return[4,uS(i,a)];case 5:return o.sent(),[3,7];case 6:tw("SyncEngine","Cannot apply mutation batch with id: "+t),o.label=7;case 7:return[2]}})})()}function uR(e,t,n){return(0,N._)(function(){var n,r,i,a,o,s,u,c,l,h,f,d,v,y,p,m,g,_,k,b,w;return(0,M._)(this,function(I){switch(I.label){case 0:n=e,r=[],i=[],a=!0,o=!1,s=void 0,I.label=1;case 1:I.trys.push([1,19,20,21]),u=t[Symbol.iterator](),I.label=2;case 2:if(a=(c=u.next()).done)return[3,18];if(l=c.value,h=void 0,!((f=n.Oa.get(l))&&0!==f.length))return[3,12];return[4,o1(n.localStore,rY(f[0]))];case 3:h=I.sent(),d=!0,v=!1,y=void 0,I.label=4;case 4:I.trys.push([4,9,10,11]),p=f[Symbol.iterator](),I.label=5;case 5:var T;if(d=(m=p.next()).done)return[3,8];return g=m.value,_=n.xa.get(g),[4,(T=n,(0,N._)(function(){var e,t,n;return(0,M._)(this,function(r){switch(r.label){case 0:return[4,o3((e=T).localStore,_.query,!0)];case 1:return t=r.sent(),n=_.view.va(t),[2,(e.isPrimaryClient&&uT(e,_.targetId,n.ba),n)]}})})())];case 6:(k=I.sent()).snapshot&&i.push(k.snapshot),I.label=7;case 7:return d=!0,[3,5];case 8:return[3,11];case 9:return b=I.sent(),v=!0,y=b,[3,11];case 10:try{d||null==p.return||p.return()}finally{if(v)throw y}return[7];
1case 11:return[3,16];case 12:return[4,o4(n.localStore,l)];case 13:return w=I.sent(),[4,o1(n.localStore,w)];case 14:return h=I.sent(),[4,uf(n,uN(w),l,!1,h.resumeToken)];case 15:I.sent(),I.label=16;case 16:r.push(h),I.label=17;case 17:return a=!0,[3,2];case 18:return[3,21];case 19:return b=I.sent(),o=!0,s=b,[3,21];case 20:try{a||null==u.return||u.return()}finally{if(o)throw s}return[7];case 21:return[2,(n.Ma.R_(i),r)]}})})()}function uN(e){var t,n,r,i,a;return t=e.path,n=e.collectionGroup,r=e.orderBy,i=e.filters,a=e.limit,new rH(t,n,r,i,a,"F",e.startAt,e.endAt)}function uO(e){return e.localStore.persistence.$i()}function uP(e,t,n,r){return(0,N._)(function(){var i,a,o,s;return(0,M._)(this,function(u){switch(u.label){case 0:if((i=e).$a)return[2,void tw("SyncEngine","Ignoring unexpected query state notification.")];if(!((a=i.Oa.get(t))&&a.length>0))return[3,7];switch(n){case"current":case"not-current":return[3,1];case"rejected":return[3,4]}return[3,6];case 1:return[4,o5(i.localStore,r4(a[0]))];case 2:return o=u.sent(),s=iH.createSynthesizedRemoteEventForCurrentChange(t,"current"===n,nJ.EMPTY_BYTE_STRING),[4,uS(i,o,s)];case 3:return u.sent(),[3,7];case 4:return[4,o2(i.localStore,t,!0)];case 5:return u.sent(),uw(i,t,r),[3,7];case 6:tS(),u.label=7;case 7:return[2]}})})()}function uL(e,t,n){return(0,N._)(function(){var r,i,a,o,s,u,c,l,h,f,d,v,y,p,m,g;return(0,M._)(this,function(_){switch(_.label){case 0:if(!(r=uM(e)).$a)return[3,18];i=!0,a=!1,o=void 0,_.label=1;case 1:_.trys.push([1,8,9,10]),s=t[Symbol.iterator](),_.label=2;case 2:if(i=(u=s.next()).done)return[3,7];if(c=u.value,r.Oa.has(c)&&r.sharedClientState.isActiveQueryTarget(c))return tw("SyncEngine","Adding an already active target "+c),[3,6];return[4,o4(r.localStore,c)];case 3:return l=_.sent(),[4,o1(r.localStore,l)];case 4:return h=_.sent(),[4,uf(r,uN(l),h.targetId,!1,h.resumeToken)];case 5:_.sent(),sC(r.remoteStore,h),_.label=6;case 6:return i=!0,[3,2];case 7:return[3,10];case 8:return f=_.sent(),a=!0,o=f,[3,10];case 9:try{i||null==s.return||s.return()}finally{if(a)throw o}return[7];case 10:d=!0,v=!1,y=void 0,_.label=11;case 11:_.trys.push([11,16,17,18]),p=function(){var e;return(0,M._)(this,function(t){switch(t.label){case 0:if(e=g.value,!r.Oa.has(e))return[3,2];return[4,o2(r.localStore,e,!1).then(function(){sx(r.remoteStore,e),uw(r,e)}).catch(t5)];case 1:t.sent(),t.label=2;case 2:return[2]}})},m=n[Symbol.iterator](),_.label=12;case 12:if(d=(g=m.next()).done)return[3,15];return[5,(0,W._)(p())];case 13:_.sent(),_.label=14;case 14:return d=!0,[3,12];case 15:return[3,18];case 16:return f=_.sent(),v=!0,y=f,[3,18];case 17:try{d||null==m.return||m.return()}finally{if(v)throw y}return[7];case 18:return[2]}})})()}function uM(e){return e.remoteStore.remoteSyncer.applyRemoteEvent=uy.bind(null,e),e.remoteStore.remoteSyncer.getRemoteKeysForTarget=ux.bind(null,e),e.remoteStore.remoteSyncer.rejectListen=um.bind(null,e),e.Ma.R_=s8.bind(null,e.eventManager),e.Ma.Wa=s7.bind(null,e.eventManager),e}function uU(e){return e.remoteStore.remoteSyncer.applySuccessfulWrite=ug.bind(null,e),e.remoteStore.remoteSyncer.rejectFailedWrite=u_.bind(null,e),e}var uF=function(){function e(){(0,O._)(this,e),this.kind="memory",this.synchronizeTabs=!1}return(0,P._)(e,[{key:"initialize",value:function(e){return(0,N._)(function(){return(0,M._)(this,function(t){switch(t.label){case 0:return this.serializer=sm(e.databaseInfo.databaseId),this.sharedClientState=this.za(e),this.persistence=this.ja(e),[4,this.persistence.start()];case 1:return t.sent(),this.localStore=this.Ha(e),this.gcScheduler=this.Ja(e,this.localStore),this.indexBackfillerScheduler=this.Ya(e,this.localStore),[2]}})}).call(this)}},{key:"Ja",value:function(e,t){return null}},{key:"Ya",value:function(e,t){return null}},{key:"Ha",value:function(e){var t,n;return t=this.persistence,n=new oX,new oY(t,n,e.initialUser,this.serializer)}},{key:"ja",value:function(e){return new oU(oV.ei,this.serializer)}},{key:"za",value:function(e){return new so}},{key:"terminate",value:function(){return(0,N._)(function(){var e,t;return(0,M._)(this,function(n){switch(n.label){case 0:return null==(e=this.gcScheduler)||e.stop(),null==(t=this.indexBackfillerScheduler)||t.stop(),this.sharedCl
1ientState.shutdown(),[4,this.persistence.shutdown()];case 1:return n.sent(),[2]}})}).call(this)}}]),e}();uF.provider={build:function(){return new uF}};var uV=function(e){function t(e){var n;return(0,O._)(this,t),(n=(0,V._)(this,t)).cacheSizeBytes=e,n}return(0,z._)(t,e),(0,P._)(t,[{key:"Ja",value:function(e,t){return(0,K._)(this.persistence.referenceDelegate,oB)||tS(),new ov(this.persistence.referenceDelegate.garbageCollector,e.asyncQueue,t)}},{key:"ja",value:function(e){var t=void 0!==this.cacheSizeBytes?a9.withCacheSize(this.cacheSizeBytes):a9.DEFAULT;return new oU(function(e){return oB.ei(e,t)},this.serializer)}}]),t}(uF),uB=function(e){function t(e,n,r){var i;return(0,O._)(this,t),(i=(0,V._)(this,t)).Za=e,i.cacheSizeBytes=n,i.forceOwnership=r,i.kind="persistent",i.synchronizeTabs=!1,i}return(0,z._)(t,e),(0,P._)(t,[{key:"initialize",value:function(e){var n=this,r=this;return(0,N._)(function(){var i;return(0,M._)(this,function(a){switch(a.label){case 0:return i=this,[4,(0,j._)((0,q._)(t.prototype),"initialize",n).call(r,e)];case 1:return a.sent(),[4,this.Za.initialize(this,e)];case 2:return a.sent(),[4,uU(this.Za.syncEngine)];case 3:return a.sent(),[4,sB(this.Za.remoteStore)];case 4:return a.sent(),[4,this.persistence.Si(function(){return i.gcScheduler&&!i.gcScheduler.started&&i.gcScheduler.start(),i.indexBackfillerScheduler&&!i.indexBackfillerScheduler.started&&i.indexBackfillerScheduler.start(),Promise.resolve()})];case 5:return a.sent(),[2]}})}).call(this)}},{key:"Ha",value:function(e){var t,n;return t=this.persistence,n=new oX,new oY(t,n,e.initialUser,this.serializer)}},{key:"Ja",value:function(e,t){return new ov(this.persistence.referenceDelegate.garbageCollector,e.asyncQueue,t)}},{key:"Ya",value:function(e,t){var n=new nu(t,this.persistence);return new ns(e.asyncQueue,n)}},{key:"ja",value:function(e){var t=oW(e.databaseInfo.databaseId,e.databaseInfo.persistenceKey),n=void 0!==this.cacheSizeBytes?a9.withCacheSize(this.cacheSizeBytes):a9.DEFAULT;return new oK(this.synchronizeTabs,t,e.clientId,n,e.asyncQueue,sy(),sp(),this.serializer,this.sharedClientState,!!this.forceOwnership)}},{key:"za",value:function(e){return new so}}]),t}(uF),uj=function(e){function t(e,n){var r;return(0,O._)(this,t),(r=(0,V._)(this,t,[e,n,!1])).Za=e,r.cacheSizeBytes=n,r.synchronizeTabs=!0,r}return(0,z._)(t,e),(0,P._)(t,[{key:"initialize",value:function(e){var n=this,r=this;return(0,N._)(function(){var i,a;return(0,M._)(this,function(o){switch(o.label){case 0:return i=this,[4,(0,j._)((0,q._)(t.prototype),"initialize",n).call(r,e)];case 1:if(o.sent(),a=this.Za.syncEngine,!(0,K._)(this.sharedClientState,sa))return[3,3];return this.sharedClientState.syncEngine={io:uD.bind(null,a),so:uP.bind(null,a),oo:uL.bind(null,a),$i:uO.bind(null,a),ro:uA.bind(null,a)},[4,this.sharedClientState.start()];case 2:o.sent(),o.label=3;case 3:return[4,this.persistence.Si(function(e){return(0,N._)(function(){return(0,M._)(this,function(t){switch(t.label){case 0:var n;return[4,(n=this.Za.syncEngine,(0,N._)(function(){var t,r,i,a,o,s,u,c,l,h,f;return(0,M._)(this,function(d){switch(d.label){case 0:if(uM(t=n),uU(t),!0!==e||!0===t.$a)return[3,3];return r=t.sharedClientState.getAllActiveQueryTargets(),[4,uR(t,r.toArray())];case 1:return i=d.sent(),t.$a=!0,[4,sQ(t.remoteStore,!0)];case 2:d.sent(),a=!0,o=!1,s=void 0;try{for(u=i[Symbol.iterator]();!(a=(c=u.next()).done);a=!0)l=c.value,sC(t.remoteStore,l)}catch(e){o=!0,s=e}finally{try{a||null==u.return||u.return()}finally{if(o)throw s}}return[3,7];case 3:if(!1!==e||!1===t.$a)return[3,7];return h=[],f=Promise.resolve(),t.Oa.forEach(function(e,n){t.sharedClientState.isLocalQueryTarget(n)?h.push(n):f=f.then(function(){return uw(t,n),o2(t.localStore,n,!0)}),sx(t.remoteStore,n)}),[4,f];case 4:return d.sent(),[4,uR(t,h)];case 5:var v;return d.sent(),(v=t).Ba.forEach(function(e,t){sx(v.remoteStore,t)}),v.ka.wr(),v.Ba=new Map,v.La=new nj(tW.comparator),t.$a=!1,[4,sQ(t.remoteStore,!1)];case 6:d.sent(),d.label=7;case 7:return[2]}})})())];case 1:return t.sent(),this.gcScheduler&&(e&&!this.gcScheduler.started?this.gcScheduler.start():e||this.gcScheduler.stop()),this.indexBackfillerScheduler&&(e&&!this.indexBackfillerScheduler.started?this.indexBackfillerScheduler.start():e||this.indexBackfillerScheduler.stop()),[2]}})}).call(i)})];case 4:return o.sent(),[2]}})}).call(this)}},{key:"za",value:function(e){var t=sy();
1if(!sa.p(t))throw new tx(tC.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");var n=oW(e.databaseInfo.databaseId,e.databaseInfo.persistenceKey);return new sa(t,e.asyncQueue,n,e.clientId,e.initialUser)}}]),t}(uB),uq=function(){function e(){(0,O._)(this,e)}return(0,P._)(e,[{key:"initialize",value:function(e,t){return(0,N._)(function(){var n;return(0,M._)(this,function(r){switch(r.label){case 0:if(n=this,this.localStore)return[3,2];return this.localStore=e.localStore,this.sharedClientState=e.sharedClientState,this.datastore=this.createDatastore(t),this.remoteStore=this.createRemoteStore(t),this.eventManager=this.createEventManager(t),this.syncEngine=this.createSyncEngine(t,!e.synchronizeTabs),this.sharedClientState.onlineStateHandler=function(e){return up(n.syncEngine,e,1)},this.remoteStore.remoteSyncer.handleCredentialChange=uC.bind(null,this.syncEngine),[4,sQ(this.remoteStore,this.syncEngine.isPrimaryClient)];case 1:r.sent(),r.label=2;case 2:return[2]}})}).call(this)}},{key:"createEventManager",value:function(e){return new s3}},{key:"createDatastore",value:function(e){var t,n=sm(e.databaseInfo.databaseId),r=new sv(e.databaseInfo);return t=e.authCredentials,new sw(t,e.appCheckCredentials,r,n)}},{key:"createRemoteStore",value:function(e){var t,n,r=this;return t=this.localStore,n=this.datastore,new sT(t,n,e.asyncQueue,function(e){return up(r.syncEngine,e,0)},su.p()?new su:new ss)}},{key:"createSyncEngine",value:function(e,t){var n,r,i,a,o,s,u;return n=this.localStore,r=this.remoteStore,i=this.eventManager,a=this.sharedClientState,o=e.initialUser,s=e.maxConcurrentLimboResolutions,u=new uu(n,r,i,a,o,s),t&&(u.$a=!0),u}},{key:"terminate",value:function(){return(0,N._)(function(){var e,t;return(0,M._)(this,function(n){switch(n.label){case 0:var r;return[4,(r=this.remoteStore,(0,N._)(function(){var e;return(0,M._)(this,function(t){switch(t.label){case 0:return e=r,tw("RemoteStore","RemoteStore shutting down."),e.k_.add(5),[4,sS(e)];case 1:return t.sent(),e.Q_.shutdown(),e.K_.set("Unknown"),[2]}})})())];case 1:return n.sent(),null==(e=this.datastore)||e.terminate(),null==(t=this.eventManager)||t.terminate(),[2]}})}).call(this)}}]),e}();uq.provider={build:function(){return new uq}};var uz=function(){function e(t){(0,O._)(this,e),this.observer=t,this.muted=!1}return(0,P._)(e,[{key:"next",value:function(e){this.muted||this.observer.next&&this.Xa(this.observer.next,e)}},{key:"error",value:function(e){this.muted||(this.observer.error?this.Xa(this.observer.error,e):tI("Uncaught Error in snapshot listener:",e.toString()))}},{key:"eu",value:function(){this.muted=!0}},{key:"Xa",value:function(e,t){var n=this;setTimeout(function(){n.muted||e(t)},0)}}]),e}();(0,P._)(function e(t,n){var r=this;(0,O._)(this,e),this.tu=t,this.serializer=n,this.metadata=new tA,this.buffer=new Uint8Array,this.nu=new TextDecoder("utf-8"),this.ru().then(function(e){e&&e.la()?r.metadata.resolve(e.ca.metadata):r.metadata.reject(Error("The first element of the bundle is not a metadata, it is\n ".concat(JSON.stringify(null==e?void 0:e.ca))))},function(e){return r.metadata.reject(e)})},[{key:"close",value:function(){return this.tu.cancel()}},{key:"getMetadata",value:function(){return(0,N._)(function(){return(0,M._)(this,function(e){return[2,this.metadata.promise]})}).call(this)}},{key:"Ga",value:function(){return(0,N._)(function(){return(0,M._)(this,function(e){switch(e.label){case 0:return[4,this.getMetadata()];case 1:return[2,(e.sent(),this.ru())]}})}).call(this)}},{key:"ru",value:function(){return(0,N._)(function(){var e,t,n;return(0,M._)(this,function(r){switch(r.label){case 0:return[4,this.iu()];case 1:if(null===(e=r.sent()))return[2,null];return isNaN(n=Number(t=this.nu.decode(e)))&&this.su("length string (".concat(t,") is not valid number")),[4,this.ou(n)];case 2:return[2,new ut(JSON.parse(r.sent()),e.length+n)]}})}).call(this)}},{key:"_u",value:function(){return this.buffer.findIndex(function(e){return 123===e})}},{key:"iu",value:function(){return(0,N._)(function(){var e,t;return(0,M._)(this,function(n){switch(n.label){case 0:if(!(0>this._u()))return[3,3];return[4,this.au()];case 1:if(n.sent())return[3,3];n.label=2;case 2:return[3,0];case 3:if(0===this.buffer.length)return[2,null];return(e=this._u())<0&&this.su("Reached the end of bundle when a length string is expected."),t=this.buffer.slice(0,e),[2,(this.buffer=this.buffer.slice(e),t)]}})}).call(this)}},{key:"ou",value:function(e){return(0,N._)(function(){var t;return(0,M._)(this,function(n){switch(n.label){case 0:if(!(this.buffer.length<e))return[3,3];return[4,this.au()];case 1:n.sent()&&this.su("Reached the end of bundle when more is expected."),n.label=2;case 2:return[3,0];case 3:return t=this.nu.decode(this.buffer.slice(0,e)),[2,(this.buffer=this.buffer.slice(e),t)]}})}).call(this)}},{key:"su",value:function(e){throw this.tu.cancel(),Error("Invalid bundle format: ".concat(e))}},{key:"au",value:function(){return(0,N._)(function(){var e,t;return(0,M._)(this,function(n){switch(n.label){case 0:return[4,this.tu.read()];case 1:return(e=n.sent()).done||((t=new Uint8Array(this.buffer.length+e.value.length)).set(this.buffer),t.set(e.value,this.buffer.length),this.buffer=t),[2,e.done]}})}).call(this)}}]);var uK=function(){function e(t){(0,O._)(this,e),this.datastore=t,this.readVersions=new Map,this.mutations=[],this.committed=!1,this.lastTransactionError=null,this.writtenDocs=new Set}return(0,P._)(e,[{key:"lookup",value:function(e){return(0,N._)(function(){var t,n;return(0,M._)(this,function(r){switch(r.label){case 0:var i;if(t=this,this.ensureCommitNotCalled(),this.mutations.length>
10)throw this.lastTransactionError=new tx(tC.INVALID_ARGUMENT,"Firestore transactions require all reads to be executed before all writes."),this.lastTransactionError;return[4,(i=this.datastore,(0,N._)(function(){var t,n,r,a,o;return(0,M._)(this,function(s){switch(s.label){case 0:return t=i,n={documents:e.map(function(e){return an(t.serializer,e)})},[4,t.ko("BatchGetDocuments",t.serializer.databaseId,tK.emptyPath(),n,e.length)];case 1:return r=s.sent(),a=new Map,r.forEach(function(e){var n,r,i,o,s,u,c,l=(n=t.serializer,"found"in e?(e.found||tS(),e.found.name,e.found.updateTime,r=ar(n,e.found.name),i=i7(e.found.updateTime),o=e.found.createTime?i7(e.found.createTime):tq.min(),s=new rp({mapValue:{fields:e.found.fields}}),rm.newFoundDocument(r,i,o,s)):"missing"in e?(e.missing||tS(),e.readTime||tS(),u=ar(n,e.missing),c=i7(e.readTime),rm.newNoDocument(u,c)):tS());a.set(l.key.toString(),l)}),o=[],[2,(e.forEach(function(e){var t=a.get(e.toString());t||tS(),o.push(t)}),o)]}})})())];case 1:return[2,((n=r.sent()).forEach(function(e){return t.recordVersion(e)}),n)]}})}).call(this)}},{key:"set",value:function(e,t){this.write(t.toMutation(e,this.precondition(e))),this.writtenDocs.add(e.toString())}},{key:"update",value:function(e,t){try{this.write(t.toMutation(e,this.preconditionForUpdate(e)))}catch(e){this.lastTransactionError=e}this.writtenDocs.add(e.toString())}},{key:"delete",value:function(e){this.write(new iN(e,this.precondition(e))),this.writtenDocs.add(e.toString())}},{key:"commit",value:function(){return(0,N._)(function(){var e,t;return(0,M._)(this,function(n){switch(n.label){case 0:var r,i;if(e=this,this.ensureCommitNotCalled(),this.lastTransactionError)throw this.lastTransactionError;return t=this.readVersions,this.mutations.forEach(function(e){t.delete(e.key.toString())}),t.forEach(function(t,n){var r=tW.fromPath(n);e.mutations.push(new iO(r,e.precondition(r)))}),[4,(r=this.datastore,i=this.mutations,(0,N._)(function(){var e,t;return(0,M._)(this,function(n){switch(n.label){case 0:return e=r,t={writes:i.map(function(t){return al(e.serializer,t)})},[4,e.Oo("Commit",e.serializer.databaseId,tK.emptyPath(),t)];case 1:return n.sent(),[2]}})})())];case 1:return n.sent(),this.committed=!0,[2]}})}).call(this)}},{key:"recordVersion",value:function(e){if(e.isFoundDocument())t=e.version;else{if(!e.isNoDocument())throw tS();t=tq.min()}var t,n=this.readVersions.get(e.key.toString());if(n){if(!t.isEqual(n))throw new tx(tC.ABORTED,"Document version changed between two reads.")}else this.readVersions.set(e.key.toString(),t)}},{key:"precondition",value:function(e){var t=this.readVersions.get(e.toString());return!this.writtenDocs.has(e.toString())&&t?t.isEqual(tq.min())?ib.exists(!1):ib.updateTime(t):ib.none()}},{key:"preconditionForUpdate",value:function(e){var t=this.readVersions.get(e.toString());if(!this.writtenDocs.has(e.toString())&&t){if(t.isEqual(tq.min()))throw new tx(tC.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return ib.updateTime(t)}return ib.exists(!0)}},{key:"write",value:function(e){this.ensureCommitNotCalled(),this.mutations.push(e)}},{key:"ensureCommitNotCalled",value:function(){}}]),e}();(0,P._)(function e(t,n,r,i,a){(0,O._)(this,e),this.asyncQueue=t,this.datastore=n,this.options=r,this.updateFunction=i,this.deferred=a,this.uu=r.maxAttempts,this.r_=new sg(this.asyncQueue,"transaction_retry")},[{key:"cu",value:function(){this.uu-=1,this.lu()}},{key:"lu",value:function(){var e=this;this.r_.jo(function(){return(0,N._)(function(){var e,t,n;return(0,M._)(this,function(r){return e=this,t=new uK(this.datastore),(n=this.hu(t))&&n.then(function(n){e.asyncQueue.enqueueAndForget(function(){return t.commit().then(function(){e.deferred.resolve(n)}).catch(function(t){e.Pu(t)})})}).catch(function(t){e.Pu(t)}),[2]})}).call(e)})}},{key:"hu",value:function(e){try{var t=this.updateFunction(e);return!nl(t)&&t.catch&&t.then?t:(this.deferred.reject(Error("Transaction callback must return a Promise")),null)}catch(e){return this.deferred.reject(e),null}}},{key:"Pu",value:function(e){var t=this;this.uu>0&&this.Tu(e)?(this.uu-=1,this.asyncQueue.enqueueAndForget(function(){return t.lu(),Promise.resolve()})):this.deferred.reject(e)}},{key:"Tu",value:function(e){if("FirebaseError"===e.name){var t=e.code;return"aborted"===t||"failed-precondition"===t||"already-exists"===t||!iF(t)}return!1}}]);var uG=function(){function e(t,n,r,i,a){var o=this;(0,O._)(this,e),this.authCredentials=t,this.appCheckCredentials=n,this.asyncQueue=r,this.databaseInfo=i,this.user=tg.UNAUTHENTICATED,this.clientId=tF.newId(),this.authCredentialListener=function(){return Promise.resolve()},this.appCheckCredentialListener=function(){return Promise.resolve()},this._uninitializedComponentsProvider=a,this.authCredentials.start(r,function(e){return(0,N._)(function(){return(0,M._)(this,function(t){switch(t.label){case 0:return tw("FirestoreClient","Received user=",e.uid),[4,this.authCredentialListener(e)];case 1:return t.sent(),this.user=e,[2]}})}).call(o)}),this.appCheckCredentials.start(r,function(e){return tw("FirestoreClient","Received new app check token=",e),o.appCheckCredentialListener(e,o.user)})}
1return(0,P._)(e,[{key:"configuration",get:function(){return{asyncQueue:this.asyncQueue,databaseInfo:this.databaseInfo,clientId:this.clientId,authCredentials:this.authCredentials,appCheckCredentials:this.appCheckCredentials,initialUser:this.user,maxConcurrentLimboResolutions:100}}},{key:"setCredentialChangeListener",value:function(e){this.authCredentialListener=e}},{key:"setAppCheckTokenChangeListener",value:function(e){this.appCheckCredentialListener=e}},{key:"terminate",value:function(){var e=this;this.asyncQueue.enterRestrictedMode();var t=new tA;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted(function(){return(0,N._)(function(){var e;return(0,M._)(this,function(n){switch(n.label){case 0:if(n.trys.push([0,5,,6]),!this._onlineComponents)return[3,2];return[4,this._onlineComponents.terminate()];case 1:n.sent(),n.label=2;case 2:if(!this._offlineComponents)return[3,4];return[4,this._offlineComponents.terminate()];case 3:n.sent(),n.label=4;case 4:return this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),t.resolve(),[3,6];case 5:return e=s$(n.sent(),"Failed to shutdown persistence"),t.reject(e),[3,6];case 6:return[2]}})}).call(e)}),t.promise}}]),e}();function uH(e,t){return(0,N._)(function(){var n,r;return(0,M._)(this,function(i){switch(i.label){case 0:return e.asyncQueue.verifyOperationInProgress(),tw("FirestoreClient","Initializing OfflineComponentProvider"),n=e.configuration,[4,t.initialize(n)];case 1:return i.sent(),r=n.initialUser,e.setCredentialChangeListener(function(e){return(0,N._)(function(){return(0,M._)(this,function(n){switch(n.label){case 0:if(r.isEqual(e))return[3,2];return[4,o$(t.localStore,e)];case 1:n.sent(),r=e,n.label=2;case 2:return[2]}})})()}),t.persistence.setDatabaseDeletedListener(function(){return e.terminate()}),e._offlineComponents=t,[2]}})})()}function uW(e,t){return(0,N._)(function(){var n;return(0,M._)(this,function(r){switch(r.label){case 0:var i;return e.asyncQueue.verifyOperationInProgress(),[4,(i=e,(0,N._)(function(){var e;return(0,M._)(this,function(t){switch(t.label){case 0:if(i._offlineComponents)return[3,8];if(!i._uninitializedComponentsProvider)return[3,6];tw("FirestoreClient","Using user provided OfflineComponentProvider"),t.label=1;case 1:return t.trys.push([1,3,,5]),[4,uH(i,i._uninitializedComponentsProvider._offline)];case 2:case 4:return t.sent(),[3,5];case 3:var n;if(!("FirebaseError"===(n=e=t.sent()).name?n.code===tC.FAILED_PRECONDITION||n.code===tC.UNIMPLEMENTED:!("u">typeof DOMException&&(0,K._)(n,DOMException))||22===n.code||20===n.code||11===n.code))throw e;return tT("Error using user provided cache. Falling back to memory cache: "+e),[4,uH(i,new uF)];case 5:return[3,8];case 6:return tw("FirestoreClient","Using default OfflineComponentProvider"),[4,uH(i,new uV(void 0))];case 7:t.sent(),t.label=8;case 8:return[2,i._offlineComponents]}})})())];case 1:return n=r.sent(),tw("FirestoreClient","Initializing OnlineComponentProvider"),[4,t.initialize(n,e.configuration)];case 2:return r.sent(),e.setCredentialChangeListener(function(e){return sW(t.remoteStore,e)}),e.setAppCheckTokenChangeListener(function(e,n){return sW(t.remoteStore,n)}),e._onlineComponents=t,[2]}})})()}function uQ(e){return(0,N._)(function(){var t,n;return(0,M._)(this,function(r){switch(r.label){case 0:return[4,(0,N._)(function(){var t;return(0,M._)(this,function(n){switch(n.label){case 0:if(e._onlineComponents)return[3,5];if(!e._uninitializedComponentsProvider)return[3,2];return tw("FirestoreClient","Using user provided OnlineComponentProvider"),[4,uW(e,e._uninitializedComponentsProvider._online)];case 1:return t=n.sent(),[3,4];case 2:return tw("FirestoreClient","Using default OnlineComponentProvider"),[4,uW(e,new uq)];case 3:t=n.sent(),n.label=4;case 4:n.label=5;case 5:return[2,e._onlineComponents]}})})()];case 1:return[2,((n=(t=r.sent()).eventManager).onListen=uc.bind(null,t.syncEngine),n.onUnlisten=ud.bind(null,t.syncEngine),n.onFirstRemoteStoreListen=ul.bind(null,t.syncEngine),n.onLastRemoteStoreUnlisten=uv.bind(null,t.syncEngine),n)]}})})()}function uJ(e){var t={};return void 0!==e.timeoutSeconds&&(t.timeoutSeconds=e.timeoutSeconds),t}var uX=new Map;function uY(e){if(tW.isDocumentKey(e))throw new tx(tC.INVALID_ARGUMENT,"Invalid collection reference. Collection references must have an odd number of segments, but ".concat(e," has ").concat(e.length,"."))}function u$(e){if(void 0===e)return"undefined";if(null===e)return"null";if("string"==typeof e)return e.length>20&&(e="".concat(e.substring(0,20),"...")),JSON.stringify(e);if("number"==typeof e||"boolean"==typeof e)return""+e;if("object"==(void 0===e?"undefined":(0,G._)(e))){if((0,K._)(e,Array))return"an array";var t,n=(t=e).constructor?t.constructor.name:null;return n?"a custom ".concat(n," object"):"an object"}return"function"==typeof e?"a function":tS()}function uZ(e,t){if("_delegate"in e&&(e=e._delegate),!(0,K._)(e,t)){if(t.name===e.constructor.name)throw new tx(tC.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");var n=u$(e);throw new tx(tC.INVALID_ARGUMENT,"Expected type '".concat(t.name,"', but it was: ").concat(n))}return e}var u0=function(){function e(t){var n,r;if((0,O._)(this,e),void 0===t.host){if(void 0!==t.ssl)throw new tx(tC.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host="firestore.googleapis.com",this.ssl=!0}else this.host=t.host,this.ssl=null==(n=t.ssl)||n;if(this.credentials=t.credentials,this.ignoreUndefinedProperties=!!t.ignoreUndefinedProperties,this.localCache=t.localCache,void 0===t.cacheSizeBytes)this.cacheSizeBytes=0x2800000;else{if(-1!==t.cacheSizeBytes&&t.cacheSizeBytes<1048576)throw new tx(tC.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=t.cacheSizeBytes}(function(e,t,n,r){if(!0===t&&!0===r)throw new tx(tC.INVALID_ARGUMENT,"".concat(e," and ").concat(n," cannot be used together."))})("experimentalForceLongPolling",t.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",t.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!t.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:void 0===t.experimentalAutoDetectLongPolling?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!t.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=uJ(null!=(r=t.experimentalLongPollingOptions)?r:{}),function(e){if(void 0!==e.timeoutSeconds){if(isNaN(e.timeoutSeconds))throw new tx(tC.INVALID_ARGUMENT,"invali
1d long polling timeout: ".concat(e.timeoutSeconds," (must not be NaN)"));if(e.timeoutSeconds<5)throw new tx(tC.INVALID_ARGUMENT,"invalid long polling timeout: ".concat(e.timeoutSeconds," (minimum allowed value is 5)"));if(e.timeoutSeconds>30)throw new tx(tC.INVALID_ARGUMENT,"invalid long polling timeout: ".concat(e.timeoutSeconds," (maximum allowed value is 30)"))}}(this.experimentalLongPollingOptions),this.useFetchStreams=!!t.useFetchStreams}return(0,P._)(e,[{key:"isEqual",value:function(e){var t,n;return this.host===e.host&&this.ssl===e.ssl&&this.credentials===e.credentials&&this.cacheSizeBytes===e.cacheSizeBytes&&this.experimentalForceLongPolling===e.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===e.experimentalAutoDetectLongPolling&&(t=this.experimentalLongPollingOptions,n=e.experimentalLongPollingOptions,t.timeoutSeconds===n.timeoutSeconds)&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams}}]),e}(),u1=function(){function e(t,n,r,i){(0,O._)(this,e),this._authCredentials=t,this._appCheckCredentials=n,this._databaseId=r,this._app=i,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new u0({}),this._settingsFrozen=!1,this._terminateTask="notTerminated"}return(0,P._)(e,[{key:"app",get:function(){if(!this._app)throw new tx(tC.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app}},{key:"_initialized",get:function(){return this._settingsFrozen}},{key:"_terminated",get:function(){return"notTerminated"!==this._terminateTask}},{key:"_setSettings",value:function(e){if(this._settingsFrozen)throw new tx(tC.FAILED_PRECONDITION,"Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.");this._settings=new u0(e),void 0!==e.credentials&&(this._authCredentials=function(e){if(!e)return new tR;switch(e.type){case"firstParty":return new tL(e.sessionIndex||"0",e.iamToken||null,e.authTokenFactory||null);case"provider":return e.client;default:throw new tx(tC.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invalid credential type")}}(e.credentials))}},{key:"_getSettings",value:function(){return this._settings}},{key:"_freezeSettings",value:function(){return this._settingsFrozen=!0,this._settings}},{key:"_delete",value:function(){return"notTerminated"===this._terminateTask&&(this._terminateTask=this._terminate()),this._terminateTask}},{key:"_restart",value:function(){return(0,N._)(function(){return(0,M._)(this,function(e){switch(e.label){case 0:if("notTerminated"!==this._terminateTask)return[3,2];return[4,this._terminate()];case 1:return e.sent(),[3,3];case 2:this._terminateTask="notTerminated",e.label=3;case 3:return[2]}})}).call(this)}},{key:"toJSON",value:function(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}},{key:"_terminate",value:function(){var e;return(e=uX.get(this))&&(tw("ComponentProvider","Removing Datastore"),uX.delete(this),e.terminate()),Promise.resolve()}}]),e}();function u2(e,t,n){var r,i,a,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},s=(e=uZ(e,u1))._getSettings(),u="".concat(t,":").concat(n);if("firestore.googleapis.com"!==s.host&&s.host!==u&&tT("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used."),e._setSettings(Object.assign(Object.assign({},s),{host:u,ssl:!1})),o.mockUserToken){if("string"==typeof o.mockUserToken)i=o.mockUserToken,a=tg.MOCK_USER;else{i=function(e,t){if(e.uid)throw Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');var n=t||"demo-project",r=e.iat||0,i=e.sub||e.user_id;if(!i)throw Error("mockUserToken must contain 'sub' or 'user_id' field!");var a=Object.assign({iss:"https://securetoken.google.com/".concat(n),aud:n,iat:r,exp:r+3600,auth_time:r,sub:i,user_id:i,firebase:{sign_in_provider:"custom",identities:{}}},e);return[et(JSON.stringify({alg:"none",type:"JWT"})),et(JSON.stringify(a)),""].join(".")}(o.mockUserToken,null==(r=e._app)?void 0:r.options.projectId);var c=o.mockUserToken.sub||o.mockUserToken.user_id;if(!c)throw new tx(tC.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");a=new tg(c)}e._authCredentials=new tN(new tD(i,a))}}var u3=function(){function e(t,n,r){(0,O._)(this,e),this.converter=n,this._query=r,this.type="query",this.firestore=t}return(0,P._)(e,[{key:"withConverter",value:function(t){return new e(this.firestore,t,this._query)}}]),e}(),u4=function(){function e(t,n,r){(0,O._)(this,e),this.converter=n,this._key=r,this.type="document",this.firestore=t}return(0,P._)(e,[{key:"_path",get:function(){return this._key.path}},{key:"id",get:function(){return this._key.path.lastSegment()}}
1,{key:"path",get:function(){return this._key.path.canonicalString()}},{key:"parent",get:function(){return new u5(this.firestore,this.converter,this._key.path.popLast())}},{key:"withConverter",value:function(t){return new e(this.firestore,t,this._key)}}]),e}(),u5=function(e){function t(e,n,r){var i;return(0,O._)(this,t),(i=(0,V._)(this,t,[e,n,rW(r)]))._path=r,i.type="collection",i}return(0,z._)(t,e),(0,P._)(t,[{key:"id",get:function(){return this._query.path.lastSegment()}},{key:"path",get:function(){return this._query.path.canonicalString()}},{key:"parent",get:function(){var e=this._path.popLast();return e.isEmpty()?null:new u4(this.firestore,null,new tW(e))}},{key:"withConverter",value:function(e){return new t(this.firestore,e,this._path)}}]),t}(u3);function u6(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];if(e=eT(e),function(e,t,n){if(!n)throw new tx(tC.INVALID_ARGUMENT,"Function ".concat(e,"() cannot be called with an empty ").concat(t,"."))}("collection","path",t),(0,K._)(e,u1)){var a=tK.fromString.apply(tK,[t].concat((0,L._)(r)));return uY(a),new u5(e,null,a)}if(!((0,K._)(e,u4)||(0,K._)(e,u5)))throw new tx(tC.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");var o=e._path.child(tK.fromString.apply(tK,[t].concat((0,L._)(r))));return uY(o),new u5(e.firestore,null,o)}var u8=function(){function e(){var t=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Promise.resolve();(0,O._)(this,e),this.Iu=[],this.Eu=!1,this.du=[],this.Au=null,this.Ru=!1,this.Vu=!1,this.mu=[],this.r_=new sg(this,"async_queue_retry"),this.fu=function(){var e=sp();e&&tw("AsyncQueue","Visibility state changed to "+e.visibilityState),t.r_.Jo()},this.gu=n;var r=sp();r&&"function"==typeof r.addEventListener&&r.addEventListener("visibilitychange",this.fu)}return(0,P._)(e,[{key:"isShuttingDown",get:function(){return this.Eu}},{key:"enqueueAndForget",value:function(e){this.enqueue(e)}},{key:"enqueueAndForgetEvenWhileRestricted",value:function(e){this.pu(),this.yu(e)}},{key:"enterRestrictedMode",value:function(e){if(!this.Eu){this.Eu=!0,this.Vu=e||!1;var t=sp();t&&"function"==typeof t.removeEventListener&&t.removeEventListener("visibilitychange",this.fu)}}},{key:"enqueue",value:function(e){var t=this;if(this.pu(),this.Eu)return new Promise(function(){});var n=new tA;return this.yu(function(){return t.Eu&&t.Vu?Promise.resolve():(e().then(n.resolve,n.reject),n.promise)}).then(function(){return n.promise})}},{key:"enqueueRetryable",value:function(e){var t=this;this.enqueueAndForget(function(){return t.Iu.push(e),t.wu()})}},{key:"wu",value:function(){return(0,N._)(function(){var e,t;return(0,M._)(this,function(n){switch(n.label){case 0:if(e=this,0===this.Iu.length)return[3,5];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.Iu[0]()];case 2:return n.sent(),this.Iu.shift(),this.r_.reset(),[3,4];case 3:if(!nn(t=n.sent()))throw t;return tw("AsyncQueue","Operation failed with retryable error: "+t),[3,4];case 4:this.Iu.length>0&&this.r_.jo(function(){return e.wu()}),n.label=5;case 5:return[2]}})}).call(this)}},{key:"yu",value:function(e){var t=this,n=this.gu.then(function(){return t.Ru=!0,e().catch(function(e){var n;throw t.Au=e,t.Ru=!1,tI("INTERNAL UNHANDLED ERROR: ",(n=e.message||"",e.stack&&(n=e.stack.includes(e.message)?e.stack:e.message+"\n"+e.stack),n)),e}).then(function(e){return t.Ru=!1,e})});return this.gu=n,n}},{key:"enqueueAfterDelay",value:function(e,t,n){var r=this;this.pu(),this.mu.indexOf(e)>-1&&(t=0);var i=sY.createAndSchedule(this,e,t,n,function(e){return r.Su(e)});return this.du.push(i),i}},{key:"pu",value:function(){this.Au&&tS()}},{key:"verifyOperationInProgress",value:function(){}},{key:"bu",value:function(){return(0,N._)(function(){var e;return(0,M._)(this,function(t){switch(t.label){case 0:return[4,e=this.gu];case 1:t.sent(),t.label=2;case 2:if(e!==this.gu)return[3,0];t.label=3;case 3:return[2]}})}).call(this)}},{key:"Du",value:function(e){var t=!0,n=!1,r=void 0;try{for(var i,a=this.du[Symbol.iterator]();!(t=(i=a.next()).done);t=!0)if(i.value.timerId===e)return!0}catch(e){n=!0,r=e}finally{try{t||null==a.return||a.return()}finally{if(n)throw r}}return!1}},{key:"vu",value:function(e){var t=this;return this.bu().then(function(){t.du.sort(function(e,t){return e.targetTimeMs-t.targetTimeMs});var n=!0,r=!1,i=void 0;try{for(var a,o=t.du[Symbol.iterator]();!(n=(a=o.next()).done);
1n=!0){var s=a.value;if(s.skipDelay(),"all"!==e&&s.timerId===e)break}}catch(e){r=!0,i=e}finally{try{n||null==o.return||o.return()}finally{if(r)throw i}}return t.bu()})}},{key:"Cu",value:function(e){this.mu.push(e)}},{key:"Su",value:function(e){var t=this.du.indexOf(e);this.du.splice(t,1)}}]),e}();function u7(e){return function(e,t){if("object"!=(void 0===e?"undefined":(0,G._)(e))||null===e)return!1;var n=!0,r=!1,i=void 0;try{for(var a,o=t[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){var s=a.value;if(s in e&&"function"==typeof e[s])return!0}}catch(e){r=!0,i=e}finally{try{n||null==o.return||o.return()}finally{if(r)throw i}}return!1}(e,["next","error","complete"])}(0,P._)(function e(){(0,O._)(this,e),this._progressObserver={},this._taskCompletionResolver=new tA,this._lastProgress={taskState:"Running",totalBytes:0,totalDocuments:0,bytesLoaded:0,documentsLoaded:0}},[{key:"onProgress",value:function(e,t,n){this._progressObserver={next:e,error:t,complete:n}}},{key:"catch",value:function(e){return this._taskCompletionResolver.promise.catch(e)}},{key:"then",value:function(e,t){return this._taskCompletionResolver.promise.then(e,t)}},{key:"_completeWith",value:function(e){this._updateProgress(e),this._progressObserver.complete&&this._progressObserver.complete(),this._taskCompletionResolver.resolve(e)}},{key:"_failWith",value:function(e){this._lastProgress.taskState="Error",this._progressObserver.next&&this._progressObserver.next(this._lastProgress),this._progressObserver.error&&this._progressObserver.error(e),this._taskCompletionResolver.reject(e)}},{key:"_updateProgress",value:function(e){this._lastProgress=e,this._progressObserver.next&&this._progressObserver.next(e)}}]);var u9=function(e){function t(e,n,r,i){var a;return(0,O._)(this,t),(a=(0,V._)(this,t,[e,n,r,i])).type="firestore",a._queue=new u8,a._persistenceKey=(null==i?void 0:i.name)||"[DEFAULT]",a}return(0,z._)(t,e),(0,P._)(t,[{key:"_terminate",value:function(){return(0,N._)(function(){var e;return(0,M._)(this,function(t){switch(t.label){case 0:if(!this._firestoreClient)return[3,2];return e=this._firestoreClient.terminate(),this._queue=new u8(e),this._firestoreClient=void 0,[4,e];case 1:t.sent(),t.label=2;case 2:return[2]}})}).call(this)}}]),t}(u1);function ce(e,t,n){n||(n="(default)");var r=e5(e,"firestore");if(r.isInitialized(n)){var i=r.getImmediate({identifier:n});if(em(r.getOptions(n),t))return i;throw new tx(tC.FAILED_PRECONDITION,"initializeFirestore() has already been called with different options. To avoid this error, call initializeFirestore() with the same options as when it was originally called, or call getFirestore() to return the already initialized instance.")}if(void 0!==t.cacheSizeBytes&&void 0!==t.localCache)throw new tx(tC.INVALID_ARGUMENT,"cache and cacheSizeBytes cannot be specified at the same time as cacheSizeBytes willbe deprecated. Instead, specify the cache size in the cache object");if(void 0!==t.cacheSizeBytes&&-1!==t.cacheSizeBytes&&t.cacheSizeBytes<1048576)throw new tx(tC.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");return r.initialize({options:t,instanceIdentifier:n})}function ct(e,t){var n=e5("object"==(void 0===e?"undefined":(0,G._)(e))?e:tn(),"firestore").getImmediate({identifier:"string"==typeof e?e:t||"(default)"});if(!n._initialized){var r=es("firestore");r&&u2.apply(void 0,[n].concat((0,L._)(r)))}return n}(0,P._)(function e(t,n,r){(0,O._)(this,e),this._userDataWriter=n,this._data=r,this.type="AggregateQuerySnapshot",this.query=t},[{key:"data",value:function(){return this._userDataWriter.convertObjectMap(this._data)}}]);var cn=function(){function e(t){(0,O._)(this,e),this._byteString=t}return(0,P._)(e,[{key:"toBase64",value:function(){return this._byteString.toBase64()}},{key:"toUint8Array",value:function(){return this._byteString.toUint8Array()}},{key:"toString",value:function(){return"Bytes(base64: "+this.toBase64()+")"}},{key:"isEqual",value:function(e){return this._byteString.isEqual(e._byteString)}}],[{key:"fromBase64String",value:function(t){try{return new e(nJ.fromBase64String(t))}catch(e){throw new tx(tC.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+e)}}},{key:"fromUint8Array",value:function(t){return new e(nJ.fromUint8Array(t))}}]),e}(),cr=function(){function e(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];(0,O._)(this,e);for(var i=0;i<n.length;++i)if(0===n[i].length)throw new tx(tC.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new tH(n)}return(0,P._)(e,[{key:"isEqual",value:function(e){return this._internalPath.isEqual(e._internalPath)}}]),e}(),ci=function e(t){(0,O._)(this,e),this._methodName=t},ca=function(){function e(t,n){if((0,O._)(this,e),!isFinite(t)||t<-90||t>90)throw new tx(tC.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+t);if(!isFinite(n)||n<-180||n>180)throw new tx(tC.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+n);this._lat=t,this._long=n}return(0,P._)(e,[{key:"latitude",get:function(){return this._lat}},{key:"longitude",get:function(){return this._long}},{key:"isEqual",value:function(e){return this._lat===e._lat&&this._long===e._long}},{key:"toJSON",value:function(){return{latitude:this._lat,longitude:this._long}}},{key:"_compareTo",value:function(e){return tV(this._lat,e._lat)||tV(this._long,e._long)}}]),e}(),co=function(){function e(t){(0,O._)(this,e),this._values=(t||[]).map(function(e){return e})}return(0,P._)(e,[{key:"toArray",value:function(){return this._values.map(function(e){return e})}},{key:"isEqual",value:function(e){return function(e,t){if(e.length!==t.length)return!1;for(var n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0}(this._values,e._values)}}]),e}(),cs=/^__.*__$/,cu=function(){function e(t,n,r){(0,O._)(this,e),this.data=t,this.fieldMask=n,this.fieldTransforms=r}return(0,P._)(e,[{key:"toMutation",value:function(e,t){return null!==this.fieldMask?new ix(e,this.data,this.fieldMask,t,this.fieldTransforms):new iC(e,this.data,t,this.fieldTransforms)}}]),e}(),cc=function(){function e(t,n,r){(0,O._)(this,e),this.data=t,this.fieldMask=n,this.fieldTransforms=r}return(0,P._)(e,[{key:"toMutation",value:function(e,t){return new ix(e,this.data,this.fieldMask,t,this.fieldTransforms)}}]),e}();function cl(e){switch(e){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw tS()}}var ch=function(){function e(t,n,r,i,a,o){(0,O._)(this,e),this.settings=t,this.databaseId=n,this.serializer
1=r,this.ignoreUndefinedProperties=i,void 0===a&&this.Fu(),this.fieldTransforms=a||[],this.fieldMask=o||[]}return(0,P._)(e,[{key:"path",get:function(){return this.settings.path}},{key:"Mu",get:function(){return this.settings.Mu}},{key:"xu",value:function(t){return new e(Object.assign(Object.assign({},this.settings),t),this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}},{key:"Ou",value:function(e){var t,n=null==(t=this.path)?void 0:t.child(e),r=this.xu({path:n,Nu:!1});return r.Lu(e),r}},{key:"Bu",value:function(e){var t,n=null==(t=this.path)?void 0:t.child(e),r=this.xu({path:n,Nu:!1});return r.Fu(),r}},{key:"ku",value:function(e){return this.xu({path:void 0,Nu:!0})}},{key:"qu",value:function(e){return cR(e,this.settings.methodName,this.settings.Qu||!1,this.path,this.settings.Ku)}},{key:"contains",value:function(e){return void 0!==this.fieldMask.find(function(t){return e.isPrefixOf(t)})||void 0!==this.fieldTransforms.find(function(t){return e.isPrefixOf(t.field)})}},{key:"Fu",value:function(){if(this.path)for(var e=0;e<this.path.length;e++)this.Lu(this.path.get(e))}},{key:"Lu",value:function(e){if(0===e.length)throw this.qu("Document fields must not be empty");if(cl(this.Mu)&&cs.test(e))throw this.qu('Document fields cannot begin and end with "__"')}}]),e}(),cf=function(){function e(t,n,r){(0,O._)(this,e),this.databaseId=t,this.ignoreUndefinedProperties=n,this.serializer=r||sm(t)}return(0,P._)(e,[{key:"$u",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return new ch({Mu:e,methodName:t,Ku:n,path:tH.emptyPath(),Nu:!1,Qu:r},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}}]),e}();function cd(e){var t=e._freezeSettings(),n=sm(e._databaseId);return new cf(e._databaseId,!!t.ignoreUndefinedProperties,n)}function cv(e,t,n,r,i){var a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},o=e.$u(a.merge||a.mergeFields?2:0,t,n,i);cC("Data must be an object, but it was:",o,r);var s=cE(r,o);if(a.merge)f=new nW(o.fieldMask),d=o.fieldTransforms;else if(a.mergeFields){var u=[],c=!0,l=!1,h=void 0;try{for(var f,d,v,y=a.mergeFields[Symbol.iterator]();!(c=(v=y.next()).done);c=!0){var p=v.value,m=cx(t,p,n);if(!o.contains(m))throw new tx(tC.INVALID_ARGUMENT,"Field '".concat(m,"' is specified in your field mask but missing from your input data."));cN(u,m)||u.push(m)}}catch(e){l=!0,h=e}finally{try{c||null==y.return||y.return()}finally{if(l)throw h}}f=new nW(u),d=o.fieldTransforms.filter(function(e){return f.covers(e.field)})}else f=null,d=o.fieldTransforms;return new cu(new rp(s),f,d)}var cy=function(e){function t(){return(0,O._)(this,t),(0,V._)(this,t,arguments)}return(0,z._)(t,e),(0,P._)(t,[{key:"_toFieldTransform",value:function(e){if(2!==e.Mu)throw 1===e.Mu?e.qu("".concat(this._methodName,"() can only appear at the top level of your update data")):e.qu("".concat(this._methodName,"() cannot be used with set() unless you pass {merge:true}"));return e.fieldMask.push(e.path),null}},{key:"isEqual",value:function(e){return(0,K._)(e,t)}}]),t}(ci);function cp(e,t,n){return new ch({Mu:3,Ku:t.settings.Ku,methodName:e._methodName,Nu:n},t.databaseId,t.serializer,t.ignoreUndefinedProperties)}function cm(){return(0,O._)(this,cm),(0,V._)(this,cm,arguments)}(0,z._)(cm,ci),(0,P._)(cm,[{key:"_toFieldTransform",value:function(e){return new i_(e.path,new il)}},{key:"isEqual",value:function(e){return(0,K._)(e,cm)}}]);function cg(e,t){var n;return(0,O._)(this,cg),(n=(0,V._)(this,cg,[e])).Uu=t,n}(0,z._)(cg,ci),(0,P._)(cg,[{key:"_toFieldTransform",value:function(e){var t=cp(this,e,!0),n=new ih(this.Uu.map(function(e){return cT(e,t)}));return new i_(e.path,n)}},{key:"isEqual",value:function(e){return(0,K._)(e,cg)&&em(this.Uu,e.Uu)}}]);function c_(e,t){var n;return(0,O._)(this,c_),(n=(0,V._)(this,c_,[e])).Uu=t,n}(0,z._)(c_,ci),(0,P._)(c_,[{key:"_toFieldTransform",value:function(e){var t=cp(this,e,!0),n=new iv(this.Uu.map(function(e){return cT(e,t)}));return new i_(e.path,n)}},{key:"isEqual",value:function(e){return(0,K._)(e,c_)&&em(this.Uu,e.Uu)}}]);function ck(e,t){var n;return(0,O._)(this,ck),(n=(0,V._)(this,ck,[e])).Wu=t,n}function cb(e,t,n,r){var i=e.$u(1,t,n);cC("Data must be an object, but it was:",i,r);var a=[],o=rp.empty();return nV(r,function(e,r){var s=cD(t,e,n);r=eT(r);var u=i.Bu(s);if((0,K._)(r,cy))a.push(s);else{var c=cT(r,u);null!=c&&(a.push(s),o.set(s,c))}}),new cc(o,new nW(a),i.fieldTransforms)}function cw(e,t,n,r,i,a){var o=e.$u(1,t,n),s=[cx(t,r,n)],u=[i];if(a.length%2!=0)throw new tx(tC.INVALID_ARGUMENT,"Function ".concat(t,"() needs to be called with an even number of arguments that alternate between field names and values."));for(var c=0;c<a.length;c+=2)s.push(cx(t,a[c])),u.push(a[c+1]);for(var l=[],h=rp.empty(),f=s.length-1;f>=0;--f)if(!cN(l,s[f])){var d=s[f],v=u[f];
1v=eT(v);var y=o.Bu(d);if((0,K._)(v,cy))l.push(d);else{var p=cT(v,y);null!=p&&(l.push(d),h.set(d,p))}}return new cc(h,new nW(l),o.fieldTransforms)}function cI(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return cT(n,e.$u(r?4:3,t))}function cT(e,t){if(cS(e=eT(e)))return cC("Unsupported field value:",t,e),cE(e,t);if((0,K._)(e,ci))return function(e,t){if(!cl(t.Mu))throw t.qu("".concat(e._methodName,"() can only be used with update() and set()"));if(!t.path)throw t.qu("".concat(e._methodName,"() is not currently supported inside arrays"));var n=e._toFieldTransform(t);n&&t.fieldTransforms.push(n)}(e,t),null;if(void 0===e&&t.ignoreUndefinedProperties)return null;if(t.path&&t.fieldMask.push(t.path),(0,K._)(e,Array)){if(t.settings.Nu&&4!==t.Mu)throw t.qu("Nested arrays are not supported");return function(e,t){var n=[],r=0,i=!0,a=!1,o=void 0;try{for(var s,u=e[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var c=s.value,l=cT(c,t.ku(r));null==l&&(l={nullValue:"NULL_VALUE"}),n.push(l),r++}}catch(e){a=!0,o=e}finally{try{i||null==u.return||u.return()}finally{if(a)throw o}}return{arrayValue:{values:n}}}(e,t)}var n=e,r=t;if(null===(n=eT(n)))return{nullValue:"NULL_VALUE"};if("number"==typeof n)return iu(r.serializer,n);if("boolean"==typeof n)return{booleanValue:n};if("string"==typeof n)return{stringValue:n};if((0,K._)(n,Date)){var i=tj.fromDate(n);return{timestampValue:i6(r.serializer,i)}}if((0,K._)(n,tj)){var a=new tj(n.seconds,1e3*Math.floor(n.nanoseconds/1e3));return{timestampValue:i6(r.serializer,a)}}if((0,K._)(n,ca))return{geoPointValue:{latitude:n.latitude,longitude:n.longitude}};if((0,K._)(n,cn))return{bytesValue:i8(r.serializer,n._byteString)};if((0,K._)(n,u4)){var o=r.databaseId,s=n.firestore._databaseId;if(!s.isEqual(o))throw r.qu("Document reference is for database ".concat(s.projectId,"/").concat(s.database," but should be for database ").concat(o.projectId,"/").concat(o.database));return{referenceValue:i9(n.firestore._databaseId||r.databaseId,n._key.path)}}if((0,K._)(n,co))return{mapValue:{fields:{__type__:{stringValue:"__vector__"},value:{arrayValue:{values:n.toArray().map(function(e){if("number"!=typeof e)throw r.qu("VectorValues must only contain numeric values.");return io(r.serializer,e)})}}}}};throw r.qu("Unsupported field value: ".concat(u$(n)))}function cE(e,t){var n={};return nB(e)?t.path&&t.path.length>0&&t.fieldMask.push(t.path):nV(e,function(e,r){var i=cT(r,t.Ou(e));null!=i&&(n[e]=i)}),{mapValue:{fields:n}}}function cS(e){return!("object"!=(void 0===e?"undefined":(0,G._)(e))||null===e||(0,K._)(e,Array)||(0,K._)(e,Date)||(0,K._)(e,tj)||(0,K._)(e,ca)||(0,K._)(e,cn)||(0,K._)(e,u4)||(0,K._)(e,ci)||(0,K._)(e,co))}function cC(e,t,n){if(!cS(n)||"object"!=(void 0===n?"undefined":(0,G._)(n))||null===n||Object.getPrototypeOf(n)!==Object.prototype&&null!==Object.getPrototypeOf(n)){var r=u$(n);throw"an object"===r?t.qu(e+" a custom object"):t.qu(e+" "+r)}}function cx(e,t,n){if((0,K._)(t=eT(t),cr))return t._internalPath;if("string"==typeof t)return cD(e,t);throw cR("Field path arguments must be of type string or ",e,!1,void 0,n)}(0,z._)(ck,ci),(0,P._)(ck,[{key:"_toFieldTransform",value:function(e){var t=new ip(e.serializer,iu(e.serializer,this.Wu));return new i_(e.path,t)}},{key:"isEqual",value:function(e){return(0,K._)(e,ck)&&this.Wu===e.Wu}}]);var cA=RegExp("[~\\*/\\[\\]]");function cD(e,t,n){if(t.search(cA)>=0)throw cR("Invalid field path (".concat(t,"). Paths must not contain '~', '*', '/', '[', or ']'"),e,!1,void 0,n);try{return(0,B._)(cr,(0,L._)(t.split(".")))._internalPath}catch(r){throw cR("Invalid field path (".concat(t,"). Paths must not be empty, begin with '.', end with '.', or contain '..'"),e,!1,void 0,n)}}function cR(e,t,n,r,i){var a=r&&!r.isEmpty(),o=void 0!==i,s="Function ".concat(t,"() called with invalid data");n&&(s+=" (via `toFirestore()`)"),s+=". ";var u="";return(a||o)&&(u+=" (found",a&&(u+=" in field ".concat(r)),o&&(u+=" in document ".concat(i)),u+=")"),new tx(tC.INVALID_ARGUMENT,s+e+u)}function cN(e,t){return e.some(function(e){return e.isEqual(t)})}var cO=function(){function e(t,n,r,i,a){(0,O._)(this,e),this._firestore=t,this._userDataWriter=n,this._key=r,this._document=i,this._converter=a}return(0,P._)(e,[{key:"id",get:function(){return this._key.path.lastSegment()}},{key:"ref",get:function(){return new u4(this._firestore,this._converter,this._key)}},{key:"exists",value:function(){return null!==this._document}},{key:"data",value:function(){if(this._document){if(this._converter){var e=new cP(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(e)}return this._userDataWriter.convertValue(this._document.data.value)}}},{key:"get",value:function(e){if(this._document){var t=this._document.data.field(cL("DocumentSnapshot.get",e));if(null!==t)return this._userDataWriter.convertValue(t)}}}]),e}(),cP=function(e){function t(){return(0,O._)(this,t),(0,V._)(this,t,arguments)}return(0,z._)(t,e),(0,P._)(t,[{key:"data",value:function(){return(0,j._)((0,q._)(t.prototype),"data",this).call(this)}}]),t}(cO);function cL(e,t){return"string"==typeof t?cD(e,t):(0,K._)(t,cr)?t._internalPath:t._delegate._internalPath}var cM=function e(){(0,O._)(this,e)},cU=function(e){function t(){return(0,O._)(this,t),(0,V._)(this,t,arguments)}return(0,z._)(t,e),t}(cM);function cF(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];var a=[];(0,K._)(t,cM)&&a.push(t),function(e){var t=e.filter(function(e){return(0,K._)(e,cj)}).length,n=e.filter(function(e){return(0,K._)(e,cV)}).length;if(t>1||t>0&&n>0)throw new tx(tC.INVALID_ARGUMENT,"InvalidQuery. When using composite filters, you cannot use more than one filter at the top level. Consider nesting the multiple filters within an `and(...)` statement. For example: change `query(query, where(...), or(...))` to `query(query, and(where(...), or(...)))`.")}(a=a.concat(r));var o=!0,s=!1,u=void 0;try{for(var c,l=a[Symbol.iterator]();!(o=(c=l.next()).done);o=!0)e=c.value._apply(e)}catch(e){s=!0,u=e}finally{try{o||null==l.return||l.return()}finally{if(s)throw u}}return e}var cV=function(e){function t(e,n,r){var i;return(0,O._)(this,t),(i=(0,V._)(this,t))._field=e,i._op=n,i._value=r,i.type="where",i}return(0,z._)(t,e),(0,P._)(t,[{key:"_apply",value:function(e){var t=this._parse(e);return cX(e._query,t),new u3(e.firestore,e.converter,r$(e._query,t))}},{key:"_parse",value:function(e){var t=cd(e.firestore);return function(e,t,n,r,i,a,o){var s;
1if(i.isKeyField()){if("array-contains"===a||"array-contains-any"===a)throw new tx(tC.INVALID_ARGUMENT,"Invalid Query. You can't perform '".concat(a,"' queries on documentId()."));if("in"===a||"not-in"===a){cJ(o,a);var u=[],c=!0,l=!1,h=void 0;try{for(var f,d=o[Symbol.iterator]();!(c=(f=d.next()).done);c=!0){var v=f.value;u.push(cQ(r,e,v))}}catch(e){l=!0,h=e}finally{try{c||null==d.return||d.return()}finally{if(l)throw h}}s={arrayValue:{values:u}}}else s=cQ(r,e,o)}else"in"!==a&&"not-in"!==a&&"array-contains-any"!==a||cJ(o,a),s=cI(n,t,o,"in"===a||"not-in"===a);return rI.create(i,a,s)}(e._query,"where",t,e.firestore._databaseId,this._field,this._op,this._value)}}],[{key:"_create",value:function(e,n,r){return new t(e,n,r)}}]),t}(cU);function cB(e,t,n){var r=cL("where",e);return cV._create(r,t,n)}var cj=function(e){function t(e,n){var r;return(0,O._)(this,t),(r=(0,V._)(this,t)).type=e,r._queryConstraints=n,r}return(0,z._)(t,e),(0,P._)(t,[{key:"_parse",value:function(e){var t=this._queryConstraints.map(function(t){return t._parse(e)}).filter(function(e){return e.getFilters().length>0});return 1===t.length?t[0]:rT.create(t,this._getOperator())}},{key:"_apply",value:function(e){var t=this._parse(e);return 0===t.getFilters().length?e:(function(e,t){var n=e,r=t.getFlattenedFilters(),i=!0,a=!1,o=void 0;try{for(var s,u=r[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var c=s.value;cX(n,c),n=r$(n,c)}}catch(e){a=!0,o=e}finally{try{i||null==u.return||u.return()}finally{if(a)throw o}}}(e._query,t),new u3(e.firestore,e.converter,r$(e._query,t)))}},{key:"_getQueryConstraints",value:function(){return this._queryConstraints}},{key:"_getOperator",value:function(){return"and"===this.type?"and":"or"}}],[{key:"_create",value:function(e,n){return new t(e,n)}}]),t}(cM),cq=function(e){function t(e,n){var r;return(0,O._)(this,t),(r=(0,V._)(this,t))._field=e,r._direction=n,r.type="orderBy",r}return(0,z._)(t,e),(0,P._)(t,[{key:"_apply",value:function(e){var t,n,r=function(e,t,n){if(null!==e.startAt)throw new tx(tC.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(null!==e.endAt)throw new tx(tC.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");return new rb(t,n)}(e._query,this._field,this._direction);return new u3(e.firestore,e.converter,(t=e._query,n=t.explicitOrderBy.concat([r]),new rH(t.path,t.collectionGroup,n,t.filters.slice(),t.limit,t.limitType,t.startAt,t.endAt)))}}],[{key:"_create",value:function(e,n){return new t(e,n)}}]),t}(cU);function cz(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"asc",n=cL("orderBy",e);return cq._create(n,t)}function cK(e,t,n){var r;return(0,O._)(this,cK),(r=(0,V._)(this,cK)).type=e,r._limit=t,r._limitType=n,r}(0,z._)(cK,cU),(0,P._)(cK,[{key:"_apply",value:function(e){return new u3(e.firestore,e.converter,rZ(e._query,this._limit,this._limitType))}}],[{key:"_create",value:function(e,t,n){return new cK(e,t,n)}}]);function cG(e,t,n){var r;return(0,O._)(this,cG),(r=(0,V._)(this,cG)).type=e,r._docOrFields=t,r._inclusive=n,r}(0,z._)(cG,cU),(0,P._)(cG,[{key:"_apply",value:function(e){var t,n=cW(e,this.type,this._docOrFields,this._inclusive);return new u3(e.firestore,e.converter,(t=e._query,new rH(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,n,t.endAt)))}}],[{key:"_create",value:function(e,t,n){return new cG(e,t,n)}}]);function cH(e,t,n){var r;return(0,O._)(this,cH),(r=(0,V._)(this,cH)).type=e,r._docOrFields=t,r._inclusive=n,r}function cW(e,t,n,r){if(n[0]=eT(n[0]),(0,K._)(n[0],cO))return function(e,t,n,r,i){if(!r)throw new tx(tC.NOT_FOUND,"Can't use a DocumentSnapshot that doesn't exist for ".concat(n,"()."));var a=[],o=!0,s=!1,u=void 0;try{for(var c,l=rX(e)[Symbol.iterator]();!(o=(c=l.next()).done);o=!0){var h=c.value;if(h.field.isKeyField())a.push(ri(t,r.key));else{var f=r.data.field(h.field);if(n0(f))throw new tx(tC.INVALID_ARGUMENT,'Invalid query. You are trying to start or end a query using a document for which the field "'+h.field+'" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');if(null===f){var d=h.field.canonicalString();throw new tx(tC.INVALID_ARGUMENT,"Invalid query. You are trying to start or end a query using a document for which the field '".concat(d,"' (used as the orderBy) does not exist."))}a.push(f)}}}catch(e){s=!0,u=e}finally{try{o||null==l.return||l.return()}finally{if(s)throw u}}return new rg(a,i)}(e._query,e.firestore._databaseId,t,n[0]._document,r);var i=cd(e.firestore);return function(e,t,n,r,i,a){var o=e.explicitOrderBy;if(i.length>o.length)throw new tx(tC.INVALID_ARGUMENT,"Too many arguments provided to ".concat(r,"(). The number of arguments must be less than or equal to the number of orderBy() clauses"));for(var s=[],u=0;u<i.length;u++){var c=i[u];
1if(o[u].field.isKeyField()){if("string"!=typeof c)throw new tx(tC.INVALID_ARGUMENT,"Invalid query. Expected a string for document ID in ".concat(r,"(), but got a ").concat(void 0===c?"undefined":(0,G._)(c)));if(!rJ(e)&&-1!==c.indexOf("/"))throw new tx(tC.INVALID_ARGUMENT,"Invalid query. When querying a collection and ordering by documentId(), the value passed to ".concat(r,"() must be a plain document ID, but '").concat(c,"' contains a slash."));var l=e.path.child(tK.fromString(c));if(!tW.isDocumentKey(l))throw new tx(tC.INVALID_ARGUMENT,"Invalid query. When querying a collection group and ordering by documentId(), the value passed to ".concat(r,"() must result in a valid document path, but '").concat(l,"' is not because it contains an odd number of segments."));var h=new tW(l);s.push(ri(t,h))}else{var f=cI(n,r,c);s.push(f)}}return new rg(s,a)}(e._query,e.firestore._databaseId,i,t,n,r)}function cQ(e,t,n){if("string"==typeof(n=eT(n))){if(""===n)throw new tx(tC.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!rJ(t)&&-1!==n.indexOf("/"))throw new tx(tC.INVALID_ARGUMENT,"Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '".concat(n,"' contains a '/' character."));var r=t.path.child(tK.fromString(n));if(!tW.isDocumentKey(r))throw new tx(tC.INVALID_ARGUMENT,"Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '".concat(r,"' is not because it has an odd number of segments (").concat(r.length,")."));return ri(e,new tW(r))}if((0,K._)(n,u4))return ri(e,n._key);throw new tx(tC.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ".concat(u$(n),"."))}function cJ(e,t){if(!Array.isArray(e)||0===e.length)throw new tx(tC.INVALID_ARGUMENT,"Invalid Query. A non-empty array is required for '".concat(t.toString(),"' filters."))}function cX(e,t){var n=function(e,t){var n=!0,r=!1,i=void 0,a=!0,o=!1,s=void 0;try{for(var u,c=e[Symbol.iterator]();!(a=(u=c.next()).done);a=!0){var l=u.value;try{for(var h,f=l.getFlattenedFilters()[Symbol.iterator]();!(n=(h=f.next()).done);n=!0){var d=h.value;if(t.indexOf(d.op)>=0)return d.op}}catch(e){r=!0,i=e}finally{try{n||null==f.return||f.return()}finally{if(r)throw i}}}}catch(e){o=!0,s=e}finally{try{a||null==c.return||c.return()}finally{if(o)throw s}}return null}(e.filters,function(e){switch(e){case"!=":return["!=","not-in"];case"array-contains-any":case"in":return["not-in"];case"not-in":return["array-contains-any","in","not-in","!="];default:return[]}}(t.op));if(null!==n)throw n===t.op?new tx(tC.INVALID_ARGUMENT,"Invalid query. You cannot use more than one '".concat(t.op.toString(),"' filter.")):new tx(tC.INVALID_ARGUMENT,"Invalid query. You cannot use '".concat(t.op.toString(),"' filters with '").concat(n.toString(),"' filters."))}(0,z._)(cH,cU),(0,P._)(cH,[{key:"_apply",value:function(e){var t,n=cW(e,this.type,this._docOrFields,this._inclusive);return new u3(e.firestore,e.converter,(t=e._query,new rH(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,t.startAt,n)))}}],[{key:"_create",value:function(e,t,n){return new cH(e,t,n)}}]);var cY=function(){function e(){(0,O._)(this,e)}return(0,P._)(e,[{key:"convertValue",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"none";switch(n8(e)){case 0:return null;case 1:return e.booleanValue;case 2:return n$(e.integerValue||e.doubleValue);case 3:return this.convertTimestamp(e.timestampValue);case 4:return this.convertServerTimestamp(e,t);case 5:return e.stringValue;case 6:return this.convertBytes(nZ(e.bytesValue));case 7:return this.convertReference(e.referenceValue);case 8:return this.convertGeoPoint(e.geoPointValue);case 9:return this.convertArray(e.arrayValue,t);case 11:return this.convertObject(e.mapValue,t);case 10:return this.convertVectorValue(e.mapValue);default:throw tS()}}},{key:"convertObject",value:function(e,t){return this.convertObjectMap(e.fields,t)}},{key:"convertObjectMap",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"none",r={};return nV(e,function(e,i){r[e]=t.convertValue(i,n)}),r}},{key:"convertVectorValue",value:function(e){var t,n,r;return new co(null==(r=null==(n=null==(t=e.fields)?void 0:t.value.arrayValue)?void 0:n.values)?void 0:r.map(function(e){return n$(e.doubleValue)}))}},{key:"convertGeoPoint",value:function(e){return new ca(n$(e.latitude),n$(e.longitude))}},{key:"convertArray",value:function(e,t){var n=this;return(e.values||[]).map(function(e){return n.convertValue(e,t)})}},{key:"convertServerTimestamp",value:function(e,t){switch(t){case"previous":var n=n1(e);return null==n?null:this.convertValue(n,t);case"estimate":return this.convertTimestamp(n2(e));default:return null}}},{key:"convertTimestamp",value:function(e){var t=nY(e);return new tj(t.seconds,t.nanos)}},{key:"convertDocumentKey",value:function(e,t){var n=tK.fromString(e);am(n)||tS();var r=new n4(n.get(1),n.get(3)),i=new tW(n.popFirst(5));return r.isEqual(t)||tI("Document ".concat(i," contains a document reference within a different database (").concat(r.projectId,"/").concat(r.database,") which is not supported. It will be treated as a reference in the current database (").concat(t.projectId,"/").concat(t.database,") instead.")),i}}]),e}();function c$(e,t,n){return e?n&&(n.merge||n.mergeFields)?e.toFirestore(t,n):e.toFirestore(t):t}var cZ=function(e){function t(e){var n;return(0,O._)(this,t),(n=(0,V._)(this,t)).firestore=e,n}
1return(0,z._)(t,e),(0,P._)(t,[{key:"convertBytes",value:function(e){return new cn(e)}},{key:"convertReference",value:function(e){var t=this.convertDocumentKey(e,this.firestore._databaseId);return new u4(this.firestore,null,t)}}]),t}(cY),c0=function(){function e(t,n){(0,O._)(this,e),this.hasPendingWrites=t,this.fromCache=n}return(0,P._)(e,[{key:"isEqual",value:function(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}}]),e}(),c1=function(e){function t(e,n,r,i,a,o){var s;return(0,O._)(this,t),(s=(0,V._)(this,t,[e,n,r,i,o]))._firestore=e,s._firestoreImpl=e,s.metadata=a,s}return(0,z._)(t,e),(0,P._)(t,[{key:"exists",value:function(){return(0,j._)((0,q._)(t.prototype),"exists",this).call(this)}},{key:"data",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this._document){if(this._converter){var t=new c2(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(t,e)}return this._userDataWriter.convertValue(this._document.data.value,e.serverTimestamps)}}},{key:"get",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this._document){var n=this._document.data.field(cL("DocumentSnapshot.get",e));if(null!==n)return this._userDataWriter.convertValue(n,t.serverTimestamps)}}}]),t}(cO),c2=function(e){function t(){return(0,O._)(this,t),(0,V._)(this,t,arguments)}return(0,z._)(t,e),(0,P._)(t,[{key:"data",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return(0,j._)((0,q._)(t.prototype),"data",this).call(this,e)}}]),t}(c1),c3=function(){function e(t,n,r,i){(0,O._)(this,e),this._firestore=t,this._userDataWriter=n,this._snapshot=i,this.metadata=new c0(i.hasPendingWrites,i.fromCache),this.query=r}return(0,P._)(e,[{key:"docs",get:function(){var e=[];return this.forEach(function(t){return e.push(t)}),e}},{key:"size",get:function(){return this._snapshot.docs.size}},{key:"empty",get:function(){return 0===this.size}},{key:"forEach",value:function(e,t){var n=this;this._snapshot.docs.forEach(function(r){e.call(t,new c2(n._firestore,n._userDataWriter,r.key,r,new c0(n._snapshot.mutatedKeys.has(r.key),n._snapshot.fromCache),n.query.converter))})}},{key:"docChanges",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=!!e.includeMetadataChanges;if(t&&this._snapshot.excludesMetadataChanges)throw new tx(tC.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===t||(this._cachedChanges=function(e,t){if(e._snapshot.oldDocs.isEmpty()){var n=0;return e._snapshot.docChanges.map(function(t){var r=new c2(e._firestore,e._userDataWriter,t.doc.key,t.doc,new c0(e._snapshot.mutatedKeys.has(t.doc.key),e._snapshot.fromCache),e.query.converter);return t.doc,{type:"added",doc:r,oldIndex:-1,newIndex:n++}})}var r=e._snapshot.oldDocs;return e._snapshot.docChanges.filter(function(e){return t||3!==e.type}).map(function(t){var n=new c2(e._firestore,e._userDataWriter,t.doc.key,t.doc,new c0(e._snapshot.mutatedKeys.has(t.doc.key),e._snapshot.fromCache),e.query.converter),i=-1,a=-1;return 0!==t.type&&(i=r.indexOf(t.doc.key),r=r.delete(t.doc.key)),1!==t.type&&(a=(r=r.add(t.doc)).indexOf(t.doc.key)),{type:function(e){switch(e){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return tS()}}(t.type),doc:n,oldIndex:i,newIndex:a}})}(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}}]),e}(),c4=function(e){function t(e){var n;return(0,O._)(this,t),(n=(0,V._)(this,t)).firestore=e,n}
1return(0,z._)(t,e),(0,P._)(t,[{key:"convertBytes",value:function(e){return new cn(e)}},{key:"convertReference",value:function(e){var t=this.convertDocumentKey(e,this.firestore._databaseId);return new u4(this.firestore,null,t)}}]),t}(cY);function c5(e){for(var t,n,r,i,a,o,s,u,c,l=arguments.length,h=Array(l>1?l-1:0),f=1;f<l;f++)h[f-1]=arguments[f];e=eT(e);var d={includeMetadataChanges:!1,source:"default"},v=0;"object"!=(0,G._)(h[v])||u7(h[v])||(d=h[v],v++);var y={includeMetadataChanges:d.includeMetadataChanges,source:d.source};if(u7(h[v])){var p=h[v];h[v]=null==(i=p.next)?void 0:i.bind(p),h[v+1]=null==(a=p.error)?void 0:a.bind(p),h[v+2]=null==(o=p.complete)?void 0:o.bind(p)}if((0,K._)(e,u4))u=uZ(e.firestore,u9),c=rW(e._key.path),s={next:function(t){var n,r,i,a,o;h[v]&&h[v]((n=u,r=e,a=(i=t).docs.get(r._key),o=new c4(n),new c1(n,o,r._key,a,new c0(i.hasPendingWrites,i.fromCache),r.converter)))},error:h[v+1],complete:h[v+2]};else{var m=uZ(e,u3);u=uZ(m.firestore,u9),c=m._query;var g=new c4(u);s={next:function(e){h[v]&&h[v](new c3(u,g,m,e))},error:h[v+1],complete:h[v+2]},function(e){if("L"===e.limitType&&0===e.explicitOrderBy.length)throw new tx(tC.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}(e._query)}return t=function(e){if(e._terminated)throw new tx(tC.FAILED_PRECONDITION,"The client has already been terminated.");return e._firestoreClient||function(e){var t,n,r,i,a,o,s,u=e._freezeSettings(),c=(r=e._databaseId,i=(null==(a=e._app)?void 0:a.options.appId)||"",new n3(r,i,e._persistenceKey,u.host,u.ssl,u.experimentalForceLongPolling,u.experimentalAutoDetectLongPolling,uJ(u.experimentalLongPollingOptions),u.useFetchStreams));e._componentsProvider||(null==(o=u.localCache)?void 0:o._offlineComponentProvider)&&(null==(s=u.localCache)?void 0:s._onlineComponentProvider)&&(e._componentsProvider={_offline:u.localCache._offlineComponentProvider,_online:u.localCache._onlineComponentProvider}),e._firestoreClient=new uG(e._authCredentials,e._appCheckCredentials,e._queue,c,e._componentsProvider&&(n=null==(t=e._componentsProvider)?void 0:t._online.build(),{_offline:null==t?void 0:t._offline.build(n),_online:n}))}(e),e._firestoreClient}(u),r=new ue(c,n=new uz(s),y),t.asyncQueue.enqueueAndForget(function(){return(0,N._)(function(){return(0,M._)(this,function(e){switch(e.label){case 0:return[4,uQ(t)];case 1:return[2,s5.apply(void 0,[e.sent(),r])]}})})()}),function(){n.eu(),t.asyncQueue.enqueueAndForget(function(){return(0,N._)(function(){return(0,M._)(this,function(e){switch(e.label){case 0:return[4,uQ(t)];case 1:return[2,s6.apply(void 0,[e.sent(),r])]}})})()})}}(0,P._)(function e(t){(0,O._)(this,e),this.kind="memory",this._onlineComponentProvider=uq.provider,(null==t?void 0:t.garbageCollector)?this._offlineComponentProvider=t.garbageCollector._offlineComponentProvider:this._offlineComponentProvider={build:function(){return new uV(void 0)}}},[{key:"toJSON",value:function(){return{kind:this.kind}}}]);var c6=function(){function e(t){var n,r;(0,O._)(this,e),this.kind="persistent",(null==t?void 0:t.tabManager)?(t.tabManager._initialize(t),n=t.tabManager):(n=new c7((r=void 0,void 0)))._initialize(t),this._onlineComponentProvider=n._onlineComponentProvider,this._offlineComponentProvider=n._offlineComponentProvider}return(0,P._)(e,[{key:"toJSON",value:function(){return{kind:this.kind}}}]),e}();function c8(e){return new c6(e)}(0,P._)(function e(){(0,O._)(this,e),this.kind="memoryEager",this._offlineComponentProvider=uF.provider},[{key:"toJSON",value:function(){return{kind:this.kind}}}]),(0,P._)(function e(t){(0,O._)(this,e),this.kind="memoryLru",this._offlineComponentProvider={build:function(){return new uV(t)}}},[{key:"toJSON",value:function(){return{kind:this.kind}}}]);var c7=function(){function e(t){(0,O._)(this,e),this.forceOwnership=t,this.kind="persistentSingleTab"}return(0,P._)(e,[{key:"toJSON",value:function(){return{kind:this.kind}}},{key:"_initialize",value:function(e){var t=this;this._onlineComponentProvider=uq.provider,this._offlineComponentProvider={build:function(n){return new uB(n,null==e?void 0:e.cacheSizeBytes,t.forceOwnership)}}}}]),e}(),c9=function(){function e(){(0,O._)(this,e),this.kind="PersistentMultipleTab"}return(0,P._)(e,[{key:"toJSON",value:function(){return{kind:this.kind}}},{key:"_initialize",value:function(e){this._onlineComponentProvider=uq.provider,this._offlineComponentProvider={build:function(t){return new uj(t,null==e?void 0:e.cacheSizeBytes)}}}}]),e}();function le(){return new c9}function lt(e,t){if((e=eT(e)).firestore!==t)throw new tx(tC.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return e}(0,P._)(function e(t,n){(0,O._)(this,e),this._firestore=t,this._commitHandler=n,this._mutations=[],this._committed=!1,this._dataReader=cd(t)},[{key:"set",value:function(e,t,n){this._verifyNotCommitted();var r=lt(e,this._firestore),i=c$(r.converter,t,n),a=cv(this._dataReader,"WriteBatch.set",r._key,i,null!==r.converter,n);return this._mutations.push(a.toMutation(r._key,ib.none())),this}},{key:"update",value:function(e,t,n){for(var r,i=arguments.length,a=Array(i>3?i-3:0),o=3;o<i;o++)a[o-3]=arguments[o];this._verifyNotCommitted();var s=lt(e,this._firestore);return r="string"==typeof(t=eT(t))||(0,K._)(t,cr)?cw(this._dataReader,"WriteBatch.update",s._key,t,n,a):cb(this._dataReader,"WriteBatch.update",s._key,t),this._mutations.push(r.toMutation(s._key,ib.exists(!0))),this}},{key:"delete",value:function(e){this._verifyNotCommitted();var t=lt(e,this._firestore);return this._mutations=this._mutations.concat(new iN(t._key,ib.none())),this}},{key:"commit",value:function(){return this._verifyNotCommitted(),this._committed=!0,this._mutations.length>0?this._commitHandler(this._mutations):Promise.resolve()}},{key:"_verifyNotCommitted",value:function(){if(this._committed)throw new tx(tC.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")}}]);var ln=function(){function e(t,n){(0,O._)(this,e),this._firestore=t,this._transaction=n,this._dataReader=cd(t)}return(0,P._)(e,[{key:"get",value:function(e){var t=this,n=lt(e,this._firestore),r=new cZ(this._firestore);return this._transaction.lookup([n._key]).then(function(e){if(!e||1!==e.length)return tS();var i=e[0];if(i.isFoundDocument())return new cO(t._firestore,r,i.key,i,n.converter);if(i.isNoDocument())return new cO(t._firestore,r,n._key,null,n.converter);throw tS()})}},{key:"set",value:function(e,t,n){var r=lt(e,this._firestore),i=c$(r.converter,t,n),a=cv(this._dataReader,"Transaction.set",r._key,i,null!==r.converter,n);return this._transaction.set(r._key,a),this}},{key:"update",value:function(e,t,n){for(var r,i=arguments.length,a=Array(i>3?i-3:0),o=3;o<i;o++)a[o-3]=arguments[o];var s=lt(e,this._firestore);return r="string"==typeof(t=eT(t))||(0,K._)(t,cr)?cw(this._dataReader,"Transaction.update",s._key,t,n,a):cb(this._dataReader,"Transaction.update",s._key,t),this._transaction.update(s._key,r),this}},{key:"delete",value:function(e){var t=lt(e,this._firestore);return this._transaction.delete(t._key),this}}]),e}();function lr(e,t){var n;return(0,O._)(this,lr),(n=(0,V._)(this,lr,[e,t]))._firestore=e,n}(0,z._)(lr,ln),(0,P._)(lr,[{key:"get",value:function(e){var t=this,n=lt(e,this._firestore),r=new c4(this._firestore);return(0,j._)((0,q._)(lr.prototype),"get",this).call(this,e).then(function(e){return new c1(t._firestore,r,n._key,e._document,new c0(!1,!1),n.converter)})}}]),new WeakMap,(0,P._)(function e(){throw(0,O._)(this,e),Error("instances of this class should not be created")},null,[{key:"onExistenceFilterMismatch",value:function(e){return li.instance.onExistenceFilterMismatch(e)}}]);var li=function(){function e(){(0,O._)(this,e),this.Gu=new Map}return(0,P._)(e,[{key:"tt",value:function(e){this.Gu.forEach(function(t){return t(e)})}},{key:"onExistenceFilterMismatch",value:function(e){var t=Symbol(),n=this.Gu;return n.set(t,e),function(){return n.delete(t)}}}],[{key:"instance",get:function(){return la||function(e){if(iB)throw Error("a TestingHooksSpi instance is already set");iB=e}(la=new e),la}}]),e}(),la=null;!function(e){var t=!(arguments.length>1)||void 0===arguments[1]||arguments[1];t_=te,e4(new eE("firestore",function(e,n){var r=n.instanceIdentifier,i=n.options,a=e.getProvider("app").getImmediate(),o=new u9(new tO(e.getProvider("auth-internal")),new tU(e.getProvider("app-check-internal")),function(e,t){if(!Object.prototype.hasOwnProperty.apply(e.options,["projectId"]))throw new tx(tC.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new n4(e.options.projectId,t)}(a,r),a);return i=Object.assign({useFetchStreams:t},i),o._setSettings(i),o},"PUBLIC").setMultipleInstances(!0)),tr(tm,"4.7.5",e),tr(tm,"4.7.5","esm2017")}(),e.s(["collection",0,u6,"getFirestore",0,ct,"initializeFirestore",0,ce,"onSnapshot",0,c5,"orderBy",0,cz,"persistentLocalCache",0,c8,"persistentMultipleTabManager",0,le,"query",0,cF,"where",0,cB],317875),tr("firebase","11.1.0","app");var lo=e.i(290571);function ls(){return(0,J._)({}
1,"dependent-sdk-initialized-before-auth","Another Firebase SDK was initialized and is trying to use Auth before Auth is initialized. Please be sure to call `initializeAuth` or `getAuth` before starting any other Firebase SDK.")}var lu=new ey("auth","Firebase",ls()),lc=new eP("@firebase/auth");function ll(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];lc.logLevel<=i.ERROR&&lc.error.apply(lc,["Auth (".concat(te,"): ").concat(e)].concat((0,L._)(n)))}function lh(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];throw ly.apply(void 0,[e].concat((0,L._)(n)))}function lf(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return ly.apply(void 0,[e].concat((0,L._)(n)))}function ld(e,t,n){return new ey("auth","Firebase",Object.assign(Object.assign({},ls()),(0,J._)({},t,n))).create(t,{appName:e.name})}function lv(e){return ld(e,"operation-not-supported-in-this-environment","Operations that alter the current user are not supported in conjunction with FirebaseServerApp")}function ly(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];if("string"!=typeof e){var i,a=n[0],o=(0,L._)(n.slice(1));return o[0]&&(o[0].appName=e.name),(i=e._errorFactory).create.apply(i,[a].concat((0,L._)(o)))}return lu.create.apply(lu,[e].concat((0,L._)(n)))}function lp(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];if(!e)throw ly.apply(void 0,[t].concat((0,L._)(r)))}function lm(e){var t="INTERNAL ASSERTION FAILED: "+e;throw ll(t),Error(t)}function lg(){var e;return"u">typeof self&&(null==(e=self.location)?void 0:e.href)||""}function l_(){return"http:"===lk()||"https:"===lk()}function lk(){var e;return"u">typeof self&&(null==(e=self.location)?void 0:e.protocol)||null}var lb=function(){function e(t,n){var r;(0,O._)(this,e),this.shortDelay=t,this.longDelay=n,r="Short delay should be less than long delay!",n>t||lm(r),this.isMobile="u">typeof window&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(eh())||("u"<typeof navigator?"undefined":(0,G._)(navigator))==="object"&&"ReactNative"===navigator.product}return(0,P._)(e,[{key:"get",value:function(){var e;return!("u">typeof navigator&&navigator&&"onLine"in navigator&&"boolean"==typeof navigator.onLine&&(l_()||(void 0===(e=("u"<typeof chrome?"undefined":(0,G._)(chrome))==="object"?chrome.runtime:("u"<typeof browser?"undefined":(0,G._)(browser))==="object"?browser.runtime:void 0)?"undefined":(0,G._)(e))==="object"&&void 0!==e.id||"connection"in navigator))||navigator.onLine?this.isMobile?this.longDelay:this.shortDelay:Math.min(5e3,this.shortDelay)}}]),e}();function lw(e,t){n=e.emulator,r="Emulator should always be set here",n||lm(r);var n,r,i=e.emulator.url;return t?"".concat(i).concat(t.startsWith("/")?t.slice(1):t):i}var lI=function(){function e(){(0,O._)(this,e)}return(0,P._)(e,null,[{key:"initialize",value:function(e,t,n){this.fetchImpl=e,t&&(this.headersImpl=t),n&&(this.responseImpl=n)}},{key:"fetch",value:function(){return this.fetchImpl?this.fetchImpl:"u">typeof self&&"fetch"in self?self.fetch:"u">typeof globalThis&&globalThis.fetch?globalThis.fetch:"u">typeof fetch?fetch:void lm("Could not find fetch implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}},{key:"headers",value:function(){return this.headersImpl?this.headersImpl:"u">typeof self&&"Headers"in self?self.Headers:"u">typeof globalThis&&globalThis.Headers?globalThis.Headers:"u">typeof Headers?Headers:void lm("Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}},{key:"response",value:function(){return this.responseImpl?this.responseImpl:"u">typeof self&&"Response"in self?self.Response:"u">typeof globalThis&&globalThis.Response?globalThis.Response:"u">typeof Response?Response:void lm("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}}]),e}(),lT=(T={},(0,J._)(T,"CREDENTIAL_MISMATCH","custom-token-mismatch"),(0,J._)(T,"MISSING_CUSTOM_TOKEN","internal-error"),(0,J._)(T,"INVALID_IDENTIFIER","invali
1d-email"),(0,J._)(T,"MISSING_CONTINUE_URI","internal-error"),(0,J._)(T,"INVALID_PASSWORD","wrong-password"),(0,J._)(T,"MISSING_PASSWORD","missing-password"),(0,J._)(T,"INVALID_LOGIN_CREDENTIALS","invalid-credential"),(0,J._)(T,"EMAIL_EXISTS","email-already-in-use"),(0,J._)(T,"PASSWORD_LOGIN_DISABLED","operation-not-allowed"),(0,J._)(T,"INVALID_IDP_RESPONSE","invalid-credential"),(0,J._)(T,"INVALID_PENDING_TOKEN","invalid-credential"),(0,J._)(T,"FEDERATED_USER_ID_ALREADY_LINKED","credential-already-in-use"),(0,J._)(T,"MISSING_REQ_TYPE","internal-error"),(0,J._)(T,"EMAIL_NOT_FOUND","user-not-found"),(0,J._)(T,"RESET_PASSWORD_EXCEED_LIMIT","too-many-requests"),(0,J._)(T,"EXPIRED_OOB_CODE","expired-action-code"),(0,J._)(T,"INVALID_OOB_CODE","invalid-action-code"),(0,J._)(T,"MISSING_OOB_CODE","internal-error"),(0,J._)(T,"CREDENTIAL_TOO_OLD_LOGIN_AGAIN","requires-recent-login"),(0,J._)(T,"INVALID_ID_TOKEN","invalid-user-token"),(0,J._)(T,"TOKEN_EXPIRED","user-token-expired"),(0,J._)(T,"USER_NOT_FOUND","user-token-expired"),(0,J._)(T,"TOO_MANY_ATTEMPTS_TRY_LATER","too-many-requests"),(0,J._)(T,"PASSWORD_DOES_NOT_MEET_REQUIREMENTS","password-does-not-meet-requirements"),(0,J._)(T,"INVALID_CODE","invalid-verification-code"),(0,J._)(T,"INVALID_SESSION_INFO","invalid-verification-id"),(0,J._)(T,"INVALID_TEMPORARY_PROOF","invalid-credential"),(0,J._)(T,"MISSING_SESSION_INFO","missing-verification-id"),(0,J._)(T,"SESSION_EXPIRED","code-expired"),(0,J._)(T,"MISSING_ANDROID_PACKAGE_NAME","missing-android-pkg-name"),(0,J._)(T,"UNAUTHORIZED_DOMAIN","unauthorized-continue-uri"),(0,J._)(T,"INVALID_OAUTH_CLIENT_ID","invalid-oauth-client-id"),(0,J._)(T,"ADMIN_ONLY_OPERATION","admin-restricted-operation"),(0,J._)(T,"INVALID_MFA_PENDING_CREDENTIAL","invalid-multi-factor-session"),(0,J._)(T,"MFA_ENROLLMENT_NOT_FOUND","multi-factor-info-not-found"),(0,J._)(T,"MISSING_MFA_ENROLLMENT_ID","missing-multi-factor-info"),(0,J._)(T,"MISSING_MFA_PENDING_CREDENTIAL","missing-multi-factor-session"),(0,J._)(T,"SECOND_FACTOR_EXISTS","second-factor-already-in-use"),(0,J._)(T,"SECOND_FACTOR_LIMIT_EXCEEDED","maximum-second-factor-count-exceeded"),(0,J._)(T,"BLOCKING_FUNCTION_ERROR_RESPONSE","internal-error"),(0,J._)(T,"RECAPTCHA_NOT_ENABLED","recaptcha-not-enabled"),(0,J._)(T,"MISSING_RECAPTCHA_TOKEN","missing-recaptcha-token"),(0,J._)(T,"INVALID_RECAPTCHA_TOKEN","invalid-recaptcha-token"),(0,J._)(T,"INVALID_RECAPTCHA_ACTION","invalid-recaptcha-action"),(0,J._)(T,"MISSING_CLIENT_TYPE","missing-client-type"),(0,J._)(T,"MISSING_RECAPTCHA_VERSION","missing-recaptcha-version"),(0,J._)(T,"INVALID_RECAPTCHA_VERSION","invalid-recaptcha-version"),(0,J._)(T,"INVALID_REQ_TYPE","invalid-req-type"),T),lE=new lb(3e4,6e4);function lS(e,t){return e.tenantId&&!t.tenantId?Object.assign(Object.assign({},t),{tenantId:e.tenantId}):t}function lC(e,t,n,r){return(0,N._)(function(e,t,n,r){var i=arguments;return(0,M._)(this,function(a){return[2,lx(e,i.length>4&&void 0!==i[4]?i[4]:{},function(){return(0,N._)(function(){var i,a,o,s,u;return(0,M._)(this,function(c){switch(c.label){case 0:return i={},a={},r&&("GET"===t?a=r:i={body:JSON.stringify(r)}),o=e_(Object.assign({key:e.config.apiKey},a)).slice(1),[4,e._getAdditionalHeaders()];case 1:return(s=c.sent())["Content-Type"]="application/json",e.languageCode&&(s["X-Firebase-Locale"]=e.languageCode),u=Object.assign({method:t,headers:s},i),"u">typeof navigator&&"Cloudflare-Workers"===navigator.userAgent||(u.referrerPolicy="no-referrer"),[2,lI.fetch()(lD(e,e.config.apiHost,n,o),u)]}})})()})]})}).apply(this,arguments)}function lx(e,t,n){return(0,N._)(function(){var r,i,a,o,s,u,c,l,h,f;return(0,M._)(this,function(d){switch(d.label){case 0:e._canInitEmulator=!1,r=Object.assign(Object.assign({},lT),t),d.label=1;case 1:return d.trys.push([1,4,,5]),i=new lR(e),[4,Promise.race([n(),i.promise])];case 2:return a=d.sent(),i.clearNetworkTimeout(),[4,a.json()];case 3:if("needConfirmation"in(o=d.sent()))throw lN(e,"account-exists-with-different-credential",o);if(a.ok&&!("errorMessage"in o))return[2,o];if(s=a.ok?o.errorMessage:o.error.message,c=(u=(0,D._)(s.split(" : "),2))[0],l=u[1],"FEDERATED_USER_ID_ALREADY_LINKED"===c)throw lN(e,"credential-already-in-use",o);if("EMAIL_EXISTS"===c)throw lN(e,"email-already-in-use",o);if("USER_DISABLED"===c)throw lN(e,"user-disabled",o);if(h=r[c]||c.toLowerCase().replace(/[_\s]+/g,"-"),l)throw ld(e,h,l);return lh(e,h),[3,5];case 4:if(f=d.sent(),(0,K._)(f,ev))throw f;return lh(e,"network-request-failed",{message:String(f)}),[3,5];case 5:return[2]}})})()}function lA(e,t,n,r){return(0,N._)(function(e,t,n,r){var i,a=arguments;return(0,M._)(this,function(o){switch(o.label){case 0:return[4,lC(e,t,n,r,a.length>4&&void 0!==a[4]?a[4]:{})];case 1:return"mfaPendingCredential"in(i=o.sent())&&lh(e,"multi-factor-auth-required",{_serverResponse:i}),[2,i]}})}).apply(this,arguments)}function lD(e,t,n,r){var i="".concat(t).concat(n,"?").concat(r);return e.config.emulator?lw(e.config,i):"".concat(e.config.apiScheme,"://").concat(i)}var lR=function(){function e(t){var n=this;(0,O._)(this,e),this.auth=t,this.timer=null,this.promise=new Promise(function(e,t){n.timer=setTimeout(function(){return t(lf(n.auth,"network-request-failed"))},lE.get())})}return(0,P._)(e,[{key:"clearNetworkTimeout",value:function(){clearTimeout(this.timer)}}]),e}();
1function lN(e,t,n){var r={appName:e.name};n.email&&(r.email=n.email),n.phoneNumber&&(r.phoneNumber=n.phoneNumber);var i=lf(e,t,r);return i.customData._tokenResponse=n,i}function lO(e){return void 0!==e&&void 0!==e.getResponse}function lP(e){return void 0!==e&&void 0!==e.enterprise}var lL=function(){function e(t){if((0,O._)(this,e),this.siteKey="",this.recaptchaEnforcementState=[],void 0===t.recaptchaKey)throw Error("recaptchaKey undefined");this.siteKey=t.recaptchaKey.split("/")[3],this.recaptchaEnforcementState=t.recaptchaEnforcementState}return(0,P._)(e,[{key:"getProviderEnforcementState",value:function(e){if(!this.recaptchaEnforcementState||0===this.recaptchaEnforcementState.length)return null;var t=!0,n=!1,r=void 0;try{for(var i,a=this.recaptchaEnforcementState[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var o=i.value;if(o.provider&&o.provider===e)switch(o.enforcementState){case"ENFORCE":return"ENFORCE";case"AUDIT":return"AUDIT";case"OFF":return"OFF";default:return"ENFORCEMENT_STATE_UNSPECIFIED"}}}catch(e){n=!0,r=e}finally{try{t||null==a.return||a.return()}finally{if(n)throw r}}return null}},{key:"isProviderEnabled",value:function(e){return"ENFORCE"===this.getProviderEnforcementState(e)||"AUDIT"===this.getProviderEnforcementState(e)}},{key:"isAnyProviderEnabled",value:function(){return this.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")||this.isProviderEnabled("PHONE_PROVIDER")}}]),e}();function lM(e,t){return(0,N._)(function(){return(0,M._)(this,function(n){return[2,lC(e,"GET","/v2/recaptchaConfig",lS(e,t))]})})()}function lU(e,t){return(0,N._)(function(){return(0,M._)(this,function(n){return[2,lC(e,"POST","/v1/accounts:lookup",t)]})})()}function lF(e){if(e)try{var t=new Date(Number(e));if(!isNaN(t.getTime()))return t.toUTCString()}catch(e){}}function lV(e){return 1e3*Number(e)}function lB(e){var t=(0,D._)(e.split("."),3),n=t[0],r=t[1],i=t[2];if(void 0===n||void 0===r||void 0===i)return ll("JWT malformed, contained fewer than 3 sections"),null;try{var a=en(r);if(!a)return ll("Failed to decode base64 JWT payload"),null;return JSON.parse(a)}catch(e){return ll("Caught error parsing JWT payload as JSON",null==e?void 0:e.toString()),null}}function lj(e){var t=lB(e);return lp(t,"internal-error"),lp(void 0!==t.exp,"internal-error"),lp(void 0!==t.iat,"internal-error"),Number(t.exp)-Number(t.iat)}function lq(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return(0,N._)(function(){var r;return(0,M._)(this,function(i){switch(i.label){case 0:if(n)return[2,t];i.label=1;case 1:return i.trys.push([1,3,,6]),[4,t];case 2:return[2,i.sent()];case 3:var a;if(r=i.sent(),!((0,K._)(r,ev)&&("auth/user-disabled"===(a=r.code)||"auth/user-token-expired"===a))||e.auth.currentUser!==e)return[3,5];return[4,e.auth.signOut()];case 4:i.sent(),i.label=5;case 5:throw r;case 6:return[2]}})})()}var lz=function(){function e(t){(0,O._)(this,e),this.user=t,this.isRunning=!1,this.timerId=null,this.errorBackoff=3e4}return(0,P._)(e,[{key:"_start",value:function(){this.isRunning||(this.isRunning=!0,this.schedule())}},{key:"_stop",value:function(){this.isRunning&&(this.isRunning=!1,null!==this.timerId&&clearTimeout(this.timerId))}},{key:"getInterval",value:function(e){if(!e)return this.errorBackoff=3e4,Math.max(0,(null!=(t=this.user.stsTokenManager.expirationTime)?t:0)-Date.now()-3e5);var t,n=this.errorBackoff;return this.errorBackoff=Math.min(2*this.errorBackoff,96e4),n}},{key:"schedule",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.isRunning){var n=this.getInterval(t);this.timerId=setTimeout(function(){return(0,N._)(function(){return(0,M._)(this,function(e){switch(e.label){case 0:return[4,this.iteration()];case 1:return e.sent(),[2]}})}).call(e)},n)}}},{key:"iteration",value:function(){return(0,N._)(function(){var e;return(0,M._)(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.user.getIdToken(!0)];case 1:return t.sent(),[3,3];case 2:return(null==(e=t.sent())?void 0:e.code)==="auth/network-request-failed"&&this.schedule(!0),[2];case 3:return this.schedule(),[2]}})}).call(this)}}]),e}(),lK=function(){function e(t,n){(0,O._)(this,e),this.createdAt=t,this.lastLoginAt=n,this._initializeTime()}return(0,P._)(e,[{key:"_initializeTime",value:function(){this.lastSignInTime=lF(this.lastLoginAt),this.creationTime=lF(this.createdAt)}},{key:"_copy",value:function(e){this.createdAt=e.createdAt,this.lastLoginAt=e.lastLoginAt,this._initializeTime()}},{key:"toJSON",value:function(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}]),e}();function lG(e){return(0,N._)(function(){var t,n,r,i,a,o,s,u,c,l;return(0,M._)(this,function(h){switch(h.label){case 0:return n=e.auth,[4,e.getIdToken()];case 1:return r=h.sent(),[4,lq(e,lU(n,{idToken:r}))];case 2:var f,d,v;return lp(null==(i=h.sent())?void 0:i.users.length,n,"internal-error"),a=i.users[0],e._notifyReloadListener(a),o=(null==(t=a.providerUserInfo)?void 0:t.length)?lH(a.providerUserInfo):[],f=e.providerData,d=o,v=f.filter(function(e){return!d.some(function(t){return t.providerId===e.providerId})}),s=(0,L._)(v).concat((0,L._)(d)),u=e.isAnonymous,c=!(e.email&&a.passwordHash)&&!(null==s?void 0:s.length),l=!!u&&c,Object.assign(e,{uid:a.localId,displayName:a.displayName||null,photoURL:a.photoUrl||null,email:a.email||null,emailVerified:a.emailVerified||!1,phoneNumber:a.phoneNumber||null,tenantId:a.tenantId||null,providerData:s,metadata:new lK(a.createdAt,a.lastLoginAt),isAnonymous:l}),[2]}})})()}function lH(e){return e.map(function(e){var t=e.providerId,n=(0,lo.__rest)(e,["providerId"]);
1return{providerId:t,uid:n.rawId||"",displayName:n.displayName||null,email:n.email||null,phoneNumber:n.phoneNumber||null,photoURL:n.photoUrl||null}})}var lW=function(){function e(){(0,O._)(this,e),this.refreshToken=null,this.accessToken=null,this.expirationTime=null}return(0,P._)(e,[{key:"isExpired",get:function(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}},{key:"updateFromServerResponse",value:function(e){lp(e.idToken,"internal-error"),lp(void 0!==e.idToken,"internal-error"),lp(void 0!==e.refreshToken,"internal-error");var t="expiresIn"in e&&void 0!==e.expiresIn?Number(e.expiresIn):lj(e.idToken);this.updateTokensAndExpiration(e.idToken,e.refreshToken,t)}},{key:"updateFromIdToken",value:function(e){lp(0!==e.length,"internal-error");var t=lj(e);this.updateTokensAndExpiration(e,null,t)}},{key:"getToken",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return(0,N._)(function(){return(0,M._)(this,function(n){switch(n.label){case 0:if(!t&&this.accessToken&&!this.isExpired)return[2,this.accessToken];if(lp(this.refreshToken,e,"user-token-expired"),!this.refreshToken)return[3,2];return[4,this.refresh(e,this.refreshToken)];case 1:return n.sent(),[2,this.accessToken];case 2:return[2,null]}})}).call(this)}},{key:"clearRefreshToken",value:function(){this.refreshToken=null}},{key:"refresh",value:function(e,t){return(0,N._)(function(){var n,r,i,a;return(0,M._)(this,function(o){switch(o.label){case 0:return[4,(0,N._)(function(){var n;return(0,M._)(this,function(r){switch(r.label){case 0:return[4,lx(e,{},function(){return(0,N._)(function(){var n,r,i,a,o,s;return(0,M._)(this,function(u){switch(u.label){case 0:return n=e_({grant_type:"refresh_token",refresh_token:t}).slice(1),i=(r=e.config).tokenApiHost,a=r.apiKey,o=lD(e,i,"/v1/token","key=".concat(a)),[4,e._getAdditionalHeaders()];case 1:return(s=u.sent())["Content-Type"]="application/x-www-form-urlencoded",[2,lI.fetch()(o,{method:"POST",headers:s,body:n})]}})})()})];case 1:return[2,{accessToken:(n=r.sent()).access_token,expiresIn:n.expires_in,refreshToken:n.refresh_token}]}})})()];case 1:return r=(n=o.sent()).accessToken,i=n.refreshToken,a=n.expiresIn,this.updateTokensAndExpiration(r,i,Number(a)),[2]}})}).call(this)}},{key:"updateTokensAndExpiration",value:function(e,t,n){this.refreshToken=t||null,this.accessToken=e||null,this.expirationTime=Date.now()+1e3*n}},{key:"toJSON",value:function(){return{refreshToken:this.refreshToken,accessToken:this.accessToken,expirationTime:this.expirationTime}}},{key:"_assign",value:function(e){this.accessToken=e.accessToken,this.refreshToken=e.refreshToken,this.expirationTime=e.expirationTime}},{key:"_clone",value:function(){return Object.assign(new e,this.toJSON())}},{key:"_performRefresh",value:function(){return lm("not implemented")}}],[{key:"fromJSON",value:function(t,n){var r=n.refreshToken,i=n.accessToken,a=n.expirationTime,o=new e;return r&&(lp("string"==typeof r,"internal-error",{appName:t}),o.refreshToken=r),i&&(lp("string"==typeof i,"internal-error",{appName:t}),o.accessToken=i),a&&(lp("number"==typeof a,"internal-error",{appName:t}),o.expirationTime=a),o}}]),e}();function lQ(e,t){lp("string"==typeof e||void 0===e,"internal-error",{appName:t})}var lJ=function(){function e(t){(0,O._)(this,e);var n=t.uid,r=t.auth,i=t.stsTokenManager,a=(0,lo.__rest)(t,["uid","auth","stsTokenManager"]);this.providerId="firebase",this.proactiveRefresh=new lz(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=n,this.auth=r,this.stsTokenManager=i,this.accessToken=i.accessToken,this.displayName=a.displayName||null,this.email=a.email||null,this.emailVerified=a.emailVerified||!1,this.phoneNumber=a.phoneNumber||null,this.photoURL=a.photoURL||null,this.isAnonymous=a.isAnonymous||!1,this.tenantId=a.tenantId||null,this.providerData=a.providerData?(0,L._)(a.providerData):[],this.metadata=new lK(a.createdAt||void 0,a.lastLoginAt||void 0)}return(0,P._)(e,[{key:"getIdToken",value:function(e){return(0,N._)(function(){var t;return(0,M._)(this,function(n){switch(n.label){case 0:return[4,lq(this,this.stsTokenManager.getToken(this.auth,e))];case 1:if(lp(t=n.sent(),this.auth,"internal-error"),this.accessToken===t)return[3,3];return this.accessToken=t,[4,this.auth._persistUserIfCurrent(this)];case 2:n.sent(),this.auth._notifyListenersIfCurrent(this),n.label=3;case 3:return[2,t]}})}).call(this)}},{key:"getIdTokenResult",value:function(e){return function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return(0,N._)(function(){var n,r,i,a,o;return(0,M._)(this,function(s){switch(s.label){case 0:return[4,(n=eT(e)).getIdToken(t)];case 1:return lp((i=lB(r=s.sent()))&&i.exp&&i.auth_time&&i.iat,n.auth,"internal-error"),o=null==(a="object"===(0,G._)(i.firebase)?i.firebase:void 0)?void 0:a.sign_in_provider,[2,{claims:i,token:r,authTime:lF(lV(i.auth_time)),issuedAtTime:lF(lV(i.iat)),expirationTime:lF(lV(i.exp)),signInProvider:o||null,signInSecondFactor:(null==a?void 0:a.sign_in_second_factor)||null}]}})})()}(this,e)}},{key:"reload",value:function(){var e;return e=this,(0,N._)(function(){var t;return(0,M._)(this,function(n){switch(n.label){case 0:return[4,lG(t=eT
1(e))];case 1:return n.sent(),[4,t.auth._persistUserIfCurrent(t)];case 2:return n.sent(),t.auth._notifyListenersIfCurrent(t),[2]}})})()}},{key:"_assign",value:function(e){this!==e&&(lp(this.uid===e.uid,this.auth,"internal-error"),this.displayName=e.displayName,this.photoURL=e.photoURL,this.email=e.email,this.emailVerified=e.emailVerified,this.phoneNumber=e.phoneNumber,this.isAnonymous=e.isAnonymous,this.tenantId=e.tenantId,this.providerData=e.providerData.map(function(e){return Object.assign({},e)}),this.metadata._copy(e.metadata),this.stsTokenManager._assign(e.stsTokenManager))}},{key:"_clone",value:function(t){var n=new e(Object.assign(Object.assign({},this),{auth:t,stsTokenManager:this.stsTokenManager._clone()}));return n.metadata._copy(this.metadata),n}},{key:"_onReload",value:function(e){lp(!this.reloadListener,this.auth,"internal-error"),this.reloadListener=e,this.reloadUserInfo&&(this._notifyReloadListener(this.reloadUserInfo),this.reloadUserInfo=null)}},{key:"_notifyReloadListener",value:function(e){this.reloadListener?this.reloadListener(e):this.reloadUserInfo=e}},{key:"_startProactiveRefresh",value:function(){this.proactiveRefresh._start()}},{key:"_stopProactiveRefresh",value:function(){this.proactiveRefresh._stop()}},{key:"_updateTokensIfNecessary",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return(0,N._)(function(){var n;return(0,M._)(this,function(r){switch(r.label){case 0:if(n=!1,e.idToken&&e.idToken!==this.stsTokenManager.accessToken&&(this.stsTokenManager.updateFromServerResponse(e),n=!0),!t)return[3,2];return[4,lG(this)];case 1:r.sent(),r.label=2;case 2:return[4,this.auth._persistUserIfCurrent(this)];case 3:return r.sent(),n&&this.auth._notifyListenersIfCurrent(this),[2]}})}).call(this)}},{key:"delete",value:function(){return(0,N._)(function(){var e;return(0,M._)(this,function(t){switch(t.label){case 0:if(e6(this.auth.app))return[2,Promise.reject(lv(this.auth))];return[4,this.getIdToken()];case 1:var n,r;return e=t.sent(),[4,lq(this,(n=this.auth,r={idToken:e},(0,N._)(function(){return(0,M._)(this,function(e){return[2,lC(n,"POST","/v1/accounts:delete",r)]})})()))];case 2:return t.sent(),this.stsTokenManager.clearRefreshToken(),[2,this.auth.signOut()]}})}).call(this)}},{key:"toJSON",value:function(){return Object.assign(Object.assign({uid:this.uid,email:this.email||void 0,emailVerified:this.emailVerified,displayName:this.displayName||void 0,isAnonymous:this.isAnonymous,photoURL:this.photoURL||void 0,phoneNumber:this.phoneNumber||void 0,tenantId:this.tenantId||void 0,providerData:this.providerData.map(function(e){return Object.assign({},e)}),stsTokenManager:this.stsTokenManager.toJSON(),_redirectEventId:this._redirectEventId},this.metadata.toJSON()),{apiKey:this.auth.config.apiKey,appName:this.auth.name})}},{key:"refreshToken",get:function(){return this.stsTokenManager.refreshToken||""}}],[{key:"_fromJSON",value:function(t,n){var r,i,a,o,s,u,c,l,h=null!=(r=n.displayName)?r:void 0,f=null!=(i=n.email)?i:void 0,d=null!=(a=n.phoneNumber)?a:void 0,v=null!=(o=n.photoURL)?o:void 0,y=null!=(s=n.tenantId)?s:void 0,p=null!=(u=n._redirectEventId)?u:void 0,m=null!=(c=n.createdAt)?c:void 0,g=null!=(l=n.lastLoginAt)?l:void 0,_=n.uid,k=n.emailVerified,b=n.isAnonymous,w=n.providerData,I=n.stsTokenManager;lp(_&&I,t,"internal-error");var T=lW.fromJSON(this.name,I);lp("string"==typeof _,t,"internal-error"),lQ(h,t.name),lQ(f,t.name),lp("boolean"==typeof k,t,"internal-error"),lp("boolean"==typeof b,t,"internal-error"),lQ(d,t.name),lQ(v,t.name),lQ(y,t.name),lQ(p,t.name),lQ(m,t.name),lQ(g,t.name);var E=new e({uid:_,auth:t,email:f,emailVerified:k,displayName:h,isAnonymous:b,photoURL:v,phoneNumber:d,tenantId:y,stsTokenManager:T,createdAt:m,lastLoginAt:g});return w&&Array.isArray(w)&&(E.providerData=w.map(function(e){return Object.assign({},e)})),p&&(E._redirectEventId=p),E}},{key:"_fromIdTokenResponse",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return(0,N._)(function(){var i,a;return(0,M._)(this,function(o){switch(o.label){case 0:return(i=new lW).updateFromServerResponse(n),[4,lG(a=new e({uid:n.localId,auth:t,stsTokenManager:i,isAnonymous:r}))];case 1:return o.sent(),[2,a]}})})()}},{key:"_fromGetAccountInfoResponse",value:function(t,n,r){return(0,N._)(function(){var i,a,o,s,u;return(0,M._)(this,function(c){return lp(void 0!==(i=n.users[0]).localId,"internal-error"),a=void 0!==i.providerUserInfo?lH(i.providerUserInfo):[],o=!(i.email&&i.passwordHash)&&!(null==a?void 0:a.length),(s=new lW).updateFromIdToken(r),Object.assign(u=new e({uid:i.localId,auth:t,stsTokenManager:s,isAnonymous:o}),{uid:i.localId,displayName:i.displayName||null,photoURL:i.photoUrl||null,email:i.email||null,emailVerified:i.emailVerified||!1,phoneNumber:i.phoneNumber||null,tenantId:i.tenantId||null,providerData:a,metadata:new lK(i.createdAt,i.lastLoginAt),isAnonymous:!(i.email&&i.passwordHash)&&!(null==a?void 0:a.length)}),[2,u]})})()}}]),e}(),lX=new Map;function lY(e){t=(0,K._)(e,Function),n="Expected a class definition",t||lm(n);var t,n,r,i,a=lX.get(e);return a?(r=(0,K._)(a,e),i="Instance stored in cache mismatched with class",r||lm(i)):(a=new e,lX.set(e,a)),a}var l$=function(){function e(){(0,O._)(this,e),this.type="NONE",this.storage={}}return(0,P._)(e,[{key:"_isAvailable",value:function(){return(0,N._)(function(){return(0,M._)(this,function(e){return[2,!0]})})()}},{key:"_set",value:function(e,t){return(0,N._)(function(){return(0,M._)(this,function(n){return this.storage[e]=t,[2]})}).call(this)}},{key:"_get",value:function(e){return(0,N._)(function(){var t;return(0,M._)(this,function(n){return[2,void 0===(t=this.storage[e])?null:t]})}).call(this)}},{key:"_remove",value:function(e){return(0,N._)(function(){return(0,M._)(this,function(t){return delete this.storage[e],[2]})}).call(this)}},{key:"_addListener",value:function(e,t){}},{key:"_removeListener",value:function(e,t){}}]),e}();function lZ(e,t,n){return"firebase:".concat(e,":").concat(t,":").concat(n)}l$.type="NONE";var l0=function(){function e(t,n,r){(0,O._)(this,e),this.persistence=t,this.auth=n,this.userKey=r;var i=this.auth,a=i.config,o=i.name;this.fullUserKey=lZ(this.userKey,a.apiKey,o),this.fullPersistenceKey=lZ("persistence",a.apiKey,o),this.boundEventHandler=n._onStorageEvent.bind(n),this.persistence._addListener(this.fullUserKey,this.boundEventHandler)}return(0,P._)(e,[{key:"setCurrentUser",value:function(e){return this.persistence._set(this.fullUserKey,e.toJSON())}},{key:"getCurrentUser",value:function(){return(0,N._)(function(){var e;return(0,M._)(this,function(t){switch(t.label){case 0:return[4,this.persistence._get(this.fullUserKey)];case 1:return[2,(e=t.sent())?lJ._fromJSON(this.auth,e):null]}})}).call(this)}},{key:"removeCurrentUser",value:function(){return this.persistence._remove(this.fullUserKey)}},{key:"savePersistenceForRedirect",value:function(){return this.persistence._set(this.fullPersistenceKey,this.persistence.type)}},{key:"setPersistence",value:function(e){return(0,N._)(function(){var t;return(0,M._)(this,function(n){switch(n.label){case 0:if(this.persistence===e)return[2];return[4,this.getCurrentUser()];case 1:return t=n.sent(),[4,this.removeCurrentUser()];case 2:if(n.sent(),this.persistence=e,t)return[2,this.setCurrentUser(t)];return[2]}})}).call(this)}},{key:"delete",value:function(){this.persistence._removeListener(this.fullUserKey,this.boundEventHandler)}}],[{key:"create",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"authUser";return(0,N._)(function(){var i,a,o,s,u,c,l,h,f,d,v,y,p,m;return(0,M._)(this,function(g){switch(g.label){case 0:if(!n.length)return[2,new e(lY(l$),t,r)];return[4,Promise.all(n.map(function(e){return(0,N._)(function(){return(0,M._)(this,function(t){switch(t.label){case 0:return[4,e._isAvailable()];case 1:if(t.sent())return[2,e];return[2,void 0]}})})()}))];case 1:a=(i=g.sent().filter(function(e){return e}))[0]||lY(l$),o=lZ(r,t.config.apiKey,t.name),s=null,u=!0,c=!1,l=void 0,g.label=2;case 2:g.trys.push([2,9,10,11]),h=n[Symbol.iterator](),g.label=3;case 3:if(u=(f=h.next()).done)return[3,8];d=f.value,g.label=4;case 4:return g.trys.push([4,6,,7]),[4,d._get(o)];case 5:if(v=g.sent())return y=lJ._fromJSON(t,v),d!==a&&(s=y),a=d,[3,8];return[3,7];case 6:return g.sent(),[3,7];case 7:return u=!0,[3,3];case 8:return[3,11];case 9:return p=g.sent(),c=!0,l=p,[3,11];case 10:try{u||null==h.return||h.return()}finally{if(c)throw l}
1return[7];case 11:if(m=i.filter(function(e){return e._shouldAllowMigration}),!a._shouldAllowMigration||!m.length)return[2,new e(a,t,r)];if(a=m[0],!s)return[3,13];return[4,a._set(o,s.toJSON())];case 12:g.sent(),g.label=13;case 13:return[4,Promise.all(n.map(function(e){return(0,N._)(function(){return(0,M._)(this,function(t){switch(t.label){case 0:if(e===a)return[3,4];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,e._remove(o)];case 2:case 3:return t.sent(),[3,4];case 4:return[2]}})})()}))];case 14:return g.sent(),[2,new e(a,t,r)]}})})()}}]),e}();function l1(e){var t=e.toLowerCase();if(t.includes("opera/")||t.includes("opr/")||t.includes("opios/"))return"Opera";if(l5(t))return"IEMobile";if(t.includes("msie")||t.includes("trident/"))return"IE";if(t.includes("edge/"))return"Edge";if(l2(t))return"Firefox";if(t.includes("silk/"))return"Silk";if(l8(t))return"Blackberry";if(l7(t))return"Webos";if(l3(t))return"Safari";if((t.includes("chrome/")||l4(t))&&!t.includes("edge/"))return"Chrome";if(l6(t))return"Android";var n=e.match(/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/);return(null==n?void 0:n.length)===2?n[1]:"Other"}function l2(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:eh();return/firefox\//i.test(e)}function l3(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:eh(),t=e.toLowerCase();return t.includes("safari/")&&!t.includes("chrome/")&&!t.includes("crios/")&&!t.includes("android")}function l4(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:eh();return/crios\//i.test(e)}function l5(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:eh();return/iemobile/i.test(e)}function l6(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:eh();return/android/i.test(e)}function l8(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:eh();return/blackberry/i.test(e)}function l7(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:eh();return/webos/i.test(e)}function l9(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:eh();return/iphone|ipad|ipod/i.test(e)||/macintosh/i.test(e)&&/mobile/i.test(e)}function he(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:eh();return l9(e)||l6(e)||l7(e)||l8(e)||/windows phone/i.test(e)||l5(e)}function ht(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];switch(e){case"Browser":t=l1(eh());break;case"Worker":t="".concat(l1(eh()),"-").concat(e);break;default:t=e}var r=n.length?n.join(","):"FirebaseCore-web";return"".concat(t,"/","JsCore","/").concat(te,"/").concat(r)}var hn=function(){function e(t){(0,O._)(this,e),this.auth=t,this.queue=[]}return(0,P._)(e,[{key:"pushCallback",value:function(e,t){var n=this,r=function(t){return new Promise(function(n,r){try{var i=e(t);n(i)}catch(e){r(e)}})};r.onAbort=t,this.queue.push(r);var i=this.queue.length-1;return function(){n.queue[i]=function(){return Promise.resolve()}}}},{key:"runMiddleware",value:function(e){return(0,N._)(function(){var t,n,r,i,a,o,s,u,c,l,h,f,d,v,y;return(0,M._)(this,function(p){switch(p.label){case 0:if(this.auth.currentUser===e)return[2];t=[],p.label=1;case 1:p.trys.push([1,10,,11]),n=!0,r=!1,i=void 0,p.label=2;case 2:p.trys.push([2,7,8,9]),a=this.queue[Symbol.iterator](),p.label=3;case 3:if(n=(o=a.next()).done)return[3,6];return[4,(s=o.value)(e)];case 4:p.sent(),s.onAbort&&t.push(s.onAbort),p.label=5;case 5:return n=!0,[3,3];case 6:return[3,9];case 7:return u=p.sent(),r=!0,i=u,[3,9];case 8:try{n||null==a.return||a.return()}finally{if(r)throw i}return[7];case 9:return[3,11];case 10:c=p.sent(),t.reverse(),l=!0,h=!1,f=void 0;try{for(d=t[Symbol.iterator]();!(l=(v=d.next()).done);l=!0){y=v.value;try{y()}catch(e){}}}catch(e){h=!0,f=e}finally{try{l||null==d.return||d.return()}finally{if(h)throw f}}throw this.auth._errorFactory.create("login-blocked",{originalMessage:null==c?void 0:c.message});case 11:return[2]}})}).call(this)}}]),e}(),hr=function(){function e(t){(0,O._)(this,e);var n,r,i,a,o=t.customStrengthOptions;this.customStrengthOptions={},this.customStrengthOptions.minPasswordLength=null!=(n=o.minPasswordLength)?n:6,o.maxPasswordLength&&(this.customStrengthOptions.maxPasswordLength=o.maxPasswordLength),void 0!==o.containsLowercaseCharacter&&(this.customStrengthOptions.containsLowercaseLetter=o.containsLowercaseCharacter),void 0!==o.containsUppercaseCharacter&&(this.customStrengthOptions.containsUppercaseLetter=o.containsUppercaseCharacter),void 0!==o.containsNumericCharacter&&(this.customStrengthOptions.containsNumericCharacter=o.containsNumericCharacter),void 0!==o.containsNonAlphanumericCharacter&&(this.customStrengthOptions.containsNonAlphanumericCharacter=o.containsNonAlphanumericCharacter),this.enforcementState=t.enforcementState,"ENFORCEMENT_STATE_UNSPECIFIED"===this.enforcementState&&(this.enforcementState="OFF"),this.allowedNonAlphanumericCharacters=null!=(i=null==(r=t.allowedNonAlphanumericCharacters)?void 0:r.join(""))?i:"",this.forceUpgradeOnSignin=null!=(a=t.forceUpgradeOnSignin)&&a,this.schemaVersion=t.schemaVersion}return(0,P._)(e,[{key:"validatePassword",value:function(e){var t,n,r,i,a,o,s={isValid:!0,passwordPolicy:this};return this.validatePasswordLengthOptions(e,s),this.validatePasswordCharacterOptions(e,s),s.isValid&&
1(s.isValid=null==(t=s.meetsMinPasswordLength)||t),s.isValid&&(s.isValid=null==(n=s.meetsMaxPasswordLength)||n),s.isValid&&(s.isValid=null==(r=s.containsLowercaseLetter)||r),s.isValid&&(s.isValid=null==(i=s.containsUppercaseLetter)||i),s.isValid&&(s.isValid=null==(a=s.containsNumericCharacter)||a),s.isValid&&(s.isValid=null==(o=s.containsNonAlphanumericCharacter)||o),s}},{key:"validatePasswordLengthOptions",value:function(e,t){var n=this.customStrengthOptions.minPasswordLength,r=this.customStrengthOptions.maxPasswordLength;n&&(t.meetsMinPasswordLength=e.length>=n),r&&(t.meetsMaxPasswordLength=e.length<=r)}},{key:"validatePasswordCharacterOptions",value:function(e,t){this.updatePasswordCharacterOptionsStatuses(t,!1,!1,!1,!1);for(var n,r=0;r<e.length;r++)n=e.charAt(r),this.updatePasswordCharacterOptionsStatuses(t,n>="a"&&n<="z",n>="A"&&n<="Z",n>="0"&&n<="9",this.allowedNonAlphanumericCharacters.includes(n))}},{key:"updatePasswordCharacterOptionsStatuses",value:function(e,t,n,r,i){this.customStrengthOptions.containsLowercaseLetter&&(e.containsLowercaseLetter||(e.containsLowercaseLetter=t)),this.customStrengthOptions.containsUppercaseLetter&&(e.containsUppercaseLetter||(e.containsUppercaseLetter=n)),this.customStrengthOptions.containsNumericCharacter&&(e.containsNumericCharacter||(e.containsNumericCharacter=r)),this.customStrengthOptions.containsNonAlphanumericCharacter&&(e.containsNonAlphanumericCharacter||(e.containsNonAlphanumericCharacter=i))}}]),e}(),hi=function(){function e(t,n,r,i){(0,O._)(this,e),this.app=t,this.heartbeatServiceProvider=n,this.appCheckServiceProvider=r,this.config=i,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new ha(this),this.idTokenSubscription=new ha(this),this.beforeStateQueue=new hn(this),this.redirectUser=null,this.isProactiveRefreshEnabled=!1,this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION=1,this._canInitEmulator=!0,this._isInitialized=!1,this._deleted=!1,this._initializationPromise=null,this._popupRedirectResolver=null,this._errorFactory=lu,this._agentRecaptchaConfig=null,this._tenantRecaptchaConfigs={},this._projectPasswordPolicy=null,this._tenantPasswordPolicies={},this.lastNotifiedUid=void 0,this.languageCode=null,this.tenantId=null,this.settings={appVerificationDisabledForTesting:!1},this.frameworks=[],this.name=t.name,this.clientVersion=i.sdkClientVersion}return(0,P._)(e,[{key:"_initializeWithPersistence",value:function(e,t){var n=this;return t&&(this._popupRedirectResolver=lY(t)),this._initializationPromise=this.queue(function(){return(0,N._)(function(){var n,r,i;return(0,M._)(this,function(a){switch(a.label){case 0:if(this._deleted)return[2];return i=this,[4,l0.create(this,e)];case 1:if(i.persistenceManager=a.sent(),this._deleted)return[2];if(!(null==(n=this._popupRedirectResolver)?void 0:n._shouldInitProactively))return[3,5];a.label=2;case 2:return a.trys.push([2,4,,5]),[4,this._popupRedirectResolver._initialize(this)];case 3:case 4:return a.sent(),[3,5];case 5:return[4,this.initializeCurrentUser(t)];case 6:if(a.sent(),this.lastNotifiedUid=(null==(r=this.currentUser)?void 0:r.uid)||null,this._deleted)return[2];return this._isInitialized=!0,[2]}})}).call(n)}),this._initializationPromise}},{key:"_onStorageEvent",value:function(){return(0,N._)(function(){var e;return(0,M._)(this,function(t){switch(t.label){case 0:if(this._deleted)return[2];return[4,this.assertedPersistence.getCurrentUser()];case 1:if(e=t.sent(),!this.currentUser&&!e)return[2];if(!(this.currentUser&&e&&this.currentUser.uid===e.uid))return[3,3];return this._currentUser._assign(e),[4,this.currentUser.getIdToken()];case 2:case 4:return t.sent(),[2];case 3:return[4,this._updateCurrentUser(e,!0)]}})}).call(this)}},{key:"initializeCurrentUserFromIdToken",value:function(e){return(0,N._)(function(){var t,n;return(0,M._)(this,function(r){switch(r.label){case 0:return r.trys.push([0,4,,6]),[4,lU(this,{idToken:e})];case 1:return t=r.sent(),[4,lJ._fromGetAccountInfoResponse(this,t,e)];case 2:return n=r.sent(),[4,this.directlySetCurrentUser(n)];case 3:case 5:return r.sent(),[3,6];case 4:return console.warn("FirebaseServerApp could not login user with provided authIdToken: ",r.sent()),[4,this.directlySetCurrentUser(null)];case 6:return[2]}})}).call(this)}},{key:"initializeCurrentUser",value:function(e){return(0,N._)(function(){var t,n,r,i,a,o,s,u,c,l;return(0,M._)(this,function(h){switch(h.label){case 0:if(t=this,e6(this.app)){if(r=this.app.settings.authIdToken)return[2,new Promise(function(e){setTimeout(function(){return t.initializeCurrentUserFromIdToken(r).then(e,e)})})];return[2,this.directlySetCurrentUser(null)]}return[4,this.assertedPersistence.getCurrentUser()];case 1:if(a=i=h.sent(),o=!1,!(e&&this.config.authDomain))return[3,4];return[4,this.getOrInitRedirectPersistenceManager()];case 2:return h.sent(),s=null==(n=this.redirectUser)?void 0:n._redirectEventId,u=null==a?void 0:a._redirectEventId,[4,this.tryRedirectSignIn(e)];case 3:c=h.sent(),(!s||s===u)&&(null==c?void 0:c.user)&&(a=c.user,o=!0),h.label=4;case 4:if(!a)return[2,this.directlySetCurrentUser(null)];if(a._redirectEventId)return[3,9];if(!o)return[3,8];h.label=5;case 5:return h.trys.push([5,7,,8]),[4,this.beforeStateQueue.runMiddleware(a)];case 6:return h.sent(),[3,8];case 7:return l=h.sent(),a=i,this._popupRedirectResolver._overrideRedirectResult(this,function(){return Promise.reject(l)}),[3,8];case 8:if(a)return[2,this.reloadAndSetCurrentUserOrClear(a)];return[2,this.directlySetCurrentUser(null)];case 9:return lp(this._popupRedirectResolver,this,"argument-error"),[4,this.getOrInitRedirectPersistenceManager()];case 10:if(h.sent(),this.redirectUser&&this.redirectUser._redirectEventId===a._redirectEventId)return[2,this.directlySetCurrentUser(a)];return[2,this.reloadAndSetCurrentUserOrClear(a)]}})}).call(this)}},{key:"tryRedirectSignIn",value:function(e){return(0,N._)(function(){var t;return(0,M._)(this,function(n){switch(n.label){case 0:t=null,n.label=1;case 1:return n.trys.push([1,3,,5]),[4,this._popupRedirectResolver._completeRedirectFn(this,e,!0)];case 2:return t=n.sent(),[3,5];case 3:return n.sent(),[4,this._setRedirectUser(null)];case 4:return n.sent(),[3,5];case 5:return[2,t]}})}).call(this)}},{key:"reloadAndSetCurrentUserOrClear",value:function(e){return(0,N._)(function(){var t;return(0,M._)(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,lG(e)];case 1:return n.sent(),[3,3];case 2:if((null==(t=n.sent())?void 0:t.code)!=="auth/network-request-failed")return[2,this.directlySetCurrentUser(null)];return[3,3];case 3:return[2,this.directlySetCurrentUser(e)]}})}).call(this)}},{key:"useDeviceLanguage",value:function(){this.languageCode=function(){if("u"<typeof navigator)return null;var e=navigator;return e.languages&&e.languages[0]||e.language||null}()}},{key:"_delete",value:function(){return(0,N._)(function(){return(0,M._)(this,function(e){return this._deleted=!0,[2]})}).call(this)}},{key:"updateCurrentUser",value:function(e){return(0,N._)(function(){var t;return(0,M._)(this,function(n){return e6(this.app)?[2,Promise.reject(lv(this))]:((t=e?eT(e):null)&&lp(t.auth.config.apiKey===this.config.apiKey,this,"invalid-user-token"),[2,this._updateCurrentUser(t&&t._clone(this))])})}).call(this)}},{key:"_updateCurrentUser",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return(0,N._)(function(){var n;return(0,M._)(this,function(r){switch(r.label){case 0:if(n=this,this._deleted)return[2];if(e&&lp(this.tenantId===e.tenantId,this,"tenant-id-mismatch"),t)return[3,2];return[4,this.beforeStateQueue.runMiddleware(e)];case 1:r.sent(),r.label=2;case 2:return[2,this.queue(function(){return(0,N._)(function(){return(0,M._)(this,function(t){switch(t.label){case 0:return[4,this.directlySetCurrentUser(e)];case 1:return t.sent(),this.notifyAuthListeners(),[2]}})}).call(n)})]}})}).call(this)}},{key:"signOut",value:function(){return(0,N._)(function(){return(0,M._)(this,function(e){switch(e.label){case 0:if(e6(this.app))return[2,Promise.reject(lv(this))];return[4,this.beforeStateQueue.runMiddleware(null)];case 1:if(e.sent(),!(this.redirectPersistenceManager||this._popupRedirectResolver))return[3,3];return[4,this._setRedirectUser(null)];case 2:e.sent(),e.label=3;case 3:return[2,this._updateCurrentUser(null,!0)]}})}).call(this)}},{key:"setPersistence",value:function(e){var t=this;return e6(this.app)?Promise.reject(lv(this)):this.queue(function(){return(0,N._)(function(){return(0,M._)(this,function(t){switch(t.label){case 0:return[4,this.assertedPersistence.setPersistence(lY(e))];case 1:return t.sent(),[2]}})}).call(t)})}},{key:"_getRecaptchaConfig",value:function(){return null==this.tenantId?this._agentRecaptchaConfig:this._tenantRecaptchaConfigs[this.tenantId]}},{key:"validatePassword",value:function(e){return(0,N._)(function(){var t;return(0,M._)(this,function(n){switch(n.label){case 0:if(this._getPasswordPolicyInternal())return[3,2];return[4,this._updatePasswordPolicy()];case 1:n.sent(),n.label=2;case 2:if((t=this._getPasswordPolicyInternal()).schemaVersion!==this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION)return[2,Promise.reject(this._errorFactory.create("unsupported-password-policy-schema-version",{}))];return[2,t.validatePassword(e)]}})}).call(this)}},{key:"_getPasswordPolicyInternal",value:function(){return null===this.tenantId?this._projectPasswordPolicy:this._tenantPasswordPolicies[this.tenantId]}},{key:"_updatePasswordPolicy",value:function(){return(0,N._)(function(){var e;return(0,M._)(this,function(t){switch(t.label){case 0:return[4,function(e){return(0,N._)(function(e){var t=arguments;return(0,M._)(this,function(n){return[2,lC(e,"GET","/v2/passwordPolicy",lS(e,t.length>1&&void 0!==t[1]?t[1]:{}))]})}).apply(this,arguments)}(this)];case 1:return e=new hr(t.sent()),null===this.tenantId?this._projectPasswordPolicy=e:this._tenantPasswordPolicies[this.tenantId]=e,[2]}})}).call(this)}},{key:"_getPersistence",value:function(){return this.assertedPersistence.persistence.type}},{key:"_updateErrorMap",value:function(e){this._errorFactory=new ey("auth","Firebase",e())}},{key:"onAuthStateChanged",value:function(e,t,n){return this.registerStateListener(this.authStateSubscription,e,t,n)}},{key:"beforeAuthStateChanged",value:function(e,t){return this.beforeStateQueue.pushCallback(e,t)}},{key:"onIdTokenChanged",value:function(e,t,n){return this.registerStateListener(this.idTokenSubscription,e,t,n)}},{key:"authStateReady",value:function(){var e=this;return new Promise(function(t,n){if(e.currentUser)t();else var r=e.onAuthStateChanged(function(){r(),t()},n)})}},{key:"revokeAccessToken",value:function(e){return(0,N._)(function(){var t;return(0,M._)(this,function(n){switch(n.label){case 0:if(!this.currentUser)return[3,3];return[4,this.currentUser.getIdToken()];case 1:var r;return t={providerId:"apple.com",tokenType:"ACCESS_TOKEN",token:e,idToken:n.sent()},null!=this.tenantId&&(t.tenantId=this.tenantId),[4,(r=this,(0,N._)(function(){return(0,M._)(this,function(e){return[2,lC(r,"POST","/v2/accounts:revokeToken",lS(r,t))]})})())];case 2:n.sent(),n.label=3;case 3:return[2]}})}).call(this)}},{key:"toJSON",value:function(){var e;return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:null==(e=this._currentUser)?void 0:e.toJSON()}}},{key:"_setRedirectUser",value:function(e,t){return(0,N._)(function(){var n;return(0,M._)(this,function(r){switch(r.label){case 0:return[4,this.getOrInitRedirectPersistenceManager(t)];case 1:return n=r.sent(),[2,null===e?n.removeCurrentUser():n.setCurrentUser(e)]}})}).call(this)}},{key:"getOrInitRedirectPersistenceManager",value:function(e){return(0,N._)(function(){var t,n,r;return(0,M._)(this,function(i){switch(i.label){case 0:if(this.redirectPersistenceManager)return[3,3];return lp(t=e&&lY(e)||this._popupRedirectResolver,this,"argument-error"),n=this,[4,l0.create(this,[lY(t._redirectPersistence)],"redirectUser")];case 1:return n.redirectPersistenceManager=i.sent(),r=this,[4,this.redirectPersistenceManager.getCurrentUser()];case 2:r.redirectUser=i.sent(),i.label=3;case 3:return[2,this.redirectPersistenceManager]}})}).call(this)}},{key:"_redirectUserForId",value:function(e){return(0,N._)(function(){var t,n;return(0,M._)(this,function(r){switch(r.label){case 0:if(!this._isInitialized)return[3,2];return[4,this.queue(function(){return(0,N._)(function(){return(0,M._)(this,function(e){return[2]})})()})];case 1:r.sent(),r.label=2;case 2:if((null==(t=this._currentUser)?void 0:t._redirectEventId)===e)return[2,this._currentUser];if((null==(n=this.redirectUser)?void 0:n._redirectEventId)===e)return[2,this.redirectUser];return[2,null]}})}).call(this)}},{key:"_persistUserIfCurrent",value:function(e){return(0,N._)(function(){var t;return(0,M._)(this,function(n){return(t=this,e===this.currentUser)?[2,this.queue(function(){return(0,N._)(function(){return(0,M._)(this,function(t){return[2,this.directlySetCurrentUser(e)]})}).call(t)})]:[2]})}).call(this)}},{key:"_notifyListenersIfCurrent",value:function(e){e===this.currentUser&&this.notifyAuthListeners()}},{key:"_key",value:function(){return"".concat(this.config.authDomain,":").concat(this.config.apiKey,":").concat(this.name)}},{key:"_startProactiveRefresh",value:function(){this.isProactiveRefreshEnabled=!0,this.currentUser&&this._currentUser._startProactiveRefresh()}},{key:"_stopProactiveRefresh",value:function(){this.isProactiveRefreshEnabled=!1,this.currentUser&&this._currentUser._stopProactiveRefresh()}},{key:"_currentUser",get:function(){return this.currentUser}},{key:"notifyAuthListeners",value:function(){if(this._isInitialized){this.idTokenSubscription.next(this.currentUser);var e,t,n=null!=(t=null==(e=this.currentUser)?void 0:e.uid)?t:null;this.lastNotifiedUid!==n&&(this.lastNotifiedUid=n,this.authStateSubscription.next(this.currentUser))}}},{key:"registerStateListener",value:function(e,t,n,r){var i=this;if(this._deleted)return function(){};var a="function"==typeof t?t:t.next.bind(t),o=!1,s=this._isInitialized?Promise.resolve():this._initializationPromise;if(lp(s,this,"internal-error"),s.then(function(){o||a(i.currentUser)}),"function"==typeof t){var u=e.addObserver(t,n,r);return function(){o=!0,u()}}var c=e.addObserver(t);return function(){o=!0,c()}}},{key:"directlySetCurrentUser",value:function(e){return(0,N._)(function(){return(0,M._)(this,function(t){switch(t.label){case 0:if(this.currentUser&&this.currentUser!==e&&this._currentUser._stopProactiveRefresh(),e&&this.isProactiveRefreshEnabled&&e._startProactiveRefresh(),this.currentUser=e,!e)return[3,2];return[4,this.assertedPersistence.setCurrentUser(e)];case 1:return t.sent(),[3,4];case 2:return[4,this.assertedPersistence.removeCurrentUser()];case 3:t.sent(),t.label=4;case 4:return[2]}})}).call(this)}},{key:"queue",value:function(e){return this.operations=this.operations.then(e,e),this.operations}},{key:"assertedPersistence",get:function(){return lp(this.persistenceManager,this,"internal-error"),this.persistenceManager}},{key:"_logFramework",value:function(e){!e||this.frameworks.includes(e)||(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=ht(this.config.clientPlatform,this._getFrameworks()))}},{key:"_getFrameworks",value:function(){return this.frameworks}},{key:"_getAdditionalHeaders",value:function(){return(0,N._)(function(){var e,t,n,r;return(0,M._)(this,function(i){switch(i.label){case 0:return t=(0,J._)({},"X-Client-Version",this.clientVersion),this.app.options.appId&&(t["X-Firebase-gmpid"]=this.app.options.appId),[4,null==(e=this.heartbeatServiceProvider.getImmediate({optional:!0}))?void 0:e.getHeartbeatsHeader()];case 1:return(n=i.sent())&&(t["X-Firebase-Client"]=n),[4,this._getAppCheckToken()];case 2:return(r=i.sent())&&(t["X-Firebase-AppCheck"]=r),[2,t]}})}).call(this)}},{key:"_getAppCheckToken",value:function(){return(0,N._)(function(){var e,t;return(0,M._)(this,function(n){switch(n.label){case 0:return[4,null==(e=this.appCheckServiceProvider.getImmediate({optional:!0}))?void 0:e.getToken()];case 1:return(null==(t=n.sent())?void 0:t.error)&&function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];lc.logLevel<=i.WARN&&lc.warn.apply(lc,["Auth (".concat(te,"): ").concat(e)
1].concat((0,L._)(n)))}("Error while retrieving App Check token: ".concat(t.error)),[2,null==t?void 0:t.token]}})}).call(this)}}]),e}(),ha=function(){function e(t){var n,r=this;(0,O._)(this,e),this.auth=t,this.observer=null,this.addObserver=(n=new ew(function(e){return r.observer=e},void 0)).subscribe.bind(n)}return(0,P._)(e,[{key:"next",get:function(){return lp(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}]),e}(),ho={loadJS:function(){return(0,N._)(function(){return(0,M._)(this,function(e){throw Error("Unable to load external scripts")})})()},recaptchaV2Script:"",recaptchaEnterpriseScript:"",gapiScript:""};function hs(e){return ho.loadJS(e)}function hu(e){return"__".concat(e).concat(Math.floor(1e6*Math.random()))}var hc=function(){function e(t){(0,O._)(this,e),this.auth=t,this.counter=1e12,this._widgets=new Map}return(0,P._)(e,[{key:"render",value:function(e,t){var n=this.counter;return this._widgets.set(n,new hf(e,this.auth.name,t||{})),this.counter++,n}},{key:"reset",value:function(e){var t,n=e||1e12;null==(t=this._widgets.get(n))||t.delete(),this._widgets.delete(n)}},{key:"getResponse",value:function(e){var t;return(null==(t=this._widgets.get(e||1e12))?void 0:t.getResponse())||""}},{key:"execute",value:function(e){return(0,N._)(function(){var t,n;return(0,M._)(this,function(r){return n=e||1e12,null==(t=this._widgets.get(n))||t.execute(),[2,""]})}).call(this)}}]),e}(),hl=function(){function e(){(0,O._)(this,e),this.enterprise=new hh}return(0,P._)(e,[{key:"ready",value:function(e){e()}},{key:"execute",value:function(e,t){return Promise.resolve("token")}},{key:"render",value:function(e,t){return""}}]),e}(),hh=function(){function e(){(0,O._)(this,e)}return(0,P._)(e,[{key:"ready",value:function(e){e()}},{key:"execute",value:function(e,t){return Promise.resolve("token")}},{key:"render",value:function(e,t){return""}}]),e}(),hf=function(){function e(t,n,r){var i=this;(0,O._)(this,e),this.params=r,this.timerId=null,this.deleted=!1,this.responseToken=null,this.clickHandler=function(){i.execute()};var a="string"==typeof t?document.getElementById(t):t;lp(a,"argument-error",{appName:n}),this.container=a,this.isVisible="invisible"!==this.params.size,this.isVisible?this.execute():this.container.addEventListener("click",this.clickHandler)}return(0,P._)(e,[{key:"getResponse",value:function(){return this.checkIfDeleted(),this.responseToken}},{key:"delete",value:function(){this.checkIfDeleted(),this.deleted=!0,this.timerId&&(clearTimeout(this.timerId),this.timerId=null),this.container.removeEventListener("click",this.clickHandler)}},{key:"execute",value:function(){var e=this;this.checkIfDeleted(),this.timerId||(this.timerId=window.setTimeout(function(){e.responseToken=function(){for(var e=[],t="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",n=0;n<50;n++)e.push(t.charAt(Math.floor(Math.random()*t.length)));return e.join("")}();var t=e.params,n=t.callback,r=t["expired-callback"];if(n)try{n(e.responseToken)}catch(e){}e.timerId=window.setTimeout(function(){if(e.timerId=null,e.responseToken=null,r)try{r()}catch(e){}e.isVisible&&e.execute()},6e4)},500))}},{key:"checkIfDeleted",value:function(){if(this.deleted)throw Error("reCAPTCHA mock was already deleted!")}}]),e}(),hd="NO_RECAPTCHA",hv=function(){function e(t){(0,O._)(this,e),this.type="recaptcha-enterprise",this.auth=eT(t)}return(0,P._)(e,[{key:"verify",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"verify",t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return(0,N._)(function(){var n;function r(t,n,r){var i=window.grecaptcha;lP(i)?i.enterprise.ready(function(){i.enterprise.execute(t,{action:e}).then(function(e){n(e)}).catch(function(){n(hd)})}):r(Error("No reCAPTCHA enterprise script loaded."))}return(0,M._)(this,function(e){return(n=this,this.auth.settings.appVerificationDisabledForTesting)?[2,new hl().execute("siteKey",{action:"verify"})]:[2,new Promise(function(e,i){var a;(a=n.auth,(0,N._)(function(){return(0,M._)(this,function(e){if(!t){if(null==a.tenantId&&null!=a._agentRecaptchaConfig)return[2,a._agentRecaptchaConfig.siteKey];if(null!=a.tenantId&&void 0!==a._tenantRecaptchaConfigs[a.tenantId])return[2,a._tenantRecaptchaConfigs[a.tenantId].siteKey]}return[2,new Promise(function(e,t){return(0,N._)(function(){return(0,M._)(this,function(n){return lM(a,{clientType:"CLIENT_TYPE_WEB",ver
1sion:"RECAPTCHA_ENTERPRISE"}).then(function(n){if(void 0===n.recaptchaKey)t(Error("recaptcha Enterprise site key undefined"));else{var r=new lL(n);return null==a.tenantId?a._agentRecaptchaConfig=r:a._tenantRecaptchaConfigs[a.tenantId]=r,e(r.siteKey)}}).catch(function(e){t(e)}),[2]})})()})]})})()).then(function(n){if(!t&&lP(window.grecaptcha))r(n,e,i);else{if("u"<typeof window)return void i(Error("RecaptchaVerifier is only supported in browser"));var a=ho.recaptchaEnterpriseScript;0!==a.length&&(a+=n),hs(a).then(function(){r(n,e,i)}).catch(function(e){i(e)})}}).catch(function(e){i(e)})})]})}).call(this)}}]),e}();function hy(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return(0,N._)(function(){var a,o,s,u,c,l;return(0,M._)(this,function(h){switch(h.label){case 0:if(a=new hv(e),!i)return[3,1];return o=hd,[3,5];case 1:return h.trys.push([1,3,,5]),[4,a.verify(n)];case 2:case 4:return o=h.sent(),[3,5];case 3:return h.sent(),[4,a.verify(n,!0)];case 5:if(s=Object.assign({},t),"mfaSmsEnrollment"===n||"mfaSmsSignIn"===n)return"phoneEnrollmentInfo"in s?(u=s.phoneEnrollmentInfo.phoneNumber,c=s.phoneEnrollmentInfo.recaptchaToken,Object.assign(s,{phoneEnrollmentInfo:{phoneNumber:u,recaptchaToken:c,captchaResponse:o,clientType:"CLIENT_TYPE_WEB",recaptchaVersion:"RECAPTCHA_ENTERPRISE"}})):"phoneSignInInfo"in s&&(l=s.phoneSignInInfo.recaptchaToken,Object.assign(s,{phoneSignInInfo:{recaptchaToken:l,captchaResponse:o,clientType:"CLIENT_TYPE_WEB",recaptchaVersion:"RECAPTCHA_ENTERPRISE"}})),[2,s];return r?Object.assign(s,{captchaResp:o}):Object.assign(s,{captchaResponse:o}),Object.assign(s,{clientType:"CLIENT_TYPE_WEB"}),Object.assign(s,{recaptchaVersion:"RECAPTCHA_ENTERPRISE"}),[2,s]}})})()}function hp(e,t,n,r,i){return(0,N._)(function(){var a,o;return(0,M._)(this,function(s){switch(s.label){case 0:if("EMAIL_PASSWORD_PROVIDER"!==i)return[3,4];if(!(null==(a=e._getRecaptchaConfig())?void 0:a.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")))return[3,2];return[4,hy(e,t,n,"getOobCode"===n)];case 1:case 7:return[2,r(e,s.sent())];case 2:return[2,r(e,t).catch(function(i){return(0,N._)(function(){return(0,M._)(this,function(a){switch(a.label){case 0:if("auth/missing-recaptcha-token"!==i.code)return[3,2];return console.log("".concat(n," is protected by reCAPTCHA Enterprise for this project. Automatically triggering the reCAPTCHA flow and restarting the flow.")),[4,hy(e,t,n,"getOobCode"===n)];case 1:return[2,r(e,a.sent())];case 2:return[2,Promise.reject(i)];case 3:return[2]}})})()})];case 3:case 8:return[3,10];case 4:if("PHONE_PROVIDER"!==i)return[3,9];if(!(null==(o=e._getRecaptchaConfig())?void 0:o.isProviderEnabled("PHONE_PROVIDER")))return[3,6];return[4,hy(e,t,n)];case 5:return[2,r(e,s.sent()).catch(function(i){return(0,N._)(function(){var a;return(0,M._)(this,function(o){switch(o.label){case 0:if((null==(a=e._getRecaptchaConfig())?void 0:a.getProviderEnforcementState("PHONE_PROVIDER"))!=="AUDIT"||"auth/missing-recaptcha-token"!==i.code&&"auth/invalid-app-credential"!==i.code)return[3,2];return console.log("Failed to verify with reCAPTCHA Enterprise. Automatically triggering the reCAPTCHA v2 flow to complete the ".concat(n," flow.")),[4,hy(e,t,n,!1,!0)];case 1:return[2,r(e,o.sent())];case 2:return[2,Promise.reject(i)]}})})()})];case 6:return[4,hy(e,t,n,!1,!0)];case 9:return[2,Promise.reject(i+" provider is not supported.")];case 10:return[2]}})})()}function hm(e){var t=e.indexOf(":");return t<0?"":e.substr(0,t+1)}function hg(e){if(!e)return null;var t=Number(e);return isNaN(t)?null:t}var h_=function(){function e(t,n){(0,O._)(this,e),this.providerId=t,this.signInMethod=n}return(0,P._)(e,[{key:"toJSON",value:function(){return lm("not implemented")}},{key:"_getIdTokenResponse",value:function(e){return lm("not implemented")}},{key:"_linkToIdToken",value:function(e,t){return lm("not implemented")}},{key:"_getReauthenticationResolver",value:function(e){return lm("not implemented")}}]),e}();function hk(e,t){return(0,N._)(function(){return(0,M._)(this,function(n){return[2,lC(e,"POST","/v1/accounts:signUp",t)]})})()}function hb(e,t){return(0,N._)(function(){return(0,M._)(this,function(n){return[2,lA(e,"POST","/v1/accounts:signInWithPassword",lS(e,t))]})})()}var hw=function(e){function t(e,n,r){var i,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;return(0,O._)(this,t),(i=(0,V._)(this,t,["password",r]))._email=e,i._password=n,i._tenantId=a,i}return(0,z._)(t,e),(0,P._)(t,[{key:"toJSON",value:function(){return{email:this._email,password:this._password,signInMethod:this.signInMethod,tenantId:this._tenantId}}},{key:"_getIdTokenResponse",value:function(e){return(0,N._)(function(){return(0,M._)(this,function(t){switch(this.signInMethod){case"password":return[2,hp(e,{returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"},"signInWithPassword",hb,"EMAIL_PASSWORD_PROVIDER")];case"emailLink":var n;return[2,(n={email:this._email,oobCode:this._password},(0,N._)(function(){return(0,M._)(this,function(t){return[2,lA(e,"POST","/v1/accounts:signInWithEmailLink",lS(e,n
1))]})})())];default:lh(e,"internal-error")}return[2]})}).call(this)}},{key:"_linkToIdToken",value:function(e,t){return(0,N._)(function(){return(0,M._)(this,function(n){switch(this.signInMethod){case"password":return[2,hp(e,{idToken:t,returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"},"signUpPassword",hk,"EMAIL_PASSWORD_PROVIDER")];case"emailLink":var r;return[2,(r={idToken:t,email:this._email,oobCode:this._password},(0,N._)(function(){return(0,M._)(this,function(t){return[2,lA(e,"POST","/v1/accounts:signInWithEmailLink",lS(e,r))]})})())];default:lh(e,"internal-error")}return[2]})}).call(this)}},{key:"_getReauthenticationResolver",value:function(e){return this._getIdTokenResponse(e)}}],[{key:"_fromEmailAndPassword",value:function(e,n){return new t(e,n,"password")}},{key:"_fromEmailAndCode",value:function(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return new t(e,n,"emailLink",r)}},{key:"fromJSON",value:function(e){var t="string"==typeof e?JSON.parse(e):e;if((null==t?void 0:t.email)&&(null==t?void 0:t.password)){if("password"===t.signInMethod)return this._fromEmailAndPassword(t.email,t.password);else if("emailLink"===t.signInMethod)return this._fromEmailAndCode(t.email,t.password,t.tenantId)}return null}}]),t}(h_);function hI(e,t){return(0,N._)(function(){return(0,M._)(this,function(n){return[2,lA(e,"POST","/v1/accounts:signInWithIdp",lS(e,t))]})})()}var hT=function(e){function t(){var e;return(0,O._)(this,t),e=(0,V._)(this,t,arguments),e.pendingToken=null,e}return(0,z._)(t,e),(0,P._)(t,[{key:"toJSON",value:function(){return{idToken:this.idToken,accessToken:this.accessToken,secret:this.secret,n
1once:this.nonce,pendingToken:this.pendingToken,providerId:this.providerId,signInMethod:this.signInMethod}}},{key:"_getIdTokenResponse",value:function(e){return hI(e,this.buildRequest())}},{key:"_linkToIdToken",value:function(e,t){var n=this.buildRequest();return n.idToken=t,hI(e,n)}},{key:"_getReauthenticationResolver",value:function(e){var t=this.buildRequest();return t.autoCreate=!1,hI(e,t)}},{key:"buildRequest",value:function(){var e={requestUri:"http://localhost",returnSecureToken:!0};if(this.pendingToken)e.pendingToken=this.pendingToken;else{var t={};this.idToken&&(t.id_token=this.idToken),this.accessToken&&(t.access_token=this.accessToken),this.secret&&(t.oauth_token_secret=this.secret),t.providerId=this.providerId,this.nonce&&!this.pendingToken&&(t.nonce=this.nonce),e.postBody=e_(t)}return e}}],[{key:"_fromParams",value:function(e){var n=new t(e.providerId,e.signInMethod);return e.idToken||e.accessToken?(e.idToken&&(n.idToken=e.idToken),e.accessToken&&(n.accessToken=e.accessToken),e.nonce&&!e.pendingToken&&(n.nonce=e.nonce),e.pendingToken&&(n.pendingToken=e.pendingToken)):e.oauthToken&&e.oauthTokenSecret?(n.accessToken=e.oauthToken,n.secret=e.oauthTokenSecret):lh("argument-error"),n}},{key:"fromJSON",value:function(e){var n="string"==typeof e?JSON.parse(e):e,r=n.providerId,i=n.signInMethod,a=(0,lo.__rest)(n,["providerId","signInMethod"]);if(!r||!i)return null;var o=new t(r,i);return o.idToken=a.idToken||void 0,o.accessToken=a.accessToken||void 0,o.secret=a.secret,o.nonce=a.nonce,o.pendingToken=a.pendingToken||null,o}}]),t}(h_);function hE(e,t){return(0,N._)(function(){return(0,M._)(this,function(n){return[2,lC(e,"POST","/v1/accounts:sendVerificationCode",lS(e,t))]})})()}var hS=(0,J._)({},"USER_NOT_FOUND","user-not-found"),hC=function(e){function t(e){var n;return(0,O._)(this,t),(n=(0,V._)(this,t,["phone","phone"])).params=e,n}return(0,z._)(t,e),(0,P._)(t,[{key:"_getIdTokenResponse",value:function(e){var t;return t=this._makeVerificationRequest(),(0,N._)(function(){return(0,M._)(this,function(n){return[2,lA(e,"POST","/v1/accounts:signInWithPhoneNumber",lS(e,t))]})})()}},{key:"_linkToIdToken",value:function(e,t){var n;return n=Object.assign({idToken:t},this._makeVerificationRequest()),(0,N._)(function(){var t;return(0,M._)(this,function(r){switch(r.label){case 0:return[4,lA(e,"POST","/v1/accounts:signInWithPhoneNumber",lS(e,n))];case 1:if((t=r.sent()).temporaryProof)throw lN(e,"account-exists-with-different-credential",t);return[2,t]}})})()}},{key:"_getReauthenticationResolver",value:function(e){var t;return t=this._makeVerificationRequest(),(0,N._)(function(){return(0,M._)(this,function(n){return[2,lA(e,"POST","/v1/accounts:signInWithPhoneNumber",lS(e,Object.assign(Object.assign({},t),{operation:"REAUTH"})),hS)]})})()}},{key:"_makeVerificationRequest",value:function(){var e=this.params,t=e.temporaryProof,n=e.phoneNumber,r=e.verificationId,i=e.verificationCode;return t&&n?{temporaryProof:t,phoneNumber:n}:{sessionInfo:r,code:i}}},{key:"toJSON",value:function(){var e={providerId:this.providerId};return this.params.phoneNumber&&(e.phoneNumber=this.params.phoneNumber),this.params.temporaryProof&&(e.temporaryProof=this.params.temporaryProof),this.params.verificationCode&&(e.verificationCode=this.params.verificationCode),this.params.verificationId&&(e.verificationId=this.params.verificationId),e}}],[{key:"_fromVerification",value:function(e,n){return new t({verificationId:e,verificationCode:n})}},{key:"_fromTokenResponse",value:function(e,n){return new t({phoneNumber:e,temporaryProof:n})}},{key:"fromJSON",value:function(e){"string"==typeof e&&(e=JSON.parse(e));var n=e.verificationId,r=e.verificationCode,i=e.phoneNumber,a=e.temporaryProof;return r||n||i||a?new t({verificationId:n,verificationCode:r,phoneNumber:i,temporaryProof:a}):null}}]),t}(h_),hx=function(){function e(t){(0,O._)(this,e);var n,r,i,a,o,s,u=ek(eb(t)),c=null!=(n=u.apiKey)?n:null,l=null!=(r=u.oobCode)?r:null,h=function(e){switch(e){case"recoverEmail":return"RECOVER_EMAIL";case"resetPassword":return"PASSWORD_RESET";case"signIn":return"EMAIL_SIGNIN";case"verifyEmail":return"VERIFY_EMAIL";case"verifyAndChangeEmail":return"VERIFY_AND_CHANGE_EMAIL";case"revertSecondFactorAddition":return"REVERT_SECOND_FACTOR_ADDITION";default:return null}}(null!=(i=u.mode)?i:null);lp(c&&l&&h,"argument-error"),this.apiKey=c,this.operation=h,this.code=l,this.continueUrl=null!=(a=u.continueUrl)?a:null,this.languageCode=null!=(o=u.languageCode)?o:null,this.tenantId=null!=(s=u.tenantId)?s:null}return(0,P._)(e,null,[{key:"parseLink",value:function(t){var n,r,i,a=(r=(n=ek(eb(t)).link)?ek(eb(n)).deep_link_id:null,((i=ek(eb(t)).deep_link_id)?ek(eb(i)).link:null)||i||r||n||t);try{return new e(a)}catch(e){return null}}}]),e}(),hA=function(){function e(){(0,O._)(this,e),this.providerId=e.PROVIDER_ID}return(0,P._)(e,null,[{key:"credential",value:function(e,t){return hw._fromEmailAndPassword(e,t)}},{key:"credentialWithLink",value:function(e,t){var n=hx.parseLink(t);return lp(n,"argument-error"),hw._fromEmailAndCode(e,n.code,n.tenantId)}}]),e}();hA.PROVIDER_ID="password",hA.EMAIL_PASSWORD_SIGN_IN_METHOD="password",hA.EMAIL_LINK_SIGN_IN_METHOD="emailLink";var hD=function(){function e(t){(0,O._)(this,e),this.providerId=t,this.defaultLanguageCode=null,this.customParameters={}}return(0,P._)(e,[{key:"setDefaultLanguage",value:function(e){this.defaultLanguageCode=e}},{key:"setCustomParameters",value:function(e){return this.customParameters=e,this}},{key:"getCustomParameters",value:function(){return this.customParameters}}]),e}(),hR=function(e){function t(){var e;return(0,O._)(this,t),e=(0,V._)(this,t,arguments),e.scopes=[],e}return(0,z._)(t,e),(0,P._)(t,[{key:"addScope",value:function(e){return this.scopes.includes(e)||this.scopes.push(e),this}},{key:"getScopes",value:function(){return(0,L._)(this.scopes)}}]),t}
1(hD);function hN(){return(0,O._)(this,hN),(0,V._)(this,hN,arguments)}(0,z._)(hN,hR),(0,P._)(hN,[{key:"credential",value:function(e){return this._credential(Object.assign(Object.assign({},e),{nonce:e.rawNonce}))}},{key:"_credential",value:function(e){return lp(e.idToken||e.accessToken,"argument-error"),hT._fromParams(Object.assign(Object.assign({},e),{providerId:this.providerId,signInMethod:this.providerId}))}}],[{key:"credentialFromJSON",value:function(e){var t="string"==typeof e?JSON.parse(e):e;return lp("providerId"in t&&"signInMethod"in t,"argument-error"),hT._fromParams(t)}},{key:"credentialFromResult",value:function(e){return hN.oauthCredentialFromTaggedObject(e)}},{key:"credentialFromError",value:function(e){return hN.oauthCredentialFromTaggedObject(e.customData||{})}},{key:"oauthCredentialFromTaggedObject",value:function(e){var t=e._tokenResponse;if(!t)return null;var n=t.oauthIdToken,r=t.oauthAccessToken,i=t.oauthTokenSecret,a=t.pendingToken,o=t.nonce,s=t.providerId;if(!r&&!i&&!n&&!a||!s)return null;try{return new hN(s)._credential({idToken:n,accessToken:r,nonce:o,pendingToken:a})}catch(e){return null}}}]);var hO=function(e){function t(){return(0,O._)(this,t),(0,V._)(this,t,["facebook.com"])}return(0,z._)(t,e),(0,P._)(t,null,[{key:"credential",value:function(e){return hT._fromParams({providerId:t.PRO
1VIDER_ID,signInMethod:t.FACEBOOK_SIGN_IN_METHOD,accessToken:e})}},{key:"credentialFromResult",value:function(e){return t.credentialFromTaggedObject(e)}},{key:"credentialFromError",value:function(e){return t.credentialFromTaggedObject(e.customData||{})}},{key:"credentialFromTaggedObject",value:function(e){var n=e._tokenResponse;if(!n||!("oauthAccessToken"in n)||!n.oauthAccessToken)return null;try{return t.credential(n.oauthAccessToken)}catch(e){return null}}}]),t}(hR);hO.FACEBOOK_SIGN_IN_METHOD="facebook.com",hO.PROVIDER_ID="facebook.com";var hP=function(e){function t(){var e;return(0,O._)(this,t),(e=(0,V._)(this,t,["google.com"])).addScope("profile"),e}return(0,z._)(t,e),(0,P._)(t,null,[{key:"credential",value:function(e,n){return hT._fromParams({providerId:t.PROVIDER_ID,signInMethod:t.GOOGLE_SIGN_IN_METHOD,idToken:e,accessToken:n})}},{key:"credentialFromResult",value:function(e){return t.credentialFromTaggedObject(e)}},{key:"credentialFromError",value:function(e){return t.credentialFromTaggedObject(e.customData||{})}},{key:"credentialFromTaggedObject",value:function(e){var n=e._tokenResponse;if(!n)return null;var r=n.oauthIdToken,i=n.oauthAccessToken;if(!r&&!i)return null;try{return t.credential(r,i)}catch(e){return null}}}]),t}(hR);hP.GOOGLE_SIGN_IN_METHOD="google.com",hP.PROVIDER_ID="google.com";var hL=function(e){function t(){return(0,O._)(this,t),(0,V._)(this,t,["github.com"])}return(0,z._)(t,e),(0,P._)(t,null,[{key:"credential",value:function(e){return hT._fromParams({providerId:t.PRO
1VIDER_ID,signInMethod:t.GITHUB_SIGN_IN_METHOD,accessToken:e})}},{key:"credentialFromResult",value:function(e){return t.credentialFromTaggedObject(e)}},{key:"credentialFromError",value:function(e){return t.credentialFromTaggedObject(e.customData||{})}},{key:"credentialFromTaggedObject",value:function(e){var n=e._tokenResponse;if(!n||!("oauthAccessToken"in n)||!n.oauthAccessToken)return null;try{return t.credential(n.oauthAccessToken)}catch(e){return null}}}]),t}(hR);hL.GITHUB_SIGN_IN_METHOD="github.com",hL.PROVIDER_ID="github.com";var hM=function(e){function t(e,n){var r;return(0,O._)(this,t),(r=(0,V._)(this,t,[e,e])).pendingToken=n,r}return(0,z._)(t,e),(0,P._)(t,[{key:"_getIdTokenResponse",value:function(e){return hI(e,this.buildRequest())}},{key:"_linkToIdToken",value:function(e,t){var n=this.buildRequest();return n.idToken=t,hI(e,n)}},{key:"_getReauthenticationResolver",value:function(e){var t=this.buildRequest();return t.autoCreate=!1,hI(e,t)}},{key:"toJSON",value:function(){return{signInMethod:this.signInMethod,providerId:this.providerId,pendingToken:this.pendingToken}}},{key:"buildRequest",value:function(){return{requestUri:"http://localhost",returnSecureToken:!0,pendingToken:this.pendingToken}}}],[{key:"fromJSON",value:function(e){var n="string"==typeof e?JSON.parse(e):e,r=n.providerId,i=n.signInMethod,a=n.pendingToken;return r&&i&&a&&r===i?new t(r,a):null}},{key:"_create",value:function(e,n){return new t(e,n)}}]),t}(h_);function hU(e){return(0,O._)(this,hU),lp(e.startsWith("saml."),"argument-error"),(0,V._)(this,hU,[e])}(0,z._)(hU,hD),(0,P._)(hU,null,[{key:"credentialFromResult",value:function(e){return hU.samlCredentialFromTaggedObject(e)}},{key:"credentialFromError",value:function(e){return hU.samlCredentialFromTaggedObject(e.customData||{})}},{key:"credentialFromJSON",value:function(e){var t=hM.fromJSON(e);return lp(t,"argument-error"),t}},{key:"samlCredentialFromTaggedObject",value:function(e){var t=e._tokenResponse;if(!t)return null;var n=t.pendingToken,r=t.providerId;if(!n||!r)return null;try{return hM._create(r,n)}catch(e){return null}}}]);var hF=function(e){function t(){return(0,O._)(this,t),(0,V._)(this,t,["twitter.com"])}return(0,z._)(t,e),(0,P._)(t,null,[{key:"credential",value:function(e,n){return hT._fromParams({providerId:t.PRO
1VIDER_ID,signInMethod:t.TWITTER_SIGN_IN_METHOD,oauthToken:e,oauthTokenSecret:n})}},{key:"credentialFromResult",value:function(e){return t.credentialFromTaggedObject(e)}},{key:"credentialFromError",value:function(e){return t.credentialFromTaggedObject(e.customData||{})}},{key:"credentialFromTaggedObject",value:function(e){var n=e._tokenResponse;if(!n)return null;var r=n.oauthAccessToken,i=n.oauthTokenSecret;if(!r||!i)return null;try{return t.credential(r,i)}catch(e){return null}}}]),t}(hR);hF.TWITTER_SIGN_IN_METHOD="twitter.com",hF.PROVIDER_ID="twitter.com";var hV=function(){function e(t){(0,O._)(this,e),this.user=t.user,this.providerId=t.providerId,this._tokenResponse=t._tokenResponse,this.operationType=t.operationType}return(0,P._)(e,null,[{key:"_fromIdTokenResponse",value:function(t,n,r){var i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return(0,N._)(function(){return(0,M._)(this,function(a){switch(a.label){case 0:return[4,lJ._fromIdTokenResponse(t,r,i)];case 1:return[2,new e({user:a.sent(),providerId:hB(r),_tokenResponse:r,operationType:n})]}})})()}},{key:"_forOperation",value:function(t,n,r){return(0,N._)(function(){return(0,M._)(this,function(i){switch(i.label){case 0:return[4,t._updateTokensIfNecessary(r,!0)];case 1:return i.sent(),[2,new e({user:t,providerId:hB(r),_tokenResponse:r,operationType:n})]}})})()}}]),e}();function hB(e){return e.providerId?e.providerId:"phoneNumber"in e?"phone":null}var hj=function(e){function t(e,n,r,i){var a,o;return(0,O._)(this,t),(a=(0,V._)(this,t,[n.code,n.message])).operationType=r,a.user=i,Object.setPrototypeOf(a,t.prototype),a.customData={appName:e.name,tenantId:null!=(o=e.tenantId)?o:void 0,_serverResponse:n.customData._serverResponse,operationType:r},a}return(0,z._)(t,e),(0,P._)(t,null,[{key:"_fromErrorAndOperation",value:function(e,n,r,i){return new t(e,n,r,i)}}]),t}(ev);function hq(e,t,n,r){return("reauthenticate"===t?n._getReauthenticationResolver(e):n._getIdTokenResponse(e)).catch(function(n){if("auth/multi-factor-auth-required"===n.code)throw hj._fromErrorAndOperation(e,n,t,r);throw n})}var hz=function(){function e(t,n){(0,O._)(this,e),this.factorId=t,this.uid=n.mfaEnrollmentId,this.enrollmentTime=new Date(n.enrolledAt).toUTCString(),this.displayName=n.displayName}return(0,P._)(e,null,[{key:"_fromServerResponse",value:function(e,t){return"phoneInfo"in t?hK._fromServerResponse(e,t):"totpInfo"in t?hG._fromServerResponse(e,t):lh(e,"internal-error")}}]),e}(),hK=function(e){function t(e){var n;return(0,O._)(this,t),(n=(0,V._)(this,t,["phone",e])).phoneNumber=e.phoneInfo,n}return(0,z._)(t,e),(0,P._)(t,null,[{key:"_fromServerResponse",value:function(e,n){return new t(n)}}]),t}(hz),hG=function(e){function t(e){return(0,O._)(this,t),(0,V._)(this,t,["totp",e])}return(0,z._)(t,e),(0,P._)(t,null,[{key:"_fromServerResponse",value:function(e,n){return new t(n)}}]),t}(hz),hH=function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};(0,O._)(this,e),this.isNewUser=t,this.providerId=n,this.profile=r},hW=function(e){function t(e,n,r,i){var a;return(0,O._)(this,t),(a=(0,V._)(this,t,[e,n,r])).username=i,a}return(0,z._)(t,e),t}(hH);(0,z._)(function e(t,n){return(0,O._)(this,e),(0,V._)(this,e,[t,"facebook.com",n])},hH),(0,z._)(function e(t,n){return(0,O._)(this,e),(0,V._)(this,e,[t,"github.com",n,"string"==typeof(null==n?void 0:n.login)?null==n?void 0:n.login:null])},hW),(0,z._)(function e(t,n){return(0,O._)(this,e),(0,V._)(this,e,[t,"google.com",n])},hH),(0,z._)(function e(t,n,r){return(0,O._)(this,e),(0,V._)(this,e,[t,"twitter.com",n,r])},hW);var hQ=function(){function e(t,n,r){(0,O._)(this,e),this.type=t,this.credential=n,this.user=r}return(0,P._)(e,[{key:"toJSON",value:function(){var e="enroll"===this.type?"idToken":"pendingCredential";return{multiFactorSession:(0,J._)({},e,this.credential)}}}],[{key:"_fromIdtoken",value:function(t,n){return new e("enroll",t,n)}},{key:"_fromMfaPendingCredential",value:function(t){return new e("signin",t)}},{key:"fromJSON",value:function(t){var n,r;if(null==t?void 0:t.multiFactorSession){if(null==(n=t.multiFactorSession)?void 0:n.pendingCredential)return e._fromMfaPendingCredential(t.multiFactorSession.pendingCredential);else if(null==(r=t.multiFactorSession)?void 0:r.idToken)return e._fromIdtoken(t.multiFactorSession.idToken)}return null}}]),e}();function hJ(e,t,n){(0,O._)(this,hJ),this.session=e,this.hints=t,this.signInResolver=n}function hX(e,t){return lC(e,"POST","/v2/accounts/mfaEnrollment:start",lS(e,t))}function hY(e){var t=this;(0,O._)(this,hY),this.user=e,this.enrolledFactors=[],e._onReload(function(n){n.mfaInfo&&(t.enrolledFactors=n.mfaInfo.map(function(t){return hz._fromServerResponse(e.auth,t)}))})}(0,P._)(hJ,[{key:"resolveSignIn",value:function(e){return(0,N._)(function(){var t;return(0,M._)(this,function(n){return t=e,[2,this.signInResolver(t)]})}).call(this)}}],[{key:"_fromError",value:function(e,t){var n=eT(e),r=t.customData._serverResponse,i=(r.mfaInfo||[]).map(function(e){return hz._fromServerResponse(n,e)});lp(r.mfaPendingCredential,n,"internal-error");var a=hQ._fromMfaPendingCredential(r.mfaPendingCredential);return new hJ(a,i,function(e){return(0,N._)(function(){var i,o,s;return(0,M._)(this,function(u){switch(u.label){case 0:return[4,e._process(n,a)];case 1:switch(i=u.sent(),delete r.mfaInfo,delete r.mfaPendingCredential,o=Object.assign(Object.assign({},r),{idToken:i.idToken,refreshToken:i.refreshToken}),t.operationType){case"signIn":return[3,2];case"reauthenticate":return[3,5]}return[3,6];case 2:return[4,hV._fromIdTokenResponse(n,t.operationType,o)];case 3:return s=u.sent(),[4,n._updateCurrentUser(s.user)];case 4:return u.sent(),[2,s];case 5:return lp(t.user,n,"internal-error"),[2,hV._forOperation(t.user,t.operationType,o)];case 6:lh(n,"internal-error"),u.label=7;case 7:return[2]}})})()})}}]),(0,P._)(hY,[{key:"getSession",value:function(){return(0,N._)(function(){var e;return(0,M._)(this,function(t){switch(t.label){case 0:return e=hQ._fromIdtoken,[4,this.user.getIdToken()];case 1:return[2,e.apply(hQ,[t.sent(),this.user])]}})}).call(this)}},{key:"enroll",value:function(e,t){return(0,N._)(function(){var n,r,i;return(0,M._)(this,function(a){switch(a.label){case 0:return n=e,[4,this.get
1Session()];case 1:return r=a.sent(),[4,lq(this.user,n._process(this.user.auth,r,t))];case 2:return i=a.sent(),[4,this.user._updateTokensIfNecessary(i)];case 3:return a.sent(),[2,this.user.reload()]}})}).call(this)}},{key:"unenroll",value:function(e){return(0,N._)(function(){var t,n,r;return(0,M._)(this,function(i){switch(i.label){case 0:return t="string"==typeof e?e:e.uid,[4,this.user.getIdToken()];case 1:n=i.sent(),i.label=2;case 2:var a;return i.trys.push([2,6,,7]),[4,lq(this.user,lC(a=this.user.auth,"POST","/v2/accounts/mfaEnrollment:withdraw",lS(a,{idToken:n,mfaEnrollmentId:t})))];case 3:return r=i.sent(),this.enrolledFactors=this.enrolledFactors.filter(function(e){return e.uid!==t}),[4,this.user._updateTokensIfNecessary(r)];case 4:return i.sent(),[4,this.user.reload()];case 5:return i.sent(),[3,7];case 6:throw i.sent();case 7:return[2]}})}).call(this)}}],[{key:"_fromUser",value:function(e){return new hY(e)}}]),new WeakMap;var h$="__sak",hZ=function(){function e(t,n){(0,O._)(this,e),this.storageRetriever=t,this.type=n}return(0,P._)(e,[{key:"_isAvailable",value:function(){try{if(!this.storage)return Promise.resolve(!1);return this.storage.setItem(h$,"1"),this.storage.removeItem(h$),Promise.resolve(!0)}catch(e){return Promise.resolve(!1)}}},{key:"_set",value:function(e,t){return this.storage.setItem(e,JSON.stringify(t)),Promise.resolve()}},{key:"_get",value:function(e){var t=this.storage.getItem(e);return Promise.resolve(t?JSON.parse(t):null)}},{key:"_remove",value:function(e){return this.storage.removeItem(e),Promise.resolve()}},{key:"storage",get:function(){return this.storageRetriever()}}]),e}(),h0=function(e){function t(){var e;return(0,O._)(this,t),(e=(0,V._)(this,t,[function(){return window.localStorage},"LOCAL"])).boundEventHandler=function(t,n){return e.onStorageEvent(t,n)},e.listeners={},e.localCache={},e.pollTimer=null,e.fallbackToPolling=he(),e._shouldAllowMigration=!0,e}return(0,z._)(t,e),(0,P._)(t,[{key:"forAllChangedKeys",value:function(e){var t=!0,n=!1,r=void 0;try{for(var i,a=Object.keys(this.listeners)[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var o=i.value,s=this.storage.getItem(o),u=this.localCache[o];s!==u&&e(o,u,s)}}catch(e){n=!0,r=e}finally{try{t||null==a.return||a.return()}finally{if(n)throw r}}}},{key:"onStorageEvent",value:function(e){var t,n=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!e.key)return void this.forAllChangedKeys(function(e,t,r){n.notifyListeners(e,r)});var i=e.key;r?this.detachListener():this.stopPolling();var a=function(){var e=n.storage.getItem(i);(r||n.localCache[i]!==e)&&n.notifyListeners(i,e)},o=this.storage.getItem(i);((t=eh()).indexOf("MSIE ")>=0||t.indexOf("Trident/")>=0)&&10===document.documentMode&&o!==e.newValue&&e.newValue!==e.oldValue?setTimeout(a,10):a()}},{key:"notifyListeners",value:function(e,t){this.localCache[e]=t;var n=this.listeners[e];if(n){var r=!0,i=!1,a=void 0;try{for(var o,s=Array.from(n)[Symbol.iterator]();!(r=(o=s.next()).done);r=!0)(0,o.value)(t?JSON.parse(t):t)}catch(e){i=!0,a=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw a}}}}},{key:"startPolling",value:function(){var e=this;this.stopPolling(),this.pollTimer=setInterval(function(){e.forAllChangedKeys(function(t,n,r){e.onStorageEvent(new StorageEvent("storage",{key:t,oldValue:n,newValue:r}),!0)})},1e3)}},{key:"stopPolling",value:function(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}},{key:"attachListener",value:function(){window.addEventListener("storage",this.boundEventHandler)}},{key:"detachListener",value:function(){window.removeEventListener("storage",this.boundEventHandler)}},{key:"_addListener",value:function(e,t){0===Object.keys(this.listeners).length&&(this.fallbackToPolling?this.startPolling():this.attachListener()),this.listeners[e]||(this.listeners[e]=new Set,this.localCache[e]=this.storage.getItem(e)),this.listeners[e].add(t)}},{key:"_removeListener",value:function(e,t){this.listeners[e]&&(this.listeners[e].delete(t),0===this.listeners[e].size&&delete this.listeners[e]),0===Object.keys(this.listeners).length&&(this.detachListener(),this.stopPolling())}},{key:"_set",value:function(e,n){var r=this,i=this;return(0,N._)(function(){return(0,M._)(this,function(a){switch(a.label){case 0:return[4,(0,j._)((0,q._)(t.prototype),"_set",r).call(i,e,
1n)];case 1:return a.sent(),this.localCache[e]=JSON.stringify(n),[2]}})}).call(this)}},{key:"_get",value:function(e){var n=this,r=this;return(0,N._)(function(){var i;return(0,M._)(this,function(a){switch(a.label){case 0:return[4,(0,j._)((0,q._)(t.prototype),"_get",n).call(r,e)];case 1:return i=a.sent(),this.localCache[e]=JSON.stringify(i),[2,i]}})}).call(this)}},{key:"_remove",value:function(e){var n=this,r=this;return(0,N._)(function(){return(0,M._)(this,function(i){switch(i.label){case 0:return[4,(0,j._)((0,q._)(t.prototype),"_remove",n).call(r,e)];case 1:return i.sent(),delete this.localCache[e],[2]}})}).call(this)}}]),t}(hZ);h0.type="LOCAL";var h1=function(e){function t(){return(0,O._)(this,t),(0,V._)(this,t,[function(){return window.sessionStorage},"SESSION"])}return(0,z._)(t,e),(0,P._)(t,[{key:"_addListener",value:function(e,t){}},{key:"_removeListener",value:function(e,t){}}]),t}(hZ);h1.type="SESSION";var h2=function(){function e(t){(0,O._)(this,e),this.eventTarget=t,this.handlersMap={},this.boundEventHandler=this.handleEvent.bind(this)}return(0,P._)(e,[{key:"isListeningto",value:function(e){return this.eventTarget===e}},{key:"handleEvent",value:function(e){return(0,N._)(function(){var t,n,r,i,a,o,s;return(0,M._)(this,function(u){switch(u.label){case 0:if(r=(n=(t=e).data).eventId,i=n.eventType,a=n.data,!(null==(o=this.handlersMap[i])?void 0:o.size))return[2];return t.ports[0].postMessage({status:"ack",eventId:r,eventType:i}),[4,Promise.all(Array.from(o).map(function(e){return(0,N._)(function(){return(0,M._)(this,function(n){return[2,e(t.origin,a)]})})()}).map(function(e){return(0,N._)(function(){return(0,M._)(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,e];case 1:return[2,{fulfilled:!0,value:t.sent()}];case 2:return[2,{fulfilled:!1,reason:t.sent()}];case 3:return[2]}})})()}))];case 1:return s=u.sent(),t.ports[0].postMessage({status:"done",eventId:r,eventType:i,response:s}),[2]}})}).call(this)}},{key:"_subscribe",value:function(e,t){0===Object.keys(this.handlersMap).length&&this.eventTarget.addEventListener("message",this.boundEventHandler),this.handlersMap[e]||(this.handlersMap[e]=new Set),this.handlersMap[e].add(t)}},{key:"_unsubscribe",value:function(e,t){this.handlersMap[e]&&t&&this.handlersMap[e].delete(t),t&&0!==this.handlersMap[e].size||delete this.handlersMap[e],0===Object.keys(this.handlersMap).length&&this.eventTarget.removeEventListener("message",this.boundEventHandler)}}],[{key:"_getInstance",value:function(t){var n=this.receivers.find(function(e){return e.isListeningto(t)});if(n)return n;var r=new e(t);return this.receivers.push(r),r}}]),e}();function h3(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,n="",r=0;r<t;r++)n+=Math.floor(10*Math.random());return e+n}h2.receivers=[];var h4=function(){function e(t){(0,O._)(this,e),this.target=t,this.handlers=new Set}return(0,P._)(e,[{key:"removeMessageHandler",value:function(e){e.messageChannel&&(e.messageChannel.port1.removeEventListener("message",e.onMessage),e.messageChannel.port1.close()),this.handlers.delete(e)}},{key:"_send",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:50;return(0,N._)(function(){var r,i,a,o;return(0,M._)(this,function(s){if(r=this,!(i="u">typeof MessageChannel?new MessageChannel:null))throw Error("connection_unavailable");return[2,new Promise(function(s,u){var c=h3("",20);i.port1.start();var l=setTimeout(function(){u(Error("unsupported_event"))},n);o={messageChannel:i,onMessage:function(e){if(e.data.eventId===c)switch(e.data.status){case"ack":clearTimeout(l),a=setTimeout(function(){u(Error("timeout"))},3e3);break;case"done":clearTimeout(a),s(e.data.response);break;default:clearTimeout(l),clearTimeout(a),u(Error("invalid_response"))}}},r.handlers.add(o),i.port1.addEventListener("message",o.onMessage),r.target.postMessage({eventType:e,eventId:c,data:t},[i.port2])}).finally(function(){o&&r.removeMessageHandler(o)})]})}).call(this)}}]),e}();function h5(){return window}function h6(){return void 0!==h5().WorkerGlobalScope&&"function"==typeof h5().importScripts}var h8="firebaseLocalStorageDb",h7="firebaseLocalStorage",h9="fbase_key",fe=function(){function e(t){(0,O._)(this,e),this.request=t}return(0,P._)(e,[{key:"toPromise",value:function(){var e=this;return new Promise(function(t,n){e.request.addEventListener("success",function(){t(e.request.result)}),e.request.addEventListener("error",function(){n(e.request.error)})})}}]),e}();function ft(e,t){return e.transaction([h7],t?"readwrite":"readonly").objectStore(h7)}function fn(){var e=indexedDB.open(h8,1);return new Promise(function(t,n){e.addEventListener("error",function(){n(e.error)}),e.addEventListener("upgradeneeded",function(){var t=e.result;try{t.createObjectStore(h7,{keyPath:h9})}catch(e){n(e)}}),e.addEventListener("success",function(){return(0,N._)(function(){var n;return(0,M._)(this,function(r){switch(r.label){case 0:if((n=e.result).objectStoreNames.contains(h7))return[3,3];return n.close(),[4,new fe(indexedDB.deleteDatabase(h8)).toPromise()];case 1:return r.sent(),[4,fn()];case 2:return t.apply(void 0,[r.sent()]),[3,4];case 3:t(n),r.label=4;case 4:return[2]}})})()})})}function fr(e,t,n){return(0,N._)(function(){var r;return(0,M._)(this,function(i){return[2,new fe(ft(e,!0).put((r={},(0,J._)(r,h9,t),(0,J._)(r,"value",n),r))).toPromise()]})})()}function fi(e,t){return new fe(ft(e,!0).delete(t)).toPromise()}var fa=function(){function e(){(0,O._)(this,e),this.type="LOCAL",this._shouldAllowMigration=!0,this.listeners={},this.localCache={},this.pollTimer=null,this.pendingWrites=0,this.receiver=null,this.sender=null,this.serviceWorkerReceiverAvailable=!1,this.activeServiceWorker=null,this._workerInitializationPromise=this.initializeServiceWorkerMessaging().then(function(){},function(){})}return(0,P._)(e,[{key:"_openDb",value:function(){return(0,N._)(function(){var e;return(0,M._)(this,function(t){switch(t.label){case 0:if(this.db)return[2,this.db];return e=this,[4,fn()];case 1:return e.db=t.sent(),[2,this.db]}})}).call(this)}},{key:"_withRetries",value:function(e){return(0,N._)(function(){var t,n;return(0,M._)(this,function(r){switch(r.label){case 0:t=0,r.label=1;case 1:r.label=2;case 2:return r.trys.push([2,5,,6]),[4,this._openDb()];case 3:return[4,e(r.sent())];case 4:return[2,r.sent()];case 5:if(n=r.sent(),t++>3)throw n;return this.db&&(this.db.close(),this.db=void 0),[3,6];case 6:return[3,1];case 7:return[2]}})}).call(this)}},{key:"initializeServiceWorkerMessaging",value:function(){return(0,N._)(function(){return(0,M._)(this,function(e){return[2,h6()?this.initializeReceiver():this.initializeSender()]})}).call(this)}},{key:"initializeReceiver",value:function(){return(0,N._)(function(){var e;return(0,M._)(this,function(t){return e=this,this.receiver=h2._getInstance(h6()?self:null),this.receiver._subscribe("keyChanged",function(t,n){return(0,N._)(function(){return(0,M._)(this,function(e){switch(e.label){case 0:return[4,this._poll()];case 1:return[2,{keyProcessed:e.sent().includes(n.key)}]}})}).call(e)}),this.receiver._subscribe("ping",function(e,t){return(0,N._)(function(){return(0,M._)(this,function(e){return[2,["keyChanged"]]})})()}),[2]})}).call(this)}},{key:"initializeSender",value:function(){return(0,N._)(function(){var e,t,n,r;return(0,M._)(this,function(i){switch(i.label){case 0:return n=this,[4,(0,N._)(function(){return(0,M._)(this,function(e){switch(e.label){case 0:if(!(null==navigator?void 0:navigator.serviceWorker))return[2,null];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,navigator.serviceWorker.ready];case 2:return[2,e.sent().active];case 3:return e.sent(),[2,null];case 4:return[2]}})})()];case 1:if(n.activeServiceWorker=i.sent(),!this.activeServiceWorker)return[2];return this.sender=new h4(this.activeServiceWorker),[4,this.sender._send("ping",{},800)];case 2:if(!(r=i.sent()))return[2];return(null==(e=r[0])?void 0:e.fulfilled)&&(null==(t=r[0])?void 0:t.value.includes("keyChanged"))&&(this.serviceWorkerReceiverAvailable=!0),[2]}})}).call(this)}},{key:"notifyServiceWorker",value:function(e){return(0,N._)(function(){return(0,M._)(this,function(t){switch(t.label){case 0:var n;if(!this.sender||!this.activeServiceWorker||((null==(n=null==navigator?void 0:navigator.serviceWorker)?void 0:n.controller)||null)!==this.activeServiceWorker)return[2];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.sender._send("keyChanged",{key:e},this.serviceWorkerReceiverAvailable?800:50)];case 2:case 3:return t.sent(),[3,4];case 4:return[2]}})}).call(this)}},{key:"_isAvailable",value:function(){return(0,N._)(function(){var e;return(0,M._)(this,function(t){switch(t.label){case 0:if(t.trys.push([0,4,,5]),!indexedDB)return[2,!1];return[4,fn()];case 1:return[4,fr(e=t.sent(),h$,"1")];case 2:return t.sent(),[4,fi(e,h$)];case 3:return t.sent(),[2,!0];case 4:return t.sent(),[3,5];case 5:return[2,!1]}})})()}},{key:"_withPendingWrite",value:function(e){return(0,N._)(function(){return(0,M._)(this,function(t){switch(t.label){case 0:this.pendingWrites++,t.label=1;case 1:return t.trys.push([1,,3,4]),[4,e()];case 2:return t.sent(),[3,4];case 3:return this.pendingWrites--,[7];case 4:return[2]}})}).call(this)}},{key:"_set",value:function(e,t){return(0,N._)(function(){var n;return(0,M._)(this,function(r){return n=this,[2,this._withPendingWrite(function(){return(0,N._)(function(){return(0,M._)(this,function(n){switch(n.label){case 0:return[4,this._withRetries(function(n){return fr(n,e,t)})];case 1:return n.sent(),this.localCache[e]=t,[2,this.notifyServiceWorker(e)]}})}).call(n)})]})}).call(this)}},{key:"_get",value:function(e){return(0,N._)(function(){var t;return(0,M._)(this,function(n){switch(n.label){case 0:return[4,this._withRetries(function(t){return(0,N._)(function(){var n;return(0,M._)(this,function(r){switch(r.label){case 0:return[4,new fe(ft(t,!1).get(e)).toPromise()];case 1:return[2,void 0===(n=r.sent())?null:n.value]}})})()})];case 1:return t=n.sent(),this.localCache[e]=t,[2,t]}})}).call(this)}},{key:"_remove",value:function(e){return(0,N._)(function(){var t;return(0,M._)(this,function(n){return t=this,[2,this._withPendingWrite(function(){return(0,N._)(function(){return(0,M._)(this,function(t){switch(t.label){case 0:return[4,this._withRetries(function(t){return fi(t,e)})];case 1:return t.sent(),delete this.localCache[e],[2,this.notifyServiceWorker(e)]}})}).call(t)})]})}).call(this)}},{key:"_poll",value:function(){return(0,N._)(function(){var e,t,n,r,i,a,o,s,u,c,l,h,f,d,v,y,p;return(0,M._)(this,function(m){switch(m.label){case 0:return[4,this._withRetries(function(e){return new fe(ft(e,!1).getAll()).toPromise()})];case 1:if(!(e=m.sent())||0!==this.pendingWrites)return[2,[]];if(t=[],n=new Set,0!==e.length){r=!0,i=!1,a=void 0;try{for(o=e[Symbol.iterator]();!(r=(s=o.next()).done);r=!0)c=(u=s.value).fbase_key,l=u.value,n.add(c),JSON.stringify(this.localCache[c])!==JSON.stringify(l)&&(this.notifyListeners(c,l),t.push(c))}catch(e){i=!0,a=e}finally{try{r||null==o.return||o.return()}finally{if(i)throw a}}}h=!0,f=!1,d=void 0;try{for(v=Object.keys(this.localCache)[Symbol.iterator]();!(h=(y=v.next()).done);h=!0)p=y.value,this.localCache[p]&&!n.has(p)&&(this.notifyListeners(p,null),t.push(p))}catch(e){f=!0,d=e}finally{try{h||null==v.return||v.return()}finally{if(f)throw d}}return[2,t]}})}).call(this)}},{key:"notifyListeners",value:function(e,t){this.localCache[e]=t;var n=this.listeners[e];if(n){var r=!0,i=!1,a=void 0;try{for(var o,s=Array.from(n)[Symbol.iterator]();!(r=(o=s.next()).done);r=!0)(0,o.value)(t)}catch(e){i=!0,a=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw a}}}}},{key:"startPolling",value:function(){var e=this;this.stopPolling(),this.pollTimer=setInterval(function(){return(0,N._)(function(){return(0,M._)(this,function(e){return[2,this._poll()]})}).call(e)},800)}},{key:"stopPolling",value:function(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}},{key:"_addListener",value:function(e,t){0===Object.keys(this.listeners).length&&this.startPolling(),this.listeners[e]||(this.listeners[e]=new Set,this._get(e)),this.listeners[e].add(t)}},{key:"_removeListener",value:function(e,t){this.listeners[e]&&(this.listeners[e].delete(t),0===this.listeners[e].size&&delete this.listeners[e]),0===Object.keys(this.listeners).length&&this.stopPolling()}}]),e}();function fo(e,t){return lC(e,"POST","/v2/accounts/mfaSignIn:start",lS(e,t))}fa.type="LOCAL";
1var fs=hu("rcb"),fu=new lb(3e4,6e4),fc=function(){function e(){var t;(0,O._)(this,e),this.hostLanguage="",this.counter=0,this.librarySeparatelyLoaded=!!(null==(t=h5().grecaptcha)?void 0:t.render)}return(0,P._)(e,[{key:"load",value:function(e){var t,n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return(lp((t=r).length<=6&&/^\s*[a-zA-Z0-9\-]*\s*$/.test(t),e,"argument-error"),this.shouldResolveImmediately(r)&&lO(h5().grecaptcha))?Promise.resolve(h5().grecaptcha):new Promise(function(t,i){var a=h5().setTimeout(function(){i(lf(e,"network-request-failed"))},fu.get());h5()[fs]=function(){h5().clearTimeout(a),delete h5()[fs];var o=h5().grecaptcha;if(!o||!lO(o))return void i(lf(e,"internal-error"));var s=o.render;o.render=function(e,t){var r=s(e,t);return n.counter++,r},n.hostLanguage=r,t(o)},hs("".concat(ho.recaptchaV2Script,"?").concat(e_({onload:fs,render:"explicit",hl:r}))).catch(function(){clearTimeout(a),i(lf(e,"internal-error"))})})}},{key:"clearedOneInstance",value:function(){this.counter--}},{key:"shouldResolveImmediately",value:function(e){var t;return!!(null==(t=h5().grecaptcha)?void 0:t.render)&&(e===this.hostLanguage||this.counter>0||this.librarySeparatelyLoaded)}}]),e}(),fl=function(){function e(){(0,O._)(this,e)}return(0,P._)(e,[{key:"load",value:function(e){return(0,N._)(function(){return(0,M._)(this,function(t){return[2,new hc(e)]})})()}},{key:"clearedOneInstance",value:function(){}}]),e}(),fh="recaptcha",ff={theme:"light",type:"image"};function fd(e,t,n){return(0,N._)(function(){var r,i,a,o,s,u,c,l,h;return(0,M._)(this,function(f){switch(f.label){case 0:return lp(n.type===fh,e,"argument-error"),[4,n.verify()];case 1:if(lp("string"==typeof(r=f.sent()),e,"argument-error"),"phoneEnrollmentInfo"in(i=Object.assign({},t)))return a=i.phoneEnrollmentInfo.phoneNumber,o=i.phoneEnrollmentInfo.captchaResponse,s=i.phoneEnrollmentInfo.clientType,u=i.phoneEnrollmentInfo.recaptchaVersion,Object.assign(i,{phoneEnrollmentInfo:{phoneNumber:a,recaptchaToken:r,captchaResponse:o,clientType:s,recaptchaVersion:u}}),[2,i];if("phoneSignInInfo"in i)return c=i.phoneSignInInfo.captchaResponse,l=i.phoneSignInInfo.clientType,h=i.phoneSignInInfo.recaptchaVersion,Object.assign(i,{phoneSignInInfo:{recaptchaToken:r,captchaResponse:c,clientType:l,recaptchaVersion:h}}),[2,i];return Object.assign(i,{recaptchaToken:r}),[2,i]}})})()}(0,P._)(function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Object.assign({},ff);(0,O._)(this,e),this.parameters=r,this.type=fh,this.destroyed=!1,this.widgetId=null,this.tokenChangeListeners=new Set,this.renderPromise=null,this.recaptcha=null,this.auth=eT(t),this.isInvisible="invisible"===this.parameters.size,lp("u">typeof document,this.auth,"operation-not-supported-in-this-environment");var i="string"==typeof n?document.getElementById(n):n;lp(i,this.auth,"argument-error"),this.container=i,this.parameters.callback=this.makeTokenCallback(this.parameters.callback),this._recaptchaLoader=this.auth.settings.appVerificationDisabledForTesting?new fl:new fc,this.validateStartingState()},[{key:"verify",value:function(){return(0,N._)(function(){var e,t,n,r;return(0,M._)(this,function(i){switch(i.label){case 0:return e=this,this.assertNotDestroyed(),[4,this.render()];case 1:if(t=i.sent(),r=(n=this.getAssertedRecaptcha()).getResponse(t))return[2,r];return[2,new Promise(function(r){var i=function(t){t&&(e.tokenChangeListeners.delete(i),r(t))};e.tokenChangeListeners.add(i),e.isInvisible&&n.execute(t)})]}})}).call(this)}},{key:"render",value:function(){var e=this;try{this.assertNotDestroyed()}catch(e){return Promise.reject(e)}return this.renderPromise||(this.renderPromise=this.makeRenderPromise().catch(function(t){throw e.renderPromise=null,t})),this.renderPromise}},{key:"_reset",value:function(){this.assertNotDestroyed(),null!==this.widgetId&&this.getAssertedRecaptcha().reset(this.widgetId)}},{key:"clear",value:function(){var e=this;this.assertNotDestroyed(),this.destroyed=!0,this._recaptchaLoader.clearedOneInstance(),this.isInvisible||this.container.childNodes.forEach(function(t){e.container.removeChild(t)})}},{key:"validateStartingState",value:function(){lp(!this.parameters.sitekey,this.auth,"argument-error"),lp(this.isInvisible||!this.container.hasChildNodes(),this.auth,"argument-error"),lp("u">typeof document,this.auth,"operation-not-supported-in-this-environment")}},{key:"makeTokenCallback",value:function(e){var t=this;
1return function(n){if(t.tokenChangeListeners.forEach(function(e){return e(n)}),"function"==typeof e)e(n);else if("string"==typeof e){var r=h5()[e];"function"==typeof r&&r(n)}}}},{key:"assertNotDestroyed",value:function(){lp(!this.destroyed,this.auth,"internal-error")}},{key:"makeRenderPromise",value:function(){return(0,N._)(function(){var e,t;return(0,M._)(this,function(n){switch(n.label){case 0:return[4,this.init()];case 1:return n.sent(),this.widgetId||(e=this.container,this.isInvisible||(t=document.createElement("div"),e.appendChild(t),e=t),this.widgetId=this.getAssertedRecaptcha().render(e,this.parameters)),[2,this.widgetId]}})}).call(this)}},{key:"init",value:function(){return(0,N._)(function(){var e,t;return(0,M._)(this,function(n){var r,i;switch(n.label){case 0:return lp(l_()&&!h6(),this.auth,"internal-error"),[4,(r=null,new Promise(function(e){"complete"===document.readyState?e():(r=function(){return e()},window.addEventListener("load",r))}).catch(function(e){throw r&&window.removeEventListener("load",r),e}))];case 1:return n.sent(),e=this,[4,this._recaptchaLoader.load(this.auth,this.auth.languageCode||void 0)];case 2:return e.recaptcha=n.sent(),[4,(i=this.auth,(0,N._)(function(){return(0,M._)(this,function(e){switch(e.label){case 0:return[4,lC(i,"GET","/v1/recaptchaParams")];case 1:return[2,e.sent().recaptchaSiteKey||""]}})})())];case 3:return lp(t=n.sent(),this.auth,"internal-error"),this.parameters.sitekey=t,[2]}})}).call(this)}},{key:"getAssertedRecaptcha",value:function(){return lp(this.recaptcha,this.auth,"internal-error"),this.recaptcha}}]),(0,P._)(function e(t,n){(0,O._)(this,e),this.verificationId=t,this.onConfirmation=n},[{key:"confirm",value:function(e){var t=hC._fromVerification(this.verificationId,e);return this.onConfirmation(t)}}]);var fv=function(){function e(t){(0,O._)(this,e),this.providerId=e.PROVIDER_ID,this.auth=eT(t)}return(0,P._)(e,[{key:"verifyPhoneNumber",value:function(e,t){var n,r;return n=this.auth,r=eT(t),(0,N._)(function(){var t,i,a,o;return(0,M._)(this,function(s){switch(s.label){case 0:if(n._getRecaptchaConfig())return[3,4];s.label=1;case 1:return s.trys.push([1,3,,4]),[4,(0,N._)(function(){var e,t;return(0,M._)(this,function(r){switch(r.label){case 0:return[4,lM(e=eT(n),{clientType:"CLIENT_TYPE_WEB",version:"RECAPTCHA_ENTERPRISE"})];case 1:return t=new lL(r.sent()),null==e.tenantId?e._agentRecaptchaConfig=t:e._tenantRecaptchaConfigs[e.tenantId]=t,t.isAnyProviderEnabled()&&new hv(e).verify(),[2]}})})()];case 2:return s.sent(),[3,4];case 3:return s.sent(),console.log("Failed to initialize reCAPTCHA Enterprise config. Triggering the reCAPTCHA v2 verification."),[3,4];case 4:if(s.trys.push([4,,12,13]),!("session"in(i="string"==typeof e?{phoneNumber:e}:e)))return[3,9];if(a=i.session,!("phoneNumber"in i))return[3,6];return lp("enroll"===a.type,n,"internal-error"),[4,hp(n,{idToken:a.credential,phoneEnrollmentInfo:{phoneNumber:i.phoneNumber,clientType:"CLIENT_TYPE_WEB"}},"mfaSmsEnrollment",function(e,t){return(0,N._)(function(){return(0,M._)(this,function(n){switch(n.label){case 0:if(t.phoneEnrollmentInfo.captchaResponse!==hd)return[3,2];return lp((null==r?void 0:r.type)===fh,e,"argument-error"),[4,fd(e,t,r)];case 1:return[2,hX(e,n.sent())];case 2:return[2,hX(e,t)]}})})()},"PHONE_PROVIDER").catch(function(e){return Promise.reject(e)})];case 5:return[2,s.sent().phoneSessionInfo.sessionInfo];case 6:return lp("signin"===a.type,n,"internal-error"),lp(o=(null==(t=i.multiFactorHint)?void 0:t.uid)||i.multiFactorUid,n,"missing-multi-factor-info"),[4,hp(n,{mfaPendingCredential:a.credential,mfaEnrollmentId:o,phoneSignInInfo:{clientType:"CLIENT_TYPE_WEB"}},"mfaSmsSignIn",function(e,t){return(0,N._)(function(){return(0,M._)(this,function(n){switch(n.label){case 0:if(t.phoneSignInInfo.captchaResponse!==hd)return[3,2];return lp((null==r?void 0:r.type)===fh,e,"argument-error"),[4,fd(e,t,r)];case 1:return[2,fo(e,n.sent())];case 2:return[2,fo(e,t)]}})})()},"PHONE_PROVIDER").catch(function(e){return Promise.reject(e)})];case 7:return[2,s.sent().phoneResponseInfo.sessionInfo];case 8:return[3,11];case 9:return[4,hp(n,{phoneNumber:i.phoneNumber,clientType:"CLIENT_TYPE_WEB"},"sendVerificationCode",function(e,t){return(0,N._)(function(){return(0,M._)(this,function(n){switch(n.label){case 0:if(t.captchaResponse!==hd)return[3,2];return lp((null==r?void 0:r.type)===fh,e,"argument-error"),[4,fd(e,t,r)];case 1:return[2,hE(e,n.sent())];case 2:return[2,hE(e,t)]}})})()}
1,"PHONE_PROVIDER").catch(function(e){return Promise.reject(e)})];case 10:return[2,s.sent().sessionInfo];case 11:return[3,13];case 12:return null==r||r._reset(),[7];case 13:return[2]}})})()}}],[{key:"credential",value:function(e,t){return hC._fromVerification(e,t)}},{key:"credentialFromResult",value:function(t){return e.credentialFromTaggedObject(t)}},{key:"credentialFromError",value:function(t){return e.credentialFromTaggedObject(t.customData||{})}},{key:"credentialFromTaggedObject",value:function(e){var t=e._tokenResponse;if(!t)return null;var n=t.phoneNumber,r=t.temporaryProof;return n&&r?hC._fromTokenResponse(n,r):null}}]),e}();fv.PROVIDER_ID="phone",fv.PHONE_SIGN_IN_METHOD="phone";var fy=function(e){function t(e){var n;return(0,O._)(this,t),(n=(0,V._)(this,t,["custom","custom"])).params=e,n}return(0,z._)(t,e),(0,P._)(t,[{key:"_getIdTokenResponse",value:function(e){return hI(e,this._buildIdpRequest())}},{key:"_linkToIdToken",value:function(e,t){return hI(e,this._buildIdpRequest(t))}},{key:"_getReauthenticationResolver",value:function(e){return hI(e,this._buildIdpRequest())}},{key:"_buildIdpRequest",value:function(e){var t={requestUri:this.params.requestUri,sessionId:this.params.sessionId,postBody:this.params.postBody,tenantId:this.params.tenantId,pendingToken:this.params.pendingToken,returnSecureToken:!0,returnIdpCredential:!0};return e&&(t.idToken=e),t}}]),t}(h_);function fp(e){return function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return(0,N._)(function(){var r,i,a;return(0,M._)(this,function(o){switch(o.label){case 0:if(e6(e.app))return[2,Promise.reject(lv(e))];return[4,hq(e,r="signIn",t)];case 1:return i=o.sent(),[4,hV._fromIdTokenResponse(e,r,i)];case 2:if(a=o.sent(),n)return[3,4];return[4,e._updateCurrentUser(a.user)];case 3:o.sent(),o.label=4;case 4:return[2,a]}})})()}(e.auth,new fy(e),e.bypassAuthState)}function fm(e){var t=e.auth,n=e.user;return lp(n,t,"internal-error"),function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return(0,N._)(function(){var r,i,a,o,s,u;return(0,M._)(this,function(c){switch(c.label){case 0:if(e6((r=e.auth).app))return[2,Promise.reject(lv(r))];i="reauthenticate",c.label=1;case 1:return c.trys.push([1,3,,4]),[4,lq(e,hq(r,i,t,e),n)];case 2:return lp((a=c.sent()).idToken,r,"internal-error"),lp(o=lB(a.idToken),r,"internal-error"),s=o.sub,lp(e.uid===s,r,"user-mismatch"),[2,hV._forOperation(e,i,a)];case 3:throw(null==(u=c.sent())?void 0:u.code)==="auth/user-not-found"&&lh(r,"user-mismatch"),u;case 4:return[2]}})})()}(n,new fy(e),e.bypassAuthState)}function fg(e){return(0,N._)(function(){var t,n;return(0,M._)(this,function(r){return t=e.auth,lp(n=e.user,t,"internal-error"),[2,function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return(0,N._)(function(){var r,i,a,o;return(0,M._)(this,function(s){switch(s.label){case 0:return i=[e],a=t._linkToIdToken,o=[e.auth],[4,e.getIdToken()];case 1:return[4,lq.apply(void 0,i.concat([a.apply(t,o.concat([s.sent()])),n]))];case 2:return r=s.sent(),[2,hV._forOperation(e,"link",r)]}})})()}(n,new fy(e),e.bypassAuthState)]})})()}var f_=function(){function e(t,n,r,i){var a=arguments.length>4&&void 0!==arguments[4]&&arguments[4];(0,O._)(this,e),this.auth=t,this.resolver=r,this.user=i,this.bypassAuthState=a,this.pendingPromise=null,this.eventManager=null,this.filter=Array.isArray(n)?n:[n]}return(0,P._)(e,[{key:"execute",value:function(){var e=this;return new Promise(function(t,n){return(0,N._)(function(){var e,r;return(0,M._)(this,function(i){switch(i.label){case 0:this.pendingPromise={resolve:t,reject:n},i.label=1;case 1:return i.trys.push([1,4,,5]),e=this,[4,this.resolver._initialize(this.auth)];case 2:return e.eventManager=i.sent(),[4,this.onExecution()];case 3:return i.sent(),this.eventManager.registerConsumer(this),[3,5];case 4:return r=i.sent(),this.reject(r),[3,5];case 5:return[2]}})}).call(e)})}},{key:"onAuthEvent",value:function(e){return(0,N._)(function(){var t,n,r,i,a,o,s,u,c,l;return(0,M._)(this,function(h){switch(h.label){case 0:if(t=e.urlResponse,n=e.sessionId,r=e.postBody,i=e.tenantId,a=e.error,o=e.type,a)return this.reject(a),[2];s={auth:this.auth,requestUri:t,sessionId:n,tenantId:i||void 0,postBody:r||void 0,user:this.user,bypassAuthState:this.bypassAuthState},h.label=1;case 1:return h.trys.push([1,3,,4]),c=(u=this).resolve,[4,this.getIdpTask(o)(s)];case 2:return c.apply(u,[h.sent()]),[3,4];case 3:return l=h.sent(),this.reject(l),[3,4];case 4:return[2]}})}).call(this)}},{key:"onError",value:function(e){this.reject(e)}},{key:"getIdpTask",value:function(e){switch(e){case"signInViaPopup":case"signInViaRedirect":return fp;case"linkViaPopup":case"linkViaRedirect":return fg;case"reauthViaPopup":case"reauthViaRedirect":return fm;default:lh(this.auth,"internal-error")}}},{key:"resolve",value:function(e){var t,n;t=this.pendingPromise,n="Pending promise was never set",t||lm(n),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}},{key:"reject",value:function(e){var t,n;t=this.pendingPromise,n="Pending promise was never set",t||lm(n),this.pendingPromise.reject(e),this.unregisterAndCleanUp()}},{key:"unregisterAndCleanUp",value:function(){this.eventManager&&this.eventManager.unregisterConsumer(this),this.pendingPromise=null,this.cleanUp()}}]),e}(),fk=new lb(2e3,1e4);(function(e){function t(e,n,r,i,a){var o;return(0,O._)(this,t),(o=(0,V._)(this,t,[e,n,i,a])).provider=r,o.authWindow=null,o.pollId=null,t.currentPopupAction&&t.currentPopupAction.cancel(),t.currentPopupAction=o,o}return(0,z._)(t,e),(0,P._)(t,[{key:"executeNotNull",value:function(){return(0,N._)(function(){var e;return(0,M._)(this,function(t){switch(t.label){case 0:return[4,this.execute()];case 1:return lp(e=t.sent(),this.auth,"internal-error"),[2,e]}})}).call(this)}},{key:"onExecution",value:function(){return(0,N._)(function(){var e,t,n;return(0,M._)(this,function(r){switch(r.label){case 0:var i,a;return e=this,i=1===this.filter.length,a="Popup operations only handle one event",i||lm(a),t=h3(),n=this,[4,this.resolver._openPopup(this.auth,this.provider,this.filter[0],t)];case 1:return n.authWindow=r.sent(),this.authWindow.associatedEvent=t,this.resolver._originValidation(this.auth).catch(function(t){e.reject(t)}),this.resolver._isIframeWebStorageSupported(this.auth,function(t){t||e.reject(lf(e.auth,"web-storage-unsupported"))}),this.pollUserCancellation(),[2]}})}).call(this)}},{key:"eventId",get:function(){var e;return(null==(e=this.authWindow)?void 0:e.associatedEvent)||null}},{key:"cancel",value:function(){this.reject(lf(this.auth,"cancelled-popup-request"))}},{key:"cleanUp",value:function(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,t.currentPopupAction=null}},{key:"pollUserCancellation",value:function(){var e=this,t=function(){var n,r;if(null==(r=null==(n=e.authWindow)?void 0:n.window)?void 0:r.closed){e.pollId=window.setTimeout(function(){e.pollId=null,e.reject(lf(e.auth,"popup-closed-by-user"))},8e3);return}e.pollId=window.setTimeout(t,fk.get())};t()}}]),t})(f_).currentPopupAction=null;var fb=new Map,fw=function(e){function t(e,n){var r,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return(0,O._)(this,t),(r=(0,V._)(this,t,[e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],n,void 0,i])).eventId=null,r}return(0,z._)(t,e),(0,P._)(t,[{key:"execute",value:function(){var e=this,n=this;return(0,N._)(function(){var r,i,a,o;return(0,M._)(this,function(s){switch(s.label){case 0:if(r=fb.get(this.auth._key()))return[3,8];s.label=1;case 1:var u,c;return s.trys.push([1,6,,7]),[4,(u=this.resolver,c=this.auth,(0,N._)(function(){var e,t,n;return(0,M._)(this,function(r){switch(r.label){case 0:var i;return e=lZ("pendingRedirect",(i=c).config.apiKey,i.name),[4,(t=lY(u._redirectPersistence))._isAvailable()];case 1:if(!r.sent())return[2,!1];return[4,t._get(e)];
1case 2:return n="true"===r.sent(),[4,t._remove(e)];case 3:return r.sent(),[2,n]}})})())];case 2:if(!s.sent())return[3,4];return[4,(0,j._)((0,q._)(t.prototype),"execute",e).call(n)];case 3:return a=s.sent(),[3,5];case 4:a=null,s.label=5;case 5:return i=a,r=function(){return Promise.resolve(i)},[3,7];case 6:return o=s.sent(),r=function(){return Promise.reject(o)},[3,7];case 7:fb.set(this.auth._key(),r),s.label=8;case 8:return this.bypassAuthState||fb.set(this.auth._key(),function(){return Promise.resolve(null)}),[2,r()]}})}).call(this)}},{key:"onAuthEvent",value:function(e){var n=this,r=this,i=function(){return(0,j._)((0,q._)(t.prototype),"onAuthEvent",n)};return(0,N._)(function(){var t;return(0,M._)(this,function(n){switch(n.label){case 0:if("signInViaRedirect"===e.type)return[2,i().call(r,e)];if("unknown"===e.type)return this.resolve(null),[2];if(!e.eventId)return[3,2];return[4,this.auth._redirectUserForId(e.eventId)];case 1:if(t=n.sent())return this.user=t,[2,i().call(r,e)];this.resolve(null),n.label=2;case 2:return[2]}})}).call(this)}},{key:"onExecution",value:function(){return(0,N._)(function(){return(0,M._)(this,function(e){return[2]})})()}},{key:"cleanUp",value:function(){}}]),t}(f_);function fI(e,t){fb.set(e._key(),t)}function fT(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return(0,N._)(function(){var r,i,a;return(0,M._)(this,function(o){switch(o.label){case 0:var s;if(e6(e.app))return[2,Promise.reject(lv(e))];return s=r=eT(e),i=t?lY(t):(lp(s._popupRedirectResolver,s,"argument-error"),s._popupRedirectResolver),[4,new fw(r,i,n).execute()];case 1:if(!((a=o.sent())&&!n))return[3,4];return delete a.user._redirectEventId,[4,r._persistUserIfCurrent(a.user)];case 2:return o.sent(),[4,r._setRedirectUser(null,t)];case 3:o.sent(),o.label=4;case 4:return[2,a]}})})()}var fE=function(){function e(t){(0,O._)(this,e),this.auth=t,this.cachedEventUids=new Set,this.consumers=new Set,this.queuedRedirectEvent=null,this.hasHandledPotentialRedirect=!1,this.lastProcessedEventTime=Date.now()}return(0,P._)(e,[{key:"registerConsumer",value:function(e){this.consumers.add(e),this.queuedRedirectEvent&&this.isEventForConsumer(this.queuedRedirectEvent,e)&&(this.sendToConsumer(this.queuedRedirectEvent,e),this.saveEventToCache(this.queuedRedirectEvent),this.queuedRedirectEvent=null)}},{key:"unregisterConsumer",value:function(e){this.consumers.delete(e)}},{key:"onEvent",value:function(e){var t=this;if(this.hasEventBeenHandled(e))return!1;var n=!1;return this.consumers.forEach(function(r){t.isEventForConsumer(e,r)&&(n=!0,t.sendToConsumer(e,r),t.saveEventToCache(e))}),this.hasHandledPotentialRedirect||!function(e){switch(e.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return!0;case"unknown":return fC(e);default:return!1}}(e)||(this.hasHandledPotentialRedirect=!0,n||(this.queuedRedirectEvent=e,n=!0)),n}},{key:"sendToConsumer",value:function(e,t){var n;if(e.error&&!fC(e)){var r=(null==(n=e.error.code)?void 0:n.split("auth/")[1])||"internal-error";t.onError(lf(this.auth,r))}else t.onAuthEvent(e)}},{key:"isEventForConsumer",value:function(e,t){var n=null===t.eventId||!!e.eventId&&e.eventId===t.eventId;return t.filter.includes(e.type)&&n}},{key:"hasEventBeenHandled",value:function(e){return Date.now()-this.lastProcessedEventTime>=6e5&&this.cachedEventUids.clear(),this.cachedEventUids.has(fS(e))}},{key:"saveEventToCache",value:function(e){this.cachedEventUids.add(fS(e)),this.lastProcessedEventTime=Date.now()}}]),e}();function fS(e){return[e.type,e.eventId,e.sessionId,e.tenantId].filter(function(e){return e}).join("-")}function fC(e){var t=e.type,n=e.error;return"unknown"===t&&(null==n?void 0:n.code)==="auth/no-auth-event"}var fx=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,fA=/^https?/,fD=new lb(3e4,6e4);function fR(){var e=h5().___jsl;if(null==e?void 0:e.H){var t=!0,n=!1,r=void 0;try{for(var i,a=Object.keys(e.H)[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var o=i.value;if(e.H[o].r=e.H[o].r||[],e.H[o].L=e.H[o].L||[],e.H[o].r=(0,L._)(e.H[o].L),e.CP)for(var s=0;s<e.CP.length;s++)e.CP[s]=null}}catch(e){n=!0,r=e}finally{try{t||null==a.return||a.return()}finally{if(n)throw r}}}}var fN=null,fO=new lb(5e3,15e3),fP={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},fL=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]),fM={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"},fU=function(){function e(t){(0,O._)(this,e),this.window=t,this.associatedEvent=null}return(0,P._)(e,[{key:"close",value:function(){if(this.window)try{this.window.close()}catch(e){}}}]),e}(),fF=encodeURIComponent("fac");function fV(e,t,n,r,i,a){return(0,N._)(function(){var o,s,u,c,l,h,f,d,v,y,p,m,g,_,k,b,w,I,T;return(0,M._)(this,function(E){switch(E.label){case 0:if(lp(e.config.authDomain,e,"auth-domain-config-required"),lp(e.config.apiKey,e,"invali
1d-api-key"),o={apiKey:e.config.apiKey,appName:e.name,authType:n,redirectUrl:r,v:te,eventId:i},(0,K._)(t,hD)){t.setDefaultLanguage(e.languageCode),o.providerId=t.providerId||"",!function(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}(t.getCustomParameters())&&(o.customParameters=JSON.stringify(t.getCustomParameters())),s=!0,u=!1,c=void 0;try{for(l=Object.entries(a||{})[Symbol.iterator]();!(s=(h=l.next()).done);s=!0)d=(f=(0,D._)(h.value,2))[0],v=f[1],o[d]=v}catch(e){u=!0,c=e}finally{try{s||null==l.return||l.return()}finally{if(u)throw c}}}(0,K._)(t,hR)&&(y=t.getScopes().filter(function(e){return""!==e})).length>0&&(o.scopes=y.join(",")),e.tenantId&&(o.tid=e.tenantId),p=o,m=!0,g=!1,_=void 0;try{for(k=Object.keys(p)[Symbol.iterator]();!(m=(b=k.next()).done);m=!0)w=b.value,void 0===p[w]&&delete p[w]}catch(e){g=!0,_=e}finally{try{m||null==k.return||k.return()}finally{if(g)throw _}}return[4,e._getAppCheckToken()];case 1:var S;return T=(I=E.sent())?"#".concat(fF,"=").concat(encodeURIComponent(I)):"",[2,"".concat((S=e.config).emulator?lw(S,"emulator/auth/handler"):"https://".concat(S.authDomain,"/").concat("__/auth/handler"),"?").concat(e_(p).slice(1)).concat(T)]}})})()}var fB="webStorageSupport",fj=function(){function e(){(0,O._)(this,e),this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=h1,this._completeRedirectFn=fT,this._overrideRedirectResult=fI}return(0,P._)(e,[{key:"_openPopup",value:function(e,t,n,r){return(0,N._)(function(){var i;return(0,M._)(this,function(a){switch(a.label){case 0:var o,s;return o=null==(i=this.eventManagers[e._key()])?void 0:i.manager,s="_initialize() not called before _openPopup()",o||lm(s),[4,fV(e,t,n,lg(),r)];case 1:return[2,function(e,t,n){var r,i,a,o,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:500,u=arguments.length>4&&void 0!==arguments[4]?arguments[4]:600,c=Math.max((window.screen.availHeight-u)/2,0).toString(),l=Math.max((window.screen.availWidth-s)/2,0).toString(),h="",f=Object.assign(Object.assign({},fM),{width:s.toString(),height:u.toString(),top:c,left:l}),d=eh().toLowerCase();n&&(h=l4(d)?"_blank":n),l2(d)&&(t=t||"http://localhost",f.scrollbars="yes");var v=Object.entries(f).reduce(function(e,t){var n=(0,D._)(t,2),r=n[0],i=n[1];return"".concat(e).concat(r,"=").concat(i,",")},"");if(function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:eh();return l9(t)&&!!(null==(e=window.navigator)?void 0:e.standalone)}(d)&&"_self"!==h){return r=t||"",i=h,(a=document.createElement("a")).href=r,a.target=i,(o=document.createEvent("MouseEvent")).initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,1,null),a.dispatchEvent(o),new fU(null)}var y=window.open(t||"",h,v);lp(y,e,"popup-blocked");try{y.focus()}catch(e){}return new fU(y)}(e,a.sent(),h3())]}})}).call(this)}},{key:"_openRedirect",value:function(e,t,n,r){return(0,N._)(function(){return(0,M._)(this,function(i){switch(i.label){case 0:return[4,this._originValidation(e)];case 1:return i.sent(),[4,fV(e,t,n,lg(),r)];case 2:var a;return a=i.sent(),h5().location.href=a,[2,new Promise(function(){})]}})}).call(this)}},{key:"_initialize",value:function(e){var t=this,n=e._key();if(this.eventManagers[n]){var r,i=this.eventManagers[n],a=i.manager,o=i.promise;return a?Promise.resolve(a):(r="If manager is not set, promise should be",o||lm(r),o)}var s=this.initAndGetManager(e);return this.eventManagers[n]={promise:s},s.catch(function(){delete t.eventManagers[n]}),s}},{key:"initAndGetManager",value:function(e){return(0,N._)(function(){var t,n;return(0,M._)(this,function(r){switch(r.label){case 0:return[4,(0,N._)(function(){var t,n;return(0,M._)(this,function(r){var i,a,o,s,u;switch(r.label){case 0:return[4,fN=fN||new Promise(function(t,n){var r,i,a,o=function(){fR(),gapi.load("gapi.iframes",{callback:function(){t(gapi.iframes.getContext())},ontimeout:function(){fR(),n(lf(e,"network-request-failed"))},timeout:fD.get()})};if(null==(i=null==(r=h5().gapi)?void 0:r.iframes)?void 0:i.Iframe)t(gapi.iframes.getContext());else if(null==(a=h5().gapi)?void 0:a.load)o();else{var s=hu("iframefcb");return h5()[s]=function(){gapi.load?o():n(lf(e,"network-request-failed"))},hs("".concat(ho.gapiScript,"?onload=").concat(s)).catch(function(e){return n(e)})}}).catch(function(e){throw fN=null,e})];case 1:return t=r.sent(),lp(n=h5().gapi,e,"internal-error"),[2,t.open({where:document.body,url:(lp((i=e.config).authDomain,e,"auth-domain-config-required"),a=i.emulator?lw(i,"emulator/auth/iframe"):"https://".concat(e.config.authDomain,"/").concat("__/auth/iframe"),o={apiKey:i.apiKey,appName:e.n
1ame,v:te},(s=fL.get(e.config.apiHost))&&(o.eid=s),(u=e._getFrameworks()).length&&(o.fw=u.join(",")),"".concat(a,"?").concat(e_(o).slice(1))),messageHandlersFilter:n.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:fP,dontclear:!0},function(t){return new Promise(function(n,r){return(0,N._)(function(){var i,a;function o(){h5().clearTimeout(a),n(t)}return(0,M._)(this,function(n){switch(n.label){case 0:return[4,t.restyle({setHideOnLeave:!1})];case 1:return n.sent(),i=lf(e,"network-request-failed"),a=h5().setTimeout(function(){r(i)},fO.get()),t.ping(o).then(o,function(){r(i)}),[2]}})})()})})]}})})()];case 1:return t=r.sent(),n=new fE(e),t.register("authEvent",function(t){return lp(null==t?void 0:t.authEvent,e,"invalid-auth-event"),{status:n.onEvent(t.authEvent)?"ACK":"ERROR"}},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[e._key()]={manager:n},this.iframes[e._key()]=t,[2,n]}})}).call(this)}},{key:"_isIframeWebStorageSupported",value:function(e,t){this.iframes[e._key()].send(fB,{type:fB},function(n){var r,i=null==(r=null==n?void 0:n[0])?void 0:r[fB];void 0!==i&&t(!!i),lh(e,"internal-error")},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}},{key:"_originValidation",value:function(e){var t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=(0,N._)(function(){var t,n,r,i,a,o,s;return(0,M._)(this,function(u){switch(u.label){case 0:if(e.config.emulator)return[2];return[4,function(e){return(0,N._)(function(e){var t=arguments;return(0,M._)(this,function(n){return[2,lC(e,"GET","/v1/projects",t.length>1&&void 0!==t[1]?t[1]:{})]})}).apply(this,arguments)}(e)];case 1:t=u.sent().authorizedDomains,n=!0,r=!1,i=void 0;try{for(a=t[Symbol.iterator]();!(n=(o=a.next()).done);n=!0){s=o.value;try{if(function(e){var t=lg(),n=new URL(t),r=n.protocol,i=n.hostname;if(e.startsWith("chrome-extension://")){var a=new URL(e);return""===a.hostname&&""===i?"chrome-extension:"===r&&e.replace("chrome-extension://","")===t.replace("chrome-extension://",""):"chrome-extension:"===r&&a.hostname===i}if(!fA.test(r))return!1;if(fx.test(e))return i===e;var o=e.replace(/\./g,"\\.");return RegExp("^(.+\\."+o+"|"+o+")$","i").test(i)}(s))return[2]}catch(e){}}}catch(e){r=!0,i=e}finally{try{n||null==a.return||a.return()}finally{if(r)throw i}}return lh(e,"unauthorized-domain"),[2]}})})()),this.originValidationPromises[t]}},{key:"_shouldInitProactively",get:function(){return he()||l3()||l9()}}]),e}(),fq=function(){function e(t){(0,O._)(this,e),this.factorId=t}return(0,P._)(e,[{key:"_process",value:function(e,t,n){switch(t.type){case"enroll":return this._finalizeEnroll(e,t.credential,n);case"signin":return this._finalizeSignIn(e,t.credential);default:return lm("unexpected MultiFactorSessionType")}}}]),e}(),fz=function(e){function t(e){var n;return(0,O._)(this,t),(n=(0,V._)(this,t,["phone"])).credential=e,n}return(0,z._)(t,e),(0,P._)(t,[{key:"_finalizeEnroll",value:function(e,t,n){return lC(e,"POST","/v2/accounts/mfaEnrollment:finalize",lS(e,{idToken:t,displayName:n,phoneVerificationInfo:this.credential._makeVerificationRequest()}))}},{key:"_finalizeSignIn",value:function(e,t){return lC(e,"POST","/v2/accounts/mfaSignIn:finalize",lS(e,{mfaPendingCredential:t,phoneVerificationInfo:this.credential._makeVerificationRequest()}))}}],[{key:"_fromCredential",value:function(e){return new t(e)}}]),t}(fq);(function(){function e(){(0,O._)(this,e)}return(0,P._)(e,null,[{key:"assertion",value:function(e){return fz._fromCredential(e)}}]),e})().FACTOR_ID="phone",function(){function e(){(0,O._)(this,e)}return(0,P._)(e,null,[{key:"assertionForEnrollment",value:function(e,t){return fK._fromSecret(e,t)}},{key:"assertionForSignIn",value:function(e,t){return fK._fromEnrollmentId(e,t)}},{key:"generateSecret",value:function(e){return(0,N._)(function(){var t,n,r;return(0,M._)(this,function(i){switch(i.label){case 0:var a;return lp(void 0!==(null==(t=(n=e).user)?void 0:t.auth),"internal-error"),[4,lC(a=n.user.auth,"POST","/v2/accounts/mfaEnrollment:start",lS(a,{idToken:n.credential,totpEnrollmentInfo:{}}))];case 1:return r=i.sent(),[2,fG._fromStartTotpMfaEnrollmentResponse(r,n.user.auth)]}})})()}}]),e}().FACTOR_ID="totp";var fK=function(e){function t(e,n,r){var i;return(0,O._)(this,t),(i=(0,V._)(this,t,["totp"])).otp=e,i.enrollmentId=n,i.secret=r,i}return(0,z._)(t,e),(0,P._)(t,[{key:"_finalizeEnroll",value:function(e,t,n){return(0,N._)(function(){return(0,M._)(this,function(r){return lp(void 0!==this.secret,e,"argument-error"),[2,lC(e,"POST","/v2/accounts/mfaEnrollment:finalize",lS(e,{idToken:t,displayName:n,totpVerificationInfo:this.secret._makeTotpVerificationInfo(this.otp)}))]})}).call(this)}},{key:"_finalizeSignIn",value:function(e,t){return(0,N._)(function(){var n;return(0,M._)(this,function(r){return lp(void 0!==this.enrollmentId&&void 0!==this.otp,e,"argument-error"),n={verificationCode:this.otp},[2,lC(e,"POST","/v2/accounts/mfaSignIn:finalize",lS(e,{mfaPendingCredential:t,mfaEnrollmentId:this.enrollmentId,totpVerificationInfo:n}))]})}).call(this)}}],[{key:"_fromSecret",value:function(e,n){return new t(n,void 0,e)}},{key:"_fromEnrollmentId",value:function(e,n){return new t(n,e)}}]),t}(fq),fG=function(){function e(t,n,r,i,a,o,s){(0,O._)(this,e),this.sessionInfo=o,this.auth=s,this.secretKey=t,this.hashingAlgorithm=n,this.codeLength=r,this.co
1deIntervalSeconds=i,this.enrollmentCompletionDeadline=a}return(0,P._)(e,[{key:"_makeTotpVerificationInfo",value:function(e){return{sessionInfo:this.sessionInfo,verificationCode:e}}},{key:"generateQrCodeUrl",value:function(e,t){var n,r=!1;return(fH(e)||fH(t))&&(r=!0),r&&(fH(e)&&(e=(null==(n=this.auth.currentUser)?void 0:n.email)||"unknownuser"),fH(t)&&(t=this.auth.name)),"otpauth://totp/".concat(t,":").concat(e,"?secret=").concat(this.secretKey,"&issuer=").concat(t,"&algorithm=").concat(this.hashingAlgorithm,"&digits=").concat(this.codeLength)}}],[{key:"_fromStartTotpMfaEnrollmentResponse",value:function(t,n){return new e(t.totpSessionInfo.sharedSecretKey,t.totpSessionInfo.hashingAlgorithm,t.totpSessionInfo.verificationCodeLength,t.totpSessionInfo.periodSec,new Date(t.totpSessionInfo.finalizeEnrollmentTime).toUTCString(),t.totpSessionInfo.sessionInfo,n)}}]),e}();function fH(e){return void 0===e||(null==e?void 0:e.length)===0}var fW="@firebase/auth",fQ="1.8.1",fJ=function(){function e(t){(0,O._)(this,e),this.auth=t,this.internalListeners=new Map}return(0,P._)(e,[{key:"getUid",value:function(){var e;return this.assertAuthConfigured(),(null==(e=this.auth.currentUser)?void 0:e.uid)||null}},{key:"getToken",value:function(e){return(0,N._)(function(){return(0,M._)(this,function(t){switch(t.label){case 0:return this.assertAuthConfigured(),[4,this.auth._initializationPromise];case 1:if(t.sent(),!this.auth.currentUser)return[2,null];return[4,this.auth.currentUser.getIdToken(e)];case 2:return[2,{accessToken:t.sent()}]}})}).call(this)}},{key:"addAuthTokenListener",value:function(e){if(this.assertAuthConfigured(),!this.internalListeners.has(e)){var t=this.auth.onIdTokenChanged(function(t){e((null==t?void 0:t.stsTokenManager.accessToken)||null)});this.internalListeners.set(e,t),this.updateProactiveRefresh()}}},{key:"removeAuthTokenListener",value:function(e){this.assertAuthConfigured();var t=this.internalListeners.get(e);t&&(this.internalListeners.delete(e),t(),this.updateProactiveRefresh())}},{key:"assertAuthConfigured",value:function(){lp(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}},{key:"updateProactiveRefresh",value:function(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}]),e}(),fX=ec("authIdTokenMaxAge")||300,fY=null;ho={loadJS:function(e){return new Promise(function(t,n){var r,i,a=document.createElement("script");a.setAttribute("src",e),a.onload=t,a.onerror=function(e){var t=lf("internal-error");t.customData=e,n(t)},a.type="text/javascript",a.charset="UTF-8",(null!=(i=null==(r=document.getElementsByTagName("head"))?void 0:r[0])?i:document).appendChild(a)})},gapiScript:"https://apis.google.com/js/api.js",recaptchaV2Script:"https://www.google.com/recaptcha/api.js",recaptchaEnterpriseScript:"https://www.google.com/recaptcha/enterprise.js?render="},r="Browser",e4(new eE("auth",function(e,t){var n,i,a=t.options,o=e.getProvider("app").getImmediate(),s=e.getProvider("heartbeat"),u=e.getProvider("app-check-internal"),c=o.options,l=c.apiKey,h=c.authDomain;lp(l&&!l.includes(":"),"invalid-api-key",{appName:o.name});var f=new hi(o,s,u,{apiKey:l,authDomain:h,clientPlatform:r,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:ht(r)});return i=(Array.isArray(n=(null==a?void 0:a.persistence)||[])?n:[n]).map(lY),(null==a?void 0:a.errorMap)&&f._updateErrorMap(a.errorMap),f._initializeWithPersistence(i,null==a?void 0:a.popupRedirectResolver),f},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback(function(e,t,n){e.getProvider("auth-internal").initialize()})),e4(new eE("auth-internal",function(e){return new fJ(eT(e.getProvider("auth").getImmediate()))},"PRIVATE").setInstantiationMode("EXPLICIT")),tr(fW,fQ,function(e){switch(e){case"Node":return"node";case"ReactNative":return"rn";case"Worker":return"webworker";case"Cordova":return"cordova";case"WebExtension":return"web-extension";default:return}}(r)),tr(fW,fQ,"esm2017");var f$={apiKey:"AIzaSyD7kX7KlyrvJghmUt7VJDZyTUbnuErY57Q",authDomain:"pipeops-prod.firebaseapp.com",projectId:"pipeops-prod",storageBucket:"pipeops-prod.appspot.com",messagingSenderId:"521732073820",a
1ppId:"1:521732073820:web:66838776eca5cc265d3999",measurementId:"G-NK8GSW6XP2"},fZ=null,f0=null,f1=null,f2=null,f3=function(){if(fZ)return{app:fZ,db:f0,auth:f1};var e=Array.from(e0.values());if(e.length>0)f0=ct(fZ=e[0]);else{fZ=tt(f$);try{f0=ce(fZ,{localCache:c8({tabManager:le()})})}catch(e){f0=ct(fZ)}}return f1=function(){var e,t,n,r,i,a,o,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:tn(),u=e5(s,"auth");if(u.isInitialized())return u.getImmediate();var c=function(e,t){var n=e5(e,"auth");if(n.isInitialized()){var r=n.getImmediate();if(em(n.getOptions(),null!=t?t:{}))return r;lh(r,"already-initialized")}return n.initialize({options:t})}(s,{popupRedirectResolver:fj,persistence:[fa,h0,h1]}),l=ec("authTokenSyncURL");if(l&&"boolean"==typeof isSecureContext&&isSecureContext){var h=new URL(l,location.origin);if(location.origin===h.origin){var f,d=(f=h.toString(),function(e){return(0,N._)(function(){var t,n,r,i;return(0,M._)(this,function(a){switch(a.label){case 0:if(!(n=e))return[3,2];return[4,e.getIdTokenResult()];case 1:n=a.sent(),a.label=2;case 2:if((r=(t=n)&&(new Date().getTime()-Date.parse(t.issuedAtTime))/1e3)&&r>fX||(i=null==t?void 0:t.token,fY===i))return[2];return fY=i,[4,fetch(f,{method:i?"POST":"DELETE",headers:i?{Authorization:"Bearer ".concat(i)}:{}})];case 3:return a.sent(),[2]}})})()});eT(c).beforeAuthStateChanged(d,function(){return d(c.currentUser)}),eT(c).onIdTokenChanged(function(e){return d(e)},void 0,void 0)}}var v=eo("auth");return v&&(e=c,t="http://".concat(v),lp((n=eT(e))._canInitEmulator,n,"emulator-config-failed"),lp(/^https?:\/\//.test(t),n,"invalid-emulator-scheme"),r=hm(t),a=(i=function(e){var t=hm(e),n=/(\/\/)?([^?#/]+)/.exec(e.substr(t.length));if(!n)return{host:"",port:null};var r=n[2].split("@").pop()||"",i=/^(\[[^\]]+\])(:|$)/.exec(r);if(i){var a=i[1];return{host:a,port:hg(r.substr(a.length+1))}}var o=(0,D._)(r.split(":"),2);return{host:o[0],port:hg(o[1])}}(t)).host,o=i.port,n.config.emulator={url:"".concat(r,"//").concat(a).concat(null===o?"":":".concat(o),"/")},n.settings.appVerificationDisabledForTesting=!0,n.emulatorConfig=Object.freeze({host:a,port:o,protocol:r.replace(":",""),options:Object.freeze({disableWarnings:!1})}),function(){function e(){var e=document.createElement("p"),t=e.style;e.innerText="Running in emulator mode. Do not use with production credentials.",t.position="fixed",t.width="100%",t.backgroundColor="#ffffff",t.border=".1em solid #000000",t.color="#b50000",t.bottom="0px",t.left="0px",t.margin="0px",t.zIndex="10000",t.textAlign="center",e.classList.add("firebase-emulator-warning"),document.body.appendChild(e)}"u">typeof console&&"function"==typeof console.info&&console.info("WARNING: You are using the Auth Emulator, which is intended for local testing only. Do not use with production credentials."),"u">typeof window&&"u">typeof document&&("loading"===document.readyState?window.addEventListener("DOMContentLoaded",e):e())}()),c}(fZ),{app:fZ,db:f0,auth:f1}},f4=function(){return fZ||f3(),{app:fZ,db:f0,auth:f1}},f5=function(){if(f2)return f2;var e=f4().auth;return f2=new Promise(function(t,n){var r,i=(r=function(r){if(i(),r)t(r);else(0,N._)(function(){var t,n,r,i;return(0,M._)(this,function(a){switch(a.label){case 0:if(e6(e.app))return[2,Promise.reject(lv(e))];return[4,(n=eT(e))._initializationPromise];case 1:var o,s;if(a.sent(),null==(t=n.currentUser)?void 0:t.isAnonymous)return[2,new hV({user:n.currentUser,providerId:null,operationType:"signIn"})];return[4,(o=n,s={returnSecureToken:!0},(0,N._)(function(){return(0,M._)(this,function(e){return[2,lA(o,"POST","/v1/accounts:signUp",lS(o,s))]})})())];case 2:return r=a.sent(),[4,hV._fromIdTokenResponse(n,"signIn",r,!0)];case 3:return i=a.sent(),[4,n._updateCurrentUser(i.user)];case 4:return a.sent(),[2,i]}})})().then(function(e){return t(e.user),e}).catch(function(e){console.error("Firebase anonymous auth error:",e),n(e)})},eT(e).onAuthStateChanged(r,void 0,void 0))})},f6=function(){return f4().db};e.s(["authenticateAnonymously",0,f5,"getDb",0,f6,"initializeFirebase",0,f3],562682);var f8=new(function(){function e(){(0,O._)(this,e),this.subscriptions=new Map,this.listeners=new Map,this.isReady=!1,this.readyPromise=null,this.visibilityHandler=null}return(0,P._)(e,[{key:"initialize",value:function(){return(0,N._)(function(){var e;return(0,M._)(this,function(t){return e=this,this.readyPromise||(this.readyPromise=f5().then(function(){return e.isReady=!0,e.setupVisibilityHandler(),!0}).catch(function(e){return console.error("SubscriptionManager init error:",e),!1})),[2,this.readyPromise]}
1)}).call(this)}},{key:"setupVisibilityHandler",value:function(){var e=this;"u">typeof document&&!this.visibilityHandler&&(this.visibilityHandler=function(){document.hidden?e.pauseAll():e.resumeAll()},document.addEventListener("visibilitychange",this.visibilityHandler))}},{key:"generateKey",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],r=t.map(function(e){return"".concat(e.field,":").concat(e.op,":").concat(e.value)}).join("|"),i=n.map(function(e){return"".concat(e.field,":").concat(e.dir)}).join("|");return"".concat(e,"::").concat(r,"::").concat(i)}},{key:"subscribe",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2?arguments[2]:void 0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},a=i.orderByFields,o=void 0===a?[]:a,s=i.onError,u=i.listenerId,c=this.generateKey(e,n,o),l=u||"".concat(c,":").concat(Date.now());if(this.listeners.has(c)||this.listeners.set(c,new Map),this.listeners.get(c).set(l,{callback:r,onError:s}),this.subscriptions.has(c)){var h=this.subscriptions.get(c);if(h.listenerCount++,h.lastSnapshot)try{r(h.lastSnapshot)}catch(e){console.error("Callback error:",e)}return function(){return t.unsubscribeListener(c,l)}}
1return this.createSubscription(c,e,n,o),function(){return t.unsubscribeListener(c,l)}}},{key:"createSubscription",value:function(e,t,n,r){var i=this,a=f6();if(!a)return void console.error("Firestore not initialized");var o=u6(a,t),s=[];n.forEach(function(e){s.push(cB(e.field,e.op,e.value))}),r.forEach(function(e){s.push(cz(e.field,e.dir||"asc"))}),s.length>0&&(o=cF.apply(void 0,[o].concat((0,L._)(s))));var u=c5(o,function(t){var n=i.subscriptions.get(e);n&&(n.lastSnapshot=t);var r=i.listeners.get(e);r&&r.forEach(function(e){var n=e.callback;try{n(t)}catch(e){console.error("Listener callback error:",e)}})},function(t){console.error("Subscription error [".concat(e,"]:"),t);var n=i.listeners.get(e);n&&n.forEach(function(e){var n=e.onError;n&&n(t)})}),c=this.subscriptions.get(e);this.subscriptions.set(e,{unsubscribe:u,collectionName:t,filters:n,orderByFields:r,listenerCount:(null==c?void 0:c.listenerCount)||1,lastSnapshot:null,paused:!1})}},{key:"unsubscribeListener",value:function(e,t){var n=this.listeners.get(e);if(n&&(n.delete(t),0===n.size)){this.listeners.delete(e);var r=this.subscriptions.get(e);r&&(r.unsubscribe(),this.subscriptions.delete(e))}}},{key:"pauseAll",value:function(){this.subscriptions.forEach(function(e){e.paused||"function"!=typeof e.unsubscribe||(e.unsubscribe(),e.unsubscribe=null,e.paused=!0,e.lastSnapshot=null)})}},{key:"resumeAll",value:function(){var e=this;this.subscriptions.forEach(function(t,n){if(t.paused){var r=t.lastSnapshot;if(e.createSubscription(n,t.collectionName,t.filters,t.orderByFields),r){var i=e.subscriptions.get(n);i&&(i.lastSnapshot=r);var a=e.listeners.get(n);a&&a.forEach(function(e){var t=e.callback;try{t(r)}catch(e){console.error("Callback error on resume:",e)}})}}})}},{key:"cleanup",value:function(){this.subscriptions.forEach(function(e){e.unsubscribe&&e.unsubscribe()}),this.subscriptions.clear(),this.listeners.clear(),this.visibilityHandler&&"u">typeof document&&(document.removeEventListener("visibilitychange",this.visibilityHandler),this.visibilityHandler=null)}}]),e}()),f7=(0,S.createContext)(null),f9=function(){var e=(0,S.useContext)(f7);if(!e)throw Error("useFirebase must be used within FirebaseProvider");return e},de=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2?arguments[2]:void 0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=r.enabled,a=void 0===i||i,o=r.orderByFields,s=void 0===o?[]:o,u=f9(),c=u.subscribe,l=u.isReady,h=(0,S.useRef)(n);(0,S.useEffect)(function(){h.current=n},[n]),(0,S.useEffect)(function(){if(a&&e&&l)return c(e,t,function(e){h.current&&h.current(e)},{orderByFields:s})},[e,JSON.stringify(t),JSON.stringify(s),a,l,c])};e.s(["FirebaseProvider",0,function(e){var t=e.children,n=(0,D._)((0,S.useState)(!1),2),r=n[0],i=n[1],a=(0,D._)((0,S.useState)(null),2),o=a[0],s=a[1];(0,S.useEffect)(function(){return f8.initialize().then(function(e){return i(e),e}).catch(function(e){s(e),console.error("Firebase initialization error:",e)}),function(){}},[]);var u=(0,S.useCallback)(function(e,t,n,r){return f8.subscribe(e,t,n,r)},[r]);return(0,R.jsx)(f7.Provider,{value:{isReady:r,error:o,subscribe:u,manager:f8},children:t})},"useCollectionSnapshot",0,de],313171),e.i(982285);var dt=e.i(56001),dn=e.i(274466),dr=e.i(78333),di=e.i(608944),da=e.i(420461),ds=(0,dr.default)(function(e){e((0,da.getProjects)())},2e3,{maxWait:5e3}),du=(0,dr.default)(function(e){e((0,dt.getServers)())},2e3,{maxWait:5e3}),dc=(0,dr.default)(function(e){e((0,di.fetchMyAddOns)())},2e3,{maxWait:5e3});e.s(["useAddonsWatcher",0,function(){var e,t=(0,x.useDispatch)(),n=(0,A.usePathname)(),r=(0,C.useSelector)(function(e){return e.UserReducer.appData}),i=(0,C.useSelector)(function(e){return e.UserReducer.activeWorkspace}),a=(0,S.useRef)(!0),o=(0,S.useMemo)(function(){var e;return(null==i||null==(e=i.Owner)?void 0:e.UUID)||(null==i?void 0:i.OwnerUUID)||(null==r?void 0:r.uuid)},[null==i||null==(e=i.Owner)?void 0:e.UUID,null==i?void 0:i.OwnerUUID,null==r?void 0:r.uuid]),s=(null==n?void 0:n.includes("/dashboard/addons"))&&!(null==n?void 0:n.includes("store")),u=(0,S.useMemo)(function(){return o?[{field:"uuid",op:"==",value:o}]:[]},[o]);(0,S.useEffect)(function(){a.current=!0},[o]),de("pipeops-addons",u,(0,S.useCallback)(function(){if(a.current){a.current=!1;return}dc(t)},[t]),{enabled:!!o&&s})},"useAgentClusterWatcher",0,function(e,t){de("pipeops-agent-cluster",(0,S.useMemo)(function(){return e?[{field:"tokenUID",op:"==",value:e}]:[]},[e]),(0,S.useCallback)(function(e){e.forEach(function(e){var n=e.data();null==t||t(n)})},[t]),{enabled:!!e})},"useBuildLogsWatcher",0,function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};de("pipeops-build-logs",(0,S.useMemo)(function(){return e?[{field:"build-sha",op:"==",value:e}]:[]},[e]),(0,S.useCallback)(function(e){null==n||n(e),e.forEach(function(e){null==t||t(e.id,e.data())})},[t,n]),(0,E._)({enabled:!!e,orderByFields:[{field:"ts",dir:"asc"}]},r))},"useClustersWatcher",0,function(){var e=(0,x.useDispatch)(),t=(0,A.usePathname)(),n=(0,C.useSelector)(function(e){return e.UserReducer.activeWorkspace}
1),r=(0,S.useRef)(!0),i=(null==t?void 0:t.includes("clusters"))||(null==t?void 0:t.includes("projects")),a=(0,S.useMemo)(function(){return(null==n?void 0:n.UUID)?[{field:"workspace_uuid",op:"==",value:n.UUID}]:[]},[null==n?void 0:n.UUID]);(0,S.useEffect)(function(){r.current=!0},[null==n?void 0:n.UUID]),de("pipeops-cluster",a,(0,S.useCallback)(function(t){if(e((0,dt.altFirebaseServerProgressState)(t)),r.current){r.current=!1;return}du(e)},[e]),{enabled:!!(null==n?void 0:n.UUID)&&i})},"useProjectsWatcher",0,function(){var e,t=(0,x.useDispatch)(),n=(0,A.usePathname)(),r=(0,C.useSelector)(function(e){return e.UserReducer.appData}),i=(0,C.useSelector)(function(e){return e.UserReducer.activeWorkspace}),a=(0,S.useRef)(!0),o=(0,S.useMemo)(function(){var e;return(null==i||null==(e=i.Owner)?void 0:e.UUID)||(null==i?void 0:i.OwnerUUID)||(null==r?void 0:r.uuid)},[null==i||null==(e=i.Owner)?void 0:e.UUID,null==i?void 0:i.OwnerUUID,null==r?void 0:r.uuid]),s=null==n?void 0:n.includes("projects"),u=(0,S.useMemo)(function(){return o?[{field:"uuid",op:"==",value:o}]:[]},[o]);(0,S.useEffect)(function(){a.current=!0},[o]),de("pipeops-project",u,(0,S.useCallback)(function(){if(a.current){a.current=!1;return}ds(t)},[t]),{enabled:!!o&&s})},"useSubscriptionWatcher",0,function(){var e,t=(0,x.useDispatch)(),n=(0,C.useSelector)(function(e){return e.UserReducer.appData}),r=(0,C.useSelector)(function(e){return e.UserReducer.activeWorkspace}),i=(0,S.useMemo)(function(){var e;return(null==r||null==(e=r.Owner)?void 0:e.UUID)||(null==r?void 0:r.OwnerUUID)||(null==n?void 0:n.uuid)},[null==r||null==(e=r.Owner)?void 0:e.UUID,null==r?void 0:r.OwnerUUID,null==n?void 0:n.uuid]);de("pipeops-subscriptions",(0,S.useMemo)(function(){return i?[{field:"uuid",op:"==",value:i}]:[]},[i]),(0,S.useCallback)(function(e){t((0,dn.altSubscriptionStage)(e))},[t]),{enabled:!!i})},"useTeamWatcher",0,function(e,t){var n=(0,C.useSelector)(function(e){return e.UserReducer.appData}),r=(0,C.useSelector)(function(e){return e.UserReducer.activeWorkspace}),i=(0,S.useRef)(!0),a=(0,S.useRef)(new Set),o=(0,S.useRef)(null),s=(0,S.useRef)(Date.now()),u=(0,S.useMemo)(function(){return(null==r?void 0:r.teamUUID)&&(null==n?void 0:n.uuid)?"".concat(r.teamUUID,"_").concat(n.uuid):null},[null==r?void 0:r.teamUUID,null==n?void 0:n.uuid]),c=null==n?void 0:n.uuid,l=null==r?void 0:r.teamUUID;u!==o.current&&(o.current=u,i.current=!0,a.current=new Set,s.current=Date.now()),de("user_team",(0,S.useMemo)(function(){return u?[{field:"team_user_uuid",op:"==",value:u}]:[]},[u]),(0,S.useCallback)(function(n){if(e||t){var r=n.docChanges();if(i.current){r.forEach(function(e){a.current.add(e.doc.id)}),i.current=!1;return}r.forEach(function(n){var r=n.doc.id,i=n.doc.data();if("added"===n.type||"modified"===n.type){if(a.current.has(r))return;a.current.add(r),i.action;var o=!0===i.revoked,u=i.user_uuid||i.userUUID,h=i.team_uuid||i.teamUUID;if(o){if(u&&u!==c||h&&h!==l)return;var f=i.timestamp||i.created_at;if(f){var d,v="number"==typeof f?f:(null==f||null==(d=f.toMillis)?void 0:d.call(f))||new Date(f).getTime(),y=Date.now()-s.current;if(Date.now()-v>y+5e3)return}null==e||e()}else null==t||t(i)}})}},[e,t,c,l]),{enabled:!!u})}],660365)}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.