@retter/sdk 0.2.59 → 0.2.60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bundle/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see index.js.LICENSE.txt */
2
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Retter=e():t.Retter=e()}(self,(function(){return(()=>{var t={4444:(t,e,n)=>{"use strict";n.d(e,{BH:()=>a,LL:()=>b,ZR:()=>v,tV:()=>o,Sg:()=>c,ne:()=>A,vZ:()=>T,pd:()=>k,m9:()=>C,z$:()=>u,ru:()=>l,d:()=>f,xb:()=>I,w1:()=>p,hl:()=>y,uI:()=>h,b$:()=>d,G6:()=>g,Mn:()=>m,xO:()=>E,zd:()=>S});const r=function(t){const e=[];let n=0;for(let r=0;r<t.length;r++){let i=t.charCodeAt(r);i<128?e[n++]=i:i<2048?(e[n++]=i>>6|192,e[n++]=63&i|128):55296==(64512&i)&&r+1<t.length&&56320==(64512&t.charCodeAt(r+1))?(i=65536+((1023&i)<<10)+(1023&t.charCodeAt(++r)),e[n++]=i>>18|240,e[n++]=i>>12&63|128,e[n++]=i>>6&63|128,e[n++]=63&i|128):(e[n++]=i>>12|224,e[n++]=i>>6&63|128,e[n++]=63&i|128)}return e},i={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(t,e){if(!Array.isArray(t))throw Error("encodeByteArray takes an array as a parameter");this.init_();const n=e?this.byteToCharMapWebSafe_:this.byteToCharMap_,r=[];for(let e=0;e<t.length;e+=3){const i=t[e],s=e+1<t.length,o=s?t[e+1]:0,a=e+2<t.length,c=a?t[e+2]:0,u=i>>2,h=(3&i)<<4|o>>4;let l=(15&o)<<2|c>>6,d=63&c;a||(d=64,s||(l=64)),r.push(n[u],n[h],n[l],n[d])}return r.join("")},encodeString(t,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(t):this.encodeByteArray(r(t),e)},decodeString(t,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(t):function(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n++];if(i<128)e[r++]=String.fromCharCode(i);else if(i>191&&i<224){const s=t[n++];e[r++]=String.fromCharCode((31&i)<<6|63&s)}else if(i>239&&i<365){const s=((7&i)<<18|(63&t[n++])<<12|(63&t[n++])<<6|63&t[n++])-65536;e[r++]=String.fromCharCode(55296+(s>>10)),e[r++]=String.fromCharCode(56320+(1023&s))}else{const s=t[n++],o=t[n++];e[r++]=String.fromCharCode((15&i)<<12|(63&s)<<6|63&o)}}return e.join("")}(this.decodeStringToByteArray(t,e))},decodeStringToByteArray(t,e){this.init_();const n=e?this.charToByteMapWebSafe_:this.charToByteMap_,r=[];for(let e=0;e<t.length;){const i=n[t.charAt(e++)],s=e<t.length?n[t.charAt(e)]:0;++e;const o=e<t.length?n[t.charAt(e)]:64;++e;const a=e<t.length?n[t.charAt(e)]:64;if(++e,null==i||null==s||null==o||null==a)throw Error();const c=i<<2|s>>4;if(r.push(c),64!==o){const t=s<<4&240|o>>2;if(r.push(t),64!==a){const t=o<<6&192|a;r.push(t)}}}return r},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let t=0;t<this.ENCODED_VALS.length;t++)this.byteToCharMap_[t]=this.ENCODED_VALS.charAt(t),this.charToByteMap_[this.byteToCharMap_[t]]=t,this.byteToCharMapWebSafe_[t]=this.ENCODED_VALS_WEBSAFE.charAt(t),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[t]]=t,t>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(t)]=t,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(t)]=t)}}},s=function(t){return function(t){const e=r(t);return i.encodeByteArray(e,!0)}(t).replace(/\./g,"")},o=function(t){try{return i.decodeString(t,!0)}catch(t){console.error("base64Decode failed: ",t)}return null};class a{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise(((t,e)=>{this.resolve=t,this.reject=e}))}wrapCallback(t){return(e,n)=>{e?this.reject(e):this.resolve(n),"function"==typeof t&&(this.promise.catch((()=>{})),1===t.length?t(e):t(e,n))}}}function c(t,e){if(t.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');const n=e||"demo-project",r=t.iat||0,i=t.sub||t.user_id;if(!i)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const o=Object.assign({iss:`https://securetoken.google.com/${n}`,aud:n,iat:r,exp:r+3600,auth_time:r,sub:i,user_id:i,firebase:{sign_in_provider:"custom",identities:{}}},t);return[s(JSON.stringify({alg:"none",type:"JWT"})),s(JSON.stringify(o)),""].join(".")}function u(){return"undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:""}function h(){return"undefined"!=typeof window&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(u())}function l(){const t="object"==typeof chrome?chrome.runtime:"object"==typeof browser?browser.runtime:void 0;return"object"==typeof t&&void 0!==t.id}function d(){return"object"==typeof navigator&&"ReactNative"===navigator.product}function f(){return u().indexOf("Electron/")>=0}function p(){const t=u();return t.indexOf("MSIE ")>=0||t.indexOf("Trident/")>=0}function m(){return u().indexOf("MSAppHost/")>=0}function g(){return!function(){try{return"[object process]"===Object.prototype.toString.call(n.g.process)}catch(t){return!1}}()&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}function y(){return"object"==typeof indexedDB}class v extends Error{constructor(t,e,n){super(e),this.code=t,this.customData=n,this.name="FirebaseError",Object.setPrototypeOf(this,v.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,b.prototype.create)}}class b{constructor(t,e,n){this.service=t,this.serviceName=e,this.errors=n}create(t,...e){const n=e[0]||{},r=`${this.service}/${t}`,i=this.errors[t],s=i?function(t,e){return t.replace(w,((t,n)=>{const r=e[n];return null!=r?String(r):`<${n}?>`}))}(i,n):"Error",o=`${this.serviceName}: ${s} (${r}).`;return new v(r,o,n)}}const w=/\{\$([^}]+)}/g;function I(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}function T(t,e){if(t===e)return!0;const n=Object.keys(t),r=Object.keys(e);for(const i of n){if(!r.includes(i))return!1;const n=t[i],s=e[i];if(_(n)&&_(s)){if(!T(n,s))return!1}else if(n!==s)return!1}for(const t of r)if(!n.includes(t))return!1;return!0}function _(t){return null!==t&&"object"==typeof t}function E(t){const e=[];for(const[n,r]of Object.entries(t))Array.isArray(r)?r.forEach((t=>{e.push(encodeURIComponent(n)+"="+encodeURIComponent(t))})):e.push(encodeURIComponent(n)+"="+encodeURIComponent(r));return e.length?"&"+e.join("&"):""}function S(t){const e={};return t.replace(/^\?/,"").split("&").forEach((t=>{if(t){const[n,r]=t.split("=");e[decodeURIComponent(n)]=decodeURIComponent(r)}})),e}function k(t){const e=t.indexOf("?");if(!e)return"";const n=t.indexOf("#",e);return t.substring(e,n>0?n:void 0)}function A(t,e){const n=new N(t,e);return n.subscribe.bind(n)}class N{constructor(t,e){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=e,this.task.then((()=>{t(this)})).catch((t=>{this.error(t)}))}next(t){this.forEachObserver((e=>{e.next(t)}))}error(t){this.forEachObserver((e=>{e.error(t)})),this.close(t)}complete(){this.forEachObserver((t=>{t.complete()})),this.close()}subscribe(t,e,n){let r;if(void 0===t&&void 0===e&&void 0===n)throw new Error("Missing Observer.");r=function(t,e){if("object"!=typeof t||null===t)return!1;for(const e of["next","error","complete"])if(e in t&&"function"==typeof t[e])return!0;return!1}(t)?t:{next:t,error:e,complete:n},void 0===r.next&&(r.next=x),void 0===r.error&&(r.error=x),void 0===r.complete&&(r.complete=x);const i=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then((()=>{try{this.finalError?r.error(this.finalError):r.complete()}catch(t){}})),this.observers.push(r),i}unsubscribeOne(t){void 0!==this.observers&&void 0!==this.observers[t]&&(delete this.observers[t],this.observerCount-=1,0===this.observerCount&&void 0!==this.onNoObservers&&this.onNoObservers(this))}forEachObserver(t){if(!this.finalized)for(let e=0;e<this.observers.length;e++)this.sendOne(e,t)}sendOne(t,e){this.task.then((()=>{if(void 0!==this.observers&&void 0!==this.observers[t])try{e(this.observers[t])}catch(t){"undefined"!=typeof console&&console.error&&console.error(t)}}))}close(t){this.finalized||(this.finalized=!0,void 0!==t&&(this.finalError=t),this.task.then((()=>{this.observers=void 0,this.onNoObservers=void 0})))}}function x(){}function C(t){return t&&t._delegate?t._delegate:t}},8060:(t,e,n)=>{"use strict";n.r(e),n.d(e,{default:()=>c,useAsyncStorage:()=>a});const r=n(942).bind({concatArrays:!0,ignoreUndefined:!0}),i=(t,e)=>new Promise(((n,r)=>{try{const r=t();e&&e(null,r),n(r)}catch(t){e&&e(t),r(t)}})),s=(t,e,n)=>Promise.all(t).then((t=>{const r=n?n(t):null;return e&&e(null,r),Promise.resolve(r)}),(t=>(e&&e(t),Promise.reject(t))));class o{static getItem(t,e){return i((()=>window.localStorage.getItem(t)),e)}static setItem(t,e,n){return i((()=>{window.localStorage.setItem(t,e)}),n)}static removeItem(t,e){return i((()=>window.localStorage.removeItem(t)),e)}static mergeItem(t,e,n){return i((()=>{((t,e)=>{const n=window.localStorage.getItem(t),i=JSON.parse(n),s=JSON.parse(e),o=JSON.stringify(r(i,s));window.localStorage.setItem(t,o)})(t,e)}),n)}static clear(t){return i((()=>{window.localStorage.clear()}),t)}static getAllKeys(t){return i((()=>{const t=window.localStorage.length,e=[];for(let n=0;n<t;n+=1){const t=window.localStorage.key(n);e.push(t)}return e}),t)}static flushGetRequests(){}static multiGet(t,e){const n=t.map((t=>o.getItem(t)));return s(n,e,(e=>e.map(((e,n)=>[t[n],e]))))}static multiSet(t,e){const n=t.map((t=>o.setItem(t[0],t[1])));return s(n,e)}static multiRemove(t,e){const n=t.map((t=>o.removeItem(t)));return s(n,e)}static multiMerge(t,e){const n=t.map((t=>o.mergeItem(t[0],t[1])));return s(n,e)}}function a(t){return{getItem:(...e)=>o.getItem(t,...e),setItem:(...e)=>o.setItem(t,...e),mergeItem:(...e)=>o.mergeItem(t,...e),removeItem:(...e)=>o.removeItem(t,...e)}}const c=o},9669:(t,e,n)=>{t.exports=n(1609)},5448:(t,e,n)=>{"use strict";var r=n(4867),i=n(6026),s=n(4372),o=n(5327),a=n(4097),c=n(4109),u=n(7985),h=n(5061),l=n(5655),d=n(5263);t.exports=function(t){return new Promise((function(e,n){var f,p=t.data,m=t.headers,g=t.responseType;function y(){t.cancelToken&&t.cancelToken.unsubscribe(f),t.signal&&t.signal.removeEventListener("abort",f)}r.isFormData(p)&&delete m["Content-Type"];var v=new XMLHttpRequest;if(t.auth){var b=t.auth.username||"",w=t.auth.password?unescape(encodeURIComponent(t.auth.password)):"";m.Authorization="Basic "+btoa(b+":"+w)}var I=a(t.baseURL,t.url);function T(){if(v){var r="getAllResponseHeaders"in v?c(v.getAllResponseHeaders()):null,s={data:g&&"text"!==g&&"json"!==g?v.response:v.responseText,status:v.status,statusText:v.statusText,headers:r,config:t,request:v};i((function(t){e(t),y()}),(function(t){n(t),y()}),s),v=null}}if(v.open(t.method.toUpperCase(),o(I,t.params,t.paramsSerializer),!0),v.timeout=t.timeout,"onloadend"in v?v.onloadend=T:v.onreadystatechange=function(){v&&4===v.readyState&&(0!==v.status||v.responseURL&&0===v.responseURL.indexOf("file:"))&&setTimeout(T)},v.onabort=function(){v&&(n(h("Request aborted",t,"ECONNABORTED",v)),v=null)},v.onerror=function(){n(h("Network Error",t,null,v)),v=null},v.ontimeout=function(){var e=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",r=t.transitional||l.transitional;t.timeoutErrorMessage&&(e=t.timeoutErrorMessage),n(h(e,t,r.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",v)),v=null},r.isStandardBrowserEnv()){var _=(t.withCredentials||u(I))&&t.xsrfCookieName?s.read(t.xsrfCookieName):void 0;_&&(m[t.xsrfHeaderName]=_)}"setRequestHeader"in v&&r.forEach(m,(function(t,e){void 0===p&&"content-type"===e.toLowerCase()?delete m[e]:v.setRequestHeader(e,t)})),r.isUndefined(t.withCredentials)||(v.withCredentials=!!t.withCredentials),g&&"json"!==g&&(v.responseType=t.responseType),"function"==typeof t.onDownloadProgress&&v.addEventListener("progress",t.onDownloadProgress),"function"==typeof t.onUploadProgress&&v.upload&&v.upload.addEventListener("progress",t.onUploadProgress),(t.cancelToken||t.signal)&&(f=function(t){v&&(n(!t||t&&t.type?new d("canceled"):t),v.abort(),v=null)},t.cancelToken&&t.cancelToken.subscribe(f),t.signal&&(t.signal.aborted?f():t.signal.addEventListener("abort",f))),p||(p=null),v.send(p)}))}},1609:(t,e,n)=>{"use strict";var r=n(4867),i=n(1849),s=n(321),o=n(7185),a=function t(e){var n=new s(e),a=i(s.prototype.request,n);return r.extend(a,s.prototype,n),r.extend(a,n),a.create=function(n){return t(o(e,n))},a}(n(5655));a.Axios=s,a.Cancel=n(5263),a.CancelToken=n(4972),a.isCancel=n(6502),a.VERSION=n(7288).version,a.all=function(t){return Promise.all(t)},a.spread=n(8713),a.isAxiosError=n(6268),t.exports=a,t.exports.default=a},5263:t=>{"use strict";function e(t){this.message=t}e.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},e.prototype.__CANCEL__=!0,t.exports=e},4972:(t,e,n)=>{"use strict";var r=n(5263);function i(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");var e;this.promise=new Promise((function(t){e=t}));var n=this;this.promise.then((function(t){if(n._listeners){var e,r=n._listeners.length;for(e=0;e<r;e++)n._listeners[e](t);n._listeners=null}})),this.promise.then=function(t){var e,r=new Promise((function(t){n.subscribe(t),e=t})).then(t);return r.cancel=function(){n.unsubscribe(e)},r},t((function(t){n.reason||(n.reason=new r(t),e(n.reason))}))}i.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},i.prototype.subscribe=function(t){this.reason?t(this.reason):this._listeners?this._listeners.push(t):this._listeners=[t]},i.prototype.unsubscribe=function(t){if(this._listeners){var e=this._listeners.indexOf(t);-1!==e&&this._listeners.splice(e,1)}},i.source=function(){var t;return{token:new i((function(e){t=e})),cancel:t}},t.exports=i},6502:t=>{"use strict";t.exports=function(t){return!(!t||!t.__CANCEL__)}},321:(t,e,n)=>{"use strict";var r=n(4867),i=n(5327),s=n(782),o=n(3572),a=n(7185),c=n(4875),u=c.validators;function h(t){this.defaults=t,this.interceptors={request:new s,response:new s}}h.prototype.request=function(t){"string"==typeof t?(t=arguments[1]||{}).url=arguments[0]:t=t||{},(t=a(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var e=t.transitional;void 0!==e&&c.assertOptions(e,{silentJSONParsing:u.transitional(u.boolean),forcedJSONParsing:u.transitional(u.boolean),clarifyTimeoutError:u.transitional(u.boolean)},!1);var n=[],r=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(r=r&&e.synchronous,n.unshift(e.fulfilled,e.rejected))}));var i,s=[];if(this.interceptors.response.forEach((function(t){s.push(t.fulfilled,t.rejected)})),!r){var h=[o,void 0];for(Array.prototype.unshift.apply(h,n),h=h.concat(s),i=Promise.resolve(t);h.length;)i=i.then(h.shift(),h.shift());return i}for(var l=t;n.length;){var d=n.shift(),f=n.shift();try{l=d(l)}catch(t){f(t);break}}try{i=o(l)}catch(t){return Promise.reject(t)}for(;s.length;)i=i.then(s.shift(),s.shift());return i},h.prototype.getUri=function(t){return t=a(this.defaults,t),i(t.url,t.params,t.paramsSerializer).replace(/^\?/,"")},r.forEach(["delete","get","head","options"],(function(t){h.prototype[t]=function(e,n){return this.request(a(n||{},{method:t,url:e,data:(n||{}).data}))}})),r.forEach(["post","put","patch"],(function(t){h.prototype[t]=function(e,n,r){return this.request(a(r||{},{method:t,url:e,data:n}))}})),t.exports=h},782:(t,e,n)=>{"use strict";var r=n(4867);function i(){this.handlers=[]}i.prototype.use=function(t,e,n){return this.handlers.push({fulfilled:t,rejected:e,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1},i.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},i.prototype.forEach=function(t){r.forEach(this.handlers,(function(e){null!==e&&t(e)}))},t.exports=i},4097:(t,e,n)=>{"use strict";var r=n(1793),i=n(7303);t.exports=function(t,e){return t&&!r(e)?i(t,e):e}},5061:(t,e,n)=>{"use strict";var r=n(481);t.exports=function(t,e,n,i,s){var o=new Error(t);return r(o,e,n,i,s)}},3572:(t,e,n)=>{"use strict";var r=n(4867),i=n(8527),s=n(6502),o=n(5655),a=n(5263);function c(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new a("canceled")}t.exports=function(t){return c(t),t.headers=t.headers||{},t.data=i.call(t,t.data,t.headers,t.transformRequest),t.headers=r.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),r.forEach(["delete","get","head","post","put","patch","common"],(function(e){delete t.headers[e]})),(t.adapter||o.adapter)(t).then((function(e){return c(t),e.data=i.call(t,e.data,e.headers,t.transformResponse),e}),(function(e){return s(e)||(c(t),e&&e.response&&(e.response.data=i.call(t,e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)}))}},481:t=>{"use strict";t.exports=function(t,e,n,r,i){return t.config=e,n&&(t.code=n),t.request=r,t.response=i,t.isAxiosError=!0,t.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}},t}},7185:(t,e,n)=>{"use strict";var r=n(4867);t.exports=function(t,e){e=e||{};var n={};function i(t,e){return r.isPlainObject(t)&&r.isPlainObject(e)?r.merge(t,e):r.isPlainObject(e)?r.merge({},e):r.isArray(e)?e.slice():e}function s(n){return r.isUndefined(e[n])?r.isUndefined(t[n])?void 0:i(void 0,t[n]):i(t[n],e[n])}function o(t){if(!r.isUndefined(e[t]))return i(void 0,e[t])}function a(n){return r.isUndefined(e[n])?r.isUndefined(t[n])?void 0:i(void 0,t[n]):i(void 0,e[n])}function c(n){return n in e?i(t[n],e[n]):n in t?i(void 0,t[n]):void 0}var u={url:o,method:o,data:o,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:c};return r.forEach(Object.keys(t).concat(Object.keys(e)),(function(t){var e=u[t]||s,i=e(t);r.isUndefined(i)&&e!==c||(n[t]=i)})),n}},6026:(t,e,n)=>{"use strict";var r=n(5061);t.exports=function(t,e,n){var i=n.config.validateStatus;n.status&&i&&!i(n.status)?e(r("Request failed with status code "+n.status,n.config,null,n.request,n)):t(n)}},8527:(t,e,n)=>{"use strict";var r=n(4867),i=n(5655);t.exports=function(t,e,n){var s=this||i;return r.forEach(n,(function(n){t=n.call(s,t,e)})),t}},5655:(t,e,n)=>{"use strict";var r=n(4867),i=n(6016),s=n(481),o={"Content-Type":"application/x-www-form-urlencoded"};function a(t,e){!r.isUndefined(t)&&r.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}var c,u={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(c=n(5448)),c),transformRequest:[function(t,e){return i(e,"Accept"),i(e,"Content-Type"),r.isFormData(t)||r.isArrayBuffer(t)||r.isBuffer(t)||r.isStream(t)||r.isFile(t)||r.isBlob(t)?t:r.isArrayBufferView(t)?t.buffer:r.isURLSearchParams(t)?(a(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString()):r.isObject(t)||e&&"application/json"===e["Content-Type"]?(a(e,"application/json"),function(t,e,n){if(r.isString(t))try{return(0,JSON.parse)(t),r.trim(t)}catch(t){if("SyntaxError"!==t.name)throw t}return(0,JSON.stringify)(t)}(t)):t}],transformResponse:[function(t){var e=this.transitional||u.transitional,n=e&&e.silentJSONParsing,i=e&&e.forcedJSONParsing,o=!n&&"json"===this.responseType;if(o||i&&r.isString(t)&&t.length)try{return JSON.parse(t)}catch(t){if(o){if("SyntaxError"===t.name)throw s(t,this,"E_JSON_PARSE");throw t}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};r.forEach(["delete","get","head"],(function(t){u.headers[t]={}})),r.forEach(["post","put","patch"],(function(t){u.headers[t]=r.merge(o)})),t.exports=u},7288:t=>{t.exports={version:"0.24.0"}},1849:t=>{"use strict";t.exports=function(t,e){return function(){for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];return t.apply(e,n)}}},5327:(t,e,n)=>{"use strict";var r=n(4867);function i(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}t.exports=function(t,e,n){if(!e)return t;var s;if(n)s=n(e);else if(r.isURLSearchParams(e))s=e.toString();else{var o=[];r.forEach(e,(function(t,e){null!=t&&(r.isArray(t)?e+="[]":t=[t],r.forEach(t,(function(t){r.isDate(t)?t=t.toISOString():r.isObject(t)&&(t=JSON.stringify(t)),o.push(i(e)+"="+i(t))})))})),s=o.join("&")}if(s){var a=t.indexOf("#");-1!==a&&(t=t.slice(0,a)),t+=(-1===t.indexOf("?")?"?":"&")+s}return t}},7303:t=>{"use strict";t.exports=function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t}},4372:(t,e,n)=>{"use strict";var r=n(4867);t.exports=r.isStandardBrowserEnv()?{write:function(t,e,n,i,s,o){var a=[];a.push(t+"="+encodeURIComponent(e)),r.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),r.isString(i)&&a.push("path="+i),r.isString(s)&&a.push("domain="+s),!0===o&&a.push("secure"),document.cookie=a.join("; ")},read:function(t){var e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},1793:t=>{"use strict";t.exports=function(t){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(t)}},6268:t=>{"use strict";t.exports=function(t){return"object"==typeof t&&!0===t.isAxiosError}},7985:(t,e,n)=>{"use strict";var r=n(4867);t.exports=r.isStandardBrowserEnv()?function(){var t,e=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function i(t){var r=t;return e&&(n.setAttribute("href",r),r=n.href),n.setAttribute("href",r),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return t=i(window.location.href),function(e){var n=r.isString(e)?i(e):e;return n.protocol===t.protocol&&n.host===t.host}}():function(){return!0}},6016:(t,e,n)=>{"use strict";var r=n(4867);t.exports=function(t,e){r.forEach(t,(function(n,r){r!==e&&r.toUpperCase()===e.toUpperCase()&&(t[e]=n,delete t[r])}))}},4109:(t,e,n)=>{"use strict";var r=n(4867),i=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];t.exports=function(t){var e,n,s,o={};return t?(r.forEach(t.split("\n"),(function(t){if(s=t.indexOf(":"),e=r.trim(t.substr(0,s)).toLowerCase(),n=r.trim(t.substr(s+1)),e){if(o[e]&&i.indexOf(e)>=0)return;o[e]="set-cookie"===e?(o[e]?o[e]:[]).concat([n]):o[e]?o[e]+", "+n:n}})),o):o}},8713:t=>{"use strict";t.exports=function(t){return function(e){return t.apply(null,e)}}},4875:(t,e,n)=>{"use strict";var r=n(7288).version,i={};["object","boolean","number","function","string","symbol"].forEach((function(t,e){i[t]=function(n){return typeof n===t||"a"+(e<1?"n ":" ")+t}}));var s={};i.transitional=function(t,e,n){function i(t,e){return"[Axios v"+r+"] Transitional option '"+t+"'"+e+(n?". "+n:"")}return function(n,r,o){if(!1===t)throw new Error(i(r," has been removed"+(e?" in "+e:"")));return e&&!s[r]&&(s[r]=!0,console.warn(i(r," has been deprecated since v"+e+" and will be removed in the near future"))),!t||t(n,r,o)}},t.exports={assertOptions:function(t,e,n){if("object"!=typeof t)throw new TypeError("options must be an object");for(var r=Object.keys(t),i=r.length;i-- >0;){var s=r[i],o=e[s];if(o){var a=t[s],c=void 0===a||o(a,s,t);if(!0!==c)throw new TypeError("option "+s+" must be "+c)}else if(!0!==n)throw Error("Unknown option "+s)}},validators:i}},4867:(t,e,n)=>{"use strict";var r=n(1849),i=Object.prototype.toString;function s(t){return"[object Array]"===i.call(t)}function o(t){return void 0===t}function a(t){return null!==t&&"object"==typeof t}function c(t){if("[object Object]"!==i.call(t))return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function u(t){return"[object Function]"===i.call(t)}function h(t,e){if(null!=t)if("object"!=typeof t&&(t=[t]),s(t))for(var n=0,r=t.length;n<r;n++)e.call(null,t[n],n,t);else for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.call(null,t[i],i,t)}t.exports={isArray:s,isArrayBuffer:function(t){return"[object ArrayBuffer]"===i.call(t)},isBuffer:function(t){return null!==t&&!o(t)&&null!==t.constructor&&!o(t.constructor)&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)},isFormData:function(t){return"undefined"!=typeof FormData&&t instanceof FormData},isArrayBufferView:function(t){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&t.buffer instanceof ArrayBuffer},isString:function(t){return"string"==typeof t},isNumber:function(t){return"number"==typeof t},isObject:a,isPlainObject:c,isUndefined:o,isDate:function(t){return"[object Date]"===i.call(t)},isFile:function(t){return"[object File]"===i.call(t)},isBlob:function(t){return"[object Blob]"===i.call(t)},isFunction:u,isStream:function(t){return a(t)&&u(t.pipe)},isURLSearchParams:function(t){return"undefined"!=typeof URLSearchParams&&t instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&"undefined"!=typeof window&&"undefined"!=typeof document},forEach:h,merge:function t(){var e={};function n(n,r){c(e[r])&&c(n)?e[r]=t(e[r],n):c(n)?e[r]=t({},n):s(n)?e[r]=n.slice():e[r]=n}for(var r=0,i=arguments.length;r<i;r++)h(arguments[r],n);return e},extend:function(t,e,n){return h(e,(function(e,i){t[i]=n&&"function"==typeof e?r(e,n):e})),t},trim:function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")},stripBOM:function(t){return 65279===t.charCodeAt(0)&&(t=t.slice(1)),t}}},5503:(t,e,n)=>{"use strict";n.r(e),n.d(e,{FirebaseError:()=>r.ZR,SDK_VERSION:()=>r.Jn,_DEFAULT_ENTRY_NAME:()=>r.l4,_addComponent:()=>r.H9,_addOrOverwriteComponent:()=>r.Vr,_apps:()=>r.Af,_clearComponents:()=>r.Z8,_components:()=>r.lz,_getProvider:()=>r.qX,_registerComponent:()=>r.Xd,_removeServiceInstance:()=>r.wN,deleteApp:()=>r.P2,getApp:()=>r.Mq,getApps:()=>r.C6,initializeApp:()=>r.ZF,onLog:()=>r.TP,registerVersion:()=>r.KN,setLogLevel:()=>r.Ub});var r=n(2238);(0,r.KN)("firebase","9.6.2","app")},900:(t,e,n)=>{"use strict";n.r(e),n.d(e,{ActionCodeOperation:()=>d,ActionCodeURL:()=>Pt,AuthCredential:()=>St,AuthErrorCodes:()=>g,EmailAuthCredential:()=>xt,EmailAuthProvider:()=>Mt,FacebookAuthProvider:()=>jt,FactorId:()=>c,GithubAuthProvider:()=>Bt,GoogleAuthProvider:()=>qt,OAuthCredential:()=>Dt,OAuthProvider:()=>Vt,OperationType:()=>l,PhoneAuthCredential:()=>Rt,PhoneAuthProvider:()=>Pn,PhoneMultiFactorGenerator:()=>_r,ProviderId:()=>u,RecaptchaVerifier:()=>An,SAMLAuthProvider:()=>Kt,SignInMethod:()=>h,TwitterAuthProvider:()=>Wt,applyActionCode:()=>fe,browserLocalPersistence:()=>Je,browserPopupRedirectResolver:()=>Ir,browserSessionPersistence:()=>Xe,checkActionCode:()=>pe,confirmPasswordReset:()=>de,connectAuthEmulator:()=>Tt,createUserWithEmailAndPassword:()=>ge,debugErrorMap:()=>f,deleteUser:()=>qe,fetchSignInMethodsForEmail:()=>Ie,getAdditionalUserInfo:()=>Pe,getAuth:()=>Nr,getIdToken:()=>G,getIdTokenResult:()=>H,getMultiFactorResolver:()=>Ke,getRedirectResult:()=>tr,inMemoryPersistence:()=>st,indexedDBLocalPersistence:()=>mn,initializeAuth:()=>x,isSignInWithEmailLink:()=>be,linkWithCredential:()=>se,linkWithPhoneNumber:()=>Cn,linkWithPopup:()=>Kn,linkWithRedirect:()=>Xn,multiFactor:()=>He,onAuthStateChanged:()=>Fe,onIdTokenChanged:()=>Me,parseActionCodeURL:()=>Lt,prodErrorMap:()=>p,reauthenticateWithCredential:()=>oe,reauthenticateWithPhoneNumber:()=>Dn,reauthenticateWithPopup:()=>zn,reauthenticateWithRedirect:()=>Zn,reload:()=>tt,sendEmailVerification:()=>Te,sendPasswordResetEmail:()=>le,sendSignInLinkToEmail:()=>ve,setPersistence:()=>Le,signInAnonymously:()=>Yt,signInWithCredential:()=>ie,signInWithCustomToken:()=>ae,signInWithEmailAndPassword:()=>ye,signInWithEmailLink:()=>we,signInWithPhoneNumber:()=>xn,signInWithPopup:()=>Bn,signInWithRedirect:()=>Jn,signOut:()=>je,unlink:()=>Xt,updateCurrentUser:()=>Ve,updateEmail:()=>Se,updatePassword:()=>ke,updatePhoneNumber:()=>Rn,updateProfile:()=>Ee,useDeviceLanguage:()=>Ue,verifyBeforeUpdateEmail:()=>_e,verifyPasswordResetCode:()=>me});var r=n(4444),i=n(2238);function s(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}Object.create,Object.create;var o=n(3333),a=n(8463);const c={PHONE:"phone"},u={FACEBOOK:"facebook.com",GITHUB:"github.com",GOOGLE:"google.com",PASSWORD:"password",PHONE:"phone",TWITTER:"twitter.com"},h={EMAIL_LINK:"emailLink",EMAIL_PASSWORD:"password",FACEBOOK:"facebook.com",GITHUB:"github.com",GOOGLE:"google.com",PHONE:"phone",TWITTER:"twitter.com"},l={LINK:"link",REAUTHENTICATE:"reauthenticate",SIGN_IN:"signIn"},d={EMAIL_SIGNIN:"EMAIL_SIGNIN",PASSWORD_RESET:"PASSWORD_RESET",RECOVER_EMAIL:"RECOVER_EMAIL",REVERT_SECOND_FACTOR_ADDITION:"REVERT_SECOND_FACTOR_ADDITION",VERIFY_AND_CHANGE_EMAIL:"VERIFY_AND_CHANGE_EMAIL",VERIFY_EMAIL:"VERIFY_EMAIL"};const f=function(){return{"admin-restricted-operation":"This operation is restricted to administrators only.","argument-error":"","app-not-authorized":"This app, identified by the domain where it's hosted, is not authorized to use Firebase Authentication with the provided API key. Review your key configuration in the Google API console.","app-not-installed":"The requested mobile application corresponding to the identifier (Android package name or iOS bundle ID) provided is not installed on this device.","captcha-check-failed":"The reCAPTCHA response token provided is either invalid, expired, already used or the domain associated with it does not match the list of whitelisted domains.","code-expired":"The SMS code has expired. Please re-send the verification code to try again.","cordova-not-ready":"Cordova framework is not ready.","cors-unsupported":"This browser is not supported.","credential-already-in-use":"This credential is already associated with a different user account.","custom-token-mismatch":"The custom token corresponds to a different audience.","requires-recent-login":"This operation is sensitive and requires recent authentication. Log in again before retrying this request.","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.","dynamic-link-not-activated":"Please activate Dynamic Links in the Firebase Console and agree to the terms and conditions.","email-change-needs-verification":"Multi-factor users must always have a verified email.","email-already-in-use":"The email address is already in use by another account.","emulator-config-failed":'Auth instance has already been used to make a network call. Auth can no longer be configured to use the emulator. Try calling "connectAuthEmulator()" sooner.',"expired-action-code":"The action code has expired.","cancelled-popup-request":"This operation has been cancelled due to another conflicting popup being opened.","internal-error":"An internal AuthError has occurred.","invalid-app-credential":"The phone verification request contains an invalid application verifier. The reCAPTCHA token response is either invalid or expired.","invalid-app-id":"The mobile app identifier is not registed for the current project.","invalid-user-token":"This user's credential isn't valid for this project. This can happen if the user's token has been tampered with, or if the user isn't for the project associated with this API key.","invalid-auth-event":"An internal AuthError has occurred.","invalid-verification-code":"The SMS verification code used to create the phone auth credential is invalid. Please resend the verification code sms and be sure to use the verification code provided by the user.","invalid-continue-uri":"The continue URL provided in the request is invalid.","invalid-cordova-configuration":"The following Cordova plugins must be installed to enable OAuth sign-in: cordova-plugin-buildinfo, cordova-universal-links-plugin, cordova-plugin-browsertab, cordova-plugin-inappbrowser and cordova-plugin-customurlscheme.","invalid-custom-token":"The custom token format is incorrect. Please check the documentation.","invalid-dynamic-link-domain":"The provided dynamic link domain is not configured or authorized for the current project.","invalid-email":"The email address is badly formatted.","invalid-emulator-scheme":"Emulator URL must start with a valid scheme (http:// or https://).","invalid-api-key":"Your API key is invalid, please check you have copied it correctly.","invalid-cert-hash":"The SHA-1 certificate hash provided is invalid.","invalid-credential":"The supplied auth credential is malformed or has expired.","invalid-message-payload":"The email template corresponding to this action contains invalid characters in its message. Please fix by going to the Auth email templates section in the Firebase Console.","invalid-multi-factor-session":"The request does not contain a valid proof of first factor successful sign-in.","invalid-oauth-provider":"EmailAuthProvider is not supported for this operation. This operation only supports OAuth providers.","invalid-oauth-client-id":"The OAuth client ID provided is either invalid or does not match the specified API key.","unauthorized-domain":"This domain is not authorized for OAuth operations for your Firebase project. Edit the list of authorized domains from the Firebase console.","invalid-action-code":"The action code is invalid. This can happen if the code is malformed, expired, or has already been used.","wrong-password":"The password is invalid or the user does not have a password.","invalid-persistence-type":"The specified persistence type is invalid. It can only be local, session or none.","invalid-phone-number":"The format of the phone number provided is incorrect. Please enter the phone number in a format that can be parsed into E.164 format. E.164 phone numbers are written in the format [+][country code][subscriber number including area code].","invalid-provider-id":"The specified provider ID is invalid.","invalid-recipient-email":"The email corresponding to this action failed to send as the provided recipient email address is invalid.","invalid-sender":"The email template corresponding to this action contains an invalid sender email or name. Please fix by going to the Auth email templates section in the Firebase Console.","invalid-verification-id":"The verification ID used to create the phone auth credential is invalid.","invalid-tenant-id":"The Auth instance's tenant ID is invalid.","missing-android-pkg-name":"An Android Package Name must be provided if the Android App is required to be installed.","auth-domain-config-required":"Be sure to include authDomain when calling firebase.initializeApp(), by following the instructions in the Firebase console.","missing-app-credential":"The phone verification request is missing an application verifier assertion. A reCAPTCHA response token needs to be provided.","missing-verification-code":"The phone auth credential was created with an empty SMS verification code.","missing-continue-uri":"A continue URL must be provided in the request.","missing-iframe-start":"An internal AuthError has occurred.","missing-ios-bundle-id":"An iOS Bundle ID must be provided if an App Store ID is provided.","missing-or-invalid-nonce":"The request does not contain a valid nonce. This can occur if the SHA-256 hash of the provided raw nonce does not match the hashed nonce in the ID token payload.","missing-multi-factor-info":"No second factor identifier is provided.","missing-multi-factor-session":"The request is missing proof of first factor successful sign-in.","missing-phone-number":"To send verification codes, provide a phone number for the recipient.","missing-verification-id":"The phone auth credential was created with an empty verification ID.","app-deleted":"This instance of FirebaseApp has been deleted.","multi-factor-info-not-found":"The user does not have a second factor matching the identifier provided.","multi-factor-auth-required":"Proof of ownership of a second factor is required to complete sign-in.","account-exists-with-different-credential":"An account already exists with the same email address but different sign-in credentials. Sign in using a provider associated with this email address.","network-request-failed":"A network AuthError (such as timeout, interrupted connection or unreachable host) has occurred.","no-auth-event":"An internal AuthError has occurred.","no-such-provider":"User was not linked to an account with the given provider.","null-user":"A null user object was provided as the argument for an operation which requires a non-null user object.","operation-not-allowed":"The given sign-in provider is disabled for this Firebase project. Enable it in the Firebase console, under the sign-in method tab of the Auth section.","operation-not-supported-in-this-environment":'This operation is not supported in the environment this application is running on. "location.protocol" must be http, https or chrome-extension and web storage must be enabled.',"popup-blocked":"Unable to establish a connection with the popup. It may have been blocked by the browser.","popup-closed-by-user":"The popup has been closed by the user before finalizing the operation.","provider-already-linked":"User can only be linked to one identity for the given provider.","quota-exceeded":"The project's quota for this operation has been exceeded.","redirect-cancelled-by-user":"The redirect operation has been cancelled by the user before finalizing.","redirect-operation-pending":"A redirect sign-in operation is already pending.","rejected-credential":"The request contains malformed or mismatching credentials.","second-factor-already-in-use":"The second factor is already enrolled on this account.","maximum-second-factor-count-exceeded":"The maximum allowed number of second factors on a user has been exceeded.","tenant-id-mismatch":"The provided tenant ID does not match the Auth instance's tenant ID",timeout:"The operation has timed out.","user-token-expired":"The user's credential is no longer valid. The user must sign in again.","too-many-requests":"We have blocked all requests from this device due to unusual activity. Try again later.","unauthorized-continue-uri":"The domain of the continue URL is not whitelisted. Please whitelist the domain in the Firebase console.","unsupported-first-factor":"Enrolling a second factor or signing in with a multi-factor account requires sign-in with a supported first factor.","unsupported-persistence-type":"The current environment does not support the specified persistence type.","unsupported-tenant-operation":"This operation is not supported in a multi-tenant context.","unverified-email":"The operation requires a verified email.","user-cancelled":"The user did not grant your application the permissions it requested.","user-not-found":"There is no user record corresponding to this identifier. The user may have been deleted.","user-disabled":"The user account has been disabled by an administrator.","user-mismatch":"The supplied credentials do not correspond to the previously signed in user.","user-signed-out":"","weak-password":"The password must be 6 characters long or more.","web-storage-unsupported":"This browser is not supported or 3rd party cookies and data may be disabled.","already-initialized":"initializeAuth() has already been called with different options. To avoid this error, call initializeAuth() with the same options as when it was originally called, or call getAuth() to return the already initialized instance."}},p=function(){return{"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."}},m=new r.LL("auth","Firebase",{"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."}),g={ADMIN_ONLY_OPERATION:"auth/admin-restricted-operation",ARGUMENT_ERROR:"auth/argument-error",APP_NOT_AUTHORIZED:"auth/app-not-authorized",APP_NOT_INSTALLED:"auth/app-not-installed",CAPTCHA_CHECK_FAILED:"auth/captcha-check-failed",CODE_EXPIRED:"auth/code-expired",CORDOVA_NOT_READY:"auth/cordova-not-ready",CORS_UNSUPPORTED:"auth/cors-unsupported",CREDENTIAL_ALREADY_IN_USE:"auth/credential-already-in-use",CREDENTIAL_MISMATCH:"auth/custom-token-mismatch",CREDENTIAL_TOO_OLD_LOGIN_AGAIN:"auth/requires-recent-login",DEPENDENT_SDK_INIT_BEFORE_AUTH:"auth/dependent-sdk-initialized-before-auth",DYNAMIC_LINK_NOT_ACTIVATED:"auth/dynamic-link-not-activated",EMAIL_CHANGE_NEEDS_VERIFICATION:"auth/email-change-needs-verification",EMAIL_EXISTS:"auth/email-already-in-use",EMULATOR_CONFIG_FAILED:"auth/emulator-config-failed",EXPIRED_OOB_CODE:"auth/expired-action-code",EXPIRED_POPUP_REQUEST:"auth/cancelled-popup-request",INTERNAL_ERROR:"auth/internal-error",INVALID_API_KEY:"auth/invalid-api-key",INVALID_APP_CREDENTIAL:"auth/invalid-app-credential",INVALID_APP_ID:"auth/invalid-app-id",INVALID_AUTH:"auth/invalid-user-token",INVALID_AUTH_EVENT:"auth/invalid-auth-event",INVALID_CERT_HASH:"auth/invalid-cert-hash",INVALID_CODE:"auth/invalid-verification-code",INVALID_CONTINUE_URI:"auth/invalid-continue-uri",INVALID_CORDOVA_CONFIGURATION:"auth/invalid-cordova-configuration",INVALID_CUSTOM_TOKEN:"auth/invalid-custom-token",INVALID_DYNAMIC_LINK_DOMAIN:"auth/invalid-dynamic-link-domain",INVALID_EMAIL:"auth/invalid-email",INVALID_EMULATOR_SCHEME:"auth/invalid-emulator-scheme",INVALID_IDP_RESPONSE:"auth/invalid-credential",INVALID_MESSAGE_PAYLOAD:"auth/invalid-message-payload",INVALID_MFA_SESSION:"auth/invalid-multi-factor-session",INVALID_OAUTH_CLIENT_ID:"auth/invalid-oauth-client-id",INVALID_OAUTH_PROVIDER:"auth/invalid-oauth-provider",INVALID_OOB_CODE:"auth/invalid-action-code",INVALID_ORIGIN:"auth/unauthorized-domain",INVALID_PASSWORD:"auth/wrong-password",INVALID_PERSISTENCE:"auth/invalid-persistence-type",INVALID_PHONE_NUMBER:"auth/invalid-phone-number",INVALID_PROVIDER_ID:"auth/invalid-provider-id",INVALID_RECIPIENT_EMAIL:"auth/invalid-recipient-email",INVALID_SENDER:"auth/invalid-sender",INVALID_SESSION_INFO:"auth/invalid-verification-id",INVALID_TENANT_ID:"auth/invalid-tenant-id",MFA_INFO_NOT_FOUND:"auth/multi-factor-info-not-found",MFA_REQUIRED:"auth/multi-factor-auth-required",MISSING_ANDROID_PACKAGE_NAME:"auth/missing-android-pkg-name",MISSING_APP_CREDENTIAL:"auth/missing-app-credential",MISSING_AUTH_DOMAIN:"auth/auth-domain-config-required",MISSING_CODE:"auth/missing-verification-code",MISSING_CONTINUE_URI:"auth/missing-continue-uri",MISSING_IFRAME_START:"auth/missing-iframe-start",MISSING_IOS_BUNDLE_ID:"auth/missing-ios-bundle-id",MISSING_OR_INVALID_NONCE:"auth/missing-or-invalid-nonce",MISSING_MFA_INFO:"auth/missing-multi-factor-info",MISSING_MFA_SESSION:"auth/missing-multi-factor-session",MISSING_PHONE_NUMBER:"auth/missing-phone-number",MISSING_SESSION_INFO:"auth/missing-verification-id",MODULE_DESTROYED:"auth/app-deleted",NEED_CONFIRMATION:"auth/account-exists-with-different-credential",NETWORK_REQUEST_FAILED:"auth/network-request-failed",NULL_USER:"auth/null-user",NO_AUTH_EVENT:"auth/no-auth-event",NO_SUCH_PROVIDER:"auth/no-such-provider",OPERATION_NOT_ALLOWED:"auth/operation-not-allowed",OPERATION_NOT_SUPPORTED:"auth/operation-not-supported-in-this-environment",POPUP_BLOCKED:"auth/popup-blocked",POPUP_CLOSED_BY_USER:"auth/popup-closed-by-user",PROVIDER_ALREADY_LINKED:"auth/provider-already-linked",QUOTA_EXCEEDED:"auth/quota-exceeded",REDIRECT_CANCELLED_BY_USER:"auth/redirect-cancelled-by-user",REDIRECT_OPERATION_PENDING:"auth/redirect-operation-pending",REJECTED_CREDENTIAL:"auth/rejected-credential",SECOND_FACTOR_ALREADY_ENROLLED:"auth/second-factor-already-in-use",SECOND_FACTOR_LIMIT_EXCEEDED:"auth/maximum-second-factor-count-exceeded",TENANT_ID_MISMATCH:"auth/tenant-id-mismatch",TIMEOUT:"auth/timeout",TOKEN_EXPIRED:"auth/user-token-expired",TOO_MANY_ATTEMPTS_TRY_LATER:"auth/too-many-requests",UNAUTHORIZED_DOMAIN:"auth/unauthorized-continue-uri",UNSUPPORTED_FIRST_FACTOR:"auth/unsupported-first-factor",UNSUPPORTED_PERSISTENCE:"auth/unsupported-persistence-type",UNSUPPORTED_TENANT_OPERATION:"auth/unsupported-tenant-operation",UNVERIFIED_EMAIL:"auth/unverified-email",USER_CANCELLED:"auth/user-cancelled",USER_DELETED:"auth/user-not-found",USER_DISABLED:"auth/user-disabled",USER_MISMATCH:"auth/user-mismatch",USER_SIGNED_OUT:"auth/user-signed-out",WEAK_PASSWORD:"auth/weak-password",WEB_STORAGE_UNSUPPORTED:"auth/web-storage-unsupported",ALREADY_INITIALIZED:"auth/already-initialized"},y=new o.Yd("@firebase/auth");function v(t,...e){y.logLevel<=o.in.ERROR&&y.error(`Auth (${i.Jn}): ${t}`,...e)}function b(t,...e){throw _(t,...e)}function w(t,...e){return _(t,...e)}function I(t,e,n){const i=Object.assign(Object.assign({},p()),{[e]:n});return new r.LL("auth","Firebase",i).create(e,{appName:t.name})}function T(t,e,n){if(!(e instanceof n))throw n.name!==e.constructor.name&&b(t,"argument-error"),I(t,"argument-error",`Type of ${e.constructor.name} does not match expected instance.Did you pass a reference from a different Auth SDK?`)}function _(t,...e){if("string"!=typeof t){const n=e[0],r=[...e.slice(1)];return r[0]&&(r[0].appName=t.name),t._errorFactory.create(n,...r)}return m.create(t,...e)}function E(t,e,...n){if(!t)throw _(e,...n)}function S(t){const e="INTERNAL ASSERTION FAILED: "+t;throw v(e),new Error(e)}function k(t,e){t||S(e)}const A=new Map;function N(t){k(t instanceof Function,"Expected a class definition");let e=A.get(t);return e?(k(e instanceof t,"Instance stored in cache mismatched with class"),e):(e=new t,A.set(t,e),e)}function x(t,e){const n=(0,i.qX)(t,"auth");if(n.isInitialized()){const t=n.getImmediate(),i=n.getOptions();if((0,r.vZ)(i,null!=e?e:{}))return t;b(t,"already-initialized")}return n.initialize({options:e})}function C(){var t;return"undefined"!=typeof self&&(null===(t=self.location)||void 0===t?void 0:t.href)||""}function D(){return"http:"===O()||"https:"===O()}function O(){var t;return"undefined"!=typeof self&&(null===(t=self.location)||void 0===t?void 0:t.protocol)||null}class R{constructor(t,e){this.shortDelay=t,this.longDelay=e,k(e>t,"Short delay should be less than long delay!"),this.isMobile=(0,r.uI)()||(0,r.b$)()}get(){return"undefined"!=typeof navigator&&navigator&&"onLine"in navigator&&"boolean"==typeof navigator.onLine&&(D()||(0,r.ru)()||"connection"in navigator)&&!navigator.onLine?Math.min(5e3,this.shortDelay):this.isMobile?this.longDelay:this.shortDelay}}function P(t,e){k(t.emulator,"Emulator should always be set here");const{url:n}=t.emulator;return e?`${n}${e.startsWith("/")?e.slice(1):e}`:n}class L{static initialize(t,e,n){this.fetchImpl=t,e&&(this.headersImpl=e),n&&(this.responseImpl=n)}static fetch(){return this.fetchImpl?this.fetchImpl:"undefined"!=typeof self&&"fetch"in self?self.fetch:void S("Could not find fetch implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static headers(){return this.headersImpl?this.headersImpl:"undefined"!=typeof self&&"Headers"in self?self.Headers:void S("Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static response(){return this.responseImpl?this.responseImpl:"undefined"!=typeof self&&"Response"in self?self.Response:void S("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}}const M={CREDENTIAL_MISMATCH:"custom-token-mismatch",MISSING_CUSTOM_TOKEN:"internal-error",INVALID_IDENTIFIER:"invalid-email",MISSING_CONTINUE_URI:"internal-error",INVALID_PASSWORD:"wrong-password",MISSING_PASSWORD:"internal-error",EMAIL_EXISTS:"email-already-in-use",PASSWORD_LOGIN_DISABLED:"operation-not-allowed",INVALID_IDP_RESPONSE:"invalid-credential",INVALID_PENDING_TOKEN:"invalid-credential",FEDERATED_USER_ID_ALREADY_LINKED:"credential-already-in-use",MISSING_REQ_TYPE:"internal-error",EMAIL_NOT_FOUND:"user-not-found",RESET_PASSWORD_EXCEED_LIMIT:"too-many-requests",EXPIRED_OOB_CODE:"expired-action-code",INVALID_OOB_CODE:"invalid-action-code",MISSING_OOB_CODE:"internal-error",CREDENTIAL_TOO_OLD_LOGIN_AGAIN:"requires-recent-login",INVALID_ID_TOKEN:"invalid-user-token",TOKEN_EXPIRED:"user-token-expired",USER_NOT_FOUND:"user-token-expired",TOO_MANY_ATTEMPTS_TRY_LATER:"too-many-requests",INVALID_CODE:"invalid-verification-code",INVALID_SESSION_INFO:"invalid-verification-id",INVALID_TEMPORARY_PROOF:"invalid-credential",MISSING_SESSION_INFO:"missing-verification-id",SESSION_EXPIRED:"code-expired",MISSING_ANDROID_PACKAGE_NAME:"missing-android-pkg-name",UNAUTHORIZED_DOMAIN:"unauthorized-continue-uri",INVALID_OAUTH_CLIENT_ID:"invalid-oauth-client-id",ADMIN_ONLY_OPERATION:"admin-restricted-operation",INVALID_MFA_PENDING_CREDENTIAL:"invalid-multi-factor-session",MFA_ENROLLMENT_NOT_FOUND:"multi-factor-info-not-found",MISSING_MFA_ENROLLMENT_ID:"missing-multi-factor-info",MISSING_MFA_PENDING_CREDENTIAL:"missing-multi-factor-session",SECOND_FACTOR_EXISTS:"second-factor-already-in-use",SECOND_FACTOR_LIMIT_EXCEEDED:"maximum-second-factor-count-exceeded",BLOCKING_FUNCTION_ERROR_RESPONSE:"internal-error"},F=new R(3e4,6e4);function U(t,e){return t.tenantId&&!e.tenantId?Object.assign(Object.assign({},e),{tenantId:t.tenantId}):e}async function V(t,e,n,i,s={}){return j(t,s,(async()=>{let s={},o={};i&&("GET"===e?o=i:s={body:JSON.stringify(i)});const a=(0,r.xO)(Object.assign({key:t.config.apiKey},o)).slice(1),c=await t._getAdditionalHeaders();return c["Content-Type"]="application/json",t.languageCode&&(c["X-Firebase-Locale"]=t.languageCode),L.fetch()(B(t,t.config.apiHost,n,a),Object.assign({method:e,headers:c,referrerPolicy:"no-referrer"},s))}))}async function j(t,e,n){t._canInitEmulator=!1;const i=Object.assign(Object.assign({},M),e);try{const e=new z(t),r=await Promise.race([n(),e.promise]);e.clearNetworkTimeout();const s=await r.json();if("needConfirmation"in s)throw K(t,"account-exists-with-different-credential",s);if(r.ok&&!("errorMessage"in s))return s;{const e=r.ok?s.errorMessage:s.error.message,[n,o]=e.split(" : ");if("FEDERATED_USER_ID_ALREADY_LINKED"===n)throw K(t,"credential-already-in-use",s);if("EMAIL_EXISTS"===n)throw K(t,"email-already-in-use",s);const a=i[n]||n.toLowerCase().replace(/[_\s]+/g,"-");if(o)throw I(t,a,o);b(t,a)}}catch(e){if(e instanceof r.ZR)throw e;b(t,"network-request-failed")}}async function q(t,e,n,r,i={}){const s=await V(t,e,n,r,i);return"mfaPendingCredential"in s&&b(t,"multi-factor-auth-required",{_serverResponse:s}),s}function B(t,e,n,r){const i=`${e}${n}?${r}`;return t.config.emulator?P(t.config,i):`${t.config.apiScheme}://${i}`}class z{constructor(t){this.auth=t,this.timer=null,this.promise=new Promise(((t,e)=>{this.timer=setTimeout((()=>e(w(this.auth,"timeout"))),F.get())}))}clearNetworkTimeout(){clearTimeout(this.timer)}}function K(t,e,n){const r={appName:t.name};n.email&&(r.email=n.email),n.phoneNumber&&(r.phoneNumber=n.phoneNumber);const i=w(t,e,r);return i.customData._tokenResponse=n,i}function W(t){if(t)try{const e=new Date(Number(t));if(!isNaN(e.getTime()))return e.toUTCString()}catch(t){}}function G(t,e=!1){return(0,r.m9)(t).getIdToken(e)}async function H(t,e=!1){const n=(0,r.m9)(t),i=await n.getIdToken(e),s=Y(i);E(s&&s.exp&&s.auth_time&&s.iat,n.auth,"internal-error");const o="object"==typeof s.firebase?s.firebase:void 0,a=null==o?void 0:o.sign_in_provider;return{claims:s,token:i,authTime:W($(s.auth_time)),issuedAtTime:W($(s.iat)),expirationTime:W($(s.exp)),signInProvider:a||null,signInSecondFactor:(null==o?void 0:o.sign_in_second_factor)||null}}function $(t){return 1e3*Number(t)}function Y(t){const[e,n,i]=t.split(".");if(void 0===e||void 0===n||void 0===i)return v("JWT malformed, contained fewer than 3 sections"),null;try{const t=(0,r.tV)(n);return t?JSON.parse(t):(v("Failed to decode base64 JWT payload"),null)}catch(t){return v("Caught error parsing JWT payload as JSON",t),null}}async function Q(t,e,n=!1){if(n)return e;try{return await e}catch(e){throw e instanceof r.ZR&&function({code:t}){return"auth/user-disabled"===t||"auth/user-token-expired"===t}(e)&&t.auth.currentUser===t&&await t.auth.signOut(),e}}class J{constructor(t){this.user=t,this.isRunning=!1,this.timerId=null,this.errorBackoff=3e4}_start(){this.isRunning||(this.isRunning=!0,this.schedule())}_stop(){this.isRunning&&(this.isRunning=!1,null!==this.timerId&&clearTimeout(this.timerId))}getInterval(t){var e;if(t){const t=this.errorBackoff;return this.errorBackoff=Math.min(2*this.errorBackoff,96e4),t}{this.errorBackoff=3e4;const t=(null!==(e=this.user.stsTokenManager.expirationTime)&&void 0!==e?e:0)-Date.now()-3e5;return Math.max(0,t)}}schedule(t=!1){if(!this.isRunning)return;const e=this.getInterval(t);this.timerId=setTimeout((async()=>{await this.iteration()}),e)}async iteration(){try{await this.user.getIdToken(!0)}catch(t){return void("auth/network-request-failed"===t.code&&this.schedule(!0))}this.schedule()}}class Z{constructor(t,e){this.createdAt=t,this.lastLoginAt=e,this._initializeTime()}_initializeTime(){this.lastSignInTime=W(this.lastLoginAt),this.creationTime=W(this.createdAt)}_copy(t){this.createdAt=t.createdAt,this.lastLoginAt=t.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}async function X(t){var e;const n=t.auth,r=await t.getIdToken(),i=await Q(t,async function(t,e){return V(t,"POST","/v1/accounts:lookup",e)}(n,{idToken:r}));E(null==i?void 0:i.users.length,n,"internal-error");const o=i.users[0];t._notifyReloadListener(o);const a=(null===(e=o.providerUserInfo)||void 0===e?void 0:e.length)?o.providerUserInfo.map((t=>{var{providerId:e}=t,n=s(t,["providerId"]);return{providerId:e,uid:n.rawId||"",displayName:n.displayName||null,email:n.email||null,phoneNumber:n.phoneNumber||null,photoURL:n.photoUrl||null}})):[],c=(u=t.providerData,h=a,[...u.filter((t=>!h.some((e=>e.providerId===t.providerId)))),...h]);var u,h;const l=t.isAnonymous,d=!(t.email&&o.passwordHash||(null==c?void 0:c.length)),f=!!l&&d,p={uid:o.localId,displayName:o.displayName||null,photoURL:o.photoUrl||null,email:o.email||null,emailVerified:o.emailVerified||!1,phoneNumber:o.phoneNumber||null,tenantId:o.tenantId||null,providerData:c,metadata:new Z(o.createdAt,o.lastLoginAt),isAnonymous:f};Object.assign(t,p)}async function tt(t){const e=(0,r.m9)(t);await X(e),await e.auth._persistUserIfCurrent(e),e.auth._notifyListenersIfCurrent(e)}class et{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(t){E(t.idToken,"internal-error"),E(void 0!==t.idToken,"internal-error"),E(void 0!==t.refreshToken,"internal-error");const e="expiresIn"in t&&void 0!==t.expiresIn?Number(t.expiresIn):function(t){const e=Y(t);return E(e,"internal-error"),E(void 0!==e.exp,"internal-error"),E(void 0!==e.iat,"internal-error"),Number(e.exp)-Number(e.iat)}(t.idToken);this.updateTokensAndExpiration(t.idToken,t.refreshToken,e)}async getToken(t,e=!1){return E(!this.accessToken||this.refreshToken,t,"user-token-expired"),e||!this.accessToken||this.isExpired?this.refreshToken?(await this.refresh(t,this.refreshToken),this.accessToken):null:this.accessToken}clearRefreshToken(){this.refreshToken=null}async refresh(t,e){const{accessToken:n,refreshToken:i,expiresIn:s}=await async function(t,e){const n=await j(t,{},(async()=>{const n=(0,r.xO)({grant_type:"refresh_token",refresh_token:e}).slice(1),{tokenApiHost:i,apiKey:s}=t.config,o=B(t,i,"/v1/token",`key=${s}`),a=await t._getAdditionalHeaders();return a["Content-Type"]="application/x-www-form-urlencoded",L.fetch()(o,{method:"POST",headers:a,body:n})}));return{accessToken:n.access_token,expiresIn:n.expires_in,refreshToken:n.refresh_token}}(t,e);this.updateTokensAndExpiration(n,i,Number(s))}updateTokensAndExpiration(t,e,n){this.refreshToken=e||null,this.accessToken=t||null,this.expirationTime=Date.now()+1e3*n}static fromJSON(t,e){const{refreshToken:n,accessToken:r,expirationTime:i}=e,s=new et;return n&&(E("string"==typeof n,"internal-error",{appName:t}),s.refreshToken=n),r&&(E("string"==typeof r,"internal-error",{appName:t}),s.accessToken=r),i&&(E("number"==typeof i,"internal-error",{appName:t}),s.expirationTime=i),s}toJSON(){return{refreshToken:this.refreshToken,accessToken:this.accessToken,expirationTime:this.expirationTime}}_assign(t){this.accessToken=t.accessToken,this.refreshToken=t.refreshToken,this.expirationTime=t.expirationTime}_clone(){return Object.assign(new et,this.toJSON())}_performRefresh(){return S("not implemented")}}function nt(t,e){E("string"==typeof t||void 0===t,"internal-error",{appName:e})}class rt{constructor(t){var{uid:e,auth:n,stsTokenManager:r}=t,i=s(t,["uid","auth","stsTokenManager"]);this.providerId="firebase",this.emailVerified=!1,this.isAnonymous=!1,this.tenantId=null,this.providerData=[],this.proactiveRefresh=new J(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=e,this.auth=n,this.stsTokenManager=r,this.accessToken=r.accessToken,this.displayName=i.displayName||null,this.email=i.email||null,this.emailVerified=i.emailVerified||!1,this.phoneNumber=i.phoneNumber||null,this.photoURL=i.photoURL||null,this.isAnonymous=i.isAnonymous||!1,this.tenantId=i.tenantId||null,this.metadata=new Z(i.createdAt||void 0,i.lastLoginAt||void 0)}async getIdToken(t){const e=await Q(this,this.stsTokenManager.getToken(this.auth,t));return E(e,this.auth,"internal-error"),this.accessToken!==e&&(this.accessToken=e,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),e}getIdTokenResult(t){return H(this,t)}reload(){return tt(this)}_assign(t){this!==t&&(E(this.uid===t.uid,this.auth,"internal-error"),this.displayName=t.displayName,this.photoURL=t.photoURL,this.email=t.email,this.emailVerified=t.emailVerified,this.phoneNumber=t.phoneNumber,this.isAnonymous=t.isAnonymous,this.tenantId=t.tenantId,this.providerData=t.providerData.map((t=>Object.assign({},t))),this.metadata._copy(t.metadata),this.stsTokenManager._assign(t.stsTokenManager))}_clone(t){return new rt(Object.assign(Object.assign({},this),{auth:t,stsTokenManager:this.stsTokenManager._clone()}))}_onReload(t){E(!this.reloadListener,this.auth,"internal-error"),this.reloadListener=t,this.reloadUserInfo&&(this._notifyReloadListener(this.reloadUserInfo),this.reloadUserInfo=null)}_notifyReloadListener(t){this.reloadListener?this.reloadListener(t):this.reloadUserInfo=t}_startProactiveRefresh(){this.proactiveRefresh._start()}_stopProactiveRefresh(){this.proactiveRefresh._stop()}async _updateTokensIfNecessary(t,e=!1){let n=!1;t.idToken&&t.idToken!==this.stsTokenManager.accessToken&&(this.stsTokenManager.updateFromServerResponse(t),n=!0),e&&await X(this),await this.auth._persistUserIfCurrent(this),n&&this.auth._notifyListenersIfCurrent(this)}async delete(){const t=await this.getIdToken();return await Q(this,async function(t,e){return V(t,"POST","/v1/accounts:delete",e)}(this.auth,{idToken:t})),this.stsTokenManager.clearRefreshToken(),this.auth.signOut()}toJSON(){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((t=>Object.assign({},t))),stsTokenManager:this.stsTokenManager.toJSON(),_redirectEventId:this._redirectEventId},this.metadata.toJSON()),{apiKey:this.auth.config.apiKey,appName:this.auth.name})}get refreshToken(){return this.stsTokenManager.refreshToken||""}static _fromJSON(t,e){var n,r,i,s,o,a,c,u;const h=null!==(n=e.displayName)&&void 0!==n?n:void 0,l=null!==(r=e.email)&&void 0!==r?r:void 0,d=null!==(i=e.phoneNumber)&&void 0!==i?i:void 0,f=null!==(s=e.photoURL)&&void 0!==s?s:void 0,p=null!==(o=e.tenantId)&&void 0!==o?o:void 0,m=null!==(a=e._redirectEventId)&&void 0!==a?a:void 0,g=null!==(c=e.createdAt)&&void 0!==c?c:void 0,y=null!==(u=e.lastLoginAt)&&void 0!==u?u:void 0,{uid:v,emailVerified:b,isAnonymous:w,providerData:I,stsTokenManager:T}=e;E(v&&T,t,"internal-error");const _=et.fromJSON(this.name,T);E("string"==typeof v,t,"internal-error"),nt(h,t.name),nt(l,t.name),E("boolean"==typeof b,t,"internal-error"),E("boolean"==typeof w,t,"internal-error"),nt(d,t.name),nt(f,t.name),nt(p,t.name),nt(m,t.name),nt(g,t.name),nt(y,t.name);const S=new rt({uid:v,auth:t,email:l,emailVerified:b,displayName:h,isAnonymous:w,photoURL:f,phoneNumber:d,tenantId:p,stsTokenManager:_,createdAt:g,lastLoginAt:y});return I&&Array.isArray(I)&&(S.providerData=I.map((t=>Object.assign({},t)))),m&&(S._redirectEventId=m),S}static async _fromIdTokenResponse(t,e,n=!1){const r=new et;r.updateFromServerResponse(e);const i=new rt({uid:e.localId,auth:t,stsTokenManager:r,isAnonymous:n});return await X(i),i}}class it{constructor(){this.type="NONE",this.storage={}}async _isAvailable(){return!0}async _set(t,e){this.storage[t]=e}async _get(t){const e=this.storage[t];return void 0===e?null:e}async _remove(t){delete this.storage[t]}_addListener(t,e){}_removeListener(t,e){}}it.type="NONE";const st=it;function ot(t,e,n){return`firebase:${t}:${e}:${n}`}class at{constructor(t,e,n){this.persistence=t,this.auth=e,this.userKey=n;const{config:r,name:i}=this.auth;this.fullUserKey=ot(this.userKey,r.apiKey,i),this.fullPersistenceKey=ot("persistence",r.apiKey,i),this.boundEventHandler=e._onStorageEvent.bind(e),this.persistence._addListener(this.fullUserKey,this.boundEventHandler)}setCurrentUser(t){return this.persistence._set(this.fullUserKey,t.toJSON())}async getCurrentUser(){const t=await this.persistence._get(this.fullUserKey);return t?rt._fromJSON(this.auth,t):null}removeCurrentUser(){return this.persistence._remove(this.fullUserKey)}savePersistenceForRedirect(){return this.persistence._set(this.fullPersistenceKey,this.persistence.type)}async setPersistence(t){if(this.persistence===t)return;const e=await this.getCurrentUser();return await this.removeCurrentUser(),this.persistence=t,e?this.setCurrentUser(e):void 0}delete(){this.persistence._removeListener(this.fullUserKey,this.boundEventHandler)}static async create(t,e,n="authUser"){if(!e.length)return new at(N(st),t,n);const r=(await Promise.all(e.map((async t=>{if(await t._isAvailable())return t})))).filter((t=>t));let i=r[0]||N(st);const s=ot(n,t.config.apiKey,t.name);let o=null;for(const n of e)try{const e=await n._get(s);if(e){const r=rt._fromJSON(t,e);n!==i&&(o=r),i=n;break}}catch(t){}const a=r.filter((t=>t._shouldAllowMigration));return i._shouldAllowMigration&&a.length?(i=a[0],o&&await i._set(s,o.toJSON()),await Promise.all(e.map((async t=>{if(t!==i)try{await t._remove(s)}catch(t){}}))),new at(i,t,n)):new at(i,t,n)}}function ct(t){const e=t.toLowerCase();if(e.includes("opera/")||e.includes("opr/")||e.includes("opios/"))return"Opera";if(dt(e))return"IEMobile";if(e.includes("msie")||e.includes("trident/"))return"IE";if(e.includes("edge/"))return"Edge";if(ut(e))return"Firefox";if(e.includes("silk/"))return"Silk";if(pt(e))return"Blackberry";if(mt(e))return"Webos";if(ht(e))return"Safari";if((e.includes("chrome/")||lt(e))&&!e.includes("edge/"))return"Chrome";if(ft(e))return"Android";{const e=/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/,n=t.match(e);if(2===(null==n?void 0:n.length))return n[1]}return"Other"}function ut(t=(0,r.z$)()){return/firefox\//i.test(t)}function ht(t=(0,r.z$)()){const e=t.toLowerCase();return e.includes("safari/")&&!e.includes("chrome/")&&!e.includes("crios/")&&!e.includes("android")}function lt(t=(0,r.z$)()){return/crios\//i.test(t)}function dt(t=(0,r.z$)()){return/iemobile/i.test(t)}function ft(t=(0,r.z$)()){return/android/i.test(t)}function pt(t=(0,r.z$)()){return/blackberry/i.test(t)}function mt(t=(0,r.z$)()){return/webos/i.test(t)}function gt(t=(0,r.z$)()){return/iphone|ipad|ipod/i.test(t)}function yt(t=(0,r.z$)()){return gt(t)||ft(t)||mt(t)||pt(t)||/windows phone/i.test(t)||dt(t)}function vt(t,e=[]){let n;switch(t){case"Browser":n=ct((0,r.z$)());break;case"Worker":n=`${ct((0,r.z$)())}-${t}`;break;default:n=t}const s=e.length?e.join(","):"FirebaseCore-web";return`${n}/JsCore/${i.Jn}/${s}`}class bt{constructor(t,e){this.app=t,this.config=e,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new It(this),this.idTokenSubscription=new It(this),this.redirectUser=null,this.isProactiveRefreshEnabled=!1,this._canInitEmulator=!0,this._isInitialized=!1,this._deleted=!1,this._initializationPromise=null,this._popupRedirectResolver=null,this._errorFactory=m,this.lastNotifiedUid=void 0,this.languageCode=null,this.tenantId=null,this.settings={appVerificationDisabledForTesting:!1},this.frameworks=[],this.name=t.name,this.clientVersion=e.sdkClientVersion}_initializeWithPersistence(t,e){return e&&(this._popupRedirectResolver=N(e)),this._initializationPromise=this.queue((async()=>{var n,r;if(!this._deleted&&(this.persistenceManager=await at.create(this,t),!this._deleted)){if(null===(n=this._popupRedirectResolver)||void 0===n?void 0:n._shouldInitProactively)try{await this._popupRedirectResolver._initialize(this)}catch(t){}await this.initializeCurrentUser(e),this.lastNotifiedUid=(null===(r=this.currentUser)||void 0===r?void 0:r.uid)||null,this._deleted||(this._isInitialized=!0)}})),this._initializationPromise}async _onStorageEvent(){if(this._deleted)return;const t=await this.assertedPersistence.getCurrentUser();return this.currentUser||t?this.currentUser&&t&&this.currentUser.uid===t.uid?(this._currentUser._assign(t),void await this.currentUser.getIdToken()):void await this._updateCurrentUser(t):void 0}async initializeCurrentUser(t){var e;let n=await this.assertedPersistence.getCurrentUser();if(t&&this.config.authDomain){await this.getOrInitRedirectPersistenceManager();const r=null===(e=this.redirectUser)||void 0===e?void 0:e._redirectEventId,i=null==n?void 0:n._redirectEventId,s=await this.tryRedirectSignIn(t);r&&r!==i||!(null==s?void 0:s.user)||(n=s.user)}return n?n._redirectEventId?(E(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===n._redirectEventId?this.directlySetCurrentUser(n):this.reloadAndSetCurrentUserOrClear(n)):this.reloadAndSetCurrentUserOrClear(n):this.directlySetCurrentUser(null)}async tryRedirectSignIn(t){let e=null;try{e=await this._popupRedirectResolver._completeRedirectFn(this,t,!0)}catch(t){await this._setRedirectUser(null)}return e}async reloadAndSetCurrentUserOrClear(t){try{await X(t)}catch(t){if("auth/network-request-failed"!==t.code)return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(t)}useDeviceLanguage(){this.languageCode=function(){if("undefined"==typeof navigator)return null;const t=navigator;return t.languages&&t.languages[0]||t.language||null}()}async _delete(){this._deleted=!0}async updateCurrentUser(t){const e=t?(0,r.m9)(t):null;return e&&E(e.auth.config.apiKey===this.config.apiKey,this,"invalid-user-token"),this._updateCurrentUser(e&&e._clone(this))}async _updateCurrentUser(t){if(!this._deleted)return t&&E(this.tenantId===t.tenantId,this,"tenant-id-mismatch"),this.queue((async()=>{await this.directlySetCurrentUser(t),this.notifyAuthListeners()}))}async signOut(){return(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null)}setPersistence(t){return this.queue((async()=>{await this.assertedPersistence.setPersistence(N(t))}))}_getPersistence(){return this.assertedPersistence.persistence.type}_updateErrorMap(t){this._errorFactory=new r.LL("auth","Firebase",t())}onAuthStateChanged(t,e,n){return this.registerStateListener(this.authStateSubscription,t,e,n)}onIdTokenChanged(t,e,n){return this.registerStateListener(this.idTokenSubscription,t,e,n)}toJSON(){var t;return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:null===(t=this._currentUser)||void 0===t?void 0:t.toJSON()}}async _setRedirectUser(t,e){const n=await this.getOrInitRedirectPersistenceManager(e);return null===t?n.removeCurrentUser():n.setCurrentUser(t)}async getOrInitRedirectPersistenceManager(t){if(!this.redirectPersistenceManager){const e=t&&N(t)||this._popupRedirectResolver;E(e,this,"argument-error"),this.redirectPersistenceManager=await at.create(this,[N(e._redirectPersistence)],"redirectUser"),this.redirectUser=await this.redirectPersistenceManager.getCurrentUser()}return this.redirectPersistenceManager}async _redirectUserForId(t){var e,n;return this._isInitialized&&await this.queue((async()=>{})),(null===(e=this._currentUser)||void 0===e?void 0:e._redirectEventId)===t?this._currentUser:(null===(n=this.redirectUser)||void 0===n?void 0:n._redirectEventId)===t?this.redirectUser:null}async _persistUserIfCurrent(t){if(t===this.currentUser)return this.queue((async()=>this.directlySetCurrentUser(t)))}_notifyListenersIfCurrent(t){t===this.currentUser&&this.notifyAuthListeners()}_key(){return`${this.config.authDomain}:${this.config.apiKey}:${this.name}`}_startProactiveRefresh(){this.isProactiveRefreshEnabled=!0,this.currentUser&&this._currentUser._startProactiveRefresh()}_stopProactiveRefresh(){this.isProactiveRefreshEnabled=!1,this.currentUser&&this._currentUser._stopProactiveRefresh()}get _currentUser(){return this.currentUser}notifyAuthListeners(){var t,e;if(!this._isInitialized)return;this.idTokenSubscription.next(this.currentUser);const n=null!==(e=null===(t=this.currentUser)||void 0===t?void 0:t.uid)&&void 0!==e?e:null;this.lastNotifiedUid!==n&&(this.lastNotifiedUid=n,this.authStateSubscription.next(this.currentUser))}registerStateListener(t,e,n,r){if(this._deleted)return()=>{};const i="function"==typeof e?e:e.next.bind(e),s=this._isInitialized?Promise.resolve():this._initializationPromise;return E(s,this,"internal-error"),s.then((()=>i(this.currentUser))),"function"==typeof e?t.addObserver(e,n,r):t.addObserver(e)}async directlySetCurrentUser(t){this.currentUser&&this.currentUser!==t&&(this._currentUser._stopProactiveRefresh(),t&&this.isProactiveRefreshEnabled&&t._startProactiveRefresh()),this.currentUser=t,t?await this.assertedPersistence.setCurrentUser(t):await this.assertedPersistence.removeCurrentUser()}queue(t){return this.operations=this.operations.then(t,t),this.operations}get assertedPersistence(){return E(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(t){t&&!this.frameworks.includes(t)&&(this.frameworks.push(t),this.frameworks.sort(),this.clientVersion=vt(this.config.clientPlatform,this._getFrameworks()))}_getFrameworks(){return this.frameworks}async _getAdditionalHeaders(){const t={"X-Client-Version":this.clientVersion};return this.app.options.appId&&(t["X-Firebase-gmpid"]=this.app.options.appId),t}}function wt(t){return(0,r.m9)(t)}class It{constructor(t){this.auth=t,this.observer=null,this.addObserver=(0,r.ne)((t=>this.observer=t))}get next(){return E(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}function Tt(t,e,n){const r=wt(t);E(r._canInitEmulator,r,"emulator-config-failed"),E(/^https?:\/\//.test(e),r,"invalid-emulator-scheme");const i=!!(null==n?void 0:n.disableWarnings),s=_t(e),{host:o,port:a}=function(t){const e=_t(t),n=/(\/\/)?([^?#/]+)/.exec(t.substr(e.length));if(!n)return{host:"",port:null};const r=n[2].split("@").pop()||"",i=/^(\[[^\]]+\])(:|$)/.exec(r);if(i){const t=i[1];return{host:t,port:Et(r.substr(t.length+1))}}{const[t,e]=r.split(":");return{host:t,port:Et(e)}}}(e),c=null===a?"":`:${a}`;r.config.emulator={url:`${s}//${o}${c}/`},r.settings.appVerificationDisabledForTesting=!0,r.emulatorConfig=Object.freeze({host:o,port:a,protocol:s.replace(":",""),options:Object.freeze({disableWarnings:i})}),i||function(){function t(){const t=document.createElement("p"),e=t.style;t.innerText="Running in emulator mode. Do not use with production credentials.",e.position="fixed",e.width="100%",e.backgroundColor="#ffffff",e.border=".1em solid #000000",e.color="#b50000",e.bottom="0px",e.left="0px",e.margin="0px",e.zIndex="10000",e.textAlign="center",t.classList.add("firebase-emulator-warning"),document.body.appendChild(t)}"undefined"!=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."),"undefined"!=typeof window&&"undefined"!=typeof document&&("loading"===document.readyState?window.addEventListener("DOMContentLoaded",t):t())}()}function _t(t){const e=t.indexOf(":");return e<0?"":t.substr(0,e+1)}function Et(t){if(!t)return null;const e=Number(t);return isNaN(e)?null:e}class St{constructor(t,e){this.providerId=t,this.signInMethod=e}toJSON(){return S("not implemented")}_getIdTokenResponse(t){return S("not implemented")}_linkToIdToken(t,e){return S("not implemented")}_getReauthenticationResolver(t){return S("not implemented")}}async function kt(t,e){return V(t,"POST","/v1/accounts:resetPassword",U(t,e))}async function At(t,e){return V(t,"POST","/v1/accounts:update",e)}async function Nt(t,e){return V(t,"POST","/v1/accounts:sendOobCode",U(t,e))}class xt extends St{constructor(t,e,n,r=null){super("password",n),this._email=t,this._password=e,this._tenantId=r}static _fromEmailAndPassword(t,e){return new xt(t,e,"password")}static _fromEmailAndCode(t,e,n=null){return new xt(t,e,"emailLink",n)}toJSON(){return{email:this._email,password:this._password,signInMethod:this.signInMethod,tenantId:this._tenantId}}static fromJSON(t){const e="string"==typeof t?JSON.parse(t):t;if((null==e?void 0:e.email)&&(null==e?void 0:e.password)){if("password"===e.signInMethod)return this._fromEmailAndPassword(e.email,e.password);if("emailLink"===e.signInMethod)return this._fromEmailAndCode(e.email,e.password,e.tenantId)}return null}async _getIdTokenResponse(t){switch(this.signInMethod){case"password":return async function(t,e){return q(t,"POST","/v1/accounts:signInWithPassword",U(t,e))}(t,{returnSecureToken:!0,email:this._email,password:this._password});case"emailLink":return async function(t,e){return q(t,"POST","/v1/accounts:signInWithEmailLink",U(t,e))}(t,{email:this._email,oobCode:this._password});default:b(t,"internal-error")}}async _linkToIdToken(t,e){switch(this.signInMethod){case"password":return At(t,{idToken:e,returnSecureToken:!0,email:this._email,password:this._password});case"emailLink":return async function(t,e){return q(t,"POST","/v1/accounts:signInWithEmailLink",U(t,e))}(t,{idToken:e,email:this._email,oobCode:this._password});default:b(t,"internal-error")}}_getReauthenticationResolver(t){return this._getIdTokenResponse(t)}}async function Ct(t,e){return q(t,"POST","/v1/accounts:signInWithIdp",U(t,e))}class Dt extends St{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(t){const e=new Dt(t.providerId,t.signInMethod);return t.idToken||t.accessToken?(t.idToken&&(e.idToken=t.idToken),t.accessToken&&(e.accessToken=t.accessToken),t.nonce&&!t.pendingToken&&(e.nonce=t.nonce),t.pendingToken&&(e.pendingToken=t.pendingToken)):t.oauthToken&&t.oauthTokenSecret?(e.accessToken=t.oauthToken,e.secret=t.oauthTokenSecret):b("argument-error"),e}toJSON(){return{idToken:this.idToken,accessToken:this.accessToken,secret:this.secret,nonce:this.nonce,pendingToken:this.pendingToken,providerId:this.providerId,signInMethod:this.signInMethod}}static fromJSON(t){const e="string"==typeof t?JSON.parse(t):t,{providerId:n,signInMethod:r}=e,i=s(e,["providerId","signInMethod"]);if(!n||!r)return null;const o=new Dt(n,r);return o.idToken=i.idToken||void 0,o.accessToken=i.accessToken||void 0,o.secret=i.secret,o.nonce=i.nonce,o.pendingToken=i.pendingToken||null,o}_getIdTokenResponse(t){return Ct(t,this.buildRequest())}_linkToIdToken(t,e){const n=this.buildRequest();return n.idToken=e,Ct(t,n)}_getReauthenticationResolver(t){const e=this.buildRequest();return e.autoCreate=!1,Ct(t,e)}buildRequest(){const t={requestUri:"http://localhost",returnSecureToken:!0};if(this.pendingToken)t.pendingToken=this.pendingToken;else{const e={};this.idToken&&(e.id_token=this.idToken),this.accessToken&&(e.access_token=this.accessToken),this.secret&&(e.oauth_token_secret=this.secret),e.providerId=this.providerId,this.nonce&&!this.pendingToken&&(e.nonce=this.nonce),t.postBody=(0,r.xO)(e)}return t}}const Ot={USER_NOT_FOUND:"user-not-found"};class Rt extends St{constructor(t){super("phone","phone"),this.params=t}static _fromVerification(t,e){return new Rt({verificationId:t,verificationCode:e})}static _fromTokenResponse(t,e){return new Rt({phoneNumber:t,temporaryProof:e})}_getIdTokenResponse(t){return async function(t,e){return q(t,"POST","/v1/accounts:signInWithPhoneNumber",U(t,e))}(t,this._makeVerificationRequest())}_linkToIdToken(t,e){return async function(t,e){const n=await q(t,"POST","/v1/accounts:signInWithPhoneNumber",U(t,e));if(n.temporaryProof)throw K(t,"account-exists-with-different-credential",n);return n}(t,Object.assign({idToken:e},this._makeVerificationRequest()))}_getReauthenticationResolver(t){return async function(t,e){return q(t,"POST","/v1/accounts:signInWithPhoneNumber",U(t,Object.assign(Object.assign({},e),{operation:"REAUTH"})),Ot)}(t,this._makeVerificationRequest())}_makeVerificationRequest(){const{temporaryProof:t,phoneNumber:e,verificationId:n,verificationCode:r}=this.params;return t&&e?{temporaryProof:t,phoneNumber:e}:{sessionInfo:n,code:r}}toJSON(){const t={providerId:this.providerId};return this.params.phoneNumber&&(t.phoneNumber=this.params.phoneNumber),this.params.temporaryProof&&(t.temporaryProof=this.params.temporaryProof),this.params.verificationCode&&(t.verificationCode=this.params.verificationCode),this.params.verificationId&&(t.verificationId=this.params.verificationId),t}static fromJSON(t){"string"==typeof t&&(t=JSON.parse(t));const{verificationId:e,verificationCode:n,phoneNumber:r,temporaryProof:i}=t;return n||e||r||i?new Rt({verificationId:e,verificationCode:n,phoneNumber:r,temporaryProof:i}):null}}class Pt{constructor(t){var e,n,i,s,o,a;const c=(0,r.zd)((0,r.pd)(t)),u=null!==(e=c.apiKey)&&void 0!==e?e:null,h=null!==(n=c.oobCode)&&void 0!==n?n:null,l=function(t){switch(t){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=c.mode)&&void 0!==i?i:null);E(u&&h&&l,"argument-error"),this.apiKey=u,this.operation=l,this.code=h,this.continueUrl=null!==(s=c.continueUrl)&&void 0!==s?s:null,this.languageCode=null!==(o=c.languageCode)&&void 0!==o?o:null,this.tenantId=null!==(a=c.tenantId)&&void 0!==a?a:null}static parseLink(t){const e=function(t){const e=(0,r.zd)((0,r.pd)(t)).link,n=e?(0,r.zd)((0,r.pd)(e)).deep_link_id:null,i=(0,r.zd)((0,r.pd)(t)).deep_link_id;return(i?(0,r.zd)((0,r.pd)(i)).link:null)||i||n||e||t}(t);try{return new Pt(e)}catch(t){return null}}}function Lt(t){return Pt.parseLink(t)}class Mt{constructor(){this.providerId=Mt.PROVIDER_ID}static credential(t,e){return xt._fromEmailAndPassword(t,e)}static credentialWithLink(t,e){const n=Pt.parseLink(e);return E(n,"argument-error"),xt._fromEmailAndCode(t,n.code,n.tenantId)}}Mt.PROVIDER_ID="password",Mt.EMAIL_PASSWORD_SIGN_IN_METHOD="password",Mt.EMAIL_LINK_SIGN_IN_METHOD="emailLink";class Ft{constructor(t){this.providerId=t,this.defaultLanguageCode=null,this.customParameters={}}setDefaultLanguage(t){this.defaultLanguageCode=t}setCustomParameters(t){return this.customParameters=t,this}getCustomParameters(){return this.customParameters}}class Ut extends Ft{constructor(){super(...arguments),this.scopes=[]}addScope(t){return this.scopes.includes(t)||this.scopes.push(t),this}getScopes(){return[...this.scopes]}}class Vt extends Ut{static credentialFromJSON(t){const e="string"==typeof t?JSON.parse(t):t;return E("providerId"in e&&"signInMethod"in e,"argument-error"),Dt._fromParams(e)}credential(t){return this._credential(Object.assign(Object.assign({},t),{nonce:t.rawNonce}))}_credential(t){return E(t.idToken||t.accessToken,"argument-error"),Dt._fromParams(Object.assign(Object.assign({},t),{providerId:this.providerId,signInMethod:this.providerId}))}static credentialFromResult(t){return Vt.oauthCredentialFromTaggedObject(t)}static credentialFromError(t){return Vt.oauthCredentialFromTaggedObject(t.customData||{})}static oauthCredentialFromTaggedObject({_tokenResponse:t}){if(!t)return null;const{oauthIdToken:e,oauthAccessToken:n,oauthTokenSecret:r,pendingToken:i,nonce:s,providerId:o}=t;if(!(n||r||e||i))return null;if(!o)return null;try{return new Vt(o)._credential({idToken:e,accessToken:n,nonce:s,pendingToken:i})}catch(t){return null}}}class jt extends Ut{constructor(){super("facebook.com")}static credential(t){return Dt._fromParams({providerId:jt.PROVIDER_ID,signInMethod:jt.FACEBOOK_SIGN_IN_METHOD,accessToken:t})}static credentialFromResult(t){return jt.credentialFromTaggedObject(t)}static credentialFromError(t){return jt.credentialFromTaggedObject(t.customData||{})}static credentialFromTaggedObject({_tokenResponse:t}){if(!t||!("oauthAccessToken"in t))return null;if(!t.oauthAccessToken)return null;try{return jt.credential(t.oauthAccessToken)}catch(t){return null}}}jt.FACEBOOK_SIGN_IN_METHOD="facebook.com",jt.PROVIDER_ID="facebook.com";class qt extends Ut{constructor(){super("google.com"),this.addScope("profile")}static credential(t,e){return Dt._fromParams({providerId:qt.PROVIDER_ID,signInMethod:qt.GOOGLE_SIGN_IN_METHOD,idToken:t,accessToken:e})}static credentialFromResult(t){return qt.credentialFromTaggedObject(t)}static credentialFromError(t){return qt.credentialFromTaggedObject(t.customData||{})}static credentialFromTaggedObject({_tokenResponse:t}){if(!t)return null;const{oauthIdToken:e,oauthAccessToken:n}=t;if(!e&&!n)return null;try{return qt.credential(e,n)}catch(t){return null}}}qt.GOOGLE_SIGN_IN_METHOD="google.com",qt.PROVIDER_ID="google.com";class Bt extends Ut{constructor(){super("github.com")}static credential(t){return Dt._fromParams({providerId:Bt.PROVIDER_ID,signInMethod:Bt.GITHUB_SIGN_IN_METHOD,accessToken:t})}static credentialFromResult(t){return Bt.credentialFromTaggedObject(t)}static credentialFromError(t){return Bt.credentialFromTaggedObject(t.customData||{})}static credentialFromTaggedObject({_tokenResponse:t}){if(!t||!("oauthAccessToken"in t))return null;if(!t.oauthAccessToken)return null;try{return Bt.credential(t.oauthAccessToken)}catch(t){return null}}}Bt.GITHUB_SIGN_IN_METHOD="github.com",Bt.PROVIDER_ID="github.com";class zt extends St{constructor(t,e){super(t,t),this.pendingToken=e}_getIdTokenResponse(t){return Ct(t,this.buildRequest())}_linkToIdToken(t,e){const n=this.buildRequest();return n.idToken=e,Ct(t,n)}_getReauthenticationResolver(t){const e=this.buildRequest();return e.autoCreate=!1,Ct(t,e)}toJSON(){return{signInMethod:this.signInMethod,providerId:this.providerId,pendingToken:this.pendingToken}}static fromJSON(t){const e="string"==typeof t?JSON.parse(t):t,{providerId:n,signInMethod:r,pendingToken:i}=e;return n&&r&&i&&n===r?new zt(n,i):null}static _create(t,e){return new zt(t,e)}buildRequest(){return{requestUri:"http://localhost",returnSecureToken:!0,pendingToken:this.pendingToken}}}class Kt extends Ft{constructor(t){E(t.startsWith("saml."),"argument-error"),super(t)}static credentialFromResult(t){return Kt.samlCredentialFromTaggedObject(t)}static credentialFromError(t){return Kt.samlCredentialFromTaggedObject(t.customData||{})}static credentialFromJSON(t){const e=zt.fromJSON(t);return E(e,"argument-error"),e}static samlCredentialFromTaggedObject({_tokenResponse:t}){if(!t)return null;const{pendingToken:e,providerId:n}=t;if(!e||!n)return null;try{return zt._create(n,e)}catch(t){return null}}}class Wt extends Ut{constructor(){super("twitter.com")}static credential(t,e){return Dt._fromParams({providerId:Wt.PROVIDER_ID,signInMethod:Wt.TWITTER_SIGN_IN_METHOD,oauthToken:t,oauthTokenSecret:e})}static credentialFromResult(t){return Wt.credentialFromTaggedObject(t)}static credentialFromError(t){return Wt.credentialFromTaggedObject(t.customData||{})}static credentialFromTaggedObject({_tokenResponse:t}){if(!t)return null;const{oauthAccessToken:e,oauthTokenSecret:n}=t;if(!e||!n)return null;try{return Wt.credential(e,n)}catch(t){return null}}}async function Gt(t,e){return q(t,"POST","/v1/accounts:signUp",U(t,e))}Wt.TWITTER_SIGN_IN_METHOD="twitter.com",Wt.PROVIDER_ID="twitter.com";class Ht{constructor(t){this.user=t.user,this.providerId=t.providerId,this._tokenResponse=t._tokenResponse,this.operationType=t.operationType}static async _fromIdTokenResponse(t,e,n,r=!1){const i=await rt._fromIdTokenResponse(t,n,r),s=$t(n);return new Ht({user:i,providerId:s,_tokenResponse:n,operationType:e})}static async _forOperation(t,e,n){await t._updateTokensIfNecessary(n,!0);const r=$t(n);return new Ht({user:t,providerId:r,_tokenResponse:n,operationType:e})}}function $t(t){return t.providerId?t.providerId:"phoneNumber"in t?"phone":null}async function Yt(t){var e;const n=wt(t);if(await n._initializationPromise,null===(e=n.currentUser)||void 0===e?void 0:e.isAnonymous)return new Ht({user:n.currentUser,providerId:null,operationType:"signIn"});const r=await Gt(n,{returnSecureToken:!0}),i=await Ht._fromIdTokenResponse(n,"signIn",r,!0);return await n._updateCurrentUser(i.user),i}class Qt extends r.ZR{constructor(t,e,n,r){var i;super(e.code,e.message),this.operationType=n,this.user=r,Object.setPrototypeOf(this,Qt.prototype),this.customData={appName:t.name,tenantId:null!==(i=t.tenantId)&&void 0!==i?i:void 0,_serverResponse:e.customData._serverResponse,operationType:n}}static _fromErrorAndOperation(t,e,n,r){return new Qt(t,e,n,r)}}function Jt(t,e,n,r){return("reauthenticate"===e?n._getReauthenticationResolver(t):n._getIdTokenResponse(t)).catch((n=>{if("auth/multi-factor-auth-required"===n.code)throw Qt._fromErrorAndOperation(t,n,e,r);throw n}))}function Zt(t){return new Set(t.map((({providerId:t})=>t)).filter((t=>!!t)))}async function Xt(t,e){const n=(0,r.m9)(t);await ee(!0,n,e);const{providerUserInfo:i}=await async function(t,e){return V(t,"POST","/v1/accounts:update",e)}(n.auth,{idToken:await n.getIdToken(),deleteProvider:[e]}),s=Zt(i||[]);return n.providerData=n.providerData.filter((t=>s.has(t.providerId))),s.has("phone")||(n.phoneNumber=null),await n.auth._persistUserIfCurrent(n),n}async function te(t,e,n=!1){const r=await Q(t,e._linkToIdToken(t.auth,await t.getIdToken()),n);return Ht._forOperation(t,"link",r)}async function ee(t,e,n){await X(e);const r=!1===t?"provider-already-linked":"no-such-provider";E(Zt(e.providerData).has(n)===t,e.auth,r)}async function ne(t,e,n=!1){const{auth:r}=t,i="reauthenticate";try{const s=await Q(t,Jt(r,i,e,t),n);E(s.idToken,r,"internal-error");const o=Y(s.idToken);E(o,r,"internal-error");const{sub:a}=o;return E(t.uid===a,r,"user-mismatch"),Ht._forOperation(t,i,s)}catch(t){throw"auth/user-not-found"===(null==t?void 0:t.code)&&b(r,"user-mismatch"),t}}async function re(t,e,n=!1){const r="signIn",i=await Jt(t,r,e),s=await Ht._fromIdTokenResponse(t,r,i);return n||await t._updateCurrentUser(s.user),s}async function ie(t,e){return re(wt(t),e)}async function se(t,e){const n=(0,r.m9)(t);return await ee(!1,n,e.providerId),te(n,e)}async function oe(t,e){return ne((0,r.m9)(t),e)}async function ae(t,e){const n=wt(t),r=await async function(t,e){return q(t,"POST","/v1/accounts:signInWithCustomToken",U(t,e))}(n,{token:e,returnSecureToken:!0}),i=await Ht._fromIdTokenResponse(n,"signIn",r);return await n._updateCurrentUser(i.user),i}class ce{constructor(t,e){this.factorId=t,this.uid=e.mfaEnrollmentId,this.enrollmentTime=new Date(e.enrolledAt).toUTCString(),this.displayName=e.displayName}static _fromServerResponse(t,e){return"phoneInfo"in e?ue._fromServerResponse(t,e):b(t,"internal-error")}}class ue extends ce{constructor(t){super("phone",t),this.phoneNumber=t.phoneInfo}static _fromServerResponse(t,e){return new ue(e)}}function he(t,e,n){var r;E((null===(r=n.url)||void 0===r?void 0:r.length)>0,t,"invalid-continue-uri"),E(void 0===n.dynamicLinkDomain||n.dynamicLinkDomain.length>0,t,"invalid-dynamic-link-domain"),e.continueUrl=n.url,e.dynamicLinkDomain=n.dynamicLinkDomain,e.canHandleCodeInApp=n.handleCodeInApp,n.iOS&&(E(n.iOS.bundleId.length>0,t,"missing-ios-bundle-id"),e.iOSBundleId=n.iOS.bundleId),n.android&&(E(n.android.packageName.length>0,t,"missing-android-pkg-name"),e.androidInstallApp=n.android.installApp,e.androidMinimumVersionCode=n.android.minimumVersion,e.androidPackageName=n.android.packageName)}async function le(t,e,n){const i=(0,r.m9)(t),s={requestType:"PASSWORD_RESET",email:e};n&&he(i,s,n),await async function(t,e){return Nt(t,e)}(i,s)}async function de(t,e,n){await kt((0,r.m9)(t),{oobCode:e,newPassword:n})}async function fe(t,e){await async function(t,e){return V(t,"POST","/v1/accounts:update",U(t,e))}((0,r.m9)(t),{oobCode:e})}async function pe(t,e){const n=(0,r.m9)(t),i=await kt(n,{oobCode:e}),s=i.requestType;switch(E(s,n,"internal-error"),s){case"EMAIL_SIGNIN":break;case"VERIFY_AND_CHANGE_EMAIL":E(i.newEmail,n,"internal-error");break;case"REVERT_SECOND_FACTOR_ADDITION":E(i.mfaInfo,n,"internal-error");default:E(i.email,n,"internal-error")}let o=null;return i.mfaInfo&&(o=ce._fromServerResponse(wt(n),i.mfaInfo)),{data:{email:("VERIFY_AND_CHANGE_EMAIL"===i.requestType?i.newEmail:i.email)||null,previousEmail:("VERIFY_AND_CHANGE_EMAIL"===i.requestType?i.email:i.newEmail)||null,multiFactorInfo:o},operation:s}}async function me(t,e){const{data:n}=await pe((0,r.m9)(t),e);return n.email}async function ge(t,e,n){const r=wt(t),i=await Gt(r,{returnSecureToken:!0,email:e,password:n}),s=await Ht._fromIdTokenResponse(r,"signIn",i);return await r._updateCurrentUser(s.user),s}function ye(t,e,n){return ie((0,r.m9)(t),Mt.credential(e,n))}async function ve(t,e,n){const i=(0,r.m9)(t),s={requestType:"EMAIL_SIGNIN",email:e};E(n.handleCodeInApp,i,"argument-error"),n&&he(i,s,n),await async function(t,e){return Nt(t,e)}(i,s)}function be(t,e){const n=Pt.parseLink(e);return"EMAIL_SIGNIN"===(null==n?void 0:n.operation)}async function we(t,e,n){const i=(0,r.m9)(t),s=Mt.credentialWithLink(e,n||C());return E(s._tenantId===(i.tenantId||null),i,"tenant-id-mismatch"),ie(i,s)}async function Ie(t,e){const n={identifier:e,continueUri:D()?C():"http://localhost"},{signinMethods:i}=await async function(t,e){return V(t,"POST","/v1/accounts:createAuthUri",U(t,e))}((0,r.m9)(t),n);return i||[]}async function Te(t,e){const n=(0,r.m9)(t),i={requestType:"VERIFY_EMAIL",idToken:await t.getIdToken()};e&&he(n.auth,i,e);const{email:s}=await async function(t,e){return Nt(t,e)}(n.auth,i);s!==t.email&&await t.reload()}async function _e(t,e,n){const i=(0,r.m9)(t),s={requestType:"VERIFY_AND_CHANGE_EMAIL",idToken:await t.getIdToken(),newEmail:e};n&&he(i.auth,s,n);const{email:o}=await async function(t,e){return Nt(t,e)}(i.auth,s);o!==t.email&&await t.reload()}async function Ee(t,{displayName:e,photoURL:n}){if(void 0===e&&void 0===n)return;const i=(0,r.m9)(t),s={idToken:await i.getIdToken(),displayName:e,photoUrl:n,returnSecureToken:!0},o=await Q(i,async function(t,e){return V(t,"POST","/v1/accounts:update",e)}(i.auth,s));i.displayName=o.displayName||null,i.photoURL=o.photoUrl||null;const a=i.providerData.find((({providerId:t})=>"password"===t));a&&(a.displayName=i.displayName,a.photoURL=i.photoURL),await i._updateTokensIfNecessary(o)}function Se(t,e){return Ae((0,r.m9)(t),e,null)}function ke(t,e){return Ae((0,r.m9)(t),null,e)}async function Ae(t,e,n){const{auth:r}=t,i={idToken:await t.getIdToken(),returnSecureToken:!0};e&&(i.email=e),n&&(i.password=n);const s=await Q(t,At(r,i));await t._updateTokensIfNecessary(s,!0)}class Ne{constructor(t,e,n={}){this.isNewUser=t,this.providerId=e,this.profile=n}}class xe extends Ne{constructor(t,e,n,r){super(t,e,n),this.username=r}}class Ce extends Ne{constructor(t,e){super(t,"facebook.com",e)}}class De extends xe{constructor(t,e){super(t,"github.com",e,"string"==typeof(null==e?void 0:e.login)?null==e?void 0:e.login:null)}}class Oe extends Ne{constructor(t,e){super(t,"google.com",e)}}class Re extends xe{constructor(t,e,n){super(t,"twitter.com",e,n)}}function Pe(t){const{user:e,_tokenResponse:n}=t;return e.isAnonymous&&!n?{providerId:null,isNewUser:!1,profile:null}:function(t){var e,n;if(!t)return null;const{providerId:r}=t,i=t.rawUserInfo?JSON.parse(t.rawUserInfo):{},s=t.isNewUser||"identitytoolkit#SignupNewUserResponse"===t.kind;if(!r&&(null==t?void 0:t.idToken)){const r=null===(n=null===(e=Y(t.idToken))||void 0===e?void 0:e.firebase)||void 0===n?void 0:n.sign_in_provider;if(r)return new Ne(s,"anonymous"!==r&&"custom"!==r?r:null)}if(!r)return null;switch(r){case"facebook.com":return new Ce(s,i);case"github.com":return new De(s,i);case"google.com":return new Oe(s,i);case"twitter.com":return new Re(s,i,t.screenName||null);case"custom":case"anonymous":return new Ne(s,null);default:return new Ne(s,r,i)}}(n)}function Le(t,e){return(0,r.m9)(t).setPersistence(e)}function Me(t,e,n,i){return(0,r.m9)(t).onIdTokenChanged(e,n,i)}function Fe(t,e,n,i){return(0,r.m9)(t).onAuthStateChanged(e,n,i)}function Ue(t){(0,r.m9)(t).useDeviceLanguage()}function Ve(t,e){return(0,r.m9)(t).updateCurrentUser(e)}function je(t){return(0,r.m9)(t).signOut()}async function qe(t){return(0,r.m9)(t).delete()}class Be{constructor(t,e){this.type=t,this.credential=e}static _fromIdtoken(t){return new Be("enroll",t)}static _fromMfaPendingCredential(t){return new Be("signin",t)}toJSON(){return{multiFactorSession:{["enroll"===this.type?"idToken":"pendingCredential"]:this.credential}}}static fromJSON(t){var e,n;if(null==t?void 0:t.multiFactorSession){if(null===(e=t.multiFactorSession)||void 0===e?void 0:e.pendingCredential)return Be._fromMfaPendingCredential(t.multiFactorSession.pendingCredential);if(null===(n=t.multiFactorSession)||void 0===n?void 0:n.idToken)return Be._fromIdtoken(t.multiFactorSession.idToken)}return null}}class ze{constructor(t,e,n){this.session=t,this.hints=e,this.signInResolver=n}static _fromError(t,e){const n=wt(t),r=e.customData._serverResponse,i=(r.mfaInfo||[]).map((t=>ce._fromServerResponse(n,t)));E(r.mfaPendingCredential,n,"internal-error");const s=Be._fromMfaPendingCredential(r.mfaPendingCredential);return new ze(s,i,(async t=>{const i=await t._process(n,s);delete r.mfaInfo,delete r.mfaPendingCredential;const o=Object.assign(Object.assign({},r),{idToken:i.idToken,refreshToken:i.refreshToken});switch(e.operationType){case"signIn":const t=await Ht._fromIdTokenResponse(n,e.operationType,o);return await n._updateCurrentUser(t.user),t;case"reauthenticate":return E(e.user,n,"internal-error"),Ht._forOperation(e.user,e.operationType,o);default:b(n,"internal-error")}}))}async resolveSignIn(t){const e=t;return this.signInResolver(e)}}function Ke(t,e){var n;const i=(0,r.m9)(t),s=e;return E(e.customData.operationType,i,"argument-error"),E(null===(n=s.customData._serverResponse)||void 0===n?void 0:n.mfaPendingCredential,i,"argument-error"),ze._fromError(i,s)}class We{constructor(t){this.user=t,this.enrolledFactors=[],t._onReload((e=>{e.mfaInfo&&(this.enrolledFactors=e.mfaInfo.map((e=>ce._fromServerResponse(t.auth,e))))}))}static _fromUser(t){return new We(t)}async getSession(){return Be._fromIdtoken(await this.user.getIdToken())}async enroll(t,e){const n=t,r=await this.getSession(),i=await Q(this.user,n._process(this.user.auth,r,e));return await this.user._updateTokensIfNecessary(i),this.user.reload()}async unenroll(t){const e="string"==typeof t?t:t.uid,n=await this.user.getIdToken(),r=await Q(this.user,(i=this.user.auth,s={idToken:n,mfaEnrollmentId:e},V(i,"POST","/v2/accounts/mfaEnrollment:withdraw",U(i,s))));var i,s;this.enrolledFactors=this.enrolledFactors.filter((({uid:t})=>t!==e)),await this.user._updateTokensIfNecessary(r);try{await this.user.reload()}catch(t){if("auth/user-token-expired"!==t.code)throw t}}}const Ge=new WeakMap;function He(t){const e=(0,r.m9)(t);return Ge.has(e)||Ge.set(e,We._fromUser(e)),Ge.get(e)}const $e="__sak";class Ye{constructor(t,e){this.storageRetriever=t,this.type=e}_isAvailable(){try{return this.storage?(this.storage.setItem($e,"1"),this.storage.removeItem($e),Promise.resolve(!0)):Promise.resolve(!1)}catch(t){return Promise.resolve(!1)}}_set(t,e){return this.storage.setItem(t,JSON.stringify(e)),Promise.resolve()}_get(t){const e=this.storage.getItem(t);return Promise.resolve(e?JSON.parse(e):null)}_remove(t){return this.storage.removeItem(t),Promise.resolve()}get storage(){return this.storageRetriever()}}class Qe extends Ye{constructor(){super((()=>window.localStorage),"LOCAL"),this.boundEventHandler=(t,e)=>this.onStorageEvent(t,e),this.listeners={},this.localCache={},this.pollTimer=null,this.safariLocalStorageNotSynced=function(){const t=(0,r.z$)();return ht(t)||gt(t)}()&&function(){try{return!(!window||window===window.top)}catch(t){return!1}}(),this.fallbackToPolling=yt(),this._shouldAllowMigration=!0}forAllChangedKeys(t){for(const e of Object.keys(this.listeners)){const n=this.storage.getItem(e),r=this.localCache[e];n!==r&&t(e,r,n)}}onStorageEvent(t,e=!1){if(!t.key)return void this.forAllChangedKeys(((t,e,n)=>{this.notifyListeners(t,n)}));const n=t.key;if(e?this.detachListener():this.stopPolling(),this.safariLocalStorageNotSynced){const r=this.storage.getItem(n);if(t.newValue!==r)null!==t.newValue?this.storage.setItem(n,t.newValue):this.storage.removeItem(n);else if(this.localCache[n]===t.newValue&&!e)return}const i=()=>{const t=this.storage.getItem(n);(e||this.localCache[n]!==t)&&this.notifyListeners(n,t)},s=this.storage.getItem(n);(0,r.w1)()&&10===document.documentMode&&s!==t.newValue&&t.newValue!==t.oldValue?setTimeout(i,10):i()}notifyListeners(t,e){this.localCache[t]=e;const n=this.listeners[t];if(n)for(const t of Array.from(n))t(e?JSON.parse(e):e)}startPolling(){this.stopPolling(),this.pollTimer=setInterval((()=>{this.forAllChangedKeys(((t,e,n)=>{this.onStorageEvent(new StorageEvent("storage",{key:t,oldValue:e,newValue:n}),!0)}))}),1e3)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}attachListener(){window.addEventListener("storage",this.boundEventHandler)}detachListener(){window.removeEventListener("storage",this.boundEventHandler)}_addListener(t,e){0===Object.keys(this.listeners).length&&(this.fallbackToPolling?this.startPolling():this.attachListener()),this.listeners[t]||(this.listeners[t]=new Set,this.localCache[t]=this.storage.getItem(t)),this.listeners[t].add(e)}_removeListener(t,e){this.listeners[t]&&(this.listeners[t].delete(e),0===this.listeners[t].size&&delete this.listeners[t]),0===Object.keys(this.listeners).length&&(this.detachListener(),this.stopPolling())}async _set(t,e){await super._set(t,e),this.localCache[t]=JSON.stringify(e)}async _get(t){const e=await super._get(t);return this.localCache[t]=JSON.stringify(e),e}async _remove(t){await super._remove(t),delete this.localCache[t]}}Qe.type="LOCAL";const Je=Qe;class Ze extends Ye{constructor(){super((()=>window.sessionStorage),"SESSION")}_addListener(t,e){}_removeListener(t,e){}}Ze.type="SESSION";const Xe=Ze;class tn{constructor(t){this.eventTarget=t,this.handlersMap={},this.boundEventHandler=this.handleEvent.bind(this)}static _getInstance(t){const e=this.receivers.find((e=>e.isListeningto(t)));if(e)return e;const n=new tn(t);return this.receivers.push(n),n}isListeningto(t){return this.eventTarget===t}async handleEvent(t){const e=t,{eventId:n,eventType:r,data:i}=e.data,s=this.handlersMap[r];if(!(null==s?void 0:s.size))return;e.ports[0].postMessage({status:"ack",eventId:n,eventType:r});const o=Array.from(s).map((async t=>t(e.origin,i))),a=await function(t){return Promise.all(t.map((async t=>{try{return{fulfilled:!0,value:await t}}catch(t){return{fulfilled:!1,reason:t}}})))}(o);e.ports[0].postMessage({status:"done",eventId:n,eventType:r,response:a})}_subscribe(t,e){0===Object.keys(this.handlersMap).length&&this.eventTarget.addEventListener("message",this.boundEventHandler),this.handlersMap[t]||(this.handlersMap[t]=new Set),this.handlersMap[t].add(e)}_unsubscribe(t,e){this.handlersMap[t]&&e&&this.handlersMap[t].delete(e),e&&0!==this.handlersMap[t].size||delete this.handlersMap[t],0===Object.keys(this.handlersMap).length&&this.eventTarget.removeEventListener("message",this.boundEventHandler)}}function en(t="",e=10){let n="";for(let t=0;t<e;t++)n+=Math.floor(10*Math.random());return t+n}tn.receivers=[];class nn{constructor(t){this.target=t,this.handlers=new Set}removeMessageHandler(t){t.messageChannel&&(t.messageChannel.port1.removeEventListener("message",t.onMessage),t.messageChannel.port1.close()),this.handlers.delete(t)}async _send(t,e,n=50){const r="undefined"!=typeof MessageChannel?new MessageChannel:null;if(!r)throw new Error("connection_unavailable");let i,s;return new Promise(((o,a)=>{const c=en("",20);r.port1.start();const u=setTimeout((()=>{a(new Error("unsupported_event"))}),n);s={messageChannel:r,onMessage(t){const e=t;if(e.data.eventId===c)switch(e.data.status){case"ack":clearTimeout(u),i=setTimeout((()=>{a(new Error("timeout"))}),3e3);break;case"done":clearTimeout(i),o(e.data.response);break;default:clearTimeout(u),clearTimeout(i),a(new Error("invalid_response"))}}},this.handlers.add(s),r.port1.addEventListener("message",s.onMessage),this.target.postMessage({eventType:t,eventId:c,data:e},[r.port2])})).finally((()=>{s&&this.removeMessageHandler(s)}))}}function rn(){return window}function sn(){return void 0!==rn().WorkerGlobalScope&&"function"==typeof rn().importScripts}const on="firebaseLocalStorageDb",an="firebaseLocalStorage",cn="fbase_key";class un{constructor(t){this.request=t}toPromise(){return new Promise(((t,e)=>{this.request.addEventListener("success",(()=>{t(this.request.result)})),this.request.addEventListener("error",(()=>{e(this.request.error)}))}))}}function hn(t,e){return t.transaction([an],e?"readwrite":"readonly").objectStore(an)}function ln(){const t=indexedDB.open(on,1);return new Promise(((e,n)=>{t.addEventListener("error",(()=>{n(t.error)})),t.addEventListener("upgradeneeded",(()=>{const e=t.result;try{e.createObjectStore(an,{keyPath:cn})}catch(t){n(t)}})),t.addEventListener("success",(async()=>{const n=t.result;n.objectStoreNames.contains(an)?e(n):(n.close(),await function(){const t=indexedDB.deleteDatabase(on);return new un(t).toPromise()}(),e(await ln()))}))}))}async function dn(t,e,n){const r=hn(t,!0).put({[cn]:e,value:n});return new un(r).toPromise()}function fn(t,e){const n=hn(t,!0).delete(e);return new un(n).toPromise()}class pn{constructor(){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((()=>{}),(()=>{}))}async _openDb(){return this.db||(this.db=await ln()),this.db}async _withRetries(t){let e=0;for(;;)try{const e=await this._openDb();return await t(e)}catch(t){if(e++>3)throw t;this.db&&(this.db.close(),this.db=void 0)}}async initializeServiceWorkerMessaging(){return sn()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=tn._getInstance(sn()?self:null),this.receiver._subscribe("keyChanged",(async(t,e)=>({keyProcessed:(await this._poll()).includes(e.key)}))),this.receiver._subscribe("ping",(async(t,e)=>["keyChanged"]))}async initializeSender(){var t,e;if(this.activeServiceWorker=await async function(){if(!(null===navigator||void 0===navigator?void 0:navigator.serviceWorker))return null;try{return(await navigator.serviceWorker.ready).active}catch(t){return null}}(),!this.activeServiceWorker)return;this.sender=new nn(this.activeServiceWorker);const n=await this.sender._send("ping",{},800);n&&(null===(t=n[0])||void 0===t?void 0:t.fulfilled)&&(null===(e=n[0])||void 0===e?void 0:e.value.includes("keyChanged"))&&(this.serviceWorkerReceiverAvailable=!0)}async notifyServiceWorker(t){var e;if(this.sender&&this.activeServiceWorker&&((null===(e=null===navigator||void 0===navigator?void 0:navigator.serviceWorker)||void 0===e?void 0:e.controller)||null)===this.activeServiceWorker)try{await this.sender._send("keyChanged",{key:t},this.serviceWorkerReceiverAvailable?800:50)}catch(e){}}async _isAvailable(){try{if(!indexedDB)return!1;const t=await ln();return await dn(t,$e,"1"),await fn(t,$e),!0}catch(t){}return!1}async _withPendingWrite(t){this.pendingWrites++;try{await t()}finally{this.pendingWrites--}}async _set(t,e){return this._withPendingWrite((async()=>(await this._withRetries((n=>dn(n,t,e))),this.localCache[t]=e,this.notifyServiceWorker(t))))}async _get(t){const e=await this._withRetries((e=>async function(t,e){const n=hn(t,!1).get(e),r=await new un(n).toPromise();return void 0===r?null:r.value}(e,t)));return this.localCache[t]=e,e}async _remove(t){return this._withPendingWrite((async()=>(await this._withRetries((e=>fn(e,t))),delete this.localCache[t],this.notifyServiceWorker(t))))}async _poll(){const t=await this._withRetries((t=>{const e=hn(t,!1).getAll();return new un(e).toPromise()}));if(!t)return[];if(0!==this.pendingWrites)return[];const e=[],n=new Set;for(const{fbase_key:r,value:i}of t)n.add(r),JSON.stringify(this.localCache[r])!==JSON.stringify(i)&&(this.notifyListeners(r,i),e.push(r));for(const t of Object.keys(this.localCache))this.localCache[t]&&!n.has(t)&&(this.notifyListeners(t,null),e.push(t));return e}notifyListeners(t,e){this.localCache[t]=e;const n=this.listeners[t];if(n)for(const t of Array.from(n))t(e)}startPolling(){this.stopPolling(),this.pollTimer=setInterval((async()=>this._poll()),800)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}_addListener(t,e){0===Object.keys(this.listeners).length&&this.startPolling(),this.listeners[t]||(this.listeners[t]=new Set,this._get(t)),this.listeners[t].add(e)}_removeListener(t,e){this.listeners[t]&&(this.listeners[t].delete(e),0===this.listeners[t].size&&delete this.listeners[t]),0===Object.keys(this.listeners).length&&this.stopPolling()}}pn.type="LOCAL";const mn=pn;function gn(t){return new Promise(((e,n)=>{const r=document.createElement("script");var i,s;r.setAttribute("src",t),r.onload=e,r.onerror=t=>{const e=w("internal-error");e.customData=t,n(e)},r.type="text/javascript",r.charset="UTF-8",(null!==(s=null===(i=document.getElementsByTagName("head"))||void 0===i?void 0:i[0])&&void 0!==s?s:document).appendChild(r)}))}function yn(t){return`__${t}${Math.floor(1e6*Math.random())}`}const vn=1e12;class bn{constructor(t){this.auth=t,this.counter=vn,this._widgets=new Map}render(t,e){const n=this.counter;return this._widgets.set(n,new wn(t,this.auth.name,e||{})),this.counter++,n}reset(t){var e;const n=t||vn;null===(e=this._widgets.get(n))||void 0===e||e.delete(),this._widgets.delete(n)}getResponse(t){var e;const n=t||vn;return(null===(e=this._widgets.get(n))||void 0===e?void 0:e.getResponse())||""}async execute(t){var e;const n=t||vn;return null===(e=this._widgets.get(n))||void 0===e||e.execute(),""}}class wn{constructor(t,e,n){this.params=n,this.timerId=null,this.deleted=!1,this.responseToken=null,this.clickHandler=()=>{this.execute()};const r="string"==typeof t?document.getElementById(t):t;E(r,"argument-error",{appName:e}),this.container=r,this.isVisible="invisible"!==this.params.size,this.isVisible?this.execute():this.container.addEventListener("click",this.clickHandler)}getResponse(){return this.checkIfDeleted(),this.responseToken}delete(){this.checkIfDeleted(),this.deleted=!0,this.timerId&&(clearTimeout(this.timerId),this.timerId=null),this.container.removeEventListener("click",this.clickHandler)}execute(){this.checkIfDeleted(),this.timerId||(this.timerId=window.setTimeout((()=>{this.responseToken=function(t){const e=[],n="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";for(let t=0;t<50;t++)e.push(n.charAt(Math.floor(Math.random()*n.length)));return e.join("")}();const{callback:t,"expired-callback":e}=this.params;if(t)try{t(this.responseToken)}catch(t){}this.timerId=window.setTimeout((()=>{if(this.timerId=null,this.responseToken=null,e)try{e()}catch(t){}this.isVisible&&this.execute()}),6e4)}),500))}checkIfDeleted(){if(this.deleted)throw new Error("reCAPTCHA mock was already deleted!")}}const In=yn("rcb"),Tn=new R(3e4,6e4);class _n{constructor(){this.hostLanguage="",this.counter=0,this.librarySeparatelyLoaded=!!rn().grecaptcha}load(t,e=""){return E(function(t){return t.length<=6&&/^\s*[a-zA-Z0-9\-]*\s*$/.test(t)}(e),t,"argument-error"),this.shouldResolveImmediately(e)?Promise.resolve(rn().grecaptcha):new Promise(((n,i)=>{const s=rn().setTimeout((()=>{i(w(t,"network-request-failed"))}),Tn.get());rn()[In]=()=>{rn().clearTimeout(s),delete rn()[In];const r=rn().grecaptcha;if(!r)return void i(w(t,"internal-error"));const o=r.render;r.render=(t,e)=>{const n=o(t,e);return this.counter++,n},this.hostLanguage=e,n(r)},gn(`https://www.google.com/recaptcha/api.js??${(0,r.xO)({onload:In,render:"explicit",hl:e})}`).catch((()=>{clearTimeout(s),i(w(t,"internal-error"))}))}))}clearedOneInstance(){this.counter--}shouldResolveImmediately(t){return!!rn().grecaptcha&&(t===this.hostLanguage||this.counter>0||this.librarySeparatelyLoaded)}}class En{async load(t){return new bn(t)}clearedOneInstance(){}}const Sn="recaptcha",kn={theme:"light",type:"image"};class An{constructor(t,e=Object.assign({},kn),n){this.parameters=e,this.type=Sn,this.destroyed=!1,this.widgetId=null,this.tokenChangeListeners=new Set,this.renderPromise=null,this.recaptcha=null,this.auth=wt(n),this.isInvisible="invisible"===this.parameters.size,E("undefined"!=typeof document,this.auth,"operation-not-supported-in-this-environment");const r="string"==typeof t?document.getElementById(t):t;E(r,this.auth,"argument-error"),this.container=r,this.parameters.callback=this.makeTokenCallback(this.parameters.callback),this._recaptchaLoader=this.auth.settings.appVerificationDisabledForTesting?new En:new _n,this.validateStartingState()}async verify(){this.assertNotDestroyed();const t=await this.render(),e=this.getAssertedRecaptcha();return e.getResponse(t)||new Promise((n=>{const r=t=>{t&&(this.tokenChangeListeners.delete(r),n(t))};this.tokenChangeListeners.add(r),this.isInvisible&&e.execute(t)}))}render(){try{this.assertNotDestroyed()}catch(t){return Promise.reject(t)}return this.renderPromise||(this.renderPromise=this.makeRenderPromise().catch((t=>{throw this.renderPromise=null,t}))),this.renderPromise}_reset(){this.assertNotDestroyed(),null!==this.widgetId&&this.getAssertedRecaptcha().reset(this.widgetId)}clear(){this.assertNotDestroyed(),this.destroyed=!0,this._recaptchaLoader.clearedOneInstance(),this.isInvisible||this.container.childNodes.forEach((t=>{this.container.removeChild(t)}))}validateStartingState(){E(!this.parameters.sitekey,this.auth,"argument-error"),E(this.isInvisible||!this.container.hasChildNodes(),this.auth,"argument-error"),E("undefined"!=typeof document,this.auth,"operation-not-supported-in-this-environment")}makeTokenCallback(t){return e=>{if(this.tokenChangeListeners.forEach((t=>t(e))),"function"==typeof t)t(e);else if("string"==typeof t){const n=rn()[t];"function"==typeof n&&n(e)}}}assertNotDestroyed(){E(!this.destroyed,this.auth,"internal-error")}async makeRenderPromise(){if(await this.init(),!this.widgetId){let t=this.container;if(!this.isInvisible){const e=document.createElement("div");t.appendChild(e),t=e}this.widgetId=this.getAssertedRecaptcha().render(t,this.parameters)}return this.widgetId}async init(){E(D()&&!sn(),this.auth,"internal-error"),await function(){let t=null;return new Promise((e=>{"complete"!==document.readyState?(t=()=>e(),window.addEventListener("load",t)):e()})).catch((e=>{throw t&&window.removeEventListener("load",t),e}))}(),this.recaptcha=await this._recaptchaLoader.load(this.auth,this.auth.languageCode||void 0);const t=await async function(t){return(await V(t,"GET","/v1/recaptchaParams")).recaptchaSiteKey||""}(this.auth);E(t,this.auth,"internal-error"),this.parameters.sitekey=t}getAssertedRecaptcha(){return E(this.recaptcha,this.auth,"internal-error"),this.recaptcha}}class Nn{constructor(t,e){this.verificationId=t,this.onConfirmation=e}confirm(t){const e=Rt._fromVerification(this.verificationId,t);return this.onConfirmation(e)}}async function xn(t,e,n){const i=wt(t),s=await On(i,e,(0,r.m9)(n));return new Nn(s,(t=>ie(i,t)))}async function Cn(t,e,n){const i=(0,r.m9)(t);await ee(!1,i,"phone");const s=await On(i.auth,e,(0,r.m9)(n));return new Nn(s,(t=>se(i,t)))}async function Dn(t,e,n){const i=(0,r.m9)(t),s=await On(i.auth,e,(0,r.m9)(n));return new Nn(s,(t=>oe(i,t)))}async function On(t,e,n){var r;const i=await n.verify();try{let s;if(E("string"==typeof i,t,"argument-error"),E(n.type===Sn,t,"argument-error"),s="string"==typeof e?{phoneNumber:e}:e,"session"in s){const e=s.session;if("phoneNumber"in s){E("enroll"===e.type,t,"internal-error");const n=await function(t,e){return V(t,"POST","/v2/accounts/mfaEnrollment:start",U(t,e))}(t,{idToken:e.credential,phoneEnrollmentInfo:{phoneNumber:s.phoneNumber,recaptchaToken:i}});return n.phoneSessionInfo.sessionInfo}{E("signin"===e.type,t,"internal-error");const n=(null===(r=s.multiFactorHint)||void 0===r?void 0:r.uid)||s.multiFactorUid;E(n,t,"missing-multi-factor-info");const o=await function(t,e){return V(t,"POST","/v2/accounts/mfaSignIn:start",U(t,e))}(t,{mfaPendingCredential:e.credential,mfaEnrollmentId:n,phoneSignInInfo:{recaptchaToken:i}});return o.phoneResponseInfo.sessionInfo}}{const{sessionInfo:e}=await async function(t,e){return V(t,"POST","/v1/accounts:sendVerificationCode",U(t,e))}(t,{phoneNumber:s.phoneNumber,recaptchaToken:i});return e}}finally{n._reset()}}async function Rn(t,e){await te((0,r.m9)(t),e)}class Pn{constructor(t){this.providerId=Pn.PROVIDER_ID,this.auth=wt(t)}verifyPhoneNumber(t,e){return On(this.auth,t,(0,r.m9)(e))}static credential(t,e){return Rt._fromVerification(t,e)}static credentialFromResult(t){const e=t;return Pn.credentialFromTaggedObject(e)}static credentialFromError(t){return Pn.credentialFromTaggedObject(t.customData||{})}static credentialFromTaggedObject({_tokenResponse:t}){if(!t)return null;const{phoneNumber:e,temporaryProof:n}=t;return e&&n?Rt._fromTokenResponse(e,n):null}}function Ln(t,e){return e?N(e):(E(t._popupRedirectResolver,t,"argument-error"),t._popupRedirectResolver)}Pn.PROVIDER_ID="phone",Pn.PHONE_SIGN_IN_METHOD="phone";class Mn extends St{constructor(t){super("custom","custom"),this.params=t}_getIdTokenResponse(t){return Ct(t,this._buildIdpRequest())}_linkToIdToken(t,e){return Ct(t,this._buildIdpRequest(e))}_getReauthenticationResolver(t){return Ct(t,this._buildIdpRequest())}_buildIdpRequest(t){const e={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 t&&(e.idToken=t),e}}function Fn(t){return re(t.auth,new Mn(t),t.bypassAuthState)}function Un(t){const{auth:e,user:n}=t;return E(n,e,"internal-error"),ne(n,new Mn(t),t.bypassAuthState)}async function Vn(t){const{auth:e,user:n}=t;return E(n,e,"internal-error"),te(n,new Mn(t),t.bypassAuthState)}class jn{constructor(t,e,n,r,i=!1){this.auth=t,this.resolver=n,this.user=r,this.bypassAuthState=i,this.pendingPromise=null,this.eventManager=null,this.filter=Array.isArray(e)?e:[e]}execute(){return new Promise((async(t,e)=>{this.pendingPromise={resolve:t,reject:e};try{this.eventManager=await this.resolver._initialize(this.auth),await this.onExecution(),this.eventManager.registerConsumer(this)}catch(t){this.reject(t)}}))}async onAuthEvent(t){const{urlResponse:e,sessionId:n,postBody:r,tenantId:i,error:s,type:o}=t;if(s)return void this.reject(s);const a={auth:this.auth,requestUri:e,sessionId:n,tenantId:i||void 0,postBody:r||void 0,user:this.user,bypassAuthState:this.bypassAuthState};try{this.resolve(await this.getIdpTask(o)(a))}catch(t){this.reject(t)}}onError(t){this.reject(t)}getIdpTask(t){switch(t){case"signInViaPopup":case"signInViaRedirect":return Fn;case"linkViaPopup":case"linkViaRedirect":return Vn;case"reauthViaPopup":case"reauthViaRedirect":return Un;default:b(this.auth,"internal-error")}}resolve(t){k(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(t),this.unregisterAndCleanUp()}reject(t){k(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.reject(t),this.unregisterAndCleanUp()}unregisterAndCleanUp(){this.eventManager&&this.eventManager.unregisterConsumer(this),this.pendingPromise=null,this.cleanUp()}}const qn=new R(2e3,1e4);async function Bn(t,e,n){const r=wt(t);T(t,e,Ft);const i=Ln(r,n);return new Wn(r,"signInViaPopup",e,i).executeNotNull()}async function zn(t,e,n){const i=(0,r.m9)(t);T(i.auth,e,Ft);const s=Ln(i.auth,n);return new Wn(i.auth,"reauthViaPopup",e,s,i).executeNotNull()}async function Kn(t,e,n){const i=(0,r.m9)(t);T(i.auth,e,Ft);const s=Ln(i.auth,n);return new Wn(i.auth,"linkViaPopup",e,s,i).executeNotNull()}class Wn extends jn{constructor(t,e,n,r,i){super(t,e,r,i),this.provider=n,this.authWindow=null,this.pollId=null,Wn.currentPopupAction&&Wn.currentPopupAction.cancel(),Wn.currentPopupAction=this}async executeNotNull(){const t=await this.execute();return E(t,this.auth,"internal-error"),t}async onExecution(){k(1===this.filter.length,"Popup operations only handle one event");const t=en();this.authWindow=await this.resolver._openPopup(this.auth,this.provider,this.filter[0],t),this.authWindow.associatedEvent=t,this.resolver._originValidation(this.auth).catch((t=>{this.reject(t)})),this.resolver._isIframeWebStorageSupported(this.auth,(t=>{t||this.reject(w(this.auth,"web-storage-unsupported"))})),this.pollUserCancellation()}get eventId(){var t;return(null===(t=this.authWindow)||void 0===t?void 0:t.associatedEvent)||null}cancel(){this.reject(w(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,Wn.currentPopupAction=null}pollUserCancellation(){const t=()=>{var e,n;(null===(n=null===(e=this.authWindow)||void 0===e?void 0:e.window)||void 0===n?void 0:n.closed)?this.pollId=window.setTimeout((()=>{this.pollId=null,this.reject(w(this.auth,"popup-closed-by-user"))}),2e3):this.pollId=window.setTimeout(t,qn.get())};t()}}Wn.currentPopupAction=null;const Gn=new Map;class Hn extends jn{constructor(t,e,n=!1){super(t,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],e,void 0,n),this.eventId=null}async execute(){let t=Gn.get(this.auth._key());if(!t){try{const e=await async function(t,e){const n=Qn(e),r=Yn(t);if(!await r._isAvailable())return!1;const i="true"===await r._get(n);return await r._remove(n),i}(this.resolver,this.auth)?await super.execute():null;t=()=>Promise.resolve(e)}catch(e){t=()=>Promise.reject(e)}Gn.set(this.auth._key(),t)}return this.bypassAuthState||Gn.set(this.auth._key(),(()=>Promise.resolve(null))),t()}async onAuthEvent(t){if("signInViaRedirect"===t.type)return super.onAuthEvent(t);if("unknown"!==t.type){if(t.eventId){const e=await this.auth._redirectUserForId(t.eventId);if(e)return this.user=e,super.onAuthEvent(t);this.resolve(null)}}else this.resolve(null)}async onExecution(){}cleanUp(){}}async function $n(t,e){return Yn(t)._set(Qn(e),"true")}function Yn(t){return N(t._redirectPersistence)}function Qn(t){return ot("pendingRedirect",t.config.apiKey,t.name)}function Jn(t,e,n){return async function(t,e,n){const r=wt(t);T(t,e,Ft);const i=Ln(r,n);return await $n(i,r),i._openRedirect(r,e,"signInViaRedirect")}(t,e,n)}function Zn(t,e,n){return async function(t,e,n){const i=(0,r.m9)(t);T(i.auth,e,Ft);const s=Ln(i.auth,n);await $n(s,i.auth);const o=await nr(i);return s._openRedirect(i.auth,e,"reauthViaRedirect",o)}(t,e,n)}function Xn(t,e,n){return async function(t,e,n){const i=(0,r.m9)(t);T(i.auth,e,Ft);const s=Ln(i.auth,n);await ee(!1,i,e.providerId),await $n(s,i.auth);const o=await nr(i);return s._openRedirect(i.auth,e,"linkViaRedirect",o)}(t,e,n)}async function tr(t,e){return await wt(t)._initializationPromise,er(t,e,!1)}async function er(t,e,n=!1){const r=wt(t),i=Ln(r,e),s=new Hn(r,i,n),o=await s.execute();return o&&!n&&(delete o.user._redirectEventId,await r._persistUserIfCurrent(o.user),await r._setRedirectUser(null,e)),o}async function nr(t){const e=en(`${t.uid}:::`);return t._redirectEventId=e,await t.auth._setRedirectUser(t),await t.auth._persistUserIfCurrent(t),e}class rr{constructor(t){this.auth=t,this.cachedEventUids=new Set,this.consumers=new Set,this.queuedRedirectEvent=null,this.hasHandledPotentialRedirect=!1,this.lastProcessedEventTime=Date.now()}registerConsumer(t){this.consumers.add(t),this.queuedRedirectEvent&&this.isEventForConsumer(this.queuedRedirectEvent,t)&&(this.sendToConsumer(this.queuedRedirectEvent,t),this.saveEventToCache(this.queuedRedirectEvent),this.queuedRedirectEvent=null)}unregisterConsumer(t){this.consumers.delete(t)}onEvent(t){if(this.hasEventBeenHandled(t))return!1;let e=!1;return this.consumers.forEach((n=>{this.isEventForConsumer(t,n)&&(e=!0,this.sendToConsumer(t,n),this.saveEventToCache(t))})),this.hasHandledPotentialRedirect||!function(t){switch(t.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return!0;case"unknown":return sr(t);default:return!1}}(t)||(this.hasHandledPotentialRedirect=!0,e||(this.queuedRedirectEvent=t,e=!0)),e}sendToConsumer(t,e){var n;if(t.error&&!sr(t)){const r=(null===(n=t.error.code)||void 0===n?void 0:n.split("auth/")[1])||"internal-error";e.onError(w(this.auth,r))}else e.onAuthEvent(t)}isEventForConsumer(t,e){const n=null===e.eventId||!!t.eventId&&t.eventId===e.eventId;return e.filter.includes(t.type)&&n}hasEventBeenHandled(t){return Date.now()-this.lastProcessedEventTime>=6e5&&this.cachedEventUids.clear(),this.cachedEventUids.has(ir(t))}saveEventToCache(t){this.cachedEventUids.add(ir(t)),this.lastProcessedEventTime=Date.now()}}function ir(t){return[t.type,t.eventId,t.sessionId,t.tenantId].filter((t=>t)).join("-")}function sr({type:t,error:e}){return"unknown"===t&&"auth/no-auth-event"===(null==e?void 0:e.code)}const or=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,ar=/^https?/;function cr(t){const e=C(),{protocol:n,hostname:r}=new URL(e);if(t.startsWith("chrome-extension://")){const i=new URL(t);return""===i.hostname&&""===r?"chrome-extension:"===n&&t.replace("chrome-extension://","")===e.replace("chrome-extension://",""):"chrome-extension:"===n&&i.hostname===r}if(!ar.test(n))return!1;if(or.test(t))return r===t;const i=t.replace(/\./g,"\\.");return new RegExp("^(.+\\."+i+"|"+i+")$","i").test(r)}const ur=new R(3e4,6e4);function hr(){const t=rn().___jsl;if(null==t?void 0:t.H)for(const e of Object.keys(t.H))if(t.H[e].r=t.H[e].r||[],t.H[e].L=t.H[e].L||[],t.H[e].r=[...t.H[e].L],t.CP)for(let e=0;e<t.CP.length;e++)t.CP[e]=null}let lr=null;function dr(t){return lr=lr||function(t){return new Promise(((e,n)=>{var r,i,s;function o(){hr(),gapi.load("gapi.iframes",{callback:()=>{e(gapi.iframes.getContext())},ontimeout:()=>{hr(),n(w(t,"network-request-failed"))},timeout:ur.get()})}if(null===(i=null===(r=rn().gapi)||void 0===r?void 0:r.iframes)||void 0===i?void 0:i.Iframe)e(gapi.iframes.getContext());else{if(!(null===(s=rn().gapi)||void 0===s?void 0:s.load)){const e=yn("iframefcb");return rn()[e]=()=>{gapi.load?o():n(w(t,"network-request-failed"))},gn(`https://apis.google.com/js/api.js?onload=${e}`).catch((t=>n(t)))}o()}})).catch((t=>{throw lr=null,t}))}(t),lr}const fr=new R(5e3,15e3),pr={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},mr=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);function gr(t){const e=t.config;E(e.authDomain,t,"auth-domain-config-required");const n=e.emulator?P(e,"emulator/auth/iframe"):`https://${t.config.authDomain}/__/auth/iframe`,s={apiKey:e.apiKey,appName:t.name,v:i.Jn},o=mr.get(t.config.apiHost);o&&(s.eid=o);const a=t._getFrameworks();return a.length&&(s.fw=a.join(",")),`${n}?${(0,r.xO)(s).slice(1)}`}const yr={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"};class vr{constructor(t){this.window=t,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch(t){}}}function br(t,e,n,s,o,a){E(t.config.authDomain,t,"auth-domain-config-required"),E(t.config.apiKey,t,"invalid-api-key");const c={apiKey:t.config.apiKey,appName:t.name,authType:n,redirectUrl:s,v:i.Jn,eventId:o};if(e instanceof Ft){e.setDefaultLanguage(t.languageCode),c.providerId=e.providerId||"",(0,r.xb)(e.getCustomParameters())||(c.customParameters=JSON.stringify(e.getCustomParameters()));for(const[t,e]of Object.entries(a||{}))c[t]=e}if(e instanceof Ut){const t=e.getScopes().filter((t=>""!==t));t.length>0&&(c.scopes=t.join(","))}t.tenantId&&(c.tid=t.tenantId);const u=c;for(const t of Object.keys(u))void 0===u[t]&&delete u[t];return`${function({config:t}){return t.emulator?P(t,"emulator/auth/handler"):`https://${t.authDomain}/__/auth/handler`}(t)}?${(0,r.xO)(u).slice(1)}`}const wr="webStorageSupport",Ir=class{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=Xe,this._completeRedirectFn=er}async _openPopup(t,e,n,i){var s;return k(null===(s=this.eventManagers[t._key()])||void 0===s?void 0:s.manager,"_initialize() not called before _openPopup()"),function(t,e,n,i=500,s=600){const o=Math.max((window.screen.availHeight-s)/2,0).toString(),a=Math.max((window.screen.availWidth-i)/2,0).toString();let c="";const u=Object.assign(Object.assign({},yr),{width:i.toString(),height:s.toString(),top:o,left:a}),h=(0,r.z$)().toLowerCase();n&&(c=lt(h)?"_blank":n),ut(h)&&(e=e||"http://localhost",u.scrollbars="yes");const l=Object.entries(u).reduce(((t,[e,n])=>`${t}${e}=${n},`),"");if(function(t=(0,r.z$)()){var e;return gt(t)&&!!(null===(e=window.navigator)||void 0===e?void 0:e.standalone)}(h)&&"_self"!==c)return function(t,e){const n=document.createElement("a");n.href=t,n.target=e;const r=document.createEvent("MouseEvent");r.initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,1,null),n.dispatchEvent(r)}(e||"",c),new vr(null);const d=window.open(e||"",c,l);E(d,t,"popup-blocked");try{d.focus()}catch(t){}return new vr(d)}(t,br(t,e,n,C(),i),en())}async _openRedirect(t,e,n,r){var i;return await this._originValidation(t),i=br(t,e,n,C(),r),rn().location.href=i,new Promise((()=>{}))}_initialize(t){const e=t._key();if(this.eventManagers[e]){const{manager:t,promise:n}=this.eventManagers[e];return t?Promise.resolve(t):(k(n,"If manager is not set, promise should be"),n)}const n=this.initAndGetManager(t);return this.eventManagers[e]={promise:n},n.catch((()=>{delete this.eventManagers[e]})),n}async initAndGetManager(t){const e=await async function(t){const e=await dr(t),n=rn().gapi;return E(n,t,"internal-error"),e.open({where:document.body,url:gr(t),messageHandlersFilter:n.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:pr,dontclear:!0},(e=>new Promise((async(n,r)=>{await e.restyle({setHideOnLeave:!1});const i=w(t,"network-request-failed"),s=rn().setTimeout((()=>{r(i)}),fr.get());function o(){rn().clearTimeout(s),n(e)}e.ping(o).then(o,(()=>{r(i)}))}))))}(t),n=new rr(t);return e.register("authEvent",(e=>(E(null==e?void 0:e.authEvent,t,"invalid-auth-event"),{status:n.onEvent(e.authEvent)?"ACK":"ERROR"})),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[t._key()]={manager:n},this.iframes[t._key()]=e,n}_isIframeWebStorageSupported(t,e){this.iframes[t._key()].send(wr,{type:wr},(n=>{var r;const i=null===(r=null==n?void 0:n[0])||void 0===r?void 0:r.webStorageSupport;void 0!==i&&e(!!i),b(t,"internal-error")}),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(t){const e=t._key();return this.originValidationPromises[e]||(this.originValidationPromises[e]=async function(t){if(t.config.emulator)return;const{authorizedDomains:e}=await async function(t,e={}){return V(t,"GET","/v1/projects",e)}(t);for(const t of e)try{if(cr(t))return}catch(t){}b(t,"unauthorized-domain")}(t)),this.originValidationPromises[e]}get _shouldInitProactively(){return yt()||ht()||gt()}};class Tr extends class{constructor(t){this.factorId=t}_process(t,e,n){switch(e.type){case"enroll":return this._finalizeEnroll(t,e.credential,n);case"signin":return this._finalizeSignIn(t,e.credential);default:return S("unexpected MultiFactorSessionType")}}}{constructor(t){super("phone"),this.credential=t}static _fromCredential(t){return new Tr(t)}_finalizeEnroll(t,e,n){return function(t,e){return V(t,"POST","/v2/accounts/mfaEnrollment:finalize",U(t,e))}(t,{idToken:e,displayName:n,phoneVerificationInfo:this.credential._makeVerificationRequest()})}_finalizeSignIn(t,e){return function(t,e){return V(t,"POST","/v2/accounts/mfaSignIn:finalize",U(t,e))}(t,{mfaPendingCredential:e,phoneVerificationInfo:this.credential._makeVerificationRequest()})}}class _r{constructor(){}static assertion(t){return Tr._fromCredential(t)}}_r.FACTOR_ID="phone";var Er,Sr="@firebase/auth",kr="0.19.5";class Ar{constructor(t){this.auth=t,this.internalListeners=new Map}getUid(){var t;return this.assertAuthConfigured(),(null===(t=this.auth.currentUser)||void 0===t?void 0:t.uid)||null}async getToken(t){return this.assertAuthConfigured(),await this.auth._initializationPromise,this.auth.currentUser?{accessToken:await this.auth.currentUser.getIdToken(t)}:null}addAuthTokenListener(t){if(this.assertAuthConfigured(),this.internalListeners.has(t))return;const e=this.auth.onIdTokenChanged((e=>{var n;t((null===(n=e)||void 0===n?void 0:n.stsTokenManager.accessToken)||null)}));this.internalListeners.set(t,e),this.updateProactiveRefresh()}removeAuthTokenListener(t){this.assertAuthConfigured();const e=this.internalListeners.get(t);e&&(this.internalListeners.delete(t),e(),this.updateProactiveRefresh())}assertAuthConfigured(){E(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}function Nr(t=(0,i.Mq)()){const e=(0,i.qX)(t,"auth");return e.isInitialized()?e.getImmediate():x(t,{popupRedirectResolver:Ir,persistence:[mn,Je,Xe]})}Er="Browser",(0,i.Xd)(new a.wA("auth",((t,{options:e})=>{const n=t.getProvider("app").getImmediate(),{apiKey:r,authDomain:i}=n.options;return(t=>{E(r&&!r.includes(":"),"invalid-api-key",{appName:t.name}),E(!(null==i?void 0:i.includes(":")),"argument-error",{appName:t.name});const n={apiKey:r,authDomain:i,clientPlatform:Er,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:vt(Er)},s=new bt(t,n);return function(t,e){const n=(null==e?void 0:e.persistence)||[],r=(Array.isArray(n)?n:[n]).map(N);(null==e?void 0:e.errorMap)&&t._updateErrorMap(e.errorMap),t._initializeWithPersistence(r,null==e?void 0:e.popupRedirectResolver)}(s,e),s})(n)}),"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback(((t,e,n)=>{t.getProvider("auth-internal").initialize()}))),(0,i.Xd)(new a.wA("auth-internal",(t=>{return e=wt(t.getProvider("auth").getImmediate()),new Ar(e);var e}),"PRIVATE").setInstantiationMode("EXPLICIT")),(0,i.KN)(Sr,kr,void 0),(0,i.KN)(Sr,kr,"esm2017")},1591:(t,e,n)=>{"use strict";n.r(e),n.d(e,{AbstractUserDataWriter:()=>Sf,Bytes:()=>wd,CACHE_SIZE_UNLIMITED:()=>ed,CollectionReference:()=>Gl,DocumentReference:()=>Kl,DocumentSnapshot:()=>Xd,FieldPath:()=>vd,FieldValue:()=>Id,Firestore:()=>nd,FirestoreError:()=>Rr,GeoPoint:()=>Td,LoadBundleTask:()=>td,Query:()=>Wl,QueryConstraint:()=>of,QueryDocumentSnapshot:()=>tf,QuerySnapshot:()=>ef,SnapshotMetadata:()=>Zd,Timestamp:()=>Qr,Transaction:()=>Wf,WriteBatch:()=>Nf,_DatabaseId:()=>Ol,_DocumentKey:()=>vi,_EmptyAppCheckTokenProvider:()=>zr,_EmptyAuthCredentialsProvider:()=>Mr,_FieldPath:()=>ii,_cast:()=>Vl,_debugAssert:()=>Cr,_isBase64Available:()=>oi,_logWarn:()=>kr,_validateIsNotUsedTogether:()=>Ll,addDoc:()=>jf,arrayRemove:()=>Qf,arrayUnion:()=>Yf,clearIndexedDbPersistence:()=>hd,collection:()=>Hl,collectionGroup:()=>$l,connectFirestoreEmulator:()=>zl,deleteDoc:()=>Vf,deleteField:()=>Hf,disableNetwork:()=>fd,doc:()=>Yl,documentId:()=>bd,enableIndexedDbPersistence:()=>ad,enableMultiTabIndexedDbPersistence:()=>cd,enableNetwork:()=>dd,endAt:()=>wf,endBefore:()=>bf,ensureFirestoreConfigured:()=>sd,executeWrite:()=>zf,getDoc:()=>Cf,getDocFromCache:()=>Of,getDocFromServer:()=>Rf,getDocs:()=>Pf,getDocsFromCache:()=>Lf,getDocsFromServer:()=>Mf,getFirestore:()=>id,increment:()=>Jf,initializeFirestore:()=>rd,limit:()=>ff,limitToLast:()=>pf,loadBundle:()=>md,namedQuery:()=>gd,onSnapshot:()=>qf,onSnapshotsInSync:()=>Bf,orderBy:()=>lf,query:()=>af,queryEqual:()=>Jl,refEqual:()=>Ql,runTransaction:()=>Gf,serverTimestamp:()=>$f,setDoc:()=>Ff,setLogLevel:()=>_r,snapshotEqual:()=>rf,startAfter:()=>yf,startAt:()=>gf,terminate:()=>pd,updateDoc:()=>Uf,waitForPendingWrites:()=>ld,where:()=>uf,writeBatch:()=>Zf});var r,i=n(2238),s=n(8463),o=n(3333),a=n(4444),c="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==n.g?n.g:"undefined"!=typeof self?self:{},u={},h=h||{},l=c||self;function d(){}function f(t){var e=typeof t;return"array"==(e="object"!=e?e:t?Array.isArray(t)?"array":e:"null")||"object"==e&&"number"==typeof t.length}function p(t){var e=typeof t;return"object"==e&&null!=t||"function"==e}var m="closure_uid_"+(1e9*Math.random()>>>0),g=0;function y(t,e,n){return t.call.apply(t.bind,arguments)}function v(t,e,n){if(!t)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),t.apply(e,n)}}return function(){return t.apply(e,arguments)}}function b(t,e,n){return(b=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?y:v).apply(null,arguments)}function w(t,e){var n=Array.prototype.slice.call(arguments,1);return function(){var e=n.slice();return e.push.apply(e,arguments),t.apply(this,e)}}function I(t,e){function n(){}n.prototype=e.prototype,t.Z=e.prototype,t.prototype=new n,t.prototype.constructor=t,t.Vb=function(t,n,r){for(var i=Array(arguments.length-2),s=2;s<arguments.length;s++)i[s-2]=arguments[s];return e.prototype[n].apply(t,i)}}function T(){this.s=this.s,this.o=this.o}var _={};T.prototype.s=!1,T.prototype.na=function(){if(!this.s&&(this.s=!0,this.M(),0)){var t=function(t){return Object.prototype.hasOwnProperty.call(t,m)&&t[m]||(t[m]=++g)}(this);delete _[t]}},T.prototype.M=function(){if(this.o)for(;this.o.length;)this.o.shift()()};const E=Array.prototype.indexOf?function(t,e){return Array.prototype.indexOf.call(t,e,void 0)}:function(t,e){if("string"==typeof t)return"string"!=typeof e||1!=e.length?-1:t.indexOf(e,0);for(let n=0;n<t.length;n++)if(n in t&&t[n]===e)return n;return-1},S=Array.prototype.forEach?function(t,e,n){Array.prototype.forEach.call(t,e,n)}:function(t,e,n){const r=t.length,i="string"==typeof t?t.split(""):t;for(let s=0;s<r;s++)s in i&&e.call(n,i[s],s,t)};function k(t){return Array.prototype.concat.apply([],arguments)}function A(t){const e=t.length;if(0<e){const n=Array(e);for(let r=0;r<e;r++)n[r]=t[r];return n}return[]}function N(t){return/^[\s\xa0]*$/.test(t)}var x,C=String.prototype.trim?function(t){return t.trim()}:function(t){return/^[\s\xa0]*([\s\S]*?)[\s\xa0]*$/.exec(t)[1]};function D(t,e){return-1!=t.indexOf(e)}function O(t,e){return t<e?-1:t>e?1:0}t:{var R=l.navigator;if(R){var P=R.userAgent;if(P){x=P;break t}}x=""}function L(t,e,n){for(const r in t)e.call(n,t[r],r,t)}function M(t){const e={};for(const n in t)e[n]=t[n];return e}var F="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function U(t,e){let n,r;for(let e=1;e<arguments.length;e++){for(n in r=arguments[e],r)t[n]=r[n];for(let e=0;e<F.length;e++)n=F[e],Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}}function V(t){return V[" "](t),t}V[" "]=d;var j,q,B=D(x,"Opera"),z=D(x,"Trident")||D(x,"MSIE"),K=D(x,"Edge"),W=K||z,G=D(x,"Gecko")&&!(D(x.toLowerCase(),"webkit")&&!D(x,"Edge"))&&!(D(x,"Trident")||D(x,"MSIE"))&&!D(x,"Edge"),H=D(x.toLowerCase(),"webkit")&&!D(x,"Edge");function $(){var t=l.document;return t?t.documentMode:void 0}t:{var Y="",Q=(q=x,G?/rv:([^\);]+)(\)|;)/.exec(q):K?/Edge\/([\d\.]+)/.exec(q):z?/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(q):H?/WebKit\/(\S+)/.exec(q):B?/(?:Version)[ \/]?(\S+)/.exec(q):void 0);if(Q&&(Y=Q?Q[1]:""),z){var J=$();if(null!=J&&J>parseFloat(Y)){j=String(J);break t}}j=Y}var Z,X={};function tt(){return t=X,Object.prototype.hasOwnProperty.call(t,9)?t[9]:t[9]=function(){let t=0;const e=C(String(j)).split("."),n=C("9").split("."),r=Math.max(e.length,n.length);for(let o=0;0==t&&o<r;o++){var i=e[o]||"",s=n[o]||"";do{if(i=/(\d*)(\D*)(.*)/.exec(i)||["","","",""],s=/(\d*)(\D*)(.*)/.exec(s)||["","","",""],0==i[0].length&&0==s[0].length)break;t=O(0==i[1].length?0:parseInt(i[1],10),0==s[1].length?0:parseInt(s[1],10))||O(0==i[2].length,0==s[2].length)||O(i[2],s[2]),i=i[3],s=s[3]}while(0==t)}return 0<=t}();var t}l.document&&z?Z=$()||parseInt(j,10)||void 0:Z=void 0;var et=Z,nt=function(){if(!l.addEventListener||!Object.defineProperty)return!1;var t=!1,e=Object.defineProperty({},"passive",{get:function(){t=!0}});try{l.addEventListener("test",d,e),l.removeEventListener("test",d,e)}catch(t){}return t}();function rt(t,e){this.type=t,this.g=this.target=e,this.defaultPrevented=!1}function it(t,e){if(rt.call(this,t?t.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,t){var n=this.type=t.type,r=t.changedTouches&&t.changedTouches.length?t.changedTouches[0]:null;if(this.target=t.target||t.srcElement,this.g=e,e=t.relatedTarget){if(G){t:{try{V(e.nodeName);var i=!0;break t}catch(t){}i=!1}i||(e=null)}}else"mouseover"==n?e=t.fromElement:"mouseout"==n&&(e=t.toElement);this.relatedTarget=e,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!==t.clientX?t.clientX:t.pageX,this.clientY=void 0!==t.clientY?t.clientY:t.pageY,this.screenX=t.screenX||0,this.screenY=t.screenY||0),this.button=t.button,this.key=t.key||"",this.ctrlKey=t.ctrlKey,this.altKey=t.altKey,this.shiftKey=t.shiftKey,this.metaKey=t.metaKey,this.pointerId=t.pointerId||0,this.pointerType="string"==typeof t.pointerType?t.pointerType:st[t.pointerType]||"",this.state=t.state,this.i=t,t.defaultPrevented&&it.Z.h.call(this)}}rt.prototype.h=function(){this.defaultPrevented=!0},I(it,rt);var st={2:"touch",3:"pen",4:"mouse"};it.prototype.h=function(){it.Z.h.call(this);var t=this.i;t.preventDefault?t.preventDefault():t.returnValue=!1};var ot="closure_listenable_"+(1e6*Math.random()|0),at=0;function ct(t,e,n,r,i){this.listener=t,this.proxy=null,this.src=e,this.type=n,this.capture=!!r,this.ia=i,this.key=++at,this.ca=this.fa=!1}function ut(t){t.ca=!0,t.listener=null,t.proxy=null,t.src=null,t.ia=null}function ht(t){this.src=t,this.g={},this.h=0}function lt(t,e){var n=e.type;if(n in t.g){var r,i=t.g[n],s=E(i,e);(r=0<=s)&&Array.prototype.splice.call(i,s,1),r&&(ut(e),0==t.g[n].length&&(delete t.g[n],t.h--))}}function dt(t,e,n,r){for(var i=0;i<t.length;++i){var s=t[i];if(!s.ca&&s.listener==e&&s.capture==!!n&&s.ia==r)return i}return-1}ht.prototype.add=function(t,e,n,r,i){var s=t.toString();(t=this.g[s])||(t=this.g[s]=[],this.h++);var o=dt(t,e,r,i);return-1<o?(e=t[o],n||(e.fa=!1)):((e=new ct(e,this.src,s,!!r,i)).fa=n,t.push(e)),e};var ft="closure_lm_"+(1e6*Math.random()|0),pt={};function mt(t,e,n,r,i){if(r&&r.once)return yt(t,e,n,r,i);if(Array.isArray(e)){for(var s=0;s<e.length;s++)mt(t,e[s],n,r,i);return null}return n=Et(n),t&&t[ot]?t.N(e,n,p(r)?!!r.capture:!!r,i):gt(t,e,n,!1,r,i)}function gt(t,e,n,r,i,s){if(!e)throw Error("Invalid event type");var o=p(i)?!!i.capture:!!i,a=Tt(t);if(a||(t[ft]=a=new ht(t)),(n=a.add(e,n,r,o,s)).proxy)return n;if(r=function(){var t=It;return function e(n){return t.call(e.src,e.listener,n)}}(),n.proxy=r,r.src=t,r.listener=n,t.addEventListener)nt||(i=o),void 0===i&&(i=!1),t.addEventListener(e.toString(),r,i);else if(t.attachEvent)t.attachEvent(wt(e.toString()),r);else{if(!t.addListener||!t.removeListener)throw Error("addEventListener and attachEvent are unavailable.");t.addListener(r)}return n}function yt(t,e,n,r,i){if(Array.isArray(e)){for(var s=0;s<e.length;s++)yt(t,e[s],n,r,i);return null}return n=Et(n),t&&t[ot]?t.O(e,n,p(r)?!!r.capture:!!r,i):gt(t,e,n,!0,r,i)}function vt(t,e,n,r,i){if(Array.isArray(e))for(var s=0;s<e.length;s++)vt(t,e[s],n,r,i);else r=p(r)?!!r.capture:!!r,n=Et(n),t&&t[ot]?(t=t.i,(e=String(e).toString())in t.g&&-1<(n=dt(s=t.g[e],n,r,i))&&(ut(s[n]),Array.prototype.splice.call(s,n,1),0==s.length&&(delete t.g[e],t.h--))):t&&(t=Tt(t))&&(e=t.g[e.toString()],t=-1,e&&(t=dt(e,n,r,i)),(n=-1<t?e[t]:null)&&bt(n))}function bt(t){if("number"!=typeof t&&t&&!t.ca){var e=t.src;if(e&&e[ot])lt(e.i,t);else{var n=t.type,r=t.proxy;e.removeEventListener?e.removeEventListener(n,r,t.capture):e.detachEvent?e.detachEvent(wt(n),r):e.addListener&&e.removeListener&&e.removeListener(r),(n=Tt(e))?(lt(n,t),0==n.h&&(n.src=null,e[ft]=null)):ut(t)}}}function wt(t){return t in pt?pt[t]:pt[t]="on"+t}function It(t,e){if(t.ca)t=!0;else{e=new it(e,this);var n=t.listener,r=t.ia||t.src;t.fa&&bt(t),t=n.call(r,e)}return t}function Tt(t){return(t=t[ft])instanceof ht?t:null}var _t="__closure_events_fn_"+(1e9*Math.random()>>>0);function Et(t){return"function"==typeof t?t:(t[_t]||(t[_t]=function(e){return t.handleEvent(e)}),t[_t])}function St(){T.call(this),this.i=new ht(this),this.P=this,this.I=null}function kt(t,e){var n,r=t.I;if(r)for(n=[];r;r=r.I)n.push(r);if(t=t.P,r=e.type||e,"string"==typeof e)e=new rt(e,t);else if(e instanceof rt)e.target=e.target||t;else{var i=e;U(e=new rt(r,t),i)}if(i=!0,n)for(var s=n.length-1;0<=s;s--){var o=e.g=n[s];i=At(o,r,!0,e)&&i}if(i=At(o=e.g=t,r,!0,e)&&i,i=At(o,r,!1,e)&&i,n)for(s=0;s<n.length;s++)i=At(o=e.g=n[s],r,!1,e)&&i}function At(t,e,n,r){if(!(e=t.i.g[String(e)]))return!0;e=e.concat();for(var i=!0,s=0;s<e.length;++s){var o=e[s];if(o&&!o.ca&&o.capture==n){var a=o.listener,c=o.ia||o.src;o.fa&&lt(t.i,o),i=!1!==a.call(c,r)&&i}}return i&&!r.defaultPrevented}I(St,T),St.prototype[ot]=!0,St.prototype.removeEventListener=function(t,e,n,r){vt(this,t,e,n,r)},St.prototype.M=function(){if(St.Z.M.call(this),this.i){var t,e=this.i;for(t in e.g){for(var n=e.g[t],r=0;r<n.length;r++)ut(n[r]);delete e.g[t],e.h--}}this.I=null},St.prototype.N=function(t,e,n,r){return this.i.add(String(t),e,!1,n,r)},St.prototype.O=function(t,e,n,r){return this.i.add(String(t),e,!0,n,r)};var Nt=l.JSON.stringify;function xt(){var t=Mt;let e=null;return t.g&&(e=t.g,t.g=t.g.next,t.g||(t.h=null),e.next=null),e}var Ct,Dt=new class{constructor(t,e){this.i=t,this.j=e,this.h=0,this.g=null}get(){let t;return 0<this.h?(this.h--,t=this.g,this.g=t.next,t.next=null):t=this.i(),t}}((()=>new Ot),(t=>t.reset()));class Ot{constructor(){this.next=this.g=this.h=null}set(t,e){this.h=t,this.g=e,this.next=null}reset(){this.next=this.g=this.h=null}}function Rt(t){l.setTimeout((()=>{throw t}),0)}function Pt(t,e){Ct||function(){var t=l.Promise.resolve(void 0);Ct=function(){t.then(Ft)}}(),Lt||(Ct(),Lt=!0),Mt.add(t,e)}var Lt=!1,Mt=new class{constructor(){this.h=this.g=null}add(t,e){const n=Dt.get();n.set(t,e),this.h?this.h.next=n:this.g=n,this.h=n}};function Ft(){for(var t;t=xt();){try{t.h.call(t.g)}catch(t){Rt(t)}var e=Dt;e.j(t),100>e.h&&(e.h++,t.next=e.g,e.g=t)}Lt=!1}function Ut(t,e){St.call(this),this.h=t||1,this.g=e||l,this.j=b(this.kb,this),this.l=Date.now()}function Vt(t){t.da=!1,t.S&&(t.g.clearTimeout(t.S),t.S=null)}function jt(t,e,n){if("function"==typeof t)n&&(t=b(t,n));else{if(!t||"function"!=typeof t.handleEvent)throw Error("Invalid listener argument");t=b(t.handleEvent,t)}return 2147483647<Number(e)?-1:l.setTimeout(t,e||0)}function qt(t){t.g=jt((()=>{t.g=null,t.i&&(t.i=!1,qt(t))}),t.j);const e=t.h;t.h=null,t.m.apply(null,e)}I(Ut,St),(r=Ut.prototype).da=!1,r.S=null,r.kb=function(){if(this.da){var t=Date.now()-this.l;0<t&&t<.8*this.h?this.S=this.g.setTimeout(this.j,this.h-t):(this.S&&(this.g.clearTimeout(this.S),this.S=null),kt(this,"tick"),this.da&&(Vt(this),this.start()))}},r.start=function(){this.da=!0,this.S||(this.S=this.g.setTimeout(this.j,this.h),this.l=Date.now())},r.M=function(){Ut.Z.M.call(this),Vt(this),delete this.g};class Bt extends T{constructor(t,e){super(),this.m=t,this.j=e,this.h=null,this.i=!1,this.g=null}l(t){this.h=arguments,this.g?this.i=!0:qt(this)}M(){super.M(),this.g&&(l.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function zt(t){T.call(this),this.h=t,this.g={}}I(zt,T);var Kt=[];function Wt(t,e,n,r){Array.isArray(n)||(n&&(Kt[0]=n.toString()),n=Kt);for(var i=0;i<n.length;i++){var s=mt(e,n[i],r||t.handleEvent,!1,t.h||t);if(!s)break;t.g[s.key]=s}}function Gt(t){L(t.g,(function(t,e){this.g.hasOwnProperty(e)&&bt(t)}),t),t.g={}}function Ht(){this.g=!0}function $t(t,e,n,r){t.info((function(){return"XMLHTTP TEXT ("+e+"): "+function(t,e){if(!t.g)return e;if(!e)return null;try{var n=JSON.parse(e);if(n)for(t=0;t<n.length;t++)if(Array.isArray(n[t])){var r=n[t];if(!(2>r.length)){var i=r[1];if(Array.isArray(i)&&!(1>i.length)){var s=i[0];if("noop"!=s&&"stop"!=s&&"close"!=s)for(var o=1;o<i.length;o++)i[o]=""}}}return Nt(n)}catch(t){return e}}(t,n)+(r?" "+r:"")}))}zt.prototype.M=function(){zt.Z.M.call(this),Gt(this)},zt.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")},Ht.prototype.Aa=function(){this.g=!1},Ht.prototype.info=function(){};var Yt={},Qt=null;function Jt(){return Qt=Qt||new St}function Zt(t){rt.call(this,Yt.Ma,t)}function Xt(t){const e=Jt();kt(e,new Zt(e,t))}function te(t,e){rt.call(this,Yt.STAT_EVENT,t),this.stat=e}function ee(t){const e=Jt();kt(e,new te(e,t))}function ne(t,e){rt.call(this,Yt.Na,t),this.size=e}function re(t,e){if("function"!=typeof t)throw Error("Fn must not be null and must be a function");return l.setTimeout((function(){t()}),e)}Yt.Ma="serverreachability",I(Zt,rt),Yt.STAT_EVENT="statevent",I(te,rt),Yt.Na="timingevent",I(ne,rt);var ie={NO_ERROR:0,lb:1,yb:2,xb:3,sb:4,wb:5,zb:6,Ja:7,TIMEOUT:8,Cb:9},se={qb:"complete",Mb:"success",Ka:"error",Ja:"abort",Eb:"ready",Fb:"readystatechange",TIMEOUT:"timeout",Ab:"incrementaldata",Db:"progress",tb:"downloadprogress",Ub:"uploadprogress"};function oe(){}function ae(t){return t.h||(t.h=t.i())}function ce(){}oe.prototype.h=null;var ue,he={OPEN:"a",pb:"b",Ka:"c",Bb:"d"};function le(){rt.call(this,"d")}function de(){rt.call(this,"c")}function fe(){}function pe(t,e,n,r){this.l=t,this.j=e,this.m=n,this.X=r||1,this.V=new zt(this),this.P=ge,t=W?125:void 0,this.W=new Ut(t),this.H=null,this.i=!1,this.s=this.A=this.v=this.K=this.F=this.Y=this.B=null,this.D=[],this.g=null,this.C=0,this.o=this.u=null,this.N=-1,this.I=!1,this.O=0,this.L=null,this.aa=this.J=this.$=this.U=!1,this.h=new me}function me(){this.i=null,this.g="",this.h=!1}I(le,rt),I(de,rt),I(fe,oe),fe.prototype.g=function(){return new XMLHttpRequest},fe.prototype.i=function(){return{}},ue=new fe;var ge=45e3,ye={},ve={};function be(t,e,n){t.K=1,t.v=Be(Me(e)),t.s=n,t.U=!0,we(t,null)}function we(t,e){t.F=Date.now(),Ee(t),t.A=Me(t.v);var n=t.A,r=t.X;Array.isArray(r)||(r=[String(r)]),en(n.h,"t",r),t.C=0,n=t.l.H,t.h=new me,t.g=nr(t.l,n?e:null,!t.s),0<t.O&&(t.L=new Bt(b(t.Ia,t,t.g),t.O)),Wt(t.V,t.g,"readystatechange",t.gb),e=t.H?M(t.H):{},t.s?(t.u||(t.u="POST"),e["Content-Type"]="application/x-www-form-urlencoded",t.g.ea(t.A,t.u,t.s,e)):(t.u="GET",t.g.ea(t.A,t.u,null,e)),Xt(1),function(t,e,n,r,i,s){t.info((function(){if(t.g)if(s)for(var o="",a=s.split("&"),c=0;c<a.length;c++){var u=a[c].split("=");if(1<u.length){var h=u[0];u=u[1];var l=h.split("_");o=2<=l.length&&"type"==l[1]?o+(h+"=")+u+"&":o+(h+"=redacted&")}}else o=null;else o=s;return"XMLHTTP REQ ("+r+") [attempt "+i+"]: "+e+"\n"+n+"\n"+o}))}(t.j,t.u,t.A,t.m,t.X,t.s)}function Ie(t){return!!t.g&&"GET"==t.u&&2!=t.K&&t.l.Ba}function Te(t,e,n){let r,i=!0;for(;!t.I&&t.C<n.length;){if(r=_e(t,n),r==ve){4==e&&(t.o=4,ee(14),i=!1),$t(t.j,t.m,null,"[Incomplete Response]");break}if(r==ye){t.o=4,ee(15),$t(t.j,t.m,n,"[Invalid Chunk]"),i=!1;break}$t(t.j,t.m,r,null),xe(t,r)}Ie(t)&&r!=ve&&r!=ye&&(t.h.g="",t.C=0),4!=e||0!=n.length||t.h.h||(t.o=1,ee(16),i=!1),t.i=t.i&&i,i?0<n.length&&!t.aa&&(t.aa=!0,(e=t.l).g==t&&e.$&&!e.L&&(e.h.info("Great, no buffering proxy detected. Bytes received: "+n.length),$n(e),e.L=!0,ee(11))):($t(t.j,t.m,n,"[Invalid Chunked Response]"),Ne(t),Ae(t))}function _e(t,e){var n=t.C,r=e.indexOf("\n",n);return-1==r?ve:(n=Number(e.substring(n,r)),isNaN(n)?ye:(r+=1)+n>e.length?ve:(e=e.substr(r,n),t.C=r+n,e))}function Ee(t){t.Y=Date.now()+t.P,Se(t,t.P)}function Se(t,e){if(null!=t.B)throw Error("WatchDog timer not null");t.B=re(b(t.eb,t),e)}function ke(t){t.B&&(l.clearTimeout(t.B),t.B=null)}function Ae(t){0==t.l.G||t.I||Jn(t.l,t)}function Ne(t){ke(t);var e=t.L;e&&"function"==typeof e.na&&e.na(),t.L=null,Vt(t.W),Gt(t.V),t.g&&(e=t.g,t.g=null,e.abort(),e.na())}function xe(t,e){try{var n=t.l;if(0!=n.G&&(n.g==t||cn(n.i,t)))if(n.I=t.N,!t.J&&cn(n.i,t)&&3==n.G){try{var r=n.Ca.g.parse(e)}catch(t){r=null}if(Array.isArray(r)&&3==r.length){var i=r;if(0==i[0]){t:if(!n.u){if(n.g){if(!(n.g.F+3e3<t.F))break t;Qn(n),Vn(n)}Hn(n),ee(18)}}else n.ta=i[1],0<n.ta-n.U&&37500>i[2]&&n.N&&0==n.A&&!n.v&&(n.v=re(b(n.ab,n),6e3));if(1>=an(n.i)&&n.ka){try{n.ka()}catch(t){}n.ka=void 0}}else Xn(n,11)}else if((t.J||n.g==t)&&Qn(n),!N(e))for(i=n.Ca.g.parse(e),e=0;e<i.length;e++){let u=i[e];if(n.U=u[0],u=u[1],2==n.G)if("c"==u[0]){n.J=u[1],n.la=u[2];const e=u[3];null!=e&&(n.ma=e,n.h.info("VER="+n.ma));const i=u[4];null!=i&&(n.za=i,n.h.info("SVER="+n.za));const h=u[5];null!=h&&"number"==typeof h&&0<h&&(r=1.5*h,n.K=r,n.h.info("backChannelRequestTimeoutMs_="+r)),r=n;const l=t.g;if(l){const t=l.g?l.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(t){var s=r.i;!s.g&&(D(t,"spdy")||D(t,"quic")||D(t,"h2"))&&(s.j=s.l,s.g=new Set,s.h&&(un(s,s.h),s.h=null))}if(r.D){const t=l.g?l.g.getResponseHeader("X-HTTP-Session-Id"):null;t&&(r.sa=t,qe(r.F,r.D,t))}}n.G=3,n.j&&n.j.xa(),n.$&&(n.O=Date.now()-t.F,n.h.info("Handshake RTT: "+n.O+"ms"));var o=t;if((r=n).oa=er(r,r.H?r.la:null,r.W),o.J){hn(r.i,o);var a=o,c=r.K;c&&a.setTimeout(c),a.B&&(ke(a),Ee(a)),r.g=o}else Gn(r);0<n.l.length&&Bn(n)}else"stop"!=u[0]&&"close"!=u[0]||Xn(n,7);else 3==n.G&&("stop"==u[0]||"close"==u[0]?"stop"==u[0]?Xn(n,7):Un(n):"noop"!=u[0]&&n.j&&n.j.wa(u),n.A=0)}Xt(4)}catch(t){}}function Ce(t,e){if(t.forEach&&"function"==typeof t.forEach)t.forEach(e,void 0);else if(f(t)||"string"==typeof t)S(t,e,void 0);else{if(t.T&&"function"==typeof t.T)var n=t.T();else if(t.R&&"function"==typeof t.R)n=void 0;else if(f(t)||"string"==typeof t){n=[];for(var r=t.length,i=0;i<r;i++)n.push(i)}else for(i in n=[],r=0,t)n[r++]=i;r=function(t){if(t.R&&"function"==typeof t.R)return t.R();if("string"==typeof t)return t.split("");if(f(t)){for(var e=[],n=t.length,r=0;r<n;r++)e.push(t[r]);return e}for(r in e=[],n=0,t)e[n++]=t[r];return e}(t),i=r.length;for(var s=0;s<i;s++)e.call(void 0,r[s],n&&n[s],t)}}function De(t,e){this.h={},this.g=[],this.i=0;var n=arguments.length;if(1<n){if(n%2)throw Error("Uneven number of arguments");for(var r=0;r<n;r+=2)this.set(arguments[r],arguments[r+1])}else if(t)if(t instanceof De)for(n=t.T(),r=0;r<n.length;r++)this.set(n[r],t.get(n[r]));else for(r in t)this.set(r,t[r])}function Oe(t){if(t.i!=t.g.length){for(var e=0,n=0;e<t.g.length;){var r=t.g[e];Re(t.h,r)&&(t.g[n++]=r),e++}t.g.length=n}if(t.i!=t.g.length){var i={};for(n=e=0;e<t.g.length;)Re(i,r=t.g[e])||(t.g[n++]=r,i[r]=1),e++;t.g.length=n}}function Re(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(r=pe.prototype).setTimeout=function(t){this.P=t},r.gb=function(t){t=t.target;const e=this.L;e&&3==Rn(t)?e.l():this.Ia(t)},r.Ia=function(t){try{if(t==this.g)t:{const h=Rn(this.g);var e=this.g.Da();const d=this.g.ba();if(!(3>h)&&(3!=h||W||this.g&&(this.h.h||this.g.ga()||Pn(this.g)))){this.I||4!=h||7==e||Xt(8==e||0>=d?3:2),ke(this);var n=this.g.ba();this.N=n;e:if(Ie(this)){var r=Pn(this.g);t="";var i=r.length,s=4==Rn(this.g);if(!this.h.i){if("undefined"==typeof TextDecoder){Ne(this),Ae(this);var o="";break e}this.h.i=new l.TextDecoder}for(e=0;e<i;e++)this.h.h=!0,t+=this.h.i.decode(r[e],{stream:s&&e==i-1});r.splice(0,i),this.h.g+=t,this.C=0,o=this.h.g}else o=this.g.ga();if(this.i=200==n,function(t,e,n,r,i,s,o){t.info((function(){return"XMLHTTP RESP ("+r+") [ attempt "+i+"]: "+e+"\n"+n+"\n"+s+" "+o}))}(this.j,this.u,this.A,this.m,this.X,h,n),this.i){if(this.$&&!this.J){e:{if(this.g){var a,c=this.g;if((a=c.g?c.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!N(a)){var u=a;break e}}u=null}if(!(n=u)){this.i=!1,this.o=3,ee(12),Ne(this),Ae(this);break t}$t(this.j,this.m,n,"Initial handshake response via X-HTTP-Initial-Response"),this.J=!0,xe(this,n)}this.U?(Te(this,h,o),W&&this.i&&3==h&&(Wt(this.V,this.W,"tick",this.fb),this.W.start())):($t(this.j,this.m,o,null),xe(this,o)),4==h&&Ne(this),this.i&&!this.I&&(4==h?Jn(this.l,this):(this.i=!1,Ee(this)))}else 400==n&&0<o.indexOf("Unknown SID")?(this.o=3,ee(12)):(this.o=0,ee(13)),Ne(this),Ae(this)}}}catch(t){}},r.fb=function(){if(this.g){var t=Rn(this.g),e=this.g.ga();this.C<e.length&&(ke(this),Te(this,t,e),this.i&&4!=t&&Ee(this))}},r.cancel=function(){this.I=!0,Ne(this)},r.eb=function(){this.B=null;const t=Date.now();0<=t-this.Y?(function(t,e){t.info((function(){return"TIMEOUT: "+e}))}(this.j,this.A),2!=this.K&&(Xt(3),ee(17)),Ne(this),this.o=2,Ae(this)):Se(this,this.Y-t)},(r=De.prototype).R=function(){Oe(this);for(var t=[],e=0;e<this.g.length;e++)t.push(this.h[this.g[e]]);return t},r.T=function(){return Oe(this),this.g.concat()},r.get=function(t,e){return Re(this.h,t)?this.h[t]:e},r.set=function(t,e){Re(this.h,t)||(this.i++,this.g.push(t)),this.h[t]=e},r.forEach=function(t,e){for(var n=this.T(),r=0;r<n.length;r++){var i=n[r],s=this.get(i);t.call(e,s,i,this)}};var Pe=/^(?:([^:/?#.]+):)?(?:\/\/(?:([^\\/?#]*)@)?([^\\/?#]*?)(?::([0-9]+))?(?=[\\/?#]|$))?([^?#]+)?(?:\?([^#]*))?(?:#([\s\S]*))?$/;function Le(t,e){if(this.i=this.s=this.j="",this.m=null,this.o=this.l="",this.g=!1,t instanceof Le){this.g=void 0!==e?e:t.g,Fe(this,t.j),this.s=t.s,Ue(this,t.i),Ve(this,t.m),this.l=t.l,e=t.h;var n=new Je;n.i=e.i,e.g&&(n.g=new De(e.g),n.h=e.h),je(this,n),this.o=t.o}else t&&(n=String(t).match(Pe))?(this.g=!!e,Fe(this,n[1]||"",!0),this.s=ze(n[2]||""),Ue(this,n[3]||"",!0),Ve(this,n[4]),this.l=ze(n[5]||"",!0),je(this,n[6]||"",!0),this.o=ze(n[7]||"")):(this.g=!!e,this.h=new Je(null,this.g))}function Me(t){return new Le(t)}function Fe(t,e,n){t.j=n?ze(e,!0):e,t.j&&(t.j=t.j.replace(/:$/,""))}function Ue(t,e,n){t.i=n?ze(e,!0):e}function Ve(t,e){if(e){if(e=Number(e),isNaN(e)||0>e)throw Error("Bad port number "+e);t.m=e}else t.m=null}function je(t,e,n){e instanceof Je?(t.h=e,function(t,e){e&&!t.j&&(Ze(t),t.i=null,t.g.forEach((function(t,e){var n=e.toLowerCase();e!=n&&(Xe(this,e),en(this,n,t))}),t)),t.j=e}(t.h,t.g)):(n||(e=Ke(e,Ye)),t.h=new Je(e,t.g))}function qe(t,e,n){t.h.set(e,n)}function Be(t){return qe(t,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)),t}function ze(t,e){return t?e?decodeURI(t.replace(/%25/g,"%2525")):decodeURIComponent(t):""}function Ke(t,e,n){return"string"==typeof t?(t=encodeURI(t).replace(e,We),n&&(t=t.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),t):null}function We(t){return"%"+((t=t.charCodeAt(0))>>4&15).toString(16)+(15&t).toString(16)}Le.prototype.toString=function(){var t=[],e=this.j;e&&t.push(Ke(e,Ge,!0),":");var n=this.i;return(n||"file"==e)&&(t.push("//"),(e=this.s)&&t.push(Ke(e,Ge,!0),"@"),t.push(encodeURIComponent(String(n)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),null!=(n=this.m)&&t.push(":",String(n))),(n=this.l)&&(this.i&&"/"!=n.charAt(0)&&t.push("/"),t.push(Ke(n,"/"==n.charAt(0)?$e:He,!0))),(n=this.h.toString())&&t.push("?",n),(n=this.o)&&t.push("#",Ke(n,Qe)),t.join("")};var Ge=/[#\/\?@]/g,He=/[#\?:]/g,$e=/[#\?]/g,Ye=/[#\?@]/g,Qe=/#/g;function Je(t,e){this.h=this.g=null,this.i=t||null,this.j=!!e}function Ze(t){t.g||(t.g=new De,t.h=0,t.i&&function(t,e){if(t){t=t.split("&");for(var n=0;n<t.length;n++){var r=t[n].indexOf("="),i=null;if(0<=r){var s=t[n].substring(0,r);i=t[n].substring(r+1)}else s=t[n];e(s,i?decodeURIComponent(i.replace(/\+/g," ")):"")}}}(t.i,(function(e,n){t.add(decodeURIComponent(e.replace(/\+/g," ")),n)})))}function Xe(t,e){Ze(t),e=nn(t,e),Re(t.g.h,e)&&(t.i=null,t.h-=t.g.get(e).length,Re((t=t.g).h,e)&&(delete t.h[e],t.i--,t.g.length>2*t.i&&Oe(t)))}function tn(t,e){return Ze(t),e=nn(t,e),Re(t.g.h,e)}function en(t,e,n){Xe(t,e),0<n.length&&(t.i=null,t.g.set(nn(t,e),A(n)),t.h+=n.length)}function nn(t,e){return e=String(e),t.j&&(e=e.toLowerCase()),e}function rn(t){this.l=t||sn,t=l.PerformanceNavigationTiming?0<(t=l.performance.getEntriesByType("navigation")).length&&("hq"==t[0].nextHopProtocol||"h2"==t[0].nextHopProtocol):!!(l.g&&l.g.Ea&&l.g.Ea()&&l.g.Ea().Zb),this.j=t?this.l:1,this.g=null,1<this.j&&(this.g=new Set),this.h=null,this.i=[]}(r=Je.prototype).add=function(t,e){Ze(this),this.i=null,t=nn(this,t);var n=this.g.get(t);return n||this.g.set(t,n=[]),n.push(e),this.h+=1,this},r.forEach=function(t,e){Ze(this),this.g.forEach((function(n,r){S(n,(function(n){t.call(e,n,r,this)}),this)}),this)},r.T=function(){Ze(this);for(var t=this.g.R(),e=this.g.T(),n=[],r=0;r<e.length;r++)for(var i=t[r],s=0;s<i.length;s++)n.push(e[r]);return n},r.R=function(t){Ze(this);var e=[];if("string"==typeof t)tn(this,t)&&(e=k(e,this.g.get(nn(this,t))));else{t=this.g.R();for(var n=0;n<t.length;n++)e=k(e,t[n])}return e},r.set=function(t,e){return Ze(this),this.i=null,tn(this,t=nn(this,t))&&(this.h-=this.g.get(t).length),this.g.set(t,[e]),this.h+=1,this},r.get=function(t,e){return t&&0<(t=this.R(t)).length?String(t[0]):e},r.toString=function(){if(this.i)return this.i;if(!this.g)return"";for(var t=[],e=this.g.T(),n=0;n<e.length;n++){var r=e[n],i=encodeURIComponent(String(r));r=this.R(r);for(var s=0;s<r.length;s++){var o=i;""!==r[s]&&(o+="="+encodeURIComponent(String(r[s]))),t.push(o)}}return this.i=t.join("&")};var sn=10;function on(t){return!!t.h||!!t.g&&t.g.size>=t.j}function an(t){return t.h?1:t.g?t.g.size:0}function cn(t,e){return t.h?t.h==e:!!t.g&&t.g.has(e)}function un(t,e){t.g?t.g.add(e):t.h=e}function hn(t,e){t.h&&t.h==e?t.h=null:t.g&&t.g.has(e)&&t.g.delete(e)}function ln(t){if(null!=t.h)return t.i.concat(t.h.D);if(null!=t.g&&0!==t.g.size){let e=t.i;for(const n of t.g.values())e=e.concat(n.D);return e}return A(t.i)}function dn(){}function fn(){this.g=new dn}function pn(t,e,n){const r=n||"";try{Ce(t,(function(t,n){let i=t;p(t)&&(i=Nt(t)),e.push(r+n+"="+encodeURIComponent(i))}))}catch(t){throw e.push(r+"type="+encodeURIComponent("_badmap")),t}}function mn(t,e,n,r,i){try{e.onload=null,e.onerror=null,e.onabort=null,e.ontimeout=null,i(r)}catch(t){}}function gn(t){this.l=t.$b||null,this.j=t.ib||!1}function yn(t,e){St.call(this),this.D=t,this.u=e,this.m=void 0,this.readyState=vn,this.status=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.v=new Headers,this.h=null,this.C="GET",this.B="",this.g=!1,this.A=this.j=this.l=null}rn.prototype.cancel=function(){if(this.i=ln(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&0!==this.g.size){for(const t of this.g.values())t.cancel();this.g.clear()}},dn.prototype.stringify=function(t){return l.JSON.stringify(t,void 0)},dn.prototype.parse=function(t){return l.JSON.parse(t,void 0)},I(gn,oe),gn.prototype.g=function(){return new yn(this.l,this.j)},gn.prototype.i=function(t){return function(){return t}}({}),I(yn,St);var vn=0;function bn(t){t.j.read().then(t.Sa.bind(t)).catch(t.ha.bind(t))}function wn(t){t.readyState=4,t.l=null,t.j=null,t.A=null,In(t)}function In(t){t.onreadystatechange&&t.onreadystatechange.call(t)}(r=yn.prototype).open=function(t,e){if(this.readyState!=vn)throw this.abort(),Error("Error reopening a connection");this.C=t,this.B=e,this.readyState=1,In(this)},r.send=function(t){if(1!=this.readyState)throw this.abort(),Error("need to call open() first. ");this.g=!0;const e={headers:this.v,method:this.C,credentials:this.m,cache:void 0};t&&(e.body=t),(this.D||l).fetch(new Request(this.B,e)).then(this.Va.bind(this),this.ha.bind(this))},r.abort=function(){this.response=this.responseText="",this.v=new Headers,this.status=0,this.j&&this.j.cancel("Request was aborted."),1<=this.readyState&&this.g&&4!=this.readyState&&(this.g=!1,wn(this)),this.readyState=vn},r.Va=function(t){if(this.g&&(this.l=t,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=t.headers,this.readyState=2,In(this)),this.g&&(this.readyState=3,In(this),this.g)))if("arraybuffer"===this.responseType)t.arrayBuffer().then(this.Ta.bind(this),this.ha.bind(this));else if(void 0!==l.ReadableStream&&"body"in t){if(this.j=t.body.getReader(),this.u){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.A=new TextDecoder;bn(this)}else t.text().then(this.Ua.bind(this),this.ha.bind(this))},r.Sa=function(t){if(this.g){if(this.u&&t.value)this.response.push(t.value);else if(!this.u){var e=t.value?t.value:new Uint8Array(0);(e=this.A.decode(e,{stream:!t.done}))&&(this.response=this.responseText+=e)}t.done?wn(this):In(this),3==this.readyState&&bn(this)}},r.Ua=function(t){this.g&&(this.response=this.responseText=t,wn(this))},r.Ta=function(t){this.g&&(this.response=t,wn(this))},r.ha=function(){this.g&&wn(this)},r.setRequestHeader=function(t,e){this.v.append(t,e)},r.getResponseHeader=function(t){return this.h&&this.h.get(t.toLowerCase())||""},r.getAllResponseHeaders=function(){if(!this.h)return"";const t=[],e=this.h.entries();for(var n=e.next();!n.done;)n=n.value,t.push(n[0]+": "+n[1]),n=e.next();return t.join("\r\n")},Object.defineProperty(yn.prototype,"withCredentials",{get:function(){return"include"===this.m},set:function(t){this.m=t?"include":"same-origin"}});var Tn=l.JSON.parse;function _n(t){St.call(this),this.headers=new De,this.u=t||null,this.h=!1,this.C=this.g=null,this.H="",this.m=0,this.j="",this.l=this.F=this.v=this.D=!1,this.B=0,this.A=null,this.J=En,this.K=this.L=!1}I(_n,St);var En="",Sn=/^https?$/i,kn=["POST","PUT"];function An(t){return"content-type"==t.toLowerCase()}function Nn(t,e){t.h=!1,t.g&&(t.l=!0,t.g.abort(),t.l=!1),t.j=e,t.m=5,xn(t),Dn(t)}function xn(t){t.D||(t.D=!0,kt(t,"complete"),kt(t,"error"))}function Cn(t){if(t.h&&void 0!==h&&(!t.C[1]||4!=Rn(t)||2!=t.ba()))if(t.v&&4==Rn(t))jt(t.Fa,0,t);else if(kt(t,"readystatechange"),4==Rn(t)){t.h=!1;try{const a=t.ba();t:switch(a){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var e=!0;break t;default:e=!1}var n;if(!(n=e)){var r;if(r=0===a){var i=String(t.H).match(Pe)[1]||null;if(!i&&l.self&&l.self.location){var s=l.self.location.protocol;i=s.substr(0,s.length-1)}r=!Sn.test(i?i.toLowerCase():"")}n=r}if(n)kt(t,"complete"),kt(t,"success");else{t.m=6;try{var o=2<Rn(t)?t.g.statusText:""}catch(t){o=""}t.j=o+" ["+t.ba()+"]",xn(t)}}finally{Dn(t)}}}function Dn(t,e){if(t.g){On(t);const n=t.g,r=t.C[0]?d:null;t.g=null,t.C=null,e||kt(t,"ready");try{n.onreadystatechange=r}catch(t){}}}function On(t){t.g&&t.K&&(t.g.ontimeout=null),t.A&&(l.clearTimeout(t.A),t.A=null)}function Rn(t){return t.g?t.g.readyState:0}function Pn(t){try{if(!t.g)return null;if("response"in t.g)return t.g.response;switch(t.J){case En:case"text":return t.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in t.g)return t.g.mozResponseArrayBuffer}return null}catch(t){return null}}function Ln(t,e,n){t:{for(r in n){var r=!1;break t}r=!0}r||(n=function(t){let e="";return L(t,(function(t,n){e+=n,e+=":",e+=t,e+="\r\n"})),e}(n),"string"==typeof t?null!=n&&encodeURIComponent(String(n)):qe(t,e,n))}function Mn(t,e,n){return n&&n.internalChannelParams&&n.internalChannelParams[t]||e}function Fn(t){this.za=0,this.l=[],this.h=new Ht,this.la=this.oa=this.F=this.W=this.g=this.sa=this.D=this.aa=this.o=this.P=this.s=null,this.Za=this.V=0,this.Xa=Mn("failFast",!1,t),this.N=this.v=this.u=this.m=this.j=null,this.X=!0,this.I=this.ta=this.U=-1,this.Y=this.A=this.C=0,this.Pa=Mn("baseRetryDelayMs",5e3,t),this.$a=Mn("retryDelaySeedMs",1e4,t),this.Ya=Mn("forwardChannelMaxRetries",2,t),this.ra=Mn("forwardChannelRequestTimeoutMs",2e4,t),this.qa=t&&t.xmlHttpFactory||void 0,this.Ba=t&&t.Yb||!1,this.K=void 0,this.H=t&&t.supportsCrossDomainXhr||!1,this.J="",this.i=new rn(t&&t.concurrentRequestLimit),this.Ca=new fn,this.ja=t&&t.fastHandshake||!1,this.Ra=t&&t.Wb||!1,t&&t.Aa&&this.h.Aa(),t&&t.forceLongPolling&&(this.X=!1),this.$=!this.ja&&this.X&&t&&t.detectBufferingProxy||!1,this.ka=void 0,this.O=0,this.L=!1,this.B=null,this.Wa=!t||!1!==t.Xb}function Un(t){if(jn(t),3==t.G){var e=t.V++,n=Me(t.F);qe(n,"SID",t.J),qe(n,"RID",e),qe(n,"TYPE","terminate"),Kn(t,n),(e=new pe(t,t.h,e,void 0)).K=2,e.v=Be(Me(n)),n=!1,l.navigator&&l.navigator.sendBeacon&&(n=l.navigator.sendBeacon(e.v.toString(),"")),!n&&l.Image&&((new Image).src=e.v,n=!0),n||(e.g=nr(e.l,null),e.g.ea(e.v)),e.F=Date.now(),Ee(e)}tr(t)}function Vn(t){t.g&&($n(t),t.g.cancel(),t.g=null)}function jn(t){Vn(t),t.u&&(l.clearTimeout(t.u),t.u=null),Qn(t),t.i.cancel(),t.m&&("number"==typeof t.m&&l.clearTimeout(t.m),t.m=null)}function qn(t,e){t.l.push(new class{constructor(t,e){this.h=t,this.g=e}}(t.Za++,e)),3==t.G&&Bn(t)}function Bn(t){on(t.i)||t.m||(t.m=!0,Pt(t.Ha,t),t.C=0)}function zn(t,e){var n;n=e?e.m:t.V++;const r=Me(t.F);qe(r,"SID",t.J),qe(r,"RID",n),qe(r,"AID",t.U),Kn(t,r),t.o&&t.s&&Ln(r,t.o,t.s),n=new pe(t,t.h,n,t.C+1),null===t.o&&(n.H=t.s),e&&(t.l=e.D.concat(t.l)),e=Wn(t,n,1e3),n.setTimeout(Math.round(.5*t.ra)+Math.round(.5*t.ra*Math.random())),un(t.i,n),be(n,r,e)}function Kn(t,e){t.j&&Ce({},(function(t,n){qe(e,n,t)}))}function Wn(t,e,n){n=Math.min(t.l.length,n);var r=t.j?b(t.j.Oa,t.j,t):null;t:{var i=t.l;let e=-1;for(;;){const t=["count="+n];-1==e?0<n?(e=i[0].h,t.push("ofs="+e)):e=0:t.push("ofs="+e);let s=!0;for(let o=0;o<n;o++){let n=i[o].h;const a=i[o].g;if(n-=e,0>n)e=Math.max(0,i[o].h-100),s=!1;else try{pn(a,t,"req"+n+"_")}catch(t){r&&r(a)}}if(s){r=t.join("&");break t}}}return t=t.l.splice(0,n),e.D=t,r}function Gn(t){t.g||t.u||(t.Y=1,Pt(t.Ga,t),t.A=0)}function Hn(t){return!(t.g||t.u||3<=t.A||(t.Y++,t.u=re(b(t.Ga,t),Zn(t,t.A)),t.A++,0))}function $n(t){null!=t.B&&(l.clearTimeout(t.B),t.B=null)}function Yn(t){t.g=new pe(t,t.h,"rpc",t.Y),null===t.o&&(t.g.H=t.s),t.g.O=0;var e=Me(t.oa);qe(e,"RID","rpc"),qe(e,"SID",t.J),qe(e,"CI",t.N?"0":"1"),qe(e,"AID",t.U),Kn(t,e),qe(e,"TYPE","xmlhttp"),t.o&&t.s&&Ln(e,t.o,t.s),t.K&&t.g.setTimeout(t.K);var n=t.g;t=t.la,n.K=1,n.v=Be(Me(e)),n.s=null,n.U=!0,we(n,t)}function Qn(t){null!=t.v&&(l.clearTimeout(t.v),t.v=null)}function Jn(t,e){var n=null;if(t.g==e){Qn(t),$n(t),t.g=null;var r=2}else{if(!cn(t.i,e))return;n=e.D,hn(t.i,e),r=1}if(t.I=e.N,0!=t.G)if(e.i)if(1==r){n=e.s?e.s.length:0,e=Date.now()-e.F;var i=t.C;kt(r=Jt(),new ne(r,n,e,i)),Bn(t)}else Gn(t);else if(3==(i=e.o)||0==i&&0<t.I||!(1==r&&function(t,e){return!(an(t.i)>=t.i.j-(t.m?1:0)||(t.m?(t.l=e.D.concat(t.l),0):1==t.G||2==t.G||t.C>=(t.Xa?0:t.Ya)||(t.m=re(b(t.Ha,t,e),Zn(t,t.C)),t.C++,0)))}(t,e)||2==r&&Hn(t)))switch(n&&0<n.length&&(e=t.i,e.i=e.i.concat(n)),i){case 1:Xn(t,5);break;case 4:Xn(t,10);break;case 3:Xn(t,6);break;default:Xn(t,2)}}function Zn(t,e){let n=t.Pa+Math.floor(Math.random()*t.$a);return t.j||(n*=2),n*e}function Xn(t,e){if(t.h.info("Error code "+e),2==e){var n=null;t.j&&(n=null);var r=b(t.jb,t);n||(n=new Le("//www.google.com/images/cleardot.gif"),l.location&&"http"==l.location.protocol||Fe(n,"https"),Be(n)),function(t,e){const n=new Ht;if(l.Image){const r=new Image;r.onload=w(mn,n,r,"TestLoadImage: loaded",!0,e),r.onerror=w(mn,n,r,"TestLoadImage: error",!1,e),r.onabort=w(mn,n,r,"TestLoadImage: abort",!1,e),r.ontimeout=w(mn,n,r,"TestLoadImage: timeout",!1,e),l.setTimeout((function(){r.ontimeout&&r.ontimeout()}),1e4),r.src=t}else e(!1)}(n.toString(),r)}else ee(2);t.G=0,t.j&&t.j.va(e),tr(t),jn(t)}function tr(t){t.G=0,t.I=-1,t.j&&(0==ln(t.i).length&&0==t.l.length||(t.i.i.length=0,A(t.l),t.l.length=0),t.j.ua())}function er(t,e,n){let r=function(t){return t instanceof Le?Me(t):new Le(t,void 0)}(n);if(""!=r.i)e&&Ue(r,e+"."+r.i),Ve(r,r.m);else{const t=l.location;r=function(t,e,n,r){var i=new Le(null,void 0);return t&&Fe(i,t),e&&Ue(i,e),n&&Ve(i,n),r&&(i.l=r),i}(t.protocol,e?e+"."+t.hostname:t.hostname,+t.port,n)}return t.aa&&L(t.aa,(function(t,e){qe(r,e,t)})),e=t.D,n=t.sa,e&&n&&qe(r,e,n),qe(r,"VER",t.ma),Kn(t,r),r}function nr(t,e,n){if(e&&!t.H)throw Error("Can't create secondary domain capable XhrIo object.");return(e=n&&t.Ba&&!t.qa?new _n(new gn({ib:!0})):new _n(t.qa)).L=t.H,e}function rr(){}function ir(){if(z&&!(10<=Number(et)))throw Error("Environmental error: no available transport.")}function sr(t,e){St.call(this),this.g=new Fn(e),this.l=t,this.h=e&&e.messageUrlParams||null,t=e&&e.messageHeaders||null,e&&e.clientProtocolHeaderRequired&&(t?t["X-Client-Protocol"]="webchannel":t={"X-Client-Protocol":"webchannel"}),this.g.s=t,t=e&&e.initMessageHeaders||null,e&&e.messageContentType&&(t?t["X-WebChannel-Content-Type"]=e.messageContentType:t={"X-WebChannel-Content-Type":e.messageContentType}),e&&e.ya&&(t?t["X-WebChannel-Client-Profile"]=e.ya:t={"X-WebChannel-Client-Profile":e.ya}),this.g.P=t,(t=e&&e.httpHeadersOverwriteParam)&&!N(t)&&(this.g.o=t),this.A=e&&e.supportsCrossDomainXhr||!1,this.v=e&&e.sendRawJson||!1,(e=e&&e.httpSessionIdParam)&&!N(e)&&(this.g.D=e,null!==(t=this.h)&&e in t&&e in(t=this.h)&&delete t[e]),this.j=new cr(this)}function or(t){le.call(this);var e=t.__sm__;if(e){t:{for(const n in e){t=n;break t}t=void 0}(this.i=t)&&(t=this.i,e=null!==e&&t in e?e[t]:void 0),this.data=e}else this.data=t}function ar(){de.call(this),this.status=1}function cr(t){this.g=t}(r=_n.prototype).ea=function(t,e,n,r){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.H+"; newUri="+t);e=e?e.toUpperCase():"GET",this.H=t,this.j="",this.m=0,this.D=!1,this.h=!0,this.g=this.u?this.u.g():ue.g(),this.C=this.u?ae(this.u):ae(ue),this.g.onreadystatechange=b(this.Fa,this);try{this.F=!0,this.g.open(e,String(t),!0),this.F=!1}catch(t){return void Nn(this,t)}t=n||"";const i=new De(this.headers);r&&Ce(r,(function(t,e){i.set(e,t)})),r=function(t){t:{var e=An;const n=t.length,r="string"==typeof t?t.split(""):t;for(let i=0;i<n;i++)if(i in r&&e.call(void 0,r[i],i,t)){e=i;break t}e=-1}return 0>e?null:"string"==typeof t?t.charAt(e):t[e]}(i.T()),n=l.FormData&&t instanceof l.FormData,!(0<=E(kn,e))||r||n||i.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8"),i.forEach((function(t,e){this.g.setRequestHeader(e,t)}),this),this.J&&(this.g.responseType=this.J),"withCredentials"in this.g&&this.g.withCredentials!==this.L&&(this.g.withCredentials=this.L);try{On(this),0<this.B&&((this.K=function(t){return z&&tt()&&"number"==typeof t.timeout&&void 0!==t.ontimeout}(this.g))?(this.g.timeout=this.B,this.g.ontimeout=b(this.pa,this)):this.A=jt(this.pa,this.B,this)),this.v=!0,this.g.send(t),this.v=!1}catch(t){Nn(this,t)}},r.pa=function(){void 0!==h&&this.g&&(this.j="Timed out after "+this.B+"ms, aborting",this.m=8,kt(this,"timeout"),this.abort(8))},r.abort=function(t){this.g&&this.h&&(this.h=!1,this.l=!0,this.g.abort(),this.l=!1,this.m=t||7,kt(this,"complete"),kt(this,"abort"),Dn(this))},r.M=function(){this.g&&(this.h&&(this.h=!1,this.l=!0,this.g.abort(),this.l=!1),Dn(this,!0)),_n.Z.M.call(this)},r.Fa=function(){this.s||(this.F||this.v||this.l?Cn(this):this.cb())},r.cb=function(){Cn(this)},r.ba=function(){try{return 2<Rn(this)?this.g.status:-1}catch(t){return-1}},r.ga=function(){try{return this.g?this.g.responseText:""}catch(t){return""}},r.Qa=function(t){if(this.g){var e=this.g.responseText;return t&&0==e.indexOf(t)&&(e=e.substring(t.length)),Tn(e)}},r.Da=function(){return this.m},r.La=function(){return"string"==typeof this.j?this.j:String(this.j)},(r=Fn.prototype).ma=8,r.G=1,r.hb=function(t){try{this.h.info("Origin Trials invoked: "+t)}catch(t){}},r.Ha=function(t){if(this.m)if(this.m=null,1==this.G){if(!t){this.V=Math.floor(1e5*Math.random()),t=this.V++;const i=new pe(this,this.h,t,void 0);let s=this.s;if(this.P&&(s?(s=M(s),U(s,this.P)):s=this.P),null===this.o&&(i.H=s),this.ja)t:{for(var e=0,n=0;n<this.l.length;n++){var r=this.l[n];if(void 0===(r="__data__"in r.g&&"string"==typeof(r=r.g.__data__)?r.length:void 0))break;if(4096<(e+=r)){e=n;break t}if(4096===e||n===this.l.length-1){e=n+1;break t}}e=1e3}else e=1e3;e=Wn(this,i,e),qe(n=Me(this.F),"RID",t),qe(n,"CVER",22),this.D&&qe(n,"X-HTTP-Session-Id",this.D),Kn(this,n),this.o&&s&&Ln(n,this.o,s),un(this.i,i),this.Ra&&qe(n,"TYPE","init"),this.ja?(qe(n,"$req",e),qe(n,"SID","null"),i.$=!0,be(i,n,null)):be(i,n,e),this.G=2}}else 3==this.G&&(t?zn(this,t):0==this.l.length||on(this.i)||zn(this))},r.Ga=function(){if(this.u=null,Yn(this),this.$&&!(this.L||null==this.g||0>=this.O)){var t=2*this.O;this.h.info("BP detection timer enabled: "+t),this.B=re(b(this.bb,this),t)}},r.bb=function(){this.B&&(this.B=null,this.h.info("BP detection timeout reached."),this.h.info("Buffering proxy detected and switch to long-polling!"),this.N=!1,this.L=!0,ee(10),Vn(this),Yn(this))},r.ab=function(){null!=this.v&&(this.v=null,Vn(this),Hn(this),ee(19))},r.jb=function(t){t?(this.h.info("Successfully pinged google.com"),ee(2)):(this.h.info("Failed to ping google.com"),ee(1))},(r=rr.prototype).xa=function(){},r.wa=function(){},r.va=function(){},r.ua=function(){},r.Oa=function(){},ir.prototype.g=function(t,e){return new sr(t,e)},I(sr,St),sr.prototype.m=function(){this.g.j=this.j,this.A&&(this.g.H=!0);var t=this.g,e=this.l,n=this.h||void 0;t.Wa&&(t.h.info("Origin Trials enabled."),Pt(b(t.hb,t,e))),ee(0),t.W=e,t.aa=n||{},t.N=t.X,t.F=er(t,null,t.W),Bn(t)},sr.prototype.close=function(){Un(this.g)},sr.prototype.u=function(t){if("string"==typeof t){var e={};e.__data__=t,qn(this.g,e)}else this.v?((e={}).__data__=Nt(t),qn(this.g,e)):qn(this.g,t)},sr.prototype.M=function(){this.g.j=null,delete this.j,Un(this.g),delete this.g,sr.Z.M.call(this)},I(or,le),I(ar,de),I(cr,rr),cr.prototype.xa=function(){kt(this.g,"a")},cr.prototype.wa=function(t){kt(this.g,new or(t))},cr.prototype.va=function(t){kt(this.g,new ar(t))},cr.prototype.ua=function(){kt(this.g,"b")},ir.prototype.createWebChannel=ir.prototype.g,sr.prototype.send=sr.prototype.u,sr.prototype.open=sr.prototype.m,sr.prototype.close=sr.prototype.close,ie.NO_ERROR=0,ie.TIMEOUT=8,ie.HTTP_ERROR=6,se.COMPLETE="complete",ce.EventType=he,he.OPEN="a",he.CLOSE="b",he.ERROR="c",he.MESSAGE="d",St.prototype.listen=St.prototype.N,_n.prototype.listenOnce=_n.prototype.O,_n.prototype.getLastError=_n.prototype.La,_n.prototype.getLastErrorCode=_n.prototype.Da,_n.prototype.getStatus=_n.prototype.ba,_n.prototype.getResponseJson=_n.prototype.Qa,_n.prototype.getResponseText=_n.prototype.ga,_n.prototype.send=_n.prototype.ea;var ur=u.createWebChannelTransport=function(){return new ir},hr=u.getStatEventTarget=function(){return Jt()},lr=u.ErrorCode=ie,dr=u.EventType=se,fr=u.Event=Yt,pr=u.Stat={rb:0,ub:1,vb:2,Ob:3,Tb:4,Qb:5,Rb:6,Pb:7,Nb:8,Sb:9,PROXY:10,NOPROXY:11,Lb:12,Hb:13,Ib:14,Gb:15,Jb:16,Kb:17,nb:18,mb:19,ob:20},mr=u.FetchXmlHttpFactory=gn,gr=u.WebChannel=ce,yr=u.XhrIo=_n;const vr="@firebase/firestore";class br{constructor(t){this.uid=t}isAuthenticated(){return null!=this.uid}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(t){return t.uid===this.uid}}br.UNAUTHENTICATED=new br(null),br.GOOGLE_CREDENTIALS=new br("google-credentials-uid"),br.FIRST_PARTY=new br("first-party-uid"),br.MOCK_USER=new br("mock-user");let wr="9.6.2";const Ir=new o.Yd("@firebase/firestore");function Tr(){return Ir.logLevel}function _r(t){Ir.setLogLevel(t)}function Er(t,...e){if(Ir.logLevel<=o.in.DEBUG){const n=e.map(Ar);Ir.debug(`Firestore (${wr}): ${t}`,...n)}}function Sr(t,...e){if(Ir.logLevel<=o.in.ERROR){const n=e.map(Ar);Ir.error(`Firestore (${wr}): ${t}`,...n)}}function kr(t,...e){if(Ir.logLevel<=o.in.WARN){const n=e.map(Ar);Ir.warn(`Firestore (${wr}): ${t}`,...n)}}function Ar(t){if("string"==typeof t)return t;try{return e=t,JSON.stringify(e)}catch(e){return t}var e}function Nr(t="Unexpected state"){const e=`FIRESTORE (${wr}) INTERNAL ASSERTION FAILED: `+t;throw Sr(e),new Error(e)}function xr(t,e){t||Nr()}function Cr(t,e){t||Nr()}function Dr(t,e){return t}const Or={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"};class Rr extends a.ZR{constructor(t,e){super(t,e),this.code=t,this.message=e,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}class Pr{constructor(){this.promise=new Promise(((t,e)=>{this.resolve=t,this.reject=e}))}}class Lr{constructor(t,e){this.user=e,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${t}`)}}class Mr{getToken(){return Promise.resolve(null)}invalidateToken(){}start(t,e){t.enqueueRetryable((()=>e(br.UNAUTHENTICATED)))}shutdown(){}}class Fr{constructor(t){this.token=t,this.changeListener=null}getToken(){return Promise.resolve(this.token)}invalidateToken(){}start(t,e){this.changeListener=e,t.enqueueRetryable((()=>e(this.token.user)))}shutdown(){this.changeListener=null}}class Ur{constructor(t){this.t=t,this.currentUser=br.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(t,e){let n=this.i;const r=t=>this.i!==n?(n=this.i,e(t)):Promise.resolve();let i=new Pr;this.o=()=>{this.i++,this.currentUser=this.u(),i.resolve(),i=new Pr,t.enqueueRetryable((()=>r(this.currentUser)))};const s=()=>{const e=i;t.enqueueRetryable((async()=>{await e.promise,await r(this.currentUser)}))},o=t=>{Er("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=t,this.auth.addAuthTokenListener(this.o),s()};this.t.onInit((t=>o(t))),setTimeout((()=>{if(!this.auth){const t=this.t.getImmediate({optional:!0});t?o(t):(Er("FirebaseAuthCredentialsProvider","Auth not yet detected"),i.resolve(),i=new Pr)}}),0),s()}getToken(){const t=this.i,e=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(e).then((e=>this.i!==t?(Er("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):e?(xr("string"==typeof e.accessToken),new Lr(e.accessToken,this.currentUser)):null)):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.auth.removeAuthTokenListener(this.o)}u(){const t=this.auth&&this.auth.getUid();return xr(null===t||"string"==typeof t),new br(t)}}class Vr{constructor(t,e,n){this.type="FirstParty",this.user=br.FIRST_PARTY,this.headers=new Map,this.headers.set("X-Goog-AuthUser",e);const r=t.auth.getAuthHeaderValueForFirstParty([]);r&&this.headers.set("Authorization",r),n&&this.headers.set("X-Goog-Iam-Authorization-Token",n)}}class jr{constructor(t,e,n){this.h=t,this.l=e,this.m=n}getToken(){return Promise.resolve(new Vr(this.h,this.l,this.m))}start(t,e){t.enqueueRetryable((()=>e(br.FIRST_PARTY)))}shutdown(){}invalidateToken(){}}class qr{constructor(t){this.value=t,this.type="AppCheck",this.headers=new Map,t&&t.length>0&&this.headers.set("x-firebase-appcheck",this.value)}}class Br{constructor(t){this.g=t,this.forceRefresh=!1,this.appCheck=null}start(t,e){this.o=n=>{t.enqueueRetryable((()=>(t=>(null!=t.error&&Er("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${t.error.message}`),e(t.token)))(n)))};const n=t=>{Er("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=t,this.appCheck.addTokenListener(this.o)};this.g.onInit((t=>n(t))),setTimeout((()=>{if(!this.appCheck){const t=this.g.getImmediate({optional:!0});t?n(t):Er("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}}),0)}getToken(){const t=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(t).then((t=>t?(xr("string"==typeof t.token),new qr(t.token)):null)):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.appCheck.removeTokenListener(this.o)}}class zr{getToken(){return Promise.resolve(new qr(""))}invalidateToken(){}start(t,e){}shutdown(){}}class Kr{constructor(t,e){this.previousValue=t,e&&(e.sequenceNumberHandler=t=>this.p(t),this.T=t=>e.writeSequenceNumber(t))}p(t){return this.previousValue=Math.max(t,this.previousValue),this.previousValue}next(){const t=++this.previousValue;return this.T&&this.T(t),t}}function Wr(t){const e="undefined"!=typeof self&&(self.crypto||self.msCrypto),n=new Uint8Array(t);if(e&&"function"==typeof e.getRandomValues)e.getRandomValues(n);else for(let e=0;e<t;e++)n[e]=Math.floor(256*Math.random());return n}Kr.I=-1;class Gr{static A(){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e=Math.floor(256/t.length)*t.length;let n="";for(;n.length<20;){const r=Wr(40);for(let i=0;i<r.length;++i)n.length<20&&r[i]<e&&(n+=t.charAt(r[i]%t.length))}return n}}function Hr(t,e){return t<e?-1:t>e?1:0}function $r(t,e,n){return t.length===e.length&&t.every(((t,r)=>n(t,e[r])))}function Yr(t){return t+"\0"}class Qr{constructor(t,e){if(this.seconds=t,this.nanoseconds=e,e<0)throw new Rr(Or.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(e>=1e9)throw new Rr(Or.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(t<-62135596800)throw new Rr(Or.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t);if(t>=253402300800)throw new Rr(Or.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t)}static now(){return Qr.fromMillis(Date.now())}static fromDate(t){return Qr.fromMillis(t.getTime())}static fromMillis(t){const e=Math.floor(t/1e3),n=Math.floor(1e6*(t-1e3*e));return new Qr(e,n)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/1e6}_compareTo(t){return this.seconds===t.seconds?Hr(this.nanoseconds,t.nanoseconds):Hr(this.seconds,t.seconds)}isEqual(t){return t.seconds===this.seconds&&t.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{seconds:this.seconds,nanoseconds:this.nanoseconds}}valueOf(){const t=this.seconds- -62135596800;return String(t).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}class Jr{constructor(t){this.timestamp=t}static fromTimestamp(t){return new Jr(t)}static min(){return new Jr(new Qr(0,0))}compareTo(t){return this.timestamp._compareTo(t.timestamp)}isEqual(t){return this.timestamp.isEqual(t.timestamp)}toMicroseconds(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}toString(){return"SnapshotVersion("+this.timestamp.toString()+")"}toTimestamp(){return this.timestamp}}function Zr(t){let e=0;for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&e++;return e}function Xr(t,e){for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&e(n,t[n])}function ti(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}class ei{constructor(t,e,n){void 0===e?e=0:e>t.length&&Nr(),void 0===n?n=t.length-e:n>t.length-e&&Nr(),this.segments=t,this.offset=e,this.len=n}get length(){return this.len}isEqual(t){return 0===ei.comparator(this,t)}child(t){const e=this.segments.slice(this.offset,this.limit());return t instanceof ei?t.forEach((t=>{e.push(t)})):e.push(t),this.construct(e)}limit(){return this.offset+this.length}popFirst(t){return t=void 0===t?1:t,this.construct(this.segments,this.offset+t,this.length-t)}popLast(){return this.construct(this.segments,this.offset,this.length-1)}firstSegment(){return this.segments[this.offset]}lastSegment(){return this.get(this.length-1)}get(t){return this.segments[this.offset+t]}isEmpty(){return 0===this.length}isPrefixOf(t){if(t.length<this.length)return!1;for(let e=0;e<this.length;e++)if(this.get(e)!==t.get(e))return!1;return!0}isImmediateParentOf(t){if(this.length+1!==t.length)return!1;for(let e=0;e<this.length;e++)if(this.get(e)!==t.get(e))return!1;return!0}forEach(t){for(let e=this.offset,n=this.limit();e<n;e++)t(this.segments[e])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(t,e){const n=Math.min(t.length,e.length);for(let r=0;r<n;r++){const n=t.get(r),i=e.get(r);if(n<i)return-1;if(n>i)return 1}return t.length<e.length?-1:t.length>e.length?1:0}}class ni extends ei{construct(t,e,n){return new ni(t,e,n)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}static fromString(...t){const e=[];for(const n of t){if(n.indexOf("//")>=0)throw new Rr(Or.INVALID_ARGUMENT,`Invalid segment (${n}). Paths must not contain // in them.`);e.push(...n.split("/").filter((t=>t.length>0)))}return new ni(e)}static emptyPath(){return new ni([])}}const ri=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class ii extends ei{construct(t,e,n){return new ii(t,e,n)}static isValidIdentifier(t){return ri.test(t)}canonicalString(){return this.toArray().map((t=>(t=t.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),ii.isValidIdentifier(t)||(t="`"+t+"`"),t))).join(".")}toString(){return this.canonicalString()}isKeyField(){return 1===this.length&&"__name__"===this.get(0)}static keyField(){return new ii(["__name__"])}static fromServerFormat(t){const e=[];let n="",r=0;const i=()=>{if(0===n.length)throw new Rr(Or.INVALID_ARGUMENT,`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);e.push(n),n=""};let s=!1;for(;r<t.length;){const e=t[r];if("\\"===e){if(r+1===t.length)throw new Rr(Or.INVALID_ARGUMENT,"Path has trailing escape character: "+t);const e=t[r+1];if("\\"!==e&&"."!==e&&"`"!==e)throw new Rr(Or.INVALID_ARGUMENT,"Path has invalid escape sequence: "+t);n+=e,r+=2}else"`"===e?(s=!s,r++):"."!==e||s?(n+=e,r++):(i(),r++)}if(i(),s)throw new Rr(Or.INVALID_ARGUMENT,"Unterminated ` in path: "+t);return new ii(e)}static emptyPath(){return new ii([])}}class si{constructor(t){this.fields=t,t.sort(ii.comparator)}covers(t){for(const e of this.fields)if(e.isPrefixOf(t))return!0;return!1}isEqual(t){return $r(this.fields,t.fields,((t,e)=>t.isEqual(e)))}}function oi(){return"undefined"!=typeof atob}class ai{constructor(t){this.binaryString=t}static fromBase64String(t){const e=atob(t);return new ai(e)}static fromUint8Array(t){const e=function(t){let e="";for(let n=0;n<t.length;++n)e+=String.fromCharCode(t[n]);return e}(t);return new ai(e)}[Symbol.iterator](){let t=0;return{next:()=>t<this.binaryString.length?{value:this.binaryString.charCodeAt(t++),done:!1}:{value:void 0,done:!0}}}toBase64(){return t=this.binaryString,btoa(t);var t}toUint8Array(){return function(t){const e=new Uint8Array(t.length);for(let n=0;n<t.length;n++)e[n]=t.charCodeAt(n);return e}(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(t){return Hr(this.binaryString,t.binaryString)}isEqual(t){return this.binaryString===t.binaryString}}ai.EMPTY_BYTE_STRING=new ai("");const ci=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function ui(t){if(xr(!!t),"string"==typeof t){let e=0;const n=ci.exec(t);if(xr(!!n),n[1]){let t=n[1];t=(t+"000000000").substr(0,9),e=Number(t)}const r=new Date(t);return{seconds:Math.floor(r.getTime()/1e3),nanos:e}}return{seconds:hi(t.seconds),nanos:hi(t.nanos)}}function hi(t){return"number"==typeof t?t:"string"==typeof t?Number(t):0}function li(t){return"string"==typeof t?ai.fromBase64String(t):ai.fromUint8Array(t)}function di(t){var e,n;return"server_timestamp"===(null===(n=((null===(e=null==t?void 0:t.mapValue)||void 0===e?void 0:e.fields)||{}).__type__)||void 0===n?void 0:n.stringValue)}function fi(t){const e=t.mapValue.fields.__previous_value__;return di(e)?fi(e):e}function pi(t){const e=ui(t.mapValue.fields.__local_write_time__.timestampValue);return new Qr(e.seconds,e.nanos)}function mi(t){return null==t}function gi(t){return 0===t&&1/t==-1/0}function yi(t){return"number"==typeof t&&Number.isInteger(t)&&!gi(t)&&t<=Number.MAX_SAFE_INTEGER&&t>=Number.MIN_SAFE_INTEGER}class vi{constructor(t){this.path=t}static fromPath(t){return new vi(ni.fromString(t))}static fromName(t){return new vi(ni.fromString(t).popFirst(5))}hasCollectionId(t){return this.path.length>=2&&this.path.get(this.path.length-2)===t}isEqual(t){return null!==t&&0===ni.comparator(this.path,t.path)}toString(){return this.path.toString()}static comparator(t,e){return ni.comparator(t.path,e.path)}static isDocumentKey(t){return t.length%2==0}static fromSegments(t){return new vi(new ni(t.slice()))}}function bi(t){return"nullValue"in t?0:"booleanValue"in t?1:"integerValue"in t||"doubleValue"in t?2:"timestampValue"in t?3:"stringValue"in t?5:"bytesValue"in t?6:"referenceValue"in t?7:"geoPointValue"in t?8:"arrayValue"in t?9:"mapValue"in t?di(t)?4:10:Nr()}function wi(t,e){if(t===e)return!0;const n=bi(t);if(n!==bi(e))return!1;switch(n){case 0:return!0;case 1:return t.booleanValue===e.booleanValue;case 4:return pi(t).isEqual(pi(e));case 3:return function(t,e){if("string"==typeof t.timestampValue&&"string"==typeof e.timestampValue&&t.timestampValue.length===e.timestampValue.length)return t.timestampValue===e.timestampValue;const n=ui(t.timestampValue),r=ui(e.timestampValue);return n.seconds===r.seconds&&n.nanos===r.nanos}(t,e);case 5:return t.stringValue===e.stringValue;case 6:return function(t,e){return li(t.bytesValue).isEqual(li(e.bytesValue))}(t,e);case 7:return t.referenceValue===e.referenceValue;case 8:return function(t,e){return hi(t.geoPointValue.latitude)===hi(e.geoPointValue.latitude)&&hi(t.geoPointValue.longitude)===hi(e.geoPointValue.longitude)}(t,e);case 2:return function(t,e){if("integerValue"in t&&"integerValue"in e)return hi(t.integerValue)===hi(e.integerValue);if("doubleValue"in t&&"doubleValue"in e){const n=hi(t.doubleValue),r=hi(e.doubleValue);return n===r?gi(n)===gi(r):isNaN(n)&&isNaN(r)}return!1}(t,e);case 9:return $r(t.arrayValue.values||[],e.arrayValue.values||[],wi);case 10:return function(t,e){const n=t.mapValue.fields||{},r=e.mapValue.fields||{};if(Zr(n)!==Zr(r))return!1;for(const t in n)if(n.hasOwnProperty(t)&&(void 0===r[t]||!wi(n[t],r[t])))return!1;return!0}(t,e);default:return Nr()}}function Ii(t,e){return void 0!==(t.values||[]).find((t=>wi(t,e)))}function Ti(t,e){if(t===e)return 0;const n=bi(t),r=bi(e);if(n!==r)return Hr(n,r);switch(n){case 0:return 0;case 1:return Hr(t.booleanValue,e.booleanValue);case 2:return function(t,e){const n=hi(t.integerValue||t.doubleValue),r=hi(e.integerValue||e.doubleValue);return n<r?-1:n>r?1:n===r?0:isNaN(n)?isNaN(r)?0:-1:1}(t,e);case 3:return _i(t.timestampValue,e.timestampValue);case 4:return _i(pi(t),pi(e));case 5:return Hr(t.stringValue,e.stringValue);case 6:return function(t,e){const n=li(t),r=li(e);return n.compareTo(r)}(t.bytesValue,e.bytesValue);case 7:return function(t,e){const n=t.split("/"),r=e.split("/");for(let t=0;t<n.length&&t<r.length;t++){const e=Hr(n[t],r[t]);if(0!==e)return e}return Hr(n.length,r.length)}(t.referenceValue,e.referenceValue);case 8:return function(t,e){const n=Hr(hi(t.latitude),hi(e.latitude));return 0!==n?n:Hr(hi(t.longitude),hi(e.longitude))}(t.geoPointValue,e.geoPointValue);case 9:return function(t,e){const n=t.values||[],r=e.values||[];for(let t=0;t<n.length&&t<r.length;++t){const e=Ti(n[t],r[t]);if(e)return e}return Hr(n.length,r.length)}(t.arrayValue,e.arrayValue);case 10:return function(t,e){const n=t.fields||{},r=Object.keys(n),i=e.fields||{},s=Object.keys(i);r.sort(),s.sort();for(let t=0;t<r.length&&t<s.length;++t){const e=Hr(r[t],s[t]);if(0!==e)return e;const o=Ti(n[r[t]],i[s[t]]);if(0!==o)return o}return Hr(r.length,s.length)}(t.mapValue,e.mapValue);default:throw Nr()}}function _i(t,e){if("string"==typeof t&&"string"==typeof e&&t.length===e.length)return Hr(t,e);const n=ui(t),r=ui(e),i=Hr(n.seconds,r.seconds);return 0!==i?i:Hr(n.nanos,r.nanos)}function Ei(t){return Si(t)}function Si(t){return"nullValue"in t?"null":"booleanValue"in t?""+t.booleanValue:"integerValue"in t?""+t.integerValue:"doubleValue"in t?""+t.doubleValue:"timestampValue"in t?function(t){const e=ui(t);return`time(${e.seconds},${e.nanos})`}(t.timestampValue):"stringValue"in t?t.stringValue:"bytesValue"in t?li(t.bytesValue).toBase64():"referenceValue"in t?(n=t.referenceValue,vi.fromName(n).toString()):"geoPointValue"in t?`geo(${(e=t.geoPointValue).latitude},${e.longitude})`:"arrayValue"in t?function(t){let e="[",n=!0;for(const r of t.values||[])n?n=!1:e+=",",e+=Si(r);return e+"]"}(t.arrayValue):"mapValue"in t?function(t){const e=Object.keys(t.fields||{}).sort();let n="{",r=!0;for(const i of e)r?r=!1:n+=",",n+=`${i}:${Si(t.fields[i])}`;return n+"}"}(t.mapValue):Nr();var e,n}function ki(t,e){return{referenceValue:`projects/${t.projectId}/databases/${t.database}/documents/${e.path.canonicalString()}`}}function Ai(t){return!!t&&"integerValue"in t}function Ni(t){return!!t&&"arrayValue"in t}function xi(t){return!!t&&"nullValue"in t}function Ci(t){return!!t&&"doubleValue"in t&&isNaN(Number(t.doubleValue))}function Di(t){return!!t&&"mapValue"in t}function Oi(t){if(t.geoPointValue)return{geoPointValue:Object.assign({},t.geoPointValue)};if(t.timestampValue&&"object"==typeof t.timestampValue)return{timestampValue:Object.assign({},t.timestampValue)};if(t.mapValue){const e={mapValue:{fields:{}}};return Xr(t.mapValue.fields,((t,n)=>e.mapValue.fields[t]=Oi(n))),e}if(t.arrayValue){const e={arrayValue:{values:[]}};for(let n=0;n<(t.arrayValue.values||[]).length;++n)e.arrayValue.values[n]=Oi(t.arrayValue.values[n]);return e}return Object.assign({},t)}class Ri{constructor(t){this.value=t}static empty(){return new Ri({mapValue:{}})}field(t){if(t.isEmpty())return this.value;{let e=this.value;for(let n=0;n<t.length-1;++n)if(e=(e.mapValue.fields||{})[t.get(n)],!Di(e))return null;return e=(e.mapValue.fields||{})[t.lastSegment()],e||null}}set(t,e){this.getFieldsMap(t.popLast())[t.lastSegment()]=Oi(e)}setAll(t){let e=ii.emptyPath(),n={},r=[];t.forEach(((t,i)=>{if(!e.isImmediateParentOf(i)){const t=this.getFieldsMap(e);this.applyChanges(t,n,r),n={},r=[],e=i.popLast()}t?n[i.lastSegment()]=Oi(t):r.push(i.lastSegment())}));const i=this.getFieldsMap(e);this.applyChanges(i,n,r)}delete(t){const e=this.field(t.popLast());Di(e)&&e.mapValue.fields&&delete e.mapValue.fields[t.lastSegment()]}isEqual(t){return wi(this.value,t.value)}getFieldsMap(t){let e=this.value;e.mapValue.fields||(e.mapValue={fields:{}});for(let n=0;n<t.length;++n){let r=e.mapValue.fields[t.get(n)];Di(r)&&r.mapValue.fields||(r={mapValue:{fields:{}}},e.mapValue.fields[t.get(n)]=r),e=r}return e.mapValue.fields}applyChanges(t,e,n){Xr(e,((e,n)=>t[e]=n));for(const e of n)delete t[e]}clone(){return new Ri(Oi(this.value))}}function Pi(t){const e=[];return Xr(t.fields,((t,n)=>{const r=new ii([t]);if(Di(n)){const t=Pi(n.mapValue).fields;if(0===t.length)e.push(r);else for(const n of t)e.push(r.child(n))}else e.push(r)})),new si(e)}class Li{constructor(t,e,n,r,i){this.key=t,this.documentType=e,this.version=n,this.data=r,this.documentState=i}static newInvalidDocument(t){return new Li(t,0,Jr.min(),Ri.empty(),0)}static newFoundDocument(t,e,n){return new Li(t,1,e,n,0)}static newNoDocument(t,e){return new Li(t,2,e,Ri.empty(),0)}static newUnknownDocument(t,e){return new Li(t,3,e,Ri.empty(),2)}convertToFoundDocument(t,e){return this.version=t,this.documentType=1,this.data=e,this.documentState=0,this}convertToNoDocument(t){return this.version=t,this.documentType=2,this.data=Ri.empty(),this.documentState=0,this}convertToUnknownDocument(t){return this.version=t,this.documentType=3,this.data=Ri.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this}get hasLocalMutations(){return 1===this.documentState}get hasCommittedMutations(){return 2===this.documentState}get hasPendingWrites(){return this.hasLocalMutations||this.hasCommittedMutations}isValidDocument(){return 0!==this.documentType}isFoundDocument(){return 1===this.documentType}isNoDocument(){return 2===this.documentType}isUnknownDocument(){return 3===this.documentType}isEqual(t){return t instanceof Li&&this.key.isEqual(t.key)&&this.version.isEqual(t.version)&&this.documentType===t.documentType&&this.documentState===t.documentState&&this.data.isEqual(t.data)}mutableCopy(){return new Li(this.key,this.documentType,this.version,this.data.clone(),this.documentState)}toString(){return`Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`}}class Mi{constructor(t,e=null,n=[],r=[],i=null,s=null,o=null){this.path=t,this.collectionGroup=e,this.orderBy=n,this.filters=r,this.limit=i,this.startAt=s,this.endAt=o,this.R=null}}function Fi(t,e=null,n=[],r=[],i=null,s=null,o=null){return new Mi(t,e,n,r,i,s,o)}function Ui(t){const e=Dr(t);if(null===e.R){let t=e.path.canonicalString();null!==e.collectionGroup&&(t+="|cg:"+e.collectionGroup),t+="|f:",t+=e.filters.map((t=>function(t){return t.field.canonicalString()+t.op.toString()+Ei(t.value)}(t))).join(","),t+="|ob:",t+=e.orderBy.map((t=>function(t){return t.field.canonicalString()+t.dir}(t))).join(","),mi(e.limit)||(t+="|l:",t+=e.limit),e.startAt&&(t+="|lb:",t+=Ji(e.startAt)),e.endAt&&(t+="|ub:",t+=Ji(e.endAt)),e.R=t}return e.R}function Vi(t,e){if(t.limit!==e.limit)return!1;if(t.orderBy.length!==e.orderBy.length)return!1;for(let n=0;n<t.orderBy.length;n++)if(!Xi(t.orderBy[n],e.orderBy[n]))return!1;if(t.filters.length!==e.filters.length)return!1;for(let i=0;i<t.filters.length;i++)if(n=t.filters[i],r=e.filters[i],n.op!==r.op||!n.field.isEqual(r.field)||!wi(n.value,r.value))return!1;var n,r;return t.collectionGroup===e.collectionGroup&&!!t.path.isEqual(e.path)&&!!es(t.startAt,e.startAt)&&es(t.endAt,e.endAt)}function ji(t){return vi.isDocumentKey(t.path)&&null===t.collectionGroup&&0===t.filters.length}class qi extends class{}{constructor(t,e,n){super(),this.field=t,this.op=e,this.value=n}static create(t,e,n){return t.isKeyField()?"in"===e||"not-in"===e?this.P(t,e,n):new Bi(t,e,n):"array-contains"===e?new Gi(t,n):"in"===e?new Hi(t,n):"not-in"===e?new $i(t,n):"array-contains-any"===e?new Yi(t,n):new qi(t,e,n)}static P(t,e,n){return"in"===e?new zi(t,n):new Ki(t,n)}matches(t){const e=t.data.field(this.field);return"!="===this.op?null!==e&&this.v(Ti(e,this.value)):null!==e&&bi(this.value)===bi(e)&&this.v(Ti(e,this.value))}v(t){switch(this.op){case"<":return t<0;case"<=":return t<=0;case"==":return 0===t;case"!=":return 0!==t;case">":return t>0;case">=":return t>=0;default:return Nr()}}V(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}}class Bi extends qi{constructor(t,e,n){super(t,e,n),this.key=vi.fromName(n.referenceValue)}matches(t){const e=vi.comparator(t.key,this.key);return this.v(e)}}class zi extends qi{constructor(t,e){super(t,"in",e),this.keys=Wi(0,e)}matches(t){return this.keys.some((e=>e.isEqual(t.key)))}}class Ki extends qi{constructor(t,e){super(t,"not-in",e),this.keys=Wi(0,e)}matches(t){return!this.keys.some((e=>e.isEqual(t.key)))}}function Wi(t,e){var n;return((null===(n=e.arrayValue)||void 0===n?void 0:n.values)||[]).map((t=>vi.fromName(t.referenceValue)))}class Gi extends qi{constructor(t,e){super(t,"array-contains",e)}matches(t){const e=t.data.field(this.field);return Ni(e)&&Ii(e.arrayValue,this.value)}}class Hi extends qi{constructor(t,e){super(t,"in",e)}matches(t){const e=t.data.field(this.field);return null!==e&&Ii(this.value.arrayValue,e)}}class $i extends qi{constructor(t,e){super(t,"not-in",e)}matches(t){if(Ii(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const e=t.data.field(this.field);return null!==e&&!Ii(this.value.arrayValue,e)}}class Yi extends qi{constructor(t,e){super(t,"array-contains-any",e)}matches(t){const e=t.data.field(this.field);return!(!Ni(e)||!e.arrayValue.values)&&e.arrayValue.values.some((t=>Ii(this.value.arrayValue,t)))}}class Qi{constructor(t,e){this.position=t,this.before=e}}function Ji(t){return`${t.before?"b":"a"}:${t.position.map((t=>Ei(t))).join(",")}`}class Zi{constructor(t,e="asc"){this.field=t,this.dir=e}}function Xi(t,e){return t.dir===e.dir&&t.field.isEqual(e.field)}function ts(t,e,n){let r=0;for(let i=0;i<t.position.length;i++){const s=e[i],o=t.position[i];if(r=s.field.isKeyField()?vi.comparator(vi.fromName(o.referenceValue),n.key):Ti(o,n.data.field(s.field)),"desc"===s.dir&&(r*=-1),0!==r)break}return t.before?r<=0:r<0}function es(t,e){if(null===t)return null===e;if(null===e)return!1;if(t.before!==e.before||t.position.length!==e.position.length)return!1;for(let n=0;n<t.position.length;n++)if(!wi(t.position[n],e.position[n]))return!1;return!0}class ns{constructor(t,e=null,n=[],r=[],i=null,s="F",o=null,a=null){this.path=t,this.collectionGroup=e,this.explicitOrderBy=n,this.filters=r,this.limit=i,this.limitType=s,this.startAt=o,this.endAt=a,this.S=null,this.D=null,this.startAt,this.endAt}}function rs(t,e,n,r,i,s,o,a){return new ns(t,e,n,r,i,s,o,a)}function is(t){return new ns(t)}function ss(t){return!mi(t.limit)&&"F"===t.limitType}function os(t){return!mi(t.limit)&&"L"===t.limitType}function as(t){return t.explicitOrderBy.length>0?t.explicitOrderBy[0].field:null}function cs(t){for(const e of t.filters)if(e.V())return e.field;return null}function us(t){return null!==t.collectionGroup}function hs(t){const e=Dr(t);if(null===e.S){e.S=[];const t=cs(e),n=as(e);if(null!==t&&null===n)t.isKeyField()||e.S.push(new Zi(t)),e.S.push(new Zi(ii.keyField(),"asc"));else{let t=!1;for(const n of e.explicitOrderBy)e.S.push(n),n.field.isKeyField()&&(t=!0);if(!t){const t=e.explicitOrderBy.length>0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";e.S.push(new Zi(ii.keyField(),t))}}}return e.S}function ls(t){const e=Dr(t);if(!e.D)if("F"===e.limitType)e.D=Fi(e.path,e.collectionGroup,hs(e),e.filters,e.limit,e.startAt,e.endAt);else{const t=[];for(const n of hs(e)){const e="desc"===n.dir?"asc":"desc";t.push(new Zi(n.field,e))}const n=e.endAt?new Qi(e.endAt.position,!e.endAt.before):null,r=e.startAt?new Qi(e.startAt.position,!e.startAt.before):null;e.D=Fi(e.path,e.collectionGroup,t,e.filters,e.limit,n,r)}return e.D}function ds(t,e,n){return new ns(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),e,n,t.startAt,t.endAt)}function fs(t,e){return Vi(ls(t),ls(e))&&t.limitType===e.limitType}function ps(t){return`${Ui(ls(t))}|lt:${t.limitType}`}function ms(t){return`Query(target=${function(t){let e=t.path.canonicalString();return null!==t.collectionGroup&&(e+=" collectionGroup="+t.collectionGroup),t.filters.length>0&&(e+=`, filters: [${t.filters.map((t=>{return`${(e=t).field.canonicalString()} ${e.op} ${Ei(e.value)}`;var e})).join(", ")}]`),mi(t.limit)||(e+=", limit: "+t.limit),t.orderBy.length>0&&(e+=`, orderBy: [${t.orderBy.map((t=>function(t){return`${t.field.canonicalString()} (${t.dir})`}(t))).join(", ")}]`),t.startAt&&(e+=", startAt: "+Ji(t.startAt)),t.endAt&&(e+=", endAt: "+Ji(t.endAt)),`Target(${e})`}(ls(t))}; limitType=${t.limitType})`}function gs(t,e){return e.isFoundDocument()&&function(t,e){const n=e.key.path;return null!==t.collectionGroup?e.key.hasCollectionId(t.collectionGroup)&&t.path.isPrefixOf(n):vi.isDocumentKey(t.path)?t.path.isEqual(n):t.path.isImmediateParentOf(n)}(t,e)&&function(t,e){for(const n of t.explicitOrderBy)if(!n.field.isKeyField()&&null===e.data.field(n.field))return!1;return!0}(t,e)&&function(t,e){for(const n of t.filters)if(!n.matches(e))return!1;return!0}(t,e)&&function(t,e){return!(t.startAt&&!ts(t.startAt,hs(t),e)||t.endAt&&ts(t.endAt,hs(t),e))}(t,e)}function ys(t){return(e,n)=>{let r=!1;for(const i of hs(t)){const t=vs(i,e,n);if(0!==t)return t;r=r||i.field.isKeyField()}return 0}}function vs(t,e,n){const r=t.field.isKeyField()?vi.comparator(e.key,n.key):function(t,e,n){const r=e.data.field(t),i=n.data.field(t);return null!==r&&null!==i?Ti(r,i):Nr()}(t.field,e,n);switch(t.dir){case"asc":return r;case"desc":return-1*r;default:return Nr()}}function bs(t,e){if(t.C){if(isNaN(e))return{doubleValue:"NaN"};if(e===1/0)return{doubleValue:"Infinity"};if(e===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:gi(e)?"-0":e}}function ws(t){return{integerValue:""+t}}function Is(t,e){return yi(e)?ws(e):bs(t,e)}class Ts{constructor(){this._=void 0}}function _s(t,e,n){return t instanceof ks?function(t,e){const n={fields:{__type__:{stringValue:"server_timestamp"},__local_write_time__:{timestampValue:{seconds:t.seconds,nanos:t.nanoseconds}}}};return e&&(n.fields.__previous_value__=e),{mapValue:n}}(n,e):t instanceof As?Ns(t,e):t instanceof xs?Cs(t,e):function(t,e){const n=Ss(t,e),r=Os(n)+Os(t.N);return Ai(n)&&Ai(t.N)?ws(r):bs(t.k,r)}(t,e)}function Es(t,e,n){return t instanceof As?Ns(t,e):t instanceof xs?Cs(t,e):n}function Ss(t,e){return t instanceof Ds?Ai(n=e)||function(t){return!!t&&"doubleValue"in t}(n)?e:{integerValue:0}:null;var n}class ks extends Ts{}class As extends Ts{constructor(t){super(),this.elements=t}}function Ns(t,e){const n=Rs(e);for(const e of t.elements)n.some((t=>wi(t,e)))||n.push(e);return{arrayValue:{values:n}}}class xs extends Ts{constructor(t){super(),this.elements=t}}function Cs(t,e){let n=Rs(e);for(const e of t.elements)n=n.filter((t=>!wi(t,e)));return{arrayValue:{values:n}}}class Ds extends Ts{constructor(t,e){super(),this.k=t,this.N=e}}function Os(t){return hi(t.integerValue||t.doubleValue)}function Rs(t){return Ni(t)&&t.arrayValue.values?t.arrayValue.values.slice():[]}class Ps{constructor(t,e){this.field=t,this.transform=e}}class Ls{constructor(t,e){this.version=t,this.transformResults=e}}class Ms{constructor(t,e){this.updateTime=t,this.exists=e}static none(){return new Ms}static exists(t){return new Ms(void 0,t)}static updateTime(t){return new Ms(t)}get isNone(){return void 0===this.updateTime&&void 0===this.exists}isEqual(t){return this.exists===t.exists&&(this.updateTime?!!t.updateTime&&this.updateTime.isEqual(t.updateTime):!t.updateTime)}}function Fs(t,e){return void 0!==t.updateTime?e.isFoundDocument()&&e.version.isEqual(t.updateTime):void 0===t.exists||t.exists===e.isFoundDocument()}class Us{}function Vs(t,e,n){t instanceof Ks?function(t,e,n){const r=t.value.clone(),i=Hs(t.fieldTransforms,e,n.transformResults);r.setAll(i),e.convertToFoundDocument(n.version,r).setHasCommittedMutations()}(t,e,n):t instanceof Ws?function(t,e,n){if(!Fs(t.precondition,e))return void e.convertToUnknownDocument(n.version);const r=Hs(t.fieldTransforms,e,n.transformResults),i=e.data;i.setAll(Gs(t)),i.setAll(r),e.convertToFoundDocument(n.version,i).setHasCommittedMutations()}(t,e,n):function(t,e,n){e.convertToNoDocument(n.version).setHasCommittedMutations()}(0,e,n)}function js(t,e,n){t instanceof Ks?function(t,e,n){if(!Fs(t.precondition,e))return;const r=t.value.clone(),i=$s(t.fieldTransforms,n,e);r.setAll(i),e.convertToFoundDocument(zs(e),r).setHasLocalMutations()}(t,e,n):t instanceof Ws?function(t,e,n){if(!Fs(t.precondition,e))return;const r=$s(t.fieldTransforms,n,e),i=e.data;i.setAll(Gs(t)),i.setAll(r),e.convertToFoundDocument(zs(e),i).setHasLocalMutations()}(t,e,n):function(t,e){Fs(t.precondition,e)&&e.convertToNoDocument(Jr.min())}(t,e)}function qs(t,e){let n=null;for(const r of t.fieldTransforms){const t=e.data.field(r.field),i=Ss(r.transform,t||null);null!=i&&(null==n&&(n=Ri.empty()),n.set(r.field,i))}return n||null}function Bs(t,e){return t.type===e.type&&!!t.key.isEqual(e.key)&&!!t.precondition.isEqual(e.precondition)&&!!function(t,e){return void 0===t&&void 0===e||!(!t||!e)&&$r(t,e,((t,e)=>function(t,e){return t.field.isEqual(e.field)&&function(t,e){return t instanceof As&&e instanceof As||t instanceof xs&&e instanceof xs?$r(t.elements,e.elements,wi):t instanceof Ds&&e instanceof Ds?wi(t.N,e.N):t instanceof ks&&e instanceof ks}(t.transform,e.transform)}(t,e)))}(t.fieldTransforms,e.fieldTransforms)&&(0===t.type?t.value.isEqual(e.value):1!==t.type||t.data.isEqual(e.data)&&t.fieldMask.isEqual(e.fieldMask))}function zs(t){return t.isFoundDocument()?t.version:Jr.min()}class Ks extends Us{constructor(t,e,n,r=[]){super(),this.key=t,this.value=e,this.precondition=n,this.fieldTransforms=r,this.type=0}}class Ws extends Us{constructor(t,e,n,r,i=[]){super(),this.key=t,this.data=e,this.fieldMask=n,this.precondition=r,this.fieldTransforms=i,this.type=1}}function Gs(t){const e=new Map;return t.fieldMask.fields.forEach((n=>{if(!n.isEmpty()){const r=t.data.field(n);e.set(n,r)}})),e}function Hs(t,e,n){const r=new Map;xr(t.length===n.length);for(let i=0;i<n.length;i++){const s=t[i],o=s.transform,a=e.data.field(s.field);r.set(s.field,Es(o,a,n[i]))}return r}function $s(t,e,n){const r=new Map;for(const i of t){const t=i.transform,s=n.data.field(i.field);r.set(i.field,_s(t,s,e))}return r}class Ys extends Us{constructor(t,e){super(),this.key=t,this.precondition=e,this.type=2,this.fieldTransforms=[]}}class Qs extends Us{constructor(t,e){super(),this.key=t,this.precondition=e,this.type=3,this.fieldTransforms=[]}}class Js{constructor(t){this.count=t}}var Zs,Xs;function to(t){switch(t){default:return Nr();case Or.CANCELLED:case Or.UNKNOWN:case Or.DEADLINE_EXCEEDED:case Or.RESOURCE_EXHAUSTED:case Or.INTERNAL:case Or.UNAVAILABLE:case Or.UNAUTHENTICATED:return!1;case Or.INVALID_ARGUMENT:case Or.NOT_FOUND:case Or.ALREADY_EXISTS:case Or.PERMISSION_DENIED:case Or.FAILED_PRECONDITION:case Or.ABORTED:case Or.OUT_OF_RANGE:case Or.UNIMPLEMENTED:case Or.DATA_LOSS:return!0}}function eo(t){if(void 0===t)return Sr("GRPC error has no .code"),Or.UNKNOWN;switch(t){case Zs.OK:return Or.OK;case Zs.CANCELLED:return Or.CANCELLED;case Zs.UNKNOWN:return Or.UNKNOWN;case Zs.DEADLINE_EXCEEDED:return Or.DEADLINE_EXCEEDED;case Zs.RESOURCE_EXHAUSTED:return Or.RESOURCE_EXHAUSTED;case Zs.INTERNAL:return Or.INTERNAL;case Zs.UNAVAILABLE:return Or.UNAVAILABLE;case Zs.UNAUTHENTICATED:return Or.UNAUTHENTICATED;case Zs.INVALID_ARGUMENT:return Or.INVALID_ARGUMENT;case Zs.NOT_FOUND:return Or.NOT_FOUND;case Zs.ALREADY_EXISTS:return Or.ALREADY_EXISTS;case Zs.PERMISSION_DENIED:return Or.PERMISSION_DENIED;case Zs.FAILED_PRECONDITION:return Or.FAILED_PRECONDITION;case Zs.ABORTED:return Or.ABORTED;case Zs.OUT_OF_RANGE:return Or.OUT_OF_RANGE;case Zs.UNIMPLEMENTED:return Or.UNIMPLEMENTED;case Zs.DATA_LOSS:return Or.DATA_LOSS;default:return Nr()}}(Xs=Zs||(Zs={}))[Xs.OK=0]="OK",Xs[Xs.CANCELLED=1]="CANCELLED",Xs[Xs.UNKNOWN=2]="UNKNOWN",Xs[Xs.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",Xs[Xs.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",Xs[Xs.NOT_FOUND=5]="NOT_FOUND",Xs[Xs.ALREADY_EXISTS=6]="ALREADY_EXISTS",Xs[Xs.PERMISSION_DENIED=7]="PERMISSION_DENIED",Xs[Xs.UNAUTHENTICATED=16]="UNAUTHENTICATED",Xs[Xs.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",Xs[Xs.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",Xs[Xs.ABORTED=10]="ABORTED",Xs[Xs.OUT_OF_RANGE=11]="OUT_OF_RANGE",Xs[Xs.UNIMPLEMENTED=12]="UNIMPLEMENTED",Xs[Xs.INTERNAL=13]="INTERNAL",Xs[Xs.UNAVAILABLE=14]="UNAVAILABLE",Xs[Xs.DATA_LOSS=15]="DATA_LOSS";class no{constructor(t,e){this.comparator=t,this.root=e||io.EMPTY}insert(t,e){return new no(this.comparator,this.root.insert(t,e,this.comparator).copy(null,null,io.BLACK,null,null))}remove(t){return new no(this.comparator,this.root.remove(t,this.comparator).copy(null,null,io.BLACK,null,null))}get(t){let e=this.root;for(;!e.isEmpty();){const n=this.comparator(t,e.key);if(0===n)return e.value;n<0?e=e.left:n>0&&(e=e.right)}return null}indexOf(t){let e=0,n=this.root;for(;!n.isEmpty();){const r=this.comparator(t,n.key);if(0===r)return e+n.left.size;r<0?n=n.left:(e+=n.left.size+1,n=n.right)}return-1}isEmpty(){return this.root.isEmpty()}get size(){return this.root.size}minKey(){return this.root.minKey()}maxKey(){return this.root.maxKey()}inorderTraversal(t){return this.root.inorderTraversal(t)}forEach(t){this.inorderTraversal(((e,n)=>(t(e,n),!1)))}toString(){const t=[];return this.inorderTraversal(((e,n)=>(t.push(`${e}:${n}`),!1))),`{${t.join(", ")}}`}reverseTraversal(t){return this.root.reverseTraversal(t)}getIterator(){return new ro(this.root,null,this.comparator,!1)}getIteratorFrom(t){return new ro(this.root,t,this.comparator,!1)}getReverseIterator(){return new ro(this.root,null,this.comparator,!0)}getReverseIteratorFrom(t){return new ro(this.root,t,this.comparator,!0)}}class ro{constructor(t,e,n,r){this.isReverse=r,this.nodeStack=[];let i=1;for(;!t.isEmpty();)if(i=e?n(t.key,e):1,r&&(i*=-1),i<0)t=this.isReverse?t.left:t.right;else{if(0===i){this.nodeStack.push(t);break}this.nodeStack.push(t),t=this.isReverse?t.right:t.left}}getNext(){let t=this.nodeStack.pop();const e={key:t.key,value:t.value};if(this.isReverse)for(t=t.left;!t.isEmpty();)this.nodeStack.push(t),t=t.right;else for(t=t.right;!t.isEmpty();)this.nodeStack.push(t),t=t.left;return e}hasNext(){return this.nodeStack.length>0}peek(){if(0===this.nodeStack.length)return null;const t=this.nodeStack[this.nodeStack.length-1];return{key:t.key,value:t.value}}}class io{constructor(t,e,n,r,i){this.key=t,this.value=e,this.color=null!=n?n:io.RED,this.left=null!=r?r:io.EMPTY,this.right=null!=i?i:io.EMPTY,this.size=this.left.size+1+this.right.size}copy(t,e,n,r,i){return new io(null!=t?t:this.key,null!=e?e:this.value,null!=n?n:this.color,null!=r?r:this.left,null!=i?i:this.right)}isEmpty(){return!1}inorderTraversal(t){return this.left.inorderTraversal(t)||t(this.key,this.value)||this.right.inorderTraversal(t)}reverseTraversal(t){return this.right.reverseTraversal(t)||t(this.key,this.value)||this.left.reverseTraversal(t)}min(){return this.left.isEmpty()?this:this.left.min()}minKey(){return this.min().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(t,e,n){let r=this;const i=n(t,r.key);return r=i<0?r.copy(null,null,null,r.left.insert(t,e,n),null):0===i?r.copy(null,e,null,null,null):r.copy(null,null,null,null,r.right.insert(t,e,n)),r.fixUp()}removeMin(){if(this.left.isEmpty())return io.EMPTY;let t=this;return t.left.isRed()||t.left.left.isRed()||(t=t.moveRedLeft()),t=t.copy(null,null,null,t.left.removeMin(),null),t.fixUp()}remove(t,e){let n,r=this;if(e(t,r.key)<0)r.left.isEmpty()||r.left.isRed()||r.left.left.isRed()||(r=r.moveRedLeft()),r=r.copy(null,null,null,r.left.remove(t,e),null);else{if(r.left.isRed()&&(r=r.rotateRight()),r.right.isEmpty()||r.right.isRed()||r.right.left.isRed()||(r=r.moveRedRight()),0===e(t,r.key)){if(r.right.isEmpty())return io.EMPTY;n=r.right.min(),r=r.copy(n.key,n.value,null,null,r.right.removeMin())}r=r.copy(null,null,null,null,r.right.remove(t,e))}return r.fixUp()}isRed(){return this.color}fixUp(){let t=this;return t.right.isRed()&&!t.left.isRed()&&(t=t.rotateLeft()),t.left.isRed()&&t.left.left.isRed()&&(t=t.rotateRight()),t.left.isRed()&&t.right.isRed()&&(t=t.colorFlip()),t}moveRedLeft(){let t=this.colorFlip();return t.right.left.isRed()&&(t=t.copy(null,null,null,null,t.right.rotateRight()),t=t.rotateLeft(),t=t.colorFlip()),t}moveRedRight(){let t=this.colorFlip();return t.left.left.isRed()&&(t=t.rotateRight(),t=t.colorFlip()),t}rotateLeft(){const t=this.copy(null,null,io.RED,null,this.right.left);return this.right.copy(null,null,this.color,t,null)}rotateRight(){const t=this.copy(null,null,io.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,t)}colorFlip(){const t=this.left.copy(null,null,!this.left.color,null,null),e=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,t,e)}checkMaxDepth(){const t=this.check();return Math.pow(2,t)<=this.size+1}check(){if(this.isRed()&&this.left.isRed())throw Nr();if(this.right.isRed())throw Nr();const t=this.left.check();if(t!==this.right.check())throw Nr();return t+(this.isRed()?0:1)}}io.EMPTY=null,io.RED=!0,io.BLACK=!1,io.EMPTY=new class{constructor(){this.size=0}get key(){throw Nr()}get value(){throw Nr()}get color(){throw Nr()}get left(){throw Nr()}get right(){throw Nr()}copy(t,e,n,r,i){return this}insert(t,e,n){return new io(t,e)}remove(t,e){return this}isEmpty(){return!0}inorderTraversal(t){return!1}reverseTraversal(t){return!1}minKey(){return null}maxKey(){return null}isRed(){return!1}checkMaxDepth(){return!0}check(){return 0}};class so{constructor(t){this.comparator=t,this.data=new no(this.comparator)}has(t){return null!==this.data.get(t)}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(t){return this.data.indexOf(t)}forEach(t){this.data.inorderTraversal(((e,n)=>(t(e),!1)))}forEachInRange(t,e){const n=this.data.getIteratorFrom(t[0]);for(;n.hasNext();){const r=n.getNext();if(this.comparator(r.key,t[1])>=0)return;e(r.key)}}forEachWhile(t,e){let n;for(n=void 0!==e?this.data.getIteratorFrom(e):this.data.getIterator();n.hasNext();)if(!t(n.getNext().key))return}firstAfterOrEqual(t){const e=this.data.getIteratorFrom(t);return e.hasNext()?e.getNext().key:null}getIterator(){return new oo(this.data.getIterator())}getIteratorFrom(t){return new oo(this.data.getIteratorFrom(t))}add(t){return this.copy(this.data.remove(t).insert(t,!0))}delete(t){return this.has(t)?this.copy(this.data.remove(t)):this}isEmpty(){return this.data.isEmpty()}unionWith(t){let e=this;return e.size<t.size&&(e=t,t=this),t.forEach((t=>{e=e.add(t)})),e}isEqual(t){if(!(t instanceof so))return!1;if(this.size!==t.size)return!1;const e=this.data.getIterator(),n=t.data.getIterator();for(;e.hasNext();){const t=e.getNext().key,r=n.getNext().key;if(0!==this.comparator(t,r))return!1}return!0}toArray(){const t=[];return this.forEach((e=>{t.push(e)})),t}toString(){const t=[];return this.forEach((e=>t.push(e))),"SortedSet("+t.toString()+")"}copy(t){const e=new so(this.comparator);return e.data=t,e}}class oo{constructor(t){this.iter=t}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}const ao=new no(vi.comparator);function co(){return ao}const uo=new no(vi.comparator);function ho(){return uo}const lo=new no(vi.comparator);function fo(){return lo}const po=new so(vi.comparator);function mo(...t){let e=po;for(const n of t)e=e.add(n);return e}const go=new so(Hr);function yo(){return go}class vo{constructor(t,e,n,r,i){this.snapshotVersion=t,this.targetChanges=e,this.targetMismatches=n,this.documentUpdates=r,this.resolvedLimboDocuments=i}static createSynthesizedRemoteEventForCurrentChange(t,e){const n=new Map;return n.set(t,bo.createSynthesizedTargetChangeForCurrentChange(t,e)),new vo(Jr.min(),n,yo(),co(),mo())}}class bo{constructor(t,e,n,r,i){this.resumeToken=t,this.current=e,this.addedDocuments=n,this.modifiedDocuments=r,this.removedDocuments=i}static createSynthesizedTargetChangeForCurrentChange(t,e){return new bo(ai.EMPTY_BYTE_STRING,e,mo(),mo(),mo())}}class wo{constructor(t,e,n,r){this.$=t,this.removedTargetIds=e,this.key=n,this.O=r}}class Io{constructor(t,e){this.targetId=t,this.F=e}}class To{constructor(t,e,n=ai.EMPTY_BYTE_STRING,r=null){this.state=t,this.targetIds=e,this.resumeToken=n,this.cause=r}}class _o{constructor(){this.M=0,this.L=ko(),this.B=ai.EMPTY_BYTE_STRING,this.U=!1,this.q=!0}get current(){return this.U}get resumeToken(){return this.B}get K(){return 0!==this.M}get j(){return this.q}W(t){t.approximateByteSize()>0&&(this.q=!0,this.B=t)}G(){let t=mo(),e=mo(),n=mo();return this.L.forEach(((r,i)=>{switch(i){case 0:t=t.add(r);break;case 2:e=e.add(r);break;case 1:n=n.add(r);break;default:Nr()}})),new bo(this.B,this.U,t,e,n)}H(){this.q=!1,this.L=ko()}J(t,e){this.q=!0,this.L=this.L.insert(t,e)}Y(t){this.q=!0,this.L=this.L.remove(t)}X(){this.M+=1}Z(){this.M-=1}tt(){this.q=!0,this.U=!0}}class Eo{constructor(t){this.et=t,this.nt=new Map,this.st=co(),this.it=So(),this.rt=new so(Hr)}ot(t){for(const e of t.$)t.O&&t.O.isFoundDocument()?this.at(e,t.O):this.ct(e,t.key,t.O);for(const e of t.removedTargetIds)this.ct(e,t.key,t.O)}ut(t){this.forEachTarget(t,(e=>{const n=this.ht(e);switch(t.state){case 0:this.lt(e)&&n.W(t.resumeToken);break;case 1:n.Z(),n.K||n.H(),n.W(t.resumeToken);break;case 2:n.Z(),n.K||this.removeTarget(e);break;case 3:this.lt(e)&&(n.tt(),n.W(t.resumeToken));break;case 4:this.lt(e)&&(this.ft(e),n.W(t.resumeToken));break;default:Nr()}}))}forEachTarget(t,e){t.targetIds.length>0?t.targetIds.forEach(e):this.nt.forEach(((t,n)=>{this.lt(n)&&e(n)}))}dt(t){const e=t.targetId,n=t.F.count,r=this.wt(e);if(r){const t=r.target;if(ji(t))if(0===n){const n=new vi(t.path);this.ct(e,n,Li.newNoDocument(n,Jr.min()))}else xr(1===n);else this._t(e)!==n&&(this.ft(e),this.rt=this.rt.add(e))}}gt(t){const e=new Map;this.nt.forEach(((n,r)=>{const i=this.wt(r);if(i){if(n.current&&ji(i.target)){const e=new vi(i.target.path);null!==this.st.get(e)||this.yt(r,e)||this.ct(r,e,Li.newNoDocument(e,t))}n.j&&(e.set(r,n.G()),n.H())}}));let n=mo();this.it.forEach(((t,e)=>{let r=!0;e.forEachWhile((t=>{const e=this.wt(t);return!e||2===e.purpose||(r=!1,!1)})),r&&(n=n.add(t))}));const r=new vo(t,e,this.rt,this.st,n);return this.st=co(),this.it=So(),this.rt=new so(Hr),r}at(t,e){if(!this.lt(t))return;const n=this.yt(t,e.key)?2:0;this.ht(t).J(e.key,n),this.st=this.st.insert(e.key,e),this.it=this.it.insert(e.key,this.Tt(e.key).add(t))}ct(t,e,n){if(!this.lt(t))return;const r=this.ht(t);this.yt(t,e)?r.J(e,1):r.Y(e),this.it=this.it.insert(e,this.Tt(e).delete(t)),n&&(this.st=this.st.insert(e,n))}removeTarget(t){this.nt.delete(t)}_t(t){const e=this.ht(t).G();return this.et.getRemoteKeysForTarget(t).size+e.addedDocuments.size-e.removedDocuments.size}X(t){this.ht(t).X()}ht(t){let e=this.nt.get(t);return e||(e=new _o,this.nt.set(t,e)),e}Tt(t){let e=this.it.get(t);return e||(e=new so(Hr),this.it=this.it.insert(t,e)),e}lt(t){const e=null!==this.wt(t);return e||Er("WatchChangeAggregator","Detected inactive target",t),e}wt(t){const e=this.nt.get(t);return e&&e.K?null:this.et.Et(t)}ft(t){this.nt.set(t,new _o),this.et.getRemoteKeysForTarget(t).forEach((e=>{this.ct(t,e,null)}))}yt(t,e){return this.et.getRemoteKeysForTarget(t).has(e)}}function So(){return new no(vi.comparator)}function ko(){return new no(vi.comparator)}const Ao={asc:"ASCENDING",desc:"DESCENDING"},No={"<":"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"};class xo{constructor(t,e){this.databaseId=t,this.C=e}}function Co(t,e){return t.C?`${new Date(1e3*e.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+e.nanoseconds).slice(-9)}Z`:{seconds:""+e.seconds,nanos:e.nanoseconds}}function Do(t,e){return t.C?e.toBase64():e.toUint8Array()}function Oo(t,e){return Co(t,e.toTimestamp())}function Ro(t){return xr(!!t),Jr.fromTimestamp(function(t){const e=ui(t);return new Qr(e.seconds,e.nanos)}(t))}function Po(t,e){return function(t){return new ni(["projects",t.projectId,"databases",t.database])}(t).child("documents").child(e).canonicalString()}function Lo(t){const e=ni.fromString(t);return xr(sa(e)),e}function Mo(t,e){return Po(t.databaseId,e.path)}function Fo(t,e){const n=Lo(e);if(n.get(1)!==t.databaseId.projectId)throw new Rr(Or.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+n.get(1)+" vs "+t.databaseId.projectId);if(n.get(3)!==t.databaseId.database)throw new Rr(Or.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+n.get(3)+" vs "+t.databaseId.database);return new vi(qo(n))}function Uo(t,e){return Po(t.databaseId,e)}function Vo(t){const e=Lo(t);return 4===e.length?ni.emptyPath():qo(e)}function jo(t){return new ni(["projects",t.databaseId.projectId,"databases",t.databaseId.database]).canonicalString()}function qo(t){return xr(t.length>4&&"documents"===t.get(4)),t.popFirst(5)}function Bo(t,e,n){return{name:Mo(t,e),fields:n.value.mapValue.fields}}function zo(t,e,n){const r=Fo(t,e.name),i=Ro(e.updateTime),s=new Ri({mapValue:{fields:e.fields}}),o=Li.newFoundDocument(r,i,s);return n&&o.setHasCommittedMutations(),n?o.setHasCommittedMutations():o}function Ko(t,e){let n;if(e instanceof Ks)n={update:Bo(t,e.key,e.value)};else if(e instanceof Ys)n={delete:Mo(t,e.key)};else if(e instanceof Ws)n={update:Bo(t,e.key,e.data),updateMask:ia(e.fieldMask)};else{if(!(e instanceof Qs))return Nr();n={verify:Mo(t,e.key)}}return e.fieldTransforms.length>0&&(n.updateTransforms=e.fieldTransforms.map((t=>function(t,e){const n=e.transform;if(n instanceof ks)return{fieldPath:e.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(n instanceof As)return{fieldPath:e.field.canonicalString(),appendMissingElements:{values:n.elements}};if(n instanceof xs)return{fieldPath:e.field.canonicalString(),removeAllFromArray:{values:n.elements}};if(n instanceof Ds)return{fieldPath:e.field.canonicalString(),increment:n.N};throw Nr()}(0,t)))),e.precondition.isNone||(n.currentDocument=function(t,e){return void 0!==e.updateTime?{updateTime:Oo(t,e.updateTime)}:void 0!==e.exists?{exists:e.exists}:Nr()}(t,e.precondition)),n}function Wo(t,e){const n=e.currentDocument?function(t){return void 0!==t.updateTime?Ms.updateTime(Ro(t.updateTime)):void 0!==t.exists?Ms.exists(t.exists):Ms.none()}(e.currentDocument):Ms.none(),r=e.updateTransforms?e.updateTransforms.map((e=>function(t,e){let n=null;if("setToServerValue"in e)xr("REQUEST_TIME"===e.setToServerValue),n=new ks;else if("appendMissingElements"in e){const t=e.appendMissingElements.values||[];n=new As(t)}else if("removeAllFromArray"in e){const t=e.removeAllFromArray.values||[];n=new xs(t)}else"increment"in e?n=new Ds(t,e.increment):Nr();const r=ii.fromServerFormat(e.fieldPath);return new Ps(r,n)}(t,e))):[];if(e.update){e.update.name;const i=Fo(t,e.update.name),s=new Ri({mapValue:{fields:e.update.fields}});if(e.updateMask){const t=function(t){const e=t.fieldPaths||[];return new si(e.map((t=>ii.fromServerFormat(t))))}(e.updateMask);return new Ws(i,s,t,n,r)}return new Ks(i,s,n,r)}if(e.delete){const r=Fo(t,e.delete);return new Ys(r,n)}if(e.verify){const r=Fo(t,e.verify);return new Qs(r,n)}return Nr()}function Go(t,e){return{documents:[Uo(t,e.path)]}}function Ho(t,e){const n={structuredQuery:{}},r=e.path;null!==e.collectionGroup?(n.parent=Uo(t,r),n.structuredQuery.from=[{collectionId:e.collectionGroup,allDescendants:!0}]):(n.parent=Uo(t,r.popLast()),n.structuredQuery.from=[{collectionId:r.lastSegment()}]);const i=function(t){if(0===t.length)return;const e=t.map((t=>function(t){if("=="===t.op){if(Ci(t.value))return{unaryFilter:{field:ta(t.field),op:"IS_NAN"}};if(xi(t.value))return{unaryFilter:{field:ta(t.field),op:"IS_NULL"}}}else if("!="===t.op){if(Ci(t.value))return{unaryFilter:{field:ta(t.field),op:"IS_NOT_NAN"}};if(xi(t.value))return{unaryFilter:{field:ta(t.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:ta(t.field),op:Xo(t.op),value:t.value}}}(t)));return 1===e.length?e[0]:{compositeFilter:{op:"AND",filters:e}}}(e.filters);i&&(n.structuredQuery.where=i);const s=function(t){if(0!==t.length)return t.map((t=>function(t){return{field:ta(t.field),direction:Zo(t.dir)}}(t)))}(e.orderBy);s&&(n.structuredQuery.orderBy=s);const o=function(t,e){return t.C||mi(e)?e:{value:e}}(t,e.limit);return null!==o&&(n.structuredQuery.limit=o),e.startAt&&(n.structuredQuery.startAt=Qo(e.startAt)),e.endAt&&(n.structuredQuery.endAt=Qo(e.endAt)),n}function $o(t){let e=Vo(t.parent);const n=t.structuredQuery,r=n.from?n.from.length:0;let i=null;if(r>0){xr(1===r);const t=n.from[0];t.allDescendants?i=t.collectionId:e=e.child(t.collectionId)}let s=[];n.where&&(s=Yo(n.where));let o=[];n.orderBy&&(o=n.orderBy.map((t=>function(t){return new Zi(ea(t.field),function(t){switch(t){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(t.direction))}(t))));let a=null;n.limit&&(a=function(t){let e;return e="object"==typeof t?t.value:t,mi(e)?null:e}(n.limit));let c=null;n.startAt&&(c=Jo(n.startAt));let u=null;return n.endAt&&(u=Jo(n.endAt)),rs(e,i,o,s,a,"F",c,u)}function Yo(t){return t?void 0!==t.unaryFilter?[ra(t)]:void 0!==t.fieldFilter?[na(t)]:void 0!==t.compositeFilter?t.compositeFilter.filters.map((t=>Yo(t))).reduce(((t,e)=>t.concat(e))):Nr():[]}function Qo(t){return{before:t.before,values:t.position}}function Jo(t){const e=!!t.before,n=t.values||[];return new Qi(n,e)}function Zo(t){return Ao[t]}function Xo(t){return No[t]}function ta(t){return{fieldPath:t.canonicalString()}}function ea(t){return ii.fromServerFormat(t.fieldPath)}function na(t){return qi.create(ea(t.fieldFilter.field),function(t){switch(t){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 Nr()}}(t.fieldFilter.op),t.fieldFilter.value)}function ra(t){switch(t.unaryFilter.op){case"IS_NAN":const e=ea(t.unaryFilter.field);return qi.create(e,"==",{doubleValue:NaN});case"IS_NULL":const n=ea(t.unaryFilter.field);return qi.create(n,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":const r=ea(t.unaryFilter.field);return qi.create(r,"!=",{doubleValue:NaN});case"IS_NOT_NULL":const i=ea(t.unaryFilter.field);return qi.create(i,"!=",{nullValue:"NULL_VALUE"});default:return Nr()}}function ia(t){const e=[];return t.fields.forEach((t=>e.push(t.canonicalString()))),{fieldPaths:e}}function sa(t){return t.length>=4&&"projects"===t.get(0)&&"databases"===t.get(2)}function oa(t){let e="";for(let n=0;n<t.length;n++)e.length>0&&(e=ca(e)),e=aa(t.get(n),e);return ca(e)}function aa(t,e){let n=e;const r=t.length;for(let e=0;e<r;e++){const r=t.charAt(e);switch(r){case"\0":n+="";break;case"":n+="";break;default:n+=r}}return n}function ca(t){return t+""}function ua(t){const e=t.length;if(xr(e>=2),2===e)return xr(""===t.charAt(0)&&""===t.charAt(1)),ni.emptyPath();const n=e-2,r=[];let i="";for(let s=0;s<e;){const e=t.indexOf("",s);switch((e<0||e>n)&&Nr(),t.charAt(e+1)){case"":const n=t.substring(s,e);let o;0===i.length?o=n:(i+=n,o=i,i=""),r.push(o);break;case"":i+=t.substring(s,e),i+="\0";break;case"":i+=t.substring(s,e+1);break;default:Nr()}s=e+2}return new ni(r)}class ha{constructor(t,e){this.seconds=t,this.nanoseconds=e}}class la{constructor(t,e,n){this.ownerId=t,this.allowTabSynchronization=e,this.leaseTimestampMs=n}}la.store="owner",la.key="owner";class da{constructor(t,e,n){this.userId=t,this.lastAcknowledgedBatchId=e,this.lastStreamToken=n}}da.store="mutationQueues",da.keyPath="userId";class fa{constructor(t,e,n,r,i){this.userId=t,this.batchId=e,this.localWriteTimeMs=n,this.baseMutations=r,this.mutations=i}}fa.store="mutations",fa.keyPath="batchId",fa.userMutationsIndex="userMutationsIndex",fa.userMutationsKeyPath=["userId","batchId"];class pa{constructor(){}static prefixForUser(t){return[t]}static prefixForPath(t,e){return[t,oa(e)]}static key(t,e,n){return[t,oa(e),n]}}pa.store="documentMutations",pa.PLACEHOLDER=new pa;class ma{constructor(t,e){this.path=t,this.readTime=e}}class ga{constructor(t,e){this.path=t,this.version=e}}class ya{constructor(t,e,n,r,i,s){this.unknownDocument=t,this.noDocument=e,this.document=n,this.hasCommittedMutations=r,this.readTime=i,this.parentPath=s}}ya.store="remoteDocuments",ya.readTimeIndex="readTimeIndex",ya.readTimeIndexPath="readTime",ya.collectionReadTimeIndex="collectionReadTimeIndex",ya.collectionReadTimeIndexPath=["parentPath","readTime"];class va{constructor(t){this.byteSize=t}}va.store="remoteDocumentGlobal",va.key="remoteDocumentGlobalKey";class ba{constructor(t,e,n,r,i,s,o){this.targetId=t,this.canonicalId=e,this.readTime=n,this.resumeToken=r,this.lastListenSequenceNumber=i,this.lastLimboFreeSnapshotVersion=s,this.query=o}}ba.store="targets",ba.keyPath="targetId",ba.queryTargetsIndexName="queryTargetsIndex",ba.queryTargetsKeyPath=["canonicalId","targetId"];class wa{constructor(t,e,n){this.targetId=t,this.path=e,this.sequenceNumber=n}}wa.store="targetDocuments",wa.keyPath=["targetId","path"],wa.documentTargetsIndex="documentTargetsIndex",wa.documentTargetsKeyPath=["path","targetId"];class Ia{constructor(t,e,n,r){this.highestTargetId=t,this.highestListenSequenceNumber=e,this.lastRemoteSnapshotVersion=n,this.targetCount=r}}Ia.key="targetGlobalKey",Ia.store="targetGlobal";class Ta{constructor(t,e){this.collectionId=t,this.parent=e}}Ta.store="collectionParents",Ta.keyPath=["collectionId","parent"];class _a{constructor(t,e,n,r){this.clientId=t,this.updateTimeMs=e,this.networkEnabled=n,this.inForeground=r}}_a.store="clientMetadata",_a.keyPath="clientId";class Ea{constructor(t,e,n){this.bundleId=t,this.createTime=e,this.version=n}}Ea.store="bundles",Ea.keyPath="bundleId";class Sa{constructor(t,e,n){this.name=t,this.readTime=e,this.bundledQuery=n}}Sa.store="namedQueries",Sa.keyPath="name";const ka=[da.store,fa.store,pa.store,ya.store,ba.store,la.store,Ia.store,wa.store,_a.store,va.store,Ta.store,Ea.store,Sa.store],Aa="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class Na{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(t){this.onCommittedListeners.push(t)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach((t=>t()))}}class xa{constructor(t){this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,t((t=>{this.isDone=!0,this.result=t,this.nextCallback&&this.nextCallback(t)}),(t=>{this.isDone=!0,this.error=t,this.catchCallback&&this.catchCallback(t)}))}catch(t){return this.next(void 0,t)}next(t,e){return this.callbackAttached&&Nr(),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(e,this.error):this.wrapSuccess(t,this.result):new xa(((n,r)=>{this.nextCallback=e=>{this.wrapSuccess(t,e).next(n,r)},this.catchCallback=t=>{this.wrapFailure(e,t).next(n,r)}}))}toPromise(){return new Promise(((t,e)=>{this.next(t,e)}))}wrapUserFunction(t){try{const e=t();return e instanceof xa?e:xa.resolve(e)}catch(t){return xa.reject(t)}}wrapSuccess(t,e){return t?this.wrapUserFunction((()=>t(e))):xa.resolve(e)}wrapFailure(t,e){return t?this.wrapUserFunction((()=>t(e))):xa.reject(e)}static resolve(t){return new xa(((e,n)=>{e(t)}))}static reject(t){return new xa(((e,n)=>{n(t)}))}static waitFor(t){return new xa(((e,n)=>{let r=0,i=0,s=!1;t.forEach((t=>{++r,t.next((()=>{++i,s&&i===r&&e()}),(t=>n(t)))})),s=!0,i===r&&e()}))}static or(t){let e=xa.resolve(!1);for(const n of t)e=e.next((t=>t?xa.resolve(t):n()));return e}static forEach(t,e){const n=[];return t.forEach(((t,r)=>{n.push(e.call(this,t,r))})),this.waitFor(n)}}class Ca{constructor(t,e){this.action=t,this.transaction=e,this.aborted=!1,this.It=new Pr,this.transaction.oncomplete=()=>{this.It.resolve()},this.transaction.onabort=()=>{e.error?this.It.reject(new Ra(t,e.error)):this.It.resolve()},this.transaction.onerror=e=>{const n=Ua(e.target.error);this.It.reject(new Ra(t,n))}}static open(t,e,n,r){try{return new Ca(e,t.transaction(r,n))}catch(t){throw new Ra(e,t)}}get At(){return this.It.promise}abort(t){t&&this.It.reject(t),this.aborted||(Er("SimpleDb","Aborting transaction:",t?t.message:"Client-initiated abort"),this.aborted=!0,this.transaction.abort())}store(t){const e=this.transaction.objectStore(t);return new La(e)}}class Da{constructor(t,e,n){this.name=t,this.version=e,this.Rt=n,12.2===Da.bt((0,a.z$)())&&Sr("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.")}static delete(t){return Er("SimpleDb","Removing database:",t),Ma(window.indexedDB.deleteDatabase(t)).toPromise()}static Pt(){if(!(0,a.hl)())return!1;if(Da.vt())return!0;const t=(0,a.z$)(),e=Da.bt(t),n=0<e&&e<10,r=Da.Vt(t),i=0<r&&r<4.5;return!(t.indexOf("MSIE ")>0||t.indexOf("Trident/")>0||t.indexOf("Edge/")>0||n||i)}static vt(){var t;return"undefined"!=typeof process&&"YES"===(null===(t=process.env)||void 0===t?void 0:t.St)}static Dt(t,e){return t.store(e)}static bt(t){const e=t.match(/i(?:phone|pad|pod) os ([\d_]+)/i),n=e?e[1].split("_").slice(0,2).join("."):"-1";return Number(n)}static Vt(t){const e=t.match(/Android ([\d.]+)/i),n=e?e[1].split(".").slice(0,2).join("."):"-1";return Number(n)}async Ct(t){return this.db||(Er("SimpleDb","Opening database:",this.name),this.db=await new Promise(((e,n)=>{const r=indexedDB.open(this.name,this.version);r.onsuccess=t=>{const n=t.target.result;e(n)},r.onblocked=()=>{n(new Ra(t,"Cannot upgrade IndexedDB schema while another tab is open. Close all tabs that access Firestore and reload this page to proceed."))},r.onerror=e=>{const r=e.target.error;"VersionError"===r.name?n(new Rr(Or.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"===r.name?n(new Rr(Or.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: "+r)):n(new Ra(t,r))},r.onupgradeneeded=t=>{Er("SimpleDb",'Database "'+this.name+'" requires upgrade from version:',t.oldVersion);const e=t.target.result;this.Rt.Nt(e,r.transaction,t.oldVersion,this.version).next((()=>{Er("SimpleDb","Database upgrade to version "+this.version+" complete")}))}}))),this.kt&&(this.db.onversionchange=t=>this.kt(t)),this.db}xt(t){this.kt=t,this.db&&(this.db.onversionchange=e=>t(e))}async runTransaction(t,e,n,r){const i="readonly"===e;let s=0;for(;;){++s;try{this.db=await this.Ct(t);const e=Ca.open(this.db,t,i?"readonly":"readwrite",n),s=r(e).catch((t=>(e.abort(t),xa.reject(t)))).toPromise();return s.catch((()=>{})),await e.At,s}catch(t){const e="FirebaseError"!==t.name&&s<3;if(Er("SimpleDb","Transaction failed with error:",t.message,"Retrying:",e),this.close(),!e)return Promise.reject(t)}}}close(){this.db&&this.db.close(),this.db=void 0}}class Oa{constructor(t){this.$t=t,this.Ot=!1,this.Ft=null}get isDone(){return this.Ot}get Mt(){return this.Ft}set cursor(t){this.$t=t}done(){this.Ot=!0}Lt(t){this.Ft=t}delete(){return Ma(this.$t.delete())}}class Ra extends Rr{constructor(t,e){super(Or.UNAVAILABLE,`IndexedDB transaction '${t}' failed: ${e}`),this.name="IndexedDbTransactionError"}}function Pa(t){return"IndexedDbTransactionError"===t.name}class La{constructor(t){this.store=t}put(t,e){let n;return void 0!==e?(Er("SimpleDb","PUT",this.store.name,t,e),n=this.store.put(e,t)):(Er("SimpleDb","PUT",this.store.name,"<auto-key>",t),n=this.store.put(t)),Ma(n)}add(t){return Er("SimpleDb","ADD",this.store.name,t,t),Ma(this.store.add(t))}get(t){return Ma(this.store.get(t)).next((e=>(void 0===e&&(e=null),Er("SimpleDb","GET",this.store.name,t,e),e)))}delete(t){return Er("SimpleDb","DELETE",this.store.name,t),Ma(this.store.delete(t))}count(){return Er("SimpleDb","COUNT",this.store.name),Ma(this.store.count())}Bt(t,e){const n=this.cursor(this.options(t,e)),r=[];return this.Ut(n,((t,e)=>{r.push(e)})).next((()=>r))}qt(t,e){Er("SimpleDb","DELETE ALL",this.store.name);const n=this.options(t,e);n.Kt=!1;const r=this.cursor(n);return this.Ut(r,((t,e,n)=>n.delete()))}jt(t,e){let n;e?n=t:(n={},e=t);const r=this.cursor(n);return this.Ut(r,e)}Qt(t){const e=this.cursor({});return new xa(((n,r)=>{e.onerror=t=>{const e=Ua(t.target.error);r(e)},e.onsuccess=e=>{const r=e.target.result;r?t(r.primaryKey,r.value).next((t=>{t?r.continue():n()})):n()}}))}Ut(t,e){const n=[];return new xa(((r,i)=>{t.onerror=t=>{i(t.target.error)},t.onsuccess=t=>{const i=t.target.result;if(!i)return void r();const s=new Oa(i),o=e(i.primaryKey,i.value,s);if(o instanceof xa){const t=o.catch((t=>(s.done(),xa.reject(t))));n.push(t)}s.isDone?r():null===s.Mt?i.continue():i.continue(s.Mt)}})).next((()=>xa.waitFor(n)))}options(t,e){let n;return void 0!==t&&("string"==typeof t?n=t:e=t),{index:n,range:e}}cursor(t){let e="next";if(t.reverse&&(e="prev"),t.index){const n=this.store.index(t.index);return t.Kt?n.openKeyCursor(t.range,e):n.openCursor(t.range,e)}return this.store.openCursor(t.range,e)}}function Ma(t){return new xa(((e,n)=>{t.onsuccess=t=>{const n=t.target.result;e(n)},t.onerror=t=>{const e=Ua(t.target.error);n(e)}}))}let Fa=!1;function Ua(t){const e=Da.bt((0,a.z$)());if(e>=12.2&&e<13){const e="An internal error was encountered in the Indexed Database server";if(t.message.indexOf(e)>=0){const t=new Rr("internal",`IOS_INDEXEDDB_BUG1: IndexedDb has thrown '${e}'. This is likely due to an unavoidable bug in iOS. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.`);return Fa||(Fa=!0,setTimeout((()=>{throw t}),0)),t}}return t}class Va extends Na{constructor(t,e){super(),this.Wt=t,this.currentSequenceNumber=e}}function ja(t,e){const n=Dr(t);return Da.Dt(n.Wt,e)}class qa{constructor(t,e,n,r){this.batchId=t,this.localWriteTime=e,this.baseMutations=n,this.mutations=r}applyToRemoteDocument(t,e){const n=e.mutationResults;for(let e=0;e<this.mutations.length;e++){const r=this.mutations[e];r.key.isEqual(t.key)&&Vs(r,t,n[e])}}applyToLocalView(t){for(const e of this.baseMutations)e.key.isEqual(t.key)&&js(e,t,this.localWriteTime);for(const e of this.mutations)e.key.isEqual(t.key)&&js(e,t,this.localWriteTime)}applyToLocalDocumentSet(t){this.mutations.forEach((e=>{const n=t.get(e.key),r=n;this.applyToLocalView(r),n.isValidDocument()||r.convertToNoDocument(Jr.min())}))}keys(){return this.mutations.reduce(((t,e)=>t.add(e.key)),mo())}isEqual(t){return this.batchId===t.batchId&&$r(this.mutations,t.mutations,((t,e)=>Bs(t,e)))&&$r(this.baseMutations,t.baseMutations,((t,e)=>Bs(t,e)))}}class Ba{constructor(t,e,n,r){this.batch=t,this.commitVersion=e,this.mutationResults=n,this.docVersions=r}static from(t,e,n){xr(t.mutations.length===n.length);let r=fo();const i=t.mutations;for(let t=0;t<i.length;t++)r=r.insert(i[t].key,n[t].version);return new Ba(t,e,n,r)}}class za{constructor(t,e,n,r,i=Jr.min(),s=Jr.min(),o=ai.EMPTY_BYTE_STRING){this.target=t,this.targetId=e,this.purpose=n,this.sequenceNumber=r,this.snapshotVersion=i,this.lastLimboFreeSnapshotVersion=s,this.resumeToken=o}withSequenceNumber(t){return new za(this.target,this.targetId,this.purpose,t,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken)}withResumeToken(t,e){return new za(this.target,this.targetId,this.purpose,this.sequenceNumber,e,this.lastLimboFreeSnapshotVersion,t)}withLastLimboFreeSnapshotVersion(t){return new za(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,t,this.resumeToken)}}class Ka{constructor(t){this.Gt=t}}function Wa(t,e){if(e.document)return zo(t.Gt,e.document,!!e.hasCommittedMutations);if(e.noDocument){const t=vi.fromSegments(e.noDocument.path),n=Qa(e.noDocument.readTime),r=Li.newNoDocument(t,n);return e.hasCommittedMutations?r.setHasCommittedMutations():r}if(e.unknownDocument){const t=vi.fromSegments(e.unknownDocument.path),n=Qa(e.unknownDocument.version);return Li.newUnknownDocument(t,n)}return Nr()}function Ga(t,e,n){const r=Ha(n),i=e.key.path.popLast().toArray();if(e.isFoundDocument()){const n=function(t,e){return{name:Mo(t,e.key),fields:e.data.value.mapValue.fields,updateTime:Co(t,e.version.toTimestamp())}}(t.Gt,e),s=e.hasCommittedMutations;return new ya(null,null,n,s,r,i)}if(e.isNoDocument()){const t=e.key.path.toArray(),n=Ya(e.version),s=e.hasCommittedMutations;return new ya(null,new ma(t,n),null,s,r,i)}if(e.isUnknownDocument()){const t=e.key.path.toArray(),n=Ya(e.version);return new ya(new ga(t,n),null,null,!0,r,i)}return Nr()}function Ha(t){const e=t.toTimestamp();return[e.seconds,e.nanoseconds]}function $a(t){const e=new Qr(t[0],t[1]);return Jr.fromTimestamp(e)}function Ya(t){const e=t.toTimestamp();return new ha(e.seconds,e.nanoseconds)}function Qa(t){const e=new Qr(t.seconds,t.nanoseconds);return Jr.fromTimestamp(e)}function Ja(t,e){const n=(e.baseMutations||[]).map((e=>Wo(t.Gt,e)));for(let t=0;t<e.mutations.length-1;++t){const n=e.mutations[t];if(t+1<e.mutations.length&&void 0!==e.mutations[t+1].transform){const r=e.mutations[t+1];n.updateTransforms=r.transform.fieldTransforms,e.mutations.splice(t+1,1),++t}}const r=e.mutations.map((e=>Wo(t.Gt,e))),i=Qr.fromMillis(e.localWriteTimeMs);return new qa(e.batchId,i,n,r)}function Za(t){const e=Qa(t.readTime),n=void 0!==t.lastLimboFreeSnapshotVersion?Qa(t.lastLimboFreeSnapshotVersion):Jr.min();let r;var i;return void 0!==t.query.documents?(xr(1===(i=t.query).documents.length),r=ls(is(Vo(i.documents[0])))):r=function(t){return ls($o(t))}(t.query),new za(r,t.targetId,0,t.lastListenSequenceNumber,e,n,ai.fromBase64String(t.resumeToken))}function Xa(t,e){const n=Ya(e.snapshotVersion),r=Ya(e.lastLimboFreeSnapshotVersion);let i;i=ji(e.target)?Go(t.Gt,e.target):Ho(t.Gt,e.target);const s=e.resumeToken.toBase64();return new ba(e.targetId,Ui(e.target),n,s,e.sequenceNumber,r,i)}function tc(t){const e=$o({parent:t.parent,structuredQuery:t.structuredQuery});return"LAST"===t.limitType?ds(e,e.limit,"L"):e}class ec{getBundleMetadata(t,e){return nc(t).get(e).next((t=>{if(t)return{id:(e=t).bundleId,createTime:Qa(e.createTime),version:e.version};var e}))}saveBundleMetadata(t,e){return nc(t).put({bundleId:(n=e).id,createTime:Ya(Ro(n.createTime)),version:n.version});var n}getNamedQuery(t,e){return rc(t).get(e).next((t=>{if(t)return{name:(e=t).name,query:tc(e.bundledQuery),readTime:Qa(e.readTime)};var e}))}saveNamedQuery(t,e){return rc(t).put(function(t){return{name:t.name,readTime:Ya(Ro(t.readTime)),bundledQuery:t.bundledQuery}}(e))}}function nc(t){return ja(t,Ea.store)}function rc(t){return ja(t,Sa.store)}class ic{constructor(){this.zt=new sc}addToCollectionParentIndex(t,e){return this.zt.add(e),xa.resolve()}getCollectionParents(t,e){return xa.resolve(this.zt.getEntries(e))}}class sc{constructor(){this.index={}}add(t){const e=t.lastSegment(),n=t.popLast(),r=this.index[e]||new so(ni.comparator),i=!r.has(n);return this.index[e]=r.add(n),i}has(t){const e=t.lastSegment(),n=t.popLast(),r=this.index[e];return r&&r.has(n)}getEntries(t){return(this.index[t]||new so(ni.comparator)).toArray()}}class oc{constructor(){this.Ht=new sc}addToCollectionParentIndex(t,e){if(!this.Ht.has(e)){const n=e.lastSegment(),r=e.popLast();t.addOnCommittedListener((()=>{this.Ht.add(e)}));const i={collectionId:n,parent:oa(r)};return ac(t).put(i)}return xa.resolve()}getCollectionParents(t,e){const n=[],r=IDBKeyRange.bound([e,""],[Yr(e),""],!1,!0);return ac(t).Bt(r).next((t=>{for(const r of t){if(r.collectionId!==e)break;n.push(ua(r.parent))}return n}))}}function ac(t){return ja(t,Ta.store)}const cc={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0};class uc{constructor(t,e,n){this.cacheSizeCollectionThreshold=t,this.percentileToCollect=e,this.maximumSequenceNumbersToCollect=n}static withCacheSize(t){return new uc(t,uc.DEFAULT_COLLECTION_PERCENTILE,uc.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}}function hc(t,e,n){const r=t.store(fa.store),i=t.store(pa.store),s=[],o=IDBKeyRange.only(n.batchId);let a=0;const c=r.jt({range:o},((t,e,n)=>(a++,n.delete())));s.push(c.next((()=>{xr(1===a)})));const u=[];for(const t of n.mutations){const r=pa.key(e,t.key.path,n.batchId);s.push(i.delete(r)),u.push(t.key)}return xa.waitFor(s).next((()=>u))}function lc(t){if(!t)return 0;let e;if(t.document)e=t.document;else if(t.unknownDocument)e=t.unknownDocument;else{if(!t.noDocument)throw Nr();e=t.noDocument}return JSON.stringify(e).length}uc.DEFAULT_COLLECTION_PERCENTILE=10,uc.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,uc.DEFAULT=new uc(41943040,uc.DEFAULT_COLLECTION_PERCENTILE,uc.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),uc.DISABLED=new uc(-1,0,0);class dc{constructor(t,e,n,r){this.userId=t,this.k=e,this.Jt=n,this.referenceDelegate=r,this.Yt={}}static Xt(t,e,n,r){xr(""!==t.uid);const i=t.isAuthenticated()?t.uid:"";return new dc(i,e,n,r)}checkEmpty(t){let e=!0;const n=IDBKeyRange.bound([this.userId,Number.NEGATIVE_INFINITY],[this.userId,Number.POSITIVE_INFINITY]);return pc(t).jt({index:fa.userMutationsIndex,range:n},((t,n,r)=>{e=!1,r.done()})).next((()=>e))}addMutationBatch(t,e,n,r){const i=mc(t),s=pc(t);return s.add({}).next((o=>{xr("number"==typeof o);const a=new qa(o,e,n,r),c=function(t,e,n){const r=n.baseMutations.map((e=>Ko(t.Gt,e))),i=n.mutations.map((e=>Ko(t.Gt,e)));return new fa(e,n.batchId,n.localWriteTime.toMillis(),r,i)}(this.k,this.userId,a),u=[];let h=new so(((t,e)=>Hr(t.canonicalString(),e.canonicalString())));for(const t of r){const e=pa.key(this.userId,t.key.path,o);h=h.add(t.key.path.popLast()),u.push(s.put(c)),u.push(i.put(e,pa.PLACEHOLDER))}return h.forEach((e=>{u.push(this.Jt.addToCollectionParentIndex(t,e))})),t.addOnCommittedListener((()=>{this.Yt[o]=a.keys()})),xa.waitFor(u).next((()=>a))}))}lookupMutationBatch(t,e){return pc(t).get(e).next((t=>t?(xr(t.userId===this.userId),Ja(this.k,t)):null))}Zt(t,e){return this.Yt[e]?xa.resolve(this.Yt[e]):this.lookupMutationBatch(t,e).next((t=>{if(t){const n=t.keys();return this.Yt[e]=n,n}return null}))}getNextMutationBatchAfterBatchId(t,e){const n=e+1,r=IDBKeyRange.lowerBound([this.userId,n]);let i=null;return pc(t).jt({index:fa.userMutationsIndex,range:r},((t,e,r)=>{e.userId===this.userId&&(xr(e.batchId>=n),i=Ja(this.k,e)),r.done()})).next((()=>i))}getHighestUnacknowledgedBatchId(t){const e=IDBKeyRange.upperBound([this.userId,Number.POSITIVE_INFINITY]);let n=-1;return pc(t).jt({index:fa.userMutationsIndex,range:e,reverse:!0},((t,e,r)=>{n=e.batchId,r.done()})).next((()=>n))}getAllMutationBatches(t){const e=IDBKeyRange.bound([this.userId,-1],[this.userId,Number.POSITIVE_INFINITY]);return pc(t).Bt(fa.userMutationsIndex,e).next((t=>t.map((t=>Ja(this.k,t)))))}getAllMutationBatchesAffectingDocumentKey(t,e){const n=pa.prefixForPath(this.userId,e.path),r=IDBKeyRange.lowerBound(n),i=[];return mc(t).jt({range:r},((n,r,s)=>{const[o,a,c]=n,u=ua(a);if(o===this.userId&&e.path.isEqual(u))return pc(t).get(c).next((t=>{if(!t)throw Nr();xr(t.userId===this.userId),i.push(Ja(this.k,t))}));s.done()})).next((()=>i))}getAllMutationBatchesAffectingDocumentKeys(t,e){let n=new so(Hr);const r=[];return e.forEach((e=>{const i=pa.prefixForPath(this.userId,e.path),s=IDBKeyRange.lowerBound(i),o=mc(t).jt({range:s},((t,r,i)=>{const[s,o,a]=t,c=ua(o);s===this.userId&&e.path.isEqual(c)?n=n.add(a):i.done()}));r.push(o)})),xa.waitFor(r).next((()=>this.te(t,n)))}getAllMutationBatchesAffectingQuery(t,e){const n=e.path,r=n.length+1,i=pa.prefixForPath(this.userId,n),s=IDBKeyRange.lowerBound(i);let o=new so(Hr);return mc(t).jt({range:s},((t,e,i)=>{const[s,a,c]=t,u=ua(a);s===this.userId&&n.isPrefixOf(u)?u.length===r&&(o=o.add(c)):i.done()})).next((()=>this.te(t,o)))}te(t,e){const n=[],r=[];return e.forEach((e=>{r.push(pc(t).get(e).next((t=>{if(null===t)throw Nr();xr(t.userId===this.userId),n.push(Ja(this.k,t))})))})),xa.waitFor(r).next((()=>n))}removeMutationBatch(t,e){return hc(t.Wt,this.userId,e).next((n=>(t.addOnCommittedListener((()=>{this.ee(e.batchId)})),xa.forEach(n,(e=>this.referenceDelegate.markPotentiallyOrphaned(t,e))))))}ee(t){delete this.Yt[t]}performConsistencyCheck(t){return this.checkEmpty(t).next((e=>{if(!e)return xa.resolve();const n=IDBKeyRange.lowerBound(pa.prefixForUser(this.userId)),r=[];return mc(t).jt({range:n},((t,e,n)=>{if(t[0]===this.userId){const e=ua(t[1]);r.push(e)}else n.done()})).next((()=>{xr(0===r.length)}))}))}containsKey(t,e){return fc(t,this.userId,e)}ne(t){return gc(t).get(this.userId).next((t=>t||new da(this.userId,-1,"")))}}function fc(t,e,n){const r=pa.prefixForPath(e,n.path),i=r[1],s=IDBKeyRange.lowerBound(r);let o=!1;return mc(t).jt({range:s,Kt:!0},((t,n,r)=>{const[s,a,c]=t;s===e&&a===i&&(o=!0),r.done()})).next((()=>o))}function pc(t){return ja(t,fa.store)}function mc(t){return ja(t,pa.store)}function gc(t){return ja(t,da.store)}class yc{constructor(t){this.se=t}next(){return this.se+=2,this.se}static ie(){return new yc(0)}static re(){return new yc(-1)}}class vc{constructor(t,e){this.referenceDelegate=t,this.k=e}allocateTargetId(t){return this.oe(t).next((e=>{const n=new yc(e.highestTargetId);return e.highestTargetId=n.next(),this.ae(t,e).next((()=>e.highestTargetId))}))}getLastRemoteSnapshotVersion(t){return this.oe(t).next((t=>Jr.fromTimestamp(new Qr(t.lastRemoteSnapshotVersion.seconds,t.lastRemoteSnapshotVersion.nanoseconds))))}getHighestSequenceNumber(t){return this.oe(t).next((t=>t.highestListenSequenceNumber))}setTargetsMetadata(t,e,n){return this.oe(t).next((r=>(r.highestListenSequenceNumber=e,n&&(r.lastRemoteSnapshotVersion=n.toTimestamp()),e>r.highestListenSequenceNumber&&(r.highestListenSequenceNumber=e),this.ae(t,r))))}addTargetData(t,e){return this.ce(t,e).next((()=>this.oe(t).next((n=>(n.targetCount+=1,this.ue(e,n),this.ae(t,n))))))}updateTargetData(t,e){return this.ce(t,e)}removeTargetData(t,e){return this.removeMatchingKeysForTargetId(t,e.targetId).next((()=>bc(t).delete(e.targetId))).next((()=>this.oe(t))).next((e=>(xr(e.targetCount>0),e.targetCount-=1,this.ae(t,e))))}removeTargets(t,e,n){let r=0;const i=[];return bc(t).jt(((s,o)=>{const a=Za(o);a.sequenceNumber<=e&&null===n.get(a.targetId)&&(r++,i.push(this.removeTargetData(t,a)))})).next((()=>xa.waitFor(i))).next((()=>r))}forEachTarget(t,e){return bc(t).jt(((t,n)=>{const r=Za(n);e(r)}))}oe(t){return wc(t).get(Ia.key).next((t=>(xr(null!==t),t)))}ae(t,e){return wc(t).put(Ia.key,e)}ce(t,e){return bc(t).put(Xa(this.k,e))}ue(t,e){let n=!1;return t.targetId>e.highestTargetId&&(e.highestTargetId=t.targetId,n=!0),t.sequenceNumber>e.highestListenSequenceNumber&&(e.highestListenSequenceNumber=t.sequenceNumber,n=!0),n}getTargetCount(t){return this.oe(t).next((t=>t.targetCount))}getTargetData(t,e){const n=Ui(e),r=IDBKeyRange.bound([n,Number.NEGATIVE_INFINITY],[n,Number.POSITIVE_INFINITY]);let i=null;return bc(t).jt({range:r,index:ba.queryTargetsIndexName},((t,n,r)=>{const s=Za(n);Vi(e,s.target)&&(i=s,r.done())})).next((()=>i))}addMatchingKeys(t,e,n){const r=[],i=Ic(t);return e.forEach((e=>{const s=oa(e.path);r.push(i.put(new wa(n,s))),r.push(this.referenceDelegate.addReference(t,n,e))})),xa.waitFor(r)}removeMatchingKeys(t,e,n){const r=Ic(t);return xa.forEach(e,(e=>{const i=oa(e.path);return xa.waitFor([r.delete([n,i]),this.referenceDelegate.removeReference(t,n,e)])}))}removeMatchingKeysForTargetId(t,e){const n=Ic(t),r=IDBKeyRange.bound([e],[e+1],!1,!0);return n.delete(r)}getMatchingKeysForTargetId(t,e){const n=IDBKeyRange.bound([e],[e+1],!1,!0),r=Ic(t);let i=mo();return r.jt({range:n,Kt:!0},((t,e,n)=>{const r=ua(t[1]),s=new vi(r);i=i.add(s)})).next((()=>i))}containsKey(t,e){const n=oa(e.path),r=IDBKeyRange.bound([n],[Yr(n)],!1,!0);let i=0;return Ic(t).jt({index:wa.documentTargetsIndex,Kt:!0,range:r},(([t,e],n,r)=>{0!==t&&(i++,r.done())})).next((()=>i>0))}Et(t,e){return bc(t).get(e).next((t=>t?Za(t):null))}}function bc(t){return ja(t,ba.store)}function wc(t){return ja(t,Ia.store)}function Ic(t){return ja(t,wa.store)}async function Tc(t){if(t.code!==Or.FAILED_PRECONDITION||t.message!==Aa)throw t;Er("LocalStore","Unexpectedly lost primary lease")}function _c([t,e],[n,r]){const i=Hr(t,n);return 0===i?Hr(e,r):i}class Ec{constructor(t){this.he=t,this.buffer=new so(_c),this.le=0}fe(){return++this.le}de(t){const e=[t,this.fe()];if(this.buffer.size<this.he)this.buffer=this.buffer.add(e);else{const t=this.buffer.last();_c(e,t)<0&&(this.buffer=this.buffer.delete(t).add(e))}}get maxValue(){return this.buffer.last()[0]}}class Sc{constructor(t,e){this.garbageCollector=t,this.asyncQueue=e,this.we=!1,this._e=null}start(t){-1!==this.garbageCollector.params.cacheSizeCollectionThreshold&&this.me(t)}stop(){this._e&&(this._e.cancel(),this._e=null)}get started(){return null!==this._e}me(t){const e=this.we?3e5:6e4;Er("LruGarbageCollector",`Garbage collection scheduled in ${e}ms`),this._e=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",e,(async()=>{this._e=null,this.we=!0;try{await t.collectGarbage(this.garbageCollector)}catch(t){Pa(t)?Er("LruGarbageCollector","Ignoring IndexedDB error during garbage collection: ",t):await Tc(t)}await this.me(t)}))}}class kc{constructor(t,e){this.ge=t,this.params=e}calculateTargetCount(t,e){return this.ge.ye(t).next((t=>Math.floor(e/100*t)))}nthSequenceNumber(t,e){if(0===e)return xa.resolve(Kr.I);const n=new Ec(e);return this.ge.forEachTarget(t,(t=>n.de(t.sequenceNumber))).next((()=>this.ge.pe(t,(t=>n.de(t))))).next((()=>n.maxValue))}removeTargets(t,e,n){return this.ge.removeTargets(t,e,n)}removeOrphanedDocuments(t,e){return this.ge.removeOrphanedDocuments(t,e)}collect(t,e){return-1===this.params.cacheSizeCollectionThreshold?(Er("LruGarbageCollector","Garbage collection skipped; disabled"),xa.resolve(cc)):this.getCacheSize(t).next((n=>n<this.params.cacheSizeCollectionThreshold?(Er("LruGarbageCollector",`Garbage collection skipped; Cache size ${n} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),cc):this.Te(t,e)))}getCacheSize(t){return this.ge.getCacheSize(t)}Te(t,e){let n,r,i,s,a,c,u;const h=Date.now();return this.calculateTargetCount(t,this.params.percentileToCollect).next((e=>(e>this.params.maximumSequenceNumbersToCollect?(Er("LruGarbageCollector",`Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${e}`),r=this.params.maximumSequenceNumbersToCollect):r=e,s=Date.now(),this.nthSequenceNumber(t,r)))).next((r=>(n=r,a=Date.now(),this.removeTargets(t,n,e)))).next((e=>(i=e,c=Date.now(),this.removeOrphanedDocuments(t,n)))).next((t=>(u=Date.now(),Tr()<=o.in.DEBUG&&Er("LruGarbageCollector",`LRU Garbage Collection\n\tCounted targets in ${s-h}ms\n\tDetermined least recently used ${r} in `+(a-s)+"ms\n"+`\tRemoved ${i} targets in `+(c-a)+"ms\n"+`\tRemoved ${t} documents in `+(u-c)+"ms\n"+`Total Duration: ${u-h}ms`),xa.resolve({didRun:!0,sequenceNumbersCollected:r,targetsRemoved:i,documentsRemoved:t}))))}}class Ac{constructor(t,e){this.db=t,this.garbageCollector=function(t,e){return new kc(t,e)}(this,e)}ye(t){const e=this.Ee(t);return this.db.getTargetCache().getTargetCount(t).next((t=>e.next((e=>t+e))))}Ee(t){let e=0;return this.pe(t,(t=>{e++})).next((()=>e))}forEachTarget(t,e){return this.db.getTargetCache().forEachTarget(t,e)}pe(t,e){return this.Ie(t,((t,n)=>e(n)))}addReference(t,e,n){return Nc(t,n)}removeReference(t,e,n){return Nc(t,n)}removeTargets(t,e,n){return this.db.getTargetCache().removeTargets(t,e,n)}markPotentiallyOrphaned(t,e){return Nc(t,e)}Ae(t,e){return function(t,e){let n=!1;return gc(t).Qt((r=>fc(t,r,e).next((t=>(t&&(n=!0),xa.resolve(!t)))))).next((()=>n))}(t,e)}removeOrphanedDocuments(t,e){const n=this.db.getRemoteDocumentCache().newChangeBuffer(),r=[];let i=0;return this.Ie(t,((s,o)=>{if(o<=e){const e=this.Ae(t,s).next((e=>{if(!e)return i++,n.getEntry(t,s).next((()=>(n.removeEntry(s),Ic(t).delete([0,oa(s.path)]))))}));r.push(e)}})).next((()=>xa.waitFor(r))).next((()=>n.apply(t))).next((()=>i))}removeTarget(t,e){const n=e.withSequenceNumber(t.currentSequenceNumber);return this.db.getTargetCache().updateTargetData(t,n)}updateLimboDocument(t,e){return Nc(t,e)}Ie(t,e){const n=Ic(t);let r,i=Kr.I;return n.jt({index:wa.documentTargetsIndex},(([t,n],{path:s,sequenceNumber:o})=>{0===t?(i!==Kr.I&&e(new vi(ua(r)),i),i=o,r=s):i=Kr.I})).next((()=>{i!==Kr.I&&e(new vi(ua(r)),i)}))}getCacheSize(t){return this.db.getRemoteDocumentCache().getSize(t)}}function Nc(t,e){return Ic(t).put(function(t,e){return new wa(0,oa(t.path),e)}(e,t.currentSequenceNumber))}class xc{constructor(t,e){this.mapKeyFn=t,this.equalsFn=e,this.inner={}}get(t){const e=this.mapKeyFn(t),n=this.inner[e];if(void 0!==n)for(const[e,r]of n)if(this.equalsFn(e,t))return r}has(t){return void 0!==this.get(t)}set(t,e){const n=this.mapKeyFn(t),r=this.inner[n];if(void 0!==r){for(let n=0;n<r.length;n++)if(this.equalsFn(r[n][0],t))return void(r[n]=[t,e]);r.push([t,e])}else this.inner[n]=[[t,e]]}delete(t){const e=this.mapKeyFn(t),n=this.inner[e];if(void 0===n)return!1;for(let r=0;r<n.length;r++)if(this.equalsFn(n[r][0],t))return 1===n.length?delete this.inner[e]:n.splice(r,1),!0;return!1}forEach(t){Xr(this.inner,((e,n)=>{for(const[e,r]of n)t(e,r)}))}isEmpty(){return ti(this.inner)}}class Cc{constructor(){this.changes=new xc((t=>t.toString()),((t,e)=>t.isEqual(e))),this.changesApplied=!1}getReadTime(t){const e=this.changes.get(t);return e?e.readTime:Jr.min()}addEntry(t,e){this.assertNotApplied(),this.changes.set(t.key,{document:t,readTime:e})}removeEntry(t,e=null){this.assertNotApplied(),this.changes.set(t,{document:Li.newInvalidDocument(t),readTime:e})}getEntry(t,e){this.assertNotApplied();const n=this.changes.get(e);return void 0!==n?xa.resolve(n.document):this.getFromCache(t,e)}getEntries(t,e){return this.getAllFromCache(t,e)}apply(t){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(t)}assertNotApplied(){}}class Dc{constructor(t,e){this.k=t,this.Jt=e}addEntry(t,e,n){return Pc(t).put(Lc(e),n)}removeEntry(t,e){const n=Pc(t),r=Lc(e);return n.delete(r)}updateMetadata(t,e){return this.getMetadata(t).next((n=>(n.byteSize+=e,this.Re(t,n))))}getEntry(t,e){return Pc(t).get(Lc(e)).next((t=>this.be(e,t)))}Pe(t,e){return Pc(t).get(Lc(e)).next((t=>({document:this.be(e,t),size:lc(t)})))}getEntries(t,e){let n=co();return this.ve(t,e,((t,e)=>{const r=this.be(t,e);n=n.insert(t,r)})).next((()=>n))}Ve(t,e){let n=co(),r=new no(vi.comparator);return this.ve(t,e,((t,e)=>{const i=this.be(t,e);n=n.insert(t,i),r=r.insert(t,lc(e))})).next((()=>({documents:n,Se:r})))}ve(t,e,n){if(e.isEmpty())return xa.resolve();const r=IDBKeyRange.bound(e.first().path.toArray(),e.last().path.toArray()),i=e.getIterator();let s=i.getNext();return Pc(t).jt({range:r},((t,e,r)=>{const o=vi.fromSegments(t);for(;s&&vi.comparator(s,o)<0;)n(s,null),s=i.getNext();s&&s.isEqual(o)&&(n(s,e),s=i.hasNext()?i.getNext():null),s?r.Lt(s.path.toArray()):r.done()})).next((()=>{for(;s;)n(s,null),s=i.hasNext()?i.getNext():null}))}getDocumentsMatchingQuery(t,e,n){let r=co();const i=e.path.length+1,s={};if(n.isEqual(Jr.min())){const t=e.path.toArray();s.range=IDBKeyRange.lowerBound(t)}else{const t=e.path.toArray(),r=Ha(n);s.range=IDBKeyRange.lowerBound([t,r],!0),s.index=ya.collectionReadTimeIndex}return Pc(t).jt(s,((t,n,s)=>{if(t.length!==i)return;const o=Wa(this.k,n);e.path.isPrefixOf(o.key.path)?gs(e,o)&&(r=r.insert(o.key,o)):s.done()})).next((()=>r))}newChangeBuffer(t){return new Oc(this,!!t&&t.trackRemovals)}getSize(t){return this.getMetadata(t).next((t=>t.byteSize))}getMetadata(t){return Rc(t).get(va.key).next((t=>(xr(!!t),t)))}Re(t,e){return Rc(t).put(va.key,e)}be(t,e){if(e){const t=Wa(this.k,e);if(!t.isNoDocument()||!t.version.isEqual(Jr.min()))return t}return Li.newInvalidDocument(t)}}class Oc extends Cc{constructor(t,e){super(),this.De=t,this.trackRemovals=e,this.Ce=new xc((t=>t.toString()),((t,e)=>t.isEqual(e)))}applyChanges(t){const e=[];let n=0,r=new so(((t,e)=>Hr(t.canonicalString(),e.canonicalString())));return this.changes.forEach(((i,s)=>{const o=this.Ce.get(i);if(s.document.isValidDocument()){const a=Ga(this.De.k,s.document,this.getReadTime(i));r=r.add(i.path.popLast());const c=lc(a);n+=c-o,e.push(this.De.addEntry(t,i,a))}else if(n-=o,this.trackRemovals){const n=Ga(this.De.k,Li.newNoDocument(i,Jr.min()),this.getReadTime(i));e.push(this.De.addEntry(t,i,n))}else e.push(this.De.removeEntry(t,i))})),r.forEach((n=>{e.push(this.De.Jt.addToCollectionParentIndex(t,n))})),e.push(this.De.updateMetadata(t,n)),xa.waitFor(e)}getFromCache(t,e){return this.De.Pe(t,e).next((t=>(this.Ce.set(e,t.size),t.document)))}getAllFromCache(t,e){return this.De.Ve(t,e).next((({documents:t,Se:e})=>(e.forEach(((t,e)=>{this.Ce.set(t,e)})),t)))}}function Rc(t){return ja(t,va.store)}function Pc(t){return ja(t,ya.store)}function Lc(t){return t.path.toArray()}class Mc{constructor(t){this.k=t}Nt(t,e,n,r){xr(n<r&&n>=0&&r<=11);const i=new Ca("createOrUpgrade",e);n<1&&r>=1&&(function(t){t.createObjectStore(la.store)}(t),function(t){t.createObjectStore(da.store,{keyPath:da.keyPath}),t.createObjectStore(fa.store,{keyPath:fa.keyPath,autoIncrement:!0}).createIndex(fa.userMutationsIndex,fa.userMutationsKeyPath,{unique:!0}),t.createObjectStore(pa.store)}(t),Fc(t),function(t){t.createObjectStore(ya.store)}(t));let s=xa.resolve();return n<3&&r>=3&&(0!==n&&(function(t){t.deleteObjectStore(wa.store),t.deleteObjectStore(ba.store),t.deleteObjectStore(Ia.store)}(t),Fc(t)),s=s.next((()=>function(t){const e=t.store(Ia.store),n=new Ia(0,0,Jr.min().toTimestamp(),0);return e.put(Ia.key,n)}(i)))),n<4&&r>=4&&(0!==n&&(s=s.next((()=>function(t,e){return e.store(fa.store).Bt().next((n=>{t.deleteObjectStore(fa.store),t.createObjectStore(fa.store,{keyPath:fa.keyPath,autoIncrement:!0}).createIndex(fa.userMutationsIndex,fa.userMutationsKeyPath,{unique:!0});const r=e.store(fa.store),i=n.map((t=>r.put(t)));return xa.waitFor(i)}))}(t,i)))),s=s.next((()=>{!function(t){t.createObjectStore(_a.store,{keyPath:_a.keyPath})}(t)}))),n<5&&r>=5&&(s=s.next((()=>this.Ne(i)))),n<6&&r>=6&&(s=s.next((()=>(function(t){t.createObjectStore(va.store)}(t),this.ke(i))))),n<7&&r>=7&&(s=s.next((()=>this.xe(i)))),n<8&&r>=8&&(s=s.next((()=>this.$e(t,i)))),n<9&&r>=9&&(s=s.next((()=>{!function(t){t.objectStoreNames.contains("remoteDocumentChanges")&&t.deleteObjectStore("remoteDocumentChanges")}(t),function(t){const e=t.objectStore(ya.store);e.createIndex(ya.readTimeIndex,ya.readTimeIndexPath,{unique:!1}),e.createIndex(ya.collectionReadTimeIndex,ya.collectionReadTimeIndexPath,{unique:!1})}(e)}))),n<10&&r>=10&&(s=s.next((()=>this.Oe(i)))),n<11&&r>=11&&(s=s.next((()=>{!function(t){t.createObjectStore(Ea.store,{keyPath:Ea.keyPath})}(t),function(t){t.createObjectStore(Sa.store,{keyPath:Sa.keyPath})}(t)}))),s}ke(t){let e=0;return t.store(ya.store).jt(((t,n)=>{e+=lc(n)})).next((()=>{const n=new va(e);return t.store(va.store).put(va.key,n)}))}Ne(t){const e=t.store(da.store),n=t.store(fa.store);return e.Bt().next((e=>xa.forEach(e,(e=>{const r=IDBKeyRange.bound([e.userId,-1],[e.userId,e.lastAcknowledgedBatchId]);return n.Bt(fa.userMutationsIndex,r).next((n=>xa.forEach(n,(n=>{xr(n.userId===e.userId);const r=Ja(this.k,n);return hc(t,e.userId,r).next((()=>{}))}))))}))))}xe(t){const e=t.store(wa.store),n=t.store(ya.store);return t.store(Ia.store).get(Ia.key).next((t=>{const r=[];return n.jt(((n,i)=>{const s=new ni(n),o=function(t){return[0,oa(t)]}(s);r.push(e.get(o).next((n=>n?xa.resolve():(n=>e.put(new wa(0,oa(n),t.highestListenSequenceNumber)))(s))))})).next((()=>xa.waitFor(r)))}))}$e(t,e){t.createObjectStore(Ta.store,{keyPath:Ta.keyPath});const n=e.store(Ta.store),r=new sc,i=t=>{if(r.add(t)){const e=t.lastSegment(),r=t.popLast();return n.put({collectionId:e,parent:oa(r)})}};return e.store(ya.store).jt({Kt:!0},((t,e)=>{const n=new ni(t);return i(n.popLast())})).next((()=>e.store(pa.store).jt({Kt:!0},(([t,e,n],r)=>{const s=ua(e);return i(s.popLast())}))))}Oe(t){const e=t.store(ba.store);return e.jt(((t,n)=>{const r=Za(n),i=Xa(this.k,r);return e.put(i)}))}}function Fc(t){t.createObjectStore(wa.store,{keyPath:wa.keyPath}).createIndex(wa.documentTargetsIndex,wa.documentTargetsKeyPath,{unique:!0}),t.createObjectStore(ba.store,{keyPath:ba.keyPath}).createIndex(ba.queryTargetsIndexName,ba.queryTargetsKeyPath,{unique:!0}),t.createObjectStore(Ia.store)}const Uc="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.";class Vc{constructor(t,e,n,r,i,s,o,a,c,u){if(this.allowTabSynchronization=t,this.persistenceKey=e,this.clientId=n,this.Fe=i,this.window=s,this.document=o,this.Me=c,this.Le=u,this.Be=null,this.Ue=!1,this.isPrimary=!1,this.networkEnabled=!0,this.qe=null,this.inForeground=!1,this.Ke=null,this.je=null,this.Qe=Number.NEGATIVE_INFINITY,this.We=t=>Promise.resolve(),!Vc.Pt())throw new Rr(Or.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");this.referenceDelegate=new Ac(this,r),this.Ge=e+"main",this.k=new Ka(a),this.ze=new Da(this.Ge,11,new Mc(this.k)),this.He=new vc(this.referenceDelegate,this.k),this.Jt=new oc,this.Je=function(t,e){return new Dc(t,e)}(this.k,this.Jt),this.Ye=new ec,this.window&&this.window.localStorage?this.Xe=this.window.localStorage:(this.Xe=null,!1===u&&Sr("IndexedDbPersistence","LocalStorage is unavailable. As a result, persistence may not work reliably. In particular enablePersistence() could fail immediately after refreshing the page."))}start(){return this.Ze().then((()=>{if(!this.isPrimary&&!this.allowTabSynchronization)throw new Rr(Or.FAILED_PRECONDITION,Uc);return this.tn(),this.en(),this.nn(),this.runTransaction("getHighestListenSequenceNumber","readonly",(t=>this.He.getHighestSequenceNumber(t)))})).then((t=>{this.Be=new Kr(t,this.Me)})).then((()=>{this.Ue=!0})).catch((t=>(this.ze&&this.ze.close(),Promise.reject(t))))}sn(t){return this.We=async e=>{if(this.started)return t(e)},t(this.isPrimary)}setDatabaseDeletedListener(t){this.ze.xt((async e=>{null===e.newVersion&&await t()}))}setNetworkEnabled(t){this.networkEnabled!==t&&(this.networkEnabled=t,this.Fe.enqueueAndForget((async()=>{this.started&&await this.Ze()})))}Ze(){return this.runTransaction("updateClientMetadataAndTryBecomePrimary","readwrite",(t=>qc(t).put(new _a(this.clientId,Date.now(),this.networkEnabled,this.inForeground)).next((()=>{if(this.isPrimary)return this.rn(t).next((t=>{t||(this.isPrimary=!1,this.Fe.enqueueRetryable((()=>this.We(!1))))}))})).next((()=>this.on(t))).next((e=>this.isPrimary&&!e?this.an(t).next((()=>!1)):!!e&&this.cn(t).next((()=>!0)))))).catch((t=>{if(Pa(t))return Er("IndexedDbPersistence","Failed to extend owner lease: ",t),this.isPrimary;if(!this.allowTabSynchronization)throw t;return Er("IndexedDbPersistence","Releasing owner lease after error during lease refresh",t),!1})).then((t=>{this.isPrimary!==t&&this.Fe.enqueueRetryable((()=>this.We(t))),this.isPrimary=t}))}rn(t){return jc(t).get(la.key).next((t=>xa.resolve(this.un(t))))}hn(t){return qc(t).delete(this.clientId)}async ln(){if(this.isPrimary&&!this.fn(this.Qe,18e5)){this.Qe=Date.now();const t=await this.runTransaction("maybeGarbageCollectMultiClientState","readwrite-primary",(t=>{const e=ja(t,_a.store);return e.Bt().next((t=>{const n=this.dn(t,18e5),r=t.filter((t=>-1===n.indexOf(t)));return xa.forEach(r,(t=>e.delete(t.clientId))).next((()=>r))}))})).catch((()=>[]));if(this.Xe)for(const e of t)this.Xe.removeItem(this.wn(e.clientId))}}nn(){this.je=this.Fe.enqueueAfterDelay("client_metadata_refresh",4e3,(()=>this.Ze().then((()=>this.ln())).then((()=>this.nn()))))}un(t){return!!t&&t.ownerId===this.clientId}on(t){return this.Le?xa.resolve(!0):jc(t).get(la.key).next((e=>{if(null!==e&&this.fn(e.leaseTimestampMs,5e3)&&!this._n(e.ownerId)){if(this.un(e)&&this.networkEnabled)return!0;if(!this.un(e)){if(!e.allowTabSynchronization)throw new Rr(Or.FAILED_PRECONDITION,Uc);return!1}}return!(!this.networkEnabled||!this.inForeground)||qc(t).Bt().next((t=>void 0===this.dn(t,5e3).find((t=>{if(this.clientId!==t.clientId){const e=!this.networkEnabled&&t.networkEnabled,n=!this.inForeground&&t.inForeground,r=this.networkEnabled===t.networkEnabled;if(e||n&&r)return!0}return!1}))))})).next((t=>(this.isPrimary!==t&&Er("IndexedDbPersistence",`Client ${t?"is":"is not"} eligible for a primary lease.`),t)))}async shutdown(){this.Ue=!1,this.mn(),this.je&&(this.je.cancel(),this.je=null),this.gn(),this.yn(),await this.ze.runTransaction("shutdown","readwrite",[la.store,_a.store],(t=>{const e=new Va(t,Kr.I);return this.an(e).next((()=>this.hn(e)))})),this.ze.close(),this.pn()}dn(t,e){return t.filter((t=>this.fn(t.updateTimeMs,e)&&!this._n(t.clientId)))}Tn(){return this.runTransaction("getActiveClients","readonly",(t=>qc(t).Bt().next((t=>this.dn(t,18e5).map((t=>t.clientId))))))}get started(){return this.Ue}getMutationQueue(t){return dc.Xt(t,this.k,this.Jt,this.referenceDelegate)}getTargetCache(){return this.He}getRemoteDocumentCache(){return this.Je}getIndexManager(){return this.Jt}getBundleCache(){return this.Ye}runTransaction(t,e,n){Er("IndexedDbPersistence","Starting transaction:",t);const r="readonly"===e?"readonly":"readwrite";let i;return this.ze.runTransaction(t,r,ka,(r=>(i=new Va(r,this.Be?this.Be.next():Kr.I),"readwrite-primary"===e?this.rn(i).next((t=>!!t||this.on(i))).next((e=>{if(!e)throw Sr(`Failed to obtain primary lease for action '${t}'.`),this.isPrimary=!1,this.Fe.enqueueRetryable((()=>this.We(!1))),new Rr(Or.FAILED_PRECONDITION,Aa);return n(i)})).next((t=>this.cn(i).next((()=>t)))):this.En(i).next((()=>n(i)))))).then((t=>(i.raiseOnCommittedEvent(),t)))}En(t){return jc(t).get(la.key).next((t=>{if(null!==t&&this.fn(t.leaseTimestampMs,5e3)&&!this._n(t.ownerId)&&!this.un(t)&&!(this.Le||this.allowTabSynchronization&&t.allowTabSynchronization))throw new Rr(Or.FAILED_PRECONDITION,Uc)}))}cn(t){const e=new la(this.clientId,this.allowTabSynchronization,Date.now());return jc(t).put(la.key,e)}static Pt(){return Da.Pt()}an(t){const e=jc(t);return e.get(la.key).next((t=>this.un(t)?(Er("IndexedDbPersistence","Releasing primary lease."),e.delete(la.key)):xa.resolve()))}fn(t,e){const n=Date.now();return!(t<n-e||t>n&&(Sr(`Detected an update time that is in the future: ${t} > ${n}`),1))}tn(){null!==this.document&&"function"==typeof this.document.addEventListener&&(this.Ke=()=>{this.Fe.enqueueAndForget((()=>(this.inForeground="visible"===this.document.visibilityState,this.Ze())))},this.document.addEventListener("visibilitychange",this.Ke),this.inForeground="visible"===this.document.visibilityState)}gn(){this.Ke&&(this.document.removeEventListener("visibilitychange",this.Ke),this.Ke=null)}en(){var t;"function"==typeof(null===(t=this.window)||void 0===t?void 0:t.addEventListener)&&(this.qe=()=>{this.mn(),(0,a.G6)()&&navigator.appVersion.match(/Version\/1[45]/)&&this.Fe.enterRestrictedMode(!0),this.Fe.enqueueAndForget((()=>this.shutdown()))},this.window.addEventListener("pagehide",this.qe))}yn(){this.qe&&(this.window.removeEventListener("pagehide",this.qe),this.qe=null)}_n(t){var e;try{const n=null!==(null===(e=this.Xe)||void 0===e?void 0:e.getItem(this.wn(t)));return Er("IndexedDbPersistence",`Client '${t}' ${n?"is":"is not"} zombied in LocalStorage`),n}catch(t){return Sr("IndexedDbPersistence","Failed to get zombied client id.",t),!1}}mn(){if(this.Xe)try{this.Xe.setItem(this.wn(this.clientId),String(Date.now()))}catch(t){Sr("Failed to set zombie client id.",t)}}pn(){if(this.Xe)try{this.Xe.removeItem(this.wn(this.clientId))}catch(t){}}wn(t){return`firestore_zombie_${this.persistenceKey}_${t}`}}function jc(t){return ja(t,la.store)}function qc(t){return ja(t,_a.store)}function Bc(t,e){let n=t.projectId;return t.isDefaultDatabase||(n+="."+t.database),"firestore/"+e+"/"+n+"/"}class zc{constructor(t,e){this.progress=t,this.In=e}}class Kc{constructor(t,e,n){this.Je=t,this.An=e,this.Jt=n}Rn(t,e){return this.An.getAllMutationBatchesAffectingDocumentKey(t,e).next((n=>this.bn(t,e,n)))}bn(t,e,n){return this.Je.getEntry(t,e).next((t=>{for(const e of n)e.applyToLocalView(t);return t}))}Pn(t,e){t.forEach(((t,n)=>{for(const t of e)t.applyToLocalView(n)}))}vn(t,e){return this.Je.getEntries(t,e).next((e=>this.Vn(t,e).next((()=>e))))}Vn(t,e){return this.An.getAllMutationBatchesAffectingDocumentKeys(t,e).next((t=>this.Pn(e,t)))}getDocumentsMatchingQuery(t,e,n){return function(t){return vi.isDocumentKey(t.path)&&null===t.collectionGroup&&0===t.filters.length}(e)?this.Sn(t,e.path):us(e)?this.Dn(t,e,n):this.Cn(t,e,n)}Sn(t,e){return this.Rn(t,new vi(e)).next((t=>{let e=ho();return t.isFoundDocument()&&(e=e.insert(t.key,t)),e}))}Dn(t,e,n){const r=e.collectionGroup;let i=ho();return this.Jt.getCollectionParents(t,r).next((s=>xa.forEach(s,(s=>{const o=function(t,e){return new ns(e,null,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,t.startAt,t.endAt)}(e,s.child(r));return this.Cn(t,o,n).next((t=>{t.forEach(((t,e)=>{i=i.insert(t,e)}))}))})).next((()=>i))))}Cn(t,e,n){let r,i;return this.Je.getDocumentsMatchingQuery(t,e,n).next((n=>(r=n,this.An.getAllMutationBatchesAffectingQuery(t,e)))).next((e=>(i=e,this.Nn(t,i,r).next((t=>{r=t;for(const t of i)for(const e of t.mutations){const n=e.key;let i=r.get(n);null==i&&(i=Li.newInvalidDocument(n),r=r.insert(n,i)),js(e,i,t.localWriteTime),i.isFoundDocument()||(r=r.remove(n))}}))))).next((()=>(r.forEach(((t,n)=>{gs(e,n)||(r=r.remove(t))})),r)))}Nn(t,e,n){let r=mo();for(const t of e)for(const e of t.mutations)e instanceof Ws&&null===n.get(e.key)&&(r=r.add(e.key));let i=n;return this.Je.getEntries(t,r).next((t=>(t.forEach(((t,e)=>{e.isFoundDocument()&&(i=i.insert(t,e))})),i)))}}class Wc{constructor(t,e,n,r){this.targetId=t,this.fromCache=e,this.kn=n,this.xn=r}static $n(t,e){let n=mo(),r=mo();for(const t of e.docChanges)switch(t.type){case 0:n=n.add(t.doc.key);break;case 1:r=r.add(t.doc.key)}return new Wc(t,e.fromCache,n,r)}}class Gc{On(t){this.Fn=t}getDocumentsMatchingQuery(t,e,n,r){return function(t){return 0===t.filters.length&&null===t.limit&&null==t.startAt&&null==t.endAt&&(0===t.explicitOrderBy.length||1===t.explicitOrderBy.length&&t.explicitOrderBy[0].field.isKeyField())}(e)||n.isEqual(Jr.min())?this.Mn(t,e):this.Fn.vn(t,r).next((i=>{const s=this.Ln(e,i);return(ss(e)||os(e))&&this.Bn(e.limitType,s,r,n)?this.Mn(t,e):(Tr()<=o.in.DEBUG&&Er("QueryEngine","Re-using previous result from %s to execute query: %s",n.toString(),ms(e)),this.Fn.getDocumentsMatchingQuery(t,e,n).next((t=>(s.forEach((e=>{t=t.insert(e.key,e)})),t))))}))}Ln(t,e){let n=new so(ys(t));return e.forEach(((e,r)=>{gs(t,r)&&(n=n.add(r))})),n}Bn(t,e,n,r){if(n.size!==e.size)return!0;const i="F"===t?e.last():e.first();return!!i&&(i.hasPendingWrites||i.version.compareTo(r)>0)}Mn(t,e){return Tr()<=o.in.DEBUG&&Er("QueryEngine","Using full collection scan to execute query:",ms(e)),this.Fn.getDocumentsMatchingQuery(t,e,Jr.min())}}class Hc{constructor(t,e,n,r){this.persistence=t,this.Un=e,this.k=r,this.qn=new no(Hr),this.Kn=new xc((t=>Ui(t)),Vi),this.jn=Jr.min(),this.An=t.getMutationQueue(n),this.Qn=t.getRemoteDocumentCache(),this.He=t.getTargetCache(),this.Wn=new Kc(this.Qn,this.An,this.persistence.getIndexManager()),this.Ye=t.getBundleCache(),this.Un.On(this.Wn)}collectGarbage(t){return this.persistence.runTransaction("Collect garbage","readwrite-primary",(e=>t.collect(e,this.qn)))}}function $c(t,e,n,r){return new Hc(t,e,n,r)}async function Yc(t,e){const n=Dr(t);let r=n.An,i=n.Wn;const s=await n.persistence.runTransaction("Handle user change","readonly",(t=>{let s;return n.An.getAllMutationBatches(t).next((o=>(s=o,r=n.persistence.getMutationQueue(e),i=new Kc(n.Qn,r,n.persistence.getIndexManager()),r.getAllMutationBatches(t)))).next((e=>{const n=[],r=[];let o=mo();for(const t of s){n.push(t.batchId);for(const e of t.mutations)o=o.add(e.key)}for(const t of e){r.push(t.batchId);for(const e of t.mutations)o=o.add(e.key)}return i.vn(t,o).next((t=>({Gn:t,removedBatchIds:n,addedBatchIds:r})))}))}));return n.An=r,n.Wn=i,n.Un.On(n.Wn),s}function Qc(t){const e=Dr(t);return e.persistence.runTransaction("Get last remote snapshot version","readonly",(t=>e.He.getLastRemoteSnapshotVersion(t)))}function Jc(t,e,n,r,i){let s=mo();return n.forEach((t=>s=s.add(t))),e.getEntries(t,s).next((t=>{let s=co();return n.forEach(((n,o)=>{const a=t.get(n),c=(null==i?void 0:i.get(n))||r;o.isNoDocument()&&o.version.isEqual(Jr.min())?(e.removeEntry(n,c),s=s.insert(n,o)):!a.isValidDocument()||o.version.compareTo(a.version)>0||0===o.version.compareTo(a.version)&&a.hasPendingWrites?(e.addEntry(o,c),s=s.insert(n,o)):Er("LocalStore","Ignoring outdated watch update for ",n,". Current version:",a.version," Watch version:",o.version)})),s}))}function Zc(t,e){const n=Dr(t);return n.persistence.runTransaction("Get next mutation batch","readonly",(t=>(void 0===e&&(e=-1),n.An.getNextMutationBatchAfterBatchId(t,e))))}function Xc(t,e){const n=Dr(t);return n.persistence.runTransaction("Allocate target","readwrite",(t=>{let r;return n.He.getTargetData(t,e).next((i=>i?(r=i,xa.resolve(r)):n.He.allocateTargetId(t).next((i=>(r=new za(e,i,0,t.currentSequenceNumber),n.He.addTargetData(t,r).next((()=>r)))))))})).then((t=>{const r=n.qn.get(t.targetId);return(null===r||t.snapshotVersion.compareTo(r.snapshotVersion)>0)&&(n.qn=n.qn.insert(t.targetId,t),n.Kn.set(e,t.targetId)),t}))}async function tu(t,e,n){const r=Dr(t),i=r.qn.get(e),s=n?"readwrite":"readwrite-primary";try{n||await r.persistence.runTransaction("Release target",s,(t=>r.persistence.referenceDelegate.removeTarget(t,i)))}catch(t){if(!Pa(t))throw t;Er("LocalStore",`Failed to update sequence numbers for target ${e}: ${t}`)}r.qn=r.qn.remove(e),r.Kn.delete(i.target)}function eu(t,e,n){const r=Dr(t);let i=Jr.min(),s=mo();return r.persistence.runTransaction("Execute query","readonly",(t=>function(t,e,n){const r=Dr(t),i=r.Kn.get(n);return void 0!==i?xa.resolve(r.qn.get(i)):r.He.getTargetData(e,n)}(r,t,ls(e)).next((e=>{if(e)return i=e.lastLimboFreeSnapshotVersion,r.He.getMatchingKeysForTargetId(t,e.targetId).next((t=>{s=t}))})).next((()=>r.Un.getDocumentsMatchingQuery(t,e,n?i:Jr.min(),n?s:mo()))).next((t=>({documents:t,zn:s})))))}function nu(t,e){const n=Dr(t),r=Dr(n.He),i=n.qn.get(e);return i?Promise.resolve(i.target):n.persistence.runTransaction("Get target data","readonly",(t=>r.Et(t,e).next((t=>t?t.target:null))))}function ru(t){const e=Dr(t);return e.persistence.runTransaction("Get new document changes","readonly",(t=>function(t,e,n){const r=Dr(t);let i=co(),s=Ha(n);const o=Pc(e),a=IDBKeyRange.lowerBound(s,!0);return o.jt({index:ya.readTimeIndex,range:a},((t,e)=>{const n=Wa(r.k,e);i=i.insert(n.key,n),s=e.readTime})).next((()=>({In:i,readTime:$a(s)})))}(e.Qn,t,e.jn))).then((({In:t,readTime:n})=>(e.jn=n,t)))}async function iu(t,e,n=mo()){const r=await Xc(t,ls(tc(e.bundledQuery))),i=Dr(t);return i.persistence.runTransaction("Save named query","readwrite",(t=>{const s=Ro(e.readTime);if(r.snapshotVersion.compareTo(s)>=0)return i.Ye.saveNamedQuery(t,e);const o=r.withResumeToken(ai.EMPTY_BYTE_STRING,s);return i.qn=i.qn.insert(o.targetId,o),i.He.updateTargetData(t,o).next((()=>i.He.removeMatchingKeysForTargetId(t,r.targetId))).next((()=>i.He.addMatchingKeys(t,n,r.targetId))).next((()=>i.Ye.saveNamedQuery(t,e)))}))}class su{constructor(t){this.k=t,this.Xn=new Map,this.Zn=new Map}getBundleMetadata(t,e){return xa.resolve(this.Xn.get(e))}saveBundleMetadata(t,e){var n;return this.Xn.set(e.id,{id:(n=e).id,version:n.version,createTime:Ro(n.createTime)}),xa.resolve()}getNamedQuery(t,e){return xa.resolve(this.Zn.get(e))}saveNamedQuery(t,e){return this.Zn.set(e.name,function(t){return{name:t.name,query:tc(t.bundledQuery),readTime:Ro(t.readTime)}}(e)),xa.resolve()}}class ou{constructor(){this.ts=new so(au.es),this.ns=new so(au.ss)}isEmpty(){return this.ts.isEmpty()}addReference(t,e){const n=new au(t,e);this.ts=this.ts.add(n),this.ns=this.ns.add(n)}rs(t,e){t.forEach((t=>this.addReference(t,e)))}removeReference(t,e){this.os(new au(t,e))}cs(t,e){t.forEach((t=>this.removeReference(t,e)))}us(t){const e=new vi(new ni([])),n=new au(e,t),r=new au(e,t+1),i=[];return this.ns.forEachInRange([n,r],(t=>{this.os(t),i.push(t.key)})),i}hs(){this.ts.forEach((t=>this.os(t)))}os(t){this.ts=this.ts.delete(t),this.ns=this.ns.delete(t)}ls(t){const e=new vi(new ni([])),n=new au(e,t),r=new au(e,t+1);let i=mo();return this.ns.forEachInRange([n,r],(t=>{i=i.add(t.key)})),i}containsKey(t){const e=new au(t,0),n=this.ts.firstAfterOrEqual(e);return null!==n&&t.isEqual(n.key)}}class au{constructor(t,e){this.key=t,this.fs=e}static es(t,e){return vi.comparator(t.key,e.key)||Hr(t.fs,e.fs)}static ss(t,e){return Hr(t.fs,e.fs)||vi.comparator(t.key,e.key)}}class cu{constructor(t,e){this.Jt=t,this.referenceDelegate=e,this.An=[],this.ds=1,this.ws=new so(au.es)}checkEmpty(t){return xa.resolve(0===this.An.length)}addMutationBatch(t,e,n,r){const i=this.ds;this.ds++,this.An.length>0&&this.An[this.An.length-1];const s=new qa(i,e,n,r);this.An.push(s);for(const e of r)this.ws=this.ws.add(new au(e.key,i)),this.Jt.addToCollectionParentIndex(t,e.key.path.popLast());return xa.resolve(s)}lookupMutationBatch(t,e){return xa.resolve(this._s(e))}getNextMutationBatchAfterBatchId(t,e){const n=e+1,r=this.gs(n),i=r<0?0:r;return xa.resolve(this.An.length>i?this.An[i]:null)}getHighestUnacknowledgedBatchId(){return xa.resolve(0===this.An.length?-1:this.ds-1)}getAllMutationBatches(t){return xa.resolve(this.An.slice())}getAllMutationBatchesAffectingDocumentKey(t,e){const n=new au(e,0),r=new au(e,Number.POSITIVE_INFINITY),i=[];return this.ws.forEachInRange([n,r],(t=>{const e=this._s(t.fs);i.push(e)})),xa.resolve(i)}getAllMutationBatchesAffectingDocumentKeys(t,e){let n=new so(Hr);return e.forEach((t=>{const e=new au(t,0),r=new au(t,Number.POSITIVE_INFINITY);this.ws.forEachInRange([e,r],(t=>{n=n.add(t.fs)}))})),xa.resolve(this.ys(n))}getAllMutationBatchesAffectingQuery(t,e){const n=e.path,r=n.length+1;let i=n;vi.isDocumentKey(i)||(i=i.child(""));const s=new au(new vi(i),0);let o=new so(Hr);return this.ws.forEachWhile((t=>{const e=t.key.path;return!!n.isPrefixOf(e)&&(e.length===r&&(o=o.add(t.fs)),!0)}),s),xa.resolve(this.ys(o))}ys(t){const e=[];return t.forEach((t=>{const n=this._s(t);null!==n&&e.push(n)})),e}removeMutationBatch(t,e){xr(0===this.ps(e.batchId,"removed")),this.An.shift();let n=this.ws;return xa.forEach(e.mutations,(r=>{const i=new au(r.key,e.batchId);return n=n.delete(i),this.referenceDelegate.markPotentiallyOrphaned(t,r.key)})).next((()=>{this.ws=n}))}ee(t){}containsKey(t,e){const n=new au(e,0),r=this.ws.firstAfterOrEqual(n);return xa.resolve(e.isEqual(r&&r.key))}performConsistencyCheck(t){return this.An.length,xa.resolve()}ps(t,e){return this.gs(t)}gs(t){return 0===this.An.length?0:t-this.An[0].batchId}_s(t){const e=this.gs(t);return e<0||e>=this.An.length?null:this.An[e]}}class uu{constructor(t,e){this.Jt=t,this.Ts=e,this.docs=new no(vi.comparator),this.size=0}addEntry(t,e,n){const r=e.key,i=this.docs.get(r),s=i?i.size:0,o=this.Ts(e);return this.docs=this.docs.insert(r,{document:e.mutableCopy(),size:o,readTime:n}),this.size+=o-s,this.Jt.addToCollectionParentIndex(t,r.path.popLast())}removeEntry(t){const e=this.docs.get(t);e&&(this.docs=this.docs.remove(t),this.size-=e.size)}getEntry(t,e){const n=this.docs.get(e);return xa.resolve(n?n.document.mutableCopy():Li.newInvalidDocument(e))}getEntries(t,e){let n=co();return e.forEach((t=>{const e=this.docs.get(t);n=n.insert(t,e?e.document.mutableCopy():Li.newInvalidDocument(t))})),xa.resolve(n)}getDocumentsMatchingQuery(t,e,n){let r=co();const i=new vi(e.path.child("")),s=this.docs.getIteratorFrom(i);for(;s.hasNext();){const{key:t,value:{document:i,readTime:o}}=s.getNext();if(!e.path.isPrefixOf(t.path))break;o.compareTo(n)<=0||gs(e,i)&&(r=r.insert(i.key,i.mutableCopy()))}return xa.resolve(r)}Es(t,e){return xa.forEach(this.docs,(t=>e(t)))}newChangeBuffer(t){return new hu(this)}getSize(t){return xa.resolve(this.size)}}class hu extends Cc{constructor(t){super(),this.De=t}applyChanges(t){const e=[];return this.changes.forEach(((n,r)=>{r.document.isValidDocument()?e.push(this.De.addEntry(t,r.document,this.getReadTime(n))):this.De.removeEntry(n)})),xa.waitFor(e)}getFromCache(t,e){return this.De.getEntry(t,e)}getAllFromCache(t,e){return this.De.getEntries(t,e)}}class lu{constructor(t){this.persistence=t,this.Is=new xc((t=>Ui(t)),Vi),this.lastRemoteSnapshotVersion=Jr.min(),this.highestTargetId=0,this.As=0,this.Rs=new ou,this.targetCount=0,this.bs=yc.ie()}forEachTarget(t,e){return this.Is.forEach(((t,n)=>e(n))),xa.resolve()}getLastRemoteSnapshotVersion(t){return xa.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(t){return xa.resolve(this.As)}allocateTargetId(t){return this.highestTargetId=this.bs.next(),xa.resolve(this.highestTargetId)}setTargetsMetadata(t,e,n){return n&&(this.lastRemoteSnapshotVersion=n),e>this.As&&(this.As=e),xa.resolve()}ce(t){this.Is.set(t.target,t);const e=t.targetId;e>this.highestTargetId&&(this.bs=new yc(e),this.highestTargetId=e),t.sequenceNumber>this.As&&(this.As=t.sequenceNumber)}addTargetData(t,e){return this.ce(e),this.targetCount+=1,xa.resolve()}updateTargetData(t,e){return this.ce(e),xa.resolve()}removeTargetData(t,e){return this.Is.delete(e.target),this.Rs.us(e.targetId),this.targetCount-=1,xa.resolve()}removeTargets(t,e,n){let r=0;const i=[];return this.Is.forEach(((s,o)=>{o.sequenceNumber<=e&&null===n.get(o.targetId)&&(this.Is.delete(s),i.push(this.removeMatchingKeysForTargetId(t,o.targetId)),r++)})),xa.waitFor(i).next((()=>r))}getTargetCount(t){return xa.resolve(this.targetCount)}getTargetData(t,e){const n=this.Is.get(e)||null;return xa.resolve(n)}addMatchingKeys(t,e,n){return this.Rs.rs(e,n),xa.resolve()}removeMatchingKeys(t,e,n){this.Rs.cs(e,n);const r=this.persistence.referenceDelegate,i=[];return r&&e.forEach((e=>{i.push(r.markPotentiallyOrphaned(t,e))})),xa.waitFor(i)}removeMatchingKeysForTargetId(t,e){return this.Rs.us(e),xa.resolve()}getMatchingKeysForTargetId(t,e){const n=this.Rs.ls(e);return xa.resolve(n)}containsKey(t,e){return xa.resolve(this.Rs.containsKey(e))}}class du{constructor(t,e){this.Ps={},this.Be=new Kr(0),this.Ue=!1,this.Ue=!0,this.referenceDelegate=t(this),this.He=new lu(this),this.Jt=new ic,this.Je=function(t,e){return new uu(t,e)}(this.Jt,(t=>this.referenceDelegate.vs(t))),this.k=new Ka(e),this.Ye=new su(this.k)}start(){return Promise.resolve()}shutdown(){return this.Ue=!1,Promise.resolve()}get started(){return this.Ue}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(){return this.Jt}getMutationQueue(t){let e=this.Ps[t.toKey()];return e||(e=new cu(this.Jt,this.referenceDelegate),this.Ps[t.toKey()]=e),e}getTargetCache(){return this.He}getRemoteDocumentCache(){return this.Je}getBundleCache(){return this.Ye}runTransaction(t,e,n){Er("MemoryPersistence","Starting transaction:",t);const r=new fu(this.Be.next());return this.referenceDelegate.Vs(),n(r).next((t=>this.referenceDelegate.Ss(r).next((()=>t)))).toPromise().then((t=>(r.raiseOnCommittedEvent(),t)))}Ds(t,e){return xa.or(Object.values(this.Ps).map((n=>()=>n.containsKey(t,e))))}}class fu extends Na{constructor(t){super(),this.currentSequenceNumber=t}}class pu{constructor(t){this.persistence=t,this.Cs=new ou,this.Ns=null}static ks(t){return new pu(t)}get xs(){if(this.Ns)return this.Ns;throw Nr()}addReference(t,e,n){return this.Cs.addReference(n,e),this.xs.delete(n.toString()),xa.resolve()}removeReference(t,e,n){return this.Cs.removeReference(n,e),this.xs.add(n.toString()),xa.resolve()}markPotentiallyOrphaned(t,e){return this.xs.add(e.toString()),xa.resolve()}removeTarget(t,e){this.Cs.us(e.targetId).forEach((t=>this.xs.add(t.toString())));const n=this.persistence.getTargetCache();return n.getMatchingKeysForTargetId(t,e.targetId).next((t=>{t.forEach((t=>this.xs.add(t.toString())))})).next((()=>n.removeTargetData(t,e)))}Vs(){this.Ns=new Set}Ss(t){const e=this.persistence.getRemoteDocumentCache().newChangeBuffer();return xa.forEach(this.xs,(n=>{const r=vi.fromPath(n);return this.$s(t,r).next((t=>{t||e.removeEntry(r)}))})).next((()=>(this.Ns=null,e.apply(t))))}updateLimboDocument(t,e){return this.$s(t,e).next((t=>{t?this.xs.delete(e.toString()):this.xs.add(e.toString())}))}vs(t){return 0}$s(t,e){return xa.or([()=>xa.resolve(this.Cs.containsKey(e)),()=>this.persistence.getTargetCache().containsKey(t,e),()=>this.persistence.Ds(t,e)])}}function mu(t,e){return`firestore_clients_${t}_${e}`}function gu(t,e,n){let r=`firestore_mutations_${t}_${n}`;return e.isAuthenticated()&&(r+=`_${e.uid}`),r}function yu(t,e){return`firestore_targets_${t}_${e}`}class vu{constructor(t,e,n,r){this.user=t,this.batchId=e,this.state=n,this.error=r}static Os(t,e,n){const r=JSON.parse(n);let i,s="object"==typeof r&&-1!==["pending","acknowledged","rejected"].indexOf(r.state)&&(void 0===r.error||"object"==typeof r.error);return s&&r.error&&(s="string"==typeof r.error.message&&"string"==typeof r.error.code,s&&(i=new Rr(r.error.code,r.error.message))),s?new vu(t,e,r.state,i):(Sr("SharedClientState",`Failed to parse mutation state for ID '${e}': ${n}`),null)}Fs(){const t={state:this.state,updateTimeMs:Date.now()};return this.error&&(t.error={code:this.error.code,message:this.error.message}),JSON.stringify(t)}}class bu{constructor(t,e,n){this.targetId=t,this.state=e,this.error=n}static Os(t,e){const n=JSON.parse(e);let r,i="object"==typeof n&&-1!==["not-current","current","rejected"].indexOf(n.state)&&(void 0===n.error||"object"==typeof n.error);return i&&n.error&&(i="string"==typeof n.error.message&&"string"==typeof n.error.code,i&&(r=new Rr(n.error.code,n.error.message))),i?new bu(t,n.state,r):(Sr("SharedClientState",`Failed to parse target state for ID '${t}': ${e}`),null)}Fs(){const t={state:this.state,updateTimeMs:Date.now()};return this.error&&(t.error={code:this.error.code,message:this.error.message}),JSON.stringify(t)}}class wu{constructor(t,e){this.clientId=t,this.activeTargetIds=e}static Os(t,e){const n=JSON.parse(e);let r="object"==typeof n&&n.activeTargetIds instanceof Array,i=yo();for(let t=0;r&&t<n.activeTargetIds.length;++t)r=yi(n.activeTargetIds[t]),i=i.add(n.activeTargetIds[t]);return r?new wu(t,i):(Sr("SharedClientState",`Failed to parse client data for instance '${t}': ${e}`),null)}}class Iu{constructor(t,e){this.clientId=t,this.onlineState=e}static Os(t){const e=JSON.parse(t);return"object"==typeof e&&-1!==["Unknown","Online","Offline"].indexOf(e.onlineState)&&"string"==typeof e.clientId?new Iu(e.clientId,e.onlineState):(Sr("SharedClientState",`Failed to parse online state: ${t}`),null)}}class Tu{constructor(){this.activeTargetIds=yo()}Ms(t){this.activeTargetIds=this.activeTargetIds.add(t)}Ls(t){this.activeTargetIds=this.activeTargetIds.delete(t)}Fs(){const t={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(t)}}class _u{constructor(t,e,n,r,i){this.window=t,this.Fe=e,this.persistenceKey=n,this.Bs=r,this.syncEngine=null,this.onlineStateHandler=null,this.sequenceNumberHandler=null,this.Us=this.qs.bind(this),this.Ks=new no(Hr),this.started=!1,this.js=[];const s=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");this.storage=this.window.localStorage,this.currentUser=i,this.Qs=mu(this.persistenceKey,this.Bs),this.Ws=function(t){return`firestore_sequence_number_${t}`}(this.persistenceKey),this.Ks=this.Ks.insert(this.Bs,new Tu),this.Gs=new RegExp(`^firestore_clients_${s}_([^_]*)$`),this.zs=new RegExp(`^firestore_mutations_${s}_(\\d+)(?:_(.*))?$`),this.Hs=new RegExp(`^firestore_targets_${s}_(\\d+)$`),this.Js=function(t){return`firestore_online_state_${t}`}(this.persistenceKey),this.Ys=function(t){return`firestore_bundle_loaded_${t}`}(this.persistenceKey),this.window.addEventListener("storage",this.Us)}static Pt(t){return!(!t||!t.localStorage)}async start(){const t=await this.syncEngine.Tn();for(const e of t){if(e===this.Bs)continue;const t=this.getItem(mu(this.persistenceKey,e));if(t){const n=wu.Os(e,t);n&&(this.Ks=this.Ks.insert(n.clientId,n))}}this.Xs();const e=this.storage.getItem(this.Js);if(e){const t=this.Zs(e);t&&this.ti(t)}for(const t of this.js)this.qs(t);this.js=[],this.window.addEventListener("pagehide",(()=>this.shutdown())),this.started=!0}writeSequenceNumber(t){this.setItem(this.Ws,JSON.stringify(t))}getAllActiveQueryTargets(){return this.ei(this.Ks)}isActiveQueryTarget(t){let e=!1;return this.Ks.forEach(((n,r)=>{r.activeTargetIds.has(t)&&(e=!0)})),e}addPendingMutation(t){this.ni(t,"pending")}updateMutationState(t,e,n){this.ni(t,e,n),this.si(t)}addLocalQueryTarget(t){let e="not-current";if(this.isActiveQueryTarget(t)){const n=this.storage.getItem(yu(this.persistenceKey,t));if(n){const r=bu.Os(t,n);r&&(e=r.state)}}return this.ii.Ms(t),this.Xs(),e}removeLocalQueryTarget(t){this.ii.Ls(t),this.Xs()}isLocalQueryTarget(t){return this.ii.activeTargetIds.has(t)}clearQueryState(t){this.removeItem(yu(this.persistenceKey,t))}updateQueryState(t,e,n){this.ri(t,e,n)}handleUserChange(t,e,n){e.forEach((t=>{this.si(t)})),this.currentUser=t,n.forEach((t=>{this.addPendingMutation(t)}))}setOnlineState(t){this.oi(t)}notifyBundleLoaded(){this.ai()}shutdown(){this.started&&(this.window.removeEventListener("storage",this.Us),this.removeItem(this.Qs),this.started=!1)}getItem(t){const e=this.storage.getItem(t);return Er("SharedClientState","READ",t,e),e}setItem(t,e){Er("SharedClientState","SET",t,e),this.storage.setItem(t,e)}removeItem(t){Er("SharedClientState","REMOVE",t),this.storage.removeItem(t)}qs(t){const e=t;if(e.storageArea===this.storage){if(Er("SharedClientState","EVENT",e.key,e.newValue),e.key===this.Qs)return void Sr("Received WebStorage notification for local change. Another client might have garbage-collected our state");this.Fe.enqueueRetryable((async()=>{if(this.started){if(null!==e.key)if(this.Gs.test(e.key)){if(null==e.newValue){const t=this.ci(e.key);return this.ui(t,null)}{const t=this.hi(e.key,e.newValue);if(t)return this.ui(t.clientId,t)}}else if(this.zs.test(e.key)){if(null!==e.newValue){const t=this.li(e.key,e.newValue);if(t)return this.fi(t)}}else if(this.Hs.test(e.key)){if(null!==e.newValue){const t=this.di(e.key,e.newValue);if(t)return this.wi(t)}}else if(e.key===this.Js){if(null!==e.newValue){const t=this.Zs(e.newValue);if(t)return this.ti(t)}}else if(e.key===this.Ws){const t=function(t){let e=Kr.I;if(null!=t)try{const n=JSON.parse(t);xr("number"==typeof n),e=n}catch(t){Sr("SharedClientState","Failed to read sequence number from WebStorage",t)}return e}(e.newValue);t!==Kr.I&&this.sequenceNumberHandler(t)}else if(e.key===this.Ys)return this.syncEngine._i()}else this.js.push(e)}))}}get ii(){return this.Ks.get(this.Bs)}Xs(){this.setItem(this.Qs,this.ii.Fs())}ni(t,e,n){const r=new vu(this.currentUser,t,e,n),i=gu(this.persistenceKey,this.currentUser,t);this.setItem(i,r.Fs())}si(t){const e=gu(this.persistenceKey,this.currentUser,t);this.removeItem(e)}oi(t){const e={clientId:this.Bs,onlineState:t};this.storage.setItem(this.Js,JSON.stringify(e))}ri(t,e,n){const r=yu(this.persistenceKey,t),i=new bu(t,e,n);this.setItem(r,i.Fs())}ai(){this.setItem(this.Ys,"value-not-used")}ci(t){const e=this.Gs.exec(t);return e?e[1]:null}hi(t,e){const n=this.ci(t);return wu.Os(n,e)}li(t,e){const n=this.zs.exec(t),r=Number(n[1]),i=void 0!==n[2]?n[2]:null;return vu.Os(new br(i),r,e)}di(t,e){const n=this.Hs.exec(t),r=Number(n[1]);return bu.Os(r,e)}Zs(t){return Iu.Os(t)}async fi(t){if(t.user.uid===this.currentUser.uid)return this.syncEngine.mi(t.batchId,t.state,t.error);Er("SharedClientState",`Ignoring mutation for non-active user ${t.user.uid}`)}wi(t){return this.syncEngine.gi(t.targetId,t.state,t.error)}ui(t,e){const n=e?this.Ks.insert(t,e):this.Ks.remove(t),r=this.ei(this.Ks),i=this.ei(n),s=[],o=[];return i.forEach((t=>{r.has(t)||s.push(t)})),r.forEach((t=>{i.has(t)||o.push(t)})),this.syncEngine.yi(s,o).then((()=>{this.Ks=n}))}ti(t){this.Ks.get(t.clientId)&&this.onlineStateHandler(t.onlineState)}ei(t){let e=yo();return t.forEach(((t,n)=>{e=e.unionWith(n.activeTargetIds)})),e}}class Eu{constructor(){this.pi=new Tu,this.Ti={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(t){}updateMutationState(t,e,n){}addLocalQueryTarget(t){return this.pi.Ms(t),this.Ti[t]||"not-current"}updateQueryState(t,e,n){this.Ti[t]=e}removeLocalQueryTarget(t){this.pi.Ls(t)}isLocalQueryTarget(t){return this.pi.activeTargetIds.has(t)}clearQueryState(t){delete this.Ti[t]}getAllActiveQueryTargets(){return this.pi.activeTargetIds}isActiveQueryTarget(t){return this.pi.activeTargetIds.has(t)}start(){return this.pi=new Tu,Promise.resolve()}handleUserChange(t,e,n){}setOnlineState(t){}shutdown(){}writeSequenceNumber(t){}notifyBundleLoaded(){}}class Su{Ei(t){}shutdown(){}}class ku{constructor(){this.Ii=()=>this.Ai(),this.Ri=()=>this.bi(),this.Pi=[],this.vi()}Ei(t){this.Pi.push(t)}shutdown(){window.removeEventListener("online",this.Ii),window.removeEventListener("offline",this.Ri)}vi(){window.addEventListener("online",this.Ii),window.addEventListener("offline",this.Ri)}Ai(){Er("ConnectivityMonitor","Network connectivity changed: AVAILABLE");for(const t of this.Pi)t(0)}bi(){Er("ConnectivityMonitor","Network connectivity changed: UNAVAILABLE");for(const t of this.Pi)t(1)}static Pt(){return"undefined"!=typeof window&&void 0!==window.addEventListener&&void 0!==window.removeEventListener}}const Au={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery"};class Nu{constructor(t){this.Vi=t.Vi,this.Si=t.Si}Di(t){this.Ci=t}Ni(t){this.ki=t}onMessage(t){this.xi=t}close(){this.Si()}send(t){this.Vi(t)}$i(){this.Ci()}Oi(t){this.ki(t)}Fi(t){this.xi(t)}}class xu extends class{constructor(t){this.databaseInfo=t,this.databaseId=t.databaseId;const e=t.ssl?"https":"http";this.Mi=e+"://"+t.host,this.Li="projects/"+this.databaseId.projectId+"/databases/"+this.databaseId.database+"/documents"}Bi(t,e,n,r,i){const s=this.Ui(t,e);Er("RestConnection","Sending: ",s,n);const o={};return this.qi(o,r,i),this.Ki(t,s,o,n).then((t=>(Er("RestConnection","Received: ",t),t)),(e=>{throw kr("RestConnection",`${t} failed with error: `,e,"url: ",s,"request:",n),e}))}ji(t,e,n,r,i){return this.Bi(t,e,n,r,i)}qi(t,e,n){t["X-Goog-Api-Client"]="gl-js/ fire/"+wr,t["Content-Type"]="text/plain",this.databaseInfo.appId&&(t["X-Firebase-GMPID"]=this.databaseInfo.appId),e&&e.headers.forEach(((e,n)=>t[n]=e)),n&&n.headers.forEach(((e,n)=>t[n]=e))}Ui(t,e){const n=Au[t];return`${this.Mi}/v1/${e}:${n}`}}{constructor(t){super(t),this.forceLongPolling=t.forceLongPolling,this.autoDetectLongPolling=t.autoDetectLongPolling,this.useFetchStreams=t.useFetchStreams}Ki(t,e,n,r){return new Promise(((i,s)=>{const o=new yr;o.listenOnce(dr.COMPLETE,(()=>{try{switch(o.getLastErrorCode()){case lr.NO_ERROR:const e=o.getResponseJson();Er("Connection","XHR received:",JSON.stringify(e)),i(e);break;case lr.TIMEOUT:Er("Connection",'RPC "'+t+'" timed out'),s(new Rr(Or.DEADLINE_EXCEEDED,"Request time out"));break;case lr.HTTP_ERROR:const n=o.getStatus();if(Er("Connection",'RPC "'+t+'" failed with status:',n,"response text:",o.getResponseText()),n>0){const t=o.getResponseJson().error;if(t&&t.status&&t.message){const e=function(t){const e=t.toLowerCase().replace(/_/g,"-");return Object.values(Or).indexOf(e)>=0?e:Or.UNKNOWN}(t.status);s(new Rr(e,t.message))}else s(new Rr(Or.UNKNOWN,"Server responded with status "+o.getStatus()))}else s(new Rr(Or.UNAVAILABLE,"Connection failed."));break;default:Nr()}}finally{Er("Connection",'RPC "'+t+'" completed.')}}));const a=JSON.stringify(r);o.send(e,"POST",a,n,15)}))}Qi(t,e,n){const r=[this.Mi,"/","google.firestore.v1.Firestore","/",t,"/channel"],i=ur(),s=hr(),o={httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:`projects/${this.databaseId.projectId}/databases/${this.databaseId.database}`},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling,detectBufferingProxy:this.autoDetectLongPolling};this.useFetchStreams&&(o.xmlHttpFactory=new mr({})),this.qi(o.initMessageHeaders,e,n),(0,a.uI)()||(0,a.b$)()||(0,a.d)()||(0,a.w1)()||(0,a.Mn)()||(0,a.ru)()||(o.httpHeadersOverwriteParam="$httpHeaders");const c=r.join("");Er("Connection","Creating WebChannel: "+c,o);const u=i.createWebChannel(c,o);let h=!1,l=!1;const d=new Nu({Vi:t=>{l?Er("Connection","Not sending because WebChannel is closed:",t):(h||(Er("Connection","Opening WebChannel transport."),u.open(),h=!0),Er("Connection","WebChannel sending:",t),u.send(t))},Si:()=>u.close()}),f=(t,e,n)=>{t.listen(e,(t=>{try{n(t)}catch(t){setTimeout((()=>{throw t}),0)}}))};return f(u,gr.EventType.OPEN,(()=>{l||Er("Connection","WebChannel transport opened.")})),f(u,gr.EventType.CLOSE,(()=>{l||(l=!0,Er("Connection","WebChannel transport closed"),d.Oi())})),f(u,gr.EventType.ERROR,(t=>{l||(l=!0,kr("Connection","WebChannel transport errored:",t),d.Oi(new Rr(Or.UNAVAILABLE,"The operation could not be completed")))})),f(u,gr.EventType.MESSAGE,(t=>{var e;if(!l){const n=t.data[0];xr(!!n);const r=n,i=r.error||(null===(e=r[0])||void 0===e?void 0:e.error);if(i){Er("Connection","WebChannel received error:",i);const t=i.status;let e=function(t){const e=Zs[t];if(void 0!==e)return eo(e)}(t),n=i.message;void 0===e&&(e=Or.INTERNAL,n="Unknown error status: "+t+" with message "+i.message),l=!0,d.Oi(new Rr(e,n)),u.close()}else Er("Connection","WebChannel received:",n),d.Fi(n)}})),f(s,fr.STAT_EVENT,(t=>{t.stat===pr.PROXY?Er("Connection","Detected buffering proxy"):t.stat===pr.NOPROXY&&Er("Connection","Detected no buffering proxy")})),setTimeout((()=>{d.$i()}),0),d}}function Cu(){return"undefined"!=typeof window?window:null}function Du(){return"undefined"!=typeof document?document:null}function Ou(t){return new xo(t,!0)}class Ru{constructor(t,e,n=1e3,r=1.5,i=6e4){this.Fe=t,this.timerId=e,this.Wi=n,this.Gi=r,this.zi=i,this.Hi=0,this.Ji=null,this.Yi=Date.now(),this.reset()}reset(){this.Hi=0}Xi(){this.Hi=this.zi}Zi(t){this.cancel();const e=Math.floor(this.Hi+this.tr()),n=Math.max(0,Date.now()-this.Yi),r=Math.max(0,e-n);r>0&&Er("ExponentialBackoff",`Backing off for ${r} ms (base delay: ${this.Hi} ms, delay with jitter: ${e} ms, last attempt: ${n} ms ago)`),this.Ji=this.Fe.enqueueAfterDelay(this.timerId,r,(()=>(this.Yi=Date.now(),t()))),this.Hi*=this.Gi,this.Hi<this.Wi&&(this.Hi=this.Wi),this.Hi>this.zi&&(this.Hi=this.zi)}er(){null!==this.Ji&&(this.Ji.skipDelay(),this.Ji=null)}cancel(){null!==this.Ji&&(this.Ji.cancel(),this.Ji=null)}tr(){return(Math.random()-.5)*this.Hi}}class Pu{constructor(t,e,n,r,i,s,o,a){this.Fe=t,this.nr=n,this.sr=r,this.ir=i,this.authCredentialsProvider=s,this.appCheckCredentialsProvider=o,this.listener=a,this.state=0,this.rr=0,this.ar=null,this.cr=null,this.stream=null,this.ur=new Ru(t,e)}hr(){return 1===this.state||5===this.state||this.lr()}lr(){return 2===this.state||3===this.state}start(){4!==this.state?this.auth():this.dr()}async stop(){this.hr()&&await this.close(0)}wr(){this.state=0,this.ur.reset()}_r(){this.lr()&&null===this.ar&&(this.ar=this.Fe.enqueueAfterDelay(this.nr,6e4,(()=>this.mr())))}gr(t){this.yr(),this.stream.send(t)}async mr(){if(this.lr())return this.close(0)}yr(){this.ar&&(this.ar.cancel(),this.ar=null)}pr(){this.cr&&(this.cr.cancel(),this.cr=null)}async close(t,e){this.yr(),this.pr(),this.ur.cancel(),this.rr++,4!==t?this.ur.reset():e&&e.code===Or.RESOURCE_EXHAUSTED?(Sr(e.toString()),Sr("Using maximum backoff delay to prevent overloading the backend."),this.ur.Xi()):e&&e.code===Or.UNAUTHENTICATED&&3!==this.state&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),null!==this.stream&&(this.Tr(),this.stream.close(),this.stream=null),this.state=t,await this.listener.Ni(e)}Tr(){}auth(){this.state=1;const t=this.Er(this.rr),e=this.rr;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then((([t,n])=>{this.rr===e&&this.Ir(t,n)}),(e=>{t((()=>{const t=new Rr(Or.UNKNOWN,"Fetching auth token failed: "+e.message);return this.Ar(t)}))}))}Ir(t,e){const n=this.Er(this.rr);this.stream=this.Rr(t,e),this.stream.Di((()=>{n((()=>(this.state=2,this.cr=this.Fe.enqueueAfterDelay(this.sr,1e4,(()=>(this.lr()&&(this.state=3),Promise.resolve()))),this.listener.Di())))})),this.stream.Ni((t=>{n((()=>this.Ar(t)))})),this.stream.onMessage((t=>{n((()=>this.onMessage(t)))}))}dr(){this.state=5,this.ur.Zi((async()=>{this.state=0,this.start()}))}Ar(t){return Er("PersistentStream",`close with error: ${t}`),this.stream=null,this.close(4,t)}Er(t){return e=>{this.Fe.enqueueAndForget((()=>this.rr===t?e():(Er("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())))}}}class Lu extends Pu{constructor(t,e,n,r,i,s){super(t,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",e,n,r,s),this.k=i}Rr(t,e){return this.ir.Qi("Listen",t,e)}onMessage(t){this.ur.reset();const e=function(t,e){let n;if("targetChange"in e){e.targetChange;const r=function(t){return"NO_CHANGE"===t?0:"ADD"===t?1:"REMOVE"===t?2:"CURRENT"===t?3:"RESET"===t?4:Nr()}(e.targetChange.targetChangeType||"NO_CHANGE"),i=e.targetChange.targetIds||[],s=function(t,e){return t.C?(xr(void 0===e||"string"==typeof e),ai.fromBase64String(e||"")):(xr(void 0===e||e instanceof Uint8Array),ai.fromUint8Array(e||new Uint8Array))}(t,e.targetChange.resumeToken),o=e.targetChange.cause,a=o&&function(t){const e=void 0===t.code?Or.UNKNOWN:eo(t.code);return new Rr(e,t.message||"")}(o);n=new To(r,i,s,a||null)}else if("documentChange"in e){e.documentChange;const r=e.documentChange;r.document,r.document.name,r.document.updateTime;const i=Fo(t,r.document.name),s=Ro(r.document.updateTime),o=new Ri({mapValue:{fields:r.document.fields}}),a=Li.newFoundDocument(i,s,o),c=r.targetIds||[],u=r.removedTargetIds||[];n=new wo(c,u,a.key,a)}else if("documentDelete"in e){e.documentDelete;const r=e.documentDelete;r.document;const i=Fo(t,r.document),s=r.readTime?Ro(r.readTime):Jr.min(),o=Li.newNoDocument(i,s),a=r.removedTargetIds||[];n=new wo([],a,o.key,o)}else if("documentRemove"in e){e.documentRemove;const r=e.documentRemove;r.document;const i=Fo(t,r.document),s=r.removedTargetIds||[];n=new wo([],s,i,null)}else{if(!("filter"in e))return Nr();{e.filter;const t=e.filter;t.targetId;const r=t.count||0,i=new Js(r),s=t.targetId;n=new Io(s,i)}}return n}(this.k,t),n=function(t){if(!("targetChange"in t))return Jr.min();const e=t.targetChange;return e.targetIds&&e.targetIds.length?Jr.min():e.readTime?Ro(e.readTime):Jr.min()}(t);return this.listener.br(e,n)}Pr(t){const e={};e.database=jo(this.k),e.addTarget=function(t,e){let n;const r=e.target;return n=ji(r)?{documents:Go(t,r)}:{query:Ho(t,r)},n.targetId=e.targetId,e.resumeToken.approximateByteSize()>0?n.resumeToken=Do(t,e.resumeToken):e.snapshotVersion.compareTo(Jr.min())>0&&(n.readTime=Co(t,e.snapshotVersion.toTimestamp())),n}(this.k,t);const n=function(t,e){const n=function(t,e){switch(e){case 0:return null;case 1:return"existence-filter-mismatch";case 2:return"limbo-document";default:return Nr()}}(0,e.purpose);return null==n?null:{"goog-listen-tags":n}}(this.k,t);n&&(e.labels=n),this.gr(e)}vr(t){const e={};e.database=jo(this.k),e.removeTarget=t,this.gr(e)}}class Mu extends Pu{constructor(t,e,n,r,i,s){super(t,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",e,n,r,s),this.k=i,this.Vr=!1}get Sr(){return this.Vr}start(){this.Vr=!1,this.lastStreamToken=void 0,super.start()}Tr(){this.Vr&&this.Dr([])}Rr(t,e){return this.ir.Qi("Write",t,e)}onMessage(t){if(xr(!!t.streamToken),this.lastStreamToken=t.streamToken,this.Vr){this.ur.reset();const e=function(t,e){return t&&t.length>0?(xr(void 0!==e),t.map((t=>function(t,e){let n=t.updateTime?Ro(t.updateTime):Ro(e);return n.isEqual(Jr.min())&&(n=Ro(e)),new Ls(n,t.transformResults||[])}(t,e)))):[]}(t.writeResults,t.commitTime),n=Ro(t.commitTime);return this.listener.Cr(n,e)}return xr(!t.writeResults||0===t.writeResults.length),this.Vr=!0,this.listener.Nr()}kr(){const t={};t.database=jo(this.k),this.gr(t)}Dr(t){const e={streamToken:this.lastStreamToken,writes:t.map((t=>Ko(this.k,t)))};this.gr(e)}}class Fu extends class{}{constructor(t,e,n,r){super(),this.authCredentials=t,this.appCheckCredentials=e,this.ir=n,this.k=r,this.$r=!1}Or(){if(this.$r)throw new Rr(Or.FAILED_PRECONDITION,"The client has already been terminated.")}Bi(t,e,n){return this.Or(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([r,i])=>this.ir.Bi(t,e,n,r,i))).catch((t=>{throw"FirebaseError"===t.name?(t.code===Or.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),t):new Rr(Or.UNKNOWN,t.toString())}))}ji(t,e,n){return this.Or(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([r,i])=>this.ir.ji(t,e,n,r,i))).catch((t=>{throw"FirebaseError"===t.name?(t.code===Or.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),t):new Rr(Or.UNKNOWN,t.toString())}))}terminate(){this.$r=!0}}class Uu{constructor(t,e){this.asyncQueue=t,this.onlineStateHandler=e,this.state="Unknown",this.Fr=0,this.Mr=null,this.Lr=!0}Br(){0===this.Fr&&(this.Ur("Unknown"),this.Mr=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,(()=>(this.Mr=null,this.qr("Backend didn't respond within 10 seconds."),this.Ur("Offline"),Promise.resolve()))))}Kr(t){"Online"===this.state?this.Ur("Unknown"):(this.Fr++,this.Fr>=1&&(this.jr(),this.qr(`Connection failed 1 times. Most recent error: ${t.toString()}`),this.Ur("Offline")))}set(t){this.jr(),this.Fr=0,"Online"===t&&(this.Lr=!1),this.Ur(t)}Ur(t){t!==this.state&&(this.state=t,this.onlineStateHandler(t))}qr(t){const e=`Could not reach Cloud Firestore backend. ${t}\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.Lr?(Sr(e),this.Lr=!1):Er("OnlineStateTracker",e)}jr(){null!==this.Mr&&(this.Mr.cancel(),this.Mr=null)}}class Vu{constructor(t,e,n,r,i){this.localStore=t,this.datastore=e,this.asyncQueue=n,this.remoteSyncer={},this.Qr=[],this.Wr=new Map,this.Gr=new Set,this.zr=[],this.Hr=i,this.Hr.Ei((t=>{n.enqueueAndForget((async()=>{$u(this)&&(Er("RemoteStore","Restarting streams for network reachability change."),await async function(t){const e=Dr(t);e.Gr.add(4),await qu(e),e.Jr.set("Unknown"),e.Gr.delete(4),await ju(e)}(this))}))})),this.Jr=new Uu(n,r)}}async function ju(t){if($u(t))for(const e of t.zr)await e(!0)}async function qu(t){for(const e of t.zr)await e(!1)}function Bu(t,e){const n=Dr(t);n.Wr.has(e.targetId)||(n.Wr.set(e.targetId,e),Hu(n)?Gu(n):lh(n).lr()&&Ku(n,e))}function zu(t,e){const n=Dr(t),r=lh(n);n.Wr.delete(e),r.lr()&&Wu(n,e),0===n.Wr.size&&(r.lr()?r._r():$u(n)&&n.Jr.set("Unknown"))}function Ku(t,e){t.Yr.X(e.targetId),lh(t).Pr(e)}function Wu(t,e){t.Yr.X(e),lh(t).vr(e)}function Gu(t){t.Yr=new Eo({getRemoteKeysForTarget:e=>t.remoteSyncer.getRemoteKeysForTarget(e),Et:e=>t.Wr.get(e)||null}),lh(t).start(),t.Jr.Br()}function Hu(t){return $u(t)&&!lh(t).hr()&&t.Wr.size>0}function $u(t){return 0===Dr(t).Gr.size}function Yu(t){t.Yr=void 0}async function Qu(t){t.Wr.forEach(((e,n)=>{Ku(t,e)}))}async function Ju(t,e){Yu(t),Hu(t)?(t.Jr.Kr(e),Gu(t)):t.Jr.set("Unknown")}async function Zu(t,e,n){if(t.Jr.set("Online"),e instanceof To&&2===e.state&&e.cause)try{await async function(t,e){const n=e.cause;for(const r of e.targetIds)t.Wr.has(r)&&(await t.remoteSyncer.rejectListen(r,n),t.Wr.delete(r),t.Yr.removeTarget(r))}(t,e)}catch(n){Er("RemoteStore","Failed to remove targets %s: %s ",e.targetIds.join(","),n),await Xu(t,n)}else if(e instanceof wo?t.Yr.ot(e):e instanceof Io?t.Yr.dt(e):t.Yr.ut(e),!n.isEqual(Jr.min()))try{const e=await Qc(t.localStore);n.compareTo(e)>=0&&await function(t,e){const n=t.Yr.gt(e);return n.targetChanges.forEach(((n,r)=>{if(n.resumeToken.approximateByteSize()>0){const i=t.Wr.get(r);i&&t.Wr.set(r,i.withResumeToken(n.resumeToken,e))}})),n.targetMismatches.forEach((e=>{const n=t.Wr.get(e);if(!n)return;t.Wr.set(e,n.withResumeToken(ai.EMPTY_BYTE_STRING,n.snapshotVersion)),Wu(t,e);const r=new za(n.target,e,1,n.sequenceNumber);Ku(t,r)})),t.remoteSyncer.applyRemoteEvent(n)}(t,n)}catch(e){Er("RemoteStore","Failed to raise snapshot:",e),await Xu(t,e)}}async function Xu(t,e,n){if(!Pa(e))throw e;t.Gr.add(1),await qu(t),t.Jr.set("Offline"),n||(n=()=>Qc(t.localStore)),t.asyncQueue.enqueueRetryable((async()=>{Er("RemoteStore","Retrying IndexedDB access"),await n(),t.Gr.delete(1),await ju(t)}))}function th(t,e){return e().catch((n=>Xu(t,n,e)))}async function eh(t){const e=Dr(t),n=dh(e);let r=e.Qr.length>0?e.Qr[e.Qr.length-1].batchId:-1;for(;nh(e);)try{const t=await Zc(e.localStore,r);if(null===t){0===e.Qr.length&&n._r();break}r=t.batchId,rh(e,t)}catch(t){await Xu(e,t)}ih(e)&&sh(e)}function nh(t){return $u(t)&&t.Qr.length<10}function rh(t,e){t.Qr.push(e);const n=dh(t);n.lr()&&n.Sr&&n.Dr(e.mutations)}function ih(t){return $u(t)&&!dh(t).hr()&&t.Qr.length>0}function sh(t){dh(t).start()}async function oh(t){dh(t).kr()}async function ah(t){const e=dh(t);for(const n of t.Qr)e.Dr(n.mutations)}async function ch(t,e,n){const r=t.Qr.shift(),i=Ba.from(r,e,n);await th(t,(()=>t.remoteSyncer.applySuccessfulWrite(i))),await eh(t)}async function uh(t,e){e&&dh(t).Sr&&await async function(t,e){if(to(n=e.code)&&n!==Or.ABORTED){const n=t.Qr.shift();dh(t).wr(),await th(t,(()=>t.remoteSyncer.rejectFailedWrite(n.batchId,e))),await eh(t)}var n}(t,e),ih(t)&&sh(t)}async function hh(t,e){const n=Dr(t);e?(n.Gr.delete(2),await ju(n)):e||(n.Gr.add(2),await qu(n),n.Jr.set("Unknown"))}function lh(t){return t.Xr||(t.Xr=function(t,e,n){const r=Dr(t);return r.Or(),new Lu(e,r.ir,r.authCredentials,r.appCheckCredentials,r.k,n)}(t.datastore,t.asyncQueue,{Di:Qu.bind(null,t),Ni:Ju.bind(null,t),br:Zu.bind(null,t)}),t.zr.push((async e=>{e?(t.Xr.wr(),Hu(t)?Gu(t):t.Jr.set("Unknown")):(await t.Xr.stop(),Yu(t))}))),t.Xr}function dh(t){return t.Zr||(t.Zr=function(t,e,n){const r=Dr(t);return r.Or(),new Mu(e,r.ir,r.authCredentials,r.appCheckCredentials,r.k,n)}(t.datastore,t.asyncQueue,{Di:oh.bind(null,t),Ni:uh.bind(null,t),Nr:ah.bind(null,t),Cr:ch.bind(null,t)}),t.zr.push((async e=>{e?(t.Zr.wr(),await eh(t)):(await t.Zr.stop(),t.Qr.length>0&&(Er("RemoteStore",`Stopping write stream with ${t.Qr.length} pending writes`),t.Qr=[]))}))),t.Zr}class fh{constructor(t,e,n,r,i){this.asyncQueue=t,this.timerId=e,this.targetTimeMs=n,this.op=r,this.removalCallback=i,this.deferred=new Pr,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch((t=>{}))}static createAndSchedule(t,e,n,r,i){const s=Date.now()+n,o=new fh(t,e,s,r,i);return o.start(n),o}start(t){this.timerHandle=setTimeout((()=>this.handleDelayElapsed()),t)}skipDelay(){return this.handleDelayElapsed()}cancel(t){null!==this.timerHandle&&(this.clearTimeout(),this.deferred.reject(new Rr(Or.CANCELLED,"Operation cancelled"+(t?": "+t:""))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget((()=>null!==this.timerHandle?(this.clearTimeout(),this.op().then((t=>this.deferred.resolve(t)))):Promise.resolve()))}clearTimeout(){null!==this.timerHandle&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}}function ph(t,e){if(Sr("AsyncQueue",`${e}: ${t}`),Pa(t))return new Rr(Or.UNAVAILABLE,`${e}: ${t}`);throw t}class mh{constructor(t){this.comparator=t?(e,n)=>t(e,n)||vi.comparator(e.key,n.key):(t,e)=>vi.comparator(t.key,e.key),this.keyedMap=ho(),this.sortedSet=new no(this.comparator)}static emptySet(t){return new mh(t.comparator)}has(t){return null!=this.keyedMap.get(t)}get(t){return this.keyedMap.get(t)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(t){const e=this.keyedMap.get(t);return e?this.sortedSet.indexOf(e):-1}get size(){return this.sortedSet.size}forEach(t){this.sortedSet.inorderTraversal(((e,n)=>(t(e),!1)))}add(t){const e=this.delete(t.key);return e.copy(e.keyedMap.insert(t.key,t),e.sortedSet.insert(t,null))}delete(t){const e=this.get(t);return e?this.copy(this.keyedMap.remove(t),this.sortedSet.remove(e)):this}isEqual(t){if(!(t instanceof mh))return!1;if(this.size!==t.size)return!1;const e=this.sortedSet.getIterator(),n=t.sortedSet.getIterator();for(;e.hasNext();){const t=e.getNext().key,r=n.getNext().key;if(!t.isEqual(r))return!1}return!0}toString(){const t=[];return this.forEach((e=>{t.push(e.toString())})),0===t.length?"DocumentSet ()":"DocumentSet (\n "+t.join(" \n")+"\n)"}copy(t,e){const n=new mh;return n.comparator=this.comparator,n.keyedMap=t,n.sortedSet=e,n}}class gh{constructor(){this.eo=new no(vi.comparator)}track(t){const e=t.doc.key,n=this.eo.get(e);n?0!==t.type&&3===n.type?this.eo=this.eo.insert(e,t):3===t.type&&1!==n.type?this.eo=this.eo.insert(e,{type:n.type,doc:t.doc}):2===t.type&&2===n.type?this.eo=this.eo.insert(e,{type:2,doc:t.doc}):2===t.type&&0===n.type?this.eo=this.eo.insert(e,{type:0,doc:t.doc}):1===t.type&&0===n.type?this.eo=this.eo.remove(e):1===t.type&&2===n.type?this.eo=this.eo.insert(e,{type:1,doc:n.doc}):0===t.type&&1===n.type?this.eo=this.eo.insert(e,{type:2,doc:t.doc}):Nr():this.eo=this.eo.insert(e,t)}no(){const t=[];return this.eo.inorderTraversal(((e,n)=>{t.push(n)})),t}}class yh{constructor(t,e,n,r,i,s,o,a){this.query=t,this.docs=e,this.oldDocs=n,this.docChanges=r,this.mutatedKeys=i,this.fromCache=s,this.syncStateChanged=o,this.excludesMetadataChanges=a}static fromInitialDocuments(t,e,n,r){const i=[];return e.forEach((t=>{i.push({type:0,doc:t})})),new yh(t,e,mh.emptySet(e),i,n,r,!0,!1)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(t){if(!(this.fromCache===t.fromCache&&this.syncStateChanged===t.syncStateChanged&&this.mutatedKeys.isEqual(t.mutatedKeys)&&fs(this.query,t.query)&&this.docs.isEqual(t.docs)&&this.oldDocs.isEqual(t.oldDocs)))return!1;const e=this.docChanges,n=t.docChanges;if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t].type!==n[t].type||!e[t].doc.isEqual(n[t].doc))return!1;return!0}}class vh{constructor(){this.so=void 0,this.listeners=[]}}class bh{constructor(){this.queries=new xc((t=>ps(t)),fs),this.onlineState="Unknown",this.io=new Set}}async function wh(t,e){const n=Dr(t),r=e.query;let i=!1,s=n.queries.get(r);if(s||(i=!0,s=new vh),i)try{s.so=await n.onListen(r)}catch(t){const n=ph(t,`Initialization of query '${ms(e.query)}' failed`);return void e.onError(n)}n.queries.set(r,s),s.listeners.push(e),e.ro(n.onlineState),s.so&&e.oo(s.so)&&Eh(n)}async function Ih(t,e){const n=Dr(t),r=e.query;let i=!1;const s=n.queries.get(r);if(s){const t=s.listeners.indexOf(e);t>=0&&(s.listeners.splice(t,1),i=0===s.listeners.length)}if(i)return n.queries.delete(r),n.onUnlisten(r)}function Th(t,e){const n=Dr(t);let r=!1;for(const t of e){const e=t.query,i=n.queries.get(e);if(i){for(const e of i.listeners)e.oo(t)&&(r=!0);i.so=t}}r&&Eh(n)}function _h(t,e,n){const r=Dr(t),i=r.queries.get(e);if(i)for(const t of i.listeners)t.onError(n);r.queries.delete(e)}function Eh(t){t.io.forEach((t=>{t.next()}))}class Sh{constructor(t,e,n){this.query=t,this.ao=e,this.co=!1,this.uo=null,this.onlineState="Unknown",this.options=n||{}}oo(t){if(!this.options.includeMetadataChanges){const e=[];for(const n of t.docChanges)3!==n.type&&e.push(n);t=new yh(t.query,t.docs,t.oldDocs,e,t.mutatedKeys,t.fromCache,t.syncStateChanged,!0)}let e=!1;return this.co?this.ho(t)&&(this.ao.next(t),e=!0):this.lo(t,this.onlineState)&&(this.fo(t),e=!0),this.uo=t,e}onError(t){this.ao.error(t)}ro(t){this.onlineState=t;let e=!1;return this.uo&&!this.co&&this.lo(this.uo,t)&&(this.fo(this.uo),e=!0),e}lo(t,e){if(!t.fromCache)return!0;const n="Offline"!==e;return!(this.options.wo&&n||t.docs.isEmpty()&&"Offline"!==e)}ho(t){if(t.docChanges.length>0)return!0;const e=this.uo&&this.uo.hasPendingWrites!==t.hasPendingWrites;return!(!t.syncStateChanged&&!e)&&!0===this.options.includeMetadataChanges}fo(t){t=yh.fromInitialDocuments(t.query,t.docs,t.mutatedKeys,t.fromCache),this.co=!0,this.ao.next(t)}}class kh{constructor(t,e){this.payload=t,this.byteLength=e}_o(){return"metadata"in this.payload}}class Ah{constructor(t){this.k=t}Hn(t){return Fo(this.k,t)}Jn(t){return t.metadata.exists?zo(this.k,t.document,!1):Li.newNoDocument(this.Hn(t.metadata.name),this.Yn(t.metadata.readTime))}Yn(t){return Ro(t)}}class Nh{constructor(t,e,n){this.mo=t,this.localStore=e,this.k=n,this.queries=[],this.documents=[],this.progress=xh(t)}yo(t){this.progress.bytesLoaded+=t.byteLength;let e=this.progress.documentsLoaded;return t.payload.namedQuery?this.queries.push(t.payload.namedQuery):t.payload.documentMetadata?(this.documents.push({metadata:t.payload.documentMetadata}),t.payload.documentMetadata.exists||++e):t.payload.document&&(this.documents[this.documents.length-1].document=t.payload.document,++e),e!==this.progress.documentsLoaded?(this.progress.documentsLoaded=e,Object.assign({},this.progress)):null}po(t){const e=new Map,n=new Ah(this.k);for(const r of t)if(r.metadata.queries){const t=n.Hn(r.metadata.name);for(const n of r.metadata.queries){const r=(e.get(n)||mo()).add(t);e.set(n,r)}}return e}async complete(){const t=await async function(t,e,n,r){const i=Dr(t);let s=mo(),o=co(),a=fo();for(const t of n){const n=e.Hn(t.metadata.name);t.document&&(s=s.add(n)),o=o.insert(n,e.Jn(t)),a=a.insert(n,e.Yn(t.metadata.readTime))}const c=i.Qn.newChangeBuffer({trackRemovals:!0}),u=await Xc(i,function(t){return ls(is(ni.fromString(`__bundle__/docs/${t}`)))}(r));return i.persistence.runTransaction("Apply bundle documents","readwrite",(t=>Jc(t,c,o,Jr.min(),a).next((e=>(c.apply(t),e))).next((e=>i.He.removeMatchingKeysForTargetId(t,u.targetId).next((()=>i.He.addMatchingKeys(t,s,u.targetId))).next((()=>i.Wn.Vn(t,e))).next((()=>e))))))}(this.localStore,new Ah(this.k),this.documents,this.mo.id),e=this.po(this.documents);for(const t of this.queries)await iu(this.localStore,t,e.get(t.name));return this.progress.taskState="Success",new zc(Object.assign({},this.progress),t)}}function xh(t){return{taskState:"Running",documentsLoaded:0,bytesLoaded:0,totalDocuments:t.totalDocuments,totalBytes:t.totalBytes}}class Ch{constructor(t){this.key=t}}class Dh{constructor(t){this.key=t}}class Oh{constructor(t,e){this.query=t,this.To=e,this.Eo=null,this.current=!1,this.Io=mo(),this.mutatedKeys=mo(),this.Ao=ys(t),this.Ro=new mh(this.Ao)}get bo(){return this.To}Po(t,e){const n=e?e.vo:new gh,r=e?e.Ro:this.Ro;let i=e?e.mutatedKeys:this.mutatedKeys,s=r,o=!1;const a=ss(this.query)&&r.size===this.query.limit?r.last():null,c=os(this.query)&&r.size===this.query.limit?r.first():null;if(t.inorderTraversal(((t,e)=>{const u=r.get(t),h=gs(this.query,e)?e:null,l=!!u&&this.mutatedKeys.has(u.key),d=!!h&&(h.hasLocalMutations||this.mutatedKeys.has(h.key)&&h.hasCommittedMutations);let f=!1;u&&h?u.data.isEqual(h.data)?l!==d&&(n.track({type:3,doc:h}),f=!0):this.Vo(u,h)||(n.track({type:2,doc:h}),f=!0,(a&&this.Ao(h,a)>0||c&&this.Ao(h,c)<0)&&(o=!0)):!u&&h?(n.track({type:0,doc:h}),f=!0):u&&!h&&(n.track({type:1,doc:u}),f=!0,(a||c)&&(o=!0)),f&&(h?(s=s.add(h),i=d?i.add(t):i.delete(t)):(s=s.delete(t),i=i.delete(t)))})),ss(this.query)||os(this.query))for(;s.size>this.query.limit;){const t=ss(this.query)?s.last():s.first();s=s.delete(t.key),i=i.delete(t.key),n.track({type:1,doc:t})}return{Ro:s,vo:n,Bn:o,mutatedKeys:i}}Vo(t,e){return t.hasLocalMutations&&e.hasCommittedMutations&&!e.hasLocalMutations}applyChanges(t,e,n){const r=this.Ro;this.Ro=t.Ro,this.mutatedKeys=t.mutatedKeys;const i=t.vo.no();i.sort(((t,e)=>function(t,e){const n=t=>{switch(t){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return Nr()}};return n(t)-n(e)}(t.type,e.type)||this.Ao(t.doc,e.doc))),this.So(n);const s=e?this.Do():[],o=0===this.Io.size&&this.current?1:0,a=o!==this.Eo;return this.Eo=o,0!==i.length||a?{snapshot:new yh(this.query,t.Ro,r,i,t.mutatedKeys,0===o,a,!1),Co:s}:{Co:s}}ro(t){return this.current&&"Offline"===t?(this.current=!1,this.applyChanges({Ro:this.Ro,vo:new gh,mutatedKeys:this.mutatedKeys,Bn:!1},!1)):{Co:[]}}No(t){return!this.To.has(t)&&!!this.Ro.has(t)&&!this.Ro.get(t).hasLocalMutations}So(t){t&&(t.addedDocuments.forEach((t=>this.To=this.To.add(t))),t.modifiedDocuments.forEach((t=>{})),t.removedDocuments.forEach((t=>this.To=this.To.delete(t))),this.current=t.current)}Do(){if(!this.current)return[];const t=this.Io;this.Io=mo(),this.Ro.forEach((t=>{this.No(t.key)&&(this.Io=this.Io.add(t.key))}));const e=[];return t.forEach((t=>{this.Io.has(t)||e.push(new Dh(t))})),this.Io.forEach((n=>{t.has(n)||e.push(new Ch(n))})),e}ko(t){this.To=t.zn,this.Io=mo();const e=this.Po(t.documents);return this.applyChanges(e,!0)}xo(){return yh.fromInitialDocuments(this.query,this.Ro,this.mutatedKeys,0===this.Eo)}}class Rh{constructor(t,e,n){this.query=t,this.targetId=e,this.view=n}}class Ph{constructor(t){this.key=t,this.$o=!1}}class Lh{constructor(t,e,n,r,i,s){this.localStore=t,this.remoteStore=e,this.eventManager=n,this.sharedClientState=r,this.currentUser=i,this.maxConcurrentLimboResolutions=s,this.Oo={},this.Fo=new xc((t=>ps(t)),fs),this.Mo=new Map,this.Lo=new Set,this.Bo=new no(vi.comparator),this.Uo=new Map,this.qo=new ou,this.Ko={},this.jo=new Map,this.Qo=yc.re(),this.onlineState="Unknown",this.Wo=void 0}get isPrimaryClient(){return!0===this.Wo}}async function Mh(t,e){const n=cl(t);let r,i;const s=n.Fo.get(e);if(s)r=s.targetId,n.sharedClientState.addLocalQueryTarget(r),i=s.view.xo();else{const t=await Xc(n.localStore,ls(e)),s=n.sharedClientState.addLocalQueryTarget(t.targetId);r=t.targetId,i=await Fh(n,e,r,"current"===s),n.isPrimaryClient&&Bu(n.remoteStore,t)}return i}async function Fh(t,e,n,r){t.Go=(e,n,r)=>async function(t,e,n,r){let i=e.view.Po(n);i.Bn&&(i=await eu(t.localStore,e.query,!1).then((({documents:t})=>e.view.Po(t,i))));const s=r&&r.targetChanges.get(e.targetId),o=e.view.applyChanges(i,t.isPrimaryClient,s);return $h(t,e.targetId,o.Co),o.snapshot}(t,e,n,r);const i=await eu(t.localStore,e,!0),s=new Oh(e,i.zn),o=s.Po(i.documents),a=bo.createSynthesizedTargetChangeForCurrentChange(n,r&&"Offline"!==t.onlineState),c=s.applyChanges(o,t.isPrimaryClient,a);$h(t,n,c.Co);const u=new Rh(e,n,s);return t.Fo.set(e,u),t.Mo.has(n)?t.Mo.get(n).push(e):t.Mo.set(n,[e]),c.snapshot}async function Uh(t,e){const n=Dr(t),r=n.Fo.get(e),i=n.Mo.get(r.targetId);if(i.length>1)return n.Mo.set(r.targetId,i.filter((t=>!fs(t,e)))),void n.Fo.delete(e);n.isPrimaryClient?(n.sharedClientState.removeLocalQueryTarget(r.targetId),n.sharedClientState.isActiveQueryTarget(r.targetId)||await tu(n.localStore,r.targetId,!1).then((()=>{n.sharedClientState.clearQueryState(r.targetId),zu(n.remoteStore,r.targetId),Gh(n,r.targetId)})).catch(Tc)):(Gh(n,r.targetId),await tu(n.localStore,r.targetId,!0))}async function Vh(t,e){const n=Dr(t);try{const t=await function(t,e){const n=Dr(t),r=e.snapshotVersion;let i=n.qn;return n.persistence.runTransaction("Apply remote event","readwrite-primary",(t=>{const s=n.Qn.newChangeBuffer({trackRemovals:!0});i=n.qn;const o=[];e.targetChanges.forEach(((s,a)=>{const c=i.get(a);if(!c)return;o.push(n.He.removeMatchingKeys(t,s.removedDocuments,a).next((()=>n.He.addMatchingKeys(t,s.addedDocuments,a))));let u=c.withSequenceNumber(t.currentSequenceNumber);e.targetMismatches.has(a)?u=u.withResumeToken(ai.EMPTY_BYTE_STRING,Jr.min()).withLastLimboFreeSnapshotVersion(Jr.min()):s.resumeToken.approximateByteSize()>0&&(u=u.withResumeToken(s.resumeToken,r)),i=i.insert(a,u),function(t,e,n){return 0===t.resumeToken.approximateByteSize()||e.snapshotVersion.toMicroseconds()-t.snapshotVersion.toMicroseconds()>=3e8||n.addedDocuments.size+n.modifiedDocuments.size+n.removedDocuments.size>0}(c,u,s)&&o.push(n.He.updateTargetData(t,u))}));let a=co();if(e.documentUpdates.forEach(((r,i)=>{e.resolvedLimboDocuments.has(r)&&o.push(n.persistence.referenceDelegate.updateLimboDocument(t,r))})),o.push(Jc(t,s,e.documentUpdates,r,void 0).next((t=>{a=t}))),!r.isEqual(Jr.min())){const e=n.He.getLastRemoteSnapshotVersion(t).next((e=>n.He.setTargetsMetadata(t,t.currentSequenceNumber,r)));o.push(e)}return xa.waitFor(o).next((()=>s.apply(t))).next((()=>n.Wn.Vn(t,a))).next((()=>a))})).then((t=>(n.qn=i,t)))}(n.localStore,e);e.targetChanges.forEach(((t,e)=>{const r=n.Uo.get(e);r&&(xr(t.addedDocuments.size+t.modifiedDocuments.size+t.removedDocuments.size<=1),t.addedDocuments.size>0?r.$o=!0:t.modifiedDocuments.size>0?xr(r.$o):t.removedDocuments.size>0&&(xr(r.$o),r.$o=!1))})),await Jh(n,t,e)}catch(t){await Tc(t)}}function jh(t,e,n){const r=Dr(t);if(r.isPrimaryClient&&0===n||!r.isPrimaryClient&&1===n){const t=[];r.Fo.forEach(((n,r)=>{const i=r.view.ro(e);i.snapshot&&t.push(i.snapshot)})),function(t,e){const n=Dr(t);n.onlineState=e;let r=!1;n.queries.forEach(((t,n)=>{for(const t of n.listeners)t.ro(e)&&(r=!0)})),r&&Eh(n)}(r.eventManager,e),t.length&&r.Oo.br(t),r.onlineState=e,r.isPrimaryClient&&r.sharedClientState.setOnlineState(e)}}async function qh(t,e,n){const r=Dr(t);r.sharedClientState.updateQueryState(e,"rejected",n);const i=r.Uo.get(e),s=i&&i.key;if(s){let t=new no(vi.comparator);t=t.insert(s,Li.newNoDocument(s,Jr.min()));const n=mo().add(s),i=new vo(Jr.min(),new Map,new so(Hr),t,n);await Vh(r,i),r.Bo=r.Bo.remove(s),r.Uo.delete(e),Qh(r)}else await tu(r.localStore,e,!1).then((()=>Gh(r,e,n))).catch(Tc)}async function Bh(t,e){const n=Dr(t),r=e.batch.batchId;try{const t=await function(t,e){const n=Dr(t);return n.persistence.runTransaction("Acknowledge batch","readwrite-primary",(t=>{const r=e.batch.keys(),i=n.Qn.newChangeBuffer({trackRemovals:!0});return function(t,e,n,r){const i=n.batch,s=i.keys();let o=xa.resolve();return s.forEach((t=>{o=o.next((()=>r.getEntry(e,t))).next((e=>{const s=n.docVersions.get(t);xr(null!==s),e.version.compareTo(s)<0&&(i.applyToRemoteDocument(e,n),e.isValidDocument()&&r.addEntry(e,n.commitVersion))}))})),o.next((()=>t.An.removeMutationBatch(e,i)))}(n,t,e,i).next((()=>i.apply(t))).next((()=>n.An.performConsistencyCheck(t))).next((()=>n.Wn.vn(t,r)))}))}(n.localStore,e);Wh(n,r,null),Kh(n,r),n.sharedClientState.updateMutationState(r,"acknowledged"),await Jh(n,t)}catch(t){await Tc(t)}}async function zh(t,e,n){const r=Dr(t);try{const t=await function(t,e){const n=Dr(t);return n.persistence.runTransaction("Reject batch","readwrite-primary",(t=>{let r;return n.An.lookupMutationBatch(t,e).next((e=>(xr(null!==e),r=e.keys(),n.An.removeMutationBatch(t,e)))).next((()=>n.An.performConsistencyCheck(t))).next((()=>n.Wn.vn(t,r)))}))}(r.localStore,e);Wh(r,e,n),Kh(r,e),r.sharedClientState.updateMutationState(e,"rejected",n),await Jh(r,t)}catch(n){await Tc(n)}}function Kh(t,e){(t.jo.get(e)||[]).forEach((t=>{t.resolve()})),t.jo.delete(e)}function Wh(t,e,n){const r=Dr(t);let i=r.Ko[r.currentUser.toKey()];if(i){const t=i.get(e);t&&(n?t.reject(n):t.resolve(),i=i.remove(e)),r.Ko[r.currentUser.toKey()]=i}}function Gh(t,e,n=null){t.sharedClientState.removeLocalQueryTarget(e);for(const r of t.Mo.get(e))t.Fo.delete(r),n&&t.Oo.zo(r,n);t.Mo.delete(e),t.isPrimaryClient&&t.qo.us(e).forEach((e=>{t.qo.containsKey(e)||Hh(t,e)}))}function Hh(t,e){t.Lo.delete(e.path.canonicalString());const n=t.Bo.get(e);null!==n&&(zu(t.remoteStore,n),t.Bo=t.Bo.remove(e),t.Uo.delete(n),Qh(t))}function $h(t,e,n){for(const r of n)r instanceof Ch?(t.qo.addReference(r.key,e),Yh(t,r)):r instanceof Dh?(Er("SyncEngine","Document no longer in limbo: "+r.key),t.qo.removeReference(r.key,e),t.qo.containsKey(r.key)||Hh(t,r.key)):Nr()}function Yh(t,e){const n=e.key,r=n.path.canonicalString();t.Bo.get(n)||t.Lo.has(r)||(Er("SyncEngine","New document in limbo: "+n),t.Lo.add(r),Qh(t))}function Qh(t){for(;t.Lo.size>0&&t.Bo.size<t.maxConcurrentLimboResolutions;){const e=t.Lo.values().next().value;t.Lo.delete(e);const n=new vi(ni.fromString(e)),r=t.Qo.next();t.Uo.set(r,new Ph(n)),t.Bo=t.Bo.insert(n,r),Bu(t.remoteStore,new za(ls(is(n.path)),r,2,Kr.I))}}async function Jh(t,e,n){const r=Dr(t),i=[],s=[],o=[];r.Fo.isEmpty()||(r.Fo.forEach(((t,a)=>{o.push(r.Go(a,e,n).then((t=>{if(t){r.isPrimaryClient&&r.sharedClientState.updateQueryState(a.targetId,t.fromCache?"not-current":"current"),i.push(t);const e=Wc.$n(a.targetId,t);s.push(e)}})))})),await Promise.all(o),r.Oo.br(i),await async function(t,e){const n=Dr(t);try{await n.persistence.runTransaction("notifyLocalViewChanges","readwrite",(t=>xa.forEach(e,(e=>xa.forEach(e.kn,(r=>n.persistence.referenceDelegate.addReference(t,e.targetId,r))).next((()=>xa.forEach(e.xn,(r=>n.persistence.referenceDelegate.removeReference(t,e.targetId,r)))))))))}catch(t){if(!Pa(t))throw t;Er("LocalStore","Failed to update sequence numbers: "+t)}for(const t of e){const e=t.targetId;if(!t.fromCache){const t=n.qn.get(e),r=t.snapshotVersion,i=t.withLastLimboFreeSnapshotVersion(r);n.qn=n.qn.insert(e,i)}}}(r.localStore,s))}async function Zh(t,e){const n=Dr(t);if(!n.currentUser.isEqual(e)){Er("SyncEngine","User change. New user:",e.toKey());const t=await Yc(n.localStore,e);n.currentUser=e,function(t,e){t.jo.forEach((t=>{t.forEach((t=>{t.reject(new Rr(Or.CANCELLED,"'waitForPendingWrites' promise is rejected due to a user change."))}))})),t.jo.clear()}(n),n.sharedClientState.handleUserChange(e,t.removedBatchIds,t.addedBatchIds),await Jh(n,t.Gn)}}function Xh(t,e){const n=Dr(t),r=n.Uo.get(e);if(r&&r.$o)return mo().add(r.key);{let t=mo();const r=n.Mo.get(e);if(!r)return t;for(const e of r){const r=n.Fo.get(e);t=t.unionWith(r.view.bo)}return t}}async function tl(t,e){const n=Dr(t),r=await eu(n.localStore,e.query,!0),i=e.view.ko(r);return n.isPrimaryClient&&$h(n,e.targetId,i.Co),i}async function el(t){const e=Dr(t);return ru(e.localStore).then((t=>Jh(e,t)))}async function nl(t,e,n,r){const i=Dr(t),s=await function(t,e){const n=Dr(t),r=Dr(n.An);return n.persistence.runTransaction("Lookup mutation documents","readonly",(t=>r.Zt(t,e).next((e=>e?n.Wn.vn(t,e):xa.resolve(null)))))}(i.localStore,e);null!==s?("pending"===n?await eh(i.remoteStore):"acknowledged"===n||"rejected"===n?(Wh(i,e,r||null),Kh(i,e),function(t,e){Dr(Dr(t).An).ee(e)}(i.localStore,e)):Nr(),await Jh(i,s)):Er("SyncEngine","Cannot apply mutation batch with id: "+e)}async function rl(t,e,n){const r=Dr(t),i=[],s=[];for(const t of e){let e;const n=r.Mo.get(t);if(n&&0!==n.length){e=await Xc(r.localStore,ls(n[0]));for(const t of n){const e=r.Fo.get(t),n=await tl(r,e);n.snapshot&&s.push(n.snapshot)}}else{const n=await nu(r.localStore,t);e=await Xc(r.localStore,n),await Fh(r,il(n),t,!1)}i.push(e)}return r.Oo.br(s),i}function il(t){return rs(t.path,t.collectionGroup,t.orderBy,t.filters,t.limit,"F",t.startAt,t.endAt)}function sl(t){const e=Dr(t);return Dr(Dr(e.localStore).persistence).Tn()}async function ol(t,e,n,r){const i=Dr(t);if(i.Wo)Er("SyncEngine","Ignoring unexpected query state notification.");else if(i.Mo.has(e))switch(n){case"current":case"not-current":{const t=await ru(i.localStore),r=vo.createSynthesizedRemoteEventForCurrentChange(e,"current"===n);await Jh(i,t,r);break}case"rejected":await tu(i.localStore,e,!0),Gh(i,e,r);break;default:Nr()}}async function al(t,e,n){const r=cl(t);if(r.Wo){for(const t of e){if(r.Mo.has(t)){Er("SyncEngine","Adding an already active target "+t);continue}const e=await nu(r.localStore,t),n=await Xc(r.localStore,e);await Fh(r,il(e),n.targetId,!1),Bu(r.remoteStore,n)}for(const t of n)r.Mo.has(t)&&await tu(r.localStore,t,!1).then((()=>{zu(r.remoteStore,t),Gh(r,t)})).catch(Tc)}}function cl(t){const e=Dr(t);return e.remoteStore.remoteSyncer.applyRemoteEvent=Vh.bind(null,e),e.remoteStore.remoteSyncer.getRemoteKeysForTarget=Xh.bind(null,e),e.remoteStore.remoteSyncer.rejectListen=qh.bind(null,e),e.Oo.br=Th.bind(null,e.eventManager),e.Oo.zo=_h.bind(null,e.eventManager),e}function ul(t){const e=Dr(t);return e.remoteStore.remoteSyncer.applySuccessfulWrite=Bh.bind(null,e),e.remoteStore.remoteSyncer.rejectFailedWrite=zh.bind(null,e),e}class hl{constructor(){this.synchronizeTabs=!1}async initialize(t){this.k=Ou(t.databaseInfo.databaseId),this.sharedClientState=this.Jo(t),this.persistence=this.Yo(t),await this.persistence.start(),this.gcScheduler=this.Xo(t),this.localStore=this.Zo(t)}Xo(t){return null}Zo(t){return $c(this.persistence,new Gc,t.initialUser,this.k)}Yo(t){return new du(pu.ks,this.k)}Jo(t){return new Eu}async terminate(){this.gcScheduler&&this.gcScheduler.stop(),await this.sharedClientState.shutdown(),await this.persistence.shutdown()}}class ll extends hl{constructor(t,e,n){super(),this.ta=t,this.cacheSizeBytes=e,this.forceOwnership=n,this.synchronizeTabs=!1}async initialize(t){await super.initialize(t),await async function(t){const e=Dr(t);return e.persistence.runTransaction("Synchronize last document change read time","readonly",(t=>function(t){const e=Pc(t);let n=Jr.min();return e.jt({index:ya.readTimeIndex,reverse:!0},((t,e,r)=>{e.readTime&&(n=$a(e.readTime)),r.done()})).next((()=>n))}(t))).then((t=>{e.jn=t}))}(this.localStore),await this.ta.initialize(this,t),await ul(this.ta.syncEngine),await eh(this.ta.remoteStore),await this.persistence.sn((()=>(this.gcScheduler&&!this.gcScheduler.started&&this.gcScheduler.start(this.localStore),Promise.resolve())))}Zo(t){return $c(this.persistence,new Gc,t.initialUser,this.k)}Xo(t){const e=this.persistence.referenceDelegate.garbageCollector;return new Sc(e,t.asyncQueue)}Yo(t){const e=Bc(t.databaseInfo.databaseId,t.databaseInfo.persistenceKey),n=void 0!==this.cacheSizeBytes?uc.withCacheSize(this.cacheSizeBytes):uc.DEFAULT;return new Vc(this.synchronizeTabs,e,t.clientId,n,t.asyncQueue,Cu(),Du(),this.k,this.sharedClientState,!!this.forceOwnership)}Jo(t){return new Eu}}class dl extends ll{constructor(t,e){super(t,e,!1),this.ta=t,this.cacheSizeBytes=e,this.synchronizeTabs=!0}async initialize(t){await super.initialize(t);const e=this.ta.syncEngine;this.sharedClientState instanceof _u&&(this.sharedClientState.syncEngine={mi:nl.bind(null,e),gi:ol.bind(null,e),yi:al.bind(null,e),Tn:sl.bind(null,e),_i:el.bind(null,e)},await this.sharedClientState.start()),await this.persistence.sn((async t=>{await async function(t,e){const n=Dr(t);if(cl(n),ul(n),!0===e&&!0!==n.Wo){const t=n.sharedClientState.getAllActiveQueryTargets(),e=await rl(n,t.toArray());n.Wo=!0,await hh(n.remoteStore,!0);for(const t of e)Bu(n.remoteStore,t)}else if(!1===e&&!1!==n.Wo){const t=[];let e=Promise.resolve();n.Mo.forEach(((r,i)=>{n.sharedClientState.isLocalQueryTarget(i)?t.push(i):e=e.then((()=>(Gh(n,i),tu(n.localStore,i,!0)))),zu(n.remoteStore,i)})),await e,await rl(n,t),function(t){const e=Dr(t);e.Uo.forEach(((t,n)=>{zu(e.remoteStore,n)})),e.qo.hs(),e.Uo=new Map,e.Bo=new no(vi.comparator)}(n),n.Wo=!1,await hh(n.remoteStore,!1)}}(this.ta.syncEngine,t),this.gcScheduler&&(t&&!this.gcScheduler.started?this.gcScheduler.start(this.localStore):t||this.gcScheduler.stop())}))}Jo(t){const e=Cu();if(!_u.Pt(e))throw new Rr(Or.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");const n=Bc(t.databaseInfo.databaseId,t.databaseInfo.persistenceKey);return new _u(e,t.asyncQueue,n,t.clientId,t.initialUser)}}class fl{async initialize(t,e){this.localStore||(this.localStore=t.localStore,this.sharedClientState=t.sharedClientState,this.datastore=this.createDatastore(e),this.remoteStore=this.createRemoteStore(e),this.eventManager=this.createEventManager(e),this.syncEngine=this.createSyncEngine(e,!t.synchronizeTabs),this.sharedClientState.onlineStateHandler=t=>jh(this.syncEngine,t,1),this.remoteStore.remoteSyncer.handleCredentialChange=Zh.bind(null,this.syncEngine),await hh(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(t){return new bh}createDatastore(t){const e=Ou(t.databaseInfo.databaseId),n=(r=t.databaseInfo,new xu(r));var r;return function(t,e,n,r){return new Fu(t,e,n,r)}(t.authCredentials,t.appCheckCredentials,n,e)}createRemoteStore(t){return e=this.localStore,n=this.datastore,r=t.asyncQueue,i=t=>jh(this.syncEngine,t,0),s=ku.Pt()?new ku:new Su,new Vu(e,n,r,i,s);var e,n,r,i,s}createSyncEngine(t,e){return function(t,e,n,r,i,s,o){const a=new Lh(t,e,n,r,i,s);return o&&(a.Wo=!0),a}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,t.initialUser,t.maxConcurrentLimboResolutions,e)}terminate(){return async function(t){const e=Dr(t);Er("RemoteStore","RemoteStore shutting down."),e.Gr.add(5),await qu(e),e.Hr.shutdown(),e.Jr.set("Unknown")}(this.remoteStore)}}function pl(t,e=10240){let n=0;return{async read(){if(n<t.byteLength){const r={value:t.slice(n,n+e),done:!1};return n+=e,r}return{done:!0}},async cancel(){},releaseLock(){},closed:Promise.reject("unimplemented")}}class ml{constructor(t){this.observer=t,this.muted=!1}next(t){this.observer.next&&this.ea(this.observer.next,t)}error(t){this.observer.error?this.ea(this.observer.error,t):console.error("Uncaught Error in snapshot listener:",t)}na(){this.muted=!0}ea(t,e){this.muted||setTimeout((()=>{this.muted||t(e)}),0)}}class gl{constructor(t,e){this.sa=t,this.k=e,this.metadata=new Pr,this.buffer=new Uint8Array,this.ia=new TextDecoder("utf-8"),this.ra().then((t=>{t&&t._o()?this.metadata.resolve(t.payload.metadata):this.metadata.reject(new Error(`The first element of the bundle is not a metadata, it is\n ${JSON.stringify(null==t?void 0:t.payload)}`))}),(t=>this.metadata.reject(t)))}close(){return this.sa.cancel()}async getMetadata(){return this.metadata.promise}async Ho(){return await this.getMetadata(),this.ra()}async ra(){const t=await this.oa();if(null===t)return null;const e=this.ia.decode(t),n=Number(e);isNaN(n)&&this.aa(`length string (${e}) is not valid number`);const r=await this.ca(n);return new kh(JSON.parse(r),t.length+n)}ua(){return this.buffer.findIndex((t=>t==="{".charCodeAt(0)))}async oa(){for(;this.ua()<0&&!await this.ha(););if(0===this.buffer.length)return null;const t=this.ua();t<0&&this.aa("Reached the end of bundle when a length string is expected.");const e=this.buffer.slice(0,t);return this.buffer=this.buffer.slice(t),e}async ca(t){for(;this.buffer.length<t;)await this.ha()&&this.aa("Reached the end of bundle when more is expected.");const e=this.ia.decode(this.buffer.slice(0,t));return this.buffer=this.buffer.slice(t),e}aa(t){throw this.sa.cancel(),new Error(`Invalid bundle format: ${t}`)}async ha(){const t=await this.sa.read();if(!t.done){const e=new Uint8Array(this.buffer.length+t.value.length);e.set(this.buffer),e.set(t.value,this.buffer.length),this.buffer=e}return t.done}}class yl{constructor(t){this.datastore=t,this.readVersions=new Map,this.mutations=[],this.committed=!1,this.lastWriteError=null,this.writtenDocs=new Set}async lookup(t){if(this.ensureCommitNotCalled(),this.mutations.length>0)throw new Rr(Or.INVALID_ARGUMENT,"Firestore transactions require all reads to be executed before all writes.");const e=await async function(t,e){const n=Dr(t),r=jo(n.k)+"/documents",i={documents:e.map((t=>Mo(n.k,t)))},s=await n.ji("BatchGetDocuments",r,i),o=new Map;s.forEach((t=>{const e=function(t,e){return"found"in e?function(t,e){xr(!!e.found),e.found.name,e.found.updateTime;const n=Fo(t,e.found.name),r=Ro(e.found.updateTime),i=new Ri({mapValue:{fields:e.found.fields}});return Li.newFoundDocument(n,r,i)}(t,e):"missing"in e?function(t,e){xr(!!e.missing),xr(!!e.readTime);const n=Fo(t,e.missing),r=Ro(e.readTime);return Li.newNoDocument(n,r)}(t,e):Nr()}(n.k,t);o.set(e.key.toString(),e)}));const a=[];return e.forEach((t=>{const e=o.get(t.toString());xr(!!e),a.push(e)})),a}(this.datastore,t);return e.forEach((t=>this.recordVersion(t))),e}set(t,e){this.write(e.toMutation(t,this.precondition(t))),this.writtenDocs.add(t.toString())}update(t,e){try{this.write(e.toMutation(t,this.preconditionForUpdate(t)))}catch(t){this.lastWriteError=t}this.writtenDocs.add(t.toString())}delete(t){this.write(new Ys(t,this.precondition(t))),this.writtenDocs.add(t.toString())}async commit(){if(this.ensureCommitNotCalled(),this.lastWriteError)throw this.lastWriteError;const t=this.readVersions;this.mutations.forEach((e=>{t.delete(e.key.toString())})),t.forEach(((t,e)=>{const n=vi.fromPath(e);this.mutations.push(new Qs(n,this.precondition(n)))})),await async function(t,e){const n=Dr(t),r=jo(n.k)+"/documents",i={writes:e.map((t=>Ko(n.k,t)))};await n.Bi("Commit",r,i)}(this.datastore,this.mutations),this.committed=!0}recordVersion(t){let e;if(t.isFoundDocument())e=t.version;else{if(!t.isNoDocument())throw Nr();e=Jr.min()}const n=this.readVersions.get(t.key.toString());if(n){if(!e.isEqual(n))throw new Rr(Or.ABORTED,"Document version changed between two reads.")}else this.readVersions.set(t.key.toString(),e)}precondition(t){const e=this.readVersions.get(t.toString());return!this.writtenDocs.has(t.toString())&&e?Ms.updateTime(e):Ms.none()}preconditionForUpdate(t){const e=this.readVersions.get(t.toString());if(!this.writtenDocs.has(t.toString())&&e){if(e.isEqual(Jr.min()))throw new Rr(Or.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return Ms.updateTime(e)}return Ms.exists(!0)}write(t){this.ensureCommitNotCalled(),this.mutations.push(t)}ensureCommitNotCalled(){}}class vl{constructor(t,e,n,r){this.asyncQueue=t,this.datastore=e,this.updateFunction=n,this.deferred=r,this.la=5,this.ur=new Ru(this.asyncQueue,"transaction_retry")}run(){this.la-=1,this.fa()}fa(){this.ur.Zi((async()=>{const t=new yl(this.datastore),e=this.da(t);e&&e.then((e=>{this.asyncQueue.enqueueAndForget((()=>t.commit().then((()=>{this.deferred.resolve(e)})).catch((t=>{this.wa(t)}))))})).catch((t=>{this.wa(t)}))}))}da(t){try{const e=this.updateFunction(t);return!mi(e)&&e.catch&&e.then?e:(this.deferred.reject(Error("Transaction callback must return a Promise")),null)}catch(t){return this.deferred.reject(t),null}}wa(t){this.la>0&&this._a(t)?(this.la-=1,this.asyncQueue.enqueueAndForget((()=>(this.fa(),Promise.resolve())))):this.deferred.reject(t)}_a(t){if("FirebaseError"===t.name){const e=t.code;return"aborted"===e||"failed-precondition"===e||!to(e)}return!1}}class bl{constructor(t,e,n,r){this.authCredentials=t,this.appCheckCredentials=e,this.asyncQueue=n,this.databaseInfo=r,this.user=br.UNAUTHENTICATED,this.clientId=Gr.A(),this.authCredentialListener=()=>Promise.resolve(),this.authCredentials.start(n,(async t=>{Er("FirestoreClient","Received user=",t.uid),await this.authCredentialListener(t),this.user=t})),this.appCheckCredentials.start(n,(()=>Promise.resolve()))}async getConfiguration(){return{asyncQueue:this.asyncQueue,databaseInfo:this.databaseInfo,clientId:this.clientId,authCredentials:this.authCredentials,appCheckCredentials:this.appCheckCredentials,initialUser:this.user,maxConcurrentLimboResolutions:100}}setCredentialChangeListener(t){this.authCredentialListener=t}verifyNotTerminated(){if(this.asyncQueue.isShuttingDown)throw new Rr(Or.FAILED_PRECONDITION,"The client has already been terminated.")}terminate(){this.asyncQueue.enterRestrictedMode();const t=new Pr;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted((async()=>{try{this.onlineComponents&&await this.onlineComponents.terminate(),this.offlineComponents&&await this.offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),t.resolve()}catch(e){const n=ph(e,"Failed to shutdown persistence");t.reject(n)}})),t.promise}}async function wl(t,e){t.asyncQueue.verifyOperationInProgress(),Er("FirestoreClient","Initializing OfflineComponentProvider");const n=await t.getConfiguration();await e.initialize(n);let r=n.initialUser;t.setCredentialChangeListener((async t=>{r.isEqual(t)||(await Yc(e.localStore,t),r=t)})),e.persistence.setDatabaseDeletedListener((()=>t.terminate())),t.offlineComponents=e}async function Il(t,e){t.asyncQueue.verifyOperationInProgress();const n=await Tl(t);Er("FirestoreClient","Initializing OnlineComponentProvider");const r=await t.getConfiguration();await e.initialize(n,r),t.setCredentialChangeListener((t=>async function(t,e){const n=Dr(t);n.asyncQueue.verifyOperationInProgress(),Er("RemoteStore","RemoteStore received new credentials");const r=$u(n);n.Gr.add(3),await qu(n),r&&n.Jr.set("Unknown"),await n.remoteSyncer.handleCredentialChange(e),n.Gr.delete(3),await ju(n)}(e.remoteStore,t))),t.onlineComponents=e}async function Tl(t){return t.offlineComponents||(Er("FirestoreClient","Using default OfflineComponentProvider"),await wl(t,new hl)),t.offlineComponents}async function _l(t){return t.onlineComponents||(Er("FirestoreClient","Using default OnlineComponentProvider"),await Il(t,new fl)),t.onlineComponents}function El(t){return Tl(t).then((t=>t.persistence))}function Sl(t){return Tl(t).then((t=>t.localStore))}function kl(t){return _l(t).then((t=>t.remoteStore))}function Al(t){return _l(t).then((t=>t.syncEngine))}async function Nl(t){const e=await _l(t),n=e.eventManager;return n.onListen=Mh.bind(null,e.syncEngine),n.onUnlisten=Uh.bind(null,e.syncEngine),n}function xl(t,e,n={}){const r=new Pr;return t.asyncQueue.enqueueAndForget((async()=>function(t,e,n,r,i){const s=new ml({next:s=>{e.enqueueAndForget((()=>Ih(t,o)));const a=s.docs.has(n);!a&&s.fromCache?i.reject(new Rr(Or.UNAVAILABLE,"Failed to get document because the client is offline.")):a&&s.fromCache&&r&&"server"===r.source?i.reject(new Rr(Or.UNAVAILABLE,'Failed to get document from server. (However, this document does exist in the local cache. Run again without setting source to "server" to retrieve the cached document.)')):i.resolve(s)},error:t=>i.reject(t)}),o=new Sh(is(n.path),s,{includeMetadataChanges:!0,wo:!0});return wh(t,o)}(await Nl(t),t.asyncQueue,e,n,r))),r.promise}function Cl(t,e,n={}){const r=new Pr;return t.asyncQueue.enqueueAndForget((async()=>function(t,e,n,r,i){const s=new ml({next:n=>{e.enqueueAndForget((()=>Ih(t,o))),n.fromCache&&"server"===r.source?i.reject(new Rr(Or.UNAVAILABLE,'Failed to get documents from server. (However, these documents may exist in the local cache. Run again without setting source to "server" to retrieve the cached documents.)')):i.resolve(n)},error:t=>i.reject(t)}),o=new Sh(n,s,{includeMetadataChanges:!0,wo:!0});return wh(t,o)}(await Nl(t),t.asyncQueue,e,n,r))),r.promise}class Dl{constructor(t,e,n,r,i,s,o,a){this.databaseId=t,this.appId=e,this.persistenceKey=n,this.host=r,this.ssl=i,this.forceLongPolling=s,this.autoDetectLongPolling=o,this.useFetchStreams=a}}class Ol{constructor(t,e){this.projectId=t,this.database=e||"(default)"}get isDefaultDatabase(){return"(default)"===this.database}isEqual(t){return t instanceof Ol&&t.projectId===this.projectId&&t.database===this.database}}const Rl=new Map;function Pl(t,e,n){if(!n)throw new Rr(Or.INVALID_ARGUMENT,`Function ${t}() cannot be called with an empty ${e}.`)}function Ll(t,e,n,r){if(!0===e&&!0===r)throw new Rr(Or.INVALID_ARGUMENT,`${t} and ${n} cannot be used together.`)}function Ml(t){if(!vi.isDocumentKey(t))throw new Rr(Or.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${t} has ${t.length}.`)}function Fl(t){if(vi.isDocumentKey(t))throw new Rr(Or.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${t} has ${t.length}.`)}function Ul(t){if(void 0===t)return"undefined";if(null===t)return"null";if("string"==typeof t)return t.length>20&&(t=`${t.substring(0,20)}...`),JSON.stringify(t);if("number"==typeof t||"boolean"==typeof t)return""+t;if("object"==typeof t){if(t instanceof Array)return"an array";{const e=function(t){return t.constructor?t.constructor.name:null}(t);return e?`a custom ${e} object`:"an object"}}return"function"==typeof t?"a function":Nr()}function Vl(t,e){if("_delegate"in t&&(t=t._delegate),!(t instanceof e)){if(e.name===t.constructor.name)throw new Rr(Or.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{const n=Ul(t);throw new Rr(Or.INVALID_ARGUMENT,`Expected type '${e.name}', but it was: ${n}`)}}return t}function jl(t,e){if(e<=0)throw new Rr(Or.INVALID_ARGUMENT,`Function ${t}() requires a positive number, but it was: ${e}.`)}class ql{constructor(t){var e;if(void 0===t.host){if(void 0!==t.ssl)throw new Rr(Or.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===(e=t.ssl)||void 0===e||e;if(this.credentials=t.credentials,this.ignoreUndefinedProperties=!!t.ignoreUndefinedProperties,void 0===t.cacheSizeBytes)this.cacheSizeBytes=41943040;else{if(-1!==t.cacheSizeBytes&&t.cacheSizeBytes<1048576)throw new Rr(Or.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=t.cacheSizeBytes}this.experimentalForceLongPolling=!!t.experimentalForceLongPolling,this.experimentalAutoDetectLongPolling=!!t.experimentalAutoDetectLongPolling,this.useFetchStreams=!!t.useFetchStreams,Ll("experimentalForceLongPolling",t.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",t.experimentalAutoDetectLongPolling)}isEqual(t){return this.host===t.host&&this.ssl===t.ssl&&this.credentials===t.credentials&&this.cacheSizeBytes===t.cacheSizeBytes&&this.experimentalForceLongPolling===t.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===t.experimentalAutoDetectLongPolling&&this.ignoreUndefinedProperties===t.ignoreUndefinedProperties&&this.useFetchStreams===t.useFetchStreams}}class Bl{constructor(t,e,n){this._authCredentials=e,this._appCheckCredentials=n,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new ql({}),this._settingsFrozen=!1,t instanceof Ol?this._databaseId=t:(this._app=t,this._databaseId=function(t){if(!Object.prototype.hasOwnProperty.apply(t.options,["projectId"]))throw new Rr(Or.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new Ol(t.options.projectId)}(t))}get app(){if(!this._app)throw new Rr(Or.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app}get _initialized(){return this._settingsFrozen}get _terminated(){return void 0!==this._terminateTask}_setSettings(t){if(this._settingsFrozen)throw new Rr(Or.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 ql(t),void 0!==t.credentials&&(this._authCredentials=function(t){if(!t)return new Mr;switch(t.type){case"gapi":const e=t.client;return xr(!("object"!=typeof e||null===e||!e.auth||!e.auth.getAuthHeaderValueForFirstParty)),new jr(e,t.sessionIndex||"0",t.iamToken||null);case"provider":return t.client;default:throw new Rr(Or.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invalid credential type")}}(t.credentials))}_getSettings(){return this._settings}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return this._terminateTask||(this._terminateTask=this._terminate()),this._terminateTask}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return function(t){const e=Rl.get(t);e&&(Er("ComponentProvider","Removing Datastore"),Rl.delete(t),e.terminate())}(this),Promise.resolve()}}function zl(t,e,n,r={}){var i;const s=(t=Vl(t,Bl))._getSettings();if("firestore.googleapis.com"!==s.host&&s.host!==e&&kr("Host has been set in both settings() and useEmulator(), emulator host will be used"),t._setSettings(Object.assign(Object.assign({},s),{host:`${e}:${n}`,ssl:!1})),r.mockUserToken){let e,n;if("string"==typeof r.mockUserToken)e=r.mockUserToken,n=br.MOCK_USER;else{e=(0,a.Sg)(r.mockUserToken,null===(i=t._app)||void 0===i?void 0:i.options.projectId);const s=r.mockUserToken.sub||r.mockUserToken.user_id;if(!s)throw new Rr(Or.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");n=new br(s)}t._authCredentials=new Fr(new Lr(e,n))}}class Kl{constructor(t,e,n){this.converter=e,this._key=n,this.type="document",this.firestore=t}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new Gl(this.firestore,this.converter,this._key.path.popLast())}withConverter(t){return new Kl(this.firestore,t,this._key)}}class Wl{constructor(t,e,n){this.converter=e,this._query=n,this.type="query",this.firestore=t}withConverter(t){return new Wl(this.firestore,t,this._query)}}class Gl extends Wl{constructor(t,e,n){super(t,e,is(n)),this._path=n,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){const t=this._path.popLast();return t.isEmpty()?null:new Kl(this.firestore,null,new vi(t))}withConverter(t){return new Gl(this.firestore,t,this._path)}}function Hl(t,e,...n){if(t=(0,a.m9)(t),Pl("collection","path",e),t instanceof Bl){const r=ni.fromString(e,...n);return Fl(r),new Gl(t,null,r)}{if(!(t instanceof Kl||t instanceof Gl))throw new Rr(Or.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=t._path.child(ni.fromString(e,...n));return Fl(r),new Gl(t.firestore,null,r)}}function $l(t,e){if(t=Vl(t,Bl),Pl("collectionGroup","collection id",e),e.indexOf("/")>=0)throw new Rr(Or.INVALID_ARGUMENT,`Invalid collection ID '${e}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);return new Wl(t,null,function(t){return new ns(ni.emptyPath(),t)}(e))}function Yl(t,e,...n){if(t=(0,a.m9)(t),1===arguments.length&&(e=Gr.A()),Pl("doc","path",e),t instanceof Bl){const r=ni.fromString(e,...n);return Ml(r),new Kl(t,null,new vi(r))}{if(!(t instanceof Kl||t instanceof Gl))throw new Rr(Or.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=t._path.child(ni.fromString(e,...n));return Ml(r),new Kl(t.firestore,t instanceof Gl?t.converter:null,new vi(r))}}function Ql(t,e){return t=(0,a.m9)(t),e=(0,a.m9)(e),(t instanceof Kl||t instanceof Gl)&&(e instanceof Kl||e instanceof Gl)&&t.firestore===e.firestore&&t.path===e.path&&t.converter===e.converter}function Jl(t,e){return t=(0,a.m9)(t),e=(0,a.m9)(e),t instanceof Wl&&e instanceof Wl&&t.firestore===e.firestore&&fs(t._query,e._query)&&t.converter===e.converter}class Zl{constructor(){this.ma=Promise.resolve(),this.ga=[],this.ya=!1,this.pa=[],this.Ta=null,this.Ea=!1,this.Ia=!1,this.Aa=[],this.ur=new Ru(this,"async_queue_retry"),this.Ra=()=>{const t=Du();t&&Er("AsyncQueue","Visibility state changed to "+t.visibilityState),this.ur.er()};const t=Du();t&&"function"==typeof t.addEventListener&&t.addEventListener("visibilitychange",this.Ra)}get isShuttingDown(){return this.ya}enqueueAndForget(t){this.enqueue(t)}enqueueAndForgetEvenWhileRestricted(t){this.ba(),this.Pa(t)}enterRestrictedMode(t){if(!this.ya){this.ya=!0,this.Ia=t||!1;const e=Du();e&&"function"==typeof e.removeEventListener&&e.removeEventListener("visibilitychange",this.Ra)}}enqueue(t){if(this.ba(),this.ya)return new Promise((()=>{}));const e=new Pr;return this.Pa((()=>this.ya&&this.Ia?Promise.resolve():(t().then(e.resolve,e.reject),e.promise))).then((()=>e.promise))}enqueueRetryable(t){this.enqueueAndForget((()=>(this.ga.push(t),this.va())))}async va(){if(0!==this.ga.length){try{await this.ga[0](),this.ga.shift(),this.ur.reset()}catch(t){if(!Pa(t))throw t;Er("AsyncQueue","Operation failed with retryable error: "+t)}this.ga.length>0&&this.ur.Zi((()=>this.va()))}}Pa(t){const e=this.ma.then((()=>(this.Ea=!0,t().catch((t=>{this.Ta=t,this.Ea=!1;const e=function(t){let e=t.message||"";return t.stack&&(e=t.stack.includes(t.message)?t.stack:t.message+"\n"+t.stack),e}(t);throw Sr("INTERNAL UNHANDLED ERROR: ",e),t})).then((t=>(this.Ea=!1,t))))));return this.ma=e,e}enqueueAfterDelay(t,e,n){this.ba(),this.Aa.indexOf(t)>-1&&(e=0);const r=fh.createAndSchedule(this,t,e,n,(t=>this.Va(t)));return this.pa.push(r),r}ba(){this.Ta&&Nr()}verifyOperationInProgress(){}async Sa(){let t;do{t=this.ma,await t}while(t!==this.ma)}Da(t){for(const e of this.pa)if(e.timerId===t)return!0;return!1}Ca(t){return this.Sa().then((()=>{this.pa.sort(((t,e)=>t.targetTimeMs-e.targetTimeMs));for(const e of this.pa)if(e.skipDelay(),"all"!==t&&e.timerId===t)break;return this.Sa()}))}Na(t){this.Aa.push(t)}Va(t){const e=this.pa.indexOf(t);this.pa.splice(e,1)}}function Xl(t){return function(t,e){if("object"!=typeof t||null===t)return!1;const n=t;for(const t of["next","error","complete"])if(t in n&&"function"==typeof n[t])return!0;return!1}(t)}class td{constructor(){this._progressObserver={},this._taskCompletionResolver=new Pr,this._lastProgress={taskState:"Running",totalBytes:0,totalDocuments:0,bytesLoaded:0,documentsLoaded:0}}onProgress(t,e,n){this._progressObserver={next:t,error:e,complete:n}}catch(t){return this._taskCompletionResolver.promise.catch(t)}then(t,e){return this._taskCompletionResolver.promise.then(t,e)}_completeWith(t){this._updateProgress(t),this._progressObserver.complete&&this._progressObserver.complete(),this._taskCompletionResolver.resolve(t)}_failWith(t){this._lastProgress.taskState="Error",this._progressObserver.next&&this._progressObserver.next(this._lastProgress),this._progressObserver.error&&this._progressObserver.error(t),this._taskCompletionResolver.reject(t)}_updateProgress(t){this._lastProgress=t,this._progressObserver.next&&this._progressObserver.next(t)}}const ed=-1;class nd extends Bl{constructor(t,e,n){super(t,e,n),this.type="firestore",this._queue=new Zl,this._persistenceKey="name"in t?t.name:"[DEFAULT]"}_terminate(){return this._firestoreClient||od(this),this._firestoreClient.terminate()}}function rd(t,e){const n=(0,i.qX)(t,"firestore");if(n.isInitialized()){const t=n.getImmediate(),r=n.getOptions();if((0,a.vZ)(r,e))return t;throw new Rr(Or.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!==e.cacheSizeBytes&&-1!==e.cacheSizeBytes&&e.cacheSizeBytes<1048576)throw new Rr(Or.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");return n.initialize({options:e})}function id(t=(0,i.Mq)()){return(0,i.qX)(t,"firestore").getImmediate()}function sd(t){return t._firestoreClient||od(t),t._firestoreClient.verifyNotTerminated(),t._firestoreClient}function od(t){var e;const n=t._freezeSettings(),r=function(t,e,n,r){return new Dl(t,e,n,r.host,r.ssl,r.experimentalForceLongPolling,r.experimentalAutoDetectLongPolling,r.useFetchStreams)}(t._databaseId,(null===(e=t._app)||void 0===e?void 0:e.options.appId)||"",t._persistenceKey,n);t._firestoreClient=new bl(t._authCredentials,t._appCheckCredentials,t._queue,r)}function ad(t,e){yd(t=Vl(t,nd));const n=sd(t),r=t._freezeSettings(),i=new fl;return ud(n,i,new ll(i,r.cacheSizeBytes,null==e?void 0:e.forceOwnership))}function cd(t){yd(t=Vl(t,nd));const e=sd(t),n=t._freezeSettings(),r=new fl;return ud(e,r,new dl(r,n.cacheSizeBytes))}function ud(t,e,n){const r=new Pr;return t.asyncQueue.enqueue((async()=>{try{await wl(t,n),await Il(t,e),r.resolve()}catch(t){if(!function(t){return"FirebaseError"===t.name?t.code===Or.FAILED_PRECONDITION||t.code===Or.UNIMPLEMENTED:!("undefined"!=typeof DOMException&&t instanceof DOMException)||22===t.code||20===t.code||11===t.code}(t))throw t;console.warn("Error enabling offline persistence. Falling back to persistence disabled: "+t),r.reject(t)}})).then((()=>r.promise))}function hd(t){if(t._initialized&&!t._terminated)throw new Rr(Or.FAILED_PRECONDITION,"Persistence can only be cleared before a Firestore instance is initialized or after it is terminated.");const e=new Pr;return t._queue.enqueueAndForgetEvenWhileRestricted((async()=>{try{await async function(t){if(!Da.Pt())return Promise.resolve();const e=t+"main";await Da.delete(e)}(Bc(t._databaseId,t._persistenceKey)),e.resolve()}catch(t){e.reject(t)}})),e.promise}function ld(t){return function(t){const e=new Pr;return t.asyncQueue.enqueueAndForget((async()=>async function(t,e){const n=Dr(t);$u(n.remoteStore)||Er("SyncEngine","The network is disabled. The task returned by 'awaitPendingWrites()' will not complete until the network is enabled.");try{const t=await function(t){const e=Dr(t);return e.persistence.runTransaction("Get highest unacknowledged batch id","readonly",(t=>e.An.getHighestUnacknowledgedBatchId(t)))}(n.localStore);if(-1===t)return void e.resolve();const r=n.jo.get(t)||[];r.push(e),n.jo.set(t,r)}catch(t){const n=ph(t,"Initialization of waitForPendingWrites() operation failed");e.reject(n)}}(await Al(t),e))),e.promise}(sd(t=Vl(t,nd)))}function dd(t){return function(t){return t.asyncQueue.enqueue((async()=>{const e=await El(t),n=await kl(t);return e.setNetworkEnabled(!0),function(t){const e=Dr(t);return e.Gr.delete(0),ju(e)}(n)}))}(sd(t=Vl(t,nd)))}function fd(t){return function(t){return t.asyncQueue.enqueue((async()=>{const e=await El(t),n=await kl(t);return e.setNetworkEnabled(!1),async function(t){const e=Dr(t);e.Gr.add(0),await qu(e),e.Jr.set("Offline")}(n)}))}(sd(t=Vl(t,nd)))}function pd(t){return(0,i.wN)(t.app,"firestore"),t._delete()}function md(t,e){const n=sd(t=Vl(t,nd)),r=new td;return function(t,e,n,r){const i=function(t,e){let n;return n="string"==typeof t?(new TextEncoder).encode(t):t,function(t,e){return new gl(t,e)}(function(t,e){if(t instanceof Uint8Array)return pl(t,e);if(t instanceof ArrayBuffer)return pl(new Uint8Array(t),e);if(t instanceof ReadableStream)return t.getReader();throw new Error("Source of `toByteStreamReader` has to be a ArrayBuffer or ReadableStream")}(n),e)}(n,Ou(e));t.asyncQueue.enqueueAndForget((async()=>{!function(t,e,n){const r=Dr(t);(async function(t,e,n){try{const r=await e.getMetadata();if(await function(t,e){const n=Dr(t),r=Ro(e.createTime);return n.persistence.runTransaction("hasNewerBundle","readonly",(t=>n.Ye.getBundleMetadata(t,e.id))).then((t=>!!t&&t.createTime.compareTo(r)>=0))}(t.localStore,r))return await e.close(),void n._completeWith(function(t){return{taskState:"Success",documentsLoaded:t.totalDocuments,bytesLoaded:t.totalBytes,totalDocuments:t.totalDocuments,totalBytes:t.totalBytes}}(r));n._updateProgress(xh(r));const i=new Nh(r,t.localStore,e.k);let s=await e.Ho();for(;s;){const t=await i.yo(s);t&&n._updateProgress(t),s=await e.Ho()}const o=await i.complete();await Jh(t,o.In,void 0),await function(t,e){const n=Dr(t);return n.persistence.runTransaction("Save bundle","readwrite",(t=>n.Ye.saveBundleMetadata(t,e)))}(t.localStore,r),n._completeWith(o.progress)}catch(t){kr("SyncEngine",`Loading bundle failed with ${t}`),n._failWith(t)}})(r,e,n).then((()=>{r.sharedClientState.notifyBundleLoaded()}))}(await Al(t),i,r)}))}(n,t._databaseId,e,r),r}function gd(t,e){return function(t,e){return t.asyncQueue.enqueue((async()=>function(t,e){const n=Dr(t);return n.persistence.runTransaction("Get named query","readonly",(t=>n.Ye.getNamedQuery(t,e)))}(await Sl(t),e)))}(sd(t=Vl(t,nd)),e).then((e=>e?new Wl(t,null,e.query):null))}function yd(t){if(t._initialized||t._terminated)throw new Rr(Or.FAILED_PRECONDITION,"Firestore has already been started and persistence can no longer be enabled. You can only enable persistence before calling any other methods on a Firestore object.")}class vd{constructor(...t){for(let e=0;e<t.length;++e)if(0===t[e].length)throw new Rr(Or.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new ii(t)}isEqual(t){return this._internalPath.isEqual(t._internalPath)}}function bd(){return new vd("__name__")}class wd{constructor(t){this._byteString=t}static fromBase64String(t){try{return new wd(ai.fromBase64String(t))}catch(t){throw new Rr(Or.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+t)}}static fromUint8Array(t){return new wd(ai.fromUint8Array(t))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(t){return this._byteString.isEqual(t._byteString)}}class Id{constructor(t){this._methodName=t}}class Td{constructor(t,e){if(!isFinite(t)||t<-90||t>90)throw new Rr(Or.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+t);if(!isFinite(e)||e<-180||e>180)throw new Rr(Or.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+e);this._lat=t,this._long=e}get latitude(){return this._lat}get longitude(){return this._long}isEqual(t){return this._lat===t._lat&&this._long===t._long}toJSON(){return{latitude:this._lat,longitude:this._long}}_compareTo(t){return Hr(this._lat,t._lat)||Hr(this._long,t._long)}}const _d=/^__.*__$/;class Ed{constructor(t,e,n){this.data=t,this.fieldMask=e,this.fieldTransforms=n}toMutation(t,e){return null!==this.fieldMask?new Ws(t,this.data,this.fieldMask,e,this.fieldTransforms):new Ks(t,this.data,e,this.fieldTransforms)}}class Sd{constructor(t,e,n){this.data=t,this.fieldMask=e,this.fieldTransforms=n}toMutation(t,e){return new Ws(t,this.data,this.fieldMask,e,this.fieldTransforms)}}function kd(t){switch(t){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw Nr()}}class Ad{constructor(t,e,n,r,i,s){this.settings=t,this.databaseId=e,this.k=n,this.ignoreUndefinedProperties=r,void 0===i&&this.ka(),this.fieldTransforms=i||[],this.fieldMask=s||[]}get path(){return this.settings.path}get xa(){return this.settings.xa}$a(t){return new Ad(Object.assign(Object.assign({},this.settings),t),this.databaseId,this.k,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}Oa(t){var e;const n=null===(e=this.path)||void 0===e?void 0:e.child(t),r=this.$a({path:n,Fa:!1});return r.Ma(t),r}La(t){var e;const n=null===(e=this.path)||void 0===e?void 0:e.child(t),r=this.$a({path:n,Fa:!1});return r.ka(),r}Ba(t){return this.$a({path:void 0,Fa:!0})}Ua(t){return Hd(t,this.settings.methodName,this.settings.qa||!1,this.path,this.settings.Ka)}contains(t){return void 0!==this.fieldMask.find((e=>t.isPrefixOf(e)))||void 0!==this.fieldTransforms.find((e=>t.isPrefixOf(e.field)))}ka(){if(this.path)for(let t=0;t<this.path.length;t++)this.Ma(this.path.get(t))}Ma(t){if(0===t.length)throw this.Ua("Document fields must not be empty");if(kd(this.xa)&&_d.test(t))throw this.Ua('Document fields cannot begin and end with "__"')}}class Nd{constructor(t,e,n){this.databaseId=t,this.ignoreUndefinedProperties=e,this.k=n||Ou(t)}ja(t,e,n,r=!1){return new Ad({xa:t,methodName:e,Ka:n,path:ii.emptyPath(),Fa:!1,qa:r},this.databaseId,this.k,this.ignoreUndefinedProperties)}}function xd(t){const e=t._freezeSettings(),n=Ou(t._databaseId);return new Nd(t._databaseId,!!e.ignoreUndefinedProperties,n)}function Cd(t,e,n,r,i,s={}){const o=t.ja(s.merge||s.mergeFields?2:0,e,n,i);zd("Data must be an object, but it was:",o,r);const a=qd(r,o);let c,u;if(s.merge)c=new si(o.fieldMask),u=o.fieldTransforms;else if(s.mergeFields){const t=[];for(const r of s.mergeFields){const i=Kd(e,r,n);if(!o.contains(i))throw new Rr(Or.INVALID_ARGUMENT,`Field '${i}' is specified in your field mask but missing from your input data.`);$d(t,i)||t.push(i)}c=new si(t),u=o.fieldTransforms.filter((t=>c.covers(t.field)))}else c=null,u=o.fieldTransforms;return new Ed(new Ri(a),c,u)}class Dd extends Id{_toFieldTransform(t){if(2!==t.xa)throw 1===t.xa?t.Ua(`${this._methodName}() can only appear at the top level of your update data`):t.Ua(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return t.fieldMask.push(t.path),null}isEqual(t){return t instanceof Dd}}function Od(t,e,n){return new Ad({xa:3,Ka:e.settings.Ka,methodName:t._methodName,Fa:n},e.databaseId,e.k,e.ignoreUndefinedProperties)}class Rd extends Id{_toFieldTransform(t){return new Ps(t.path,new ks)}isEqual(t){return t instanceof Rd}}class Pd extends Id{constructor(t,e){super(t),this.Qa=e}_toFieldTransform(t){const e=Od(this,t,!0),n=this.Qa.map((t=>jd(t,e))),r=new As(n);return new Ps(t.path,r)}isEqual(t){return this===t}}class Ld extends Id{constructor(t,e){super(t),this.Qa=e}_toFieldTransform(t){const e=Od(this,t,!0),n=this.Qa.map((t=>jd(t,e))),r=new xs(n);return new Ps(t.path,r)}isEqual(t){return this===t}}class Md extends Id{constructor(t,e){super(t),this.Wa=e}_toFieldTransform(t){const e=new Ds(t.k,Is(t.k,this.Wa));return new Ps(t.path,e)}isEqual(t){return this===t}}function Fd(t,e,n,r){const i=t.ja(1,e,n);zd("Data must be an object, but it was:",i,r);const s=[],o=Ri.empty();Xr(r,((t,r)=>{const c=Gd(e,t,n);r=(0,a.m9)(r);const u=i.La(c);if(r instanceof Dd)s.push(c);else{const t=jd(r,u);null!=t&&(s.push(c),o.set(c,t))}}));const c=new si(s);return new Sd(o,c,i.fieldTransforms)}function Ud(t,e,n,r,i,s){const o=t.ja(1,e,n),c=[Kd(e,r,n)],u=[i];if(s.length%2!=0)throw new Rr(Or.INVALID_ARGUMENT,`Function ${e}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let t=0;t<s.length;t+=2)c.push(Kd(e,s[t])),u.push(s[t+1]);const h=[],l=Ri.empty();for(let t=c.length-1;t>=0;--t)if(!$d(h,c[t])){const e=c[t];let n=u[t];n=(0,a.m9)(n);const r=o.La(e);if(n instanceof Dd)h.push(e);else{const t=jd(n,r);null!=t&&(h.push(e),l.set(e,t))}}const d=new si(h);return new Sd(l,d,o.fieldTransforms)}function Vd(t,e,n,r=!1){return jd(n,t.ja(r?4:3,e))}function jd(t,e){if(Bd(t=(0,a.m9)(t)))return zd("Unsupported field value:",e,t),qd(t,e);if(t instanceof Id)return function(t,e){if(!kd(e.xa))throw e.Ua(`${t._methodName}() can only be used with update() and set()`);if(!e.path)throw e.Ua(`${t._methodName}() is not currently supported inside arrays`);const n=t._toFieldTransform(e);n&&e.fieldTransforms.push(n)}(t,e),null;if(void 0===t&&e.ignoreUndefinedProperties)return null;if(e.path&&e.fieldMask.push(e.path),t instanceof Array){if(e.settings.Fa&&4!==e.xa)throw e.Ua("Nested arrays are not supported");return function(t,e){const n=[];let r=0;for(const i of t){let t=jd(i,e.Ba(r));null==t&&(t={nullValue:"NULL_VALUE"}),n.push(t),r++}return{arrayValue:{values:n}}}(t,e)}return function(t,e){if(null===(t=(0,a.m9)(t)))return{nullValue:"NULL_VALUE"};if("number"==typeof t)return Is(e.k,t);if("boolean"==typeof t)return{booleanValue:t};if("string"==typeof t)return{stringValue:t};if(t instanceof Date){const n=Qr.fromDate(t);return{timestampValue:Co(e.k,n)}}if(t instanceof Qr){const n=new Qr(t.seconds,1e3*Math.floor(t.nanoseconds/1e3));return{timestampValue:Co(e.k,n)}}if(t instanceof Td)return{geoPointValue:{latitude:t.latitude,longitude:t.longitude}};if(t instanceof wd)return{bytesValue:Do(e.k,t._byteString)};if(t instanceof Kl){const n=e.databaseId,r=t.firestore._databaseId;if(!r.isEqual(n))throw e.Ua(`Document reference is for database ${r.projectId}/${r.database} but should be for database ${n.projectId}/${n.database}`);return{referenceValue:Po(t.firestore._databaseId||e.databaseId,t._key.path)}}throw e.Ua(`Unsupported field value: ${Ul(t)}`)}(t,e)}function qd(t,e){const n={};return ti(t)?e.path&&e.path.length>0&&e.fieldMask.push(e.path):Xr(t,((t,r)=>{const i=jd(r,e.Oa(t));null!=i&&(n[t]=i)})),{mapValue:{fields:n}}}function Bd(t){return!("object"!=typeof t||null===t||t instanceof Array||t instanceof Date||t instanceof Qr||t instanceof Td||t instanceof wd||t instanceof Kl||t instanceof Id)}function zd(t,e,n){if(!Bd(n)||!function(t){return"object"==typeof t&&null!==t&&(Object.getPrototypeOf(t)===Object.prototype||null===Object.getPrototypeOf(t))}(n)){const r=Ul(n);throw"an object"===r?e.Ua(t+" a custom object"):e.Ua(t+" "+r)}}function Kd(t,e,n){if((e=(0,a.m9)(e))instanceof vd)return e._internalPath;if("string"==typeof e)return Gd(t,e);throw Hd("Field path arguments must be of type string or FieldPath.",t,!1,void 0,n)}const Wd=new RegExp("[~\\*/\\[\\]]");function Gd(t,e,n){if(e.search(Wd)>=0)throw Hd(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`,t,!1,void 0,n);try{return new vd(...e.split("."))._internalPath}catch(r){throw Hd(`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,t,!1,void 0,n)}}function Hd(t,e,n,r,i){const s=r&&!r.isEmpty(),o=void 0!==i;let a=`Function ${e}() called with invalid data`;n&&(a+=" (via `toFirestore()`)"),a+=". ";let c="";return(s||o)&&(c+=" (found",s&&(c+=` in field ${r}`),o&&(c+=` in document ${i}`),c+=")"),new Rr(Or.INVALID_ARGUMENT,a+t+c)}function $d(t,e){return t.some((t=>t.isEqual(e)))}class Yd{constructor(t,e,n,r,i){this._firestore=t,this._userDataWriter=e,this._key=n,this._document=r,this._converter=i}get id(){return this._key.path.lastSegment()}get ref(){return new Kl(this._firestore,this._converter,this._key)}exists(){return null!==this._document}data(){if(this._document){if(this._converter){const t=new Qd(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(t)}return this._userDataWriter.convertValue(this._document.data.value)}}get(t){if(this._document){const e=this._document.data.field(Jd("DocumentSnapshot.get",t));if(null!==e)return this._userDataWriter.convertValue(e)}}}class Qd extends Yd{data(){return super.data()}}function Jd(t,e){return"string"==typeof e?Gd(t,e):e instanceof vd?e._internalPath:e._delegate._internalPath}class Zd{constructor(t,e){this.hasPendingWrites=t,this.fromCache=e}isEqual(t){return this.hasPendingWrites===t.hasPendingWrites&&this.fromCache===t.fromCache}}class Xd extends Yd{constructor(t,e,n,r,i,s){super(t,e,n,r,s),this._firestore=t,this._firestoreImpl=t,this.metadata=i}exists(){return super.exists()}data(t={}){if(this._document){if(this._converter){const e=new tf(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(e,t)}return this._userDataWriter.convertValue(this._document.data.value,t.serverTimestamps)}}get(t,e={}){if(this._document){const n=this._document.data.field(Jd("DocumentSnapshot.get",t));if(null!==n)return this._userDataWriter.convertValue(n,e.serverTimestamps)}}}class tf extends Xd{data(t={}){return super.data(t)}}class ef{constructor(t,e,n,r){this._firestore=t,this._userDataWriter=e,this._snapshot=r,this.metadata=new Zd(r.hasPendingWrites,r.fromCache),this.query=n}get docs(){const t=[];return this.forEach((e=>t.push(e))),t}get size(){return this._snapshot.docs.size}get empty(){return 0===this.size}forEach(t,e){this._snapshot.docs.forEach((n=>{t.call(e,new tf(this._firestore,this._userDataWriter,n.key,n,new Zd(this._snapshot.mutatedKeys.has(n.key),this._snapshot.fromCache),this.query.converter))}))}docChanges(t={}){const e=!!t.includeMetadataChanges;if(e&&this._snapshot.excludesMetadataChanges)throw new Rr(Or.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===e||(this._cachedChanges=function(t,e){if(t._snapshot.oldDocs.isEmpty()){let e=0;return t._snapshot.docChanges.map((n=>({type:"added",doc:new tf(t._firestore,t._userDataWriter,n.doc.key,n.doc,new Zd(t._snapshot.mutatedKeys.has(n.doc.key),t._snapshot.fromCache),t.query.converter),oldIndex:-1,newIndex:e++})))}{let n=t._snapshot.oldDocs;return t._snapshot.docChanges.filter((t=>e||3!==t.type)).map((e=>{const r=new tf(t._firestore,t._userDataWriter,e.doc.key,e.doc,new Zd(t._snapshot.mutatedKeys.has(e.doc.key),t._snapshot.fromCache),t.query.converter);let i=-1,s=-1;return 0!==e.type&&(i=n.indexOf(e.doc.key),n=n.delete(e.doc.key)),1!==e.type&&(n=n.add(e.doc),s=n.indexOf(e.doc.key)),{type:nf(e.type),doc:r,oldIndex:i,newIndex:s}}))}}(this,e),this._cachedChangesIncludeMetadataChanges=e),this._cachedChanges}}function nf(t){switch(t){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return Nr()}}function rf(t,e){return t instanceof Xd&&e instanceof Xd?t._firestore===e._firestore&&t._key.isEqual(e._key)&&(null===t._document?null===e._document:t._document.isEqual(e._document))&&t._converter===e._converter:t instanceof ef&&e instanceof ef&&t._firestore===e._firestore&&Jl(t.query,e.query)&&t.metadata.isEqual(e.metadata)&&t._snapshot.isEqual(e._snapshot)}function sf(t){if(os(t)&&0===t.explicitOrderBy.length)throw new Rr(Or.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class of{}function af(t,...e){for(const n of e)t=n._apply(t);return t}class cf extends of{constructor(t,e,n){super(),this.Ga=t,this.za=e,this.Ha=n,this.type="where"}_apply(t){const e=xd(t.firestore),n=function(t,e,n,r,i,s,o){let a;if(i.isKeyField()){if("array-contains"===s||"array-contains-any"===s)throw new Rr(Or.INVALID_ARGUMENT,`Invalid Query. You can't perform '${s}' queries on FieldPath.documentId().`);if("in"===s||"not-in"===s){_f(o,s);const e=[];for(const n of o)e.push(Tf(r,t,n));a={arrayValue:{values:e}}}else a=Tf(r,t,o)}else"in"!==s&&"not-in"!==s&&"array-contains-any"!==s||_f(o,s),a=Vd(n,"where",o,"in"===s||"not-in"===s);const c=qi.create(i,s,a);return function(t,e){if(e.V()){const n=cs(t);if(null!==n&&!n.isEqual(e.field))throw new Rr(Or.INVALID_ARGUMENT,`Invalid query. All where filters with an inequality (<, <=, !=, not-in, >, or >=) must be on the same field. But you have inequality filters on '${n.toString()}' and '${e.field.toString()}'`);const r=as(t);null!==r&&Ef(0,e.field,r)}const n=function(t,e){for(const n of t.filters)if(e.indexOf(n.op)>=0)return n.op;return null}(t,function(t){switch(t){case"!=":return["!=","not-in"];case"array-contains":return["array-contains","array-contains-any","not-in"];case"in":return["array-contains-any","in","not-in"];case"array-contains-any":return["array-contains","array-contains-any","in","not-in"];case"not-in":return["array-contains","array-contains-any","in","not-in","!="];default:return[]}}(e.op));if(null!==n)throw n===e.op?new Rr(Or.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${e.op.toString()}' filter.`):new Rr(Or.INVALID_ARGUMENT,`Invalid query. You cannot use '${e.op.toString()}' filters with '${n.toString()}' filters.`)}(t,c),c}(t._query,0,e,t.firestore._databaseId,this.Ga,this.za,this.Ha);return new Wl(t.firestore,t.converter,function(t,e){const n=t.filters.concat([e]);return new ns(t.path,t.collectionGroup,t.explicitOrderBy.slice(),n,t.limit,t.limitType,t.startAt,t.endAt)}(t._query,n))}}function uf(t,e,n){const r=e,i=Jd("where",t);return new cf(i,r,n)}class hf extends of{constructor(t,e){super(),this.Ga=t,this.Ja=e,this.type="orderBy"}_apply(t){const e=function(t,e,n){if(null!==t.startAt)throw new Rr(Or.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(null!==t.endAt)throw new Rr(Or.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");const r=new Zi(e,n);return function(t,e){if(null===as(t)){const n=cs(t);null!==n&&Ef(0,n,e.field)}}(t,r),r}(t._query,this.Ga,this.Ja);return new Wl(t.firestore,t.converter,function(t,e){const n=t.explicitOrderBy.concat([e]);return new ns(t.path,t.collectionGroup,n,t.filters.slice(),t.limit,t.limitType,t.startAt,t.endAt)}(t._query,e))}}function lf(t,e="asc"){const n=e,r=Jd("orderBy",t);return new hf(r,n)}class df extends of{constructor(t,e,n){super(),this.type=t,this.Ya=e,this.Xa=n}_apply(t){return new Wl(t.firestore,t.converter,ds(t._query,this.Ya,this.Xa))}}function ff(t){return jl("limit",t),new df("limit",t,"F")}function pf(t){return jl("limitToLast",t),new df("limitToLast",t,"L")}class mf extends of{constructor(t,e,n){super(),this.type=t,this.Za=e,this.tc=n}_apply(t){const e=If(t,this.type,this.Za,this.tc);return new Wl(t.firestore,t.converter,function(t,e){return new ns(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,e,t.endAt)}(t._query,e))}}function gf(...t){return new mf("startAt",t,!0)}function yf(...t){return new mf("startAfter",t,!1)}class vf extends of{constructor(t,e,n){super(),this.type=t,this.Za=e,this.tc=n}_apply(t){const e=If(t,this.type,this.Za,this.tc);return new Wl(t.firestore,t.converter,function(t,e){return new ns(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,t.startAt,e)}(t._query,e))}}function bf(...t){return new vf("endBefore",t,!0)}function wf(...t){return new vf("endAt",t,!1)}function If(t,e,n,r){if(n[0]=(0,a.m9)(n[0]),n[0]instanceof Yd)return function(t,e,n,r,i){if(!r)throw new Rr(Or.NOT_FOUND,`Can't use a DocumentSnapshot that doesn't exist for ${n}().`);const s=[];for(const n of hs(t))if(n.field.isKeyField())s.push(ki(e,r.key));else{const t=r.data.field(n.field);if(di(t))throw new Rr(Or.INVALID_ARGUMENT,'Invalid query. You are trying to start or end a query using a document for which the field "'+n.field+'" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');if(null===t){const t=n.field.canonicalString();throw new Rr(Or.INVALID_ARGUMENT,`Invalid query. You are trying to start or end a query using a document for which the field '${t}' (used as the orderBy) does not exist.`)}s.push(t)}return new Qi(s,i)}(t._query,t.firestore._databaseId,e,n[0]._document,r);{const i=xd(t.firestore);return function(t,e,n,r,i,s){const o=t.explicitOrderBy;if(i.length>o.length)throw new Rr(Or.INVALID_ARGUMENT,`Too many arguments provided to ${r}(). The number of arguments must be less than or equal to the number of orderBy() clauses`);const a=[];for(let s=0;s<i.length;s++){const c=i[s];if(o[s].field.isKeyField()){if("string"!=typeof c)throw new Rr(Or.INVALID_ARGUMENT,`Invalid query. Expected a string for document ID in ${r}(), but got a ${typeof c}`);if(!us(t)&&-1!==c.indexOf("/"))throw new Rr(Or.INVALID_ARGUMENT,`Invalid query. When querying a collection and ordering by FieldPath.documentId(), the value passed to ${r}() must be a plain document ID, but '${c}' contains a slash.`);const n=t.path.child(ni.fromString(c));if(!vi.isDocumentKey(n))throw new Rr(Or.INVALID_ARGUMENT,`Invalid query. When querying a collection group and ordering by FieldPath.documentId(), the value passed to ${r}() must result in a valid document path, but '${n}' is not because it contains an odd number of segments.`);const i=new vi(n);a.push(ki(e,i))}else{const t=Vd(n,r,c);a.push(t)}}return new Qi(a,s)}(t._query,t.firestore._databaseId,i,e,n,r)}}function Tf(t,e,n){if("string"==typeof(n=(0,a.m9)(n))){if(""===n)throw new Rr(Or.INVALID_ARGUMENT,"Invalid query. When querying with FieldPath.documentId(), you must provide a valid document ID, but it was an empty string.");if(!us(e)&&-1!==n.indexOf("/"))throw new Rr(Or.INVALID_ARGUMENT,`Invalid query. When querying a collection by FieldPath.documentId(), you must provide a plain document ID, but '${n}' contains a '/' character.`);const r=e.path.child(ni.fromString(n));if(!vi.isDocumentKey(r))throw new Rr(Or.INVALID_ARGUMENT,`Invalid query. When querying a collection group by FieldPath.documentId(), the value provided must result in a valid document path, but '${r}' is not because it has an odd number of segments (${r.length}).`);return ki(t,new vi(r))}if(n instanceof Kl)return ki(t,n._key);throw new Rr(Or.INVALID_ARGUMENT,`Invalid query. When querying with FieldPath.documentId(), you must provide a valid string or a DocumentReference, but it was: ${Ul(n)}.`)}function _f(t,e){if(!Array.isArray(t)||0===t.length)throw new Rr(Or.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${e.toString()}' filters.`);if(t.length>10)throw new Rr(Or.INVALID_ARGUMENT,`Invalid Query. '${e.toString()}' filters support a maximum of 10 elements in the value array.`)}function Ef(t,e,n){if(!n.isEqual(e))throw new Rr(Or.INVALID_ARGUMENT,`Invalid query. You have a where filter with an inequality (<, <=, !=, not-in, >, or >=) on field '${e.toString()}' and so you must also use '${e.toString()}' as your first argument to orderBy(), but your first orderBy() is on field '${n.toString()}' instead.`)}class Sf{convertValue(t,e="none"){switch(bi(t)){case 0:return null;case 1:return t.booleanValue;case 2:return hi(t.integerValue||t.doubleValue);case 3:return this.convertTimestamp(t.timestampValue);case 4:return this.convertServerTimestamp(t,e);case 5:return t.stringValue;case 6:return this.convertBytes(li(t.bytesValue));case 7:return this.convertReference(t.referenceValue);case 8:return this.convertGeoPoint(t.geoPointValue);case 9:return this.convertArray(t.arrayValue,e);case 10:return this.convertObject(t.mapValue,e);default:throw Nr()}}convertObject(t,e){const n={};return Xr(t.fields,((t,r)=>{n[t]=this.convertValue(r,e)})),n}convertGeoPoint(t){return new Td(hi(t.latitude),hi(t.longitude))}convertArray(t,e){return(t.values||[]).map((t=>this.convertValue(t,e)))}convertServerTimestamp(t,e){switch(e){case"previous":const n=fi(t);return null==n?null:this.convertValue(n,e);case"estimate":return this.convertTimestamp(pi(t));default:return null}}convertTimestamp(t){const e=ui(t);return new Qr(e.seconds,e.nanos)}convertDocumentKey(t,e){const n=ni.fromString(t);xr(sa(n));const r=new Ol(n.get(1),n.get(3)),i=new vi(n.popFirst(5));return r.isEqual(e)||Sr(`Document ${i} contains a document reference within a different database (${r.projectId}/${r.database}) which is not supported. It will be treated as a reference in the current database (${e.projectId}/${e.database}) instead.`),i}}function kf(t,e,n){let r;return r=t?n&&(n.merge||n.mergeFields)?t.toFirestore(e,n):t.toFirestore(e):e,r}class Af extends Sf{constructor(t){super(),this.firestore=t}convertBytes(t){return new wd(t)}convertReference(t){const e=this.convertDocumentKey(t,this.firestore._databaseId);return new Kl(this.firestore,null,e)}}class Nf{constructor(t,e){this._firestore=t,this._commitHandler=e,this._mutations=[],this._committed=!1,this._dataReader=xd(t)}set(t,e,n){this._verifyNotCommitted();const r=xf(t,this._firestore),i=kf(r.converter,e,n),s=Cd(this._dataReader,"WriteBatch.set",r._key,i,null!==r.converter,n);return this._mutations.push(s.toMutation(r._key,Ms.none())),this}update(t,e,n,...r){this._verifyNotCommitted();const i=xf(t,this._firestore);let s;return s="string"==typeof(e=(0,a.m9)(e))||e instanceof vd?Ud(this._dataReader,"WriteBatch.update",i._key,e,n,r):Fd(this._dataReader,"WriteBatch.update",i._key,e),this._mutations.push(s.toMutation(i._key,Ms.exists(!0))),this}delete(t){this._verifyNotCommitted();const e=xf(t,this._firestore);return this._mutations=this._mutations.concat(new Ys(e._key,Ms.none())),this}commit(){return this._verifyNotCommitted(),this._committed=!0,this._mutations.length>0?this._commitHandler(this._mutations):Promise.resolve()}_verifyNotCommitted(){if(this._committed)throw new Rr(Or.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")}}function xf(t,e){if((t=(0,a.m9)(t)).firestore!==e)throw new Rr(Or.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return t}function Cf(t){t=Vl(t,Kl);const e=Vl(t.firestore,nd);return xl(sd(e),t._key).then((n=>Kf(e,t,n)))}class Df extends Sf{constructor(t){super(),this.firestore=t}convertBytes(t){return new wd(t)}convertReference(t){const e=this.convertDocumentKey(t,this.firestore._databaseId);return new Kl(this.firestore,null,e)}}function Of(t){t=Vl(t,Kl);const e=Vl(t.firestore,nd),n=sd(e),r=new Df(e);return function(t,e){const n=new Pr;return t.asyncQueue.enqueueAndForget((async()=>async function(t,e,n){try{const r=await function(t,e){const n=Dr(t);return n.persistence.runTransaction("read document","readonly",(t=>n.Wn.Rn(t,e)))}(t,e);r.isFoundDocument()?n.resolve(r):r.isNoDocument()?n.resolve(null):n.reject(new Rr(Or.UNAVAILABLE,"Failed to get document from cache. (However, this document may exist on the server. Run again without setting 'source' in the GetOptions to attempt to retrieve the document from the server.)"))}catch(t){const r=ph(t,`Failed to get document '${e} from cache`);n.reject(r)}}(await Sl(t),e,n))),n.promise}(n,t._key).then((n=>new Xd(e,r,t._key,n,new Zd(null!==n&&n.hasLocalMutations,!0),t.converter)))}function Rf(t){t=Vl(t,Kl);const e=Vl(t.firestore,nd);return xl(sd(e),t._key,{source:"server"}).then((n=>Kf(e,t,n)))}function Pf(t){t=Vl(t,Wl);const e=Vl(t.firestore,nd),n=sd(e),r=new Df(e);return sf(t._query),Cl(n,t._query).then((n=>new ef(e,r,t,n)))}function Lf(t){t=Vl(t,Wl);const e=Vl(t.firestore,nd),n=sd(e),r=new Df(e);return function(t,e){const n=new Pr;return t.asyncQueue.enqueueAndForget((async()=>async function(t,e,n){try{const r=await eu(t,e,!0),i=new Oh(e,r.zn),s=i.Po(r.documents),o=i.applyChanges(s,!1);n.resolve(o.snapshot)}catch(t){const r=ph(t,`Failed to execute query '${e} against cache`);n.reject(r)}}(await Sl(t),e,n))),n.promise}(n,t._query).then((n=>new ef(e,r,t,n)))}function Mf(t){t=Vl(t,Wl);const e=Vl(t.firestore,nd),n=sd(e),r=new Df(e);return Cl(n,t._query,{source:"server"}).then((n=>new ef(e,r,t,n)))}function Ff(t,e,n){t=Vl(t,Kl);const r=Vl(t.firestore,nd),i=kf(t.converter,e,n);return zf(r,[Cd(xd(r),"setDoc",t._key,i,null!==t.converter,n).toMutation(t._key,Ms.none())])}function Uf(t,e,n,...r){t=Vl(t,Kl);const i=Vl(t.firestore,nd),s=xd(i);let o;return o="string"==typeof(e=(0,a.m9)(e))||e instanceof vd?Ud(s,"updateDoc",t._key,e,n,r):Fd(s,"updateDoc",t._key,e),zf(i,[o.toMutation(t._key,Ms.exists(!0))])}function Vf(t){return zf(Vl(t.firestore,nd),[new Ys(t._key,Ms.none())])}function jf(t,e){const n=Vl(t.firestore,nd),r=Yl(t),i=kf(t.converter,e);return zf(n,[Cd(xd(t.firestore),"addDoc",r._key,i,null!==t.converter,{}).toMutation(r._key,Ms.exists(!1))]).then((()=>r))}function qf(t,...e){var n,r,i;t=(0,a.m9)(t);let s={includeMetadataChanges:!1},o=0;"object"!=typeof e[o]||Xl(e[o])||(s=e[o],o++);const c={includeMetadataChanges:s.includeMetadataChanges};if(Xl(e[o])){const t=e[o];e[o]=null===(n=t.next)||void 0===n?void 0:n.bind(t),e[o+1]=null===(r=t.error)||void 0===r?void 0:r.bind(t),e[o+2]=null===(i=t.complete)||void 0===i?void 0:i.bind(t)}let u,h,l;if(t instanceof Kl)h=Vl(t.firestore,nd),l=is(t._key.path),u={next:n=>{e[o]&&e[o](Kf(h,t,n))},error:e[o+1],complete:e[o+2]};else{const n=Vl(t,Wl);h=Vl(n.firestore,nd),l=n._query;const r=new Df(h);u={next:t=>{e[o]&&e[o](new ef(h,r,n,t))},error:e[o+1],complete:e[o+2]},sf(t._query)}return function(t,e,n,r){const i=new ml(r),s=new Sh(e,i,n);return t.asyncQueue.enqueueAndForget((async()=>wh(await Nl(t),s))),()=>{i.na(),t.asyncQueue.enqueueAndForget((async()=>Ih(await Nl(t),s)))}}(sd(h),l,c,u)}function Bf(t,e){return function(t,e){const n=new ml(e);return t.asyncQueue.enqueueAndForget((async()=>function(t,e){Dr(t).io.add(e),e.next()}(await Nl(t),n))),()=>{n.na(),t.asyncQueue.enqueueAndForget((async()=>function(t,e){Dr(t).io.delete(e)}(await Nl(t),n)))}}(sd(t=Vl(t,nd)),Xl(e)?e:{next:e})}function zf(t,e){return function(t,e){const n=new Pr;return t.asyncQueue.enqueueAndForget((async()=>async function(t,e,n){const r=ul(t);try{const t=await function(t,e){const n=Dr(t),r=Qr.now(),i=e.reduce(((t,e)=>t.add(e.key)),mo());let s;return n.persistence.runTransaction("Locally write mutations","readwrite",(t=>n.Wn.vn(t,i).next((i=>{s=i;const o=[];for(const t of e){const e=qs(t,s.get(t.key));null!=e&&o.push(new Ws(t.key,e,Pi(e.value.mapValue),Ms.exists(!0)))}return n.An.addMutationBatch(t,r,o,e)})))).then((t=>(t.applyToLocalDocumentSet(s),{batchId:t.batchId,changes:s})))}(r.localStore,e);r.sharedClientState.addPendingMutation(t.batchId),function(t,e,n){let r=t.Ko[t.currentUser.toKey()];r||(r=new no(Hr)),r=r.insert(e,n),t.Ko[t.currentUser.toKey()]=r}(r,t.batchId,n),await Jh(r,t.changes),await eh(r.remoteStore)}catch(t){const e=ph(t,"Failed to persist write");n.reject(e)}}(await Al(t),e,n))),n.promise}(sd(t),e)}function Kf(t,e,n){const r=n.docs.get(e._key),i=new Df(t);return new Xd(t,i,e._key,r,new Zd(n.hasPendingWrites,n.fromCache),e.converter)}class Wf extends class{constructor(t,e){this._firestore=t,this._transaction=e,this._dataReader=xd(t)}get(t){const e=xf(t,this._firestore),n=new Af(this._firestore);return this._transaction.lookup([e._key]).then((t=>{if(!t||1!==t.length)return Nr();const r=t[0];if(r.isFoundDocument())return new Yd(this._firestore,n,r.key,r,e.converter);if(r.isNoDocument())return new Yd(this._firestore,n,e._key,null,e.converter);throw Nr()}))}set(t,e,n){const r=xf(t,this._firestore),i=kf(r.converter,e,n),s=Cd(this._dataReader,"Transaction.set",r._key,i,null!==r.converter,n);return this._transaction.set(r._key,s),this}update(t,e,n,...r){const i=xf(t,this._firestore);let s;return s="string"==typeof(e=(0,a.m9)(e))||e instanceof vd?Ud(this._dataReader,"Transaction.update",i._key,e,n,r):Fd(this._dataReader,"Transaction.update",i._key,e),this._transaction.update(i._key,s),this}delete(t){const e=xf(t,this._firestore);return this._transaction.delete(e._key),this}}{constructor(t,e){super(t,e),this._firestore=t}get(t){const e=xf(t,this._firestore),n=new Df(this._firestore);return super.get(t).then((t=>new Xd(this._firestore,n,e._key,t._document,new Zd(!1,!1),e.converter)))}}function Gf(t,e){return function(t,e){const n=new Pr;return t.asyncQueue.enqueueAndForget((async()=>{const r=await function(t){return _l(t).then((t=>t.datastore))}(t);new vl(t.asyncQueue,r,e,n).run()})),n.promise}(sd(t=Vl(t,nd)),(n=>e(new Wf(t,n))))}function Hf(){return new Dd("deleteField")}function $f(){return new Rd("serverTimestamp")}function Yf(...t){return new Pd("arrayUnion",t)}function Qf(...t){return new Ld("arrayRemove",t)}function Jf(t){return new Md("increment",t)}function Zf(t){return sd(t=Vl(t,nd)),new Nf(t,(e=>zf(t,e)))}!function(t,e=!0){!function(t){wr=t}(i.Jn),(0,i.Xd)(new s.wA("firestore",((t,{options:n})=>{const r=t.getProvider("app").getImmediate(),i=new nd(r,new Ur(t.getProvider("auth-internal")),new Br(t.getProvider("app-check-internal")));return n=Object.assign({useFetchStreams:e},n),i._setSettings(n),i}),"PUBLIC")),(0,i.KN)(vr,"3.4.2",t),(0,i.KN)(vr,"3.4.2","esm2017")}()},3310:t=>{"use strict";t.exports=t=>{if("[object Object]"!==Object.prototype.toString.call(t))return!1;const e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}},6245:(t,e,n)=>{"use strict";function r(t){this.message=t}n.r(e),n.d(e,{default:()=>a,InvalidTokenError:()=>o}),r.prototype=new Error,r.prototype.name="InvalidCharacterError";var i="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new r("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,i,s=0,o=0,a="";i=e.charAt(o++);~i&&(n=s%4?64*n+i:i,s++%4)?a+=String.fromCharCode(255&n>>(-2*s&6)):0)i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(i);return a};function s(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(i(t).replace(/(.)/g,(function(t,e){var n=e.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(e)}catch(t){return i(e)}}function o(t){this.message=t}o.prototype=new Error,o.prototype.name="InvalidTokenError";const a=function(t,e){if("string"!=typeof t)throw new o("Invalid token specified");var n=!0===(e=e||{}).header?0:1;try{return JSON.parse(s(t.split(".")[n]))}catch(t){throw new o("Invalid token specified: "+t.message)}}},942:function(t,e,n){"use strict";const r=n(3310),{hasOwnProperty:i}=Object.prototype,{propertyIsEnumerable:s}=Object,o=(t,e,n)=>Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0}),a=this,c={concatArrays:!1,ignoreUndefined:!1},u=t=>{const e=[];for(const n in t)i.call(t,n)&&e.push(n);if(Object.getOwnPropertySymbols){const n=Object.getOwnPropertySymbols(t);for(const r of n)s.call(t,r)&&e.push(r)}return e};function h(t){return Array.isArray(t)?function(t){const e=t.slice(0,0);return u(t).forEach((n=>{o(e,n,h(t[n]))})),e}(t):r(t)?function(t){const e=null===Object.getPrototypeOf(t)?Object.create(null):{};return u(t).forEach((n=>{o(e,n,h(t[n]))})),e}(t):t}const l=(t,e,n,r)=>(n.forEach((n=>{void 0===e[n]&&r.ignoreUndefined||(n in t&&t[n]!==Object.getPrototypeOf(t)?o(t,n,d(t[n],e[n],r)):o(t,n,h(e[n])))})),t);function d(t,e,n){return n.concatArrays&&Array.isArray(t)&&Array.isArray(e)?((t,e,n)=>{let r=t.slice(0,0),s=0;return[t,e].forEach((e=>{const a=[];for(let n=0;n<e.length;n++)i.call(e,n)&&(a.push(String(n)),o(r,s++,e===t?e[n]:h(e[n])));r=l(r,e,u(e).filter((t=>!a.includes(t))),n)})),r})(t,e,n):r(e)&&r(t)?l(t,e,u(e),n):h(e)}t.exports=function(...t){const e=d(h(c),this!==a&&this||{},c);let n={_:{}};for(const i of t)if(void 0!==i){if(!r(i))throw new TypeError("`"+i+"` is not an Option Object");n=d(n,{_:i},e)}return n._}},4143:(t,e,n)=>{"use strict";n.r(e),n.d(e,{ArgumentOutOfRangeError:()=>D.W,AsyncSubject:()=>h.c,BehaviorSubject:()=>c.X,ConnectableObservable:()=>i.c,EMPTY:()=>Q.E,EmptyError:()=>O.K,GroupedObservable:()=>s.T,NEVER:()=>dt,Notification:()=>k.P,NotificationKind:()=>k.W,ObjectUnsubscribedError:()=>R.N,Observable:()=>r.y,ReplaySubject:()=>u.t,Scheduler:()=>_.b,Subject:()=>a.xQ,Subscriber:()=>S.L,Subscription:()=>E.w,TimeoutError:()=>L.W,UnsubscriptionError:()=>P.B,VirtualAction:()=>T,VirtualTimeScheduler:()=>I,animationFrame:()=>w,animationFrameScheduler:()=>b,asap:()=>l.e,asapScheduler:()=>l.E,async:()=>d.P,asyncScheduler:()=>d.z,bindCallback:()=>j,bindNodeCallback:()=>z,combineLatest:()=>H.aj,concat:()=>$.z,config:()=>Ct.v,defer:()=>Y.P,empty:()=>Q.c,forkJoin:()=>X,from:()=>Z.D,fromEvent:()=>nt,fromEventPattern:()=>it,generate:()=>st,identity:()=>x.y,iif:()=>at,interval:()=>ut,isObservable:()=>C,merge:()=>lt.T,never:()=>ft,noop:()=>N.Z,observable:()=>o.L,of:()=>pt.of,onErrorResumeNext:()=>mt,pairs:()=>gt,partition:()=>It,pipe:()=>A.z,queue:()=>f.c,queueScheduler:()=>f.N,race:()=>Tt.S3,range:()=>_t,scheduled:()=>xt.x,throwError:()=>St._,timer:()=>kt.H,using:()=>At,zip:()=>Nt.$R});var r=n(2772),i=n(3140),s=n(1120),o=n(5050),a=n(211),c=n(9233),u=n(2630),h=n(364),l=n(6650),d=n(964),f=n(2546),p=n(5987),m=n(6114),g=function(t){function e(e,n){var r=t.call(this,e,n)||this;return r.scheduler=e,r.work=n,r}return p.ZT(e,t),e.prototype.requestAsyncId=function(e,n,r){return void 0===r&&(r=0),null!==r&&r>0?t.prototype.requestAsyncId.call(this,e,n,r):(e.actions.push(this),e.scheduled||(e.scheduled=requestAnimationFrame((function(){return e.flush(null)}))))},e.prototype.recycleAsyncId=function(e,n,r){if(void 0===r&&(r=0),null!==r&&r>0||null===r&&this.delay>0)return t.prototype.recycleAsyncId.call(this,e,n,r);0===e.actions.length&&(cancelAnimationFrame(n),e.scheduled=void 0)},e}(m.o),y=n(8399),v=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return p.ZT(e,t),e.prototype.flush=function(t){this.active=!0,this.scheduled=void 0;var e,n=this.actions,r=-1,i=n.length;t=t||n.shift();do{if(e=t.execute(t.state,t.delay))break}while(++r<i&&(t=n.shift()));if(this.active=!1,e){for(;++r<i&&(t=n.shift());)t.unsubscribe();throw e}},e}(y.v),b=new v(g),w=b,I=function(t){function e(e,n){void 0===e&&(e=T),void 0===n&&(n=Number.POSITIVE_INFINITY);var r=t.call(this,e,(function(){return r.frame}))||this;return r.maxFrames=n,r.frame=0,r.index=-1,r}return p.ZT(e,t),e.prototype.flush=function(){for(var t,e,n=this.actions,r=this.maxFrames;(e=n[0])&&e.delay<=r&&(n.shift(),this.frame=e.delay,!(t=e.execute(e.state,e.delay))););if(t){for(;e=n.shift();)e.unsubscribe();throw t}},e.frameTimeFactor=10,e}(y.v),T=function(t){function e(e,n,r){void 0===r&&(r=e.index+=1);var i=t.call(this,e,n)||this;return i.scheduler=e,i.work=n,i.index=r,i.active=!0,i.index=e.index=r,i}return p.ZT(e,t),e.prototype.schedule=function(n,r){if(void 0===r&&(r=0),!this.id)return t.prototype.schedule.call(this,n,r);this.active=!1;var i=new e(this.scheduler,this.work);return this.add(i),i.schedule(n,r)},e.prototype.requestAsyncId=function(t,n,r){void 0===r&&(r=0),this.delay=t.frame+r;var i=t.actions;return i.push(this),i.sort(e.sortActions),!0},e.prototype.recycleAsyncId=function(t,e,n){void 0===n&&(n=0)},e.prototype._execute=function(e,n){if(!0===this.active)return t.prototype._execute.call(this,e,n)},e.sortActions=function(t,e){return t.delay===e.delay?t.index===e.index?0:t.index>e.index?1:-1:t.delay>e.delay?1:-1},e}(m.o),_=n(8725),E=n(8760),S=n(979),k=n(2632),A=n(2561),N=n(3306),x=n(3608);function C(t){return!!t&&(t instanceof r.y||"function"==typeof t.lift&&"function"==typeof t.subscribe)}var D=n(6565),O=n(6929),R=n(1016),P=n(8782),L=n(1462),M=n(5709),F=n(3642),U=n(9026),V=n(7507);function j(t,e,n){if(e){if(!(0,V.K)(e))return function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];return j(t,n).apply(void 0,r).pipe((0,M.U)((function(t){return(0,U.k)(t)?e.apply(void 0,t):e(t)})))};n=e}return function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];var s,o=this,a={context:o,subject:s,callbackFunc:t,scheduler:n};return new r.y((function(r){if(n){var i={args:e,subscriber:r,params:a};return n.schedule(q,0,i)}if(!s){s=new h.c;try{t.apply(o,e.concat([function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];s.next(t.length<=1?t[0]:t),s.complete()}]))}catch(t){(0,F._)(s)?s.error(t):console.warn(t)}}return s.subscribe(r)}))}}function q(t){var e=this,n=t.args,r=t.subscriber,i=t.params,s=i.callbackFunc,o=i.context,a=i.scheduler,c=i.subject;if(!c){c=i.subject=new h.c;try{s.apply(o,n.concat([function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=t.length<=1?t[0]:t;e.add(a.schedule(B,0,{value:r,subject:c}))}]))}catch(t){c.error(t)}}this.add(c.subscribe(r))}function B(t){var e=t.value,n=t.subject;n.next(e),n.complete()}function z(t,e,n){if(e){if(!(0,V.K)(e))return function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];return z(t,n).apply(void 0,r).pipe((0,M.U)((function(t){return(0,U.k)(t)?e.apply(void 0,t):e(t)})))};n=e}return function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];var s={subject:void 0,args:e,callbackFunc:t,scheduler:n,context:this};return new r.y((function(r){var i=s.context,o=s.subject;if(n)return n.schedule(K,0,{params:s,subscriber:r,context:i});if(!o){o=s.subject=new h.c;try{t.apply(i,e.concat([function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=t.shift();n?o.error(n):(o.next(t.length<=1?t[0]:t),o.complete())}]))}catch(t){(0,F._)(o)?o.error(t):console.warn(t)}}return o.subscribe(r)}))}}function K(t){var e=this,n=t.params,r=t.subscriber,i=t.context,s=n.callbackFunc,o=n.args,a=n.scheduler,c=n.subject;if(!c){c=n.subject=new h.c;try{s.apply(i,o.concat([function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=t.shift();if(r)e.add(a.schedule(G,0,{err:r,subject:c}));else{var i=t.length<=1?t[0]:t;e.add(a.schedule(W,0,{value:i,subject:c}))}}]))}catch(t){this.add(a.schedule(G,0,{err:t,subject:c}))}}this.add(c.subscribe(r))}function W(t){var e=t.value,n=t.subject;n.next(e),n.complete()}function G(t){var e=t.err;t.subject.error(e)}var H=n(5142),$=n(9795),Y=n(1410),Q=n(5631),J=n(2009),Z=n(5760);function X(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(1===t.length){var n=t[0];if((0,U.k)(n))return tt(n,null);if((0,J.K)(n)&&Object.getPrototypeOf(n)===Object.prototype){var r=Object.keys(n);return tt(r.map((function(t){return n[t]})),r)}}if("function"==typeof t[t.length-1]){var i=t.pop();return tt(t=1===t.length&&(0,U.k)(t[0])?t[0]:t,null).pipe((0,M.U)((function(t){return i.apply(void 0,t)})))}return tt(t,null)}function tt(t,e){return new r.y((function(n){var r=t.length;if(0!==r)for(var i=new Array(r),s=0,o=0,a=function(a){var c=(0,Z.D)(t[a]),u=!1;n.add(c.subscribe({next:function(t){u||(u=!0,o++),i[a]=t},error:function(t){return n.error(t)},complete:function(){++s!==r&&u||(o===r&&n.next(e?e.reduce((function(t,e,n){return t[e]=i[n],t}),{}):i),n.complete())}}))},c=0;c<r;c++)a(c);else n.complete()}))}var et=n(4156);function nt(t,e,n,i){return(0,et.m)(n)&&(i=n,n=void 0),i?nt(t,e,n).pipe((0,M.U)((function(t){return(0,U.k)(t)?i.apply(void 0,t):i(t)}))):new r.y((function(r){rt(t,e,(function(t){arguments.length>1?r.next(Array.prototype.slice.call(arguments)):r.next(t)}),r,n)}))}function rt(t,e,n,r,i){var s;if(function(t){return t&&"function"==typeof t.addEventListener&&"function"==typeof t.removeEventListener}(t)){var o=t;t.addEventListener(e,n,i),s=function(){return o.removeEventListener(e,n,i)}}else if(function(t){return t&&"function"==typeof t.on&&"function"==typeof t.off}(t)){var a=t;t.on(e,n),s=function(){return a.off(e,n)}}else if(function(t){return t&&"function"==typeof t.addListener&&"function"==typeof t.removeListener}(t)){var c=t;t.addListener(e,n),s=function(){return c.removeListener(e,n)}}else{if(!t||!t.length)throw new TypeError("Invalid event target");for(var u=0,h=t.length;u<h;u++)rt(t[u],e,n,r,i)}r.add(s)}function it(t,e,n){return n?it(t,e).pipe((0,M.U)((function(t){return(0,U.k)(t)?n.apply(void 0,t):n(t)}))):new r.y((function(n){var r,i=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return n.next(1===t.length?t[0]:t)};try{r=t(i)}catch(t){return void n.error(t)}if((0,et.m)(e))return function(){return e(i,r)}}))}function st(t,e,n,i,s){var o,a;if(1==arguments.length){var c=t;a=c.initialState,e=c.condition,n=c.iterate,o=c.resultSelector||x.y,s=c.scheduler}else void 0===i||(0,V.K)(i)?(a=t,o=x.y,s=i):(a=t,o=i);return new r.y((function(t){var r=a;if(s)return s.schedule(ot,0,{subscriber:t,iterate:n,condition:e,resultSelector:o,state:r});for(;;){if(e){var i=void 0;try{i=e(r)}catch(e){return void t.error(e)}if(!i){t.complete();break}}var c=void 0;try{c=o(r)}catch(e){return void t.error(e)}if(t.next(c),t.closed)break;try{r=n(r)}catch(e){return void t.error(e)}}}))}function ot(t){var e=t.subscriber,n=t.condition;if(!e.closed){if(t.needIterate)try{t.state=t.iterate(t.state)}catch(t){return void e.error(t)}else t.needIterate=!0;if(n){var r=void 0;try{r=n(t.state)}catch(t){return void e.error(t)}if(!r)return void e.complete();if(e.closed)return}var i;try{i=t.resultSelector(t.state)}catch(t){return void e.error(t)}if(!e.closed&&(e.next(i),!e.closed))return this.schedule(t)}}function at(t,e,n){return void 0===e&&(e=Q.E),void 0===n&&(n=Q.E),(0,Y.P)((function(){return t()?e:n}))}var ct=n(5812);function ut(t,e){return void 0===t&&(t=0),void 0===e&&(e=d.P),(!(0,ct.k)(t)||t<0)&&(t=0),e&&"function"==typeof e.schedule||(e=d.P),new r.y((function(n){return n.add(e.schedule(ht,t,{subscriber:n,counter:0,period:t})),n}))}function ht(t){var e=t.subscriber,n=t.counter,r=t.period;e.next(n),this.schedule({subscriber:e,counter:n+1,period:r},r)}var lt=n(4370),dt=new r.y(N.Z);function ft(){return dt}var pt=n(8170);function mt(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(0===t.length)return Q.E;var n=t[0],i=t.slice(1);return 1===t.length&&(0,U.k)(n)?mt.apply(void 0,n):new r.y((function(t){var e=function(){return t.add(mt.apply(void 0,i).subscribe(t))};return(0,Z.D)(n).subscribe({next:function(e){t.next(e)},error:e,complete:e})}))}function gt(t,e){return e?new r.y((function(n){var r=Object.keys(t),i=new E.w;return i.add(e.schedule(yt,0,{keys:r,index:0,subscriber:n,subscription:i,obj:t})),i})):new r.y((function(e){for(var n=Object.keys(t),r=0;r<n.length&&!e.closed;r++){var i=n[r];t.hasOwnProperty(i)&&e.next([i,t[i]])}e.complete()}))}function yt(t){var e=t.keys,n=t.index,r=t.subscriber,i=t.subscription,s=t.obj;if(!r.closed)if(n<e.length){var o=e[n];r.next([o,s[o]]),i.add(this.schedule({keys:e,index:n+1,subscriber:r,subscription:i,obj:s}))}else r.complete()}var vt=n(9067),bt=n(7843),wt=n(6008);function It(t,e,n){return[(0,wt.h)(e,n)(new r.y((0,bt.s)(t))),(0,wt.h)((0,vt.f)(e,n))(new r.y((0,bt.s)(t)))]}var Tt=n(8821);function _t(t,e,n){return void 0===t&&(t=0),new r.y((function(r){void 0===e&&(e=t,t=0);var i=0,s=t;if(n)return n.schedule(Et,0,{index:i,count:e,start:t,subscriber:r});for(;;){if(i++>=e){r.complete();break}if(r.next(s++),r.closed)break}}))}function Et(t){var e=t.start,n=t.index,r=t.count,i=t.subscriber;n>=r?i.complete():(i.next(e),i.closed||(t.index=n+1,t.start=e+1,this.schedule(t)))}var St=n(4944),kt=n(9604);function At(t,e){return new r.y((function(n){var r,i;try{r=t()}catch(t){return void n.error(t)}try{i=e(r)}catch(t){return void n.error(t)}var s=(i?(0,Z.D)(i):Q.E).subscribe(n);return function(){s.unsubscribe(),r&&r.unsubscribe()}}))}var Nt=n(5080),xt=n(8107),Ct=n(150)},364:(t,e,n)=>{"use strict";n.d(e,{c:()=>o});var r=n(5987),i=n(211),s=n(8760),o=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.value=null,e.hasNext=!1,e.hasCompleted=!1,e}return r.ZT(e,t),e.prototype._subscribe=function(e){return this.hasError?(e.error(this.thrownError),s.w.EMPTY):this.hasCompleted&&this.hasNext?(e.next(this.value),e.complete(),s.w.EMPTY):t.prototype._subscribe.call(this,e)},e.prototype.next=function(t){this.hasCompleted||(this.value=t,this.hasNext=!0)},e.prototype.error=function(e){this.hasCompleted||t.prototype.error.call(this,e)},e.prototype.complete=function(){this.hasCompleted=!0,this.hasNext&&t.prototype.next.call(this,this.value),t.prototype.complete.call(this)},e}(i.xQ)},9233:(t,e,n)=>{"use strict";n.d(e,{X:()=>o});var r=n(5987),i=n(211),s=n(1016),o=function(t){function e(e){var n=t.call(this)||this;return n._value=e,n}return r.ZT(e,t),Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!0,configurable:!0}),e.prototype._subscribe=function(e){var n=t.prototype._subscribe.call(this,e);return n&&!n.closed&&e.next(this._value),n},e.prototype.getValue=function(){if(this.hasError)throw this.thrownError;if(this.closed)throw new s.N;return this._value},e.prototype.next=function(e){t.prototype.next.call(this,this._value=e)},e}(i.xQ)},2632:(t,e,n)=>{"use strict";n.d(e,{W:()=>r,P:()=>a});var r,i=n(5631),s=n(8170),o=n(4944);r||(r={});var a=function(){function t(t,e,n){this.kind=t,this.value=e,this.error=n,this.hasValue="N"===t}return t.prototype.observe=function(t){switch(this.kind){case"N":return t.next&&t.next(this.value);case"E":return t.error&&t.error(this.error);case"C":return t.complete&&t.complete()}},t.prototype.do=function(t,e,n){switch(this.kind){case"N":return t&&t(this.value);case"E":return e&&e(this.error);case"C":return n&&n()}},t.prototype.accept=function(t,e,n){return t&&"function"==typeof t.next?this.observe(t):this.do(t,e,n)},t.prototype.toObservable=function(){switch(this.kind){case"N":return(0,s.of)(this.value);case"E":return(0,o._)(this.error);case"C":return(0,i.c)()}throw new Error("unexpected notification kind value")},t.createNext=function(e){return void 0!==e?new t("N",e):t.undefinedValueNotification},t.createError=function(e){return new t("E",void 0,e)},t.createComplete=function(){return t.completeNotification},t.completeNotification=new t("C"),t.undefinedValueNotification=new t("N",void 0),t}()},2772:(t,e,n)=>{"use strict";n.d(e,{y:()=>h});var r=n(3642),i=n(979),s=n(3142),o=n(2174),a=n(5050),c=n(2561),u=n(150),h=function(){function t(t){this._isScalar=!1,t&&(this._subscribe=t)}return t.prototype.lift=function(e){var n=new t;return n.source=this,n.operator=e,n},t.prototype.subscribe=function(t,e,n){var r=this.operator,a=function(t,e,n){if(t){if(t instanceof i.L)return t;if(t[s.b])return t[s.b]()}return t||e||n?new i.L(t,e,n):new i.L(o.c)}(t,e,n);if(r?a.add(r.call(a,this.source)):a.add(this.source||u.v.useDeprecatedSynchronousErrorHandling&&!a.syncErrorThrowable?this._subscribe(a):this._trySubscribe(a)),u.v.useDeprecatedSynchronousErrorHandling&&a.syncErrorThrowable&&(a.syncErrorThrowable=!1,a.syncErrorThrown))throw a.syncErrorValue;return a},t.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){u.v.useDeprecatedSynchronousErrorHandling&&(t.syncErrorThrown=!0,t.syncErrorValue=e),(0,r._)(t)?t.error(e):console.warn(e)}},t.prototype.forEach=function(t,e){var n=this;return new(e=l(e))((function(e,r){var i;i=n.subscribe((function(e){try{t(e)}catch(t){r(t),i&&i.unsubscribe()}}),r,e)}))},t.prototype._subscribe=function(t){var e=this.source;return e&&e.subscribe(t)},t.prototype[a.L]=function(){return this},t.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return 0===t.length?this:(0,c.U)(t)(this)},t.prototype.toPromise=function(t){var e=this;return new(t=l(t))((function(t,n){var r;e.subscribe((function(t){return r=t}),(function(t){return n(t)}),(function(){return t(r)}))}))},t.create=function(e){return new t(e)},t}();function l(t){if(t||(t=u.v.Promise||Promise),!t)throw new Error("no Promise impl found");return t}},2174:(t,e,n)=>{"use strict";n.d(e,{c:()=>s});var r=n(150),i=n(1644),s={closed:!0,next:function(t){},error:function(t){if(r.v.useDeprecatedSynchronousErrorHandling)throw t;(0,i.z)(t)},complete:function(){}}},2039:(t,e,n)=>{"use strict";n.d(e,{L:()=>i});var r=n(5987),i=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r.ZT(e,t),e.prototype.notifyNext=function(t,e,n,r,i){this.destination.next(e)},e.prototype.notifyError=function(t,e){this.destination.error(t)},e.prototype.notifyComplete=function(t){this.destination.complete()},e}(n(979).L)},2630:(t,e,n)=>{"use strict";n.d(e,{t:()=>h});var r=n(5987),i=n(211),s=n(2546),o=n(8760),a=n(9276),c=n(1016),u=n(8253),h=function(t){function e(e,n,r){void 0===e&&(e=Number.POSITIVE_INFINITY),void 0===n&&(n=Number.POSITIVE_INFINITY);var i=t.call(this)||this;return i.scheduler=r,i._events=[],i._infiniteTimeWindow=!1,i._bufferSize=e<1?1:e,i._windowTime=n<1?1:n,n===Number.POSITIVE_INFINITY?(i._infiniteTimeWindow=!0,i.next=i.nextInfiniteTimeWindow):i.next=i.nextTimeWindow,i}return r.ZT(e,t),e.prototype.nextInfiniteTimeWindow=function(e){if(!this.isStopped){var n=this._events;n.push(e),n.length>this._bufferSize&&n.shift()}t.prototype.next.call(this,e)},e.prototype.nextTimeWindow=function(e){this.isStopped||(this._events.push(new l(this._getNow(),e)),this._trimBufferThenGetEvents()),t.prototype.next.call(this,e)},e.prototype._subscribe=function(t){var e,n=this._infiniteTimeWindow,r=n?this._events:this._trimBufferThenGetEvents(),i=this.scheduler,s=r.length;if(this.closed)throw new c.N;if(this.isStopped||this.hasError?e=o.w.EMPTY:(this.observers.push(t),e=new u.W(this,t)),i&&t.add(t=new a.ht(t,i)),n)for(var h=0;h<s&&!t.closed;h++)t.next(r[h]);else for(h=0;h<s&&!t.closed;h++)t.next(r[h].value);return this.hasError?t.error(this.thrownError):this.isStopped&&t.complete(),e},e.prototype._getNow=function(){return(this.scheduler||s.c).now()},e.prototype._trimBufferThenGetEvents=function(){for(var t=this._getNow(),e=this._bufferSize,n=this._windowTime,r=this._events,i=r.length,s=0;s<i&&!(t-r[s].time<n);)s++;return i>e&&(s=Math.max(s,i-e)),s>0&&r.splice(0,s),r},e}(i.xQ),l=function(){return function(t,e){this.time=t,this.value=e}}()},8725:(t,e,n)=>{"use strict";n.d(e,{b:()=>r});var r=function(){function t(e,n){void 0===n&&(n=t.now),this.SchedulerAction=e,this.now=n}return t.prototype.schedule=function(t,e,n){return void 0===e&&(e=0),new this.SchedulerAction(this,t).schedule(n,e)},t.now=function(){return Date.now()},t}()},211:(t,e,n)=>{"use strict";n.d(e,{Yc:()=>h,xQ:()=>l});var r=n(5987),i=n(2772),s=n(979),o=n(8760),a=n(1016),c=n(8253),u=n(3142),h=function(t){function e(e){var n=t.call(this,e)||this;return n.destination=e,n}return r.ZT(e,t),e}(s.L),l=function(t){function e(){var e=t.call(this)||this;return e.observers=[],e.closed=!1,e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return r.ZT(e,t),e.prototype[u.b]=function(){return new h(this)},e.prototype.lift=function(t){var e=new d(this,this);return e.operator=t,e},e.prototype.next=function(t){if(this.closed)throw new a.N;if(!this.isStopped)for(var e=this.observers,n=e.length,r=e.slice(),i=0;i<n;i++)r[i].next(t)},e.prototype.error=function(t){if(this.closed)throw new a.N;this.hasError=!0,this.thrownError=t,this.isStopped=!0;for(var e=this.observers,n=e.length,r=e.slice(),i=0;i<n;i++)r[i].error(t);this.observers.length=0},e.prototype.complete=function(){if(this.closed)throw new a.N;this.isStopped=!0;for(var t=this.observers,e=t.length,n=t.slice(),r=0;r<e;r++)n[r].complete();this.observers.length=0},e.prototype.unsubscribe=function(){this.isStopped=!0,this.closed=!0,this.observers=null},e.prototype._trySubscribe=function(e){if(this.closed)throw new a.N;return t.prototype._trySubscribe.call(this,e)},e.prototype._subscribe=function(t){if(this.closed)throw new a.N;return this.hasError?(t.error(this.thrownError),o.w.EMPTY):this.isStopped?(t.complete(),o.w.EMPTY):(this.observers.push(t),new c.W(this,t))},e.prototype.asObservable=function(){var t=new i.y;return t.source=this,t},e.create=function(t,e){return new d(t,e)},e}(i.y),d=function(t){function e(e,n){var r=t.call(this)||this;return r.destination=e,r.source=n,r}return r.ZT(e,t),e.prototype.next=function(t){var e=this.destination;e&&e.next&&e.next(t)},e.prototype.error=function(t){var e=this.destination;e&&e.error&&this.destination.error(t)},e.prototype.complete=function(){var t=this.destination;t&&t.complete&&this.destination.complete()},e.prototype._subscribe=function(t){return this.source?this.source.subscribe(t):o.w.EMPTY},e}(l)},8253:(t,e,n)=>{"use strict";n.d(e,{W:()=>i});var r=n(5987),i=function(t){function e(e,n){var r=t.call(this)||this;return r.subject=e,r.subscriber=n,r.closed=!1,r}return r.ZT(e,t),e.prototype.unsubscribe=function(){if(!this.closed){this.closed=!0;var t=this.subject,e=t.observers;if(this.subject=null,e&&0!==e.length&&!t.isStopped&&!t.closed){var n=e.indexOf(this.subscriber);-1!==n&&e.splice(n,1)}}},e}(n(8760).w)},979:(t,e,n)=>{"use strict";n.d(e,{L:()=>h});var r=n(5987),i=n(4156),s=n(2174),o=n(8760),a=n(3142),c=n(150),u=n(1644),h=function(t){function e(n,r,i){var o=t.call(this)||this;switch(o.syncErrorValue=null,o.syncErrorThrown=!1,o.syncErrorThrowable=!1,o.isStopped=!1,arguments.length){case 0:o.destination=s.c;break;case 1:if(!n){o.destination=s.c;break}if("object"==typeof n){n instanceof e?(o.syncErrorThrowable=n.syncErrorThrowable,o.destination=n,n.add(o)):(o.syncErrorThrowable=!0,o.destination=new l(o,n));break}default:o.syncErrorThrowable=!0,o.destination=new l(o,n,r,i)}return o}return r.ZT(e,t),e.prototype[a.b]=function(){return this},e.create=function(t,n,r){var i=new e(t,n,r);return i.syncErrorThrowable=!1,i},e.prototype.next=function(t){this.isStopped||this._next(t)},e.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this))},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){this.destination.error(t),this.unsubscribe()},e.prototype._complete=function(){this.destination.complete(),this.unsubscribe()},e.prototype._unsubscribeAndRecycle=function(){var t=this._parentOrParents;return this._parentOrParents=null,this.unsubscribe(),this.closed=!1,this.isStopped=!1,this._parentOrParents=t,this},e}(o.w),l=function(t){function e(e,n,r,o){var a,c=t.call(this)||this;c._parentSubscriber=e;var u=c;return(0,i.m)(n)?a=n:n&&(a=n.next,r=n.error,o=n.complete,n!==s.c&&(u=Object.create(n),(0,i.m)(u.unsubscribe)&&c.add(u.unsubscribe.bind(u)),u.unsubscribe=c.unsubscribe.bind(c))),c._context=u,c._next=a,c._error=r,c._complete=o,c}return r.ZT(e,t),e.prototype.next=function(t){if(!this.isStopped&&this._next){var e=this._parentSubscriber;c.v.useDeprecatedSynchronousErrorHandling&&e.syncErrorThrowable?this.__tryOrSetError(e,this._next,t)&&this.unsubscribe():this.__tryOrUnsub(this._next,t)}},e.prototype.error=function(t){if(!this.isStopped){var e=this._parentSubscriber,n=c.v.useDeprecatedSynchronousErrorHandling;if(this._error)n&&e.syncErrorThrowable?(this.__tryOrSetError(e,this._error,t),this.unsubscribe()):(this.__tryOrUnsub(this._error,t),this.unsubscribe());else if(e.syncErrorThrowable)n?(e.syncErrorValue=t,e.syncErrorThrown=!0):(0,u.z)(t),this.unsubscribe();else{if(this.unsubscribe(),n)throw t;(0,u.z)(t)}}},e.prototype.complete=function(){var t=this;if(!this.isStopped){var e=this._parentSubscriber;if(this._complete){var n=function(){return t._complete.call(t._context)};c.v.useDeprecatedSynchronousErrorHandling&&e.syncErrorThrowable?(this.__tryOrSetError(e,n),this.unsubscribe()):(this.__tryOrUnsub(n),this.unsubscribe())}else this.unsubscribe()}},e.prototype.__tryOrUnsub=function(t,e){try{t.call(this._context,e)}catch(t){if(this.unsubscribe(),c.v.useDeprecatedSynchronousErrorHandling)throw t;(0,u.z)(t)}},e.prototype.__tryOrSetError=function(t,e,n){if(!c.v.useDeprecatedSynchronousErrorHandling)throw new Error("bad call");try{e.call(this._context,n)}catch(e){return c.v.useDeprecatedSynchronousErrorHandling?(t.syncErrorValue=e,t.syncErrorThrown=!0,!0):((0,u.z)(e),!0)}return!1},e.prototype._unsubscribe=function(){var t=this._parentSubscriber;this._context=null,this._parentSubscriber=null,t.unsubscribe()},e}(h)},8760:(t,e,n)=>{"use strict";n.d(e,{w:()=>a});var r=n(9026),i=n(2009),s=n(4156),o=n(8782),a=function(){function t(t){this.closed=!1,this._parentOrParents=null,this._subscriptions=null,t&&(this._ctorUnsubscribe=!0,this._unsubscribe=t)}var e;return t.prototype.unsubscribe=function(){var e;if(!this.closed){var n=this,a=n._parentOrParents,u=n._ctorUnsubscribe,h=n._unsubscribe,l=n._subscriptions;if(this.closed=!0,this._parentOrParents=null,this._subscriptions=null,a instanceof t)a.remove(this);else if(null!==a)for(var d=0;d<a.length;++d)a[d].remove(this);if((0,s.m)(h)){u&&(this._unsubscribe=void 0);try{h.call(this)}catch(t){e=t instanceof o.B?c(t.errors):[t]}}if((0,r.k)(l)){d=-1;for(var f=l.length;++d<f;){var p=l[d];if((0,i.K)(p))try{p.unsubscribe()}catch(t){e=e||[],t instanceof o.B?e=e.concat(c(t.errors)):e.push(t)}}}if(e)throw new o.B(e)}},t.prototype.add=function(e){var n=e;if(!e)return t.EMPTY;switch(typeof e){case"function":n=new t(e);case"object":if(n===this||n.closed||"function"!=typeof n.unsubscribe)return n;if(this.closed)return n.unsubscribe(),n;if(!(n instanceof t)){var r=n;(n=new t)._subscriptions=[r]}break;default:throw new Error("unrecognized teardown "+e+" added to Subscription.")}var i=n._parentOrParents;if(null===i)n._parentOrParents=this;else if(i instanceof t){if(i===this)return n;n._parentOrParents=[i,this]}else{if(-1!==i.indexOf(this))return n;i.push(this)}var s=this._subscriptions;return null===s?this._subscriptions=[n]:s.push(n),n},t.prototype.remove=function(t){var e=this._subscriptions;if(e){var n=e.indexOf(t);-1!==n&&e.splice(n,1)}},t.EMPTY=((e=new t).closed=!0,e),t}();function c(t){return t.reduce((function(t,e){return t.concat(e instanceof o.B?e.errors:e)}),[])}},150:(t,e,n)=>{"use strict";n.d(e,{v:()=>i});var r=!1,i={Promise:void 0,set useDeprecatedSynchronousErrorHandling(t){t&&(new Error).stack,r=t},get useDeprecatedSynchronousErrorHandling(){return r}}},7604:(t,e,n)=>{"use strict";n.d(e,{IY:()=>a,Ds:()=>c,ft:()=>u});var r=n(5987),i=n(979),s=n(2772),o=n(7843),a=function(t){function e(e){var n=t.call(this)||this;return n.parent=e,n}return r.ZT(e,t),e.prototype._next=function(t){this.parent.notifyNext(t)},e.prototype._error=function(t){this.parent.notifyError(t),this.unsubscribe()},e.prototype._complete=function(){this.parent.notifyComplete(),this.unsubscribe()},e}(i.L),c=(i.L,function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r.ZT(e,t),e.prototype.notifyNext=function(t){this.destination.next(t)},e.prototype.notifyError=function(t){this.destination.error(t)},e.prototype.notifyComplete=function(){this.destination.complete()},e}(i.L));function u(t,e){if(!e.closed)return t instanceof s.y?t.subscribe(e):(0,o.s)(t)(e)}i.L},3140:(t,e,n)=>{"use strict";n.d(e,{c:()=>u,N:()=>h});var r=n(5987),i=n(211),s=n(2772),o=n(979),a=n(8760),c=n(3018),u=function(t){function e(e,n){var r=t.call(this)||this;return r.source=e,r.subjectFactory=n,r._refCount=0,r._isComplete=!1,r}return r.ZT(e,t),e.prototype._subscribe=function(t){return this.getSubject().subscribe(t)},e.prototype.getSubject=function(){var t=this._subject;return t&&!t.isStopped||(this._subject=this.subjectFactory()),this._subject},e.prototype.connect=function(){var t=this._connection;return t||(this._isComplete=!1,(t=this._connection=new a.w).add(this.source.subscribe(new l(this.getSubject(),this))),t.closed&&(this._connection=null,t=a.w.EMPTY)),t},e.prototype.refCount=function(){return(0,c.x)()(this)},e}(s.y),h=function(){var t=u.prototype;return{operator:{value:null},_refCount:{value:0,writable:!0},_subject:{value:null,writable:!0},_connection:{value:null,writable:!0},_subscribe:{value:t._subscribe},_isComplete:{value:t._isComplete,writable:!0},getSubject:{value:t.getSubject},connect:{value:t.connect},refCount:{value:t.refCount}}}(),l=function(t){function e(e,n){var r=t.call(this,e)||this;return r.connectable=n,r}return r.ZT(e,t),e.prototype._error=function(e){this._unsubscribe(),t.prototype._error.call(this,e)},e.prototype._complete=function(){this.connectable._isComplete=!0,this._unsubscribe(),t.prototype._complete.call(this)},e.prototype._unsubscribe=function(){var t=this.connectable;if(t){this.connectable=null;var e=t._connection;t._refCount=0,t._subject=null,t._connection=null,e&&e.unsubscribe()}},e}(i.Yc);o.L},5142:(t,e,n)=>{"use strict";n.d(e,{aj:()=>h,Ms:()=>l});var r=n(5987),i=n(7507),s=n(9026),o=n(2039),a=n(2080),c=n(3375),u={};function h(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=void 0,r=void 0;return(0,i.K)(t[t.length-1])&&(r=t.pop()),"function"==typeof t[t.length-1]&&(n=t.pop()),1===t.length&&(0,s.k)(t[0])&&(t=t[0]),(0,c.n)(t,r).lift(new l(n))}var l=function(){function t(t){this.resultSelector=t}return t.prototype.call=function(t,e){return e.subscribe(new d(t,this.resultSelector))},t}(),d=function(t){function e(e,n){var r=t.call(this,e)||this;return r.resultSelector=n,r.active=0,r.values=[],r.observables=[],r}return r.ZT(e,t),e.prototype._next=function(t){this.values.push(u),this.observables.push(t)},e.prototype._complete=function(){var t=this.observables,e=t.length;if(0===e)this.destination.complete();else{this.active=e,this.toRespond=e;for(var n=0;n<e;n++){var r=t[n];this.add((0,a.D)(this,r,void 0,n))}}},e.prototype.notifyComplete=function(t){0==(this.active-=1)&&this.destination.complete()},e.prototype.notifyNext=function(t,e,n){var r=this.values,i=r[n],s=this.toRespond?i===u?--this.toRespond:this.toRespond:0;r[n]=e,0===s&&(this.resultSelector?this._tryResultSelector(r):this.destination.next(r.slice()))},e.prototype._tryResultSelector=function(t){var e;try{e=this.resultSelector.apply(this,t)}catch(t){return void this.destination.error(t)}this.destination.next(e)},e}(o.L)},9795:(t,e,n)=>{"use strict";n.d(e,{z:()=>s});var r=n(8170),i=n(2257);function s(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return(0,i.u)()(r.of.apply(void 0,t))}},1410:(t,e,n)=>{"use strict";n.d(e,{P:()=>o});var r=n(2772),i=n(5760),s=n(5631);function o(t){return new r.y((function(e){var n;try{n=t()}catch(t){return void e.error(t)}return(n?(0,i.D)(n):(0,s.c)()).subscribe(e)}))}},5631:(t,e,n)=>{"use strict";n.d(e,{E:()=>i,c:()=>s});var r=n(2772),i=new r.y((function(t){return t.complete()}));function s(t){return t?function(t){return new r.y((function(e){return t.schedule((function(){return e.complete()}))}))}(t):i}},5760:(t,e,n)=>{"use strict";n.d(e,{D:()=>o});var r=n(2772),i=n(7843),s=n(8107);function o(t,e){return e?(0,s.x)(t,e):t instanceof r.y?t:new r.y((0,i.s)(t))}},3375:(t,e,n)=>{"use strict";n.d(e,{n:()=>o});var r=n(2772),i=n(6900),s=n(3109);function o(t,e){return e?(0,s.r)(t,e):new r.y((0,i.V)(t))}},4370:(t,e,n)=>{"use strict";n.d(e,{T:()=>a});var r=n(2772),i=n(7507),s=n(2556),o=n(3375);function a(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=Number.POSITIVE_INFINITY,a=null,c=t[t.length-1];return(0,i.K)(c)?(a=t.pop(),t.length>1&&"number"==typeof t[t.length-1]&&(n=t.pop())):"number"==typeof c&&(n=t.pop()),null===a&&1===t.length&&t[0]instanceof r.y?t[0]:(0,s.J)(n)((0,o.n)(t,a))}},8170:(t,e,n)=>{"use strict";n.d(e,{of:()=>o});var r=n(7507),i=n(3375),s=n(3109);function o(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=t[t.length-1];return(0,r.K)(n)?(t.pop(),(0,s.r)(t,n)):(0,i.n)(t)}},8821:(t,e,n)=>{"use strict";n.d(e,{S3:()=>c});var r=n(5987),i=n(9026),s=n(3375),o=n(2039),a=n(2080);function c(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(1===t.length){if(!(0,i.k)(t[0]))return t[0];t=t[0]}return(0,s.n)(t,void 0).lift(new u)}var u=function(){function t(){}return t.prototype.call=function(t,e){return e.subscribe(new h(t))},t}(),h=function(t){function e(e){var n=t.call(this,e)||this;return n.hasFirst=!1,n.observables=[],n.subscriptions=[],n}return r.ZT(e,t),e.prototype._next=function(t){this.observables.push(t)},e.prototype._complete=function(){var t=this.observables,e=t.length;if(0===e)this.destination.complete();else{for(var n=0;n<e&&!this.hasFirst;n++){var r=t[n],i=(0,a.D)(this,r,void 0,n);this.subscriptions&&this.subscriptions.push(i),this.add(i)}this.observables=null}},e.prototype.notifyNext=function(t,e,n){if(!this.hasFirst){this.hasFirst=!0;for(var r=0;r<this.subscriptions.length;r++)if(r!==n){var i=this.subscriptions[r];i.unsubscribe(),this.remove(i)}this.subscriptions=null}this.destination.next(e)},e}(o.L)},4944:(t,e,n)=>{"use strict";n.d(e,{_:()=>i});var r=n(2772);function i(t,e){return e?new r.y((function(n){return e.schedule(s,0,{error:t,subscriber:n})})):new r.y((function(e){return e.error(t)}))}function s(t){var e=t.error;t.subscriber.error(e)}},9604:(t,e,n)=>{"use strict";n.d(e,{H:()=>a});var r=n(2772),i=n(964),s=n(5812),o=n(7507);function a(t,e,n){void 0===t&&(t=0);var a=-1;return(0,s.k)(e)?a=Number(e)<1?1:Number(e):(0,o.K)(e)&&(n=e),(0,o.K)(n)||(n=i.P),new r.y((function(e){var r=(0,s.k)(t)?t:+t-n.now();return n.schedule(c,r,{index:0,period:a,subscriber:e})}))}function c(t){var e=t.index,n=t.period,r=t.subscriber;if(r.next(e),!r.closed){if(-1===n)return r.complete();t.index=e+1,this.schedule(t,n)}}},5080:(t,e,n)=>{"use strict";n.d(e,{$R:()=>u,mx:()=>h});var r=n(5987),i=n(3375),s=n(9026),o=n(979),a=n(999),c=n(7604);function u(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=t[t.length-1];return"function"==typeof n&&t.pop(),(0,i.n)(t,void 0).lift(new h(n))}var h=function(){function t(t){this.resultSelector=t}return t.prototype.call=function(t,e){return e.subscribe(new l(t,this.resultSelector))},t}(),l=function(t){function e(e,n,r){void 0===r&&(r=Object.create(null));var i=t.call(this,e)||this;return i.resultSelector=n,i.iterators=[],i.active=0,i.resultSelector="function"==typeof n?n:void 0,i}return r.ZT(e,t),e.prototype._next=function(t){var e=this.iterators;(0,s.k)(t)?e.push(new f(t)):"function"==typeof t[a.hZ]?e.push(new d(t[a.hZ]())):e.push(new p(this.destination,this,t))},e.prototype._complete=function(){var t=this.iterators,e=t.length;if(this.unsubscribe(),0!==e){this.active=e;for(var n=0;n<e;n++){var r=t[n];r.stillUnsubscribed?this.destination.add(r.subscribe()):this.active--}}else this.destination.complete()},e.prototype.notifyInactive=function(){this.active--,0===this.active&&this.destination.complete()},e.prototype.checkIterators=function(){for(var t=this.iterators,e=t.length,n=this.destination,r=0;r<e;r++)if("function"==typeof(o=t[r]).hasValue&&!o.hasValue())return;var i=!1,s=[];for(r=0;r<e;r++){var o,a=(o=t[r]).next();if(o.hasCompleted()&&(i=!0),a.done)return void n.complete();s.push(a.value)}this.resultSelector?this._tryresultSelector(s):n.next(s),i&&n.complete()},e.prototype._tryresultSelector=function(t){var e;try{e=this.resultSelector.apply(this,t)}catch(t){return void this.destination.error(t)}this.destination.next(e)},e}(o.L),d=function(){function t(t){this.iterator=t,this.nextResult=t.next()}return t.prototype.hasValue=function(){return!0},t.prototype.next=function(){var t=this.nextResult;return this.nextResult=this.iterator.next(),t},t.prototype.hasCompleted=function(){var t=this.nextResult;return Boolean(t&&t.done)},t}(),f=function(){function t(t){this.array=t,this.index=0,this.length=0,this.length=t.length}return t.prototype[a.hZ]=function(){return this},t.prototype.next=function(t){var e=this.index++,n=this.array;return e<this.length?{value:n[e],done:!1}:{value:null,done:!0}},t.prototype.hasValue=function(){return this.array.length>this.index},t.prototype.hasCompleted=function(){return this.array.length===this.index},t}(),p=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.parent=n,i.observable=r,i.stillUnsubscribed=!0,i.buffer=[],i.isComplete=!1,i}return r.ZT(e,t),e.prototype[a.hZ]=function(){return this},e.prototype.next=function(){var t=this.buffer;return 0===t.length&&this.isComplete?{value:null,done:!0}:{value:t.shift(),done:!1}},e.prototype.hasValue=function(){return this.buffer.length>0},e.prototype.hasCompleted=function(){return 0===this.buffer.length&&this.isComplete},e.prototype.notifyComplete=function(){this.buffer.length>0?(this.isComplete=!0,this.parent.notifyInactive()):this.destination.complete()},e.prototype.notifyNext=function(t){this.buffer.push(t),this.parent.checkIterators()},e.prototype.subscribe=function(){return(0,c.ft)(this.observable,new c.IY(this))},e}(c.Ds)},2257:(t,e,n)=>{"use strict";n.d(e,{u:()=>i});var r=n(2556);function i(){return(0,r.J)(1)}},6008:(t,e,n)=>{"use strict";n.d(e,{h:()=>s});var r=n(5987),i=n(979);function s(t,e){return function(n){return n.lift(new o(t,e))}}var o=function(){function t(t,e){this.predicate=t,this.thisArg=e}return t.prototype.call=function(t,e){return e.subscribe(new a(t,this.predicate,this.thisArg))},t}(),a=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.predicate=n,i.thisArg=r,i.count=0,i}return r.ZT(e,t),e.prototype._next=function(t){var e;try{e=this.predicate.call(this.thisArg,t,this.count++)}catch(t){return void this.destination.error(t)}e&&this.destination.next(t)},e}(i.L)},1120:(t,e,n)=>{"use strict";n.d(e,{v:()=>c,T:()=>d});var r=n(5987),i=n(979),s=n(8760),o=n(2772),a=n(211);function c(t,e,n,r){return function(i){return i.lift(new u(t,e,n,r))}}var u=function(){function t(t,e,n,r){this.keySelector=t,this.elementSelector=e,this.durationSelector=n,this.subjectSelector=r}return t.prototype.call=function(t,e){return e.subscribe(new h(t,this.keySelector,this.elementSelector,this.durationSelector,this.subjectSelector))},t}(),h=function(t){function e(e,n,r,i,s){var o=t.call(this,e)||this;return o.keySelector=n,o.elementSelector=r,o.durationSelector=i,o.subjectSelector=s,o.groups=null,o.attemptedToUnsubscribe=!1,o.count=0,o}return r.ZT(e,t),e.prototype._next=function(t){var e;try{e=this.keySelector(t)}catch(t){return void this.error(t)}this._group(t,e)},e.prototype._group=function(t,e){var n=this.groups;n||(n=this.groups=new Map);var r,i=n.get(e);if(this.elementSelector)try{r=this.elementSelector(t)}catch(t){this.error(t)}else r=t;if(!i){i=this.subjectSelector?this.subjectSelector():new a.xQ,n.set(e,i);var s=new d(e,i,this);if(this.destination.next(s),this.durationSelector){var o=void 0;try{o=this.durationSelector(new d(e,i))}catch(t){return void this.error(t)}this.add(o.subscribe(new l(e,i,this)))}}i.closed||i.next(r)},e.prototype._error=function(t){var e=this.groups;e&&(e.forEach((function(e,n){e.error(t)})),e.clear()),this.destination.error(t)},e.prototype._complete=function(){var t=this.groups;t&&(t.forEach((function(t,e){t.complete()})),t.clear()),this.destination.complete()},e.prototype.removeGroup=function(t){this.groups.delete(t)},e.prototype.unsubscribe=function(){this.closed||(this.attemptedToUnsubscribe=!0,0===this.count&&t.prototype.unsubscribe.call(this))},e}(i.L),l=function(t){function e(e,n,r){var i=t.call(this,n)||this;return i.key=e,i.group=n,i.parent=r,i}return r.ZT(e,t),e.prototype._next=function(t){this.complete()},e.prototype._unsubscribe=function(){var t=this.parent,e=this.key;this.key=this.parent=null,t&&t.removeGroup(e)},e}(i.L),d=function(t){function e(e,n,r){var i=t.call(this)||this;return i.key=e,i.groupSubject=n,i.refCountSubscription=r,i}return r.ZT(e,t),e.prototype._subscribe=function(t){var e=new s.w,n=this.refCountSubscription,r=this.groupSubject;return n&&!n.closed&&e.add(new f(n)),e.add(r.subscribe(t)),e},e}(o.y),f=function(t){function e(e){var n=t.call(this)||this;return n.parent=e,e.count++,n}return r.ZT(e,t),e.prototype.unsubscribe=function(){var e=this.parent;e.closed||this.closed||(t.prototype.unsubscribe.call(this),e.count-=1,0===e.count&&e.attemptedToUnsubscribe&&e.unsubscribe())},e}(s.w)},5709:(t,e,n)=>{"use strict";n.d(e,{U:()=>s});var r=n(5987),i=n(979);function s(t,e){return function(n){if("function"!=typeof t)throw new TypeError("argument is not a function. Are you looking for `mapTo()`?");return n.lift(new o(t,e))}}var o=function(){function t(t,e){this.project=t,this.thisArg=e}return t.prototype.call=function(t,e){return e.subscribe(new a(t,this.project,this.thisArg))},t}(),a=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.project=n,i.count=0,i.thisArg=r||i,i}return r.ZT(e,t),e.prototype._next=function(t){var e;try{e=this.project.call(this.thisArg,t,this.count++)}catch(t){return void this.destination.error(t)}this.destination.next(e)},e}(i.L)},2556:(t,e,n)=>{"use strict";n.d(e,{J:()=>s});var r=n(7746),i=n(3608);function s(t){return void 0===t&&(t=Number.POSITIVE_INFINITY),(0,r.zg)(i.y,t)}},7746:(t,e,n)=>{"use strict";n.d(e,{zg:()=>a,VS:()=>h});var r=n(5987),i=n(5709),s=n(5760),o=n(7604);function a(t,e,n){return void 0===n&&(n=Number.POSITIVE_INFINITY),"function"==typeof e?function(r){return r.pipe(a((function(n,r){return(0,s.D)(t(n,r)).pipe((0,i.U)((function(t,i){return e(n,t,r,i)})))}),n))}:("number"==typeof e&&(n=e),function(e){return e.lift(new c(t,n))})}var c=function(){function t(t,e){void 0===e&&(e=Number.POSITIVE_INFINITY),this.project=t,this.concurrent=e}return t.prototype.call=function(t,e){return e.subscribe(new u(t,this.project,this.concurrent))},t}(),u=function(t){function e(e,n,r){void 0===r&&(r=Number.POSITIVE_INFINITY);var i=t.call(this,e)||this;return i.project=n,i.concurrent=r,i.hasCompleted=!1,i.buffer=[],i.active=0,i.index=0,i}return r.ZT(e,t),e.prototype._next=function(t){this.active<this.concurrent?this._tryNext(t):this.buffer.push(t)},e.prototype._tryNext=function(t){var e,n=this.index++;try{e=this.project(t,n)}catch(t){return void this.destination.error(t)}this.active++,this._innerSub(e)},e.prototype._innerSub=function(t){var e=new o.IY(this),n=this.destination;n.add(e);var r=(0,o.ft)(t,e);r!==e&&n.add(r)},e.prototype._complete=function(){this.hasCompleted=!0,0===this.active&&0===this.buffer.length&&this.destination.complete(),this.unsubscribe()},e.prototype.notifyNext=function(t){this.destination.next(t)},e.prototype.notifyComplete=function(){var t=this.buffer;this.active--,t.length>0?this._next(t.shift()):0===this.active&&this.hasCompleted&&this.destination.complete()},e}(o.Ds),h=a},9276:(t,e,n)=>{"use strict";n.d(e,{QV:()=>o,ht:()=>c});var r=n(5987),i=n(979),s=n(2632);function o(t,e){return void 0===e&&(e=0),function(n){return n.lift(new a(t,e))}}var a=function(){function t(t,e){void 0===e&&(e=0),this.scheduler=t,this.delay=e}return t.prototype.call=function(t,e){return e.subscribe(new c(t,this.scheduler,this.delay))},t}(),c=function(t){function e(e,n,r){void 0===r&&(r=0);var i=t.call(this,e)||this;return i.scheduler=n,i.delay=r,i}return r.ZT(e,t),e.dispatch=function(t){var e=t.notification,n=t.destination;e.observe(n),this.unsubscribe()},e.prototype.scheduleMessage=function(t){this.destination.add(this.scheduler.schedule(e.dispatch,this.delay,new u(t,this.destination)))},e.prototype._next=function(t){this.scheduleMessage(s.P.createNext(t))},e.prototype._error=function(t){this.scheduleMessage(s.P.createError(t)),this.unsubscribe()},e.prototype._complete=function(){this.scheduleMessage(s.P.createComplete()),this.unsubscribe()},e}(i.L),u=function(){return function(t,e){this.notification=t,this.destination=e}}()},3018:(t,e,n)=>{"use strict";n.d(e,{x:()=>s});var r=n(5987),i=n(979);function s(){return function(t){return t.lift(new o(t))}}var o=function(){function t(t){this.connectable=t}return t.prototype.call=function(t,e){var n=this.connectable;n._refCount++;var r=new a(t,n),i=e.subscribe(r);return r.closed||(r.connection=n.connect()),i},t}(),a=function(t){function e(e,n){var r=t.call(this,e)||this;return r.connectable=n,r}return r.ZT(e,t),e.prototype._unsubscribe=function(){var t=this.connectable;if(t){this.connectable=null;var e=t._refCount;if(e<=0)this.connection=null;else if(t._refCount=e-1,e>1)this.connection=null;else{var n=this.connection,r=t._connection;this.connection=null,!r||n&&r!==n||r.unsubscribe()}}else this.connection=null},e}(i.L)},3109:(t,e,n)=>{"use strict";n.d(e,{r:()=>s});var r=n(2772),i=n(8760);function s(t,e){return new r.y((function(n){var r=new i.w,s=0;return r.add(e.schedule((function(){s!==t.length?(n.next(t[s++]),n.closed||r.add(this.schedule())):n.complete()}))),r}))}},8107:(t,e,n)=>{"use strict";n.d(e,{x:()=>h});var r=n(2772),i=n(8760),s=n(5050),o=n(3109),a=n(999),c=n(336),u=n(9217);function h(t,e){if(null!=t){if(function(t){return t&&"function"==typeof t[s.L]}(t))return function(t,e){return new r.y((function(n){var r=new i.w;return r.add(e.schedule((function(){var i=t[s.L]();r.add(i.subscribe({next:function(t){r.add(e.schedule((function(){return n.next(t)})))},error:function(t){r.add(e.schedule((function(){return n.error(t)})))},complete:function(){r.add(e.schedule((function(){return n.complete()})))}}))}))),r}))}(t,e);if((0,c.t)(t))return function(t,e){return new r.y((function(n){var r=new i.w;return r.add(e.schedule((function(){return t.then((function(t){r.add(e.schedule((function(){n.next(t),r.add(e.schedule((function(){return n.complete()})))})))}),(function(t){r.add(e.schedule((function(){return n.error(t)})))}))}))),r}))}(t,e);if((0,u.z)(t))return(0,o.r)(t,e);if(function(t){return t&&"function"==typeof t[a.hZ]}(t)||"string"==typeof t)return function(t,e){if(!t)throw new Error("Iterable cannot be null");return new r.y((function(n){var r,s=new i.w;return s.add((function(){r&&"function"==typeof r.return&&r.return()})),s.add(e.schedule((function(){r=t[a.hZ](),s.add(e.schedule((function(){if(!n.closed){var t,e;try{var i=r.next();t=i.value,e=i.done}catch(t){return void n.error(t)}e?n.complete():(n.next(t),this.schedule())}})))}))),s}))}(t,e)}throw new TypeError((null!==t&&typeof t||t)+" is not observable")}},6114:(t,e,n)=>{"use strict";n.d(e,{o:()=>i});var r=n(5987),i=function(t){function e(e,n){var r=t.call(this,e,n)||this;return r.scheduler=e,r.work=n,r.pending=!1,r}return r.ZT(e,t),e.prototype.schedule=function(t,e){if(void 0===e&&(e=0),this.closed)return this;this.state=t;var n=this.id,r=this.scheduler;return null!=n&&(this.id=this.recycleAsyncId(r,n,e)),this.pending=!0,this.delay=e,this.id=this.id||this.requestAsyncId(r,this.id,e),this},e.prototype.requestAsyncId=function(t,e,n){return void 0===n&&(n=0),setInterval(t.flush.bind(t,this),n)},e.prototype.recycleAsyncId=function(t,e,n){if(void 0===n&&(n=0),null!==n&&this.delay===n&&!1===this.pending)return e;clearInterval(e)},e.prototype.execute=function(t,e){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var n=this._execute(t,e);if(n)return n;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(t,e){var n=!1,r=void 0;try{this.work(t)}catch(t){n=!0,r=!!t&&t||new Error(t)}if(n)return this.unsubscribe(),r},e.prototype._unsubscribe=function(){var t=this.id,e=this.scheduler,n=e.actions,r=n.indexOf(this);this.work=null,this.state=null,this.pending=!1,this.scheduler=null,-1!==r&&n.splice(r,1),null!=t&&(this.id=this.recycleAsyncId(e,t,null)),this.delay=null},e}(function(t){function e(e,n){return t.call(this)||this}return r.ZT(e,t),e.prototype.schedule=function(t,e){return void 0===e&&(e=0),this},e}(n(8760).w))},8399:(t,e,n)=>{"use strict";n.d(e,{v:()=>s});var r=n(5987),i=n(8725),s=function(t){function e(n,r){void 0===r&&(r=i.b.now);var s=t.call(this,n,(function(){return e.delegate&&e.delegate!==s?e.delegate.now():r()}))||this;return s.actions=[],s.active=!1,s.scheduled=void 0,s}return r.ZT(e,t),e.prototype.schedule=function(n,r,i){return void 0===r&&(r=0),e.delegate&&e.delegate!==this?e.delegate.schedule(n,r,i):t.prototype.schedule.call(this,n,r,i)},e.prototype.flush=function(t){var e=this.actions;if(this.active)e.push(t);else{var n;this.active=!0;do{if(n=t.execute(t.state,t.delay))break}while(t=e.shift());if(this.active=!1,n){for(;t=e.shift();)t.unsubscribe();throw n}}},e}(i.b)},6650:(t,e,n)=>{"use strict";n.d(e,{e:()=>l,E:()=>h});var r=n(5987),i=1,s=function(){return Promise.resolve()}(),o={};function a(t){return t in o&&(delete o[t],!0)}var c=function(t){function e(e,n){var r=t.call(this,e,n)||this;return r.scheduler=e,r.work=n,r}return r.ZT(e,t),e.prototype.requestAsyncId=function(e,n,r){return void 0===r&&(r=0),null!==r&&r>0?t.prototype.requestAsyncId.call(this,e,n,r):(e.actions.push(this),e.scheduled||(e.scheduled=(c=e.flush.bind(e,null),u=i++,o[u]=!0,s.then((function(){return a(u)&&c()})),u)));var c,u},e.prototype.recycleAsyncId=function(e,n,r){if(void 0===r&&(r=0),null!==r&&r>0||null===r&&this.delay>0)return t.prototype.recycleAsyncId.call(this,e,n,r);0===e.actions.length&&(a(n),e.scheduled=void 0)},e}(n(6114).o),u=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r.ZT(e,t),e.prototype.flush=function(t){this.active=!0,this.scheduled=void 0;var e,n=this.actions,r=-1,i=n.length;t=t||n.shift();do{if(e=t.execute(t.state,t.delay))break}while(++r<i&&(t=n.shift()));if(this.active=!1,e){for(;++r<i&&(t=n.shift());)t.unsubscribe();throw e}},e}(n(8399).v),h=new u(c),l=h},964:(t,e,n)=>{"use strict";n.d(e,{z:()=>i,P:()=>s});var r=n(6114),i=new(n(8399).v)(r.o),s=i},2546:(t,e,n)=>{"use strict";n.d(e,{c:()=>a,N:()=>o});var r=n(5987),i=function(t){function e(e,n){var r=t.call(this,e,n)||this;return r.scheduler=e,r.work=n,r}return r.ZT(e,t),e.prototype.schedule=function(e,n){return void 0===n&&(n=0),n>0?t.prototype.schedule.call(this,e,n):(this.delay=n,this.state=e,this.scheduler.flush(this),this)},e.prototype.execute=function(e,n){return n>0||this.closed?t.prototype.execute.call(this,e,n):this._execute(e,n)},e.prototype.requestAsyncId=function(e,n,r){return void 0===r&&(r=0),null!==r&&r>0||null===r&&this.delay>0?t.prototype.requestAsyncId.call(this,e,n,r):e.flush(this)},e}(n(6114).o),s=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r.ZT(e,t),e}(n(8399).v),o=new s(i),a=o},999:(t,e,n)=>{"use strict";function r(){return"function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator"}n.d(e,{hZ:()=>i});var i=r()},5050:(t,e,n)=>{"use strict";n.d(e,{L:()=>r});var r=function(){return"function"==typeof Symbol&&Symbol.observable||"@@observable"}()},3142:(t,e,n)=>{"use strict";n.d(e,{b:()=>r});var r=function(){return"function"==typeof Symbol?Symbol("rxSubscriber"):"@@rxSubscriber_"+Math.random()}()},6565:(t,e,n)=>{"use strict";n.d(e,{W:()=>r});var r=function(){function t(){return Error.call(this),this.message="argument out of range",this.name="ArgumentOutOfRangeError",this}return t.prototype=Object.create(Error.prototype),t}()},6929:(t,e,n)=>{"use strict";n.d(e,{K:()=>r});var r=function(){function t(){return Error.call(this),this.message="no elements in sequence",this.name="EmptyError",this}return t.prototype=Object.create(Error.prototype),t}()},1016:(t,e,n)=>{"use strict";n.d(e,{N:()=>r});var r=function(){function t(){return Error.call(this),this.message="object unsubscribed",this.name="ObjectUnsubscribedError",this}return t.prototype=Object.create(Error.prototype),t}()},1462:(t,e,n)=>{"use strict";n.d(e,{W:()=>r});var r=function(){function t(){return Error.call(this),this.message="Timeout has occurred",this.name="TimeoutError",this}return t.prototype=Object.create(Error.prototype),t}()},8782:(t,e,n)=>{"use strict";n.d(e,{B:()=>r});var r=function(){function t(t){return Error.call(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(t,e){return e+1+") "+t.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t,this}return t.prototype=Object.create(Error.prototype),t}()},3642:(t,e,n)=>{"use strict";n.d(e,{_:()=>i});var r=n(979);function i(t){for(;t;){var e=t,n=e.closed,i=e.destination,s=e.isStopped;if(n||s)return!1;t=i&&i instanceof r.L?i:null}return!0}},1644:(t,e,n)=>{"use strict";function r(t){setTimeout((function(){throw t}),0)}n.d(e,{z:()=>r})},3608:(t,e,n)=>{"use strict";function r(t){return t}n.d(e,{y:()=>r})},9026:(t,e,n)=>{"use strict";n.d(e,{k:()=>r});var r=function(){return Array.isArray||function(t){return t&&"number"==typeof t.length}}()},9217:(t,e,n)=>{"use strict";n.d(e,{z:()=>r});var r=function(t){return t&&"number"==typeof t.length&&"function"!=typeof t}},4156:(t,e,n)=>{"use strict";function r(t){return"function"==typeof t}n.d(e,{m:()=>r})},5812:(t,e,n)=>{"use strict";n.d(e,{k:()=>i});var r=n(9026);function i(t){return!(0,r.k)(t)&&t-parseFloat(t)+1>=0}},2009:(t,e,n)=>{"use strict";function r(t){return null!==t&&"object"==typeof t}n.d(e,{K:()=>r})},336:(t,e,n)=>{"use strict";function r(t){return!!t&&"function"!=typeof t.subscribe&&"function"==typeof t.then}n.d(e,{t:()=>r})},7507:(t,e,n)=>{"use strict";function r(t){return t&&"function"==typeof t.schedule}n.d(e,{K:()=>r})},3306:(t,e,n)=>{"use strict";function r(){}n.d(e,{Z:()=>r})},9067:(t,e,n)=>{"use strict";function r(t,e){function n(){return!n.pred.apply(n.thisArg,arguments)}return n.pred=t,n.thisArg=e,n}n.d(e,{f:()=>r})},2561:(t,e,n)=>{"use strict";n.d(e,{z:()=>i,U:()=>s});var r=n(3608);function i(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return s(t)}function s(t){return 0===t.length?r.y:1===t.length?t[0]:function(e){return t.reduce((function(t,e){return e(t)}),e)}}},7843:(t,e,n)=>{"use strict";n.d(e,{s:()=>h});var r=n(6900),i=n(1644),s=n(999),o=n(5050),a=n(9217),c=n(336),u=n(2009),h=function(t){if(t&&"function"==typeof t[o.L])return h=t,function(t){var e=h[o.L]();if("function"!=typeof e.subscribe)throw new TypeError("Provided object does not correctly implement Symbol.observable");return e.subscribe(t)};if((0,a.z)(t))return(0,r.V)(t);if((0,c.t)(t))return n=t,function(t){return n.then((function(e){t.closed||(t.next(e),t.complete())}),(function(e){return t.error(e)})).then(null,i.z),t};if(t&&"function"==typeof t[s.hZ])return e=t,function(t){for(var n=e[s.hZ]();;){var r=void 0;try{r=n.next()}catch(e){return t.error(e),t}if(r.done){t.complete();break}if(t.next(r.value),t.closed)break}return"function"==typeof n.return&&t.add((function(){n.return&&n.return()})),t};var e,n,h,l=(0,u.K)(t)?"an invalid object":"'"+t+"'";throw new TypeError("You provided "+l+" where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.")}},6900:(t,e,n)=>{"use strict";n.d(e,{V:()=>r});var r=function(t){return function(e){for(var n=0,r=t.length;n<r&&!e.closed;n++)e.next(t[n]);e.complete()}}},2080:(t,e,n)=>{"use strict";n.d(e,{D:()=>a});var r=n(5987),i=function(t){function e(e,n,r){var i=t.call(this)||this;return i.parent=e,i.outerValue=n,i.outerIndex=r,i.index=0,i}return r.ZT(e,t),e.prototype._next=function(t){this.parent.notifyNext(this.outerValue,t,this.outerIndex,this.index++,this)},e.prototype._error=function(t){this.parent.notifyError(t,this),this.unsubscribe()},e.prototype._complete=function(){this.parent.notifyComplete(this),this.unsubscribe()},e}(n(979).L),s=n(7843),o=n(2772);function a(t,e,n,r,a){if(void 0===a&&(a=new i(t,n,r)),!a.closed)return e instanceof o.y?e.subscribe(a):(0,s.s)(e)(a)}},1717:(t,e,n)=>{"use strict";n.r(e),n.d(e,{audit:()=>s,auditTime:()=>h,buffer:()=>l,bufferCount:()=>m,bufferTime:()=>w,bufferToggle:()=>C,bufferWhen:()=>R,catchError:()=>M,combineAll:()=>j,combineLatest:()=>z,concat:()=>W,concatAll:()=>G.u,concatMap:()=>$,concatMapTo:()=>Y,count:()=>Q,debounce:()=>X,debounceTime:()=>nt,defaultIfEmpty:()=>ot,delay:()=>lt,delayWhen:()=>gt,dematerialize:()=>It,distinct:()=>Et,distinctUntilChanged:()=>At,distinctUntilKeyChanged:()=>Ct,elementAt:()=>Bt,endWith:()=>Kt,every:()=>Wt,exhaust:()=>$t,exhaustMap:()=>Zt,expand:()=>ee,filter:()=>Ot.h,finalize:()=>ie,find:()=>ae,findIndex:()=>he,first:()=>de,flatMap:()=>H.VS,groupBy:()=>fe.v,ignoreElements:()=>pe,isEmpty:()=>ye,last:()=>_e,map:()=>Jt.U,mapTo:()=>Ee,materialize:()=>Ae,max:()=>Le,merge:()=>Fe,mergeAll:()=>Ue.J,mergeMap:()=>H.zg,mergeMapTo:()=>Ve,mergeScan:()=>je,min:()=>ze,multicast:()=>We,observeOn:()=>He.QV,onErrorResumeNext:()=>$e,pairwise:()=>Je,partition:()=>en,pluck:()=>nn,publish:()=>on,publishBehavior:()=>cn,publishLast:()=>hn,publishReplay:()=>dn,race:()=>pn,reduce:()=>Pe,refCount:()=>An.x,repeat:()=>mn,repeatWhen:()=>vn,retry:()=>In,retryWhen:()=>En,sample:()=>Nn,sampleTime:()=>Dn,scan:()=>Ce,sequenceEqual:()=>Ln,share:()=>jn,shareReplay:()=>qn,single:()=>Bn,skip:()=>Wn,skipLast:()=>$n,skipUntil:()=>Jn,skipWhile:()=>tr,startWith:()=>rr,subscribeOn:()=>ar,switchAll:()=>dr,switchMap:()=>ur,switchMapTo:()=>fr,take:()=>Vt,takeLast:()=>we,takeUntil:()=>pr,takeWhile:()=>yr,tap:()=>Tr,throttle:()=>kr,throttleTime:()=>xr,throwIfEmpty:()=>Pt,timeInterval:()=>Pr,timeout:()=>qr,timeoutWith:()=>Fr,timestamp:()=>Br,toArray:()=>Wr,window:()=>Gr,windowCount:()=>Yr,windowTime:()=>Zr,windowToggle:()=>si,windowWhen:()=>ci,withLatestFrom:()=>li,zip:()=>mi,zipAll:()=>gi});var r=n(5987),i=n(7604);function s(t){return function(e){return e.lift(new o(t))}}var o=function(){function t(t){this.durationSelector=t}return t.prototype.call=function(t,e){return e.subscribe(new a(t,this.durationSelector))},t}(),a=function(t){function e(e,n){var r=t.call(this,e)||this;return r.durationSelector=n,r.hasValue=!1,r}return r.ZT(e,t),e.prototype._next=function(t){if(this.value=t,this.hasValue=!0,!this.throttled){var e=void 0;try{e=(0,this.durationSelector)(t)}catch(t){return this.destination.error(t)}var n=(0,i.ft)(e,new i.IY(this));!n||n.closed?this.clearThrottle():this.add(this.throttled=n)}},e.prototype.clearThrottle=function(){var t=this,e=t.value,n=t.hasValue,r=t.throttled;r&&(this.remove(r),this.throttled=void 0,r.unsubscribe()),n&&(this.value=void 0,this.hasValue=!1,this.destination.next(e))},e.prototype.notifyNext=function(){this.clearThrottle()},e.prototype.notifyComplete=function(){this.clearThrottle()},e}(i.Ds),c=n(964),u=n(9604);function h(t,e){return void 0===e&&(e=c.P),s((function(){return(0,u.H)(t,e)}))}function l(t){return function(e){return e.lift(new d(t))}}var d=function(){function t(t){this.closingNotifier=t}return t.prototype.call=function(t,e){return e.subscribe(new f(t,this.closingNotifier))},t}(),f=function(t){function e(e,n){var r=t.call(this,e)||this;return r.buffer=[],r.add((0,i.ft)(n,new i.IY(r))),r}return r.ZT(e,t),e.prototype._next=function(t){this.buffer.push(t)},e.prototype.notifyNext=function(){var t=this.buffer;this.buffer=[],this.destination.next(t)},e}(i.Ds),p=n(979);function m(t,e){return void 0===e&&(e=null),function(n){return n.lift(new g(t,e))}}var g=function(){function t(t,e){this.bufferSize=t,this.startBufferEvery=e,this.subscriberClass=e&&t!==e?v:y}return t.prototype.call=function(t,e){return e.subscribe(new this.subscriberClass(t,this.bufferSize,this.startBufferEvery))},t}(),y=function(t){function e(e,n){var r=t.call(this,e)||this;return r.bufferSize=n,r.buffer=[],r}return r.ZT(e,t),e.prototype._next=function(t){var e=this.buffer;e.push(t),e.length==this.bufferSize&&(this.destination.next(e),this.buffer=[])},e.prototype._complete=function(){var e=this.buffer;e.length>0&&this.destination.next(e),t.prototype._complete.call(this)},e}(p.L),v=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.bufferSize=n,i.startBufferEvery=r,i.buffers=[],i.count=0,i}return r.ZT(e,t),e.prototype._next=function(t){var e=this,n=e.bufferSize,r=e.startBufferEvery,i=e.buffers,s=e.count;this.count++,s%r==0&&i.push([]);for(var o=i.length;o--;){var a=i[o];a.push(t),a.length===n&&(i.splice(o,1),this.destination.next(a))}},e.prototype._complete=function(){for(var e=this.buffers,n=this.destination;e.length>0;){var r=e.shift();r.length>0&&n.next(r)}t.prototype._complete.call(this)},e}(p.L),b=n(7507);function w(t){var e=arguments.length,n=c.P;(0,b.K)(arguments[arguments.length-1])&&(n=arguments[arguments.length-1],e--);var r=null;e>=2&&(r=arguments[1]);var i=Number.POSITIVE_INFINITY;return e>=3&&(i=arguments[2]),function(e){return e.lift(new I(t,r,i,n))}}var I=function(){function t(t,e,n,r){this.bufferTimeSpan=t,this.bufferCreationInterval=e,this.maxBufferSize=n,this.scheduler=r}return t.prototype.call=function(t,e){return e.subscribe(new _(t,this.bufferTimeSpan,this.bufferCreationInterval,this.maxBufferSize,this.scheduler))},t}(),T=function(){return function(){this.buffer=[]}}(),_=function(t){function e(e,n,r,i,s){var o=t.call(this,e)||this;o.bufferTimeSpan=n,o.bufferCreationInterval=r,o.maxBufferSize=i,o.scheduler=s,o.contexts=[];var a=o.openContext();if(o.timespanOnly=null==r||r<0,o.timespanOnly){var c={subscriber:o,context:a,bufferTimeSpan:n};o.add(a.closeAction=s.schedule(E,n,c))}else{var u={subscriber:o,context:a},h={bufferTimeSpan:n,bufferCreationInterval:r,subscriber:o,scheduler:s};o.add(a.closeAction=s.schedule(k,n,u)),o.add(s.schedule(S,r,h))}return o}return r.ZT(e,t),e.prototype._next=function(t){for(var e,n=this.contexts,r=n.length,i=0;i<r;i++){var s=n[i],o=s.buffer;o.push(t),o.length==this.maxBufferSize&&(e=s)}e&&this.onBufferFull(e)},e.prototype._error=function(e){this.contexts.length=0,t.prototype._error.call(this,e)},e.prototype._complete=function(){for(var e=this.contexts,n=this.destination;e.length>0;){var r=e.shift();n.next(r.buffer)}t.prototype._complete.call(this)},e.prototype._unsubscribe=function(){this.contexts=null},e.prototype.onBufferFull=function(t){this.closeContext(t);var e=t.closeAction;if(e.unsubscribe(),this.remove(e),!this.closed&&this.timespanOnly){t=this.openContext();var n=this.bufferTimeSpan,r={subscriber:this,context:t,bufferTimeSpan:n};this.add(t.closeAction=this.scheduler.schedule(E,n,r))}},e.prototype.openContext=function(){var t=new T;return this.contexts.push(t),t},e.prototype.closeContext=function(t){this.destination.next(t.buffer);var e=this.contexts;(e?e.indexOf(t):-1)>=0&&e.splice(e.indexOf(t),1)},e}(p.L);function E(t){var e=t.subscriber,n=t.context;n&&e.closeContext(n),e.closed||(t.context=e.openContext(),t.context.closeAction=this.schedule(t,t.bufferTimeSpan))}function S(t){var e=t.bufferCreationInterval,n=t.bufferTimeSpan,r=t.subscriber,i=t.scheduler,s=r.openContext();r.closed||(r.add(s.closeAction=i.schedule(k,n,{subscriber:r,context:s})),this.schedule(t,e))}function k(t){var e=t.subscriber,n=t.context;e.closeContext(n)}var A=n(8760),N=n(2080),x=n(2039);function C(t,e){return function(n){return n.lift(new D(t,e))}}var D=function(){function t(t,e){this.openings=t,this.closingSelector=e}return t.prototype.call=function(t,e){return e.subscribe(new O(t,this.openings,this.closingSelector))},t}(),O=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.closingSelector=r,i.contexts=[],i.add((0,N.D)(i,n)),i}return r.ZT(e,t),e.prototype._next=function(t){for(var e=this.contexts,n=e.length,r=0;r<n;r++)e[r].buffer.push(t)},e.prototype._error=function(e){for(var n=this.contexts;n.length>0;){var r=n.shift();r.subscription.unsubscribe(),r.buffer=null,r.subscription=null}this.contexts=null,t.prototype._error.call(this,e)},e.prototype._complete=function(){for(var e=this.contexts;e.length>0;){var n=e.shift();this.destination.next(n.buffer),n.subscription.unsubscribe(),n.buffer=null,n.subscription=null}this.contexts=null,t.prototype._complete.call(this)},e.prototype.notifyNext=function(t,e){t?this.closeBuffer(t):this.openBuffer(e)},e.prototype.notifyComplete=function(t){this.closeBuffer(t.context)},e.prototype.openBuffer=function(t){try{var e=this.closingSelector.call(this,t);e&&this.trySubscribe(e)}catch(t){this._error(t)}},e.prototype.closeBuffer=function(t){var e=this.contexts;if(e&&t){var n=t.buffer,r=t.subscription;this.destination.next(n),e.splice(e.indexOf(t),1),this.remove(r),r.unsubscribe()}},e.prototype.trySubscribe=function(t){var e=this.contexts,n=new A.w,r={buffer:[],subscription:n};e.push(r);var i=(0,N.D)(this,t,r);!i||i.closed?this.closeBuffer(r):(i.context=r,this.add(i),n.add(i))},e}(x.L);function R(t){return function(e){return e.lift(new P(t))}}var P=function(){function t(t){this.closingSelector=t}return t.prototype.call=function(t,e){return e.subscribe(new L(t,this.closingSelector))},t}(),L=function(t){function e(e,n){var r=t.call(this,e)||this;return r.closingSelector=n,r.subscribing=!1,r.openBuffer(),r}return r.ZT(e,t),e.prototype._next=function(t){this.buffer.push(t)},e.prototype._complete=function(){var e=this.buffer;e&&this.destination.next(e),t.prototype._complete.call(this)},e.prototype._unsubscribe=function(){this.buffer=void 0,this.subscribing=!1},e.prototype.notifyNext=function(){this.openBuffer()},e.prototype.notifyComplete=function(){this.subscribing?this.complete():this.openBuffer()},e.prototype.openBuffer=function(){var t=this.closingSubscription;t&&(this.remove(t),t.unsubscribe());var e,n=this.buffer;this.buffer&&this.destination.next(n),this.buffer=[];try{e=(0,this.closingSelector)()}catch(t){return this.error(t)}t=new A.w,this.closingSubscription=t,this.add(t),this.subscribing=!0,t.add((0,i.ft)(e,new i.IY(this))),this.subscribing=!1},e}(i.Ds);function M(t){return function(e){var n=new F(t),r=e.lift(n);return n.caught=r}}var F=function(){function t(t){this.selector=t}return t.prototype.call=function(t,e){return e.subscribe(new U(t,this.selector,this.caught))},t}(),U=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.selector=n,i.caught=r,i}return r.ZT(e,t),e.prototype.error=function(e){if(!this.isStopped){var n=void 0;try{n=this.selector(e,this.caught)}catch(e){return void t.prototype.error.call(this,e)}this._unsubscribeAndRecycle();var r=new i.IY(this);this.add(r);var s=(0,i.ft)(n,r);s!==r&&this.add(s)}},e}(i.Ds),V=n(5142);function j(t){return function(e){return e.lift(new V.Ms(t))}}var q=n(9026),B=n(5760);function z(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=null;return"function"==typeof t[t.length-1]&&(n=t.pop()),1===t.length&&(0,q.k)(t[0])&&(t=t[0].slice()),function(e){return e.lift.call((0,B.D)([e].concat(t)),new V.Ms(n))}}var K=n(9795);function W(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return function(e){return e.lift.call(K.z.apply(void 0,[e].concat(t)))}}var G=n(2257),H=n(7746);function $(t,e){return(0,H.zg)(t,e,1)}function Y(t,e){return $((function(){return t}),e)}function Q(t){return function(e){return e.lift(new J(t,e))}}var J=function(){function t(t,e){this.predicate=t,this.source=e}return t.prototype.call=function(t,e){return e.subscribe(new Z(t,this.predicate,this.source))},t}(),Z=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.predicate=n,i.source=r,i.count=0,i.index=0,i}return r.ZT(e,t),e.prototype._next=function(t){this.predicate?this._tryPredicate(t):this.count++},e.prototype._tryPredicate=function(t){var e;try{e=this.predicate(t,this.index++,this.source)}catch(t){return void this.destination.error(t)}e&&this.count++},e.prototype._complete=function(){this.destination.next(this.count),this.destination.complete()},e}(p.L);function X(t){return function(e){return e.lift(new tt(t))}}var tt=function(){function t(t){this.durationSelector=t}return t.prototype.call=function(t,e){return e.subscribe(new et(t,this.durationSelector))},t}(),et=function(t){function e(e,n){var r=t.call(this,e)||this;return r.durationSelector=n,r.hasValue=!1,r}return r.ZT(e,t),e.prototype._next=function(t){try{var e=this.durationSelector.call(this,t);e&&this._tryNext(t,e)}catch(t){this.destination.error(t)}},e.prototype._complete=function(){this.emitValue(),this.destination.complete()},e.prototype._tryNext=function(t,e){var n=this.durationSubscription;this.value=t,this.hasValue=!0,n&&(n.unsubscribe(),this.remove(n)),(n=(0,i.ft)(e,new i.IY(this)))&&!n.closed&&this.add(this.durationSubscription=n)},e.prototype.notifyNext=function(){this.emitValue()},e.prototype.notifyComplete=function(){this.emitValue()},e.prototype.emitValue=function(){if(this.hasValue){var e=this.value,n=this.durationSubscription;n&&(this.durationSubscription=void 0,n.unsubscribe(),this.remove(n)),this.value=void 0,this.hasValue=!1,t.prototype._next.call(this,e)}},e}(i.Ds);function nt(t,e){return void 0===e&&(e=c.P),function(n){return n.lift(new rt(t,e))}}var rt=function(){function t(t,e){this.dueTime=t,this.scheduler=e}return t.prototype.call=function(t,e){return e.subscribe(new it(t,this.dueTime,this.scheduler))},t}(),it=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.dueTime=n,i.scheduler=r,i.debouncedSubscription=null,i.lastValue=null,i.hasValue=!1,i}return r.ZT(e,t),e.prototype._next=function(t){this.clearDebounce(),this.lastValue=t,this.hasValue=!0,this.add(this.debouncedSubscription=this.scheduler.schedule(st,this.dueTime,this))},e.prototype._complete=function(){this.debouncedNext(),this.destination.complete()},e.prototype.debouncedNext=function(){if(this.clearDebounce(),this.hasValue){var t=this.lastValue;this.lastValue=null,this.hasValue=!1,this.destination.next(t)}},e.prototype.clearDebounce=function(){var t=this.debouncedSubscription;null!==t&&(this.remove(t),t.unsubscribe(),this.debouncedSubscription=null)},e}(p.L);function st(t){t.debouncedNext()}function ot(t){return void 0===t&&(t=null),function(e){return e.lift(new at(t))}}var at=function(){function t(t){this.defaultValue=t}return t.prototype.call=function(t,e){return e.subscribe(new ct(t,this.defaultValue))},t}(),ct=function(t){function e(e,n){var r=t.call(this,e)||this;return r.defaultValue=n,r.isEmpty=!0,r}return r.ZT(e,t),e.prototype._next=function(t){this.isEmpty=!1,this.destination.next(t)},e.prototype._complete=function(){this.isEmpty&&this.destination.next(this.defaultValue),this.destination.complete()},e}(p.L);function ut(t){return t instanceof Date&&!isNaN(+t)}var ht=n(2632);function lt(t,e){void 0===e&&(e=c.P);var n=ut(t)?+t-e.now():Math.abs(t);return function(t){return t.lift(new dt(n,e))}}var dt=function(){function t(t,e){this.delay=t,this.scheduler=e}return t.prototype.call=function(t,e){return e.subscribe(new ft(t,this.delay,this.scheduler))},t}(),ft=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.delay=n,i.scheduler=r,i.queue=[],i.active=!1,i.errored=!1,i}return r.ZT(e,t),e.dispatch=function(t){for(var e=t.source,n=e.queue,r=t.scheduler,i=t.destination;n.length>0&&n[0].time-r.now()<=0;)n.shift().notification.observe(i);if(n.length>0){var s=Math.max(0,n[0].time-r.now());this.schedule(t,s)}else this.unsubscribe(),e.active=!1},e.prototype._schedule=function(t){this.active=!0,this.destination.add(t.schedule(e.dispatch,this.delay,{source:this,destination:this.destination,scheduler:t}))},e.prototype.scheduleNotification=function(t){if(!0!==this.errored){var e=this.scheduler,n=new pt(e.now()+this.delay,t);this.queue.push(n),!1===this.active&&this._schedule(e)}},e.prototype._next=function(t){this.scheduleNotification(ht.P.createNext(t))},e.prototype._error=function(t){this.errored=!0,this.queue=[],this.destination.error(t),this.unsubscribe()},e.prototype._complete=function(){this.scheduleNotification(ht.P.createComplete()),this.unsubscribe()},e}(p.L),pt=function(){return function(t,e){this.time=t,this.notification=e}}(),mt=n(2772);function gt(t,e){return e?function(n){return new bt(n,e).lift(new yt(t))}:function(e){return e.lift(new yt(t))}}var yt=function(){function t(t){this.delayDurationSelector=t}return t.prototype.call=function(t,e){return e.subscribe(new vt(t,this.delayDurationSelector))},t}(),vt=function(t){function e(e,n){var r=t.call(this,e)||this;return r.delayDurationSelector=n,r.completed=!1,r.delayNotifierSubscriptions=[],r.index=0,r}return r.ZT(e,t),e.prototype.notifyNext=function(t,e,n,r,i){this.destination.next(t),this.removeSubscription(i),this.tryComplete()},e.prototype.notifyError=function(t,e){this._error(t)},e.prototype.notifyComplete=function(t){var e=this.removeSubscription(t);e&&this.destination.next(e),this.tryComplete()},e.prototype._next=function(t){var e=this.index++;try{var n=this.delayDurationSelector(t,e);n&&this.tryDelay(n,t)}catch(t){this.destination.error(t)}},e.prototype._complete=function(){this.completed=!0,this.tryComplete(),this.unsubscribe()},e.prototype.removeSubscription=function(t){t.unsubscribe();var e=this.delayNotifierSubscriptions.indexOf(t);return-1!==e&&this.delayNotifierSubscriptions.splice(e,1),t.outerValue},e.prototype.tryDelay=function(t,e){var n=(0,N.D)(this,t,e);n&&!n.closed&&(this.destination.add(n),this.delayNotifierSubscriptions.push(n))},e.prototype.tryComplete=function(){this.completed&&0===this.delayNotifierSubscriptions.length&&this.destination.complete()},e}(x.L),bt=function(t){function e(e,n){var r=t.call(this)||this;return r.source=e,r.subscriptionDelay=n,r}return r.ZT(e,t),e.prototype._subscribe=function(t){this.subscriptionDelay.subscribe(new wt(t,this.source))},e}(mt.y),wt=function(t){function e(e,n){var r=t.call(this)||this;return r.parent=e,r.source=n,r.sourceSubscribed=!1,r}return r.ZT(e,t),e.prototype._next=function(t){this.subscribeToSource()},e.prototype._error=function(t){this.unsubscribe(),this.parent.error(t)},e.prototype._complete=function(){this.unsubscribe(),this.subscribeToSource()},e.prototype.subscribeToSource=function(){this.sourceSubscribed||(this.sourceSubscribed=!0,this.unsubscribe(),this.source.subscribe(this.parent))},e}(p.L);function It(){return function(t){return t.lift(new Tt)}}var Tt=function(){function t(){}return t.prototype.call=function(t,e){return e.subscribe(new _t(t))},t}(),_t=function(t){function e(e){return t.call(this,e)||this}return r.ZT(e,t),e.prototype._next=function(t){t.observe(this.destination)},e}(p.L);function Et(t,e){return function(n){return n.lift(new St(t,e))}}var St=function(){function t(t,e){this.keySelector=t,this.flushes=e}return t.prototype.call=function(t,e){return e.subscribe(new kt(t,this.keySelector,this.flushes))},t}(),kt=function(t){function e(e,n,r){var s=t.call(this,e)||this;return s.keySelector=n,s.values=new Set,r&&s.add((0,i.ft)(r,new i.IY(s))),s}return r.ZT(e,t),e.prototype.notifyNext=function(){this.values.clear()},e.prototype.notifyError=function(t){this._error(t)},e.prototype._next=function(t){this.keySelector?this._useKeySelector(t):this._finalizeNext(t,t)},e.prototype._useKeySelector=function(t){var e,n=this.destination;try{e=this.keySelector(t)}catch(t){return void n.error(t)}this._finalizeNext(e,t)},e.prototype._finalizeNext=function(t,e){var n=this.values;n.has(t)||(n.add(t),this.destination.next(e))},e}(i.Ds);function At(t,e){return function(n){return n.lift(new Nt(t,e))}}var Nt=function(){function t(t,e){this.compare=t,this.keySelector=e}return t.prototype.call=function(t,e){return e.subscribe(new xt(t,this.compare,this.keySelector))},t}(),xt=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.keySelector=r,i.hasKey=!1,"function"==typeof n&&(i.compare=n),i}return r.ZT(e,t),e.prototype.compare=function(t,e){return t===e},e.prototype._next=function(t){var e;try{var n=this.keySelector;e=n?n(t):t}catch(t){return this.destination.error(t)}var r=!1;if(this.hasKey)try{r=(0,this.compare)(this.key,e)}catch(t){return this.destination.error(t)}else this.hasKey=!0;r||(this.key=e,this.destination.next(t))},e}(p.L);function Ct(t,e){return At((function(n,r){return e?e(n[t],r[t]):n[t]===r[t]}))}var Dt=n(6565),Ot=n(6008),Rt=n(6929);function Pt(t){return void 0===t&&(t=Ft),function(e){return e.lift(new Lt(t))}}var Lt=function(){function t(t){this.errorFactory=t}return t.prototype.call=function(t,e){return e.subscribe(new Mt(t,this.errorFactory))},t}(),Mt=function(t){function e(e,n){var r=t.call(this,e)||this;return r.errorFactory=n,r.hasValue=!1,r}return r.ZT(e,t),e.prototype._next=function(t){this.hasValue=!0,this.destination.next(t)},e.prototype._complete=function(){if(this.hasValue)return this.destination.complete();var t=void 0;try{t=this.errorFactory()}catch(e){t=e}this.destination.error(t)},e}(p.L);function Ft(){return new Rt.K}var Ut=n(5631);function Vt(t){return function(e){return 0===t?(0,Ut.c)():e.lift(new jt(t))}}var jt=function(){function t(t){if(this.total=t,this.total<0)throw new Dt.W}return t.prototype.call=function(t,e){return e.subscribe(new qt(t,this.total))},t}(),qt=function(t){function e(e,n){var r=t.call(this,e)||this;return r.total=n,r.count=0,r}return r.ZT(e,t),e.prototype._next=function(t){var e=this.total,n=++this.count;n<=e&&(this.destination.next(t),n===e&&(this.destination.complete(),this.unsubscribe()))},e}(p.L);function Bt(t,e){if(t<0)throw new Dt.W;var n=arguments.length>=2;return function(r){return r.pipe((0,Ot.h)((function(e,n){return n===t})),Vt(1),n?ot(e):Pt((function(){return new Dt.W})))}}var zt=n(8170);function Kt(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return function(e){return(0,K.z)(e,zt.of.apply(void 0,t))}}function Wt(t,e){return function(n){return n.lift(new Gt(t,e,n))}}var Gt=function(){function t(t,e,n){this.predicate=t,this.thisArg=e,this.source=n}return t.prototype.call=function(t,e){return e.subscribe(new Ht(t,this.predicate,this.thisArg,this.source))},t}(),Ht=function(t){function e(e,n,r,i){var s=t.call(this,e)||this;return s.predicate=n,s.thisArg=r,s.source=i,s.index=0,s.thisArg=r||s,s}return r.ZT(e,t),e.prototype.notifyComplete=function(t){this.destination.next(t),this.destination.complete()},e.prototype._next=function(t){var e=!1;try{e=this.predicate.call(this.thisArg,t,this.index++,this.source)}catch(t){return void this.destination.error(t)}e||this.notifyComplete(!1)},e.prototype._complete=function(){this.notifyComplete(!0)},e}(p.L);function $t(){return function(t){return t.lift(new Yt)}}var Yt=function(){function t(){}return t.prototype.call=function(t,e){return e.subscribe(new Qt(t))},t}(),Qt=function(t){function e(e){var n=t.call(this,e)||this;return n.hasCompleted=!1,n.hasSubscription=!1,n}return r.ZT(e,t),e.prototype._next=function(t){this.hasSubscription||(this.hasSubscription=!0,this.add((0,i.ft)(t,new i.IY(this))))},e.prototype._complete=function(){this.hasCompleted=!0,this.hasSubscription||this.destination.complete()},e.prototype.notifyComplete=function(){this.hasSubscription=!1,this.hasCompleted&&this.destination.complete()},e}(i.Ds),Jt=n(5709);function Zt(t,e){return e?function(n){return n.pipe(Zt((function(n,r){return(0,B.D)(t(n,r)).pipe((0,Jt.U)((function(t,i){return e(n,t,r,i)})))})))}:function(e){return e.lift(new Xt(t))}}var Xt=function(){function t(t){this.project=t}return t.prototype.call=function(t,e){return e.subscribe(new te(t,this.project))},t}(),te=function(t){function e(e,n){var r=t.call(this,e)||this;return r.project=n,r.hasSubscription=!1,r.hasCompleted=!1,r.index=0,r}return r.ZT(e,t),e.prototype._next=function(t){this.hasSubscription||this.tryNext(t)},e.prototype.tryNext=function(t){var e,n=this.index++;try{e=this.project(t,n)}catch(t){return void this.destination.error(t)}this.hasSubscription=!0,this._innerSub(e)},e.prototype._innerSub=function(t){var e=new i.IY(this),n=this.destination;n.add(e);var r=(0,i.ft)(t,e);r!==e&&n.add(r)},e.prototype._complete=function(){this.hasCompleted=!0,this.hasSubscription||this.destination.complete(),this.unsubscribe()},e.prototype.notifyNext=function(t){this.destination.next(t)},e.prototype.notifyError=function(t){this.destination.error(t)},e.prototype.notifyComplete=function(){this.hasSubscription=!1,this.hasCompleted&&this.destination.complete()},e}(i.Ds);function ee(t,e,n){return void 0===e&&(e=Number.POSITIVE_INFINITY),e=(e||0)<1?Number.POSITIVE_INFINITY:e,function(r){return r.lift(new ne(t,e,n))}}var ne=function(){function t(t,e,n){this.project=t,this.concurrent=e,this.scheduler=n}return t.prototype.call=function(t,e){return e.subscribe(new re(t,this.project,this.concurrent,this.scheduler))},t}(),re=function(t){function e(e,n,r,i){var s=t.call(this,e)||this;return s.project=n,s.concurrent=r,s.scheduler=i,s.index=0,s.active=0,s.hasCompleted=!1,r<Number.POSITIVE_INFINITY&&(s.buffer=[]),s}return r.ZT(e,t),e.dispatch=function(t){var e=t.subscriber,n=t.result,r=t.value,i=t.index;e.subscribeToProjection(n,r,i)},e.prototype._next=function(t){var n=this.destination;if(n.closed)this._complete();else{var r=this.index++;if(this.active<this.concurrent){n.next(t);try{var i=(0,this.project)(t,r);if(this.scheduler){var s={subscriber:this,result:i,value:t,index:r};this.destination.add(this.scheduler.schedule(e.dispatch,0,s))}else this.subscribeToProjection(i,t,r)}catch(t){n.error(t)}}else this.buffer.push(t)}},e.prototype.subscribeToProjection=function(t,e,n){this.active++,this.destination.add((0,i.ft)(t,new i.IY(this)))},e.prototype._complete=function(){this.hasCompleted=!0,this.hasCompleted&&0===this.active&&this.destination.complete(),this.unsubscribe()},e.prototype.notifyNext=function(t){this._next(t)},e.prototype.notifyComplete=function(){var t=this.buffer;this.active--,t&&t.length>0&&this._next(t.shift()),this.hasCompleted&&0===this.active&&this.destination.complete()},e}(i.Ds);function ie(t){return function(e){return e.lift(new se(t))}}var se=function(){function t(t){this.callback=t}return t.prototype.call=function(t,e){return e.subscribe(new oe(t,this.callback))},t}(),oe=function(t){function e(e,n){var r=t.call(this,e)||this;return r.add(new A.w(n)),r}return r.ZT(e,t),e}(p.L);function ae(t,e){if("function"!=typeof t)throw new TypeError("predicate is not a function");return function(n){return n.lift(new ce(t,n,!1,e))}}var ce=function(){function t(t,e,n,r){this.predicate=t,this.source=e,this.yieldIndex=n,this.thisArg=r}return t.prototype.call=function(t,e){return e.subscribe(new ue(t,this.predicate,this.source,this.yieldIndex,this.thisArg))},t}(),ue=function(t){function e(e,n,r,i,s){var o=t.call(this,e)||this;return o.predicate=n,o.source=r,o.yieldIndex=i,o.thisArg=s,o.index=0,o}return r.ZT(e,t),e.prototype.notifyComplete=function(t){var e=this.destination;e.next(t),e.complete(),this.unsubscribe()},e.prototype._next=function(t){var e=this.predicate,n=this.thisArg,r=this.index++;try{e.call(n||this,t,r,this.source)&&this.notifyComplete(this.yieldIndex?r:t)}catch(t){this.destination.error(t)}},e.prototype._complete=function(){this.notifyComplete(this.yieldIndex?-1:void 0)},e}(p.L);function he(t,e){return function(n){return n.lift(new ce(t,n,!0,e))}}var le=n(3608);function de(t,e){var n=arguments.length>=2;return function(r){return r.pipe(t?(0,Ot.h)((function(e,n){return t(e,n,r)})):le.y,Vt(1),n?ot(e):Pt((function(){return new Rt.K})))}}var fe=n(1120);function pe(){return function(t){return t.lift(new me)}}var me=function(){function t(){}return t.prototype.call=function(t,e){return e.subscribe(new ge(t))},t}(),ge=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r.ZT(e,t),e.prototype._next=function(t){},e}(p.L);function ye(){return function(t){return t.lift(new ve)}}var ve=function(){function t(){}return t.prototype.call=function(t,e){return e.subscribe(new be(t))},t}(),be=function(t){function e(e){return t.call(this,e)||this}return r.ZT(e,t),e.prototype.notifyComplete=function(t){var e=this.destination;e.next(t),e.complete()},e.prototype._next=function(t){this.notifyComplete(!1)},e.prototype._complete=function(){this.notifyComplete(!0)},e}(p.L);function we(t){return function(e){return 0===t?(0,Ut.c)():e.lift(new Ie(t))}}var Ie=function(){function t(t){if(this.total=t,this.total<0)throw new Dt.W}return t.prototype.call=function(t,e){return e.subscribe(new Te(t,this.total))},t}(),Te=function(t){function e(e,n){var r=t.call(this,e)||this;return r.total=n,r.ring=new Array,r.count=0,r}return r.ZT(e,t),e.prototype._next=function(t){var e=this.ring,n=this.total,r=this.count++;e.length<n?e.push(t):e[r%n]=t},e.prototype._complete=function(){var t=this.destination,e=this.count;if(e>0)for(var n=this.count>=this.total?this.total:this.count,r=this.ring,i=0;i<n;i++){var s=e++%n;t.next(r[s])}t.complete()},e}(p.L);function _e(t,e){var n=arguments.length>=2;return function(r){return r.pipe(t?(0,Ot.h)((function(e,n){return t(e,n,r)})):le.y,we(1),n?ot(e):Pt((function(){return new Rt.K})))}}function Ee(t){return function(e){return e.lift(new Se(t))}}var Se=function(){function t(t){this.value=t}return t.prototype.call=function(t,e){return e.subscribe(new ke(t,this.value))},t}(),ke=function(t){function e(e,n){var r=t.call(this,e)||this;return r.value=n,r}return r.ZT(e,t),e.prototype._next=function(t){this.destination.next(this.value)},e}(p.L);function Ae(){return function(t){return t.lift(new Ne)}}var Ne=function(){function t(){}return t.prototype.call=function(t,e){return e.subscribe(new xe(t))},t}(),xe=function(t){function e(e){return t.call(this,e)||this}return r.ZT(e,t),e.prototype._next=function(t){this.destination.next(ht.P.createNext(t))},e.prototype._error=function(t){var e=this.destination;e.next(ht.P.createError(t)),e.complete()},e.prototype._complete=function(){var t=this.destination;t.next(ht.P.createComplete()),t.complete()},e}(p.L);function Ce(t,e){var n=!1;return arguments.length>=2&&(n=!0),function(r){return r.lift(new De(t,e,n))}}var De=function(){function t(t,e,n){void 0===n&&(n=!1),this.accumulator=t,this.seed=e,this.hasSeed=n}return t.prototype.call=function(t,e){return e.subscribe(new Oe(t,this.accumulator,this.seed,this.hasSeed))},t}(),Oe=function(t){function e(e,n,r,i){var s=t.call(this,e)||this;return s.accumulator=n,s._seed=r,s.hasSeed=i,s.index=0,s}return r.ZT(e,t),Object.defineProperty(e.prototype,"seed",{get:function(){return this._seed},set:function(t){this.hasSeed=!0,this._seed=t},enumerable:!0,configurable:!0}),e.prototype._next=function(t){if(this.hasSeed)return this._tryNext(t);this.seed=t,this.destination.next(t)},e.prototype._tryNext=function(t){var e,n=this.index++;try{e=this.accumulator(this.seed,t,n)}catch(t){this.destination.error(t)}this.seed=e,this.destination.next(e)},e}(p.L),Re=n(2561);function Pe(t,e){return arguments.length>=2?function(n){return(0,Re.z)(Ce(t,e),we(1),ot(e))(n)}:function(e){return(0,Re.z)(Ce((function(e,n,r){return t(e,n,r+1)})),we(1))(e)}}function Le(t){return Pe("function"==typeof t?function(e,n){return t(e,n)>0?e:n}:function(t,e){return t>e?t:e})}var Me=n(4370);function Fe(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return function(e){return e.lift.call(Me.T.apply(void 0,[e].concat(t)))}}var Ue=n(2556);function Ve(t,e,n){return void 0===n&&(n=Number.POSITIVE_INFINITY),"function"==typeof e?(0,H.zg)((function(){return t}),e,n):("number"==typeof e&&(n=e),(0,H.zg)((function(){return t}),n))}function je(t,e,n){return void 0===n&&(n=Number.POSITIVE_INFINITY),function(r){return r.lift(new qe(t,e,n))}}var qe=function(){function t(t,e,n){this.accumulator=t,this.seed=e,this.concurrent=n}return t.prototype.call=function(t,e){return e.subscribe(new Be(t,this.accumulator,this.seed,this.concurrent))},t}(),Be=function(t){function e(e,n,r,i){var s=t.call(this,e)||this;return s.accumulator=n,s.acc=r,s.concurrent=i,s.hasValue=!1,s.hasCompleted=!1,s.buffer=[],s.active=0,s.index=0,s}return r.ZT(e,t),e.prototype._next=function(t){if(this.active<this.concurrent){var e=this.index++,n=this.destination,r=void 0;try{r=(0,this.accumulator)(this.acc,t,e)}catch(t){return n.error(t)}this.active++,this._innerSub(r)}else this.buffer.push(t)},e.prototype._innerSub=function(t){var e=new i.IY(this),n=this.destination;n.add(e);var r=(0,i.ft)(t,e);r!==e&&n.add(r)},e.prototype._complete=function(){this.hasCompleted=!0,0===this.active&&0===this.buffer.length&&(!1===this.hasValue&&this.destination.next(this.acc),this.destination.complete()),this.unsubscribe()},e.prototype.notifyNext=function(t){var e=this.destination;this.acc=t,this.hasValue=!0,e.next(t)},e.prototype.notifyComplete=function(){var t=this.buffer;this.active--,t.length>0?this._next(t.shift()):0===this.active&&this.hasCompleted&&(!1===this.hasValue&&this.destination.next(this.acc),this.destination.complete())},e}(i.Ds);function ze(t){return Pe("function"==typeof t?function(e,n){return t(e,n)<0?e:n}:function(t,e){return t<e?t:e})}var Ke=n(3140);function We(t,e){return function(n){var r;if(r="function"==typeof t?t:function(){return t},"function"==typeof e)return n.lift(new Ge(r,e));var i=Object.create(n,Ke.N);return i.source=n,i.subjectFactory=r,i}}var Ge=function(){function t(t,e){this.subjectFactory=t,this.selector=e}return t.prototype.call=function(t,e){var n=this.selector,r=this.subjectFactory(),i=n(r).subscribe(t);return i.add(e.subscribe(r)),i},t}(),He=n(9276);function $e(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return 1===t.length&&(0,q.k)(t[0])&&(t=t[0]),function(e){return e.lift(new Ye(t))}}var Ye=function(){function t(t){this.nextSources=t}return t.prototype.call=function(t,e){return e.subscribe(new Qe(t,this.nextSources))},t}(),Qe=function(t){function e(e,n){var r=t.call(this,e)||this;return r.destination=e,r.nextSources=n,r}return r.ZT(e,t),e.prototype.notifyError=function(){this.subscribeToNextSource()},e.prototype.notifyComplete=function(){this.subscribeToNextSource()},e.prototype._error=function(t){this.subscribeToNextSource(),this.unsubscribe()},e.prototype._complete=function(){this.subscribeToNextSource(),this.unsubscribe()},e.prototype.subscribeToNextSource=function(){var t=this.nextSources.shift();if(t){var e=new i.IY(this),n=this.destination;n.add(e);var r=(0,i.ft)(t,e);r!==e&&n.add(r)}else this.destination.complete()},e}(i.Ds);function Je(){return function(t){return t.lift(new Ze)}}var Ze=function(){function t(){}return t.prototype.call=function(t,e){return e.subscribe(new Xe(t))},t}(),Xe=function(t){function e(e){var n=t.call(this,e)||this;return n.hasPrev=!1,n}return r.ZT(e,t),e.prototype._next=function(t){var e;this.hasPrev?e=[this.prev,t]:this.hasPrev=!0,this.prev=t,e&&this.destination.next(e)},e}(p.L),tn=n(9067);function en(t,e){return function(n){return[(0,Ot.h)(t,e)(n),(0,Ot.h)((0,tn.f)(t,e))(n)]}}function nn(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=t.length;if(0===n)throw new Error("list of properties cannot be empty.");return function(e){return(0,Jt.U)(rn(t,n))(e)}}function rn(t,e){return function(n){for(var r=n,i=0;i<e;i++){var s=null!=r?r[t[i]]:void 0;if(void 0===s)return;r=s}return r}}var sn=n(211);function on(t){return t?We((function(){return new sn.xQ}),t):We(new sn.xQ)}var an=n(9233);function cn(t){return function(e){return We(new an.X(t))(e)}}var un=n(364);function hn(){return function(t){return We(new un.c)(t)}}var ln=n(2630);function dn(t,e,n,r){n&&"function"!=typeof n&&(r=n);var i="function"==typeof n?n:void 0,s=new ln.t(t,e,r);return function(t){return We((function(){return s}),i)(t)}}var fn=n(8821);function pn(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return function(e){return 1===t.length&&(0,q.k)(t[0])&&(t=t[0]),e.lift.call(fn.S3.apply(void 0,[e].concat(t)))}}function mn(t){return void 0===t&&(t=-1),function(e){return 0===t?(0,Ut.c)():t<0?e.lift(new gn(-1,e)):e.lift(new gn(t-1,e))}}var gn=function(){function t(t,e){this.count=t,this.source=e}return t.prototype.call=function(t,e){return e.subscribe(new yn(t,this.count,this.source))},t}(),yn=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.count=n,i.source=r,i}return r.ZT(e,t),e.prototype.complete=function(){if(!this.isStopped){var e=this.source,n=this.count;if(0===n)return t.prototype.complete.call(this);n>-1&&(this.count=n-1),e.subscribe(this._unsubscribeAndRecycle())}},e}(p.L);function vn(t){return function(e){return e.lift(new bn(t))}}var bn=function(){function t(t){this.notifier=t}return t.prototype.call=function(t,e){return e.subscribe(new wn(t,this.notifier,e))},t}(),wn=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.notifier=n,i.source=r,i.sourceIsBeingSubscribedTo=!0,i}return r.ZT(e,t),e.prototype.notifyNext=function(){this.sourceIsBeingSubscribedTo=!0,this.source.subscribe(this)},e.prototype.notifyComplete=function(){if(!1===this.sourceIsBeingSubscribedTo)return t.prototype.complete.call(this)},e.prototype.complete=function(){if(this.sourceIsBeingSubscribedTo=!1,!this.isStopped){if(this.retries||this.subscribeToRetries(),!this.retriesSubscription||this.retriesSubscription.closed)return t.prototype.complete.call(this);this._unsubscribeAndRecycle(),this.notifications.next(void 0)}},e.prototype._unsubscribe=function(){var t=this.notifications,e=this.retriesSubscription;t&&(t.unsubscribe(),this.notifications=void 0),e&&(e.unsubscribe(),this.retriesSubscription=void 0),this.retries=void 0},e.prototype._unsubscribeAndRecycle=function(){var e=this._unsubscribe;return this._unsubscribe=null,t.prototype._unsubscribeAndRecycle.call(this),this._unsubscribe=e,this},e.prototype.subscribeToRetries=function(){var e;this.notifications=new sn.xQ;try{e=(0,this.notifier)(this.notifications)}catch(e){return t.prototype.complete.call(this)}this.retries=e,this.retriesSubscription=(0,i.ft)(e,new i.IY(this))},e}(i.Ds);function In(t){return void 0===t&&(t=-1),function(e){return e.lift(new Tn(t,e))}}var Tn=function(){function t(t,e){this.count=t,this.source=e}return t.prototype.call=function(t,e){return e.subscribe(new _n(t,this.count,this.source))},t}(),_n=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.count=n,i.source=r,i}return r.ZT(e,t),e.prototype.error=function(e){if(!this.isStopped){var n=this.source,r=this.count;if(0===r)return t.prototype.error.call(this,e);r>-1&&(this.count=r-1),n.subscribe(this._unsubscribeAndRecycle())}},e}(p.L);function En(t){return function(e){return e.lift(new Sn(t,e))}}var Sn=function(){function t(t,e){this.notifier=t,this.source=e}return t.prototype.call=function(t,e){return e.subscribe(new kn(t,this.notifier,this.source))},t}(),kn=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.notifier=n,i.source=r,i}return r.ZT(e,t),e.prototype.error=function(e){if(!this.isStopped){var n=this.errors,r=this.retries,s=this.retriesSubscription;if(r)this.errors=void 0,this.retriesSubscription=void 0;else{n=new sn.xQ;try{r=(0,this.notifier)(n)}catch(e){return t.prototype.error.call(this,e)}s=(0,i.ft)(r,new i.IY(this))}this._unsubscribeAndRecycle(),this.errors=n,this.retries=r,this.retriesSubscription=s,n.next(e)}},e.prototype._unsubscribe=function(){var t=this.errors,e=this.retriesSubscription;t&&(t.unsubscribe(),this.errors=void 0),e&&(e.unsubscribe(),this.retriesSubscription=void 0),this.retries=void 0},e.prototype.notifyNext=function(){var t=this._unsubscribe;this._unsubscribe=null,this._unsubscribeAndRecycle(),this._unsubscribe=t,this.source.subscribe(this)},e}(i.Ds),An=n(3018);function Nn(t){return function(e){return e.lift(new xn(t))}}var xn=function(){function t(t){this.notifier=t}return t.prototype.call=function(t,e){var n=new Cn(t),r=e.subscribe(n);return r.add((0,i.ft)(this.notifier,new i.IY(n))),r},t}(),Cn=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.hasValue=!1,e}return r.ZT(e,t),e.prototype._next=function(t){this.value=t,this.hasValue=!0},e.prototype.notifyNext=function(){this.emitValue()},e.prototype.notifyComplete=function(){this.emitValue()},e.prototype.emitValue=function(){this.hasValue&&(this.hasValue=!1,this.destination.next(this.value))},e}(i.Ds);function Dn(t,e){return void 0===e&&(e=c.P),function(n){return n.lift(new On(t,e))}}var On=function(){function t(t,e){this.period=t,this.scheduler=e}return t.prototype.call=function(t,e){return e.subscribe(new Rn(t,this.period,this.scheduler))},t}(),Rn=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.period=n,i.scheduler=r,i.hasValue=!1,i.add(r.schedule(Pn,n,{subscriber:i,period:n})),i}return r.ZT(e,t),e.prototype._next=function(t){this.lastValue=t,this.hasValue=!0},e.prototype.notifyNext=function(){this.hasValue&&(this.hasValue=!1,this.destination.next(this.lastValue))},e}(p.L);function Pn(t){var e=t.subscriber,n=t.period;e.notifyNext(),this.schedule(t,n)}function Ln(t,e){return function(n){return n.lift(new Mn(t,e))}}var Mn=function(){function t(t,e){this.compareTo=t,this.comparator=e}return t.prototype.call=function(t,e){return e.subscribe(new Fn(t,this.compareTo,this.comparator))},t}(),Fn=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.compareTo=n,i.comparator=r,i._a=[],i._b=[],i._oneComplete=!1,i.destination.add(n.subscribe(new Un(e,i))),i}return r.ZT(e,t),e.prototype._next=function(t){this._oneComplete&&0===this._b.length?this.emit(!1):(this._a.push(t),this.checkValues())},e.prototype._complete=function(){this._oneComplete?this.emit(0===this._a.length&&0===this._b.length):this._oneComplete=!0,this.unsubscribe()},e.prototype.checkValues=function(){for(var t=this,e=t._a,n=t._b,r=t.comparator;e.length>0&&n.length>0;){var i=e.shift(),s=n.shift(),o=!1;try{o=r?r(i,s):i===s}catch(t){this.destination.error(t)}o||this.emit(!1)}},e.prototype.emit=function(t){var e=this.destination;e.next(t),e.complete()},e.prototype.nextB=function(t){this._oneComplete&&0===this._a.length?this.emit(!1):(this._b.push(t),this.checkValues())},e.prototype.completeB=function(){this._oneComplete?this.emit(0===this._a.length&&0===this._b.length):this._oneComplete=!0},e}(p.L),Un=function(t){function e(e,n){var r=t.call(this,e)||this;return r.parent=n,r}return r.ZT(e,t),e.prototype._next=function(t){this.parent.nextB(t)},e.prototype._error=function(t){this.parent.error(t),this.unsubscribe()},e.prototype._complete=function(){this.parent.completeB(),this.unsubscribe()},e}(p.L);function Vn(){return new sn.xQ}function jn(){return function(t){return(0,An.x)()(We(Vn)(t))}}function qn(t,e,n){var r;return r=t&&"object"==typeof t?t:{bufferSize:t,windowTime:e,refCount:!1,scheduler:n},function(t){return t.lift(function(t){var e,n,r=t.bufferSize,i=void 0===r?Number.POSITIVE_INFINITY:r,s=t.windowTime,o=void 0===s?Number.POSITIVE_INFINITY:s,a=t.refCount,c=t.scheduler,u=0,h=!1,l=!1;return function(t){var r;u++,!e||h?(h=!1,e=new ln.t(i,o,c),r=e.subscribe(this),n=t.subscribe({next:function(t){e.next(t)},error:function(t){h=!0,e.error(t)},complete:function(){l=!0,n=void 0,e.complete()}})):r=e.subscribe(this),this.add((function(){u--,r.unsubscribe(),n&&!l&&a&&0===u&&(n.unsubscribe(),n=void 0,e=void 0)}))}}(r))}}function Bn(t){return function(e){return e.lift(new zn(t,e))}}var zn=function(){function t(t,e){this.predicate=t,this.source=e}return t.prototype.call=function(t,e){return e.subscribe(new Kn(t,this.predicate,this.source))},t}(),Kn=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.predicate=n,i.source=r,i.seenValue=!1,i.index=0,i}return r.ZT(e,t),e.prototype.applySingleValue=function(t){this.seenValue?this.destination.error("Sequence contains more than one element"):(this.seenValue=!0,this.singleValue=t)},e.prototype._next=function(t){var e=this.index++;this.predicate?this.tryNext(t,e):this.applySingleValue(t)},e.prototype.tryNext=function(t,e){try{this.predicate(t,e,this.source)&&this.applySingleValue(t)}catch(t){this.destination.error(t)}},e.prototype._complete=function(){var t=this.destination;this.index>0?(t.next(this.seenValue?this.singleValue:void 0),t.complete()):t.error(new Rt.K)},e}(p.L);function Wn(t){return function(e){return e.lift(new Gn(t))}}var Gn=function(){function t(t){this.total=t}return t.prototype.call=function(t,e){return e.subscribe(new Hn(t,this.total))},t}(),Hn=function(t){function e(e,n){var r=t.call(this,e)||this;return r.total=n,r.count=0,r}return r.ZT(e,t),e.prototype._next=function(t){++this.count>this.total&&this.destination.next(t)},e}(p.L);function $n(t){return function(e){return e.lift(new Yn(t))}}var Yn=function(){function t(t){if(this._skipCount=t,this._skipCount<0)throw new Dt.W}return t.prototype.call=function(t,e){return 0===this._skipCount?e.subscribe(new p.L(t)):e.subscribe(new Qn(t,this._skipCount))},t}(),Qn=function(t){function e(e,n){var r=t.call(this,e)||this;return r._skipCount=n,r._count=0,r._ring=new Array(n),r}return r.ZT(e,t),e.prototype._next=function(t){var e=this._skipCount,n=this._count++;if(n<e)this._ring[n]=t;else{var r=n%e,i=this._ring,s=i[r];i[r]=t,this.destination.next(s)}},e}(p.L);function Jn(t){return function(e){return e.lift(new Zn(t))}}var Zn=function(){function t(t){this.notifier=t}return t.prototype.call=function(t,e){return e.subscribe(new Xn(t,this.notifier))},t}(),Xn=function(t){function e(e,n){var r=t.call(this,e)||this;r.hasValue=!1;var s=new i.IY(r);r.add(s),r.innerSubscription=s;var o=(0,i.ft)(n,s);return o!==s&&(r.add(o),r.innerSubscription=o),r}return r.ZT(e,t),e.prototype._next=function(e){this.hasValue&&t.prototype._next.call(this,e)},e.prototype.notifyNext=function(){this.hasValue=!0,this.innerSubscription&&this.innerSubscription.unsubscribe()},e.prototype.notifyComplete=function(){},e}(i.Ds);function tr(t){return function(e){return e.lift(new er(t))}}var er=function(){function t(t){this.predicate=t}return t.prototype.call=function(t,e){return e.subscribe(new nr(t,this.predicate))},t}(),nr=function(t){function e(e,n){var r=t.call(this,e)||this;return r.predicate=n,r.skipping=!0,r.index=0,r}return r.ZT(e,t),e.prototype._next=function(t){var e=this.destination;this.skipping&&this.tryCallPredicate(t),this.skipping||e.next(t)},e.prototype.tryCallPredicate=function(t){try{var e=this.predicate(t,this.index++);this.skipping=Boolean(e)}catch(t){this.destination.error(t)}},e}(p.L);function rr(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=t[t.length-1];return(0,b.K)(n)?(t.pop(),function(e){return(0,K.z)(t,e,n)}):function(e){return(0,K.z)(t,e)}}var ir=n(6650),sr=n(5812),or=function(t){function e(e,n,r){void 0===n&&(n=0),void 0===r&&(r=ir.e);var i=t.call(this)||this;return i.source=e,i.delayTime=n,i.scheduler=r,(!(0,sr.k)(n)||n<0)&&(i.delayTime=0),r&&"function"==typeof r.schedule||(i.scheduler=ir.e),i}return r.ZT(e,t),e.create=function(t,n,r){return void 0===n&&(n=0),void 0===r&&(r=ir.e),new e(t,n,r)},e.dispatch=function(t){var e=t.source,n=t.subscriber;return this.add(e.subscribe(n))},e.prototype._subscribe=function(t){var n=this.delayTime,r=this.source;return this.scheduler.schedule(e.dispatch,n,{source:r,subscriber:t})},e}(mt.y);function ar(t,e){return void 0===e&&(e=0),function(n){return n.lift(new cr(t,e))}}var cr=function(){function t(t,e){this.scheduler=t,this.delay=e}return t.prototype.call=function(t,e){return new or(e,this.delay,this.scheduler).subscribe(t)},t}();function ur(t,e){return"function"==typeof e?function(n){return n.pipe(ur((function(n,r){return(0,B.D)(t(n,r)).pipe((0,Jt.U)((function(t,i){return e(n,t,r,i)})))})))}:function(e){return e.lift(new hr(t))}}var hr=function(){function t(t){this.project=t}return t.prototype.call=function(t,e){return e.subscribe(new lr(t,this.project))},t}(),lr=function(t){function e(e,n){var r=t.call(this,e)||this;return r.project=n,r.index=0,r}return r.ZT(e,t),e.prototype._next=function(t){var e,n=this.index++;try{e=this.project(t,n)}catch(t){return void this.destination.error(t)}this._innerSub(e)},e.prototype._innerSub=function(t){var e=this.innerSubscription;e&&e.unsubscribe();var n=new i.IY(this),r=this.destination;r.add(n),this.innerSubscription=(0,i.ft)(t,n),this.innerSubscription!==n&&r.add(this.innerSubscription)},e.prototype._complete=function(){var e=this.innerSubscription;e&&!e.closed||t.prototype._complete.call(this),this.unsubscribe()},e.prototype._unsubscribe=function(){this.innerSubscription=void 0},e.prototype.notifyComplete=function(){this.innerSubscription=void 0,this.isStopped&&t.prototype._complete.call(this)},e.prototype.notifyNext=function(t){this.destination.next(t)},e}(i.Ds);function dr(){return ur(le.y)}function fr(t,e){return e?ur((function(){return t}),e):ur((function(){return t}))}function pr(t){return function(e){return e.lift(new mr(t))}}var mr=function(){function t(t){this.notifier=t}return t.prototype.call=function(t,e){var n=new gr(t),r=(0,i.ft)(this.notifier,new i.IY(n));return r&&!n.seenValue?(n.add(r),e.subscribe(n)):n},t}(),gr=function(t){function e(e){var n=t.call(this,e)||this;return n.seenValue=!1,n}return r.ZT(e,t),e.prototype.notifyNext=function(){this.seenValue=!0,this.complete()},e.prototype.notifyComplete=function(){},e}(i.Ds);function yr(t,e){return void 0===e&&(e=!1),function(n){return n.lift(new vr(t,e))}}var vr=function(){function t(t,e){this.predicate=t,this.inclusive=e}return t.prototype.call=function(t,e){return e.subscribe(new br(t,this.predicate,this.inclusive))},t}(),br=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.predicate=n,i.inclusive=r,i.index=0,i}return r.ZT(e,t),e.prototype._next=function(t){var e,n=this.destination;try{e=this.predicate(t,this.index++)}catch(t){return void n.error(t)}this.nextOrComplete(t,e)},e.prototype.nextOrComplete=function(t,e){var n=this.destination;Boolean(e)?n.next(t):(this.inclusive&&n.next(t),n.complete())},e}(p.L),wr=n(3306),Ir=n(4156);function Tr(t,e,n){return function(r){return r.lift(new _r(t,e,n))}}var _r=function(){function t(t,e,n){this.nextOrObserver=t,this.error=e,this.complete=n}return t.prototype.call=function(t,e){return e.subscribe(new Er(t,this.nextOrObserver,this.error,this.complete))},t}(),Er=function(t){function e(e,n,r,i){var s=t.call(this,e)||this;return s._tapNext=wr.Z,s._tapError=wr.Z,s._tapComplete=wr.Z,s._tapError=r||wr.Z,s._tapComplete=i||wr.Z,(0,Ir.m)(n)?(s._context=s,s._tapNext=n):n&&(s._context=n,s._tapNext=n.next||wr.Z,s._tapError=n.error||wr.Z,s._tapComplete=n.complete||wr.Z),s}return r.ZT(e,t),e.prototype._next=function(t){try{this._tapNext.call(this._context,t)}catch(t){return void this.destination.error(t)}this.destination.next(t)},e.prototype._error=function(t){try{this._tapError.call(this._context,t)}catch(t){return void this.destination.error(t)}this.destination.error(t)},e.prototype._complete=function(){try{this._tapComplete.call(this._context)}catch(t){return void this.destination.error(t)}return this.destination.complete()},e}(p.L),Sr={leading:!0,trailing:!1};function kr(t,e){return void 0===e&&(e=Sr),function(n){return n.lift(new Ar(t,!!e.leading,!!e.trailing))}}var Ar=function(){function t(t,e,n){this.durationSelector=t,this.leading=e,this.trailing=n}return t.prototype.call=function(t,e){return e.subscribe(new Nr(t,this.durationSelector,this.leading,this.trailing))},t}(),Nr=function(t){function e(e,n,r,i){var s=t.call(this,e)||this;return s.destination=e,s.durationSelector=n,s._leading=r,s._trailing=i,s._hasValue=!1,s}return r.ZT(e,t),e.prototype._next=function(t){this._hasValue=!0,this._sendValue=t,this._throttled||(this._leading?this.send():this.throttle(t))},e.prototype.send=function(){var t=this._hasValue,e=this._sendValue;t&&(this.destination.next(e),this.throttle(e)),this._hasValue=!1,this._sendValue=void 0},e.prototype.throttle=function(t){var e=this.tryDurationSelector(t);e&&this.add(this._throttled=(0,i.ft)(e,new i.IY(this)))},e.prototype.tryDurationSelector=function(t){try{return this.durationSelector(t)}catch(t){return this.destination.error(t),null}},e.prototype.throttlingDone=function(){var t=this._throttled,e=this._trailing;t&&t.unsubscribe(),this._throttled=void 0,e&&this.send()},e.prototype.notifyNext=function(){this.throttlingDone()},e.prototype.notifyComplete=function(){this.throttlingDone()},e}(i.Ds);function xr(t,e,n){return void 0===e&&(e=c.P),void 0===n&&(n=Sr),function(r){return r.lift(new Cr(t,e,n.leading,n.trailing))}}var Cr=function(){function t(t,e,n,r){this.duration=t,this.scheduler=e,this.leading=n,this.trailing=r}return t.prototype.call=function(t,e){return e.subscribe(new Dr(t,this.duration,this.scheduler,this.leading,this.trailing))},t}(),Dr=function(t){function e(e,n,r,i,s){var o=t.call(this,e)||this;return o.duration=n,o.scheduler=r,o.leading=i,o.trailing=s,o._hasTrailingValue=!1,o._trailingValue=null,o}return r.ZT(e,t),e.prototype._next=function(t){this.throttled?this.trailing&&(this._trailingValue=t,this._hasTrailingValue=!0):(this.add(this.throttled=this.scheduler.schedule(Or,this.duration,{subscriber:this})),this.leading?this.destination.next(t):this.trailing&&(this._trailingValue=t,this._hasTrailingValue=!0))},e.prototype._complete=function(){this._hasTrailingValue?(this.destination.next(this._trailingValue),this.destination.complete()):this.destination.complete()},e.prototype.clearThrottle=function(){var t=this.throttled;t&&(this.trailing&&this._hasTrailingValue&&(this.destination.next(this._trailingValue),this._trailingValue=null,this._hasTrailingValue=!1),t.unsubscribe(),this.remove(t),this.throttled=null)},e}(p.L);function Or(t){t.subscriber.clearThrottle()}var Rr=n(1410);function Pr(t){return void 0===t&&(t=c.P),function(e){return(0,Rr.P)((function(){return e.pipe(Ce((function(e,n){var r=e.current;return{value:n,current:t.now(),last:r}}),{current:t.now(),value:void 0,last:void 0}),(0,Jt.U)((function(t){var e=t.current,n=t.last,r=t.value;return new Lr(r,e-n)})))}))}}var Lr=function(){return function(t,e){this.value=t,this.interval=e}}(),Mr=n(1462);function Fr(t,e,n){return void 0===n&&(n=c.P),function(r){var i=ut(t),s=i?+t-n.now():Math.abs(t);return r.lift(new Ur(s,i,e,n))}}var Ur=function(){function t(t,e,n,r){this.waitFor=t,this.absoluteTimeout=e,this.withObservable=n,this.scheduler=r}return t.prototype.call=function(t,e){return e.subscribe(new Vr(t,this.absoluteTimeout,this.waitFor,this.withObservable,this.scheduler))},t}(),Vr=function(t){function e(e,n,r,i,s){var o=t.call(this,e)||this;return o.absoluteTimeout=n,o.waitFor=r,o.withObservable=i,o.scheduler=s,o.scheduleTimeout(),o}return r.ZT(e,t),e.dispatchTimeout=function(t){var e=t.withObservable;t._unsubscribeAndRecycle(),t.add((0,i.ft)(e,new i.IY(t)))},e.prototype.scheduleTimeout=function(){var t=this.action;t?this.action=t.schedule(this,this.waitFor):this.add(this.action=this.scheduler.schedule(e.dispatchTimeout,this.waitFor,this))},e.prototype._next=function(e){this.absoluteTimeout||this.scheduleTimeout(),t.prototype._next.call(this,e)},e.prototype._unsubscribe=function(){this.action=void 0,this.scheduler=null,this.withObservable=null},e}(i.Ds),jr=n(4944);function qr(t,e){return void 0===e&&(e=c.P),Fr(t,(0,jr._)(new Mr.W),e)}function Br(t){return void 0===t&&(t=c.P),(0,Jt.U)((function(e){return new zr(e,t.now())}))}var zr=function(){return function(t,e){this.value=t,this.timestamp=e}}();function Kr(t,e,n){return 0===n?[e]:(t.push(e),t)}function Wr(){return Pe(Kr,[])}function Gr(t){return function(e){return e.lift(new Hr(t))}}var Hr=function(){function t(t){this.windowBoundaries=t}return t.prototype.call=function(t,e){var n=new $r(t),r=e.subscribe(n);return r.closed||n.add((0,i.ft)(this.windowBoundaries,new i.IY(n))),r},t}(),$r=function(t){function e(e){var n=t.call(this,e)||this;return n.window=new sn.xQ,e.next(n.window),n}return r.ZT(e,t),e.prototype.notifyNext=function(){this.openWindow()},e.prototype.notifyError=function(t){this._error(t)},e.prototype.notifyComplete=function(){this._complete()},e.prototype._next=function(t){this.window.next(t)},e.prototype._error=function(t){this.window.error(t),this.destination.error(t)},e.prototype._complete=function(){this.window.complete(),this.destination.complete()},e.prototype._unsubscribe=function(){this.window=null},e.prototype.openWindow=function(){var t=this.window;t&&t.complete();var e=this.destination,n=this.window=new sn.xQ;e.next(n)},e}(i.Ds);function Yr(t,e){return void 0===e&&(e=0),function(n){return n.lift(new Qr(t,e))}}var Qr=function(){function t(t,e){this.windowSize=t,this.startWindowEvery=e}return t.prototype.call=function(t,e){return e.subscribe(new Jr(t,this.windowSize,this.startWindowEvery))},t}(),Jr=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.destination=e,i.windowSize=n,i.startWindowEvery=r,i.windows=[new sn.xQ],i.count=0,e.next(i.windows[0]),i}return r.ZT(e,t),e.prototype._next=function(t){for(var e=this.startWindowEvery>0?this.startWindowEvery:this.windowSize,n=this.destination,r=this.windowSize,i=this.windows,s=i.length,o=0;o<s&&!this.closed;o++)i[o].next(t);var a=this.count-r+1;if(a>=0&&a%e==0&&!this.closed&&i.shift().complete(),++this.count%e==0&&!this.closed){var c=new sn.xQ;i.push(c),n.next(c)}},e.prototype._error=function(t){var e=this.windows;if(e)for(;e.length>0&&!this.closed;)e.shift().error(t);this.destination.error(t)},e.prototype._complete=function(){var t=this.windows;if(t)for(;t.length>0&&!this.closed;)t.shift().complete();this.destination.complete()},e.prototype._unsubscribe=function(){this.count=0,this.windows=null},e}(p.L);function Zr(t){var e=c.P,n=null,r=Number.POSITIVE_INFINITY;return(0,b.K)(arguments[3])&&(e=arguments[3]),(0,b.K)(arguments[2])?e=arguments[2]:(0,sr.k)(arguments[2])&&(r=Number(arguments[2])),(0,b.K)(arguments[1])?e=arguments[1]:(0,sr.k)(arguments[1])&&(n=Number(arguments[1])),function(i){return i.lift(new Xr(t,n,r,e))}}var Xr=function(){function t(t,e,n,r){this.windowTimeSpan=t,this.windowCreationInterval=e,this.maxWindowSize=n,this.scheduler=r}return t.prototype.call=function(t,e){return e.subscribe(new ei(t,this.windowTimeSpan,this.windowCreationInterval,this.maxWindowSize,this.scheduler))},t}(),ti=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._numberOfNextedValues=0,e}return r.ZT(e,t),e.prototype.next=function(e){this._numberOfNextedValues++,t.prototype.next.call(this,e)},Object.defineProperty(e.prototype,"numberOfNextedValues",{get:function(){return this._numberOfNextedValues},enumerable:!0,configurable:!0}),e}(sn.xQ),ei=function(t){function e(e,n,r,i,s){var o=t.call(this,e)||this;o.destination=e,o.windowTimeSpan=n,o.windowCreationInterval=r,o.maxWindowSize=i,o.scheduler=s,o.windows=[];var a=o.openWindow();if(null!==r&&r>=0){var c={subscriber:o,window:a,context:null},u={windowTimeSpan:n,windowCreationInterval:r,subscriber:o,scheduler:s};o.add(s.schedule(ii,n,c)),o.add(s.schedule(ri,r,u))}else{var h={subscriber:o,window:a,windowTimeSpan:n};o.add(s.schedule(ni,n,h))}return o}return r.ZT(e,t),e.prototype._next=function(t){for(var e=this.windows,n=e.length,r=0;r<n;r++){var i=e[r];i.closed||(i.next(t),i.numberOfNextedValues>=this.maxWindowSize&&this.closeWindow(i))}},e.prototype._error=function(t){for(var e=this.windows;e.length>0;)e.shift().error(t);this.destination.error(t)},e.prototype._complete=function(){for(var t=this.windows;t.length>0;){var e=t.shift();e.closed||e.complete()}this.destination.complete()},e.prototype.openWindow=function(){var t=new ti;return this.windows.push(t),this.destination.next(t),t},e.prototype.closeWindow=function(t){t.complete();var e=this.windows;e.splice(e.indexOf(t),1)},e}(p.L);function ni(t){var e=t.subscriber,n=t.windowTimeSpan,r=t.window;r&&e.closeWindow(r),t.window=e.openWindow(),this.schedule(t,n)}function ri(t){var e=t.windowTimeSpan,n=t.subscriber,r=t.scheduler,i=t.windowCreationInterval,s=n.openWindow(),o=this,a={action:o,subscription:null},c={subscriber:n,window:s,context:a};a.subscription=r.schedule(ii,e,c),o.add(a.subscription),o.schedule(t,i)}function ii(t){var e=t.subscriber,n=t.window,r=t.context;r&&r.action&&r.subscription&&r.action.remove(r.subscription),e.closeWindow(n)}function si(t,e){return function(n){return n.lift(new oi(t,e))}}var oi=function(){function t(t,e){this.openings=t,this.closingSelector=e}return t.prototype.call=function(t,e){return e.subscribe(new ai(t,this.openings,this.closingSelector))},t}(),ai=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.openings=n,i.closingSelector=r,i.contexts=[],i.add(i.openSubscription=(0,N.D)(i,n,n)),i}return r.ZT(e,t),e.prototype._next=function(t){var e=this.contexts;if(e)for(var n=e.length,r=0;r<n;r++)e[r].window.next(t)},e.prototype._error=function(e){var n=this.contexts;if(this.contexts=null,n)for(var r=n.length,i=-1;++i<r;){var s=n[i];s.window.error(e),s.subscription.unsubscribe()}t.prototype._error.call(this,e)},e.prototype._complete=function(){var e=this.contexts;if(this.contexts=null,e)for(var n=e.length,r=-1;++r<n;){var i=e[r];i.window.complete(),i.subscription.unsubscribe()}t.prototype._complete.call(this)},e.prototype._unsubscribe=function(){var t=this.contexts;if(this.contexts=null,t)for(var e=t.length,n=-1;++n<e;){var r=t[n];r.window.unsubscribe(),r.subscription.unsubscribe()}},e.prototype.notifyNext=function(t,e,n,r,i){if(t===this.openings){var s=void 0;try{s=(0,this.closingSelector)(e)}catch(t){return this.error(t)}var o=new sn.xQ,a=new A.w,c={window:o,subscription:a};this.contexts.push(c);var u=(0,N.D)(this,s,c);u.closed?this.closeWindow(this.contexts.length-1):(u.context=c,a.add(u)),this.destination.next(o)}else this.closeWindow(this.contexts.indexOf(t))},e.prototype.notifyError=function(t){this.error(t)},e.prototype.notifyComplete=function(t){t!==this.openSubscription&&this.closeWindow(this.contexts.indexOf(t.context))},e.prototype.closeWindow=function(t){if(-1!==t){var e=this.contexts,n=e[t],r=n.window,i=n.subscription;e.splice(t,1),r.complete(),i.unsubscribe()}},e}(x.L);function ci(t){return function(e){return e.lift(new ui(t))}}var ui=function(){function t(t){this.closingSelector=t}return t.prototype.call=function(t,e){return e.subscribe(new hi(t,this.closingSelector))},t}(),hi=function(t){function e(e,n){var r=t.call(this,e)||this;return r.destination=e,r.closingSelector=n,r.openWindow(),r}return r.ZT(e,t),e.prototype.notifyNext=function(t,e,n,r,i){this.openWindow(i)},e.prototype.notifyError=function(t){this._error(t)},e.prototype.notifyComplete=function(t){this.openWindow(t)},e.prototype._next=function(t){this.window.next(t)},e.prototype._error=function(t){this.window.error(t),this.destination.error(t),this.unsubscribeClosingNotification()},e.prototype._complete=function(){this.window.complete(),this.destination.complete(),this.unsubscribeClosingNotification()},e.prototype.unsubscribeClosingNotification=function(){this.closingNotification&&this.closingNotification.unsubscribe()},e.prototype.openWindow=function(t){void 0===t&&(t=null),t&&(this.remove(t),t.unsubscribe());var e=this.window;e&&e.complete();var n,r=this.window=new sn.xQ;this.destination.next(r);try{n=(0,this.closingSelector)()}catch(t){return this.destination.error(t),void this.window.error(t)}this.add(this.closingNotification=(0,N.D)(this,n))},e}(x.L);function li(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return function(e){var n;"function"==typeof t[t.length-1]&&(n=t.pop());var r=t;return e.lift(new di(r,n))}}var di=function(){function t(t,e){this.observables=t,this.project=e}return t.prototype.call=function(t,e){return e.subscribe(new fi(t,this.observables,this.project))},t}(),fi=function(t){function e(e,n,r){var i=t.call(this,e)||this;i.observables=n,i.project=r,i.toRespond=[];var s=n.length;i.values=new Array(s);for(var o=0;o<s;o++)i.toRespond.push(o);for(o=0;o<s;o++){var a=n[o];i.add((0,N.D)(i,a,void 0,o))}return i}return r.ZT(e,t),e.prototype.notifyNext=function(t,e,n){this.values[n]=e;var r=this.toRespond;if(r.length>0){var i=r.indexOf(n);-1!==i&&r.splice(i,1)}},e.prototype.notifyComplete=function(){},e.prototype._next=function(t){if(0===this.toRespond.length){var e=[t].concat(this.values);this.project?this._tryProject(e):this.destination.next(e)}},e.prototype._tryProject=function(t){var e;try{e=this.project.apply(this,t)}catch(t){return void this.destination.error(t)}this.destination.next(e)},e}(x.L),pi=n(5080);function mi(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return function(e){return e.lift.call(pi.$R.apply(void 0,[e].concat(t)))}}function gi(t){return function(e){return e.lift(new pi.mx(t))}}},5987:(t,e,n)=>{"use strict";n.d(e,{ZT:()=>i});var r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},r(t,e)};function i(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}},8977:function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(t){try{c(r.next(t))}catch(t){s(t)}}function a(t){try{c(r.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}c((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=e.call(t,o)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var o=s(n(6245)),a=s(n(8060)),c=n(1382),u=n(9699),h=function(){function t(t){var e;this.clientConfig=t,this.tokenStorageKey="RIO_TOKENS_KEY.".concat(t.projectId),this.rootProjectId=null!==(e=t.rootProjectId)&&void 0!==e?e:"root"}return t.prototype.setHttp=function(t){this.http=t},t.prototype.storeTokenData=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e=(0,c.getRuntime)(),void 0===t?[2]:("web"===e&&localStorage.setItem(this.tokenStorageKey,JSON.stringify(t)),"react-native"!==e?[3,2]:[4,a.default.setItem(this.tokenStorageKey,JSON.stringify(t))]);case 1:n.sent(),n.label=2;case 2:return this.currentTokenData=t,[2]}}))}))},t.prototype.clearTokenData=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return"web"===(t=(0,c.getRuntime)())&&localStorage.removeItem(this.tokenStorageKey),"react-native"!==t?[3,2]:[4,a.default.removeItem(this.tokenStorageKey)];case 1:e.sent(),e.label=2;case 2:return this.currentTokenData=void 0,[2]}}))}))},t.prototype.getCurrentTokenData=function(){return r(this,void 0,void 0,(function(){var t,e,n;return i(this,(function(r){switch(r.label){case 0:return"web"!==(e=(0,c.getRuntime)())?[3,1]:((n=localStorage.getItem(this.tokenStorageKey))&&"undefined"!==n&&(t=JSON.parse(n)),[3,4]);case 1:return"react-native"!==e?[3,3]:[4,a.default.getItem(this.tokenStorageKey)];case 2:return(n=r.sent())&&"undefined"!==n&&(t=JSON.parse(n)),[3,4];case 3:t=this.currentTokenData,r.label=4;case 4:return!t||t.accessTokenDecoded&&t.refreshTokenDecoded||(t.accessTokenDecoded=this.decodeToken(t.accessToken),t.refreshTokenDecoded=this.decodeToken(t.refreshToken)),[2,t]}}))}))},t.prototype.getCurrentUser=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return[4,this.getCurrentTokenData()];case 1:return[2,null==(t=e.sent())?void 0:t.accessTokenDecoded]}}))}))},t.prototype.getTokenData=function(){var t,e;return r(this,void 0,void 0,(function(){var n,r,s,o;return i(this,(function(i){switch(i.label){case 0:return[4,this.getCurrentTokenData()];case 1:return(n=i.sent())?(r=n.diff+Math.round((new Date).getTime()/1e3)+30,n.accessTokenDecoded=this.decodeToken(n.accessToken),n.refreshTokenDecoded=this.decodeToken(n.refreshToken),s=null!==(t=n.accessTokenDecoded.exp)&&void 0!==t?t:0,(null!==(e=n.refreshTokenDecoded.exp)&&void 0!==e?e:0)>r&&s<=r?[4,this.getFreshToken(n.refreshToken,n.refreshTokenDecoded.userId)]:[3,3]):[3,4];case 2:return(o=i.sent()).accessTokenDecoded=this.decodeToken(o.accessToken),o.refreshTokenDecoded=this.decodeToken(o.refreshToken),[2,o];case 3:return[2,n];case 4:return[4,this.getAnonymousToken()];case 5:return[2,i.sent()]}}))}))},t.prototype.decodeToken=function(t){return(0,o.default)(t)},t.prototype.formatTokenData=function(t){return t.accessTokenDecoded=this.decodeToken(t.accessToken),t.refreshTokenDecoded=this.decodeToken(t.refreshToken),t.accessTokenDecoded.iat&&(t.diff=t.accessTokenDecoded.iat-Math.floor(Date.now()/1e3)),t},t.prototype.getFreshToken=function(t,e){return r(this,void 0,void 0,(function(){var n,r;return i(this,(function(i){switch(i.label){case 0:return n="/CALL/ProjectUser/refreshToken/".concat(this.clientConfig.projectId,"_").concat(e),[4,this.http.call(this.rootProjectId,n,{method:"get",params:{refreshToken:t}})];case 1:return r=i.sent(),[2,this.formatTokenData(r.data)]}}))}))},t.prototype.getAnonymousToken=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return[4,this.http.call(this.rootProjectId,"/INSTANCE/ProjectUser",{method:"get",params:{projectId:this.clientConfig.projectId}})];case 1:return t=e.sent(),[2,this.formatTokenData(t.data.response)]}}))}))},t.prototype.signIn=function(t){return r(this,void 0,void 0,(function(){var e,n,r;return i(this,(function(i){switch(i.label){case 0:return e=this.decodeToken(t).userId,n="/CALL/ProjectUser/authWithCustomToken/".concat(this.clientConfig.projectId,"_").concat(e),[4,this.http.call(this.rootProjectId,n,{method:"get",params:{customToken:t}})];case 1:return r=i.sent().data,[2,this.formatTokenData(r)]}}))}))},t.prototype.signOut=function(){return r(this,void 0,void 0,(function(){var t,e;return i(this,(function(n){switch(n.label){case 0:return n.trys.push([0,4,,5]),[4,this.getCurrentTokenData()];case 1:return(t=n.sent())?(e="/CALL/ProjectUser/signOut/".concat(this.clientConfig.projectId,"_").concat(t.accessTokenDecoded.userId),[4,this.http.call(this.rootProjectId,e,{method:"get",params:{accessToken:t.accessToken}})]):[3,3];case 2:n.sent(),n.label=3;case 3:return[3,5];case 4:return n.sent(),[3,5];case 5:return[2]}}))}))},t.prototype.getAuthStatus=function(t){if(t&&t.accessTokenDecoded){var e=t.accessTokenDecoded;return{uid:e.userId,identity:e.identity,authStatus:e.anonymous?u.RetterAuthStatus.SIGNED_IN_ANONYM:u.RetterAuthStatus.SIGNED_IN}}return{authStatus:u.RetterAuthStatus.SIGNED_OUT}},t}();e.default=h},6905:function(t,e,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},r.apply(this,arguments)},i=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(t){try{c(r.next(t))}catch(t){s(t)}}function a(t){try{c(r.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}c((r=r.apply(t,e||[])).next())}))},s=this&&this.__generator||function(t,e){var n,r,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=e.call(t,o)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var a=o(n(9669)),c=n(1382),u=n(9699),h=[{id:u.RetterRegion.euWest1,url:"api.retter.io"},{id:u.RetterRegion.euWest1Beta,url:"test-api.retter.io"}],l=function(){function t(t){this.createAxiosInstance(),this.url=t.url,t.region||(t.region=u.RetterRegion.euWest1),this.region=h.find((function(e){return e.id===t.region})),this.culture=t.culture,this.platform=t.culture}return t.prototype.createAxiosInstance=function(){this.axiosInstance=a.default.create({responseType:"json",headers:{"Content-Type":"application/json"},timeout:3e4})},t.prototype.buildUrl=function(t,e){var n=this.url?"".concat(this.url):"".concat(t,".").concat(this.region.url);return"https://".concat(n,"/").concat(t,"/").concat(e.startsWith("/")?e.substr(1):e)},t.prototype.call=function(t,e,n){return i(this,void 0,void 0,(function(){var i,o;return s(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),!(i=r({},n.params)).__culture&&this.culture&&(i.__culture=this.culture),!i.__platform&&this.platform&&(i.__platform=this.platform),"get"===n.method&&!1!==n.base64Encode&&n.data&&(o=(0,c.base64Encode)(JSON.stringify(n.data)),delete n.data,i.data=o,i.__isbase64=!0),console.log("url:",this.buildUrl(t,e)),[4,this.axiosInstance(r(r({url:this.buildUrl(t,e)},n),{params:i}))];case 1:return[2,s.sent()];case 2:throw s.sent();case 3:return[2]}}))}))},t}();e.default=l},1382:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.base64Encode=e.getRuntime=void 0,e.getRuntime=function(){return"undefined"!=typeof document?"web":"undefined"!=typeof navigator&&"ReactNative"==navigator.product?"react-native":"node"},e.base64Encode=function(t){return Buffer.from(t).toString("base64")}},3607:function(t,e,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},r.apply(this,arguments)},i=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n),Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[n]}})}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),s=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)},o=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(t){try{c(r.next(t))}catch(t){s(t)}}function a(t){try{c(r.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}c((r=r.apply(t,e||[])).next())}))},a=this&&this.__generator||function(t,e){var n,r,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=e.call(t,o)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},c=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var u=n(1591),h=n(5503),l=n(1591),d=n(900),f=n(4143),p=n(1717),m=c(n(8977)),g=c(n(6905)),y=n(9699);s(n(9699),e);var v=function(){function t(){this.initialized=!1,this.authQueue=new f.Subject,this.actionQueue=new f.Subject,this.authStatusSubject=new f.ReplaySubject(1),this.cloudObjects=[]}return t.getInstance=function(e){var n=t.instances.find((function(t){var n;return(null===(n=t.clientConfig)||void 0===n?void 0:n.projectId)===e.projectId}));if(n)return n;var r=new t;return r.init(e),t.instances.push(r),r},t.prototype.init=function(t){var e=this;if(this.initialized)throw new Error("SDK already initialized.");this.initialized=!0,t.retryConfig||(t.retryConfig={}),t.retryConfig.delay||(t.retryConfig.delay=50),t.retryConfig.count||(t.retryConfig.count=3),t.retryConfig.rate||(t.retryConfig.rate=1.5),this.clientConfig=t,this.auth=new m.default(t),this.http=new g.default(t),this.auth.setHttp(this.http),this.processAuthQueue(),this.processActionQueue(),setTimeout((function(){return o(e,void 0,void 0,(function(){var t;return a(this,(function(e){switch(e.label){case 0:return[4,this.auth.getCurrentTokenData()];case 1:return t=e.sent(),this.fireAuthStatus({tokenData:t}),[2]}}))}))}),1)},t.prototype.processAuthQueue=function(){var t=this,e=this.authQueue.pipe((0,p.concatMap)((function(e){return(0,f.defer)((function(){return o(t,void 0,void 0,(function(){var t,n;return a(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.auth.signIn(e.data)];case 1:return t=r.sent(),[2,{action:e,response:t}];case 2:throw n=r.sent(),{action:e,responseError:n};case 3:return[2]}}))}))})).pipe((0,p.materialize)())})),(0,p.share)());e.pipe((0,p.filter)((function(t){return t.hasValue&&"N"===t.kind})),(0,p.map)((function(t){var e;return r(r({},t.value),{tokenData:null===(e=t.value)||void 0===e?void 0:e.response})})),(0,p.switchMap)((function(e){return o(t,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,this.storeTokenData(e)];case 1:return t.sent(),[2,e]}}))}))})),(0,p.switchMap)((function(e){return o(t,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,this.clearCloudObjects()];case 1:return t.sent(),e.tokenData?[4,this.initFirebase(e)]:[3,3];case 2:t.sent(),t.label=3;case 3:return this.fireAuthStatus(e),[2,e]}}))}))}))).subscribe((function(e){var n,r;(null===(n=e.action)||void 0===n?void 0:n.resolve)&&e.action.resolve(null===(r=t.auth)||void 0===r?void 0:r.getAuthStatus(e.tokenData))})),e.pipe((0,p.filter)((function(t){return!1===t.hasValue&&"E"===t.kind}))).subscribe((function(t){var e;if(t.error&&t.error.action&&t.error.action.resolve){var n={authStatus:y.RetterAuthStatus.AUTH_FAILED,message:null===(e=t.error.responseError.response)||void 0===e?void 0:e.data};t.error.action.resolve(n)}})),this.authStatus.subscribe()},t.prototype.processActionQueue=function(){var t=this,e=this.actionQueue.asObservable().pipe((0,p.concatMap)(this.getActionWithTokenData.bind(this)),(0,p.tap)(this.fireAuthStatus.bind(this)),(0,p.filter)((function(t){return null!==t.tokenData})),(0,p.switchMap)((function(e){return o(t,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,this.storeTokenData(e)];case 1:return t.sent(),[2,e]}}))}))})),(0,p.mergeMap)(this.processAction.bind(this)),(0,p.share)());e.pipe((0,p.filter)((function(t){return t.hasValue&&"N"===t.kind}))).subscribe((function(t){t.value&&t.value.action&&t.value.action.resolve&&t.value.response&&t.value.action.resolve(t.value.response)})),e.pipe((0,p.filter)((function(t){return!1===t.hasValue&&"E"===t.kind}))).subscribe((function(t){t.error&&t.error.action&&t.error.action.reject&&t.error.responseError&&t.error.action.reject(t.error.responseError)}))},t.prototype.sendToAuthQueue=function(t){return o(this,void 0,void 0,(function(){var e=this;return a(this,(function(n){return[2,new Promise((function(n,i){e.authQueue.next(r(r({},t),{reject:i,resolve:n}))}))]}))}))},t.prototype.sendToActionQueue=function(t){return o(this,void 0,void 0,(function(){var e=this;return a(this,(function(n){return[2,new Promise((function(n,i){e.actionQueue.next(r(r({},t),{reject:i,resolve:n}))}))]}))}))},t.prototype.getActionWithTokenData=function(t){return o(this,void 0,void 0,(function(){var e,n;return a(this,(function(r){switch(r.label){case 0:return r.trys.push([0,3,,5]),n={action:t},[4,this.auth.getTokenData()];case 1:return n.tokenData=r.sent(),e=n,[4,this.initFirebase(e)];case 2:return r.sent(),[2,e];case 3:return r.sent(),[4,this.signOut()];case 4:return r.sent(),[2,{action:t}];case 5:return[2]}}))}))},t.prototype.fireAuthStatus=function(t){var e=this.auth.getAuthStatus(t.tokenData);this.authStatusSubject.next(e)},t.prototype.storeTokenData=function(t){return o(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,this.auth.storeTokenData(t.tokenData)];case 1:return e.sent(),[2]}}))}))},t.prototype.processAction=function(t){var e,n,i=this;return(null===(e=t.action)||void 0===e?void 0:e.action)===y.RetterActions.EMPTY?(0,f.defer)((function(){return(0,f.of)(r(r({},t),{response:!0}))})).pipe((0,p.materialize)()):(null===(n=t.action)||void 0===n?void 0:n.action)===y.RetterActions.SIGN_IN_ANONYM?(0,f.defer)((function(){return(0,f.of)(r(r({},t),{response:i.auth.getAuthStatus(t.tokenData)}))})).pipe((0,p.materialize)()):(0,f.defer)((function(){return o(i,void 0,void 0,(function(){var e,n,i;return a(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),e=this.getCosEndpoint(t),[4,this.http.call(this.clientConfig.projectId,e.path,e.params)];case 1:return n=s.sent(),[2,r(r({},t),{response:n})];case 2:throw i=s.sent(),r(r({},t),{responseError:i});case 3:return[2]}}))}))})).pipe((0,p.materialize)())},t.prototype.initFirebase=function(t){var e;return o(this,void 0,void 0,(function(){var n;return a(this,(function(r){switch(r.label){case 0:return!(n=null===(e=t.tokenData)||void 0===e?void 0:e.firebase)||this.firebase?[2,t]:(this.firebase=(0,h.initializeApp)({apiKey:n.apiKey,authDomain:n.projectId+".firebaseapp.com",projectId:n.projectId},this.clientConfig.projectId),this.firestore=(0,u.getFirestore)(this.firebase),this.firebaseAuth=(0,d.getAuth)(this.firebase),[4,(0,d.signInWithCustomToken)(this.firebaseAuth,n.customToken)]);case 1:return r.sent(),[2,t]}}))}))},t.prototype.clearFirebase=function(){this.firebase=void 0,this.firestore=void 0,this.firebaseAuth=void 0},t.prototype.getCosEndpoint=function(t){var e,n,i,s,o,a=t.action,c=a.data,u={_token:null!==(e=c.token)&&void 0!==e?e:null===(n=t.tokenData)||void 0===n?void 0:n.accessToken};for(var h in c.queryStringParams||[])u[h]=c.queryStringParams[h];u.__culture=null!==(i=c.culture)&&void 0!==i?i:"en-us",c.platform&&(u.__platform=c.platform);var l={params:u,method:null!==(s=c.httpMethod)&&void 0!==s?s:"post",data:c.body,base64Encode:null===(o=c.base64Encode)||void 0===o||o,headers:r({},c.headers)};if(a.action===y.RetterActions.COS_INSTANCE){var d=c.key?"".concat(c.key.name,"!").concat(c.key.value):c.instanceId;return{path:"INSTANCE/".concat(c.classId).concat(d?"/".concat(d):""),params:l}}return a.action===y.RetterActions.COS_STATE?{path:"STATE/".concat(c.classId,"/").concat(c.instanceId),params:l}:a.action===y.RetterActions.COS_LIST?{path:"LIST/".concat(c.classId),params:l}:{path:"CALL/".concat(c.classId,"/").concat(c.method,"/").concat(c.instanceId),params:l}},t.prototype.getFirebaseListener=function(t,e,n){var r=(0,l.doc)(this.firestore,e,n);return(0,l.onSnapshot)(r,(function(e){for(var n=Object.assign({},e.data()),r=0,i=Object.keys(n);r<i.length;r++){var s=i[r];s.startsWith("__")&&delete n[s]}t.next(n)}))},t.prototype.getFirebaseState=function(t){return o(this,void 0,void 0,(function(){var e,n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return e={role:new f.ReplaySubject(1),user:new f.ReplaySubject(1),public:new f.ReplaySubject(1)},n={role:e.role.asObservable(),user:e.user.asObservable(),public:e.public.asObservable()},r=this.clientConfig.projectId,[4,this.auth.getCurrentUser()];case 1:return i=o.sent(),(s=[]).push(this.getFirebaseListener(e.public,"/projects/".concat(r,"/classes/").concat(t.classId,"/instances"),t.instanceId)),s.push(this.getFirebaseListener(e.user,"/projects/".concat(r,"/classes/").concat(t.classId,"/instances/").concat(t.instanceId,"/userState"),i.userId)),s.push(this.getFirebaseListener(e.role,"/projects/".concat(r,"/classes/").concat(t.classId,"/instances/").concat(t.instanceId,"/roleState"),i.identity)),[2,{state:n,unsubscribers:s}]}}))}))},t.prototype.clearCloudObjects=function(){return o(this,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return this.cloudObjects.map((function(t){return t.unsubscribers.map((function(t){return t()}))})),this.cloudObjects=[],this.firebaseAuth?[4,(0,d.signOut)(this.firebaseAuth)]:[3,2];case 1:t.sent(),t.label=2;case 2:return this.clearFirebase(),[2]}}))}))},t.prototype.signInAnonymously=function(){return o(this,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:if(!this.initialized)throw new Error("Retter SDK not initialized.");return[4,this.sendToActionQueue({action:y.RetterActions.SIGN_IN_ANONYM})];case 1:return[2,t.sent()]}}))}))},t.prototype.authenticateWithCustomToken=function(t){return o(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:if(!this.initialized)throw new Error("Retter SDK not initialized.");return[4,this.sendToAuthQueue({action:y.RetterActions.SIGN_IN,data:t})];case 1:return[2,e.sent()]}}))}))},t.prototype.signOut=function(){return o(this,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:if(!this.initialized)throw new Error("Retter SDK not initialized.");return[4,this.clearCloudObjects()];case 1:return t.sent(),[4,this.auth.signOut()];case 2:return t.sent(),[4,this.auth.clearTokenData()];case 3:return t.sent(),this.fireAuthStatus({}),[2]}}))}))},t.prototype.getCurrentUser=function(){return o(this,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,this.auth.getCurrentUser()];case 1:return[2,t.sent()]}}))}))},t.prototype.getCloudObject=function(t){var e,n,i,s;return o(this,void 0,void 0,(function(){var c,u,h,l,d,f,p,m,g,v,b=this;return a(this,(function(w){switch(w.label){case 0:if(!this.initialized)throw new Error("Retter SDK not initialized.");return t.instanceId&&t.useLocal?[4,this.sendToActionQueue({action:y.RetterActions.EMPTY})]:[3,2];case 1:return w.sent(),[3,4];case 2:return[4,this.sendToActionQueue({action:y.RetterActions.COS_INSTANCE,data:t})];case 3:u=w.sent().data,c=u,t.instanceId=c.instanceId,w.label=4;case 4:return(h=this.cloudObjects.find((function(e){return e.config.classId===t.classId&&e.config.instanceId===t.instanceId})))?[2,{call:h.call,state:h.state,listInstances:h.listInstances,getState:h.getState,methods:null!==(e=null==c?void 0:c.methods)&&void 0!==e?e:[],instanceId:t.instanceId,response:h.response,isNewInstance:!1}]:[4,this.getFirebaseState(t)];case 5:return l=w.sent(),d=l.state,f=l.unsubscribers,p=function(e){return o(b,void 0,void 0,(function(){var n;return a(this,(function(i){switch(i.label){case 0:e.retryConfig=r(r({},this.clientConfig.retryConfig),e.retryConfig),i.label=1;case 1:return i.trys.push([1,3,,8]),[4,this.sendToActionQueue({action:y.RetterActions.COS_CALL,data:r(r({},e),{classId:t.classId,instanceId:t.instanceId})})];case 2:return[2,i.sent()];case 3:return n=i.sent(),--e.retryConfig.count,e.retryConfig.delay*=e.retryConfig.rate,n.response&&570===n.response.status&&e.retryConfig.count>0?[4,new Promise((function(t){return setTimeout(t,e.retryConfig.delay)}))]:[3,6];case 4:return i.sent(),[4,p(e)];case 5:return[2,i.sent()];case 6:throw n;case 7:return[3,8];case 8:return[2]}}))}))},m=function(e){return o(b,void 0,void 0,(function(){return a(this,(function(n){switch(n.label){case 0:return[4,this.sendToActionQueue({action:y.RetterActions.COS_STATE,data:r(r({},e),{classId:t.classId,instanceId:t.instanceId})})];case 1:return[2,n.sent()]}}))}))},g=function(e){return o(b,void 0,void 0,(function(){return a(this,(function(n){switch(n.label){case 0:return[4,this.sendToActionQueue({action:y.RetterActions.COS_LIST,data:r(r({},e),{classId:t.classId})})];case 1:return[2,n.sent().data.instanceIds]}}))}))},v={call:p,state:d,getState:m,listInstances:g,methods:null!==(n=null==c?void 0:c.methods)&&void 0!==n?n:[],response:null!==(i=null==c?void 0:c.response)&&void 0!==i?i:null,instanceId:t.instanceId,isNewInstance:null!==(s=null==c?void 0:c.isNewInstance)&&void 0!==s&&s},this.cloudObjects.push(r(r({},v),{config:t,unsubscribers:f})),[2,v]}}))}))},Object.defineProperty(t.prototype,"authStatus",{get:function(){return this.authStatusSubject.asObservable().pipe((0,p.distinctUntilChanged)((function(t,e){return t.authStatus===e.authStatus&&t.identity===e.identity&&t.uid===e.uid})))},enumerable:!1,configurable:!0}),t.instances=[],t}();e.default=v},9699:(t,e)=>{"use strict";var n,r,i;Object.defineProperty(e,"__esModule",{value:!0}),e.RetterAuthStatus=e.RetterActions=e.RetterRegion=void 0,(i=e.RetterRegion||(e.RetterRegion={}))[i.euWest1=0]="euWest1",i[i.euWest1Beta=1]="euWest1Beta",(r=e.RetterActions||(e.RetterActions={})).EMPTY="EMPTY",r.SIGN_IN="SIGN_IN",r.SIGN_IN_ANONYM="SIGN_IN_ANONYM",r.COS_CALL="COS_CALL",r.COS_STATE="COS_STATE",r.COS_INSTANCE="COS_INSTANCE",r.COS_LIST="COS_LIST",(n=e.RetterAuthStatus||(e.RetterAuthStatus={})).SIGNED_IN="SIGNED_IN",n.SIGNED_IN_ANONYM="SIGNED_IN_ANONYM",n.SIGNED_OUT="SIGNED_OUT",n.AUTH_FAILED="AUTH_FAILED"},2238:(t,e,n)=>{"use strict";n.d(e,{ZR:()=>s.ZR,Jn:()=>T,l4:()=>h,H9:()=>p,Vr:()=>m,Af:()=>d,Z8:()=>b,lz:()=>f,qX:()=>y,Xd:()=>g,wN:()=>v,P2:()=>k,Mq:()=>E,C6:()=>S,ZF:()=>_,TP:()=>N,KN:()=>A,Ub:()=>x});var r=n(8463),i=n(3333),s=n(4444);class o{constructor(t){this.container=t}getPlatformInfoString(){return this.container.getProviders().map((t=>{if(function(t){const e=t.getComponent();return"VERSION"===(null==e?void 0:e.type)}(t)){const e=t.getImmediate();return`${e.library}/${e.version}`}return null})).filter((t=>t)).join(" ")}}const a="@firebase/app",c="0.7.12",u=new i.Yd("@firebase/app"),h="[DEFAULT]",l={[a]:"fire-core","@firebase/app-compat":"fire-core-compat","@firebase/analytics":"fire-analytics","@firebase/analytics-compat":"fire-analytics-compat","@firebase/app-check":"fire-app-check","@firebase/app-check-compat":"fire-app-check-compat","@firebase/auth":"fire-auth","@firebase/auth-compat":"fire-auth-compat","@firebase/database":"fire-rtdb","@firebase/database-compat":"fire-rtdb-compat","@firebase/functions":"fire-fn","@firebase/functions-compat":"fire-fn-compat","@firebase/installations":"fire-iid","@firebase/installations-compat":"fire-iid-compat","@firebase/messaging":"fire-fcm","@firebase/messaging-compat":"fire-fcm-compat","@firebase/performance":"fire-perf","@firebase/performance-compat":"fire-perf-compat","@firebase/remote-config":"fire-rc","@firebase/remote-config-compat":"fire-rc-compat","@firebase/storage":"fire-gcs","@firebase/storage-compat":"fire-gcs-compat","@firebase/firestore":"fire-fst","@firebase/firestore-compat":"fire-fst-compat","fire-js":"fire-js",firebase:"fire-js-all"},d=new Map,f=new Map;function p(t,e){try{t.container.addComponent(e)}catch(n){u.debug(`Component ${e.name} failed to register with FirebaseApp ${t.name}`,n)}}function m(t,e){t.container.addOrOverwriteComponent(e)}function g(t){const e=t.name;if(f.has(e))return u.debug(`There were multiple attempts to register component ${e}.`),!1;f.set(e,t);for(const e of d.values())p(e,t);return!0}function y(t,e){return t.container.getProvider(e)}function v(t,e,n=h){y(t,e).clearInstance(n)}function b(){f.clear()}const w=new s.LL("app","Firebase",{"no-app":"No Firebase App '{$appName}' has been created - call Firebase App.initializeApp()","bad-app-name":"Illegal App name: '{$appName}","duplicate-app":"Firebase App named '{$appName}' already exists with different options or config","app-deleted":"Firebase App named '{$appName}' already deleted","invalid-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance.","invalid-log-argument":"First argument to `onLog` must be null or a function."});class I{constructor(t,e,n){this._isDeleted=!1,this._options=Object.assign({},t),this._config=Object.assign({},e),this._name=e.name,this._automaticDataCollectionEnabled=e.automaticDataCollectionEnabled,this._container=n,this.container.addComponent(new r.wA("app",(()=>this),"PUBLIC"))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(t){this.checkDestroyed(),this._automaticDataCollectionEnabled=t}get name(){return this.checkDestroyed(),this._name}get options(){return this.checkDestroyed(),this._options}get config(){return this.checkDestroyed(),this._config}get container(){return this._container}get isDeleted(){return this._isDeleted}set isDeleted(t){this._isDeleted=t}checkDestroyed(){if(this.isDeleted)throw w.create("app-deleted",{appName:this._name})}}const T="9.6.2";function _(t,e={}){"object"!=typeof e&&(e={name:e});const n=Object.assign({name:h,automaticDataCollectionEnabled:!1},e),i=n.name;if("string"!=typeof i||!i)throw w.create("bad-app-name",{appName:String(i)});const o=d.get(i);if(o){if((0,s.vZ)(t,o.options)&&(0,s.vZ)(n,o.config))return o;throw w.create("duplicate-app",{appName:i})}const a=new r.H0(i);for(const t of f.values())a.addComponent(t);const c=new I(t,n,a);return d.set(i,c),c}function E(t=h){const e=d.get(t);if(!e)throw w.create("no-app",{appName:t});return e}function S(){return Array.from(d.values())}async function k(t){const e=t.name;d.has(e)&&(d.delete(e),await Promise.all(t.container.getProviders().map((t=>t.delete()))),t.isDeleted=!0)}function A(t,e,n){var i;let s=null!==(i=l[t])&&void 0!==i?i:t;n&&(s+=`-${n}`);const o=s.match(/\s|\//),a=e.match(/\s|\//);if(o||a){const t=[`Unable to register library "${s}" with version "${e}":`];return o&&t.push(`library name "${s}" contains illegal characters (whitespace or "/")`),o&&a&&t.push("and"),a&&t.push(`version name "${e}" contains illegal characters (whitespace or "/")`),void u.warn(t.join(" "))}g(new r.wA(`${s}-version`,(()=>({library:s,version:e})),"VERSION"))}function N(t,e){if(null!==t&&"function"!=typeof t)throw w.create("invalid-log-argument");(0,i.Am)(t,e)}function x(t){(0,i.Ub)(t)}g(new r.wA("platform-logger",(t=>new o(t)),"PRIVATE")),A(a,c,""),A(a,c,"esm2017"),A("fire-js","")},8463:(t,e,n)=>{"use strict";n.d(e,{wA:()=>i,H0:()=>a});var r=n(4444);class i{constructor(t,e,n){this.name=t,this.instanceFactory=e,this.type=n,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(t){return this.instantiationMode=t,this}setMultipleInstances(t){return this.multipleInstances=t,this}setServiceProps(t){return this.serviceProps=t,this}setInstanceCreatedCallback(t){return this.onInstanceCreated=t,this}}const s="[DEFAULT]";class o{constructor(t,e){this.name=t,this.container=e,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(t){const e=this.normalizeInstanceIdentifier(t);if(!this.instancesDeferred.has(e)){const t=new r.BH;if(this.instancesDeferred.set(e,t),this.isInitialized(e)||this.shouldAutoInitialize())try{const n=this.getOrInitializeService({instanceIdentifier:e});n&&t.resolve(n)}catch(t){}}return this.instancesDeferred.get(e).promise}getImmediate(t){var e;const n=this.normalizeInstanceIdentifier(null==t?void 0:t.identifier),r=null!==(e=null==t?void 0:t.optional)&&void 0!==e&&e;if(!this.isInitialized(n)&&!this.shouldAutoInitialize()){if(r)return null;throw Error(`Service ${this.name} is not available`)}try{return this.getOrInitializeService({instanceIdentifier:n})}catch(t){if(r)return null;throw t}}getComponent(){return this.component}setComponent(t){if(t.name!==this.name)throw Error(`Mismatching Component ${t.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=t,this.shouldAutoInitialize()){if(function(t){return"EAGER"===t.instantiationMode}(t))try{this.getOrInitializeService({instanceIdentifier:s})}catch(t){}for(const[t,e]of this.instancesDeferred.entries()){const n=this.normalizeInstanceIdentifier(t);try{const t=this.getOrInitializeService({instanceIdentifier:n});e.resolve(t)}catch(t){}}}}clearInstance(t="[DEFAULT]"){this.instancesDeferred.delete(t),this.instancesOptions.delete(t),this.instances.delete(t)}async delete(){const t=Array.from(this.instances.values());await Promise.all([...t.filter((t=>"INTERNAL"in t)).map((t=>t.INTERNAL.delete())),...t.filter((t=>"_delete"in t)).map((t=>t._delete()))])}isComponentSet(){return null!=this.component}isInitialized(t="[DEFAULT]"){return this.instances.has(t)}getOptions(t="[DEFAULT]"){return this.instancesOptions.get(t)||{}}initialize(t={}){const{options:e={}}=t,n=this.normalizeInstanceIdentifier(t.instanceIdentifier);if(this.isInitialized(n))throw Error(`${this.name}(${n}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const r=this.getOrInitializeService({instanceIdentifier:n,options:e});for(const[t,e]of this.instancesDeferred.entries())n===this.normalizeInstanceIdentifier(t)&&e.resolve(r);return r}onInit(t,e){var n;const r=this.normalizeInstanceIdentifier(e),i=null!==(n=this.onInitCallbacks.get(r))&&void 0!==n?n:new Set;i.add(t),this.onInitCallbacks.set(r,i);const s=this.instances.get(r);return s&&t(s,r),()=>{i.delete(t)}}invokeOnInitCallbacks(t,e){const n=this.onInitCallbacks.get(e);if(n)for(const r of n)try{r(t,e)}catch(t){}}getOrInitializeService({instanceIdentifier:t,options:e={}}){let n=this.instances.get(t);if(!n&&this.component&&(n=this.component.instanceFactory(this.container,{instanceIdentifier:(r=t,r===s?void 0:r),options:e}),this.instances.set(t,n),this.instancesOptions.set(t,e),this.invokeOnInitCallbacks(n,t),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,t,n)}catch(t){}var r;return n||null}normalizeInstanceIdentifier(t="[DEFAULT]"){return this.component?this.component.multipleInstances?t:s:t}shouldAutoInitialize(){return!!this.component&&"EXPLICIT"!==this.component.instantiationMode}}class a{constructor(t){this.name=t,this.providers=new Map}addComponent(t){const e=this.getProvider(t.name);if(e.isComponentSet())throw new Error(`Component ${t.name} has already been registered with ${this.name}`);e.setComponent(t)}addOrOverwriteComponent(t){this.getProvider(t.name).isComponentSet()&&this.providers.delete(t.name),this.addComponent(t)}getProvider(t){if(this.providers.has(t))return this.providers.get(t);const e=new o(t,this);return this.providers.set(t,e),e}getProviders(){return Array.from(this.providers.values())}}},3333:(t,e,n)=>{"use strict";n.d(e,{in:()=>i,Yd:()=>u,Ub:()=>h,Am:()=>l});const r=[];var i;!function(t){t[t.DEBUG=0]="DEBUG",t[t.VERBOSE=1]="VERBOSE",t[t.INFO=2]="INFO",t[t.WARN=3]="WARN",t[t.ERROR=4]="ERROR",t[t.SILENT=5]="SILENT"}(i||(i={}));const s={debug:i.DEBUG,verbose:i.VERBOSE,info:i.INFO,warn:i.WARN,error:i.ERROR,silent:i.SILENT},o=i.INFO,a={[i.DEBUG]:"log",[i.VERBOSE]:"log",[i.INFO]:"info",[i.WARN]:"warn",[i.ERROR]:"error"},c=(t,e,...n)=>{if(e<t.logLevel)return;const r=(new Date).toISOString(),i=a[e];if(!i)throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`);console[i](`[${r}] ${t.name}:`,...n)};class u{constructor(t){this.name=t,this._logLevel=o,this._logHandler=c,this._userLogHandler=null,r.push(this)}get logLevel(){return this._logLevel}set logLevel(t){if(!(t in i))throw new TypeError(`Invalid value "${t}" assigned to \`logLevel\``);this._logLevel=t}setLogLevel(t){this._logLevel="string"==typeof t?s[t]:t}get logHandler(){return this._logHandler}set logHandler(t){if("function"!=typeof t)throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=t}get userLogHandler(){return this._userLogHandler}set userLogHandler(t){this._userLogHandler=t}debug(...t){this._userLogHandler&&this._userLogHandler(this,i.DEBUG,...t),this._logHandler(this,i.DEBUG,...t)}log(...t){this._userLogHandler&&this._userLogHandler(this,i.VERBOSE,...t),this._logHandler(this,i.VERBOSE,...t)}info(...t){this._userLogHandler&&this._userLogHandler(this,i.INFO,...t),this._logHandler(this,i.INFO,...t)}warn(...t){this._userLogHandler&&this._userLogHandler(this,i.WARN,...t),this._logHandler(this,i.WARN,...t)}error(...t){this._userLogHandler&&this._userLogHandler(this,i.ERROR,...t),this._logHandler(this,i.ERROR,...t)}}function h(t){r.forEach((e=>{e.setLogLevel(t)}))}function l(t,e){for(const n of r){let r=null;e&&e.level&&(r=s[e.level]),n.userLogHandler=null===t?null:(e,n,...s)=>{const o=s.map((t=>{if(null==t)return null;if("string"==typeof t)return t;if("number"==typeof t||"boolean"==typeof t)return t.toString();if(t instanceof Error)return t.message;try{return JSON.stringify(t)}catch(t){return null}})).filter((t=>t)).join(" ");n>=(null!=r?r:e.logLevel)&&t({level:i[n].toLowerCase(),message:o,args:s,type:e.name})}}}}},e={};function n(r){var i=e[r];if(void 0!==i)return i.exports;var s=e[r]={exports:{}};return t[r].call(s.exports,s,s.exports,n),s.exports}n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r=n(3607);return r.default})()}));
2
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Retter=e():t.Retter=e()}(self,(function(){return(()=>{var t={4444:(t,e,n)=>{"use strict";n.d(e,{BH:()=>a,LL:()=>b,ZR:()=>v,tV:()=>o,Sg:()=>c,ne:()=>A,vZ:()=>T,pd:()=>k,m9:()=>C,z$:()=>u,ru:()=>l,d:()=>f,xb:()=>I,w1:()=>p,hl:()=>y,uI:()=>h,b$:()=>d,G6:()=>g,Mn:()=>m,xO:()=>E,zd:()=>S});const r=function(t){const e=[];let n=0;for(let r=0;r<t.length;r++){let i=t.charCodeAt(r);i<128?e[n++]=i:i<2048?(e[n++]=i>>6|192,e[n++]=63&i|128):55296==(64512&i)&&r+1<t.length&&56320==(64512&t.charCodeAt(r+1))?(i=65536+((1023&i)<<10)+(1023&t.charCodeAt(++r)),e[n++]=i>>18|240,e[n++]=i>>12&63|128,e[n++]=i>>6&63|128,e[n++]=63&i|128):(e[n++]=i>>12|224,e[n++]=i>>6&63|128,e[n++]=63&i|128)}return e},i={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(t,e){if(!Array.isArray(t))throw Error("encodeByteArray takes an array as a parameter");this.init_();const n=e?this.byteToCharMapWebSafe_:this.byteToCharMap_,r=[];for(let e=0;e<t.length;e+=3){const i=t[e],s=e+1<t.length,o=s?t[e+1]:0,a=e+2<t.length,c=a?t[e+2]:0,u=i>>2,h=(3&i)<<4|o>>4;let l=(15&o)<<2|c>>6,d=63&c;a||(d=64,s||(l=64)),r.push(n[u],n[h],n[l],n[d])}return r.join("")},encodeString(t,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(t):this.encodeByteArray(r(t),e)},decodeString(t,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(t):function(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n++];if(i<128)e[r++]=String.fromCharCode(i);else if(i>191&&i<224){const s=t[n++];e[r++]=String.fromCharCode((31&i)<<6|63&s)}else if(i>239&&i<365){const s=((7&i)<<18|(63&t[n++])<<12|(63&t[n++])<<6|63&t[n++])-65536;e[r++]=String.fromCharCode(55296+(s>>10)),e[r++]=String.fromCharCode(56320+(1023&s))}else{const s=t[n++],o=t[n++];e[r++]=String.fromCharCode((15&i)<<12|(63&s)<<6|63&o)}}return e.join("")}(this.decodeStringToByteArray(t,e))},decodeStringToByteArray(t,e){this.init_();const n=e?this.charToByteMapWebSafe_:this.charToByteMap_,r=[];for(let e=0;e<t.length;){const i=n[t.charAt(e++)],s=e<t.length?n[t.charAt(e)]:0;++e;const o=e<t.length?n[t.charAt(e)]:64;++e;const a=e<t.length?n[t.charAt(e)]:64;if(++e,null==i||null==s||null==o||null==a)throw Error();const c=i<<2|s>>4;if(r.push(c),64!==o){const t=s<<4&240|o>>2;if(r.push(t),64!==a){const t=o<<6&192|a;r.push(t)}}}return r},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let t=0;t<this.ENCODED_VALS.length;t++)this.byteToCharMap_[t]=this.ENCODED_VALS.charAt(t),this.charToByteMap_[this.byteToCharMap_[t]]=t,this.byteToCharMapWebSafe_[t]=this.ENCODED_VALS_WEBSAFE.charAt(t),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[t]]=t,t>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(t)]=t,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(t)]=t)}}},s=function(t){return function(t){const e=r(t);return i.encodeByteArray(e,!0)}(t).replace(/\./g,"")},o=function(t){try{return i.decodeString(t,!0)}catch(t){console.error("base64Decode failed: ",t)}return null};class a{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise(((t,e)=>{this.resolve=t,this.reject=e}))}wrapCallback(t){return(e,n)=>{e?this.reject(e):this.resolve(n),"function"==typeof t&&(this.promise.catch((()=>{})),1===t.length?t(e):t(e,n))}}}function c(t,e){if(t.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');const n=e||"demo-project",r=t.iat||0,i=t.sub||t.user_id;if(!i)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const o=Object.assign({iss:`https://securetoken.google.com/${n}`,aud:n,iat:r,exp:r+3600,auth_time:r,sub:i,user_id:i,firebase:{sign_in_provider:"custom",identities:{}}},t);return[s(JSON.stringify({alg:"none",type:"JWT"})),s(JSON.stringify(o)),""].join(".")}function u(){return"undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:""}function h(){return"undefined"!=typeof window&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(u())}function l(){const t="object"==typeof chrome?chrome.runtime:"object"==typeof browser?browser.runtime:void 0;return"object"==typeof t&&void 0!==t.id}function d(){return"object"==typeof navigator&&"ReactNative"===navigator.product}function f(){return u().indexOf("Electron/")>=0}function p(){const t=u();return t.indexOf("MSIE ")>=0||t.indexOf("Trident/")>=0}function m(){return u().indexOf("MSAppHost/")>=0}function g(){return!function(){try{return"[object process]"===Object.prototype.toString.call(n.g.process)}catch(t){return!1}}()&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}function y(){return"object"==typeof indexedDB}class v extends Error{constructor(t,e,n){super(e),this.code=t,this.customData=n,this.name="FirebaseError",Object.setPrototypeOf(this,v.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,b.prototype.create)}}class b{constructor(t,e,n){this.service=t,this.serviceName=e,this.errors=n}create(t,...e){const n=e[0]||{},r=`${this.service}/${t}`,i=this.errors[t],s=i?function(t,e){return t.replace(w,((t,n)=>{const r=e[n];return null!=r?String(r):`<${n}?>`}))}(i,n):"Error",o=`${this.serviceName}: ${s} (${r}).`;return new v(r,o,n)}}const w=/\{\$([^}]+)}/g;function I(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}function T(t,e){if(t===e)return!0;const n=Object.keys(t),r=Object.keys(e);for(const i of n){if(!r.includes(i))return!1;const n=t[i],s=e[i];if(_(n)&&_(s)){if(!T(n,s))return!1}else if(n!==s)return!1}for(const t of r)if(!n.includes(t))return!1;return!0}function _(t){return null!==t&&"object"==typeof t}function E(t){const e=[];for(const[n,r]of Object.entries(t))Array.isArray(r)?r.forEach((t=>{e.push(encodeURIComponent(n)+"="+encodeURIComponent(t))})):e.push(encodeURIComponent(n)+"="+encodeURIComponent(r));return e.length?"&"+e.join("&"):""}function S(t){const e={};return t.replace(/^\?/,"").split("&").forEach((t=>{if(t){const[n,r]=t.split("=");e[decodeURIComponent(n)]=decodeURIComponent(r)}})),e}function k(t){const e=t.indexOf("?");if(!e)return"";const n=t.indexOf("#",e);return t.substring(e,n>0?n:void 0)}function A(t,e){const n=new N(t,e);return n.subscribe.bind(n)}class N{constructor(t,e){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=e,this.task.then((()=>{t(this)})).catch((t=>{this.error(t)}))}next(t){this.forEachObserver((e=>{e.next(t)}))}error(t){this.forEachObserver((e=>{e.error(t)})),this.close(t)}complete(){this.forEachObserver((t=>{t.complete()})),this.close()}subscribe(t,e,n){let r;if(void 0===t&&void 0===e&&void 0===n)throw new Error("Missing Observer.");r=function(t,e){if("object"!=typeof t||null===t)return!1;for(const e of["next","error","complete"])if(e in t&&"function"==typeof t[e])return!0;return!1}(t)?t:{next:t,error:e,complete:n},void 0===r.next&&(r.next=x),void 0===r.error&&(r.error=x),void 0===r.complete&&(r.complete=x);const i=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then((()=>{try{this.finalError?r.error(this.finalError):r.complete()}catch(t){}})),this.observers.push(r),i}unsubscribeOne(t){void 0!==this.observers&&void 0!==this.observers[t]&&(delete this.observers[t],this.observerCount-=1,0===this.observerCount&&void 0!==this.onNoObservers&&this.onNoObservers(this))}forEachObserver(t){if(!this.finalized)for(let e=0;e<this.observers.length;e++)this.sendOne(e,t)}sendOne(t,e){this.task.then((()=>{if(void 0!==this.observers&&void 0!==this.observers[t])try{e(this.observers[t])}catch(t){"undefined"!=typeof console&&console.error&&console.error(t)}}))}close(t){this.finalized||(this.finalized=!0,void 0!==t&&(this.finalError=t),this.task.then((()=>{this.observers=void 0,this.onNoObservers=void 0})))}}function x(){}function C(t){return t&&t._delegate?t._delegate:t}},8060:(t,e,n)=>{"use strict";n.r(e),n.d(e,{default:()=>c,useAsyncStorage:()=>a});const r=n(942).bind({concatArrays:!0,ignoreUndefined:!0}),i=(t,e)=>new Promise(((n,r)=>{try{const r=t();e&&e(null,r),n(r)}catch(t){e&&e(t),r(t)}})),s=(t,e,n)=>Promise.all(t).then((t=>{const r=n?n(t):null;return e&&e(null,r),Promise.resolve(r)}),(t=>(e&&e(t),Promise.reject(t))));class o{static getItem(t,e){return i((()=>window.localStorage.getItem(t)),e)}static setItem(t,e,n){return i((()=>{window.localStorage.setItem(t,e)}),n)}static removeItem(t,e){return i((()=>window.localStorage.removeItem(t)),e)}static mergeItem(t,e,n){return i((()=>{((t,e)=>{const n=window.localStorage.getItem(t),i=JSON.parse(n),s=JSON.parse(e),o=JSON.stringify(r(i,s));window.localStorage.setItem(t,o)})(t,e)}),n)}static clear(t){return i((()=>{window.localStorage.clear()}),t)}static getAllKeys(t){return i((()=>{const t=window.localStorage.length,e=[];for(let n=0;n<t;n+=1){const t=window.localStorage.key(n);e.push(t)}return e}),t)}static flushGetRequests(){}static multiGet(t,e){const n=t.map((t=>o.getItem(t)));return s(n,e,(e=>e.map(((e,n)=>[t[n],e]))))}static multiSet(t,e){const n=t.map((t=>o.setItem(t[0],t[1])));return s(n,e)}static multiRemove(t,e){const n=t.map((t=>o.removeItem(t)));return s(n,e)}static multiMerge(t,e){const n=t.map((t=>o.mergeItem(t[0],t[1])));return s(n,e)}}function a(t){return{getItem:(...e)=>o.getItem(t,...e),setItem:(...e)=>o.setItem(t,...e),mergeItem:(...e)=>o.mergeItem(t,...e),removeItem:(...e)=>o.removeItem(t,...e)}}const c=o},9669:(t,e,n)=>{t.exports=n(1609)},5448:(t,e,n)=>{"use strict";var r=n(4867),i=n(6026),s=n(4372),o=n(5327),a=n(4097),c=n(4109),u=n(7985),h=n(5061),l=n(5655),d=n(5263);t.exports=function(t){return new Promise((function(e,n){var f,p=t.data,m=t.headers,g=t.responseType;function y(){t.cancelToken&&t.cancelToken.unsubscribe(f),t.signal&&t.signal.removeEventListener("abort",f)}r.isFormData(p)&&delete m["Content-Type"];var v=new XMLHttpRequest;if(t.auth){var b=t.auth.username||"",w=t.auth.password?unescape(encodeURIComponent(t.auth.password)):"";m.Authorization="Basic "+btoa(b+":"+w)}var I=a(t.baseURL,t.url);function T(){if(v){var r="getAllResponseHeaders"in v?c(v.getAllResponseHeaders()):null,s={data:g&&"text"!==g&&"json"!==g?v.response:v.responseText,status:v.status,statusText:v.statusText,headers:r,config:t,request:v};i((function(t){e(t),y()}),(function(t){n(t),y()}),s),v=null}}if(v.open(t.method.toUpperCase(),o(I,t.params,t.paramsSerializer),!0),v.timeout=t.timeout,"onloadend"in v?v.onloadend=T:v.onreadystatechange=function(){v&&4===v.readyState&&(0!==v.status||v.responseURL&&0===v.responseURL.indexOf("file:"))&&setTimeout(T)},v.onabort=function(){v&&(n(h("Request aborted",t,"ECONNABORTED",v)),v=null)},v.onerror=function(){n(h("Network Error",t,null,v)),v=null},v.ontimeout=function(){var e=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",r=t.transitional||l.transitional;t.timeoutErrorMessage&&(e=t.timeoutErrorMessage),n(h(e,t,r.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",v)),v=null},r.isStandardBrowserEnv()){var _=(t.withCredentials||u(I))&&t.xsrfCookieName?s.read(t.xsrfCookieName):void 0;_&&(m[t.xsrfHeaderName]=_)}"setRequestHeader"in v&&r.forEach(m,(function(t,e){void 0===p&&"content-type"===e.toLowerCase()?delete m[e]:v.setRequestHeader(e,t)})),r.isUndefined(t.withCredentials)||(v.withCredentials=!!t.withCredentials),g&&"json"!==g&&(v.responseType=t.responseType),"function"==typeof t.onDownloadProgress&&v.addEventListener("progress",t.onDownloadProgress),"function"==typeof t.onUploadProgress&&v.upload&&v.upload.addEventListener("progress",t.onUploadProgress),(t.cancelToken||t.signal)&&(f=function(t){v&&(n(!t||t&&t.type?new d("canceled"):t),v.abort(),v=null)},t.cancelToken&&t.cancelToken.subscribe(f),t.signal&&(t.signal.aborted?f():t.signal.addEventListener("abort",f))),p||(p=null),v.send(p)}))}},1609:(t,e,n)=>{"use strict";var r=n(4867),i=n(1849),s=n(321),o=n(7185),a=function t(e){var n=new s(e),a=i(s.prototype.request,n);return r.extend(a,s.prototype,n),r.extend(a,n),a.create=function(n){return t(o(e,n))},a}(n(5655));a.Axios=s,a.Cancel=n(5263),a.CancelToken=n(4972),a.isCancel=n(6502),a.VERSION=n(7288).version,a.all=function(t){return Promise.all(t)},a.spread=n(8713),a.isAxiosError=n(6268),t.exports=a,t.exports.default=a},5263:t=>{"use strict";function e(t){this.message=t}e.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},e.prototype.__CANCEL__=!0,t.exports=e},4972:(t,e,n)=>{"use strict";var r=n(5263);function i(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");var e;this.promise=new Promise((function(t){e=t}));var n=this;this.promise.then((function(t){if(n._listeners){var e,r=n._listeners.length;for(e=0;e<r;e++)n._listeners[e](t);n._listeners=null}})),this.promise.then=function(t){var e,r=new Promise((function(t){n.subscribe(t),e=t})).then(t);return r.cancel=function(){n.unsubscribe(e)},r},t((function(t){n.reason||(n.reason=new r(t),e(n.reason))}))}i.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},i.prototype.subscribe=function(t){this.reason?t(this.reason):this._listeners?this._listeners.push(t):this._listeners=[t]},i.prototype.unsubscribe=function(t){if(this._listeners){var e=this._listeners.indexOf(t);-1!==e&&this._listeners.splice(e,1)}},i.source=function(){var t;return{token:new i((function(e){t=e})),cancel:t}},t.exports=i},6502:t=>{"use strict";t.exports=function(t){return!(!t||!t.__CANCEL__)}},321:(t,e,n)=>{"use strict";var r=n(4867),i=n(5327),s=n(782),o=n(3572),a=n(7185),c=n(4875),u=c.validators;function h(t){this.defaults=t,this.interceptors={request:new s,response:new s}}h.prototype.request=function(t){"string"==typeof t?(t=arguments[1]||{}).url=arguments[0]:t=t||{},(t=a(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var e=t.transitional;void 0!==e&&c.assertOptions(e,{silentJSONParsing:u.transitional(u.boolean),forcedJSONParsing:u.transitional(u.boolean),clarifyTimeoutError:u.transitional(u.boolean)},!1);var n=[],r=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(r=r&&e.synchronous,n.unshift(e.fulfilled,e.rejected))}));var i,s=[];if(this.interceptors.response.forEach((function(t){s.push(t.fulfilled,t.rejected)})),!r){var h=[o,void 0];for(Array.prototype.unshift.apply(h,n),h=h.concat(s),i=Promise.resolve(t);h.length;)i=i.then(h.shift(),h.shift());return i}for(var l=t;n.length;){var d=n.shift(),f=n.shift();try{l=d(l)}catch(t){f(t);break}}try{i=o(l)}catch(t){return Promise.reject(t)}for(;s.length;)i=i.then(s.shift(),s.shift());return i},h.prototype.getUri=function(t){return t=a(this.defaults,t),i(t.url,t.params,t.paramsSerializer).replace(/^\?/,"")},r.forEach(["delete","get","head","options"],(function(t){h.prototype[t]=function(e,n){return this.request(a(n||{},{method:t,url:e,data:(n||{}).data}))}})),r.forEach(["post","put","patch"],(function(t){h.prototype[t]=function(e,n,r){return this.request(a(r||{},{method:t,url:e,data:n}))}})),t.exports=h},782:(t,e,n)=>{"use strict";var r=n(4867);function i(){this.handlers=[]}i.prototype.use=function(t,e,n){return this.handlers.push({fulfilled:t,rejected:e,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1},i.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},i.prototype.forEach=function(t){r.forEach(this.handlers,(function(e){null!==e&&t(e)}))},t.exports=i},4097:(t,e,n)=>{"use strict";var r=n(1793),i=n(7303);t.exports=function(t,e){return t&&!r(e)?i(t,e):e}},5061:(t,e,n)=>{"use strict";var r=n(481);t.exports=function(t,e,n,i,s){var o=new Error(t);return r(o,e,n,i,s)}},3572:(t,e,n)=>{"use strict";var r=n(4867),i=n(8527),s=n(6502),o=n(5655),a=n(5263);function c(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new a("canceled")}t.exports=function(t){return c(t),t.headers=t.headers||{},t.data=i.call(t,t.data,t.headers,t.transformRequest),t.headers=r.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),r.forEach(["delete","get","head","post","put","patch","common"],(function(e){delete t.headers[e]})),(t.adapter||o.adapter)(t).then((function(e){return c(t),e.data=i.call(t,e.data,e.headers,t.transformResponse),e}),(function(e){return s(e)||(c(t),e&&e.response&&(e.response.data=i.call(t,e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)}))}},481:t=>{"use strict";t.exports=function(t,e,n,r,i){return t.config=e,n&&(t.code=n),t.request=r,t.response=i,t.isAxiosError=!0,t.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}},t}},7185:(t,e,n)=>{"use strict";var r=n(4867);t.exports=function(t,e){e=e||{};var n={};function i(t,e){return r.isPlainObject(t)&&r.isPlainObject(e)?r.merge(t,e):r.isPlainObject(e)?r.merge({},e):r.isArray(e)?e.slice():e}function s(n){return r.isUndefined(e[n])?r.isUndefined(t[n])?void 0:i(void 0,t[n]):i(t[n],e[n])}function o(t){if(!r.isUndefined(e[t]))return i(void 0,e[t])}function a(n){return r.isUndefined(e[n])?r.isUndefined(t[n])?void 0:i(void 0,t[n]):i(void 0,e[n])}function c(n){return n in e?i(t[n],e[n]):n in t?i(void 0,t[n]):void 0}var u={url:o,method:o,data:o,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:c};return r.forEach(Object.keys(t).concat(Object.keys(e)),(function(t){var e=u[t]||s,i=e(t);r.isUndefined(i)&&e!==c||(n[t]=i)})),n}},6026:(t,e,n)=>{"use strict";var r=n(5061);t.exports=function(t,e,n){var i=n.config.validateStatus;n.status&&i&&!i(n.status)?e(r("Request failed with status code "+n.status,n.config,null,n.request,n)):t(n)}},8527:(t,e,n)=>{"use strict";var r=n(4867),i=n(5655);t.exports=function(t,e,n){var s=this||i;return r.forEach(n,(function(n){t=n.call(s,t,e)})),t}},5655:(t,e,n)=>{"use strict";var r=n(4867),i=n(6016),s=n(481),o={"Content-Type":"application/x-www-form-urlencoded"};function a(t,e){!r.isUndefined(t)&&r.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}var c,u={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(c=n(5448)),c),transformRequest:[function(t,e){return i(e,"Accept"),i(e,"Content-Type"),r.isFormData(t)||r.isArrayBuffer(t)||r.isBuffer(t)||r.isStream(t)||r.isFile(t)||r.isBlob(t)?t:r.isArrayBufferView(t)?t.buffer:r.isURLSearchParams(t)?(a(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString()):r.isObject(t)||e&&"application/json"===e["Content-Type"]?(a(e,"application/json"),function(t,e,n){if(r.isString(t))try{return(0,JSON.parse)(t),r.trim(t)}catch(t){if("SyntaxError"!==t.name)throw t}return(0,JSON.stringify)(t)}(t)):t}],transformResponse:[function(t){var e=this.transitional||u.transitional,n=e&&e.silentJSONParsing,i=e&&e.forcedJSONParsing,o=!n&&"json"===this.responseType;if(o||i&&r.isString(t)&&t.length)try{return JSON.parse(t)}catch(t){if(o){if("SyntaxError"===t.name)throw s(t,this,"E_JSON_PARSE");throw t}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};r.forEach(["delete","get","head"],(function(t){u.headers[t]={}})),r.forEach(["post","put","patch"],(function(t){u.headers[t]=r.merge(o)})),t.exports=u},7288:t=>{t.exports={version:"0.24.0"}},1849:t=>{"use strict";t.exports=function(t,e){return function(){for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];return t.apply(e,n)}}},5327:(t,e,n)=>{"use strict";var r=n(4867);function i(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}t.exports=function(t,e,n){if(!e)return t;var s;if(n)s=n(e);else if(r.isURLSearchParams(e))s=e.toString();else{var o=[];r.forEach(e,(function(t,e){null!=t&&(r.isArray(t)?e+="[]":t=[t],r.forEach(t,(function(t){r.isDate(t)?t=t.toISOString():r.isObject(t)&&(t=JSON.stringify(t)),o.push(i(e)+"="+i(t))})))})),s=o.join("&")}if(s){var a=t.indexOf("#");-1!==a&&(t=t.slice(0,a)),t+=(-1===t.indexOf("?")?"?":"&")+s}return t}},7303:t=>{"use strict";t.exports=function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t}},4372:(t,e,n)=>{"use strict";var r=n(4867);t.exports=r.isStandardBrowserEnv()?{write:function(t,e,n,i,s,o){var a=[];a.push(t+"="+encodeURIComponent(e)),r.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),r.isString(i)&&a.push("path="+i),r.isString(s)&&a.push("domain="+s),!0===o&&a.push("secure"),document.cookie=a.join("; ")},read:function(t){var e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},1793:t=>{"use strict";t.exports=function(t){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(t)}},6268:t=>{"use strict";t.exports=function(t){return"object"==typeof t&&!0===t.isAxiosError}},7985:(t,e,n)=>{"use strict";var r=n(4867);t.exports=r.isStandardBrowserEnv()?function(){var t,e=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function i(t){var r=t;return e&&(n.setAttribute("href",r),r=n.href),n.setAttribute("href",r),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return t=i(window.location.href),function(e){var n=r.isString(e)?i(e):e;return n.protocol===t.protocol&&n.host===t.host}}():function(){return!0}},6016:(t,e,n)=>{"use strict";var r=n(4867);t.exports=function(t,e){r.forEach(t,(function(n,r){r!==e&&r.toUpperCase()===e.toUpperCase()&&(t[e]=n,delete t[r])}))}},4109:(t,e,n)=>{"use strict";var r=n(4867),i=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];t.exports=function(t){var e,n,s,o={};return t?(r.forEach(t.split("\n"),(function(t){if(s=t.indexOf(":"),e=r.trim(t.substr(0,s)).toLowerCase(),n=r.trim(t.substr(s+1)),e){if(o[e]&&i.indexOf(e)>=0)return;o[e]="set-cookie"===e?(o[e]?o[e]:[]).concat([n]):o[e]?o[e]+", "+n:n}})),o):o}},8713:t=>{"use strict";t.exports=function(t){return function(e){return t.apply(null,e)}}},4875:(t,e,n)=>{"use strict";var r=n(7288).version,i={};["object","boolean","number","function","string","symbol"].forEach((function(t,e){i[t]=function(n){return typeof n===t||"a"+(e<1?"n ":" ")+t}}));var s={};i.transitional=function(t,e,n){function i(t,e){return"[Axios v"+r+"] Transitional option '"+t+"'"+e+(n?". "+n:"")}return function(n,r,o){if(!1===t)throw new Error(i(r," has been removed"+(e?" in "+e:"")));return e&&!s[r]&&(s[r]=!0,console.warn(i(r," has been deprecated since v"+e+" and will be removed in the near future"))),!t||t(n,r,o)}},t.exports={assertOptions:function(t,e,n){if("object"!=typeof t)throw new TypeError("options must be an object");for(var r=Object.keys(t),i=r.length;i-- >0;){var s=r[i],o=e[s];if(o){var a=t[s],c=void 0===a||o(a,s,t);if(!0!==c)throw new TypeError("option "+s+" must be "+c)}else if(!0!==n)throw Error("Unknown option "+s)}},validators:i}},4867:(t,e,n)=>{"use strict";var r=n(1849),i=Object.prototype.toString;function s(t){return"[object Array]"===i.call(t)}function o(t){return void 0===t}function a(t){return null!==t&&"object"==typeof t}function c(t){if("[object Object]"!==i.call(t))return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function u(t){return"[object Function]"===i.call(t)}function h(t,e){if(null!=t)if("object"!=typeof t&&(t=[t]),s(t))for(var n=0,r=t.length;n<r;n++)e.call(null,t[n],n,t);else for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.call(null,t[i],i,t)}t.exports={isArray:s,isArrayBuffer:function(t){return"[object ArrayBuffer]"===i.call(t)},isBuffer:function(t){return null!==t&&!o(t)&&null!==t.constructor&&!o(t.constructor)&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)},isFormData:function(t){return"undefined"!=typeof FormData&&t instanceof FormData},isArrayBufferView:function(t){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&t.buffer instanceof ArrayBuffer},isString:function(t){return"string"==typeof t},isNumber:function(t){return"number"==typeof t},isObject:a,isPlainObject:c,isUndefined:o,isDate:function(t){return"[object Date]"===i.call(t)},isFile:function(t){return"[object File]"===i.call(t)},isBlob:function(t){return"[object Blob]"===i.call(t)},isFunction:u,isStream:function(t){return a(t)&&u(t.pipe)},isURLSearchParams:function(t){return"undefined"!=typeof URLSearchParams&&t instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&"undefined"!=typeof window&&"undefined"!=typeof document},forEach:h,merge:function t(){var e={};function n(n,r){c(e[r])&&c(n)?e[r]=t(e[r],n):c(n)?e[r]=t({},n):s(n)?e[r]=n.slice():e[r]=n}for(var r=0,i=arguments.length;r<i;r++)h(arguments[r],n);return e},extend:function(t,e,n){return h(e,(function(e,i){t[i]=n&&"function"==typeof e?r(e,n):e})),t},trim:function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")},stripBOM:function(t){return 65279===t.charCodeAt(0)&&(t=t.slice(1)),t}}},5503:(t,e,n)=>{"use strict";n.r(e),n.d(e,{FirebaseError:()=>r.ZR,SDK_VERSION:()=>r.Jn,_DEFAULT_ENTRY_NAME:()=>r.l4,_addComponent:()=>r.H9,_addOrOverwriteComponent:()=>r.Vr,_apps:()=>r.Af,_clearComponents:()=>r.Z8,_components:()=>r.lz,_getProvider:()=>r.qX,_registerComponent:()=>r.Xd,_removeServiceInstance:()=>r.wN,deleteApp:()=>r.P2,getApp:()=>r.Mq,getApps:()=>r.C6,initializeApp:()=>r.ZF,onLog:()=>r.TP,registerVersion:()=>r.KN,setLogLevel:()=>r.Ub});var r=n(2238);(0,r.KN)("firebase","9.6.2","app")},900:(t,e,n)=>{"use strict";n.r(e),n.d(e,{ActionCodeOperation:()=>d,ActionCodeURL:()=>Pt,AuthCredential:()=>St,AuthErrorCodes:()=>g,EmailAuthCredential:()=>xt,EmailAuthProvider:()=>Mt,FacebookAuthProvider:()=>jt,FactorId:()=>c,GithubAuthProvider:()=>Bt,GoogleAuthProvider:()=>qt,OAuthCredential:()=>Dt,OAuthProvider:()=>Vt,OperationType:()=>l,PhoneAuthCredential:()=>Rt,PhoneAuthProvider:()=>Pn,PhoneMultiFactorGenerator:()=>_r,ProviderId:()=>u,RecaptchaVerifier:()=>An,SAMLAuthProvider:()=>Kt,SignInMethod:()=>h,TwitterAuthProvider:()=>Wt,applyActionCode:()=>fe,browserLocalPersistence:()=>Je,browserPopupRedirectResolver:()=>Ir,browserSessionPersistence:()=>Xe,checkActionCode:()=>pe,confirmPasswordReset:()=>de,connectAuthEmulator:()=>Tt,createUserWithEmailAndPassword:()=>ge,debugErrorMap:()=>f,deleteUser:()=>qe,fetchSignInMethodsForEmail:()=>Ie,getAdditionalUserInfo:()=>Pe,getAuth:()=>Nr,getIdToken:()=>G,getIdTokenResult:()=>H,getMultiFactorResolver:()=>Ke,getRedirectResult:()=>tr,inMemoryPersistence:()=>st,indexedDBLocalPersistence:()=>mn,initializeAuth:()=>x,isSignInWithEmailLink:()=>be,linkWithCredential:()=>se,linkWithPhoneNumber:()=>Cn,linkWithPopup:()=>Kn,linkWithRedirect:()=>Xn,multiFactor:()=>He,onAuthStateChanged:()=>Fe,onIdTokenChanged:()=>Me,parseActionCodeURL:()=>Lt,prodErrorMap:()=>p,reauthenticateWithCredential:()=>oe,reauthenticateWithPhoneNumber:()=>Dn,reauthenticateWithPopup:()=>zn,reauthenticateWithRedirect:()=>Zn,reload:()=>tt,sendEmailVerification:()=>Te,sendPasswordResetEmail:()=>le,sendSignInLinkToEmail:()=>ve,setPersistence:()=>Le,signInAnonymously:()=>Yt,signInWithCredential:()=>ie,signInWithCustomToken:()=>ae,signInWithEmailAndPassword:()=>ye,signInWithEmailLink:()=>we,signInWithPhoneNumber:()=>xn,signInWithPopup:()=>Bn,signInWithRedirect:()=>Jn,signOut:()=>je,unlink:()=>Xt,updateCurrentUser:()=>Ve,updateEmail:()=>Se,updatePassword:()=>ke,updatePhoneNumber:()=>Rn,updateProfile:()=>Ee,useDeviceLanguage:()=>Ue,verifyBeforeUpdateEmail:()=>_e,verifyPasswordResetCode:()=>me});var r=n(4444),i=n(2238);function s(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}Object.create,Object.create;var o=n(3333),a=n(8463);const c={PHONE:"phone"},u={FACEBOOK:"facebook.com",GITHUB:"github.com",GOOGLE:"google.com",PASSWORD:"password",PHONE:"phone",TWITTER:"twitter.com"},h={EMAIL_LINK:"emailLink",EMAIL_PASSWORD:"password",FACEBOOK:"facebook.com",GITHUB:"github.com",GOOGLE:"google.com",PHONE:"phone",TWITTER:"twitter.com"},l={LINK:"link",REAUTHENTICATE:"reauthenticate",SIGN_IN:"signIn"},d={EMAIL_SIGNIN:"EMAIL_SIGNIN",PASSWORD_RESET:"PASSWORD_RESET",RECOVER_EMAIL:"RECOVER_EMAIL",REVERT_SECOND_FACTOR_ADDITION:"REVERT_SECOND_FACTOR_ADDITION",VERIFY_AND_CHANGE_EMAIL:"VERIFY_AND_CHANGE_EMAIL",VERIFY_EMAIL:"VERIFY_EMAIL"};const f=function(){return{"admin-restricted-operation":"This operation is restricted to administrators only.","argument-error":"","app-not-authorized":"This app, identified by the domain where it's hosted, is not authorized to use Firebase Authentication with the provided API key. Review your key configuration in the Google API console.","app-not-installed":"The requested mobile application corresponding to the identifier (Android package name or iOS bundle ID) provided is not installed on this device.","captcha-check-failed":"The reCAPTCHA response token provided is either invalid, expired, already used or the domain associated with it does not match the list of whitelisted domains.","code-expired":"The SMS code has expired. Please re-send the verification code to try again.","cordova-not-ready":"Cordova framework is not ready.","cors-unsupported":"This browser is not supported.","credential-already-in-use":"This credential is already associated with a different user account.","custom-token-mismatch":"The custom token corresponds to a different audience.","requires-recent-login":"This operation is sensitive and requires recent authentication. Log in again before retrying this request.","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.","dynamic-link-not-activated":"Please activate Dynamic Links in the Firebase Console and agree to the terms and conditions.","email-change-needs-verification":"Multi-factor users must always have a verified email.","email-already-in-use":"The email address is already in use by another account.","emulator-config-failed":'Auth instance has already been used to make a network call. Auth can no longer be configured to use the emulator. Try calling "connectAuthEmulator()" sooner.',"expired-action-code":"The action code has expired.","cancelled-popup-request":"This operation has been cancelled due to another conflicting popup being opened.","internal-error":"An internal AuthError has occurred.","invalid-app-credential":"The phone verification request contains an invalid application verifier. The reCAPTCHA token response is either invalid or expired.","invalid-app-id":"The mobile app identifier is not registed for the current project.","invalid-user-token":"This user's credential isn't valid for this project. This can happen if the user's token has been tampered with, or if the user isn't for the project associated with this API key.","invalid-auth-event":"An internal AuthError has occurred.","invalid-verification-code":"The SMS verification code used to create the phone auth credential is invalid. Please resend the verification code sms and be sure to use the verification code provided by the user.","invalid-continue-uri":"The continue URL provided in the request is invalid.","invalid-cordova-configuration":"The following Cordova plugins must be installed to enable OAuth sign-in: cordova-plugin-buildinfo, cordova-universal-links-plugin, cordova-plugin-browsertab, cordova-plugin-inappbrowser and cordova-plugin-customurlscheme.","invalid-custom-token":"The custom token format is incorrect. Please check the documentation.","invalid-dynamic-link-domain":"The provided dynamic link domain is not configured or authorized for the current project.","invalid-email":"The email address is badly formatted.","invalid-emulator-scheme":"Emulator URL must start with a valid scheme (http:// or https://).","invalid-api-key":"Your API key is invalid, please check you have copied it correctly.","invalid-cert-hash":"The SHA-1 certificate hash provided is invalid.","invalid-credential":"The supplied auth credential is malformed or has expired.","invalid-message-payload":"The email template corresponding to this action contains invalid characters in its message. Please fix by going to the Auth email templates section in the Firebase Console.","invalid-multi-factor-session":"The request does not contain a valid proof of first factor successful sign-in.","invalid-oauth-provider":"EmailAuthProvider is not supported for this operation. This operation only supports OAuth providers.","invalid-oauth-client-id":"The OAuth client ID provided is either invalid or does not match the specified API key.","unauthorized-domain":"This domain is not authorized for OAuth operations for your Firebase project. Edit the list of authorized domains from the Firebase console.","invalid-action-code":"The action code is invalid. This can happen if the code is malformed, expired, or has already been used.","wrong-password":"The password is invalid or the user does not have a password.","invalid-persistence-type":"The specified persistence type is invalid. It can only be local, session or none.","invalid-phone-number":"The format of the phone number provided is incorrect. Please enter the phone number in a format that can be parsed into E.164 format. E.164 phone numbers are written in the format [+][country code][subscriber number including area code].","invalid-provider-id":"The specified provider ID is invalid.","invalid-recipient-email":"The email corresponding to this action failed to send as the provided recipient email address is invalid.","invalid-sender":"The email template corresponding to this action contains an invalid sender email or name. Please fix by going to the Auth email templates section in the Firebase Console.","invalid-verification-id":"The verification ID used to create the phone auth credential is invalid.","invalid-tenant-id":"The Auth instance's tenant ID is invalid.","missing-android-pkg-name":"An Android Package Name must be provided if the Android App is required to be installed.","auth-domain-config-required":"Be sure to include authDomain when calling firebase.initializeApp(), by following the instructions in the Firebase console.","missing-app-credential":"The phone verification request is missing an application verifier assertion. A reCAPTCHA response token needs to be provided.","missing-verification-code":"The phone auth credential was created with an empty SMS verification code.","missing-continue-uri":"A continue URL must be provided in the request.","missing-iframe-start":"An internal AuthError has occurred.","missing-ios-bundle-id":"An iOS Bundle ID must be provided if an App Store ID is provided.","missing-or-invalid-nonce":"The request does not contain a valid nonce. This can occur if the SHA-256 hash of the provided raw nonce does not match the hashed nonce in the ID token payload.","missing-multi-factor-info":"No second factor identifier is provided.","missing-multi-factor-session":"The request is missing proof of first factor successful sign-in.","missing-phone-number":"To send verification codes, provide a phone number for the recipient.","missing-verification-id":"The phone auth credential was created with an empty verification ID.","app-deleted":"This instance of FirebaseApp has been deleted.","multi-factor-info-not-found":"The user does not have a second factor matching the identifier provided.","multi-factor-auth-required":"Proof of ownership of a second factor is required to complete sign-in.","account-exists-with-different-credential":"An account already exists with the same email address but different sign-in credentials. Sign in using a provider associated with this email address.","network-request-failed":"A network AuthError (such as timeout, interrupted connection or unreachable host) has occurred.","no-auth-event":"An internal AuthError has occurred.","no-such-provider":"User was not linked to an account with the given provider.","null-user":"A null user object was provided as the argument for an operation which requires a non-null user object.","operation-not-allowed":"The given sign-in provider is disabled for this Firebase project. Enable it in the Firebase console, under the sign-in method tab of the Auth section.","operation-not-supported-in-this-environment":'This operation is not supported in the environment this application is running on. "location.protocol" must be http, https or chrome-extension and web storage must be enabled.',"popup-blocked":"Unable to establish a connection with the popup. It may have been blocked by the browser.","popup-closed-by-user":"The popup has been closed by the user before finalizing the operation.","provider-already-linked":"User can only be linked to one identity for the given provider.","quota-exceeded":"The project's quota for this operation has been exceeded.","redirect-cancelled-by-user":"The redirect operation has been cancelled by the user before finalizing.","redirect-operation-pending":"A redirect sign-in operation is already pending.","rejected-credential":"The request contains malformed or mismatching credentials.","second-factor-already-in-use":"The second factor is already enrolled on this account.","maximum-second-factor-count-exceeded":"The maximum allowed number of second factors on a user has been exceeded.","tenant-id-mismatch":"The provided tenant ID does not match the Auth instance's tenant ID",timeout:"The operation has timed out.","user-token-expired":"The user's credential is no longer valid. The user must sign in again.","too-many-requests":"We have blocked all requests from this device due to unusual activity. Try again later.","unauthorized-continue-uri":"The domain of the continue URL is not whitelisted. Please whitelist the domain in the Firebase console.","unsupported-first-factor":"Enrolling a second factor or signing in with a multi-factor account requires sign-in with a supported first factor.","unsupported-persistence-type":"The current environment does not support the specified persistence type.","unsupported-tenant-operation":"This operation is not supported in a multi-tenant context.","unverified-email":"The operation requires a verified email.","user-cancelled":"The user did not grant your application the permissions it requested.","user-not-found":"There is no user record corresponding to this identifier. The user may have been deleted.","user-disabled":"The user account has been disabled by an administrator.","user-mismatch":"The supplied credentials do not correspond to the previously signed in user.","user-signed-out":"","weak-password":"The password must be 6 characters long or more.","web-storage-unsupported":"This browser is not supported or 3rd party cookies and data may be disabled.","already-initialized":"initializeAuth() has already been called with different options. To avoid this error, call initializeAuth() with the same options as when it was originally called, or call getAuth() to return the already initialized instance."}},p=function(){return{"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."}},m=new r.LL("auth","Firebase",{"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."}),g={ADMIN_ONLY_OPERATION:"auth/admin-restricted-operation",ARGUMENT_ERROR:"auth/argument-error",APP_NOT_AUTHORIZED:"auth/app-not-authorized",APP_NOT_INSTALLED:"auth/app-not-installed",CAPTCHA_CHECK_FAILED:"auth/captcha-check-failed",CODE_EXPIRED:"auth/code-expired",CORDOVA_NOT_READY:"auth/cordova-not-ready",CORS_UNSUPPORTED:"auth/cors-unsupported",CREDENTIAL_ALREADY_IN_USE:"auth/credential-already-in-use",CREDENTIAL_MISMATCH:"auth/custom-token-mismatch",CREDENTIAL_TOO_OLD_LOGIN_AGAIN:"auth/requires-recent-login",DEPENDENT_SDK_INIT_BEFORE_AUTH:"auth/dependent-sdk-initialized-before-auth",DYNAMIC_LINK_NOT_ACTIVATED:"auth/dynamic-link-not-activated",EMAIL_CHANGE_NEEDS_VERIFICATION:"auth/email-change-needs-verification",EMAIL_EXISTS:"auth/email-already-in-use",EMULATOR_CONFIG_FAILED:"auth/emulator-config-failed",EXPIRED_OOB_CODE:"auth/expired-action-code",EXPIRED_POPUP_REQUEST:"auth/cancelled-popup-request",INTERNAL_ERROR:"auth/internal-error",INVALID_API_KEY:"auth/invalid-api-key",INVALID_APP_CREDENTIAL:"auth/invalid-app-credential",INVALID_APP_ID:"auth/invalid-app-id",INVALID_AUTH:"auth/invalid-user-token",INVALID_AUTH_EVENT:"auth/invalid-auth-event",INVALID_CERT_HASH:"auth/invalid-cert-hash",INVALID_CODE:"auth/invalid-verification-code",INVALID_CONTINUE_URI:"auth/invalid-continue-uri",INVALID_CORDOVA_CONFIGURATION:"auth/invalid-cordova-configuration",INVALID_CUSTOM_TOKEN:"auth/invalid-custom-token",INVALID_DYNAMIC_LINK_DOMAIN:"auth/invalid-dynamic-link-domain",INVALID_EMAIL:"auth/invalid-email",INVALID_EMULATOR_SCHEME:"auth/invalid-emulator-scheme",INVALID_IDP_RESPONSE:"auth/invalid-credential",INVALID_MESSAGE_PAYLOAD:"auth/invalid-message-payload",INVALID_MFA_SESSION:"auth/invalid-multi-factor-session",INVALID_OAUTH_CLIENT_ID:"auth/invalid-oauth-client-id",INVALID_OAUTH_PROVIDER:"auth/invalid-oauth-provider",INVALID_OOB_CODE:"auth/invalid-action-code",INVALID_ORIGIN:"auth/unauthorized-domain",INVALID_PASSWORD:"auth/wrong-password",INVALID_PERSISTENCE:"auth/invalid-persistence-type",INVALID_PHONE_NUMBER:"auth/invalid-phone-number",INVALID_PROVIDER_ID:"auth/invalid-provider-id",INVALID_RECIPIENT_EMAIL:"auth/invalid-recipient-email",INVALID_SENDER:"auth/invalid-sender",INVALID_SESSION_INFO:"auth/invalid-verification-id",INVALID_TENANT_ID:"auth/invalid-tenant-id",MFA_INFO_NOT_FOUND:"auth/multi-factor-info-not-found",MFA_REQUIRED:"auth/multi-factor-auth-required",MISSING_ANDROID_PACKAGE_NAME:"auth/missing-android-pkg-name",MISSING_APP_CREDENTIAL:"auth/missing-app-credential",MISSING_AUTH_DOMAIN:"auth/auth-domain-config-required",MISSING_CODE:"auth/missing-verification-code",MISSING_CONTINUE_URI:"auth/missing-continue-uri",MISSING_IFRAME_START:"auth/missing-iframe-start",MISSING_IOS_BUNDLE_ID:"auth/missing-ios-bundle-id",MISSING_OR_INVALID_NONCE:"auth/missing-or-invalid-nonce",MISSING_MFA_INFO:"auth/missing-multi-factor-info",MISSING_MFA_SESSION:"auth/missing-multi-factor-session",MISSING_PHONE_NUMBER:"auth/missing-phone-number",MISSING_SESSION_INFO:"auth/missing-verification-id",MODULE_DESTROYED:"auth/app-deleted",NEED_CONFIRMATION:"auth/account-exists-with-different-credential",NETWORK_REQUEST_FAILED:"auth/network-request-failed",NULL_USER:"auth/null-user",NO_AUTH_EVENT:"auth/no-auth-event",NO_SUCH_PROVIDER:"auth/no-such-provider",OPERATION_NOT_ALLOWED:"auth/operation-not-allowed",OPERATION_NOT_SUPPORTED:"auth/operation-not-supported-in-this-environment",POPUP_BLOCKED:"auth/popup-blocked",POPUP_CLOSED_BY_USER:"auth/popup-closed-by-user",PROVIDER_ALREADY_LINKED:"auth/provider-already-linked",QUOTA_EXCEEDED:"auth/quota-exceeded",REDIRECT_CANCELLED_BY_USER:"auth/redirect-cancelled-by-user",REDIRECT_OPERATION_PENDING:"auth/redirect-operation-pending",REJECTED_CREDENTIAL:"auth/rejected-credential",SECOND_FACTOR_ALREADY_ENROLLED:"auth/second-factor-already-in-use",SECOND_FACTOR_LIMIT_EXCEEDED:"auth/maximum-second-factor-count-exceeded",TENANT_ID_MISMATCH:"auth/tenant-id-mismatch",TIMEOUT:"auth/timeout",TOKEN_EXPIRED:"auth/user-token-expired",TOO_MANY_ATTEMPTS_TRY_LATER:"auth/too-many-requests",UNAUTHORIZED_DOMAIN:"auth/unauthorized-continue-uri",UNSUPPORTED_FIRST_FACTOR:"auth/unsupported-first-factor",UNSUPPORTED_PERSISTENCE:"auth/unsupported-persistence-type",UNSUPPORTED_TENANT_OPERATION:"auth/unsupported-tenant-operation",UNVERIFIED_EMAIL:"auth/unverified-email",USER_CANCELLED:"auth/user-cancelled",USER_DELETED:"auth/user-not-found",USER_DISABLED:"auth/user-disabled",USER_MISMATCH:"auth/user-mismatch",USER_SIGNED_OUT:"auth/user-signed-out",WEAK_PASSWORD:"auth/weak-password",WEB_STORAGE_UNSUPPORTED:"auth/web-storage-unsupported",ALREADY_INITIALIZED:"auth/already-initialized"},y=new o.Yd("@firebase/auth");function v(t,...e){y.logLevel<=o.in.ERROR&&y.error(`Auth (${i.Jn}): ${t}`,...e)}function b(t,...e){throw _(t,...e)}function w(t,...e){return _(t,...e)}function I(t,e,n){const i=Object.assign(Object.assign({},p()),{[e]:n});return new r.LL("auth","Firebase",i).create(e,{appName:t.name})}function T(t,e,n){if(!(e instanceof n))throw n.name!==e.constructor.name&&b(t,"argument-error"),I(t,"argument-error",`Type of ${e.constructor.name} does not match expected instance.Did you pass a reference from a different Auth SDK?`)}function _(t,...e){if("string"!=typeof t){const n=e[0],r=[...e.slice(1)];return r[0]&&(r[0].appName=t.name),t._errorFactory.create(n,...r)}return m.create(t,...e)}function E(t,e,...n){if(!t)throw _(e,...n)}function S(t){const e="INTERNAL ASSERTION FAILED: "+t;throw v(e),new Error(e)}function k(t,e){t||S(e)}const A=new Map;function N(t){k(t instanceof Function,"Expected a class definition");let e=A.get(t);return e?(k(e instanceof t,"Instance stored in cache mismatched with class"),e):(e=new t,A.set(t,e),e)}function x(t,e){const n=(0,i.qX)(t,"auth");if(n.isInitialized()){const t=n.getImmediate(),i=n.getOptions();if((0,r.vZ)(i,null!=e?e:{}))return t;b(t,"already-initialized")}return n.initialize({options:e})}function C(){var t;return"undefined"!=typeof self&&(null===(t=self.location)||void 0===t?void 0:t.href)||""}function D(){return"http:"===O()||"https:"===O()}function O(){var t;return"undefined"!=typeof self&&(null===(t=self.location)||void 0===t?void 0:t.protocol)||null}class R{constructor(t,e){this.shortDelay=t,this.longDelay=e,k(e>t,"Short delay should be less than long delay!"),this.isMobile=(0,r.uI)()||(0,r.b$)()}get(){return"undefined"!=typeof navigator&&navigator&&"onLine"in navigator&&"boolean"==typeof navigator.onLine&&(D()||(0,r.ru)()||"connection"in navigator)&&!navigator.onLine?Math.min(5e3,this.shortDelay):this.isMobile?this.longDelay:this.shortDelay}}function P(t,e){k(t.emulator,"Emulator should always be set here");const{url:n}=t.emulator;return e?`${n}${e.startsWith("/")?e.slice(1):e}`:n}class L{static initialize(t,e,n){this.fetchImpl=t,e&&(this.headersImpl=e),n&&(this.responseImpl=n)}static fetch(){return this.fetchImpl?this.fetchImpl:"undefined"!=typeof self&&"fetch"in self?self.fetch:void S("Could not find fetch implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static headers(){return this.headersImpl?this.headersImpl:"undefined"!=typeof self&&"Headers"in self?self.Headers:void S("Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static response(){return this.responseImpl?this.responseImpl:"undefined"!=typeof self&&"Response"in self?self.Response:void S("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}}const M={CREDENTIAL_MISMATCH:"custom-token-mismatch",MISSING_CUSTOM_TOKEN:"internal-error",INVALID_IDENTIFIER:"invalid-email",MISSING_CONTINUE_URI:"internal-error",INVALID_PASSWORD:"wrong-password",MISSING_PASSWORD:"internal-error",EMAIL_EXISTS:"email-already-in-use",PASSWORD_LOGIN_DISABLED:"operation-not-allowed",INVALID_IDP_RESPONSE:"invalid-credential",INVALID_PENDING_TOKEN:"invalid-credential",FEDERATED_USER_ID_ALREADY_LINKED:"credential-already-in-use",MISSING_REQ_TYPE:"internal-error",EMAIL_NOT_FOUND:"user-not-found",RESET_PASSWORD_EXCEED_LIMIT:"too-many-requests",EXPIRED_OOB_CODE:"expired-action-code",INVALID_OOB_CODE:"invalid-action-code",MISSING_OOB_CODE:"internal-error",CREDENTIAL_TOO_OLD_LOGIN_AGAIN:"requires-recent-login",INVALID_ID_TOKEN:"invalid-user-token",TOKEN_EXPIRED:"user-token-expired",USER_NOT_FOUND:"user-token-expired",TOO_MANY_ATTEMPTS_TRY_LATER:"too-many-requests",INVALID_CODE:"invalid-verification-code",INVALID_SESSION_INFO:"invalid-verification-id",INVALID_TEMPORARY_PROOF:"invalid-credential",MISSING_SESSION_INFO:"missing-verification-id",SESSION_EXPIRED:"code-expired",MISSING_ANDROID_PACKAGE_NAME:"missing-android-pkg-name",UNAUTHORIZED_DOMAIN:"unauthorized-continue-uri",INVALID_OAUTH_CLIENT_ID:"invalid-oauth-client-id",ADMIN_ONLY_OPERATION:"admin-restricted-operation",INVALID_MFA_PENDING_CREDENTIAL:"invalid-multi-factor-session",MFA_ENROLLMENT_NOT_FOUND:"multi-factor-info-not-found",MISSING_MFA_ENROLLMENT_ID:"missing-multi-factor-info",MISSING_MFA_PENDING_CREDENTIAL:"missing-multi-factor-session",SECOND_FACTOR_EXISTS:"second-factor-already-in-use",SECOND_FACTOR_LIMIT_EXCEEDED:"maximum-second-factor-count-exceeded",BLOCKING_FUNCTION_ERROR_RESPONSE:"internal-error"},F=new R(3e4,6e4);function U(t,e){return t.tenantId&&!e.tenantId?Object.assign(Object.assign({},e),{tenantId:t.tenantId}):e}async function V(t,e,n,i,s={}){return j(t,s,(async()=>{let s={},o={};i&&("GET"===e?o=i:s={body:JSON.stringify(i)});const a=(0,r.xO)(Object.assign({key:t.config.apiKey},o)).slice(1),c=await t._getAdditionalHeaders();return c["Content-Type"]="application/json",t.languageCode&&(c["X-Firebase-Locale"]=t.languageCode),L.fetch()(B(t,t.config.apiHost,n,a),Object.assign({method:e,headers:c,referrerPolicy:"no-referrer"},s))}))}async function j(t,e,n){t._canInitEmulator=!1;const i=Object.assign(Object.assign({},M),e);try{const e=new z(t),r=await Promise.race([n(),e.promise]);e.clearNetworkTimeout();const s=await r.json();if("needConfirmation"in s)throw K(t,"account-exists-with-different-credential",s);if(r.ok&&!("errorMessage"in s))return s;{const e=r.ok?s.errorMessage:s.error.message,[n,o]=e.split(" : ");if("FEDERATED_USER_ID_ALREADY_LINKED"===n)throw K(t,"credential-already-in-use",s);if("EMAIL_EXISTS"===n)throw K(t,"email-already-in-use",s);const a=i[n]||n.toLowerCase().replace(/[_\s]+/g,"-");if(o)throw I(t,a,o);b(t,a)}}catch(e){if(e instanceof r.ZR)throw e;b(t,"network-request-failed")}}async function q(t,e,n,r,i={}){const s=await V(t,e,n,r,i);return"mfaPendingCredential"in s&&b(t,"multi-factor-auth-required",{_serverResponse:s}),s}function B(t,e,n,r){const i=`${e}${n}?${r}`;return t.config.emulator?P(t.config,i):`${t.config.apiScheme}://${i}`}class z{constructor(t){this.auth=t,this.timer=null,this.promise=new Promise(((t,e)=>{this.timer=setTimeout((()=>e(w(this.auth,"timeout"))),F.get())}))}clearNetworkTimeout(){clearTimeout(this.timer)}}function K(t,e,n){const r={appName:t.name};n.email&&(r.email=n.email),n.phoneNumber&&(r.phoneNumber=n.phoneNumber);const i=w(t,e,r);return i.customData._tokenResponse=n,i}function W(t){if(t)try{const e=new Date(Number(t));if(!isNaN(e.getTime()))return e.toUTCString()}catch(t){}}function G(t,e=!1){return(0,r.m9)(t).getIdToken(e)}async function H(t,e=!1){const n=(0,r.m9)(t),i=await n.getIdToken(e),s=Y(i);E(s&&s.exp&&s.auth_time&&s.iat,n.auth,"internal-error");const o="object"==typeof s.firebase?s.firebase:void 0,a=null==o?void 0:o.sign_in_provider;return{claims:s,token:i,authTime:W($(s.auth_time)),issuedAtTime:W($(s.iat)),expirationTime:W($(s.exp)),signInProvider:a||null,signInSecondFactor:(null==o?void 0:o.sign_in_second_factor)||null}}function $(t){return 1e3*Number(t)}function Y(t){const[e,n,i]=t.split(".");if(void 0===e||void 0===n||void 0===i)return v("JWT malformed, contained fewer than 3 sections"),null;try{const t=(0,r.tV)(n);return t?JSON.parse(t):(v("Failed to decode base64 JWT payload"),null)}catch(t){return v("Caught error parsing JWT payload as JSON",t),null}}async function Q(t,e,n=!1){if(n)return e;try{return await e}catch(e){throw e instanceof r.ZR&&function({code:t}){return"auth/user-disabled"===t||"auth/user-token-expired"===t}(e)&&t.auth.currentUser===t&&await t.auth.signOut(),e}}class J{constructor(t){this.user=t,this.isRunning=!1,this.timerId=null,this.errorBackoff=3e4}_start(){this.isRunning||(this.isRunning=!0,this.schedule())}_stop(){this.isRunning&&(this.isRunning=!1,null!==this.timerId&&clearTimeout(this.timerId))}getInterval(t){var e;if(t){const t=this.errorBackoff;return this.errorBackoff=Math.min(2*this.errorBackoff,96e4),t}{this.errorBackoff=3e4;const t=(null!==(e=this.user.stsTokenManager.expirationTime)&&void 0!==e?e:0)-Date.now()-3e5;return Math.max(0,t)}}schedule(t=!1){if(!this.isRunning)return;const e=this.getInterval(t);this.timerId=setTimeout((async()=>{await this.iteration()}),e)}async iteration(){try{await this.user.getIdToken(!0)}catch(t){return void("auth/network-request-failed"===t.code&&this.schedule(!0))}this.schedule()}}class Z{constructor(t,e){this.createdAt=t,this.lastLoginAt=e,this._initializeTime()}_initializeTime(){this.lastSignInTime=W(this.lastLoginAt),this.creationTime=W(this.createdAt)}_copy(t){this.createdAt=t.createdAt,this.lastLoginAt=t.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}async function X(t){var e;const n=t.auth,r=await t.getIdToken(),i=await Q(t,async function(t,e){return V(t,"POST","/v1/accounts:lookup",e)}(n,{idToken:r}));E(null==i?void 0:i.users.length,n,"internal-error");const o=i.users[0];t._notifyReloadListener(o);const a=(null===(e=o.providerUserInfo)||void 0===e?void 0:e.length)?o.providerUserInfo.map((t=>{var{providerId:e}=t,n=s(t,["providerId"]);return{providerId:e,uid:n.rawId||"",displayName:n.displayName||null,email:n.email||null,phoneNumber:n.phoneNumber||null,photoURL:n.photoUrl||null}})):[],c=(u=t.providerData,h=a,[...u.filter((t=>!h.some((e=>e.providerId===t.providerId)))),...h]);var u,h;const l=t.isAnonymous,d=!(t.email&&o.passwordHash||(null==c?void 0:c.length)),f=!!l&&d,p={uid:o.localId,displayName:o.displayName||null,photoURL:o.photoUrl||null,email:o.email||null,emailVerified:o.emailVerified||!1,phoneNumber:o.phoneNumber||null,tenantId:o.tenantId||null,providerData:c,metadata:new Z(o.createdAt,o.lastLoginAt),isAnonymous:f};Object.assign(t,p)}async function tt(t){const e=(0,r.m9)(t);await X(e),await e.auth._persistUserIfCurrent(e),e.auth._notifyListenersIfCurrent(e)}class et{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(t){E(t.idToken,"internal-error"),E(void 0!==t.idToken,"internal-error"),E(void 0!==t.refreshToken,"internal-error");const e="expiresIn"in t&&void 0!==t.expiresIn?Number(t.expiresIn):function(t){const e=Y(t);return E(e,"internal-error"),E(void 0!==e.exp,"internal-error"),E(void 0!==e.iat,"internal-error"),Number(e.exp)-Number(e.iat)}(t.idToken);this.updateTokensAndExpiration(t.idToken,t.refreshToken,e)}async getToken(t,e=!1){return E(!this.accessToken||this.refreshToken,t,"user-token-expired"),e||!this.accessToken||this.isExpired?this.refreshToken?(await this.refresh(t,this.refreshToken),this.accessToken):null:this.accessToken}clearRefreshToken(){this.refreshToken=null}async refresh(t,e){const{accessToken:n,refreshToken:i,expiresIn:s}=await async function(t,e){const n=await j(t,{},(async()=>{const n=(0,r.xO)({grant_type:"refresh_token",refresh_token:e}).slice(1),{tokenApiHost:i,apiKey:s}=t.config,o=B(t,i,"/v1/token",`key=${s}`),a=await t._getAdditionalHeaders();return a["Content-Type"]="application/x-www-form-urlencoded",L.fetch()(o,{method:"POST",headers:a,body:n})}));return{accessToken:n.access_token,expiresIn:n.expires_in,refreshToken:n.refresh_token}}(t,e);this.updateTokensAndExpiration(n,i,Number(s))}updateTokensAndExpiration(t,e,n){this.refreshToken=e||null,this.accessToken=t||null,this.expirationTime=Date.now()+1e3*n}static fromJSON(t,e){const{refreshToken:n,accessToken:r,expirationTime:i}=e,s=new et;return n&&(E("string"==typeof n,"internal-error",{appName:t}),s.refreshToken=n),r&&(E("string"==typeof r,"internal-error",{appName:t}),s.accessToken=r),i&&(E("number"==typeof i,"internal-error",{appName:t}),s.expirationTime=i),s}toJSON(){return{refreshToken:this.refreshToken,accessToken:this.accessToken,expirationTime:this.expirationTime}}_assign(t){this.accessToken=t.accessToken,this.refreshToken=t.refreshToken,this.expirationTime=t.expirationTime}_clone(){return Object.assign(new et,this.toJSON())}_performRefresh(){return S("not implemented")}}function nt(t,e){E("string"==typeof t||void 0===t,"internal-error",{appName:e})}class rt{constructor(t){var{uid:e,auth:n,stsTokenManager:r}=t,i=s(t,["uid","auth","stsTokenManager"]);this.providerId="firebase",this.emailVerified=!1,this.isAnonymous=!1,this.tenantId=null,this.providerData=[],this.proactiveRefresh=new J(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=e,this.auth=n,this.stsTokenManager=r,this.accessToken=r.accessToken,this.displayName=i.displayName||null,this.email=i.email||null,this.emailVerified=i.emailVerified||!1,this.phoneNumber=i.phoneNumber||null,this.photoURL=i.photoURL||null,this.isAnonymous=i.isAnonymous||!1,this.tenantId=i.tenantId||null,this.metadata=new Z(i.createdAt||void 0,i.lastLoginAt||void 0)}async getIdToken(t){const e=await Q(this,this.stsTokenManager.getToken(this.auth,t));return E(e,this.auth,"internal-error"),this.accessToken!==e&&(this.accessToken=e,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),e}getIdTokenResult(t){return H(this,t)}reload(){return tt(this)}_assign(t){this!==t&&(E(this.uid===t.uid,this.auth,"internal-error"),this.displayName=t.displayName,this.photoURL=t.photoURL,this.email=t.email,this.emailVerified=t.emailVerified,this.phoneNumber=t.phoneNumber,this.isAnonymous=t.isAnonymous,this.tenantId=t.tenantId,this.providerData=t.providerData.map((t=>Object.assign({},t))),this.metadata._copy(t.metadata),this.stsTokenManager._assign(t.stsTokenManager))}_clone(t){return new rt(Object.assign(Object.assign({},this),{auth:t,stsTokenManager:this.stsTokenManager._clone()}))}_onReload(t){E(!this.reloadListener,this.auth,"internal-error"),this.reloadListener=t,this.reloadUserInfo&&(this._notifyReloadListener(this.reloadUserInfo),this.reloadUserInfo=null)}_notifyReloadListener(t){this.reloadListener?this.reloadListener(t):this.reloadUserInfo=t}_startProactiveRefresh(){this.proactiveRefresh._start()}_stopProactiveRefresh(){this.proactiveRefresh._stop()}async _updateTokensIfNecessary(t,e=!1){let n=!1;t.idToken&&t.idToken!==this.stsTokenManager.accessToken&&(this.stsTokenManager.updateFromServerResponse(t),n=!0),e&&await X(this),await this.auth._persistUserIfCurrent(this),n&&this.auth._notifyListenersIfCurrent(this)}async delete(){const t=await this.getIdToken();return await Q(this,async function(t,e){return V(t,"POST","/v1/accounts:delete",e)}(this.auth,{idToken:t})),this.stsTokenManager.clearRefreshToken(),this.auth.signOut()}toJSON(){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((t=>Object.assign({},t))),stsTokenManager:this.stsTokenManager.toJSON(),_redirectEventId:this._redirectEventId},this.metadata.toJSON()),{apiKey:this.auth.config.apiKey,appName:this.auth.name})}get refreshToken(){return this.stsTokenManager.refreshToken||""}static _fromJSON(t,e){var n,r,i,s,o,a,c,u;const h=null!==(n=e.displayName)&&void 0!==n?n:void 0,l=null!==(r=e.email)&&void 0!==r?r:void 0,d=null!==(i=e.phoneNumber)&&void 0!==i?i:void 0,f=null!==(s=e.photoURL)&&void 0!==s?s:void 0,p=null!==(o=e.tenantId)&&void 0!==o?o:void 0,m=null!==(a=e._redirectEventId)&&void 0!==a?a:void 0,g=null!==(c=e.createdAt)&&void 0!==c?c:void 0,y=null!==(u=e.lastLoginAt)&&void 0!==u?u:void 0,{uid:v,emailVerified:b,isAnonymous:w,providerData:I,stsTokenManager:T}=e;E(v&&T,t,"internal-error");const _=et.fromJSON(this.name,T);E("string"==typeof v,t,"internal-error"),nt(h,t.name),nt(l,t.name),E("boolean"==typeof b,t,"internal-error"),E("boolean"==typeof w,t,"internal-error"),nt(d,t.name),nt(f,t.name),nt(p,t.name),nt(m,t.name),nt(g,t.name),nt(y,t.name);const S=new rt({uid:v,auth:t,email:l,emailVerified:b,displayName:h,isAnonymous:w,photoURL:f,phoneNumber:d,tenantId:p,stsTokenManager:_,createdAt:g,lastLoginAt:y});return I&&Array.isArray(I)&&(S.providerData=I.map((t=>Object.assign({},t)))),m&&(S._redirectEventId=m),S}static async _fromIdTokenResponse(t,e,n=!1){const r=new et;r.updateFromServerResponse(e);const i=new rt({uid:e.localId,auth:t,stsTokenManager:r,isAnonymous:n});return await X(i),i}}class it{constructor(){this.type="NONE",this.storage={}}async _isAvailable(){return!0}async _set(t,e){this.storage[t]=e}async _get(t){const e=this.storage[t];return void 0===e?null:e}async _remove(t){delete this.storage[t]}_addListener(t,e){}_removeListener(t,e){}}it.type="NONE";const st=it;function ot(t,e,n){return`firebase:${t}:${e}:${n}`}class at{constructor(t,e,n){this.persistence=t,this.auth=e,this.userKey=n;const{config:r,name:i}=this.auth;this.fullUserKey=ot(this.userKey,r.apiKey,i),this.fullPersistenceKey=ot("persistence",r.apiKey,i),this.boundEventHandler=e._onStorageEvent.bind(e),this.persistence._addListener(this.fullUserKey,this.boundEventHandler)}setCurrentUser(t){return this.persistence._set(this.fullUserKey,t.toJSON())}async getCurrentUser(){const t=await this.persistence._get(this.fullUserKey);return t?rt._fromJSON(this.auth,t):null}removeCurrentUser(){return this.persistence._remove(this.fullUserKey)}savePersistenceForRedirect(){return this.persistence._set(this.fullPersistenceKey,this.persistence.type)}async setPersistence(t){if(this.persistence===t)return;const e=await this.getCurrentUser();return await this.removeCurrentUser(),this.persistence=t,e?this.setCurrentUser(e):void 0}delete(){this.persistence._removeListener(this.fullUserKey,this.boundEventHandler)}static async create(t,e,n="authUser"){if(!e.length)return new at(N(st),t,n);const r=(await Promise.all(e.map((async t=>{if(await t._isAvailable())return t})))).filter((t=>t));let i=r[0]||N(st);const s=ot(n,t.config.apiKey,t.name);let o=null;for(const n of e)try{const e=await n._get(s);if(e){const r=rt._fromJSON(t,e);n!==i&&(o=r),i=n;break}}catch(t){}const a=r.filter((t=>t._shouldAllowMigration));return i._shouldAllowMigration&&a.length?(i=a[0],o&&await i._set(s,o.toJSON()),await Promise.all(e.map((async t=>{if(t!==i)try{await t._remove(s)}catch(t){}}))),new at(i,t,n)):new at(i,t,n)}}function ct(t){const e=t.toLowerCase();if(e.includes("opera/")||e.includes("opr/")||e.includes("opios/"))return"Opera";if(dt(e))return"IEMobile";if(e.includes("msie")||e.includes("trident/"))return"IE";if(e.includes("edge/"))return"Edge";if(ut(e))return"Firefox";if(e.includes("silk/"))return"Silk";if(pt(e))return"Blackberry";if(mt(e))return"Webos";if(ht(e))return"Safari";if((e.includes("chrome/")||lt(e))&&!e.includes("edge/"))return"Chrome";if(ft(e))return"Android";{const e=/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/,n=t.match(e);if(2===(null==n?void 0:n.length))return n[1]}return"Other"}function ut(t=(0,r.z$)()){return/firefox\//i.test(t)}function ht(t=(0,r.z$)()){const e=t.toLowerCase();return e.includes("safari/")&&!e.includes("chrome/")&&!e.includes("crios/")&&!e.includes("android")}function lt(t=(0,r.z$)()){return/crios\//i.test(t)}function dt(t=(0,r.z$)()){return/iemobile/i.test(t)}function ft(t=(0,r.z$)()){return/android/i.test(t)}function pt(t=(0,r.z$)()){return/blackberry/i.test(t)}function mt(t=(0,r.z$)()){return/webos/i.test(t)}function gt(t=(0,r.z$)()){return/iphone|ipad|ipod/i.test(t)}function yt(t=(0,r.z$)()){return gt(t)||ft(t)||mt(t)||pt(t)||/windows phone/i.test(t)||dt(t)}function vt(t,e=[]){let n;switch(t){case"Browser":n=ct((0,r.z$)());break;case"Worker":n=`${ct((0,r.z$)())}-${t}`;break;default:n=t}const s=e.length?e.join(","):"FirebaseCore-web";return`${n}/JsCore/${i.Jn}/${s}`}class bt{constructor(t,e){this.app=t,this.config=e,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new It(this),this.idTokenSubscription=new It(this),this.redirectUser=null,this.isProactiveRefreshEnabled=!1,this._canInitEmulator=!0,this._isInitialized=!1,this._deleted=!1,this._initializationPromise=null,this._popupRedirectResolver=null,this._errorFactory=m,this.lastNotifiedUid=void 0,this.languageCode=null,this.tenantId=null,this.settings={appVerificationDisabledForTesting:!1},this.frameworks=[],this.name=t.name,this.clientVersion=e.sdkClientVersion}_initializeWithPersistence(t,e){return e&&(this._popupRedirectResolver=N(e)),this._initializationPromise=this.queue((async()=>{var n,r;if(!this._deleted&&(this.persistenceManager=await at.create(this,t),!this._deleted)){if(null===(n=this._popupRedirectResolver)||void 0===n?void 0:n._shouldInitProactively)try{await this._popupRedirectResolver._initialize(this)}catch(t){}await this.initializeCurrentUser(e),this.lastNotifiedUid=(null===(r=this.currentUser)||void 0===r?void 0:r.uid)||null,this._deleted||(this._isInitialized=!0)}})),this._initializationPromise}async _onStorageEvent(){if(this._deleted)return;const t=await this.assertedPersistence.getCurrentUser();return this.currentUser||t?this.currentUser&&t&&this.currentUser.uid===t.uid?(this._currentUser._assign(t),void await this.currentUser.getIdToken()):void await this._updateCurrentUser(t):void 0}async initializeCurrentUser(t){var e;let n=await this.assertedPersistence.getCurrentUser();if(t&&this.config.authDomain){await this.getOrInitRedirectPersistenceManager();const r=null===(e=this.redirectUser)||void 0===e?void 0:e._redirectEventId,i=null==n?void 0:n._redirectEventId,s=await this.tryRedirectSignIn(t);r&&r!==i||!(null==s?void 0:s.user)||(n=s.user)}return n?n._redirectEventId?(E(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===n._redirectEventId?this.directlySetCurrentUser(n):this.reloadAndSetCurrentUserOrClear(n)):this.reloadAndSetCurrentUserOrClear(n):this.directlySetCurrentUser(null)}async tryRedirectSignIn(t){let e=null;try{e=await this._popupRedirectResolver._completeRedirectFn(this,t,!0)}catch(t){await this._setRedirectUser(null)}return e}async reloadAndSetCurrentUserOrClear(t){try{await X(t)}catch(t){if("auth/network-request-failed"!==t.code)return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(t)}useDeviceLanguage(){this.languageCode=function(){if("undefined"==typeof navigator)return null;const t=navigator;return t.languages&&t.languages[0]||t.language||null}()}async _delete(){this._deleted=!0}async updateCurrentUser(t){const e=t?(0,r.m9)(t):null;return e&&E(e.auth.config.apiKey===this.config.apiKey,this,"invalid-user-token"),this._updateCurrentUser(e&&e._clone(this))}async _updateCurrentUser(t){if(!this._deleted)return t&&E(this.tenantId===t.tenantId,this,"tenant-id-mismatch"),this.queue((async()=>{await this.directlySetCurrentUser(t),this.notifyAuthListeners()}))}async signOut(){return(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null)}setPersistence(t){return this.queue((async()=>{await this.assertedPersistence.setPersistence(N(t))}))}_getPersistence(){return this.assertedPersistence.persistence.type}_updateErrorMap(t){this._errorFactory=new r.LL("auth","Firebase",t())}onAuthStateChanged(t,e,n){return this.registerStateListener(this.authStateSubscription,t,e,n)}onIdTokenChanged(t,e,n){return this.registerStateListener(this.idTokenSubscription,t,e,n)}toJSON(){var t;return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:null===(t=this._currentUser)||void 0===t?void 0:t.toJSON()}}async _setRedirectUser(t,e){const n=await this.getOrInitRedirectPersistenceManager(e);return null===t?n.removeCurrentUser():n.setCurrentUser(t)}async getOrInitRedirectPersistenceManager(t){if(!this.redirectPersistenceManager){const e=t&&N(t)||this._popupRedirectResolver;E(e,this,"argument-error"),this.redirectPersistenceManager=await at.create(this,[N(e._redirectPersistence)],"redirectUser"),this.redirectUser=await this.redirectPersistenceManager.getCurrentUser()}return this.redirectPersistenceManager}async _redirectUserForId(t){var e,n;return this._isInitialized&&await this.queue((async()=>{})),(null===(e=this._currentUser)||void 0===e?void 0:e._redirectEventId)===t?this._currentUser:(null===(n=this.redirectUser)||void 0===n?void 0:n._redirectEventId)===t?this.redirectUser:null}async _persistUserIfCurrent(t){if(t===this.currentUser)return this.queue((async()=>this.directlySetCurrentUser(t)))}_notifyListenersIfCurrent(t){t===this.currentUser&&this.notifyAuthListeners()}_key(){return`${this.config.authDomain}:${this.config.apiKey}:${this.name}`}_startProactiveRefresh(){this.isProactiveRefreshEnabled=!0,this.currentUser&&this._currentUser._startProactiveRefresh()}_stopProactiveRefresh(){this.isProactiveRefreshEnabled=!1,this.currentUser&&this._currentUser._stopProactiveRefresh()}get _currentUser(){return this.currentUser}notifyAuthListeners(){var t,e;if(!this._isInitialized)return;this.idTokenSubscription.next(this.currentUser);const n=null!==(e=null===(t=this.currentUser)||void 0===t?void 0:t.uid)&&void 0!==e?e:null;this.lastNotifiedUid!==n&&(this.lastNotifiedUid=n,this.authStateSubscription.next(this.currentUser))}registerStateListener(t,e,n,r){if(this._deleted)return()=>{};const i="function"==typeof e?e:e.next.bind(e),s=this._isInitialized?Promise.resolve():this._initializationPromise;return E(s,this,"internal-error"),s.then((()=>i(this.currentUser))),"function"==typeof e?t.addObserver(e,n,r):t.addObserver(e)}async directlySetCurrentUser(t){this.currentUser&&this.currentUser!==t&&(this._currentUser._stopProactiveRefresh(),t&&this.isProactiveRefreshEnabled&&t._startProactiveRefresh()),this.currentUser=t,t?await this.assertedPersistence.setCurrentUser(t):await this.assertedPersistence.removeCurrentUser()}queue(t){return this.operations=this.operations.then(t,t),this.operations}get assertedPersistence(){return E(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(t){t&&!this.frameworks.includes(t)&&(this.frameworks.push(t),this.frameworks.sort(),this.clientVersion=vt(this.config.clientPlatform,this._getFrameworks()))}_getFrameworks(){return this.frameworks}async _getAdditionalHeaders(){const t={"X-Client-Version":this.clientVersion};return this.app.options.appId&&(t["X-Firebase-gmpid"]=this.app.options.appId),t}}function wt(t){return(0,r.m9)(t)}class It{constructor(t){this.auth=t,this.observer=null,this.addObserver=(0,r.ne)((t=>this.observer=t))}get next(){return E(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}function Tt(t,e,n){const r=wt(t);E(r._canInitEmulator,r,"emulator-config-failed"),E(/^https?:\/\//.test(e),r,"invalid-emulator-scheme");const i=!!(null==n?void 0:n.disableWarnings),s=_t(e),{host:o,port:a}=function(t){const e=_t(t),n=/(\/\/)?([^?#/]+)/.exec(t.substr(e.length));if(!n)return{host:"",port:null};const r=n[2].split("@").pop()||"",i=/^(\[[^\]]+\])(:|$)/.exec(r);if(i){const t=i[1];return{host:t,port:Et(r.substr(t.length+1))}}{const[t,e]=r.split(":");return{host:t,port:Et(e)}}}(e),c=null===a?"":`:${a}`;r.config.emulator={url:`${s}//${o}${c}/`},r.settings.appVerificationDisabledForTesting=!0,r.emulatorConfig=Object.freeze({host:o,port:a,protocol:s.replace(":",""),options:Object.freeze({disableWarnings:i})}),i||function(){function t(){const t=document.createElement("p"),e=t.style;t.innerText="Running in emulator mode. Do not use with production credentials.",e.position="fixed",e.width="100%",e.backgroundColor="#ffffff",e.border=".1em solid #000000",e.color="#b50000",e.bottom="0px",e.left="0px",e.margin="0px",e.zIndex="10000",e.textAlign="center",t.classList.add("firebase-emulator-warning"),document.body.appendChild(t)}"undefined"!=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."),"undefined"!=typeof window&&"undefined"!=typeof document&&("loading"===document.readyState?window.addEventListener("DOMContentLoaded",t):t())}()}function _t(t){const e=t.indexOf(":");return e<0?"":t.substr(0,e+1)}function Et(t){if(!t)return null;const e=Number(t);return isNaN(e)?null:e}class St{constructor(t,e){this.providerId=t,this.signInMethod=e}toJSON(){return S("not implemented")}_getIdTokenResponse(t){return S("not implemented")}_linkToIdToken(t,e){return S("not implemented")}_getReauthenticationResolver(t){return S("not implemented")}}async function kt(t,e){return V(t,"POST","/v1/accounts:resetPassword",U(t,e))}async function At(t,e){return V(t,"POST","/v1/accounts:update",e)}async function Nt(t,e){return V(t,"POST","/v1/accounts:sendOobCode",U(t,e))}class xt extends St{constructor(t,e,n,r=null){super("password",n),this._email=t,this._password=e,this._tenantId=r}static _fromEmailAndPassword(t,e){return new xt(t,e,"password")}static _fromEmailAndCode(t,e,n=null){return new xt(t,e,"emailLink",n)}toJSON(){return{email:this._email,password:this._password,signInMethod:this.signInMethod,tenantId:this._tenantId}}static fromJSON(t){const e="string"==typeof t?JSON.parse(t):t;if((null==e?void 0:e.email)&&(null==e?void 0:e.password)){if("password"===e.signInMethod)return this._fromEmailAndPassword(e.email,e.password);if("emailLink"===e.signInMethod)return this._fromEmailAndCode(e.email,e.password,e.tenantId)}return null}async _getIdTokenResponse(t){switch(this.signInMethod){case"password":return async function(t,e){return q(t,"POST","/v1/accounts:signInWithPassword",U(t,e))}(t,{returnSecureToken:!0,email:this._email,password:this._password});case"emailLink":return async function(t,e){return q(t,"POST","/v1/accounts:signInWithEmailLink",U(t,e))}(t,{email:this._email,oobCode:this._password});default:b(t,"internal-error")}}async _linkToIdToken(t,e){switch(this.signInMethod){case"password":return At(t,{idToken:e,returnSecureToken:!0,email:this._email,password:this._password});case"emailLink":return async function(t,e){return q(t,"POST","/v1/accounts:signInWithEmailLink",U(t,e))}(t,{idToken:e,email:this._email,oobCode:this._password});default:b(t,"internal-error")}}_getReauthenticationResolver(t){return this._getIdTokenResponse(t)}}async function Ct(t,e){return q(t,"POST","/v1/accounts:signInWithIdp",U(t,e))}class Dt extends St{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(t){const e=new Dt(t.providerId,t.signInMethod);return t.idToken||t.accessToken?(t.idToken&&(e.idToken=t.idToken),t.accessToken&&(e.accessToken=t.accessToken),t.nonce&&!t.pendingToken&&(e.nonce=t.nonce),t.pendingToken&&(e.pendingToken=t.pendingToken)):t.oauthToken&&t.oauthTokenSecret?(e.accessToken=t.oauthToken,e.secret=t.oauthTokenSecret):b("argument-error"),e}toJSON(){return{idToken:this.idToken,accessToken:this.accessToken,secret:this.secret,nonce:this.nonce,pendingToken:this.pendingToken,providerId:this.providerId,signInMethod:this.signInMethod}}static fromJSON(t){const e="string"==typeof t?JSON.parse(t):t,{providerId:n,signInMethod:r}=e,i=s(e,["providerId","signInMethod"]);if(!n||!r)return null;const o=new Dt(n,r);return o.idToken=i.idToken||void 0,o.accessToken=i.accessToken||void 0,o.secret=i.secret,o.nonce=i.nonce,o.pendingToken=i.pendingToken||null,o}_getIdTokenResponse(t){return Ct(t,this.buildRequest())}_linkToIdToken(t,e){const n=this.buildRequest();return n.idToken=e,Ct(t,n)}_getReauthenticationResolver(t){const e=this.buildRequest();return e.autoCreate=!1,Ct(t,e)}buildRequest(){const t={requestUri:"http://localhost",returnSecureToken:!0};if(this.pendingToken)t.pendingToken=this.pendingToken;else{const e={};this.idToken&&(e.id_token=this.idToken),this.accessToken&&(e.access_token=this.accessToken),this.secret&&(e.oauth_token_secret=this.secret),e.providerId=this.providerId,this.nonce&&!this.pendingToken&&(e.nonce=this.nonce),t.postBody=(0,r.xO)(e)}return t}}const Ot={USER_NOT_FOUND:"user-not-found"};class Rt extends St{constructor(t){super("phone","phone"),this.params=t}static _fromVerification(t,e){return new Rt({verificationId:t,verificationCode:e})}static _fromTokenResponse(t,e){return new Rt({phoneNumber:t,temporaryProof:e})}_getIdTokenResponse(t){return async function(t,e){return q(t,"POST","/v1/accounts:signInWithPhoneNumber",U(t,e))}(t,this._makeVerificationRequest())}_linkToIdToken(t,e){return async function(t,e){const n=await q(t,"POST","/v1/accounts:signInWithPhoneNumber",U(t,e));if(n.temporaryProof)throw K(t,"account-exists-with-different-credential",n);return n}(t,Object.assign({idToken:e},this._makeVerificationRequest()))}_getReauthenticationResolver(t){return async function(t,e){return q(t,"POST","/v1/accounts:signInWithPhoneNumber",U(t,Object.assign(Object.assign({},e),{operation:"REAUTH"})),Ot)}(t,this._makeVerificationRequest())}_makeVerificationRequest(){const{temporaryProof:t,phoneNumber:e,verificationId:n,verificationCode:r}=this.params;return t&&e?{temporaryProof:t,phoneNumber:e}:{sessionInfo:n,code:r}}toJSON(){const t={providerId:this.providerId};return this.params.phoneNumber&&(t.phoneNumber=this.params.phoneNumber),this.params.temporaryProof&&(t.temporaryProof=this.params.temporaryProof),this.params.verificationCode&&(t.verificationCode=this.params.verificationCode),this.params.verificationId&&(t.verificationId=this.params.verificationId),t}static fromJSON(t){"string"==typeof t&&(t=JSON.parse(t));const{verificationId:e,verificationCode:n,phoneNumber:r,temporaryProof:i}=t;return n||e||r||i?new Rt({verificationId:e,verificationCode:n,phoneNumber:r,temporaryProof:i}):null}}class Pt{constructor(t){var e,n,i,s,o,a;const c=(0,r.zd)((0,r.pd)(t)),u=null!==(e=c.apiKey)&&void 0!==e?e:null,h=null!==(n=c.oobCode)&&void 0!==n?n:null,l=function(t){switch(t){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=c.mode)&&void 0!==i?i:null);E(u&&h&&l,"argument-error"),this.apiKey=u,this.operation=l,this.code=h,this.continueUrl=null!==(s=c.continueUrl)&&void 0!==s?s:null,this.languageCode=null!==(o=c.languageCode)&&void 0!==o?o:null,this.tenantId=null!==(a=c.tenantId)&&void 0!==a?a:null}static parseLink(t){const e=function(t){const e=(0,r.zd)((0,r.pd)(t)).link,n=e?(0,r.zd)((0,r.pd)(e)).deep_link_id:null,i=(0,r.zd)((0,r.pd)(t)).deep_link_id;return(i?(0,r.zd)((0,r.pd)(i)).link:null)||i||n||e||t}(t);try{return new Pt(e)}catch(t){return null}}}function Lt(t){return Pt.parseLink(t)}class Mt{constructor(){this.providerId=Mt.PROVIDER_ID}static credential(t,e){return xt._fromEmailAndPassword(t,e)}static credentialWithLink(t,e){const n=Pt.parseLink(e);return E(n,"argument-error"),xt._fromEmailAndCode(t,n.code,n.tenantId)}}Mt.PROVIDER_ID="password",Mt.EMAIL_PASSWORD_SIGN_IN_METHOD="password",Mt.EMAIL_LINK_SIGN_IN_METHOD="emailLink";class Ft{constructor(t){this.providerId=t,this.defaultLanguageCode=null,this.customParameters={}}setDefaultLanguage(t){this.defaultLanguageCode=t}setCustomParameters(t){return this.customParameters=t,this}getCustomParameters(){return this.customParameters}}class Ut extends Ft{constructor(){super(...arguments),this.scopes=[]}addScope(t){return this.scopes.includes(t)||this.scopes.push(t),this}getScopes(){return[...this.scopes]}}class Vt extends Ut{static credentialFromJSON(t){const e="string"==typeof t?JSON.parse(t):t;return E("providerId"in e&&"signInMethod"in e,"argument-error"),Dt._fromParams(e)}credential(t){return this._credential(Object.assign(Object.assign({},t),{nonce:t.rawNonce}))}_credential(t){return E(t.idToken||t.accessToken,"argument-error"),Dt._fromParams(Object.assign(Object.assign({},t),{providerId:this.providerId,signInMethod:this.providerId}))}static credentialFromResult(t){return Vt.oauthCredentialFromTaggedObject(t)}static credentialFromError(t){return Vt.oauthCredentialFromTaggedObject(t.customData||{})}static oauthCredentialFromTaggedObject({_tokenResponse:t}){if(!t)return null;const{oauthIdToken:e,oauthAccessToken:n,oauthTokenSecret:r,pendingToken:i,nonce:s,providerId:o}=t;if(!(n||r||e||i))return null;if(!o)return null;try{return new Vt(o)._credential({idToken:e,accessToken:n,nonce:s,pendingToken:i})}catch(t){return null}}}class jt extends Ut{constructor(){super("facebook.com")}static credential(t){return Dt._fromParams({providerId:jt.PROVIDER_ID,signInMethod:jt.FACEBOOK_SIGN_IN_METHOD,accessToken:t})}static credentialFromResult(t){return jt.credentialFromTaggedObject(t)}static credentialFromError(t){return jt.credentialFromTaggedObject(t.customData||{})}static credentialFromTaggedObject({_tokenResponse:t}){if(!t||!("oauthAccessToken"in t))return null;if(!t.oauthAccessToken)return null;try{return jt.credential(t.oauthAccessToken)}catch(t){return null}}}jt.FACEBOOK_SIGN_IN_METHOD="facebook.com",jt.PROVIDER_ID="facebook.com";class qt extends Ut{constructor(){super("google.com"),this.addScope("profile")}static credential(t,e){return Dt._fromParams({providerId:qt.PROVIDER_ID,signInMethod:qt.GOOGLE_SIGN_IN_METHOD,idToken:t,accessToken:e})}static credentialFromResult(t){return qt.credentialFromTaggedObject(t)}static credentialFromError(t){return qt.credentialFromTaggedObject(t.customData||{})}static credentialFromTaggedObject({_tokenResponse:t}){if(!t)return null;const{oauthIdToken:e,oauthAccessToken:n}=t;if(!e&&!n)return null;try{return qt.credential(e,n)}catch(t){return null}}}qt.GOOGLE_SIGN_IN_METHOD="google.com",qt.PROVIDER_ID="google.com";class Bt extends Ut{constructor(){super("github.com")}static credential(t){return Dt._fromParams({providerId:Bt.PROVIDER_ID,signInMethod:Bt.GITHUB_SIGN_IN_METHOD,accessToken:t})}static credentialFromResult(t){return Bt.credentialFromTaggedObject(t)}static credentialFromError(t){return Bt.credentialFromTaggedObject(t.customData||{})}static credentialFromTaggedObject({_tokenResponse:t}){if(!t||!("oauthAccessToken"in t))return null;if(!t.oauthAccessToken)return null;try{return Bt.credential(t.oauthAccessToken)}catch(t){return null}}}Bt.GITHUB_SIGN_IN_METHOD="github.com",Bt.PROVIDER_ID="github.com";class zt extends St{constructor(t,e){super(t,t),this.pendingToken=e}_getIdTokenResponse(t){return Ct(t,this.buildRequest())}_linkToIdToken(t,e){const n=this.buildRequest();return n.idToken=e,Ct(t,n)}_getReauthenticationResolver(t){const e=this.buildRequest();return e.autoCreate=!1,Ct(t,e)}toJSON(){return{signInMethod:this.signInMethod,providerId:this.providerId,pendingToken:this.pendingToken}}static fromJSON(t){const e="string"==typeof t?JSON.parse(t):t,{providerId:n,signInMethod:r,pendingToken:i}=e;return n&&r&&i&&n===r?new zt(n,i):null}static _create(t,e){return new zt(t,e)}buildRequest(){return{requestUri:"http://localhost",returnSecureToken:!0,pendingToken:this.pendingToken}}}class Kt extends Ft{constructor(t){E(t.startsWith("saml."),"argument-error"),super(t)}static credentialFromResult(t){return Kt.samlCredentialFromTaggedObject(t)}static credentialFromError(t){return Kt.samlCredentialFromTaggedObject(t.customData||{})}static credentialFromJSON(t){const e=zt.fromJSON(t);return E(e,"argument-error"),e}static samlCredentialFromTaggedObject({_tokenResponse:t}){if(!t)return null;const{pendingToken:e,providerId:n}=t;if(!e||!n)return null;try{return zt._create(n,e)}catch(t){return null}}}class Wt extends Ut{constructor(){super("twitter.com")}static credential(t,e){return Dt._fromParams({providerId:Wt.PROVIDER_ID,signInMethod:Wt.TWITTER_SIGN_IN_METHOD,oauthToken:t,oauthTokenSecret:e})}static credentialFromResult(t){return Wt.credentialFromTaggedObject(t)}static credentialFromError(t){return Wt.credentialFromTaggedObject(t.customData||{})}static credentialFromTaggedObject({_tokenResponse:t}){if(!t)return null;const{oauthAccessToken:e,oauthTokenSecret:n}=t;if(!e||!n)return null;try{return Wt.credential(e,n)}catch(t){return null}}}async function Gt(t,e){return q(t,"POST","/v1/accounts:signUp",U(t,e))}Wt.TWITTER_SIGN_IN_METHOD="twitter.com",Wt.PROVIDER_ID="twitter.com";class Ht{constructor(t){this.user=t.user,this.providerId=t.providerId,this._tokenResponse=t._tokenResponse,this.operationType=t.operationType}static async _fromIdTokenResponse(t,e,n,r=!1){const i=await rt._fromIdTokenResponse(t,n,r),s=$t(n);return new Ht({user:i,providerId:s,_tokenResponse:n,operationType:e})}static async _forOperation(t,e,n){await t._updateTokensIfNecessary(n,!0);const r=$t(n);return new Ht({user:t,providerId:r,_tokenResponse:n,operationType:e})}}function $t(t){return t.providerId?t.providerId:"phoneNumber"in t?"phone":null}async function Yt(t){var e;const n=wt(t);if(await n._initializationPromise,null===(e=n.currentUser)||void 0===e?void 0:e.isAnonymous)return new Ht({user:n.currentUser,providerId:null,operationType:"signIn"});const r=await Gt(n,{returnSecureToken:!0}),i=await Ht._fromIdTokenResponse(n,"signIn",r,!0);return await n._updateCurrentUser(i.user),i}class Qt extends r.ZR{constructor(t,e,n,r){var i;super(e.code,e.message),this.operationType=n,this.user=r,Object.setPrototypeOf(this,Qt.prototype),this.customData={appName:t.name,tenantId:null!==(i=t.tenantId)&&void 0!==i?i:void 0,_serverResponse:e.customData._serverResponse,operationType:n}}static _fromErrorAndOperation(t,e,n,r){return new Qt(t,e,n,r)}}function Jt(t,e,n,r){return("reauthenticate"===e?n._getReauthenticationResolver(t):n._getIdTokenResponse(t)).catch((n=>{if("auth/multi-factor-auth-required"===n.code)throw Qt._fromErrorAndOperation(t,n,e,r);throw n}))}function Zt(t){return new Set(t.map((({providerId:t})=>t)).filter((t=>!!t)))}async function Xt(t,e){const n=(0,r.m9)(t);await ee(!0,n,e);const{providerUserInfo:i}=await async function(t,e){return V(t,"POST","/v1/accounts:update",e)}(n.auth,{idToken:await n.getIdToken(),deleteProvider:[e]}),s=Zt(i||[]);return n.providerData=n.providerData.filter((t=>s.has(t.providerId))),s.has("phone")||(n.phoneNumber=null),await n.auth._persistUserIfCurrent(n),n}async function te(t,e,n=!1){const r=await Q(t,e._linkToIdToken(t.auth,await t.getIdToken()),n);return Ht._forOperation(t,"link",r)}async function ee(t,e,n){await X(e);const r=!1===t?"provider-already-linked":"no-such-provider";E(Zt(e.providerData).has(n)===t,e.auth,r)}async function ne(t,e,n=!1){const{auth:r}=t,i="reauthenticate";try{const s=await Q(t,Jt(r,i,e,t),n);E(s.idToken,r,"internal-error");const o=Y(s.idToken);E(o,r,"internal-error");const{sub:a}=o;return E(t.uid===a,r,"user-mismatch"),Ht._forOperation(t,i,s)}catch(t){throw"auth/user-not-found"===(null==t?void 0:t.code)&&b(r,"user-mismatch"),t}}async function re(t,e,n=!1){const r="signIn",i=await Jt(t,r,e),s=await Ht._fromIdTokenResponse(t,r,i);return n||await t._updateCurrentUser(s.user),s}async function ie(t,e){return re(wt(t),e)}async function se(t,e){const n=(0,r.m9)(t);return await ee(!1,n,e.providerId),te(n,e)}async function oe(t,e){return ne((0,r.m9)(t),e)}async function ae(t,e){const n=wt(t),r=await async function(t,e){return q(t,"POST","/v1/accounts:signInWithCustomToken",U(t,e))}(n,{token:e,returnSecureToken:!0}),i=await Ht._fromIdTokenResponse(n,"signIn",r);return await n._updateCurrentUser(i.user),i}class ce{constructor(t,e){this.factorId=t,this.uid=e.mfaEnrollmentId,this.enrollmentTime=new Date(e.enrolledAt).toUTCString(),this.displayName=e.displayName}static _fromServerResponse(t,e){return"phoneInfo"in e?ue._fromServerResponse(t,e):b(t,"internal-error")}}class ue extends ce{constructor(t){super("phone",t),this.phoneNumber=t.phoneInfo}static _fromServerResponse(t,e){return new ue(e)}}function he(t,e,n){var r;E((null===(r=n.url)||void 0===r?void 0:r.length)>0,t,"invalid-continue-uri"),E(void 0===n.dynamicLinkDomain||n.dynamicLinkDomain.length>0,t,"invalid-dynamic-link-domain"),e.continueUrl=n.url,e.dynamicLinkDomain=n.dynamicLinkDomain,e.canHandleCodeInApp=n.handleCodeInApp,n.iOS&&(E(n.iOS.bundleId.length>0,t,"missing-ios-bundle-id"),e.iOSBundleId=n.iOS.bundleId),n.android&&(E(n.android.packageName.length>0,t,"missing-android-pkg-name"),e.androidInstallApp=n.android.installApp,e.androidMinimumVersionCode=n.android.minimumVersion,e.androidPackageName=n.android.packageName)}async function le(t,e,n){const i=(0,r.m9)(t),s={requestType:"PASSWORD_RESET",email:e};n&&he(i,s,n),await async function(t,e){return Nt(t,e)}(i,s)}async function de(t,e,n){await kt((0,r.m9)(t),{oobCode:e,newPassword:n})}async function fe(t,e){await async function(t,e){return V(t,"POST","/v1/accounts:update",U(t,e))}((0,r.m9)(t),{oobCode:e})}async function pe(t,e){const n=(0,r.m9)(t),i=await kt(n,{oobCode:e}),s=i.requestType;switch(E(s,n,"internal-error"),s){case"EMAIL_SIGNIN":break;case"VERIFY_AND_CHANGE_EMAIL":E(i.newEmail,n,"internal-error");break;case"REVERT_SECOND_FACTOR_ADDITION":E(i.mfaInfo,n,"internal-error");default:E(i.email,n,"internal-error")}let o=null;return i.mfaInfo&&(o=ce._fromServerResponse(wt(n),i.mfaInfo)),{data:{email:("VERIFY_AND_CHANGE_EMAIL"===i.requestType?i.newEmail:i.email)||null,previousEmail:("VERIFY_AND_CHANGE_EMAIL"===i.requestType?i.email:i.newEmail)||null,multiFactorInfo:o},operation:s}}async function me(t,e){const{data:n}=await pe((0,r.m9)(t),e);return n.email}async function ge(t,e,n){const r=wt(t),i=await Gt(r,{returnSecureToken:!0,email:e,password:n}),s=await Ht._fromIdTokenResponse(r,"signIn",i);return await r._updateCurrentUser(s.user),s}function ye(t,e,n){return ie((0,r.m9)(t),Mt.credential(e,n))}async function ve(t,e,n){const i=(0,r.m9)(t),s={requestType:"EMAIL_SIGNIN",email:e};E(n.handleCodeInApp,i,"argument-error"),n&&he(i,s,n),await async function(t,e){return Nt(t,e)}(i,s)}function be(t,e){const n=Pt.parseLink(e);return"EMAIL_SIGNIN"===(null==n?void 0:n.operation)}async function we(t,e,n){const i=(0,r.m9)(t),s=Mt.credentialWithLink(e,n||C());return E(s._tenantId===(i.tenantId||null),i,"tenant-id-mismatch"),ie(i,s)}async function Ie(t,e){const n={identifier:e,continueUri:D()?C():"http://localhost"},{signinMethods:i}=await async function(t,e){return V(t,"POST","/v1/accounts:createAuthUri",U(t,e))}((0,r.m9)(t),n);return i||[]}async function Te(t,e){const n=(0,r.m9)(t),i={requestType:"VERIFY_EMAIL",idToken:await t.getIdToken()};e&&he(n.auth,i,e);const{email:s}=await async function(t,e){return Nt(t,e)}(n.auth,i);s!==t.email&&await t.reload()}async function _e(t,e,n){const i=(0,r.m9)(t),s={requestType:"VERIFY_AND_CHANGE_EMAIL",idToken:await t.getIdToken(),newEmail:e};n&&he(i.auth,s,n);const{email:o}=await async function(t,e){return Nt(t,e)}(i.auth,s);o!==t.email&&await t.reload()}async function Ee(t,{displayName:e,photoURL:n}){if(void 0===e&&void 0===n)return;const i=(0,r.m9)(t),s={idToken:await i.getIdToken(),displayName:e,photoUrl:n,returnSecureToken:!0},o=await Q(i,async function(t,e){return V(t,"POST","/v1/accounts:update",e)}(i.auth,s));i.displayName=o.displayName||null,i.photoURL=o.photoUrl||null;const a=i.providerData.find((({providerId:t})=>"password"===t));a&&(a.displayName=i.displayName,a.photoURL=i.photoURL),await i._updateTokensIfNecessary(o)}function Se(t,e){return Ae((0,r.m9)(t),e,null)}function ke(t,e){return Ae((0,r.m9)(t),null,e)}async function Ae(t,e,n){const{auth:r}=t,i={idToken:await t.getIdToken(),returnSecureToken:!0};e&&(i.email=e),n&&(i.password=n);const s=await Q(t,At(r,i));await t._updateTokensIfNecessary(s,!0)}class Ne{constructor(t,e,n={}){this.isNewUser=t,this.providerId=e,this.profile=n}}class xe extends Ne{constructor(t,e,n,r){super(t,e,n),this.username=r}}class Ce extends Ne{constructor(t,e){super(t,"facebook.com",e)}}class De extends xe{constructor(t,e){super(t,"github.com",e,"string"==typeof(null==e?void 0:e.login)?null==e?void 0:e.login:null)}}class Oe extends Ne{constructor(t,e){super(t,"google.com",e)}}class Re extends xe{constructor(t,e,n){super(t,"twitter.com",e,n)}}function Pe(t){const{user:e,_tokenResponse:n}=t;return e.isAnonymous&&!n?{providerId:null,isNewUser:!1,profile:null}:function(t){var e,n;if(!t)return null;const{providerId:r}=t,i=t.rawUserInfo?JSON.parse(t.rawUserInfo):{},s=t.isNewUser||"identitytoolkit#SignupNewUserResponse"===t.kind;if(!r&&(null==t?void 0:t.idToken)){const r=null===(n=null===(e=Y(t.idToken))||void 0===e?void 0:e.firebase)||void 0===n?void 0:n.sign_in_provider;if(r)return new Ne(s,"anonymous"!==r&&"custom"!==r?r:null)}if(!r)return null;switch(r){case"facebook.com":return new Ce(s,i);case"github.com":return new De(s,i);case"google.com":return new Oe(s,i);case"twitter.com":return new Re(s,i,t.screenName||null);case"custom":case"anonymous":return new Ne(s,null);default:return new Ne(s,r,i)}}(n)}function Le(t,e){return(0,r.m9)(t).setPersistence(e)}function Me(t,e,n,i){return(0,r.m9)(t).onIdTokenChanged(e,n,i)}function Fe(t,e,n,i){return(0,r.m9)(t).onAuthStateChanged(e,n,i)}function Ue(t){(0,r.m9)(t).useDeviceLanguage()}function Ve(t,e){return(0,r.m9)(t).updateCurrentUser(e)}function je(t){return(0,r.m9)(t).signOut()}async function qe(t){return(0,r.m9)(t).delete()}class Be{constructor(t,e){this.type=t,this.credential=e}static _fromIdtoken(t){return new Be("enroll",t)}static _fromMfaPendingCredential(t){return new Be("signin",t)}toJSON(){return{multiFactorSession:{["enroll"===this.type?"idToken":"pendingCredential"]:this.credential}}}static fromJSON(t){var e,n;if(null==t?void 0:t.multiFactorSession){if(null===(e=t.multiFactorSession)||void 0===e?void 0:e.pendingCredential)return Be._fromMfaPendingCredential(t.multiFactorSession.pendingCredential);if(null===(n=t.multiFactorSession)||void 0===n?void 0:n.idToken)return Be._fromIdtoken(t.multiFactorSession.idToken)}return null}}class ze{constructor(t,e,n){this.session=t,this.hints=e,this.signInResolver=n}static _fromError(t,e){const n=wt(t),r=e.customData._serverResponse,i=(r.mfaInfo||[]).map((t=>ce._fromServerResponse(n,t)));E(r.mfaPendingCredential,n,"internal-error");const s=Be._fromMfaPendingCredential(r.mfaPendingCredential);return new ze(s,i,(async t=>{const i=await t._process(n,s);delete r.mfaInfo,delete r.mfaPendingCredential;const o=Object.assign(Object.assign({},r),{idToken:i.idToken,refreshToken:i.refreshToken});switch(e.operationType){case"signIn":const t=await Ht._fromIdTokenResponse(n,e.operationType,o);return await n._updateCurrentUser(t.user),t;case"reauthenticate":return E(e.user,n,"internal-error"),Ht._forOperation(e.user,e.operationType,o);default:b(n,"internal-error")}}))}async resolveSignIn(t){const e=t;return this.signInResolver(e)}}function Ke(t,e){var n;const i=(0,r.m9)(t),s=e;return E(e.customData.operationType,i,"argument-error"),E(null===(n=s.customData._serverResponse)||void 0===n?void 0:n.mfaPendingCredential,i,"argument-error"),ze._fromError(i,s)}class We{constructor(t){this.user=t,this.enrolledFactors=[],t._onReload((e=>{e.mfaInfo&&(this.enrolledFactors=e.mfaInfo.map((e=>ce._fromServerResponse(t.auth,e))))}))}static _fromUser(t){return new We(t)}async getSession(){return Be._fromIdtoken(await this.user.getIdToken())}async enroll(t,e){const n=t,r=await this.getSession(),i=await Q(this.user,n._process(this.user.auth,r,e));return await this.user._updateTokensIfNecessary(i),this.user.reload()}async unenroll(t){const e="string"==typeof t?t:t.uid,n=await this.user.getIdToken(),r=await Q(this.user,(i=this.user.auth,s={idToken:n,mfaEnrollmentId:e},V(i,"POST","/v2/accounts/mfaEnrollment:withdraw",U(i,s))));var i,s;this.enrolledFactors=this.enrolledFactors.filter((({uid:t})=>t!==e)),await this.user._updateTokensIfNecessary(r);try{await this.user.reload()}catch(t){if("auth/user-token-expired"!==t.code)throw t}}}const Ge=new WeakMap;function He(t){const e=(0,r.m9)(t);return Ge.has(e)||Ge.set(e,We._fromUser(e)),Ge.get(e)}const $e="__sak";class Ye{constructor(t,e){this.storageRetriever=t,this.type=e}_isAvailable(){try{return this.storage?(this.storage.setItem($e,"1"),this.storage.removeItem($e),Promise.resolve(!0)):Promise.resolve(!1)}catch(t){return Promise.resolve(!1)}}_set(t,e){return this.storage.setItem(t,JSON.stringify(e)),Promise.resolve()}_get(t){const e=this.storage.getItem(t);return Promise.resolve(e?JSON.parse(e):null)}_remove(t){return this.storage.removeItem(t),Promise.resolve()}get storage(){return this.storageRetriever()}}class Qe extends Ye{constructor(){super((()=>window.localStorage),"LOCAL"),this.boundEventHandler=(t,e)=>this.onStorageEvent(t,e),this.listeners={},this.localCache={},this.pollTimer=null,this.safariLocalStorageNotSynced=function(){const t=(0,r.z$)();return ht(t)||gt(t)}()&&function(){try{return!(!window||window===window.top)}catch(t){return!1}}(),this.fallbackToPolling=yt(),this._shouldAllowMigration=!0}forAllChangedKeys(t){for(const e of Object.keys(this.listeners)){const n=this.storage.getItem(e),r=this.localCache[e];n!==r&&t(e,r,n)}}onStorageEvent(t,e=!1){if(!t.key)return void this.forAllChangedKeys(((t,e,n)=>{this.notifyListeners(t,n)}));const n=t.key;if(e?this.detachListener():this.stopPolling(),this.safariLocalStorageNotSynced){const r=this.storage.getItem(n);if(t.newValue!==r)null!==t.newValue?this.storage.setItem(n,t.newValue):this.storage.removeItem(n);else if(this.localCache[n]===t.newValue&&!e)return}const i=()=>{const t=this.storage.getItem(n);(e||this.localCache[n]!==t)&&this.notifyListeners(n,t)},s=this.storage.getItem(n);(0,r.w1)()&&10===document.documentMode&&s!==t.newValue&&t.newValue!==t.oldValue?setTimeout(i,10):i()}notifyListeners(t,e){this.localCache[t]=e;const n=this.listeners[t];if(n)for(const t of Array.from(n))t(e?JSON.parse(e):e)}startPolling(){this.stopPolling(),this.pollTimer=setInterval((()=>{this.forAllChangedKeys(((t,e,n)=>{this.onStorageEvent(new StorageEvent("storage",{key:t,oldValue:e,newValue:n}),!0)}))}),1e3)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}attachListener(){window.addEventListener("storage",this.boundEventHandler)}detachListener(){window.removeEventListener("storage",this.boundEventHandler)}_addListener(t,e){0===Object.keys(this.listeners).length&&(this.fallbackToPolling?this.startPolling():this.attachListener()),this.listeners[t]||(this.listeners[t]=new Set,this.localCache[t]=this.storage.getItem(t)),this.listeners[t].add(e)}_removeListener(t,e){this.listeners[t]&&(this.listeners[t].delete(e),0===this.listeners[t].size&&delete this.listeners[t]),0===Object.keys(this.listeners).length&&(this.detachListener(),this.stopPolling())}async _set(t,e){await super._set(t,e),this.localCache[t]=JSON.stringify(e)}async _get(t){const e=await super._get(t);return this.localCache[t]=JSON.stringify(e),e}async _remove(t){await super._remove(t),delete this.localCache[t]}}Qe.type="LOCAL";const Je=Qe;class Ze extends Ye{constructor(){super((()=>window.sessionStorage),"SESSION")}_addListener(t,e){}_removeListener(t,e){}}Ze.type="SESSION";const Xe=Ze;class tn{constructor(t){this.eventTarget=t,this.handlersMap={},this.boundEventHandler=this.handleEvent.bind(this)}static _getInstance(t){const e=this.receivers.find((e=>e.isListeningto(t)));if(e)return e;const n=new tn(t);return this.receivers.push(n),n}isListeningto(t){return this.eventTarget===t}async handleEvent(t){const e=t,{eventId:n,eventType:r,data:i}=e.data,s=this.handlersMap[r];if(!(null==s?void 0:s.size))return;e.ports[0].postMessage({status:"ack",eventId:n,eventType:r});const o=Array.from(s).map((async t=>t(e.origin,i))),a=await function(t){return Promise.all(t.map((async t=>{try{return{fulfilled:!0,value:await t}}catch(t){return{fulfilled:!1,reason:t}}})))}(o);e.ports[0].postMessage({status:"done",eventId:n,eventType:r,response:a})}_subscribe(t,e){0===Object.keys(this.handlersMap).length&&this.eventTarget.addEventListener("message",this.boundEventHandler),this.handlersMap[t]||(this.handlersMap[t]=new Set),this.handlersMap[t].add(e)}_unsubscribe(t,e){this.handlersMap[t]&&e&&this.handlersMap[t].delete(e),e&&0!==this.handlersMap[t].size||delete this.handlersMap[t],0===Object.keys(this.handlersMap).length&&this.eventTarget.removeEventListener("message",this.boundEventHandler)}}function en(t="",e=10){let n="";for(let t=0;t<e;t++)n+=Math.floor(10*Math.random());return t+n}tn.receivers=[];class nn{constructor(t){this.target=t,this.handlers=new Set}removeMessageHandler(t){t.messageChannel&&(t.messageChannel.port1.removeEventListener("message",t.onMessage),t.messageChannel.port1.close()),this.handlers.delete(t)}async _send(t,e,n=50){const r="undefined"!=typeof MessageChannel?new MessageChannel:null;if(!r)throw new Error("connection_unavailable");let i,s;return new Promise(((o,a)=>{const c=en("",20);r.port1.start();const u=setTimeout((()=>{a(new Error("unsupported_event"))}),n);s={messageChannel:r,onMessage(t){const e=t;if(e.data.eventId===c)switch(e.data.status){case"ack":clearTimeout(u),i=setTimeout((()=>{a(new Error("timeout"))}),3e3);break;case"done":clearTimeout(i),o(e.data.response);break;default:clearTimeout(u),clearTimeout(i),a(new Error("invalid_response"))}}},this.handlers.add(s),r.port1.addEventListener("message",s.onMessage),this.target.postMessage({eventType:t,eventId:c,data:e},[r.port2])})).finally((()=>{s&&this.removeMessageHandler(s)}))}}function rn(){return window}function sn(){return void 0!==rn().WorkerGlobalScope&&"function"==typeof rn().importScripts}const on="firebaseLocalStorageDb",an="firebaseLocalStorage",cn="fbase_key";class un{constructor(t){this.request=t}toPromise(){return new Promise(((t,e)=>{this.request.addEventListener("success",(()=>{t(this.request.result)})),this.request.addEventListener("error",(()=>{e(this.request.error)}))}))}}function hn(t,e){return t.transaction([an],e?"readwrite":"readonly").objectStore(an)}function ln(){const t=indexedDB.open(on,1);return new Promise(((e,n)=>{t.addEventListener("error",(()=>{n(t.error)})),t.addEventListener("upgradeneeded",(()=>{const e=t.result;try{e.createObjectStore(an,{keyPath:cn})}catch(t){n(t)}})),t.addEventListener("success",(async()=>{const n=t.result;n.objectStoreNames.contains(an)?e(n):(n.close(),await function(){const t=indexedDB.deleteDatabase(on);return new un(t).toPromise()}(),e(await ln()))}))}))}async function dn(t,e,n){const r=hn(t,!0).put({[cn]:e,value:n});return new un(r).toPromise()}function fn(t,e){const n=hn(t,!0).delete(e);return new un(n).toPromise()}class pn{constructor(){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((()=>{}),(()=>{}))}async _openDb(){return this.db||(this.db=await ln()),this.db}async _withRetries(t){let e=0;for(;;)try{const e=await this._openDb();return await t(e)}catch(t){if(e++>3)throw t;this.db&&(this.db.close(),this.db=void 0)}}async initializeServiceWorkerMessaging(){return sn()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=tn._getInstance(sn()?self:null),this.receiver._subscribe("keyChanged",(async(t,e)=>({keyProcessed:(await this._poll()).includes(e.key)}))),this.receiver._subscribe("ping",(async(t,e)=>["keyChanged"]))}async initializeSender(){var t,e;if(this.activeServiceWorker=await async function(){if(!(null===navigator||void 0===navigator?void 0:navigator.serviceWorker))return null;try{return(await navigator.serviceWorker.ready).active}catch(t){return null}}(),!this.activeServiceWorker)return;this.sender=new nn(this.activeServiceWorker);const n=await this.sender._send("ping",{},800);n&&(null===(t=n[0])||void 0===t?void 0:t.fulfilled)&&(null===(e=n[0])||void 0===e?void 0:e.value.includes("keyChanged"))&&(this.serviceWorkerReceiverAvailable=!0)}async notifyServiceWorker(t){var e;if(this.sender&&this.activeServiceWorker&&((null===(e=null===navigator||void 0===navigator?void 0:navigator.serviceWorker)||void 0===e?void 0:e.controller)||null)===this.activeServiceWorker)try{await this.sender._send("keyChanged",{key:t},this.serviceWorkerReceiverAvailable?800:50)}catch(e){}}async _isAvailable(){try{if(!indexedDB)return!1;const t=await ln();return await dn(t,$e,"1"),await fn(t,$e),!0}catch(t){}return!1}async _withPendingWrite(t){this.pendingWrites++;try{await t()}finally{this.pendingWrites--}}async _set(t,e){return this._withPendingWrite((async()=>(await this._withRetries((n=>dn(n,t,e))),this.localCache[t]=e,this.notifyServiceWorker(t))))}async _get(t){const e=await this._withRetries((e=>async function(t,e){const n=hn(t,!1).get(e),r=await new un(n).toPromise();return void 0===r?null:r.value}(e,t)));return this.localCache[t]=e,e}async _remove(t){return this._withPendingWrite((async()=>(await this._withRetries((e=>fn(e,t))),delete this.localCache[t],this.notifyServiceWorker(t))))}async _poll(){const t=await this._withRetries((t=>{const e=hn(t,!1).getAll();return new un(e).toPromise()}));if(!t)return[];if(0!==this.pendingWrites)return[];const e=[],n=new Set;for(const{fbase_key:r,value:i}of t)n.add(r),JSON.stringify(this.localCache[r])!==JSON.stringify(i)&&(this.notifyListeners(r,i),e.push(r));for(const t of Object.keys(this.localCache))this.localCache[t]&&!n.has(t)&&(this.notifyListeners(t,null),e.push(t));return e}notifyListeners(t,e){this.localCache[t]=e;const n=this.listeners[t];if(n)for(const t of Array.from(n))t(e)}startPolling(){this.stopPolling(),this.pollTimer=setInterval((async()=>this._poll()),800)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}_addListener(t,e){0===Object.keys(this.listeners).length&&this.startPolling(),this.listeners[t]||(this.listeners[t]=new Set,this._get(t)),this.listeners[t].add(e)}_removeListener(t,e){this.listeners[t]&&(this.listeners[t].delete(e),0===this.listeners[t].size&&delete this.listeners[t]),0===Object.keys(this.listeners).length&&this.stopPolling()}}pn.type="LOCAL";const mn=pn;function gn(t){return new Promise(((e,n)=>{const r=document.createElement("script");var i,s;r.setAttribute("src",t),r.onload=e,r.onerror=t=>{const e=w("internal-error");e.customData=t,n(e)},r.type="text/javascript",r.charset="UTF-8",(null!==(s=null===(i=document.getElementsByTagName("head"))||void 0===i?void 0:i[0])&&void 0!==s?s:document).appendChild(r)}))}function yn(t){return`__${t}${Math.floor(1e6*Math.random())}`}const vn=1e12;class bn{constructor(t){this.auth=t,this.counter=vn,this._widgets=new Map}render(t,e){const n=this.counter;return this._widgets.set(n,new wn(t,this.auth.name,e||{})),this.counter++,n}reset(t){var e;const n=t||vn;null===(e=this._widgets.get(n))||void 0===e||e.delete(),this._widgets.delete(n)}getResponse(t){var e;const n=t||vn;return(null===(e=this._widgets.get(n))||void 0===e?void 0:e.getResponse())||""}async execute(t){var e;const n=t||vn;return null===(e=this._widgets.get(n))||void 0===e||e.execute(),""}}class wn{constructor(t,e,n){this.params=n,this.timerId=null,this.deleted=!1,this.responseToken=null,this.clickHandler=()=>{this.execute()};const r="string"==typeof t?document.getElementById(t):t;E(r,"argument-error",{appName:e}),this.container=r,this.isVisible="invisible"!==this.params.size,this.isVisible?this.execute():this.container.addEventListener("click",this.clickHandler)}getResponse(){return this.checkIfDeleted(),this.responseToken}delete(){this.checkIfDeleted(),this.deleted=!0,this.timerId&&(clearTimeout(this.timerId),this.timerId=null),this.container.removeEventListener("click",this.clickHandler)}execute(){this.checkIfDeleted(),this.timerId||(this.timerId=window.setTimeout((()=>{this.responseToken=function(t){const e=[],n="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";for(let t=0;t<50;t++)e.push(n.charAt(Math.floor(Math.random()*n.length)));return e.join("")}();const{callback:t,"expired-callback":e}=this.params;if(t)try{t(this.responseToken)}catch(t){}this.timerId=window.setTimeout((()=>{if(this.timerId=null,this.responseToken=null,e)try{e()}catch(t){}this.isVisible&&this.execute()}),6e4)}),500))}checkIfDeleted(){if(this.deleted)throw new Error("reCAPTCHA mock was already deleted!")}}const In=yn("rcb"),Tn=new R(3e4,6e4);class _n{constructor(){this.hostLanguage="",this.counter=0,this.librarySeparatelyLoaded=!!rn().grecaptcha}load(t,e=""){return E(function(t){return t.length<=6&&/^\s*[a-zA-Z0-9\-]*\s*$/.test(t)}(e),t,"argument-error"),this.shouldResolveImmediately(e)?Promise.resolve(rn().grecaptcha):new Promise(((n,i)=>{const s=rn().setTimeout((()=>{i(w(t,"network-request-failed"))}),Tn.get());rn()[In]=()=>{rn().clearTimeout(s),delete rn()[In];const r=rn().grecaptcha;if(!r)return void i(w(t,"internal-error"));const o=r.render;r.render=(t,e)=>{const n=o(t,e);return this.counter++,n},this.hostLanguage=e,n(r)},gn(`https://www.google.com/recaptcha/api.js??${(0,r.xO)({onload:In,render:"explicit",hl:e})}`).catch((()=>{clearTimeout(s),i(w(t,"internal-error"))}))}))}clearedOneInstance(){this.counter--}shouldResolveImmediately(t){return!!rn().grecaptcha&&(t===this.hostLanguage||this.counter>0||this.librarySeparatelyLoaded)}}class En{async load(t){return new bn(t)}clearedOneInstance(){}}const Sn="recaptcha",kn={theme:"light",type:"image"};class An{constructor(t,e=Object.assign({},kn),n){this.parameters=e,this.type=Sn,this.destroyed=!1,this.widgetId=null,this.tokenChangeListeners=new Set,this.renderPromise=null,this.recaptcha=null,this.auth=wt(n),this.isInvisible="invisible"===this.parameters.size,E("undefined"!=typeof document,this.auth,"operation-not-supported-in-this-environment");const r="string"==typeof t?document.getElementById(t):t;E(r,this.auth,"argument-error"),this.container=r,this.parameters.callback=this.makeTokenCallback(this.parameters.callback),this._recaptchaLoader=this.auth.settings.appVerificationDisabledForTesting?new En:new _n,this.validateStartingState()}async verify(){this.assertNotDestroyed();const t=await this.render(),e=this.getAssertedRecaptcha();return e.getResponse(t)||new Promise((n=>{const r=t=>{t&&(this.tokenChangeListeners.delete(r),n(t))};this.tokenChangeListeners.add(r),this.isInvisible&&e.execute(t)}))}render(){try{this.assertNotDestroyed()}catch(t){return Promise.reject(t)}return this.renderPromise||(this.renderPromise=this.makeRenderPromise().catch((t=>{throw this.renderPromise=null,t}))),this.renderPromise}_reset(){this.assertNotDestroyed(),null!==this.widgetId&&this.getAssertedRecaptcha().reset(this.widgetId)}clear(){this.assertNotDestroyed(),this.destroyed=!0,this._recaptchaLoader.clearedOneInstance(),this.isInvisible||this.container.childNodes.forEach((t=>{this.container.removeChild(t)}))}validateStartingState(){E(!this.parameters.sitekey,this.auth,"argument-error"),E(this.isInvisible||!this.container.hasChildNodes(),this.auth,"argument-error"),E("undefined"!=typeof document,this.auth,"operation-not-supported-in-this-environment")}makeTokenCallback(t){return e=>{if(this.tokenChangeListeners.forEach((t=>t(e))),"function"==typeof t)t(e);else if("string"==typeof t){const n=rn()[t];"function"==typeof n&&n(e)}}}assertNotDestroyed(){E(!this.destroyed,this.auth,"internal-error")}async makeRenderPromise(){if(await this.init(),!this.widgetId){let t=this.container;if(!this.isInvisible){const e=document.createElement("div");t.appendChild(e),t=e}this.widgetId=this.getAssertedRecaptcha().render(t,this.parameters)}return this.widgetId}async init(){E(D()&&!sn(),this.auth,"internal-error"),await function(){let t=null;return new Promise((e=>{"complete"!==document.readyState?(t=()=>e(),window.addEventListener("load",t)):e()})).catch((e=>{throw t&&window.removeEventListener("load",t),e}))}(),this.recaptcha=await this._recaptchaLoader.load(this.auth,this.auth.languageCode||void 0);const t=await async function(t){return(await V(t,"GET","/v1/recaptchaParams")).recaptchaSiteKey||""}(this.auth);E(t,this.auth,"internal-error"),this.parameters.sitekey=t}getAssertedRecaptcha(){return E(this.recaptcha,this.auth,"internal-error"),this.recaptcha}}class Nn{constructor(t,e){this.verificationId=t,this.onConfirmation=e}confirm(t){const e=Rt._fromVerification(this.verificationId,t);return this.onConfirmation(e)}}async function xn(t,e,n){const i=wt(t),s=await On(i,e,(0,r.m9)(n));return new Nn(s,(t=>ie(i,t)))}async function Cn(t,e,n){const i=(0,r.m9)(t);await ee(!1,i,"phone");const s=await On(i.auth,e,(0,r.m9)(n));return new Nn(s,(t=>se(i,t)))}async function Dn(t,e,n){const i=(0,r.m9)(t),s=await On(i.auth,e,(0,r.m9)(n));return new Nn(s,(t=>oe(i,t)))}async function On(t,e,n){var r;const i=await n.verify();try{let s;if(E("string"==typeof i,t,"argument-error"),E(n.type===Sn,t,"argument-error"),s="string"==typeof e?{phoneNumber:e}:e,"session"in s){const e=s.session;if("phoneNumber"in s){E("enroll"===e.type,t,"internal-error");const n=await function(t,e){return V(t,"POST","/v2/accounts/mfaEnrollment:start",U(t,e))}(t,{idToken:e.credential,phoneEnrollmentInfo:{phoneNumber:s.phoneNumber,recaptchaToken:i}});return n.phoneSessionInfo.sessionInfo}{E("signin"===e.type,t,"internal-error");const n=(null===(r=s.multiFactorHint)||void 0===r?void 0:r.uid)||s.multiFactorUid;E(n,t,"missing-multi-factor-info");const o=await function(t,e){return V(t,"POST","/v2/accounts/mfaSignIn:start",U(t,e))}(t,{mfaPendingCredential:e.credential,mfaEnrollmentId:n,phoneSignInInfo:{recaptchaToken:i}});return o.phoneResponseInfo.sessionInfo}}{const{sessionInfo:e}=await async function(t,e){return V(t,"POST","/v1/accounts:sendVerificationCode",U(t,e))}(t,{phoneNumber:s.phoneNumber,recaptchaToken:i});return e}}finally{n._reset()}}async function Rn(t,e){await te((0,r.m9)(t),e)}class Pn{constructor(t){this.providerId=Pn.PROVIDER_ID,this.auth=wt(t)}verifyPhoneNumber(t,e){return On(this.auth,t,(0,r.m9)(e))}static credential(t,e){return Rt._fromVerification(t,e)}static credentialFromResult(t){const e=t;return Pn.credentialFromTaggedObject(e)}static credentialFromError(t){return Pn.credentialFromTaggedObject(t.customData||{})}static credentialFromTaggedObject({_tokenResponse:t}){if(!t)return null;const{phoneNumber:e,temporaryProof:n}=t;return e&&n?Rt._fromTokenResponse(e,n):null}}function Ln(t,e){return e?N(e):(E(t._popupRedirectResolver,t,"argument-error"),t._popupRedirectResolver)}Pn.PROVIDER_ID="phone",Pn.PHONE_SIGN_IN_METHOD="phone";class Mn extends St{constructor(t){super("custom","custom"),this.params=t}_getIdTokenResponse(t){return Ct(t,this._buildIdpRequest())}_linkToIdToken(t,e){return Ct(t,this._buildIdpRequest(e))}_getReauthenticationResolver(t){return Ct(t,this._buildIdpRequest())}_buildIdpRequest(t){const e={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 t&&(e.idToken=t),e}}function Fn(t){return re(t.auth,new Mn(t),t.bypassAuthState)}function Un(t){const{auth:e,user:n}=t;return E(n,e,"internal-error"),ne(n,new Mn(t),t.bypassAuthState)}async function Vn(t){const{auth:e,user:n}=t;return E(n,e,"internal-error"),te(n,new Mn(t),t.bypassAuthState)}class jn{constructor(t,e,n,r,i=!1){this.auth=t,this.resolver=n,this.user=r,this.bypassAuthState=i,this.pendingPromise=null,this.eventManager=null,this.filter=Array.isArray(e)?e:[e]}execute(){return new Promise((async(t,e)=>{this.pendingPromise={resolve:t,reject:e};try{this.eventManager=await this.resolver._initialize(this.auth),await this.onExecution(),this.eventManager.registerConsumer(this)}catch(t){this.reject(t)}}))}async onAuthEvent(t){const{urlResponse:e,sessionId:n,postBody:r,tenantId:i,error:s,type:o}=t;if(s)return void this.reject(s);const a={auth:this.auth,requestUri:e,sessionId:n,tenantId:i||void 0,postBody:r||void 0,user:this.user,bypassAuthState:this.bypassAuthState};try{this.resolve(await this.getIdpTask(o)(a))}catch(t){this.reject(t)}}onError(t){this.reject(t)}getIdpTask(t){switch(t){case"signInViaPopup":case"signInViaRedirect":return Fn;case"linkViaPopup":case"linkViaRedirect":return Vn;case"reauthViaPopup":case"reauthViaRedirect":return Un;default:b(this.auth,"internal-error")}}resolve(t){k(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(t),this.unregisterAndCleanUp()}reject(t){k(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.reject(t),this.unregisterAndCleanUp()}unregisterAndCleanUp(){this.eventManager&&this.eventManager.unregisterConsumer(this),this.pendingPromise=null,this.cleanUp()}}const qn=new R(2e3,1e4);async function Bn(t,e,n){const r=wt(t);T(t,e,Ft);const i=Ln(r,n);return new Wn(r,"signInViaPopup",e,i).executeNotNull()}async function zn(t,e,n){const i=(0,r.m9)(t);T(i.auth,e,Ft);const s=Ln(i.auth,n);return new Wn(i.auth,"reauthViaPopup",e,s,i).executeNotNull()}async function Kn(t,e,n){const i=(0,r.m9)(t);T(i.auth,e,Ft);const s=Ln(i.auth,n);return new Wn(i.auth,"linkViaPopup",e,s,i).executeNotNull()}class Wn extends jn{constructor(t,e,n,r,i){super(t,e,r,i),this.provider=n,this.authWindow=null,this.pollId=null,Wn.currentPopupAction&&Wn.currentPopupAction.cancel(),Wn.currentPopupAction=this}async executeNotNull(){const t=await this.execute();return E(t,this.auth,"internal-error"),t}async onExecution(){k(1===this.filter.length,"Popup operations only handle one event");const t=en();this.authWindow=await this.resolver._openPopup(this.auth,this.provider,this.filter[0],t),this.authWindow.associatedEvent=t,this.resolver._originValidation(this.auth).catch((t=>{this.reject(t)})),this.resolver._isIframeWebStorageSupported(this.auth,(t=>{t||this.reject(w(this.auth,"web-storage-unsupported"))})),this.pollUserCancellation()}get eventId(){var t;return(null===(t=this.authWindow)||void 0===t?void 0:t.associatedEvent)||null}cancel(){this.reject(w(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,Wn.currentPopupAction=null}pollUserCancellation(){const t=()=>{var e,n;(null===(n=null===(e=this.authWindow)||void 0===e?void 0:e.window)||void 0===n?void 0:n.closed)?this.pollId=window.setTimeout((()=>{this.pollId=null,this.reject(w(this.auth,"popup-closed-by-user"))}),2e3):this.pollId=window.setTimeout(t,qn.get())};t()}}Wn.currentPopupAction=null;const Gn=new Map;class Hn extends jn{constructor(t,e,n=!1){super(t,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],e,void 0,n),this.eventId=null}async execute(){let t=Gn.get(this.auth._key());if(!t){try{const e=await async function(t,e){const n=Qn(e),r=Yn(t);if(!await r._isAvailable())return!1;const i="true"===await r._get(n);return await r._remove(n),i}(this.resolver,this.auth)?await super.execute():null;t=()=>Promise.resolve(e)}catch(e){t=()=>Promise.reject(e)}Gn.set(this.auth._key(),t)}return this.bypassAuthState||Gn.set(this.auth._key(),(()=>Promise.resolve(null))),t()}async onAuthEvent(t){if("signInViaRedirect"===t.type)return super.onAuthEvent(t);if("unknown"!==t.type){if(t.eventId){const e=await this.auth._redirectUserForId(t.eventId);if(e)return this.user=e,super.onAuthEvent(t);this.resolve(null)}}else this.resolve(null)}async onExecution(){}cleanUp(){}}async function $n(t,e){return Yn(t)._set(Qn(e),"true")}function Yn(t){return N(t._redirectPersistence)}function Qn(t){return ot("pendingRedirect",t.config.apiKey,t.name)}function Jn(t,e,n){return async function(t,e,n){const r=wt(t);T(t,e,Ft);const i=Ln(r,n);return await $n(i,r),i._openRedirect(r,e,"signInViaRedirect")}(t,e,n)}function Zn(t,e,n){return async function(t,e,n){const i=(0,r.m9)(t);T(i.auth,e,Ft);const s=Ln(i.auth,n);await $n(s,i.auth);const o=await nr(i);return s._openRedirect(i.auth,e,"reauthViaRedirect",o)}(t,e,n)}function Xn(t,e,n){return async function(t,e,n){const i=(0,r.m9)(t);T(i.auth,e,Ft);const s=Ln(i.auth,n);await ee(!1,i,e.providerId),await $n(s,i.auth);const o=await nr(i);return s._openRedirect(i.auth,e,"linkViaRedirect",o)}(t,e,n)}async function tr(t,e){return await wt(t)._initializationPromise,er(t,e,!1)}async function er(t,e,n=!1){const r=wt(t),i=Ln(r,e),s=new Hn(r,i,n),o=await s.execute();return o&&!n&&(delete o.user._redirectEventId,await r._persistUserIfCurrent(o.user),await r._setRedirectUser(null,e)),o}async function nr(t){const e=en(`${t.uid}:::`);return t._redirectEventId=e,await t.auth._setRedirectUser(t),await t.auth._persistUserIfCurrent(t),e}class rr{constructor(t){this.auth=t,this.cachedEventUids=new Set,this.consumers=new Set,this.queuedRedirectEvent=null,this.hasHandledPotentialRedirect=!1,this.lastProcessedEventTime=Date.now()}registerConsumer(t){this.consumers.add(t),this.queuedRedirectEvent&&this.isEventForConsumer(this.queuedRedirectEvent,t)&&(this.sendToConsumer(this.queuedRedirectEvent,t),this.saveEventToCache(this.queuedRedirectEvent),this.queuedRedirectEvent=null)}unregisterConsumer(t){this.consumers.delete(t)}onEvent(t){if(this.hasEventBeenHandled(t))return!1;let e=!1;return this.consumers.forEach((n=>{this.isEventForConsumer(t,n)&&(e=!0,this.sendToConsumer(t,n),this.saveEventToCache(t))})),this.hasHandledPotentialRedirect||!function(t){switch(t.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return!0;case"unknown":return sr(t);default:return!1}}(t)||(this.hasHandledPotentialRedirect=!0,e||(this.queuedRedirectEvent=t,e=!0)),e}sendToConsumer(t,e){var n;if(t.error&&!sr(t)){const r=(null===(n=t.error.code)||void 0===n?void 0:n.split("auth/")[1])||"internal-error";e.onError(w(this.auth,r))}else e.onAuthEvent(t)}isEventForConsumer(t,e){const n=null===e.eventId||!!t.eventId&&t.eventId===e.eventId;return e.filter.includes(t.type)&&n}hasEventBeenHandled(t){return Date.now()-this.lastProcessedEventTime>=6e5&&this.cachedEventUids.clear(),this.cachedEventUids.has(ir(t))}saveEventToCache(t){this.cachedEventUids.add(ir(t)),this.lastProcessedEventTime=Date.now()}}function ir(t){return[t.type,t.eventId,t.sessionId,t.tenantId].filter((t=>t)).join("-")}function sr({type:t,error:e}){return"unknown"===t&&"auth/no-auth-event"===(null==e?void 0:e.code)}const or=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,ar=/^https?/;function cr(t){const e=C(),{protocol:n,hostname:r}=new URL(e);if(t.startsWith("chrome-extension://")){const i=new URL(t);return""===i.hostname&&""===r?"chrome-extension:"===n&&t.replace("chrome-extension://","")===e.replace("chrome-extension://",""):"chrome-extension:"===n&&i.hostname===r}if(!ar.test(n))return!1;if(or.test(t))return r===t;const i=t.replace(/\./g,"\\.");return new RegExp("^(.+\\."+i+"|"+i+")$","i").test(r)}const ur=new R(3e4,6e4);function hr(){const t=rn().___jsl;if(null==t?void 0:t.H)for(const e of Object.keys(t.H))if(t.H[e].r=t.H[e].r||[],t.H[e].L=t.H[e].L||[],t.H[e].r=[...t.H[e].L],t.CP)for(let e=0;e<t.CP.length;e++)t.CP[e]=null}let lr=null;function dr(t){return lr=lr||function(t){return new Promise(((e,n)=>{var r,i,s;function o(){hr(),gapi.load("gapi.iframes",{callback:()=>{e(gapi.iframes.getContext())},ontimeout:()=>{hr(),n(w(t,"network-request-failed"))},timeout:ur.get()})}if(null===(i=null===(r=rn().gapi)||void 0===r?void 0:r.iframes)||void 0===i?void 0:i.Iframe)e(gapi.iframes.getContext());else{if(!(null===(s=rn().gapi)||void 0===s?void 0:s.load)){const e=yn("iframefcb");return rn()[e]=()=>{gapi.load?o():n(w(t,"network-request-failed"))},gn(`https://apis.google.com/js/api.js?onload=${e}`).catch((t=>n(t)))}o()}})).catch((t=>{throw lr=null,t}))}(t),lr}const fr=new R(5e3,15e3),pr={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},mr=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);function gr(t){const e=t.config;E(e.authDomain,t,"auth-domain-config-required");const n=e.emulator?P(e,"emulator/auth/iframe"):`https://${t.config.authDomain}/__/auth/iframe`,s={apiKey:e.apiKey,appName:t.name,v:i.Jn},o=mr.get(t.config.apiHost);o&&(s.eid=o);const a=t._getFrameworks();return a.length&&(s.fw=a.join(",")),`${n}?${(0,r.xO)(s).slice(1)}`}const yr={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"};class vr{constructor(t){this.window=t,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch(t){}}}function br(t,e,n,s,o,a){E(t.config.authDomain,t,"auth-domain-config-required"),E(t.config.apiKey,t,"invalid-api-key");const c={apiKey:t.config.apiKey,appName:t.name,authType:n,redirectUrl:s,v:i.Jn,eventId:o};if(e instanceof Ft){e.setDefaultLanguage(t.languageCode),c.providerId=e.providerId||"",(0,r.xb)(e.getCustomParameters())||(c.customParameters=JSON.stringify(e.getCustomParameters()));for(const[t,e]of Object.entries(a||{}))c[t]=e}if(e instanceof Ut){const t=e.getScopes().filter((t=>""!==t));t.length>0&&(c.scopes=t.join(","))}t.tenantId&&(c.tid=t.tenantId);const u=c;for(const t of Object.keys(u))void 0===u[t]&&delete u[t];return`${function({config:t}){return t.emulator?P(t,"emulator/auth/handler"):`https://${t.authDomain}/__/auth/handler`}(t)}?${(0,r.xO)(u).slice(1)}`}const wr="webStorageSupport",Ir=class{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=Xe,this._completeRedirectFn=er}async _openPopup(t,e,n,i){var s;return k(null===(s=this.eventManagers[t._key()])||void 0===s?void 0:s.manager,"_initialize() not called before _openPopup()"),function(t,e,n,i=500,s=600){const o=Math.max((window.screen.availHeight-s)/2,0).toString(),a=Math.max((window.screen.availWidth-i)/2,0).toString();let c="";const u=Object.assign(Object.assign({},yr),{width:i.toString(),height:s.toString(),top:o,left:a}),h=(0,r.z$)().toLowerCase();n&&(c=lt(h)?"_blank":n),ut(h)&&(e=e||"http://localhost",u.scrollbars="yes");const l=Object.entries(u).reduce(((t,[e,n])=>`${t}${e}=${n},`),"");if(function(t=(0,r.z$)()){var e;return gt(t)&&!!(null===(e=window.navigator)||void 0===e?void 0:e.standalone)}(h)&&"_self"!==c)return function(t,e){const n=document.createElement("a");n.href=t,n.target=e;const r=document.createEvent("MouseEvent");r.initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,1,null),n.dispatchEvent(r)}(e||"",c),new vr(null);const d=window.open(e||"",c,l);E(d,t,"popup-blocked");try{d.focus()}catch(t){}return new vr(d)}(t,br(t,e,n,C(),i),en())}async _openRedirect(t,e,n,r){var i;return await this._originValidation(t),i=br(t,e,n,C(),r),rn().location.href=i,new Promise((()=>{}))}_initialize(t){const e=t._key();if(this.eventManagers[e]){const{manager:t,promise:n}=this.eventManagers[e];return t?Promise.resolve(t):(k(n,"If manager is not set, promise should be"),n)}const n=this.initAndGetManager(t);return this.eventManagers[e]={promise:n},n.catch((()=>{delete this.eventManagers[e]})),n}async initAndGetManager(t){const e=await async function(t){const e=await dr(t),n=rn().gapi;return E(n,t,"internal-error"),e.open({where:document.body,url:gr(t),messageHandlersFilter:n.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:pr,dontclear:!0},(e=>new Promise((async(n,r)=>{await e.restyle({setHideOnLeave:!1});const i=w(t,"network-request-failed"),s=rn().setTimeout((()=>{r(i)}),fr.get());function o(){rn().clearTimeout(s),n(e)}e.ping(o).then(o,(()=>{r(i)}))}))))}(t),n=new rr(t);return e.register("authEvent",(e=>(E(null==e?void 0:e.authEvent,t,"invalid-auth-event"),{status:n.onEvent(e.authEvent)?"ACK":"ERROR"})),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[t._key()]={manager:n},this.iframes[t._key()]=e,n}_isIframeWebStorageSupported(t,e){this.iframes[t._key()].send(wr,{type:wr},(n=>{var r;const i=null===(r=null==n?void 0:n[0])||void 0===r?void 0:r.webStorageSupport;void 0!==i&&e(!!i),b(t,"internal-error")}),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(t){const e=t._key();return this.originValidationPromises[e]||(this.originValidationPromises[e]=async function(t){if(t.config.emulator)return;const{authorizedDomains:e}=await async function(t,e={}){return V(t,"GET","/v1/projects",e)}(t);for(const t of e)try{if(cr(t))return}catch(t){}b(t,"unauthorized-domain")}(t)),this.originValidationPromises[e]}get _shouldInitProactively(){return yt()||ht()||gt()}};class Tr extends class{constructor(t){this.factorId=t}_process(t,e,n){switch(e.type){case"enroll":return this._finalizeEnroll(t,e.credential,n);case"signin":return this._finalizeSignIn(t,e.credential);default:return S("unexpected MultiFactorSessionType")}}}{constructor(t){super("phone"),this.credential=t}static _fromCredential(t){return new Tr(t)}_finalizeEnroll(t,e,n){return function(t,e){return V(t,"POST","/v2/accounts/mfaEnrollment:finalize",U(t,e))}(t,{idToken:e,displayName:n,phoneVerificationInfo:this.credential._makeVerificationRequest()})}_finalizeSignIn(t,e){return function(t,e){return V(t,"POST","/v2/accounts/mfaSignIn:finalize",U(t,e))}(t,{mfaPendingCredential:e,phoneVerificationInfo:this.credential._makeVerificationRequest()})}}class _r{constructor(){}static assertion(t){return Tr._fromCredential(t)}}_r.FACTOR_ID="phone";var Er,Sr="@firebase/auth",kr="0.19.5";class Ar{constructor(t){this.auth=t,this.internalListeners=new Map}getUid(){var t;return this.assertAuthConfigured(),(null===(t=this.auth.currentUser)||void 0===t?void 0:t.uid)||null}async getToken(t){return this.assertAuthConfigured(),await this.auth._initializationPromise,this.auth.currentUser?{accessToken:await this.auth.currentUser.getIdToken(t)}:null}addAuthTokenListener(t){if(this.assertAuthConfigured(),this.internalListeners.has(t))return;const e=this.auth.onIdTokenChanged((e=>{var n;t((null===(n=e)||void 0===n?void 0:n.stsTokenManager.accessToken)||null)}));this.internalListeners.set(t,e),this.updateProactiveRefresh()}removeAuthTokenListener(t){this.assertAuthConfigured();const e=this.internalListeners.get(t);e&&(this.internalListeners.delete(t),e(),this.updateProactiveRefresh())}assertAuthConfigured(){E(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}function Nr(t=(0,i.Mq)()){const e=(0,i.qX)(t,"auth");return e.isInitialized()?e.getImmediate():x(t,{popupRedirectResolver:Ir,persistence:[mn,Je,Xe]})}Er="Browser",(0,i.Xd)(new a.wA("auth",((t,{options:e})=>{const n=t.getProvider("app").getImmediate(),{apiKey:r,authDomain:i}=n.options;return(t=>{E(r&&!r.includes(":"),"invalid-api-key",{appName:t.name}),E(!(null==i?void 0:i.includes(":")),"argument-error",{appName:t.name});const n={apiKey:r,authDomain:i,clientPlatform:Er,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:vt(Er)},s=new bt(t,n);return function(t,e){const n=(null==e?void 0:e.persistence)||[],r=(Array.isArray(n)?n:[n]).map(N);(null==e?void 0:e.errorMap)&&t._updateErrorMap(e.errorMap),t._initializeWithPersistence(r,null==e?void 0:e.popupRedirectResolver)}(s,e),s})(n)}),"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback(((t,e,n)=>{t.getProvider("auth-internal").initialize()}))),(0,i.Xd)(new a.wA("auth-internal",(t=>{return e=wt(t.getProvider("auth").getImmediate()),new Ar(e);var e}),"PRIVATE").setInstantiationMode("EXPLICIT")),(0,i.KN)(Sr,kr,void 0),(0,i.KN)(Sr,kr,"esm2017")},1591:(t,e,n)=>{"use strict";n.r(e),n.d(e,{AbstractUserDataWriter:()=>Sf,Bytes:()=>wd,CACHE_SIZE_UNLIMITED:()=>ed,CollectionReference:()=>Gl,DocumentReference:()=>Kl,DocumentSnapshot:()=>Xd,FieldPath:()=>vd,FieldValue:()=>Id,Firestore:()=>nd,FirestoreError:()=>Rr,GeoPoint:()=>Td,LoadBundleTask:()=>td,Query:()=>Wl,QueryConstraint:()=>of,QueryDocumentSnapshot:()=>tf,QuerySnapshot:()=>ef,SnapshotMetadata:()=>Zd,Timestamp:()=>Qr,Transaction:()=>Wf,WriteBatch:()=>Nf,_DatabaseId:()=>Ol,_DocumentKey:()=>vi,_EmptyAppCheckTokenProvider:()=>zr,_EmptyAuthCredentialsProvider:()=>Mr,_FieldPath:()=>ii,_cast:()=>Vl,_debugAssert:()=>Cr,_isBase64Available:()=>oi,_logWarn:()=>kr,_validateIsNotUsedTogether:()=>Ll,addDoc:()=>jf,arrayRemove:()=>Qf,arrayUnion:()=>Yf,clearIndexedDbPersistence:()=>hd,collection:()=>Hl,collectionGroup:()=>$l,connectFirestoreEmulator:()=>zl,deleteDoc:()=>Vf,deleteField:()=>Hf,disableNetwork:()=>fd,doc:()=>Yl,documentId:()=>bd,enableIndexedDbPersistence:()=>ad,enableMultiTabIndexedDbPersistence:()=>cd,enableNetwork:()=>dd,endAt:()=>wf,endBefore:()=>bf,ensureFirestoreConfigured:()=>sd,executeWrite:()=>zf,getDoc:()=>Cf,getDocFromCache:()=>Of,getDocFromServer:()=>Rf,getDocs:()=>Pf,getDocsFromCache:()=>Lf,getDocsFromServer:()=>Mf,getFirestore:()=>id,increment:()=>Jf,initializeFirestore:()=>rd,limit:()=>ff,limitToLast:()=>pf,loadBundle:()=>md,namedQuery:()=>gd,onSnapshot:()=>qf,onSnapshotsInSync:()=>Bf,orderBy:()=>lf,query:()=>af,queryEqual:()=>Jl,refEqual:()=>Ql,runTransaction:()=>Gf,serverTimestamp:()=>$f,setDoc:()=>Ff,setLogLevel:()=>_r,snapshotEqual:()=>rf,startAfter:()=>yf,startAt:()=>gf,terminate:()=>pd,updateDoc:()=>Uf,waitForPendingWrites:()=>ld,where:()=>uf,writeBatch:()=>Zf});var r,i=n(2238),s=n(8463),o=n(3333),a=n(4444),c="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==n.g?n.g:"undefined"!=typeof self?self:{},u={},h=h||{},l=c||self;function d(){}function f(t){var e=typeof t;return"array"==(e="object"!=e?e:t?Array.isArray(t)?"array":e:"null")||"object"==e&&"number"==typeof t.length}function p(t){var e=typeof t;return"object"==e&&null!=t||"function"==e}var m="closure_uid_"+(1e9*Math.random()>>>0),g=0;function y(t,e,n){return t.call.apply(t.bind,arguments)}function v(t,e,n){if(!t)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),t.apply(e,n)}}return function(){return t.apply(e,arguments)}}function b(t,e,n){return(b=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?y:v).apply(null,arguments)}function w(t,e){var n=Array.prototype.slice.call(arguments,1);return function(){var e=n.slice();return e.push.apply(e,arguments),t.apply(this,e)}}function I(t,e){function n(){}n.prototype=e.prototype,t.Z=e.prototype,t.prototype=new n,t.prototype.constructor=t,t.Vb=function(t,n,r){for(var i=Array(arguments.length-2),s=2;s<arguments.length;s++)i[s-2]=arguments[s];return e.prototype[n].apply(t,i)}}function T(){this.s=this.s,this.o=this.o}var _={};T.prototype.s=!1,T.prototype.na=function(){if(!this.s&&(this.s=!0,this.M(),0)){var t=function(t){return Object.prototype.hasOwnProperty.call(t,m)&&t[m]||(t[m]=++g)}(this);delete _[t]}},T.prototype.M=function(){if(this.o)for(;this.o.length;)this.o.shift()()};const E=Array.prototype.indexOf?function(t,e){return Array.prototype.indexOf.call(t,e,void 0)}:function(t,e){if("string"==typeof t)return"string"!=typeof e||1!=e.length?-1:t.indexOf(e,0);for(let n=0;n<t.length;n++)if(n in t&&t[n]===e)return n;return-1},S=Array.prototype.forEach?function(t,e,n){Array.prototype.forEach.call(t,e,n)}:function(t,e,n){const r=t.length,i="string"==typeof t?t.split(""):t;for(let s=0;s<r;s++)s in i&&e.call(n,i[s],s,t)};function k(t){return Array.prototype.concat.apply([],arguments)}function A(t){const e=t.length;if(0<e){const n=Array(e);for(let r=0;r<e;r++)n[r]=t[r];return n}return[]}function N(t){return/^[\s\xa0]*$/.test(t)}var x,C=String.prototype.trim?function(t){return t.trim()}:function(t){return/^[\s\xa0]*([\s\S]*?)[\s\xa0]*$/.exec(t)[1]};function D(t,e){return-1!=t.indexOf(e)}function O(t,e){return t<e?-1:t>e?1:0}t:{var R=l.navigator;if(R){var P=R.userAgent;if(P){x=P;break t}}x=""}function L(t,e,n){for(const r in t)e.call(n,t[r],r,t)}function M(t){const e={};for(const n in t)e[n]=t[n];return e}var F="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function U(t,e){let n,r;for(let e=1;e<arguments.length;e++){for(n in r=arguments[e],r)t[n]=r[n];for(let e=0;e<F.length;e++)n=F[e],Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}}function V(t){return V[" "](t),t}V[" "]=d;var j,q,B=D(x,"Opera"),z=D(x,"Trident")||D(x,"MSIE"),K=D(x,"Edge"),W=K||z,G=D(x,"Gecko")&&!(D(x.toLowerCase(),"webkit")&&!D(x,"Edge"))&&!(D(x,"Trident")||D(x,"MSIE"))&&!D(x,"Edge"),H=D(x.toLowerCase(),"webkit")&&!D(x,"Edge");function $(){var t=l.document;return t?t.documentMode:void 0}t:{var Y="",Q=(q=x,G?/rv:([^\);]+)(\)|;)/.exec(q):K?/Edge\/([\d\.]+)/.exec(q):z?/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(q):H?/WebKit\/(\S+)/.exec(q):B?/(?:Version)[ \/]?(\S+)/.exec(q):void 0);if(Q&&(Y=Q?Q[1]:""),z){var J=$();if(null!=J&&J>parseFloat(Y)){j=String(J);break t}}j=Y}var Z,X={};function tt(){return t=X,Object.prototype.hasOwnProperty.call(t,9)?t[9]:t[9]=function(){let t=0;const e=C(String(j)).split("."),n=C("9").split("."),r=Math.max(e.length,n.length);for(let o=0;0==t&&o<r;o++){var i=e[o]||"",s=n[o]||"";do{if(i=/(\d*)(\D*)(.*)/.exec(i)||["","","",""],s=/(\d*)(\D*)(.*)/.exec(s)||["","","",""],0==i[0].length&&0==s[0].length)break;t=O(0==i[1].length?0:parseInt(i[1],10),0==s[1].length?0:parseInt(s[1],10))||O(0==i[2].length,0==s[2].length)||O(i[2],s[2]),i=i[3],s=s[3]}while(0==t)}return 0<=t}();var t}l.document&&z?Z=$()||parseInt(j,10)||void 0:Z=void 0;var et=Z,nt=function(){if(!l.addEventListener||!Object.defineProperty)return!1;var t=!1,e=Object.defineProperty({},"passive",{get:function(){t=!0}});try{l.addEventListener("test",d,e),l.removeEventListener("test",d,e)}catch(t){}return t}();function rt(t,e){this.type=t,this.g=this.target=e,this.defaultPrevented=!1}function it(t,e){if(rt.call(this,t?t.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,t){var n=this.type=t.type,r=t.changedTouches&&t.changedTouches.length?t.changedTouches[0]:null;if(this.target=t.target||t.srcElement,this.g=e,e=t.relatedTarget){if(G){t:{try{V(e.nodeName);var i=!0;break t}catch(t){}i=!1}i||(e=null)}}else"mouseover"==n?e=t.fromElement:"mouseout"==n&&(e=t.toElement);this.relatedTarget=e,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!==t.clientX?t.clientX:t.pageX,this.clientY=void 0!==t.clientY?t.clientY:t.pageY,this.screenX=t.screenX||0,this.screenY=t.screenY||0),this.button=t.button,this.key=t.key||"",this.ctrlKey=t.ctrlKey,this.altKey=t.altKey,this.shiftKey=t.shiftKey,this.metaKey=t.metaKey,this.pointerId=t.pointerId||0,this.pointerType="string"==typeof t.pointerType?t.pointerType:st[t.pointerType]||"",this.state=t.state,this.i=t,t.defaultPrevented&&it.Z.h.call(this)}}rt.prototype.h=function(){this.defaultPrevented=!0},I(it,rt);var st={2:"touch",3:"pen",4:"mouse"};it.prototype.h=function(){it.Z.h.call(this);var t=this.i;t.preventDefault?t.preventDefault():t.returnValue=!1};var ot="closure_listenable_"+(1e6*Math.random()|0),at=0;function ct(t,e,n,r,i){this.listener=t,this.proxy=null,this.src=e,this.type=n,this.capture=!!r,this.ia=i,this.key=++at,this.ca=this.fa=!1}function ut(t){t.ca=!0,t.listener=null,t.proxy=null,t.src=null,t.ia=null}function ht(t){this.src=t,this.g={},this.h=0}function lt(t,e){var n=e.type;if(n in t.g){var r,i=t.g[n],s=E(i,e);(r=0<=s)&&Array.prototype.splice.call(i,s,1),r&&(ut(e),0==t.g[n].length&&(delete t.g[n],t.h--))}}function dt(t,e,n,r){for(var i=0;i<t.length;++i){var s=t[i];if(!s.ca&&s.listener==e&&s.capture==!!n&&s.ia==r)return i}return-1}ht.prototype.add=function(t,e,n,r,i){var s=t.toString();(t=this.g[s])||(t=this.g[s]=[],this.h++);var o=dt(t,e,r,i);return-1<o?(e=t[o],n||(e.fa=!1)):((e=new ct(e,this.src,s,!!r,i)).fa=n,t.push(e)),e};var ft="closure_lm_"+(1e6*Math.random()|0),pt={};function mt(t,e,n,r,i){if(r&&r.once)return yt(t,e,n,r,i);if(Array.isArray(e)){for(var s=0;s<e.length;s++)mt(t,e[s],n,r,i);return null}return n=Et(n),t&&t[ot]?t.N(e,n,p(r)?!!r.capture:!!r,i):gt(t,e,n,!1,r,i)}function gt(t,e,n,r,i,s){if(!e)throw Error("Invalid event type");var o=p(i)?!!i.capture:!!i,a=Tt(t);if(a||(t[ft]=a=new ht(t)),(n=a.add(e,n,r,o,s)).proxy)return n;if(r=function(){var t=It;return function e(n){return t.call(e.src,e.listener,n)}}(),n.proxy=r,r.src=t,r.listener=n,t.addEventListener)nt||(i=o),void 0===i&&(i=!1),t.addEventListener(e.toString(),r,i);else if(t.attachEvent)t.attachEvent(wt(e.toString()),r);else{if(!t.addListener||!t.removeListener)throw Error("addEventListener and attachEvent are unavailable.");t.addListener(r)}return n}function yt(t,e,n,r,i){if(Array.isArray(e)){for(var s=0;s<e.length;s++)yt(t,e[s],n,r,i);return null}return n=Et(n),t&&t[ot]?t.O(e,n,p(r)?!!r.capture:!!r,i):gt(t,e,n,!0,r,i)}function vt(t,e,n,r,i){if(Array.isArray(e))for(var s=0;s<e.length;s++)vt(t,e[s],n,r,i);else r=p(r)?!!r.capture:!!r,n=Et(n),t&&t[ot]?(t=t.i,(e=String(e).toString())in t.g&&-1<(n=dt(s=t.g[e],n,r,i))&&(ut(s[n]),Array.prototype.splice.call(s,n,1),0==s.length&&(delete t.g[e],t.h--))):t&&(t=Tt(t))&&(e=t.g[e.toString()],t=-1,e&&(t=dt(e,n,r,i)),(n=-1<t?e[t]:null)&&bt(n))}function bt(t){if("number"!=typeof t&&t&&!t.ca){var e=t.src;if(e&&e[ot])lt(e.i,t);else{var n=t.type,r=t.proxy;e.removeEventListener?e.removeEventListener(n,r,t.capture):e.detachEvent?e.detachEvent(wt(n),r):e.addListener&&e.removeListener&&e.removeListener(r),(n=Tt(e))?(lt(n,t),0==n.h&&(n.src=null,e[ft]=null)):ut(t)}}}function wt(t){return t in pt?pt[t]:pt[t]="on"+t}function It(t,e){if(t.ca)t=!0;else{e=new it(e,this);var n=t.listener,r=t.ia||t.src;t.fa&&bt(t),t=n.call(r,e)}return t}function Tt(t){return(t=t[ft])instanceof ht?t:null}var _t="__closure_events_fn_"+(1e9*Math.random()>>>0);function Et(t){return"function"==typeof t?t:(t[_t]||(t[_t]=function(e){return t.handleEvent(e)}),t[_t])}function St(){T.call(this),this.i=new ht(this),this.P=this,this.I=null}function kt(t,e){var n,r=t.I;if(r)for(n=[];r;r=r.I)n.push(r);if(t=t.P,r=e.type||e,"string"==typeof e)e=new rt(e,t);else if(e instanceof rt)e.target=e.target||t;else{var i=e;U(e=new rt(r,t),i)}if(i=!0,n)for(var s=n.length-1;0<=s;s--){var o=e.g=n[s];i=At(o,r,!0,e)&&i}if(i=At(o=e.g=t,r,!0,e)&&i,i=At(o,r,!1,e)&&i,n)for(s=0;s<n.length;s++)i=At(o=e.g=n[s],r,!1,e)&&i}function At(t,e,n,r){if(!(e=t.i.g[String(e)]))return!0;e=e.concat();for(var i=!0,s=0;s<e.length;++s){var o=e[s];if(o&&!o.ca&&o.capture==n){var a=o.listener,c=o.ia||o.src;o.fa&&lt(t.i,o),i=!1!==a.call(c,r)&&i}}return i&&!r.defaultPrevented}I(St,T),St.prototype[ot]=!0,St.prototype.removeEventListener=function(t,e,n,r){vt(this,t,e,n,r)},St.prototype.M=function(){if(St.Z.M.call(this),this.i){var t,e=this.i;for(t in e.g){for(var n=e.g[t],r=0;r<n.length;r++)ut(n[r]);delete e.g[t],e.h--}}this.I=null},St.prototype.N=function(t,e,n,r){return this.i.add(String(t),e,!1,n,r)},St.prototype.O=function(t,e,n,r){return this.i.add(String(t),e,!0,n,r)};var Nt=l.JSON.stringify;function xt(){var t=Mt;let e=null;return t.g&&(e=t.g,t.g=t.g.next,t.g||(t.h=null),e.next=null),e}var Ct,Dt=new class{constructor(t,e){this.i=t,this.j=e,this.h=0,this.g=null}get(){let t;return 0<this.h?(this.h--,t=this.g,this.g=t.next,t.next=null):t=this.i(),t}}((()=>new Ot),(t=>t.reset()));class Ot{constructor(){this.next=this.g=this.h=null}set(t,e){this.h=t,this.g=e,this.next=null}reset(){this.next=this.g=this.h=null}}function Rt(t){l.setTimeout((()=>{throw t}),0)}function Pt(t,e){Ct||function(){var t=l.Promise.resolve(void 0);Ct=function(){t.then(Ft)}}(),Lt||(Ct(),Lt=!0),Mt.add(t,e)}var Lt=!1,Mt=new class{constructor(){this.h=this.g=null}add(t,e){const n=Dt.get();n.set(t,e),this.h?this.h.next=n:this.g=n,this.h=n}};function Ft(){for(var t;t=xt();){try{t.h.call(t.g)}catch(t){Rt(t)}var e=Dt;e.j(t),100>e.h&&(e.h++,t.next=e.g,e.g=t)}Lt=!1}function Ut(t,e){St.call(this),this.h=t||1,this.g=e||l,this.j=b(this.kb,this),this.l=Date.now()}function Vt(t){t.da=!1,t.S&&(t.g.clearTimeout(t.S),t.S=null)}function jt(t,e,n){if("function"==typeof t)n&&(t=b(t,n));else{if(!t||"function"!=typeof t.handleEvent)throw Error("Invalid listener argument");t=b(t.handleEvent,t)}return 2147483647<Number(e)?-1:l.setTimeout(t,e||0)}function qt(t){t.g=jt((()=>{t.g=null,t.i&&(t.i=!1,qt(t))}),t.j);const e=t.h;t.h=null,t.m.apply(null,e)}I(Ut,St),(r=Ut.prototype).da=!1,r.S=null,r.kb=function(){if(this.da){var t=Date.now()-this.l;0<t&&t<.8*this.h?this.S=this.g.setTimeout(this.j,this.h-t):(this.S&&(this.g.clearTimeout(this.S),this.S=null),kt(this,"tick"),this.da&&(Vt(this),this.start()))}},r.start=function(){this.da=!0,this.S||(this.S=this.g.setTimeout(this.j,this.h),this.l=Date.now())},r.M=function(){Ut.Z.M.call(this),Vt(this),delete this.g};class Bt extends T{constructor(t,e){super(),this.m=t,this.j=e,this.h=null,this.i=!1,this.g=null}l(t){this.h=arguments,this.g?this.i=!0:qt(this)}M(){super.M(),this.g&&(l.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function zt(t){T.call(this),this.h=t,this.g={}}I(zt,T);var Kt=[];function Wt(t,e,n,r){Array.isArray(n)||(n&&(Kt[0]=n.toString()),n=Kt);for(var i=0;i<n.length;i++){var s=mt(e,n[i],r||t.handleEvent,!1,t.h||t);if(!s)break;t.g[s.key]=s}}function Gt(t){L(t.g,(function(t,e){this.g.hasOwnProperty(e)&&bt(t)}),t),t.g={}}function Ht(){this.g=!0}function $t(t,e,n,r){t.info((function(){return"XMLHTTP TEXT ("+e+"): "+function(t,e){if(!t.g)return e;if(!e)return null;try{var n=JSON.parse(e);if(n)for(t=0;t<n.length;t++)if(Array.isArray(n[t])){var r=n[t];if(!(2>r.length)){var i=r[1];if(Array.isArray(i)&&!(1>i.length)){var s=i[0];if("noop"!=s&&"stop"!=s&&"close"!=s)for(var o=1;o<i.length;o++)i[o]=""}}}return Nt(n)}catch(t){return e}}(t,n)+(r?" "+r:"")}))}zt.prototype.M=function(){zt.Z.M.call(this),Gt(this)},zt.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")},Ht.prototype.Aa=function(){this.g=!1},Ht.prototype.info=function(){};var Yt={},Qt=null;function Jt(){return Qt=Qt||new St}function Zt(t){rt.call(this,Yt.Ma,t)}function Xt(t){const e=Jt();kt(e,new Zt(e,t))}function te(t,e){rt.call(this,Yt.STAT_EVENT,t),this.stat=e}function ee(t){const e=Jt();kt(e,new te(e,t))}function ne(t,e){rt.call(this,Yt.Na,t),this.size=e}function re(t,e){if("function"!=typeof t)throw Error("Fn must not be null and must be a function");return l.setTimeout((function(){t()}),e)}Yt.Ma="serverreachability",I(Zt,rt),Yt.STAT_EVENT="statevent",I(te,rt),Yt.Na="timingevent",I(ne,rt);var ie={NO_ERROR:0,lb:1,yb:2,xb:3,sb:4,wb:5,zb:6,Ja:7,TIMEOUT:8,Cb:9},se={qb:"complete",Mb:"success",Ka:"error",Ja:"abort",Eb:"ready",Fb:"readystatechange",TIMEOUT:"timeout",Ab:"incrementaldata",Db:"progress",tb:"downloadprogress",Ub:"uploadprogress"};function oe(){}function ae(t){return t.h||(t.h=t.i())}function ce(){}oe.prototype.h=null;var ue,he={OPEN:"a",pb:"b",Ka:"c",Bb:"d"};function le(){rt.call(this,"d")}function de(){rt.call(this,"c")}function fe(){}function pe(t,e,n,r){this.l=t,this.j=e,this.m=n,this.X=r||1,this.V=new zt(this),this.P=ge,t=W?125:void 0,this.W=new Ut(t),this.H=null,this.i=!1,this.s=this.A=this.v=this.K=this.F=this.Y=this.B=null,this.D=[],this.g=null,this.C=0,this.o=this.u=null,this.N=-1,this.I=!1,this.O=0,this.L=null,this.aa=this.J=this.$=this.U=!1,this.h=new me}function me(){this.i=null,this.g="",this.h=!1}I(le,rt),I(de,rt),I(fe,oe),fe.prototype.g=function(){return new XMLHttpRequest},fe.prototype.i=function(){return{}},ue=new fe;var ge=45e3,ye={},ve={};function be(t,e,n){t.K=1,t.v=Be(Me(e)),t.s=n,t.U=!0,we(t,null)}function we(t,e){t.F=Date.now(),Ee(t),t.A=Me(t.v);var n=t.A,r=t.X;Array.isArray(r)||(r=[String(r)]),en(n.h,"t",r),t.C=0,n=t.l.H,t.h=new me,t.g=nr(t.l,n?e:null,!t.s),0<t.O&&(t.L=new Bt(b(t.Ia,t,t.g),t.O)),Wt(t.V,t.g,"readystatechange",t.gb),e=t.H?M(t.H):{},t.s?(t.u||(t.u="POST"),e["Content-Type"]="application/x-www-form-urlencoded",t.g.ea(t.A,t.u,t.s,e)):(t.u="GET",t.g.ea(t.A,t.u,null,e)),Xt(1),function(t,e,n,r,i,s){t.info((function(){if(t.g)if(s)for(var o="",a=s.split("&"),c=0;c<a.length;c++){var u=a[c].split("=");if(1<u.length){var h=u[0];u=u[1];var l=h.split("_");o=2<=l.length&&"type"==l[1]?o+(h+"=")+u+"&":o+(h+"=redacted&")}}else o=null;else o=s;return"XMLHTTP REQ ("+r+") [attempt "+i+"]: "+e+"\n"+n+"\n"+o}))}(t.j,t.u,t.A,t.m,t.X,t.s)}function Ie(t){return!!t.g&&"GET"==t.u&&2!=t.K&&t.l.Ba}function Te(t,e,n){let r,i=!0;for(;!t.I&&t.C<n.length;){if(r=_e(t,n),r==ve){4==e&&(t.o=4,ee(14),i=!1),$t(t.j,t.m,null,"[Incomplete Response]");break}if(r==ye){t.o=4,ee(15),$t(t.j,t.m,n,"[Invalid Chunk]"),i=!1;break}$t(t.j,t.m,r,null),xe(t,r)}Ie(t)&&r!=ve&&r!=ye&&(t.h.g="",t.C=0),4!=e||0!=n.length||t.h.h||(t.o=1,ee(16),i=!1),t.i=t.i&&i,i?0<n.length&&!t.aa&&(t.aa=!0,(e=t.l).g==t&&e.$&&!e.L&&(e.h.info("Great, no buffering proxy detected. Bytes received: "+n.length),$n(e),e.L=!0,ee(11))):($t(t.j,t.m,n,"[Invalid Chunked Response]"),Ne(t),Ae(t))}function _e(t,e){var n=t.C,r=e.indexOf("\n",n);return-1==r?ve:(n=Number(e.substring(n,r)),isNaN(n)?ye:(r+=1)+n>e.length?ve:(e=e.substr(r,n),t.C=r+n,e))}function Ee(t){t.Y=Date.now()+t.P,Se(t,t.P)}function Se(t,e){if(null!=t.B)throw Error("WatchDog timer not null");t.B=re(b(t.eb,t),e)}function ke(t){t.B&&(l.clearTimeout(t.B),t.B=null)}function Ae(t){0==t.l.G||t.I||Jn(t.l,t)}function Ne(t){ke(t);var e=t.L;e&&"function"==typeof e.na&&e.na(),t.L=null,Vt(t.W),Gt(t.V),t.g&&(e=t.g,t.g=null,e.abort(),e.na())}function xe(t,e){try{var n=t.l;if(0!=n.G&&(n.g==t||cn(n.i,t)))if(n.I=t.N,!t.J&&cn(n.i,t)&&3==n.G){try{var r=n.Ca.g.parse(e)}catch(t){r=null}if(Array.isArray(r)&&3==r.length){var i=r;if(0==i[0]){t:if(!n.u){if(n.g){if(!(n.g.F+3e3<t.F))break t;Qn(n),Vn(n)}Hn(n),ee(18)}}else n.ta=i[1],0<n.ta-n.U&&37500>i[2]&&n.N&&0==n.A&&!n.v&&(n.v=re(b(n.ab,n),6e3));if(1>=an(n.i)&&n.ka){try{n.ka()}catch(t){}n.ka=void 0}}else Xn(n,11)}else if((t.J||n.g==t)&&Qn(n),!N(e))for(i=n.Ca.g.parse(e),e=0;e<i.length;e++){let u=i[e];if(n.U=u[0],u=u[1],2==n.G)if("c"==u[0]){n.J=u[1],n.la=u[2];const e=u[3];null!=e&&(n.ma=e,n.h.info("VER="+n.ma));const i=u[4];null!=i&&(n.za=i,n.h.info("SVER="+n.za));const h=u[5];null!=h&&"number"==typeof h&&0<h&&(r=1.5*h,n.K=r,n.h.info("backChannelRequestTimeoutMs_="+r)),r=n;const l=t.g;if(l){const t=l.g?l.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(t){var s=r.i;!s.g&&(D(t,"spdy")||D(t,"quic")||D(t,"h2"))&&(s.j=s.l,s.g=new Set,s.h&&(un(s,s.h),s.h=null))}if(r.D){const t=l.g?l.g.getResponseHeader("X-HTTP-Session-Id"):null;t&&(r.sa=t,qe(r.F,r.D,t))}}n.G=3,n.j&&n.j.xa(),n.$&&(n.O=Date.now()-t.F,n.h.info("Handshake RTT: "+n.O+"ms"));var o=t;if((r=n).oa=er(r,r.H?r.la:null,r.W),o.J){hn(r.i,o);var a=o,c=r.K;c&&a.setTimeout(c),a.B&&(ke(a),Ee(a)),r.g=o}else Gn(r);0<n.l.length&&Bn(n)}else"stop"!=u[0]&&"close"!=u[0]||Xn(n,7);else 3==n.G&&("stop"==u[0]||"close"==u[0]?"stop"==u[0]?Xn(n,7):Un(n):"noop"!=u[0]&&n.j&&n.j.wa(u),n.A=0)}Xt(4)}catch(t){}}function Ce(t,e){if(t.forEach&&"function"==typeof t.forEach)t.forEach(e,void 0);else if(f(t)||"string"==typeof t)S(t,e,void 0);else{if(t.T&&"function"==typeof t.T)var n=t.T();else if(t.R&&"function"==typeof t.R)n=void 0;else if(f(t)||"string"==typeof t){n=[];for(var r=t.length,i=0;i<r;i++)n.push(i)}else for(i in n=[],r=0,t)n[r++]=i;r=function(t){if(t.R&&"function"==typeof t.R)return t.R();if("string"==typeof t)return t.split("");if(f(t)){for(var e=[],n=t.length,r=0;r<n;r++)e.push(t[r]);return e}for(r in e=[],n=0,t)e[n++]=t[r];return e}(t),i=r.length;for(var s=0;s<i;s++)e.call(void 0,r[s],n&&n[s],t)}}function De(t,e){this.h={},this.g=[],this.i=0;var n=arguments.length;if(1<n){if(n%2)throw Error("Uneven number of arguments");for(var r=0;r<n;r+=2)this.set(arguments[r],arguments[r+1])}else if(t)if(t instanceof De)for(n=t.T(),r=0;r<n.length;r++)this.set(n[r],t.get(n[r]));else for(r in t)this.set(r,t[r])}function Oe(t){if(t.i!=t.g.length){for(var e=0,n=0;e<t.g.length;){var r=t.g[e];Re(t.h,r)&&(t.g[n++]=r),e++}t.g.length=n}if(t.i!=t.g.length){var i={};for(n=e=0;e<t.g.length;)Re(i,r=t.g[e])||(t.g[n++]=r,i[r]=1),e++;t.g.length=n}}function Re(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(r=pe.prototype).setTimeout=function(t){this.P=t},r.gb=function(t){t=t.target;const e=this.L;e&&3==Rn(t)?e.l():this.Ia(t)},r.Ia=function(t){try{if(t==this.g)t:{const h=Rn(this.g);var e=this.g.Da();const d=this.g.ba();if(!(3>h)&&(3!=h||W||this.g&&(this.h.h||this.g.ga()||Pn(this.g)))){this.I||4!=h||7==e||Xt(8==e||0>=d?3:2),ke(this);var n=this.g.ba();this.N=n;e:if(Ie(this)){var r=Pn(this.g);t="";var i=r.length,s=4==Rn(this.g);if(!this.h.i){if("undefined"==typeof TextDecoder){Ne(this),Ae(this);var o="";break e}this.h.i=new l.TextDecoder}for(e=0;e<i;e++)this.h.h=!0,t+=this.h.i.decode(r[e],{stream:s&&e==i-1});r.splice(0,i),this.h.g+=t,this.C=0,o=this.h.g}else o=this.g.ga();if(this.i=200==n,function(t,e,n,r,i,s,o){t.info((function(){return"XMLHTTP RESP ("+r+") [ attempt "+i+"]: "+e+"\n"+n+"\n"+s+" "+o}))}(this.j,this.u,this.A,this.m,this.X,h,n),this.i){if(this.$&&!this.J){e:{if(this.g){var a,c=this.g;if((a=c.g?c.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!N(a)){var u=a;break e}}u=null}if(!(n=u)){this.i=!1,this.o=3,ee(12),Ne(this),Ae(this);break t}$t(this.j,this.m,n,"Initial handshake response via X-HTTP-Initial-Response"),this.J=!0,xe(this,n)}this.U?(Te(this,h,o),W&&this.i&&3==h&&(Wt(this.V,this.W,"tick",this.fb),this.W.start())):($t(this.j,this.m,o,null),xe(this,o)),4==h&&Ne(this),this.i&&!this.I&&(4==h?Jn(this.l,this):(this.i=!1,Ee(this)))}else 400==n&&0<o.indexOf("Unknown SID")?(this.o=3,ee(12)):(this.o=0,ee(13)),Ne(this),Ae(this)}}}catch(t){}},r.fb=function(){if(this.g){var t=Rn(this.g),e=this.g.ga();this.C<e.length&&(ke(this),Te(this,t,e),this.i&&4!=t&&Ee(this))}},r.cancel=function(){this.I=!0,Ne(this)},r.eb=function(){this.B=null;const t=Date.now();0<=t-this.Y?(function(t,e){t.info((function(){return"TIMEOUT: "+e}))}(this.j,this.A),2!=this.K&&(Xt(3),ee(17)),Ne(this),this.o=2,Ae(this)):Se(this,this.Y-t)},(r=De.prototype).R=function(){Oe(this);for(var t=[],e=0;e<this.g.length;e++)t.push(this.h[this.g[e]]);return t},r.T=function(){return Oe(this),this.g.concat()},r.get=function(t,e){return Re(this.h,t)?this.h[t]:e},r.set=function(t,e){Re(this.h,t)||(this.i++,this.g.push(t)),this.h[t]=e},r.forEach=function(t,e){for(var n=this.T(),r=0;r<n.length;r++){var i=n[r],s=this.get(i);t.call(e,s,i,this)}};var Pe=/^(?:([^:/?#.]+):)?(?:\/\/(?:([^\\/?#]*)@)?([^\\/?#]*?)(?::([0-9]+))?(?=[\\/?#]|$))?([^?#]+)?(?:\?([^#]*))?(?:#([\s\S]*))?$/;function Le(t,e){if(this.i=this.s=this.j="",this.m=null,this.o=this.l="",this.g=!1,t instanceof Le){this.g=void 0!==e?e:t.g,Fe(this,t.j),this.s=t.s,Ue(this,t.i),Ve(this,t.m),this.l=t.l,e=t.h;var n=new Je;n.i=e.i,e.g&&(n.g=new De(e.g),n.h=e.h),je(this,n),this.o=t.o}else t&&(n=String(t).match(Pe))?(this.g=!!e,Fe(this,n[1]||"",!0),this.s=ze(n[2]||""),Ue(this,n[3]||"",!0),Ve(this,n[4]),this.l=ze(n[5]||"",!0),je(this,n[6]||"",!0),this.o=ze(n[7]||"")):(this.g=!!e,this.h=new Je(null,this.g))}function Me(t){return new Le(t)}function Fe(t,e,n){t.j=n?ze(e,!0):e,t.j&&(t.j=t.j.replace(/:$/,""))}function Ue(t,e,n){t.i=n?ze(e,!0):e}function Ve(t,e){if(e){if(e=Number(e),isNaN(e)||0>e)throw Error("Bad port number "+e);t.m=e}else t.m=null}function je(t,e,n){e instanceof Je?(t.h=e,function(t,e){e&&!t.j&&(Ze(t),t.i=null,t.g.forEach((function(t,e){var n=e.toLowerCase();e!=n&&(Xe(this,e),en(this,n,t))}),t)),t.j=e}(t.h,t.g)):(n||(e=Ke(e,Ye)),t.h=new Je(e,t.g))}function qe(t,e,n){t.h.set(e,n)}function Be(t){return qe(t,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)),t}function ze(t,e){return t?e?decodeURI(t.replace(/%25/g,"%2525")):decodeURIComponent(t):""}function Ke(t,e,n){return"string"==typeof t?(t=encodeURI(t).replace(e,We),n&&(t=t.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),t):null}function We(t){return"%"+((t=t.charCodeAt(0))>>4&15).toString(16)+(15&t).toString(16)}Le.prototype.toString=function(){var t=[],e=this.j;e&&t.push(Ke(e,Ge,!0),":");var n=this.i;return(n||"file"==e)&&(t.push("//"),(e=this.s)&&t.push(Ke(e,Ge,!0),"@"),t.push(encodeURIComponent(String(n)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),null!=(n=this.m)&&t.push(":",String(n))),(n=this.l)&&(this.i&&"/"!=n.charAt(0)&&t.push("/"),t.push(Ke(n,"/"==n.charAt(0)?$e:He,!0))),(n=this.h.toString())&&t.push("?",n),(n=this.o)&&t.push("#",Ke(n,Qe)),t.join("")};var Ge=/[#\/\?@]/g,He=/[#\?:]/g,$e=/[#\?]/g,Ye=/[#\?@]/g,Qe=/#/g;function Je(t,e){this.h=this.g=null,this.i=t||null,this.j=!!e}function Ze(t){t.g||(t.g=new De,t.h=0,t.i&&function(t,e){if(t){t=t.split("&");for(var n=0;n<t.length;n++){var r=t[n].indexOf("="),i=null;if(0<=r){var s=t[n].substring(0,r);i=t[n].substring(r+1)}else s=t[n];e(s,i?decodeURIComponent(i.replace(/\+/g," ")):"")}}}(t.i,(function(e,n){t.add(decodeURIComponent(e.replace(/\+/g," ")),n)})))}function Xe(t,e){Ze(t),e=nn(t,e),Re(t.g.h,e)&&(t.i=null,t.h-=t.g.get(e).length,Re((t=t.g).h,e)&&(delete t.h[e],t.i--,t.g.length>2*t.i&&Oe(t)))}function tn(t,e){return Ze(t),e=nn(t,e),Re(t.g.h,e)}function en(t,e,n){Xe(t,e),0<n.length&&(t.i=null,t.g.set(nn(t,e),A(n)),t.h+=n.length)}function nn(t,e){return e=String(e),t.j&&(e=e.toLowerCase()),e}function rn(t){this.l=t||sn,t=l.PerformanceNavigationTiming?0<(t=l.performance.getEntriesByType("navigation")).length&&("hq"==t[0].nextHopProtocol||"h2"==t[0].nextHopProtocol):!!(l.g&&l.g.Ea&&l.g.Ea()&&l.g.Ea().Zb),this.j=t?this.l:1,this.g=null,1<this.j&&(this.g=new Set),this.h=null,this.i=[]}(r=Je.prototype).add=function(t,e){Ze(this),this.i=null,t=nn(this,t);var n=this.g.get(t);return n||this.g.set(t,n=[]),n.push(e),this.h+=1,this},r.forEach=function(t,e){Ze(this),this.g.forEach((function(n,r){S(n,(function(n){t.call(e,n,r,this)}),this)}),this)},r.T=function(){Ze(this);for(var t=this.g.R(),e=this.g.T(),n=[],r=0;r<e.length;r++)for(var i=t[r],s=0;s<i.length;s++)n.push(e[r]);return n},r.R=function(t){Ze(this);var e=[];if("string"==typeof t)tn(this,t)&&(e=k(e,this.g.get(nn(this,t))));else{t=this.g.R();for(var n=0;n<t.length;n++)e=k(e,t[n])}return e},r.set=function(t,e){return Ze(this),this.i=null,tn(this,t=nn(this,t))&&(this.h-=this.g.get(t).length),this.g.set(t,[e]),this.h+=1,this},r.get=function(t,e){return t&&0<(t=this.R(t)).length?String(t[0]):e},r.toString=function(){if(this.i)return this.i;if(!this.g)return"";for(var t=[],e=this.g.T(),n=0;n<e.length;n++){var r=e[n],i=encodeURIComponent(String(r));r=this.R(r);for(var s=0;s<r.length;s++){var o=i;""!==r[s]&&(o+="="+encodeURIComponent(String(r[s]))),t.push(o)}}return this.i=t.join("&")};var sn=10;function on(t){return!!t.h||!!t.g&&t.g.size>=t.j}function an(t){return t.h?1:t.g?t.g.size:0}function cn(t,e){return t.h?t.h==e:!!t.g&&t.g.has(e)}function un(t,e){t.g?t.g.add(e):t.h=e}function hn(t,e){t.h&&t.h==e?t.h=null:t.g&&t.g.has(e)&&t.g.delete(e)}function ln(t){if(null!=t.h)return t.i.concat(t.h.D);if(null!=t.g&&0!==t.g.size){let e=t.i;for(const n of t.g.values())e=e.concat(n.D);return e}return A(t.i)}function dn(){}function fn(){this.g=new dn}function pn(t,e,n){const r=n||"";try{Ce(t,(function(t,n){let i=t;p(t)&&(i=Nt(t)),e.push(r+n+"="+encodeURIComponent(i))}))}catch(t){throw e.push(r+"type="+encodeURIComponent("_badmap")),t}}function mn(t,e,n,r,i){try{e.onload=null,e.onerror=null,e.onabort=null,e.ontimeout=null,i(r)}catch(t){}}function gn(t){this.l=t.$b||null,this.j=t.ib||!1}function yn(t,e){St.call(this),this.D=t,this.u=e,this.m=void 0,this.readyState=vn,this.status=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.v=new Headers,this.h=null,this.C="GET",this.B="",this.g=!1,this.A=this.j=this.l=null}rn.prototype.cancel=function(){if(this.i=ln(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&0!==this.g.size){for(const t of this.g.values())t.cancel();this.g.clear()}},dn.prototype.stringify=function(t){return l.JSON.stringify(t,void 0)},dn.prototype.parse=function(t){return l.JSON.parse(t,void 0)},I(gn,oe),gn.prototype.g=function(){return new yn(this.l,this.j)},gn.prototype.i=function(t){return function(){return t}}({}),I(yn,St);var vn=0;function bn(t){t.j.read().then(t.Sa.bind(t)).catch(t.ha.bind(t))}function wn(t){t.readyState=4,t.l=null,t.j=null,t.A=null,In(t)}function In(t){t.onreadystatechange&&t.onreadystatechange.call(t)}(r=yn.prototype).open=function(t,e){if(this.readyState!=vn)throw this.abort(),Error("Error reopening a connection");this.C=t,this.B=e,this.readyState=1,In(this)},r.send=function(t){if(1!=this.readyState)throw this.abort(),Error("need to call open() first. ");this.g=!0;const e={headers:this.v,method:this.C,credentials:this.m,cache:void 0};t&&(e.body=t),(this.D||l).fetch(new Request(this.B,e)).then(this.Va.bind(this),this.ha.bind(this))},r.abort=function(){this.response=this.responseText="",this.v=new Headers,this.status=0,this.j&&this.j.cancel("Request was aborted."),1<=this.readyState&&this.g&&4!=this.readyState&&(this.g=!1,wn(this)),this.readyState=vn},r.Va=function(t){if(this.g&&(this.l=t,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=t.headers,this.readyState=2,In(this)),this.g&&(this.readyState=3,In(this),this.g)))if("arraybuffer"===this.responseType)t.arrayBuffer().then(this.Ta.bind(this),this.ha.bind(this));else if(void 0!==l.ReadableStream&&"body"in t){if(this.j=t.body.getReader(),this.u){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.A=new TextDecoder;bn(this)}else t.text().then(this.Ua.bind(this),this.ha.bind(this))},r.Sa=function(t){if(this.g){if(this.u&&t.value)this.response.push(t.value);else if(!this.u){var e=t.value?t.value:new Uint8Array(0);(e=this.A.decode(e,{stream:!t.done}))&&(this.response=this.responseText+=e)}t.done?wn(this):In(this),3==this.readyState&&bn(this)}},r.Ua=function(t){this.g&&(this.response=this.responseText=t,wn(this))},r.Ta=function(t){this.g&&(this.response=t,wn(this))},r.ha=function(){this.g&&wn(this)},r.setRequestHeader=function(t,e){this.v.append(t,e)},r.getResponseHeader=function(t){return this.h&&this.h.get(t.toLowerCase())||""},r.getAllResponseHeaders=function(){if(!this.h)return"";const t=[],e=this.h.entries();for(var n=e.next();!n.done;)n=n.value,t.push(n[0]+": "+n[1]),n=e.next();return t.join("\r\n")},Object.defineProperty(yn.prototype,"withCredentials",{get:function(){return"include"===this.m},set:function(t){this.m=t?"include":"same-origin"}});var Tn=l.JSON.parse;function _n(t){St.call(this),this.headers=new De,this.u=t||null,this.h=!1,this.C=this.g=null,this.H="",this.m=0,this.j="",this.l=this.F=this.v=this.D=!1,this.B=0,this.A=null,this.J=En,this.K=this.L=!1}I(_n,St);var En="",Sn=/^https?$/i,kn=["POST","PUT"];function An(t){return"content-type"==t.toLowerCase()}function Nn(t,e){t.h=!1,t.g&&(t.l=!0,t.g.abort(),t.l=!1),t.j=e,t.m=5,xn(t),Dn(t)}function xn(t){t.D||(t.D=!0,kt(t,"complete"),kt(t,"error"))}function Cn(t){if(t.h&&void 0!==h&&(!t.C[1]||4!=Rn(t)||2!=t.ba()))if(t.v&&4==Rn(t))jt(t.Fa,0,t);else if(kt(t,"readystatechange"),4==Rn(t)){t.h=!1;try{const a=t.ba();t:switch(a){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var e=!0;break t;default:e=!1}var n;if(!(n=e)){var r;if(r=0===a){var i=String(t.H).match(Pe)[1]||null;if(!i&&l.self&&l.self.location){var s=l.self.location.protocol;i=s.substr(0,s.length-1)}r=!Sn.test(i?i.toLowerCase():"")}n=r}if(n)kt(t,"complete"),kt(t,"success");else{t.m=6;try{var o=2<Rn(t)?t.g.statusText:""}catch(t){o=""}t.j=o+" ["+t.ba()+"]",xn(t)}}finally{Dn(t)}}}function Dn(t,e){if(t.g){On(t);const n=t.g,r=t.C[0]?d:null;t.g=null,t.C=null,e||kt(t,"ready");try{n.onreadystatechange=r}catch(t){}}}function On(t){t.g&&t.K&&(t.g.ontimeout=null),t.A&&(l.clearTimeout(t.A),t.A=null)}function Rn(t){return t.g?t.g.readyState:0}function Pn(t){try{if(!t.g)return null;if("response"in t.g)return t.g.response;switch(t.J){case En:case"text":return t.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in t.g)return t.g.mozResponseArrayBuffer}return null}catch(t){return null}}function Ln(t,e,n){t:{for(r in n){var r=!1;break t}r=!0}r||(n=function(t){let e="";return L(t,(function(t,n){e+=n,e+=":",e+=t,e+="\r\n"})),e}(n),"string"==typeof t?null!=n&&encodeURIComponent(String(n)):qe(t,e,n))}function Mn(t,e,n){return n&&n.internalChannelParams&&n.internalChannelParams[t]||e}function Fn(t){this.za=0,this.l=[],this.h=new Ht,this.la=this.oa=this.F=this.W=this.g=this.sa=this.D=this.aa=this.o=this.P=this.s=null,this.Za=this.V=0,this.Xa=Mn("failFast",!1,t),this.N=this.v=this.u=this.m=this.j=null,this.X=!0,this.I=this.ta=this.U=-1,this.Y=this.A=this.C=0,this.Pa=Mn("baseRetryDelayMs",5e3,t),this.$a=Mn("retryDelaySeedMs",1e4,t),this.Ya=Mn("forwardChannelMaxRetries",2,t),this.ra=Mn("forwardChannelRequestTimeoutMs",2e4,t),this.qa=t&&t.xmlHttpFactory||void 0,this.Ba=t&&t.Yb||!1,this.K=void 0,this.H=t&&t.supportsCrossDomainXhr||!1,this.J="",this.i=new rn(t&&t.concurrentRequestLimit),this.Ca=new fn,this.ja=t&&t.fastHandshake||!1,this.Ra=t&&t.Wb||!1,t&&t.Aa&&this.h.Aa(),t&&t.forceLongPolling&&(this.X=!1),this.$=!this.ja&&this.X&&t&&t.detectBufferingProxy||!1,this.ka=void 0,this.O=0,this.L=!1,this.B=null,this.Wa=!t||!1!==t.Xb}function Un(t){if(jn(t),3==t.G){var e=t.V++,n=Me(t.F);qe(n,"SID",t.J),qe(n,"RID",e),qe(n,"TYPE","terminate"),Kn(t,n),(e=new pe(t,t.h,e,void 0)).K=2,e.v=Be(Me(n)),n=!1,l.navigator&&l.navigator.sendBeacon&&(n=l.navigator.sendBeacon(e.v.toString(),"")),!n&&l.Image&&((new Image).src=e.v,n=!0),n||(e.g=nr(e.l,null),e.g.ea(e.v)),e.F=Date.now(),Ee(e)}tr(t)}function Vn(t){t.g&&($n(t),t.g.cancel(),t.g=null)}function jn(t){Vn(t),t.u&&(l.clearTimeout(t.u),t.u=null),Qn(t),t.i.cancel(),t.m&&("number"==typeof t.m&&l.clearTimeout(t.m),t.m=null)}function qn(t,e){t.l.push(new class{constructor(t,e){this.h=t,this.g=e}}(t.Za++,e)),3==t.G&&Bn(t)}function Bn(t){on(t.i)||t.m||(t.m=!0,Pt(t.Ha,t),t.C=0)}function zn(t,e){var n;n=e?e.m:t.V++;const r=Me(t.F);qe(r,"SID",t.J),qe(r,"RID",n),qe(r,"AID",t.U),Kn(t,r),t.o&&t.s&&Ln(r,t.o,t.s),n=new pe(t,t.h,n,t.C+1),null===t.o&&(n.H=t.s),e&&(t.l=e.D.concat(t.l)),e=Wn(t,n,1e3),n.setTimeout(Math.round(.5*t.ra)+Math.round(.5*t.ra*Math.random())),un(t.i,n),be(n,r,e)}function Kn(t,e){t.j&&Ce({},(function(t,n){qe(e,n,t)}))}function Wn(t,e,n){n=Math.min(t.l.length,n);var r=t.j?b(t.j.Oa,t.j,t):null;t:{var i=t.l;let e=-1;for(;;){const t=["count="+n];-1==e?0<n?(e=i[0].h,t.push("ofs="+e)):e=0:t.push("ofs="+e);let s=!0;for(let o=0;o<n;o++){let n=i[o].h;const a=i[o].g;if(n-=e,0>n)e=Math.max(0,i[o].h-100),s=!1;else try{pn(a,t,"req"+n+"_")}catch(t){r&&r(a)}}if(s){r=t.join("&");break t}}}return t=t.l.splice(0,n),e.D=t,r}function Gn(t){t.g||t.u||(t.Y=1,Pt(t.Ga,t),t.A=0)}function Hn(t){return!(t.g||t.u||3<=t.A||(t.Y++,t.u=re(b(t.Ga,t),Zn(t,t.A)),t.A++,0))}function $n(t){null!=t.B&&(l.clearTimeout(t.B),t.B=null)}function Yn(t){t.g=new pe(t,t.h,"rpc",t.Y),null===t.o&&(t.g.H=t.s),t.g.O=0;var e=Me(t.oa);qe(e,"RID","rpc"),qe(e,"SID",t.J),qe(e,"CI",t.N?"0":"1"),qe(e,"AID",t.U),Kn(t,e),qe(e,"TYPE","xmlhttp"),t.o&&t.s&&Ln(e,t.o,t.s),t.K&&t.g.setTimeout(t.K);var n=t.g;t=t.la,n.K=1,n.v=Be(Me(e)),n.s=null,n.U=!0,we(n,t)}function Qn(t){null!=t.v&&(l.clearTimeout(t.v),t.v=null)}function Jn(t,e){var n=null;if(t.g==e){Qn(t),$n(t),t.g=null;var r=2}else{if(!cn(t.i,e))return;n=e.D,hn(t.i,e),r=1}if(t.I=e.N,0!=t.G)if(e.i)if(1==r){n=e.s?e.s.length:0,e=Date.now()-e.F;var i=t.C;kt(r=Jt(),new ne(r,n,e,i)),Bn(t)}else Gn(t);else if(3==(i=e.o)||0==i&&0<t.I||!(1==r&&function(t,e){return!(an(t.i)>=t.i.j-(t.m?1:0)||(t.m?(t.l=e.D.concat(t.l),0):1==t.G||2==t.G||t.C>=(t.Xa?0:t.Ya)||(t.m=re(b(t.Ha,t,e),Zn(t,t.C)),t.C++,0)))}(t,e)||2==r&&Hn(t)))switch(n&&0<n.length&&(e=t.i,e.i=e.i.concat(n)),i){case 1:Xn(t,5);break;case 4:Xn(t,10);break;case 3:Xn(t,6);break;default:Xn(t,2)}}function Zn(t,e){let n=t.Pa+Math.floor(Math.random()*t.$a);return t.j||(n*=2),n*e}function Xn(t,e){if(t.h.info("Error code "+e),2==e){var n=null;t.j&&(n=null);var r=b(t.jb,t);n||(n=new Le("//www.google.com/images/cleardot.gif"),l.location&&"http"==l.location.protocol||Fe(n,"https"),Be(n)),function(t,e){const n=new Ht;if(l.Image){const r=new Image;r.onload=w(mn,n,r,"TestLoadImage: loaded",!0,e),r.onerror=w(mn,n,r,"TestLoadImage: error",!1,e),r.onabort=w(mn,n,r,"TestLoadImage: abort",!1,e),r.ontimeout=w(mn,n,r,"TestLoadImage: timeout",!1,e),l.setTimeout((function(){r.ontimeout&&r.ontimeout()}),1e4),r.src=t}else e(!1)}(n.toString(),r)}else ee(2);t.G=0,t.j&&t.j.va(e),tr(t),jn(t)}function tr(t){t.G=0,t.I=-1,t.j&&(0==ln(t.i).length&&0==t.l.length||(t.i.i.length=0,A(t.l),t.l.length=0),t.j.ua())}function er(t,e,n){let r=function(t){return t instanceof Le?Me(t):new Le(t,void 0)}(n);if(""!=r.i)e&&Ue(r,e+"."+r.i),Ve(r,r.m);else{const t=l.location;r=function(t,e,n,r){var i=new Le(null,void 0);return t&&Fe(i,t),e&&Ue(i,e),n&&Ve(i,n),r&&(i.l=r),i}(t.protocol,e?e+"."+t.hostname:t.hostname,+t.port,n)}return t.aa&&L(t.aa,(function(t,e){qe(r,e,t)})),e=t.D,n=t.sa,e&&n&&qe(r,e,n),qe(r,"VER",t.ma),Kn(t,r),r}function nr(t,e,n){if(e&&!t.H)throw Error("Can't create secondary domain capable XhrIo object.");return(e=n&&t.Ba&&!t.qa?new _n(new gn({ib:!0})):new _n(t.qa)).L=t.H,e}function rr(){}function ir(){if(z&&!(10<=Number(et)))throw Error("Environmental error: no available transport.")}function sr(t,e){St.call(this),this.g=new Fn(e),this.l=t,this.h=e&&e.messageUrlParams||null,t=e&&e.messageHeaders||null,e&&e.clientProtocolHeaderRequired&&(t?t["X-Client-Protocol"]="webchannel":t={"X-Client-Protocol":"webchannel"}),this.g.s=t,t=e&&e.initMessageHeaders||null,e&&e.messageContentType&&(t?t["X-WebChannel-Content-Type"]=e.messageContentType:t={"X-WebChannel-Content-Type":e.messageContentType}),e&&e.ya&&(t?t["X-WebChannel-Client-Profile"]=e.ya:t={"X-WebChannel-Client-Profile":e.ya}),this.g.P=t,(t=e&&e.httpHeadersOverwriteParam)&&!N(t)&&(this.g.o=t),this.A=e&&e.supportsCrossDomainXhr||!1,this.v=e&&e.sendRawJson||!1,(e=e&&e.httpSessionIdParam)&&!N(e)&&(this.g.D=e,null!==(t=this.h)&&e in t&&e in(t=this.h)&&delete t[e]),this.j=new cr(this)}function or(t){le.call(this);var e=t.__sm__;if(e){t:{for(const n in e){t=n;break t}t=void 0}(this.i=t)&&(t=this.i,e=null!==e&&t in e?e[t]:void 0),this.data=e}else this.data=t}function ar(){de.call(this),this.status=1}function cr(t){this.g=t}(r=_n.prototype).ea=function(t,e,n,r){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.H+"; newUri="+t);e=e?e.toUpperCase():"GET",this.H=t,this.j="",this.m=0,this.D=!1,this.h=!0,this.g=this.u?this.u.g():ue.g(),this.C=this.u?ae(this.u):ae(ue),this.g.onreadystatechange=b(this.Fa,this);try{this.F=!0,this.g.open(e,String(t),!0),this.F=!1}catch(t){return void Nn(this,t)}t=n||"";const i=new De(this.headers);r&&Ce(r,(function(t,e){i.set(e,t)})),r=function(t){t:{var e=An;const n=t.length,r="string"==typeof t?t.split(""):t;for(let i=0;i<n;i++)if(i in r&&e.call(void 0,r[i],i,t)){e=i;break t}e=-1}return 0>e?null:"string"==typeof t?t.charAt(e):t[e]}(i.T()),n=l.FormData&&t instanceof l.FormData,!(0<=E(kn,e))||r||n||i.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8"),i.forEach((function(t,e){this.g.setRequestHeader(e,t)}),this),this.J&&(this.g.responseType=this.J),"withCredentials"in this.g&&this.g.withCredentials!==this.L&&(this.g.withCredentials=this.L);try{On(this),0<this.B&&((this.K=function(t){return z&&tt()&&"number"==typeof t.timeout&&void 0!==t.ontimeout}(this.g))?(this.g.timeout=this.B,this.g.ontimeout=b(this.pa,this)):this.A=jt(this.pa,this.B,this)),this.v=!0,this.g.send(t),this.v=!1}catch(t){Nn(this,t)}},r.pa=function(){void 0!==h&&this.g&&(this.j="Timed out after "+this.B+"ms, aborting",this.m=8,kt(this,"timeout"),this.abort(8))},r.abort=function(t){this.g&&this.h&&(this.h=!1,this.l=!0,this.g.abort(),this.l=!1,this.m=t||7,kt(this,"complete"),kt(this,"abort"),Dn(this))},r.M=function(){this.g&&(this.h&&(this.h=!1,this.l=!0,this.g.abort(),this.l=!1),Dn(this,!0)),_n.Z.M.call(this)},r.Fa=function(){this.s||(this.F||this.v||this.l?Cn(this):this.cb())},r.cb=function(){Cn(this)},r.ba=function(){try{return 2<Rn(this)?this.g.status:-1}catch(t){return-1}},r.ga=function(){try{return this.g?this.g.responseText:""}catch(t){return""}},r.Qa=function(t){if(this.g){var e=this.g.responseText;return t&&0==e.indexOf(t)&&(e=e.substring(t.length)),Tn(e)}},r.Da=function(){return this.m},r.La=function(){return"string"==typeof this.j?this.j:String(this.j)},(r=Fn.prototype).ma=8,r.G=1,r.hb=function(t){try{this.h.info("Origin Trials invoked: "+t)}catch(t){}},r.Ha=function(t){if(this.m)if(this.m=null,1==this.G){if(!t){this.V=Math.floor(1e5*Math.random()),t=this.V++;const i=new pe(this,this.h,t,void 0);let s=this.s;if(this.P&&(s?(s=M(s),U(s,this.P)):s=this.P),null===this.o&&(i.H=s),this.ja)t:{for(var e=0,n=0;n<this.l.length;n++){var r=this.l[n];if(void 0===(r="__data__"in r.g&&"string"==typeof(r=r.g.__data__)?r.length:void 0))break;if(4096<(e+=r)){e=n;break t}if(4096===e||n===this.l.length-1){e=n+1;break t}}e=1e3}else e=1e3;e=Wn(this,i,e),qe(n=Me(this.F),"RID",t),qe(n,"CVER",22),this.D&&qe(n,"X-HTTP-Session-Id",this.D),Kn(this,n),this.o&&s&&Ln(n,this.o,s),un(this.i,i),this.Ra&&qe(n,"TYPE","init"),this.ja?(qe(n,"$req",e),qe(n,"SID","null"),i.$=!0,be(i,n,null)):be(i,n,e),this.G=2}}else 3==this.G&&(t?zn(this,t):0==this.l.length||on(this.i)||zn(this))},r.Ga=function(){if(this.u=null,Yn(this),this.$&&!(this.L||null==this.g||0>=this.O)){var t=2*this.O;this.h.info("BP detection timer enabled: "+t),this.B=re(b(this.bb,this),t)}},r.bb=function(){this.B&&(this.B=null,this.h.info("BP detection timeout reached."),this.h.info("Buffering proxy detected and switch to long-polling!"),this.N=!1,this.L=!0,ee(10),Vn(this),Yn(this))},r.ab=function(){null!=this.v&&(this.v=null,Vn(this),Hn(this),ee(19))},r.jb=function(t){t?(this.h.info("Successfully pinged google.com"),ee(2)):(this.h.info("Failed to ping google.com"),ee(1))},(r=rr.prototype).xa=function(){},r.wa=function(){},r.va=function(){},r.ua=function(){},r.Oa=function(){},ir.prototype.g=function(t,e){return new sr(t,e)},I(sr,St),sr.prototype.m=function(){this.g.j=this.j,this.A&&(this.g.H=!0);var t=this.g,e=this.l,n=this.h||void 0;t.Wa&&(t.h.info("Origin Trials enabled."),Pt(b(t.hb,t,e))),ee(0),t.W=e,t.aa=n||{},t.N=t.X,t.F=er(t,null,t.W),Bn(t)},sr.prototype.close=function(){Un(this.g)},sr.prototype.u=function(t){if("string"==typeof t){var e={};e.__data__=t,qn(this.g,e)}else this.v?((e={}).__data__=Nt(t),qn(this.g,e)):qn(this.g,t)},sr.prototype.M=function(){this.g.j=null,delete this.j,Un(this.g),delete this.g,sr.Z.M.call(this)},I(or,le),I(ar,de),I(cr,rr),cr.prototype.xa=function(){kt(this.g,"a")},cr.prototype.wa=function(t){kt(this.g,new or(t))},cr.prototype.va=function(t){kt(this.g,new ar(t))},cr.prototype.ua=function(){kt(this.g,"b")},ir.prototype.createWebChannel=ir.prototype.g,sr.prototype.send=sr.prototype.u,sr.prototype.open=sr.prototype.m,sr.prototype.close=sr.prototype.close,ie.NO_ERROR=0,ie.TIMEOUT=8,ie.HTTP_ERROR=6,se.COMPLETE="complete",ce.EventType=he,he.OPEN="a",he.CLOSE="b",he.ERROR="c",he.MESSAGE="d",St.prototype.listen=St.prototype.N,_n.prototype.listenOnce=_n.prototype.O,_n.prototype.getLastError=_n.prototype.La,_n.prototype.getLastErrorCode=_n.prototype.Da,_n.prototype.getStatus=_n.prototype.ba,_n.prototype.getResponseJson=_n.prototype.Qa,_n.prototype.getResponseText=_n.prototype.ga,_n.prototype.send=_n.prototype.ea;var ur=u.createWebChannelTransport=function(){return new ir},hr=u.getStatEventTarget=function(){return Jt()},lr=u.ErrorCode=ie,dr=u.EventType=se,fr=u.Event=Yt,pr=u.Stat={rb:0,ub:1,vb:2,Ob:3,Tb:4,Qb:5,Rb:6,Pb:7,Nb:8,Sb:9,PROXY:10,NOPROXY:11,Lb:12,Hb:13,Ib:14,Gb:15,Jb:16,Kb:17,nb:18,mb:19,ob:20},mr=u.FetchXmlHttpFactory=gn,gr=u.WebChannel=ce,yr=u.XhrIo=_n;const vr="@firebase/firestore";class br{constructor(t){this.uid=t}isAuthenticated(){return null!=this.uid}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(t){return t.uid===this.uid}}br.UNAUTHENTICATED=new br(null),br.GOOGLE_CREDENTIALS=new br("google-credentials-uid"),br.FIRST_PARTY=new br("first-party-uid"),br.MOCK_USER=new br("mock-user");let wr="9.6.2";const Ir=new o.Yd("@firebase/firestore");function Tr(){return Ir.logLevel}function _r(t){Ir.setLogLevel(t)}function Er(t,...e){if(Ir.logLevel<=o.in.DEBUG){const n=e.map(Ar);Ir.debug(`Firestore (${wr}): ${t}`,...n)}}function Sr(t,...e){if(Ir.logLevel<=o.in.ERROR){const n=e.map(Ar);Ir.error(`Firestore (${wr}): ${t}`,...n)}}function kr(t,...e){if(Ir.logLevel<=o.in.WARN){const n=e.map(Ar);Ir.warn(`Firestore (${wr}): ${t}`,...n)}}function Ar(t){if("string"==typeof t)return t;try{return e=t,JSON.stringify(e)}catch(e){return t}var e}function Nr(t="Unexpected state"){const e=`FIRESTORE (${wr}) INTERNAL ASSERTION FAILED: `+t;throw Sr(e),new Error(e)}function xr(t,e){t||Nr()}function Cr(t,e){t||Nr()}function Dr(t,e){return t}const Or={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"};class Rr extends a.ZR{constructor(t,e){super(t,e),this.code=t,this.message=e,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}class Pr{constructor(){this.promise=new Promise(((t,e)=>{this.resolve=t,this.reject=e}))}}class Lr{constructor(t,e){this.user=e,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${t}`)}}class Mr{getToken(){return Promise.resolve(null)}invalidateToken(){}start(t,e){t.enqueueRetryable((()=>e(br.UNAUTHENTICATED)))}shutdown(){}}class Fr{constructor(t){this.token=t,this.changeListener=null}getToken(){return Promise.resolve(this.token)}invalidateToken(){}start(t,e){this.changeListener=e,t.enqueueRetryable((()=>e(this.token.user)))}shutdown(){this.changeListener=null}}class Ur{constructor(t){this.t=t,this.currentUser=br.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(t,e){let n=this.i;const r=t=>this.i!==n?(n=this.i,e(t)):Promise.resolve();let i=new Pr;this.o=()=>{this.i++,this.currentUser=this.u(),i.resolve(),i=new Pr,t.enqueueRetryable((()=>r(this.currentUser)))};const s=()=>{const e=i;t.enqueueRetryable((async()=>{await e.promise,await r(this.currentUser)}))},o=t=>{Er("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=t,this.auth.addAuthTokenListener(this.o),s()};this.t.onInit((t=>o(t))),setTimeout((()=>{if(!this.auth){const t=this.t.getImmediate({optional:!0});t?o(t):(Er("FirebaseAuthCredentialsProvider","Auth not yet detected"),i.resolve(),i=new Pr)}}),0),s()}getToken(){const t=this.i,e=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(e).then((e=>this.i!==t?(Er("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):e?(xr("string"==typeof e.accessToken),new Lr(e.accessToken,this.currentUser)):null)):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.auth.removeAuthTokenListener(this.o)}u(){const t=this.auth&&this.auth.getUid();return xr(null===t||"string"==typeof t),new br(t)}}class Vr{constructor(t,e,n){this.type="FirstParty",this.user=br.FIRST_PARTY,this.headers=new Map,this.headers.set("X-Goog-AuthUser",e);const r=t.auth.getAuthHeaderValueForFirstParty([]);r&&this.headers.set("Authorization",r),n&&this.headers.set("X-Goog-Iam-Authorization-Token",n)}}class jr{constructor(t,e,n){this.h=t,this.l=e,this.m=n}getToken(){return Promise.resolve(new Vr(this.h,this.l,this.m))}start(t,e){t.enqueueRetryable((()=>e(br.FIRST_PARTY)))}shutdown(){}invalidateToken(){}}class qr{constructor(t){this.value=t,this.type="AppCheck",this.headers=new Map,t&&t.length>0&&this.headers.set("x-firebase-appcheck",this.value)}}class Br{constructor(t){this.g=t,this.forceRefresh=!1,this.appCheck=null}start(t,e){this.o=n=>{t.enqueueRetryable((()=>(t=>(null!=t.error&&Er("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${t.error.message}`),e(t.token)))(n)))};const n=t=>{Er("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=t,this.appCheck.addTokenListener(this.o)};this.g.onInit((t=>n(t))),setTimeout((()=>{if(!this.appCheck){const t=this.g.getImmediate({optional:!0});t?n(t):Er("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}}),0)}getToken(){const t=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(t).then((t=>t?(xr("string"==typeof t.token),new qr(t.token)):null)):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.appCheck.removeTokenListener(this.o)}}class zr{getToken(){return Promise.resolve(new qr(""))}invalidateToken(){}start(t,e){}shutdown(){}}class Kr{constructor(t,e){this.previousValue=t,e&&(e.sequenceNumberHandler=t=>this.p(t),this.T=t=>e.writeSequenceNumber(t))}p(t){return this.previousValue=Math.max(t,this.previousValue),this.previousValue}next(){const t=++this.previousValue;return this.T&&this.T(t),t}}function Wr(t){const e="undefined"!=typeof self&&(self.crypto||self.msCrypto),n=new Uint8Array(t);if(e&&"function"==typeof e.getRandomValues)e.getRandomValues(n);else for(let e=0;e<t;e++)n[e]=Math.floor(256*Math.random());return n}Kr.I=-1;class Gr{static A(){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e=Math.floor(256/t.length)*t.length;let n="";for(;n.length<20;){const r=Wr(40);for(let i=0;i<r.length;++i)n.length<20&&r[i]<e&&(n+=t.charAt(r[i]%t.length))}return n}}function Hr(t,e){return t<e?-1:t>e?1:0}function $r(t,e,n){return t.length===e.length&&t.every(((t,r)=>n(t,e[r])))}function Yr(t){return t+"\0"}class Qr{constructor(t,e){if(this.seconds=t,this.nanoseconds=e,e<0)throw new Rr(Or.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(e>=1e9)throw new Rr(Or.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(t<-62135596800)throw new Rr(Or.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t);if(t>=253402300800)throw new Rr(Or.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t)}static now(){return Qr.fromMillis(Date.now())}static fromDate(t){return Qr.fromMillis(t.getTime())}static fromMillis(t){const e=Math.floor(t/1e3),n=Math.floor(1e6*(t-1e3*e));return new Qr(e,n)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/1e6}_compareTo(t){return this.seconds===t.seconds?Hr(this.nanoseconds,t.nanoseconds):Hr(this.seconds,t.seconds)}isEqual(t){return t.seconds===this.seconds&&t.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{seconds:this.seconds,nanoseconds:this.nanoseconds}}valueOf(){const t=this.seconds- -62135596800;return String(t).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}class Jr{constructor(t){this.timestamp=t}static fromTimestamp(t){return new Jr(t)}static min(){return new Jr(new Qr(0,0))}compareTo(t){return this.timestamp._compareTo(t.timestamp)}isEqual(t){return this.timestamp.isEqual(t.timestamp)}toMicroseconds(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}toString(){return"SnapshotVersion("+this.timestamp.toString()+")"}toTimestamp(){return this.timestamp}}function Zr(t){let e=0;for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&e++;return e}function Xr(t,e){for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&e(n,t[n])}function ti(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}class ei{constructor(t,e,n){void 0===e?e=0:e>t.length&&Nr(),void 0===n?n=t.length-e:n>t.length-e&&Nr(),this.segments=t,this.offset=e,this.len=n}get length(){return this.len}isEqual(t){return 0===ei.comparator(this,t)}child(t){const e=this.segments.slice(this.offset,this.limit());return t instanceof ei?t.forEach((t=>{e.push(t)})):e.push(t),this.construct(e)}limit(){return this.offset+this.length}popFirst(t){return t=void 0===t?1:t,this.construct(this.segments,this.offset+t,this.length-t)}popLast(){return this.construct(this.segments,this.offset,this.length-1)}firstSegment(){return this.segments[this.offset]}lastSegment(){return this.get(this.length-1)}get(t){return this.segments[this.offset+t]}isEmpty(){return 0===this.length}isPrefixOf(t){if(t.length<this.length)return!1;for(let e=0;e<this.length;e++)if(this.get(e)!==t.get(e))return!1;return!0}isImmediateParentOf(t){if(this.length+1!==t.length)return!1;for(let e=0;e<this.length;e++)if(this.get(e)!==t.get(e))return!1;return!0}forEach(t){for(let e=this.offset,n=this.limit();e<n;e++)t(this.segments[e])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(t,e){const n=Math.min(t.length,e.length);for(let r=0;r<n;r++){const n=t.get(r),i=e.get(r);if(n<i)return-1;if(n>i)return 1}return t.length<e.length?-1:t.length>e.length?1:0}}class ni extends ei{construct(t,e,n){return new ni(t,e,n)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}static fromString(...t){const e=[];for(const n of t){if(n.indexOf("//")>=0)throw new Rr(Or.INVALID_ARGUMENT,`Invalid segment (${n}). Paths must not contain // in them.`);e.push(...n.split("/").filter((t=>t.length>0)))}return new ni(e)}static emptyPath(){return new ni([])}}const ri=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class ii extends ei{construct(t,e,n){return new ii(t,e,n)}static isValidIdentifier(t){return ri.test(t)}canonicalString(){return this.toArray().map((t=>(t=t.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),ii.isValidIdentifier(t)||(t="`"+t+"`"),t))).join(".")}toString(){return this.canonicalString()}isKeyField(){return 1===this.length&&"__name__"===this.get(0)}static keyField(){return new ii(["__name__"])}static fromServerFormat(t){const e=[];let n="",r=0;const i=()=>{if(0===n.length)throw new Rr(Or.INVALID_ARGUMENT,`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);e.push(n),n=""};let s=!1;for(;r<t.length;){const e=t[r];if("\\"===e){if(r+1===t.length)throw new Rr(Or.INVALID_ARGUMENT,"Path has trailing escape character: "+t);const e=t[r+1];if("\\"!==e&&"."!==e&&"`"!==e)throw new Rr(Or.INVALID_ARGUMENT,"Path has invalid escape sequence: "+t);n+=e,r+=2}else"`"===e?(s=!s,r++):"."!==e||s?(n+=e,r++):(i(),r++)}if(i(),s)throw new Rr(Or.INVALID_ARGUMENT,"Unterminated ` in path: "+t);return new ii(e)}static emptyPath(){return new ii([])}}class si{constructor(t){this.fields=t,t.sort(ii.comparator)}covers(t){for(const e of this.fields)if(e.isPrefixOf(t))return!0;return!1}isEqual(t){return $r(this.fields,t.fields,((t,e)=>t.isEqual(e)))}}function oi(){return"undefined"!=typeof atob}class ai{constructor(t){this.binaryString=t}static fromBase64String(t){const e=atob(t);return new ai(e)}static fromUint8Array(t){const e=function(t){let e="";for(let n=0;n<t.length;++n)e+=String.fromCharCode(t[n]);return e}(t);return new ai(e)}[Symbol.iterator](){let t=0;return{next:()=>t<this.binaryString.length?{value:this.binaryString.charCodeAt(t++),done:!1}:{value:void 0,done:!0}}}toBase64(){return t=this.binaryString,btoa(t);var t}toUint8Array(){return function(t){const e=new Uint8Array(t.length);for(let n=0;n<t.length;n++)e[n]=t.charCodeAt(n);return e}(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(t){return Hr(this.binaryString,t.binaryString)}isEqual(t){return this.binaryString===t.binaryString}}ai.EMPTY_BYTE_STRING=new ai("");const ci=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function ui(t){if(xr(!!t),"string"==typeof t){let e=0;const n=ci.exec(t);if(xr(!!n),n[1]){let t=n[1];t=(t+"000000000").substr(0,9),e=Number(t)}const r=new Date(t);return{seconds:Math.floor(r.getTime()/1e3),nanos:e}}return{seconds:hi(t.seconds),nanos:hi(t.nanos)}}function hi(t){return"number"==typeof t?t:"string"==typeof t?Number(t):0}function li(t){return"string"==typeof t?ai.fromBase64String(t):ai.fromUint8Array(t)}function di(t){var e,n;return"server_timestamp"===(null===(n=((null===(e=null==t?void 0:t.mapValue)||void 0===e?void 0:e.fields)||{}).__type__)||void 0===n?void 0:n.stringValue)}function fi(t){const e=t.mapValue.fields.__previous_value__;return di(e)?fi(e):e}function pi(t){const e=ui(t.mapValue.fields.__local_write_time__.timestampValue);return new Qr(e.seconds,e.nanos)}function mi(t){return null==t}function gi(t){return 0===t&&1/t==-1/0}function yi(t){return"number"==typeof t&&Number.isInteger(t)&&!gi(t)&&t<=Number.MAX_SAFE_INTEGER&&t>=Number.MIN_SAFE_INTEGER}class vi{constructor(t){this.path=t}static fromPath(t){return new vi(ni.fromString(t))}static fromName(t){return new vi(ni.fromString(t).popFirst(5))}hasCollectionId(t){return this.path.length>=2&&this.path.get(this.path.length-2)===t}isEqual(t){return null!==t&&0===ni.comparator(this.path,t.path)}toString(){return this.path.toString()}static comparator(t,e){return ni.comparator(t.path,e.path)}static isDocumentKey(t){return t.length%2==0}static fromSegments(t){return new vi(new ni(t.slice()))}}function bi(t){return"nullValue"in t?0:"booleanValue"in t?1:"integerValue"in t||"doubleValue"in t?2:"timestampValue"in t?3:"stringValue"in t?5:"bytesValue"in t?6:"referenceValue"in t?7:"geoPointValue"in t?8:"arrayValue"in t?9:"mapValue"in t?di(t)?4:10:Nr()}function wi(t,e){if(t===e)return!0;const n=bi(t);if(n!==bi(e))return!1;switch(n){case 0:return!0;case 1:return t.booleanValue===e.booleanValue;case 4:return pi(t).isEqual(pi(e));case 3:return function(t,e){if("string"==typeof t.timestampValue&&"string"==typeof e.timestampValue&&t.timestampValue.length===e.timestampValue.length)return t.timestampValue===e.timestampValue;const n=ui(t.timestampValue),r=ui(e.timestampValue);return n.seconds===r.seconds&&n.nanos===r.nanos}(t,e);case 5:return t.stringValue===e.stringValue;case 6:return function(t,e){return li(t.bytesValue).isEqual(li(e.bytesValue))}(t,e);case 7:return t.referenceValue===e.referenceValue;case 8:return function(t,e){return hi(t.geoPointValue.latitude)===hi(e.geoPointValue.latitude)&&hi(t.geoPointValue.longitude)===hi(e.geoPointValue.longitude)}(t,e);case 2:return function(t,e){if("integerValue"in t&&"integerValue"in e)return hi(t.integerValue)===hi(e.integerValue);if("doubleValue"in t&&"doubleValue"in e){const n=hi(t.doubleValue),r=hi(e.doubleValue);return n===r?gi(n)===gi(r):isNaN(n)&&isNaN(r)}return!1}(t,e);case 9:return $r(t.arrayValue.values||[],e.arrayValue.values||[],wi);case 10:return function(t,e){const n=t.mapValue.fields||{},r=e.mapValue.fields||{};if(Zr(n)!==Zr(r))return!1;for(const t in n)if(n.hasOwnProperty(t)&&(void 0===r[t]||!wi(n[t],r[t])))return!1;return!0}(t,e);default:return Nr()}}function Ii(t,e){return void 0!==(t.values||[]).find((t=>wi(t,e)))}function Ti(t,e){if(t===e)return 0;const n=bi(t),r=bi(e);if(n!==r)return Hr(n,r);switch(n){case 0:return 0;case 1:return Hr(t.booleanValue,e.booleanValue);case 2:return function(t,e){const n=hi(t.integerValue||t.doubleValue),r=hi(e.integerValue||e.doubleValue);return n<r?-1:n>r?1:n===r?0:isNaN(n)?isNaN(r)?0:-1:1}(t,e);case 3:return _i(t.timestampValue,e.timestampValue);case 4:return _i(pi(t),pi(e));case 5:return Hr(t.stringValue,e.stringValue);case 6:return function(t,e){const n=li(t),r=li(e);return n.compareTo(r)}(t.bytesValue,e.bytesValue);case 7:return function(t,e){const n=t.split("/"),r=e.split("/");for(let t=0;t<n.length&&t<r.length;t++){const e=Hr(n[t],r[t]);if(0!==e)return e}return Hr(n.length,r.length)}(t.referenceValue,e.referenceValue);case 8:return function(t,e){const n=Hr(hi(t.latitude),hi(e.latitude));return 0!==n?n:Hr(hi(t.longitude),hi(e.longitude))}(t.geoPointValue,e.geoPointValue);case 9:return function(t,e){const n=t.values||[],r=e.values||[];for(let t=0;t<n.length&&t<r.length;++t){const e=Ti(n[t],r[t]);if(e)return e}return Hr(n.length,r.length)}(t.arrayValue,e.arrayValue);case 10:return function(t,e){const n=t.fields||{},r=Object.keys(n),i=e.fields||{},s=Object.keys(i);r.sort(),s.sort();for(let t=0;t<r.length&&t<s.length;++t){const e=Hr(r[t],s[t]);if(0!==e)return e;const o=Ti(n[r[t]],i[s[t]]);if(0!==o)return o}return Hr(r.length,s.length)}(t.mapValue,e.mapValue);default:throw Nr()}}function _i(t,e){if("string"==typeof t&&"string"==typeof e&&t.length===e.length)return Hr(t,e);const n=ui(t),r=ui(e),i=Hr(n.seconds,r.seconds);return 0!==i?i:Hr(n.nanos,r.nanos)}function Ei(t){return Si(t)}function Si(t){return"nullValue"in t?"null":"booleanValue"in t?""+t.booleanValue:"integerValue"in t?""+t.integerValue:"doubleValue"in t?""+t.doubleValue:"timestampValue"in t?function(t){const e=ui(t);return`time(${e.seconds},${e.nanos})`}(t.timestampValue):"stringValue"in t?t.stringValue:"bytesValue"in t?li(t.bytesValue).toBase64():"referenceValue"in t?(n=t.referenceValue,vi.fromName(n).toString()):"geoPointValue"in t?`geo(${(e=t.geoPointValue).latitude},${e.longitude})`:"arrayValue"in t?function(t){let e="[",n=!0;for(const r of t.values||[])n?n=!1:e+=",",e+=Si(r);return e+"]"}(t.arrayValue):"mapValue"in t?function(t){const e=Object.keys(t.fields||{}).sort();let n="{",r=!0;for(const i of e)r?r=!1:n+=",",n+=`${i}:${Si(t.fields[i])}`;return n+"}"}(t.mapValue):Nr();var e,n}function ki(t,e){return{referenceValue:`projects/${t.projectId}/databases/${t.database}/documents/${e.path.canonicalString()}`}}function Ai(t){return!!t&&"integerValue"in t}function Ni(t){return!!t&&"arrayValue"in t}function xi(t){return!!t&&"nullValue"in t}function Ci(t){return!!t&&"doubleValue"in t&&isNaN(Number(t.doubleValue))}function Di(t){return!!t&&"mapValue"in t}function Oi(t){if(t.geoPointValue)return{geoPointValue:Object.assign({},t.geoPointValue)};if(t.timestampValue&&"object"==typeof t.timestampValue)return{timestampValue:Object.assign({},t.timestampValue)};if(t.mapValue){const e={mapValue:{fields:{}}};return Xr(t.mapValue.fields,((t,n)=>e.mapValue.fields[t]=Oi(n))),e}if(t.arrayValue){const e={arrayValue:{values:[]}};for(let n=0;n<(t.arrayValue.values||[]).length;++n)e.arrayValue.values[n]=Oi(t.arrayValue.values[n]);return e}return Object.assign({},t)}class Ri{constructor(t){this.value=t}static empty(){return new Ri({mapValue:{}})}field(t){if(t.isEmpty())return this.value;{let e=this.value;for(let n=0;n<t.length-1;++n)if(e=(e.mapValue.fields||{})[t.get(n)],!Di(e))return null;return e=(e.mapValue.fields||{})[t.lastSegment()],e||null}}set(t,e){this.getFieldsMap(t.popLast())[t.lastSegment()]=Oi(e)}setAll(t){let e=ii.emptyPath(),n={},r=[];t.forEach(((t,i)=>{if(!e.isImmediateParentOf(i)){const t=this.getFieldsMap(e);this.applyChanges(t,n,r),n={},r=[],e=i.popLast()}t?n[i.lastSegment()]=Oi(t):r.push(i.lastSegment())}));const i=this.getFieldsMap(e);this.applyChanges(i,n,r)}delete(t){const e=this.field(t.popLast());Di(e)&&e.mapValue.fields&&delete e.mapValue.fields[t.lastSegment()]}isEqual(t){return wi(this.value,t.value)}getFieldsMap(t){let e=this.value;e.mapValue.fields||(e.mapValue={fields:{}});for(let n=0;n<t.length;++n){let r=e.mapValue.fields[t.get(n)];Di(r)&&r.mapValue.fields||(r={mapValue:{fields:{}}},e.mapValue.fields[t.get(n)]=r),e=r}return e.mapValue.fields}applyChanges(t,e,n){Xr(e,((e,n)=>t[e]=n));for(const e of n)delete t[e]}clone(){return new Ri(Oi(this.value))}}function Pi(t){const e=[];return Xr(t.fields,((t,n)=>{const r=new ii([t]);if(Di(n)){const t=Pi(n.mapValue).fields;if(0===t.length)e.push(r);else for(const n of t)e.push(r.child(n))}else e.push(r)})),new si(e)}class Li{constructor(t,e,n,r,i){this.key=t,this.documentType=e,this.version=n,this.data=r,this.documentState=i}static newInvalidDocument(t){return new Li(t,0,Jr.min(),Ri.empty(),0)}static newFoundDocument(t,e,n){return new Li(t,1,e,n,0)}static newNoDocument(t,e){return new Li(t,2,e,Ri.empty(),0)}static newUnknownDocument(t,e){return new Li(t,3,e,Ri.empty(),2)}convertToFoundDocument(t,e){return this.version=t,this.documentType=1,this.data=e,this.documentState=0,this}convertToNoDocument(t){return this.version=t,this.documentType=2,this.data=Ri.empty(),this.documentState=0,this}convertToUnknownDocument(t){return this.version=t,this.documentType=3,this.data=Ri.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this}get hasLocalMutations(){return 1===this.documentState}get hasCommittedMutations(){return 2===this.documentState}get hasPendingWrites(){return this.hasLocalMutations||this.hasCommittedMutations}isValidDocument(){return 0!==this.documentType}isFoundDocument(){return 1===this.documentType}isNoDocument(){return 2===this.documentType}isUnknownDocument(){return 3===this.documentType}isEqual(t){return t instanceof Li&&this.key.isEqual(t.key)&&this.version.isEqual(t.version)&&this.documentType===t.documentType&&this.documentState===t.documentState&&this.data.isEqual(t.data)}mutableCopy(){return new Li(this.key,this.documentType,this.version,this.data.clone(),this.documentState)}toString(){return`Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`}}class Mi{constructor(t,e=null,n=[],r=[],i=null,s=null,o=null){this.path=t,this.collectionGroup=e,this.orderBy=n,this.filters=r,this.limit=i,this.startAt=s,this.endAt=o,this.R=null}}function Fi(t,e=null,n=[],r=[],i=null,s=null,o=null){return new Mi(t,e,n,r,i,s,o)}function Ui(t){const e=Dr(t);if(null===e.R){let t=e.path.canonicalString();null!==e.collectionGroup&&(t+="|cg:"+e.collectionGroup),t+="|f:",t+=e.filters.map((t=>function(t){return t.field.canonicalString()+t.op.toString()+Ei(t.value)}(t))).join(","),t+="|ob:",t+=e.orderBy.map((t=>function(t){return t.field.canonicalString()+t.dir}(t))).join(","),mi(e.limit)||(t+="|l:",t+=e.limit),e.startAt&&(t+="|lb:",t+=Ji(e.startAt)),e.endAt&&(t+="|ub:",t+=Ji(e.endAt)),e.R=t}return e.R}function Vi(t,e){if(t.limit!==e.limit)return!1;if(t.orderBy.length!==e.orderBy.length)return!1;for(let n=0;n<t.orderBy.length;n++)if(!Xi(t.orderBy[n],e.orderBy[n]))return!1;if(t.filters.length!==e.filters.length)return!1;for(let i=0;i<t.filters.length;i++)if(n=t.filters[i],r=e.filters[i],n.op!==r.op||!n.field.isEqual(r.field)||!wi(n.value,r.value))return!1;var n,r;return t.collectionGroup===e.collectionGroup&&!!t.path.isEqual(e.path)&&!!es(t.startAt,e.startAt)&&es(t.endAt,e.endAt)}function ji(t){return vi.isDocumentKey(t.path)&&null===t.collectionGroup&&0===t.filters.length}class qi extends class{}{constructor(t,e,n){super(),this.field=t,this.op=e,this.value=n}static create(t,e,n){return t.isKeyField()?"in"===e||"not-in"===e?this.P(t,e,n):new Bi(t,e,n):"array-contains"===e?new Gi(t,n):"in"===e?new Hi(t,n):"not-in"===e?new $i(t,n):"array-contains-any"===e?new Yi(t,n):new qi(t,e,n)}static P(t,e,n){return"in"===e?new zi(t,n):new Ki(t,n)}matches(t){const e=t.data.field(this.field);return"!="===this.op?null!==e&&this.v(Ti(e,this.value)):null!==e&&bi(this.value)===bi(e)&&this.v(Ti(e,this.value))}v(t){switch(this.op){case"<":return t<0;case"<=":return t<=0;case"==":return 0===t;case"!=":return 0!==t;case">":return t>0;case">=":return t>=0;default:return Nr()}}V(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}}class Bi extends qi{constructor(t,e,n){super(t,e,n),this.key=vi.fromName(n.referenceValue)}matches(t){const e=vi.comparator(t.key,this.key);return this.v(e)}}class zi extends qi{constructor(t,e){super(t,"in",e),this.keys=Wi(0,e)}matches(t){return this.keys.some((e=>e.isEqual(t.key)))}}class Ki extends qi{constructor(t,e){super(t,"not-in",e),this.keys=Wi(0,e)}matches(t){return!this.keys.some((e=>e.isEqual(t.key)))}}function Wi(t,e){var n;return((null===(n=e.arrayValue)||void 0===n?void 0:n.values)||[]).map((t=>vi.fromName(t.referenceValue)))}class Gi extends qi{constructor(t,e){super(t,"array-contains",e)}matches(t){const e=t.data.field(this.field);return Ni(e)&&Ii(e.arrayValue,this.value)}}class Hi extends qi{constructor(t,e){super(t,"in",e)}matches(t){const e=t.data.field(this.field);return null!==e&&Ii(this.value.arrayValue,e)}}class $i extends qi{constructor(t,e){super(t,"not-in",e)}matches(t){if(Ii(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const e=t.data.field(this.field);return null!==e&&!Ii(this.value.arrayValue,e)}}class Yi extends qi{constructor(t,e){super(t,"array-contains-any",e)}matches(t){const e=t.data.field(this.field);return!(!Ni(e)||!e.arrayValue.values)&&e.arrayValue.values.some((t=>Ii(this.value.arrayValue,t)))}}class Qi{constructor(t,e){this.position=t,this.before=e}}function Ji(t){return`${t.before?"b":"a"}:${t.position.map((t=>Ei(t))).join(",")}`}class Zi{constructor(t,e="asc"){this.field=t,this.dir=e}}function Xi(t,e){return t.dir===e.dir&&t.field.isEqual(e.field)}function ts(t,e,n){let r=0;for(let i=0;i<t.position.length;i++){const s=e[i],o=t.position[i];if(r=s.field.isKeyField()?vi.comparator(vi.fromName(o.referenceValue),n.key):Ti(o,n.data.field(s.field)),"desc"===s.dir&&(r*=-1),0!==r)break}return t.before?r<=0:r<0}function es(t,e){if(null===t)return null===e;if(null===e)return!1;if(t.before!==e.before||t.position.length!==e.position.length)return!1;for(let n=0;n<t.position.length;n++)if(!wi(t.position[n],e.position[n]))return!1;return!0}class ns{constructor(t,e=null,n=[],r=[],i=null,s="F",o=null,a=null){this.path=t,this.collectionGroup=e,this.explicitOrderBy=n,this.filters=r,this.limit=i,this.limitType=s,this.startAt=o,this.endAt=a,this.S=null,this.D=null,this.startAt,this.endAt}}function rs(t,e,n,r,i,s,o,a){return new ns(t,e,n,r,i,s,o,a)}function is(t){return new ns(t)}function ss(t){return!mi(t.limit)&&"F"===t.limitType}function os(t){return!mi(t.limit)&&"L"===t.limitType}function as(t){return t.explicitOrderBy.length>0?t.explicitOrderBy[0].field:null}function cs(t){for(const e of t.filters)if(e.V())return e.field;return null}function us(t){return null!==t.collectionGroup}function hs(t){const e=Dr(t);if(null===e.S){e.S=[];const t=cs(e),n=as(e);if(null!==t&&null===n)t.isKeyField()||e.S.push(new Zi(t)),e.S.push(new Zi(ii.keyField(),"asc"));else{let t=!1;for(const n of e.explicitOrderBy)e.S.push(n),n.field.isKeyField()&&(t=!0);if(!t){const t=e.explicitOrderBy.length>0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";e.S.push(new Zi(ii.keyField(),t))}}}return e.S}function ls(t){const e=Dr(t);if(!e.D)if("F"===e.limitType)e.D=Fi(e.path,e.collectionGroup,hs(e),e.filters,e.limit,e.startAt,e.endAt);else{const t=[];for(const n of hs(e)){const e="desc"===n.dir?"asc":"desc";t.push(new Zi(n.field,e))}const n=e.endAt?new Qi(e.endAt.position,!e.endAt.before):null,r=e.startAt?new Qi(e.startAt.position,!e.startAt.before):null;e.D=Fi(e.path,e.collectionGroup,t,e.filters,e.limit,n,r)}return e.D}function ds(t,e,n){return new ns(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),e,n,t.startAt,t.endAt)}function fs(t,e){return Vi(ls(t),ls(e))&&t.limitType===e.limitType}function ps(t){return`${Ui(ls(t))}|lt:${t.limitType}`}function ms(t){return`Query(target=${function(t){let e=t.path.canonicalString();return null!==t.collectionGroup&&(e+=" collectionGroup="+t.collectionGroup),t.filters.length>0&&(e+=`, filters: [${t.filters.map((t=>{return`${(e=t).field.canonicalString()} ${e.op} ${Ei(e.value)}`;var e})).join(", ")}]`),mi(t.limit)||(e+=", limit: "+t.limit),t.orderBy.length>0&&(e+=`, orderBy: [${t.orderBy.map((t=>function(t){return`${t.field.canonicalString()} (${t.dir})`}(t))).join(", ")}]`),t.startAt&&(e+=", startAt: "+Ji(t.startAt)),t.endAt&&(e+=", endAt: "+Ji(t.endAt)),`Target(${e})`}(ls(t))}; limitType=${t.limitType})`}function gs(t,e){return e.isFoundDocument()&&function(t,e){const n=e.key.path;return null!==t.collectionGroup?e.key.hasCollectionId(t.collectionGroup)&&t.path.isPrefixOf(n):vi.isDocumentKey(t.path)?t.path.isEqual(n):t.path.isImmediateParentOf(n)}(t,e)&&function(t,e){for(const n of t.explicitOrderBy)if(!n.field.isKeyField()&&null===e.data.field(n.field))return!1;return!0}(t,e)&&function(t,e){for(const n of t.filters)if(!n.matches(e))return!1;return!0}(t,e)&&function(t,e){return!(t.startAt&&!ts(t.startAt,hs(t),e)||t.endAt&&ts(t.endAt,hs(t),e))}(t,e)}function ys(t){return(e,n)=>{let r=!1;for(const i of hs(t)){const t=vs(i,e,n);if(0!==t)return t;r=r||i.field.isKeyField()}return 0}}function vs(t,e,n){const r=t.field.isKeyField()?vi.comparator(e.key,n.key):function(t,e,n){const r=e.data.field(t),i=n.data.field(t);return null!==r&&null!==i?Ti(r,i):Nr()}(t.field,e,n);switch(t.dir){case"asc":return r;case"desc":return-1*r;default:return Nr()}}function bs(t,e){if(t.C){if(isNaN(e))return{doubleValue:"NaN"};if(e===1/0)return{doubleValue:"Infinity"};if(e===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:gi(e)?"-0":e}}function ws(t){return{integerValue:""+t}}function Is(t,e){return yi(e)?ws(e):bs(t,e)}class Ts{constructor(){this._=void 0}}function _s(t,e,n){return t instanceof ks?function(t,e){const n={fields:{__type__:{stringValue:"server_timestamp"},__local_write_time__:{timestampValue:{seconds:t.seconds,nanos:t.nanoseconds}}}};return e&&(n.fields.__previous_value__=e),{mapValue:n}}(n,e):t instanceof As?Ns(t,e):t instanceof xs?Cs(t,e):function(t,e){const n=Ss(t,e),r=Os(n)+Os(t.N);return Ai(n)&&Ai(t.N)?ws(r):bs(t.k,r)}(t,e)}function Es(t,e,n){return t instanceof As?Ns(t,e):t instanceof xs?Cs(t,e):n}function Ss(t,e){return t instanceof Ds?Ai(n=e)||function(t){return!!t&&"doubleValue"in t}(n)?e:{integerValue:0}:null;var n}class ks extends Ts{}class As extends Ts{constructor(t){super(),this.elements=t}}function Ns(t,e){const n=Rs(e);for(const e of t.elements)n.some((t=>wi(t,e)))||n.push(e);return{arrayValue:{values:n}}}class xs extends Ts{constructor(t){super(),this.elements=t}}function Cs(t,e){let n=Rs(e);for(const e of t.elements)n=n.filter((t=>!wi(t,e)));return{arrayValue:{values:n}}}class Ds extends Ts{constructor(t,e){super(),this.k=t,this.N=e}}function Os(t){return hi(t.integerValue||t.doubleValue)}function Rs(t){return Ni(t)&&t.arrayValue.values?t.arrayValue.values.slice():[]}class Ps{constructor(t,e){this.field=t,this.transform=e}}class Ls{constructor(t,e){this.version=t,this.transformResults=e}}class Ms{constructor(t,e){this.updateTime=t,this.exists=e}static none(){return new Ms}static exists(t){return new Ms(void 0,t)}static updateTime(t){return new Ms(t)}get isNone(){return void 0===this.updateTime&&void 0===this.exists}isEqual(t){return this.exists===t.exists&&(this.updateTime?!!t.updateTime&&this.updateTime.isEqual(t.updateTime):!t.updateTime)}}function Fs(t,e){return void 0!==t.updateTime?e.isFoundDocument()&&e.version.isEqual(t.updateTime):void 0===t.exists||t.exists===e.isFoundDocument()}class Us{}function Vs(t,e,n){t instanceof Ks?function(t,e,n){const r=t.value.clone(),i=Hs(t.fieldTransforms,e,n.transformResults);r.setAll(i),e.convertToFoundDocument(n.version,r).setHasCommittedMutations()}(t,e,n):t instanceof Ws?function(t,e,n){if(!Fs(t.precondition,e))return void e.convertToUnknownDocument(n.version);const r=Hs(t.fieldTransforms,e,n.transformResults),i=e.data;i.setAll(Gs(t)),i.setAll(r),e.convertToFoundDocument(n.version,i).setHasCommittedMutations()}(t,e,n):function(t,e,n){e.convertToNoDocument(n.version).setHasCommittedMutations()}(0,e,n)}function js(t,e,n){t instanceof Ks?function(t,e,n){if(!Fs(t.precondition,e))return;const r=t.value.clone(),i=$s(t.fieldTransforms,n,e);r.setAll(i),e.convertToFoundDocument(zs(e),r).setHasLocalMutations()}(t,e,n):t instanceof Ws?function(t,e,n){if(!Fs(t.precondition,e))return;const r=$s(t.fieldTransforms,n,e),i=e.data;i.setAll(Gs(t)),i.setAll(r),e.convertToFoundDocument(zs(e),i).setHasLocalMutations()}(t,e,n):function(t,e){Fs(t.precondition,e)&&e.convertToNoDocument(Jr.min())}(t,e)}function qs(t,e){let n=null;for(const r of t.fieldTransforms){const t=e.data.field(r.field),i=Ss(r.transform,t||null);null!=i&&(null==n&&(n=Ri.empty()),n.set(r.field,i))}return n||null}function Bs(t,e){return t.type===e.type&&!!t.key.isEqual(e.key)&&!!t.precondition.isEqual(e.precondition)&&!!function(t,e){return void 0===t&&void 0===e||!(!t||!e)&&$r(t,e,((t,e)=>function(t,e){return t.field.isEqual(e.field)&&function(t,e){return t instanceof As&&e instanceof As||t instanceof xs&&e instanceof xs?$r(t.elements,e.elements,wi):t instanceof Ds&&e instanceof Ds?wi(t.N,e.N):t instanceof ks&&e instanceof ks}(t.transform,e.transform)}(t,e)))}(t.fieldTransforms,e.fieldTransforms)&&(0===t.type?t.value.isEqual(e.value):1!==t.type||t.data.isEqual(e.data)&&t.fieldMask.isEqual(e.fieldMask))}function zs(t){return t.isFoundDocument()?t.version:Jr.min()}class Ks extends Us{constructor(t,e,n,r=[]){super(),this.key=t,this.value=e,this.precondition=n,this.fieldTransforms=r,this.type=0}}class Ws extends Us{constructor(t,e,n,r,i=[]){super(),this.key=t,this.data=e,this.fieldMask=n,this.precondition=r,this.fieldTransforms=i,this.type=1}}function Gs(t){const e=new Map;return t.fieldMask.fields.forEach((n=>{if(!n.isEmpty()){const r=t.data.field(n);e.set(n,r)}})),e}function Hs(t,e,n){const r=new Map;xr(t.length===n.length);for(let i=0;i<n.length;i++){const s=t[i],o=s.transform,a=e.data.field(s.field);r.set(s.field,Es(o,a,n[i]))}return r}function $s(t,e,n){const r=new Map;for(const i of t){const t=i.transform,s=n.data.field(i.field);r.set(i.field,_s(t,s,e))}return r}class Ys extends Us{constructor(t,e){super(),this.key=t,this.precondition=e,this.type=2,this.fieldTransforms=[]}}class Qs extends Us{constructor(t,e){super(),this.key=t,this.precondition=e,this.type=3,this.fieldTransforms=[]}}class Js{constructor(t){this.count=t}}var Zs,Xs;function to(t){switch(t){default:return Nr();case Or.CANCELLED:case Or.UNKNOWN:case Or.DEADLINE_EXCEEDED:case Or.RESOURCE_EXHAUSTED:case Or.INTERNAL:case Or.UNAVAILABLE:case Or.UNAUTHENTICATED:return!1;case Or.INVALID_ARGUMENT:case Or.NOT_FOUND:case Or.ALREADY_EXISTS:case Or.PERMISSION_DENIED:case Or.FAILED_PRECONDITION:case Or.ABORTED:case Or.OUT_OF_RANGE:case Or.UNIMPLEMENTED:case Or.DATA_LOSS:return!0}}function eo(t){if(void 0===t)return Sr("GRPC error has no .code"),Or.UNKNOWN;switch(t){case Zs.OK:return Or.OK;case Zs.CANCELLED:return Or.CANCELLED;case Zs.UNKNOWN:return Or.UNKNOWN;case Zs.DEADLINE_EXCEEDED:return Or.DEADLINE_EXCEEDED;case Zs.RESOURCE_EXHAUSTED:return Or.RESOURCE_EXHAUSTED;case Zs.INTERNAL:return Or.INTERNAL;case Zs.UNAVAILABLE:return Or.UNAVAILABLE;case Zs.UNAUTHENTICATED:return Or.UNAUTHENTICATED;case Zs.INVALID_ARGUMENT:return Or.INVALID_ARGUMENT;case Zs.NOT_FOUND:return Or.NOT_FOUND;case Zs.ALREADY_EXISTS:return Or.ALREADY_EXISTS;case Zs.PERMISSION_DENIED:return Or.PERMISSION_DENIED;case Zs.FAILED_PRECONDITION:return Or.FAILED_PRECONDITION;case Zs.ABORTED:return Or.ABORTED;case Zs.OUT_OF_RANGE:return Or.OUT_OF_RANGE;case Zs.UNIMPLEMENTED:return Or.UNIMPLEMENTED;case Zs.DATA_LOSS:return Or.DATA_LOSS;default:return Nr()}}(Xs=Zs||(Zs={}))[Xs.OK=0]="OK",Xs[Xs.CANCELLED=1]="CANCELLED",Xs[Xs.UNKNOWN=2]="UNKNOWN",Xs[Xs.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",Xs[Xs.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",Xs[Xs.NOT_FOUND=5]="NOT_FOUND",Xs[Xs.ALREADY_EXISTS=6]="ALREADY_EXISTS",Xs[Xs.PERMISSION_DENIED=7]="PERMISSION_DENIED",Xs[Xs.UNAUTHENTICATED=16]="UNAUTHENTICATED",Xs[Xs.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",Xs[Xs.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",Xs[Xs.ABORTED=10]="ABORTED",Xs[Xs.OUT_OF_RANGE=11]="OUT_OF_RANGE",Xs[Xs.UNIMPLEMENTED=12]="UNIMPLEMENTED",Xs[Xs.INTERNAL=13]="INTERNAL",Xs[Xs.UNAVAILABLE=14]="UNAVAILABLE",Xs[Xs.DATA_LOSS=15]="DATA_LOSS";class no{constructor(t,e){this.comparator=t,this.root=e||io.EMPTY}insert(t,e){return new no(this.comparator,this.root.insert(t,e,this.comparator).copy(null,null,io.BLACK,null,null))}remove(t){return new no(this.comparator,this.root.remove(t,this.comparator).copy(null,null,io.BLACK,null,null))}get(t){let e=this.root;for(;!e.isEmpty();){const n=this.comparator(t,e.key);if(0===n)return e.value;n<0?e=e.left:n>0&&(e=e.right)}return null}indexOf(t){let e=0,n=this.root;for(;!n.isEmpty();){const r=this.comparator(t,n.key);if(0===r)return e+n.left.size;r<0?n=n.left:(e+=n.left.size+1,n=n.right)}return-1}isEmpty(){return this.root.isEmpty()}get size(){return this.root.size}minKey(){return this.root.minKey()}maxKey(){return this.root.maxKey()}inorderTraversal(t){return this.root.inorderTraversal(t)}forEach(t){this.inorderTraversal(((e,n)=>(t(e,n),!1)))}toString(){const t=[];return this.inorderTraversal(((e,n)=>(t.push(`${e}:${n}`),!1))),`{${t.join(", ")}}`}reverseTraversal(t){return this.root.reverseTraversal(t)}getIterator(){return new ro(this.root,null,this.comparator,!1)}getIteratorFrom(t){return new ro(this.root,t,this.comparator,!1)}getReverseIterator(){return new ro(this.root,null,this.comparator,!0)}getReverseIteratorFrom(t){return new ro(this.root,t,this.comparator,!0)}}class ro{constructor(t,e,n,r){this.isReverse=r,this.nodeStack=[];let i=1;for(;!t.isEmpty();)if(i=e?n(t.key,e):1,r&&(i*=-1),i<0)t=this.isReverse?t.left:t.right;else{if(0===i){this.nodeStack.push(t);break}this.nodeStack.push(t),t=this.isReverse?t.right:t.left}}getNext(){let t=this.nodeStack.pop();const e={key:t.key,value:t.value};if(this.isReverse)for(t=t.left;!t.isEmpty();)this.nodeStack.push(t),t=t.right;else for(t=t.right;!t.isEmpty();)this.nodeStack.push(t),t=t.left;return e}hasNext(){return this.nodeStack.length>0}peek(){if(0===this.nodeStack.length)return null;const t=this.nodeStack[this.nodeStack.length-1];return{key:t.key,value:t.value}}}class io{constructor(t,e,n,r,i){this.key=t,this.value=e,this.color=null!=n?n:io.RED,this.left=null!=r?r:io.EMPTY,this.right=null!=i?i:io.EMPTY,this.size=this.left.size+1+this.right.size}copy(t,e,n,r,i){return new io(null!=t?t:this.key,null!=e?e:this.value,null!=n?n:this.color,null!=r?r:this.left,null!=i?i:this.right)}isEmpty(){return!1}inorderTraversal(t){return this.left.inorderTraversal(t)||t(this.key,this.value)||this.right.inorderTraversal(t)}reverseTraversal(t){return this.right.reverseTraversal(t)||t(this.key,this.value)||this.left.reverseTraversal(t)}min(){return this.left.isEmpty()?this:this.left.min()}minKey(){return this.min().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(t,e,n){let r=this;const i=n(t,r.key);return r=i<0?r.copy(null,null,null,r.left.insert(t,e,n),null):0===i?r.copy(null,e,null,null,null):r.copy(null,null,null,null,r.right.insert(t,e,n)),r.fixUp()}removeMin(){if(this.left.isEmpty())return io.EMPTY;let t=this;return t.left.isRed()||t.left.left.isRed()||(t=t.moveRedLeft()),t=t.copy(null,null,null,t.left.removeMin(),null),t.fixUp()}remove(t,e){let n,r=this;if(e(t,r.key)<0)r.left.isEmpty()||r.left.isRed()||r.left.left.isRed()||(r=r.moveRedLeft()),r=r.copy(null,null,null,r.left.remove(t,e),null);else{if(r.left.isRed()&&(r=r.rotateRight()),r.right.isEmpty()||r.right.isRed()||r.right.left.isRed()||(r=r.moveRedRight()),0===e(t,r.key)){if(r.right.isEmpty())return io.EMPTY;n=r.right.min(),r=r.copy(n.key,n.value,null,null,r.right.removeMin())}r=r.copy(null,null,null,null,r.right.remove(t,e))}return r.fixUp()}isRed(){return this.color}fixUp(){let t=this;return t.right.isRed()&&!t.left.isRed()&&(t=t.rotateLeft()),t.left.isRed()&&t.left.left.isRed()&&(t=t.rotateRight()),t.left.isRed()&&t.right.isRed()&&(t=t.colorFlip()),t}moveRedLeft(){let t=this.colorFlip();return t.right.left.isRed()&&(t=t.copy(null,null,null,null,t.right.rotateRight()),t=t.rotateLeft(),t=t.colorFlip()),t}moveRedRight(){let t=this.colorFlip();return t.left.left.isRed()&&(t=t.rotateRight(),t=t.colorFlip()),t}rotateLeft(){const t=this.copy(null,null,io.RED,null,this.right.left);return this.right.copy(null,null,this.color,t,null)}rotateRight(){const t=this.copy(null,null,io.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,t)}colorFlip(){const t=this.left.copy(null,null,!this.left.color,null,null),e=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,t,e)}checkMaxDepth(){const t=this.check();return Math.pow(2,t)<=this.size+1}check(){if(this.isRed()&&this.left.isRed())throw Nr();if(this.right.isRed())throw Nr();const t=this.left.check();if(t!==this.right.check())throw Nr();return t+(this.isRed()?0:1)}}io.EMPTY=null,io.RED=!0,io.BLACK=!1,io.EMPTY=new class{constructor(){this.size=0}get key(){throw Nr()}get value(){throw Nr()}get color(){throw Nr()}get left(){throw Nr()}get right(){throw Nr()}copy(t,e,n,r,i){return this}insert(t,e,n){return new io(t,e)}remove(t,e){return this}isEmpty(){return!0}inorderTraversal(t){return!1}reverseTraversal(t){return!1}minKey(){return null}maxKey(){return null}isRed(){return!1}checkMaxDepth(){return!0}check(){return 0}};class so{constructor(t){this.comparator=t,this.data=new no(this.comparator)}has(t){return null!==this.data.get(t)}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(t){return this.data.indexOf(t)}forEach(t){this.data.inorderTraversal(((e,n)=>(t(e),!1)))}forEachInRange(t,e){const n=this.data.getIteratorFrom(t[0]);for(;n.hasNext();){const r=n.getNext();if(this.comparator(r.key,t[1])>=0)return;e(r.key)}}forEachWhile(t,e){let n;for(n=void 0!==e?this.data.getIteratorFrom(e):this.data.getIterator();n.hasNext();)if(!t(n.getNext().key))return}firstAfterOrEqual(t){const e=this.data.getIteratorFrom(t);return e.hasNext()?e.getNext().key:null}getIterator(){return new oo(this.data.getIterator())}getIteratorFrom(t){return new oo(this.data.getIteratorFrom(t))}add(t){return this.copy(this.data.remove(t).insert(t,!0))}delete(t){return this.has(t)?this.copy(this.data.remove(t)):this}isEmpty(){return this.data.isEmpty()}unionWith(t){let e=this;return e.size<t.size&&(e=t,t=this),t.forEach((t=>{e=e.add(t)})),e}isEqual(t){if(!(t instanceof so))return!1;if(this.size!==t.size)return!1;const e=this.data.getIterator(),n=t.data.getIterator();for(;e.hasNext();){const t=e.getNext().key,r=n.getNext().key;if(0!==this.comparator(t,r))return!1}return!0}toArray(){const t=[];return this.forEach((e=>{t.push(e)})),t}toString(){const t=[];return this.forEach((e=>t.push(e))),"SortedSet("+t.toString()+")"}copy(t){const e=new so(this.comparator);return e.data=t,e}}class oo{constructor(t){this.iter=t}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}const ao=new no(vi.comparator);function co(){return ao}const uo=new no(vi.comparator);function ho(){return uo}const lo=new no(vi.comparator);function fo(){return lo}const po=new so(vi.comparator);function mo(...t){let e=po;for(const n of t)e=e.add(n);return e}const go=new so(Hr);function yo(){return go}class vo{constructor(t,e,n,r,i){this.snapshotVersion=t,this.targetChanges=e,this.targetMismatches=n,this.documentUpdates=r,this.resolvedLimboDocuments=i}static createSynthesizedRemoteEventForCurrentChange(t,e){const n=new Map;return n.set(t,bo.createSynthesizedTargetChangeForCurrentChange(t,e)),new vo(Jr.min(),n,yo(),co(),mo())}}class bo{constructor(t,e,n,r,i){this.resumeToken=t,this.current=e,this.addedDocuments=n,this.modifiedDocuments=r,this.removedDocuments=i}static createSynthesizedTargetChangeForCurrentChange(t,e){return new bo(ai.EMPTY_BYTE_STRING,e,mo(),mo(),mo())}}class wo{constructor(t,e,n,r){this.$=t,this.removedTargetIds=e,this.key=n,this.O=r}}class Io{constructor(t,e){this.targetId=t,this.F=e}}class To{constructor(t,e,n=ai.EMPTY_BYTE_STRING,r=null){this.state=t,this.targetIds=e,this.resumeToken=n,this.cause=r}}class _o{constructor(){this.M=0,this.L=ko(),this.B=ai.EMPTY_BYTE_STRING,this.U=!1,this.q=!0}get current(){return this.U}get resumeToken(){return this.B}get K(){return 0!==this.M}get j(){return this.q}W(t){t.approximateByteSize()>0&&(this.q=!0,this.B=t)}G(){let t=mo(),e=mo(),n=mo();return this.L.forEach(((r,i)=>{switch(i){case 0:t=t.add(r);break;case 2:e=e.add(r);break;case 1:n=n.add(r);break;default:Nr()}})),new bo(this.B,this.U,t,e,n)}H(){this.q=!1,this.L=ko()}J(t,e){this.q=!0,this.L=this.L.insert(t,e)}Y(t){this.q=!0,this.L=this.L.remove(t)}X(){this.M+=1}Z(){this.M-=1}tt(){this.q=!0,this.U=!0}}class Eo{constructor(t){this.et=t,this.nt=new Map,this.st=co(),this.it=So(),this.rt=new so(Hr)}ot(t){for(const e of t.$)t.O&&t.O.isFoundDocument()?this.at(e,t.O):this.ct(e,t.key,t.O);for(const e of t.removedTargetIds)this.ct(e,t.key,t.O)}ut(t){this.forEachTarget(t,(e=>{const n=this.ht(e);switch(t.state){case 0:this.lt(e)&&n.W(t.resumeToken);break;case 1:n.Z(),n.K||n.H(),n.W(t.resumeToken);break;case 2:n.Z(),n.K||this.removeTarget(e);break;case 3:this.lt(e)&&(n.tt(),n.W(t.resumeToken));break;case 4:this.lt(e)&&(this.ft(e),n.W(t.resumeToken));break;default:Nr()}}))}forEachTarget(t,e){t.targetIds.length>0?t.targetIds.forEach(e):this.nt.forEach(((t,n)=>{this.lt(n)&&e(n)}))}dt(t){const e=t.targetId,n=t.F.count,r=this.wt(e);if(r){const t=r.target;if(ji(t))if(0===n){const n=new vi(t.path);this.ct(e,n,Li.newNoDocument(n,Jr.min()))}else xr(1===n);else this._t(e)!==n&&(this.ft(e),this.rt=this.rt.add(e))}}gt(t){const e=new Map;this.nt.forEach(((n,r)=>{const i=this.wt(r);if(i){if(n.current&&ji(i.target)){const e=new vi(i.target.path);null!==this.st.get(e)||this.yt(r,e)||this.ct(r,e,Li.newNoDocument(e,t))}n.j&&(e.set(r,n.G()),n.H())}}));let n=mo();this.it.forEach(((t,e)=>{let r=!0;e.forEachWhile((t=>{const e=this.wt(t);return!e||2===e.purpose||(r=!1,!1)})),r&&(n=n.add(t))}));const r=new vo(t,e,this.rt,this.st,n);return this.st=co(),this.it=So(),this.rt=new so(Hr),r}at(t,e){if(!this.lt(t))return;const n=this.yt(t,e.key)?2:0;this.ht(t).J(e.key,n),this.st=this.st.insert(e.key,e),this.it=this.it.insert(e.key,this.Tt(e.key).add(t))}ct(t,e,n){if(!this.lt(t))return;const r=this.ht(t);this.yt(t,e)?r.J(e,1):r.Y(e),this.it=this.it.insert(e,this.Tt(e).delete(t)),n&&(this.st=this.st.insert(e,n))}removeTarget(t){this.nt.delete(t)}_t(t){const e=this.ht(t).G();return this.et.getRemoteKeysForTarget(t).size+e.addedDocuments.size-e.removedDocuments.size}X(t){this.ht(t).X()}ht(t){let e=this.nt.get(t);return e||(e=new _o,this.nt.set(t,e)),e}Tt(t){let e=this.it.get(t);return e||(e=new so(Hr),this.it=this.it.insert(t,e)),e}lt(t){const e=null!==this.wt(t);return e||Er("WatchChangeAggregator","Detected inactive target",t),e}wt(t){const e=this.nt.get(t);return e&&e.K?null:this.et.Et(t)}ft(t){this.nt.set(t,new _o),this.et.getRemoteKeysForTarget(t).forEach((e=>{this.ct(t,e,null)}))}yt(t,e){return this.et.getRemoteKeysForTarget(t).has(e)}}function So(){return new no(vi.comparator)}function ko(){return new no(vi.comparator)}const Ao={asc:"ASCENDING",desc:"DESCENDING"},No={"<":"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"};class xo{constructor(t,e){this.databaseId=t,this.C=e}}function Co(t,e){return t.C?`${new Date(1e3*e.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+e.nanoseconds).slice(-9)}Z`:{seconds:""+e.seconds,nanos:e.nanoseconds}}function Do(t,e){return t.C?e.toBase64():e.toUint8Array()}function Oo(t,e){return Co(t,e.toTimestamp())}function Ro(t){return xr(!!t),Jr.fromTimestamp(function(t){const e=ui(t);return new Qr(e.seconds,e.nanos)}(t))}function Po(t,e){return function(t){return new ni(["projects",t.projectId,"databases",t.database])}(t).child("documents").child(e).canonicalString()}function Lo(t){const e=ni.fromString(t);return xr(sa(e)),e}function Mo(t,e){return Po(t.databaseId,e.path)}function Fo(t,e){const n=Lo(e);if(n.get(1)!==t.databaseId.projectId)throw new Rr(Or.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+n.get(1)+" vs "+t.databaseId.projectId);if(n.get(3)!==t.databaseId.database)throw new Rr(Or.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+n.get(3)+" vs "+t.databaseId.database);return new vi(qo(n))}function Uo(t,e){return Po(t.databaseId,e)}function Vo(t){const e=Lo(t);return 4===e.length?ni.emptyPath():qo(e)}function jo(t){return new ni(["projects",t.databaseId.projectId,"databases",t.databaseId.database]).canonicalString()}function qo(t){return xr(t.length>4&&"documents"===t.get(4)),t.popFirst(5)}function Bo(t,e,n){return{name:Mo(t,e),fields:n.value.mapValue.fields}}function zo(t,e,n){const r=Fo(t,e.name),i=Ro(e.updateTime),s=new Ri({mapValue:{fields:e.fields}}),o=Li.newFoundDocument(r,i,s);return n&&o.setHasCommittedMutations(),n?o.setHasCommittedMutations():o}function Ko(t,e){let n;if(e instanceof Ks)n={update:Bo(t,e.key,e.value)};else if(e instanceof Ys)n={delete:Mo(t,e.key)};else if(e instanceof Ws)n={update:Bo(t,e.key,e.data),updateMask:ia(e.fieldMask)};else{if(!(e instanceof Qs))return Nr();n={verify:Mo(t,e.key)}}return e.fieldTransforms.length>0&&(n.updateTransforms=e.fieldTransforms.map((t=>function(t,e){const n=e.transform;if(n instanceof ks)return{fieldPath:e.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(n instanceof As)return{fieldPath:e.field.canonicalString(),appendMissingElements:{values:n.elements}};if(n instanceof xs)return{fieldPath:e.field.canonicalString(),removeAllFromArray:{values:n.elements}};if(n instanceof Ds)return{fieldPath:e.field.canonicalString(),increment:n.N};throw Nr()}(0,t)))),e.precondition.isNone||(n.currentDocument=function(t,e){return void 0!==e.updateTime?{updateTime:Oo(t,e.updateTime)}:void 0!==e.exists?{exists:e.exists}:Nr()}(t,e.precondition)),n}function Wo(t,e){const n=e.currentDocument?function(t){return void 0!==t.updateTime?Ms.updateTime(Ro(t.updateTime)):void 0!==t.exists?Ms.exists(t.exists):Ms.none()}(e.currentDocument):Ms.none(),r=e.updateTransforms?e.updateTransforms.map((e=>function(t,e){let n=null;if("setToServerValue"in e)xr("REQUEST_TIME"===e.setToServerValue),n=new ks;else if("appendMissingElements"in e){const t=e.appendMissingElements.values||[];n=new As(t)}else if("removeAllFromArray"in e){const t=e.removeAllFromArray.values||[];n=new xs(t)}else"increment"in e?n=new Ds(t,e.increment):Nr();const r=ii.fromServerFormat(e.fieldPath);return new Ps(r,n)}(t,e))):[];if(e.update){e.update.name;const i=Fo(t,e.update.name),s=new Ri({mapValue:{fields:e.update.fields}});if(e.updateMask){const t=function(t){const e=t.fieldPaths||[];return new si(e.map((t=>ii.fromServerFormat(t))))}(e.updateMask);return new Ws(i,s,t,n,r)}return new Ks(i,s,n,r)}if(e.delete){const r=Fo(t,e.delete);return new Ys(r,n)}if(e.verify){const r=Fo(t,e.verify);return new Qs(r,n)}return Nr()}function Go(t,e){return{documents:[Uo(t,e.path)]}}function Ho(t,e){const n={structuredQuery:{}},r=e.path;null!==e.collectionGroup?(n.parent=Uo(t,r),n.structuredQuery.from=[{collectionId:e.collectionGroup,allDescendants:!0}]):(n.parent=Uo(t,r.popLast()),n.structuredQuery.from=[{collectionId:r.lastSegment()}]);const i=function(t){if(0===t.length)return;const e=t.map((t=>function(t){if("=="===t.op){if(Ci(t.value))return{unaryFilter:{field:ta(t.field),op:"IS_NAN"}};if(xi(t.value))return{unaryFilter:{field:ta(t.field),op:"IS_NULL"}}}else if("!="===t.op){if(Ci(t.value))return{unaryFilter:{field:ta(t.field),op:"IS_NOT_NAN"}};if(xi(t.value))return{unaryFilter:{field:ta(t.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:ta(t.field),op:Xo(t.op),value:t.value}}}(t)));return 1===e.length?e[0]:{compositeFilter:{op:"AND",filters:e}}}(e.filters);i&&(n.structuredQuery.where=i);const s=function(t){if(0!==t.length)return t.map((t=>function(t){return{field:ta(t.field),direction:Zo(t.dir)}}(t)))}(e.orderBy);s&&(n.structuredQuery.orderBy=s);const o=function(t,e){return t.C||mi(e)?e:{value:e}}(t,e.limit);return null!==o&&(n.structuredQuery.limit=o),e.startAt&&(n.structuredQuery.startAt=Qo(e.startAt)),e.endAt&&(n.structuredQuery.endAt=Qo(e.endAt)),n}function $o(t){let e=Vo(t.parent);const n=t.structuredQuery,r=n.from?n.from.length:0;let i=null;if(r>0){xr(1===r);const t=n.from[0];t.allDescendants?i=t.collectionId:e=e.child(t.collectionId)}let s=[];n.where&&(s=Yo(n.where));let o=[];n.orderBy&&(o=n.orderBy.map((t=>function(t){return new Zi(ea(t.field),function(t){switch(t){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(t.direction))}(t))));let a=null;n.limit&&(a=function(t){let e;return e="object"==typeof t?t.value:t,mi(e)?null:e}(n.limit));let c=null;n.startAt&&(c=Jo(n.startAt));let u=null;return n.endAt&&(u=Jo(n.endAt)),rs(e,i,o,s,a,"F",c,u)}function Yo(t){return t?void 0!==t.unaryFilter?[ra(t)]:void 0!==t.fieldFilter?[na(t)]:void 0!==t.compositeFilter?t.compositeFilter.filters.map((t=>Yo(t))).reduce(((t,e)=>t.concat(e))):Nr():[]}function Qo(t){return{before:t.before,values:t.position}}function Jo(t){const e=!!t.before,n=t.values||[];return new Qi(n,e)}function Zo(t){return Ao[t]}function Xo(t){return No[t]}function ta(t){return{fieldPath:t.canonicalString()}}function ea(t){return ii.fromServerFormat(t.fieldPath)}function na(t){return qi.create(ea(t.fieldFilter.field),function(t){switch(t){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 Nr()}}(t.fieldFilter.op),t.fieldFilter.value)}function ra(t){switch(t.unaryFilter.op){case"IS_NAN":const e=ea(t.unaryFilter.field);return qi.create(e,"==",{doubleValue:NaN});case"IS_NULL":const n=ea(t.unaryFilter.field);return qi.create(n,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":const r=ea(t.unaryFilter.field);return qi.create(r,"!=",{doubleValue:NaN});case"IS_NOT_NULL":const i=ea(t.unaryFilter.field);return qi.create(i,"!=",{nullValue:"NULL_VALUE"});default:return Nr()}}function ia(t){const e=[];return t.fields.forEach((t=>e.push(t.canonicalString()))),{fieldPaths:e}}function sa(t){return t.length>=4&&"projects"===t.get(0)&&"databases"===t.get(2)}function oa(t){let e="";for(let n=0;n<t.length;n++)e.length>0&&(e=ca(e)),e=aa(t.get(n),e);return ca(e)}function aa(t,e){let n=e;const r=t.length;for(let e=0;e<r;e++){const r=t.charAt(e);switch(r){case"\0":n+="";break;case"":n+="";break;default:n+=r}}return n}function ca(t){return t+""}function ua(t){const e=t.length;if(xr(e>=2),2===e)return xr(""===t.charAt(0)&&""===t.charAt(1)),ni.emptyPath();const n=e-2,r=[];let i="";for(let s=0;s<e;){const e=t.indexOf("",s);switch((e<0||e>n)&&Nr(),t.charAt(e+1)){case"":const n=t.substring(s,e);let o;0===i.length?o=n:(i+=n,o=i,i=""),r.push(o);break;case"":i+=t.substring(s,e),i+="\0";break;case"":i+=t.substring(s,e+1);break;default:Nr()}s=e+2}return new ni(r)}class ha{constructor(t,e){this.seconds=t,this.nanoseconds=e}}class la{constructor(t,e,n){this.ownerId=t,this.allowTabSynchronization=e,this.leaseTimestampMs=n}}la.store="owner",la.key="owner";class da{constructor(t,e,n){this.userId=t,this.lastAcknowledgedBatchId=e,this.lastStreamToken=n}}da.store="mutationQueues",da.keyPath="userId";class fa{constructor(t,e,n,r,i){this.userId=t,this.batchId=e,this.localWriteTimeMs=n,this.baseMutations=r,this.mutations=i}}fa.store="mutations",fa.keyPath="batchId",fa.userMutationsIndex="userMutationsIndex",fa.userMutationsKeyPath=["userId","batchId"];class pa{constructor(){}static prefixForUser(t){return[t]}static prefixForPath(t,e){return[t,oa(e)]}static key(t,e,n){return[t,oa(e),n]}}pa.store="documentMutations",pa.PLACEHOLDER=new pa;class ma{constructor(t,e){this.path=t,this.readTime=e}}class ga{constructor(t,e){this.path=t,this.version=e}}class ya{constructor(t,e,n,r,i,s){this.unknownDocument=t,this.noDocument=e,this.document=n,this.hasCommittedMutations=r,this.readTime=i,this.parentPath=s}}ya.store="remoteDocuments",ya.readTimeIndex="readTimeIndex",ya.readTimeIndexPath="readTime",ya.collectionReadTimeIndex="collectionReadTimeIndex",ya.collectionReadTimeIndexPath=["parentPath","readTime"];class va{constructor(t){this.byteSize=t}}va.store="remoteDocumentGlobal",va.key="remoteDocumentGlobalKey";class ba{constructor(t,e,n,r,i,s,o){this.targetId=t,this.canonicalId=e,this.readTime=n,this.resumeToken=r,this.lastListenSequenceNumber=i,this.lastLimboFreeSnapshotVersion=s,this.query=o}}ba.store="targets",ba.keyPath="targetId",ba.queryTargetsIndexName="queryTargetsIndex",ba.queryTargetsKeyPath=["canonicalId","targetId"];class wa{constructor(t,e,n){this.targetId=t,this.path=e,this.sequenceNumber=n}}wa.store="targetDocuments",wa.keyPath=["targetId","path"],wa.documentTargetsIndex="documentTargetsIndex",wa.documentTargetsKeyPath=["path","targetId"];class Ia{constructor(t,e,n,r){this.highestTargetId=t,this.highestListenSequenceNumber=e,this.lastRemoteSnapshotVersion=n,this.targetCount=r}}Ia.key="targetGlobalKey",Ia.store="targetGlobal";class Ta{constructor(t,e){this.collectionId=t,this.parent=e}}Ta.store="collectionParents",Ta.keyPath=["collectionId","parent"];class _a{constructor(t,e,n,r){this.clientId=t,this.updateTimeMs=e,this.networkEnabled=n,this.inForeground=r}}_a.store="clientMetadata",_a.keyPath="clientId";class Ea{constructor(t,e,n){this.bundleId=t,this.createTime=e,this.version=n}}Ea.store="bundles",Ea.keyPath="bundleId";class Sa{constructor(t,e,n){this.name=t,this.readTime=e,this.bundledQuery=n}}Sa.store="namedQueries",Sa.keyPath="name";const ka=[da.store,fa.store,pa.store,ya.store,ba.store,la.store,Ia.store,wa.store,_a.store,va.store,Ta.store,Ea.store,Sa.store],Aa="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class Na{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(t){this.onCommittedListeners.push(t)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach((t=>t()))}}class xa{constructor(t){this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,t((t=>{this.isDone=!0,this.result=t,this.nextCallback&&this.nextCallback(t)}),(t=>{this.isDone=!0,this.error=t,this.catchCallback&&this.catchCallback(t)}))}catch(t){return this.next(void 0,t)}next(t,e){return this.callbackAttached&&Nr(),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(e,this.error):this.wrapSuccess(t,this.result):new xa(((n,r)=>{this.nextCallback=e=>{this.wrapSuccess(t,e).next(n,r)},this.catchCallback=t=>{this.wrapFailure(e,t).next(n,r)}}))}toPromise(){return new Promise(((t,e)=>{this.next(t,e)}))}wrapUserFunction(t){try{const e=t();return e instanceof xa?e:xa.resolve(e)}catch(t){return xa.reject(t)}}wrapSuccess(t,e){return t?this.wrapUserFunction((()=>t(e))):xa.resolve(e)}wrapFailure(t,e){return t?this.wrapUserFunction((()=>t(e))):xa.reject(e)}static resolve(t){return new xa(((e,n)=>{e(t)}))}static reject(t){return new xa(((e,n)=>{n(t)}))}static waitFor(t){return new xa(((e,n)=>{let r=0,i=0,s=!1;t.forEach((t=>{++r,t.next((()=>{++i,s&&i===r&&e()}),(t=>n(t)))})),s=!0,i===r&&e()}))}static or(t){let e=xa.resolve(!1);for(const n of t)e=e.next((t=>t?xa.resolve(t):n()));return e}static forEach(t,e){const n=[];return t.forEach(((t,r)=>{n.push(e.call(this,t,r))})),this.waitFor(n)}}class Ca{constructor(t,e){this.action=t,this.transaction=e,this.aborted=!1,this.It=new Pr,this.transaction.oncomplete=()=>{this.It.resolve()},this.transaction.onabort=()=>{e.error?this.It.reject(new Ra(t,e.error)):this.It.resolve()},this.transaction.onerror=e=>{const n=Ua(e.target.error);this.It.reject(new Ra(t,n))}}static open(t,e,n,r){try{return new Ca(e,t.transaction(r,n))}catch(t){throw new Ra(e,t)}}get At(){return this.It.promise}abort(t){t&&this.It.reject(t),this.aborted||(Er("SimpleDb","Aborting transaction:",t?t.message:"Client-initiated abort"),this.aborted=!0,this.transaction.abort())}store(t){const e=this.transaction.objectStore(t);return new La(e)}}class Da{constructor(t,e,n){this.name=t,this.version=e,this.Rt=n,12.2===Da.bt((0,a.z$)())&&Sr("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.")}static delete(t){return Er("SimpleDb","Removing database:",t),Ma(window.indexedDB.deleteDatabase(t)).toPromise()}static Pt(){if(!(0,a.hl)())return!1;if(Da.vt())return!0;const t=(0,a.z$)(),e=Da.bt(t),n=0<e&&e<10,r=Da.Vt(t),i=0<r&&r<4.5;return!(t.indexOf("MSIE ")>0||t.indexOf("Trident/")>0||t.indexOf("Edge/")>0||n||i)}static vt(){var t;return"undefined"!=typeof process&&"YES"===(null===(t=process.env)||void 0===t?void 0:t.St)}static Dt(t,e){return t.store(e)}static bt(t){const e=t.match(/i(?:phone|pad|pod) os ([\d_]+)/i),n=e?e[1].split("_").slice(0,2).join("."):"-1";return Number(n)}static Vt(t){const e=t.match(/Android ([\d.]+)/i),n=e?e[1].split(".").slice(0,2).join("."):"-1";return Number(n)}async Ct(t){return this.db||(Er("SimpleDb","Opening database:",this.name),this.db=await new Promise(((e,n)=>{const r=indexedDB.open(this.name,this.version);r.onsuccess=t=>{const n=t.target.result;e(n)},r.onblocked=()=>{n(new Ra(t,"Cannot upgrade IndexedDB schema while another tab is open. Close all tabs that access Firestore and reload this page to proceed."))},r.onerror=e=>{const r=e.target.error;"VersionError"===r.name?n(new Rr(Or.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"===r.name?n(new Rr(Or.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: "+r)):n(new Ra(t,r))},r.onupgradeneeded=t=>{Er("SimpleDb",'Database "'+this.name+'" requires upgrade from version:',t.oldVersion);const e=t.target.result;this.Rt.Nt(e,r.transaction,t.oldVersion,this.version).next((()=>{Er("SimpleDb","Database upgrade to version "+this.version+" complete")}))}}))),this.kt&&(this.db.onversionchange=t=>this.kt(t)),this.db}xt(t){this.kt=t,this.db&&(this.db.onversionchange=e=>t(e))}async runTransaction(t,e,n,r){const i="readonly"===e;let s=0;for(;;){++s;try{this.db=await this.Ct(t);const e=Ca.open(this.db,t,i?"readonly":"readwrite",n),s=r(e).catch((t=>(e.abort(t),xa.reject(t)))).toPromise();return s.catch((()=>{})),await e.At,s}catch(t){const e="FirebaseError"!==t.name&&s<3;if(Er("SimpleDb","Transaction failed with error:",t.message,"Retrying:",e),this.close(),!e)return Promise.reject(t)}}}close(){this.db&&this.db.close(),this.db=void 0}}class Oa{constructor(t){this.$t=t,this.Ot=!1,this.Ft=null}get isDone(){return this.Ot}get Mt(){return this.Ft}set cursor(t){this.$t=t}done(){this.Ot=!0}Lt(t){this.Ft=t}delete(){return Ma(this.$t.delete())}}class Ra extends Rr{constructor(t,e){super(Or.UNAVAILABLE,`IndexedDB transaction '${t}' failed: ${e}`),this.name="IndexedDbTransactionError"}}function Pa(t){return"IndexedDbTransactionError"===t.name}class La{constructor(t){this.store=t}put(t,e){let n;return void 0!==e?(Er("SimpleDb","PUT",this.store.name,t,e),n=this.store.put(e,t)):(Er("SimpleDb","PUT",this.store.name,"<auto-key>",t),n=this.store.put(t)),Ma(n)}add(t){return Er("SimpleDb","ADD",this.store.name,t,t),Ma(this.store.add(t))}get(t){return Ma(this.store.get(t)).next((e=>(void 0===e&&(e=null),Er("SimpleDb","GET",this.store.name,t,e),e)))}delete(t){return Er("SimpleDb","DELETE",this.store.name,t),Ma(this.store.delete(t))}count(){return Er("SimpleDb","COUNT",this.store.name),Ma(this.store.count())}Bt(t,e){const n=this.cursor(this.options(t,e)),r=[];return this.Ut(n,((t,e)=>{r.push(e)})).next((()=>r))}qt(t,e){Er("SimpleDb","DELETE ALL",this.store.name);const n=this.options(t,e);n.Kt=!1;const r=this.cursor(n);return this.Ut(r,((t,e,n)=>n.delete()))}jt(t,e){let n;e?n=t:(n={},e=t);const r=this.cursor(n);return this.Ut(r,e)}Qt(t){const e=this.cursor({});return new xa(((n,r)=>{e.onerror=t=>{const e=Ua(t.target.error);r(e)},e.onsuccess=e=>{const r=e.target.result;r?t(r.primaryKey,r.value).next((t=>{t?r.continue():n()})):n()}}))}Ut(t,e){const n=[];return new xa(((r,i)=>{t.onerror=t=>{i(t.target.error)},t.onsuccess=t=>{const i=t.target.result;if(!i)return void r();const s=new Oa(i),o=e(i.primaryKey,i.value,s);if(o instanceof xa){const t=o.catch((t=>(s.done(),xa.reject(t))));n.push(t)}s.isDone?r():null===s.Mt?i.continue():i.continue(s.Mt)}})).next((()=>xa.waitFor(n)))}options(t,e){let n;return void 0!==t&&("string"==typeof t?n=t:e=t),{index:n,range:e}}cursor(t){let e="next";if(t.reverse&&(e="prev"),t.index){const n=this.store.index(t.index);return t.Kt?n.openKeyCursor(t.range,e):n.openCursor(t.range,e)}return this.store.openCursor(t.range,e)}}function Ma(t){return new xa(((e,n)=>{t.onsuccess=t=>{const n=t.target.result;e(n)},t.onerror=t=>{const e=Ua(t.target.error);n(e)}}))}let Fa=!1;function Ua(t){const e=Da.bt((0,a.z$)());if(e>=12.2&&e<13){const e="An internal error was encountered in the Indexed Database server";if(t.message.indexOf(e)>=0){const t=new Rr("internal",`IOS_INDEXEDDB_BUG1: IndexedDb has thrown '${e}'. This is likely due to an unavoidable bug in iOS. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.`);return Fa||(Fa=!0,setTimeout((()=>{throw t}),0)),t}}return t}class Va extends Na{constructor(t,e){super(),this.Wt=t,this.currentSequenceNumber=e}}function ja(t,e){const n=Dr(t);return Da.Dt(n.Wt,e)}class qa{constructor(t,e,n,r){this.batchId=t,this.localWriteTime=e,this.baseMutations=n,this.mutations=r}applyToRemoteDocument(t,e){const n=e.mutationResults;for(let e=0;e<this.mutations.length;e++){const r=this.mutations[e];r.key.isEqual(t.key)&&Vs(r,t,n[e])}}applyToLocalView(t){for(const e of this.baseMutations)e.key.isEqual(t.key)&&js(e,t,this.localWriteTime);for(const e of this.mutations)e.key.isEqual(t.key)&&js(e,t,this.localWriteTime)}applyToLocalDocumentSet(t){this.mutations.forEach((e=>{const n=t.get(e.key),r=n;this.applyToLocalView(r),n.isValidDocument()||r.convertToNoDocument(Jr.min())}))}keys(){return this.mutations.reduce(((t,e)=>t.add(e.key)),mo())}isEqual(t){return this.batchId===t.batchId&&$r(this.mutations,t.mutations,((t,e)=>Bs(t,e)))&&$r(this.baseMutations,t.baseMutations,((t,e)=>Bs(t,e)))}}class Ba{constructor(t,e,n,r){this.batch=t,this.commitVersion=e,this.mutationResults=n,this.docVersions=r}static from(t,e,n){xr(t.mutations.length===n.length);let r=fo();const i=t.mutations;for(let t=0;t<i.length;t++)r=r.insert(i[t].key,n[t].version);return new Ba(t,e,n,r)}}class za{constructor(t,e,n,r,i=Jr.min(),s=Jr.min(),o=ai.EMPTY_BYTE_STRING){this.target=t,this.targetId=e,this.purpose=n,this.sequenceNumber=r,this.snapshotVersion=i,this.lastLimboFreeSnapshotVersion=s,this.resumeToken=o}withSequenceNumber(t){return new za(this.target,this.targetId,this.purpose,t,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken)}withResumeToken(t,e){return new za(this.target,this.targetId,this.purpose,this.sequenceNumber,e,this.lastLimboFreeSnapshotVersion,t)}withLastLimboFreeSnapshotVersion(t){return new za(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,t,this.resumeToken)}}class Ka{constructor(t){this.Gt=t}}function Wa(t,e){if(e.document)return zo(t.Gt,e.document,!!e.hasCommittedMutations);if(e.noDocument){const t=vi.fromSegments(e.noDocument.path),n=Qa(e.noDocument.readTime),r=Li.newNoDocument(t,n);return e.hasCommittedMutations?r.setHasCommittedMutations():r}if(e.unknownDocument){const t=vi.fromSegments(e.unknownDocument.path),n=Qa(e.unknownDocument.version);return Li.newUnknownDocument(t,n)}return Nr()}function Ga(t,e,n){const r=Ha(n),i=e.key.path.popLast().toArray();if(e.isFoundDocument()){const n=function(t,e){return{name:Mo(t,e.key),fields:e.data.value.mapValue.fields,updateTime:Co(t,e.version.toTimestamp())}}(t.Gt,e),s=e.hasCommittedMutations;return new ya(null,null,n,s,r,i)}if(e.isNoDocument()){const t=e.key.path.toArray(),n=Ya(e.version),s=e.hasCommittedMutations;return new ya(null,new ma(t,n),null,s,r,i)}if(e.isUnknownDocument()){const t=e.key.path.toArray(),n=Ya(e.version);return new ya(new ga(t,n),null,null,!0,r,i)}return Nr()}function Ha(t){const e=t.toTimestamp();return[e.seconds,e.nanoseconds]}function $a(t){const e=new Qr(t[0],t[1]);return Jr.fromTimestamp(e)}function Ya(t){const e=t.toTimestamp();return new ha(e.seconds,e.nanoseconds)}function Qa(t){const e=new Qr(t.seconds,t.nanoseconds);return Jr.fromTimestamp(e)}function Ja(t,e){const n=(e.baseMutations||[]).map((e=>Wo(t.Gt,e)));for(let t=0;t<e.mutations.length-1;++t){const n=e.mutations[t];if(t+1<e.mutations.length&&void 0!==e.mutations[t+1].transform){const r=e.mutations[t+1];n.updateTransforms=r.transform.fieldTransforms,e.mutations.splice(t+1,1),++t}}const r=e.mutations.map((e=>Wo(t.Gt,e))),i=Qr.fromMillis(e.localWriteTimeMs);return new qa(e.batchId,i,n,r)}function Za(t){const e=Qa(t.readTime),n=void 0!==t.lastLimboFreeSnapshotVersion?Qa(t.lastLimboFreeSnapshotVersion):Jr.min();let r;var i;return void 0!==t.query.documents?(xr(1===(i=t.query).documents.length),r=ls(is(Vo(i.documents[0])))):r=function(t){return ls($o(t))}(t.query),new za(r,t.targetId,0,t.lastListenSequenceNumber,e,n,ai.fromBase64String(t.resumeToken))}function Xa(t,e){const n=Ya(e.snapshotVersion),r=Ya(e.lastLimboFreeSnapshotVersion);let i;i=ji(e.target)?Go(t.Gt,e.target):Ho(t.Gt,e.target);const s=e.resumeToken.toBase64();return new ba(e.targetId,Ui(e.target),n,s,e.sequenceNumber,r,i)}function tc(t){const e=$o({parent:t.parent,structuredQuery:t.structuredQuery});return"LAST"===t.limitType?ds(e,e.limit,"L"):e}class ec{getBundleMetadata(t,e){return nc(t).get(e).next((t=>{if(t)return{id:(e=t).bundleId,createTime:Qa(e.createTime),version:e.version};var e}))}saveBundleMetadata(t,e){return nc(t).put({bundleId:(n=e).id,createTime:Ya(Ro(n.createTime)),version:n.version});var n}getNamedQuery(t,e){return rc(t).get(e).next((t=>{if(t)return{name:(e=t).name,query:tc(e.bundledQuery),readTime:Qa(e.readTime)};var e}))}saveNamedQuery(t,e){return rc(t).put(function(t){return{name:t.name,readTime:Ya(Ro(t.readTime)),bundledQuery:t.bundledQuery}}(e))}}function nc(t){return ja(t,Ea.store)}function rc(t){return ja(t,Sa.store)}class ic{constructor(){this.zt=new sc}addToCollectionParentIndex(t,e){return this.zt.add(e),xa.resolve()}getCollectionParents(t,e){return xa.resolve(this.zt.getEntries(e))}}class sc{constructor(){this.index={}}add(t){const e=t.lastSegment(),n=t.popLast(),r=this.index[e]||new so(ni.comparator),i=!r.has(n);return this.index[e]=r.add(n),i}has(t){const e=t.lastSegment(),n=t.popLast(),r=this.index[e];return r&&r.has(n)}getEntries(t){return(this.index[t]||new so(ni.comparator)).toArray()}}class oc{constructor(){this.Ht=new sc}addToCollectionParentIndex(t,e){if(!this.Ht.has(e)){const n=e.lastSegment(),r=e.popLast();t.addOnCommittedListener((()=>{this.Ht.add(e)}));const i={collectionId:n,parent:oa(r)};return ac(t).put(i)}return xa.resolve()}getCollectionParents(t,e){const n=[],r=IDBKeyRange.bound([e,""],[Yr(e),""],!1,!0);return ac(t).Bt(r).next((t=>{for(const r of t){if(r.collectionId!==e)break;n.push(ua(r.parent))}return n}))}}function ac(t){return ja(t,Ta.store)}const cc={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0};class uc{constructor(t,e,n){this.cacheSizeCollectionThreshold=t,this.percentileToCollect=e,this.maximumSequenceNumbersToCollect=n}static withCacheSize(t){return new uc(t,uc.DEFAULT_COLLECTION_PERCENTILE,uc.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}}function hc(t,e,n){const r=t.store(fa.store),i=t.store(pa.store),s=[],o=IDBKeyRange.only(n.batchId);let a=0;const c=r.jt({range:o},((t,e,n)=>(a++,n.delete())));s.push(c.next((()=>{xr(1===a)})));const u=[];for(const t of n.mutations){const r=pa.key(e,t.key.path,n.batchId);s.push(i.delete(r)),u.push(t.key)}return xa.waitFor(s).next((()=>u))}function lc(t){if(!t)return 0;let e;if(t.document)e=t.document;else if(t.unknownDocument)e=t.unknownDocument;else{if(!t.noDocument)throw Nr();e=t.noDocument}return JSON.stringify(e).length}uc.DEFAULT_COLLECTION_PERCENTILE=10,uc.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,uc.DEFAULT=new uc(41943040,uc.DEFAULT_COLLECTION_PERCENTILE,uc.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),uc.DISABLED=new uc(-1,0,0);class dc{constructor(t,e,n,r){this.userId=t,this.k=e,this.Jt=n,this.referenceDelegate=r,this.Yt={}}static Xt(t,e,n,r){xr(""!==t.uid);const i=t.isAuthenticated()?t.uid:"";return new dc(i,e,n,r)}checkEmpty(t){let e=!0;const n=IDBKeyRange.bound([this.userId,Number.NEGATIVE_INFINITY],[this.userId,Number.POSITIVE_INFINITY]);return pc(t).jt({index:fa.userMutationsIndex,range:n},((t,n,r)=>{e=!1,r.done()})).next((()=>e))}addMutationBatch(t,e,n,r){const i=mc(t),s=pc(t);return s.add({}).next((o=>{xr("number"==typeof o);const a=new qa(o,e,n,r),c=function(t,e,n){const r=n.baseMutations.map((e=>Ko(t.Gt,e))),i=n.mutations.map((e=>Ko(t.Gt,e)));return new fa(e,n.batchId,n.localWriteTime.toMillis(),r,i)}(this.k,this.userId,a),u=[];let h=new so(((t,e)=>Hr(t.canonicalString(),e.canonicalString())));for(const t of r){const e=pa.key(this.userId,t.key.path,o);h=h.add(t.key.path.popLast()),u.push(s.put(c)),u.push(i.put(e,pa.PLACEHOLDER))}return h.forEach((e=>{u.push(this.Jt.addToCollectionParentIndex(t,e))})),t.addOnCommittedListener((()=>{this.Yt[o]=a.keys()})),xa.waitFor(u).next((()=>a))}))}lookupMutationBatch(t,e){return pc(t).get(e).next((t=>t?(xr(t.userId===this.userId),Ja(this.k,t)):null))}Zt(t,e){return this.Yt[e]?xa.resolve(this.Yt[e]):this.lookupMutationBatch(t,e).next((t=>{if(t){const n=t.keys();return this.Yt[e]=n,n}return null}))}getNextMutationBatchAfterBatchId(t,e){const n=e+1,r=IDBKeyRange.lowerBound([this.userId,n]);let i=null;return pc(t).jt({index:fa.userMutationsIndex,range:r},((t,e,r)=>{e.userId===this.userId&&(xr(e.batchId>=n),i=Ja(this.k,e)),r.done()})).next((()=>i))}getHighestUnacknowledgedBatchId(t){const e=IDBKeyRange.upperBound([this.userId,Number.POSITIVE_INFINITY]);let n=-1;return pc(t).jt({index:fa.userMutationsIndex,range:e,reverse:!0},((t,e,r)=>{n=e.batchId,r.done()})).next((()=>n))}getAllMutationBatches(t){const e=IDBKeyRange.bound([this.userId,-1],[this.userId,Number.POSITIVE_INFINITY]);return pc(t).Bt(fa.userMutationsIndex,e).next((t=>t.map((t=>Ja(this.k,t)))))}getAllMutationBatchesAffectingDocumentKey(t,e){const n=pa.prefixForPath(this.userId,e.path),r=IDBKeyRange.lowerBound(n),i=[];return mc(t).jt({range:r},((n,r,s)=>{const[o,a,c]=n,u=ua(a);if(o===this.userId&&e.path.isEqual(u))return pc(t).get(c).next((t=>{if(!t)throw Nr();xr(t.userId===this.userId),i.push(Ja(this.k,t))}));s.done()})).next((()=>i))}getAllMutationBatchesAffectingDocumentKeys(t,e){let n=new so(Hr);const r=[];return e.forEach((e=>{const i=pa.prefixForPath(this.userId,e.path),s=IDBKeyRange.lowerBound(i),o=mc(t).jt({range:s},((t,r,i)=>{const[s,o,a]=t,c=ua(o);s===this.userId&&e.path.isEqual(c)?n=n.add(a):i.done()}));r.push(o)})),xa.waitFor(r).next((()=>this.te(t,n)))}getAllMutationBatchesAffectingQuery(t,e){const n=e.path,r=n.length+1,i=pa.prefixForPath(this.userId,n),s=IDBKeyRange.lowerBound(i);let o=new so(Hr);return mc(t).jt({range:s},((t,e,i)=>{const[s,a,c]=t,u=ua(a);s===this.userId&&n.isPrefixOf(u)?u.length===r&&(o=o.add(c)):i.done()})).next((()=>this.te(t,o)))}te(t,e){const n=[],r=[];return e.forEach((e=>{r.push(pc(t).get(e).next((t=>{if(null===t)throw Nr();xr(t.userId===this.userId),n.push(Ja(this.k,t))})))})),xa.waitFor(r).next((()=>n))}removeMutationBatch(t,e){return hc(t.Wt,this.userId,e).next((n=>(t.addOnCommittedListener((()=>{this.ee(e.batchId)})),xa.forEach(n,(e=>this.referenceDelegate.markPotentiallyOrphaned(t,e))))))}ee(t){delete this.Yt[t]}performConsistencyCheck(t){return this.checkEmpty(t).next((e=>{if(!e)return xa.resolve();const n=IDBKeyRange.lowerBound(pa.prefixForUser(this.userId)),r=[];return mc(t).jt({range:n},((t,e,n)=>{if(t[0]===this.userId){const e=ua(t[1]);r.push(e)}else n.done()})).next((()=>{xr(0===r.length)}))}))}containsKey(t,e){return fc(t,this.userId,e)}ne(t){return gc(t).get(this.userId).next((t=>t||new da(this.userId,-1,"")))}}function fc(t,e,n){const r=pa.prefixForPath(e,n.path),i=r[1],s=IDBKeyRange.lowerBound(r);let o=!1;return mc(t).jt({range:s,Kt:!0},((t,n,r)=>{const[s,a,c]=t;s===e&&a===i&&(o=!0),r.done()})).next((()=>o))}function pc(t){return ja(t,fa.store)}function mc(t){return ja(t,pa.store)}function gc(t){return ja(t,da.store)}class yc{constructor(t){this.se=t}next(){return this.se+=2,this.se}static ie(){return new yc(0)}static re(){return new yc(-1)}}class vc{constructor(t,e){this.referenceDelegate=t,this.k=e}allocateTargetId(t){return this.oe(t).next((e=>{const n=new yc(e.highestTargetId);return e.highestTargetId=n.next(),this.ae(t,e).next((()=>e.highestTargetId))}))}getLastRemoteSnapshotVersion(t){return this.oe(t).next((t=>Jr.fromTimestamp(new Qr(t.lastRemoteSnapshotVersion.seconds,t.lastRemoteSnapshotVersion.nanoseconds))))}getHighestSequenceNumber(t){return this.oe(t).next((t=>t.highestListenSequenceNumber))}setTargetsMetadata(t,e,n){return this.oe(t).next((r=>(r.highestListenSequenceNumber=e,n&&(r.lastRemoteSnapshotVersion=n.toTimestamp()),e>r.highestListenSequenceNumber&&(r.highestListenSequenceNumber=e),this.ae(t,r))))}addTargetData(t,e){return this.ce(t,e).next((()=>this.oe(t).next((n=>(n.targetCount+=1,this.ue(e,n),this.ae(t,n))))))}updateTargetData(t,e){return this.ce(t,e)}removeTargetData(t,e){return this.removeMatchingKeysForTargetId(t,e.targetId).next((()=>bc(t).delete(e.targetId))).next((()=>this.oe(t))).next((e=>(xr(e.targetCount>0),e.targetCount-=1,this.ae(t,e))))}removeTargets(t,e,n){let r=0;const i=[];return bc(t).jt(((s,o)=>{const a=Za(o);a.sequenceNumber<=e&&null===n.get(a.targetId)&&(r++,i.push(this.removeTargetData(t,a)))})).next((()=>xa.waitFor(i))).next((()=>r))}forEachTarget(t,e){return bc(t).jt(((t,n)=>{const r=Za(n);e(r)}))}oe(t){return wc(t).get(Ia.key).next((t=>(xr(null!==t),t)))}ae(t,e){return wc(t).put(Ia.key,e)}ce(t,e){return bc(t).put(Xa(this.k,e))}ue(t,e){let n=!1;return t.targetId>e.highestTargetId&&(e.highestTargetId=t.targetId,n=!0),t.sequenceNumber>e.highestListenSequenceNumber&&(e.highestListenSequenceNumber=t.sequenceNumber,n=!0),n}getTargetCount(t){return this.oe(t).next((t=>t.targetCount))}getTargetData(t,e){const n=Ui(e),r=IDBKeyRange.bound([n,Number.NEGATIVE_INFINITY],[n,Number.POSITIVE_INFINITY]);let i=null;return bc(t).jt({range:r,index:ba.queryTargetsIndexName},((t,n,r)=>{const s=Za(n);Vi(e,s.target)&&(i=s,r.done())})).next((()=>i))}addMatchingKeys(t,e,n){const r=[],i=Ic(t);return e.forEach((e=>{const s=oa(e.path);r.push(i.put(new wa(n,s))),r.push(this.referenceDelegate.addReference(t,n,e))})),xa.waitFor(r)}removeMatchingKeys(t,e,n){const r=Ic(t);return xa.forEach(e,(e=>{const i=oa(e.path);return xa.waitFor([r.delete([n,i]),this.referenceDelegate.removeReference(t,n,e)])}))}removeMatchingKeysForTargetId(t,e){const n=Ic(t),r=IDBKeyRange.bound([e],[e+1],!1,!0);return n.delete(r)}getMatchingKeysForTargetId(t,e){const n=IDBKeyRange.bound([e],[e+1],!1,!0),r=Ic(t);let i=mo();return r.jt({range:n,Kt:!0},((t,e,n)=>{const r=ua(t[1]),s=new vi(r);i=i.add(s)})).next((()=>i))}containsKey(t,e){const n=oa(e.path),r=IDBKeyRange.bound([n],[Yr(n)],!1,!0);let i=0;return Ic(t).jt({index:wa.documentTargetsIndex,Kt:!0,range:r},(([t,e],n,r)=>{0!==t&&(i++,r.done())})).next((()=>i>0))}Et(t,e){return bc(t).get(e).next((t=>t?Za(t):null))}}function bc(t){return ja(t,ba.store)}function wc(t){return ja(t,Ia.store)}function Ic(t){return ja(t,wa.store)}async function Tc(t){if(t.code!==Or.FAILED_PRECONDITION||t.message!==Aa)throw t;Er("LocalStore","Unexpectedly lost primary lease")}function _c([t,e],[n,r]){const i=Hr(t,n);return 0===i?Hr(e,r):i}class Ec{constructor(t){this.he=t,this.buffer=new so(_c),this.le=0}fe(){return++this.le}de(t){const e=[t,this.fe()];if(this.buffer.size<this.he)this.buffer=this.buffer.add(e);else{const t=this.buffer.last();_c(e,t)<0&&(this.buffer=this.buffer.delete(t).add(e))}}get maxValue(){return this.buffer.last()[0]}}class Sc{constructor(t,e){this.garbageCollector=t,this.asyncQueue=e,this.we=!1,this._e=null}start(t){-1!==this.garbageCollector.params.cacheSizeCollectionThreshold&&this.me(t)}stop(){this._e&&(this._e.cancel(),this._e=null)}get started(){return null!==this._e}me(t){const e=this.we?3e5:6e4;Er("LruGarbageCollector",`Garbage collection scheduled in ${e}ms`),this._e=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",e,(async()=>{this._e=null,this.we=!0;try{await t.collectGarbage(this.garbageCollector)}catch(t){Pa(t)?Er("LruGarbageCollector","Ignoring IndexedDB error during garbage collection: ",t):await Tc(t)}await this.me(t)}))}}class kc{constructor(t,e){this.ge=t,this.params=e}calculateTargetCount(t,e){return this.ge.ye(t).next((t=>Math.floor(e/100*t)))}nthSequenceNumber(t,e){if(0===e)return xa.resolve(Kr.I);const n=new Ec(e);return this.ge.forEachTarget(t,(t=>n.de(t.sequenceNumber))).next((()=>this.ge.pe(t,(t=>n.de(t))))).next((()=>n.maxValue))}removeTargets(t,e,n){return this.ge.removeTargets(t,e,n)}removeOrphanedDocuments(t,e){return this.ge.removeOrphanedDocuments(t,e)}collect(t,e){return-1===this.params.cacheSizeCollectionThreshold?(Er("LruGarbageCollector","Garbage collection skipped; disabled"),xa.resolve(cc)):this.getCacheSize(t).next((n=>n<this.params.cacheSizeCollectionThreshold?(Er("LruGarbageCollector",`Garbage collection skipped; Cache size ${n} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),cc):this.Te(t,e)))}getCacheSize(t){return this.ge.getCacheSize(t)}Te(t,e){let n,r,i,s,a,c,u;const h=Date.now();return this.calculateTargetCount(t,this.params.percentileToCollect).next((e=>(e>this.params.maximumSequenceNumbersToCollect?(Er("LruGarbageCollector",`Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${e}`),r=this.params.maximumSequenceNumbersToCollect):r=e,s=Date.now(),this.nthSequenceNumber(t,r)))).next((r=>(n=r,a=Date.now(),this.removeTargets(t,n,e)))).next((e=>(i=e,c=Date.now(),this.removeOrphanedDocuments(t,n)))).next((t=>(u=Date.now(),Tr()<=o.in.DEBUG&&Er("LruGarbageCollector",`LRU Garbage Collection\n\tCounted targets in ${s-h}ms\n\tDetermined least recently used ${r} in `+(a-s)+"ms\n"+`\tRemoved ${i} targets in `+(c-a)+"ms\n"+`\tRemoved ${t} documents in `+(u-c)+"ms\n"+`Total Duration: ${u-h}ms`),xa.resolve({didRun:!0,sequenceNumbersCollected:r,targetsRemoved:i,documentsRemoved:t}))))}}class Ac{constructor(t,e){this.db=t,this.garbageCollector=function(t,e){return new kc(t,e)}(this,e)}ye(t){const e=this.Ee(t);return this.db.getTargetCache().getTargetCount(t).next((t=>e.next((e=>t+e))))}Ee(t){let e=0;return this.pe(t,(t=>{e++})).next((()=>e))}forEachTarget(t,e){return this.db.getTargetCache().forEachTarget(t,e)}pe(t,e){return this.Ie(t,((t,n)=>e(n)))}addReference(t,e,n){return Nc(t,n)}removeReference(t,e,n){return Nc(t,n)}removeTargets(t,e,n){return this.db.getTargetCache().removeTargets(t,e,n)}markPotentiallyOrphaned(t,e){return Nc(t,e)}Ae(t,e){return function(t,e){let n=!1;return gc(t).Qt((r=>fc(t,r,e).next((t=>(t&&(n=!0),xa.resolve(!t)))))).next((()=>n))}(t,e)}removeOrphanedDocuments(t,e){const n=this.db.getRemoteDocumentCache().newChangeBuffer(),r=[];let i=0;return this.Ie(t,((s,o)=>{if(o<=e){const e=this.Ae(t,s).next((e=>{if(!e)return i++,n.getEntry(t,s).next((()=>(n.removeEntry(s),Ic(t).delete([0,oa(s.path)]))))}));r.push(e)}})).next((()=>xa.waitFor(r))).next((()=>n.apply(t))).next((()=>i))}removeTarget(t,e){const n=e.withSequenceNumber(t.currentSequenceNumber);return this.db.getTargetCache().updateTargetData(t,n)}updateLimboDocument(t,e){return Nc(t,e)}Ie(t,e){const n=Ic(t);let r,i=Kr.I;return n.jt({index:wa.documentTargetsIndex},(([t,n],{path:s,sequenceNumber:o})=>{0===t?(i!==Kr.I&&e(new vi(ua(r)),i),i=o,r=s):i=Kr.I})).next((()=>{i!==Kr.I&&e(new vi(ua(r)),i)}))}getCacheSize(t){return this.db.getRemoteDocumentCache().getSize(t)}}function Nc(t,e){return Ic(t).put(function(t,e){return new wa(0,oa(t.path),e)}(e,t.currentSequenceNumber))}class xc{constructor(t,e){this.mapKeyFn=t,this.equalsFn=e,this.inner={}}get(t){const e=this.mapKeyFn(t),n=this.inner[e];if(void 0!==n)for(const[e,r]of n)if(this.equalsFn(e,t))return r}has(t){return void 0!==this.get(t)}set(t,e){const n=this.mapKeyFn(t),r=this.inner[n];if(void 0!==r){for(let n=0;n<r.length;n++)if(this.equalsFn(r[n][0],t))return void(r[n]=[t,e]);r.push([t,e])}else this.inner[n]=[[t,e]]}delete(t){const e=this.mapKeyFn(t),n=this.inner[e];if(void 0===n)return!1;for(let r=0;r<n.length;r++)if(this.equalsFn(n[r][0],t))return 1===n.length?delete this.inner[e]:n.splice(r,1),!0;return!1}forEach(t){Xr(this.inner,((e,n)=>{for(const[e,r]of n)t(e,r)}))}isEmpty(){return ti(this.inner)}}class Cc{constructor(){this.changes=new xc((t=>t.toString()),((t,e)=>t.isEqual(e))),this.changesApplied=!1}getReadTime(t){const e=this.changes.get(t);return e?e.readTime:Jr.min()}addEntry(t,e){this.assertNotApplied(),this.changes.set(t.key,{document:t,readTime:e})}removeEntry(t,e=null){this.assertNotApplied(),this.changes.set(t,{document:Li.newInvalidDocument(t),readTime:e})}getEntry(t,e){this.assertNotApplied();const n=this.changes.get(e);return void 0!==n?xa.resolve(n.document):this.getFromCache(t,e)}getEntries(t,e){return this.getAllFromCache(t,e)}apply(t){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(t)}assertNotApplied(){}}class Dc{constructor(t,e){this.k=t,this.Jt=e}addEntry(t,e,n){return Pc(t).put(Lc(e),n)}removeEntry(t,e){const n=Pc(t),r=Lc(e);return n.delete(r)}updateMetadata(t,e){return this.getMetadata(t).next((n=>(n.byteSize+=e,this.Re(t,n))))}getEntry(t,e){return Pc(t).get(Lc(e)).next((t=>this.be(e,t)))}Pe(t,e){return Pc(t).get(Lc(e)).next((t=>({document:this.be(e,t),size:lc(t)})))}getEntries(t,e){let n=co();return this.ve(t,e,((t,e)=>{const r=this.be(t,e);n=n.insert(t,r)})).next((()=>n))}Ve(t,e){let n=co(),r=new no(vi.comparator);return this.ve(t,e,((t,e)=>{const i=this.be(t,e);n=n.insert(t,i),r=r.insert(t,lc(e))})).next((()=>({documents:n,Se:r})))}ve(t,e,n){if(e.isEmpty())return xa.resolve();const r=IDBKeyRange.bound(e.first().path.toArray(),e.last().path.toArray()),i=e.getIterator();let s=i.getNext();return Pc(t).jt({range:r},((t,e,r)=>{const o=vi.fromSegments(t);for(;s&&vi.comparator(s,o)<0;)n(s,null),s=i.getNext();s&&s.isEqual(o)&&(n(s,e),s=i.hasNext()?i.getNext():null),s?r.Lt(s.path.toArray()):r.done()})).next((()=>{for(;s;)n(s,null),s=i.hasNext()?i.getNext():null}))}getDocumentsMatchingQuery(t,e,n){let r=co();const i=e.path.length+1,s={};if(n.isEqual(Jr.min())){const t=e.path.toArray();s.range=IDBKeyRange.lowerBound(t)}else{const t=e.path.toArray(),r=Ha(n);s.range=IDBKeyRange.lowerBound([t,r],!0),s.index=ya.collectionReadTimeIndex}return Pc(t).jt(s,((t,n,s)=>{if(t.length!==i)return;const o=Wa(this.k,n);e.path.isPrefixOf(o.key.path)?gs(e,o)&&(r=r.insert(o.key,o)):s.done()})).next((()=>r))}newChangeBuffer(t){return new Oc(this,!!t&&t.trackRemovals)}getSize(t){return this.getMetadata(t).next((t=>t.byteSize))}getMetadata(t){return Rc(t).get(va.key).next((t=>(xr(!!t),t)))}Re(t,e){return Rc(t).put(va.key,e)}be(t,e){if(e){const t=Wa(this.k,e);if(!t.isNoDocument()||!t.version.isEqual(Jr.min()))return t}return Li.newInvalidDocument(t)}}class Oc extends Cc{constructor(t,e){super(),this.De=t,this.trackRemovals=e,this.Ce=new xc((t=>t.toString()),((t,e)=>t.isEqual(e)))}applyChanges(t){const e=[];let n=0,r=new so(((t,e)=>Hr(t.canonicalString(),e.canonicalString())));return this.changes.forEach(((i,s)=>{const o=this.Ce.get(i);if(s.document.isValidDocument()){const a=Ga(this.De.k,s.document,this.getReadTime(i));r=r.add(i.path.popLast());const c=lc(a);n+=c-o,e.push(this.De.addEntry(t,i,a))}else if(n-=o,this.trackRemovals){const n=Ga(this.De.k,Li.newNoDocument(i,Jr.min()),this.getReadTime(i));e.push(this.De.addEntry(t,i,n))}else e.push(this.De.removeEntry(t,i))})),r.forEach((n=>{e.push(this.De.Jt.addToCollectionParentIndex(t,n))})),e.push(this.De.updateMetadata(t,n)),xa.waitFor(e)}getFromCache(t,e){return this.De.Pe(t,e).next((t=>(this.Ce.set(e,t.size),t.document)))}getAllFromCache(t,e){return this.De.Ve(t,e).next((({documents:t,Se:e})=>(e.forEach(((t,e)=>{this.Ce.set(t,e)})),t)))}}function Rc(t){return ja(t,va.store)}function Pc(t){return ja(t,ya.store)}function Lc(t){return t.path.toArray()}class Mc{constructor(t){this.k=t}Nt(t,e,n,r){xr(n<r&&n>=0&&r<=11);const i=new Ca("createOrUpgrade",e);n<1&&r>=1&&(function(t){t.createObjectStore(la.store)}(t),function(t){t.createObjectStore(da.store,{keyPath:da.keyPath}),t.createObjectStore(fa.store,{keyPath:fa.keyPath,autoIncrement:!0}).createIndex(fa.userMutationsIndex,fa.userMutationsKeyPath,{unique:!0}),t.createObjectStore(pa.store)}(t),Fc(t),function(t){t.createObjectStore(ya.store)}(t));let s=xa.resolve();return n<3&&r>=3&&(0!==n&&(function(t){t.deleteObjectStore(wa.store),t.deleteObjectStore(ba.store),t.deleteObjectStore(Ia.store)}(t),Fc(t)),s=s.next((()=>function(t){const e=t.store(Ia.store),n=new Ia(0,0,Jr.min().toTimestamp(),0);return e.put(Ia.key,n)}(i)))),n<4&&r>=4&&(0!==n&&(s=s.next((()=>function(t,e){return e.store(fa.store).Bt().next((n=>{t.deleteObjectStore(fa.store),t.createObjectStore(fa.store,{keyPath:fa.keyPath,autoIncrement:!0}).createIndex(fa.userMutationsIndex,fa.userMutationsKeyPath,{unique:!0});const r=e.store(fa.store),i=n.map((t=>r.put(t)));return xa.waitFor(i)}))}(t,i)))),s=s.next((()=>{!function(t){t.createObjectStore(_a.store,{keyPath:_a.keyPath})}(t)}))),n<5&&r>=5&&(s=s.next((()=>this.Ne(i)))),n<6&&r>=6&&(s=s.next((()=>(function(t){t.createObjectStore(va.store)}(t),this.ke(i))))),n<7&&r>=7&&(s=s.next((()=>this.xe(i)))),n<8&&r>=8&&(s=s.next((()=>this.$e(t,i)))),n<9&&r>=9&&(s=s.next((()=>{!function(t){t.objectStoreNames.contains("remoteDocumentChanges")&&t.deleteObjectStore("remoteDocumentChanges")}(t),function(t){const e=t.objectStore(ya.store);e.createIndex(ya.readTimeIndex,ya.readTimeIndexPath,{unique:!1}),e.createIndex(ya.collectionReadTimeIndex,ya.collectionReadTimeIndexPath,{unique:!1})}(e)}))),n<10&&r>=10&&(s=s.next((()=>this.Oe(i)))),n<11&&r>=11&&(s=s.next((()=>{!function(t){t.createObjectStore(Ea.store,{keyPath:Ea.keyPath})}(t),function(t){t.createObjectStore(Sa.store,{keyPath:Sa.keyPath})}(t)}))),s}ke(t){let e=0;return t.store(ya.store).jt(((t,n)=>{e+=lc(n)})).next((()=>{const n=new va(e);return t.store(va.store).put(va.key,n)}))}Ne(t){const e=t.store(da.store),n=t.store(fa.store);return e.Bt().next((e=>xa.forEach(e,(e=>{const r=IDBKeyRange.bound([e.userId,-1],[e.userId,e.lastAcknowledgedBatchId]);return n.Bt(fa.userMutationsIndex,r).next((n=>xa.forEach(n,(n=>{xr(n.userId===e.userId);const r=Ja(this.k,n);return hc(t,e.userId,r).next((()=>{}))}))))}))))}xe(t){const e=t.store(wa.store),n=t.store(ya.store);return t.store(Ia.store).get(Ia.key).next((t=>{const r=[];return n.jt(((n,i)=>{const s=new ni(n),o=function(t){return[0,oa(t)]}(s);r.push(e.get(o).next((n=>n?xa.resolve():(n=>e.put(new wa(0,oa(n),t.highestListenSequenceNumber)))(s))))})).next((()=>xa.waitFor(r)))}))}$e(t,e){t.createObjectStore(Ta.store,{keyPath:Ta.keyPath});const n=e.store(Ta.store),r=new sc,i=t=>{if(r.add(t)){const e=t.lastSegment(),r=t.popLast();return n.put({collectionId:e,parent:oa(r)})}};return e.store(ya.store).jt({Kt:!0},((t,e)=>{const n=new ni(t);return i(n.popLast())})).next((()=>e.store(pa.store).jt({Kt:!0},(([t,e,n],r)=>{const s=ua(e);return i(s.popLast())}))))}Oe(t){const e=t.store(ba.store);return e.jt(((t,n)=>{const r=Za(n),i=Xa(this.k,r);return e.put(i)}))}}function Fc(t){t.createObjectStore(wa.store,{keyPath:wa.keyPath}).createIndex(wa.documentTargetsIndex,wa.documentTargetsKeyPath,{unique:!0}),t.createObjectStore(ba.store,{keyPath:ba.keyPath}).createIndex(ba.queryTargetsIndexName,ba.queryTargetsKeyPath,{unique:!0}),t.createObjectStore(Ia.store)}const Uc="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.";class Vc{constructor(t,e,n,r,i,s,o,a,c,u){if(this.allowTabSynchronization=t,this.persistenceKey=e,this.clientId=n,this.Fe=i,this.window=s,this.document=o,this.Me=c,this.Le=u,this.Be=null,this.Ue=!1,this.isPrimary=!1,this.networkEnabled=!0,this.qe=null,this.inForeground=!1,this.Ke=null,this.je=null,this.Qe=Number.NEGATIVE_INFINITY,this.We=t=>Promise.resolve(),!Vc.Pt())throw new Rr(Or.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");this.referenceDelegate=new Ac(this,r),this.Ge=e+"main",this.k=new Ka(a),this.ze=new Da(this.Ge,11,new Mc(this.k)),this.He=new vc(this.referenceDelegate,this.k),this.Jt=new oc,this.Je=function(t,e){return new Dc(t,e)}(this.k,this.Jt),this.Ye=new ec,this.window&&this.window.localStorage?this.Xe=this.window.localStorage:(this.Xe=null,!1===u&&Sr("IndexedDbPersistence","LocalStorage is unavailable. As a result, persistence may not work reliably. In particular enablePersistence() could fail immediately after refreshing the page."))}start(){return this.Ze().then((()=>{if(!this.isPrimary&&!this.allowTabSynchronization)throw new Rr(Or.FAILED_PRECONDITION,Uc);return this.tn(),this.en(),this.nn(),this.runTransaction("getHighestListenSequenceNumber","readonly",(t=>this.He.getHighestSequenceNumber(t)))})).then((t=>{this.Be=new Kr(t,this.Me)})).then((()=>{this.Ue=!0})).catch((t=>(this.ze&&this.ze.close(),Promise.reject(t))))}sn(t){return this.We=async e=>{if(this.started)return t(e)},t(this.isPrimary)}setDatabaseDeletedListener(t){this.ze.xt((async e=>{null===e.newVersion&&await t()}))}setNetworkEnabled(t){this.networkEnabled!==t&&(this.networkEnabled=t,this.Fe.enqueueAndForget((async()=>{this.started&&await this.Ze()})))}Ze(){return this.runTransaction("updateClientMetadataAndTryBecomePrimary","readwrite",(t=>qc(t).put(new _a(this.clientId,Date.now(),this.networkEnabled,this.inForeground)).next((()=>{if(this.isPrimary)return this.rn(t).next((t=>{t||(this.isPrimary=!1,this.Fe.enqueueRetryable((()=>this.We(!1))))}))})).next((()=>this.on(t))).next((e=>this.isPrimary&&!e?this.an(t).next((()=>!1)):!!e&&this.cn(t).next((()=>!0)))))).catch((t=>{if(Pa(t))return Er("IndexedDbPersistence","Failed to extend owner lease: ",t),this.isPrimary;if(!this.allowTabSynchronization)throw t;return Er("IndexedDbPersistence","Releasing owner lease after error during lease refresh",t),!1})).then((t=>{this.isPrimary!==t&&this.Fe.enqueueRetryable((()=>this.We(t))),this.isPrimary=t}))}rn(t){return jc(t).get(la.key).next((t=>xa.resolve(this.un(t))))}hn(t){return qc(t).delete(this.clientId)}async ln(){if(this.isPrimary&&!this.fn(this.Qe,18e5)){this.Qe=Date.now();const t=await this.runTransaction("maybeGarbageCollectMultiClientState","readwrite-primary",(t=>{const e=ja(t,_a.store);return e.Bt().next((t=>{const n=this.dn(t,18e5),r=t.filter((t=>-1===n.indexOf(t)));return xa.forEach(r,(t=>e.delete(t.clientId))).next((()=>r))}))})).catch((()=>[]));if(this.Xe)for(const e of t)this.Xe.removeItem(this.wn(e.clientId))}}nn(){this.je=this.Fe.enqueueAfterDelay("client_metadata_refresh",4e3,(()=>this.Ze().then((()=>this.ln())).then((()=>this.nn()))))}un(t){return!!t&&t.ownerId===this.clientId}on(t){return this.Le?xa.resolve(!0):jc(t).get(la.key).next((e=>{if(null!==e&&this.fn(e.leaseTimestampMs,5e3)&&!this._n(e.ownerId)){if(this.un(e)&&this.networkEnabled)return!0;if(!this.un(e)){if(!e.allowTabSynchronization)throw new Rr(Or.FAILED_PRECONDITION,Uc);return!1}}return!(!this.networkEnabled||!this.inForeground)||qc(t).Bt().next((t=>void 0===this.dn(t,5e3).find((t=>{if(this.clientId!==t.clientId){const e=!this.networkEnabled&&t.networkEnabled,n=!this.inForeground&&t.inForeground,r=this.networkEnabled===t.networkEnabled;if(e||n&&r)return!0}return!1}))))})).next((t=>(this.isPrimary!==t&&Er("IndexedDbPersistence",`Client ${t?"is":"is not"} eligible for a primary lease.`),t)))}async shutdown(){this.Ue=!1,this.mn(),this.je&&(this.je.cancel(),this.je=null),this.gn(),this.yn(),await this.ze.runTransaction("shutdown","readwrite",[la.store,_a.store],(t=>{const e=new Va(t,Kr.I);return this.an(e).next((()=>this.hn(e)))})),this.ze.close(),this.pn()}dn(t,e){return t.filter((t=>this.fn(t.updateTimeMs,e)&&!this._n(t.clientId)))}Tn(){return this.runTransaction("getActiveClients","readonly",(t=>qc(t).Bt().next((t=>this.dn(t,18e5).map((t=>t.clientId))))))}get started(){return this.Ue}getMutationQueue(t){return dc.Xt(t,this.k,this.Jt,this.referenceDelegate)}getTargetCache(){return this.He}getRemoteDocumentCache(){return this.Je}getIndexManager(){return this.Jt}getBundleCache(){return this.Ye}runTransaction(t,e,n){Er("IndexedDbPersistence","Starting transaction:",t);const r="readonly"===e?"readonly":"readwrite";let i;return this.ze.runTransaction(t,r,ka,(r=>(i=new Va(r,this.Be?this.Be.next():Kr.I),"readwrite-primary"===e?this.rn(i).next((t=>!!t||this.on(i))).next((e=>{if(!e)throw Sr(`Failed to obtain primary lease for action '${t}'.`),this.isPrimary=!1,this.Fe.enqueueRetryable((()=>this.We(!1))),new Rr(Or.FAILED_PRECONDITION,Aa);return n(i)})).next((t=>this.cn(i).next((()=>t)))):this.En(i).next((()=>n(i)))))).then((t=>(i.raiseOnCommittedEvent(),t)))}En(t){return jc(t).get(la.key).next((t=>{if(null!==t&&this.fn(t.leaseTimestampMs,5e3)&&!this._n(t.ownerId)&&!this.un(t)&&!(this.Le||this.allowTabSynchronization&&t.allowTabSynchronization))throw new Rr(Or.FAILED_PRECONDITION,Uc)}))}cn(t){const e=new la(this.clientId,this.allowTabSynchronization,Date.now());return jc(t).put(la.key,e)}static Pt(){return Da.Pt()}an(t){const e=jc(t);return e.get(la.key).next((t=>this.un(t)?(Er("IndexedDbPersistence","Releasing primary lease."),e.delete(la.key)):xa.resolve()))}fn(t,e){const n=Date.now();return!(t<n-e||t>n&&(Sr(`Detected an update time that is in the future: ${t} > ${n}`),1))}tn(){null!==this.document&&"function"==typeof this.document.addEventListener&&(this.Ke=()=>{this.Fe.enqueueAndForget((()=>(this.inForeground="visible"===this.document.visibilityState,this.Ze())))},this.document.addEventListener("visibilitychange",this.Ke),this.inForeground="visible"===this.document.visibilityState)}gn(){this.Ke&&(this.document.removeEventListener("visibilitychange",this.Ke),this.Ke=null)}en(){var t;"function"==typeof(null===(t=this.window)||void 0===t?void 0:t.addEventListener)&&(this.qe=()=>{this.mn(),(0,a.G6)()&&navigator.appVersion.match(/Version\/1[45]/)&&this.Fe.enterRestrictedMode(!0),this.Fe.enqueueAndForget((()=>this.shutdown()))},this.window.addEventListener("pagehide",this.qe))}yn(){this.qe&&(this.window.removeEventListener("pagehide",this.qe),this.qe=null)}_n(t){var e;try{const n=null!==(null===(e=this.Xe)||void 0===e?void 0:e.getItem(this.wn(t)));return Er("IndexedDbPersistence",`Client '${t}' ${n?"is":"is not"} zombied in LocalStorage`),n}catch(t){return Sr("IndexedDbPersistence","Failed to get zombied client id.",t),!1}}mn(){if(this.Xe)try{this.Xe.setItem(this.wn(this.clientId),String(Date.now()))}catch(t){Sr("Failed to set zombie client id.",t)}}pn(){if(this.Xe)try{this.Xe.removeItem(this.wn(this.clientId))}catch(t){}}wn(t){return`firestore_zombie_${this.persistenceKey}_${t}`}}function jc(t){return ja(t,la.store)}function qc(t){return ja(t,_a.store)}function Bc(t,e){let n=t.projectId;return t.isDefaultDatabase||(n+="."+t.database),"firestore/"+e+"/"+n+"/"}class zc{constructor(t,e){this.progress=t,this.In=e}}class Kc{constructor(t,e,n){this.Je=t,this.An=e,this.Jt=n}Rn(t,e){return this.An.getAllMutationBatchesAffectingDocumentKey(t,e).next((n=>this.bn(t,e,n)))}bn(t,e,n){return this.Je.getEntry(t,e).next((t=>{for(const e of n)e.applyToLocalView(t);return t}))}Pn(t,e){t.forEach(((t,n)=>{for(const t of e)t.applyToLocalView(n)}))}vn(t,e){return this.Je.getEntries(t,e).next((e=>this.Vn(t,e).next((()=>e))))}Vn(t,e){return this.An.getAllMutationBatchesAffectingDocumentKeys(t,e).next((t=>this.Pn(e,t)))}getDocumentsMatchingQuery(t,e,n){return function(t){return vi.isDocumentKey(t.path)&&null===t.collectionGroup&&0===t.filters.length}(e)?this.Sn(t,e.path):us(e)?this.Dn(t,e,n):this.Cn(t,e,n)}Sn(t,e){return this.Rn(t,new vi(e)).next((t=>{let e=ho();return t.isFoundDocument()&&(e=e.insert(t.key,t)),e}))}Dn(t,e,n){const r=e.collectionGroup;let i=ho();return this.Jt.getCollectionParents(t,r).next((s=>xa.forEach(s,(s=>{const o=function(t,e){return new ns(e,null,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,t.startAt,t.endAt)}(e,s.child(r));return this.Cn(t,o,n).next((t=>{t.forEach(((t,e)=>{i=i.insert(t,e)}))}))})).next((()=>i))))}Cn(t,e,n){let r,i;return this.Je.getDocumentsMatchingQuery(t,e,n).next((n=>(r=n,this.An.getAllMutationBatchesAffectingQuery(t,e)))).next((e=>(i=e,this.Nn(t,i,r).next((t=>{r=t;for(const t of i)for(const e of t.mutations){const n=e.key;let i=r.get(n);null==i&&(i=Li.newInvalidDocument(n),r=r.insert(n,i)),js(e,i,t.localWriteTime),i.isFoundDocument()||(r=r.remove(n))}}))))).next((()=>(r.forEach(((t,n)=>{gs(e,n)||(r=r.remove(t))})),r)))}Nn(t,e,n){let r=mo();for(const t of e)for(const e of t.mutations)e instanceof Ws&&null===n.get(e.key)&&(r=r.add(e.key));let i=n;return this.Je.getEntries(t,r).next((t=>(t.forEach(((t,e)=>{e.isFoundDocument()&&(i=i.insert(t,e))})),i)))}}class Wc{constructor(t,e,n,r){this.targetId=t,this.fromCache=e,this.kn=n,this.xn=r}static $n(t,e){let n=mo(),r=mo();for(const t of e.docChanges)switch(t.type){case 0:n=n.add(t.doc.key);break;case 1:r=r.add(t.doc.key)}return new Wc(t,e.fromCache,n,r)}}class Gc{On(t){this.Fn=t}getDocumentsMatchingQuery(t,e,n,r){return function(t){return 0===t.filters.length&&null===t.limit&&null==t.startAt&&null==t.endAt&&(0===t.explicitOrderBy.length||1===t.explicitOrderBy.length&&t.explicitOrderBy[0].field.isKeyField())}(e)||n.isEqual(Jr.min())?this.Mn(t,e):this.Fn.vn(t,r).next((i=>{const s=this.Ln(e,i);return(ss(e)||os(e))&&this.Bn(e.limitType,s,r,n)?this.Mn(t,e):(Tr()<=o.in.DEBUG&&Er("QueryEngine","Re-using previous result from %s to execute query: %s",n.toString(),ms(e)),this.Fn.getDocumentsMatchingQuery(t,e,n).next((t=>(s.forEach((e=>{t=t.insert(e.key,e)})),t))))}))}Ln(t,e){let n=new so(ys(t));return e.forEach(((e,r)=>{gs(t,r)&&(n=n.add(r))})),n}Bn(t,e,n,r){if(n.size!==e.size)return!0;const i="F"===t?e.last():e.first();return!!i&&(i.hasPendingWrites||i.version.compareTo(r)>0)}Mn(t,e){return Tr()<=o.in.DEBUG&&Er("QueryEngine","Using full collection scan to execute query:",ms(e)),this.Fn.getDocumentsMatchingQuery(t,e,Jr.min())}}class Hc{constructor(t,e,n,r){this.persistence=t,this.Un=e,this.k=r,this.qn=new no(Hr),this.Kn=new xc((t=>Ui(t)),Vi),this.jn=Jr.min(),this.An=t.getMutationQueue(n),this.Qn=t.getRemoteDocumentCache(),this.He=t.getTargetCache(),this.Wn=new Kc(this.Qn,this.An,this.persistence.getIndexManager()),this.Ye=t.getBundleCache(),this.Un.On(this.Wn)}collectGarbage(t){return this.persistence.runTransaction("Collect garbage","readwrite-primary",(e=>t.collect(e,this.qn)))}}function $c(t,e,n,r){return new Hc(t,e,n,r)}async function Yc(t,e){const n=Dr(t);let r=n.An,i=n.Wn;const s=await n.persistence.runTransaction("Handle user change","readonly",(t=>{let s;return n.An.getAllMutationBatches(t).next((o=>(s=o,r=n.persistence.getMutationQueue(e),i=new Kc(n.Qn,r,n.persistence.getIndexManager()),r.getAllMutationBatches(t)))).next((e=>{const n=[],r=[];let o=mo();for(const t of s){n.push(t.batchId);for(const e of t.mutations)o=o.add(e.key)}for(const t of e){r.push(t.batchId);for(const e of t.mutations)o=o.add(e.key)}return i.vn(t,o).next((t=>({Gn:t,removedBatchIds:n,addedBatchIds:r})))}))}));return n.An=r,n.Wn=i,n.Un.On(n.Wn),s}function Qc(t){const e=Dr(t);return e.persistence.runTransaction("Get last remote snapshot version","readonly",(t=>e.He.getLastRemoteSnapshotVersion(t)))}function Jc(t,e,n,r,i){let s=mo();return n.forEach((t=>s=s.add(t))),e.getEntries(t,s).next((t=>{let s=co();return n.forEach(((n,o)=>{const a=t.get(n),c=(null==i?void 0:i.get(n))||r;o.isNoDocument()&&o.version.isEqual(Jr.min())?(e.removeEntry(n,c),s=s.insert(n,o)):!a.isValidDocument()||o.version.compareTo(a.version)>0||0===o.version.compareTo(a.version)&&a.hasPendingWrites?(e.addEntry(o,c),s=s.insert(n,o)):Er("LocalStore","Ignoring outdated watch update for ",n,". Current version:",a.version," Watch version:",o.version)})),s}))}function Zc(t,e){const n=Dr(t);return n.persistence.runTransaction("Get next mutation batch","readonly",(t=>(void 0===e&&(e=-1),n.An.getNextMutationBatchAfterBatchId(t,e))))}function Xc(t,e){const n=Dr(t);return n.persistence.runTransaction("Allocate target","readwrite",(t=>{let r;return n.He.getTargetData(t,e).next((i=>i?(r=i,xa.resolve(r)):n.He.allocateTargetId(t).next((i=>(r=new za(e,i,0,t.currentSequenceNumber),n.He.addTargetData(t,r).next((()=>r)))))))})).then((t=>{const r=n.qn.get(t.targetId);return(null===r||t.snapshotVersion.compareTo(r.snapshotVersion)>0)&&(n.qn=n.qn.insert(t.targetId,t),n.Kn.set(e,t.targetId)),t}))}async function tu(t,e,n){const r=Dr(t),i=r.qn.get(e),s=n?"readwrite":"readwrite-primary";try{n||await r.persistence.runTransaction("Release target",s,(t=>r.persistence.referenceDelegate.removeTarget(t,i)))}catch(t){if(!Pa(t))throw t;Er("LocalStore",`Failed to update sequence numbers for target ${e}: ${t}`)}r.qn=r.qn.remove(e),r.Kn.delete(i.target)}function eu(t,e,n){const r=Dr(t);let i=Jr.min(),s=mo();return r.persistence.runTransaction("Execute query","readonly",(t=>function(t,e,n){const r=Dr(t),i=r.Kn.get(n);return void 0!==i?xa.resolve(r.qn.get(i)):r.He.getTargetData(e,n)}(r,t,ls(e)).next((e=>{if(e)return i=e.lastLimboFreeSnapshotVersion,r.He.getMatchingKeysForTargetId(t,e.targetId).next((t=>{s=t}))})).next((()=>r.Un.getDocumentsMatchingQuery(t,e,n?i:Jr.min(),n?s:mo()))).next((t=>({documents:t,zn:s})))))}function nu(t,e){const n=Dr(t),r=Dr(n.He),i=n.qn.get(e);return i?Promise.resolve(i.target):n.persistence.runTransaction("Get target data","readonly",(t=>r.Et(t,e).next((t=>t?t.target:null))))}function ru(t){const e=Dr(t);return e.persistence.runTransaction("Get new document changes","readonly",(t=>function(t,e,n){const r=Dr(t);let i=co(),s=Ha(n);const o=Pc(e),a=IDBKeyRange.lowerBound(s,!0);return o.jt({index:ya.readTimeIndex,range:a},((t,e)=>{const n=Wa(r.k,e);i=i.insert(n.key,n),s=e.readTime})).next((()=>({In:i,readTime:$a(s)})))}(e.Qn,t,e.jn))).then((({In:t,readTime:n})=>(e.jn=n,t)))}async function iu(t,e,n=mo()){const r=await Xc(t,ls(tc(e.bundledQuery))),i=Dr(t);return i.persistence.runTransaction("Save named query","readwrite",(t=>{const s=Ro(e.readTime);if(r.snapshotVersion.compareTo(s)>=0)return i.Ye.saveNamedQuery(t,e);const o=r.withResumeToken(ai.EMPTY_BYTE_STRING,s);return i.qn=i.qn.insert(o.targetId,o),i.He.updateTargetData(t,o).next((()=>i.He.removeMatchingKeysForTargetId(t,r.targetId))).next((()=>i.He.addMatchingKeys(t,n,r.targetId))).next((()=>i.Ye.saveNamedQuery(t,e)))}))}class su{constructor(t){this.k=t,this.Xn=new Map,this.Zn=new Map}getBundleMetadata(t,e){return xa.resolve(this.Xn.get(e))}saveBundleMetadata(t,e){var n;return this.Xn.set(e.id,{id:(n=e).id,version:n.version,createTime:Ro(n.createTime)}),xa.resolve()}getNamedQuery(t,e){return xa.resolve(this.Zn.get(e))}saveNamedQuery(t,e){return this.Zn.set(e.name,function(t){return{name:t.name,query:tc(t.bundledQuery),readTime:Ro(t.readTime)}}(e)),xa.resolve()}}class ou{constructor(){this.ts=new so(au.es),this.ns=new so(au.ss)}isEmpty(){return this.ts.isEmpty()}addReference(t,e){const n=new au(t,e);this.ts=this.ts.add(n),this.ns=this.ns.add(n)}rs(t,e){t.forEach((t=>this.addReference(t,e)))}removeReference(t,e){this.os(new au(t,e))}cs(t,e){t.forEach((t=>this.removeReference(t,e)))}us(t){const e=new vi(new ni([])),n=new au(e,t),r=new au(e,t+1),i=[];return this.ns.forEachInRange([n,r],(t=>{this.os(t),i.push(t.key)})),i}hs(){this.ts.forEach((t=>this.os(t)))}os(t){this.ts=this.ts.delete(t),this.ns=this.ns.delete(t)}ls(t){const e=new vi(new ni([])),n=new au(e,t),r=new au(e,t+1);let i=mo();return this.ns.forEachInRange([n,r],(t=>{i=i.add(t.key)})),i}containsKey(t){const e=new au(t,0),n=this.ts.firstAfterOrEqual(e);return null!==n&&t.isEqual(n.key)}}class au{constructor(t,e){this.key=t,this.fs=e}static es(t,e){return vi.comparator(t.key,e.key)||Hr(t.fs,e.fs)}static ss(t,e){return Hr(t.fs,e.fs)||vi.comparator(t.key,e.key)}}class cu{constructor(t,e){this.Jt=t,this.referenceDelegate=e,this.An=[],this.ds=1,this.ws=new so(au.es)}checkEmpty(t){return xa.resolve(0===this.An.length)}addMutationBatch(t,e,n,r){const i=this.ds;this.ds++,this.An.length>0&&this.An[this.An.length-1];const s=new qa(i,e,n,r);this.An.push(s);for(const e of r)this.ws=this.ws.add(new au(e.key,i)),this.Jt.addToCollectionParentIndex(t,e.key.path.popLast());return xa.resolve(s)}lookupMutationBatch(t,e){return xa.resolve(this._s(e))}getNextMutationBatchAfterBatchId(t,e){const n=e+1,r=this.gs(n),i=r<0?0:r;return xa.resolve(this.An.length>i?this.An[i]:null)}getHighestUnacknowledgedBatchId(){return xa.resolve(0===this.An.length?-1:this.ds-1)}getAllMutationBatches(t){return xa.resolve(this.An.slice())}getAllMutationBatchesAffectingDocumentKey(t,e){const n=new au(e,0),r=new au(e,Number.POSITIVE_INFINITY),i=[];return this.ws.forEachInRange([n,r],(t=>{const e=this._s(t.fs);i.push(e)})),xa.resolve(i)}getAllMutationBatchesAffectingDocumentKeys(t,e){let n=new so(Hr);return e.forEach((t=>{const e=new au(t,0),r=new au(t,Number.POSITIVE_INFINITY);this.ws.forEachInRange([e,r],(t=>{n=n.add(t.fs)}))})),xa.resolve(this.ys(n))}getAllMutationBatchesAffectingQuery(t,e){const n=e.path,r=n.length+1;let i=n;vi.isDocumentKey(i)||(i=i.child(""));const s=new au(new vi(i),0);let o=new so(Hr);return this.ws.forEachWhile((t=>{const e=t.key.path;return!!n.isPrefixOf(e)&&(e.length===r&&(o=o.add(t.fs)),!0)}),s),xa.resolve(this.ys(o))}ys(t){const e=[];return t.forEach((t=>{const n=this._s(t);null!==n&&e.push(n)})),e}removeMutationBatch(t,e){xr(0===this.ps(e.batchId,"removed")),this.An.shift();let n=this.ws;return xa.forEach(e.mutations,(r=>{const i=new au(r.key,e.batchId);return n=n.delete(i),this.referenceDelegate.markPotentiallyOrphaned(t,r.key)})).next((()=>{this.ws=n}))}ee(t){}containsKey(t,e){const n=new au(e,0),r=this.ws.firstAfterOrEqual(n);return xa.resolve(e.isEqual(r&&r.key))}performConsistencyCheck(t){return this.An.length,xa.resolve()}ps(t,e){return this.gs(t)}gs(t){return 0===this.An.length?0:t-this.An[0].batchId}_s(t){const e=this.gs(t);return e<0||e>=this.An.length?null:this.An[e]}}class uu{constructor(t,e){this.Jt=t,this.Ts=e,this.docs=new no(vi.comparator),this.size=0}addEntry(t,e,n){const r=e.key,i=this.docs.get(r),s=i?i.size:0,o=this.Ts(e);return this.docs=this.docs.insert(r,{document:e.mutableCopy(),size:o,readTime:n}),this.size+=o-s,this.Jt.addToCollectionParentIndex(t,r.path.popLast())}removeEntry(t){const e=this.docs.get(t);e&&(this.docs=this.docs.remove(t),this.size-=e.size)}getEntry(t,e){const n=this.docs.get(e);return xa.resolve(n?n.document.mutableCopy():Li.newInvalidDocument(e))}getEntries(t,e){let n=co();return e.forEach((t=>{const e=this.docs.get(t);n=n.insert(t,e?e.document.mutableCopy():Li.newInvalidDocument(t))})),xa.resolve(n)}getDocumentsMatchingQuery(t,e,n){let r=co();const i=new vi(e.path.child("")),s=this.docs.getIteratorFrom(i);for(;s.hasNext();){const{key:t,value:{document:i,readTime:o}}=s.getNext();if(!e.path.isPrefixOf(t.path))break;o.compareTo(n)<=0||gs(e,i)&&(r=r.insert(i.key,i.mutableCopy()))}return xa.resolve(r)}Es(t,e){return xa.forEach(this.docs,(t=>e(t)))}newChangeBuffer(t){return new hu(this)}getSize(t){return xa.resolve(this.size)}}class hu extends Cc{constructor(t){super(),this.De=t}applyChanges(t){const e=[];return this.changes.forEach(((n,r)=>{r.document.isValidDocument()?e.push(this.De.addEntry(t,r.document,this.getReadTime(n))):this.De.removeEntry(n)})),xa.waitFor(e)}getFromCache(t,e){return this.De.getEntry(t,e)}getAllFromCache(t,e){return this.De.getEntries(t,e)}}class lu{constructor(t){this.persistence=t,this.Is=new xc((t=>Ui(t)),Vi),this.lastRemoteSnapshotVersion=Jr.min(),this.highestTargetId=0,this.As=0,this.Rs=new ou,this.targetCount=0,this.bs=yc.ie()}forEachTarget(t,e){return this.Is.forEach(((t,n)=>e(n))),xa.resolve()}getLastRemoteSnapshotVersion(t){return xa.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(t){return xa.resolve(this.As)}allocateTargetId(t){return this.highestTargetId=this.bs.next(),xa.resolve(this.highestTargetId)}setTargetsMetadata(t,e,n){return n&&(this.lastRemoteSnapshotVersion=n),e>this.As&&(this.As=e),xa.resolve()}ce(t){this.Is.set(t.target,t);const e=t.targetId;e>this.highestTargetId&&(this.bs=new yc(e),this.highestTargetId=e),t.sequenceNumber>this.As&&(this.As=t.sequenceNumber)}addTargetData(t,e){return this.ce(e),this.targetCount+=1,xa.resolve()}updateTargetData(t,e){return this.ce(e),xa.resolve()}removeTargetData(t,e){return this.Is.delete(e.target),this.Rs.us(e.targetId),this.targetCount-=1,xa.resolve()}removeTargets(t,e,n){let r=0;const i=[];return this.Is.forEach(((s,o)=>{o.sequenceNumber<=e&&null===n.get(o.targetId)&&(this.Is.delete(s),i.push(this.removeMatchingKeysForTargetId(t,o.targetId)),r++)})),xa.waitFor(i).next((()=>r))}getTargetCount(t){return xa.resolve(this.targetCount)}getTargetData(t,e){const n=this.Is.get(e)||null;return xa.resolve(n)}addMatchingKeys(t,e,n){return this.Rs.rs(e,n),xa.resolve()}removeMatchingKeys(t,e,n){this.Rs.cs(e,n);const r=this.persistence.referenceDelegate,i=[];return r&&e.forEach((e=>{i.push(r.markPotentiallyOrphaned(t,e))})),xa.waitFor(i)}removeMatchingKeysForTargetId(t,e){return this.Rs.us(e),xa.resolve()}getMatchingKeysForTargetId(t,e){const n=this.Rs.ls(e);return xa.resolve(n)}containsKey(t,e){return xa.resolve(this.Rs.containsKey(e))}}class du{constructor(t,e){this.Ps={},this.Be=new Kr(0),this.Ue=!1,this.Ue=!0,this.referenceDelegate=t(this),this.He=new lu(this),this.Jt=new ic,this.Je=function(t,e){return new uu(t,e)}(this.Jt,(t=>this.referenceDelegate.vs(t))),this.k=new Ka(e),this.Ye=new su(this.k)}start(){return Promise.resolve()}shutdown(){return this.Ue=!1,Promise.resolve()}get started(){return this.Ue}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(){return this.Jt}getMutationQueue(t){let e=this.Ps[t.toKey()];return e||(e=new cu(this.Jt,this.referenceDelegate),this.Ps[t.toKey()]=e),e}getTargetCache(){return this.He}getRemoteDocumentCache(){return this.Je}getBundleCache(){return this.Ye}runTransaction(t,e,n){Er("MemoryPersistence","Starting transaction:",t);const r=new fu(this.Be.next());return this.referenceDelegate.Vs(),n(r).next((t=>this.referenceDelegate.Ss(r).next((()=>t)))).toPromise().then((t=>(r.raiseOnCommittedEvent(),t)))}Ds(t,e){return xa.or(Object.values(this.Ps).map((n=>()=>n.containsKey(t,e))))}}class fu extends Na{constructor(t){super(),this.currentSequenceNumber=t}}class pu{constructor(t){this.persistence=t,this.Cs=new ou,this.Ns=null}static ks(t){return new pu(t)}get xs(){if(this.Ns)return this.Ns;throw Nr()}addReference(t,e,n){return this.Cs.addReference(n,e),this.xs.delete(n.toString()),xa.resolve()}removeReference(t,e,n){return this.Cs.removeReference(n,e),this.xs.add(n.toString()),xa.resolve()}markPotentiallyOrphaned(t,e){return this.xs.add(e.toString()),xa.resolve()}removeTarget(t,e){this.Cs.us(e.targetId).forEach((t=>this.xs.add(t.toString())));const n=this.persistence.getTargetCache();return n.getMatchingKeysForTargetId(t,e.targetId).next((t=>{t.forEach((t=>this.xs.add(t.toString())))})).next((()=>n.removeTargetData(t,e)))}Vs(){this.Ns=new Set}Ss(t){const e=this.persistence.getRemoteDocumentCache().newChangeBuffer();return xa.forEach(this.xs,(n=>{const r=vi.fromPath(n);return this.$s(t,r).next((t=>{t||e.removeEntry(r)}))})).next((()=>(this.Ns=null,e.apply(t))))}updateLimboDocument(t,e){return this.$s(t,e).next((t=>{t?this.xs.delete(e.toString()):this.xs.add(e.toString())}))}vs(t){return 0}$s(t,e){return xa.or([()=>xa.resolve(this.Cs.containsKey(e)),()=>this.persistence.getTargetCache().containsKey(t,e),()=>this.persistence.Ds(t,e)])}}function mu(t,e){return`firestore_clients_${t}_${e}`}function gu(t,e,n){let r=`firestore_mutations_${t}_${n}`;return e.isAuthenticated()&&(r+=`_${e.uid}`),r}function yu(t,e){return`firestore_targets_${t}_${e}`}class vu{constructor(t,e,n,r){this.user=t,this.batchId=e,this.state=n,this.error=r}static Os(t,e,n){const r=JSON.parse(n);let i,s="object"==typeof r&&-1!==["pending","acknowledged","rejected"].indexOf(r.state)&&(void 0===r.error||"object"==typeof r.error);return s&&r.error&&(s="string"==typeof r.error.message&&"string"==typeof r.error.code,s&&(i=new Rr(r.error.code,r.error.message))),s?new vu(t,e,r.state,i):(Sr("SharedClientState",`Failed to parse mutation state for ID '${e}': ${n}`),null)}Fs(){const t={state:this.state,updateTimeMs:Date.now()};return this.error&&(t.error={code:this.error.code,message:this.error.message}),JSON.stringify(t)}}class bu{constructor(t,e,n){this.targetId=t,this.state=e,this.error=n}static Os(t,e){const n=JSON.parse(e);let r,i="object"==typeof n&&-1!==["not-current","current","rejected"].indexOf(n.state)&&(void 0===n.error||"object"==typeof n.error);return i&&n.error&&(i="string"==typeof n.error.message&&"string"==typeof n.error.code,i&&(r=new Rr(n.error.code,n.error.message))),i?new bu(t,n.state,r):(Sr("SharedClientState",`Failed to parse target state for ID '${t}': ${e}`),null)}Fs(){const t={state:this.state,updateTimeMs:Date.now()};return this.error&&(t.error={code:this.error.code,message:this.error.message}),JSON.stringify(t)}}class wu{constructor(t,e){this.clientId=t,this.activeTargetIds=e}static Os(t,e){const n=JSON.parse(e);let r="object"==typeof n&&n.activeTargetIds instanceof Array,i=yo();for(let t=0;r&&t<n.activeTargetIds.length;++t)r=yi(n.activeTargetIds[t]),i=i.add(n.activeTargetIds[t]);return r?new wu(t,i):(Sr("SharedClientState",`Failed to parse client data for instance '${t}': ${e}`),null)}}class Iu{constructor(t,e){this.clientId=t,this.onlineState=e}static Os(t){const e=JSON.parse(t);return"object"==typeof e&&-1!==["Unknown","Online","Offline"].indexOf(e.onlineState)&&"string"==typeof e.clientId?new Iu(e.clientId,e.onlineState):(Sr("SharedClientState",`Failed to parse online state: ${t}`),null)}}class Tu{constructor(){this.activeTargetIds=yo()}Ms(t){this.activeTargetIds=this.activeTargetIds.add(t)}Ls(t){this.activeTargetIds=this.activeTargetIds.delete(t)}Fs(){const t={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(t)}}class _u{constructor(t,e,n,r,i){this.window=t,this.Fe=e,this.persistenceKey=n,this.Bs=r,this.syncEngine=null,this.onlineStateHandler=null,this.sequenceNumberHandler=null,this.Us=this.qs.bind(this),this.Ks=new no(Hr),this.started=!1,this.js=[];const s=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");this.storage=this.window.localStorage,this.currentUser=i,this.Qs=mu(this.persistenceKey,this.Bs),this.Ws=function(t){return`firestore_sequence_number_${t}`}(this.persistenceKey),this.Ks=this.Ks.insert(this.Bs,new Tu),this.Gs=new RegExp(`^firestore_clients_${s}_([^_]*)$`),this.zs=new RegExp(`^firestore_mutations_${s}_(\\d+)(?:_(.*))?$`),this.Hs=new RegExp(`^firestore_targets_${s}_(\\d+)$`),this.Js=function(t){return`firestore_online_state_${t}`}(this.persistenceKey),this.Ys=function(t){return`firestore_bundle_loaded_${t}`}(this.persistenceKey),this.window.addEventListener("storage",this.Us)}static Pt(t){return!(!t||!t.localStorage)}async start(){const t=await this.syncEngine.Tn();for(const e of t){if(e===this.Bs)continue;const t=this.getItem(mu(this.persistenceKey,e));if(t){const n=wu.Os(e,t);n&&(this.Ks=this.Ks.insert(n.clientId,n))}}this.Xs();const e=this.storage.getItem(this.Js);if(e){const t=this.Zs(e);t&&this.ti(t)}for(const t of this.js)this.qs(t);this.js=[],this.window.addEventListener("pagehide",(()=>this.shutdown())),this.started=!0}writeSequenceNumber(t){this.setItem(this.Ws,JSON.stringify(t))}getAllActiveQueryTargets(){return this.ei(this.Ks)}isActiveQueryTarget(t){let e=!1;return this.Ks.forEach(((n,r)=>{r.activeTargetIds.has(t)&&(e=!0)})),e}addPendingMutation(t){this.ni(t,"pending")}updateMutationState(t,e,n){this.ni(t,e,n),this.si(t)}addLocalQueryTarget(t){let e="not-current";if(this.isActiveQueryTarget(t)){const n=this.storage.getItem(yu(this.persistenceKey,t));if(n){const r=bu.Os(t,n);r&&(e=r.state)}}return this.ii.Ms(t),this.Xs(),e}removeLocalQueryTarget(t){this.ii.Ls(t),this.Xs()}isLocalQueryTarget(t){return this.ii.activeTargetIds.has(t)}clearQueryState(t){this.removeItem(yu(this.persistenceKey,t))}updateQueryState(t,e,n){this.ri(t,e,n)}handleUserChange(t,e,n){e.forEach((t=>{this.si(t)})),this.currentUser=t,n.forEach((t=>{this.addPendingMutation(t)}))}setOnlineState(t){this.oi(t)}notifyBundleLoaded(){this.ai()}shutdown(){this.started&&(this.window.removeEventListener("storage",this.Us),this.removeItem(this.Qs),this.started=!1)}getItem(t){const e=this.storage.getItem(t);return Er("SharedClientState","READ",t,e),e}setItem(t,e){Er("SharedClientState","SET",t,e),this.storage.setItem(t,e)}removeItem(t){Er("SharedClientState","REMOVE",t),this.storage.removeItem(t)}qs(t){const e=t;if(e.storageArea===this.storage){if(Er("SharedClientState","EVENT",e.key,e.newValue),e.key===this.Qs)return void Sr("Received WebStorage notification for local change. Another client might have garbage-collected our state");this.Fe.enqueueRetryable((async()=>{if(this.started){if(null!==e.key)if(this.Gs.test(e.key)){if(null==e.newValue){const t=this.ci(e.key);return this.ui(t,null)}{const t=this.hi(e.key,e.newValue);if(t)return this.ui(t.clientId,t)}}else if(this.zs.test(e.key)){if(null!==e.newValue){const t=this.li(e.key,e.newValue);if(t)return this.fi(t)}}else if(this.Hs.test(e.key)){if(null!==e.newValue){const t=this.di(e.key,e.newValue);if(t)return this.wi(t)}}else if(e.key===this.Js){if(null!==e.newValue){const t=this.Zs(e.newValue);if(t)return this.ti(t)}}else if(e.key===this.Ws){const t=function(t){let e=Kr.I;if(null!=t)try{const n=JSON.parse(t);xr("number"==typeof n),e=n}catch(t){Sr("SharedClientState","Failed to read sequence number from WebStorage",t)}return e}(e.newValue);t!==Kr.I&&this.sequenceNumberHandler(t)}else if(e.key===this.Ys)return this.syncEngine._i()}else this.js.push(e)}))}}get ii(){return this.Ks.get(this.Bs)}Xs(){this.setItem(this.Qs,this.ii.Fs())}ni(t,e,n){const r=new vu(this.currentUser,t,e,n),i=gu(this.persistenceKey,this.currentUser,t);this.setItem(i,r.Fs())}si(t){const e=gu(this.persistenceKey,this.currentUser,t);this.removeItem(e)}oi(t){const e={clientId:this.Bs,onlineState:t};this.storage.setItem(this.Js,JSON.stringify(e))}ri(t,e,n){const r=yu(this.persistenceKey,t),i=new bu(t,e,n);this.setItem(r,i.Fs())}ai(){this.setItem(this.Ys,"value-not-used")}ci(t){const e=this.Gs.exec(t);return e?e[1]:null}hi(t,e){const n=this.ci(t);return wu.Os(n,e)}li(t,e){const n=this.zs.exec(t),r=Number(n[1]),i=void 0!==n[2]?n[2]:null;return vu.Os(new br(i),r,e)}di(t,e){const n=this.Hs.exec(t),r=Number(n[1]);return bu.Os(r,e)}Zs(t){return Iu.Os(t)}async fi(t){if(t.user.uid===this.currentUser.uid)return this.syncEngine.mi(t.batchId,t.state,t.error);Er("SharedClientState",`Ignoring mutation for non-active user ${t.user.uid}`)}wi(t){return this.syncEngine.gi(t.targetId,t.state,t.error)}ui(t,e){const n=e?this.Ks.insert(t,e):this.Ks.remove(t),r=this.ei(this.Ks),i=this.ei(n),s=[],o=[];return i.forEach((t=>{r.has(t)||s.push(t)})),r.forEach((t=>{i.has(t)||o.push(t)})),this.syncEngine.yi(s,o).then((()=>{this.Ks=n}))}ti(t){this.Ks.get(t.clientId)&&this.onlineStateHandler(t.onlineState)}ei(t){let e=yo();return t.forEach(((t,n)=>{e=e.unionWith(n.activeTargetIds)})),e}}class Eu{constructor(){this.pi=new Tu,this.Ti={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(t){}updateMutationState(t,e,n){}addLocalQueryTarget(t){return this.pi.Ms(t),this.Ti[t]||"not-current"}updateQueryState(t,e,n){this.Ti[t]=e}removeLocalQueryTarget(t){this.pi.Ls(t)}isLocalQueryTarget(t){return this.pi.activeTargetIds.has(t)}clearQueryState(t){delete this.Ti[t]}getAllActiveQueryTargets(){return this.pi.activeTargetIds}isActiveQueryTarget(t){return this.pi.activeTargetIds.has(t)}start(){return this.pi=new Tu,Promise.resolve()}handleUserChange(t,e,n){}setOnlineState(t){}shutdown(){}writeSequenceNumber(t){}notifyBundleLoaded(){}}class Su{Ei(t){}shutdown(){}}class ku{constructor(){this.Ii=()=>this.Ai(),this.Ri=()=>this.bi(),this.Pi=[],this.vi()}Ei(t){this.Pi.push(t)}shutdown(){window.removeEventListener("online",this.Ii),window.removeEventListener("offline",this.Ri)}vi(){window.addEventListener("online",this.Ii),window.addEventListener("offline",this.Ri)}Ai(){Er("ConnectivityMonitor","Network connectivity changed: AVAILABLE");for(const t of this.Pi)t(0)}bi(){Er("ConnectivityMonitor","Network connectivity changed: UNAVAILABLE");for(const t of this.Pi)t(1)}static Pt(){return"undefined"!=typeof window&&void 0!==window.addEventListener&&void 0!==window.removeEventListener}}const Au={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery"};class Nu{constructor(t){this.Vi=t.Vi,this.Si=t.Si}Di(t){this.Ci=t}Ni(t){this.ki=t}onMessage(t){this.xi=t}close(){this.Si()}send(t){this.Vi(t)}$i(){this.Ci()}Oi(t){this.ki(t)}Fi(t){this.xi(t)}}class xu extends class{constructor(t){this.databaseInfo=t,this.databaseId=t.databaseId;const e=t.ssl?"https":"http";this.Mi=e+"://"+t.host,this.Li="projects/"+this.databaseId.projectId+"/databases/"+this.databaseId.database+"/documents"}Bi(t,e,n,r,i){const s=this.Ui(t,e);Er("RestConnection","Sending: ",s,n);const o={};return this.qi(o,r,i),this.Ki(t,s,o,n).then((t=>(Er("RestConnection","Received: ",t),t)),(e=>{throw kr("RestConnection",`${t} failed with error: `,e,"url: ",s,"request:",n),e}))}ji(t,e,n,r,i){return this.Bi(t,e,n,r,i)}qi(t,e,n){t["X-Goog-Api-Client"]="gl-js/ fire/"+wr,t["Content-Type"]="text/plain",this.databaseInfo.appId&&(t["X-Firebase-GMPID"]=this.databaseInfo.appId),e&&e.headers.forEach(((e,n)=>t[n]=e)),n&&n.headers.forEach(((e,n)=>t[n]=e))}Ui(t,e){const n=Au[t];return`${this.Mi}/v1/${e}:${n}`}}{constructor(t){super(t),this.forceLongPolling=t.forceLongPolling,this.autoDetectLongPolling=t.autoDetectLongPolling,this.useFetchStreams=t.useFetchStreams}Ki(t,e,n,r){return new Promise(((i,s)=>{const o=new yr;o.listenOnce(dr.COMPLETE,(()=>{try{switch(o.getLastErrorCode()){case lr.NO_ERROR:const e=o.getResponseJson();Er("Connection","XHR received:",JSON.stringify(e)),i(e);break;case lr.TIMEOUT:Er("Connection",'RPC "'+t+'" timed out'),s(new Rr(Or.DEADLINE_EXCEEDED,"Request time out"));break;case lr.HTTP_ERROR:const n=o.getStatus();if(Er("Connection",'RPC "'+t+'" failed with status:',n,"response text:",o.getResponseText()),n>0){const t=o.getResponseJson().error;if(t&&t.status&&t.message){const e=function(t){const e=t.toLowerCase().replace(/_/g,"-");return Object.values(Or).indexOf(e)>=0?e:Or.UNKNOWN}(t.status);s(new Rr(e,t.message))}else s(new Rr(Or.UNKNOWN,"Server responded with status "+o.getStatus()))}else s(new Rr(Or.UNAVAILABLE,"Connection failed."));break;default:Nr()}}finally{Er("Connection",'RPC "'+t+'" completed.')}}));const a=JSON.stringify(r);o.send(e,"POST",a,n,15)}))}Qi(t,e,n){const r=[this.Mi,"/","google.firestore.v1.Firestore","/",t,"/channel"],i=ur(),s=hr(),o={httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:`projects/${this.databaseId.projectId}/databases/${this.databaseId.database}`},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling,detectBufferingProxy:this.autoDetectLongPolling};this.useFetchStreams&&(o.xmlHttpFactory=new mr({})),this.qi(o.initMessageHeaders,e,n),(0,a.uI)()||(0,a.b$)()||(0,a.d)()||(0,a.w1)()||(0,a.Mn)()||(0,a.ru)()||(o.httpHeadersOverwriteParam="$httpHeaders");const c=r.join("");Er("Connection","Creating WebChannel: "+c,o);const u=i.createWebChannel(c,o);let h=!1,l=!1;const d=new Nu({Vi:t=>{l?Er("Connection","Not sending because WebChannel is closed:",t):(h||(Er("Connection","Opening WebChannel transport."),u.open(),h=!0),Er("Connection","WebChannel sending:",t),u.send(t))},Si:()=>u.close()}),f=(t,e,n)=>{t.listen(e,(t=>{try{n(t)}catch(t){setTimeout((()=>{throw t}),0)}}))};return f(u,gr.EventType.OPEN,(()=>{l||Er("Connection","WebChannel transport opened.")})),f(u,gr.EventType.CLOSE,(()=>{l||(l=!0,Er("Connection","WebChannel transport closed"),d.Oi())})),f(u,gr.EventType.ERROR,(t=>{l||(l=!0,kr("Connection","WebChannel transport errored:",t),d.Oi(new Rr(Or.UNAVAILABLE,"The operation could not be completed")))})),f(u,gr.EventType.MESSAGE,(t=>{var e;if(!l){const n=t.data[0];xr(!!n);const r=n,i=r.error||(null===(e=r[0])||void 0===e?void 0:e.error);if(i){Er("Connection","WebChannel received error:",i);const t=i.status;let e=function(t){const e=Zs[t];if(void 0!==e)return eo(e)}(t),n=i.message;void 0===e&&(e=Or.INTERNAL,n="Unknown error status: "+t+" with message "+i.message),l=!0,d.Oi(new Rr(e,n)),u.close()}else Er("Connection","WebChannel received:",n),d.Fi(n)}})),f(s,fr.STAT_EVENT,(t=>{t.stat===pr.PROXY?Er("Connection","Detected buffering proxy"):t.stat===pr.NOPROXY&&Er("Connection","Detected no buffering proxy")})),setTimeout((()=>{d.$i()}),0),d}}function Cu(){return"undefined"!=typeof window?window:null}function Du(){return"undefined"!=typeof document?document:null}function Ou(t){return new xo(t,!0)}class Ru{constructor(t,e,n=1e3,r=1.5,i=6e4){this.Fe=t,this.timerId=e,this.Wi=n,this.Gi=r,this.zi=i,this.Hi=0,this.Ji=null,this.Yi=Date.now(),this.reset()}reset(){this.Hi=0}Xi(){this.Hi=this.zi}Zi(t){this.cancel();const e=Math.floor(this.Hi+this.tr()),n=Math.max(0,Date.now()-this.Yi),r=Math.max(0,e-n);r>0&&Er("ExponentialBackoff",`Backing off for ${r} ms (base delay: ${this.Hi} ms, delay with jitter: ${e} ms, last attempt: ${n} ms ago)`),this.Ji=this.Fe.enqueueAfterDelay(this.timerId,r,(()=>(this.Yi=Date.now(),t()))),this.Hi*=this.Gi,this.Hi<this.Wi&&(this.Hi=this.Wi),this.Hi>this.zi&&(this.Hi=this.zi)}er(){null!==this.Ji&&(this.Ji.skipDelay(),this.Ji=null)}cancel(){null!==this.Ji&&(this.Ji.cancel(),this.Ji=null)}tr(){return(Math.random()-.5)*this.Hi}}class Pu{constructor(t,e,n,r,i,s,o,a){this.Fe=t,this.nr=n,this.sr=r,this.ir=i,this.authCredentialsProvider=s,this.appCheckCredentialsProvider=o,this.listener=a,this.state=0,this.rr=0,this.ar=null,this.cr=null,this.stream=null,this.ur=new Ru(t,e)}hr(){return 1===this.state||5===this.state||this.lr()}lr(){return 2===this.state||3===this.state}start(){4!==this.state?this.auth():this.dr()}async stop(){this.hr()&&await this.close(0)}wr(){this.state=0,this.ur.reset()}_r(){this.lr()&&null===this.ar&&(this.ar=this.Fe.enqueueAfterDelay(this.nr,6e4,(()=>this.mr())))}gr(t){this.yr(),this.stream.send(t)}async mr(){if(this.lr())return this.close(0)}yr(){this.ar&&(this.ar.cancel(),this.ar=null)}pr(){this.cr&&(this.cr.cancel(),this.cr=null)}async close(t,e){this.yr(),this.pr(),this.ur.cancel(),this.rr++,4!==t?this.ur.reset():e&&e.code===Or.RESOURCE_EXHAUSTED?(Sr(e.toString()),Sr("Using maximum backoff delay to prevent overloading the backend."),this.ur.Xi()):e&&e.code===Or.UNAUTHENTICATED&&3!==this.state&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),null!==this.stream&&(this.Tr(),this.stream.close(),this.stream=null),this.state=t,await this.listener.Ni(e)}Tr(){}auth(){this.state=1;const t=this.Er(this.rr),e=this.rr;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then((([t,n])=>{this.rr===e&&this.Ir(t,n)}),(e=>{t((()=>{const t=new Rr(Or.UNKNOWN,"Fetching auth token failed: "+e.message);return this.Ar(t)}))}))}Ir(t,e){const n=this.Er(this.rr);this.stream=this.Rr(t,e),this.stream.Di((()=>{n((()=>(this.state=2,this.cr=this.Fe.enqueueAfterDelay(this.sr,1e4,(()=>(this.lr()&&(this.state=3),Promise.resolve()))),this.listener.Di())))})),this.stream.Ni((t=>{n((()=>this.Ar(t)))})),this.stream.onMessage((t=>{n((()=>this.onMessage(t)))}))}dr(){this.state=5,this.ur.Zi((async()=>{this.state=0,this.start()}))}Ar(t){return Er("PersistentStream",`close with error: ${t}`),this.stream=null,this.close(4,t)}Er(t){return e=>{this.Fe.enqueueAndForget((()=>this.rr===t?e():(Er("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())))}}}class Lu extends Pu{constructor(t,e,n,r,i,s){super(t,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",e,n,r,s),this.k=i}Rr(t,e){return this.ir.Qi("Listen",t,e)}onMessage(t){this.ur.reset();const e=function(t,e){let n;if("targetChange"in e){e.targetChange;const r=function(t){return"NO_CHANGE"===t?0:"ADD"===t?1:"REMOVE"===t?2:"CURRENT"===t?3:"RESET"===t?4:Nr()}(e.targetChange.targetChangeType||"NO_CHANGE"),i=e.targetChange.targetIds||[],s=function(t,e){return t.C?(xr(void 0===e||"string"==typeof e),ai.fromBase64String(e||"")):(xr(void 0===e||e instanceof Uint8Array),ai.fromUint8Array(e||new Uint8Array))}(t,e.targetChange.resumeToken),o=e.targetChange.cause,a=o&&function(t){const e=void 0===t.code?Or.UNKNOWN:eo(t.code);return new Rr(e,t.message||"")}(o);n=new To(r,i,s,a||null)}else if("documentChange"in e){e.documentChange;const r=e.documentChange;r.document,r.document.name,r.document.updateTime;const i=Fo(t,r.document.name),s=Ro(r.document.updateTime),o=new Ri({mapValue:{fields:r.document.fields}}),a=Li.newFoundDocument(i,s,o),c=r.targetIds||[],u=r.removedTargetIds||[];n=new wo(c,u,a.key,a)}else if("documentDelete"in e){e.documentDelete;const r=e.documentDelete;r.document;const i=Fo(t,r.document),s=r.readTime?Ro(r.readTime):Jr.min(),o=Li.newNoDocument(i,s),a=r.removedTargetIds||[];n=new wo([],a,o.key,o)}else if("documentRemove"in e){e.documentRemove;const r=e.documentRemove;r.document;const i=Fo(t,r.document),s=r.removedTargetIds||[];n=new wo([],s,i,null)}else{if(!("filter"in e))return Nr();{e.filter;const t=e.filter;t.targetId;const r=t.count||0,i=new Js(r),s=t.targetId;n=new Io(s,i)}}return n}(this.k,t),n=function(t){if(!("targetChange"in t))return Jr.min();const e=t.targetChange;return e.targetIds&&e.targetIds.length?Jr.min():e.readTime?Ro(e.readTime):Jr.min()}(t);return this.listener.br(e,n)}Pr(t){const e={};e.database=jo(this.k),e.addTarget=function(t,e){let n;const r=e.target;return n=ji(r)?{documents:Go(t,r)}:{query:Ho(t,r)},n.targetId=e.targetId,e.resumeToken.approximateByteSize()>0?n.resumeToken=Do(t,e.resumeToken):e.snapshotVersion.compareTo(Jr.min())>0&&(n.readTime=Co(t,e.snapshotVersion.toTimestamp())),n}(this.k,t);const n=function(t,e){const n=function(t,e){switch(e){case 0:return null;case 1:return"existence-filter-mismatch";case 2:return"limbo-document";default:return Nr()}}(0,e.purpose);return null==n?null:{"goog-listen-tags":n}}(this.k,t);n&&(e.labels=n),this.gr(e)}vr(t){const e={};e.database=jo(this.k),e.removeTarget=t,this.gr(e)}}class Mu extends Pu{constructor(t,e,n,r,i,s){super(t,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",e,n,r,s),this.k=i,this.Vr=!1}get Sr(){return this.Vr}start(){this.Vr=!1,this.lastStreamToken=void 0,super.start()}Tr(){this.Vr&&this.Dr([])}Rr(t,e){return this.ir.Qi("Write",t,e)}onMessage(t){if(xr(!!t.streamToken),this.lastStreamToken=t.streamToken,this.Vr){this.ur.reset();const e=function(t,e){return t&&t.length>0?(xr(void 0!==e),t.map((t=>function(t,e){let n=t.updateTime?Ro(t.updateTime):Ro(e);return n.isEqual(Jr.min())&&(n=Ro(e)),new Ls(n,t.transformResults||[])}(t,e)))):[]}(t.writeResults,t.commitTime),n=Ro(t.commitTime);return this.listener.Cr(n,e)}return xr(!t.writeResults||0===t.writeResults.length),this.Vr=!0,this.listener.Nr()}kr(){const t={};t.database=jo(this.k),this.gr(t)}Dr(t){const e={streamToken:this.lastStreamToken,writes:t.map((t=>Ko(this.k,t)))};this.gr(e)}}class Fu extends class{}{constructor(t,e,n,r){super(),this.authCredentials=t,this.appCheckCredentials=e,this.ir=n,this.k=r,this.$r=!1}Or(){if(this.$r)throw new Rr(Or.FAILED_PRECONDITION,"The client has already been terminated.")}Bi(t,e,n){return this.Or(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([r,i])=>this.ir.Bi(t,e,n,r,i))).catch((t=>{throw"FirebaseError"===t.name?(t.code===Or.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),t):new Rr(Or.UNKNOWN,t.toString())}))}ji(t,e,n){return this.Or(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([r,i])=>this.ir.ji(t,e,n,r,i))).catch((t=>{throw"FirebaseError"===t.name?(t.code===Or.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),t):new Rr(Or.UNKNOWN,t.toString())}))}terminate(){this.$r=!0}}class Uu{constructor(t,e){this.asyncQueue=t,this.onlineStateHandler=e,this.state="Unknown",this.Fr=0,this.Mr=null,this.Lr=!0}Br(){0===this.Fr&&(this.Ur("Unknown"),this.Mr=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,(()=>(this.Mr=null,this.qr("Backend didn't respond within 10 seconds."),this.Ur("Offline"),Promise.resolve()))))}Kr(t){"Online"===this.state?this.Ur("Unknown"):(this.Fr++,this.Fr>=1&&(this.jr(),this.qr(`Connection failed 1 times. Most recent error: ${t.toString()}`),this.Ur("Offline")))}set(t){this.jr(),this.Fr=0,"Online"===t&&(this.Lr=!1),this.Ur(t)}Ur(t){t!==this.state&&(this.state=t,this.onlineStateHandler(t))}qr(t){const e=`Could not reach Cloud Firestore backend. ${t}\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.Lr?(Sr(e),this.Lr=!1):Er("OnlineStateTracker",e)}jr(){null!==this.Mr&&(this.Mr.cancel(),this.Mr=null)}}class Vu{constructor(t,e,n,r,i){this.localStore=t,this.datastore=e,this.asyncQueue=n,this.remoteSyncer={},this.Qr=[],this.Wr=new Map,this.Gr=new Set,this.zr=[],this.Hr=i,this.Hr.Ei((t=>{n.enqueueAndForget((async()=>{$u(this)&&(Er("RemoteStore","Restarting streams for network reachability change."),await async function(t){const e=Dr(t);e.Gr.add(4),await qu(e),e.Jr.set("Unknown"),e.Gr.delete(4),await ju(e)}(this))}))})),this.Jr=new Uu(n,r)}}async function ju(t){if($u(t))for(const e of t.zr)await e(!0)}async function qu(t){for(const e of t.zr)await e(!1)}function Bu(t,e){const n=Dr(t);n.Wr.has(e.targetId)||(n.Wr.set(e.targetId,e),Hu(n)?Gu(n):lh(n).lr()&&Ku(n,e))}function zu(t,e){const n=Dr(t),r=lh(n);n.Wr.delete(e),r.lr()&&Wu(n,e),0===n.Wr.size&&(r.lr()?r._r():$u(n)&&n.Jr.set("Unknown"))}function Ku(t,e){t.Yr.X(e.targetId),lh(t).Pr(e)}function Wu(t,e){t.Yr.X(e),lh(t).vr(e)}function Gu(t){t.Yr=new Eo({getRemoteKeysForTarget:e=>t.remoteSyncer.getRemoteKeysForTarget(e),Et:e=>t.Wr.get(e)||null}),lh(t).start(),t.Jr.Br()}function Hu(t){return $u(t)&&!lh(t).hr()&&t.Wr.size>0}function $u(t){return 0===Dr(t).Gr.size}function Yu(t){t.Yr=void 0}async function Qu(t){t.Wr.forEach(((e,n)=>{Ku(t,e)}))}async function Ju(t,e){Yu(t),Hu(t)?(t.Jr.Kr(e),Gu(t)):t.Jr.set("Unknown")}async function Zu(t,e,n){if(t.Jr.set("Online"),e instanceof To&&2===e.state&&e.cause)try{await async function(t,e){const n=e.cause;for(const r of e.targetIds)t.Wr.has(r)&&(await t.remoteSyncer.rejectListen(r,n),t.Wr.delete(r),t.Yr.removeTarget(r))}(t,e)}catch(n){Er("RemoteStore","Failed to remove targets %s: %s ",e.targetIds.join(","),n),await Xu(t,n)}else if(e instanceof wo?t.Yr.ot(e):e instanceof Io?t.Yr.dt(e):t.Yr.ut(e),!n.isEqual(Jr.min()))try{const e=await Qc(t.localStore);n.compareTo(e)>=0&&await function(t,e){const n=t.Yr.gt(e);return n.targetChanges.forEach(((n,r)=>{if(n.resumeToken.approximateByteSize()>0){const i=t.Wr.get(r);i&&t.Wr.set(r,i.withResumeToken(n.resumeToken,e))}})),n.targetMismatches.forEach((e=>{const n=t.Wr.get(e);if(!n)return;t.Wr.set(e,n.withResumeToken(ai.EMPTY_BYTE_STRING,n.snapshotVersion)),Wu(t,e);const r=new za(n.target,e,1,n.sequenceNumber);Ku(t,r)})),t.remoteSyncer.applyRemoteEvent(n)}(t,n)}catch(e){Er("RemoteStore","Failed to raise snapshot:",e),await Xu(t,e)}}async function Xu(t,e,n){if(!Pa(e))throw e;t.Gr.add(1),await qu(t),t.Jr.set("Offline"),n||(n=()=>Qc(t.localStore)),t.asyncQueue.enqueueRetryable((async()=>{Er("RemoteStore","Retrying IndexedDB access"),await n(),t.Gr.delete(1),await ju(t)}))}function th(t,e){return e().catch((n=>Xu(t,n,e)))}async function eh(t){const e=Dr(t),n=dh(e);let r=e.Qr.length>0?e.Qr[e.Qr.length-1].batchId:-1;for(;nh(e);)try{const t=await Zc(e.localStore,r);if(null===t){0===e.Qr.length&&n._r();break}r=t.batchId,rh(e,t)}catch(t){await Xu(e,t)}ih(e)&&sh(e)}function nh(t){return $u(t)&&t.Qr.length<10}function rh(t,e){t.Qr.push(e);const n=dh(t);n.lr()&&n.Sr&&n.Dr(e.mutations)}function ih(t){return $u(t)&&!dh(t).hr()&&t.Qr.length>0}function sh(t){dh(t).start()}async function oh(t){dh(t).kr()}async function ah(t){const e=dh(t);for(const n of t.Qr)e.Dr(n.mutations)}async function ch(t,e,n){const r=t.Qr.shift(),i=Ba.from(r,e,n);await th(t,(()=>t.remoteSyncer.applySuccessfulWrite(i))),await eh(t)}async function uh(t,e){e&&dh(t).Sr&&await async function(t,e){if(to(n=e.code)&&n!==Or.ABORTED){const n=t.Qr.shift();dh(t).wr(),await th(t,(()=>t.remoteSyncer.rejectFailedWrite(n.batchId,e))),await eh(t)}var n}(t,e),ih(t)&&sh(t)}async function hh(t,e){const n=Dr(t);e?(n.Gr.delete(2),await ju(n)):e||(n.Gr.add(2),await qu(n),n.Jr.set("Unknown"))}function lh(t){return t.Xr||(t.Xr=function(t,e,n){const r=Dr(t);return r.Or(),new Lu(e,r.ir,r.authCredentials,r.appCheckCredentials,r.k,n)}(t.datastore,t.asyncQueue,{Di:Qu.bind(null,t),Ni:Ju.bind(null,t),br:Zu.bind(null,t)}),t.zr.push((async e=>{e?(t.Xr.wr(),Hu(t)?Gu(t):t.Jr.set("Unknown")):(await t.Xr.stop(),Yu(t))}))),t.Xr}function dh(t){return t.Zr||(t.Zr=function(t,e,n){const r=Dr(t);return r.Or(),new Mu(e,r.ir,r.authCredentials,r.appCheckCredentials,r.k,n)}(t.datastore,t.asyncQueue,{Di:oh.bind(null,t),Ni:uh.bind(null,t),Nr:ah.bind(null,t),Cr:ch.bind(null,t)}),t.zr.push((async e=>{e?(t.Zr.wr(),await eh(t)):(await t.Zr.stop(),t.Qr.length>0&&(Er("RemoteStore",`Stopping write stream with ${t.Qr.length} pending writes`),t.Qr=[]))}))),t.Zr}class fh{constructor(t,e,n,r,i){this.asyncQueue=t,this.timerId=e,this.targetTimeMs=n,this.op=r,this.removalCallback=i,this.deferred=new Pr,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch((t=>{}))}static createAndSchedule(t,e,n,r,i){const s=Date.now()+n,o=new fh(t,e,s,r,i);return o.start(n),o}start(t){this.timerHandle=setTimeout((()=>this.handleDelayElapsed()),t)}skipDelay(){return this.handleDelayElapsed()}cancel(t){null!==this.timerHandle&&(this.clearTimeout(),this.deferred.reject(new Rr(Or.CANCELLED,"Operation cancelled"+(t?": "+t:""))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget((()=>null!==this.timerHandle?(this.clearTimeout(),this.op().then((t=>this.deferred.resolve(t)))):Promise.resolve()))}clearTimeout(){null!==this.timerHandle&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}}function ph(t,e){if(Sr("AsyncQueue",`${e}: ${t}`),Pa(t))return new Rr(Or.UNAVAILABLE,`${e}: ${t}`);throw t}class mh{constructor(t){this.comparator=t?(e,n)=>t(e,n)||vi.comparator(e.key,n.key):(t,e)=>vi.comparator(t.key,e.key),this.keyedMap=ho(),this.sortedSet=new no(this.comparator)}static emptySet(t){return new mh(t.comparator)}has(t){return null!=this.keyedMap.get(t)}get(t){return this.keyedMap.get(t)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(t){const e=this.keyedMap.get(t);return e?this.sortedSet.indexOf(e):-1}get size(){return this.sortedSet.size}forEach(t){this.sortedSet.inorderTraversal(((e,n)=>(t(e),!1)))}add(t){const e=this.delete(t.key);return e.copy(e.keyedMap.insert(t.key,t),e.sortedSet.insert(t,null))}delete(t){const e=this.get(t);return e?this.copy(this.keyedMap.remove(t),this.sortedSet.remove(e)):this}isEqual(t){if(!(t instanceof mh))return!1;if(this.size!==t.size)return!1;const e=this.sortedSet.getIterator(),n=t.sortedSet.getIterator();for(;e.hasNext();){const t=e.getNext().key,r=n.getNext().key;if(!t.isEqual(r))return!1}return!0}toString(){const t=[];return this.forEach((e=>{t.push(e.toString())})),0===t.length?"DocumentSet ()":"DocumentSet (\n "+t.join(" \n")+"\n)"}copy(t,e){const n=new mh;return n.comparator=this.comparator,n.keyedMap=t,n.sortedSet=e,n}}class gh{constructor(){this.eo=new no(vi.comparator)}track(t){const e=t.doc.key,n=this.eo.get(e);n?0!==t.type&&3===n.type?this.eo=this.eo.insert(e,t):3===t.type&&1!==n.type?this.eo=this.eo.insert(e,{type:n.type,doc:t.doc}):2===t.type&&2===n.type?this.eo=this.eo.insert(e,{type:2,doc:t.doc}):2===t.type&&0===n.type?this.eo=this.eo.insert(e,{type:0,doc:t.doc}):1===t.type&&0===n.type?this.eo=this.eo.remove(e):1===t.type&&2===n.type?this.eo=this.eo.insert(e,{type:1,doc:n.doc}):0===t.type&&1===n.type?this.eo=this.eo.insert(e,{type:2,doc:t.doc}):Nr():this.eo=this.eo.insert(e,t)}no(){const t=[];return this.eo.inorderTraversal(((e,n)=>{t.push(n)})),t}}class yh{constructor(t,e,n,r,i,s,o,a){this.query=t,this.docs=e,this.oldDocs=n,this.docChanges=r,this.mutatedKeys=i,this.fromCache=s,this.syncStateChanged=o,this.excludesMetadataChanges=a}static fromInitialDocuments(t,e,n,r){const i=[];return e.forEach((t=>{i.push({type:0,doc:t})})),new yh(t,e,mh.emptySet(e),i,n,r,!0,!1)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(t){if(!(this.fromCache===t.fromCache&&this.syncStateChanged===t.syncStateChanged&&this.mutatedKeys.isEqual(t.mutatedKeys)&&fs(this.query,t.query)&&this.docs.isEqual(t.docs)&&this.oldDocs.isEqual(t.oldDocs)))return!1;const e=this.docChanges,n=t.docChanges;if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t].type!==n[t].type||!e[t].doc.isEqual(n[t].doc))return!1;return!0}}class vh{constructor(){this.so=void 0,this.listeners=[]}}class bh{constructor(){this.queries=new xc((t=>ps(t)),fs),this.onlineState="Unknown",this.io=new Set}}async function wh(t,e){const n=Dr(t),r=e.query;let i=!1,s=n.queries.get(r);if(s||(i=!0,s=new vh),i)try{s.so=await n.onListen(r)}catch(t){const n=ph(t,`Initialization of query '${ms(e.query)}' failed`);return void e.onError(n)}n.queries.set(r,s),s.listeners.push(e),e.ro(n.onlineState),s.so&&e.oo(s.so)&&Eh(n)}async function Ih(t,e){const n=Dr(t),r=e.query;let i=!1;const s=n.queries.get(r);if(s){const t=s.listeners.indexOf(e);t>=0&&(s.listeners.splice(t,1),i=0===s.listeners.length)}if(i)return n.queries.delete(r),n.onUnlisten(r)}function Th(t,e){const n=Dr(t);let r=!1;for(const t of e){const e=t.query,i=n.queries.get(e);if(i){for(const e of i.listeners)e.oo(t)&&(r=!0);i.so=t}}r&&Eh(n)}function _h(t,e,n){const r=Dr(t),i=r.queries.get(e);if(i)for(const t of i.listeners)t.onError(n);r.queries.delete(e)}function Eh(t){t.io.forEach((t=>{t.next()}))}class Sh{constructor(t,e,n){this.query=t,this.ao=e,this.co=!1,this.uo=null,this.onlineState="Unknown",this.options=n||{}}oo(t){if(!this.options.includeMetadataChanges){const e=[];for(const n of t.docChanges)3!==n.type&&e.push(n);t=new yh(t.query,t.docs,t.oldDocs,e,t.mutatedKeys,t.fromCache,t.syncStateChanged,!0)}let e=!1;return this.co?this.ho(t)&&(this.ao.next(t),e=!0):this.lo(t,this.onlineState)&&(this.fo(t),e=!0),this.uo=t,e}onError(t){this.ao.error(t)}ro(t){this.onlineState=t;let e=!1;return this.uo&&!this.co&&this.lo(this.uo,t)&&(this.fo(this.uo),e=!0),e}lo(t,e){if(!t.fromCache)return!0;const n="Offline"!==e;return!(this.options.wo&&n||t.docs.isEmpty()&&"Offline"!==e)}ho(t){if(t.docChanges.length>0)return!0;const e=this.uo&&this.uo.hasPendingWrites!==t.hasPendingWrites;return!(!t.syncStateChanged&&!e)&&!0===this.options.includeMetadataChanges}fo(t){t=yh.fromInitialDocuments(t.query,t.docs,t.mutatedKeys,t.fromCache),this.co=!0,this.ao.next(t)}}class kh{constructor(t,e){this.payload=t,this.byteLength=e}_o(){return"metadata"in this.payload}}class Ah{constructor(t){this.k=t}Hn(t){return Fo(this.k,t)}Jn(t){return t.metadata.exists?zo(this.k,t.document,!1):Li.newNoDocument(this.Hn(t.metadata.name),this.Yn(t.metadata.readTime))}Yn(t){return Ro(t)}}class Nh{constructor(t,e,n){this.mo=t,this.localStore=e,this.k=n,this.queries=[],this.documents=[],this.progress=xh(t)}yo(t){this.progress.bytesLoaded+=t.byteLength;let e=this.progress.documentsLoaded;return t.payload.namedQuery?this.queries.push(t.payload.namedQuery):t.payload.documentMetadata?(this.documents.push({metadata:t.payload.documentMetadata}),t.payload.documentMetadata.exists||++e):t.payload.document&&(this.documents[this.documents.length-1].document=t.payload.document,++e),e!==this.progress.documentsLoaded?(this.progress.documentsLoaded=e,Object.assign({},this.progress)):null}po(t){const e=new Map,n=new Ah(this.k);for(const r of t)if(r.metadata.queries){const t=n.Hn(r.metadata.name);for(const n of r.metadata.queries){const r=(e.get(n)||mo()).add(t);e.set(n,r)}}return e}async complete(){const t=await async function(t,e,n,r){const i=Dr(t);let s=mo(),o=co(),a=fo();for(const t of n){const n=e.Hn(t.metadata.name);t.document&&(s=s.add(n)),o=o.insert(n,e.Jn(t)),a=a.insert(n,e.Yn(t.metadata.readTime))}const c=i.Qn.newChangeBuffer({trackRemovals:!0}),u=await Xc(i,function(t){return ls(is(ni.fromString(`__bundle__/docs/${t}`)))}(r));return i.persistence.runTransaction("Apply bundle documents","readwrite",(t=>Jc(t,c,o,Jr.min(),a).next((e=>(c.apply(t),e))).next((e=>i.He.removeMatchingKeysForTargetId(t,u.targetId).next((()=>i.He.addMatchingKeys(t,s,u.targetId))).next((()=>i.Wn.Vn(t,e))).next((()=>e))))))}(this.localStore,new Ah(this.k),this.documents,this.mo.id),e=this.po(this.documents);for(const t of this.queries)await iu(this.localStore,t,e.get(t.name));return this.progress.taskState="Success",new zc(Object.assign({},this.progress),t)}}function xh(t){return{taskState:"Running",documentsLoaded:0,bytesLoaded:0,totalDocuments:t.totalDocuments,totalBytes:t.totalBytes}}class Ch{constructor(t){this.key=t}}class Dh{constructor(t){this.key=t}}class Oh{constructor(t,e){this.query=t,this.To=e,this.Eo=null,this.current=!1,this.Io=mo(),this.mutatedKeys=mo(),this.Ao=ys(t),this.Ro=new mh(this.Ao)}get bo(){return this.To}Po(t,e){const n=e?e.vo:new gh,r=e?e.Ro:this.Ro;let i=e?e.mutatedKeys:this.mutatedKeys,s=r,o=!1;const a=ss(this.query)&&r.size===this.query.limit?r.last():null,c=os(this.query)&&r.size===this.query.limit?r.first():null;if(t.inorderTraversal(((t,e)=>{const u=r.get(t),h=gs(this.query,e)?e:null,l=!!u&&this.mutatedKeys.has(u.key),d=!!h&&(h.hasLocalMutations||this.mutatedKeys.has(h.key)&&h.hasCommittedMutations);let f=!1;u&&h?u.data.isEqual(h.data)?l!==d&&(n.track({type:3,doc:h}),f=!0):this.Vo(u,h)||(n.track({type:2,doc:h}),f=!0,(a&&this.Ao(h,a)>0||c&&this.Ao(h,c)<0)&&(o=!0)):!u&&h?(n.track({type:0,doc:h}),f=!0):u&&!h&&(n.track({type:1,doc:u}),f=!0,(a||c)&&(o=!0)),f&&(h?(s=s.add(h),i=d?i.add(t):i.delete(t)):(s=s.delete(t),i=i.delete(t)))})),ss(this.query)||os(this.query))for(;s.size>this.query.limit;){const t=ss(this.query)?s.last():s.first();s=s.delete(t.key),i=i.delete(t.key),n.track({type:1,doc:t})}return{Ro:s,vo:n,Bn:o,mutatedKeys:i}}Vo(t,e){return t.hasLocalMutations&&e.hasCommittedMutations&&!e.hasLocalMutations}applyChanges(t,e,n){const r=this.Ro;this.Ro=t.Ro,this.mutatedKeys=t.mutatedKeys;const i=t.vo.no();i.sort(((t,e)=>function(t,e){const n=t=>{switch(t){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return Nr()}};return n(t)-n(e)}(t.type,e.type)||this.Ao(t.doc,e.doc))),this.So(n);const s=e?this.Do():[],o=0===this.Io.size&&this.current?1:0,a=o!==this.Eo;return this.Eo=o,0!==i.length||a?{snapshot:new yh(this.query,t.Ro,r,i,t.mutatedKeys,0===o,a,!1),Co:s}:{Co:s}}ro(t){return this.current&&"Offline"===t?(this.current=!1,this.applyChanges({Ro:this.Ro,vo:new gh,mutatedKeys:this.mutatedKeys,Bn:!1},!1)):{Co:[]}}No(t){return!this.To.has(t)&&!!this.Ro.has(t)&&!this.Ro.get(t).hasLocalMutations}So(t){t&&(t.addedDocuments.forEach((t=>this.To=this.To.add(t))),t.modifiedDocuments.forEach((t=>{})),t.removedDocuments.forEach((t=>this.To=this.To.delete(t))),this.current=t.current)}Do(){if(!this.current)return[];const t=this.Io;this.Io=mo(),this.Ro.forEach((t=>{this.No(t.key)&&(this.Io=this.Io.add(t.key))}));const e=[];return t.forEach((t=>{this.Io.has(t)||e.push(new Dh(t))})),this.Io.forEach((n=>{t.has(n)||e.push(new Ch(n))})),e}ko(t){this.To=t.zn,this.Io=mo();const e=this.Po(t.documents);return this.applyChanges(e,!0)}xo(){return yh.fromInitialDocuments(this.query,this.Ro,this.mutatedKeys,0===this.Eo)}}class Rh{constructor(t,e,n){this.query=t,this.targetId=e,this.view=n}}class Ph{constructor(t){this.key=t,this.$o=!1}}class Lh{constructor(t,e,n,r,i,s){this.localStore=t,this.remoteStore=e,this.eventManager=n,this.sharedClientState=r,this.currentUser=i,this.maxConcurrentLimboResolutions=s,this.Oo={},this.Fo=new xc((t=>ps(t)),fs),this.Mo=new Map,this.Lo=new Set,this.Bo=new no(vi.comparator),this.Uo=new Map,this.qo=new ou,this.Ko={},this.jo=new Map,this.Qo=yc.re(),this.onlineState="Unknown",this.Wo=void 0}get isPrimaryClient(){return!0===this.Wo}}async function Mh(t,e){const n=cl(t);let r,i;const s=n.Fo.get(e);if(s)r=s.targetId,n.sharedClientState.addLocalQueryTarget(r),i=s.view.xo();else{const t=await Xc(n.localStore,ls(e)),s=n.sharedClientState.addLocalQueryTarget(t.targetId);r=t.targetId,i=await Fh(n,e,r,"current"===s),n.isPrimaryClient&&Bu(n.remoteStore,t)}return i}async function Fh(t,e,n,r){t.Go=(e,n,r)=>async function(t,e,n,r){let i=e.view.Po(n);i.Bn&&(i=await eu(t.localStore,e.query,!1).then((({documents:t})=>e.view.Po(t,i))));const s=r&&r.targetChanges.get(e.targetId),o=e.view.applyChanges(i,t.isPrimaryClient,s);return $h(t,e.targetId,o.Co),o.snapshot}(t,e,n,r);const i=await eu(t.localStore,e,!0),s=new Oh(e,i.zn),o=s.Po(i.documents),a=bo.createSynthesizedTargetChangeForCurrentChange(n,r&&"Offline"!==t.onlineState),c=s.applyChanges(o,t.isPrimaryClient,a);$h(t,n,c.Co);const u=new Rh(e,n,s);return t.Fo.set(e,u),t.Mo.has(n)?t.Mo.get(n).push(e):t.Mo.set(n,[e]),c.snapshot}async function Uh(t,e){const n=Dr(t),r=n.Fo.get(e),i=n.Mo.get(r.targetId);if(i.length>1)return n.Mo.set(r.targetId,i.filter((t=>!fs(t,e)))),void n.Fo.delete(e);n.isPrimaryClient?(n.sharedClientState.removeLocalQueryTarget(r.targetId),n.sharedClientState.isActiveQueryTarget(r.targetId)||await tu(n.localStore,r.targetId,!1).then((()=>{n.sharedClientState.clearQueryState(r.targetId),zu(n.remoteStore,r.targetId),Gh(n,r.targetId)})).catch(Tc)):(Gh(n,r.targetId),await tu(n.localStore,r.targetId,!0))}async function Vh(t,e){const n=Dr(t);try{const t=await function(t,e){const n=Dr(t),r=e.snapshotVersion;let i=n.qn;return n.persistence.runTransaction("Apply remote event","readwrite-primary",(t=>{const s=n.Qn.newChangeBuffer({trackRemovals:!0});i=n.qn;const o=[];e.targetChanges.forEach(((s,a)=>{const c=i.get(a);if(!c)return;o.push(n.He.removeMatchingKeys(t,s.removedDocuments,a).next((()=>n.He.addMatchingKeys(t,s.addedDocuments,a))));let u=c.withSequenceNumber(t.currentSequenceNumber);e.targetMismatches.has(a)?u=u.withResumeToken(ai.EMPTY_BYTE_STRING,Jr.min()).withLastLimboFreeSnapshotVersion(Jr.min()):s.resumeToken.approximateByteSize()>0&&(u=u.withResumeToken(s.resumeToken,r)),i=i.insert(a,u),function(t,e,n){return 0===t.resumeToken.approximateByteSize()||e.snapshotVersion.toMicroseconds()-t.snapshotVersion.toMicroseconds()>=3e8||n.addedDocuments.size+n.modifiedDocuments.size+n.removedDocuments.size>0}(c,u,s)&&o.push(n.He.updateTargetData(t,u))}));let a=co();if(e.documentUpdates.forEach(((r,i)=>{e.resolvedLimboDocuments.has(r)&&o.push(n.persistence.referenceDelegate.updateLimboDocument(t,r))})),o.push(Jc(t,s,e.documentUpdates,r,void 0).next((t=>{a=t}))),!r.isEqual(Jr.min())){const e=n.He.getLastRemoteSnapshotVersion(t).next((e=>n.He.setTargetsMetadata(t,t.currentSequenceNumber,r)));o.push(e)}return xa.waitFor(o).next((()=>s.apply(t))).next((()=>n.Wn.Vn(t,a))).next((()=>a))})).then((t=>(n.qn=i,t)))}(n.localStore,e);e.targetChanges.forEach(((t,e)=>{const r=n.Uo.get(e);r&&(xr(t.addedDocuments.size+t.modifiedDocuments.size+t.removedDocuments.size<=1),t.addedDocuments.size>0?r.$o=!0:t.modifiedDocuments.size>0?xr(r.$o):t.removedDocuments.size>0&&(xr(r.$o),r.$o=!1))})),await Jh(n,t,e)}catch(t){await Tc(t)}}function jh(t,e,n){const r=Dr(t);if(r.isPrimaryClient&&0===n||!r.isPrimaryClient&&1===n){const t=[];r.Fo.forEach(((n,r)=>{const i=r.view.ro(e);i.snapshot&&t.push(i.snapshot)})),function(t,e){const n=Dr(t);n.onlineState=e;let r=!1;n.queries.forEach(((t,n)=>{for(const t of n.listeners)t.ro(e)&&(r=!0)})),r&&Eh(n)}(r.eventManager,e),t.length&&r.Oo.br(t),r.onlineState=e,r.isPrimaryClient&&r.sharedClientState.setOnlineState(e)}}async function qh(t,e,n){const r=Dr(t);r.sharedClientState.updateQueryState(e,"rejected",n);const i=r.Uo.get(e),s=i&&i.key;if(s){let t=new no(vi.comparator);t=t.insert(s,Li.newNoDocument(s,Jr.min()));const n=mo().add(s),i=new vo(Jr.min(),new Map,new so(Hr),t,n);await Vh(r,i),r.Bo=r.Bo.remove(s),r.Uo.delete(e),Qh(r)}else await tu(r.localStore,e,!1).then((()=>Gh(r,e,n))).catch(Tc)}async function Bh(t,e){const n=Dr(t),r=e.batch.batchId;try{const t=await function(t,e){const n=Dr(t);return n.persistence.runTransaction("Acknowledge batch","readwrite-primary",(t=>{const r=e.batch.keys(),i=n.Qn.newChangeBuffer({trackRemovals:!0});return function(t,e,n,r){const i=n.batch,s=i.keys();let o=xa.resolve();return s.forEach((t=>{o=o.next((()=>r.getEntry(e,t))).next((e=>{const s=n.docVersions.get(t);xr(null!==s),e.version.compareTo(s)<0&&(i.applyToRemoteDocument(e,n),e.isValidDocument()&&r.addEntry(e,n.commitVersion))}))})),o.next((()=>t.An.removeMutationBatch(e,i)))}(n,t,e,i).next((()=>i.apply(t))).next((()=>n.An.performConsistencyCheck(t))).next((()=>n.Wn.vn(t,r)))}))}(n.localStore,e);Wh(n,r,null),Kh(n,r),n.sharedClientState.updateMutationState(r,"acknowledged"),await Jh(n,t)}catch(t){await Tc(t)}}async function zh(t,e,n){const r=Dr(t);try{const t=await function(t,e){const n=Dr(t);return n.persistence.runTransaction("Reject batch","readwrite-primary",(t=>{let r;return n.An.lookupMutationBatch(t,e).next((e=>(xr(null!==e),r=e.keys(),n.An.removeMutationBatch(t,e)))).next((()=>n.An.performConsistencyCheck(t))).next((()=>n.Wn.vn(t,r)))}))}(r.localStore,e);Wh(r,e,n),Kh(r,e),r.sharedClientState.updateMutationState(e,"rejected",n),await Jh(r,t)}catch(n){await Tc(n)}}function Kh(t,e){(t.jo.get(e)||[]).forEach((t=>{t.resolve()})),t.jo.delete(e)}function Wh(t,e,n){const r=Dr(t);let i=r.Ko[r.currentUser.toKey()];if(i){const t=i.get(e);t&&(n?t.reject(n):t.resolve(),i=i.remove(e)),r.Ko[r.currentUser.toKey()]=i}}function Gh(t,e,n=null){t.sharedClientState.removeLocalQueryTarget(e);for(const r of t.Mo.get(e))t.Fo.delete(r),n&&t.Oo.zo(r,n);t.Mo.delete(e),t.isPrimaryClient&&t.qo.us(e).forEach((e=>{t.qo.containsKey(e)||Hh(t,e)}))}function Hh(t,e){t.Lo.delete(e.path.canonicalString());const n=t.Bo.get(e);null!==n&&(zu(t.remoteStore,n),t.Bo=t.Bo.remove(e),t.Uo.delete(n),Qh(t))}function $h(t,e,n){for(const r of n)r instanceof Ch?(t.qo.addReference(r.key,e),Yh(t,r)):r instanceof Dh?(Er("SyncEngine","Document no longer in limbo: "+r.key),t.qo.removeReference(r.key,e),t.qo.containsKey(r.key)||Hh(t,r.key)):Nr()}function Yh(t,e){const n=e.key,r=n.path.canonicalString();t.Bo.get(n)||t.Lo.has(r)||(Er("SyncEngine","New document in limbo: "+n),t.Lo.add(r),Qh(t))}function Qh(t){for(;t.Lo.size>0&&t.Bo.size<t.maxConcurrentLimboResolutions;){const e=t.Lo.values().next().value;t.Lo.delete(e);const n=new vi(ni.fromString(e)),r=t.Qo.next();t.Uo.set(r,new Ph(n)),t.Bo=t.Bo.insert(n,r),Bu(t.remoteStore,new za(ls(is(n.path)),r,2,Kr.I))}}async function Jh(t,e,n){const r=Dr(t),i=[],s=[],o=[];r.Fo.isEmpty()||(r.Fo.forEach(((t,a)=>{o.push(r.Go(a,e,n).then((t=>{if(t){r.isPrimaryClient&&r.sharedClientState.updateQueryState(a.targetId,t.fromCache?"not-current":"current"),i.push(t);const e=Wc.$n(a.targetId,t);s.push(e)}})))})),await Promise.all(o),r.Oo.br(i),await async function(t,e){const n=Dr(t);try{await n.persistence.runTransaction("notifyLocalViewChanges","readwrite",(t=>xa.forEach(e,(e=>xa.forEach(e.kn,(r=>n.persistence.referenceDelegate.addReference(t,e.targetId,r))).next((()=>xa.forEach(e.xn,(r=>n.persistence.referenceDelegate.removeReference(t,e.targetId,r)))))))))}catch(t){if(!Pa(t))throw t;Er("LocalStore","Failed to update sequence numbers: "+t)}for(const t of e){const e=t.targetId;if(!t.fromCache){const t=n.qn.get(e),r=t.snapshotVersion,i=t.withLastLimboFreeSnapshotVersion(r);n.qn=n.qn.insert(e,i)}}}(r.localStore,s))}async function Zh(t,e){const n=Dr(t);if(!n.currentUser.isEqual(e)){Er("SyncEngine","User change. New user:",e.toKey());const t=await Yc(n.localStore,e);n.currentUser=e,function(t,e){t.jo.forEach((t=>{t.forEach((t=>{t.reject(new Rr(Or.CANCELLED,"'waitForPendingWrites' promise is rejected due to a user change."))}))})),t.jo.clear()}(n),n.sharedClientState.handleUserChange(e,t.removedBatchIds,t.addedBatchIds),await Jh(n,t.Gn)}}function Xh(t,e){const n=Dr(t),r=n.Uo.get(e);if(r&&r.$o)return mo().add(r.key);{let t=mo();const r=n.Mo.get(e);if(!r)return t;for(const e of r){const r=n.Fo.get(e);t=t.unionWith(r.view.bo)}return t}}async function tl(t,e){const n=Dr(t),r=await eu(n.localStore,e.query,!0),i=e.view.ko(r);return n.isPrimaryClient&&$h(n,e.targetId,i.Co),i}async function el(t){const e=Dr(t);return ru(e.localStore).then((t=>Jh(e,t)))}async function nl(t,e,n,r){const i=Dr(t),s=await function(t,e){const n=Dr(t),r=Dr(n.An);return n.persistence.runTransaction("Lookup mutation documents","readonly",(t=>r.Zt(t,e).next((e=>e?n.Wn.vn(t,e):xa.resolve(null)))))}(i.localStore,e);null!==s?("pending"===n?await eh(i.remoteStore):"acknowledged"===n||"rejected"===n?(Wh(i,e,r||null),Kh(i,e),function(t,e){Dr(Dr(t).An).ee(e)}(i.localStore,e)):Nr(),await Jh(i,s)):Er("SyncEngine","Cannot apply mutation batch with id: "+e)}async function rl(t,e,n){const r=Dr(t),i=[],s=[];for(const t of e){let e;const n=r.Mo.get(t);if(n&&0!==n.length){e=await Xc(r.localStore,ls(n[0]));for(const t of n){const e=r.Fo.get(t),n=await tl(r,e);n.snapshot&&s.push(n.snapshot)}}else{const n=await nu(r.localStore,t);e=await Xc(r.localStore,n),await Fh(r,il(n),t,!1)}i.push(e)}return r.Oo.br(s),i}function il(t){return rs(t.path,t.collectionGroup,t.orderBy,t.filters,t.limit,"F",t.startAt,t.endAt)}function sl(t){const e=Dr(t);return Dr(Dr(e.localStore).persistence).Tn()}async function ol(t,e,n,r){const i=Dr(t);if(i.Wo)Er("SyncEngine","Ignoring unexpected query state notification.");else if(i.Mo.has(e))switch(n){case"current":case"not-current":{const t=await ru(i.localStore),r=vo.createSynthesizedRemoteEventForCurrentChange(e,"current"===n);await Jh(i,t,r);break}case"rejected":await tu(i.localStore,e,!0),Gh(i,e,r);break;default:Nr()}}async function al(t,e,n){const r=cl(t);if(r.Wo){for(const t of e){if(r.Mo.has(t)){Er("SyncEngine","Adding an already active target "+t);continue}const e=await nu(r.localStore,t),n=await Xc(r.localStore,e);await Fh(r,il(e),n.targetId,!1),Bu(r.remoteStore,n)}for(const t of n)r.Mo.has(t)&&await tu(r.localStore,t,!1).then((()=>{zu(r.remoteStore,t),Gh(r,t)})).catch(Tc)}}function cl(t){const e=Dr(t);return e.remoteStore.remoteSyncer.applyRemoteEvent=Vh.bind(null,e),e.remoteStore.remoteSyncer.getRemoteKeysForTarget=Xh.bind(null,e),e.remoteStore.remoteSyncer.rejectListen=qh.bind(null,e),e.Oo.br=Th.bind(null,e.eventManager),e.Oo.zo=_h.bind(null,e.eventManager),e}function ul(t){const e=Dr(t);return e.remoteStore.remoteSyncer.applySuccessfulWrite=Bh.bind(null,e),e.remoteStore.remoteSyncer.rejectFailedWrite=zh.bind(null,e),e}class hl{constructor(){this.synchronizeTabs=!1}async initialize(t){this.k=Ou(t.databaseInfo.databaseId),this.sharedClientState=this.Jo(t),this.persistence=this.Yo(t),await this.persistence.start(),this.gcScheduler=this.Xo(t),this.localStore=this.Zo(t)}Xo(t){return null}Zo(t){return $c(this.persistence,new Gc,t.initialUser,this.k)}Yo(t){return new du(pu.ks,this.k)}Jo(t){return new Eu}async terminate(){this.gcScheduler&&this.gcScheduler.stop(),await this.sharedClientState.shutdown(),await this.persistence.shutdown()}}class ll extends hl{constructor(t,e,n){super(),this.ta=t,this.cacheSizeBytes=e,this.forceOwnership=n,this.synchronizeTabs=!1}async initialize(t){await super.initialize(t),await async function(t){const e=Dr(t);return e.persistence.runTransaction("Synchronize last document change read time","readonly",(t=>function(t){const e=Pc(t);let n=Jr.min();return e.jt({index:ya.readTimeIndex,reverse:!0},((t,e,r)=>{e.readTime&&(n=$a(e.readTime)),r.done()})).next((()=>n))}(t))).then((t=>{e.jn=t}))}(this.localStore),await this.ta.initialize(this,t),await ul(this.ta.syncEngine),await eh(this.ta.remoteStore),await this.persistence.sn((()=>(this.gcScheduler&&!this.gcScheduler.started&&this.gcScheduler.start(this.localStore),Promise.resolve())))}Zo(t){return $c(this.persistence,new Gc,t.initialUser,this.k)}Xo(t){const e=this.persistence.referenceDelegate.garbageCollector;return new Sc(e,t.asyncQueue)}Yo(t){const e=Bc(t.databaseInfo.databaseId,t.databaseInfo.persistenceKey),n=void 0!==this.cacheSizeBytes?uc.withCacheSize(this.cacheSizeBytes):uc.DEFAULT;return new Vc(this.synchronizeTabs,e,t.clientId,n,t.asyncQueue,Cu(),Du(),this.k,this.sharedClientState,!!this.forceOwnership)}Jo(t){return new Eu}}class dl extends ll{constructor(t,e){super(t,e,!1),this.ta=t,this.cacheSizeBytes=e,this.synchronizeTabs=!0}async initialize(t){await super.initialize(t);const e=this.ta.syncEngine;this.sharedClientState instanceof _u&&(this.sharedClientState.syncEngine={mi:nl.bind(null,e),gi:ol.bind(null,e),yi:al.bind(null,e),Tn:sl.bind(null,e),_i:el.bind(null,e)},await this.sharedClientState.start()),await this.persistence.sn((async t=>{await async function(t,e){const n=Dr(t);if(cl(n),ul(n),!0===e&&!0!==n.Wo){const t=n.sharedClientState.getAllActiveQueryTargets(),e=await rl(n,t.toArray());n.Wo=!0,await hh(n.remoteStore,!0);for(const t of e)Bu(n.remoteStore,t)}else if(!1===e&&!1!==n.Wo){const t=[];let e=Promise.resolve();n.Mo.forEach(((r,i)=>{n.sharedClientState.isLocalQueryTarget(i)?t.push(i):e=e.then((()=>(Gh(n,i),tu(n.localStore,i,!0)))),zu(n.remoteStore,i)})),await e,await rl(n,t),function(t){const e=Dr(t);e.Uo.forEach(((t,n)=>{zu(e.remoteStore,n)})),e.qo.hs(),e.Uo=new Map,e.Bo=new no(vi.comparator)}(n),n.Wo=!1,await hh(n.remoteStore,!1)}}(this.ta.syncEngine,t),this.gcScheduler&&(t&&!this.gcScheduler.started?this.gcScheduler.start(this.localStore):t||this.gcScheduler.stop())}))}Jo(t){const e=Cu();if(!_u.Pt(e))throw new Rr(Or.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");const n=Bc(t.databaseInfo.databaseId,t.databaseInfo.persistenceKey);return new _u(e,t.asyncQueue,n,t.clientId,t.initialUser)}}class fl{async initialize(t,e){this.localStore||(this.localStore=t.localStore,this.sharedClientState=t.sharedClientState,this.datastore=this.createDatastore(e),this.remoteStore=this.createRemoteStore(e),this.eventManager=this.createEventManager(e),this.syncEngine=this.createSyncEngine(e,!t.synchronizeTabs),this.sharedClientState.onlineStateHandler=t=>jh(this.syncEngine,t,1),this.remoteStore.remoteSyncer.handleCredentialChange=Zh.bind(null,this.syncEngine),await hh(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(t){return new bh}createDatastore(t){const e=Ou(t.databaseInfo.databaseId),n=(r=t.databaseInfo,new xu(r));var r;return function(t,e,n,r){return new Fu(t,e,n,r)}(t.authCredentials,t.appCheckCredentials,n,e)}createRemoteStore(t){return e=this.localStore,n=this.datastore,r=t.asyncQueue,i=t=>jh(this.syncEngine,t,0),s=ku.Pt()?new ku:new Su,new Vu(e,n,r,i,s);var e,n,r,i,s}createSyncEngine(t,e){return function(t,e,n,r,i,s,o){const a=new Lh(t,e,n,r,i,s);return o&&(a.Wo=!0),a}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,t.initialUser,t.maxConcurrentLimboResolutions,e)}terminate(){return async function(t){const e=Dr(t);Er("RemoteStore","RemoteStore shutting down."),e.Gr.add(5),await qu(e),e.Hr.shutdown(),e.Jr.set("Unknown")}(this.remoteStore)}}function pl(t,e=10240){let n=0;return{async read(){if(n<t.byteLength){const r={value:t.slice(n,n+e),done:!1};return n+=e,r}return{done:!0}},async cancel(){},releaseLock(){},closed:Promise.reject("unimplemented")}}class ml{constructor(t){this.observer=t,this.muted=!1}next(t){this.observer.next&&this.ea(this.observer.next,t)}error(t){this.observer.error?this.ea(this.observer.error,t):console.error("Uncaught Error in snapshot listener:",t)}na(){this.muted=!0}ea(t,e){this.muted||setTimeout((()=>{this.muted||t(e)}),0)}}class gl{constructor(t,e){this.sa=t,this.k=e,this.metadata=new Pr,this.buffer=new Uint8Array,this.ia=new TextDecoder("utf-8"),this.ra().then((t=>{t&&t._o()?this.metadata.resolve(t.payload.metadata):this.metadata.reject(new Error(`The first element of the bundle is not a metadata, it is\n ${JSON.stringify(null==t?void 0:t.payload)}`))}),(t=>this.metadata.reject(t)))}close(){return this.sa.cancel()}async getMetadata(){return this.metadata.promise}async Ho(){return await this.getMetadata(),this.ra()}async ra(){const t=await this.oa();if(null===t)return null;const e=this.ia.decode(t),n=Number(e);isNaN(n)&&this.aa(`length string (${e}) is not valid number`);const r=await this.ca(n);return new kh(JSON.parse(r),t.length+n)}ua(){return this.buffer.findIndex((t=>t==="{".charCodeAt(0)))}async oa(){for(;this.ua()<0&&!await this.ha(););if(0===this.buffer.length)return null;const t=this.ua();t<0&&this.aa("Reached the end of bundle when a length string is expected.");const e=this.buffer.slice(0,t);return this.buffer=this.buffer.slice(t),e}async ca(t){for(;this.buffer.length<t;)await this.ha()&&this.aa("Reached the end of bundle when more is expected.");const e=this.ia.decode(this.buffer.slice(0,t));return this.buffer=this.buffer.slice(t),e}aa(t){throw this.sa.cancel(),new Error(`Invalid bundle format: ${t}`)}async ha(){const t=await this.sa.read();if(!t.done){const e=new Uint8Array(this.buffer.length+t.value.length);e.set(this.buffer),e.set(t.value,this.buffer.length),this.buffer=e}return t.done}}class yl{constructor(t){this.datastore=t,this.readVersions=new Map,this.mutations=[],this.committed=!1,this.lastWriteError=null,this.writtenDocs=new Set}async lookup(t){if(this.ensureCommitNotCalled(),this.mutations.length>0)throw new Rr(Or.INVALID_ARGUMENT,"Firestore transactions require all reads to be executed before all writes.");const e=await async function(t,e){const n=Dr(t),r=jo(n.k)+"/documents",i={documents:e.map((t=>Mo(n.k,t)))},s=await n.ji("BatchGetDocuments",r,i),o=new Map;s.forEach((t=>{const e=function(t,e){return"found"in e?function(t,e){xr(!!e.found),e.found.name,e.found.updateTime;const n=Fo(t,e.found.name),r=Ro(e.found.updateTime),i=new Ri({mapValue:{fields:e.found.fields}});return Li.newFoundDocument(n,r,i)}(t,e):"missing"in e?function(t,e){xr(!!e.missing),xr(!!e.readTime);const n=Fo(t,e.missing),r=Ro(e.readTime);return Li.newNoDocument(n,r)}(t,e):Nr()}(n.k,t);o.set(e.key.toString(),e)}));const a=[];return e.forEach((t=>{const e=o.get(t.toString());xr(!!e),a.push(e)})),a}(this.datastore,t);return e.forEach((t=>this.recordVersion(t))),e}set(t,e){this.write(e.toMutation(t,this.precondition(t))),this.writtenDocs.add(t.toString())}update(t,e){try{this.write(e.toMutation(t,this.preconditionForUpdate(t)))}catch(t){this.lastWriteError=t}this.writtenDocs.add(t.toString())}delete(t){this.write(new Ys(t,this.precondition(t))),this.writtenDocs.add(t.toString())}async commit(){if(this.ensureCommitNotCalled(),this.lastWriteError)throw this.lastWriteError;const t=this.readVersions;this.mutations.forEach((e=>{t.delete(e.key.toString())})),t.forEach(((t,e)=>{const n=vi.fromPath(e);this.mutations.push(new Qs(n,this.precondition(n)))})),await async function(t,e){const n=Dr(t),r=jo(n.k)+"/documents",i={writes:e.map((t=>Ko(n.k,t)))};await n.Bi("Commit",r,i)}(this.datastore,this.mutations),this.committed=!0}recordVersion(t){let e;if(t.isFoundDocument())e=t.version;else{if(!t.isNoDocument())throw Nr();e=Jr.min()}const n=this.readVersions.get(t.key.toString());if(n){if(!e.isEqual(n))throw new Rr(Or.ABORTED,"Document version changed between two reads.")}else this.readVersions.set(t.key.toString(),e)}precondition(t){const e=this.readVersions.get(t.toString());return!this.writtenDocs.has(t.toString())&&e?Ms.updateTime(e):Ms.none()}preconditionForUpdate(t){const e=this.readVersions.get(t.toString());if(!this.writtenDocs.has(t.toString())&&e){if(e.isEqual(Jr.min()))throw new Rr(Or.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return Ms.updateTime(e)}return Ms.exists(!0)}write(t){this.ensureCommitNotCalled(),this.mutations.push(t)}ensureCommitNotCalled(){}}class vl{constructor(t,e,n,r){this.asyncQueue=t,this.datastore=e,this.updateFunction=n,this.deferred=r,this.la=5,this.ur=new Ru(this.asyncQueue,"transaction_retry")}run(){this.la-=1,this.fa()}fa(){this.ur.Zi((async()=>{const t=new yl(this.datastore),e=this.da(t);e&&e.then((e=>{this.asyncQueue.enqueueAndForget((()=>t.commit().then((()=>{this.deferred.resolve(e)})).catch((t=>{this.wa(t)}))))})).catch((t=>{this.wa(t)}))}))}da(t){try{const e=this.updateFunction(t);return!mi(e)&&e.catch&&e.then?e:(this.deferred.reject(Error("Transaction callback must return a Promise")),null)}catch(t){return this.deferred.reject(t),null}}wa(t){this.la>0&&this._a(t)?(this.la-=1,this.asyncQueue.enqueueAndForget((()=>(this.fa(),Promise.resolve())))):this.deferred.reject(t)}_a(t){if("FirebaseError"===t.name){const e=t.code;return"aborted"===e||"failed-precondition"===e||!to(e)}return!1}}class bl{constructor(t,e,n,r){this.authCredentials=t,this.appCheckCredentials=e,this.asyncQueue=n,this.databaseInfo=r,this.user=br.UNAUTHENTICATED,this.clientId=Gr.A(),this.authCredentialListener=()=>Promise.resolve(),this.authCredentials.start(n,(async t=>{Er("FirestoreClient","Received user=",t.uid),await this.authCredentialListener(t),this.user=t})),this.appCheckCredentials.start(n,(()=>Promise.resolve()))}async getConfiguration(){return{asyncQueue:this.asyncQueue,databaseInfo:this.databaseInfo,clientId:this.clientId,authCredentials:this.authCredentials,appCheckCredentials:this.appCheckCredentials,initialUser:this.user,maxConcurrentLimboResolutions:100}}setCredentialChangeListener(t){this.authCredentialListener=t}verifyNotTerminated(){if(this.asyncQueue.isShuttingDown)throw new Rr(Or.FAILED_PRECONDITION,"The client has already been terminated.")}terminate(){this.asyncQueue.enterRestrictedMode();const t=new Pr;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted((async()=>{try{this.onlineComponents&&await this.onlineComponents.terminate(),this.offlineComponents&&await this.offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),t.resolve()}catch(e){const n=ph(e,"Failed to shutdown persistence");t.reject(n)}})),t.promise}}async function wl(t,e){t.asyncQueue.verifyOperationInProgress(),Er("FirestoreClient","Initializing OfflineComponentProvider");const n=await t.getConfiguration();await e.initialize(n);let r=n.initialUser;t.setCredentialChangeListener((async t=>{r.isEqual(t)||(await Yc(e.localStore,t),r=t)})),e.persistence.setDatabaseDeletedListener((()=>t.terminate())),t.offlineComponents=e}async function Il(t,e){t.asyncQueue.verifyOperationInProgress();const n=await Tl(t);Er("FirestoreClient","Initializing OnlineComponentProvider");const r=await t.getConfiguration();await e.initialize(n,r),t.setCredentialChangeListener((t=>async function(t,e){const n=Dr(t);n.asyncQueue.verifyOperationInProgress(),Er("RemoteStore","RemoteStore received new credentials");const r=$u(n);n.Gr.add(3),await qu(n),r&&n.Jr.set("Unknown"),await n.remoteSyncer.handleCredentialChange(e),n.Gr.delete(3),await ju(n)}(e.remoteStore,t))),t.onlineComponents=e}async function Tl(t){return t.offlineComponents||(Er("FirestoreClient","Using default OfflineComponentProvider"),await wl(t,new hl)),t.offlineComponents}async function _l(t){return t.onlineComponents||(Er("FirestoreClient","Using default OnlineComponentProvider"),await Il(t,new fl)),t.onlineComponents}function El(t){return Tl(t).then((t=>t.persistence))}function Sl(t){return Tl(t).then((t=>t.localStore))}function kl(t){return _l(t).then((t=>t.remoteStore))}function Al(t){return _l(t).then((t=>t.syncEngine))}async function Nl(t){const e=await _l(t),n=e.eventManager;return n.onListen=Mh.bind(null,e.syncEngine),n.onUnlisten=Uh.bind(null,e.syncEngine),n}function xl(t,e,n={}){const r=new Pr;return t.asyncQueue.enqueueAndForget((async()=>function(t,e,n,r,i){const s=new ml({next:s=>{e.enqueueAndForget((()=>Ih(t,o)));const a=s.docs.has(n);!a&&s.fromCache?i.reject(new Rr(Or.UNAVAILABLE,"Failed to get document because the client is offline.")):a&&s.fromCache&&r&&"server"===r.source?i.reject(new Rr(Or.UNAVAILABLE,'Failed to get document from server. (However, this document does exist in the local cache. Run again without setting source to "server" to retrieve the cached document.)')):i.resolve(s)},error:t=>i.reject(t)}),o=new Sh(is(n.path),s,{includeMetadataChanges:!0,wo:!0});return wh(t,o)}(await Nl(t),t.asyncQueue,e,n,r))),r.promise}function Cl(t,e,n={}){const r=new Pr;return t.asyncQueue.enqueueAndForget((async()=>function(t,e,n,r,i){const s=new ml({next:n=>{e.enqueueAndForget((()=>Ih(t,o))),n.fromCache&&"server"===r.source?i.reject(new Rr(Or.UNAVAILABLE,'Failed to get documents from server. (However, these documents may exist in the local cache. Run again without setting source to "server" to retrieve the cached documents.)')):i.resolve(n)},error:t=>i.reject(t)}),o=new Sh(n,s,{includeMetadataChanges:!0,wo:!0});return wh(t,o)}(await Nl(t),t.asyncQueue,e,n,r))),r.promise}class Dl{constructor(t,e,n,r,i,s,o,a){this.databaseId=t,this.appId=e,this.persistenceKey=n,this.host=r,this.ssl=i,this.forceLongPolling=s,this.autoDetectLongPolling=o,this.useFetchStreams=a}}class Ol{constructor(t,e){this.projectId=t,this.database=e||"(default)"}get isDefaultDatabase(){return"(default)"===this.database}isEqual(t){return t instanceof Ol&&t.projectId===this.projectId&&t.database===this.database}}const Rl=new Map;function Pl(t,e,n){if(!n)throw new Rr(Or.INVALID_ARGUMENT,`Function ${t}() cannot be called with an empty ${e}.`)}function Ll(t,e,n,r){if(!0===e&&!0===r)throw new Rr(Or.INVALID_ARGUMENT,`${t} and ${n} cannot be used together.`)}function Ml(t){if(!vi.isDocumentKey(t))throw new Rr(Or.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${t} has ${t.length}.`)}function Fl(t){if(vi.isDocumentKey(t))throw new Rr(Or.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${t} has ${t.length}.`)}function Ul(t){if(void 0===t)return"undefined";if(null===t)return"null";if("string"==typeof t)return t.length>20&&(t=`${t.substring(0,20)}...`),JSON.stringify(t);if("number"==typeof t||"boolean"==typeof t)return""+t;if("object"==typeof t){if(t instanceof Array)return"an array";{const e=function(t){return t.constructor?t.constructor.name:null}(t);return e?`a custom ${e} object`:"an object"}}return"function"==typeof t?"a function":Nr()}function Vl(t,e){if("_delegate"in t&&(t=t._delegate),!(t instanceof e)){if(e.name===t.constructor.name)throw new Rr(Or.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{const n=Ul(t);throw new Rr(Or.INVALID_ARGUMENT,`Expected type '${e.name}', but it was: ${n}`)}}return t}function jl(t,e){if(e<=0)throw new Rr(Or.INVALID_ARGUMENT,`Function ${t}() requires a positive number, but it was: ${e}.`)}class ql{constructor(t){var e;if(void 0===t.host){if(void 0!==t.ssl)throw new Rr(Or.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===(e=t.ssl)||void 0===e||e;if(this.credentials=t.credentials,this.ignoreUndefinedProperties=!!t.ignoreUndefinedProperties,void 0===t.cacheSizeBytes)this.cacheSizeBytes=41943040;else{if(-1!==t.cacheSizeBytes&&t.cacheSizeBytes<1048576)throw new Rr(Or.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=t.cacheSizeBytes}this.experimentalForceLongPolling=!!t.experimentalForceLongPolling,this.experimentalAutoDetectLongPolling=!!t.experimentalAutoDetectLongPolling,this.useFetchStreams=!!t.useFetchStreams,Ll("experimentalForceLongPolling",t.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",t.experimentalAutoDetectLongPolling)}isEqual(t){return this.host===t.host&&this.ssl===t.ssl&&this.credentials===t.credentials&&this.cacheSizeBytes===t.cacheSizeBytes&&this.experimentalForceLongPolling===t.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===t.experimentalAutoDetectLongPolling&&this.ignoreUndefinedProperties===t.ignoreUndefinedProperties&&this.useFetchStreams===t.useFetchStreams}}class Bl{constructor(t,e,n){this._authCredentials=e,this._appCheckCredentials=n,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new ql({}),this._settingsFrozen=!1,t instanceof Ol?this._databaseId=t:(this._app=t,this._databaseId=function(t){if(!Object.prototype.hasOwnProperty.apply(t.options,["projectId"]))throw new Rr(Or.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new Ol(t.options.projectId)}(t))}get app(){if(!this._app)throw new Rr(Or.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app}get _initialized(){return this._settingsFrozen}get _terminated(){return void 0!==this._terminateTask}_setSettings(t){if(this._settingsFrozen)throw new Rr(Or.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 ql(t),void 0!==t.credentials&&(this._authCredentials=function(t){if(!t)return new Mr;switch(t.type){case"gapi":const e=t.client;return xr(!("object"!=typeof e||null===e||!e.auth||!e.auth.getAuthHeaderValueForFirstParty)),new jr(e,t.sessionIndex||"0",t.iamToken||null);case"provider":return t.client;default:throw new Rr(Or.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invalid credential type")}}(t.credentials))}_getSettings(){return this._settings}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return this._terminateTask||(this._terminateTask=this._terminate()),this._terminateTask}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return function(t){const e=Rl.get(t);e&&(Er("ComponentProvider","Removing Datastore"),Rl.delete(t),e.terminate())}(this),Promise.resolve()}}function zl(t,e,n,r={}){var i;const s=(t=Vl(t,Bl))._getSettings();if("firestore.googleapis.com"!==s.host&&s.host!==e&&kr("Host has been set in both settings() and useEmulator(), emulator host will be used"),t._setSettings(Object.assign(Object.assign({},s),{host:`${e}:${n}`,ssl:!1})),r.mockUserToken){let e,n;if("string"==typeof r.mockUserToken)e=r.mockUserToken,n=br.MOCK_USER;else{e=(0,a.Sg)(r.mockUserToken,null===(i=t._app)||void 0===i?void 0:i.options.projectId);const s=r.mockUserToken.sub||r.mockUserToken.user_id;if(!s)throw new Rr(Or.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");n=new br(s)}t._authCredentials=new Fr(new Lr(e,n))}}class Kl{constructor(t,e,n){this.converter=e,this._key=n,this.type="document",this.firestore=t}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new Gl(this.firestore,this.converter,this._key.path.popLast())}withConverter(t){return new Kl(this.firestore,t,this._key)}}class Wl{constructor(t,e,n){this.converter=e,this._query=n,this.type="query",this.firestore=t}withConverter(t){return new Wl(this.firestore,t,this._query)}}class Gl extends Wl{constructor(t,e,n){super(t,e,is(n)),this._path=n,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){const t=this._path.popLast();return t.isEmpty()?null:new Kl(this.firestore,null,new vi(t))}withConverter(t){return new Gl(this.firestore,t,this._path)}}function Hl(t,e,...n){if(t=(0,a.m9)(t),Pl("collection","path",e),t instanceof Bl){const r=ni.fromString(e,...n);return Fl(r),new Gl(t,null,r)}{if(!(t instanceof Kl||t instanceof Gl))throw new Rr(Or.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=t._path.child(ni.fromString(e,...n));return Fl(r),new Gl(t.firestore,null,r)}}function $l(t,e){if(t=Vl(t,Bl),Pl("collectionGroup","collection id",e),e.indexOf("/")>=0)throw new Rr(Or.INVALID_ARGUMENT,`Invalid collection ID '${e}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);return new Wl(t,null,function(t){return new ns(ni.emptyPath(),t)}(e))}function Yl(t,e,...n){if(t=(0,a.m9)(t),1===arguments.length&&(e=Gr.A()),Pl("doc","path",e),t instanceof Bl){const r=ni.fromString(e,...n);return Ml(r),new Kl(t,null,new vi(r))}{if(!(t instanceof Kl||t instanceof Gl))throw new Rr(Or.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=t._path.child(ni.fromString(e,...n));return Ml(r),new Kl(t.firestore,t instanceof Gl?t.converter:null,new vi(r))}}function Ql(t,e){return t=(0,a.m9)(t),e=(0,a.m9)(e),(t instanceof Kl||t instanceof Gl)&&(e instanceof Kl||e instanceof Gl)&&t.firestore===e.firestore&&t.path===e.path&&t.converter===e.converter}function Jl(t,e){return t=(0,a.m9)(t),e=(0,a.m9)(e),t instanceof Wl&&e instanceof Wl&&t.firestore===e.firestore&&fs(t._query,e._query)&&t.converter===e.converter}class Zl{constructor(){this.ma=Promise.resolve(),this.ga=[],this.ya=!1,this.pa=[],this.Ta=null,this.Ea=!1,this.Ia=!1,this.Aa=[],this.ur=new Ru(this,"async_queue_retry"),this.Ra=()=>{const t=Du();t&&Er("AsyncQueue","Visibility state changed to "+t.visibilityState),this.ur.er()};const t=Du();t&&"function"==typeof t.addEventListener&&t.addEventListener("visibilitychange",this.Ra)}get isShuttingDown(){return this.ya}enqueueAndForget(t){this.enqueue(t)}enqueueAndForgetEvenWhileRestricted(t){this.ba(),this.Pa(t)}enterRestrictedMode(t){if(!this.ya){this.ya=!0,this.Ia=t||!1;const e=Du();e&&"function"==typeof e.removeEventListener&&e.removeEventListener("visibilitychange",this.Ra)}}enqueue(t){if(this.ba(),this.ya)return new Promise((()=>{}));const e=new Pr;return this.Pa((()=>this.ya&&this.Ia?Promise.resolve():(t().then(e.resolve,e.reject),e.promise))).then((()=>e.promise))}enqueueRetryable(t){this.enqueueAndForget((()=>(this.ga.push(t),this.va())))}async va(){if(0!==this.ga.length){try{await this.ga[0](),this.ga.shift(),this.ur.reset()}catch(t){if(!Pa(t))throw t;Er("AsyncQueue","Operation failed with retryable error: "+t)}this.ga.length>0&&this.ur.Zi((()=>this.va()))}}Pa(t){const e=this.ma.then((()=>(this.Ea=!0,t().catch((t=>{this.Ta=t,this.Ea=!1;const e=function(t){let e=t.message||"";return t.stack&&(e=t.stack.includes(t.message)?t.stack:t.message+"\n"+t.stack),e}(t);throw Sr("INTERNAL UNHANDLED ERROR: ",e),t})).then((t=>(this.Ea=!1,t))))));return this.ma=e,e}enqueueAfterDelay(t,e,n){this.ba(),this.Aa.indexOf(t)>-1&&(e=0);const r=fh.createAndSchedule(this,t,e,n,(t=>this.Va(t)));return this.pa.push(r),r}ba(){this.Ta&&Nr()}verifyOperationInProgress(){}async Sa(){let t;do{t=this.ma,await t}while(t!==this.ma)}Da(t){for(const e of this.pa)if(e.timerId===t)return!0;return!1}Ca(t){return this.Sa().then((()=>{this.pa.sort(((t,e)=>t.targetTimeMs-e.targetTimeMs));for(const e of this.pa)if(e.skipDelay(),"all"!==t&&e.timerId===t)break;return this.Sa()}))}Na(t){this.Aa.push(t)}Va(t){const e=this.pa.indexOf(t);this.pa.splice(e,1)}}function Xl(t){return function(t,e){if("object"!=typeof t||null===t)return!1;const n=t;for(const t of["next","error","complete"])if(t in n&&"function"==typeof n[t])return!0;return!1}(t)}class td{constructor(){this._progressObserver={},this._taskCompletionResolver=new Pr,this._lastProgress={taskState:"Running",totalBytes:0,totalDocuments:0,bytesLoaded:0,documentsLoaded:0}}onProgress(t,e,n){this._progressObserver={next:t,error:e,complete:n}}catch(t){return this._taskCompletionResolver.promise.catch(t)}then(t,e){return this._taskCompletionResolver.promise.then(t,e)}_completeWith(t){this._updateProgress(t),this._progressObserver.complete&&this._progressObserver.complete(),this._taskCompletionResolver.resolve(t)}_failWith(t){this._lastProgress.taskState="Error",this._progressObserver.next&&this._progressObserver.next(this._lastProgress),this._progressObserver.error&&this._progressObserver.error(t),this._taskCompletionResolver.reject(t)}_updateProgress(t){this._lastProgress=t,this._progressObserver.next&&this._progressObserver.next(t)}}const ed=-1;class nd extends Bl{constructor(t,e,n){super(t,e,n),this.type="firestore",this._queue=new Zl,this._persistenceKey="name"in t?t.name:"[DEFAULT]"}_terminate(){return this._firestoreClient||od(this),this._firestoreClient.terminate()}}function rd(t,e){const n=(0,i.qX)(t,"firestore");if(n.isInitialized()){const t=n.getImmediate(),r=n.getOptions();if((0,a.vZ)(r,e))return t;throw new Rr(Or.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!==e.cacheSizeBytes&&-1!==e.cacheSizeBytes&&e.cacheSizeBytes<1048576)throw new Rr(Or.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");return n.initialize({options:e})}function id(t=(0,i.Mq)()){return(0,i.qX)(t,"firestore").getImmediate()}function sd(t){return t._firestoreClient||od(t),t._firestoreClient.verifyNotTerminated(),t._firestoreClient}function od(t){var e;const n=t._freezeSettings(),r=function(t,e,n,r){return new Dl(t,e,n,r.host,r.ssl,r.experimentalForceLongPolling,r.experimentalAutoDetectLongPolling,r.useFetchStreams)}(t._databaseId,(null===(e=t._app)||void 0===e?void 0:e.options.appId)||"",t._persistenceKey,n);t._firestoreClient=new bl(t._authCredentials,t._appCheckCredentials,t._queue,r)}function ad(t,e){yd(t=Vl(t,nd));const n=sd(t),r=t._freezeSettings(),i=new fl;return ud(n,i,new ll(i,r.cacheSizeBytes,null==e?void 0:e.forceOwnership))}function cd(t){yd(t=Vl(t,nd));const e=sd(t),n=t._freezeSettings(),r=new fl;return ud(e,r,new dl(r,n.cacheSizeBytes))}function ud(t,e,n){const r=new Pr;return t.asyncQueue.enqueue((async()=>{try{await wl(t,n),await Il(t,e),r.resolve()}catch(t){if(!function(t){return"FirebaseError"===t.name?t.code===Or.FAILED_PRECONDITION||t.code===Or.UNIMPLEMENTED:!("undefined"!=typeof DOMException&&t instanceof DOMException)||22===t.code||20===t.code||11===t.code}(t))throw t;console.warn("Error enabling offline persistence. Falling back to persistence disabled: "+t),r.reject(t)}})).then((()=>r.promise))}function hd(t){if(t._initialized&&!t._terminated)throw new Rr(Or.FAILED_PRECONDITION,"Persistence can only be cleared before a Firestore instance is initialized or after it is terminated.");const e=new Pr;return t._queue.enqueueAndForgetEvenWhileRestricted((async()=>{try{await async function(t){if(!Da.Pt())return Promise.resolve();const e=t+"main";await Da.delete(e)}(Bc(t._databaseId,t._persistenceKey)),e.resolve()}catch(t){e.reject(t)}})),e.promise}function ld(t){return function(t){const e=new Pr;return t.asyncQueue.enqueueAndForget((async()=>async function(t,e){const n=Dr(t);$u(n.remoteStore)||Er("SyncEngine","The network is disabled. The task returned by 'awaitPendingWrites()' will not complete until the network is enabled.");try{const t=await function(t){const e=Dr(t);return e.persistence.runTransaction("Get highest unacknowledged batch id","readonly",(t=>e.An.getHighestUnacknowledgedBatchId(t)))}(n.localStore);if(-1===t)return void e.resolve();const r=n.jo.get(t)||[];r.push(e),n.jo.set(t,r)}catch(t){const n=ph(t,"Initialization of waitForPendingWrites() operation failed");e.reject(n)}}(await Al(t),e))),e.promise}(sd(t=Vl(t,nd)))}function dd(t){return function(t){return t.asyncQueue.enqueue((async()=>{const e=await El(t),n=await kl(t);return e.setNetworkEnabled(!0),function(t){const e=Dr(t);return e.Gr.delete(0),ju(e)}(n)}))}(sd(t=Vl(t,nd)))}function fd(t){return function(t){return t.asyncQueue.enqueue((async()=>{const e=await El(t),n=await kl(t);return e.setNetworkEnabled(!1),async function(t){const e=Dr(t);e.Gr.add(0),await qu(e),e.Jr.set("Offline")}(n)}))}(sd(t=Vl(t,nd)))}function pd(t){return(0,i.wN)(t.app,"firestore"),t._delete()}function md(t,e){const n=sd(t=Vl(t,nd)),r=new td;return function(t,e,n,r){const i=function(t,e){let n;return n="string"==typeof t?(new TextEncoder).encode(t):t,function(t,e){return new gl(t,e)}(function(t,e){if(t instanceof Uint8Array)return pl(t,e);if(t instanceof ArrayBuffer)return pl(new Uint8Array(t),e);if(t instanceof ReadableStream)return t.getReader();throw new Error("Source of `toByteStreamReader` has to be a ArrayBuffer or ReadableStream")}(n),e)}(n,Ou(e));t.asyncQueue.enqueueAndForget((async()=>{!function(t,e,n){const r=Dr(t);(async function(t,e,n){try{const r=await e.getMetadata();if(await function(t,e){const n=Dr(t),r=Ro(e.createTime);return n.persistence.runTransaction("hasNewerBundle","readonly",(t=>n.Ye.getBundleMetadata(t,e.id))).then((t=>!!t&&t.createTime.compareTo(r)>=0))}(t.localStore,r))return await e.close(),void n._completeWith(function(t){return{taskState:"Success",documentsLoaded:t.totalDocuments,bytesLoaded:t.totalBytes,totalDocuments:t.totalDocuments,totalBytes:t.totalBytes}}(r));n._updateProgress(xh(r));const i=new Nh(r,t.localStore,e.k);let s=await e.Ho();for(;s;){const t=await i.yo(s);t&&n._updateProgress(t),s=await e.Ho()}const o=await i.complete();await Jh(t,o.In,void 0),await function(t,e){const n=Dr(t);return n.persistence.runTransaction("Save bundle","readwrite",(t=>n.Ye.saveBundleMetadata(t,e)))}(t.localStore,r),n._completeWith(o.progress)}catch(t){kr("SyncEngine",`Loading bundle failed with ${t}`),n._failWith(t)}})(r,e,n).then((()=>{r.sharedClientState.notifyBundleLoaded()}))}(await Al(t),i,r)}))}(n,t._databaseId,e,r),r}function gd(t,e){return function(t,e){return t.asyncQueue.enqueue((async()=>function(t,e){const n=Dr(t);return n.persistence.runTransaction("Get named query","readonly",(t=>n.Ye.getNamedQuery(t,e)))}(await Sl(t),e)))}(sd(t=Vl(t,nd)),e).then((e=>e?new Wl(t,null,e.query):null))}function yd(t){if(t._initialized||t._terminated)throw new Rr(Or.FAILED_PRECONDITION,"Firestore has already been started and persistence can no longer be enabled. You can only enable persistence before calling any other methods on a Firestore object.")}class vd{constructor(...t){for(let e=0;e<t.length;++e)if(0===t[e].length)throw new Rr(Or.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new ii(t)}isEqual(t){return this._internalPath.isEqual(t._internalPath)}}function bd(){return new vd("__name__")}class wd{constructor(t){this._byteString=t}static fromBase64String(t){try{return new wd(ai.fromBase64String(t))}catch(t){throw new Rr(Or.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+t)}}static fromUint8Array(t){return new wd(ai.fromUint8Array(t))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(t){return this._byteString.isEqual(t._byteString)}}class Id{constructor(t){this._methodName=t}}class Td{constructor(t,e){if(!isFinite(t)||t<-90||t>90)throw new Rr(Or.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+t);if(!isFinite(e)||e<-180||e>180)throw new Rr(Or.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+e);this._lat=t,this._long=e}get latitude(){return this._lat}get longitude(){return this._long}isEqual(t){return this._lat===t._lat&&this._long===t._long}toJSON(){return{latitude:this._lat,longitude:this._long}}_compareTo(t){return Hr(this._lat,t._lat)||Hr(this._long,t._long)}}const _d=/^__.*__$/;class Ed{constructor(t,e,n){this.data=t,this.fieldMask=e,this.fieldTransforms=n}toMutation(t,e){return null!==this.fieldMask?new Ws(t,this.data,this.fieldMask,e,this.fieldTransforms):new Ks(t,this.data,e,this.fieldTransforms)}}class Sd{constructor(t,e,n){this.data=t,this.fieldMask=e,this.fieldTransforms=n}toMutation(t,e){return new Ws(t,this.data,this.fieldMask,e,this.fieldTransforms)}}function kd(t){switch(t){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw Nr()}}class Ad{constructor(t,e,n,r,i,s){this.settings=t,this.databaseId=e,this.k=n,this.ignoreUndefinedProperties=r,void 0===i&&this.ka(),this.fieldTransforms=i||[],this.fieldMask=s||[]}get path(){return this.settings.path}get xa(){return this.settings.xa}$a(t){return new Ad(Object.assign(Object.assign({},this.settings),t),this.databaseId,this.k,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}Oa(t){var e;const n=null===(e=this.path)||void 0===e?void 0:e.child(t),r=this.$a({path:n,Fa:!1});return r.Ma(t),r}La(t){var e;const n=null===(e=this.path)||void 0===e?void 0:e.child(t),r=this.$a({path:n,Fa:!1});return r.ka(),r}Ba(t){return this.$a({path:void 0,Fa:!0})}Ua(t){return Hd(t,this.settings.methodName,this.settings.qa||!1,this.path,this.settings.Ka)}contains(t){return void 0!==this.fieldMask.find((e=>t.isPrefixOf(e)))||void 0!==this.fieldTransforms.find((e=>t.isPrefixOf(e.field)))}ka(){if(this.path)for(let t=0;t<this.path.length;t++)this.Ma(this.path.get(t))}Ma(t){if(0===t.length)throw this.Ua("Document fields must not be empty");if(kd(this.xa)&&_d.test(t))throw this.Ua('Document fields cannot begin and end with "__"')}}class Nd{constructor(t,e,n){this.databaseId=t,this.ignoreUndefinedProperties=e,this.k=n||Ou(t)}ja(t,e,n,r=!1){return new Ad({xa:t,methodName:e,Ka:n,path:ii.emptyPath(),Fa:!1,qa:r},this.databaseId,this.k,this.ignoreUndefinedProperties)}}function xd(t){const e=t._freezeSettings(),n=Ou(t._databaseId);return new Nd(t._databaseId,!!e.ignoreUndefinedProperties,n)}function Cd(t,e,n,r,i,s={}){const o=t.ja(s.merge||s.mergeFields?2:0,e,n,i);zd("Data must be an object, but it was:",o,r);const a=qd(r,o);let c,u;if(s.merge)c=new si(o.fieldMask),u=o.fieldTransforms;else if(s.mergeFields){const t=[];for(const r of s.mergeFields){const i=Kd(e,r,n);if(!o.contains(i))throw new Rr(Or.INVALID_ARGUMENT,`Field '${i}' is specified in your field mask but missing from your input data.`);$d(t,i)||t.push(i)}c=new si(t),u=o.fieldTransforms.filter((t=>c.covers(t.field)))}else c=null,u=o.fieldTransforms;return new Ed(new Ri(a),c,u)}class Dd extends Id{_toFieldTransform(t){if(2!==t.xa)throw 1===t.xa?t.Ua(`${this._methodName}() can only appear at the top level of your update data`):t.Ua(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return t.fieldMask.push(t.path),null}isEqual(t){return t instanceof Dd}}function Od(t,e,n){return new Ad({xa:3,Ka:e.settings.Ka,methodName:t._methodName,Fa:n},e.databaseId,e.k,e.ignoreUndefinedProperties)}class Rd extends Id{_toFieldTransform(t){return new Ps(t.path,new ks)}isEqual(t){return t instanceof Rd}}class Pd extends Id{constructor(t,e){super(t),this.Qa=e}_toFieldTransform(t){const e=Od(this,t,!0),n=this.Qa.map((t=>jd(t,e))),r=new As(n);return new Ps(t.path,r)}isEqual(t){return this===t}}class Ld extends Id{constructor(t,e){super(t),this.Qa=e}_toFieldTransform(t){const e=Od(this,t,!0),n=this.Qa.map((t=>jd(t,e))),r=new xs(n);return new Ps(t.path,r)}isEqual(t){return this===t}}class Md extends Id{constructor(t,e){super(t),this.Wa=e}_toFieldTransform(t){const e=new Ds(t.k,Is(t.k,this.Wa));return new Ps(t.path,e)}isEqual(t){return this===t}}function Fd(t,e,n,r){const i=t.ja(1,e,n);zd("Data must be an object, but it was:",i,r);const s=[],o=Ri.empty();Xr(r,((t,r)=>{const c=Gd(e,t,n);r=(0,a.m9)(r);const u=i.La(c);if(r instanceof Dd)s.push(c);else{const t=jd(r,u);null!=t&&(s.push(c),o.set(c,t))}}));const c=new si(s);return new Sd(o,c,i.fieldTransforms)}function Ud(t,e,n,r,i,s){const o=t.ja(1,e,n),c=[Kd(e,r,n)],u=[i];if(s.length%2!=0)throw new Rr(Or.INVALID_ARGUMENT,`Function ${e}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let t=0;t<s.length;t+=2)c.push(Kd(e,s[t])),u.push(s[t+1]);const h=[],l=Ri.empty();for(let t=c.length-1;t>=0;--t)if(!$d(h,c[t])){const e=c[t];let n=u[t];n=(0,a.m9)(n);const r=o.La(e);if(n instanceof Dd)h.push(e);else{const t=jd(n,r);null!=t&&(h.push(e),l.set(e,t))}}const d=new si(h);return new Sd(l,d,o.fieldTransforms)}function Vd(t,e,n,r=!1){return jd(n,t.ja(r?4:3,e))}function jd(t,e){if(Bd(t=(0,a.m9)(t)))return zd("Unsupported field value:",e,t),qd(t,e);if(t instanceof Id)return function(t,e){if(!kd(e.xa))throw e.Ua(`${t._methodName}() can only be used with update() and set()`);if(!e.path)throw e.Ua(`${t._methodName}() is not currently supported inside arrays`);const n=t._toFieldTransform(e);n&&e.fieldTransforms.push(n)}(t,e),null;if(void 0===t&&e.ignoreUndefinedProperties)return null;if(e.path&&e.fieldMask.push(e.path),t instanceof Array){if(e.settings.Fa&&4!==e.xa)throw e.Ua("Nested arrays are not supported");return function(t,e){const n=[];let r=0;for(const i of t){let t=jd(i,e.Ba(r));null==t&&(t={nullValue:"NULL_VALUE"}),n.push(t),r++}return{arrayValue:{values:n}}}(t,e)}return function(t,e){if(null===(t=(0,a.m9)(t)))return{nullValue:"NULL_VALUE"};if("number"==typeof t)return Is(e.k,t);if("boolean"==typeof t)return{booleanValue:t};if("string"==typeof t)return{stringValue:t};if(t instanceof Date){const n=Qr.fromDate(t);return{timestampValue:Co(e.k,n)}}if(t instanceof Qr){const n=new Qr(t.seconds,1e3*Math.floor(t.nanoseconds/1e3));return{timestampValue:Co(e.k,n)}}if(t instanceof Td)return{geoPointValue:{latitude:t.latitude,longitude:t.longitude}};if(t instanceof wd)return{bytesValue:Do(e.k,t._byteString)};if(t instanceof Kl){const n=e.databaseId,r=t.firestore._databaseId;if(!r.isEqual(n))throw e.Ua(`Document reference is for database ${r.projectId}/${r.database} but should be for database ${n.projectId}/${n.database}`);return{referenceValue:Po(t.firestore._databaseId||e.databaseId,t._key.path)}}throw e.Ua(`Unsupported field value: ${Ul(t)}`)}(t,e)}function qd(t,e){const n={};return ti(t)?e.path&&e.path.length>0&&e.fieldMask.push(e.path):Xr(t,((t,r)=>{const i=jd(r,e.Oa(t));null!=i&&(n[t]=i)})),{mapValue:{fields:n}}}function Bd(t){return!("object"!=typeof t||null===t||t instanceof Array||t instanceof Date||t instanceof Qr||t instanceof Td||t instanceof wd||t instanceof Kl||t instanceof Id)}function zd(t,e,n){if(!Bd(n)||!function(t){return"object"==typeof t&&null!==t&&(Object.getPrototypeOf(t)===Object.prototype||null===Object.getPrototypeOf(t))}(n)){const r=Ul(n);throw"an object"===r?e.Ua(t+" a custom object"):e.Ua(t+" "+r)}}function Kd(t,e,n){if((e=(0,a.m9)(e))instanceof vd)return e._internalPath;if("string"==typeof e)return Gd(t,e);throw Hd("Field path arguments must be of type string or FieldPath.",t,!1,void 0,n)}const Wd=new RegExp("[~\\*/\\[\\]]");function Gd(t,e,n){if(e.search(Wd)>=0)throw Hd(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`,t,!1,void 0,n);try{return new vd(...e.split("."))._internalPath}catch(r){throw Hd(`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,t,!1,void 0,n)}}function Hd(t,e,n,r,i){const s=r&&!r.isEmpty(),o=void 0!==i;let a=`Function ${e}() called with invalid data`;n&&(a+=" (via `toFirestore()`)"),a+=". ";let c="";return(s||o)&&(c+=" (found",s&&(c+=` in field ${r}`),o&&(c+=` in document ${i}`),c+=")"),new Rr(Or.INVALID_ARGUMENT,a+t+c)}function $d(t,e){return t.some((t=>t.isEqual(e)))}class Yd{constructor(t,e,n,r,i){this._firestore=t,this._userDataWriter=e,this._key=n,this._document=r,this._converter=i}get id(){return this._key.path.lastSegment()}get ref(){return new Kl(this._firestore,this._converter,this._key)}exists(){return null!==this._document}data(){if(this._document){if(this._converter){const t=new Qd(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(t)}return this._userDataWriter.convertValue(this._document.data.value)}}get(t){if(this._document){const e=this._document.data.field(Jd("DocumentSnapshot.get",t));if(null!==e)return this._userDataWriter.convertValue(e)}}}class Qd extends Yd{data(){return super.data()}}function Jd(t,e){return"string"==typeof e?Gd(t,e):e instanceof vd?e._internalPath:e._delegate._internalPath}class Zd{constructor(t,e){this.hasPendingWrites=t,this.fromCache=e}isEqual(t){return this.hasPendingWrites===t.hasPendingWrites&&this.fromCache===t.fromCache}}class Xd extends Yd{constructor(t,e,n,r,i,s){super(t,e,n,r,s),this._firestore=t,this._firestoreImpl=t,this.metadata=i}exists(){return super.exists()}data(t={}){if(this._document){if(this._converter){const e=new tf(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(e,t)}return this._userDataWriter.convertValue(this._document.data.value,t.serverTimestamps)}}get(t,e={}){if(this._document){const n=this._document.data.field(Jd("DocumentSnapshot.get",t));if(null!==n)return this._userDataWriter.convertValue(n,e.serverTimestamps)}}}class tf extends Xd{data(t={}){return super.data(t)}}class ef{constructor(t,e,n,r){this._firestore=t,this._userDataWriter=e,this._snapshot=r,this.metadata=new Zd(r.hasPendingWrites,r.fromCache),this.query=n}get docs(){const t=[];return this.forEach((e=>t.push(e))),t}get size(){return this._snapshot.docs.size}get empty(){return 0===this.size}forEach(t,e){this._snapshot.docs.forEach((n=>{t.call(e,new tf(this._firestore,this._userDataWriter,n.key,n,new Zd(this._snapshot.mutatedKeys.has(n.key),this._snapshot.fromCache),this.query.converter))}))}docChanges(t={}){const e=!!t.includeMetadataChanges;if(e&&this._snapshot.excludesMetadataChanges)throw new Rr(Or.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===e||(this._cachedChanges=function(t,e){if(t._snapshot.oldDocs.isEmpty()){let e=0;return t._snapshot.docChanges.map((n=>({type:"added",doc:new tf(t._firestore,t._userDataWriter,n.doc.key,n.doc,new Zd(t._snapshot.mutatedKeys.has(n.doc.key),t._snapshot.fromCache),t.query.converter),oldIndex:-1,newIndex:e++})))}{let n=t._snapshot.oldDocs;return t._snapshot.docChanges.filter((t=>e||3!==t.type)).map((e=>{const r=new tf(t._firestore,t._userDataWriter,e.doc.key,e.doc,new Zd(t._snapshot.mutatedKeys.has(e.doc.key),t._snapshot.fromCache),t.query.converter);let i=-1,s=-1;return 0!==e.type&&(i=n.indexOf(e.doc.key),n=n.delete(e.doc.key)),1!==e.type&&(n=n.add(e.doc),s=n.indexOf(e.doc.key)),{type:nf(e.type),doc:r,oldIndex:i,newIndex:s}}))}}(this,e),this._cachedChangesIncludeMetadataChanges=e),this._cachedChanges}}function nf(t){switch(t){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return Nr()}}function rf(t,e){return t instanceof Xd&&e instanceof Xd?t._firestore===e._firestore&&t._key.isEqual(e._key)&&(null===t._document?null===e._document:t._document.isEqual(e._document))&&t._converter===e._converter:t instanceof ef&&e instanceof ef&&t._firestore===e._firestore&&Jl(t.query,e.query)&&t.metadata.isEqual(e.metadata)&&t._snapshot.isEqual(e._snapshot)}function sf(t){if(os(t)&&0===t.explicitOrderBy.length)throw new Rr(Or.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class of{}function af(t,...e){for(const n of e)t=n._apply(t);return t}class cf extends of{constructor(t,e,n){super(),this.Ga=t,this.za=e,this.Ha=n,this.type="where"}_apply(t){const e=xd(t.firestore),n=function(t,e,n,r,i,s,o){let a;if(i.isKeyField()){if("array-contains"===s||"array-contains-any"===s)throw new Rr(Or.INVALID_ARGUMENT,`Invalid Query. You can't perform '${s}' queries on FieldPath.documentId().`);if("in"===s||"not-in"===s){_f(o,s);const e=[];for(const n of o)e.push(Tf(r,t,n));a={arrayValue:{values:e}}}else a=Tf(r,t,o)}else"in"!==s&&"not-in"!==s&&"array-contains-any"!==s||_f(o,s),a=Vd(n,"where",o,"in"===s||"not-in"===s);const c=qi.create(i,s,a);return function(t,e){if(e.V()){const n=cs(t);if(null!==n&&!n.isEqual(e.field))throw new Rr(Or.INVALID_ARGUMENT,`Invalid query. All where filters with an inequality (<, <=, !=, not-in, >, or >=) must be on the same field. But you have inequality filters on '${n.toString()}' and '${e.field.toString()}'`);const r=as(t);null!==r&&Ef(0,e.field,r)}const n=function(t,e){for(const n of t.filters)if(e.indexOf(n.op)>=0)return n.op;return null}(t,function(t){switch(t){case"!=":return["!=","not-in"];case"array-contains":return["array-contains","array-contains-any","not-in"];case"in":return["array-contains-any","in","not-in"];case"array-contains-any":return["array-contains","array-contains-any","in","not-in"];case"not-in":return["array-contains","array-contains-any","in","not-in","!="];default:return[]}}(e.op));if(null!==n)throw n===e.op?new Rr(Or.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${e.op.toString()}' filter.`):new Rr(Or.INVALID_ARGUMENT,`Invalid query. You cannot use '${e.op.toString()}' filters with '${n.toString()}' filters.`)}(t,c),c}(t._query,0,e,t.firestore._databaseId,this.Ga,this.za,this.Ha);return new Wl(t.firestore,t.converter,function(t,e){const n=t.filters.concat([e]);return new ns(t.path,t.collectionGroup,t.explicitOrderBy.slice(),n,t.limit,t.limitType,t.startAt,t.endAt)}(t._query,n))}}function uf(t,e,n){const r=e,i=Jd("where",t);return new cf(i,r,n)}class hf extends of{constructor(t,e){super(),this.Ga=t,this.Ja=e,this.type="orderBy"}_apply(t){const e=function(t,e,n){if(null!==t.startAt)throw new Rr(Or.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(null!==t.endAt)throw new Rr(Or.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");const r=new Zi(e,n);return function(t,e){if(null===as(t)){const n=cs(t);null!==n&&Ef(0,n,e.field)}}(t,r),r}(t._query,this.Ga,this.Ja);return new Wl(t.firestore,t.converter,function(t,e){const n=t.explicitOrderBy.concat([e]);return new ns(t.path,t.collectionGroup,n,t.filters.slice(),t.limit,t.limitType,t.startAt,t.endAt)}(t._query,e))}}function lf(t,e="asc"){const n=e,r=Jd("orderBy",t);return new hf(r,n)}class df extends of{constructor(t,e,n){super(),this.type=t,this.Ya=e,this.Xa=n}_apply(t){return new Wl(t.firestore,t.converter,ds(t._query,this.Ya,this.Xa))}}function ff(t){return jl("limit",t),new df("limit",t,"F")}function pf(t){return jl("limitToLast",t),new df("limitToLast",t,"L")}class mf extends of{constructor(t,e,n){super(),this.type=t,this.Za=e,this.tc=n}_apply(t){const e=If(t,this.type,this.Za,this.tc);return new Wl(t.firestore,t.converter,function(t,e){return new ns(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,e,t.endAt)}(t._query,e))}}function gf(...t){return new mf("startAt",t,!0)}function yf(...t){return new mf("startAfter",t,!1)}class vf extends of{constructor(t,e,n){super(),this.type=t,this.Za=e,this.tc=n}_apply(t){const e=If(t,this.type,this.Za,this.tc);return new Wl(t.firestore,t.converter,function(t,e){return new ns(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,t.startAt,e)}(t._query,e))}}function bf(...t){return new vf("endBefore",t,!0)}function wf(...t){return new vf("endAt",t,!1)}function If(t,e,n,r){if(n[0]=(0,a.m9)(n[0]),n[0]instanceof Yd)return function(t,e,n,r,i){if(!r)throw new Rr(Or.NOT_FOUND,`Can't use a DocumentSnapshot that doesn't exist for ${n}().`);const s=[];for(const n of hs(t))if(n.field.isKeyField())s.push(ki(e,r.key));else{const t=r.data.field(n.field);if(di(t))throw new Rr(Or.INVALID_ARGUMENT,'Invalid query. You are trying to start or end a query using a document for which the field "'+n.field+'" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');if(null===t){const t=n.field.canonicalString();throw new Rr(Or.INVALID_ARGUMENT,`Invalid query. You are trying to start or end a query using a document for which the field '${t}' (used as the orderBy) does not exist.`)}s.push(t)}return new Qi(s,i)}(t._query,t.firestore._databaseId,e,n[0]._document,r);{const i=xd(t.firestore);return function(t,e,n,r,i,s){const o=t.explicitOrderBy;if(i.length>o.length)throw new Rr(Or.INVALID_ARGUMENT,`Too many arguments provided to ${r}(). The number of arguments must be less than or equal to the number of orderBy() clauses`);const a=[];for(let s=0;s<i.length;s++){const c=i[s];if(o[s].field.isKeyField()){if("string"!=typeof c)throw new Rr(Or.INVALID_ARGUMENT,`Invalid query. Expected a string for document ID in ${r}(), but got a ${typeof c}`);if(!us(t)&&-1!==c.indexOf("/"))throw new Rr(Or.INVALID_ARGUMENT,`Invalid query. When querying a collection and ordering by FieldPath.documentId(), the value passed to ${r}() must be a plain document ID, but '${c}' contains a slash.`);const n=t.path.child(ni.fromString(c));if(!vi.isDocumentKey(n))throw new Rr(Or.INVALID_ARGUMENT,`Invalid query. When querying a collection group and ordering by FieldPath.documentId(), the value passed to ${r}() must result in a valid document path, but '${n}' is not because it contains an odd number of segments.`);const i=new vi(n);a.push(ki(e,i))}else{const t=Vd(n,r,c);a.push(t)}}return new Qi(a,s)}(t._query,t.firestore._databaseId,i,e,n,r)}}function Tf(t,e,n){if("string"==typeof(n=(0,a.m9)(n))){if(""===n)throw new Rr(Or.INVALID_ARGUMENT,"Invalid query. When querying with FieldPath.documentId(), you must provide a valid document ID, but it was an empty string.");if(!us(e)&&-1!==n.indexOf("/"))throw new Rr(Or.INVALID_ARGUMENT,`Invalid query. When querying a collection by FieldPath.documentId(), you must provide a plain document ID, but '${n}' contains a '/' character.`);const r=e.path.child(ni.fromString(n));if(!vi.isDocumentKey(r))throw new Rr(Or.INVALID_ARGUMENT,`Invalid query. When querying a collection group by FieldPath.documentId(), the value provided must result in a valid document path, but '${r}' is not because it has an odd number of segments (${r.length}).`);return ki(t,new vi(r))}if(n instanceof Kl)return ki(t,n._key);throw new Rr(Or.INVALID_ARGUMENT,`Invalid query. When querying with FieldPath.documentId(), you must provide a valid string or a DocumentReference, but it was: ${Ul(n)}.`)}function _f(t,e){if(!Array.isArray(t)||0===t.length)throw new Rr(Or.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${e.toString()}' filters.`);if(t.length>10)throw new Rr(Or.INVALID_ARGUMENT,`Invalid Query. '${e.toString()}' filters support a maximum of 10 elements in the value array.`)}function Ef(t,e,n){if(!n.isEqual(e))throw new Rr(Or.INVALID_ARGUMENT,`Invalid query. You have a where filter with an inequality (<, <=, !=, not-in, >, or >=) on field '${e.toString()}' and so you must also use '${e.toString()}' as your first argument to orderBy(), but your first orderBy() is on field '${n.toString()}' instead.`)}class Sf{convertValue(t,e="none"){switch(bi(t)){case 0:return null;case 1:return t.booleanValue;case 2:return hi(t.integerValue||t.doubleValue);case 3:return this.convertTimestamp(t.timestampValue);case 4:return this.convertServerTimestamp(t,e);case 5:return t.stringValue;case 6:return this.convertBytes(li(t.bytesValue));case 7:return this.convertReference(t.referenceValue);case 8:return this.convertGeoPoint(t.geoPointValue);case 9:return this.convertArray(t.arrayValue,e);case 10:return this.convertObject(t.mapValue,e);default:throw Nr()}}convertObject(t,e){const n={};return Xr(t.fields,((t,r)=>{n[t]=this.convertValue(r,e)})),n}convertGeoPoint(t){return new Td(hi(t.latitude),hi(t.longitude))}convertArray(t,e){return(t.values||[]).map((t=>this.convertValue(t,e)))}convertServerTimestamp(t,e){switch(e){case"previous":const n=fi(t);return null==n?null:this.convertValue(n,e);case"estimate":return this.convertTimestamp(pi(t));default:return null}}convertTimestamp(t){const e=ui(t);return new Qr(e.seconds,e.nanos)}convertDocumentKey(t,e){const n=ni.fromString(t);xr(sa(n));const r=new Ol(n.get(1),n.get(3)),i=new vi(n.popFirst(5));return r.isEqual(e)||Sr(`Document ${i} contains a document reference within a different database (${r.projectId}/${r.database}) which is not supported. It will be treated as a reference in the current database (${e.projectId}/${e.database}) instead.`),i}}function kf(t,e,n){let r;return r=t?n&&(n.merge||n.mergeFields)?t.toFirestore(e,n):t.toFirestore(e):e,r}class Af extends Sf{constructor(t){super(),this.firestore=t}convertBytes(t){return new wd(t)}convertReference(t){const e=this.convertDocumentKey(t,this.firestore._databaseId);return new Kl(this.firestore,null,e)}}class Nf{constructor(t,e){this._firestore=t,this._commitHandler=e,this._mutations=[],this._committed=!1,this._dataReader=xd(t)}set(t,e,n){this._verifyNotCommitted();const r=xf(t,this._firestore),i=kf(r.converter,e,n),s=Cd(this._dataReader,"WriteBatch.set",r._key,i,null!==r.converter,n);return this._mutations.push(s.toMutation(r._key,Ms.none())),this}update(t,e,n,...r){this._verifyNotCommitted();const i=xf(t,this._firestore);let s;return s="string"==typeof(e=(0,a.m9)(e))||e instanceof vd?Ud(this._dataReader,"WriteBatch.update",i._key,e,n,r):Fd(this._dataReader,"WriteBatch.update",i._key,e),this._mutations.push(s.toMutation(i._key,Ms.exists(!0))),this}delete(t){this._verifyNotCommitted();const e=xf(t,this._firestore);return this._mutations=this._mutations.concat(new Ys(e._key,Ms.none())),this}commit(){return this._verifyNotCommitted(),this._committed=!0,this._mutations.length>0?this._commitHandler(this._mutations):Promise.resolve()}_verifyNotCommitted(){if(this._committed)throw new Rr(Or.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")}}function xf(t,e){if((t=(0,a.m9)(t)).firestore!==e)throw new Rr(Or.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return t}function Cf(t){t=Vl(t,Kl);const e=Vl(t.firestore,nd);return xl(sd(e),t._key).then((n=>Kf(e,t,n)))}class Df extends Sf{constructor(t){super(),this.firestore=t}convertBytes(t){return new wd(t)}convertReference(t){const e=this.convertDocumentKey(t,this.firestore._databaseId);return new Kl(this.firestore,null,e)}}function Of(t){t=Vl(t,Kl);const e=Vl(t.firestore,nd),n=sd(e),r=new Df(e);return function(t,e){const n=new Pr;return t.asyncQueue.enqueueAndForget((async()=>async function(t,e,n){try{const r=await function(t,e){const n=Dr(t);return n.persistence.runTransaction("read document","readonly",(t=>n.Wn.Rn(t,e)))}(t,e);r.isFoundDocument()?n.resolve(r):r.isNoDocument()?n.resolve(null):n.reject(new Rr(Or.UNAVAILABLE,"Failed to get document from cache. (However, this document may exist on the server. Run again without setting 'source' in the GetOptions to attempt to retrieve the document from the server.)"))}catch(t){const r=ph(t,`Failed to get document '${e} from cache`);n.reject(r)}}(await Sl(t),e,n))),n.promise}(n,t._key).then((n=>new Xd(e,r,t._key,n,new Zd(null!==n&&n.hasLocalMutations,!0),t.converter)))}function Rf(t){t=Vl(t,Kl);const e=Vl(t.firestore,nd);return xl(sd(e),t._key,{source:"server"}).then((n=>Kf(e,t,n)))}function Pf(t){t=Vl(t,Wl);const e=Vl(t.firestore,nd),n=sd(e),r=new Df(e);return sf(t._query),Cl(n,t._query).then((n=>new ef(e,r,t,n)))}function Lf(t){t=Vl(t,Wl);const e=Vl(t.firestore,nd),n=sd(e),r=new Df(e);return function(t,e){const n=new Pr;return t.asyncQueue.enqueueAndForget((async()=>async function(t,e,n){try{const r=await eu(t,e,!0),i=new Oh(e,r.zn),s=i.Po(r.documents),o=i.applyChanges(s,!1);n.resolve(o.snapshot)}catch(t){const r=ph(t,`Failed to execute query '${e} against cache`);n.reject(r)}}(await Sl(t),e,n))),n.promise}(n,t._query).then((n=>new ef(e,r,t,n)))}function Mf(t){t=Vl(t,Wl);const e=Vl(t.firestore,nd),n=sd(e),r=new Df(e);return Cl(n,t._query,{source:"server"}).then((n=>new ef(e,r,t,n)))}function Ff(t,e,n){t=Vl(t,Kl);const r=Vl(t.firestore,nd),i=kf(t.converter,e,n);return zf(r,[Cd(xd(r),"setDoc",t._key,i,null!==t.converter,n).toMutation(t._key,Ms.none())])}function Uf(t,e,n,...r){t=Vl(t,Kl);const i=Vl(t.firestore,nd),s=xd(i);let o;return o="string"==typeof(e=(0,a.m9)(e))||e instanceof vd?Ud(s,"updateDoc",t._key,e,n,r):Fd(s,"updateDoc",t._key,e),zf(i,[o.toMutation(t._key,Ms.exists(!0))])}function Vf(t){return zf(Vl(t.firestore,nd),[new Ys(t._key,Ms.none())])}function jf(t,e){const n=Vl(t.firestore,nd),r=Yl(t),i=kf(t.converter,e);return zf(n,[Cd(xd(t.firestore),"addDoc",r._key,i,null!==t.converter,{}).toMutation(r._key,Ms.exists(!1))]).then((()=>r))}function qf(t,...e){var n,r,i;t=(0,a.m9)(t);let s={includeMetadataChanges:!1},o=0;"object"!=typeof e[o]||Xl(e[o])||(s=e[o],o++);const c={includeMetadataChanges:s.includeMetadataChanges};if(Xl(e[o])){const t=e[o];e[o]=null===(n=t.next)||void 0===n?void 0:n.bind(t),e[o+1]=null===(r=t.error)||void 0===r?void 0:r.bind(t),e[o+2]=null===(i=t.complete)||void 0===i?void 0:i.bind(t)}let u,h,l;if(t instanceof Kl)h=Vl(t.firestore,nd),l=is(t._key.path),u={next:n=>{e[o]&&e[o](Kf(h,t,n))},error:e[o+1],complete:e[o+2]};else{const n=Vl(t,Wl);h=Vl(n.firestore,nd),l=n._query;const r=new Df(h);u={next:t=>{e[o]&&e[o](new ef(h,r,n,t))},error:e[o+1],complete:e[o+2]},sf(t._query)}return function(t,e,n,r){const i=new ml(r),s=new Sh(e,i,n);return t.asyncQueue.enqueueAndForget((async()=>wh(await Nl(t),s))),()=>{i.na(),t.asyncQueue.enqueueAndForget((async()=>Ih(await Nl(t),s)))}}(sd(h),l,c,u)}function Bf(t,e){return function(t,e){const n=new ml(e);return t.asyncQueue.enqueueAndForget((async()=>function(t,e){Dr(t).io.add(e),e.next()}(await Nl(t),n))),()=>{n.na(),t.asyncQueue.enqueueAndForget((async()=>function(t,e){Dr(t).io.delete(e)}(await Nl(t),n)))}}(sd(t=Vl(t,nd)),Xl(e)?e:{next:e})}function zf(t,e){return function(t,e){const n=new Pr;return t.asyncQueue.enqueueAndForget((async()=>async function(t,e,n){const r=ul(t);try{const t=await function(t,e){const n=Dr(t),r=Qr.now(),i=e.reduce(((t,e)=>t.add(e.key)),mo());let s;return n.persistence.runTransaction("Locally write mutations","readwrite",(t=>n.Wn.vn(t,i).next((i=>{s=i;const o=[];for(const t of e){const e=qs(t,s.get(t.key));null!=e&&o.push(new Ws(t.key,e,Pi(e.value.mapValue),Ms.exists(!0)))}return n.An.addMutationBatch(t,r,o,e)})))).then((t=>(t.applyToLocalDocumentSet(s),{batchId:t.batchId,changes:s})))}(r.localStore,e);r.sharedClientState.addPendingMutation(t.batchId),function(t,e,n){let r=t.Ko[t.currentUser.toKey()];r||(r=new no(Hr)),r=r.insert(e,n),t.Ko[t.currentUser.toKey()]=r}(r,t.batchId,n),await Jh(r,t.changes),await eh(r.remoteStore)}catch(t){const e=ph(t,"Failed to persist write");n.reject(e)}}(await Al(t),e,n))),n.promise}(sd(t),e)}function Kf(t,e,n){const r=n.docs.get(e._key),i=new Df(t);return new Xd(t,i,e._key,r,new Zd(n.hasPendingWrites,n.fromCache),e.converter)}class Wf extends class{constructor(t,e){this._firestore=t,this._transaction=e,this._dataReader=xd(t)}get(t){const e=xf(t,this._firestore),n=new Af(this._firestore);return this._transaction.lookup([e._key]).then((t=>{if(!t||1!==t.length)return Nr();const r=t[0];if(r.isFoundDocument())return new Yd(this._firestore,n,r.key,r,e.converter);if(r.isNoDocument())return new Yd(this._firestore,n,e._key,null,e.converter);throw Nr()}))}set(t,e,n){const r=xf(t,this._firestore),i=kf(r.converter,e,n),s=Cd(this._dataReader,"Transaction.set",r._key,i,null!==r.converter,n);return this._transaction.set(r._key,s),this}update(t,e,n,...r){const i=xf(t,this._firestore);let s;return s="string"==typeof(e=(0,a.m9)(e))||e instanceof vd?Ud(this._dataReader,"Transaction.update",i._key,e,n,r):Fd(this._dataReader,"Transaction.update",i._key,e),this._transaction.update(i._key,s),this}delete(t){const e=xf(t,this._firestore);return this._transaction.delete(e._key),this}}{constructor(t,e){super(t,e),this._firestore=t}get(t){const e=xf(t,this._firestore),n=new Df(this._firestore);return super.get(t).then((t=>new Xd(this._firestore,n,e._key,t._document,new Zd(!1,!1),e.converter)))}}function Gf(t,e){return function(t,e){const n=new Pr;return t.asyncQueue.enqueueAndForget((async()=>{const r=await function(t){return _l(t).then((t=>t.datastore))}(t);new vl(t.asyncQueue,r,e,n).run()})),n.promise}(sd(t=Vl(t,nd)),(n=>e(new Wf(t,n))))}function Hf(){return new Dd("deleteField")}function $f(){return new Rd("serverTimestamp")}function Yf(...t){return new Pd("arrayUnion",t)}function Qf(...t){return new Ld("arrayRemove",t)}function Jf(t){return new Md("increment",t)}function Zf(t){return sd(t=Vl(t,nd)),new Nf(t,(e=>zf(t,e)))}!function(t,e=!0){!function(t){wr=t}(i.Jn),(0,i.Xd)(new s.wA("firestore",((t,{options:n})=>{const r=t.getProvider("app").getImmediate(),i=new nd(r,new Ur(t.getProvider("auth-internal")),new Br(t.getProvider("app-check-internal")));return n=Object.assign({useFetchStreams:e},n),i._setSettings(n),i}),"PUBLIC")),(0,i.KN)(vr,"3.4.2",t),(0,i.KN)(vr,"3.4.2","esm2017")}()},3310:t=>{"use strict";t.exports=t=>{if("[object Object]"!==Object.prototype.toString.call(t))return!1;const e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}},6245:(t,e,n)=>{"use strict";function r(t){this.message=t}n.r(e),n.d(e,{default:()=>a,InvalidTokenError:()=>o}),r.prototype=new Error,r.prototype.name="InvalidCharacterError";var i="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new r("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,i,s=0,o=0,a="";i=e.charAt(o++);~i&&(n=s%4?64*n+i:i,s++%4)?a+=String.fromCharCode(255&n>>(-2*s&6)):0)i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(i);return a};function s(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(i(t).replace(/(.)/g,(function(t,e){var n=e.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(e)}catch(t){return i(e)}}function o(t){this.message=t}o.prototype=new Error,o.prototype.name="InvalidTokenError";const a=function(t,e){if("string"!=typeof t)throw new o("Invalid token specified");var n=!0===(e=e||{}).header?0:1;try{return JSON.parse(s(t.split(".")[n]))}catch(t){throw new o("Invalid token specified: "+t.message)}}},942:function(t,e,n){"use strict";const r=n(3310),{hasOwnProperty:i}=Object.prototype,{propertyIsEnumerable:s}=Object,o=(t,e,n)=>Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0}),a=this,c={concatArrays:!1,ignoreUndefined:!1},u=t=>{const e=[];for(const n in t)i.call(t,n)&&e.push(n);if(Object.getOwnPropertySymbols){const n=Object.getOwnPropertySymbols(t);for(const r of n)s.call(t,r)&&e.push(r)}return e};function h(t){return Array.isArray(t)?function(t){const e=t.slice(0,0);return u(t).forEach((n=>{o(e,n,h(t[n]))})),e}(t):r(t)?function(t){const e=null===Object.getPrototypeOf(t)?Object.create(null):{};return u(t).forEach((n=>{o(e,n,h(t[n]))})),e}(t):t}const l=(t,e,n,r)=>(n.forEach((n=>{void 0===e[n]&&r.ignoreUndefined||(n in t&&t[n]!==Object.getPrototypeOf(t)?o(t,n,d(t[n],e[n],r)):o(t,n,h(e[n])))})),t);function d(t,e,n){return n.concatArrays&&Array.isArray(t)&&Array.isArray(e)?((t,e,n)=>{let r=t.slice(0,0),s=0;return[t,e].forEach((e=>{const a=[];for(let n=0;n<e.length;n++)i.call(e,n)&&(a.push(String(n)),o(r,s++,e===t?e[n]:h(e[n])));r=l(r,e,u(e).filter((t=>!a.includes(t))),n)})),r})(t,e,n):r(e)&&r(t)?l(t,e,u(e),n):h(e)}t.exports=function(...t){const e=d(h(c),this!==a&&this||{},c);let n={_:{}};for(const i of t)if(void 0!==i){if(!r(i))throw new TypeError("`"+i+"` is not an Option Object");n=d(n,{_:i},e)}return n._}},4143:(t,e,n)=>{"use strict";n.r(e),n.d(e,{ArgumentOutOfRangeError:()=>D.W,AsyncSubject:()=>h.c,BehaviorSubject:()=>c.X,ConnectableObservable:()=>i.c,EMPTY:()=>Q.E,EmptyError:()=>O.K,GroupedObservable:()=>s.T,NEVER:()=>dt,Notification:()=>k.P,NotificationKind:()=>k.W,ObjectUnsubscribedError:()=>R.N,Observable:()=>r.y,ReplaySubject:()=>u.t,Scheduler:()=>_.b,Subject:()=>a.xQ,Subscriber:()=>S.L,Subscription:()=>E.w,TimeoutError:()=>L.W,UnsubscriptionError:()=>P.B,VirtualAction:()=>T,VirtualTimeScheduler:()=>I,animationFrame:()=>w,animationFrameScheduler:()=>b,asap:()=>l.e,asapScheduler:()=>l.E,async:()=>d.P,asyncScheduler:()=>d.z,bindCallback:()=>j,bindNodeCallback:()=>z,combineLatest:()=>H.aj,concat:()=>$.z,config:()=>Ct.v,defer:()=>Y.P,empty:()=>Q.c,forkJoin:()=>X,from:()=>Z.D,fromEvent:()=>nt,fromEventPattern:()=>it,generate:()=>st,identity:()=>x.y,iif:()=>at,interval:()=>ut,isObservable:()=>C,merge:()=>lt.T,never:()=>ft,noop:()=>N.Z,observable:()=>o.L,of:()=>pt.of,onErrorResumeNext:()=>mt,pairs:()=>gt,partition:()=>It,pipe:()=>A.z,queue:()=>f.c,queueScheduler:()=>f.N,race:()=>Tt.S3,range:()=>_t,scheduled:()=>xt.x,throwError:()=>St._,timer:()=>kt.H,using:()=>At,zip:()=>Nt.$R});var r=n(2772),i=n(3140),s=n(1120),o=n(5050),a=n(211),c=n(9233),u=n(2630),h=n(364),l=n(6650),d=n(964),f=n(2546),p=n(5987),m=n(6114),g=function(t){function e(e,n){var r=t.call(this,e,n)||this;return r.scheduler=e,r.work=n,r}return p.ZT(e,t),e.prototype.requestAsyncId=function(e,n,r){return void 0===r&&(r=0),null!==r&&r>0?t.prototype.requestAsyncId.call(this,e,n,r):(e.actions.push(this),e.scheduled||(e.scheduled=requestAnimationFrame((function(){return e.flush(null)}))))},e.prototype.recycleAsyncId=function(e,n,r){if(void 0===r&&(r=0),null!==r&&r>0||null===r&&this.delay>0)return t.prototype.recycleAsyncId.call(this,e,n,r);0===e.actions.length&&(cancelAnimationFrame(n),e.scheduled=void 0)},e}(m.o),y=n(8399),v=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return p.ZT(e,t),e.prototype.flush=function(t){this.active=!0,this.scheduled=void 0;var e,n=this.actions,r=-1,i=n.length;t=t||n.shift();do{if(e=t.execute(t.state,t.delay))break}while(++r<i&&(t=n.shift()));if(this.active=!1,e){for(;++r<i&&(t=n.shift());)t.unsubscribe();throw e}},e}(y.v),b=new v(g),w=b,I=function(t){function e(e,n){void 0===e&&(e=T),void 0===n&&(n=Number.POSITIVE_INFINITY);var r=t.call(this,e,(function(){return r.frame}))||this;return r.maxFrames=n,r.frame=0,r.index=-1,r}return p.ZT(e,t),e.prototype.flush=function(){for(var t,e,n=this.actions,r=this.maxFrames;(e=n[0])&&e.delay<=r&&(n.shift(),this.frame=e.delay,!(t=e.execute(e.state,e.delay))););if(t){for(;e=n.shift();)e.unsubscribe();throw t}},e.frameTimeFactor=10,e}(y.v),T=function(t){function e(e,n,r){void 0===r&&(r=e.index+=1);var i=t.call(this,e,n)||this;return i.scheduler=e,i.work=n,i.index=r,i.active=!0,i.index=e.index=r,i}return p.ZT(e,t),e.prototype.schedule=function(n,r){if(void 0===r&&(r=0),!this.id)return t.prototype.schedule.call(this,n,r);this.active=!1;var i=new e(this.scheduler,this.work);return this.add(i),i.schedule(n,r)},e.prototype.requestAsyncId=function(t,n,r){void 0===r&&(r=0),this.delay=t.frame+r;var i=t.actions;return i.push(this),i.sort(e.sortActions),!0},e.prototype.recycleAsyncId=function(t,e,n){void 0===n&&(n=0)},e.prototype._execute=function(e,n){if(!0===this.active)return t.prototype._execute.call(this,e,n)},e.sortActions=function(t,e){return t.delay===e.delay?t.index===e.index?0:t.index>e.index?1:-1:t.delay>e.delay?1:-1},e}(m.o),_=n(8725),E=n(8760),S=n(979),k=n(2632),A=n(2561),N=n(3306),x=n(3608);function C(t){return!!t&&(t instanceof r.y||"function"==typeof t.lift&&"function"==typeof t.subscribe)}var D=n(6565),O=n(6929),R=n(1016),P=n(8782),L=n(1462),M=n(5709),F=n(3642),U=n(9026),V=n(7507);function j(t,e,n){if(e){if(!(0,V.K)(e))return function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];return j(t,n).apply(void 0,r).pipe((0,M.U)((function(t){return(0,U.k)(t)?e.apply(void 0,t):e(t)})))};n=e}return function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];var s,o=this,a={context:o,subject:s,callbackFunc:t,scheduler:n};return new r.y((function(r){if(n){var i={args:e,subscriber:r,params:a};return n.schedule(q,0,i)}if(!s){s=new h.c;try{t.apply(o,e.concat([function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];s.next(t.length<=1?t[0]:t),s.complete()}]))}catch(t){(0,F._)(s)?s.error(t):console.warn(t)}}return s.subscribe(r)}))}}function q(t){var e=this,n=t.args,r=t.subscriber,i=t.params,s=i.callbackFunc,o=i.context,a=i.scheduler,c=i.subject;if(!c){c=i.subject=new h.c;try{s.apply(o,n.concat([function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=t.length<=1?t[0]:t;e.add(a.schedule(B,0,{value:r,subject:c}))}]))}catch(t){c.error(t)}}this.add(c.subscribe(r))}function B(t){var e=t.value,n=t.subject;n.next(e),n.complete()}function z(t,e,n){if(e){if(!(0,V.K)(e))return function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];return z(t,n).apply(void 0,r).pipe((0,M.U)((function(t){return(0,U.k)(t)?e.apply(void 0,t):e(t)})))};n=e}return function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];var s={subject:void 0,args:e,callbackFunc:t,scheduler:n,context:this};return new r.y((function(r){var i=s.context,o=s.subject;if(n)return n.schedule(K,0,{params:s,subscriber:r,context:i});if(!o){o=s.subject=new h.c;try{t.apply(i,e.concat([function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=t.shift();n?o.error(n):(o.next(t.length<=1?t[0]:t),o.complete())}]))}catch(t){(0,F._)(o)?o.error(t):console.warn(t)}}return o.subscribe(r)}))}}function K(t){var e=this,n=t.params,r=t.subscriber,i=t.context,s=n.callbackFunc,o=n.args,a=n.scheduler,c=n.subject;if(!c){c=n.subject=new h.c;try{s.apply(i,o.concat([function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=t.shift();if(r)e.add(a.schedule(G,0,{err:r,subject:c}));else{var i=t.length<=1?t[0]:t;e.add(a.schedule(W,0,{value:i,subject:c}))}}]))}catch(t){this.add(a.schedule(G,0,{err:t,subject:c}))}}this.add(c.subscribe(r))}function W(t){var e=t.value,n=t.subject;n.next(e),n.complete()}function G(t){var e=t.err;t.subject.error(e)}var H=n(5142),$=n(9795),Y=n(1410),Q=n(5631),J=n(2009),Z=n(5760);function X(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(1===t.length){var n=t[0];if((0,U.k)(n))return tt(n,null);if((0,J.K)(n)&&Object.getPrototypeOf(n)===Object.prototype){var r=Object.keys(n);return tt(r.map((function(t){return n[t]})),r)}}if("function"==typeof t[t.length-1]){var i=t.pop();return tt(t=1===t.length&&(0,U.k)(t[0])?t[0]:t,null).pipe((0,M.U)((function(t){return i.apply(void 0,t)})))}return tt(t,null)}function tt(t,e){return new r.y((function(n){var r=t.length;if(0!==r)for(var i=new Array(r),s=0,o=0,a=function(a){var c=(0,Z.D)(t[a]),u=!1;n.add(c.subscribe({next:function(t){u||(u=!0,o++),i[a]=t},error:function(t){return n.error(t)},complete:function(){++s!==r&&u||(o===r&&n.next(e?e.reduce((function(t,e,n){return t[e]=i[n],t}),{}):i),n.complete())}}))},c=0;c<r;c++)a(c);else n.complete()}))}var et=n(4156);function nt(t,e,n,i){return(0,et.m)(n)&&(i=n,n=void 0),i?nt(t,e,n).pipe((0,M.U)((function(t){return(0,U.k)(t)?i.apply(void 0,t):i(t)}))):new r.y((function(r){rt(t,e,(function(t){arguments.length>1?r.next(Array.prototype.slice.call(arguments)):r.next(t)}),r,n)}))}function rt(t,e,n,r,i){var s;if(function(t){return t&&"function"==typeof t.addEventListener&&"function"==typeof t.removeEventListener}(t)){var o=t;t.addEventListener(e,n,i),s=function(){return o.removeEventListener(e,n,i)}}else if(function(t){return t&&"function"==typeof t.on&&"function"==typeof t.off}(t)){var a=t;t.on(e,n),s=function(){return a.off(e,n)}}else if(function(t){return t&&"function"==typeof t.addListener&&"function"==typeof t.removeListener}(t)){var c=t;t.addListener(e,n),s=function(){return c.removeListener(e,n)}}else{if(!t||!t.length)throw new TypeError("Invalid event target");for(var u=0,h=t.length;u<h;u++)rt(t[u],e,n,r,i)}r.add(s)}function it(t,e,n){return n?it(t,e).pipe((0,M.U)((function(t){return(0,U.k)(t)?n.apply(void 0,t):n(t)}))):new r.y((function(n){var r,i=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return n.next(1===t.length?t[0]:t)};try{r=t(i)}catch(t){return void n.error(t)}if((0,et.m)(e))return function(){return e(i,r)}}))}function st(t,e,n,i,s){var o,a;if(1==arguments.length){var c=t;a=c.initialState,e=c.condition,n=c.iterate,o=c.resultSelector||x.y,s=c.scheduler}else void 0===i||(0,V.K)(i)?(a=t,o=x.y,s=i):(a=t,o=i);return new r.y((function(t){var r=a;if(s)return s.schedule(ot,0,{subscriber:t,iterate:n,condition:e,resultSelector:o,state:r});for(;;){if(e){var i=void 0;try{i=e(r)}catch(e){return void t.error(e)}if(!i){t.complete();break}}var c=void 0;try{c=o(r)}catch(e){return void t.error(e)}if(t.next(c),t.closed)break;try{r=n(r)}catch(e){return void t.error(e)}}}))}function ot(t){var e=t.subscriber,n=t.condition;if(!e.closed){if(t.needIterate)try{t.state=t.iterate(t.state)}catch(t){return void e.error(t)}else t.needIterate=!0;if(n){var r=void 0;try{r=n(t.state)}catch(t){return void e.error(t)}if(!r)return void e.complete();if(e.closed)return}var i;try{i=t.resultSelector(t.state)}catch(t){return void e.error(t)}if(!e.closed&&(e.next(i),!e.closed))return this.schedule(t)}}function at(t,e,n){return void 0===e&&(e=Q.E),void 0===n&&(n=Q.E),(0,Y.P)((function(){return t()?e:n}))}var ct=n(5812);function ut(t,e){return void 0===t&&(t=0),void 0===e&&(e=d.P),(!(0,ct.k)(t)||t<0)&&(t=0),e&&"function"==typeof e.schedule||(e=d.P),new r.y((function(n){return n.add(e.schedule(ht,t,{subscriber:n,counter:0,period:t})),n}))}function ht(t){var e=t.subscriber,n=t.counter,r=t.period;e.next(n),this.schedule({subscriber:e,counter:n+1,period:r},r)}var lt=n(4370),dt=new r.y(N.Z);function ft(){return dt}var pt=n(8170);function mt(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(0===t.length)return Q.E;var n=t[0],i=t.slice(1);return 1===t.length&&(0,U.k)(n)?mt.apply(void 0,n):new r.y((function(t){var e=function(){return t.add(mt.apply(void 0,i).subscribe(t))};return(0,Z.D)(n).subscribe({next:function(e){t.next(e)},error:e,complete:e})}))}function gt(t,e){return e?new r.y((function(n){var r=Object.keys(t),i=new E.w;return i.add(e.schedule(yt,0,{keys:r,index:0,subscriber:n,subscription:i,obj:t})),i})):new r.y((function(e){for(var n=Object.keys(t),r=0;r<n.length&&!e.closed;r++){var i=n[r];t.hasOwnProperty(i)&&e.next([i,t[i]])}e.complete()}))}function yt(t){var e=t.keys,n=t.index,r=t.subscriber,i=t.subscription,s=t.obj;if(!r.closed)if(n<e.length){var o=e[n];r.next([o,s[o]]),i.add(this.schedule({keys:e,index:n+1,subscriber:r,subscription:i,obj:s}))}else r.complete()}var vt=n(9067),bt=n(7843),wt=n(6008);function It(t,e,n){return[(0,wt.h)(e,n)(new r.y((0,bt.s)(t))),(0,wt.h)((0,vt.f)(e,n))(new r.y((0,bt.s)(t)))]}var Tt=n(8821);function _t(t,e,n){return void 0===t&&(t=0),new r.y((function(r){void 0===e&&(e=t,t=0);var i=0,s=t;if(n)return n.schedule(Et,0,{index:i,count:e,start:t,subscriber:r});for(;;){if(i++>=e){r.complete();break}if(r.next(s++),r.closed)break}}))}function Et(t){var e=t.start,n=t.index,r=t.count,i=t.subscriber;n>=r?i.complete():(i.next(e),i.closed||(t.index=n+1,t.start=e+1,this.schedule(t)))}var St=n(4944),kt=n(9604);function At(t,e){return new r.y((function(n){var r,i;try{r=t()}catch(t){return void n.error(t)}try{i=e(r)}catch(t){return void n.error(t)}var s=(i?(0,Z.D)(i):Q.E).subscribe(n);return function(){s.unsubscribe(),r&&r.unsubscribe()}}))}var Nt=n(5080),xt=n(8107),Ct=n(150)},364:(t,e,n)=>{"use strict";n.d(e,{c:()=>o});var r=n(5987),i=n(211),s=n(8760),o=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.value=null,e.hasNext=!1,e.hasCompleted=!1,e}return r.ZT(e,t),e.prototype._subscribe=function(e){return this.hasError?(e.error(this.thrownError),s.w.EMPTY):this.hasCompleted&&this.hasNext?(e.next(this.value),e.complete(),s.w.EMPTY):t.prototype._subscribe.call(this,e)},e.prototype.next=function(t){this.hasCompleted||(this.value=t,this.hasNext=!0)},e.prototype.error=function(e){this.hasCompleted||t.prototype.error.call(this,e)},e.prototype.complete=function(){this.hasCompleted=!0,this.hasNext&&t.prototype.next.call(this,this.value),t.prototype.complete.call(this)},e}(i.xQ)},9233:(t,e,n)=>{"use strict";n.d(e,{X:()=>o});var r=n(5987),i=n(211),s=n(1016),o=function(t){function e(e){var n=t.call(this)||this;return n._value=e,n}return r.ZT(e,t),Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!0,configurable:!0}),e.prototype._subscribe=function(e){var n=t.prototype._subscribe.call(this,e);return n&&!n.closed&&e.next(this._value),n},e.prototype.getValue=function(){if(this.hasError)throw this.thrownError;if(this.closed)throw new s.N;return this._value},e.prototype.next=function(e){t.prototype.next.call(this,this._value=e)},e}(i.xQ)},2632:(t,e,n)=>{"use strict";n.d(e,{W:()=>r,P:()=>a});var r,i=n(5631),s=n(8170),o=n(4944);r||(r={});var a=function(){function t(t,e,n){this.kind=t,this.value=e,this.error=n,this.hasValue="N"===t}return t.prototype.observe=function(t){switch(this.kind){case"N":return t.next&&t.next(this.value);case"E":return t.error&&t.error(this.error);case"C":return t.complete&&t.complete()}},t.prototype.do=function(t,e,n){switch(this.kind){case"N":return t&&t(this.value);case"E":return e&&e(this.error);case"C":return n&&n()}},t.prototype.accept=function(t,e,n){return t&&"function"==typeof t.next?this.observe(t):this.do(t,e,n)},t.prototype.toObservable=function(){switch(this.kind){case"N":return(0,s.of)(this.value);case"E":return(0,o._)(this.error);case"C":return(0,i.c)()}throw new Error("unexpected notification kind value")},t.createNext=function(e){return void 0!==e?new t("N",e):t.undefinedValueNotification},t.createError=function(e){return new t("E",void 0,e)},t.createComplete=function(){return t.completeNotification},t.completeNotification=new t("C"),t.undefinedValueNotification=new t("N",void 0),t}()},2772:(t,e,n)=>{"use strict";n.d(e,{y:()=>h});var r=n(3642),i=n(979),s=n(3142),o=n(2174),a=n(5050),c=n(2561),u=n(150),h=function(){function t(t){this._isScalar=!1,t&&(this._subscribe=t)}return t.prototype.lift=function(e){var n=new t;return n.source=this,n.operator=e,n},t.prototype.subscribe=function(t,e,n){var r=this.operator,a=function(t,e,n){if(t){if(t instanceof i.L)return t;if(t[s.b])return t[s.b]()}return t||e||n?new i.L(t,e,n):new i.L(o.c)}(t,e,n);if(r?a.add(r.call(a,this.source)):a.add(this.source||u.v.useDeprecatedSynchronousErrorHandling&&!a.syncErrorThrowable?this._subscribe(a):this._trySubscribe(a)),u.v.useDeprecatedSynchronousErrorHandling&&a.syncErrorThrowable&&(a.syncErrorThrowable=!1,a.syncErrorThrown))throw a.syncErrorValue;return a},t.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){u.v.useDeprecatedSynchronousErrorHandling&&(t.syncErrorThrown=!0,t.syncErrorValue=e),(0,r._)(t)?t.error(e):console.warn(e)}},t.prototype.forEach=function(t,e){var n=this;return new(e=l(e))((function(e,r){var i;i=n.subscribe((function(e){try{t(e)}catch(t){r(t),i&&i.unsubscribe()}}),r,e)}))},t.prototype._subscribe=function(t){var e=this.source;return e&&e.subscribe(t)},t.prototype[a.L]=function(){return this},t.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return 0===t.length?this:(0,c.U)(t)(this)},t.prototype.toPromise=function(t){var e=this;return new(t=l(t))((function(t,n){var r;e.subscribe((function(t){return r=t}),(function(t){return n(t)}),(function(){return t(r)}))}))},t.create=function(e){return new t(e)},t}();function l(t){if(t||(t=u.v.Promise||Promise),!t)throw new Error("no Promise impl found");return t}},2174:(t,e,n)=>{"use strict";n.d(e,{c:()=>s});var r=n(150),i=n(1644),s={closed:!0,next:function(t){},error:function(t){if(r.v.useDeprecatedSynchronousErrorHandling)throw t;(0,i.z)(t)},complete:function(){}}},2039:(t,e,n)=>{"use strict";n.d(e,{L:()=>i});var r=n(5987),i=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r.ZT(e,t),e.prototype.notifyNext=function(t,e,n,r,i){this.destination.next(e)},e.prototype.notifyError=function(t,e){this.destination.error(t)},e.prototype.notifyComplete=function(t){this.destination.complete()},e}(n(979).L)},2630:(t,e,n)=>{"use strict";n.d(e,{t:()=>h});var r=n(5987),i=n(211),s=n(2546),o=n(8760),a=n(9276),c=n(1016),u=n(8253),h=function(t){function e(e,n,r){void 0===e&&(e=Number.POSITIVE_INFINITY),void 0===n&&(n=Number.POSITIVE_INFINITY);var i=t.call(this)||this;return i.scheduler=r,i._events=[],i._infiniteTimeWindow=!1,i._bufferSize=e<1?1:e,i._windowTime=n<1?1:n,n===Number.POSITIVE_INFINITY?(i._infiniteTimeWindow=!0,i.next=i.nextInfiniteTimeWindow):i.next=i.nextTimeWindow,i}return r.ZT(e,t),e.prototype.nextInfiniteTimeWindow=function(e){if(!this.isStopped){var n=this._events;n.push(e),n.length>this._bufferSize&&n.shift()}t.prototype.next.call(this,e)},e.prototype.nextTimeWindow=function(e){this.isStopped||(this._events.push(new l(this._getNow(),e)),this._trimBufferThenGetEvents()),t.prototype.next.call(this,e)},e.prototype._subscribe=function(t){var e,n=this._infiniteTimeWindow,r=n?this._events:this._trimBufferThenGetEvents(),i=this.scheduler,s=r.length;if(this.closed)throw new c.N;if(this.isStopped||this.hasError?e=o.w.EMPTY:(this.observers.push(t),e=new u.W(this,t)),i&&t.add(t=new a.ht(t,i)),n)for(var h=0;h<s&&!t.closed;h++)t.next(r[h]);else for(h=0;h<s&&!t.closed;h++)t.next(r[h].value);return this.hasError?t.error(this.thrownError):this.isStopped&&t.complete(),e},e.prototype._getNow=function(){return(this.scheduler||s.c).now()},e.prototype._trimBufferThenGetEvents=function(){for(var t=this._getNow(),e=this._bufferSize,n=this._windowTime,r=this._events,i=r.length,s=0;s<i&&!(t-r[s].time<n);)s++;return i>e&&(s=Math.max(s,i-e)),s>0&&r.splice(0,s),r},e}(i.xQ),l=function(){return function(t,e){this.time=t,this.value=e}}()},8725:(t,e,n)=>{"use strict";n.d(e,{b:()=>r});var r=function(){function t(e,n){void 0===n&&(n=t.now),this.SchedulerAction=e,this.now=n}return t.prototype.schedule=function(t,e,n){return void 0===e&&(e=0),new this.SchedulerAction(this,t).schedule(n,e)},t.now=function(){return Date.now()},t}()},211:(t,e,n)=>{"use strict";n.d(e,{Yc:()=>h,xQ:()=>l});var r=n(5987),i=n(2772),s=n(979),o=n(8760),a=n(1016),c=n(8253),u=n(3142),h=function(t){function e(e){var n=t.call(this,e)||this;return n.destination=e,n}return r.ZT(e,t),e}(s.L),l=function(t){function e(){var e=t.call(this)||this;return e.observers=[],e.closed=!1,e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return r.ZT(e,t),e.prototype[u.b]=function(){return new h(this)},e.prototype.lift=function(t){var e=new d(this,this);return e.operator=t,e},e.prototype.next=function(t){if(this.closed)throw new a.N;if(!this.isStopped)for(var e=this.observers,n=e.length,r=e.slice(),i=0;i<n;i++)r[i].next(t)},e.prototype.error=function(t){if(this.closed)throw new a.N;this.hasError=!0,this.thrownError=t,this.isStopped=!0;for(var e=this.observers,n=e.length,r=e.slice(),i=0;i<n;i++)r[i].error(t);this.observers.length=0},e.prototype.complete=function(){if(this.closed)throw new a.N;this.isStopped=!0;for(var t=this.observers,e=t.length,n=t.slice(),r=0;r<e;r++)n[r].complete();this.observers.length=0},e.prototype.unsubscribe=function(){this.isStopped=!0,this.closed=!0,this.observers=null},e.prototype._trySubscribe=function(e){if(this.closed)throw new a.N;return t.prototype._trySubscribe.call(this,e)},e.prototype._subscribe=function(t){if(this.closed)throw new a.N;return this.hasError?(t.error(this.thrownError),o.w.EMPTY):this.isStopped?(t.complete(),o.w.EMPTY):(this.observers.push(t),new c.W(this,t))},e.prototype.asObservable=function(){var t=new i.y;return t.source=this,t},e.create=function(t,e){return new d(t,e)},e}(i.y),d=function(t){function e(e,n){var r=t.call(this)||this;return r.destination=e,r.source=n,r}return r.ZT(e,t),e.prototype.next=function(t){var e=this.destination;e&&e.next&&e.next(t)},e.prototype.error=function(t){var e=this.destination;e&&e.error&&this.destination.error(t)},e.prototype.complete=function(){var t=this.destination;t&&t.complete&&this.destination.complete()},e.prototype._subscribe=function(t){return this.source?this.source.subscribe(t):o.w.EMPTY},e}(l)},8253:(t,e,n)=>{"use strict";n.d(e,{W:()=>i});var r=n(5987),i=function(t){function e(e,n){var r=t.call(this)||this;return r.subject=e,r.subscriber=n,r.closed=!1,r}return r.ZT(e,t),e.prototype.unsubscribe=function(){if(!this.closed){this.closed=!0;var t=this.subject,e=t.observers;if(this.subject=null,e&&0!==e.length&&!t.isStopped&&!t.closed){var n=e.indexOf(this.subscriber);-1!==n&&e.splice(n,1)}}},e}(n(8760).w)},979:(t,e,n)=>{"use strict";n.d(e,{L:()=>h});var r=n(5987),i=n(4156),s=n(2174),o=n(8760),a=n(3142),c=n(150),u=n(1644),h=function(t){function e(n,r,i){var o=t.call(this)||this;switch(o.syncErrorValue=null,o.syncErrorThrown=!1,o.syncErrorThrowable=!1,o.isStopped=!1,arguments.length){case 0:o.destination=s.c;break;case 1:if(!n){o.destination=s.c;break}if("object"==typeof n){n instanceof e?(o.syncErrorThrowable=n.syncErrorThrowable,o.destination=n,n.add(o)):(o.syncErrorThrowable=!0,o.destination=new l(o,n));break}default:o.syncErrorThrowable=!0,o.destination=new l(o,n,r,i)}return o}return r.ZT(e,t),e.prototype[a.b]=function(){return this},e.create=function(t,n,r){var i=new e(t,n,r);return i.syncErrorThrowable=!1,i},e.prototype.next=function(t){this.isStopped||this._next(t)},e.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this))},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){this.destination.error(t),this.unsubscribe()},e.prototype._complete=function(){this.destination.complete(),this.unsubscribe()},e.prototype._unsubscribeAndRecycle=function(){var t=this._parentOrParents;return this._parentOrParents=null,this.unsubscribe(),this.closed=!1,this.isStopped=!1,this._parentOrParents=t,this},e}(o.w),l=function(t){function e(e,n,r,o){var a,c=t.call(this)||this;c._parentSubscriber=e;var u=c;return(0,i.m)(n)?a=n:n&&(a=n.next,r=n.error,o=n.complete,n!==s.c&&(u=Object.create(n),(0,i.m)(u.unsubscribe)&&c.add(u.unsubscribe.bind(u)),u.unsubscribe=c.unsubscribe.bind(c))),c._context=u,c._next=a,c._error=r,c._complete=o,c}return r.ZT(e,t),e.prototype.next=function(t){if(!this.isStopped&&this._next){var e=this._parentSubscriber;c.v.useDeprecatedSynchronousErrorHandling&&e.syncErrorThrowable?this.__tryOrSetError(e,this._next,t)&&this.unsubscribe():this.__tryOrUnsub(this._next,t)}},e.prototype.error=function(t){if(!this.isStopped){var e=this._parentSubscriber,n=c.v.useDeprecatedSynchronousErrorHandling;if(this._error)n&&e.syncErrorThrowable?(this.__tryOrSetError(e,this._error,t),this.unsubscribe()):(this.__tryOrUnsub(this._error,t),this.unsubscribe());else if(e.syncErrorThrowable)n?(e.syncErrorValue=t,e.syncErrorThrown=!0):(0,u.z)(t),this.unsubscribe();else{if(this.unsubscribe(),n)throw t;(0,u.z)(t)}}},e.prototype.complete=function(){var t=this;if(!this.isStopped){var e=this._parentSubscriber;if(this._complete){var n=function(){return t._complete.call(t._context)};c.v.useDeprecatedSynchronousErrorHandling&&e.syncErrorThrowable?(this.__tryOrSetError(e,n),this.unsubscribe()):(this.__tryOrUnsub(n),this.unsubscribe())}else this.unsubscribe()}},e.prototype.__tryOrUnsub=function(t,e){try{t.call(this._context,e)}catch(t){if(this.unsubscribe(),c.v.useDeprecatedSynchronousErrorHandling)throw t;(0,u.z)(t)}},e.prototype.__tryOrSetError=function(t,e,n){if(!c.v.useDeprecatedSynchronousErrorHandling)throw new Error("bad call");try{e.call(this._context,n)}catch(e){return c.v.useDeprecatedSynchronousErrorHandling?(t.syncErrorValue=e,t.syncErrorThrown=!0,!0):((0,u.z)(e),!0)}return!1},e.prototype._unsubscribe=function(){var t=this._parentSubscriber;this._context=null,this._parentSubscriber=null,t.unsubscribe()},e}(h)},8760:(t,e,n)=>{"use strict";n.d(e,{w:()=>a});var r=n(9026),i=n(2009),s=n(4156),o=n(8782),a=function(){function t(t){this.closed=!1,this._parentOrParents=null,this._subscriptions=null,t&&(this._ctorUnsubscribe=!0,this._unsubscribe=t)}var e;return t.prototype.unsubscribe=function(){var e;if(!this.closed){var n=this,a=n._parentOrParents,u=n._ctorUnsubscribe,h=n._unsubscribe,l=n._subscriptions;if(this.closed=!0,this._parentOrParents=null,this._subscriptions=null,a instanceof t)a.remove(this);else if(null!==a)for(var d=0;d<a.length;++d)a[d].remove(this);if((0,s.m)(h)){u&&(this._unsubscribe=void 0);try{h.call(this)}catch(t){e=t instanceof o.B?c(t.errors):[t]}}if((0,r.k)(l)){d=-1;for(var f=l.length;++d<f;){var p=l[d];if((0,i.K)(p))try{p.unsubscribe()}catch(t){e=e||[],t instanceof o.B?e=e.concat(c(t.errors)):e.push(t)}}}if(e)throw new o.B(e)}},t.prototype.add=function(e){var n=e;if(!e)return t.EMPTY;switch(typeof e){case"function":n=new t(e);case"object":if(n===this||n.closed||"function"!=typeof n.unsubscribe)return n;if(this.closed)return n.unsubscribe(),n;if(!(n instanceof t)){var r=n;(n=new t)._subscriptions=[r]}break;default:throw new Error("unrecognized teardown "+e+" added to Subscription.")}var i=n._parentOrParents;if(null===i)n._parentOrParents=this;else if(i instanceof t){if(i===this)return n;n._parentOrParents=[i,this]}else{if(-1!==i.indexOf(this))return n;i.push(this)}var s=this._subscriptions;return null===s?this._subscriptions=[n]:s.push(n),n},t.prototype.remove=function(t){var e=this._subscriptions;if(e){var n=e.indexOf(t);-1!==n&&e.splice(n,1)}},t.EMPTY=((e=new t).closed=!0,e),t}();function c(t){return t.reduce((function(t,e){return t.concat(e instanceof o.B?e.errors:e)}),[])}},150:(t,e,n)=>{"use strict";n.d(e,{v:()=>i});var r=!1,i={Promise:void 0,set useDeprecatedSynchronousErrorHandling(t){t&&(new Error).stack,r=t},get useDeprecatedSynchronousErrorHandling(){return r}}},7604:(t,e,n)=>{"use strict";n.d(e,{IY:()=>a,Ds:()=>c,ft:()=>u});var r=n(5987),i=n(979),s=n(2772),o=n(7843),a=function(t){function e(e){var n=t.call(this)||this;return n.parent=e,n}return r.ZT(e,t),e.prototype._next=function(t){this.parent.notifyNext(t)},e.prototype._error=function(t){this.parent.notifyError(t),this.unsubscribe()},e.prototype._complete=function(){this.parent.notifyComplete(),this.unsubscribe()},e}(i.L),c=(i.L,function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r.ZT(e,t),e.prototype.notifyNext=function(t){this.destination.next(t)},e.prototype.notifyError=function(t){this.destination.error(t)},e.prototype.notifyComplete=function(){this.destination.complete()},e}(i.L));function u(t,e){if(!e.closed)return t instanceof s.y?t.subscribe(e):(0,o.s)(t)(e)}i.L},3140:(t,e,n)=>{"use strict";n.d(e,{c:()=>u,N:()=>h});var r=n(5987),i=n(211),s=n(2772),o=n(979),a=n(8760),c=n(3018),u=function(t){function e(e,n){var r=t.call(this)||this;return r.source=e,r.subjectFactory=n,r._refCount=0,r._isComplete=!1,r}return r.ZT(e,t),e.prototype._subscribe=function(t){return this.getSubject().subscribe(t)},e.prototype.getSubject=function(){var t=this._subject;return t&&!t.isStopped||(this._subject=this.subjectFactory()),this._subject},e.prototype.connect=function(){var t=this._connection;return t||(this._isComplete=!1,(t=this._connection=new a.w).add(this.source.subscribe(new l(this.getSubject(),this))),t.closed&&(this._connection=null,t=a.w.EMPTY)),t},e.prototype.refCount=function(){return(0,c.x)()(this)},e}(s.y),h=function(){var t=u.prototype;return{operator:{value:null},_refCount:{value:0,writable:!0},_subject:{value:null,writable:!0},_connection:{value:null,writable:!0},_subscribe:{value:t._subscribe},_isComplete:{value:t._isComplete,writable:!0},getSubject:{value:t.getSubject},connect:{value:t.connect},refCount:{value:t.refCount}}}(),l=function(t){function e(e,n){var r=t.call(this,e)||this;return r.connectable=n,r}return r.ZT(e,t),e.prototype._error=function(e){this._unsubscribe(),t.prototype._error.call(this,e)},e.prototype._complete=function(){this.connectable._isComplete=!0,this._unsubscribe(),t.prototype._complete.call(this)},e.prototype._unsubscribe=function(){var t=this.connectable;if(t){this.connectable=null;var e=t._connection;t._refCount=0,t._subject=null,t._connection=null,e&&e.unsubscribe()}},e}(i.Yc);o.L},5142:(t,e,n)=>{"use strict";n.d(e,{aj:()=>h,Ms:()=>l});var r=n(5987),i=n(7507),s=n(9026),o=n(2039),a=n(2080),c=n(3375),u={};function h(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=void 0,r=void 0;return(0,i.K)(t[t.length-1])&&(r=t.pop()),"function"==typeof t[t.length-1]&&(n=t.pop()),1===t.length&&(0,s.k)(t[0])&&(t=t[0]),(0,c.n)(t,r).lift(new l(n))}var l=function(){function t(t){this.resultSelector=t}return t.prototype.call=function(t,e){return e.subscribe(new d(t,this.resultSelector))},t}(),d=function(t){function e(e,n){var r=t.call(this,e)||this;return r.resultSelector=n,r.active=0,r.values=[],r.observables=[],r}return r.ZT(e,t),e.prototype._next=function(t){this.values.push(u),this.observables.push(t)},e.prototype._complete=function(){var t=this.observables,e=t.length;if(0===e)this.destination.complete();else{this.active=e,this.toRespond=e;for(var n=0;n<e;n++){var r=t[n];this.add((0,a.D)(this,r,void 0,n))}}},e.prototype.notifyComplete=function(t){0==(this.active-=1)&&this.destination.complete()},e.prototype.notifyNext=function(t,e,n){var r=this.values,i=r[n],s=this.toRespond?i===u?--this.toRespond:this.toRespond:0;r[n]=e,0===s&&(this.resultSelector?this._tryResultSelector(r):this.destination.next(r.slice()))},e.prototype._tryResultSelector=function(t){var e;try{e=this.resultSelector.apply(this,t)}catch(t){return void this.destination.error(t)}this.destination.next(e)},e}(o.L)},9795:(t,e,n)=>{"use strict";n.d(e,{z:()=>s});var r=n(8170),i=n(2257);function s(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return(0,i.u)()(r.of.apply(void 0,t))}},1410:(t,e,n)=>{"use strict";n.d(e,{P:()=>o});var r=n(2772),i=n(5760),s=n(5631);function o(t){return new r.y((function(e){var n;try{n=t()}catch(t){return void e.error(t)}return(n?(0,i.D)(n):(0,s.c)()).subscribe(e)}))}},5631:(t,e,n)=>{"use strict";n.d(e,{E:()=>i,c:()=>s});var r=n(2772),i=new r.y((function(t){return t.complete()}));function s(t){return t?function(t){return new r.y((function(e){return t.schedule((function(){return e.complete()}))}))}(t):i}},5760:(t,e,n)=>{"use strict";n.d(e,{D:()=>o});var r=n(2772),i=n(7843),s=n(8107);function o(t,e){return e?(0,s.x)(t,e):t instanceof r.y?t:new r.y((0,i.s)(t))}},3375:(t,e,n)=>{"use strict";n.d(e,{n:()=>o});var r=n(2772),i=n(6900),s=n(3109);function o(t,e){return e?(0,s.r)(t,e):new r.y((0,i.V)(t))}},4370:(t,e,n)=>{"use strict";n.d(e,{T:()=>a});var r=n(2772),i=n(7507),s=n(2556),o=n(3375);function a(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=Number.POSITIVE_INFINITY,a=null,c=t[t.length-1];return(0,i.K)(c)?(a=t.pop(),t.length>1&&"number"==typeof t[t.length-1]&&(n=t.pop())):"number"==typeof c&&(n=t.pop()),null===a&&1===t.length&&t[0]instanceof r.y?t[0]:(0,s.J)(n)((0,o.n)(t,a))}},8170:(t,e,n)=>{"use strict";n.d(e,{of:()=>o});var r=n(7507),i=n(3375),s=n(3109);function o(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=t[t.length-1];return(0,r.K)(n)?(t.pop(),(0,s.r)(t,n)):(0,i.n)(t)}},8821:(t,e,n)=>{"use strict";n.d(e,{S3:()=>c});var r=n(5987),i=n(9026),s=n(3375),o=n(2039),a=n(2080);function c(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(1===t.length){if(!(0,i.k)(t[0]))return t[0];t=t[0]}return(0,s.n)(t,void 0).lift(new u)}var u=function(){function t(){}return t.prototype.call=function(t,e){return e.subscribe(new h(t))},t}(),h=function(t){function e(e){var n=t.call(this,e)||this;return n.hasFirst=!1,n.observables=[],n.subscriptions=[],n}return r.ZT(e,t),e.prototype._next=function(t){this.observables.push(t)},e.prototype._complete=function(){var t=this.observables,e=t.length;if(0===e)this.destination.complete();else{for(var n=0;n<e&&!this.hasFirst;n++){var r=t[n],i=(0,a.D)(this,r,void 0,n);this.subscriptions&&this.subscriptions.push(i),this.add(i)}this.observables=null}},e.prototype.notifyNext=function(t,e,n){if(!this.hasFirst){this.hasFirst=!0;for(var r=0;r<this.subscriptions.length;r++)if(r!==n){var i=this.subscriptions[r];i.unsubscribe(),this.remove(i)}this.subscriptions=null}this.destination.next(e)},e}(o.L)},4944:(t,e,n)=>{"use strict";n.d(e,{_:()=>i});var r=n(2772);function i(t,e){return e?new r.y((function(n){return e.schedule(s,0,{error:t,subscriber:n})})):new r.y((function(e){return e.error(t)}))}function s(t){var e=t.error;t.subscriber.error(e)}},9604:(t,e,n)=>{"use strict";n.d(e,{H:()=>a});var r=n(2772),i=n(964),s=n(5812),o=n(7507);function a(t,e,n){void 0===t&&(t=0);var a=-1;return(0,s.k)(e)?a=Number(e)<1?1:Number(e):(0,o.K)(e)&&(n=e),(0,o.K)(n)||(n=i.P),new r.y((function(e){var r=(0,s.k)(t)?t:+t-n.now();return n.schedule(c,r,{index:0,period:a,subscriber:e})}))}function c(t){var e=t.index,n=t.period,r=t.subscriber;if(r.next(e),!r.closed){if(-1===n)return r.complete();t.index=e+1,this.schedule(t,n)}}},5080:(t,e,n)=>{"use strict";n.d(e,{$R:()=>u,mx:()=>h});var r=n(5987),i=n(3375),s=n(9026),o=n(979),a=n(999),c=n(7604);function u(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=t[t.length-1];return"function"==typeof n&&t.pop(),(0,i.n)(t,void 0).lift(new h(n))}var h=function(){function t(t){this.resultSelector=t}return t.prototype.call=function(t,e){return e.subscribe(new l(t,this.resultSelector))},t}(),l=function(t){function e(e,n,r){void 0===r&&(r=Object.create(null));var i=t.call(this,e)||this;return i.resultSelector=n,i.iterators=[],i.active=0,i.resultSelector="function"==typeof n?n:void 0,i}return r.ZT(e,t),e.prototype._next=function(t){var e=this.iterators;(0,s.k)(t)?e.push(new f(t)):"function"==typeof t[a.hZ]?e.push(new d(t[a.hZ]())):e.push(new p(this.destination,this,t))},e.prototype._complete=function(){var t=this.iterators,e=t.length;if(this.unsubscribe(),0!==e){this.active=e;for(var n=0;n<e;n++){var r=t[n];r.stillUnsubscribed?this.destination.add(r.subscribe()):this.active--}}else this.destination.complete()},e.prototype.notifyInactive=function(){this.active--,0===this.active&&this.destination.complete()},e.prototype.checkIterators=function(){for(var t=this.iterators,e=t.length,n=this.destination,r=0;r<e;r++)if("function"==typeof(o=t[r]).hasValue&&!o.hasValue())return;var i=!1,s=[];for(r=0;r<e;r++){var o,a=(o=t[r]).next();if(o.hasCompleted()&&(i=!0),a.done)return void n.complete();s.push(a.value)}this.resultSelector?this._tryresultSelector(s):n.next(s),i&&n.complete()},e.prototype._tryresultSelector=function(t){var e;try{e=this.resultSelector.apply(this,t)}catch(t){return void this.destination.error(t)}this.destination.next(e)},e}(o.L),d=function(){function t(t){this.iterator=t,this.nextResult=t.next()}return t.prototype.hasValue=function(){return!0},t.prototype.next=function(){var t=this.nextResult;return this.nextResult=this.iterator.next(),t},t.prototype.hasCompleted=function(){var t=this.nextResult;return Boolean(t&&t.done)},t}(),f=function(){function t(t){this.array=t,this.index=0,this.length=0,this.length=t.length}return t.prototype[a.hZ]=function(){return this},t.prototype.next=function(t){var e=this.index++,n=this.array;return e<this.length?{value:n[e],done:!1}:{value:null,done:!0}},t.prototype.hasValue=function(){return this.array.length>this.index},t.prototype.hasCompleted=function(){return this.array.length===this.index},t}(),p=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.parent=n,i.observable=r,i.stillUnsubscribed=!0,i.buffer=[],i.isComplete=!1,i}return r.ZT(e,t),e.prototype[a.hZ]=function(){return this},e.prototype.next=function(){var t=this.buffer;return 0===t.length&&this.isComplete?{value:null,done:!0}:{value:t.shift(),done:!1}},e.prototype.hasValue=function(){return this.buffer.length>0},e.prototype.hasCompleted=function(){return 0===this.buffer.length&&this.isComplete},e.prototype.notifyComplete=function(){this.buffer.length>0?(this.isComplete=!0,this.parent.notifyInactive()):this.destination.complete()},e.prototype.notifyNext=function(t){this.buffer.push(t),this.parent.checkIterators()},e.prototype.subscribe=function(){return(0,c.ft)(this.observable,new c.IY(this))},e}(c.Ds)},2257:(t,e,n)=>{"use strict";n.d(e,{u:()=>i});var r=n(2556);function i(){return(0,r.J)(1)}},6008:(t,e,n)=>{"use strict";n.d(e,{h:()=>s});var r=n(5987),i=n(979);function s(t,e){return function(n){return n.lift(new o(t,e))}}var o=function(){function t(t,e){this.predicate=t,this.thisArg=e}return t.prototype.call=function(t,e){return e.subscribe(new a(t,this.predicate,this.thisArg))},t}(),a=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.predicate=n,i.thisArg=r,i.count=0,i}return r.ZT(e,t),e.prototype._next=function(t){var e;try{e=this.predicate.call(this.thisArg,t,this.count++)}catch(t){return void this.destination.error(t)}e&&this.destination.next(t)},e}(i.L)},1120:(t,e,n)=>{"use strict";n.d(e,{v:()=>c,T:()=>d});var r=n(5987),i=n(979),s=n(8760),o=n(2772),a=n(211);function c(t,e,n,r){return function(i){return i.lift(new u(t,e,n,r))}}var u=function(){function t(t,e,n,r){this.keySelector=t,this.elementSelector=e,this.durationSelector=n,this.subjectSelector=r}return t.prototype.call=function(t,e){return e.subscribe(new h(t,this.keySelector,this.elementSelector,this.durationSelector,this.subjectSelector))},t}(),h=function(t){function e(e,n,r,i,s){var o=t.call(this,e)||this;return o.keySelector=n,o.elementSelector=r,o.durationSelector=i,o.subjectSelector=s,o.groups=null,o.attemptedToUnsubscribe=!1,o.count=0,o}return r.ZT(e,t),e.prototype._next=function(t){var e;try{e=this.keySelector(t)}catch(t){return void this.error(t)}this._group(t,e)},e.prototype._group=function(t,e){var n=this.groups;n||(n=this.groups=new Map);var r,i=n.get(e);if(this.elementSelector)try{r=this.elementSelector(t)}catch(t){this.error(t)}else r=t;if(!i){i=this.subjectSelector?this.subjectSelector():new a.xQ,n.set(e,i);var s=new d(e,i,this);if(this.destination.next(s),this.durationSelector){var o=void 0;try{o=this.durationSelector(new d(e,i))}catch(t){return void this.error(t)}this.add(o.subscribe(new l(e,i,this)))}}i.closed||i.next(r)},e.prototype._error=function(t){var e=this.groups;e&&(e.forEach((function(e,n){e.error(t)})),e.clear()),this.destination.error(t)},e.prototype._complete=function(){var t=this.groups;t&&(t.forEach((function(t,e){t.complete()})),t.clear()),this.destination.complete()},e.prototype.removeGroup=function(t){this.groups.delete(t)},e.prototype.unsubscribe=function(){this.closed||(this.attemptedToUnsubscribe=!0,0===this.count&&t.prototype.unsubscribe.call(this))},e}(i.L),l=function(t){function e(e,n,r){var i=t.call(this,n)||this;return i.key=e,i.group=n,i.parent=r,i}return r.ZT(e,t),e.prototype._next=function(t){this.complete()},e.prototype._unsubscribe=function(){var t=this.parent,e=this.key;this.key=this.parent=null,t&&t.removeGroup(e)},e}(i.L),d=function(t){function e(e,n,r){var i=t.call(this)||this;return i.key=e,i.groupSubject=n,i.refCountSubscription=r,i}return r.ZT(e,t),e.prototype._subscribe=function(t){var e=new s.w,n=this.refCountSubscription,r=this.groupSubject;return n&&!n.closed&&e.add(new f(n)),e.add(r.subscribe(t)),e},e}(o.y),f=function(t){function e(e){var n=t.call(this)||this;return n.parent=e,e.count++,n}return r.ZT(e,t),e.prototype.unsubscribe=function(){var e=this.parent;e.closed||this.closed||(t.prototype.unsubscribe.call(this),e.count-=1,0===e.count&&e.attemptedToUnsubscribe&&e.unsubscribe())},e}(s.w)},5709:(t,e,n)=>{"use strict";n.d(e,{U:()=>s});var r=n(5987),i=n(979);function s(t,e){return function(n){if("function"!=typeof t)throw new TypeError("argument is not a function. Are you looking for `mapTo()`?");return n.lift(new o(t,e))}}var o=function(){function t(t,e){this.project=t,this.thisArg=e}return t.prototype.call=function(t,e){return e.subscribe(new a(t,this.project,this.thisArg))},t}(),a=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.project=n,i.count=0,i.thisArg=r||i,i}return r.ZT(e,t),e.prototype._next=function(t){var e;try{e=this.project.call(this.thisArg,t,this.count++)}catch(t){return void this.destination.error(t)}this.destination.next(e)},e}(i.L)},2556:(t,e,n)=>{"use strict";n.d(e,{J:()=>s});var r=n(7746),i=n(3608);function s(t){return void 0===t&&(t=Number.POSITIVE_INFINITY),(0,r.zg)(i.y,t)}},7746:(t,e,n)=>{"use strict";n.d(e,{zg:()=>a,VS:()=>h});var r=n(5987),i=n(5709),s=n(5760),o=n(7604);function a(t,e,n){return void 0===n&&(n=Number.POSITIVE_INFINITY),"function"==typeof e?function(r){return r.pipe(a((function(n,r){return(0,s.D)(t(n,r)).pipe((0,i.U)((function(t,i){return e(n,t,r,i)})))}),n))}:("number"==typeof e&&(n=e),function(e){return e.lift(new c(t,n))})}var c=function(){function t(t,e){void 0===e&&(e=Number.POSITIVE_INFINITY),this.project=t,this.concurrent=e}return t.prototype.call=function(t,e){return e.subscribe(new u(t,this.project,this.concurrent))},t}(),u=function(t){function e(e,n,r){void 0===r&&(r=Number.POSITIVE_INFINITY);var i=t.call(this,e)||this;return i.project=n,i.concurrent=r,i.hasCompleted=!1,i.buffer=[],i.active=0,i.index=0,i}return r.ZT(e,t),e.prototype._next=function(t){this.active<this.concurrent?this._tryNext(t):this.buffer.push(t)},e.prototype._tryNext=function(t){var e,n=this.index++;try{e=this.project(t,n)}catch(t){return void this.destination.error(t)}this.active++,this._innerSub(e)},e.prototype._innerSub=function(t){var e=new o.IY(this),n=this.destination;n.add(e);var r=(0,o.ft)(t,e);r!==e&&n.add(r)},e.prototype._complete=function(){this.hasCompleted=!0,0===this.active&&0===this.buffer.length&&this.destination.complete(),this.unsubscribe()},e.prototype.notifyNext=function(t){this.destination.next(t)},e.prototype.notifyComplete=function(){var t=this.buffer;this.active--,t.length>0?this._next(t.shift()):0===this.active&&this.hasCompleted&&this.destination.complete()},e}(o.Ds),h=a},9276:(t,e,n)=>{"use strict";n.d(e,{QV:()=>o,ht:()=>c});var r=n(5987),i=n(979),s=n(2632);function o(t,e){return void 0===e&&(e=0),function(n){return n.lift(new a(t,e))}}var a=function(){function t(t,e){void 0===e&&(e=0),this.scheduler=t,this.delay=e}return t.prototype.call=function(t,e){return e.subscribe(new c(t,this.scheduler,this.delay))},t}(),c=function(t){function e(e,n,r){void 0===r&&(r=0);var i=t.call(this,e)||this;return i.scheduler=n,i.delay=r,i}return r.ZT(e,t),e.dispatch=function(t){var e=t.notification,n=t.destination;e.observe(n),this.unsubscribe()},e.prototype.scheduleMessage=function(t){this.destination.add(this.scheduler.schedule(e.dispatch,this.delay,new u(t,this.destination)))},e.prototype._next=function(t){this.scheduleMessage(s.P.createNext(t))},e.prototype._error=function(t){this.scheduleMessage(s.P.createError(t)),this.unsubscribe()},e.prototype._complete=function(){this.scheduleMessage(s.P.createComplete()),this.unsubscribe()},e}(i.L),u=function(){return function(t,e){this.notification=t,this.destination=e}}()},3018:(t,e,n)=>{"use strict";n.d(e,{x:()=>s});var r=n(5987),i=n(979);function s(){return function(t){return t.lift(new o(t))}}var o=function(){function t(t){this.connectable=t}return t.prototype.call=function(t,e){var n=this.connectable;n._refCount++;var r=new a(t,n),i=e.subscribe(r);return r.closed||(r.connection=n.connect()),i},t}(),a=function(t){function e(e,n){var r=t.call(this,e)||this;return r.connectable=n,r}return r.ZT(e,t),e.prototype._unsubscribe=function(){var t=this.connectable;if(t){this.connectable=null;var e=t._refCount;if(e<=0)this.connection=null;else if(t._refCount=e-1,e>1)this.connection=null;else{var n=this.connection,r=t._connection;this.connection=null,!r||n&&r!==n||r.unsubscribe()}}else this.connection=null},e}(i.L)},3109:(t,e,n)=>{"use strict";n.d(e,{r:()=>s});var r=n(2772),i=n(8760);function s(t,e){return new r.y((function(n){var r=new i.w,s=0;return r.add(e.schedule((function(){s!==t.length?(n.next(t[s++]),n.closed||r.add(this.schedule())):n.complete()}))),r}))}},8107:(t,e,n)=>{"use strict";n.d(e,{x:()=>h});var r=n(2772),i=n(8760),s=n(5050),o=n(3109),a=n(999),c=n(336),u=n(9217);function h(t,e){if(null!=t){if(function(t){return t&&"function"==typeof t[s.L]}(t))return function(t,e){return new r.y((function(n){var r=new i.w;return r.add(e.schedule((function(){var i=t[s.L]();r.add(i.subscribe({next:function(t){r.add(e.schedule((function(){return n.next(t)})))},error:function(t){r.add(e.schedule((function(){return n.error(t)})))},complete:function(){r.add(e.schedule((function(){return n.complete()})))}}))}))),r}))}(t,e);if((0,c.t)(t))return function(t,e){return new r.y((function(n){var r=new i.w;return r.add(e.schedule((function(){return t.then((function(t){r.add(e.schedule((function(){n.next(t),r.add(e.schedule((function(){return n.complete()})))})))}),(function(t){r.add(e.schedule((function(){return n.error(t)})))}))}))),r}))}(t,e);if((0,u.z)(t))return(0,o.r)(t,e);if(function(t){return t&&"function"==typeof t[a.hZ]}(t)||"string"==typeof t)return function(t,e){if(!t)throw new Error("Iterable cannot be null");return new r.y((function(n){var r,s=new i.w;return s.add((function(){r&&"function"==typeof r.return&&r.return()})),s.add(e.schedule((function(){r=t[a.hZ](),s.add(e.schedule((function(){if(!n.closed){var t,e;try{var i=r.next();t=i.value,e=i.done}catch(t){return void n.error(t)}e?n.complete():(n.next(t),this.schedule())}})))}))),s}))}(t,e)}throw new TypeError((null!==t&&typeof t||t)+" is not observable")}},6114:(t,e,n)=>{"use strict";n.d(e,{o:()=>i});var r=n(5987),i=function(t){function e(e,n){var r=t.call(this,e,n)||this;return r.scheduler=e,r.work=n,r.pending=!1,r}return r.ZT(e,t),e.prototype.schedule=function(t,e){if(void 0===e&&(e=0),this.closed)return this;this.state=t;var n=this.id,r=this.scheduler;return null!=n&&(this.id=this.recycleAsyncId(r,n,e)),this.pending=!0,this.delay=e,this.id=this.id||this.requestAsyncId(r,this.id,e),this},e.prototype.requestAsyncId=function(t,e,n){return void 0===n&&(n=0),setInterval(t.flush.bind(t,this),n)},e.prototype.recycleAsyncId=function(t,e,n){if(void 0===n&&(n=0),null!==n&&this.delay===n&&!1===this.pending)return e;clearInterval(e)},e.prototype.execute=function(t,e){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var n=this._execute(t,e);if(n)return n;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(t,e){var n=!1,r=void 0;try{this.work(t)}catch(t){n=!0,r=!!t&&t||new Error(t)}if(n)return this.unsubscribe(),r},e.prototype._unsubscribe=function(){var t=this.id,e=this.scheduler,n=e.actions,r=n.indexOf(this);this.work=null,this.state=null,this.pending=!1,this.scheduler=null,-1!==r&&n.splice(r,1),null!=t&&(this.id=this.recycleAsyncId(e,t,null)),this.delay=null},e}(function(t){function e(e,n){return t.call(this)||this}return r.ZT(e,t),e.prototype.schedule=function(t,e){return void 0===e&&(e=0),this},e}(n(8760).w))},8399:(t,e,n)=>{"use strict";n.d(e,{v:()=>s});var r=n(5987),i=n(8725),s=function(t){function e(n,r){void 0===r&&(r=i.b.now);var s=t.call(this,n,(function(){return e.delegate&&e.delegate!==s?e.delegate.now():r()}))||this;return s.actions=[],s.active=!1,s.scheduled=void 0,s}return r.ZT(e,t),e.prototype.schedule=function(n,r,i){return void 0===r&&(r=0),e.delegate&&e.delegate!==this?e.delegate.schedule(n,r,i):t.prototype.schedule.call(this,n,r,i)},e.prototype.flush=function(t){var e=this.actions;if(this.active)e.push(t);else{var n;this.active=!0;do{if(n=t.execute(t.state,t.delay))break}while(t=e.shift());if(this.active=!1,n){for(;t=e.shift();)t.unsubscribe();throw n}}},e}(i.b)},6650:(t,e,n)=>{"use strict";n.d(e,{e:()=>l,E:()=>h});var r=n(5987),i=1,s=function(){return Promise.resolve()}(),o={};function a(t){return t in o&&(delete o[t],!0)}var c=function(t){function e(e,n){var r=t.call(this,e,n)||this;return r.scheduler=e,r.work=n,r}return r.ZT(e,t),e.prototype.requestAsyncId=function(e,n,r){return void 0===r&&(r=0),null!==r&&r>0?t.prototype.requestAsyncId.call(this,e,n,r):(e.actions.push(this),e.scheduled||(e.scheduled=(c=e.flush.bind(e,null),u=i++,o[u]=!0,s.then((function(){return a(u)&&c()})),u)));var c,u},e.prototype.recycleAsyncId=function(e,n,r){if(void 0===r&&(r=0),null!==r&&r>0||null===r&&this.delay>0)return t.prototype.recycleAsyncId.call(this,e,n,r);0===e.actions.length&&(a(n),e.scheduled=void 0)},e}(n(6114).o),u=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r.ZT(e,t),e.prototype.flush=function(t){this.active=!0,this.scheduled=void 0;var e,n=this.actions,r=-1,i=n.length;t=t||n.shift();do{if(e=t.execute(t.state,t.delay))break}while(++r<i&&(t=n.shift()));if(this.active=!1,e){for(;++r<i&&(t=n.shift());)t.unsubscribe();throw e}},e}(n(8399).v),h=new u(c),l=h},964:(t,e,n)=>{"use strict";n.d(e,{z:()=>i,P:()=>s});var r=n(6114),i=new(n(8399).v)(r.o),s=i},2546:(t,e,n)=>{"use strict";n.d(e,{c:()=>a,N:()=>o});var r=n(5987),i=function(t){function e(e,n){var r=t.call(this,e,n)||this;return r.scheduler=e,r.work=n,r}return r.ZT(e,t),e.prototype.schedule=function(e,n){return void 0===n&&(n=0),n>0?t.prototype.schedule.call(this,e,n):(this.delay=n,this.state=e,this.scheduler.flush(this),this)},e.prototype.execute=function(e,n){return n>0||this.closed?t.prototype.execute.call(this,e,n):this._execute(e,n)},e.prototype.requestAsyncId=function(e,n,r){return void 0===r&&(r=0),null!==r&&r>0||null===r&&this.delay>0?t.prototype.requestAsyncId.call(this,e,n,r):e.flush(this)},e}(n(6114).o),s=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r.ZT(e,t),e}(n(8399).v),o=new s(i),a=o},999:(t,e,n)=>{"use strict";function r(){return"function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator"}n.d(e,{hZ:()=>i});var i=r()},5050:(t,e,n)=>{"use strict";n.d(e,{L:()=>r});var r=function(){return"function"==typeof Symbol&&Symbol.observable||"@@observable"}()},3142:(t,e,n)=>{"use strict";n.d(e,{b:()=>r});var r=function(){return"function"==typeof Symbol?Symbol("rxSubscriber"):"@@rxSubscriber_"+Math.random()}()},6565:(t,e,n)=>{"use strict";n.d(e,{W:()=>r});var r=function(){function t(){return Error.call(this),this.message="argument out of range",this.name="ArgumentOutOfRangeError",this}return t.prototype=Object.create(Error.prototype),t}()},6929:(t,e,n)=>{"use strict";n.d(e,{K:()=>r});var r=function(){function t(){return Error.call(this),this.message="no elements in sequence",this.name="EmptyError",this}return t.prototype=Object.create(Error.prototype),t}()},1016:(t,e,n)=>{"use strict";n.d(e,{N:()=>r});var r=function(){function t(){return Error.call(this),this.message="object unsubscribed",this.name="ObjectUnsubscribedError",this}return t.prototype=Object.create(Error.prototype),t}()},1462:(t,e,n)=>{"use strict";n.d(e,{W:()=>r});var r=function(){function t(){return Error.call(this),this.message="Timeout has occurred",this.name="TimeoutError",this}return t.prototype=Object.create(Error.prototype),t}()},8782:(t,e,n)=>{"use strict";n.d(e,{B:()=>r});var r=function(){function t(t){return Error.call(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(t,e){return e+1+") "+t.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t,this}return t.prototype=Object.create(Error.prototype),t}()},3642:(t,e,n)=>{"use strict";n.d(e,{_:()=>i});var r=n(979);function i(t){for(;t;){var e=t,n=e.closed,i=e.destination,s=e.isStopped;if(n||s)return!1;t=i&&i instanceof r.L?i:null}return!0}},1644:(t,e,n)=>{"use strict";function r(t){setTimeout((function(){throw t}),0)}n.d(e,{z:()=>r})},3608:(t,e,n)=>{"use strict";function r(t){return t}n.d(e,{y:()=>r})},9026:(t,e,n)=>{"use strict";n.d(e,{k:()=>r});var r=function(){return Array.isArray||function(t){return t&&"number"==typeof t.length}}()},9217:(t,e,n)=>{"use strict";n.d(e,{z:()=>r});var r=function(t){return t&&"number"==typeof t.length&&"function"!=typeof t}},4156:(t,e,n)=>{"use strict";function r(t){return"function"==typeof t}n.d(e,{m:()=>r})},5812:(t,e,n)=>{"use strict";n.d(e,{k:()=>i});var r=n(9026);function i(t){return!(0,r.k)(t)&&t-parseFloat(t)+1>=0}},2009:(t,e,n)=>{"use strict";function r(t){return null!==t&&"object"==typeof t}n.d(e,{K:()=>r})},336:(t,e,n)=>{"use strict";function r(t){return!!t&&"function"!=typeof t.subscribe&&"function"==typeof t.then}n.d(e,{t:()=>r})},7507:(t,e,n)=>{"use strict";function r(t){return t&&"function"==typeof t.schedule}n.d(e,{K:()=>r})},3306:(t,e,n)=>{"use strict";function r(){}n.d(e,{Z:()=>r})},9067:(t,e,n)=>{"use strict";function r(t,e){function n(){return!n.pred.apply(n.thisArg,arguments)}return n.pred=t,n.thisArg=e,n}n.d(e,{f:()=>r})},2561:(t,e,n)=>{"use strict";n.d(e,{z:()=>i,U:()=>s});var r=n(3608);function i(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return s(t)}function s(t){return 0===t.length?r.y:1===t.length?t[0]:function(e){return t.reduce((function(t,e){return e(t)}),e)}}},7843:(t,e,n)=>{"use strict";n.d(e,{s:()=>h});var r=n(6900),i=n(1644),s=n(999),o=n(5050),a=n(9217),c=n(336),u=n(2009),h=function(t){if(t&&"function"==typeof t[o.L])return h=t,function(t){var e=h[o.L]();if("function"!=typeof e.subscribe)throw new TypeError("Provided object does not correctly implement Symbol.observable");return e.subscribe(t)};if((0,a.z)(t))return(0,r.V)(t);if((0,c.t)(t))return n=t,function(t){return n.then((function(e){t.closed||(t.next(e),t.complete())}),(function(e){return t.error(e)})).then(null,i.z),t};if(t&&"function"==typeof t[s.hZ])return e=t,function(t){for(var n=e[s.hZ]();;){var r=void 0;try{r=n.next()}catch(e){return t.error(e),t}if(r.done){t.complete();break}if(t.next(r.value),t.closed)break}return"function"==typeof n.return&&t.add((function(){n.return&&n.return()})),t};var e,n,h,l=(0,u.K)(t)?"an invalid object":"'"+t+"'";throw new TypeError("You provided "+l+" where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.")}},6900:(t,e,n)=>{"use strict";n.d(e,{V:()=>r});var r=function(t){return function(e){for(var n=0,r=t.length;n<r&&!e.closed;n++)e.next(t[n]);e.complete()}}},2080:(t,e,n)=>{"use strict";n.d(e,{D:()=>a});var r=n(5987),i=function(t){function e(e,n,r){var i=t.call(this)||this;return i.parent=e,i.outerValue=n,i.outerIndex=r,i.index=0,i}return r.ZT(e,t),e.prototype._next=function(t){this.parent.notifyNext(this.outerValue,t,this.outerIndex,this.index++,this)},e.prototype._error=function(t){this.parent.notifyError(t,this),this.unsubscribe()},e.prototype._complete=function(){this.parent.notifyComplete(this),this.unsubscribe()},e}(n(979).L),s=n(7843),o=n(2772);function a(t,e,n,r,a){if(void 0===a&&(a=new i(t,n,r)),!a.closed)return e instanceof o.y?e.subscribe(a):(0,s.s)(e)(a)}},1717:(t,e,n)=>{"use strict";n.r(e),n.d(e,{audit:()=>s,auditTime:()=>h,buffer:()=>l,bufferCount:()=>m,bufferTime:()=>w,bufferToggle:()=>C,bufferWhen:()=>R,catchError:()=>M,combineAll:()=>j,combineLatest:()=>z,concat:()=>W,concatAll:()=>G.u,concatMap:()=>$,concatMapTo:()=>Y,count:()=>Q,debounce:()=>X,debounceTime:()=>nt,defaultIfEmpty:()=>ot,delay:()=>lt,delayWhen:()=>gt,dematerialize:()=>It,distinct:()=>Et,distinctUntilChanged:()=>At,distinctUntilKeyChanged:()=>Ct,elementAt:()=>Bt,endWith:()=>Kt,every:()=>Wt,exhaust:()=>$t,exhaustMap:()=>Zt,expand:()=>ee,filter:()=>Ot.h,finalize:()=>ie,find:()=>ae,findIndex:()=>he,first:()=>de,flatMap:()=>H.VS,groupBy:()=>fe.v,ignoreElements:()=>pe,isEmpty:()=>ye,last:()=>_e,map:()=>Jt.U,mapTo:()=>Ee,materialize:()=>Ae,max:()=>Le,merge:()=>Fe,mergeAll:()=>Ue.J,mergeMap:()=>H.zg,mergeMapTo:()=>Ve,mergeScan:()=>je,min:()=>ze,multicast:()=>We,observeOn:()=>He.QV,onErrorResumeNext:()=>$e,pairwise:()=>Je,partition:()=>en,pluck:()=>nn,publish:()=>on,publishBehavior:()=>cn,publishLast:()=>hn,publishReplay:()=>dn,race:()=>pn,reduce:()=>Pe,refCount:()=>An.x,repeat:()=>mn,repeatWhen:()=>vn,retry:()=>In,retryWhen:()=>En,sample:()=>Nn,sampleTime:()=>Dn,scan:()=>Ce,sequenceEqual:()=>Ln,share:()=>jn,shareReplay:()=>qn,single:()=>Bn,skip:()=>Wn,skipLast:()=>$n,skipUntil:()=>Jn,skipWhile:()=>tr,startWith:()=>rr,subscribeOn:()=>ar,switchAll:()=>dr,switchMap:()=>ur,switchMapTo:()=>fr,take:()=>Vt,takeLast:()=>we,takeUntil:()=>pr,takeWhile:()=>yr,tap:()=>Tr,throttle:()=>kr,throttleTime:()=>xr,throwIfEmpty:()=>Pt,timeInterval:()=>Pr,timeout:()=>qr,timeoutWith:()=>Fr,timestamp:()=>Br,toArray:()=>Wr,window:()=>Gr,windowCount:()=>Yr,windowTime:()=>Zr,windowToggle:()=>si,windowWhen:()=>ci,withLatestFrom:()=>li,zip:()=>mi,zipAll:()=>gi});var r=n(5987),i=n(7604);function s(t){return function(e){return e.lift(new o(t))}}var o=function(){function t(t){this.durationSelector=t}return t.prototype.call=function(t,e){return e.subscribe(new a(t,this.durationSelector))},t}(),a=function(t){function e(e,n){var r=t.call(this,e)||this;return r.durationSelector=n,r.hasValue=!1,r}return r.ZT(e,t),e.prototype._next=function(t){if(this.value=t,this.hasValue=!0,!this.throttled){var e=void 0;try{e=(0,this.durationSelector)(t)}catch(t){return this.destination.error(t)}var n=(0,i.ft)(e,new i.IY(this));!n||n.closed?this.clearThrottle():this.add(this.throttled=n)}},e.prototype.clearThrottle=function(){var t=this,e=t.value,n=t.hasValue,r=t.throttled;r&&(this.remove(r),this.throttled=void 0,r.unsubscribe()),n&&(this.value=void 0,this.hasValue=!1,this.destination.next(e))},e.prototype.notifyNext=function(){this.clearThrottle()},e.prototype.notifyComplete=function(){this.clearThrottle()},e}(i.Ds),c=n(964),u=n(9604);function h(t,e){return void 0===e&&(e=c.P),s((function(){return(0,u.H)(t,e)}))}function l(t){return function(e){return e.lift(new d(t))}}var d=function(){function t(t){this.closingNotifier=t}return t.prototype.call=function(t,e){return e.subscribe(new f(t,this.closingNotifier))},t}(),f=function(t){function e(e,n){var r=t.call(this,e)||this;return r.buffer=[],r.add((0,i.ft)(n,new i.IY(r))),r}return r.ZT(e,t),e.prototype._next=function(t){this.buffer.push(t)},e.prototype.notifyNext=function(){var t=this.buffer;this.buffer=[],this.destination.next(t)},e}(i.Ds),p=n(979);function m(t,e){return void 0===e&&(e=null),function(n){return n.lift(new g(t,e))}}var g=function(){function t(t,e){this.bufferSize=t,this.startBufferEvery=e,this.subscriberClass=e&&t!==e?v:y}return t.prototype.call=function(t,e){return e.subscribe(new this.subscriberClass(t,this.bufferSize,this.startBufferEvery))},t}(),y=function(t){function e(e,n){var r=t.call(this,e)||this;return r.bufferSize=n,r.buffer=[],r}return r.ZT(e,t),e.prototype._next=function(t){var e=this.buffer;e.push(t),e.length==this.bufferSize&&(this.destination.next(e),this.buffer=[])},e.prototype._complete=function(){var e=this.buffer;e.length>0&&this.destination.next(e),t.prototype._complete.call(this)},e}(p.L),v=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.bufferSize=n,i.startBufferEvery=r,i.buffers=[],i.count=0,i}return r.ZT(e,t),e.prototype._next=function(t){var e=this,n=e.bufferSize,r=e.startBufferEvery,i=e.buffers,s=e.count;this.count++,s%r==0&&i.push([]);for(var o=i.length;o--;){var a=i[o];a.push(t),a.length===n&&(i.splice(o,1),this.destination.next(a))}},e.prototype._complete=function(){for(var e=this.buffers,n=this.destination;e.length>0;){var r=e.shift();r.length>0&&n.next(r)}t.prototype._complete.call(this)},e}(p.L),b=n(7507);function w(t){var e=arguments.length,n=c.P;(0,b.K)(arguments[arguments.length-1])&&(n=arguments[arguments.length-1],e--);var r=null;e>=2&&(r=arguments[1]);var i=Number.POSITIVE_INFINITY;return e>=3&&(i=arguments[2]),function(e){return e.lift(new I(t,r,i,n))}}var I=function(){function t(t,e,n,r){this.bufferTimeSpan=t,this.bufferCreationInterval=e,this.maxBufferSize=n,this.scheduler=r}return t.prototype.call=function(t,e){return e.subscribe(new _(t,this.bufferTimeSpan,this.bufferCreationInterval,this.maxBufferSize,this.scheduler))},t}(),T=function(){return function(){this.buffer=[]}}(),_=function(t){function e(e,n,r,i,s){var o=t.call(this,e)||this;o.bufferTimeSpan=n,o.bufferCreationInterval=r,o.maxBufferSize=i,o.scheduler=s,o.contexts=[];var a=o.openContext();if(o.timespanOnly=null==r||r<0,o.timespanOnly){var c={subscriber:o,context:a,bufferTimeSpan:n};o.add(a.closeAction=s.schedule(E,n,c))}else{var u={subscriber:o,context:a},h={bufferTimeSpan:n,bufferCreationInterval:r,subscriber:o,scheduler:s};o.add(a.closeAction=s.schedule(k,n,u)),o.add(s.schedule(S,r,h))}return o}return r.ZT(e,t),e.prototype._next=function(t){for(var e,n=this.contexts,r=n.length,i=0;i<r;i++){var s=n[i],o=s.buffer;o.push(t),o.length==this.maxBufferSize&&(e=s)}e&&this.onBufferFull(e)},e.prototype._error=function(e){this.contexts.length=0,t.prototype._error.call(this,e)},e.prototype._complete=function(){for(var e=this.contexts,n=this.destination;e.length>0;){var r=e.shift();n.next(r.buffer)}t.prototype._complete.call(this)},e.prototype._unsubscribe=function(){this.contexts=null},e.prototype.onBufferFull=function(t){this.closeContext(t);var e=t.closeAction;if(e.unsubscribe(),this.remove(e),!this.closed&&this.timespanOnly){t=this.openContext();var n=this.bufferTimeSpan,r={subscriber:this,context:t,bufferTimeSpan:n};this.add(t.closeAction=this.scheduler.schedule(E,n,r))}},e.prototype.openContext=function(){var t=new T;return this.contexts.push(t),t},e.prototype.closeContext=function(t){this.destination.next(t.buffer);var e=this.contexts;(e?e.indexOf(t):-1)>=0&&e.splice(e.indexOf(t),1)},e}(p.L);function E(t){var e=t.subscriber,n=t.context;n&&e.closeContext(n),e.closed||(t.context=e.openContext(),t.context.closeAction=this.schedule(t,t.bufferTimeSpan))}function S(t){var e=t.bufferCreationInterval,n=t.bufferTimeSpan,r=t.subscriber,i=t.scheduler,s=r.openContext();r.closed||(r.add(s.closeAction=i.schedule(k,n,{subscriber:r,context:s})),this.schedule(t,e))}function k(t){var e=t.subscriber,n=t.context;e.closeContext(n)}var A=n(8760),N=n(2080),x=n(2039);function C(t,e){return function(n){return n.lift(new D(t,e))}}var D=function(){function t(t,e){this.openings=t,this.closingSelector=e}return t.prototype.call=function(t,e){return e.subscribe(new O(t,this.openings,this.closingSelector))},t}(),O=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.closingSelector=r,i.contexts=[],i.add((0,N.D)(i,n)),i}return r.ZT(e,t),e.prototype._next=function(t){for(var e=this.contexts,n=e.length,r=0;r<n;r++)e[r].buffer.push(t)},e.prototype._error=function(e){for(var n=this.contexts;n.length>0;){var r=n.shift();r.subscription.unsubscribe(),r.buffer=null,r.subscription=null}this.contexts=null,t.prototype._error.call(this,e)},e.prototype._complete=function(){for(var e=this.contexts;e.length>0;){var n=e.shift();this.destination.next(n.buffer),n.subscription.unsubscribe(),n.buffer=null,n.subscription=null}this.contexts=null,t.prototype._complete.call(this)},e.prototype.notifyNext=function(t,e){t?this.closeBuffer(t):this.openBuffer(e)},e.prototype.notifyComplete=function(t){this.closeBuffer(t.context)},e.prototype.openBuffer=function(t){try{var e=this.closingSelector.call(this,t);e&&this.trySubscribe(e)}catch(t){this._error(t)}},e.prototype.closeBuffer=function(t){var e=this.contexts;if(e&&t){var n=t.buffer,r=t.subscription;this.destination.next(n),e.splice(e.indexOf(t),1),this.remove(r),r.unsubscribe()}},e.prototype.trySubscribe=function(t){var e=this.contexts,n=new A.w,r={buffer:[],subscription:n};e.push(r);var i=(0,N.D)(this,t,r);!i||i.closed?this.closeBuffer(r):(i.context=r,this.add(i),n.add(i))},e}(x.L);function R(t){return function(e){return e.lift(new P(t))}}var P=function(){function t(t){this.closingSelector=t}return t.prototype.call=function(t,e){return e.subscribe(new L(t,this.closingSelector))},t}(),L=function(t){function e(e,n){var r=t.call(this,e)||this;return r.closingSelector=n,r.subscribing=!1,r.openBuffer(),r}return r.ZT(e,t),e.prototype._next=function(t){this.buffer.push(t)},e.prototype._complete=function(){var e=this.buffer;e&&this.destination.next(e),t.prototype._complete.call(this)},e.prototype._unsubscribe=function(){this.buffer=void 0,this.subscribing=!1},e.prototype.notifyNext=function(){this.openBuffer()},e.prototype.notifyComplete=function(){this.subscribing?this.complete():this.openBuffer()},e.prototype.openBuffer=function(){var t=this.closingSubscription;t&&(this.remove(t),t.unsubscribe());var e,n=this.buffer;this.buffer&&this.destination.next(n),this.buffer=[];try{e=(0,this.closingSelector)()}catch(t){return this.error(t)}t=new A.w,this.closingSubscription=t,this.add(t),this.subscribing=!0,t.add((0,i.ft)(e,new i.IY(this))),this.subscribing=!1},e}(i.Ds);function M(t){return function(e){var n=new F(t),r=e.lift(n);return n.caught=r}}var F=function(){function t(t){this.selector=t}return t.prototype.call=function(t,e){return e.subscribe(new U(t,this.selector,this.caught))},t}(),U=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.selector=n,i.caught=r,i}return r.ZT(e,t),e.prototype.error=function(e){if(!this.isStopped){var n=void 0;try{n=this.selector(e,this.caught)}catch(e){return void t.prototype.error.call(this,e)}this._unsubscribeAndRecycle();var r=new i.IY(this);this.add(r);var s=(0,i.ft)(n,r);s!==r&&this.add(s)}},e}(i.Ds),V=n(5142);function j(t){return function(e){return e.lift(new V.Ms(t))}}var q=n(9026),B=n(5760);function z(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=null;return"function"==typeof t[t.length-1]&&(n=t.pop()),1===t.length&&(0,q.k)(t[0])&&(t=t[0].slice()),function(e){return e.lift.call((0,B.D)([e].concat(t)),new V.Ms(n))}}var K=n(9795);function W(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return function(e){return e.lift.call(K.z.apply(void 0,[e].concat(t)))}}var G=n(2257),H=n(7746);function $(t,e){return(0,H.zg)(t,e,1)}function Y(t,e){return $((function(){return t}),e)}function Q(t){return function(e){return e.lift(new J(t,e))}}var J=function(){function t(t,e){this.predicate=t,this.source=e}return t.prototype.call=function(t,e){return e.subscribe(new Z(t,this.predicate,this.source))},t}(),Z=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.predicate=n,i.source=r,i.count=0,i.index=0,i}return r.ZT(e,t),e.prototype._next=function(t){this.predicate?this._tryPredicate(t):this.count++},e.prototype._tryPredicate=function(t){var e;try{e=this.predicate(t,this.index++,this.source)}catch(t){return void this.destination.error(t)}e&&this.count++},e.prototype._complete=function(){this.destination.next(this.count),this.destination.complete()},e}(p.L);function X(t){return function(e){return e.lift(new tt(t))}}var tt=function(){function t(t){this.durationSelector=t}return t.prototype.call=function(t,e){return e.subscribe(new et(t,this.durationSelector))},t}(),et=function(t){function e(e,n){var r=t.call(this,e)||this;return r.durationSelector=n,r.hasValue=!1,r}return r.ZT(e,t),e.prototype._next=function(t){try{var e=this.durationSelector.call(this,t);e&&this._tryNext(t,e)}catch(t){this.destination.error(t)}},e.prototype._complete=function(){this.emitValue(),this.destination.complete()},e.prototype._tryNext=function(t,e){var n=this.durationSubscription;this.value=t,this.hasValue=!0,n&&(n.unsubscribe(),this.remove(n)),(n=(0,i.ft)(e,new i.IY(this)))&&!n.closed&&this.add(this.durationSubscription=n)},e.prototype.notifyNext=function(){this.emitValue()},e.prototype.notifyComplete=function(){this.emitValue()},e.prototype.emitValue=function(){if(this.hasValue){var e=this.value,n=this.durationSubscription;n&&(this.durationSubscription=void 0,n.unsubscribe(),this.remove(n)),this.value=void 0,this.hasValue=!1,t.prototype._next.call(this,e)}},e}(i.Ds);function nt(t,e){return void 0===e&&(e=c.P),function(n){return n.lift(new rt(t,e))}}var rt=function(){function t(t,e){this.dueTime=t,this.scheduler=e}return t.prototype.call=function(t,e){return e.subscribe(new it(t,this.dueTime,this.scheduler))},t}(),it=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.dueTime=n,i.scheduler=r,i.debouncedSubscription=null,i.lastValue=null,i.hasValue=!1,i}return r.ZT(e,t),e.prototype._next=function(t){this.clearDebounce(),this.lastValue=t,this.hasValue=!0,this.add(this.debouncedSubscription=this.scheduler.schedule(st,this.dueTime,this))},e.prototype._complete=function(){this.debouncedNext(),this.destination.complete()},e.prototype.debouncedNext=function(){if(this.clearDebounce(),this.hasValue){var t=this.lastValue;this.lastValue=null,this.hasValue=!1,this.destination.next(t)}},e.prototype.clearDebounce=function(){var t=this.debouncedSubscription;null!==t&&(this.remove(t),t.unsubscribe(),this.debouncedSubscription=null)},e}(p.L);function st(t){t.debouncedNext()}function ot(t){return void 0===t&&(t=null),function(e){return e.lift(new at(t))}}var at=function(){function t(t){this.defaultValue=t}return t.prototype.call=function(t,e){return e.subscribe(new ct(t,this.defaultValue))},t}(),ct=function(t){function e(e,n){var r=t.call(this,e)||this;return r.defaultValue=n,r.isEmpty=!0,r}return r.ZT(e,t),e.prototype._next=function(t){this.isEmpty=!1,this.destination.next(t)},e.prototype._complete=function(){this.isEmpty&&this.destination.next(this.defaultValue),this.destination.complete()},e}(p.L);function ut(t){return t instanceof Date&&!isNaN(+t)}var ht=n(2632);function lt(t,e){void 0===e&&(e=c.P);var n=ut(t)?+t-e.now():Math.abs(t);return function(t){return t.lift(new dt(n,e))}}var dt=function(){function t(t,e){this.delay=t,this.scheduler=e}return t.prototype.call=function(t,e){return e.subscribe(new ft(t,this.delay,this.scheduler))},t}(),ft=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.delay=n,i.scheduler=r,i.queue=[],i.active=!1,i.errored=!1,i}return r.ZT(e,t),e.dispatch=function(t){for(var e=t.source,n=e.queue,r=t.scheduler,i=t.destination;n.length>0&&n[0].time-r.now()<=0;)n.shift().notification.observe(i);if(n.length>0){var s=Math.max(0,n[0].time-r.now());this.schedule(t,s)}else this.unsubscribe(),e.active=!1},e.prototype._schedule=function(t){this.active=!0,this.destination.add(t.schedule(e.dispatch,this.delay,{source:this,destination:this.destination,scheduler:t}))},e.prototype.scheduleNotification=function(t){if(!0!==this.errored){var e=this.scheduler,n=new pt(e.now()+this.delay,t);this.queue.push(n),!1===this.active&&this._schedule(e)}},e.prototype._next=function(t){this.scheduleNotification(ht.P.createNext(t))},e.prototype._error=function(t){this.errored=!0,this.queue=[],this.destination.error(t),this.unsubscribe()},e.prototype._complete=function(){this.scheduleNotification(ht.P.createComplete()),this.unsubscribe()},e}(p.L),pt=function(){return function(t,e){this.time=t,this.notification=e}}(),mt=n(2772);function gt(t,e){return e?function(n){return new bt(n,e).lift(new yt(t))}:function(e){return e.lift(new yt(t))}}var yt=function(){function t(t){this.delayDurationSelector=t}return t.prototype.call=function(t,e){return e.subscribe(new vt(t,this.delayDurationSelector))},t}(),vt=function(t){function e(e,n){var r=t.call(this,e)||this;return r.delayDurationSelector=n,r.completed=!1,r.delayNotifierSubscriptions=[],r.index=0,r}return r.ZT(e,t),e.prototype.notifyNext=function(t,e,n,r,i){this.destination.next(t),this.removeSubscription(i),this.tryComplete()},e.prototype.notifyError=function(t,e){this._error(t)},e.prototype.notifyComplete=function(t){var e=this.removeSubscription(t);e&&this.destination.next(e),this.tryComplete()},e.prototype._next=function(t){var e=this.index++;try{var n=this.delayDurationSelector(t,e);n&&this.tryDelay(n,t)}catch(t){this.destination.error(t)}},e.prototype._complete=function(){this.completed=!0,this.tryComplete(),this.unsubscribe()},e.prototype.removeSubscription=function(t){t.unsubscribe();var e=this.delayNotifierSubscriptions.indexOf(t);return-1!==e&&this.delayNotifierSubscriptions.splice(e,1),t.outerValue},e.prototype.tryDelay=function(t,e){var n=(0,N.D)(this,t,e);n&&!n.closed&&(this.destination.add(n),this.delayNotifierSubscriptions.push(n))},e.prototype.tryComplete=function(){this.completed&&0===this.delayNotifierSubscriptions.length&&this.destination.complete()},e}(x.L),bt=function(t){function e(e,n){var r=t.call(this)||this;return r.source=e,r.subscriptionDelay=n,r}return r.ZT(e,t),e.prototype._subscribe=function(t){this.subscriptionDelay.subscribe(new wt(t,this.source))},e}(mt.y),wt=function(t){function e(e,n){var r=t.call(this)||this;return r.parent=e,r.source=n,r.sourceSubscribed=!1,r}return r.ZT(e,t),e.prototype._next=function(t){this.subscribeToSource()},e.prototype._error=function(t){this.unsubscribe(),this.parent.error(t)},e.prototype._complete=function(){this.unsubscribe(),this.subscribeToSource()},e.prototype.subscribeToSource=function(){this.sourceSubscribed||(this.sourceSubscribed=!0,this.unsubscribe(),this.source.subscribe(this.parent))},e}(p.L);function It(){return function(t){return t.lift(new Tt)}}var Tt=function(){function t(){}return t.prototype.call=function(t,e){return e.subscribe(new _t(t))},t}(),_t=function(t){function e(e){return t.call(this,e)||this}return r.ZT(e,t),e.prototype._next=function(t){t.observe(this.destination)},e}(p.L);function Et(t,e){return function(n){return n.lift(new St(t,e))}}var St=function(){function t(t,e){this.keySelector=t,this.flushes=e}return t.prototype.call=function(t,e){return e.subscribe(new kt(t,this.keySelector,this.flushes))},t}(),kt=function(t){function e(e,n,r){var s=t.call(this,e)||this;return s.keySelector=n,s.values=new Set,r&&s.add((0,i.ft)(r,new i.IY(s))),s}return r.ZT(e,t),e.prototype.notifyNext=function(){this.values.clear()},e.prototype.notifyError=function(t){this._error(t)},e.prototype._next=function(t){this.keySelector?this._useKeySelector(t):this._finalizeNext(t,t)},e.prototype._useKeySelector=function(t){var e,n=this.destination;try{e=this.keySelector(t)}catch(t){return void n.error(t)}this._finalizeNext(e,t)},e.prototype._finalizeNext=function(t,e){var n=this.values;n.has(t)||(n.add(t),this.destination.next(e))},e}(i.Ds);function At(t,e){return function(n){return n.lift(new Nt(t,e))}}var Nt=function(){function t(t,e){this.compare=t,this.keySelector=e}return t.prototype.call=function(t,e){return e.subscribe(new xt(t,this.compare,this.keySelector))},t}(),xt=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.keySelector=r,i.hasKey=!1,"function"==typeof n&&(i.compare=n),i}return r.ZT(e,t),e.prototype.compare=function(t,e){return t===e},e.prototype._next=function(t){var e;try{var n=this.keySelector;e=n?n(t):t}catch(t){return this.destination.error(t)}var r=!1;if(this.hasKey)try{r=(0,this.compare)(this.key,e)}catch(t){return this.destination.error(t)}else this.hasKey=!0;r||(this.key=e,this.destination.next(t))},e}(p.L);function Ct(t,e){return At((function(n,r){return e?e(n[t],r[t]):n[t]===r[t]}))}var Dt=n(6565),Ot=n(6008),Rt=n(6929);function Pt(t){return void 0===t&&(t=Ft),function(e){return e.lift(new Lt(t))}}var Lt=function(){function t(t){this.errorFactory=t}return t.prototype.call=function(t,e){return e.subscribe(new Mt(t,this.errorFactory))},t}(),Mt=function(t){function e(e,n){var r=t.call(this,e)||this;return r.errorFactory=n,r.hasValue=!1,r}return r.ZT(e,t),e.prototype._next=function(t){this.hasValue=!0,this.destination.next(t)},e.prototype._complete=function(){if(this.hasValue)return this.destination.complete();var t=void 0;try{t=this.errorFactory()}catch(e){t=e}this.destination.error(t)},e}(p.L);function Ft(){return new Rt.K}var Ut=n(5631);function Vt(t){return function(e){return 0===t?(0,Ut.c)():e.lift(new jt(t))}}var jt=function(){function t(t){if(this.total=t,this.total<0)throw new Dt.W}return t.prototype.call=function(t,e){return e.subscribe(new qt(t,this.total))},t}(),qt=function(t){function e(e,n){var r=t.call(this,e)||this;return r.total=n,r.count=0,r}return r.ZT(e,t),e.prototype._next=function(t){var e=this.total,n=++this.count;n<=e&&(this.destination.next(t),n===e&&(this.destination.complete(),this.unsubscribe()))},e}(p.L);function Bt(t,e){if(t<0)throw new Dt.W;var n=arguments.length>=2;return function(r){return r.pipe((0,Ot.h)((function(e,n){return n===t})),Vt(1),n?ot(e):Pt((function(){return new Dt.W})))}}var zt=n(8170);function Kt(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return function(e){return(0,K.z)(e,zt.of.apply(void 0,t))}}function Wt(t,e){return function(n){return n.lift(new Gt(t,e,n))}}var Gt=function(){function t(t,e,n){this.predicate=t,this.thisArg=e,this.source=n}return t.prototype.call=function(t,e){return e.subscribe(new Ht(t,this.predicate,this.thisArg,this.source))},t}(),Ht=function(t){function e(e,n,r,i){var s=t.call(this,e)||this;return s.predicate=n,s.thisArg=r,s.source=i,s.index=0,s.thisArg=r||s,s}return r.ZT(e,t),e.prototype.notifyComplete=function(t){this.destination.next(t),this.destination.complete()},e.prototype._next=function(t){var e=!1;try{e=this.predicate.call(this.thisArg,t,this.index++,this.source)}catch(t){return void this.destination.error(t)}e||this.notifyComplete(!1)},e.prototype._complete=function(){this.notifyComplete(!0)},e}(p.L);function $t(){return function(t){return t.lift(new Yt)}}var Yt=function(){function t(){}return t.prototype.call=function(t,e){return e.subscribe(new Qt(t))},t}(),Qt=function(t){function e(e){var n=t.call(this,e)||this;return n.hasCompleted=!1,n.hasSubscription=!1,n}return r.ZT(e,t),e.prototype._next=function(t){this.hasSubscription||(this.hasSubscription=!0,this.add((0,i.ft)(t,new i.IY(this))))},e.prototype._complete=function(){this.hasCompleted=!0,this.hasSubscription||this.destination.complete()},e.prototype.notifyComplete=function(){this.hasSubscription=!1,this.hasCompleted&&this.destination.complete()},e}(i.Ds),Jt=n(5709);function Zt(t,e){return e?function(n){return n.pipe(Zt((function(n,r){return(0,B.D)(t(n,r)).pipe((0,Jt.U)((function(t,i){return e(n,t,r,i)})))})))}:function(e){return e.lift(new Xt(t))}}var Xt=function(){function t(t){this.project=t}return t.prototype.call=function(t,e){return e.subscribe(new te(t,this.project))},t}(),te=function(t){function e(e,n){var r=t.call(this,e)||this;return r.project=n,r.hasSubscription=!1,r.hasCompleted=!1,r.index=0,r}return r.ZT(e,t),e.prototype._next=function(t){this.hasSubscription||this.tryNext(t)},e.prototype.tryNext=function(t){var e,n=this.index++;try{e=this.project(t,n)}catch(t){return void this.destination.error(t)}this.hasSubscription=!0,this._innerSub(e)},e.prototype._innerSub=function(t){var e=new i.IY(this),n=this.destination;n.add(e);var r=(0,i.ft)(t,e);r!==e&&n.add(r)},e.prototype._complete=function(){this.hasCompleted=!0,this.hasSubscription||this.destination.complete(),this.unsubscribe()},e.prototype.notifyNext=function(t){this.destination.next(t)},e.prototype.notifyError=function(t){this.destination.error(t)},e.prototype.notifyComplete=function(){this.hasSubscription=!1,this.hasCompleted&&this.destination.complete()},e}(i.Ds);function ee(t,e,n){return void 0===e&&(e=Number.POSITIVE_INFINITY),e=(e||0)<1?Number.POSITIVE_INFINITY:e,function(r){return r.lift(new ne(t,e,n))}}var ne=function(){function t(t,e,n){this.project=t,this.concurrent=e,this.scheduler=n}return t.prototype.call=function(t,e){return e.subscribe(new re(t,this.project,this.concurrent,this.scheduler))},t}(),re=function(t){function e(e,n,r,i){var s=t.call(this,e)||this;return s.project=n,s.concurrent=r,s.scheduler=i,s.index=0,s.active=0,s.hasCompleted=!1,r<Number.POSITIVE_INFINITY&&(s.buffer=[]),s}return r.ZT(e,t),e.dispatch=function(t){var e=t.subscriber,n=t.result,r=t.value,i=t.index;e.subscribeToProjection(n,r,i)},e.prototype._next=function(t){var n=this.destination;if(n.closed)this._complete();else{var r=this.index++;if(this.active<this.concurrent){n.next(t);try{var i=(0,this.project)(t,r);if(this.scheduler){var s={subscriber:this,result:i,value:t,index:r};this.destination.add(this.scheduler.schedule(e.dispatch,0,s))}else this.subscribeToProjection(i,t,r)}catch(t){n.error(t)}}else this.buffer.push(t)}},e.prototype.subscribeToProjection=function(t,e,n){this.active++,this.destination.add((0,i.ft)(t,new i.IY(this)))},e.prototype._complete=function(){this.hasCompleted=!0,this.hasCompleted&&0===this.active&&this.destination.complete(),this.unsubscribe()},e.prototype.notifyNext=function(t){this._next(t)},e.prototype.notifyComplete=function(){var t=this.buffer;this.active--,t&&t.length>0&&this._next(t.shift()),this.hasCompleted&&0===this.active&&this.destination.complete()},e}(i.Ds);function ie(t){return function(e){return e.lift(new se(t))}}var se=function(){function t(t){this.callback=t}return t.prototype.call=function(t,e){return e.subscribe(new oe(t,this.callback))},t}(),oe=function(t){function e(e,n){var r=t.call(this,e)||this;return r.add(new A.w(n)),r}return r.ZT(e,t),e}(p.L);function ae(t,e){if("function"!=typeof t)throw new TypeError("predicate is not a function");return function(n){return n.lift(new ce(t,n,!1,e))}}var ce=function(){function t(t,e,n,r){this.predicate=t,this.source=e,this.yieldIndex=n,this.thisArg=r}return t.prototype.call=function(t,e){return e.subscribe(new ue(t,this.predicate,this.source,this.yieldIndex,this.thisArg))},t}(),ue=function(t){function e(e,n,r,i,s){var o=t.call(this,e)||this;return o.predicate=n,o.source=r,o.yieldIndex=i,o.thisArg=s,o.index=0,o}return r.ZT(e,t),e.prototype.notifyComplete=function(t){var e=this.destination;e.next(t),e.complete(),this.unsubscribe()},e.prototype._next=function(t){var e=this.predicate,n=this.thisArg,r=this.index++;try{e.call(n||this,t,r,this.source)&&this.notifyComplete(this.yieldIndex?r:t)}catch(t){this.destination.error(t)}},e.prototype._complete=function(){this.notifyComplete(this.yieldIndex?-1:void 0)},e}(p.L);function he(t,e){return function(n){return n.lift(new ce(t,n,!0,e))}}var le=n(3608);function de(t,e){var n=arguments.length>=2;return function(r){return r.pipe(t?(0,Ot.h)((function(e,n){return t(e,n,r)})):le.y,Vt(1),n?ot(e):Pt((function(){return new Rt.K})))}}var fe=n(1120);function pe(){return function(t){return t.lift(new me)}}var me=function(){function t(){}return t.prototype.call=function(t,e){return e.subscribe(new ge(t))},t}(),ge=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r.ZT(e,t),e.prototype._next=function(t){},e}(p.L);function ye(){return function(t){return t.lift(new ve)}}var ve=function(){function t(){}return t.prototype.call=function(t,e){return e.subscribe(new be(t))},t}(),be=function(t){function e(e){return t.call(this,e)||this}return r.ZT(e,t),e.prototype.notifyComplete=function(t){var e=this.destination;e.next(t),e.complete()},e.prototype._next=function(t){this.notifyComplete(!1)},e.prototype._complete=function(){this.notifyComplete(!0)},e}(p.L);function we(t){return function(e){return 0===t?(0,Ut.c)():e.lift(new Ie(t))}}var Ie=function(){function t(t){if(this.total=t,this.total<0)throw new Dt.W}return t.prototype.call=function(t,e){return e.subscribe(new Te(t,this.total))},t}(),Te=function(t){function e(e,n){var r=t.call(this,e)||this;return r.total=n,r.ring=new Array,r.count=0,r}return r.ZT(e,t),e.prototype._next=function(t){var e=this.ring,n=this.total,r=this.count++;e.length<n?e.push(t):e[r%n]=t},e.prototype._complete=function(){var t=this.destination,e=this.count;if(e>0)for(var n=this.count>=this.total?this.total:this.count,r=this.ring,i=0;i<n;i++){var s=e++%n;t.next(r[s])}t.complete()},e}(p.L);function _e(t,e){var n=arguments.length>=2;return function(r){return r.pipe(t?(0,Ot.h)((function(e,n){return t(e,n,r)})):le.y,we(1),n?ot(e):Pt((function(){return new Rt.K})))}}function Ee(t){return function(e){return e.lift(new Se(t))}}var Se=function(){function t(t){this.value=t}return t.prototype.call=function(t,e){return e.subscribe(new ke(t,this.value))},t}(),ke=function(t){function e(e,n){var r=t.call(this,e)||this;return r.value=n,r}return r.ZT(e,t),e.prototype._next=function(t){this.destination.next(this.value)},e}(p.L);function Ae(){return function(t){return t.lift(new Ne)}}var Ne=function(){function t(){}return t.prototype.call=function(t,e){return e.subscribe(new xe(t))},t}(),xe=function(t){function e(e){return t.call(this,e)||this}return r.ZT(e,t),e.prototype._next=function(t){this.destination.next(ht.P.createNext(t))},e.prototype._error=function(t){var e=this.destination;e.next(ht.P.createError(t)),e.complete()},e.prototype._complete=function(){var t=this.destination;t.next(ht.P.createComplete()),t.complete()},e}(p.L);function Ce(t,e){var n=!1;return arguments.length>=2&&(n=!0),function(r){return r.lift(new De(t,e,n))}}var De=function(){function t(t,e,n){void 0===n&&(n=!1),this.accumulator=t,this.seed=e,this.hasSeed=n}return t.prototype.call=function(t,e){return e.subscribe(new Oe(t,this.accumulator,this.seed,this.hasSeed))},t}(),Oe=function(t){function e(e,n,r,i){var s=t.call(this,e)||this;return s.accumulator=n,s._seed=r,s.hasSeed=i,s.index=0,s}return r.ZT(e,t),Object.defineProperty(e.prototype,"seed",{get:function(){return this._seed},set:function(t){this.hasSeed=!0,this._seed=t},enumerable:!0,configurable:!0}),e.prototype._next=function(t){if(this.hasSeed)return this._tryNext(t);this.seed=t,this.destination.next(t)},e.prototype._tryNext=function(t){var e,n=this.index++;try{e=this.accumulator(this.seed,t,n)}catch(t){this.destination.error(t)}this.seed=e,this.destination.next(e)},e}(p.L),Re=n(2561);function Pe(t,e){return arguments.length>=2?function(n){return(0,Re.z)(Ce(t,e),we(1),ot(e))(n)}:function(e){return(0,Re.z)(Ce((function(e,n,r){return t(e,n,r+1)})),we(1))(e)}}function Le(t){return Pe("function"==typeof t?function(e,n){return t(e,n)>0?e:n}:function(t,e){return t>e?t:e})}var Me=n(4370);function Fe(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return function(e){return e.lift.call(Me.T.apply(void 0,[e].concat(t)))}}var Ue=n(2556);function Ve(t,e,n){return void 0===n&&(n=Number.POSITIVE_INFINITY),"function"==typeof e?(0,H.zg)((function(){return t}),e,n):("number"==typeof e&&(n=e),(0,H.zg)((function(){return t}),n))}function je(t,e,n){return void 0===n&&(n=Number.POSITIVE_INFINITY),function(r){return r.lift(new qe(t,e,n))}}var qe=function(){function t(t,e,n){this.accumulator=t,this.seed=e,this.concurrent=n}return t.prototype.call=function(t,e){return e.subscribe(new Be(t,this.accumulator,this.seed,this.concurrent))},t}(),Be=function(t){function e(e,n,r,i){var s=t.call(this,e)||this;return s.accumulator=n,s.acc=r,s.concurrent=i,s.hasValue=!1,s.hasCompleted=!1,s.buffer=[],s.active=0,s.index=0,s}return r.ZT(e,t),e.prototype._next=function(t){if(this.active<this.concurrent){var e=this.index++,n=this.destination,r=void 0;try{r=(0,this.accumulator)(this.acc,t,e)}catch(t){return n.error(t)}this.active++,this._innerSub(r)}else this.buffer.push(t)},e.prototype._innerSub=function(t){var e=new i.IY(this),n=this.destination;n.add(e);var r=(0,i.ft)(t,e);r!==e&&n.add(r)},e.prototype._complete=function(){this.hasCompleted=!0,0===this.active&&0===this.buffer.length&&(!1===this.hasValue&&this.destination.next(this.acc),this.destination.complete()),this.unsubscribe()},e.prototype.notifyNext=function(t){var e=this.destination;this.acc=t,this.hasValue=!0,e.next(t)},e.prototype.notifyComplete=function(){var t=this.buffer;this.active--,t.length>0?this._next(t.shift()):0===this.active&&this.hasCompleted&&(!1===this.hasValue&&this.destination.next(this.acc),this.destination.complete())},e}(i.Ds);function ze(t){return Pe("function"==typeof t?function(e,n){return t(e,n)<0?e:n}:function(t,e){return t<e?t:e})}var Ke=n(3140);function We(t,e){return function(n){var r;if(r="function"==typeof t?t:function(){return t},"function"==typeof e)return n.lift(new Ge(r,e));var i=Object.create(n,Ke.N);return i.source=n,i.subjectFactory=r,i}}var Ge=function(){function t(t,e){this.subjectFactory=t,this.selector=e}return t.prototype.call=function(t,e){var n=this.selector,r=this.subjectFactory(),i=n(r).subscribe(t);return i.add(e.subscribe(r)),i},t}(),He=n(9276);function $e(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return 1===t.length&&(0,q.k)(t[0])&&(t=t[0]),function(e){return e.lift(new Ye(t))}}var Ye=function(){function t(t){this.nextSources=t}return t.prototype.call=function(t,e){return e.subscribe(new Qe(t,this.nextSources))},t}(),Qe=function(t){function e(e,n){var r=t.call(this,e)||this;return r.destination=e,r.nextSources=n,r}return r.ZT(e,t),e.prototype.notifyError=function(){this.subscribeToNextSource()},e.prototype.notifyComplete=function(){this.subscribeToNextSource()},e.prototype._error=function(t){this.subscribeToNextSource(),this.unsubscribe()},e.prototype._complete=function(){this.subscribeToNextSource(),this.unsubscribe()},e.prototype.subscribeToNextSource=function(){var t=this.nextSources.shift();if(t){var e=new i.IY(this),n=this.destination;n.add(e);var r=(0,i.ft)(t,e);r!==e&&n.add(r)}else this.destination.complete()},e}(i.Ds);function Je(){return function(t){return t.lift(new Ze)}}var Ze=function(){function t(){}return t.prototype.call=function(t,e){return e.subscribe(new Xe(t))},t}(),Xe=function(t){function e(e){var n=t.call(this,e)||this;return n.hasPrev=!1,n}return r.ZT(e,t),e.prototype._next=function(t){var e;this.hasPrev?e=[this.prev,t]:this.hasPrev=!0,this.prev=t,e&&this.destination.next(e)},e}(p.L),tn=n(9067);function en(t,e){return function(n){return[(0,Ot.h)(t,e)(n),(0,Ot.h)((0,tn.f)(t,e))(n)]}}function nn(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=t.length;if(0===n)throw new Error("list of properties cannot be empty.");return function(e){return(0,Jt.U)(rn(t,n))(e)}}function rn(t,e){return function(n){for(var r=n,i=0;i<e;i++){var s=null!=r?r[t[i]]:void 0;if(void 0===s)return;r=s}return r}}var sn=n(211);function on(t){return t?We((function(){return new sn.xQ}),t):We(new sn.xQ)}var an=n(9233);function cn(t){return function(e){return We(new an.X(t))(e)}}var un=n(364);function hn(){return function(t){return We(new un.c)(t)}}var ln=n(2630);function dn(t,e,n,r){n&&"function"!=typeof n&&(r=n);var i="function"==typeof n?n:void 0,s=new ln.t(t,e,r);return function(t){return We((function(){return s}),i)(t)}}var fn=n(8821);function pn(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return function(e){return 1===t.length&&(0,q.k)(t[0])&&(t=t[0]),e.lift.call(fn.S3.apply(void 0,[e].concat(t)))}}function mn(t){return void 0===t&&(t=-1),function(e){return 0===t?(0,Ut.c)():t<0?e.lift(new gn(-1,e)):e.lift(new gn(t-1,e))}}var gn=function(){function t(t,e){this.count=t,this.source=e}return t.prototype.call=function(t,e){return e.subscribe(new yn(t,this.count,this.source))},t}(),yn=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.count=n,i.source=r,i}return r.ZT(e,t),e.prototype.complete=function(){if(!this.isStopped){var e=this.source,n=this.count;if(0===n)return t.prototype.complete.call(this);n>-1&&(this.count=n-1),e.subscribe(this._unsubscribeAndRecycle())}},e}(p.L);function vn(t){return function(e){return e.lift(new bn(t))}}var bn=function(){function t(t){this.notifier=t}return t.prototype.call=function(t,e){return e.subscribe(new wn(t,this.notifier,e))},t}(),wn=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.notifier=n,i.source=r,i.sourceIsBeingSubscribedTo=!0,i}return r.ZT(e,t),e.prototype.notifyNext=function(){this.sourceIsBeingSubscribedTo=!0,this.source.subscribe(this)},e.prototype.notifyComplete=function(){if(!1===this.sourceIsBeingSubscribedTo)return t.prototype.complete.call(this)},e.prototype.complete=function(){if(this.sourceIsBeingSubscribedTo=!1,!this.isStopped){if(this.retries||this.subscribeToRetries(),!this.retriesSubscription||this.retriesSubscription.closed)return t.prototype.complete.call(this);this._unsubscribeAndRecycle(),this.notifications.next(void 0)}},e.prototype._unsubscribe=function(){var t=this.notifications,e=this.retriesSubscription;t&&(t.unsubscribe(),this.notifications=void 0),e&&(e.unsubscribe(),this.retriesSubscription=void 0),this.retries=void 0},e.prototype._unsubscribeAndRecycle=function(){var e=this._unsubscribe;return this._unsubscribe=null,t.prototype._unsubscribeAndRecycle.call(this),this._unsubscribe=e,this},e.prototype.subscribeToRetries=function(){var e;this.notifications=new sn.xQ;try{e=(0,this.notifier)(this.notifications)}catch(e){return t.prototype.complete.call(this)}this.retries=e,this.retriesSubscription=(0,i.ft)(e,new i.IY(this))},e}(i.Ds);function In(t){return void 0===t&&(t=-1),function(e){return e.lift(new Tn(t,e))}}var Tn=function(){function t(t,e){this.count=t,this.source=e}return t.prototype.call=function(t,e){return e.subscribe(new _n(t,this.count,this.source))},t}(),_n=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.count=n,i.source=r,i}return r.ZT(e,t),e.prototype.error=function(e){if(!this.isStopped){var n=this.source,r=this.count;if(0===r)return t.prototype.error.call(this,e);r>-1&&(this.count=r-1),n.subscribe(this._unsubscribeAndRecycle())}},e}(p.L);function En(t){return function(e){return e.lift(new Sn(t,e))}}var Sn=function(){function t(t,e){this.notifier=t,this.source=e}return t.prototype.call=function(t,e){return e.subscribe(new kn(t,this.notifier,this.source))},t}(),kn=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.notifier=n,i.source=r,i}return r.ZT(e,t),e.prototype.error=function(e){if(!this.isStopped){var n=this.errors,r=this.retries,s=this.retriesSubscription;if(r)this.errors=void 0,this.retriesSubscription=void 0;else{n=new sn.xQ;try{r=(0,this.notifier)(n)}catch(e){return t.prototype.error.call(this,e)}s=(0,i.ft)(r,new i.IY(this))}this._unsubscribeAndRecycle(),this.errors=n,this.retries=r,this.retriesSubscription=s,n.next(e)}},e.prototype._unsubscribe=function(){var t=this.errors,e=this.retriesSubscription;t&&(t.unsubscribe(),this.errors=void 0),e&&(e.unsubscribe(),this.retriesSubscription=void 0),this.retries=void 0},e.prototype.notifyNext=function(){var t=this._unsubscribe;this._unsubscribe=null,this._unsubscribeAndRecycle(),this._unsubscribe=t,this.source.subscribe(this)},e}(i.Ds),An=n(3018);function Nn(t){return function(e){return e.lift(new xn(t))}}var xn=function(){function t(t){this.notifier=t}return t.prototype.call=function(t,e){var n=new Cn(t),r=e.subscribe(n);return r.add((0,i.ft)(this.notifier,new i.IY(n))),r},t}(),Cn=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.hasValue=!1,e}return r.ZT(e,t),e.prototype._next=function(t){this.value=t,this.hasValue=!0},e.prototype.notifyNext=function(){this.emitValue()},e.prototype.notifyComplete=function(){this.emitValue()},e.prototype.emitValue=function(){this.hasValue&&(this.hasValue=!1,this.destination.next(this.value))},e}(i.Ds);function Dn(t,e){return void 0===e&&(e=c.P),function(n){return n.lift(new On(t,e))}}var On=function(){function t(t,e){this.period=t,this.scheduler=e}return t.prototype.call=function(t,e){return e.subscribe(new Rn(t,this.period,this.scheduler))},t}(),Rn=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.period=n,i.scheduler=r,i.hasValue=!1,i.add(r.schedule(Pn,n,{subscriber:i,period:n})),i}return r.ZT(e,t),e.prototype._next=function(t){this.lastValue=t,this.hasValue=!0},e.prototype.notifyNext=function(){this.hasValue&&(this.hasValue=!1,this.destination.next(this.lastValue))},e}(p.L);function Pn(t){var e=t.subscriber,n=t.period;e.notifyNext(),this.schedule(t,n)}function Ln(t,e){return function(n){return n.lift(new Mn(t,e))}}var Mn=function(){function t(t,e){this.compareTo=t,this.comparator=e}return t.prototype.call=function(t,e){return e.subscribe(new Fn(t,this.compareTo,this.comparator))},t}(),Fn=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.compareTo=n,i.comparator=r,i._a=[],i._b=[],i._oneComplete=!1,i.destination.add(n.subscribe(new Un(e,i))),i}return r.ZT(e,t),e.prototype._next=function(t){this._oneComplete&&0===this._b.length?this.emit(!1):(this._a.push(t),this.checkValues())},e.prototype._complete=function(){this._oneComplete?this.emit(0===this._a.length&&0===this._b.length):this._oneComplete=!0,this.unsubscribe()},e.prototype.checkValues=function(){for(var t=this,e=t._a,n=t._b,r=t.comparator;e.length>0&&n.length>0;){var i=e.shift(),s=n.shift(),o=!1;try{o=r?r(i,s):i===s}catch(t){this.destination.error(t)}o||this.emit(!1)}},e.prototype.emit=function(t){var e=this.destination;e.next(t),e.complete()},e.prototype.nextB=function(t){this._oneComplete&&0===this._a.length?this.emit(!1):(this._b.push(t),this.checkValues())},e.prototype.completeB=function(){this._oneComplete?this.emit(0===this._a.length&&0===this._b.length):this._oneComplete=!0},e}(p.L),Un=function(t){function e(e,n){var r=t.call(this,e)||this;return r.parent=n,r}return r.ZT(e,t),e.prototype._next=function(t){this.parent.nextB(t)},e.prototype._error=function(t){this.parent.error(t),this.unsubscribe()},e.prototype._complete=function(){this.parent.completeB(),this.unsubscribe()},e}(p.L);function Vn(){return new sn.xQ}function jn(){return function(t){return(0,An.x)()(We(Vn)(t))}}function qn(t,e,n){var r;return r=t&&"object"==typeof t?t:{bufferSize:t,windowTime:e,refCount:!1,scheduler:n},function(t){return t.lift(function(t){var e,n,r=t.bufferSize,i=void 0===r?Number.POSITIVE_INFINITY:r,s=t.windowTime,o=void 0===s?Number.POSITIVE_INFINITY:s,a=t.refCount,c=t.scheduler,u=0,h=!1,l=!1;return function(t){var r;u++,!e||h?(h=!1,e=new ln.t(i,o,c),r=e.subscribe(this),n=t.subscribe({next:function(t){e.next(t)},error:function(t){h=!0,e.error(t)},complete:function(){l=!0,n=void 0,e.complete()}})):r=e.subscribe(this),this.add((function(){u--,r.unsubscribe(),n&&!l&&a&&0===u&&(n.unsubscribe(),n=void 0,e=void 0)}))}}(r))}}function Bn(t){return function(e){return e.lift(new zn(t,e))}}var zn=function(){function t(t,e){this.predicate=t,this.source=e}return t.prototype.call=function(t,e){return e.subscribe(new Kn(t,this.predicate,this.source))},t}(),Kn=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.predicate=n,i.source=r,i.seenValue=!1,i.index=0,i}return r.ZT(e,t),e.prototype.applySingleValue=function(t){this.seenValue?this.destination.error("Sequence contains more than one element"):(this.seenValue=!0,this.singleValue=t)},e.prototype._next=function(t){var e=this.index++;this.predicate?this.tryNext(t,e):this.applySingleValue(t)},e.prototype.tryNext=function(t,e){try{this.predicate(t,e,this.source)&&this.applySingleValue(t)}catch(t){this.destination.error(t)}},e.prototype._complete=function(){var t=this.destination;this.index>0?(t.next(this.seenValue?this.singleValue:void 0),t.complete()):t.error(new Rt.K)},e}(p.L);function Wn(t){return function(e){return e.lift(new Gn(t))}}var Gn=function(){function t(t){this.total=t}return t.prototype.call=function(t,e){return e.subscribe(new Hn(t,this.total))},t}(),Hn=function(t){function e(e,n){var r=t.call(this,e)||this;return r.total=n,r.count=0,r}return r.ZT(e,t),e.prototype._next=function(t){++this.count>this.total&&this.destination.next(t)},e}(p.L);function $n(t){return function(e){return e.lift(new Yn(t))}}var Yn=function(){function t(t){if(this._skipCount=t,this._skipCount<0)throw new Dt.W}return t.prototype.call=function(t,e){return 0===this._skipCount?e.subscribe(new p.L(t)):e.subscribe(new Qn(t,this._skipCount))},t}(),Qn=function(t){function e(e,n){var r=t.call(this,e)||this;return r._skipCount=n,r._count=0,r._ring=new Array(n),r}return r.ZT(e,t),e.prototype._next=function(t){var e=this._skipCount,n=this._count++;if(n<e)this._ring[n]=t;else{var r=n%e,i=this._ring,s=i[r];i[r]=t,this.destination.next(s)}},e}(p.L);function Jn(t){return function(e){return e.lift(new Zn(t))}}var Zn=function(){function t(t){this.notifier=t}return t.prototype.call=function(t,e){return e.subscribe(new Xn(t,this.notifier))},t}(),Xn=function(t){function e(e,n){var r=t.call(this,e)||this;r.hasValue=!1;var s=new i.IY(r);r.add(s),r.innerSubscription=s;var o=(0,i.ft)(n,s);return o!==s&&(r.add(o),r.innerSubscription=o),r}return r.ZT(e,t),e.prototype._next=function(e){this.hasValue&&t.prototype._next.call(this,e)},e.prototype.notifyNext=function(){this.hasValue=!0,this.innerSubscription&&this.innerSubscription.unsubscribe()},e.prototype.notifyComplete=function(){},e}(i.Ds);function tr(t){return function(e){return e.lift(new er(t))}}var er=function(){function t(t){this.predicate=t}return t.prototype.call=function(t,e){return e.subscribe(new nr(t,this.predicate))},t}(),nr=function(t){function e(e,n){var r=t.call(this,e)||this;return r.predicate=n,r.skipping=!0,r.index=0,r}return r.ZT(e,t),e.prototype._next=function(t){var e=this.destination;this.skipping&&this.tryCallPredicate(t),this.skipping||e.next(t)},e.prototype.tryCallPredicate=function(t){try{var e=this.predicate(t,this.index++);this.skipping=Boolean(e)}catch(t){this.destination.error(t)}},e}(p.L);function rr(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=t[t.length-1];return(0,b.K)(n)?(t.pop(),function(e){return(0,K.z)(t,e,n)}):function(e){return(0,K.z)(t,e)}}var ir=n(6650),sr=n(5812),or=function(t){function e(e,n,r){void 0===n&&(n=0),void 0===r&&(r=ir.e);var i=t.call(this)||this;return i.source=e,i.delayTime=n,i.scheduler=r,(!(0,sr.k)(n)||n<0)&&(i.delayTime=0),r&&"function"==typeof r.schedule||(i.scheduler=ir.e),i}return r.ZT(e,t),e.create=function(t,n,r){return void 0===n&&(n=0),void 0===r&&(r=ir.e),new e(t,n,r)},e.dispatch=function(t){var e=t.source,n=t.subscriber;return this.add(e.subscribe(n))},e.prototype._subscribe=function(t){var n=this.delayTime,r=this.source;return this.scheduler.schedule(e.dispatch,n,{source:r,subscriber:t})},e}(mt.y);function ar(t,e){return void 0===e&&(e=0),function(n){return n.lift(new cr(t,e))}}var cr=function(){function t(t,e){this.scheduler=t,this.delay=e}return t.prototype.call=function(t,e){return new or(e,this.delay,this.scheduler).subscribe(t)},t}();function ur(t,e){return"function"==typeof e?function(n){return n.pipe(ur((function(n,r){return(0,B.D)(t(n,r)).pipe((0,Jt.U)((function(t,i){return e(n,t,r,i)})))})))}:function(e){return e.lift(new hr(t))}}var hr=function(){function t(t){this.project=t}return t.prototype.call=function(t,e){return e.subscribe(new lr(t,this.project))},t}(),lr=function(t){function e(e,n){var r=t.call(this,e)||this;return r.project=n,r.index=0,r}return r.ZT(e,t),e.prototype._next=function(t){var e,n=this.index++;try{e=this.project(t,n)}catch(t){return void this.destination.error(t)}this._innerSub(e)},e.prototype._innerSub=function(t){var e=this.innerSubscription;e&&e.unsubscribe();var n=new i.IY(this),r=this.destination;r.add(n),this.innerSubscription=(0,i.ft)(t,n),this.innerSubscription!==n&&r.add(this.innerSubscription)},e.prototype._complete=function(){var e=this.innerSubscription;e&&!e.closed||t.prototype._complete.call(this),this.unsubscribe()},e.prototype._unsubscribe=function(){this.innerSubscription=void 0},e.prototype.notifyComplete=function(){this.innerSubscription=void 0,this.isStopped&&t.prototype._complete.call(this)},e.prototype.notifyNext=function(t){this.destination.next(t)},e}(i.Ds);function dr(){return ur(le.y)}function fr(t,e){return e?ur((function(){return t}),e):ur((function(){return t}))}function pr(t){return function(e){return e.lift(new mr(t))}}var mr=function(){function t(t){this.notifier=t}return t.prototype.call=function(t,e){var n=new gr(t),r=(0,i.ft)(this.notifier,new i.IY(n));return r&&!n.seenValue?(n.add(r),e.subscribe(n)):n},t}(),gr=function(t){function e(e){var n=t.call(this,e)||this;return n.seenValue=!1,n}return r.ZT(e,t),e.prototype.notifyNext=function(){this.seenValue=!0,this.complete()},e.prototype.notifyComplete=function(){},e}(i.Ds);function yr(t,e){return void 0===e&&(e=!1),function(n){return n.lift(new vr(t,e))}}var vr=function(){function t(t,e){this.predicate=t,this.inclusive=e}return t.prototype.call=function(t,e){return e.subscribe(new br(t,this.predicate,this.inclusive))},t}(),br=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.predicate=n,i.inclusive=r,i.index=0,i}return r.ZT(e,t),e.prototype._next=function(t){var e,n=this.destination;try{e=this.predicate(t,this.index++)}catch(t){return void n.error(t)}this.nextOrComplete(t,e)},e.prototype.nextOrComplete=function(t,e){var n=this.destination;Boolean(e)?n.next(t):(this.inclusive&&n.next(t),n.complete())},e}(p.L),wr=n(3306),Ir=n(4156);function Tr(t,e,n){return function(r){return r.lift(new _r(t,e,n))}}var _r=function(){function t(t,e,n){this.nextOrObserver=t,this.error=e,this.complete=n}return t.prototype.call=function(t,e){return e.subscribe(new Er(t,this.nextOrObserver,this.error,this.complete))},t}(),Er=function(t){function e(e,n,r,i){var s=t.call(this,e)||this;return s._tapNext=wr.Z,s._tapError=wr.Z,s._tapComplete=wr.Z,s._tapError=r||wr.Z,s._tapComplete=i||wr.Z,(0,Ir.m)(n)?(s._context=s,s._tapNext=n):n&&(s._context=n,s._tapNext=n.next||wr.Z,s._tapError=n.error||wr.Z,s._tapComplete=n.complete||wr.Z),s}return r.ZT(e,t),e.prototype._next=function(t){try{this._tapNext.call(this._context,t)}catch(t){return void this.destination.error(t)}this.destination.next(t)},e.prototype._error=function(t){try{this._tapError.call(this._context,t)}catch(t){return void this.destination.error(t)}this.destination.error(t)},e.prototype._complete=function(){try{this._tapComplete.call(this._context)}catch(t){return void this.destination.error(t)}return this.destination.complete()},e}(p.L),Sr={leading:!0,trailing:!1};function kr(t,e){return void 0===e&&(e=Sr),function(n){return n.lift(new Ar(t,!!e.leading,!!e.trailing))}}var Ar=function(){function t(t,e,n){this.durationSelector=t,this.leading=e,this.trailing=n}return t.prototype.call=function(t,e){return e.subscribe(new Nr(t,this.durationSelector,this.leading,this.trailing))},t}(),Nr=function(t){function e(e,n,r,i){var s=t.call(this,e)||this;return s.destination=e,s.durationSelector=n,s._leading=r,s._trailing=i,s._hasValue=!1,s}return r.ZT(e,t),e.prototype._next=function(t){this._hasValue=!0,this._sendValue=t,this._throttled||(this._leading?this.send():this.throttle(t))},e.prototype.send=function(){var t=this._hasValue,e=this._sendValue;t&&(this.destination.next(e),this.throttle(e)),this._hasValue=!1,this._sendValue=void 0},e.prototype.throttle=function(t){var e=this.tryDurationSelector(t);e&&this.add(this._throttled=(0,i.ft)(e,new i.IY(this)))},e.prototype.tryDurationSelector=function(t){try{return this.durationSelector(t)}catch(t){return this.destination.error(t),null}},e.prototype.throttlingDone=function(){var t=this._throttled,e=this._trailing;t&&t.unsubscribe(),this._throttled=void 0,e&&this.send()},e.prototype.notifyNext=function(){this.throttlingDone()},e.prototype.notifyComplete=function(){this.throttlingDone()},e}(i.Ds);function xr(t,e,n){return void 0===e&&(e=c.P),void 0===n&&(n=Sr),function(r){return r.lift(new Cr(t,e,n.leading,n.trailing))}}var Cr=function(){function t(t,e,n,r){this.duration=t,this.scheduler=e,this.leading=n,this.trailing=r}return t.prototype.call=function(t,e){return e.subscribe(new Dr(t,this.duration,this.scheduler,this.leading,this.trailing))},t}(),Dr=function(t){function e(e,n,r,i,s){var o=t.call(this,e)||this;return o.duration=n,o.scheduler=r,o.leading=i,o.trailing=s,o._hasTrailingValue=!1,o._trailingValue=null,o}return r.ZT(e,t),e.prototype._next=function(t){this.throttled?this.trailing&&(this._trailingValue=t,this._hasTrailingValue=!0):(this.add(this.throttled=this.scheduler.schedule(Or,this.duration,{subscriber:this})),this.leading?this.destination.next(t):this.trailing&&(this._trailingValue=t,this._hasTrailingValue=!0))},e.prototype._complete=function(){this._hasTrailingValue?(this.destination.next(this._trailingValue),this.destination.complete()):this.destination.complete()},e.prototype.clearThrottle=function(){var t=this.throttled;t&&(this.trailing&&this._hasTrailingValue&&(this.destination.next(this._trailingValue),this._trailingValue=null,this._hasTrailingValue=!1),t.unsubscribe(),this.remove(t),this.throttled=null)},e}(p.L);function Or(t){t.subscriber.clearThrottle()}var Rr=n(1410);function Pr(t){return void 0===t&&(t=c.P),function(e){return(0,Rr.P)((function(){return e.pipe(Ce((function(e,n){var r=e.current;return{value:n,current:t.now(),last:r}}),{current:t.now(),value:void 0,last:void 0}),(0,Jt.U)((function(t){var e=t.current,n=t.last,r=t.value;return new Lr(r,e-n)})))}))}}var Lr=function(){return function(t,e){this.value=t,this.interval=e}}(),Mr=n(1462);function Fr(t,e,n){return void 0===n&&(n=c.P),function(r){var i=ut(t),s=i?+t-n.now():Math.abs(t);return r.lift(new Ur(s,i,e,n))}}var Ur=function(){function t(t,e,n,r){this.waitFor=t,this.absoluteTimeout=e,this.withObservable=n,this.scheduler=r}return t.prototype.call=function(t,e){return e.subscribe(new Vr(t,this.absoluteTimeout,this.waitFor,this.withObservable,this.scheduler))},t}(),Vr=function(t){function e(e,n,r,i,s){var o=t.call(this,e)||this;return o.absoluteTimeout=n,o.waitFor=r,o.withObservable=i,o.scheduler=s,o.scheduleTimeout(),o}return r.ZT(e,t),e.dispatchTimeout=function(t){var e=t.withObservable;t._unsubscribeAndRecycle(),t.add((0,i.ft)(e,new i.IY(t)))},e.prototype.scheduleTimeout=function(){var t=this.action;t?this.action=t.schedule(this,this.waitFor):this.add(this.action=this.scheduler.schedule(e.dispatchTimeout,this.waitFor,this))},e.prototype._next=function(e){this.absoluteTimeout||this.scheduleTimeout(),t.prototype._next.call(this,e)},e.prototype._unsubscribe=function(){this.action=void 0,this.scheduler=null,this.withObservable=null},e}(i.Ds),jr=n(4944);function qr(t,e){return void 0===e&&(e=c.P),Fr(t,(0,jr._)(new Mr.W),e)}function Br(t){return void 0===t&&(t=c.P),(0,Jt.U)((function(e){return new zr(e,t.now())}))}var zr=function(){return function(t,e){this.value=t,this.timestamp=e}}();function Kr(t,e,n){return 0===n?[e]:(t.push(e),t)}function Wr(){return Pe(Kr,[])}function Gr(t){return function(e){return e.lift(new Hr(t))}}var Hr=function(){function t(t){this.windowBoundaries=t}return t.prototype.call=function(t,e){var n=new $r(t),r=e.subscribe(n);return r.closed||n.add((0,i.ft)(this.windowBoundaries,new i.IY(n))),r},t}(),$r=function(t){function e(e){var n=t.call(this,e)||this;return n.window=new sn.xQ,e.next(n.window),n}return r.ZT(e,t),e.prototype.notifyNext=function(){this.openWindow()},e.prototype.notifyError=function(t){this._error(t)},e.prototype.notifyComplete=function(){this._complete()},e.prototype._next=function(t){this.window.next(t)},e.prototype._error=function(t){this.window.error(t),this.destination.error(t)},e.prototype._complete=function(){this.window.complete(),this.destination.complete()},e.prototype._unsubscribe=function(){this.window=null},e.prototype.openWindow=function(){var t=this.window;t&&t.complete();var e=this.destination,n=this.window=new sn.xQ;e.next(n)},e}(i.Ds);function Yr(t,e){return void 0===e&&(e=0),function(n){return n.lift(new Qr(t,e))}}var Qr=function(){function t(t,e){this.windowSize=t,this.startWindowEvery=e}return t.prototype.call=function(t,e){return e.subscribe(new Jr(t,this.windowSize,this.startWindowEvery))},t}(),Jr=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.destination=e,i.windowSize=n,i.startWindowEvery=r,i.windows=[new sn.xQ],i.count=0,e.next(i.windows[0]),i}return r.ZT(e,t),e.prototype._next=function(t){for(var e=this.startWindowEvery>0?this.startWindowEvery:this.windowSize,n=this.destination,r=this.windowSize,i=this.windows,s=i.length,o=0;o<s&&!this.closed;o++)i[o].next(t);var a=this.count-r+1;if(a>=0&&a%e==0&&!this.closed&&i.shift().complete(),++this.count%e==0&&!this.closed){var c=new sn.xQ;i.push(c),n.next(c)}},e.prototype._error=function(t){var e=this.windows;if(e)for(;e.length>0&&!this.closed;)e.shift().error(t);this.destination.error(t)},e.prototype._complete=function(){var t=this.windows;if(t)for(;t.length>0&&!this.closed;)t.shift().complete();this.destination.complete()},e.prototype._unsubscribe=function(){this.count=0,this.windows=null},e}(p.L);function Zr(t){var e=c.P,n=null,r=Number.POSITIVE_INFINITY;return(0,b.K)(arguments[3])&&(e=arguments[3]),(0,b.K)(arguments[2])?e=arguments[2]:(0,sr.k)(arguments[2])&&(r=Number(arguments[2])),(0,b.K)(arguments[1])?e=arguments[1]:(0,sr.k)(arguments[1])&&(n=Number(arguments[1])),function(i){return i.lift(new Xr(t,n,r,e))}}var Xr=function(){function t(t,e,n,r){this.windowTimeSpan=t,this.windowCreationInterval=e,this.maxWindowSize=n,this.scheduler=r}return t.prototype.call=function(t,e){return e.subscribe(new ei(t,this.windowTimeSpan,this.windowCreationInterval,this.maxWindowSize,this.scheduler))},t}(),ti=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._numberOfNextedValues=0,e}return r.ZT(e,t),e.prototype.next=function(e){this._numberOfNextedValues++,t.prototype.next.call(this,e)},Object.defineProperty(e.prototype,"numberOfNextedValues",{get:function(){return this._numberOfNextedValues},enumerable:!0,configurable:!0}),e}(sn.xQ),ei=function(t){function e(e,n,r,i,s){var o=t.call(this,e)||this;o.destination=e,o.windowTimeSpan=n,o.windowCreationInterval=r,o.maxWindowSize=i,o.scheduler=s,o.windows=[];var a=o.openWindow();if(null!==r&&r>=0){var c={subscriber:o,window:a,context:null},u={windowTimeSpan:n,windowCreationInterval:r,subscriber:o,scheduler:s};o.add(s.schedule(ii,n,c)),o.add(s.schedule(ri,r,u))}else{var h={subscriber:o,window:a,windowTimeSpan:n};o.add(s.schedule(ni,n,h))}return o}return r.ZT(e,t),e.prototype._next=function(t){for(var e=this.windows,n=e.length,r=0;r<n;r++){var i=e[r];i.closed||(i.next(t),i.numberOfNextedValues>=this.maxWindowSize&&this.closeWindow(i))}},e.prototype._error=function(t){for(var e=this.windows;e.length>0;)e.shift().error(t);this.destination.error(t)},e.prototype._complete=function(){for(var t=this.windows;t.length>0;){var e=t.shift();e.closed||e.complete()}this.destination.complete()},e.prototype.openWindow=function(){var t=new ti;return this.windows.push(t),this.destination.next(t),t},e.prototype.closeWindow=function(t){t.complete();var e=this.windows;e.splice(e.indexOf(t),1)},e}(p.L);function ni(t){var e=t.subscriber,n=t.windowTimeSpan,r=t.window;r&&e.closeWindow(r),t.window=e.openWindow(),this.schedule(t,n)}function ri(t){var e=t.windowTimeSpan,n=t.subscriber,r=t.scheduler,i=t.windowCreationInterval,s=n.openWindow(),o=this,a={action:o,subscription:null},c={subscriber:n,window:s,context:a};a.subscription=r.schedule(ii,e,c),o.add(a.subscription),o.schedule(t,i)}function ii(t){var e=t.subscriber,n=t.window,r=t.context;r&&r.action&&r.subscription&&r.action.remove(r.subscription),e.closeWindow(n)}function si(t,e){return function(n){return n.lift(new oi(t,e))}}var oi=function(){function t(t,e){this.openings=t,this.closingSelector=e}return t.prototype.call=function(t,e){return e.subscribe(new ai(t,this.openings,this.closingSelector))},t}(),ai=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.openings=n,i.closingSelector=r,i.contexts=[],i.add(i.openSubscription=(0,N.D)(i,n,n)),i}return r.ZT(e,t),e.prototype._next=function(t){var e=this.contexts;if(e)for(var n=e.length,r=0;r<n;r++)e[r].window.next(t)},e.prototype._error=function(e){var n=this.contexts;if(this.contexts=null,n)for(var r=n.length,i=-1;++i<r;){var s=n[i];s.window.error(e),s.subscription.unsubscribe()}t.prototype._error.call(this,e)},e.prototype._complete=function(){var e=this.contexts;if(this.contexts=null,e)for(var n=e.length,r=-1;++r<n;){var i=e[r];i.window.complete(),i.subscription.unsubscribe()}t.prototype._complete.call(this)},e.prototype._unsubscribe=function(){var t=this.contexts;if(this.contexts=null,t)for(var e=t.length,n=-1;++n<e;){var r=t[n];r.window.unsubscribe(),r.subscription.unsubscribe()}},e.prototype.notifyNext=function(t,e,n,r,i){if(t===this.openings){var s=void 0;try{s=(0,this.closingSelector)(e)}catch(t){return this.error(t)}var o=new sn.xQ,a=new A.w,c={window:o,subscription:a};this.contexts.push(c);var u=(0,N.D)(this,s,c);u.closed?this.closeWindow(this.contexts.length-1):(u.context=c,a.add(u)),this.destination.next(o)}else this.closeWindow(this.contexts.indexOf(t))},e.prototype.notifyError=function(t){this.error(t)},e.prototype.notifyComplete=function(t){t!==this.openSubscription&&this.closeWindow(this.contexts.indexOf(t.context))},e.prototype.closeWindow=function(t){if(-1!==t){var e=this.contexts,n=e[t],r=n.window,i=n.subscription;e.splice(t,1),r.complete(),i.unsubscribe()}},e}(x.L);function ci(t){return function(e){return e.lift(new ui(t))}}var ui=function(){function t(t){this.closingSelector=t}return t.prototype.call=function(t,e){return e.subscribe(new hi(t,this.closingSelector))},t}(),hi=function(t){function e(e,n){var r=t.call(this,e)||this;return r.destination=e,r.closingSelector=n,r.openWindow(),r}return r.ZT(e,t),e.prototype.notifyNext=function(t,e,n,r,i){this.openWindow(i)},e.prototype.notifyError=function(t){this._error(t)},e.prototype.notifyComplete=function(t){this.openWindow(t)},e.prototype._next=function(t){this.window.next(t)},e.prototype._error=function(t){this.window.error(t),this.destination.error(t),this.unsubscribeClosingNotification()},e.prototype._complete=function(){this.window.complete(),this.destination.complete(),this.unsubscribeClosingNotification()},e.prototype.unsubscribeClosingNotification=function(){this.closingNotification&&this.closingNotification.unsubscribe()},e.prototype.openWindow=function(t){void 0===t&&(t=null),t&&(this.remove(t),t.unsubscribe());var e=this.window;e&&e.complete();var n,r=this.window=new sn.xQ;this.destination.next(r);try{n=(0,this.closingSelector)()}catch(t){return this.destination.error(t),void this.window.error(t)}this.add(this.closingNotification=(0,N.D)(this,n))},e}(x.L);function li(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return function(e){var n;"function"==typeof t[t.length-1]&&(n=t.pop());var r=t;return e.lift(new di(r,n))}}var di=function(){function t(t,e){this.observables=t,this.project=e}return t.prototype.call=function(t,e){return e.subscribe(new fi(t,this.observables,this.project))},t}(),fi=function(t){function e(e,n,r){var i=t.call(this,e)||this;i.observables=n,i.project=r,i.toRespond=[];var s=n.length;i.values=new Array(s);for(var o=0;o<s;o++)i.toRespond.push(o);for(o=0;o<s;o++){var a=n[o];i.add((0,N.D)(i,a,void 0,o))}return i}return r.ZT(e,t),e.prototype.notifyNext=function(t,e,n){this.values[n]=e;var r=this.toRespond;if(r.length>0){var i=r.indexOf(n);-1!==i&&r.splice(i,1)}},e.prototype.notifyComplete=function(){},e.prototype._next=function(t){if(0===this.toRespond.length){var e=[t].concat(this.values);this.project?this._tryProject(e):this.destination.next(e)}},e.prototype._tryProject=function(t){var e;try{e=this.project.apply(this,t)}catch(t){return void this.destination.error(t)}this.destination.next(e)},e}(x.L),pi=n(5080);function mi(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return function(e){return e.lift.call(pi.$R.apply(void 0,[e].concat(t)))}}function gi(t){return function(e){return e.lift(new pi.mx(t))}}},5987:(t,e,n)=>{"use strict";n.d(e,{ZT:()=>i});var r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},r(t,e)};function i(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}},8977:function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(t){try{c(r.next(t))}catch(t){s(t)}}function a(t){try{c(r.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}c((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=e.call(t,o)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var o=s(n(6245)),a=s(n(8060)),c=n(1382),u=n(9699),h=function(){function t(t){var e;this.clientConfig=t,this.tokenStorageKey="RIO_TOKENS_KEY.".concat(t.projectId),this.rootProjectId=null!==(e=t.rootProjectId)&&void 0!==e?e:"root"}return t.prototype.setHttp=function(t){this.http=t},t.prototype.storeTokenData=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e=(0,c.getRuntime)(),void 0===t?[2]:("web"===e&&localStorage.setItem(this.tokenStorageKey,JSON.stringify(t)),"react-native"!==e?[3,2]:[4,a.default.setItem(this.tokenStorageKey,JSON.stringify(t))]);case 1:n.sent(),n.label=2;case 2:return this.currentTokenData=t,[2]}}))}))},t.prototype.clearTokenData=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return"web"===(t=(0,c.getRuntime)())&&localStorage.removeItem(this.tokenStorageKey),"react-native"!==t?[3,2]:[4,a.default.removeItem(this.tokenStorageKey)];case 1:e.sent(),e.label=2;case 2:return this.currentTokenData=void 0,[2]}}))}))},t.prototype.getCurrentTokenData=function(){return r(this,void 0,void 0,(function(){var t,e,n;return i(this,(function(r){switch(r.label){case 0:return"web"!==(e=(0,c.getRuntime)())?[3,1]:((n=localStorage.getItem(this.tokenStorageKey))&&"undefined"!==n&&(t=JSON.parse(n)),[3,4]);case 1:return"react-native"!==e?[3,3]:[4,a.default.getItem(this.tokenStorageKey)];case 2:return(n=r.sent())&&"undefined"!==n&&(t=JSON.parse(n)),[3,4];case 3:t=this.currentTokenData,r.label=4;case 4:return!t||t.accessTokenDecoded&&t.refreshTokenDecoded||(t.accessTokenDecoded=this.decodeToken(t.accessToken),t.refreshTokenDecoded=this.decodeToken(t.refreshToken)),[2,t]}}))}))},t.prototype.getCurrentUser=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return[4,this.getCurrentTokenData()];case 1:return[2,null==(t=e.sent())?void 0:t.accessTokenDecoded]}}))}))},t.prototype.getTokenData=function(){var t,e;return r(this,void 0,void 0,(function(){var n,r,s,o;return i(this,(function(i){switch(i.label){case 0:return[4,this.getCurrentTokenData()];case 1:return(n=i.sent())?(r=n.diff+Math.round((new Date).getTime()/1e3)+30,n.accessTokenDecoded=this.decodeToken(n.accessToken),n.refreshTokenDecoded=this.decodeToken(n.refreshToken),s=null!==(t=n.accessTokenDecoded.exp)&&void 0!==t?t:0,(null!==(e=n.refreshTokenDecoded.exp)&&void 0!==e?e:0)>r&&s<=r?[4,this.getFreshToken(n.refreshToken,n.refreshTokenDecoded.userId)]:[3,3]):[3,4];case 2:return(o=i.sent()).accessTokenDecoded=this.decodeToken(o.accessToken),o.refreshTokenDecoded=this.decodeToken(o.refreshToken),[2,o];case 3:return[2,n];case 4:return[4,this.getAnonymousToken()];case 5:return[2,i.sent()]}}))}))},t.prototype.decodeToken=function(t){return(0,o.default)(t)},t.prototype.formatTokenData=function(t){return t.accessTokenDecoded=this.decodeToken(t.accessToken),t.refreshTokenDecoded=this.decodeToken(t.refreshToken),t.accessTokenDecoded.iat&&(t.diff=t.accessTokenDecoded.iat-Math.floor(Date.now()/1e3)),t},t.prototype.getFreshToken=function(t,e){return r(this,void 0,void 0,(function(){var n,r;return i(this,(function(i){switch(i.label){case 0:return n="/CALL/ProjectUser/refreshToken/".concat(this.clientConfig.projectId,"_").concat(e),[4,this.http.call(this.rootProjectId,n,{method:"get",params:{refreshToken:t}})];case 1:return r=i.sent(),[2,this.formatTokenData(r.data)]}}))}))},t.prototype.getAnonymousToken=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return[4,this.http.call(this.rootProjectId,"/INSTANCE/ProjectUser",{method:"get",params:{projectId:this.clientConfig.projectId}})];case 1:return t=e.sent(),[2,this.formatTokenData(t.data.response)]}}))}))},t.prototype.signIn=function(t){return r(this,void 0,void 0,(function(){var e,n,r;return i(this,(function(i){switch(i.label){case 0:return e=this.decodeToken(t).userId,n="/CALL/ProjectUser/authWithCustomToken/".concat(this.clientConfig.projectId,"_").concat(e),[4,this.http.call(this.rootProjectId,n,{method:"get",params:{customToken:t}})];case 1:return r=i.sent().data,[2,this.formatTokenData(r)]}}))}))},t.prototype.signOut=function(){return r(this,void 0,void 0,(function(){var t,e;return i(this,(function(n){switch(n.label){case 0:return n.trys.push([0,4,,5]),[4,this.getCurrentTokenData()];case 1:return(t=n.sent())?(e="/CALL/ProjectUser/signOut/".concat(this.clientConfig.projectId,"_").concat(t.accessTokenDecoded.userId),[4,this.http.call(this.rootProjectId,e,{method:"get",params:{accessToken:t.accessToken}})]):[3,3];case 2:n.sent(),n.label=3;case 3:return[3,5];case 4:return n.sent(),[3,5];case 5:return[2]}}))}))},t.prototype.getAuthStatus=function(t){if(t&&t.accessTokenDecoded){var e=t.accessTokenDecoded;return{uid:e.userId,identity:e.identity,authStatus:e.anonymous?u.RetterAuthStatus.SIGNED_IN_ANONYM:u.RetterAuthStatus.SIGNED_IN}}return{authStatus:u.RetterAuthStatus.SIGNED_OUT}},t}();e.default=h},6905:function(t,e,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},r.apply(this,arguments)},i=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(t){try{c(r.next(t))}catch(t){s(t)}}function a(t){try{c(r.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}c((r=r.apply(t,e||[])).next())}))},s=this&&this.__generator||function(t,e){var n,r,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=e.call(t,o)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var a=o(n(9669)),c=n(1382),u=n(9699),h=[{id:u.RetterRegion.euWest1,url:"api.retter.io"},{id:u.RetterRegion.euWest1Beta,url:"test-api.retter.io"}],l=function(){function t(t){this.createAxiosInstance(),this.url=t.url,t.region||(t.region=u.RetterRegion.euWest1),this.region=h.find((function(e){return e.id===t.region})),this.culture=t.culture,this.platform=t.culture}return t.prototype.createAxiosInstance=function(){this.axiosInstance=a.default.create({responseType:"json",headers:{"Content-Type":"application/json"},timeout:3e4})},t.prototype.buildUrl=function(t,e){var n=this.url?"".concat(this.url):"".concat(t,".").concat(this.region.url);return"https://".concat(n,"/").concat(t,"/").concat(e.startsWith("/")?e.substr(1):e)},t.prototype.call=function(t,e,n){return i(this,void 0,void 0,(function(){var i,o;return s(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),!(i=r({},n.params)).__culture&&this.culture&&(i.__culture=this.culture),!i.__platform&&this.platform&&(i.__platform=this.platform),"get"===n.method&&!1!==n.base64Encode&&n.data&&(o=(0,c.base64Encode)(JSON.stringify(n.data)),delete n.data,i.data=o,i.__isbase64=!0),[4,this.axiosInstance(r(r({url:this.buildUrl(t,e)},n),{params:i}))];case 1:return[2,s.sent()];case 2:throw s.sent();case 3:return[2]}}))}))},t}();e.default=l},1382:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.base64Encode=e.getRuntime=void 0,e.getRuntime=function(){return"undefined"!=typeof document?"web":"undefined"!=typeof navigator&&"ReactNative"==navigator.product?"react-native":"node"},e.base64Encode=function(t){return Buffer.from(t).toString("base64")}},3607:function(t,e,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},r.apply(this,arguments)},i=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n),Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[n]}})}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),s=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)},o=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(t){try{c(r.next(t))}catch(t){s(t)}}function a(t){try{c(r.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}c((r=r.apply(t,e||[])).next())}))},a=this&&this.__generator||function(t,e){var n,r,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=e.call(t,o)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},c=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var u=n(1591),h=n(5503),l=n(1591),d=n(900),f=n(4143),p=n(1717),m=c(n(8977)),g=c(n(6905)),y=n(9699);s(n(9699),e);var v=function(){function t(){this.initialized=!1,this.authQueue=new f.Subject,this.actionQueue=new f.Subject,this.authStatusSubject=new f.ReplaySubject(1),this.cloudObjects=[]}return t.getInstance=function(e){var n=t.instances.find((function(t){var n;return(null===(n=t.clientConfig)||void 0===n?void 0:n.projectId)===e.projectId}));if(n)return n;var r=new t;return r.init(e),t.instances.push(r),r},t.prototype.init=function(t){var e=this;if(this.initialized)throw new Error("SDK already initialized.");this.initialized=!0,t.retryConfig||(t.retryConfig={}),t.retryConfig.delay||(t.retryConfig.delay=50),t.retryConfig.count||(t.retryConfig.count=3),t.retryConfig.rate||(t.retryConfig.rate=1.5),this.clientConfig=t,this.auth=new m.default(t),this.http=new g.default(t),this.auth.setHttp(this.http),this.processAuthQueue(),this.processActionQueue(),setTimeout((function(){return o(e,void 0,void 0,(function(){var t;return a(this,(function(e){switch(e.label){case 0:return[4,this.auth.getCurrentTokenData()];case 1:return t=e.sent(),this.fireAuthStatus({tokenData:t}),[2]}}))}))}),1)},t.prototype.processAuthQueue=function(){var t=this,e=this.authQueue.pipe((0,p.concatMap)((function(e){return(0,f.defer)((function(){return o(t,void 0,void 0,(function(){var t,n;return a(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.auth.signIn(e.data)];case 1:return t=r.sent(),[2,{action:e,response:t}];case 2:throw n=r.sent(),{action:e,responseError:n};case 3:return[2]}}))}))})).pipe((0,p.materialize)())})),(0,p.share)());e.pipe((0,p.filter)((function(t){return t.hasValue&&"N"===t.kind})),(0,p.map)((function(t){var e;return r(r({},t.value),{tokenData:null===(e=t.value)||void 0===e?void 0:e.response})})),(0,p.switchMap)((function(e){return o(t,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,this.storeTokenData(e)];case 1:return t.sent(),[2,e]}}))}))})),(0,p.switchMap)((function(e){return o(t,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,this.clearCloudObjects()];case 1:return t.sent(),e.tokenData?[4,this.initFirebase(e)]:[3,3];case 2:t.sent(),t.label=3;case 3:return this.fireAuthStatus(e),[2,e]}}))}))}))).subscribe((function(e){var n,r;(null===(n=e.action)||void 0===n?void 0:n.resolve)&&e.action.resolve(null===(r=t.auth)||void 0===r?void 0:r.getAuthStatus(e.tokenData))})),e.pipe((0,p.filter)((function(t){return!1===t.hasValue&&"E"===t.kind}))).subscribe((function(t){var e;if(t.error&&t.error.action&&t.error.action.resolve){var n={authStatus:y.RetterAuthStatus.AUTH_FAILED,message:null===(e=t.error.responseError.response)||void 0===e?void 0:e.data};t.error.action.resolve(n)}})),this.authStatus.subscribe()},t.prototype.processActionQueue=function(){var t=this,e=this.actionQueue.asObservable().pipe((0,p.concatMap)(this.getActionWithTokenData.bind(this)),(0,p.tap)(this.fireAuthStatus.bind(this)),(0,p.filter)((function(t){return null!==t.tokenData})),(0,p.switchMap)((function(e){return o(t,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,this.storeTokenData(e)];case 1:return t.sent(),[2,e]}}))}))})),(0,p.mergeMap)(this.processAction.bind(this)),(0,p.share)());e.pipe((0,p.filter)((function(t){return t.hasValue&&"N"===t.kind}))).subscribe((function(t){t.value&&t.value.action&&t.value.action.resolve&&t.value.response&&t.value.action.resolve(t.value.response)})),e.pipe((0,p.filter)((function(t){return!1===t.hasValue&&"E"===t.kind}))).subscribe((function(t){t.error&&t.error.action&&t.error.action.reject&&t.error.responseError&&t.error.action.reject(t.error.responseError)}))},t.prototype.sendToAuthQueue=function(t){return o(this,void 0,void 0,(function(){var e=this;return a(this,(function(n){return[2,new Promise((function(n,i){e.authQueue.next(r(r({},t),{reject:i,resolve:n}))}))]}))}))},t.prototype.sendToActionQueue=function(t){return o(this,void 0,void 0,(function(){var e=this;return a(this,(function(n){return[2,new Promise((function(n,i){e.actionQueue.next(r(r({},t),{reject:i,resolve:n}))}))]}))}))},t.prototype.getActionWithTokenData=function(t){return o(this,void 0,void 0,(function(){var e,n;return a(this,(function(r){switch(r.label){case 0:return r.trys.push([0,3,,5]),n={action:t},[4,this.auth.getTokenData()];case 1:return n.tokenData=r.sent(),e=n,[4,this.initFirebase(e)];case 2:return r.sent(),[2,e];case 3:return r.sent(),[4,this.signOut()];case 4:return r.sent(),[2,{action:t}];case 5:return[2]}}))}))},t.prototype.fireAuthStatus=function(t){var e=this.auth.getAuthStatus(t.tokenData);this.authStatusSubject.next(e)},t.prototype.storeTokenData=function(t){return o(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,this.auth.storeTokenData(t.tokenData)];case 1:return e.sent(),[2]}}))}))},t.prototype.processAction=function(t){var e,n,i=this;return(null===(e=t.action)||void 0===e?void 0:e.action)===y.RetterActions.EMPTY?(0,f.defer)((function(){return(0,f.of)(r(r({},t),{response:!0}))})).pipe((0,p.materialize)()):(null===(n=t.action)||void 0===n?void 0:n.action)===y.RetterActions.SIGN_IN_ANONYM?(0,f.defer)((function(){return(0,f.of)(r(r({},t),{response:i.auth.getAuthStatus(t.tokenData)}))})).pipe((0,p.materialize)()):(0,f.defer)((function(){return o(i,void 0,void 0,(function(){var e,n,i;return a(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),e=this.getCosEndpoint(t),[4,this.http.call(this.clientConfig.projectId,e.path,e.params)];case 1:return n=s.sent(),[2,r(r({},t),{response:n})];case 2:throw i=s.sent(),r(r({},t),{responseError:i});case 3:return[2]}}))}))})).pipe((0,p.materialize)())},t.prototype.initFirebase=function(t){var e;return o(this,void 0,void 0,(function(){var n;return a(this,(function(r){switch(r.label){case 0:return!(n=null===(e=t.tokenData)||void 0===e?void 0:e.firebase)||this.firebase?[2,t]:(this.firebase=(0,h.initializeApp)({apiKey:n.apiKey,authDomain:n.projectId+".firebaseapp.com",projectId:n.projectId},this.clientConfig.projectId),this.firestore=(0,u.getFirestore)(this.firebase),this.firebaseAuth=(0,d.getAuth)(this.firebase),[4,(0,d.signInWithCustomToken)(this.firebaseAuth,n.customToken)]);case 1:return r.sent(),[2,t]}}))}))},t.prototype.clearFirebase=function(){this.firebase=void 0,this.firestore=void 0,this.firebaseAuth=void 0},t.prototype.getCosEndpoint=function(t){var e,n,i,s,o,a=t.action,c=a.data,u={_token:null!==(e=c.token)&&void 0!==e?e:null===(n=t.tokenData)||void 0===n?void 0:n.accessToken};for(var h in c.queryStringParams||[])u[h]=c.queryStringParams[h];u.__culture=null!==(i=c.culture)&&void 0!==i?i:"en-us",c.platform&&(u.__platform=c.platform);var l={params:u,method:null!==(s=c.httpMethod)&&void 0!==s?s:"post",data:c.body,base64Encode:null===(o=c.base64Encode)||void 0===o||o,headers:r({},c.headers)};if(a.action===y.RetterActions.COS_INSTANCE){var d=c.key?"".concat(c.key.name,"!").concat(c.key.value):c.instanceId;return{path:"INSTANCE/".concat(c.classId).concat(d?"/".concat(d):""),params:l}}return a.action===y.RetterActions.COS_STATE?{path:"STATE/".concat(c.classId,"/").concat(c.instanceId),params:l}:a.action===y.RetterActions.COS_LIST?{path:"LIST/".concat(c.classId),params:l}:{path:"CALL/".concat(c.classId,"/").concat(c.method,"/").concat(c.instanceId),params:l}},t.prototype.getFirebaseListener=function(t,e,n){var r=(0,l.doc)(this.firestore,e,n);return(0,l.onSnapshot)(r,(function(e){for(var n=Object.assign({},e.data()),r=0,i=Object.keys(n);r<i.length;r++){var s=i[r];s.startsWith("__")&&delete n[s]}t.next(n)}))},t.prototype.getFirebaseState=function(t){return o(this,void 0,void 0,(function(){var e,n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return e={role:new f.ReplaySubject(1),user:new f.ReplaySubject(1),public:new f.ReplaySubject(1)},n={role:e.role.asObservable(),user:e.user.asObservable(),public:e.public.asObservable()},r=this.clientConfig.projectId,[4,this.auth.getCurrentUser()];case 1:return i=o.sent(),(s=[]).push(this.getFirebaseListener(e.public,"/projects/".concat(r,"/classes/").concat(t.classId,"/instances"),t.instanceId)),s.push(this.getFirebaseListener(e.user,"/projects/".concat(r,"/classes/").concat(t.classId,"/instances/").concat(t.instanceId,"/userState"),i.userId)),s.push(this.getFirebaseListener(e.role,"/projects/".concat(r,"/classes/").concat(t.classId,"/instances/").concat(t.instanceId,"/roleState"),i.identity)),[2,{state:n,unsubscribers:s}]}}))}))},t.prototype.clearCloudObjects=function(){return o(this,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return this.cloudObjects.map((function(t){return t.unsubscribers.map((function(t){return t()}))})),this.cloudObjects=[],this.firebaseAuth?[4,(0,d.signOut)(this.firebaseAuth)]:[3,2];case 1:t.sent(),t.label=2;case 2:return this.clearFirebase(),[2]}}))}))},t.prototype.signInAnonymously=function(){return o(this,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:if(!this.initialized)throw new Error("Retter SDK not initialized.");return[4,this.sendToActionQueue({action:y.RetterActions.SIGN_IN_ANONYM})];case 1:return[2,t.sent()]}}))}))},t.prototype.authenticateWithCustomToken=function(t){return o(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:if(!this.initialized)throw new Error("Retter SDK not initialized.");return[4,this.sendToAuthQueue({action:y.RetterActions.SIGN_IN,data:t})];case 1:return[2,e.sent()]}}))}))},t.prototype.signOut=function(){return o(this,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:if(!this.initialized)throw new Error("Retter SDK not initialized.");return[4,this.clearCloudObjects()];case 1:return t.sent(),[4,this.auth.signOut()];case 2:return t.sent(),[4,this.auth.clearTokenData()];case 3:return t.sent(),this.fireAuthStatus({}),[2]}}))}))},t.prototype.getCurrentUser=function(){return o(this,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,this.auth.getCurrentUser()];case 1:return[2,t.sent()]}}))}))},t.prototype.getCloudObject=function(t){var e,n,i,s;return o(this,void 0,void 0,(function(){var c,u,h,l,d,f,p,m,g,v,b=this;return a(this,(function(w){switch(w.label){case 0:if(!this.initialized)throw new Error("Retter SDK not initialized.");return t.instanceId&&t.useLocal?[4,this.sendToActionQueue({action:y.RetterActions.EMPTY})]:[3,2];case 1:return w.sent(),[3,4];case 2:return[4,this.sendToActionQueue({action:y.RetterActions.COS_INSTANCE,data:t})];case 3:u=w.sent().data,c=u,t.instanceId=c.instanceId,w.label=4;case 4:return(h=this.cloudObjects.find((function(e){return e.config.classId===t.classId&&e.config.instanceId===t.instanceId})))?[2,{call:h.call,state:h.state,listInstances:h.listInstances,getState:h.getState,methods:null!==(e=null==c?void 0:c.methods)&&void 0!==e?e:[],instanceId:t.instanceId,response:h.response,isNewInstance:!1}]:[4,this.getFirebaseState(t)];case 5:return l=w.sent(),d=l.state,f=l.unsubscribers,p=function(e){return o(b,void 0,void 0,(function(){var n;return a(this,(function(i){switch(i.label){case 0:e.retryConfig=r(r({},this.clientConfig.retryConfig),e.retryConfig),i.label=1;case 1:return i.trys.push([1,3,,8]),[4,this.sendToActionQueue({action:y.RetterActions.COS_CALL,data:r(r({},e),{classId:t.classId,instanceId:t.instanceId})})];case 2:return[2,i.sent()];case 3:return n=i.sent(),--e.retryConfig.count,e.retryConfig.delay*=e.retryConfig.rate,n.response&&570===n.response.status&&e.retryConfig.count>0?[4,new Promise((function(t){return setTimeout(t,e.retryConfig.delay)}))]:[3,6];case 4:return i.sent(),[4,p(e)];case 5:return[2,i.sent()];case 6:throw n;case 7:return[3,8];case 8:return[2]}}))}))},m=function(e){return o(b,void 0,void 0,(function(){return a(this,(function(n){switch(n.label){case 0:return[4,this.sendToActionQueue({action:y.RetterActions.COS_STATE,data:r(r({},e),{classId:t.classId,instanceId:t.instanceId})})];case 1:return[2,n.sent()]}}))}))},g=function(e){return o(b,void 0,void 0,(function(){return a(this,(function(n){switch(n.label){case 0:return[4,this.sendToActionQueue({action:y.RetterActions.COS_LIST,data:r(r({},e),{classId:t.classId})})];case 1:return[2,n.sent().data.instanceIds]}}))}))},v={call:p,state:d,getState:m,listInstances:g,methods:null!==(n=null==c?void 0:c.methods)&&void 0!==n?n:[],response:null!==(i=null==c?void 0:c.response)&&void 0!==i?i:null,instanceId:t.instanceId,isNewInstance:null!==(s=null==c?void 0:c.isNewInstance)&&void 0!==s&&s},this.cloudObjects.push(r(r({},v),{config:t,unsubscribers:f})),[2,v]}}))}))},Object.defineProperty(t.prototype,"authStatus",{get:function(){return this.authStatusSubject.asObservable().pipe((0,p.distinctUntilChanged)((function(t,e){return t.authStatus===e.authStatus&&t.identity===e.identity&&t.uid===e.uid})))},enumerable:!1,configurable:!0}),t.instances=[],t}();e.default=v},9699:(t,e)=>{"use strict";var n,r,i;Object.defineProperty(e,"__esModule",{value:!0}),e.RetterAuthStatus=e.RetterActions=e.RetterRegion=void 0,(i=e.RetterRegion||(e.RetterRegion={}))[i.euWest1=0]="euWest1",i[i.euWest1Beta=1]="euWest1Beta",(r=e.RetterActions||(e.RetterActions={})).EMPTY="EMPTY",r.SIGN_IN="SIGN_IN",r.SIGN_IN_ANONYM="SIGN_IN_ANONYM",r.COS_CALL="COS_CALL",r.COS_STATE="COS_STATE",r.COS_INSTANCE="COS_INSTANCE",r.COS_LIST="COS_LIST",(n=e.RetterAuthStatus||(e.RetterAuthStatus={})).SIGNED_IN="SIGNED_IN",n.SIGNED_IN_ANONYM="SIGNED_IN_ANONYM",n.SIGNED_OUT="SIGNED_OUT",n.AUTH_FAILED="AUTH_FAILED"},2238:(t,e,n)=>{"use strict";n.d(e,{ZR:()=>s.ZR,Jn:()=>T,l4:()=>h,H9:()=>p,Vr:()=>m,Af:()=>d,Z8:()=>b,lz:()=>f,qX:()=>y,Xd:()=>g,wN:()=>v,P2:()=>k,Mq:()=>E,C6:()=>S,ZF:()=>_,TP:()=>N,KN:()=>A,Ub:()=>x});var r=n(8463),i=n(3333),s=n(4444);class o{constructor(t){this.container=t}getPlatformInfoString(){return this.container.getProviders().map((t=>{if(function(t){const e=t.getComponent();return"VERSION"===(null==e?void 0:e.type)}(t)){const e=t.getImmediate();return`${e.library}/${e.version}`}return null})).filter((t=>t)).join(" ")}}const a="@firebase/app",c="0.7.12",u=new i.Yd("@firebase/app"),h="[DEFAULT]",l={[a]:"fire-core","@firebase/app-compat":"fire-core-compat","@firebase/analytics":"fire-analytics","@firebase/analytics-compat":"fire-analytics-compat","@firebase/app-check":"fire-app-check","@firebase/app-check-compat":"fire-app-check-compat","@firebase/auth":"fire-auth","@firebase/auth-compat":"fire-auth-compat","@firebase/database":"fire-rtdb","@firebase/database-compat":"fire-rtdb-compat","@firebase/functions":"fire-fn","@firebase/functions-compat":"fire-fn-compat","@firebase/installations":"fire-iid","@firebase/installations-compat":"fire-iid-compat","@firebase/messaging":"fire-fcm","@firebase/messaging-compat":"fire-fcm-compat","@firebase/performance":"fire-perf","@firebase/performance-compat":"fire-perf-compat","@firebase/remote-config":"fire-rc","@firebase/remote-config-compat":"fire-rc-compat","@firebase/storage":"fire-gcs","@firebase/storage-compat":"fire-gcs-compat","@firebase/firestore":"fire-fst","@firebase/firestore-compat":"fire-fst-compat","fire-js":"fire-js",firebase:"fire-js-all"},d=new Map,f=new Map;function p(t,e){try{t.container.addComponent(e)}catch(n){u.debug(`Component ${e.name} failed to register with FirebaseApp ${t.name}`,n)}}function m(t,e){t.container.addOrOverwriteComponent(e)}function g(t){const e=t.name;if(f.has(e))return u.debug(`There were multiple attempts to register component ${e}.`),!1;f.set(e,t);for(const e of d.values())p(e,t);return!0}function y(t,e){return t.container.getProvider(e)}function v(t,e,n=h){y(t,e).clearInstance(n)}function b(){f.clear()}const w=new s.LL("app","Firebase",{"no-app":"No Firebase App '{$appName}' has been created - call Firebase App.initializeApp()","bad-app-name":"Illegal App name: '{$appName}","duplicate-app":"Firebase App named '{$appName}' already exists with different options or config","app-deleted":"Firebase App named '{$appName}' already deleted","invalid-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance.","invalid-log-argument":"First argument to `onLog` must be null or a function."});class I{constructor(t,e,n){this._isDeleted=!1,this._options=Object.assign({},t),this._config=Object.assign({},e),this._name=e.name,this._automaticDataCollectionEnabled=e.automaticDataCollectionEnabled,this._container=n,this.container.addComponent(new r.wA("app",(()=>this),"PUBLIC"))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(t){this.checkDestroyed(),this._automaticDataCollectionEnabled=t}get name(){return this.checkDestroyed(),this._name}get options(){return this.checkDestroyed(),this._options}get config(){return this.checkDestroyed(),this._config}get container(){return this._container}get isDeleted(){return this._isDeleted}set isDeleted(t){this._isDeleted=t}checkDestroyed(){if(this.isDeleted)throw w.create("app-deleted",{appName:this._name})}}const T="9.6.2";function _(t,e={}){"object"!=typeof e&&(e={name:e});const n=Object.assign({name:h,automaticDataCollectionEnabled:!1},e),i=n.name;if("string"!=typeof i||!i)throw w.create("bad-app-name",{appName:String(i)});const o=d.get(i);if(o){if((0,s.vZ)(t,o.options)&&(0,s.vZ)(n,o.config))return o;throw w.create("duplicate-app",{appName:i})}const a=new r.H0(i);for(const t of f.values())a.addComponent(t);const c=new I(t,n,a);return d.set(i,c),c}function E(t=h){const e=d.get(t);if(!e)throw w.create("no-app",{appName:t});return e}function S(){return Array.from(d.values())}async function k(t){const e=t.name;d.has(e)&&(d.delete(e),await Promise.all(t.container.getProviders().map((t=>t.delete()))),t.isDeleted=!0)}function A(t,e,n){var i;let s=null!==(i=l[t])&&void 0!==i?i:t;n&&(s+=`-${n}`);const o=s.match(/\s|\//),a=e.match(/\s|\//);if(o||a){const t=[`Unable to register library "${s}" with version "${e}":`];return o&&t.push(`library name "${s}" contains illegal characters (whitespace or "/")`),o&&a&&t.push("and"),a&&t.push(`version name "${e}" contains illegal characters (whitespace or "/")`),void u.warn(t.join(" "))}g(new r.wA(`${s}-version`,(()=>({library:s,version:e})),"VERSION"))}function N(t,e){if(null!==t&&"function"!=typeof t)throw w.create("invalid-log-argument");(0,i.Am)(t,e)}function x(t){(0,i.Ub)(t)}g(new r.wA("platform-logger",(t=>new o(t)),"PRIVATE")),A(a,c,""),A(a,c,"esm2017"),A("fire-js","")},8463:(t,e,n)=>{"use strict";n.d(e,{wA:()=>i,H0:()=>a});var r=n(4444);class i{constructor(t,e,n){this.name=t,this.instanceFactory=e,this.type=n,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(t){return this.instantiationMode=t,this}setMultipleInstances(t){return this.multipleInstances=t,this}setServiceProps(t){return this.serviceProps=t,this}setInstanceCreatedCallback(t){return this.onInstanceCreated=t,this}}const s="[DEFAULT]";class o{constructor(t,e){this.name=t,this.container=e,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(t){const e=this.normalizeInstanceIdentifier(t);if(!this.instancesDeferred.has(e)){const t=new r.BH;if(this.instancesDeferred.set(e,t),this.isInitialized(e)||this.shouldAutoInitialize())try{const n=this.getOrInitializeService({instanceIdentifier:e});n&&t.resolve(n)}catch(t){}}return this.instancesDeferred.get(e).promise}getImmediate(t){var e;const n=this.normalizeInstanceIdentifier(null==t?void 0:t.identifier),r=null!==(e=null==t?void 0:t.optional)&&void 0!==e&&e;if(!this.isInitialized(n)&&!this.shouldAutoInitialize()){if(r)return null;throw Error(`Service ${this.name} is not available`)}try{return this.getOrInitializeService({instanceIdentifier:n})}catch(t){if(r)return null;throw t}}getComponent(){return this.component}setComponent(t){if(t.name!==this.name)throw Error(`Mismatching Component ${t.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=t,this.shouldAutoInitialize()){if(function(t){return"EAGER"===t.instantiationMode}(t))try{this.getOrInitializeService({instanceIdentifier:s})}catch(t){}for(const[t,e]of this.instancesDeferred.entries()){const n=this.normalizeInstanceIdentifier(t);try{const t=this.getOrInitializeService({instanceIdentifier:n});e.resolve(t)}catch(t){}}}}clearInstance(t="[DEFAULT]"){this.instancesDeferred.delete(t),this.instancesOptions.delete(t),this.instances.delete(t)}async delete(){const t=Array.from(this.instances.values());await Promise.all([...t.filter((t=>"INTERNAL"in t)).map((t=>t.INTERNAL.delete())),...t.filter((t=>"_delete"in t)).map((t=>t._delete()))])}isComponentSet(){return null!=this.component}isInitialized(t="[DEFAULT]"){return this.instances.has(t)}getOptions(t="[DEFAULT]"){return this.instancesOptions.get(t)||{}}initialize(t={}){const{options:e={}}=t,n=this.normalizeInstanceIdentifier(t.instanceIdentifier);if(this.isInitialized(n))throw Error(`${this.name}(${n}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const r=this.getOrInitializeService({instanceIdentifier:n,options:e});for(const[t,e]of this.instancesDeferred.entries())n===this.normalizeInstanceIdentifier(t)&&e.resolve(r);return r}onInit(t,e){var n;const r=this.normalizeInstanceIdentifier(e),i=null!==(n=this.onInitCallbacks.get(r))&&void 0!==n?n:new Set;i.add(t),this.onInitCallbacks.set(r,i);const s=this.instances.get(r);return s&&t(s,r),()=>{i.delete(t)}}invokeOnInitCallbacks(t,e){const n=this.onInitCallbacks.get(e);if(n)for(const r of n)try{r(t,e)}catch(t){}}getOrInitializeService({instanceIdentifier:t,options:e={}}){let n=this.instances.get(t);if(!n&&this.component&&(n=this.component.instanceFactory(this.container,{instanceIdentifier:(r=t,r===s?void 0:r),options:e}),this.instances.set(t,n),this.instancesOptions.set(t,e),this.invokeOnInitCallbacks(n,t),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,t,n)}catch(t){}var r;return n||null}normalizeInstanceIdentifier(t="[DEFAULT]"){return this.component?this.component.multipleInstances?t:s:t}shouldAutoInitialize(){return!!this.component&&"EXPLICIT"!==this.component.instantiationMode}}class a{constructor(t){this.name=t,this.providers=new Map}addComponent(t){const e=this.getProvider(t.name);if(e.isComponentSet())throw new Error(`Component ${t.name} has already been registered with ${this.name}`);e.setComponent(t)}addOrOverwriteComponent(t){this.getProvider(t.name).isComponentSet()&&this.providers.delete(t.name),this.addComponent(t)}getProvider(t){if(this.providers.has(t))return this.providers.get(t);const e=new o(t,this);return this.providers.set(t,e),e}getProviders(){return Array.from(this.providers.values())}}},3333:(t,e,n)=>{"use strict";n.d(e,{in:()=>i,Yd:()=>u,Ub:()=>h,Am:()=>l});const r=[];var i;!function(t){t[t.DEBUG=0]="DEBUG",t[t.VERBOSE=1]="VERBOSE",t[t.INFO=2]="INFO",t[t.WARN=3]="WARN",t[t.ERROR=4]="ERROR",t[t.SILENT=5]="SILENT"}(i||(i={}));const s={debug:i.DEBUG,verbose:i.VERBOSE,info:i.INFO,warn:i.WARN,error:i.ERROR,silent:i.SILENT},o=i.INFO,a={[i.DEBUG]:"log",[i.VERBOSE]:"log",[i.INFO]:"info",[i.WARN]:"warn",[i.ERROR]:"error"},c=(t,e,...n)=>{if(e<t.logLevel)return;const r=(new Date).toISOString(),i=a[e];if(!i)throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`);console[i](`[${r}] ${t.name}:`,...n)};class u{constructor(t){this.name=t,this._logLevel=o,this._logHandler=c,this._userLogHandler=null,r.push(this)}get logLevel(){return this._logLevel}set logLevel(t){if(!(t in i))throw new TypeError(`Invalid value "${t}" assigned to \`logLevel\``);this._logLevel=t}setLogLevel(t){this._logLevel="string"==typeof t?s[t]:t}get logHandler(){return this._logHandler}set logHandler(t){if("function"!=typeof t)throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=t}get userLogHandler(){return this._userLogHandler}set userLogHandler(t){this._userLogHandler=t}debug(...t){this._userLogHandler&&this._userLogHandler(this,i.DEBUG,...t),this._logHandler(this,i.DEBUG,...t)}log(...t){this._userLogHandler&&this._userLogHandler(this,i.VERBOSE,...t),this._logHandler(this,i.VERBOSE,...t)}info(...t){this._userLogHandler&&this._userLogHandler(this,i.INFO,...t),this._logHandler(this,i.INFO,...t)}warn(...t){this._userLogHandler&&this._userLogHandler(this,i.WARN,...t),this._logHandler(this,i.WARN,...t)}error(...t){this._userLogHandler&&this._userLogHandler(this,i.ERROR,...t),this._logHandler(this,i.ERROR,...t)}}function h(t){r.forEach((e=>{e.setLogLevel(t)}))}function l(t,e){for(const n of r){let r=null;e&&e.level&&(r=s[e.level]),n.userLogHandler=null===t?null:(e,n,...s)=>{const o=s.map((t=>{if(null==t)return null;if("string"==typeof t)return t;if("number"==typeof t||"boolean"==typeof t)return t.toString();if(t instanceof Error)return t.message;try{return JSON.stringify(t)}catch(t){return null}})).filter((t=>t)).join(" ");n>=(null!=r?r:e.logLevel)&&t({level:i[n].toLowerCase(),message:o,args:s,type:e.name})}}}}},e={};function n(r){var i=e[r];if(void 0!==i)return i.exports;var s=e[r]={exports:{}};return t[r].call(s.exports,s,s.exports,n),s.exports}n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r=n(3607);return r.default})()}));