@retter/sdk 0.7.4 → 0.8.0-development

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(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Retter=t():e.Retter=t()}(self,(()=>(()=>{var e={6199:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r,i,s=n(5319),o=n(1635),a=n(5844),c=n(6336),u=n(6148),l=function(){function e(e){this.container=e}return e.prototype.getPlatformInfoString=function(){return this.container.getProviders().map((function(e){if(function(e){var t=e.getComponent();return"VERSION"===(null==t?void 0:t.type)}(e)){var t=e.getImmediate();return"".concat(t.library,"/").concat(t.version)}return null})).filter((function(e){return e})).join(" ")},e}(),h="@firebase/app",d="0.10.10",f=new a.Logger("@firebase/app"),p="[DEFAULT]",m=((r={})[h]="fire-core",r["@firebase/app-compat"]="fire-core-compat",r["@firebase/analytics"]="fire-analytics",r["@firebase/analytics-compat"]="fire-analytics-compat",r["@firebase/app-check"]="fire-app-check",r["@firebase/app-check-compat"]="fire-app-check-compat",r["@firebase/auth"]="fire-auth",r["@firebase/auth-compat"]="fire-auth-compat",r["@firebase/database"]="fire-rtdb",r["@firebase/database-compat"]="fire-rtdb-compat",r["@firebase/functions"]="fire-fn",r["@firebase/functions-compat"]="fire-fn-compat",r["@firebase/installations"]="fire-iid",r["@firebase/installations-compat"]="fire-iid-compat",r["@firebase/messaging"]="fire-fcm",r["@firebase/messaging-compat"]="fire-fcm-compat",r["@firebase/performance"]="fire-perf",r["@firebase/performance-compat"]="fire-perf-compat",r["@firebase/remote-config"]="fire-rc",r["@firebase/remote-config-compat"]="fire-rc-compat",r["@firebase/storage"]="fire-gcs",r["@firebase/storage-compat"]="fire-gcs-compat",r["@firebase/firestore"]="fire-fst",r["@firebase/firestore-compat"]="fire-fst-compat",r["@firebase/vertexai-preview"]="fire-vertex",r["fire-js"]="fire-js",r.firebase="fire-js-all",r),g=new Map,y=new Map,v=new Map;function b(e,t){try{e.container.addComponent(t)}catch(n){f.debug("Component ".concat(t.name," failed to register with FirebaseApp ").concat(e.name),n)}}function w(e){var t,n,r,i,s=e.name;if(v.has(s))return f.debug("There were multiple attempts to register component ".concat(s,".")),!1;v.set(s,e);try{for(var a=o.__values(g.values()),c=a.next();!c.done;c=a.next())b(c.value,e)}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}try{for(var u=o.__values(y.values()),l=u.next();!l.done;l=u.next())b(l.value,e)}catch(e){r={error:e}}finally{try{l&&!l.done&&(i=u.return)&&i.call(u)}finally{if(r)throw r.error}}return!0}function _(e,t){var n=e.container.getProvider("heartbeat").getImmediate({optional:!0});return n&&n.triggerHeartbeat(),e.container.getProvider(t)}function I(e){return void 0!==e.options}var E=((i={})["no-app"]="No Firebase App '{$appName}' has been created - call initializeApp() first",i["bad-app-name"]="Illegal App name: '{$appName}'",i["duplicate-app"]="Firebase App named '{$appName}' already exists with different options or config",i["app-deleted"]="Firebase App named '{$appName}' already deleted",i["server-app-deleted"]="Firebase Server App has been deleted",i["no-options"]="Need to provide options, when not being deployed to hosting via source.",i["invalid-app-argument"]="firebase.{$appName}() takes either no argument or a Firebase App instance.",i["invalid-log-argument"]="First argument to `onLog` must be null or a function.",i["idb-open"]="Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.",i["idb-get"]="Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.",i["idb-set"]="Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.",i["idb-delete"]="Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.",i["finalization-registry-not-supported"]="FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.",i["invalid-server-app-environment"]="FirebaseServerApp is not for use in browser environments.",i),T=new c.ErrorFactory("app","Firebase",E),S=function(){function e(e,t,n){var r=this;this._isDeleted=!1,this._options=o.__assign({},e),this._config=o.__assign({},t),this._name=t.name,this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled,this._container=n,this.container.addComponent(new s.Component("app",(function(){return r}),"PUBLIC"))}return Object.defineProperty(e.prototype,"automaticDataCollectionEnabled",{get:function(){return this.checkDestroyed(),this._automaticDataCollectionEnabled},set:function(e){this.checkDestroyed(),this._automaticDataCollectionEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"name",{get:function(){return this.checkDestroyed(),this._name},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"options",{get:function(){return this.checkDestroyed(),this._options},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"config",{get:function(){return this.checkDestroyed(),this._config},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"container",{get:function(){return this._container},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isDeleted",{get:function(){return this._isDeleted},set:function(e){this._isDeleted=e},enumerable:!1,configurable:!0}),e.prototype.checkDestroyed=function(){if(this.isDeleted)throw T.create("app-deleted",{appName:this._name})},e}(),C=function(e){function t(t,n,r,i){var s=this,a=void 0!==n.automaticDataCollectionEnabled&&n.automaticDataCollectionEnabled,c={name:r,automaticDataCollectionEnabled:a};if(void 0!==t.apiKey)s=e.call(this,t,c,i)||this;else{var u=t;s=e.call(this,u.options,c,i)||this}return s._serverConfig=o.__assign({automaticDataCollectionEnabled:a},n),s._finalizationRegistry=null,"undefined"!=typeof FinalizationRegistry&&(s._finalizationRegistry=new FinalizationRegistry((function(){s.automaticCleanup()}))),s._refCount=0,s.incRefCount(s._serverConfig.releaseOnDeref),s._serverConfig.releaseOnDeref=void 0,n.releaseOnDeref=void 0,k(h,d,"serverapp"),s}return o.__extends(t,e),t.prototype.toJSON=function(){},Object.defineProperty(t.prototype,"refCount",{get:function(){return this._refCount},enumerable:!1,configurable:!0}),t.prototype.incRefCount=function(e){this.isDeleted||(this._refCount++,void 0!==e&&null!==this._finalizationRegistry&&this._finalizationRegistry.register(e,this))},t.prototype.decRefCount=function(){return this.isDeleted?0:--this._refCount},t.prototype.automaticCleanup=function(){x(this)},Object.defineProperty(t.prototype,"settings",{get:function(){return this.checkDestroyed(),this._serverConfig},enumerable:!1,configurable:!0}),t.prototype.checkDestroyed=function(){if(this.isDeleted)throw T.create("server-app-deleted")},t}(S);function A(e,t){var n,r;void 0===t&&(t={});var i=e;"object"!=typeof t&&(t={name:t});var a=o.__assign({name:p,automaticDataCollectionEnabled:!1},t),u=a.name;if("string"!=typeof u||!u)throw T.create("bad-app-name",{appName:String(u)});if(i||(i=c.getDefaultAppConfig()),!i)throw T.create("no-options");var l=g.get(u);if(l){if(c.deepEqual(i,l.options)&&c.deepEqual(a,l.config))return l;throw T.create("duplicate-app",{appName:u})}var h=new s.ComponentContainer(u);try{for(var d=o.__values(v.values()),f=d.next();!f.done;f=d.next()){var m=f.value;h.addComponent(m)}}catch(e){n={error:e}}finally{try{f&&!f.done&&(r=d.return)&&r.call(d)}finally{if(n)throw n.error}}var y=new S(i,a,h);return g.set(u,y),y}function x(e){return o.__awaiter(this,void 0,void 0,(function(){var t,n;return o.__generator(this,(function(r){switch(r.label){case 0:return t=!1,n=e.name,g.has(n)?(t=!0,g.delete(n)):y.has(n)&&e.decRefCount()<=0&&(y.delete(n),t=!0),t?[4,Promise.all(e.container.getProviders().map((function(e){return e.delete()})))]:[3,2];case 1:r.sent(),e.isDeleted=!0,r.label=2;case 2:return[2]}}))}))}function k(e,t,n){var r,i=null!==(r=m[e])&&void 0!==r?r:e;n&&(i+="-".concat(n));var o=i.match(/\s|\//),a=t.match(/\s|\//);if(o||a){var c=['Unable to register library "'.concat(i,'" with version "').concat(t,'":')];return o&&c.push('library name "'.concat(i,'" contains illegal characters (whitespace or "/")')),o&&a&&c.push("and"),a&&c.push('version name "'.concat(t,'" contains illegal characters (whitespace or "/")')),void f.warn(c.join(" "))}w(new s.Component("".concat(i,"-version"),(function(){return{library:i,version:t}}),"VERSION"))}var N="firebase-heartbeat-database",O=1,D="firebase-heartbeat-store",R=null;function P(){return R||(R=u.openDB(N,O,{upgrade:function(e,t){if(0===t)try{e.createObjectStore(D)}catch(e){console.warn(e)}}}).catch((function(e){throw T.create("idb-open",{originalErrorMessage:e.message})}))),R}function L(e){return o.__awaiter(this,void 0,void 0,(function(){var t,n,r,i,s;return o.__generator(this,(function(o){switch(o.label){case 0:return o.trys.push([0,4,,5]),[4,P()];case 1:return t=o.sent(),[4,(n=t.transaction(D)).objectStore(D).get(F(e))];case 2:return r=o.sent(),[4,n.done];case 3:return o.sent(),[2,r];case 4:return(i=o.sent())instanceof c.FirebaseError?f.warn(i.message):(s=T.create("idb-get",{originalErrorMessage:null==i?void 0:i.message}),f.warn(s.message)),[3,5];case 5:return[2]}}))}))}function M(e,t){return o.__awaiter(this,void 0,void 0,(function(){var n,r,i,s;return o.__generator(this,(function(o){switch(o.label){case 0:return o.trys.push([0,4,,5]),[4,P()];case 1:return n=o.sent(),[4,(r=n.transaction(D,"readwrite")).objectStore(D).put(t,F(e))];case 2:return o.sent(),[4,r.done];case 3:return o.sent(),[3,5];case 4:return(i=o.sent())instanceof c.FirebaseError?f.warn(i.message):(s=T.create("idb-set",{originalErrorMessage:null==i?void 0:i.message}),f.warn(s.message)),[3,5];case 5:return[2]}}))}))}function F(e){return"".concat(e.name,"!").concat(e.options.appId)}var V=function(){function e(e){var t=this;this.container=e,this._heartbeatsCache=null;var n=this.container.getProvider("app").getImmediate();this._storage=new j(n),this._heartbeatsCachePromise=this._storage.read().then((function(e){return t._heartbeatsCache=e,e}))}return e.prototype.triggerHeartbeat=function(){var e,t;return o.__awaiter(this,void 0,void 0,(function(){var n,r,i,s,a;return o.__generator(this,(function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),n=this.container.getProvider("platform-logger").getImmediate(),r=n.getPlatformInfoString(),i=U(),null!=(null===(e=this._heartbeatsCache)||void 0===e?void 0:e.heartbeats)?[3,2]:(s=this,[4,this._heartbeatsCachePromise]);case 1:if(s._heartbeatsCache=o.sent(),null==(null===(t=this._heartbeatsCache)||void 0===t?void 0:t.heartbeats))return[2];o.label=2;case 2:return this._heartbeatsCache.lastSentHeartbeatDate===i||this._heartbeatsCache.heartbeats.some((function(e){return e.date===i}))?[2]:(this._heartbeatsCache.heartbeats.push({date:i,agent:r}),this._heartbeatsCache.heartbeats=this._heartbeatsCache.heartbeats.filter((function(e){var t=new Date(e.date).valueOf();return Date.now()-t<=2592e6})),[2,this._storage.overwrite(this._heartbeatsCache)]);case 3:return a=o.sent(),f.warn(a),[3,4];case 4:return[2]}}))}))},e.prototype.getHeartbeatsHeader=function(){var e;return o.__awaiter(this,void 0,void 0,(function(){var t,n,r,i,s,a;return o.__generator(this,(function(u){switch(u.label){case 0:return u.trys.push([0,6,,7]),null!==this._heartbeatsCache?[3,2]:[4,this._heartbeatsCachePromise];case 1:u.sent(),u.label=2;case 2:return null==(null===(e=this._heartbeatsCache)||void 0===e?void 0:e.heartbeats)||0===this._heartbeatsCache.heartbeats.length?[2,""]:(t=U(),n=function(e,t){var n,r;void 0===t&&(t=1024);var i=[],s=e.slice(),a=function(e){var n=i.find((function(t){return t.agent===e.agent}));if(n){if(n.dates.push(e.date),B(i)>t)return n.dates.pop(),"break"}else if(i.push({agent:e.agent,dates:[e.date]}),B(i)>t)return i.pop(),"break";s=s.slice(1)};try{for(var c=o.__values(e),u=c.next();!u.done&&"break"!==a(u.value);u=c.next());}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}return{heartbeatsToSend:i,unsentEntries:s}}(this._heartbeatsCache.heartbeats),r=n.heartbeatsToSend,i=n.unsentEntries,s=c.base64urlEncodeWithoutPadding(JSON.stringify({version:2,heartbeats:r})),this._heartbeatsCache.lastSentHeartbeatDate=t,i.length>0?(this._heartbeatsCache.heartbeats=i,[4,this._storage.overwrite(this._heartbeatsCache)]):[3,4]);case 3:return u.sent(),[3,5];case 4:this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache),u.label=5;case 5:return[2,s];case 6:return a=u.sent(),f.warn(a),[2,""];case 7:return[2]}}))}))},e}();function U(){return(new Date).toISOString().substring(0,10)}var j=function(){function e(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}return e.prototype.runIndexedDBEnvironmentCheck=function(){return o.__awaiter(this,void 0,void 0,(function(){return o.__generator(this,(function(e){return c.isIndexedDBAvailable()?[2,c.validateIndexedDBOpenable().then((function(){return!0})).catch((function(){return!1}))]:[2,!1]}))}))},e.prototype.read=function(){return o.__awaiter(this,void 0,void 0,(function(){var e;return o.__generator(this,(function(t){switch(t.label){case 0:return[4,this._canUseIndexedDBPromise];case 1:return t.sent()?[3,2]:[2,{heartbeats:[]}];case 2:return[4,L(this.app)];case 3:return(null==(e=t.sent())?void 0:e.heartbeats)?[2,e]:[2,{heartbeats:[]}];case 4:return[2]}}))}))},e.prototype.overwrite=function(e){var t;return o.__awaiter(this,void 0,void 0,(function(){var n;return o.__generator(this,(function(r){switch(r.label){case 0:return[4,this._canUseIndexedDBPromise];case 1:return r.sent()?[3,2]:[2];case 2:return[4,this.read()];case 3:return n=r.sent(),[2,M(this.app,{lastSentHeartbeatDate:null!==(t=e.lastSentHeartbeatDate)&&void 0!==t?t:n.lastSentHeartbeatDate,heartbeats:e.heartbeats})]}}))}))},e.prototype.add=function(e){var t;return o.__awaiter(this,void 0,void 0,(function(){var n;return o.__generator(this,(function(r){switch(r.label){case 0:return[4,this._canUseIndexedDBPromise];case 1:return r.sent()?[3,2]:[2];case 2:return[4,this.read()];case 3:return n=r.sent(),[2,M(this.app,{lastSentHeartbeatDate:null!==(t=e.lastSentHeartbeatDate)&&void 0!==t?t:n.lastSentHeartbeatDate,heartbeats:o.__spreadArray(o.__spreadArray([],o.__read(n.heartbeats),!1),o.__read(e.heartbeats),!1)})]}}))}))},e}();function B(e){return c.base64urlEncodeWithoutPadding(JSON.stringify({version:2,heartbeats:e})).length}w(new s.Component("platform-logger",(function(e){return new l(e)}),"PRIVATE")),w(new s.Component("heartbeat",(function(e){return new V(e)}),"PRIVATE")),k(h,d,"node"),k(h,d,"cjs5"),k("fire-js",""),Object.defineProperty(t,"FirebaseError",{enumerable:!0,get:function(){return c.FirebaseError}}),t.SDK_VERSION="10.13.1",t._DEFAULT_ENTRY_NAME=p,t._addComponent=b,t._addOrOverwriteComponent=function(e,t){e.container.addOrOverwriteComponent(t)},t._apps=g,t._clearComponents=function(){v.clear()},t._components=v,t._getProvider=_,t._isFirebaseApp=I,t._isFirebaseServerApp=function(e){return void 0!==e.settings},t._registerComponent=w,t._removeServiceInstance=function(e,t,n){void 0===n&&(n=p),_(e,t).clearInstance(n)},t._serverApps=y,t.deleteApp=x,t.getApp=function(e){void 0===e&&(e=p);var t=g.get(e);if(!t&&e===p&&c.getDefaultAppConfig())return A();if(!t)throw T.create("no-app",{appName:e});return t},t.getApps=function(){return Array.from(g.values())},t.initializeApp=A,t.initializeServerApp=function(e,t){var n,r,i;if(c.isBrowser()&&!c.isWebWorker())throw T.create("invalid-server-app-environment");void 0===t.automaticDataCollectionEnabled&&(t.automaticDataCollectionEnabled=!1),i=I(e)?e.options:e;var a=o.__assign(o.__assign({},t),i);if(void 0!==a.releaseOnDeref&&delete a.releaseOnDeref,void 0!==t.releaseOnDeref&&"undefined"==typeof FinalizationRegistry)throw T.create("finalization-registry-not-supported",{});var u,l=""+(u=JSON.stringify(a),o.__spreadArray([],o.__read(u),!1).reduce((function(e,t){return Math.imul(31,e)+t.charCodeAt(0)|0}),0)),h=y.get(l);if(h)return h.incRefCount(t.releaseOnDeref),h;var d=new s.ComponentContainer(l);try{for(var f=o.__values(v.values()),p=f.next();!p.done;p=f.next()){var m=p.value;d.addComponent(m)}}catch(e){n={error:e}}finally{try{p&&!p.done&&(r=f.return)&&r.call(f)}finally{if(n)throw n.error}}var g=new C(i,t,l,d);return y.set(l,g),g},t.onLog=function(e,t){if(null!==e&&"function"!=typeof e)throw T.create("invalid-log-argument");a.setUserLogHandler(e,t)},t.registerVersion=k,t.setLogLevel=function(e){a.setLogLevel(e)}},8366:(e,t,n)=>{"use strict";var r=n(6199),i=n(6336),s=n(5844),o=n(1635),a=n(5319);const c=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."}},u=new i.ErrorFactory("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."}),l=new s.Logger("@firebase/auth");function h(e,...t){l.logLevel<=s.LogLevel.ERROR&&l.error(`Auth (${r.SDK_VERSION}): ${e}`,...t)}function d(e,...t){throw y(e,...t)}function f(e,...t){return y(e,...t)}function p(e,t,n){const r=Object.assign(Object.assign({},c()),{[t]:n});return new i.ErrorFactory("auth","Firebase",r).create(t,{appName:e.name})}function m(e){return p(e,"operation-not-supported-in-this-environment","Operations that alter the current user are not supported in conjunction with FirebaseServerApp")}function g(e,t,n){if(!(t instanceof n))throw n.name!==t.constructor.name&&d(e,"argument-error"),p(e,"argument-error",`Type of ${t.constructor.name} does not match expected instance.Did you pass a reference from a different Auth SDK?`)}function y(e,...t){if("string"!=typeof e){const n=t[0],r=[...t.slice(1)];return r[0]&&(r[0].appName=e.name),e._errorFactory.create(n,...r)}return u.create(e,...t)}function v(e,t,...n){if(!e)throw y(t,...n)}function b(e){const t="INTERNAL ASSERTION FAILED: "+e;throw h(t),new Error(t)}function w(e,t){e||b(t)}function _(){var e;return"undefined"!=typeof self&&(null===(e=self.location)||void 0===e?void 0:e.href)||""}function I(){return"http:"===E()||"https:"===E()}function E(){var e;return"undefined"!=typeof self&&(null===(e=self.location)||void 0===e?void 0:e.protocol)||null}class T{constructor(e,t){this.shortDelay=e,this.longDelay=t,w(t>e,"Short delay should be less than long delay!"),this.isMobile=i.isMobileCordova()||i.isReactNative()}get(){return"undefined"!=typeof navigator&&navigator&&"onLine"in navigator&&"boolean"==typeof navigator.onLine&&(I()||i.isBrowserExtension()||"connection"in navigator)&&!navigator.onLine?Math.min(5e3,this.shortDelay):this.isMobile?this.longDelay:this.shortDelay}}function S(e,t){w(e.emulator,"Emulator should always be set here");const{url:n}=e.emulator;return t?`${n}${t.startsWith("/")?t.slice(1):t}`:n}class C{static initialize(e,t,n){this.fetchImpl=e,t&&(this.headersImpl=t),n&&(this.responseImpl=n)}static fetch(){return this.fetchImpl?this.fetchImpl:"undefined"!=typeof self&&"fetch"in self?self.fetch:"undefined"!=typeof globalThis&&globalThis.fetch?globalThis.fetch:"undefined"!=typeof fetch?fetch:void b("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:"undefined"!=typeof globalThis&&globalThis.Headers?globalThis.Headers:"undefined"!=typeof Headers?Headers:void b("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:"undefined"!=typeof globalThis&&globalThis.Response?globalThis.Response:"undefined"!=typeof Response?Response:void b("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}}const A={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:"missing-password",INVALID_LOGIN_CREDENTIALS:"invalid-credential",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",PASSWORD_DOES_NOT_MEET_REQUIREMENTS:"password-does-not-meet-requirements",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",RECAPTCHA_NOT_ENABLED:"recaptcha-not-enabled",MISSING_RECAPTCHA_TOKEN:"missing-recaptcha-token",INVALID_RECAPTCHA_TOKEN:"invalid-recaptcha-token",INVALID_RECAPTCHA_ACTION:"invalid-recaptcha-action",MISSING_CLIENT_TYPE:"missing-client-type",MISSING_RECAPTCHA_VERSION:"missing-recaptcha-version",INVALID_RECAPTCHA_VERSION:"invalid-recaptcha-version",INVALID_REQ_TYPE:"invalid-req-type"},x=new T(3e4,6e4);function k(e,t){return e.tenantId&&!t.tenantId?Object.assign(Object.assign({},t),{tenantId:e.tenantId}):t}async function N(e,t,n,r,s={}){return O(e,s,(async()=>{let s={},o={};r&&("GET"===t?o=r:s={body:JSON.stringify(r)});const a=i.querystring(Object.assign({key:e.config.apiKey},o)).slice(1),c=await e._getAdditionalHeaders();return c["Content-Type"]="application/json",e.languageCode&&(c["X-Firebase-Locale"]=e.languageCode),C.fetch()(R(e,e.config.apiHost,n,a),Object.assign({method:t,headers:c,referrerPolicy:"no-referrer"},s))}))}async function O(e,t,n){e._canInitEmulator=!1;const r=Object.assign(Object.assign({},A),t);try{const t=new L(e),i=await Promise.race([n(),t.promise]);t.clearNetworkTimeout();const s=await i.json();if("needConfirmation"in s)throw M(e,"account-exists-with-different-credential",s);if(i.ok&&!("errorMessage"in s))return s;{const t=i.ok?s.errorMessage:s.error.message,[n,o]=t.split(" : ");if("FEDERATED_USER_ID_ALREADY_LINKED"===n)throw M(e,"credential-already-in-use",s);if("EMAIL_EXISTS"===n)throw M(e,"email-already-in-use",s);if("USER_DISABLED"===n)throw M(e,"user-disabled",s);const a=r[n]||n.toLowerCase().replace(/[_\s]+/g,"-");if(o)throw p(e,a,o);d(e,a)}}catch(t){if(t instanceof i.FirebaseError)throw t;d(e,"network-request-failed",{message:String(t)})}}async function D(e,t,n,r,i={}){const s=await N(e,t,n,r,i);return"mfaPendingCredential"in s&&d(e,"multi-factor-auth-required",{_serverResponse:s}),s}function R(e,t,n,r){const i=`${t}${n}?${r}`;return e.config.emulator?S(e.config,i):`${e.config.apiScheme}://${i}`}function P(e){switch(e){case"ENFORCE":return"ENFORCE";case"AUDIT":return"AUDIT";case"OFF":return"OFF";default:return"ENFORCEMENT_STATE_UNSPECIFIED"}}class L{constructor(e){this.auth=e,this.timer=null,this.promise=new Promise(((e,t)=>{this.timer=setTimeout((()=>t(f(this.auth,"network-request-failed"))),x.get())}))}clearNetworkTimeout(){clearTimeout(this.timer)}}function M(e,t,n){const r={appName:e.name};n.email&&(r.email=n.email),n.phoneNumber&&(r.phoneNumber=n.phoneNumber);const i=f(e,t,r);return i.customData._tokenResponse=n,i}function F(e){return void 0!==e&&void 0!==e.getResponse}function V(e){return void 0!==e&&void 0!==e.enterprise}class U{constructor(e){if(this.siteKey="",this.recaptchaEnforcementState=[],void 0===e.recaptchaKey)throw new Error("recaptchaKey undefined");this.siteKey=e.recaptchaKey.split("/")[3],this.recaptchaEnforcementState=e.recaptchaEnforcementState}getProviderEnforcementState(e){if(!this.recaptchaEnforcementState||0===this.recaptchaEnforcementState.length)return null;for(const t of this.recaptchaEnforcementState)if(t.provider&&t.provider===e)return P(t.enforcementState);return null}isProviderEnabled(e){return"ENFORCE"===this.getProviderEnforcementState(e)||"AUDIT"===this.getProviderEnforcementState(e)}}async function j(e,t){return N(e,"GET","/v2/recaptchaConfig",k(e,t))}async function B(e,t){return N(e,"POST","/v1/accounts:lookup",t)}function q(e){if(e)try{const t=new Date(Number(e));if(!isNaN(t.getTime()))return t.toUTCString()}catch(e){}}async function z(e,t=!1){const n=i.getModularInstance(e),r=await n.getIdToken(t),s=K(r);v(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:r,authTime:q(G(s.auth_time)),issuedAtTime:q(G(s.iat)),expirationTime:q(G(s.exp)),signInProvider:a||null,signInSecondFactor:(null==o?void 0:o.sign_in_second_factor)||null}}function G(e){return 1e3*Number(e)}function K(e){const[t,n,r]=e.split(".");if(void 0===t||void 0===n||void 0===r)return h("JWT malformed, contained fewer than 3 sections"),null;try{const e=i.base64Decode(n);return e?JSON.parse(e):(h("Failed to decode base64 JWT payload"),null)}catch(e){return h("Caught error parsing JWT payload as JSON",null==e?void 0:e.toString()),null}}function W(e){const t=K(e);return v(t,"internal-error"),v(void 0!==t.exp,"internal-error"),v(void 0!==t.iat,"internal-error"),Number(t.exp)-Number(t.iat)}async function $(e,t,n=!1){if(n)return t;try{return await t}catch(t){throw t instanceof i.FirebaseError&&function({code:e}){return"auth/user-disabled"===e||"auth/user-token-expired"===e}(t)&&e.auth.currentUser===e&&await e.auth.signOut(),t}}class H{constructor(e){this.user=e,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(e){var t;if(e){const e=this.errorBackoff;return this.errorBackoff=Math.min(2*this.errorBackoff,96e4),e}{this.errorBackoff=3e4;const e=(null!==(t=this.user.stsTokenManager.expirationTime)&&void 0!==t?t:0)-Date.now()-3e5;return Math.max(0,e)}}schedule(e=!1){if(!this.isRunning)return;const t=this.getInterval(e);this.timerId=setTimeout((async()=>{await this.iteration()}),t)}async iteration(){try{await this.user.getIdToken(!0)}catch(e){return void("auth/network-request-failed"===(null==e?void 0:e.code)&&this.schedule(!0))}this.schedule()}}class Q{constructor(e,t){this.createdAt=e,this.lastLoginAt=t,this._initializeTime()}_initializeTime(){this.lastSignInTime=q(this.lastLoginAt),this.creationTime=q(this.createdAt)}_copy(e){this.createdAt=e.createdAt,this.lastLoginAt=e.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}async function J(e){var t;const n=e.auth,r=await e.getIdToken(),i=await $(e,B(n,{idToken:r}));v(null==i?void 0:i.users.length,n,"internal-error");const s=i.users[0];e._notifyReloadListener(s);const o=(null===(t=s.providerUserInfo)||void 0===t?void 0:t.length)?X(s.providerUserInfo):[],a=(c=e.providerData,u=o,[...c.filter((e=>!u.some((t=>t.providerId===e.providerId)))),...u]);var c,u;const l=e.isAnonymous,h=!(e.email&&s.passwordHash||(null==a?void 0:a.length)),d=!!l&&h,f={uid:s.localId,displayName:s.displayName||null,photoURL:s.photoUrl||null,email:s.email||null,emailVerified:s.emailVerified||!1,phoneNumber:s.phoneNumber||null,tenantId:s.tenantId||null,providerData:a,metadata:new Q(s.createdAt,s.lastLoginAt),isAnonymous:d};Object.assign(e,f)}async function Y(e){const t=i.getModularInstance(e);await J(t),await t.auth._persistUserIfCurrent(t),t.auth._notifyListenersIfCurrent(t)}function X(e){return e.map((e=>{var{providerId:t}=e,n=o.__rest(e,["providerId"]);return{providerId:t,uid:n.rawId||"",displayName:n.displayName||null,email:n.email||null,phoneNumber:n.phoneNumber||null,photoURL:n.photoUrl||null}}))}class Z{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){v(e.idToken,"internal-error"),v(void 0!==e.idToken,"internal-error"),v(void 0!==e.refreshToken,"internal-error");const t="expiresIn"in e&&void 0!==e.expiresIn?Number(e.expiresIn):W(e.idToken);this.updateTokensAndExpiration(e.idToken,e.refreshToken,t)}updateFromIdToken(e){v(0!==e.length,"internal-error");const t=W(e);this.updateTokensAndExpiration(e,null,t)}async getToken(e,t=!1){return t||!this.accessToken||this.isExpired?(v(this.refreshToken,e,"user-token-expired"),this.refreshToken?(await this.refresh(e,this.refreshToken),this.accessToken):null):this.accessToken}clearRefreshToken(){this.refreshToken=null}async refresh(e,t){const{accessToken:n,refreshToken:r,expiresIn:s}=await async function(e,t){const n=await O(e,{},(async()=>{const n=i.querystring({grant_type:"refresh_token",refresh_token:t}).slice(1),{tokenApiHost:r,apiKey:s}=e.config,o=R(e,r,"/v1/token",`key=${s}`),a=await e._getAdditionalHeaders();return a["Content-Type"]="application/x-www-form-urlencoded",C.fetch()(o,{method:"POST",headers:a,body:n})}));return{accessToken:n.access_token,expiresIn:n.expires_in,refreshToken:n.refresh_token}}(e,t);this.updateTokensAndExpiration(n,r,Number(s))}updateTokensAndExpiration(e,t,n){this.refreshToken=t||null,this.accessToken=e||null,this.expirationTime=Date.now()+1e3*n}static fromJSON(e,t){const{refreshToken:n,accessToken:r,expirationTime:i}=t,s=new Z;return n&&(v("string"==typeof n,"internal-error",{appName:e}),s.refreshToken=n),r&&(v("string"==typeof r,"internal-error",{appName:e}),s.accessToken=r),i&&(v("number"==typeof i,"internal-error",{appName:e}),s.expirationTime=i),s}toJSON(){return{refreshToken:this.refreshToken,accessToken:this.accessToken,expirationTime:this.expirationTime}}_assign(e){this.accessToken=e.accessToken,this.refreshToken=e.refreshToken,this.expirationTime=e.expirationTime}_clone(){return Object.assign(new Z,this.toJSON())}_performRefresh(){return b("not implemented")}}function ee(e,t){v("string"==typeof e||void 0===e,"internal-error",{appName:t})}class te{constructor(e){var{uid:t,auth:n,stsTokenManager:r}=e,i=o.__rest(e,["uid","auth","stsTokenManager"]);this.providerId="firebase",this.proactiveRefresh=new H(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=t,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.providerData=i.providerData?[...i.providerData]:[],this.metadata=new Q(i.createdAt||void 0,i.lastLoginAt||void 0)}async getIdToken(e){const t=await $(this,this.stsTokenManager.getToken(this.auth,e));return v(t,this.auth,"internal-error"),this.accessToken!==t&&(this.accessToken=t,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),t}getIdTokenResult(e){return z(this,e)}reload(){return Y(this)}_assign(e){this!==e&&(v(this.uid===e.uid,this.auth,"internal-error"),this.displayName=e.displayName,this.photoURL=e.photoURL,this.email=e.email,this.emailVerified=e.emailVerified,this.phoneNumber=e.phoneNumber,this.isAnonymous=e.isAnonymous,this.tenantId=e.tenantId,this.providerData=e.providerData.map((e=>Object.assign({},e))),this.metadata._copy(e.metadata),this.stsTokenManager._assign(e.stsTokenManager))}_clone(e){const t=new te(Object.assign(Object.assign({},this),{auth:e,stsTokenManager:this.stsTokenManager._clone()}));return t.metadata._copy(this.metadata),t}_onReload(e){v(!this.reloadListener,this.auth,"internal-error"),this.reloadListener=e,this.reloadUserInfo&&(this._notifyReloadListener(this.reloadUserInfo),this.reloadUserInfo=null)}_notifyReloadListener(e){this.reloadListener?this.reloadListener(e):this.reloadUserInfo=e}_startProactiveRefresh(){this.proactiveRefresh._start()}_stopProactiveRefresh(){this.proactiveRefresh._stop()}async _updateTokensIfNecessary(e,t=!1){let n=!1;e.idToken&&e.idToken!==this.stsTokenManager.accessToken&&(this.stsTokenManager.updateFromServerResponse(e),n=!0),t&&await J(this),await this.auth._persistUserIfCurrent(this),n&&this.auth._notifyListenersIfCurrent(this)}async delete(){if(r._isFirebaseServerApp(this.auth.app))return Promise.reject(m(this.auth));const e=await this.getIdToken();return await $(this,async function(e,t){return N(e,"POST","/v1/accounts:delete",t)}(this.auth,{idToken:e})),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((e=>Object.assign({},e))),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(e,t){var n,r,i,s,o,a,c,u;const l=null!==(n=t.displayName)&&void 0!==n?n:void 0,h=null!==(r=t.email)&&void 0!==r?r:void 0,d=null!==(i=t.phoneNumber)&&void 0!==i?i:void 0,f=null!==(s=t.photoURL)&&void 0!==s?s:void 0,p=null!==(o=t.tenantId)&&void 0!==o?o:void 0,m=null!==(a=t._redirectEventId)&&void 0!==a?a:void 0,g=null!==(c=t.createdAt)&&void 0!==c?c:void 0,y=null!==(u=t.lastLoginAt)&&void 0!==u?u:void 0,{uid:b,emailVerified:w,isAnonymous:_,providerData:I,stsTokenManager:E}=t;v(b&&E,e,"internal-error");const T=Z.fromJSON(this.name,E);v("string"==typeof b,e,"internal-error"),ee(l,e.name),ee(h,e.name),v("boolean"==typeof w,e,"internal-error"),v("boolean"==typeof _,e,"internal-error"),ee(d,e.name),ee(f,e.name),ee(p,e.name),ee(m,e.name),ee(g,e.name),ee(y,e.name);const S=new te({uid:b,auth:e,email:h,emailVerified:w,displayName:l,isAnonymous:_,photoURL:f,phoneNumber:d,tenantId:p,stsTokenManager:T,createdAt:g,lastLoginAt:y});return I&&Array.isArray(I)&&(S.providerData=I.map((e=>Object.assign({},e)))),m&&(S._redirectEventId=m),S}static async _fromIdTokenResponse(e,t,n=!1){const r=new Z;r.updateFromServerResponse(t);const i=new te({uid:t.localId,auth:e,stsTokenManager:r,isAnonymous:n});return await J(i),i}static async _fromGetAccountInfoResponse(e,t,n){const r=t.users[0];v(void 0!==r.localId,"internal-error");const i=void 0!==r.providerUserInfo?X(r.providerUserInfo):[],s=!(r.email&&r.passwordHash||(null==i?void 0:i.length)),o=new Z;o.updateFromIdToken(n);const a=new te({uid:r.localId,auth:e,stsTokenManager:o,isAnonymous:s}),c={uid:r.localId,displayName:r.displayName||null,photoURL:r.photoUrl||null,email:r.email||null,emailVerified:r.emailVerified||!1,phoneNumber:r.phoneNumber||null,tenantId:r.tenantId||null,providerData:i,metadata:new Q(r.createdAt,r.lastLoginAt),isAnonymous:!(r.email&&r.passwordHash||(null==i?void 0:i.length))};return Object.assign(a,c),a}}const ne=new Map;function re(e){w(e instanceof Function,"Expected a class definition");let t=ne.get(e);return t?(w(t instanceof e,"Instance stored in cache mismatched with class"),t):(t=new e,ne.set(e,t),t)}class ie{constructor(){this.type="NONE",this.storage={}}async _isAvailable(){return!0}async _set(e,t){this.storage[e]=t}async _get(e){const t=this.storage[e];return void 0===t?null:t}async _remove(e){delete this.storage[e]}_addListener(e,t){}_removeListener(e,t){}}ie.type="NONE";const se=ie;function oe(e,t,n){return`firebase:${e}:${t}:${n}`}class ae{constructor(e,t,n){this.persistence=e,this.auth=t,this.userKey=n;const{config:r,name:i}=this.auth;this.fullUserKey=oe(this.userKey,r.apiKey,i),this.fullPersistenceKey=oe("persistence",r.apiKey,i),this.boundEventHandler=t._onStorageEvent.bind(t),this.persistence._addListener(this.fullUserKey,this.boundEventHandler)}setCurrentUser(e){return this.persistence._set(this.fullUserKey,e.toJSON())}async getCurrentUser(){const e=await this.persistence._get(this.fullUserKey);return e?te._fromJSON(this.auth,e):null}removeCurrentUser(){return this.persistence._remove(this.fullUserKey)}savePersistenceForRedirect(){return this.persistence._set(this.fullPersistenceKey,this.persistence.type)}async setPersistence(e){if(this.persistence===e)return;const t=await this.getCurrentUser();return await this.removeCurrentUser(),this.persistence=e,t?this.setCurrentUser(t):void 0}delete(){this.persistence._removeListener(this.fullUserKey,this.boundEventHandler)}static async create(e,t,n="authUser"){if(!t.length)return new ae(re(se),e,n);const r=(await Promise.all(t.map((async e=>{if(await e._isAvailable())return e})))).filter((e=>e));let i=r[0]||re(se);const s=oe(n,e.config.apiKey,e.name);let o=null;for(const n of t)try{const t=await n._get(s);if(t){const r=te._fromJSON(e,t);n!==i&&(o=r),i=n;break}}catch(e){}const a=r.filter((e=>e._shouldAllowMigration));return i._shouldAllowMigration&&a.length?(i=a[0],o&&await i._set(s,o.toJSON()),await Promise.all(t.map((async e=>{if(e!==i)try{await e._remove(s)}catch(e){}}))),new ae(i,e,n)):new ae(i,e,n)}}function ce(e){const t=e.toLowerCase();if(t.includes("opera/")||t.includes("opr/")||t.includes("opios/"))return"Opera";if(de(t))return"IEMobile";if(t.includes("msie")||t.includes("trident/"))return"IE";if(t.includes("edge/"))return"Edge";if(ue(t))return"Firefox";if(t.includes("silk/"))return"Silk";if(pe(t))return"Blackberry";if(me(t))return"Webos";if(le(t))return"Safari";if((t.includes("chrome/")||he(t))&&!t.includes("edge/"))return"Chrome";if(fe(t))return"Android";{const t=/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/,n=e.match(t);if(2===(null==n?void 0:n.length))return n[1]}return"Other"}function ue(e=i.getUA()){return/firefox\//i.test(e)}function le(e=i.getUA()){const t=e.toLowerCase();return t.includes("safari/")&&!t.includes("chrome/")&&!t.includes("crios/")&&!t.includes("android")}function he(e=i.getUA()){return/crios\//i.test(e)}function de(e=i.getUA()){return/iemobile/i.test(e)}function fe(e=i.getUA()){return/android/i.test(e)}function pe(e=i.getUA()){return/blackberry/i.test(e)}function me(e=i.getUA()){return/webos/i.test(e)}function ge(e=i.getUA()){return/iphone|ipad|ipod/i.test(e)||/macintosh/i.test(e)&&/mobile/i.test(e)}function ye(e=i.getUA()){return ge(e)||fe(e)||me(e)||pe(e)||/windows phone/i.test(e)||de(e)}function ve(e,t=[]){let n;switch(e){case"Browser":n=ce(i.getUA());break;case"Worker":n=`${ce(i.getUA())}-${e}`;break;default:n=e}const s=t.length?t.join(","):"FirebaseCore-web";return`${n}/JsCore/${r.SDK_VERSION}/${s}`}class be{constructor(e){this.auth=e,this.queue=[]}pushCallback(e,t){const n=t=>new Promise(((n,r)=>{try{n(e(t))}catch(e){r(e)}}));n.onAbort=t,this.queue.push(n);const r=this.queue.length-1;return()=>{this.queue[r]=()=>Promise.resolve()}}async runMiddleware(e){if(this.auth.currentUser===e)return;const t=[];try{for(const n of this.queue)await n(e),n.onAbort&&t.push(n.onAbort)}catch(e){t.reverse();for(const e of t)try{e()}catch(e){}throw this.auth._errorFactory.create("login-blocked",{originalMessage:null==e?void 0:e.message})}}}class we{constructor(e){var t,n,r,i;const s=e.customStrengthOptions;this.customStrengthOptions={},this.customStrengthOptions.minPasswordLength=null!==(t=s.minPasswordLength)&&void 0!==t?t:6,s.maxPasswordLength&&(this.customStrengthOptions.maxPasswordLength=s.maxPasswordLength),void 0!==s.containsLowercaseCharacter&&(this.customStrengthOptions.containsLowercaseLetter=s.containsLowercaseCharacter),void 0!==s.containsUppercaseCharacter&&(this.customStrengthOptions.containsUppercaseLetter=s.containsUppercaseCharacter),void 0!==s.containsNumericCharacter&&(this.customStrengthOptions.containsNumericCharacter=s.containsNumericCharacter),void 0!==s.containsNonAlphanumericCharacter&&(this.customStrengthOptions.containsNonAlphanumericCharacter=s.containsNonAlphanumericCharacter),this.enforcementState=e.enforcementState,"ENFORCEMENT_STATE_UNSPECIFIED"===this.enforcementState&&(this.enforcementState="OFF"),this.allowedNonAlphanumericCharacters=null!==(r=null===(n=e.allowedNonAlphanumericCharacters)||void 0===n?void 0:n.join(""))&&void 0!==r?r:"",this.forceUpgradeOnSignin=null!==(i=e.forceUpgradeOnSignin)&&void 0!==i&&i,this.schemaVersion=e.schemaVersion}validatePassword(e){var t,n,r,i,s,o;const a={isValid:!0,passwordPolicy:this};return this.validatePasswordLengthOptions(e,a),this.validatePasswordCharacterOptions(e,a),a.isValid&&(a.isValid=null===(t=a.meetsMinPasswordLength)||void 0===t||t),a.isValid&&(a.isValid=null===(n=a.meetsMaxPasswordLength)||void 0===n||n),a.isValid&&(a.isValid=null===(r=a.containsLowercaseLetter)||void 0===r||r),a.isValid&&(a.isValid=null===(i=a.containsUppercaseLetter)||void 0===i||i),a.isValid&&(a.isValid=null===(s=a.containsNumericCharacter)||void 0===s||s),a.isValid&&(a.isValid=null===(o=a.containsNonAlphanumericCharacter)||void 0===o||o),a}validatePasswordLengthOptions(e,t){const n=this.customStrengthOptions.minPasswordLength,r=this.customStrengthOptions.maxPasswordLength;n&&(t.meetsMinPasswordLength=e.length>=n),r&&(t.meetsMaxPasswordLength=e.length<=r)}validatePasswordCharacterOptions(e,t){let n;this.updatePasswordCharacterOptionsStatuses(t,!1,!1,!1,!1);for(let r=0;r<e.length;r++)n=e.charAt(r),this.updatePasswordCharacterOptionsStatuses(t,n>="a"&&n<="z",n>="A"&&n<="Z",n>="0"&&n<="9",this.allowedNonAlphanumericCharacters.includes(n))}updatePasswordCharacterOptionsStatuses(e,t,n,r,i){this.customStrengthOptions.containsLowercaseLetter&&(e.containsLowercaseLetter||(e.containsLowercaseLetter=t)),this.customStrengthOptions.containsUppercaseLetter&&(e.containsUppercaseLetter||(e.containsUppercaseLetter=n)),this.customStrengthOptions.containsNumericCharacter&&(e.containsNumericCharacter||(e.containsNumericCharacter=r)),this.customStrengthOptions.containsNonAlphanumericCharacter&&(e.containsNonAlphanumericCharacter||(e.containsNonAlphanumericCharacter=i))}}class _e{constructor(e,t,n,r){this.app=e,this.heartbeatServiceProvider=t,this.appCheckServiceProvider=n,this.config=r,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new Ee(this),this.idTokenSubscription=new Ee(this),this.beforeStateQueue=new be(this),this.redirectUser=null,this.isProactiveRefreshEnabled=!1,this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION=1,this._canInitEmulator=!0,this._isInitialized=!1,this._deleted=!1,this._initializationPromise=null,this._popupRedirectResolver=null,this._errorFactory=u,this._agentRecaptchaConfig=null,this._tenantRecaptchaConfigs={},this._projectPasswordPolicy=null,this._tenantPasswordPolicies={},this.lastNotifiedUid=void 0,this.languageCode=null,this.tenantId=null,this.settings={appVerificationDisabledForTesting:!1},this.frameworks=[],this.name=e.name,this.clientVersion=r.sdkClientVersion}_initializeWithPersistence(e,t){return t&&(this._popupRedirectResolver=re(t)),this._initializationPromise=this.queue((async()=>{var n,r;if(!this._deleted&&(this.persistenceManager=await ae.create(this,e),!this._deleted)){if(null===(n=this._popupRedirectResolver)||void 0===n?void 0:n._shouldInitProactively)try{await this._popupRedirectResolver._initialize(this)}catch(e){}await this.initializeCurrentUser(t),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 e=await this.assertedPersistence.getCurrentUser();return this.currentUser||e?this.currentUser&&e&&this.currentUser.uid===e.uid?(this._currentUser._assign(e),void await this.currentUser.getIdToken()):void await this._updateCurrentUser(e,!0):void 0}async initializeCurrentUserFromIdToken(e){try{const t=await B(this,{idToken:e}),n=await te._fromGetAccountInfoResponse(this,t,e);await this.directlySetCurrentUser(n)}catch(e){console.warn("FirebaseServerApp could not login user with provided authIdToken: ",e),await this.directlySetCurrentUser(null)}}async initializeCurrentUser(e){var t;if(r._isFirebaseServerApp(this.app)){const e=this.app.settings.authIdToken;return e?new Promise((t=>{setTimeout((()=>this.initializeCurrentUserFromIdToken(e).then(t,t)))})):this.directlySetCurrentUser(null)}const n=await this.assertedPersistence.getCurrentUser();let i=n,s=!1;if(e&&this.config.authDomain){await this.getOrInitRedirectPersistenceManager();const n=null===(t=this.redirectUser)||void 0===t?void 0:t._redirectEventId,r=null==i?void 0:i._redirectEventId,o=await this.tryRedirectSignIn(e);n&&n!==r||!(null==o?void 0:o.user)||(i=o.user,s=!0)}if(!i)return this.directlySetCurrentUser(null);if(!i._redirectEventId){if(s)try{await this.beforeStateQueue.runMiddleware(i)}catch(e){i=n,this._popupRedirectResolver._overrideRedirectResult(this,(()=>Promise.reject(e)))}return i?this.reloadAndSetCurrentUserOrClear(i):this.directlySetCurrentUser(null)}return v(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===i._redirectEventId?this.directlySetCurrentUser(i):this.reloadAndSetCurrentUserOrClear(i)}async tryRedirectSignIn(e){let t=null;try{t=await this._popupRedirectResolver._completeRedirectFn(this,e,!0)}catch(e){await this._setRedirectUser(null)}return t}async reloadAndSetCurrentUserOrClear(e){try{await J(e)}catch(e){if("auth/network-request-failed"!==(null==e?void 0:e.code))return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(e)}useDeviceLanguage(){this.languageCode=function(){if("undefined"==typeof navigator)return null;const e=navigator;return e.languages&&e.languages[0]||e.language||null}()}async _delete(){this._deleted=!0}async updateCurrentUser(e){if(r._isFirebaseServerApp(this.app))return Promise.reject(m(this));const t=e?i.getModularInstance(e):null;return t&&v(t.auth.config.apiKey===this.config.apiKey,this,"invalid-user-token"),this._updateCurrentUser(t&&t._clone(this))}async _updateCurrentUser(e,t=!1){if(!this._deleted)return e&&v(this.tenantId===e.tenantId,this,"tenant-id-mismatch"),t||await this.beforeStateQueue.runMiddleware(e),this.queue((async()=>{await this.directlySetCurrentUser(e),this.notifyAuthListeners()}))}async signOut(){return r._isFirebaseServerApp(this.app)?Promise.reject(m(this)):(await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0))}setPersistence(e){return r._isFirebaseServerApp(this.app)?Promise.reject(m(this)):this.queue((async()=>{await this.assertedPersistence.setPersistence(re(e))}))}_getRecaptchaConfig(){return null==this.tenantId?this._agentRecaptchaConfig:this._tenantRecaptchaConfigs[this.tenantId]}async validatePassword(e){this._getPasswordPolicyInternal()||await this._updatePasswordPolicy();const t=this._getPasswordPolicyInternal();return t.schemaVersion!==this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION?Promise.reject(this._errorFactory.create("unsupported-password-policy-schema-version",{})):t.validatePassword(e)}_getPasswordPolicyInternal(){return null===this.tenantId?this._projectPasswordPolicy:this._tenantPasswordPolicies[this.tenantId]}async _updatePasswordPolicy(){const e=await async function(e,t={}){return N(e,"GET","/v2/passwordPolicy",k(e,t))}(this),t=new we(e);null===this.tenantId?this._projectPasswordPolicy=t:this._tenantPasswordPolicies[this.tenantId]=t}_getPersistence(){return this.assertedPersistence.persistence.type}_updateErrorMap(e){this._errorFactory=new i.ErrorFactory("auth","Firebase",e())}onAuthStateChanged(e,t,n){return this.registerStateListener(this.authStateSubscription,e,t,n)}beforeAuthStateChanged(e,t){return this.beforeStateQueue.pushCallback(e,t)}onIdTokenChanged(e,t,n){return this.registerStateListener(this.idTokenSubscription,e,t,n)}authStateReady(){return new Promise(((e,t)=>{if(this.currentUser)e();else{const n=this.onAuthStateChanged((()=>{n(),e()}),t)}}))}async revokeAccessToken(e){if(this.currentUser){const t={providerId:"apple.com",tokenType:"ACCESS_TOKEN",token:e,idToken:await this.currentUser.getIdToken()};null!=this.tenantId&&(t.tenantId=this.tenantId),await async function(e,t){return N(e,"POST","/v2/accounts:revokeToken",k(e,t))}(this,t)}}toJSON(){var e;return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:null===(e=this._currentUser)||void 0===e?void 0:e.toJSON()}}async _setRedirectUser(e,t){const n=await this.getOrInitRedirectPersistenceManager(t);return null===e?n.removeCurrentUser():n.setCurrentUser(e)}async getOrInitRedirectPersistenceManager(e){if(!this.redirectPersistenceManager){const t=e&&re(e)||this._popupRedirectResolver;v(t,this,"argument-error"),this.redirectPersistenceManager=await ae.create(this,[re(t._redirectPersistence)],"redirectUser"),this.redirectUser=await this.redirectPersistenceManager.getCurrentUser()}return this.redirectPersistenceManager}async _redirectUserForId(e){var t,n;return this._isInitialized&&await this.queue((async()=>{})),(null===(t=this._currentUser)||void 0===t?void 0:t._redirectEventId)===e?this._currentUser:(null===(n=this.redirectUser)||void 0===n?void 0:n._redirectEventId)===e?this.redirectUser:null}async _persistUserIfCurrent(e){if(e===this.currentUser)return this.queue((async()=>this.directlySetCurrentUser(e)))}_notifyListenersIfCurrent(e){e===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 e,t;if(!this._isInitialized)return;this.idTokenSubscription.next(this.currentUser);const n=null!==(t=null===(e=this.currentUser)||void 0===e?void 0:e.uid)&&void 0!==t?t:null;this.lastNotifiedUid!==n&&(this.lastNotifiedUid=n,this.authStateSubscription.next(this.currentUser))}registerStateListener(e,t,n,r){if(this._deleted)return()=>{};const i="function"==typeof t?t:t.next.bind(t);let s=!1;const o=this._isInitialized?Promise.resolve():this._initializationPromise;if(v(o,this,"internal-error"),o.then((()=>{s||i(this.currentUser)})),"function"==typeof t){const i=e.addObserver(t,n,r);return()=>{s=!0,i()}}{const n=e.addObserver(t);return()=>{s=!0,n()}}}async directlySetCurrentUser(e){this.currentUser&&this.currentUser!==e&&this._currentUser._stopProactiveRefresh(),e&&this.isProactiveRefreshEnabled&&e._startProactiveRefresh(),this.currentUser=e,e?await this.assertedPersistence.setCurrentUser(e):await this.assertedPersistence.removeCurrentUser()}queue(e){return this.operations=this.operations.then(e,e),this.operations}get assertedPersistence(){return v(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(e){e&&!this.frameworks.includes(e)&&(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=ve(this.config.clientPlatform,this._getFrameworks()))}_getFrameworks(){return this.frameworks}async _getAdditionalHeaders(){var e;const t={"X-Client-Version":this.clientVersion};this.app.options.appId&&(t["X-Firebase-gmpid"]=this.app.options.appId);const n=await(null===(e=this.heartbeatServiceProvider.getImmediate({optional:!0}))||void 0===e?void 0:e.getHeartbeatsHeader());n&&(t["X-Firebase-Client"]=n);const r=await this._getAppCheckToken();return r&&(t["X-Firebase-AppCheck"]=r),t}async _getAppCheckToken(){var e;const t=await(null===(e=this.appCheckServiceProvider.getImmediate({optional:!0}))||void 0===e?void 0:e.getToken());return(null==t?void 0:t.error)&&function(e,...t){l.logLevel<=s.LogLevel.WARN&&l.warn(`Auth (${r.SDK_VERSION}): ${e}`,...t)}(`Error while retrieving App Check token: ${t.error}`),null==t?void 0:t.token}}function Ie(e){return i.getModularInstance(e)}class Ee{constructor(e){this.auth=e,this.observer=null,this.addObserver=i.createSubscribe((e=>this.observer=e))}get next(){return v(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}let Te={async loadJS(){throw new Error("Unable to load external scripts")},recaptchaV2Script:"",recaptchaEnterpriseScript:"",gapiScript:""};function Se(e){return Te.loadJS(e)}function Ce(e){return`__${e}${Math.floor(1e6*Math.random())}`}class Ae{constructor(e){this.type="recaptcha-enterprise",this.auth=Ie(e)}async verify(e="verify",t=!1){function n(t,n,r){const i=window.grecaptcha;V(i)?i.enterprise.ready((()=>{i.enterprise.execute(t,{action:e}).then((e=>{n(e)})).catch((()=>{n("NO_RECAPTCHA")}))})):r(Error("No reCAPTCHA enterprise script loaded."))}return new Promise(((e,r)=>{(async function(e){if(!t){if(null==e.tenantId&&null!=e._agentRecaptchaConfig)return e._agentRecaptchaConfig.siteKey;if(null!=e.tenantId&&void 0!==e._tenantRecaptchaConfigs[e.tenantId])return e._tenantRecaptchaConfigs[e.tenantId].siteKey}return new Promise((async(t,n)=>{j(e,{clientType:"CLIENT_TYPE_WEB",version:"RECAPTCHA_ENTERPRISE"}).then((r=>{if(void 0!==r.recaptchaKey){const n=new U(r);return null==e.tenantId?e._agentRecaptchaConfig=n:e._tenantRecaptchaConfigs[e.tenantId]=n,t(n.siteKey)}n(new Error("recaptcha Enterprise site key undefined"))})).catch((e=>{n(e)}))}))})(this.auth).then((i=>{if(!t&&V(window.grecaptcha))n(i,e,r);else{if("undefined"==typeof window)return void r(new Error("RecaptchaVerifier is only supported in browser"));let t=Te.recaptchaEnterpriseScript;0!==t.length&&(t+=i),Se(t).then((()=>{n(i,e,r)})).catch((e=>{r(e)}))}})).catch((e=>{r(e)}))}))}}async function xe(e,t,n,r=!1){const i=new Ae(e);let s;try{s=await i.verify(n)}catch(e){s=await i.verify(n,!0)}const o=Object.assign({},t);return r?Object.assign(o,{captchaResp:s}):Object.assign(o,{captchaResponse:s}),Object.assign(o,{clientType:"CLIENT_TYPE_WEB"}),Object.assign(o,{recaptchaVersion:"RECAPTCHA_ENTERPRISE"}),o}async function ke(e,t,n,r){var i;if(null===(i=e._getRecaptchaConfig())||void 0===i?void 0:i.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")){const i=await xe(e,t,n,"getOobCode"===n);return r(e,i)}return r(e,t).catch((async i=>{if("auth/missing-recaptcha-token"===i.code){console.log(`${n} is protected by reCAPTCHA Enterprise for this project. Automatically triggering the reCAPTCHA flow and restarting the flow.`);const i=await xe(e,t,n,"getOobCode"===n);return r(e,i)}return Promise.reject(i)}))}function Ne(e,t){const n=r._getProvider(e,"auth");if(n.isInitialized()){const e=n.getImmediate(),r=n.getOptions();if(i.deepEqual(r,null!=t?t:{}))return e;d(e,"already-initialized")}return n.initialize({options:t})}function Oe(e,t,n){const r=Ie(e);v(r._canInitEmulator,r,"emulator-config-failed"),v(/^https?:\/\//.test(t),r,"invalid-emulator-scheme");const i=!!(null==n?void 0:n.disableWarnings),s=De(t),{host:o,port:a}=function(e){const t=De(e),n=/(\/\/)?([^?#/]+)/.exec(e.substr(t.length));if(!n)return{host:"",port:null};const r=n[2].split("@").pop()||"",i=/^(\[[^\]]+\])(:|$)/.exec(r);if(i){const e=i[1];return{host:e,port:Re(r.substr(e.length+1))}}{const[e,t]=r.split(":");return{host:e,port:Re(t)}}}(t),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 e(){const e=document.createElement("p"),t=e.style;e.innerText="Running in emulator mode. Do not use with production credentials.",t.position="fixed",t.width="100%",t.backgroundColor="#ffffff",t.border=".1em solid #000000",t.color="#b50000",t.bottom="0px",t.left="0px",t.margin="0px",t.zIndex="10000",t.textAlign="center",e.classList.add("firebase-emulator-warning"),document.body.appendChild(e)}"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",e):e())}()}function De(e){const t=e.indexOf(":");return t<0?"":e.substr(0,t+1)}function Re(e){if(!e)return null;const t=Number(e);return isNaN(t)?null:t}class Pe{constructor(e,t){this.providerId=e,this.signInMethod=t}toJSON(){return b("not implemented")}_getIdTokenResponse(e){return b("not implemented")}_linkToIdToken(e,t){return b("not implemented")}_getReauthenticationResolver(e){return b("not implemented")}}async function Le(e,t){return N(e,"POST","/v1/accounts:resetPassword",k(e,t))}async function Me(e,t){return N(e,"POST","/v1/accounts:signUp",t)}async function Fe(e,t){return D(e,"POST","/v1/accounts:signInWithPassword",k(e,t))}async function Ve(e,t){return N(e,"POST","/v1/accounts:sendOobCode",k(e,t))}async function Ue(e,t){return Ve(e,t)}async function je(e,t){return Ve(e,t)}class Be extends Pe{constructor(e,t,n,r=null){super("password",n),this._email=e,this._password=t,this._tenantId=r}static _fromEmailAndPassword(e,t){return new Be(e,t,"password")}static _fromEmailAndCode(e,t,n=null){return new Be(e,t,"emailLink",n)}toJSON(){return{email:this._email,password:this._password,signInMethod:this.signInMethod,tenantId:this._tenantId}}static fromJSON(e){const t="string"==typeof e?JSON.parse(e):e;if((null==t?void 0:t.email)&&(null==t?void 0:t.password)){if("password"===t.signInMethod)return this._fromEmailAndPassword(t.email,t.password);if("emailLink"===t.signInMethod)return this._fromEmailAndCode(t.email,t.password,t.tenantId)}return null}async _getIdTokenResponse(e){switch(this.signInMethod){case"password":return ke(e,{returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"},"signInWithPassword",Fe);case"emailLink":return async function(e,t){return D(e,"POST","/v1/accounts:signInWithEmailLink",k(e,t))}(e,{email:this._email,oobCode:this._password});default:d(e,"internal-error")}}async _linkToIdToken(e,t){switch(this.signInMethod){case"password":return ke(e,{idToken:t,returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"},"signUpPassword",Me);case"emailLink":return async function(e,t){return D(e,"POST","/v1/accounts:signInWithEmailLink",k(e,t))}(e,{idToken:t,email:this._email,oobCode:this._password});default:d(e,"internal-error")}}_getReauthenticationResolver(e){return this._getIdTokenResponse(e)}}async function qe(e,t){return D(e,"POST","/v1/accounts:signInWithIdp",k(e,t))}class ze extends Pe{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(e){const t=new ze(e.providerId,e.signInMethod);return e.idToken||e.accessToken?(e.idToken&&(t.idToken=e.idToken),e.accessToken&&(t.accessToken=e.accessToken),e.nonce&&!e.pendingToken&&(t.nonce=e.nonce),e.pendingToken&&(t.pendingToken=e.pendingToken)):e.oauthToken&&e.oauthTokenSecret?(t.accessToken=e.oauthToken,t.secret=e.oauthTokenSecret):d("argument-error"),t}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(e){const t="string"==typeof e?JSON.parse(e):e,{providerId:n,signInMethod:r}=t,i=o.__rest(t,["providerId","signInMethod"]);if(!n||!r)return null;const s=new ze(n,r);return s.idToken=i.idToken||void 0,s.accessToken=i.accessToken||void 0,s.secret=i.secret,s.nonce=i.nonce,s.pendingToken=i.pendingToken||null,s}_getIdTokenResponse(e){return qe(e,this.buildRequest())}_linkToIdToken(e,t){const n=this.buildRequest();return n.idToken=t,qe(e,n)}_getReauthenticationResolver(e){const t=this.buildRequest();return t.autoCreate=!1,qe(e,t)}buildRequest(){const e={requestUri:"http://localhost",returnSecureToken:!0};if(this.pendingToken)e.pendingToken=this.pendingToken;else{const t={};this.idToken&&(t.id_token=this.idToken),this.accessToken&&(t.access_token=this.accessToken),this.secret&&(t.oauth_token_secret=this.secret),t.providerId=this.providerId,this.nonce&&!this.pendingToken&&(t.nonce=this.nonce),e.postBody=i.querystring(t)}return e}}const Ge={USER_NOT_FOUND:"user-not-found"};class Ke extends Pe{constructor(e){super("phone","phone"),this.params=e}static _fromVerification(e,t){return new Ke({verificationId:e,verificationCode:t})}static _fromTokenResponse(e,t){return new Ke({phoneNumber:e,temporaryProof:t})}_getIdTokenResponse(e){return async function(e,t){return D(e,"POST","/v1/accounts:signInWithPhoneNumber",k(e,t))}(e,this._makeVerificationRequest())}_linkToIdToken(e,t){return async function(e,t){const n=await D(e,"POST","/v1/accounts:signInWithPhoneNumber",k(e,t));if(n.temporaryProof)throw M(e,"account-exists-with-different-credential",n);return n}(e,Object.assign({idToken:t},this._makeVerificationRequest()))}_getReauthenticationResolver(e){return async function(e,t){return D(e,"POST","/v1/accounts:signInWithPhoneNumber",k(e,Object.assign(Object.assign({},t),{operation:"REAUTH"})),Ge)}(e,this._makeVerificationRequest())}_makeVerificationRequest(){const{temporaryProof:e,phoneNumber:t,verificationId:n,verificationCode:r}=this.params;return e&&t?{temporaryProof:e,phoneNumber:t}:{sessionInfo:n,code:r}}toJSON(){const e={providerId:this.providerId};return this.params.phoneNumber&&(e.phoneNumber=this.params.phoneNumber),this.params.temporaryProof&&(e.temporaryProof=this.params.temporaryProof),this.params.verificationCode&&(e.verificationCode=this.params.verificationCode),this.params.verificationId&&(e.verificationId=this.params.verificationId),e}static fromJSON(e){"string"==typeof e&&(e=JSON.parse(e));const{verificationId:t,verificationCode:n,phoneNumber:r,temporaryProof:i}=e;return n||t||r||i?new Ke({verificationId:t,verificationCode:n,phoneNumber:r,temporaryProof:i}):null}}class We{constructor(e){var t,n,r,s,o,a;const c=i.querystringDecode(i.extractQuerystring(e)),u=null!==(t=c.apiKey)&&void 0!==t?t:null,l=null!==(n=c.oobCode)&&void 0!==n?n:null,h=function(e){switch(e){case"recoverEmail":return"RECOVER_EMAIL";case"resetPassword":return"PASSWORD_RESET";case"signIn":return"EMAIL_SIGNIN";case"verifyEmail":return"VERIFY_EMAIL";case"verifyAndChangeEmail":return"VERIFY_AND_CHANGE_EMAIL";case"revertSecondFactorAddition":return"REVERT_SECOND_FACTOR_ADDITION";default:return null}}(null!==(r=c.mode)&&void 0!==r?r:null);v(u&&l&&h,"argument-error"),this.apiKey=u,this.operation=h,this.code=l,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(e){const t=function(e){const t=i.querystringDecode(i.extractQuerystring(e)).link,n=t?i.querystringDecode(i.extractQuerystring(t)).deep_link_id:null,r=i.querystringDecode(i.extractQuerystring(e)).deep_link_id;return(r?i.querystringDecode(i.extractQuerystring(r)).link:null)||r||n||t||e}(e);try{return new We(t)}catch(e){return null}}}class $e{constructor(){this.providerId=$e.PROVIDER_ID}static credential(e,t){return Be._fromEmailAndPassword(e,t)}static credentialWithLink(e,t){const n=We.parseLink(t);return v(n,"argument-error"),Be._fromEmailAndCode(e,n.code,n.tenantId)}}$e.PROVIDER_ID="password",$e.EMAIL_PASSWORD_SIGN_IN_METHOD="password",$e.EMAIL_LINK_SIGN_IN_METHOD="emailLink";class He{constructor(e){this.providerId=e,this.defaultLanguageCode=null,this.customParameters={}}setDefaultLanguage(e){this.defaultLanguageCode=e}setCustomParameters(e){return this.customParameters=e,this}getCustomParameters(){return this.customParameters}}class Qe extends He{constructor(){super(...arguments),this.scopes=[]}addScope(e){return this.scopes.includes(e)||this.scopes.push(e),this}getScopes(){return[...this.scopes]}}class Je extends Qe{static credentialFromJSON(e){const t="string"==typeof e?JSON.parse(e):e;return v("providerId"in t&&"signInMethod"in t,"argument-error"),ze._fromParams(t)}credential(e){return this._credential(Object.assign(Object.assign({},e),{nonce:e.rawNonce}))}_credential(e){return v(e.idToken||e.accessToken,"argument-error"),ze._fromParams(Object.assign(Object.assign({},e),{providerId:this.providerId,signInMethod:this.providerId}))}static credentialFromResult(e){return Je.oauthCredentialFromTaggedObject(e)}static credentialFromError(e){return Je.oauthCredentialFromTaggedObject(e.customData||{})}static oauthCredentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthIdToken:t,oauthAccessToken:n,oauthTokenSecret:r,pendingToken:i,nonce:s,providerId:o}=e;if(!(n||r||t||i))return null;if(!o)return null;try{return new Je(o)._credential({idToken:t,accessToken:n,nonce:s,pendingToken:i})}catch(e){return null}}}class Ye extends Qe{constructor(){super("facebook.com")}static credential(e){return ze._fromParams({providerId:Ye.PROVIDER_ID,signInMethod:Ye.FACEBOOK_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return Ye.credentialFromTaggedObject(e)}static credentialFromError(e){return Ye.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e))return null;if(!e.oauthAccessToken)return null;try{return Ye.credential(e.oauthAccessToken)}catch(e){return null}}}Ye.FACEBOOK_SIGN_IN_METHOD="facebook.com",Ye.PROVIDER_ID="facebook.com";class Xe extends Qe{constructor(){super("google.com"),this.addScope("profile")}static credential(e,t){return ze._fromParams({providerId:Xe.PROVIDER_ID,signInMethod:Xe.GOOGLE_SIGN_IN_METHOD,idToken:e,accessToken:t})}static credentialFromResult(e){return Xe.credentialFromTaggedObject(e)}static credentialFromError(e){return Xe.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthIdToken:t,oauthAccessToken:n}=e;if(!t&&!n)return null;try{return Xe.credential(t,n)}catch(e){return null}}}Xe.GOOGLE_SIGN_IN_METHOD="google.com",Xe.PROVIDER_ID="google.com";class Ze extends Qe{constructor(){super("github.com")}static credential(e){return ze._fromParams({providerId:Ze.PROVIDER_ID,signInMethod:Ze.GITHUB_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return Ze.credentialFromTaggedObject(e)}static credentialFromError(e){return Ze.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e))return null;if(!e.oauthAccessToken)return null;try{return Ze.credential(e.oauthAccessToken)}catch(e){return null}}}Ze.GITHUB_SIGN_IN_METHOD="github.com",Ze.PROVIDER_ID="github.com";class et extends Pe{constructor(e,t){super(e,e),this.pendingToken=t}_getIdTokenResponse(e){return qe(e,this.buildRequest())}_linkToIdToken(e,t){const n=this.buildRequest();return n.idToken=t,qe(e,n)}_getReauthenticationResolver(e){const t=this.buildRequest();return t.autoCreate=!1,qe(e,t)}toJSON(){return{signInMethod:this.signInMethod,providerId:this.providerId,pendingToken:this.pendingToken}}static fromJSON(e){const t="string"==typeof e?JSON.parse(e):e,{providerId:n,signInMethod:r,pendingToken:i}=t;return n&&r&&i&&n===r?new et(n,i):null}static _create(e,t){return new et(e,t)}buildRequest(){return{requestUri:"http://localhost",returnSecureToken:!0,pendingToken:this.pendingToken}}}class tt extends He{constructor(e){v(e.startsWith("saml."),"argument-error"),super(e)}static credentialFromResult(e){return tt.samlCredentialFromTaggedObject(e)}static credentialFromError(e){return tt.samlCredentialFromTaggedObject(e.customData||{})}static credentialFromJSON(e){const t=et.fromJSON(e);return v(t,"argument-error"),t}static samlCredentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{pendingToken:t,providerId:n}=e;if(!t||!n)return null;try{return et._create(n,t)}catch(e){return null}}}class nt extends Qe{constructor(){super("twitter.com")}static credential(e,t){return ze._fromParams({providerId:nt.PROVIDER_ID,signInMethod:nt.TWITTER_SIGN_IN_METHOD,oauthToken:e,oauthTokenSecret:t})}static credentialFromResult(e){return nt.credentialFromTaggedObject(e)}static credentialFromError(e){return nt.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthAccessToken:t,oauthTokenSecret:n}=e;if(!t||!n)return null;try{return nt.credential(t,n)}catch(e){return null}}}async function rt(e,t){return D(e,"POST","/v1/accounts:signUp",k(e,t))}nt.TWITTER_SIGN_IN_METHOD="twitter.com",nt.PROVIDER_ID="twitter.com";class it{constructor(e){this.user=e.user,this.providerId=e.providerId,this._tokenResponse=e._tokenResponse,this.operationType=e.operationType}static async _fromIdTokenResponse(e,t,n,r=!1){const i=await te._fromIdTokenResponse(e,n,r),s=st(n);return new it({user:i,providerId:s,_tokenResponse:n,operationType:t})}static async _forOperation(e,t,n){await e._updateTokensIfNecessary(n,!0);const r=st(n);return new it({user:e,providerId:r,_tokenResponse:n,operationType:t})}}function st(e){return e.providerId?e.providerId:"phoneNumber"in e?"phone":null}class ot extends i.FirebaseError{constructor(e,t,n,r){var i;super(t.code,t.message),this.operationType=n,this.user=r,Object.setPrototypeOf(this,ot.prototype),this.customData={appName:e.name,tenantId:null!==(i=e.tenantId)&&void 0!==i?i:void 0,_serverResponse:t.customData._serverResponse,operationType:n}}static _fromErrorAndOperation(e,t,n,r){return new ot(e,t,n,r)}}function at(e,t,n,r){return("reauthenticate"===t?n._getReauthenticationResolver(e):n._getIdTokenResponse(e)).catch((n=>{if("auth/multi-factor-auth-required"===n.code)throw ot._fromErrorAndOperation(e,n,t,r);throw n}))}function ct(e){return new Set(e.map((({providerId:e})=>e)).filter((e=>!!e)))}async function ut(e,t,n=!1){const r=await $(e,t._linkToIdToken(e.auth,await e.getIdToken()),n);return it._forOperation(e,"link",r)}async function lt(e,t,n){await J(t);const r=!1===e?"provider-already-linked":"no-such-provider";v(ct(t.providerData).has(n)===e,t.auth,r)}async function ht(e,t,n=!1){const{auth:i}=e;if(r._isFirebaseServerApp(i.app))return Promise.reject(m(i));const s="reauthenticate";try{const r=await $(e,at(i,s,t,e),n);v(r.idToken,i,"internal-error");const o=K(r.idToken);v(o,i,"internal-error");const{sub:a}=o;return v(e.uid===a,i,"user-mismatch"),it._forOperation(e,s,r)}catch(e){throw"auth/user-not-found"===(null==e?void 0:e.code)&&d(i,"user-mismatch"),e}}async function dt(e,t,n=!1){if(r._isFirebaseServerApp(e.app))return Promise.reject(m(e));const i="signIn",s=await at(e,i,t),o=await it._fromIdTokenResponse(e,i,s);return n||await e._updateCurrentUser(o.user),o}async function ft(e,t){return dt(Ie(e),t)}async function pt(e,t){const n=i.getModularInstance(e);return await lt(!1,n,t.providerId),ut(n,t)}async function mt(e,t){return ht(i.getModularInstance(e),t)}class gt{constructor(e,t){this.factorId=e,this.uid=t.mfaEnrollmentId,this.enrollmentTime=new Date(t.enrolledAt).toUTCString(),this.displayName=t.displayName}static _fromServerResponse(e,t){return"phoneInfo"in t?yt._fromServerResponse(e,t):"totpInfo"in t?vt._fromServerResponse(e,t):d(e,"internal-error")}}class yt extends gt{constructor(e){super("phone",e),this.phoneNumber=e.phoneInfo}static _fromServerResponse(e,t){return new yt(t)}}class vt extends gt{constructor(e){super("totp",e)}static _fromServerResponse(e,t){return new vt(t)}}function bt(e,t,n){var r;v((null===(r=n.url)||void 0===r?void 0:r.length)>0,e,"invalid-continue-uri"),v(void 0===n.dynamicLinkDomain||n.dynamicLinkDomain.length>0,e,"invalid-dynamic-link-domain"),t.continueUrl=n.url,t.dynamicLinkDomain=n.dynamicLinkDomain,t.canHandleCodeInApp=n.handleCodeInApp,n.iOS&&(v(n.iOS.bundleId.length>0,e,"missing-ios-bundle-id"),t.iOSBundleId=n.iOS.bundleId),n.android&&(v(n.android.packageName.length>0,e,"missing-android-pkg-name"),t.androidInstallApp=n.android.installApp,t.androidMinimumVersionCode=n.android.minimumVersion,t.androidPackageName=n.android.packageName)}async function wt(e){const t=Ie(e);t._getPasswordPolicyInternal()&&await t._updatePasswordPolicy()}async function _t(e,t){const n=i.getModularInstance(e),r=await Le(n,{oobCode:t}),s=r.requestType;switch(v(s,n,"internal-error"),s){case"EMAIL_SIGNIN":break;case"VERIFY_AND_CHANGE_EMAIL":v(r.newEmail,n,"internal-error");break;case"REVERT_SECOND_FACTOR_ADDITION":v(r.mfaInfo,n,"internal-error");default:v(r.email,n,"internal-error")}let o=null;return r.mfaInfo&&(o=gt._fromServerResponse(Ie(n),r.mfaInfo)),{data:{email:("VERIFY_AND_CHANGE_EMAIL"===r.requestType?r.newEmail:r.email)||null,previousEmail:("VERIFY_AND_CHANGE_EMAIL"===r.requestType?r.email:r.newEmail)||null,multiFactorInfo:o},operation:s}}async function It(e,t,n){const{auth:r}=e,i={idToken:await e.getIdToken(),returnSecureToken:!0};t&&(i.email=t),n&&(i.password=n);const s=await $(e,async function(e,t){return N(e,"POST","/v1/accounts:update",t)}(r,i));await e._updateTokensIfNecessary(s,!0)}class Et{constructor(e,t,n={}){this.isNewUser=e,this.providerId=t,this.profile=n}}class Tt extends Et{constructor(e,t,n,r){super(e,t,n),this.username=r}}class St extends Et{constructor(e,t){super(e,"facebook.com",t)}}class Ct extends Tt{constructor(e,t){super(e,"github.com",t,"string"==typeof(null==t?void 0:t.login)?null==t?void 0:t.login:null)}}class At extends Et{constructor(e,t){super(e,"google.com",t)}}class xt extends Tt{constructor(e,t,n){super(e,"twitter.com",t,n)}}function kt(e,t,n,r){return i.getModularInstance(e).onIdTokenChanged(t,n,r)}function Nt(e,t,n){return i.getModularInstance(e).beforeAuthStateChanged(t,n)}class Ot{constructor(e,t,n){this.type=e,this.credential=t,this.user=n}static _fromIdtoken(e,t){return new Ot("enroll",e,t)}static _fromMfaPendingCredential(e){return new Ot("signin",e)}toJSON(){const e="enroll"===this.type?"idToken":"pendingCredential";return{multiFactorSession:{[e]:this.credential}}}static fromJSON(e){var t,n;if(null==e?void 0:e.multiFactorSession){if(null===(t=e.multiFactorSession)||void 0===t?void 0:t.pendingCredential)return Ot._fromMfaPendingCredential(e.multiFactorSession.pendingCredential);if(null===(n=e.multiFactorSession)||void 0===n?void 0:n.idToken)return Ot._fromIdtoken(e.multiFactorSession.idToken)}return null}}class Dt{constructor(e,t,n){this.session=e,this.hints=t,this.signInResolver=n}static _fromError(e,t){const n=Ie(e),r=t.customData._serverResponse,i=(r.mfaInfo||[]).map((e=>gt._fromServerResponse(n,e)));v(r.mfaPendingCredential,n,"internal-error");const s=Ot._fromMfaPendingCredential(r.mfaPendingCredential);return new Dt(s,i,(async e=>{const i=await e._process(n,s);delete r.mfaInfo,delete r.mfaPendingCredential;const o=Object.assign(Object.assign({},r),{idToken:i.idToken,refreshToken:i.refreshToken});switch(t.operationType){case"signIn":const e=await it._fromIdTokenResponse(n,t.operationType,o);return await n._updateCurrentUser(e.user),e;case"reauthenticate":return v(t.user,n,"internal-error"),it._forOperation(t.user,t.operationType,o);default:d(n,"internal-error")}}))}async resolveSignIn(e){const t=e;return this.signInResolver(t)}}class Rt{constructor(e){this.user=e,this.enrolledFactors=[],e._onReload((t=>{t.mfaInfo&&(this.enrolledFactors=t.mfaInfo.map((t=>gt._fromServerResponse(e.auth,t))))}))}static _fromUser(e){return new Rt(e)}async getSession(){return Ot._fromIdtoken(await this.user.getIdToken(),this.user)}async enroll(e,t){const n=e,r=await this.getSession(),i=await $(this.user,n._process(this.user.auth,r,t));return await this.user._updateTokensIfNecessary(i),this.user.reload()}async unenroll(e){const t="string"==typeof e?e:e.uid,n=await this.user.getIdToken();try{const e=await $(this.user,(r=this.user.auth,i={idToken:n,mfaEnrollmentId:t},N(r,"POST","/v2/accounts/mfaEnrollment:withdraw",k(r,i))));this.enrolledFactors=this.enrolledFactors.filter((({uid:e})=>e!==t)),await this.user._updateTokensIfNecessary(e),await this.user.reload()}catch(e){throw e}var r,i}}const Pt=new WeakMap,Lt="__sak";class Mt{constructor(e,t){this.storageRetriever=e,this.type=t}_isAvailable(){try{return this.storage?(this.storage.setItem(Lt,"1"),this.storage.removeItem(Lt),Promise.resolve(!0)):Promise.resolve(!1)}catch(e){return Promise.resolve(!1)}}_set(e,t){return this.storage.setItem(e,JSON.stringify(t)),Promise.resolve()}_get(e){const t=this.storage.getItem(e);return Promise.resolve(t?JSON.parse(t):null)}_remove(e){return this.storage.removeItem(e),Promise.resolve()}get storage(){return this.storageRetriever()}}class Ft extends Mt{constructor(){super((()=>window.localStorage),"LOCAL"),this.boundEventHandler=(e,t)=>this.onStorageEvent(e,t),this.listeners={},this.localCache={},this.pollTimer=null,this.fallbackToPolling=ye(),this._shouldAllowMigration=!0}forAllChangedKeys(e){for(const t of Object.keys(this.listeners)){const n=this.storage.getItem(t),r=this.localCache[t];n!==r&&e(t,r,n)}}onStorageEvent(e,t=!1){if(!e.key)return void this.forAllChangedKeys(((e,t,n)=>{this.notifyListeners(e,n)}));const n=e.key;t?this.detachListener():this.stopPolling();const r=()=>{const e=this.storage.getItem(n);(t||this.localCache[n]!==e)&&this.notifyListeners(n,e)},s=this.storage.getItem(n);i.isIE()&&10===document.documentMode&&s!==e.newValue&&e.newValue!==e.oldValue?setTimeout(r,10):r()}notifyListeners(e,t){this.localCache[e]=t;const n=this.listeners[e];if(n)for(const e of Array.from(n))e(t?JSON.parse(t):t)}startPolling(){this.stopPolling(),this.pollTimer=setInterval((()=>{this.forAllChangedKeys(((e,t,n)=>{this.onStorageEvent(new StorageEvent("storage",{key:e,oldValue:t,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(e,t){0===Object.keys(this.listeners).length&&(this.fallbackToPolling?this.startPolling():this.attachListener()),this.listeners[e]||(this.listeners[e]=new Set,this.localCache[e]=this.storage.getItem(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),0===this.listeners[e].size&&delete this.listeners[e]),0===Object.keys(this.listeners).length&&(this.detachListener(),this.stopPolling())}async _set(e,t){await super._set(e,t),this.localCache[e]=JSON.stringify(t)}async _get(e){const t=await super._get(e);return this.localCache[e]=JSON.stringify(t),t}async _remove(e){await super._remove(e),delete this.localCache[e]}}Ft.type="LOCAL";const Vt=Ft;class Ut extends Mt{constructor(){super((()=>window.sessionStorage),"SESSION")}_addListener(e,t){}_removeListener(e,t){}}Ut.type="SESSION";const jt=Ut;class Bt{constructor(e){this.eventTarget=e,this.handlersMap={},this.boundEventHandler=this.handleEvent.bind(this)}static _getInstance(e){const t=this.receivers.find((t=>t.isListeningto(e)));if(t)return t;const n=new Bt(e);return this.receivers.push(n),n}isListeningto(e){return this.eventTarget===e}async handleEvent(e){const t=e,{eventId:n,eventType:r,data:i}=t.data,s=this.handlersMap[r];if(!(null==s?void 0:s.size))return;t.ports[0].postMessage({status:"ack",eventId:n,eventType:r});const o=Array.from(s).map((async e=>e(t.origin,i))),a=await function(e){return Promise.all(e.map((async e=>{try{return{fulfilled:!0,value:await e}}catch(e){return{fulfilled:!1,reason:e}}})))}(o);t.ports[0].postMessage({status:"done",eventId:n,eventType:r,response:a})}_subscribe(e,t){0===Object.keys(this.handlersMap).length&&this.eventTarget.addEventListener("message",this.boundEventHandler),this.handlersMap[e]||(this.handlersMap[e]=new Set),this.handlersMap[e].add(t)}_unsubscribe(e,t){this.handlersMap[e]&&t&&this.handlersMap[e].delete(t),t&&0!==this.handlersMap[e].size||delete this.handlersMap[e],0===Object.keys(this.handlersMap).length&&this.eventTarget.removeEventListener("message",this.boundEventHandler)}}function qt(e="",t=10){let n="";for(let e=0;e<t;e++)n+=Math.floor(10*Math.random());return e+n}Bt.receivers=[];class zt{constructor(e){this.target=e,this.handlers=new Set}removeMessageHandler(e){e.messageChannel&&(e.messageChannel.port1.removeEventListener("message",e.onMessage),e.messageChannel.port1.close()),this.handlers.delete(e)}async _send(e,t,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=qt("",20);r.port1.start();const u=setTimeout((()=>{a(new Error("unsupported_event"))}),n);s={messageChannel:r,onMessage(e){const t=e;if(t.data.eventId===c)switch(t.data.status){case"ack":clearTimeout(u),i=setTimeout((()=>{a(new Error("timeout"))}),3e3);break;case"done":clearTimeout(i),o(t.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:e,eventId:c,data:t},[r.port2])})).finally((()=>{s&&this.removeMessageHandler(s)}))}}function Gt(){return window}function Kt(){return void 0!==Gt().WorkerGlobalScope&&"function"==typeof Gt().importScripts}const Wt="firebaseLocalStorageDb",$t="firebaseLocalStorage",Ht="fbase_key";class Qt{constructor(e){this.request=e}toPromise(){return new Promise(((e,t)=>{this.request.addEventListener("success",(()=>{e(this.request.result)})),this.request.addEventListener("error",(()=>{t(this.request.error)}))}))}}function Jt(e,t){return e.transaction([$t],t?"readwrite":"readonly").objectStore($t)}function Yt(){const e=indexedDB.open(Wt,1);return new Promise(((t,n)=>{e.addEventListener("error",(()=>{n(e.error)})),e.addEventListener("upgradeneeded",(()=>{const t=e.result;try{t.createObjectStore($t,{keyPath:Ht})}catch(e){n(e)}})),e.addEventListener("success",(async()=>{const n=e.result;n.objectStoreNames.contains($t)?t(n):(n.close(),await function(){const e=indexedDB.deleteDatabase(Wt);return new Qt(e).toPromise()}(),t(await Yt()))}))}))}async function Xt(e,t,n){const r=Jt(e,!0).put({[Ht]:t,value:n});return new Qt(r).toPromise()}function Zt(e,t){const n=Jt(e,!0).delete(t);return new Qt(n).toPromise()}class en{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 Yt()),this.db}async _withRetries(e){let t=0;for(;;)try{const t=await this._openDb();return await e(t)}catch(e){if(t++>3)throw e;this.db&&(this.db.close(),this.db=void 0)}}async initializeServiceWorkerMessaging(){return Kt()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=Bt._getInstance(Kt()?self:null),this.receiver._subscribe("keyChanged",(async(e,t)=>({keyProcessed:(await this._poll()).includes(t.key)}))),this.receiver._subscribe("ping",(async(e,t)=>["keyChanged"]))}async initializeSender(){var e,t;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(e){return null}}(),!this.activeServiceWorker)return;this.sender=new zt(this.activeServiceWorker);const n=await this.sender._send("ping",{},800);n&&(null===(e=n[0])||void 0===e?void 0:e.fulfilled)&&(null===(t=n[0])||void 0===t?void 0:t.value.includes("keyChanged"))&&(this.serviceWorkerReceiverAvailable=!0)}async notifyServiceWorker(e){var t;if(this.sender&&this.activeServiceWorker&&((null===(t=null===navigator||void 0===navigator?void 0:navigator.serviceWorker)||void 0===t?void 0:t.controller)||null)===this.activeServiceWorker)try{await this.sender._send("keyChanged",{key:e},this.serviceWorkerReceiverAvailable?800:50)}catch(t){}}async _isAvailable(){try{if(!indexedDB)return!1;const e=await Yt();return await Xt(e,Lt,"1"),await Zt(e,Lt),!0}catch(e){}return!1}async _withPendingWrite(e){this.pendingWrites++;try{await e()}finally{this.pendingWrites--}}async _set(e,t){return this._withPendingWrite((async()=>(await this._withRetries((n=>Xt(n,e,t))),this.localCache[e]=t,this.notifyServiceWorker(e))))}async _get(e){const t=await this._withRetries((t=>async function(e,t){const n=Jt(e,!1).get(t),r=await new Qt(n).toPromise();return void 0===r?null:r.value}(t,e)));return this.localCache[e]=t,t}async _remove(e){return this._withPendingWrite((async()=>(await this._withRetries((t=>Zt(t,e))),delete this.localCache[e],this.notifyServiceWorker(e))))}async _poll(){const e=await this._withRetries((e=>{const t=Jt(e,!1).getAll();return new Qt(t).toPromise()}));if(!e)return[];if(0!==this.pendingWrites)return[];const t=[],n=new Set;if(0!==e.length)for(const{fbase_key:r,value:i}of e)n.add(r),JSON.stringify(this.localCache[r])!==JSON.stringify(i)&&(this.notifyListeners(r,i),t.push(r));for(const e of Object.keys(this.localCache))this.localCache[e]&&!n.has(e)&&(this.notifyListeners(e,null),t.push(e));return t}notifyListeners(e,t){this.localCache[e]=t;const n=this.listeners[e];if(n)for(const e of Array.from(n))e(t)}startPolling(){this.stopPolling(),this.pollTimer=setInterval((async()=>this._poll()),800)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}_addListener(e,t){0===Object.keys(this.listeners).length&&this.startPolling(),this.listeners[e]||(this.listeners[e]=new Set,this._get(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),0===this.listeners[e].size&&delete this.listeners[e]),0===Object.keys(this.listeners).length&&this.stopPolling()}}en.type="LOCAL";const tn=en,nn=1e12;class rn{constructor(e){this.auth=e,this.counter=nn,this._widgets=new Map}render(e,t){const n=this.counter;return this._widgets.set(n,new sn(e,this.auth.name,t||{})),this.counter++,n}reset(e){var t;const n=e||nn;null===(t=this._widgets.get(n))||void 0===t||t.delete(),this._widgets.delete(n)}getResponse(e){var t;const n=e||nn;return(null===(t=this._widgets.get(n))||void 0===t?void 0:t.getResponse())||""}async execute(e){var t;const n=e||nn;return null===(t=this._widgets.get(n))||void 0===t||t.execute(),""}}class sn{constructor(e,t,n){this.params=n,this.timerId=null,this.deleted=!1,this.responseToken=null,this.clickHandler=()=>{this.execute()};const r="string"==typeof e?document.getElementById(e):e;v(r,"argument-error",{appName:t}),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(){const e=[],t="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";for(let n=0;n<50;n++)e.push(t.charAt(Math.floor(62*Math.random())));return e.join("")}();const{callback:e,"expired-callback":t}=this.params;if(e)try{e(this.responseToken)}catch(e){}this.timerId=window.setTimeout((()=>{if(this.timerId=null,this.responseToken=null,t)try{t()}catch(e){}this.isVisible&&this.execute()}),6e4)}),500))}checkIfDeleted(){if(this.deleted)throw new Error("reCAPTCHA mock was already deleted!")}}const on=Ce("rcb"),an=new T(3e4,6e4);class cn{constructor(){var e;this.hostLanguage="",this.counter=0,this.librarySeparatelyLoaded=!!(null===(e=Gt().grecaptcha)||void 0===e?void 0:e.render)}load(e,t=""){return v(function(e){return e.length<=6&&/^\s*[a-zA-Z0-9\-]*\s*$/.test(e)}(t),e,"argument-error"),this.shouldResolveImmediately(t)&&F(Gt().grecaptcha)?Promise.resolve(Gt().grecaptcha):new Promise(((n,r)=>{const s=Gt().setTimeout((()=>{r(f(e,"network-request-failed"))}),an.get());Gt()[on]=()=>{Gt().clearTimeout(s),delete Gt()[on];const i=Gt().grecaptcha;if(!i||!F(i))return void r(f(e,"internal-error"));const o=i.render;i.render=(e,t)=>{const n=o(e,t);return this.counter++,n},this.hostLanguage=t,n(i)},Se(`${Te.recaptchaV2Script}?${i.querystring({onload:on,render:"explicit",hl:t})}`).catch((()=>{clearTimeout(s),r(f(e,"internal-error"))}))}))}clearedOneInstance(){this.counter--}shouldResolveImmediately(e){var t;return!!(null===(t=Gt().grecaptcha)||void 0===t?void 0:t.render)&&(e===this.hostLanguage||this.counter>0||this.librarySeparatelyLoaded)}}class un{async load(e){return new rn(e)}clearedOneInstance(){}}const ln="recaptcha",hn={theme:"light",type:"image"};class dn{constructor(e,t){this.verificationId=e,this.onConfirmation=t}confirm(e){const t=Ke._fromVerification(this.verificationId,e);return this.onConfirmation(t)}}async function fn(e,t,n){var r;const i=await n.verify();try{let s;if(v("string"==typeof i,e,"argument-error"),v(n.type===ln,e,"argument-error"),s="string"==typeof t?{phoneNumber:t}:t,"session"in s){const t=s.session;if("phoneNumber"in s){v("enroll"===t.type,e,"internal-error");const n=await function(e,t){return N(e,"POST","/v2/accounts/mfaEnrollment:start",k(e,t))}(e,{idToken:t.credential,phoneEnrollmentInfo:{phoneNumber:s.phoneNumber,recaptchaToken:i}});return n.phoneSessionInfo.sessionInfo}{v("signin"===t.type,e,"internal-error");const n=(null===(r=s.multiFactorHint)||void 0===r?void 0:r.uid)||s.multiFactorUid;v(n,e,"missing-multi-factor-info");const o=await function(e,t){return N(e,"POST","/v2/accounts/mfaSignIn:start",k(e,t))}(e,{mfaPendingCredential:t.credential,mfaEnrollmentId:n,phoneSignInInfo:{recaptchaToken:i}});return o.phoneResponseInfo.sessionInfo}}{const{sessionInfo:t}=await async function(e,t){return N(e,"POST","/v1/accounts:sendVerificationCode",k(e,t))}(e,{phoneNumber:s.phoneNumber,recaptchaToken:i});return t}}finally{n._reset()}}class pn{constructor(e){this.providerId=pn.PROVIDER_ID,this.auth=Ie(e)}verifyPhoneNumber(e,t){return fn(this.auth,e,i.getModularInstance(t))}static credential(e,t){return Ke._fromVerification(e,t)}static credentialFromResult(e){const t=e;return pn.credentialFromTaggedObject(t)}static credentialFromError(e){return pn.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{phoneNumber:t,temporaryProof:n}=e;return t&&n?Ke._fromTokenResponse(t,n):null}}function mn(e,t){return t?re(t):(v(e._popupRedirectResolver,e,"argument-error"),e._popupRedirectResolver)}pn.PROVIDER_ID="phone",pn.PHONE_SIGN_IN_METHOD="phone";class gn extends Pe{constructor(e){super("custom","custom"),this.params=e}_getIdTokenResponse(e){return qe(e,this._buildIdpRequest())}_linkToIdToken(e,t){return qe(e,this._buildIdpRequest(t))}_getReauthenticationResolver(e){return qe(e,this._buildIdpRequest())}_buildIdpRequest(e){const t={requestUri:this.params.requestUri,sessionId:this.params.sessionId,postBody:this.params.postBody,tenantId:this.params.tenantId,pendingToken:this.params.pendingToken,returnSecureToken:!0,returnIdpCredential:!0};return e&&(t.idToken=e),t}}function yn(e){return dt(e.auth,new gn(e),e.bypassAuthState)}function vn(e){const{auth:t,user:n}=e;return v(n,t,"internal-error"),ht(n,new gn(e),e.bypassAuthState)}async function bn(e){const{auth:t,user:n}=e;return v(n,t,"internal-error"),ut(n,new gn(e),e.bypassAuthState)}class wn{constructor(e,t,n,r,i=!1){this.auth=e,this.resolver=n,this.user=r,this.bypassAuthState=i,this.pendingPromise=null,this.eventManager=null,this.filter=Array.isArray(t)?t:[t]}execute(){return new Promise((async(e,t)=>{this.pendingPromise={resolve:e,reject:t};try{this.eventManager=await this.resolver._initialize(this.auth),await this.onExecution(),this.eventManager.registerConsumer(this)}catch(e){this.reject(e)}}))}async onAuthEvent(e){const{urlResponse:t,sessionId:n,postBody:r,tenantId:i,error:s,type:o}=e;if(s)return void this.reject(s);const a={auth:this.auth,requestUri:t,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(e){this.reject(e)}}onError(e){this.reject(e)}getIdpTask(e){switch(e){case"signInViaPopup":case"signInViaRedirect":return yn;case"linkViaPopup":case"linkViaRedirect":return bn;case"reauthViaPopup":case"reauthViaRedirect":return vn;default:d(this.auth,"internal-error")}}resolve(e){w(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){w(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.reject(e),this.unregisterAndCleanUp()}unregisterAndCleanUp(){this.eventManager&&this.eventManager.unregisterConsumer(this),this.pendingPromise=null,this.cleanUp()}}const _n=new T(2e3,1e4);class In extends wn{constructor(e,t,n,r,i){super(e,t,r,i),this.provider=n,this.authWindow=null,this.pollId=null,In.currentPopupAction&&In.currentPopupAction.cancel(),In.currentPopupAction=this}async executeNotNull(){const e=await this.execute();return v(e,this.auth,"internal-error"),e}async onExecution(){w(1===this.filter.length,"Popup operations only handle one event");const e=qt();this.authWindow=await this.resolver._openPopup(this.auth,this.provider,this.filter[0],e),this.authWindow.associatedEvent=e,this.resolver._originValidation(this.auth).catch((e=>{this.reject(e)})),this.resolver._isIframeWebStorageSupported(this.auth,(e=>{e||this.reject(f(this.auth,"web-storage-unsupported"))})),this.pollUserCancellation()}get eventId(){var e;return(null===(e=this.authWindow)||void 0===e?void 0:e.associatedEvent)||null}cancel(){this.reject(f(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,In.currentPopupAction=null}pollUserCancellation(){const e=()=>{var t,n;(null===(n=null===(t=this.authWindow)||void 0===t?void 0:t.window)||void 0===n?void 0:n.closed)?this.pollId=window.setTimeout((()=>{this.pollId=null,this.reject(f(this.auth,"popup-closed-by-user"))}),8e3):this.pollId=window.setTimeout(e,_n.get())};e()}}In.currentPopupAction=null;const En="pendingRedirect",Tn=new Map;class Sn extends wn{constructor(e,t,n=!1){super(e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],t,void 0,n),this.eventId=null}async execute(){let e=Tn.get(this.auth._key());if(!e){try{const t=await async function(e,t){const n=kn(t),r=xn(e);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;e=()=>Promise.resolve(t)}catch(t){e=()=>Promise.reject(t)}Tn.set(this.auth._key(),e)}return this.bypassAuthState||Tn.set(this.auth._key(),(()=>Promise.resolve(null))),e()}async onAuthEvent(e){if("signInViaRedirect"===e.type)return super.onAuthEvent(e);if("unknown"!==e.type){if(e.eventId){const t=await this.auth._redirectUserForId(e.eventId);if(t)return this.user=t,super.onAuthEvent(e);this.resolve(null)}}else this.resolve(null)}async onExecution(){}cleanUp(){}}async function Cn(e,t){return xn(e)._set(kn(t),"true")}function An(e,t){Tn.set(e._key(),t)}function xn(e){return re(e._redirectPersistence)}function kn(e){return oe(En,e.config.apiKey,e.name)}async function Nn(e,t,n=!1){if(r._isFirebaseServerApp(e.app))return Promise.reject(m(e));const i=Ie(e),s=mn(i,t),o=new Sn(i,s,n),a=await o.execute();return a&&!n&&(delete a.user._redirectEventId,await i._persistUserIfCurrent(a.user),await i._setRedirectUser(null,t)),a}async function On(e){const t=qt(`${e.uid}:::`);return e._redirectEventId=t,await e.auth._setRedirectUser(e),await e.auth._persistUserIfCurrent(e),t}class Dn{constructor(e){this.auth=e,this.cachedEventUids=new Set,this.consumers=new Set,this.queuedRedirectEvent=null,this.hasHandledPotentialRedirect=!1,this.lastProcessedEventTime=Date.now()}registerConsumer(e){this.consumers.add(e),this.queuedRedirectEvent&&this.isEventForConsumer(this.queuedRedirectEvent,e)&&(this.sendToConsumer(this.queuedRedirectEvent,e),this.saveEventToCache(this.queuedRedirectEvent),this.queuedRedirectEvent=null)}unregisterConsumer(e){this.consumers.delete(e)}onEvent(e){if(this.hasEventBeenHandled(e))return!1;let t=!1;return this.consumers.forEach((n=>{this.isEventForConsumer(e,n)&&(t=!0,this.sendToConsumer(e,n),this.saveEventToCache(e))})),this.hasHandledPotentialRedirect||!function(e){switch(e.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return!0;case"unknown":return Pn(e);default:return!1}}(e)||(this.hasHandledPotentialRedirect=!0,t||(this.queuedRedirectEvent=e,t=!0)),t}sendToConsumer(e,t){var n;if(e.error&&!Pn(e)){const r=(null===(n=e.error.code)||void 0===n?void 0:n.split("auth/")[1])||"internal-error";t.onError(f(this.auth,r))}else t.onAuthEvent(e)}isEventForConsumer(e,t){const n=null===t.eventId||!!e.eventId&&e.eventId===t.eventId;return t.filter.includes(e.type)&&n}hasEventBeenHandled(e){return Date.now()-this.lastProcessedEventTime>=6e5&&this.cachedEventUids.clear(),this.cachedEventUids.has(Rn(e))}saveEventToCache(e){this.cachedEventUids.add(Rn(e)),this.lastProcessedEventTime=Date.now()}}function Rn(e){return[e.type,e.eventId,e.sessionId,e.tenantId].filter((e=>e)).join("-")}function Pn({type:e,error:t}){return"unknown"===e&&"auth/no-auth-event"===(null==t?void 0:t.code)}async function Ln(e,t={}){return N(e,"GET","/v1/projects",t)}const Mn=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,Fn=/^https?/;function Vn(e){const t=_(),{protocol:n,hostname:r}=new URL(t);if(e.startsWith("chrome-extension://")){const i=new URL(e);return""===i.hostname&&""===r?"chrome-extension:"===n&&e.replace("chrome-extension://","")===t.replace("chrome-extension://",""):"chrome-extension:"===n&&i.hostname===r}if(!Fn.test(n))return!1;if(Mn.test(e))return r===e;const i=e.replace(/\./g,"\\.");return new RegExp("^(.+\\."+i+"|"+i+")$","i").test(r)}const Un=new T(3e4,6e4);function jn(){const e=Gt().___jsl;if(null==e?void 0:e.H)for(const t of Object.keys(e.H))if(e.H[t].r=e.H[t].r||[],e.H[t].L=e.H[t].L||[],e.H[t].r=[...e.H[t].L],e.CP)for(let t=0;t<e.CP.length;t++)e.CP[t]=null}function Bn(e){return new Promise(((t,n)=>{var r,i,s;function o(){jn(),gapi.load("gapi.iframes",{callback:()=>{t(gapi.iframes.getContext())},ontimeout:()=>{jn(),n(f(e,"network-request-failed"))},timeout:Un.get()})}if(null===(i=null===(r=Gt().gapi)||void 0===r?void 0:r.iframes)||void 0===i?void 0:i.Iframe)t(gapi.iframes.getContext());else{if(!(null===(s=Gt().gapi)||void 0===s?void 0:s.load)){const t=Ce("iframefcb");return Gt()[t]=()=>{gapi.load?o():n(f(e,"network-request-failed"))},Se(`${Te.gapiScript}?onload=${t}`).catch((e=>n(e)))}o()}})).catch((e=>{throw qn=null,e}))}let qn=null;const zn=new T(5e3,15e3),Gn="__/auth/iframe",Kn="emulator/auth/iframe",Wn={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},$n=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);function Hn(e){const t=e.config;v(t.authDomain,e,"auth-domain-config-required");const n=t.emulator?S(t,Kn):`https://${e.config.authDomain}/${Gn}`,s={apiKey:t.apiKey,appName:e.name,v:r.SDK_VERSION},o=$n.get(e.config.apiHost);o&&(s.eid=o);const a=e._getFrameworks();return a.length&&(s.fw=a.join(",")),`${n}?${i.querystring(s).slice(1)}`}const Qn={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"};class Jn{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch(e){}}}const Yn=encodeURIComponent("fac");async function Xn(e,t,n,s,o,a){v(e.config.authDomain,e,"auth-domain-config-required"),v(e.config.apiKey,e,"invalid-api-key");const c={apiKey:e.config.apiKey,appName:e.name,authType:n,redirectUrl:s,v:r.SDK_VERSION,eventId:o};if(t instanceof He){t.setDefaultLanguage(e.languageCode),c.providerId=t.providerId||"",i.isEmpty(t.getCustomParameters())||(c.customParameters=JSON.stringify(t.getCustomParameters()));for(const[e,t]of Object.entries(a||{}))c[e]=t}if(t instanceof Qe){const e=t.getScopes().filter((e=>""!==e));e.length>0&&(c.scopes=e.join(","))}e.tenantId&&(c.tid=e.tenantId);const u=c;for(const e of Object.keys(u))void 0===u[e]&&delete u[e];const l=await e._getAppCheckToken(),h=l?`#${Yn}=${encodeURIComponent(l)}`:"";return`${function({config:e}){return e.emulator?S(e,"emulator/auth/handler"):`https://${e.authDomain}/__/auth/handler`}(e)}?${i.querystring(u).slice(1)}${h}`}const Zn="webStorageSupport",er=class{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=jt,this._completeRedirectFn=Nn,this._overrideRedirectResult=An}async _openPopup(e,t,n,r){var s;return w(null===(s=this.eventManagers[e._key()])||void 0===s?void 0:s.manager,"_initialize() not called before _openPopup()"),function(e,t,n,r=500,s=600){const o=Math.max((window.screen.availHeight-s)/2,0).toString(),a=Math.max((window.screen.availWidth-r)/2,0).toString();let c="";const u=Object.assign(Object.assign({},Qn),{width:r.toString(),height:s.toString(),top:o,left:a}),l=i.getUA().toLowerCase();n&&(c=he(l)?"_blank":n),ue(l)&&(t=t||"http://localhost",u.scrollbars="yes");const h=Object.entries(u).reduce(((e,[t,n])=>`${e}${t}=${n},`),"");if(function(e=i.getUA()){var t;return ge(e)&&!!(null===(t=window.navigator)||void 0===t?void 0:t.standalone)}(l)&&"_self"!==c)return function(e,t){const n=document.createElement("a");n.href=e,n.target=t;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)}(t||"",c),new Jn(null);const d=window.open(t||"",c,h);v(d,e,"popup-blocked");try{d.focus()}catch(e){}return new Jn(d)}(e,await Xn(e,t,n,_(),r),qt())}async _openRedirect(e,t,n,r){return await this._originValidation(e),i=await Xn(e,t,n,_(),r),Gt().location.href=i,new Promise((()=>{}));var i}_initialize(e){const t=e._key();if(this.eventManagers[t]){const{manager:e,promise:n}=this.eventManagers[t];return e?Promise.resolve(e):(w(n,"If manager is not set, promise should be"),n)}const n=this.initAndGetManager(e);return this.eventManagers[t]={promise:n},n.catch((()=>{delete this.eventManagers[t]})),n}async initAndGetManager(e){const t=await async function(e){const t=await function(e){return qn=qn||Bn(e),qn}(e),n=Gt().gapi;return v(n,e,"internal-error"),t.open({where:document.body,url:Hn(e),messageHandlersFilter:n.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:Wn,dontclear:!0},(t=>new Promise((async(n,r)=>{await t.restyle({setHideOnLeave:!1});const i=f(e,"network-request-failed"),s=Gt().setTimeout((()=>{r(i)}),zn.get());function o(){Gt().clearTimeout(s),n(t)}t.ping(o).then(o,(()=>{r(i)}))}))))}(e),n=new Dn(e);return t.register("authEvent",(t=>(v(null==t?void 0:t.authEvent,e,"invalid-auth-event"),{status:n.onEvent(t.authEvent)?"ACK":"ERROR"})),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[e._key()]={manager:n},this.iframes[e._key()]=t,n}_isIframeWebStorageSupported(e,t){this.iframes[e._key()].send(Zn,{type:Zn},(n=>{var r;const i=null===(r=null==n?void 0:n[0])||void 0===r?void 0:r[Zn];void 0!==i&&t(!!i),d(e,"internal-error")}),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){const t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=async function(e){if(e.config.emulator)return;const{authorizedDomains:t}=await Ln(e);for(const e of t)try{if(Vn(e))return}catch(e){}d(e,"unauthorized-domain")}(e)),this.originValidationPromises[t]}get _shouldInitProactively(){return ye()||le()||ge()}};class tr{constructor(e){this.factorId=e}_process(e,t,n){switch(t.type){case"enroll":return this._finalizeEnroll(e,t.credential,n);case"signin":return this._finalizeSignIn(e,t.credential);default:return b("unexpected MultiFactorSessionType")}}}class nr extends tr{constructor(e){super("phone"),this.credential=e}static _fromCredential(e){return new nr(e)}_finalizeEnroll(e,t,n){return function(e,t){return N(e,"POST","/v2/accounts/mfaEnrollment:finalize",k(e,t))}(e,{idToken:t,displayName:n,phoneVerificationInfo:this.credential._makeVerificationRequest()})}_finalizeSignIn(e,t){return function(e,t){return N(e,"POST","/v2/accounts/mfaSignIn:finalize",k(e,t))}(e,{mfaPendingCredential:t,phoneVerificationInfo:this.credential._makeVerificationRequest()})}}class rr{constructor(){}static assertion(e){return nr._fromCredential(e)}}rr.FACTOR_ID="phone";class ir{static assertionForEnrollment(e,t){return sr._fromSecret(e,t)}static assertionForSignIn(e,t){return sr._fromEnrollmentId(e,t)}static async generateSecret(e){var t;const n=e;v(void 0!==(null===(t=n.user)||void 0===t?void 0:t.auth),"internal-error");const r=await(i=n.user.auth,s={idToken:n.credential,totpEnrollmentInfo:{}},N(i,"POST","/v2/accounts/mfaEnrollment:start",k(i,s)));var i,s;return or._fromStartTotpMfaEnrollmentResponse(r,n.user.auth)}}ir.FACTOR_ID="totp";class sr extends tr{constructor(e,t,n){super("totp"),this.otp=e,this.enrollmentId=t,this.secret=n}static _fromSecret(e,t){return new sr(t,void 0,e)}static _fromEnrollmentId(e,t){return new sr(t,e)}async _finalizeEnroll(e,t,n){return v(void 0!==this.secret,e,"argument-error"),function(e,t){return N(e,"POST","/v2/accounts/mfaEnrollment:finalize",k(e,t))}(e,{idToken:t,displayName:n,totpVerificationInfo:this.secret._makeTotpVerificationInfo(this.otp)})}async _finalizeSignIn(e,t){v(void 0!==this.enrollmentId&&void 0!==this.otp,e,"argument-error");const n={verificationCode:this.otp};return function(e,t){return N(e,"POST","/v2/accounts/mfaSignIn:finalize",k(e,t))}(e,{mfaPendingCredential:t,mfaEnrollmentId:this.enrollmentId,totpVerificationInfo:n})}}class or{constructor(e,t,n,r,i,s,o){this.sessionInfo=s,this.auth=o,this.secretKey=e,this.hashingAlgorithm=t,this.codeLength=n,this.codeIntervalSeconds=r,this.enrollmentCompletionDeadline=i}static _fromStartTotpMfaEnrollmentResponse(e,t){return new or(e.totpSessionInfo.sharedSecretKey,e.totpSessionInfo.hashingAlgorithm,e.totpSessionInfo.verificationCodeLength,e.totpSessionInfo.periodSec,new Date(e.totpSessionInfo.finalizeEnrollmentTime).toUTCString(),e.totpSessionInfo.sessionInfo,t)}_makeTotpVerificationInfo(e){return{sessionInfo:this.sessionInfo,verificationCode:e}}generateQrCodeUrl(e,t){var n;let r=!1;return(ar(e)||ar(t))&&(r=!0),r&&(ar(e)&&(e=(null===(n=this.auth.currentUser)||void 0===n?void 0:n.email)||"unknownuser"),ar(t)&&(t=this.auth.name)),`otpauth://totp/${t}:${e}?secret=${this.secretKey}&issuer=${t}&algorithm=${this.hashingAlgorithm}&digits=${this.codeLength}`}}function ar(e){return void 0===e||0===(null==e?void 0:e.length)}var cr="@firebase/auth",ur="1.7.8";class lr{constructor(e){this.auth=e,this.internalListeners=new Map}getUid(){var e;return this.assertAuthConfigured(),(null===(e=this.auth.currentUser)||void 0===e?void 0:e.uid)||null}async getToken(e){return this.assertAuthConfigured(),await this.auth._initializationPromise,this.auth.currentUser?{accessToken:await this.auth.currentUser.getIdToken(e)}:null}addAuthTokenListener(e){if(this.assertAuthConfigured(),this.internalListeners.has(e))return;const t=this.auth.onIdTokenChanged((t=>{e((null==t?void 0:t.stsTokenManager.accessToken)||null)}));this.internalListeners.set(e,t),this.updateProactiveRefresh()}removeAuthTokenListener(e){this.assertAuthConfigured();const t=this.internalListeners.get(e);t&&(this.internalListeners.delete(e),t(),this.updateProactiveRefresh())}assertAuthConfigured(){v(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}const hr=i.getExperimentalSetting("authIdTokenMaxAge")||300;let dr=null;var fr;Te={loadJS:e=>new Promise(((t,n)=>{const r=document.createElement("script");var i,s;r.setAttribute("src",e),r.onload=t,r.onerror=e=>{const t=f("internal-error");t.customData=e,n(t)},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)})),gapiScript:"https://apis.google.com/js/api.js",recaptchaV2Script:"https://www.google.com/recaptcha/api.js",recaptchaEnterpriseScript:"https://www.google.com/recaptcha/enterprise.js?render="},fr="Browser",r._registerComponent(new a.Component("auth",((e,{options:t})=>{const n=e.getProvider("app").getImmediate(),r=e.getProvider("heartbeat"),i=e.getProvider("app-check-internal"),{apiKey:s,authDomain:o}=n.options;v(s&&!s.includes(":"),"invalid-api-key",{appName:n.name});const a={apiKey:s,authDomain:o,clientPlatform:fr,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:ve(fr)},c=new _e(n,r,i,a);return function(e,t){const n=(null==t?void 0:t.persistence)||[],r=(Array.isArray(n)?n:[n]).map(re);(null==t?void 0:t.errorMap)&&e._updateErrorMap(t.errorMap),e._initializeWithPersistence(r,null==t?void 0:t.popupRedirectResolver)}(c,t),c}),"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback(((e,t,n)=>{e.getProvider("auth-internal").initialize()}))),r._registerComponent(new a.Component("auth-internal",(e=>{return t=Ie(e.getProvider("auth").getImmediate()),new lr(t);var t}),"PRIVATE").setInstantiationMode("EXPLICIT")),r.registerVersion(cr,ur,function(e){switch(e){case"Node":return"node";case"ReactNative":return"rn";case"Worker":return"webworker";case"Cordova":return"cordova";case"WebExtension":return"web-extension";default:return}}(fr)),r.registerVersion(cr,ur,"cjs2017"),t.AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY={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_LOGIN_CREDENTIALS:"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",RECAPTCHA_NOT_ENABLED:"auth/recaptcha-not-enabled",MISSING_RECAPTCHA_TOKEN:"auth/missing-recaptcha-token",INVALID_RECAPTCHA_TOKEN:"auth/invalid-recaptcha-token",INVALID_RECAPTCHA_ACTION:"auth/invalid-recaptcha-action",MISSING_CLIENT_TYPE:"auth/missing-client-type",MISSING_RECAPTCHA_VERSION:"auth/missing-recaptcha-version",INVALID_RECAPTCHA_VERSION:"auth/invalid-recaptcha-version",INVALID_REQ_TYPE:"auth/invalid-req-type"},t.ActionCodeOperation={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"},t.ActionCodeURL=We,t.AuthCredential=Pe,t.AuthEventManager=Dn,t.AuthImpl=_e,t.AuthPopup=Jn,t.EmailAuthCredential=Be,t.EmailAuthProvider=$e,t.FacebookAuthProvider=Ye,t.FactorId={PHONE:"phone",TOTP:"totp"},t.FetchProvider=C,t.GithubAuthProvider=Ze,t.GoogleAuthProvider=Xe,t.OAuthCredential=ze,t.OAuthProvider=Je,t.OperationType={LINK:"link",REAUTHENTICATE:"reauthenticate",SIGN_IN:"signIn"},t.PhoneAuthCredential=Ke,t.PhoneAuthProvider=pn,t.PhoneMultiFactorGenerator=rr,t.ProviderId={FACEBOOK:"facebook.com",GITHUB:"github.com",GOOGLE:"google.com",PASSWORD:"password",PHONE:"phone",TWITTER:"twitter.com"},t.RecaptchaVerifier=class{constructor(e,t,n=Object.assign({},hn)){this.parameters=n,this.type=ln,this.destroyed=!1,this.widgetId=null,this.tokenChangeListeners=new Set,this.renderPromise=null,this.recaptcha=null,this.auth=Ie(e),this.isInvisible="invisible"===this.parameters.size,v("undefined"!=typeof document,this.auth,"operation-not-supported-in-this-environment");const r="string"==typeof t?document.getElementById(t):t;v(r,this.auth,"argument-error"),this.container=r,this.parameters.callback=this.makeTokenCallback(this.parameters.callback),this._recaptchaLoader=this.auth.settings.appVerificationDisabledForTesting?new un:new cn,this.validateStartingState()}async verify(){this.assertNotDestroyed();const e=await this.render(),t=this.getAssertedRecaptcha();return t.getResponse(e)||new Promise((n=>{const r=e=>{e&&(this.tokenChangeListeners.delete(r),n(e))};this.tokenChangeListeners.add(r),this.isInvisible&&t.execute(e)}))}render(){try{this.assertNotDestroyed()}catch(e){return Promise.reject(e)}return this.renderPromise||(this.renderPromise=this.makeRenderPromise().catch((e=>{throw this.renderPromise=null,e}))),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((e=>{this.container.removeChild(e)}))}validateStartingState(){v(!this.parameters.sitekey,this.auth,"argument-error"),v(this.isInvisible||!this.container.hasChildNodes(),this.auth,"argument-error"),v("undefined"!=typeof document,this.auth,"operation-not-supported-in-this-environment")}makeTokenCallback(e){return t=>{if(this.tokenChangeListeners.forEach((e=>e(t))),"function"==typeof e)e(t);else if("string"==typeof e){const n=Gt()[e];"function"==typeof n&&n(t)}}}assertNotDestroyed(){v(!this.destroyed,this.auth,"internal-error")}async makeRenderPromise(){if(await this.init(),!this.widgetId){let e=this.container;if(!this.isInvisible){const t=document.createElement("div");e.appendChild(t),e=t}this.widgetId=this.getAssertedRecaptcha().render(e,this.parameters)}return this.widgetId}async init(){v(I()&&!Kt(),this.auth,"internal-error"),await function(){let e=null;return new Promise((t=>{"complete"!==document.readyState?(e=()=>t(),window.addEventListener("load",e)):t()})).catch((t=>{throw e&&window.removeEventListener("load",e),t}))}(),this.recaptcha=await this._recaptchaLoader.load(this.auth,this.auth.languageCode||void 0);const e=await async function(e){return(await N(e,"GET","/v1/recaptchaParams")).recaptchaSiteKey||""}(this.auth);v(e,this.auth,"internal-error"),this.parameters.sitekey=e}getAssertedRecaptcha(){return v(this.recaptcha,this.auth,"internal-error"),this.recaptcha}},t.SAMLAuthCredential=et,t.SAMLAuthProvider=tt,t.SignInMethod={EMAIL_LINK:"emailLink",EMAIL_PASSWORD:"password",FACEBOOK:"facebook.com",GITHUB:"github.com",GOOGLE:"google.com",PHONE:"phone",TWITTER:"twitter.com"},t.TotpMultiFactorGenerator=ir,t.TotpSecret=or,t.TwitterAuthProvider=nt,t.UserImpl=te,t._assert=v,t._castAuth=Ie,t._clearRedirectOutcomes=function(){Tn.clear()},t._createError=f,t._fail=d,t._generateEventId=qt,t._getClientVersion=ve,t._getInstance=re,t._getProjectConfig=Ln,t._getRedirectResult=Nn,t._getRedirectUrl=Xn,t._isAndroid=fe,t._isIOS=ge,t._isIOS7Or8=function(e=i.getUA()){return/(iPad|iPhone|iPod).*OS 7_\d/i.test(e)||/(iPad|iPhone|iPod).*OS 8_\d/i.test(e)},t._overrideRedirectResult=An,t._persistenceKeyName=oe,t.applyActionCode=async function(e,t){await async function(e,t){return N(e,"POST","/v1/accounts:update",k(e,t))}(i.getModularInstance(e),{oobCode:t})},t.beforeAuthStateChanged=Nt,t.browserLocalPersistence=Vt,t.browserPopupRedirectResolver=er,t.browserSessionPersistence=jt,t.checkActionCode=_t,t.confirmPasswordReset=async function(e,t,n){await Le(i.getModularInstance(e),{oobCode:t,newPassword:n}).catch((async t=>{throw"auth/password-does-not-meet-requirements"===t.code&&wt(e),t}))},t.connectAuthEmulator=Oe,t.createUserWithEmailAndPassword=async function(e,t,n){if(r._isFirebaseServerApp(e.app))return Promise.reject(m(e));const i=Ie(e),s=ke(i,{returnSecureToken:!0,email:t,password:n,clientType:"CLIENT_TYPE_WEB"},"signUpPassword",rt),o=await s.catch((t=>{throw"auth/password-does-not-meet-requirements"===t.code&&wt(e),t})),a=await it._fromIdTokenResponse(i,"signIn",o);return await i._updateCurrentUser(a.user),a},t.debugAssert=w,t.debugErrorMap=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 registered 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 incorrect, 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.","login-blocked":"Login blocked by user-provided method: {$originalMessage}","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-password":"A non-empty password must be provided","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.","missing-recaptcha-token":"The reCAPTCHA token is missing when sending request to the backend.","invalid-recaptcha-token":"The reCAPTCHA token is invalid when sending request to the backend.","invalid-recaptcha-action":"The reCAPTCHA action is invalid when sending request to the backend.","recaptcha-not-enabled":"reCAPTCHA Enterprise integration is not enabled for this project.","missing-client-type":"The reCAPTCHA client type is missing when sending request to the backend.","missing-recaptcha-version":"The reCAPTCHA version is missing when sending request to the backend.","invalid-req-type":"Invalid request parameters.","invalid-recaptcha-version":"The reCAPTCHA version is invalid when sending request to the backend.","unsupported-password-policy-schema-version":"The password policy received from the backend uses a schema version that is not supported by this version of the Firebase SDK.","password-does-not-meet-requirements":"The password does not meet the requirements."}},t.deleteUser=async function(e){return i.getModularInstance(e).delete()},t.fetchSignInMethodsForEmail=async function(e,t){const n={identifier:t,continueUri:I()?_():"http://localhost"},{signinMethods:r}=await async function(e,t){return N(e,"POST","/v1/accounts:createAuthUri",k(e,t))}(i.getModularInstance(e),n);return r||[]},t.getAdditionalUserInfo=function(e){const{user:t,_tokenResponse:n}=e;return t.isAnonymous&&!n?{providerId:null,isNewUser:!1,profile:null}:function(e){var t,n;if(!e)return null;const{providerId:r}=e,i=e.rawUserInfo?JSON.parse(e.rawUserInfo):{},s=e.isNewUser||"identitytoolkit#SignupNewUserResponse"===e.kind;if(!r&&(null==e?void 0:e.idToken)){const r=null===(n=null===(t=K(e.idToken))||void 0===t?void 0:t.firebase)||void 0===n?void 0:n.sign_in_provider;if(r)return new Et(s,"anonymous"!==r&&"custom"!==r?r:null)}if(!r)return null;switch(r){case"facebook.com":return new St(s,i);case"github.com":return new Ct(s,i);case"google.com":return new At(s,i);case"twitter.com":return new xt(s,i,e.screenName||null);case"custom":case"anonymous":return new Et(s,null);default:return new Et(s,r,i)}}(n)},t.getAuth=function(e=r.getApp()){const t=r._getProvider(e,"auth");if(t.isInitialized())return t.getImmediate();const n=Ne(e,{popupRedirectResolver:er,persistence:[tn,Vt,jt]}),s=i.getExperimentalSetting("authTokenSyncURL");if(s&&"boolean"==typeof isSecureContext&&isSecureContext){const e=new URL(s,location.origin);if(location.origin===e.origin){const t=(o=e.toString(),async e=>{const t=e&&await e.getIdTokenResult(),n=t&&((new Date).getTime()-Date.parse(t.issuedAtTime))/1e3;if(n&&n>hr)return;const r=null==t?void 0:t.token;dr!==r&&(dr=r,await fetch(o,{method:r?"POST":"DELETE",headers:r?{Authorization:`Bearer ${r}`}:{}}))});Nt(n,t,(()=>t(n.currentUser))),kt(n,(e=>t(e)))}}var o;const a=i.getDefaultEmulatorHost("auth");return a&&Oe(n,`http://${a}`),n},t.getIdToken=function(e,t=!1){return i.getModularInstance(e).getIdToken(t)},t.getIdTokenResult=z,t.getMultiFactorResolver=function(e,t){var n;const r=i.getModularInstance(e),s=t;return v(t.customData.operationType,r,"argument-error"),v(null===(n=s.customData._serverResponse)||void 0===n?void 0:n.mfaPendingCredential,r,"argument-error"),Dt._fromError(r,s)},t.getRedirectResult=async function(e,t){return await Ie(e)._initializationPromise,Nn(e,t,!1)},t.inMemoryPersistence=se,t.indexedDBLocalPersistence=tn,t.initializeAuth=Ne,t.initializeRecaptchaConfig=function(e){return async function(e){const t=Ie(e),n=await j(t,{clientType:"CLIENT_TYPE_WEB",version:"RECAPTCHA_ENTERPRISE"}),r=new U(n);null==t.tenantId?t._agentRecaptchaConfig=r:t._tenantRecaptchaConfigs[t.tenantId]=r,r.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")&&new Ae(t).verify()}(e)},t.isSignInWithEmailLink=function(e,t){const n=We.parseLink(t);return"EMAIL_SIGNIN"===(null==n?void 0:n.operation)},t.linkWithCredential=pt,t.linkWithPhoneNumber=async function(e,t,n){const r=i.getModularInstance(e);await lt(!1,r,"phone");const s=await fn(r.auth,t,i.getModularInstance(n));return new dn(s,(e=>pt(r,e)))},t.linkWithPopup=async function(e,t,n){const r=i.getModularInstance(e);g(r.auth,t,He);const s=mn(r.auth,n);return new In(r.auth,"linkViaPopup",t,s,r).executeNotNull()},t.linkWithRedirect=function(e,t,n){return async function(e,t,n){const r=i.getModularInstance(e);g(r.auth,t,He),await r.auth._initializationPromise;const s=mn(r.auth,n);await lt(!1,r,t.providerId),await Cn(s,r.auth);const o=await On(r);return s._openRedirect(r.auth,t,"linkViaRedirect",o)}(e,t,n)},t.multiFactor=function(e){const t=i.getModularInstance(e);return Pt.has(t)||Pt.set(t,Rt._fromUser(t)),Pt.get(t)},t.onAuthStateChanged=function(e,t,n,r){return i.getModularInstance(e).onAuthStateChanged(t,n,r)},t.onIdTokenChanged=kt,t.parseActionCodeURL=function(e){return We.parseLink(e)},t.prodErrorMap=c,t.reauthenticateWithCredential=mt,t.reauthenticateWithPhoneNumber=async function(e,t,n){const s=i.getModularInstance(e);if(r._isFirebaseServerApp(s.auth.app))return Promise.reject(m(s.auth));const o=await fn(s.auth,t,i.getModularInstance(n));return new dn(o,(e=>mt(s,e)))},t.reauthenticateWithPopup=async function(e,t,n){const s=i.getModularInstance(e);if(r._isFirebaseServerApp(s.auth.app))return Promise.reject(f(s.auth,"operation-not-supported-in-this-environment"));g(s.auth,t,He);const o=mn(s.auth,n);return new In(s.auth,"reauthViaPopup",t,o,s).executeNotNull()},t.reauthenticateWithRedirect=function(e,t,n){return async function(e,t,n){const s=i.getModularInstance(e);if(g(s.auth,t,He),r._isFirebaseServerApp(s.auth.app))return Promise.reject(m(s.auth));await s.auth._initializationPromise;const o=mn(s.auth,n);await Cn(o,s.auth);const a=await On(s);return o._openRedirect(s.auth,t,"reauthViaRedirect",a)}(e,t,n)},t.reload=Y,t.revokeAccessToken=function(e,t){return Ie(e).revokeAccessToken(t)},t.sendEmailVerification=async function(e,t){const n=i.getModularInstance(e),r={requestType:"VERIFY_EMAIL",idToken:await e.getIdToken()};t&&bt(n.auth,r,t);const{email:s}=await async function(e,t){return Ve(e,t)}(n.auth,r);s!==e.email&&await e.reload()},t.sendPasswordResetEmail=async function(e,t,n){const r=Ie(e),i={requestType:"PASSWORD_RESET",email:t,clientType:"CLIENT_TYPE_WEB"};n&&bt(r,i,n),await ke(r,i,"getOobCode",Ue)},t.sendSignInLinkToEmail=async function(e,t,n){const r=Ie(e),i={requestType:"EMAIL_SIGNIN",email:t,clientType:"CLIENT_TYPE_WEB"};!function(e,t){v(t.handleCodeInApp,r,"argument-error"),t&&bt(r,e,t)}(i,n),await ke(r,i,"getOobCode",je)},t.setPersistence=function(e,t){return i.getModularInstance(e).setPersistence(t)},t.signInAnonymously=async function(e){var t;if(r._isFirebaseServerApp(e.app))return Promise.reject(m(e));const n=Ie(e);if(await n._initializationPromise,null===(t=n.currentUser)||void 0===t?void 0:t.isAnonymous)return new it({user:n.currentUser,providerId:null,operationType:"signIn"});const i=await rt(n,{returnSecureToken:!0}),s=await it._fromIdTokenResponse(n,"signIn",i,!0);return await n._updateCurrentUser(s.user),s},t.signInWithCredential=ft,t.signInWithCustomToken=async function(e,t){if(r._isFirebaseServerApp(e.app))return Promise.reject(m(e));const n=Ie(e),i=await async function(e,t){return D(e,"POST","/v1/accounts:signInWithCustomToken",k(e,t))}(n,{token:t,returnSecureToken:!0}),s=await it._fromIdTokenResponse(n,"signIn",i);return await n._updateCurrentUser(s.user),s},t.signInWithEmailAndPassword=function(e,t,n){return r._isFirebaseServerApp(e.app)?Promise.reject(m(e)):ft(i.getModularInstance(e),$e.credential(t,n)).catch((async t=>{throw"auth/password-does-not-meet-requirements"===t.code&&wt(e),t}))},t.signInWithEmailLink=async function(e,t,n){if(r._isFirebaseServerApp(e.app))return Promise.reject(m(e));const s=i.getModularInstance(e),o=$e.credentialWithLink(t,n||_());return v(o._tenantId===(s.tenantId||null),s,"tenant-id-mismatch"),ft(s,o)},t.signInWithPhoneNumber=async function(e,t,n){if(r._isFirebaseServerApp(e.app))return Promise.reject(m(e));const s=Ie(e),o=await fn(s,t,i.getModularInstance(n));return new dn(o,(e=>ft(s,e)))},t.signInWithPopup=async function(e,t,n){if(r._isFirebaseServerApp(e.app))return Promise.reject(f(e,"operation-not-supported-in-this-environment"));const i=Ie(e);g(e,t,He);const s=mn(i,n);return new In(i,"signInViaPopup",t,s).executeNotNull()},t.signInWithRedirect=function(e,t,n){return async function(e,t,n){if(r._isFirebaseServerApp(e.app))return Promise.reject(m(e));const i=Ie(e);g(e,t,He),await i._initializationPromise;const s=mn(i,n);return await Cn(s,i),s._openRedirect(i,t,"signInViaRedirect")}(e,t,n)},t.signOut=function(e){return i.getModularInstance(e).signOut()},t.unlink=async function(e,t){const n=i.getModularInstance(e);await lt(!0,n,t);const{providerUserInfo:r}=await async function(e,t){return N(e,"POST","/v1/accounts:update",t)}(n.auth,{idToken:await n.getIdToken(),deleteProvider:[t]}),s=ct(r||[]);return n.providerData=n.providerData.filter((e=>s.has(e.providerId))),s.has("phone")||(n.phoneNumber=null),await n.auth._persistUserIfCurrent(n),n},t.updateCurrentUser=function(e,t){return i.getModularInstance(e).updateCurrentUser(t)},t.updateEmail=function(e,t){const n=i.getModularInstance(e);return r._isFirebaseServerApp(n.auth.app)?Promise.reject(m(n.auth)):It(n,t,null)},t.updatePassword=function(e,t){return It(i.getModularInstance(e),null,t)},t.updatePhoneNumber=async function(e,t){const n=i.getModularInstance(e);if(r._isFirebaseServerApp(n.auth.app))return Promise.reject(m(n.auth));await ut(n,t)},t.updateProfile=async function(e,{displayName:t,photoURL:n}){if(void 0===t&&void 0===n)return;const r=i.getModularInstance(e),s={idToken:await r.getIdToken(),displayName:t,photoUrl:n,returnSecureToken:!0},o=await $(r,async function(e,t){return N(e,"POST","/v1/accounts:update",t)}(r.auth,s));r.displayName=o.displayName||null,r.photoURL=o.photoUrl||null;const a=r.providerData.find((({providerId:e})=>"password"===e));a&&(a.displayName=r.displayName,a.photoURL=r.photoURL),await r._updateTokensIfNecessary(o)},t.useDeviceLanguage=function(e){i.getModularInstance(e).useDeviceLanguage()},t.validatePassword=async function(e,t){return Ie(e).validatePassword(t)},t.verifyBeforeUpdateEmail=async function(e,t,n){const r=i.getModularInstance(e),s={requestType:"VERIFY_AND_CHANGE_EMAIL",idToken:await e.getIdToken(),newEmail:t};n&&bt(r.auth,s,n);const{email:o}=await async function(e,t){return Ve(e,t)}(r.auth,s);o!==e.email&&await e.reload()},t.verifyPasswordResetCode=async function(e,t){const{data:n}=await _t(i.getModularInstance(e),t);return n.email}},9970:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(8366);n(6199),n(6336),n(5844),n(1635),n(5319),t.ActionCodeOperation=r.ActionCodeOperation,t.ActionCodeURL=r.ActionCodeURL,t.AuthCredential=r.AuthCredential,t.AuthErrorCodes=r.AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY,t.EmailAuthCredential=r.EmailAuthCredential,t.EmailAuthProvider=r.EmailAuthProvider,t.FacebookAuthProvider=r.FacebookAuthProvider,t.FactorId=r.FactorId,t.GithubAuthProvider=r.GithubAuthProvider,t.GoogleAuthProvider=r.GoogleAuthProvider,t.OAuthCredential=r.OAuthCredential,t.OAuthProvider=r.OAuthProvider,t.OperationType=r.OperationType,t.PhoneAuthCredential=r.PhoneAuthCredential,t.PhoneAuthProvider=r.PhoneAuthProvider,t.PhoneMultiFactorGenerator=r.PhoneMultiFactorGenerator,t.ProviderId=r.ProviderId,t.RecaptchaVerifier=r.RecaptchaVerifier,t.SAMLAuthProvider=r.SAMLAuthProvider,t.SignInMethod=r.SignInMethod,t.TotpMultiFactorGenerator=r.TotpMultiFactorGenerator,t.TotpSecret=r.TotpSecret,t.TwitterAuthProvider=r.TwitterAuthProvider,t.applyActionCode=r.applyActionCode,t.beforeAuthStateChanged=r.beforeAuthStateChanged,t.browserLocalPersistence=r.browserLocalPersistence,t.browserPopupRedirectResolver=r.browserPopupRedirectResolver,t.browserSessionPersistence=r.browserSessionPersistence,t.checkActionCode=r.checkActionCode,t.confirmPasswordReset=r.confirmPasswordReset,t.connectAuthEmulator=r.connectAuthEmulator,t.createUserWithEmailAndPassword=r.createUserWithEmailAndPassword,t.debugErrorMap=r.debugErrorMap,t.deleteUser=r.deleteUser,t.fetchSignInMethodsForEmail=r.fetchSignInMethodsForEmail,t.getAdditionalUserInfo=r.getAdditionalUserInfo,t.getAuth=r.getAuth,t.getIdToken=r.getIdToken,t.getIdTokenResult=r.getIdTokenResult,t.getMultiFactorResolver=r.getMultiFactorResolver,t.getRedirectResult=r.getRedirectResult,t.inMemoryPersistence=r.inMemoryPersistence,t.indexedDBLocalPersistence=r.indexedDBLocalPersistence,t.initializeAuth=r.initializeAuth,t.initializeRecaptchaConfig=r.initializeRecaptchaConfig,t.isSignInWithEmailLink=r.isSignInWithEmailLink,t.linkWithCredential=r.linkWithCredential,t.linkWithPhoneNumber=r.linkWithPhoneNumber,t.linkWithPopup=r.linkWithPopup,t.linkWithRedirect=r.linkWithRedirect,t.multiFactor=r.multiFactor,t.onAuthStateChanged=r.onAuthStateChanged,t.onIdTokenChanged=r.onIdTokenChanged,t.parseActionCodeURL=r.parseActionCodeURL,t.prodErrorMap=r.prodErrorMap,t.reauthenticateWithCredential=r.reauthenticateWithCredential,t.reauthenticateWithPhoneNumber=r.reauthenticateWithPhoneNumber,t.reauthenticateWithPopup=r.reauthenticateWithPopup,t.reauthenticateWithRedirect=r.reauthenticateWithRedirect,t.reload=r.reload,t.revokeAccessToken=r.revokeAccessToken,t.sendEmailVerification=r.sendEmailVerification,t.sendPasswordResetEmail=r.sendPasswordResetEmail,t.sendSignInLinkToEmail=r.sendSignInLinkToEmail,t.setPersistence=r.setPersistence,t.signInAnonymously=r.signInAnonymously,t.signInWithCredential=r.signInWithCredential,t.signInWithCustomToken=r.signInWithCustomToken,t.signInWithEmailAndPassword=r.signInWithEmailAndPassword,t.signInWithEmailLink=r.signInWithEmailLink,t.signInWithPhoneNumber=r.signInWithPhoneNumber,t.signInWithPopup=r.signInWithPopup,t.signInWithRedirect=r.signInWithRedirect,t.signOut=r.signOut,t.unlink=r.unlink,t.updateCurrentUser=r.updateCurrentUser,t.updateEmail=r.updateEmail,t.updatePassword=r.updatePassword,t.updatePhoneNumber=r.updatePhoneNumber,t.updateProfile=r.updateProfile,t.useDeviceLanguage=r.useDeviceLanguage,t.validatePassword=r.validatePassword,t.verifyBeforeUpdateEmail=r.verifyBeforeUpdateEmail,t.verifyPasswordResetCode=r.verifyPasswordResetCode},5319:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(1635),i=n(6336),s=function(){function e(e,t,n){this.name=e,this.instanceFactory=t,this.type=n,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}return e.prototype.setInstantiationMode=function(e){return this.instantiationMode=e,this},e.prototype.setMultipleInstances=function(e){return this.multipleInstances=e,this},e.prototype.setServiceProps=function(e){return this.serviceProps=e,this},e.prototype.setInstanceCreatedCallback=function(e){return this.onInstanceCreated=e,this},e}(),o="[DEFAULT]",a=function(){function e(e,t){this.name=e,this.container=t,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}return e.prototype.get=function(e){var t=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(t)){var n=new i.Deferred;if(this.instancesDeferred.set(t,n),this.isInitialized(t)||this.shouldAutoInitialize())try{var r=this.getOrInitializeService({instanceIdentifier:t});r&&n.resolve(r)}catch(e){}}return this.instancesDeferred.get(t).promise},e.prototype.getImmediate=function(e){var t,n=this.normalizeInstanceIdentifier(null==e?void 0:e.identifier),r=null!==(t=null==e?void 0:e.optional)&&void 0!==t&&t;if(!this.isInitialized(n)&&!this.shouldAutoInitialize()){if(r)return null;throw Error("Service ".concat(this.name," is not available"))}try{return this.getOrInitializeService({instanceIdentifier:n})}catch(e){if(r)return null;throw e}},e.prototype.getComponent=function(){return this.component},e.prototype.setComponent=function(e){var t,n;if(e.name!==this.name)throw Error("Mismatching Component ".concat(e.name," for Provider ").concat(this.name,"."));if(this.component)throw Error("Component for ".concat(this.name," has already been provided"));if(this.component=e,this.shouldAutoInitialize()){if(function(e){return"EAGER"===e.instantiationMode}(e))try{this.getOrInitializeService({instanceIdentifier:o})}catch(e){}try{for(var i=r.__values(this.instancesDeferred.entries()),s=i.next();!s.done;s=i.next()){var a=r.__read(s.value,2),c=a[0],u=a[1],l=this.normalizeInstanceIdentifier(c);try{var h=this.getOrInitializeService({instanceIdentifier:l});u.resolve(h)}catch(e){}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}}},e.prototype.clearInstance=function(e){void 0===e&&(e=o),this.instancesDeferred.delete(e),this.instancesOptions.delete(e),this.instances.delete(e)},e.prototype.delete=function(){return r.__awaiter(this,void 0,void 0,(function(){var e;return r.__generator(this,(function(t){switch(t.label){case 0:return e=Array.from(this.instances.values()),[4,Promise.all(r.__spreadArray(r.__spreadArray([],r.__read(e.filter((function(e){return"INTERNAL"in e})).map((function(e){return e.INTERNAL.delete()}))),!1),r.__read(e.filter((function(e){return"_delete"in e})).map((function(e){return e._delete()}))),!1))];case 1:return t.sent(),[2]}}))}))},e.prototype.isComponentSet=function(){return null!=this.component},e.prototype.isInitialized=function(e){return void 0===e&&(e=o),this.instances.has(e)},e.prototype.getOptions=function(e){return void 0===e&&(e=o),this.instancesOptions.get(e)||{}},e.prototype.initialize=function(e){var t,n;void 0===e&&(e={});var i=e.options,s=void 0===i?{}:i,o=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(o))throw Error("".concat(this.name,"(").concat(o,") has already been initialized"));if(!this.isComponentSet())throw Error("Component ".concat(this.name," has not been registered yet"));var a=this.getOrInitializeService({instanceIdentifier:o,options:s});try{for(var c=r.__values(this.instancesDeferred.entries()),u=c.next();!u.done;u=c.next()){var l=r.__read(u.value,2),h=l[0],d=l[1];o===this.normalizeInstanceIdentifier(h)&&d.resolve(a)}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=c.return)&&n.call(c)}finally{if(t)throw t.error}}return a},e.prototype.onInit=function(e,t){var n,r=this.normalizeInstanceIdentifier(t),i=null!==(n=this.onInitCallbacks.get(r))&&void 0!==n?n:new Set;i.add(e),this.onInitCallbacks.set(r,i);var s=this.instances.get(r);return s&&e(s,r),function(){i.delete(e)}},e.prototype.invokeOnInitCallbacks=function(e,t){var n,i,s=this.onInitCallbacks.get(t);if(s)try{for(var o=r.__values(s),a=o.next();!a.done;a=o.next()){var c=a.value;try{c(e,t)}catch(e){}}}catch(e){n={error:e}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}},e.prototype.getOrInitializeService=function(e){var t,n=e.instanceIdentifier,r=e.options,i=void 0===r?{}:r,s=this.instances.get(n);if(!s&&this.component&&(s=this.component.instanceFactory(this.container,{instanceIdentifier:(t=n,t===o?void 0:t),options:i}),this.instances.set(n,s),this.instancesOptions.set(n,i),this.invokeOnInitCallbacks(s,n),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,n,s)}catch(e){}return s||null},e.prototype.normalizeInstanceIdentifier=function(e){return void 0===e&&(e=o),this.component?this.component.multipleInstances?e:o:e},e.prototype.shouldAutoInitialize=function(){return!!this.component&&"EXPLICIT"!==this.component.instantiationMode},e}(),c=function(){function e(e){this.name=e,this.providers=new Map}return e.prototype.addComponent=function(e){var t=this.getProvider(e.name);if(t.isComponentSet())throw new Error("Component ".concat(e.name," has already been registered with ").concat(this.name));t.setComponent(e)},e.prototype.addOrOverwriteComponent=function(e){this.getProvider(e.name).isComponentSet()&&this.providers.delete(e.name),this.addComponent(e)},e.prototype.getProvider=function(e){if(this.providers.has(e))return this.providers.get(e);var t=new a(e,this);return this.providers.set(e,t),t},e.prototype.getProviders=function(){return Array.from(this.providers.values())},e}();t.Component=s,t.ComponentContainer=c,t.Provider=a},1241:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(6199),i=n(5319),s=n(5844),o=n(6336),a=n(860),c=n(4832);const u="@firebase/firestore";class l{constructor(e){this.uid=e}isAuthenticated(){return null!=this.uid}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(e){return e.uid===this.uid}}l.UNAUTHENTICATED=new l(null),l.GOOGLE_CREDENTIALS=new l("google-credentials-uid"),l.FIRST_PARTY=new l("first-party-uid"),l.MOCK_USER=new l("mock-user");let h="10.13.1";const d=new s.Logger("@firebase/firestore");function f(){return d.logLevel}function p(e,...t){if(d.logLevel<=s.LogLevel.DEBUG){const n=t.map(y);d.debug(`Firestore (${h}): ${e}`,...n)}}function m(e,...t){if(d.logLevel<=s.LogLevel.ERROR){const n=t.map(y);d.error(`Firestore (${h}): ${e}`,...n)}}function g(e,...t){if(d.logLevel<=s.LogLevel.WARN){const n=t.map(y);d.warn(`Firestore (${h}): ${e}`,...n)}}function y(e){if("string"==typeof e)return e;try{return function(e){return JSON.stringify(e)}(e)}catch(t){return e}}function v(e="Unexpected state"){const t=`FIRESTORE (${h}) INTERNAL ASSERTION FAILED: `+e;throw m(t),new Error(t)}function b(e,t){e||v()}function w(e,t){return e}const _={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 I extends o.FirebaseError{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}class E{constructor(){this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}}class T{constructor(e,t){this.user=t,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class S{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable((()=>t(l.UNAUTHENTICATED)))}shutdown(){}}class C{constructor(e){this.token=e,this.changeListener=null}getToken(){return Promise.resolve(this.token)}invalidateToken(){}start(e,t){this.changeListener=t,e.enqueueRetryable((()=>t(this.token.user)))}shutdown(){this.changeListener=null}}class A{constructor(e){this.t=e,this.currentUser=l.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,t){let n=this.i;const r=e=>this.i!==n?(n=this.i,t(e)):Promise.resolve();let i=new E;this.o=()=>{this.i++,this.currentUser=this.u(),i.resolve(),i=new E,e.enqueueRetryable((()=>r(this.currentUser)))};const s=()=>{const t=i;e.enqueueRetryable((async()=>{await t.promise,await r(this.currentUser)}))},o=e=>{p("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=e,this.auth.addAuthTokenListener(this.o),s()};this.t.onInit((e=>o(e))),setTimeout((()=>{if(!this.auth){const e=this.t.getImmediate({optional:!0});e?o(e):(p("FirebaseAuthCredentialsProvider","Auth not yet detected"),i.resolve(),i=new E)}}),0),s()}getToken(){const e=this.i,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then((t=>this.i!==e?(p("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):t?(b("string"==typeof t.accessToken),new T(t.accessToken,this.currentUser)):null)):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.auth.removeAuthTokenListener(this.o)}u(){const e=this.auth&&this.auth.getUid();return b(null===e||"string"==typeof e),new l(e)}}class x{constructor(e,t,n){this.l=e,this.h=t,this.P=n,this.type="FirstParty",this.user=l.FIRST_PARTY,this.I=new Map}T(){return this.P?this.P():null}get headers(){this.I.set("X-Goog-AuthUser",this.l);const e=this.T();return e&&this.I.set("Authorization",e),this.h&&this.I.set("X-Goog-Iam-Authorization-Token",this.h),this.I}}class k{constructor(e,t,n){this.l=e,this.h=t,this.P=n}getToken(){return Promise.resolve(new x(this.l,this.h,this.P))}start(e,t){e.enqueueRetryable((()=>t(l.FIRST_PARTY)))}shutdown(){}invalidateToken(){}}class N{constructor(e){this.value=e,this.type="AppCheck",this.headers=new Map,e&&e.length>0&&this.headers.set("x-firebase-appcheck",this.value)}}class O{constructor(e){this.A=e,this.forceRefresh=!1,this.appCheck=null,this.R=null}start(e,t){const n=e=>{null!=e.error&&p("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${e.error.message}`);const n=e.token!==this.R;return this.R=e.token,p("FirebaseAppCheckTokenProvider",`Received ${n?"new":"existing"} token.`),n?t(e.token):Promise.resolve()};this.o=t=>{e.enqueueRetryable((()=>n(t)))};const r=e=>{p("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=e,this.appCheck.addTokenListener(this.o)};this.A.onInit((e=>r(e))),setTimeout((()=>{if(!this.appCheck){const e=this.A.getImmediate({optional:!0});e?r(e):p("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}}),0)}getToken(){const e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then((e=>e?(b("string"==typeof e.token),this.R=e.token,new N(e.token)):null)):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.appCheck.removeTokenListener(this.o)}}function D(e){const t="undefined"!=typeof self&&(self.crypto||self.msCrypto),n=new Uint8Array(e);if(t&&"function"==typeof t.getRandomValues)t.getRandomValues(n);else for(let t=0;t<e;t++)n[t]=Math.floor(256*Math.random());return n}class R{static newId(){const e=62*Math.floor(256/62);let t="";for(;t.length<20;){const n=D(40);for(let r=0;r<n.length;++r)t.length<20&&n[r]<e&&(t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(n[r]%62))}return t}}function P(e,t){return e<t?-1:e>t?1:0}function L(e,t,n){return e.length===t.length&&e.every(((e,r)=>n(e,t[r])))}function M(e){return e+"\0"}class F{constructor(e,t){if(this.seconds=e,this.nanoseconds=t,t<0)throw new I(_.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(t>=1e9)throw new I(_.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(e<-62135596800)throw new I(_.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e);if(e>=253402300800)throw new I(_.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e)}static now(){return F.fromMillis(Date.now())}static fromDate(e){return F.fromMillis(e.getTime())}static fromMillis(e){const t=Math.floor(e/1e3),n=Math.floor(1e6*(e-1e3*t));return new F(t,n)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/1e6}_compareTo(e){return this.seconds===e.seconds?P(this.nanoseconds,e.nanoseconds):P(this.seconds,e.seconds)}isEqual(e){return e.seconds===this.seconds&&e.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{seconds:this.seconds,nanoseconds:this.nanoseconds}}valueOf(){const e=this.seconds- -62135596800;return String(e).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}class V{constructor(e){this.timestamp=e}static fromTimestamp(e){return new V(e)}static min(){return new V(new F(0,0))}static max(){return new V(new F(253402300799,999999999))}compareTo(e){return this.timestamp._compareTo(e.timestamp)}isEqual(e){return this.timestamp.isEqual(e.timestamp)}toMicroseconds(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}toString(){return"SnapshotVersion("+this.timestamp.toString()+")"}toTimestamp(){return this.timestamp}}class U{constructor(e,t,n){void 0===t?t=0:t>e.length&&v(),void 0===n?n=e.length-t:n>e.length-t&&v(),this.segments=e,this.offset=t,this.len=n}get length(){return this.len}isEqual(e){return 0===U.comparator(this,e)}child(e){const t=this.segments.slice(this.offset,this.limit());return e instanceof U?e.forEach((e=>{t.push(e)})):t.push(e),this.construct(t)}limit(){return this.offset+this.length}popFirst(e){return e=void 0===e?1:e,this.construct(this.segments,this.offset+e,this.length-e)}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(e){return this.segments[this.offset+e]}isEmpty(){return 0===this.length}isPrefixOf(e){if(e.length<this.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}isImmediateParentOf(e){if(this.length+1!==e.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}forEach(e){for(let t=this.offset,n=this.limit();t<n;t++)e(this.segments[t])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(e,t){const n=Math.min(e.length,t.length);for(let r=0;r<n;r++){const n=e.get(r),i=t.get(r);if(n<i)return-1;if(n>i)return 1}return e.length<t.length?-1:e.length>t.length?1:0}}class j extends U{construct(e,t,n){return new j(e,t,n)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...e){const t=[];for(const n of e){if(n.indexOf("//")>=0)throw new I(_.INVALID_ARGUMENT,`Invalid segment (${n}). Paths must not contain // in them.`);t.push(...n.split("/").filter((e=>e.length>0)))}return new j(t)}static emptyPath(){return new j([])}}const B=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class q extends U{construct(e,t,n){return new q(e,t,n)}static isValidIdentifier(e){return B.test(e)}canonicalString(){return this.toArray().map((e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),q.isValidIdentifier(e)||(e="`"+e+"`"),e))).join(".")}toString(){return this.canonicalString()}isKeyField(){return 1===this.length&&"__name__"===this.get(0)}static keyField(){return new q(["__name__"])}static fromServerFormat(e){const t=[];let n="",r=0;const i=()=>{if(0===n.length)throw new I(_.INVALID_ARGUMENT,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);t.push(n),n=""};let s=!1;for(;r<e.length;){const t=e[r];if("\\"===t){if(r+1===e.length)throw new I(_.INVALID_ARGUMENT,"Path has trailing escape character: "+e);const t=e[r+1];if("\\"!==t&&"."!==t&&"`"!==t)throw new I(_.INVALID_ARGUMENT,"Path has invalid escape sequence: "+e);n+=t,r+=2}else"`"===t?(s=!s,r++):"."!==t||s?(n+=t,r++):(i(),r++)}if(i(),s)throw new I(_.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new q(t)}static emptyPath(){return new q([])}}class z{constructor(e){this.path=e}static fromPath(e){return new z(j.fromString(e))}static fromName(e){return new z(j.fromString(e).popFirst(5))}static empty(){return new z(j.emptyPath())}get collectionGroup(){return this.path.popLast().lastSegment()}hasCollectionId(e){return this.path.length>=2&&this.path.get(this.path.length-2)===e}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(e){return null!==e&&0===j.comparator(this.path,e.path)}toString(){return this.path.toString()}static comparator(e,t){return j.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new z(new j(e.slice()))}}class G{constructor(e,t,n,r){this.indexId=e,this.collectionGroup=t,this.fields=n,this.indexState=r}}function K(e){return e.fields.find((e=>2===e.kind))}function W(e){return e.fields.filter((e=>2!==e.kind))}function $(e,t){let n=P(e.collectionGroup,t.collectionGroup);if(0!==n)return n;for(let r=0;r<Math.min(e.fields.length,t.fields.length);++r)if(n=Q(e.fields[r],t.fields[r]),0!==n)return n;return P(e.fields.length,t.fields.length)}G.UNKNOWN_ID=-1;class H{constructor(e,t){this.fieldPath=e,this.kind=t}}function Q(e,t){const n=q.comparator(e.fieldPath,t.fieldPath);return 0!==n?n:P(e.kind,t.kind)}class J{constructor(e,t){this.sequenceNumber=e,this.offset=t}static empty(){return new J(0,Z.min())}}function Y(e,t){const n=e.toTimestamp().seconds,r=e.toTimestamp().nanoseconds+1,i=V.fromTimestamp(1e9===r?new F(n+1,0):new F(n,r));return new Z(i,z.empty(),t)}function X(e){return new Z(e.readTime,e.key,-1)}class Z{constructor(e,t,n){this.readTime=e,this.documentKey=t,this.largestBatchId=n}static min(){return new Z(V.min(),z.empty(),-1)}static max(){return new Z(V.max(),z.empty(),-1)}}function ee(e,t){let n=e.readTime.compareTo(t.readTime);return 0!==n?n:(n=z.comparator(e.documentKey,t.documentKey),0!==n?n:P(e.largestBatchId,t.largestBatchId))}const te="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class ne{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach((e=>e()))}}async function re(e){if(e.code!==_.FAILED_PRECONDITION||e.message!==te)throw e;p("LocalStore","Unexpectedly lost primary lease")}class ie{constructor(e){this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,e((e=>{this.isDone=!0,this.result=e,this.nextCallback&&this.nextCallback(e)}),(e=>{this.isDone=!0,this.error=e,this.catchCallback&&this.catchCallback(e)}))}catch(e){return this.next(void 0,e)}next(e,t){return this.callbackAttached&&v(),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(t,this.error):this.wrapSuccess(e,this.result):new ie(((n,r)=>{this.nextCallback=t=>{this.wrapSuccess(e,t).next(n,r)},this.catchCallback=e=>{this.wrapFailure(t,e).next(n,r)}}))}toPromise(){return new Promise(((e,t)=>{this.next(e,t)}))}wrapUserFunction(e){try{const t=e();return t instanceof ie?t:ie.resolve(t)}catch(e){return ie.reject(e)}}wrapSuccess(e,t){return e?this.wrapUserFunction((()=>e(t))):ie.resolve(t)}wrapFailure(e,t){return e?this.wrapUserFunction((()=>e(t))):ie.reject(t)}static resolve(e){return new ie(((t,n)=>{t(e)}))}static reject(e){return new ie(((t,n)=>{n(e)}))}static waitFor(e){return new ie(((t,n)=>{let r=0,i=0,s=!1;e.forEach((e=>{++r,e.next((()=>{++i,s&&i===r&&t()}),(e=>n(e)))})),s=!0,i===r&&t()}))}static or(e){let t=ie.resolve(!1);for(const n of e)t=t.next((e=>e?ie.resolve(e):n()));return t}static forEach(e,t){const n=[];return e.forEach(((e,r)=>{n.push(t.call(this,e,r))})),this.waitFor(n)}static mapArray(e,t){return new ie(((n,r)=>{const i=e.length,s=new Array(i);let o=0;for(let a=0;a<i;a++){const c=a;t(e[c]).next((e=>{s[c]=e,++o,o===i&&n(s)}),(e=>r(e)))}}))}static doWhile(e,t){return new ie(((n,r)=>{const i=()=>{!0===e()?t().next((()=>{i()}),r):n()};i()}))}}class se{constructor(e,t){this.action=e,this.transaction=t,this.aborted=!1,this.V=new E,this.transaction.oncomplete=()=>{this.V.resolve()},this.transaction.onabort=()=>{t.error?this.V.reject(new ue(e,t.error)):this.V.resolve()},this.transaction.onerror=t=>{const n=pe(t.target.error);this.V.reject(new ue(e,n))}}static open(e,t,n,r){try{return new se(t,e.transaction(r,n))}catch(e){throw new ue(t,e)}}get m(){return this.V.promise}abort(e){e&&this.V.reject(e),this.aborted||(p("SimpleDb","Aborting transaction:",e?e.message:"Client-initiated abort"),this.aborted=!0,this.transaction.abort())}g(){const e=this.transaction;this.aborted||"function"!=typeof e.commit||e.commit()}store(e){const t=this.transaction.objectStore(e);return new he(t)}}class oe{constructor(e,t,n){this.name=e,this.version=t,this.p=n,12.2===oe.S(o.getUA())&&m("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(e){return p("SimpleDb","Removing database:",e),de(window.indexedDB.deleteDatabase(e)).toPromise()}static D(){if(!o.isIndexedDBAvailable())return!1;if(oe.v())return!0;const e=o.getUA(),t=oe.S(e),n=0<t&&t<10,r=ae(e),i=0<r&&r<4.5;return!(e.indexOf("MSIE ")>0||e.indexOf("Trident/")>0||e.indexOf("Edge/")>0||n||i)}static v(){var e;return"undefined"!=typeof process&&"YES"===(null===(e=process.__PRIVATE_env)||void 0===e?void 0:e.C)}static F(e,t){return e.store(t)}static S(e){const t=e.match(/i(?:phone|pad|pod) os ([\d_]+)/i),n=t?t[1].split("_").slice(0,2).join("."):"-1";return Number(n)}async M(e){return this.db||(p("SimpleDb","Opening database:",this.name),this.db=await new Promise(((t,n)=>{const r=indexedDB.open(this.name,this.version);r.onsuccess=e=>{const n=e.target.result;t(n)},r.onblocked=()=>{n(new ue(e,"Cannot upgrade IndexedDB schema while another tab is open. Close all tabs that access Firestore and reload this page to proceed."))},r.onerror=t=>{const r=t.target.error;"VersionError"===r.name?n(new I(_.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 I(_.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 ue(e,r))},r.onupgradeneeded=e=>{p("SimpleDb",'Database "'+this.name+'" requires upgrade from version:',e.oldVersion);const t=e.target.result;this.p.O(t,r.transaction,e.oldVersion,this.version).next((()=>{p("SimpleDb","Database upgrade to version "+this.version+" complete")}))}}))),this.N&&(this.db.onversionchange=e=>this.N(e)),this.db}L(e){this.N=e,this.db&&(this.db.onversionchange=t=>e(t))}async runTransaction(e,t,n,r){const i="readonly"===t;let s=0;for(;;){++s;try{this.db=await this.M(e);const t=se.open(this.db,e,i?"readonly":"readwrite",n),s=r(t).next((e=>(t.g(),e))).catch((e=>(t.abort(e),ie.reject(e)))).toPromise();return s.catch((()=>{})),await t.m,s}catch(e){const t=e,n="FirebaseError"!==t.name&&s<3;if(p("SimpleDb","Transaction failed with error:",t.message,"Retrying:",n),this.close(),!n)return Promise.reject(t)}}}close(){this.db&&this.db.close(),this.db=void 0}}function ae(e){const t=e.match(/Android ([\d.]+)/i),n=t?t[1].split(".").slice(0,2).join("."):"-1";return Number(n)}class ce{constructor(e){this.B=e,this.k=!1,this.q=null}get isDone(){return this.k}get K(){return this.q}set cursor(e){this.B=e}done(){this.k=!0}$(e){this.q=e}delete(){return de(this.B.delete())}}class ue extends I{constructor(e,t){super(_.UNAVAILABLE,`IndexedDB transaction '${e}' failed: ${t}`),this.name="IndexedDbTransactionError"}}function le(e){return"IndexedDbTransactionError"===e.name}class he{constructor(e){this.store=e}put(e,t){let n;return void 0!==t?(p("SimpleDb","PUT",this.store.name,e,t),n=this.store.put(t,e)):(p("SimpleDb","PUT",this.store.name,"<auto-key>",e),n=this.store.put(e)),de(n)}add(e){return p("SimpleDb","ADD",this.store.name,e,e),de(this.store.add(e))}get(e){return de(this.store.get(e)).next((t=>(void 0===t&&(t=null),p("SimpleDb","GET",this.store.name,e,t),t)))}delete(e){return p("SimpleDb","DELETE",this.store.name,e),de(this.store.delete(e))}count(){return p("SimpleDb","COUNT",this.store.name),de(this.store.count())}U(e,t){const n=this.options(e,t),r=n.index?this.store.index(n.index):this.store;if("function"==typeof r.getAll){const e=r.getAll(n.range);return new ie(((t,n)=>{e.onerror=e=>{n(e.target.error)},e.onsuccess=e=>{t(e.target.result)}}))}{const e=this.cursor(n),t=[];return this.W(e,((e,n)=>{t.push(n)})).next((()=>t))}}G(e,t){const n=this.store.getAll(e,null===t?void 0:t);return new ie(((e,t)=>{n.onerror=e=>{t(e.target.error)},n.onsuccess=t=>{e(t.target.result)}}))}j(e,t){p("SimpleDb","DELETE ALL",this.store.name);const n=this.options(e,t);n.H=!1;const r=this.cursor(n);return this.W(r,((e,t,n)=>n.delete()))}J(e,t){let n;t?n=e:(n={},t=e);const r=this.cursor(n);return this.W(r,t)}Y(e){const t=this.cursor({});return new ie(((n,r)=>{t.onerror=e=>{const t=pe(e.target.error);r(t)},t.onsuccess=t=>{const r=t.target.result;r?e(r.primaryKey,r.value).next((e=>{e?r.continue():n()})):n()}}))}W(e,t){const n=[];return new ie(((r,i)=>{e.onerror=e=>{i(e.target.error)},e.onsuccess=e=>{const i=e.target.result;if(!i)return void r();const s=new ce(i),o=t(i.primaryKey,i.value,s);if(o instanceof ie){const e=o.catch((e=>(s.done(),ie.reject(e))));n.push(e)}s.isDone?r():null===s.K?i.continue():i.continue(s.K)}})).next((()=>ie.waitFor(n)))}options(e,t){let n;return void 0!==e&&("string"==typeof e?n=e:t=e),{index:n,range:t}}cursor(e){let t="next";if(e.reverse&&(t="prev"),e.index){const n=this.store.index(e.index);return e.H?n.openKeyCursor(e.range,t):n.openCursor(e.range,t)}return this.store.openCursor(e.range,t)}}function de(e){return new ie(((t,n)=>{e.onsuccess=e=>{const n=e.target.result;t(n)},e.onerror=e=>{const t=pe(e.target.error);n(t)}}))}let fe=!1;function pe(e){const t=oe.S(o.getUA());if(t>=12.2&&t<13){const t="An internal error was encountered in the Indexed Database server";if(e.message.indexOf(t)>=0){const e=new I("internal",`IOS_INDEXEDDB_BUG1: IndexedDb has thrown '${t}'. This is likely due to an unavoidable bug in iOS. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.`);return fe||(fe=!0,setTimeout((()=>{throw e}),0)),e}}return e}class me{constructor(e,t){this.asyncQueue=e,this.Z=t,this.task=null}start(){this.X(15e3)}stop(){this.task&&(this.task.cancel(),this.task=null)}get started(){return null!==this.task}X(e){p("IndexBackfiller",`Scheduled in ${e}ms`),this.task=this.asyncQueue.enqueueAfterDelay("index_backfill",e,(async()=>{this.task=null;try{p("IndexBackfiller",`Documents written: ${await this.Z.ee()}`)}catch(e){le(e)?p("IndexBackfiller","Ignoring IndexedDB error during index backfill: ",e):await re(e)}await this.X(6e4)}))}}class ge{constructor(e,t){this.localStore=e,this.persistence=t}async ee(e=50){return this.persistence.runTransaction("Backfill Indexes","readwrite-primary",(t=>this.te(t,e)))}te(e,t){const n=new Set;let r=t,i=!0;return ie.doWhile((()=>!0===i&&r>0),(()=>this.localStore.indexManager.getNextCollectionGroupToUpdate(e).next((t=>{if(null!==t&&!n.has(t))return p("IndexBackfiller",`Processing collection: ${t}`),this.ne(e,t,r).next((e=>{r-=e,n.add(t)}));i=!1})))).next((()=>t-r))}ne(e,t,n){return this.localStore.indexManager.getMinOffsetFromCollectionGroup(e,t).next((r=>this.localStore.localDocuments.getNextDocuments(e,t,r,n).next((n=>{const i=n.changes;return this.localStore.indexManager.updateIndexEntries(e,i).next((()=>this.re(r,n))).next((n=>(p("IndexBackfiller",`Updating offset: ${n}`),this.localStore.indexManager.updateCollectionGroup(e,t,n)))).next((()=>i.size))}))))}re(e,t){let n=e;return t.changes.forEach(((e,t)=>{const r=X(t);ee(r,n)>0&&(n=r)})),new Z(n.readTime,n.documentKey,Math.max(t.batchId,e.largestBatchId))}}class ye{constructor(e,t){this.previousValue=e,t&&(t.sequenceNumberHandler=e=>this.ie(e),this.se=e=>t.writeSequenceNumber(e))}ie(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}next(){const e=++this.previousValue;return this.se&&this.se(e),e}}function ve(e){return null==e}function be(e){return 0===e&&1/e==-1/0}function we(e){return"number"==typeof e&&Number.isInteger(e)&&!be(e)&&e<=Number.MAX_SAFE_INTEGER&&e>=Number.MIN_SAFE_INTEGER}function _e(e){let t="";for(let n=0;n<e.length;n++)t.length>0&&(t=Ee(t)),t=Ie(e.get(n),t);return Ee(t)}function Ie(e,t){let n=t;const r=e.length;for(let t=0;t<r;t++){const r=e.charAt(t);switch(r){case"\0":n+="";break;case"":n+="";break;default:n+=r}}return n}function Ee(e){return e+""}function Te(e){const t=e.length;if(b(t>=2),2===t)return b(""===e.charAt(0)&&""===e.charAt(1)),j.emptyPath();const n=t-2,r=[];let i="";for(let s=0;s<t;){const t=e.indexOf("",s);switch((t<0||t>n)&&v(),e.charAt(t+1)){case"":const n=e.substring(s,t);let o;0===i.length?o=n:(i+=n,o=i,i=""),r.push(o);break;case"":i+=e.substring(s,t),i+="\0";break;case"":i+=e.substring(s,t+1);break;default:v()}s=t+2}return new j(r)}ye.oe=-1;const Se=["userId","batchId"];function Ce(e,t){return[e,_e(t)]}function Ae(e,t,n){return[e,_e(t),n]}const xe={},ke=["prefixPath","collectionGroup","readTime","documentId"],Ne=["prefixPath","collectionGroup","documentId"],Oe=["collectionGroup","readTime","prefixPath","documentId"],De=["canonicalId","targetId"],Re=["targetId","path"],Pe=["path","targetId"],Le=["collectionId","parent"],Me=["indexId","uid"],Fe=["uid","sequenceNumber"],Ve=["indexId","uid","arrayValue","directionalValue","orderedDocumentKey","documentKey"],Ue=["indexId","uid","orderedDocumentKey"],je=["userId","collectionPath","documentId"],Be=["userId","collectionPath","largestBatchId"],qe=["userId","collectionGroup","largestBatchId"],ze=["mutationQueues","mutations","documentMutations","remoteDocuments","targets","owner","targetGlobal","targetDocuments","clientMetadata","remoteDocumentGlobal","collectionParents","bundles","namedQueries"],Ge=[...ze,"documentOverlays"],Ke=["mutationQueues","mutations","documentMutations","remoteDocumentsV14","targets","owner","targetGlobal","targetDocuments","clientMetadata","remoteDocumentGlobal","collectionParents","bundles","namedQueries","documentOverlays"],We=Ke,$e=[...We,"indexConfiguration","indexState","indexEntries"],He=$e,Qe=[...$e,"globals"];class Je extends ne{constructor(e,t){super(),this._e=e,this.currentSequenceNumber=t}}function Ye(e,t){const n=w(e);return oe.F(n._e,t)}function Xe(e){let t=0;for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}function Ze(e,t){for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t(n,e[n])}function et(e,t){const n=[];for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.push(t(e[r],r,e));return n}function tt(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}class nt{constructor(e,t){this.comparator=e,this.root=t||it.EMPTY}insert(e,t){return new nt(this.comparator,this.root.insert(e,t,this.comparator).copy(null,null,it.BLACK,null,null))}remove(e){return new nt(this.comparator,this.root.remove(e,this.comparator).copy(null,null,it.BLACK,null,null))}get(e){let t=this.root;for(;!t.isEmpty();){const n=this.comparator(e,t.key);if(0===n)return t.value;n<0?t=t.left:n>0&&(t=t.right)}return null}indexOf(e){let t=0,n=this.root;for(;!n.isEmpty();){const r=this.comparator(e,n.key);if(0===r)return t+n.left.size;r<0?n=n.left:(t+=n.left.size+1,n=n.right)}return-1}isEmpty(){return this.root.isEmpty()}get size(){return this.root.size}minKey(){return this.root.minKey()}maxKey(){return this.root.maxKey()}inorderTraversal(e){return this.root.inorderTraversal(e)}forEach(e){this.inorderTraversal(((t,n)=>(e(t,n),!1)))}toString(){const e=[];return this.inorderTraversal(((t,n)=>(e.push(`${t}:${n}`),!1))),`{${e.join(", ")}}`}reverseTraversal(e){return this.root.reverseTraversal(e)}getIterator(){return new rt(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new rt(this.root,e,this.comparator,!1)}getReverseIterator(){return new rt(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new rt(this.root,e,this.comparator,!0)}}class rt{constructor(e,t,n,r){this.isReverse=r,this.nodeStack=[];let i=1;for(;!e.isEmpty();)if(i=t?n(e.key,t):1,t&&r&&(i*=-1),i<0)e=this.isReverse?e.left:e.right;else{if(0===i){this.nodeStack.push(e);break}this.nodeStack.push(e),e=this.isReverse?e.right:e.left}}getNext(){let e=this.nodeStack.pop();const t={key:e.key,value:e.value};if(this.isReverse)for(e=e.left;!e.isEmpty();)this.nodeStack.push(e),e=e.right;else for(e=e.right;!e.isEmpty();)this.nodeStack.push(e),e=e.left;return t}hasNext(){return this.nodeStack.length>0}peek(){if(0===this.nodeStack.length)return null;const e=this.nodeStack[this.nodeStack.length-1];return{key:e.key,value:e.value}}}class it{constructor(e,t,n,r,i){this.key=e,this.value=t,this.color=null!=n?n:it.RED,this.left=null!=r?r:it.EMPTY,this.right=null!=i?i:it.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,t,n,r,i){return new it(null!=e?e:this.key,null!=t?t:this.value,null!=n?n:this.color,null!=r?r:this.left,null!=i?i:this.right)}isEmpty(){return!1}inorderTraversal(e){return this.left.inorderTraversal(e)||e(this.key,this.value)||this.right.inorderTraversal(e)}reverseTraversal(e){return this.right.reverseTraversal(e)||e(this.key,this.value)||this.left.reverseTraversal(e)}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(e,t,n){let r=this;const i=n(e,r.key);return r=i<0?r.copy(null,null,null,r.left.insert(e,t,n),null):0===i?r.copy(null,t,null,null,null):r.copy(null,null,null,null,r.right.insert(e,t,n)),r.fixUp()}removeMin(){if(this.left.isEmpty())return it.EMPTY;let e=this;return e.left.isRed()||e.left.left.isRed()||(e=e.moveRedLeft()),e=e.copy(null,null,null,e.left.removeMin(),null),e.fixUp()}remove(e,t){let n,r=this;if(t(e,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(e,t),null);else{if(r.left.isRed()&&(r=r.rotateRight()),r.right.isEmpty()||r.right.isRed()||r.right.left.isRed()||(r=r.moveRedRight()),0===t(e,r.key)){if(r.right.isEmpty())return it.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(e,t))}return r.fixUp()}isRed(){return this.color}fixUp(){let e=this;return e.right.isRed()&&!e.left.isRed()&&(e=e.rotateLeft()),e.left.isRed()&&e.left.left.isRed()&&(e=e.rotateRight()),e.left.isRed()&&e.right.isRed()&&(e=e.colorFlip()),e}moveRedLeft(){let e=this.colorFlip();return e.right.left.isRed()&&(e=e.copy(null,null,null,null,e.right.rotateRight()),e=e.rotateLeft(),e=e.colorFlip()),e}moveRedRight(){let e=this.colorFlip();return e.left.left.isRed()&&(e=e.rotateRight(),e=e.colorFlip()),e}rotateLeft(){const e=this.copy(null,null,it.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){const e=this.copy(null,null,it.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip(){const e=this.left.copy(null,null,!this.left.color,null,null),t=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,t)}checkMaxDepth(){const e=this.check();return Math.pow(2,e)<=this.size+1}check(){if(this.isRed()&&this.left.isRed())throw v();if(this.right.isRed())throw v();const e=this.left.check();if(e!==this.right.check())throw v();return e+(this.isRed()?0:1)}}it.EMPTY=null,it.RED=!0,it.BLACK=!1,it.EMPTY=new class{constructor(){this.size=0}get key(){throw v()}get value(){throw v()}get color(){throw v()}get left(){throw v()}get right(){throw v()}copy(e,t,n,r,i){return this}insert(e,t,n){return new it(e,t)}remove(e,t){return this}isEmpty(){return!0}inorderTraversal(e){return!1}reverseTraversal(e){return!1}minKey(){return null}maxKey(){return null}isRed(){return!1}checkMaxDepth(){return!0}check(){return 0}};class st{constructor(e){this.comparator=e,this.data=new nt(this.comparator)}has(e){return null!==this.data.get(e)}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(e){return this.data.indexOf(e)}forEach(e){this.data.inorderTraversal(((t,n)=>(e(t),!1)))}forEachInRange(e,t){const n=this.data.getIteratorFrom(e[0]);for(;n.hasNext();){const r=n.getNext();if(this.comparator(r.key,e[1])>=0)return;t(r.key)}}forEachWhile(e,t){let n;for(n=void 0!==t?this.data.getIteratorFrom(t):this.data.getIterator();n.hasNext();)if(!e(n.getNext().key))return}firstAfterOrEqual(e){const t=this.data.getIteratorFrom(e);return t.hasNext()?t.getNext().key:null}getIterator(){return new ot(this.data.getIterator())}getIteratorFrom(e){return new ot(this.data.getIteratorFrom(e))}add(e){return this.copy(this.data.remove(e).insert(e,!0))}delete(e){return this.has(e)?this.copy(this.data.remove(e)):this}isEmpty(){return this.data.isEmpty()}unionWith(e){let t=this;return t.size<e.size&&(t=e,e=this),e.forEach((e=>{t=t.add(e)})),t}isEqual(e){if(!(e instanceof st))return!1;if(this.size!==e.size)return!1;const t=this.data.getIterator(),n=e.data.getIterator();for(;t.hasNext();){const e=t.getNext().key,r=n.getNext().key;if(0!==this.comparator(e,r))return!1}return!0}toArray(){const e=[];return this.forEach((t=>{e.push(t)})),e}toString(){const e=[];return this.forEach((t=>e.push(t))),"SortedSet("+e.toString()+")"}copy(e){const t=new st(this.comparator);return t.data=e,t}}class ot{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}function at(e){return e.hasNext()?e.getNext():void 0}class ct{constructor(e){this.fields=e,e.sort(q.comparator)}static empty(){return new ct([])}unionWith(e){let t=new st(q.comparator);for(const e of this.fields)t=t.add(e);for(const n of e)t=t.add(n);return new ct(t.toArray())}covers(e){for(const t of this.fields)if(t.isPrefixOf(e))return!0;return!1}isEqual(e){return L(this.fields,e.fields,((e,t)=>e.isEqual(t)))}}class ut extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}class lt{constructor(e){this.binaryString=e}static fromBase64String(e){const t=function(e){try{return atob(e)}catch(e){throw"undefined"!=typeof DOMException&&e instanceof DOMException?new ut("Invalid base64 string: "+e):e}}(e);return new lt(t)}static fromUint8Array(e){const t=function(e){let t="";for(let n=0;n<e.length;++n)t+=String.fromCharCode(e[n]);return t}(e);return new lt(t)}[Symbol.iterator](){let e=0;return{next:()=>e<this.binaryString.length?{value:this.binaryString.charCodeAt(e++),done:!1}:{value:void 0,done:!0}}}toBase64(){return e=this.binaryString,btoa(e);var e}toUint8Array(){return function(e){const t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(e){return P(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}}lt.EMPTY_BYTE_STRING=new lt("");const ht=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function dt(e){if(b(!!e),"string"==typeof e){let t=0;const n=ht.exec(e);if(b(!!n),n[1]){let e=n[1];e=(e+"000000000").substr(0,9),t=Number(e)}const r=new Date(e);return{seconds:Math.floor(r.getTime()/1e3),nanos:t}}return{seconds:ft(e.seconds),nanos:ft(e.nanos)}}function ft(e){return"number"==typeof e?e:"string"==typeof e?Number(e):0}function pt(e){return"string"==typeof e?lt.fromBase64String(e):lt.fromUint8Array(e)}function mt(e){var t,n;return"server_timestamp"===(null===(n=((null===(t=null==e?void 0:e.mapValue)||void 0===t?void 0:t.fields)||{}).__type__)||void 0===n?void 0:n.stringValue)}function gt(e){const t=e.mapValue.fields.__previous_value__;return mt(t)?gt(t):t}function yt(e){const t=dt(e.mapValue.fields.__local_write_time__.timestampValue);return new F(t.seconds,t.nanos)}class vt{constructor(e,t,n,r,i,s,o,a,c){this.databaseId=e,this.appId=t,this.persistenceKey=n,this.host=r,this.ssl=i,this.forceLongPolling=s,this.autoDetectLongPolling=o,this.longPollingOptions=a,this.useFetchStreams=c}}class bt{constructor(e,t){this.projectId=e,this.database=t||"(default)"}static empty(){return new bt("","")}get isDefaultDatabase(){return"(default)"===this.database}isEqual(e){return e instanceof bt&&e.projectId===this.projectId&&e.database===this.database}}const wt={mapValue:{fields:{__type__:{stringValue:"__max__"}}}},_t={nullValue:"NULL_VALUE"};function It(e){return"nullValue"in e?0:"booleanValue"in e?1:"integerValue"in e||"doubleValue"in e?2:"timestampValue"in e?3:"stringValue"in e?5:"bytesValue"in e?6:"referenceValue"in e?7:"geoPointValue"in e?8:"arrayValue"in e?9:"mapValue"in e?mt(e)?4:Ut(e)?9007199254740991:Ft(e)?10:11:v()}function Et(e,t){if(e===t)return!0;const n=It(e);if(n!==It(t))return!1;switch(n){case 0:case 9007199254740991:return!0;case 1:return e.booleanValue===t.booleanValue;case 4:return yt(e).isEqual(yt(t));case 3:return function(e,t){if("string"==typeof e.timestampValue&&"string"==typeof t.timestampValue&&e.timestampValue.length===t.timestampValue.length)return e.timestampValue===t.timestampValue;const n=dt(e.timestampValue),r=dt(t.timestampValue);return n.seconds===r.seconds&&n.nanos===r.nanos}(e,t);case 5:return e.stringValue===t.stringValue;case 6:return function(e,t){return pt(e.bytesValue).isEqual(pt(t.bytesValue))}(e,t);case 7:return e.referenceValue===t.referenceValue;case 8:return function(e,t){return ft(e.geoPointValue.latitude)===ft(t.geoPointValue.latitude)&&ft(e.geoPointValue.longitude)===ft(t.geoPointValue.longitude)}(e,t);case 2:return function(e,t){if("integerValue"in e&&"integerValue"in t)return ft(e.integerValue)===ft(t.integerValue);if("doubleValue"in e&&"doubleValue"in t){const n=ft(e.doubleValue),r=ft(t.doubleValue);return n===r?be(n)===be(r):isNaN(n)&&isNaN(r)}return!1}(e,t);case 9:return L(e.arrayValue.values||[],t.arrayValue.values||[],Et);case 10:case 11:return function(e,t){const n=e.mapValue.fields||{},r=t.mapValue.fields||{};if(Xe(n)!==Xe(r))return!1;for(const e in n)if(n.hasOwnProperty(e)&&(void 0===r[e]||!Et(n[e],r[e])))return!1;return!0}(e,t);default:return v()}}function Tt(e,t){return void 0!==(e.values||[]).find((e=>Et(e,t)))}function St(e,t){if(e===t)return 0;const n=It(e),r=It(t);if(n!==r)return P(n,r);switch(n){case 0:case 9007199254740991:return 0;case 1:return P(e.booleanValue,t.booleanValue);case 2:return function(e,t){const n=ft(e.integerValue||e.doubleValue),r=ft(t.integerValue||t.doubleValue);return n<r?-1:n>r?1:n===r?0:isNaN(n)?isNaN(r)?0:-1:1}(e,t);case 3:return Ct(e.timestampValue,t.timestampValue);case 4:return Ct(yt(e),yt(t));case 5:return P(e.stringValue,t.stringValue);case 6:return function(e,t){const n=pt(e),r=pt(t);return n.compareTo(r)}(e.bytesValue,t.bytesValue);case 7:return function(e,t){const n=e.split("/"),r=t.split("/");for(let e=0;e<n.length&&e<r.length;e++){const t=P(n[e],r[e]);if(0!==t)return t}return P(n.length,r.length)}(e.referenceValue,t.referenceValue);case 8:return function(e,t){const n=P(ft(e.latitude),ft(t.latitude));return 0!==n?n:P(ft(e.longitude),ft(t.longitude))}(e.geoPointValue,t.geoPointValue);case 9:return At(e.arrayValue,t.arrayValue);case 10:return function(e,t){var n,r,i,s;const o=e.fields||{},a=t.fields||{},c=null===(n=o.value)||void 0===n?void 0:n.arrayValue,u=null===(r=a.value)||void 0===r?void 0:r.arrayValue,l=P((null===(i=null==c?void 0:c.values)||void 0===i?void 0:i.length)||0,(null===(s=null==u?void 0:u.values)||void 0===s?void 0:s.length)||0);return 0!==l?l:At(c,u)}(e.mapValue,t.mapValue);case 11:return function(e,t){if(e===wt.mapValue&&t===wt.mapValue)return 0;if(e===wt.mapValue)return 1;if(t===wt.mapValue)return-1;const n=e.fields||{},r=Object.keys(n),i=t.fields||{},s=Object.keys(i);r.sort(),s.sort();for(let e=0;e<r.length&&e<s.length;++e){const t=P(r[e],s[e]);if(0!==t)return t;const o=St(n[r[e]],i[s[e]]);if(0!==o)return o}return P(r.length,s.length)}(e.mapValue,t.mapValue);default:throw v()}}function Ct(e,t){if("string"==typeof e&&"string"==typeof t&&e.length===t.length)return P(e,t);const n=dt(e),r=dt(t),i=P(n.seconds,r.seconds);return 0!==i?i:P(n.nanos,r.nanos)}function At(e,t){const n=e.values||[],r=t.values||[];for(let e=0;e<n.length&&e<r.length;++e){const t=St(n[e],r[e]);if(t)return t}return P(n.length,r.length)}function xt(e){return kt(e)}function kt(e){return"nullValue"in e?"null":"booleanValue"in e?""+e.booleanValue:"integerValue"in e?""+e.integerValue:"doubleValue"in e?""+e.doubleValue:"timestampValue"in e?function(e){const t=dt(e);return`time(${t.seconds},${t.nanos})`}(e.timestampValue):"stringValue"in e?e.stringValue:"bytesValue"in e?function(e){return pt(e).toBase64()}(e.bytesValue):"referenceValue"in e?function(e){return z.fromName(e).toString()}(e.referenceValue):"geoPointValue"in e?function(e){return`geo(${e.latitude},${e.longitude})`}(e.geoPointValue):"arrayValue"in e?function(e){let t="[",n=!0;for(const r of e.values||[])n?n=!1:t+=",",t+=kt(r);return t+"]"}(e.arrayValue):"mapValue"in e?function(e){const t=Object.keys(e.fields||{}).sort();let n="{",r=!0;for(const i of t)r?r=!1:n+=",",n+=`${i}:${kt(e.fields[i])}`;return n+"}"}(e.mapValue):v()}function Nt(e){switch(It(e)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:const t=gt(e);return t?16+Nt(t):16;case 5:return 2*e.stringValue.length;case 6:return pt(e.bytesValue).approximateByteSize();case 7:return e.referenceValue.length;case 9:return function(e){return(e.values||[]).reduce(((e,t)=>e+Nt(t)),0)}(e.arrayValue);case 10:case 11:return function(e){let t=0;return Ze(e.fields,((e,n)=>{t+=e.length+Nt(n)})),t}(e.mapValue);default:throw v()}}function Ot(e,t){return{referenceValue:`projects/${e.projectId}/databases/${e.database}/documents/${t.path.canonicalString()}`}}function Dt(e){return!!e&&"integerValue"in e}function Rt(e){return!!e&&"arrayValue"in e}function Pt(e){return!!e&&"nullValue"in e}function Lt(e){return!!e&&"doubleValue"in e&&isNaN(Number(e.doubleValue))}function Mt(e){return!!e&&"mapValue"in e}function Ft(e){var t,n;return"__vector__"===(null===(n=((null===(t=null==e?void 0:e.mapValue)||void 0===t?void 0:t.fields)||{}).__type__)||void 0===n?void 0:n.stringValue)}function Vt(e){if(e.geoPointValue)return{geoPointValue:Object.assign({},e.geoPointValue)};if(e.timestampValue&&"object"==typeof e.timestampValue)return{timestampValue:Object.assign({},e.timestampValue)};if(e.mapValue){const t={mapValue:{fields:{}}};return Ze(e.mapValue.fields,((e,n)=>t.mapValue.fields[e]=Vt(n))),t}if(e.arrayValue){const t={arrayValue:{values:[]}};for(let n=0;n<(e.arrayValue.values||[]).length;++n)t.arrayValue.values[n]=Vt(e.arrayValue.values[n]);return t}return Object.assign({},e)}function Ut(e){return"__max__"===(((e.mapValue||{}).fields||{}).__type__||{}).stringValue}const jt={mapValue:{fields:{__type__:{stringValue:"__vector__"},value:{arrayValue:{}}}}};function Bt(e){return"nullValue"in e?_t:"booleanValue"in e?{booleanValue:!1}:"integerValue"in e||"doubleValue"in e?{doubleValue:NaN}:"timestampValue"in e?{timestampValue:{seconds:Number.MIN_SAFE_INTEGER}}:"stringValue"in e?{stringValue:""}:"bytesValue"in e?{bytesValue:""}:"referenceValue"in e?Ot(bt.empty(),z.empty()):"geoPointValue"in e?{geoPointValue:{latitude:-90,longitude:-180}}:"arrayValue"in e?{arrayValue:{}}:"mapValue"in e?Ft(e)?jt:{mapValue:{}}:v()}function qt(e){return"nullValue"in e?{booleanValue:!1}:"booleanValue"in e?{doubleValue:NaN}:"integerValue"in e||"doubleValue"in e?{timestampValue:{seconds:Number.MIN_SAFE_INTEGER}}:"timestampValue"in e?{stringValue:""}:"stringValue"in e?{bytesValue:""}:"bytesValue"in e?Ot(bt.empty(),z.empty()):"referenceValue"in e?{geoPointValue:{latitude:-90,longitude:-180}}:"geoPointValue"in e?{arrayValue:{}}:"arrayValue"in e?jt:"mapValue"in e?Ft(e)?{mapValue:{}}:wt:v()}function zt(e,t){const n=St(e.value,t.value);return 0!==n?n:e.inclusive&&!t.inclusive?-1:!e.inclusive&&t.inclusive?1:0}function Gt(e,t){const n=St(e.value,t.value);return 0!==n?n:e.inclusive&&!t.inclusive?1:!e.inclusive&&t.inclusive?-1:0}class Kt{constructor(e){this.value=e}static empty(){return new Kt({mapValue:{}})}field(e){if(e.isEmpty())return this.value;{let t=this.value;for(let n=0;n<e.length-1;++n)if(t=(t.mapValue.fields||{})[e.get(n)],!Mt(t))return null;return t=(t.mapValue.fields||{})[e.lastSegment()],t||null}}set(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=Vt(t)}setAll(e){let t=q.emptyPath(),n={},r=[];e.forEach(((e,i)=>{if(!t.isImmediateParentOf(i)){const e=this.getFieldsMap(t);this.applyChanges(e,n,r),n={},r=[],t=i.popLast()}e?n[i.lastSegment()]=Vt(e):r.push(i.lastSegment())}));const i=this.getFieldsMap(t);this.applyChanges(i,n,r)}delete(e){const t=this.field(e.popLast());Mt(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return Et(this.value,e.value)}getFieldsMap(e){let t=this.value;t.mapValue.fields||(t.mapValue={fields:{}});for(let n=0;n<e.length;++n){let r=t.mapValue.fields[e.get(n)];Mt(r)&&r.mapValue.fields||(r={mapValue:{fields:{}}},t.mapValue.fields[e.get(n)]=r),t=r}return t.mapValue.fields}applyChanges(e,t,n){Ze(t,((t,n)=>e[t]=n));for(const t of n)delete e[t]}clone(){return new Kt(Vt(this.value))}}function Wt(e){const t=[];return Ze(e.fields,((e,n)=>{const r=new q([e]);if(Mt(n)){const e=Wt(n.mapValue).fields;if(0===e.length)t.push(r);else for(const n of e)t.push(r.child(n))}else t.push(r)})),new ct(t)}class $t{constructor(e,t,n,r,i,s,o){this.key=e,this.documentType=t,this.version=n,this.readTime=r,this.createTime=i,this.data=s,this.documentState=o}static newInvalidDocument(e){return new $t(e,0,V.min(),V.min(),V.min(),Kt.empty(),0)}static newFoundDocument(e,t,n,r){return new $t(e,1,t,V.min(),n,r,0)}static newNoDocument(e,t){return new $t(e,2,t,V.min(),V.min(),Kt.empty(),0)}static newUnknownDocument(e,t){return new $t(e,3,t,V.min(),V.min(),Kt.empty(),2)}convertToFoundDocument(e,t){return!this.createTime.isEqual(V.min())||2!==this.documentType&&0!==this.documentType||(this.createTime=e),this.version=e,this.documentType=1,this.data=t,this.documentState=0,this}convertToNoDocument(e){return this.version=e,this.documentType=2,this.data=Kt.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=Kt.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=V.min(),this}setReadTime(e){return this.readTime=e,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(e){return e instanceof $t&&this.key.isEqual(e.key)&&this.version.isEqual(e.version)&&this.documentType===e.documentType&&this.documentState===e.documentState&&this.data.isEqual(e.data)}mutableCopy(){return new $t(this.key,this.documentType,this.version,this.readTime,this.createTime,this.data.clone(),this.documentState)}toString(){return`Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {createTime: ${this.createTime}}), {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`}}class Ht{constructor(e,t){this.position=e,this.inclusive=t}}function Qt(e,t,n){let r=0;for(let i=0;i<e.position.length;i++){const s=t[i],o=e.position[i];if(r=s.field.isKeyField()?z.comparator(z.fromName(o.referenceValue),n.key):St(o,n.data.field(s.field)),"desc"===s.dir&&(r*=-1),0!==r)break}return r}function Jt(e,t){if(null===e)return null===t;if(null===t)return!1;if(e.inclusive!==t.inclusive||e.position.length!==t.position.length)return!1;for(let n=0;n<e.position.length;n++)if(!Et(e.position[n],t.position[n]))return!1;return!0}class Yt{constructor(e,t="asc"){this.field=e,this.dir=t}}function Xt(e,t){return e.dir===t.dir&&e.field.isEqual(t.field)}class Zt{}class en extends Zt{constructor(e,t,n){super(),this.field=e,this.op=t,this.value=n}static create(e,t,n){return e.isKeyField()?"in"===t||"not-in"===t?this.createKeyFieldInFilter(e,t,n):new hn(e,t,n):"array-contains"===t?new mn(e,n):"in"===t?new gn(e,n):"not-in"===t?new yn(e,n):"array-contains-any"===t?new vn(e,n):new en(e,t,n)}static createKeyFieldInFilter(e,t,n){return"in"===t?new dn(e,n):new fn(e,n)}matches(e){const t=e.data.field(this.field);return"!="===this.op?null!==t&&this.matchesComparison(St(t,this.value)):null!==t&&It(this.value)===It(t)&&this.matchesComparison(St(t,this.value))}matchesComparison(e){switch(this.op){case"<":return e<0;case"<=":return e<=0;case"==":return 0===e;case"!=":return 0!==e;case">":return e>0;case">=":return e>=0;default:return v()}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class tn extends Zt{constructor(e,t){super(),this.filters=e,this.op=t,this.ae=null}static create(e,t){return new tn(e,t)}matches(e){return nn(this)?void 0===this.filters.find((t=>!t.matches(e))):void 0!==this.filters.find((t=>t.matches(e)))}getFlattenedFilters(){return null!==this.ae||(this.ae=this.filters.reduce(((e,t)=>e.concat(t.getFlattenedFilters())),[])),this.ae}getFilters(){return Object.assign([],this.filters)}}function nn(e){return"and"===e.op}function rn(e){return"or"===e.op}function sn(e){return on(e)&&nn(e)}function on(e){for(const t of e.filters)if(t instanceof tn)return!1;return!0}function an(e){if(e instanceof en)return e.field.canonicalString()+e.op.toString()+xt(e.value);if(sn(e))return e.filters.map((e=>an(e))).join(",");{const t=e.filters.map((e=>an(e))).join(",");return`${e.op}(${t})`}}function cn(e,t){return e instanceof en?function(e,t){return t instanceof en&&e.op===t.op&&e.field.isEqual(t.field)&&Et(e.value,t.value)}(e,t):e instanceof tn?function(e,t){return t instanceof tn&&e.op===t.op&&e.filters.length===t.filters.length&&e.filters.reduce(((e,n,r)=>e&&cn(n,t.filters[r])),!0)}(e,t):void v()}function un(e,t){const n=e.filters.concat(t);return tn.create(n,e.op)}function ln(e){return e instanceof en?function(e){return`${e.field.canonicalString()} ${e.op} ${xt(e.value)}`}(e):e instanceof tn?function(e){return e.op.toString()+" {"+e.getFilters().map(ln).join(" ,")+"}"}(e):"Filter"}class hn extends en{constructor(e,t,n){super(e,t,n),this.key=z.fromName(n.referenceValue)}matches(e){const t=z.comparator(e.key,this.key);return this.matchesComparison(t)}}class dn extends en{constructor(e,t){super(e,"in",t),this.keys=pn(0,t)}matches(e){return this.keys.some((t=>t.isEqual(e.key)))}}class fn extends en{constructor(e,t){super(e,"not-in",t),this.keys=pn(0,t)}matches(e){return!this.keys.some((t=>t.isEqual(e.key)))}}function pn(e,t){var n;return((null===(n=t.arrayValue)||void 0===n?void 0:n.values)||[]).map((e=>z.fromName(e.referenceValue)))}class mn extends en{constructor(e,t){super(e,"array-contains",t)}matches(e){const t=e.data.field(this.field);return Rt(t)&&Tt(t.arrayValue,this.value)}}class gn extends en{constructor(e,t){super(e,"in",t)}matches(e){const t=e.data.field(this.field);return null!==t&&Tt(this.value.arrayValue,t)}}class yn extends en{constructor(e,t){super(e,"not-in",t)}matches(e){if(Tt(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const t=e.data.field(this.field);return null!==t&&!Tt(this.value.arrayValue,t)}}class vn extends en{constructor(e,t){super(e,"array-contains-any",t)}matches(e){const t=e.data.field(this.field);return!(!Rt(t)||!t.arrayValue.values)&&t.arrayValue.values.some((e=>Tt(this.value.arrayValue,e)))}}class bn{constructor(e,t=null,n=[],r=[],i=null,s=null,o=null){this.path=e,this.collectionGroup=t,this.orderBy=n,this.filters=r,this.limit=i,this.startAt=s,this.endAt=o,this.ue=null}}function wn(e,t=null,n=[],r=[],i=null,s=null,o=null){return new bn(e,t,n,r,i,s,o)}function _n(e){const t=w(e);if(null===t.ue){let e=t.path.canonicalString();null!==t.collectionGroup&&(e+="|cg:"+t.collectionGroup),e+="|f:",e+=t.filters.map((e=>an(e))).join(","),e+="|ob:",e+=t.orderBy.map((e=>function(e){return e.field.canonicalString()+e.dir}(e))).join(","),ve(t.limit)||(e+="|l:",e+=t.limit),t.startAt&&(e+="|lb:",e+=t.startAt.inclusive?"b:":"a:",e+=t.startAt.position.map((e=>xt(e))).join(",")),t.endAt&&(e+="|ub:",e+=t.endAt.inclusive?"a:":"b:",e+=t.endAt.position.map((e=>xt(e))).join(",")),t.ue=e}return t.ue}function In(e,t){if(e.limit!==t.limit)return!1;if(e.orderBy.length!==t.orderBy.length)return!1;for(let n=0;n<e.orderBy.length;n++)if(!Xt(e.orderBy[n],t.orderBy[n]))return!1;if(e.filters.length!==t.filters.length)return!1;for(let n=0;n<e.filters.length;n++)if(!cn(e.filters[n],t.filters[n]))return!1;return e.collectionGroup===t.collectionGroup&&!!e.path.isEqual(t.path)&&!!Jt(e.startAt,t.startAt)&&Jt(e.endAt,t.endAt)}function En(e){return z.isDocumentKey(e.path)&&null===e.collectionGroup&&0===e.filters.length}function Tn(e,t){return e.filters.filter((e=>e instanceof en&&e.field.isEqual(t)))}function Sn(e,t,n){let r=_t,i=!0;for(const n of Tn(e,t)){let e=_t,t=!0;switch(n.op){case"<":case"<=":e=Bt(n.value);break;case"==":case"in":case">=":e=n.value;break;case">":e=n.value,t=!1;break;case"!=":case"not-in":e=_t}zt({value:r,inclusive:i},{value:e,inclusive:t})<0&&(r=e,i=t)}if(null!==n)for(let s=0;s<e.orderBy.length;++s)if(e.orderBy[s].field.isEqual(t)){const e=n.position[s];zt({value:r,inclusive:i},{value:e,inclusive:n.inclusive})<0&&(r=e,i=n.inclusive);break}return{value:r,inclusive:i}}function Cn(e,t,n){let r=wt,i=!0;for(const n of Tn(e,t)){let e=wt,t=!0;switch(n.op){case">=":case">":e=qt(n.value),t=!1;break;case"==":case"in":case"<=":e=n.value;break;case"<":e=n.value,t=!1;break;case"!=":case"not-in":e=wt}Gt({value:r,inclusive:i},{value:e,inclusive:t})>0&&(r=e,i=t)}if(null!==n)for(let s=0;s<e.orderBy.length;++s)if(e.orderBy[s].field.isEqual(t)){const e=n.position[s];Gt({value:r,inclusive:i},{value:e,inclusive:n.inclusive})>0&&(r=e,i=n.inclusive);break}return{value:r,inclusive:i}}class An{constructor(e,t=null,n=[],r=[],i=null,s="F",o=null,a=null){this.path=e,this.collectionGroup=t,this.explicitOrderBy=n,this.filters=r,this.limit=i,this.limitType=s,this.startAt=o,this.endAt=a,this.ce=null,this.le=null,this.he=null,this.startAt,this.endAt}}function xn(e,t,n,r,i,s,o,a){return new An(e,t,n,r,i,s,o,a)}function kn(e){return new An(e)}function Nn(e){return 0===e.filters.length&&null===e.limit&&null==e.startAt&&null==e.endAt&&(0===e.explicitOrderBy.length||1===e.explicitOrderBy.length&&e.explicitOrderBy[0].field.isKeyField())}function On(e){return null!==e.collectionGroup}function Dn(e){const t=w(e);if(null===t.ce){t.ce=[];const e=new Set;for(const n of t.explicitOrderBy)t.ce.push(n),e.add(n.field.canonicalString());const n=t.explicitOrderBy.length>0?t.explicitOrderBy[t.explicitOrderBy.length-1].dir:"asc",r=function(e){let t=new st(q.comparator);return e.filters.forEach((e=>{e.getFlattenedFilters().forEach((e=>{e.isInequality()&&(t=t.add(e.field))}))})),t}(t);r.forEach((r=>{e.has(r.canonicalString())||r.isKeyField()||t.ce.push(new Yt(r,n))})),e.has(q.keyField().canonicalString())||t.ce.push(new Yt(q.keyField(),n))}return t.ce}function Rn(e){const t=w(e);return t.le||(t.le=Ln(t,Dn(e))),t.le}function Pn(e){const t=w(e);return t.he||(t.he=Ln(t,e.explicitOrderBy)),t.he}function Ln(e,t){if("F"===e.limitType)return wn(e.path,e.collectionGroup,t,e.filters,e.limit,e.startAt,e.endAt);{t=t.map((e=>{const t="desc"===e.dir?"asc":"desc";return new Yt(e.field,t)}));const n=e.endAt?new Ht(e.endAt.position,e.endAt.inclusive):null,r=e.startAt?new Ht(e.startAt.position,e.startAt.inclusive):null;return wn(e.path,e.collectionGroup,t,e.filters,e.limit,n,r)}}function Mn(e,t){const n=e.filters.concat([t]);return new An(e.path,e.collectionGroup,e.explicitOrderBy.slice(),n,e.limit,e.limitType,e.startAt,e.endAt)}function Fn(e,t,n){return new An(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),t,n,e.startAt,e.endAt)}function Vn(e,t){return In(Rn(e),Rn(t))&&e.limitType===t.limitType}function Un(e){return`${_n(Rn(e))}|lt:${e.limitType}`}function jn(e){return`Query(target=${function(e){let t=e.path.canonicalString();return null!==e.collectionGroup&&(t+=" collectionGroup="+e.collectionGroup),e.filters.length>0&&(t+=`, filters: [${e.filters.map((e=>ln(e))).join(", ")}]`),ve(e.limit)||(t+=", limit: "+e.limit),e.orderBy.length>0&&(t+=`, orderBy: [${e.orderBy.map((e=>function(e){return`${e.field.canonicalString()} (${e.dir})`}(e))).join(", ")}]`),e.startAt&&(t+=", startAt: ",t+=e.startAt.inclusive?"b:":"a:",t+=e.startAt.position.map((e=>xt(e))).join(",")),e.endAt&&(t+=", endAt: ",t+=e.endAt.inclusive?"a:":"b:",t+=e.endAt.position.map((e=>xt(e))).join(",")),`Target(${t})`}(Rn(e))}; limitType=${e.limitType})`}function Bn(e,t){return t.isFoundDocument()&&function(e,t){const n=t.key.path;return null!==e.collectionGroup?t.key.hasCollectionId(e.collectionGroup)&&e.path.isPrefixOf(n):z.isDocumentKey(e.path)?e.path.isEqual(n):e.path.isImmediateParentOf(n)}(e,t)&&function(e,t){for(const n of Dn(e))if(!n.field.isKeyField()&&null===t.data.field(n.field))return!1;return!0}(e,t)&&function(e,t){for(const n of e.filters)if(!n.matches(t))return!1;return!0}(e,t)&&function(e,t){return!(e.startAt&&!function(e,t,n){const r=Qt(e,t,n);return e.inclusive?r<=0:r<0}(e.startAt,Dn(e),t)||e.endAt&&!function(e,t,n){const r=Qt(e,t,n);return e.inclusive?r>=0:r>0}(e.endAt,Dn(e),t))}(e,t)}function qn(e){return e.collectionGroup||(e.path.length%2==1?e.path.lastSegment():e.path.get(e.path.length-2))}function zn(e){return(t,n)=>{let r=!1;for(const i of Dn(e)){const e=Gn(i,t,n);if(0!==e)return e;r=r||i.field.isKeyField()}return 0}}function Gn(e,t,n){const r=e.field.isKeyField()?z.comparator(t.key,n.key):function(e,t,n){const r=t.data.field(e),i=n.data.field(e);return null!==r&&null!==i?St(r,i):v()}(e.field,t,n);switch(e.dir){case"asc":return r;case"desc":return-1*r;default:return v()}}class Kn{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.innerSize=0}get(e){const t=this.mapKeyFn(e),n=this.inner[t];if(void 0!==n)for(const[t,r]of n)if(this.equalsFn(t,e))return r}has(e){return void 0!==this.get(e)}set(e,t){const n=this.mapKeyFn(e),r=this.inner[n];if(void 0===r)return this.inner[n]=[[e,t]],void this.innerSize++;for(let n=0;n<r.length;n++)if(this.equalsFn(r[n][0],e))return void(r[n]=[e,t]);r.push([e,t]),this.innerSize++}delete(e){const t=this.mapKeyFn(e),n=this.inner[t];if(void 0===n)return!1;for(let r=0;r<n.length;r++)if(this.equalsFn(n[r][0],e))return 1===n.length?delete this.inner[t]:n.splice(r,1),this.innerSize--,!0;return!1}forEach(e){Ze(this.inner,((t,n)=>{for(const[t,r]of n)e(t,r)}))}isEmpty(){return tt(this.inner)}size(){return this.innerSize}}const Wn=new nt(z.comparator);function $n(){return Wn}const Hn=new nt(z.comparator);function Qn(...e){let t=Hn;for(const n of e)t=t.insert(n.key,n);return t}function Jn(e){let t=Hn;return e.forEach(((e,n)=>t=t.insert(e,n.overlayedDocument))),t}function Yn(){return Zn()}function Xn(){return Zn()}function Zn(){return new Kn((e=>e.toString()),((e,t)=>e.isEqual(t)))}const er=new nt(z.comparator),tr=new st(z.comparator);function nr(...e){let t=tr;for(const n of e)t=t.add(n);return t}const rr=new st(P);function ir(){return rr}function sr(e,t){if(e.useProto3Json){if(isNaN(t))return{doubleValue:"NaN"};if(t===1/0)return{doubleValue:"Infinity"};if(t===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:be(t)?"-0":t}}function or(e){return{integerValue:""+e}}function ar(e,t){return we(t)?or(t):sr(e,t)}class cr{constructor(){this._=void 0}}function ur(e,t,n){return e instanceof dr?function(e,t){const n={fields:{__type__:{stringValue:"server_timestamp"},__local_write_time__:{timestampValue:{seconds:e.seconds,nanos:e.nanoseconds}}}};return t&&mt(t)&&(t=gt(t)),t&&(n.fields.__previous_value__=t),{mapValue:n}}(n,t):e instanceof fr?pr(e,t):e instanceof mr?gr(e,t):function(e,t){const n=hr(e,t),r=vr(n)+vr(e.Pe);return Dt(n)&&Dt(e.Pe)?or(r):sr(e.serializer,r)}(e,t)}function lr(e,t,n){return e instanceof fr?pr(e,t):e instanceof mr?gr(e,t):n}function hr(e,t){return e instanceof yr?function(e){return Dt(e)||function(e){return!!e&&"doubleValue"in e}(e)}(t)?t:{integerValue:0}:null}class dr extends cr{}class fr extends cr{constructor(e){super(),this.elements=e}}function pr(e,t){const n=br(t);for(const t of e.elements)n.some((e=>Et(e,t)))||n.push(t);return{arrayValue:{values:n}}}class mr extends cr{constructor(e){super(),this.elements=e}}function gr(e,t){let n=br(t);for(const t of e.elements)n=n.filter((e=>!Et(e,t)));return{arrayValue:{values:n}}}class yr extends cr{constructor(e,t){super(),this.serializer=e,this.Pe=t}}function vr(e){return ft(e.integerValue||e.doubleValue)}function br(e){return Rt(e)&&e.arrayValue.values?e.arrayValue.values.slice():[]}class wr{constructor(e,t){this.field=e,this.transform=t}}class _r{constructor(e,t){this.version=e,this.transformResults=t}}class Ir{constructor(e,t){this.updateTime=e,this.exists=t}static none(){return new Ir}static exists(e){return new Ir(void 0,e)}static updateTime(e){return new Ir(e)}get isNone(){return void 0===this.updateTime&&void 0===this.exists}isEqual(e){return this.exists===e.exists&&(this.updateTime?!!e.updateTime&&this.updateTime.isEqual(e.updateTime):!e.updateTime)}}function Er(e,t){return void 0!==e.updateTime?t.isFoundDocument()&&t.version.isEqual(e.updateTime):void 0===e.exists||e.exists===t.isFoundDocument()}class Tr{}function Sr(e,t){if(!e.hasLocalMutations||t&&0===t.fields.length)return null;if(null===t)return e.isNoDocument()?new Lr(e.key,Ir.none()):new Nr(e.key,e.data,Ir.none());{const n=e.data,r=Kt.empty();let i=new st(q.comparator);for(let e of t.fields)if(!i.has(e)){let t=n.field(e);null===t&&e.length>1&&(e=e.popLast(),t=n.field(e)),null===t?r.delete(e):r.set(e,t),i=i.add(e)}return new Or(e.key,r,new ct(i.toArray()),Ir.none())}}function Cr(e,t,n){e instanceof Nr?function(e,t,n){const r=e.value.clone(),i=Rr(e.fieldTransforms,t,n.transformResults);r.setAll(i),t.convertToFoundDocument(n.version,r).setHasCommittedMutations()}(e,t,n):e instanceof Or?function(e,t,n){if(!Er(e.precondition,t))return void t.convertToUnknownDocument(n.version);const r=Rr(e.fieldTransforms,t,n.transformResults),i=t.data;i.setAll(Dr(e)),i.setAll(r),t.convertToFoundDocument(n.version,i).setHasCommittedMutations()}(e,t,n):function(e,t,n){t.convertToNoDocument(n.version).setHasCommittedMutations()}(0,t,n)}function Ar(e,t,n,r){return e instanceof Nr?function(e,t,n,r){if(!Er(e.precondition,t))return n;const i=e.value.clone(),s=Pr(e.fieldTransforms,r,t);return i.setAll(s),t.convertToFoundDocument(t.version,i).setHasLocalMutations(),null}(e,t,n,r):e instanceof Or?function(e,t,n,r){if(!Er(e.precondition,t))return n;const i=Pr(e.fieldTransforms,r,t),s=t.data;return s.setAll(Dr(e)),s.setAll(i),t.convertToFoundDocument(t.version,s).setHasLocalMutations(),null===n?null:n.unionWith(e.fieldMask.fields).unionWith(e.fieldTransforms.map((e=>e.field)))}(e,t,n,r):function(e,t,n){return Er(e.precondition,t)?(t.convertToNoDocument(t.version).setHasLocalMutations(),null):n}(e,t,n)}function xr(e,t){let n=null;for(const r of e.fieldTransforms){const e=t.data.field(r.field),i=hr(r.transform,e||null);null!=i&&(null===n&&(n=Kt.empty()),n.set(r.field,i))}return n||null}function kr(e,t){return e.type===t.type&&!!e.key.isEqual(t.key)&&!!e.precondition.isEqual(t.precondition)&&!!function(e,t){return void 0===e&&void 0===t||!(!e||!t)&&L(e,t,((e,t)=>function(e,t){return e.field.isEqual(t.field)&&function(e,t){return e instanceof fr&&t instanceof fr||e instanceof mr&&t instanceof mr?L(e.elements,t.elements,Et):e instanceof yr&&t instanceof yr?Et(e.Pe,t.Pe):e instanceof dr&&t instanceof dr}(e.transform,t.transform)}(e,t)))}(e.fieldTransforms,t.fieldTransforms)&&(0===e.type?e.value.isEqual(t.value):1!==e.type||e.data.isEqual(t.data)&&e.fieldMask.isEqual(t.fieldMask))}class Nr extends Tr{constructor(e,t,n,r=[]){super(),this.key=e,this.value=t,this.precondition=n,this.fieldTransforms=r,this.type=0}getFieldMask(){return null}}class Or extends Tr{constructor(e,t,n,r,i=[]){super(),this.key=e,this.data=t,this.fieldMask=n,this.precondition=r,this.fieldTransforms=i,this.type=1}getFieldMask(){return this.fieldMask}}function Dr(e){const t=new Map;return e.fieldMask.fields.forEach((n=>{if(!n.isEmpty()){const r=e.data.field(n);t.set(n,r)}})),t}function Rr(e,t,n){const r=new Map;b(e.length===n.length);for(let i=0;i<n.length;i++){const s=e[i],o=s.transform,a=t.data.field(s.field);r.set(s.field,lr(o,a,n[i]))}return r}function Pr(e,t,n){const r=new Map;for(const i of e){const e=i.transform,s=n.data.field(i.field);r.set(i.field,ur(e,s,t))}return r}class Lr extends Tr{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}class Mr extends Tr{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}}class Fr{constructor(e,t,n,r){this.batchId=e,this.localWriteTime=t,this.baseMutations=n,this.mutations=r}applyToRemoteDocument(e,t){const n=t.mutationResults;for(let t=0;t<this.mutations.length;t++){const r=this.mutations[t];r.key.isEqual(e.key)&&Cr(r,e,n[t])}}applyToLocalView(e,t){for(const n of this.baseMutations)n.key.isEqual(e.key)&&(t=Ar(n,e,t,this.localWriteTime));for(const n of this.mutations)n.key.isEqual(e.key)&&(t=Ar(n,e,t,this.localWriteTime));return t}applyToLocalDocumentSet(e,t){const n=Xn();return this.mutations.forEach((r=>{const i=e.get(r.key),s=i.overlayedDocument;let o=this.applyToLocalView(s,i.mutatedFields);o=t.has(r.key)?null:o;const a=Sr(s,o);null!==a&&n.set(r.key,a),s.isValidDocument()||s.convertToNoDocument(V.min())})),n}keys(){return this.mutations.reduce(((e,t)=>e.add(t.key)),nr())}isEqual(e){return this.batchId===e.batchId&&L(this.mutations,e.mutations,((e,t)=>kr(e,t)))&&L(this.baseMutations,e.baseMutations,((e,t)=>kr(e,t)))}}class Vr{constructor(e,t,n,r){this.batch=e,this.commitVersion=t,this.mutationResults=n,this.docVersions=r}static from(e,t,n){b(e.mutations.length===n.length);let r=er;const i=e.mutations;for(let e=0;e<i.length;e++)r=r.insert(i[e].key,n[e].version);return new Vr(e,t,n,r)}}class Ur{constructor(e,t){this.largestBatchId=e,this.mutation=t}getKey(){return this.mutation.key}isEqual(e){return null!==e&&this.mutation===e.mutation}toString(){return`Overlay{\n largestBatchId: ${this.largestBatchId},\n mutation: ${this.mutation.toString()}\n }`}}class jr{constructor(e,t,n){this.alias=e,this.aggregateType=t,this.fieldPath=n}}class Br{constructor(e,t){this.count=e,this.unchangedNames=t}}var qr,zr;function Gr(e){switch(e){default:return v();case _.CANCELLED:case _.UNKNOWN:case _.DEADLINE_EXCEEDED:case _.RESOURCE_EXHAUSTED:case _.INTERNAL:case _.UNAVAILABLE:case _.UNAUTHENTICATED:return!1;case _.INVALID_ARGUMENT:case _.NOT_FOUND:case _.ALREADY_EXISTS:case _.PERMISSION_DENIED:case _.FAILED_PRECONDITION:case _.ABORTED:case _.OUT_OF_RANGE:case _.UNIMPLEMENTED:case _.DATA_LOSS:return!0}}function Kr(e){if(void 0===e)return m("GRPC error has no .code"),_.UNKNOWN;switch(e){case qr.OK:return _.OK;case qr.CANCELLED:return _.CANCELLED;case qr.UNKNOWN:return _.UNKNOWN;case qr.DEADLINE_EXCEEDED:return _.DEADLINE_EXCEEDED;case qr.RESOURCE_EXHAUSTED:return _.RESOURCE_EXHAUSTED;case qr.INTERNAL:return _.INTERNAL;case qr.UNAVAILABLE:return _.UNAVAILABLE;case qr.UNAUTHENTICATED:return _.UNAUTHENTICATED;case qr.INVALID_ARGUMENT:return _.INVALID_ARGUMENT;case qr.NOT_FOUND:return _.NOT_FOUND;case qr.ALREADY_EXISTS:return _.ALREADY_EXISTS;case qr.PERMISSION_DENIED:return _.PERMISSION_DENIED;case qr.FAILED_PRECONDITION:return _.FAILED_PRECONDITION;case qr.ABORTED:return _.ABORTED;case qr.OUT_OF_RANGE:return _.OUT_OF_RANGE;case qr.UNIMPLEMENTED:return _.UNIMPLEMENTED;case qr.DATA_LOSS:return _.DATA_LOSS;default:return v()}}(zr=qr||(qr={}))[zr.OK=0]="OK",zr[zr.CANCELLED=1]="CANCELLED",zr[zr.UNKNOWN=2]="UNKNOWN",zr[zr.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",zr[zr.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",zr[zr.NOT_FOUND=5]="NOT_FOUND",zr[zr.ALREADY_EXISTS=6]="ALREADY_EXISTS",zr[zr.PERMISSION_DENIED=7]="PERMISSION_DENIED",zr[zr.UNAUTHENTICATED=16]="UNAUTHENTICATED",zr[zr.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",zr[zr.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",zr[zr.ABORTED=10]="ABORTED",zr[zr.OUT_OF_RANGE=11]="OUT_OF_RANGE",zr[zr.UNIMPLEMENTED=12]="UNIMPLEMENTED",zr[zr.INTERNAL=13]="INTERNAL",zr[zr.UNAVAILABLE=14]="UNAVAILABLE",zr[zr.DATA_LOSS=15]="DATA_LOSS";let Wr=null;function $r(){return new TextEncoder}const Hr=new a.Integer([4294967295,4294967295],0);function Qr(e){const t=$r().encode(e),n=new a.Md5;return n.update(t),new Uint8Array(n.digest())}function Jr(e){const t=new DataView(e.buffer),n=t.getUint32(0,!0),r=t.getUint32(4,!0),i=t.getUint32(8,!0),s=t.getUint32(12,!0);return[new a.Integer([n,r],0),new a.Integer([i,s],0)]}class Yr{constructor(e,t,n){if(this.bitmap=e,this.padding=t,this.hashCount=n,t<0||t>=8)throw new Xr(`Invalid padding: ${t}`);if(n<0)throw new Xr(`Invalid hash count: ${n}`);if(e.length>0&&0===this.hashCount)throw new Xr(`Invalid hash count: ${n}`);if(0===e.length&&0!==t)throw new Xr(`Invalid padding when bitmap length is 0: ${t}`);this.Ie=8*e.length-t,this.Te=a.Integer.fromNumber(this.Ie)}Ee(e,t,n){let r=e.add(t.multiply(a.Integer.fromNumber(n)));return 1===r.compare(Hr)&&(r=new a.Integer([r.getBits(0),r.getBits(1)],0)),r.modulo(this.Te).toNumber()}de(e){return!!(this.bitmap[Math.floor(e/8)]&1<<e%8)}mightContain(e){if(0===this.Ie)return!1;const t=Qr(e),[n,r]=Jr(t);for(let e=0;e<this.hashCount;e++){const t=this.Ee(n,r,e);if(!this.de(t))return!1}return!0}static create(e,t,n){const r=e%8==0?0:8-e%8,i=new Uint8Array(Math.ceil(e/8)),s=new Yr(i,r,t);return n.forEach((e=>s.insert(e))),s}insert(e){if(0===this.Ie)return;const t=Qr(e),[n,r]=Jr(t);for(let e=0;e<this.hashCount;e++){const t=this.Ee(n,r,e);this.Ae(t)}}Ae(e){const t=Math.floor(e/8),n=e%8;this.bitmap[t]|=1<<n}}class Xr extends Error{constructor(){super(...arguments),this.name="BloomFilterError"}}class Zr{constructor(e,t,n,r,i){this.snapshotVersion=e,this.targetChanges=t,this.targetMismatches=n,this.documentUpdates=r,this.resolvedLimboDocuments=i}static createSynthesizedRemoteEventForCurrentChange(e,t,n){const r=new Map;return r.set(e,ei.createSynthesizedTargetChangeForCurrentChange(e,t,n)),new Zr(V.min(),r,new nt(P),$n(),nr())}}class ei{constructor(e,t,n,r,i){this.resumeToken=e,this.current=t,this.addedDocuments=n,this.modifiedDocuments=r,this.removedDocuments=i}static createSynthesizedTargetChangeForCurrentChange(e,t,n){return new ei(n,t,nr(),nr(),nr())}}class ti{constructor(e,t,n,r){this.Re=e,this.removedTargetIds=t,this.key=n,this.Ve=r}}class ni{constructor(e,t){this.targetId=e,this.me=t}}class ri{constructor(e,t,n=lt.EMPTY_BYTE_STRING,r=null){this.state=e,this.targetIds=t,this.resumeToken=n,this.cause=r}}class ii{constructor(){this.fe=0,this.ge=ai(),this.pe=lt.EMPTY_BYTE_STRING,this.ye=!1,this.we=!0}get current(){return this.ye}get resumeToken(){return this.pe}get Se(){return 0!==this.fe}get be(){return this.we}De(e){e.approximateByteSize()>0&&(this.we=!0,this.pe=e)}ve(){let e=nr(),t=nr(),n=nr();return this.ge.forEach(((r,i)=>{switch(i){case 0:e=e.add(r);break;case 2:t=t.add(r);break;case 1:n=n.add(r);break;default:v()}})),new ei(this.pe,this.ye,e,t,n)}Ce(){this.we=!1,this.ge=ai()}Fe(e,t){this.we=!0,this.ge=this.ge.insert(e,t)}Me(e){this.we=!0,this.ge=this.ge.remove(e)}xe(){this.fe+=1}Oe(){this.fe-=1,b(this.fe>=0)}Ne(){this.we=!0,this.ye=!0}}class si{constructor(e){this.Le=e,this.Be=new Map,this.ke=$n(),this.qe=oi(),this.Qe=new nt(P)}Ke(e){for(const t of e.Re)e.Ve&&e.Ve.isFoundDocument()?this.$e(t,e.Ve):this.Ue(t,e.key,e.Ve);for(const t of e.removedTargetIds)this.Ue(t,e.key,e.Ve)}We(e){this.forEachTarget(e,(t=>{const n=this.Ge(t);switch(e.state){case 0:this.ze(t)&&n.De(e.resumeToken);break;case 1:n.Oe(),n.Se||n.Ce(),n.De(e.resumeToken);break;case 2:n.Oe(),n.Se||this.removeTarget(t);break;case 3:this.ze(t)&&(n.Ne(),n.De(e.resumeToken));break;case 4:this.ze(t)&&(this.je(t),n.De(e.resumeToken));break;default:v()}}))}forEachTarget(e,t){e.targetIds.length>0?e.targetIds.forEach(t):this.Be.forEach(((e,n)=>{this.ze(n)&&t(n)}))}He(e){const t=e.targetId,n=e.me.count,r=this.Je(t);if(r){const i=r.target;if(En(i))if(0===n){const e=new z(i.path);this.Ue(t,e,$t.newNoDocument(e,V.min()))}else b(1===n);else{const r=this.Ye(t);if(r!==n){const n=this.Ze(e),i=n?this.Xe(n,e,r):1;if(0!==i){this.je(t);const e=2===i?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch";this.Qe=this.Qe.insert(t,e)}null==Wr||Wr.et(function(e,t,n,r,i){var s,o,a,c,u,l;const h={localCacheCount:e,existenceFilterCount:t.count,databaseId:n.database,projectId:n.projectId},d=t.unchangedNames;return d&&(h.bloomFilter={applied:0===i,hashCount:null!==(s=null==d?void 0:d.hashCount)&&void 0!==s?s:0,bitmapLength:null!==(c=null===(a=null===(o=null==d?void 0:d.bits)||void 0===o?void 0:o.bitmap)||void 0===a?void 0:a.length)&&void 0!==c?c:0,padding:null!==(l=null===(u=null==d?void 0:d.bits)||void 0===u?void 0:u.padding)&&void 0!==l?l:0,mightContain:e=>{var t;return null!==(t=null==r?void 0:r.mightContain(e))&&void 0!==t&&t}}),h}(r,e.me,this.Le.tt(),n,i))}}}}Ze(e){const t=e.me.unchangedNames;if(!t||!t.bits)return null;const{bits:{bitmap:n="",padding:r=0},hashCount:i=0}=t;let s,o;try{s=pt(n).toUint8Array()}catch(e){if(e instanceof ut)return g("Decoding the base64 bloom filter in existence filter failed ("+e.message+"); ignoring the bloom filter and falling back to full re-query."),null;throw e}try{o=new Yr(s,r,i)}catch(e){return g(e instanceof Xr?"BloomFilter error: ":"Applying bloom filter failed: ",e),null}return 0===o.Ie?null:o}Xe(e,t,n){return t.me.count===n-this.nt(e,t.targetId)?0:2}nt(e,t){const n=this.Le.getRemoteKeysForTarget(t);let r=0;return n.forEach((n=>{const i=this.Le.tt(),s=`projects/${i.projectId}/databases/${i.database}/documents/${n.path.canonicalString()}`;e.mightContain(s)||(this.Ue(t,n,null),r++)})),r}rt(e){const t=new Map;this.Be.forEach(((n,r)=>{const i=this.Je(r);if(i){if(n.current&&En(i.target)){const t=new z(i.target.path);null!==this.ke.get(t)||this.it(r,t)||this.Ue(r,t,$t.newNoDocument(t,e))}n.be&&(t.set(r,n.ve()),n.Ce())}}));let n=nr();this.qe.forEach(((e,t)=>{let r=!0;t.forEachWhile((e=>{const t=this.Je(e);return!t||"TargetPurposeLimboResolution"===t.purpose||(r=!1,!1)})),r&&(n=n.add(e))})),this.ke.forEach(((t,n)=>n.setReadTime(e)));const r=new Zr(e,t,this.Qe,this.ke,n);return this.ke=$n(),this.qe=oi(),this.Qe=new nt(P),r}$e(e,t){if(!this.ze(e))return;const n=this.it(e,t.key)?2:0;this.Ge(e).Fe(t.key,n),this.ke=this.ke.insert(t.key,t),this.qe=this.qe.insert(t.key,this.st(t.key).add(e))}Ue(e,t,n){if(!this.ze(e))return;const r=this.Ge(e);this.it(e,t)?r.Fe(t,1):r.Me(t),this.qe=this.qe.insert(t,this.st(t).delete(e)),n&&(this.ke=this.ke.insert(t,n))}removeTarget(e){this.Be.delete(e)}Ye(e){const t=this.Ge(e).ve();return this.Le.getRemoteKeysForTarget(e).size+t.addedDocuments.size-t.removedDocuments.size}xe(e){this.Ge(e).xe()}Ge(e){let t=this.Be.get(e);return t||(t=new ii,this.Be.set(e,t)),t}st(e){let t=this.qe.get(e);return t||(t=new st(P),this.qe=this.qe.insert(e,t)),t}ze(e){const t=null!==this.Je(e);return t||p("WatchChangeAggregator","Detected inactive target",e),t}Je(e){const t=this.Be.get(e);return t&&t.Se?null:this.Le.ot(e)}je(e){this.Be.set(e,new ii),this.Le.getRemoteKeysForTarget(e).forEach((t=>{this.Ue(e,t,null)}))}it(e,t){return this.Le.getRemoteKeysForTarget(e).has(t)}}function oi(){return new nt(z.comparator)}function ai(){return new nt(z.comparator)}const ci={asc:"ASCENDING",desc:"DESCENDING"},ui={"<":"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"},li={and:"AND",or:"OR"};class hi{constructor(e,t){this.databaseId=e,this.useProto3Json=t}}function di(e,t){return e.useProto3Json||ve(t)?t:{value:t}}function fi(e,t){return e.useProto3Json?`${new Date(1e3*t.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+t.nanoseconds).slice(-9)}Z`:{seconds:""+t.seconds,nanos:t.nanoseconds}}function pi(e,t){return e.useProto3Json?t.toBase64():t.toUint8Array()}function mi(e,t){return fi(e,t.toTimestamp())}function gi(e){return b(!!e),V.fromTimestamp(function(e){const t=dt(e);return new F(t.seconds,t.nanos)}(e))}function yi(e,t){return vi(e,t).canonicalString()}function vi(e,t){const n=function(e){return new j(["projects",e.projectId,"databases",e.database])}(e).child("documents");return void 0===t?n:n.child(t)}function bi(e){const t=j.fromString(e);return b(qi(t)),t}function wi(e,t){return yi(e.databaseId,t.path)}function _i(e,t){const n=bi(t);if(n.get(1)!==e.databaseId.projectId)throw new I(_.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+n.get(1)+" vs "+e.databaseId.projectId);if(n.get(3)!==e.databaseId.database)throw new I(_.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+n.get(3)+" vs "+e.databaseId.database);return new z(Si(n))}function Ii(e,t){return yi(e.databaseId,t)}function Ei(e){const t=bi(e);return 4===t.length?j.emptyPath():Si(t)}function Ti(e){return new j(["projects",e.databaseId.projectId,"databases",e.databaseId.database]).canonicalString()}function Si(e){return b(e.length>4&&"documents"===e.get(4)),e.popFirst(5)}function Ci(e,t,n){return{name:wi(e,t),fields:n.value.mapValue.fields}}function Ai(e,t,n){const r=_i(e,t.name),i=gi(t.updateTime),s=t.createTime?gi(t.createTime):V.min(),o=new Kt({mapValue:{fields:t.fields}}),a=$t.newFoundDocument(r,i,s,o);return n&&a.setHasCommittedMutations(),n?a.setHasCommittedMutations():a}function xi(e,t){let n;if(t instanceof Nr)n={update:Ci(e,t.key,t.value)};else if(t instanceof Lr)n={delete:wi(e,t.key)};else if(t instanceof Or)n={update:Ci(e,t.key,t.data),updateMask:Bi(t.fieldMask)};else{if(!(t instanceof Mr))return v();n={verify:wi(e,t.key)}}return t.fieldTransforms.length>0&&(n.updateTransforms=t.fieldTransforms.map((e=>function(e,t){const n=t.transform;if(n instanceof dr)return{fieldPath:t.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(n instanceof fr)return{fieldPath:t.field.canonicalString(),appendMissingElements:{values:n.elements}};if(n instanceof mr)return{fieldPath:t.field.canonicalString(),removeAllFromArray:{values:n.elements}};if(n instanceof yr)return{fieldPath:t.field.canonicalString(),increment:n.Pe};throw v()}(0,e)))),t.precondition.isNone||(n.currentDocument=function(e,t){return void 0!==t.updateTime?{updateTime:mi(e,t.updateTime)}:void 0!==t.exists?{exists:t.exists}:v()}(e,t.precondition)),n}function ki(e,t){const n=t.currentDocument?function(e){return void 0!==e.updateTime?Ir.updateTime(gi(e.updateTime)):void 0!==e.exists?Ir.exists(e.exists):Ir.none()}(t.currentDocument):Ir.none(),r=t.updateTransforms?t.updateTransforms.map((t=>function(e,t){let n=null;if("setToServerValue"in t)b("REQUEST_TIME"===t.setToServerValue),n=new dr;else if("appendMissingElements"in t){const e=t.appendMissingElements.values||[];n=new fr(e)}else if("removeAllFromArray"in t){const e=t.removeAllFromArray.values||[];n=new mr(e)}else"increment"in t?n=new yr(e,t.increment):v();const r=q.fromServerFormat(t.fieldPath);return new wr(r,n)}(e,t))):[];if(t.update){t.update.name;const i=_i(e,t.update.name),s=new Kt({mapValue:{fields:t.update.fields}});if(t.updateMask){const e=function(e){const t=e.fieldPaths||[];return new ct(t.map((e=>q.fromServerFormat(e))))}(t.updateMask);return new Or(i,s,e,n,r)}return new Nr(i,s,n,r)}if(t.delete){const r=_i(e,t.delete);return new Lr(r,n)}if(t.verify){const r=_i(e,t.verify);return new Mr(r,n)}return v()}function Ni(e,t){return{documents:[Ii(e,t.path)]}}function Oi(e,t){const n={structuredQuery:{}},r=t.path;let i;null!==t.collectionGroup?(i=r,n.structuredQuery.from=[{collectionId:t.collectionGroup,allDescendants:!0}]):(i=r.popLast(),n.structuredQuery.from=[{collectionId:r.lastSegment()}]),n.parent=Ii(e,i);const s=function(e){if(0!==e.length)return ji(tn.create(e,"and"))}(t.filters);s&&(n.structuredQuery.where=s);const o=function(e){if(0!==e.length)return e.map((e=>function(e){return{field:Vi(e.field),direction:Li(e.dir)}}(e)))}(t.orderBy);o&&(n.structuredQuery.orderBy=o);const a=di(e,t.limit);return null!==a&&(n.structuredQuery.limit=a),t.startAt&&(n.structuredQuery.startAt=function(e){return{before:e.inclusive,values:e.position}}(t.startAt)),t.endAt&&(n.structuredQuery.endAt=function(e){return{before:!e.inclusive,values:e.position}}(t.endAt)),{_t:n,parent:i}}function Di(e,t,n,r){const{_t:i,parent:s}=Oi(e,t),o={},a=[];let c=0;return n.forEach((e=>{const t=r?e.alias:"aggregate_"+c++;o[t]=e.alias,"count"===e.aggregateType?a.push({alias:t,count:{}}):"avg"===e.aggregateType?a.push({alias:t,avg:{field:Vi(e.fieldPath)}}):"sum"===e.aggregateType&&a.push({alias:t,sum:{field:Vi(e.fieldPath)}})})),{request:{structuredAggregationQuery:{aggregations:a,structuredQuery:i.structuredQuery},parent:i.parent},ut:o,parent:s}}function Ri(e){let t=Ei(e.parent);const n=e.structuredQuery,r=n.from?n.from.length:0;let i=null;if(r>0){b(1===r);const e=n.from[0];e.allDescendants?i=e.collectionId:t=t.child(e.collectionId)}let s=[];n.where&&(s=function(e){const t=Pi(e);return t instanceof tn&&sn(t)?t.getFilters():[t]}(n.where));let o=[];n.orderBy&&(o=function(e){return e.map((e=>function(e){return new Yt(Ui(e.field),function(e){switch(e){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(e.direction))}(e)))}(n.orderBy));let a=null;n.limit&&(a=function(e){let t;return t="object"==typeof e?e.value:e,ve(t)?null:t}(n.limit));let c=null;n.startAt&&(c=function(e){const t=!!e.before,n=e.values||[];return new Ht(n,t)}(n.startAt));let u=null;return n.endAt&&(u=function(e){const t=!e.before,n=e.values||[];return new Ht(n,t)}(n.endAt)),xn(t,i,o,s,a,"F",c,u)}function Pi(e){return void 0!==e.unaryFilter?function(e){switch(e.unaryFilter.op){case"IS_NAN":const t=Ui(e.unaryFilter.field);return en.create(t,"==",{doubleValue:NaN});case"IS_NULL":const n=Ui(e.unaryFilter.field);return en.create(n,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":const r=Ui(e.unaryFilter.field);return en.create(r,"!=",{doubleValue:NaN});case"IS_NOT_NULL":const i=Ui(e.unaryFilter.field);return en.create(i,"!=",{nullValue:"NULL_VALUE"});default:return v()}}(e):void 0!==e.fieldFilter?function(e){return en.create(Ui(e.fieldFilter.field),function(e){switch(e){case"EQUAL":return"==";case"NOT_EQUAL":return"!=";case"GREATER_THAN":return">";case"GREATER_THAN_OR_EQUAL":return">=";case"LESS_THAN":return"<";case"LESS_THAN_OR_EQUAL":return"<=";case"ARRAY_CONTAINS":return"array-contains";case"IN":return"in";case"NOT_IN":return"not-in";case"ARRAY_CONTAINS_ANY":return"array-contains-any";default:return v()}}(e.fieldFilter.op),e.fieldFilter.value)}(e):void 0!==e.compositeFilter?function(e){return tn.create(e.compositeFilter.filters.map((e=>Pi(e))),function(e){switch(e){case"AND":return"and";case"OR":return"or";default:return v()}}(e.compositeFilter.op))}(e):v()}function Li(e){return ci[e]}function Mi(e){return ui[e]}function Fi(e){return li[e]}function Vi(e){return{fieldPath:e.canonicalString()}}function Ui(e){return q.fromServerFormat(e.fieldPath)}function ji(e){return e instanceof en?function(e){if("=="===e.op){if(Lt(e.value))return{unaryFilter:{field:Vi(e.field),op:"IS_NAN"}};if(Pt(e.value))return{unaryFilter:{field:Vi(e.field),op:"IS_NULL"}}}else if("!="===e.op){if(Lt(e.value))return{unaryFilter:{field:Vi(e.field),op:"IS_NOT_NAN"}};if(Pt(e.value))return{unaryFilter:{field:Vi(e.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:Vi(e.field),op:Mi(e.op),value:e.value}}}(e):e instanceof tn?function(e){const t=e.getFilters().map((e=>ji(e)));return 1===t.length?t[0]:{compositeFilter:{op:Fi(e.op),filters:t}}}(e):v()}function Bi(e){const t=[];return e.fields.forEach((e=>t.push(e.canonicalString()))),{fieldPaths:t}}function qi(e){return e.length>=4&&"projects"===e.get(0)&&"databases"===e.get(2)}class zi{constructor(e,t,n,r,i=V.min(),s=V.min(),o=lt.EMPTY_BYTE_STRING,a=null){this.target=e,this.targetId=t,this.purpose=n,this.sequenceNumber=r,this.snapshotVersion=i,this.lastLimboFreeSnapshotVersion=s,this.resumeToken=o,this.expectedCount=a}withSequenceNumber(e){return new zi(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(e,t){return new zi(this.target,this.targetId,this.purpose,this.sequenceNumber,t,this.lastLimboFreeSnapshotVersion,e,null)}withExpectedCount(e){return new zi(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,e)}withLastLimboFreeSnapshotVersion(e){return new zi(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken,this.expectedCount)}}class Gi{constructor(e){this.ct=e}}function Ki(e,t){const n=t.key,r={prefixPath:n.getCollectionPath().popLast().toArray(),collectionGroup:n.collectionGroup,documentId:n.path.lastSegment(),readTime:Wi(t.readTime),hasCommittedMutations:t.hasCommittedMutations};if(t.isFoundDocument())r.document=function(e,t){return{name:wi(e,t.key),fields:t.data.value.mapValue.fields,updateTime:fi(e,t.version.toTimestamp()),createTime:fi(e,t.createTime.toTimestamp())}}(e.ct,t);else if(t.isNoDocument())r.noDocument={path:n.path.toArray(),readTime:$i(t.version)};else{if(!t.isUnknownDocument())return v();r.unknownDocument={path:n.path.toArray(),version:$i(t.version)}}return r}function Wi(e){const t=e.toTimestamp();return[t.seconds,t.nanoseconds]}function $i(e){const t=e.toTimestamp();return{seconds:t.seconds,nanoseconds:t.nanoseconds}}function Hi(e){const t=new F(e.seconds,e.nanoseconds);return V.fromTimestamp(t)}function Qi(e,t){const n=(t.baseMutations||[]).map((t=>ki(e.ct,t)));for(let e=0;e<t.mutations.length-1;++e){const n=t.mutations[e];if(e+1<t.mutations.length&&void 0!==t.mutations[e+1].transform){const r=t.mutations[e+1];n.updateTransforms=r.transform.fieldTransforms,t.mutations.splice(e+1,1),++e}}const r=t.mutations.map((t=>ki(e.ct,t))),i=F.fromMillis(t.localWriteTimeMs);return new Fr(t.batchId,i,n,r)}function Ji(e){const t=Hi(e.readTime),n=void 0!==e.lastLimboFreeSnapshotVersion?Hi(e.lastLimboFreeSnapshotVersion):V.min();let r;return r=function(e){return void 0!==e.documents}(e.query)?function(e){return b(1===e.documents.length),Rn(kn(Ei(e.documents[0])))}(e.query):function(e){return Rn(Ri(e))}(e.query),new zi(r,e.targetId,"TargetPurposeListen",e.lastListenSequenceNumber,t,n,lt.fromBase64String(e.resumeToken))}function Yi(e,t){const n=$i(t.snapshotVersion),r=$i(t.lastLimboFreeSnapshotVersion);let i;i=En(t.target)?Ni(e.ct,t.target):Oi(e.ct,t.target)._t;const s=t.resumeToken.toBase64();return{targetId:t.targetId,canonicalId:_n(t.target),readTime:n,resumeToken:s,lastListenSequenceNumber:t.sequenceNumber,lastLimboFreeSnapshotVersion:r,query:i}}function Xi(e){const t=Ri({parent:e.parent,structuredQuery:e.structuredQuery});return"LAST"===e.limitType?Fn(t,t.limit,"L"):t}function Zi(e,t){return new Ur(t.largestBatchId,ki(e.ct,t.overlayMutation))}function es(e,t){const n=t.path.lastSegment();return[e,_e(t.path.popLast()),n]}function ts(e,t,n,r){return{indexId:e,uid:t,sequenceNumber:n,readTime:$i(r.readTime),documentKey:_e(r.documentKey.path),largestBatchId:r.largestBatchId}}class ns{getBundleMetadata(e,t){return rs(e).get(t).next((e=>{if(e)return function(e){return{id:e.bundleId,createTime:Hi(e.createTime),version:e.version}}(e)}))}saveBundleMetadata(e,t){return rs(e).put(function(e){return{bundleId:e.id,createTime:$i(gi(e.createTime)),version:e.version}}(t))}getNamedQuery(e,t){return is(e).get(t).next((e=>{if(e)return function(e){return{name:e.name,query:Xi(e.bundledQuery),readTime:Hi(e.readTime)}}(e)}))}saveNamedQuery(e,t){return is(e).put(function(e){return{name:e.name,readTime:$i(gi(e.readTime)),bundledQuery:e.bundledQuery}}(t))}}function rs(e){return Ye(e,"bundles")}function is(e){return Ye(e,"namedQueries")}class ss{constructor(e,t){this.serializer=e,this.userId=t}static lt(e,t){const n=t.uid||"";return new ss(e,n)}getOverlay(e,t){return os(e).get(es(this.userId,t)).next((e=>e?Zi(this.serializer,e):null))}getOverlays(e,t){const n=Yn();return ie.forEach(t,(t=>this.getOverlay(e,t).next((e=>{null!==e&&n.set(t,e)})))).next((()=>n))}saveOverlays(e,t,n){const r=[];return n.forEach(((n,i)=>{const s=new Ur(t,i);r.push(this.ht(e,s))})),ie.waitFor(r)}removeOverlaysForBatchId(e,t,n){const r=new Set;t.forEach((e=>r.add(_e(e.getCollectionPath()))));const i=[];return r.forEach((t=>{const r=IDBKeyRange.bound([this.userId,t,n],[this.userId,t,n+1],!1,!0);i.push(os(e).j("collectionPathOverlayIndex",r))})),ie.waitFor(i)}getOverlaysForCollection(e,t,n){const r=Yn(),i=_e(t),s=IDBKeyRange.bound([this.userId,i,n],[this.userId,i,Number.POSITIVE_INFINITY],!0);return os(e).U("collectionPathOverlayIndex",s).next((e=>{for(const t of e){const e=Zi(this.serializer,t);r.set(e.getKey(),e)}return r}))}getOverlaysForCollectionGroup(e,t,n,r){const i=Yn();let s;const o=IDBKeyRange.bound([this.userId,t,n],[this.userId,t,Number.POSITIVE_INFINITY],!0);return os(e).J({index:"collectionGroupOverlayIndex",range:o},((e,t,n)=>{const o=Zi(this.serializer,t);i.size()<r||o.largestBatchId===s?(i.set(o.getKey(),o),s=o.largestBatchId):n.done()})).next((()=>i))}ht(e,t){return os(e).put(function(e,t,n){const[r,i,s]=es(t,n.mutation.key);return{userId:t,collectionPath:i,documentId:s,collectionGroup:n.mutation.key.getCollectionGroup(),largestBatchId:n.largestBatchId,overlayMutation:xi(e.ct,n.mutation)}}(this.serializer,this.userId,t))}}function os(e){return Ye(e,"documentOverlays")}class as{Pt(e){return Ye(e,"globals")}getSessionToken(e){return this.Pt(e).get("sessionToken").next((e=>{const t=null==e?void 0:e.value;return t?lt.fromUint8Array(t):lt.EMPTY_BYTE_STRING}))}setSessionToken(e,t){return this.Pt(e).put({name:"sessionToken",value:t.toUint8Array()})}}class cs{constructor(){}It(e,t){this.Tt(e,t),t.Et()}Tt(e,t){if("nullValue"in e)this.dt(t,5);else if("booleanValue"in e)this.dt(t,10),t.At(e.booleanValue?1:0);else if("integerValue"in e)this.dt(t,15),t.At(ft(e.integerValue));else if("doubleValue"in e){const n=ft(e.doubleValue);isNaN(n)?this.dt(t,13):(this.dt(t,15),be(n)?t.At(0):t.At(n))}else if("timestampValue"in e){let n=e.timestampValue;this.dt(t,20),"string"==typeof n&&(n=dt(n)),t.Rt(`${n.seconds||""}`),t.At(n.nanos||0)}else if("stringValue"in e)this.Vt(e.stringValue,t),this.ft(t);else if("bytesValue"in e)this.dt(t,30),t.gt(pt(e.bytesValue)),this.ft(t);else if("referenceValue"in e)this.yt(e.referenceValue,t);else if("geoPointValue"in e){const n=e.geoPointValue;this.dt(t,45),t.At(n.latitude||0),t.At(n.longitude||0)}else"mapValue"in e?Ut(e)?this.dt(t,Number.MAX_SAFE_INTEGER):Ft(e)?this.wt(e.mapValue,t):(this.St(e.mapValue,t),this.ft(t)):"arrayValue"in e?(this.bt(e.arrayValue,t),this.ft(t)):v()}Vt(e,t){this.dt(t,25),this.Dt(e,t)}Dt(e,t){t.Rt(e)}St(e,t){const n=e.fields||{};this.dt(t,55);for(const e of Object.keys(n))this.Vt(e,t),this.Tt(n[e],t)}wt(e,t){var n,r;const i=e.fields||{};this.dt(t,53);const s="value",o=(null===(r=null===(n=i[s].arrayValue)||void 0===n?void 0:n.values)||void 0===r?void 0:r.length)||0;this.dt(t,15),t.At(ft(o)),this.Vt(s,t),this.Tt(i[s],t)}bt(e,t){const n=e.values||[];this.dt(t,50);for(const e of n)this.Tt(e,t)}yt(e,t){this.dt(t,37),z.fromName(e).path.forEach((e=>{this.dt(t,60),this.Dt(e,t)}))}dt(e,t){e.At(t)}ft(e){e.At(2)}}function us(e){if(0===e)return 8;let t=0;return!(e>>4)&&(t+=4,e<<=4),!(e>>6)&&(t+=2,e<<=2),!(e>>7)&&(t+=1),t}function ls(e){const t=64-function(e){let t=0;for(let n=0;n<8;++n){const r=us(255&e[n]);if(t+=r,8!==r)break}return t}(e);return Math.ceil(t/8)}cs.vt=new cs;class hs{constructor(){this.buffer=new Uint8Array(1024),this.position=0}Ct(e){const t=e[Symbol.iterator]();let n=t.next();for(;!n.done;)this.Ft(n.value),n=t.next();this.Mt()}xt(e){const t=e[Symbol.iterator]();let n=t.next();for(;!n.done;)this.Ot(n.value),n=t.next();this.Nt()}Lt(e){for(const t of e){const e=t.charCodeAt(0);if(e<128)this.Ft(e);else if(e<2048)this.Ft(960|e>>>6),this.Ft(128|63&e);else if(t<"\ud800"||"\udbff"<t)this.Ft(480|e>>>12),this.Ft(128|63&e>>>6),this.Ft(128|63&e);else{const e=t.codePointAt(0);this.Ft(240|e>>>18),this.Ft(128|63&e>>>12),this.Ft(128|63&e>>>6),this.Ft(128|63&e)}}this.Mt()}Bt(e){for(const t of e){const e=t.charCodeAt(0);if(e<128)this.Ot(e);else if(e<2048)this.Ot(960|e>>>6),this.Ot(128|63&e);else if(t<"\ud800"||"\udbff"<t)this.Ot(480|e>>>12),this.Ot(128|63&e>>>6),this.Ot(128|63&e);else{const e=t.codePointAt(0);this.Ot(240|e>>>18),this.Ot(128|63&e>>>12),this.Ot(128|63&e>>>6),this.Ot(128|63&e)}}this.Nt()}kt(e){const t=this.qt(e),n=ls(t);this.Qt(1+n),this.buffer[this.position++]=255&n;for(let e=t.length-n;e<t.length;++e)this.buffer[this.position++]=255&t[e]}Kt(e){const t=this.qt(e),n=ls(t);this.Qt(1+n),this.buffer[this.position++]=~(255&n);for(let e=t.length-n;e<t.length;++e)this.buffer[this.position++]=~(255&t[e])}$t(){this.Ut(255),this.Ut(255)}Wt(){this.Gt(255),this.Gt(255)}reset(){this.position=0}seed(e){this.Qt(e.length),this.buffer.set(e,this.position),this.position+=e.length}zt(){return this.buffer.slice(0,this.position)}qt(e){const t=function(e){const t=new DataView(new ArrayBuffer(8));return t.setFloat64(0,e,!1),new Uint8Array(t.buffer)}(e),n=!!(128&t[0]);t[0]^=n?255:128;for(let e=1;e<t.length;++e)t[e]^=n?255:0;return t}Ft(e){const t=255&e;0===t?(this.Ut(0),this.Ut(255)):255===t?(this.Ut(255),this.Ut(0)):this.Ut(t)}Ot(e){const t=255&e;0===t?(this.Gt(0),this.Gt(255)):255===t?(this.Gt(255),this.Gt(0)):this.Gt(e)}Mt(){this.Ut(0),this.Ut(1)}Nt(){this.Gt(0),this.Gt(1)}Ut(e){this.Qt(1),this.buffer[this.position++]=e}Gt(e){this.Qt(1),this.buffer[this.position++]=~e}Qt(e){const t=e+this.position;if(t<=this.buffer.length)return;let n=2*this.buffer.length;n<t&&(n=t);const r=new Uint8Array(n);r.set(this.buffer),this.buffer=r}}class ds{constructor(e){this.jt=e}gt(e){this.jt.Ct(e)}Rt(e){this.jt.Lt(e)}At(e){this.jt.kt(e)}Et(){this.jt.$t()}}class fs{constructor(e){this.jt=e}gt(e){this.jt.xt(e)}Rt(e){this.jt.Bt(e)}At(e){this.jt.Kt(e)}Et(){this.jt.Wt()}}class ps{constructor(){this.jt=new hs,this.Ht=new ds(this.jt),this.Jt=new fs(this.jt)}seed(e){this.jt.seed(e)}Yt(e){return 0===e?this.Ht:this.Jt}zt(){return this.jt.zt()}reset(){this.jt.reset()}}class ms{constructor(e,t,n,r){this.indexId=e,this.documentKey=t,this.arrayValue=n,this.directionalValue=r}Zt(){const e=this.directionalValue.length,t=0===e||255===this.directionalValue[e-1]?e+1:e,n=new Uint8Array(t);return n.set(this.directionalValue,0),t!==e?n.set([0],this.directionalValue.length):++n[n.length-1],new ms(this.indexId,this.documentKey,this.arrayValue,n)}}function gs(e,t){let n=e.indexId-t.indexId;return 0!==n?n:(n=ys(e.arrayValue,t.arrayValue),0!==n?n:(n=ys(e.directionalValue,t.directionalValue),0!==n?n:z.comparator(e.documentKey,t.documentKey)))}function ys(e,t){for(let n=0;n<e.length&&n<t.length;++n){const r=e[n]-t[n];if(0!==r)return r}return e.length-t.length}class vs{constructor(e){this.Xt=new st(((e,t)=>q.comparator(e.field,t.field))),this.collectionId=null!=e.collectionGroup?e.collectionGroup:e.path.lastSegment(),this.en=e.orderBy,this.tn=[];for(const t of e.filters){const e=t;e.isInequality()?this.Xt=this.Xt.add(e):this.tn.push(e)}}get nn(){return this.Xt.size>1}rn(e){if(b(e.collectionGroup===this.collectionId),this.nn)return!1;const t=K(e);if(void 0!==t&&!this.sn(t))return!1;const n=W(e);let r=new Set,i=0,s=0;for(;i<n.length&&this.sn(n[i]);++i)r=r.add(n[i].fieldPath.canonicalString());if(i===n.length)return!0;if(this.Xt.size>0){const e=this.Xt.getIterator().getNext();if(!r.has(e.field.canonicalString())){const t=n[i];if(!this.on(e,t)||!this._n(this.en[s++],t))return!1}++i}for(;i<n.length;++i){const e=n[i];if(s>=this.en.length||!this._n(this.en[s++],e))return!1}return!0}an(){if(this.nn)return null;let e=new st(q.comparator);const t=[];for(const n of this.tn)if(!n.field.isKeyField())if("array-contains"===n.op||"array-contains-any"===n.op)t.push(new H(n.field,2));else{if(e.has(n.field))continue;e=e.add(n.field),t.push(new H(n.field,0))}for(const n of this.en)n.field.isKeyField()||e.has(n.field)||(e=e.add(n.field),t.push(new H(n.field,"asc"===n.dir?0:1)));return new G(G.UNKNOWN_ID,this.collectionId,t,J.empty())}sn(e){for(const t of this.tn)if(this.on(t,e))return!0;return!1}on(e,t){if(void 0===e||!e.field.isEqual(t.fieldPath))return!1;const n="array-contains"===e.op||"array-contains-any"===e.op;return 2===t.kind===n}_n(e,t){return!!e.field.isEqual(t.fieldPath)&&(0===t.kind&&"asc"===e.dir||1===t.kind&&"desc"===e.dir)}}function bs(e){var t,n;if(b(e instanceof en||e instanceof tn),e instanceof en){if(e instanceof gn){const r=(null===(n=null===(t=e.value.arrayValue)||void 0===t?void 0:t.values)||void 0===n?void 0:n.map((t=>en.create(e.field,"==",t))))||[];return tn.create(r,"or")}return e}const r=e.filters.map((e=>bs(e)));return tn.create(r,e.op)}function ws(e){if(0===e.getFilters().length)return[];const t=Ts(bs(e));return b(Es(t)),_s(t)||Is(t)?[t]:t.getFilters()}function _s(e){return e instanceof en}function Is(e){return e instanceof tn&&sn(e)}function Es(e){return _s(e)||Is(e)||function(e){if(e instanceof tn&&rn(e)){for(const t of e.getFilters())if(!_s(t)&&!Is(t))return!1;return!0}return!1}(e)}function Ts(e){if(b(e instanceof en||e instanceof tn),e instanceof en)return e;if(1===e.filters.length)return Ts(e.filters[0]);const t=e.filters.map((e=>Ts(e)));let n=tn.create(t,e.op);return n=As(n),Es(n)?n:(b(n instanceof tn),b(nn(n)),b(n.filters.length>1),n.filters.reduce(((e,t)=>Ss(e,t))))}function Ss(e,t){let n;return b(e instanceof en||e instanceof tn),b(t instanceof en||t instanceof tn),n=e instanceof en?t instanceof en?function(e,t){return tn.create([e,t],"and")}(e,t):Cs(e,t):t instanceof en?Cs(t,e):function(e,t){if(b(e.filters.length>0&&t.filters.length>0),nn(e)&&nn(t))return un(e,t.getFilters());const n=rn(e)?e:t,r=rn(e)?t:e,i=n.filters.map((e=>Ss(e,r)));return tn.create(i,"or")}(e,t),As(n)}function Cs(e,t){if(nn(t))return un(t,e.getFilters());{const n=t.filters.map((t=>Ss(e,t)));return tn.create(n,"or")}}function As(e){if(b(e instanceof en||e instanceof tn),e instanceof en)return e;const t=e.getFilters();if(1===t.length)return As(t[0]);if(on(e))return e;const n=t.map((e=>As(e))),r=[];return n.forEach((t=>{t instanceof en?r.push(t):t instanceof tn&&(t.op===e.op?r.push(...t.filters):r.push(t))})),1===r.length?r[0]:tn.create(r,e.op)}class xs{constructor(){this.un=new ks}addToCollectionParentIndex(e,t){return this.un.add(t),ie.resolve()}getCollectionParents(e,t){return ie.resolve(this.un.getEntries(t))}addFieldIndex(e,t){return ie.resolve()}deleteFieldIndex(e,t){return ie.resolve()}deleteAllFieldIndexes(e){return ie.resolve()}createTargetIndexes(e,t){return ie.resolve()}getDocumentsMatchingTarget(e,t){return ie.resolve(null)}getIndexType(e,t){return ie.resolve(0)}getFieldIndexes(e,t){return ie.resolve([])}getNextCollectionGroupToUpdate(e){return ie.resolve(null)}getMinOffset(e,t){return ie.resolve(Z.min())}getMinOffsetFromCollectionGroup(e,t){return ie.resolve(Z.min())}updateCollectionGroup(e,t,n){return ie.resolve()}updateIndexEntries(e,t){return ie.resolve()}}class ks{constructor(){this.index={}}add(e){const t=e.lastSegment(),n=e.popLast(),r=this.index[t]||new st(j.comparator),i=!r.has(n);return this.index[t]=r.add(n),i}has(e){const t=e.lastSegment(),n=e.popLast(),r=this.index[t];return r&&r.has(n)}getEntries(e){return(this.index[e]||new st(j.comparator)).toArray()}}const Ns=new Uint8Array(0);class Os{constructor(e,t){this.databaseId=t,this.cn=new ks,this.ln=new Kn((e=>_n(e)),((e,t)=>In(e,t))),this.uid=e.uid||""}addToCollectionParentIndex(e,t){if(!this.cn.has(t)){const n=t.lastSegment(),r=t.popLast();e.addOnCommittedListener((()=>{this.cn.add(t)}));const i={collectionId:n,parent:_e(r)};return Ds(e).put(i)}return ie.resolve()}getCollectionParents(e,t){const n=[],r=IDBKeyRange.bound([t,""],[M(t),""],!1,!0);return Ds(e).U(r).next((e=>{for(const r of e){if(r.collectionId!==t)break;n.push(Te(r.parent))}return n}))}addFieldIndex(e,t){const n=Ps(e),r=function(e){return{indexId:e.indexId,collectionGroup:e.collectionGroup,fields:e.fields.map((e=>[e.fieldPath.canonicalString(),e.kind]))}}(t);delete r.indexId;const i=n.add(r);if(t.indexState){const n=Ls(e);return i.next((e=>{n.put(ts(e,this.uid,t.indexState.sequenceNumber,t.indexState.offset))}))}return i.next()}deleteFieldIndex(e,t){const n=Ps(e),r=Ls(e),i=Rs(e);return n.delete(t.indexId).next((()=>r.delete(IDBKeyRange.bound([t.indexId],[t.indexId+1],!1,!0)))).next((()=>i.delete(IDBKeyRange.bound([t.indexId],[t.indexId+1],!1,!0))))}deleteAllFieldIndexes(e){const t=Ps(e),n=Rs(e),r=Ls(e);return t.j().next((()=>n.j())).next((()=>r.j()))}createTargetIndexes(e,t){return ie.forEach(this.hn(t),(t=>this.getIndexType(e,t).next((n=>{if(0===n||1===n){const n=new vs(t).an();if(null!=n)return this.addFieldIndex(e,n)}}))))}getDocumentsMatchingTarget(e,t){const n=Rs(e);let r=!0;const i=new Map;return ie.forEach(this.hn(t),(t=>this.Pn(e,t).next((e=>{r&&(r=!!e),i.set(t,e)})))).next((()=>{if(r){let e=nr();const r=[];return ie.forEach(i,((i,s)=>{p("IndexedDbIndexManager",`Using index ${function(e){return`id=${e.indexId}|cg=${e.collectionGroup}|f=${e.fields.map((e=>`${e.fieldPath}:${e.kind}`)).join(",")}`}(i)} to execute ${_n(t)}`);const o=function(e,t){const n=K(t);if(void 0===n)return null;for(const t of Tn(e,n.fieldPath))switch(t.op){case"array-contains-any":return t.value.arrayValue.values||[];case"array-contains":return[t.value]}return null}(s,i),a=function(e,t){const n=new Map;for(const r of W(t))for(const t of Tn(e,r.fieldPath))switch(t.op){case"==":case"in":n.set(r.fieldPath.canonicalString(),t.value);break;case"not-in":case"!=":return n.set(r.fieldPath.canonicalString(),t.value),Array.from(n.values())}return null}(s,i),c=function(e,t){const n=[];let r=!0;for(const i of W(t)){const t=0===i.kind?Sn(e,i.fieldPath,e.startAt):Cn(e,i.fieldPath,e.startAt);n.push(t.value),r&&(r=t.inclusive)}return new Ht(n,r)}(s,i),u=function(e,t){const n=[];let r=!0;for(const i of W(t)){const t=0===i.kind?Cn(e,i.fieldPath,e.endAt):Sn(e,i.fieldPath,e.endAt);n.push(t.value),r&&(r=t.inclusive)}return new Ht(n,r)}(s,i),l=this.In(i,s,c),h=this.In(i,s,u),d=this.Tn(i,s,a),f=this.En(i.indexId,o,l,c.inclusive,h,u.inclusive,d);return ie.forEach(f,(i=>n.G(i,t.limit).next((t=>{t.forEach((t=>{const n=z.fromSegments(t.documentKey);e.has(n)||(e=e.add(n),r.push(n))}))}))))})).next((()=>r))}return ie.resolve(null)}))}hn(e){let t=this.ln.get(e);return t||(t=0===e.filters.length?[e]:ws(tn.create(e.filters,"and")).map((t=>wn(e.path,e.collectionGroup,e.orderBy,t.getFilters(),e.limit,e.startAt,e.endAt))),this.ln.set(e,t),t)}En(e,t,n,r,i,s,o){const a=(null!=t?t.length:1)*Math.max(n.length,i.length),c=a/(null!=t?t.length:1),u=[];for(let l=0;l<a;++l){const a=t?this.dn(t[l/c]):Ns,h=this.An(e,a,n[l%c],r),d=this.Rn(e,a,i[l%c],s),f=o.map((t=>this.An(e,a,t,!0)));u.push(...this.createRange(h,d,f))}return u}An(e,t,n,r){const i=new ms(e,z.empty(),t,n);return r?i:i.Zt()}Rn(e,t,n,r){const i=new ms(e,z.empty(),t,n);return r?i.Zt():i}Pn(e,t){const n=new vs(t),r=null!=t.collectionGroup?t.collectionGroup:t.path.lastSegment();return this.getFieldIndexes(e,r).next((e=>{let t=null;for(const r of e)n.rn(r)&&(!t||r.fields.length>t.fields.length)&&(t=r);return t}))}getIndexType(e,t){let n=2;const r=this.hn(t);return ie.forEach(r,(t=>this.Pn(e,t).next((e=>{e?0!==n&&e.fields.length<function(e){let t=new st(q.comparator),n=!1;for(const r of e.filters)for(const e of r.getFlattenedFilters())e.field.isKeyField()||("array-contains"===e.op||"array-contains-any"===e.op?n=!0:t=t.add(e.field));for(const n of e.orderBy)n.field.isKeyField()||(t=t.add(n.field));return t.size+(n?1:0)}(t)&&(n=1):n=0})))).next((()=>function(e){return null!==e.limit}(t)&&r.length>1&&2===n?1:n))}Vn(e,t){const n=new ps;for(const r of W(e)){const e=t.data.field(r.fieldPath);if(null==e)return null;const i=n.Yt(r.kind);cs.vt.It(e,i)}return n.zt()}dn(e){const t=new ps;return cs.vt.It(e,t.Yt(0)),t.zt()}mn(e,t){const n=new ps;return cs.vt.It(Ot(this.databaseId,t),n.Yt(function(e){const t=W(e);return 0===t.length?0:t[t.length-1].kind}(e))),n.zt()}Tn(e,t,n){if(null===n)return[];let r=[];r.push(new ps);let i=0;for(const s of W(e)){const e=n[i++];for(const n of r)if(this.fn(t,s.fieldPath)&&Rt(e))r=this.gn(r,s,e);else{const t=n.Yt(s.kind);cs.vt.It(e,t)}}return this.pn(r)}In(e,t,n){return this.Tn(e,t,n.position)}pn(e){const t=[];for(let n=0;n<e.length;++n)t[n]=e[n].zt();return t}gn(e,t,n){const r=[...e],i=[];for(const e of n.arrayValue.values||[])for(const n of r){const r=new ps;r.seed(n.zt()),cs.vt.It(e,r.Yt(t.kind)),i.push(r)}return i}fn(e,t){return!!e.filters.find((e=>e instanceof en&&e.field.isEqual(t)&&("in"===e.op||"not-in"===e.op)))}getFieldIndexes(e,t){const n=Ps(e),r=Ls(e);return(t?n.U("collectionGroupIndex",IDBKeyRange.bound(t,t)):n.U()).next((e=>{const t=[];return ie.forEach(e,(e=>r.get([e.indexId,this.uid]).next((n=>{t.push(function(e,t){const n=t?new J(t.sequenceNumber,new Z(Hi(t.readTime),new z(Te(t.documentKey)),t.largestBatchId)):J.empty(),r=e.fields.map((([e,t])=>new H(q.fromServerFormat(e),t)));return new G(e.indexId,e.collectionGroup,r,n)}(e,n))})))).next((()=>t))}))}getNextCollectionGroupToUpdate(e){return this.getFieldIndexes(e).next((e=>0===e.length?null:(e.sort(((e,t)=>{const n=e.indexState.sequenceNumber-t.indexState.sequenceNumber;return 0!==n?n:P(e.collectionGroup,t.collectionGroup)})),e[0].collectionGroup)))}updateCollectionGroup(e,t,n){const r=Ps(e),i=Ls(e);return this.yn(e).next((e=>r.U("collectionGroupIndex",IDBKeyRange.bound(t,t)).next((t=>ie.forEach(t,(t=>i.put(ts(t.indexId,this.uid,e,n))))))))}updateIndexEntries(e,t){const n=new Map;return ie.forEach(t,((t,r)=>{const i=n.get(t.collectionGroup);return(i?ie.resolve(i):this.getFieldIndexes(e,t.collectionGroup)).next((i=>(n.set(t.collectionGroup,i),ie.forEach(i,(n=>this.wn(e,t,n).next((t=>{const i=this.Sn(r,n);return t.isEqual(i)?ie.resolve():this.bn(e,r,n,t,i)})))))))}))}Dn(e,t,n,r){return Rs(e).put({indexId:r.indexId,uid:this.uid,arrayValue:r.arrayValue,directionalValue:r.directionalValue,orderedDocumentKey:this.mn(n,t.key),documentKey:t.key.path.toArray()})}vn(e,t,n,r){return Rs(e).delete([r.indexId,this.uid,r.arrayValue,r.directionalValue,this.mn(n,t.key),t.key.path.toArray()])}wn(e,t,n){const r=Rs(e);let i=new st(gs);return r.J({index:"documentKeyIndex",range:IDBKeyRange.only([n.indexId,this.uid,this.mn(n,t)])},((e,r)=>{i=i.add(new ms(n.indexId,t,r.arrayValue,r.directionalValue))})).next((()=>i))}Sn(e,t){let n=new st(gs);const r=this.Vn(t,e);if(null==r)return n;const i=K(t);if(null!=i){const s=e.data.field(i.fieldPath);if(Rt(s))for(const i of s.arrayValue.values||[])n=n.add(new ms(t.indexId,e.key,this.dn(i),r))}else n=n.add(new ms(t.indexId,e.key,Ns,r));return n}bn(e,t,n,r,i){p("IndexedDbIndexManager","Updating index entries for document '%s'",t.key);const s=[];return function(e,t,n,r,i){const s=e.getIterator(),o=t.getIterator();let a=at(s),c=at(o);for(;a||c;){let e=!1,t=!1;if(a&&c){const r=n(a,c);r<0?t=!0:r>0&&(e=!0)}else null!=a?t=!0:e=!0;e?(r(c),c=at(o)):t?(i(a),a=at(s)):(a=at(s),c=at(o))}}(r,i,gs,(r=>{s.push(this.Dn(e,t,n,r))}),(r=>{s.push(this.vn(e,t,n,r))})),ie.waitFor(s)}yn(e){let t=1;return Ls(e).J({index:"sequenceNumberIndex",reverse:!0,range:IDBKeyRange.upperBound([this.uid,Number.MAX_SAFE_INTEGER])},((e,n,r)=>{r.done(),t=n.sequenceNumber+1})).next((()=>t))}createRange(e,t,n){n=n.sort(((e,t)=>gs(e,t))).filter(((e,t,n)=>!t||0!==gs(e,n[t-1])));const r=[];r.push(e);for(const i of n){const n=gs(i,e),s=gs(i,t);if(0===n)r[0]=e.Zt();else if(n>0&&s<0)r.push(i),r.push(i.Zt());else if(s>0)break}r.push(t);const i=[];for(let e=0;e<r.length;e+=2){if(this.Cn(r[e],r[e+1]))return[];const t=[r[e].indexId,this.uid,r[e].arrayValue,r[e].directionalValue,Ns,[]],n=[r[e+1].indexId,this.uid,r[e+1].arrayValue,r[e+1].directionalValue,Ns,[]];i.push(IDBKeyRange.bound(t,n))}return i}Cn(e,t){return gs(e,t)>0}getMinOffsetFromCollectionGroup(e,t){return this.getFieldIndexes(e,t).next(Ms)}getMinOffset(e,t){return ie.mapArray(this.hn(t),(t=>this.Pn(e,t).next((e=>e||v())))).next(Ms)}}function Ds(e){return Ye(e,"collectionParents")}function Rs(e){return Ye(e,"indexEntries")}function Ps(e){return Ye(e,"indexConfiguration")}function Ls(e){return Ye(e,"indexState")}function Ms(e){b(0!==e.length);let t=e[0].indexState.offset,n=t.largestBatchId;for(let r=1;r<e.length;r++){const i=e[r].indexState.offset;ee(i,t)<0&&(t=i),n<i.largestBatchId&&(n=i.largestBatchId)}return new Z(t.readTime,t.documentKey,n)}const Fs={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0};class Vs{constructor(e,t,n){this.cacheSizeCollectionThreshold=e,this.percentileToCollect=t,this.maximumSequenceNumbersToCollect=n}static withCacheSize(e){return new Vs(e,Vs.DEFAULT_COLLECTION_PERCENTILE,Vs.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}}function Us(e,t,n){const r=e.store("mutations"),i=e.store("documentMutations"),s=[],o=IDBKeyRange.only(n.batchId);let a=0;const c=r.J({range:o},((e,t,n)=>(a++,n.delete())));s.push(c.next((()=>{b(1===a)})));const u=[];for(const e of n.mutations){const r=Ae(t,e.key.path,n.batchId);s.push(i.delete(r)),u.push(e.key)}return ie.waitFor(s).next((()=>u))}function js(e){if(!e)return 0;let t;if(e.document)t=e.document;else if(e.unknownDocument)t=e.unknownDocument;else{if(!e.noDocument)throw v();t=e.noDocument}return JSON.stringify(t).length}Vs.DEFAULT_COLLECTION_PERCENTILE=10,Vs.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,Vs.DEFAULT=new Vs(41943040,Vs.DEFAULT_COLLECTION_PERCENTILE,Vs.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),Vs.DISABLED=new Vs(-1,0,0);class Bs{constructor(e,t,n,r){this.userId=e,this.serializer=t,this.indexManager=n,this.referenceDelegate=r,this.Fn={}}static lt(e,t,n,r){b(""!==e.uid);const i=e.isAuthenticated()?e.uid:"";return new Bs(i,t,n,r)}checkEmpty(e){let t=!0;const n=IDBKeyRange.bound([this.userId,Number.NEGATIVE_INFINITY],[this.userId,Number.POSITIVE_INFINITY]);return zs(e).J({index:"userMutationsIndex",range:n},((e,n,r)=>{t=!1,r.done()})).next((()=>t))}addMutationBatch(e,t,n,r){const i=Gs(e),s=zs(e);return s.add({}).next((o=>{b("number"==typeof o);const a=new Fr(o,t,n,r),c=function(e,t,n){const r=n.baseMutations.map((t=>xi(e.ct,t))),i=n.mutations.map((t=>xi(e.ct,t)));return{userId:t,batchId:n.batchId,localWriteTimeMs:n.localWriteTime.toMillis(),baseMutations:r,mutations:i}}(this.serializer,this.userId,a),u=[];let l=new st(((e,t)=>P(e.canonicalString(),t.canonicalString())));for(const e of r){const t=Ae(this.userId,e.key.path,o);l=l.add(e.key.path.popLast()),u.push(s.put(c)),u.push(i.put(t,xe))}return l.forEach((t=>{u.push(this.indexManager.addToCollectionParentIndex(e,t))})),e.addOnCommittedListener((()=>{this.Fn[o]=a.keys()})),ie.waitFor(u).next((()=>a))}))}lookupMutationBatch(e,t){return zs(e).get(t).next((e=>e?(b(e.userId===this.userId),Qi(this.serializer,e)):null))}Mn(e,t){return this.Fn[t]?ie.resolve(this.Fn[t]):this.lookupMutationBatch(e,t).next((e=>{if(e){const n=e.keys();return this.Fn[t]=n,n}return null}))}getNextMutationBatchAfterBatchId(e,t){const n=t+1,r=IDBKeyRange.lowerBound([this.userId,n]);let i=null;return zs(e).J({index:"userMutationsIndex",range:r},((e,t,r)=>{t.userId===this.userId&&(b(t.batchId>=n),i=Qi(this.serializer,t)),r.done()})).next((()=>i))}getHighestUnacknowledgedBatchId(e){const t=IDBKeyRange.upperBound([this.userId,Number.POSITIVE_INFINITY]);let n=-1;return zs(e).J({index:"userMutationsIndex",range:t,reverse:!0},((e,t,r)=>{n=t.batchId,r.done()})).next((()=>n))}getAllMutationBatches(e){const t=IDBKeyRange.bound([this.userId,-1],[this.userId,Number.POSITIVE_INFINITY]);return zs(e).U("userMutationsIndex",t).next((e=>e.map((e=>Qi(this.serializer,e)))))}getAllMutationBatchesAffectingDocumentKey(e,t){const n=Ce(this.userId,t.path),r=IDBKeyRange.lowerBound(n),i=[];return Gs(e).J({range:r},((n,r,s)=>{const[o,a,c]=n,u=Te(a);if(o===this.userId&&t.path.isEqual(u))return zs(e).get(c).next((e=>{if(!e)throw v();b(e.userId===this.userId),i.push(Qi(this.serializer,e))}));s.done()})).next((()=>i))}getAllMutationBatchesAffectingDocumentKeys(e,t){let n=new st(P);const r=[];return t.forEach((t=>{const i=Ce(this.userId,t.path),s=IDBKeyRange.lowerBound(i),o=Gs(e).J({range:s},((e,r,i)=>{const[s,o,a]=e,c=Te(o);s===this.userId&&t.path.isEqual(c)?n=n.add(a):i.done()}));r.push(o)})),ie.waitFor(r).next((()=>this.xn(e,n)))}getAllMutationBatchesAffectingQuery(e,t){const n=t.path,r=n.length+1,i=Ce(this.userId,n),s=IDBKeyRange.lowerBound(i);let o=new st(P);return Gs(e).J({range:s},((e,t,i)=>{const[s,a,c]=e,u=Te(a);s===this.userId&&n.isPrefixOf(u)?u.length===r&&(o=o.add(c)):i.done()})).next((()=>this.xn(e,o)))}xn(e,t){const n=[],r=[];return t.forEach((t=>{r.push(zs(e).get(t).next((e=>{if(null===e)throw v();b(e.userId===this.userId),n.push(Qi(this.serializer,e))})))})),ie.waitFor(r).next((()=>n))}removeMutationBatch(e,t){return Us(e._e,this.userId,t).next((n=>(e.addOnCommittedListener((()=>{this.On(t.batchId)})),ie.forEach(n,(t=>this.referenceDelegate.markPotentiallyOrphaned(e,t))))))}On(e){delete this.Fn[e]}performConsistencyCheck(e){return this.checkEmpty(e).next((t=>{if(!t)return ie.resolve();const n=IDBKeyRange.lowerBound(function(e){return[e]}(this.userId)),r=[];return Gs(e).J({range:n},((e,t,n)=>{if(e[0]===this.userId){const t=Te(e[1]);r.push(t)}else n.done()})).next((()=>{b(0===r.length)}))}))}containsKey(e,t){return qs(e,this.userId,t)}Nn(e){return Ks(e).get(this.userId).next((e=>e||{userId:this.userId,lastAcknowledgedBatchId:-1,lastStreamToken:""}))}}function qs(e,t,n){const r=Ce(t,n.path),i=r[1],s=IDBKeyRange.lowerBound(r);let o=!1;return Gs(e).J({range:s,H:!0},((e,n,r)=>{const[s,a,c]=e;s===t&&a===i&&(o=!0),r.done()})).next((()=>o))}function zs(e){return Ye(e,"mutations")}function Gs(e){return Ye(e,"documentMutations")}function Ks(e){return Ye(e,"mutationQueues")}class Ws{constructor(e){this.Ln=e}next(){return this.Ln+=2,this.Ln}static Bn(){return new Ws(0)}static kn(){return new Ws(-1)}}class $s{constructor(e,t){this.referenceDelegate=e,this.serializer=t}allocateTargetId(e){return this.qn(e).next((t=>{const n=new Ws(t.highestTargetId);return t.highestTargetId=n.next(),this.Qn(e,t).next((()=>t.highestTargetId))}))}getLastRemoteSnapshotVersion(e){return this.qn(e).next((e=>V.fromTimestamp(new F(e.lastRemoteSnapshotVersion.seconds,e.lastRemoteSnapshotVersion.nanoseconds))))}getHighestSequenceNumber(e){return this.qn(e).next((e=>e.highestListenSequenceNumber))}setTargetsMetadata(e,t,n){return this.qn(e).next((r=>(r.highestListenSequenceNumber=t,n&&(r.lastRemoteSnapshotVersion=n.toTimestamp()),t>r.highestListenSequenceNumber&&(r.highestListenSequenceNumber=t),this.Qn(e,r))))}addTargetData(e,t){return this.Kn(e,t).next((()=>this.qn(e).next((n=>(n.targetCount+=1,this.$n(t,n),this.Qn(e,n))))))}updateTargetData(e,t){return this.Kn(e,t)}removeTargetData(e,t){return this.removeMatchingKeysForTargetId(e,t.targetId).next((()=>Hs(e).delete(t.targetId))).next((()=>this.qn(e))).next((t=>(b(t.targetCount>0),t.targetCount-=1,this.Qn(e,t))))}removeTargets(e,t,n){let r=0;const i=[];return Hs(e).J(((s,o)=>{const a=Ji(o);a.sequenceNumber<=t&&null===n.get(a.targetId)&&(r++,i.push(this.removeTargetData(e,a)))})).next((()=>ie.waitFor(i))).next((()=>r))}forEachTarget(e,t){return Hs(e).J(((e,n)=>{const r=Ji(n);t(r)}))}qn(e){return Qs(e).get("targetGlobalKey").next((e=>(b(null!==e),e)))}Qn(e,t){return Qs(e).put("targetGlobalKey",t)}Kn(e,t){return Hs(e).put(Yi(this.serializer,t))}$n(e,t){let n=!1;return e.targetId>t.highestTargetId&&(t.highestTargetId=e.targetId,n=!0),e.sequenceNumber>t.highestListenSequenceNumber&&(t.highestListenSequenceNumber=e.sequenceNumber,n=!0),n}getTargetCount(e){return this.qn(e).next((e=>e.targetCount))}getTargetData(e,t){const n=_n(t),r=IDBKeyRange.bound([n,Number.NEGATIVE_INFINITY],[n,Number.POSITIVE_INFINITY]);let i=null;return Hs(e).J({range:r,index:"queryTargetsIndex"},((e,n,r)=>{const s=Ji(n);In(t,s.target)&&(i=s,r.done())})).next((()=>i))}addMatchingKeys(e,t,n){const r=[],i=Js(e);return t.forEach((t=>{const s=_e(t.path);r.push(i.put({targetId:n,path:s})),r.push(this.referenceDelegate.addReference(e,n,t))})),ie.waitFor(r)}removeMatchingKeys(e,t,n){const r=Js(e);return ie.forEach(t,(t=>{const i=_e(t.path);return ie.waitFor([r.delete([n,i]),this.referenceDelegate.removeReference(e,n,t)])}))}removeMatchingKeysForTargetId(e,t){const n=Js(e),r=IDBKeyRange.bound([t],[t+1],!1,!0);return n.delete(r)}getMatchingKeysForTargetId(e,t){const n=IDBKeyRange.bound([t],[t+1],!1,!0),r=Js(e);let i=nr();return r.J({range:n,H:!0},((e,t,n)=>{const r=Te(e[1]),s=new z(r);i=i.add(s)})).next((()=>i))}containsKey(e,t){const n=_e(t.path),r=IDBKeyRange.bound([n],[M(n)],!1,!0);let i=0;return Js(e).J({index:"documentTargetsIndex",H:!0,range:r},(([e,t],n,r)=>{0!==e&&(i++,r.done())})).next((()=>i>0))}ot(e,t){return Hs(e).get(t).next((e=>e?Ji(e):null))}}function Hs(e){return Ye(e,"targets")}function Qs(e){return Ye(e,"targetGlobal")}function Js(e){return Ye(e,"targetDocuments")}function Ys([e,t],[n,r]){const i=P(e,n);return 0===i?P(t,r):i}class Xs{constructor(e){this.Un=e,this.buffer=new st(Ys),this.Wn=0}Gn(){return++this.Wn}zn(e){const t=[e,this.Gn()];if(this.buffer.size<this.Un)this.buffer=this.buffer.add(t);else{const e=this.buffer.last();Ys(t,e)<0&&(this.buffer=this.buffer.delete(e).add(t))}}get maxValue(){return this.buffer.last()[0]}}class Zs{constructor(e,t,n){this.garbageCollector=e,this.asyncQueue=t,this.localStore=n,this.jn=null}start(){-1!==this.garbageCollector.params.cacheSizeCollectionThreshold&&this.Hn(6e4)}stop(){this.jn&&(this.jn.cancel(),this.jn=null)}get started(){return null!==this.jn}Hn(e){p("LruGarbageCollector",`Garbage collection scheduled in ${e}ms`),this.jn=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",e,(async()=>{this.jn=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(e){le(e)?p("LruGarbageCollector","Ignoring IndexedDB error during garbage collection: ",e):await re(e)}await this.Hn(3e5)}))}}class eo{constructor(e,t){this.Jn=e,this.params=t}calculateTargetCount(e,t){return this.Jn.Yn(e).next((e=>Math.floor(t/100*e)))}nthSequenceNumber(e,t){if(0===t)return ie.resolve(ye.oe);const n=new Xs(t);return this.Jn.forEachTarget(e,(e=>n.zn(e.sequenceNumber))).next((()=>this.Jn.Zn(e,(e=>n.zn(e))))).next((()=>n.maxValue))}removeTargets(e,t,n){return this.Jn.removeTargets(e,t,n)}removeOrphanedDocuments(e,t){return this.Jn.removeOrphanedDocuments(e,t)}collect(e,t){return-1===this.params.cacheSizeCollectionThreshold?(p("LruGarbageCollector","Garbage collection skipped; disabled"),ie.resolve(Fs)):this.getCacheSize(e).next((n=>n<this.params.cacheSizeCollectionThreshold?(p("LruGarbageCollector",`Garbage collection skipped; Cache size ${n} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),Fs):this.Xn(e,t)))}getCacheSize(e){return this.Jn.getCacheSize(e)}Xn(e,t){let n,r,i,o,a,c,u;const l=Date.now();return this.calculateTargetCount(e,this.params.percentileToCollect).next((t=>(t>this.params.maximumSequenceNumbersToCollect?(p("LruGarbageCollector",`Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${t}`),r=this.params.maximumSequenceNumbersToCollect):r=t,o=Date.now(),this.nthSequenceNumber(e,r)))).next((r=>(n=r,a=Date.now(),this.removeTargets(e,n,t)))).next((t=>(i=t,c=Date.now(),this.removeOrphanedDocuments(e,n)))).next((e=>(u=Date.now(),f()<=s.LogLevel.DEBUG&&p("LruGarbageCollector",`LRU Garbage Collection\n\tCounted targets in ${o-l}ms\n\tDetermined least recently used ${r} in `+(a-o)+"ms\n"+`\tRemoved ${i} targets in `+(c-a)+"ms\n"+`\tRemoved ${e} documents in `+(u-c)+"ms\n"+`Total Duration: ${u-l}ms`),ie.resolve({didRun:!0,sequenceNumbersCollected:r,targetsRemoved:i,documentsRemoved:e}))))}}function to(e,t){return new eo(e,t)}class no{constructor(e,t){this.db=e,this.garbageCollector=to(this,t)}Yn(e){const t=this.er(e);return this.db.getTargetCache().getTargetCount(e).next((e=>t.next((t=>e+t))))}er(e){let t=0;return this.Zn(e,(e=>{t++})).next((()=>t))}forEachTarget(e,t){return this.db.getTargetCache().forEachTarget(e,t)}Zn(e,t){return this.tr(e,((e,n)=>t(n)))}addReference(e,t,n){return ro(e,n)}removeReference(e,t,n){return ro(e,n)}removeTargets(e,t,n){return this.db.getTargetCache().removeTargets(e,t,n)}markPotentiallyOrphaned(e,t){return ro(e,t)}nr(e,t){return function(e,t){let n=!1;return Ks(e).Y((r=>qs(e,r,t).next((e=>(e&&(n=!0),ie.resolve(!e)))))).next((()=>n))}(e,t)}removeOrphanedDocuments(e,t){const n=this.db.getRemoteDocumentCache().newChangeBuffer(),r=[];let i=0;return this.tr(e,((s,o)=>{if(o<=t){const t=this.nr(e,s).next((t=>{if(!t)return i++,n.getEntry(e,s).next((()=>(n.removeEntry(s,V.min()),Js(e).delete(function(e){return[0,_e(e.path)]}(s)))))}));r.push(t)}})).next((()=>ie.waitFor(r))).next((()=>n.apply(e))).next((()=>i))}removeTarget(e,t){const n=t.withSequenceNumber(e.currentSequenceNumber);return this.db.getTargetCache().updateTargetData(e,n)}updateLimboDocument(e,t){return ro(e,t)}tr(e,t){const n=Js(e);let r,i=ye.oe;return n.J({index:"documentTargetsIndex"},(([e,n],{path:s,sequenceNumber:o})=>{0===e?(i!==ye.oe&&t(new z(Te(r)),i),i=o,r=s):i=ye.oe})).next((()=>{i!==ye.oe&&t(new z(Te(r)),i)}))}getCacheSize(e){return this.db.getRemoteDocumentCache().getSize(e)}}function ro(e,t){return Js(e).put(function(e,t){return{targetId:0,path:_e(e.path),sequenceNumber:t}}(t,e.currentSequenceNumber))}class io{constructor(){this.changes=new Kn((e=>e.toString()),((e,t)=>e.isEqual(t))),this.changesApplied=!1}addEntry(e){this.assertNotApplied(),this.changes.set(e.key,e)}removeEntry(e,t){this.assertNotApplied(),this.changes.set(e,$t.newInvalidDocument(e).setReadTime(t))}getEntry(e,t){this.assertNotApplied();const n=this.changes.get(t);return void 0!==n?ie.resolve(n):this.getFromCache(e,t)}getEntries(e,t){return this.getAllFromCache(e,t)}apply(e){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(e)}assertNotApplied(){}}class so{constructor(e){this.serializer=e}setIndexManager(e){this.indexManager=e}addEntry(e,t,n){return uo(e).put(n)}removeEntry(e,t,n){return uo(e).delete(function(e,t){const n=e.path.toArray();return[n.slice(0,n.length-2),n[n.length-2],Wi(t),n[n.length-1]]}(t,n))}updateMetadata(e,t){return this.getMetadata(e).next((n=>(n.byteSize+=t,this.rr(e,n))))}getEntry(e,t){let n=$t.newInvalidDocument(t);return uo(e).J({index:"documentKeyIndex",range:IDBKeyRange.only(lo(t))},((e,r)=>{n=this.ir(t,r)})).next((()=>n))}sr(e,t){let n={size:0,document:$t.newInvalidDocument(t)};return uo(e).J({index:"documentKeyIndex",range:IDBKeyRange.only(lo(t))},((e,r)=>{n={document:this.ir(t,r),size:js(r)}})).next((()=>n))}getEntries(e,t){let n=$n();return this._r(e,t,((e,t)=>{const r=this.ir(e,t);n=n.insert(e,r)})).next((()=>n))}ar(e,t){let n=$n(),r=new nt(z.comparator);return this._r(e,t,((e,t)=>{const i=this.ir(e,t);n=n.insert(e,i),r=r.insert(e,js(t))})).next((()=>({documents:n,ur:r})))}_r(e,t,n){if(t.isEmpty())return ie.resolve();let r=new st(fo);t.forEach((e=>r=r.add(e)));const i=IDBKeyRange.bound(lo(r.first()),lo(r.last())),s=r.getIterator();let o=s.getNext();return uo(e).J({index:"documentKeyIndex",range:i},((e,t,r)=>{const i=z.fromSegments([...t.prefixPath,t.collectionGroup,t.documentId]);for(;o&&fo(o,i)<0;)n(o,null),o=s.getNext();o&&o.isEqual(i)&&(n(o,t),o=s.hasNext()?s.getNext():null),o?r.$(lo(o)):r.done()})).next((()=>{for(;o;)n(o,null),o=s.hasNext()?s.getNext():null}))}getDocumentsMatchingQuery(e,t,n,r,i){const s=t.path,o=[s.popLast().toArray(),s.lastSegment(),Wi(n.readTime),n.documentKey.path.isEmpty()?"":n.documentKey.path.lastSegment()],a=[s.popLast().toArray(),s.lastSegment(),[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],""];return uo(e).U(IDBKeyRange.bound(o,a,!0)).next((e=>{null==i||i.incrementDocumentReadCount(e.length);let n=$n();for(const i of e){const e=this.ir(z.fromSegments(i.prefixPath.concat(i.collectionGroup,i.documentId)),i);e.isFoundDocument()&&(Bn(t,e)||r.has(e.key))&&(n=n.insert(e.key,e))}return n}))}getAllFromCollectionGroup(e,t,n,r){let i=$n();const s=ho(t,n),o=ho(t,Z.max());return uo(e).J({index:"collectionGroupIndex",range:IDBKeyRange.bound(s,o,!0)},((e,t,n)=>{const s=this.ir(z.fromSegments(t.prefixPath.concat(t.collectionGroup,t.documentId)),t);i=i.insert(s.key,s),i.size===r&&n.done()})).next((()=>i))}newChangeBuffer(e){return new ao(this,!!e&&e.trackRemovals)}getSize(e){return this.getMetadata(e).next((e=>e.byteSize))}getMetadata(e){return co(e).get("remoteDocumentGlobalKey").next((e=>(b(!!e),e)))}rr(e,t){return co(e).put("remoteDocumentGlobalKey",t)}ir(e,t){if(t){const e=function(e,t){let n;if(t.document)n=Ai(e.ct,t.document,!!t.hasCommittedMutations);else if(t.noDocument){const e=z.fromSegments(t.noDocument.path),r=Hi(t.noDocument.readTime);n=$t.newNoDocument(e,r),t.hasCommittedMutations&&n.setHasCommittedMutations()}else{if(!t.unknownDocument)return v();{const e=z.fromSegments(t.unknownDocument.path),r=Hi(t.unknownDocument.version);n=$t.newUnknownDocument(e,r)}}return t.readTime&&n.setReadTime(function(e){const t=new F(e[0],e[1]);return V.fromTimestamp(t)}(t.readTime)),n}(this.serializer,t);if(!e.isNoDocument()||!e.version.isEqual(V.min()))return e}return $t.newInvalidDocument(e)}}function oo(e){return new so(e)}class ao extends io{constructor(e,t){super(),this.cr=e,this.trackRemovals=t,this.lr=new Kn((e=>e.toString()),((e,t)=>e.isEqual(t)))}applyChanges(e){const t=[];let n=0,r=new st(((e,t)=>P(e.canonicalString(),t.canonicalString())));return this.changes.forEach(((i,s)=>{const o=this.lr.get(i);if(t.push(this.cr.removeEntry(e,i,o.readTime)),s.isValidDocument()){const a=Ki(this.cr.serializer,s);r=r.add(i.path.popLast());const c=js(a);n+=c-o.size,t.push(this.cr.addEntry(e,i,a))}else if(n-=o.size,this.trackRemovals){const n=Ki(this.cr.serializer,s.convertToNoDocument(V.min()));t.push(this.cr.addEntry(e,i,n))}})),r.forEach((n=>{t.push(this.cr.indexManager.addToCollectionParentIndex(e,n))})),t.push(this.cr.updateMetadata(e,n)),ie.waitFor(t)}getFromCache(e,t){return this.cr.sr(e,t).next((e=>(this.lr.set(t,{size:e.size,readTime:e.document.readTime}),e.document)))}getAllFromCache(e,t){return this.cr.ar(e,t).next((({documents:e,ur:t})=>(t.forEach(((t,n)=>{this.lr.set(t,{size:n,readTime:e.get(t).readTime})})),e)))}}function co(e){return Ye(e,"remoteDocumentGlobal")}function uo(e){return Ye(e,"remoteDocumentsV14")}function lo(e){const t=e.path.toArray();return[t.slice(0,t.length-2),t[t.length-2],t[t.length-1]]}function ho(e,t){const n=t.documentKey.path.toArray();return[e,Wi(t.readTime),n.slice(0,n.length-2),n.length>0?n[n.length-1]:""]}function fo(e,t){const n=e.path.toArray(),r=t.path.toArray();let i=0;for(let e=0;e<n.length-2&&e<r.length-2;++e)if(i=P(n[e],r[e]),i)return i;return i=P(n.length,r.length),i||(i=P(n[n.length-2],r[r.length-2]),i||P(n[n.length-1],r[r.length-1]))}class po{constructor(e,t){this.overlayedDocument=e,this.mutatedFields=t}}class mo{constructor(e,t,n,r){this.remoteDocumentCache=e,this.mutationQueue=t,this.documentOverlayCache=n,this.indexManager=r}getDocument(e,t){let n=null;return this.documentOverlayCache.getOverlay(e,t).next((r=>(n=r,this.remoteDocumentCache.getEntry(e,t)))).next((e=>(null!==n&&Ar(n.mutation,e,ct.empty(),F.now()),e)))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next((t=>this.getLocalViewOfDocuments(e,t,nr()).next((()=>t))))}getLocalViewOfDocuments(e,t,n=nr()){const r=Yn();return this.populateOverlays(e,r,t).next((()=>this.computeViews(e,t,r,n).next((e=>{let t=Qn();return e.forEach(((e,n)=>{t=t.insert(e,n.overlayedDocument)})),t}))))}getOverlayedDocuments(e,t){const n=Yn();return this.populateOverlays(e,n,t).next((()=>this.computeViews(e,t,n,nr())))}populateOverlays(e,t,n){const r=[];return n.forEach((e=>{t.has(e)||r.push(e)})),this.documentOverlayCache.getOverlays(e,r).next((e=>{e.forEach(((e,n)=>{t.set(e,n)}))}))}computeViews(e,t,n,r){let i=$n();const s=Zn(),o=Zn();return t.forEach(((e,t)=>{const o=n.get(t.key);r.has(t.key)&&(void 0===o||o.mutation instanceof Or)?i=i.insert(t.key,t):void 0!==o?(s.set(t.key,o.mutation.getFieldMask()),Ar(o.mutation,t,o.mutation.getFieldMask(),F.now())):s.set(t.key,ct.empty())})),this.recalculateAndSaveOverlays(e,i).next((e=>(e.forEach(((e,t)=>s.set(e,t))),t.forEach(((e,t)=>{var n;return o.set(e,new po(t,null!==(n=s.get(e))&&void 0!==n?n:null))})),o)))}recalculateAndSaveOverlays(e,t){const n=Zn();let r=new nt(((e,t)=>e-t)),i=nr();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,t).next((e=>{for(const i of e)i.keys().forEach((e=>{const s=t.get(e);if(null===s)return;let o=n.get(e)||ct.empty();o=i.applyToLocalView(s,o),n.set(e,o);const a=(r.get(i.batchId)||nr()).add(e);r=r.insert(i.batchId,a)}))})).next((()=>{const s=[],o=r.getReverseIterator();for(;o.hasNext();){const r=o.getNext(),a=r.key,c=r.value,u=Xn();c.forEach((e=>{if(!i.has(e)){const r=Sr(t.get(e),n.get(e));null!==r&&u.set(e,r),i=i.add(e)}})),s.push(this.documentOverlayCache.saveOverlays(e,a,u))}return ie.waitFor(s)})).next((()=>n))}recalculateAndSaveOverlaysForDocumentKeys(e,t){return this.remoteDocumentCache.getEntries(e,t).next((t=>this.recalculateAndSaveOverlays(e,t)))}getDocumentsMatchingQuery(e,t,n,r){return function(e){return z.isDocumentKey(e.path)&&null===e.collectionGroup&&0===e.filters.length}(t)?this.getDocumentsMatchingDocumentQuery(e,t.path):On(t)?this.getDocumentsMatchingCollectionGroupQuery(e,t,n,r):this.getDocumentsMatchingCollectionQuery(e,t,n,r)}getNextDocuments(e,t,n,r){return this.remoteDocumentCache.getAllFromCollectionGroup(e,t,n,r).next((i=>{const s=r-i.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(e,t,n.largestBatchId,r-i.size):ie.resolve(Yn());let o=-1,a=i;return s.next((t=>ie.forEach(t,((t,n)=>(o<n.largestBatchId&&(o=n.largestBatchId),i.get(t)?ie.resolve():this.remoteDocumentCache.getEntry(e,t).next((e=>{a=a.insert(t,e)}))))).next((()=>this.populateOverlays(e,t,i))).next((()=>this.computeViews(e,a,t,nr()))).next((e=>({batchId:o,changes:Jn(e)})))))}))}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new z(t)).next((e=>{let t=Qn();return e.isFoundDocument()&&(t=t.insert(e.key,e)),t}))}getDocumentsMatchingCollectionGroupQuery(e,t,n,r){const i=t.collectionGroup;let s=Qn();return this.indexManager.getCollectionParents(e,i).next((o=>ie.forEach(o,(o=>{const a=function(e,t){return new An(t,null,e.explicitOrderBy.slice(),e.filters.slice(),e.limit,e.limitType,e.startAt,e.endAt)}(t,o.child(i));return this.getDocumentsMatchingCollectionQuery(e,a,n,r).next((e=>{e.forEach(((e,t)=>{s=s.insert(e,t)}))}))})).next((()=>s))))}getDocumentsMatchingCollectionQuery(e,t,n,r){let i;return this.documentOverlayCache.getOverlaysForCollection(e,t.path,n.largestBatchId).next((s=>(i=s,this.remoteDocumentCache.getDocumentsMatchingQuery(e,t,n,i,r)))).next((e=>{i.forEach(((t,n)=>{const r=n.getKey();null===e.get(r)&&(e=e.insert(r,$t.newInvalidDocument(r)))}));let n=Qn();return e.forEach(((e,r)=>{const s=i.get(e);void 0!==s&&Ar(s.mutation,r,ct.empty(),F.now()),Bn(t,r)&&(n=n.insert(e,r))})),n}))}}class go{constructor(e){this.serializer=e,this.hr=new Map,this.Pr=new Map}getBundleMetadata(e,t){return ie.resolve(this.hr.get(t))}saveBundleMetadata(e,t){return this.hr.set(t.id,function(e){return{id:e.id,version:e.version,createTime:gi(e.createTime)}}(t)),ie.resolve()}getNamedQuery(e,t){return ie.resolve(this.Pr.get(t))}saveNamedQuery(e,t){return this.Pr.set(t.name,function(e){return{name:e.name,query:Xi(e.bundledQuery),readTime:gi(e.readTime)}}(t)),ie.resolve()}}class yo{constructor(){this.overlays=new nt(z.comparator),this.Ir=new Map}getOverlay(e,t){return ie.resolve(this.overlays.get(t))}getOverlays(e,t){const n=Yn();return ie.forEach(t,(t=>this.getOverlay(e,t).next((e=>{null!==e&&n.set(t,e)})))).next((()=>n))}saveOverlays(e,t,n){return n.forEach(((n,r)=>{this.ht(e,t,r)})),ie.resolve()}removeOverlaysForBatchId(e,t,n){const r=this.Ir.get(n);return void 0!==r&&(r.forEach((e=>this.overlays=this.overlays.remove(e))),this.Ir.delete(n)),ie.resolve()}getOverlaysForCollection(e,t,n){const r=Yn(),i=t.length+1,s=new z(t.child("")),o=this.overlays.getIteratorFrom(s);for(;o.hasNext();){const e=o.getNext().value,s=e.getKey();if(!t.isPrefixOf(s.path))break;s.path.length===i&&e.largestBatchId>n&&r.set(e.getKey(),e)}return ie.resolve(r)}getOverlaysForCollectionGroup(e,t,n,r){let i=new nt(((e,t)=>e-t));const s=this.overlays.getIterator();for(;s.hasNext();){const e=s.getNext().value;if(e.getKey().getCollectionGroup()===t&&e.largestBatchId>n){let t=i.get(e.largestBatchId);null===t&&(t=Yn(),i=i.insert(e.largestBatchId,t)),t.set(e.getKey(),e)}}const o=Yn(),a=i.getIterator();for(;a.hasNext()&&(a.getNext().value.forEach(((e,t)=>o.set(e,t))),!(o.size()>=r)););return ie.resolve(o)}ht(e,t,n){const r=this.overlays.get(n.key);if(null!==r){const e=this.Ir.get(r.largestBatchId).delete(n.key);this.Ir.set(r.largestBatchId,e)}this.overlays=this.overlays.insert(n.key,new Ur(t,n));let i=this.Ir.get(t);void 0===i&&(i=nr(),this.Ir.set(t,i)),this.Ir.set(t,i.add(n.key))}}class vo{constructor(){this.sessionToken=lt.EMPTY_BYTE_STRING}getSessionToken(e){return ie.resolve(this.sessionToken)}setSessionToken(e,t){return this.sessionToken=t,ie.resolve()}}class bo{constructor(){this.Tr=new st(wo.Er),this.dr=new st(wo.Ar)}isEmpty(){return this.Tr.isEmpty()}addReference(e,t){const n=new wo(e,t);this.Tr=this.Tr.add(n),this.dr=this.dr.add(n)}Rr(e,t){e.forEach((e=>this.addReference(e,t)))}removeReference(e,t){this.Vr(new wo(e,t))}mr(e,t){e.forEach((e=>this.removeReference(e,t)))}gr(e){const t=new z(new j([])),n=new wo(t,e),r=new wo(t,e+1),i=[];return this.dr.forEachInRange([n,r],(e=>{this.Vr(e),i.push(e.key)})),i}pr(){this.Tr.forEach((e=>this.Vr(e)))}Vr(e){this.Tr=this.Tr.delete(e),this.dr=this.dr.delete(e)}yr(e){const t=new z(new j([])),n=new wo(t,e),r=new wo(t,e+1);let i=nr();return this.dr.forEachInRange([n,r],(e=>{i=i.add(e.key)})),i}containsKey(e){const t=new wo(e,0),n=this.Tr.firstAfterOrEqual(t);return null!==n&&e.isEqual(n.key)}}class wo{constructor(e,t){this.key=e,this.wr=t}static Er(e,t){return z.comparator(e.key,t.key)||P(e.wr,t.wr)}static Ar(e,t){return P(e.wr,t.wr)||z.comparator(e.key,t.key)}}class _o{constructor(e,t){this.indexManager=e,this.referenceDelegate=t,this.mutationQueue=[],this.Sr=1,this.br=new st(wo.Er)}checkEmpty(e){return ie.resolve(0===this.mutationQueue.length)}addMutationBatch(e,t,n,r){const i=this.Sr;this.Sr++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];const s=new Fr(i,t,n,r);this.mutationQueue.push(s);for(const t of r)this.br=this.br.add(new wo(t.key,i)),this.indexManager.addToCollectionParentIndex(e,t.key.path.popLast());return ie.resolve(s)}lookupMutationBatch(e,t){return ie.resolve(this.Dr(t))}getNextMutationBatchAfterBatchId(e,t){const n=t+1,r=this.vr(n),i=r<0?0:r;return ie.resolve(this.mutationQueue.length>i?this.mutationQueue[i]:null)}getHighestUnacknowledgedBatchId(){return ie.resolve(0===this.mutationQueue.length?-1:this.Sr-1)}getAllMutationBatches(e){return ie.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){const n=new wo(t,0),r=new wo(t,Number.POSITIVE_INFINITY),i=[];return this.br.forEachInRange([n,r],(e=>{const t=this.Dr(e.wr);i.push(t)})),ie.resolve(i)}getAllMutationBatchesAffectingDocumentKeys(e,t){let n=new st(P);return t.forEach((e=>{const t=new wo(e,0),r=new wo(e,Number.POSITIVE_INFINITY);this.br.forEachInRange([t,r],(e=>{n=n.add(e.wr)}))})),ie.resolve(this.Cr(n))}getAllMutationBatchesAffectingQuery(e,t){const n=t.path,r=n.length+1;let i=n;z.isDocumentKey(i)||(i=i.child(""));const s=new wo(new z(i),0);let o=new st(P);return this.br.forEachWhile((e=>{const t=e.key.path;return!!n.isPrefixOf(t)&&(t.length===r&&(o=o.add(e.wr)),!0)}),s),ie.resolve(this.Cr(o))}Cr(e){const t=[];return e.forEach((e=>{const n=this.Dr(e);null!==n&&t.push(n)})),t}removeMutationBatch(e,t){b(0===this.Fr(t.batchId,"removed")),this.mutationQueue.shift();let n=this.br;return ie.forEach(t.mutations,(r=>{const i=new wo(r.key,t.batchId);return n=n.delete(i),this.referenceDelegate.markPotentiallyOrphaned(e,r.key)})).next((()=>{this.br=n}))}On(e){}containsKey(e,t){const n=new wo(t,0),r=this.br.firstAfterOrEqual(n);return ie.resolve(t.isEqual(r&&r.key))}performConsistencyCheck(e){return this.mutationQueue.length,ie.resolve()}Fr(e,t){return this.vr(e)}vr(e){return 0===this.mutationQueue.length?0:e-this.mutationQueue[0].batchId}Dr(e){const t=this.vr(e);return t<0||t>=this.mutationQueue.length?null:this.mutationQueue[t]}}class Io{constructor(e){this.Mr=e,this.docs=new nt(z.comparator),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,t){const n=t.key,r=this.docs.get(n),i=r?r.size:0,s=this.Mr(t);return this.docs=this.docs.insert(n,{document:t.mutableCopy(),size:s}),this.size+=s-i,this.indexManager.addToCollectionParentIndex(e,n.path.popLast())}removeEntry(e){const t=this.docs.get(e);t&&(this.docs=this.docs.remove(e),this.size-=t.size)}getEntry(e,t){const n=this.docs.get(t);return ie.resolve(n?n.document.mutableCopy():$t.newInvalidDocument(t))}getEntries(e,t){let n=$n();return t.forEach((e=>{const t=this.docs.get(e);n=n.insert(e,t?t.document.mutableCopy():$t.newInvalidDocument(e))})),ie.resolve(n)}getDocumentsMatchingQuery(e,t,n,r){let i=$n();const s=t.path,o=new z(s.child("")),a=this.docs.getIteratorFrom(o);for(;a.hasNext();){const{key:e,value:{document:o}}=a.getNext();if(!s.isPrefixOf(e.path))break;e.path.length>s.length+1||ee(X(o),n)<=0||(r.has(o.key)||Bn(t,o))&&(i=i.insert(o.key,o.mutableCopy()))}return ie.resolve(i)}getAllFromCollectionGroup(e,t,n,r){v()}Or(e,t){return ie.forEach(this.docs,(e=>t(e)))}newChangeBuffer(e){return new Eo(this)}getSize(e){return ie.resolve(this.size)}}class Eo extends io{constructor(e){super(),this.cr=e}applyChanges(e){const t=[];return this.changes.forEach(((n,r)=>{r.isValidDocument()?t.push(this.cr.addEntry(e,r)):this.cr.removeEntry(n)})),ie.waitFor(t)}getFromCache(e,t){return this.cr.getEntry(e,t)}getAllFromCache(e,t){return this.cr.getEntries(e,t)}}class To{constructor(e){this.persistence=e,this.Nr=new Kn((e=>_n(e)),In),this.lastRemoteSnapshotVersion=V.min(),this.highestTargetId=0,this.Lr=0,this.Br=new bo,this.targetCount=0,this.kr=Ws.Bn()}forEachTarget(e,t){return this.Nr.forEach(((e,n)=>t(n))),ie.resolve()}getLastRemoteSnapshotVersion(e){return ie.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return ie.resolve(this.Lr)}allocateTargetId(e){return this.highestTargetId=this.kr.next(),ie.resolve(this.highestTargetId)}setTargetsMetadata(e,t,n){return n&&(this.lastRemoteSnapshotVersion=n),t>this.Lr&&(this.Lr=t),ie.resolve()}Kn(e){this.Nr.set(e.target,e);const t=e.targetId;t>this.highestTargetId&&(this.kr=new Ws(t),this.highestTargetId=t),e.sequenceNumber>this.Lr&&(this.Lr=e.sequenceNumber)}addTargetData(e,t){return this.Kn(t),this.targetCount+=1,ie.resolve()}updateTargetData(e,t){return this.Kn(t),ie.resolve()}removeTargetData(e,t){return this.Nr.delete(t.target),this.Br.gr(t.targetId),this.targetCount-=1,ie.resolve()}removeTargets(e,t,n){let r=0;const i=[];return this.Nr.forEach(((s,o)=>{o.sequenceNumber<=t&&null===n.get(o.targetId)&&(this.Nr.delete(s),i.push(this.removeMatchingKeysForTargetId(e,o.targetId)),r++)})),ie.waitFor(i).next((()=>r))}getTargetCount(e){return ie.resolve(this.targetCount)}getTargetData(e,t){const n=this.Nr.get(t)||null;return ie.resolve(n)}addMatchingKeys(e,t,n){return this.Br.Rr(t,n),ie.resolve()}removeMatchingKeys(e,t,n){this.Br.mr(t,n);const r=this.persistence.referenceDelegate,i=[];return r&&t.forEach((t=>{i.push(r.markPotentiallyOrphaned(e,t))})),ie.waitFor(i)}removeMatchingKeysForTargetId(e,t){return this.Br.gr(t),ie.resolve()}getMatchingKeysForTargetId(e,t){const n=this.Br.yr(t);return ie.resolve(n)}containsKey(e,t){return ie.resolve(this.Br.containsKey(t))}}class So{constructor(e,t){this.qr={},this.overlays={},this.Qr=new ye(0),this.Kr=!1,this.Kr=!0,this.$r=new vo,this.referenceDelegate=e(this),this.Ur=new To(this),this.indexManager=new xs,this.remoteDocumentCache=function(e){return new Io(e)}((e=>this.referenceDelegate.Wr(e))),this.serializer=new Gi(t),this.Gr=new go(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.Kr=!1,Promise.resolve()}get started(){return this.Kr}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let t=this.overlays[e.toKey()];return t||(t=new yo,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let n=this.qr[e.toKey()];return n||(n=new _o(t,this.referenceDelegate),this.qr[e.toKey()]=n),n}getGlobalsCache(){return this.$r}getTargetCache(){return this.Ur}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Gr}runTransaction(e,t,n){p("MemoryPersistence","Starting transaction:",e);const r=new Co(this.Qr.next());return this.referenceDelegate.zr(),n(r).next((e=>this.referenceDelegate.jr(r).next((()=>e)))).toPromise().then((e=>(r.raiseOnCommittedEvent(),e)))}Hr(e,t){return ie.or(Object.values(this.qr).map((n=>()=>n.containsKey(e,t))))}}class Co extends ne{constructor(e){super(),this.currentSequenceNumber=e}}class Ao{constructor(e){this.persistence=e,this.Jr=new bo,this.Yr=null}static Zr(e){return new Ao(e)}get Xr(){if(this.Yr)return this.Yr;throw v()}addReference(e,t,n){return this.Jr.addReference(n,t),this.Xr.delete(n.toString()),ie.resolve()}removeReference(e,t,n){return this.Jr.removeReference(n,t),this.Xr.add(n.toString()),ie.resolve()}markPotentiallyOrphaned(e,t){return this.Xr.add(t.toString()),ie.resolve()}removeTarget(e,t){this.Jr.gr(t.targetId).forEach((e=>this.Xr.add(e.toString())));const n=this.persistence.getTargetCache();return n.getMatchingKeysForTargetId(e,t.targetId).next((e=>{e.forEach((e=>this.Xr.add(e.toString())))})).next((()=>n.removeTargetData(e,t)))}zr(){this.Yr=new Set}jr(e){const t=this.persistence.getRemoteDocumentCache().newChangeBuffer();return ie.forEach(this.Xr,(n=>{const r=z.fromPath(n);return this.ei(e,r).next((e=>{e||t.removeEntry(r,V.min())}))})).next((()=>(this.Yr=null,t.apply(e))))}updateLimboDocument(e,t){return this.ei(e,t).next((e=>{e?this.Xr.delete(t.toString()):this.Xr.add(t.toString())}))}Wr(e){return 0}ei(e,t){return ie.or([()=>ie.resolve(this.Jr.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.Hr(e,t)])}}class xo{constructor(e,t){this.persistence=e,this.ti=new Kn((e=>_e(e.path)),((e,t)=>e.isEqual(t))),this.garbageCollector=to(this,t)}static Zr(e,t){return new xo(e,t)}zr(){}jr(e){return ie.resolve()}forEachTarget(e,t){return this.persistence.getTargetCache().forEachTarget(e,t)}Yn(e){const t=this.er(e);return this.persistence.getTargetCache().getTargetCount(e).next((e=>t.next((t=>e+t))))}er(e){let t=0;return this.Zn(e,(e=>{t++})).next((()=>t))}Zn(e,t){return ie.forEach(this.ti,((n,r)=>this.nr(e,n,r).next((e=>e?ie.resolve():t(r)))))}removeTargets(e,t,n){return this.persistence.getTargetCache().removeTargets(e,t,n)}removeOrphanedDocuments(e,t){let n=0;const r=this.persistence.getRemoteDocumentCache(),i=r.newChangeBuffer();return r.Or(e,(r=>this.nr(e,r,t).next((e=>{e||(n++,i.removeEntry(r,V.min()))})))).next((()=>i.apply(e))).next((()=>n))}markPotentiallyOrphaned(e,t){return this.ti.set(t,e.currentSequenceNumber),ie.resolve()}removeTarget(e,t){const n=t.withSequenceNumber(e.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(e,n)}addReference(e,t,n){return this.ti.set(n,e.currentSequenceNumber),ie.resolve()}removeReference(e,t,n){return this.ti.set(n,e.currentSequenceNumber),ie.resolve()}updateLimboDocument(e,t){return this.ti.set(t,e.currentSequenceNumber),ie.resolve()}Wr(e){let t=e.key.toString().length;return e.isFoundDocument()&&(t+=Nt(e.data.value)),t}nr(e,t,n){return ie.or([()=>this.persistence.Hr(e,t),()=>this.persistence.getTargetCache().containsKey(e,t),()=>{const e=this.ti.get(t);return ie.resolve(void 0!==e&&e>n)}])}getCacheSize(e){return this.persistence.getRemoteDocumentCache().getSize(e)}}class ko{constructor(e){this.serializer=e}O(e,t,n,r){const i=new se("createOrUpgrade",t);n<1&&r>=1&&(function(e){e.createObjectStore("owner")}(e),function(e){e.createObjectStore("mutationQueues",{keyPath:"userId"}),e.createObjectStore("mutations",{keyPath:"batchId",autoIncrement:!0}).createIndex("userMutationsIndex",Se,{unique:!0}),e.createObjectStore("documentMutations")}(e),No(e),function(e){e.createObjectStore("remoteDocuments")}(e));let s=ie.resolve();return n<3&&r>=3&&(0!==n&&(function(e){e.deleteObjectStore("targetDocuments"),e.deleteObjectStore("targets"),e.deleteObjectStore("targetGlobal")}(e),No(e)),s=s.next((()=>function(e){const t=e.store("targetGlobal"),n={highestTargetId:0,highestListenSequenceNumber:0,lastRemoteSnapshotVersion:V.min().toTimestamp(),targetCount:0};return t.put("targetGlobalKey",n)}(i)))),n<4&&r>=4&&(0!==n&&(s=s.next((()=>function(e,t){return t.store("mutations").U().next((n=>{e.deleteObjectStore("mutations"),e.createObjectStore("mutations",{keyPath:"batchId",autoIncrement:!0}).createIndex("userMutationsIndex",Se,{unique:!0});const r=t.store("mutations"),i=n.map((e=>r.put(e)));return ie.waitFor(i)}))}(e,i)))),s=s.next((()=>{!function(e){e.createObjectStore("clientMetadata",{keyPath:"clientId"})}(e)}))),n<5&&r>=5&&(s=s.next((()=>this.ni(i)))),n<6&&r>=6&&(s=s.next((()=>(function(e){e.createObjectStore("remoteDocumentGlobal")}(e),this.ri(i))))),n<7&&r>=7&&(s=s.next((()=>this.ii(i)))),n<8&&r>=8&&(s=s.next((()=>this.si(e,i)))),n<9&&r>=9&&(s=s.next((()=>{!function(e){e.objectStoreNames.contains("remoteDocumentChanges")&&e.deleteObjectStore("remoteDocumentChanges")}(e)}))),n<10&&r>=10&&(s=s.next((()=>this.oi(i)))),n<11&&r>=11&&(s=s.next((()=>{!function(e){e.createObjectStore("bundles",{keyPath:"bundleId"})}(e),function(e){e.createObjectStore("namedQueries",{keyPath:"name"})}(e)}))),n<12&&r>=12&&(s=s.next((()=>{!function(e){const t=e.createObjectStore("documentOverlays",{keyPath:je});t.createIndex("collectionPathOverlayIndex",Be,{unique:!1}),t.createIndex("collectionGroupOverlayIndex",qe,{unique:!1})}(e)}))),n<13&&r>=13&&(s=s.next((()=>function(e){const t=e.createObjectStore("remoteDocumentsV14",{keyPath:ke});t.createIndex("documentKeyIndex",Ne),t.createIndex("collectionGroupIndex",Oe)}(e))).next((()=>this._i(e,i))).next((()=>e.deleteObjectStore("remoteDocuments")))),n<14&&r>=14&&(s=s.next((()=>this.ai(e,i)))),n<15&&r>=15&&(s=s.next((()=>function(e){e.createObjectStore("indexConfiguration",{keyPath:"indexId",autoIncrement:!0}).createIndex("collectionGroupIndex","collectionGroup",{unique:!1}),e.createObjectStore("indexState",{keyPath:Me}).createIndex("sequenceNumberIndex",Fe,{unique:!1}),e.createObjectStore("indexEntries",{keyPath:Ve}).createIndex("documentKeyIndex",Ue,{unique:!1})}(e)))),n<16&&r>=16&&(s=s.next((()=>{t.objectStore("indexState").clear()})).next((()=>{t.objectStore("indexEntries").clear()}))),n<17&&r>=17&&(s=s.next((()=>{!function(e){e.createObjectStore("globals",{keyPath:"name"})}(e)}))),s}ri(e){let t=0;return e.store("remoteDocuments").J(((e,n)=>{t+=js(n)})).next((()=>{const n={byteSize:t};return e.store("remoteDocumentGlobal").put("remoteDocumentGlobalKey",n)}))}ni(e){const t=e.store("mutationQueues"),n=e.store("mutations");return t.U().next((t=>ie.forEach(t,(t=>{const r=IDBKeyRange.bound([t.userId,-1],[t.userId,t.lastAcknowledgedBatchId]);return n.U("userMutationsIndex",r).next((n=>ie.forEach(n,(n=>{b(n.userId===t.userId);const r=Qi(this.serializer,n);return Us(e,t.userId,r).next((()=>{}))}))))}))))}ii(e){const t=e.store("targetDocuments"),n=e.store("remoteDocuments");return e.store("targetGlobal").get("targetGlobalKey").next((e=>{const r=[];return n.J(((n,i)=>{const s=new j(n),o=function(e){return[0,_e(e)]}(s);r.push(t.get(o).next((n=>n?ie.resolve():(n=>t.put({targetId:0,path:_e(n),sequenceNumber:e.highestListenSequenceNumber}))(s))))})).next((()=>ie.waitFor(r)))}))}si(e,t){e.createObjectStore("collectionParents",{keyPath:Le});const n=t.store("collectionParents"),r=new ks,i=e=>{if(r.add(e)){const t=e.lastSegment(),r=e.popLast();return n.put({collectionId:t,parent:_e(r)})}};return t.store("remoteDocuments").J({H:!0},((e,t)=>{const n=new j(e);return i(n.popLast())})).next((()=>t.store("documentMutations").J({H:!0},(([e,t,n],r)=>{const s=Te(t);return i(s.popLast())}))))}oi(e){const t=e.store("targets");return t.J(((e,n)=>{const r=Ji(n),i=Yi(this.serializer,r);return t.put(i)}))}_i(e,t){const n=t.store("remoteDocuments"),r=[];return n.J(((e,n)=>{const i=t.store("remoteDocumentsV14"),s=function(e){return e.document?new z(j.fromString(e.document.name).popFirst(5)):e.noDocument?z.fromSegments(e.noDocument.path):e.unknownDocument?z.fromSegments(e.unknownDocument.path):v()}(n).path.toArray(),o={prefixPath:s.slice(0,s.length-2),collectionGroup:s[s.length-2],documentId:s[s.length-1],readTime:n.readTime||[0,0],unknownDocument:n.unknownDocument,noDocument:n.noDocument,document:n.document,hasCommittedMutations:!!n.hasCommittedMutations};r.push(i.put(o))})).next((()=>ie.waitFor(r)))}ai(e,t){const n=t.store("mutations"),r=oo(this.serializer),i=new So(Ao.Zr,this.serializer.ct);return n.U().next((e=>{const n=new Map;return e.forEach((e=>{var t;let r=null!==(t=n.get(e.userId))&&void 0!==t?t:nr();Qi(this.serializer,e).keys().forEach((e=>r=r.add(e))),n.set(e.userId,r)})),ie.forEach(n,((e,n)=>{const s=new l(n),o=ss.lt(this.serializer,s),a=i.getIndexManager(s),c=Bs.lt(s,this.serializer,a,i.referenceDelegate);return new mo(r,c,o,a).recalculateAndSaveOverlaysForDocumentKeys(new Je(t,ye.oe),e).next()}))}))}}function No(e){e.createObjectStore("targetDocuments",{keyPath:Re}).createIndex("documentTargetsIndex",Pe,{unique:!0}),e.createObjectStore("targets",{keyPath:"targetId"}).createIndex("queryTargetsIndex",De,{unique:!0}),e.createObjectStore("targetGlobal")}const Oo="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 Do{constructor(e,t,n,r,i,s,o,a,c,u,l=17){if(this.allowTabSynchronization=e,this.persistenceKey=t,this.clientId=n,this.ui=i,this.window=s,this.document=o,this.ci=c,this.li=u,this.hi=l,this.Qr=null,this.Kr=!1,this.isPrimary=!1,this.networkEnabled=!0,this.Pi=null,this.inForeground=!1,this.Ii=null,this.Ti=null,this.Ei=Number.NEGATIVE_INFINITY,this.di=e=>Promise.resolve(),!Do.D())throw new I(_.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");this.referenceDelegate=new no(this,r),this.Ai=t+"main",this.serializer=new Gi(a),this.Ri=new oe(this.Ai,this.hi,new ko(this.serializer)),this.$r=new as,this.Ur=new $s(this.referenceDelegate,this.serializer),this.remoteDocumentCache=oo(this.serializer),this.Gr=new ns,this.window&&this.window.localStorage?this.Vi=this.window.localStorage:(this.Vi=null,!1===u&&m("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.mi().then((()=>{if(!this.isPrimary&&!this.allowTabSynchronization)throw new I(_.FAILED_PRECONDITION,Oo);return this.fi(),this.gi(),this.pi(),this.runTransaction("getHighestListenSequenceNumber","readonly",(e=>this.Ur.getHighestSequenceNumber(e)))})).then((e=>{this.Qr=new ye(e,this.ci)})).then((()=>{this.Kr=!0})).catch((e=>(this.Ri&&this.Ri.close(),Promise.reject(e))))}yi(e){return this.di=async t=>{if(this.started)return e(t)},e(this.isPrimary)}setDatabaseDeletedListener(e){this.Ri.L((async t=>{null===t.newVersion&&await e()}))}setNetworkEnabled(e){this.networkEnabled!==e&&(this.networkEnabled=e,this.ui.enqueueAndForget((async()=>{this.started&&await this.mi()})))}mi(){return this.runTransaction("updateClientMetadataAndTryBecomePrimary","readwrite",(e=>Po(e).put({clientId:this.clientId,updateTimeMs:Date.now(),networkEnabled:this.networkEnabled,inForeground:this.inForeground}).next((()=>{if(this.isPrimary)return this.wi(e).next((e=>{e||(this.isPrimary=!1,this.ui.enqueueRetryable((()=>this.di(!1))))}))})).next((()=>this.Si(e))).next((t=>this.isPrimary&&!t?this.bi(e).next((()=>!1)):!!t&&this.Di(e).next((()=>!0)))))).catch((e=>{if(le(e))return p("IndexedDbPersistence","Failed to extend owner lease: ",e),this.isPrimary;if(!this.allowTabSynchronization)throw e;return p("IndexedDbPersistence","Releasing owner lease after error during lease refresh",e),!1})).then((e=>{this.isPrimary!==e&&this.ui.enqueueRetryable((()=>this.di(e))),this.isPrimary=e}))}wi(e){return Ro(e).get("owner").next((e=>ie.resolve(this.vi(e))))}Ci(e){return Po(e).delete(this.clientId)}async Fi(){if(this.isPrimary&&!this.Mi(this.Ei,18e5)){this.Ei=Date.now();const e=await this.runTransaction("maybeGarbageCollectMultiClientState","readwrite-primary",(e=>{const t=Ye(e,"clientMetadata");return t.U().next((e=>{const n=this.xi(e,18e5),r=e.filter((e=>-1===n.indexOf(e)));return ie.forEach(r,(e=>t.delete(e.clientId))).next((()=>r))}))})).catch((()=>[]));if(this.Vi)for(const t of e)this.Vi.removeItem(this.Oi(t.clientId))}}pi(){this.Ti=this.ui.enqueueAfterDelay("client_metadata_refresh",4e3,(()=>this.mi().then((()=>this.Fi())).then((()=>this.pi()))))}vi(e){return!!e&&e.ownerId===this.clientId}Si(e){return this.li?ie.resolve(!0):Ro(e).get("owner").next((t=>{if(null!==t&&this.Mi(t.leaseTimestampMs,5e3)&&!this.Ni(t.ownerId)){if(this.vi(t)&&this.networkEnabled)return!0;if(!this.vi(t)){if(!t.allowTabSynchronization)throw new I(_.FAILED_PRECONDITION,Oo);return!1}}return!(!this.networkEnabled||!this.inForeground)||Po(e).U().next((e=>void 0===this.xi(e,5e3).find((e=>{if(this.clientId!==e.clientId){const t=!this.networkEnabled&&e.networkEnabled,n=!this.inForeground&&e.inForeground,r=this.networkEnabled===e.networkEnabled;if(t||n&&r)return!0}return!1}))))})).next((e=>(this.isPrimary!==e&&p("IndexedDbPersistence",`Client ${e?"is":"is not"} eligible for a primary lease.`),e)))}async shutdown(){this.Kr=!1,this.Li(),this.Ti&&(this.Ti.cancel(),this.Ti=null),this.Bi(),this.ki(),await this.Ri.runTransaction("shutdown","readwrite",["owner","clientMetadata"],(e=>{const t=new Je(e,ye.oe);return this.bi(t).next((()=>this.Ci(t)))})),this.Ri.close(),this.qi()}xi(e,t){return e.filter((e=>this.Mi(e.updateTimeMs,t)&&!this.Ni(e.clientId)))}Qi(){return this.runTransaction("getActiveClients","readonly",(e=>Po(e).U().next((e=>this.xi(e,18e5).map((e=>e.clientId))))))}get started(){return this.Kr}getGlobalsCache(){return this.$r}getMutationQueue(e,t){return Bs.lt(e,this.serializer,t,this.referenceDelegate)}getTargetCache(){return this.Ur}getRemoteDocumentCache(){return this.remoteDocumentCache}getIndexManager(e){return new Os(e,this.serializer.ct.databaseId)}getDocumentOverlayCache(e){return ss.lt(this.serializer,e)}getBundleCache(){return this.Gr}runTransaction(e,t,n){p("IndexedDbPersistence","Starting transaction:",e);const r="readonly"===t?"readonly":"readwrite",i=function(e){return 17===e?Qe:16===e?He:15===e?$e:14===e?We:13===e?Ke:12===e?Ge:11===e?ze:void v()}(this.hi);let s;return this.Ri.runTransaction(e,r,i,(r=>(s=new Je(r,this.Qr?this.Qr.next():ye.oe),"readwrite-primary"===t?this.wi(s).next((e=>!!e||this.Si(s))).next((t=>{if(!t)throw m(`Failed to obtain primary lease for action '${e}'.`),this.isPrimary=!1,this.ui.enqueueRetryable((()=>this.di(!1))),new I(_.FAILED_PRECONDITION,te);return n(s)})).next((e=>this.Di(s).next((()=>e)))):this.Ki(s).next((()=>n(s)))))).then((e=>(s.raiseOnCommittedEvent(),e)))}Ki(e){return Ro(e).get("owner").next((e=>{if(null!==e&&this.Mi(e.leaseTimestampMs,5e3)&&!this.Ni(e.ownerId)&&!this.vi(e)&&!(this.li||this.allowTabSynchronization&&e.allowTabSynchronization))throw new I(_.FAILED_PRECONDITION,Oo)}))}Di(e){const t={ownerId:this.clientId,allowTabSynchronization:this.allowTabSynchronization,leaseTimestampMs:Date.now()};return Ro(e).put("owner",t)}static D(){return oe.D()}bi(e){const t=Ro(e);return t.get("owner").next((e=>this.vi(e)?(p("IndexedDbPersistence","Releasing primary lease."),t.delete("owner")):ie.resolve()))}Mi(e,t){const n=Date.now();return!(e<n-t||e>n&&(m(`Detected an update time that is in the future: ${e} > ${n}`),1))}fi(){null!==this.document&&"function"==typeof this.document.addEventListener&&(this.Ii=()=>{this.ui.enqueueAndForget((()=>(this.inForeground="visible"===this.document.visibilityState,this.mi())))},this.document.addEventListener("visibilitychange",this.Ii),this.inForeground="visible"===this.document.visibilityState)}Bi(){this.Ii&&(this.document.removeEventListener("visibilitychange",this.Ii),this.Ii=null)}gi(){var e;"function"==typeof(null===(e=this.window)||void 0===e?void 0:e.addEventListener)&&(this.Pi=()=>{this.Li();const e=/(?:Version|Mobile)\/1[456]/;o.isSafari()&&(navigator.appVersion.match(e)||navigator.userAgent.match(e))&&this.ui.enterRestrictedMode(!0),this.ui.enqueueAndForget((()=>this.shutdown()))},this.window.addEventListener("pagehide",this.Pi))}ki(){this.Pi&&(this.window.removeEventListener("pagehide",this.Pi),this.Pi=null)}Ni(e){var t;try{const n=null!==(null===(t=this.Vi)||void 0===t?void 0:t.getItem(this.Oi(e)));return p("IndexedDbPersistence",`Client '${e}' ${n?"is":"is not"} zombied in LocalStorage`),n}catch(e){return m("IndexedDbPersistence","Failed to get zombied client id.",e),!1}}Li(){if(this.Vi)try{this.Vi.setItem(this.Oi(this.clientId),String(Date.now()))}catch(e){m("Failed to set zombie client id.",e)}}qi(){if(this.Vi)try{this.Vi.removeItem(this.Oi(this.clientId))}catch(e){}}Oi(e){return`firestore_zombie_${this.persistenceKey}_${e}`}}function Ro(e){return Ye(e,"owner")}function Po(e){return Ye(e,"clientMetadata")}function Lo(e,t){let n=e.projectId;return e.isDefaultDatabase||(n+="."+e.database),"firestore/"+t+"/"+n+"/"}class Mo{constructor(e,t,n,r){this.targetId=e,this.fromCache=t,this.$i=n,this.Ui=r}static Wi(e,t){let n=nr(),r=nr();for(const e of t.docChanges)switch(e.type){case 0:n=n.add(e.doc.key);break;case 1:r=r.add(e.doc.key)}return new Mo(e,t.fromCache,n,r)}}class Fo{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(e){this._documentReadCount+=e}}class Vo{constructor(){this.Gi=!1,this.zi=!1,this.ji=100,this.Hi=o.isSafari()?8:ae(o.getUA())>0?6:4}initialize(e,t){this.Ji=e,this.indexManager=t,this.Gi=!0}getDocumentsMatchingQuery(e,t,n,r){const i={result:null};return this.Yi(e,t).next((e=>{i.result=e})).next((()=>{if(!i.result)return this.Zi(e,t,r,n).next((e=>{i.result=e}))})).next((()=>{if(i.result)return;const n=new Fo;return this.Xi(e,t,n).next((r=>{if(i.result=r,this.zi)return this.es(e,t,n,r.size)}))})).next((()=>i.result))}es(e,t,n,r){return n.documentReadCount<this.ji?(f()<=s.LogLevel.DEBUG&&p("QueryEngine","SDK will not create cache indexes for query:",jn(t),"since it only creates cache indexes for collection contains","more than or equal to",this.ji,"documents"),ie.resolve()):(f()<=s.LogLevel.DEBUG&&p("QueryEngine","Query:",jn(t),"scans",n.documentReadCount,"local documents and returns",r,"documents as results."),n.documentReadCount>this.Hi*r?(f()<=s.LogLevel.DEBUG&&p("QueryEngine","The SDK decides to create cache indexes for query:",jn(t),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(e,Rn(t))):ie.resolve())}Yi(e,t){if(Nn(t))return ie.resolve(null);let n=Rn(t);return this.indexManager.getIndexType(e,n).next((r=>0===r?null:(null!==t.limit&&1===r&&(t=Fn(t,null,"F"),n=Rn(t)),this.indexManager.getDocumentsMatchingTarget(e,n).next((r=>{const i=nr(...r);return this.Ji.getDocuments(e,i).next((r=>this.indexManager.getMinOffset(e,n).next((n=>{const s=this.ts(t,r);return this.ns(t,s,i,n.readTime)?this.Yi(e,Fn(t,null,"F")):this.rs(e,s,t,n)}))))})))))}Zi(e,t,n,r){return Nn(t)||r.isEqual(V.min())?ie.resolve(null):this.Ji.getDocuments(e,n).next((i=>{const o=this.ts(t,i);return this.ns(t,o,n,r)?ie.resolve(null):(f()<=s.LogLevel.DEBUG&&p("QueryEngine","Re-using previous result from %s to execute query: %s",r.toString(),jn(t)),this.rs(e,o,t,Y(r,-1)).next((e=>e)))}))}ts(e,t){let n=new st(zn(e));return t.forEach(((t,r)=>{Bn(e,r)&&(n=n.add(r))})),n}ns(e,t,n,r){if(null===e.limit)return!1;if(n.size!==t.size)return!0;const i="F"===e.limitType?t.last():t.first();return!!i&&(i.hasPendingWrites||i.version.compareTo(r)>0)}Xi(e,t,n){return f()<=s.LogLevel.DEBUG&&p("QueryEngine","Using full collection scan to execute query:",jn(t)),this.Ji.getDocumentsMatchingQuery(e,t,Z.min(),n)}rs(e,t,n,r){return this.Ji.getDocumentsMatchingQuery(e,n,r).next((e=>(t.forEach((t=>{e=e.insert(t.key,t)})),e)))}}class Uo{constructor(e,t,n,r){this.persistence=e,this.ss=t,this.serializer=r,this.os=new nt(P),this._s=new Kn((e=>_n(e)),In),this.us=new Map,this.cs=e.getRemoteDocumentCache(),this.Ur=e.getTargetCache(),this.Gr=e.getBundleCache(),this.ls(n)}ls(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new mo(this.cs,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.cs.setIndexManager(this.indexManager),this.ss.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction("Collect garbage","readwrite-primary",(t=>e.collect(t,this.os)))}}function jo(e,t,n,r){return new Uo(e,t,n,r)}async function Bo(e,t){const n=w(e);return await n.persistence.runTransaction("Handle user change","readonly",(e=>{let r;return n.mutationQueue.getAllMutationBatches(e).next((i=>(r=i,n.ls(t),n.mutationQueue.getAllMutationBatches(e)))).next((t=>{const i=[],s=[];let o=nr();for(const e of r){i.push(e.batchId);for(const t of e.mutations)o=o.add(t.key)}for(const e of t){s.push(e.batchId);for(const t of e.mutations)o=o.add(t.key)}return n.localDocuments.getDocuments(e,o).next((e=>({hs:e,removedBatchIds:i,addedBatchIds:s})))}))}))}function qo(e){const t=w(e);return t.persistence.runTransaction("Get last remote snapshot version","readonly",(e=>t.Ur.getLastRemoteSnapshotVersion(e)))}function zo(e,t,n){let r=nr(),i=nr();return n.forEach((e=>r=r.add(e))),t.getEntries(e,r).next((e=>{let r=$n();return n.forEach(((n,s)=>{const o=e.get(n);s.isFoundDocument()!==o.isFoundDocument()&&(i=i.add(n)),s.isNoDocument()&&s.version.isEqual(V.min())?(t.removeEntry(n,s.readTime),r=r.insert(n,s)):!o.isValidDocument()||s.version.compareTo(o.version)>0||0===s.version.compareTo(o.version)&&o.hasPendingWrites?(t.addEntry(s),r=r.insert(n,s)):p("LocalStore","Ignoring outdated watch update for ",n,". Current version:",o.version," Watch version:",s.version)})),{Ps:r,Is:i}}))}function Go(e,t){const n=w(e);return n.persistence.runTransaction("Get next mutation batch","readonly",(e=>(void 0===t&&(t=-1),n.mutationQueue.getNextMutationBatchAfterBatchId(e,t))))}function Ko(e,t){const n=w(e);return n.persistence.runTransaction("Allocate target","readwrite",(e=>{let r;return n.Ur.getTargetData(e,t).next((i=>i?(r=i,ie.resolve(r)):n.Ur.allocateTargetId(e).next((i=>(r=new zi(t,i,"TargetPurposeListen",e.currentSequenceNumber),n.Ur.addTargetData(e,r).next((()=>r)))))))})).then((e=>{const r=n.os.get(e.targetId);return(null===r||e.snapshotVersion.compareTo(r.snapshotVersion)>0)&&(n.os=n.os.insert(e.targetId,e),n._s.set(t,e.targetId)),e}))}async function Wo(e,t,n){const r=w(e),i=r.os.get(t),s=n?"readwrite":"readwrite-primary";try{n||await r.persistence.runTransaction("Release target",s,(e=>r.persistence.referenceDelegate.removeTarget(e,i)))}catch(e){if(!le(e))throw e;p("LocalStore",`Failed to update sequence numbers for target ${t}: ${e}`)}r.os=r.os.remove(t),r._s.delete(i.target)}function $o(e,t,n){const r=w(e);let i=V.min(),s=nr();return r.persistence.runTransaction("Execute query","readwrite",(e=>function(e,t,n){const r=w(e),i=r._s.get(n);return void 0!==i?ie.resolve(r.os.get(i)):r.Ur.getTargetData(t,n)}(r,e,Rn(t)).next((t=>{if(t)return i=t.lastLimboFreeSnapshotVersion,r.Ur.getMatchingKeysForTargetId(e,t.targetId).next((e=>{s=e}))})).next((()=>r.ss.getDocumentsMatchingQuery(e,t,n?i:V.min(),n?s:nr()))).next((e=>(Jo(r,qn(t),e),{documents:e,Ts:s})))))}function Ho(e,t){const n=w(e),r=w(n.Ur),i=n.os.get(t);return i?Promise.resolve(i.target):n.persistence.runTransaction("Get target data","readonly",(e=>r.ot(e,t).next((e=>e?e.target:null))))}function Qo(e,t){const n=w(e),r=n.us.get(t)||V.min();return n.persistence.runTransaction("Get new document changes","readonly",(e=>n.cs.getAllFromCollectionGroup(e,t,Y(r,-1),Number.MAX_SAFE_INTEGER))).then((e=>(Jo(n,t,e),e)))}function Jo(e,t,n){let r=e.us.get(t)||V.min();n.forEach(((e,t)=>{t.readTime.compareTo(r)>0&&(r=t.readTime)})),e.us.set(t,r)}async function Yo(e,t,n=nr()){const r=await Ko(e,Rn(Xi(t.bundledQuery))),i=w(e);return i.persistence.runTransaction("Save named query","readwrite",(e=>{const s=gi(t.readTime);if(r.snapshotVersion.compareTo(s)>=0)return i.Gr.saveNamedQuery(e,t);const o=r.withResumeToken(lt.EMPTY_BYTE_STRING,s);return i.os=i.os.insert(o.targetId,o),i.Ur.updateTargetData(e,o).next((()=>i.Ur.removeMatchingKeysForTargetId(e,r.targetId))).next((()=>i.Ur.addMatchingKeys(e,n,r.targetId))).next((()=>i.Gr.saveNamedQuery(e,t)))}))}function Xo(e,t){return`firestore_clients_${e}_${t}`}function Zo(e,t,n){let r=`firestore_mutations_${e}_${n}`;return t.isAuthenticated()&&(r+=`_${t.uid}`),r}function ea(e,t){return`firestore_targets_${e}_${t}`}class ta{constructor(e,t,n,r){this.user=e,this.batchId=t,this.state=n,this.error=r}static Rs(e,t,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 I(r.error.code,r.error.message))),s?new ta(e,t,r.state,i):(m("SharedClientState",`Failed to parse mutation state for ID '${t}': ${n}`),null)}Vs(){const e={state:this.state,updateTimeMs:Date.now()};return this.error&&(e.error={code:this.error.code,message:this.error.message}),JSON.stringify(e)}}class na{constructor(e,t,n){this.targetId=e,this.state=t,this.error=n}static Rs(e,t){const n=JSON.parse(t);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 I(n.error.code,n.error.message))),i?new na(e,n.state,r):(m("SharedClientState",`Failed to parse target state for ID '${e}': ${t}`),null)}Vs(){const e={state:this.state,updateTimeMs:Date.now()};return this.error&&(e.error={code:this.error.code,message:this.error.message}),JSON.stringify(e)}}class ra{constructor(e,t){this.clientId=e,this.activeTargetIds=t}static Rs(e,t){const n=JSON.parse(t);let r="object"==typeof n&&n.activeTargetIds instanceof Array,i=ir();for(let e=0;r&&e<n.activeTargetIds.length;++e)r=we(n.activeTargetIds[e]),i=i.add(n.activeTargetIds[e]);return r?new ra(e,i):(m("SharedClientState",`Failed to parse client data for instance '${e}': ${t}`),null)}}class ia{constructor(e,t){this.clientId=e,this.onlineState=t}static Rs(e){const t=JSON.parse(e);return"object"==typeof t&&-1!==["Unknown","Online","Offline"].indexOf(t.onlineState)&&"string"==typeof t.clientId?new ia(t.clientId,t.onlineState):(m("SharedClientState",`Failed to parse online state: ${e}`),null)}}class sa{constructor(){this.activeTargetIds=ir()}fs(e){this.activeTargetIds=this.activeTargetIds.add(e)}gs(e){this.activeTargetIds=this.activeTargetIds.delete(e)}Vs(){const e={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(e)}}class oa{constructor(e,t,n,r,i){this.window=e,this.ui=t,this.persistenceKey=n,this.ps=r,this.syncEngine=null,this.onlineStateHandler=null,this.sequenceNumberHandler=null,this.ys=this.ws.bind(this),this.Ss=new nt(P),this.started=!1,this.bs=[];const s=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");this.storage=this.window.localStorage,this.currentUser=i,this.Ds=Xo(this.persistenceKey,this.ps),this.vs=function(e){return`firestore_sequence_number_${e}`}(this.persistenceKey),this.Ss=this.Ss.insert(this.ps,new sa),this.Cs=new RegExp(`^firestore_clients_${s}_([^_]*)$`),this.Fs=new RegExp(`^firestore_mutations_${s}_(\\d+)(?:_(.*))?$`),this.Ms=new RegExp(`^firestore_targets_${s}_(\\d+)$`),this.xs=function(e){return`firestore_online_state_${e}`}(this.persistenceKey),this.Os=function(e){return`firestore_bundle_loaded_v2_${e}`}(this.persistenceKey),this.window.addEventListener("storage",this.ys)}static D(e){return!(!e||!e.localStorage)}async start(){const e=await this.syncEngine.Qi();for(const t of e){if(t===this.ps)continue;const e=this.getItem(Xo(this.persistenceKey,t));if(e){const n=ra.Rs(t,e);n&&(this.Ss=this.Ss.insert(n.clientId,n))}}this.Ns();const t=this.storage.getItem(this.xs);if(t){const e=this.Ls(t);e&&this.Bs(e)}for(const e of this.bs)this.ws(e);this.bs=[],this.window.addEventListener("pagehide",(()=>this.shutdown())),this.started=!0}writeSequenceNumber(e){this.setItem(this.vs,JSON.stringify(e))}getAllActiveQueryTargets(){return this.ks(this.Ss)}isActiveQueryTarget(e){let t=!1;return this.Ss.forEach(((n,r)=>{r.activeTargetIds.has(e)&&(t=!0)})),t}addPendingMutation(e){this.qs(e,"pending")}updateMutationState(e,t,n){this.qs(e,t,n),this.Qs(e)}addLocalQueryTarget(e){let t="not-current";if(this.isActiveQueryTarget(e)){const n=this.storage.getItem(ea(this.persistenceKey,e));if(n){const r=na.Rs(e,n);r&&(t=r.state)}}return this.Ks.fs(e),this.Ns(),t}removeLocalQueryTarget(e){this.Ks.gs(e),this.Ns()}isLocalQueryTarget(e){return this.Ks.activeTargetIds.has(e)}clearQueryState(e){this.removeItem(ea(this.persistenceKey,e))}updateQueryState(e,t,n){this.$s(e,t,n)}handleUserChange(e,t,n){t.forEach((e=>{this.Qs(e)})),this.currentUser=e,n.forEach((e=>{this.addPendingMutation(e)}))}setOnlineState(e){this.Us(e)}notifyBundleLoaded(e){this.Ws(e)}shutdown(){this.started&&(this.window.removeEventListener("storage",this.ys),this.removeItem(this.Ds),this.started=!1)}getItem(e){const t=this.storage.getItem(e);return p("SharedClientState","READ",e,t),t}setItem(e,t){p("SharedClientState","SET",e,t),this.storage.setItem(e,t)}removeItem(e){p("SharedClientState","REMOVE",e),this.storage.removeItem(e)}ws(e){const t=e;if(t.storageArea===this.storage){if(p("SharedClientState","EVENT",t.key,t.newValue),t.key===this.Ds)return void m("Received WebStorage notification for local change. Another client might have garbage-collected our state");this.ui.enqueueRetryable((async()=>{if(this.started){if(null!==t.key)if(this.Cs.test(t.key)){if(null==t.newValue){const e=this.Gs(t.key);return this.zs(e,null)}{const e=this.js(t.key,t.newValue);if(e)return this.zs(e.clientId,e)}}else if(this.Fs.test(t.key)){if(null!==t.newValue){const e=this.Hs(t.key,t.newValue);if(e)return this.Js(e)}}else if(this.Ms.test(t.key)){if(null!==t.newValue){const e=this.Ys(t.key,t.newValue);if(e)return this.Zs(e)}}else if(t.key===this.xs){if(null!==t.newValue){const e=this.Ls(t.newValue);if(e)return this.Bs(e)}}else if(t.key===this.vs){const e=function(e){let t=ye.oe;if(null!=e)try{const n=JSON.parse(e);b("number"==typeof n),t=n}catch(e){m("SharedClientState","Failed to read sequence number from WebStorage",e)}return t}(t.newValue);e!==ye.oe&&this.sequenceNumberHandler(e)}else if(t.key===this.Os){const e=this.Xs(t.newValue);await Promise.all(e.map((e=>this.syncEngine.eo(e))))}}else this.bs.push(t)}))}}get Ks(){return this.Ss.get(this.ps)}Ns(){this.setItem(this.Ds,this.Ks.Vs())}qs(e,t,n){const r=new ta(this.currentUser,e,t,n),i=Zo(this.persistenceKey,this.currentUser,e);this.setItem(i,r.Vs())}Qs(e){const t=Zo(this.persistenceKey,this.currentUser,e);this.removeItem(t)}Us(e){const t={clientId:this.ps,onlineState:e};this.storage.setItem(this.xs,JSON.stringify(t))}$s(e,t,n){const r=ea(this.persistenceKey,e),i=new na(e,t,n);this.setItem(r,i.Vs())}Ws(e){const t=JSON.stringify(Array.from(e));this.setItem(this.Os,t)}Gs(e){const t=this.Cs.exec(e);return t?t[1]:null}js(e,t){const n=this.Gs(e);return ra.Rs(n,t)}Hs(e,t){const n=this.Fs.exec(e),r=Number(n[1]),i=void 0!==n[2]?n[2]:null;return ta.Rs(new l(i),r,t)}Ys(e,t){const n=this.Ms.exec(e),r=Number(n[1]);return na.Rs(r,t)}Ls(e){return ia.Rs(e)}Xs(e){return JSON.parse(e)}async Js(e){if(e.user.uid===this.currentUser.uid)return this.syncEngine.no(e.batchId,e.state,e.error);p("SharedClientState",`Ignoring mutation for non-active user ${e.user.uid}`)}Zs(e){return this.syncEngine.ro(e.targetId,e.state,e.error)}zs(e,t){const n=t?this.Ss.insert(e,t):this.Ss.remove(e),r=this.ks(this.Ss),i=this.ks(n),s=[],o=[];return i.forEach((e=>{r.has(e)||s.push(e)})),r.forEach((e=>{i.has(e)||o.push(e)})),this.syncEngine.io(s,o).then((()=>{this.Ss=n}))}Bs(e){this.Ss.get(e.clientId)&&this.onlineStateHandler(e.onlineState)}ks(e){let t=ir();return e.forEach(((e,n)=>{t=t.unionWith(n.activeTargetIds)})),t}}class aa{constructor(){this.so=new sa,this.oo={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,t,n){}addLocalQueryTarget(e){return this.so.fs(e),this.oo[e]||"not-current"}updateQueryState(e,t,n){this.oo[e]=t}removeLocalQueryTarget(e){this.so.gs(e)}isLocalQueryTarget(e){return this.so.activeTargetIds.has(e)}clearQueryState(e){delete this.oo[e]}getAllActiveQueryTargets(){return this.so.activeTargetIds}isActiveQueryTarget(e){return this.so.activeTargetIds.has(e)}start(){return this.so=new sa,Promise.resolve()}handleUserChange(e,t,n){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}}class ca{_o(e){}shutdown(){}}class ua{constructor(){this.ao=()=>this.uo(),this.co=()=>this.lo(),this.ho=[],this.Po()}_o(e){this.ho.push(e)}shutdown(){window.removeEventListener("online",this.ao),window.removeEventListener("offline",this.co)}Po(){window.addEventListener("online",this.ao),window.addEventListener("offline",this.co)}uo(){p("ConnectivityMonitor","Network connectivity changed: AVAILABLE");for(const e of this.ho)e(0)}lo(){p("ConnectivityMonitor","Network connectivity changed: UNAVAILABLE");for(const e of this.ho)e(1)}static D(){return"undefined"!=typeof window&&void 0!==window.addEventListener&&void 0!==window.removeEventListener}}let la=null;function ha(){return null===la?la=268435456+Math.round(2147483648*Math.random()):la++,"0x"+la.toString(16)}const da={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery"};class fa{constructor(e){this.Io=e.Io,this.To=e.To}Eo(e){this.Ao=e}Ro(e){this.Vo=e}mo(e){this.fo=e}onMessage(e){this.po=e}close(){this.To()}send(e){this.Io(e)}yo(){this.Ao()}wo(){this.Vo()}So(e){this.fo(e)}bo(e){this.po(e)}}const pa="WebChannelConnection";class ma extends class{constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;const t=e.ssl?"https":"http",n=encodeURIComponent(this.databaseId.projectId),r=encodeURIComponent(this.databaseId.database);this.Do=t+"://"+e.host,this.vo=`projects/${n}/databases/${r}`,this.Co="(default)"===this.databaseId.database?`project_id=${n}`:`project_id=${n}&database_id=${r}`}get Fo(){return!1}Mo(e,t,n,r,i){const s=ha(),o=this.xo(e,t.toUriEncodedString());p("RestConnection",`Sending RPC '${e}' ${s}:`,o,n);const a={"google-cloud-resource-prefix":this.vo,"x-goog-request-params":this.Co};return this.Oo(a,r,i),this.No(e,o,a,n).then((t=>(p("RestConnection",`Received RPC '${e}' ${s}: `,t),t)),(t=>{throw g("RestConnection",`RPC '${e}' ${s} failed with error: `,t,"url: ",o,"request:",n),t}))}Lo(e,t,n,r,i,s){return this.Mo(e,t,n,r,i)}Oo(e,t,n){e["X-Goog-Api-Client"]="gl-js/ fire/"+h,e["Content-Type"]="text/plain",this.databaseInfo.appId&&(e["X-Firebase-GMPID"]=this.databaseInfo.appId),t&&t.headers.forEach(((t,n)=>e[n]=t)),n&&n.headers.forEach(((t,n)=>e[n]=t))}xo(e,t){const n=da[e];return`${this.Do}/v1/${t}:${n}`}terminate(){}}{constructor(e){super(e),this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}No(e,t,n,r){const i=ha();return new Promise(((s,o)=>{const a=new c.XhrIo;a.setWithCredentials(!0),a.listenOnce(c.EventType.COMPLETE,(()=>{try{switch(a.getLastErrorCode()){case c.ErrorCode.NO_ERROR:const t=a.getResponseJson();p(pa,`XHR for RPC '${e}' ${i} received:`,JSON.stringify(t)),s(t);break;case c.ErrorCode.TIMEOUT:p(pa,`RPC '${e}' ${i} timed out`),o(new I(_.DEADLINE_EXCEEDED,"Request time out"));break;case c.ErrorCode.HTTP_ERROR:const n=a.getStatus();if(p(pa,`RPC '${e}' ${i} failed with status:`,n,"response text:",a.getResponseText()),n>0){let e=a.getResponseJson();Array.isArray(e)&&(e=e[0]);const t=null==e?void 0:e.error;if(t&&t.status&&t.message){const e=function(e){const t=e.toLowerCase().replace(/_/g,"-");return Object.values(_).indexOf(t)>=0?t:_.UNKNOWN}(t.status);o(new I(e,t.message))}else o(new I(_.UNKNOWN,"Server responded with status "+a.getStatus()))}else o(new I(_.UNAVAILABLE,"Connection failed."));break;default:v()}}finally{p(pa,`RPC '${e}' ${i} completed.`)}}));const u=JSON.stringify(r);p(pa,`RPC '${e}' ${i} sending request:`,r),a.send(t,"POST",u,n,15)}))}Bo(e,t,n){const r=ha(),i=[this.Do,"/","google.firestore.v1.Firestore","/",e,"/channel"],s=c.createWebChannelTransport(),o=c.getStatEventTarget(),a={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},u=this.longPollingOptions.timeoutSeconds;void 0!==u&&(a.longPollingTimeout=Math.round(1e3*u)),this.useFetchStreams&&(a.xmlHttpFactory=new c.FetchXmlHttpFactory({})),this.Oo(a.initMessageHeaders,t,n),a.encodeInitMessageHeaders=!0;const l=i.join("");p(pa,`Creating RPC '${e}' stream ${r}: ${l}`,a);const h=s.createWebChannel(l,a);let d=!1,f=!1;const m=new fa({Io:t=>{f?p(pa,`Not sending because RPC '${e}' stream ${r} is closed:`,t):(d||(p(pa,`Opening RPC '${e}' stream ${r} transport.`),h.open(),d=!0),p(pa,`RPC '${e}' stream ${r} sending:`,t),h.send(t))},To:()=>h.close()}),y=(e,t,n)=>{e.listen(t,(e=>{try{n(e)}catch(e){setTimeout((()=>{throw e}),0)}}))};return y(h,c.WebChannel.EventType.OPEN,(()=>{f||(p(pa,`RPC '${e}' stream ${r} transport opened.`),m.yo())})),y(h,c.WebChannel.EventType.CLOSE,(()=>{f||(f=!0,p(pa,`RPC '${e}' stream ${r} transport closed`),m.So())})),y(h,c.WebChannel.EventType.ERROR,(t=>{f||(f=!0,g(pa,`RPC '${e}' stream ${r} transport errored:`,t),m.So(new I(_.UNAVAILABLE,"The operation could not be completed")))})),y(h,c.WebChannel.EventType.MESSAGE,(t=>{var n;if(!f){const i=t.data[0];b(!!i);const s=i,o=s.error||(null===(n=s[0])||void 0===n?void 0:n.error);if(o){p(pa,`RPC '${e}' stream ${r} received error:`,o);const t=o.status;let n=function(e){const t=qr[e];if(void 0!==t)return Kr(t)}(t),i=o.message;void 0===n&&(n=_.INTERNAL,i="Unknown error status: "+t+" with message "+o.message),f=!0,m.So(new I(n,i)),h.close()}else p(pa,`RPC '${e}' stream ${r} received:`,i),m.bo(i)}})),y(o,c.Event.STAT_EVENT,(t=>{t.stat===c.Stat.PROXY?p(pa,`RPC '${e}' stream ${r} detected buffering proxy`):t.stat===c.Stat.NOPROXY&&p(pa,`RPC '${e}' stream ${r} detected no buffering proxy`)})),setTimeout((()=>{m.wo()}),0),m}}function ga(){return"undefined"!=typeof window?window:null}function ya(){return"undefined"!=typeof document?document:null}function va(e){return new hi(e,!0)}class ba{constructor(e,t,n=1e3,r=1.5,i=6e4){this.ui=e,this.timerId=t,this.ko=n,this.qo=r,this.Qo=i,this.Ko=0,this.$o=null,this.Uo=Date.now(),this.reset()}reset(){this.Ko=0}Wo(){this.Ko=this.Qo}Go(e){this.cancel();const t=Math.floor(this.Ko+this.zo()),n=Math.max(0,Date.now()-this.Uo),r=Math.max(0,t-n);r>0&&p("ExponentialBackoff",`Backing off for ${r} ms (base delay: ${this.Ko} ms, delay with jitter: ${t} ms, last attempt: ${n} ms ago)`),this.$o=this.ui.enqueueAfterDelay(this.timerId,r,(()=>(this.Uo=Date.now(),e()))),this.Ko*=this.qo,this.Ko<this.ko&&(this.Ko=this.ko),this.Ko>this.Qo&&(this.Ko=this.Qo)}jo(){null!==this.$o&&(this.$o.skipDelay(),this.$o=null)}cancel(){null!==this.$o&&(this.$o.cancel(),this.$o=null)}zo(){return(Math.random()-.5)*this.Ko}}class wa{constructor(e,t,n,r,i,s,o,a){this.ui=e,this.Ho=n,this.Jo=r,this.connection=i,this.authCredentialsProvider=s,this.appCheckCredentialsProvider=o,this.listener=a,this.state=0,this.Yo=0,this.Zo=null,this.Xo=null,this.stream=null,this.e_=0,this.t_=new ba(e,t)}n_(){return 1===this.state||5===this.state||this.r_()}r_(){return 2===this.state||3===this.state}start(){this.e_=0,4!==this.state?this.auth():this.i_()}async stop(){this.n_()&&await this.close(0)}s_(){this.state=0,this.t_.reset()}o_(){this.r_()&&null===this.Zo&&(this.Zo=this.ui.enqueueAfterDelay(this.Ho,6e4,(()=>this.__())))}a_(e){this.u_(),this.stream.send(e)}async __(){if(this.r_())return this.close(0)}u_(){this.Zo&&(this.Zo.cancel(),this.Zo=null)}c_(){this.Xo&&(this.Xo.cancel(),this.Xo=null)}async close(e,t){this.u_(),this.c_(),this.t_.cancel(),this.Yo++,4!==e?this.t_.reset():t&&t.code===_.RESOURCE_EXHAUSTED?(m(t.toString()),m("Using maximum backoff delay to prevent overloading the backend."),this.t_.Wo()):t&&t.code===_.UNAUTHENTICATED&&3!==this.state&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),null!==this.stream&&(this.l_(),this.stream.close(),this.stream=null),this.state=e,await this.listener.mo(t)}l_(){}auth(){this.state=1;const e=this.h_(this.Yo),t=this.Yo;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then((([e,n])=>{this.Yo===t&&this.P_(e,n)}),(t=>{e((()=>{const e=new I(_.UNKNOWN,"Fetching auth token failed: "+t.message);return this.I_(e)}))}))}P_(e,t){const n=this.h_(this.Yo);this.stream=this.T_(e,t),this.stream.Eo((()=>{n((()=>this.listener.Eo()))})),this.stream.Ro((()=>{n((()=>(this.state=2,this.Xo=this.ui.enqueueAfterDelay(this.Jo,1e4,(()=>(this.r_()&&(this.state=3),Promise.resolve()))),this.listener.Ro())))})),this.stream.mo((e=>{n((()=>this.I_(e)))})),this.stream.onMessage((e=>{n((()=>1==++this.e_?this.E_(e):this.onNext(e)))}))}i_(){this.state=5,this.t_.Go((async()=>{this.state=0,this.start()}))}I_(e){return p("PersistentStream",`close with error: ${e}`),this.stream=null,this.close(4,e)}h_(e){return t=>{this.ui.enqueueAndForget((()=>this.Yo===e?t():(p("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())))}}}class _a extends wa{constructor(e,t,n,r,i,s){super(e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",t,n,r,s),this.serializer=i}T_(e,t){return this.connection.Bo("Listen",e,t)}E_(e){return this.onNext(e)}onNext(e){this.t_.reset();const t=function(e,t){let n;if("targetChange"in t){t.targetChange;const r=function(e){return"NO_CHANGE"===e?0:"ADD"===e?1:"REMOVE"===e?2:"CURRENT"===e?3:"RESET"===e?4:v()}(t.targetChange.targetChangeType||"NO_CHANGE"),i=t.targetChange.targetIds||[],s=function(e,t){return e.useProto3Json?(b(void 0===t||"string"==typeof t),lt.fromBase64String(t||"")):(b(void 0===t||t instanceof Buffer||t instanceof Uint8Array),lt.fromUint8Array(t||new Uint8Array))}(e,t.targetChange.resumeToken),o=t.targetChange.cause,a=o&&function(e){const t=void 0===e.code?_.UNKNOWN:Kr(e.code);return new I(t,e.message||"")}(o);n=new ri(r,i,s,a||null)}else if("documentChange"in t){t.documentChange;const r=t.documentChange;r.document,r.document.name,r.document.updateTime;const i=_i(e,r.document.name),s=gi(r.document.updateTime),o=r.document.createTime?gi(r.document.createTime):V.min(),a=new Kt({mapValue:{fields:r.document.fields}}),c=$t.newFoundDocument(i,s,o,a),u=r.targetIds||[],l=r.removedTargetIds||[];n=new ti(u,l,c.key,c)}else if("documentDelete"in t){t.documentDelete;const r=t.documentDelete;r.document;const i=_i(e,r.document),s=r.readTime?gi(r.readTime):V.min(),o=$t.newNoDocument(i,s),a=r.removedTargetIds||[];n=new ti([],a,o.key,o)}else if("documentRemove"in t){t.documentRemove;const r=t.documentRemove;r.document;const i=_i(e,r.document),s=r.removedTargetIds||[];n=new ti([],s,i,null)}else{if(!("filter"in t))return v();{t.filter;const e=t.filter;e.targetId;const{count:r=0,unchangedNames:i}=e,s=new Br(r,i),o=e.targetId;n=new ni(o,s)}}return n}(this.serializer,e),n=function(e){if(!("targetChange"in e))return V.min();const t=e.targetChange;return t.targetIds&&t.targetIds.length?V.min():t.readTime?gi(t.readTime):V.min()}(e);return this.listener.d_(t,n)}A_(e){const t={};t.database=Ti(this.serializer),t.addTarget=function(e,t){let n;const r=t.target;if(n=En(r)?{documents:Ni(e,r)}:{query:Oi(e,r)._t},n.targetId=t.targetId,t.resumeToken.approximateByteSize()>0){n.resumeToken=pi(e,t.resumeToken);const r=di(e,t.expectedCount);null!==r&&(n.expectedCount=r)}else if(t.snapshotVersion.compareTo(V.min())>0){n.readTime=fi(e,t.snapshotVersion.toTimestamp());const r=di(e,t.expectedCount);null!==r&&(n.expectedCount=r)}return n}(this.serializer,e);const n=function(e,t){const n=function(e){switch(e){case"TargetPurposeListen":return null;case"TargetPurposeExistenceFilterMismatch":return"existence-filter-mismatch";case"TargetPurposeExistenceFilterMismatchBloom":return"existence-filter-mismatch-bloom";case"TargetPurposeLimboResolution":return"limbo-document";default:return v()}}(t.purpose);return null==n?null:{"goog-listen-tags":n}}(this.serializer,e);n&&(t.labels=n),this.a_(t)}R_(e){const t={};t.database=Ti(this.serializer),t.removeTarget=e,this.a_(t)}}class Ia extends wa{constructor(e,t,n,r,i,s){super(e,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",t,n,r,s),this.serializer=i}get V_(){return this.e_>0}start(){this.lastStreamToken=void 0,super.start()}l_(){this.V_&&this.m_([])}T_(e,t){return this.connection.Bo("Write",e,t)}E_(e){return b(!!e.streamToken),this.lastStreamToken=e.streamToken,b(!e.writeResults||0===e.writeResults.length),this.listener.f_()}onNext(e){b(!!e.streamToken),this.lastStreamToken=e.streamToken,this.t_.reset();const t=function(e,t){return e&&e.length>0?(b(void 0!==t),e.map((e=>function(e,t){let n=e.updateTime?gi(e.updateTime):gi(t);return n.isEqual(V.min())&&(n=gi(t)),new _r(n,e.transformResults||[])}(e,t)))):[]}(e.writeResults,e.commitTime),n=gi(e.commitTime);return this.listener.g_(n,t)}p_(){const e={};e.database=Ti(this.serializer),this.a_(e)}m_(e){const t={streamToken:this.lastStreamToken,writes:e.map((e=>xi(this.serializer,e)))};this.a_(t)}}class Ea extends class{}{constructor(e,t,n,r){super(),this.authCredentials=e,this.appCheckCredentials=t,this.connection=n,this.serializer=r,this.y_=!1}w_(){if(this.y_)throw new I(_.FAILED_PRECONDITION,"The client has already been terminated.")}Mo(e,t,n,r){return this.w_(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([i,s])=>this.connection.Mo(e,vi(t,n),r,i,s))).catch((e=>{throw"FirebaseError"===e.name?(e.code===_.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new I(_.UNKNOWN,e.toString())}))}Lo(e,t,n,r,i){return this.w_(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([s,o])=>this.connection.Lo(e,vi(t,n),r,s,o,i))).catch((e=>{throw"FirebaseError"===e.name?(e.code===_.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new I(_.UNKNOWN,e.toString())}))}terminate(){this.y_=!0,this.connection.terminate()}}class Ta{constructor(e,t){this.asyncQueue=e,this.onlineStateHandler=t,this.state="Unknown",this.S_=0,this.b_=null,this.D_=!0}v_(){0===this.S_&&(this.C_("Unknown"),this.b_=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,(()=>(this.b_=null,this.F_("Backend didn't respond within 10 seconds."),this.C_("Offline"),Promise.resolve()))))}M_(e){"Online"===this.state?this.C_("Unknown"):(this.S_++,this.S_>=1&&(this.x_(),this.F_(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.C_("Offline")))}set(e){this.x_(),this.S_=0,"Online"===e&&(this.D_=!1),this.C_(e)}C_(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}F_(e){const t=`Could not reach Cloud Firestore backend. ${e}\nThis typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.`;this.D_?(m(t),this.D_=!1):p("OnlineStateTracker",t)}x_(){null!==this.b_&&(this.b_.cancel(),this.b_=null)}}class Sa{constructor(e,t,n,r,i){this.localStore=e,this.datastore=t,this.asyncQueue=n,this.remoteSyncer={},this.O_=[],this.N_=new Map,this.L_=new Set,this.B_=[],this.k_=i,this.k_._o((e=>{n.enqueueAndForget((async()=>{Pa(this)&&(p("RemoteStore","Restarting streams for network reachability change."),await async function(e){const t=w(e);t.L_.add(4),await Aa(t),t.q_.set("Unknown"),t.L_.delete(4),await Ca(t)}(this))}))})),this.q_=new Ta(n,r)}}async function Ca(e){if(Pa(e))for(const t of e.B_)await t(!0)}async function Aa(e){for(const t of e.B_)await t(!1)}function xa(e,t){const n=w(e);n.N_.has(t.targetId)||(n.N_.set(t.targetId,t),Ra(n)?Da(n):Za(n).r_()&&Na(n,t))}function ka(e,t){const n=w(e),r=Za(n);n.N_.delete(t),r.r_()&&Oa(n,t),0===n.N_.size&&(r.r_()?r.o_():Pa(n)&&n.q_.set("Unknown"))}function Na(e,t){if(e.Q_.xe(t.targetId),t.resumeToken.approximateByteSize()>0||t.snapshotVersion.compareTo(V.min())>0){const n=e.remoteSyncer.getRemoteKeysForTarget(t.targetId).size;t=t.withExpectedCount(n)}Za(e).A_(t)}function Oa(e,t){e.Q_.xe(t),Za(e).R_(t)}function Da(e){e.Q_=new si({getRemoteKeysForTarget:t=>e.remoteSyncer.getRemoteKeysForTarget(t),ot:t=>e.N_.get(t)||null,tt:()=>e.datastore.serializer.databaseId}),Za(e).start(),e.q_.v_()}function Ra(e){return Pa(e)&&!Za(e).n_()&&e.N_.size>0}function Pa(e){return 0===w(e).L_.size}function La(e){e.Q_=void 0}async function Ma(e){e.q_.set("Online")}async function Fa(e){e.N_.forEach(((t,n)=>{Na(e,t)}))}async function Va(e,t){La(e),Ra(e)?(e.q_.M_(t),Da(e)):e.q_.set("Unknown")}async function Ua(e,t,n){if(e.q_.set("Online"),t instanceof ri&&2===t.state&&t.cause)try{await async function(e,t){const n=t.cause;for(const r of t.targetIds)e.N_.has(r)&&(await e.remoteSyncer.rejectListen(r,n),e.N_.delete(r),e.Q_.removeTarget(r))}(e,t)}catch(n){p("RemoteStore","Failed to remove targets %s: %s ",t.targetIds.join(","),n),await ja(e,n)}else if(t instanceof ti?e.Q_.Ke(t):t instanceof ni?e.Q_.He(t):e.Q_.We(t),!n.isEqual(V.min()))try{const t=await qo(e.localStore);n.compareTo(t)>=0&&await function(e,t){const n=e.Q_.rt(t);return n.targetChanges.forEach(((n,r)=>{if(n.resumeToken.approximateByteSize()>0){const i=e.N_.get(r);i&&e.N_.set(r,i.withResumeToken(n.resumeToken,t))}})),n.targetMismatches.forEach(((t,n)=>{const r=e.N_.get(t);if(!r)return;e.N_.set(t,r.withResumeToken(lt.EMPTY_BYTE_STRING,r.snapshotVersion)),Oa(e,t);const i=new zi(r.target,t,n,r.sequenceNumber);Na(e,i)})),e.remoteSyncer.applyRemoteEvent(n)}(e,n)}catch(t){p("RemoteStore","Failed to raise snapshot:",t),await ja(e,t)}}async function ja(e,t,n){if(!le(t))throw t;e.L_.add(1),await Aa(e),e.q_.set("Offline"),n||(n=()=>qo(e.localStore)),e.asyncQueue.enqueueRetryable((async()=>{p("RemoteStore","Retrying IndexedDB access"),await n(),e.L_.delete(1),await Ca(e)}))}function Ba(e,t){return t().catch((n=>ja(e,n,t)))}async function qa(e){const t=w(e),n=ec(t);let r=t.O_.length>0?t.O_[t.O_.length-1].batchId:-1;for(;za(t);)try{const e=await Go(t.localStore,r);if(null===e){0===t.O_.length&&n.o_();break}r=e.batchId,Ga(t,e)}catch(e){await ja(t,e)}Ka(t)&&Wa(t)}function za(e){return Pa(e)&&e.O_.length<10}function Ga(e,t){e.O_.push(t);const n=ec(e);n.r_()&&n.V_&&n.m_(t.mutations)}function Ka(e){return Pa(e)&&!ec(e).n_()&&e.O_.length>0}function Wa(e){ec(e).start()}async function $a(e){ec(e).p_()}async function Ha(e){const t=ec(e);for(const n of e.O_)t.m_(n.mutations)}async function Qa(e,t,n){const r=e.O_.shift(),i=Vr.from(r,t,n);await Ba(e,(()=>e.remoteSyncer.applySuccessfulWrite(i))),await qa(e)}async function Ja(e,t){t&&ec(e).V_&&await async function(e,t){if(function(e){return Gr(e)&&e!==_.ABORTED}(t.code)){const n=e.O_.shift();ec(e).s_(),await Ba(e,(()=>e.remoteSyncer.rejectFailedWrite(n.batchId,t))),await qa(e)}}(e,t),Ka(e)&&Wa(e)}async function Ya(e,t){const n=w(e);n.asyncQueue.verifyOperationInProgress(),p("RemoteStore","RemoteStore received new credentials");const r=Pa(n);n.L_.add(3),await Aa(n),r&&n.q_.set("Unknown"),await n.remoteSyncer.handleCredentialChange(t),n.L_.delete(3),await Ca(n)}async function Xa(e,t){const n=w(e);t?(n.L_.delete(2),await Ca(n)):t||(n.L_.add(2),await Aa(n),n.q_.set("Unknown"))}function Za(e){return e.K_||(e.K_=function(e,t,n){const r=w(e);return r.w_(),new _a(t,r.connection,r.authCredentials,r.appCheckCredentials,r.serializer,n)}(e.datastore,e.asyncQueue,{Eo:Ma.bind(null,e),Ro:Fa.bind(null,e),mo:Va.bind(null,e),d_:Ua.bind(null,e)}),e.B_.push((async t=>{t?(e.K_.s_(),Ra(e)?Da(e):e.q_.set("Unknown")):(await e.K_.stop(),La(e))}))),e.K_}function ec(e){return e.U_||(e.U_=function(e,t,n){const r=w(e);return r.w_(),new Ia(t,r.connection,r.authCredentials,r.appCheckCredentials,r.serializer,n)}(e.datastore,e.asyncQueue,{Eo:()=>Promise.resolve(),Ro:$a.bind(null,e),mo:Ja.bind(null,e),f_:Ha.bind(null,e),g_:Qa.bind(null,e)}),e.B_.push((async t=>{t?(e.U_.s_(),await qa(e)):(await e.U_.stop(),e.O_.length>0&&(p("RemoteStore",`Stopping write stream with ${e.O_.length} pending writes`),e.O_=[]))}))),e.U_}class tc{constructor(e,t,n,r,i){this.asyncQueue=e,this.timerId=t,this.targetTimeMs=n,this.op=r,this.removalCallback=i,this.deferred=new E,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch((e=>{}))}get promise(){return this.deferred.promise}static createAndSchedule(e,t,n,r,i){const s=Date.now()+n,o=new tc(e,t,s,r,i);return o.start(n),o}start(e){this.timerHandle=setTimeout((()=>this.handleDelayElapsed()),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){null!==this.timerHandle&&(this.clearTimeout(),this.deferred.reject(new I(_.CANCELLED,"Operation cancelled"+(e?": "+e:""))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget((()=>null!==this.timerHandle?(this.clearTimeout(),this.op().then((e=>this.deferred.resolve(e)))):Promise.resolve()))}clearTimeout(){null!==this.timerHandle&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}}function nc(e,t){if(m("AsyncQueue",`${t}: ${e}`),le(e))return new I(_.UNAVAILABLE,`${t}: ${e}`);throw e}class rc{constructor(e){this.comparator=e?(t,n)=>e(t,n)||z.comparator(t.key,n.key):(e,t)=>z.comparator(e.key,t.key),this.keyedMap=Qn(),this.sortedSet=new nt(this.comparator)}static emptySet(e){return new rc(e.comparator)}has(e){return null!=this.keyedMap.get(e)}get(e){return this.keyedMap.get(e)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(e){const t=this.keyedMap.get(e);return t?this.sortedSet.indexOf(t):-1}get size(){return this.sortedSet.size}forEach(e){this.sortedSet.inorderTraversal(((t,n)=>(e(t),!1)))}add(e){const t=this.delete(e.key);return t.copy(t.keyedMap.insert(e.key,e),t.sortedSet.insert(e,null))}delete(e){const t=this.get(e);return t?this.copy(this.keyedMap.remove(e),this.sortedSet.remove(t)):this}isEqual(e){if(!(e instanceof rc))return!1;if(this.size!==e.size)return!1;const t=this.sortedSet.getIterator(),n=e.sortedSet.getIterator();for(;t.hasNext();){const e=t.getNext().key,r=n.getNext().key;if(!e.isEqual(r))return!1}return!0}toString(){const e=[];return this.forEach((t=>{e.push(t.toString())})),0===e.length?"DocumentSet ()":"DocumentSet (\n "+e.join(" \n")+"\n)"}copy(e,t){const n=new rc;return n.comparator=this.comparator,n.keyedMap=e,n.sortedSet=t,n}}class ic{constructor(){this.W_=new nt(z.comparator)}track(e){const t=e.doc.key,n=this.W_.get(t);n?0!==e.type&&3===n.type?this.W_=this.W_.insert(t,e):3===e.type&&1!==n.type?this.W_=this.W_.insert(t,{type:n.type,doc:e.doc}):2===e.type&&2===n.type?this.W_=this.W_.insert(t,{type:2,doc:e.doc}):2===e.type&&0===n.type?this.W_=this.W_.insert(t,{type:0,doc:e.doc}):1===e.type&&0===n.type?this.W_=this.W_.remove(t):1===e.type&&2===n.type?this.W_=this.W_.insert(t,{type:1,doc:n.doc}):0===e.type&&1===n.type?this.W_=this.W_.insert(t,{type:2,doc:e.doc}):v():this.W_=this.W_.insert(t,e)}G_(){const e=[];return this.W_.inorderTraversal(((t,n)=>{e.push(n)})),e}}class sc{constructor(e,t,n,r,i,s,o,a,c){this.query=e,this.docs=t,this.oldDocs=n,this.docChanges=r,this.mutatedKeys=i,this.fromCache=s,this.syncStateChanged=o,this.excludesMetadataChanges=a,this.hasCachedResults=c}static fromInitialDocuments(e,t,n,r,i){const s=[];return t.forEach((e=>{s.push({type:0,doc:e})})),new sc(e,t,rc.emptySet(t),s,n,r,!0,!1,i)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(e){if(!(this.fromCache===e.fromCache&&this.hasCachedResults===e.hasCachedResults&&this.syncStateChanged===e.syncStateChanged&&this.mutatedKeys.isEqual(e.mutatedKeys)&&Vn(this.query,e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;const t=this.docChanges,n=e.docChanges;if(t.length!==n.length)return!1;for(let e=0;e<t.length;e++)if(t[e].type!==n[e].type||!t[e].doc.isEqual(n[e].doc))return!1;return!0}}class oc{constructor(){this.z_=void 0,this.j_=[]}H_(){return this.j_.some((e=>e.J_()))}}class ac{constructor(){this.queries=cc(),this.onlineState="Unknown",this.Y_=new Set}terminate(){!function(e,t){const n=w(e),r=n.queries;n.queries=cc(),r.forEach(((e,n)=>{for(const e of n.j_)e.onError(t)}))}(this,new I(_.ABORTED,"Firestore shutting down"))}}function cc(){return new Kn((e=>Un(e)),Vn)}async function uc(e,t){const n=w(e);let r=3;const i=t.query;let s=n.queries.get(i);s?!s.H_()&&t.J_()&&(r=2):(s=new oc,r=t.J_()?0:1);try{switch(r){case 0:s.z_=await n.onListen(i,!0);break;case 1:s.z_=await n.onListen(i,!1);break;case 2:await n.onFirstRemoteStoreListen(i)}}catch(e){const n=nc(e,`Initialization of query '${jn(t.query)}' failed`);return void t.onError(n)}n.queries.set(i,s),s.j_.push(t),t.Z_(n.onlineState),s.z_&&t.X_(s.z_)&&fc(n)}async function lc(e,t){const n=w(e),r=t.query;let i=3;const s=n.queries.get(r);if(s){const e=s.j_.indexOf(t);e>=0&&(s.j_.splice(e,1),0===s.j_.length?i=t.J_()?0:1:!s.H_()&&t.J_()&&(i=2))}switch(i){case 0:return n.queries.delete(r),n.onUnlisten(r,!0);case 1:return n.queries.delete(r),n.onUnlisten(r,!1);case 2:return n.onLastRemoteStoreUnlisten(r);default:return}}function hc(e,t){const n=w(e);let r=!1;for(const e of t){const t=e.query,i=n.queries.get(t);if(i){for(const t of i.j_)t.X_(e)&&(r=!0);i.z_=e}}r&&fc(n)}function dc(e,t,n){const r=w(e),i=r.queries.get(t);if(i)for(const e of i.j_)e.onError(n);r.queries.delete(t)}function fc(e){e.Y_.forEach((e=>{e.next()}))}var pc,mc;(mc=pc||(pc={})).ea="default",mc.Cache="cache";class gc{constructor(e,t,n){this.query=e,this.ta=t,this.na=!1,this.ra=null,this.onlineState="Unknown",this.options=n||{}}X_(e){if(!this.options.includeMetadataChanges){const t=[];for(const n of e.docChanges)3!==n.type&&t.push(n);e=new sc(e.query,e.docs,e.oldDocs,t,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let t=!1;return this.na?this.ia(e)&&(this.ta.next(e),t=!0):this.sa(e,this.onlineState)&&(this.oa(e),t=!0),this.ra=e,t}onError(e){this.ta.error(e)}Z_(e){this.onlineState=e;let t=!1;return this.ra&&!this.na&&this.sa(this.ra,e)&&(this.oa(this.ra),t=!0),t}sa(e,t){if(!e.fromCache)return!0;if(!this.J_())return!0;const n="Offline"!==t;return(!this.options._a||!n)&&(!e.docs.isEmpty()||e.hasCachedResults||"Offline"===t)}ia(e){if(e.docChanges.length>0)return!0;const t=this.ra&&this.ra.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&!0===this.options.includeMetadataChanges}oa(e){e=sc.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.na=!0,this.ta.next(e)}J_(){return this.options.source!==pc.Cache}}class yc{constructor(e,t){this.aa=e,this.byteLength=t}ua(){return"metadata"in this.aa}}class vc{constructor(e){this.serializer=e}Es(e){return _i(this.serializer,e)}ds(e){return e.metadata.exists?Ai(this.serializer,e.document,!1):$t.newNoDocument(this.Es(e.metadata.name),this.As(e.metadata.readTime))}As(e){return gi(e)}}class bc{constructor(e,t,n){this.ca=e,this.localStore=t,this.serializer=n,this.queries=[],this.documents=[],this.collectionGroups=new Set,this.progress=wc(e)}la(e){this.progress.bytesLoaded+=e.byteLength;let t=this.progress.documentsLoaded;if(e.aa.namedQuery)this.queries.push(e.aa.namedQuery);else if(e.aa.documentMetadata){this.documents.push({metadata:e.aa.documentMetadata}),e.aa.documentMetadata.exists||++t;const n=j.fromString(e.aa.documentMetadata.name);this.collectionGroups.add(n.get(n.length-2))}else e.aa.document&&(this.documents[this.documents.length-1].document=e.aa.document,++t);return t!==this.progress.documentsLoaded?(this.progress.documentsLoaded=t,Object.assign({},this.progress)):null}ha(e){const t=new Map,n=new vc(this.serializer);for(const r of e)if(r.metadata.queries){const e=n.Es(r.metadata.name);for(const n of r.metadata.queries){const r=(t.get(n)||nr()).add(e);t.set(n,r)}}return t}async complete(){const e=await async function(e,t,n,r){const i=w(e);let s=nr(),o=$n();for(const e of n){const n=t.Es(e.metadata.name);e.document&&(s=s.add(n));const r=t.ds(e);r.setReadTime(t.As(e.metadata.readTime)),o=o.insert(n,r)}const a=i.cs.newChangeBuffer({trackRemovals:!0}),c=await Ko(i,function(e){return Rn(kn(j.fromString(`__bundle__/docs/${e}`)))}(r));return i.persistence.runTransaction("Apply bundle documents","readwrite",(e=>zo(e,a,o).next((t=>(a.apply(e),t))).next((t=>i.Ur.removeMatchingKeysForTargetId(e,c.targetId).next((()=>i.Ur.addMatchingKeys(e,s,c.targetId))).next((()=>i.localDocuments.getLocalViewOfDocuments(e,t.Ps,t.Is))).next((()=>t.Ps))))))}(this.localStore,new vc(this.serializer),this.documents,this.ca.id),t=this.ha(this.documents);for(const e of this.queries)await Yo(this.localStore,e,t.get(e.name));return this.progress.taskState="Success",{progress:this.progress,Pa:this.collectionGroups,Ia:e}}}function wc(e){return{taskState:"Running",documentsLoaded:0,bytesLoaded:0,totalDocuments:e.totalDocuments,totalBytes:e.totalBytes}}class _c{constructor(e){this.key=e}}class Ic{constructor(e){this.key=e}}class Ec{constructor(e,t){this.query=e,this.Ta=t,this.Ea=null,this.hasCachedResults=!1,this.current=!1,this.da=nr(),this.mutatedKeys=nr(),this.Aa=zn(e),this.Ra=new rc(this.Aa)}get Va(){return this.Ta}ma(e,t){const n=t?t.fa:new ic,r=t?t.Ra:this.Ra;let i=t?t.mutatedKeys:this.mutatedKeys,s=r,o=!1;const a="F"===this.query.limitType&&r.size===this.query.limit?r.last():null,c="L"===this.query.limitType&&r.size===this.query.limit?r.first():null;if(e.inorderTraversal(((e,t)=>{const u=r.get(e),l=Bn(this.query,t)?t:null,h=!!u&&this.mutatedKeys.has(u.key),d=!!l&&(l.hasLocalMutations||this.mutatedKeys.has(l.key)&&l.hasCommittedMutations);let f=!1;u&&l?u.data.isEqual(l.data)?h!==d&&(n.track({type:3,doc:l}),f=!0):this.ga(u,l)||(n.track({type:2,doc:l}),f=!0,(a&&this.Aa(l,a)>0||c&&this.Aa(l,c)<0)&&(o=!0)):!u&&l?(n.track({type:0,doc:l}),f=!0):u&&!l&&(n.track({type:1,doc:u}),f=!0,(a||c)&&(o=!0)),f&&(l?(s=s.add(l),i=d?i.add(e):i.delete(e)):(s=s.delete(e),i=i.delete(e)))})),null!==this.query.limit)for(;s.size>this.query.limit;){const e="F"===this.query.limitType?s.last():s.first();s=s.delete(e.key),i=i.delete(e.key),n.track({type:1,doc:e})}return{Ra:s,fa:n,ns:o,mutatedKeys:i}}ga(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}applyChanges(e,t,n,r){const i=this.Ra;this.Ra=e.Ra,this.mutatedKeys=e.mutatedKeys;const s=e.fa.G_();s.sort(((e,t)=>function(e,t){const n=e=>{switch(e){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return v()}};return n(e)-n(t)}(e.type,t.type)||this.Aa(e.doc,t.doc))),this.pa(n),r=null!=r&&r;const o=t&&!r?this.ya():[],a=0===this.da.size&&this.current&&!r?1:0,c=a!==this.Ea;return this.Ea=a,0!==s.length||c?{snapshot:new sc(this.query,e.Ra,i,s,e.mutatedKeys,0===a,c,!1,!!n&&n.resumeToken.approximateByteSize()>0),wa:o}:{wa:o}}Z_(e){return this.current&&"Offline"===e?(this.current=!1,this.applyChanges({Ra:this.Ra,fa:new ic,mutatedKeys:this.mutatedKeys,ns:!1},!1)):{wa:[]}}Sa(e){return!this.Ta.has(e)&&!!this.Ra.has(e)&&!this.Ra.get(e).hasLocalMutations}pa(e){e&&(e.addedDocuments.forEach((e=>this.Ta=this.Ta.add(e))),e.modifiedDocuments.forEach((e=>{})),e.removedDocuments.forEach((e=>this.Ta=this.Ta.delete(e))),this.current=e.current)}ya(){if(!this.current)return[];const e=this.da;this.da=nr(),this.Ra.forEach((e=>{this.Sa(e.key)&&(this.da=this.da.add(e.key))}));const t=[];return e.forEach((e=>{this.da.has(e)||t.push(new Ic(e))})),this.da.forEach((n=>{e.has(n)||t.push(new _c(n))})),t}ba(e){this.Ta=e.Ts,this.da=nr();const t=this.ma(e.documents);return this.applyChanges(t,!0)}Da(){return sc.fromInitialDocuments(this.query,this.Ra,this.mutatedKeys,0===this.Ea,this.hasCachedResults)}}class Tc{constructor(e,t,n){this.query=e,this.targetId=t,this.view=n}}class Sc{constructor(e){this.key=e,this.va=!1}}class Cc{constructor(e,t,n,r,i,s){this.localStore=e,this.remoteStore=t,this.eventManager=n,this.sharedClientState=r,this.currentUser=i,this.maxConcurrentLimboResolutions=s,this.Ca={},this.Fa=new Kn((e=>Un(e)),Vn),this.Ma=new Map,this.xa=new Set,this.Oa=new nt(z.comparator),this.Na=new Map,this.La=new bo,this.Ba={},this.ka=new Map,this.qa=Ws.kn(),this.onlineState="Unknown",this.Qa=void 0}get isPrimaryClient(){return!0===this.Qa}}async function Ac(e,t,n=!0){const r=nu(e);let i;const s=r.Fa.get(t);return s?(r.sharedClientState.addLocalQueryTarget(s.targetId),i=s.view.Da()):i=await kc(r,t,n,!0),i}async function xc(e,t){const n=nu(e);await kc(n,t,!0,!1)}async function kc(e,t,n,r){const i=await Ko(e.localStore,Rn(t)),s=i.targetId,o=n?e.sharedClientState.addLocalQueryTarget(s):"not-current";let a;return r&&(a=await Nc(e,t,s,"current"===o,i.resumeToken)),e.isPrimaryClient&&n&&xa(e.remoteStore,i),a}async function Nc(e,t,n,r,i){e.Ka=(t,n,r)=>async function(e,t,n,r){let i=t.view.ma(n);i.ns&&(i=await $o(e.localStore,t.query,!1).then((({documents:e})=>t.view.ma(e,i))));const s=r&&r.targetChanges.get(t.targetId),o=r&&null!=r.targetMismatches.get(t.targetId),a=t.view.applyChanges(i,e.isPrimaryClient,s,o);return qc(e,t.targetId,a.wa),a.snapshot}(e,t,n,r);const s=await $o(e.localStore,t,!0),o=new Ec(t,s.Ts),a=o.ma(s.documents),c=ei.createSynthesizedTargetChangeForCurrentChange(n,r&&"Offline"!==e.onlineState,i),u=o.applyChanges(a,e.isPrimaryClient,c);qc(e,n,u.wa);const l=new Tc(t,n,o);return e.Fa.set(t,l),e.Ma.has(n)?e.Ma.get(n).push(t):e.Ma.set(n,[t]),u.snapshot}async function Oc(e,t,n){const r=w(e),i=r.Fa.get(t),s=r.Ma.get(i.targetId);if(s.length>1)return r.Ma.set(i.targetId,s.filter((e=>!Vn(e,t)))),void r.Fa.delete(t);r.isPrimaryClient?(r.sharedClientState.removeLocalQueryTarget(i.targetId),r.sharedClientState.isActiveQueryTarget(i.targetId)||await Wo(r.localStore,i.targetId,!1).then((()=>{r.sharedClientState.clearQueryState(i.targetId),n&&ka(r.remoteStore,i.targetId),jc(r,i.targetId)})).catch(re)):(jc(r,i.targetId),await Wo(r.localStore,i.targetId,!0))}async function Dc(e,t){const n=w(e),r=n.Fa.get(t),i=n.Ma.get(r.targetId);n.isPrimaryClient&&1===i.length&&(n.sharedClientState.removeLocalQueryTarget(r.targetId),ka(n.remoteStore,r.targetId))}async function Rc(e,t){const n=w(e);try{const e=await function(e,t){const n=w(e),r=t.snapshotVersion;let i=n.os;return n.persistence.runTransaction("Apply remote event","readwrite-primary",(e=>{const s=n.cs.newChangeBuffer({trackRemovals:!0});i=n.os;const o=[];t.targetChanges.forEach(((s,a)=>{const c=i.get(a);if(!c)return;o.push(n.Ur.removeMatchingKeys(e,s.removedDocuments,a).next((()=>n.Ur.addMatchingKeys(e,s.addedDocuments,a))));let u=c.withSequenceNumber(e.currentSequenceNumber);null!==t.targetMismatches.get(a)?u=u.withResumeToken(lt.EMPTY_BYTE_STRING,V.min()).withLastLimboFreeSnapshotVersion(V.min()):s.resumeToken.approximateByteSize()>0&&(u=u.withResumeToken(s.resumeToken,r)),i=i.insert(a,u),function(e,t,n){return 0===e.resumeToken.approximateByteSize()||t.snapshotVersion.toMicroseconds()-e.snapshotVersion.toMicroseconds()>=3e8||n.addedDocuments.size+n.modifiedDocuments.size+n.removedDocuments.size>0}(c,u,s)&&o.push(n.Ur.updateTargetData(e,u))}));let a=$n(),c=nr();if(t.documentUpdates.forEach((r=>{t.resolvedLimboDocuments.has(r)&&o.push(n.persistence.referenceDelegate.updateLimboDocument(e,r))})),o.push(zo(e,s,t.documentUpdates).next((e=>{a=e.Ps,c=e.Is}))),!r.isEqual(V.min())){const t=n.Ur.getLastRemoteSnapshotVersion(e).next((t=>n.Ur.setTargetsMetadata(e,e.currentSequenceNumber,r)));o.push(t)}return ie.waitFor(o).next((()=>s.apply(e))).next((()=>n.localDocuments.getLocalViewOfDocuments(e,a,c))).next((()=>a))})).then((e=>(n.os=i,e)))}(n.localStore,t);t.targetChanges.forEach(((e,t)=>{const r=n.Na.get(t);r&&(b(e.addedDocuments.size+e.modifiedDocuments.size+e.removedDocuments.size<=1),e.addedDocuments.size>0?r.va=!0:e.modifiedDocuments.size>0?b(r.va):e.removedDocuments.size>0&&(b(r.va),r.va=!1))})),await Kc(n,e,t)}catch(e){await re(e)}}function Pc(e,t,n){const r=w(e);if(r.isPrimaryClient&&0===n||!r.isPrimaryClient&&1===n){const e=[];r.Fa.forEach(((n,r)=>{const i=r.view.Z_(t);i.snapshot&&e.push(i.snapshot)})),function(e,t){const n=w(e);n.onlineState=t;let r=!1;n.queries.forEach(((e,n)=>{for(const e of n.j_)e.Z_(t)&&(r=!0)})),r&&fc(n)}(r.eventManager,t),e.length&&r.Ca.d_(e),r.onlineState=t,r.isPrimaryClient&&r.sharedClientState.setOnlineState(t)}}async function Lc(e,t,n){const r=w(e);r.sharedClientState.updateQueryState(t,"rejected",n);const i=r.Na.get(t),s=i&&i.key;if(s){let e=new nt(z.comparator);e=e.insert(s,$t.newNoDocument(s,V.min()));const n=nr().add(s),i=new Zr(V.min(),new Map,new nt(P),e,n);await Rc(r,i),r.Oa=r.Oa.remove(s),r.Na.delete(t),Gc(r)}else await Wo(r.localStore,t,!1).then((()=>jc(r,t,n))).catch(re)}async function Mc(e,t){const n=w(e),r=t.batch.batchId;try{const e=await function(e,t){const n=w(e);return n.persistence.runTransaction("Acknowledge batch","readwrite-primary",(e=>{const r=t.batch.keys(),i=n.cs.newChangeBuffer({trackRemovals:!0});return function(e,t,n,r){const i=n.batch,s=i.keys();let o=ie.resolve();return s.forEach((e=>{o=o.next((()=>r.getEntry(t,e))).next((t=>{const s=n.docVersions.get(e);b(null!==s),t.version.compareTo(s)<0&&(i.applyToRemoteDocument(t,n),t.isValidDocument()&&(t.setReadTime(n.commitVersion),r.addEntry(t)))}))})),o.next((()=>e.mutationQueue.removeMutationBatch(t,i)))}(n,e,t,i).next((()=>i.apply(e))).next((()=>n.mutationQueue.performConsistencyCheck(e))).next((()=>n.documentOverlayCache.removeOverlaysForBatchId(e,r,t.batch.batchId))).next((()=>n.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(e,function(e){let t=nr();for(let n=0;n<e.mutationResults.length;++n)e.mutationResults[n].transformResults.length>0&&(t=t.add(e.batch.mutations[n].key));return t}(t)))).next((()=>n.localDocuments.getDocuments(e,r)))}))}(n.localStore,t);Uc(n,r,null),Vc(n,r),n.sharedClientState.updateMutationState(r,"acknowledged"),await Kc(n,e)}catch(e){await re(e)}}async function Fc(e,t,n){const r=w(e);try{const e=await function(e,t){const n=w(e);return n.persistence.runTransaction("Reject batch","readwrite-primary",(e=>{let r;return n.mutationQueue.lookupMutationBatch(e,t).next((t=>(b(null!==t),r=t.keys(),n.mutationQueue.removeMutationBatch(e,t)))).next((()=>n.mutationQueue.performConsistencyCheck(e))).next((()=>n.documentOverlayCache.removeOverlaysForBatchId(e,r,t))).next((()=>n.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(e,r))).next((()=>n.localDocuments.getDocuments(e,r)))}))}(r.localStore,t);Uc(r,t,n),Vc(r,t),r.sharedClientState.updateMutationState(t,"rejected",n),await Kc(r,e)}catch(n){await re(n)}}function Vc(e,t){(e.ka.get(t)||[]).forEach((e=>{e.resolve()})),e.ka.delete(t)}function Uc(e,t,n){const r=w(e);let i=r.Ba[r.currentUser.toKey()];if(i){const e=i.get(t);e&&(n?e.reject(n):e.resolve(),i=i.remove(t)),r.Ba[r.currentUser.toKey()]=i}}function jc(e,t,n=null){e.sharedClientState.removeLocalQueryTarget(t);for(const r of e.Ma.get(t))e.Fa.delete(r),n&&e.Ca.$a(r,n);e.Ma.delete(t),e.isPrimaryClient&&e.La.gr(t).forEach((t=>{e.La.containsKey(t)||Bc(e,t)}))}function Bc(e,t){e.xa.delete(t.path.canonicalString());const n=e.Oa.get(t);null!==n&&(ka(e.remoteStore,n),e.Oa=e.Oa.remove(t),e.Na.delete(n),Gc(e))}function qc(e,t,n){for(const r of n)r instanceof _c?(e.La.addReference(r.key,t),zc(e,r)):r instanceof Ic?(p("SyncEngine","Document no longer in limbo: "+r.key),e.La.removeReference(r.key,t),e.La.containsKey(r.key)||Bc(e,r.key)):v()}function zc(e,t){const n=t.key,r=n.path.canonicalString();e.Oa.get(n)||e.xa.has(r)||(p("SyncEngine","New document in limbo: "+n),e.xa.add(r),Gc(e))}function Gc(e){for(;e.xa.size>0&&e.Oa.size<e.maxConcurrentLimboResolutions;){const t=e.xa.values().next().value;e.xa.delete(t);const n=new z(j.fromString(t)),r=e.qa.next();e.Na.set(r,new Sc(n)),e.Oa=e.Oa.insert(n,r),xa(e.remoteStore,new zi(Rn(kn(n.path)),r,"TargetPurposeLimboResolution",ye.oe))}}async function Kc(e,t,n){const r=w(e),i=[],s=[],o=[];r.Fa.isEmpty()||(r.Fa.forEach(((e,a)=>{o.push(r.Ka(a,t,n).then((e=>{var t;if((e||n)&&r.isPrimaryClient){const i=e?!e.fromCache:null===(t=null==n?void 0:n.targetChanges.get(a.targetId))||void 0===t?void 0:t.current;r.sharedClientState.updateQueryState(a.targetId,i?"current":"not-current")}if(e){i.push(e);const t=Mo.Wi(a.targetId,e);s.push(t)}})))})),await Promise.all(o),r.Ca.d_(i),await async function(e,t){const n=w(e);try{await n.persistence.runTransaction("notifyLocalViewChanges","readwrite",(e=>ie.forEach(t,(t=>ie.forEach(t.$i,(r=>n.persistence.referenceDelegate.addReference(e,t.targetId,r))).next((()=>ie.forEach(t.Ui,(r=>n.persistence.referenceDelegate.removeReference(e,t.targetId,r)))))))))}catch(e){if(!le(e))throw e;p("LocalStore","Failed to update sequence numbers: "+e)}for(const e of t){const t=e.targetId;if(!e.fromCache){const e=n.os.get(t),r=e.snapshotVersion,i=e.withLastLimboFreeSnapshotVersion(r);n.os=n.os.insert(t,i)}}}(r.localStore,s))}async function Wc(e,t){const n=w(e);if(!n.currentUser.isEqual(t)){p("SyncEngine","User change. New user:",t.toKey());const e=await Bo(n.localStore,t);n.currentUser=t,function(e){e.ka.forEach((e=>{e.forEach((e=>{e.reject(new I(_.CANCELLED,"'waitForPendingWrites' promise is rejected due to a user change."))}))})),e.ka.clear()}(n),n.sharedClientState.handleUserChange(t,e.removedBatchIds,e.addedBatchIds),await Kc(n,e.hs)}}function $c(e,t){const n=w(e),r=n.Na.get(t);if(r&&r.va)return nr().add(r.key);{let e=nr();const r=n.Ma.get(t);if(!r)return e;for(const t of r){const r=n.Fa.get(t);e=e.unionWith(r.view.Va)}return e}}async function Hc(e,t){const n=w(e),r=await $o(n.localStore,t.query,!0),i=t.view.ba(r);return n.isPrimaryClient&&qc(n,t.targetId,i.wa),i}async function Qc(e,t){const n=w(e);return Qo(n.localStore,t).then((e=>Kc(n,e)))}async function Jc(e,t,n,r){const i=w(e),s=await function(e,t){const n=w(e),r=w(n.mutationQueue);return n.persistence.runTransaction("Lookup mutation documents","readonly",(e=>r.Mn(e,t).next((t=>t?n.localDocuments.getDocuments(e,t):ie.resolve(null)))))}(i.localStore,t);null!==s?("pending"===n?await qa(i.remoteStore):"acknowledged"===n||"rejected"===n?(Uc(i,t,r||null),Vc(i,t),function(e,t){w(w(e).mutationQueue).On(t)}(i.localStore,t)):v(),await Kc(i,s)):p("SyncEngine","Cannot apply mutation batch with id: "+t)}async function Yc(e,t,n){const r=w(e),i=[],s=[];for(const e of t){let t;const n=r.Ma.get(e);if(n&&0!==n.length){t=await Ko(r.localStore,Rn(n[0]));for(const e of n){const t=r.Fa.get(e),n=await Hc(r,t);n.snapshot&&s.push(n.snapshot)}}else{const n=await Ho(r.localStore,e);t=await Ko(r.localStore,n),await Nc(r,Xc(n),e,!1,t.resumeToken)}i.push(t)}return r.Ca.d_(s),i}function Xc(e){return xn(e.path,e.collectionGroup,e.orderBy,e.filters,e.limit,"F",e.startAt,e.endAt)}function Zc(e){return function(e){return w(w(e).persistence).Qi()}(w(e).localStore)}async function eu(e,t,n,r){const i=w(e);if(i.Qa)return void p("SyncEngine","Ignoring unexpected query state notification.");const s=i.Ma.get(t);if(s&&s.length>0)switch(n){case"current":case"not-current":{const e=await Qo(i.localStore,qn(s[0])),r=Zr.createSynthesizedRemoteEventForCurrentChange(t,"current"===n,lt.EMPTY_BYTE_STRING);await Kc(i,e,r);break}case"rejected":await Wo(i.localStore,t,!0),jc(i,t,r);break;default:v()}}async function tu(e,t,n){const r=nu(e);if(r.Qa){for(const e of t){if(r.Ma.has(e)&&r.sharedClientState.isActiveQueryTarget(e)){p("SyncEngine","Adding an already active target "+e);continue}const t=await Ho(r.localStore,e),n=await Ko(r.localStore,t);await Nc(r,Xc(t),n.targetId,!1,n.resumeToken),xa(r.remoteStore,n)}for(const e of n)r.Ma.has(e)&&await Wo(r.localStore,e,!1).then((()=>{ka(r.remoteStore,e),jc(r,e)})).catch(re)}}function nu(e){const t=w(e);return t.remoteStore.remoteSyncer.applyRemoteEvent=Rc.bind(null,t),t.remoteStore.remoteSyncer.getRemoteKeysForTarget=$c.bind(null,t),t.remoteStore.remoteSyncer.rejectListen=Lc.bind(null,t),t.Ca.d_=hc.bind(null,t.eventManager),t.Ca.$a=dc.bind(null,t.eventManager),t}function ru(e){const t=w(e);return t.remoteStore.remoteSyncer.applySuccessfulWrite=Mc.bind(null,t),t.remoteStore.remoteSyncer.rejectFailedWrite=Fc.bind(null,t),t}class iu{constructor(){this.synchronizeTabs=!1}async initialize(e){this.serializer=va(e.databaseInfo.databaseId),this.sharedClientState=this.createSharedClientState(e),this.persistence=this.createPersistence(e),await this.persistence.start(),this.localStore=this.createLocalStore(e),this.gcScheduler=this.createGarbageCollectionScheduler(e,this.localStore),this.indexBackfillerScheduler=this.createIndexBackfillerScheduler(e,this.localStore)}createGarbageCollectionScheduler(e,t){return null}createIndexBackfillerScheduler(e,t){return null}createLocalStore(e){return jo(this.persistence,new Vo,e.initialUser,this.serializer)}createPersistence(e){return new So(Ao.Zr,this.serializer)}createSharedClientState(e){return new aa}async terminate(){var e,t;null===(e=this.gcScheduler)||void 0===e||e.stop(),null===(t=this.indexBackfillerScheduler)||void 0===t||t.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}}class su extends iu{constructor(e){super(),this.cacheSizeBytes=e}createGarbageCollectionScheduler(e,t){b(this.persistence.referenceDelegate instanceof xo);const n=this.persistence.referenceDelegate.garbageCollector;return new Zs(n,e.asyncQueue,t)}createPersistence(e){const t=void 0!==this.cacheSizeBytes?Vs.withCacheSize(this.cacheSizeBytes):Vs.DEFAULT;return new So((e=>xo.Zr(e,t)),this.serializer)}}class ou extends iu{constructor(e,t,n){super(),this.Wa=e,this.cacheSizeBytes=t,this.forceOwnership=n,this.synchronizeTabs=!1}async initialize(e){await super.initialize(e),await this.Wa.initialize(this,e),await ru(this.Wa.syncEngine),await qa(this.Wa.remoteStore),await this.persistence.yi((()=>(this.gcScheduler&&!this.gcScheduler.started&&this.gcScheduler.start(),this.indexBackfillerScheduler&&!this.indexBackfillerScheduler.started&&this.indexBackfillerScheduler.start(),Promise.resolve())))}createLocalStore(e){return jo(this.persistence,new Vo,e.initialUser,this.serializer)}createGarbageCollectionScheduler(e,t){const n=this.persistence.referenceDelegate.garbageCollector;return new Zs(n,e.asyncQueue,t)}createIndexBackfillerScheduler(e,t){const n=new ge(t,this.persistence);return new me(e.asyncQueue,n)}createPersistence(e){const t=Lo(e.databaseInfo.databaseId,e.databaseInfo.persistenceKey),n=void 0!==this.cacheSizeBytes?Vs.withCacheSize(this.cacheSizeBytes):Vs.DEFAULT;return new Do(this.synchronizeTabs,t,e.clientId,n,e.asyncQueue,ga(),ya(),this.serializer,this.sharedClientState,!!this.forceOwnership)}createSharedClientState(e){return new aa}}class au extends ou{constructor(e,t){super(e,t,!1),this.Wa=e,this.cacheSizeBytes=t,this.synchronizeTabs=!0}async initialize(e){await super.initialize(e);const t=this.Wa.syncEngine;this.sharedClientState instanceof oa&&(this.sharedClientState.syncEngine={no:Jc.bind(null,t),ro:eu.bind(null,t),io:tu.bind(null,t),Qi:Zc.bind(null,t),eo:Qc.bind(null,t)},await this.sharedClientState.start()),await this.persistence.yi((async e=>{await async function(e,t){const n=w(e);if(nu(n),ru(n),!0===t&&!0!==n.Qa){const e=n.sharedClientState.getAllActiveQueryTargets(),t=await Yc(n,e.toArray());n.Qa=!0,await Xa(n.remoteStore,!0);for(const e of t)xa(n.remoteStore,e)}else if(!1===t&&!1!==n.Qa){const e=[];let t=Promise.resolve();n.Ma.forEach(((r,i)=>{n.sharedClientState.isLocalQueryTarget(i)?e.push(i):t=t.then((()=>(jc(n,i),Wo(n.localStore,i,!0)))),ka(n.remoteStore,i)})),await t,await Yc(n,e),function(e){const t=w(e);t.Na.forEach(((e,n)=>{ka(t.remoteStore,n)})),t.La.pr(),t.Na=new Map,t.Oa=new nt(z.comparator)}(n),n.Qa=!1,await Xa(n.remoteStore,!1)}}(this.Wa.syncEngine,e),this.gcScheduler&&(e&&!this.gcScheduler.started?this.gcScheduler.start():e||this.gcScheduler.stop()),this.indexBackfillerScheduler&&(e&&!this.indexBackfillerScheduler.started?this.indexBackfillerScheduler.start():e||this.indexBackfillerScheduler.stop())}))}createSharedClientState(e){const t=ga();if(!oa.D(t))throw new I(_.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");const n=Lo(e.databaseInfo.databaseId,e.databaseInfo.persistenceKey);return new oa(t,e.asyncQueue,n,e.clientId,e.initialUser)}}class cu{async initialize(e,t){this.localStore||(this.localStore=e.localStore,this.sharedClientState=e.sharedClientState,this.datastore=this.createDatastore(t),this.remoteStore=this.createRemoteStore(t),this.eventManager=this.createEventManager(t),this.syncEngine=this.createSyncEngine(t,!e.synchronizeTabs),this.sharedClientState.onlineStateHandler=e=>Pc(this.syncEngine,e,1),this.remoteStore.remoteSyncer.handleCredentialChange=Wc.bind(null,this.syncEngine),await Xa(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return new ac}createDatastore(e){const t=va(e.databaseInfo.databaseId),n=function(e){return new ma(e)}(e.databaseInfo);return function(e,t,n,r){return new Ea(e,t,n,r)}(e.authCredentials,e.appCheckCredentials,n,t)}createRemoteStore(e){return function(e,t,n,r,i){return new Sa(e,t,n,r,i)}(this.localStore,this.datastore,e.asyncQueue,(e=>Pc(this.syncEngine,e,0)),ua.D()?new ua:new ca)}createSyncEngine(e,t){return function(e,t,n,r,i,s,o){const a=new Cc(e,t,n,r,i,s);return o&&(a.Qa=!0),a}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,e.initialUser,e.maxConcurrentLimboResolutions,t)}async terminate(){var e,t;await async function(e){const t=w(e);p("RemoteStore","RemoteStore shutting down."),t.L_.add(5),await Aa(t),t.k_.shutdown(),t.q_.set("Unknown")}(this.remoteStore),null===(e=this.datastore)||void 0===e||e.terminate(),null===(t=this.eventManager)||void 0===t||t.terminate()}}function uu(e,t=10240){let n=0;return{async read(){if(n<e.byteLength){const r={value:e.slice(n,n+t),done:!1};return n+=t,r}return{done:!0}},async cancel(){},releaseLock(){},closed:Promise.resolve()}}class lu{constructor(e){this.observer=e,this.muted=!1}next(e){this.observer.next&&this.Ga(this.observer.next,e)}error(e){this.observer.error?this.Ga(this.observer.error,e):m("Uncaught Error in snapshot listener:",e.toString())}za(){this.muted=!0}Ga(e,t){this.muted||setTimeout((()=>{this.muted||e(t)}),0)}}class hu{constructor(e,t){this.ja=e,this.serializer=t,this.metadata=new E,this.buffer=new Uint8Array,this.Ha=new TextDecoder("utf-8"),this.Ja().then((e=>{e&&e.ua()?this.metadata.resolve(e.aa.metadata):this.metadata.reject(new Error(`The first element of the bundle is not a metadata, it is\n ${JSON.stringify(null==e?void 0:e.aa)}`))}),(e=>this.metadata.reject(e)))}close(){return this.ja.cancel()}async getMetadata(){return this.metadata.promise}async Ua(){return await this.getMetadata(),this.Ja()}async Ja(){const e=await this.Ya();if(null===e)return null;const t=this.Ha.decode(e),n=Number(t);isNaN(n)&&this.Za(`length string (${t}) is not valid number`);const r=await this.Xa(n);return new yc(JSON.parse(r),e.length+n)}eu(){return this.buffer.findIndex((e=>e==="{".charCodeAt(0)))}async Ya(){for(;this.eu()<0&&!await this.tu(););if(0===this.buffer.length)return null;const e=this.eu();e<0&&this.Za("Reached the end of bundle when a length string is expected.");const t=this.buffer.slice(0,e);return this.buffer=this.buffer.slice(e),t}async Xa(e){for(;this.buffer.length<e;)await this.tu()&&this.Za("Reached the end of bundle when more is expected.");const t=this.Ha.decode(this.buffer.slice(0,e));return this.buffer=this.buffer.slice(e),t}Za(e){throw this.ja.cancel(),new Error(`Invalid bundle format: ${e}`)}async tu(){const e=await this.ja.read();if(!e.done){const t=new Uint8Array(this.buffer.length+e.value.length);t.set(this.buffer),t.set(e.value,this.buffer.length),this.buffer=t}return e.done}}class du{constructor(e){this.datastore=e,this.readVersions=new Map,this.mutations=[],this.committed=!1,this.lastTransactionError=null,this.writtenDocs=new Set}async lookup(e){if(this.ensureCommitNotCalled(),this.mutations.length>0)throw this.lastTransactionError=new I(_.INVALID_ARGUMENT,"Firestore transactions require all reads to be executed before all writes."),this.lastTransactionError;const t=await async function(e,t){const n=w(e),r={documents:t.map((e=>wi(n.serializer,e)))},i=await n.Lo("BatchGetDocuments",n.serializer.databaseId,j.emptyPath(),r,t.length),s=new Map;i.forEach((e=>{const t=function(e,t){return"found"in t?function(e,t){b(!!t.found),t.found.name,t.found.updateTime;const n=_i(e,t.found.name),r=gi(t.found.updateTime),i=t.found.createTime?gi(t.found.createTime):V.min(),s=new Kt({mapValue:{fields:t.found.fields}});return $t.newFoundDocument(n,r,i,s)}(e,t):"missing"in t?function(e,t){b(!!t.missing),b(!!t.readTime);const n=_i(e,t.missing),r=gi(t.readTime);return $t.newNoDocument(n,r)}(e,t):v()}(n.serializer,e);s.set(t.key.toString(),t)}));const o=[];return t.forEach((e=>{const t=s.get(e.toString());b(!!t),o.push(t)})),o}(this.datastore,e);return t.forEach((e=>this.recordVersion(e))),t}set(e,t){this.write(t.toMutation(e,this.precondition(e))),this.writtenDocs.add(e.toString())}update(e,t){try{this.write(t.toMutation(e,this.preconditionForUpdate(e)))}catch(e){this.lastTransactionError=e}this.writtenDocs.add(e.toString())}delete(e){this.write(new Lr(e,this.precondition(e))),this.writtenDocs.add(e.toString())}async commit(){if(this.ensureCommitNotCalled(),this.lastTransactionError)throw this.lastTransactionError;const e=this.readVersions;this.mutations.forEach((t=>{e.delete(t.key.toString())})),e.forEach(((e,t)=>{const n=z.fromPath(t);this.mutations.push(new Mr(n,this.precondition(n)))})),await async function(e,t){const n=w(e),r={writes:t.map((e=>xi(n.serializer,e)))};await n.Mo("Commit",n.serializer.databaseId,j.emptyPath(),r)}(this.datastore,this.mutations),this.committed=!0}recordVersion(e){let t;if(e.isFoundDocument())t=e.version;else{if(!e.isNoDocument())throw v();t=V.min()}const n=this.readVersions.get(e.key.toString());if(n){if(!t.isEqual(n))throw new I(_.ABORTED,"Document version changed between two reads.")}else this.readVersions.set(e.key.toString(),t)}precondition(e){const t=this.readVersions.get(e.toString());return!this.writtenDocs.has(e.toString())&&t?t.isEqual(V.min())?Ir.exists(!1):Ir.updateTime(t):Ir.none()}preconditionForUpdate(e){const t=this.readVersions.get(e.toString());if(!this.writtenDocs.has(e.toString())&&t){if(t.isEqual(V.min()))throw new I(_.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return Ir.updateTime(t)}return Ir.exists(!0)}write(e){this.ensureCommitNotCalled(),this.mutations.push(e)}ensureCommitNotCalled(){}}class fu{constructor(e,t,n,r,i){this.asyncQueue=e,this.datastore=t,this.options=n,this.updateFunction=r,this.deferred=i,this.nu=n.maxAttempts,this.t_=new ba(this.asyncQueue,"transaction_retry")}ru(){this.nu-=1,this.iu()}iu(){this.t_.Go((async()=>{const e=new du(this.datastore),t=this.su(e);t&&t.then((t=>{this.asyncQueue.enqueueAndForget((()=>e.commit().then((()=>{this.deferred.resolve(t)})).catch((e=>{this.ou(e)}))))})).catch((e=>{this.ou(e)}))}))}su(e){try{const t=this.updateFunction(e);return!ve(t)&&t.catch&&t.then?t:(this.deferred.reject(Error("Transaction callback must return a Promise")),null)}catch(e){return this.deferred.reject(e),null}}ou(e){this.nu>0&&this._u(e)?(this.nu-=1,this.asyncQueue.enqueueAndForget((()=>(this.iu(),Promise.resolve())))):this.deferred.reject(e)}_u(e){if("FirebaseError"===e.name){const t=e.code;return"aborted"===t||"failed-precondition"===t||"already-exists"===t||!Gr(t)}return!1}}class pu{constructor(e,t,n,r){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=n,this.databaseInfo=r,this.user=l.UNAUTHENTICATED,this.clientId=R.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this.authCredentials.start(n,(async e=>{p("FirestoreClient","Received user=",e.uid),await this.authCredentialListener(e),this.user=e})),this.appCheckCredentials.start(n,(e=>(p("FirestoreClient","Received new app check token=",e),this.appCheckCredentialListener(e,this.user))))}get configuration(){return{asyncQueue:this.asyncQueue,databaseInfo:this.databaseInfo,clientId:this.clientId,authCredentials:this.authCredentials,appCheckCredentials:this.appCheckCredentials,initialUser:this.user,maxConcurrentLimboResolutions:100}}setCredentialChangeListener(e){this.authCredentialListener=e}setAppCheckTokenChangeListener(e){this.appCheckCredentialListener=e}verifyNotTerminated(){if(this.asyncQueue.isShuttingDown)throw new I(_.FAILED_PRECONDITION,"The client has already been terminated.")}terminate(){this.asyncQueue.enterRestrictedMode();const e=new E;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted((async()=>{try{this._onlineComponents&&await this._onlineComponents.terminate(),this._offlineComponents&&await this._offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),e.resolve()}catch(t){const n=nc(t,"Failed to shutdown persistence");e.reject(n)}})),e.promise}}async function mu(e,t){e.asyncQueue.verifyOperationInProgress(),p("FirestoreClient","Initializing OfflineComponentProvider");const n=e.configuration;await t.initialize(n);let r=n.initialUser;e.setCredentialChangeListener((async e=>{r.isEqual(e)||(await Bo(t.localStore,e),r=e)})),t.persistence.setDatabaseDeletedListener((()=>e.terminate())),e._offlineComponents=t}async function gu(e,t){e.asyncQueue.verifyOperationInProgress();const n=await vu(e);p("FirestoreClient","Initializing OnlineComponentProvider"),await t.initialize(n,e.configuration),e.setCredentialChangeListener((e=>Ya(t.remoteStore,e))),e.setAppCheckTokenChangeListener(((e,n)=>Ya(t.remoteStore,n))),e._onlineComponents=t}function yu(e){return"FirebaseError"===e.name?e.code===_.FAILED_PRECONDITION||e.code===_.UNIMPLEMENTED:!("undefined"!=typeof DOMException&&e instanceof DOMException)||22===e.code||20===e.code||11===e.code}async function vu(e){if(!e._offlineComponents)if(e._uninitializedComponentsProvider){p("FirestoreClient","Using user provided OfflineComponentProvider");try{await mu(e,e._uninitializedComponentsProvider._offline)}catch(t){const n=t;if(!yu(n))throw n;g("Error using user provided cache. Falling back to memory cache: "+n),await mu(e,new iu)}}else p("FirestoreClient","Using default OfflineComponentProvider"),await mu(e,new iu);return e._offlineComponents}async function bu(e){return e._onlineComponents||(e._uninitializedComponentsProvider?(p("FirestoreClient","Using user provided OnlineComponentProvider"),await gu(e,e._uninitializedComponentsProvider._online)):(p("FirestoreClient","Using default OnlineComponentProvider"),await gu(e,new cu))),e._onlineComponents}function wu(e){return vu(e).then((e=>e.persistence))}function _u(e){return vu(e).then((e=>e.localStore))}function Iu(e){return bu(e).then((e=>e.remoteStore))}function Eu(e){return bu(e).then((e=>e.syncEngine))}function Tu(e){return bu(e).then((e=>e.datastore))}async function Su(e){const t=await bu(e),n=t.eventManager;return n.onListen=Ac.bind(null,t.syncEngine),n.onUnlisten=Oc.bind(null,t.syncEngine),n.onFirstRemoteStoreListen=xc.bind(null,t.syncEngine),n.onLastRemoteStoreUnlisten=Dc.bind(null,t.syncEngine),n}function Cu(e,t,n={}){const r=new E;return e.asyncQueue.enqueueAndForget((async()=>function(e,t,n,r,i){const s=new lu({next:s=>{t.enqueueAndForget((()=>lc(e,o)));const a=s.docs.has(n);!a&&s.fromCache?i.reject(new I(_.UNAVAILABLE,"Failed to get document because the client is offline.")):a&&s.fromCache&&r&&"server"===r.source?i.reject(new I(_.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:e=>i.reject(e)}),o=new gc(kn(n.path),s,{includeMetadataChanges:!0,_a:!0});return uc(e,o)}(await Su(e),e.asyncQueue,t,n,r))),r.promise}function Au(e,t,n={}){const r=new E;return e.asyncQueue.enqueueAndForget((async()=>function(e,t,n,r,i){const s=new lu({next:n=>{t.enqueueAndForget((()=>lc(e,o))),n.fromCache&&"server"===r.source?i.reject(new I(_.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:e=>i.reject(e)}),o=new gc(n,s,{includeMetadataChanges:!0,_a:!0});return uc(e,o)}(await Su(e),e.asyncQueue,t,n,r))),r.promise}function xu(e){const t={};return void 0!==e.timeoutSeconds&&(t.timeoutSeconds=e.timeoutSeconds),t}const ku=new Map;function Nu(e,t,n){if(!n)throw new I(_.INVALID_ARGUMENT,`Function ${e}() cannot be called with an empty ${t}.`)}function Ou(e,t,n,r){if(!0===t&&!0===r)throw new I(_.INVALID_ARGUMENT,`${e} and ${n} cannot be used together.`)}function Du(e){if(!z.isDocumentKey(e))throw new I(_.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${e} has ${e.length}.`)}function Ru(e){if(z.isDocumentKey(e))throw new I(_.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${e} has ${e.length}.`)}function Pu(e){if(void 0===e)return"undefined";if(null===e)return"null";if("string"==typeof e)return e.length>20&&(e=`${e.substring(0,20)}...`),JSON.stringify(e);if("number"==typeof e||"boolean"==typeof e)return""+e;if("object"==typeof e){if(e instanceof Array)return"an array";{const t=function(e){return e.constructor?e.constructor.name:null}(e);return t?`a custom ${t} object`:"an object"}}return"function"==typeof e?"a function":v()}function Lu(e,t){if("_delegate"in e&&(e=e._delegate),!(e instanceof t)){if(t.name===e.constructor.name)throw new I(_.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{const n=Pu(e);throw new I(_.INVALID_ARGUMENT,`Expected type '${t.name}', but it was: ${n}`)}}return e}function Mu(e,t){if(t<=0)throw new I(_.INVALID_ARGUMENT,`Function ${e}() requires a positive number, but it was: ${t}.`)}class Fu{constructor(e){var t,n;if(void 0===e.host){if(void 0!==e.ssl)throw new I(_.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host="firestore.googleapis.com",this.ssl=!0}else this.host=e.host,this.ssl=null===(t=e.ssl)||void 0===t||t;if(this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,this.localCache=e.localCache,void 0===e.cacheSizeBytes)this.cacheSizeBytes=41943040;else{if(-1!==e.cacheSizeBytes&&e.cacheSizeBytes<1048576)throw new I(_.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}Ou("experimentalForceLongPolling",e.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",e.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!e.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:void 0===e.experimentalAutoDetectLongPolling?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!e.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=xu(null!==(n=e.experimentalLongPollingOptions)&&void 0!==n?n:{}),function(e){if(void 0!==e.timeoutSeconds){if(isNaN(e.timeoutSeconds))throw new I(_.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (must not be NaN)`);if(e.timeoutSeconds<5)throw new I(_.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (minimum allowed value is 5)`);if(e.timeoutSeconds>30)throw new I(_.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (maximum allowed value is 30)`)}}(this.experimentalLongPollingOptions),this.useFetchStreams=!!e.useFetchStreams}isEqual(e){return this.host===e.host&&this.ssl===e.ssl&&this.credentials===e.credentials&&this.cacheSizeBytes===e.cacheSizeBytes&&this.experimentalForceLongPolling===e.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===e.experimentalAutoDetectLongPolling&&function(e,t){return e.timeoutSeconds===t.timeoutSeconds}(this.experimentalLongPollingOptions,e.experimentalLongPollingOptions)&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams}}class Vu{constructor(e,t,n,r){this._authCredentials=e,this._appCheckCredentials=t,this._databaseId=n,this._app=r,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new Fu({}),this._settingsFrozen=!1}get app(){if(!this._app)throw new I(_.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(e){if(this._settingsFrozen)throw new I(_.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 Fu(e),void 0!==e.credentials&&(this._authCredentials=function(e){if(!e)return new S;switch(e.type){case"firstParty":return new k(e.sessionIndex||"0",e.iamToken||null,e.authTokenFactory||null);case"provider":return e.client;default:throw new I(_.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invalid credential type")}}(e.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(e){const t=ku.get(e);t&&(p("ComponentProvider","Removing Datastore"),ku.delete(e),t.terminate())}(this),Promise.resolve()}}function Uu(e,t,n,r={}){var i;const s=(e=Lu(e,Vu))._getSettings(),a=`${t}:${n}`;if("firestore.googleapis.com"!==s.host&&s.host!==a&&g("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used."),e._setSettings(Object.assign(Object.assign({},s),{host:a,ssl:!1})),r.mockUserToken){let t,n;if("string"==typeof r.mockUserToken)t=r.mockUserToken,n=l.MOCK_USER;else{t=o.createMockUserToken(r.mockUserToken,null===(i=e._app)||void 0===i?void 0:i.options.projectId);const s=r.mockUserToken.sub||r.mockUserToken.user_id;if(!s)throw new I(_.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");n=new l(s)}e._authCredentials=new C(new T(t,n))}}class ju{constructor(e,t,n){this.converter=t,this._query=n,this.type="query",this.firestore=e}withConverter(e){return new ju(this.firestore,e,this._query)}}class Bu{constructor(e,t,n){this.converter=t,this._key=n,this.type="document",this.firestore=e}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new qu(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new Bu(this.firestore,e,this._key)}}class qu extends ju{constructor(e,t,n){super(e,t,kn(n)),this._path=n,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){const e=this._path.popLast();return e.isEmpty()?null:new Bu(this.firestore,null,new z(e))}withConverter(e){return new qu(this.firestore,e,this._path)}}function zu(e,t,...n){if(e=o.getModularInstance(e),1===arguments.length&&(t=R.newId()),Nu("doc","path",t),e instanceof Vu){const r=j.fromString(t,...n);return Du(r),new Bu(e,null,new z(r))}{if(!(e instanceof Bu||e instanceof qu))throw new I(_.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=e._path.child(j.fromString(t,...n));return Du(r),new Bu(e.firestore,e instanceof qu?e.converter:null,new z(r))}}function Gu(e,t){return e=o.getModularInstance(e),t=o.getModularInstance(t),e instanceof ju&&t instanceof ju&&e.firestore===t.firestore&&Vn(e._query,t._query)&&e.converter===t.converter}class Ku{constructor(){this.au=Promise.resolve(),this.uu=[],this.cu=!1,this.lu=[],this.hu=null,this.Pu=!1,this.Iu=!1,this.Tu=[],this.t_=new ba(this,"async_queue_retry"),this.Eu=()=>{const e=ya();e&&p("AsyncQueue","Visibility state changed to "+e.visibilityState),this.t_.jo()};const e=ya();e&&"function"==typeof e.addEventListener&&e.addEventListener("visibilitychange",this.Eu)}get isShuttingDown(){return this.cu}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.du(),this.Au(e)}enterRestrictedMode(e){if(!this.cu){this.cu=!0,this.Iu=e||!1;const t=ya();t&&"function"==typeof t.removeEventListener&&t.removeEventListener("visibilitychange",this.Eu)}}enqueue(e){if(this.du(),this.cu)return new Promise((()=>{}));const t=new E;return this.Au((()=>this.cu&&this.Iu?Promise.resolve():(e().then(t.resolve,t.reject),t.promise))).then((()=>t.promise))}enqueueRetryable(e){this.enqueueAndForget((()=>(this.uu.push(e),this.Ru())))}async Ru(){if(0!==this.uu.length){try{await this.uu[0](),this.uu.shift(),this.t_.reset()}catch(e){if(!le(e))throw e;p("AsyncQueue","Operation failed with retryable error: "+e)}this.uu.length>0&&this.t_.Go((()=>this.Ru()))}}Au(e){const t=this.au.then((()=>(this.Pu=!0,e().catch((e=>{this.hu=e,this.Pu=!1;const t=function(e){let t=e.message||"";return e.stack&&(t=e.stack.includes(e.message)?e.stack:e.message+"\n"+e.stack),t}(e);throw m("INTERNAL UNHANDLED ERROR: ",t),e})).then((e=>(this.Pu=!1,e))))));return this.au=t,t}enqueueAfterDelay(e,t,n){this.du(),this.Tu.indexOf(e)>-1&&(t=0);const r=tc.createAndSchedule(this,e,t,n,(e=>this.Vu(e)));return this.lu.push(r),r}du(){this.hu&&v()}verifyOperationInProgress(){}async mu(){let e;do{e=this.au,await e}while(e!==this.au)}fu(e){for(const t of this.lu)if(t.timerId===e)return!0;return!1}gu(e){return this.mu().then((()=>{this.lu.sort(((e,t)=>e.targetTimeMs-t.targetTimeMs));for(const t of this.lu)if(t.skipDelay(),"all"!==e&&t.timerId===e)break;return this.mu()}))}pu(e){this.Tu.push(e)}Vu(e){const t=this.lu.indexOf(e);this.lu.splice(t,1)}}function Wu(e){return function(e){if("object"!=typeof e||null===e)return!1;const t=e;for(const e of["next","error","complete"])if(e in t&&"function"==typeof t[e])return!0;return!1}(e)}class $u{constructor(){this._progressObserver={},this._taskCompletionResolver=new E,this._lastProgress={taskState:"Running",totalBytes:0,totalDocuments:0,bytesLoaded:0,documentsLoaded:0}}onProgress(e,t,n){this._progressObserver={next:e,error:t,complete:n}}catch(e){return this._taskCompletionResolver.promise.catch(e)}then(e,t){return this._taskCompletionResolver.promise.then(e,t)}_completeWith(e){this._updateProgress(e),this._progressObserver.complete&&this._progressObserver.complete(),this._taskCompletionResolver.resolve(e)}_failWith(e){this._lastProgress.taskState="Error",this._progressObserver.next&&this._progressObserver.next(this._lastProgress),this._progressObserver.error&&this._progressObserver.error(e),this._taskCompletionResolver.reject(e)}_updateProgress(e){this._lastProgress=e,this._progressObserver.next&&this._progressObserver.next(e)}}class Hu extends Vu{constructor(e,t,n,r){super(e,t,n,r),this.type="firestore",this._queue=new Ku,this._persistenceKey=(null==r?void 0:r.name)||"[DEFAULT]"}_terminate(){return this._firestoreClient||Ju(this),this._firestoreClient.terminate()}}function Qu(e){return e._firestoreClient||Ju(e),e._firestoreClient.verifyNotTerminated(),e._firestoreClient}function Ju(e){var t,n,r;const i=e._freezeSettings(),s=function(e,t,n,r){return new vt(e,t,n,r.host,r.ssl,r.experimentalForceLongPolling,r.experimentalAutoDetectLongPolling,xu(r.experimentalLongPollingOptions),r.useFetchStreams)}(e._databaseId,(null===(t=e._app)||void 0===t?void 0:t.options.appId)||"",e._persistenceKey,i);e._firestoreClient=new pu(e._authCredentials,e._appCheckCredentials,e._queue,s),(null===(n=i.localCache)||void 0===n?void 0:n._offlineComponentProvider)&&(null===(r=i.localCache)||void 0===r?void 0:r._onlineComponentProvider)&&(e._firestoreClient._uninitializedComponentsProvider={_offlineKind:i.localCache.kind,_offline:i.localCache._offlineComponentProvider,_online:i.localCache._onlineComponentProvider})}function Yu(e,t,n){const r=new E;return e.asyncQueue.enqueue((async()=>{try{await mu(e,n),await gu(e,t),r.resolve()}catch(e){const t=e;if(!yu(t))throw t;g("Error enabling indexeddb cache. Falling back to memory cache: "+t),r.reject(t)}})).then((()=>r.promise))}function Xu(e){if(e._initialized||e._terminated)throw new I(_.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 Zu{constructor(e="count",t){this._internalFieldPath=t,this.type="AggregateField",this.aggregateType=e}}class el{constructor(e,t,n){this._userDataWriter=t,this._data=n,this.type="AggregateQuerySnapshot",this.query=e}data(){return this._userDataWriter.convertObjectMap(this._data)}}class tl{constructor(e){this._byteString=e}static fromBase64String(e){try{return new tl(lt.fromBase64String(e))}catch(e){throw new I(_.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+e)}}static fromUint8Array(e){return new tl(lt.fromUint8Array(e))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(e){return this._byteString.isEqual(e._byteString)}}class nl{constructor(...e){for(let t=0;t<e.length;++t)if(0===e[t].length)throw new I(_.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new q(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}}class rl{constructor(e){this._methodName=e}}class il{constructor(e,t){if(!isFinite(e)||e<-90||e>90)throw new I(_.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(t)||t<-180||t>180)throw new I(_.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+t);this._lat=e,this._long=t}get latitude(){return this._lat}get longitude(){return this._long}isEqual(e){return this._lat===e._lat&&this._long===e._long}toJSON(){return{latitude:this._lat,longitude:this._long}}_compareTo(e){return P(this._lat,e._lat)||P(this._long,e._long)}}class sl{constructor(e){this._values=(e||[]).map((e=>e))}toArray(){return this._values.map((e=>e))}isEqual(e){return function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0}(this._values,e._values)}}const ol=/^__.*__$/;class al{constructor(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}toMutation(e,t){return null!==this.fieldMask?new Or(e,this.data,this.fieldMask,t,this.fieldTransforms):new Nr(e,this.data,t,this.fieldTransforms)}}class cl{constructor(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}toMutation(e,t){return new Or(e,this.data,this.fieldMask,t,this.fieldTransforms)}}function ul(e){switch(e){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw v()}}class ll{constructor(e,t,n,r,i,s){this.settings=e,this.databaseId=t,this.serializer=n,this.ignoreUndefinedProperties=r,void 0===i&&this.yu(),this.fieldTransforms=i||[],this.fieldMask=s||[]}get path(){return this.settings.path}get wu(){return this.settings.wu}Su(e){return new ll(Object.assign(Object.assign({},this.settings),e),this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}bu(e){var t;const n=null===(t=this.path)||void 0===t?void 0:t.child(e),r=this.Su({path:n,Du:!1});return r.vu(e),r}Cu(e){var t;const n=null===(t=this.path)||void 0===t?void 0:t.child(e),r=this.Su({path:n,Du:!1});return r.yu(),r}Fu(e){return this.Su({path:void 0,Du:!0})}Mu(e){return Nl(e,this.settings.methodName,this.settings.xu||!1,this.path,this.settings.Ou)}contains(e){return void 0!==this.fieldMask.find((t=>e.isPrefixOf(t)))||void 0!==this.fieldTransforms.find((t=>e.isPrefixOf(t.field)))}yu(){if(this.path)for(let e=0;e<this.path.length;e++)this.vu(this.path.get(e))}vu(e){if(0===e.length)throw this.Mu("Document fields must not be empty");if(ul(this.wu)&&ol.test(e))throw this.Mu('Document fields cannot begin and end with "__"')}}class hl{constructor(e,t,n){this.databaseId=e,this.ignoreUndefinedProperties=t,this.serializer=n||va(e)}Nu(e,t,n,r=!1){return new ll({wu:e,methodName:t,Ou:n,path:q.emptyPath(),Du:!1,xu:r},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}}function dl(e){const t=e._freezeSettings(),n=va(e._databaseId);return new hl(e._databaseId,!!t.ignoreUndefinedProperties,n)}function fl(e,t,n,r,i,s={}){const o=e.Nu(s.merge||s.mergeFields?2:0,t,n,i);Cl("Data must be an object, but it was:",o,r);const a=Tl(r,o);let c,u;if(s.merge)c=new ct(o.fieldMask),u=o.fieldTransforms;else if(s.mergeFields){const e=[];for(const r of s.mergeFields){const i=Al(t,r,n);if(!o.contains(i))throw new I(_.INVALID_ARGUMENT,`Field '${i}' is specified in your field mask but missing from your input data.`);Ol(e,i)||e.push(i)}c=new ct(e),u=o.fieldTransforms.filter((e=>c.covers(e.field)))}else c=null,u=o.fieldTransforms;return new al(new Kt(a),c,u)}class pl extends rl{_toFieldTransform(e){if(2!==e.wu)throw 1===e.wu?e.Mu(`${this._methodName}() can only appear at the top level of your update data`):e.Mu(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return e.fieldMask.push(e.path),null}isEqual(e){return e instanceof pl}}function ml(e,t,n){return new ll({wu:3,Ou:t.settings.Ou,methodName:e._methodName,Du:n},t.databaseId,t.serializer,t.ignoreUndefinedProperties)}class gl extends rl{_toFieldTransform(e){return new wr(e.path,new dr)}isEqual(e){return e instanceof gl}}class yl extends rl{constructor(e,t){super(e),this.Lu=t}_toFieldTransform(e){const t=ml(this,e,!0),n=this.Lu.map((e=>El(e,t))),r=new fr(n);return new wr(e.path,r)}isEqual(e){return e instanceof yl&&o.deepEqual(this.Lu,e.Lu)}}class vl extends rl{constructor(e,t){super(e),this.Lu=t}_toFieldTransform(e){const t=ml(this,e,!0),n=this.Lu.map((e=>El(e,t))),r=new mr(n);return new wr(e.path,r)}isEqual(e){return e instanceof vl&&o.deepEqual(this.Lu,e.Lu)}}class bl extends rl{constructor(e,t){super(e),this.Bu=t}_toFieldTransform(e){const t=new yr(e.serializer,ar(e.serializer,this.Bu));return new wr(e.path,t)}isEqual(e){return e instanceof bl&&this.Bu===e.Bu}}function wl(e,t,n,r){const i=e.Nu(1,t,n);Cl("Data must be an object, but it was:",i,r);const s=[],a=Kt.empty();Ze(r,((e,r)=>{const c=kl(t,e,n);r=o.getModularInstance(r);const u=i.Cu(c);if(r instanceof pl)s.push(c);else{const e=El(r,u);null!=e&&(s.push(c),a.set(c,e))}}));const c=new ct(s);return new cl(a,c,i.fieldTransforms)}function _l(e,t,n,r,i,s){const a=e.Nu(1,t,n),c=[Al(t,r,n)],u=[i];if(s.length%2!=0)throw new I(_.INVALID_ARGUMENT,`Function ${t}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let e=0;e<s.length;e+=2)c.push(Al(t,s[e])),u.push(s[e+1]);const l=[],h=Kt.empty();for(let e=c.length-1;e>=0;--e)if(!Ol(l,c[e])){const t=c[e];let n=u[e];n=o.getModularInstance(n);const r=a.Cu(t);if(n instanceof pl)l.push(t);else{const e=El(n,r);null!=e&&(l.push(t),h.set(t,e))}}const d=new ct(l);return new cl(h,d,a.fieldTransforms)}function Il(e,t,n,r=!1){return El(n,e.Nu(r?4:3,t))}function El(e,t){if(Sl(e=o.getModularInstance(e)))return Cl("Unsupported field value:",t,e),Tl(e,t);if(e instanceof rl)return function(e,t){if(!ul(t.wu))throw t.Mu(`${e._methodName}() can only be used with update() and set()`);if(!t.path)throw t.Mu(`${e._methodName}() is not currently supported inside arrays`);const n=e._toFieldTransform(t);n&&t.fieldTransforms.push(n)}(e,t),null;if(void 0===e&&t.ignoreUndefinedProperties)return null;if(t.path&&t.fieldMask.push(t.path),e instanceof Array){if(t.settings.Du&&4!==t.wu)throw t.Mu("Nested arrays are not supported");return function(e,t){const n=[];let r=0;for(const i of e){let e=El(i,t.Fu(r));null==e&&(e={nullValue:"NULL_VALUE"}),n.push(e),r++}return{arrayValue:{values:n}}}(e,t)}return function(e,t){if(null===(e=o.getModularInstance(e)))return{nullValue:"NULL_VALUE"};if("number"==typeof e)return ar(t.serializer,e);if("boolean"==typeof e)return{booleanValue:e};if("string"==typeof e)return{stringValue:e};if(e instanceof Date){const n=F.fromDate(e);return{timestampValue:fi(t.serializer,n)}}if(e instanceof F){const n=new F(e.seconds,1e3*Math.floor(e.nanoseconds/1e3));return{timestampValue:fi(t.serializer,n)}}if(e instanceof il)return{geoPointValue:{latitude:e.latitude,longitude:e.longitude}};if(e instanceof tl)return{bytesValue:pi(t.serializer,e._byteString)};if(e instanceof Bu){const n=t.databaseId,r=e.firestore._databaseId;if(!r.isEqual(n))throw t.Mu(`Document reference is for database ${r.projectId}/${r.database} but should be for database ${n.projectId}/${n.database}`);return{referenceValue:yi(e.firestore._databaseId||t.databaseId,e._key.path)}}if(e instanceof sl)return function(e,t){return{mapValue:{fields:{__type__:{stringValue:"__vector__"},value:{arrayValue:{values:e.toArray().map((e=>{if("number"!=typeof e)throw t.Mu("VectorValues must only contain numeric values.");return sr(t.serializer,e)}))}}}}}}(e,t);throw t.Mu(`Unsupported field value: ${Pu(e)}`)}(e,t)}function Tl(e,t){const n={};return tt(e)?t.path&&t.path.length>0&&t.fieldMask.push(t.path):Ze(e,((e,r)=>{const i=El(r,t.bu(e));null!=i&&(n[e]=i)})),{mapValue:{fields:n}}}function Sl(e){return!("object"!=typeof e||null===e||e instanceof Array||e instanceof Date||e instanceof F||e instanceof il||e instanceof tl||e instanceof Bu||e instanceof rl||e instanceof sl)}function Cl(e,t,n){if(!Sl(n)||!function(e){return"object"==typeof e&&null!==e&&(Object.getPrototypeOf(e)===Object.prototype||null===Object.getPrototypeOf(e))}(n)){const r=Pu(n);throw"an object"===r?t.Mu(e+" a custom object"):t.Mu(e+" "+r)}}function Al(e,t,n){if((t=o.getModularInstance(t))instanceof nl)return t._internalPath;if("string"==typeof t)return kl(e,t);throw Nl("Field path arguments must be of type string or ",e,!1,void 0,n)}const xl=new RegExp("[~\\*/\\[\\]]");function kl(e,t,n){if(t.search(xl)>=0)throw Nl(`Invalid field path (${t}). Paths must not contain '~', '*', '/', '[', or ']'`,e,!1,void 0,n);try{return new nl(...t.split("."))._internalPath}catch(r){throw Nl(`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,e,!1,void 0,n)}}function Nl(e,t,n,r,i){const s=r&&!r.isEmpty(),o=void 0!==i;let a=`Function ${t}() 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 I(_.INVALID_ARGUMENT,a+e+c)}function Ol(e,t){return e.some((e=>e.isEqual(t)))}class Dl{constructor(e,t,n,r,i){this._firestore=e,this._userDataWriter=t,this._key=n,this._document=r,this._converter=i}get id(){return this._key.path.lastSegment()}get ref(){return new Bu(this._firestore,this._converter,this._key)}exists(){return null!==this._document}data(){if(this._document){if(this._converter){const e=new Rl(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(e)}return this._userDataWriter.convertValue(this._document.data.value)}}get(e){if(this._document){const t=this._document.data.field(Pl("DocumentSnapshot.get",e));if(null!==t)return this._userDataWriter.convertValue(t)}}}class Rl extends Dl{data(){return super.data()}}function Pl(e,t){return"string"==typeof t?kl(e,t):t instanceof nl?t._internalPath:t._delegate._internalPath}function Ll(e){if("L"===e.limitType&&0===e.explicitOrderBy.length)throw new I(_.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class Ml{}class Fl extends Ml{}class Vl extends Fl{constructor(e,t,n){super(),this._field=e,this._op=t,this._value=n,this.type="where"}static _create(e,t,n){return new Vl(e,t,n)}_apply(e){const t=this._parse(e);return $l(e._query,t),new ju(e.firestore,e.converter,Mn(e._query,t))}_parse(e){const t=dl(e.firestore),n=function(e,t,n,r,i,s,o){let a;if(i.isKeyField()){if("array-contains"===s||"array-contains-any"===s)throw new I(_.INVALID_ARGUMENT,`Invalid Query. You can't perform '${s}' queries on documentId().`);if("in"===s||"not-in"===s){Wl(o,s);const t=[];for(const n of o)t.push(Kl(r,e,n));a={arrayValue:{values:t}}}else a=Kl(r,e,o)}else"in"!==s&&"not-in"!==s&&"array-contains-any"!==s||Wl(o,s),a=Il(n,"where",o,"in"===s||"not-in"===s);return en.create(i,s,a)}(e._query,0,t,e.firestore._databaseId,this._field,this._op,this._value);return n}}class Ul extends Ml{constructor(e,t){super(),this.type=e,this._queryConstraints=t}static _create(e,t){return new Ul(e,t)}_parse(e){const t=this._queryConstraints.map((t=>t._parse(e))).filter((e=>e.getFilters().length>0));return 1===t.length?t[0]:tn.create(t,this._getOperator())}_apply(e){const t=this._parse(e);return 0===t.getFilters().length?e:(function(e,t){let n=e;const r=t.getFlattenedFilters();for(const e of r)$l(n,e),n=Mn(n,e)}(e._query,t),new ju(e.firestore,e.converter,Mn(e._query,t)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return"and"===this.type?"and":"or"}}class jl extends Fl{constructor(e,t){super(),this._field=e,this._direction=t,this.type="orderBy"}static _create(e,t){return new jl(e,t)}_apply(e){const t=function(e,t,n){if(null!==e.startAt)throw new I(_.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(null!==e.endAt)throw new I(_.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");return new Yt(t,n)}(e._query,this._field,this._direction);return new ju(e.firestore,e.converter,function(e,t){const n=e.explicitOrderBy.concat([t]);return new An(e.path,e.collectionGroup,n,e.filters.slice(),e.limit,e.limitType,e.startAt,e.endAt)}(e._query,t))}}class Bl extends Fl{constructor(e,t,n){super(),this.type=e,this._limit=t,this._limitType=n}static _create(e,t,n){return new Bl(e,t,n)}_apply(e){return new ju(e.firestore,e.converter,Fn(e._query,this._limit,this._limitType))}}class ql extends Fl{constructor(e,t,n){super(),this.type=e,this._docOrFields=t,this._inclusive=n}static _create(e,t,n){return new ql(e,t,n)}_apply(e){const t=Gl(e,this.type,this._docOrFields,this._inclusive);return new ju(e.firestore,e.converter,function(e,t){return new An(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),e.limit,e.limitType,t,e.endAt)}(e._query,t))}}class zl extends Fl{constructor(e,t,n){super(),this.type=e,this._docOrFields=t,this._inclusive=n}static _create(e,t,n){return new zl(e,t,n)}_apply(e){const t=Gl(e,this.type,this._docOrFields,this._inclusive);return new ju(e.firestore,e.converter,function(e,t){return new An(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),e.limit,e.limitType,e.startAt,t)}(e._query,t))}}function Gl(e,t,n,r){if(n[0]=o.getModularInstance(n[0]),n[0]instanceof Dl)return function(e,t,n,r,i){if(!r)throw new I(_.NOT_FOUND,`Can't use a DocumentSnapshot that doesn't exist for ${n}().`);const s=[];for(const n of Dn(e))if(n.field.isKeyField())s.push(Ot(t,r.key));else{const e=r.data.field(n.field);if(mt(e))throw new I(_.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===e){const e=n.field.canonicalString();throw new I(_.INVALID_ARGUMENT,`Invalid query. You are trying to start or end a query using a document for which the field '${e}' (used as the orderBy) does not exist.`)}s.push(e)}return new Ht(s,i)}(e._query,e.firestore._databaseId,t,n[0]._document,r);{const i=dl(e.firestore);return function(e,t,n,r,i,s){const o=e.explicitOrderBy;if(i.length>o.length)throw new I(_.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 I(_.INVALID_ARGUMENT,`Invalid query. Expected a string for document ID in ${r}(), but got a ${typeof c}`);if(!On(e)&&-1!==c.indexOf("/"))throw new I(_.INVALID_ARGUMENT,`Invalid query. When querying a collection and ordering by documentId(), the value passed to ${r}() must be a plain document ID, but '${c}' contains a slash.`);const n=e.path.child(j.fromString(c));if(!z.isDocumentKey(n))throw new I(_.INVALID_ARGUMENT,`Invalid query. When querying a collection group and ordering by 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 z(n);a.push(Ot(t,i))}else{const e=Il(n,r,c);a.push(e)}}return new Ht(a,s)}(e._query,e.firestore._databaseId,i,t,n,r)}}function Kl(e,t,n){if("string"==typeof(n=o.getModularInstance(n))){if(""===n)throw new I(_.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!On(t)&&-1!==n.indexOf("/"))throw new I(_.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${n}' contains a '/' character.`);const r=t.path.child(j.fromString(n));if(!z.isDocumentKey(r))throw new I(_.INVALID_ARGUMENT,`Invalid query. When querying a collection group by 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 Ot(e,new z(r))}if(n instanceof Bu)return Ot(e,n._key);throw new I(_.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${Pu(n)}.`)}function Wl(e,t){if(!Array.isArray(e)||0===e.length)throw new I(_.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${t.toString()}' filters.`)}function $l(e,t){const n=function(e,t){for(const n of e)for(const e of n.getFlattenedFilters())if(t.indexOf(e.op)>=0)return e.op;return null}(e.filters,function(e){switch(e){case"!=":return["!=","not-in"];case"array-contains-any":case"in":return["not-in"];case"not-in":return["array-contains-any","in","not-in","!="];default:return[]}}(t.op));if(null!==n)throw n===t.op?new I(_.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${t.op.toString()}' filter.`):new I(_.INVALID_ARGUMENT,`Invalid query. You cannot use '${t.op.toString()}' filters with '${n.toString()}' filters.`)}function Hl(e,t){if(!(t instanceof Vl||t instanceof Ul))throw new I(_.INVALID_ARGUMENT,`Function ${e}() requires AppliableConstraints created with a call to 'where(...)', 'or(...)', or 'and(...)'.`)}class Ql{convertValue(e,t="none"){switch(It(e)){case 0:return null;case 1:return e.booleanValue;case 2:return ft(e.integerValue||e.doubleValue);case 3:return this.convertTimestamp(e.timestampValue);case 4:return this.convertServerTimestamp(e,t);case 5:return e.stringValue;case 6:return this.convertBytes(pt(e.bytesValue));case 7:return this.convertReference(e.referenceValue);case 8:return this.convertGeoPoint(e.geoPointValue);case 9:return this.convertArray(e.arrayValue,t);case 11:return this.convertObject(e.mapValue,t);case 10:return this.convertVectorValue(e.mapValue);default:throw v()}}convertObject(e,t){return this.convertObjectMap(e.fields,t)}convertObjectMap(e,t="none"){const n={};return Ze(e,((e,r)=>{n[e]=this.convertValue(r,t)})),n}convertVectorValue(e){var t,n,r;const i=null===(r=null===(n=null===(t=e.fields)||void 0===t?void 0:t.value.arrayValue)||void 0===n?void 0:n.values)||void 0===r?void 0:r.map((e=>ft(e.doubleValue)));return new sl(i)}convertGeoPoint(e){return new il(ft(e.latitude),ft(e.longitude))}convertArray(e,t){return(e.values||[]).map((e=>this.convertValue(e,t)))}convertServerTimestamp(e,t){switch(t){case"previous":const n=gt(e);return null==n?null:this.convertValue(n,t);case"estimate":return this.convertTimestamp(yt(e));default:return null}}convertTimestamp(e){const t=dt(e);return new F(t.seconds,t.nanos)}convertDocumentKey(e,t){const n=j.fromString(e);b(qi(n));const r=new bt(n.get(1),n.get(3)),i=new z(n.popFirst(5));return r.isEqual(t)||m(`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 (${t.projectId}/${t.database}) instead.`),i}}function Jl(e,t,n){let r;return r=e?n&&(n.merge||n.mergeFields)?e.toFirestore(t,n):e.toFirestore(t):t,r}class Yl extends Ql{constructor(e){super(),this.firestore=e}convertBytes(e){return new tl(e)}convertReference(e){const t=this.convertDocumentKey(e,this.firestore._databaseId);return new Bu(this.firestore,null,t)}}function Xl(){return new Zu("count")}class Zl{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}}class eh extends Dl{constructor(e,t,n,r,i,s){super(e,t,n,r,s),this._firestore=e,this._firestoreImpl=e,this.metadata=i}exists(){return super.exists()}data(e={}){if(this._document){if(this._converter){const t=new th(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(t,e)}return this._userDataWriter.convertValue(this._document.data.value,e.serverTimestamps)}}get(e,t={}){if(this._document){const n=this._document.data.field(Pl("DocumentSnapshot.get",e));if(null!==n)return this._userDataWriter.convertValue(n,t.serverTimestamps)}}}class th extends eh{data(e={}){return super.data(e)}}class nh{constructor(e,t,n,r){this._firestore=e,this._userDataWriter=t,this._snapshot=r,this.metadata=new Zl(r.hasPendingWrites,r.fromCache),this.query=n}get docs(){const e=[];return this.forEach((t=>e.push(t))),e}get size(){return this._snapshot.docs.size}get empty(){return 0===this.size}forEach(e,t){this._snapshot.docs.forEach((n=>{e.call(t,new th(this._firestore,this._userDataWriter,n.key,n,new Zl(this._snapshot.mutatedKeys.has(n.key),this._snapshot.fromCache),this.query.converter))}))}docChanges(e={}){const t=!!e.includeMetadataChanges;if(t&&this._snapshot.excludesMetadataChanges)throw new I(_.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===t||(this._cachedChanges=function(e,t){if(e._snapshot.oldDocs.isEmpty()){let t=0;return e._snapshot.docChanges.map((n=>{const r=new th(e._firestore,e._userDataWriter,n.doc.key,n.doc,new Zl(e._snapshot.mutatedKeys.has(n.doc.key),e._snapshot.fromCache),e.query.converter);return n.doc,{type:"added",doc:r,oldIndex:-1,newIndex:t++}}))}{let n=e._snapshot.oldDocs;return e._snapshot.docChanges.filter((e=>t||3!==e.type)).map((t=>{const r=new th(e._firestore,e._userDataWriter,t.doc.key,t.doc,new Zl(e._snapshot.mutatedKeys.has(t.doc.key),e._snapshot.fromCache),e.query.converter);let i=-1,s=-1;return 0!==t.type&&(i=n.indexOf(t.doc.key),n=n.delete(t.doc.key)),1!==t.type&&(n=n.add(t.doc),s=n.indexOf(t.doc.key)),{type:rh(t.type),doc:r,oldIndex:i,newIndex:s}}))}}(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}}function rh(e){switch(e){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return v()}}class ih extends Ql{constructor(e){super(),this.firestore=e}convertBytes(e){return new tl(e)}convertReference(e){const t=this.convertDocumentKey(e,this.firestore._databaseId);return new Bu(this.firestore,null,t)}}function sh(e,t){return function(e,t){const n=new E;return e.asyncQueue.enqueueAndForget((async()=>async function(e,t,n){const r=ru(e);try{const e=await function(e,t){const n=w(e),r=F.now(),i=t.reduce(((e,t)=>e.add(t.key)),nr());let s,o;return n.persistence.runTransaction("Locally write mutations","readwrite",(e=>{let a=$n(),c=nr();return n.cs.getEntries(e,i).next((e=>{a=e,a.forEach(((e,t)=>{t.isValidDocument()||(c=c.add(e))}))})).next((()=>n.localDocuments.getOverlayedDocuments(e,a))).next((i=>{s=i;const o=[];for(const e of t){const t=xr(e,s.get(e.key).overlayedDocument);null!=t&&o.push(new Or(e.key,t,Wt(t.value.mapValue),Ir.exists(!0)))}return n.mutationQueue.addMutationBatch(e,r,o,t)})).next((t=>{o=t;const r=t.applyToLocalDocumentSet(s,c);return n.documentOverlayCache.saveOverlays(e,t.batchId,r)}))})).then((()=>({batchId:o.batchId,changes:Jn(s)})))}(r.localStore,t);r.sharedClientState.addPendingMutation(e.batchId),function(e,t,n){let r=e.Ba[e.currentUser.toKey()];r||(r=new nt(P)),r=r.insert(t,n),e.Ba[e.currentUser.toKey()]=r}(r,e.batchId,n),await Kc(r,e.changes),await qa(r.remoteStore)}catch(e){const t=nc(e,"Failed to persist write");n.reject(t)}}(await Eu(e),t,n))),n.promise}(Qu(e),t)}function oh(e,t,n){const r=n.docs.get(t._key),i=new ih(e);return new eh(e,i,t._key,r,new Zl(n.hasPendingWrites,n.fromCache),t.converter)}function ah(e,t){const n=Lu(e.firestore,Hu),r=Qu(n),i=et(t,((e,t)=>new jr(t,e.aggregateType,e._internalFieldPath)));return function(e,t,n){const r=new E;return e.asyncQueue.enqueueAndForget((async()=>{try{const i=await Tu(e);r.resolve(async function(e,t,n){var r;const i=w(e),{request:s,ut:o,parent:a}=Di(i.serializer,Pn(t),n);i.connection.Fo||delete s.parent;const c=(await i.Lo("RunAggregationQuery",i.serializer.databaseId,a,s,1)).filter((e=>!!e.result));b(1===c.length);const u=null===(r=c[0].result)||void 0===r?void 0:r.aggregateFields;return Object.keys(u).reduce(((e,t)=>(e[o[t]]=u[t],e)),{})}(i,t,n))}catch(e){r.reject(e)}})),r.promise}(r,e._query,i).then((t=>function(e,t,n){const r=new ih(e);return new el(t,r,n)}(n,e,t)))}class ch{constructor(e){this.kind="memory",this._onlineComponentProvider=new cu,(null==e?void 0:e.garbageCollector)?this._offlineComponentProvider=e.garbageCollector._offlineComponentProvider:this._offlineComponentProvider=new iu}toJSON(){return{kind:this.kind}}}class uh{constructor(e){let t;this.kind="persistent",(null==e?void 0:e.tabManager)?(e.tabManager._initialize(e),t=e.tabManager):(t=ph(void 0),t._initialize(e)),this._onlineComponentProvider=t._onlineComponentProvider,this._offlineComponentProvider=t._offlineComponentProvider}toJSON(){return{kind:this.kind}}}class lh{constructor(){this.kind="memoryEager",this._offlineComponentProvider=new iu}toJSON(){return{kind:this.kind}}}class hh{constructor(e){this.kind="memoryLru",this._offlineComponentProvider=new su(e)}toJSON(){return{kind:this.kind}}}class dh{constructor(e){this.forceOwnership=e,this.kind="persistentSingleTab"}toJSON(){return{kind:this.kind}}_initialize(e){this._onlineComponentProvider=new cu,this._offlineComponentProvider=new ou(this._onlineComponentProvider,null==e?void 0:e.cacheSizeBytes,this.forceOwnership)}}class fh{constructor(){this.kind="PersistentMultipleTab"}toJSON(){return{kind:this.kind}}_initialize(e){this._onlineComponentProvider=new cu,this._offlineComponentProvider=new au(this._onlineComponentProvider,null==e?void 0:e.cacheSizeBytes)}}function ph(e){return new dh(null==e?void 0:e.forceOwnership)}const mh={maxAttempts:5};class gh{constructor(e,t){this._firestore=e,this._commitHandler=t,this._mutations=[],this._committed=!1,this._dataReader=dl(e)}set(e,t,n){this._verifyNotCommitted();const r=yh(e,this._firestore),i=Jl(r.converter,t,n),s=fl(this._dataReader,"WriteBatch.set",r._key,i,null!==r.converter,n);return this._mutations.push(s.toMutation(r._key,Ir.none())),this}update(e,t,n,...r){this._verifyNotCommitted();const i=yh(e,this._firestore);let s;return s="string"==typeof(t=o.getModularInstance(t))||t instanceof nl?_l(this._dataReader,"WriteBatch.update",i._key,t,n,r):wl(this._dataReader,"WriteBatch.update",i._key,t),this._mutations.push(s.toMutation(i._key,Ir.exists(!0))),this}delete(e){this._verifyNotCommitted();const t=yh(e,this._firestore);return this._mutations=this._mutations.concat(new Lr(t._key,Ir.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 I(_.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")}}function yh(e,t){if((e=o.getModularInstance(e)).firestore!==t)throw new I(_.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return e}class vh extends class{constructor(e,t){this._firestore=e,this._transaction=t,this._dataReader=dl(e)}get(e){const t=yh(e,this._firestore),n=new Yl(this._firestore);return this._transaction.lookup([t._key]).then((e=>{if(!e||1!==e.length)return v();const r=e[0];if(r.isFoundDocument())return new Dl(this._firestore,n,r.key,r,t.converter);if(r.isNoDocument())return new Dl(this._firestore,n,t._key,null,t.converter);throw v()}))}set(e,t,n){const r=yh(e,this._firestore),i=Jl(r.converter,t,n),s=fl(this._dataReader,"Transaction.set",r._key,i,null!==r.converter,n);return this._transaction.set(r._key,s),this}update(e,t,n,...r){const i=yh(e,this._firestore);let s;return s="string"==typeof(t=o.getModularInstance(t))||t instanceof nl?_l(this._dataReader,"Transaction.update",i._key,t,n,r):wl(this._dataReader,"Transaction.update",i._key,t),this._transaction.update(i._key,s),this}delete(e){const t=yh(e,this._firestore);return this._transaction.delete(t._key),this}}{constructor(e,t){super(e,t),this._firestore=e}get(e){const t=yh(e,this._firestore),n=new ih(this._firestore);return super.get(e).then((e=>new eh(this._firestore,n,t._key,e._document,new Zl(!1,!1),t.converter)))}}function bh(e,t){if("string"!=typeof e[t])throw new I(_.INVALID_ARGUMENT,"Missing string value for: "+t);return e[t]}class wh{constructor(e){this._client=e,this.type="PersistentCacheIndexManager"}}function _h(e,t){e._client.verifyNotTerminated(),function(e,t){return e.asyncQueue.enqueue((async()=>function(e,t){w(e).ss.zi=t}(await _u(e),t)))}(e._client,t).then((e=>p(`setting persistent cache index auto creation isEnabled=${t} succeeded`))).catch((e=>g(`setting persistent cache index auto creation isEnabled=${t} failed`,e)))}const Ih=new WeakMap;class Eh{constructor(){this.ku=new Map}static get instance(){return Th||(Th=new Eh,function(e){if(Wr)throw new Error("a TestingHooksSpi instance is already set");Wr=e}(Th)),Th}et(e){this.ku.forEach((t=>t(e)))}onExistenceFilterMismatch(e){const t=Symbol(),n=this.ku;return n.set(t,e),()=>n.delete(t)}}let Th=null;!function(e,t=!0){!function(e){h=e}(r.SDK_VERSION),r._registerComponent(new i.Component("firestore",((e,{instanceIdentifier:n,options:r})=>{const i=e.getProvider("app").getImmediate(),s=new Hu(new A(e.getProvider("auth-internal")),new O(e.getProvider("app-check-internal")),function(e,t){if(!Object.prototype.hasOwnProperty.apply(e.options,["projectId"]))throw new I(_.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new bt(e.options.projectId,t)}(i,n),i);return r=Object.assign({useFetchStreams:t},r),s._setSettings(r),s}),"PUBLIC").setMultipleInstances(!0)),r.registerVersion(u,"4.7.1",e),r.registerVersion(u,"4.7.1","cjs2017")}(),t.AbstractUserDataWriter=Ql,t.AggregateField=Zu,t.AggregateQuerySnapshot=el,t.Bytes=tl,t.CACHE_SIZE_UNLIMITED=-1,t.CollectionReference=qu,t.DocumentReference=Bu,t.DocumentSnapshot=eh,t.FieldPath=nl,t.FieldValue=rl,t.Firestore=Hu,t.FirestoreError=I,t.GeoPoint=il,t.LoadBundleTask=$u,t.PersistentCacheIndexManager=wh,t.Query=ju,t.QueryCompositeFilterConstraint=Ul,t.QueryConstraint=Fl,t.QueryDocumentSnapshot=th,t.QueryEndAtConstraint=zl,t.QueryFieldFilterConstraint=Vl,t.QueryLimitConstraint=Bl,t.QueryOrderByConstraint=jl,t.QuerySnapshot=nh,t.QueryStartAtConstraint=ql,t.SnapshotMetadata=Zl,t.Timestamp=F,t.Transaction=vh,t.VectorValue=sl,t.WriteBatch=gh,t._AutoId=R,t._ByteString=lt,t._DatabaseId=bt,t._DocumentKey=z,t._EmptyAppCheckTokenProvider=class{getToken(){return Promise.resolve(new N(""))}invalidateToken(){}start(e,t){}shutdown(){}},t._EmptyAuthCredentialsProvider=S,t._FieldPath=q,t._TestingHooks=class{constructor(){throw new Error("instances of this class should not be created")}static onExistenceFilterMismatch(e){return Eh.instance.onExistenceFilterMismatch(e)}},t._cast=Lu,t._debugAssert=function(e,t){e||v()},t._internalAggregationQueryToProtoRunAggregationQueryRequest=function(e,t){var n;const r=et(t,((e,t)=>new jr(t,e.aggregateType,e._internalFieldPath))),i=null===(n=Qu(Lu(e.firestore,Hu))._onlineComponents)||void 0===n?void 0:n.datastore.serializer;return void 0===i?null:Di(i,Pn(e._query),r,!0).request},t._internalQueryToProtoQueryTarget=function(e){var t;const n=null===(t=Qu(Lu(e.firestore,Hu))._onlineComponents)||void 0===t?void 0:t.datastore.serializer;return void 0===n?null:Oi(n,Rn(e._query))._t},t._isBase64Available=function(){return"undefined"!=typeof atob},t._logWarn=g,t._validateIsNotUsedTogether=Ou,t.addDoc=function(e,t){const n=Lu(e.firestore,Hu),r=zu(e),i=Jl(e.converter,t);return sh(n,[fl(dl(e.firestore),"addDoc",r._key,i,null!==e.converter,{}).toMutation(r._key,Ir.exists(!1))]).then((()=>r))},t.aggregateFieldEqual=function(e,t){var n,r;return e instanceof Zu&&t instanceof Zu&&e.aggregateType===t.aggregateType&&(null===(n=e._internalFieldPath)||void 0===n?void 0:n.canonicalString())===(null===(r=t._internalFieldPath)||void 0===r?void 0:r.canonicalString())},t.aggregateQuerySnapshotEqual=function(e,t){return Gu(e.query,t.query)&&o.deepEqual(e.data(),t.data())},t.and=function(...e){return e.forEach((e=>Hl("and",e))),Ul._create("and",e)},t.arrayRemove=function(...e){return new vl("arrayRemove",e)},t.arrayUnion=function(...e){return new yl("arrayUnion",e)},t.average=function(e){return new Zu("avg",Al("average",e))},t.clearIndexedDbPersistence=function(e){if(e._initialized&&!e._terminated)throw new I(_.FAILED_PRECONDITION,"Persistence can only be cleared before a Firestore instance is initialized or after it is terminated.");const t=new E;return e._queue.enqueueAndForgetEvenWhileRestricted((async()=>{try{await async function(e){if(!oe.D())return Promise.resolve();const t=e+"main";await oe.delete(t)}(Lo(e._databaseId,e._persistenceKey)),t.resolve()}catch(e){t.reject(e)}})),t.promise},t.collection=function(e,t,...n){if(e=o.getModularInstance(e),Nu("collection","path",t),e instanceof Vu){const r=j.fromString(t,...n);return Ru(r),new qu(e,null,r)}{if(!(e instanceof Bu||e instanceof qu))throw new I(_.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=e._path.child(j.fromString(t,...n));return Ru(r),new qu(e.firestore,null,r)}},t.collectionGroup=function(e,t){if(e=Lu(e,Vu),Nu("collectionGroup","collection id",t),t.indexOf("/")>=0)throw new I(_.INVALID_ARGUMENT,`Invalid collection ID '${t}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);return new ju(e,null,function(e){return new An(j.emptyPath(),e)}(t))},t.connectFirestoreEmulator=Uu,t.count=Xl,t.deleteAllPersistentCacheIndexes=function(e){e._client.verifyNotTerminated(),function(e){return e.asyncQueue.enqueue((async()=>function(e){const t=w(e),n=t.indexManager;return t.persistence.runTransaction("Delete All Indexes","readwrite",(e=>n.deleteAllFieldIndexes(e)))}(await _u(e))))}(e._client).then((e=>p("deleting all persistent cache indexes succeeded"))).catch((e=>g("deleting all persistent cache indexes failed",e)))},t.deleteDoc=function(e){return sh(Lu(e.firestore,Hu),[new Lr(e._key,Ir.none())])},t.deleteField=function(){return new pl("deleteField")},t.disableNetwork=function(e){return function(e){return e.asyncQueue.enqueue((async()=>{const t=await wu(e),n=await Iu(e);return t.setNetworkEnabled(!1),async function(e){const t=w(e);t.L_.add(0),await Aa(t),t.q_.set("Offline")}(n)}))}(Qu(e=Lu(e,Hu)))},t.disablePersistentCacheIndexAutoCreation=function(e){_h(e,!1)},t.doc=zu,t.documentId=function(){return new nl("__name__")},t.enableIndexedDbPersistence=function(e,t){Xu(e=Lu(e,Hu));const n=Qu(e);if(n._uninitializedComponentsProvider)throw new I(_.FAILED_PRECONDITION,"SDK cache is already specified.");g("enableIndexedDbPersistence() will be deprecated in the future, you can use `FirestoreSettings.cache` instead.");const r=e._freezeSettings(),i=new cu;return Yu(n,i,new ou(i,r.cacheSizeBytes,null==t?void 0:t.forceOwnership))},t.enableMultiTabIndexedDbPersistence=function(e){Xu(e=Lu(e,Hu));const t=Qu(e);if(t._uninitializedComponentsProvider)throw new I(_.FAILED_PRECONDITION,"SDK cache is already specified.");g("enableMultiTabIndexedDbPersistence() will be deprecated in the future, you can use `FirestoreSettings.cache` instead.");const n=e._freezeSettings(),r=new cu;return Yu(t,r,new au(r,n.cacheSizeBytes))},t.enableNetwork=function(e){return function(e){return e.asyncQueue.enqueue((async()=>{const t=await wu(e),n=await Iu(e);return t.setNetworkEnabled(!0),function(e){const t=w(e);return t.L_.delete(0),Ca(t)}(n)}))}(Qu(e=Lu(e,Hu)))},t.enablePersistentCacheIndexAutoCreation=function(e){_h(e,!0)},t.endAt=function(...e){return zl._create("endAt",e,!0)},t.endBefore=function(...e){return zl._create("endBefore",e,!1)},t.ensureFirestoreConfigured=Qu,t.executeWrite=sh,t.getAggregateFromServer=ah,t.getCountFromServer=function(e){return ah(e,{count:Xl()})},t.getDoc=function(e){e=Lu(e,Bu);const t=Lu(e.firestore,Hu);return Cu(Qu(t),e._key).then((n=>oh(t,e,n)))},t.getDocFromCache=function(e){e=Lu(e,Bu);const t=Lu(e.firestore,Hu),n=Qu(t),r=new ih(t);return function(e,t){const n=new E;return e.asyncQueue.enqueueAndForget((async()=>async function(e,t,n){try{const r=await function(e,t){const n=w(e);return n.persistence.runTransaction("read document","readonly",(e=>n.localDocuments.getDocument(e,t)))}(e,t);r.isFoundDocument()?n.resolve(r):r.isNoDocument()?n.resolve(null):n.reject(new I(_.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(e){const r=nc(e,`Failed to get document '${t} from cache`);n.reject(r)}}(await _u(e),t,n))),n.promise}(n,e._key).then((n=>new eh(t,r,e._key,n,new Zl(null!==n&&n.hasLocalMutations,!0),e.converter)))},t.getDocFromServer=function(e){e=Lu(e,Bu);const t=Lu(e.firestore,Hu);return Cu(Qu(t),e._key,{source:"server"}).then((n=>oh(t,e,n)))},t.getDocs=function(e){e=Lu(e,ju);const t=Lu(e.firestore,Hu),n=Qu(t),r=new ih(t);return Ll(e._query),Au(n,e._query).then((n=>new nh(t,r,e,n)))},t.getDocsFromCache=function(e){e=Lu(e,ju);const t=Lu(e.firestore,Hu),n=Qu(t),r=new ih(t);return function(e,t){const n=new E;return e.asyncQueue.enqueueAndForget((async()=>async function(e,t,n){try{const r=await $o(e,t,!0),i=new Ec(t,r.Ts),s=i.ma(r.documents),o=i.applyChanges(s,!1);n.resolve(o.snapshot)}catch(e){const r=nc(e,`Failed to execute query '${t} against cache`);n.reject(r)}}(await _u(e),t,n))),n.promise}(n,e._query).then((n=>new nh(t,r,e,n)))},t.getDocsFromServer=function(e){e=Lu(e,ju);const t=Lu(e.firestore,Hu),n=Qu(t),r=new ih(t);return Au(n,e._query,{source:"server"}).then((n=>new nh(t,r,e,n)))},t.getFirestore=function(e,t){const n="object"==typeof e?e:r.getApp(),i="string"==typeof e?e:t||"(default)",s=r._getProvider(n,"firestore").getImmediate({identifier:i});if(!s._initialized){const e=o.getDefaultEmulatorHostnameAndPort("firestore");e&&Uu(s,...e)}return s},t.getPersistentCacheIndexManager=function(e){var t;e=Lu(e,Hu);const n=Ih.get(e);if(n)return n;const r=Qu(e);if("persistent"!==(null===(t=r._uninitializedComponentsProvider)||void 0===t?void 0:t._offlineKind))return null;const i=new wh(r);return Ih.set(e,i),i},t.increment=function(e){return new bl("increment",e)},t.initializeFirestore=function(e,t,n){n||(n="(default)");const i=r._getProvider(e,"firestore");if(i.isInitialized(n)){const e=i.getImmediate({identifier:n}),r=i.getOptions(n);if(o.deepEqual(r,t))return e;throw new I(_.FAILED_PRECONDITION,"initializeFirestore() has already been called with different options. To avoid this error, call initializeFirestore() with the same options as when it was originally called, or call getFirestore() to return the already initialized instance.")}if(void 0!==t.cacheSizeBytes&&void 0!==t.localCache)throw new I(_.INVALID_ARGUMENT,"cache and cacheSizeBytes cannot be specified at the same time as cacheSizeBytes willbe deprecated. Instead, specify the cache size in the cache object");if(void 0!==t.cacheSizeBytes&&-1!==t.cacheSizeBytes&&t.cacheSizeBytes<1048576)throw new I(_.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");return i.initialize({options:t,instanceIdentifier:n})},t.limit=function(e){return Mu("limit",e),Bl._create("limit",e,"F")},t.limitToLast=function(e){return Mu("limitToLast",e),Bl._create("limitToLast",e,"L")},t.loadBundle=function(e,t){const n=Qu(e=Lu(e,Hu)),r=new $u;return function(e,t,n,r){const i=function(e,t){let n;return n="string"==typeof e?$r().encode(e):e,function(e,t){return new hu(e,t)}(function(e,t){if(e instanceof Uint8Array)return uu(e,t);if(e instanceof ArrayBuffer)return uu(new Uint8Array(e),t);if(e instanceof ReadableStream)return e.getReader();throw new Error("Source of `toByteStreamReader` has to be a ArrayBuffer or ReadableStream")}(n),t)}(n,va(t));e.asyncQueue.enqueueAndForget((async()=>{!function(e,t,n){const r=w(e);(async function(e,t,n){try{const r=await t.getMetadata();if(await function(e,t){const n=w(e),r=gi(t.createTime);return n.persistence.runTransaction("hasNewerBundle","readonly",(e=>n.Gr.getBundleMetadata(e,t.id))).then((e=>!!e&&e.createTime.compareTo(r)>=0))}(e.localStore,r))return await t.close(),n._completeWith(function(e){return{taskState:"Success",documentsLoaded:e.totalDocuments,bytesLoaded:e.totalBytes,totalDocuments:e.totalDocuments,totalBytes:e.totalBytes}}(r)),Promise.resolve(new Set);n._updateProgress(wc(r));const i=new bc(r,e.localStore,t.serializer);let s=await t.Ua();for(;s;){const e=await i.la(s);e&&n._updateProgress(e),s=await t.Ua()}const o=await i.complete();return await Kc(e,o.Ia,void 0),await function(e,t){const n=w(e);return n.persistence.runTransaction("Save bundle","readwrite",(e=>n.Gr.saveBundleMetadata(e,t)))}(e.localStore,r),n._completeWith(o.progress),Promise.resolve(o.Pa)}catch(e){return g("SyncEngine",`Loading bundle failed with ${e}`),n._failWith(e),Promise.resolve(new Set)}})(r,t,n).then((e=>{r.sharedClientState.notifyBundleLoaded(e)}))}(await Eu(e),i,r)}))}(n,e._databaseId,t,r),r},t.memoryEagerGarbageCollector=function(){return new lh},t.memoryLocalCache=function(e){return new ch(e)},t.memoryLruGarbageCollector=function(e){return new hh(null==e?void 0:e.cacheSizeBytes)},t.namedQuery=function(e,t){return function(e,t){return e.asyncQueue.enqueue((async()=>function(e,t){const n=w(e);return n.persistence.runTransaction("Get named query","readonly",(e=>n.Gr.getNamedQuery(e,t)))}(await _u(e),t)))}(Qu(e=Lu(e,Hu)),t).then((t=>t?new ju(e,null,t.query):null))},t.onSnapshot=function(e,...t){var n,r,i;e=o.getModularInstance(e);let s={includeMetadataChanges:!1,source:"default"},a=0;"object"!=typeof t[a]||Wu(t[a])||(s=t[a],a++);const c={includeMetadataChanges:s.includeMetadataChanges,source:s.source};if(Wu(t[a])){const e=t[a];t[a]=null===(n=e.next)||void 0===n?void 0:n.bind(e),t[a+1]=null===(r=e.error)||void 0===r?void 0:r.bind(e),t[a+2]=null===(i=e.complete)||void 0===i?void 0:i.bind(e)}let u,l,h;if(e instanceof Bu)l=Lu(e.firestore,Hu),h=kn(e._key.path),u={next:n=>{t[a]&&t[a](oh(l,e,n))},error:t[a+1],complete:t[a+2]};else{const n=Lu(e,ju);l=Lu(n.firestore,Hu),h=n._query;const r=new ih(l);u={next:e=>{t[a]&&t[a](new nh(l,r,n,e))},error:t[a+1],complete:t[a+2]},Ll(e._query)}return function(e,t,n,r){const i=new lu(r),s=new gc(t,i,n);return e.asyncQueue.enqueueAndForget((async()=>uc(await Su(e),s))),()=>{i.za(),e.asyncQueue.enqueueAndForget((async()=>lc(await Su(e),s)))}}(Qu(l),h,c,u)},t.onSnapshotsInSync=function(e,t){return function(e,t){const n=new lu(t);return e.asyncQueue.enqueueAndForget((async()=>function(e,t){w(e).Y_.add(t),t.next()}(await Su(e),n))),()=>{n.za(),e.asyncQueue.enqueueAndForget((async()=>function(e,t){w(e).Y_.delete(t)}(await Su(e),n)))}}(Qu(e=Lu(e,Hu)),Wu(t)?t:{next:t})},t.or=function(...e){return e.forEach((e=>Hl("or",e))),Ul._create("or",e)},t.orderBy=function(e,t="asc"){const n=t,r=Pl("orderBy",e);return jl._create(r,n)},t.persistentLocalCache=function(e){return new uh(e)},t.persistentMultipleTabManager=function(){return new fh},t.persistentSingleTabManager=ph,t.query=function(e,t,...n){let r=[];t instanceof Ml&&r.push(t),r=r.concat(n),function(e){const t=e.filter((e=>e instanceof Ul)).length,n=e.filter((e=>e instanceof Vl)).length;if(t>1||t>0&&n>0)throw new I(_.INVALID_ARGUMENT,"InvalidQuery. When using composite filters, you cannot use more than one filter at the top level. Consider nesting the multiple filters within an `and(...)` statement. For example: change `query(query, where(...), or(...))` to `query(query, and(where(...), or(...)))`.")}(r);for(const t of r)e=t._apply(e);return e},t.queryEqual=Gu,t.refEqual=function(e,t){return e=o.getModularInstance(e),t=o.getModularInstance(t),(e instanceof Bu||e instanceof qu)&&(t instanceof Bu||t instanceof qu)&&e.firestore===t.firestore&&e.path===t.path&&e.converter===t.converter},t.runTransaction=function(e,t,n){e=Lu(e,Hu);const r=Object.assign(Object.assign({},mh),n);return function(e){if(e.maxAttempts<1)throw new I(_.INVALID_ARGUMENT,"Max attempts must be at least 1")}(r),function(e,t,n){const r=new E;return e.asyncQueue.enqueueAndForget((async()=>{const i=await Tu(e);new fu(e.asyncQueue,i,n,t,r).ru()})),r.promise}(Qu(e),(n=>t(new vh(e,n))),r)},t.serverTimestamp=function(){return new gl("serverTimestamp")},t.setDoc=function(e,t,n){e=Lu(e,Bu);const r=Lu(e.firestore,Hu),i=Jl(e.converter,t,n);return sh(r,[fl(dl(r),"setDoc",e._key,i,null!==e.converter,n).toMutation(e._key,Ir.none())])},t.setIndexConfiguration=function(e,t){var n;const r=Qu(e=Lu(e,Hu));if(!r._uninitializedComponentsProvider||"memory"===(null===(n=r._uninitializedComponentsProvider)||void 0===n?void 0:n._offlineKind))return g("Cannot enable indexes when persistence is disabled"),Promise.resolve();const i=function(e){const t="string"==typeof e?function(e){try{return JSON.parse(e)}catch(e){throw new I(_.INVALID_ARGUMENT,"Failed to parse JSON: "+(null==e?void 0:e.message))}}(e):e,n=[];if(Array.isArray(t.indexes))for(const e of t.indexes){const t=bh(e,"collectionGroup"),r=[];if(Array.isArray(e.fields))for(const t of e.fields){const e=kl("setIndexConfiguration",bh(t,"fieldPath"));"CONTAINS"===t.arrayConfig?r.push(new H(e,2)):"ASCENDING"===t.order?r.push(new H(e,0)):"DESCENDING"===t.order&&r.push(new H(e,1))}n.push(new G(G.UNKNOWN_ID,t,r,J.empty()))}return n}(t);return function(e,t){return e.asyncQueue.enqueue((async()=>async function(e,t){const n=w(e),r=n.indexManager,i=[];return n.persistence.runTransaction("Configure indexes","readwrite",(e=>r.getFieldIndexes(e).next((n=>function(e,t,n,r,i){e=[...e],t=[...t],e.sort(n),t.sort(n);const s=e.length,o=t.length;let a=0,c=0;for(;a<o&&c<s;){const s=n(e[c],t[a]);s<0?i(e[c++]):s>0?r(t[a++]):(a++,c++)}for(;a<o;)r(t[a++]);for(;c<s;)i(e[c++])}(n,t,$,(t=>{i.push(r.addFieldIndex(e,t))}),(t=>{i.push(r.deleteFieldIndex(e,t))})))).next((()=>ie.waitFor(i)))))}(await _u(e),t)))}(r,i)},t.setLogLevel=function(e){d.setLogLevel(e)},t.snapshotEqual=function(e,t){return e instanceof eh&&t instanceof eh?e._firestore===t._firestore&&e._key.isEqual(t._key)&&(null===e._document?null===t._document:e._document.isEqual(t._document))&&e._converter===t._converter:e instanceof nh&&t instanceof nh&&e._firestore===t._firestore&&Gu(e.query,t.query)&&e.metadata.isEqual(t.metadata)&&e._snapshot.isEqual(t._snapshot)},t.startAfter=function(...e){return ql._create("startAfter",e,!1)},t.startAt=function(...e){return ql._create("startAt",e,!0)},t.sum=function(e){return new Zu("sum",Al("sum",e))},t.terminate=function(e){return r._removeServiceInstance(e.app,"firestore",e._databaseId.database),e._delete()},t.updateDoc=function(e,t,n,...r){e=Lu(e,Bu);const i=Lu(e.firestore,Hu),s=dl(i);let a;return a="string"==typeof(t=o.getModularInstance(t))||t instanceof nl?_l(s,"updateDoc",e._key,t,n,r):wl(s,"updateDoc",e._key,t),sh(i,[a.toMutation(e._key,Ir.exists(!0))])},t.vector=function(e){return new sl(e)},t.waitForPendingWrites=function(e){return function(e){const t=new E;return e.asyncQueue.enqueueAndForget((async()=>async function(e,t){const n=w(e);Pa(n.remoteStore)||p("SyncEngine","The network is disabled. The task returned by 'awaitPendingWrites()' will not complete until the network is enabled.");try{const e=await function(e){const t=w(e);return t.persistence.runTransaction("Get highest unacknowledged batch id","readonly",(e=>t.mutationQueue.getHighestUnacknowledgedBatchId(e)))}(n.localStore);if(-1===e)return void t.resolve();const r=n.ka.get(e)||[];r.push(t),n.ka.set(e,r)}catch(e){const n=nc(e,"Initialization of waitForPendingWrites() operation failed");t.reject(n)}}(await Eu(e),t))),t.promise}(Qu(e=Lu(e,Hu)))},t.where=function(e,t,n){const r=t,i=Pl("where",e);return Vl._create(i,r,n)},t.writeBatch=function(e){return Qu(e=Lu(e,Hu)),new gh(e,(t=>sh(e,t)))}},5844:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r,i,s=n(1635),o=[];t.LogLevel=void 0,(i=t.LogLevel||(t.LogLevel={}))[i.DEBUG=0]="DEBUG",i[i.VERBOSE=1]="VERBOSE",i[i.INFO=2]="INFO",i[i.WARN=3]="WARN",i[i.ERROR=4]="ERROR",i[i.SILENT=5]="SILENT";var a={debug:t.LogLevel.DEBUG,verbose:t.LogLevel.VERBOSE,info:t.LogLevel.INFO,warn:t.LogLevel.WARN,error:t.LogLevel.ERROR,silent:t.LogLevel.SILENT},c=t.LogLevel.INFO,u=((r={})[t.LogLevel.DEBUG]="log",r[t.LogLevel.VERBOSE]="log",r[t.LogLevel.INFO]="info",r[t.LogLevel.WARN]="warn",r[t.LogLevel.ERROR]="error",r),l=function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];if(!(t<e.logLevel)){var i=(new Date).toISOString(),o=u[t];if(!o)throw new Error("Attempted to log a message with an invalid logType (value: ".concat(t,")"));console[o].apply(console,s.__spreadArray(["[".concat(i,"] ").concat(e.name,":")],n,!1))}},h=function(){function e(e){this.name=e,this._logLevel=c,this._logHandler=l,this._userLogHandler=null,o.push(this)}return Object.defineProperty(e.prototype,"logLevel",{get:function(){return this._logLevel},set:function(e){if(!(e in t.LogLevel))throw new TypeError('Invalid value "'.concat(e,'" assigned to `logLevel`'));this._logLevel=e},enumerable:!1,configurable:!0}),e.prototype.setLogLevel=function(e){this._logLevel="string"==typeof e?a[e]:e},Object.defineProperty(e.prototype,"logHandler",{get:function(){return this._logHandler},set:function(e){if("function"!=typeof e)throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"userLogHandler",{get:function(){return this._userLogHandler},set:function(e){this._userLogHandler=e},enumerable:!1,configurable:!0}),e.prototype.debug=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];this._userLogHandler&&this._userLogHandler.apply(this,s.__spreadArray([this,t.LogLevel.DEBUG],e,!1)),this._logHandler.apply(this,s.__spreadArray([this,t.LogLevel.DEBUG],e,!1))},e.prototype.log=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];this._userLogHandler&&this._userLogHandler.apply(this,s.__spreadArray([this,t.LogLevel.VERBOSE],e,!1)),this._logHandler.apply(this,s.__spreadArray([this,t.LogLevel.VERBOSE],e,!1))},e.prototype.info=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];this._userLogHandler&&this._userLogHandler.apply(this,s.__spreadArray([this,t.LogLevel.INFO],e,!1)),this._logHandler.apply(this,s.__spreadArray([this,t.LogLevel.INFO],e,!1))},e.prototype.warn=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];this._userLogHandler&&this._userLogHandler.apply(this,s.__spreadArray([this,t.LogLevel.WARN],e,!1)),this._logHandler.apply(this,s.__spreadArray([this,t.LogLevel.WARN],e,!1))},e.prototype.error=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];this._userLogHandler&&this._userLogHandler.apply(this,s.__spreadArray([this,t.LogLevel.ERROR],e,!1)),this._logHandler.apply(this,s.__spreadArray([this,t.LogLevel.ERROR],e,!1))},e}();t.Logger=h,t.setLogLevel=function(e){o.forEach((function(t){t.setLogLevel(e)}))},t.setUserLogHandler=function(e,n){for(var r=function(r){var i=null;n&&n.level&&(i=a[n.level]),r.userLogHandler=null===e?null:function(n,r){for(var s=[],o=2;o<arguments.length;o++)s[o-2]=arguments[o];var a=s.map((function(e){if(null==e)return null;if("string"==typeof e)return e;if("number"==typeof e||"boolean"==typeof e)return e.toString();if(e instanceof Error)return e.message;try{return JSON.stringify(e)}catch(e){return null}})).filter((function(e){return e})).join(" ");r>=(null!=i?i:n.logLevel)&&e({level:t.LogLevel[r].toLowerCase(),message:a,args:s,type:n.name})}},i=0,s=o;i<s.length;i++)r(s[i])}},6336:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r={NODE_CLIENT:!1,NODE_ADMIN:!1,SDK_VERSION:"${JSCORE_VERSION}"},i=function(e,t){if(!e)throw s(t)},s=function(e){return new Error("Firebase Database ("+r.SDK_VERSION+") INTERNAL ASSERT FAILED: "+e)},o=function(e){const t=[];let n=0;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);i<128?t[n++]=i:i<2048?(t[n++]=i>>6|192,t[n++]=63&i|128):55296==(64512&i)&&r+1<e.length&&56320==(64512&e.charCodeAt(r+1))?(i=65536+((1023&i)<<10)+(1023&e.charCodeAt(++r)),t[n++]=i>>18|240,t[n++]=i>>12&63|128,t[n++]=i>>6&63|128,t[n++]=63&i|128):(t[n++]=i>>12|224,t[n++]=i>>6&63|128,t[n++]=63&i|128)}return t},a={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(e,t){if(!Array.isArray(e))throw Error("encodeByteArray takes an array as a parameter");this.init_();const n=t?this.byteToCharMapWebSafe_:this.byteToCharMap_,r=[];for(let t=0;t<e.length;t+=3){const i=e[t],s=t+1<e.length,o=s?e[t+1]:0,a=t+2<e.length,c=a?e[t+2]:0,u=i>>2,l=(3&i)<<4|o>>4;let h=(15&o)<<2|c>>6,d=63&c;a||(d=64,s||(h=64)),r.push(n[u],n[l],n[h],n[d])}return r.join("")},encodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?btoa(e):this.encodeByteArray(o(e),t)},decodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?atob(e):function(e){const t=[];let n=0,r=0;for(;n<e.length;){const i=e[n++];if(i<128)t[r++]=String.fromCharCode(i);else if(i>191&&i<224){const s=e[n++];t[r++]=String.fromCharCode((31&i)<<6|63&s)}else if(i>239&&i<365){const s=((7&i)<<18|(63&e[n++])<<12|(63&e[n++])<<6|63&e[n++])-65536;t[r++]=String.fromCharCode(55296+(s>>10)),t[r++]=String.fromCharCode(56320+(1023&s))}else{const s=e[n++],o=e[n++];t[r++]=String.fromCharCode((15&i)<<12|(63&s)<<6|63&o)}}return t.join("")}(this.decodeStringToByteArray(e,t))},decodeStringToByteArray(e,t){this.init_();const n=t?this.charToByteMapWebSafe_:this.charToByteMap_,r=[];for(let t=0;t<e.length;){const i=n[e.charAt(t++)],s=t<e.length?n[e.charAt(t)]:0;++t;const o=t<e.length?n[e.charAt(t)]:64;++t;const a=t<e.length?n[e.charAt(t)]:64;if(++t,null==i||null==s||null==o||null==a)throw new c;const u=i<<2|s>>4;if(r.push(u),64!==o){const e=s<<4&240|o>>2;if(r.push(e),64!==a){const e=o<<6&192|a;r.push(e)}}}return r},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let e=0;e<this.ENCODED_VALS.length;e++)this.byteToCharMap_[e]=this.ENCODED_VALS.charAt(e),this.charToByteMap_[this.byteToCharMap_[e]]=e,this.byteToCharMapWebSafe_[e]=this.ENCODED_VALS_WEBSAFE.charAt(e),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[e]]=e,e>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(e)]=e,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(e)]=e)}}};class c extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}const u=function(e){const t=o(e);return a.encodeByteArray(t,!0)},l=function(e){return u(e).replace(/\./g,"")},h=function(e){try{return a.decodeString(e,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};function d(e,t){if(!(t instanceof Object))return t;switch(t.constructor){case Date:return new Date(t.getTime());case Object:void 0===e&&(e={});break;case Array:e=[];break;default:return t}for(const n in t)t.hasOwnProperty(n)&&"__proto__"!==n&&(e[n]=d(e[n],t[n]));return e}function f(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==n.g)return n.g;throw new Error("Unable to locate global object.")}const p=()=>{try{return f().__FIREBASE_DEFAULTS__||(()=>{if("undefined"==typeof process||void 0===process.env)return;const e=process.env.__FIREBASE_DEFAULTS__;return e?JSON.parse(e):void 0})()||(()=>{if("undefined"==typeof document)return;let e;try{e=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch(e){return}const t=e&&h(e[1]);return t&&JSON.parse(t)})()}catch(e){return void console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${e}`)}},m=e=>{var t,n;return null===(n=null===(t=p())||void 0===t?void 0:t.emulatorHosts)||void 0===n?void 0:n[e]};class g{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}wrapCallback(e){return(t,n)=>{t?this.reject(t):this.resolve(n),"function"==typeof e&&(this.promise.catch((()=>{})),1===e.length?e(t):e(t,n))}}}function y(){return"undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:""}function v(){var e;const t=null===(e=p())||void 0===e?void 0:e.forceEnvironment;if("node"===t)return!0;if("browser"===t)return!1;try{return"[object process]"===Object.prototype.toString.call(n.g.process)}catch(e){return!1}}function b(){return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope}class w extends Error{constructor(e,t,n){super(t),this.code=e,this.customData=n,this.name="FirebaseError",Object.setPrototypeOf(this,w.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,_.prototype.create)}}class _{constructor(e,t,n){this.service=e,this.serviceName=t,this.errors=n}create(e,...t){const n=t[0]||{},r=`${this.service}/${e}`,i=this.errors[e],s=i?function(e,t){return e.replace(I,((e,n)=>{const r=t[n];return null!=r?String(r):`<${n}?>`}))}(i,n):"Error",o=`${this.serviceName}: ${s} (${r}).`;return new w(r,o,n)}}const I=/\{\$([^}]+)}/g;function E(e){return JSON.parse(e)}const T=function(e){let t={},n={},r={},i="";try{const s=e.split(".");t=E(h(s[0])||""),n=E(h(s[1])||""),i=s[2],r=n.d||{},delete n.d}catch(e){}return{header:t,claims:n,data:r,signature:i}};function S(e){return null!==e&&"object"==typeof e}class C{constructor(e,t){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=t,this.task.then((()=>{e(this)})).catch((e=>{this.error(e)}))}next(e){this.forEachObserver((t=>{t.next(e)}))}error(e){this.forEachObserver((t=>{t.error(e)})),this.close(e)}complete(){this.forEachObserver((e=>{e.complete()})),this.close()}subscribe(e,t,n){let r;if(void 0===e&&void 0===t&&void 0===n)throw new Error("Missing Observer.");r=function(e){if("object"!=typeof e||null===e)return!1;for(const t of["next","error","complete"])if(t in e&&"function"==typeof e[t])return!0;return!1}(e)?e:{next:e,error:t,complete:n},void 0===r.next&&(r.next=A),void 0===r.error&&(r.error=A),void 0===r.complete&&(r.complete=A);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(e){}})),this.observers.push(r),i}unsubscribeOne(e){void 0!==this.observers&&void 0!==this.observers[e]&&(delete this.observers[e],this.observerCount-=1,0===this.observerCount&&void 0!==this.onNoObservers&&this.onNoObservers(this))}forEachObserver(e){if(!this.finalized)for(let t=0;t<this.observers.length;t++)this.sendOne(t,e)}sendOne(e,t){this.task.then((()=>{if(void 0!==this.observers&&void 0!==this.observers[e])try{t(this.observers[e])}catch(e){"undefined"!=typeof console&&console.error&&console.error(e)}}))}close(e){this.finalized||(this.finalized=!0,void 0!==e&&(this.finalError=e),this.task.then((()=>{this.observers=void 0,this.onNoObservers=void 0})))}}function A(){}function x(e,t){return`${e} failed: ${t} argument `}const k=144e5;t.CONSTANTS=r,t.DecodeBase64StringError=c,t.Deferred=g,t.ErrorFactory=_,t.FirebaseError=w,t.MAX_VALUE_MILLIS=k,t.RANDOM_FACTOR=.5,t.Sha1=class{constructor(){this.chain_=[],this.buf_=[],this.W_=[],this.pad_=[],this.inbuf_=0,this.total_=0,this.blockSize=64,this.pad_[0]=128;for(let e=1;e<this.blockSize;++e)this.pad_[e]=0;this.reset()}reset(){this.chain_[0]=1732584193,this.chain_[1]=4023233417,this.chain_[2]=2562383102,this.chain_[3]=271733878,this.chain_[4]=3285377520,this.inbuf_=0,this.total_=0}compress_(e,t){t||(t=0);const n=this.W_;if("string"==typeof e)for(let r=0;r<16;r++)n[r]=e.charCodeAt(t)<<24|e.charCodeAt(t+1)<<16|e.charCodeAt(t+2)<<8|e.charCodeAt(t+3),t+=4;else for(let r=0;r<16;r++)n[r]=e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3],t+=4;for(let e=16;e<80;e++){const t=n[e-3]^n[e-8]^n[e-14]^n[e-16];n[e]=4294967295&(t<<1|t>>>31)}let r,i,s=this.chain_[0],o=this.chain_[1],a=this.chain_[2],c=this.chain_[3],u=this.chain_[4];for(let e=0;e<80;e++){e<40?e<20?(r=c^o&(a^c),i=1518500249):(r=o^a^c,i=1859775393):e<60?(r=o&a|c&(o|a),i=2400959708):(r=o^a^c,i=3395469782);const t=(s<<5|s>>>27)+r+u+i+n[e]&4294967295;u=c,c=a,a=4294967295&(o<<30|o>>>2),o=s,s=t}this.chain_[0]=this.chain_[0]+s&4294967295,this.chain_[1]=this.chain_[1]+o&4294967295,this.chain_[2]=this.chain_[2]+a&4294967295,this.chain_[3]=this.chain_[3]+c&4294967295,this.chain_[4]=this.chain_[4]+u&4294967295}update(e,t){if(null==e)return;void 0===t&&(t=e.length);const n=t-this.blockSize;let r=0;const i=this.buf_;let s=this.inbuf_;for(;r<t;){if(0===s)for(;r<=n;)this.compress_(e,r),r+=this.blockSize;if("string"==typeof e){for(;r<t;)if(i[s]=e.charCodeAt(r),++s,++r,s===this.blockSize){this.compress_(i),s=0;break}}else for(;r<t;)if(i[s]=e[r],++s,++r,s===this.blockSize){this.compress_(i),s=0;break}}this.inbuf_=s,this.total_+=t}digest(){const e=[];let t=8*this.total_;this.inbuf_<56?this.update(this.pad_,56-this.inbuf_):this.update(this.pad_,this.blockSize-(this.inbuf_-56));for(let e=this.blockSize-1;e>=56;e--)this.buf_[e]=255&t,t/=256;this.compress_(this.buf_);let n=0;for(let t=0;t<5;t++)for(let r=24;r>=0;r-=8)e[n]=this.chain_[t]>>r&255,++n;return e}},t.areCookiesEnabled=function(){return!("undefined"==typeof navigator||!navigator.cookieEnabled)},t.assert=i,t.assertionError=s,t.async=function(e,t){return(...n)=>{Promise.resolve(!0).then((()=>{e(...n)})).catch((e=>{t&&t(e)}))}},t.base64=a,t.base64Decode=h,t.base64Encode=u,t.base64urlEncodeWithoutPadding=l,t.calculateBackoffMillis=function(e,t=1e3,n=2){const r=t*Math.pow(n,e),i=Math.round(.5*r*(Math.random()-.5)*2);return Math.min(k,r+i)},t.contains=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.createMockUserToken=function(e,t){if(e.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');const n=t||"demo-project",r=e.iat||0,i=e.sub||e.user_id;if(!i)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const s=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:{}}},e);return[l(JSON.stringify({alg:"none",type:"JWT"})),l(JSON.stringify(s)),""].join(".")},t.createSubscribe=function(e,t){const n=new C(e,t);return n.subscribe.bind(n)},t.decode=T,t.deepCopy=function(e){return d(void 0,e)},t.deepEqual=function e(t,n){if(t===n)return!0;const r=Object.keys(t),i=Object.keys(n);for(const s of r){if(!i.includes(s))return!1;const r=t[s],o=n[s];if(S(r)&&S(o)){if(!e(r,o))return!1}else if(r!==o)return!1}for(const e of i)if(!r.includes(e))return!1;return!0},t.deepExtend=d,t.errorPrefix=x,t.extractQuerystring=function(e){const t=e.indexOf("?");if(!t)return"";const n=e.indexOf("#",t);return e.substring(t,n>0?n:void 0)},t.getDefaultAppConfig=()=>{var e;return null===(e=p())||void 0===e?void 0:e.config},t.getDefaultEmulatorHost=m,t.getDefaultEmulatorHostnameAndPort=e=>{const t=m(e);if(!t)return;const n=t.lastIndexOf(":");if(n<=0||n+1===t.length)throw new Error(`Invalid host ${t} with no separate hostname and port!`);const r=parseInt(t.substring(n+1),10);return"["===t[0]?[t.substring(1,n-1),r]:[t.substring(0,n),r]},t.getDefaults=p,t.getExperimentalSetting=e=>{var t;return null===(t=p())||void 0===t?void 0:t[`_${e}`]},t.getGlobal=f,t.getModularInstance=function(e){return e&&e._delegate?e._delegate:e},t.getUA=y,t.isAdmin=function(e){const t=T(e).claims;return"object"==typeof t&&!0===t.admin},t.isBrowser=function(){return"undefined"!=typeof window||b()},t.isBrowserExtension=function(){const e="object"==typeof chrome?chrome.runtime:"object"==typeof browser?browser.runtime:void 0;return"object"==typeof e&&void 0!==e.id},t.isElectron=function(){return y().indexOf("Electron/")>=0},t.isEmpty=function(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0},t.isIE=function(){const e=y();return e.indexOf("MSIE ")>=0||e.indexOf("Trident/")>=0},t.isIndexedDBAvailable=function(){try{return"object"==typeof indexedDB}catch(e){return!1}},t.isMobileCordova=function(){return"undefined"!=typeof window&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(y())},t.isNode=v,t.isNodeSdk=function(){return!0===r.NODE_CLIENT||!0===r.NODE_ADMIN},t.isReactNative=function(){return"object"==typeof navigator&&"ReactNative"===navigator.product},t.isSafari=function(){return!v()&&!!navigator.userAgent&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")},t.isUWP=function(){return y().indexOf("MSAppHost/")>=0},t.isValidFormat=function(e){const t=T(e).claims;return!!t&&"object"==typeof t&&t.hasOwnProperty("iat")},t.isValidTimestamp=function(e){const t=T(e).claims,n=Math.floor((new Date).getTime()/1e3);let r=0,i=0;return"object"==typeof t&&(t.hasOwnProperty("nbf")?r=t.nbf:t.hasOwnProperty("iat")&&(r=t.iat),i=t.hasOwnProperty("exp")?t.exp:r+86400),!!n&&!!r&&!!i&&n>=r&&n<=i},t.isWebWorker=b,t.issuedAtTime=function(e){const t=T(e).claims;return"object"==typeof t&&t.hasOwnProperty("iat")?t.iat:null},t.jsonEval=E,t.map=function(e,t,n){const r={};for(const i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=t.call(n,e[i],i,e));return r},t.ordinal=function(e){return Number.isFinite(e)?e+function(e){const t=(e=Math.abs(e))%100;if(t>=10&&t<=20)return"th";const n=e%10;return 1===n?"st":2===n?"nd":3===n?"rd":"th"}(e):`${e}`},t.promiseWithTimeout=function(e,t=2e3){const n=new g;return setTimeout((()=>n.reject("timeout!")),t),e.then(n.resolve,n.reject),n.promise},t.querystring=function(e){const t=[];for(const[n,r]of Object.entries(e))Array.isArray(r)?r.forEach((e=>{t.push(encodeURIComponent(n)+"="+encodeURIComponent(e))})):t.push(encodeURIComponent(n)+"="+encodeURIComponent(r));return t.length?"&"+t.join("&"):""},t.querystringDecode=function(e){const t={};return e.replace(/^\?/,"").split("&").forEach((e=>{if(e){const[n,r]=e.split("=");t[decodeURIComponent(n)]=decodeURIComponent(r)}})),t},t.safeGet=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0},t.stringLength=function(e){let t=0;for(let n=0;n<e.length;n++){const r=e.charCodeAt(n);r<128?t++:r<2048?t+=2:r>=55296&&r<=56319?(t+=4,n++):t+=3}return t},t.stringToByteArray=function(e){const t=[];let n=0;for(let r=0;r<e.length;r++){let s=e.charCodeAt(r);if(s>=55296&&s<=56319){const t=s-55296;r++,i(r<e.length,"Surrogate pair missing trail surrogate."),s=65536+(t<<10)+(e.charCodeAt(r)-56320)}s<128?t[n++]=s:s<2048?(t[n++]=s>>6|192,t[n++]=63&s|128):s<65536?(t[n++]=s>>12|224,t[n++]=s>>6&63|128,t[n++]=63&s|128):(t[n++]=s>>18|240,t[n++]=s>>12&63|128,t[n++]=s>>6&63|128,t[n++]=63&s|128)}return t},t.stringify=function(e){return JSON.stringify(e)},t.uuidv4=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))},t.validateArgCount=function(e,t,n,r){let i;if(r<t?i="at least "+t:r>n&&(i=0===n?"none":"no more than "+n),i)throw new Error(e+" failed: Was called with "+r+(1===r?" argument.":" arguments.")+" Expects "+i+".")},t.validateCallback=function(e,t,n,r){if((!r||n)&&"function"!=typeof n)throw new Error(x(e,t)+"must be a valid function.")},t.validateContextObject=function(e,t,n,r){if((!r||n)&&("object"!=typeof n||null===n))throw new Error(x(e,t)+"must be a valid context object.")},t.validateIndexedDBOpenable=function(){return new Promise(((e,t)=>{try{let n=!0;const r="validate-browser-context-for-indexeddb-analytics-module",i=self.indexedDB.open(r);i.onsuccess=()=>{i.result.close(),n||self.indexedDB.deleteDatabase(r),e(!0)},i.onupgradeneeded=()=>{n=!1},i.onerror=()=>{var e;t((null===(e=i.error)||void 0===e?void 0:e.message)||"")}}catch(e){t(e)}}))},t.validateNamespace=function(e,t,n){if((!n||t)&&"string"!=typeof t)throw new Error(x(e,"namespace")+"must be a valid firebase namespace.")}},860:(e,t,n)=>{(function(){"use strict";var t;function n(){this.blockSize=-1,this.blockSize=64,this.g=Array(4),this.B=Array(this.blockSize),this.o=this.h=0,this.s()}function r(e,t,n){n||(n=0);var r=Array(16);if("string"==typeof t)for(var i=0;16>i;++i)r[i]=t.charCodeAt(n++)|t.charCodeAt(n++)<<8|t.charCodeAt(n++)<<16|t.charCodeAt(n++)<<24;else for(i=0;16>i;++i)r[i]=t[n++]|t[n++]<<8|t[n++]<<16|t[n++]<<24;t=e.g[0],n=e.g[1],i=e.g[2];var s=e.g[3],o=t+(s^n&(i^s))+r[0]+3614090360&4294967295;o=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=n+(o<<7&4294967295|o>>>25))+((o=s+(i^t&(n^i))+r[1]+3905402710&4294967295)<<12&4294967295|o>>>20))+((o=i+(n^s&(t^n))+r[2]+606105819&4294967295)<<17&4294967295|o>>>15))+((o=n+(t^i&(s^t))+r[3]+3250441966&4294967295)<<22&4294967295|o>>>10))+((o=t+(s^n&(i^s))+r[4]+4118548399&4294967295)<<7&4294967295|o>>>25))+((o=s+(i^t&(n^i))+r[5]+1200080426&4294967295)<<12&4294967295|o>>>20))+((o=i+(n^s&(t^n))+r[6]+2821735955&4294967295)<<17&4294967295|o>>>15))+((o=n+(t^i&(s^t))+r[7]+4249261313&4294967295)<<22&4294967295|o>>>10))+((o=t+(s^n&(i^s))+r[8]+1770035416&4294967295)<<7&4294967295|o>>>25))+((o=s+(i^t&(n^i))+r[9]+2336552879&4294967295)<<12&4294967295|o>>>20))+((o=i+(n^s&(t^n))+r[10]+4294925233&4294967295)<<17&4294967295|o>>>15))+((o=n+(t^i&(s^t))+r[11]+2304563134&4294967295)<<22&4294967295|o>>>10))+((o=t+(s^n&(i^s))+r[12]+1804603682&4294967295)<<7&4294967295|o>>>25))+((o=s+(i^t&(n^i))+r[13]+4254626195&4294967295)<<12&4294967295|o>>>20))+((o=i+(n^s&(t^n))+r[14]+2792965006&4294967295)<<17&4294967295|o>>>15))+((o=n+(t^i&(s^t))+r[15]+1236535329&4294967295)<<22&4294967295|o>>>10))+((o=t+(i^s&(n^i))+r[1]+4129170786&4294967295)<<5&4294967295|o>>>27))+((o=s+(n^i&(t^n))+r[6]+3225465664&4294967295)<<9&4294967295|o>>>23))+((o=i+(t^n&(s^t))+r[11]+643717713&4294967295)<<14&4294967295|o>>>18))+((o=n+(s^t&(i^s))+r[0]+3921069994&4294967295)<<20&4294967295|o>>>12))+((o=t+(i^s&(n^i))+r[5]+3593408605&4294967295)<<5&4294967295|o>>>27))+((o=s+(n^i&(t^n))+r[10]+38016083&4294967295)<<9&4294967295|o>>>23))+((o=i+(t^n&(s^t))+r[15]+3634488961&4294967295)<<14&4294967295|o>>>18))+((o=n+(s^t&(i^s))+r[4]+3889429448&4294967295)<<20&4294967295|o>>>12))+((o=t+(i^s&(n^i))+r[9]+568446438&4294967295)<<5&4294967295|o>>>27))+((o=s+(n^i&(t^n))+r[14]+3275163606&4294967295)<<9&4294967295|o>>>23))+((o=i+(t^n&(s^t))+r[3]+4107603335&4294967295)<<14&4294967295|o>>>18))+((o=n+(s^t&(i^s))+r[8]+1163531501&4294967295)<<20&4294967295|o>>>12))+((o=t+(i^s&(n^i))+r[13]+2850285829&4294967295)<<5&4294967295|o>>>27))+((o=s+(n^i&(t^n))+r[2]+4243563512&4294967295)<<9&4294967295|o>>>23))+((o=i+(t^n&(s^t))+r[7]+1735328473&4294967295)<<14&4294967295|o>>>18))+((o=n+(s^t&(i^s))+r[12]+2368359562&4294967295)<<20&4294967295|o>>>12))+((o=t+(n^i^s)+r[5]+4294588738&4294967295)<<4&4294967295|o>>>28))+((o=s+(t^n^i)+r[8]+2272392833&4294967295)<<11&4294967295|o>>>21))+((o=i+(s^t^n)+r[11]+1839030562&4294967295)<<16&4294967295|o>>>16))+((o=n+(i^s^t)+r[14]+4259657740&4294967295)<<23&4294967295|o>>>9))+((o=t+(n^i^s)+r[1]+2763975236&4294967295)<<4&4294967295|o>>>28))+((o=s+(t^n^i)+r[4]+1272893353&4294967295)<<11&4294967295|o>>>21))+((o=i+(s^t^n)+r[7]+4139469664&4294967295)<<16&4294967295|o>>>16))+((o=n+(i^s^t)+r[10]+3200236656&4294967295)<<23&4294967295|o>>>9))+((o=t+(n^i^s)+r[13]+681279174&4294967295)<<4&4294967295|o>>>28))+((o=s+(t^n^i)+r[0]+3936430074&4294967295)<<11&4294967295|o>>>21))+((o=i+(s^t^n)+r[3]+3572445317&4294967295)<<16&4294967295|o>>>16))+((o=n+(i^s^t)+r[6]+76029189&4294967295)<<23&4294967295|o>>>9))+((o=t+(n^i^s)+r[9]+3654602809&4294967295)<<4&4294967295|o>>>28))+((o=s+(t^n^i)+r[12]+3873151461&4294967295)<<11&4294967295|o>>>21))+((o=i+(s^t^n)+r[15]+530742520&4294967295)<<16&4294967295|o>>>16))+((o=n+(i^s^t)+r[2]+3299628645&4294967295)<<23&4294967295|o>>>9))+((o=t+(i^(n|~s))+r[0]+4096336452&4294967295)<<6&4294967295|o>>>26))+((o=s+(n^(t|~i))+r[7]+1126891415&4294967295)<<10&4294967295|o>>>22))+((o=i+(t^(s|~n))+r[14]+2878612391&4294967295)<<15&4294967295|o>>>17))+((o=n+(s^(i|~t))+r[5]+4237533241&4294967295)<<21&4294967295|o>>>11))+((o=t+(i^(n|~s))+r[12]+1700485571&4294967295)<<6&4294967295|o>>>26))+((o=s+(n^(t|~i))+r[3]+2399980690&4294967295)<<10&4294967295|o>>>22))+((o=i+(t^(s|~n))+r[10]+4293915773&4294967295)<<15&4294967295|o>>>17))+((o=n+(s^(i|~t))+r[1]+2240044497&4294967295)<<21&4294967295|o>>>11))+((o=t+(i^(n|~s))+r[8]+1873313359&4294967295)<<6&4294967295|o>>>26))+((o=s+(n^(t|~i))+r[15]+4264355552&4294967295)<<10&4294967295|o>>>22))+((o=i+(t^(s|~n))+r[6]+2734768916&4294967295)<<15&4294967295|o>>>17))+((o=n+(s^(i|~t))+r[13]+1309151649&4294967295)<<21&4294967295|o>>>11))+((s=(t=n+((o=t+(i^(n|~s))+r[4]+4149444226&4294967295)<<6&4294967295|o>>>26))+((o=s+(n^(t|~i))+r[11]+3174756917&4294967295)<<10&4294967295|o>>>22))^((i=s+((o=i+(t^(s|~n))+r[2]+718787259&4294967295)<<15&4294967295|o>>>17))|~t))+r[9]+3951481745&4294967295,e.g[0]=e.g[0]+t&4294967295,e.g[1]=e.g[1]+(i+(o<<21&4294967295|o>>>11))&4294967295,e.g[2]=e.g[2]+i&4294967295,e.g[3]=e.g[3]+s&4294967295}function i(e,t){this.h=t;for(var n=[],r=!0,i=e.length-1;0<=i;i--){var s=0|e[i];r&&s==t||(n[i]=s,r=!1)}this.g=n}!function(e,t){function n(){}n.prototype=t.prototype,e.D=t.prototype,e.prototype=new n,e.prototype.constructor=e,e.C=function(e,n,r){for(var i=Array(arguments.length-2),s=2;s<arguments.length;s++)i[s-2]=arguments[s];return t.prototype[n].apply(e,i)}}(n,(function(){this.blockSize=-1})),n.prototype.s=function(){this.g[0]=1732584193,this.g[1]=4023233417,this.g[2]=2562383102,this.g[3]=271733878,this.o=this.h=0},n.prototype.u=function(e,t){void 0===t&&(t=e.length);for(var n=t-this.blockSize,i=this.B,s=this.h,o=0;o<t;){if(0==s)for(;o<=n;)r(this,e,o),o+=this.blockSize;if("string"==typeof e){for(;o<t;)if(i[s++]=e.charCodeAt(o++),s==this.blockSize){r(this,i),s=0;break}}else for(;o<t;)if(i[s++]=e[o++],s==this.blockSize){r(this,i),s=0;break}}this.h=s,this.o+=t},n.prototype.v=function(){var e=Array((56>this.h?this.blockSize:2*this.blockSize)-this.h);e[0]=128;for(var t=1;t<e.length-8;++t)e[t]=0;var n=8*this.o;for(t=e.length-8;t<e.length;++t)e[t]=255&n,n/=256;for(this.u(e),e=Array(16),t=n=0;4>t;++t)for(var r=0;32>r;r+=8)e[n++]=this.g[t]>>>r&255;return e};var s={};function o(e){return-128<=e&&128>e?function(e){var t=s;return Object.prototype.hasOwnProperty.call(t,e)?t[e]:t[e]=function(e){return new i([0|e],0>e?-1:0)}(e)}(e):new i([0|e],0>e?-1:0)}function a(e){if(isNaN(e)||!isFinite(e))return c;if(0>e)return f(a(-e));for(var t=[],n=1,r=0;e>=n;r++)t[r]=e/n|0,n*=4294967296;return new i(t,0)}var c=o(0),u=o(1),l=o(16777216);function h(e){if(0!=e.h)return!1;for(var t=0;t<e.g.length;t++)if(0!=e.g[t])return!1;return!0}function d(e){return-1==e.h}function f(e){for(var t=e.g.length,n=[],r=0;r<t;r++)n[r]=~e.g[r];return new i(n,~e.h).add(u)}function p(e,t){return e.add(f(t))}function m(e,t){for(;(65535&e[t])!=e[t];)e[t+1]+=e[t]>>>16,e[t]&=65535,t++}function g(e,t){this.g=e,this.h=t}function y(e,t){if(h(t))throw Error("division by zero");if(h(e))return new g(c,c);if(d(e))return t=y(f(e),t),new g(f(t.g),f(t.h));if(d(t))return t=y(e,f(t)),new g(f(t.g),t.h);if(30<e.g.length){if(d(e)||d(t))throw Error("slowDivide_ only works with positive integers.");for(var n=u,r=t;0>=r.l(e);)n=v(n),r=v(r);var i=b(n,1),s=b(r,1);for(r=b(r,2),n=b(n,2);!h(r);){var o=s.add(r);0>=o.l(e)&&(i=i.add(n),s=o),r=b(r,1),n=b(n,1)}return t=p(e,i.j(t)),new g(i,t)}for(i=c;0<=e.l(t);){for(n=Math.max(1,Math.floor(e.m()/t.m())),r=48>=(r=Math.ceil(Math.log(n)/Math.LN2))?1:Math.pow(2,r-48),o=(s=a(n)).j(t);d(o)||0<o.l(e);)o=(s=a(n-=r)).j(t);h(s)&&(s=u),i=i.add(s),e=p(e,o)}return new g(i,e)}function v(e){for(var t=e.g.length+1,n=[],r=0;r<t;r++)n[r]=e.i(r)<<1|e.i(r-1)>>>31;return new i(n,e.h)}function b(e,t){var n=t>>5;t%=32;for(var r=e.g.length-n,s=[],o=0;o<r;o++)s[o]=0<t?e.i(o+n)>>>t|e.i(o+n+1)<<32-t:e.i(o+n);return new i(s,e.h)}(t=i.prototype).m=function(){if(d(this))return-f(this).m();for(var e=0,t=1,n=0;n<this.g.length;n++){var r=this.i(n);e+=(0<=r?r:4294967296+r)*t,t*=4294967296}return e},t.toString=function(e){if(2>(e=e||10)||36<e)throw Error("radix out of range: "+e);if(h(this))return"0";if(d(this))return"-"+f(this).toString(e);for(var t=a(Math.pow(e,6)),n=this,r="";;){var i=y(n,t).g,s=((0<(n=p(n,i.j(t))).g.length?n.g[0]:n.h)>>>0).toString(e);if(h(n=i))return s+r;for(;6>s.length;)s="0"+s;r=s+r}},t.i=function(e){return 0>e?0:e<this.g.length?this.g[e]:this.h},t.l=function(e){return d(e=p(this,e))?-1:h(e)?0:1},t.abs=function(){return d(this)?f(this):this},t.add=function(e){for(var t=Math.max(this.g.length,e.g.length),n=[],r=0,s=0;s<=t;s++){var o=r+(65535&this.i(s))+(65535&e.i(s)),a=(o>>>16)+(this.i(s)>>>16)+(e.i(s)>>>16);r=a>>>16,o&=65535,a&=65535,n[s]=a<<16|o}return new i(n,-2147483648&n[n.length-1]?-1:0)},t.j=function(e){if(h(this)||h(e))return c;if(d(this))return d(e)?f(this).j(f(e)):f(f(this).j(e));if(d(e))return f(this.j(f(e)));if(0>this.l(l)&&0>e.l(l))return a(this.m()*e.m());for(var t=this.g.length+e.g.length,n=[],r=0;r<2*t;r++)n[r]=0;for(r=0;r<this.g.length;r++)for(var s=0;s<e.g.length;s++){var o=this.i(r)>>>16,u=65535&this.i(r),p=e.i(s)>>>16,g=65535&e.i(s);n[2*r+2*s]+=u*g,m(n,2*r+2*s),n[2*r+2*s+1]+=o*g,m(n,2*r+2*s+1),n[2*r+2*s+1]+=u*p,m(n,2*r+2*s+1),n[2*r+2*s+2]+=o*p,m(n,2*r+2*s+2)}for(r=0;r<t;r++)n[r]=n[2*r+1]<<16|n[2*r];for(r=t;r<2*t;r++)n[r]=0;return new i(n,0)},t.A=function(e){return y(this,e).h},t.and=function(e){for(var t=Math.max(this.g.length,e.g.length),n=[],r=0;r<t;r++)n[r]=this.i(r)&e.i(r);return new i(n,this.h&e.h)},t.or=function(e){for(var t=Math.max(this.g.length,e.g.length),n=[],r=0;r<t;r++)n[r]=this.i(r)|e.i(r);return new i(n,this.h|e.h)},t.xor=function(e){for(var t=Math.max(this.g.length,e.g.length),n=[],r=0;r<t;r++)n[r]=this.i(r)^e.i(r);return new i(n,this.h^e.h)},n.prototype.digest=n.prototype.v,n.prototype.reset=n.prototype.s,n.prototype.update=n.prototype.u,e.exports.Md5=n,i.prototype.add=i.prototype.add,i.prototype.multiply=i.prototype.j,i.prototype.modulo=i.prototype.A,i.prototype.compare=i.prototype.l,i.prototype.toNumber=i.prototype.m,i.prototype.toString=i.prototype.toString,i.prototype.getBits=i.prototype.i,i.fromNumber=a,i.fromString=function e(t,n){if(0==t.length)throw Error("number format error: empty string");if(2>(n=n||10)||36<n)throw Error("radix out of range: "+n);if("-"==t.charAt(0))return f(e(t.substring(1),n));if(0<=t.indexOf("-"))throw Error('number format error: interior "-" character');for(var r=a(Math.pow(n,8)),i=c,s=0;s<t.length;s+=8){var o=Math.min(8,t.length-s),u=parseInt(t.substring(s,s+o),n);8>o?(o=a(Math.pow(n,o)),i=i.j(o).add(a(u))):i=(i=i.j(r)).add(a(u))}return i},e.exports.Integer=i}).apply(void 0!==n.g?n.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},4832:(e,t,n)=>{(function(){"use strict";var t,r="function"==typeof Object.defineProperties?Object.defineProperty:function(e,t,n){return e==Array.prototype||e==Object.prototype||(e[t]=n.value),e},i=function(e){e=["object"==typeof globalThis&&globalThis,e,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof n.g&&n.g];for(var t=0;t<e.length;++t){var r=e[t];if(r&&r.Math==Math)return r}throw Error("Cannot find global object")}(this);!function(e,t){if(t)e:{var n=i;e=e.split(".");for(var s=0;s<e.length-1;s++){var o=e[s];if(!(o in n))break e;n=n[o]}(t=t(s=n[e=e[e.length-1]]))!=s&&null!=t&&r(n,e,{configurable:!0,writable:!0,value:t})}}("Array.prototype.values",(function(e){return e||function(){return function(e,t){e instanceof String&&(e+="");var n=0,r=!1,i={next:function(){if(!r&&n<e.length){var i=n++;return{value:t(0,e[i]),done:!1}}return r=!0,{done:!0,value:void 0}}};return i[Symbol.iterator]=function(){return i},i}(this,(function(e,t){return t}))}}));var s=s||{},o=this||self;function a(e){var t=typeof e;return"array"==(t="object"!=t?t:e?Array.isArray(e)?"array":t:"null")||"object"==t&&"number"==typeof e.length}function c(e){var t=typeof e;return"object"==t&&null!=e||"function"==t}function u(e,t,n){return e.call.apply(e.bind,arguments)}function l(e,t,n){if(!e)throw Error();if(2<arguments.length){var r=Array.prototype.slice.call(arguments,2);return function(){var n=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(n,r),e.apply(t,n)}}return function(){return e.apply(t,arguments)}}function h(e,t,n){return(h=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?u:l).apply(null,arguments)}function d(e,t){var n=Array.prototype.slice.call(arguments,1);return function(){var t=n.slice();return t.push.apply(t,arguments),e.apply(this,t)}}function f(e,t){function n(){}n.prototype=t.prototype,e.aa=t.prototype,e.prototype=new n,e.prototype.constructor=e,e.Qb=function(e,n,r){for(var i=Array(arguments.length-2),s=2;s<arguments.length;s++)i[s-2]=arguments[s];return t.prototype[n].apply(e,i)}}function p(e){const t=e.length;if(0<t){const n=Array(t);for(let r=0;r<t;r++)n[r]=e[r];return n}return[]}function m(e,t){for(let t=1;t<arguments.length;t++){const n=arguments[t];if(a(n)){const t=e.length||0,r=n.length||0;e.length=t+r;for(let i=0;i<r;i++)e[t+i]=n[i]}else e.push(n)}}function g(e){return/^[\s\xa0]*$/.test(e)}function y(){var e=o.navigator;return e&&(e=e.userAgent)?e:""}function v(e){return v[" "](e),e}v[" "]=function(){};var b=!(-1==y().indexOf("Gecko")||-1!=y().toLowerCase().indexOf("webkit")&&-1==y().indexOf("Edge")||-1!=y().indexOf("Trident")||-1!=y().indexOf("MSIE")||-1!=y().indexOf("Edge"));function w(e,t,n){for(const r in e)t.call(n,e[r],r,e)}function _(e){const t={};for(const n in e)t[n]=e[n];return t}const I="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function E(e,t){let n,r;for(let t=1;t<arguments.length;t++){for(n in r=arguments[t],r)e[n]=r[n];for(let t=0;t<I.length;t++)n=I[t],Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}}function T(e){var t=1;e=e.split(":");const n=[];for(;0<t&&e.length;)n.push(e.shift()),t--;return e.length&&n.push(e.join(":")),n}function S(e){o.setTimeout((()=>{throw e}),0)}function C(){var e=O;let t=null;return e.g&&(t=e.g,e.g=e.g.next,e.g||(e.h=null),t.next=null),t}var A=new class{constructor(e,t){this.i=e,this.j=t,this.h=0,this.g=null}get(){let e;return 0<this.h?(this.h--,e=this.g,this.g=e.next,e.next=null):e=this.i(),e}}((()=>new x),(e=>e.reset()));class x{constructor(){this.next=this.g=this.h=null}set(e,t){this.h=e,this.g=t,this.next=null}reset(){this.next=this.g=this.h=null}}let k,N=!1,O=new class{constructor(){this.h=this.g=null}add(e,t){const n=A.get();n.set(e,t),this.h?this.h.next=n:this.g=n,this.h=n}},D=()=>{const e=o.Promise.resolve(void 0);k=()=>{e.then(R)}};var R=()=>{for(var e;e=C();){try{e.h.call(e.g)}catch(e){S(e)}var t=A;t.j(e),100>t.h&&(t.h++,e.next=t.g,t.g=e)}N=!1};function P(){this.s=this.s,this.C=this.C}function L(e,t){this.type=e,this.g=this.target=t,this.defaultPrevented=!1}P.prototype.s=!1,P.prototype.ma=function(){this.s||(this.s=!0,this.N())},P.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()},L.prototype.h=function(){this.defaultPrevented=!0};var M=function(){if(!o.addEventListener||!Object.defineProperty)return!1;var e=!1,t=Object.defineProperty({},"passive",{get:function(){e=!0}});try{const e=()=>{};o.addEventListener("test",e,t),o.removeEventListener("test",e,t)}catch(e){}return e}();function F(e,t){if(L.call(this,e?e.type:""),this.relatedTarget=this.g=this.target=null,this.button=this.screenY=this.screenX=this.clientY=this.clientX=0,this.key="",this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.state=null,this.pointerId=0,this.pointerType="",this.i=null,e){var n=this.type=e.type,r=e.changedTouches&&e.changedTouches.length?e.changedTouches[0]:null;if(this.target=e.target||e.srcElement,this.g=t,t=e.relatedTarget){if(b){e:{try{v(t.nodeName);var i=!0;break e}catch(e){}i=!1}i||(t=null)}}else"mouseover"==n?t=e.fromElement:"mouseout"==n&&(t=e.toElement);this.relatedTarget=t,r?(this.clientX=void 0!==r.clientX?r.clientX:r.pageX,this.clientY=void 0!==r.clientY?r.clientY:r.pageY,this.screenX=r.screenX||0,this.screenY=r.screenY||0):(this.clientX=void 0!==e.clientX?e.clientX:e.pageX,this.clientY=void 0!==e.clientY?e.clientY:e.pageY,this.screenX=e.screenX||0,this.screenY=e.screenY||0),this.button=e.button,this.key=e.key||"",this.ctrlKey=e.ctrlKey,this.altKey=e.altKey,this.shiftKey=e.shiftKey,this.metaKey=e.metaKey,this.pointerId=e.pointerId||0,this.pointerType="string"==typeof e.pointerType?e.pointerType:V[e.pointerType]||"",this.state=e.state,this.i=e,e.defaultPrevented&&F.aa.h.call(this)}}f(F,L);var V={2:"touch",3:"pen",4:"mouse"};F.prototype.h=function(){F.aa.h.call(this);var e=this.i;e.preventDefault?e.preventDefault():e.returnValue=!1};var U="closure_listenable_"+(1e6*Math.random()|0),j=0;function B(e,t,n,r,i){this.listener=e,this.proxy=null,this.src=t,this.type=n,this.capture=!!r,this.ha=i,this.key=++j,this.da=this.fa=!1}function q(e){e.da=!0,e.listener=null,e.proxy=null,e.src=null,e.ha=null}function z(e){this.src=e,this.g={},this.h=0}function G(e,t){var n=t.type;if(n in e.g){var r,i=e.g[n],s=Array.prototype.indexOf.call(i,t,void 0);(r=0<=s)&&Array.prototype.splice.call(i,s,1),r&&(q(t),0==e.g[n].length&&(delete e.g[n],e.h--))}}function K(e,t,n,r){for(var i=0;i<e.length;++i){var s=e[i];if(!s.da&&s.listener==t&&s.capture==!!n&&s.ha==r)return i}return-1}z.prototype.add=function(e,t,n,r,i){var s=e.toString();(e=this.g[s])||(e=this.g[s]=[],this.h++);var o=K(e,t,r,i);return-1<o?(t=e[o],n||(t.fa=!1)):((t=new B(t,this.src,s,!!r,i)).fa=n,e.push(t)),t};var W="closure_lm_"+(1e6*Math.random()|0),$={};function H(e,t,n,r,i){if(r&&r.once)return J(e,t,n,r,i);if(Array.isArray(t)){for(var s=0;s<t.length;s++)H(e,t[s],n,r,i);return null}return n=re(n),e&&e[U]?e.K(t,n,c(r)?!!r.capture:!!r,i):Q(e,t,n,!1,r,i)}function Q(e,t,n,r,i,s){if(!t)throw Error("Invalid event type");var o=c(i)?!!i.capture:!!i,a=te(e);if(a||(e[W]=a=new z(e)),(n=a.add(t,n,r,o,s)).proxy)return n;if(r=function(){const e=ee;return function t(n){return e.call(t.src,t.listener,n)}}(),n.proxy=r,r.src=e,r.listener=n,e.addEventListener)M||(i=o),void 0===i&&(i=!1),e.addEventListener(t.toString(),r,i);else if(e.attachEvent)e.attachEvent(Z(t.toString()),r);else{if(!e.addListener||!e.removeListener)throw Error("addEventListener and attachEvent are unavailable.");e.addListener(r)}return n}function J(e,t,n,r,i){if(Array.isArray(t)){for(var s=0;s<t.length;s++)J(e,t[s],n,r,i);return null}return n=re(n),e&&e[U]?e.L(t,n,c(r)?!!r.capture:!!r,i):Q(e,t,n,!0,r,i)}function Y(e,t,n,r,i){if(Array.isArray(t))for(var s=0;s<t.length;s++)Y(e,t[s],n,r,i);else r=c(r)?!!r.capture:!!r,n=re(n),e&&e[U]?(e=e.i,(t=String(t).toString())in e.g&&-1<(n=K(s=e.g[t],n,r,i))&&(q(s[n]),Array.prototype.splice.call(s,n,1),0==s.length&&(delete e.g[t],e.h--))):e&&(e=te(e))&&(t=e.g[t.toString()],e=-1,t&&(e=K(t,n,r,i)),(n=-1<e?t[e]:null)&&X(n))}function X(e){if("number"!=typeof e&&e&&!e.da){var t=e.src;if(t&&t[U])G(t.i,e);else{var n=e.type,r=e.proxy;t.removeEventListener?t.removeEventListener(n,r,e.capture):t.detachEvent?t.detachEvent(Z(n),r):t.addListener&&t.removeListener&&t.removeListener(r),(n=te(t))?(G(n,e),0==n.h&&(n.src=null,t[W]=null)):q(e)}}}function Z(e){return e in $?$[e]:$[e]="on"+e}function ee(e,t){if(e.da)e=!0;else{t=new F(t,this);var n=e.listener,r=e.ha||e.src;e.fa&&X(e),e=n.call(r,t)}return e}function te(e){return(e=e[W])instanceof z?e:null}var ne="__closure_events_fn_"+(1e9*Math.random()>>>0);function re(e){return"function"==typeof e?e:(e[ne]||(e[ne]=function(t){return e.handleEvent(t)}),e[ne])}function ie(){P.call(this),this.i=new z(this),this.M=this,this.F=null}function se(e,t){var n,r=e.F;if(r)for(n=[];r;r=r.F)n.push(r);if(e=e.M,r=t.type||t,"string"==typeof t)t=new L(t,e);else if(t instanceof L)t.target=t.target||e;else{var i=t;E(t=new L(r,e),i)}if(i=!0,n)for(var s=n.length-1;0<=s;s--){var o=t.g=n[s];i=oe(o,r,!0,t)&&i}if(i=oe(o=t.g=e,r,!0,t)&&i,i=oe(o,r,!1,t)&&i,n)for(s=0;s<n.length;s++)i=oe(o=t.g=n[s],r,!1,t)&&i}function oe(e,t,n,r){if(!(t=e.i.g[String(t)]))return!0;t=t.concat();for(var i=!0,s=0;s<t.length;++s){var o=t[s];if(o&&!o.da&&o.capture==n){var a=o.listener,c=o.ha||o.src;o.fa&&G(e.i,o),i=!1!==a.call(c,r)&&i}}return i&&!r.defaultPrevented}function ae(e,t,n){if("function"==typeof e)n&&(e=h(e,n));else{if(!e||"function"!=typeof e.handleEvent)throw Error("Invalid listener argument");e=h(e.handleEvent,e)}return 2147483647<Number(t)?-1:o.setTimeout(e,t||0)}function ce(e){e.g=ae((()=>{e.g=null,e.i&&(e.i=!1,ce(e))}),e.l);const t=e.h;e.h=null,e.m.apply(null,t)}f(ie,P),ie.prototype[U]=!0,ie.prototype.removeEventListener=function(e,t,n,r){Y(this,e,t,n,r)},ie.prototype.N=function(){if(ie.aa.N.call(this),this.i){var e,t=this.i;for(e in t.g){for(var n=t.g[e],r=0;r<n.length;r++)q(n[r]);delete t.g[e],t.h--}}this.F=null},ie.prototype.K=function(e,t,n,r){return this.i.add(String(e),t,!1,n,r)},ie.prototype.L=function(e,t,n,r){return this.i.add(String(e),t,!0,n,r)};class ue extends P{constructor(e,t){super(),this.m=e,this.l=t,this.h=null,this.i=!1,this.g=null}j(e){this.h=arguments,this.g?this.i=!0:ce(this)}N(){super.N(),this.g&&(o.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function le(e){P.call(this),this.h=e,this.g={}}f(le,P);var he=[];function de(e){w(e.g,(function(e,t){this.g.hasOwnProperty(t)&&X(e)}),e),e.g={}}le.prototype.N=function(){le.aa.N.call(this),de(this)},le.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var fe=o.JSON.stringify,pe=o.JSON.parse,me=class{stringify(e){return o.JSON.stringify(e,void 0)}parse(e){return o.JSON.parse(e,void 0)}};function ge(){}function ye(e){return e.h||(e.h=e.i())}function ve(){}ge.prototype.h=null;var be={OPEN:"a",kb:"b",Ja:"c",wb:"d"};function we(){L.call(this,"d")}function _e(){L.call(this,"c")}f(we,L),f(_e,L);var Ie={},Ee=null;function Te(){return Ee=Ee||new ie}function Se(e){L.call(this,Ie.La,e)}function Ce(e){const t=Te();se(t,new Se(t,e))}function Ae(e,t){L.call(this,Ie.STAT_EVENT,e),this.stat=t}function xe(e){const t=Te();se(t,new Ae(t,e))}function ke(e,t){L.call(this,Ie.Ma,e),this.size=t}function Ne(e,t){if("function"!=typeof e)throw Error("Fn must not be null and must be a function");return o.setTimeout((function(){e()}),t)}function Oe(){this.g=!0}function De(e,t,n,r){e.info((function(){return"XMLHTTP TEXT ("+t+"): "+function(e,t){if(!e.g)return t;if(!t)return null;try{var n=JSON.parse(t);if(n)for(e=0;e<n.length;e++)if(Array.isArray(n[e])){var r=n[e];if(!(2>r.length)){var i=r[1];if(Array.isArray(i)&&!(1>i.length)){var s=i[0];if("noop"!=s&&"stop"!=s&&"close"!=s)for(var o=1;o<i.length;o++)i[o]=""}}}return fe(n)}catch(e){return t}}(e,n)+(r?" "+r:"")}))}Ie.La="serverreachability",f(Se,L),Ie.STAT_EVENT="statevent",f(Ae,L),Ie.Ma="timingevent",f(ke,L),Oe.prototype.xa=function(){this.g=!1},Oe.prototype.info=function(){};var Re,Pe={NO_ERROR:0,gb:1,tb:2,sb:3,nb:4,rb:5,ub:6,Ia:7,TIMEOUT:8,xb:9},Le={lb:"complete",Hb:"success",Ja:"error",Ia:"abort",zb:"ready",Ab:"readystatechange",TIMEOUT:"timeout",vb:"incrementaldata",yb:"progress",ob:"downloadprogress",Pb:"uploadprogress"};function Me(){}function Fe(e,t,n,r){this.j=e,this.i=t,this.l=n,this.R=r||1,this.U=new le(this),this.I=45e3,this.H=null,this.o=!1,this.m=this.A=this.v=this.L=this.F=this.S=this.B=null,this.D=[],this.g=null,this.C=0,this.s=this.u=null,this.X=-1,this.J=!1,this.O=0,this.M=null,this.W=this.K=this.T=this.P=!1,this.h=new Ve}function Ve(){this.i=null,this.g="",this.h=!1}f(Me,ge),Me.prototype.g=function(){return new XMLHttpRequest},Me.prototype.i=function(){return{}},Re=new Me;var Ue={},je={};function Be(e,t,n){e.L=1,e.v=ft(ct(t)),e.m=n,e.P=!0,qe(e,null)}function qe(e,t){e.F=Date.now(),Ke(e),e.A=ct(e.v);var n=e.A,r=e.R;Array.isArray(r)||(r=[String(r)]),At(n.i,"t",r),e.C=0,n=e.j.J,e.h=new Ve,e.g=mn(e.j,n?t:null,!e.m),0<e.O&&(e.M=new ue(h(e.Y,e,e.g),e.O)),t=e.U,n=e.g,r=e.ca;var i="readystatechange";Array.isArray(i)||(i&&(he[0]=i.toString()),i=he);for(var s=0;s<i.length;s++){var o=H(n,i[s],r||t.handleEvent,!1,t.h||t);if(!o)break;t.g[o.key]=o}t=e.H?_(e.H):{},e.m?(e.u||(e.u="POST"),t["Content-Type"]="application/x-www-form-urlencoded",e.g.ea(e.A,e.u,e.m,t)):(e.u="GET",e.g.ea(e.A,e.u,null,t)),Ce(1),function(e,t,n,r,i,s){e.info((function(){if(e.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 l=u[0];u=u[1];var h=l.split("_");o=2<=h.length&&"type"==h[1]?o+(l+"=")+u+"&":o+(l+"=redacted&")}}else o=null;else o=s;return"XMLHTTP REQ ("+r+") [attempt "+i+"]: "+t+"\n"+n+"\n"+o}))}(e.i,e.u,e.A,e.l,e.R,e.m)}function ze(e){return!!e.g&&"GET"==e.u&&2!=e.L&&e.j.Ca}function Ge(e,t){var n=e.C,r=t.indexOf("\n",n);return-1==r?je:(n=Number(t.substring(n,r)),isNaN(n)?Ue:(r+=1)+n>t.length?je:(t=t.slice(r,r+n),e.C=r+n,t))}function Ke(e){e.S=Date.now()+e.I,We(e,e.I)}function We(e,t){if(null!=e.B)throw Error("WatchDog timer not null");e.B=Ne(h(e.ba,e),t)}function $e(e){e.B&&(o.clearTimeout(e.B),e.B=null)}function He(e){0==e.j.G||e.J||ln(e.j,e)}function Qe(e){$e(e);var t=e.M;t&&"function"==typeof t.ma&&t.ma(),e.M=null,de(e.U),e.g&&(t=e.g,e.g=null,t.abort(),t.ma())}function Je(e,t){try{var n=e.j;if(0!=n.G&&(n.g==e||tt(n.h,e)))if(!e.K&&tt(n.h,e)&&3==n.G){try{var r=n.Da.g.parse(t)}catch(e){r=null}if(Array.isArray(r)&&3==r.length){var i=r;if(0==i[0]){e:if(!n.u){if(n.g){if(!(n.g.F+3e3<e.F))break e;un(n),Xt(n)}on(n),xe(18)}}else n.za=i[1],0<n.za-n.T&&37500>i[2]&&n.F&&0==n.v&&!n.C&&(n.C=Ne(h(n.Za,n),6e3));if(1>=et(n.h)&&n.ca){try{n.ca()}catch(e){}n.ca=void 0}}else dn(n,11)}else if((e.K||n.g==e)&&un(n),!g(t))for(i=n.Da.g.parse(t),t=0;t<i.length;t++){let u=i[t];if(n.T=u[0],u=u[1],2==n.G)if("c"==u[0]){n.K=u[1],n.ia=u[2];const t=u[3];null!=t&&(n.la=t,n.j.info("VER="+n.la));const i=u[4];null!=i&&(n.Aa=i,n.j.info("SVER="+n.Aa));const l=u[5];null!=l&&"number"==typeof l&&0<l&&(r=1.5*l,n.L=r,n.j.info("backChannelRequestTimeoutMs_="+r)),r=n;const h=e.g;if(h){const e=h.g?h.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(e){var s=r.h;s.g||-1==e.indexOf("spdy")&&-1==e.indexOf("quic")&&-1==e.indexOf("h2")||(s.j=s.l,s.g=new Set,s.h&&(nt(s,s.h),s.h=null))}if(r.D){const e=h.g?h.g.getResponseHeader("X-HTTP-Session-Id"):null;e&&(r.ya=e,dt(r.I,r.D,e))}}n.G=3,n.l&&n.l.ua(),n.ba&&(n.R=Date.now()-e.F,n.j.info("Handshake RTT: "+n.R+"ms"));var o=e;if((r=n).qa=pn(r,r.J?r.ia:null,r.W),o.K){rt(r.h,o);var a=o,c=r.L;c&&(a.I=c),a.B&&($e(a),Ke(a)),r.g=o}else sn(r);0<n.i.length&&en(n)}else"stop"!=u[0]&&"close"!=u[0]||dn(n,7);else 3==n.G&&("stop"==u[0]||"close"==u[0]?"stop"==u[0]?dn(n,7):Yt(n):"noop"!=u[0]&&n.l&&n.l.ta(u),n.v=0)}Ce(4)}catch(e){}}Fe.prototype.ca=function(e){e=e.target;const t=this.M;t&&3==$t(e)?t.j():this.Y(e)},Fe.prototype.Y=function(e){try{if(e==this.g)e:{const d=$t(this.g);var t=this.g.Ba();const f=this.g.Z();if(!(3>d)&&(3!=d||this.g&&(this.h.h||this.g.oa()||Ht(this.g)))){this.J||4!=d||7==t||Ce(8==t||0>=f?3:2),$e(this);var n=this.g.Z();this.X=n;t:if(ze(this)){var r=Ht(this.g);e="";var i=r.length,s=4==$t(this.g);if(!this.h.i){if("undefined"==typeof TextDecoder){Qe(this),He(this);var a="";break t}this.h.i=new o.TextDecoder}for(t=0;t<i;t++)this.h.h=!0,e+=this.h.i.decode(r[t],{stream:!(s&&t==i-1)});r.length=0,this.h.g+=e,this.C=0,a=this.h.g}else a=this.g.oa();if(this.o=200==n,function(e,t,n,r,i,s,o){e.info((function(){return"XMLHTTP RESP ("+r+") [ attempt "+i+"]: "+t+"\n"+n+"\n"+s+" "+o}))}(this.i,this.u,this.A,this.l,this.R,d,n),this.o){if(this.T&&!this.K){t:{if(this.g){var c,u=this.g;if((c=u.g?u.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!g(c)){var l=c;break t}}l=null}if(!(n=l)){this.o=!1,this.s=3,xe(12),Qe(this),He(this);break e}De(this.i,this.l,n,"Initial handshake response via X-HTTP-Initial-Response"),this.K=!0,Je(this,n)}if(this.P){let e;for(n=!0;!this.J&&this.C<a.length;){if(e=Ge(this,a),e==je){4==d&&(this.s=4,xe(14),n=!1),De(this.i,this.l,null,"[Incomplete Response]");break}if(e==Ue){this.s=4,xe(15),De(this.i,this.l,a,"[Invalid Chunk]"),n=!1;break}De(this.i,this.l,e,null),Je(this,e)}if(ze(this)&&0!=this.C&&(this.h.g=this.h.g.slice(this.C),this.C=0),4!=d||0!=a.length||this.h.h||(this.s=1,xe(16),n=!1),this.o=this.o&&n,n){if(0<a.length&&!this.W){this.W=!0;var h=this.j;h.g==this&&h.ba&&!h.M&&(h.j.info("Great, no buffering proxy detected. Bytes received: "+a.length),an(h),h.M=!0,xe(11))}}else De(this.i,this.l,a,"[Invalid Chunked Response]"),Qe(this),He(this)}else De(this.i,this.l,a,null),Je(this,a);4==d&&Qe(this),this.o&&!this.J&&(4==d?ln(this.j,this):(this.o=!1,Ke(this)))}else(function(e){const t={};e=(e.g&&2<=$t(e)&&e.g.getAllResponseHeaders()||"").split("\r\n");for(let r=0;r<e.length;r++){if(g(e[r]))continue;var n=T(e[r]);const i=n[0];if("string"!=typeof(n=n[1]))continue;n=n.trim();const s=t[i]||[];t[i]=s,s.push(n)}!function(e,t){for(const n in e)t.call(void 0,e[n],n,e)}(t,(function(e){return e.join(", ")}))})(this.g),400==n&&0<a.indexOf("Unknown SID")?(this.s=3,xe(12)):(this.s=0,xe(13)),Qe(this),He(this)}}}catch(e){}},Fe.prototype.cancel=function(){this.J=!0,Qe(this)},Fe.prototype.ba=function(){this.B=null;const e=Date.now();0<=e-this.S?(function(e,t){e.info((function(){return"TIMEOUT: "+t}))}(this.i,this.A),2!=this.L&&(Ce(3),xe(17)),Qe(this),this.s=2,He(this)):We(this,this.S-e)};var Ye=class{constructor(e,t){this.g=e,this.map=t}};function Xe(e){this.l=e||10,e=o.PerformanceNavigationTiming?0<(e=o.performance.getEntriesByType("navigation")).length&&("hq"==e[0].nextHopProtocol||"h2"==e[0].nextHopProtocol):!!(o.chrome&&o.chrome.loadTimes&&o.chrome.loadTimes()&&o.chrome.loadTimes().wasFetchedViaSpdy),this.j=e?this.l:1,this.g=null,1<this.j&&(this.g=new Set),this.h=null,this.i=[]}function Ze(e){return!!e.h||!!e.g&&e.g.size>=e.j}function et(e){return e.h?1:e.g?e.g.size:0}function tt(e,t){return e.h?e.h==t:!!e.g&&e.g.has(t)}function nt(e,t){e.g?e.g.add(t):e.h=t}function rt(e,t){e.h&&e.h==t?e.h=null:e.g&&e.g.has(t)&&e.g.delete(t)}function it(e){if(null!=e.h)return e.i.concat(e.h.D);if(null!=e.g&&0!==e.g.size){let t=e.i;for(const n of e.g.values())t=t.concat(n.D);return t}return p(e.i)}function st(e,t){if(e.forEach&&"function"==typeof e.forEach)e.forEach(t,void 0);else if(a(e)||"string"==typeof e)Array.prototype.forEach.call(e,t,void 0);else for(var n=function(e){if(e.na&&"function"==typeof e.na)return e.na();if(!e.V||"function"!=typeof e.V){if("undefined"!=typeof Map&&e instanceof Map)return Array.from(e.keys());if(!("undefined"!=typeof Set&&e instanceof Set)){if(a(e)||"string"==typeof e){var t=[];e=e.length;for(var n=0;n<e;n++)t.push(n);return t}t=[],n=0;for(const r in e)t[n++]=r;return t}}}(e),r=function(e){if(e.V&&"function"==typeof e.V)return e.V();if("undefined"!=typeof Map&&e instanceof Map||"undefined"!=typeof Set&&e instanceof Set)return Array.from(e.values());if("string"==typeof e)return e.split("");if(a(e)){for(var t=[],n=e.length,r=0;r<n;r++)t.push(e[r]);return t}for(r in t=[],n=0,e)t[n++]=e[r];return t}(e),i=r.length,s=0;s<i;s++)t.call(void 0,r[s],n&&n[s],e)}Xe.prototype.cancel=function(){if(this.i=it(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&0!==this.g.size){for(const e of this.g.values())e.cancel();this.g.clear()}};var ot=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function at(e){if(this.g=this.o=this.j="",this.s=null,this.m=this.l="",this.h=!1,e instanceof at){this.h=e.h,ut(this,e.j),this.o=e.o,this.g=e.g,lt(this,e.s),this.l=e.l;var t=e.i,n=new Et;n.i=t.i,t.g&&(n.g=new Map(t.g),n.h=t.h),ht(this,n),this.m=e.m}else e&&(t=String(e).match(ot))?(this.h=!1,ut(this,t[1]||"",!0),this.o=pt(t[2]||""),this.g=pt(t[3]||"",!0),lt(this,t[4]),this.l=pt(t[5]||"",!0),ht(this,t[6]||"",!0),this.m=pt(t[7]||"")):(this.h=!1,this.i=new Et(null,this.h))}function ct(e){return new at(e)}function ut(e,t,n){e.j=n?pt(t,!0):t,e.j&&(e.j=e.j.replace(/:$/,""))}function lt(e,t){if(t){if(t=Number(t),isNaN(t)||0>t)throw Error("Bad port number "+t);e.s=t}else e.s=null}function ht(e,t,n){t instanceof Et?(e.i=t,function(e,t){t&&!e.j&&(Tt(e),e.i=null,e.g.forEach((function(e,t){var n=t.toLowerCase();t!=n&&(St(this,t),At(this,n,e))}),e)),e.j=t}(e.i,e.h)):(n||(t=mt(t,_t)),e.i=new Et(t,e.h))}function dt(e,t,n){e.i.set(t,n)}function ft(e){return dt(e,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)),e}function pt(e,t){return e?t?decodeURI(e.replace(/%25/g,"%2525")):decodeURIComponent(e):""}function mt(e,t,n){return"string"==typeof e?(e=encodeURI(e).replace(t,gt),n&&(e=e.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),e):null}function gt(e){return"%"+((e=e.charCodeAt(0))>>4&15).toString(16)+(15&e).toString(16)}at.prototype.toString=function(){var e=[],t=this.j;t&&e.push(mt(t,vt,!0),":");var n=this.g;return(n||"file"==t)&&(e.push("//"),(t=this.o)&&e.push(mt(t,vt,!0),"@"),e.push(encodeURIComponent(String(n)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),null!=(n=this.s)&&e.push(":",String(n))),(n=this.l)&&(this.g&&"/"!=n.charAt(0)&&e.push("/"),e.push(mt(n,"/"==n.charAt(0)?wt:bt,!0))),(n=this.i.toString())&&e.push("?",n),(n=this.m)&&e.push("#",mt(n,It)),e.join("")};var yt,vt=/[#\/\?@]/g,bt=/[#\?:]/g,wt=/[#\?]/g,_t=/[#\?@]/g,It=/#/g;function Et(e,t){this.h=this.g=null,this.i=e||null,this.j=!!t}function Tt(e){e.g||(e.g=new Map,e.h=0,e.i&&function(e,t){if(e){e=e.split("&");for(var n=0;n<e.length;n++){var r=e[n].indexOf("="),i=null;if(0<=r){var s=e[n].substring(0,r);i=e[n].substring(r+1)}else s=e[n];t(s,i?decodeURIComponent(i.replace(/\+/g," ")):"")}}}(e.i,(function(t,n){e.add(decodeURIComponent(t.replace(/\+/g," ")),n)})))}function St(e,t){Tt(e),t=xt(e,t),e.g.has(t)&&(e.i=null,e.h-=e.g.get(t).length,e.g.delete(t))}function Ct(e,t){return Tt(e),t=xt(e,t),e.g.has(t)}function At(e,t,n){St(e,t),0<n.length&&(e.i=null,e.g.set(xt(e,t),p(n)),e.h+=n.length)}function xt(e,t){return t=String(t),e.j&&(t=t.toLowerCase()),t}function kt(e,t,n,r,i){try{i&&(i.onload=null,i.onerror=null,i.onabort=null,i.ontimeout=null),r(n)}catch(e){}}function Nt(){this.g=new me}function Ot(e,t,n){const r=n||"";try{st(e,(function(e,n){let i=e;c(e)&&(i=fe(e)),t.push(r+n+"="+encodeURIComponent(i))}))}catch(e){throw t.push(r+"type="+encodeURIComponent("_badmap")),e}}function Dt(e){this.l=e.Ub||null,this.j=e.eb||!1}function Rt(e,t){ie.call(this),this.D=e,this.o=t,this.m=void 0,this.status=this.readyState=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.u=new Headers,this.h=null,this.B="GET",this.A="",this.g=!1,this.v=this.j=this.l=null}function Pt(e){e.j.read().then(e.Pa.bind(e)).catch(e.ga.bind(e))}function Lt(e){e.readyState=4,e.l=null,e.j=null,e.v=null,Mt(e)}function Mt(e){e.onreadystatechange&&e.onreadystatechange.call(e)}function Ft(e){let t="";return w(e,(function(e,n){t+=n,t+=":",t+=e,t+="\r\n"})),t}function Vt(e,t,n){e:{for(r in n){var r=!1;break e}r=!0}r||(n=Ft(n),"string"==typeof e?(encodeURIComponent(String(t)),null!=n&&encodeURIComponent(String(n))):dt(e,t,n))}function Ut(e){ie.call(this),this.headers=new Map,this.o=e||null,this.h=!1,this.v=this.g=null,this.D="",this.m=0,this.l="",this.j=this.B=this.u=this.A=!1,this.I=null,this.H="",this.J=!1}(t=Et.prototype).add=function(e,t){Tt(this),this.i=null,e=xt(this,e);var n=this.g.get(e);return n||this.g.set(e,n=[]),n.push(t),this.h+=1,this},t.forEach=function(e,t){Tt(this),this.g.forEach((function(n,r){n.forEach((function(n){e.call(t,n,r,this)}),this)}),this)},t.na=function(){Tt(this);const e=Array.from(this.g.values()),t=Array.from(this.g.keys()),n=[];for(let r=0;r<t.length;r++){const i=e[r];for(let e=0;e<i.length;e++)n.push(t[r])}return n},t.V=function(e){Tt(this);let t=[];if("string"==typeof e)Ct(this,e)&&(t=t.concat(this.g.get(xt(this,e))));else{e=Array.from(this.g.values());for(let n=0;n<e.length;n++)t=t.concat(e[n])}return t},t.set=function(e,t){return Tt(this),this.i=null,Ct(this,e=xt(this,e))&&(this.h-=this.g.get(e).length),this.g.set(e,[t]),this.h+=1,this},t.get=function(e,t){return e&&0<(e=this.V(e)).length?String(e[0]):t},t.toString=function(){if(this.i)return this.i;if(!this.g)return"";const e=[],t=Array.from(this.g.keys());for(var n=0;n<t.length;n++){var r=t[n];const s=encodeURIComponent(String(r)),o=this.V(r);for(r=0;r<o.length;r++){var i=s;""!==o[r]&&(i+="="+encodeURIComponent(String(o[r]))),e.push(i)}}return this.i=e.join("&")},f(Dt,ge),Dt.prototype.g=function(){return new Rt(this.l,this.j)},Dt.prototype.i=(yt={},function(){return yt}),f(Rt,ie),(t=Rt.prototype).open=function(e,t){if(0!=this.readyState)throw this.abort(),Error("Error reopening a connection");this.B=e,this.A=t,this.readyState=1,Mt(this)},t.send=function(e){if(1!=this.readyState)throw this.abort(),Error("need to call open() first. ");this.g=!0;const t={headers:this.u,method:this.B,credentials:this.m,cache:void 0};e&&(t.body=e),(this.D||o).fetch(new Request(this.A,t)).then(this.Sa.bind(this),this.ga.bind(this))},t.abort=function(){this.response=this.responseText="",this.u=new Headers,this.status=0,this.j&&this.j.cancel("Request was aborted.").catch((()=>{})),1<=this.readyState&&this.g&&4!=this.readyState&&(this.g=!1,Lt(this)),this.readyState=0},t.Sa=function(e){if(this.g&&(this.l=e,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=e.headers,this.readyState=2,Mt(this)),this.g&&(this.readyState=3,Mt(this),this.g)))if("arraybuffer"===this.responseType)e.arrayBuffer().then(this.Qa.bind(this),this.ga.bind(this));else if(void 0!==o.ReadableStream&&"body"in e){if(this.j=e.body.getReader(),this.o){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.v=new TextDecoder;Pt(this)}else e.text().then(this.Ra.bind(this),this.ga.bind(this))},t.Pa=function(e){if(this.g){if(this.o&&e.value)this.response.push(e.value);else if(!this.o){var t=e.value?e.value:new Uint8Array(0);(t=this.v.decode(t,{stream:!e.done}))&&(this.response=this.responseText+=t)}e.done?Lt(this):Mt(this),3==this.readyState&&Pt(this)}},t.Ra=function(e){this.g&&(this.response=this.responseText=e,Lt(this))},t.Qa=function(e){this.g&&(this.response=e,Lt(this))},t.ga=function(){this.g&&Lt(this)},t.setRequestHeader=function(e,t){this.u.append(e,t)},t.getResponseHeader=function(e){return this.h&&this.h.get(e.toLowerCase())||""},t.getAllResponseHeaders=function(){if(!this.h)return"";const e=[],t=this.h.entries();for(var n=t.next();!n.done;)n=n.value,e.push(n[0]+": "+n[1]),n=t.next();return e.join("\r\n")},Object.defineProperty(Rt.prototype,"withCredentials",{get:function(){return"include"===this.m},set:function(e){this.m=e?"include":"same-origin"}}),f(Ut,ie);var jt=/^https?$/i,Bt=["POST","PUT"];function qt(e,t){e.h=!1,e.g&&(e.j=!0,e.g.abort(),e.j=!1),e.l=t,e.m=5,zt(e),Kt(e)}function zt(e){e.A||(e.A=!0,se(e,"complete"),se(e,"error"))}function Gt(e){if(e.h&&void 0!==s&&(!e.v[1]||4!=$t(e)||2!=e.Z()))if(e.u&&4==$t(e))ae(e.Ea,0,e);else if(se(e,"readystatechange"),4==$t(e)){e.h=!1;try{const s=e.Z();e:switch(s){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var t=!0;break e;default:t=!1}var n;if(!(n=t)){var r;if(r=0===s){var i=String(e.D).match(ot)[1]||null;!i&&o.self&&o.self.location&&(i=o.self.location.protocol.slice(0,-1)),r=!jt.test(i?i.toLowerCase():"")}n=r}if(n)se(e,"complete"),se(e,"success");else{e.m=6;try{var a=2<$t(e)?e.g.statusText:""}catch(e){a=""}e.l=a+" ["+e.Z()+"]",zt(e)}}finally{Kt(e)}}}function Kt(e,t){if(e.g){Wt(e);const n=e.g,r=e.v[0]?()=>{}:null;e.g=null,e.v=null,t||se(e,"ready");try{n.onreadystatechange=r}catch(e){}}}function Wt(e){e.I&&(o.clearTimeout(e.I),e.I=null)}function $t(e){return e.g?e.g.readyState:0}function Ht(e){try{if(!e.g)return null;if("response"in e.g)return e.g.response;switch(e.H){case"":case"text":return e.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in e.g)return e.g.mozResponseArrayBuffer}return null}catch(e){return null}}function Qt(e,t,n){return n&&n.internalChannelParams&&n.internalChannelParams[e]||t}function Jt(e){this.Aa=0,this.i=[],this.j=new Oe,this.ia=this.qa=this.I=this.W=this.g=this.ya=this.D=this.H=this.m=this.S=this.o=null,this.Ya=this.U=0,this.Va=Qt("failFast",!1,e),this.F=this.C=this.u=this.s=this.l=null,this.X=!0,this.za=this.T=-1,this.Y=this.v=this.B=0,this.Ta=Qt("baseRetryDelayMs",5e3,e),this.cb=Qt("retryDelaySeedMs",1e4,e),this.Wa=Qt("forwardChannelMaxRetries",2,e),this.wa=Qt("forwardChannelRequestTimeoutMs",2e4,e),this.pa=e&&e.xmlHttpFactory||void 0,this.Xa=e&&e.Tb||void 0,this.Ca=e&&e.useFetchStreams||!1,this.L=void 0,this.J=e&&e.supportsCrossDomainXhr||!1,this.K="",this.h=new Xe(e&&e.concurrentRequestLimit),this.Da=new Nt,this.P=e&&e.fastHandshake||!1,this.O=e&&e.encodeInitMessageHeaders||!1,this.P&&this.O&&(this.O=!1),this.Ua=e&&e.Rb||!1,e&&e.xa&&this.j.xa(),e&&e.forceLongPolling&&(this.X=!1),this.ba=!this.P&&this.X&&e&&e.detectBufferingProxy||!1,this.ja=void 0,e&&e.longPollingTimeout&&0<e.longPollingTimeout&&(this.ja=e.longPollingTimeout),this.ca=void 0,this.R=0,this.M=!1,this.ka=this.A=null}function Yt(e){if(Zt(e),3==e.G){var t=e.U++,n=ct(e.I);if(dt(n,"SID",e.K),dt(n,"RID",t),dt(n,"TYPE","terminate"),nn(e,n),(t=new Fe(e,e.j,t)).L=2,t.v=ft(ct(n)),n=!1,o.navigator&&o.navigator.sendBeacon)try{n=o.navigator.sendBeacon(t.v.toString(),"")}catch(e){}!n&&o.Image&&((new Image).src=t.v,n=!0),n||(t.g=mn(t.j,null),t.g.ea(t.v)),t.F=Date.now(),Ke(t)}fn(e)}function Xt(e){e.g&&(an(e),e.g.cancel(),e.g=null)}function Zt(e){Xt(e),e.u&&(o.clearTimeout(e.u),e.u=null),un(e),e.h.cancel(),e.s&&("number"==typeof e.s&&o.clearTimeout(e.s),e.s=null)}function en(e){if(!Ze(e.h)&&!e.s){e.s=!0;var t=e.Ga;k||D(),N||(k(),N=!0),O.add(t,e),e.B=0}}function tn(e,t){var n;n=t?t.l:e.U++;const r=ct(e.I);dt(r,"SID",e.K),dt(r,"RID",n),dt(r,"AID",e.T),nn(e,r),e.m&&e.o&&Vt(r,e.m,e.o),n=new Fe(e,e.j,n,e.B+1),null===e.m&&(n.H=e.o),t&&(e.i=t.D.concat(e.i)),t=rn(e,n,1e3),n.I=Math.round(.5*e.wa)+Math.round(.5*e.wa*Math.random()),nt(e.h,n),Be(n,r,t)}function nn(e,t){e.H&&w(e.H,(function(e,n){dt(t,n,e)})),e.l&&st({},(function(e,n){dt(t,n,e)}))}function rn(e,t,n){n=Math.min(e.i.length,n);var r=e.l?h(e.l.Na,e.l,e):null;e:{var i=e.i;let t=-1;for(;;){const e=["count="+n];-1==t?0<n?(t=i[0].g,e.push("ofs="+t)):t=0:e.push("ofs="+t);let s=!0;for(let o=0;o<n;o++){let n=i[o].g;const a=i[o].map;if(n-=t,0>n)t=Math.max(0,i[o].g-100),s=!1;else try{Ot(a,e,"req"+n+"_")}catch(e){r&&r(a)}}if(s){r=e.join("&");break e}}}return e=e.i.splice(0,n),t.D=e,r}function sn(e){if(!e.g&&!e.u){e.Y=1;var t=e.Fa;k||D(),N||(k(),N=!0),O.add(t,e),e.v=0}}function on(e){return!(e.g||e.u||3<=e.v||(e.Y++,e.u=Ne(h(e.Fa,e),hn(e,e.v)),e.v++,0))}function an(e){null!=e.A&&(o.clearTimeout(e.A),e.A=null)}function cn(e){e.g=new Fe(e,e.j,"rpc",e.Y),null===e.m&&(e.g.H=e.o),e.g.O=0;var t=ct(e.qa);dt(t,"RID","rpc"),dt(t,"SID",e.K),dt(t,"AID",e.T),dt(t,"CI",e.F?"0":"1"),!e.F&&e.ja&&dt(t,"TO",e.ja),dt(t,"TYPE","xmlhttp"),nn(e,t),e.m&&e.o&&Vt(t,e.m,e.o),e.L&&(e.g.I=e.L);var n=e.g;e=e.ia,n.L=1,n.v=ft(ct(t)),n.m=null,n.P=!0,qe(n,e)}function un(e){null!=e.C&&(o.clearTimeout(e.C),e.C=null)}function ln(e,t){var n=null;if(e.g==t){un(e),an(e),e.g=null;var r=2}else{if(!tt(e.h,t))return;n=t.D,rt(e.h,t),r=1}if(0!=e.G)if(t.o)if(1==r){n=t.m?t.m.length:0,t=Date.now()-t.F;var i=e.B;se(r=Te(),new ke(r,n,t,i)),en(e)}else sn(e);else if(3==(i=t.s)||0==i&&0<t.X||!(1==r&&function(e,t){return!(et(e.h)>=e.h.j-(e.s?1:0)||(e.s?(e.i=t.D.concat(e.i),0):1==e.G||2==e.G||e.B>=(e.Va?0:e.Wa)||(e.s=Ne(h(e.Ga,e,t),hn(e,e.B)),e.B++,0)))}(e,t)||2==r&&on(e)))switch(n&&0<n.length&&(t=e.h,t.i=t.i.concat(n)),i){case 1:dn(e,5);break;case 4:dn(e,10);break;case 3:dn(e,6);break;default:dn(e,2)}}function hn(e,t){let n=e.Ta+Math.floor(Math.random()*e.cb);return e.isActive()||(n*=2),n*t}function dn(e,t){if(e.j.info("Error code "+t),2==t){var n=h(e.fb,e),r=e.Xa;const t=!r;r=new at(r||"//www.google.com/images/cleardot.gif"),o.location&&"http"==o.location.protocol||ut(r,"https"),ft(r),t?function(e,t){const n=new Oe;if(o.Image){const r=new Image;r.onload=d(kt,n,"TestLoadImage: loaded",!0,t,r),r.onerror=d(kt,n,"TestLoadImage: error",!1,t,r),r.onabort=d(kt,n,"TestLoadImage: abort",!1,t,r),r.ontimeout=d(kt,n,"TestLoadImage: timeout",!1,t,r),o.setTimeout((function(){r.ontimeout&&r.ontimeout()}),1e4),r.src=e}else t(!1)}(r.toString(),n):function(e,t){new Oe;const n=new AbortController,r=setTimeout((()=>{n.abort(),kt(0,0,!1,t)}),1e4);fetch(e,{signal:n.signal}).then((e=>{clearTimeout(r),e.ok?kt(0,0,!0,t):kt(0,0,!1,t)})).catch((()=>{clearTimeout(r),kt(0,0,!1,t)}))}(r.toString(),n)}else xe(2);e.G=0,e.l&&e.l.sa(t),fn(e),Zt(e)}function fn(e){if(e.G=0,e.ka=[],e.l){const t=it(e.h);0==t.length&&0==e.i.length||(m(e.ka,t),m(e.ka,e.i),e.h.i.length=0,p(e.i),e.i.length=0),e.l.ra()}}function pn(e,t,n){var r=n instanceof at?ct(n):new at(n);if(""!=r.g)t&&(r.g=t+"."+r.g),lt(r,r.s);else{var i=o.location;r=i.protocol,t=t?t+"."+i.hostname:i.hostname,i=+i.port;var s=new at(null);r&&ut(s,r),t&&(s.g=t),i&&lt(s,i),n&&(s.l=n),r=s}return n=e.D,t=e.ya,n&&t&&dt(r,n,t),dt(r,"VER",e.la),nn(e,r),r}function mn(e,t,n){if(t&&!e.J)throw Error("Can't create secondary domain capable XhrIo object.");return(t=e.Ca&&!e.pa?new Ut(new Dt({eb:n})):new Ut(e.pa)).Ha(e.J),t}function gn(){}function yn(){}function vn(e,t){ie.call(this),this.g=new Jt(t),this.l=e,this.h=t&&t.messageUrlParams||null,e=t&&t.messageHeaders||null,t&&t.clientProtocolHeaderRequired&&(e?e["X-Client-Protocol"]="webchannel":e={"X-Client-Protocol":"webchannel"}),this.g.o=e,e=t&&t.initMessageHeaders||null,t&&t.messageContentType&&(e?e["X-WebChannel-Content-Type"]=t.messageContentType:e={"X-WebChannel-Content-Type":t.messageContentType}),t&&t.va&&(e?e["X-WebChannel-Client-Profile"]=t.va:e={"X-WebChannel-Client-Profile":t.va}),this.g.S=e,(e=t&&t.Sb)&&!g(e)&&(this.g.m=e),this.v=t&&t.supportsCrossDomainXhr||!1,this.u=t&&t.sendRawJson||!1,(t=t&&t.httpSessionIdParam)&&!g(t)&&(this.g.D=t,null!==(e=this.h)&&t in e&&t in(e=this.h)&&delete e[t]),this.j=new _n(this)}function bn(e){we.call(this),e.__headers__&&(this.headers=e.__headers__,this.statusCode=e.__status__,delete e.__headers__,delete e.__status__);var t=e.__sm__;if(t){e:{for(const n in t){e=n;break e}e=void 0}(this.i=e)&&(e=this.i,t=null!==t&&e in t?t[e]:void 0),this.data=t}else this.data=e}function wn(){_e.call(this),this.status=1}function _n(e){this.g=e}(t=Ut.prototype).Ha=function(e){this.J=e},t.ea=function(e,t,n,r){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.D+"; newUri="+e);t=t?t.toUpperCase():"GET",this.D=e,this.l="",this.m=0,this.A=!1,this.h=!0,this.g=this.o?this.o.g():Re.g(),this.v=this.o?ye(this.o):ye(Re),this.g.onreadystatechange=h(this.Ea,this);try{this.B=!0,this.g.open(t,String(e),!0),this.B=!1}catch(e){return void qt(this,e)}if(e=n||"",n=new Map(this.headers),r)if(Object.getPrototypeOf(r)===Object.prototype)for(var i in r)n.set(i,r[i]);else{if("function"!=typeof r.keys||"function"!=typeof r.get)throw Error("Unknown input type for opt_headers: "+String(r));for(const e of r.keys())n.set(e,r.get(e))}r=Array.from(n.keys()).find((e=>"content-type"==e.toLowerCase())),i=o.FormData&&e instanceof o.FormData,!(0<=Array.prototype.indexOf.call(Bt,t,void 0))||r||i||n.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");for(const[e,t]of n)this.g.setRequestHeader(e,t);this.H&&(this.g.responseType=this.H),"withCredentials"in this.g&&this.g.withCredentials!==this.J&&(this.g.withCredentials=this.J);try{Wt(this),this.u=!0,this.g.send(e),this.u=!1}catch(e){qt(this,e)}},t.abort=function(e){this.g&&this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1,this.m=e||7,se(this,"complete"),se(this,"abort"),Kt(this))},t.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),Kt(this,!0)),Ut.aa.N.call(this)},t.Ea=function(){this.s||(this.B||this.u||this.j?Gt(this):this.bb())},t.bb=function(){Gt(this)},t.isActive=function(){return!!this.g},t.Z=function(){try{return 2<$t(this)?this.g.status:-1}catch(e){return-1}},t.oa=function(){try{return this.g?this.g.responseText:""}catch(e){return""}},t.Oa=function(e){if(this.g){var t=this.g.responseText;return e&&0==t.indexOf(e)&&(t=t.substring(e.length)),pe(t)}},t.Ba=function(){return this.m},t.Ka=function(){return"string"==typeof this.l?this.l:String(this.l)},(t=Jt.prototype).la=8,t.G=1,t.connect=function(e,t,n,r){xe(0),this.W=e,this.H=t||{},n&&void 0!==r&&(this.H.OSID=n,this.H.OAID=r),this.F=this.X,this.I=pn(this,null,this.W),en(this)},t.Ga=function(e){if(this.s)if(this.s=null,1==this.G){if(!e){this.U=Math.floor(1e5*Math.random()),e=this.U++;const i=new Fe(this,this.j,e);let s=this.o;if(this.S&&(s?(s=_(s),E(s,this.S)):s=this.S),null!==this.m||this.O||(i.H=s,s=null),this.P)e:{for(var t=0,n=0;n<this.i.length;n++){var r=this.i[n];if(void 0===(r="__data__"in r.map&&"string"==typeof(r=r.map.__data__)?r.length:void 0))break;if(4096<(t+=r)){t=n;break e}if(4096===t||n===this.i.length-1){t=n+1;break e}}t=1e3}else t=1e3;t=rn(this,i,t),dt(n=ct(this.I),"RID",e),dt(n,"CVER",22),this.D&&dt(n,"X-HTTP-Session-Id",this.D),nn(this,n),s&&(this.O?t="headers="+encodeURIComponent(String(Ft(s)))+"&"+t:this.m&&Vt(n,this.m,s)),nt(this.h,i),this.Ua&&dt(n,"TYPE","init"),this.P?(dt(n,"$req",t),dt(n,"SID","null"),i.T=!0,Be(i,n,null)):Be(i,n,t),this.G=2}}else 3==this.G&&(e?tn(this,e):0==this.i.length||Ze(this.h)||tn(this))},t.Fa=function(){if(this.u=null,cn(this),this.ba&&!(this.M||null==this.g||0>=this.R)){var e=2*this.R;this.j.info("BP detection timer enabled: "+e),this.A=Ne(h(this.ab,this),e)}},t.ab=function(){this.A&&(this.A=null,this.j.info("BP detection timeout reached."),this.j.info("Buffering proxy detected and switch to long-polling!"),this.F=!1,this.M=!0,xe(10),Xt(this),cn(this))},t.Za=function(){null!=this.C&&(this.C=null,Xt(this),on(this),xe(19))},t.fb=function(e){e?(this.j.info("Successfully pinged google.com"),xe(2)):(this.j.info("Failed to ping google.com"),xe(1))},t.isActive=function(){return!!this.l&&this.l.isActive(this)},(t=gn.prototype).ua=function(){},t.ta=function(){},t.sa=function(){},t.ra=function(){},t.isActive=function(){return!0},t.Na=function(){},yn.prototype.g=function(e,t){return new vn(e,t)},f(vn,ie),vn.prototype.m=function(){this.g.l=this.j,this.v&&(this.g.J=!0),this.g.connect(this.l,this.h||void 0)},vn.prototype.close=function(){Yt(this.g)},vn.prototype.o=function(e){var t=this.g;if("string"==typeof e){var n={};n.__data__=e,e=n}else this.u&&((n={}).__data__=fe(e),e=n);t.i.push(new Ye(t.Ya++,e)),3==t.G&&en(t)},vn.prototype.N=function(){this.g.l=null,delete this.j,Yt(this.g),delete this.g,vn.aa.N.call(this)},f(bn,we),f(wn,_e),f(_n,gn),_n.prototype.ua=function(){se(this.g,"a")},_n.prototype.ta=function(e){se(this.g,new bn(e))},_n.prototype.sa=function(e){se(this.g,new wn(e))},_n.prototype.ra=function(){se(this.g,"b")},yn.prototype.createWebChannel=yn.prototype.g,vn.prototype.send=vn.prototype.o,vn.prototype.open=vn.prototype.m,vn.prototype.close=vn.prototype.close,e.exports.createWebChannelTransport=function(){return new yn},e.exports.getStatEventTarget=function(){return Te()},e.exports.Event=Ie,e.exports.Stat={mb:0,pb:1,qb:2,Jb:3,Ob:4,Lb:5,Mb:6,Kb:7,Ib:8,Nb:9,PROXY:10,NOPROXY:11,Gb:12,Cb:13,Db:14,Bb:15,Eb:16,Fb:17,ib:18,hb:19,jb:20},Pe.NO_ERROR=0,Pe.TIMEOUT=8,Pe.HTTP_ERROR=6,e.exports.ErrorCode=Pe,Le.COMPLETE="complete",e.exports.EventType=Le,ve.EventType=be,be.OPEN="a",be.CLOSE="b",be.ERROR="c",be.MESSAGE="d",ie.prototype.listen=ie.prototype.K,e.exports.WebChannel=ve,e.exports.FetchXmlHttpFactory=Dt,Ut.prototype.listenOnce=Ut.prototype.L,Ut.prototype.getLastError=Ut.prototype.Ka,Ut.prototype.getLastErrorCode=Ut.prototype.Ba,Ut.prototype.getStatus=Ut.prototype.Z,Ut.prototype.getResponseJson=Ut.prototype.Oa,Ut.prototype.getResponseText=Ut.prototype.oa,Ut.prototype.send=Ut.prototype.ea,Ut.prototype.setWithCredentials=Ut.prototype.Ha,e.exports.XhrIo=Ut}).apply(void 0!==n.g?n.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},5577:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(6199);r.registerVersion("firebase","10.13.1","app"),Object.keys(r).forEach((function(e){"default"===e||t.hasOwnProperty(e)||Object.defineProperty(t,e,{enumerable:!0,get:function(){return r[e]}})}))},5052:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(9970);Object.keys(r).forEach((function(e){"default"===e||t.hasOwnProperty(e)||Object.defineProperty(t,e,{enumerable:!0,get:function(){return r[e]}})}))},9815:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(1241);Object.keys(r).forEach((function(e){"default"===e||t.hasOwnProperty(e)||Object.defineProperty(t,e,{enumerable:!0,get:function(){return r[e]}})}))},2733:function(e){e.exports=function(){"use strict";function e(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)e[r]=n[r]}return e}return function t(n,r){function i(t,i,s){if("undefined"!=typeof document){"number"==typeof(s=e({},r,s)).expires&&(s.expires=new Date(Date.now()+864e5*s.expires)),s.expires&&(s.expires=s.expires.toUTCString()),t=encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var o="";for(var a in s)s[a]&&(o+="; "+a,!0!==s[a]&&(o+="="+s[a].split(";")[0]));return document.cookie=t+"="+n.write(i,t)+o}}return Object.create({set:i,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var t=document.cookie?document.cookie.split("; "):[],r={},i=0;i<t.length;i++){var s=t[i].split("="),o=s.slice(1).join("=");try{var a=decodeURIComponent(s[0]);if(r[a]=n.read(o,a),e===a)break}catch(e){}}return e?r[e]:r}},remove:function(t,n){i(t,"",e({},n,{expires:-1}))},withAttributes:function(n){return t(this.converter,e({},this.attributes,n))},withConverter:function(n){return t(e({},this.converter,n),this.attributes)}},{attributes:{value:Object.freeze(r)},converter:{value:Object.freeze(n)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"})}()},6765:(e,t,n)=>{"use strict";function r(e){this.message=e}n.r(t),n.d(t,{InvalidTokenError:()=>o,default:()=>a}),r.prototype=new Error,r.prototype.name="InvalidCharacterError";var i="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.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=t.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(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(i(e).replace(/(.)/g,(function(e,t){var n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return i(t)}}function o(e){this.message=e}o.prototype=new Error,o.prototype.name="InvalidTokenError";const a=function(e,t){if("string"!=typeof e)throw new o("Invalid token specified");var n=!0===(t=t||{}).header?0:1;try{return JSON.parse(s(e.split(".")[n]))}catch(e){throw new o("Invalid token specified: "+e.message)}}},4046:(e,t,n)=>{"use strict";n.r(t),n.d(t,{ArgumentOutOfRangeError:()=>N.k,AsyncSubject:()=>l.h,BehaviorSubject:()=>c.t,ConnectableObservable:()=>i.G,EMPTY:()=>Q.w,EmptyError:()=>O.G,GroupedObservable:()=>s.k,NEVER:()=>he,Notification:()=>S.E,NotificationKind:()=>S.I,ObjectUnsubscribedError:()=>D.P,Observable:()=>r.c,ReplaySubject:()=>u.m,Scheduler:()=>I._,Subject:()=>a.B7,Subscriber:()=>T.v,Subscription:()=>E.y,TimeoutError:()=>P.M,UnsubscriptionError:()=>R.Z,VirtualAction:()=>_,VirtualTimeScheduler:()=>w,animationFrame:()=>b,animationFrameScheduler:()=>v,asap:()=>h.I,asapScheduler:()=>h.$,async:()=>d.b,asyncScheduler:()=>d.E,bindCallback:()=>U,bindNodeCallback:()=>q,combineLatest:()=>W.zV,concat:()=>$.x,config:()=>ke.$,defer:()=>H.v,empty:()=>Q.I,forkJoin:()=>X,from:()=>Y.H,fromEvent:()=>te,fromEventPattern:()=>re,generate:()=>ie,identity:()=>x.D,iif:()=>oe,interval:()=>ce,isObservable:()=>k,merge:()=>le.h,never:()=>de,noop:()=>A.l,observable:()=>o.s,of:()=>fe.of,onErrorResumeNext:()=>pe,pairs:()=>me,partition:()=>we,pipe:()=>C.F,queue:()=>f.g,queueScheduler:()=>f.T,race:()=>_e.O4,range:()=>Ie,scheduled:()=>xe.c,throwError:()=>Te.$,timer:()=>Se.O,using:()=>Ce,zip:()=>Ae.yU});var r=n(9664),i=n(4491),s=n(3108),o=n(3656),a=n(6988),c=n(2430),u=n(8977),l=n(1934),h=n(9081),d=n(6346),f=n(464),p=n(7272),m=n(6027),g=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.scheduler=t,r.work=n,r}return p.C6(t,e),t.prototype.requestAsyncId=function(t,n,r){return void 0===r&&(r=0),null!==r&&r>0?e.prototype.requestAsyncId.call(this,t,n,r):(t.actions.push(this),t.scheduled||(t.scheduled=requestAnimationFrame((function(){return t.flush(null)}))))},t.prototype.recycleAsyncId=function(t,n,r){if(void 0===r&&(r=0),null!==r&&r>0||null===r&&this.delay>0)return e.prototype.recycleAsyncId.call(this,t,n,r);0===t.actions.length&&(cancelAnimationFrame(n),t.scheduled=void 0)},t}(m.R),y=n(4881),v=new(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return p.C6(t,e),t.prototype.flush=function(e){this.active=!0,this.scheduled=void 0;var t,n=this.actions,r=-1,i=n.length;e=e||n.shift();do{if(t=e.execute(e.state,e.delay))break}while(++r<i&&(e=n.shift()));if(this.active=!1,t){for(;++r<i&&(e=n.shift());)e.unsubscribe();throw t}},t}(y.q))(g),b=v,w=function(e){function t(t,n){void 0===t&&(t=_),void 0===n&&(n=Number.POSITIVE_INFINITY);var r=e.call(this,t,(function(){return r.frame}))||this;return r.maxFrames=n,r.frame=0,r.index=-1,r}return p.C6(t,e),t.prototype.flush=function(){for(var e,t,n=this.actions,r=this.maxFrames;(t=n[0])&&t.delay<=r&&(n.shift(),this.frame=t.delay,!(e=t.execute(t.state,t.delay))););if(e){for(;t=n.shift();)t.unsubscribe();throw e}},t.frameTimeFactor=10,t}(y.q),_=function(e){function t(t,n,r){void 0===r&&(r=t.index+=1);var i=e.call(this,t,n)||this;return i.scheduler=t,i.work=n,i.index=r,i.active=!0,i.index=t.index=r,i}return p.C6(t,e),t.prototype.schedule=function(n,r){if(void 0===r&&(r=0),!this.id)return e.prototype.schedule.call(this,n,r);this.active=!1;var i=new t(this.scheduler,this.work);return this.add(i),i.schedule(n,r)},t.prototype.requestAsyncId=function(e,n,r){void 0===r&&(r=0),this.delay=e.frame+r;var i=e.actions;return i.push(this),i.sort(t.sortActions),!0},t.prototype.recycleAsyncId=function(e,t,n){void 0===n&&(n=0)},t.prototype._execute=function(t,n){if(!0===this.active)return e.prototype._execute.call(this,t,n)},t.sortActions=function(e,t){return e.delay===t.delay?e.index===t.index?0:e.index>t.index?1:-1:e.delay>t.delay?1:-1},t}(m.R),I=n(957),E=n(9147),T=n(2968),S=n(2281),C=n(6833),A=n(1193),x=n(1015);function k(e){return!!e&&(e instanceof r.c||"function"==typeof e.lift&&"function"==typeof e.subscribe)}var N=n(692),O=n(3700),D=n(731),R=n(9857),P=n(34),L=n(8100),M=n(1075),F=n(252),V=n(4576);function U(e,t,n){if(t){if(!(0,V.m)(t))return function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];return U(e,n).apply(void 0,r).pipe((0,L.T)((function(e){return(0,F.c)(e)?t.apply(void 0,e):t(e)})))};n=t}return function(){for(var t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];var s,o=this,a={context:o,subject:s,callbackFunc:e,scheduler:n};return new r.c((function(r){if(n){var i={args:t,subscriber:r,params:a};return n.schedule(j,0,i)}if(!s){s=new l.h;try{e.apply(o,t.concat([function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];s.next(e.length<=1?e[0]:e),s.complete()}]))}catch(e){(0,M.H)(s)?s.error(e):console.warn(e)}}return s.subscribe(r)}))}}function j(e){var t=this,n=e.args,r=e.subscriber,i=e.params,s=i.callbackFunc,o=i.context,a=i.scheduler,c=i.subject;if(!c){c=i.subject=new l.h;try{s.apply(o,n.concat([function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=e.length<=1?e[0]:e;t.add(a.schedule(B,0,{value:r,subject:c}))}]))}catch(e){c.error(e)}}this.add(c.subscribe(r))}function B(e){var t=e.value,n=e.subject;n.next(t),n.complete()}function q(e,t,n){if(t){if(!(0,V.m)(t))return function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];return q(e,n).apply(void 0,r).pipe((0,L.T)((function(e){return(0,F.c)(e)?t.apply(void 0,e):t(e)})))};n=t}return function(){for(var t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];var s={subject:void 0,args:t,callbackFunc:e,scheduler:n,context:this};return new r.c((function(r){var i=s.context,o=s.subject;if(n)return n.schedule(z,0,{params:s,subscriber:r,context:i});if(!o){o=s.subject=new l.h;try{e.apply(i,t.concat([function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e.shift();n?o.error(n):(o.next(e.length<=1?e[0]:e),o.complete())}]))}catch(e){(0,M.H)(o)?o.error(e):console.warn(e)}}return o.subscribe(r)}))}}function z(e){var t=this,n=e.params,r=e.subscriber,i=e.context,s=n.callbackFunc,o=n.args,a=n.scheduler,c=n.subject;if(!c){c=n.subject=new l.h;try{s.apply(i,o.concat([function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=e.shift();if(r)t.add(a.schedule(K,0,{err:r,subject:c}));else{var i=e.length<=1?e[0]:e;t.add(a.schedule(G,0,{value:i,subject:c}))}}]))}catch(e){this.add(a.schedule(K,0,{err:e,subject:c}))}}this.add(c.subscribe(r))}function G(e){var t=e.value,n=e.subject;n.next(t),n.complete()}function K(e){var t=e.err;e.subject.error(t)}var W=n(8890),$=n(926),H=n(560),Q=n(4833),J=n(806),Y=n(7046);function X(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(1===e.length){var n=e[0];if((0,F.c)(n))return Z(n,null);if((0,J.G)(n)&&Object.getPrototypeOf(n)===Object.prototype){var r=Object.keys(n);return Z(r.map((function(e){return n[e]})),r)}}if("function"==typeof e[e.length-1]){var i=e.pop();return Z(e=1===e.length&&(0,F.c)(e[0])?e[0]:e,null).pipe((0,L.T)((function(e){return i.apply(void 0,e)})))}return Z(e,null)}function Z(e,t){return new r.c((function(n){var r=e.length;if(0!==r)for(var i=new Array(r),s=0,o=0,a=function(a){var c=(0,Y.H)(e[a]),u=!1;n.add(c.subscribe({next:function(e){u||(u=!0,o++),i[a]=e},error:function(e){return n.error(e)},complete:function(){++s!==r&&u||(o===r&&n.next(t?t.reduce((function(e,t,n){return e[t]=i[n],e}),{}):i),n.complete())}}))},c=0;c<r;c++)a(c);else n.complete()}))}var ee=n(9029);function te(e,t,n,i){return(0,ee.T)(n)&&(i=n,n=void 0),i?te(e,t,n).pipe((0,L.T)((function(e){return(0,F.c)(e)?i.apply(void 0,e):i(e)}))):new r.c((function(r){ne(e,t,(function(e){arguments.length>1?r.next(Array.prototype.slice.call(arguments)):r.next(e)}),r,n)}))}function ne(e,t,n,r,i){var s;if(function(e){return e&&"function"==typeof e.addEventListener&&"function"==typeof e.removeEventListener}(e)){var o=e;e.addEventListener(t,n,i),s=function(){return o.removeEventListener(t,n,i)}}else if(function(e){return e&&"function"==typeof e.on&&"function"==typeof e.off}(e)){var a=e;e.on(t,n),s=function(){return a.off(t,n)}}else if(function(e){return e&&"function"==typeof e.addListener&&"function"==typeof e.removeListener}(e)){var c=e;e.addListener(t,n),s=function(){return c.removeListener(t,n)}}else{if(!e||!e.length)throw new TypeError("Invalid event target");for(var u=0,l=e.length;u<l;u++)ne(e[u],t,n,r,i)}r.add(s)}function re(e,t,n){return n?re(e,t).pipe((0,L.T)((function(e){return(0,F.c)(e)?n.apply(void 0,e):n(e)}))):new r.c((function(n){var r,i=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n.next(1===e.length?e[0]:e)};try{r=e(i)}catch(e){return void n.error(e)}if((0,ee.T)(t))return function(){return t(i,r)}}))}function ie(e,t,n,i,s){var o,a;if(1==arguments.length){var c=e;a=c.initialState,t=c.condition,n=c.iterate,o=c.resultSelector||x.D,s=c.scheduler}else void 0===i||(0,V.m)(i)?(a=e,o=x.D,s=i):(a=e,o=i);return new r.c((function(e){var r=a;if(s)return s.schedule(se,0,{subscriber:e,iterate:n,condition:t,resultSelector:o,state:r});for(;;){if(t){var i=void 0;try{i=t(r)}catch(t){return void e.error(t)}if(!i){e.complete();break}}var c=void 0;try{c=o(r)}catch(t){return void e.error(t)}if(e.next(c),e.closed)break;try{r=n(r)}catch(t){return void e.error(t)}}}))}function se(e){var t=e.subscriber,n=e.condition;if(!t.closed){if(e.needIterate)try{e.state=e.iterate(e.state)}catch(e){return void t.error(e)}else e.needIterate=!0;if(n){var r=void 0;try{r=n(e.state)}catch(e){return void t.error(e)}if(!r)return void t.complete();if(t.closed)return}var i;try{i=e.resultSelector(e.state)}catch(e){return void t.error(e)}if(!t.closed&&(t.next(i),!t.closed))return this.schedule(e)}}function oe(e,t,n){return void 0===t&&(t=Q.w),void 0===n&&(n=Q.w),(0,H.v)((function(){return e()?t:n}))}var ae=n(6290);function ce(e,t){return void 0===e&&(e=0),void 0===t&&(t=d.b),(!(0,ae.k)(e)||e<0)&&(e=0),t&&"function"==typeof t.schedule||(t=d.b),new r.c((function(n){return n.add(t.schedule(ue,e,{subscriber:n,counter:0,period:e})),n}))}function ue(e){var t=e.subscriber,n=e.counter,r=e.period;t.next(n),this.schedule({subscriber:t,counter:n+1,period:r},r)}var le=n(3767),he=new r.c(A.l);function de(){return he}var fe=n(8927);function pe(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(0===e.length)return Q.w;var n=e[0],i=e.slice(1);return 1===e.length&&(0,F.c)(n)?pe.apply(void 0,n):new r.c((function(e){var t=function(){return e.add(pe.apply(void 0,i).subscribe(e))};return(0,Y.H)(n).subscribe({next:function(t){e.next(t)},error:t,complete:t})}))}function me(e,t){return t?new r.c((function(n){var r=Object.keys(e),i=new E.y;return i.add(t.schedule(ge,0,{keys:r,index:0,subscriber:n,subscription:i,obj:e})),i})):new r.c((function(t){for(var n=Object.keys(e),r=0;r<n.length&&!t.closed;r++){var i=n[r];e.hasOwnProperty(i)&&t.next([i,e[i]])}t.complete()}))}function ge(e){var t=e.keys,n=e.index,r=e.subscriber,i=e.subscription,s=e.obj;if(!r.closed)if(n<t.length){var o=t[n];r.next([o,s[o]]),i.add(this.schedule({keys:t,index:n+1,subscriber:r,subscription:i,obj:s}))}else r.complete()}var ye=n(3428),ve=n(8777),be=n(9610);function we(e,t,n){return[(0,be.p)(t,n)(new r.c((0,ve.i)(e))),(0,be.p)((0,ye.A)(t,n))(new r.c((0,ve.i)(e)))]}var _e=n(8071);function Ie(e,t,n){return void 0===e&&(e=0),new r.c((function(r){void 0===t&&(t=e,e=0);var i=0,s=e;if(n)return n.schedule(Ee,0,{index:i,count:t,start:e,subscriber:r});for(;;){if(i++>=t){r.complete();break}if(r.next(s++),r.closed)break}}))}function Ee(e){var t=e.start,n=e.index,r=e.count,i=e.subscriber;n>=r?i.complete():(i.next(t),i.closed||(e.index=n+1,e.start=t+1,this.schedule(e)))}var Te=n(7404),Se=n(1133);function Ce(e,t){return new r.c((function(n){var r,i;try{r=e()}catch(e){return void n.error(e)}try{i=t(r)}catch(e){return void n.error(e)}var s=(i?(0,Y.H)(i):Q.w).subscribe(n);return function(){s.unsubscribe(),r&&r.unsubscribe()}}))}var Ae=n(4219),xe=n(1413),ke=n(1732)},1934:(e,t,n)=>{"use strict";n.d(t,{h:()=>o});var r=n(7272),i=n(6988),s=n(9147),o=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.value=null,t.hasNext=!1,t.hasCompleted=!1,t}return r.C6(t,e),t.prototype._subscribe=function(t){return this.hasError?(t.error(this.thrownError),s.y.EMPTY):this.hasCompleted&&this.hasNext?(t.next(this.value),t.complete(),s.y.EMPTY):e.prototype._subscribe.call(this,t)},t.prototype.next=function(e){this.hasCompleted||(this.value=e,this.hasNext=!0)},t.prototype.error=function(t){this.hasCompleted||e.prototype.error.call(this,t)},t.prototype.complete=function(){this.hasCompleted=!0,this.hasNext&&e.prototype.next.call(this,this.value),e.prototype.complete.call(this)},t}(i.B7)},2430:(e,t,n)=>{"use strict";n.d(t,{t:()=>o});var r=n(7272),i=n(6988),s=n(731),o=function(e){function t(t){var n=e.call(this)||this;return n._value=t,n}return r.C6(t,e),Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!0,configurable:!0}),t.prototype._subscribe=function(t){var n=e.prototype._subscribe.call(this,t);return n&&!n.closed&&t.next(this._value),n},t.prototype.getValue=function(){if(this.hasError)throw this.thrownError;if(this.closed)throw new s.P;return this._value},t.prototype.next=function(t){e.prototype.next.call(this,this._value=t)},t}(i.B7)},2281:(e,t,n)=>{"use strict";n.d(t,{E:()=>a,I:()=>r});var r,i=n(4833),s=n(8927),o=n(7404);r||(r={});var a=function(){function e(e,t,n){this.kind=e,this.value=t,this.error=n,this.hasValue="N"===e}return e.prototype.observe=function(e){switch(this.kind){case"N":return e.next&&e.next(this.value);case"E":return e.error&&e.error(this.error);case"C":return e.complete&&e.complete()}},e.prototype.do=function(e,t,n){switch(this.kind){case"N":return e&&e(this.value);case"E":return t&&t(this.error);case"C":return n&&n()}},e.prototype.accept=function(e,t,n){return e&&"function"==typeof e.next?this.observe(e):this.do(e,t,n)},e.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.I)()}throw new Error("unexpected notification kind value")},e.createNext=function(t){return void 0!==t?new e("N",t):e.undefinedValueNotification},e.createError=function(t){return new e("E",void 0,t)},e.createComplete=function(){return e.completeNotification},e.completeNotification=new e("C"),e.undefinedValueNotification=new e("N",void 0),e}()},9664:(e,t,n)=>{"use strict";n.d(t,{c:()=>l});var r=n(1075),i=n(2968),s=n(3089),o=n(6708),a=n(3656),c=n(6833),u=n(1732),l=function(){function e(e){this._isScalar=!1,e&&(this._subscribe=e)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(e,t,n){var r=this.operator,a=function(e,t,n){if(e){if(e instanceof i.v)return e;if(e[s.D])return e[s.D]()}return e||t||n?new i.v(e,t,n):new i.v(o.I)}(e,t,n);if(r?a.add(r.call(a,this.source)):a.add(this.source||u.$.useDeprecatedSynchronousErrorHandling&&!a.syncErrorThrowable?this._subscribe(a):this._trySubscribe(a)),u.$.useDeprecatedSynchronousErrorHandling&&a.syncErrorThrowable&&(a.syncErrorThrowable=!1,a.syncErrorThrown))throw a.syncErrorValue;return a},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){u.$.useDeprecatedSynchronousErrorHandling&&(e.syncErrorThrown=!0,e.syncErrorValue=t),(0,r.H)(e)?e.error(t):console.warn(t)}},e.prototype.forEach=function(e,t){var n=this;return new(t=h(t))((function(t,r){var i;i=n.subscribe((function(t){try{e(t)}catch(e){r(e),i&&i.unsubscribe()}}),r,t)}))},e.prototype._subscribe=function(e){var t=this.source;return t&&t.subscribe(e)},e.prototype[a.s]=function(){return this},e.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return 0===e.length?this:(0,c.m)(e)(this)},e.prototype.toPromise=function(e){var t=this;return new(e=h(e))((function(e,n){var r;t.subscribe((function(e){return r=e}),(function(e){return n(e)}),(function(){return e(r)}))}))},e.create=function(t){return new e(t)},e}();function h(e){if(e||(e=u.$.Promise||Promise),!e)throw new Error("no Promise impl found");return e}},6708:(e,t,n)=>{"use strict";n.d(t,{I:()=>s});var r=n(1732),i=n(9199),s={closed:!0,next:function(e){},error:function(e){if(r.$.useDeprecatedSynchronousErrorHandling)throw e;(0,i.T)(e)},complete:function(){}}},7069:(e,t,n)=>{"use strict";n.d(t,{E:()=>i});var r=n(7272),i=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r.C6(t,e),t.prototype.notifyNext=function(e,t,n,r,i){this.destination.next(t)},t.prototype.notifyError=function(e,t){this.destination.error(e)},t.prototype.notifyComplete=function(e){this.destination.complete()},t}(n(2968).v)},8977:(e,t,n)=>{"use strict";n.d(t,{m:()=>l});var r=n(7272),i=n(6988),s=n(464),o=n(9147),a=n(3947),c=n(731),u=n(293),l=function(e){function t(t,n,r){void 0===t&&(t=Number.POSITIVE_INFINITY),void 0===n&&(n=Number.POSITIVE_INFINITY);var i=e.call(this)||this;return i.scheduler=r,i._events=[],i._infiniteTimeWindow=!1,i._bufferSize=t<1?1:t,i._windowTime=n<1?1:n,n===Number.POSITIVE_INFINITY?(i._infiniteTimeWindow=!0,i.next=i.nextInfiniteTimeWindow):i.next=i.nextTimeWindow,i}return r.C6(t,e),t.prototype.nextInfiniteTimeWindow=function(t){if(!this.isStopped){var n=this._events;n.push(t),n.length>this._bufferSize&&n.shift()}e.prototype.next.call(this,t)},t.prototype.nextTimeWindow=function(t){this.isStopped||(this._events.push(new h(this._getNow(),t)),this._trimBufferThenGetEvents()),e.prototype.next.call(this,t)},t.prototype._subscribe=function(e){var t,n=this._infiniteTimeWindow,r=n?this._events:this._trimBufferThenGetEvents(),i=this.scheduler,s=r.length;if(this.closed)throw new c.P;if(this.isStopped||this.hasError?t=o.y.EMPTY:(this.observers.push(e),t=new u.Y(this,e)),i&&e.add(e=new a.YZ(e,i)),n)for(var l=0;l<s&&!e.closed;l++)e.next(r[l]);else for(l=0;l<s&&!e.closed;l++)e.next(r[l].value);return this.hasError?e.error(this.thrownError):this.isStopped&&e.complete(),t},t.prototype._getNow=function(){return(this.scheduler||s.g).now()},t.prototype._trimBufferThenGetEvents=function(){for(var e=this._getNow(),t=this._bufferSize,n=this._windowTime,r=this._events,i=r.length,s=0;s<i&&!(e-r[s].time<n);)s++;return i>t&&(s=Math.max(s,i-t)),s>0&&r.splice(0,s),r},t}(i.B7),h=function(){return function(e,t){this.time=e,this.value=t}}()},957:(e,t,n)=>{"use strict";n.d(t,{_:()=>r});var r=function(){function e(t,n){void 0===n&&(n=e.now),this.SchedulerAction=t,this.now=n}return e.prototype.schedule=function(e,t,n){return void 0===t&&(t=0),new this.SchedulerAction(this,e).schedule(n,t)},e.now=function(){return Date.now()},e}()},6988:(e,t,n)=>{"use strict";n.d(t,{B7:()=>h,PJ:()=>l});var r=n(7272),i=n(9664),s=n(2968),o=n(9147),a=n(731),c=n(293),u=n(3089),l=function(e){function t(t){var n=e.call(this,t)||this;return n.destination=t,n}return r.C6(t,e),t}(s.v),h=function(e){function t(){var t=e.call(this)||this;return t.observers=[],t.closed=!1,t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return r.C6(t,e),t.prototype[u.D]=function(){return new l(this)},t.prototype.lift=function(e){var t=new d(this,this);return t.operator=e,t},t.prototype.next=function(e){if(this.closed)throw new a.P;if(!this.isStopped)for(var t=this.observers,n=t.length,r=t.slice(),i=0;i<n;i++)r[i].next(e)},t.prototype.error=function(e){if(this.closed)throw new a.P;this.hasError=!0,this.thrownError=e,this.isStopped=!0;for(var t=this.observers,n=t.length,r=t.slice(),i=0;i<n;i++)r[i].error(e);this.observers.length=0},t.prototype.complete=function(){if(this.closed)throw new a.P;this.isStopped=!0;for(var e=this.observers,t=e.length,n=e.slice(),r=0;r<t;r++)n[r].complete();this.observers.length=0},t.prototype.unsubscribe=function(){this.isStopped=!0,this.closed=!0,this.observers=null},t.prototype._trySubscribe=function(t){if(this.closed)throw new a.P;return e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){if(this.closed)throw new a.P;return this.hasError?(e.error(this.thrownError),o.y.EMPTY):this.isStopped?(e.complete(),o.y.EMPTY):(this.observers.push(e),new c.Y(this,e))},t.prototype.asObservable=function(){var e=new i.c;return e.source=this,e},t.create=function(e,t){return new d(e,t)},t}(i.c),d=function(e){function t(t,n){var r=e.call(this)||this;return r.destination=t,r.source=n,r}return r.C6(t,e),t.prototype.next=function(e){var t=this.destination;t&&t.next&&t.next(e)},t.prototype.error=function(e){var t=this.destination;t&&t.error&&this.destination.error(e)},t.prototype.complete=function(){var e=this.destination;e&&e.complete&&this.destination.complete()},t.prototype._subscribe=function(e){return this.source?this.source.subscribe(e):o.y.EMPTY},t}(h)},293:(e,t,n)=>{"use strict";n.d(t,{Y:()=>i});var r=n(7272),i=function(e){function t(t,n){var r=e.call(this)||this;return r.subject=t,r.subscriber=n,r.closed=!1,r}return r.C6(t,e),t.prototype.unsubscribe=function(){if(!this.closed){this.closed=!0;var e=this.subject,t=e.observers;if(this.subject=null,t&&0!==t.length&&!e.isStopped&&!e.closed){var n=t.indexOf(this.subscriber);-1!==n&&t.splice(n,1)}}},t}(n(9147).y)},2968:(e,t,n)=>{"use strict";n.d(t,{v:()=>l});var r=n(7272),i=n(9029),s=n(6708),o=n(9147),a=n(3089),c=n(1732),u=n(9199),l=function(e){function t(n,r,i){var o=e.call(this)||this;switch(o.syncErrorValue=null,o.syncErrorThrown=!1,o.syncErrorThrowable=!1,o.isStopped=!1,arguments.length){case 0:o.destination=s.I;break;case 1:if(!n){o.destination=s.I;break}if("object"==typeof n){n instanceof t?(o.syncErrorThrowable=n.syncErrorThrowable,o.destination=n,n.add(o)):(o.syncErrorThrowable=!0,o.destination=new h(o,n));break}default:o.syncErrorThrowable=!0,o.destination=new h(o,n,r,i)}return o}return r.C6(t,e),t.prototype[a.D]=function(){return this},t.create=function(e,n,r){var i=new t(e,n,r);return i.syncErrorThrowable=!1,i},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this))},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){this.destination.error(e),this.unsubscribe()},t.prototype._complete=function(){this.destination.complete(),this.unsubscribe()},t.prototype._unsubscribeAndRecycle=function(){var e=this._parentOrParents;return this._parentOrParents=null,this.unsubscribe(),this.closed=!1,this.isStopped=!1,this._parentOrParents=e,this},t}(o.y),h=function(e){function t(t,n,r,o){var a,c=e.call(this)||this;c._parentSubscriber=t;var u=c;return(0,i.T)(n)?a=n:n&&(a=n.next,r=n.error,o=n.complete,n!==s.I&&(u=Object.create(n),(0,i.T)(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.C6(t,e),t.prototype.next=function(e){if(!this.isStopped&&this._next){var t=this._parentSubscriber;c.$.useDeprecatedSynchronousErrorHandling&&t.syncErrorThrowable?this.__tryOrSetError(t,this._next,e)&&this.unsubscribe():this.__tryOrUnsub(this._next,e)}},t.prototype.error=function(e){if(!this.isStopped){var t=this._parentSubscriber,n=c.$.useDeprecatedSynchronousErrorHandling;if(this._error)n&&t.syncErrorThrowable?(this.__tryOrSetError(t,this._error,e),this.unsubscribe()):(this.__tryOrUnsub(this._error,e),this.unsubscribe());else if(t.syncErrorThrowable)n?(t.syncErrorValue=e,t.syncErrorThrown=!0):(0,u.T)(e),this.unsubscribe();else{if(this.unsubscribe(),n)throw e;(0,u.T)(e)}}},t.prototype.complete=function(){var e=this;if(!this.isStopped){var t=this._parentSubscriber;if(this._complete){var n=function(){return e._complete.call(e._context)};c.$.useDeprecatedSynchronousErrorHandling&&t.syncErrorThrowable?(this.__tryOrSetError(t,n),this.unsubscribe()):(this.__tryOrUnsub(n),this.unsubscribe())}else this.unsubscribe()}},t.prototype.__tryOrUnsub=function(e,t){try{e.call(this._context,t)}catch(e){if(this.unsubscribe(),c.$.useDeprecatedSynchronousErrorHandling)throw e;(0,u.T)(e)}},t.prototype.__tryOrSetError=function(e,t,n){if(!c.$.useDeprecatedSynchronousErrorHandling)throw new Error("bad call");try{t.call(this._context,n)}catch(t){return c.$.useDeprecatedSynchronousErrorHandling?(e.syncErrorValue=t,e.syncErrorThrown=!0,!0):((0,u.T)(t),!0)}return!1},t.prototype._unsubscribe=function(){var e=this._parentSubscriber;this._context=null,this._parentSubscriber=null,e.unsubscribe()},t}(l)},9147:(e,t,n)=>{"use strict";n.d(t,{y:()=>a});var r=n(252),i=n(806),s=n(9029),o=n(9857),a=function(){function e(e){this.closed=!1,this._parentOrParents=null,this._subscriptions=null,e&&(this._ctorUnsubscribe=!0,this._unsubscribe=e)}var t;return e.prototype.unsubscribe=function(){var t;if(!this.closed){var n=this,a=n._parentOrParents,u=n._ctorUnsubscribe,l=n._unsubscribe,h=n._subscriptions;if(this.closed=!0,this._parentOrParents=null,this._subscriptions=null,a instanceof e)a.remove(this);else if(null!==a)for(var d=0;d<a.length;++d)a[d].remove(this);if((0,s.T)(l)){u&&(this._unsubscribe=void 0);try{l.call(this)}catch(e){t=e instanceof o.Z?c(e.errors):[e]}}if((0,r.c)(h)){d=-1;for(var f=h.length;++d<f;){var p=h[d];if((0,i.G)(p))try{p.unsubscribe()}catch(e){t=t||[],e instanceof o.Z?t=t.concat(c(e.errors)):t.push(e)}}}if(t)throw new o.Z(t)}},e.prototype.add=function(t){var n=t;if(!t)return e.EMPTY;switch(typeof t){case"function":n=new e(t);case"object":if(n===this||n.closed||"function"!=typeof n.unsubscribe)return n;if(this.closed)return n.unsubscribe(),n;if(!(n instanceof e)){var r=n;(n=new e)._subscriptions=[r]}break;default:throw new Error("unrecognized teardown "+t+" added to Subscription.")}var i=n._parentOrParents;if(null===i)n._parentOrParents=this;else if(i instanceof e){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},e.prototype.remove=function(e){var t=this._subscriptions;if(t){var n=t.indexOf(e);-1!==n&&t.splice(n,1)}},e.EMPTY=((t=new e).closed=!0,t),e}();function c(e){return e.reduce((function(e,t){return e.concat(t instanceof o.Z?t.errors:t)}),[])}},1732:(e,t,n)=>{"use strict";n.d(t,{$:()=>i});var r=!1,i={Promise:void 0,set useDeprecatedSynchronousErrorHandling(e){e&&(new Error).stack,r=e},get useDeprecatedSynchronousErrorHandling(){return r}}},298:(e,t,n)=>{"use strict";n.d(t,{gn:()=>c,tS:()=>u,zA:()=>a});var r=n(7272),i=n(2968),s=n(9664),o=n(8777),a=function(e){function t(t){var n=e.call(this)||this;return n.parent=t,n}return r.C6(t,e),t.prototype._next=function(e){this.parent.notifyNext(e)},t.prototype._error=function(e){this.parent.notifyError(e),this.unsubscribe()},t.prototype._complete=function(){this.parent.notifyComplete(),this.unsubscribe()},t}(i.v),c=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r.C6(t,e),t.prototype.notifyNext=function(e){this.destination.next(e)},t.prototype.notifyError=function(e){this.destination.error(e)},t.prototype.notifyComplete=function(){this.destination.complete()},t}(i.v);function u(e,t){if(!t.closed)return e instanceof s.c?e.subscribe(t):(0,o.i)(e)(t)}},4491:(e,t,n)=>{"use strict";n.d(t,{G:()=>c,f:()=>u});var r=n(7272),i=n(6988),s=n(9664),o=n(9147),a=n(1764),c=function(e){function t(t,n){var r=e.call(this)||this;return r.source=t,r.subjectFactory=n,r._refCount=0,r._isComplete=!1,r}return r.C6(t,e),t.prototype._subscribe=function(e){return this.getSubject().subscribe(e)},t.prototype.getSubject=function(){var e=this._subject;return e&&!e.isStopped||(this._subject=this.subjectFactory()),this._subject},t.prototype.connect=function(){var e=this._connection;return e||(this._isComplete=!1,(e=this._connection=new o.y).add(this.source.subscribe(new l(this.getSubject(),this))),e.closed&&(this._connection=null,e=o.y.EMPTY)),e},t.prototype.refCount=function(){return(0,a.B)()(this)},t}(s.c),u=function(){var e=c.prototype;return{operator:{value:null},_refCount:{value:0,writable:!0},_subject:{value:null,writable:!0},_connection:{value:null,writable:!0},_subscribe:{value:e._subscribe},_isComplete:{value:e._isComplete,writable:!0},getSubject:{value:e.getSubject},connect:{value:e.connect},refCount:{value:e.refCount}}}(),l=function(e){function t(t,n){var r=e.call(this,t)||this;return r.connectable=n,r}return r.C6(t,e),t.prototype._error=function(t){this._unsubscribe(),e.prototype._error.call(this,t)},t.prototype._complete=function(){this.connectable._isComplete=!0,this._unsubscribe(),e.prototype._complete.call(this)},t.prototype._unsubscribe=function(){var e=this.connectable;if(e){this.connectable=null;var t=e._connection;e._refCount=0,e._subject=null,e._connection=null,t&&t.unsubscribe()}},t}(i.PJ)},8890:(e,t,n)=>{"use strict";n.d(t,{ZS:()=>h,zV:()=>l});var r=n(7272),i=n(4576),s=n(252),o=n(7069),a=n(538),c=n(4601),u={};function l(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=void 0,r=void 0;return(0,i.m)(e[e.length-1])&&(r=e.pop()),"function"==typeof e[e.length-1]&&(n=e.pop()),1===e.length&&(0,s.c)(e[0])&&(e=e[0]),(0,c.c)(e,r).lift(new h(n))}var h=function(){function e(e){this.resultSelector=e}return e.prototype.call=function(e,t){return t.subscribe(new d(e,this.resultSelector))},e}(),d=function(e){function t(t,n){var r=e.call(this,t)||this;return r.resultSelector=n,r.active=0,r.values=[],r.observables=[],r}return r.C6(t,e),t.prototype._next=function(e){this.values.push(u),this.observables.push(e)},t.prototype._complete=function(){var e=this.observables,t=e.length;if(0===t)this.destination.complete();else{this.active=t,this.toRespond=t;for(var n=0;n<t;n++){var r=e[n];this.add((0,a.F)(this,r,void 0,n))}}},t.prototype.notifyComplete=function(e){0==(this.active-=1)&&this.destination.complete()},t.prototype.notifyNext=function(e,t,n){var r=this.values,i=r[n],s=this.toRespond?i===u?--this.toRespond:this.toRespond:0;r[n]=t,0===s&&(this.resultSelector?this._tryResultSelector(r):this.destination.next(r.slice()))},t.prototype._tryResultSelector=function(e){var t;try{t=this.resultSelector.apply(this,e)}catch(e){return void this.destination.error(e)}this.destination.next(t)},t}(o.E)},926:(e,t,n)=>{"use strict";n.d(t,{x:()=>s});var r=n(8927),i=n(7125);function s(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return(0,i.K)()(r.of.apply(void 0,e))}},560:(e,t,n)=>{"use strict";n.d(t,{v:()=>o});var r=n(9664),i=n(7046),s=n(4833);function o(e){return new r.c((function(t){var n;try{n=e()}catch(e){return void t.error(e)}return(n?(0,i.H)(n):(0,s.I)()).subscribe(t)}))}},4833:(e,t,n)=>{"use strict";n.d(t,{I:()=>s,w:()=>i});var r=n(9664),i=new r.c((function(e){return e.complete()}));function s(e){return e?function(e){return new r.c((function(t){return e.schedule((function(){return t.complete()}))}))}(e):i}},7046:(e,t,n)=>{"use strict";n.d(t,{H:()=>o});var r=n(9664),i=n(8777),s=n(1413);function o(e,t){return t?(0,s.c)(e,t):e instanceof r.c?e:new r.c((0,i.i)(e))}},4601:(e,t,n)=>{"use strict";n.d(t,{c:()=>o});var r=n(9664),i=n(6239),s=n(5890);function o(e,t){return t?(0,s.V)(e,t):new r.c((0,i.v)(e))}},3767:(e,t,n)=>{"use strict";n.d(t,{h:()=>a});var r=n(9664),i=n(4576),s=n(6723),o=n(4601);function a(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Number.POSITIVE_INFINITY,a=null,c=e[e.length-1];return(0,i.m)(c)?(a=e.pop(),e.length>1&&"number"==typeof e[e.length-1]&&(n=e.pop())):"number"==typeof c&&(n=e.pop()),null===a&&1===e.length&&e[0]instanceof r.c?e[0]:(0,s.U)(n)((0,o.c)(e,a))}},8927:(e,t,n)=>{"use strict";n.d(t,{of:()=>o});var r=n(4576),i=n(4601),s=n(5890);function o(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e[e.length-1];return(0,r.m)(n)?(e.pop(),(0,s.V)(e,n)):(0,i.c)(e)}},8071:(e,t,n)=>{"use strict";n.d(t,{O4:()=>c});var r=n(7272),i=n(252),s=n(4601),o=n(7069),a=n(538);function c(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(1===e.length){if(!(0,i.c)(e[0]))return e[0];e=e[0]}return(0,s.c)(e,void 0).lift(new u)}var u=function(){function e(){}return e.prototype.call=function(e,t){return t.subscribe(new l(e))},e}(),l=function(e){function t(t){var n=e.call(this,t)||this;return n.hasFirst=!1,n.observables=[],n.subscriptions=[],n}return r.C6(t,e),t.prototype._next=function(e){this.observables.push(e)},t.prototype._complete=function(){var e=this.observables,t=e.length;if(0===t)this.destination.complete();else{for(var n=0;n<t&&!this.hasFirst;n++){var r=e[n],i=(0,a.F)(this,r,void 0,n);this.subscriptions&&this.subscriptions.push(i),this.add(i)}this.observables=null}},t.prototype.notifyNext=function(e,t,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(t)},t}(o.E)},7404:(e,t,n)=>{"use strict";n.d(t,{$:()=>i});var r=n(9664);function i(e,t){return t?new r.c((function(n){return t.schedule(s,0,{error:e,subscriber:n})})):new r.c((function(t){return t.error(e)}))}function s(e){var t=e.error;e.subscriber.error(t)}},1133:(e,t,n)=>{"use strict";n.d(t,{O:()=>a});var r=n(9664),i=n(6346),s=n(6290),o=n(4576);function a(e,t,n){void 0===e&&(e=0);var a=-1;return(0,s.k)(t)?a=Number(t)<1?1:Number(t):(0,o.m)(t)&&(n=t),(0,o.m)(n)||(n=i.b),new r.c((function(t){var r=(0,s.k)(e)?e:+e-n.now();return n.schedule(c,r,{index:0,period:a,subscriber:t})}))}function c(e){var t=e.index,n=e.period,r=e.subscriber;if(r.next(t),!r.closed){if(-1===n)return r.complete();e.index=t+1,this.schedule(e,n)}}},4219:(e,t,n)=>{"use strict";n.d(t,{ee:()=>l,yU:()=>u});var r=n(7272),i=n(4601),s=n(252),o=n(2968),a=n(3991),c=n(298);function u(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e[e.length-1];return"function"==typeof n&&e.pop(),(0,i.c)(e,void 0).lift(new l(n))}var l=function(){function e(e){this.resultSelector=e}return e.prototype.call=function(e,t){return t.subscribe(new h(e,this.resultSelector))},e}(),h=function(e){function t(t,n,r){void 0===r&&(r=Object.create(null));var i=e.call(this,t)||this;return i.resultSelector=n,i.iterators=[],i.active=0,i.resultSelector="function"==typeof n?n:void 0,i}return r.C6(t,e),t.prototype._next=function(e){var t=this.iterators;(0,s.c)(e)?t.push(new f(e)):"function"==typeof e[a.lJ]?t.push(new d(e[a.lJ]())):t.push(new p(this.destination,this,e))},t.prototype._complete=function(){var e=this.iterators,t=e.length;if(this.unsubscribe(),0!==t){this.active=t;for(var n=0;n<t;n++){var r=e[n];r.stillUnsubscribed?this.destination.add(r.subscribe()):this.active--}}else this.destination.complete()},t.prototype.notifyInactive=function(){this.active--,0===this.active&&this.destination.complete()},t.prototype.checkIterators=function(){for(var e=this.iterators,t=e.length,n=this.destination,r=0;r<t;r++)if("function"==typeof(o=e[r]).hasValue&&!o.hasValue())return;var i=!1,s=[];for(r=0;r<t;r++){var o,a=(o=e[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()},t.prototype._tryresultSelector=function(e){var t;try{t=this.resultSelector.apply(this,e)}catch(e){return void this.destination.error(e)}this.destination.next(t)},t}(o.v),d=function(){function e(e){this.iterator=e,this.nextResult=e.next()}return e.prototype.hasValue=function(){return!0},e.prototype.next=function(){var e=this.nextResult;return this.nextResult=this.iterator.next(),e},e.prototype.hasCompleted=function(){var e=this.nextResult;return Boolean(e&&e.done)},e}(),f=function(){function e(e){this.array=e,this.index=0,this.length=0,this.length=e.length}return e.prototype[a.lJ]=function(){return this},e.prototype.next=function(e){var t=this.index++,n=this.array;return t<this.length?{value:n[t],done:!1}:{value:null,done:!0}},e.prototype.hasValue=function(){return this.array.length>this.index},e.prototype.hasCompleted=function(){return this.array.length===this.index},e}(),p=function(e){function t(t,n,r){var i=e.call(this,t)||this;return i.parent=n,i.observable=r,i.stillUnsubscribed=!0,i.buffer=[],i.isComplete=!1,i}return r.C6(t,e),t.prototype[a.lJ]=function(){return this},t.prototype.next=function(){var e=this.buffer;return 0===e.length&&this.isComplete?{value:null,done:!0}:{value:e.shift(),done:!1}},t.prototype.hasValue=function(){return this.buffer.length>0},t.prototype.hasCompleted=function(){return 0===this.buffer.length&&this.isComplete},t.prototype.notifyComplete=function(){this.buffer.length>0?(this.isComplete=!0,this.parent.notifyInactive()):this.destination.complete()},t.prototype.notifyNext=function(e){this.buffer.push(e),this.parent.checkIterators()},t.prototype.subscribe=function(){return(0,c.tS)(this.observable,new c.zA(this))},t}(c.gn)},7125:(e,t,n)=>{"use strict";n.d(t,{K:()=>i});var r=n(6723);function i(){return(0,r.U)(1)}},9610:(e,t,n)=>{"use strict";n.d(t,{p:()=>s});var r=n(7272),i=n(2968);function s(e,t){return function(n){return n.lift(new o(e,t))}}var o=function(){function e(e,t){this.predicate=e,this.thisArg=t}return e.prototype.call=function(e,t){return t.subscribe(new a(e,this.predicate,this.thisArg))},e}(),a=function(e){function t(t,n,r){var i=e.call(this,t)||this;return i.predicate=n,i.thisArg=r,i.count=0,i}return r.C6(t,e),t.prototype._next=function(e){var t;try{t=this.predicate.call(this.thisArg,e,this.count++)}catch(e){return void this.destination.error(e)}t&&this.destination.next(e)},t}(i.v)},3108:(e,t,n)=>{"use strict";n.d(t,{$:()=>c,k:()=>d});var r=n(7272),i=n(2968),s=n(9147),o=n(9664),a=n(6988);function c(e,t,n,r){return function(i){return i.lift(new u(e,t,n,r))}}var u=function(){function e(e,t,n,r){this.keySelector=e,this.elementSelector=t,this.durationSelector=n,this.subjectSelector=r}return e.prototype.call=function(e,t){return t.subscribe(new l(e,this.keySelector,this.elementSelector,this.durationSelector,this.subjectSelector))},e}(),l=function(e){function t(t,n,r,i,s){var o=e.call(this,t)||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.C6(t,e),t.prototype._next=function(e){var t;try{t=this.keySelector(e)}catch(e){return void this.error(e)}this._group(e,t)},t.prototype._group=function(e,t){var n=this.groups;n||(n=this.groups=new Map);var r,i=n.get(t);if(this.elementSelector)try{r=this.elementSelector(e)}catch(e){this.error(e)}else r=e;if(!i){i=this.subjectSelector?this.subjectSelector():new a.B7,n.set(t,i);var s=new d(t,i,this);if(this.destination.next(s),this.durationSelector){var o=void 0;try{o=this.durationSelector(new d(t,i))}catch(e){return void this.error(e)}this.add(o.subscribe(new h(t,i,this)))}}i.closed||i.next(r)},t.prototype._error=function(e){var t=this.groups;t&&(t.forEach((function(t,n){t.error(e)})),t.clear()),this.destination.error(e)},t.prototype._complete=function(){var e=this.groups;e&&(e.forEach((function(e,t){e.complete()})),e.clear()),this.destination.complete()},t.prototype.removeGroup=function(e){this.groups.delete(e)},t.prototype.unsubscribe=function(){this.closed||(this.attemptedToUnsubscribe=!0,0===this.count&&e.prototype.unsubscribe.call(this))},t}(i.v),h=function(e){function t(t,n,r){var i=e.call(this,n)||this;return i.key=t,i.group=n,i.parent=r,i}return r.C6(t,e),t.prototype._next=function(e){this.complete()},t.prototype._unsubscribe=function(){var e=this.parent,t=this.key;this.key=this.parent=null,e&&e.removeGroup(t)},t}(i.v),d=function(e){function t(t,n,r){var i=e.call(this)||this;return i.key=t,i.groupSubject=n,i.refCountSubscription=r,i}return r.C6(t,e),t.prototype._subscribe=function(e){var t=new s.y,n=this.refCountSubscription,r=this.groupSubject;return n&&!n.closed&&t.add(new f(n)),t.add(r.subscribe(e)),t},t}(o.c),f=function(e){function t(t){var n=e.call(this)||this;return n.parent=t,t.count++,n}return r.C6(t,e),t.prototype.unsubscribe=function(){var t=this.parent;t.closed||this.closed||(e.prototype.unsubscribe.call(this),t.count-=1,0===t.count&&t.attemptedToUnsubscribe&&t.unsubscribe())},t}(s.y)},8100:(e,t,n)=>{"use strict";n.d(t,{T:()=>s});var r=n(7272),i=n(2968);function s(e,t){return function(n){if("function"!=typeof e)throw new TypeError("argument is not a function. Are you looking for `mapTo()`?");return n.lift(new o(e,t))}}var o=function(){function e(e,t){this.project=e,this.thisArg=t}return e.prototype.call=function(e,t){return t.subscribe(new a(e,this.project,this.thisArg))},e}(),a=function(e){function t(t,n,r){var i=e.call(this,t)||this;return i.project=n,i.count=0,i.thisArg=r||i,i}return r.C6(t,e),t.prototype._next=function(e){var t;try{t=this.project.call(this.thisArg,e,this.count++)}catch(e){return void this.destination.error(e)}this.destination.next(t)},t}(i.v)},6723:(e,t,n)=>{"use strict";n.d(t,{U:()=>s});var r=n(4490),i=n(1015);function s(e){return void 0===e&&(e=Number.POSITIVE_INFINITY),(0,r.ZZ)(i.D,e)}},4490:(e,t,n)=>{"use strict";n.d(t,{ZZ:()=>a,qI:()=>l});var r=n(7272),i=n(8100),s=n(7046),o=n(298);function a(e,t,n){return void 0===n&&(n=Number.POSITIVE_INFINITY),"function"==typeof t?function(r){return r.pipe(a((function(n,r){return(0,s.H)(e(n,r)).pipe((0,i.T)((function(e,i){return t(n,e,r,i)})))}),n))}:("number"==typeof t&&(n=t),function(t){return t.lift(new c(e,n))})}var c=function(){function e(e,t){void 0===t&&(t=Number.POSITIVE_INFINITY),this.project=e,this.concurrent=t}return e.prototype.call=function(e,t){return t.subscribe(new u(e,this.project,this.concurrent))},e}(),u=function(e){function t(t,n,r){void 0===r&&(r=Number.POSITIVE_INFINITY);var i=e.call(this,t)||this;return i.project=n,i.concurrent=r,i.hasCompleted=!1,i.buffer=[],i.active=0,i.index=0,i}return r.C6(t,e),t.prototype._next=function(e){this.active<this.concurrent?this._tryNext(e):this.buffer.push(e)},t.prototype._tryNext=function(e){var t,n=this.index++;try{t=this.project(e,n)}catch(e){return void this.destination.error(e)}this.active++,this._innerSub(t)},t.prototype._innerSub=function(e){var t=new o.zA(this),n=this.destination;n.add(t);var r=(0,o.tS)(e,t);r!==t&&n.add(r)},t.prototype._complete=function(){this.hasCompleted=!0,0===this.active&&0===this.buffer.length&&this.destination.complete(),this.unsubscribe()},t.prototype.notifyNext=function(e){this.destination.next(e)},t.prototype.notifyComplete=function(){var e=this.buffer;this.active--,e.length>0?this._next(e.shift()):0===this.active&&this.hasCompleted&&this.destination.complete()},t}(o.gn),l=a},3947:(e,t,n)=>{"use strict";n.d(t,{QE:()=>o,YZ:()=>c});var r=n(7272),i=n(2968),s=n(2281);function o(e,t){return void 0===t&&(t=0),function(n){return n.lift(new a(e,t))}}var a=function(){function e(e,t){void 0===t&&(t=0),this.scheduler=e,this.delay=t}return e.prototype.call=function(e,t){return t.subscribe(new c(e,this.scheduler,this.delay))},e}(),c=function(e){function t(t,n,r){void 0===r&&(r=0);var i=e.call(this,t)||this;return i.scheduler=n,i.delay=r,i}return r.C6(t,e),t.dispatch=function(e){var t=e.notification,n=e.destination;t.observe(n),this.unsubscribe()},t.prototype.scheduleMessage=function(e){this.destination.add(this.scheduler.schedule(t.dispatch,this.delay,new u(e,this.destination)))},t.prototype._next=function(e){this.scheduleMessage(s.E.createNext(e))},t.prototype._error=function(e){this.scheduleMessage(s.E.createError(e)),this.unsubscribe()},t.prototype._complete=function(){this.scheduleMessage(s.E.createComplete()),this.unsubscribe()},t}(i.v),u=function(){return function(e,t){this.notification=e,this.destination=t}}()},1764:(e,t,n)=>{"use strict";n.d(t,{B:()=>s});var r=n(7272),i=n(2968);function s(){return function(e){return e.lift(new o(e))}}var o=function(){function e(e){this.connectable=e}return e.prototype.call=function(e,t){var n=this.connectable;n._refCount++;var r=new a(e,n),i=t.subscribe(r);return r.closed||(r.connection=n.connect()),i},e}(),a=function(e){function t(t,n){var r=e.call(this,t)||this;return r.connectable=n,r}return r.C6(t,e),t.prototype._unsubscribe=function(){var e=this.connectable;if(e){this.connectable=null;var t=e._refCount;if(t<=0)this.connection=null;else if(e._refCount=t-1,t>1)this.connection=null;else{var n=this.connection,r=e._connection;this.connection=null,!r||n&&r!==n||r.unsubscribe()}}else this.connection=null},t}(i.v)},5890:(e,t,n)=>{"use strict";n.d(t,{V:()=>s});var r=n(9664),i=n(9147);function s(e,t){return new r.c((function(n){var r=new i.y,s=0;return r.add(t.schedule((function(){s!==e.length?(n.next(e[s++]),n.closed||r.add(this.schedule())):n.complete()}))),r}))}},1413:(e,t,n)=>{"use strict";n.d(t,{c:()=>l});var r=n(9664),i=n(9147),s=n(3656),o=n(5890),a=n(3991),c=n(1164),u=n(9923);function l(e,t){if(null!=e){if(function(e){return e&&"function"==typeof e[s.s]}(e))return function(e,t){return new r.c((function(n){var r=new i.y;return r.add(t.schedule((function(){var i=e[s.s]();r.add(i.subscribe({next:function(e){r.add(t.schedule((function(){return n.next(e)})))},error:function(e){r.add(t.schedule((function(){return n.error(e)})))},complete:function(){r.add(t.schedule((function(){return n.complete()})))}}))}))),r}))}(e,t);if((0,c.y)(e))return function(e,t){return new r.c((function(n){var r=new i.y;return r.add(t.schedule((function(){return e.then((function(e){r.add(t.schedule((function(){n.next(e),r.add(t.schedule((function(){return n.complete()})))})))}),(function(e){r.add(t.schedule((function(){return n.error(e)})))}))}))),r}))}(e,t);if((0,u.X)(e))return(0,o.V)(e,t);if(function(e){return e&&"function"==typeof e[a.lJ]}(e)||"string"==typeof e)return function(e,t){if(!e)throw new Error("Iterable cannot be null");return new r.c((function(n){var r,s=new i.y;return s.add((function(){r&&"function"==typeof r.return&&r.return()})),s.add(t.schedule((function(){r=e[a.lJ](),s.add(t.schedule((function(){if(!n.closed){var e,t;try{var i=r.next();e=i.value,t=i.done}catch(e){return void n.error(e)}t?n.complete():(n.next(e),this.schedule())}})))}))),s}))}(e,t)}throw new TypeError((null!==e&&typeof e||e)+" is not observable")}},6027:(e,t,n)=>{"use strict";n.d(t,{R:()=>i});var r=n(7272),i=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.scheduler=t,r.work=n,r.pending=!1,r}return r.C6(t,e),t.prototype.schedule=function(e,t){if(void 0===t&&(t=0),this.closed)return this;this.state=e;var n=this.id,r=this.scheduler;return null!=n&&(this.id=this.recycleAsyncId(r,n,t)),this.pending=!0,this.delay=t,this.id=this.id||this.requestAsyncId(r,this.id,t),this},t.prototype.requestAsyncId=function(e,t,n){return void 0===n&&(n=0),setInterval(e.flush.bind(e,this),n)},t.prototype.recycleAsyncId=function(e,t,n){if(void 0===n&&(n=0),null!==n&&this.delay===n&&!1===this.pending)return t;clearInterval(t)},t.prototype.execute=function(e,t){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var n=this._execute(e,t);if(n)return n;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,t){var n=!1,r=void 0;try{this.work(e)}catch(e){n=!0,r=!!e&&e||new Error(e)}if(n)return this.unsubscribe(),r},t.prototype._unsubscribe=function(){var e=this.id,t=this.scheduler,n=t.actions,r=n.indexOf(this);this.work=null,this.state=null,this.pending=!1,this.scheduler=null,-1!==r&&n.splice(r,1),null!=e&&(this.id=this.recycleAsyncId(t,e,null)),this.delay=null},t}(function(e){function t(t,n){return e.call(this)||this}return r.C6(t,e),t.prototype.schedule=function(e,t){return void 0===t&&(t=0),this},t}(n(9147).y))},4881:(e,t,n)=>{"use strict";n.d(t,{q:()=>s});var r=n(7272),i=n(957),s=function(e){function t(n,r){void 0===r&&(r=i._.now);var s=e.call(this,n,(function(){return t.delegate&&t.delegate!==s?t.delegate.now():r()}))||this;return s.actions=[],s.active=!1,s.scheduled=void 0,s}return r.C6(t,e),t.prototype.schedule=function(n,r,i){return void 0===r&&(r=0),t.delegate&&t.delegate!==this?t.delegate.schedule(n,r,i):e.prototype.schedule.call(this,n,r,i)},t.prototype.flush=function(e){var t=this.actions;if(this.active)t.push(e);else{var n;this.active=!0;do{if(n=e.execute(e.state,e.delay))break}while(e=t.shift());if(this.active=!1,n){for(;e=t.shift();)e.unsubscribe();throw n}}},t}(i._)},9081:(e,t,n)=>{"use strict";n.d(t,{I:()=>l,$:()=>u});var r=n(7272),i=1,s=function(){return Promise.resolve()}(),o={};function a(e){return e in o&&(delete o[e],!0)}var c=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.scheduler=t,r.work=n,r}return r.C6(t,e),t.prototype.requestAsyncId=function(t,n,r){return void 0===r&&(r=0),null!==r&&r>0?e.prototype.requestAsyncId.call(this,t,n,r):(t.actions.push(this),t.scheduled||(t.scheduled=(c=t.flush.bind(t,null),u=i++,o[u]=!0,s.then((function(){return a(u)&&c()})),u)));var c,u},t.prototype.recycleAsyncId=function(t,n,r){if(void 0===r&&(r=0),null!==r&&r>0||null===r&&this.delay>0)return e.prototype.recycleAsyncId.call(this,t,n,r);0===t.actions.length&&(a(n),t.scheduled=void 0)},t}(n(6027).R),u=new(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r.C6(t,e),t.prototype.flush=function(e){this.active=!0,this.scheduled=void 0;var t,n=this.actions,r=-1,i=n.length;e=e||n.shift();do{if(t=e.execute(e.state,e.delay))break}while(++r<i&&(e=n.shift()));if(this.active=!1,t){for(;++r<i&&(e=n.shift());)e.unsubscribe();throw t}},t}(n(4881).q))(c),l=u},6346:(e,t,n)=>{"use strict";n.d(t,{E:()=>i,b:()=>s});var r=n(6027),i=new(n(4881).q)(r.R),s=i},464:(e,t,n)=>{"use strict";n.d(t,{g:()=>o,T:()=>s});var r=n(7272),i=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.scheduler=t,r.work=n,r}return r.C6(t,e),t.prototype.schedule=function(t,n){return void 0===n&&(n=0),n>0?e.prototype.schedule.call(this,t,n):(this.delay=n,this.state=t,this.scheduler.flush(this),this)},t.prototype.execute=function(t,n){return n>0||this.closed?e.prototype.execute.call(this,t,n):this._execute(t,n)},t.prototype.requestAsyncId=function(t,n,r){return void 0===r&&(r=0),null!==r&&r>0||null===r&&this.delay>0?e.prototype.requestAsyncId.call(this,t,n,r):t.flush(this)},t}(n(6027).R),s=new(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r.C6(t,e),t}(n(4881).q))(i),o=s},3991:(e,t,n)=>{"use strict";function r(){return"function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator"}n.d(t,{lJ:()=>i});var i=r()},3656:(e,t,n)=>{"use strict";n.d(t,{s:()=>r});var r=function(){return"function"==typeof Symbol&&Symbol.observable||"@@observable"}()},3089:(e,t,n)=>{"use strict";n.d(t,{D:()=>r});var r=function(){return"function"==typeof Symbol?Symbol("rxSubscriber"):"@@rxSubscriber_"+Math.random()}()},692:(e,t,n)=>{"use strict";n.d(t,{k:()=>r});var r=function(){function e(){return Error.call(this),this.message="argument out of range",this.name="ArgumentOutOfRangeError",this}return e.prototype=Object.create(Error.prototype),e}()},3700:(e,t,n)=>{"use strict";n.d(t,{G:()=>r});var r=function(){function e(){return Error.call(this),this.message="no elements in sequence",this.name="EmptyError",this}return e.prototype=Object.create(Error.prototype),e}()},731:(e,t,n)=>{"use strict";n.d(t,{P:()=>r});var r=function(){function e(){return Error.call(this),this.message="object unsubscribed",this.name="ObjectUnsubscribedError",this}return e.prototype=Object.create(Error.prototype),e}()},34:(e,t,n)=>{"use strict";n.d(t,{M:()=>r});var r=function(){function e(){return Error.call(this),this.message="Timeout has occurred",this.name="TimeoutError",this}return e.prototype=Object.create(Error.prototype),e}()},9857:(e,t,n)=>{"use strict";n.d(t,{Z:()=>r});var r=function(){function e(e){return Error.call(this),this.message=e?e.length+" errors occurred during unsubscription:\n"+e.map((function(e,t){return t+1+") "+e.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=e,this}return e.prototype=Object.create(Error.prototype),e}()},1075:(e,t,n)=>{"use strict";n.d(t,{H:()=>i});var r=n(2968);function i(e){for(;e;){var t=e,n=t.closed,i=t.destination,s=t.isStopped;if(n||s)return!1;e=i&&i instanceof r.v?i:null}return!0}},9199:(e,t,n)=>{"use strict";function r(e){setTimeout((function(){throw e}),0)}n.d(t,{T:()=>r})},1015:(e,t,n)=>{"use strict";function r(e){return e}n.d(t,{D:()=>r})},252:(e,t,n)=>{"use strict";n.d(t,{c:()=>r});var r=function(){return Array.isArray||function(e){return e&&"number"==typeof e.length}}()},9923:(e,t,n)=>{"use strict";n.d(t,{X:()=>r});var r=function(e){return e&&"number"==typeof e.length&&"function"!=typeof e}},9029:(e,t,n)=>{"use strict";function r(e){return"function"==typeof e}n.d(t,{T:()=>r})},6290:(e,t,n)=>{"use strict";n.d(t,{k:()=>i});var r=n(252);function i(e){return!(0,r.c)(e)&&e-parseFloat(e)+1>=0}},806:(e,t,n)=>{"use strict";function r(e){return null!==e&&"object"==typeof e}n.d(t,{G:()=>r})},1164:(e,t,n)=>{"use strict";function r(e){return!!e&&"function"!=typeof e.subscribe&&"function"==typeof e.then}n.d(t,{y:()=>r})},4576:(e,t,n)=>{"use strict";function r(e){return e&&"function"==typeof e.schedule}n.d(t,{m:()=>r})},1193:(e,t,n)=>{"use strict";function r(){}n.d(t,{l:()=>r})},3428:(e,t,n)=>{"use strict";function r(e,t){function n(){return!n.pred.apply(n.thisArg,arguments)}return n.pred=e,n.thisArg=t,n}n.d(t,{A:()=>r})},6833:(e,t,n)=>{"use strict";n.d(t,{F:()=>i,m:()=>s});var r=n(1015);function i(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return s(e)}function s(e){return 0===e.length?r.D:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)}}},8777:(e,t,n)=>{"use strict";n.d(t,{i:()=>l});var r=n(6239),i=n(9199),s=n(3991),o=n(3656),a=n(9923),c=n(1164),u=n(806),l=function(e){if(e&&"function"==typeof e[o.s])return l=e,function(e){var t=l[o.s]();if("function"!=typeof t.subscribe)throw new TypeError("Provided object does not correctly implement Symbol.observable");return t.subscribe(e)};if((0,a.X)(e))return(0,r.v)(e);if((0,c.y)(e))return n=e,function(e){return n.then((function(t){e.closed||(e.next(t),e.complete())}),(function(t){return e.error(t)})).then(null,i.T),e};if(e&&"function"==typeof e[s.lJ])return t=e,function(e){for(var n=t[s.lJ]();;){var r=void 0;try{r=n.next()}catch(t){return e.error(t),e}if(r.done){e.complete();break}if(e.next(r.value),e.closed)break}return"function"==typeof n.return&&e.add((function(){n.return&&n.return()})),e};var t,n,l,h=(0,u.G)(e)?"an invalid object":"'"+e+"'";throw new TypeError("You provided "+h+" where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.")}},6239:(e,t,n)=>{"use strict";n.d(t,{v:()=>r});var r=function(e){return function(t){for(var n=0,r=e.length;n<r&&!t.closed;n++)t.next(e[n]);t.complete()}}},538:(e,t,n)=>{"use strict";n.d(t,{F:()=>a});var r=n(7272),i=function(e){function t(t,n,r){var i=e.call(this)||this;return i.parent=t,i.outerValue=n,i.outerIndex=r,i.index=0,i}return r.C6(t,e),t.prototype._next=function(e){this.parent.notifyNext(this.outerValue,e,this.outerIndex,this.index++,this)},t.prototype._error=function(e){this.parent.notifyError(e,this),this.unsubscribe()},t.prototype._complete=function(){this.parent.notifyComplete(this),this.unsubscribe()},t}(n(2968).v),s=n(8777),o=n(9664);function a(e,t,n,r,a){if(void 0===a&&(a=new i(e,n,r)),!a.closed)return t instanceof o.c?t.subscribe(a):(0,s.i)(t)(a)}},5758:(e,t,n)=>{"use strict";n.r(t),n.d(t,{audit:()=>s,auditTime:()=>l,buffer:()=>h,bufferCount:()=>m,bufferTime:()=>w,bufferToggle:()=>N,bufferWhen:()=>R,catchError:()=>M,combineAll:()=>j,combineLatest:()=>z,concat:()=>K,concatAll:()=>W.K,concatMap:()=>H,concatMapTo:()=>Q,count:()=>J,debounce:()=>Z,debounceTime:()=>ne,defaultIfEmpty:()=>oe,delay:()=>he,delayWhen:()=>ge,dematerialize:()=>_e,distinct:()=>Te,distinctUntilChanged:()=>Ae,distinctUntilKeyChanged:()=>Ne,elementAt:()=>qe,endWith:()=>Ge,every:()=>Ke,exhaust:()=>He,exhaustMap:()=>Xe,expand:()=>tt,filter:()=>De.p,finalize:()=>it,find:()=>at,findIndex:()=>lt,first:()=>dt,flatMap:()=>$.qI,groupBy:()=>ft.$,ignoreElements:()=>pt,isEmpty:()=>yt,last:()=>Et,map:()=>Ye.T,mapTo:()=>Tt,materialize:()=>At,max:()=>Lt,merge:()=>Ft,mergeAll:()=>Vt.U,mergeMap:()=>$.ZZ,mergeMapTo:()=>Ut,mergeScan:()=>jt,min:()=>zt,multicast:()=>Kt,observeOn:()=>$t.QE,onErrorResumeNext:()=>Ht,pairwise:()=>Yt,partition:()=>tn,pluck:()=>nn,publish:()=>sn,publishBehavior:()=>an,publishLast:()=>un,publishReplay:()=>hn,race:()=>fn,reduce:()=>Pt,refCount:()=>Cn.B,repeat:()=>pn,repeatWhen:()=>yn,retry:()=>wn,retryWhen:()=>En,sample:()=>An,sampleTime:()=>Nn,scan:()=>Nt,sequenceEqual:()=>Pn,share:()=>Un,shareReplay:()=>jn,single:()=>Bn,skip:()=>Gn,skipLast:()=>$n,skipUntil:()=>Jn,skipWhile:()=>Zn,startWith:()=>nr,subscribeOn:()=>or,switchAll:()=>hr,switchMap:()=>cr,switchMapTo:()=>dr,take:()=>Ue,takeLast:()=>wt,takeUntil:()=>fr,takeWhile:()=>gr,tap:()=>_r,throttle:()=>Sr,throttleTime:()=>xr,throwIfEmpty:()=>Pe,timeInterval:()=>Rr,timeout:()=>jr,timeoutWith:()=>Mr,timestamp:()=>Br,toArray:()=>Gr,window:()=>Kr,windowCount:()=>Hr,windowTime:()=>Yr,windowToggle:()=>ii,windowWhen:()=>ai,withLatestFrom:()=>li,zip:()=>pi,zipAll:()=>mi});var r=n(7272),i=n(298);function s(e){return function(t){return t.lift(new o(e))}}var o=function(){function e(e){this.durationSelector=e}return e.prototype.call=function(e,t){return t.subscribe(new a(e,this.durationSelector))},e}(),a=function(e){function t(t,n){var r=e.call(this,t)||this;return r.durationSelector=n,r.hasValue=!1,r}return r.C6(t,e),t.prototype._next=function(e){if(this.value=e,this.hasValue=!0,!this.throttled){var t=void 0;try{t=(0,this.durationSelector)(e)}catch(e){return this.destination.error(e)}var n=(0,i.tS)(t,new i.zA(this));!n||n.closed?this.clearThrottle():this.add(this.throttled=n)}},t.prototype.clearThrottle=function(){var e=this,t=e.value,n=e.hasValue,r=e.throttled;r&&(this.remove(r),this.throttled=void 0,r.unsubscribe()),n&&(this.value=void 0,this.hasValue=!1,this.destination.next(t))},t.prototype.notifyNext=function(){this.clearThrottle()},t.prototype.notifyComplete=function(){this.clearThrottle()},t}(i.gn),c=n(6346),u=n(1133);function l(e,t){return void 0===t&&(t=c.b),s((function(){return(0,u.O)(e,t)}))}function h(e){return function(t){return t.lift(new d(e))}}var d=function(){function e(e){this.closingNotifier=e}return e.prototype.call=function(e,t){return t.subscribe(new f(e,this.closingNotifier))},e}(),f=function(e){function t(t,n){var r=e.call(this,t)||this;return r.buffer=[],r.add((0,i.tS)(n,new i.zA(r))),r}return r.C6(t,e),t.prototype._next=function(e){this.buffer.push(e)},t.prototype.notifyNext=function(){var e=this.buffer;this.buffer=[],this.destination.next(e)},t}(i.gn),p=n(2968);function m(e,t){return void 0===t&&(t=null),function(n){return n.lift(new g(e,t))}}var g=function(){function e(e,t){this.bufferSize=e,this.startBufferEvery=t,this.subscriberClass=t&&e!==t?v:y}return e.prototype.call=function(e,t){return t.subscribe(new this.subscriberClass(e,this.bufferSize,this.startBufferEvery))},e}(),y=function(e){function t(t,n){var r=e.call(this,t)||this;return r.bufferSize=n,r.buffer=[],r}return r.C6(t,e),t.prototype._next=function(e){var t=this.buffer;t.push(e),t.length==this.bufferSize&&(this.destination.next(t),this.buffer=[])},t.prototype._complete=function(){var t=this.buffer;t.length>0&&this.destination.next(t),e.prototype._complete.call(this)},t}(p.v),v=function(e){function t(t,n,r){var i=e.call(this,t)||this;return i.bufferSize=n,i.startBufferEvery=r,i.buffers=[],i.count=0,i}return r.C6(t,e),t.prototype._next=function(e){var t=this,n=t.bufferSize,r=t.startBufferEvery,i=t.buffers,s=t.count;this.count++,s%r==0&&i.push([]);for(var o=i.length;o--;){var a=i[o];a.push(e),a.length===n&&(i.splice(o,1),this.destination.next(a))}},t.prototype._complete=function(){for(var t=this.buffers,n=this.destination;t.length>0;){var r=t.shift();r.length>0&&n.next(r)}e.prototype._complete.call(this)},t}(p.v),b=n(4576);function w(e){var t=arguments.length,n=c.b;(0,b.m)(arguments[arguments.length-1])&&(n=arguments[arguments.length-1],t--);var r=null;t>=2&&(r=arguments[1]);var i=Number.POSITIVE_INFINITY;return t>=3&&(i=arguments[2]),function(t){return t.lift(new _(e,r,i,n))}}var _=function(){function e(e,t,n,r){this.bufferTimeSpan=e,this.bufferCreationInterval=t,this.maxBufferSize=n,this.scheduler=r}return e.prototype.call=function(e,t){return t.subscribe(new E(e,this.bufferTimeSpan,this.bufferCreationInterval,this.maxBufferSize,this.scheduler))},e}(),I=function(){return function(){this.buffer=[]}}(),E=function(e){function t(t,n,r,i,s){var o=e.call(this,t)||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(T,n,c))}else{var u={subscriber:o,context:a},l={bufferTimeSpan:n,bufferCreationInterval:r,subscriber:o,scheduler:s};o.add(a.closeAction=s.schedule(C,n,u)),o.add(s.schedule(S,r,l))}return o}return r.C6(t,e),t.prototype._next=function(e){for(var t,n=this.contexts,r=n.length,i=0;i<r;i++){var s=n[i],o=s.buffer;o.push(e),o.length==this.maxBufferSize&&(t=s)}t&&this.onBufferFull(t)},t.prototype._error=function(t){this.contexts.length=0,e.prototype._error.call(this,t)},t.prototype._complete=function(){for(var t=this.contexts,n=this.destination;t.length>0;){var r=t.shift();n.next(r.buffer)}e.prototype._complete.call(this)},t.prototype._unsubscribe=function(){this.contexts=null},t.prototype.onBufferFull=function(e){this.closeContext(e);var t=e.closeAction;if(t.unsubscribe(),this.remove(t),!this.closed&&this.timespanOnly){e=this.openContext();var n=this.bufferTimeSpan,r={subscriber:this,context:e,bufferTimeSpan:n};this.add(e.closeAction=this.scheduler.schedule(T,n,r))}},t.prototype.openContext=function(){var e=new I;return this.contexts.push(e),e},t.prototype.closeContext=function(e){this.destination.next(e.buffer);var t=this.contexts;(t?t.indexOf(e):-1)>=0&&t.splice(t.indexOf(e),1)},t}(p.v);function T(e){var t=e.subscriber,n=e.context;n&&t.closeContext(n),t.closed||(e.context=t.openContext(),e.context.closeAction=this.schedule(e,e.bufferTimeSpan))}function S(e){var t=e.bufferCreationInterval,n=e.bufferTimeSpan,r=e.subscriber,i=e.scheduler,s=r.openContext();r.closed||(r.add(s.closeAction=i.schedule(C,n,{subscriber:r,context:s})),this.schedule(e,t))}function C(e){var t=e.subscriber,n=e.context;t.closeContext(n)}var A=n(9147),x=n(538),k=n(7069);function N(e,t){return function(n){return n.lift(new O(e,t))}}var O=function(){function e(e,t){this.openings=e,this.closingSelector=t}return e.prototype.call=function(e,t){return t.subscribe(new D(e,this.openings,this.closingSelector))},e}(),D=function(e){function t(t,n,r){var i=e.call(this,t)||this;return i.closingSelector=r,i.contexts=[],i.add((0,x.F)(i,n)),i}return r.C6(t,e),t.prototype._next=function(e){for(var t=this.contexts,n=t.length,r=0;r<n;r++)t[r].buffer.push(e)},t.prototype._error=function(t){for(var n=this.contexts;n.length>0;){var r=n.shift();r.subscription.unsubscribe(),r.buffer=null,r.subscription=null}this.contexts=null,e.prototype._error.call(this,t)},t.prototype._complete=function(){for(var t=this.contexts;t.length>0;){var n=t.shift();this.destination.next(n.buffer),n.subscription.unsubscribe(),n.buffer=null,n.subscription=null}this.contexts=null,e.prototype._complete.call(this)},t.prototype.notifyNext=function(e,t){e?this.closeBuffer(e):this.openBuffer(t)},t.prototype.notifyComplete=function(e){this.closeBuffer(e.context)},t.prototype.openBuffer=function(e){try{var t=this.closingSelector.call(this,e);t&&this.trySubscribe(t)}catch(e){this._error(e)}},t.prototype.closeBuffer=function(e){var t=this.contexts;if(t&&e){var n=e.buffer,r=e.subscription;this.destination.next(n),t.splice(t.indexOf(e),1),this.remove(r),r.unsubscribe()}},t.prototype.trySubscribe=function(e){var t=this.contexts,n=new A.y,r={buffer:[],subscription:n};t.push(r);var i=(0,x.F)(this,e,r);!i||i.closed?this.closeBuffer(r):(i.context=r,this.add(i),n.add(i))},t}(k.E);function R(e){return function(t){return t.lift(new P(e))}}var P=function(){function e(e){this.closingSelector=e}return e.prototype.call=function(e,t){return t.subscribe(new L(e,this.closingSelector))},e}(),L=function(e){function t(t,n){var r=e.call(this,t)||this;return r.closingSelector=n,r.subscribing=!1,r.openBuffer(),r}return r.C6(t,e),t.prototype._next=function(e){this.buffer.push(e)},t.prototype._complete=function(){var t=this.buffer;t&&this.destination.next(t),e.prototype._complete.call(this)},t.prototype._unsubscribe=function(){this.buffer=void 0,this.subscribing=!1},t.prototype.notifyNext=function(){this.openBuffer()},t.prototype.notifyComplete=function(){this.subscribing?this.complete():this.openBuffer()},t.prototype.openBuffer=function(){var e=this.closingSubscription;e&&(this.remove(e),e.unsubscribe());var t,n=this.buffer;this.buffer&&this.destination.next(n),this.buffer=[];try{t=(0,this.closingSelector)()}catch(e){return this.error(e)}e=new A.y,this.closingSubscription=e,this.add(e),this.subscribing=!0,e.add((0,i.tS)(t,new i.zA(this))),this.subscribing=!1},t}(i.gn);function M(e){return function(t){var n=new F(e),r=t.lift(n);return n.caught=r}}var F=function(){function e(e){this.selector=e}return e.prototype.call=function(e,t){return t.subscribe(new V(e,this.selector,this.caught))},e}(),V=function(e){function t(t,n,r){var i=e.call(this,t)||this;return i.selector=n,i.caught=r,i}return r.C6(t,e),t.prototype.error=function(t){if(!this.isStopped){var n=void 0;try{n=this.selector(t,this.caught)}catch(t){return void e.prototype.error.call(this,t)}this._unsubscribeAndRecycle();var r=new i.zA(this);this.add(r);var s=(0,i.tS)(n,r);s!==r&&this.add(s)}},t}(i.gn),U=n(8890);function j(e){return function(t){return t.lift(new U.ZS(e))}}var B=n(252),q=n(7046);function z(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=null;return"function"==typeof e[e.length-1]&&(n=e.pop()),1===e.length&&(0,B.c)(e[0])&&(e=e[0].slice()),function(t){return t.lift.call((0,q.H)([t].concat(e)),new U.ZS(n))}}var G=n(926);function K(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t){return t.lift.call(G.x.apply(void 0,[t].concat(e)))}}var W=n(7125),$=n(4490);function H(e,t){return(0,$.ZZ)(e,t,1)}function Q(e,t){return H((function(){return e}),t)}function J(e){return function(t){return t.lift(new Y(e,t))}}var Y=function(){function e(e,t){this.predicate=e,this.source=t}return e.prototype.call=function(e,t){return t.subscribe(new X(e,this.predicate,this.source))},e}(),X=function(e){function t(t,n,r){var i=e.call(this,t)||this;return i.predicate=n,i.source=r,i.count=0,i.index=0,i}return r.C6(t,e),t.prototype._next=function(e){this.predicate?this._tryPredicate(e):this.count++},t.prototype._tryPredicate=function(e){var t;try{t=this.predicate(e,this.index++,this.source)}catch(e){return void this.destination.error(e)}t&&this.count++},t.prototype._complete=function(){this.destination.next(this.count),this.destination.complete()},t}(p.v);function Z(e){return function(t){return t.lift(new ee(e))}}var ee=function(){function e(e){this.durationSelector=e}return e.prototype.call=function(e,t){return t.subscribe(new te(e,this.durationSelector))},e}(),te=function(e){function t(t,n){var r=e.call(this,t)||this;return r.durationSelector=n,r.hasValue=!1,r}return r.C6(t,e),t.prototype._next=function(e){try{var t=this.durationSelector.call(this,e);t&&this._tryNext(e,t)}catch(e){this.destination.error(e)}},t.prototype._complete=function(){this.emitValue(),this.destination.complete()},t.prototype._tryNext=function(e,t){var n=this.durationSubscription;this.value=e,this.hasValue=!0,n&&(n.unsubscribe(),this.remove(n)),(n=(0,i.tS)(t,new i.zA(this)))&&!n.closed&&this.add(this.durationSubscription=n)},t.prototype.notifyNext=function(){this.emitValue()},t.prototype.notifyComplete=function(){this.emitValue()},t.prototype.emitValue=function(){if(this.hasValue){var t=this.value,n=this.durationSubscription;n&&(this.durationSubscription=void 0,n.unsubscribe(),this.remove(n)),this.value=void 0,this.hasValue=!1,e.prototype._next.call(this,t)}},t}(i.gn);function ne(e,t){return void 0===t&&(t=c.b),function(n){return n.lift(new re(e,t))}}var re=function(){function e(e,t){this.dueTime=e,this.scheduler=t}return e.prototype.call=function(e,t){return t.subscribe(new ie(e,this.dueTime,this.scheduler))},e}(),ie=function(e){function t(t,n,r){var i=e.call(this,t)||this;return i.dueTime=n,i.scheduler=r,i.debouncedSubscription=null,i.lastValue=null,i.hasValue=!1,i}return r.C6(t,e),t.prototype._next=function(e){this.clearDebounce(),this.lastValue=e,this.hasValue=!0,this.add(this.debouncedSubscription=this.scheduler.schedule(se,this.dueTime,this))},t.prototype._complete=function(){this.debouncedNext(),this.destination.complete()},t.prototype.debouncedNext=function(){if(this.clearDebounce(),this.hasValue){var e=this.lastValue;this.lastValue=null,this.hasValue=!1,this.destination.next(e)}},t.prototype.clearDebounce=function(){var e=this.debouncedSubscription;null!==e&&(this.remove(e),e.unsubscribe(),this.debouncedSubscription=null)},t}(p.v);function se(e){e.debouncedNext()}function oe(e){return void 0===e&&(e=null),function(t){return t.lift(new ae(e))}}var ae=function(){function e(e){this.defaultValue=e}return e.prototype.call=function(e,t){return t.subscribe(new ce(e,this.defaultValue))},e}(),ce=function(e){function t(t,n){var r=e.call(this,t)||this;return r.defaultValue=n,r.isEmpty=!0,r}return r.C6(t,e),t.prototype._next=function(e){this.isEmpty=!1,this.destination.next(e)},t.prototype._complete=function(){this.isEmpty&&this.destination.next(this.defaultValue),this.destination.complete()},t}(p.v);function ue(e){return e instanceof Date&&!isNaN(+e)}var le=n(2281);function he(e,t){void 0===t&&(t=c.b);var n=ue(e)?+e-t.now():Math.abs(e);return function(e){return e.lift(new de(n,t))}}var de=function(){function e(e,t){this.delay=e,this.scheduler=t}return e.prototype.call=function(e,t){return t.subscribe(new fe(e,this.delay,this.scheduler))},e}(),fe=function(e){function t(t,n,r){var i=e.call(this,t)||this;return i.delay=n,i.scheduler=r,i.queue=[],i.active=!1,i.errored=!1,i}return r.C6(t,e),t.dispatch=function(e){for(var t=e.source,n=t.queue,r=e.scheduler,i=e.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(e,s)}else this.unsubscribe(),t.active=!1},t.prototype._schedule=function(e){this.active=!0,this.destination.add(e.schedule(t.dispatch,this.delay,{source:this,destination:this.destination,scheduler:e}))},t.prototype.scheduleNotification=function(e){if(!0!==this.errored){var t=this.scheduler,n=new pe(t.now()+this.delay,e);this.queue.push(n),!1===this.active&&this._schedule(t)}},t.prototype._next=function(e){this.scheduleNotification(le.E.createNext(e))},t.prototype._error=function(e){this.errored=!0,this.queue=[],this.destination.error(e),this.unsubscribe()},t.prototype._complete=function(){this.scheduleNotification(le.E.createComplete()),this.unsubscribe()},t}(p.v),pe=function(){return function(e,t){this.time=e,this.notification=t}}(),me=n(9664);function ge(e,t){return t?function(n){return new be(n,t).lift(new ye(e))}:function(t){return t.lift(new ye(e))}}var ye=function(){function e(e){this.delayDurationSelector=e}return e.prototype.call=function(e,t){return t.subscribe(new ve(e,this.delayDurationSelector))},e}(),ve=function(e){function t(t,n){var r=e.call(this,t)||this;return r.delayDurationSelector=n,r.completed=!1,r.delayNotifierSubscriptions=[],r.index=0,r}return r.C6(t,e),t.prototype.notifyNext=function(e,t,n,r,i){this.destination.next(e),this.removeSubscription(i),this.tryComplete()},t.prototype.notifyError=function(e,t){this._error(e)},t.prototype.notifyComplete=function(e){var t=this.removeSubscription(e);t&&this.destination.next(t),this.tryComplete()},t.prototype._next=function(e){var t=this.index++;try{var n=this.delayDurationSelector(e,t);n&&this.tryDelay(n,e)}catch(e){this.destination.error(e)}},t.prototype._complete=function(){this.completed=!0,this.tryComplete(),this.unsubscribe()},t.prototype.removeSubscription=function(e){e.unsubscribe();var t=this.delayNotifierSubscriptions.indexOf(e);return-1!==t&&this.delayNotifierSubscriptions.splice(t,1),e.outerValue},t.prototype.tryDelay=function(e,t){var n=(0,x.F)(this,e,t);n&&!n.closed&&(this.destination.add(n),this.delayNotifierSubscriptions.push(n))},t.prototype.tryComplete=function(){this.completed&&0===this.delayNotifierSubscriptions.length&&this.destination.complete()},t}(k.E),be=function(e){function t(t,n){var r=e.call(this)||this;return r.source=t,r.subscriptionDelay=n,r}return r.C6(t,e),t.prototype._subscribe=function(e){this.subscriptionDelay.subscribe(new we(e,this.source))},t}(me.c),we=function(e){function t(t,n){var r=e.call(this)||this;return r.parent=t,r.source=n,r.sourceSubscribed=!1,r}return r.C6(t,e),t.prototype._next=function(e){this.subscribeToSource()},t.prototype._error=function(e){this.unsubscribe(),this.parent.error(e)},t.prototype._complete=function(){this.unsubscribe(),this.subscribeToSource()},t.prototype.subscribeToSource=function(){this.sourceSubscribed||(this.sourceSubscribed=!0,this.unsubscribe(),this.source.subscribe(this.parent))},t}(p.v);function _e(){return function(e){return e.lift(new Ie)}}var Ie=function(){function e(){}return e.prototype.call=function(e,t){return t.subscribe(new Ee(e))},e}(),Ee=function(e){function t(t){return e.call(this,t)||this}return r.C6(t,e),t.prototype._next=function(e){e.observe(this.destination)},t}(p.v);function Te(e,t){return function(n){return n.lift(new Se(e,t))}}var Se=function(){function e(e,t){this.keySelector=e,this.flushes=t}return e.prototype.call=function(e,t){return t.subscribe(new Ce(e,this.keySelector,this.flushes))},e}(),Ce=function(e){function t(t,n,r){var s=e.call(this,t)||this;return s.keySelector=n,s.values=new Set,r&&s.add((0,i.tS)(r,new i.zA(s))),s}return r.C6(t,e),t.prototype.notifyNext=function(){this.values.clear()},t.prototype.notifyError=function(e){this._error(e)},t.prototype._next=function(e){this.keySelector?this._useKeySelector(e):this._finalizeNext(e,e)},t.prototype._useKeySelector=function(e){var t,n=this.destination;try{t=this.keySelector(e)}catch(e){return void n.error(e)}this._finalizeNext(t,e)},t.prototype._finalizeNext=function(e,t){var n=this.values;n.has(e)||(n.add(e),this.destination.next(t))},t}(i.gn);function Ae(e,t){return function(n){return n.lift(new xe(e,t))}}var xe=function(){function e(e,t){this.compare=e,this.keySelector=t}return e.prototype.call=function(e,t){return t.subscribe(new ke(e,this.compare,this.keySelector))},e}(),ke=function(e){function t(t,n,r){var i=e.call(this,t)||this;return i.keySelector=r,i.hasKey=!1,"function"==typeof n&&(i.compare=n),i}return r.C6(t,e),t.prototype.compare=function(e,t){return e===t},t.prototype._next=function(e){var t;try{var n=this.keySelector;t=n?n(e):e}catch(e){return this.destination.error(e)}var r=!1;if(this.hasKey)try{r=(0,this.compare)(this.key,t)}catch(e){return this.destination.error(e)}else this.hasKey=!0;r||(this.key=t,this.destination.next(e))},t}(p.v);function Ne(e,t){return Ae((function(n,r){return t?t(n[e],r[e]):n[e]===r[e]}))}var Oe=n(692),De=n(9610),Re=n(3700);function Pe(e){return void 0===e&&(e=Fe),function(t){return t.lift(new Le(e))}}var Le=function(){function e(e){this.errorFactory=e}return e.prototype.call=function(e,t){return t.subscribe(new Me(e,this.errorFactory))},e}(),Me=function(e){function t(t,n){var r=e.call(this,t)||this;return r.errorFactory=n,r.hasValue=!1,r}return r.C6(t,e),t.prototype._next=function(e){this.hasValue=!0,this.destination.next(e)},t.prototype._complete=function(){if(this.hasValue)return this.destination.complete();var e=void 0;try{e=this.errorFactory()}catch(t){e=t}this.destination.error(e)},t}(p.v);function Fe(){return new Re.G}var Ve=n(4833);function Ue(e){return function(t){return 0===e?(0,Ve.I)():t.lift(new je(e))}}var je=function(){function e(e){if(this.total=e,this.total<0)throw new Oe.k}return e.prototype.call=function(e,t){return t.subscribe(new Be(e,this.total))},e}(),Be=function(e){function t(t,n){var r=e.call(this,t)||this;return r.total=n,r.count=0,r}return r.C6(t,e),t.prototype._next=function(e){var t=this.total,n=++this.count;n<=t&&(this.destination.next(e),n===t&&(this.destination.complete(),this.unsubscribe()))},t}(p.v);function qe(e,t){if(e<0)throw new Oe.k;var n=arguments.length>=2;return function(r){return r.pipe((0,De.p)((function(t,n){return n===e})),Ue(1),n?oe(t):Pe((function(){return new Oe.k})))}}var ze=n(8927);function Ge(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t){return(0,G.x)(t,ze.of.apply(void 0,e))}}function Ke(e,t){return function(n){return n.lift(new We(e,t,n))}}var We=function(){function e(e,t,n){this.predicate=e,this.thisArg=t,this.source=n}return e.prototype.call=function(e,t){return t.subscribe(new $e(e,this.predicate,this.thisArg,this.source))},e}(),$e=function(e){function t(t,n,r,i){var s=e.call(this,t)||this;return s.predicate=n,s.thisArg=r,s.source=i,s.index=0,s.thisArg=r||s,s}return r.C6(t,e),t.prototype.notifyComplete=function(e){this.destination.next(e),this.destination.complete()},t.prototype._next=function(e){var t=!1;try{t=this.predicate.call(this.thisArg,e,this.index++,this.source)}catch(e){return void this.destination.error(e)}t||this.notifyComplete(!1)},t.prototype._complete=function(){this.notifyComplete(!0)},t}(p.v);function He(){return function(e){return e.lift(new Qe)}}var Qe=function(){function e(){}return e.prototype.call=function(e,t){return t.subscribe(new Je(e))},e}(),Je=function(e){function t(t){var n=e.call(this,t)||this;return n.hasCompleted=!1,n.hasSubscription=!1,n}return r.C6(t,e),t.prototype._next=function(e){this.hasSubscription||(this.hasSubscription=!0,this.add((0,i.tS)(e,new i.zA(this))))},t.prototype._complete=function(){this.hasCompleted=!0,this.hasSubscription||this.destination.complete()},t.prototype.notifyComplete=function(){this.hasSubscription=!1,this.hasCompleted&&this.destination.complete()},t}(i.gn),Ye=n(8100);function Xe(e,t){return t?function(n){return n.pipe(Xe((function(n,r){return(0,q.H)(e(n,r)).pipe((0,Ye.T)((function(e,i){return t(n,e,r,i)})))})))}:function(t){return t.lift(new Ze(e))}}var Ze=function(){function e(e){this.project=e}return e.prototype.call=function(e,t){return t.subscribe(new et(e,this.project))},e}(),et=function(e){function t(t,n){var r=e.call(this,t)||this;return r.project=n,r.hasSubscription=!1,r.hasCompleted=!1,r.index=0,r}return r.C6(t,e),t.prototype._next=function(e){this.hasSubscription||this.tryNext(e)},t.prototype.tryNext=function(e){var t,n=this.index++;try{t=this.project(e,n)}catch(e){return void this.destination.error(e)}this.hasSubscription=!0,this._innerSub(t)},t.prototype._innerSub=function(e){var t=new i.zA(this),n=this.destination;n.add(t);var r=(0,i.tS)(e,t);r!==t&&n.add(r)},t.prototype._complete=function(){this.hasCompleted=!0,this.hasSubscription||this.destination.complete(),this.unsubscribe()},t.prototype.notifyNext=function(e){this.destination.next(e)},t.prototype.notifyError=function(e){this.destination.error(e)},t.prototype.notifyComplete=function(){this.hasSubscription=!1,this.hasCompleted&&this.destination.complete()},t}(i.gn);function tt(e,t,n){return void 0===t&&(t=Number.POSITIVE_INFINITY),t=(t||0)<1?Number.POSITIVE_INFINITY:t,function(r){return r.lift(new nt(e,t,n))}}var nt=function(){function e(e,t,n){this.project=e,this.concurrent=t,this.scheduler=n}return e.prototype.call=function(e,t){return t.subscribe(new rt(e,this.project,this.concurrent,this.scheduler))},e}(),rt=function(e){function t(t,n,r,i){var s=e.call(this,t)||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.C6(t,e),t.dispatch=function(e){var t=e.subscriber,n=e.result,r=e.value,i=e.index;t.subscribeToProjection(n,r,i)},t.prototype._next=function(e){var n=this.destination;if(n.closed)this._complete();else{var r=this.index++;if(this.active<this.concurrent){n.next(e);try{var i=(0,this.project)(e,r);if(this.scheduler){var s={subscriber:this,result:i,value:e,index:r};this.destination.add(this.scheduler.schedule(t.dispatch,0,s))}else this.subscribeToProjection(i,e,r)}catch(e){n.error(e)}}else this.buffer.push(e)}},t.prototype.subscribeToProjection=function(e,t,n){this.active++,this.destination.add((0,i.tS)(e,new i.zA(this)))},t.prototype._complete=function(){this.hasCompleted=!0,this.hasCompleted&&0===this.active&&this.destination.complete(),this.unsubscribe()},t.prototype.notifyNext=function(e){this._next(e)},t.prototype.notifyComplete=function(){var e=this.buffer;this.active--,e&&e.length>0&&this._next(e.shift()),this.hasCompleted&&0===this.active&&this.destination.complete()},t}(i.gn);function it(e){return function(t){return t.lift(new st(e))}}var st=function(){function e(e){this.callback=e}return e.prototype.call=function(e,t){return t.subscribe(new ot(e,this.callback))},e}(),ot=function(e){function t(t,n){var r=e.call(this,t)||this;return r.add(new A.y(n)),r}return r.C6(t,e),t}(p.v);function at(e,t){if("function"!=typeof e)throw new TypeError("predicate is not a function");return function(n){return n.lift(new ct(e,n,!1,t))}}var ct=function(){function e(e,t,n,r){this.predicate=e,this.source=t,this.yieldIndex=n,this.thisArg=r}return e.prototype.call=function(e,t){return t.subscribe(new ut(e,this.predicate,this.source,this.yieldIndex,this.thisArg))},e}(),ut=function(e){function t(t,n,r,i,s){var o=e.call(this,t)||this;return o.predicate=n,o.source=r,o.yieldIndex=i,o.thisArg=s,o.index=0,o}return r.C6(t,e),t.prototype.notifyComplete=function(e){var t=this.destination;t.next(e),t.complete(),this.unsubscribe()},t.prototype._next=function(e){var t=this.predicate,n=this.thisArg,r=this.index++;try{t.call(n||this,e,r,this.source)&&this.notifyComplete(this.yieldIndex?r:e)}catch(e){this.destination.error(e)}},t.prototype._complete=function(){this.notifyComplete(this.yieldIndex?-1:void 0)},t}(p.v);function lt(e,t){return function(n){return n.lift(new ct(e,n,!0,t))}}var ht=n(1015);function dt(e,t){var n=arguments.length>=2;return function(r){return r.pipe(e?(0,De.p)((function(t,n){return e(t,n,r)})):ht.D,Ue(1),n?oe(t):Pe((function(){return new Re.G})))}}var ft=n(3108);function pt(){return function(e){return e.lift(new mt)}}var mt=function(){function e(){}return e.prototype.call=function(e,t){return t.subscribe(new gt(e))},e}(),gt=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r.C6(t,e),t.prototype._next=function(e){},t}(p.v);function yt(){return function(e){return e.lift(new vt)}}var vt=function(){function e(){}return e.prototype.call=function(e,t){return t.subscribe(new bt(e))},e}(),bt=function(e){function t(t){return e.call(this,t)||this}return r.C6(t,e),t.prototype.notifyComplete=function(e){var t=this.destination;t.next(e),t.complete()},t.prototype._next=function(e){this.notifyComplete(!1)},t.prototype._complete=function(){this.notifyComplete(!0)},t}(p.v);function wt(e){return function(t){return 0===e?(0,Ve.I)():t.lift(new _t(e))}}var _t=function(){function e(e){if(this.total=e,this.total<0)throw new Oe.k}return e.prototype.call=function(e,t){return t.subscribe(new It(e,this.total))},e}(),It=function(e){function t(t,n){var r=e.call(this,t)||this;return r.total=n,r.ring=new Array,r.count=0,r}return r.C6(t,e),t.prototype._next=function(e){var t=this.ring,n=this.total,r=this.count++;t.length<n?t.push(e):t[r%n]=e},t.prototype._complete=function(){var e=this.destination,t=this.count;if(t>0)for(var n=this.count>=this.total?this.total:this.count,r=this.ring,i=0;i<n;i++){var s=t++%n;e.next(r[s])}e.complete()},t}(p.v);function Et(e,t){var n=arguments.length>=2;return function(r){return r.pipe(e?(0,De.p)((function(t,n){return e(t,n,r)})):ht.D,wt(1),n?oe(t):Pe((function(){return new Re.G})))}}function Tt(e){return function(t){return t.lift(new St(e))}}var St=function(){function e(e){this.value=e}return e.prototype.call=function(e,t){return t.subscribe(new Ct(e,this.value))},e}(),Ct=function(e){function t(t,n){var r=e.call(this,t)||this;return r.value=n,r}return r.C6(t,e),t.prototype._next=function(e){this.destination.next(this.value)},t}(p.v);function At(){return function(e){return e.lift(new xt)}}var xt=function(){function e(){}return e.prototype.call=function(e,t){return t.subscribe(new kt(e))},e}(),kt=function(e){function t(t){return e.call(this,t)||this}return r.C6(t,e),t.prototype._next=function(e){this.destination.next(le.E.createNext(e))},t.prototype._error=function(e){var t=this.destination;t.next(le.E.createError(e)),t.complete()},t.prototype._complete=function(){var e=this.destination;e.next(le.E.createComplete()),e.complete()},t}(p.v);function Nt(e,t){var n=!1;return arguments.length>=2&&(n=!0),function(r){return r.lift(new Ot(e,t,n))}}var Ot=function(){function e(e,t,n){void 0===n&&(n=!1),this.accumulator=e,this.seed=t,this.hasSeed=n}return e.prototype.call=function(e,t){return t.subscribe(new Dt(e,this.accumulator,this.seed,this.hasSeed))},e}(),Dt=function(e){function t(t,n,r,i){var s=e.call(this,t)||this;return s.accumulator=n,s._seed=r,s.hasSeed=i,s.index=0,s}return r.C6(t,e),Object.defineProperty(t.prototype,"seed",{get:function(){return this._seed},set:function(e){this.hasSeed=!0,this._seed=e},enumerable:!0,configurable:!0}),t.prototype._next=function(e){if(this.hasSeed)return this._tryNext(e);this.seed=e,this.destination.next(e)},t.prototype._tryNext=function(e){var t,n=this.index++;try{t=this.accumulator(this.seed,e,n)}catch(e){this.destination.error(e)}this.seed=t,this.destination.next(t)},t}(p.v),Rt=n(6833);function Pt(e,t){return arguments.length>=2?function(n){return(0,Rt.F)(Nt(e,t),wt(1),oe(t))(n)}:function(t){return(0,Rt.F)(Nt((function(t,n,r){return e(t,n,r+1)})),wt(1))(t)}}function Lt(e){return Pt("function"==typeof e?function(t,n){return e(t,n)>0?t:n}:function(e,t){return e>t?e:t})}var Mt=n(3767);function Ft(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t){return t.lift.call(Mt.h.apply(void 0,[t].concat(e)))}}var Vt=n(6723);function Ut(e,t,n){return void 0===n&&(n=Number.POSITIVE_INFINITY),"function"==typeof t?(0,$.ZZ)((function(){return e}),t,n):("number"==typeof t&&(n=t),(0,$.ZZ)((function(){return e}),n))}function jt(e,t,n){return void 0===n&&(n=Number.POSITIVE_INFINITY),function(r){return r.lift(new Bt(e,t,n))}}var Bt=function(){function e(e,t,n){this.accumulator=e,this.seed=t,this.concurrent=n}return e.prototype.call=function(e,t){return t.subscribe(new qt(e,this.accumulator,this.seed,this.concurrent))},e}(),qt=function(e){function t(t,n,r,i){var s=e.call(this,t)||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.C6(t,e),t.prototype._next=function(e){if(this.active<this.concurrent){var t=this.index++,n=this.destination,r=void 0;try{r=(0,this.accumulator)(this.acc,e,t)}catch(e){return n.error(e)}this.active++,this._innerSub(r)}else this.buffer.push(e)},t.prototype._innerSub=function(e){var t=new i.zA(this),n=this.destination;n.add(t);var r=(0,i.tS)(e,t);r!==t&&n.add(r)},t.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()},t.prototype.notifyNext=function(e){var t=this.destination;this.acc=e,this.hasValue=!0,t.next(e)},t.prototype.notifyComplete=function(){var e=this.buffer;this.active--,e.length>0?this._next(e.shift()):0===this.active&&this.hasCompleted&&(!1===this.hasValue&&this.destination.next(this.acc),this.destination.complete())},t}(i.gn);function zt(e){return Pt("function"==typeof e?function(t,n){return e(t,n)<0?t:n}:function(e,t){return e<t?e:t})}var Gt=n(4491);function Kt(e,t){return function(n){var r;if(r="function"==typeof e?e:function(){return e},"function"==typeof t)return n.lift(new Wt(r,t));var i=Object.create(n,Gt.f);return i.source=n,i.subjectFactory=r,i}}var Wt=function(){function e(e,t){this.subjectFactory=e,this.selector=t}return e.prototype.call=function(e,t){var n=this.selector,r=this.subjectFactory(),i=n(r).subscribe(e);return i.add(t.subscribe(r)),i},e}(),$t=n(3947);function Ht(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return 1===e.length&&(0,B.c)(e[0])&&(e=e[0]),function(t){return t.lift(new Qt(e))}}var Qt=function(){function e(e){this.nextSources=e}return e.prototype.call=function(e,t){return t.subscribe(new Jt(e,this.nextSources))},e}(),Jt=function(e){function t(t,n){var r=e.call(this,t)||this;return r.destination=t,r.nextSources=n,r}return r.C6(t,e),t.prototype.notifyError=function(){this.subscribeToNextSource()},t.prototype.notifyComplete=function(){this.subscribeToNextSource()},t.prototype._error=function(e){this.subscribeToNextSource(),this.unsubscribe()},t.prototype._complete=function(){this.subscribeToNextSource(),this.unsubscribe()},t.prototype.subscribeToNextSource=function(){var e=this.nextSources.shift();if(e){var t=new i.zA(this),n=this.destination;n.add(t);var r=(0,i.tS)(e,t);r!==t&&n.add(r)}else this.destination.complete()},t}(i.gn);function Yt(){return function(e){return e.lift(new Xt)}}var Xt=function(){function e(){}return e.prototype.call=function(e,t){return t.subscribe(new Zt(e))},e}(),Zt=function(e){function t(t){var n=e.call(this,t)||this;return n.hasPrev=!1,n}return r.C6(t,e),t.prototype._next=function(e){var t;this.hasPrev?t=[this.prev,e]:this.hasPrev=!0,this.prev=e,t&&this.destination.next(t)},t}(p.v),en=n(3428);function tn(e,t){return function(n){return[(0,De.p)(e,t)(n),(0,De.p)((0,en.A)(e,t))(n)]}}function nn(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e.length;if(0===n)throw new Error("list of properties cannot be empty.");return function(t){return(0,Ye.T)(function(e,t){return function(n){for(var r=n,i=0;i<t;i++){var s=null!=r?r[e[i]]:void 0;if(void 0===s)return;r=s}return r}}(e,n))(t)}}var rn=n(6988);function sn(e){return e?Kt((function(){return new rn.B7}),e):Kt(new rn.B7)}var on=n(2430);function an(e){return function(t){return Kt(new on.t(e))(t)}}var cn=n(1934);function un(){return function(e){return Kt(new cn.h)(e)}}var ln=n(8977);function hn(e,t,n,r){n&&"function"!=typeof n&&(r=n);var i="function"==typeof n?n:void 0,s=new ln.m(e,t,r);return function(e){return Kt((function(){return s}),i)(e)}}var dn=n(8071);function fn(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t){return 1===e.length&&(0,B.c)(e[0])&&(e=e[0]),t.lift.call(dn.O4.apply(void 0,[t].concat(e)))}}function pn(e){return void 0===e&&(e=-1),function(t){return 0===e?(0,Ve.I)():e<0?t.lift(new mn(-1,t)):t.lift(new mn(e-1,t))}}var mn=function(){function e(e,t){this.count=e,this.source=t}return e.prototype.call=function(e,t){return t.subscribe(new gn(e,this.count,this.source))},e}(),gn=function(e){function t(t,n,r){var i=e.call(this,t)||this;return i.count=n,i.source=r,i}return r.C6(t,e),t.prototype.complete=function(){if(!this.isStopped){var t=this.source,n=this.count;if(0===n)return e.prototype.complete.call(this);n>-1&&(this.count=n-1),t.subscribe(this._unsubscribeAndRecycle())}},t}(p.v);function yn(e){return function(t){return t.lift(new vn(e))}}var vn=function(){function e(e){this.notifier=e}return e.prototype.call=function(e,t){return t.subscribe(new bn(e,this.notifier,t))},e}(),bn=function(e){function t(t,n,r){var i=e.call(this,t)||this;return i.notifier=n,i.source=r,i.sourceIsBeingSubscribedTo=!0,i}return r.C6(t,e),t.prototype.notifyNext=function(){this.sourceIsBeingSubscribedTo=!0,this.source.subscribe(this)},t.prototype.notifyComplete=function(){if(!1===this.sourceIsBeingSubscribedTo)return e.prototype.complete.call(this)},t.prototype.complete=function(){if(this.sourceIsBeingSubscribedTo=!1,!this.isStopped){if(this.retries||this.subscribeToRetries(),!this.retriesSubscription||this.retriesSubscription.closed)return e.prototype.complete.call(this);this._unsubscribeAndRecycle(),this.notifications.next(void 0)}},t.prototype._unsubscribe=function(){var e=this.notifications,t=this.retriesSubscription;e&&(e.unsubscribe(),this.notifications=void 0),t&&(t.unsubscribe(),this.retriesSubscription=void 0),this.retries=void 0},t.prototype._unsubscribeAndRecycle=function(){var t=this._unsubscribe;return this._unsubscribe=null,e.prototype._unsubscribeAndRecycle.call(this),this._unsubscribe=t,this},t.prototype.subscribeToRetries=function(){var t;this.notifications=new rn.B7;try{t=(0,this.notifier)(this.notifications)}catch(t){return e.prototype.complete.call(this)}this.retries=t,this.retriesSubscription=(0,i.tS)(t,new i.zA(this))},t}(i.gn);function wn(e){return void 0===e&&(e=-1),function(t){return t.lift(new _n(e,t))}}var _n=function(){function e(e,t){this.count=e,this.source=t}return e.prototype.call=function(e,t){return t.subscribe(new In(e,this.count,this.source))},e}(),In=function(e){function t(t,n,r){var i=e.call(this,t)||this;return i.count=n,i.source=r,i}return r.C6(t,e),t.prototype.error=function(t){if(!this.isStopped){var n=this.source,r=this.count;if(0===r)return e.prototype.error.call(this,t);r>-1&&(this.count=r-1),n.subscribe(this._unsubscribeAndRecycle())}},t}(p.v);function En(e){return function(t){return t.lift(new Tn(e,t))}}var Tn=function(){function e(e,t){this.notifier=e,this.source=t}return e.prototype.call=function(e,t){return t.subscribe(new Sn(e,this.notifier,this.source))},e}(),Sn=function(e){function t(t,n,r){var i=e.call(this,t)||this;return i.notifier=n,i.source=r,i}return r.C6(t,e),t.prototype.error=function(t){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 rn.B7;try{r=(0,this.notifier)(n)}catch(t){return e.prototype.error.call(this,t)}s=(0,i.tS)(r,new i.zA(this))}this._unsubscribeAndRecycle(),this.errors=n,this.retries=r,this.retriesSubscription=s,n.next(t)}},t.prototype._unsubscribe=function(){var e=this.errors,t=this.retriesSubscription;e&&(e.unsubscribe(),this.errors=void 0),t&&(t.unsubscribe(),this.retriesSubscription=void 0),this.retries=void 0},t.prototype.notifyNext=function(){var e=this._unsubscribe;this._unsubscribe=null,this._unsubscribeAndRecycle(),this._unsubscribe=e,this.source.subscribe(this)},t}(i.gn),Cn=n(1764);function An(e){return function(t){return t.lift(new xn(e))}}var xn=function(){function e(e){this.notifier=e}return e.prototype.call=function(e,t){var n=new kn(e),r=t.subscribe(n);return r.add((0,i.tS)(this.notifier,new i.zA(n))),r},e}(),kn=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.hasValue=!1,t}return r.C6(t,e),t.prototype._next=function(e){this.value=e,this.hasValue=!0},t.prototype.notifyNext=function(){this.emitValue()},t.prototype.notifyComplete=function(){this.emitValue()},t.prototype.emitValue=function(){this.hasValue&&(this.hasValue=!1,this.destination.next(this.value))},t}(i.gn);function Nn(e,t){return void 0===t&&(t=c.b),function(n){return n.lift(new On(e,t))}}var On=function(){function e(e,t){this.period=e,this.scheduler=t}return e.prototype.call=function(e,t){return t.subscribe(new Dn(e,this.period,this.scheduler))},e}(),Dn=function(e){function t(t,n,r){var i=e.call(this,t)||this;return i.period=n,i.scheduler=r,i.hasValue=!1,i.add(r.schedule(Rn,n,{subscriber:i,period:n})),i}return r.C6(t,e),t.prototype._next=function(e){this.lastValue=e,this.hasValue=!0},t.prototype.notifyNext=function(){this.hasValue&&(this.hasValue=!1,this.destination.next(this.lastValue))},t}(p.v);function Rn(e){var t=e.subscriber,n=e.period;t.notifyNext(),this.schedule(e,n)}function Pn(e,t){return function(n){return n.lift(new Ln(e,t))}}var Ln=function(){function e(e,t){this.compareTo=e,this.comparator=t}return e.prototype.call=function(e,t){return t.subscribe(new Mn(e,this.compareTo,this.comparator))},e}(),Mn=function(e){function t(t,n,r){var i=e.call(this,t)||this;return i.compareTo=n,i.comparator=r,i._a=[],i._b=[],i._oneComplete=!1,i.destination.add(n.subscribe(new Fn(t,i))),i}return r.C6(t,e),t.prototype._next=function(e){this._oneComplete&&0===this._b.length?this.emit(!1):(this._a.push(e),this.checkValues())},t.prototype._complete=function(){this._oneComplete?this.emit(0===this._a.length&&0===this._b.length):this._oneComplete=!0,this.unsubscribe()},t.prototype.checkValues=function(){for(var e=this,t=e._a,n=e._b,r=e.comparator;t.length>0&&n.length>0;){var i=t.shift(),s=n.shift(),o=!1;try{o=r?r(i,s):i===s}catch(e){this.destination.error(e)}o||this.emit(!1)}},t.prototype.emit=function(e){var t=this.destination;t.next(e),t.complete()},t.prototype.nextB=function(e){this._oneComplete&&0===this._a.length?this.emit(!1):(this._b.push(e),this.checkValues())},t.prototype.completeB=function(){this._oneComplete?this.emit(0===this._a.length&&0===this._b.length):this._oneComplete=!0},t}(p.v),Fn=function(e){function t(t,n){var r=e.call(this,t)||this;return r.parent=n,r}return r.C6(t,e),t.prototype._next=function(e){this.parent.nextB(e)},t.prototype._error=function(e){this.parent.error(e),this.unsubscribe()},t.prototype._complete=function(){this.parent.completeB(),this.unsubscribe()},t}(p.v);function Vn(){return new rn.B7}function Un(){return function(e){return(0,Cn.B)()(Kt(Vn)(e))}}function jn(e,t,n){var r;return r=e&&"object"==typeof e?e:{bufferSize:e,windowTime:t,refCount:!1,scheduler:n},function(e){return e.lift(function(e){var t,n,r=e.bufferSize,i=void 0===r?Number.POSITIVE_INFINITY:r,s=e.windowTime,o=void 0===s?Number.POSITIVE_INFINITY:s,a=e.refCount,c=e.scheduler,u=0,l=!1,h=!1;return function(e){var r;u++,!t||l?(l=!1,t=new ln.m(i,o,c),r=t.subscribe(this),n=e.subscribe({next:function(e){t.next(e)},error:function(e){l=!0,t.error(e)},complete:function(){h=!0,n=void 0,t.complete()}})):r=t.subscribe(this),this.add((function(){u--,r.unsubscribe(),n&&!h&&a&&0===u&&(n.unsubscribe(),n=void 0,t=void 0)}))}}(r))}}function Bn(e){return function(t){return t.lift(new qn(e,t))}}var qn=function(){function e(e,t){this.predicate=e,this.source=t}return e.prototype.call=function(e,t){return t.subscribe(new zn(e,this.predicate,this.source))},e}(),zn=function(e){function t(t,n,r){var i=e.call(this,t)||this;return i.predicate=n,i.source=r,i.seenValue=!1,i.index=0,i}return r.C6(t,e),t.prototype.applySingleValue=function(e){this.seenValue?this.destination.error("Sequence contains more than one element"):(this.seenValue=!0,this.singleValue=e)},t.prototype._next=function(e){var t=this.index++;this.predicate?this.tryNext(e,t):this.applySingleValue(e)},t.prototype.tryNext=function(e,t){try{this.predicate(e,t,this.source)&&this.applySingleValue(e)}catch(e){this.destination.error(e)}},t.prototype._complete=function(){var e=this.destination;this.index>0?(e.next(this.seenValue?this.singleValue:void 0),e.complete()):e.error(new Re.G)},t}(p.v);function Gn(e){return function(t){return t.lift(new Kn(e))}}var Kn=function(){function e(e){this.total=e}return e.prototype.call=function(e,t){return t.subscribe(new Wn(e,this.total))},e}(),Wn=function(e){function t(t,n){var r=e.call(this,t)||this;return r.total=n,r.count=0,r}return r.C6(t,e),t.prototype._next=function(e){++this.count>this.total&&this.destination.next(e)},t}(p.v);function $n(e){return function(t){return t.lift(new Hn(e))}}var Hn=function(){function e(e){if(this._skipCount=e,this._skipCount<0)throw new Oe.k}return e.prototype.call=function(e,t){return 0===this._skipCount?t.subscribe(new p.v(e)):t.subscribe(new Qn(e,this._skipCount))},e}(),Qn=function(e){function t(t,n){var r=e.call(this,t)||this;return r._skipCount=n,r._count=0,r._ring=new Array(n),r}return r.C6(t,e),t.prototype._next=function(e){var t=this._skipCount,n=this._count++;if(n<t)this._ring[n]=e;else{var r=n%t,i=this._ring,s=i[r];i[r]=e,this.destination.next(s)}},t}(p.v);function Jn(e){return function(t){return t.lift(new Yn(e))}}var Yn=function(){function e(e){this.notifier=e}return e.prototype.call=function(e,t){return t.subscribe(new Xn(e,this.notifier))},e}(),Xn=function(e){function t(t,n){var r=e.call(this,t)||this;r.hasValue=!1;var s=new i.zA(r);r.add(s),r.innerSubscription=s;var o=(0,i.tS)(n,s);return o!==s&&(r.add(o),r.innerSubscription=o),r}return r.C6(t,e),t.prototype._next=function(t){this.hasValue&&e.prototype._next.call(this,t)},t.prototype.notifyNext=function(){this.hasValue=!0,this.innerSubscription&&this.innerSubscription.unsubscribe()},t.prototype.notifyComplete=function(){},t}(i.gn);function Zn(e){return function(t){return t.lift(new er(e))}}var er=function(){function e(e){this.predicate=e}return e.prototype.call=function(e,t){return t.subscribe(new tr(e,this.predicate))},e}(),tr=function(e){function t(t,n){var r=e.call(this,t)||this;return r.predicate=n,r.skipping=!0,r.index=0,r}return r.C6(t,e),t.prototype._next=function(e){var t=this.destination;this.skipping&&this.tryCallPredicate(e),this.skipping||t.next(e)},t.prototype.tryCallPredicate=function(e){try{var t=this.predicate(e,this.index++);this.skipping=Boolean(t)}catch(e){this.destination.error(e)}},t}(p.v);function nr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e[e.length-1];return(0,b.m)(n)?(e.pop(),function(t){return(0,G.x)(e,t,n)}):function(t){return(0,G.x)(e,t)}}var rr=n(9081),ir=n(6290),sr=function(e){function t(t,n,r){void 0===n&&(n=0),void 0===r&&(r=rr.I);var i=e.call(this)||this;return i.source=t,i.delayTime=n,i.scheduler=r,(!(0,ir.k)(n)||n<0)&&(i.delayTime=0),r&&"function"==typeof r.schedule||(i.scheduler=rr.I),i}return r.C6(t,e),t.create=function(e,n,r){return void 0===n&&(n=0),void 0===r&&(r=rr.I),new t(e,n,r)},t.dispatch=function(e){var t=e.source,n=e.subscriber;return this.add(t.subscribe(n))},t.prototype._subscribe=function(e){var n=this.delayTime,r=this.source;return this.scheduler.schedule(t.dispatch,n,{source:r,subscriber:e})},t}(me.c);function or(e,t){return void 0===t&&(t=0),function(n){return n.lift(new ar(e,t))}}var ar=function(){function e(e,t){this.scheduler=e,this.delay=t}return e.prototype.call=function(e,t){return new sr(t,this.delay,this.scheduler).subscribe(e)},e}();function cr(e,t){return"function"==typeof t?function(n){return n.pipe(cr((function(n,r){return(0,q.H)(e(n,r)).pipe((0,Ye.T)((function(e,i){return t(n,e,r,i)})))})))}:function(t){return t.lift(new ur(e))}}var ur=function(){function e(e){this.project=e}return e.prototype.call=function(e,t){return t.subscribe(new lr(e,this.project))},e}(),lr=function(e){function t(t,n){var r=e.call(this,t)||this;return r.project=n,r.index=0,r}return r.C6(t,e),t.prototype._next=function(e){var t,n=this.index++;try{t=this.project(e,n)}catch(e){return void this.destination.error(e)}this._innerSub(t)},t.prototype._innerSub=function(e){var t=this.innerSubscription;t&&t.unsubscribe();var n=new i.zA(this),r=this.destination;r.add(n),this.innerSubscription=(0,i.tS)(e,n),this.innerSubscription!==n&&r.add(this.innerSubscription)},t.prototype._complete=function(){var t=this.innerSubscription;t&&!t.closed||e.prototype._complete.call(this),this.unsubscribe()},t.prototype._unsubscribe=function(){this.innerSubscription=void 0},t.prototype.notifyComplete=function(){this.innerSubscription=void 0,this.isStopped&&e.prototype._complete.call(this)},t.prototype.notifyNext=function(e){this.destination.next(e)},t}(i.gn);function hr(){return cr(ht.D)}function dr(e,t){return t?cr((function(){return e}),t):cr((function(){return e}))}function fr(e){return function(t){return t.lift(new pr(e))}}var pr=function(){function e(e){this.notifier=e}return e.prototype.call=function(e,t){var n=new mr(e),r=(0,i.tS)(this.notifier,new i.zA(n));return r&&!n.seenValue?(n.add(r),t.subscribe(n)):n},e}(),mr=function(e){function t(t){var n=e.call(this,t)||this;return n.seenValue=!1,n}return r.C6(t,e),t.prototype.notifyNext=function(){this.seenValue=!0,this.complete()},t.prototype.notifyComplete=function(){},t}(i.gn);function gr(e,t){return void 0===t&&(t=!1),function(n){return n.lift(new yr(e,t))}}var yr=function(){function e(e,t){this.predicate=e,this.inclusive=t}return e.prototype.call=function(e,t){return t.subscribe(new vr(e,this.predicate,this.inclusive))},e}(),vr=function(e){function t(t,n,r){var i=e.call(this,t)||this;return i.predicate=n,i.inclusive=r,i.index=0,i}return r.C6(t,e),t.prototype._next=function(e){var t,n=this.destination;try{t=this.predicate(e,this.index++)}catch(e){return void n.error(e)}this.nextOrComplete(e,t)},t.prototype.nextOrComplete=function(e,t){var n=this.destination;Boolean(t)?n.next(e):(this.inclusive&&n.next(e),n.complete())},t}(p.v),br=n(1193),wr=n(9029);function _r(e,t,n){return function(r){return r.lift(new Ir(e,t,n))}}var Ir=function(){function e(e,t,n){this.nextOrObserver=e,this.error=t,this.complete=n}return e.prototype.call=function(e,t){return t.subscribe(new Er(e,this.nextOrObserver,this.error,this.complete))},e}(),Er=function(e){function t(t,n,r,i){var s=e.call(this,t)||this;return s._tapNext=br.l,s._tapError=br.l,s._tapComplete=br.l,s._tapError=r||br.l,s._tapComplete=i||br.l,(0,wr.T)(n)?(s._context=s,s._tapNext=n):n&&(s._context=n,s._tapNext=n.next||br.l,s._tapError=n.error||br.l,s._tapComplete=n.complete||br.l),s}return r.C6(t,e),t.prototype._next=function(e){try{this._tapNext.call(this._context,e)}catch(e){return void this.destination.error(e)}this.destination.next(e)},t.prototype._error=function(e){try{this._tapError.call(this._context,e)}catch(e){return void this.destination.error(e)}this.destination.error(e)},t.prototype._complete=function(){try{this._tapComplete.call(this._context)}catch(e){return void this.destination.error(e)}return this.destination.complete()},t}(p.v),Tr={leading:!0,trailing:!1};function Sr(e,t){return void 0===t&&(t=Tr),function(n){return n.lift(new Cr(e,!!t.leading,!!t.trailing))}}var Cr=function(){function e(e,t,n){this.durationSelector=e,this.leading=t,this.trailing=n}return e.prototype.call=function(e,t){return t.subscribe(new Ar(e,this.durationSelector,this.leading,this.trailing))},e}(),Ar=function(e){function t(t,n,r,i){var s=e.call(this,t)||this;return s.destination=t,s.durationSelector=n,s._leading=r,s._trailing=i,s._hasValue=!1,s}return r.C6(t,e),t.prototype._next=function(e){this._hasValue=!0,this._sendValue=e,this._throttled||(this._leading?this.send():this.throttle(e))},t.prototype.send=function(){var e=this._hasValue,t=this._sendValue;e&&(this.destination.next(t),this.throttle(t)),this._hasValue=!1,this._sendValue=void 0},t.prototype.throttle=function(e){var t=this.tryDurationSelector(e);t&&this.add(this._throttled=(0,i.tS)(t,new i.zA(this)))},t.prototype.tryDurationSelector=function(e){try{return this.durationSelector(e)}catch(e){return this.destination.error(e),null}},t.prototype.throttlingDone=function(){var e=this._throttled,t=this._trailing;e&&e.unsubscribe(),this._throttled=void 0,t&&this.send()},t.prototype.notifyNext=function(){this.throttlingDone()},t.prototype.notifyComplete=function(){this.throttlingDone()},t}(i.gn);function xr(e,t,n){return void 0===t&&(t=c.b),void 0===n&&(n=Tr),function(r){return r.lift(new kr(e,t,n.leading,n.trailing))}}var kr=function(){function e(e,t,n,r){this.duration=e,this.scheduler=t,this.leading=n,this.trailing=r}return e.prototype.call=function(e,t){return t.subscribe(new Nr(e,this.duration,this.scheduler,this.leading,this.trailing))},e}(),Nr=function(e){function t(t,n,r,i,s){var o=e.call(this,t)||this;return o.duration=n,o.scheduler=r,o.leading=i,o.trailing=s,o._hasTrailingValue=!1,o._trailingValue=null,o}return r.C6(t,e),t.prototype._next=function(e){this.throttled?this.trailing&&(this._trailingValue=e,this._hasTrailingValue=!0):(this.add(this.throttled=this.scheduler.schedule(Or,this.duration,{subscriber:this})),this.leading?this.destination.next(e):this.trailing&&(this._trailingValue=e,this._hasTrailingValue=!0))},t.prototype._complete=function(){this._hasTrailingValue?(this.destination.next(this._trailingValue),this.destination.complete()):this.destination.complete()},t.prototype.clearThrottle=function(){var e=this.throttled;e&&(this.trailing&&this._hasTrailingValue&&(this.destination.next(this._trailingValue),this._trailingValue=null,this._hasTrailingValue=!1),e.unsubscribe(),this.remove(e),this.throttled=null)},t}(p.v);function Or(e){e.subscriber.clearThrottle()}var Dr=n(560);function Rr(e){return void 0===e&&(e=c.b),function(t){return(0,Dr.v)((function(){return t.pipe(Nt((function(t,n){var r=t.current;return{value:n,current:e.now(),last:r}}),{current:e.now(),value:void 0,last:void 0}),(0,Ye.T)((function(e){var t=e.current,n=e.last,r=e.value;return new Pr(r,t-n)})))}))}}var Pr=function(){return function(e,t){this.value=e,this.interval=t}}(),Lr=n(34);function Mr(e,t,n){return void 0===n&&(n=c.b),function(r){var i=ue(e),s=i?+e-n.now():Math.abs(e);return r.lift(new Fr(s,i,t,n))}}var Fr=function(){function e(e,t,n,r){this.waitFor=e,this.absoluteTimeout=t,this.withObservable=n,this.scheduler=r}return e.prototype.call=function(e,t){return t.subscribe(new Vr(e,this.absoluteTimeout,this.waitFor,this.withObservable,this.scheduler))},e}(),Vr=function(e){function t(t,n,r,i,s){var o=e.call(this,t)||this;return o.absoluteTimeout=n,o.waitFor=r,o.withObservable=i,o.scheduler=s,o.scheduleTimeout(),o}return r.C6(t,e),t.dispatchTimeout=function(e){var t=e.withObservable;e._unsubscribeAndRecycle(),e.add((0,i.tS)(t,new i.zA(e)))},t.prototype.scheduleTimeout=function(){var e=this.action;e?this.action=e.schedule(this,this.waitFor):this.add(this.action=this.scheduler.schedule(t.dispatchTimeout,this.waitFor,this))},t.prototype._next=function(t){this.absoluteTimeout||this.scheduleTimeout(),e.prototype._next.call(this,t)},t.prototype._unsubscribe=function(){this.action=void 0,this.scheduler=null,this.withObservable=null},t}(i.gn),Ur=n(7404);function jr(e,t){return void 0===t&&(t=c.b),Mr(e,(0,Ur.$)(new Lr.M),t)}function Br(e){return void 0===e&&(e=c.b),(0,Ye.T)((function(t){return new qr(t,e.now())}))}var qr=function(){return function(e,t){this.value=e,this.timestamp=t}}();function zr(e,t,n){return 0===n?[t]:(e.push(t),e)}function Gr(){return Pt(zr,[])}function Kr(e){return function(t){return t.lift(new Wr(e))}}var Wr=function(){function e(e){this.windowBoundaries=e}return e.prototype.call=function(e,t){var n=new $r(e),r=t.subscribe(n);return r.closed||n.add((0,i.tS)(this.windowBoundaries,new i.zA(n))),r},e}(),$r=function(e){function t(t){var n=e.call(this,t)||this;return n.window=new rn.B7,t.next(n.window),n}return r.C6(t,e),t.prototype.notifyNext=function(){this.openWindow()},t.prototype.notifyError=function(e){this._error(e)},t.prototype.notifyComplete=function(){this._complete()},t.prototype._next=function(e){this.window.next(e)},t.prototype._error=function(e){this.window.error(e),this.destination.error(e)},t.prototype._complete=function(){this.window.complete(),this.destination.complete()},t.prototype._unsubscribe=function(){this.window=null},t.prototype.openWindow=function(){var e=this.window;e&&e.complete();var t=this.destination,n=this.window=new rn.B7;t.next(n)},t}(i.gn);function Hr(e,t){return void 0===t&&(t=0),function(n){return n.lift(new Qr(e,t))}}var Qr=function(){function e(e,t){this.windowSize=e,this.startWindowEvery=t}return e.prototype.call=function(e,t){return t.subscribe(new Jr(e,this.windowSize,this.startWindowEvery))},e}(),Jr=function(e){function t(t,n,r){var i=e.call(this,t)||this;return i.destination=t,i.windowSize=n,i.startWindowEvery=r,i.windows=[new rn.B7],i.count=0,t.next(i.windows[0]),i}return r.C6(t,e),t.prototype._next=function(e){for(var t=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(e);var a=this.count-r+1;if(a>=0&&a%t==0&&!this.closed&&i.shift().complete(),++this.count%t==0&&!this.closed){var c=new rn.B7;i.push(c),n.next(c)}},t.prototype._error=function(e){var t=this.windows;if(t)for(;t.length>0&&!this.closed;)t.shift().error(e);this.destination.error(e)},t.prototype._complete=function(){var e=this.windows;if(e)for(;e.length>0&&!this.closed;)e.shift().complete();this.destination.complete()},t.prototype._unsubscribe=function(){this.count=0,this.windows=null},t}(p.v);function Yr(e){var t=c.b,n=null,r=Number.POSITIVE_INFINITY;return(0,b.m)(arguments[3])&&(t=arguments[3]),(0,b.m)(arguments[2])?t=arguments[2]:(0,ir.k)(arguments[2])&&(r=Number(arguments[2])),(0,b.m)(arguments[1])?t=arguments[1]:(0,ir.k)(arguments[1])&&(n=Number(arguments[1])),function(i){return i.lift(new Xr(e,n,r,t))}}var Xr=function(){function e(e,t,n,r){this.windowTimeSpan=e,this.windowCreationInterval=t,this.maxWindowSize=n,this.scheduler=r}return e.prototype.call=function(e,t){return t.subscribe(new ei(e,this.windowTimeSpan,this.windowCreationInterval,this.maxWindowSize,this.scheduler))},e}(),Zr=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._numberOfNextedValues=0,t}return r.C6(t,e),t.prototype.next=function(t){this._numberOfNextedValues++,e.prototype.next.call(this,t)},Object.defineProperty(t.prototype,"numberOfNextedValues",{get:function(){return this._numberOfNextedValues},enumerable:!0,configurable:!0}),t}(rn.B7),ei=function(e){function t(t,n,r,i,s){var o=e.call(this,t)||this;o.destination=t,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(ri,n,c)),o.add(s.schedule(ni,r,u))}else{var l={subscriber:o,window:a,windowTimeSpan:n};o.add(s.schedule(ti,n,l))}return o}return r.C6(t,e),t.prototype._next=function(e){for(var t=this.windows,n=t.length,r=0;r<n;r++){var i=t[r];i.closed||(i.next(e),i.numberOfNextedValues>=this.maxWindowSize&&this.closeWindow(i))}},t.prototype._error=function(e){for(var t=this.windows;t.length>0;)t.shift().error(e);this.destination.error(e)},t.prototype._complete=function(){for(var e=this.windows;e.length>0;){var t=e.shift();t.closed||t.complete()}this.destination.complete()},t.prototype.openWindow=function(){var e=new Zr;return this.windows.push(e),this.destination.next(e),e},t.prototype.closeWindow=function(e){e.complete();var t=this.windows;t.splice(t.indexOf(e),1)},t}(p.v);function ti(e){var t=e.subscriber,n=e.windowTimeSpan,r=e.window;r&&t.closeWindow(r),e.window=t.openWindow(),this.schedule(e,n)}function ni(e){var t=e.windowTimeSpan,n=e.subscriber,r=e.scheduler,i=e.windowCreationInterval,s=n.openWindow(),o=this,a={action:o,subscription:null},c={subscriber:n,window:s,context:a};a.subscription=r.schedule(ri,t,c),o.add(a.subscription),o.schedule(e,i)}function ri(e){var t=e.subscriber,n=e.window,r=e.context;r&&r.action&&r.subscription&&r.action.remove(r.subscription),t.closeWindow(n)}function ii(e,t){return function(n){return n.lift(new si(e,t))}}var si=function(){function e(e,t){this.openings=e,this.closingSelector=t}return e.prototype.call=function(e,t){return t.subscribe(new oi(e,this.openings,this.closingSelector))},e}(),oi=function(e){function t(t,n,r){var i=e.call(this,t)||this;return i.openings=n,i.closingSelector=r,i.contexts=[],i.add(i.openSubscription=(0,x.F)(i,n,n)),i}return r.C6(t,e),t.prototype._next=function(e){var t=this.contexts;if(t)for(var n=t.length,r=0;r<n;r++)t[r].window.next(e)},t.prototype._error=function(t){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(t),s.subscription.unsubscribe()}e.prototype._error.call(this,t)},t.prototype._complete=function(){var t=this.contexts;if(this.contexts=null,t)for(var n=t.length,r=-1;++r<n;){var i=t[r];i.window.complete(),i.subscription.unsubscribe()}e.prototype._complete.call(this)},t.prototype._unsubscribe=function(){var e=this.contexts;if(this.contexts=null,e)for(var t=e.length,n=-1;++n<t;){var r=e[n];r.window.unsubscribe(),r.subscription.unsubscribe()}},t.prototype.notifyNext=function(e,t,n,r,i){if(e===this.openings){var s=void 0;try{s=(0,this.closingSelector)(t)}catch(e){return this.error(e)}var o=new rn.B7,a=new A.y,c={window:o,subscription:a};this.contexts.push(c);var u=(0,x.F)(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(e))},t.prototype.notifyError=function(e){this.error(e)},t.prototype.notifyComplete=function(e){e!==this.openSubscription&&this.closeWindow(this.contexts.indexOf(e.context))},t.prototype.closeWindow=function(e){if(-1!==e){var t=this.contexts,n=t[e],r=n.window,i=n.subscription;t.splice(e,1),r.complete(),i.unsubscribe()}},t}(k.E);function ai(e){return function(t){return t.lift(new ci(e))}}var ci=function(){function e(e){this.closingSelector=e}return e.prototype.call=function(e,t){return t.subscribe(new ui(e,this.closingSelector))},e}(),ui=function(e){function t(t,n){var r=e.call(this,t)||this;return r.destination=t,r.closingSelector=n,r.openWindow(),r}return r.C6(t,e),t.prototype.notifyNext=function(e,t,n,r,i){this.openWindow(i)},t.prototype.notifyError=function(e){this._error(e)},t.prototype.notifyComplete=function(e){this.openWindow(e)},t.prototype._next=function(e){this.window.next(e)},t.prototype._error=function(e){this.window.error(e),this.destination.error(e),this.unsubscribeClosingNotification()},t.prototype._complete=function(){this.window.complete(),this.destination.complete(),this.unsubscribeClosingNotification()},t.prototype.unsubscribeClosingNotification=function(){this.closingNotification&&this.closingNotification.unsubscribe()},t.prototype.openWindow=function(e){void 0===e&&(e=null),e&&(this.remove(e),e.unsubscribe());var t=this.window;t&&t.complete();var n,r=this.window=new rn.B7;this.destination.next(r);try{n=(0,this.closingSelector)()}catch(e){return this.destination.error(e),void this.window.error(e)}this.add(this.closingNotification=(0,x.F)(this,n))},t}(k.E);function li(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t){var n;"function"==typeof e[e.length-1]&&(n=e.pop());var r=e;return t.lift(new hi(r,n))}}var hi=function(){function e(e,t){this.observables=e,this.project=t}return e.prototype.call=function(e,t){return t.subscribe(new di(e,this.observables,this.project))},e}(),di=function(e){function t(t,n,r){var i=e.call(this,t)||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,x.F)(i,a,void 0,o))}return i}return r.C6(t,e),t.prototype.notifyNext=function(e,t,n){this.values[n]=t;var r=this.toRespond;if(r.length>0){var i=r.indexOf(n);-1!==i&&r.splice(i,1)}},t.prototype.notifyComplete=function(){},t.prototype._next=function(e){if(0===this.toRespond.length){var t=[e].concat(this.values);this.project?this._tryProject(t):this.destination.next(t)}},t.prototype._tryProject=function(e){var t;try{t=this.project.apply(this,e)}catch(e){return void this.destination.error(e)}this.destination.next(t)},t}(k.E),fi=n(4219);function pi(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t){return t.lift.call(fi.yU.apply(void 0,[t].concat(e)))}}function mi(e){return function(t){return t.lift(new fi.ee(e))}}},7272:(e,t,n)=>{"use strict";n.d(t,{C6:()=>i});var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},r(e,t)};function i(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}},6032:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,s){function o(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,i,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=s(n(6765)),a=s(n(2733)),c=n(1673),u=n(1613),l=function(){function e(e){this.clientConfig=e,this.tokenStorageKey="RIO_TOKENS_KEY.".concat(e.projectId)}return e.prototype.setHttp=function(e){this.http=e},e.prototype.storeTokenData=function(e){return r(this,void 0,void 0,(function(){var t,n;return i(this,(function(r){return t=(0,c.getRuntime)(),void 0===e||(t===u.Runtime.web&&(localStorage.setItem(this.tokenStorageKey,JSON.stringify(e)),(null===(n=this.clientConfig)||void 0===n?void 0:n.useCookies)&&a.default.set(this.tokenStorageKey,JSON.stringify(e))),this.currentTokenData=e),[2]}))}))},e.prototype.clearTokenData=function(){return r(this,void 0,void 0,(function(){return i(this,(function(e){return(0,c.getRuntime)()===u.Runtime.web&&(localStorage.removeItem(this.tokenStorageKey),a.default.remove(this.tokenStorageKey)),this.currentTokenData=void 0,[2]}))}))},e.prototype.getCurrentTokenData=function(){return r(this,void 0,void 0,(function(){var e,t,n;return i(this,(function(r){return(0,c.getRuntime)()===u.Runtime.web?((null===(n=this.clientConfig)||void 0===n?void 0:n.useCookies)&&(t=a.default.get(this.tokenStorageKey))&&"undefined"!==t&&(e=JSON.parse(t)),e||(t=localStorage.getItem(this.tokenStorageKey))&&"undefined"!==t&&(e=JSON.parse(t))):e=this.currentTokenData,!e||e.accessTokenDecoded&&e.refreshTokenDecoded||(e.accessTokenDecoded=this.decodeToken(e.accessToken),e.refreshTokenDecoded=this.decodeToken(e.refreshToken)),[2,e]}))}))},e.prototype.getCurrentUser=function(){return r(this,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,this.getCurrentTokenData()];case 1:return[2,null==(e=t.sent())?void 0:e.accessTokenDecoded]}}))}))},e.prototype.getTokenData=function(){return r(this,void 0,void 0,(function(){var e,t,n,r,s,o;return i(this,(function(i){switch(i.label){case 0:return[4,this.getCurrentTokenData()];case 1:return(e=i.sent())?(t=e.diff+Math.round((new Date).getTime()/1e3)+30,e.accessTokenDecoded=this.decodeToken(e.accessToken),e.refreshTokenDecoded=this.decodeToken(e.refreshToken),n=null!==(s=e.accessTokenDecoded.exp)&&void 0!==s?s:0,(null!==(o=e.refreshTokenDecoded.exp)&&void 0!==o?o:0)>t&&n<=t?[4,this.getFreshToken(e.refreshToken,e.accessToken)]:[3,3]):[2,void 0];case 2:return(r=i.sent()).accessTokenDecoded=this.decodeToken(r.accessToken),r.refreshTokenDecoded=this.decodeToken(r.refreshToken),[2,r];case 3:return[2,e]}}))}))},e.prototype.decodeToken=function(e){return(0,o.default)(e)},e.prototype.formatTokenData=function(e){return e.accessTokenDecoded=this.decodeToken(e.accessToken),e.refreshTokenDecoded=this.decodeToken(e.refreshToken),e.accessTokenDecoded.iat&&(e.diff=e.accessTokenDecoded.iat-Math.floor(Date.now()/1e3)),e},e.prototype.getFreshToken=function(e,t){return r(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.http.call(this.clientConfig.projectId,"/TOKEN/refresh",{method:"post",data:{refreshToken:e,accessToken:t}})];case 1:return n=r.sent(),[2,this.formatTokenData(n.data)]}}))}))},e.prototype.signIn=function(e){return r(this,void 0,void 0,(function(){var t;return i(this,(function(n){switch(n.label){case 0:return[4,this.http.call(this.clientConfig.projectId,"/TOKEN/auth",{method:"post",data:{customToken:e}})];case 1:return t=n.sent().data,[2,this.formatTokenData(t)]}}))}))},e.prototype.signOut=function(){return r(this,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return t.trys.push([0,4,,5]),[4,this.getCurrentTokenData()];case 1:return(e=t.sent())?[4,this.http.call(this.clientConfig.projectId,"/TOKEN/signOut",{method:"post",headers:{Authorization:"Bearer ".concat(e.accessToken)}})]:[3,3];case 2:t.sent(),t.label=3;case 3:return[3,5];case 4:return t.sent(),[3,5];case 5:return[2]}}))}))},e.prototype.getAuthStatus=function(e){if(e&&e.accessTokenDecoded){var t=e.accessTokenDecoded;return{uid:t.userId,identity:t.identity,authStatus:u.RetterAuthStatus.SIGNED_IN}}return{authStatus:u.RetterAuthStatus.SIGNED_OUT}},e}();t.default=l},5281:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},r.apply(this,arguments)},i=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,s){function o(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((r=r.apply(e,t||[])).next())}))},s=this&&this.__generator||function(e,t){var n,r,i,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var a=o(n(6425)),c=n(1673),u=n(1613),l=[{id:u.RetterRegion.euWest1,url:"api.retter.io"},{id:u.RetterRegion.euWest1Beta,url:"test-api.retter.io"}],h=function(){function e(e){this.createAxiosInstance(),this.url=e.url,e.region||(e.region=u.RetterRegion.euWest1),this.region=l.find((function(t){return t.id===e.region})),this.culture=e.culture,this.platform=e.platform}return e.prototype.createAxiosInstance=function(){this.axiosInstance=a.default.create({responseType:"json",headers:{"Content-Type":"application/json"},timeout:3e4})},e.prototype.buildUrl=function(e,t){var n=this.url?"".concat(this.url):"".concat(e,".").concat(this.region.url);return"https://".concat(n,"/").concat(e,"/").concat(t.startsWith("/")?t.substr(1):t)},e.prototype.call=function(e,t,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((0,c.sort)(n.data))),delete n.data,i.data=o,i.__isbase64=!0),[4,this.axiosInstance(r(r({url:this.buildUrl(e,t)},n),{params:i}))];case 1:return[2,s.sent()];case 2:throw s.sent();case 3:return[2]}}))}))},e}();t.default=h},1673:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getRuntime=function(){return"undefined"!=typeof document?r.Runtime.web:r.Runtime.node},t.base64Encode=function(e){return Buffer.from(e).toString("base64")},t.sort=function e(t){return null==t?t:Array.isArray(t)?t.sort().map(e):"object"==typeof t?Object.keys(t).sort().reduce((function(n,r){return n[r]=e(t[r]),n}),{}):t};var r=n(1613)},8156:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},r.apply(this,arguments)},i=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),s=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,s){function o(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((r=r.apply(e,t||[])).next())}))},a=this&&this.__generator||function(e,t){var n,r,i,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var u=n(9815),l=n(5577),h=n(9815),d=n(5052),f=n(4046),p=n(5758),m=c(n(6032)),g=c(n(5281)),y=n(1613);s(n(1613),t);var v=function(){function e(){this.initialized=!1,this.authQueue=new f.Subject,this.actionQueue=new f.Subject,this.authStatusSubject=new f.ReplaySubject(1),this.cloudObjects=[],this.listeners={}}return e.getInstance=function(t){var n=e.instances.find((function(e){var n;return(null===(n=e.clientConfig)||void 0===n?void 0:n.projectId)===t.projectId}));if(n)return n;var r=new e;return r.init(t),e.instances.push(r),r},e.prototype.init=function(e){var t=this;if(this.initialized)throw new Error("SDK already initialized.");this.initialized=!0,e.retryConfig||(e.retryConfig={}),e.retryConfig.delay||(e.retryConfig.delay=50),e.retryConfig.count||(e.retryConfig.count=3),e.retryConfig.rate||(e.retryConfig.rate=1.5),this.clientConfig=e,this.auth=new m.default(e),this.http=new g.default(e),this.auth.setHttp(this.http),this.processAuthQueue(),this.processActionQueue(),setTimeout((function(){return o(t,void 0,void 0,(function(){var e;return a(this,(function(t){switch(t.label){case 0:return[4,this.auth.getCurrentTokenData()];case 1:return e=t.sent(),this.fireAuthStatus({tokenData:e}),[2]}}))}))}),1)},e.prototype.processAuthQueue=function(){var e=this,t=this.authQueue.pipe((0,p.concatMap)((function(t){return(0,f.defer)((function(){return o(e,void 0,void 0,(function(){var e,n;return a(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.auth.signIn(t.data)];case 1:return e=r.sent(),[2,{action:t,response:e}];case 2:throw n=r.sent(),{action:t,responseError:n};case 3:return[2]}}))}))})).pipe((0,p.materialize)())})),(0,p.share)());t.pipe((0,p.filter)((function(e){return e.hasValue&&"N"===e.kind})),(0,p.map)((function(e){var t;return r(r({},e.value),{tokenData:null===(t=e.value)||void 0===t?void 0:t.response})})),(0,p.switchMap)((function(t){return o(e,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,this.storeTokenData(t)];case 1:return e.sent(),[2,t]}}))}))})),(0,p.switchMap)((function(t){return o(e,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return this.firebaseAuth?[4,(0,d.signOut)(this.firebaseAuth)]:[3,2];case 1:e.sent(),e.label=2;case 2:return this.clearFirebase(),t.tokenData?[4,this.initFirebase(t)]:[3,4];case 3:e.sent(),e.label=4;case 4:return this.fireAuthStatus(t),[2,t]}}))}))}))).subscribe((function(t){var n,r;(null===(n=t.action)||void 0===n?void 0:n.resolve)&&t.action.resolve(null===(r=e.auth)||void 0===r?void 0:r.getAuthStatus(t.tokenData))})),t.pipe((0,p.filter)((function(e){return!1===e.hasValue&&"E"===e.kind}))).subscribe((function(e){var t;if(e.error&&e.error.action&&e.error.action.resolve){var n={authStatus:y.RetterAuthStatus.AUTH_FAILED,message:null===(t=e.error.responseError.response)||void 0===t?void 0:t.data};e.error.action.resolve(n)}})),this.authStatus.subscribe()},e.prototype.processActionQueue=function(){var e=this,t=this.actionQueue.asObservable().pipe((0,p.concatMap)(this.getActionWithTokenData.bind(this)),(0,p.tap)(this.fireAuthStatus.bind(this)),(0,p.filter)((function(e){return null!==e.tokenData})),(0,p.switchMap)((function(t){return o(e,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,this.storeTokenData(t)];case 1:return e.sent(),[2,t]}}))}))})),(0,p.mergeMap)(this.processAction.bind(this)),(0,p.share)());t.pipe((0,p.filter)((function(e){return e.hasValue&&"N"===e.kind}))).subscribe((function(e){e.value&&e.value.action&&e.value.action.resolve&&e.value.response&&e.value.action.resolve(e.value.response)})),t.pipe((0,p.filter)((function(e){return!1===e.hasValue&&"E"===e.kind}))).subscribe((function(e){e.error&&e.error.action&&e.error.action.reject&&e.error.responseError&&e.error.action.reject(e.error.responseError)}))},e.prototype.sendToAuthQueue=function(e){return o(this,void 0,void 0,(function(){var t=this;return a(this,(function(n){return[2,new Promise((function(n,i){t.authQueue.next(r(r({},e),{reject:i,resolve:n}))}))]}))}))},e.prototype.sendToActionQueue=function(e){return o(this,void 0,void 0,(function(){var t=this;return a(this,(function(n){return[2,new Promise((function(n,i){t.actionQueue.next(r(r({},e),{reject:i,resolve:n}))}))]}))}))},e.prototype.getActionWithTokenData=function(e){return o(this,void 0,void 0,(function(){var t,n;return a(this,(function(r){switch(r.label){case 0:return r.trys.push([0,3,,5]),n={action:e},[4,this.auth.getTokenData()];case 1:return n.tokenData=r.sent(),t=n,[4,this.initFirebase(t)];case 2:return r.sent(),[2,t];case 3:return r.sent(),[4,this.signOut()];case 4:return r.sent(),[2,{action:e}];case 5:return[2]}}))}))},e.prototype.fireAuthStatus=function(e){var t=this.auth.getAuthStatus(e.tokenData);this.authStatusSubject.next(t)},e.prototype.storeTokenData=function(e){return o(this,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,this.auth.storeTokenData(e.tokenData)];case 1:return t.sent(),[2]}}))}))},e.prototype.processAction=function(e){var t,n=this;return(null===(t=e.action)||void 0===t?void 0:t.action)===y.RetterActions.EMPTY?(0,f.defer)((function(){return(0,f.of)(r(r({},e),{response:!0}))})).pipe((0,p.materialize)()):(0,f.defer)((function(){return o(n,void 0,void 0,(function(){var t,n,i;return a(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),t=this.getCosEndpoint(e),[4,this.http.call(this.clientConfig.projectId,t.path,t.params)];case 1:return n=s.sent(),[2,r(r({},e),{response:n})];case 2:throw(i=s.sent()).response&&403===i.response.status&&i.response.data&&"ACCESS_DENIED"===i.response.data.code&&this.signOut(),r(r({},e),{responseError:i});case 3:return[2]}}))}))})).pipe((0,p.materialize)())},e.prototype.initFirebase=function(e){return o(this,void 0,void 0,(function(){var t,n;return a(this,(function(r){switch(r.label){case 0:return!(t=null===(n=e.tokenData)||void 0===n?void 0:n.firebase)||this.firebase?[2,e]:(this.firebase=(0,l.initializeApp)({apiKey:t.apiKey,authDomain:t.projectId+".firebaseapp.com",projectId:t.projectId},this.clientConfig.projectId),this.firestore=(0,u.getFirestore)(this.firebase),this.firebaseAuth=(0,d.getAuth)(this.firebase),[4,(0,d.signInWithCustomToken)(this.firebaseAuth,t.customToken)]);case 1:return r.sent(),[2,e]}}))}))},e.prototype.clearFirebase=function(){this.firebase=void 0,this.firestore=void 0,this.firebaseAuth=void 0},e.prototype.getCosEndpoint=function(e){var t,n,i,s,o,a,c,u,l,h=e.action,d=h.data,f={};for(var p in d.queryStringParams||[])f[p]=d.queryStringParams[p];f.__culture=null!==(t=d.culture)&&void 0!==t?t:(null===(n=this.clientConfig)||void 0===n?void 0:n.culture)||"en-us",(d.platform||(null===(i=this.clientConfig)||void 0===i?void 0:i.platform))&&(f.__platform=null!==(s=d.platform)&&void 0!==s?s:null===(o=this.clientConfig)||void 0===o?void 0:o.platform);var m={params:f,method:null!==(a=d.httpMethod)&&void 0!==a?a:"post",data:d.body,base64Encode:null===(c=d.base64Encode)||void 0===c||c,headers:r({},d.headers)},g=null!==(u=d.token)&&void 0!==u?u:null===(l=e.tokenData)||void 0===l?void 0:l.accessToken;if(g&&(m.headers.Authorization="Bearer ".concat(g)),h.action===y.RetterActions.COS_INSTANCE){var v=d.key?"".concat(d.key.name,"!").concat(d.key.value):d.instanceId;return{path:"INSTANCE/".concat(d.classId).concat(v?"/".concat(v):""),params:m}}return h.action===y.RetterActions.COS_STATE?{path:"STATE/".concat(d.classId,"/").concat(d.instanceId),params:m}:h.action===y.RetterActions.COS_LIST?{path:"LIST/".concat(d.classId),params:m}:h.action===y.RetterActions.COS_STATIC_CALL?{path:"CALL/".concat(d.classId,"/").concat(d.method).concat(d.pathParams?"/".concat(d.pathParams):""),params:m}:{path:"CALL/".concat(d.classId,"/").concat(d.method,"/").concat(d.instanceId).concat(d.pathParams?"/".concat(d.pathParams):""),params:m}},e.prototype.getFirebaseListener=function(e,t,n){var r=(0,h.doc)(this.firestore,t,n);return(0,h.onSnapshot)(r,(function(t){for(var n=Object.assign({},t.data()),r=0,i=Object.keys(n);r<i.length;r++){var s=i[r];s.startsWith("__")&&delete n[s]}e.next(n)}))},e.prototype.getFirebaseState=function(e){return o(this,void 0,void 0,(function(){var t,n,r,i,s=this;return a(this,(function(o){switch(o.label){case 0:return t=this.clientConfig.projectId,[4,this.auth.getCurrentUser()];case 1:return n=o.sent(),r=[],[2,{state:{role:{queue:(i={role:new f.ReplaySubject(1),user:new f.ReplaySubject(1),public:new f.ReplaySubject(1)}).role,subscribe:function(o){if(!s.listeners["".concat(t,"_").concat(e.classId,"_").concat(e.instanceId,"_role")]){var a=s.getFirebaseListener(i.role,"/projects/".concat(t,"/classes/").concat(e.classId,"/instances/").concat(e.instanceId,"/roleState"),n.identity);r.push(a),s.listeners["".concat(t,"_").concat(e.classId,"_").concat(e.instanceId,"_role")]=a}return i.role.subscribe(o)}},user:{queue:i.user,subscribe:function(o){if(!s.listeners["".concat(t,"_").concat(e.classId,"_").concat(e.instanceId,"_user")]){var a=s.getFirebaseListener(i.user,"/projects/".concat(t,"/classes/").concat(e.classId,"/instances/").concat(e.instanceId,"/userState"),n.userId);r.push(a),s.listeners["".concat(t,"_").concat(e.classId,"_").concat(e.instanceId,"_user")]=a}return i.user.subscribe(o)}},public:{queue:i.public,subscribe:function(n){if(!s.listeners["".concat(t,"_").concat(e.classId,"_").concat(e.instanceId,"_public")]){var o=s.getFirebaseListener(i.public,"/projects/".concat(t,"/classes/").concat(e.classId,"/instances"),e.instanceId);r.push(o),s.listeners["".concat(t,"_").concat(e.classId,"_").concat(e.instanceId,"_public")]=o}return i.public.subscribe(n)}}},unsubscribers:r}]}}))}))},e.prototype.clearCloudObjects=function(){return o(this,void 0,void 0,(function(){var e;return a(this,(function(t){switch(t.label){case 0:return(e=Object.values(this.listeners)).length>0&&(e.map((function(e){return e()})),this.cloudObjects.map((function(e){var t,n,r,i,s,o;null===(n=null===(t=e.state)||void 0===t?void 0:t.role.queue)||void 0===n||n.complete(),null===(i=null===(r=e.state)||void 0===r?void 0:r.user.queue)||void 0===i||i.complete(),null===(o=null===(s=e.state)||void 0===s?void 0:s.public.queue)||void 0===o||o.complete()}))),this.listeners={},this.cloudObjects.map((function(e){return e.unsubscribers.map((function(e){return e()}))})),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]}}))}))},e.prototype.authenticateWithCustomToken=function(e){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.sendToAuthQueue({action:y.RetterActions.SIGN_IN,data:e})];case 1:return[2,t.sent()]}}))}))},e.prototype.signOut=function(){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.clearCloudObjects()];case 1:return e.sent(),[4,this.auth.signOut()];case 2:return e.sent(),[4,this.auth.clearTokenData()];case 3:return e.sent(),this.fireAuthStatus({}),[2]}}))}))},e.prototype.getCurrentUser=function(){return o(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,this.auth.getCurrentUser()];case 1:return[2,e.sent()]}}))}))},e.prototype.getCloudObject=function(e){return o(this,void 0,void 0,(function(){var t,n,i,s,c,u,l,h,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 e.instanceId&&e.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:e})];case 3:n=w.sent().data,t=n,e.instanceId=t.instanceId,w.label=4;case 4:return(i=this.cloudObjects.find((function(t){return t.config.classId===e.classId&&t.config.instanceId===e.instanceId})))?[2,{call:i.call,state:i.state,listInstances:i.listInstances,getState:i.getState,methods:null!==(p=null==t?void 0:t.methods)&&void 0!==p?p:[],instanceId:e.instanceId,response:i.response,isNewInstance:!1}]:[4,this.getFirebaseState(e)];case 5:return s=w.sent(),c=s.state,u=s.unsubscribers,l=function(t){return o(b,void 0,void 0,(function(){var n;return a(this,(function(i){switch(i.label){case 0:t.retryConfig=r(r({},this.clientConfig.retryConfig),t.retryConfig),i.label=1;case 1:return i.trys.push([1,3,,8]),[4,this.sendToActionQueue({action:y.RetterActions.COS_CALL,data:r(r({},t),{classId:e.classId,instanceId:e.instanceId})})];case 2:return[2,i.sent()];case 3:return n=i.sent(),--t.retryConfig.count,t.retryConfig.delay*=t.retryConfig.rate,n.response&&570===n.response.status&&t.retryConfig.count>0?[4,new Promise((function(e){return setTimeout(e,t.retryConfig.delay)}))]:[3,6];case 4:return i.sent(),[4,l(t)];case 5:return[2,i.sent()];case 6:throw n;case 7:return[3,8];case 8:return[2]}}))}))},h=function(t){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({},t),{classId:e.classId,instanceId:e.instanceId})})];case 1:return[2,n.sent()]}}))}))},d=function(t){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({},t),{classId:e.classId})})];case 1:return[2,n.sent().data.instanceIds]}}))}))},f={call:l,state:c,getState:h,listInstances:d,methods:null!==(m=null==t?void 0:t.methods)&&void 0!==m?m:[],response:null!==(g=null==t?void 0:t.response)&&void 0!==g?g:null,instanceId:e.instanceId,isNewInstance:null!==(v=null==t?void 0:t.newInstance)&&void 0!==v&&v},this.cloudObjects.push(r(r({},f),{config:e,unsubscribers:u})),[2,f]}}))}))},e.prototype.makeStaticCall=function(e){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.COS_STATIC_CALL,data:r(r({},e),{classId:e.classId})})];case 1:return[2,t.sent()]}}))}))},Object.defineProperty(e.prototype,"authStatus",{get:function(){return this.authStatusSubject.asObservable().pipe((0,p.distinctUntilChanged)((function(e,t){return e.authStatus===t.authStatus&&e.identity===t.identity&&e.uid===t.uid})))},enumerable:!1,configurable:!0}),e.instances=[],e}();t.default=v},1613:(e,t)=>{"use strict";var n,r,i,s;Object.defineProperty(t,"__esModule",{value:!0}),t.Runtime=t.RetterAuthStatus=t.RetterActions=t.RetterRegion=void 0,function(e){e[e.euWest1=0]="euWest1",e[e.euWest1Beta=1]="euWest1Beta"}(n||(t.RetterRegion=n={})),function(e){e.EMPTY="EMPTY",e.SIGN_IN="SIGN_IN",e.COS_CALL="COS_CALL",e.COS_LIST="COS_LIST",e.COS_STATE="COS_STATE",e.COS_INSTANCE="COS_INSTANCE",e.COS_STATIC_CALL="COS_STATIC_CALL"}(r||(t.RetterActions=r={})),function(e){e.SIGNED_IN="SIGNED_IN",e.SIGNED_OUT="SIGNED_OUT",e.AUTH_FAILED="AUTH_FAILED"}(i||(t.RetterAuthStatus=i={})),function(e){e.web="web",e.node="node"}(s||(t.Runtime=s={}))},6425:(e,t,n)=>{"use strict";function r(e,t){return function(){return e.apply(t,arguments)}}const{toString:i}=Object.prototype,{getPrototypeOf:s}=Object,o=(a=Object.create(null),e=>{const t=i.call(e);return a[t]||(a[t]=t.slice(8,-1).toLowerCase())});var a;const c=e=>(e=e.toLowerCase(),t=>o(t)===e),u=e=>t=>typeof t===e,{isArray:l}=Array,h=u("undefined"),d=c("ArrayBuffer"),f=u("string"),p=u("function"),m=u("number"),g=e=>null!==e&&"object"==typeof e,y=e=>{if("object"!==o(e))return!1;const t=s(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)},v=c("Date"),b=c("File"),w=c("Blob"),_=c("FileList"),I=c("URLSearchParams"),[E,T,S,C]=["ReadableStream","Request","Response","Headers"].map(c);function A(e,t,{allOwnKeys:n=!1}={}){if(null==e)return;let r,i;if("object"!=typeof e&&(e=[e]),l(e))for(r=0,i=e.length;r<i;r++)t.call(null,e[r],r,e);else{const i=n?Object.getOwnPropertyNames(e):Object.keys(e),s=i.length;let o;for(r=0;r<s;r++)o=i[r],t.call(null,e[o],o,e)}}function x(e,t){t=t.toLowerCase();const n=Object.keys(e);let r,i=n.length;for(;i-- >0;)if(r=n[i],t===r.toLowerCase())return r;return null}const k="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:n.g,N=e=>!h(e)&&e!==k,O=(D="undefined"!=typeof Uint8Array&&s(Uint8Array),e=>D&&e instanceof D);var D;const R=c("HTMLFormElement"),P=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),L=c("RegExp"),M=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};A(n,((n,i)=>{let s;!1!==(s=t(n,i,e))&&(r[i]=s||n)})),Object.defineProperties(e,r)},F="abcdefghijklmnopqrstuvwxyz",V="0123456789",U={DIGIT:V,ALPHA:F,ALPHA_DIGIT:F+F.toUpperCase()+V},j=c("AsyncFunction"),B=(q="function"==typeof setImmediate,z=p(k.postMessage),q?setImmediate:z?(G=`axios@${Math.random()}`,K=[],k.addEventListener("message",(({source:e,data:t})=>{e===k&&t===G&&K.length&&K.shift()()}),!1),e=>{K.push(e),k.postMessage(G,"*")}):e=>setTimeout(e));var q,z,G,K;const W="undefined"!=typeof queueMicrotask?queueMicrotask.bind(k):"undefined"!=typeof process&&process.nextTick||B;var $={isArray:l,isArrayBuffer:d,isBuffer:function(e){return null!==e&&!h(e)&&null!==e.constructor&&!h(e.constructor)&&p(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||p(e.append)&&("formdata"===(t=o(e))||"object"===t&&p(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&d(e.buffer),t},isString:f,isNumber:m,isBoolean:e=>!0===e||!1===e,isObject:g,isPlainObject:y,isReadableStream:E,isRequest:T,isResponse:S,isHeaders:C,isUndefined:h,isDate:v,isFile:b,isBlob:w,isRegExp:L,isFunction:p,isStream:e=>g(e)&&p(e.pipe),isURLSearchParams:I,isTypedArray:O,isFileList:_,forEach:A,merge:function e(){const{caseless:t}=N(this)&&this||{},n={},r=(r,i)=>{const s=t&&x(n,i)||i;y(n[s])&&y(r)?n[s]=e(n[s],r):y(r)?n[s]=e({},r):l(r)?n[s]=r.slice():n[s]=r};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&A(arguments[e],r);return n},extend:(e,t,n,{allOwnKeys:i}={})=>(A(t,((t,i)=>{n&&p(t)?e[i]=r(t,n):e[i]=t}),{allOwnKeys:i}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},toFlatObject:(e,t,n,r)=>{let i,o,a;const c={};if(t=t||{},null==e)return t;do{for(i=Object.getOwnPropertyNames(e),o=i.length;o-- >0;)a=i[o],r&&!r(a,e,t)||c[a]||(t[a]=e[a],c[a]=!0);e=!1!==n&&s(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:o,kindOfTest:c,endsWith:(e,t,n)=>{e=String(e),(void 0===n||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return-1!==r&&r===n},toArray:e=>{if(!e)return null;if(l(e))return e;let t=e.length;if(!m(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},forEachEntry:(e,t)=>{const n=(e&&e[Symbol.iterator]).call(e);let r;for(;(r=n.next())&&!r.done;){const n=r.value;t.call(e,n[0],n[1])}},matchAll:(e,t)=>{let n;const r=[];for(;null!==(n=e.exec(t));)r.push(n);return r},isHTMLForm:R,hasOwnProperty:P,hasOwnProp:P,reduceDescriptors:M,freezeMethods:e=>{M(e,((t,n)=>{if(p(e)&&-1!==["arguments","caller","callee"].indexOf(n))return!1;const r=e[n];p(r)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")}))}))},toObjectSet:(e,t)=>{const n={},r=e=>{e.forEach((e=>{n[e]=!0}))};return l(e)?r(e):r(String(e).split(t)),n},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(e,t,n){return t.toUpperCase()+n})),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:x,global:k,isContextDefined:N,ALPHABET:U,generateString:(e=16,t=U.ALPHA_DIGIT)=>{let n="";const{length:r}=t;for(;e--;)n+=t[Math.random()*r|0];return n},isSpecCompliantForm:function(e){return!!(e&&p(e.append)&&"FormData"===e[Symbol.toStringTag]&&e[Symbol.iterator])},toJSONObject:e=>{const t=new Array(10),n=(e,r)=>{if(g(e)){if(t.indexOf(e)>=0)return;if(!("toJSON"in e)){t[r]=e;const i=l(e)?[]:{};return A(e,((e,t)=>{const s=n(e,r+1);!h(s)&&(i[t]=s)})),t[r]=void 0,i}}return e};return n(e,0)},isAsyncFn:j,isThenable:e=>e&&(g(e)||p(e))&&p(e.then)&&p(e.catch),setImmediate:B,asap:W};function H(e,t,n,r,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),i&&(this.response=i,this.status=i.status?i.status:null)}$.inherits(H,Error,{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:$.toJSONObject(this.config),code:this.code,status:this.status}}});const Q=H.prototype,J={};function Y(e){return $.isPlainObject(e)||$.isArray(e)}function X(e){return $.endsWith(e,"[]")?e.slice(0,-2):e}function Z(e,t,n){return e?e.concat(t).map((function(e,t){return e=X(e),!n&&t?"["+e+"]":e})).join(n?".":""):t}["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((e=>{J[e]={value:e}})),Object.defineProperties(H,J),Object.defineProperty(Q,"isAxiosError",{value:!0}),H.from=(e,t,n,r,i,s)=>{const o=Object.create(Q);return $.toFlatObject(e,o,(function(e){return e!==Error.prototype}),(e=>"isAxiosError"!==e)),H.call(o,e.message,t,n,r,i),o.cause=e,o.name=e.name,s&&Object.assign(o,s),o};const ee=$.toFlatObject($,{},null,(function(e){return/^is[A-Z]/.test(e)}));function te(e,t,n){if(!$.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const r=(n=$.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!$.isUndefined(t[e])}))).metaTokens,i=n.visitor||u,s=n.dots,o=n.indexes,a=(n.Blob||"undefined"!=typeof Blob&&Blob)&&$.isSpecCompliantForm(t);if(!$.isFunction(i))throw new TypeError("visitor must be a function");function c(e){if(null===e)return"";if($.isDate(e))return e.toISOString();if(!a&&$.isBlob(e))throw new H("Blob is not supported. Use a Buffer instead.");return $.isArrayBuffer(e)||$.isTypedArray(e)?a&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function u(e,n,i){let a=e;if(e&&!i&&"object"==typeof e)if($.endsWith(n,"{}"))n=r?n:n.slice(0,-2),e=JSON.stringify(e);else if($.isArray(e)&&function(e){return $.isArray(e)&&!e.some(Y)}(e)||($.isFileList(e)||$.endsWith(n,"[]"))&&(a=$.toArray(e)))return n=X(n),a.forEach((function(e,r){!$.isUndefined(e)&&null!==e&&t.append(!0===o?Z([n],r,s):null===o?n:n+"[]",c(e))})),!1;return!!Y(e)||(t.append(Z(i,n,s),c(e)),!1)}const l=[],h=Object.assign(ee,{defaultVisitor:u,convertValue:c,isVisitable:Y});if(!$.isObject(e))throw new TypeError("data must be an object");return function e(n,r){if(!$.isUndefined(n)){if(-1!==l.indexOf(n))throw Error("Circular reference detected in "+r.join("."));l.push(n),$.forEach(n,(function(n,s){!0===(!($.isUndefined(n)||null===n)&&i.call(t,n,$.isString(s)?s.trim():s,r,h))&&e(n,r?r.concat(s):[s])})),l.pop()}}(e),t}function ne(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,(function(e){return t[e]}))}function re(e,t){this._pairs=[],e&&te(e,this,t)}const ie=re.prototype;function se(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function oe(e,t,n){if(!t)return e;const r=n&&n.encode||se,i=n&&n.serialize;let s;if(s=i?i(t,n):$.isURLSearchParams(t)?t.toString():new re(t,n).toString(r),s){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+s}return e}ie.append=function(e,t){this._pairs.push([e,t])},ie.toString=function(e){const t=e?function(t){return e.call(this,t,ne)}:ne;return this._pairs.map((function(e){return t(e[0])+"="+t(e[1])}),"").join("&")};var ae=class{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){$.forEach(this.handlers,(function(t){null!==t&&e(t)}))}},ce={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},ue={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:re,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const le="undefined"!=typeof window&&"undefined"!=typeof document,he="object"==typeof navigator&&navigator||void 0,de=le&&(!he||["ReactNative","NativeScript","NS"].indexOf(he.product)<0),fe="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,pe=le&&window.location.href||"http://localhost";var me={...Object.freeze({__proto__:null,hasBrowserEnv:le,hasStandardBrowserWebWorkerEnv:fe,hasStandardBrowserEnv:de,navigator:he,origin:pe}),...ue};function ge(e){function t(e,n,r,i){let s=e[i++];if("__proto__"===s)return!0;const o=Number.isFinite(+s),a=i>=e.length;return s=!s&&$.isArray(r)?r.length:s,a?($.hasOwnProp(r,s)?r[s]=[r[s],n]:r[s]=n,!o):(r[s]&&$.isObject(r[s])||(r[s]=[]),t(e,n,r[s],i)&&$.isArray(r[s])&&(r[s]=function(e){const t={},n=Object.keys(e);let r;const i=n.length;let s;for(r=0;r<i;r++)s=n[r],t[s]=e[s];return t}(r[s])),!o)}if($.isFormData(e)&&$.isFunction(e.entries)){const n={};return $.forEachEntry(e,((e,r)=>{t(function(e){return $.matchAll(/\w+|\[(\w*)]/g,e).map((e=>"[]"===e[0]?"":e[1]||e[0]))}(e),r,n,0)})),n}return null}const ye={transitional:ce,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",r=n.indexOf("application/json")>-1,i=$.isObject(e);if(i&&$.isHTMLForm(e)&&(e=new FormData(e)),$.isFormData(e))return r?JSON.stringify(ge(e)):e;if($.isArrayBuffer(e)||$.isBuffer(e)||$.isStream(e)||$.isFile(e)||$.isBlob(e)||$.isReadableStream(e))return e;if($.isArrayBufferView(e))return e.buffer;if($.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let s;if(i){if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return te(e,new me.classes.URLSearchParams,Object.assign({visitor:function(e,t,n,r){return me.isNode&&$.isBuffer(e)?(this.append(t,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((s=$.isFileList(e))||n.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return te(s?{"files[]":e}:e,t&&new t,this.formSerializer)}}return i||r?(t.setContentType("application/json",!1),function(e){if($.isString(e))try{return(0,JSON.parse)(e),$.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(0,JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||ye.transitional,n=t&&t.forcedJSONParsing,r="json"===this.responseType;if($.isResponse(e)||$.isReadableStream(e))return e;if(e&&$.isString(e)&&(n&&!this.responseType||r)){const n=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e)}catch(e){if(n){if("SyntaxError"===e.name)throw H.from(e,H.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:me.classes.FormData,Blob:me.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};$.forEach(["delete","get","head","post","put","patch"],(e=>{ye.headers[e]={}}));var ve=ye;const be=$.toObjectSet(["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"]),we=Symbol("internals");function _e(e){return e&&String(e).trim().toLowerCase()}function Ie(e){return!1===e||null==e?e:$.isArray(e)?e.map(Ie):String(e)}function Ee(e,t,n,r,i){return $.isFunction(r)?r.call(this,t,n):(i&&(t=n),$.isString(t)?$.isString(r)?-1!==t.indexOf(r):$.isRegExp(r)?r.test(t):void 0:void 0)}class Te{constructor(e){e&&this.set(e)}set(e,t,n){const r=this;function i(e,t,n){const i=_e(t);if(!i)throw new Error("header name must be a non-empty string");const s=$.findKey(r,i);(!s||void 0===r[s]||!0===n||void 0===n&&!1!==r[s])&&(r[s||t]=Ie(e))}const s=(e,t)=>$.forEach(e,((e,n)=>i(e,n,t)));if($.isPlainObject(e)||e instanceof this.constructor)s(e,t);else if($.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))s((e=>{const t={};let n,r,i;return e&&e.split("\n").forEach((function(e){i=e.indexOf(":"),n=e.substring(0,i).trim().toLowerCase(),r=e.substring(i+1).trim(),!n||t[n]&&be[n]||("set-cookie"===n?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)})),t})(e),t);else if($.isHeaders(e))for(const[t,r]of e.entries())i(r,t,n);else null!=e&&i(t,e,n);return this}get(e,t){if(e=_e(e)){const n=$.findKey(this,e);if(n){const e=this[n];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}(e);if($.isFunction(t))return t.call(this,e,n);if($.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=_e(e)){const n=$.findKey(this,e);return!(!n||void 0===this[n]||t&&!Ee(0,this[n],n,t))}return!1}delete(e,t){const n=this;let r=!1;function i(e){if(e=_e(e)){const i=$.findKey(n,e);!i||t&&!Ee(0,n[i],i,t)||(delete n[i],r=!0)}}return $.isArray(e)?e.forEach(i):i(e),r}clear(e){const t=Object.keys(this);let n=t.length,r=!1;for(;n--;){const i=t[n];e&&!Ee(0,this[i],i,e,!0)||(delete this[i],r=!0)}return r}normalize(e){const t=this,n={};return $.forEach(this,((r,i)=>{const s=$.findKey(n,i);if(s)return t[s]=Ie(r),void delete t[i];const o=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,((e,t,n)=>t.toUpperCase()+n))}(i):String(i).trim();o!==i&&delete t[i],t[o]=Ie(r),n[o]=!0})),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return $.forEach(this,((n,r)=>{null!=n&&!1!==n&&(t[r]=e&&$.isArray(n)?n.join(", "):n)})),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map((([e,t])=>e+": "+t)).join("\n")}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const n=new this(e);return t.forEach((e=>n.set(e))),n}static accessor(e){const t=(this[we]=this[we]={accessors:{}}).accessors,n=this.prototype;function r(e){const r=_e(e);t[r]||(function(e,t){const n=$.toCamelCase(" "+t);["get","set","has"].forEach((r=>{Object.defineProperty(e,r+n,{value:function(e,n,i){return this[r].call(this,t,e,n,i)},configurable:!0})}))}(n,e),t[r]=!0)}return $.isArray(e)?e.forEach(r):r(e),this}}Te.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),$.reduceDescriptors(Te.prototype,(({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}})),$.freezeMethods(Te);var Se=Te;function Ce(e,t){const n=this||ve,r=t||n,i=Se.from(r.headers);let s=r.data;return $.forEach(e,(function(e){s=e.call(n,s,i.normalize(),t?t.status:void 0)})),i.normalize(),s}function Ae(e){return!(!e||!e.__CANCEL__)}function xe(e,t,n){H.call(this,null==e?"canceled":e,H.ERR_CANCELED,t,n),this.name="CanceledError"}function ke(e,t,n){const r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(new H("Request failed with status code "+n.status,[H.ERR_BAD_REQUEST,H.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}$.inherits(xe,H,{__CANCEL__:!0});const Ne=(e,t,n=3)=>{let r=0;const i=function(e,t){e=e||10;const n=new Array(e),r=new Array(e);let i,s=0,o=0;return t=void 0!==t?t:1e3,function(a){const c=Date.now(),u=r[o];i||(i=c),n[s]=a,r[s]=c;let l=o,h=0;for(;l!==s;)h+=n[l++],l%=e;if(s=(s+1)%e,s===o&&(o=(o+1)%e),c-i<t)return;const d=u&&c-u;return d?Math.round(1e3*h/d):void 0}}(50,250);return function(e,t){let n,r,i=0,s=1e3/t;const o=(t,s=Date.now())=>{i=s,n=null,r&&(clearTimeout(r),r=null),e.apply(null,t)};return[(...e)=>{const t=Date.now(),a=t-i;a>=s?o(e,t):(n=e,r||(r=setTimeout((()=>{r=null,o(n)}),s-a)))},()=>n&&o(n)]}((n=>{const s=n.loaded,o=n.lengthComputable?n.total:void 0,a=s-r,c=i(a);r=s,e({loaded:s,total:o,progress:o?s/o:void 0,bytes:a,rate:c||void 0,estimated:c&&o&&s<=o?(o-s)/c:void 0,event:n,lengthComputable:null!=o,[t?"download":"upload"]:!0})}),n)},Oe=(e,t)=>{const n=null!=e;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},De=e=>(...t)=>$.asap((()=>e(...t)));var Re=me.hasStandardBrowserEnv?function(){const e=me.navigator&&/(msie|trident)/i.test(me.navigator.userAgent),t=document.createElement("a");let n;function r(n){let r=n;return e&&(t.setAttribute("href",r),r=t.href),t.setAttribute("href",r),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:"/"===t.pathname.charAt(0)?t.pathname:"/"+t.pathname}}return n=r(window.location.href),function(e){const t=$.isString(e)?r(e):e;return t.protocol===n.protocol&&t.host===n.host}}():function(){return!0},Pe=me.hasStandardBrowserEnv?{write(e,t,n,r,i,s){const o=[e+"="+encodeURIComponent(t)];$.isNumber(n)&&o.push("expires="+new Date(n).toGMTString()),$.isString(r)&&o.push("path="+r),$.isString(i)&&o.push("domain="+i),!0===s&&o.push("secure"),document.cookie=o.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function Le(e,t){return e&&!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const Me=e=>e instanceof Se?{...e}:e;function Fe(e,t){t=t||{};const n={};function r(e,t,n){return $.isPlainObject(e)&&$.isPlainObject(t)?$.merge.call({caseless:n},e,t):$.isPlainObject(t)?$.merge({},t):$.isArray(t)?t.slice():t}function i(e,t,n){return $.isUndefined(t)?$.isUndefined(e)?void 0:r(void 0,e,n):r(e,t,n)}function s(e,t){if(!$.isUndefined(t))return r(void 0,t)}function o(e,t){return $.isUndefined(t)?$.isUndefined(e)?void 0:r(void 0,e):r(void 0,t)}function a(n,i,s){return s in t?r(n,i):s in e?r(void 0,n):void 0}const c={url:s,method:s,data:s,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:a,headers:(e,t)=>i(Me(e),Me(t),!0)};return $.forEach(Object.keys(Object.assign({},e,t)),(function(r){const s=c[r]||i,o=s(e[r],t[r],r);$.isUndefined(o)&&s!==a||(n[r]=o)})),n}var Ve=e=>{const t=Fe({},e);let n,{data:r,withXSRFToken:i,xsrfHeaderName:s,xsrfCookieName:o,headers:a,auth:c}=t;if(t.headers=a=Se.from(a),t.url=oe(Le(t.baseURL,t.url),e.params,e.paramsSerializer),c&&a.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),$.isFormData(r))if(me.hasStandardBrowserEnv||me.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if(!1!==(n=a.getContentType())){const[e,...t]=n?n.split(";").map((e=>e.trim())).filter(Boolean):[];a.setContentType([e||"multipart/form-data",...t].join("; "))}if(me.hasStandardBrowserEnv&&(i&&$.isFunction(i)&&(i=i(t)),i||!1!==i&&Re(t.url))){const e=s&&o&&Pe.read(o);e&&a.set(s,e)}return t},Ue="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise((function(t,n){const r=Ve(e);let i=r.data;const s=Se.from(r.headers).normalize();let o,a,c,u,l,{responseType:h,onUploadProgress:d,onDownloadProgress:f}=r;function p(){u&&u(),l&&l(),r.cancelToken&&r.cancelToken.unsubscribe(o),r.signal&&r.signal.removeEventListener("abort",o)}let m=new XMLHttpRequest;function g(){if(!m)return;const r=Se.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders());ke((function(e){t(e),p()}),(function(e){n(e),p()}),{data:h&&"text"!==h&&"json"!==h?m.response:m.responseText,status:m.status,statusText:m.statusText,headers:r,config:e,request:m}),m=null}m.open(r.method.toUpperCase(),r.url,!0),m.timeout=r.timeout,"onloadend"in m?m.onloadend=g:m.onreadystatechange=function(){m&&4===m.readyState&&(0!==m.status||m.responseURL&&0===m.responseURL.indexOf("file:"))&&setTimeout(g)},m.onabort=function(){m&&(n(new H("Request aborted",H.ECONNABORTED,e,m)),m=null)},m.onerror=function(){n(new H("Network Error",H.ERR_NETWORK,e,m)),m=null},m.ontimeout=function(){let t=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const i=r.transitional||ce;r.timeoutErrorMessage&&(t=r.timeoutErrorMessage),n(new H(t,i.clarifyTimeoutError?H.ETIMEDOUT:H.ECONNABORTED,e,m)),m=null},void 0===i&&s.setContentType(null),"setRequestHeader"in m&&$.forEach(s.toJSON(),(function(e,t){m.setRequestHeader(t,e)})),$.isUndefined(r.withCredentials)||(m.withCredentials=!!r.withCredentials),h&&"json"!==h&&(m.responseType=r.responseType),f&&([c,l]=Ne(f,!0),m.addEventListener("progress",c)),d&&m.upload&&([a,u]=Ne(d),m.upload.addEventListener("progress",a),m.upload.addEventListener("loadend",u)),(r.cancelToken||r.signal)&&(o=t=>{m&&(n(!t||t.type?new xe(null,e,m):t),m.abort(),m=null)},r.cancelToken&&r.cancelToken.subscribe(o),r.signal&&(r.signal.aborted?o():r.signal.addEventListener("abort",o)));const y=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(r.url);y&&-1===me.protocols.indexOf(y)?n(new H("Unsupported protocol "+y+":",H.ERR_BAD_REQUEST,e)):m.send(i||null)}))},je=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let n,r=new AbortController;const i=function(e){if(!n){n=!0,o();const t=e instanceof Error?e:this.reason;r.abort(t instanceof H?t:new xe(t instanceof Error?t.message:t))}};let s=t&&setTimeout((()=>{s=null,i(new H(`timeout ${t} of ms exceeded`,H.ETIMEDOUT))}),t);const o=()=>{e&&(s&&clearTimeout(s),s=null,e.forEach((e=>{e.unsubscribe?e.unsubscribe(i):e.removeEventListener("abort",i)})),e=null)};e.forEach((e=>e.addEventListener("abort",i)));const{signal:a}=r;return a.unsubscribe=()=>$.asap(o),a}};const Be=function*(e,t){let n=e.byteLength;if(!t||n<t)return void(yield e);let r,i=0;for(;i<n;)r=i+t,yield e.slice(i,r),i=r},qe=(e,t,n,r)=>{const i=async function*(e,t){for await(const n of async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);const t=e.getReader();try{for(;;){const{done:e,value:n}=await t.read();if(e)break;yield n}}finally{await t.cancel()}}(e))yield*Be(n,t)}(e,t);let s,o=0,a=e=>{s||(s=!0,r&&r(e))};return new ReadableStream({async pull(e){try{const{done:t,value:r}=await i.next();if(t)return a(),void e.close();let s=r.byteLength;if(n){let e=o+=s;n(e)}e.enqueue(new Uint8Array(r))}catch(e){throw a(e),e}},cancel:e=>(a(e),i.return())},{highWaterMark:2})},ze="function"==typeof fetch&&"function"==typeof Request&&"function"==typeof Response,Ge=ze&&"function"==typeof ReadableStream,Ke=ze&&("function"==typeof TextEncoder?(We=new TextEncoder,e=>We.encode(e)):async e=>new Uint8Array(await new Response(e).arrayBuffer()));var We;const $e=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},He=Ge&&$e((()=>{let e=!1;const t=new Request(me.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t})),Qe=Ge&&$e((()=>$.isReadableStream(new Response("").body))),Je={stream:Qe&&(e=>e.body)};var Ye;ze&&(Ye=new Response,["text","arrayBuffer","blob","formData","stream"].forEach((e=>{!Je[e]&&(Je[e]=$.isFunction(Ye[e])?t=>t[e]():(t,n)=>{throw new H(`Response type '${e}' is not supported`,H.ERR_NOT_SUPPORT,n)})})));const Xe={http:null,xhr:Ue,fetch:ze&&(async e=>{let{url:t,method:n,data:r,signal:i,cancelToken:s,timeout:o,onDownloadProgress:a,onUploadProgress:c,responseType:u,headers:l,withCredentials:h="same-origin",fetchOptions:d}=Ve(e);u=u?(u+"").toLowerCase():"text";let f,p=je([i,s&&s.toAbortSignal()],o);const m=p&&p.unsubscribe&&(()=>{p.unsubscribe()});let g;try{if(c&&He&&"get"!==n&&"head"!==n&&0!==(g=await(async(e,t)=>{const n=$.toFiniteNumber(e.getContentLength());return null==n?(async e=>{if(null==e)return 0;if($.isBlob(e))return e.size;if($.isSpecCompliantForm(e)){const t=new Request(me.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return $.isArrayBufferView(e)||$.isArrayBuffer(e)?e.byteLength:($.isURLSearchParams(e)&&(e+=""),$.isString(e)?(await Ke(e)).byteLength:void 0)})(t):n})(l,r))){let e,n=new Request(t,{method:"POST",body:r,duplex:"half"});if($.isFormData(r)&&(e=n.headers.get("content-type"))&&l.setContentType(e),n.body){const[e,t]=Oe(g,Ne(De(c)));r=qe(n.body,65536,e,t)}}$.isString(h)||(h=h?"include":"omit");const i="credentials"in Request.prototype;f=new Request(t,{...d,signal:p,method:n.toUpperCase(),headers:l.normalize().toJSON(),body:r,duplex:"half",credentials:i?h:void 0});let s=await fetch(f);const o=Qe&&("stream"===u||"response"===u);if(Qe&&(a||o&&m)){const e={};["status","statusText","headers"].forEach((t=>{e[t]=s[t]}));const t=$.toFiniteNumber(s.headers.get("content-length")),[n,r]=a&&Oe(t,Ne(De(a),!0))||[];s=new Response(qe(s.body,65536,n,(()=>{r&&r(),m&&m()})),e)}u=u||"text";let y=await Je[$.findKey(Je,u)||"text"](s,e);return!o&&m&&m(),await new Promise(((t,n)=>{ke(t,n,{data:y,headers:Se.from(s.headers),status:s.status,statusText:s.statusText,config:e,request:f})}))}catch(t){if(m&&m(),t&&"TypeError"===t.name&&/fetch/i.test(t.message))throw Object.assign(new H("Network Error",H.ERR_NETWORK,e,f),{cause:t.cause||t});throw H.from(t,t&&t.code,e,f)}})};$.forEach(Xe,((e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}}));const Ze=e=>`- ${e}`,et=e=>$.isFunction(e)||null===e||!1===e;var tt=e=>{e=$.isArray(e)?e:[e];const{length:t}=e;let n,r;const i={};for(let s=0;s<t;s++){let t;if(n=e[s],r=n,!et(n)&&(r=Xe[(t=String(n)).toLowerCase()],void 0===r))throw new H(`Unknown adapter '${t}'`);if(r)break;i[t||"#"+s]=r}if(!r){const e=Object.entries(i).map((([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build")));throw new H("There is no suitable adapter to dispatch the request "+(t?e.length>1?"since :\n"+e.map(Ze).join("\n"):" "+Ze(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return r};function nt(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new xe(null,e)}function rt(e){return nt(e),e.headers=Se.from(e.headers),e.data=Ce.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1),tt(e.adapter||ve.adapter)(e).then((function(t){return nt(e),t.data=Ce.call(e,e.transformResponse,t),t.headers=Se.from(t.headers),t}),(function(t){return Ae(t)||(nt(e),t&&t.response&&(t.response.data=Ce.call(e,e.transformResponse,t.response),t.response.headers=Se.from(t.response.headers))),Promise.reject(t)}))}const it={};["object","boolean","number","function","string","symbol"].forEach(((e,t)=>{it[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}}));const st={};it.transitional=function(e,t,n){function r(e,t){return"[Axios v1.7.7] Transitional option '"+e+"'"+t+(n?". "+n:"")}return(n,i,s)=>{if(!1===e)throw new H(r(i," has been removed"+(t?" in "+t:"")),H.ERR_DEPRECATED);return t&&!st[i]&&(st[i]=!0,console.warn(r(i," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,i,s)}};var ot={assertOptions:function(e,t,n){if("object"!=typeof e)throw new H("options must be an object",H.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let i=r.length;for(;i-- >0;){const s=r[i],o=t[s];if(o){const t=e[s],n=void 0===t||o(t,s,e);if(!0!==n)throw new H("option "+s+" must be "+n,H.ERR_BAD_OPTION_VALUE)}else if(!0!==n)throw new H("Unknown option "+s,H.ERR_BAD_OPTION)}},validators:it};const at=ot.validators;class ct{constructor(e){this.defaults=e,this.interceptors={request:new ae,response:new ae}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t;Error.captureStackTrace?Error.captureStackTrace(t={}):t=new Error;const n=t.stack?t.stack.replace(/^.+\n/,""):"";try{e.stack?n&&!String(e.stack).endsWith(n.replace(/^.+\n.+\n/,""))&&(e.stack+="\n"+n):e.stack=n}catch(e){}}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=Fe(this.defaults,t);const{transitional:n,paramsSerializer:r,headers:i}=t;void 0!==n&&ot.assertOptions(n,{silentJSONParsing:at.transitional(at.boolean),forcedJSONParsing:at.transitional(at.boolean),clarifyTimeoutError:at.transitional(at.boolean)},!1),null!=r&&($.isFunction(r)?t.paramsSerializer={serialize:r}:ot.assertOptions(r,{encode:at.function,serialize:at.function},!0)),t.method=(t.method||this.defaults.method||"get").toLowerCase();let s=i&&$.merge(i.common,i[t.method]);i&&$.forEach(["delete","get","head","post","put","patch","common"],(e=>{delete i[e]})),t.headers=Se.concat(s,i);const o=[];let a=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(a=a&&e.synchronous,o.unshift(e.fulfilled,e.rejected))}));const c=[];let u;this.interceptors.response.forEach((function(e){c.push(e.fulfilled,e.rejected)}));let l,h=0;if(!a){const e=[rt.bind(this),void 0];for(e.unshift.apply(e,o),e.push.apply(e,c),l=e.length,u=Promise.resolve(t);h<l;)u=u.then(e[h++],e[h++]);return u}l=o.length;let d=t;for(h=0;h<l;){const e=o[h++],t=o[h++];try{d=e(d)}catch(e){t.call(this,e);break}}try{u=rt.call(this,d)}catch(e){return Promise.reject(e)}for(h=0,l=c.length;h<l;)u=u.then(c[h++],c[h++]);return u}getUri(e){return oe(Le((e=Fe(this.defaults,e)).baseURL,e.url),e.params,e.paramsSerializer)}}$.forEach(["delete","get","head","options"],(function(e){ct.prototype[e]=function(t,n){return this.request(Fe(n||{},{method:e,url:t,data:(n||{}).data}))}})),$.forEach(["post","put","patch"],(function(e){function t(t){return function(n,r,i){return this.request(Fe(i||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:r}))}}ct.prototype[e]=t(),ct.prototype[e+"Form"]=t(!0)}));var ut=ct;class lt{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise((function(e){t=e}));const n=this;this.promise.then((e=>{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null})),this.promise.then=e=>{let t;const r=new Promise((e=>{n.subscribe(e),t=e})).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e((function(e,r,i){n.reason||(n.reason=new xe(e,r,i),t(n.reason))}))}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new lt((function(t){e=t})),cancel:e}}}var ht=lt;const dt={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(dt).forEach((([e,t])=>{dt[t]=e}));var ft=dt;const pt=function e(t){const n=new ut(t),i=r(ut.prototype.request,n);return $.extend(i,ut.prototype,n,{allOwnKeys:!0}),$.extend(i,n,null,{allOwnKeys:!0}),i.create=function(n){return e(Fe(t,n))},i}(ve);pt.Axios=ut,pt.CanceledError=xe,pt.CancelToken=ht,pt.isCancel=Ae,pt.VERSION="1.7.7",pt.toFormData=te,pt.AxiosError=H,pt.Cancel=pt.CanceledError,pt.all=function(e){return Promise.all(e)},pt.spread=function(e){return function(t){return e.apply(null,t)}},pt.isAxiosError=function(e){return $.isObject(e)&&!0===e.isAxiosError},pt.mergeConfig=Fe,pt.AxiosHeaders=Se,pt.formToJSON=e=>ge($.isHTMLForm(e)?new FormData(e):e),pt.getAdapter=tt,pt.HttpStatusCode=ft,pt.default=pt,e.exports=pt},6148:(e,t,n)=>{"use strict";n.r(t),n.d(t,{deleteDB:()=>g,openDB:()=>m,unwrap:()=>p,wrap:()=>f});const r=(e,t)=>t.some((t=>e instanceof t));let i,s;const o=new WeakMap,a=new WeakMap,c=new WeakMap,u=new WeakMap,l=new WeakMap;let h={get(e,t,n){if(e instanceof IDBTransaction){if("done"===t)return a.get(e);if("objectStoreNames"===t)return e.objectStoreNames||c.get(e);if("store"===t)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return f(e[t])},set:(e,t,n)=>(e[t]=n,!0),has:(e,t)=>e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e};function d(e){return"function"==typeof e?(t=e)!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?(s||(s=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(t)?function(...e){return t.apply(p(this),e),f(o.get(this))}:function(...e){return f(t.apply(p(this),e))}:function(e,...n){const r=t.call(p(this),e,...n);return c.set(r,e.sort?e.sort():[e]),f(r)}:(e instanceof IDBTransaction&&function(e){if(a.has(e))return;const t=new Promise(((t,n)=>{const r=()=>{e.removeEventListener("complete",i),e.removeEventListener("error",s),e.removeEventListener("abort",s)},i=()=>{t(),r()},s=()=>{n(e.error||new DOMException("AbortError","AbortError")),r()};e.addEventListener("complete",i),e.addEventListener("error",s),e.addEventListener("abort",s)}));a.set(e,t)}(e),r(e,i||(i=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]))?new Proxy(e,h):e);var t}function f(e){if(e instanceof IDBRequest)return function(e){const t=new Promise(((t,n)=>{const r=()=>{e.removeEventListener("success",i),e.removeEventListener("error",s)},i=()=>{t(f(e.result)),r()},s=()=>{n(e.error),r()};e.addEventListener("success",i),e.addEventListener("error",s)}));return t.then((t=>{t instanceof IDBCursor&&o.set(t,e)})).catch((()=>{})),l.set(t,e),t}(e);if(u.has(e))return u.get(e);const t=d(e);return t!==e&&(u.set(e,t),l.set(t,e)),t}const p=e=>l.get(e);function m(e,t,{blocked:n,upgrade:r,blocking:i,terminated:s}={}){const o=indexedDB.open(e,t),a=f(o);return r&&o.addEventListener("upgradeneeded",(e=>{r(f(o.result),e.oldVersion,e.newVersion,f(o.transaction),e)})),n&&o.addEventListener("blocked",(e=>n(e.oldVersion,e.newVersion,e))),a.then((e=>{s&&e.addEventListener("close",(()=>s())),i&&e.addEventListener("versionchange",(e=>i(e.oldVersion,e.newVersion,e)))})).catch((()=>{})),a}function g(e,{blocked:t}={}){const n=indexedDB.deleteDatabase(e);return t&&n.addEventListener("blocked",(e=>t(e.oldVersion,e))),f(n).then((()=>{}))}const y=["get","getKey","getAll","getAllKeys","count"],v=["put","add","delete","clear"],b=new Map;function w(e,t){if(!(e instanceof IDBDatabase)||t in e||"string"!=typeof t)return;if(b.get(t))return b.get(t);const n=t.replace(/FromIndex$/,""),r=t!==n,i=v.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!i&&!y.includes(n))return;const s=async function(e,...t){const s=this.transaction(e,i?"readwrite":"readonly");let o=s.store;return r&&(o=o.index(t.shift())),(await Promise.all([o[n](...t),i&&s.done]))[0]};return b.set(t,s),s}var _;_=h,h={..._,get:(e,t,n)=>w(e,t)||_.get(e,t,n),has:(e,t)=>!!w(e,t)||_.has(e,t)}},1635:(e,t,n)=>{"use strict";n.r(t),n.d(t,{__addDisposableResource:()=>P,__assign:()=>s,__asyncDelegator:()=>S,__asyncGenerator:()=>T,__asyncValues:()=>C,__await:()=>E,__awaiter:()=>p,__classPrivateFieldGet:()=>O,__classPrivateFieldIn:()=>R,__classPrivateFieldSet:()=>D,__createBinding:()=>g,__decorate:()=>a,__disposeResources:()=>M,__esDecorate:()=>u,__exportStar:()=>y,__extends:()=>i,__generator:()=>m,__importDefault:()=>N,__importStar:()=>k,__makeTemplateObject:()=>A,__metadata:()=>f,__param:()=>c,__propKey:()=>h,__read:()=>b,__rest:()=>o,__runInitializers:()=>l,__setFunctionName:()=>d,__spread:()=>w,__spreadArray:()=>I,__spreadArrays:()=>_,__values:()=>v,default:()=>F});var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)};function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var s=function(){return s=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},s.apply(this,arguments)};function o(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}function a(e,t,n,r){var i,s=arguments.length,o=s<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(o=(s<3?i(o):s>3?i(t,n,o):i(t,n))||o);return s>3&&o&&Object.defineProperty(t,n,o),o}function c(e,t){return function(n,r){t(n,r,e)}}function u(e,t,n,r,i,s){function o(e){if(void 0!==e&&"function"!=typeof e)throw new TypeError("Function expected");return e}for(var a,c=r.kind,u="getter"===c?"get":"setter"===c?"set":"value",l=!t&&e?r.static?e:e.prototype:null,h=t||(l?Object.getOwnPropertyDescriptor(l,r.name):{}),d=!1,f=n.length-1;f>=0;f--){var p={};for(var m in r)p[m]="access"===m?{}:r[m];for(var m in r.access)p.access[m]=r.access[m];p.addInitializer=function(e){if(d)throw new TypeError("Cannot add initializers after decoration has completed");s.push(o(e||null))};var g=(0,n[f])("accessor"===c?{get:h.get,set:h.set}:h[u],p);if("accessor"===c){if(void 0===g)continue;if(null===g||"object"!=typeof g)throw new TypeError("Object expected");(a=o(g.get))&&(h.get=a),(a=o(g.set))&&(h.set=a),(a=o(g.init))&&i.unshift(a)}else(a=o(g))&&("field"===c?i.unshift(a):h[u]=a)}l&&Object.defineProperty(l,r.name,h),d=!0}function l(e,t,n){for(var r=arguments.length>2,i=0;i<t.length;i++)n=r?t[i].call(e,n):t[i].call(e);return r?n:void 0}function h(e){return"symbol"==typeof e?e:"".concat(e)}function d(e,t,n){return"symbol"==typeof t&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:n?"".concat(n," ",t):t})}function f(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function p(e,t,n,r){return new(n||(n=Promise))((function(i,s){function o(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((r=r.apply(e,t||[])).next())}))}function m(e,t){var n,r,i,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}var g=Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]};function y(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||g(t,e,n)}function v(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function b(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,s=n.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(r=s.next()).done;)o.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(i)throw i.error}}return o}function w(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(b(arguments[t]));return e}function _(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),i=0;for(t=0;t<n;t++)for(var s=arguments[t],o=0,a=s.length;o<a;o++,i++)r[i]=s[o];return r}function I(e,t,n){if(n||2===arguments.length)for(var r,i=0,s=t.length;i<s;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}function E(e){return this instanceof E?(this.v=e,this):new E(e)}function T(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,i=n.apply(e,t||[]),s=[];return r=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),o("next"),o("throw"),o("return",(function(e){return function(t){return Promise.resolve(t).then(e,u)}})),r[Symbol.asyncIterator]=function(){return this},r;function o(e,t){i[e]&&(r[e]=function(t){return new Promise((function(n,r){s.push([e,t,n,r])>1||a(e,t)}))},t&&(r[e]=t(r[e])))}function a(e,t){try{(n=i[e](t)).value instanceof E?Promise.resolve(n.value.v).then(c,u):l(s[0][2],n)}catch(e){l(s[0][3],e)}var n}function c(e){a("next",e)}function u(e){a("throw",e)}function l(e,t){e(t),s.shift(),s.length&&a(s[0][0],s[0][1])}}function S(e){var t,n;return t={},r("next"),r("throw",(function(e){throw e})),r("return"),t[Symbol.iterator]=function(){return this},t;function r(r,i){t[r]=e[r]?function(t){return(n=!n)?{value:E(e[r](t)),done:!1}:i?i(t):t}:i}}function C(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=v(e),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise((function(r,i){!function(e,t,n,r){Promise.resolve(r).then((function(t){e({value:t,done:n})}),t)}(r,i,(t=e[n](t)).done,t.value)}))}}}function A(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var x=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t};function k(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&g(t,e,n);return x(t,e),t}function N(e){return e&&e.__esModule?e:{default:e}}function O(e,t,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(e):r?r.value:t.get(e)}function D(e,t,n,r,i){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?i.call(e,n):i?i.value=n:t.set(e,n),n}function R(e,t){if(null===t||"object"!=typeof t&&"function"!=typeof t)throw new TypeError("Cannot use 'in' operator on non-object");return"function"==typeof e?t===e:e.has(t)}function P(e,t,n){if(null!=t){if("object"!=typeof t&&"function"!=typeof t)throw new TypeError("Object expected.");var r,i;if(n){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");r=t[Symbol.asyncDispose]}if(void 0===r){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");r=t[Symbol.dispose],n&&(i=r)}if("function"!=typeof r)throw new TypeError("Object not disposable.");i&&(r=function(){try{i.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:r,async:n})}else n&&e.stack.push({async:!0});return t}var L="function"==typeof SuppressedError?SuppressedError:function(e,t,n){var r=new Error(n);return r.name="SuppressedError",r.error=e,r.suppressed=t,r};function M(e){function t(t){e.error=e.hasError?new L(t,e.error,"An error was suppressed during disposal."):t,e.hasError=!0}var n,r=0;return function i(){for(;n=e.stack.pop();)try{if(!n.async&&1===r)return r=0,e.stack.push(n),Promise.resolve().then(i);if(n.dispose){var s=n.dispose.call(n.value);if(n.async)return r|=2,Promise.resolve(s).then(i,(function(e){return t(e),i()}))}else r|=1}catch(e){t(e)}if(1===r)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}()}const F={__extends:i,__assign:s,__rest:o,__decorate:a,__param:c,__metadata:f,__awaiter:p,__generator:m,__createBinding:g,__exportStar:y,__values:v,__read:b,__spread:w,__spreadArrays:_,__spreadArray:I,__await:E,__asyncGenerator:T,__asyncDelegator:S,__asyncValues:C,__makeTemplateObject:A,__importStar:k,__importDefault:N,__classPrivateFieldGet:O,__classPrivateFieldSet:D,__classPrivateFieldIn:R,__addDisposableResource:P,__disposeResources:M}}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var s=t[r]={exports:{}};return e[r].call(s.exports,s,s.exports,n),s.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r=n(8156);return r.default})()));
2
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Retter=t():e.Retter=t()}(self,(()=>(()=>{var e={6199:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r,i,s=n(5319),o=n(1635),a=n(5844),c=n(6336),u=n(6148),l=function(){function e(e){this.container=e}return e.prototype.getPlatformInfoString=function(){return this.container.getProviders().map((function(e){if(function(e){var t=e.getComponent();return"VERSION"===(null==t?void 0:t.type)}(e)){var t=e.getImmediate();return"".concat(t.library,"/").concat(t.version)}return null})).filter((function(e){return e})).join(" ")},e}(),h="@firebase/app",d="0.10.11",f=new a.Logger("@firebase/app"),p="[DEFAULT]",m=((r={})[h]="fire-core",r["@firebase/app-compat"]="fire-core-compat",r["@firebase/analytics"]="fire-analytics",r["@firebase/analytics-compat"]="fire-analytics-compat",r["@firebase/app-check"]="fire-app-check",r["@firebase/app-check-compat"]="fire-app-check-compat",r["@firebase/auth"]="fire-auth",r["@firebase/auth-compat"]="fire-auth-compat",r["@firebase/database"]="fire-rtdb",r["@firebase/database-compat"]="fire-rtdb-compat",r["@firebase/functions"]="fire-fn",r["@firebase/functions-compat"]="fire-fn-compat",r["@firebase/installations"]="fire-iid",r["@firebase/installations-compat"]="fire-iid-compat",r["@firebase/messaging"]="fire-fcm",r["@firebase/messaging-compat"]="fire-fcm-compat",r["@firebase/performance"]="fire-perf",r["@firebase/performance-compat"]="fire-perf-compat",r["@firebase/remote-config"]="fire-rc",r["@firebase/remote-config-compat"]="fire-rc-compat",r["@firebase/storage"]="fire-gcs",r["@firebase/storage-compat"]="fire-gcs-compat",r["@firebase/firestore"]="fire-fst",r["@firebase/firestore-compat"]="fire-fst-compat",r["@firebase/vertexai-preview"]="fire-vertex",r["fire-js"]="fire-js",r.firebase="fire-js-all",r),g=new Map,y=new Map,v=new Map;function b(e,t){try{e.container.addComponent(t)}catch(n){f.debug("Component ".concat(t.name," failed to register with FirebaseApp ").concat(e.name),n)}}function w(e){var t,n,r,i,s=e.name;if(v.has(s))return f.debug("There were multiple attempts to register component ".concat(s,".")),!1;v.set(s,e);try{for(var a=o.__values(g.values()),c=a.next();!c.done;c=a.next())b(c.value,e)}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}try{for(var u=o.__values(y.values()),l=u.next();!l.done;l=u.next())b(l.value,e)}catch(e){r={error:e}}finally{try{l&&!l.done&&(i=u.return)&&i.call(u)}finally{if(r)throw r.error}}return!0}function _(e,t){var n=e.container.getProvider("heartbeat").getImmediate({optional:!0});return n&&n.triggerHeartbeat(),e.container.getProvider(t)}function I(e){return void 0!==e.options}var E=((i={})["no-app"]="No Firebase App '{$appName}' has been created - call initializeApp() first",i["bad-app-name"]="Illegal App name: '{$appName}'",i["duplicate-app"]="Firebase App named '{$appName}' already exists with different options or config",i["app-deleted"]="Firebase App named '{$appName}' already deleted",i["server-app-deleted"]="Firebase Server App has been deleted",i["no-options"]="Need to provide options, when not being deployed to hosting via source.",i["invalid-app-argument"]="firebase.{$appName}() takes either no argument or a Firebase App instance.",i["invalid-log-argument"]="First argument to `onLog` must be null or a function.",i["idb-open"]="Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.",i["idb-get"]="Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.",i["idb-set"]="Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.",i["idb-delete"]="Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.",i["finalization-registry-not-supported"]="FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.",i["invalid-server-app-environment"]="FirebaseServerApp is not for use in browser environments.",i),T=new c.ErrorFactory("app","Firebase",E),S=function(){function e(e,t,n){var r=this;this._isDeleted=!1,this._options=o.__assign({},e),this._config=o.__assign({},t),this._name=t.name,this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled,this._container=n,this.container.addComponent(new s.Component("app",(function(){return r}),"PUBLIC"))}return Object.defineProperty(e.prototype,"automaticDataCollectionEnabled",{get:function(){return this.checkDestroyed(),this._automaticDataCollectionEnabled},set:function(e){this.checkDestroyed(),this._automaticDataCollectionEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"name",{get:function(){return this.checkDestroyed(),this._name},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"options",{get:function(){return this.checkDestroyed(),this._options},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"config",{get:function(){return this.checkDestroyed(),this._config},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"container",{get:function(){return this._container},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isDeleted",{get:function(){return this._isDeleted},set:function(e){this._isDeleted=e},enumerable:!1,configurable:!0}),e.prototype.checkDestroyed=function(){if(this.isDeleted)throw T.create("app-deleted",{appName:this._name})},e}(),C=function(e){function t(t,n,r,i){var s=this,a=void 0!==n.automaticDataCollectionEnabled&&n.automaticDataCollectionEnabled,c={name:r,automaticDataCollectionEnabled:a};if(void 0!==t.apiKey)s=e.call(this,t,c,i)||this;else{var u=t;s=e.call(this,u.options,c,i)||this}return s._serverConfig=o.__assign({automaticDataCollectionEnabled:a},n),s._finalizationRegistry=null,"undefined"!=typeof FinalizationRegistry&&(s._finalizationRegistry=new FinalizationRegistry((function(){s.automaticCleanup()}))),s._refCount=0,s.incRefCount(s._serverConfig.releaseOnDeref),s._serverConfig.releaseOnDeref=void 0,n.releaseOnDeref=void 0,k(h,d,"serverapp"),s}return o.__extends(t,e),t.prototype.toJSON=function(){},Object.defineProperty(t.prototype,"refCount",{get:function(){return this._refCount},enumerable:!1,configurable:!0}),t.prototype.incRefCount=function(e){this.isDeleted||(this._refCount++,void 0!==e&&null!==this._finalizationRegistry&&this._finalizationRegistry.register(e,this))},t.prototype.decRefCount=function(){return this.isDeleted?0:--this._refCount},t.prototype.automaticCleanup=function(){x(this)},Object.defineProperty(t.prototype,"settings",{get:function(){return this.checkDestroyed(),this._serverConfig},enumerable:!1,configurable:!0}),t.prototype.checkDestroyed=function(){if(this.isDeleted)throw T.create("server-app-deleted")},t}(S);function A(e,t){var n,r;void 0===t&&(t={});var i=e;"object"!=typeof t&&(t={name:t});var a=o.__assign({name:p,automaticDataCollectionEnabled:!1},t),u=a.name;if("string"!=typeof u||!u)throw T.create("bad-app-name",{appName:String(u)});if(i||(i=c.getDefaultAppConfig()),!i)throw T.create("no-options");var l=g.get(u);if(l){if(c.deepEqual(i,l.options)&&c.deepEqual(a,l.config))return l;throw T.create("duplicate-app",{appName:u})}var h=new s.ComponentContainer(u);try{for(var d=o.__values(v.values()),f=d.next();!f.done;f=d.next()){var m=f.value;h.addComponent(m)}}catch(e){n={error:e}}finally{try{f&&!f.done&&(r=d.return)&&r.call(d)}finally{if(n)throw n.error}}var y=new S(i,a,h);return g.set(u,y),y}function x(e){return o.__awaiter(this,void 0,void 0,(function(){var t,n;return o.__generator(this,(function(r){switch(r.label){case 0:return t=!1,n=e.name,g.has(n)?(t=!0,g.delete(n)):y.has(n)&&e.decRefCount()<=0&&(y.delete(n),t=!0),t?[4,Promise.all(e.container.getProviders().map((function(e){return e.delete()})))]:[3,2];case 1:r.sent(),e.isDeleted=!0,r.label=2;case 2:return[2]}}))}))}function k(e,t,n){var r,i=null!==(r=m[e])&&void 0!==r?r:e;n&&(i+="-".concat(n));var o=i.match(/\s|\//),a=t.match(/\s|\//);if(o||a){var c=['Unable to register library "'.concat(i,'" with version "').concat(t,'":')];return o&&c.push('library name "'.concat(i,'" contains illegal characters (whitespace or "/")')),o&&a&&c.push("and"),a&&c.push('version name "'.concat(t,'" contains illegal characters (whitespace or "/")')),void f.warn(c.join(" "))}w(new s.Component("".concat(i,"-version"),(function(){return{library:i,version:t}}),"VERSION"))}var N="firebase-heartbeat-database",O=1,D="firebase-heartbeat-store",R=null;function P(){return R||(R=u.openDB(N,O,{upgrade:function(e,t){if(0===t)try{e.createObjectStore(D)}catch(e){console.warn(e)}}}).catch((function(e){throw T.create("idb-open",{originalErrorMessage:e.message})}))),R}function L(e){return o.__awaiter(this,void 0,void 0,(function(){var t,n,r,i,s;return o.__generator(this,(function(o){switch(o.label){case 0:return o.trys.push([0,4,,5]),[4,P()];case 1:return t=o.sent(),[4,(n=t.transaction(D)).objectStore(D).get(F(e))];case 2:return r=o.sent(),[4,n.done];case 3:return o.sent(),[2,r];case 4:return(i=o.sent())instanceof c.FirebaseError?f.warn(i.message):(s=T.create("idb-get",{originalErrorMessage:null==i?void 0:i.message}),f.warn(s.message)),[3,5];case 5:return[2]}}))}))}function M(e,t){return o.__awaiter(this,void 0,void 0,(function(){var n,r,i,s;return o.__generator(this,(function(o){switch(o.label){case 0:return o.trys.push([0,4,,5]),[4,P()];case 1:return n=o.sent(),[4,(r=n.transaction(D,"readwrite")).objectStore(D).put(t,F(e))];case 2:return o.sent(),[4,r.done];case 3:return o.sent(),[3,5];case 4:return(i=o.sent())instanceof c.FirebaseError?f.warn(i.message):(s=T.create("idb-set",{originalErrorMessage:null==i?void 0:i.message}),f.warn(s.message)),[3,5];case 5:return[2]}}))}))}function F(e){return"".concat(e.name,"!").concat(e.options.appId)}var V=function(){function e(e){var t=this;this.container=e,this._heartbeatsCache=null;var n=this.container.getProvider("app").getImmediate();this._storage=new j(n),this._heartbeatsCachePromise=this._storage.read().then((function(e){return t._heartbeatsCache=e,e}))}return e.prototype.triggerHeartbeat=function(){var e,t;return o.__awaiter(this,void 0,void 0,(function(){var n,r,i,s,a;return o.__generator(this,(function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),n=this.container.getProvider("platform-logger").getImmediate(),r=n.getPlatformInfoString(),i=U(),null!=(null===(e=this._heartbeatsCache)||void 0===e?void 0:e.heartbeats)?[3,2]:(s=this,[4,this._heartbeatsCachePromise]);case 1:if(s._heartbeatsCache=o.sent(),null==(null===(t=this._heartbeatsCache)||void 0===t?void 0:t.heartbeats))return[2];o.label=2;case 2:return this._heartbeatsCache.lastSentHeartbeatDate===i||this._heartbeatsCache.heartbeats.some((function(e){return e.date===i}))?[2]:(this._heartbeatsCache.heartbeats.push({date:i,agent:r}),this._heartbeatsCache.heartbeats=this._heartbeatsCache.heartbeats.filter((function(e){var t=new Date(e.date).valueOf();return Date.now()-t<=2592e6})),[2,this._storage.overwrite(this._heartbeatsCache)]);case 3:return a=o.sent(),f.warn(a),[3,4];case 4:return[2]}}))}))},e.prototype.getHeartbeatsHeader=function(){var e;return o.__awaiter(this,void 0,void 0,(function(){var t,n,r,i,s,a;return o.__generator(this,(function(u){switch(u.label){case 0:return u.trys.push([0,6,,7]),null!==this._heartbeatsCache?[3,2]:[4,this._heartbeatsCachePromise];case 1:u.sent(),u.label=2;case 2:return null==(null===(e=this._heartbeatsCache)||void 0===e?void 0:e.heartbeats)||0===this._heartbeatsCache.heartbeats.length?[2,""]:(t=U(),n=function(e,t){var n,r;void 0===t&&(t=1024);var i=[],s=e.slice(),a=function(e){var n=i.find((function(t){return t.agent===e.agent}));if(n){if(n.dates.push(e.date),B(i)>t)return n.dates.pop(),"break"}else if(i.push({agent:e.agent,dates:[e.date]}),B(i)>t)return i.pop(),"break";s=s.slice(1)};try{for(var c=o.__values(e),u=c.next();!u.done&&"break"!==a(u.value);u=c.next());}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}return{heartbeatsToSend:i,unsentEntries:s}}(this._heartbeatsCache.heartbeats),r=n.heartbeatsToSend,i=n.unsentEntries,s=c.base64urlEncodeWithoutPadding(JSON.stringify({version:2,heartbeats:r})),this._heartbeatsCache.lastSentHeartbeatDate=t,i.length>0?(this._heartbeatsCache.heartbeats=i,[4,this._storage.overwrite(this._heartbeatsCache)]):[3,4]);case 3:return u.sent(),[3,5];case 4:this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache),u.label=5;case 5:return[2,s];case 6:return a=u.sent(),f.warn(a),[2,""];case 7:return[2]}}))}))},e}();function U(){return(new Date).toISOString().substring(0,10)}var j=function(){function e(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}return e.prototype.runIndexedDBEnvironmentCheck=function(){return o.__awaiter(this,void 0,void 0,(function(){return o.__generator(this,(function(e){return c.isIndexedDBAvailable()?[2,c.validateIndexedDBOpenable().then((function(){return!0})).catch((function(){return!1}))]:[2,!1]}))}))},e.prototype.read=function(){return o.__awaiter(this,void 0,void 0,(function(){var e;return o.__generator(this,(function(t){switch(t.label){case 0:return[4,this._canUseIndexedDBPromise];case 1:return t.sent()?[3,2]:[2,{heartbeats:[]}];case 2:return[4,L(this.app)];case 3:return(null==(e=t.sent())?void 0:e.heartbeats)?[2,e]:[2,{heartbeats:[]}];case 4:return[2]}}))}))},e.prototype.overwrite=function(e){var t;return o.__awaiter(this,void 0,void 0,(function(){var n;return o.__generator(this,(function(r){switch(r.label){case 0:return[4,this._canUseIndexedDBPromise];case 1:return r.sent()?[3,2]:[2];case 2:return[4,this.read()];case 3:return n=r.sent(),[2,M(this.app,{lastSentHeartbeatDate:null!==(t=e.lastSentHeartbeatDate)&&void 0!==t?t:n.lastSentHeartbeatDate,heartbeats:e.heartbeats})]}}))}))},e.prototype.add=function(e){var t;return o.__awaiter(this,void 0,void 0,(function(){var n;return o.__generator(this,(function(r){switch(r.label){case 0:return[4,this._canUseIndexedDBPromise];case 1:return r.sent()?[3,2]:[2];case 2:return[4,this.read()];case 3:return n=r.sent(),[2,M(this.app,{lastSentHeartbeatDate:null!==(t=e.lastSentHeartbeatDate)&&void 0!==t?t:n.lastSentHeartbeatDate,heartbeats:o.__spreadArray(o.__spreadArray([],o.__read(n.heartbeats),!1),o.__read(e.heartbeats),!1)})]}}))}))},e}();function B(e){return c.base64urlEncodeWithoutPadding(JSON.stringify({version:2,heartbeats:e})).length}w(new s.Component("platform-logger",(function(e){return new l(e)}),"PRIVATE")),w(new s.Component("heartbeat",(function(e){return new V(e)}),"PRIVATE")),k(h,d,"node"),k(h,d,"cjs5"),k("fire-js",""),Object.defineProperty(t,"FirebaseError",{enumerable:!0,get:function(){return c.FirebaseError}}),t.SDK_VERSION="10.13.2",t._DEFAULT_ENTRY_NAME=p,t._addComponent=b,t._addOrOverwriteComponent=function(e,t){e.container.addOrOverwriteComponent(t)},t._apps=g,t._clearComponents=function(){v.clear()},t._components=v,t._getProvider=_,t._isFirebaseApp=I,t._isFirebaseServerApp=function(e){return void 0!==e.settings},t._registerComponent=w,t._removeServiceInstance=function(e,t,n){void 0===n&&(n=p),_(e,t).clearInstance(n)},t._serverApps=y,t.deleteApp=x,t.getApp=function(e){void 0===e&&(e=p);var t=g.get(e);if(!t&&e===p&&c.getDefaultAppConfig())return A();if(!t)throw T.create("no-app",{appName:e});return t},t.getApps=function(){return Array.from(g.values())},t.initializeApp=A,t.initializeServerApp=function(e,t){var n,r,i;if(c.isBrowser()&&!c.isWebWorker())throw T.create("invalid-server-app-environment");void 0===t.automaticDataCollectionEnabled&&(t.automaticDataCollectionEnabled=!1),i=I(e)?e.options:e;var a=o.__assign(o.__assign({},t),i);if(void 0!==a.releaseOnDeref&&delete a.releaseOnDeref,void 0!==t.releaseOnDeref&&"undefined"==typeof FinalizationRegistry)throw T.create("finalization-registry-not-supported",{});var u,l=""+(u=JSON.stringify(a),o.__spreadArray([],o.__read(u),!1).reduce((function(e,t){return Math.imul(31,e)+t.charCodeAt(0)|0}),0)),h=y.get(l);if(h)return h.incRefCount(t.releaseOnDeref),h;var d=new s.ComponentContainer(l);try{for(var f=o.__values(v.values()),p=f.next();!p.done;p=f.next()){var m=p.value;d.addComponent(m)}}catch(e){n={error:e}}finally{try{p&&!p.done&&(r=f.return)&&r.call(f)}finally{if(n)throw n.error}}var g=new C(i,t,l,d);return y.set(l,g),g},t.onLog=function(e,t){if(null!==e&&"function"!=typeof e)throw T.create("invalid-log-argument");a.setUserLogHandler(e,t)},t.registerVersion=k,t.setLogLevel=function(e){a.setLogLevel(e)}},6906:(e,t,n)=>{"use strict";var r=n(6199),i=n(6336),s=n(5844),o=n(1635),a=n(5319);const c=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."}},u=new i.ErrorFactory("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."}),l=new s.Logger("@firebase/auth");function h(e,...t){l.logLevel<=s.LogLevel.ERROR&&l.error(`Auth (${r.SDK_VERSION}): ${e}`,...t)}function d(e,...t){throw y(e,...t)}function f(e,...t){return y(e,...t)}function p(e,t,n){const r=Object.assign(Object.assign({},c()),{[t]:n});return new i.ErrorFactory("auth","Firebase",r).create(t,{appName:e.name})}function m(e){return p(e,"operation-not-supported-in-this-environment","Operations that alter the current user are not supported in conjunction with FirebaseServerApp")}function g(e,t,n){if(!(t instanceof n))throw n.name!==t.constructor.name&&d(e,"argument-error"),p(e,"argument-error",`Type of ${t.constructor.name} does not match expected instance.Did you pass a reference from a different Auth SDK?`)}function y(e,...t){if("string"!=typeof e){const n=t[0],r=[...t.slice(1)];return r[0]&&(r[0].appName=e.name),e._errorFactory.create(n,...r)}return u.create(e,...t)}function v(e,t,...n){if(!e)throw y(t,...n)}function b(e){const t="INTERNAL ASSERTION FAILED: "+e;throw h(t),new Error(t)}function w(e,t){e||b(t)}function _(){var e;return"undefined"!=typeof self&&(null===(e=self.location)||void 0===e?void 0:e.href)||""}function I(){return"http:"===E()||"https:"===E()}function E(){var e;return"undefined"!=typeof self&&(null===(e=self.location)||void 0===e?void 0:e.protocol)||null}class T{constructor(e,t){this.shortDelay=e,this.longDelay=t,w(t>e,"Short delay should be less than long delay!"),this.isMobile=i.isMobileCordova()||i.isReactNative()}get(){return"undefined"!=typeof navigator&&navigator&&"onLine"in navigator&&"boolean"==typeof navigator.onLine&&(I()||i.isBrowserExtension()||"connection"in navigator)&&!navigator.onLine?Math.min(5e3,this.shortDelay):this.isMobile?this.longDelay:this.shortDelay}}function S(e,t){w(e.emulator,"Emulator should always be set here");const{url:n}=e.emulator;return t?`${n}${t.startsWith("/")?t.slice(1):t}`:n}class C{static initialize(e,t,n){this.fetchImpl=e,t&&(this.headersImpl=t),n&&(this.responseImpl=n)}static fetch(){return this.fetchImpl?this.fetchImpl:"undefined"!=typeof self&&"fetch"in self?self.fetch:"undefined"!=typeof globalThis&&globalThis.fetch?globalThis.fetch:"undefined"!=typeof fetch?fetch:void b("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:"undefined"!=typeof globalThis&&globalThis.Headers?globalThis.Headers:"undefined"!=typeof Headers?Headers:void b("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:"undefined"!=typeof globalThis&&globalThis.Response?globalThis.Response:"undefined"!=typeof Response?Response:void b("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}}const A={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:"missing-password",INVALID_LOGIN_CREDENTIALS:"invalid-credential",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",PASSWORD_DOES_NOT_MEET_REQUIREMENTS:"password-does-not-meet-requirements",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",RECAPTCHA_NOT_ENABLED:"recaptcha-not-enabled",MISSING_RECAPTCHA_TOKEN:"missing-recaptcha-token",INVALID_RECAPTCHA_TOKEN:"invalid-recaptcha-token",INVALID_RECAPTCHA_ACTION:"invalid-recaptcha-action",MISSING_CLIENT_TYPE:"missing-client-type",MISSING_RECAPTCHA_VERSION:"missing-recaptcha-version",INVALID_RECAPTCHA_VERSION:"invalid-recaptcha-version",INVALID_REQ_TYPE:"invalid-req-type"},x=new T(3e4,6e4);function k(e,t){return e.tenantId&&!t.tenantId?Object.assign(Object.assign({},t),{tenantId:e.tenantId}):t}async function N(e,t,n,r,s={}){return O(e,s,(async()=>{let s={},o={};r&&("GET"===t?o=r:s={body:JSON.stringify(r)});const a=i.querystring(Object.assign({key:e.config.apiKey},o)).slice(1),c=await e._getAdditionalHeaders();c["Content-Type"]="application/json",e.languageCode&&(c["X-Firebase-Locale"]=e.languageCode);const u=Object.assign({method:t,headers:c},s);return i.isCloudflareWorker()||(u.referrerPolicy="no-referrer"),C.fetch()(R(e,e.config.apiHost,n,a),u)}))}async function O(e,t,n){e._canInitEmulator=!1;const r=Object.assign(Object.assign({},A),t);try{const t=new L(e),i=await Promise.race([n(),t.promise]);t.clearNetworkTimeout();const s=await i.json();if("needConfirmation"in s)throw M(e,"account-exists-with-different-credential",s);if(i.ok&&!("errorMessage"in s))return s;{const t=i.ok?s.errorMessage:s.error.message,[n,o]=t.split(" : ");if("FEDERATED_USER_ID_ALREADY_LINKED"===n)throw M(e,"credential-already-in-use",s);if("EMAIL_EXISTS"===n)throw M(e,"email-already-in-use",s);if("USER_DISABLED"===n)throw M(e,"user-disabled",s);const a=r[n]||n.toLowerCase().replace(/[_\s]+/g,"-");if(o)throw p(e,a,o);d(e,a)}}catch(t){if(t instanceof i.FirebaseError)throw t;d(e,"network-request-failed",{message:String(t)})}}async function D(e,t,n,r,i={}){const s=await N(e,t,n,r,i);return"mfaPendingCredential"in s&&d(e,"multi-factor-auth-required",{_serverResponse:s}),s}function R(e,t,n,r){const i=`${t}${n}?${r}`;return e.config.emulator?S(e.config,i):`${e.config.apiScheme}://${i}`}function P(e){switch(e){case"ENFORCE":return"ENFORCE";case"AUDIT":return"AUDIT";case"OFF":return"OFF";default:return"ENFORCEMENT_STATE_UNSPECIFIED"}}class L{constructor(e){this.auth=e,this.timer=null,this.promise=new Promise(((e,t)=>{this.timer=setTimeout((()=>t(f(this.auth,"network-request-failed"))),x.get())}))}clearNetworkTimeout(){clearTimeout(this.timer)}}function M(e,t,n){const r={appName:e.name};n.email&&(r.email=n.email),n.phoneNumber&&(r.phoneNumber=n.phoneNumber);const i=f(e,t,r);return i.customData._tokenResponse=n,i}function F(e){return void 0!==e&&void 0!==e.getResponse}function V(e){return void 0!==e&&void 0!==e.enterprise}class U{constructor(e){if(this.siteKey="",this.recaptchaEnforcementState=[],void 0===e.recaptchaKey)throw new Error("recaptchaKey undefined");this.siteKey=e.recaptchaKey.split("/")[3],this.recaptchaEnforcementState=e.recaptchaEnforcementState}getProviderEnforcementState(e){if(!this.recaptchaEnforcementState||0===this.recaptchaEnforcementState.length)return null;for(const t of this.recaptchaEnforcementState)if(t.provider&&t.provider===e)return P(t.enforcementState);return null}isProviderEnabled(e){return"ENFORCE"===this.getProviderEnforcementState(e)||"AUDIT"===this.getProviderEnforcementState(e)}}async function j(e,t){return N(e,"GET","/v2/recaptchaConfig",k(e,t))}async function B(e,t){return N(e,"POST","/v1/accounts:lookup",t)}function q(e){if(e)try{const t=new Date(Number(e));if(!isNaN(t.getTime()))return t.toUTCString()}catch(e){}}async function z(e,t=!1){const n=i.getModularInstance(e),r=await n.getIdToken(t),s=K(r);v(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:r,authTime:q(G(s.auth_time)),issuedAtTime:q(G(s.iat)),expirationTime:q(G(s.exp)),signInProvider:a||null,signInSecondFactor:(null==o?void 0:o.sign_in_second_factor)||null}}function G(e){return 1e3*Number(e)}function K(e){const[t,n,r]=e.split(".");if(void 0===t||void 0===n||void 0===r)return h("JWT malformed, contained fewer than 3 sections"),null;try{const e=i.base64Decode(n);return e?JSON.parse(e):(h("Failed to decode base64 JWT payload"),null)}catch(e){return h("Caught error parsing JWT payload as JSON",null==e?void 0:e.toString()),null}}function W(e){const t=K(e);return v(t,"internal-error"),v(void 0!==t.exp,"internal-error"),v(void 0!==t.iat,"internal-error"),Number(t.exp)-Number(t.iat)}async function $(e,t,n=!1){if(n)return t;try{return await t}catch(t){throw t instanceof i.FirebaseError&&function({code:e}){return"auth/user-disabled"===e||"auth/user-token-expired"===e}(t)&&e.auth.currentUser===e&&await e.auth.signOut(),t}}class H{constructor(e){this.user=e,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(e){var t;if(e){const e=this.errorBackoff;return this.errorBackoff=Math.min(2*this.errorBackoff,96e4),e}{this.errorBackoff=3e4;const e=(null!==(t=this.user.stsTokenManager.expirationTime)&&void 0!==t?t:0)-Date.now()-3e5;return Math.max(0,e)}}schedule(e=!1){if(!this.isRunning)return;const t=this.getInterval(e);this.timerId=setTimeout((async()=>{await this.iteration()}),t)}async iteration(){try{await this.user.getIdToken(!0)}catch(e){return void("auth/network-request-failed"===(null==e?void 0:e.code)&&this.schedule(!0))}this.schedule()}}class Q{constructor(e,t){this.createdAt=e,this.lastLoginAt=t,this._initializeTime()}_initializeTime(){this.lastSignInTime=q(this.lastLoginAt),this.creationTime=q(this.createdAt)}_copy(e){this.createdAt=e.createdAt,this.lastLoginAt=e.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}async function J(e){var t;const n=e.auth,r=await e.getIdToken(),i=await $(e,B(n,{idToken:r}));v(null==i?void 0:i.users.length,n,"internal-error");const s=i.users[0];e._notifyReloadListener(s);const o=(null===(t=s.providerUserInfo)||void 0===t?void 0:t.length)?X(s.providerUserInfo):[],a=(c=e.providerData,u=o,[...c.filter((e=>!u.some((t=>t.providerId===e.providerId)))),...u]);var c,u;const l=e.isAnonymous,h=!(e.email&&s.passwordHash||(null==a?void 0:a.length)),d=!!l&&h,f={uid:s.localId,displayName:s.displayName||null,photoURL:s.photoUrl||null,email:s.email||null,emailVerified:s.emailVerified||!1,phoneNumber:s.phoneNumber||null,tenantId:s.tenantId||null,providerData:a,metadata:new Q(s.createdAt,s.lastLoginAt),isAnonymous:d};Object.assign(e,f)}async function Y(e){const t=i.getModularInstance(e);await J(t),await t.auth._persistUserIfCurrent(t),t.auth._notifyListenersIfCurrent(t)}function X(e){return e.map((e=>{var{providerId:t}=e,n=o.__rest(e,["providerId"]);return{providerId:t,uid:n.rawId||"",displayName:n.displayName||null,email:n.email||null,phoneNumber:n.phoneNumber||null,photoURL:n.photoUrl||null}}))}class Z{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){v(e.idToken,"internal-error"),v(void 0!==e.idToken,"internal-error"),v(void 0!==e.refreshToken,"internal-error");const t="expiresIn"in e&&void 0!==e.expiresIn?Number(e.expiresIn):W(e.idToken);this.updateTokensAndExpiration(e.idToken,e.refreshToken,t)}updateFromIdToken(e){v(0!==e.length,"internal-error");const t=W(e);this.updateTokensAndExpiration(e,null,t)}async getToken(e,t=!1){return t||!this.accessToken||this.isExpired?(v(this.refreshToken,e,"user-token-expired"),this.refreshToken?(await this.refresh(e,this.refreshToken),this.accessToken):null):this.accessToken}clearRefreshToken(){this.refreshToken=null}async refresh(e,t){const{accessToken:n,refreshToken:r,expiresIn:s}=await async function(e,t){const n=await O(e,{},(async()=>{const n=i.querystring({grant_type:"refresh_token",refresh_token:t}).slice(1),{tokenApiHost:r,apiKey:s}=e.config,o=R(e,r,"/v1/token",`key=${s}`),a=await e._getAdditionalHeaders();return a["Content-Type"]="application/x-www-form-urlencoded",C.fetch()(o,{method:"POST",headers:a,body:n})}));return{accessToken:n.access_token,expiresIn:n.expires_in,refreshToken:n.refresh_token}}(e,t);this.updateTokensAndExpiration(n,r,Number(s))}updateTokensAndExpiration(e,t,n){this.refreshToken=t||null,this.accessToken=e||null,this.expirationTime=Date.now()+1e3*n}static fromJSON(e,t){const{refreshToken:n,accessToken:r,expirationTime:i}=t,s=new Z;return n&&(v("string"==typeof n,"internal-error",{appName:e}),s.refreshToken=n),r&&(v("string"==typeof r,"internal-error",{appName:e}),s.accessToken=r),i&&(v("number"==typeof i,"internal-error",{appName:e}),s.expirationTime=i),s}toJSON(){return{refreshToken:this.refreshToken,accessToken:this.accessToken,expirationTime:this.expirationTime}}_assign(e){this.accessToken=e.accessToken,this.refreshToken=e.refreshToken,this.expirationTime=e.expirationTime}_clone(){return Object.assign(new Z,this.toJSON())}_performRefresh(){return b("not implemented")}}function ee(e,t){v("string"==typeof e||void 0===e,"internal-error",{appName:t})}class te{constructor(e){var{uid:t,auth:n,stsTokenManager:r}=e,i=o.__rest(e,["uid","auth","stsTokenManager"]);this.providerId="firebase",this.proactiveRefresh=new H(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=t,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.providerData=i.providerData?[...i.providerData]:[],this.metadata=new Q(i.createdAt||void 0,i.lastLoginAt||void 0)}async getIdToken(e){const t=await $(this,this.stsTokenManager.getToken(this.auth,e));return v(t,this.auth,"internal-error"),this.accessToken!==t&&(this.accessToken=t,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),t}getIdTokenResult(e){return z(this,e)}reload(){return Y(this)}_assign(e){this!==e&&(v(this.uid===e.uid,this.auth,"internal-error"),this.displayName=e.displayName,this.photoURL=e.photoURL,this.email=e.email,this.emailVerified=e.emailVerified,this.phoneNumber=e.phoneNumber,this.isAnonymous=e.isAnonymous,this.tenantId=e.tenantId,this.providerData=e.providerData.map((e=>Object.assign({},e))),this.metadata._copy(e.metadata),this.stsTokenManager._assign(e.stsTokenManager))}_clone(e){const t=new te(Object.assign(Object.assign({},this),{auth:e,stsTokenManager:this.stsTokenManager._clone()}));return t.metadata._copy(this.metadata),t}_onReload(e){v(!this.reloadListener,this.auth,"internal-error"),this.reloadListener=e,this.reloadUserInfo&&(this._notifyReloadListener(this.reloadUserInfo),this.reloadUserInfo=null)}_notifyReloadListener(e){this.reloadListener?this.reloadListener(e):this.reloadUserInfo=e}_startProactiveRefresh(){this.proactiveRefresh._start()}_stopProactiveRefresh(){this.proactiveRefresh._stop()}async _updateTokensIfNecessary(e,t=!1){let n=!1;e.idToken&&e.idToken!==this.stsTokenManager.accessToken&&(this.stsTokenManager.updateFromServerResponse(e),n=!0),t&&await J(this),await this.auth._persistUserIfCurrent(this),n&&this.auth._notifyListenersIfCurrent(this)}async delete(){if(r._isFirebaseServerApp(this.auth.app))return Promise.reject(m(this.auth));const e=await this.getIdToken();return await $(this,async function(e,t){return N(e,"POST","/v1/accounts:delete",t)}(this.auth,{idToken:e})),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((e=>Object.assign({},e))),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(e,t){var n,r,i,s,o,a,c,u;const l=null!==(n=t.displayName)&&void 0!==n?n:void 0,h=null!==(r=t.email)&&void 0!==r?r:void 0,d=null!==(i=t.phoneNumber)&&void 0!==i?i:void 0,f=null!==(s=t.photoURL)&&void 0!==s?s:void 0,p=null!==(o=t.tenantId)&&void 0!==o?o:void 0,m=null!==(a=t._redirectEventId)&&void 0!==a?a:void 0,g=null!==(c=t.createdAt)&&void 0!==c?c:void 0,y=null!==(u=t.lastLoginAt)&&void 0!==u?u:void 0,{uid:b,emailVerified:w,isAnonymous:_,providerData:I,stsTokenManager:E}=t;v(b&&E,e,"internal-error");const T=Z.fromJSON(this.name,E);v("string"==typeof b,e,"internal-error"),ee(l,e.name),ee(h,e.name),v("boolean"==typeof w,e,"internal-error"),v("boolean"==typeof _,e,"internal-error"),ee(d,e.name),ee(f,e.name),ee(p,e.name),ee(m,e.name),ee(g,e.name),ee(y,e.name);const S=new te({uid:b,auth:e,email:h,emailVerified:w,displayName:l,isAnonymous:_,photoURL:f,phoneNumber:d,tenantId:p,stsTokenManager:T,createdAt:g,lastLoginAt:y});return I&&Array.isArray(I)&&(S.providerData=I.map((e=>Object.assign({},e)))),m&&(S._redirectEventId=m),S}static async _fromIdTokenResponse(e,t,n=!1){const r=new Z;r.updateFromServerResponse(t);const i=new te({uid:t.localId,auth:e,stsTokenManager:r,isAnonymous:n});return await J(i),i}static async _fromGetAccountInfoResponse(e,t,n){const r=t.users[0];v(void 0!==r.localId,"internal-error");const i=void 0!==r.providerUserInfo?X(r.providerUserInfo):[],s=!(r.email&&r.passwordHash||(null==i?void 0:i.length)),o=new Z;o.updateFromIdToken(n);const a=new te({uid:r.localId,auth:e,stsTokenManager:o,isAnonymous:s}),c={uid:r.localId,displayName:r.displayName||null,photoURL:r.photoUrl||null,email:r.email||null,emailVerified:r.emailVerified||!1,phoneNumber:r.phoneNumber||null,tenantId:r.tenantId||null,providerData:i,metadata:new Q(r.createdAt,r.lastLoginAt),isAnonymous:!(r.email&&r.passwordHash||(null==i?void 0:i.length))};return Object.assign(a,c),a}}const ne=new Map;function re(e){w(e instanceof Function,"Expected a class definition");let t=ne.get(e);return t?(w(t instanceof e,"Instance stored in cache mismatched with class"),t):(t=new e,ne.set(e,t),t)}class ie{constructor(){this.type="NONE",this.storage={}}async _isAvailable(){return!0}async _set(e,t){this.storage[e]=t}async _get(e){const t=this.storage[e];return void 0===t?null:t}async _remove(e){delete this.storage[e]}_addListener(e,t){}_removeListener(e,t){}}ie.type="NONE";const se=ie;function oe(e,t,n){return`firebase:${e}:${t}:${n}`}class ae{constructor(e,t,n){this.persistence=e,this.auth=t,this.userKey=n;const{config:r,name:i}=this.auth;this.fullUserKey=oe(this.userKey,r.apiKey,i),this.fullPersistenceKey=oe("persistence",r.apiKey,i),this.boundEventHandler=t._onStorageEvent.bind(t),this.persistence._addListener(this.fullUserKey,this.boundEventHandler)}setCurrentUser(e){return this.persistence._set(this.fullUserKey,e.toJSON())}async getCurrentUser(){const e=await this.persistence._get(this.fullUserKey);return e?te._fromJSON(this.auth,e):null}removeCurrentUser(){return this.persistence._remove(this.fullUserKey)}savePersistenceForRedirect(){return this.persistence._set(this.fullPersistenceKey,this.persistence.type)}async setPersistence(e){if(this.persistence===e)return;const t=await this.getCurrentUser();return await this.removeCurrentUser(),this.persistence=e,t?this.setCurrentUser(t):void 0}delete(){this.persistence._removeListener(this.fullUserKey,this.boundEventHandler)}static async create(e,t,n="authUser"){if(!t.length)return new ae(re(se),e,n);const r=(await Promise.all(t.map((async e=>{if(await e._isAvailable())return e})))).filter((e=>e));let i=r[0]||re(se);const s=oe(n,e.config.apiKey,e.name);let o=null;for(const n of t)try{const t=await n._get(s);if(t){const r=te._fromJSON(e,t);n!==i&&(o=r),i=n;break}}catch(e){}const a=r.filter((e=>e._shouldAllowMigration));return i._shouldAllowMigration&&a.length?(i=a[0],o&&await i._set(s,o.toJSON()),await Promise.all(t.map((async e=>{if(e!==i)try{await e._remove(s)}catch(e){}}))),new ae(i,e,n)):new ae(i,e,n)}}function ce(e){const t=e.toLowerCase();if(t.includes("opera/")||t.includes("opr/")||t.includes("opios/"))return"Opera";if(de(t))return"IEMobile";if(t.includes("msie")||t.includes("trident/"))return"IE";if(t.includes("edge/"))return"Edge";if(ue(t))return"Firefox";if(t.includes("silk/"))return"Silk";if(pe(t))return"Blackberry";if(me(t))return"Webos";if(le(t))return"Safari";if((t.includes("chrome/")||he(t))&&!t.includes("edge/"))return"Chrome";if(fe(t))return"Android";{const t=/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/,n=e.match(t);if(2===(null==n?void 0:n.length))return n[1]}return"Other"}function ue(e=i.getUA()){return/firefox\//i.test(e)}function le(e=i.getUA()){const t=e.toLowerCase();return t.includes("safari/")&&!t.includes("chrome/")&&!t.includes("crios/")&&!t.includes("android")}function he(e=i.getUA()){return/crios\//i.test(e)}function de(e=i.getUA()){return/iemobile/i.test(e)}function fe(e=i.getUA()){return/android/i.test(e)}function pe(e=i.getUA()){return/blackberry/i.test(e)}function me(e=i.getUA()){return/webos/i.test(e)}function ge(e=i.getUA()){return/iphone|ipad|ipod/i.test(e)||/macintosh/i.test(e)&&/mobile/i.test(e)}function ye(e=i.getUA()){return ge(e)||fe(e)||me(e)||pe(e)||/windows phone/i.test(e)||de(e)}function ve(e,t=[]){let n;switch(e){case"Browser":n=ce(i.getUA());break;case"Worker":n=`${ce(i.getUA())}-${e}`;break;default:n=e}const s=t.length?t.join(","):"FirebaseCore-web";return`${n}/JsCore/${r.SDK_VERSION}/${s}`}class be{constructor(e){this.auth=e,this.queue=[]}pushCallback(e,t){const n=t=>new Promise(((n,r)=>{try{n(e(t))}catch(e){r(e)}}));n.onAbort=t,this.queue.push(n);const r=this.queue.length-1;return()=>{this.queue[r]=()=>Promise.resolve()}}async runMiddleware(e){if(this.auth.currentUser===e)return;const t=[];try{for(const n of this.queue)await n(e),n.onAbort&&t.push(n.onAbort)}catch(e){t.reverse();for(const e of t)try{e()}catch(e){}throw this.auth._errorFactory.create("login-blocked",{originalMessage:null==e?void 0:e.message})}}}class we{constructor(e){var t,n,r,i;const s=e.customStrengthOptions;this.customStrengthOptions={},this.customStrengthOptions.minPasswordLength=null!==(t=s.minPasswordLength)&&void 0!==t?t:6,s.maxPasswordLength&&(this.customStrengthOptions.maxPasswordLength=s.maxPasswordLength),void 0!==s.containsLowercaseCharacter&&(this.customStrengthOptions.containsLowercaseLetter=s.containsLowercaseCharacter),void 0!==s.containsUppercaseCharacter&&(this.customStrengthOptions.containsUppercaseLetter=s.containsUppercaseCharacter),void 0!==s.containsNumericCharacter&&(this.customStrengthOptions.containsNumericCharacter=s.containsNumericCharacter),void 0!==s.containsNonAlphanumericCharacter&&(this.customStrengthOptions.containsNonAlphanumericCharacter=s.containsNonAlphanumericCharacter),this.enforcementState=e.enforcementState,"ENFORCEMENT_STATE_UNSPECIFIED"===this.enforcementState&&(this.enforcementState="OFF"),this.allowedNonAlphanumericCharacters=null!==(r=null===(n=e.allowedNonAlphanumericCharacters)||void 0===n?void 0:n.join(""))&&void 0!==r?r:"",this.forceUpgradeOnSignin=null!==(i=e.forceUpgradeOnSignin)&&void 0!==i&&i,this.schemaVersion=e.schemaVersion}validatePassword(e){var t,n,r,i,s,o;const a={isValid:!0,passwordPolicy:this};return this.validatePasswordLengthOptions(e,a),this.validatePasswordCharacterOptions(e,a),a.isValid&&(a.isValid=null===(t=a.meetsMinPasswordLength)||void 0===t||t),a.isValid&&(a.isValid=null===(n=a.meetsMaxPasswordLength)||void 0===n||n),a.isValid&&(a.isValid=null===(r=a.containsLowercaseLetter)||void 0===r||r),a.isValid&&(a.isValid=null===(i=a.containsUppercaseLetter)||void 0===i||i),a.isValid&&(a.isValid=null===(s=a.containsNumericCharacter)||void 0===s||s),a.isValid&&(a.isValid=null===(o=a.containsNonAlphanumericCharacter)||void 0===o||o),a}validatePasswordLengthOptions(e,t){const n=this.customStrengthOptions.minPasswordLength,r=this.customStrengthOptions.maxPasswordLength;n&&(t.meetsMinPasswordLength=e.length>=n),r&&(t.meetsMaxPasswordLength=e.length<=r)}validatePasswordCharacterOptions(e,t){let n;this.updatePasswordCharacterOptionsStatuses(t,!1,!1,!1,!1);for(let r=0;r<e.length;r++)n=e.charAt(r),this.updatePasswordCharacterOptionsStatuses(t,n>="a"&&n<="z",n>="A"&&n<="Z",n>="0"&&n<="9",this.allowedNonAlphanumericCharacters.includes(n))}updatePasswordCharacterOptionsStatuses(e,t,n,r,i){this.customStrengthOptions.containsLowercaseLetter&&(e.containsLowercaseLetter||(e.containsLowercaseLetter=t)),this.customStrengthOptions.containsUppercaseLetter&&(e.containsUppercaseLetter||(e.containsUppercaseLetter=n)),this.customStrengthOptions.containsNumericCharacter&&(e.containsNumericCharacter||(e.containsNumericCharacter=r)),this.customStrengthOptions.containsNonAlphanumericCharacter&&(e.containsNonAlphanumericCharacter||(e.containsNonAlphanumericCharacter=i))}}class _e{constructor(e,t,n,r){this.app=e,this.heartbeatServiceProvider=t,this.appCheckServiceProvider=n,this.config=r,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new Ee(this),this.idTokenSubscription=new Ee(this),this.beforeStateQueue=new be(this),this.redirectUser=null,this.isProactiveRefreshEnabled=!1,this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION=1,this._canInitEmulator=!0,this._isInitialized=!1,this._deleted=!1,this._initializationPromise=null,this._popupRedirectResolver=null,this._errorFactory=u,this._agentRecaptchaConfig=null,this._tenantRecaptchaConfigs={},this._projectPasswordPolicy=null,this._tenantPasswordPolicies={},this.lastNotifiedUid=void 0,this.languageCode=null,this.tenantId=null,this.settings={appVerificationDisabledForTesting:!1},this.frameworks=[],this.name=e.name,this.clientVersion=r.sdkClientVersion}_initializeWithPersistence(e,t){return t&&(this._popupRedirectResolver=re(t)),this._initializationPromise=this.queue((async()=>{var n,r;if(!this._deleted&&(this.persistenceManager=await ae.create(this,e),!this._deleted)){if(null===(n=this._popupRedirectResolver)||void 0===n?void 0:n._shouldInitProactively)try{await this._popupRedirectResolver._initialize(this)}catch(e){}await this.initializeCurrentUser(t),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 e=await this.assertedPersistence.getCurrentUser();return this.currentUser||e?this.currentUser&&e&&this.currentUser.uid===e.uid?(this._currentUser._assign(e),void await this.currentUser.getIdToken()):void await this._updateCurrentUser(e,!0):void 0}async initializeCurrentUserFromIdToken(e){try{const t=await B(this,{idToken:e}),n=await te._fromGetAccountInfoResponse(this,t,e);await this.directlySetCurrentUser(n)}catch(e){console.warn("FirebaseServerApp could not login user with provided authIdToken: ",e),await this.directlySetCurrentUser(null)}}async initializeCurrentUser(e){var t;if(r._isFirebaseServerApp(this.app)){const e=this.app.settings.authIdToken;return e?new Promise((t=>{setTimeout((()=>this.initializeCurrentUserFromIdToken(e).then(t,t)))})):this.directlySetCurrentUser(null)}const n=await this.assertedPersistence.getCurrentUser();let i=n,s=!1;if(e&&this.config.authDomain){await this.getOrInitRedirectPersistenceManager();const n=null===(t=this.redirectUser)||void 0===t?void 0:t._redirectEventId,r=null==i?void 0:i._redirectEventId,o=await this.tryRedirectSignIn(e);n&&n!==r||!(null==o?void 0:o.user)||(i=o.user,s=!0)}if(!i)return this.directlySetCurrentUser(null);if(!i._redirectEventId){if(s)try{await this.beforeStateQueue.runMiddleware(i)}catch(e){i=n,this._popupRedirectResolver._overrideRedirectResult(this,(()=>Promise.reject(e)))}return i?this.reloadAndSetCurrentUserOrClear(i):this.directlySetCurrentUser(null)}return v(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===i._redirectEventId?this.directlySetCurrentUser(i):this.reloadAndSetCurrentUserOrClear(i)}async tryRedirectSignIn(e){let t=null;try{t=await this._popupRedirectResolver._completeRedirectFn(this,e,!0)}catch(e){await this._setRedirectUser(null)}return t}async reloadAndSetCurrentUserOrClear(e){try{await J(e)}catch(e){if("auth/network-request-failed"!==(null==e?void 0:e.code))return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(e)}useDeviceLanguage(){this.languageCode=function(){if("undefined"==typeof navigator)return null;const e=navigator;return e.languages&&e.languages[0]||e.language||null}()}async _delete(){this._deleted=!0}async updateCurrentUser(e){if(r._isFirebaseServerApp(this.app))return Promise.reject(m(this));const t=e?i.getModularInstance(e):null;return t&&v(t.auth.config.apiKey===this.config.apiKey,this,"invalid-user-token"),this._updateCurrentUser(t&&t._clone(this))}async _updateCurrentUser(e,t=!1){if(!this._deleted)return e&&v(this.tenantId===e.tenantId,this,"tenant-id-mismatch"),t||await this.beforeStateQueue.runMiddleware(e),this.queue((async()=>{await this.directlySetCurrentUser(e),this.notifyAuthListeners()}))}async signOut(){return r._isFirebaseServerApp(this.app)?Promise.reject(m(this)):(await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0))}setPersistence(e){return r._isFirebaseServerApp(this.app)?Promise.reject(m(this)):this.queue((async()=>{await this.assertedPersistence.setPersistence(re(e))}))}_getRecaptchaConfig(){return null==this.tenantId?this._agentRecaptchaConfig:this._tenantRecaptchaConfigs[this.tenantId]}async validatePassword(e){this._getPasswordPolicyInternal()||await this._updatePasswordPolicy();const t=this._getPasswordPolicyInternal();return t.schemaVersion!==this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION?Promise.reject(this._errorFactory.create("unsupported-password-policy-schema-version",{})):t.validatePassword(e)}_getPasswordPolicyInternal(){return null===this.tenantId?this._projectPasswordPolicy:this._tenantPasswordPolicies[this.tenantId]}async _updatePasswordPolicy(){const e=await async function(e,t={}){return N(e,"GET","/v2/passwordPolicy",k(e,t))}(this),t=new we(e);null===this.tenantId?this._projectPasswordPolicy=t:this._tenantPasswordPolicies[this.tenantId]=t}_getPersistence(){return this.assertedPersistence.persistence.type}_updateErrorMap(e){this._errorFactory=new i.ErrorFactory("auth","Firebase",e())}onAuthStateChanged(e,t,n){return this.registerStateListener(this.authStateSubscription,e,t,n)}beforeAuthStateChanged(e,t){return this.beforeStateQueue.pushCallback(e,t)}onIdTokenChanged(e,t,n){return this.registerStateListener(this.idTokenSubscription,e,t,n)}authStateReady(){return new Promise(((e,t)=>{if(this.currentUser)e();else{const n=this.onAuthStateChanged((()=>{n(),e()}),t)}}))}async revokeAccessToken(e){if(this.currentUser){const t={providerId:"apple.com",tokenType:"ACCESS_TOKEN",token:e,idToken:await this.currentUser.getIdToken()};null!=this.tenantId&&(t.tenantId=this.tenantId),await async function(e,t){return N(e,"POST","/v2/accounts:revokeToken",k(e,t))}(this,t)}}toJSON(){var e;return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:null===(e=this._currentUser)||void 0===e?void 0:e.toJSON()}}async _setRedirectUser(e,t){const n=await this.getOrInitRedirectPersistenceManager(t);return null===e?n.removeCurrentUser():n.setCurrentUser(e)}async getOrInitRedirectPersistenceManager(e){if(!this.redirectPersistenceManager){const t=e&&re(e)||this._popupRedirectResolver;v(t,this,"argument-error"),this.redirectPersistenceManager=await ae.create(this,[re(t._redirectPersistence)],"redirectUser"),this.redirectUser=await this.redirectPersistenceManager.getCurrentUser()}return this.redirectPersistenceManager}async _redirectUserForId(e){var t,n;return this._isInitialized&&await this.queue((async()=>{})),(null===(t=this._currentUser)||void 0===t?void 0:t._redirectEventId)===e?this._currentUser:(null===(n=this.redirectUser)||void 0===n?void 0:n._redirectEventId)===e?this.redirectUser:null}async _persistUserIfCurrent(e){if(e===this.currentUser)return this.queue((async()=>this.directlySetCurrentUser(e)))}_notifyListenersIfCurrent(e){e===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 e,t;if(!this._isInitialized)return;this.idTokenSubscription.next(this.currentUser);const n=null!==(t=null===(e=this.currentUser)||void 0===e?void 0:e.uid)&&void 0!==t?t:null;this.lastNotifiedUid!==n&&(this.lastNotifiedUid=n,this.authStateSubscription.next(this.currentUser))}registerStateListener(e,t,n,r){if(this._deleted)return()=>{};const i="function"==typeof t?t:t.next.bind(t);let s=!1;const o=this._isInitialized?Promise.resolve():this._initializationPromise;if(v(o,this,"internal-error"),o.then((()=>{s||i(this.currentUser)})),"function"==typeof t){const i=e.addObserver(t,n,r);return()=>{s=!0,i()}}{const n=e.addObserver(t);return()=>{s=!0,n()}}}async directlySetCurrentUser(e){this.currentUser&&this.currentUser!==e&&this._currentUser._stopProactiveRefresh(),e&&this.isProactiveRefreshEnabled&&e._startProactiveRefresh(),this.currentUser=e,e?await this.assertedPersistence.setCurrentUser(e):await this.assertedPersistence.removeCurrentUser()}queue(e){return this.operations=this.operations.then(e,e),this.operations}get assertedPersistence(){return v(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(e){e&&!this.frameworks.includes(e)&&(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=ve(this.config.clientPlatform,this._getFrameworks()))}_getFrameworks(){return this.frameworks}async _getAdditionalHeaders(){var e;const t={"X-Client-Version":this.clientVersion};this.app.options.appId&&(t["X-Firebase-gmpid"]=this.app.options.appId);const n=await(null===(e=this.heartbeatServiceProvider.getImmediate({optional:!0}))||void 0===e?void 0:e.getHeartbeatsHeader());n&&(t["X-Firebase-Client"]=n);const r=await this._getAppCheckToken();return r&&(t["X-Firebase-AppCheck"]=r),t}async _getAppCheckToken(){var e;const t=await(null===(e=this.appCheckServiceProvider.getImmediate({optional:!0}))||void 0===e?void 0:e.getToken());return(null==t?void 0:t.error)&&function(e,...t){l.logLevel<=s.LogLevel.WARN&&l.warn(`Auth (${r.SDK_VERSION}): ${e}`,...t)}(`Error while retrieving App Check token: ${t.error}`),null==t?void 0:t.token}}function Ie(e){return i.getModularInstance(e)}class Ee{constructor(e){this.auth=e,this.observer=null,this.addObserver=i.createSubscribe((e=>this.observer=e))}get next(){return v(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}let Te={async loadJS(){throw new Error("Unable to load external scripts")},recaptchaV2Script:"",recaptchaEnterpriseScript:"",gapiScript:""};function Se(e){return Te.loadJS(e)}function Ce(e){return`__${e}${Math.floor(1e6*Math.random())}`}class Ae{constructor(e){this.type="recaptcha-enterprise",this.auth=Ie(e)}async verify(e="verify",t=!1){function n(t,n,r){const i=window.grecaptcha;V(i)?i.enterprise.ready((()=>{i.enterprise.execute(t,{action:e}).then((e=>{n(e)})).catch((()=>{n("NO_RECAPTCHA")}))})):r(Error("No reCAPTCHA enterprise script loaded."))}return new Promise(((e,r)=>{(async function(e){if(!t){if(null==e.tenantId&&null!=e._agentRecaptchaConfig)return e._agentRecaptchaConfig.siteKey;if(null!=e.tenantId&&void 0!==e._tenantRecaptchaConfigs[e.tenantId])return e._tenantRecaptchaConfigs[e.tenantId].siteKey}return new Promise((async(t,n)=>{j(e,{clientType:"CLIENT_TYPE_WEB",version:"RECAPTCHA_ENTERPRISE"}).then((r=>{if(void 0!==r.recaptchaKey){const n=new U(r);return null==e.tenantId?e._agentRecaptchaConfig=n:e._tenantRecaptchaConfigs[e.tenantId]=n,t(n.siteKey)}n(new Error("recaptcha Enterprise site key undefined"))})).catch((e=>{n(e)}))}))})(this.auth).then((i=>{if(!t&&V(window.grecaptcha))n(i,e,r);else{if("undefined"==typeof window)return void r(new Error("RecaptchaVerifier is only supported in browser"));let t=Te.recaptchaEnterpriseScript;0!==t.length&&(t+=i),Se(t).then((()=>{n(i,e,r)})).catch((e=>{r(e)}))}})).catch((e=>{r(e)}))}))}}async function xe(e,t,n,r=!1){const i=new Ae(e);let s;try{s=await i.verify(n)}catch(e){s=await i.verify(n,!0)}const o=Object.assign({},t);return r?Object.assign(o,{captchaResp:s}):Object.assign(o,{captchaResponse:s}),Object.assign(o,{clientType:"CLIENT_TYPE_WEB"}),Object.assign(o,{recaptchaVersion:"RECAPTCHA_ENTERPRISE"}),o}async function ke(e,t,n,r){var i;if(null===(i=e._getRecaptchaConfig())||void 0===i?void 0:i.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")){const i=await xe(e,t,n,"getOobCode"===n);return r(e,i)}return r(e,t).catch((async i=>{if("auth/missing-recaptcha-token"===i.code){console.log(`${n} is protected by reCAPTCHA Enterprise for this project. Automatically triggering the reCAPTCHA flow and restarting the flow.`);const i=await xe(e,t,n,"getOobCode"===n);return r(e,i)}return Promise.reject(i)}))}function Ne(e,t){const n=r._getProvider(e,"auth");if(n.isInitialized()){const e=n.getImmediate(),r=n.getOptions();if(i.deepEqual(r,null!=t?t:{}))return e;d(e,"already-initialized")}return n.initialize({options:t})}function Oe(e,t,n){const r=Ie(e);v(r._canInitEmulator,r,"emulator-config-failed"),v(/^https?:\/\//.test(t),r,"invalid-emulator-scheme");const i=!!(null==n?void 0:n.disableWarnings),s=De(t),{host:o,port:a}=function(e){const t=De(e),n=/(\/\/)?([^?#/]+)/.exec(e.substr(t.length));if(!n)return{host:"",port:null};const r=n[2].split("@").pop()||"",i=/^(\[[^\]]+\])(:|$)/.exec(r);if(i){const e=i[1];return{host:e,port:Re(r.substr(e.length+1))}}{const[e,t]=r.split(":");return{host:e,port:Re(t)}}}(t),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 e(){const e=document.createElement("p"),t=e.style;e.innerText="Running in emulator mode. Do not use with production credentials.",t.position="fixed",t.width="100%",t.backgroundColor="#ffffff",t.border=".1em solid #000000",t.color="#b50000",t.bottom="0px",t.left="0px",t.margin="0px",t.zIndex="10000",t.textAlign="center",e.classList.add("firebase-emulator-warning"),document.body.appendChild(e)}"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",e):e())}()}function De(e){const t=e.indexOf(":");return t<0?"":e.substr(0,t+1)}function Re(e){if(!e)return null;const t=Number(e);return isNaN(t)?null:t}class Pe{constructor(e,t){this.providerId=e,this.signInMethod=t}toJSON(){return b("not implemented")}_getIdTokenResponse(e){return b("not implemented")}_linkToIdToken(e,t){return b("not implemented")}_getReauthenticationResolver(e){return b("not implemented")}}async function Le(e,t){return N(e,"POST","/v1/accounts:resetPassword",k(e,t))}async function Me(e,t){return N(e,"POST","/v1/accounts:signUp",t)}async function Fe(e,t){return D(e,"POST","/v1/accounts:signInWithPassword",k(e,t))}async function Ve(e,t){return N(e,"POST","/v1/accounts:sendOobCode",k(e,t))}async function Ue(e,t){return Ve(e,t)}async function je(e,t){return Ve(e,t)}class Be extends Pe{constructor(e,t,n,r=null){super("password",n),this._email=e,this._password=t,this._tenantId=r}static _fromEmailAndPassword(e,t){return new Be(e,t,"password")}static _fromEmailAndCode(e,t,n=null){return new Be(e,t,"emailLink",n)}toJSON(){return{email:this._email,password:this._password,signInMethod:this.signInMethod,tenantId:this._tenantId}}static fromJSON(e){const t="string"==typeof e?JSON.parse(e):e;if((null==t?void 0:t.email)&&(null==t?void 0:t.password)){if("password"===t.signInMethod)return this._fromEmailAndPassword(t.email,t.password);if("emailLink"===t.signInMethod)return this._fromEmailAndCode(t.email,t.password,t.tenantId)}return null}async _getIdTokenResponse(e){switch(this.signInMethod){case"password":return ke(e,{returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"},"signInWithPassword",Fe);case"emailLink":return async function(e,t){return D(e,"POST","/v1/accounts:signInWithEmailLink",k(e,t))}(e,{email:this._email,oobCode:this._password});default:d(e,"internal-error")}}async _linkToIdToken(e,t){switch(this.signInMethod){case"password":return ke(e,{idToken:t,returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"},"signUpPassword",Me);case"emailLink":return async function(e,t){return D(e,"POST","/v1/accounts:signInWithEmailLink",k(e,t))}(e,{idToken:t,email:this._email,oobCode:this._password});default:d(e,"internal-error")}}_getReauthenticationResolver(e){return this._getIdTokenResponse(e)}}async function qe(e,t){return D(e,"POST","/v1/accounts:signInWithIdp",k(e,t))}class ze extends Pe{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(e){const t=new ze(e.providerId,e.signInMethod);return e.idToken||e.accessToken?(e.idToken&&(t.idToken=e.idToken),e.accessToken&&(t.accessToken=e.accessToken),e.nonce&&!e.pendingToken&&(t.nonce=e.nonce),e.pendingToken&&(t.pendingToken=e.pendingToken)):e.oauthToken&&e.oauthTokenSecret?(t.accessToken=e.oauthToken,t.secret=e.oauthTokenSecret):d("argument-error"),t}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(e){const t="string"==typeof e?JSON.parse(e):e,{providerId:n,signInMethod:r}=t,i=o.__rest(t,["providerId","signInMethod"]);if(!n||!r)return null;const s=new ze(n,r);return s.idToken=i.idToken||void 0,s.accessToken=i.accessToken||void 0,s.secret=i.secret,s.nonce=i.nonce,s.pendingToken=i.pendingToken||null,s}_getIdTokenResponse(e){return qe(e,this.buildRequest())}_linkToIdToken(e,t){const n=this.buildRequest();return n.idToken=t,qe(e,n)}_getReauthenticationResolver(e){const t=this.buildRequest();return t.autoCreate=!1,qe(e,t)}buildRequest(){const e={requestUri:"http://localhost",returnSecureToken:!0};if(this.pendingToken)e.pendingToken=this.pendingToken;else{const t={};this.idToken&&(t.id_token=this.idToken),this.accessToken&&(t.access_token=this.accessToken),this.secret&&(t.oauth_token_secret=this.secret),t.providerId=this.providerId,this.nonce&&!this.pendingToken&&(t.nonce=this.nonce),e.postBody=i.querystring(t)}return e}}const Ge={USER_NOT_FOUND:"user-not-found"};class Ke extends Pe{constructor(e){super("phone","phone"),this.params=e}static _fromVerification(e,t){return new Ke({verificationId:e,verificationCode:t})}static _fromTokenResponse(e,t){return new Ke({phoneNumber:e,temporaryProof:t})}_getIdTokenResponse(e){return async function(e,t){return D(e,"POST","/v1/accounts:signInWithPhoneNumber",k(e,t))}(e,this._makeVerificationRequest())}_linkToIdToken(e,t){return async function(e,t){const n=await D(e,"POST","/v1/accounts:signInWithPhoneNumber",k(e,t));if(n.temporaryProof)throw M(e,"account-exists-with-different-credential",n);return n}(e,Object.assign({idToken:t},this._makeVerificationRequest()))}_getReauthenticationResolver(e){return async function(e,t){return D(e,"POST","/v1/accounts:signInWithPhoneNumber",k(e,Object.assign(Object.assign({},t),{operation:"REAUTH"})),Ge)}(e,this._makeVerificationRequest())}_makeVerificationRequest(){const{temporaryProof:e,phoneNumber:t,verificationId:n,verificationCode:r}=this.params;return e&&t?{temporaryProof:e,phoneNumber:t}:{sessionInfo:n,code:r}}toJSON(){const e={providerId:this.providerId};return this.params.phoneNumber&&(e.phoneNumber=this.params.phoneNumber),this.params.temporaryProof&&(e.temporaryProof=this.params.temporaryProof),this.params.verificationCode&&(e.verificationCode=this.params.verificationCode),this.params.verificationId&&(e.verificationId=this.params.verificationId),e}static fromJSON(e){"string"==typeof e&&(e=JSON.parse(e));const{verificationId:t,verificationCode:n,phoneNumber:r,temporaryProof:i}=e;return n||t||r||i?new Ke({verificationId:t,verificationCode:n,phoneNumber:r,temporaryProof:i}):null}}class We{constructor(e){var t,n,r,s,o,a;const c=i.querystringDecode(i.extractQuerystring(e)),u=null!==(t=c.apiKey)&&void 0!==t?t:null,l=null!==(n=c.oobCode)&&void 0!==n?n:null,h=function(e){switch(e){case"recoverEmail":return"RECOVER_EMAIL";case"resetPassword":return"PASSWORD_RESET";case"signIn":return"EMAIL_SIGNIN";case"verifyEmail":return"VERIFY_EMAIL";case"verifyAndChangeEmail":return"VERIFY_AND_CHANGE_EMAIL";case"revertSecondFactorAddition":return"REVERT_SECOND_FACTOR_ADDITION";default:return null}}(null!==(r=c.mode)&&void 0!==r?r:null);v(u&&l&&h,"argument-error"),this.apiKey=u,this.operation=h,this.code=l,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(e){const t=function(e){const t=i.querystringDecode(i.extractQuerystring(e)).link,n=t?i.querystringDecode(i.extractQuerystring(t)).deep_link_id:null,r=i.querystringDecode(i.extractQuerystring(e)).deep_link_id;return(r?i.querystringDecode(i.extractQuerystring(r)).link:null)||r||n||t||e}(e);try{return new We(t)}catch(e){return null}}}class $e{constructor(){this.providerId=$e.PROVIDER_ID}static credential(e,t){return Be._fromEmailAndPassword(e,t)}static credentialWithLink(e,t){const n=We.parseLink(t);return v(n,"argument-error"),Be._fromEmailAndCode(e,n.code,n.tenantId)}}$e.PROVIDER_ID="password",$e.EMAIL_PASSWORD_SIGN_IN_METHOD="password",$e.EMAIL_LINK_SIGN_IN_METHOD="emailLink";class He{constructor(e){this.providerId=e,this.defaultLanguageCode=null,this.customParameters={}}setDefaultLanguage(e){this.defaultLanguageCode=e}setCustomParameters(e){return this.customParameters=e,this}getCustomParameters(){return this.customParameters}}class Qe extends He{constructor(){super(...arguments),this.scopes=[]}addScope(e){return this.scopes.includes(e)||this.scopes.push(e),this}getScopes(){return[...this.scopes]}}class Je extends Qe{static credentialFromJSON(e){const t="string"==typeof e?JSON.parse(e):e;return v("providerId"in t&&"signInMethod"in t,"argument-error"),ze._fromParams(t)}credential(e){return this._credential(Object.assign(Object.assign({},e),{nonce:e.rawNonce}))}_credential(e){return v(e.idToken||e.accessToken,"argument-error"),ze._fromParams(Object.assign(Object.assign({},e),{providerId:this.providerId,signInMethod:this.providerId}))}static credentialFromResult(e){return Je.oauthCredentialFromTaggedObject(e)}static credentialFromError(e){return Je.oauthCredentialFromTaggedObject(e.customData||{})}static oauthCredentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthIdToken:t,oauthAccessToken:n,oauthTokenSecret:r,pendingToken:i,nonce:s,providerId:o}=e;if(!(n||r||t||i))return null;if(!o)return null;try{return new Je(o)._credential({idToken:t,accessToken:n,nonce:s,pendingToken:i})}catch(e){return null}}}class Ye extends Qe{constructor(){super("facebook.com")}static credential(e){return ze._fromParams({providerId:Ye.PROVIDER_ID,signInMethod:Ye.FACEBOOK_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return Ye.credentialFromTaggedObject(e)}static credentialFromError(e){return Ye.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e))return null;if(!e.oauthAccessToken)return null;try{return Ye.credential(e.oauthAccessToken)}catch(e){return null}}}Ye.FACEBOOK_SIGN_IN_METHOD="facebook.com",Ye.PROVIDER_ID="facebook.com";class Xe extends Qe{constructor(){super("google.com"),this.addScope("profile")}static credential(e,t){return ze._fromParams({providerId:Xe.PROVIDER_ID,signInMethod:Xe.GOOGLE_SIGN_IN_METHOD,idToken:e,accessToken:t})}static credentialFromResult(e){return Xe.credentialFromTaggedObject(e)}static credentialFromError(e){return Xe.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthIdToken:t,oauthAccessToken:n}=e;if(!t&&!n)return null;try{return Xe.credential(t,n)}catch(e){return null}}}Xe.GOOGLE_SIGN_IN_METHOD="google.com",Xe.PROVIDER_ID="google.com";class Ze extends Qe{constructor(){super("github.com")}static credential(e){return ze._fromParams({providerId:Ze.PROVIDER_ID,signInMethod:Ze.GITHUB_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return Ze.credentialFromTaggedObject(e)}static credentialFromError(e){return Ze.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e))return null;if(!e.oauthAccessToken)return null;try{return Ze.credential(e.oauthAccessToken)}catch(e){return null}}}Ze.GITHUB_SIGN_IN_METHOD="github.com",Ze.PROVIDER_ID="github.com";class et extends Pe{constructor(e,t){super(e,e),this.pendingToken=t}_getIdTokenResponse(e){return qe(e,this.buildRequest())}_linkToIdToken(e,t){const n=this.buildRequest();return n.idToken=t,qe(e,n)}_getReauthenticationResolver(e){const t=this.buildRequest();return t.autoCreate=!1,qe(e,t)}toJSON(){return{signInMethod:this.signInMethod,providerId:this.providerId,pendingToken:this.pendingToken}}static fromJSON(e){const t="string"==typeof e?JSON.parse(e):e,{providerId:n,signInMethod:r,pendingToken:i}=t;return n&&r&&i&&n===r?new et(n,i):null}static _create(e,t){return new et(e,t)}buildRequest(){return{requestUri:"http://localhost",returnSecureToken:!0,pendingToken:this.pendingToken}}}class tt extends He{constructor(e){v(e.startsWith("saml."),"argument-error"),super(e)}static credentialFromResult(e){return tt.samlCredentialFromTaggedObject(e)}static credentialFromError(e){return tt.samlCredentialFromTaggedObject(e.customData||{})}static credentialFromJSON(e){const t=et.fromJSON(e);return v(t,"argument-error"),t}static samlCredentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{pendingToken:t,providerId:n}=e;if(!t||!n)return null;try{return et._create(n,t)}catch(e){return null}}}class nt extends Qe{constructor(){super("twitter.com")}static credential(e,t){return ze._fromParams({providerId:nt.PROVIDER_ID,signInMethod:nt.TWITTER_SIGN_IN_METHOD,oauthToken:e,oauthTokenSecret:t})}static credentialFromResult(e){return nt.credentialFromTaggedObject(e)}static credentialFromError(e){return nt.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthAccessToken:t,oauthTokenSecret:n}=e;if(!t||!n)return null;try{return nt.credential(t,n)}catch(e){return null}}}async function rt(e,t){return D(e,"POST","/v1/accounts:signUp",k(e,t))}nt.TWITTER_SIGN_IN_METHOD="twitter.com",nt.PROVIDER_ID="twitter.com";class it{constructor(e){this.user=e.user,this.providerId=e.providerId,this._tokenResponse=e._tokenResponse,this.operationType=e.operationType}static async _fromIdTokenResponse(e,t,n,r=!1){const i=await te._fromIdTokenResponse(e,n,r),s=st(n);return new it({user:i,providerId:s,_tokenResponse:n,operationType:t})}static async _forOperation(e,t,n){await e._updateTokensIfNecessary(n,!0);const r=st(n);return new it({user:e,providerId:r,_tokenResponse:n,operationType:t})}}function st(e){return e.providerId?e.providerId:"phoneNumber"in e?"phone":null}class ot extends i.FirebaseError{constructor(e,t,n,r){var i;super(t.code,t.message),this.operationType=n,this.user=r,Object.setPrototypeOf(this,ot.prototype),this.customData={appName:e.name,tenantId:null!==(i=e.tenantId)&&void 0!==i?i:void 0,_serverResponse:t.customData._serverResponse,operationType:n}}static _fromErrorAndOperation(e,t,n,r){return new ot(e,t,n,r)}}function at(e,t,n,r){return("reauthenticate"===t?n._getReauthenticationResolver(e):n._getIdTokenResponse(e)).catch((n=>{if("auth/multi-factor-auth-required"===n.code)throw ot._fromErrorAndOperation(e,n,t,r);throw n}))}function ct(e){return new Set(e.map((({providerId:e})=>e)).filter((e=>!!e)))}async function ut(e,t,n=!1){const r=await $(e,t._linkToIdToken(e.auth,await e.getIdToken()),n);return it._forOperation(e,"link",r)}async function lt(e,t,n){await J(t);const r=!1===e?"provider-already-linked":"no-such-provider";v(ct(t.providerData).has(n)===e,t.auth,r)}async function ht(e,t,n=!1){const{auth:i}=e;if(r._isFirebaseServerApp(i.app))return Promise.reject(m(i));const s="reauthenticate";try{const r=await $(e,at(i,s,t,e),n);v(r.idToken,i,"internal-error");const o=K(r.idToken);v(o,i,"internal-error");const{sub:a}=o;return v(e.uid===a,i,"user-mismatch"),it._forOperation(e,s,r)}catch(e){throw"auth/user-not-found"===(null==e?void 0:e.code)&&d(i,"user-mismatch"),e}}async function dt(e,t,n=!1){if(r._isFirebaseServerApp(e.app))return Promise.reject(m(e));const i="signIn",s=await at(e,i,t),o=await it._fromIdTokenResponse(e,i,s);return n||await e._updateCurrentUser(o.user),o}async function ft(e,t){return dt(Ie(e),t)}async function pt(e,t){const n=i.getModularInstance(e);return await lt(!1,n,t.providerId),ut(n,t)}async function mt(e,t){return ht(i.getModularInstance(e),t)}class gt{constructor(e,t){this.factorId=e,this.uid=t.mfaEnrollmentId,this.enrollmentTime=new Date(t.enrolledAt).toUTCString(),this.displayName=t.displayName}static _fromServerResponse(e,t){return"phoneInfo"in t?yt._fromServerResponse(e,t):"totpInfo"in t?vt._fromServerResponse(e,t):d(e,"internal-error")}}class yt extends gt{constructor(e){super("phone",e),this.phoneNumber=e.phoneInfo}static _fromServerResponse(e,t){return new yt(t)}}class vt extends gt{constructor(e){super("totp",e)}static _fromServerResponse(e,t){return new vt(t)}}function bt(e,t,n){var r;v((null===(r=n.url)||void 0===r?void 0:r.length)>0,e,"invalid-continue-uri"),v(void 0===n.dynamicLinkDomain||n.dynamicLinkDomain.length>0,e,"invalid-dynamic-link-domain"),t.continueUrl=n.url,t.dynamicLinkDomain=n.dynamicLinkDomain,t.canHandleCodeInApp=n.handleCodeInApp,n.iOS&&(v(n.iOS.bundleId.length>0,e,"missing-ios-bundle-id"),t.iOSBundleId=n.iOS.bundleId),n.android&&(v(n.android.packageName.length>0,e,"missing-android-pkg-name"),t.androidInstallApp=n.android.installApp,t.androidMinimumVersionCode=n.android.minimumVersion,t.androidPackageName=n.android.packageName)}async function wt(e){const t=Ie(e);t._getPasswordPolicyInternal()&&await t._updatePasswordPolicy()}async function _t(e,t){const n=i.getModularInstance(e),r=await Le(n,{oobCode:t}),s=r.requestType;switch(v(s,n,"internal-error"),s){case"EMAIL_SIGNIN":break;case"VERIFY_AND_CHANGE_EMAIL":v(r.newEmail,n,"internal-error");break;case"REVERT_SECOND_FACTOR_ADDITION":v(r.mfaInfo,n,"internal-error");default:v(r.email,n,"internal-error")}let o=null;return r.mfaInfo&&(o=gt._fromServerResponse(Ie(n),r.mfaInfo)),{data:{email:("VERIFY_AND_CHANGE_EMAIL"===r.requestType?r.newEmail:r.email)||null,previousEmail:("VERIFY_AND_CHANGE_EMAIL"===r.requestType?r.email:r.newEmail)||null,multiFactorInfo:o},operation:s}}async function It(e,t,n){const{auth:r}=e,i={idToken:await e.getIdToken(),returnSecureToken:!0};t&&(i.email=t),n&&(i.password=n);const s=await $(e,async function(e,t){return N(e,"POST","/v1/accounts:update",t)}(r,i));await e._updateTokensIfNecessary(s,!0)}class Et{constructor(e,t,n={}){this.isNewUser=e,this.providerId=t,this.profile=n}}class Tt extends Et{constructor(e,t,n,r){super(e,t,n),this.username=r}}class St extends Et{constructor(e,t){super(e,"facebook.com",t)}}class Ct extends Tt{constructor(e,t){super(e,"github.com",t,"string"==typeof(null==t?void 0:t.login)?null==t?void 0:t.login:null)}}class At extends Et{constructor(e,t){super(e,"google.com",t)}}class xt extends Tt{constructor(e,t,n){super(e,"twitter.com",t,n)}}function kt(e,t,n,r){return i.getModularInstance(e).onIdTokenChanged(t,n,r)}function Nt(e,t,n){return i.getModularInstance(e).beforeAuthStateChanged(t,n)}class Ot{constructor(e,t,n){this.type=e,this.credential=t,this.user=n}static _fromIdtoken(e,t){return new Ot("enroll",e,t)}static _fromMfaPendingCredential(e){return new Ot("signin",e)}toJSON(){const e="enroll"===this.type?"idToken":"pendingCredential";return{multiFactorSession:{[e]:this.credential}}}static fromJSON(e){var t,n;if(null==e?void 0:e.multiFactorSession){if(null===(t=e.multiFactorSession)||void 0===t?void 0:t.pendingCredential)return Ot._fromMfaPendingCredential(e.multiFactorSession.pendingCredential);if(null===(n=e.multiFactorSession)||void 0===n?void 0:n.idToken)return Ot._fromIdtoken(e.multiFactorSession.idToken)}return null}}class Dt{constructor(e,t,n){this.session=e,this.hints=t,this.signInResolver=n}static _fromError(e,t){const n=Ie(e),r=t.customData._serverResponse,i=(r.mfaInfo||[]).map((e=>gt._fromServerResponse(n,e)));v(r.mfaPendingCredential,n,"internal-error");const s=Ot._fromMfaPendingCredential(r.mfaPendingCredential);return new Dt(s,i,(async e=>{const i=await e._process(n,s);delete r.mfaInfo,delete r.mfaPendingCredential;const o=Object.assign(Object.assign({},r),{idToken:i.idToken,refreshToken:i.refreshToken});switch(t.operationType){case"signIn":const e=await it._fromIdTokenResponse(n,t.operationType,o);return await n._updateCurrentUser(e.user),e;case"reauthenticate":return v(t.user,n,"internal-error"),it._forOperation(t.user,t.operationType,o);default:d(n,"internal-error")}}))}async resolveSignIn(e){const t=e;return this.signInResolver(t)}}class Rt{constructor(e){this.user=e,this.enrolledFactors=[],e._onReload((t=>{t.mfaInfo&&(this.enrolledFactors=t.mfaInfo.map((t=>gt._fromServerResponse(e.auth,t))))}))}static _fromUser(e){return new Rt(e)}async getSession(){return Ot._fromIdtoken(await this.user.getIdToken(),this.user)}async enroll(e,t){const n=e,r=await this.getSession(),i=await $(this.user,n._process(this.user.auth,r,t));return await this.user._updateTokensIfNecessary(i),this.user.reload()}async unenroll(e){const t="string"==typeof e?e:e.uid,n=await this.user.getIdToken();try{const e=await $(this.user,(r=this.user.auth,i={idToken:n,mfaEnrollmentId:t},N(r,"POST","/v2/accounts/mfaEnrollment:withdraw",k(r,i))));this.enrolledFactors=this.enrolledFactors.filter((({uid:e})=>e!==t)),await this.user._updateTokensIfNecessary(e),await this.user.reload()}catch(e){throw e}var r,i}}const Pt=new WeakMap,Lt="__sak";class Mt{constructor(e,t){this.storageRetriever=e,this.type=t}_isAvailable(){try{return this.storage?(this.storage.setItem(Lt,"1"),this.storage.removeItem(Lt),Promise.resolve(!0)):Promise.resolve(!1)}catch(e){return Promise.resolve(!1)}}_set(e,t){return this.storage.setItem(e,JSON.stringify(t)),Promise.resolve()}_get(e){const t=this.storage.getItem(e);return Promise.resolve(t?JSON.parse(t):null)}_remove(e){return this.storage.removeItem(e),Promise.resolve()}get storage(){return this.storageRetriever()}}class Ft extends Mt{constructor(){super((()=>window.localStorage),"LOCAL"),this.boundEventHandler=(e,t)=>this.onStorageEvent(e,t),this.listeners={},this.localCache={},this.pollTimer=null,this.fallbackToPolling=ye(),this._shouldAllowMigration=!0}forAllChangedKeys(e){for(const t of Object.keys(this.listeners)){const n=this.storage.getItem(t),r=this.localCache[t];n!==r&&e(t,r,n)}}onStorageEvent(e,t=!1){if(!e.key)return void this.forAllChangedKeys(((e,t,n)=>{this.notifyListeners(e,n)}));const n=e.key;t?this.detachListener():this.stopPolling();const r=()=>{const e=this.storage.getItem(n);(t||this.localCache[n]!==e)&&this.notifyListeners(n,e)},s=this.storage.getItem(n);i.isIE()&&10===document.documentMode&&s!==e.newValue&&e.newValue!==e.oldValue?setTimeout(r,10):r()}notifyListeners(e,t){this.localCache[e]=t;const n=this.listeners[e];if(n)for(const e of Array.from(n))e(t?JSON.parse(t):t)}startPolling(){this.stopPolling(),this.pollTimer=setInterval((()=>{this.forAllChangedKeys(((e,t,n)=>{this.onStorageEvent(new StorageEvent("storage",{key:e,oldValue:t,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(e,t){0===Object.keys(this.listeners).length&&(this.fallbackToPolling?this.startPolling():this.attachListener()),this.listeners[e]||(this.listeners[e]=new Set,this.localCache[e]=this.storage.getItem(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),0===this.listeners[e].size&&delete this.listeners[e]),0===Object.keys(this.listeners).length&&(this.detachListener(),this.stopPolling())}async _set(e,t){await super._set(e,t),this.localCache[e]=JSON.stringify(t)}async _get(e){const t=await super._get(e);return this.localCache[e]=JSON.stringify(t),t}async _remove(e){await super._remove(e),delete this.localCache[e]}}Ft.type="LOCAL";const Vt=Ft;class Ut extends Mt{constructor(){super((()=>window.sessionStorage),"SESSION")}_addListener(e,t){}_removeListener(e,t){}}Ut.type="SESSION";const jt=Ut;class Bt{constructor(e){this.eventTarget=e,this.handlersMap={},this.boundEventHandler=this.handleEvent.bind(this)}static _getInstance(e){const t=this.receivers.find((t=>t.isListeningto(e)));if(t)return t;const n=new Bt(e);return this.receivers.push(n),n}isListeningto(e){return this.eventTarget===e}async handleEvent(e){const t=e,{eventId:n,eventType:r,data:i}=t.data,s=this.handlersMap[r];if(!(null==s?void 0:s.size))return;t.ports[0].postMessage({status:"ack",eventId:n,eventType:r});const o=Array.from(s).map((async e=>e(t.origin,i))),a=await function(e){return Promise.all(e.map((async e=>{try{return{fulfilled:!0,value:await e}}catch(e){return{fulfilled:!1,reason:e}}})))}(o);t.ports[0].postMessage({status:"done",eventId:n,eventType:r,response:a})}_subscribe(e,t){0===Object.keys(this.handlersMap).length&&this.eventTarget.addEventListener("message",this.boundEventHandler),this.handlersMap[e]||(this.handlersMap[e]=new Set),this.handlersMap[e].add(t)}_unsubscribe(e,t){this.handlersMap[e]&&t&&this.handlersMap[e].delete(t),t&&0!==this.handlersMap[e].size||delete this.handlersMap[e],0===Object.keys(this.handlersMap).length&&this.eventTarget.removeEventListener("message",this.boundEventHandler)}}function qt(e="",t=10){let n="";for(let e=0;e<t;e++)n+=Math.floor(10*Math.random());return e+n}Bt.receivers=[];class zt{constructor(e){this.target=e,this.handlers=new Set}removeMessageHandler(e){e.messageChannel&&(e.messageChannel.port1.removeEventListener("message",e.onMessage),e.messageChannel.port1.close()),this.handlers.delete(e)}async _send(e,t,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=qt("",20);r.port1.start();const u=setTimeout((()=>{a(new Error("unsupported_event"))}),n);s={messageChannel:r,onMessage(e){const t=e;if(t.data.eventId===c)switch(t.data.status){case"ack":clearTimeout(u),i=setTimeout((()=>{a(new Error("timeout"))}),3e3);break;case"done":clearTimeout(i),o(t.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:e,eventId:c,data:t},[r.port2])})).finally((()=>{s&&this.removeMessageHandler(s)}))}}function Gt(){return window}function Kt(){return void 0!==Gt().WorkerGlobalScope&&"function"==typeof Gt().importScripts}const Wt="firebaseLocalStorageDb",$t="firebaseLocalStorage",Ht="fbase_key";class Qt{constructor(e){this.request=e}toPromise(){return new Promise(((e,t)=>{this.request.addEventListener("success",(()=>{e(this.request.result)})),this.request.addEventListener("error",(()=>{t(this.request.error)}))}))}}function Jt(e,t){return e.transaction([$t],t?"readwrite":"readonly").objectStore($t)}function Yt(){const e=indexedDB.open(Wt,1);return new Promise(((t,n)=>{e.addEventListener("error",(()=>{n(e.error)})),e.addEventListener("upgradeneeded",(()=>{const t=e.result;try{t.createObjectStore($t,{keyPath:Ht})}catch(e){n(e)}})),e.addEventListener("success",(async()=>{const n=e.result;n.objectStoreNames.contains($t)?t(n):(n.close(),await function(){const e=indexedDB.deleteDatabase(Wt);return new Qt(e).toPromise()}(),t(await Yt()))}))}))}async function Xt(e,t,n){const r=Jt(e,!0).put({[Ht]:t,value:n});return new Qt(r).toPromise()}function Zt(e,t){const n=Jt(e,!0).delete(t);return new Qt(n).toPromise()}class en{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 Yt()),this.db}async _withRetries(e){let t=0;for(;;)try{const t=await this._openDb();return await e(t)}catch(e){if(t++>3)throw e;this.db&&(this.db.close(),this.db=void 0)}}async initializeServiceWorkerMessaging(){return Kt()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=Bt._getInstance(Kt()?self:null),this.receiver._subscribe("keyChanged",(async(e,t)=>({keyProcessed:(await this._poll()).includes(t.key)}))),this.receiver._subscribe("ping",(async(e,t)=>["keyChanged"]))}async initializeSender(){var e,t;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(e){return null}}(),!this.activeServiceWorker)return;this.sender=new zt(this.activeServiceWorker);const n=await this.sender._send("ping",{},800);n&&(null===(e=n[0])||void 0===e?void 0:e.fulfilled)&&(null===(t=n[0])||void 0===t?void 0:t.value.includes("keyChanged"))&&(this.serviceWorkerReceiverAvailable=!0)}async notifyServiceWorker(e){var t;if(this.sender&&this.activeServiceWorker&&((null===(t=null===navigator||void 0===navigator?void 0:navigator.serviceWorker)||void 0===t?void 0:t.controller)||null)===this.activeServiceWorker)try{await this.sender._send("keyChanged",{key:e},this.serviceWorkerReceiverAvailable?800:50)}catch(t){}}async _isAvailable(){try{if(!indexedDB)return!1;const e=await Yt();return await Xt(e,Lt,"1"),await Zt(e,Lt),!0}catch(e){}return!1}async _withPendingWrite(e){this.pendingWrites++;try{await e()}finally{this.pendingWrites--}}async _set(e,t){return this._withPendingWrite((async()=>(await this._withRetries((n=>Xt(n,e,t))),this.localCache[e]=t,this.notifyServiceWorker(e))))}async _get(e){const t=await this._withRetries((t=>async function(e,t){const n=Jt(e,!1).get(t),r=await new Qt(n).toPromise();return void 0===r?null:r.value}(t,e)));return this.localCache[e]=t,t}async _remove(e){return this._withPendingWrite((async()=>(await this._withRetries((t=>Zt(t,e))),delete this.localCache[e],this.notifyServiceWorker(e))))}async _poll(){const e=await this._withRetries((e=>{const t=Jt(e,!1).getAll();return new Qt(t).toPromise()}));if(!e)return[];if(0!==this.pendingWrites)return[];const t=[],n=new Set;if(0!==e.length)for(const{fbase_key:r,value:i}of e)n.add(r),JSON.stringify(this.localCache[r])!==JSON.stringify(i)&&(this.notifyListeners(r,i),t.push(r));for(const e of Object.keys(this.localCache))this.localCache[e]&&!n.has(e)&&(this.notifyListeners(e,null),t.push(e));return t}notifyListeners(e,t){this.localCache[e]=t;const n=this.listeners[e];if(n)for(const e of Array.from(n))e(t)}startPolling(){this.stopPolling(),this.pollTimer=setInterval((async()=>this._poll()),800)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}_addListener(e,t){0===Object.keys(this.listeners).length&&this.startPolling(),this.listeners[e]||(this.listeners[e]=new Set,this._get(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),0===this.listeners[e].size&&delete this.listeners[e]),0===Object.keys(this.listeners).length&&this.stopPolling()}}en.type="LOCAL";const tn=en,nn=1e12;class rn{constructor(e){this.auth=e,this.counter=nn,this._widgets=new Map}render(e,t){const n=this.counter;return this._widgets.set(n,new sn(e,this.auth.name,t||{})),this.counter++,n}reset(e){var t;const n=e||nn;null===(t=this._widgets.get(n))||void 0===t||t.delete(),this._widgets.delete(n)}getResponse(e){var t;const n=e||nn;return(null===(t=this._widgets.get(n))||void 0===t?void 0:t.getResponse())||""}async execute(e){var t;const n=e||nn;return null===(t=this._widgets.get(n))||void 0===t||t.execute(),""}}class sn{constructor(e,t,n){this.params=n,this.timerId=null,this.deleted=!1,this.responseToken=null,this.clickHandler=()=>{this.execute()};const r="string"==typeof e?document.getElementById(e):e;v(r,"argument-error",{appName:t}),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(){const e=[],t="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";for(let n=0;n<50;n++)e.push(t.charAt(Math.floor(62*Math.random())));return e.join("")}();const{callback:e,"expired-callback":t}=this.params;if(e)try{e(this.responseToken)}catch(e){}this.timerId=window.setTimeout((()=>{if(this.timerId=null,this.responseToken=null,t)try{t()}catch(e){}this.isVisible&&this.execute()}),6e4)}),500))}checkIfDeleted(){if(this.deleted)throw new Error("reCAPTCHA mock was already deleted!")}}const on=Ce("rcb"),an=new T(3e4,6e4);class cn{constructor(){var e;this.hostLanguage="",this.counter=0,this.librarySeparatelyLoaded=!!(null===(e=Gt().grecaptcha)||void 0===e?void 0:e.render)}load(e,t=""){return v(function(e){return e.length<=6&&/^\s*[a-zA-Z0-9\-]*\s*$/.test(e)}(t),e,"argument-error"),this.shouldResolveImmediately(t)&&F(Gt().grecaptcha)?Promise.resolve(Gt().grecaptcha):new Promise(((n,r)=>{const s=Gt().setTimeout((()=>{r(f(e,"network-request-failed"))}),an.get());Gt()[on]=()=>{Gt().clearTimeout(s),delete Gt()[on];const i=Gt().grecaptcha;if(!i||!F(i))return void r(f(e,"internal-error"));const o=i.render;i.render=(e,t)=>{const n=o(e,t);return this.counter++,n},this.hostLanguage=t,n(i)},Se(`${Te.recaptchaV2Script}?${i.querystring({onload:on,render:"explicit",hl:t})}`).catch((()=>{clearTimeout(s),r(f(e,"internal-error"))}))}))}clearedOneInstance(){this.counter--}shouldResolveImmediately(e){var t;return!!(null===(t=Gt().grecaptcha)||void 0===t?void 0:t.render)&&(e===this.hostLanguage||this.counter>0||this.librarySeparatelyLoaded)}}class un{async load(e){return new rn(e)}clearedOneInstance(){}}const ln="recaptcha",hn={theme:"light",type:"image"};class dn{constructor(e,t){this.verificationId=e,this.onConfirmation=t}confirm(e){const t=Ke._fromVerification(this.verificationId,e);return this.onConfirmation(t)}}async function fn(e,t,n){var r;const i=await n.verify();try{let s;if(v("string"==typeof i,e,"argument-error"),v(n.type===ln,e,"argument-error"),s="string"==typeof t?{phoneNumber:t}:t,"session"in s){const t=s.session;if("phoneNumber"in s){v("enroll"===t.type,e,"internal-error");const n=await function(e,t){return N(e,"POST","/v2/accounts/mfaEnrollment:start",k(e,t))}(e,{idToken:t.credential,phoneEnrollmentInfo:{phoneNumber:s.phoneNumber,recaptchaToken:i}});return n.phoneSessionInfo.sessionInfo}{v("signin"===t.type,e,"internal-error");const n=(null===(r=s.multiFactorHint)||void 0===r?void 0:r.uid)||s.multiFactorUid;v(n,e,"missing-multi-factor-info");const o=await function(e,t){return N(e,"POST","/v2/accounts/mfaSignIn:start",k(e,t))}(e,{mfaPendingCredential:t.credential,mfaEnrollmentId:n,phoneSignInInfo:{recaptchaToken:i}});return o.phoneResponseInfo.sessionInfo}}{const{sessionInfo:t}=await async function(e,t){return N(e,"POST","/v1/accounts:sendVerificationCode",k(e,t))}(e,{phoneNumber:s.phoneNumber,recaptchaToken:i});return t}}finally{n._reset()}}class pn{constructor(e){this.providerId=pn.PROVIDER_ID,this.auth=Ie(e)}verifyPhoneNumber(e,t){return fn(this.auth,e,i.getModularInstance(t))}static credential(e,t){return Ke._fromVerification(e,t)}static credentialFromResult(e){const t=e;return pn.credentialFromTaggedObject(t)}static credentialFromError(e){return pn.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{phoneNumber:t,temporaryProof:n}=e;return t&&n?Ke._fromTokenResponse(t,n):null}}function mn(e,t){return t?re(t):(v(e._popupRedirectResolver,e,"argument-error"),e._popupRedirectResolver)}pn.PROVIDER_ID="phone",pn.PHONE_SIGN_IN_METHOD="phone";class gn extends Pe{constructor(e){super("custom","custom"),this.params=e}_getIdTokenResponse(e){return qe(e,this._buildIdpRequest())}_linkToIdToken(e,t){return qe(e,this._buildIdpRequest(t))}_getReauthenticationResolver(e){return qe(e,this._buildIdpRequest())}_buildIdpRequest(e){const t={requestUri:this.params.requestUri,sessionId:this.params.sessionId,postBody:this.params.postBody,tenantId:this.params.tenantId,pendingToken:this.params.pendingToken,returnSecureToken:!0,returnIdpCredential:!0};return e&&(t.idToken=e),t}}function yn(e){return dt(e.auth,new gn(e),e.bypassAuthState)}function vn(e){const{auth:t,user:n}=e;return v(n,t,"internal-error"),ht(n,new gn(e),e.bypassAuthState)}async function bn(e){const{auth:t,user:n}=e;return v(n,t,"internal-error"),ut(n,new gn(e),e.bypassAuthState)}class wn{constructor(e,t,n,r,i=!1){this.auth=e,this.resolver=n,this.user=r,this.bypassAuthState=i,this.pendingPromise=null,this.eventManager=null,this.filter=Array.isArray(t)?t:[t]}execute(){return new Promise((async(e,t)=>{this.pendingPromise={resolve:e,reject:t};try{this.eventManager=await this.resolver._initialize(this.auth),await this.onExecution(),this.eventManager.registerConsumer(this)}catch(e){this.reject(e)}}))}async onAuthEvent(e){const{urlResponse:t,sessionId:n,postBody:r,tenantId:i,error:s,type:o}=e;if(s)return void this.reject(s);const a={auth:this.auth,requestUri:t,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(e){this.reject(e)}}onError(e){this.reject(e)}getIdpTask(e){switch(e){case"signInViaPopup":case"signInViaRedirect":return yn;case"linkViaPopup":case"linkViaRedirect":return bn;case"reauthViaPopup":case"reauthViaRedirect":return vn;default:d(this.auth,"internal-error")}}resolve(e){w(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){w(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.reject(e),this.unregisterAndCleanUp()}unregisterAndCleanUp(){this.eventManager&&this.eventManager.unregisterConsumer(this),this.pendingPromise=null,this.cleanUp()}}const _n=new T(2e3,1e4);class In extends wn{constructor(e,t,n,r,i){super(e,t,r,i),this.provider=n,this.authWindow=null,this.pollId=null,In.currentPopupAction&&In.currentPopupAction.cancel(),In.currentPopupAction=this}async executeNotNull(){const e=await this.execute();return v(e,this.auth,"internal-error"),e}async onExecution(){w(1===this.filter.length,"Popup operations only handle one event");const e=qt();this.authWindow=await this.resolver._openPopup(this.auth,this.provider,this.filter[0],e),this.authWindow.associatedEvent=e,this.resolver._originValidation(this.auth).catch((e=>{this.reject(e)})),this.resolver._isIframeWebStorageSupported(this.auth,(e=>{e||this.reject(f(this.auth,"web-storage-unsupported"))})),this.pollUserCancellation()}get eventId(){var e;return(null===(e=this.authWindow)||void 0===e?void 0:e.associatedEvent)||null}cancel(){this.reject(f(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,In.currentPopupAction=null}pollUserCancellation(){const e=()=>{var t,n;(null===(n=null===(t=this.authWindow)||void 0===t?void 0:t.window)||void 0===n?void 0:n.closed)?this.pollId=window.setTimeout((()=>{this.pollId=null,this.reject(f(this.auth,"popup-closed-by-user"))}),8e3):this.pollId=window.setTimeout(e,_n.get())};e()}}In.currentPopupAction=null;const En="pendingRedirect",Tn=new Map;class Sn extends wn{constructor(e,t,n=!1){super(e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],t,void 0,n),this.eventId=null}async execute(){let e=Tn.get(this.auth._key());if(!e){try{const t=await async function(e,t){const n=kn(t),r=xn(e);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;e=()=>Promise.resolve(t)}catch(t){e=()=>Promise.reject(t)}Tn.set(this.auth._key(),e)}return this.bypassAuthState||Tn.set(this.auth._key(),(()=>Promise.resolve(null))),e()}async onAuthEvent(e){if("signInViaRedirect"===e.type)return super.onAuthEvent(e);if("unknown"!==e.type){if(e.eventId){const t=await this.auth._redirectUserForId(e.eventId);if(t)return this.user=t,super.onAuthEvent(e);this.resolve(null)}}else this.resolve(null)}async onExecution(){}cleanUp(){}}async function Cn(e,t){return xn(e)._set(kn(t),"true")}function An(e,t){Tn.set(e._key(),t)}function xn(e){return re(e._redirectPersistence)}function kn(e){return oe(En,e.config.apiKey,e.name)}async function Nn(e,t,n=!1){if(r._isFirebaseServerApp(e.app))return Promise.reject(m(e));const i=Ie(e),s=mn(i,t),o=new Sn(i,s,n),a=await o.execute();return a&&!n&&(delete a.user._redirectEventId,await i._persistUserIfCurrent(a.user),await i._setRedirectUser(null,t)),a}async function On(e){const t=qt(`${e.uid}:::`);return e._redirectEventId=t,await e.auth._setRedirectUser(e),await e.auth._persistUserIfCurrent(e),t}class Dn{constructor(e){this.auth=e,this.cachedEventUids=new Set,this.consumers=new Set,this.queuedRedirectEvent=null,this.hasHandledPotentialRedirect=!1,this.lastProcessedEventTime=Date.now()}registerConsumer(e){this.consumers.add(e),this.queuedRedirectEvent&&this.isEventForConsumer(this.queuedRedirectEvent,e)&&(this.sendToConsumer(this.queuedRedirectEvent,e),this.saveEventToCache(this.queuedRedirectEvent),this.queuedRedirectEvent=null)}unregisterConsumer(e){this.consumers.delete(e)}onEvent(e){if(this.hasEventBeenHandled(e))return!1;let t=!1;return this.consumers.forEach((n=>{this.isEventForConsumer(e,n)&&(t=!0,this.sendToConsumer(e,n),this.saveEventToCache(e))})),this.hasHandledPotentialRedirect||!function(e){switch(e.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return!0;case"unknown":return Pn(e);default:return!1}}(e)||(this.hasHandledPotentialRedirect=!0,t||(this.queuedRedirectEvent=e,t=!0)),t}sendToConsumer(e,t){var n;if(e.error&&!Pn(e)){const r=(null===(n=e.error.code)||void 0===n?void 0:n.split("auth/")[1])||"internal-error";t.onError(f(this.auth,r))}else t.onAuthEvent(e)}isEventForConsumer(e,t){const n=null===t.eventId||!!e.eventId&&e.eventId===t.eventId;return t.filter.includes(e.type)&&n}hasEventBeenHandled(e){return Date.now()-this.lastProcessedEventTime>=6e5&&this.cachedEventUids.clear(),this.cachedEventUids.has(Rn(e))}saveEventToCache(e){this.cachedEventUids.add(Rn(e)),this.lastProcessedEventTime=Date.now()}}function Rn(e){return[e.type,e.eventId,e.sessionId,e.tenantId].filter((e=>e)).join("-")}function Pn({type:e,error:t}){return"unknown"===e&&"auth/no-auth-event"===(null==t?void 0:t.code)}async function Ln(e,t={}){return N(e,"GET","/v1/projects",t)}const Mn=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,Fn=/^https?/;function Vn(e){const t=_(),{protocol:n,hostname:r}=new URL(t);if(e.startsWith("chrome-extension://")){const i=new URL(e);return""===i.hostname&&""===r?"chrome-extension:"===n&&e.replace("chrome-extension://","")===t.replace("chrome-extension://",""):"chrome-extension:"===n&&i.hostname===r}if(!Fn.test(n))return!1;if(Mn.test(e))return r===e;const i=e.replace(/\./g,"\\.");return new RegExp("^(.+\\."+i+"|"+i+")$","i").test(r)}const Un=new T(3e4,6e4);function jn(){const e=Gt().___jsl;if(null==e?void 0:e.H)for(const t of Object.keys(e.H))if(e.H[t].r=e.H[t].r||[],e.H[t].L=e.H[t].L||[],e.H[t].r=[...e.H[t].L],e.CP)for(let t=0;t<e.CP.length;t++)e.CP[t]=null}function Bn(e){return new Promise(((t,n)=>{var r,i,s;function o(){jn(),gapi.load("gapi.iframes",{callback:()=>{t(gapi.iframes.getContext())},ontimeout:()=>{jn(),n(f(e,"network-request-failed"))},timeout:Un.get()})}if(null===(i=null===(r=Gt().gapi)||void 0===r?void 0:r.iframes)||void 0===i?void 0:i.Iframe)t(gapi.iframes.getContext());else{if(!(null===(s=Gt().gapi)||void 0===s?void 0:s.load)){const t=Ce("iframefcb");return Gt()[t]=()=>{gapi.load?o():n(f(e,"network-request-failed"))},Se(`${Te.gapiScript}?onload=${t}`).catch((e=>n(e)))}o()}})).catch((e=>{throw qn=null,e}))}let qn=null;const zn=new T(5e3,15e3),Gn="__/auth/iframe",Kn="emulator/auth/iframe",Wn={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},$n=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);function Hn(e){const t=e.config;v(t.authDomain,e,"auth-domain-config-required");const n=t.emulator?S(t,Kn):`https://${e.config.authDomain}/${Gn}`,s={apiKey:t.apiKey,appName:e.name,v:r.SDK_VERSION},o=$n.get(e.config.apiHost);o&&(s.eid=o);const a=e._getFrameworks();return a.length&&(s.fw=a.join(",")),`${n}?${i.querystring(s).slice(1)}`}const Qn={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"};class Jn{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch(e){}}}const Yn=encodeURIComponent("fac");async function Xn(e,t,n,s,o,a){v(e.config.authDomain,e,"auth-domain-config-required"),v(e.config.apiKey,e,"invalid-api-key");const c={apiKey:e.config.apiKey,appName:e.name,authType:n,redirectUrl:s,v:r.SDK_VERSION,eventId:o};if(t instanceof He){t.setDefaultLanguage(e.languageCode),c.providerId=t.providerId||"",i.isEmpty(t.getCustomParameters())||(c.customParameters=JSON.stringify(t.getCustomParameters()));for(const[e,t]of Object.entries(a||{}))c[e]=t}if(t instanceof Qe){const e=t.getScopes().filter((e=>""!==e));e.length>0&&(c.scopes=e.join(","))}e.tenantId&&(c.tid=e.tenantId);const u=c;for(const e of Object.keys(u))void 0===u[e]&&delete u[e];const l=await e._getAppCheckToken(),h=l?`#${Yn}=${encodeURIComponent(l)}`:"";return`${function({config:e}){return e.emulator?S(e,"emulator/auth/handler"):`https://${e.authDomain}/__/auth/handler`}(e)}?${i.querystring(u).slice(1)}${h}`}const Zn="webStorageSupport",er=class{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=jt,this._completeRedirectFn=Nn,this._overrideRedirectResult=An}async _openPopup(e,t,n,r){var s;return w(null===(s=this.eventManagers[e._key()])||void 0===s?void 0:s.manager,"_initialize() not called before _openPopup()"),function(e,t,n,r=500,s=600){const o=Math.max((window.screen.availHeight-s)/2,0).toString(),a=Math.max((window.screen.availWidth-r)/2,0).toString();let c="";const u=Object.assign(Object.assign({},Qn),{width:r.toString(),height:s.toString(),top:o,left:a}),l=i.getUA().toLowerCase();n&&(c=he(l)?"_blank":n),ue(l)&&(t=t||"http://localhost",u.scrollbars="yes");const h=Object.entries(u).reduce(((e,[t,n])=>`${e}${t}=${n},`),"");if(function(e=i.getUA()){var t;return ge(e)&&!!(null===(t=window.navigator)||void 0===t?void 0:t.standalone)}(l)&&"_self"!==c)return function(e,t){const n=document.createElement("a");n.href=e,n.target=t;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)}(t||"",c),new Jn(null);const d=window.open(t||"",c,h);v(d,e,"popup-blocked");try{d.focus()}catch(e){}return new Jn(d)}(e,await Xn(e,t,n,_(),r),qt())}async _openRedirect(e,t,n,r){return await this._originValidation(e),i=await Xn(e,t,n,_(),r),Gt().location.href=i,new Promise((()=>{}));var i}_initialize(e){const t=e._key();if(this.eventManagers[t]){const{manager:e,promise:n}=this.eventManagers[t];return e?Promise.resolve(e):(w(n,"If manager is not set, promise should be"),n)}const n=this.initAndGetManager(e);return this.eventManagers[t]={promise:n},n.catch((()=>{delete this.eventManagers[t]})),n}async initAndGetManager(e){const t=await async function(e){const t=await function(e){return qn=qn||Bn(e),qn}(e),n=Gt().gapi;return v(n,e,"internal-error"),t.open({where:document.body,url:Hn(e),messageHandlersFilter:n.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:Wn,dontclear:!0},(t=>new Promise((async(n,r)=>{await t.restyle({setHideOnLeave:!1});const i=f(e,"network-request-failed"),s=Gt().setTimeout((()=>{r(i)}),zn.get());function o(){Gt().clearTimeout(s),n(t)}t.ping(o).then(o,(()=>{r(i)}))}))))}(e),n=new Dn(e);return t.register("authEvent",(t=>(v(null==t?void 0:t.authEvent,e,"invalid-auth-event"),{status:n.onEvent(t.authEvent)?"ACK":"ERROR"})),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[e._key()]={manager:n},this.iframes[e._key()]=t,n}_isIframeWebStorageSupported(e,t){this.iframes[e._key()].send(Zn,{type:Zn},(n=>{var r;const i=null===(r=null==n?void 0:n[0])||void 0===r?void 0:r[Zn];void 0!==i&&t(!!i),d(e,"internal-error")}),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){const t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=async function(e){if(e.config.emulator)return;const{authorizedDomains:t}=await Ln(e);for(const e of t)try{if(Vn(e))return}catch(e){}d(e,"unauthorized-domain")}(e)),this.originValidationPromises[t]}get _shouldInitProactively(){return ye()||le()||ge()}};class tr{constructor(e){this.factorId=e}_process(e,t,n){switch(t.type){case"enroll":return this._finalizeEnroll(e,t.credential,n);case"signin":return this._finalizeSignIn(e,t.credential);default:return b("unexpected MultiFactorSessionType")}}}class nr extends tr{constructor(e){super("phone"),this.credential=e}static _fromCredential(e){return new nr(e)}_finalizeEnroll(e,t,n){return function(e,t){return N(e,"POST","/v2/accounts/mfaEnrollment:finalize",k(e,t))}(e,{idToken:t,displayName:n,phoneVerificationInfo:this.credential._makeVerificationRequest()})}_finalizeSignIn(e,t){return function(e,t){return N(e,"POST","/v2/accounts/mfaSignIn:finalize",k(e,t))}(e,{mfaPendingCredential:t,phoneVerificationInfo:this.credential._makeVerificationRequest()})}}class rr{constructor(){}static assertion(e){return nr._fromCredential(e)}}rr.FACTOR_ID="phone";class ir{static assertionForEnrollment(e,t){return sr._fromSecret(e,t)}static assertionForSignIn(e,t){return sr._fromEnrollmentId(e,t)}static async generateSecret(e){var t;const n=e;v(void 0!==(null===(t=n.user)||void 0===t?void 0:t.auth),"internal-error");const r=await(i=n.user.auth,s={idToken:n.credential,totpEnrollmentInfo:{}},N(i,"POST","/v2/accounts/mfaEnrollment:start",k(i,s)));var i,s;return or._fromStartTotpMfaEnrollmentResponse(r,n.user.auth)}}ir.FACTOR_ID="totp";class sr extends tr{constructor(e,t,n){super("totp"),this.otp=e,this.enrollmentId=t,this.secret=n}static _fromSecret(e,t){return new sr(t,void 0,e)}static _fromEnrollmentId(e,t){return new sr(t,e)}async _finalizeEnroll(e,t,n){return v(void 0!==this.secret,e,"argument-error"),function(e,t){return N(e,"POST","/v2/accounts/mfaEnrollment:finalize",k(e,t))}(e,{idToken:t,displayName:n,totpVerificationInfo:this.secret._makeTotpVerificationInfo(this.otp)})}async _finalizeSignIn(e,t){v(void 0!==this.enrollmentId&&void 0!==this.otp,e,"argument-error");const n={verificationCode:this.otp};return function(e,t){return N(e,"POST","/v2/accounts/mfaSignIn:finalize",k(e,t))}(e,{mfaPendingCredential:t,mfaEnrollmentId:this.enrollmentId,totpVerificationInfo:n})}}class or{constructor(e,t,n,r,i,s,o){this.sessionInfo=s,this.auth=o,this.secretKey=e,this.hashingAlgorithm=t,this.codeLength=n,this.codeIntervalSeconds=r,this.enrollmentCompletionDeadline=i}static _fromStartTotpMfaEnrollmentResponse(e,t){return new or(e.totpSessionInfo.sharedSecretKey,e.totpSessionInfo.hashingAlgorithm,e.totpSessionInfo.verificationCodeLength,e.totpSessionInfo.periodSec,new Date(e.totpSessionInfo.finalizeEnrollmentTime).toUTCString(),e.totpSessionInfo.sessionInfo,t)}_makeTotpVerificationInfo(e){return{sessionInfo:this.sessionInfo,verificationCode:e}}generateQrCodeUrl(e,t){var n;let r=!1;return(ar(e)||ar(t))&&(r=!0),r&&(ar(e)&&(e=(null===(n=this.auth.currentUser)||void 0===n?void 0:n.email)||"unknownuser"),ar(t)&&(t=this.auth.name)),`otpauth://totp/${t}:${e}?secret=${this.secretKey}&issuer=${t}&algorithm=${this.hashingAlgorithm}&digits=${this.codeLength}`}}function ar(e){return void 0===e||0===(null==e?void 0:e.length)}var cr="@firebase/auth",ur="1.7.9";class lr{constructor(e){this.auth=e,this.internalListeners=new Map}getUid(){var e;return this.assertAuthConfigured(),(null===(e=this.auth.currentUser)||void 0===e?void 0:e.uid)||null}async getToken(e){return this.assertAuthConfigured(),await this.auth._initializationPromise,this.auth.currentUser?{accessToken:await this.auth.currentUser.getIdToken(e)}:null}addAuthTokenListener(e){if(this.assertAuthConfigured(),this.internalListeners.has(e))return;const t=this.auth.onIdTokenChanged((t=>{e((null==t?void 0:t.stsTokenManager.accessToken)||null)}));this.internalListeners.set(e,t),this.updateProactiveRefresh()}removeAuthTokenListener(e){this.assertAuthConfigured();const t=this.internalListeners.get(e);t&&(this.internalListeners.delete(e),t(),this.updateProactiveRefresh())}assertAuthConfigured(){v(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}const hr=i.getExperimentalSetting("authIdTokenMaxAge")||300;let dr=null;var fr;Te={loadJS:e=>new Promise(((t,n)=>{const r=document.createElement("script");var i,s;r.setAttribute("src",e),r.onload=t,r.onerror=e=>{const t=f("internal-error");t.customData=e,n(t)},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)})),gapiScript:"https://apis.google.com/js/api.js",recaptchaV2Script:"https://www.google.com/recaptcha/api.js",recaptchaEnterpriseScript:"https://www.google.com/recaptcha/enterprise.js?render="},fr="Browser",r._registerComponent(new a.Component("auth",((e,{options:t})=>{const n=e.getProvider("app").getImmediate(),r=e.getProvider("heartbeat"),i=e.getProvider("app-check-internal"),{apiKey:s,authDomain:o}=n.options;v(s&&!s.includes(":"),"invalid-api-key",{appName:n.name});const a={apiKey:s,authDomain:o,clientPlatform:fr,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:ve(fr)},c=new _e(n,r,i,a);return function(e,t){const n=(null==t?void 0:t.persistence)||[],r=(Array.isArray(n)?n:[n]).map(re);(null==t?void 0:t.errorMap)&&e._updateErrorMap(t.errorMap),e._initializeWithPersistence(r,null==t?void 0:t.popupRedirectResolver)}(c,t),c}),"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback(((e,t,n)=>{e.getProvider("auth-internal").initialize()}))),r._registerComponent(new a.Component("auth-internal",(e=>{return t=Ie(e.getProvider("auth").getImmediate()),new lr(t);var t}),"PRIVATE").setInstantiationMode("EXPLICIT")),r.registerVersion(cr,ur,function(e){switch(e){case"Node":return"node";case"ReactNative":return"rn";case"Worker":return"webworker";case"Cordova":return"cordova";case"WebExtension":return"web-extension";default:return}}(fr)),r.registerVersion(cr,ur,"cjs2017"),t.AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY={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_LOGIN_CREDENTIALS:"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",RECAPTCHA_NOT_ENABLED:"auth/recaptcha-not-enabled",MISSING_RECAPTCHA_TOKEN:"auth/missing-recaptcha-token",INVALID_RECAPTCHA_TOKEN:"auth/invalid-recaptcha-token",INVALID_RECAPTCHA_ACTION:"auth/invalid-recaptcha-action",MISSING_CLIENT_TYPE:"auth/missing-client-type",MISSING_RECAPTCHA_VERSION:"auth/missing-recaptcha-version",INVALID_RECAPTCHA_VERSION:"auth/invalid-recaptcha-version",INVALID_REQ_TYPE:"auth/invalid-req-type"},t.ActionCodeOperation={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"},t.ActionCodeURL=We,t.AuthCredential=Pe,t.AuthEventManager=Dn,t.AuthImpl=_e,t.AuthPopup=Jn,t.EmailAuthCredential=Be,t.EmailAuthProvider=$e,t.FacebookAuthProvider=Ye,t.FactorId={PHONE:"phone",TOTP:"totp"},t.FetchProvider=C,t.GithubAuthProvider=Ze,t.GoogleAuthProvider=Xe,t.OAuthCredential=ze,t.OAuthProvider=Je,t.OperationType={LINK:"link",REAUTHENTICATE:"reauthenticate",SIGN_IN:"signIn"},t.PhoneAuthCredential=Ke,t.PhoneAuthProvider=pn,t.PhoneMultiFactorGenerator=rr,t.ProviderId={FACEBOOK:"facebook.com",GITHUB:"github.com",GOOGLE:"google.com",PASSWORD:"password",PHONE:"phone",TWITTER:"twitter.com"},t.RecaptchaVerifier=class{constructor(e,t,n=Object.assign({},hn)){this.parameters=n,this.type=ln,this.destroyed=!1,this.widgetId=null,this.tokenChangeListeners=new Set,this.renderPromise=null,this.recaptcha=null,this.auth=Ie(e),this.isInvisible="invisible"===this.parameters.size,v("undefined"!=typeof document,this.auth,"operation-not-supported-in-this-environment");const r="string"==typeof t?document.getElementById(t):t;v(r,this.auth,"argument-error"),this.container=r,this.parameters.callback=this.makeTokenCallback(this.parameters.callback),this._recaptchaLoader=this.auth.settings.appVerificationDisabledForTesting?new un:new cn,this.validateStartingState()}async verify(){this.assertNotDestroyed();const e=await this.render(),t=this.getAssertedRecaptcha();return t.getResponse(e)||new Promise((n=>{const r=e=>{e&&(this.tokenChangeListeners.delete(r),n(e))};this.tokenChangeListeners.add(r),this.isInvisible&&t.execute(e)}))}render(){try{this.assertNotDestroyed()}catch(e){return Promise.reject(e)}return this.renderPromise||(this.renderPromise=this.makeRenderPromise().catch((e=>{throw this.renderPromise=null,e}))),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((e=>{this.container.removeChild(e)}))}validateStartingState(){v(!this.parameters.sitekey,this.auth,"argument-error"),v(this.isInvisible||!this.container.hasChildNodes(),this.auth,"argument-error"),v("undefined"!=typeof document,this.auth,"operation-not-supported-in-this-environment")}makeTokenCallback(e){return t=>{if(this.tokenChangeListeners.forEach((e=>e(t))),"function"==typeof e)e(t);else if("string"==typeof e){const n=Gt()[e];"function"==typeof n&&n(t)}}}assertNotDestroyed(){v(!this.destroyed,this.auth,"internal-error")}async makeRenderPromise(){if(await this.init(),!this.widgetId){let e=this.container;if(!this.isInvisible){const t=document.createElement("div");e.appendChild(t),e=t}this.widgetId=this.getAssertedRecaptcha().render(e,this.parameters)}return this.widgetId}async init(){v(I()&&!Kt(),this.auth,"internal-error"),await function(){let e=null;return new Promise((t=>{"complete"!==document.readyState?(e=()=>t(),window.addEventListener("load",e)):t()})).catch((t=>{throw e&&window.removeEventListener("load",e),t}))}(),this.recaptcha=await this._recaptchaLoader.load(this.auth,this.auth.languageCode||void 0);const e=await async function(e){return(await N(e,"GET","/v1/recaptchaParams")).recaptchaSiteKey||""}(this.auth);v(e,this.auth,"internal-error"),this.parameters.sitekey=e}getAssertedRecaptcha(){return v(this.recaptcha,this.auth,"internal-error"),this.recaptcha}},t.SAMLAuthCredential=et,t.SAMLAuthProvider=tt,t.SignInMethod={EMAIL_LINK:"emailLink",EMAIL_PASSWORD:"password",FACEBOOK:"facebook.com",GITHUB:"github.com",GOOGLE:"google.com",PHONE:"phone",TWITTER:"twitter.com"},t.TotpMultiFactorGenerator=ir,t.TotpSecret=or,t.TwitterAuthProvider=nt,t.UserImpl=te,t._assert=v,t._castAuth=Ie,t._clearRedirectOutcomes=function(){Tn.clear()},t._createError=f,t._fail=d,t._generateEventId=qt,t._getClientVersion=ve,t._getInstance=re,t._getProjectConfig=Ln,t._getRedirectResult=Nn,t._getRedirectUrl=Xn,t._isAndroid=fe,t._isIOS=ge,t._isIOS7Or8=function(e=i.getUA()){return/(iPad|iPhone|iPod).*OS 7_\d/i.test(e)||/(iPad|iPhone|iPod).*OS 8_\d/i.test(e)},t._overrideRedirectResult=An,t._persistenceKeyName=oe,t.applyActionCode=async function(e,t){await async function(e,t){return N(e,"POST","/v1/accounts:update",k(e,t))}(i.getModularInstance(e),{oobCode:t})},t.beforeAuthStateChanged=Nt,t.browserLocalPersistence=Vt,t.browserPopupRedirectResolver=er,t.browserSessionPersistence=jt,t.checkActionCode=_t,t.confirmPasswordReset=async function(e,t,n){await Le(i.getModularInstance(e),{oobCode:t,newPassword:n}).catch((async t=>{throw"auth/password-does-not-meet-requirements"===t.code&&wt(e),t}))},t.connectAuthEmulator=Oe,t.createUserWithEmailAndPassword=async function(e,t,n){if(r._isFirebaseServerApp(e.app))return Promise.reject(m(e));const i=Ie(e),s=ke(i,{returnSecureToken:!0,email:t,password:n,clientType:"CLIENT_TYPE_WEB"},"signUpPassword",rt),o=await s.catch((t=>{throw"auth/password-does-not-meet-requirements"===t.code&&wt(e),t})),a=await it._fromIdTokenResponse(i,"signIn",o);return await i._updateCurrentUser(a.user),a},t.debugAssert=w,t.debugErrorMap=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 registered 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 incorrect, 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.","login-blocked":"Login blocked by user-provided method: {$originalMessage}","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-password":"A non-empty password must be provided","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.","missing-recaptcha-token":"The reCAPTCHA token is missing when sending request to the backend.","invalid-recaptcha-token":"The reCAPTCHA token is invalid when sending request to the backend.","invalid-recaptcha-action":"The reCAPTCHA action is invalid when sending request to the backend.","recaptcha-not-enabled":"reCAPTCHA Enterprise integration is not enabled for this project.","missing-client-type":"The reCAPTCHA client type is missing when sending request to the backend.","missing-recaptcha-version":"The reCAPTCHA version is missing when sending request to the backend.","invalid-req-type":"Invalid request parameters.","invalid-recaptcha-version":"The reCAPTCHA version is invalid when sending request to the backend.","unsupported-password-policy-schema-version":"The password policy received from the backend uses a schema version that is not supported by this version of the Firebase SDK.","password-does-not-meet-requirements":"The password does not meet the requirements."}},t.deleteUser=async function(e){return i.getModularInstance(e).delete()},t.fetchSignInMethodsForEmail=async function(e,t){const n={identifier:t,continueUri:I()?_():"http://localhost"},{signinMethods:r}=await async function(e,t){return N(e,"POST","/v1/accounts:createAuthUri",k(e,t))}(i.getModularInstance(e),n);return r||[]},t.getAdditionalUserInfo=function(e){const{user:t,_tokenResponse:n}=e;return t.isAnonymous&&!n?{providerId:null,isNewUser:!1,profile:null}:function(e){var t,n;if(!e)return null;const{providerId:r}=e,i=e.rawUserInfo?JSON.parse(e.rawUserInfo):{},s=e.isNewUser||"identitytoolkit#SignupNewUserResponse"===e.kind;if(!r&&(null==e?void 0:e.idToken)){const r=null===(n=null===(t=K(e.idToken))||void 0===t?void 0:t.firebase)||void 0===n?void 0:n.sign_in_provider;if(r)return new Et(s,"anonymous"!==r&&"custom"!==r?r:null)}if(!r)return null;switch(r){case"facebook.com":return new St(s,i);case"github.com":return new Ct(s,i);case"google.com":return new At(s,i);case"twitter.com":return new xt(s,i,e.screenName||null);case"custom":case"anonymous":return new Et(s,null);default:return new Et(s,r,i)}}(n)},t.getAuth=function(e=r.getApp()){const t=r._getProvider(e,"auth");if(t.isInitialized())return t.getImmediate();const n=Ne(e,{popupRedirectResolver:er,persistence:[tn,Vt,jt]}),s=i.getExperimentalSetting("authTokenSyncURL");if(s&&"boolean"==typeof isSecureContext&&isSecureContext){const e=new URL(s,location.origin);if(location.origin===e.origin){const t=(o=e.toString(),async e=>{const t=e&&await e.getIdTokenResult(),n=t&&((new Date).getTime()-Date.parse(t.issuedAtTime))/1e3;if(n&&n>hr)return;const r=null==t?void 0:t.token;dr!==r&&(dr=r,await fetch(o,{method:r?"POST":"DELETE",headers:r?{Authorization:`Bearer ${r}`}:{}}))});Nt(n,t,(()=>t(n.currentUser))),kt(n,(e=>t(e)))}}var o;const a=i.getDefaultEmulatorHost("auth");return a&&Oe(n,`http://${a}`),n},t.getIdToken=function(e,t=!1){return i.getModularInstance(e).getIdToken(t)},t.getIdTokenResult=z,t.getMultiFactorResolver=function(e,t){var n;const r=i.getModularInstance(e),s=t;return v(t.customData.operationType,r,"argument-error"),v(null===(n=s.customData._serverResponse)||void 0===n?void 0:n.mfaPendingCredential,r,"argument-error"),Dt._fromError(r,s)},t.getRedirectResult=async function(e,t){return await Ie(e)._initializationPromise,Nn(e,t,!1)},t.inMemoryPersistence=se,t.indexedDBLocalPersistence=tn,t.initializeAuth=Ne,t.initializeRecaptchaConfig=function(e){return async function(e){const t=Ie(e),n=await j(t,{clientType:"CLIENT_TYPE_WEB",version:"RECAPTCHA_ENTERPRISE"}),r=new U(n);null==t.tenantId?t._agentRecaptchaConfig=r:t._tenantRecaptchaConfigs[t.tenantId]=r,r.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")&&new Ae(t).verify()}(e)},t.isSignInWithEmailLink=function(e,t){const n=We.parseLink(t);return"EMAIL_SIGNIN"===(null==n?void 0:n.operation)},t.linkWithCredential=pt,t.linkWithPhoneNumber=async function(e,t,n){const r=i.getModularInstance(e);await lt(!1,r,"phone");const s=await fn(r.auth,t,i.getModularInstance(n));return new dn(s,(e=>pt(r,e)))},t.linkWithPopup=async function(e,t,n){const r=i.getModularInstance(e);g(r.auth,t,He);const s=mn(r.auth,n);return new In(r.auth,"linkViaPopup",t,s,r).executeNotNull()},t.linkWithRedirect=function(e,t,n){return async function(e,t,n){const r=i.getModularInstance(e);g(r.auth,t,He),await r.auth._initializationPromise;const s=mn(r.auth,n);await lt(!1,r,t.providerId),await Cn(s,r.auth);const o=await On(r);return s._openRedirect(r.auth,t,"linkViaRedirect",o)}(e,t,n)},t.multiFactor=function(e){const t=i.getModularInstance(e);return Pt.has(t)||Pt.set(t,Rt._fromUser(t)),Pt.get(t)},t.onAuthStateChanged=function(e,t,n,r){return i.getModularInstance(e).onAuthStateChanged(t,n,r)},t.onIdTokenChanged=kt,t.parseActionCodeURL=function(e){return We.parseLink(e)},t.prodErrorMap=c,t.reauthenticateWithCredential=mt,t.reauthenticateWithPhoneNumber=async function(e,t,n){const s=i.getModularInstance(e);if(r._isFirebaseServerApp(s.auth.app))return Promise.reject(m(s.auth));const o=await fn(s.auth,t,i.getModularInstance(n));return new dn(o,(e=>mt(s,e)))},t.reauthenticateWithPopup=async function(e,t,n){const s=i.getModularInstance(e);if(r._isFirebaseServerApp(s.auth.app))return Promise.reject(f(s.auth,"operation-not-supported-in-this-environment"));g(s.auth,t,He);const o=mn(s.auth,n);return new In(s.auth,"reauthViaPopup",t,o,s).executeNotNull()},t.reauthenticateWithRedirect=function(e,t,n){return async function(e,t,n){const s=i.getModularInstance(e);if(g(s.auth,t,He),r._isFirebaseServerApp(s.auth.app))return Promise.reject(m(s.auth));await s.auth._initializationPromise;const o=mn(s.auth,n);await Cn(o,s.auth);const a=await On(s);return o._openRedirect(s.auth,t,"reauthViaRedirect",a)}(e,t,n)},t.reload=Y,t.revokeAccessToken=function(e,t){return Ie(e).revokeAccessToken(t)},t.sendEmailVerification=async function(e,t){const n=i.getModularInstance(e),r={requestType:"VERIFY_EMAIL",idToken:await e.getIdToken()};t&&bt(n.auth,r,t);const{email:s}=await async function(e,t){return Ve(e,t)}(n.auth,r);s!==e.email&&await e.reload()},t.sendPasswordResetEmail=async function(e,t,n){const r=Ie(e),i={requestType:"PASSWORD_RESET",email:t,clientType:"CLIENT_TYPE_WEB"};n&&bt(r,i,n),await ke(r,i,"getOobCode",Ue)},t.sendSignInLinkToEmail=async function(e,t,n){const r=Ie(e),i={requestType:"EMAIL_SIGNIN",email:t,clientType:"CLIENT_TYPE_WEB"};!function(e,t){v(t.handleCodeInApp,r,"argument-error"),t&&bt(r,e,t)}(i,n),await ke(r,i,"getOobCode",je)},t.setPersistence=function(e,t){return i.getModularInstance(e).setPersistence(t)},t.signInAnonymously=async function(e){var t;if(r._isFirebaseServerApp(e.app))return Promise.reject(m(e));const n=Ie(e);if(await n._initializationPromise,null===(t=n.currentUser)||void 0===t?void 0:t.isAnonymous)return new it({user:n.currentUser,providerId:null,operationType:"signIn"});const i=await rt(n,{returnSecureToken:!0}),s=await it._fromIdTokenResponse(n,"signIn",i,!0);return await n._updateCurrentUser(s.user),s},t.signInWithCredential=ft,t.signInWithCustomToken=async function(e,t){if(r._isFirebaseServerApp(e.app))return Promise.reject(m(e));const n=Ie(e),i=await async function(e,t){return D(e,"POST","/v1/accounts:signInWithCustomToken",k(e,t))}(n,{token:t,returnSecureToken:!0}),s=await it._fromIdTokenResponse(n,"signIn",i);return await n._updateCurrentUser(s.user),s},t.signInWithEmailAndPassword=function(e,t,n){return r._isFirebaseServerApp(e.app)?Promise.reject(m(e)):ft(i.getModularInstance(e),$e.credential(t,n)).catch((async t=>{throw"auth/password-does-not-meet-requirements"===t.code&&wt(e),t}))},t.signInWithEmailLink=async function(e,t,n){if(r._isFirebaseServerApp(e.app))return Promise.reject(m(e));const s=i.getModularInstance(e),o=$e.credentialWithLink(t,n||_());return v(o._tenantId===(s.tenantId||null),s,"tenant-id-mismatch"),ft(s,o)},t.signInWithPhoneNumber=async function(e,t,n){if(r._isFirebaseServerApp(e.app))return Promise.reject(m(e));const s=Ie(e),o=await fn(s,t,i.getModularInstance(n));return new dn(o,(e=>ft(s,e)))},t.signInWithPopup=async function(e,t,n){if(r._isFirebaseServerApp(e.app))return Promise.reject(f(e,"operation-not-supported-in-this-environment"));const i=Ie(e);g(e,t,He);const s=mn(i,n);return new In(i,"signInViaPopup",t,s).executeNotNull()},t.signInWithRedirect=function(e,t,n){return async function(e,t,n){if(r._isFirebaseServerApp(e.app))return Promise.reject(m(e));const i=Ie(e);g(e,t,He),await i._initializationPromise;const s=mn(i,n);return await Cn(s,i),s._openRedirect(i,t,"signInViaRedirect")}(e,t,n)},t.signOut=function(e){return i.getModularInstance(e).signOut()},t.unlink=async function(e,t){const n=i.getModularInstance(e);await lt(!0,n,t);const{providerUserInfo:r}=await async function(e,t){return N(e,"POST","/v1/accounts:update",t)}(n.auth,{idToken:await n.getIdToken(),deleteProvider:[t]}),s=ct(r||[]);return n.providerData=n.providerData.filter((e=>s.has(e.providerId))),s.has("phone")||(n.phoneNumber=null),await n.auth._persistUserIfCurrent(n),n},t.updateCurrentUser=function(e,t){return i.getModularInstance(e).updateCurrentUser(t)},t.updateEmail=function(e,t){const n=i.getModularInstance(e);return r._isFirebaseServerApp(n.auth.app)?Promise.reject(m(n.auth)):It(n,t,null)},t.updatePassword=function(e,t){return It(i.getModularInstance(e),null,t)},t.updatePhoneNumber=async function(e,t){const n=i.getModularInstance(e);if(r._isFirebaseServerApp(n.auth.app))return Promise.reject(m(n.auth));await ut(n,t)},t.updateProfile=async function(e,{displayName:t,photoURL:n}){if(void 0===t&&void 0===n)return;const r=i.getModularInstance(e),s={idToken:await r.getIdToken(),displayName:t,photoUrl:n,returnSecureToken:!0},o=await $(r,async function(e,t){return N(e,"POST","/v1/accounts:update",t)}(r.auth,s));r.displayName=o.displayName||null,r.photoURL=o.photoUrl||null;const a=r.providerData.find((({providerId:e})=>"password"===e));a&&(a.displayName=r.displayName,a.photoURL=r.photoURL),await r._updateTokensIfNecessary(o)},t.useDeviceLanguage=function(e){i.getModularInstance(e).useDeviceLanguage()},t.validatePassword=async function(e,t){return Ie(e).validatePassword(t)},t.verifyBeforeUpdateEmail=async function(e,t,n){const r=i.getModularInstance(e),s={requestType:"VERIFY_AND_CHANGE_EMAIL",idToken:await e.getIdToken(),newEmail:t};n&&bt(r.auth,s,n);const{email:o}=await async function(e,t){return Ve(e,t)}(r.auth,s);o!==e.email&&await e.reload()},t.verifyPasswordResetCode=async function(e,t){const{data:n}=await _t(i.getModularInstance(e),t);return n.email}},9970:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(6906);n(6199),n(6336),n(5844),n(1635),n(5319),t.ActionCodeOperation=r.ActionCodeOperation,t.ActionCodeURL=r.ActionCodeURL,t.AuthCredential=r.AuthCredential,t.AuthErrorCodes=r.AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY,t.EmailAuthCredential=r.EmailAuthCredential,t.EmailAuthProvider=r.EmailAuthProvider,t.FacebookAuthProvider=r.FacebookAuthProvider,t.FactorId=r.FactorId,t.GithubAuthProvider=r.GithubAuthProvider,t.GoogleAuthProvider=r.GoogleAuthProvider,t.OAuthCredential=r.OAuthCredential,t.OAuthProvider=r.OAuthProvider,t.OperationType=r.OperationType,t.PhoneAuthCredential=r.PhoneAuthCredential,t.PhoneAuthProvider=r.PhoneAuthProvider,t.PhoneMultiFactorGenerator=r.PhoneMultiFactorGenerator,t.ProviderId=r.ProviderId,t.RecaptchaVerifier=r.RecaptchaVerifier,t.SAMLAuthProvider=r.SAMLAuthProvider,t.SignInMethod=r.SignInMethod,t.TotpMultiFactorGenerator=r.TotpMultiFactorGenerator,t.TotpSecret=r.TotpSecret,t.TwitterAuthProvider=r.TwitterAuthProvider,t.applyActionCode=r.applyActionCode,t.beforeAuthStateChanged=r.beforeAuthStateChanged,t.browserLocalPersistence=r.browserLocalPersistence,t.browserPopupRedirectResolver=r.browserPopupRedirectResolver,t.browserSessionPersistence=r.browserSessionPersistence,t.checkActionCode=r.checkActionCode,t.confirmPasswordReset=r.confirmPasswordReset,t.connectAuthEmulator=r.connectAuthEmulator,t.createUserWithEmailAndPassword=r.createUserWithEmailAndPassword,t.debugErrorMap=r.debugErrorMap,t.deleteUser=r.deleteUser,t.fetchSignInMethodsForEmail=r.fetchSignInMethodsForEmail,t.getAdditionalUserInfo=r.getAdditionalUserInfo,t.getAuth=r.getAuth,t.getIdToken=r.getIdToken,t.getIdTokenResult=r.getIdTokenResult,t.getMultiFactorResolver=r.getMultiFactorResolver,t.getRedirectResult=r.getRedirectResult,t.inMemoryPersistence=r.inMemoryPersistence,t.indexedDBLocalPersistence=r.indexedDBLocalPersistence,t.initializeAuth=r.initializeAuth,t.initializeRecaptchaConfig=r.initializeRecaptchaConfig,t.isSignInWithEmailLink=r.isSignInWithEmailLink,t.linkWithCredential=r.linkWithCredential,t.linkWithPhoneNumber=r.linkWithPhoneNumber,t.linkWithPopup=r.linkWithPopup,t.linkWithRedirect=r.linkWithRedirect,t.multiFactor=r.multiFactor,t.onAuthStateChanged=r.onAuthStateChanged,t.onIdTokenChanged=r.onIdTokenChanged,t.parseActionCodeURL=r.parseActionCodeURL,t.prodErrorMap=r.prodErrorMap,t.reauthenticateWithCredential=r.reauthenticateWithCredential,t.reauthenticateWithPhoneNumber=r.reauthenticateWithPhoneNumber,t.reauthenticateWithPopup=r.reauthenticateWithPopup,t.reauthenticateWithRedirect=r.reauthenticateWithRedirect,t.reload=r.reload,t.revokeAccessToken=r.revokeAccessToken,t.sendEmailVerification=r.sendEmailVerification,t.sendPasswordResetEmail=r.sendPasswordResetEmail,t.sendSignInLinkToEmail=r.sendSignInLinkToEmail,t.setPersistence=r.setPersistence,t.signInAnonymously=r.signInAnonymously,t.signInWithCredential=r.signInWithCredential,t.signInWithCustomToken=r.signInWithCustomToken,t.signInWithEmailAndPassword=r.signInWithEmailAndPassword,t.signInWithEmailLink=r.signInWithEmailLink,t.signInWithPhoneNumber=r.signInWithPhoneNumber,t.signInWithPopup=r.signInWithPopup,t.signInWithRedirect=r.signInWithRedirect,t.signOut=r.signOut,t.unlink=r.unlink,t.updateCurrentUser=r.updateCurrentUser,t.updateEmail=r.updateEmail,t.updatePassword=r.updatePassword,t.updatePhoneNumber=r.updatePhoneNumber,t.updateProfile=r.updateProfile,t.useDeviceLanguage=r.useDeviceLanguage,t.validatePassword=r.validatePassword,t.verifyBeforeUpdateEmail=r.verifyBeforeUpdateEmail,t.verifyPasswordResetCode=r.verifyPasswordResetCode},5319:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(1635),i=n(6336),s=function(){function e(e,t,n){this.name=e,this.instanceFactory=t,this.type=n,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}return e.prototype.setInstantiationMode=function(e){return this.instantiationMode=e,this},e.prototype.setMultipleInstances=function(e){return this.multipleInstances=e,this},e.prototype.setServiceProps=function(e){return this.serviceProps=e,this},e.prototype.setInstanceCreatedCallback=function(e){return this.onInstanceCreated=e,this},e}(),o="[DEFAULT]",a=function(){function e(e,t){this.name=e,this.container=t,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}return e.prototype.get=function(e){var t=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(t)){var n=new i.Deferred;if(this.instancesDeferred.set(t,n),this.isInitialized(t)||this.shouldAutoInitialize())try{var r=this.getOrInitializeService({instanceIdentifier:t});r&&n.resolve(r)}catch(e){}}return this.instancesDeferred.get(t).promise},e.prototype.getImmediate=function(e){var t,n=this.normalizeInstanceIdentifier(null==e?void 0:e.identifier),r=null!==(t=null==e?void 0:e.optional)&&void 0!==t&&t;if(!this.isInitialized(n)&&!this.shouldAutoInitialize()){if(r)return null;throw Error("Service ".concat(this.name," is not available"))}try{return this.getOrInitializeService({instanceIdentifier:n})}catch(e){if(r)return null;throw e}},e.prototype.getComponent=function(){return this.component},e.prototype.setComponent=function(e){var t,n;if(e.name!==this.name)throw Error("Mismatching Component ".concat(e.name," for Provider ").concat(this.name,"."));if(this.component)throw Error("Component for ".concat(this.name," has already been provided"));if(this.component=e,this.shouldAutoInitialize()){if(function(e){return"EAGER"===e.instantiationMode}(e))try{this.getOrInitializeService({instanceIdentifier:o})}catch(e){}try{for(var i=r.__values(this.instancesDeferred.entries()),s=i.next();!s.done;s=i.next()){var a=r.__read(s.value,2),c=a[0],u=a[1],l=this.normalizeInstanceIdentifier(c);try{var h=this.getOrInitializeService({instanceIdentifier:l});u.resolve(h)}catch(e){}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}}},e.prototype.clearInstance=function(e){void 0===e&&(e=o),this.instancesDeferred.delete(e),this.instancesOptions.delete(e),this.instances.delete(e)},e.prototype.delete=function(){return r.__awaiter(this,void 0,void 0,(function(){var e;return r.__generator(this,(function(t){switch(t.label){case 0:return e=Array.from(this.instances.values()),[4,Promise.all(r.__spreadArray(r.__spreadArray([],r.__read(e.filter((function(e){return"INTERNAL"in e})).map((function(e){return e.INTERNAL.delete()}))),!1),r.__read(e.filter((function(e){return"_delete"in e})).map((function(e){return e._delete()}))),!1))];case 1:return t.sent(),[2]}}))}))},e.prototype.isComponentSet=function(){return null!=this.component},e.prototype.isInitialized=function(e){return void 0===e&&(e=o),this.instances.has(e)},e.prototype.getOptions=function(e){return void 0===e&&(e=o),this.instancesOptions.get(e)||{}},e.prototype.initialize=function(e){var t,n;void 0===e&&(e={});var i=e.options,s=void 0===i?{}:i,o=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(o))throw Error("".concat(this.name,"(").concat(o,") has already been initialized"));if(!this.isComponentSet())throw Error("Component ".concat(this.name," has not been registered yet"));var a=this.getOrInitializeService({instanceIdentifier:o,options:s});try{for(var c=r.__values(this.instancesDeferred.entries()),u=c.next();!u.done;u=c.next()){var l=r.__read(u.value,2),h=l[0],d=l[1];o===this.normalizeInstanceIdentifier(h)&&d.resolve(a)}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=c.return)&&n.call(c)}finally{if(t)throw t.error}}return a},e.prototype.onInit=function(e,t){var n,r=this.normalizeInstanceIdentifier(t),i=null!==(n=this.onInitCallbacks.get(r))&&void 0!==n?n:new Set;i.add(e),this.onInitCallbacks.set(r,i);var s=this.instances.get(r);return s&&e(s,r),function(){i.delete(e)}},e.prototype.invokeOnInitCallbacks=function(e,t){var n,i,s=this.onInitCallbacks.get(t);if(s)try{for(var o=r.__values(s),a=o.next();!a.done;a=o.next()){var c=a.value;try{c(e,t)}catch(e){}}}catch(e){n={error:e}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}},e.prototype.getOrInitializeService=function(e){var t,n=e.instanceIdentifier,r=e.options,i=void 0===r?{}:r,s=this.instances.get(n);if(!s&&this.component&&(s=this.component.instanceFactory(this.container,{instanceIdentifier:(t=n,t===o?void 0:t),options:i}),this.instances.set(n,s),this.instancesOptions.set(n,i),this.invokeOnInitCallbacks(s,n),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,n,s)}catch(e){}return s||null},e.prototype.normalizeInstanceIdentifier=function(e){return void 0===e&&(e=o),this.component?this.component.multipleInstances?e:o:e},e.prototype.shouldAutoInitialize=function(){return!!this.component&&"EXPLICIT"!==this.component.instantiationMode},e}(),c=function(){function e(e){this.name=e,this.providers=new Map}return e.prototype.addComponent=function(e){var t=this.getProvider(e.name);if(t.isComponentSet())throw new Error("Component ".concat(e.name," has already been registered with ").concat(this.name));t.setComponent(e)},e.prototype.addOrOverwriteComponent=function(e){this.getProvider(e.name).isComponentSet()&&this.providers.delete(e.name),this.addComponent(e)},e.prototype.getProvider=function(e){if(this.providers.has(e))return this.providers.get(e);var t=new a(e,this);return this.providers.set(e,t),t},e.prototype.getProviders=function(){return Array.from(this.providers.values())},e}();t.Component=s,t.ComponentContainer=c,t.Provider=a},1241:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(6199),i=n(5319),s=n(5844),o=n(6336),a=n(860),c=n(4832);const u="@firebase/firestore";class l{constructor(e){this.uid=e}isAuthenticated(){return null!=this.uid}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(e){return e.uid===this.uid}}l.UNAUTHENTICATED=new l(null),l.GOOGLE_CREDENTIALS=new l("google-credentials-uid"),l.FIRST_PARTY=new l("first-party-uid"),l.MOCK_USER=new l("mock-user");let h="10.13.2";const d=new s.Logger("@firebase/firestore");function f(){return d.logLevel}function p(e,...t){if(d.logLevel<=s.LogLevel.DEBUG){const n=t.map(y);d.debug(`Firestore (${h}): ${e}`,...n)}}function m(e,...t){if(d.logLevel<=s.LogLevel.ERROR){const n=t.map(y);d.error(`Firestore (${h}): ${e}`,...n)}}function g(e,...t){if(d.logLevel<=s.LogLevel.WARN){const n=t.map(y);d.warn(`Firestore (${h}): ${e}`,...n)}}function y(e){if("string"==typeof e)return e;try{return function(e){return JSON.stringify(e)}(e)}catch(t){return e}}function v(e="Unexpected state"){const t=`FIRESTORE (${h}) INTERNAL ASSERTION FAILED: `+e;throw m(t),new Error(t)}function b(e,t){e||v()}function w(e,t){return e}const _={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 I extends o.FirebaseError{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}class E{constructor(){this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}}class T{constructor(e,t){this.user=t,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class S{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable((()=>t(l.UNAUTHENTICATED)))}shutdown(){}}class C{constructor(e){this.token=e,this.changeListener=null}getToken(){return Promise.resolve(this.token)}invalidateToken(){}start(e,t){this.changeListener=t,e.enqueueRetryable((()=>t(this.token.user)))}shutdown(){this.changeListener=null}}class A{constructor(e){this.t=e,this.currentUser=l.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,t){let n=this.i;const r=e=>this.i!==n?(n=this.i,t(e)):Promise.resolve();let i=new E;this.o=()=>{this.i++,this.currentUser=this.u(),i.resolve(),i=new E,e.enqueueRetryable((()=>r(this.currentUser)))};const s=()=>{const t=i;e.enqueueRetryable((async()=>{await t.promise,await r(this.currentUser)}))},o=e=>{p("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=e,this.auth.addAuthTokenListener(this.o),s()};this.t.onInit((e=>o(e))),setTimeout((()=>{if(!this.auth){const e=this.t.getImmediate({optional:!0});e?o(e):(p("FirebaseAuthCredentialsProvider","Auth not yet detected"),i.resolve(),i=new E)}}),0),s()}getToken(){const e=this.i,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then((t=>this.i!==e?(p("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):t?(b("string"==typeof t.accessToken),new T(t.accessToken,this.currentUser)):null)):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.auth.removeAuthTokenListener(this.o)}u(){const e=this.auth&&this.auth.getUid();return b(null===e||"string"==typeof e),new l(e)}}class x{constructor(e,t,n){this.l=e,this.h=t,this.P=n,this.type="FirstParty",this.user=l.FIRST_PARTY,this.I=new Map}T(){return this.P?this.P():null}get headers(){this.I.set("X-Goog-AuthUser",this.l);const e=this.T();return e&&this.I.set("Authorization",e),this.h&&this.I.set("X-Goog-Iam-Authorization-Token",this.h),this.I}}class k{constructor(e,t,n){this.l=e,this.h=t,this.P=n}getToken(){return Promise.resolve(new x(this.l,this.h,this.P))}start(e,t){e.enqueueRetryable((()=>t(l.FIRST_PARTY)))}shutdown(){}invalidateToken(){}}class N{constructor(e){this.value=e,this.type="AppCheck",this.headers=new Map,e&&e.length>0&&this.headers.set("x-firebase-appcheck",this.value)}}class O{constructor(e){this.A=e,this.forceRefresh=!1,this.appCheck=null,this.R=null}start(e,t){const n=e=>{null!=e.error&&p("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${e.error.message}`);const n=e.token!==this.R;return this.R=e.token,p("FirebaseAppCheckTokenProvider",`Received ${n?"new":"existing"} token.`),n?t(e.token):Promise.resolve()};this.o=t=>{e.enqueueRetryable((()=>n(t)))};const r=e=>{p("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=e,this.appCheck.addTokenListener(this.o)};this.A.onInit((e=>r(e))),setTimeout((()=>{if(!this.appCheck){const e=this.A.getImmediate({optional:!0});e?r(e):p("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}}),0)}getToken(){const e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then((e=>e?(b("string"==typeof e.token),this.R=e.token,new N(e.token)):null)):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.appCheck.removeTokenListener(this.o)}}function D(e){const t="undefined"!=typeof self&&(self.crypto||self.msCrypto),n=new Uint8Array(e);if(t&&"function"==typeof t.getRandomValues)t.getRandomValues(n);else for(let t=0;t<e;t++)n[t]=Math.floor(256*Math.random());return n}class R{static newId(){const e=62*Math.floor(256/62);let t="";for(;t.length<20;){const n=D(40);for(let r=0;r<n.length;++r)t.length<20&&n[r]<e&&(t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(n[r]%62))}return t}}function P(e,t){return e<t?-1:e>t?1:0}function L(e,t,n){return e.length===t.length&&e.every(((e,r)=>n(e,t[r])))}function M(e){return e+"\0"}class F{constructor(e,t){if(this.seconds=e,this.nanoseconds=t,t<0)throw new I(_.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(t>=1e9)throw new I(_.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(e<-62135596800)throw new I(_.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e);if(e>=253402300800)throw new I(_.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e)}static now(){return F.fromMillis(Date.now())}static fromDate(e){return F.fromMillis(e.getTime())}static fromMillis(e){const t=Math.floor(e/1e3),n=Math.floor(1e6*(e-1e3*t));return new F(t,n)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/1e6}_compareTo(e){return this.seconds===e.seconds?P(this.nanoseconds,e.nanoseconds):P(this.seconds,e.seconds)}isEqual(e){return e.seconds===this.seconds&&e.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{seconds:this.seconds,nanoseconds:this.nanoseconds}}valueOf(){const e=this.seconds- -62135596800;return String(e).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}class V{constructor(e){this.timestamp=e}static fromTimestamp(e){return new V(e)}static min(){return new V(new F(0,0))}static max(){return new V(new F(253402300799,999999999))}compareTo(e){return this.timestamp._compareTo(e.timestamp)}isEqual(e){return this.timestamp.isEqual(e.timestamp)}toMicroseconds(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}toString(){return"SnapshotVersion("+this.timestamp.toString()+")"}toTimestamp(){return this.timestamp}}class U{constructor(e,t,n){void 0===t?t=0:t>e.length&&v(),void 0===n?n=e.length-t:n>e.length-t&&v(),this.segments=e,this.offset=t,this.len=n}get length(){return this.len}isEqual(e){return 0===U.comparator(this,e)}child(e){const t=this.segments.slice(this.offset,this.limit());return e instanceof U?e.forEach((e=>{t.push(e)})):t.push(e),this.construct(t)}limit(){return this.offset+this.length}popFirst(e){return e=void 0===e?1:e,this.construct(this.segments,this.offset+e,this.length-e)}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(e){return this.segments[this.offset+e]}isEmpty(){return 0===this.length}isPrefixOf(e){if(e.length<this.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}isImmediateParentOf(e){if(this.length+1!==e.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}forEach(e){for(let t=this.offset,n=this.limit();t<n;t++)e(this.segments[t])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(e,t){const n=Math.min(e.length,t.length);for(let r=0;r<n;r++){const n=e.get(r),i=t.get(r);if(n<i)return-1;if(n>i)return 1}return e.length<t.length?-1:e.length>t.length?1:0}}class j extends U{construct(e,t,n){return new j(e,t,n)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...e){const t=[];for(const n of e){if(n.indexOf("//")>=0)throw new I(_.INVALID_ARGUMENT,`Invalid segment (${n}). Paths must not contain // in them.`);t.push(...n.split("/").filter((e=>e.length>0)))}return new j(t)}static emptyPath(){return new j([])}}const B=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class q extends U{construct(e,t,n){return new q(e,t,n)}static isValidIdentifier(e){return B.test(e)}canonicalString(){return this.toArray().map((e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),q.isValidIdentifier(e)||(e="`"+e+"`"),e))).join(".")}toString(){return this.canonicalString()}isKeyField(){return 1===this.length&&"__name__"===this.get(0)}static keyField(){return new q(["__name__"])}static fromServerFormat(e){const t=[];let n="",r=0;const i=()=>{if(0===n.length)throw new I(_.INVALID_ARGUMENT,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);t.push(n),n=""};let s=!1;for(;r<e.length;){const t=e[r];if("\\"===t){if(r+1===e.length)throw new I(_.INVALID_ARGUMENT,"Path has trailing escape character: "+e);const t=e[r+1];if("\\"!==t&&"."!==t&&"`"!==t)throw new I(_.INVALID_ARGUMENT,"Path has invalid escape sequence: "+e);n+=t,r+=2}else"`"===t?(s=!s,r++):"."!==t||s?(n+=t,r++):(i(),r++)}if(i(),s)throw new I(_.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new q(t)}static emptyPath(){return new q([])}}class z{constructor(e){this.path=e}static fromPath(e){return new z(j.fromString(e))}static fromName(e){return new z(j.fromString(e).popFirst(5))}static empty(){return new z(j.emptyPath())}get collectionGroup(){return this.path.popLast().lastSegment()}hasCollectionId(e){return this.path.length>=2&&this.path.get(this.path.length-2)===e}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(e){return null!==e&&0===j.comparator(this.path,e.path)}toString(){return this.path.toString()}static comparator(e,t){return j.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new z(new j(e.slice()))}}class G{constructor(e,t,n,r){this.indexId=e,this.collectionGroup=t,this.fields=n,this.indexState=r}}function K(e){return e.fields.find((e=>2===e.kind))}function W(e){return e.fields.filter((e=>2!==e.kind))}function $(e,t){let n=P(e.collectionGroup,t.collectionGroup);if(0!==n)return n;for(let r=0;r<Math.min(e.fields.length,t.fields.length);++r)if(n=Q(e.fields[r],t.fields[r]),0!==n)return n;return P(e.fields.length,t.fields.length)}G.UNKNOWN_ID=-1;class H{constructor(e,t){this.fieldPath=e,this.kind=t}}function Q(e,t){const n=q.comparator(e.fieldPath,t.fieldPath);return 0!==n?n:P(e.kind,t.kind)}class J{constructor(e,t){this.sequenceNumber=e,this.offset=t}static empty(){return new J(0,Z.min())}}function Y(e,t){const n=e.toTimestamp().seconds,r=e.toTimestamp().nanoseconds+1,i=V.fromTimestamp(1e9===r?new F(n+1,0):new F(n,r));return new Z(i,z.empty(),t)}function X(e){return new Z(e.readTime,e.key,-1)}class Z{constructor(e,t,n){this.readTime=e,this.documentKey=t,this.largestBatchId=n}static min(){return new Z(V.min(),z.empty(),-1)}static max(){return new Z(V.max(),z.empty(),-1)}}function ee(e,t){let n=e.readTime.compareTo(t.readTime);return 0!==n?n:(n=z.comparator(e.documentKey,t.documentKey),0!==n?n:P(e.largestBatchId,t.largestBatchId))}const te="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class ne{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach((e=>e()))}}async function re(e){if(e.code!==_.FAILED_PRECONDITION||e.message!==te)throw e;p("LocalStore","Unexpectedly lost primary lease")}class ie{constructor(e){this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,e((e=>{this.isDone=!0,this.result=e,this.nextCallback&&this.nextCallback(e)}),(e=>{this.isDone=!0,this.error=e,this.catchCallback&&this.catchCallback(e)}))}catch(e){return this.next(void 0,e)}next(e,t){return this.callbackAttached&&v(),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(t,this.error):this.wrapSuccess(e,this.result):new ie(((n,r)=>{this.nextCallback=t=>{this.wrapSuccess(e,t).next(n,r)},this.catchCallback=e=>{this.wrapFailure(t,e).next(n,r)}}))}toPromise(){return new Promise(((e,t)=>{this.next(e,t)}))}wrapUserFunction(e){try{const t=e();return t instanceof ie?t:ie.resolve(t)}catch(e){return ie.reject(e)}}wrapSuccess(e,t){return e?this.wrapUserFunction((()=>e(t))):ie.resolve(t)}wrapFailure(e,t){return e?this.wrapUserFunction((()=>e(t))):ie.reject(t)}static resolve(e){return new ie(((t,n)=>{t(e)}))}static reject(e){return new ie(((t,n)=>{n(e)}))}static waitFor(e){return new ie(((t,n)=>{let r=0,i=0,s=!1;e.forEach((e=>{++r,e.next((()=>{++i,s&&i===r&&t()}),(e=>n(e)))})),s=!0,i===r&&t()}))}static or(e){let t=ie.resolve(!1);for(const n of e)t=t.next((e=>e?ie.resolve(e):n()));return t}static forEach(e,t){const n=[];return e.forEach(((e,r)=>{n.push(t.call(this,e,r))})),this.waitFor(n)}static mapArray(e,t){return new ie(((n,r)=>{const i=e.length,s=new Array(i);let o=0;for(let a=0;a<i;a++){const c=a;t(e[c]).next((e=>{s[c]=e,++o,o===i&&n(s)}),(e=>r(e)))}}))}static doWhile(e,t){return new ie(((n,r)=>{const i=()=>{!0===e()?t().next((()=>{i()}),r):n()};i()}))}}class se{constructor(e,t){this.action=e,this.transaction=t,this.aborted=!1,this.V=new E,this.transaction.oncomplete=()=>{this.V.resolve()},this.transaction.onabort=()=>{t.error?this.V.reject(new ue(e,t.error)):this.V.resolve()},this.transaction.onerror=t=>{const n=pe(t.target.error);this.V.reject(new ue(e,n))}}static open(e,t,n,r){try{return new se(t,e.transaction(r,n))}catch(e){throw new ue(t,e)}}get m(){return this.V.promise}abort(e){e&&this.V.reject(e),this.aborted||(p("SimpleDb","Aborting transaction:",e?e.message:"Client-initiated abort"),this.aborted=!0,this.transaction.abort())}g(){const e=this.transaction;this.aborted||"function"!=typeof e.commit||e.commit()}store(e){const t=this.transaction.objectStore(e);return new he(t)}}class oe{constructor(e,t,n){this.name=e,this.version=t,this.p=n,12.2===oe.S(o.getUA())&&m("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(e){return p("SimpleDb","Removing database:",e),de(window.indexedDB.deleteDatabase(e)).toPromise()}static D(){if(!o.isIndexedDBAvailable())return!1;if(oe.v())return!0;const e=o.getUA(),t=oe.S(e),n=0<t&&t<10,r=ae(e),i=0<r&&r<4.5;return!(e.indexOf("MSIE ")>0||e.indexOf("Trident/")>0||e.indexOf("Edge/")>0||n||i)}static v(){var e;return"undefined"!=typeof process&&"YES"===(null===(e=process.__PRIVATE_env)||void 0===e?void 0:e.C)}static F(e,t){return e.store(t)}static S(e){const t=e.match(/i(?:phone|pad|pod) os ([\d_]+)/i),n=t?t[1].split("_").slice(0,2).join("."):"-1";return Number(n)}async M(e){return this.db||(p("SimpleDb","Opening database:",this.name),this.db=await new Promise(((t,n)=>{const r=indexedDB.open(this.name,this.version);r.onsuccess=e=>{const n=e.target.result;t(n)},r.onblocked=()=>{n(new ue(e,"Cannot upgrade IndexedDB schema while another tab is open. Close all tabs that access Firestore and reload this page to proceed."))},r.onerror=t=>{const r=t.target.error;"VersionError"===r.name?n(new I(_.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 I(_.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 ue(e,r))},r.onupgradeneeded=e=>{p("SimpleDb",'Database "'+this.name+'" requires upgrade from version:',e.oldVersion);const t=e.target.result;this.p.O(t,r.transaction,e.oldVersion,this.version).next((()=>{p("SimpleDb","Database upgrade to version "+this.version+" complete")}))}}))),this.N&&(this.db.onversionchange=e=>this.N(e)),this.db}L(e){this.N=e,this.db&&(this.db.onversionchange=t=>e(t))}async runTransaction(e,t,n,r){const i="readonly"===t;let s=0;for(;;){++s;try{this.db=await this.M(e);const t=se.open(this.db,e,i?"readonly":"readwrite",n),s=r(t).next((e=>(t.g(),e))).catch((e=>(t.abort(e),ie.reject(e)))).toPromise();return s.catch((()=>{})),await t.m,s}catch(e){const t=e,n="FirebaseError"!==t.name&&s<3;if(p("SimpleDb","Transaction failed with error:",t.message,"Retrying:",n),this.close(),!n)return Promise.reject(t)}}}close(){this.db&&this.db.close(),this.db=void 0}}function ae(e){const t=e.match(/Android ([\d.]+)/i),n=t?t[1].split(".").slice(0,2).join("."):"-1";return Number(n)}class ce{constructor(e){this.B=e,this.k=!1,this.q=null}get isDone(){return this.k}get K(){return this.q}set cursor(e){this.B=e}done(){this.k=!0}$(e){this.q=e}delete(){return de(this.B.delete())}}class ue extends I{constructor(e,t){super(_.UNAVAILABLE,`IndexedDB transaction '${e}' failed: ${t}`),this.name="IndexedDbTransactionError"}}function le(e){return"IndexedDbTransactionError"===e.name}class he{constructor(e){this.store=e}put(e,t){let n;return void 0!==t?(p("SimpleDb","PUT",this.store.name,e,t),n=this.store.put(t,e)):(p("SimpleDb","PUT",this.store.name,"<auto-key>",e),n=this.store.put(e)),de(n)}add(e){return p("SimpleDb","ADD",this.store.name,e,e),de(this.store.add(e))}get(e){return de(this.store.get(e)).next((t=>(void 0===t&&(t=null),p("SimpleDb","GET",this.store.name,e,t),t)))}delete(e){return p("SimpleDb","DELETE",this.store.name,e),de(this.store.delete(e))}count(){return p("SimpleDb","COUNT",this.store.name),de(this.store.count())}U(e,t){const n=this.options(e,t),r=n.index?this.store.index(n.index):this.store;if("function"==typeof r.getAll){const e=r.getAll(n.range);return new ie(((t,n)=>{e.onerror=e=>{n(e.target.error)},e.onsuccess=e=>{t(e.target.result)}}))}{const e=this.cursor(n),t=[];return this.W(e,((e,n)=>{t.push(n)})).next((()=>t))}}G(e,t){const n=this.store.getAll(e,null===t?void 0:t);return new ie(((e,t)=>{n.onerror=e=>{t(e.target.error)},n.onsuccess=t=>{e(t.target.result)}}))}j(e,t){p("SimpleDb","DELETE ALL",this.store.name);const n=this.options(e,t);n.H=!1;const r=this.cursor(n);return this.W(r,((e,t,n)=>n.delete()))}J(e,t){let n;t?n=e:(n={},t=e);const r=this.cursor(n);return this.W(r,t)}Y(e){const t=this.cursor({});return new ie(((n,r)=>{t.onerror=e=>{const t=pe(e.target.error);r(t)},t.onsuccess=t=>{const r=t.target.result;r?e(r.primaryKey,r.value).next((e=>{e?r.continue():n()})):n()}}))}W(e,t){const n=[];return new ie(((r,i)=>{e.onerror=e=>{i(e.target.error)},e.onsuccess=e=>{const i=e.target.result;if(!i)return void r();const s=new ce(i),o=t(i.primaryKey,i.value,s);if(o instanceof ie){const e=o.catch((e=>(s.done(),ie.reject(e))));n.push(e)}s.isDone?r():null===s.K?i.continue():i.continue(s.K)}})).next((()=>ie.waitFor(n)))}options(e,t){let n;return void 0!==e&&("string"==typeof e?n=e:t=e),{index:n,range:t}}cursor(e){let t="next";if(e.reverse&&(t="prev"),e.index){const n=this.store.index(e.index);return e.H?n.openKeyCursor(e.range,t):n.openCursor(e.range,t)}return this.store.openCursor(e.range,t)}}function de(e){return new ie(((t,n)=>{e.onsuccess=e=>{const n=e.target.result;t(n)},e.onerror=e=>{const t=pe(e.target.error);n(t)}}))}let fe=!1;function pe(e){const t=oe.S(o.getUA());if(t>=12.2&&t<13){const t="An internal error was encountered in the Indexed Database server";if(e.message.indexOf(t)>=0){const e=new I("internal",`IOS_INDEXEDDB_BUG1: IndexedDb has thrown '${t}'. This is likely due to an unavoidable bug in iOS. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.`);return fe||(fe=!0,setTimeout((()=>{throw e}),0)),e}}return e}class me{constructor(e,t){this.asyncQueue=e,this.Z=t,this.task=null}start(){this.X(15e3)}stop(){this.task&&(this.task.cancel(),this.task=null)}get started(){return null!==this.task}X(e){p("IndexBackfiller",`Scheduled in ${e}ms`),this.task=this.asyncQueue.enqueueAfterDelay("index_backfill",e,(async()=>{this.task=null;try{p("IndexBackfiller",`Documents written: ${await this.Z.ee()}`)}catch(e){le(e)?p("IndexBackfiller","Ignoring IndexedDB error during index backfill: ",e):await re(e)}await this.X(6e4)}))}}class ge{constructor(e,t){this.localStore=e,this.persistence=t}async ee(e=50){return this.persistence.runTransaction("Backfill Indexes","readwrite-primary",(t=>this.te(t,e)))}te(e,t){const n=new Set;let r=t,i=!0;return ie.doWhile((()=>!0===i&&r>0),(()=>this.localStore.indexManager.getNextCollectionGroupToUpdate(e).next((t=>{if(null!==t&&!n.has(t))return p("IndexBackfiller",`Processing collection: ${t}`),this.ne(e,t,r).next((e=>{r-=e,n.add(t)}));i=!1})))).next((()=>t-r))}ne(e,t,n){return this.localStore.indexManager.getMinOffsetFromCollectionGroup(e,t).next((r=>this.localStore.localDocuments.getNextDocuments(e,t,r,n).next((n=>{const i=n.changes;return this.localStore.indexManager.updateIndexEntries(e,i).next((()=>this.re(r,n))).next((n=>(p("IndexBackfiller",`Updating offset: ${n}`),this.localStore.indexManager.updateCollectionGroup(e,t,n)))).next((()=>i.size))}))))}re(e,t){let n=e;return t.changes.forEach(((e,t)=>{const r=X(t);ee(r,n)>0&&(n=r)})),new Z(n.readTime,n.documentKey,Math.max(t.batchId,e.largestBatchId))}}class ye{constructor(e,t){this.previousValue=e,t&&(t.sequenceNumberHandler=e=>this.ie(e),this.se=e=>t.writeSequenceNumber(e))}ie(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}next(){const e=++this.previousValue;return this.se&&this.se(e),e}}function ve(e){return null==e}function be(e){return 0===e&&1/e==-1/0}function we(e){return"number"==typeof e&&Number.isInteger(e)&&!be(e)&&e<=Number.MAX_SAFE_INTEGER&&e>=Number.MIN_SAFE_INTEGER}function _e(e){let t="";for(let n=0;n<e.length;n++)t.length>0&&(t=Ee(t)),t=Ie(e.get(n),t);return Ee(t)}function Ie(e,t){let n=t;const r=e.length;for(let t=0;t<r;t++){const r=e.charAt(t);switch(r){case"\0":n+="";break;case"":n+="";break;default:n+=r}}return n}function Ee(e){return e+""}function Te(e){const t=e.length;if(b(t>=2),2===t)return b(""===e.charAt(0)&&""===e.charAt(1)),j.emptyPath();const n=t-2,r=[];let i="";for(let s=0;s<t;){const t=e.indexOf("",s);switch((t<0||t>n)&&v(),e.charAt(t+1)){case"":const n=e.substring(s,t);let o;0===i.length?o=n:(i+=n,o=i,i=""),r.push(o);break;case"":i+=e.substring(s,t),i+="\0";break;case"":i+=e.substring(s,t+1);break;default:v()}s=t+2}return new j(r)}ye.oe=-1;const Se=["userId","batchId"];function Ce(e,t){return[e,_e(t)]}function Ae(e,t,n){return[e,_e(t),n]}const xe={},ke=["prefixPath","collectionGroup","readTime","documentId"],Ne=["prefixPath","collectionGroup","documentId"],Oe=["collectionGroup","readTime","prefixPath","documentId"],De=["canonicalId","targetId"],Re=["targetId","path"],Pe=["path","targetId"],Le=["collectionId","parent"],Me=["indexId","uid"],Fe=["uid","sequenceNumber"],Ve=["indexId","uid","arrayValue","directionalValue","orderedDocumentKey","documentKey"],Ue=["indexId","uid","orderedDocumentKey"],je=["userId","collectionPath","documentId"],Be=["userId","collectionPath","largestBatchId"],qe=["userId","collectionGroup","largestBatchId"],ze=["mutationQueues","mutations","documentMutations","remoteDocuments","targets","owner","targetGlobal","targetDocuments","clientMetadata","remoteDocumentGlobal","collectionParents","bundles","namedQueries"],Ge=[...ze,"documentOverlays"],Ke=["mutationQueues","mutations","documentMutations","remoteDocumentsV14","targets","owner","targetGlobal","targetDocuments","clientMetadata","remoteDocumentGlobal","collectionParents","bundles","namedQueries","documentOverlays"],We=Ke,$e=[...We,"indexConfiguration","indexState","indexEntries"],He=$e,Qe=[...$e,"globals"];class Je extends ne{constructor(e,t){super(),this._e=e,this.currentSequenceNumber=t}}function Ye(e,t){const n=w(e);return oe.F(n._e,t)}function Xe(e){let t=0;for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}function Ze(e,t){for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t(n,e[n])}function et(e,t){const n=[];for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.push(t(e[r],r,e));return n}function tt(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}class nt{constructor(e,t){this.comparator=e,this.root=t||it.EMPTY}insert(e,t){return new nt(this.comparator,this.root.insert(e,t,this.comparator).copy(null,null,it.BLACK,null,null))}remove(e){return new nt(this.comparator,this.root.remove(e,this.comparator).copy(null,null,it.BLACK,null,null))}get(e){let t=this.root;for(;!t.isEmpty();){const n=this.comparator(e,t.key);if(0===n)return t.value;n<0?t=t.left:n>0&&(t=t.right)}return null}indexOf(e){let t=0,n=this.root;for(;!n.isEmpty();){const r=this.comparator(e,n.key);if(0===r)return t+n.left.size;r<0?n=n.left:(t+=n.left.size+1,n=n.right)}return-1}isEmpty(){return this.root.isEmpty()}get size(){return this.root.size}minKey(){return this.root.minKey()}maxKey(){return this.root.maxKey()}inorderTraversal(e){return this.root.inorderTraversal(e)}forEach(e){this.inorderTraversal(((t,n)=>(e(t,n),!1)))}toString(){const e=[];return this.inorderTraversal(((t,n)=>(e.push(`${t}:${n}`),!1))),`{${e.join(", ")}}`}reverseTraversal(e){return this.root.reverseTraversal(e)}getIterator(){return new rt(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new rt(this.root,e,this.comparator,!1)}getReverseIterator(){return new rt(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new rt(this.root,e,this.comparator,!0)}}class rt{constructor(e,t,n,r){this.isReverse=r,this.nodeStack=[];let i=1;for(;!e.isEmpty();)if(i=t?n(e.key,t):1,t&&r&&(i*=-1),i<0)e=this.isReverse?e.left:e.right;else{if(0===i){this.nodeStack.push(e);break}this.nodeStack.push(e),e=this.isReverse?e.right:e.left}}getNext(){let e=this.nodeStack.pop();const t={key:e.key,value:e.value};if(this.isReverse)for(e=e.left;!e.isEmpty();)this.nodeStack.push(e),e=e.right;else for(e=e.right;!e.isEmpty();)this.nodeStack.push(e),e=e.left;return t}hasNext(){return this.nodeStack.length>0}peek(){if(0===this.nodeStack.length)return null;const e=this.nodeStack[this.nodeStack.length-1];return{key:e.key,value:e.value}}}class it{constructor(e,t,n,r,i){this.key=e,this.value=t,this.color=null!=n?n:it.RED,this.left=null!=r?r:it.EMPTY,this.right=null!=i?i:it.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,t,n,r,i){return new it(null!=e?e:this.key,null!=t?t:this.value,null!=n?n:this.color,null!=r?r:this.left,null!=i?i:this.right)}isEmpty(){return!1}inorderTraversal(e){return this.left.inorderTraversal(e)||e(this.key,this.value)||this.right.inorderTraversal(e)}reverseTraversal(e){return this.right.reverseTraversal(e)||e(this.key,this.value)||this.left.reverseTraversal(e)}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(e,t,n){let r=this;const i=n(e,r.key);return r=i<0?r.copy(null,null,null,r.left.insert(e,t,n),null):0===i?r.copy(null,t,null,null,null):r.copy(null,null,null,null,r.right.insert(e,t,n)),r.fixUp()}removeMin(){if(this.left.isEmpty())return it.EMPTY;let e=this;return e.left.isRed()||e.left.left.isRed()||(e=e.moveRedLeft()),e=e.copy(null,null,null,e.left.removeMin(),null),e.fixUp()}remove(e,t){let n,r=this;if(t(e,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(e,t),null);else{if(r.left.isRed()&&(r=r.rotateRight()),r.right.isEmpty()||r.right.isRed()||r.right.left.isRed()||(r=r.moveRedRight()),0===t(e,r.key)){if(r.right.isEmpty())return it.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(e,t))}return r.fixUp()}isRed(){return this.color}fixUp(){let e=this;return e.right.isRed()&&!e.left.isRed()&&(e=e.rotateLeft()),e.left.isRed()&&e.left.left.isRed()&&(e=e.rotateRight()),e.left.isRed()&&e.right.isRed()&&(e=e.colorFlip()),e}moveRedLeft(){let e=this.colorFlip();return e.right.left.isRed()&&(e=e.copy(null,null,null,null,e.right.rotateRight()),e=e.rotateLeft(),e=e.colorFlip()),e}moveRedRight(){let e=this.colorFlip();return e.left.left.isRed()&&(e=e.rotateRight(),e=e.colorFlip()),e}rotateLeft(){const e=this.copy(null,null,it.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){const e=this.copy(null,null,it.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip(){const e=this.left.copy(null,null,!this.left.color,null,null),t=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,t)}checkMaxDepth(){const e=this.check();return Math.pow(2,e)<=this.size+1}check(){if(this.isRed()&&this.left.isRed())throw v();if(this.right.isRed())throw v();const e=this.left.check();if(e!==this.right.check())throw v();return e+(this.isRed()?0:1)}}it.EMPTY=null,it.RED=!0,it.BLACK=!1,it.EMPTY=new class{constructor(){this.size=0}get key(){throw v()}get value(){throw v()}get color(){throw v()}get left(){throw v()}get right(){throw v()}copy(e,t,n,r,i){return this}insert(e,t,n){return new it(e,t)}remove(e,t){return this}isEmpty(){return!0}inorderTraversal(e){return!1}reverseTraversal(e){return!1}minKey(){return null}maxKey(){return null}isRed(){return!1}checkMaxDepth(){return!0}check(){return 0}};class st{constructor(e){this.comparator=e,this.data=new nt(this.comparator)}has(e){return null!==this.data.get(e)}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(e){return this.data.indexOf(e)}forEach(e){this.data.inorderTraversal(((t,n)=>(e(t),!1)))}forEachInRange(e,t){const n=this.data.getIteratorFrom(e[0]);for(;n.hasNext();){const r=n.getNext();if(this.comparator(r.key,e[1])>=0)return;t(r.key)}}forEachWhile(e,t){let n;for(n=void 0!==t?this.data.getIteratorFrom(t):this.data.getIterator();n.hasNext();)if(!e(n.getNext().key))return}firstAfterOrEqual(e){const t=this.data.getIteratorFrom(e);return t.hasNext()?t.getNext().key:null}getIterator(){return new ot(this.data.getIterator())}getIteratorFrom(e){return new ot(this.data.getIteratorFrom(e))}add(e){return this.copy(this.data.remove(e).insert(e,!0))}delete(e){return this.has(e)?this.copy(this.data.remove(e)):this}isEmpty(){return this.data.isEmpty()}unionWith(e){let t=this;return t.size<e.size&&(t=e,e=this),e.forEach((e=>{t=t.add(e)})),t}isEqual(e){if(!(e instanceof st))return!1;if(this.size!==e.size)return!1;const t=this.data.getIterator(),n=e.data.getIterator();for(;t.hasNext();){const e=t.getNext().key,r=n.getNext().key;if(0!==this.comparator(e,r))return!1}return!0}toArray(){const e=[];return this.forEach((t=>{e.push(t)})),e}toString(){const e=[];return this.forEach((t=>e.push(t))),"SortedSet("+e.toString()+")"}copy(e){const t=new st(this.comparator);return t.data=e,t}}class ot{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}function at(e){return e.hasNext()?e.getNext():void 0}class ct{constructor(e){this.fields=e,e.sort(q.comparator)}static empty(){return new ct([])}unionWith(e){let t=new st(q.comparator);for(const e of this.fields)t=t.add(e);for(const n of e)t=t.add(n);return new ct(t.toArray())}covers(e){for(const t of this.fields)if(t.isPrefixOf(e))return!0;return!1}isEqual(e){return L(this.fields,e.fields,((e,t)=>e.isEqual(t)))}}class ut extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}class lt{constructor(e){this.binaryString=e}static fromBase64String(e){const t=function(e){try{return atob(e)}catch(e){throw"undefined"!=typeof DOMException&&e instanceof DOMException?new ut("Invalid base64 string: "+e):e}}(e);return new lt(t)}static fromUint8Array(e){const t=function(e){let t="";for(let n=0;n<e.length;++n)t+=String.fromCharCode(e[n]);return t}(e);return new lt(t)}[Symbol.iterator](){let e=0;return{next:()=>e<this.binaryString.length?{value:this.binaryString.charCodeAt(e++),done:!1}:{value:void 0,done:!0}}}toBase64(){return e=this.binaryString,btoa(e);var e}toUint8Array(){return function(e){const t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(e){return P(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}}lt.EMPTY_BYTE_STRING=new lt("");const ht=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function dt(e){if(b(!!e),"string"==typeof e){let t=0;const n=ht.exec(e);if(b(!!n),n[1]){let e=n[1];e=(e+"000000000").substr(0,9),t=Number(e)}const r=new Date(e);return{seconds:Math.floor(r.getTime()/1e3),nanos:t}}return{seconds:ft(e.seconds),nanos:ft(e.nanos)}}function ft(e){return"number"==typeof e?e:"string"==typeof e?Number(e):0}function pt(e){return"string"==typeof e?lt.fromBase64String(e):lt.fromUint8Array(e)}function mt(e){var t,n;return"server_timestamp"===(null===(n=((null===(t=null==e?void 0:e.mapValue)||void 0===t?void 0:t.fields)||{}).__type__)||void 0===n?void 0:n.stringValue)}function gt(e){const t=e.mapValue.fields.__previous_value__;return mt(t)?gt(t):t}function yt(e){const t=dt(e.mapValue.fields.__local_write_time__.timestampValue);return new F(t.seconds,t.nanos)}class vt{constructor(e,t,n,r,i,s,o,a,c){this.databaseId=e,this.appId=t,this.persistenceKey=n,this.host=r,this.ssl=i,this.forceLongPolling=s,this.autoDetectLongPolling=o,this.longPollingOptions=a,this.useFetchStreams=c}}class bt{constructor(e,t){this.projectId=e,this.database=t||"(default)"}static empty(){return new bt("","")}get isDefaultDatabase(){return"(default)"===this.database}isEqual(e){return e instanceof bt&&e.projectId===this.projectId&&e.database===this.database}}const wt={mapValue:{fields:{__type__:{stringValue:"__max__"}}}},_t={nullValue:"NULL_VALUE"};function It(e){return"nullValue"in e?0:"booleanValue"in e?1:"integerValue"in e||"doubleValue"in e?2:"timestampValue"in e?3:"stringValue"in e?5:"bytesValue"in e?6:"referenceValue"in e?7:"geoPointValue"in e?8:"arrayValue"in e?9:"mapValue"in e?mt(e)?4:Ut(e)?9007199254740991:Ft(e)?10:11:v()}function Et(e,t){if(e===t)return!0;const n=It(e);if(n!==It(t))return!1;switch(n){case 0:case 9007199254740991:return!0;case 1:return e.booleanValue===t.booleanValue;case 4:return yt(e).isEqual(yt(t));case 3:return function(e,t){if("string"==typeof e.timestampValue&&"string"==typeof t.timestampValue&&e.timestampValue.length===t.timestampValue.length)return e.timestampValue===t.timestampValue;const n=dt(e.timestampValue),r=dt(t.timestampValue);return n.seconds===r.seconds&&n.nanos===r.nanos}(e,t);case 5:return e.stringValue===t.stringValue;case 6:return function(e,t){return pt(e.bytesValue).isEqual(pt(t.bytesValue))}(e,t);case 7:return e.referenceValue===t.referenceValue;case 8:return function(e,t){return ft(e.geoPointValue.latitude)===ft(t.geoPointValue.latitude)&&ft(e.geoPointValue.longitude)===ft(t.geoPointValue.longitude)}(e,t);case 2:return function(e,t){if("integerValue"in e&&"integerValue"in t)return ft(e.integerValue)===ft(t.integerValue);if("doubleValue"in e&&"doubleValue"in t){const n=ft(e.doubleValue),r=ft(t.doubleValue);return n===r?be(n)===be(r):isNaN(n)&&isNaN(r)}return!1}(e,t);case 9:return L(e.arrayValue.values||[],t.arrayValue.values||[],Et);case 10:case 11:return function(e,t){const n=e.mapValue.fields||{},r=t.mapValue.fields||{};if(Xe(n)!==Xe(r))return!1;for(const e in n)if(n.hasOwnProperty(e)&&(void 0===r[e]||!Et(n[e],r[e])))return!1;return!0}(e,t);default:return v()}}function Tt(e,t){return void 0!==(e.values||[]).find((e=>Et(e,t)))}function St(e,t){if(e===t)return 0;const n=It(e),r=It(t);if(n!==r)return P(n,r);switch(n){case 0:case 9007199254740991:return 0;case 1:return P(e.booleanValue,t.booleanValue);case 2:return function(e,t){const n=ft(e.integerValue||e.doubleValue),r=ft(t.integerValue||t.doubleValue);return n<r?-1:n>r?1:n===r?0:isNaN(n)?isNaN(r)?0:-1:1}(e,t);case 3:return Ct(e.timestampValue,t.timestampValue);case 4:return Ct(yt(e),yt(t));case 5:return P(e.stringValue,t.stringValue);case 6:return function(e,t){const n=pt(e),r=pt(t);return n.compareTo(r)}(e.bytesValue,t.bytesValue);case 7:return function(e,t){const n=e.split("/"),r=t.split("/");for(let e=0;e<n.length&&e<r.length;e++){const t=P(n[e],r[e]);if(0!==t)return t}return P(n.length,r.length)}(e.referenceValue,t.referenceValue);case 8:return function(e,t){const n=P(ft(e.latitude),ft(t.latitude));return 0!==n?n:P(ft(e.longitude),ft(t.longitude))}(e.geoPointValue,t.geoPointValue);case 9:return At(e.arrayValue,t.arrayValue);case 10:return function(e,t){var n,r,i,s;const o=e.fields||{},a=t.fields||{},c=null===(n=o.value)||void 0===n?void 0:n.arrayValue,u=null===(r=a.value)||void 0===r?void 0:r.arrayValue,l=P((null===(i=null==c?void 0:c.values)||void 0===i?void 0:i.length)||0,(null===(s=null==u?void 0:u.values)||void 0===s?void 0:s.length)||0);return 0!==l?l:At(c,u)}(e.mapValue,t.mapValue);case 11:return function(e,t){if(e===wt.mapValue&&t===wt.mapValue)return 0;if(e===wt.mapValue)return 1;if(t===wt.mapValue)return-1;const n=e.fields||{},r=Object.keys(n),i=t.fields||{},s=Object.keys(i);r.sort(),s.sort();for(let e=0;e<r.length&&e<s.length;++e){const t=P(r[e],s[e]);if(0!==t)return t;const o=St(n[r[e]],i[s[e]]);if(0!==o)return o}return P(r.length,s.length)}(e.mapValue,t.mapValue);default:throw v()}}function Ct(e,t){if("string"==typeof e&&"string"==typeof t&&e.length===t.length)return P(e,t);const n=dt(e),r=dt(t),i=P(n.seconds,r.seconds);return 0!==i?i:P(n.nanos,r.nanos)}function At(e,t){const n=e.values||[],r=t.values||[];for(let e=0;e<n.length&&e<r.length;++e){const t=St(n[e],r[e]);if(t)return t}return P(n.length,r.length)}function xt(e){return kt(e)}function kt(e){return"nullValue"in e?"null":"booleanValue"in e?""+e.booleanValue:"integerValue"in e?""+e.integerValue:"doubleValue"in e?""+e.doubleValue:"timestampValue"in e?function(e){const t=dt(e);return`time(${t.seconds},${t.nanos})`}(e.timestampValue):"stringValue"in e?e.stringValue:"bytesValue"in e?function(e){return pt(e).toBase64()}(e.bytesValue):"referenceValue"in e?function(e){return z.fromName(e).toString()}(e.referenceValue):"geoPointValue"in e?function(e){return`geo(${e.latitude},${e.longitude})`}(e.geoPointValue):"arrayValue"in e?function(e){let t="[",n=!0;for(const r of e.values||[])n?n=!1:t+=",",t+=kt(r);return t+"]"}(e.arrayValue):"mapValue"in e?function(e){const t=Object.keys(e.fields||{}).sort();let n="{",r=!0;for(const i of t)r?r=!1:n+=",",n+=`${i}:${kt(e.fields[i])}`;return n+"}"}(e.mapValue):v()}function Nt(e){switch(It(e)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:const t=gt(e);return t?16+Nt(t):16;case 5:return 2*e.stringValue.length;case 6:return pt(e.bytesValue).approximateByteSize();case 7:return e.referenceValue.length;case 9:return function(e){return(e.values||[]).reduce(((e,t)=>e+Nt(t)),0)}(e.arrayValue);case 10:case 11:return function(e){let t=0;return Ze(e.fields,((e,n)=>{t+=e.length+Nt(n)})),t}(e.mapValue);default:throw v()}}function Ot(e,t){return{referenceValue:`projects/${e.projectId}/databases/${e.database}/documents/${t.path.canonicalString()}`}}function Dt(e){return!!e&&"integerValue"in e}function Rt(e){return!!e&&"arrayValue"in e}function Pt(e){return!!e&&"nullValue"in e}function Lt(e){return!!e&&"doubleValue"in e&&isNaN(Number(e.doubleValue))}function Mt(e){return!!e&&"mapValue"in e}function Ft(e){var t,n;return"__vector__"===(null===(n=((null===(t=null==e?void 0:e.mapValue)||void 0===t?void 0:t.fields)||{}).__type__)||void 0===n?void 0:n.stringValue)}function Vt(e){if(e.geoPointValue)return{geoPointValue:Object.assign({},e.geoPointValue)};if(e.timestampValue&&"object"==typeof e.timestampValue)return{timestampValue:Object.assign({},e.timestampValue)};if(e.mapValue){const t={mapValue:{fields:{}}};return Ze(e.mapValue.fields,((e,n)=>t.mapValue.fields[e]=Vt(n))),t}if(e.arrayValue){const t={arrayValue:{values:[]}};for(let n=0;n<(e.arrayValue.values||[]).length;++n)t.arrayValue.values[n]=Vt(e.arrayValue.values[n]);return t}return Object.assign({},e)}function Ut(e){return"__max__"===(((e.mapValue||{}).fields||{}).__type__||{}).stringValue}const jt={mapValue:{fields:{__type__:{stringValue:"__vector__"},value:{arrayValue:{}}}}};function Bt(e){return"nullValue"in e?_t:"booleanValue"in e?{booleanValue:!1}:"integerValue"in e||"doubleValue"in e?{doubleValue:NaN}:"timestampValue"in e?{timestampValue:{seconds:Number.MIN_SAFE_INTEGER}}:"stringValue"in e?{stringValue:""}:"bytesValue"in e?{bytesValue:""}:"referenceValue"in e?Ot(bt.empty(),z.empty()):"geoPointValue"in e?{geoPointValue:{latitude:-90,longitude:-180}}:"arrayValue"in e?{arrayValue:{}}:"mapValue"in e?Ft(e)?jt:{mapValue:{}}:v()}function qt(e){return"nullValue"in e?{booleanValue:!1}:"booleanValue"in e?{doubleValue:NaN}:"integerValue"in e||"doubleValue"in e?{timestampValue:{seconds:Number.MIN_SAFE_INTEGER}}:"timestampValue"in e?{stringValue:""}:"stringValue"in e?{bytesValue:""}:"bytesValue"in e?Ot(bt.empty(),z.empty()):"referenceValue"in e?{geoPointValue:{latitude:-90,longitude:-180}}:"geoPointValue"in e?{arrayValue:{}}:"arrayValue"in e?jt:"mapValue"in e?Ft(e)?{mapValue:{}}:wt:v()}function zt(e,t){const n=St(e.value,t.value);return 0!==n?n:e.inclusive&&!t.inclusive?-1:!e.inclusive&&t.inclusive?1:0}function Gt(e,t){const n=St(e.value,t.value);return 0!==n?n:e.inclusive&&!t.inclusive?1:!e.inclusive&&t.inclusive?-1:0}class Kt{constructor(e){this.value=e}static empty(){return new Kt({mapValue:{}})}field(e){if(e.isEmpty())return this.value;{let t=this.value;for(let n=0;n<e.length-1;++n)if(t=(t.mapValue.fields||{})[e.get(n)],!Mt(t))return null;return t=(t.mapValue.fields||{})[e.lastSegment()],t||null}}set(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=Vt(t)}setAll(e){let t=q.emptyPath(),n={},r=[];e.forEach(((e,i)=>{if(!t.isImmediateParentOf(i)){const e=this.getFieldsMap(t);this.applyChanges(e,n,r),n={},r=[],t=i.popLast()}e?n[i.lastSegment()]=Vt(e):r.push(i.lastSegment())}));const i=this.getFieldsMap(t);this.applyChanges(i,n,r)}delete(e){const t=this.field(e.popLast());Mt(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return Et(this.value,e.value)}getFieldsMap(e){let t=this.value;t.mapValue.fields||(t.mapValue={fields:{}});for(let n=0;n<e.length;++n){let r=t.mapValue.fields[e.get(n)];Mt(r)&&r.mapValue.fields||(r={mapValue:{fields:{}}},t.mapValue.fields[e.get(n)]=r),t=r}return t.mapValue.fields}applyChanges(e,t,n){Ze(t,((t,n)=>e[t]=n));for(const t of n)delete e[t]}clone(){return new Kt(Vt(this.value))}}function Wt(e){const t=[];return Ze(e.fields,((e,n)=>{const r=new q([e]);if(Mt(n)){const e=Wt(n.mapValue).fields;if(0===e.length)t.push(r);else for(const n of e)t.push(r.child(n))}else t.push(r)})),new ct(t)}class $t{constructor(e,t,n,r,i,s,o){this.key=e,this.documentType=t,this.version=n,this.readTime=r,this.createTime=i,this.data=s,this.documentState=o}static newInvalidDocument(e){return new $t(e,0,V.min(),V.min(),V.min(),Kt.empty(),0)}static newFoundDocument(e,t,n,r){return new $t(e,1,t,V.min(),n,r,0)}static newNoDocument(e,t){return new $t(e,2,t,V.min(),V.min(),Kt.empty(),0)}static newUnknownDocument(e,t){return new $t(e,3,t,V.min(),V.min(),Kt.empty(),2)}convertToFoundDocument(e,t){return!this.createTime.isEqual(V.min())||2!==this.documentType&&0!==this.documentType||(this.createTime=e),this.version=e,this.documentType=1,this.data=t,this.documentState=0,this}convertToNoDocument(e){return this.version=e,this.documentType=2,this.data=Kt.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=Kt.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=V.min(),this}setReadTime(e){return this.readTime=e,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(e){return e instanceof $t&&this.key.isEqual(e.key)&&this.version.isEqual(e.version)&&this.documentType===e.documentType&&this.documentState===e.documentState&&this.data.isEqual(e.data)}mutableCopy(){return new $t(this.key,this.documentType,this.version,this.readTime,this.createTime,this.data.clone(),this.documentState)}toString(){return`Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {createTime: ${this.createTime}}), {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`}}class Ht{constructor(e,t){this.position=e,this.inclusive=t}}function Qt(e,t,n){let r=0;for(let i=0;i<e.position.length;i++){const s=t[i],o=e.position[i];if(r=s.field.isKeyField()?z.comparator(z.fromName(o.referenceValue),n.key):St(o,n.data.field(s.field)),"desc"===s.dir&&(r*=-1),0!==r)break}return r}function Jt(e,t){if(null===e)return null===t;if(null===t)return!1;if(e.inclusive!==t.inclusive||e.position.length!==t.position.length)return!1;for(let n=0;n<e.position.length;n++)if(!Et(e.position[n],t.position[n]))return!1;return!0}class Yt{constructor(e,t="asc"){this.field=e,this.dir=t}}function Xt(e,t){return e.dir===t.dir&&e.field.isEqual(t.field)}class Zt{}class en extends Zt{constructor(e,t,n){super(),this.field=e,this.op=t,this.value=n}static create(e,t,n){return e.isKeyField()?"in"===t||"not-in"===t?this.createKeyFieldInFilter(e,t,n):new hn(e,t,n):"array-contains"===t?new mn(e,n):"in"===t?new gn(e,n):"not-in"===t?new yn(e,n):"array-contains-any"===t?new vn(e,n):new en(e,t,n)}static createKeyFieldInFilter(e,t,n){return"in"===t?new dn(e,n):new fn(e,n)}matches(e){const t=e.data.field(this.field);return"!="===this.op?null!==t&&this.matchesComparison(St(t,this.value)):null!==t&&It(this.value)===It(t)&&this.matchesComparison(St(t,this.value))}matchesComparison(e){switch(this.op){case"<":return e<0;case"<=":return e<=0;case"==":return 0===e;case"!=":return 0!==e;case">":return e>0;case">=":return e>=0;default:return v()}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class tn extends Zt{constructor(e,t){super(),this.filters=e,this.op=t,this.ae=null}static create(e,t){return new tn(e,t)}matches(e){return nn(this)?void 0===this.filters.find((t=>!t.matches(e))):void 0!==this.filters.find((t=>t.matches(e)))}getFlattenedFilters(){return null!==this.ae||(this.ae=this.filters.reduce(((e,t)=>e.concat(t.getFlattenedFilters())),[])),this.ae}getFilters(){return Object.assign([],this.filters)}}function nn(e){return"and"===e.op}function rn(e){return"or"===e.op}function sn(e){return on(e)&&nn(e)}function on(e){for(const t of e.filters)if(t instanceof tn)return!1;return!0}function an(e){if(e instanceof en)return e.field.canonicalString()+e.op.toString()+xt(e.value);if(sn(e))return e.filters.map((e=>an(e))).join(",");{const t=e.filters.map((e=>an(e))).join(",");return`${e.op}(${t})`}}function cn(e,t){return e instanceof en?function(e,t){return t instanceof en&&e.op===t.op&&e.field.isEqual(t.field)&&Et(e.value,t.value)}(e,t):e instanceof tn?function(e,t){return t instanceof tn&&e.op===t.op&&e.filters.length===t.filters.length&&e.filters.reduce(((e,n,r)=>e&&cn(n,t.filters[r])),!0)}(e,t):void v()}function un(e,t){const n=e.filters.concat(t);return tn.create(n,e.op)}function ln(e){return e instanceof en?function(e){return`${e.field.canonicalString()} ${e.op} ${xt(e.value)}`}(e):e instanceof tn?function(e){return e.op.toString()+" {"+e.getFilters().map(ln).join(" ,")+"}"}(e):"Filter"}class hn extends en{constructor(e,t,n){super(e,t,n),this.key=z.fromName(n.referenceValue)}matches(e){const t=z.comparator(e.key,this.key);return this.matchesComparison(t)}}class dn extends en{constructor(e,t){super(e,"in",t),this.keys=pn(0,t)}matches(e){return this.keys.some((t=>t.isEqual(e.key)))}}class fn extends en{constructor(e,t){super(e,"not-in",t),this.keys=pn(0,t)}matches(e){return!this.keys.some((t=>t.isEqual(e.key)))}}function pn(e,t){var n;return((null===(n=t.arrayValue)||void 0===n?void 0:n.values)||[]).map((e=>z.fromName(e.referenceValue)))}class mn extends en{constructor(e,t){super(e,"array-contains",t)}matches(e){const t=e.data.field(this.field);return Rt(t)&&Tt(t.arrayValue,this.value)}}class gn extends en{constructor(e,t){super(e,"in",t)}matches(e){const t=e.data.field(this.field);return null!==t&&Tt(this.value.arrayValue,t)}}class yn extends en{constructor(e,t){super(e,"not-in",t)}matches(e){if(Tt(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const t=e.data.field(this.field);return null!==t&&!Tt(this.value.arrayValue,t)}}class vn extends en{constructor(e,t){super(e,"array-contains-any",t)}matches(e){const t=e.data.field(this.field);return!(!Rt(t)||!t.arrayValue.values)&&t.arrayValue.values.some((e=>Tt(this.value.arrayValue,e)))}}class bn{constructor(e,t=null,n=[],r=[],i=null,s=null,o=null){this.path=e,this.collectionGroup=t,this.orderBy=n,this.filters=r,this.limit=i,this.startAt=s,this.endAt=o,this.ue=null}}function wn(e,t=null,n=[],r=[],i=null,s=null,o=null){return new bn(e,t,n,r,i,s,o)}function _n(e){const t=w(e);if(null===t.ue){let e=t.path.canonicalString();null!==t.collectionGroup&&(e+="|cg:"+t.collectionGroup),e+="|f:",e+=t.filters.map((e=>an(e))).join(","),e+="|ob:",e+=t.orderBy.map((e=>function(e){return e.field.canonicalString()+e.dir}(e))).join(","),ve(t.limit)||(e+="|l:",e+=t.limit),t.startAt&&(e+="|lb:",e+=t.startAt.inclusive?"b:":"a:",e+=t.startAt.position.map((e=>xt(e))).join(",")),t.endAt&&(e+="|ub:",e+=t.endAt.inclusive?"a:":"b:",e+=t.endAt.position.map((e=>xt(e))).join(",")),t.ue=e}return t.ue}function In(e,t){if(e.limit!==t.limit)return!1;if(e.orderBy.length!==t.orderBy.length)return!1;for(let n=0;n<e.orderBy.length;n++)if(!Xt(e.orderBy[n],t.orderBy[n]))return!1;if(e.filters.length!==t.filters.length)return!1;for(let n=0;n<e.filters.length;n++)if(!cn(e.filters[n],t.filters[n]))return!1;return e.collectionGroup===t.collectionGroup&&!!e.path.isEqual(t.path)&&!!Jt(e.startAt,t.startAt)&&Jt(e.endAt,t.endAt)}function En(e){return z.isDocumentKey(e.path)&&null===e.collectionGroup&&0===e.filters.length}function Tn(e,t){return e.filters.filter((e=>e instanceof en&&e.field.isEqual(t)))}function Sn(e,t,n){let r=_t,i=!0;for(const n of Tn(e,t)){let e=_t,t=!0;switch(n.op){case"<":case"<=":e=Bt(n.value);break;case"==":case"in":case">=":e=n.value;break;case">":e=n.value,t=!1;break;case"!=":case"not-in":e=_t}zt({value:r,inclusive:i},{value:e,inclusive:t})<0&&(r=e,i=t)}if(null!==n)for(let s=0;s<e.orderBy.length;++s)if(e.orderBy[s].field.isEqual(t)){const e=n.position[s];zt({value:r,inclusive:i},{value:e,inclusive:n.inclusive})<0&&(r=e,i=n.inclusive);break}return{value:r,inclusive:i}}function Cn(e,t,n){let r=wt,i=!0;for(const n of Tn(e,t)){let e=wt,t=!0;switch(n.op){case">=":case">":e=qt(n.value),t=!1;break;case"==":case"in":case"<=":e=n.value;break;case"<":e=n.value,t=!1;break;case"!=":case"not-in":e=wt}Gt({value:r,inclusive:i},{value:e,inclusive:t})>0&&(r=e,i=t)}if(null!==n)for(let s=0;s<e.orderBy.length;++s)if(e.orderBy[s].field.isEqual(t)){const e=n.position[s];Gt({value:r,inclusive:i},{value:e,inclusive:n.inclusive})>0&&(r=e,i=n.inclusive);break}return{value:r,inclusive:i}}class An{constructor(e,t=null,n=[],r=[],i=null,s="F",o=null,a=null){this.path=e,this.collectionGroup=t,this.explicitOrderBy=n,this.filters=r,this.limit=i,this.limitType=s,this.startAt=o,this.endAt=a,this.ce=null,this.le=null,this.he=null,this.startAt,this.endAt}}function xn(e,t,n,r,i,s,o,a){return new An(e,t,n,r,i,s,o,a)}function kn(e){return new An(e)}function Nn(e){return 0===e.filters.length&&null===e.limit&&null==e.startAt&&null==e.endAt&&(0===e.explicitOrderBy.length||1===e.explicitOrderBy.length&&e.explicitOrderBy[0].field.isKeyField())}function On(e){return null!==e.collectionGroup}function Dn(e){const t=w(e);if(null===t.ce){t.ce=[];const e=new Set;for(const n of t.explicitOrderBy)t.ce.push(n),e.add(n.field.canonicalString());const n=t.explicitOrderBy.length>0?t.explicitOrderBy[t.explicitOrderBy.length-1].dir:"asc",r=function(e){let t=new st(q.comparator);return e.filters.forEach((e=>{e.getFlattenedFilters().forEach((e=>{e.isInequality()&&(t=t.add(e.field))}))})),t}(t);r.forEach((r=>{e.has(r.canonicalString())||r.isKeyField()||t.ce.push(new Yt(r,n))})),e.has(q.keyField().canonicalString())||t.ce.push(new Yt(q.keyField(),n))}return t.ce}function Rn(e){const t=w(e);return t.le||(t.le=Ln(t,Dn(e))),t.le}function Pn(e){const t=w(e);return t.he||(t.he=Ln(t,e.explicitOrderBy)),t.he}function Ln(e,t){if("F"===e.limitType)return wn(e.path,e.collectionGroup,t,e.filters,e.limit,e.startAt,e.endAt);{t=t.map((e=>{const t="desc"===e.dir?"asc":"desc";return new Yt(e.field,t)}));const n=e.endAt?new Ht(e.endAt.position,e.endAt.inclusive):null,r=e.startAt?new Ht(e.startAt.position,e.startAt.inclusive):null;return wn(e.path,e.collectionGroup,t,e.filters,e.limit,n,r)}}function Mn(e,t){const n=e.filters.concat([t]);return new An(e.path,e.collectionGroup,e.explicitOrderBy.slice(),n,e.limit,e.limitType,e.startAt,e.endAt)}function Fn(e,t,n){return new An(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),t,n,e.startAt,e.endAt)}function Vn(e,t){return In(Rn(e),Rn(t))&&e.limitType===t.limitType}function Un(e){return`${_n(Rn(e))}|lt:${e.limitType}`}function jn(e){return`Query(target=${function(e){let t=e.path.canonicalString();return null!==e.collectionGroup&&(t+=" collectionGroup="+e.collectionGroup),e.filters.length>0&&(t+=`, filters: [${e.filters.map((e=>ln(e))).join(", ")}]`),ve(e.limit)||(t+=", limit: "+e.limit),e.orderBy.length>0&&(t+=`, orderBy: [${e.orderBy.map((e=>function(e){return`${e.field.canonicalString()} (${e.dir})`}(e))).join(", ")}]`),e.startAt&&(t+=", startAt: ",t+=e.startAt.inclusive?"b:":"a:",t+=e.startAt.position.map((e=>xt(e))).join(",")),e.endAt&&(t+=", endAt: ",t+=e.endAt.inclusive?"a:":"b:",t+=e.endAt.position.map((e=>xt(e))).join(",")),`Target(${t})`}(Rn(e))}; limitType=${e.limitType})`}function Bn(e,t){return t.isFoundDocument()&&function(e,t){const n=t.key.path;return null!==e.collectionGroup?t.key.hasCollectionId(e.collectionGroup)&&e.path.isPrefixOf(n):z.isDocumentKey(e.path)?e.path.isEqual(n):e.path.isImmediateParentOf(n)}(e,t)&&function(e,t){for(const n of Dn(e))if(!n.field.isKeyField()&&null===t.data.field(n.field))return!1;return!0}(e,t)&&function(e,t){for(const n of e.filters)if(!n.matches(t))return!1;return!0}(e,t)&&function(e,t){return!(e.startAt&&!function(e,t,n){const r=Qt(e,t,n);return e.inclusive?r<=0:r<0}(e.startAt,Dn(e),t)||e.endAt&&!function(e,t,n){const r=Qt(e,t,n);return e.inclusive?r>=0:r>0}(e.endAt,Dn(e),t))}(e,t)}function qn(e){return e.collectionGroup||(e.path.length%2==1?e.path.lastSegment():e.path.get(e.path.length-2))}function zn(e){return(t,n)=>{let r=!1;for(const i of Dn(e)){const e=Gn(i,t,n);if(0!==e)return e;r=r||i.field.isKeyField()}return 0}}function Gn(e,t,n){const r=e.field.isKeyField()?z.comparator(t.key,n.key):function(e,t,n){const r=t.data.field(e),i=n.data.field(e);return null!==r&&null!==i?St(r,i):v()}(e.field,t,n);switch(e.dir){case"asc":return r;case"desc":return-1*r;default:return v()}}class Kn{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.innerSize=0}get(e){const t=this.mapKeyFn(e),n=this.inner[t];if(void 0!==n)for(const[t,r]of n)if(this.equalsFn(t,e))return r}has(e){return void 0!==this.get(e)}set(e,t){const n=this.mapKeyFn(e),r=this.inner[n];if(void 0===r)return this.inner[n]=[[e,t]],void this.innerSize++;for(let n=0;n<r.length;n++)if(this.equalsFn(r[n][0],e))return void(r[n]=[e,t]);r.push([e,t]),this.innerSize++}delete(e){const t=this.mapKeyFn(e),n=this.inner[t];if(void 0===n)return!1;for(let r=0;r<n.length;r++)if(this.equalsFn(n[r][0],e))return 1===n.length?delete this.inner[t]:n.splice(r,1),this.innerSize--,!0;return!1}forEach(e){Ze(this.inner,((t,n)=>{for(const[t,r]of n)e(t,r)}))}isEmpty(){return tt(this.inner)}size(){return this.innerSize}}const Wn=new nt(z.comparator);function $n(){return Wn}const Hn=new nt(z.comparator);function Qn(...e){let t=Hn;for(const n of e)t=t.insert(n.key,n);return t}function Jn(e){let t=Hn;return e.forEach(((e,n)=>t=t.insert(e,n.overlayedDocument))),t}function Yn(){return Zn()}function Xn(){return Zn()}function Zn(){return new Kn((e=>e.toString()),((e,t)=>e.isEqual(t)))}const er=new nt(z.comparator),tr=new st(z.comparator);function nr(...e){let t=tr;for(const n of e)t=t.add(n);return t}const rr=new st(P);function ir(){return rr}function sr(e,t){if(e.useProto3Json){if(isNaN(t))return{doubleValue:"NaN"};if(t===1/0)return{doubleValue:"Infinity"};if(t===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:be(t)?"-0":t}}function or(e){return{integerValue:""+e}}function ar(e,t){return we(t)?or(t):sr(e,t)}class cr{constructor(){this._=void 0}}function ur(e,t,n){return e instanceof dr?function(e,t){const n={fields:{__type__:{stringValue:"server_timestamp"},__local_write_time__:{timestampValue:{seconds:e.seconds,nanos:e.nanoseconds}}}};return t&&mt(t)&&(t=gt(t)),t&&(n.fields.__previous_value__=t),{mapValue:n}}(n,t):e instanceof fr?pr(e,t):e instanceof mr?gr(e,t):function(e,t){const n=hr(e,t),r=vr(n)+vr(e.Pe);return Dt(n)&&Dt(e.Pe)?or(r):sr(e.serializer,r)}(e,t)}function lr(e,t,n){return e instanceof fr?pr(e,t):e instanceof mr?gr(e,t):n}function hr(e,t){return e instanceof yr?function(e){return Dt(e)||function(e){return!!e&&"doubleValue"in e}(e)}(t)?t:{integerValue:0}:null}class dr extends cr{}class fr extends cr{constructor(e){super(),this.elements=e}}function pr(e,t){const n=br(t);for(const t of e.elements)n.some((e=>Et(e,t)))||n.push(t);return{arrayValue:{values:n}}}class mr extends cr{constructor(e){super(),this.elements=e}}function gr(e,t){let n=br(t);for(const t of e.elements)n=n.filter((e=>!Et(e,t)));return{arrayValue:{values:n}}}class yr extends cr{constructor(e,t){super(),this.serializer=e,this.Pe=t}}function vr(e){return ft(e.integerValue||e.doubleValue)}function br(e){return Rt(e)&&e.arrayValue.values?e.arrayValue.values.slice():[]}class wr{constructor(e,t){this.field=e,this.transform=t}}class _r{constructor(e,t){this.version=e,this.transformResults=t}}class Ir{constructor(e,t){this.updateTime=e,this.exists=t}static none(){return new Ir}static exists(e){return new Ir(void 0,e)}static updateTime(e){return new Ir(e)}get isNone(){return void 0===this.updateTime&&void 0===this.exists}isEqual(e){return this.exists===e.exists&&(this.updateTime?!!e.updateTime&&this.updateTime.isEqual(e.updateTime):!e.updateTime)}}function Er(e,t){return void 0!==e.updateTime?t.isFoundDocument()&&t.version.isEqual(e.updateTime):void 0===e.exists||e.exists===t.isFoundDocument()}class Tr{}function Sr(e,t){if(!e.hasLocalMutations||t&&0===t.fields.length)return null;if(null===t)return e.isNoDocument()?new Lr(e.key,Ir.none()):new Nr(e.key,e.data,Ir.none());{const n=e.data,r=Kt.empty();let i=new st(q.comparator);for(let e of t.fields)if(!i.has(e)){let t=n.field(e);null===t&&e.length>1&&(e=e.popLast(),t=n.field(e)),null===t?r.delete(e):r.set(e,t),i=i.add(e)}return new Or(e.key,r,new ct(i.toArray()),Ir.none())}}function Cr(e,t,n){e instanceof Nr?function(e,t,n){const r=e.value.clone(),i=Rr(e.fieldTransforms,t,n.transformResults);r.setAll(i),t.convertToFoundDocument(n.version,r).setHasCommittedMutations()}(e,t,n):e instanceof Or?function(e,t,n){if(!Er(e.precondition,t))return void t.convertToUnknownDocument(n.version);const r=Rr(e.fieldTransforms,t,n.transformResults),i=t.data;i.setAll(Dr(e)),i.setAll(r),t.convertToFoundDocument(n.version,i).setHasCommittedMutations()}(e,t,n):function(e,t,n){t.convertToNoDocument(n.version).setHasCommittedMutations()}(0,t,n)}function Ar(e,t,n,r){return e instanceof Nr?function(e,t,n,r){if(!Er(e.precondition,t))return n;const i=e.value.clone(),s=Pr(e.fieldTransforms,r,t);return i.setAll(s),t.convertToFoundDocument(t.version,i).setHasLocalMutations(),null}(e,t,n,r):e instanceof Or?function(e,t,n,r){if(!Er(e.precondition,t))return n;const i=Pr(e.fieldTransforms,r,t),s=t.data;return s.setAll(Dr(e)),s.setAll(i),t.convertToFoundDocument(t.version,s).setHasLocalMutations(),null===n?null:n.unionWith(e.fieldMask.fields).unionWith(e.fieldTransforms.map((e=>e.field)))}(e,t,n,r):function(e,t,n){return Er(e.precondition,t)?(t.convertToNoDocument(t.version).setHasLocalMutations(),null):n}(e,t,n)}function xr(e,t){let n=null;for(const r of e.fieldTransforms){const e=t.data.field(r.field),i=hr(r.transform,e||null);null!=i&&(null===n&&(n=Kt.empty()),n.set(r.field,i))}return n||null}function kr(e,t){return e.type===t.type&&!!e.key.isEqual(t.key)&&!!e.precondition.isEqual(t.precondition)&&!!function(e,t){return void 0===e&&void 0===t||!(!e||!t)&&L(e,t,((e,t)=>function(e,t){return e.field.isEqual(t.field)&&function(e,t){return e instanceof fr&&t instanceof fr||e instanceof mr&&t instanceof mr?L(e.elements,t.elements,Et):e instanceof yr&&t instanceof yr?Et(e.Pe,t.Pe):e instanceof dr&&t instanceof dr}(e.transform,t.transform)}(e,t)))}(e.fieldTransforms,t.fieldTransforms)&&(0===e.type?e.value.isEqual(t.value):1!==e.type||e.data.isEqual(t.data)&&e.fieldMask.isEqual(t.fieldMask))}class Nr extends Tr{constructor(e,t,n,r=[]){super(),this.key=e,this.value=t,this.precondition=n,this.fieldTransforms=r,this.type=0}getFieldMask(){return null}}class Or extends Tr{constructor(e,t,n,r,i=[]){super(),this.key=e,this.data=t,this.fieldMask=n,this.precondition=r,this.fieldTransforms=i,this.type=1}getFieldMask(){return this.fieldMask}}function Dr(e){const t=new Map;return e.fieldMask.fields.forEach((n=>{if(!n.isEmpty()){const r=e.data.field(n);t.set(n,r)}})),t}function Rr(e,t,n){const r=new Map;b(e.length===n.length);for(let i=0;i<n.length;i++){const s=e[i],o=s.transform,a=t.data.field(s.field);r.set(s.field,lr(o,a,n[i]))}return r}function Pr(e,t,n){const r=new Map;for(const i of e){const e=i.transform,s=n.data.field(i.field);r.set(i.field,ur(e,s,t))}return r}class Lr extends Tr{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}class Mr extends Tr{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}}class Fr{constructor(e,t,n,r){this.batchId=e,this.localWriteTime=t,this.baseMutations=n,this.mutations=r}applyToRemoteDocument(e,t){const n=t.mutationResults;for(let t=0;t<this.mutations.length;t++){const r=this.mutations[t];r.key.isEqual(e.key)&&Cr(r,e,n[t])}}applyToLocalView(e,t){for(const n of this.baseMutations)n.key.isEqual(e.key)&&(t=Ar(n,e,t,this.localWriteTime));for(const n of this.mutations)n.key.isEqual(e.key)&&(t=Ar(n,e,t,this.localWriteTime));return t}applyToLocalDocumentSet(e,t){const n=Xn();return this.mutations.forEach((r=>{const i=e.get(r.key),s=i.overlayedDocument;let o=this.applyToLocalView(s,i.mutatedFields);o=t.has(r.key)?null:o;const a=Sr(s,o);null!==a&&n.set(r.key,a),s.isValidDocument()||s.convertToNoDocument(V.min())})),n}keys(){return this.mutations.reduce(((e,t)=>e.add(t.key)),nr())}isEqual(e){return this.batchId===e.batchId&&L(this.mutations,e.mutations,((e,t)=>kr(e,t)))&&L(this.baseMutations,e.baseMutations,((e,t)=>kr(e,t)))}}class Vr{constructor(e,t,n,r){this.batch=e,this.commitVersion=t,this.mutationResults=n,this.docVersions=r}static from(e,t,n){b(e.mutations.length===n.length);let r=er;const i=e.mutations;for(let e=0;e<i.length;e++)r=r.insert(i[e].key,n[e].version);return new Vr(e,t,n,r)}}class Ur{constructor(e,t){this.largestBatchId=e,this.mutation=t}getKey(){return this.mutation.key}isEqual(e){return null!==e&&this.mutation===e.mutation}toString(){return`Overlay{\n largestBatchId: ${this.largestBatchId},\n mutation: ${this.mutation.toString()}\n }`}}class jr{constructor(e,t,n){this.alias=e,this.aggregateType=t,this.fieldPath=n}}class Br{constructor(e,t){this.count=e,this.unchangedNames=t}}var qr,zr;function Gr(e){switch(e){default:return v();case _.CANCELLED:case _.UNKNOWN:case _.DEADLINE_EXCEEDED:case _.RESOURCE_EXHAUSTED:case _.INTERNAL:case _.UNAVAILABLE:case _.UNAUTHENTICATED:return!1;case _.INVALID_ARGUMENT:case _.NOT_FOUND:case _.ALREADY_EXISTS:case _.PERMISSION_DENIED:case _.FAILED_PRECONDITION:case _.ABORTED:case _.OUT_OF_RANGE:case _.UNIMPLEMENTED:case _.DATA_LOSS:return!0}}function Kr(e){if(void 0===e)return m("GRPC error has no .code"),_.UNKNOWN;switch(e){case qr.OK:return _.OK;case qr.CANCELLED:return _.CANCELLED;case qr.UNKNOWN:return _.UNKNOWN;case qr.DEADLINE_EXCEEDED:return _.DEADLINE_EXCEEDED;case qr.RESOURCE_EXHAUSTED:return _.RESOURCE_EXHAUSTED;case qr.INTERNAL:return _.INTERNAL;case qr.UNAVAILABLE:return _.UNAVAILABLE;case qr.UNAUTHENTICATED:return _.UNAUTHENTICATED;case qr.INVALID_ARGUMENT:return _.INVALID_ARGUMENT;case qr.NOT_FOUND:return _.NOT_FOUND;case qr.ALREADY_EXISTS:return _.ALREADY_EXISTS;case qr.PERMISSION_DENIED:return _.PERMISSION_DENIED;case qr.FAILED_PRECONDITION:return _.FAILED_PRECONDITION;case qr.ABORTED:return _.ABORTED;case qr.OUT_OF_RANGE:return _.OUT_OF_RANGE;case qr.UNIMPLEMENTED:return _.UNIMPLEMENTED;case qr.DATA_LOSS:return _.DATA_LOSS;default:return v()}}(zr=qr||(qr={}))[zr.OK=0]="OK",zr[zr.CANCELLED=1]="CANCELLED",zr[zr.UNKNOWN=2]="UNKNOWN",zr[zr.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",zr[zr.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",zr[zr.NOT_FOUND=5]="NOT_FOUND",zr[zr.ALREADY_EXISTS=6]="ALREADY_EXISTS",zr[zr.PERMISSION_DENIED=7]="PERMISSION_DENIED",zr[zr.UNAUTHENTICATED=16]="UNAUTHENTICATED",zr[zr.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",zr[zr.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",zr[zr.ABORTED=10]="ABORTED",zr[zr.OUT_OF_RANGE=11]="OUT_OF_RANGE",zr[zr.UNIMPLEMENTED=12]="UNIMPLEMENTED",zr[zr.INTERNAL=13]="INTERNAL",zr[zr.UNAVAILABLE=14]="UNAVAILABLE",zr[zr.DATA_LOSS=15]="DATA_LOSS";let Wr=null;function $r(){return new TextEncoder}const Hr=new a.Integer([4294967295,4294967295],0);function Qr(e){const t=$r().encode(e),n=new a.Md5;return n.update(t),new Uint8Array(n.digest())}function Jr(e){const t=new DataView(e.buffer),n=t.getUint32(0,!0),r=t.getUint32(4,!0),i=t.getUint32(8,!0),s=t.getUint32(12,!0);return[new a.Integer([n,r],0),new a.Integer([i,s],0)]}class Yr{constructor(e,t,n){if(this.bitmap=e,this.padding=t,this.hashCount=n,t<0||t>=8)throw new Xr(`Invalid padding: ${t}`);if(n<0)throw new Xr(`Invalid hash count: ${n}`);if(e.length>0&&0===this.hashCount)throw new Xr(`Invalid hash count: ${n}`);if(0===e.length&&0!==t)throw new Xr(`Invalid padding when bitmap length is 0: ${t}`);this.Ie=8*e.length-t,this.Te=a.Integer.fromNumber(this.Ie)}Ee(e,t,n){let r=e.add(t.multiply(a.Integer.fromNumber(n)));return 1===r.compare(Hr)&&(r=new a.Integer([r.getBits(0),r.getBits(1)],0)),r.modulo(this.Te).toNumber()}de(e){return!!(this.bitmap[Math.floor(e/8)]&1<<e%8)}mightContain(e){if(0===this.Ie)return!1;const t=Qr(e),[n,r]=Jr(t);for(let e=0;e<this.hashCount;e++){const t=this.Ee(n,r,e);if(!this.de(t))return!1}return!0}static create(e,t,n){const r=e%8==0?0:8-e%8,i=new Uint8Array(Math.ceil(e/8)),s=new Yr(i,r,t);return n.forEach((e=>s.insert(e))),s}insert(e){if(0===this.Ie)return;const t=Qr(e),[n,r]=Jr(t);for(let e=0;e<this.hashCount;e++){const t=this.Ee(n,r,e);this.Ae(t)}}Ae(e){const t=Math.floor(e/8),n=e%8;this.bitmap[t]|=1<<n}}class Xr extends Error{constructor(){super(...arguments),this.name="BloomFilterError"}}class Zr{constructor(e,t,n,r,i){this.snapshotVersion=e,this.targetChanges=t,this.targetMismatches=n,this.documentUpdates=r,this.resolvedLimboDocuments=i}static createSynthesizedRemoteEventForCurrentChange(e,t,n){const r=new Map;return r.set(e,ei.createSynthesizedTargetChangeForCurrentChange(e,t,n)),new Zr(V.min(),r,new nt(P),$n(),nr())}}class ei{constructor(e,t,n,r,i){this.resumeToken=e,this.current=t,this.addedDocuments=n,this.modifiedDocuments=r,this.removedDocuments=i}static createSynthesizedTargetChangeForCurrentChange(e,t,n){return new ei(n,t,nr(),nr(),nr())}}class ti{constructor(e,t,n,r){this.Re=e,this.removedTargetIds=t,this.key=n,this.Ve=r}}class ni{constructor(e,t){this.targetId=e,this.me=t}}class ri{constructor(e,t,n=lt.EMPTY_BYTE_STRING,r=null){this.state=e,this.targetIds=t,this.resumeToken=n,this.cause=r}}class ii{constructor(){this.fe=0,this.ge=ai(),this.pe=lt.EMPTY_BYTE_STRING,this.ye=!1,this.we=!0}get current(){return this.ye}get resumeToken(){return this.pe}get Se(){return 0!==this.fe}get be(){return this.we}De(e){e.approximateByteSize()>0&&(this.we=!0,this.pe=e)}ve(){let e=nr(),t=nr(),n=nr();return this.ge.forEach(((r,i)=>{switch(i){case 0:e=e.add(r);break;case 2:t=t.add(r);break;case 1:n=n.add(r);break;default:v()}})),new ei(this.pe,this.ye,e,t,n)}Ce(){this.we=!1,this.ge=ai()}Fe(e,t){this.we=!0,this.ge=this.ge.insert(e,t)}Me(e){this.we=!0,this.ge=this.ge.remove(e)}xe(){this.fe+=1}Oe(){this.fe-=1,b(this.fe>=0)}Ne(){this.we=!0,this.ye=!0}}class si{constructor(e){this.Le=e,this.Be=new Map,this.ke=$n(),this.qe=oi(),this.Qe=new nt(P)}Ke(e){for(const t of e.Re)e.Ve&&e.Ve.isFoundDocument()?this.$e(t,e.Ve):this.Ue(t,e.key,e.Ve);for(const t of e.removedTargetIds)this.Ue(t,e.key,e.Ve)}We(e){this.forEachTarget(e,(t=>{const n=this.Ge(t);switch(e.state){case 0:this.ze(t)&&n.De(e.resumeToken);break;case 1:n.Oe(),n.Se||n.Ce(),n.De(e.resumeToken);break;case 2:n.Oe(),n.Se||this.removeTarget(t);break;case 3:this.ze(t)&&(n.Ne(),n.De(e.resumeToken));break;case 4:this.ze(t)&&(this.je(t),n.De(e.resumeToken));break;default:v()}}))}forEachTarget(e,t){e.targetIds.length>0?e.targetIds.forEach(t):this.Be.forEach(((e,n)=>{this.ze(n)&&t(n)}))}He(e){const t=e.targetId,n=e.me.count,r=this.Je(t);if(r){const i=r.target;if(En(i))if(0===n){const e=new z(i.path);this.Ue(t,e,$t.newNoDocument(e,V.min()))}else b(1===n);else{const r=this.Ye(t);if(r!==n){const n=this.Ze(e),i=n?this.Xe(n,e,r):1;if(0!==i){this.je(t);const e=2===i?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch";this.Qe=this.Qe.insert(t,e)}null==Wr||Wr.et(function(e,t,n,r,i){var s,o,a,c,u,l;const h={localCacheCount:e,existenceFilterCount:t.count,databaseId:n.database,projectId:n.projectId},d=t.unchangedNames;return d&&(h.bloomFilter={applied:0===i,hashCount:null!==(s=null==d?void 0:d.hashCount)&&void 0!==s?s:0,bitmapLength:null!==(c=null===(a=null===(o=null==d?void 0:d.bits)||void 0===o?void 0:o.bitmap)||void 0===a?void 0:a.length)&&void 0!==c?c:0,padding:null!==(l=null===(u=null==d?void 0:d.bits)||void 0===u?void 0:u.padding)&&void 0!==l?l:0,mightContain:e=>{var t;return null!==(t=null==r?void 0:r.mightContain(e))&&void 0!==t&&t}}),h}(r,e.me,this.Le.tt(),n,i))}}}}Ze(e){const t=e.me.unchangedNames;if(!t||!t.bits)return null;const{bits:{bitmap:n="",padding:r=0},hashCount:i=0}=t;let s,o;try{s=pt(n).toUint8Array()}catch(e){if(e instanceof ut)return g("Decoding the base64 bloom filter in existence filter failed ("+e.message+"); ignoring the bloom filter and falling back to full re-query."),null;throw e}try{o=new Yr(s,r,i)}catch(e){return g(e instanceof Xr?"BloomFilter error: ":"Applying bloom filter failed: ",e),null}return 0===o.Ie?null:o}Xe(e,t,n){return t.me.count===n-this.nt(e,t.targetId)?0:2}nt(e,t){const n=this.Le.getRemoteKeysForTarget(t);let r=0;return n.forEach((n=>{const i=this.Le.tt(),s=`projects/${i.projectId}/databases/${i.database}/documents/${n.path.canonicalString()}`;e.mightContain(s)||(this.Ue(t,n,null),r++)})),r}rt(e){const t=new Map;this.Be.forEach(((n,r)=>{const i=this.Je(r);if(i){if(n.current&&En(i.target)){const t=new z(i.target.path);null!==this.ke.get(t)||this.it(r,t)||this.Ue(r,t,$t.newNoDocument(t,e))}n.be&&(t.set(r,n.ve()),n.Ce())}}));let n=nr();this.qe.forEach(((e,t)=>{let r=!0;t.forEachWhile((e=>{const t=this.Je(e);return!t||"TargetPurposeLimboResolution"===t.purpose||(r=!1,!1)})),r&&(n=n.add(e))})),this.ke.forEach(((t,n)=>n.setReadTime(e)));const r=new Zr(e,t,this.Qe,this.ke,n);return this.ke=$n(),this.qe=oi(),this.Qe=new nt(P),r}$e(e,t){if(!this.ze(e))return;const n=this.it(e,t.key)?2:0;this.Ge(e).Fe(t.key,n),this.ke=this.ke.insert(t.key,t),this.qe=this.qe.insert(t.key,this.st(t.key).add(e))}Ue(e,t,n){if(!this.ze(e))return;const r=this.Ge(e);this.it(e,t)?r.Fe(t,1):r.Me(t),this.qe=this.qe.insert(t,this.st(t).delete(e)),n&&(this.ke=this.ke.insert(t,n))}removeTarget(e){this.Be.delete(e)}Ye(e){const t=this.Ge(e).ve();return this.Le.getRemoteKeysForTarget(e).size+t.addedDocuments.size-t.removedDocuments.size}xe(e){this.Ge(e).xe()}Ge(e){let t=this.Be.get(e);return t||(t=new ii,this.Be.set(e,t)),t}st(e){let t=this.qe.get(e);return t||(t=new st(P),this.qe=this.qe.insert(e,t)),t}ze(e){const t=null!==this.Je(e);return t||p("WatchChangeAggregator","Detected inactive target",e),t}Je(e){const t=this.Be.get(e);return t&&t.Se?null:this.Le.ot(e)}je(e){this.Be.set(e,new ii),this.Le.getRemoteKeysForTarget(e).forEach((t=>{this.Ue(e,t,null)}))}it(e,t){return this.Le.getRemoteKeysForTarget(e).has(t)}}function oi(){return new nt(z.comparator)}function ai(){return new nt(z.comparator)}const ci={asc:"ASCENDING",desc:"DESCENDING"},ui={"<":"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"},li={and:"AND",or:"OR"};class hi{constructor(e,t){this.databaseId=e,this.useProto3Json=t}}function di(e,t){return e.useProto3Json||ve(t)?t:{value:t}}function fi(e,t){return e.useProto3Json?`${new Date(1e3*t.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+t.nanoseconds).slice(-9)}Z`:{seconds:""+t.seconds,nanos:t.nanoseconds}}function pi(e,t){return e.useProto3Json?t.toBase64():t.toUint8Array()}function mi(e,t){return fi(e,t.toTimestamp())}function gi(e){return b(!!e),V.fromTimestamp(function(e){const t=dt(e);return new F(t.seconds,t.nanos)}(e))}function yi(e,t){return vi(e,t).canonicalString()}function vi(e,t){const n=function(e){return new j(["projects",e.projectId,"databases",e.database])}(e).child("documents");return void 0===t?n:n.child(t)}function bi(e){const t=j.fromString(e);return b(qi(t)),t}function wi(e,t){return yi(e.databaseId,t.path)}function _i(e,t){const n=bi(t);if(n.get(1)!==e.databaseId.projectId)throw new I(_.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+n.get(1)+" vs "+e.databaseId.projectId);if(n.get(3)!==e.databaseId.database)throw new I(_.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+n.get(3)+" vs "+e.databaseId.database);return new z(Si(n))}function Ii(e,t){return yi(e.databaseId,t)}function Ei(e){const t=bi(e);return 4===t.length?j.emptyPath():Si(t)}function Ti(e){return new j(["projects",e.databaseId.projectId,"databases",e.databaseId.database]).canonicalString()}function Si(e){return b(e.length>4&&"documents"===e.get(4)),e.popFirst(5)}function Ci(e,t,n){return{name:wi(e,t),fields:n.value.mapValue.fields}}function Ai(e,t,n){const r=_i(e,t.name),i=gi(t.updateTime),s=t.createTime?gi(t.createTime):V.min(),o=new Kt({mapValue:{fields:t.fields}}),a=$t.newFoundDocument(r,i,s,o);return n&&a.setHasCommittedMutations(),n?a.setHasCommittedMutations():a}function xi(e,t){let n;if(t instanceof Nr)n={update:Ci(e,t.key,t.value)};else if(t instanceof Lr)n={delete:wi(e,t.key)};else if(t instanceof Or)n={update:Ci(e,t.key,t.data),updateMask:Bi(t.fieldMask)};else{if(!(t instanceof Mr))return v();n={verify:wi(e,t.key)}}return t.fieldTransforms.length>0&&(n.updateTransforms=t.fieldTransforms.map((e=>function(e,t){const n=t.transform;if(n instanceof dr)return{fieldPath:t.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(n instanceof fr)return{fieldPath:t.field.canonicalString(),appendMissingElements:{values:n.elements}};if(n instanceof mr)return{fieldPath:t.field.canonicalString(),removeAllFromArray:{values:n.elements}};if(n instanceof yr)return{fieldPath:t.field.canonicalString(),increment:n.Pe};throw v()}(0,e)))),t.precondition.isNone||(n.currentDocument=function(e,t){return void 0!==t.updateTime?{updateTime:mi(e,t.updateTime)}:void 0!==t.exists?{exists:t.exists}:v()}(e,t.precondition)),n}function ki(e,t){const n=t.currentDocument?function(e){return void 0!==e.updateTime?Ir.updateTime(gi(e.updateTime)):void 0!==e.exists?Ir.exists(e.exists):Ir.none()}(t.currentDocument):Ir.none(),r=t.updateTransforms?t.updateTransforms.map((t=>function(e,t){let n=null;if("setToServerValue"in t)b("REQUEST_TIME"===t.setToServerValue),n=new dr;else if("appendMissingElements"in t){const e=t.appendMissingElements.values||[];n=new fr(e)}else if("removeAllFromArray"in t){const e=t.removeAllFromArray.values||[];n=new mr(e)}else"increment"in t?n=new yr(e,t.increment):v();const r=q.fromServerFormat(t.fieldPath);return new wr(r,n)}(e,t))):[];if(t.update){t.update.name;const i=_i(e,t.update.name),s=new Kt({mapValue:{fields:t.update.fields}});if(t.updateMask){const e=function(e){const t=e.fieldPaths||[];return new ct(t.map((e=>q.fromServerFormat(e))))}(t.updateMask);return new Or(i,s,e,n,r)}return new Nr(i,s,n,r)}if(t.delete){const r=_i(e,t.delete);return new Lr(r,n)}if(t.verify){const r=_i(e,t.verify);return new Mr(r,n)}return v()}function Ni(e,t){return{documents:[Ii(e,t.path)]}}function Oi(e,t){const n={structuredQuery:{}},r=t.path;let i;null!==t.collectionGroup?(i=r,n.structuredQuery.from=[{collectionId:t.collectionGroup,allDescendants:!0}]):(i=r.popLast(),n.structuredQuery.from=[{collectionId:r.lastSegment()}]),n.parent=Ii(e,i);const s=function(e){if(0!==e.length)return ji(tn.create(e,"and"))}(t.filters);s&&(n.structuredQuery.where=s);const o=function(e){if(0!==e.length)return e.map((e=>function(e){return{field:Vi(e.field),direction:Li(e.dir)}}(e)))}(t.orderBy);o&&(n.structuredQuery.orderBy=o);const a=di(e,t.limit);return null!==a&&(n.structuredQuery.limit=a),t.startAt&&(n.structuredQuery.startAt=function(e){return{before:e.inclusive,values:e.position}}(t.startAt)),t.endAt&&(n.structuredQuery.endAt=function(e){return{before:!e.inclusive,values:e.position}}(t.endAt)),{_t:n,parent:i}}function Di(e,t,n,r){const{_t:i,parent:s}=Oi(e,t),o={},a=[];let c=0;return n.forEach((e=>{const t=r?e.alias:"aggregate_"+c++;o[t]=e.alias,"count"===e.aggregateType?a.push({alias:t,count:{}}):"avg"===e.aggregateType?a.push({alias:t,avg:{field:Vi(e.fieldPath)}}):"sum"===e.aggregateType&&a.push({alias:t,sum:{field:Vi(e.fieldPath)}})})),{request:{structuredAggregationQuery:{aggregations:a,structuredQuery:i.structuredQuery},parent:i.parent},ut:o,parent:s}}function Ri(e){let t=Ei(e.parent);const n=e.structuredQuery,r=n.from?n.from.length:0;let i=null;if(r>0){b(1===r);const e=n.from[0];e.allDescendants?i=e.collectionId:t=t.child(e.collectionId)}let s=[];n.where&&(s=function(e){const t=Pi(e);return t instanceof tn&&sn(t)?t.getFilters():[t]}(n.where));let o=[];n.orderBy&&(o=function(e){return e.map((e=>function(e){return new Yt(Ui(e.field),function(e){switch(e){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(e.direction))}(e)))}(n.orderBy));let a=null;n.limit&&(a=function(e){let t;return t="object"==typeof e?e.value:e,ve(t)?null:t}(n.limit));let c=null;n.startAt&&(c=function(e){const t=!!e.before,n=e.values||[];return new Ht(n,t)}(n.startAt));let u=null;return n.endAt&&(u=function(e){const t=!e.before,n=e.values||[];return new Ht(n,t)}(n.endAt)),xn(t,i,o,s,a,"F",c,u)}function Pi(e){return void 0!==e.unaryFilter?function(e){switch(e.unaryFilter.op){case"IS_NAN":const t=Ui(e.unaryFilter.field);return en.create(t,"==",{doubleValue:NaN});case"IS_NULL":const n=Ui(e.unaryFilter.field);return en.create(n,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":const r=Ui(e.unaryFilter.field);return en.create(r,"!=",{doubleValue:NaN});case"IS_NOT_NULL":const i=Ui(e.unaryFilter.field);return en.create(i,"!=",{nullValue:"NULL_VALUE"});default:return v()}}(e):void 0!==e.fieldFilter?function(e){return en.create(Ui(e.fieldFilter.field),function(e){switch(e){case"EQUAL":return"==";case"NOT_EQUAL":return"!=";case"GREATER_THAN":return">";case"GREATER_THAN_OR_EQUAL":return">=";case"LESS_THAN":return"<";case"LESS_THAN_OR_EQUAL":return"<=";case"ARRAY_CONTAINS":return"array-contains";case"IN":return"in";case"NOT_IN":return"not-in";case"ARRAY_CONTAINS_ANY":return"array-contains-any";default:return v()}}(e.fieldFilter.op),e.fieldFilter.value)}(e):void 0!==e.compositeFilter?function(e){return tn.create(e.compositeFilter.filters.map((e=>Pi(e))),function(e){switch(e){case"AND":return"and";case"OR":return"or";default:return v()}}(e.compositeFilter.op))}(e):v()}function Li(e){return ci[e]}function Mi(e){return ui[e]}function Fi(e){return li[e]}function Vi(e){return{fieldPath:e.canonicalString()}}function Ui(e){return q.fromServerFormat(e.fieldPath)}function ji(e){return e instanceof en?function(e){if("=="===e.op){if(Lt(e.value))return{unaryFilter:{field:Vi(e.field),op:"IS_NAN"}};if(Pt(e.value))return{unaryFilter:{field:Vi(e.field),op:"IS_NULL"}}}else if("!="===e.op){if(Lt(e.value))return{unaryFilter:{field:Vi(e.field),op:"IS_NOT_NAN"}};if(Pt(e.value))return{unaryFilter:{field:Vi(e.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:Vi(e.field),op:Mi(e.op),value:e.value}}}(e):e instanceof tn?function(e){const t=e.getFilters().map((e=>ji(e)));return 1===t.length?t[0]:{compositeFilter:{op:Fi(e.op),filters:t}}}(e):v()}function Bi(e){const t=[];return e.fields.forEach((e=>t.push(e.canonicalString()))),{fieldPaths:t}}function qi(e){return e.length>=4&&"projects"===e.get(0)&&"databases"===e.get(2)}class zi{constructor(e,t,n,r,i=V.min(),s=V.min(),o=lt.EMPTY_BYTE_STRING,a=null){this.target=e,this.targetId=t,this.purpose=n,this.sequenceNumber=r,this.snapshotVersion=i,this.lastLimboFreeSnapshotVersion=s,this.resumeToken=o,this.expectedCount=a}withSequenceNumber(e){return new zi(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(e,t){return new zi(this.target,this.targetId,this.purpose,this.sequenceNumber,t,this.lastLimboFreeSnapshotVersion,e,null)}withExpectedCount(e){return new zi(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,e)}withLastLimboFreeSnapshotVersion(e){return new zi(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken,this.expectedCount)}}class Gi{constructor(e){this.ct=e}}function Ki(e,t){const n=t.key,r={prefixPath:n.getCollectionPath().popLast().toArray(),collectionGroup:n.collectionGroup,documentId:n.path.lastSegment(),readTime:Wi(t.readTime),hasCommittedMutations:t.hasCommittedMutations};if(t.isFoundDocument())r.document=function(e,t){return{name:wi(e,t.key),fields:t.data.value.mapValue.fields,updateTime:fi(e,t.version.toTimestamp()),createTime:fi(e,t.createTime.toTimestamp())}}(e.ct,t);else if(t.isNoDocument())r.noDocument={path:n.path.toArray(),readTime:$i(t.version)};else{if(!t.isUnknownDocument())return v();r.unknownDocument={path:n.path.toArray(),version:$i(t.version)}}return r}function Wi(e){const t=e.toTimestamp();return[t.seconds,t.nanoseconds]}function $i(e){const t=e.toTimestamp();return{seconds:t.seconds,nanoseconds:t.nanoseconds}}function Hi(e){const t=new F(e.seconds,e.nanoseconds);return V.fromTimestamp(t)}function Qi(e,t){const n=(t.baseMutations||[]).map((t=>ki(e.ct,t)));for(let e=0;e<t.mutations.length-1;++e){const n=t.mutations[e];if(e+1<t.mutations.length&&void 0!==t.mutations[e+1].transform){const r=t.mutations[e+1];n.updateTransforms=r.transform.fieldTransforms,t.mutations.splice(e+1,1),++e}}const r=t.mutations.map((t=>ki(e.ct,t))),i=F.fromMillis(t.localWriteTimeMs);return new Fr(t.batchId,i,n,r)}function Ji(e){const t=Hi(e.readTime),n=void 0!==e.lastLimboFreeSnapshotVersion?Hi(e.lastLimboFreeSnapshotVersion):V.min();let r;return r=function(e){return void 0!==e.documents}(e.query)?function(e){return b(1===e.documents.length),Rn(kn(Ei(e.documents[0])))}(e.query):function(e){return Rn(Ri(e))}(e.query),new zi(r,e.targetId,"TargetPurposeListen",e.lastListenSequenceNumber,t,n,lt.fromBase64String(e.resumeToken))}function Yi(e,t){const n=$i(t.snapshotVersion),r=$i(t.lastLimboFreeSnapshotVersion);let i;i=En(t.target)?Ni(e.ct,t.target):Oi(e.ct,t.target)._t;const s=t.resumeToken.toBase64();return{targetId:t.targetId,canonicalId:_n(t.target),readTime:n,resumeToken:s,lastListenSequenceNumber:t.sequenceNumber,lastLimboFreeSnapshotVersion:r,query:i}}function Xi(e){const t=Ri({parent:e.parent,structuredQuery:e.structuredQuery});return"LAST"===e.limitType?Fn(t,t.limit,"L"):t}function Zi(e,t){return new Ur(t.largestBatchId,ki(e.ct,t.overlayMutation))}function es(e,t){const n=t.path.lastSegment();return[e,_e(t.path.popLast()),n]}function ts(e,t,n,r){return{indexId:e,uid:t,sequenceNumber:n,readTime:$i(r.readTime),documentKey:_e(r.documentKey.path),largestBatchId:r.largestBatchId}}class ns{getBundleMetadata(e,t){return rs(e).get(t).next((e=>{if(e)return function(e){return{id:e.bundleId,createTime:Hi(e.createTime),version:e.version}}(e)}))}saveBundleMetadata(e,t){return rs(e).put(function(e){return{bundleId:e.id,createTime:$i(gi(e.createTime)),version:e.version}}(t))}getNamedQuery(e,t){return is(e).get(t).next((e=>{if(e)return function(e){return{name:e.name,query:Xi(e.bundledQuery),readTime:Hi(e.readTime)}}(e)}))}saveNamedQuery(e,t){return is(e).put(function(e){return{name:e.name,readTime:$i(gi(e.readTime)),bundledQuery:e.bundledQuery}}(t))}}function rs(e){return Ye(e,"bundles")}function is(e){return Ye(e,"namedQueries")}class ss{constructor(e,t){this.serializer=e,this.userId=t}static lt(e,t){const n=t.uid||"";return new ss(e,n)}getOverlay(e,t){return os(e).get(es(this.userId,t)).next((e=>e?Zi(this.serializer,e):null))}getOverlays(e,t){const n=Yn();return ie.forEach(t,(t=>this.getOverlay(e,t).next((e=>{null!==e&&n.set(t,e)})))).next((()=>n))}saveOverlays(e,t,n){const r=[];return n.forEach(((n,i)=>{const s=new Ur(t,i);r.push(this.ht(e,s))})),ie.waitFor(r)}removeOverlaysForBatchId(e,t,n){const r=new Set;t.forEach((e=>r.add(_e(e.getCollectionPath()))));const i=[];return r.forEach((t=>{const r=IDBKeyRange.bound([this.userId,t,n],[this.userId,t,n+1],!1,!0);i.push(os(e).j("collectionPathOverlayIndex",r))})),ie.waitFor(i)}getOverlaysForCollection(e,t,n){const r=Yn(),i=_e(t),s=IDBKeyRange.bound([this.userId,i,n],[this.userId,i,Number.POSITIVE_INFINITY],!0);return os(e).U("collectionPathOverlayIndex",s).next((e=>{for(const t of e){const e=Zi(this.serializer,t);r.set(e.getKey(),e)}return r}))}getOverlaysForCollectionGroup(e,t,n,r){const i=Yn();let s;const o=IDBKeyRange.bound([this.userId,t,n],[this.userId,t,Number.POSITIVE_INFINITY],!0);return os(e).J({index:"collectionGroupOverlayIndex",range:o},((e,t,n)=>{const o=Zi(this.serializer,t);i.size()<r||o.largestBatchId===s?(i.set(o.getKey(),o),s=o.largestBatchId):n.done()})).next((()=>i))}ht(e,t){return os(e).put(function(e,t,n){const[r,i,s]=es(t,n.mutation.key);return{userId:t,collectionPath:i,documentId:s,collectionGroup:n.mutation.key.getCollectionGroup(),largestBatchId:n.largestBatchId,overlayMutation:xi(e.ct,n.mutation)}}(this.serializer,this.userId,t))}}function os(e){return Ye(e,"documentOverlays")}class as{Pt(e){return Ye(e,"globals")}getSessionToken(e){return this.Pt(e).get("sessionToken").next((e=>{const t=null==e?void 0:e.value;return t?lt.fromUint8Array(t):lt.EMPTY_BYTE_STRING}))}setSessionToken(e,t){return this.Pt(e).put({name:"sessionToken",value:t.toUint8Array()})}}class cs{constructor(){}It(e,t){this.Tt(e,t),t.Et()}Tt(e,t){if("nullValue"in e)this.dt(t,5);else if("booleanValue"in e)this.dt(t,10),t.At(e.booleanValue?1:0);else if("integerValue"in e)this.dt(t,15),t.At(ft(e.integerValue));else if("doubleValue"in e){const n=ft(e.doubleValue);isNaN(n)?this.dt(t,13):(this.dt(t,15),be(n)?t.At(0):t.At(n))}else if("timestampValue"in e){let n=e.timestampValue;this.dt(t,20),"string"==typeof n&&(n=dt(n)),t.Rt(`${n.seconds||""}`),t.At(n.nanos||0)}else if("stringValue"in e)this.Vt(e.stringValue,t),this.ft(t);else if("bytesValue"in e)this.dt(t,30),t.gt(pt(e.bytesValue)),this.ft(t);else if("referenceValue"in e)this.yt(e.referenceValue,t);else if("geoPointValue"in e){const n=e.geoPointValue;this.dt(t,45),t.At(n.latitude||0),t.At(n.longitude||0)}else"mapValue"in e?Ut(e)?this.dt(t,Number.MAX_SAFE_INTEGER):Ft(e)?this.wt(e.mapValue,t):(this.St(e.mapValue,t),this.ft(t)):"arrayValue"in e?(this.bt(e.arrayValue,t),this.ft(t)):v()}Vt(e,t){this.dt(t,25),this.Dt(e,t)}Dt(e,t){t.Rt(e)}St(e,t){const n=e.fields||{};this.dt(t,55);for(const e of Object.keys(n))this.Vt(e,t),this.Tt(n[e],t)}wt(e,t){var n,r;const i=e.fields||{};this.dt(t,53);const s="value",o=(null===(r=null===(n=i[s].arrayValue)||void 0===n?void 0:n.values)||void 0===r?void 0:r.length)||0;this.dt(t,15),t.At(ft(o)),this.Vt(s,t),this.Tt(i[s],t)}bt(e,t){const n=e.values||[];this.dt(t,50);for(const e of n)this.Tt(e,t)}yt(e,t){this.dt(t,37),z.fromName(e).path.forEach((e=>{this.dt(t,60),this.Dt(e,t)}))}dt(e,t){e.At(t)}ft(e){e.At(2)}}function us(e){if(0===e)return 8;let t=0;return!(e>>4)&&(t+=4,e<<=4),!(e>>6)&&(t+=2,e<<=2),!(e>>7)&&(t+=1),t}function ls(e){const t=64-function(e){let t=0;for(let n=0;n<8;++n){const r=us(255&e[n]);if(t+=r,8!==r)break}return t}(e);return Math.ceil(t/8)}cs.vt=new cs;class hs{constructor(){this.buffer=new Uint8Array(1024),this.position=0}Ct(e){const t=e[Symbol.iterator]();let n=t.next();for(;!n.done;)this.Ft(n.value),n=t.next();this.Mt()}xt(e){const t=e[Symbol.iterator]();let n=t.next();for(;!n.done;)this.Ot(n.value),n=t.next();this.Nt()}Lt(e){for(const t of e){const e=t.charCodeAt(0);if(e<128)this.Ft(e);else if(e<2048)this.Ft(960|e>>>6),this.Ft(128|63&e);else if(t<"\ud800"||"\udbff"<t)this.Ft(480|e>>>12),this.Ft(128|63&e>>>6),this.Ft(128|63&e);else{const e=t.codePointAt(0);this.Ft(240|e>>>18),this.Ft(128|63&e>>>12),this.Ft(128|63&e>>>6),this.Ft(128|63&e)}}this.Mt()}Bt(e){for(const t of e){const e=t.charCodeAt(0);if(e<128)this.Ot(e);else if(e<2048)this.Ot(960|e>>>6),this.Ot(128|63&e);else if(t<"\ud800"||"\udbff"<t)this.Ot(480|e>>>12),this.Ot(128|63&e>>>6),this.Ot(128|63&e);else{const e=t.codePointAt(0);this.Ot(240|e>>>18),this.Ot(128|63&e>>>12),this.Ot(128|63&e>>>6),this.Ot(128|63&e)}}this.Nt()}kt(e){const t=this.qt(e),n=ls(t);this.Qt(1+n),this.buffer[this.position++]=255&n;for(let e=t.length-n;e<t.length;++e)this.buffer[this.position++]=255&t[e]}Kt(e){const t=this.qt(e),n=ls(t);this.Qt(1+n),this.buffer[this.position++]=~(255&n);for(let e=t.length-n;e<t.length;++e)this.buffer[this.position++]=~(255&t[e])}$t(){this.Ut(255),this.Ut(255)}Wt(){this.Gt(255),this.Gt(255)}reset(){this.position=0}seed(e){this.Qt(e.length),this.buffer.set(e,this.position),this.position+=e.length}zt(){return this.buffer.slice(0,this.position)}qt(e){const t=function(e){const t=new DataView(new ArrayBuffer(8));return t.setFloat64(0,e,!1),new Uint8Array(t.buffer)}(e),n=!!(128&t[0]);t[0]^=n?255:128;for(let e=1;e<t.length;++e)t[e]^=n?255:0;return t}Ft(e){const t=255&e;0===t?(this.Ut(0),this.Ut(255)):255===t?(this.Ut(255),this.Ut(0)):this.Ut(t)}Ot(e){const t=255&e;0===t?(this.Gt(0),this.Gt(255)):255===t?(this.Gt(255),this.Gt(0)):this.Gt(e)}Mt(){this.Ut(0),this.Ut(1)}Nt(){this.Gt(0),this.Gt(1)}Ut(e){this.Qt(1),this.buffer[this.position++]=e}Gt(e){this.Qt(1),this.buffer[this.position++]=~e}Qt(e){const t=e+this.position;if(t<=this.buffer.length)return;let n=2*this.buffer.length;n<t&&(n=t);const r=new Uint8Array(n);r.set(this.buffer),this.buffer=r}}class ds{constructor(e){this.jt=e}gt(e){this.jt.Ct(e)}Rt(e){this.jt.Lt(e)}At(e){this.jt.kt(e)}Et(){this.jt.$t()}}class fs{constructor(e){this.jt=e}gt(e){this.jt.xt(e)}Rt(e){this.jt.Bt(e)}At(e){this.jt.Kt(e)}Et(){this.jt.Wt()}}class ps{constructor(){this.jt=new hs,this.Ht=new ds(this.jt),this.Jt=new fs(this.jt)}seed(e){this.jt.seed(e)}Yt(e){return 0===e?this.Ht:this.Jt}zt(){return this.jt.zt()}reset(){this.jt.reset()}}class ms{constructor(e,t,n,r){this.indexId=e,this.documentKey=t,this.arrayValue=n,this.directionalValue=r}Zt(){const e=this.directionalValue.length,t=0===e||255===this.directionalValue[e-1]?e+1:e,n=new Uint8Array(t);return n.set(this.directionalValue,0),t!==e?n.set([0],this.directionalValue.length):++n[n.length-1],new ms(this.indexId,this.documentKey,this.arrayValue,n)}}function gs(e,t){let n=e.indexId-t.indexId;return 0!==n?n:(n=ys(e.arrayValue,t.arrayValue),0!==n?n:(n=ys(e.directionalValue,t.directionalValue),0!==n?n:z.comparator(e.documentKey,t.documentKey)))}function ys(e,t){for(let n=0;n<e.length&&n<t.length;++n){const r=e[n]-t[n];if(0!==r)return r}return e.length-t.length}class vs{constructor(e){this.Xt=new st(((e,t)=>q.comparator(e.field,t.field))),this.collectionId=null!=e.collectionGroup?e.collectionGroup:e.path.lastSegment(),this.en=e.orderBy,this.tn=[];for(const t of e.filters){const e=t;e.isInequality()?this.Xt=this.Xt.add(e):this.tn.push(e)}}get nn(){return this.Xt.size>1}rn(e){if(b(e.collectionGroup===this.collectionId),this.nn)return!1;const t=K(e);if(void 0!==t&&!this.sn(t))return!1;const n=W(e);let r=new Set,i=0,s=0;for(;i<n.length&&this.sn(n[i]);++i)r=r.add(n[i].fieldPath.canonicalString());if(i===n.length)return!0;if(this.Xt.size>0){const e=this.Xt.getIterator().getNext();if(!r.has(e.field.canonicalString())){const t=n[i];if(!this.on(e,t)||!this._n(this.en[s++],t))return!1}++i}for(;i<n.length;++i){const e=n[i];if(s>=this.en.length||!this._n(this.en[s++],e))return!1}return!0}an(){if(this.nn)return null;let e=new st(q.comparator);const t=[];for(const n of this.tn)if(!n.field.isKeyField())if("array-contains"===n.op||"array-contains-any"===n.op)t.push(new H(n.field,2));else{if(e.has(n.field))continue;e=e.add(n.field),t.push(new H(n.field,0))}for(const n of this.en)n.field.isKeyField()||e.has(n.field)||(e=e.add(n.field),t.push(new H(n.field,"asc"===n.dir?0:1)));return new G(G.UNKNOWN_ID,this.collectionId,t,J.empty())}sn(e){for(const t of this.tn)if(this.on(t,e))return!0;return!1}on(e,t){if(void 0===e||!e.field.isEqual(t.fieldPath))return!1;const n="array-contains"===e.op||"array-contains-any"===e.op;return 2===t.kind===n}_n(e,t){return!!e.field.isEqual(t.fieldPath)&&(0===t.kind&&"asc"===e.dir||1===t.kind&&"desc"===e.dir)}}function bs(e){var t,n;if(b(e instanceof en||e instanceof tn),e instanceof en){if(e instanceof gn){const r=(null===(n=null===(t=e.value.arrayValue)||void 0===t?void 0:t.values)||void 0===n?void 0:n.map((t=>en.create(e.field,"==",t))))||[];return tn.create(r,"or")}return e}const r=e.filters.map((e=>bs(e)));return tn.create(r,e.op)}function ws(e){if(0===e.getFilters().length)return[];const t=Ts(bs(e));return b(Es(t)),_s(t)||Is(t)?[t]:t.getFilters()}function _s(e){return e instanceof en}function Is(e){return e instanceof tn&&sn(e)}function Es(e){return _s(e)||Is(e)||function(e){if(e instanceof tn&&rn(e)){for(const t of e.getFilters())if(!_s(t)&&!Is(t))return!1;return!0}return!1}(e)}function Ts(e){if(b(e instanceof en||e instanceof tn),e instanceof en)return e;if(1===e.filters.length)return Ts(e.filters[0]);const t=e.filters.map((e=>Ts(e)));let n=tn.create(t,e.op);return n=As(n),Es(n)?n:(b(n instanceof tn),b(nn(n)),b(n.filters.length>1),n.filters.reduce(((e,t)=>Ss(e,t))))}function Ss(e,t){let n;return b(e instanceof en||e instanceof tn),b(t instanceof en||t instanceof tn),n=e instanceof en?t instanceof en?function(e,t){return tn.create([e,t],"and")}(e,t):Cs(e,t):t instanceof en?Cs(t,e):function(e,t){if(b(e.filters.length>0&&t.filters.length>0),nn(e)&&nn(t))return un(e,t.getFilters());const n=rn(e)?e:t,r=rn(e)?t:e,i=n.filters.map((e=>Ss(e,r)));return tn.create(i,"or")}(e,t),As(n)}function Cs(e,t){if(nn(t))return un(t,e.getFilters());{const n=t.filters.map((t=>Ss(e,t)));return tn.create(n,"or")}}function As(e){if(b(e instanceof en||e instanceof tn),e instanceof en)return e;const t=e.getFilters();if(1===t.length)return As(t[0]);if(on(e))return e;const n=t.map((e=>As(e))),r=[];return n.forEach((t=>{t instanceof en?r.push(t):t instanceof tn&&(t.op===e.op?r.push(...t.filters):r.push(t))})),1===r.length?r[0]:tn.create(r,e.op)}class xs{constructor(){this.un=new ks}addToCollectionParentIndex(e,t){return this.un.add(t),ie.resolve()}getCollectionParents(e,t){return ie.resolve(this.un.getEntries(t))}addFieldIndex(e,t){return ie.resolve()}deleteFieldIndex(e,t){return ie.resolve()}deleteAllFieldIndexes(e){return ie.resolve()}createTargetIndexes(e,t){return ie.resolve()}getDocumentsMatchingTarget(e,t){return ie.resolve(null)}getIndexType(e,t){return ie.resolve(0)}getFieldIndexes(e,t){return ie.resolve([])}getNextCollectionGroupToUpdate(e){return ie.resolve(null)}getMinOffset(e,t){return ie.resolve(Z.min())}getMinOffsetFromCollectionGroup(e,t){return ie.resolve(Z.min())}updateCollectionGroup(e,t,n){return ie.resolve()}updateIndexEntries(e,t){return ie.resolve()}}class ks{constructor(){this.index={}}add(e){const t=e.lastSegment(),n=e.popLast(),r=this.index[t]||new st(j.comparator),i=!r.has(n);return this.index[t]=r.add(n),i}has(e){const t=e.lastSegment(),n=e.popLast(),r=this.index[t];return r&&r.has(n)}getEntries(e){return(this.index[e]||new st(j.comparator)).toArray()}}const Ns=new Uint8Array(0);class Os{constructor(e,t){this.databaseId=t,this.cn=new ks,this.ln=new Kn((e=>_n(e)),((e,t)=>In(e,t))),this.uid=e.uid||""}addToCollectionParentIndex(e,t){if(!this.cn.has(t)){const n=t.lastSegment(),r=t.popLast();e.addOnCommittedListener((()=>{this.cn.add(t)}));const i={collectionId:n,parent:_e(r)};return Ds(e).put(i)}return ie.resolve()}getCollectionParents(e,t){const n=[],r=IDBKeyRange.bound([t,""],[M(t),""],!1,!0);return Ds(e).U(r).next((e=>{for(const r of e){if(r.collectionId!==t)break;n.push(Te(r.parent))}return n}))}addFieldIndex(e,t){const n=Ps(e),r=function(e){return{indexId:e.indexId,collectionGroup:e.collectionGroup,fields:e.fields.map((e=>[e.fieldPath.canonicalString(),e.kind]))}}(t);delete r.indexId;const i=n.add(r);if(t.indexState){const n=Ls(e);return i.next((e=>{n.put(ts(e,this.uid,t.indexState.sequenceNumber,t.indexState.offset))}))}return i.next()}deleteFieldIndex(e,t){const n=Ps(e),r=Ls(e),i=Rs(e);return n.delete(t.indexId).next((()=>r.delete(IDBKeyRange.bound([t.indexId],[t.indexId+1],!1,!0)))).next((()=>i.delete(IDBKeyRange.bound([t.indexId],[t.indexId+1],!1,!0))))}deleteAllFieldIndexes(e){const t=Ps(e),n=Rs(e),r=Ls(e);return t.j().next((()=>n.j())).next((()=>r.j()))}createTargetIndexes(e,t){return ie.forEach(this.hn(t),(t=>this.getIndexType(e,t).next((n=>{if(0===n||1===n){const n=new vs(t).an();if(null!=n)return this.addFieldIndex(e,n)}}))))}getDocumentsMatchingTarget(e,t){const n=Rs(e);let r=!0;const i=new Map;return ie.forEach(this.hn(t),(t=>this.Pn(e,t).next((e=>{r&&(r=!!e),i.set(t,e)})))).next((()=>{if(r){let e=nr();const r=[];return ie.forEach(i,((i,s)=>{p("IndexedDbIndexManager",`Using index ${function(e){return`id=${e.indexId}|cg=${e.collectionGroup}|f=${e.fields.map((e=>`${e.fieldPath}:${e.kind}`)).join(",")}`}(i)} to execute ${_n(t)}`);const o=function(e,t){const n=K(t);if(void 0===n)return null;for(const t of Tn(e,n.fieldPath))switch(t.op){case"array-contains-any":return t.value.arrayValue.values||[];case"array-contains":return[t.value]}return null}(s,i),a=function(e,t){const n=new Map;for(const r of W(t))for(const t of Tn(e,r.fieldPath))switch(t.op){case"==":case"in":n.set(r.fieldPath.canonicalString(),t.value);break;case"not-in":case"!=":return n.set(r.fieldPath.canonicalString(),t.value),Array.from(n.values())}return null}(s,i),c=function(e,t){const n=[];let r=!0;for(const i of W(t)){const t=0===i.kind?Sn(e,i.fieldPath,e.startAt):Cn(e,i.fieldPath,e.startAt);n.push(t.value),r&&(r=t.inclusive)}return new Ht(n,r)}(s,i),u=function(e,t){const n=[];let r=!0;for(const i of W(t)){const t=0===i.kind?Cn(e,i.fieldPath,e.endAt):Sn(e,i.fieldPath,e.endAt);n.push(t.value),r&&(r=t.inclusive)}return new Ht(n,r)}(s,i),l=this.In(i,s,c),h=this.In(i,s,u),d=this.Tn(i,s,a),f=this.En(i.indexId,o,l,c.inclusive,h,u.inclusive,d);return ie.forEach(f,(i=>n.G(i,t.limit).next((t=>{t.forEach((t=>{const n=z.fromSegments(t.documentKey);e.has(n)||(e=e.add(n),r.push(n))}))}))))})).next((()=>r))}return ie.resolve(null)}))}hn(e){let t=this.ln.get(e);return t||(t=0===e.filters.length?[e]:ws(tn.create(e.filters,"and")).map((t=>wn(e.path,e.collectionGroup,e.orderBy,t.getFilters(),e.limit,e.startAt,e.endAt))),this.ln.set(e,t),t)}En(e,t,n,r,i,s,o){const a=(null!=t?t.length:1)*Math.max(n.length,i.length),c=a/(null!=t?t.length:1),u=[];for(let l=0;l<a;++l){const a=t?this.dn(t[l/c]):Ns,h=this.An(e,a,n[l%c],r),d=this.Rn(e,a,i[l%c],s),f=o.map((t=>this.An(e,a,t,!0)));u.push(...this.createRange(h,d,f))}return u}An(e,t,n,r){const i=new ms(e,z.empty(),t,n);return r?i:i.Zt()}Rn(e,t,n,r){const i=new ms(e,z.empty(),t,n);return r?i.Zt():i}Pn(e,t){const n=new vs(t),r=null!=t.collectionGroup?t.collectionGroup:t.path.lastSegment();return this.getFieldIndexes(e,r).next((e=>{let t=null;for(const r of e)n.rn(r)&&(!t||r.fields.length>t.fields.length)&&(t=r);return t}))}getIndexType(e,t){let n=2;const r=this.hn(t);return ie.forEach(r,(t=>this.Pn(e,t).next((e=>{e?0!==n&&e.fields.length<function(e){let t=new st(q.comparator),n=!1;for(const r of e.filters)for(const e of r.getFlattenedFilters())e.field.isKeyField()||("array-contains"===e.op||"array-contains-any"===e.op?n=!0:t=t.add(e.field));for(const n of e.orderBy)n.field.isKeyField()||(t=t.add(n.field));return t.size+(n?1:0)}(t)&&(n=1):n=0})))).next((()=>function(e){return null!==e.limit}(t)&&r.length>1&&2===n?1:n))}Vn(e,t){const n=new ps;for(const r of W(e)){const e=t.data.field(r.fieldPath);if(null==e)return null;const i=n.Yt(r.kind);cs.vt.It(e,i)}return n.zt()}dn(e){const t=new ps;return cs.vt.It(e,t.Yt(0)),t.zt()}mn(e,t){const n=new ps;return cs.vt.It(Ot(this.databaseId,t),n.Yt(function(e){const t=W(e);return 0===t.length?0:t[t.length-1].kind}(e))),n.zt()}Tn(e,t,n){if(null===n)return[];let r=[];r.push(new ps);let i=0;for(const s of W(e)){const e=n[i++];for(const n of r)if(this.fn(t,s.fieldPath)&&Rt(e))r=this.gn(r,s,e);else{const t=n.Yt(s.kind);cs.vt.It(e,t)}}return this.pn(r)}In(e,t,n){return this.Tn(e,t,n.position)}pn(e){const t=[];for(let n=0;n<e.length;++n)t[n]=e[n].zt();return t}gn(e,t,n){const r=[...e],i=[];for(const e of n.arrayValue.values||[])for(const n of r){const r=new ps;r.seed(n.zt()),cs.vt.It(e,r.Yt(t.kind)),i.push(r)}return i}fn(e,t){return!!e.filters.find((e=>e instanceof en&&e.field.isEqual(t)&&("in"===e.op||"not-in"===e.op)))}getFieldIndexes(e,t){const n=Ps(e),r=Ls(e);return(t?n.U("collectionGroupIndex",IDBKeyRange.bound(t,t)):n.U()).next((e=>{const t=[];return ie.forEach(e,(e=>r.get([e.indexId,this.uid]).next((n=>{t.push(function(e,t){const n=t?new J(t.sequenceNumber,new Z(Hi(t.readTime),new z(Te(t.documentKey)),t.largestBatchId)):J.empty(),r=e.fields.map((([e,t])=>new H(q.fromServerFormat(e),t)));return new G(e.indexId,e.collectionGroup,r,n)}(e,n))})))).next((()=>t))}))}getNextCollectionGroupToUpdate(e){return this.getFieldIndexes(e).next((e=>0===e.length?null:(e.sort(((e,t)=>{const n=e.indexState.sequenceNumber-t.indexState.sequenceNumber;return 0!==n?n:P(e.collectionGroup,t.collectionGroup)})),e[0].collectionGroup)))}updateCollectionGroup(e,t,n){const r=Ps(e),i=Ls(e);return this.yn(e).next((e=>r.U("collectionGroupIndex",IDBKeyRange.bound(t,t)).next((t=>ie.forEach(t,(t=>i.put(ts(t.indexId,this.uid,e,n))))))))}updateIndexEntries(e,t){const n=new Map;return ie.forEach(t,((t,r)=>{const i=n.get(t.collectionGroup);return(i?ie.resolve(i):this.getFieldIndexes(e,t.collectionGroup)).next((i=>(n.set(t.collectionGroup,i),ie.forEach(i,(n=>this.wn(e,t,n).next((t=>{const i=this.Sn(r,n);return t.isEqual(i)?ie.resolve():this.bn(e,r,n,t,i)})))))))}))}Dn(e,t,n,r){return Rs(e).put({indexId:r.indexId,uid:this.uid,arrayValue:r.arrayValue,directionalValue:r.directionalValue,orderedDocumentKey:this.mn(n,t.key),documentKey:t.key.path.toArray()})}vn(e,t,n,r){return Rs(e).delete([r.indexId,this.uid,r.arrayValue,r.directionalValue,this.mn(n,t.key),t.key.path.toArray()])}wn(e,t,n){const r=Rs(e);let i=new st(gs);return r.J({index:"documentKeyIndex",range:IDBKeyRange.only([n.indexId,this.uid,this.mn(n,t)])},((e,r)=>{i=i.add(new ms(n.indexId,t,r.arrayValue,r.directionalValue))})).next((()=>i))}Sn(e,t){let n=new st(gs);const r=this.Vn(t,e);if(null==r)return n;const i=K(t);if(null!=i){const s=e.data.field(i.fieldPath);if(Rt(s))for(const i of s.arrayValue.values||[])n=n.add(new ms(t.indexId,e.key,this.dn(i),r))}else n=n.add(new ms(t.indexId,e.key,Ns,r));return n}bn(e,t,n,r,i){p("IndexedDbIndexManager","Updating index entries for document '%s'",t.key);const s=[];return function(e,t,n,r,i){const s=e.getIterator(),o=t.getIterator();let a=at(s),c=at(o);for(;a||c;){let e=!1,t=!1;if(a&&c){const r=n(a,c);r<0?t=!0:r>0&&(e=!0)}else null!=a?t=!0:e=!0;e?(r(c),c=at(o)):t?(i(a),a=at(s)):(a=at(s),c=at(o))}}(r,i,gs,(r=>{s.push(this.Dn(e,t,n,r))}),(r=>{s.push(this.vn(e,t,n,r))})),ie.waitFor(s)}yn(e){let t=1;return Ls(e).J({index:"sequenceNumberIndex",reverse:!0,range:IDBKeyRange.upperBound([this.uid,Number.MAX_SAFE_INTEGER])},((e,n,r)=>{r.done(),t=n.sequenceNumber+1})).next((()=>t))}createRange(e,t,n){n=n.sort(((e,t)=>gs(e,t))).filter(((e,t,n)=>!t||0!==gs(e,n[t-1])));const r=[];r.push(e);for(const i of n){const n=gs(i,e),s=gs(i,t);if(0===n)r[0]=e.Zt();else if(n>0&&s<0)r.push(i),r.push(i.Zt());else if(s>0)break}r.push(t);const i=[];for(let e=0;e<r.length;e+=2){if(this.Cn(r[e],r[e+1]))return[];const t=[r[e].indexId,this.uid,r[e].arrayValue,r[e].directionalValue,Ns,[]],n=[r[e+1].indexId,this.uid,r[e+1].arrayValue,r[e+1].directionalValue,Ns,[]];i.push(IDBKeyRange.bound(t,n))}return i}Cn(e,t){return gs(e,t)>0}getMinOffsetFromCollectionGroup(e,t){return this.getFieldIndexes(e,t).next(Ms)}getMinOffset(e,t){return ie.mapArray(this.hn(t),(t=>this.Pn(e,t).next((e=>e||v())))).next(Ms)}}function Ds(e){return Ye(e,"collectionParents")}function Rs(e){return Ye(e,"indexEntries")}function Ps(e){return Ye(e,"indexConfiguration")}function Ls(e){return Ye(e,"indexState")}function Ms(e){b(0!==e.length);let t=e[0].indexState.offset,n=t.largestBatchId;for(let r=1;r<e.length;r++){const i=e[r].indexState.offset;ee(i,t)<0&&(t=i),n<i.largestBatchId&&(n=i.largestBatchId)}return new Z(t.readTime,t.documentKey,n)}const Fs={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0};class Vs{constructor(e,t,n){this.cacheSizeCollectionThreshold=e,this.percentileToCollect=t,this.maximumSequenceNumbersToCollect=n}static withCacheSize(e){return new Vs(e,Vs.DEFAULT_COLLECTION_PERCENTILE,Vs.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}}function Us(e,t,n){const r=e.store("mutations"),i=e.store("documentMutations"),s=[],o=IDBKeyRange.only(n.batchId);let a=0;const c=r.J({range:o},((e,t,n)=>(a++,n.delete())));s.push(c.next((()=>{b(1===a)})));const u=[];for(const e of n.mutations){const r=Ae(t,e.key.path,n.batchId);s.push(i.delete(r)),u.push(e.key)}return ie.waitFor(s).next((()=>u))}function js(e){if(!e)return 0;let t;if(e.document)t=e.document;else if(e.unknownDocument)t=e.unknownDocument;else{if(!e.noDocument)throw v();t=e.noDocument}return JSON.stringify(t).length}Vs.DEFAULT_COLLECTION_PERCENTILE=10,Vs.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,Vs.DEFAULT=new Vs(41943040,Vs.DEFAULT_COLLECTION_PERCENTILE,Vs.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),Vs.DISABLED=new Vs(-1,0,0);class Bs{constructor(e,t,n,r){this.userId=e,this.serializer=t,this.indexManager=n,this.referenceDelegate=r,this.Fn={}}static lt(e,t,n,r){b(""!==e.uid);const i=e.isAuthenticated()?e.uid:"";return new Bs(i,t,n,r)}checkEmpty(e){let t=!0;const n=IDBKeyRange.bound([this.userId,Number.NEGATIVE_INFINITY],[this.userId,Number.POSITIVE_INFINITY]);return zs(e).J({index:"userMutationsIndex",range:n},((e,n,r)=>{t=!1,r.done()})).next((()=>t))}addMutationBatch(e,t,n,r){const i=Gs(e),s=zs(e);return s.add({}).next((o=>{b("number"==typeof o);const a=new Fr(o,t,n,r),c=function(e,t,n){const r=n.baseMutations.map((t=>xi(e.ct,t))),i=n.mutations.map((t=>xi(e.ct,t)));return{userId:t,batchId:n.batchId,localWriteTimeMs:n.localWriteTime.toMillis(),baseMutations:r,mutations:i}}(this.serializer,this.userId,a),u=[];let l=new st(((e,t)=>P(e.canonicalString(),t.canonicalString())));for(const e of r){const t=Ae(this.userId,e.key.path,o);l=l.add(e.key.path.popLast()),u.push(s.put(c)),u.push(i.put(t,xe))}return l.forEach((t=>{u.push(this.indexManager.addToCollectionParentIndex(e,t))})),e.addOnCommittedListener((()=>{this.Fn[o]=a.keys()})),ie.waitFor(u).next((()=>a))}))}lookupMutationBatch(e,t){return zs(e).get(t).next((e=>e?(b(e.userId===this.userId),Qi(this.serializer,e)):null))}Mn(e,t){return this.Fn[t]?ie.resolve(this.Fn[t]):this.lookupMutationBatch(e,t).next((e=>{if(e){const n=e.keys();return this.Fn[t]=n,n}return null}))}getNextMutationBatchAfterBatchId(e,t){const n=t+1,r=IDBKeyRange.lowerBound([this.userId,n]);let i=null;return zs(e).J({index:"userMutationsIndex",range:r},((e,t,r)=>{t.userId===this.userId&&(b(t.batchId>=n),i=Qi(this.serializer,t)),r.done()})).next((()=>i))}getHighestUnacknowledgedBatchId(e){const t=IDBKeyRange.upperBound([this.userId,Number.POSITIVE_INFINITY]);let n=-1;return zs(e).J({index:"userMutationsIndex",range:t,reverse:!0},((e,t,r)=>{n=t.batchId,r.done()})).next((()=>n))}getAllMutationBatches(e){const t=IDBKeyRange.bound([this.userId,-1],[this.userId,Number.POSITIVE_INFINITY]);return zs(e).U("userMutationsIndex",t).next((e=>e.map((e=>Qi(this.serializer,e)))))}getAllMutationBatchesAffectingDocumentKey(e,t){const n=Ce(this.userId,t.path),r=IDBKeyRange.lowerBound(n),i=[];return Gs(e).J({range:r},((n,r,s)=>{const[o,a,c]=n,u=Te(a);if(o===this.userId&&t.path.isEqual(u))return zs(e).get(c).next((e=>{if(!e)throw v();b(e.userId===this.userId),i.push(Qi(this.serializer,e))}));s.done()})).next((()=>i))}getAllMutationBatchesAffectingDocumentKeys(e,t){let n=new st(P);const r=[];return t.forEach((t=>{const i=Ce(this.userId,t.path),s=IDBKeyRange.lowerBound(i),o=Gs(e).J({range:s},((e,r,i)=>{const[s,o,a]=e,c=Te(o);s===this.userId&&t.path.isEqual(c)?n=n.add(a):i.done()}));r.push(o)})),ie.waitFor(r).next((()=>this.xn(e,n)))}getAllMutationBatchesAffectingQuery(e,t){const n=t.path,r=n.length+1,i=Ce(this.userId,n),s=IDBKeyRange.lowerBound(i);let o=new st(P);return Gs(e).J({range:s},((e,t,i)=>{const[s,a,c]=e,u=Te(a);s===this.userId&&n.isPrefixOf(u)?u.length===r&&(o=o.add(c)):i.done()})).next((()=>this.xn(e,o)))}xn(e,t){const n=[],r=[];return t.forEach((t=>{r.push(zs(e).get(t).next((e=>{if(null===e)throw v();b(e.userId===this.userId),n.push(Qi(this.serializer,e))})))})),ie.waitFor(r).next((()=>n))}removeMutationBatch(e,t){return Us(e._e,this.userId,t).next((n=>(e.addOnCommittedListener((()=>{this.On(t.batchId)})),ie.forEach(n,(t=>this.referenceDelegate.markPotentiallyOrphaned(e,t))))))}On(e){delete this.Fn[e]}performConsistencyCheck(e){return this.checkEmpty(e).next((t=>{if(!t)return ie.resolve();const n=IDBKeyRange.lowerBound(function(e){return[e]}(this.userId)),r=[];return Gs(e).J({range:n},((e,t,n)=>{if(e[0]===this.userId){const t=Te(e[1]);r.push(t)}else n.done()})).next((()=>{b(0===r.length)}))}))}containsKey(e,t){return qs(e,this.userId,t)}Nn(e){return Ks(e).get(this.userId).next((e=>e||{userId:this.userId,lastAcknowledgedBatchId:-1,lastStreamToken:""}))}}function qs(e,t,n){const r=Ce(t,n.path),i=r[1],s=IDBKeyRange.lowerBound(r);let o=!1;return Gs(e).J({range:s,H:!0},((e,n,r)=>{const[s,a,c]=e;s===t&&a===i&&(o=!0),r.done()})).next((()=>o))}function zs(e){return Ye(e,"mutations")}function Gs(e){return Ye(e,"documentMutations")}function Ks(e){return Ye(e,"mutationQueues")}class Ws{constructor(e){this.Ln=e}next(){return this.Ln+=2,this.Ln}static Bn(){return new Ws(0)}static kn(){return new Ws(-1)}}class $s{constructor(e,t){this.referenceDelegate=e,this.serializer=t}allocateTargetId(e){return this.qn(e).next((t=>{const n=new Ws(t.highestTargetId);return t.highestTargetId=n.next(),this.Qn(e,t).next((()=>t.highestTargetId))}))}getLastRemoteSnapshotVersion(e){return this.qn(e).next((e=>V.fromTimestamp(new F(e.lastRemoteSnapshotVersion.seconds,e.lastRemoteSnapshotVersion.nanoseconds))))}getHighestSequenceNumber(e){return this.qn(e).next((e=>e.highestListenSequenceNumber))}setTargetsMetadata(e,t,n){return this.qn(e).next((r=>(r.highestListenSequenceNumber=t,n&&(r.lastRemoteSnapshotVersion=n.toTimestamp()),t>r.highestListenSequenceNumber&&(r.highestListenSequenceNumber=t),this.Qn(e,r))))}addTargetData(e,t){return this.Kn(e,t).next((()=>this.qn(e).next((n=>(n.targetCount+=1,this.$n(t,n),this.Qn(e,n))))))}updateTargetData(e,t){return this.Kn(e,t)}removeTargetData(e,t){return this.removeMatchingKeysForTargetId(e,t.targetId).next((()=>Hs(e).delete(t.targetId))).next((()=>this.qn(e))).next((t=>(b(t.targetCount>0),t.targetCount-=1,this.Qn(e,t))))}removeTargets(e,t,n){let r=0;const i=[];return Hs(e).J(((s,o)=>{const a=Ji(o);a.sequenceNumber<=t&&null===n.get(a.targetId)&&(r++,i.push(this.removeTargetData(e,a)))})).next((()=>ie.waitFor(i))).next((()=>r))}forEachTarget(e,t){return Hs(e).J(((e,n)=>{const r=Ji(n);t(r)}))}qn(e){return Qs(e).get("targetGlobalKey").next((e=>(b(null!==e),e)))}Qn(e,t){return Qs(e).put("targetGlobalKey",t)}Kn(e,t){return Hs(e).put(Yi(this.serializer,t))}$n(e,t){let n=!1;return e.targetId>t.highestTargetId&&(t.highestTargetId=e.targetId,n=!0),e.sequenceNumber>t.highestListenSequenceNumber&&(t.highestListenSequenceNumber=e.sequenceNumber,n=!0),n}getTargetCount(e){return this.qn(e).next((e=>e.targetCount))}getTargetData(e,t){const n=_n(t),r=IDBKeyRange.bound([n,Number.NEGATIVE_INFINITY],[n,Number.POSITIVE_INFINITY]);let i=null;return Hs(e).J({range:r,index:"queryTargetsIndex"},((e,n,r)=>{const s=Ji(n);In(t,s.target)&&(i=s,r.done())})).next((()=>i))}addMatchingKeys(e,t,n){const r=[],i=Js(e);return t.forEach((t=>{const s=_e(t.path);r.push(i.put({targetId:n,path:s})),r.push(this.referenceDelegate.addReference(e,n,t))})),ie.waitFor(r)}removeMatchingKeys(e,t,n){const r=Js(e);return ie.forEach(t,(t=>{const i=_e(t.path);return ie.waitFor([r.delete([n,i]),this.referenceDelegate.removeReference(e,n,t)])}))}removeMatchingKeysForTargetId(e,t){const n=Js(e),r=IDBKeyRange.bound([t],[t+1],!1,!0);return n.delete(r)}getMatchingKeysForTargetId(e,t){const n=IDBKeyRange.bound([t],[t+1],!1,!0),r=Js(e);let i=nr();return r.J({range:n,H:!0},((e,t,n)=>{const r=Te(e[1]),s=new z(r);i=i.add(s)})).next((()=>i))}containsKey(e,t){const n=_e(t.path),r=IDBKeyRange.bound([n],[M(n)],!1,!0);let i=0;return Js(e).J({index:"documentTargetsIndex",H:!0,range:r},(([e,t],n,r)=>{0!==e&&(i++,r.done())})).next((()=>i>0))}ot(e,t){return Hs(e).get(t).next((e=>e?Ji(e):null))}}function Hs(e){return Ye(e,"targets")}function Qs(e){return Ye(e,"targetGlobal")}function Js(e){return Ye(e,"targetDocuments")}function Ys([e,t],[n,r]){const i=P(e,n);return 0===i?P(t,r):i}class Xs{constructor(e){this.Un=e,this.buffer=new st(Ys),this.Wn=0}Gn(){return++this.Wn}zn(e){const t=[e,this.Gn()];if(this.buffer.size<this.Un)this.buffer=this.buffer.add(t);else{const e=this.buffer.last();Ys(t,e)<0&&(this.buffer=this.buffer.delete(e).add(t))}}get maxValue(){return this.buffer.last()[0]}}class Zs{constructor(e,t,n){this.garbageCollector=e,this.asyncQueue=t,this.localStore=n,this.jn=null}start(){-1!==this.garbageCollector.params.cacheSizeCollectionThreshold&&this.Hn(6e4)}stop(){this.jn&&(this.jn.cancel(),this.jn=null)}get started(){return null!==this.jn}Hn(e){p("LruGarbageCollector",`Garbage collection scheduled in ${e}ms`),this.jn=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",e,(async()=>{this.jn=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(e){le(e)?p("LruGarbageCollector","Ignoring IndexedDB error during garbage collection: ",e):await re(e)}await this.Hn(3e5)}))}}class eo{constructor(e,t){this.Jn=e,this.params=t}calculateTargetCount(e,t){return this.Jn.Yn(e).next((e=>Math.floor(t/100*e)))}nthSequenceNumber(e,t){if(0===t)return ie.resolve(ye.oe);const n=new Xs(t);return this.Jn.forEachTarget(e,(e=>n.zn(e.sequenceNumber))).next((()=>this.Jn.Zn(e,(e=>n.zn(e))))).next((()=>n.maxValue))}removeTargets(e,t,n){return this.Jn.removeTargets(e,t,n)}removeOrphanedDocuments(e,t){return this.Jn.removeOrphanedDocuments(e,t)}collect(e,t){return-1===this.params.cacheSizeCollectionThreshold?(p("LruGarbageCollector","Garbage collection skipped; disabled"),ie.resolve(Fs)):this.getCacheSize(e).next((n=>n<this.params.cacheSizeCollectionThreshold?(p("LruGarbageCollector",`Garbage collection skipped; Cache size ${n} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),Fs):this.Xn(e,t)))}getCacheSize(e){return this.Jn.getCacheSize(e)}Xn(e,t){let n,r,i,o,a,c,u;const l=Date.now();return this.calculateTargetCount(e,this.params.percentileToCollect).next((t=>(t>this.params.maximumSequenceNumbersToCollect?(p("LruGarbageCollector",`Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${t}`),r=this.params.maximumSequenceNumbersToCollect):r=t,o=Date.now(),this.nthSequenceNumber(e,r)))).next((r=>(n=r,a=Date.now(),this.removeTargets(e,n,t)))).next((t=>(i=t,c=Date.now(),this.removeOrphanedDocuments(e,n)))).next((e=>(u=Date.now(),f()<=s.LogLevel.DEBUG&&p("LruGarbageCollector",`LRU Garbage Collection\n\tCounted targets in ${o-l}ms\n\tDetermined least recently used ${r} in `+(a-o)+"ms\n"+`\tRemoved ${i} targets in `+(c-a)+"ms\n"+`\tRemoved ${e} documents in `+(u-c)+"ms\n"+`Total Duration: ${u-l}ms`),ie.resolve({didRun:!0,sequenceNumbersCollected:r,targetsRemoved:i,documentsRemoved:e}))))}}function to(e,t){return new eo(e,t)}class no{constructor(e,t){this.db=e,this.garbageCollector=to(this,t)}Yn(e){const t=this.er(e);return this.db.getTargetCache().getTargetCount(e).next((e=>t.next((t=>e+t))))}er(e){let t=0;return this.Zn(e,(e=>{t++})).next((()=>t))}forEachTarget(e,t){return this.db.getTargetCache().forEachTarget(e,t)}Zn(e,t){return this.tr(e,((e,n)=>t(n)))}addReference(e,t,n){return ro(e,n)}removeReference(e,t,n){return ro(e,n)}removeTargets(e,t,n){return this.db.getTargetCache().removeTargets(e,t,n)}markPotentiallyOrphaned(e,t){return ro(e,t)}nr(e,t){return function(e,t){let n=!1;return Ks(e).Y((r=>qs(e,r,t).next((e=>(e&&(n=!0),ie.resolve(!e)))))).next((()=>n))}(e,t)}removeOrphanedDocuments(e,t){const n=this.db.getRemoteDocumentCache().newChangeBuffer(),r=[];let i=0;return this.tr(e,((s,o)=>{if(o<=t){const t=this.nr(e,s).next((t=>{if(!t)return i++,n.getEntry(e,s).next((()=>(n.removeEntry(s,V.min()),Js(e).delete(function(e){return[0,_e(e.path)]}(s)))))}));r.push(t)}})).next((()=>ie.waitFor(r))).next((()=>n.apply(e))).next((()=>i))}removeTarget(e,t){const n=t.withSequenceNumber(e.currentSequenceNumber);return this.db.getTargetCache().updateTargetData(e,n)}updateLimboDocument(e,t){return ro(e,t)}tr(e,t){const n=Js(e);let r,i=ye.oe;return n.J({index:"documentTargetsIndex"},(([e,n],{path:s,sequenceNumber:o})=>{0===e?(i!==ye.oe&&t(new z(Te(r)),i),i=o,r=s):i=ye.oe})).next((()=>{i!==ye.oe&&t(new z(Te(r)),i)}))}getCacheSize(e){return this.db.getRemoteDocumentCache().getSize(e)}}function ro(e,t){return Js(e).put(function(e,t){return{targetId:0,path:_e(e.path),sequenceNumber:t}}(t,e.currentSequenceNumber))}class io{constructor(){this.changes=new Kn((e=>e.toString()),((e,t)=>e.isEqual(t))),this.changesApplied=!1}addEntry(e){this.assertNotApplied(),this.changes.set(e.key,e)}removeEntry(e,t){this.assertNotApplied(),this.changes.set(e,$t.newInvalidDocument(e).setReadTime(t))}getEntry(e,t){this.assertNotApplied();const n=this.changes.get(t);return void 0!==n?ie.resolve(n):this.getFromCache(e,t)}getEntries(e,t){return this.getAllFromCache(e,t)}apply(e){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(e)}assertNotApplied(){}}class so{constructor(e){this.serializer=e}setIndexManager(e){this.indexManager=e}addEntry(e,t,n){return uo(e).put(n)}removeEntry(e,t,n){return uo(e).delete(function(e,t){const n=e.path.toArray();return[n.slice(0,n.length-2),n[n.length-2],Wi(t),n[n.length-1]]}(t,n))}updateMetadata(e,t){return this.getMetadata(e).next((n=>(n.byteSize+=t,this.rr(e,n))))}getEntry(e,t){let n=$t.newInvalidDocument(t);return uo(e).J({index:"documentKeyIndex",range:IDBKeyRange.only(lo(t))},((e,r)=>{n=this.ir(t,r)})).next((()=>n))}sr(e,t){let n={size:0,document:$t.newInvalidDocument(t)};return uo(e).J({index:"documentKeyIndex",range:IDBKeyRange.only(lo(t))},((e,r)=>{n={document:this.ir(t,r),size:js(r)}})).next((()=>n))}getEntries(e,t){let n=$n();return this._r(e,t,((e,t)=>{const r=this.ir(e,t);n=n.insert(e,r)})).next((()=>n))}ar(e,t){let n=$n(),r=new nt(z.comparator);return this._r(e,t,((e,t)=>{const i=this.ir(e,t);n=n.insert(e,i),r=r.insert(e,js(t))})).next((()=>({documents:n,ur:r})))}_r(e,t,n){if(t.isEmpty())return ie.resolve();let r=new st(fo);t.forEach((e=>r=r.add(e)));const i=IDBKeyRange.bound(lo(r.first()),lo(r.last())),s=r.getIterator();let o=s.getNext();return uo(e).J({index:"documentKeyIndex",range:i},((e,t,r)=>{const i=z.fromSegments([...t.prefixPath,t.collectionGroup,t.documentId]);for(;o&&fo(o,i)<0;)n(o,null),o=s.getNext();o&&o.isEqual(i)&&(n(o,t),o=s.hasNext()?s.getNext():null),o?r.$(lo(o)):r.done()})).next((()=>{for(;o;)n(o,null),o=s.hasNext()?s.getNext():null}))}getDocumentsMatchingQuery(e,t,n,r,i){const s=t.path,o=[s.popLast().toArray(),s.lastSegment(),Wi(n.readTime),n.documentKey.path.isEmpty()?"":n.documentKey.path.lastSegment()],a=[s.popLast().toArray(),s.lastSegment(),[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],""];return uo(e).U(IDBKeyRange.bound(o,a,!0)).next((e=>{null==i||i.incrementDocumentReadCount(e.length);let n=$n();for(const i of e){const e=this.ir(z.fromSegments(i.prefixPath.concat(i.collectionGroup,i.documentId)),i);e.isFoundDocument()&&(Bn(t,e)||r.has(e.key))&&(n=n.insert(e.key,e))}return n}))}getAllFromCollectionGroup(e,t,n,r){let i=$n();const s=ho(t,n),o=ho(t,Z.max());return uo(e).J({index:"collectionGroupIndex",range:IDBKeyRange.bound(s,o,!0)},((e,t,n)=>{const s=this.ir(z.fromSegments(t.prefixPath.concat(t.collectionGroup,t.documentId)),t);i=i.insert(s.key,s),i.size===r&&n.done()})).next((()=>i))}newChangeBuffer(e){return new ao(this,!!e&&e.trackRemovals)}getSize(e){return this.getMetadata(e).next((e=>e.byteSize))}getMetadata(e){return co(e).get("remoteDocumentGlobalKey").next((e=>(b(!!e),e)))}rr(e,t){return co(e).put("remoteDocumentGlobalKey",t)}ir(e,t){if(t){const e=function(e,t){let n;if(t.document)n=Ai(e.ct,t.document,!!t.hasCommittedMutations);else if(t.noDocument){const e=z.fromSegments(t.noDocument.path),r=Hi(t.noDocument.readTime);n=$t.newNoDocument(e,r),t.hasCommittedMutations&&n.setHasCommittedMutations()}else{if(!t.unknownDocument)return v();{const e=z.fromSegments(t.unknownDocument.path),r=Hi(t.unknownDocument.version);n=$t.newUnknownDocument(e,r)}}return t.readTime&&n.setReadTime(function(e){const t=new F(e[0],e[1]);return V.fromTimestamp(t)}(t.readTime)),n}(this.serializer,t);if(!e.isNoDocument()||!e.version.isEqual(V.min()))return e}return $t.newInvalidDocument(e)}}function oo(e){return new so(e)}class ao extends io{constructor(e,t){super(),this.cr=e,this.trackRemovals=t,this.lr=new Kn((e=>e.toString()),((e,t)=>e.isEqual(t)))}applyChanges(e){const t=[];let n=0,r=new st(((e,t)=>P(e.canonicalString(),t.canonicalString())));return this.changes.forEach(((i,s)=>{const o=this.lr.get(i);if(t.push(this.cr.removeEntry(e,i,o.readTime)),s.isValidDocument()){const a=Ki(this.cr.serializer,s);r=r.add(i.path.popLast());const c=js(a);n+=c-o.size,t.push(this.cr.addEntry(e,i,a))}else if(n-=o.size,this.trackRemovals){const n=Ki(this.cr.serializer,s.convertToNoDocument(V.min()));t.push(this.cr.addEntry(e,i,n))}})),r.forEach((n=>{t.push(this.cr.indexManager.addToCollectionParentIndex(e,n))})),t.push(this.cr.updateMetadata(e,n)),ie.waitFor(t)}getFromCache(e,t){return this.cr.sr(e,t).next((e=>(this.lr.set(t,{size:e.size,readTime:e.document.readTime}),e.document)))}getAllFromCache(e,t){return this.cr.ar(e,t).next((({documents:e,ur:t})=>(t.forEach(((t,n)=>{this.lr.set(t,{size:n,readTime:e.get(t).readTime})})),e)))}}function co(e){return Ye(e,"remoteDocumentGlobal")}function uo(e){return Ye(e,"remoteDocumentsV14")}function lo(e){const t=e.path.toArray();return[t.slice(0,t.length-2),t[t.length-2],t[t.length-1]]}function ho(e,t){const n=t.documentKey.path.toArray();return[e,Wi(t.readTime),n.slice(0,n.length-2),n.length>0?n[n.length-1]:""]}function fo(e,t){const n=e.path.toArray(),r=t.path.toArray();let i=0;for(let e=0;e<n.length-2&&e<r.length-2;++e)if(i=P(n[e],r[e]),i)return i;return i=P(n.length,r.length),i||(i=P(n[n.length-2],r[r.length-2]),i||P(n[n.length-1],r[r.length-1]))}class po{constructor(e,t){this.overlayedDocument=e,this.mutatedFields=t}}class mo{constructor(e,t,n,r){this.remoteDocumentCache=e,this.mutationQueue=t,this.documentOverlayCache=n,this.indexManager=r}getDocument(e,t){let n=null;return this.documentOverlayCache.getOverlay(e,t).next((r=>(n=r,this.remoteDocumentCache.getEntry(e,t)))).next((e=>(null!==n&&Ar(n.mutation,e,ct.empty(),F.now()),e)))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next((t=>this.getLocalViewOfDocuments(e,t,nr()).next((()=>t))))}getLocalViewOfDocuments(e,t,n=nr()){const r=Yn();return this.populateOverlays(e,r,t).next((()=>this.computeViews(e,t,r,n).next((e=>{let t=Qn();return e.forEach(((e,n)=>{t=t.insert(e,n.overlayedDocument)})),t}))))}getOverlayedDocuments(e,t){const n=Yn();return this.populateOverlays(e,n,t).next((()=>this.computeViews(e,t,n,nr())))}populateOverlays(e,t,n){const r=[];return n.forEach((e=>{t.has(e)||r.push(e)})),this.documentOverlayCache.getOverlays(e,r).next((e=>{e.forEach(((e,n)=>{t.set(e,n)}))}))}computeViews(e,t,n,r){let i=$n();const s=Zn(),o=Zn();return t.forEach(((e,t)=>{const o=n.get(t.key);r.has(t.key)&&(void 0===o||o.mutation instanceof Or)?i=i.insert(t.key,t):void 0!==o?(s.set(t.key,o.mutation.getFieldMask()),Ar(o.mutation,t,o.mutation.getFieldMask(),F.now())):s.set(t.key,ct.empty())})),this.recalculateAndSaveOverlays(e,i).next((e=>(e.forEach(((e,t)=>s.set(e,t))),t.forEach(((e,t)=>{var n;return o.set(e,new po(t,null!==(n=s.get(e))&&void 0!==n?n:null))})),o)))}recalculateAndSaveOverlays(e,t){const n=Zn();let r=new nt(((e,t)=>e-t)),i=nr();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,t).next((e=>{for(const i of e)i.keys().forEach((e=>{const s=t.get(e);if(null===s)return;let o=n.get(e)||ct.empty();o=i.applyToLocalView(s,o),n.set(e,o);const a=(r.get(i.batchId)||nr()).add(e);r=r.insert(i.batchId,a)}))})).next((()=>{const s=[],o=r.getReverseIterator();for(;o.hasNext();){const r=o.getNext(),a=r.key,c=r.value,u=Xn();c.forEach((e=>{if(!i.has(e)){const r=Sr(t.get(e),n.get(e));null!==r&&u.set(e,r),i=i.add(e)}})),s.push(this.documentOverlayCache.saveOverlays(e,a,u))}return ie.waitFor(s)})).next((()=>n))}recalculateAndSaveOverlaysForDocumentKeys(e,t){return this.remoteDocumentCache.getEntries(e,t).next((t=>this.recalculateAndSaveOverlays(e,t)))}getDocumentsMatchingQuery(e,t,n,r){return function(e){return z.isDocumentKey(e.path)&&null===e.collectionGroup&&0===e.filters.length}(t)?this.getDocumentsMatchingDocumentQuery(e,t.path):On(t)?this.getDocumentsMatchingCollectionGroupQuery(e,t,n,r):this.getDocumentsMatchingCollectionQuery(e,t,n,r)}getNextDocuments(e,t,n,r){return this.remoteDocumentCache.getAllFromCollectionGroup(e,t,n,r).next((i=>{const s=r-i.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(e,t,n.largestBatchId,r-i.size):ie.resolve(Yn());let o=-1,a=i;return s.next((t=>ie.forEach(t,((t,n)=>(o<n.largestBatchId&&(o=n.largestBatchId),i.get(t)?ie.resolve():this.remoteDocumentCache.getEntry(e,t).next((e=>{a=a.insert(t,e)}))))).next((()=>this.populateOverlays(e,t,i))).next((()=>this.computeViews(e,a,t,nr()))).next((e=>({batchId:o,changes:Jn(e)})))))}))}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new z(t)).next((e=>{let t=Qn();return e.isFoundDocument()&&(t=t.insert(e.key,e)),t}))}getDocumentsMatchingCollectionGroupQuery(e,t,n,r){const i=t.collectionGroup;let s=Qn();return this.indexManager.getCollectionParents(e,i).next((o=>ie.forEach(o,(o=>{const a=function(e,t){return new An(t,null,e.explicitOrderBy.slice(),e.filters.slice(),e.limit,e.limitType,e.startAt,e.endAt)}(t,o.child(i));return this.getDocumentsMatchingCollectionQuery(e,a,n,r).next((e=>{e.forEach(((e,t)=>{s=s.insert(e,t)}))}))})).next((()=>s))))}getDocumentsMatchingCollectionQuery(e,t,n,r){let i;return this.documentOverlayCache.getOverlaysForCollection(e,t.path,n.largestBatchId).next((s=>(i=s,this.remoteDocumentCache.getDocumentsMatchingQuery(e,t,n,i,r)))).next((e=>{i.forEach(((t,n)=>{const r=n.getKey();null===e.get(r)&&(e=e.insert(r,$t.newInvalidDocument(r)))}));let n=Qn();return e.forEach(((e,r)=>{const s=i.get(e);void 0!==s&&Ar(s.mutation,r,ct.empty(),F.now()),Bn(t,r)&&(n=n.insert(e,r))})),n}))}}class go{constructor(e){this.serializer=e,this.hr=new Map,this.Pr=new Map}getBundleMetadata(e,t){return ie.resolve(this.hr.get(t))}saveBundleMetadata(e,t){return this.hr.set(t.id,function(e){return{id:e.id,version:e.version,createTime:gi(e.createTime)}}(t)),ie.resolve()}getNamedQuery(e,t){return ie.resolve(this.Pr.get(t))}saveNamedQuery(e,t){return this.Pr.set(t.name,function(e){return{name:e.name,query:Xi(e.bundledQuery),readTime:gi(e.readTime)}}(t)),ie.resolve()}}class yo{constructor(){this.overlays=new nt(z.comparator),this.Ir=new Map}getOverlay(e,t){return ie.resolve(this.overlays.get(t))}getOverlays(e,t){const n=Yn();return ie.forEach(t,(t=>this.getOverlay(e,t).next((e=>{null!==e&&n.set(t,e)})))).next((()=>n))}saveOverlays(e,t,n){return n.forEach(((n,r)=>{this.ht(e,t,r)})),ie.resolve()}removeOverlaysForBatchId(e,t,n){const r=this.Ir.get(n);return void 0!==r&&(r.forEach((e=>this.overlays=this.overlays.remove(e))),this.Ir.delete(n)),ie.resolve()}getOverlaysForCollection(e,t,n){const r=Yn(),i=t.length+1,s=new z(t.child("")),o=this.overlays.getIteratorFrom(s);for(;o.hasNext();){const e=o.getNext().value,s=e.getKey();if(!t.isPrefixOf(s.path))break;s.path.length===i&&e.largestBatchId>n&&r.set(e.getKey(),e)}return ie.resolve(r)}getOverlaysForCollectionGroup(e,t,n,r){let i=new nt(((e,t)=>e-t));const s=this.overlays.getIterator();for(;s.hasNext();){const e=s.getNext().value;if(e.getKey().getCollectionGroup()===t&&e.largestBatchId>n){let t=i.get(e.largestBatchId);null===t&&(t=Yn(),i=i.insert(e.largestBatchId,t)),t.set(e.getKey(),e)}}const o=Yn(),a=i.getIterator();for(;a.hasNext()&&(a.getNext().value.forEach(((e,t)=>o.set(e,t))),!(o.size()>=r)););return ie.resolve(o)}ht(e,t,n){const r=this.overlays.get(n.key);if(null!==r){const e=this.Ir.get(r.largestBatchId).delete(n.key);this.Ir.set(r.largestBatchId,e)}this.overlays=this.overlays.insert(n.key,new Ur(t,n));let i=this.Ir.get(t);void 0===i&&(i=nr(),this.Ir.set(t,i)),this.Ir.set(t,i.add(n.key))}}class vo{constructor(){this.sessionToken=lt.EMPTY_BYTE_STRING}getSessionToken(e){return ie.resolve(this.sessionToken)}setSessionToken(e,t){return this.sessionToken=t,ie.resolve()}}class bo{constructor(){this.Tr=new st(wo.Er),this.dr=new st(wo.Ar)}isEmpty(){return this.Tr.isEmpty()}addReference(e,t){const n=new wo(e,t);this.Tr=this.Tr.add(n),this.dr=this.dr.add(n)}Rr(e,t){e.forEach((e=>this.addReference(e,t)))}removeReference(e,t){this.Vr(new wo(e,t))}mr(e,t){e.forEach((e=>this.removeReference(e,t)))}gr(e){const t=new z(new j([])),n=new wo(t,e),r=new wo(t,e+1),i=[];return this.dr.forEachInRange([n,r],(e=>{this.Vr(e),i.push(e.key)})),i}pr(){this.Tr.forEach((e=>this.Vr(e)))}Vr(e){this.Tr=this.Tr.delete(e),this.dr=this.dr.delete(e)}yr(e){const t=new z(new j([])),n=new wo(t,e),r=new wo(t,e+1);let i=nr();return this.dr.forEachInRange([n,r],(e=>{i=i.add(e.key)})),i}containsKey(e){const t=new wo(e,0),n=this.Tr.firstAfterOrEqual(t);return null!==n&&e.isEqual(n.key)}}class wo{constructor(e,t){this.key=e,this.wr=t}static Er(e,t){return z.comparator(e.key,t.key)||P(e.wr,t.wr)}static Ar(e,t){return P(e.wr,t.wr)||z.comparator(e.key,t.key)}}class _o{constructor(e,t){this.indexManager=e,this.referenceDelegate=t,this.mutationQueue=[],this.Sr=1,this.br=new st(wo.Er)}checkEmpty(e){return ie.resolve(0===this.mutationQueue.length)}addMutationBatch(e,t,n,r){const i=this.Sr;this.Sr++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];const s=new Fr(i,t,n,r);this.mutationQueue.push(s);for(const t of r)this.br=this.br.add(new wo(t.key,i)),this.indexManager.addToCollectionParentIndex(e,t.key.path.popLast());return ie.resolve(s)}lookupMutationBatch(e,t){return ie.resolve(this.Dr(t))}getNextMutationBatchAfterBatchId(e,t){const n=t+1,r=this.vr(n),i=r<0?0:r;return ie.resolve(this.mutationQueue.length>i?this.mutationQueue[i]:null)}getHighestUnacknowledgedBatchId(){return ie.resolve(0===this.mutationQueue.length?-1:this.Sr-1)}getAllMutationBatches(e){return ie.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){const n=new wo(t,0),r=new wo(t,Number.POSITIVE_INFINITY),i=[];return this.br.forEachInRange([n,r],(e=>{const t=this.Dr(e.wr);i.push(t)})),ie.resolve(i)}getAllMutationBatchesAffectingDocumentKeys(e,t){let n=new st(P);return t.forEach((e=>{const t=new wo(e,0),r=new wo(e,Number.POSITIVE_INFINITY);this.br.forEachInRange([t,r],(e=>{n=n.add(e.wr)}))})),ie.resolve(this.Cr(n))}getAllMutationBatchesAffectingQuery(e,t){const n=t.path,r=n.length+1;let i=n;z.isDocumentKey(i)||(i=i.child(""));const s=new wo(new z(i),0);let o=new st(P);return this.br.forEachWhile((e=>{const t=e.key.path;return!!n.isPrefixOf(t)&&(t.length===r&&(o=o.add(e.wr)),!0)}),s),ie.resolve(this.Cr(o))}Cr(e){const t=[];return e.forEach((e=>{const n=this.Dr(e);null!==n&&t.push(n)})),t}removeMutationBatch(e,t){b(0===this.Fr(t.batchId,"removed")),this.mutationQueue.shift();let n=this.br;return ie.forEach(t.mutations,(r=>{const i=new wo(r.key,t.batchId);return n=n.delete(i),this.referenceDelegate.markPotentiallyOrphaned(e,r.key)})).next((()=>{this.br=n}))}On(e){}containsKey(e,t){const n=new wo(t,0),r=this.br.firstAfterOrEqual(n);return ie.resolve(t.isEqual(r&&r.key))}performConsistencyCheck(e){return this.mutationQueue.length,ie.resolve()}Fr(e,t){return this.vr(e)}vr(e){return 0===this.mutationQueue.length?0:e-this.mutationQueue[0].batchId}Dr(e){const t=this.vr(e);return t<0||t>=this.mutationQueue.length?null:this.mutationQueue[t]}}class Io{constructor(e){this.Mr=e,this.docs=new nt(z.comparator),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,t){const n=t.key,r=this.docs.get(n),i=r?r.size:0,s=this.Mr(t);return this.docs=this.docs.insert(n,{document:t.mutableCopy(),size:s}),this.size+=s-i,this.indexManager.addToCollectionParentIndex(e,n.path.popLast())}removeEntry(e){const t=this.docs.get(e);t&&(this.docs=this.docs.remove(e),this.size-=t.size)}getEntry(e,t){const n=this.docs.get(t);return ie.resolve(n?n.document.mutableCopy():$t.newInvalidDocument(t))}getEntries(e,t){let n=$n();return t.forEach((e=>{const t=this.docs.get(e);n=n.insert(e,t?t.document.mutableCopy():$t.newInvalidDocument(e))})),ie.resolve(n)}getDocumentsMatchingQuery(e,t,n,r){let i=$n();const s=t.path,o=new z(s.child("")),a=this.docs.getIteratorFrom(o);for(;a.hasNext();){const{key:e,value:{document:o}}=a.getNext();if(!s.isPrefixOf(e.path))break;e.path.length>s.length+1||ee(X(o),n)<=0||(r.has(o.key)||Bn(t,o))&&(i=i.insert(o.key,o.mutableCopy()))}return ie.resolve(i)}getAllFromCollectionGroup(e,t,n,r){v()}Or(e,t){return ie.forEach(this.docs,(e=>t(e)))}newChangeBuffer(e){return new Eo(this)}getSize(e){return ie.resolve(this.size)}}class Eo extends io{constructor(e){super(),this.cr=e}applyChanges(e){const t=[];return this.changes.forEach(((n,r)=>{r.isValidDocument()?t.push(this.cr.addEntry(e,r)):this.cr.removeEntry(n)})),ie.waitFor(t)}getFromCache(e,t){return this.cr.getEntry(e,t)}getAllFromCache(e,t){return this.cr.getEntries(e,t)}}class To{constructor(e){this.persistence=e,this.Nr=new Kn((e=>_n(e)),In),this.lastRemoteSnapshotVersion=V.min(),this.highestTargetId=0,this.Lr=0,this.Br=new bo,this.targetCount=0,this.kr=Ws.Bn()}forEachTarget(e,t){return this.Nr.forEach(((e,n)=>t(n))),ie.resolve()}getLastRemoteSnapshotVersion(e){return ie.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return ie.resolve(this.Lr)}allocateTargetId(e){return this.highestTargetId=this.kr.next(),ie.resolve(this.highestTargetId)}setTargetsMetadata(e,t,n){return n&&(this.lastRemoteSnapshotVersion=n),t>this.Lr&&(this.Lr=t),ie.resolve()}Kn(e){this.Nr.set(e.target,e);const t=e.targetId;t>this.highestTargetId&&(this.kr=new Ws(t),this.highestTargetId=t),e.sequenceNumber>this.Lr&&(this.Lr=e.sequenceNumber)}addTargetData(e,t){return this.Kn(t),this.targetCount+=1,ie.resolve()}updateTargetData(e,t){return this.Kn(t),ie.resolve()}removeTargetData(e,t){return this.Nr.delete(t.target),this.Br.gr(t.targetId),this.targetCount-=1,ie.resolve()}removeTargets(e,t,n){let r=0;const i=[];return this.Nr.forEach(((s,o)=>{o.sequenceNumber<=t&&null===n.get(o.targetId)&&(this.Nr.delete(s),i.push(this.removeMatchingKeysForTargetId(e,o.targetId)),r++)})),ie.waitFor(i).next((()=>r))}getTargetCount(e){return ie.resolve(this.targetCount)}getTargetData(e,t){const n=this.Nr.get(t)||null;return ie.resolve(n)}addMatchingKeys(e,t,n){return this.Br.Rr(t,n),ie.resolve()}removeMatchingKeys(e,t,n){this.Br.mr(t,n);const r=this.persistence.referenceDelegate,i=[];return r&&t.forEach((t=>{i.push(r.markPotentiallyOrphaned(e,t))})),ie.waitFor(i)}removeMatchingKeysForTargetId(e,t){return this.Br.gr(t),ie.resolve()}getMatchingKeysForTargetId(e,t){const n=this.Br.yr(t);return ie.resolve(n)}containsKey(e,t){return ie.resolve(this.Br.containsKey(t))}}class So{constructor(e,t){this.qr={},this.overlays={},this.Qr=new ye(0),this.Kr=!1,this.Kr=!0,this.$r=new vo,this.referenceDelegate=e(this),this.Ur=new To(this),this.indexManager=new xs,this.remoteDocumentCache=function(e){return new Io(e)}((e=>this.referenceDelegate.Wr(e))),this.serializer=new Gi(t),this.Gr=new go(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.Kr=!1,Promise.resolve()}get started(){return this.Kr}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let t=this.overlays[e.toKey()];return t||(t=new yo,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let n=this.qr[e.toKey()];return n||(n=new _o(t,this.referenceDelegate),this.qr[e.toKey()]=n),n}getGlobalsCache(){return this.$r}getTargetCache(){return this.Ur}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Gr}runTransaction(e,t,n){p("MemoryPersistence","Starting transaction:",e);const r=new Co(this.Qr.next());return this.referenceDelegate.zr(),n(r).next((e=>this.referenceDelegate.jr(r).next((()=>e)))).toPromise().then((e=>(r.raiseOnCommittedEvent(),e)))}Hr(e,t){return ie.or(Object.values(this.qr).map((n=>()=>n.containsKey(e,t))))}}class Co extends ne{constructor(e){super(),this.currentSequenceNumber=e}}class Ao{constructor(e){this.persistence=e,this.Jr=new bo,this.Yr=null}static Zr(e){return new Ao(e)}get Xr(){if(this.Yr)return this.Yr;throw v()}addReference(e,t,n){return this.Jr.addReference(n,t),this.Xr.delete(n.toString()),ie.resolve()}removeReference(e,t,n){return this.Jr.removeReference(n,t),this.Xr.add(n.toString()),ie.resolve()}markPotentiallyOrphaned(e,t){return this.Xr.add(t.toString()),ie.resolve()}removeTarget(e,t){this.Jr.gr(t.targetId).forEach((e=>this.Xr.add(e.toString())));const n=this.persistence.getTargetCache();return n.getMatchingKeysForTargetId(e,t.targetId).next((e=>{e.forEach((e=>this.Xr.add(e.toString())))})).next((()=>n.removeTargetData(e,t)))}zr(){this.Yr=new Set}jr(e){const t=this.persistence.getRemoteDocumentCache().newChangeBuffer();return ie.forEach(this.Xr,(n=>{const r=z.fromPath(n);return this.ei(e,r).next((e=>{e||t.removeEntry(r,V.min())}))})).next((()=>(this.Yr=null,t.apply(e))))}updateLimboDocument(e,t){return this.ei(e,t).next((e=>{e?this.Xr.delete(t.toString()):this.Xr.add(t.toString())}))}Wr(e){return 0}ei(e,t){return ie.or([()=>ie.resolve(this.Jr.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.Hr(e,t)])}}class xo{constructor(e,t){this.persistence=e,this.ti=new Kn((e=>_e(e.path)),((e,t)=>e.isEqual(t))),this.garbageCollector=to(this,t)}static Zr(e,t){return new xo(e,t)}zr(){}jr(e){return ie.resolve()}forEachTarget(e,t){return this.persistence.getTargetCache().forEachTarget(e,t)}Yn(e){const t=this.er(e);return this.persistence.getTargetCache().getTargetCount(e).next((e=>t.next((t=>e+t))))}er(e){let t=0;return this.Zn(e,(e=>{t++})).next((()=>t))}Zn(e,t){return ie.forEach(this.ti,((n,r)=>this.nr(e,n,r).next((e=>e?ie.resolve():t(r)))))}removeTargets(e,t,n){return this.persistence.getTargetCache().removeTargets(e,t,n)}removeOrphanedDocuments(e,t){let n=0;const r=this.persistence.getRemoteDocumentCache(),i=r.newChangeBuffer();return r.Or(e,(r=>this.nr(e,r,t).next((e=>{e||(n++,i.removeEntry(r,V.min()))})))).next((()=>i.apply(e))).next((()=>n))}markPotentiallyOrphaned(e,t){return this.ti.set(t,e.currentSequenceNumber),ie.resolve()}removeTarget(e,t){const n=t.withSequenceNumber(e.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(e,n)}addReference(e,t,n){return this.ti.set(n,e.currentSequenceNumber),ie.resolve()}removeReference(e,t,n){return this.ti.set(n,e.currentSequenceNumber),ie.resolve()}updateLimboDocument(e,t){return this.ti.set(t,e.currentSequenceNumber),ie.resolve()}Wr(e){let t=e.key.toString().length;return e.isFoundDocument()&&(t+=Nt(e.data.value)),t}nr(e,t,n){return ie.or([()=>this.persistence.Hr(e,t),()=>this.persistence.getTargetCache().containsKey(e,t),()=>{const e=this.ti.get(t);return ie.resolve(void 0!==e&&e>n)}])}getCacheSize(e){return this.persistence.getRemoteDocumentCache().getSize(e)}}class ko{constructor(e){this.serializer=e}O(e,t,n,r){const i=new se("createOrUpgrade",t);n<1&&r>=1&&(function(e){e.createObjectStore("owner")}(e),function(e){e.createObjectStore("mutationQueues",{keyPath:"userId"}),e.createObjectStore("mutations",{keyPath:"batchId",autoIncrement:!0}).createIndex("userMutationsIndex",Se,{unique:!0}),e.createObjectStore("documentMutations")}(e),No(e),function(e){e.createObjectStore("remoteDocuments")}(e));let s=ie.resolve();return n<3&&r>=3&&(0!==n&&(function(e){e.deleteObjectStore("targetDocuments"),e.deleteObjectStore("targets"),e.deleteObjectStore("targetGlobal")}(e),No(e)),s=s.next((()=>function(e){const t=e.store("targetGlobal"),n={highestTargetId:0,highestListenSequenceNumber:0,lastRemoteSnapshotVersion:V.min().toTimestamp(),targetCount:0};return t.put("targetGlobalKey",n)}(i)))),n<4&&r>=4&&(0!==n&&(s=s.next((()=>function(e,t){return t.store("mutations").U().next((n=>{e.deleteObjectStore("mutations"),e.createObjectStore("mutations",{keyPath:"batchId",autoIncrement:!0}).createIndex("userMutationsIndex",Se,{unique:!0});const r=t.store("mutations"),i=n.map((e=>r.put(e)));return ie.waitFor(i)}))}(e,i)))),s=s.next((()=>{!function(e){e.createObjectStore("clientMetadata",{keyPath:"clientId"})}(e)}))),n<5&&r>=5&&(s=s.next((()=>this.ni(i)))),n<6&&r>=6&&(s=s.next((()=>(function(e){e.createObjectStore("remoteDocumentGlobal")}(e),this.ri(i))))),n<7&&r>=7&&(s=s.next((()=>this.ii(i)))),n<8&&r>=8&&(s=s.next((()=>this.si(e,i)))),n<9&&r>=9&&(s=s.next((()=>{!function(e){e.objectStoreNames.contains("remoteDocumentChanges")&&e.deleteObjectStore("remoteDocumentChanges")}(e)}))),n<10&&r>=10&&(s=s.next((()=>this.oi(i)))),n<11&&r>=11&&(s=s.next((()=>{!function(e){e.createObjectStore("bundles",{keyPath:"bundleId"})}(e),function(e){e.createObjectStore("namedQueries",{keyPath:"name"})}(e)}))),n<12&&r>=12&&(s=s.next((()=>{!function(e){const t=e.createObjectStore("documentOverlays",{keyPath:je});t.createIndex("collectionPathOverlayIndex",Be,{unique:!1}),t.createIndex("collectionGroupOverlayIndex",qe,{unique:!1})}(e)}))),n<13&&r>=13&&(s=s.next((()=>function(e){const t=e.createObjectStore("remoteDocumentsV14",{keyPath:ke});t.createIndex("documentKeyIndex",Ne),t.createIndex("collectionGroupIndex",Oe)}(e))).next((()=>this._i(e,i))).next((()=>e.deleteObjectStore("remoteDocuments")))),n<14&&r>=14&&(s=s.next((()=>this.ai(e,i)))),n<15&&r>=15&&(s=s.next((()=>function(e){e.createObjectStore("indexConfiguration",{keyPath:"indexId",autoIncrement:!0}).createIndex("collectionGroupIndex","collectionGroup",{unique:!1}),e.createObjectStore("indexState",{keyPath:Me}).createIndex("sequenceNumberIndex",Fe,{unique:!1}),e.createObjectStore("indexEntries",{keyPath:Ve}).createIndex("documentKeyIndex",Ue,{unique:!1})}(e)))),n<16&&r>=16&&(s=s.next((()=>{t.objectStore("indexState").clear()})).next((()=>{t.objectStore("indexEntries").clear()}))),n<17&&r>=17&&(s=s.next((()=>{!function(e){e.createObjectStore("globals",{keyPath:"name"})}(e)}))),s}ri(e){let t=0;return e.store("remoteDocuments").J(((e,n)=>{t+=js(n)})).next((()=>{const n={byteSize:t};return e.store("remoteDocumentGlobal").put("remoteDocumentGlobalKey",n)}))}ni(e){const t=e.store("mutationQueues"),n=e.store("mutations");return t.U().next((t=>ie.forEach(t,(t=>{const r=IDBKeyRange.bound([t.userId,-1],[t.userId,t.lastAcknowledgedBatchId]);return n.U("userMutationsIndex",r).next((n=>ie.forEach(n,(n=>{b(n.userId===t.userId);const r=Qi(this.serializer,n);return Us(e,t.userId,r).next((()=>{}))}))))}))))}ii(e){const t=e.store("targetDocuments"),n=e.store("remoteDocuments");return e.store("targetGlobal").get("targetGlobalKey").next((e=>{const r=[];return n.J(((n,i)=>{const s=new j(n),o=function(e){return[0,_e(e)]}(s);r.push(t.get(o).next((n=>n?ie.resolve():(n=>t.put({targetId:0,path:_e(n),sequenceNumber:e.highestListenSequenceNumber}))(s))))})).next((()=>ie.waitFor(r)))}))}si(e,t){e.createObjectStore("collectionParents",{keyPath:Le});const n=t.store("collectionParents"),r=new ks,i=e=>{if(r.add(e)){const t=e.lastSegment(),r=e.popLast();return n.put({collectionId:t,parent:_e(r)})}};return t.store("remoteDocuments").J({H:!0},((e,t)=>{const n=new j(e);return i(n.popLast())})).next((()=>t.store("documentMutations").J({H:!0},(([e,t,n],r)=>{const s=Te(t);return i(s.popLast())}))))}oi(e){const t=e.store("targets");return t.J(((e,n)=>{const r=Ji(n),i=Yi(this.serializer,r);return t.put(i)}))}_i(e,t){const n=t.store("remoteDocuments"),r=[];return n.J(((e,n)=>{const i=t.store("remoteDocumentsV14"),s=function(e){return e.document?new z(j.fromString(e.document.name).popFirst(5)):e.noDocument?z.fromSegments(e.noDocument.path):e.unknownDocument?z.fromSegments(e.unknownDocument.path):v()}(n).path.toArray(),o={prefixPath:s.slice(0,s.length-2),collectionGroup:s[s.length-2],documentId:s[s.length-1],readTime:n.readTime||[0,0],unknownDocument:n.unknownDocument,noDocument:n.noDocument,document:n.document,hasCommittedMutations:!!n.hasCommittedMutations};r.push(i.put(o))})).next((()=>ie.waitFor(r)))}ai(e,t){const n=t.store("mutations"),r=oo(this.serializer),i=new So(Ao.Zr,this.serializer.ct);return n.U().next((e=>{const n=new Map;return e.forEach((e=>{var t;let r=null!==(t=n.get(e.userId))&&void 0!==t?t:nr();Qi(this.serializer,e).keys().forEach((e=>r=r.add(e))),n.set(e.userId,r)})),ie.forEach(n,((e,n)=>{const s=new l(n),o=ss.lt(this.serializer,s),a=i.getIndexManager(s),c=Bs.lt(s,this.serializer,a,i.referenceDelegate);return new mo(r,c,o,a).recalculateAndSaveOverlaysForDocumentKeys(new Je(t,ye.oe),e).next()}))}))}}function No(e){e.createObjectStore("targetDocuments",{keyPath:Re}).createIndex("documentTargetsIndex",Pe,{unique:!0}),e.createObjectStore("targets",{keyPath:"targetId"}).createIndex("queryTargetsIndex",De,{unique:!0}),e.createObjectStore("targetGlobal")}const Oo="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 Do{constructor(e,t,n,r,i,s,o,a,c,u,l=17){if(this.allowTabSynchronization=e,this.persistenceKey=t,this.clientId=n,this.ui=i,this.window=s,this.document=o,this.ci=c,this.li=u,this.hi=l,this.Qr=null,this.Kr=!1,this.isPrimary=!1,this.networkEnabled=!0,this.Pi=null,this.inForeground=!1,this.Ii=null,this.Ti=null,this.Ei=Number.NEGATIVE_INFINITY,this.di=e=>Promise.resolve(),!Do.D())throw new I(_.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");this.referenceDelegate=new no(this,r),this.Ai=t+"main",this.serializer=new Gi(a),this.Ri=new oe(this.Ai,this.hi,new ko(this.serializer)),this.$r=new as,this.Ur=new $s(this.referenceDelegate,this.serializer),this.remoteDocumentCache=oo(this.serializer),this.Gr=new ns,this.window&&this.window.localStorage?this.Vi=this.window.localStorage:(this.Vi=null,!1===u&&m("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.mi().then((()=>{if(!this.isPrimary&&!this.allowTabSynchronization)throw new I(_.FAILED_PRECONDITION,Oo);return this.fi(),this.gi(),this.pi(),this.runTransaction("getHighestListenSequenceNumber","readonly",(e=>this.Ur.getHighestSequenceNumber(e)))})).then((e=>{this.Qr=new ye(e,this.ci)})).then((()=>{this.Kr=!0})).catch((e=>(this.Ri&&this.Ri.close(),Promise.reject(e))))}yi(e){return this.di=async t=>{if(this.started)return e(t)},e(this.isPrimary)}setDatabaseDeletedListener(e){this.Ri.L((async t=>{null===t.newVersion&&await e()}))}setNetworkEnabled(e){this.networkEnabled!==e&&(this.networkEnabled=e,this.ui.enqueueAndForget((async()=>{this.started&&await this.mi()})))}mi(){return this.runTransaction("updateClientMetadataAndTryBecomePrimary","readwrite",(e=>Po(e).put({clientId:this.clientId,updateTimeMs:Date.now(),networkEnabled:this.networkEnabled,inForeground:this.inForeground}).next((()=>{if(this.isPrimary)return this.wi(e).next((e=>{e||(this.isPrimary=!1,this.ui.enqueueRetryable((()=>this.di(!1))))}))})).next((()=>this.Si(e))).next((t=>this.isPrimary&&!t?this.bi(e).next((()=>!1)):!!t&&this.Di(e).next((()=>!0)))))).catch((e=>{if(le(e))return p("IndexedDbPersistence","Failed to extend owner lease: ",e),this.isPrimary;if(!this.allowTabSynchronization)throw e;return p("IndexedDbPersistence","Releasing owner lease after error during lease refresh",e),!1})).then((e=>{this.isPrimary!==e&&this.ui.enqueueRetryable((()=>this.di(e))),this.isPrimary=e}))}wi(e){return Ro(e).get("owner").next((e=>ie.resolve(this.vi(e))))}Ci(e){return Po(e).delete(this.clientId)}async Fi(){if(this.isPrimary&&!this.Mi(this.Ei,18e5)){this.Ei=Date.now();const e=await this.runTransaction("maybeGarbageCollectMultiClientState","readwrite-primary",(e=>{const t=Ye(e,"clientMetadata");return t.U().next((e=>{const n=this.xi(e,18e5),r=e.filter((e=>-1===n.indexOf(e)));return ie.forEach(r,(e=>t.delete(e.clientId))).next((()=>r))}))})).catch((()=>[]));if(this.Vi)for(const t of e)this.Vi.removeItem(this.Oi(t.clientId))}}pi(){this.Ti=this.ui.enqueueAfterDelay("client_metadata_refresh",4e3,(()=>this.mi().then((()=>this.Fi())).then((()=>this.pi()))))}vi(e){return!!e&&e.ownerId===this.clientId}Si(e){return this.li?ie.resolve(!0):Ro(e).get("owner").next((t=>{if(null!==t&&this.Mi(t.leaseTimestampMs,5e3)&&!this.Ni(t.ownerId)){if(this.vi(t)&&this.networkEnabled)return!0;if(!this.vi(t)){if(!t.allowTabSynchronization)throw new I(_.FAILED_PRECONDITION,Oo);return!1}}return!(!this.networkEnabled||!this.inForeground)||Po(e).U().next((e=>void 0===this.xi(e,5e3).find((e=>{if(this.clientId!==e.clientId){const t=!this.networkEnabled&&e.networkEnabled,n=!this.inForeground&&e.inForeground,r=this.networkEnabled===e.networkEnabled;if(t||n&&r)return!0}return!1}))))})).next((e=>(this.isPrimary!==e&&p("IndexedDbPersistence",`Client ${e?"is":"is not"} eligible for a primary lease.`),e)))}async shutdown(){this.Kr=!1,this.Li(),this.Ti&&(this.Ti.cancel(),this.Ti=null),this.Bi(),this.ki(),await this.Ri.runTransaction("shutdown","readwrite",["owner","clientMetadata"],(e=>{const t=new Je(e,ye.oe);return this.bi(t).next((()=>this.Ci(t)))})),this.Ri.close(),this.qi()}xi(e,t){return e.filter((e=>this.Mi(e.updateTimeMs,t)&&!this.Ni(e.clientId)))}Qi(){return this.runTransaction("getActiveClients","readonly",(e=>Po(e).U().next((e=>this.xi(e,18e5).map((e=>e.clientId))))))}get started(){return this.Kr}getGlobalsCache(){return this.$r}getMutationQueue(e,t){return Bs.lt(e,this.serializer,t,this.referenceDelegate)}getTargetCache(){return this.Ur}getRemoteDocumentCache(){return this.remoteDocumentCache}getIndexManager(e){return new Os(e,this.serializer.ct.databaseId)}getDocumentOverlayCache(e){return ss.lt(this.serializer,e)}getBundleCache(){return this.Gr}runTransaction(e,t,n){p("IndexedDbPersistence","Starting transaction:",e);const r="readonly"===t?"readonly":"readwrite",i=function(e){return 17===e?Qe:16===e?He:15===e?$e:14===e?We:13===e?Ke:12===e?Ge:11===e?ze:void v()}(this.hi);let s;return this.Ri.runTransaction(e,r,i,(r=>(s=new Je(r,this.Qr?this.Qr.next():ye.oe),"readwrite-primary"===t?this.wi(s).next((e=>!!e||this.Si(s))).next((t=>{if(!t)throw m(`Failed to obtain primary lease for action '${e}'.`),this.isPrimary=!1,this.ui.enqueueRetryable((()=>this.di(!1))),new I(_.FAILED_PRECONDITION,te);return n(s)})).next((e=>this.Di(s).next((()=>e)))):this.Ki(s).next((()=>n(s)))))).then((e=>(s.raiseOnCommittedEvent(),e)))}Ki(e){return Ro(e).get("owner").next((e=>{if(null!==e&&this.Mi(e.leaseTimestampMs,5e3)&&!this.Ni(e.ownerId)&&!this.vi(e)&&!(this.li||this.allowTabSynchronization&&e.allowTabSynchronization))throw new I(_.FAILED_PRECONDITION,Oo)}))}Di(e){const t={ownerId:this.clientId,allowTabSynchronization:this.allowTabSynchronization,leaseTimestampMs:Date.now()};return Ro(e).put("owner",t)}static D(){return oe.D()}bi(e){const t=Ro(e);return t.get("owner").next((e=>this.vi(e)?(p("IndexedDbPersistence","Releasing primary lease."),t.delete("owner")):ie.resolve()))}Mi(e,t){const n=Date.now();return!(e<n-t||e>n&&(m(`Detected an update time that is in the future: ${e} > ${n}`),1))}fi(){null!==this.document&&"function"==typeof this.document.addEventListener&&(this.Ii=()=>{this.ui.enqueueAndForget((()=>(this.inForeground="visible"===this.document.visibilityState,this.mi())))},this.document.addEventListener("visibilitychange",this.Ii),this.inForeground="visible"===this.document.visibilityState)}Bi(){this.Ii&&(this.document.removeEventListener("visibilitychange",this.Ii),this.Ii=null)}gi(){var e;"function"==typeof(null===(e=this.window)||void 0===e?void 0:e.addEventListener)&&(this.Pi=()=>{this.Li();const e=/(?:Version|Mobile)\/1[456]/;o.isSafari()&&(navigator.appVersion.match(e)||navigator.userAgent.match(e))&&this.ui.enterRestrictedMode(!0),this.ui.enqueueAndForget((()=>this.shutdown()))},this.window.addEventListener("pagehide",this.Pi))}ki(){this.Pi&&(this.window.removeEventListener("pagehide",this.Pi),this.Pi=null)}Ni(e){var t;try{const n=null!==(null===(t=this.Vi)||void 0===t?void 0:t.getItem(this.Oi(e)));return p("IndexedDbPersistence",`Client '${e}' ${n?"is":"is not"} zombied in LocalStorage`),n}catch(e){return m("IndexedDbPersistence","Failed to get zombied client id.",e),!1}}Li(){if(this.Vi)try{this.Vi.setItem(this.Oi(this.clientId),String(Date.now()))}catch(e){m("Failed to set zombie client id.",e)}}qi(){if(this.Vi)try{this.Vi.removeItem(this.Oi(this.clientId))}catch(e){}}Oi(e){return`firestore_zombie_${this.persistenceKey}_${e}`}}function Ro(e){return Ye(e,"owner")}function Po(e){return Ye(e,"clientMetadata")}function Lo(e,t){let n=e.projectId;return e.isDefaultDatabase||(n+="."+e.database),"firestore/"+t+"/"+n+"/"}class Mo{constructor(e,t,n,r){this.targetId=e,this.fromCache=t,this.$i=n,this.Ui=r}static Wi(e,t){let n=nr(),r=nr();for(const e of t.docChanges)switch(e.type){case 0:n=n.add(e.doc.key);break;case 1:r=r.add(e.doc.key)}return new Mo(e,t.fromCache,n,r)}}class Fo{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(e){this._documentReadCount+=e}}class Vo{constructor(){this.Gi=!1,this.zi=!1,this.ji=100,this.Hi=o.isSafari()?8:ae(o.getUA())>0?6:4}initialize(e,t){this.Ji=e,this.indexManager=t,this.Gi=!0}getDocumentsMatchingQuery(e,t,n,r){const i={result:null};return this.Yi(e,t).next((e=>{i.result=e})).next((()=>{if(!i.result)return this.Zi(e,t,r,n).next((e=>{i.result=e}))})).next((()=>{if(i.result)return;const n=new Fo;return this.Xi(e,t,n).next((r=>{if(i.result=r,this.zi)return this.es(e,t,n,r.size)}))})).next((()=>i.result))}es(e,t,n,r){return n.documentReadCount<this.ji?(f()<=s.LogLevel.DEBUG&&p("QueryEngine","SDK will not create cache indexes for query:",jn(t),"since it only creates cache indexes for collection contains","more than or equal to",this.ji,"documents"),ie.resolve()):(f()<=s.LogLevel.DEBUG&&p("QueryEngine","Query:",jn(t),"scans",n.documentReadCount,"local documents and returns",r,"documents as results."),n.documentReadCount>this.Hi*r?(f()<=s.LogLevel.DEBUG&&p("QueryEngine","The SDK decides to create cache indexes for query:",jn(t),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(e,Rn(t))):ie.resolve())}Yi(e,t){if(Nn(t))return ie.resolve(null);let n=Rn(t);return this.indexManager.getIndexType(e,n).next((r=>0===r?null:(null!==t.limit&&1===r&&(t=Fn(t,null,"F"),n=Rn(t)),this.indexManager.getDocumentsMatchingTarget(e,n).next((r=>{const i=nr(...r);return this.Ji.getDocuments(e,i).next((r=>this.indexManager.getMinOffset(e,n).next((n=>{const s=this.ts(t,r);return this.ns(t,s,i,n.readTime)?this.Yi(e,Fn(t,null,"F")):this.rs(e,s,t,n)}))))})))))}Zi(e,t,n,r){return Nn(t)||r.isEqual(V.min())?ie.resolve(null):this.Ji.getDocuments(e,n).next((i=>{const o=this.ts(t,i);return this.ns(t,o,n,r)?ie.resolve(null):(f()<=s.LogLevel.DEBUG&&p("QueryEngine","Re-using previous result from %s to execute query: %s",r.toString(),jn(t)),this.rs(e,o,t,Y(r,-1)).next((e=>e)))}))}ts(e,t){let n=new st(zn(e));return t.forEach(((t,r)=>{Bn(e,r)&&(n=n.add(r))})),n}ns(e,t,n,r){if(null===e.limit)return!1;if(n.size!==t.size)return!0;const i="F"===e.limitType?t.last():t.first();return!!i&&(i.hasPendingWrites||i.version.compareTo(r)>0)}Xi(e,t,n){return f()<=s.LogLevel.DEBUG&&p("QueryEngine","Using full collection scan to execute query:",jn(t)),this.Ji.getDocumentsMatchingQuery(e,t,Z.min(),n)}rs(e,t,n,r){return this.Ji.getDocumentsMatchingQuery(e,n,r).next((e=>(t.forEach((t=>{e=e.insert(t.key,t)})),e)))}}class Uo{constructor(e,t,n,r){this.persistence=e,this.ss=t,this.serializer=r,this.os=new nt(P),this._s=new Kn((e=>_n(e)),In),this.us=new Map,this.cs=e.getRemoteDocumentCache(),this.Ur=e.getTargetCache(),this.Gr=e.getBundleCache(),this.ls(n)}ls(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new mo(this.cs,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.cs.setIndexManager(this.indexManager),this.ss.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction("Collect garbage","readwrite-primary",(t=>e.collect(t,this.os)))}}function jo(e,t,n,r){return new Uo(e,t,n,r)}async function Bo(e,t){const n=w(e);return await n.persistence.runTransaction("Handle user change","readonly",(e=>{let r;return n.mutationQueue.getAllMutationBatches(e).next((i=>(r=i,n.ls(t),n.mutationQueue.getAllMutationBatches(e)))).next((t=>{const i=[],s=[];let o=nr();for(const e of r){i.push(e.batchId);for(const t of e.mutations)o=o.add(t.key)}for(const e of t){s.push(e.batchId);for(const t of e.mutations)o=o.add(t.key)}return n.localDocuments.getDocuments(e,o).next((e=>({hs:e,removedBatchIds:i,addedBatchIds:s})))}))}))}function qo(e){const t=w(e);return t.persistence.runTransaction("Get last remote snapshot version","readonly",(e=>t.Ur.getLastRemoteSnapshotVersion(e)))}function zo(e,t,n){let r=nr(),i=nr();return n.forEach((e=>r=r.add(e))),t.getEntries(e,r).next((e=>{let r=$n();return n.forEach(((n,s)=>{const o=e.get(n);s.isFoundDocument()!==o.isFoundDocument()&&(i=i.add(n)),s.isNoDocument()&&s.version.isEqual(V.min())?(t.removeEntry(n,s.readTime),r=r.insert(n,s)):!o.isValidDocument()||s.version.compareTo(o.version)>0||0===s.version.compareTo(o.version)&&o.hasPendingWrites?(t.addEntry(s),r=r.insert(n,s)):p("LocalStore","Ignoring outdated watch update for ",n,". Current version:",o.version," Watch version:",s.version)})),{Ps:r,Is:i}}))}function Go(e,t){const n=w(e);return n.persistence.runTransaction("Get next mutation batch","readonly",(e=>(void 0===t&&(t=-1),n.mutationQueue.getNextMutationBatchAfterBatchId(e,t))))}function Ko(e,t){const n=w(e);return n.persistence.runTransaction("Allocate target","readwrite",(e=>{let r;return n.Ur.getTargetData(e,t).next((i=>i?(r=i,ie.resolve(r)):n.Ur.allocateTargetId(e).next((i=>(r=new zi(t,i,"TargetPurposeListen",e.currentSequenceNumber),n.Ur.addTargetData(e,r).next((()=>r)))))))})).then((e=>{const r=n.os.get(e.targetId);return(null===r||e.snapshotVersion.compareTo(r.snapshotVersion)>0)&&(n.os=n.os.insert(e.targetId,e),n._s.set(t,e.targetId)),e}))}async function Wo(e,t,n){const r=w(e),i=r.os.get(t),s=n?"readwrite":"readwrite-primary";try{n||await r.persistence.runTransaction("Release target",s,(e=>r.persistence.referenceDelegate.removeTarget(e,i)))}catch(e){if(!le(e))throw e;p("LocalStore",`Failed to update sequence numbers for target ${t}: ${e}`)}r.os=r.os.remove(t),r._s.delete(i.target)}function $o(e,t,n){const r=w(e);let i=V.min(),s=nr();return r.persistence.runTransaction("Execute query","readwrite",(e=>function(e,t,n){const r=w(e),i=r._s.get(n);return void 0!==i?ie.resolve(r.os.get(i)):r.Ur.getTargetData(t,n)}(r,e,Rn(t)).next((t=>{if(t)return i=t.lastLimboFreeSnapshotVersion,r.Ur.getMatchingKeysForTargetId(e,t.targetId).next((e=>{s=e}))})).next((()=>r.ss.getDocumentsMatchingQuery(e,t,n?i:V.min(),n?s:nr()))).next((e=>(Jo(r,qn(t),e),{documents:e,Ts:s})))))}function Ho(e,t){const n=w(e),r=w(n.Ur),i=n.os.get(t);return i?Promise.resolve(i.target):n.persistence.runTransaction("Get target data","readonly",(e=>r.ot(e,t).next((e=>e?e.target:null))))}function Qo(e,t){const n=w(e),r=n.us.get(t)||V.min();return n.persistence.runTransaction("Get new document changes","readonly",(e=>n.cs.getAllFromCollectionGroup(e,t,Y(r,-1),Number.MAX_SAFE_INTEGER))).then((e=>(Jo(n,t,e),e)))}function Jo(e,t,n){let r=e.us.get(t)||V.min();n.forEach(((e,t)=>{t.readTime.compareTo(r)>0&&(r=t.readTime)})),e.us.set(t,r)}async function Yo(e,t,n=nr()){const r=await Ko(e,Rn(Xi(t.bundledQuery))),i=w(e);return i.persistence.runTransaction("Save named query","readwrite",(e=>{const s=gi(t.readTime);if(r.snapshotVersion.compareTo(s)>=0)return i.Gr.saveNamedQuery(e,t);const o=r.withResumeToken(lt.EMPTY_BYTE_STRING,s);return i.os=i.os.insert(o.targetId,o),i.Ur.updateTargetData(e,o).next((()=>i.Ur.removeMatchingKeysForTargetId(e,r.targetId))).next((()=>i.Ur.addMatchingKeys(e,n,r.targetId))).next((()=>i.Gr.saveNamedQuery(e,t)))}))}function Xo(e,t){return`firestore_clients_${e}_${t}`}function Zo(e,t,n){let r=`firestore_mutations_${e}_${n}`;return t.isAuthenticated()&&(r+=`_${t.uid}`),r}function ea(e,t){return`firestore_targets_${e}_${t}`}class ta{constructor(e,t,n,r){this.user=e,this.batchId=t,this.state=n,this.error=r}static Rs(e,t,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 I(r.error.code,r.error.message))),s?new ta(e,t,r.state,i):(m("SharedClientState",`Failed to parse mutation state for ID '${t}': ${n}`),null)}Vs(){const e={state:this.state,updateTimeMs:Date.now()};return this.error&&(e.error={code:this.error.code,message:this.error.message}),JSON.stringify(e)}}class na{constructor(e,t,n){this.targetId=e,this.state=t,this.error=n}static Rs(e,t){const n=JSON.parse(t);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 I(n.error.code,n.error.message))),i?new na(e,n.state,r):(m("SharedClientState",`Failed to parse target state for ID '${e}': ${t}`),null)}Vs(){const e={state:this.state,updateTimeMs:Date.now()};return this.error&&(e.error={code:this.error.code,message:this.error.message}),JSON.stringify(e)}}class ra{constructor(e,t){this.clientId=e,this.activeTargetIds=t}static Rs(e,t){const n=JSON.parse(t);let r="object"==typeof n&&n.activeTargetIds instanceof Array,i=ir();for(let e=0;r&&e<n.activeTargetIds.length;++e)r=we(n.activeTargetIds[e]),i=i.add(n.activeTargetIds[e]);return r?new ra(e,i):(m("SharedClientState",`Failed to parse client data for instance '${e}': ${t}`),null)}}class ia{constructor(e,t){this.clientId=e,this.onlineState=t}static Rs(e){const t=JSON.parse(e);return"object"==typeof t&&-1!==["Unknown","Online","Offline"].indexOf(t.onlineState)&&"string"==typeof t.clientId?new ia(t.clientId,t.onlineState):(m("SharedClientState",`Failed to parse online state: ${e}`),null)}}class sa{constructor(){this.activeTargetIds=ir()}fs(e){this.activeTargetIds=this.activeTargetIds.add(e)}gs(e){this.activeTargetIds=this.activeTargetIds.delete(e)}Vs(){const e={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(e)}}class oa{constructor(e,t,n,r,i){this.window=e,this.ui=t,this.persistenceKey=n,this.ps=r,this.syncEngine=null,this.onlineStateHandler=null,this.sequenceNumberHandler=null,this.ys=this.ws.bind(this),this.Ss=new nt(P),this.started=!1,this.bs=[];const s=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");this.storage=this.window.localStorage,this.currentUser=i,this.Ds=Xo(this.persistenceKey,this.ps),this.vs=function(e){return`firestore_sequence_number_${e}`}(this.persistenceKey),this.Ss=this.Ss.insert(this.ps,new sa),this.Cs=new RegExp(`^firestore_clients_${s}_([^_]*)$`),this.Fs=new RegExp(`^firestore_mutations_${s}_(\\d+)(?:_(.*))?$`),this.Ms=new RegExp(`^firestore_targets_${s}_(\\d+)$`),this.xs=function(e){return`firestore_online_state_${e}`}(this.persistenceKey),this.Os=function(e){return`firestore_bundle_loaded_v2_${e}`}(this.persistenceKey),this.window.addEventListener("storage",this.ys)}static D(e){return!(!e||!e.localStorage)}async start(){const e=await this.syncEngine.Qi();for(const t of e){if(t===this.ps)continue;const e=this.getItem(Xo(this.persistenceKey,t));if(e){const n=ra.Rs(t,e);n&&(this.Ss=this.Ss.insert(n.clientId,n))}}this.Ns();const t=this.storage.getItem(this.xs);if(t){const e=this.Ls(t);e&&this.Bs(e)}for(const e of this.bs)this.ws(e);this.bs=[],this.window.addEventListener("pagehide",(()=>this.shutdown())),this.started=!0}writeSequenceNumber(e){this.setItem(this.vs,JSON.stringify(e))}getAllActiveQueryTargets(){return this.ks(this.Ss)}isActiveQueryTarget(e){let t=!1;return this.Ss.forEach(((n,r)=>{r.activeTargetIds.has(e)&&(t=!0)})),t}addPendingMutation(e){this.qs(e,"pending")}updateMutationState(e,t,n){this.qs(e,t,n),this.Qs(e)}addLocalQueryTarget(e,t=!0){let n="not-current";if(this.isActiveQueryTarget(e)){const t=this.storage.getItem(ea(this.persistenceKey,e));if(t){const r=na.Rs(e,t);r&&(n=r.state)}}return t&&this.Ks.fs(e),this.Ns(),n}removeLocalQueryTarget(e){this.Ks.gs(e),this.Ns()}isLocalQueryTarget(e){return this.Ks.activeTargetIds.has(e)}clearQueryState(e){this.removeItem(ea(this.persistenceKey,e))}updateQueryState(e,t,n){this.$s(e,t,n)}handleUserChange(e,t,n){t.forEach((e=>{this.Qs(e)})),this.currentUser=e,n.forEach((e=>{this.addPendingMutation(e)}))}setOnlineState(e){this.Us(e)}notifyBundleLoaded(e){this.Ws(e)}shutdown(){this.started&&(this.window.removeEventListener("storage",this.ys),this.removeItem(this.Ds),this.started=!1)}getItem(e){const t=this.storage.getItem(e);return p("SharedClientState","READ",e,t),t}setItem(e,t){p("SharedClientState","SET",e,t),this.storage.setItem(e,t)}removeItem(e){p("SharedClientState","REMOVE",e),this.storage.removeItem(e)}ws(e){const t=e;if(t.storageArea===this.storage){if(p("SharedClientState","EVENT",t.key,t.newValue),t.key===this.Ds)return void m("Received WebStorage notification for local change. Another client might have garbage-collected our state");this.ui.enqueueRetryable((async()=>{if(this.started){if(null!==t.key)if(this.Cs.test(t.key)){if(null==t.newValue){const e=this.Gs(t.key);return this.zs(e,null)}{const e=this.js(t.key,t.newValue);if(e)return this.zs(e.clientId,e)}}else if(this.Fs.test(t.key)){if(null!==t.newValue){const e=this.Hs(t.key,t.newValue);if(e)return this.Js(e)}}else if(this.Ms.test(t.key)){if(null!==t.newValue){const e=this.Ys(t.key,t.newValue);if(e)return this.Zs(e)}}else if(t.key===this.xs){if(null!==t.newValue){const e=this.Ls(t.newValue);if(e)return this.Bs(e)}}else if(t.key===this.vs){const e=function(e){let t=ye.oe;if(null!=e)try{const n=JSON.parse(e);b("number"==typeof n),t=n}catch(e){m("SharedClientState","Failed to read sequence number from WebStorage",e)}return t}(t.newValue);e!==ye.oe&&this.sequenceNumberHandler(e)}else if(t.key===this.Os){const e=this.Xs(t.newValue);await Promise.all(e.map((e=>this.syncEngine.eo(e))))}}else this.bs.push(t)}))}}get Ks(){return this.Ss.get(this.ps)}Ns(){this.setItem(this.Ds,this.Ks.Vs())}qs(e,t,n){const r=new ta(this.currentUser,e,t,n),i=Zo(this.persistenceKey,this.currentUser,e);this.setItem(i,r.Vs())}Qs(e){const t=Zo(this.persistenceKey,this.currentUser,e);this.removeItem(t)}Us(e){const t={clientId:this.ps,onlineState:e};this.storage.setItem(this.xs,JSON.stringify(t))}$s(e,t,n){const r=ea(this.persistenceKey,e),i=new na(e,t,n);this.setItem(r,i.Vs())}Ws(e){const t=JSON.stringify(Array.from(e));this.setItem(this.Os,t)}Gs(e){const t=this.Cs.exec(e);return t?t[1]:null}js(e,t){const n=this.Gs(e);return ra.Rs(n,t)}Hs(e,t){const n=this.Fs.exec(e),r=Number(n[1]),i=void 0!==n[2]?n[2]:null;return ta.Rs(new l(i),r,t)}Ys(e,t){const n=this.Ms.exec(e),r=Number(n[1]);return na.Rs(r,t)}Ls(e){return ia.Rs(e)}Xs(e){return JSON.parse(e)}async Js(e){if(e.user.uid===this.currentUser.uid)return this.syncEngine.no(e.batchId,e.state,e.error);p("SharedClientState",`Ignoring mutation for non-active user ${e.user.uid}`)}Zs(e){return this.syncEngine.ro(e.targetId,e.state,e.error)}zs(e,t){const n=t?this.Ss.insert(e,t):this.Ss.remove(e),r=this.ks(this.Ss),i=this.ks(n),s=[],o=[];return i.forEach((e=>{r.has(e)||s.push(e)})),r.forEach((e=>{i.has(e)||o.push(e)})),this.syncEngine.io(s,o).then((()=>{this.Ss=n}))}Bs(e){this.Ss.get(e.clientId)&&this.onlineStateHandler(e.onlineState)}ks(e){let t=ir();return e.forEach(((e,n)=>{t=t.unionWith(n.activeTargetIds)})),t}}class aa{constructor(){this.so=new sa,this.oo={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,t,n){}addLocalQueryTarget(e,t=!0){return t&&this.so.fs(e),this.oo[e]||"not-current"}updateQueryState(e,t,n){this.oo[e]=t}removeLocalQueryTarget(e){this.so.gs(e)}isLocalQueryTarget(e){return this.so.activeTargetIds.has(e)}clearQueryState(e){delete this.oo[e]}getAllActiveQueryTargets(){return this.so.activeTargetIds}isActiveQueryTarget(e){return this.so.activeTargetIds.has(e)}start(){return this.so=new sa,Promise.resolve()}handleUserChange(e,t,n){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}}class ca{_o(e){}shutdown(){}}class ua{constructor(){this.ao=()=>this.uo(),this.co=()=>this.lo(),this.ho=[],this.Po()}_o(e){this.ho.push(e)}shutdown(){window.removeEventListener("online",this.ao),window.removeEventListener("offline",this.co)}Po(){window.addEventListener("online",this.ao),window.addEventListener("offline",this.co)}uo(){p("ConnectivityMonitor","Network connectivity changed: AVAILABLE");for(const e of this.ho)e(0)}lo(){p("ConnectivityMonitor","Network connectivity changed: UNAVAILABLE");for(const e of this.ho)e(1)}static D(){return"undefined"!=typeof window&&void 0!==window.addEventListener&&void 0!==window.removeEventListener}}let la=null;function ha(){return null===la?la=268435456+Math.round(2147483648*Math.random()):la++,"0x"+la.toString(16)}const da={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery"};class fa{constructor(e){this.Io=e.Io,this.To=e.To}Eo(e){this.Ao=e}Ro(e){this.Vo=e}mo(e){this.fo=e}onMessage(e){this.po=e}close(){this.To()}send(e){this.Io(e)}yo(){this.Ao()}wo(){this.Vo()}So(e){this.fo(e)}bo(e){this.po(e)}}const pa="WebChannelConnection";class ma extends class{constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;const t=e.ssl?"https":"http",n=encodeURIComponent(this.databaseId.projectId),r=encodeURIComponent(this.databaseId.database);this.Do=t+"://"+e.host,this.vo=`projects/${n}/databases/${r}`,this.Co="(default)"===this.databaseId.database?`project_id=${n}`:`project_id=${n}&database_id=${r}`}get Fo(){return!1}Mo(e,t,n,r,i){const s=ha(),o=this.xo(e,t.toUriEncodedString());p("RestConnection",`Sending RPC '${e}' ${s}:`,o,n);const a={"google-cloud-resource-prefix":this.vo,"x-goog-request-params":this.Co};return this.Oo(a,r,i),this.No(e,o,a,n).then((t=>(p("RestConnection",`Received RPC '${e}' ${s}: `,t),t)),(t=>{throw g("RestConnection",`RPC '${e}' ${s} failed with error: `,t,"url: ",o,"request:",n),t}))}Lo(e,t,n,r,i,s){return this.Mo(e,t,n,r,i)}Oo(e,t,n){e["X-Goog-Api-Client"]="gl-js/ fire/"+h,e["Content-Type"]="text/plain",this.databaseInfo.appId&&(e["X-Firebase-GMPID"]=this.databaseInfo.appId),t&&t.headers.forEach(((t,n)=>e[n]=t)),n&&n.headers.forEach(((t,n)=>e[n]=t))}xo(e,t){const n=da[e];return`${this.Do}/v1/${t}:${n}`}terminate(){}}{constructor(e){super(e),this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}No(e,t,n,r){const i=ha();return new Promise(((s,o)=>{const a=new c.XhrIo;a.setWithCredentials(!0),a.listenOnce(c.EventType.COMPLETE,(()=>{try{switch(a.getLastErrorCode()){case c.ErrorCode.NO_ERROR:const t=a.getResponseJson();p(pa,`XHR for RPC '${e}' ${i} received:`,JSON.stringify(t)),s(t);break;case c.ErrorCode.TIMEOUT:p(pa,`RPC '${e}' ${i} timed out`),o(new I(_.DEADLINE_EXCEEDED,"Request time out"));break;case c.ErrorCode.HTTP_ERROR:const n=a.getStatus();if(p(pa,`RPC '${e}' ${i} failed with status:`,n,"response text:",a.getResponseText()),n>0){let e=a.getResponseJson();Array.isArray(e)&&(e=e[0]);const t=null==e?void 0:e.error;if(t&&t.status&&t.message){const e=function(e){const t=e.toLowerCase().replace(/_/g,"-");return Object.values(_).indexOf(t)>=0?t:_.UNKNOWN}(t.status);o(new I(e,t.message))}else o(new I(_.UNKNOWN,"Server responded with status "+a.getStatus()))}else o(new I(_.UNAVAILABLE,"Connection failed."));break;default:v()}}finally{p(pa,`RPC '${e}' ${i} completed.`)}}));const u=JSON.stringify(r);p(pa,`RPC '${e}' ${i} sending request:`,r),a.send(t,"POST",u,n,15)}))}Bo(e,t,n){const r=ha(),i=[this.Do,"/","google.firestore.v1.Firestore","/",e,"/channel"],s=c.createWebChannelTransport(),o=c.getStatEventTarget(),a={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},u=this.longPollingOptions.timeoutSeconds;void 0!==u&&(a.longPollingTimeout=Math.round(1e3*u)),this.useFetchStreams&&(a.xmlHttpFactory=new c.FetchXmlHttpFactory({})),this.Oo(a.initMessageHeaders,t,n),a.encodeInitMessageHeaders=!0;const l=i.join("");p(pa,`Creating RPC '${e}' stream ${r}: ${l}`,a);const h=s.createWebChannel(l,a);let d=!1,f=!1;const m=new fa({Io:t=>{f?p(pa,`Not sending because RPC '${e}' stream ${r} is closed:`,t):(d||(p(pa,`Opening RPC '${e}' stream ${r} transport.`),h.open(),d=!0),p(pa,`RPC '${e}' stream ${r} sending:`,t),h.send(t))},To:()=>h.close()}),y=(e,t,n)=>{e.listen(t,(e=>{try{n(e)}catch(e){setTimeout((()=>{throw e}),0)}}))};return y(h,c.WebChannel.EventType.OPEN,(()=>{f||(p(pa,`RPC '${e}' stream ${r} transport opened.`),m.yo())})),y(h,c.WebChannel.EventType.CLOSE,(()=>{f||(f=!0,p(pa,`RPC '${e}' stream ${r} transport closed`),m.So())})),y(h,c.WebChannel.EventType.ERROR,(t=>{f||(f=!0,g(pa,`RPC '${e}' stream ${r} transport errored:`,t),m.So(new I(_.UNAVAILABLE,"The operation could not be completed")))})),y(h,c.WebChannel.EventType.MESSAGE,(t=>{var n;if(!f){const i=t.data[0];b(!!i);const s=i,o=s.error||(null===(n=s[0])||void 0===n?void 0:n.error);if(o){p(pa,`RPC '${e}' stream ${r} received error:`,o);const t=o.status;let n=function(e){const t=qr[e];if(void 0!==t)return Kr(t)}(t),i=o.message;void 0===n&&(n=_.INTERNAL,i="Unknown error status: "+t+" with message "+o.message),f=!0,m.So(new I(n,i)),h.close()}else p(pa,`RPC '${e}' stream ${r} received:`,i),m.bo(i)}})),y(o,c.Event.STAT_EVENT,(t=>{t.stat===c.Stat.PROXY?p(pa,`RPC '${e}' stream ${r} detected buffering proxy`):t.stat===c.Stat.NOPROXY&&p(pa,`RPC '${e}' stream ${r} detected no buffering proxy`)})),setTimeout((()=>{m.wo()}),0),m}}function ga(){return"undefined"!=typeof window?window:null}function ya(){return"undefined"!=typeof document?document:null}function va(e){return new hi(e,!0)}class ba{constructor(e,t,n=1e3,r=1.5,i=6e4){this.ui=e,this.timerId=t,this.ko=n,this.qo=r,this.Qo=i,this.Ko=0,this.$o=null,this.Uo=Date.now(),this.reset()}reset(){this.Ko=0}Wo(){this.Ko=this.Qo}Go(e){this.cancel();const t=Math.floor(this.Ko+this.zo()),n=Math.max(0,Date.now()-this.Uo),r=Math.max(0,t-n);r>0&&p("ExponentialBackoff",`Backing off for ${r} ms (base delay: ${this.Ko} ms, delay with jitter: ${t} ms, last attempt: ${n} ms ago)`),this.$o=this.ui.enqueueAfterDelay(this.timerId,r,(()=>(this.Uo=Date.now(),e()))),this.Ko*=this.qo,this.Ko<this.ko&&(this.Ko=this.ko),this.Ko>this.Qo&&(this.Ko=this.Qo)}jo(){null!==this.$o&&(this.$o.skipDelay(),this.$o=null)}cancel(){null!==this.$o&&(this.$o.cancel(),this.$o=null)}zo(){return(Math.random()-.5)*this.Ko}}class wa{constructor(e,t,n,r,i,s,o,a){this.ui=e,this.Ho=n,this.Jo=r,this.connection=i,this.authCredentialsProvider=s,this.appCheckCredentialsProvider=o,this.listener=a,this.state=0,this.Yo=0,this.Zo=null,this.Xo=null,this.stream=null,this.e_=0,this.t_=new ba(e,t)}n_(){return 1===this.state||5===this.state||this.r_()}r_(){return 2===this.state||3===this.state}start(){this.e_=0,4!==this.state?this.auth():this.i_()}async stop(){this.n_()&&await this.close(0)}s_(){this.state=0,this.t_.reset()}o_(){this.r_()&&null===this.Zo&&(this.Zo=this.ui.enqueueAfterDelay(this.Ho,6e4,(()=>this.__())))}a_(e){this.u_(),this.stream.send(e)}async __(){if(this.r_())return this.close(0)}u_(){this.Zo&&(this.Zo.cancel(),this.Zo=null)}c_(){this.Xo&&(this.Xo.cancel(),this.Xo=null)}async close(e,t){this.u_(),this.c_(),this.t_.cancel(),this.Yo++,4!==e?this.t_.reset():t&&t.code===_.RESOURCE_EXHAUSTED?(m(t.toString()),m("Using maximum backoff delay to prevent overloading the backend."),this.t_.Wo()):t&&t.code===_.UNAUTHENTICATED&&3!==this.state&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),null!==this.stream&&(this.l_(),this.stream.close(),this.stream=null),this.state=e,await this.listener.mo(t)}l_(){}auth(){this.state=1;const e=this.h_(this.Yo),t=this.Yo;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then((([e,n])=>{this.Yo===t&&this.P_(e,n)}),(t=>{e((()=>{const e=new I(_.UNKNOWN,"Fetching auth token failed: "+t.message);return this.I_(e)}))}))}P_(e,t){const n=this.h_(this.Yo);this.stream=this.T_(e,t),this.stream.Eo((()=>{n((()=>this.listener.Eo()))})),this.stream.Ro((()=>{n((()=>(this.state=2,this.Xo=this.ui.enqueueAfterDelay(this.Jo,1e4,(()=>(this.r_()&&(this.state=3),Promise.resolve()))),this.listener.Ro())))})),this.stream.mo((e=>{n((()=>this.I_(e)))})),this.stream.onMessage((e=>{n((()=>1==++this.e_?this.E_(e):this.onNext(e)))}))}i_(){this.state=5,this.t_.Go((async()=>{this.state=0,this.start()}))}I_(e){return p("PersistentStream",`close with error: ${e}`),this.stream=null,this.close(4,e)}h_(e){return t=>{this.ui.enqueueAndForget((()=>this.Yo===e?t():(p("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())))}}}class _a extends wa{constructor(e,t,n,r,i,s){super(e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",t,n,r,s),this.serializer=i}T_(e,t){return this.connection.Bo("Listen",e,t)}E_(e){return this.onNext(e)}onNext(e){this.t_.reset();const t=function(e,t){let n;if("targetChange"in t){t.targetChange;const r=function(e){return"NO_CHANGE"===e?0:"ADD"===e?1:"REMOVE"===e?2:"CURRENT"===e?3:"RESET"===e?4:v()}(t.targetChange.targetChangeType||"NO_CHANGE"),i=t.targetChange.targetIds||[],s=function(e,t){return e.useProto3Json?(b(void 0===t||"string"==typeof t),lt.fromBase64String(t||"")):(b(void 0===t||t instanceof Buffer||t instanceof Uint8Array),lt.fromUint8Array(t||new Uint8Array))}(e,t.targetChange.resumeToken),o=t.targetChange.cause,a=o&&function(e){const t=void 0===e.code?_.UNKNOWN:Kr(e.code);return new I(t,e.message||"")}(o);n=new ri(r,i,s,a||null)}else if("documentChange"in t){t.documentChange;const r=t.documentChange;r.document,r.document.name,r.document.updateTime;const i=_i(e,r.document.name),s=gi(r.document.updateTime),o=r.document.createTime?gi(r.document.createTime):V.min(),a=new Kt({mapValue:{fields:r.document.fields}}),c=$t.newFoundDocument(i,s,o,a),u=r.targetIds||[],l=r.removedTargetIds||[];n=new ti(u,l,c.key,c)}else if("documentDelete"in t){t.documentDelete;const r=t.documentDelete;r.document;const i=_i(e,r.document),s=r.readTime?gi(r.readTime):V.min(),o=$t.newNoDocument(i,s),a=r.removedTargetIds||[];n=new ti([],a,o.key,o)}else if("documentRemove"in t){t.documentRemove;const r=t.documentRemove;r.document;const i=_i(e,r.document),s=r.removedTargetIds||[];n=new ti([],s,i,null)}else{if(!("filter"in t))return v();{t.filter;const e=t.filter;e.targetId;const{count:r=0,unchangedNames:i}=e,s=new Br(r,i),o=e.targetId;n=new ni(o,s)}}return n}(this.serializer,e),n=function(e){if(!("targetChange"in e))return V.min();const t=e.targetChange;return t.targetIds&&t.targetIds.length?V.min():t.readTime?gi(t.readTime):V.min()}(e);return this.listener.d_(t,n)}A_(e){const t={};t.database=Ti(this.serializer),t.addTarget=function(e,t){let n;const r=t.target;if(n=En(r)?{documents:Ni(e,r)}:{query:Oi(e,r)._t},n.targetId=t.targetId,t.resumeToken.approximateByteSize()>0){n.resumeToken=pi(e,t.resumeToken);const r=di(e,t.expectedCount);null!==r&&(n.expectedCount=r)}else if(t.snapshotVersion.compareTo(V.min())>0){n.readTime=fi(e,t.snapshotVersion.toTimestamp());const r=di(e,t.expectedCount);null!==r&&(n.expectedCount=r)}return n}(this.serializer,e);const n=function(e,t){const n=function(e){switch(e){case"TargetPurposeListen":return null;case"TargetPurposeExistenceFilterMismatch":return"existence-filter-mismatch";case"TargetPurposeExistenceFilterMismatchBloom":return"existence-filter-mismatch-bloom";case"TargetPurposeLimboResolution":return"limbo-document";default:return v()}}(t.purpose);return null==n?null:{"goog-listen-tags":n}}(this.serializer,e);n&&(t.labels=n),this.a_(t)}R_(e){const t={};t.database=Ti(this.serializer),t.removeTarget=e,this.a_(t)}}class Ia extends wa{constructor(e,t,n,r,i,s){super(e,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",t,n,r,s),this.serializer=i}get V_(){return this.e_>0}start(){this.lastStreamToken=void 0,super.start()}l_(){this.V_&&this.m_([])}T_(e,t){return this.connection.Bo("Write",e,t)}E_(e){return b(!!e.streamToken),this.lastStreamToken=e.streamToken,b(!e.writeResults||0===e.writeResults.length),this.listener.f_()}onNext(e){b(!!e.streamToken),this.lastStreamToken=e.streamToken,this.t_.reset();const t=function(e,t){return e&&e.length>0?(b(void 0!==t),e.map((e=>function(e,t){let n=e.updateTime?gi(e.updateTime):gi(t);return n.isEqual(V.min())&&(n=gi(t)),new _r(n,e.transformResults||[])}(e,t)))):[]}(e.writeResults,e.commitTime),n=gi(e.commitTime);return this.listener.g_(n,t)}p_(){const e={};e.database=Ti(this.serializer),this.a_(e)}m_(e){const t={streamToken:this.lastStreamToken,writes:e.map((e=>xi(this.serializer,e)))};this.a_(t)}}class Ea extends class{}{constructor(e,t,n,r){super(),this.authCredentials=e,this.appCheckCredentials=t,this.connection=n,this.serializer=r,this.y_=!1}w_(){if(this.y_)throw new I(_.FAILED_PRECONDITION,"The client has already been terminated.")}Mo(e,t,n,r){return this.w_(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([i,s])=>this.connection.Mo(e,vi(t,n),r,i,s))).catch((e=>{throw"FirebaseError"===e.name?(e.code===_.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new I(_.UNKNOWN,e.toString())}))}Lo(e,t,n,r,i){return this.w_(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([s,o])=>this.connection.Lo(e,vi(t,n),r,s,o,i))).catch((e=>{throw"FirebaseError"===e.name?(e.code===_.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new I(_.UNKNOWN,e.toString())}))}terminate(){this.y_=!0,this.connection.terminate()}}class Ta{constructor(e,t){this.asyncQueue=e,this.onlineStateHandler=t,this.state="Unknown",this.S_=0,this.b_=null,this.D_=!0}v_(){0===this.S_&&(this.C_("Unknown"),this.b_=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,(()=>(this.b_=null,this.F_("Backend didn't respond within 10 seconds."),this.C_("Offline"),Promise.resolve()))))}M_(e){"Online"===this.state?this.C_("Unknown"):(this.S_++,this.S_>=1&&(this.x_(),this.F_(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.C_("Offline")))}set(e){this.x_(),this.S_=0,"Online"===e&&(this.D_=!1),this.C_(e)}C_(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}F_(e){const t=`Could not reach Cloud Firestore backend. ${e}\nThis typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.`;this.D_?(m(t),this.D_=!1):p("OnlineStateTracker",t)}x_(){null!==this.b_&&(this.b_.cancel(),this.b_=null)}}class Sa{constructor(e,t,n,r,i){this.localStore=e,this.datastore=t,this.asyncQueue=n,this.remoteSyncer={},this.O_=[],this.N_=new Map,this.L_=new Set,this.B_=[],this.k_=i,this.k_._o((e=>{n.enqueueAndForget((async()=>{Pa(this)&&(p("RemoteStore","Restarting streams for network reachability change."),await async function(e){const t=w(e);t.L_.add(4),await Aa(t),t.q_.set("Unknown"),t.L_.delete(4),await Ca(t)}(this))}))})),this.q_=new Ta(n,r)}}async function Ca(e){if(Pa(e))for(const t of e.B_)await t(!0)}async function Aa(e){for(const t of e.B_)await t(!1)}function xa(e,t){const n=w(e);n.N_.has(t.targetId)||(n.N_.set(t.targetId,t),Ra(n)?Da(n):Za(n).r_()&&Na(n,t))}function ka(e,t){const n=w(e),r=Za(n);n.N_.delete(t),r.r_()&&Oa(n,t),0===n.N_.size&&(r.r_()?r.o_():Pa(n)&&n.q_.set("Unknown"))}function Na(e,t){if(e.Q_.xe(t.targetId),t.resumeToken.approximateByteSize()>0||t.snapshotVersion.compareTo(V.min())>0){const n=e.remoteSyncer.getRemoteKeysForTarget(t.targetId).size;t=t.withExpectedCount(n)}Za(e).A_(t)}function Oa(e,t){e.Q_.xe(t),Za(e).R_(t)}function Da(e){e.Q_=new si({getRemoteKeysForTarget:t=>e.remoteSyncer.getRemoteKeysForTarget(t),ot:t=>e.N_.get(t)||null,tt:()=>e.datastore.serializer.databaseId}),Za(e).start(),e.q_.v_()}function Ra(e){return Pa(e)&&!Za(e).n_()&&e.N_.size>0}function Pa(e){return 0===w(e).L_.size}function La(e){e.Q_=void 0}async function Ma(e){e.q_.set("Online")}async function Fa(e){e.N_.forEach(((t,n)=>{Na(e,t)}))}async function Va(e,t){La(e),Ra(e)?(e.q_.M_(t),Da(e)):e.q_.set("Unknown")}async function Ua(e,t,n){if(e.q_.set("Online"),t instanceof ri&&2===t.state&&t.cause)try{await async function(e,t){const n=t.cause;for(const r of t.targetIds)e.N_.has(r)&&(await e.remoteSyncer.rejectListen(r,n),e.N_.delete(r),e.Q_.removeTarget(r))}(e,t)}catch(n){p("RemoteStore","Failed to remove targets %s: %s ",t.targetIds.join(","),n),await ja(e,n)}else if(t instanceof ti?e.Q_.Ke(t):t instanceof ni?e.Q_.He(t):e.Q_.We(t),!n.isEqual(V.min()))try{const t=await qo(e.localStore);n.compareTo(t)>=0&&await function(e,t){const n=e.Q_.rt(t);return n.targetChanges.forEach(((n,r)=>{if(n.resumeToken.approximateByteSize()>0){const i=e.N_.get(r);i&&e.N_.set(r,i.withResumeToken(n.resumeToken,t))}})),n.targetMismatches.forEach(((t,n)=>{const r=e.N_.get(t);if(!r)return;e.N_.set(t,r.withResumeToken(lt.EMPTY_BYTE_STRING,r.snapshotVersion)),Oa(e,t);const i=new zi(r.target,t,n,r.sequenceNumber);Na(e,i)})),e.remoteSyncer.applyRemoteEvent(n)}(e,n)}catch(t){p("RemoteStore","Failed to raise snapshot:",t),await ja(e,t)}}async function ja(e,t,n){if(!le(t))throw t;e.L_.add(1),await Aa(e),e.q_.set("Offline"),n||(n=()=>qo(e.localStore)),e.asyncQueue.enqueueRetryable((async()=>{p("RemoteStore","Retrying IndexedDB access"),await n(),e.L_.delete(1),await Ca(e)}))}function Ba(e,t){return t().catch((n=>ja(e,n,t)))}async function qa(e){const t=w(e),n=ec(t);let r=t.O_.length>0?t.O_[t.O_.length-1].batchId:-1;for(;za(t);)try{const e=await Go(t.localStore,r);if(null===e){0===t.O_.length&&n.o_();break}r=e.batchId,Ga(t,e)}catch(e){await ja(t,e)}Ka(t)&&Wa(t)}function za(e){return Pa(e)&&e.O_.length<10}function Ga(e,t){e.O_.push(t);const n=ec(e);n.r_()&&n.V_&&n.m_(t.mutations)}function Ka(e){return Pa(e)&&!ec(e).n_()&&e.O_.length>0}function Wa(e){ec(e).start()}async function $a(e){ec(e).p_()}async function Ha(e){const t=ec(e);for(const n of e.O_)t.m_(n.mutations)}async function Qa(e,t,n){const r=e.O_.shift(),i=Vr.from(r,t,n);await Ba(e,(()=>e.remoteSyncer.applySuccessfulWrite(i))),await qa(e)}async function Ja(e,t){t&&ec(e).V_&&await async function(e,t){if(function(e){return Gr(e)&&e!==_.ABORTED}(t.code)){const n=e.O_.shift();ec(e).s_(),await Ba(e,(()=>e.remoteSyncer.rejectFailedWrite(n.batchId,t))),await qa(e)}}(e,t),Ka(e)&&Wa(e)}async function Ya(e,t){const n=w(e);n.asyncQueue.verifyOperationInProgress(),p("RemoteStore","RemoteStore received new credentials");const r=Pa(n);n.L_.add(3),await Aa(n),r&&n.q_.set("Unknown"),await n.remoteSyncer.handleCredentialChange(t),n.L_.delete(3),await Ca(n)}async function Xa(e,t){const n=w(e);t?(n.L_.delete(2),await Ca(n)):t||(n.L_.add(2),await Aa(n),n.q_.set("Unknown"))}function Za(e){return e.K_||(e.K_=function(e,t,n){const r=w(e);return r.w_(),new _a(t,r.connection,r.authCredentials,r.appCheckCredentials,r.serializer,n)}(e.datastore,e.asyncQueue,{Eo:Ma.bind(null,e),Ro:Fa.bind(null,e),mo:Va.bind(null,e),d_:Ua.bind(null,e)}),e.B_.push((async t=>{t?(e.K_.s_(),Ra(e)?Da(e):e.q_.set("Unknown")):(await e.K_.stop(),La(e))}))),e.K_}function ec(e){return e.U_||(e.U_=function(e,t,n){const r=w(e);return r.w_(),new Ia(t,r.connection,r.authCredentials,r.appCheckCredentials,r.serializer,n)}(e.datastore,e.asyncQueue,{Eo:()=>Promise.resolve(),Ro:$a.bind(null,e),mo:Ja.bind(null,e),f_:Ha.bind(null,e),g_:Qa.bind(null,e)}),e.B_.push((async t=>{t?(e.U_.s_(),await qa(e)):(await e.U_.stop(),e.O_.length>0&&(p("RemoteStore",`Stopping write stream with ${e.O_.length} pending writes`),e.O_=[]))}))),e.U_}class tc{constructor(e,t,n,r,i){this.asyncQueue=e,this.timerId=t,this.targetTimeMs=n,this.op=r,this.removalCallback=i,this.deferred=new E,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch((e=>{}))}get promise(){return this.deferred.promise}static createAndSchedule(e,t,n,r,i){const s=Date.now()+n,o=new tc(e,t,s,r,i);return o.start(n),o}start(e){this.timerHandle=setTimeout((()=>this.handleDelayElapsed()),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){null!==this.timerHandle&&(this.clearTimeout(),this.deferred.reject(new I(_.CANCELLED,"Operation cancelled"+(e?": "+e:""))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget((()=>null!==this.timerHandle?(this.clearTimeout(),this.op().then((e=>this.deferred.resolve(e)))):Promise.resolve()))}clearTimeout(){null!==this.timerHandle&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}}function nc(e,t){if(m("AsyncQueue",`${t}: ${e}`),le(e))return new I(_.UNAVAILABLE,`${t}: ${e}`);throw e}class rc{constructor(e){this.comparator=e?(t,n)=>e(t,n)||z.comparator(t.key,n.key):(e,t)=>z.comparator(e.key,t.key),this.keyedMap=Qn(),this.sortedSet=new nt(this.comparator)}static emptySet(e){return new rc(e.comparator)}has(e){return null!=this.keyedMap.get(e)}get(e){return this.keyedMap.get(e)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(e){const t=this.keyedMap.get(e);return t?this.sortedSet.indexOf(t):-1}get size(){return this.sortedSet.size}forEach(e){this.sortedSet.inorderTraversal(((t,n)=>(e(t),!1)))}add(e){const t=this.delete(e.key);return t.copy(t.keyedMap.insert(e.key,e),t.sortedSet.insert(e,null))}delete(e){const t=this.get(e);return t?this.copy(this.keyedMap.remove(e),this.sortedSet.remove(t)):this}isEqual(e){if(!(e instanceof rc))return!1;if(this.size!==e.size)return!1;const t=this.sortedSet.getIterator(),n=e.sortedSet.getIterator();for(;t.hasNext();){const e=t.getNext().key,r=n.getNext().key;if(!e.isEqual(r))return!1}return!0}toString(){const e=[];return this.forEach((t=>{e.push(t.toString())})),0===e.length?"DocumentSet ()":"DocumentSet (\n "+e.join(" \n")+"\n)"}copy(e,t){const n=new rc;return n.comparator=this.comparator,n.keyedMap=e,n.sortedSet=t,n}}class ic{constructor(){this.W_=new nt(z.comparator)}track(e){const t=e.doc.key,n=this.W_.get(t);n?0!==e.type&&3===n.type?this.W_=this.W_.insert(t,e):3===e.type&&1!==n.type?this.W_=this.W_.insert(t,{type:n.type,doc:e.doc}):2===e.type&&2===n.type?this.W_=this.W_.insert(t,{type:2,doc:e.doc}):2===e.type&&0===n.type?this.W_=this.W_.insert(t,{type:0,doc:e.doc}):1===e.type&&0===n.type?this.W_=this.W_.remove(t):1===e.type&&2===n.type?this.W_=this.W_.insert(t,{type:1,doc:n.doc}):0===e.type&&1===n.type?this.W_=this.W_.insert(t,{type:2,doc:e.doc}):v():this.W_=this.W_.insert(t,e)}G_(){const e=[];return this.W_.inorderTraversal(((t,n)=>{e.push(n)})),e}}class sc{constructor(e,t,n,r,i,s,o,a,c){this.query=e,this.docs=t,this.oldDocs=n,this.docChanges=r,this.mutatedKeys=i,this.fromCache=s,this.syncStateChanged=o,this.excludesMetadataChanges=a,this.hasCachedResults=c}static fromInitialDocuments(e,t,n,r,i){const s=[];return t.forEach((e=>{s.push({type:0,doc:e})})),new sc(e,t,rc.emptySet(t),s,n,r,!0,!1,i)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(e){if(!(this.fromCache===e.fromCache&&this.hasCachedResults===e.hasCachedResults&&this.syncStateChanged===e.syncStateChanged&&this.mutatedKeys.isEqual(e.mutatedKeys)&&Vn(this.query,e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;const t=this.docChanges,n=e.docChanges;if(t.length!==n.length)return!1;for(let e=0;e<t.length;e++)if(t[e].type!==n[e].type||!t[e].doc.isEqual(n[e].doc))return!1;return!0}}class oc{constructor(){this.z_=void 0,this.j_=[]}H_(){return this.j_.some((e=>e.J_()))}}class ac{constructor(){this.queries=cc(),this.onlineState="Unknown",this.Y_=new Set}terminate(){!function(e,t){const n=w(e),r=n.queries;n.queries=cc(),r.forEach(((e,n)=>{for(const e of n.j_)e.onError(t)}))}(this,new I(_.ABORTED,"Firestore shutting down"))}}function cc(){return new Kn((e=>Un(e)),Vn)}async function uc(e,t){const n=w(e);let r=3;const i=t.query;let s=n.queries.get(i);s?!s.H_()&&t.J_()&&(r=2):(s=new oc,r=t.J_()?0:1);try{switch(r){case 0:s.z_=await n.onListen(i,!0);break;case 1:s.z_=await n.onListen(i,!1);break;case 2:await n.onFirstRemoteStoreListen(i)}}catch(e){const n=nc(e,`Initialization of query '${jn(t.query)}' failed`);return void t.onError(n)}n.queries.set(i,s),s.j_.push(t),t.Z_(n.onlineState),s.z_&&t.X_(s.z_)&&fc(n)}async function lc(e,t){const n=w(e),r=t.query;let i=3;const s=n.queries.get(r);if(s){const e=s.j_.indexOf(t);e>=0&&(s.j_.splice(e,1),0===s.j_.length?i=t.J_()?0:1:!s.H_()&&t.J_()&&(i=2))}switch(i){case 0:return n.queries.delete(r),n.onUnlisten(r,!0);case 1:return n.queries.delete(r),n.onUnlisten(r,!1);case 2:return n.onLastRemoteStoreUnlisten(r);default:return}}function hc(e,t){const n=w(e);let r=!1;for(const e of t){const t=e.query,i=n.queries.get(t);if(i){for(const t of i.j_)t.X_(e)&&(r=!0);i.z_=e}}r&&fc(n)}function dc(e,t,n){const r=w(e),i=r.queries.get(t);if(i)for(const e of i.j_)e.onError(n);r.queries.delete(t)}function fc(e){e.Y_.forEach((e=>{e.next()}))}var pc,mc;(mc=pc||(pc={})).ea="default",mc.Cache="cache";class gc{constructor(e,t,n){this.query=e,this.ta=t,this.na=!1,this.ra=null,this.onlineState="Unknown",this.options=n||{}}X_(e){if(!this.options.includeMetadataChanges){const t=[];for(const n of e.docChanges)3!==n.type&&t.push(n);e=new sc(e.query,e.docs,e.oldDocs,t,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let t=!1;return this.na?this.ia(e)&&(this.ta.next(e),t=!0):this.sa(e,this.onlineState)&&(this.oa(e),t=!0),this.ra=e,t}onError(e){this.ta.error(e)}Z_(e){this.onlineState=e;let t=!1;return this.ra&&!this.na&&this.sa(this.ra,e)&&(this.oa(this.ra),t=!0),t}sa(e,t){if(!e.fromCache)return!0;if(!this.J_())return!0;const n="Offline"!==t;return(!this.options._a||!n)&&(!e.docs.isEmpty()||e.hasCachedResults||"Offline"===t)}ia(e){if(e.docChanges.length>0)return!0;const t=this.ra&&this.ra.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&!0===this.options.includeMetadataChanges}oa(e){e=sc.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.na=!0,this.ta.next(e)}J_(){return this.options.source!==pc.Cache}}class yc{constructor(e,t){this.aa=e,this.byteLength=t}ua(){return"metadata"in this.aa}}class vc{constructor(e){this.serializer=e}Es(e){return _i(this.serializer,e)}ds(e){return e.metadata.exists?Ai(this.serializer,e.document,!1):$t.newNoDocument(this.Es(e.metadata.name),this.As(e.metadata.readTime))}As(e){return gi(e)}}class bc{constructor(e,t,n){this.ca=e,this.localStore=t,this.serializer=n,this.queries=[],this.documents=[],this.collectionGroups=new Set,this.progress=wc(e)}la(e){this.progress.bytesLoaded+=e.byteLength;let t=this.progress.documentsLoaded;if(e.aa.namedQuery)this.queries.push(e.aa.namedQuery);else if(e.aa.documentMetadata){this.documents.push({metadata:e.aa.documentMetadata}),e.aa.documentMetadata.exists||++t;const n=j.fromString(e.aa.documentMetadata.name);this.collectionGroups.add(n.get(n.length-2))}else e.aa.document&&(this.documents[this.documents.length-1].document=e.aa.document,++t);return t!==this.progress.documentsLoaded?(this.progress.documentsLoaded=t,Object.assign({},this.progress)):null}ha(e){const t=new Map,n=new vc(this.serializer);for(const r of e)if(r.metadata.queries){const e=n.Es(r.metadata.name);for(const n of r.metadata.queries){const r=(t.get(n)||nr()).add(e);t.set(n,r)}}return t}async complete(){const e=await async function(e,t,n,r){const i=w(e);let s=nr(),o=$n();for(const e of n){const n=t.Es(e.metadata.name);e.document&&(s=s.add(n));const r=t.ds(e);r.setReadTime(t.As(e.metadata.readTime)),o=o.insert(n,r)}const a=i.cs.newChangeBuffer({trackRemovals:!0}),c=await Ko(i,function(e){return Rn(kn(j.fromString(`__bundle__/docs/${e}`)))}(r));return i.persistence.runTransaction("Apply bundle documents","readwrite",(e=>zo(e,a,o).next((t=>(a.apply(e),t))).next((t=>i.Ur.removeMatchingKeysForTargetId(e,c.targetId).next((()=>i.Ur.addMatchingKeys(e,s,c.targetId))).next((()=>i.localDocuments.getLocalViewOfDocuments(e,t.Ps,t.Is))).next((()=>t.Ps))))))}(this.localStore,new vc(this.serializer),this.documents,this.ca.id),t=this.ha(this.documents);for(const e of this.queries)await Yo(this.localStore,e,t.get(e.name));return this.progress.taskState="Success",{progress:this.progress,Pa:this.collectionGroups,Ia:e}}}function wc(e){return{taskState:"Running",documentsLoaded:0,bytesLoaded:0,totalDocuments:e.totalDocuments,totalBytes:e.totalBytes}}class _c{constructor(e){this.key=e}}class Ic{constructor(e){this.key=e}}class Ec{constructor(e,t){this.query=e,this.Ta=t,this.Ea=null,this.hasCachedResults=!1,this.current=!1,this.da=nr(),this.mutatedKeys=nr(),this.Aa=zn(e),this.Ra=new rc(this.Aa)}get Va(){return this.Ta}ma(e,t){const n=t?t.fa:new ic,r=t?t.Ra:this.Ra;let i=t?t.mutatedKeys:this.mutatedKeys,s=r,o=!1;const a="F"===this.query.limitType&&r.size===this.query.limit?r.last():null,c="L"===this.query.limitType&&r.size===this.query.limit?r.first():null;if(e.inorderTraversal(((e,t)=>{const u=r.get(e),l=Bn(this.query,t)?t:null,h=!!u&&this.mutatedKeys.has(u.key),d=!!l&&(l.hasLocalMutations||this.mutatedKeys.has(l.key)&&l.hasCommittedMutations);let f=!1;u&&l?u.data.isEqual(l.data)?h!==d&&(n.track({type:3,doc:l}),f=!0):this.ga(u,l)||(n.track({type:2,doc:l}),f=!0,(a&&this.Aa(l,a)>0||c&&this.Aa(l,c)<0)&&(o=!0)):!u&&l?(n.track({type:0,doc:l}),f=!0):u&&!l&&(n.track({type:1,doc:u}),f=!0,(a||c)&&(o=!0)),f&&(l?(s=s.add(l),i=d?i.add(e):i.delete(e)):(s=s.delete(e),i=i.delete(e)))})),null!==this.query.limit)for(;s.size>this.query.limit;){const e="F"===this.query.limitType?s.last():s.first();s=s.delete(e.key),i=i.delete(e.key),n.track({type:1,doc:e})}return{Ra:s,fa:n,ns:o,mutatedKeys:i}}ga(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}applyChanges(e,t,n,r){const i=this.Ra;this.Ra=e.Ra,this.mutatedKeys=e.mutatedKeys;const s=e.fa.G_();s.sort(((e,t)=>function(e,t){const n=e=>{switch(e){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return v()}};return n(e)-n(t)}(e.type,t.type)||this.Aa(e.doc,t.doc))),this.pa(n),r=null!=r&&r;const o=t&&!r?this.ya():[],a=0===this.da.size&&this.current&&!r?1:0,c=a!==this.Ea;return this.Ea=a,0!==s.length||c?{snapshot:new sc(this.query,e.Ra,i,s,e.mutatedKeys,0===a,c,!1,!!n&&n.resumeToken.approximateByteSize()>0),wa:o}:{wa:o}}Z_(e){return this.current&&"Offline"===e?(this.current=!1,this.applyChanges({Ra:this.Ra,fa:new ic,mutatedKeys:this.mutatedKeys,ns:!1},!1)):{wa:[]}}Sa(e){return!this.Ta.has(e)&&!!this.Ra.has(e)&&!this.Ra.get(e).hasLocalMutations}pa(e){e&&(e.addedDocuments.forEach((e=>this.Ta=this.Ta.add(e))),e.modifiedDocuments.forEach((e=>{})),e.removedDocuments.forEach((e=>this.Ta=this.Ta.delete(e))),this.current=e.current)}ya(){if(!this.current)return[];const e=this.da;this.da=nr(),this.Ra.forEach((e=>{this.Sa(e.key)&&(this.da=this.da.add(e.key))}));const t=[];return e.forEach((e=>{this.da.has(e)||t.push(new Ic(e))})),this.da.forEach((n=>{e.has(n)||t.push(new _c(n))})),t}ba(e){this.Ta=e.Ts,this.da=nr();const t=this.ma(e.documents);return this.applyChanges(t,!0)}Da(){return sc.fromInitialDocuments(this.query,this.Ra,this.mutatedKeys,0===this.Ea,this.hasCachedResults)}}class Tc{constructor(e,t,n){this.query=e,this.targetId=t,this.view=n}}class Sc{constructor(e){this.key=e,this.va=!1}}class Cc{constructor(e,t,n,r,i,s){this.localStore=e,this.remoteStore=t,this.eventManager=n,this.sharedClientState=r,this.currentUser=i,this.maxConcurrentLimboResolutions=s,this.Ca={},this.Fa=new Kn((e=>Un(e)),Vn),this.Ma=new Map,this.xa=new Set,this.Oa=new nt(z.comparator),this.Na=new Map,this.La=new bo,this.Ba={},this.ka=new Map,this.qa=Ws.kn(),this.onlineState="Unknown",this.Qa=void 0}get isPrimaryClient(){return!0===this.Qa}}async function Ac(e,t,n=!0){const r=nu(e);let i;const s=r.Fa.get(t);return s?(r.sharedClientState.addLocalQueryTarget(s.targetId),i=s.view.Da()):i=await kc(r,t,n,!0),i}async function xc(e,t){const n=nu(e);await kc(n,t,!0,!1)}async function kc(e,t,n,r){const i=await Ko(e.localStore,Rn(t)),s=i.targetId,o=e.sharedClientState.addLocalQueryTarget(s,n);let a;return r&&(a=await Nc(e,t,s,"current"===o,i.resumeToken)),e.isPrimaryClient&&n&&xa(e.remoteStore,i),a}async function Nc(e,t,n,r,i){e.Ka=(t,n,r)=>async function(e,t,n,r){let i=t.view.ma(n);i.ns&&(i=await $o(e.localStore,t.query,!1).then((({documents:e})=>t.view.ma(e,i))));const s=r&&r.targetChanges.get(t.targetId),o=r&&null!=r.targetMismatches.get(t.targetId),a=t.view.applyChanges(i,e.isPrimaryClient,s,o);return qc(e,t.targetId,a.wa),a.snapshot}(e,t,n,r);const s=await $o(e.localStore,t,!0),o=new Ec(t,s.Ts),a=o.ma(s.documents),c=ei.createSynthesizedTargetChangeForCurrentChange(n,r&&"Offline"!==e.onlineState,i),u=o.applyChanges(a,e.isPrimaryClient,c);qc(e,n,u.wa);const l=new Tc(t,n,o);return e.Fa.set(t,l),e.Ma.has(n)?e.Ma.get(n).push(t):e.Ma.set(n,[t]),u.snapshot}async function Oc(e,t,n){const r=w(e),i=r.Fa.get(t),s=r.Ma.get(i.targetId);if(s.length>1)return r.Ma.set(i.targetId,s.filter((e=>!Vn(e,t)))),void r.Fa.delete(t);r.isPrimaryClient?(r.sharedClientState.removeLocalQueryTarget(i.targetId),r.sharedClientState.isActiveQueryTarget(i.targetId)||await Wo(r.localStore,i.targetId,!1).then((()=>{r.sharedClientState.clearQueryState(i.targetId),n&&ka(r.remoteStore,i.targetId),jc(r,i.targetId)})).catch(re)):(jc(r,i.targetId),await Wo(r.localStore,i.targetId,!0))}async function Dc(e,t){const n=w(e),r=n.Fa.get(t),i=n.Ma.get(r.targetId);n.isPrimaryClient&&1===i.length&&(n.sharedClientState.removeLocalQueryTarget(r.targetId),ka(n.remoteStore,r.targetId))}async function Rc(e,t){const n=w(e);try{const e=await function(e,t){const n=w(e),r=t.snapshotVersion;let i=n.os;return n.persistence.runTransaction("Apply remote event","readwrite-primary",(e=>{const s=n.cs.newChangeBuffer({trackRemovals:!0});i=n.os;const o=[];t.targetChanges.forEach(((s,a)=>{const c=i.get(a);if(!c)return;o.push(n.Ur.removeMatchingKeys(e,s.removedDocuments,a).next((()=>n.Ur.addMatchingKeys(e,s.addedDocuments,a))));let u=c.withSequenceNumber(e.currentSequenceNumber);null!==t.targetMismatches.get(a)?u=u.withResumeToken(lt.EMPTY_BYTE_STRING,V.min()).withLastLimboFreeSnapshotVersion(V.min()):s.resumeToken.approximateByteSize()>0&&(u=u.withResumeToken(s.resumeToken,r)),i=i.insert(a,u),function(e,t,n){return 0===e.resumeToken.approximateByteSize()||t.snapshotVersion.toMicroseconds()-e.snapshotVersion.toMicroseconds()>=3e8||n.addedDocuments.size+n.modifiedDocuments.size+n.removedDocuments.size>0}(c,u,s)&&o.push(n.Ur.updateTargetData(e,u))}));let a=$n(),c=nr();if(t.documentUpdates.forEach((r=>{t.resolvedLimboDocuments.has(r)&&o.push(n.persistence.referenceDelegate.updateLimboDocument(e,r))})),o.push(zo(e,s,t.documentUpdates).next((e=>{a=e.Ps,c=e.Is}))),!r.isEqual(V.min())){const t=n.Ur.getLastRemoteSnapshotVersion(e).next((t=>n.Ur.setTargetsMetadata(e,e.currentSequenceNumber,r)));o.push(t)}return ie.waitFor(o).next((()=>s.apply(e))).next((()=>n.localDocuments.getLocalViewOfDocuments(e,a,c))).next((()=>a))})).then((e=>(n.os=i,e)))}(n.localStore,t);t.targetChanges.forEach(((e,t)=>{const r=n.Na.get(t);r&&(b(e.addedDocuments.size+e.modifiedDocuments.size+e.removedDocuments.size<=1),e.addedDocuments.size>0?r.va=!0:e.modifiedDocuments.size>0?b(r.va):e.removedDocuments.size>0&&(b(r.va),r.va=!1))})),await Kc(n,e,t)}catch(e){await re(e)}}function Pc(e,t,n){const r=w(e);if(r.isPrimaryClient&&0===n||!r.isPrimaryClient&&1===n){const e=[];r.Fa.forEach(((n,r)=>{const i=r.view.Z_(t);i.snapshot&&e.push(i.snapshot)})),function(e,t){const n=w(e);n.onlineState=t;let r=!1;n.queries.forEach(((e,n)=>{for(const e of n.j_)e.Z_(t)&&(r=!0)})),r&&fc(n)}(r.eventManager,t),e.length&&r.Ca.d_(e),r.onlineState=t,r.isPrimaryClient&&r.sharedClientState.setOnlineState(t)}}async function Lc(e,t,n){const r=w(e);r.sharedClientState.updateQueryState(t,"rejected",n);const i=r.Na.get(t),s=i&&i.key;if(s){let e=new nt(z.comparator);e=e.insert(s,$t.newNoDocument(s,V.min()));const n=nr().add(s),i=new Zr(V.min(),new Map,new nt(P),e,n);await Rc(r,i),r.Oa=r.Oa.remove(s),r.Na.delete(t),Gc(r)}else await Wo(r.localStore,t,!1).then((()=>jc(r,t,n))).catch(re)}async function Mc(e,t){const n=w(e),r=t.batch.batchId;try{const e=await function(e,t){const n=w(e);return n.persistence.runTransaction("Acknowledge batch","readwrite-primary",(e=>{const r=t.batch.keys(),i=n.cs.newChangeBuffer({trackRemovals:!0});return function(e,t,n,r){const i=n.batch,s=i.keys();let o=ie.resolve();return s.forEach((e=>{o=o.next((()=>r.getEntry(t,e))).next((t=>{const s=n.docVersions.get(e);b(null!==s),t.version.compareTo(s)<0&&(i.applyToRemoteDocument(t,n),t.isValidDocument()&&(t.setReadTime(n.commitVersion),r.addEntry(t)))}))})),o.next((()=>e.mutationQueue.removeMutationBatch(t,i)))}(n,e,t,i).next((()=>i.apply(e))).next((()=>n.mutationQueue.performConsistencyCheck(e))).next((()=>n.documentOverlayCache.removeOverlaysForBatchId(e,r,t.batch.batchId))).next((()=>n.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(e,function(e){let t=nr();for(let n=0;n<e.mutationResults.length;++n)e.mutationResults[n].transformResults.length>0&&(t=t.add(e.batch.mutations[n].key));return t}(t)))).next((()=>n.localDocuments.getDocuments(e,r)))}))}(n.localStore,t);Uc(n,r,null),Vc(n,r),n.sharedClientState.updateMutationState(r,"acknowledged"),await Kc(n,e)}catch(e){await re(e)}}async function Fc(e,t,n){const r=w(e);try{const e=await function(e,t){const n=w(e);return n.persistence.runTransaction("Reject batch","readwrite-primary",(e=>{let r;return n.mutationQueue.lookupMutationBatch(e,t).next((t=>(b(null!==t),r=t.keys(),n.mutationQueue.removeMutationBatch(e,t)))).next((()=>n.mutationQueue.performConsistencyCheck(e))).next((()=>n.documentOverlayCache.removeOverlaysForBatchId(e,r,t))).next((()=>n.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(e,r))).next((()=>n.localDocuments.getDocuments(e,r)))}))}(r.localStore,t);Uc(r,t,n),Vc(r,t),r.sharedClientState.updateMutationState(t,"rejected",n),await Kc(r,e)}catch(n){await re(n)}}function Vc(e,t){(e.ka.get(t)||[]).forEach((e=>{e.resolve()})),e.ka.delete(t)}function Uc(e,t,n){const r=w(e);let i=r.Ba[r.currentUser.toKey()];if(i){const e=i.get(t);e&&(n?e.reject(n):e.resolve(),i=i.remove(t)),r.Ba[r.currentUser.toKey()]=i}}function jc(e,t,n=null){e.sharedClientState.removeLocalQueryTarget(t);for(const r of e.Ma.get(t))e.Fa.delete(r),n&&e.Ca.$a(r,n);e.Ma.delete(t),e.isPrimaryClient&&e.La.gr(t).forEach((t=>{e.La.containsKey(t)||Bc(e,t)}))}function Bc(e,t){e.xa.delete(t.path.canonicalString());const n=e.Oa.get(t);null!==n&&(ka(e.remoteStore,n),e.Oa=e.Oa.remove(t),e.Na.delete(n),Gc(e))}function qc(e,t,n){for(const r of n)r instanceof _c?(e.La.addReference(r.key,t),zc(e,r)):r instanceof Ic?(p("SyncEngine","Document no longer in limbo: "+r.key),e.La.removeReference(r.key,t),e.La.containsKey(r.key)||Bc(e,r.key)):v()}function zc(e,t){const n=t.key,r=n.path.canonicalString();e.Oa.get(n)||e.xa.has(r)||(p("SyncEngine","New document in limbo: "+n),e.xa.add(r),Gc(e))}function Gc(e){for(;e.xa.size>0&&e.Oa.size<e.maxConcurrentLimboResolutions;){const t=e.xa.values().next().value;e.xa.delete(t);const n=new z(j.fromString(t)),r=e.qa.next();e.Na.set(r,new Sc(n)),e.Oa=e.Oa.insert(n,r),xa(e.remoteStore,new zi(Rn(kn(n.path)),r,"TargetPurposeLimboResolution",ye.oe))}}async function Kc(e,t,n){const r=w(e),i=[],s=[],o=[];r.Fa.isEmpty()||(r.Fa.forEach(((e,a)=>{o.push(r.Ka(a,t,n).then((e=>{var t;if((e||n)&&r.isPrimaryClient){const i=e?!e.fromCache:null===(t=null==n?void 0:n.targetChanges.get(a.targetId))||void 0===t?void 0:t.current;r.sharedClientState.updateQueryState(a.targetId,i?"current":"not-current")}if(e){i.push(e);const t=Mo.Wi(a.targetId,e);s.push(t)}})))})),await Promise.all(o),r.Ca.d_(i),await async function(e,t){const n=w(e);try{await n.persistence.runTransaction("notifyLocalViewChanges","readwrite",(e=>ie.forEach(t,(t=>ie.forEach(t.$i,(r=>n.persistence.referenceDelegate.addReference(e,t.targetId,r))).next((()=>ie.forEach(t.Ui,(r=>n.persistence.referenceDelegate.removeReference(e,t.targetId,r)))))))))}catch(e){if(!le(e))throw e;p("LocalStore","Failed to update sequence numbers: "+e)}for(const e of t){const t=e.targetId;if(!e.fromCache){const e=n.os.get(t),r=e.snapshotVersion,i=e.withLastLimboFreeSnapshotVersion(r);n.os=n.os.insert(t,i)}}}(r.localStore,s))}async function Wc(e,t){const n=w(e);if(!n.currentUser.isEqual(t)){p("SyncEngine","User change. New user:",t.toKey());const e=await Bo(n.localStore,t);n.currentUser=t,function(e){e.ka.forEach((e=>{e.forEach((e=>{e.reject(new I(_.CANCELLED,"'waitForPendingWrites' promise is rejected due to a user change."))}))})),e.ka.clear()}(n),n.sharedClientState.handleUserChange(t,e.removedBatchIds,e.addedBatchIds),await Kc(n,e.hs)}}function $c(e,t){const n=w(e),r=n.Na.get(t);if(r&&r.va)return nr().add(r.key);{let e=nr();const r=n.Ma.get(t);if(!r)return e;for(const t of r){const r=n.Fa.get(t);e=e.unionWith(r.view.Va)}return e}}async function Hc(e,t){const n=w(e),r=await $o(n.localStore,t.query,!0),i=t.view.ba(r);return n.isPrimaryClient&&qc(n,t.targetId,i.wa),i}async function Qc(e,t){const n=w(e);return Qo(n.localStore,t).then((e=>Kc(n,e)))}async function Jc(e,t,n,r){const i=w(e),s=await function(e,t){const n=w(e),r=w(n.mutationQueue);return n.persistence.runTransaction("Lookup mutation documents","readonly",(e=>r.Mn(e,t).next((t=>t?n.localDocuments.getDocuments(e,t):ie.resolve(null)))))}(i.localStore,t);null!==s?("pending"===n?await qa(i.remoteStore):"acknowledged"===n||"rejected"===n?(Uc(i,t,r||null),Vc(i,t),function(e,t){w(w(e).mutationQueue).On(t)}(i.localStore,t)):v(),await Kc(i,s)):p("SyncEngine","Cannot apply mutation batch with id: "+t)}async function Yc(e,t,n){const r=w(e),i=[],s=[];for(const e of t){let t;const n=r.Ma.get(e);if(n&&0!==n.length){t=await Ko(r.localStore,Rn(n[0]));for(const e of n){const t=r.Fa.get(e),n=await Hc(r,t);n.snapshot&&s.push(n.snapshot)}}else{const n=await Ho(r.localStore,e);t=await Ko(r.localStore,n),await Nc(r,Xc(n),e,!1,t.resumeToken)}i.push(t)}return r.Ca.d_(s),i}function Xc(e){return xn(e.path,e.collectionGroup,e.orderBy,e.filters,e.limit,"F",e.startAt,e.endAt)}function Zc(e){return function(e){return w(w(e).persistence).Qi()}(w(e).localStore)}async function eu(e,t,n,r){const i=w(e);if(i.Qa)return void p("SyncEngine","Ignoring unexpected query state notification.");const s=i.Ma.get(t);if(s&&s.length>0)switch(n){case"current":case"not-current":{const e=await Qo(i.localStore,qn(s[0])),r=Zr.createSynthesizedRemoteEventForCurrentChange(t,"current"===n,lt.EMPTY_BYTE_STRING);await Kc(i,e,r);break}case"rejected":await Wo(i.localStore,t,!0),jc(i,t,r);break;default:v()}}async function tu(e,t,n){const r=nu(e);if(r.Qa){for(const e of t){if(r.Ma.has(e)&&r.sharedClientState.isActiveQueryTarget(e)){p("SyncEngine","Adding an already active target "+e);continue}const t=await Ho(r.localStore,e),n=await Ko(r.localStore,t);await Nc(r,Xc(t),n.targetId,!1,n.resumeToken),xa(r.remoteStore,n)}for(const e of n)r.Ma.has(e)&&await Wo(r.localStore,e,!1).then((()=>{ka(r.remoteStore,e),jc(r,e)})).catch(re)}}function nu(e){const t=w(e);return t.remoteStore.remoteSyncer.applyRemoteEvent=Rc.bind(null,t),t.remoteStore.remoteSyncer.getRemoteKeysForTarget=$c.bind(null,t),t.remoteStore.remoteSyncer.rejectListen=Lc.bind(null,t),t.Ca.d_=hc.bind(null,t.eventManager),t.Ca.$a=dc.bind(null,t.eventManager),t}function ru(e){const t=w(e);return t.remoteStore.remoteSyncer.applySuccessfulWrite=Mc.bind(null,t),t.remoteStore.remoteSyncer.rejectFailedWrite=Fc.bind(null,t),t}class iu{constructor(){this.synchronizeTabs=!1}async initialize(e){this.serializer=va(e.databaseInfo.databaseId),this.sharedClientState=this.createSharedClientState(e),this.persistence=this.createPersistence(e),await this.persistence.start(),this.localStore=this.createLocalStore(e),this.gcScheduler=this.createGarbageCollectionScheduler(e,this.localStore),this.indexBackfillerScheduler=this.createIndexBackfillerScheduler(e,this.localStore)}createGarbageCollectionScheduler(e,t){return null}createIndexBackfillerScheduler(e,t){return null}createLocalStore(e){return jo(this.persistence,new Vo,e.initialUser,this.serializer)}createPersistence(e){return new So(Ao.Zr,this.serializer)}createSharedClientState(e){return new aa}async terminate(){var e,t;null===(e=this.gcScheduler)||void 0===e||e.stop(),null===(t=this.indexBackfillerScheduler)||void 0===t||t.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}}class su extends iu{constructor(e){super(),this.cacheSizeBytes=e}createGarbageCollectionScheduler(e,t){b(this.persistence.referenceDelegate instanceof xo);const n=this.persistence.referenceDelegate.garbageCollector;return new Zs(n,e.asyncQueue,t)}createPersistence(e){const t=void 0!==this.cacheSizeBytes?Vs.withCacheSize(this.cacheSizeBytes):Vs.DEFAULT;return new So((e=>xo.Zr(e,t)),this.serializer)}}class ou extends iu{constructor(e,t,n){super(),this.Wa=e,this.cacheSizeBytes=t,this.forceOwnership=n,this.synchronizeTabs=!1}async initialize(e){await super.initialize(e),await this.Wa.initialize(this,e),await ru(this.Wa.syncEngine),await qa(this.Wa.remoteStore),await this.persistence.yi((()=>(this.gcScheduler&&!this.gcScheduler.started&&this.gcScheduler.start(),this.indexBackfillerScheduler&&!this.indexBackfillerScheduler.started&&this.indexBackfillerScheduler.start(),Promise.resolve())))}createLocalStore(e){return jo(this.persistence,new Vo,e.initialUser,this.serializer)}createGarbageCollectionScheduler(e,t){const n=this.persistence.referenceDelegate.garbageCollector;return new Zs(n,e.asyncQueue,t)}createIndexBackfillerScheduler(e,t){const n=new ge(t,this.persistence);return new me(e.asyncQueue,n)}createPersistence(e){const t=Lo(e.databaseInfo.databaseId,e.databaseInfo.persistenceKey),n=void 0!==this.cacheSizeBytes?Vs.withCacheSize(this.cacheSizeBytes):Vs.DEFAULT;return new Do(this.synchronizeTabs,t,e.clientId,n,e.asyncQueue,ga(),ya(),this.serializer,this.sharedClientState,!!this.forceOwnership)}createSharedClientState(e){return new aa}}class au extends ou{constructor(e,t){super(e,t,!1),this.Wa=e,this.cacheSizeBytes=t,this.synchronizeTabs=!0}async initialize(e){await super.initialize(e);const t=this.Wa.syncEngine;this.sharedClientState instanceof oa&&(this.sharedClientState.syncEngine={no:Jc.bind(null,t),ro:eu.bind(null,t),io:tu.bind(null,t),Qi:Zc.bind(null,t),eo:Qc.bind(null,t)},await this.sharedClientState.start()),await this.persistence.yi((async e=>{await async function(e,t){const n=w(e);if(nu(n),ru(n),!0===t&&!0!==n.Qa){const e=n.sharedClientState.getAllActiveQueryTargets(),t=await Yc(n,e.toArray());n.Qa=!0,await Xa(n.remoteStore,!0);for(const e of t)xa(n.remoteStore,e)}else if(!1===t&&!1!==n.Qa){const e=[];let t=Promise.resolve();n.Ma.forEach(((r,i)=>{n.sharedClientState.isLocalQueryTarget(i)?e.push(i):t=t.then((()=>(jc(n,i),Wo(n.localStore,i,!0)))),ka(n.remoteStore,i)})),await t,await Yc(n,e),function(e){const t=w(e);t.Na.forEach(((e,n)=>{ka(t.remoteStore,n)})),t.La.pr(),t.Na=new Map,t.Oa=new nt(z.comparator)}(n),n.Qa=!1,await Xa(n.remoteStore,!1)}}(this.Wa.syncEngine,e),this.gcScheduler&&(e&&!this.gcScheduler.started?this.gcScheduler.start():e||this.gcScheduler.stop()),this.indexBackfillerScheduler&&(e&&!this.indexBackfillerScheduler.started?this.indexBackfillerScheduler.start():e||this.indexBackfillerScheduler.stop())}))}createSharedClientState(e){const t=ga();if(!oa.D(t))throw new I(_.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");const n=Lo(e.databaseInfo.databaseId,e.databaseInfo.persistenceKey);return new oa(t,e.asyncQueue,n,e.clientId,e.initialUser)}}class cu{async initialize(e,t){this.localStore||(this.localStore=e.localStore,this.sharedClientState=e.sharedClientState,this.datastore=this.createDatastore(t),this.remoteStore=this.createRemoteStore(t),this.eventManager=this.createEventManager(t),this.syncEngine=this.createSyncEngine(t,!e.synchronizeTabs),this.sharedClientState.onlineStateHandler=e=>Pc(this.syncEngine,e,1),this.remoteStore.remoteSyncer.handleCredentialChange=Wc.bind(null,this.syncEngine),await Xa(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return new ac}createDatastore(e){const t=va(e.databaseInfo.databaseId),n=function(e){return new ma(e)}(e.databaseInfo);return function(e,t,n,r){return new Ea(e,t,n,r)}(e.authCredentials,e.appCheckCredentials,n,t)}createRemoteStore(e){return function(e,t,n,r,i){return new Sa(e,t,n,r,i)}(this.localStore,this.datastore,e.asyncQueue,(e=>Pc(this.syncEngine,e,0)),ua.D()?new ua:new ca)}createSyncEngine(e,t){return function(e,t,n,r,i,s,o){const a=new Cc(e,t,n,r,i,s);return o&&(a.Qa=!0),a}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,e.initialUser,e.maxConcurrentLimboResolutions,t)}async terminate(){var e,t;await async function(e){const t=w(e);p("RemoteStore","RemoteStore shutting down."),t.L_.add(5),await Aa(t),t.k_.shutdown(),t.q_.set("Unknown")}(this.remoteStore),null===(e=this.datastore)||void 0===e||e.terminate(),null===(t=this.eventManager)||void 0===t||t.terminate()}}function uu(e,t=10240){let n=0;return{async read(){if(n<e.byteLength){const r={value:e.slice(n,n+t),done:!1};return n+=t,r}return{done:!0}},async cancel(){},releaseLock(){},closed:Promise.resolve()}}class lu{constructor(e){this.observer=e,this.muted=!1}next(e){this.observer.next&&this.Ga(this.observer.next,e)}error(e){this.observer.error?this.Ga(this.observer.error,e):m("Uncaught Error in snapshot listener:",e.toString())}za(){this.muted=!0}Ga(e,t){this.muted||setTimeout((()=>{this.muted||e(t)}),0)}}class hu{constructor(e,t){this.ja=e,this.serializer=t,this.metadata=new E,this.buffer=new Uint8Array,this.Ha=new TextDecoder("utf-8"),this.Ja().then((e=>{e&&e.ua()?this.metadata.resolve(e.aa.metadata):this.metadata.reject(new Error(`The first element of the bundle is not a metadata, it is\n ${JSON.stringify(null==e?void 0:e.aa)}`))}),(e=>this.metadata.reject(e)))}close(){return this.ja.cancel()}async getMetadata(){return this.metadata.promise}async Ua(){return await this.getMetadata(),this.Ja()}async Ja(){const e=await this.Ya();if(null===e)return null;const t=this.Ha.decode(e),n=Number(t);isNaN(n)&&this.Za(`length string (${t}) is not valid number`);const r=await this.Xa(n);return new yc(JSON.parse(r),e.length+n)}eu(){return this.buffer.findIndex((e=>e==="{".charCodeAt(0)))}async Ya(){for(;this.eu()<0&&!await this.tu(););if(0===this.buffer.length)return null;const e=this.eu();e<0&&this.Za("Reached the end of bundle when a length string is expected.");const t=this.buffer.slice(0,e);return this.buffer=this.buffer.slice(e),t}async Xa(e){for(;this.buffer.length<e;)await this.tu()&&this.Za("Reached the end of bundle when more is expected.");const t=this.Ha.decode(this.buffer.slice(0,e));return this.buffer=this.buffer.slice(e),t}Za(e){throw this.ja.cancel(),new Error(`Invalid bundle format: ${e}`)}async tu(){const e=await this.ja.read();if(!e.done){const t=new Uint8Array(this.buffer.length+e.value.length);t.set(this.buffer),t.set(e.value,this.buffer.length),this.buffer=t}return e.done}}class du{constructor(e){this.datastore=e,this.readVersions=new Map,this.mutations=[],this.committed=!1,this.lastTransactionError=null,this.writtenDocs=new Set}async lookup(e){if(this.ensureCommitNotCalled(),this.mutations.length>0)throw this.lastTransactionError=new I(_.INVALID_ARGUMENT,"Firestore transactions require all reads to be executed before all writes."),this.lastTransactionError;const t=await async function(e,t){const n=w(e),r={documents:t.map((e=>wi(n.serializer,e)))},i=await n.Lo("BatchGetDocuments",n.serializer.databaseId,j.emptyPath(),r,t.length),s=new Map;i.forEach((e=>{const t=function(e,t){return"found"in t?function(e,t){b(!!t.found),t.found.name,t.found.updateTime;const n=_i(e,t.found.name),r=gi(t.found.updateTime),i=t.found.createTime?gi(t.found.createTime):V.min(),s=new Kt({mapValue:{fields:t.found.fields}});return $t.newFoundDocument(n,r,i,s)}(e,t):"missing"in t?function(e,t){b(!!t.missing),b(!!t.readTime);const n=_i(e,t.missing),r=gi(t.readTime);return $t.newNoDocument(n,r)}(e,t):v()}(n.serializer,e);s.set(t.key.toString(),t)}));const o=[];return t.forEach((e=>{const t=s.get(e.toString());b(!!t),o.push(t)})),o}(this.datastore,e);return t.forEach((e=>this.recordVersion(e))),t}set(e,t){this.write(t.toMutation(e,this.precondition(e))),this.writtenDocs.add(e.toString())}update(e,t){try{this.write(t.toMutation(e,this.preconditionForUpdate(e)))}catch(e){this.lastTransactionError=e}this.writtenDocs.add(e.toString())}delete(e){this.write(new Lr(e,this.precondition(e))),this.writtenDocs.add(e.toString())}async commit(){if(this.ensureCommitNotCalled(),this.lastTransactionError)throw this.lastTransactionError;const e=this.readVersions;this.mutations.forEach((t=>{e.delete(t.key.toString())})),e.forEach(((e,t)=>{const n=z.fromPath(t);this.mutations.push(new Mr(n,this.precondition(n)))})),await async function(e,t){const n=w(e),r={writes:t.map((e=>xi(n.serializer,e)))};await n.Mo("Commit",n.serializer.databaseId,j.emptyPath(),r)}(this.datastore,this.mutations),this.committed=!0}recordVersion(e){let t;if(e.isFoundDocument())t=e.version;else{if(!e.isNoDocument())throw v();t=V.min()}const n=this.readVersions.get(e.key.toString());if(n){if(!t.isEqual(n))throw new I(_.ABORTED,"Document version changed between two reads.")}else this.readVersions.set(e.key.toString(),t)}precondition(e){const t=this.readVersions.get(e.toString());return!this.writtenDocs.has(e.toString())&&t?t.isEqual(V.min())?Ir.exists(!1):Ir.updateTime(t):Ir.none()}preconditionForUpdate(e){const t=this.readVersions.get(e.toString());if(!this.writtenDocs.has(e.toString())&&t){if(t.isEqual(V.min()))throw new I(_.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return Ir.updateTime(t)}return Ir.exists(!0)}write(e){this.ensureCommitNotCalled(),this.mutations.push(e)}ensureCommitNotCalled(){}}class fu{constructor(e,t,n,r,i){this.asyncQueue=e,this.datastore=t,this.options=n,this.updateFunction=r,this.deferred=i,this.nu=n.maxAttempts,this.t_=new ba(this.asyncQueue,"transaction_retry")}ru(){this.nu-=1,this.iu()}iu(){this.t_.Go((async()=>{const e=new du(this.datastore),t=this.su(e);t&&t.then((t=>{this.asyncQueue.enqueueAndForget((()=>e.commit().then((()=>{this.deferred.resolve(t)})).catch((e=>{this.ou(e)}))))})).catch((e=>{this.ou(e)}))}))}su(e){try{const t=this.updateFunction(e);return!ve(t)&&t.catch&&t.then?t:(this.deferred.reject(Error("Transaction callback must return a Promise")),null)}catch(e){return this.deferred.reject(e),null}}ou(e){this.nu>0&&this._u(e)?(this.nu-=1,this.asyncQueue.enqueueAndForget((()=>(this.iu(),Promise.resolve())))):this.deferred.reject(e)}_u(e){if("FirebaseError"===e.name){const t=e.code;return"aborted"===t||"failed-precondition"===t||"already-exists"===t||!Gr(t)}return!1}}class pu{constructor(e,t,n,r){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=n,this.databaseInfo=r,this.user=l.UNAUTHENTICATED,this.clientId=R.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this.authCredentials.start(n,(async e=>{p("FirestoreClient","Received user=",e.uid),await this.authCredentialListener(e),this.user=e})),this.appCheckCredentials.start(n,(e=>(p("FirestoreClient","Received new app check token=",e),this.appCheckCredentialListener(e,this.user))))}get configuration(){return{asyncQueue:this.asyncQueue,databaseInfo:this.databaseInfo,clientId:this.clientId,authCredentials:this.authCredentials,appCheckCredentials:this.appCheckCredentials,initialUser:this.user,maxConcurrentLimboResolutions:100}}setCredentialChangeListener(e){this.authCredentialListener=e}setAppCheckTokenChangeListener(e){this.appCheckCredentialListener=e}verifyNotTerminated(){if(this.asyncQueue.isShuttingDown)throw new I(_.FAILED_PRECONDITION,"The client has already been terminated.")}terminate(){this.asyncQueue.enterRestrictedMode();const e=new E;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted((async()=>{try{this._onlineComponents&&await this._onlineComponents.terminate(),this._offlineComponents&&await this._offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),e.resolve()}catch(t){const n=nc(t,"Failed to shutdown persistence");e.reject(n)}})),e.promise}}async function mu(e,t){e.asyncQueue.verifyOperationInProgress(),p("FirestoreClient","Initializing OfflineComponentProvider");const n=e.configuration;await t.initialize(n);let r=n.initialUser;e.setCredentialChangeListener((async e=>{r.isEqual(e)||(await Bo(t.localStore,e),r=e)})),t.persistence.setDatabaseDeletedListener((()=>e.terminate())),e._offlineComponents=t}async function gu(e,t){e.asyncQueue.verifyOperationInProgress();const n=await vu(e);p("FirestoreClient","Initializing OnlineComponentProvider"),await t.initialize(n,e.configuration),e.setCredentialChangeListener((e=>Ya(t.remoteStore,e))),e.setAppCheckTokenChangeListener(((e,n)=>Ya(t.remoteStore,n))),e._onlineComponents=t}function yu(e){return"FirebaseError"===e.name?e.code===_.FAILED_PRECONDITION||e.code===_.UNIMPLEMENTED:!("undefined"!=typeof DOMException&&e instanceof DOMException)||22===e.code||20===e.code||11===e.code}async function vu(e){if(!e._offlineComponents)if(e._uninitializedComponentsProvider){p("FirestoreClient","Using user provided OfflineComponentProvider");try{await mu(e,e._uninitializedComponentsProvider._offline)}catch(t){const n=t;if(!yu(n))throw n;g("Error using user provided cache. Falling back to memory cache: "+n),await mu(e,new iu)}}else p("FirestoreClient","Using default OfflineComponentProvider"),await mu(e,new iu);return e._offlineComponents}async function bu(e){return e._onlineComponents||(e._uninitializedComponentsProvider?(p("FirestoreClient","Using user provided OnlineComponentProvider"),await gu(e,e._uninitializedComponentsProvider._online)):(p("FirestoreClient","Using default OnlineComponentProvider"),await gu(e,new cu))),e._onlineComponents}function wu(e){return vu(e).then((e=>e.persistence))}function _u(e){return vu(e).then((e=>e.localStore))}function Iu(e){return bu(e).then((e=>e.remoteStore))}function Eu(e){return bu(e).then((e=>e.syncEngine))}function Tu(e){return bu(e).then((e=>e.datastore))}async function Su(e){const t=await bu(e),n=t.eventManager;return n.onListen=Ac.bind(null,t.syncEngine),n.onUnlisten=Oc.bind(null,t.syncEngine),n.onFirstRemoteStoreListen=xc.bind(null,t.syncEngine),n.onLastRemoteStoreUnlisten=Dc.bind(null,t.syncEngine),n}function Cu(e,t,n={}){const r=new E;return e.asyncQueue.enqueueAndForget((async()=>function(e,t,n,r,i){const s=new lu({next:s=>{t.enqueueAndForget((()=>lc(e,o)));const a=s.docs.has(n);!a&&s.fromCache?i.reject(new I(_.UNAVAILABLE,"Failed to get document because the client is offline.")):a&&s.fromCache&&r&&"server"===r.source?i.reject(new I(_.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:e=>i.reject(e)}),o=new gc(kn(n.path),s,{includeMetadataChanges:!0,_a:!0});return uc(e,o)}(await Su(e),e.asyncQueue,t,n,r))),r.promise}function Au(e,t,n={}){const r=new E;return e.asyncQueue.enqueueAndForget((async()=>function(e,t,n,r,i){const s=new lu({next:n=>{t.enqueueAndForget((()=>lc(e,o))),n.fromCache&&"server"===r.source?i.reject(new I(_.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:e=>i.reject(e)}),o=new gc(n,s,{includeMetadataChanges:!0,_a:!0});return uc(e,o)}(await Su(e),e.asyncQueue,t,n,r))),r.promise}function xu(e){const t={};return void 0!==e.timeoutSeconds&&(t.timeoutSeconds=e.timeoutSeconds),t}const ku=new Map;function Nu(e,t,n){if(!n)throw new I(_.INVALID_ARGUMENT,`Function ${e}() cannot be called with an empty ${t}.`)}function Ou(e,t,n,r){if(!0===t&&!0===r)throw new I(_.INVALID_ARGUMENT,`${e} and ${n} cannot be used together.`)}function Du(e){if(!z.isDocumentKey(e))throw new I(_.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${e} has ${e.length}.`)}function Ru(e){if(z.isDocumentKey(e))throw new I(_.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${e} has ${e.length}.`)}function Pu(e){if(void 0===e)return"undefined";if(null===e)return"null";if("string"==typeof e)return e.length>20&&(e=`${e.substring(0,20)}...`),JSON.stringify(e);if("number"==typeof e||"boolean"==typeof e)return""+e;if("object"==typeof e){if(e instanceof Array)return"an array";{const t=function(e){return e.constructor?e.constructor.name:null}(e);return t?`a custom ${t} object`:"an object"}}return"function"==typeof e?"a function":v()}function Lu(e,t){if("_delegate"in e&&(e=e._delegate),!(e instanceof t)){if(t.name===e.constructor.name)throw new I(_.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{const n=Pu(e);throw new I(_.INVALID_ARGUMENT,`Expected type '${t.name}', but it was: ${n}`)}}return e}function Mu(e,t){if(t<=0)throw new I(_.INVALID_ARGUMENT,`Function ${e}() requires a positive number, but it was: ${t}.`)}class Fu{constructor(e){var t,n;if(void 0===e.host){if(void 0!==e.ssl)throw new I(_.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host="firestore.googleapis.com",this.ssl=!0}else this.host=e.host,this.ssl=null===(t=e.ssl)||void 0===t||t;if(this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,this.localCache=e.localCache,void 0===e.cacheSizeBytes)this.cacheSizeBytes=41943040;else{if(-1!==e.cacheSizeBytes&&e.cacheSizeBytes<1048576)throw new I(_.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}Ou("experimentalForceLongPolling",e.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",e.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!e.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:void 0===e.experimentalAutoDetectLongPolling?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!e.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=xu(null!==(n=e.experimentalLongPollingOptions)&&void 0!==n?n:{}),function(e){if(void 0!==e.timeoutSeconds){if(isNaN(e.timeoutSeconds))throw new I(_.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (must not be NaN)`);if(e.timeoutSeconds<5)throw new I(_.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (minimum allowed value is 5)`);if(e.timeoutSeconds>30)throw new I(_.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (maximum allowed value is 30)`)}}(this.experimentalLongPollingOptions),this.useFetchStreams=!!e.useFetchStreams}isEqual(e){return this.host===e.host&&this.ssl===e.ssl&&this.credentials===e.credentials&&this.cacheSizeBytes===e.cacheSizeBytes&&this.experimentalForceLongPolling===e.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===e.experimentalAutoDetectLongPolling&&function(e,t){return e.timeoutSeconds===t.timeoutSeconds}(this.experimentalLongPollingOptions,e.experimentalLongPollingOptions)&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams}}class Vu{constructor(e,t,n,r){this._authCredentials=e,this._appCheckCredentials=t,this._databaseId=n,this._app=r,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new Fu({}),this._settingsFrozen=!1}get app(){if(!this._app)throw new I(_.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(e){if(this._settingsFrozen)throw new I(_.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 Fu(e),void 0!==e.credentials&&(this._authCredentials=function(e){if(!e)return new S;switch(e.type){case"firstParty":return new k(e.sessionIndex||"0",e.iamToken||null,e.authTokenFactory||null);case"provider":return e.client;default:throw new I(_.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invalid credential type")}}(e.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(e){const t=ku.get(e);t&&(p("ComponentProvider","Removing Datastore"),ku.delete(e),t.terminate())}(this),Promise.resolve()}}function Uu(e,t,n,r={}){var i;const s=(e=Lu(e,Vu))._getSettings(),a=`${t}:${n}`;if("firestore.googleapis.com"!==s.host&&s.host!==a&&g("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used."),e._setSettings(Object.assign(Object.assign({},s),{host:a,ssl:!1})),r.mockUserToken){let t,n;if("string"==typeof r.mockUserToken)t=r.mockUserToken,n=l.MOCK_USER;else{t=o.createMockUserToken(r.mockUserToken,null===(i=e._app)||void 0===i?void 0:i.options.projectId);const s=r.mockUserToken.sub||r.mockUserToken.user_id;if(!s)throw new I(_.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");n=new l(s)}e._authCredentials=new C(new T(t,n))}}class ju{constructor(e,t,n){this.converter=t,this._query=n,this.type="query",this.firestore=e}withConverter(e){return new ju(this.firestore,e,this._query)}}class Bu{constructor(e,t,n){this.converter=t,this._key=n,this.type="document",this.firestore=e}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new qu(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new Bu(this.firestore,e,this._key)}}class qu extends ju{constructor(e,t,n){super(e,t,kn(n)),this._path=n,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){const e=this._path.popLast();return e.isEmpty()?null:new Bu(this.firestore,null,new z(e))}withConverter(e){return new qu(this.firestore,e,this._path)}}function zu(e,t,...n){if(e=o.getModularInstance(e),1===arguments.length&&(t=R.newId()),Nu("doc","path",t),e instanceof Vu){const r=j.fromString(t,...n);return Du(r),new Bu(e,null,new z(r))}{if(!(e instanceof Bu||e instanceof qu))throw new I(_.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=e._path.child(j.fromString(t,...n));return Du(r),new Bu(e.firestore,e instanceof qu?e.converter:null,new z(r))}}function Gu(e,t){return e=o.getModularInstance(e),t=o.getModularInstance(t),e instanceof ju&&t instanceof ju&&e.firestore===t.firestore&&Vn(e._query,t._query)&&e.converter===t.converter}class Ku{constructor(){this.au=Promise.resolve(),this.uu=[],this.cu=!1,this.lu=[],this.hu=null,this.Pu=!1,this.Iu=!1,this.Tu=[],this.t_=new ba(this,"async_queue_retry"),this.Eu=()=>{const e=ya();e&&p("AsyncQueue","Visibility state changed to "+e.visibilityState),this.t_.jo()};const e=ya();e&&"function"==typeof e.addEventListener&&e.addEventListener("visibilitychange",this.Eu)}get isShuttingDown(){return this.cu}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.du(),this.Au(e)}enterRestrictedMode(e){if(!this.cu){this.cu=!0,this.Iu=e||!1;const t=ya();t&&"function"==typeof t.removeEventListener&&t.removeEventListener("visibilitychange",this.Eu)}}enqueue(e){if(this.du(),this.cu)return new Promise((()=>{}));const t=new E;return this.Au((()=>this.cu&&this.Iu?Promise.resolve():(e().then(t.resolve,t.reject),t.promise))).then((()=>t.promise))}enqueueRetryable(e){this.enqueueAndForget((()=>(this.uu.push(e),this.Ru())))}async Ru(){if(0!==this.uu.length){try{await this.uu[0](),this.uu.shift(),this.t_.reset()}catch(e){if(!le(e))throw e;p("AsyncQueue","Operation failed with retryable error: "+e)}this.uu.length>0&&this.t_.Go((()=>this.Ru()))}}Au(e){const t=this.au.then((()=>(this.Pu=!0,e().catch((e=>{this.hu=e,this.Pu=!1;const t=function(e){let t=e.message||"";return e.stack&&(t=e.stack.includes(e.message)?e.stack:e.message+"\n"+e.stack),t}(e);throw m("INTERNAL UNHANDLED ERROR: ",t),e})).then((e=>(this.Pu=!1,e))))));return this.au=t,t}enqueueAfterDelay(e,t,n){this.du(),this.Tu.indexOf(e)>-1&&(t=0);const r=tc.createAndSchedule(this,e,t,n,(e=>this.Vu(e)));return this.lu.push(r),r}du(){this.hu&&v()}verifyOperationInProgress(){}async mu(){let e;do{e=this.au,await e}while(e!==this.au)}fu(e){for(const t of this.lu)if(t.timerId===e)return!0;return!1}gu(e){return this.mu().then((()=>{this.lu.sort(((e,t)=>e.targetTimeMs-t.targetTimeMs));for(const t of this.lu)if(t.skipDelay(),"all"!==e&&t.timerId===e)break;return this.mu()}))}pu(e){this.Tu.push(e)}Vu(e){const t=this.lu.indexOf(e);this.lu.splice(t,1)}}function Wu(e){return function(e){if("object"!=typeof e||null===e)return!1;const t=e;for(const e of["next","error","complete"])if(e in t&&"function"==typeof t[e])return!0;return!1}(e)}class $u{constructor(){this._progressObserver={},this._taskCompletionResolver=new E,this._lastProgress={taskState:"Running",totalBytes:0,totalDocuments:0,bytesLoaded:0,documentsLoaded:0}}onProgress(e,t,n){this._progressObserver={next:e,error:t,complete:n}}catch(e){return this._taskCompletionResolver.promise.catch(e)}then(e,t){return this._taskCompletionResolver.promise.then(e,t)}_completeWith(e){this._updateProgress(e),this._progressObserver.complete&&this._progressObserver.complete(),this._taskCompletionResolver.resolve(e)}_failWith(e){this._lastProgress.taskState="Error",this._progressObserver.next&&this._progressObserver.next(this._lastProgress),this._progressObserver.error&&this._progressObserver.error(e),this._taskCompletionResolver.reject(e)}_updateProgress(e){this._lastProgress=e,this._progressObserver.next&&this._progressObserver.next(e)}}class Hu extends Vu{constructor(e,t,n,r){super(e,t,n,r),this.type="firestore",this._queue=new Ku,this._persistenceKey=(null==r?void 0:r.name)||"[DEFAULT]"}_terminate(){return this._firestoreClient||Ju(this),this._firestoreClient.terminate()}}function Qu(e){return e._firestoreClient||Ju(e),e._firestoreClient.verifyNotTerminated(),e._firestoreClient}function Ju(e){var t,n,r;const i=e._freezeSettings(),s=function(e,t,n,r){return new vt(e,t,n,r.host,r.ssl,r.experimentalForceLongPolling,r.experimentalAutoDetectLongPolling,xu(r.experimentalLongPollingOptions),r.useFetchStreams)}(e._databaseId,(null===(t=e._app)||void 0===t?void 0:t.options.appId)||"",e._persistenceKey,i);e._firestoreClient=new pu(e._authCredentials,e._appCheckCredentials,e._queue,s),(null===(n=i.localCache)||void 0===n?void 0:n._offlineComponentProvider)&&(null===(r=i.localCache)||void 0===r?void 0:r._onlineComponentProvider)&&(e._firestoreClient._uninitializedComponentsProvider={_offlineKind:i.localCache.kind,_offline:i.localCache._offlineComponentProvider,_online:i.localCache._onlineComponentProvider})}function Yu(e,t,n){const r=new E;return e.asyncQueue.enqueue((async()=>{try{await mu(e,n),await gu(e,t),r.resolve()}catch(e){const t=e;if(!yu(t))throw t;g("Error enabling indexeddb cache. Falling back to memory cache: "+t),r.reject(t)}})).then((()=>r.promise))}function Xu(e){if(e._initialized||e._terminated)throw new I(_.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 Zu{constructor(e="count",t){this._internalFieldPath=t,this.type="AggregateField",this.aggregateType=e}}class el{constructor(e,t,n){this._userDataWriter=t,this._data=n,this.type="AggregateQuerySnapshot",this.query=e}data(){return this._userDataWriter.convertObjectMap(this._data)}}class tl{constructor(e){this._byteString=e}static fromBase64String(e){try{return new tl(lt.fromBase64String(e))}catch(e){throw new I(_.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+e)}}static fromUint8Array(e){return new tl(lt.fromUint8Array(e))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(e){return this._byteString.isEqual(e._byteString)}}class nl{constructor(...e){for(let t=0;t<e.length;++t)if(0===e[t].length)throw new I(_.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new q(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}}class rl{constructor(e){this._methodName=e}}class il{constructor(e,t){if(!isFinite(e)||e<-90||e>90)throw new I(_.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(t)||t<-180||t>180)throw new I(_.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+t);this._lat=e,this._long=t}get latitude(){return this._lat}get longitude(){return this._long}isEqual(e){return this._lat===e._lat&&this._long===e._long}toJSON(){return{latitude:this._lat,longitude:this._long}}_compareTo(e){return P(this._lat,e._lat)||P(this._long,e._long)}}class sl{constructor(e){this._values=(e||[]).map((e=>e))}toArray(){return this._values.map((e=>e))}isEqual(e){return function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0}(this._values,e._values)}}const ol=/^__.*__$/;class al{constructor(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}toMutation(e,t){return null!==this.fieldMask?new Or(e,this.data,this.fieldMask,t,this.fieldTransforms):new Nr(e,this.data,t,this.fieldTransforms)}}class cl{constructor(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}toMutation(e,t){return new Or(e,this.data,this.fieldMask,t,this.fieldTransforms)}}function ul(e){switch(e){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw v()}}class ll{constructor(e,t,n,r,i,s){this.settings=e,this.databaseId=t,this.serializer=n,this.ignoreUndefinedProperties=r,void 0===i&&this.yu(),this.fieldTransforms=i||[],this.fieldMask=s||[]}get path(){return this.settings.path}get wu(){return this.settings.wu}Su(e){return new ll(Object.assign(Object.assign({},this.settings),e),this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}bu(e){var t;const n=null===(t=this.path)||void 0===t?void 0:t.child(e),r=this.Su({path:n,Du:!1});return r.vu(e),r}Cu(e){var t;const n=null===(t=this.path)||void 0===t?void 0:t.child(e),r=this.Su({path:n,Du:!1});return r.yu(),r}Fu(e){return this.Su({path:void 0,Du:!0})}Mu(e){return Nl(e,this.settings.methodName,this.settings.xu||!1,this.path,this.settings.Ou)}contains(e){return void 0!==this.fieldMask.find((t=>e.isPrefixOf(t)))||void 0!==this.fieldTransforms.find((t=>e.isPrefixOf(t.field)))}yu(){if(this.path)for(let e=0;e<this.path.length;e++)this.vu(this.path.get(e))}vu(e){if(0===e.length)throw this.Mu("Document fields must not be empty");if(ul(this.wu)&&ol.test(e))throw this.Mu('Document fields cannot begin and end with "__"')}}class hl{constructor(e,t,n){this.databaseId=e,this.ignoreUndefinedProperties=t,this.serializer=n||va(e)}Nu(e,t,n,r=!1){return new ll({wu:e,methodName:t,Ou:n,path:q.emptyPath(),Du:!1,xu:r},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}}function dl(e){const t=e._freezeSettings(),n=va(e._databaseId);return new hl(e._databaseId,!!t.ignoreUndefinedProperties,n)}function fl(e,t,n,r,i,s={}){const o=e.Nu(s.merge||s.mergeFields?2:0,t,n,i);Cl("Data must be an object, but it was:",o,r);const a=Tl(r,o);let c,u;if(s.merge)c=new ct(o.fieldMask),u=o.fieldTransforms;else if(s.mergeFields){const e=[];for(const r of s.mergeFields){const i=Al(t,r,n);if(!o.contains(i))throw new I(_.INVALID_ARGUMENT,`Field '${i}' is specified in your field mask but missing from your input data.`);Ol(e,i)||e.push(i)}c=new ct(e),u=o.fieldTransforms.filter((e=>c.covers(e.field)))}else c=null,u=o.fieldTransforms;return new al(new Kt(a),c,u)}class pl extends rl{_toFieldTransform(e){if(2!==e.wu)throw 1===e.wu?e.Mu(`${this._methodName}() can only appear at the top level of your update data`):e.Mu(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return e.fieldMask.push(e.path),null}isEqual(e){return e instanceof pl}}function ml(e,t,n){return new ll({wu:3,Ou:t.settings.Ou,methodName:e._methodName,Du:n},t.databaseId,t.serializer,t.ignoreUndefinedProperties)}class gl extends rl{_toFieldTransform(e){return new wr(e.path,new dr)}isEqual(e){return e instanceof gl}}class yl extends rl{constructor(e,t){super(e),this.Lu=t}_toFieldTransform(e){const t=ml(this,e,!0),n=this.Lu.map((e=>El(e,t))),r=new fr(n);return new wr(e.path,r)}isEqual(e){return e instanceof yl&&o.deepEqual(this.Lu,e.Lu)}}class vl extends rl{constructor(e,t){super(e),this.Lu=t}_toFieldTransform(e){const t=ml(this,e,!0),n=this.Lu.map((e=>El(e,t))),r=new mr(n);return new wr(e.path,r)}isEqual(e){return e instanceof vl&&o.deepEqual(this.Lu,e.Lu)}}class bl extends rl{constructor(e,t){super(e),this.Bu=t}_toFieldTransform(e){const t=new yr(e.serializer,ar(e.serializer,this.Bu));return new wr(e.path,t)}isEqual(e){return e instanceof bl&&this.Bu===e.Bu}}function wl(e,t,n,r){const i=e.Nu(1,t,n);Cl("Data must be an object, but it was:",i,r);const s=[],a=Kt.empty();Ze(r,((e,r)=>{const c=kl(t,e,n);r=o.getModularInstance(r);const u=i.Cu(c);if(r instanceof pl)s.push(c);else{const e=El(r,u);null!=e&&(s.push(c),a.set(c,e))}}));const c=new ct(s);return new cl(a,c,i.fieldTransforms)}function _l(e,t,n,r,i,s){const a=e.Nu(1,t,n),c=[Al(t,r,n)],u=[i];if(s.length%2!=0)throw new I(_.INVALID_ARGUMENT,`Function ${t}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let e=0;e<s.length;e+=2)c.push(Al(t,s[e])),u.push(s[e+1]);const l=[],h=Kt.empty();for(let e=c.length-1;e>=0;--e)if(!Ol(l,c[e])){const t=c[e];let n=u[e];n=o.getModularInstance(n);const r=a.Cu(t);if(n instanceof pl)l.push(t);else{const e=El(n,r);null!=e&&(l.push(t),h.set(t,e))}}const d=new ct(l);return new cl(h,d,a.fieldTransforms)}function Il(e,t,n,r=!1){return El(n,e.Nu(r?4:3,t))}function El(e,t){if(Sl(e=o.getModularInstance(e)))return Cl("Unsupported field value:",t,e),Tl(e,t);if(e instanceof rl)return function(e,t){if(!ul(t.wu))throw t.Mu(`${e._methodName}() can only be used with update() and set()`);if(!t.path)throw t.Mu(`${e._methodName}() is not currently supported inside arrays`);const n=e._toFieldTransform(t);n&&t.fieldTransforms.push(n)}(e,t),null;if(void 0===e&&t.ignoreUndefinedProperties)return null;if(t.path&&t.fieldMask.push(t.path),e instanceof Array){if(t.settings.Du&&4!==t.wu)throw t.Mu("Nested arrays are not supported");return function(e,t){const n=[];let r=0;for(const i of e){let e=El(i,t.Fu(r));null==e&&(e={nullValue:"NULL_VALUE"}),n.push(e),r++}return{arrayValue:{values:n}}}(e,t)}return function(e,t){if(null===(e=o.getModularInstance(e)))return{nullValue:"NULL_VALUE"};if("number"==typeof e)return ar(t.serializer,e);if("boolean"==typeof e)return{booleanValue:e};if("string"==typeof e)return{stringValue:e};if(e instanceof Date){const n=F.fromDate(e);return{timestampValue:fi(t.serializer,n)}}if(e instanceof F){const n=new F(e.seconds,1e3*Math.floor(e.nanoseconds/1e3));return{timestampValue:fi(t.serializer,n)}}if(e instanceof il)return{geoPointValue:{latitude:e.latitude,longitude:e.longitude}};if(e instanceof tl)return{bytesValue:pi(t.serializer,e._byteString)};if(e instanceof Bu){const n=t.databaseId,r=e.firestore._databaseId;if(!r.isEqual(n))throw t.Mu(`Document reference is for database ${r.projectId}/${r.database} but should be for database ${n.projectId}/${n.database}`);return{referenceValue:yi(e.firestore._databaseId||t.databaseId,e._key.path)}}if(e instanceof sl)return function(e,t){return{mapValue:{fields:{__type__:{stringValue:"__vector__"},value:{arrayValue:{values:e.toArray().map((e=>{if("number"!=typeof e)throw t.Mu("VectorValues must only contain numeric values.");return sr(t.serializer,e)}))}}}}}}(e,t);throw t.Mu(`Unsupported field value: ${Pu(e)}`)}(e,t)}function Tl(e,t){const n={};return tt(e)?t.path&&t.path.length>0&&t.fieldMask.push(t.path):Ze(e,((e,r)=>{const i=El(r,t.bu(e));null!=i&&(n[e]=i)})),{mapValue:{fields:n}}}function Sl(e){return!("object"!=typeof e||null===e||e instanceof Array||e instanceof Date||e instanceof F||e instanceof il||e instanceof tl||e instanceof Bu||e instanceof rl||e instanceof sl)}function Cl(e,t,n){if(!Sl(n)||!function(e){return"object"==typeof e&&null!==e&&(Object.getPrototypeOf(e)===Object.prototype||null===Object.getPrototypeOf(e))}(n)){const r=Pu(n);throw"an object"===r?t.Mu(e+" a custom object"):t.Mu(e+" "+r)}}function Al(e,t,n){if((t=o.getModularInstance(t))instanceof nl)return t._internalPath;if("string"==typeof t)return kl(e,t);throw Nl("Field path arguments must be of type string or ",e,!1,void 0,n)}const xl=new RegExp("[~\\*/\\[\\]]");function kl(e,t,n){if(t.search(xl)>=0)throw Nl(`Invalid field path (${t}). Paths must not contain '~', '*', '/', '[', or ']'`,e,!1,void 0,n);try{return new nl(...t.split("."))._internalPath}catch(r){throw Nl(`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,e,!1,void 0,n)}}function Nl(e,t,n,r,i){const s=r&&!r.isEmpty(),o=void 0!==i;let a=`Function ${t}() 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 I(_.INVALID_ARGUMENT,a+e+c)}function Ol(e,t){return e.some((e=>e.isEqual(t)))}class Dl{constructor(e,t,n,r,i){this._firestore=e,this._userDataWriter=t,this._key=n,this._document=r,this._converter=i}get id(){return this._key.path.lastSegment()}get ref(){return new Bu(this._firestore,this._converter,this._key)}exists(){return null!==this._document}data(){if(this._document){if(this._converter){const e=new Rl(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(e)}return this._userDataWriter.convertValue(this._document.data.value)}}get(e){if(this._document){const t=this._document.data.field(Pl("DocumentSnapshot.get",e));if(null!==t)return this._userDataWriter.convertValue(t)}}}class Rl extends Dl{data(){return super.data()}}function Pl(e,t){return"string"==typeof t?kl(e,t):t instanceof nl?t._internalPath:t._delegate._internalPath}function Ll(e){if("L"===e.limitType&&0===e.explicitOrderBy.length)throw new I(_.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class Ml{}class Fl extends Ml{}class Vl extends Fl{constructor(e,t,n){super(),this._field=e,this._op=t,this._value=n,this.type="where"}static _create(e,t,n){return new Vl(e,t,n)}_apply(e){const t=this._parse(e);return $l(e._query,t),new ju(e.firestore,e.converter,Mn(e._query,t))}_parse(e){const t=dl(e.firestore),n=function(e,t,n,r,i,s,o){let a;if(i.isKeyField()){if("array-contains"===s||"array-contains-any"===s)throw new I(_.INVALID_ARGUMENT,`Invalid Query. You can't perform '${s}' queries on documentId().`);if("in"===s||"not-in"===s){Wl(o,s);const t=[];for(const n of o)t.push(Kl(r,e,n));a={arrayValue:{values:t}}}else a=Kl(r,e,o)}else"in"!==s&&"not-in"!==s&&"array-contains-any"!==s||Wl(o,s),a=Il(n,"where",o,"in"===s||"not-in"===s);return en.create(i,s,a)}(e._query,0,t,e.firestore._databaseId,this._field,this._op,this._value);return n}}class Ul extends Ml{constructor(e,t){super(),this.type=e,this._queryConstraints=t}static _create(e,t){return new Ul(e,t)}_parse(e){const t=this._queryConstraints.map((t=>t._parse(e))).filter((e=>e.getFilters().length>0));return 1===t.length?t[0]:tn.create(t,this._getOperator())}_apply(e){const t=this._parse(e);return 0===t.getFilters().length?e:(function(e,t){let n=e;const r=t.getFlattenedFilters();for(const e of r)$l(n,e),n=Mn(n,e)}(e._query,t),new ju(e.firestore,e.converter,Mn(e._query,t)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return"and"===this.type?"and":"or"}}class jl extends Fl{constructor(e,t){super(),this._field=e,this._direction=t,this.type="orderBy"}static _create(e,t){return new jl(e,t)}_apply(e){const t=function(e,t,n){if(null!==e.startAt)throw new I(_.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(null!==e.endAt)throw new I(_.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");return new Yt(t,n)}(e._query,this._field,this._direction);return new ju(e.firestore,e.converter,function(e,t){const n=e.explicitOrderBy.concat([t]);return new An(e.path,e.collectionGroup,n,e.filters.slice(),e.limit,e.limitType,e.startAt,e.endAt)}(e._query,t))}}class Bl extends Fl{constructor(e,t,n){super(),this.type=e,this._limit=t,this._limitType=n}static _create(e,t,n){return new Bl(e,t,n)}_apply(e){return new ju(e.firestore,e.converter,Fn(e._query,this._limit,this._limitType))}}class ql extends Fl{constructor(e,t,n){super(),this.type=e,this._docOrFields=t,this._inclusive=n}static _create(e,t,n){return new ql(e,t,n)}_apply(e){const t=Gl(e,this.type,this._docOrFields,this._inclusive);return new ju(e.firestore,e.converter,function(e,t){return new An(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),e.limit,e.limitType,t,e.endAt)}(e._query,t))}}class zl extends Fl{constructor(e,t,n){super(),this.type=e,this._docOrFields=t,this._inclusive=n}static _create(e,t,n){return new zl(e,t,n)}_apply(e){const t=Gl(e,this.type,this._docOrFields,this._inclusive);return new ju(e.firestore,e.converter,function(e,t){return new An(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),e.limit,e.limitType,e.startAt,t)}(e._query,t))}}function Gl(e,t,n,r){if(n[0]=o.getModularInstance(n[0]),n[0]instanceof Dl)return function(e,t,n,r,i){if(!r)throw new I(_.NOT_FOUND,`Can't use a DocumentSnapshot that doesn't exist for ${n}().`);const s=[];for(const n of Dn(e))if(n.field.isKeyField())s.push(Ot(t,r.key));else{const e=r.data.field(n.field);if(mt(e))throw new I(_.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===e){const e=n.field.canonicalString();throw new I(_.INVALID_ARGUMENT,`Invalid query. You are trying to start or end a query using a document for which the field '${e}' (used as the orderBy) does not exist.`)}s.push(e)}return new Ht(s,i)}(e._query,e.firestore._databaseId,t,n[0]._document,r);{const i=dl(e.firestore);return function(e,t,n,r,i,s){const o=e.explicitOrderBy;if(i.length>o.length)throw new I(_.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 I(_.INVALID_ARGUMENT,`Invalid query. Expected a string for document ID in ${r}(), but got a ${typeof c}`);if(!On(e)&&-1!==c.indexOf("/"))throw new I(_.INVALID_ARGUMENT,`Invalid query. When querying a collection and ordering by documentId(), the value passed to ${r}() must be a plain document ID, but '${c}' contains a slash.`);const n=e.path.child(j.fromString(c));if(!z.isDocumentKey(n))throw new I(_.INVALID_ARGUMENT,`Invalid query. When querying a collection group and ordering by 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 z(n);a.push(Ot(t,i))}else{const e=Il(n,r,c);a.push(e)}}return new Ht(a,s)}(e._query,e.firestore._databaseId,i,t,n,r)}}function Kl(e,t,n){if("string"==typeof(n=o.getModularInstance(n))){if(""===n)throw new I(_.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!On(t)&&-1!==n.indexOf("/"))throw new I(_.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${n}' contains a '/' character.`);const r=t.path.child(j.fromString(n));if(!z.isDocumentKey(r))throw new I(_.INVALID_ARGUMENT,`Invalid query. When querying a collection group by 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 Ot(e,new z(r))}if(n instanceof Bu)return Ot(e,n._key);throw new I(_.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${Pu(n)}.`)}function Wl(e,t){if(!Array.isArray(e)||0===e.length)throw new I(_.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${t.toString()}' filters.`)}function $l(e,t){const n=function(e,t){for(const n of e)for(const e of n.getFlattenedFilters())if(t.indexOf(e.op)>=0)return e.op;return null}(e.filters,function(e){switch(e){case"!=":return["!=","not-in"];case"array-contains-any":case"in":return["not-in"];case"not-in":return["array-contains-any","in","not-in","!="];default:return[]}}(t.op));if(null!==n)throw n===t.op?new I(_.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${t.op.toString()}' filter.`):new I(_.INVALID_ARGUMENT,`Invalid query. You cannot use '${t.op.toString()}' filters with '${n.toString()}' filters.`)}function Hl(e,t){if(!(t instanceof Vl||t instanceof Ul))throw new I(_.INVALID_ARGUMENT,`Function ${e}() requires AppliableConstraints created with a call to 'where(...)', 'or(...)', or 'and(...)'.`)}class Ql{convertValue(e,t="none"){switch(It(e)){case 0:return null;case 1:return e.booleanValue;case 2:return ft(e.integerValue||e.doubleValue);case 3:return this.convertTimestamp(e.timestampValue);case 4:return this.convertServerTimestamp(e,t);case 5:return e.stringValue;case 6:return this.convertBytes(pt(e.bytesValue));case 7:return this.convertReference(e.referenceValue);case 8:return this.convertGeoPoint(e.geoPointValue);case 9:return this.convertArray(e.arrayValue,t);case 11:return this.convertObject(e.mapValue,t);case 10:return this.convertVectorValue(e.mapValue);default:throw v()}}convertObject(e,t){return this.convertObjectMap(e.fields,t)}convertObjectMap(e,t="none"){const n={};return Ze(e,((e,r)=>{n[e]=this.convertValue(r,t)})),n}convertVectorValue(e){var t,n,r;const i=null===(r=null===(n=null===(t=e.fields)||void 0===t?void 0:t.value.arrayValue)||void 0===n?void 0:n.values)||void 0===r?void 0:r.map((e=>ft(e.doubleValue)));return new sl(i)}convertGeoPoint(e){return new il(ft(e.latitude),ft(e.longitude))}convertArray(e,t){return(e.values||[]).map((e=>this.convertValue(e,t)))}convertServerTimestamp(e,t){switch(t){case"previous":const n=gt(e);return null==n?null:this.convertValue(n,t);case"estimate":return this.convertTimestamp(yt(e));default:return null}}convertTimestamp(e){const t=dt(e);return new F(t.seconds,t.nanos)}convertDocumentKey(e,t){const n=j.fromString(e);b(qi(n));const r=new bt(n.get(1),n.get(3)),i=new z(n.popFirst(5));return r.isEqual(t)||m(`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 (${t.projectId}/${t.database}) instead.`),i}}function Jl(e,t,n){let r;return r=e?n&&(n.merge||n.mergeFields)?e.toFirestore(t,n):e.toFirestore(t):t,r}class Yl extends Ql{constructor(e){super(),this.firestore=e}convertBytes(e){return new tl(e)}convertReference(e){const t=this.convertDocumentKey(e,this.firestore._databaseId);return new Bu(this.firestore,null,t)}}function Xl(){return new Zu("count")}class Zl{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}}class eh extends Dl{constructor(e,t,n,r,i,s){super(e,t,n,r,s),this._firestore=e,this._firestoreImpl=e,this.metadata=i}exists(){return super.exists()}data(e={}){if(this._document){if(this._converter){const t=new th(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(t,e)}return this._userDataWriter.convertValue(this._document.data.value,e.serverTimestamps)}}get(e,t={}){if(this._document){const n=this._document.data.field(Pl("DocumentSnapshot.get",e));if(null!==n)return this._userDataWriter.convertValue(n,t.serverTimestamps)}}}class th extends eh{data(e={}){return super.data(e)}}class nh{constructor(e,t,n,r){this._firestore=e,this._userDataWriter=t,this._snapshot=r,this.metadata=new Zl(r.hasPendingWrites,r.fromCache),this.query=n}get docs(){const e=[];return this.forEach((t=>e.push(t))),e}get size(){return this._snapshot.docs.size}get empty(){return 0===this.size}forEach(e,t){this._snapshot.docs.forEach((n=>{e.call(t,new th(this._firestore,this._userDataWriter,n.key,n,new Zl(this._snapshot.mutatedKeys.has(n.key),this._snapshot.fromCache),this.query.converter))}))}docChanges(e={}){const t=!!e.includeMetadataChanges;if(t&&this._snapshot.excludesMetadataChanges)throw new I(_.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===t||(this._cachedChanges=function(e,t){if(e._snapshot.oldDocs.isEmpty()){let t=0;return e._snapshot.docChanges.map((n=>{const r=new th(e._firestore,e._userDataWriter,n.doc.key,n.doc,new Zl(e._snapshot.mutatedKeys.has(n.doc.key),e._snapshot.fromCache),e.query.converter);return n.doc,{type:"added",doc:r,oldIndex:-1,newIndex:t++}}))}{let n=e._snapshot.oldDocs;return e._snapshot.docChanges.filter((e=>t||3!==e.type)).map((t=>{const r=new th(e._firestore,e._userDataWriter,t.doc.key,t.doc,new Zl(e._snapshot.mutatedKeys.has(t.doc.key),e._snapshot.fromCache),e.query.converter);let i=-1,s=-1;return 0!==t.type&&(i=n.indexOf(t.doc.key),n=n.delete(t.doc.key)),1!==t.type&&(n=n.add(t.doc),s=n.indexOf(t.doc.key)),{type:rh(t.type),doc:r,oldIndex:i,newIndex:s}}))}}(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}}function rh(e){switch(e){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return v()}}class ih extends Ql{constructor(e){super(),this.firestore=e}convertBytes(e){return new tl(e)}convertReference(e){const t=this.convertDocumentKey(e,this.firestore._databaseId);return new Bu(this.firestore,null,t)}}function sh(e,t){return function(e,t){const n=new E;return e.asyncQueue.enqueueAndForget((async()=>async function(e,t,n){const r=ru(e);try{const e=await function(e,t){const n=w(e),r=F.now(),i=t.reduce(((e,t)=>e.add(t.key)),nr());let s,o;return n.persistence.runTransaction("Locally write mutations","readwrite",(e=>{let a=$n(),c=nr();return n.cs.getEntries(e,i).next((e=>{a=e,a.forEach(((e,t)=>{t.isValidDocument()||(c=c.add(e))}))})).next((()=>n.localDocuments.getOverlayedDocuments(e,a))).next((i=>{s=i;const o=[];for(const e of t){const t=xr(e,s.get(e.key).overlayedDocument);null!=t&&o.push(new Or(e.key,t,Wt(t.value.mapValue),Ir.exists(!0)))}return n.mutationQueue.addMutationBatch(e,r,o,t)})).next((t=>{o=t;const r=t.applyToLocalDocumentSet(s,c);return n.documentOverlayCache.saveOverlays(e,t.batchId,r)}))})).then((()=>({batchId:o.batchId,changes:Jn(s)})))}(r.localStore,t);r.sharedClientState.addPendingMutation(e.batchId),function(e,t,n){let r=e.Ba[e.currentUser.toKey()];r||(r=new nt(P)),r=r.insert(t,n),e.Ba[e.currentUser.toKey()]=r}(r,e.batchId,n),await Kc(r,e.changes),await qa(r.remoteStore)}catch(e){const t=nc(e,"Failed to persist write");n.reject(t)}}(await Eu(e),t,n))),n.promise}(Qu(e),t)}function oh(e,t,n){const r=n.docs.get(t._key),i=new ih(e);return new eh(e,i,t._key,r,new Zl(n.hasPendingWrites,n.fromCache),t.converter)}function ah(e,t){const n=Lu(e.firestore,Hu),r=Qu(n),i=et(t,((e,t)=>new jr(t,e.aggregateType,e._internalFieldPath)));return function(e,t,n){const r=new E;return e.asyncQueue.enqueueAndForget((async()=>{try{const i=await Tu(e);r.resolve(async function(e,t,n){var r;const i=w(e),{request:s,ut:o,parent:a}=Di(i.serializer,Pn(t),n);i.connection.Fo||delete s.parent;const c=(await i.Lo("RunAggregationQuery",i.serializer.databaseId,a,s,1)).filter((e=>!!e.result));b(1===c.length);const u=null===(r=c[0].result)||void 0===r?void 0:r.aggregateFields;return Object.keys(u).reduce(((e,t)=>(e[o[t]]=u[t],e)),{})}(i,t,n))}catch(e){r.reject(e)}})),r.promise}(r,e._query,i).then((t=>function(e,t,n){const r=new ih(e);return new el(t,r,n)}(n,e,t)))}class ch{constructor(e){this.kind="memory",this._onlineComponentProvider=new cu,(null==e?void 0:e.garbageCollector)?this._offlineComponentProvider=e.garbageCollector._offlineComponentProvider:this._offlineComponentProvider=new iu}toJSON(){return{kind:this.kind}}}class uh{constructor(e){let t;this.kind="persistent",(null==e?void 0:e.tabManager)?(e.tabManager._initialize(e),t=e.tabManager):(t=ph(void 0),t._initialize(e)),this._onlineComponentProvider=t._onlineComponentProvider,this._offlineComponentProvider=t._offlineComponentProvider}toJSON(){return{kind:this.kind}}}class lh{constructor(){this.kind="memoryEager",this._offlineComponentProvider=new iu}toJSON(){return{kind:this.kind}}}class hh{constructor(e){this.kind="memoryLru",this._offlineComponentProvider=new su(e)}toJSON(){return{kind:this.kind}}}class dh{constructor(e){this.forceOwnership=e,this.kind="persistentSingleTab"}toJSON(){return{kind:this.kind}}_initialize(e){this._onlineComponentProvider=new cu,this._offlineComponentProvider=new ou(this._onlineComponentProvider,null==e?void 0:e.cacheSizeBytes,this.forceOwnership)}}class fh{constructor(){this.kind="PersistentMultipleTab"}toJSON(){return{kind:this.kind}}_initialize(e){this._onlineComponentProvider=new cu,this._offlineComponentProvider=new au(this._onlineComponentProvider,null==e?void 0:e.cacheSizeBytes)}}function ph(e){return new dh(null==e?void 0:e.forceOwnership)}const mh={maxAttempts:5};class gh{constructor(e,t){this._firestore=e,this._commitHandler=t,this._mutations=[],this._committed=!1,this._dataReader=dl(e)}set(e,t,n){this._verifyNotCommitted();const r=yh(e,this._firestore),i=Jl(r.converter,t,n),s=fl(this._dataReader,"WriteBatch.set",r._key,i,null!==r.converter,n);return this._mutations.push(s.toMutation(r._key,Ir.none())),this}update(e,t,n,...r){this._verifyNotCommitted();const i=yh(e,this._firestore);let s;return s="string"==typeof(t=o.getModularInstance(t))||t instanceof nl?_l(this._dataReader,"WriteBatch.update",i._key,t,n,r):wl(this._dataReader,"WriteBatch.update",i._key,t),this._mutations.push(s.toMutation(i._key,Ir.exists(!0))),this}delete(e){this._verifyNotCommitted();const t=yh(e,this._firestore);return this._mutations=this._mutations.concat(new Lr(t._key,Ir.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 I(_.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")}}function yh(e,t){if((e=o.getModularInstance(e)).firestore!==t)throw new I(_.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return e}class vh extends class{constructor(e,t){this._firestore=e,this._transaction=t,this._dataReader=dl(e)}get(e){const t=yh(e,this._firestore),n=new Yl(this._firestore);return this._transaction.lookup([t._key]).then((e=>{if(!e||1!==e.length)return v();const r=e[0];if(r.isFoundDocument())return new Dl(this._firestore,n,r.key,r,t.converter);if(r.isNoDocument())return new Dl(this._firestore,n,t._key,null,t.converter);throw v()}))}set(e,t,n){const r=yh(e,this._firestore),i=Jl(r.converter,t,n),s=fl(this._dataReader,"Transaction.set",r._key,i,null!==r.converter,n);return this._transaction.set(r._key,s),this}update(e,t,n,...r){const i=yh(e,this._firestore);let s;return s="string"==typeof(t=o.getModularInstance(t))||t instanceof nl?_l(this._dataReader,"Transaction.update",i._key,t,n,r):wl(this._dataReader,"Transaction.update",i._key,t),this._transaction.update(i._key,s),this}delete(e){const t=yh(e,this._firestore);return this._transaction.delete(t._key),this}}{constructor(e,t){super(e,t),this._firestore=e}get(e){const t=yh(e,this._firestore),n=new ih(this._firestore);return super.get(e).then((e=>new eh(this._firestore,n,t._key,e._document,new Zl(!1,!1),t.converter)))}}function bh(e,t){if("string"!=typeof e[t])throw new I(_.INVALID_ARGUMENT,"Missing string value for: "+t);return e[t]}class wh{constructor(e){this._client=e,this.type="PersistentCacheIndexManager"}}function _h(e,t){e._client.verifyNotTerminated(),function(e,t){return e.asyncQueue.enqueue((async()=>function(e,t){w(e).ss.zi=t}(await _u(e),t)))}(e._client,t).then((e=>p(`setting persistent cache index auto creation isEnabled=${t} succeeded`))).catch((e=>g(`setting persistent cache index auto creation isEnabled=${t} failed`,e)))}const Ih=new WeakMap;class Eh{constructor(){this.ku=new Map}static get instance(){return Th||(Th=new Eh,function(e){if(Wr)throw new Error("a TestingHooksSpi instance is already set");Wr=e}(Th)),Th}et(e){this.ku.forEach((t=>t(e)))}onExistenceFilterMismatch(e){const t=Symbol(),n=this.ku;return n.set(t,e),()=>n.delete(t)}}let Th=null;!function(e,t=!0){!function(e){h=e}(r.SDK_VERSION),r._registerComponent(new i.Component("firestore",((e,{instanceIdentifier:n,options:r})=>{const i=e.getProvider("app").getImmediate(),s=new Hu(new A(e.getProvider("auth-internal")),new O(e.getProvider("app-check-internal")),function(e,t){if(!Object.prototype.hasOwnProperty.apply(e.options,["projectId"]))throw new I(_.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new bt(e.options.projectId,t)}(i,n),i);return r=Object.assign({useFetchStreams:t},r),s._setSettings(r),s}),"PUBLIC").setMultipleInstances(!0)),r.registerVersion(u,"4.7.2",e),r.registerVersion(u,"4.7.2","cjs2017")}(),t.AbstractUserDataWriter=Ql,t.AggregateField=Zu,t.AggregateQuerySnapshot=el,t.Bytes=tl,t.CACHE_SIZE_UNLIMITED=-1,t.CollectionReference=qu,t.DocumentReference=Bu,t.DocumentSnapshot=eh,t.FieldPath=nl,t.FieldValue=rl,t.Firestore=Hu,t.FirestoreError=I,t.GeoPoint=il,t.LoadBundleTask=$u,t.PersistentCacheIndexManager=wh,t.Query=ju,t.QueryCompositeFilterConstraint=Ul,t.QueryConstraint=Fl,t.QueryDocumentSnapshot=th,t.QueryEndAtConstraint=zl,t.QueryFieldFilterConstraint=Vl,t.QueryLimitConstraint=Bl,t.QueryOrderByConstraint=jl,t.QuerySnapshot=nh,t.QueryStartAtConstraint=ql,t.SnapshotMetadata=Zl,t.Timestamp=F,t.Transaction=vh,t.VectorValue=sl,t.WriteBatch=gh,t._AutoId=R,t._ByteString=lt,t._DatabaseId=bt,t._DocumentKey=z,t._EmptyAppCheckTokenProvider=class{getToken(){return Promise.resolve(new N(""))}invalidateToken(){}start(e,t){}shutdown(){}},t._EmptyAuthCredentialsProvider=S,t._FieldPath=q,t._TestingHooks=class{constructor(){throw new Error("instances of this class should not be created")}static onExistenceFilterMismatch(e){return Eh.instance.onExistenceFilterMismatch(e)}},t._cast=Lu,t._debugAssert=function(e,t){e||v()},t._internalAggregationQueryToProtoRunAggregationQueryRequest=function(e,t){var n;const r=et(t,((e,t)=>new jr(t,e.aggregateType,e._internalFieldPath))),i=null===(n=Qu(Lu(e.firestore,Hu))._onlineComponents)||void 0===n?void 0:n.datastore.serializer;return void 0===i?null:Di(i,Pn(e._query),r,!0).request},t._internalQueryToProtoQueryTarget=function(e){var t;const n=null===(t=Qu(Lu(e.firestore,Hu))._onlineComponents)||void 0===t?void 0:t.datastore.serializer;return void 0===n?null:Oi(n,Rn(e._query))._t},t._isBase64Available=function(){return"undefined"!=typeof atob},t._logWarn=g,t._validateIsNotUsedTogether=Ou,t.addDoc=function(e,t){const n=Lu(e.firestore,Hu),r=zu(e),i=Jl(e.converter,t);return sh(n,[fl(dl(e.firestore),"addDoc",r._key,i,null!==e.converter,{}).toMutation(r._key,Ir.exists(!1))]).then((()=>r))},t.aggregateFieldEqual=function(e,t){var n,r;return e instanceof Zu&&t instanceof Zu&&e.aggregateType===t.aggregateType&&(null===(n=e._internalFieldPath)||void 0===n?void 0:n.canonicalString())===(null===(r=t._internalFieldPath)||void 0===r?void 0:r.canonicalString())},t.aggregateQuerySnapshotEqual=function(e,t){return Gu(e.query,t.query)&&o.deepEqual(e.data(),t.data())},t.and=function(...e){return e.forEach((e=>Hl("and",e))),Ul._create("and",e)},t.arrayRemove=function(...e){return new vl("arrayRemove",e)},t.arrayUnion=function(...e){return new yl("arrayUnion",e)},t.average=function(e){return new Zu("avg",Al("average",e))},t.clearIndexedDbPersistence=function(e){if(e._initialized&&!e._terminated)throw new I(_.FAILED_PRECONDITION,"Persistence can only be cleared before a Firestore instance is initialized or after it is terminated.");const t=new E;return e._queue.enqueueAndForgetEvenWhileRestricted((async()=>{try{await async function(e){if(!oe.D())return Promise.resolve();const t=e+"main";await oe.delete(t)}(Lo(e._databaseId,e._persistenceKey)),t.resolve()}catch(e){t.reject(e)}})),t.promise},t.collection=function(e,t,...n){if(e=o.getModularInstance(e),Nu("collection","path",t),e instanceof Vu){const r=j.fromString(t,...n);return Ru(r),new qu(e,null,r)}{if(!(e instanceof Bu||e instanceof qu))throw new I(_.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=e._path.child(j.fromString(t,...n));return Ru(r),new qu(e.firestore,null,r)}},t.collectionGroup=function(e,t){if(e=Lu(e,Vu),Nu("collectionGroup","collection id",t),t.indexOf("/")>=0)throw new I(_.INVALID_ARGUMENT,`Invalid collection ID '${t}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);return new ju(e,null,function(e){return new An(j.emptyPath(),e)}(t))},t.connectFirestoreEmulator=Uu,t.count=Xl,t.deleteAllPersistentCacheIndexes=function(e){e._client.verifyNotTerminated(),function(e){return e.asyncQueue.enqueue((async()=>function(e){const t=w(e),n=t.indexManager;return t.persistence.runTransaction("Delete All Indexes","readwrite",(e=>n.deleteAllFieldIndexes(e)))}(await _u(e))))}(e._client).then((e=>p("deleting all persistent cache indexes succeeded"))).catch((e=>g("deleting all persistent cache indexes failed",e)))},t.deleteDoc=function(e){return sh(Lu(e.firestore,Hu),[new Lr(e._key,Ir.none())])},t.deleteField=function(){return new pl("deleteField")},t.disableNetwork=function(e){return function(e){return e.asyncQueue.enqueue((async()=>{const t=await wu(e),n=await Iu(e);return t.setNetworkEnabled(!1),async function(e){const t=w(e);t.L_.add(0),await Aa(t),t.q_.set("Offline")}(n)}))}(Qu(e=Lu(e,Hu)))},t.disablePersistentCacheIndexAutoCreation=function(e){_h(e,!1)},t.doc=zu,t.documentId=function(){return new nl("__name__")},t.enableIndexedDbPersistence=function(e,t){Xu(e=Lu(e,Hu));const n=Qu(e);if(n._uninitializedComponentsProvider)throw new I(_.FAILED_PRECONDITION,"SDK cache is already specified.");g("enableIndexedDbPersistence() will be deprecated in the future, you can use `FirestoreSettings.cache` instead.");const r=e._freezeSettings(),i=new cu;return Yu(n,i,new ou(i,r.cacheSizeBytes,null==t?void 0:t.forceOwnership))},t.enableMultiTabIndexedDbPersistence=function(e){Xu(e=Lu(e,Hu));const t=Qu(e);if(t._uninitializedComponentsProvider)throw new I(_.FAILED_PRECONDITION,"SDK cache is already specified.");g("enableMultiTabIndexedDbPersistence() will be deprecated in the future, you can use `FirestoreSettings.cache` instead.");const n=e._freezeSettings(),r=new cu;return Yu(t,r,new au(r,n.cacheSizeBytes))},t.enableNetwork=function(e){return function(e){return e.asyncQueue.enqueue((async()=>{const t=await wu(e),n=await Iu(e);return t.setNetworkEnabled(!0),function(e){const t=w(e);return t.L_.delete(0),Ca(t)}(n)}))}(Qu(e=Lu(e,Hu)))},t.enablePersistentCacheIndexAutoCreation=function(e){_h(e,!0)},t.endAt=function(...e){return zl._create("endAt",e,!0)},t.endBefore=function(...e){return zl._create("endBefore",e,!1)},t.ensureFirestoreConfigured=Qu,t.executeWrite=sh,t.getAggregateFromServer=ah,t.getCountFromServer=function(e){return ah(e,{count:Xl()})},t.getDoc=function(e){e=Lu(e,Bu);const t=Lu(e.firestore,Hu);return Cu(Qu(t),e._key).then((n=>oh(t,e,n)))},t.getDocFromCache=function(e){e=Lu(e,Bu);const t=Lu(e.firestore,Hu),n=Qu(t),r=new ih(t);return function(e,t){const n=new E;return e.asyncQueue.enqueueAndForget((async()=>async function(e,t,n){try{const r=await function(e,t){const n=w(e);return n.persistence.runTransaction("read document","readonly",(e=>n.localDocuments.getDocument(e,t)))}(e,t);r.isFoundDocument()?n.resolve(r):r.isNoDocument()?n.resolve(null):n.reject(new I(_.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(e){const r=nc(e,`Failed to get document '${t} from cache`);n.reject(r)}}(await _u(e),t,n))),n.promise}(n,e._key).then((n=>new eh(t,r,e._key,n,new Zl(null!==n&&n.hasLocalMutations,!0),e.converter)))},t.getDocFromServer=function(e){e=Lu(e,Bu);const t=Lu(e.firestore,Hu);return Cu(Qu(t),e._key,{source:"server"}).then((n=>oh(t,e,n)))},t.getDocs=function(e){e=Lu(e,ju);const t=Lu(e.firestore,Hu),n=Qu(t),r=new ih(t);return Ll(e._query),Au(n,e._query).then((n=>new nh(t,r,e,n)))},t.getDocsFromCache=function(e){e=Lu(e,ju);const t=Lu(e.firestore,Hu),n=Qu(t),r=new ih(t);return function(e,t){const n=new E;return e.asyncQueue.enqueueAndForget((async()=>async function(e,t,n){try{const r=await $o(e,t,!0),i=new Ec(t,r.Ts),s=i.ma(r.documents),o=i.applyChanges(s,!1);n.resolve(o.snapshot)}catch(e){const r=nc(e,`Failed to execute query '${t} against cache`);n.reject(r)}}(await _u(e),t,n))),n.promise}(n,e._query).then((n=>new nh(t,r,e,n)))},t.getDocsFromServer=function(e){e=Lu(e,ju);const t=Lu(e.firestore,Hu),n=Qu(t),r=new ih(t);return Au(n,e._query,{source:"server"}).then((n=>new nh(t,r,e,n)))},t.getFirestore=function(e,t){const n="object"==typeof e?e:r.getApp(),i="string"==typeof e?e:t||"(default)",s=r._getProvider(n,"firestore").getImmediate({identifier:i});if(!s._initialized){const e=o.getDefaultEmulatorHostnameAndPort("firestore");e&&Uu(s,...e)}return s},t.getPersistentCacheIndexManager=function(e){var t;e=Lu(e,Hu);const n=Ih.get(e);if(n)return n;const r=Qu(e);if("persistent"!==(null===(t=r._uninitializedComponentsProvider)||void 0===t?void 0:t._offlineKind))return null;const i=new wh(r);return Ih.set(e,i),i},t.increment=function(e){return new bl("increment",e)},t.initializeFirestore=function(e,t,n){n||(n="(default)");const i=r._getProvider(e,"firestore");if(i.isInitialized(n)){const e=i.getImmediate({identifier:n}),r=i.getOptions(n);if(o.deepEqual(r,t))return e;throw new I(_.FAILED_PRECONDITION,"initializeFirestore() has already been called with different options. To avoid this error, call initializeFirestore() with the same options as when it was originally called, or call getFirestore() to return the already initialized instance.")}if(void 0!==t.cacheSizeBytes&&void 0!==t.localCache)throw new I(_.INVALID_ARGUMENT,"cache and cacheSizeBytes cannot be specified at the same time as cacheSizeBytes willbe deprecated. Instead, specify the cache size in the cache object");if(void 0!==t.cacheSizeBytes&&-1!==t.cacheSizeBytes&&t.cacheSizeBytes<1048576)throw new I(_.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");return i.initialize({options:t,instanceIdentifier:n})},t.limit=function(e){return Mu("limit",e),Bl._create("limit",e,"F")},t.limitToLast=function(e){return Mu("limitToLast",e),Bl._create("limitToLast",e,"L")},t.loadBundle=function(e,t){const n=Qu(e=Lu(e,Hu)),r=new $u;return function(e,t,n,r){const i=function(e,t){let n;return n="string"==typeof e?$r().encode(e):e,function(e,t){return new hu(e,t)}(function(e,t){if(e instanceof Uint8Array)return uu(e,t);if(e instanceof ArrayBuffer)return uu(new Uint8Array(e),t);if(e instanceof ReadableStream)return e.getReader();throw new Error("Source of `toByteStreamReader` has to be a ArrayBuffer or ReadableStream")}(n),t)}(n,va(t));e.asyncQueue.enqueueAndForget((async()=>{!function(e,t,n){const r=w(e);(async function(e,t,n){try{const r=await t.getMetadata();if(await function(e,t){const n=w(e),r=gi(t.createTime);return n.persistence.runTransaction("hasNewerBundle","readonly",(e=>n.Gr.getBundleMetadata(e,t.id))).then((e=>!!e&&e.createTime.compareTo(r)>=0))}(e.localStore,r))return await t.close(),n._completeWith(function(e){return{taskState:"Success",documentsLoaded:e.totalDocuments,bytesLoaded:e.totalBytes,totalDocuments:e.totalDocuments,totalBytes:e.totalBytes}}(r)),Promise.resolve(new Set);n._updateProgress(wc(r));const i=new bc(r,e.localStore,t.serializer);let s=await t.Ua();for(;s;){const e=await i.la(s);e&&n._updateProgress(e),s=await t.Ua()}const o=await i.complete();return await Kc(e,o.Ia,void 0),await function(e,t){const n=w(e);return n.persistence.runTransaction("Save bundle","readwrite",(e=>n.Gr.saveBundleMetadata(e,t)))}(e.localStore,r),n._completeWith(o.progress),Promise.resolve(o.Pa)}catch(e){return g("SyncEngine",`Loading bundle failed with ${e}`),n._failWith(e),Promise.resolve(new Set)}})(r,t,n).then((e=>{r.sharedClientState.notifyBundleLoaded(e)}))}(await Eu(e),i,r)}))}(n,e._databaseId,t,r),r},t.memoryEagerGarbageCollector=function(){return new lh},t.memoryLocalCache=function(e){return new ch(e)},t.memoryLruGarbageCollector=function(e){return new hh(null==e?void 0:e.cacheSizeBytes)},t.namedQuery=function(e,t){return function(e,t){return e.asyncQueue.enqueue((async()=>function(e,t){const n=w(e);return n.persistence.runTransaction("Get named query","readonly",(e=>n.Gr.getNamedQuery(e,t)))}(await _u(e),t)))}(Qu(e=Lu(e,Hu)),t).then((t=>t?new ju(e,null,t.query):null))},t.onSnapshot=function(e,...t){var n,r,i;e=o.getModularInstance(e);let s={includeMetadataChanges:!1,source:"default"},a=0;"object"!=typeof t[a]||Wu(t[a])||(s=t[a],a++);const c={includeMetadataChanges:s.includeMetadataChanges,source:s.source};if(Wu(t[a])){const e=t[a];t[a]=null===(n=e.next)||void 0===n?void 0:n.bind(e),t[a+1]=null===(r=e.error)||void 0===r?void 0:r.bind(e),t[a+2]=null===(i=e.complete)||void 0===i?void 0:i.bind(e)}let u,l,h;if(e instanceof Bu)l=Lu(e.firestore,Hu),h=kn(e._key.path),u={next:n=>{t[a]&&t[a](oh(l,e,n))},error:t[a+1],complete:t[a+2]};else{const n=Lu(e,ju);l=Lu(n.firestore,Hu),h=n._query;const r=new ih(l);u={next:e=>{t[a]&&t[a](new nh(l,r,n,e))},error:t[a+1],complete:t[a+2]},Ll(e._query)}return function(e,t,n,r){const i=new lu(r),s=new gc(t,i,n);return e.asyncQueue.enqueueAndForget((async()=>uc(await Su(e),s))),()=>{i.za(),e.asyncQueue.enqueueAndForget((async()=>lc(await Su(e),s)))}}(Qu(l),h,c,u)},t.onSnapshotsInSync=function(e,t){return function(e,t){const n=new lu(t);return e.asyncQueue.enqueueAndForget((async()=>function(e,t){w(e).Y_.add(t),t.next()}(await Su(e),n))),()=>{n.za(),e.asyncQueue.enqueueAndForget((async()=>function(e,t){w(e).Y_.delete(t)}(await Su(e),n)))}}(Qu(e=Lu(e,Hu)),Wu(t)?t:{next:t})},t.or=function(...e){return e.forEach((e=>Hl("or",e))),Ul._create("or",e)},t.orderBy=function(e,t="asc"){const n=t,r=Pl("orderBy",e);return jl._create(r,n)},t.persistentLocalCache=function(e){return new uh(e)},t.persistentMultipleTabManager=function(){return new fh},t.persistentSingleTabManager=ph,t.query=function(e,t,...n){let r=[];t instanceof Ml&&r.push(t),r=r.concat(n),function(e){const t=e.filter((e=>e instanceof Ul)).length,n=e.filter((e=>e instanceof Vl)).length;if(t>1||t>0&&n>0)throw new I(_.INVALID_ARGUMENT,"InvalidQuery. When using composite filters, you cannot use more than one filter at the top level. Consider nesting the multiple filters within an `and(...)` statement. For example: change `query(query, where(...), or(...))` to `query(query, and(where(...), or(...)))`.")}(r);for(const t of r)e=t._apply(e);return e},t.queryEqual=Gu,t.refEqual=function(e,t){return e=o.getModularInstance(e),t=o.getModularInstance(t),(e instanceof Bu||e instanceof qu)&&(t instanceof Bu||t instanceof qu)&&e.firestore===t.firestore&&e.path===t.path&&e.converter===t.converter},t.runTransaction=function(e,t,n){e=Lu(e,Hu);const r=Object.assign(Object.assign({},mh),n);return function(e){if(e.maxAttempts<1)throw new I(_.INVALID_ARGUMENT,"Max attempts must be at least 1")}(r),function(e,t,n){const r=new E;return e.asyncQueue.enqueueAndForget((async()=>{const i=await Tu(e);new fu(e.asyncQueue,i,n,t,r).ru()})),r.promise}(Qu(e),(n=>t(new vh(e,n))),r)},t.serverTimestamp=function(){return new gl("serverTimestamp")},t.setDoc=function(e,t,n){e=Lu(e,Bu);const r=Lu(e.firestore,Hu),i=Jl(e.converter,t,n);return sh(r,[fl(dl(r),"setDoc",e._key,i,null!==e.converter,n).toMutation(e._key,Ir.none())])},t.setIndexConfiguration=function(e,t){var n;const r=Qu(e=Lu(e,Hu));if(!r._uninitializedComponentsProvider||"memory"===(null===(n=r._uninitializedComponentsProvider)||void 0===n?void 0:n._offlineKind))return g("Cannot enable indexes when persistence is disabled"),Promise.resolve();const i=function(e){const t="string"==typeof e?function(e){try{return JSON.parse(e)}catch(e){throw new I(_.INVALID_ARGUMENT,"Failed to parse JSON: "+(null==e?void 0:e.message))}}(e):e,n=[];if(Array.isArray(t.indexes))for(const e of t.indexes){const t=bh(e,"collectionGroup"),r=[];if(Array.isArray(e.fields))for(const t of e.fields){const e=kl("setIndexConfiguration",bh(t,"fieldPath"));"CONTAINS"===t.arrayConfig?r.push(new H(e,2)):"ASCENDING"===t.order?r.push(new H(e,0)):"DESCENDING"===t.order&&r.push(new H(e,1))}n.push(new G(G.UNKNOWN_ID,t,r,J.empty()))}return n}(t);return function(e,t){return e.asyncQueue.enqueue((async()=>async function(e,t){const n=w(e),r=n.indexManager,i=[];return n.persistence.runTransaction("Configure indexes","readwrite",(e=>r.getFieldIndexes(e).next((n=>function(e,t,n,r,i){e=[...e],t=[...t],e.sort(n),t.sort(n);const s=e.length,o=t.length;let a=0,c=0;for(;a<o&&c<s;){const s=n(e[c],t[a]);s<0?i(e[c++]):s>0?r(t[a++]):(a++,c++)}for(;a<o;)r(t[a++]);for(;c<s;)i(e[c++])}(n,t,$,(t=>{i.push(r.addFieldIndex(e,t))}),(t=>{i.push(r.deleteFieldIndex(e,t))})))).next((()=>ie.waitFor(i)))))}(await _u(e),t)))}(r,i)},t.setLogLevel=function(e){d.setLogLevel(e)},t.snapshotEqual=function(e,t){return e instanceof eh&&t instanceof eh?e._firestore===t._firestore&&e._key.isEqual(t._key)&&(null===e._document?null===t._document:e._document.isEqual(t._document))&&e._converter===t._converter:e instanceof nh&&t instanceof nh&&e._firestore===t._firestore&&Gu(e.query,t.query)&&e.metadata.isEqual(t.metadata)&&e._snapshot.isEqual(t._snapshot)},t.startAfter=function(...e){return ql._create("startAfter",e,!1)},t.startAt=function(...e){return ql._create("startAt",e,!0)},t.sum=function(e){return new Zu("sum",Al("sum",e))},t.terminate=function(e){return r._removeServiceInstance(e.app,"firestore",e._databaseId.database),e._delete()},t.updateDoc=function(e,t,n,...r){e=Lu(e,Bu);const i=Lu(e.firestore,Hu),s=dl(i);let a;return a="string"==typeof(t=o.getModularInstance(t))||t instanceof nl?_l(s,"updateDoc",e._key,t,n,r):wl(s,"updateDoc",e._key,t),sh(i,[a.toMutation(e._key,Ir.exists(!0))])},t.vector=function(e){return new sl(e)},t.waitForPendingWrites=function(e){return function(e){const t=new E;return e.asyncQueue.enqueueAndForget((async()=>async function(e,t){const n=w(e);Pa(n.remoteStore)||p("SyncEngine","The network is disabled. The task returned by 'awaitPendingWrites()' will not complete until the network is enabled.");try{const e=await function(e){const t=w(e);return t.persistence.runTransaction("Get highest unacknowledged batch id","readonly",(e=>t.mutationQueue.getHighestUnacknowledgedBatchId(e)))}(n.localStore);if(-1===e)return void t.resolve();const r=n.ka.get(e)||[];r.push(t),n.ka.set(e,r)}catch(e){const n=nc(e,"Initialization of waitForPendingWrites() operation failed");t.reject(n)}}(await Eu(e),t))),t.promise}(Qu(e=Lu(e,Hu)))},t.where=function(e,t,n){const r=t,i=Pl("where",e);return Vl._create(i,r,n)},t.writeBatch=function(e){return Qu(e=Lu(e,Hu)),new gh(e,(t=>sh(e,t)))}},5844:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r,i,s=n(1635),o=[];t.LogLevel=void 0,(i=t.LogLevel||(t.LogLevel={}))[i.DEBUG=0]="DEBUG",i[i.VERBOSE=1]="VERBOSE",i[i.INFO=2]="INFO",i[i.WARN=3]="WARN",i[i.ERROR=4]="ERROR",i[i.SILENT=5]="SILENT";var a={debug:t.LogLevel.DEBUG,verbose:t.LogLevel.VERBOSE,info:t.LogLevel.INFO,warn:t.LogLevel.WARN,error:t.LogLevel.ERROR,silent:t.LogLevel.SILENT},c=t.LogLevel.INFO,u=((r={})[t.LogLevel.DEBUG]="log",r[t.LogLevel.VERBOSE]="log",r[t.LogLevel.INFO]="info",r[t.LogLevel.WARN]="warn",r[t.LogLevel.ERROR]="error",r),l=function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];if(!(t<e.logLevel)){var i=(new Date).toISOString(),o=u[t];if(!o)throw new Error("Attempted to log a message with an invalid logType (value: ".concat(t,")"));console[o].apply(console,s.__spreadArray(["[".concat(i,"] ").concat(e.name,":")],n,!1))}},h=function(){function e(e){this.name=e,this._logLevel=c,this._logHandler=l,this._userLogHandler=null,o.push(this)}return Object.defineProperty(e.prototype,"logLevel",{get:function(){return this._logLevel},set:function(e){if(!(e in t.LogLevel))throw new TypeError('Invalid value "'.concat(e,'" assigned to `logLevel`'));this._logLevel=e},enumerable:!1,configurable:!0}),e.prototype.setLogLevel=function(e){this._logLevel="string"==typeof e?a[e]:e},Object.defineProperty(e.prototype,"logHandler",{get:function(){return this._logHandler},set:function(e){if("function"!=typeof e)throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"userLogHandler",{get:function(){return this._userLogHandler},set:function(e){this._userLogHandler=e},enumerable:!1,configurable:!0}),e.prototype.debug=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];this._userLogHandler&&this._userLogHandler.apply(this,s.__spreadArray([this,t.LogLevel.DEBUG],e,!1)),this._logHandler.apply(this,s.__spreadArray([this,t.LogLevel.DEBUG],e,!1))},e.prototype.log=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];this._userLogHandler&&this._userLogHandler.apply(this,s.__spreadArray([this,t.LogLevel.VERBOSE],e,!1)),this._logHandler.apply(this,s.__spreadArray([this,t.LogLevel.VERBOSE],e,!1))},e.prototype.info=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];this._userLogHandler&&this._userLogHandler.apply(this,s.__spreadArray([this,t.LogLevel.INFO],e,!1)),this._logHandler.apply(this,s.__spreadArray([this,t.LogLevel.INFO],e,!1))},e.prototype.warn=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];this._userLogHandler&&this._userLogHandler.apply(this,s.__spreadArray([this,t.LogLevel.WARN],e,!1)),this._logHandler.apply(this,s.__spreadArray([this,t.LogLevel.WARN],e,!1))},e.prototype.error=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];this._userLogHandler&&this._userLogHandler.apply(this,s.__spreadArray([this,t.LogLevel.ERROR],e,!1)),this._logHandler.apply(this,s.__spreadArray([this,t.LogLevel.ERROR],e,!1))},e}();t.Logger=h,t.setLogLevel=function(e){o.forEach((function(t){t.setLogLevel(e)}))},t.setUserLogHandler=function(e,n){for(var r=function(r){var i=null;n&&n.level&&(i=a[n.level]),r.userLogHandler=null===e?null:function(n,r){for(var s=[],o=2;o<arguments.length;o++)s[o-2]=arguments[o];var a=s.map((function(e){if(null==e)return null;if("string"==typeof e)return e;if("number"==typeof e||"boolean"==typeof e)return e.toString();if(e instanceof Error)return e.message;try{return JSON.stringify(e)}catch(e){return null}})).filter((function(e){return e})).join(" ");r>=(null!=i?i:n.logLevel)&&e({level:t.LogLevel[r].toLowerCase(),message:a,args:s,type:n.name})}},i=0,s=o;i<s.length;i++)r(s[i])}},6336:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r={NODE_CLIENT:!1,NODE_ADMIN:!1,SDK_VERSION:"${JSCORE_VERSION}"},i=function(e,t){if(!e)throw s(t)},s=function(e){return new Error("Firebase Database ("+r.SDK_VERSION+") INTERNAL ASSERT FAILED: "+e)},o=function(e){const t=[];let n=0;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);i<128?t[n++]=i:i<2048?(t[n++]=i>>6|192,t[n++]=63&i|128):55296==(64512&i)&&r+1<e.length&&56320==(64512&e.charCodeAt(r+1))?(i=65536+((1023&i)<<10)+(1023&e.charCodeAt(++r)),t[n++]=i>>18|240,t[n++]=i>>12&63|128,t[n++]=i>>6&63|128,t[n++]=63&i|128):(t[n++]=i>>12|224,t[n++]=i>>6&63|128,t[n++]=63&i|128)}return t},a={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(e,t){if(!Array.isArray(e))throw Error("encodeByteArray takes an array as a parameter");this.init_();const n=t?this.byteToCharMapWebSafe_:this.byteToCharMap_,r=[];for(let t=0;t<e.length;t+=3){const i=e[t],s=t+1<e.length,o=s?e[t+1]:0,a=t+2<e.length,c=a?e[t+2]:0,u=i>>2,l=(3&i)<<4|o>>4;let h=(15&o)<<2|c>>6,d=63&c;a||(d=64,s||(h=64)),r.push(n[u],n[l],n[h],n[d])}return r.join("")},encodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?btoa(e):this.encodeByteArray(o(e),t)},decodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?atob(e):function(e){const t=[];let n=0,r=0;for(;n<e.length;){const i=e[n++];if(i<128)t[r++]=String.fromCharCode(i);else if(i>191&&i<224){const s=e[n++];t[r++]=String.fromCharCode((31&i)<<6|63&s)}else if(i>239&&i<365){const s=((7&i)<<18|(63&e[n++])<<12|(63&e[n++])<<6|63&e[n++])-65536;t[r++]=String.fromCharCode(55296+(s>>10)),t[r++]=String.fromCharCode(56320+(1023&s))}else{const s=e[n++],o=e[n++];t[r++]=String.fromCharCode((15&i)<<12|(63&s)<<6|63&o)}}return t.join("")}(this.decodeStringToByteArray(e,t))},decodeStringToByteArray(e,t){this.init_();const n=t?this.charToByteMapWebSafe_:this.charToByteMap_,r=[];for(let t=0;t<e.length;){const i=n[e.charAt(t++)],s=t<e.length?n[e.charAt(t)]:0;++t;const o=t<e.length?n[e.charAt(t)]:64;++t;const a=t<e.length?n[e.charAt(t)]:64;if(++t,null==i||null==s||null==o||null==a)throw new c;const u=i<<2|s>>4;if(r.push(u),64!==o){const e=s<<4&240|o>>2;if(r.push(e),64!==a){const e=o<<6&192|a;r.push(e)}}}return r},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let e=0;e<this.ENCODED_VALS.length;e++)this.byteToCharMap_[e]=this.ENCODED_VALS.charAt(e),this.charToByteMap_[this.byteToCharMap_[e]]=e,this.byteToCharMapWebSafe_[e]=this.ENCODED_VALS_WEBSAFE.charAt(e),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[e]]=e,e>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(e)]=e,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(e)]=e)}}};class c extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}const u=function(e){const t=o(e);return a.encodeByteArray(t,!0)},l=function(e){return u(e).replace(/\./g,"")},h=function(e){try{return a.decodeString(e,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};function d(e,t){if(!(t instanceof Object))return t;switch(t.constructor){case Date:return new Date(t.getTime());case Object:void 0===e&&(e={});break;case Array:e=[];break;default:return t}for(const n in t)t.hasOwnProperty(n)&&"__proto__"!==n&&(e[n]=d(e[n],t[n]));return e}function f(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==n.g)return n.g;throw new Error("Unable to locate global object.")}const p=()=>{try{return f().__FIREBASE_DEFAULTS__||(()=>{if("undefined"==typeof process||void 0===process.env)return;const e=process.env.__FIREBASE_DEFAULTS__;return e?JSON.parse(e):void 0})()||(()=>{if("undefined"==typeof document)return;let e;try{e=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch(e){return}const t=e&&h(e[1]);return t&&JSON.parse(t)})()}catch(e){return void console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${e}`)}},m=e=>{var t,n;return null===(n=null===(t=p())||void 0===t?void 0:t.emulatorHosts)||void 0===n?void 0:n[e]};class g{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}wrapCallback(e){return(t,n)=>{t?this.reject(t):this.resolve(n),"function"==typeof e&&(this.promise.catch((()=>{})),1===e.length?e(t):e(t,n))}}}function y(){return"undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:""}function v(){var e;const t=null===(e=p())||void 0===e?void 0:e.forceEnvironment;if("node"===t)return!0;if("browser"===t)return!1;try{return"[object process]"===Object.prototype.toString.call(n.g.process)}catch(e){return!1}}function b(){return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope}class w extends Error{constructor(e,t,n){super(t),this.code=e,this.customData=n,this.name="FirebaseError",Object.setPrototypeOf(this,w.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,_.prototype.create)}}class _{constructor(e,t,n){this.service=e,this.serviceName=t,this.errors=n}create(e,...t){const n=t[0]||{},r=`${this.service}/${e}`,i=this.errors[e],s=i?function(e,t){return e.replace(I,((e,n)=>{const r=t[n];return null!=r?String(r):`<${n}?>`}))}(i,n):"Error",o=`${this.serviceName}: ${s} (${r}).`;return new w(r,o,n)}}const I=/\{\$([^}]+)}/g;function E(e){return JSON.parse(e)}const T=function(e){let t={},n={},r={},i="";try{const s=e.split(".");t=E(h(s[0])||""),n=E(h(s[1])||""),i=s[2],r=n.d||{},delete n.d}catch(e){}return{header:t,claims:n,data:r,signature:i}};function S(e){return null!==e&&"object"==typeof e}class C{constructor(e,t){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=t,this.task.then((()=>{e(this)})).catch((e=>{this.error(e)}))}next(e){this.forEachObserver((t=>{t.next(e)}))}error(e){this.forEachObserver((t=>{t.error(e)})),this.close(e)}complete(){this.forEachObserver((e=>{e.complete()})),this.close()}subscribe(e,t,n){let r;if(void 0===e&&void 0===t&&void 0===n)throw new Error("Missing Observer.");r=function(e){if("object"!=typeof e||null===e)return!1;for(const t of["next","error","complete"])if(t in e&&"function"==typeof e[t])return!0;return!1}(e)?e:{next:e,error:t,complete:n},void 0===r.next&&(r.next=A),void 0===r.error&&(r.error=A),void 0===r.complete&&(r.complete=A);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(e){}})),this.observers.push(r),i}unsubscribeOne(e){void 0!==this.observers&&void 0!==this.observers[e]&&(delete this.observers[e],this.observerCount-=1,0===this.observerCount&&void 0!==this.onNoObservers&&this.onNoObservers(this))}forEachObserver(e){if(!this.finalized)for(let t=0;t<this.observers.length;t++)this.sendOne(t,e)}sendOne(e,t){this.task.then((()=>{if(void 0!==this.observers&&void 0!==this.observers[e])try{t(this.observers[e])}catch(e){"undefined"!=typeof console&&console.error&&console.error(e)}}))}close(e){this.finalized||(this.finalized=!0,void 0!==e&&(this.finalError=e),this.task.then((()=>{this.observers=void 0,this.onNoObservers=void 0})))}}function A(){}function x(e,t){return`${e} failed: ${t} argument `}const k=144e5;t.CONSTANTS=r,t.DecodeBase64StringError=c,t.Deferred=g,t.ErrorFactory=_,t.FirebaseError=w,t.MAX_VALUE_MILLIS=k,t.RANDOM_FACTOR=.5,t.Sha1=class{constructor(){this.chain_=[],this.buf_=[],this.W_=[],this.pad_=[],this.inbuf_=0,this.total_=0,this.blockSize=64,this.pad_[0]=128;for(let e=1;e<this.blockSize;++e)this.pad_[e]=0;this.reset()}reset(){this.chain_[0]=1732584193,this.chain_[1]=4023233417,this.chain_[2]=2562383102,this.chain_[3]=271733878,this.chain_[4]=3285377520,this.inbuf_=0,this.total_=0}compress_(e,t){t||(t=0);const n=this.W_;if("string"==typeof e)for(let r=0;r<16;r++)n[r]=e.charCodeAt(t)<<24|e.charCodeAt(t+1)<<16|e.charCodeAt(t+2)<<8|e.charCodeAt(t+3),t+=4;else for(let r=0;r<16;r++)n[r]=e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3],t+=4;for(let e=16;e<80;e++){const t=n[e-3]^n[e-8]^n[e-14]^n[e-16];n[e]=4294967295&(t<<1|t>>>31)}let r,i,s=this.chain_[0],o=this.chain_[1],a=this.chain_[2],c=this.chain_[3],u=this.chain_[4];for(let e=0;e<80;e++){e<40?e<20?(r=c^o&(a^c),i=1518500249):(r=o^a^c,i=1859775393):e<60?(r=o&a|c&(o|a),i=2400959708):(r=o^a^c,i=3395469782);const t=(s<<5|s>>>27)+r+u+i+n[e]&4294967295;u=c,c=a,a=4294967295&(o<<30|o>>>2),o=s,s=t}this.chain_[0]=this.chain_[0]+s&4294967295,this.chain_[1]=this.chain_[1]+o&4294967295,this.chain_[2]=this.chain_[2]+a&4294967295,this.chain_[3]=this.chain_[3]+c&4294967295,this.chain_[4]=this.chain_[4]+u&4294967295}update(e,t){if(null==e)return;void 0===t&&(t=e.length);const n=t-this.blockSize;let r=0;const i=this.buf_;let s=this.inbuf_;for(;r<t;){if(0===s)for(;r<=n;)this.compress_(e,r),r+=this.blockSize;if("string"==typeof e){for(;r<t;)if(i[s]=e.charCodeAt(r),++s,++r,s===this.blockSize){this.compress_(i),s=0;break}}else for(;r<t;)if(i[s]=e[r],++s,++r,s===this.blockSize){this.compress_(i),s=0;break}}this.inbuf_=s,this.total_+=t}digest(){const e=[];let t=8*this.total_;this.inbuf_<56?this.update(this.pad_,56-this.inbuf_):this.update(this.pad_,this.blockSize-(this.inbuf_-56));for(let e=this.blockSize-1;e>=56;e--)this.buf_[e]=255&t,t/=256;this.compress_(this.buf_);let n=0;for(let t=0;t<5;t++)for(let r=24;r>=0;r-=8)e[n]=this.chain_[t]>>r&255,++n;return e}},t.areCookiesEnabled=function(){return!("undefined"==typeof navigator||!navigator.cookieEnabled)},t.assert=i,t.assertionError=s,t.async=function(e,t){return(...n)=>{Promise.resolve(!0).then((()=>{e(...n)})).catch((e=>{t&&t(e)}))}},t.base64=a,t.base64Decode=h,t.base64Encode=u,t.base64urlEncodeWithoutPadding=l,t.calculateBackoffMillis=function(e,t=1e3,n=2){const r=t*Math.pow(n,e),i=Math.round(.5*r*(Math.random()-.5)*2);return Math.min(k,r+i)},t.contains=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.createMockUserToken=function(e,t){if(e.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');const n=t||"demo-project",r=e.iat||0,i=e.sub||e.user_id;if(!i)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const s=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:{}}},e);return[l(JSON.stringify({alg:"none",type:"JWT"})),l(JSON.stringify(s)),""].join(".")},t.createSubscribe=function(e,t){const n=new C(e,t);return n.subscribe.bind(n)},t.decode=T,t.deepCopy=function(e){return d(void 0,e)},t.deepEqual=function e(t,n){if(t===n)return!0;const r=Object.keys(t),i=Object.keys(n);for(const s of r){if(!i.includes(s))return!1;const r=t[s],o=n[s];if(S(r)&&S(o)){if(!e(r,o))return!1}else if(r!==o)return!1}for(const e of i)if(!r.includes(e))return!1;return!0},t.deepExtend=d,t.errorPrefix=x,t.extractQuerystring=function(e){const t=e.indexOf("?");if(!t)return"";const n=e.indexOf("#",t);return e.substring(t,n>0?n:void 0)},t.getDefaultAppConfig=()=>{var e;return null===(e=p())||void 0===e?void 0:e.config},t.getDefaultEmulatorHost=m,t.getDefaultEmulatorHostnameAndPort=e=>{const t=m(e);if(!t)return;const n=t.lastIndexOf(":");if(n<=0||n+1===t.length)throw new Error(`Invalid host ${t} with no separate hostname and port!`);const r=parseInt(t.substring(n+1),10);return"["===t[0]?[t.substring(1,n-1),r]:[t.substring(0,n),r]},t.getDefaults=p,t.getExperimentalSetting=e=>{var t;return null===(t=p())||void 0===t?void 0:t[`_${e}`]},t.getGlobal=f,t.getModularInstance=function(e){return e&&e._delegate?e._delegate:e},t.getUA=y,t.isAdmin=function(e){const t=T(e).claims;return"object"==typeof t&&!0===t.admin},t.isBrowser=function(){return"undefined"!=typeof window||b()},t.isBrowserExtension=function(){const e="object"==typeof chrome?chrome.runtime:"object"==typeof browser?browser.runtime:void 0;return"object"==typeof e&&void 0!==e.id},t.isCloudflareWorker=function(){return"undefined"!=typeof navigator&&"Cloudflare-Workers"===navigator.userAgent},t.isElectron=function(){return y().indexOf("Electron/")>=0},t.isEmpty=function(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0},t.isIE=function(){const e=y();return e.indexOf("MSIE ")>=0||e.indexOf("Trident/")>=0},t.isIndexedDBAvailable=function(){try{return"object"==typeof indexedDB}catch(e){return!1}},t.isMobileCordova=function(){return"undefined"!=typeof window&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(y())},t.isNode=v,t.isNodeSdk=function(){return!0===r.NODE_CLIENT||!0===r.NODE_ADMIN},t.isReactNative=function(){return"object"==typeof navigator&&"ReactNative"===navigator.product},t.isSafari=function(){return!v()&&!!navigator.userAgent&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")},t.isUWP=function(){return y().indexOf("MSAppHost/")>=0},t.isValidFormat=function(e){const t=T(e).claims;return!!t&&"object"==typeof t&&t.hasOwnProperty("iat")},t.isValidTimestamp=function(e){const t=T(e).claims,n=Math.floor((new Date).getTime()/1e3);let r=0,i=0;return"object"==typeof t&&(t.hasOwnProperty("nbf")?r=t.nbf:t.hasOwnProperty("iat")&&(r=t.iat),i=t.hasOwnProperty("exp")?t.exp:r+86400),!!n&&!!r&&!!i&&n>=r&&n<=i},t.isWebWorker=b,t.issuedAtTime=function(e){const t=T(e).claims;return"object"==typeof t&&t.hasOwnProperty("iat")?t.iat:null},t.jsonEval=E,t.map=function(e,t,n){const r={};for(const i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=t.call(n,e[i],i,e));return r},t.ordinal=function(e){return Number.isFinite(e)?e+function(e){const t=(e=Math.abs(e))%100;if(t>=10&&t<=20)return"th";const n=e%10;return 1===n?"st":2===n?"nd":3===n?"rd":"th"}(e):`${e}`},t.promiseWithTimeout=function(e,t=2e3){const n=new g;return setTimeout((()=>n.reject("timeout!")),t),e.then(n.resolve,n.reject),n.promise},t.querystring=function(e){const t=[];for(const[n,r]of Object.entries(e))Array.isArray(r)?r.forEach((e=>{t.push(encodeURIComponent(n)+"="+encodeURIComponent(e))})):t.push(encodeURIComponent(n)+"="+encodeURIComponent(r));return t.length?"&"+t.join("&"):""},t.querystringDecode=function(e){const t={};return e.replace(/^\?/,"").split("&").forEach((e=>{if(e){const[n,r]=e.split("=");t[decodeURIComponent(n)]=decodeURIComponent(r)}})),t},t.safeGet=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0},t.stringLength=function(e){let t=0;for(let n=0;n<e.length;n++){const r=e.charCodeAt(n);r<128?t++:r<2048?t+=2:r>=55296&&r<=56319?(t+=4,n++):t+=3}return t},t.stringToByteArray=function(e){const t=[];let n=0;for(let r=0;r<e.length;r++){let s=e.charCodeAt(r);if(s>=55296&&s<=56319){const t=s-55296;r++,i(r<e.length,"Surrogate pair missing trail surrogate."),s=65536+(t<<10)+(e.charCodeAt(r)-56320)}s<128?t[n++]=s:s<2048?(t[n++]=s>>6|192,t[n++]=63&s|128):s<65536?(t[n++]=s>>12|224,t[n++]=s>>6&63|128,t[n++]=63&s|128):(t[n++]=s>>18|240,t[n++]=s>>12&63|128,t[n++]=s>>6&63|128,t[n++]=63&s|128)}return t},t.stringify=function(e){return JSON.stringify(e)},t.uuidv4=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))},t.validateArgCount=function(e,t,n,r){let i;if(r<t?i="at least "+t:r>n&&(i=0===n?"none":"no more than "+n),i)throw new Error(e+" failed: Was called with "+r+(1===r?" argument.":" arguments.")+" Expects "+i+".")},t.validateCallback=function(e,t,n,r){if((!r||n)&&"function"!=typeof n)throw new Error(x(e,t)+"must be a valid function.")},t.validateContextObject=function(e,t,n,r){if((!r||n)&&("object"!=typeof n||null===n))throw new Error(x(e,t)+"must be a valid context object.")},t.validateIndexedDBOpenable=function(){return new Promise(((e,t)=>{try{let n=!0;const r="validate-browser-context-for-indexeddb-analytics-module",i=self.indexedDB.open(r);i.onsuccess=()=>{i.result.close(),n||self.indexedDB.deleteDatabase(r),e(!0)},i.onupgradeneeded=()=>{n=!1},i.onerror=()=>{var e;t((null===(e=i.error)||void 0===e?void 0:e.message)||"")}}catch(e){t(e)}}))},t.validateNamespace=function(e,t,n){if((!n||t)&&"string"!=typeof t)throw new Error(x(e,"namespace")+"must be a valid firebase namespace.")}},860:(e,t,n)=>{(function(){"use strict";var t;function n(){this.blockSize=-1,this.blockSize=64,this.g=Array(4),this.B=Array(this.blockSize),this.o=this.h=0,this.s()}function r(e,t,n){n||(n=0);var r=Array(16);if("string"==typeof t)for(var i=0;16>i;++i)r[i]=t.charCodeAt(n++)|t.charCodeAt(n++)<<8|t.charCodeAt(n++)<<16|t.charCodeAt(n++)<<24;else for(i=0;16>i;++i)r[i]=t[n++]|t[n++]<<8|t[n++]<<16|t[n++]<<24;t=e.g[0],n=e.g[1],i=e.g[2];var s=e.g[3],o=t+(s^n&(i^s))+r[0]+3614090360&4294967295;o=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=n+(o<<7&4294967295|o>>>25))+((o=s+(i^t&(n^i))+r[1]+3905402710&4294967295)<<12&4294967295|o>>>20))+((o=i+(n^s&(t^n))+r[2]+606105819&4294967295)<<17&4294967295|o>>>15))+((o=n+(t^i&(s^t))+r[3]+3250441966&4294967295)<<22&4294967295|o>>>10))+((o=t+(s^n&(i^s))+r[4]+4118548399&4294967295)<<7&4294967295|o>>>25))+((o=s+(i^t&(n^i))+r[5]+1200080426&4294967295)<<12&4294967295|o>>>20))+((o=i+(n^s&(t^n))+r[6]+2821735955&4294967295)<<17&4294967295|o>>>15))+((o=n+(t^i&(s^t))+r[7]+4249261313&4294967295)<<22&4294967295|o>>>10))+((o=t+(s^n&(i^s))+r[8]+1770035416&4294967295)<<7&4294967295|o>>>25))+((o=s+(i^t&(n^i))+r[9]+2336552879&4294967295)<<12&4294967295|o>>>20))+((o=i+(n^s&(t^n))+r[10]+4294925233&4294967295)<<17&4294967295|o>>>15))+((o=n+(t^i&(s^t))+r[11]+2304563134&4294967295)<<22&4294967295|o>>>10))+((o=t+(s^n&(i^s))+r[12]+1804603682&4294967295)<<7&4294967295|o>>>25))+((o=s+(i^t&(n^i))+r[13]+4254626195&4294967295)<<12&4294967295|o>>>20))+((o=i+(n^s&(t^n))+r[14]+2792965006&4294967295)<<17&4294967295|o>>>15))+((o=n+(t^i&(s^t))+r[15]+1236535329&4294967295)<<22&4294967295|o>>>10))+((o=t+(i^s&(n^i))+r[1]+4129170786&4294967295)<<5&4294967295|o>>>27))+((o=s+(n^i&(t^n))+r[6]+3225465664&4294967295)<<9&4294967295|o>>>23))+((o=i+(t^n&(s^t))+r[11]+643717713&4294967295)<<14&4294967295|o>>>18))+((o=n+(s^t&(i^s))+r[0]+3921069994&4294967295)<<20&4294967295|o>>>12))+((o=t+(i^s&(n^i))+r[5]+3593408605&4294967295)<<5&4294967295|o>>>27))+((o=s+(n^i&(t^n))+r[10]+38016083&4294967295)<<9&4294967295|o>>>23))+((o=i+(t^n&(s^t))+r[15]+3634488961&4294967295)<<14&4294967295|o>>>18))+((o=n+(s^t&(i^s))+r[4]+3889429448&4294967295)<<20&4294967295|o>>>12))+((o=t+(i^s&(n^i))+r[9]+568446438&4294967295)<<5&4294967295|o>>>27))+((o=s+(n^i&(t^n))+r[14]+3275163606&4294967295)<<9&4294967295|o>>>23))+((o=i+(t^n&(s^t))+r[3]+4107603335&4294967295)<<14&4294967295|o>>>18))+((o=n+(s^t&(i^s))+r[8]+1163531501&4294967295)<<20&4294967295|o>>>12))+((o=t+(i^s&(n^i))+r[13]+2850285829&4294967295)<<5&4294967295|o>>>27))+((o=s+(n^i&(t^n))+r[2]+4243563512&4294967295)<<9&4294967295|o>>>23))+((o=i+(t^n&(s^t))+r[7]+1735328473&4294967295)<<14&4294967295|o>>>18))+((o=n+(s^t&(i^s))+r[12]+2368359562&4294967295)<<20&4294967295|o>>>12))+((o=t+(n^i^s)+r[5]+4294588738&4294967295)<<4&4294967295|o>>>28))+((o=s+(t^n^i)+r[8]+2272392833&4294967295)<<11&4294967295|o>>>21))+((o=i+(s^t^n)+r[11]+1839030562&4294967295)<<16&4294967295|o>>>16))+((o=n+(i^s^t)+r[14]+4259657740&4294967295)<<23&4294967295|o>>>9))+((o=t+(n^i^s)+r[1]+2763975236&4294967295)<<4&4294967295|o>>>28))+((o=s+(t^n^i)+r[4]+1272893353&4294967295)<<11&4294967295|o>>>21))+((o=i+(s^t^n)+r[7]+4139469664&4294967295)<<16&4294967295|o>>>16))+((o=n+(i^s^t)+r[10]+3200236656&4294967295)<<23&4294967295|o>>>9))+((o=t+(n^i^s)+r[13]+681279174&4294967295)<<4&4294967295|o>>>28))+((o=s+(t^n^i)+r[0]+3936430074&4294967295)<<11&4294967295|o>>>21))+((o=i+(s^t^n)+r[3]+3572445317&4294967295)<<16&4294967295|o>>>16))+((o=n+(i^s^t)+r[6]+76029189&4294967295)<<23&4294967295|o>>>9))+((o=t+(n^i^s)+r[9]+3654602809&4294967295)<<4&4294967295|o>>>28))+((o=s+(t^n^i)+r[12]+3873151461&4294967295)<<11&4294967295|o>>>21))+((o=i+(s^t^n)+r[15]+530742520&4294967295)<<16&4294967295|o>>>16))+((o=n+(i^s^t)+r[2]+3299628645&4294967295)<<23&4294967295|o>>>9))+((o=t+(i^(n|~s))+r[0]+4096336452&4294967295)<<6&4294967295|o>>>26))+((o=s+(n^(t|~i))+r[7]+1126891415&4294967295)<<10&4294967295|o>>>22))+((o=i+(t^(s|~n))+r[14]+2878612391&4294967295)<<15&4294967295|o>>>17))+((o=n+(s^(i|~t))+r[5]+4237533241&4294967295)<<21&4294967295|o>>>11))+((o=t+(i^(n|~s))+r[12]+1700485571&4294967295)<<6&4294967295|o>>>26))+((o=s+(n^(t|~i))+r[3]+2399980690&4294967295)<<10&4294967295|o>>>22))+((o=i+(t^(s|~n))+r[10]+4293915773&4294967295)<<15&4294967295|o>>>17))+((o=n+(s^(i|~t))+r[1]+2240044497&4294967295)<<21&4294967295|o>>>11))+((o=t+(i^(n|~s))+r[8]+1873313359&4294967295)<<6&4294967295|o>>>26))+((o=s+(n^(t|~i))+r[15]+4264355552&4294967295)<<10&4294967295|o>>>22))+((o=i+(t^(s|~n))+r[6]+2734768916&4294967295)<<15&4294967295|o>>>17))+((o=n+(s^(i|~t))+r[13]+1309151649&4294967295)<<21&4294967295|o>>>11))+((s=(t=n+((o=t+(i^(n|~s))+r[4]+4149444226&4294967295)<<6&4294967295|o>>>26))+((o=s+(n^(t|~i))+r[11]+3174756917&4294967295)<<10&4294967295|o>>>22))^((i=s+((o=i+(t^(s|~n))+r[2]+718787259&4294967295)<<15&4294967295|o>>>17))|~t))+r[9]+3951481745&4294967295,e.g[0]=e.g[0]+t&4294967295,e.g[1]=e.g[1]+(i+(o<<21&4294967295|o>>>11))&4294967295,e.g[2]=e.g[2]+i&4294967295,e.g[3]=e.g[3]+s&4294967295}function i(e,t){this.h=t;for(var n=[],r=!0,i=e.length-1;0<=i;i--){var s=0|e[i];r&&s==t||(n[i]=s,r=!1)}this.g=n}!function(e,t){function n(){}n.prototype=t.prototype,e.D=t.prototype,e.prototype=new n,e.prototype.constructor=e,e.C=function(e,n,r){for(var i=Array(arguments.length-2),s=2;s<arguments.length;s++)i[s-2]=arguments[s];return t.prototype[n].apply(e,i)}}(n,(function(){this.blockSize=-1})),n.prototype.s=function(){this.g[0]=1732584193,this.g[1]=4023233417,this.g[2]=2562383102,this.g[3]=271733878,this.o=this.h=0},n.prototype.u=function(e,t){void 0===t&&(t=e.length);for(var n=t-this.blockSize,i=this.B,s=this.h,o=0;o<t;){if(0==s)for(;o<=n;)r(this,e,o),o+=this.blockSize;if("string"==typeof e){for(;o<t;)if(i[s++]=e.charCodeAt(o++),s==this.blockSize){r(this,i),s=0;break}}else for(;o<t;)if(i[s++]=e[o++],s==this.blockSize){r(this,i),s=0;break}}this.h=s,this.o+=t},n.prototype.v=function(){var e=Array((56>this.h?this.blockSize:2*this.blockSize)-this.h);e[0]=128;for(var t=1;t<e.length-8;++t)e[t]=0;var n=8*this.o;for(t=e.length-8;t<e.length;++t)e[t]=255&n,n/=256;for(this.u(e),e=Array(16),t=n=0;4>t;++t)for(var r=0;32>r;r+=8)e[n++]=this.g[t]>>>r&255;return e};var s={};function o(e){return-128<=e&&128>e?function(e){var t=s;return Object.prototype.hasOwnProperty.call(t,e)?t[e]:t[e]=function(e){return new i([0|e],0>e?-1:0)}(e)}(e):new i([0|e],0>e?-1:0)}function a(e){if(isNaN(e)||!isFinite(e))return c;if(0>e)return f(a(-e));for(var t=[],n=1,r=0;e>=n;r++)t[r]=e/n|0,n*=4294967296;return new i(t,0)}var c=o(0),u=o(1),l=o(16777216);function h(e){if(0!=e.h)return!1;for(var t=0;t<e.g.length;t++)if(0!=e.g[t])return!1;return!0}function d(e){return-1==e.h}function f(e){for(var t=e.g.length,n=[],r=0;r<t;r++)n[r]=~e.g[r];return new i(n,~e.h).add(u)}function p(e,t){return e.add(f(t))}function m(e,t){for(;(65535&e[t])!=e[t];)e[t+1]+=e[t]>>>16,e[t]&=65535,t++}function g(e,t){this.g=e,this.h=t}function y(e,t){if(h(t))throw Error("division by zero");if(h(e))return new g(c,c);if(d(e))return t=y(f(e),t),new g(f(t.g),f(t.h));if(d(t))return t=y(e,f(t)),new g(f(t.g),t.h);if(30<e.g.length){if(d(e)||d(t))throw Error("slowDivide_ only works with positive integers.");for(var n=u,r=t;0>=r.l(e);)n=v(n),r=v(r);var i=b(n,1),s=b(r,1);for(r=b(r,2),n=b(n,2);!h(r);){var o=s.add(r);0>=o.l(e)&&(i=i.add(n),s=o),r=b(r,1),n=b(n,1)}return t=p(e,i.j(t)),new g(i,t)}for(i=c;0<=e.l(t);){for(n=Math.max(1,Math.floor(e.m()/t.m())),r=48>=(r=Math.ceil(Math.log(n)/Math.LN2))?1:Math.pow(2,r-48),o=(s=a(n)).j(t);d(o)||0<o.l(e);)o=(s=a(n-=r)).j(t);h(s)&&(s=u),i=i.add(s),e=p(e,o)}return new g(i,e)}function v(e){for(var t=e.g.length+1,n=[],r=0;r<t;r++)n[r]=e.i(r)<<1|e.i(r-1)>>>31;return new i(n,e.h)}function b(e,t){var n=t>>5;t%=32;for(var r=e.g.length-n,s=[],o=0;o<r;o++)s[o]=0<t?e.i(o+n)>>>t|e.i(o+n+1)<<32-t:e.i(o+n);return new i(s,e.h)}(t=i.prototype).m=function(){if(d(this))return-f(this).m();for(var e=0,t=1,n=0;n<this.g.length;n++){var r=this.i(n);e+=(0<=r?r:4294967296+r)*t,t*=4294967296}return e},t.toString=function(e){if(2>(e=e||10)||36<e)throw Error("radix out of range: "+e);if(h(this))return"0";if(d(this))return"-"+f(this).toString(e);for(var t=a(Math.pow(e,6)),n=this,r="";;){var i=y(n,t).g,s=((0<(n=p(n,i.j(t))).g.length?n.g[0]:n.h)>>>0).toString(e);if(h(n=i))return s+r;for(;6>s.length;)s="0"+s;r=s+r}},t.i=function(e){return 0>e?0:e<this.g.length?this.g[e]:this.h},t.l=function(e){return d(e=p(this,e))?-1:h(e)?0:1},t.abs=function(){return d(this)?f(this):this},t.add=function(e){for(var t=Math.max(this.g.length,e.g.length),n=[],r=0,s=0;s<=t;s++){var o=r+(65535&this.i(s))+(65535&e.i(s)),a=(o>>>16)+(this.i(s)>>>16)+(e.i(s)>>>16);r=a>>>16,o&=65535,a&=65535,n[s]=a<<16|o}return new i(n,-2147483648&n[n.length-1]?-1:0)},t.j=function(e){if(h(this)||h(e))return c;if(d(this))return d(e)?f(this).j(f(e)):f(f(this).j(e));if(d(e))return f(this.j(f(e)));if(0>this.l(l)&&0>e.l(l))return a(this.m()*e.m());for(var t=this.g.length+e.g.length,n=[],r=0;r<2*t;r++)n[r]=0;for(r=0;r<this.g.length;r++)for(var s=0;s<e.g.length;s++){var o=this.i(r)>>>16,u=65535&this.i(r),p=e.i(s)>>>16,g=65535&e.i(s);n[2*r+2*s]+=u*g,m(n,2*r+2*s),n[2*r+2*s+1]+=o*g,m(n,2*r+2*s+1),n[2*r+2*s+1]+=u*p,m(n,2*r+2*s+1),n[2*r+2*s+2]+=o*p,m(n,2*r+2*s+2)}for(r=0;r<t;r++)n[r]=n[2*r+1]<<16|n[2*r];for(r=t;r<2*t;r++)n[r]=0;return new i(n,0)},t.A=function(e){return y(this,e).h},t.and=function(e){for(var t=Math.max(this.g.length,e.g.length),n=[],r=0;r<t;r++)n[r]=this.i(r)&e.i(r);return new i(n,this.h&e.h)},t.or=function(e){for(var t=Math.max(this.g.length,e.g.length),n=[],r=0;r<t;r++)n[r]=this.i(r)|e.i(r);return new i(n,this.h|e.h)},t.xor=function(e){for(var t=Math.max(this.g.length,e.g.length),n=[],r=0;r<t;r++)n[r]=this.i(r)^e.i(r);return new i(n,this.h^e.h)},n.prototype.digest=n.prototype.v,n.prototype.reset=n.prototype.s,n.prototype.update=n.prototype.u,e.exports.Md5=n,i.prototype.add=i.prototype.add,i.prototype.multiply=i.prototype.j,i.prototype.modulo=i.prototype.A,i.prototype.compare=i.prototype.l,i.prototype.toNumber=i.prototype.m,i.prototype.toString=i.prototype.toString,i.prototype.getBits=i.prototype.i,i.fromNumber=a,i.fromString=function e(t,n){if(0==t.length)throw Error("number format error: empty string");if(2>(n=n||10)||36<n)throw Error("radix out of range: "+n);if("-"==t.charAt(0))return f(e(t.substring(1),n));if(0<=t.indexOf("-"))throw Error('number format error: interior "-" character');for(var r=a(Math.pow(n,8)),i=c,s=0;s<t.length;s+=8){var o=Math.min(8,t.length-s),u=parseInt(t.substring(s,s+o),n);8>o?(o=a(Math.pow(n,o)),i=i.j(o).add(a(u))):i=(i=i.j(r)).add(a(u))}return i},e.exports.Integer=i}).apply(void 0!==n.g?n.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},4832:(e,t,n)=>{(function(){"use strict";var t,r="function"==typeof Object.defineProperties?Object.defineProperty:function(e,t,n){return e==Array.prototype||e==Object.prototype||(e[t]=n.value),e},i=function(e){e=["object"==typeof globalThis&&globalThis,e,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof n.g&&n.g];for(var t=0;t<e.length;++t){var r=e[t];if(r&&r.Math==Math)return r}throw Error("Cannot find global object")}(this);!function(e,t){if(t)e:{var n=i;e=e.split(".");for(var s=0;s<e.length-1;s++){var o=e[s];if(!(o in n))break e;n=n[o]}(t=t(s=n[e=e[e.length-1]]))!=s&&null!=t&&r(n,e,{configurable:!0,writable:!0,value:t})}}("Array.prototype.values",(function(e){return e||function(){return function(e,t){e instanceof String&&(e+="");var n=0,r=!1,i={next:function(){if(!r&&n<e.length){var i=n++;return{value:t(0,e[i]),done:!1}}return r=!0,{done:!0,value:void 0}}};return i[Symbol.iterator]=function(){return i},i}(this,(function(e,t){return t}))}}));var s=s||{},o=this||self;function a(e){var t=typeof e;return"array"==(t="object"!=t?t:e?Array.isArray(e)?"array":t:"null")||"object"==t&&"number"==typeof e.length}function c(e){var t=typeof e;return"object"==t&&null!=e||"function"==t}function u(e,t,n){return e.call.apply(e.bind,arguments)}function l(e,t,n){if(!e)throw Error();if(2<arguments.length){var r=Array.prototype.slice.call(arguments,2);return function(){var n=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(n,r),e.apply(t,n)}}return function(){return e.apply(t,arguments)}}function h(e,t,n){return(h=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?u:l).apply(null,arguments)}function d(e,t){var n=Array.prototype.slice.call(arguments,1);return function(){var t=n.slice();return t.push.apply(t,arguments),e.apply(this,t)}}function f(e,t){function n(){}n.prototype=t.prototype,e.aa=t.prototype,e.prototype=new n,e.prototype.constructor=e,e.Qb=function(e,n,r){for(var i=Array(arguments.length-2),s=2;s<arguments.length;s++)i[s-2]=arguments[s];return t.prototype[n].apply(e,i)}}function p(e){const t=e.length;if(0<t){const n=Array(t);for(let r=0;r<t;r++)n[r]=e[r];return n}return[]}function m(e,t){for(let t=1;t<arguments.length;t++){const n=arguments[t];if(a(n)){const t=e.length||0,r=n.length||0;e.length=t+r;for(let i=0;i<r;i++)e[t+i]=n[i]}else e.push(n)}}function g(e){return/^[\s\xa0]*$/.test(e)}function y(){var e=o.navigator;return e&&(e=e.userAgent)?e:""}function v(e){return v[" "](e),e}v[" "]=function(){};var b=!(-1==y().indexOf("Gecko")||-1!=y().toLowerCase().indexOf("webkit")&&-1==y().indexOf("Edge")||-1!=y().indexOf("Trident")||-1!=y().indexOf("MSIE")||-1!=y().indexOf("Edge"));function w(e,t,n){for(const r in e)t.call(n,e[r],r,e)}function _(e){const t={};for(const n in e)t[n]=e[n];return t}const I="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function E(e,t){let n,r;for(let t=1;t<arguments.length;t++){for(n in r=arguments[t],r)e[n]=r[n];for(let t=0;t<I.length;t++)n=I[t],Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}}function T(e){var t=1;e=e.split(":");const n=[];for(;0<t&&e.length;)n.push(e.shift()),t--;return e.length&&n.push(e.join(":")),n}function S(e){o.setTimeout((()=>{throw e}),0)}function C(){var e=O;let t=null;return e.g&&(t=e.g,e.g=e.g.next,e.g||(e.h=null),t.next=null),t}var A=new class{constructor(e,t){this.i=e,this.j=t,this.h=0,this.g=null}get(){let e;return 0<this.h?(this.h--,e=this.g,this.g=e.next,e.next=null):e=this.i(),e}}((()=>new x),(e=>e.reset()));class x{constructor(){this.next=this.g=this.h=null}set(e,t){this.h=e,this.g=t,this.next=null}reset(){this.next=this.g=this.h=null}}let k,N=!1,O=new class{constructor(){this.h=this.g=null}add(e,t){const n=A.get();n.set(e,t),this.h?this.h.next=n:this.g=n,this.h=n}},D=()=>{const e=o.Promise.resolve(void 0);k=()=>{e.then(R)}};var R=()=>{for(var e;e=C();){try{e.h.call(e.g)}catch(e){S(e)}var t=A;t.j(e),100>t.h&&(t.h++,e.next=t.g,t.g=e)}N=!1};function P(){this.s=this.s,this.C=this.C}function L(e,t){this.type=e,this.g=this.target=t,this.defaultPrevented=!1}P.prototype.s=!1,P.prototype.ma=function(){this.s||(this.s=!0,this.N())},P.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()},L.prototype.h=function(){this.defaultPrevented=!0};var M=function(){if(!o.addEventListener||!Object.defineProperty)return!1;var e=!1,t=Object.defineProperty({},"passive",{get:function(){e=!0}});try{const e=()=>{};o.addEventListener("test",e,t),o.removeEventListener("test",e,t)}catch(e){}return e}();function F(e,t){if(L.call(this,e?e.type:""),this.relatedTarget=this.g=this.target=null,this.button=this.screenY=this.screenX=this.clientY=this.clientX=0,this.key="",this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.state=null,this.pointerId=0,this.pointerType="",this.i=null,e){var n=this.type=e.type,r=e.changedTouches&&e.changedTouches.length?e.changedTouches[0]:null;if(this.target=e.target||e.srcElement,this.g=t,t=e.relatedTarget){if(b){e:{try{v(t.nodeName);var i=!0;break e}catch(e){}i=!1}i||(t=null)}}else"mouseover"==n?t=e.fromElement:"mouseout"==n&&(t=e.toElement);this.relatedTarget=t,r?(this.clientX=void 0!==r.clientX?r.clientX:r.pageX,this.clientY=void 0!==r.clientY?r.clientY:r.pageY,this.screenX=r.screenX||0,this.screenY=r.screenY||0):(this.clientX=void 0!==e.clientX?e.clientX:e.pageX,this.clientY=void 0!==e.clientY?e.clientY:e.pageY,this.screenX=e.screenX||0,this.screenY=e.screenY||0),this.button=e.button,this.key=e.key||"",this.ctrlKey=e.ctrlKey,this.altKey=e.altKey,this.shiftKey=e.shiftKey,this.metaKey=e.metaKey,this.pointerId=e.pointerId||0,this.pointerType="string"==typeof e.pointerType?e.pointerType:V[e.pointerType]||"",this.state=e.state,this.i=e,e.defaultPrevented&&F.aa.h.call(this)}}f(F,L);var V={2:"touch",3:"pen",4:"mouse"};F.prototype.h=function(){F.aa.h.call(this);var e=this.i;e.preventDefault?e.preventDefault():e.returnValue=!1};var U="closure_listenable_"+(1e6*Math.random()|0),j=0;function B(e,t,n,r,i){this.listener=e,this.proxy=null,this.src=t,this.type=n,this.capture=!!r,this.ha=i,this.key=++j,this.da=this.fa=!1}function q(e){e.da=!0,e.listener=null,e.proxy=null,e.src=null,e.ha=null}function z(e){this.src=e,this.g={},this.h=0}function G(e,t){var n=t.type;if(n in e.g){var r,i=e.g[n],s=Array.prototype.indexOf.call(i,t,void 0);(r=0<=s)&&Array.prototype.splice.call(i,s,1),r&&(q(t),0==e.g[n].length&&(delete e.g[n],e.h--))}}function K(e,t,n,r){for(var i=0;i<e.length;++i){var s=e[i];if(!s.da&&s.listener==t&&s.capture==!!n&&s.ha==r)return i}return-1}z.prototype.add=function(e,t,n,r,i){var s=e.toString();(e=this.g[s])||(e=this.g[s]=[],this.h++);var o=K(e,t,r,i);return-1<o?(t=e[o],n||(t.fa=!1)):((t=new B(t,this.src,s,!!r,i)).fa=n,e.push(t)),t};var W="closure_lm_"+(1e6*Math.random()|0),$={};function H(e,t,n,r,i){if(r&&r.once)return J(e,t,n,r,i);if(Array.isArray(t)){for(var s=0;s<t.length;s++)H(e,t[s],n,r,i);return null}return n=re(n),e&&e[U]?e.K(t,n,c(r)?!!r.capture:!!r,i):Q(e,t,n,!1,r,i)}function Q(e,t,n,r,i,s){if(!t)throw Error("Invalid event type");var o=c(i)?!!i.capture:!!i,a=te(e);if(a||(e[W]=a=new z(e)),(n=a.add(t,n,r,o,s)).proxy)return n;if(r=function(){const e=ee;return function t(n){return e.call(t.src,t.listener,n)}}(),n.proxy=r,r.src=e,r.listener=n,e.addEventListener)M||(i=o),void 0===i&&(i=!1),e.addEventListener(t.toString(),r,i);else if(e.attachEvent)e.attachEvent(Z(t.toString()),r);else{if(!e.addListener||!e.removeListener)throw Error("addEventListener and attachEvent are unavailable.");e.addListener(r)}return n}function J(e,t,n,r,i){if(Array.isArray(t)){for(var s=0;s<t.length;s++)J(e,t[s],n,r,i);return null}return n=re(n),e&&e[U]?e.L(t,n,c(r)?!!r.capture:!!r,i):Q(e,t,n,!0,r,i)}function Y(e,t,n,r,i){if(Array.isArray(t))for(var s=0;s<t.length;s++)Y(e,t[s],n,r,i);else r=c(r)?!!r.capture:!!r,n=re(n),e&&e[U]?(e=e.i,(t=String(t).toString())in e.g&&-1<(n=K(s=e.g[t],n,r,i))&&(q(s[n]),Array.prototype.splice.call(s,n,1),0==s.length&&(delete e.g[t],e.h--))):e&&(e=te(e))&&(t=e.g[t.toString()],e=-1,t&&(e=K(t,n,r,i)),(n=-1<e?t[e]:null)&&X(n))}function X(e){if("number"!=typeof e&&e&&!e.da){var t=e.src;if(t&&t[U])G(t.i,e);else{var n=e.type,r=e.proxy;t.removeEventListener?t.removeEventListener(n,r,e.capture):t.detachEvent?t.detachEvent(Z(n),r):t.addListener&&t.removeListener&&t.removeListener(r),(n=te(t))?(G(n,e),0==n.h&&(n.src=null,t[W]=null)):q(e)}}}function Z(e){return e in $?$[e]:$[e]="on"+e}function ee(e,t){if(e.da)e=!0;else{t=new F(t,this);var n=e.listener,r=e.ha||e.src;e.fa&&X(e),e=n.call(r,t)}return e}function te(e){return(e=e[W])instanceof z?e:null}var ne="__closure_events_fn_"+(1e9*Math.random()>>>0);function re(e){return"function"==typeof e?e:(e[ne]||(e[ne]=function(t){return e.handleEvent(t)}),e[ne])}function ie(){P.call(this),this.i=new z(this),this.M=this,this.F=null}function se(e,t){var n,r=e.F;if(r)for(n=[];r;r=r.F)n.push(r);if(e=e.M,r=t.type||t,"string"==typeof t)t=new L(t,e);else if(t instanceof L)t.target=t.target||e;else{var i=t;E(t=new L(r,e),i)}if(i=!0,n)for(var s=n.length-1;0<=s;s--){var o=t.g=n[s];i=oe(o,r,!0,t)&&i}if(i=oe(o=t.g=e,r,!0,t)&&i,i=oe(o,r,!1,t)&&i,n)for(s=0;s<n.length;s++)i=oe(o=t.g=n[s],r,!1,t)&&i}function oe(e,t,n,r){if(!(t=e.i.g[String(t)]))return!0;t=t.concat();for(var i=!0,s=0;s<t.length;++s){var o=t[s];if(o&&!o.da&&o.capture==n){var a=o.listener,c=o.ha||o.src;o.fa&&G(e.i,o),i=!1!==a.call(c,r)&&i}}return i&&!r.defaultPrevented}function ae(e,t,n){if("function"==typeof e)n&&(e=h(e,n));else{if(!e||"function"!=typeof e.handleEvent)throw Error("Invalid listener argument");e=h(e.handleEvent,e)}return 2147483647<Number(t)?-1:o.setTimeout(e,t||0)}function ce(e){e.g=ae((()=>{e.g=null,e.i&&(e.i=!1,ce(e))}),e.l);const t=e.h;e.h=null,e.m.apply(null,t)}f(ie,P),ie.prototype[U]=!0,ie.prototype.removeEventListener=function(e,t,n,r){Y(this,e,t,n,r)},ie.prototype.N=function(){if(ie.aa.N.call(this),this.i){var e,t=this.i;for(e in t.g){for(var n=t.g[e],r=0;r<n.length;r++)q(n[r]);delete t.g[e],t.h--}}this.F=null},ie.prototype.K=function(e,t,n,r){return this.i.add(String(e),t,!1,n,r)},ie.prototype.L=function(e,t,n,r){return this.i.add(String(e),t,!0,n,r)};class ue extends P{constructor(e,t){super(),this.m=e,this.l=t,this.h=null,this.i=!1,this.g=null}j(e){this.h=arguments,this.g?this.i=!0:ce(this)}N(){super.N(),this.g&&(o.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function le(e){P.call(this),this.h=e,this.g={}}f(le,P);var he=[];function de(e){w(e.g,(function(e,t){this.g.hasOwnProperty(t)&&X(e)}),e),e.g={}}le.prototype.N=function(){le.aa.N.call(this),de(this)},le.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var fe=o.JSON.stringify,pe=o.JSON.parse,me=class{stringify(e){return o.JSON.stringify(e,void 0)}parse(e){return o.JSON.parse(e,void 0)}};function ge(){}function ye(e){return e.h||(e.h=e.i())}function ve(){}ge.prototype.h=null;var be={OPEN:"a",kb:"b",Ja:"c",wb:"d"};function we(){L.call(this,"d")}function _e(){L.call(this,"c")}f(we,L),f(_e,L);var Ie={},Ee=null;function Te(){return Ee=Ee||new ie}function Se(e){L.call(this,Ie.La,e)}function Ce(e){const t=Te();se(t,new Se(t,e))}function Ae(e,t){L.call(this,Ie.STAT_EVENT,e),this.stat=t}function xe(e){const t=Te();se(t,new Ae(t,e))}function ke(e,t){L.call(this,Ie.Ma,e),this.size=t}function Ne(e,t){if("function"!=typeof e)throw Error("Fn must not be null and must be a function");return o.setTimeout((function(){e()}),t)}function Oe(){this.g=!0}function De(e,t,n,r){e.info((function(){return"XMLHTTP TEXT ("+t+"): "+function(e,t){if(!e.g)return t;if(!t)return null;try{var n=JSON.parse(t);if(n)for(e=0;e<n.length;e++)if(Array.isArray(n[e])){var r=n[e];if(!(2>r.length)){var i=r[1];if(Array.isArray(i)&&!(1>i.length)){var s=i[0];if("noop"!=s&&"stop"!=s&&"close"!=s)for(var o=1;o<i.length;o++)i[o]=""}}}return fe(n)}catch(e){return t}}(e,n)+(r?" "+r:"")}))}Ie.La="serverreachability",f(Se,L),Ie.STAT_EVENT="statevent",f(Ae,L),Ie.Ma="timingevent",f(ke,L),Oe.prototype.xa=function(){this.g=!1},Oe.prototype.info=function(){};var Re,Pe={NO_ERROR:0,gb:1,tb:2,sb:3,nb:4,rb:5,ub:6,Ia:7,TIMEOUT:8,xb:9},Le={lb:"complete",Hb:"success",Ja:"error",Ia:"abort",zb:"ready",Ab:"readystatechange",TIMEOUT:"timeout",vb:"incrementaldata",yb:"progress",ob:"downloadprogress",Pb:"uploadprogress"};function Me(){}function Fe(e,t,n,r){this.j=e,this.i=t,this.l=n,this.R=r||1,this.U=new le(this),this.I=45e3,this.H=null,this.o=!1,this.m=this.A=this.v=this.L=this.F=this.S=this.B=null,this.D=[],this.g=null,this.C=0,this.s=this.u=null,this.X=-1,this.J=!1,this.O=0,this.M=null,this.W=this.K=this.T=this.P=!1,this.h=new Ve}function Ve(){this.i=null,this.g="",this.h=!1}f(Me,ge),Me.prototype.g=function(){return new XMLHttpRequest},Me.prototype.i=function(){return{}},Re=new Me;var Ue={},je={};function Be(e,t,n){e.L=1,e.v=ft(ct(t)),e.m=n,e.P=!0,qe(e,null)}function qe(e,t){e.F=Date.now(),Ke(e),e.A=ct(e.v);var n=e.A,r=e.R;Array.isArray(r)||(r=[String(r)]),At(n.i,"t",r),e.C=0,n=e.j.J,e.h=new Ve,e.g=mn(e.j,n?t:null,!e.m),0<e.O&&(e.M=new ue(h(e.Y,e,e.g),e.O)),t=e.U,n=e.g,r=e.ca;var i="readystatechange";Array.isArray(i)||(i&&(he[0]=i.toString()),i=he);for(var s=0;s<i.length;s++){var o=H(n,i[s],r||t.handleEvent,!1,t.h||t);if(!o)break;t.g[o.key]=o}t=e.H?_(e.H):{},e.m?(e.u||(e.u="POST"),t["Content-Type"]="application/x-www-form-urlencoded",e.g.ea(e.A,e.u,e.m,t)):(e.u="GET",e.g.ea(e.A,e.u,null,t)),Ce(1),function(e,t,n,r,i,s){e.info((function(){if(e.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 l=u[0];u=u[1];var h=l.split("_");o=2<=h.length&&"type"==h[1]?o+(l+"=")+u+"&":o+(l+"=redacted&")}}else o=null;else o=s;return"XMLHTTP REQ ("+r+") [attempt "+i+"]: "+t+"\n"+n+"\n"+o}))}(e.i,e.u,e.A,e.l,e.R,e.m)}function ze(e){return!!e.g&&"GET"==e.u&&2!=e.L&&e.j.Ca}function Ge(e,t){var n=e.C,r=t.indexOf("\n",n);return-1==r?je:(n=Number(t.substring(n,r)),isNaN(n)?Ue:(r+=1)+n>t.length?je:(t=t.slice(r,r+n),e.C=r+n,t))}function Ke(e){e.S=Date.now()+e.I,We(e,e.I)}function We(e,t){if(null!=e.B)throw Error("WatchDog timer not null");e.B=Ne(h(e.ba,e),t)}function $e(e){e.B&&(o.clearTimeout(e.B),e.B=null)}function He(e){0==e.j.G||e.J||ln(e.j,e)}function Qe(e){$e(e);var t=e.M;t&&"function"==typeof t.ma&&t.ma(),e.M=null,de(e.U),e.g&&(t=e.g,e.g=null,t.abort(),t.ma())}function Je(e,t){try{var n=e.j;if(0!=n.G&&(n.g==e||tt(n.h,e)))if(!e.K&&tt(n.h,e)&&3==n.G){try{var r=n.Da.g.parse(t)}catch(e){r=null}if(Array.isArray(r)&&3==r.length){var i=r;if(0==i[0]){e:if(!n.u){if(n.g){if(!(n.g.F+3e3<e.F))break e;un(n),Xt(n)}on(n),xe(18)}}else n.za=i[1],0<n.za-n.T&&37500>i[2]&&n.F&&0==n.v&&!n.C&&(n.C=Ne(h(n.Za,n),6e3));if(1>=et(n.h)&&n.ca){try{n.ca()}catch(e){}n.ca=void 0}}else dn(n,11)}else if((e.K||n.g==e)&&un(n),!g(t))for(i=n.Da.g.parse(t),t=0;t<i.length;t++){let u=i[t];if(n.T=u[0],u=u[1],2==n.G)if("c"==u[0]){n.K=u[1],n.ia=u[2];const t=u[3];null!=t&&(n.la=t,n.j.info("VER="+n.la));const i=u[4];null!=i&&(n.Aa=i,n.j.info("SVER="+n.Aa));const l=u[5];null!=l&&"number"==typeof l&&0<l&&(r=1.5*l,n.L=r,n.j.info("backChannelRequestTimeoutMs_="+r)),r=n;const h=e.g;if(h){const e=h.g?h.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(e){var s=r.h;s.g||-1==e.indexOf("spdy")&&-1==e.indexOf("quic")&&-1==e.indexOf("h2")||(s.j=s.l,s.g=new Set,s.h&&(nt(s,s.h),s.h=null))}if(r.D){const e=h.g?h.g.getResponseHeader("X-HTTP-Session-Id"):null;e&&(r.ya=e,dt(r.I,r.D,e))}}n.G=3,n.l&&n.l.ua(),n.ba&&(n.R=Date.now()-e.F,n.j.info("Handshake RTT: "+n.R+"ms"));var o=e;if((r=n).qa=pn(r,r.J?r.ia:null,r.W),o.K){rt(r.h,o);var a=o,c=r.L;c&&(a.I=c),a.B&&($e(a),Ke(a)),r.g=o}else sn(r);0<n.i.length&&en(n)}else"stop"!=u[0]&&"close"!=u[0]||dn(n,7);else 3==n.G&&("stop"==u[0]||"close"==u[0]?"stop"==u[0]?dn(n,7):Yt(n):"noop"!=u[0]&&n.l&&n.l.ta(u),n.v=0)}Ce(4)}catch(e){}}Fe.prototype.ca=function(e){e=e.target;const t=this.M;t&&3==$t(e)?t.j():this.Y(e)},Fe.prototype.Y=function(e){try{if(e==this.g)e:{const d=$t(this.g);var t=this.g.Ba();const f=this.g.Z();if(!(3>d)&&(3!=d||this.g&&(this.h.h||this.g.oa()||Ht(this.g)))){this.J||4!=d||7==t||Ce(8==t||0>=f?3:2),$e(this);var n=this.g.Z();this.X=n;t:if(ze(this)){var r=Ht(this.g);e="";var i=r.length,s=4==$t(this.g);if(!this.h.i){if("undefined"==typeof TextDecoder){Qe(this),He(this);var a="";break t}this.h.i=new o.TextDecoder}for(t=0;t<i;t++)this.h.h=!0,e+=this.h.i.decode(r[t],{stream:!(s&&t==i-1)});r.length=0,this.h.g+=e,this.C=0,a=this.h.g}else a=this.g.oa();if(this.o=200==n,function(e,t,n,r,i,s,o){e.info((function(){return"XMLHTTP RESP ("+r+") [ attempt "+i+"]: "+t+"\n"+n+"\n"+s+" "+o}))}(this.i,this.u,this.A,this.l,this.R,d,n),this.o){if(this.T&&!this.K){t:{if(this.g){var c,u=this.g;if((c=u.g?u.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!g(c)){var l=c;break t}}l=null}if(!(n=l)){this.o=!1,this.s=3,xe(12),Qe(this),He(this);break e}De(this.i,this.l,n,"Initial handshake response via X-HTTP-Initial-Response"),this.K=!0,Je(this,n)}if(this.P){let e;for(n=!0;!this.J&&this.C<a.length;){if(e=Ge(this,a),e==je){4==d&&(this.s=4,xe(14),n=!1),De(this.i,this.l,null,"[Incomplete Response]");break}if(e==Ue){this.s=4,xe(15),De(this.i,this.l,a,"[Invalid Chunk]"),n=!1;break}De(this.i,this.l,e,null),Je(this,e)}if(ze(this)&&0!=this.C&&(this.h.g=this.h.g.slice(this.C),this.C=0),4!=d||0!=a.length||this.h.h||(this.s=1,xe(16),n=!1),this.o=this.o&&n,n){if(0<a.length&&!this.W){this.W=!0;var h=this.j;h.g==this&&h.ba&&!h.M&&(h.j.info("Great, no buffering proxy detected. Bytes received: "+a.length),an(h),h.M=!0,xe(11))}}else De(this.i,this.l,a,"[Invalid Chunked Response]"),Qe(this),He(this)}else De(this.i,this.l,a,null),Je(this,a);4==d&&Qe(this),this.o&&!this.J&&(4==d?ln(this.j,this):(this.o=!1,Ke(this)))}else(function(e){const t={};e=(e.g&&2<=$t(e)&&e.g.getAllResponseHeaders()||"").split("\r\n");for(let r=0;r<e.length;r++){if(g(e[r]))continue;var n=T(e[r]);const i=n[0];if("string"!=typeof(n=n[1]))continue;n=n.trim();const s=t[i]||[];t[i]=s,s.push(n)}!function(e,t){for(const n in e)t.call(void 0,e[n],n,e)}(t,(function(e){return e.join(", ")}))})(this.g),400==n&&0<a.indexOf("Unknown SID")?(this.s=3,xe(12)):(this.s=0,xe(13)),Qe(this),He(this)}}}catch(e){}},Fe.prototype.cancel=function(){this.J=!0,Qe(this)},Fe.prototype.ba=function(){this.B=null;const e=Date.now();0<=e-this.S?(function(e,t){e.info((function(){return"TIMEOUT: "+t}))}(this.i,this.A),2!=this.L&&(Ce(3),xe(17)),Qe(this),this.s=2,He(this)):We(this,this.S-e)};var Ye=class{constructor(e,t){this.g=e,this.map=t}};function Xe(e){this.l=e||10,e=o.PerformanceNavigationTiming?0<(e=o.performance.getEntriesByType("navigation")).length&&("hq"==e[0].nextHopProtocol||"h2"==e[0].nextHopProtocol):!!(o.chrome&&o.chrome.loadTimes&&o.chrome.loadTimes()&&o.chrome.loadTimes().wasFetchedViaSpdy),this.j=e?this.l:1,this.g=null,1<this.j&&(this.g=new Set),this.h=null,this.i=[]}function Ze(e){return!!e.h||!!e.g&&e.g.size>=e.j}function et(e){return e.h?1:e.g?e.g.size:0}function tt(e,t){return e.h?e.h==t:!!e.g&&e.g.has(t)}function nt(e,t){e.g?e.g.add(t):e.h=t}function rt(e,t){e.h&&e.h==t?e.h=null:e.g&&e.g.has(t)&&e.g.delete(t)}function it(e){if(null!=e.h)return e.i.concat(e.h.D);if(null!=e.g&&0!==e.g.size){let t=e.i;for(const n of e.g.values())t=t.concat(n.D);return t}return p(e.i)}function st(e,t){if(e.forEach&&"function"==typeof e.forEach)e.forEach(t,void 0);else if(a(e)||"string"==typeof e)Array.prototype.forEach.call(e,t,void 0);else for(var n=function(e){if(e.na&&"function"==typeof e.na)return e.na();if(!e.V||"function"!=typeof e.V){if("undefined"!=typeof Map&&e instanceof Map)return Array.from(e.keys());if(!("undefined"!=typeof Set&&e instanceof Set)){if(a(e)||"string"==typeof e){var t=[];e=e.length;for(var n=0;n<e;n++)t.push(n);return t}t=[],n=0;for(const r in e)t[n++]=r;return t}}}(e),r=function(e){if(e.V&&"function"==typeof e.V)return e.V();if("undefined"!=typeof Map&&e instanceof Map||"undefined"!=typeof Set&&e instanceof Set)return Array.from(e.values());if("string"==typeof e)return e.split("");if(a(e)){for(var t=[],n=e.length,r=0;r<n;r++)t.push(e[r]);return t}for(r in t=[],n=0,e)t[n++]=e[r];return t}(e),i=r.length,s=0;s<i;s++)t.call(void 0,r[s],n&&n[s],e)}Xe.prototype.cancel=function(){if(this.i=it(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&0!==this.g.size){for(const e of this.g.values())e.cancel();this.g.clear()}};var ot=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function at(e){if(this.g=this.o=this.j="",this.s=null,this.m=this.l="",this.h=!1,e instanceof at){this.h=e.h,ut(this,e.j),this.o=e.o,this.g=e.g,lt(this,e.s),this.l=e.l;var t=e.i,n=new Et;n.i=t.i,t.g&&(n.g=new Map(t.g),n.h=t.h),ht(this,n),this.m=e.m}else e&&(t=String(e).match(ot))?(this.h=!1,ut(this,t[1]||"",!0),this.o=pt(t[2]||""),this.g=pt(t[3]||"",!0),lt(this,t[4]),this.l=pt(t[5]||"",!0),ht(this,t[6]||"",!0),this.m=pt(t[7]||"")):(this.h=!1,this.i=new Et(null,this.h))}function ct(e){return new at(e)}function ut(e,t,n){e.j=n?pt(t,!0):t,e.j&&(e.j=e.j.replace(/:$/,""))}function lt(e,t){if(t){if(t=Number(t),isNaN(t)||0>t)throw Error("Bad port number "+t);e.s=t}else e.s=null}function ht(e,t,n){t instanceof Et?(e.i=t,function(e,t){t&&!e.j&&(Tt(e),e.i=null,e.g.forEach((function(e,t){var n=t.toLowerCase();t!=n&&(St(this,t),At(this,n,e))}),e)),e.j=t}(e.i,e.h)):(n||(t=mt(t,_t)),e.i=new Et(t,e.h))}function dt(e,t,n){e.i.set(t,n)}function ft(e){return dt(e,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)),e}function pt(e,t){return e?t?decodeURI(e.replace(/%25/g,"%2525")):decodeURIComponent(e):""}function mt(e,t,n){return"string"==typeof e?(e=encodeURI(e).replace(t,gt),n&&(e=e.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),e):null}function gt(e){return"%"+((e=e.charCodeAt(0))>>4&15).toString(16)+(15&e).toString(16)}at.prototype.toString=function(){var e=[],t=this.j;t&&e.push(mt(t,vt,!0),":");var n=this.g;return(n||"file"==t)&&(e.push("//"),(t=this.o)&&e.push(mt(t,vt,!0),"@"),e.push(encodeURIComponent(String(n)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),null!=(n=this.s)&&e.push(":",String(n))),(n=this.l)&&(this.g&&"/"!=n.charAt(0)&&e.push("/"),e.push(mt(n,"/"==n.charAt(0)?wt:bt,!0))),(n=this.i.toString())&&e.push("?",n),(n=this.m)&&e.push("#",mt(n,It)),e.join("")};var yt,vt=/[#\/\?@]/g,bt=/[#\?:]/g,wt=/[#\?]/g,_t=/[#\?@]/g,It=/#/g;function Et(e,t){this.h=this.g=null,this.i=e||null,this.j=!!t}function Tt(e){e.g||(e.g=new Map,e.h=0,e.i&&function(e,t){if(e){e=e.split("&");for(var n=0;n<e.length;n++){var r=e[n].indexOf("="),i=null;if(0<=r){var s=e[n].substring(0,r);i=e[n].substring(r+1)}else s=e[n];t(s,i?decodeURIComponent(i.replace(/\+/g," ")):"")}}}(e.i,(function(t,n){e.add(decodeURIComponent(t.replace(/\+/g," ")),n)})))}function St(e,t){Tt(e),t=xt(e,t),e.g.has(t)&&(e.i=null,e.h-=e.g.get(t).length,e.g.delete(t))}function Ct(e,t){return Tt(e),t=xt(e,t),e.g.has(t)}function At(e,t,n){St(e,t),0<n.length&&(e.i=null,e.g.set(xt(e,t),p(n)),e.h+=n.length)}function xt(e,t){return t=String(t),e.j&&(t=t.toLowerCase()),t}function kt(e,t,n,r,i){try{i&&(i.onload=null,i.onerror=null,i.onabort=null,i.ontimeout=null),r(n)}catch(e){}}function Nt(){this.g=new me}function Ot(e,t,n){const r=n||"";try{st(e,(function(e,n){let i=e;c(e)&&(i=fe(e)),t.push(r+n+"="+encodeURIComponent(i))}))}catch(e){throw t.push(r+"type="+encodeURIComponent("_badmap")),e}}function Dt(e){this.l=e.Ub||null,this.j=e.eb||!1}function Rt(e,t){ie.call(this),this.D=e,this.o=t,this.m=void 0,this.status=this.readyState=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.u=new Headers,this.h=null,this.B="GET",this.A="",this.g=!1,this.v=this.j=this.l=null}function Pt(e){e.j.read().then(e.Pa.bind(e)).catch(e.ga.bind(e))}function Lt(e){e.readyState=4,e.l=null,e.j=null,e.v=null,Mt(e)}function Mt(e){e.onreadystatechange&&e.onreadystatechange.call(e)}function Ft(e){let t="";return w(e,(function(e,n){t+=n,t+=":",t+=e,t+="\r\n"})),t}function Vt(e,t,n){e:{for(r in n){var r=!1;break e}r=!0}r||(n=Ft(n),"string"==typeof e?(encodeURIComponent(String(t)),null!=n&&encodeURIComponent(String(n))):dt(e,t,n))}function Ut(e){ie.call(this),this.headers=new Map,this.o=e||null,this.h=!1,this.v=this.g=null,this.D="",this.m=0,this.l="",this.j=this.B=this.u=this.A=!1,this.I=null,this.H="",this.J=!1}(t=Et.prototype).add=function(e,t){Tt(this),this.i=null,e=xt(this,e);var n=this.g.get(e);return n||this.g.set(e,n=[]),n.push(t),this.h+=1,this},t.forEach=function(e,t){Tt(this),this.g.forEach((function(n,r){n.forEach((function(n){e.call(t,n,r,this)}),this)}),this)},t.na=function(){Tt(this);const e=Array.from(this.g.values()),t=Array.from(this.g.keys()),n=[];for(let r=0;r<t.length;r++){const i=e[r];for(let e=0;e<i.length;e++)n.push(t[r])}return n},t.V=function(e){Tt(this);let t=[];if("string"==typeof e)Ct(this,e)&&(t=t.concat(this.g.get(xt(this,e))));else{e=Array.from(this.g.values());for(let n=0;n<e.length;n++)t=t.concat(e[n])}return t},t.set=function(e,t){return Tt(this),this.i=null,Ct(this,e=xt(this,e))&&(this.h-=this.g.get(e).length),this.g.set(e,[t]),this.h+=1,this},t.get=function(e,t){return e&&0<(e=this.V(e)).length?String(e[0]):t},t.toString=function(){if(this.i)return this.i;if(!this.g)return"";const e=[],t=Array.from(this.g.keys());for(var n=0;n<t.length;n++){var r=t[n];const s=encodeURIComponent(String(r)),o=this.V(r);for(r=0;r<o.length;r++){var i=s;""!==o[r]&&(i+="="+encodeURIComponent(String(o[r]))),e.push(i)}}return this.i=e.join("&")},f(Dt,ge),Dt.prototype.g=function(){return new Rt(this.l,this.j)},Dt.prototype.i=(yt={},function(){return yt}),f(Rt,ie),(t=Rt.prototype).open=function(e,t){if(0!=this.readyState)throw this.abort(),Error("Error reopening a connection");this.B=e,this.A=t,this.readyState=1,Mt(this)},t.send=function(e){if(1!=this.readyState)throw this.abort(),Error("need to call open() first. ");this.g=!0;const t={headers:this.u,method:this.B,credentials:this.m,cache:void 0};e&&(t.body=e),(this.D||o).fetch(new Request(this.A,t)).then(this.Sa.bind(this),this.ga.bind(this))},t.abort=function(){this.response=this.responseText="",this.u=new Headers,this.status=0,this.j&&this.j.cancel("Request was aborted.").catch((()=>{})),1<=this.readyState&&this.g&&4!=this.readyState&&(this.g=!1,Lt(this)),this.readyState=0},t.Sa=function(e){if(this.g&&(this.l=e,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=e.headers,this.readyState=2,Mt(this)),this.g&&(this.readyState=3,Mt(this),this.g)))if("arraybuffer"===this.responseType)e.arrayBuffer().then(this.Qa.bind(this),this.ga.bind(this));else if(void 0!==o.ReadableStream&&"body"in e){if(this.j=e.body.getReader(),this.o){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.v=new TextDecoder;Pt(this)}else e.text().then(this.Ra.bind(this),this.ga.bind(this))},t.Pa=function(e){if(this.g){if(this.o&&e.value)this.response.push(e.value);else if(!this.o){var t=e.value?e.value:new Uint8Array(0);(t=this.v.decode(t,{stream:!e.done}))&&(this.response=this.responseText+=t)}e.done?Lt(this):Mt(this),3==this.readyState&&Pt(this)}},t.Ra=function(e){this.g&&(this.response=this.responseText=e,Lt(this))},t.Qa=function(e){this.g&&(this.response=e,Lt(this))},t.ga=function(){this.g&&Lt(this)},t.setRequestHeader=function(e,t){this.u.append(e,t)},t.getResponseHeader=function(e){return this.h&&this.h.get(e.toLowerCase())||""},t.getAllResponseHeaders=function(){if(!this.h)return"";const e=[],t=this.h.entries();for(var n=t.next();!n.done;)n=n.value,e.push(n[0]+": "+n[1]),n=t.next();return e.join("\r\n")},Object.defineProperty(Rt.prototype,"withCredentials",{get:function(){return"include"===this.m},set:function(e){this.m=e?"include":"same-origin"}}),f(Ut,ie);var jt=/^https?$/i,Bt=["POST","PUT"];function qt(e,t){e.h=!1,e.g&&(e.j=!0,e.g.abort(),e.j=!1),e.l=t,e.m=5,zt(e),Kt(e)}function zt(e){e.A||(e.A=!0,se(e,"complete"),se(e,"error"))}function Gt(e){if(e.h&&void 0!==s&&(!e.v[1]||4!=$t(e)||2!=e.Z()))if(e.u&&4==$t(e))ae(e.Ea,0,e);else if(se(e,"readystatechange"),4==$t(e)){e.h=!1;try{const s=e.Z();e:switch(s){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var t=!0;break e;default:t=!1}var n;if(!(n=t)){var r;if(r=0===s){var i=String(e.D).match(ot)[1]||null;!i&&o.self&&o.self.location&&(i=o.self.location.protocol.slice(0,-1)),r=!jt.test(i?i.toLowerCase():"")}n=r}if(n)se(e,"complete"),se(e,"success");else{e.m=6;try{var a=2<$t(e)?e.g.statusText:""}catch(e){a=""}e.l=a+" ["+e.Z()+"]",zt(e)}}finally{Kt(e)}}}function Kt(e,t){if(e.g){Wt(e);const n=e.g,r=e.v[0]?()=>{}:null;e.g=null,e.v=null,t||se(e,"ready");try{n.onreadystatechange=r}catch(e){}}}function Wt(e){e.I&&(o.clearTimeout(e.I),e.I=null)}function $t(e){return e.g?e.g.readyState:0}function Ht(e){try{if(!e.g)return null;if("response"in e.g)return e.g.response;switch(e.H){case"":case"text":return e.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in e.g)return e.g.mozResponseArrayBuffer}return null}catch(e){return null}}function Qt(e,t,n){return n&&n.internalChannelParams&&n.internalChannelParams[e]||t}function Jt(e){this.Aa=0,this.i=[],this.j=new Oe,this.ia=this.qa=this.I=this.W=this.g=this.ya=this.D=this.H=this.m=this.S=this.o=null,this.Ya=this.U=0,this.Va=Qt("failFast",!1,e),this.F=this.C=this.u=this.s=this.l=null,this.X=!0,this.za=this.T=-1,this.Y=this.v=this.B=0,this.Ta=Qt("baseRetryDelayMs",5e3,e),this.cb=Qt("retryDelaySeedMs",1e4,e),this.Wa=Qt("forwardChannelMaxRetries",2,e),this.wa=Qt("forwardChannelRequestTimeoutMs",2e4,e),this.pa=e&&e.xmlHttpFactory||void 0,this.Xa=e&&e.Tb||void 0,this.Ca=e&&e.useFetchStreams||!1,this.L=void 0,this.J=e&&e.supportsCrossDomainXhr||!1,this.K="",this.h=new Xe(e&&e.concurrentRequestLimit),this.Da=new Nt,this.P=e&&e.fastHandshake||!1,this.O=e&&e.encodeInitMessageHeaders||!1,this.P&&this.O&&(this.O=!1),this.Ua=e&&e.Rb||!1,e&&e.xa&&this.j.xa(),e&&e.forceLongPolling&&(this.X=!1),this.ba=!this.P&&this.X&&e&&e.detectBufferingProxy||!1,this.ja=void 0,e&&e.longPollingTimeout&&0<e.longPollingTimeout&&(this.ja=e.longPollingTimeout),this.ca=void 0,this.R=0,this.M=!1,this.ka=this.A=null}function Yt(e){if(Zt(e),3==e.G){var t=e.U++,n=ct(e.I);if(dt(n,"SID",e.K),dt(n,"RID",t),dt(n,"TYPE","terminate"),nn(e,n),(t=new Fe(e,e.j,t)).L=2,t.v=ft(ct(n)),n=!1,o.navigator&&o.navigator.sendBeacon)try{n=o.navigator.sendBeacon(t.v.toString(),"")}catch(e){}!n&&o.Image&&((new Image).src=t.v,n=!0),n||(t.g=mn(t.j,null),t.g.ea(t.v)),t.F=Date.now(),Ke(t)}fn(e)}function Xt(e){e.g&&(an(e),e.g.cancel(),e.g=null)}function Zt(e){Xt(e),e.u&&(o.clearTimeout(e.u),e.u=null),un(e),e.h.cancel(),e.s&&("number"==typeof e.s&&o.clearTimeout(e.s),e.s=null)}function en(e){if(!Ze(e.h)&&!e.s){e.s=!0;var t=e.Ga;k||D(),N||(k(),N=!0),O.add(t,e),e.B=0}}function tn(e,t){var n;n=t?t.l:e.U++;const r=ct(e.I);dt(r,"SID",e.K),dt(r,"RID",n),dt(r,"AID",e.T),nn(e,r),e.m&&e.o&&Vt(r,e.m,e.o),n=new Fe(e,e.j,n,e.B+1),null===e.m&&(n.H=e.o),t&&(e.i=t.D.concat(e.i)),t=rn(e,n,1e3),n.I=Math.round(.5*e.wa)+Math.round(.5*e.wa*Math.random()),nt(e.h,n),Be(n,r,t)}function nn(e,t){e.H&&w(e.H,(function(e,n){dt(t,n,e)})),e.l&&st({},(function(e,n){dt(t,n,e)}))}function rn(e,t,n){n=Math.min(e.i.length,n);var r=e.l?h(e.l.Na,e.l,e):null;e:{var i=e.i;let t=-1;for(;;){const e=["count="+n];-1==t?0<n?(t=i[0].g,e.push("ofs="+t)):t=0:e.push("ofs="+t);let s=!0;for(let o=0;o<n;o++){let n=i[o].g;const a=i[o].map;if(n-=t,0>n)t=Math.max(0,i[o].g-100),s=!1;else try{Ot(a,e,"req"+n+"_")}catch(e){r&&r(a)}}if(s){r=e.join("&");break e}}}return e=e.i.splice(0,n),t.D=e,r}function sn(e){if(!e.g&&!e.u){e.Y=1;var t=e.Fa;k||D(),N||(k(),N=!0),O.add(t,e),e.v=0}}function on(e){return!(e.g||e.u||3<=e.v||(e.Y++,e.u=Ne(h(e.Fa,e),hn(e,e.v)),e.v++,0))}function an(e){null!=e.A&&(o.clearTimeout(e.A),e.A=null)}function cn(e){e.g=new Fe(e,e.j,"rpc",e.Y),null===e.m&&(e.g.H=e.o),e.g.O=0;var t=ct(e.qa);dt(t,"RID","rpc"),dt(t,"SID",e.K),dt(t,"AID",e.T),dt(t,"CI",e.F?"0":"1"),!e.F&&e.ja&&dt(t,"TO",e.ja),dt(t,"TYPE","xmlhttp"),nn(e,t),e.m&&e.o&&Vt(t,e.m,e.o),e.L&&(e.g.I=e.L);var n=e.g;e=e.ia,n.L=1,n.v=ft(ct(t)),n.m=null,n.P=!0,qe(n,e)}function un(e){null!=e.C&&(o.clearTimeout(e.C),e.C=null)}function ln(e,t){var n=null;if(e.g==t){un(e),an(e),e.g=null;var r=2}else{if(!tt(e.h,t))return;n=t.D,rt(e.h,t),r=1}if(0!=e.G)if(t.o)if(1==r){n=t.m?t.m.length:0,t=Date.now()-t.F;var i=e.B;se(r=Te(),new ke(r,n,t,i)),en(e)}else sn(e);else if(3==(i=t.s)||0==i&&0<t.X||!(1==r&&function(e,t){return!(et(e.h)>=e.h.j-(e.s?1:0)||(e.s?(e.i=t.D.concat(e.i),0):1==e.G||2==e.G||e.B>=(e.Va?0:e.Wa)||(e.s=Ne(h(e.Ga,e,t),hn(e,e.B)),e.B++,0)))}(e,t)||2==r&&on(e)))switch(n&&0<n.length&&(t=e.h,t.i=t.i.concat(n)),i){case 1:dn(e,5);break;case 4:dn(e,10);break;case 3:dn(e,6);break;default:dn(e,2)}}function hn(e,t){let n=e.Ta+Math.floor(Math.random()*e.cb);return e.isActive()||(n*=2),n*t}function dn(e,t){if(e.j.info("Error code "+t),2==t){var n=h(e.fb,e),r=e.Xa;const t=!r;r=new at(r||"//www.google.com/images/cleardot.gif"),o.location&&"http"==o.location.protocol||ut(r,"https"),ft(r),t?function(e,t){const n=new Oe;if(o.Image){const r=new Image;r.onload=d(kt,n,"TestLoadImage: loaded",!0,t,r),r.onerror=d(kt,n,"TestLoadImage: error",!1,t,r),r.onabort=d(kt,n,"TestLoadImage: abort",!1,t,r),r.ontimeout=d(kt,n,"TestLoadImage: timeout",!1,t,r),o.setTimeout((function(){r.ontimeout&&r.ontimeout()}),1e4),r.src=e}else t(!1)}(r.toString(),n):function(e,t){new Oe;const n=new AbortController,r=setTimeout((()=>{n.abort(),kt(0,0,!1,t)}),1e4);fetch(e,{signal:n.signal}).then((e=>{clearTimeout(r),e.ok?kt(0,0,!0,t):kt(0,0,!1,t)})).catch((()=>{clearTimeout(r),kt(0,0,!1,t)}))}(r.toString(),n)}else xe(2);e.G=0,e.l&&e.l.sa(t),fn(e),Zt(e)}function fn(e){if(e.G=0,e.ka=[],e.l){const t=it(e.h);0==t.length&&0==e.i.length||(m(e.ka,t),m(e.ka,e.i),e.h.i.length=0,p(e.i),e.i.length=0),e.l.ra()}}function pn(e,t,n){var r=n instanceof at?ct(n):new at(n);if(""!=r.g)t&&(r.g=t+"."+r.g),lt(r,r.s);else{var i=o.location;r=i.protocol,t=t?t+"."+i.hostname:i.hostname,i=+i.port;var s=new at(null);r&&ut(s,r),t&&(s.g=t),i&&lt(s,i),n&&(s.l=n),r=s}return n=e.D,t=e.ya,n&&t&&dt(r,n,t),dt(r,"VER",e.la),nn(e,r),r}function mn(e,t,n){if(t&&!e.J)throw Error("Can't create secondary domain capable XhrIo object.");return(t=e.Ca&&!e.pa?new Ut(new Dt({eb:n})):new Ut(e.pa)).Ha(e.J),t}function gn(){}function yn(){}function vn(e,t){ie.call(this),this.g=new Jt(t),this.l=e,this.h=t&&t.messageUrlParams||null,e=t&&t.messageHeaders||null,t&&t.clientProtocolHeaderRequired&&(e?e["X-Client-Protocol"]="webchannel":e={"X-Client-Protocol":"webchannel"}),this.g.o=e,e=t&&t.initMessageHeaders||null,t&&t.messageContentType&&(e?e["X-WebChannel-Content-Type"]=t.messageContentType:e={"X-WebChannel-Content-Type":t.messageContentType}),t&&t.va&&(e?e["X-WebChannel-Client-Profile"]=t.va:e={"X-WebChannel-Client-Profile":t.va}),this.g.S=e,(e=t&&t.Sb)&&!g(e)&&(this.g.m=e),this.v=t&&t.supportsCrossDomainXhr||!1,this.u=t&&t.sendRawJson||!1,(t=t&&t.httpSessionIdParam)&&!g(t)&&(this.g.D=t,null!==(e=this.h)&&t in e&&t in(e=this.h)&&delete e[t]),this.j=new _n(this)}function bn(e){we.call(this),e.__headers__&&(this.headers=e.__headers__,this.statusCode=e.__status__,delete e.__headers__,delete e.__status__);var t=e.__sm__;if(t){e:{for(const n in t){e=n;break e}e=void 0}(this.i=e)&&(e=this.i,t=null!==t&&e in t?t[e]:void 0),this.data=t}else this.data=e}function wn(){_e.call(this),this.status=1}function _n(e){this.g=e}(t=Ut.prototype).Ha=function(e){this.J=e},t.ea=function(e,t,n,r){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.D+"; newUri="+e);t=t?t.toUpperCase():"GET",this.D=e,this.l="",this.m=0,this.A=!1,this.h=!0,this.g=this.o?this.o.g():Re.g(),this.v=this.o?ye(this.o):ye(Re),this.g.onreadystatechange=h(this.Ea,this);try{this.B=!0,this.g.open(t,String(e),!0),this.B=!1}catch(e){return void qt(this,e)}if(e=n||"",n=new Map(this.headers),r)if(Object.getPrototypeOf(r)===Object.prototype)for(var i in r)n.set(i,r[i]);else{if("function"!=typeof r.keys||"function"!=typeof r.get)throw Error("Unknown input type for opt_headers: "+String(r));for(const e of r.keys())n.set(e,r.get(e))}r=Array.from(n.keys()).find((e=>"content-type"==e.toLowerCase())),i=o.FormData&&e instanceof o.FormData,!(0<=Array.prototype.indexOf.call(Bt,t,void 0))||r||i||n.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");for(const[e,t]of n)this.g.setRequestHeader(e,t);this.H&&(this.g.responseType=this.H),"withCredentials"in this.g&&this.g.withCredentials!==this.J&&(this.g.withCredentials=this.J);try{Wt(this),this.u=!0,this.g.send(e),this.u=!1}catch(e){qt(this,e)}},t.abort=function(e){this.g&&this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1,this.m=e||7,se(this,"complete"),se(this,"abort"),Kt(this))},t.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),Kt(this,!0)),Ut.aa.N.call(this)},t.Ea=function(){this.s||(this.B||this.u||this.j?Gt(this):this.bb())},t.bb=function(){Gt(this)},t.isActive=function(){return!!this.g},t.Z=function(){try{return 2<$t(this)?this.g.status:-1}catch(e){return-1}},t.oa=function(){try{return this.g?this.g.responseText:""}catch(e){return""}},t.Oa=function(e){if(this.g){var t=this.g.responseText;return e&&0==t.indexOf(e)&&(t=t.substring(e.length)),pe(t)}},t.Ba=function(){return this.m},t.Ka=function(){return"string"==typeof this.l?this.l:String(this.l)},(t=Jt.prototype).la=8,t.G=1,t.connect=function(e,t,n,r){xe(0),this.W=e,this.H=t||{},n&&void 0!==r&&(this.H.OSID=n,this.H.OAID=r),this.F=this.X,this.I=pn(this,null,this.W),en(this)},t.Ga=function(e){if(this.s)if(this.s=null,1==this.G){if(!e){this.U=Math.floor(1e5*Math.random()),e=this.U++;const i=new Fe(this,this.j,e);let s=this.o;if(this.S&&(s?(s=_(s),E(s,this.S)):s=this.S),null!==this.m||this.O||(i.H=s,s=null),this.P)e:{for(var t=0,n=0;n<this.i.length;n++){var r=this.i[n];if(void 0===(r="__data__"in r.map&&"string"==typeof(r=r.map.__data__)?r.length:void 0))break;if(4096<(t+=r)){t=n;break e}if(4096===t||n===this.i.length-1){t=n+1;break e}}t=1e3}else t=1e3;t=rn(this,i,t),dt(n=ct(this.I),"RID",e),dt(n,"CVER",22),this.D&&dt(n,"X-HTTP-Session-Id",this.D),nn(this,n),s&&(this.O?t="headers="+encodeURIComponent(String(Ft(s)))+"&"+t:this.m&&Vt(n,this.m,s)),nt(this.h,i),this.Ua&&dt(n,"TYPE","init"),this.P?(dt(n,"$req",t),dt(n,"SID","null"),i.T=!0,Be(i,n,null)):Be(i,n,t),this.G=2}}else 3==this.G&&(e?tn(this,e):0==this.i.length||Ze(this.h)||tn(this))},t.Fa=function(){if(this.u=null,cn(this),this.ba&&!(this.M||null==this.g||0>=this.R)){var e=2*this.R;this.j.info("BP detection timer enabled: "+e),this.A=Ne(h(this.ab,this),e)}},t.ab=function(){this.A&&(this.A=null,this.j.info("BP detection timeout reached."),this.j.info("Buffering proxy detected and switch to long-polling!"),this.F=!1,this.M=!0,xe(10),Xt(this),cn(this))},t.Za=function(){null!=this.C&&(this.C=null,Xt(this),on(this),xe(19))},t.fb=function(e){e?(this.j.info("Successfully pinged google.com"),xe(2)):(this.j.info("Failed to ping google.com"),xe(1))},t.isActive=function(){return!!this.l&&this.l.isActive(this)},(t=gn.prototype).ua=function(){},t.ta=function(){},t.sa=function(){},t.ra=function(){},t.isActive=function(){return!0},t.Na=function(){},yn.prototype.g=function(e,t){return new vn(e,t)},f(vn,ie),vn.prototype.m=function(){this.g.l=this.j,this.v&&(this.g.J=!0),this.g.connect(this.l,this.h||void 0)},vn.prototype.close=function(){Yt(this.g)},vn.prototype.o=function(e){var t=this.g;if("string"==typeof e){var n={};n.__data__=e,e=n}else this.u&&((n={}).__data__=fe(e),e=n);t.i.push(new Ye(t.Ya++,e)),3==t.G&&en(t)},vn.prototype.N=function(){this.g.l=null,delete this.j,Yt(this.g),delete this.g,vn.aa.N.call(this)},f(bn,we),f(wn,_e),f(_n,gn),_n.prototype.ua=function(){se(this.g,"a")},_n.prototype.ta=function(e){se(this.g,new bn(e))},_n.prototype.sa=function(e){se(this.g,new wn(e))},_n.prototype.ra=function(){se(this.g,"b")},yn.prototype.createWebChannel=yn.prototype.g,vn.prototype.send=vn.prototype.o,vn.prototype.open=vn.prototype.m,vn.prototype.close=vn.prototype.close,e.exports.createWebChannelTransport=function(){return new yn},e.exports.getStatEventTarget=function(){return Te()},e.exports.Event=Ie,e.exports.Stat={mb:0,pb:1,qb:2,Jb:3,Ob:4,Lb:5,Mb:6,Kb:7,Ib:8,Nb:9,PROXY:10,NOPROXY:11,Gb:12,Cb:13,Db:14,Bb:15,Eb:16,Fb:17,ib:18,hb:19,jb:20},Pe.NO_ERROR=0,Pe.TIMEOUT=8,Pe.HTTP_ERROR=6,e.exports.ErrorCode=Pe,Le.COMPLETE="complete",e.exports.EventType=Le,ve.EventType=be,be.OPEN="a",be.CLOSE="b",be.ERROR="c",be.MESSAGE="d",ie.prototype.listen=ie.prototype.K,e.exports.WebChannel=ve,e.exports.FetchXmlHttpFactory=Dt,Ut.prototype.listenOnce=Ut.prototype.L,Ut.prototype.getLastError=Ut.prototype.Ka,Ut.prototype.getLastErrorCode=Ut.prototype.Ba,Ut.prototype.getStatus=Ut.prototype.Z,Ut.prototype.getResponseJson=Ut.prototype.Oa,Ut.prototype.getResponseText=Ut.prototype.oa,Ut.prototype.send=Ut.prototype.ea,Ut.prototype.setWithCredentials=Ut.prototype.Ha,e.exports.XhrIo=Ut}).apply(void 0!==n.g?n.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},5577:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(6199);r.registerVersion("firebase","10.13.2","app"),Object.keys(r).forEach((function(e){"default"===e||t.hasOwnProperty(e)||Object.defineProperty(t,e,{enumerable:!0,get:function(){return r[e]}})}))},5052:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(9970);Object.keys(r).forEach((function(e){"default"===e||t.hasOwnProperty(e)||Object.defineProperty(t,e,{enumerable:!0,get:function(){return r[e]}})}))},9815:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(1241);Object.keys(r).forEach((function(e){"default"===e||t.hasOwnProperty(e)||Object.defineProperty(t,e,{enumerable:!0,get:function(){return r[e]}})}))},2733:function(e){e.exports=function(){"use strict";function e(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)e[r]=n[r]}return e}return function t(n,r){function i(t,i,s){if("undefined"!=typeof document){"number"==typeof(s=e({},r,s)).expires&&(s.expires=new Date(Date.now()+864e5*s.expires)),s.expires&&(s.expires=s.expires.toUTCString()),t=encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var o="";for(var a in s)s[a]&&(o+="; "+a,!0!==s[a]&&(o+="="+s[a].split(";")[0]));return document.cookie=t+"="+n.write(i,t)+o}}return Object.create({set:i,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var t=document.cookie?document.cookie.split("; "):[],r={},i=0;i<t.length;i++){var s=t[i].split("="),o=s.slice(1).join("=");try{var a=decodeURIComponent(s[0]);if(r[a]=n.read(o,a),e===a)break}catch(e){}}return e?r[e]:r}},remove:function(t,n){i(t,"",e({},n,{expires:-1}))},withAttributes:function(n){return t(this.converter,e({},this.attributes,n))},withConverter:function(n){return t(e({},this.converter,n),this.attributes)}},{attributes:{value:Object.freeze(r)},converter:{value:Object.freeze(n)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"})}()},6765:(e,t,n)=>{"use strict";function r(e){this.message=e}n.r(t),n.d(t,{InvalidTokenError:()=>o,default:()=>a}),r.prototype=new Error,r.prototype.name="InvalidCharacterError";var i="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.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=t.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(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(i(e).replace(/(.)/g,(function(e,t){var n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return i(t)}}function o(e){this.message=e}o.prototype=new Error,o.prototype.name="InvalidTokenError";const a=function(e,t){if("string"!=typeof e)throw new o("Invalid token specified");var n=!0===(t=t||{}).header?0:1;try{return JSON.parse(s(e.split(".")[n]))}catch(e){throw new o("Invalid token specified: "+e.message)}}},4046:(e,t,n)=>{"use strict";n.r(t),n.d(t,{ArgumentOutOfRangeError:()=>N.k,AsyncSubject:()=>l.h,BehaviorSubject:()=>c.t,ConnectableObservable:()=>i.G,EMPTY:()=>Q.w,EmptyError:()=>O.G,GroupedObservable:()=>s.k,NEVER:()=>he,Notification:()=>S.E,NotificationKind:()=>S.I,ObjectUnsubscribedError:()=>D.P,Observable:()=>r.c,ReplaySubject:()=>u.m,Scheduler:()=>I._,Subject:()=>a.B7,Subscriber:()=>T.v,Subscription:()=>E.y,TimeoutError:()=>P.M,UnsubscriptionError:()=>R.Z,VirtualAction:()=>_,VirtualTimeScheduler:()=>w,animationFrame:()=>b,animationFrameScheduler:()=>v,asap:()=>h.I,asapScheduler:()=>h.$,async:()=>d.b,asyncScheduler:()=>d.E,bindCallback:()=>U,bindNodeCallback:()=>q,combineLatest:()=>W.zV,concat:()=>$.x,config:()=>ke.$,defer:()=>H.v,empty:()=>Q.I,forkJoin:()=>X,from:()=>Y.H,fromEvent:()=>te,fromEventPattern:()=>re,generate:()=>ie,identity:()=>x.D,iif:()=>oe,interval:()=>ce,isObservable:()=>k,merge:()=>le.h,never:()=>de,noop:()=>A.l,observable:()=>o.s,of:()=>fe.of,onErrorResumeNext:()=>pe,pairs:()=>me,partition:()=>we,pipe:()=>C.F,queue:()=>f.g,queueScheduler:()=>f.T,race:()=>_e.O4,range:()=>Ie,scheduled:()=>xe.c,throwError:()=>Te.$,timer:()=>Se.O,using:()=>Ce,zip:()=>Ae.yU});var r=n(9664),i=n(4491),s=n(3108),o=n(3656),a=n(6988),c=n(2430),u=n(8977),l=n(1934),h=n(9081),d=n(6346),f=n(464),p=n(7272),m=n(6027),g=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.scheduler=t,r.work=n,r}return p.C6(t,e),t.prototype.requestAsyncId=function(t,n,r){return void 0===r&&(r=0),null!==r&&r>0?e.prototype.requestAsyncId.call(this,t,n,r):(t.actions.push(this),t.scheduled||(t.scheduled=requestAnimationFrame((function(){return t.flush(null)}))))},t.prototype.recycleAsyncId=function(t,n,r){if(void 0===r&&(r=0),null!==r&&r>0||null===r&&this.delay>0)return e.prototype.recycleAsyncId.call(this,t,n,r);0===t.actions.length&&(cancelAnimationFrame(n),t.scheduled=void 0)},t}(m.R),y=n(4881),v=new(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return p.C6(t,e),t.prototype.flush=function(e){this.active=!0,this.scheduled=void 0;var t,n=this.actions,r=-1,i=n.length;e=e||n.shift();do{if(t=e.execute(e.state,e.delay))break}while(++r<i&&(e=n.shift()));if(this.active=!1,t){for(;++r<i&&(e=n.shift());)e.unsubscribe();throw t}},t}(y.q))(g),b=v,w=function(e){function t(t,n){void 0===t&&(t=_),void 0===n&&(n=Number.POSITIVE_INFINITY);var r=e.call(this,t,(function(){return r.frame}))||this;return r.maxFrames=n,r.frame=0,r.index=-1,r}return p.C6(t,e),t.prototype.flush=function(){for(var e,t,n=this.actions,r=this.maxFrames;(t=n[0])&&t.delay<=r&&(n.shift(),this.frame=t.delay,!(e=t.execute(t.state,t.delay))););if(e){for(;t=n.shift();)t.unsubscribe();throw e}},t.frameTimeFactor=10,t}(y.q),_=function(e){function t(t,n,r){void 0===r&&(r=t.index+=1);var i=e.call(this,t,n)||this;return i.scheduler=t,i.work=n,i.index=r,i.active=!0,i.index=t.index=r,i}return p.C6(t,e),t.prototype.schedule=function(n,r){if(void 0===r&&(r=0),!this.id)return e.prototype.schedule.call(this,n,r);this.active=!1;var i=new t(this.scheduler,this.work);return this.add(i),i.schedule(n,r)},t.prototype.requestAsyncId=function(e,n,r){void 0===r&&(r=0),this.delay=e.frame+r;var i=e.actions;return i.push(this),i.sort(t.sortActions),!0},t.prototype.recycleAsyncId=function(e,t,n){void 0===n&&(n=0)},t.prototype._execute=function(t,n){if(!0===this.active)return e.prototype._execute.call(this,t,n)},t.sortActions=function(e,t){return e.delay===t.delay?e.index===t.index?0:e.index>t.index?1:-1:e.delay>t.delay?1:-1},t}(m.R),I=n(957),E=n(9147),T=n(2968),S=n(2281),C=n(6833),A=n(1193),x=n(1015);function k(e){return!!e&&(e instanceof r.c||"function"==typeof e.lift&&"function"==typeof e.subscribe)}var N=n(692),O=n(3700),D=n(731),R=n(9857),P=n(34),L=n(8100),M=n(1075),F=n(252),V=n(4576);function U(e,t,n){if(t){if(!(0,V.m)(t))return function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];return U(e,n).apply(void 0,r).pipe((0,L.T)((function(e){return(0,F.c)(e)?t.apply(void 0,e):t(e)})))};n=t}return function(){for(var t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];var s,o=this,a={context:o,subject:s,callbackFunc:e,scheduler:n};return new r.c((function(r){if(n){var i={args:t,subscriber:r,params:a};return n.schedule(j,0,i)}if(!s){s=new l.h;try{e.apply(o,t.concat([function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];s.next(e.length<=1?e[0]:e),s.complete()}]))}catch(e){(0,M.H)(s)?s.error(e):console.warn(e)}}return s.subscribe(r)}))}}function j(e){var t=this,n=e.args,r=e.subscriber,i=e.params,s=i.callbackFunc,o=i.context,a=i.scheduler,c=i.subject;if(!c){c=i.subject=new l.h;try{s.apply(o,n.concat([function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=e.length<=1?e[0]:e;t.add(a.schedule(B,0,{value:r,subject:c}))}]))}catch(e){c.error(e)}}this.add(c.subscribe(r))}function B(e){var t=e.value,n=e.subject;n.next(t),n.complete()}function q(e,t,n){if(t){if(!(0,V.m)(t))return function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];return q(e,n).apply(void 0,r).pipe((0,L.T)((function(e){return(0,F.c)(e)?t.apply(void 0,e):t(e)})))};n=t}return function(){for(var t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];var s={subject:void 0,args:t,callbackFunc:e,scheduler:n,context:this};return new r.c((function(r){var i=s.context,o=s.subject;if(n)return n.schedule(z,0,{params:s,subscriber:r,context:i});if(!o){o=s.subject=new l.h;try{e.apply(i,t.concat([function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e.shift();n?o.error(n):(o.next(e.length<=1?e[0]:e),o.complete())}]))}catch(e){(0,M.H)(o)?o.error(e):console.warn(e)}}return o.subscribe(r)}))}}function z(e){var t=this,n=e.params,r=e.subscriber,i=e.context,s=n.callbackFunc,o=n.args,a=n.scheduler,c=n.subject;if(!c){c=n.subject=new l.h;try{s.apply(i,o.concat([function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=e.shift();if(r)t.add(a.schedule(K,0,{err:r,subject:c}));else{var i=e.length<=1?e[0]:e;t.add(a.schedule(G,0,{value:i,subject:c}))}}]))}catch(e){this.add(a.schedule(K,0,{err:e,subject:c}))}}this.add(c.subscribe(r))}function G(e){var t=e.value,n=e.subject;n.next(t),n.complete()}function K(e){var t=e.err;e.subject.error(t)}var W=n(8890),$=n(926),H=n(560),Q=n(4833),J=n(806),Y=n(7046);function X(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(1===e.length){var n=e[0];if((0,F.c)(n))return Z(n,null);if((0,J.G)(n)&&Object.getPrototypeOf(n)===Object.prototype){var r=Object.keys(n);return Z(r.map((function(e){return n[e]})),r)}}if("function"==typeof e[e.length-1]){var i=e.pop();return Z(e=1===e.length&&(0,F.c)(e[0])?e[0]:e,null).pipe((0,L.T)((function(e){return i.apply(void 0,e)})))}return Z(e,null)}function Z(e,t){return new r.c((function(n){var r=e.length;if(0!==r)for(var i=new Array(r),s=0,o=0,a=function(a){var c=(0,Y.H)(e[a]),u=!1;n.add(c.subscribe({next:function(e){u||(u=!0,o++),i[a]=e},error:function(e){return n.error(e)},complete:function(){++s!==r&&u||(o===r&&n.next(t?t.reduce((function(e,t,n){return e[t]=i[n],e}),{}):i),n.complete())}}))},c=0;c<r;c++)a(c);else n.complete()}))}var ee=n(9029);function te(e,t,n,i){return(0,ee.T)(n)&&(i=n,n=void 0),i?te(e,t,n).pipe((0,L.T)((function(e){return(0,F.c)(e)?i.apply(void 0,e):i(e)}))):new r.c((function(r){ne(e,t,(function(e){arguments.length>1?r.next(Array.prototype.slice.call(arguments)):r.next(e)}),r,n)}))}function ne(e,t,n,r,i){var s;if(function(e){return e&&"function"==typeof e.addEventListener&&"function"==typeof e.removeEventListener}(e)){var o=e;e.addEventListener(t,n,i),s=function(){return o.removeEventListener(t,n,i)}}else if(function(e){return e&&"function"==typeof e.on&&"function"==typeof e.off}(e)){var a=e;e.on(t,n),s=function(){return a.off(t,n)}}else if(function(e){return e&&"function"==typeof e.addListener&&"function"==typeof e.removeListener}(e)){var c=e;e.addListener(t,n),s=function(){return c.removeListener(t,n)}}else{if(!e||!e.length)throw new TypeError("Invalid event target");for(var u=0,l=e.length;u<l;u++)ne(e[u],t,n,r,i)}r.add(s)}function re(e,t,n){return n?re(e,t).pipe((0,L.T)((function(e){return(0,F.c)(e)?n.apply(void 0,e):n(e)}))):new r.c((function(n){var r,i=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n.next(1===e.length?e[0]:e)};try{r=e(i)}catch(e){return void n.error(e)}if((0,ee.T)(t))return function(){return t(i,r)}}))}function ie(e,t,n,i,s){var o,a;if(1==arguments.length){var c=e;a=c.initialState,t=c.condition,n=c.iterate,o=c.resultSelector||x.D,s=c.scheduler}else void 0===i||(0,V.m)(i)?(a=e,o=x.D,s=i):(a=e,o=i);return new r.c((function(e){var r=a;if(s)return s.schedule(se,0,{subscriber:e,iterate:n,condition:t,resultSelector:o,state:r});for(;;){if(t){var i=void 0;try{i=t(r)}catch(t){return void e.error(t)}if(!i){e.complete();break}}var c=void 0;try{c=o(r)}catch(t){return void e.error(t)}if(e.next(c),e.closed)break;try{r=n(r)}catch(t){return void e.error(t)}}}))}function se(e){var t=e.subscriber,n=e.condition;if(!t.closed){if(e.needIterate)try{e.state=e.iterate(e.state)}catch(e){return void t.error(e)}else e.needIterate=!0;if(n){var r=void 0;try{r=n(e.state)}catch(e){return void t.error(e)}if(!r)return void t.complete();if(t.closed)return}var i;try{i=e.resultSelector(e.state)}catch(e){return void t.error(e)}if(!t.closed&&(t.next(i),!t.closed))return this.schedule(e)}}function oe(e,t,n){return void 0===t&&(t=Q.w),void 0===n&&(n=Q.w),(0,H.v)((function(){return e()?t:n}))}var ae=n(6290);function ce(e,t){return void 0===e&&(e=0),void 0===t&&(t=d.b),(!(0,ae.k)(e)||e<0)&&(e=0),t&&"function"==typeof t.schedule||(t=d.b),new r.c((function(n){return n.add(t.schedule(ue,e,{subscriber:n,counter:0,period:e})),n}))}function ue(e){var t=e.subscriber,n=e.counter,r=e.period;t.next(n),this.schedule({subscriber:t,counter:n+1,period:r},r)}var le=n(3767),he=new r.c(A.l);function de(){return he}var fe=n(8927);function pe(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(0===e.length)return Q.w;var n=e[0],i=e.slice(1);return 1===e.length&&(0,F.c)(n)?pe.apply(void 0,n):new r.c((function(e){var t=function(){return e.add(pe.apply(void 0,i).subscribe(e))};return(0,Y.H)(n).subscribe({next:function(t){e.next(t)},error:t,complete:t})}))}function me(e,t){return t?new r.c((function(n){var r=Object.keys(e),i=new E.y;return i.add(t.schedule(ge,0,{keys:r,index:0,subscriber:n,subscription:i,obj:e})),i})):new r.c((function(t){for(var n=Object.keys(e),r=0;r<n.length&&!t.closed;r++){var i=n[r];e.hasOwnProperty(i)&&t.next([i,e[i]])}t.complete()}))}function ge(e){var t=e.keys,n=e.index,r=e.subscriber,i=e.subscription,s=e.obj;if(!r.closed)if(n<t.length){var o=t[n];r.next([o,s[o]]),i.add(this.schedule({keys:t,index:n+1,subscriber:r,subscription:i,obj:s}))}else r.complete()}var ye=n(3428),ve=n(8777),be=n(9610);function we(e,t,n){return[(0,be.p)(t,n)(new r.c((0,ve.i)(e))),(0,be.p)((0,ye.A)(t,n))(new r.c((0,ve.i)(e)))]}var _e=n(8071);function Ie(e,t,n){return void 0===e&&(e=0),new r.c((function(r){void 0===t&&(t=e,e=0);var i=0,s=e;if(n)return n.schedule(Ee,0,{index:i,count:t,start:e,subscriber:r});for(;;){if(i++>=t){r.complete();break}if(r.next(s++),r.closed)break}}))}function Ee(e){var t=e.start,n=e.index,r=e.count,i=e.subscriber;n>=r?i.complete():(i.next(t),i.closed||(e.index=n+1,e.start=t+1,this.schedule(e)))}var Te=n(7404),Se=n(1133);function Ce(e,t){return new r.c((function(n){var r,i;try{r=e()}catch(e){return void n.error(e)}try{i=t(r)}catch(e){return void n.error(e)}var s=(i?(0,Y.H)(i):Q.w).subscribe(n);return function(){s.unsubscribe(),r&&r.unsubscribe()}}))}var Ae=n(4219),xe=n(1413),ke=n(1732)},1934:(e,t,n)=>{"use strict";n.d(t,{h:()=>o});var r=n(7272),i=n(6988),s=n(9147),o=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.value=null,t.hasNext=!1,t.hasCompleted=!1,t}return r.C6(t,e),t.prototype._subscribe=function(t){return this.hasError?(t.error(this.thrownError),s.y.EMPTY):this.hasCompleted&&this.hasNext?(t.next(this.value),t.complete(),s.y.EMPTY):e.prototype._subscribe.call(this,t)},t.prototype.next=function(e){this.hasCompleted||(this.value=e,this.hasNext=!0)},t.prototype.error=function(t){this.hasCompleted||e.prototype.error.call(this,t)},t.prototype.complete=function(){this.hasCompleted=!0,this.hasNext&&e.prototype.next.call(this,this.value),e.prototype.complete.call(this)},t}(i.B7)},2430:(e,t,n)=>{"use strict";n.d(t,{t:()=>o});var r=n(7272),i=n(6988),s=n(731),o=function(e){function t(t){var n=e.call(this)||this;return n._value=t,n}return r.C6(t,e),Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!0,configurable:!0}),t.prototype._subscribe=function(t){var n=e.prototype._subscribe.call(this,t);return n&&!n.closed&&t.next(this._value),n},t.prototype.getValue=function(){if(this.hasError)throw this.thrownError;if(this.closed)throw new s.P;return this._value},t.prototype.next=function(t){e.prototype.next.call(this,this._value=t)},t}(i.B7)},2281:(e,t,n)=>{"use strict";n.d(t,{E:()=>a,I:()=>r});var r,i=n(4833),s=n(8927),o=n(7404);r||(r={});var a=function(){function e(e,t,n){this.kind=e,this.value=t,this.error=n,this.hasValue="N"===e}return e.prototype.observe=function(e){switch(this.kind){case"N":return e.next&&e.next(this.value);case"E":return e.error&&e.error(this.error);case"C":return e.complete&&e.complete()}},e.prototype.do=function(e,t,n){switch(this.kind){case"N":return e&&e(this.value);case"E":return t&&t(this.error);case"C":return n&&n()}},e.prototype.accept=function(e,t,n){return e&&"function"==typeof e.next?this.observe(e):this.do(e,t,n)},e.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.I)()}throw new Error("unexpected notification kind value")},e.createNext=function(t){return void 0!==t?new e("N",t):e.undefinedValueNotification},e.createError=function(t){return new e("E",void 0,t)},e.createComplete=function(){return e.completeNotification},e.completeNotification=new e("C"),e.undefinedValueNotification=new e("N",void 0),e}()},9664:(e,t,n)=>{"use strict";n.d(t,{c:()=>l});var r=n(1075),i=n(2968),s=n(3089),o=n(6708),a=n(3656),c=n(6833),u=n(1732),l=function(){function e(e){this._isScalar=!1,e&&(this._subscribe=e)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(e,t,n){var r=this.operator,a=function(e,t,n){if(e){if(e instanceof i.v)return e;if(e[s.D])return e[s.D]()}return e||t||n?new i.v(e,t,n):new i.v(o.I)}(e,t,n);if(r?a.add(r.call(a,this.source)):a.add(this.source||u.$.useDeprecatedSynchronousErrorHandling&&!a.syncErrorThrowable?this._subscribe(a):this._trySubscribe(a)),u.$.useDeprecatedSynchronousErrorHandling&&a.syncErrorThrowable&&(a.syncErrorThrowable=!1,a.syncErrorThrown))throw a.syncErrorValue;return a},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){u.$.useDeprecatedSynchronousErrorHandling&&(e.syncErrorThrown=!0,e.syncErrorValue=t),(0,r.H)(e)?e.error(t):console.warn(t)}},e.prototype.forEach=function(e,t){var n=this;return new(t=h(t))((function(t,r){var i;i=n.subscribe((function(t){try{e(t)}catch(e){r(e),i&&i.unsubscribe()}}),r,t)}))},e.prototype._subscribe=function(e){var t=this.source;return t&&t.subscribe(e)},e.prototype[a.s]=function(){return this},e.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return 0===e.length?this:(0,c.m)(e)(this)},e.prototype.toPromise=function(e){var t=this;return new(e=h(e))((function(e,n){var r;t.subscribe((function(e){return r=e}),(function(e){return n(e)}),(function(){return e(r)}))}))},e.create=function(t){return new e(t)},e}();function h(e){if(e||(e=u.$.Promise||Promise),!e)throw new Error("no Promise impl found");return e}},6708:(e,t,n)=>{"use strict";n.d(t,{I:()=>s});var r=n(1732),i=n(9199),s={closed:!0,next:function(e){},error:function(e){if(r.$.useDeprecatedSynchronousErrorHandling)throw e;(0,i.T)(e)},complete:function(){}}},7069:(e,t,n)=>{"use strict";n.d(t,{E:()=>i});var r=n(7272),i=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r.C6(t,e),t.prototype.notifyNext=function(e,t,n,r,i){this.destination.next(t)},t.prototype.notifyError=function(e,t){this.destination.error(e)},t.prototype.notifyComplete=function(e){this.destination.complete()},t}(n(2968).v)},8977:(e,t,n)=>{"use strict";n.d(t,{m:()=>l});var r=n(7272),i=n(6988),s=n(464),o=n(9147),a=n(3947),c=n(731),u=n(293),l=function(e){function t(t,n,r){void 0===t&&(t=Number.POSITIVE_INFINITY),void 0===n&&(n=Number.POSITIVE_INFINITY);var i=e.call(this)||this;return i.scheduler=r,i._events=[],i._infiniteTimeWindow=!1,i._bufferSize=t<1?1:t,i._windowTime=n<1?1:n,n===Number.POSITIVE_INFINITY?(i._infiniteTimeWindow=!0,i.next=i.nextInfiniteTimeWindow):i.next=i.nextTimeWindow,i}return r.C6(t,e),t.prototype.nextInfiniteTimeWindow=function(t){if(!this.isStopped){var n=this._events;n.push(t),n.length>this._bufferSize&&n.shift()}e.prototype.next.call(this,t)},t.prototype.nextTimeWindow=function(t){this.isStopped||(this._events.push(new h(this._getNow(),t)),this._trimBufferThenGetEvents()),e.prototype.next.call(this,t)},t.prototype._subscribe=function(e){var t,n=this._infiniteTimeWindow,r=n?this._events:this._trimBufferThenGetEvents(),i=this.scheduler,s=r.length;if(this.closed)throw new c.P;if(this.isStopped||this.hasError?t=o.y.EMPTY:(this.observers.push(e),t=new u.Y(this,e)),i&&e.add(e=new a.YZ(e,i)),n)for(var l=0;l<s&&!e.closed;l++)e.next(r[l]);else for(l=0;l<s&&!e.closed;l++)e.next(r[l].value);return this.hasError?e.error(this.thrownError):this.isStopped&&e.complete(),t},t.prototype._getNow=function(){return(this.scheduler||s.g).now()},t.prototype._trimBufferThenGetEvents=function(){for(var e=this._getNow(),t=this._bufferSize,n=this._windowTime,r=this._events,i=r.length,s=0;s<i&&!(e-r[s].time<n);)s++;return i>t&&(s=Math.max(s,i-t)),s>0&&r.splice(0,s),r},t}(i.B7),h=function(){return function(e,t){this.time=e,this.value=t}}()},957:(e,t,n)=>{"use strict";n.d(t,{_:()=>r});var r=function(){function e(t,n){void 0===n&&(n=e.now),this.SchedulerAction=t,this.now=n}return e.prototype.schedule=function(e,t,n){return void 0===t&&(t=0),new this.SchedulerAction(this,e).schedule(n,t)},e.now=function(){return Date.now()},e}()},6988:(e,t,n)=>{"use strict";n.d(t,{B7:()=>h,PJ:()=>l});var r=n(7272),i=n(9664),s=n(2968),o=n(9147),a=n(731),c=n(293),u=n(3089),l=function(e){function t(t){var n=e.call(this,t)||this;return n.destination=t,n}return r.C6(t,e),t}(s.v),h=function(e){function t(){var t=e.call(this)||this;return t.observers=[],t.closed=!1,t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return r.C6(t,e),t.prototype[u.D]=function(){return new l(this)},t.prototype.lift=function(e){var t=new d(this,this);return t.operator=e,t},t.prototype.next=function(e){if(this.closed)throw new a.P;if(!this.isStopped)for(var t=this.observers,n=t.length,r=t.slice(),i=0;i<n;i++)r[i].next(e)},t.prototype.error=function(e){if(this.closed)throw new a.P;this.hasError=!0,this.thrownError=e,this.isStopped=!0;for(var t=this.observers,n=t.length,r=t.slice(),i=0;i<n;i++)r[i].error(e);this.observers.length=0},t.prototype.complete=function(){if(this.closed)throw new a.P;this.isStopped=!0;for(var e=this.observers,t=e.length,n=e.slice(),r=0;r<t;r++)n[r].complete();this.observers.length=0},t.prototype.unsubscribe=function(){this.isStopped=!0,this.closed=!0,this.observers=null},t.prototype._trySubscribe=function(t){if(this.closed)throw new a.P;return e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){if(this.closed)throw new a.P;return this.hasError?(e.error(this.thrownError),o.y.EMPTY):this.isStopped?(e.complete(),o.y.EMPTY):(this.observers.push(e),new c.Y(this,e))},t.prototype.asObservable=function(){var e=new i.c;return e.source=this,e},t.create=function(e,t){return new d(e,t)},t}(i.c),d=function(e){function t(t,n){var r=e.call(this)||this;return r.destination=t,r.source=n,r}return r.C6(t,e),t.prototype.next=function(e){var t=this.destination;t&&t.next&&t.next(e)},t.prototype.error=function(e){var t=this.destination;t&&t.error&&this.destination.error(e)},t.prototype.complete=function(){var e=this.destination;e&&e.complete&&this.destination.complete()},t.prototype._subscribe=function(e){return this.source?this.source.subscribe(e):o.y.EMPTY},t}(h)},293:(e,t,n)=>{"use strict";n.d(t,{Y:()=>i});var r=n(7272),i=function(e){function t(t,n){var r=e.call(this)||this;return r.subject=t,r.subscriber=n,r.closed=!1,r}return r.C6(t,e),t.prototype.unsubscribe=function(){if(!this.closed){this.closed=!0;var e=this.subject,t=e.observers;if(this.subject=null,t&&0!==t.length&&!e.isStopped&&!e.closed){var n=t.indexOf(this.subscriber);-1!==n&&t.splice(n,1)}}},t}(n(9147).y)},2968:(e,t,n)=>{"use strict";n.d(t,{v:()=>l});var r=n(7272),i=n(9029),s=n(6708),o=n(9147),a=n(3089),c=n(1732),u=n(9199),l=function(e){function t(n,r,i){var o=e.call(this)||this;switch(o.syncErrorValue=null,o.syncErrorThrown=!1,o.syncErrorThrowable=!1,o.isStopped=!1,arguments.length){case 0:o.destination=s.I;break;case 1:if(!n){o.destination=s.I;break}if("object"==typeof n){n instanceof t?(o.syncErrorThrowable=n.syncErrorThrowable,o.destination=n,n.add(o)):(o.syncErrorThrowable=!0,o.destination=new h(o,n));break}default:o.syncErrorThrowable=!0,o.destination=new h(o,n,r,i)}return o}return r.C6(t,e),t.prototype[a.D]=function(){return this},t.create=function(e,n,r){var i=new t(e,n,r);return i.syncErrorThrowable=!1,i},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this))},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){this.destination.error(e),this.unsubscribe()},t.prototype._complete=function(){this.destination.complete(),this.unsubscribe()},t.prototype._unsubscribeAndRecycle=function(){var e=this._parentOrParents;return this._parentOrParents=null,this.unsubscribe(),this.closed=!1,this.isStopped=!1,this._parentOrParents=e,this},t}(o.y),h=function(e){function t(t,n,r,o){var a,c=e.call(this)||this;c._parentSubscriber=t;var u=c;return(0,i.T)(n)?a=n:n&&(a=n.next,r=n.error,o=n.complete,n!==s.I&&(u=Object.create(n),(0,i.T)(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.C6(t,e),t.prototype.next=function(e){if(!this.isStopped&&this._next){var t=this._parentSubscriber;c.$.useDeprecatedSynchronousErrorHandling&&t.syncErrorThrowable?this.__tryOrSetError(t,this._next,e)&&this.unsubscribe():this.__tryOrUnsub(this._next,e)}},t.prototype.error=function(e){if(!this.isStopped){var t=this._parentSubscriber,n=c.$.useDeprecatedSynchronousErrorHandling;if(this._error)n&&t.syncErrorThrowable?(this.__tryOrSetError(t,this._error,e),this.unsubscribe()):(this.__tryOrUnsub(this._error,e),this.unsubscribe());else if(t.syncErrorThrowable)n?(t.syncErrorValue=e,t.syncErrorThrown=!0):(0,u.T)(e),this.unsubscribe();else{if(this.unsubscribe(),n)throw e;(0,u.T)(e)}}},t.prototype.complete=function(){var e=this;if(!this.isStopped){var t=this._parentSubscriber;if(this._complete){var n=function(){return e._complete.call(e._context)};c.$.useDeprecatedSynchronousErrorHandling&&t.syncErrorThrowable?(this.__tryOrSetError(t,n),this.unsubscribe()):(this.__tryOrUnsub(n),this.unsubscribe())}else this.unsubscribe()}},t.prototype.__tryOrUnsub=function(e,t){try{e.call(this._context,t)}catch(e){if(this.unsubscribe(),c.$.useDeprecatedSynchronousErrorHandling)throw e;(0,u.T)(e)}},t.prototype.__tryOrSetError=function(e,t,n){if(!c.$.useDeprecatedSynchronousErrorHandling)throw new Error("bad call");try{t.call(this._context,n)}catch(t){return c.$.useDeprecatedSynchronousErrorHandling?(e.syncErrorValue=t,e.syncErrorThrown=!0,!0):((0,u.T)(t),!0)}return!1},t.prototype._unsubscribe=function(){var e=this._parentSubscriber;this._context=null,this._parentSubscriber=null,e.unsubscribe()},t}(l)},9147:(e,t,n)=>{"use strict";n.d(t,{y:()=>a});var r=n(252),i=n(806),s=n(9029),o=n(9857),a=function(){function e(e){this.closed=!1,this._parentOrParents=null,this._subscriptions=null,e&&(this._ctorUnsubscribe=!0,this._unsubscribe=e)}var t;return e.prototype.unsubscribe=function(){var t;if(!this.closed){var n=this,a=n._parentOrParents,u=n._ctorUnsubscribe,l=n._unsubscribe,h=n._subscriptions;if(this.closed=!0,this._parentOrParents=null,this._subscriptions=null,a instanceof e)a.remove(this);else if(null!==a)for(var d=0;d<a.length;++d)a[d].remove(this);if((0,s.T)(l)){u&&(this._unsubscribe=void 0);try{l.call(this)}catch(e){t=e instanceof o.Z?c(e.errors):[e]}}if((0,r.c)(h)){d=-1;for(var f=h.length;++d<f;){var p=h[d];if((0,i.G)(p))try{p.unsubscribe()}catch(e){t=t||[],e instanceof o.Z?t=t.concat(c(e.errors)):t.push(e)}}}if(t)throw new o.Z(t)}},e.prototype.add=function(t){var n=t;if(!t)return e.EMPTY;switch(typeof t){case"function":n=new e(t);case"object":if(n===this||n.closed||"function"!=typeof n.unsubscribe)return n;if(this.closed)return n.unsubscribe(),n;if(!(n instanceof e)){var r=n;(n=new e)._subscriptions=[r]}break;default:throw new Error("unrecognized teardown "+t+" added to Subscription.")}var i=n._parentOrParents;if(null===i)n._parentOrParents=this;else if(i instanceof e){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},e.prototype.remove=function(e){var t=this._subscriptions;if(t){var n=t.indexOf(e);-1!==n&&t.splice(n,1)}},e.EMPTY=((t=new e).closed=!0,t),e}();function c(e){return e.reduce((function(e,t){return e.concat(t instanceof o.Z?t.errors:t)}),[])}},1732:(e,t,n)=>{"use strict";n.d(t,{$:()=>i});var r=!1,i={Promise:void 0,set useDeprecatedSynchronousErrorHandling(e){e&&(new Error).stack,r=e},get useDeprecatedSynchronousErrorHandling(){return r}}},298:(e,t,n)=>{"use strict";n.d(t,{gn:()=>c,tS:()=>u,zA:()=>a});var r=n(7272),i=n(2968),s=n(9664),o=n(8777),a=function(e){function t(t){var n=e.call(this)||this;return n.parent=t,n}return r.C6(t,e),t.prototype._next=function(e){this.parent.notifyNext(e)},t.prototype._error=function(e){this.parent.notifyError(e),this.unsubscribe()},t.prototype._complete=function(){this.parent.notifyComplete(),this.unsubscribe()},t}(i.v),c=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r.C6(t,e),t.prototype.notifyNext=function(e){this.destination.next(e)},t.prototype.notifyError=function(e){this.destination.error(e)},t.prototype.notifyComplete=function(){this.destination.complete()},t}(i.v);function u(e,t){if(!t.closed){if(e instanceof s.c)return e.subscribe(t);var n;try{n=(0,o.i)(e)(t)}catch(e){t.error(e)}return n}}},4491:(e,t,n)=>{"use strict";n.d(t,{G:()=>c,f:()=>u});var r=n(7272),i=n(6988),s=n(9664),o=n(9147),a=n(1764),c=function(e){function t(t,n){var r=e.call(this)||this;return r.source=t,r.subjectFactory=n,r._refCount=0,r._isComplete=!1,r}return r.C6(t,e),t.prototype._subscribe=function(e){return this.getSubject().subscribe(e)},t.prototype.getSubject=function(){var e=this._subject;return e&&!e.isStopped||(this._subject=this.subjectFactory()),this._subject},t.prototype.connect=function(){var e=this._connection;return e||(this._isComplete=!1,(e=this._connection=new o.y).add(this.source.subscribe(new l(this.getSubject(),this))),e.closed&&(this._connection=null,e=o.y.EMPTY)),e},t.prototype.refCount=function(){return(0,a.B)()(this)},t}(s.c),u=function(){var e=c.prototype;return{operator:{value:null},_refCount:{value:0,writable:!0},_subject:{value:null,writable:!0},_connection:{value:null,writable:!0},_subscribe:{value:e._subscribe},_isComplete:{value:e._isComplete,writable:!0},getSubject:{value:e.getSubject},connect:{value:e.connect},refCount:{value:e.refCount}}}(),l=function(e){function t(t,n){var r=e.call(this,t)||this;return r.connectable=n,r}return r.C6(t,e),t.prototype._error=function(t){this._unsubscribe(),e.prototype._error.call(this,t)},t.prototype._complete=function(){this.connectable._isComplete=!0,this._unsubscribe(),e.prototype._complete.call(this)},t.prototype._unsubscribe=function(){var e=this.connectable;if(e){this.connectable=null;var t=e._connection;e._refCount=0,e._subject=null,e._connection=null,t&&t.unsubscribe()}},t}(i.PJ)},8890:(e,t,n)=>{"use strict";n.d(t,{ZS:()=>h,zV:()=>l});var r=n(7272),i=n(4576),s=n(252),o=n(7069),a=n(538),c=n(4601),u={};function l(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=void 0,r=void 0;return(0,i.m)(e[e.length-1])&&(r=e.pop()),"function"==typeof e[e.length-1]&&(n=e.pop()),1===e.length&&(0,s.c)(e[0])&&(e=e[0]),(0,c.c)(e,r).lift(new h(n))}var h=function(){function e(e){this.resultSelector=e}return e.prototype.call=function(e,t){return t.subscribe(new d(e,this.resultSelector))},e}(),d=function(e){function t(t,n){var r=e.call(this,t)||this;return r.resultSelector=n,r.active=0,r.values=[],r.observables=[],r}return r.C6(t,e),t.prototype._next=function(e){this.values.push(u),this.observables.push(e)},t.prototype._complete=function(){var e=this.observables,t=e.length;if(0===t)this.destination.complete();else{this.active=t,this.toRespond=t;for(var n=0;n<t;n++){var r=e[n];this.add((0,a.F)(this,r,void 0,n))}}},t.prototype.notifyComplete=function(e){0==(this.active-=1)&&this.destination.complete()},t.prototype.notifyNext=function(e,t,n){var r=this.values,i=r[n],s=this.toRespond?i===u?--this.toRespond:this.toRespond:0;r[n]=t,0===s&&(this.resultSelector?this._tryResultSelector(r):this.destination.next(r.slice()))},t.prototype._tryResultSelector=function(e){var t;try{t=this.resultSelector.apply(this,e)}catch(e){return void this.destination.error(e)}this.destination.next(t)},t}(o.E)},926:(e,t,n)=>{"use strict";n.d(t,{x:()=>s});var r=n(8927),i=n(7125);function s(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return(0,i.K)()(r.of.apply(void 0,e))}},560:(e,t,n)=>{"use strict";n.d(t,{v:()=>o});var r=n(9664),i=n(7046),s=n(4833);function o(e){return new r.c((function(t){var n;try{n=e()}catch(e){return void t.error(e)}return(n?(0,i.H)(n):(0,s.I)()).subscribe(t)}))}},4833:(e,t,n)=>{"use strict";n.d(t,{I:()=>s,w:()=>i});var r=n(9664),i=new r.c((function(e){return e.complete()}));function s(e){return e?function(e){return new r.c((function(t){return e.schedule((function(){return t.complete()}))}))}(e):i}},7046:(e,t,n)=>{"use strict";n.d(t,{H:()=>o});var r=n(9664),i=n(8777),s=n(1413);function o(e,t){return t?(0,s.c)(e,t):e instanceof r.c?e:new r.c((0,i.i)(e))}},4601:(e,t,n)=>{"use strict";n.d(t,{c:()=>o});var r=n(9664),i=n(6239),s=n(5890);function o(e,t){return t?(0,s.V)(e,t):new r.c((0,i.v)(e))}},3767:(e,t,n)=>{"use strict";n.d(t,{h:()=>a});var r=n(9664),i=n(4576),s=n(6723),o=n(4601);function a(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Number.POSITIVE_INFINITY,a=null,c=e[e.length-1];return(0,i.m)(c)?(a=e.pop(),e.length>1&&"number"==typeof e[e.length-1]&&(n=e.pop())):"number"==typeof c&&(n=e.pop()),null===a&&1===e.length&&e[0]instanceof r.c?e[0]:(0,s.U)(n)((0,o.c)(e,a))}},8927:(e,t,n)=>{"use strict";n.d(t,{of:()=>o});var r=n(4576),i=n(4601),s=n(5890);function o(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e[e.length-1];return(0,r.m)(n)?(e.pop(),(0,s.V)(e,n)):(0,i.c)(e)}},8071:(e,t,n)=>{"use strict";n.d(t,{O4:()=>c});var r=n(7272),i=n(252),s=n(4601),o=n(7069),a=n(538);function c(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(1===e.length){if(!(0,i.c)(e[0]))return e[0];e=e[0]}return(0,s.c)(e,void 0).lift(new u)}var u=function(){function e(){}return e.prototype.call=function(e,t){return t.subscribe(new l(e))},e}(),l=function(e){function t(t){var n=e.call(this,t)||this;return n.hasFirst=!1,n.observables=[],n.subscriptions=[],n}return r.C6(t,e),t.prototype._next=function(e){this.observables.push(e)},t.prototype._complete=function(){var e=this.observables,t=e.length;if(0===t)this.destination.complete();else{for(var n=0;n<t&&!this.hasFirst;n++){var r=e[n],i=(0,a.F)(this,r,void 0,n);this.subscriptions&&this.subscriptions.push(i),this.add(i)}this.observables=null}},t.prototype.notifyNext=function(e,t,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(t)},t}(o.E)},7404:(e,t,n)=>{"use strict";n.d(t,{$:()=>i});var r=n(9664);function i(e,t){return t?new r.c((function(n){return t.schedule(s,0,{error:e,subscriber:n})})):new r.c((function(t){return t.error(e)}))}function s(e){var t=e.error;e.subscriber.error(t)}},1133:(e,t,n)=>{"use strict";n.d(t,{O:()=>a});var r=n(9664),i=n(6346),s=n(6290),o=n(4576);function a(e,t,n){void 0===e&&(e=0);var a=-1;return(0,s.k)(t)?a=Number(t)<1?1:Number(t):(0,o.m)(t)&&(n=t),(0,o.m)(n)||(n=i.b),new r.c((function(t){var r=(0,s.k)(e)?e:+e-n.now();return n.schedule(c,r,{index:0,period:a,subscriber:t})}))}function c(e){var t=e.index,n=e.period,r=e.subscriber;if(r.next(t),!r.closed){if(-1===n)return r.complete();e.index=t+1,this.schedule(e,n)}}},4219:(e,t,n)=>{"use strict";n.d(t,{ee:()=>l,yU:()=>u});var r=n(7272),i=n(4601),s=n(252),o=n(2968),a=n(3991),c=n(298);function u(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e[e.length-1];return"function"==typeof n&&e.pop(),(0,i.c)(e,void 0).lift(new l(n))}var l=function(){function e(e){this.resultSelector=e}return e.prototype.call=function(e,t){return t.subscribe(new h(e,this.resultSelector))},e}(),h=function(e){function t(t,n,r){void 0===r&&(r=Object.create(null));var i=e.call(this,t)||this;return i.resultSelector=n,i.iterators=[],i.active=0,i.resultSelector="function"==typeof n?n:void 0,i}return r.C6(t,e),t.prototype._next=function(e){var t=this.iterators;(0,s.c)(e)?t.push(new f(e)):"function"==typeof e[a.lJ]?t.push(new d(e[a.lJ]())):t.push(new p(this.destination,this,e))},t.prototype._complete=function(){var e=this.iterators,t=e.length;if(this.unsubscribe(),0!==t){this.active=t;for(var n=0;n<t;n++){var r=e[n];r.stillUnsubscribed?this.destination.add(r.subscribe()):this.active--}}else this.destination.complete()},t.prototype.notifyInactive=function(){this.active--,0===this.active&&this.destination.complete()},t.prototype.checkIterators=function(){for(var e=this.iterators,t=e.length,n=this.destination,r=0;r<t;r++)if("function"==typeof(o=e[r]).hasValue&&!o.hasValue())return;var i=!1,s=[];for(r=0;r<t;r++){var o,a=(o=e[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()},t.prototype._tryresultSelector=function(e){var t;try{t=this.resultSelector.apply(this,e)}catch(e){return void this.destination.error(e)}this.destination.next(t)},t}(o.v),d=function(){function e(e){this.iterator=e,this.nextResult=e.next()}return e.prototype.hasValue=function(){return!0},e.prototype.next=function(){var e=this.nextResult;return this.nextResult=this.iterator.next(),e},e.prototype.hasCompleted=function(){var e=this.nextResult;return Boolean(e&&e.done)},e}(),f=function(){function e(e){this.array=e,this.index=0,this.length=0,this.length=e.length}return e.prototype[a.lJ]=function(){return this},e.prototype.next=function(e){var t=this.index++,n=this.array;return t<this.length?{value:n[t],done:!1}:{value:null,done:!0}},e.prototype.hasValue=function(){return this.array.length>this.index},e.prototype.hasCompleted=function(){return this.array.length===this.index},e}(),p=function(e){function t(t,n,r){var i=e.call(this,t)||this;return i.parent=n,i.observable=r,i.stillUnsubscribed=!0,i.buffer=[],i.isComplete=!1,i}return r.C6(t,e),t.prototype[a.lJ]=function(){return this},t.prototype.next=function(){var e=this.buffer;return 0===e.length&&this.isComplete?{value:null,done:!0}:{value:e.shift(),done:!1}},t.prototype.hasValue=function(){return this.buffer.length>0},t.prototype.hasCompleted=function(){return 0===this.buffer.length&&this.isComplete},t.prototype.notifyComplete=function(){this.buffer.length>0?(this.isComplete=!0,this.parent.notifyInactive()):this.destination.complete()},t.prototype.notifyNext=function(e){this.buffer.push(e),this.parent.checkIterators()},t.prototype.subscribe=function(){return(0,c.tS)(this.observable,new c.zA(this))},t}(c.gn)},7125:(e,t,n)=>{"use strict";n.d(t,{K:()=>i});var r=n(6723);function i(){return(0,r.U)(1)}},9610:(e,t,n)=>{"use strict";n.d(t,{p:()=>s});var r=n(7272),i=n(2968);function s(e,t){return function(n){return n.lift(new o(e,t))}}var o=function(){function e(e,t){this.predicate=e,this.thisArg=t}return e.prototype.call=function(e,t){return t.subscribe(new a(e,this.predicate,this.thisArg))},e}(),a=function(e){function t(t,n,r){var i=e.call(this,t)||this;return i.predicate=n,i.thisArg=r,i.count=0,i}return r.C6(t,e),t.prototype._next=function(e){var t;try{t=this.predicate.call(this.thisArg,e,this.count++)}catch(e){return void this.destination.error(e)}t&&this.destination.next(e)},t}(i.v)},3108:(e,t,n)=>{"use strict";n.d(t,{$:()=>c,k:()=>d});var r=n(7272),i=n(2968),s=n(9147),o=n(9664),a=n(6988);function c(e,t,n,r){return function(i){return i.lift(new u(e,t,n,r))}}var u=function(){function e(e,t,n,r){this.keySelector=e,this.elementSelector=t,this.durationSelector=n,this.subjectSelector=r}return e.prototype.call=function(e,t){return t.subscribe(new l(e,this.keySelector,this.elementSelector,this.durationSelector,this.subjectSelector))},e}(),l=function(e){function t(t,n,r,i,s){var o=e.call(this,t)||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.C6(t,e),t.prototype._next=function(e){var t;try{t=this.keySelector(e)}catch(e){return void this.error(e)}this._group(e,t)},t.prototype._group=function(e,t){var n=this.groups;n||(n=this.groups=new Map);var r,i=n.get(t);if(this.elementSelector)try{r=this.elementSelector(e)}catch(e){this.error(e)}else r=e;if(!i){i=this.subjectSelector?this.subjectSelector():new a.B7,n.set(t,i);var s=new d(t,i,this);if(this.destination.next(s),this.durationSelector){var o=void 0;try{o=this.durationSelector(new d(t,i))}catch(e){return void this.error(e)}this.add(o.subscribe(new h(t,i,this)))}}i.closed||i.next(r)},t.prototype._error=function(e){var t=this.groups;t&&(t.forEach((function(t,n){t.error(e)})),t.clear()),this.destination.error(e)},t.prototype._complete=function(){var e=this.groups;e&&(e.forEach((function(e,t){e.complete()})),e.clear()),this.destination.complete()},t.prototype.removeGroup=function(e){this.groups.delete(e)},t.prototype.unsubscribe=function(){this.closed||(this.attemptedToUnsubscribe=!0,0===this.count&&e.prototype.unsubscribe.call(this))},t}(i.v),h=function(e){function t(t,n,r){var i=e.call(this,n)||this;return i.key=t,i.group=n,i.parent=r,i}return r.C6(t,e),t.prototype._next=function(e){this.complete()},t.prototype._unsubscribe=function(){var e=this.parent,t=this.key;this.key=this.parent=null,e&&e.removeGroup(t)},t}(i.v),d=function(e){function t(t,n,r){var i=e.call(this)||this;return i.key=t,i.groupSubject=n,i.refCountSubscription=r,i}return r.C6(t,e),t.prototype._subscribe=function(e){var t=new s.y,n=this.refCountSubscription,r=this.groupSubject;return n&&!n.closed&&t.add(new f(n)),t.add(r.subscribe(e)),t},t}(o.c),f=function(e){function t(t){var n=e.call(this)||this;return n.parent=t,t.count++,n}return r.C6(t,e),t.prototype.unsubscribe=function(){var t=this.parent;t.closed||this.closed||(e.prototype.unsubscribe.call(this),t.count-=1,0===t.count&&t.attemptedToUnsubscribe&&t.unsubscribe())},t}(s.y)},8100:(e,t,n)=>{"use strict";n.d(t,{T:()=>s});var r=n(7272),i=n(2968);function s(e,t){return function(n){if("function"!=typeof e)throw new TypeError("argument is not a function. Are you looking for `mapTo()`?");return n.lift(new o(e,t))}}var o=function(){function e(e,t){this.project=e,this.thisArg=t}return e.prototype.call=function(e,t){return t.subscribe(new a(e,this.project,this.thisArg))},e}(),a=function(e){function t(t,n,r){var i=e.call(this,t)||this;return i.project=n,i.count=0,i.thisArg=r||i,i}return r.C6(t,e),t.prototype._next=function(e){var t;try{t=this.project.call(this.thisArg,e,this.count++)}catch(e){return void this.destination.error(e)}this.destination.next(t)},t}(i.v)},6723:(e,t,n)=>{"use strict";n.d(t,{U:()=>s});var r=n(4490),i=n(1015);function s(e){return void 0===e&&(e=Number.POSITIVE_INFINITY),(0,r.ZZ)(i.D,e)}},4490:(e,t,n)=>{"use strict";n.d(t,{ZZ:()=>a,qI:()=>l});var r=n(7272),i=n(8100),s=n(7046),o=n(298);function a(e,t,n){return void 0===n&&(n=Number.POSITIVE_INFINITY),"function"==typeof t?function(r){return r.pipe(a((function(n,r){return(0,s.H)(e(n,r)).pipe((0,i.T)((function(e,i){return t(n,e,r,i)})))}),n))}:("number"==typeof t&&(n=t),function(t){return t.lift(new c(e,n))})}var c=function(){function e(e,t){void 0===t&&(t=Number.POSITIVE_INFINITY),this.project=e,this.concurrent=t}return e.prototype.call=function(e,t){return t.subscribe(new u(e,this.project,this.concurrent))},e}(),u=function(e){function t(t,n,r){void 0===r&&(r=Number.POSITIVE_INFINITY);var i=e.call(this,t)||this;return i.project=n,i.concurrent=r,i.hasCompleted=!1,i.buffer=[],i.active=0,i.index=0,i}return r.C6(t,e),t.prototype._next=function(e){this.active<this.concurrent?this._tryNext(e):this.buffer.push(e)},t.prototype._tryNext=function(e){var t,n=this.index++;try{t=this.project(e,n)}catch(e){return void this.destination.error(e)}this.active++,this._innerSub(t)},t.prototype._innerSub=function(e){var t=new o.zA(this),n=this.destination;n.add(t);var r=(0,o.tS)(e,t);r!==t&&n.add(r)},t.prototype._complete=function(){this.hasCompleted=!0,0===this.active&&0===this.buffer.length&&this.destination.complete(),this.unsubscribe()},t.prototype.notifyNext=function(e){this.destination.next(e)},t.prototype.notifyComplete=function(){var e=this.buffer;this.active--,e.length>0?this._next(e.shift()):0===this.active&&this.hasCompleted&&this.destination.complete()},t}(o.gn),l=a},3947:(e,t,n)=>{"use strict";n.d(t,{QE:()=>o,YZ:()=>c});var r=n(7272),i=n(2968),s=n(2281);function o(e,t){return void 0===t&&(t=0),function(n){return n.lift(new a(e,t))}}var a=function(){function e(e,t){void 0===t&&(t=0),this.scheduler=e,this.delay=t}return e.prototype.call=function(e,t){return t.subscribe(new c(e,this.scheduler,this.delay))},e}(),c=function(e){function t(t,n,r){void 0===r&&(r=0);var i=e.call(this,t)||this;return i.scheduler=n,i.delay=r,i}return r.C6(t,e),t.dispatch=function(e){var t=e.notification,n=e.destination;t.observe(n),this.unsubscribe()},t.prototype.scheduleMessage=function(e){this.destination.add(this.scheduler.schedule(t.dispatch,this.delay,new u(e,this.destination)))},t.prototype._next=function(e){this.scheduleMessage(s.E.createNext(e))},t.prototype._error=function(e){this.scheduleMessage(s.E.createError(e)),this.unsubscribe()},t.prototype._complete=function(){this.scheduleMessage(s.E.createComplete()),this.unsubscribe()},t}(i.v),u=function(){return function(e,t){this.notification=e,this.destination=t}}()},1764:(e,t,n)=>{"use strict";n.d(t,{B:()=>s});var r=n(7272),i=n(2968);function s(){return function(e){return e.lift(new o(e))}}var o=function(){function e(e){this.connectable=e}return e.prototype.call=function(e,t){var n=this.connectable;n._refCount++;var r=new a(e,n),i=t.subscribe(r);return r.closed||(r.connection=n.connect()),i},e}(),a=function(e){function t(t,n){var r=e.call(this,t)||this;return r.connectable=n,r}return r.C6(t,e),t.prototype._unsubscribe=function(){var e=this.connectable;if(e){this.connectable=null;var t=e._refCount;if(t<=0)this.connection=null;else if(e._refCount=t-1,t>1)this.connection=null;else{var n=this.connection,r=e._connection;this.connection=null,!r||n&&r!==n||r.unsubscribe()}}else this.connection=null},t}(i.v)},5890:(e,t,n)=>{"use strict";n.d(t,{V:()=>s});var r=n(9664),i=n(9147);function s(e,t){return new r.c((function(n){var r=new i.y,s=0;return r.add(t.schedule((function(){s!==e.length?(n.next(e[s++]),n.closed||r.add(this.schedule())):n.complete()}))),r}))}},1413:(e,t,n)=>{"use strict";n.d(t,{c:()=>l});var r=n(9664),i=n(9147),s=n(3656),o=n(5890),a=n(3991),c=n(1164),u=n(9923);function l(e,t){if(null!=e){if(function(e){return e&&"function"==typeof e[s.s]}(e))return function(e,t){return new r.c((function(n){var r=new i.y;return r.add(t.schedule((function(){var i=e[s.s]();r.add(i.subscribe({next:function(e){r.add(t.schedule((function(){return n.next(e)})))},error:function(e){r.add(t.schedule((function(){return n.error(e)})))},complete:function(){r.add(t.schedule((function(){return n.complete()})))}}))}))),r}))}(e,t);if((0,c.y)(e))return function(e,t){return new r.c((function(n){var r=new i.y;return r.add(t.schedule((function(){return e.then((function(e){r.add(t.schedule((function(){n.next(e),r.add(t.schedule((function(){return n.complete()})))})))}),(function(e){r.add(t.schedule((function(){return n.error(e)})))}))}))),r}))}(e,t);if((0,u.X)(e))return(0,o.V)(e,t);if(function(e){return e&&"function"==typeof e[a.lJ]}(e)||"string"==typeof e)return function(e,t){if(!e)throw new Error("Iterable cannot be null");return new r.c((function(n){var r,s=new i.y;return s.add((function(){r&&"function"==typeof r.return&&r.return()})),s.add(t.schedule((function(){r=e[a.lJ](),s.add(t.schedule((function(){if(!n.closed){var e,t;try{var i=r.next();e=i.value,t=i.done}catch(e){return void n.error(e)}t?n.complete():(n.next(e),this.schedule())}})))}))),s}))}(e,t)}throw new TypeError((null!==e&&typeof e||e)+" is not observable")}},6027:(e,t,n)=>{"use strict";n.d(t,{R:()=>i});var r=n(7272),i=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.scheduler=t,r.work=n,r.pending=!1,r}return r.C6(t,e),t.prototype.schedule=function(e,t){if(void 0===t&&(t=0),this.closed)return this;this.state=e;var n=this.id,r=this.scheduler;return null!=n&&(this.id=this.recycleAsyncId(r,n,t)),this.pending=!0,this.delay=t,this.id=this.id||this.requestAsyncId(r,this.id,t),this},t.prototype.requestAsyncId=function(e,t,n){return void 0===n&&(n=0),setInterval(e.flush.bind(e,this),n)},t.prototype.recycleAsyncId=function(e,t,n){if(void 0===n&&(n=0),null!==n&&this.delay===n&&!1===this.pending)return t;clearInterval(t)},t.prototype.execute=function(e,t){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var n=this._execute(e,t);if(n)return n;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,t){var n=!1,r=void 0;try{this.work(e)}catch(e){n=!0,r=!!e&&e||new Error(e)}if(n)return this.unsubscribe(),r},t.prototype._unsubscribe=function(){var e=this.id,t=this.scheduler,n=t.actions,r=n.indexOf(this);this.work=null,this.state=null,this.pending=!1,this.scheduler=null,-1!==r&&n.splice(r,1),null!=e&&(this.id=this.recycleAsyncId(t,e,null)),this.delay=null},t}(function(e){function t(t,n){return e.call(this)||this}return r.C6(t,e),t.prototype.schedule=function(e,t){return void 0===t&&(t=0),this},t}(n(9147).y))},4881:(e,t,n)=>{"use strict";n.d(t,{q:()=>s});var r=n(7272),i=n(957),s=function(e){function t(n,r){void 0===r&&(r=i._.now);var s=e.call(this,n,(function(){return t.delegate&&t.delegate!==s?t.delegate.now():r()}))||this;return s.actions=[],s.active=!1,s.scheduled=void 0,s}return r.C6(t,e),t.prototype.schedule=function(n,r,i){return void 0===r&&(r=0),t.delegate&&t.delegate!==this?t.delegate.schedule(n,r,i):e.prototype.schedule.call(this,n,r,i)},t.prototype.flush=function(e){var t=this.actions;if(this.active)t.push(e);else{var n;this.active=!0;do{if(n=e.execute(e.state,e.delay))break}while(e=t.shift());if(this.active=!1,n){for(;e=t.shift();)e.unsubscribe();throw n}}},t}(i._)},9081:(e,t,n)=>{"use strict";n.d(t,{I:()=>l,$:()=>u});var r=n(7272),i=1,s=function(){return Promise.resolve()}(),o={};function a(e){return e in o&&(delete o[e],!0)}var c=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.scheduler=t,r.work=n,r}return r.C6(t,e),t.prototype.requestAsyncId=function(t,n,r){return void 0===r&&(r=0),null!==r&&r>0?e.prototype.requestAsyncId.call(this,t,n,r):(t.actions.push(this),t.scheduled||(t.scheduled=(c=t.flush.bind(t,null),u=i++,o[u]=!0,s.then((function(){return a(u)&&c()})),u)));var c,u},t.prototype.recycleAsyncId=function(t,n,r){if(void 0===r&&(r=0),null!==r&&r>0||null===r&&this.delay>0)return e.prototype.recycleAsyncId.call(this,t,n,r);0===t.actions.length&&(a(n),t.scheduled=void 0)},t}(n(6027).R),u=new(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r.C6(t,e),t.prototype.flush=function(e){this.active=!0,this.scheduled=void 0;var t,n=this.actions,r=-1,i=n.length;e=e||n.shift();do{if(t=e.execute(e.state,e.delay))break}while(++r<i&&(e=n.shift()));if(this.active=!1,t){for(;++r<i&&(e=n.shift());)e.unsubscribe();throw t}},t}(n(4881).q))(c),l=u},6346:(e,t,n)=>{"use strict";n.d(t,{E:()=>i,b:()=>s});var r=n(6027),i=new(n(4881).q)(r.R),s=i},464:(e,t,n)=>{"use strict";n.d(t,{g:()=>o,T:()=>s});var r=n(7272),i=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.scheduler=t,r.work=n,r}return r.C6(t,e),t.prototype.schedule=function(t,n){return void 0===n&&(n=0),n>0?e.prototype.schedule.call(this,t,n):(this.delay=n,this.state=t,this.scheduler.flush(this),this)},t.prototype.execute=function(t,n){return n>0||this.closed?e.prototype.execute.call(this,t,n):this._execute(t,n)},t.prototype.requestAsyncId=function(t,n,r){return void 0===r&&(r=0),null!==r&&r>0||null===r&&this.delay>0?e.prototype.requestAsyncId.call(this,t,n,r):t.flush(this)},t}(n(6027).R),s=new(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r.C6(t,e),t}(n(4881).q))(i),o=s},3991:(e,t,n)=>{"use strict";function r(){return"function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator"}n.d(t,{lJ:()=>i});var i=r()},3656:(e,t,n)=>{"use strict";n.d(t,{s:()=>r});var r=function(){return"function"==typeof Symbol&&Symbol.observable||"@@observable"}()},3089:(e,t,n)=>{"use strict";n.d(t,{D:()=>r});var r=function(){return"function"==typeof Symbol?Symbol("rxSubscriber"):"@@rxSubscriber_"+Math.random()}()},692:(e,t,n)=>{"use strict";n.d(t,{k:()=>r});var r=function(){function e(){return Error.call(this),this.message="argument out of range",this.name="ArgumentOutOfRangeError",this}return e.prototype=Object.create(Error.prototype),e}()},3700:(e,t,n)=>{"use strict";n.d(t,{G:()=>r});var r=function(){function e(){return Error.call(this),this.message="no elements in sequence",this.name="EmptyError",this}return e.prototype=Object.create(Error.prototype),e}()},731:(e,t,n)=>{"use strict";n.d(t,{P:()=>r});var r=function(){function e(){return Error.call(this),this.message="object unsubscribed",this.name="ObjectUnsubscribedError",this}return e.prototype=Object.create(Error.prototype),e}()},34:(e,t,n)=>{"use strict";n.d(t,{M:()=>r});var r=function(){function e(){return Error.call(this),this.message="Timeout has occurred",this.name="TimeoutError",this}return e.prototype=Object.create(Error.prototype),e}()},9857:(e,t,n)=>{"use strict";n.d(t,{Z:()=>r});var r=function(){function e(e){return Error.call(this),this.message=e?e.length+" errors occurred during unsubscription:\n"+e.map((function(e,t){return t+1+") "+e.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=e,this}return e.prototype=Object.create(Error.prototype),e}()},1075:(e,t,n)=>{"use strict";n.d(t,{H:()=>i});var r=n(2968);function i(e){for(;e;){var t=e,n=t.closed,i=t.destination,s=t.isStopped;if(n||s)return!1;e=i&&i instanceof r.v?i:null}return!0}},9199:(e,t,n)=>{"use strict";function r(e){setTimeout((function(){throw e}),0)}n.d(t,{T:()=>r})},1015:(e,t,n)=>{"use strict";function r(e){return e}n.d(t,{D:()=>r})},252:(e,t,n)=>{"use strict";n.d(t,{c:()=>r});var r=function(){return Array.isArray||function(e){return e&&"number"==typeof e.length}}()},9923:(e,t,n)=>{"use strict";n.d(t,{X:()=>r});var r=function(e){return e&&"number"==typeof e.length&&"function"!=typeof e}},9029:(e,t,n)=>{"use strict";function r(e){return"function"==typeof e}n.d(t,{T:()=>r})},6290:(e,t,n)=>{"use strict";n.d(t,{k:()=>i});var r=n(252);function i(e){return!(0,r.c)(e)&&e-parseFloat(e)+1>=0}},806:(e,t,n)=>{"use strict";function r(e){return null!==e&&"object"==typeof e}n.d(t,{G:()=>r})},1164:(e,t,n)=>{"use strict";function r(e){return!!e&&"function"!=typeof e.subscribe&&"function"==typeof e.then}n.d(t,{y:()=>r})},4576:(e,t,n)=>{"use strict";function r(e){return e&&"function"==typeof e.schedule}n.d(t,{m:()=>r})},1193:(e,t,n)=>{"use strict";function r(){}n.d(t,{l:()=>r})},3428:(e,t,n)=>{"use strict";function r(e,t){function n(){return!n.pred.apply(n.thisArg,arguments)}return n.pred=e,n.thisArg=t,n}n.d(t,{A:()=>r})},6833:(e,t,n)=>{"use strict";n.d(t,{F:()=>i,m:()=>s});var r=n(1015);function i(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return s(e)}function s(e){return 0===e.length?r.D:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)}}},8777:(e,t,n)=>{"use strict";n.d(t,{i:()=>l});var r=n(6239),i=n(9199),s=n(3991),o=n(3656),a=n(9923),c=n(1164),u=n(806),l=function(e){if(e&&"function"==typeof e[o.s])return l=e,function(e){var t=l[o.s]();if("function"!=typeof t.subscribe)throw new TypeError("Provided object does not correctly implement Symbol.observable");return t.subscribe(e)};if((0,a.X)(e))return(0,r.v)(e);if((0,c.y)(e))return n=e,function(e){return n.then((function(t){e.closed||(e.next(t),e.complete())}),(function(t){return e.error(t)})).then(null,i.T),e};if(e&&"function"==typeof e[s.lJ])return t=e,function(e){for(var n=t[s.lJ]();;){var r=void 0;try{r=n.next()}catch(t){return e.error(t),e}if(r.done){e.complete();break}if(e.next(r.value),e.closed)break}return"function"==typeof n.return&&e.add((function(){n.return&&n.return()})),e};var t,n,l,h=(0,u.G)(e)?"an invalid object":"'"+e+"'";throw new TypeError("You provided "+h+" where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.")}},6239:(e,t,n)=>{"use strict";n.d(t,{v:()=>r});var r=function(e){return function(t){for(var n=0,r=e.length;n<r&&!t.closed;n++)t.next(e[n]);t.complete()}}},538:(e,t,n)=>{"use strict";n.d(t,{F:()=>a});var r=n(7272),i=function(e){function t(t,n,r){var i=e.call(this)||this;return i.parent=t,i.outerValue=n,i.outerIndex=r,i.index=0,i}return r.C6(t,e),t.prototype._next=function(e){this.parent.notifyNext(this.outerValue,e,this.outerIndex,this.index++,this)},t.prototype._error=function(e){this.parent.notifyError(e,this),this.unsubscribe()},t.prototype._complete=function(){this.parent.notifyComplete(this),this.unsubscribe()},t}(n(2968).v),s=n(8777),o=n(9664);function a(e,t,n,r,a){if(void 0===a&&(a=new i(e,n,r)),!a.closed)return t instanceof o.c?t.subscribe(a):(0,s.i)(t)(a)}},5758:(e,t,n)=>{"use strict";n.r(t),n.d(t,{audit:()=>s,auditTime:()=>l,buffer:()=>h,bufferCount:()=>m,bufferTime:()=>w,bufferToggle:()=>N,bufferWhen:()=>R,catchError:()=>M,combineAll:()=>j,combineLatest:()=>z,concat:()=>K,concatAll:()=>W.K,concatMap:()=>H,concatMapTo:()=>Q,count:()=>J,debounce:()=>Z,debounceTime:()=>ne,defaultIfEmpty:()=>oe,delay:()=>he,delayWhen:()=>ge,dematerialize:()=>_e,distinct:()=>Te,distinctUntilChanged:()=>Ae,distinctUntilKeyChanged:()=>Ne,elementAt:()=>qe,endWith:()=>Ge,every:()=>Ke,exhaust:()=>He,exhaustMap:()=>Xe,expand:()=>tt,filter:()=>De.p,finalize:()=>it,find:()=>at,findIndex:()=>lt,first:()=>dt,flatMap:()=>$.qI,groupBy:()=>ft.$,ignoreElements:()=>pt,isEmpty:()=>yt,last:()=>Et,map:()=>Ye.T,mapTo:()=>Tt,materialize:()=>At,max:()=>Lt,merge:()=>Ft,mergeAll:()=>Vt.U,mergeMap:()=>$.ZZ,mergeMapTo:()=>Ut,mergeScan:()=>jt,min:()=>zt,multicast:()=>Kt,observeOn:()=>$t.QE,onErrorResumeNext:()=>Ht,pairwise:()=>Yt,partition:()=>tn,pluck:()=>nn,publish:()=>sn,publishBehavior:()=>an,publishLast:()=>un,publishReplay:()=>hn,race:()=>fn,reduce:()=>Pt,refCount:()=>Cn.B,repeat:()=>pn,repeatWhen:()=>yn,retry:()=>wn,retryWhen:()=>En,sample:()=>An,sampleTime:()=>Nn,scan:()=>Nt,sequenceEqual:()=>Pn,share:()=>Un,shareReplay:()=>jn,single:()=>Bn,skip:()=>Gn,skipLast:()=>$n,skipUntil:()=>Jn,skipWhile:()=>Zn,startWith:()=>nr,subscribeOn:()=>or,switchAll:()=>hr,switchMap:()=>cr,switchMapTo:()=>dr,take:()=>Ue,takeLast:()=>wt,takeUntil:()=>fr,takeWhile:()=>gr,tap:()=>_r,throttle:()=>Sr,throttleTime:()=>xr,throwIfEmpty:()=>Pe,timeInterval:()=>Rr,timeout:()=>jr,timeoutWith:()=>Mr,timestamp:()=>Br,toArray:()=>Gr,window:()=>Kr,windowCount:()=>Hr,windowTime:()=>Yr,windowToggle:()=>ii,windowWhen:()=>ai,withLatestFrom:()=>li,zip:()=>pi,zipAll:()=>mi});var r=n(7272),i=n(298);function s(e){return function(t){return t.lift(new o(e))}}var o=function(){function e(e){this.durationSelector=e}return e.prototype.call=function(e,t){return t.subscribe(new a(e,this.durationSelector))},e}(),a=function(e){function t(t,n){var r=e.call(this,t)||this;return r.durationSelector=n,r.hasValue=!1,r}return r.C6(t,e),t.prototype._next=function(e){if(this.value=e,this.hasValue=!0,!this.throttled){var t=void 0;try{t=(0,this.durationSelector)(e)}catch(e){return this.destination.error(e)}var n=(0,i.tS)(t,new i.zA(this));!n||n.closed?this.clearThrottle():this.add(this.throttled=n)}},t.prototype.clearThrottle=function(){var e=this,t=e.value,n=e.hasValue,r=e.throttled;r&&(this.remove(r),this.throttled=void 0,r.unsubscribe()),n&&(this.value=void 0,this.hasValue=!1,this.destination.next(t))},t.prototype.notifyNext=function(){this.clearThrottle()},t.prototype.notifyComplete=function(){this.clearThrottle()},t}(i.gn),c=n(6346),u=n(1133);function l(e,t){return void 0===t&&(t=c.b),s((function(){return(0,u.O)(e,t)}))}function h(e){return function(t){return t.lift(new d(e))}}var d=function(){function e(e){this.closingNotifier=e}return e.prototype.call=function(e,t){return t.subscribe(new f(e,this.closingNotifier))},e}(),f=function(e){function t(t,n){var r=e.call(this,t)||this;return r.buffer=[],r.add((0,i.tS)(n,new i.zA(r))),r}return r.C6(t,e),t.prototype._next=function(e){this.buffer.push(e)},t.prototype.notifyNext=function(){var e=this.buffer;this.buffer=[],this.destination.next(e)},t}(i.gn),p=n(2968);function m(e,t){return void 0===t&&(t=null),function(n){return n.lift(new g(e,t))}}var g=function(){function e(e,t){this.bufferSize=e,this.startBufferEvery=t,this.subscriberClass=t&&e!==t?v:y}return e.prototype.call=function(e,t){return t.subscribe(new this.subscriberClass(e,this.bufferSize,this.startBufferEvery))},e}(),y=function(e){function t(t,n){var r=e.call(this,t)||this;return r.bufferSize=n,r.buffer=[],r}return r.C6(t,e),t.prototype._next=function(e){var t=this.buffer;t.push(e),t.length==this.bufferSize&&(this.destination.next(t),this.buffer=[])},t.prototype._complete=function(){var t=this.buffer;t.length>0&&this.destination.next(t),e.prototype._complete.call(this)},t}(p.v),v=function(e){function t(t,n,r){var i=e.call(this,t)||this;return i.bufferSize=n,i.startBufferEvery=r,i.buffers=[],i.count=0,i}return r.C6(t,e),t.prototype._next=function(e){var t=this,n=t.bufferSize,r=t.startBufferEvery,i=t.buffers,s=t.count;this.count++,s%r==0&&i.push([]);for(var o=i.length;o--;){var a=i[o];a.push(e),a.length===n&&(i.splice(o,1),this.destination.next(a))}},t.prototype._complete=function(){for(var t=this.buffers,n=this.destination;t.length>0;){var r=t.shift();r.length>0&&n.next(r)}e.prototype._complete.call(this)},t}(p.v),b=n(4576);function w(e){var t=arguments.length,n=c.b;(0,b.m)(arguments[arguments.length-1])&&(n=arguments[arguments.length-1],t--);var r=null;t>=2&&(r=arguments[1]);var i=Number.POSITIVE_INFINITY;return t>=3&&(i=arguments[2]),function(t){return t.lift(new _(e,r,i,n))}}var _=function(){function e(e,t,n,r){this.bufferTimeSpan=e,this.bufferCreationInterval=t,this.maxBufferSize=n,this.scheduler=r}return e.prototype.call=function(e,t){return t.subscribe(new E(e,this.bufferTimeSpan,this.bufferCreationInterval,this.maxBufferSize,this.scheduler))},e}(),I=function(){return function(){this.buffer=[]}}(),E=function(e){function t(t,n,r,i,s){var o=e.call(this,t)||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(T,n,c))}else{var u={subscriber:o,context:a},l={bufferTimeSpan:n,bufferCreationInterval:r,subscriber:o,scheduler:s};o.add(a.closeAction=s.schedule(C,n,u)),o.add(s.schedule(S,r,l))}return o}return r.C6(t,e),t.prototype._next=function(e){for(var t,n=this.contexts,r=n.length,i=0;i<r;i++){var s=n[i],o=s.buffer;o.push(e),o.length==this.maxBufferSize&&(t=s)}t&&this.onBufferFull(t)},t.prototype._error=function(t){this.contexts.length=0,e.prototype._error.call(this,t)},t.prototype._complete=function(){for(var t=this.contexts,n=this.destination;t.length>0;){var r=t.shift();n.next(r.buffer)}e.prototype._complete.call(this)},t.prototype._unsubscribe=function(){this.contexts=null},t.prototype.onBufferFull=function(e){this.closeContext(e);var t=e.closeAction;if(t.unsubscribe(),this.remove(t),!this.closed&&this.timespanOnly){e=this.openContext();var n=this.bufferTimeSpan,r={subscriber:this,context:e,bufferTimeSpan:n};this.add(e.closeAction=this.scheduler.schedule(T,n,r))}},t.prototype.openContext=function(){var e=new I;return this.contexts.push(e),e},t.prototype.closeContext=function(e){this.destination.next(e.buffer);var t=this.contexts;(t?t.indexOf(e):-1)>=0&&t.splice(t.indexOf(e),1)},t}(p.v);function T(e){var t=e.subscriber,n=e.context;n&&t.closeContext(n),t.closed||(e.context=t.openContext(),e.context.closeAction=this.schedule(e,e.bufferTimeSpan))}function S(e){var t=e.bufferCreationInterval,n=e.bufferTimeSpan,r=e.subscriber,i=e.scheduler,s=r.openContext();r.closed||(r.add(s.closeAction=i.schedule(C,n,{subscriber:r,context:s})),this.schedule(e,t))}function C(e){var t=e.subscriber,n=e.context;t.closeContext(n)}var A=n(9147),x=n(538),k=n(7069);function N(e,t){return function(n){return n.lift(new O(e,t))}}var O=function(){function e(e,t){this.openings=e,this.closingSelector=t}return e.prototype.call=function(e,t){return t.subscribe(new D(e,this.openings,this.closingSelector))},e}(),D=function(e){function t(t,n,r){var i=e.call(this,t)||this;return i.closingSelector=r,i.contexts=[],i.add((0,x.F)(i,n)),i}return r.C6(t,e),t.prototype._next=function(e){for(var t=this.contexts,n=t.length,r=0;r<n;r++)t[r].buffer.push(e)},t.prototype._error=function(t){for(var n=this.contexts;n.length>0;){var r=n.shift();r.subscription.unsubscribe(),r.buffer=null,r.subscription=null}this.contexts=null,e.prototype._error.call(this,t)},t.prototype._complete=function(){for(var t=this.contexts;t.length>0;){var n=t.shift();this.destination.next(n.buffer),n.subscription.unsubscribe(),n.buffer=null,n.subscription=null}this.contexts=null,e.prototype._complete.call(this)},t.prototype.notifyNext=function(e,t){e?this.closeBuffer(e):this.openBuffer(t)},t.prototype.notifyComplete=function(e){this.closeBuffer(e.context)},t.prototype.openBuffer=function(e){try{var t=this.closingSelector.call(this,e);t&&this.trySubscribe(t)}catch(e){this._error(e)}},t.prototype.closeBuffer=function(e){var t=this.contexts;if(t&&e){var n=e.buffer,r=e.subscription;this.destination.next(n),t.splice(t.indexOf(e),1),this.remove(r),r.unsubscribe()}},t.prototype.trySubscribe=function(e){var t=this.contexts,n=new A.y,r={buffer:[],subscription:n};t.push(r);var i=(0,x.F)(this,e,r);!i||i.closed?this.closeBuffer(r):(i.context=r,this.add(i),n.add(i))},t}(k.E);function R(e){return function(t){return t.lift(new P(e))}}var P=function(){function e(e){this.closingSelector=e}return e.prototype.call=function(e,t){return t.subscribe(new L(e,this.closingSelector))},e}(),L=function(e){function t(t,n){var r=e.call(this,t)||this;return r.closingSelector=n,r.subscribing=!1,r.openBuffer(),r}return r.C6(t,e),t.prototype._next=function(e){this.buffer.push(e)},t.prototype._complete=function(){var t=this.buffer;t&&this.destination.next(t),e.prototype._complete.call(this)},t.prototype._unsubscribe=function(){this.buffer=void 0,this.subscribing=!1},t.prototype.notifyNext=function(){this.openBuffer()},t.prototype.notifyComplete=function(){this.subscribing?this.complete():this.openBuffer()},t.prototype.openBuffer=function(){var e=this.closingSubscription;e&&(this.remove(e),e.unsubscribe());var t,n=this.buffer;this.buffer&&this.destination.next(n),this.buffer=[];try{t=(0,this.closingSelector)()}catch(e){return this.error(e)}e=new A.y,this.closingSubscription=e,this.add(e),this.subscribing=!0,e.add((0,i.tS)(t,new i.zA(this))),this.subscribing=!1},t}(i.gn);function M(e){return function(t){var n=new F(e),r=t.lift(n);return n.caught=r}}var F=function(){function e(e){this.selector=e}return e.prototype.call=function(e,t){return t.subscribe(new V(e,this.selector,this.caught))},e}(),V=function(e){function t(t,n,r){var i=e.call(this,t)||this;return i.selector=n,i.caught=r,i}return r.C6(t,e),t.prototype.error=function(t){if(!this.isStopped){var n=void 0;try{n=this.selector(t,this.caught)}catch(t){return void e.prototype.error.call(this,t)}this._unsubscribeAndRecycle();var r=new i.zA(this);this.add(r);var s=(0,i.tS)(n,r);s!==r&&this.add(s)}},t}(i.gn),U=n(8890);function j(e){return function(t){return t.lift(new U.ZS(e))}}var B=n(252),q=n(7046);function z(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=null;return"function"==typeof e[e.length-1]&&(n=e.pop()),1===e.length&&(0,B.c)(e[0])&&(e=e[0].slice()),function(t){return t.lift.call((0,q.H)([t].concat(e)),new U.ZS(n))}}var G=n(926);function K(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t){return t.lift.call(G.x.apply(void 0,[t].concat(e)))}}var W=n(7125),$=n(4490);function H(e,t){return(0,$.ZZ)(e,t,1)}function Q(e,t){return H((function(){return e}),t)}function J(e){return function(t){return t.lift(new Y(e,t))}}var Y=function(){function e(e,t){this.predicate=e,this.source=t}return e.prototype.call=function(e,t){return t.subscribe(new X(e,this.predicate,this.source))},e}(),X=function(e){function t(t,n,r){var i=e.call(this,t)||this;return i.predicate=n,i.source=r,i.count=0,i.index=0,i}return r.C6(t,e),t.prototype._next=function(e){this.predicate?this._tryPredicate(e):this.count++},t.prototype._tryPredicate=function(e){var t;try{t=this.predicate(e,this.index++,this.source)}catch(e){return void this.destination.error(e)}t&&this.count++},t.prototype._complete=function(){this.destination.next(this.count),this.destination.complete()},t}(p.v);function Z(e){return function(t){return t.lift(new ee(e))}}var ee=function(){function e(e){this.durationSelector=e}return e.prototype.call=function(e,t){return t.subscribe(new te(e,this.durationSelector))},e}(),te=function(e){function t(t,n){var r=e.call(this,t)||this;return r.durationSelector=n,r.hasValue=!1,r}return r.C6(t,e),t.prototype._next=function(e){try{var t=this.durationSelector.call(this,e);t&&this._tryNext(e,t)}catch(e){this.destination.error(e)}},t.prototype._complete=function(){this.emitValue(),this.destination.complete()},t.prototype._tryNext=function(e,t){var n=this.durationSubscription;this.value=e,this.hasValue=!0,n&&(n.unsubscribe(),this.remove(n)),(n=(0,i.tS)(t,new i.zA(this)))&&!n.closed&&this.add(this.durationSubscription=n)},t.prototype.notifyNext=function(){this.emitValue()},t.prototype.notifyComplete=function(){this.emitValue()},t.prototype.emitValue=function(){if(this.hasValue){var t=this.value,n=this.durationSubscription;n&&(this.durationSubscription=void 0,n.unsubscribe(),this.remove(n)),this.value=void 0,this.hasValue=!1,e.prototype._next.call(this,t)}},t}(i.gn);function ne(e,t){return void 0===t&&(t=c.b),function(n){return n.lift(new re(e,t))}}var re=function(){function e(e,t){this.dueTime=e,this.scheduler=t}return e.prototype.call=function(e,t){return t.subscribe(new ie(e,this.dueTime,this.scheduler))},e}(),ie=function(e){function t(t,n,r){var i=e.call(this,t)||this;return i.dueTime=n,i.scheduler=r,i.debouncedSubscription=null,i.lastValue=null,i.hasValue=!1,i}return r.C6(t,e),t.prototype._next=function(e){this.clearDebounce(),this.lastValue=e,this.hasValue=!0,this.add(this.debouncedSubscription=this.scheduler.schedule(se,this.dueTime,this))},t.prototype._complete=function(){this.debouncedNext(),this.destination.complete()},t.prototype.debouncedNext=function(){if(this.clearDebounce(),this.hasValue){var e=this.lastValue;this.lastValue=null,this.hasValue=!1,this.destination.next(e)}},t.prototype.clearDebounce=function(){var e=this.debouncedSubscription;null!==e&&(this.remove(e),e.unsubscribe(),this.debouncedSubscription=null)},t}(p.v);function se(e){e.debouncedNext()}function oe(e){return void 0===e&&(e=null),function(t){return t.lift(new ae(e))}}var ae=function(){function e(e){this.defaultValue=e}return e.prototype.call=function(e,t){return t.subscribe(new ce(e,this.defaultValue))},e}(),ce=function(e){function t(t,n){var r=e.call(this,t)||this;return r.defaultValue=n,r.isEmpty=!0,r}return r.C6(t,e),t.prototype._next=function(e){this.isEmpty=!1,this.destination.next(e)},t.prototype._complete=function(){this.isEmpty&&this.destination.next(this.defaultValue),this.destination.complete()},t}(p.v);function ue(e){return e instanceof Date&&!isNaN(+e)}var le=n(2281);function he(e,t){void 0===t&&(t=c.b);var n=ue(e)?+e-t.now():Math.abs(e);return function(e){return e.lift(new de(n,t))}}var de=function(){function e(e,t){this.delay=e,this.scheduler=t}return e.prototype.call=function(e,t){return t.subscribe(new fe(e,this.delay,this.scheduler))},e}(),fe=function(e){function t(t,n,r){var i=e.call(this,t)||this;return i.delay=n,i.scheduler=r,i.queue=[],i.active=!1,i.errored=!1,i}return r.C6(t,e),t.dispatch=function(e){for(var t=e.source,n=t.queue,r=e.scheduler,i=e.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(e,s)}else this.unsubscribe(),t.active=!1},t.prototype._schedule=function(e){this.active=!0,this.destination.add(e.schedule(t.dispatch,this.delay,{source:this,destination:this.destination,scheduler:e}))},t.prototype.scheduleNotification=function(e){if(!0!==this.errored){var t=this.scheduler,n=new pe(t.now()+this.delay,e);this.queue.push(n),!1===this.active&&this._schedule(t)}},t.prototype._next=function(e){this.scheduleNotification(le.E.createNext(e))},t.prototype._error=function(e){this.errored=!0,this.queue=[],this.destination.error(e),this.unsubscribe()},t.prototype._complete=function(){this.scheduleNotification(le.E.createComplete()),this.unsubscribe()},t}(p.v),pe=function(){return function(e,t){this.time=e,this.notification=t}}(),me=n(9664);function ge(e,t){return t?function(n){return new be(n,t).lift(new ye(e))}:function(t){return t.lift(new ye(e))}}var ye=function(){function e(e){this.delayDurationSelector=e}return e.prototype.call=function(e,t){return t.subscribe(new ve(e,this.delayDurationSelector))},e}(),ve=function(e){function t(t,n){var r=e.call(this,t)||this;return r.delayDurationSelector=n,r.completed=!1,r.delayNotifierSubscriptions=[],r.index=0,r}return r.C6(t,e),t.prototype.notifyNext=function(e,t,n,r,i){this.destination.next(e),this.removeSubscription(i),this.tryComplete()},t.prototype.notifyError=function(e,t){this._error(e)},t.prototype.notifyComplete=function(e){var t=this.removeSubscription(e);t&&this.destination.next(t),this.tryComplete()},t.prototype._next=function(e){var t=this.index++;try{var n=this.delayDurationSelector(e,t);n&&this.tryDelay(n,e)}catch(e){this.destination.error(e)}},t.prototype._complete=function(){this.completed=!0,this.tryComplete(),this.unsubscribe()},t.prototype.removeSubscription=function(e){e.unsubscribe();var t=this.delayNotifierSubscriptions.indexOf(e);return-1!==t&&this.delayNotifierSubscriptions.splice(t,1),e.outerValue},t.prototype.tryDelay=function(e,t){var n=(0,x.F)(this,e,t);n&&!n.closed&&(this.destination.add(n),this.delayNotifierSubscriptions.push(n))},t.prototype.tryComplete=function(){this.completed&&0===this.delayNotifierSubscriptions.length&&this.destination.complete()},t}(k.E),be=function(e){function t(t,n){var r=e.call(this)||this;return r.source=t,r.subscriptionDelay=n,r}return r.C6(t,e),t.prototype._subscribe=function(e){this.subscriptionDelay.subscribe(new we(e,this.source))},t}(me.c),we=function(e){function t(t,n){var r=e.call(this)||this;return r.parent=t,r.source=n,r.sourceSubscribed=!1,r}return r.C6(t,e),t.prototype._next=function(e){this.subscribeToSource()},t.prototype._error=function(e){this.unsubscribe(),this.parent.error(e)},t.prototype._complete=function(){this.unsubscribe(),this.subscribeToSource()},t.prototype.subscribeToSource=function(){this.sourceSubscribed||(this.sourceSubscribed=!0,this.unsubscribe(),this.source.subscribe(this.parent))},t}(p.v);function _e(){return function(e){return e.lift(new Ie)}}var Ie=function(){function e(){}return e.prototype.call=function(e,t){return t.subscribe(new Ee(e))},e}(),Ee=function(e){function t(t){return e.call(this,t)||this}return r.C6(t,e),t.prototype._next=function(e){e.observe(this.destination)},t}(p.v);function Te(e,t){return function(n){return n.lift(new Se(e,t))}}var Se=function(){function e(e,t){this.keySelector=e,this.flushes=t}return e.prototype.call=function(e,t){return t.subscribe(new Ce(e,this.keySelector,this.flushes))},e}(),Ce=function(e){function t(t,n,r){var s=e.call(this,t)||this;return s.keySelector=n,s.values=new Set,r&&s.add((0,i.tS)(r,new i.zA(s))),s}return r.C6(t,e),t.prototype.notifyNext=function(){this.values.clear()},t.prototype.notifyError=function(e){this._error(e)},t.prototype._next=function(e){this.keySelector?this._useKeySelector(e):this._finalizeNext(e,e)},t.prototype._useKeySelector=function(e){var t,n=this.destination;try{t=this.keySelector(e)}catch(e){return void n.error(e)}this._finalizeNext(t,e)},t.prototype._finalizeNext=function(e,t){var n=this.values;n.has(e)||(n.add(e),this.destination.next(t))},t}(i.gn);function Ae(e,t){return function(n){return n.lift(new xe(e,t))}}var xe=function(){function e(e,t){this.compare=e,this.keySelector=t}return e.prototype.call=function(e,t){return t.subscribe(new ke(e,this.compare,this.keySelector))},e}(),ke=function(e){function t(t,n,r){var i=e.call(this,t)||this;return i.keySelector=r,i.hasKey=!1,"function"==typeof n&&(i.compare=n),i}return r.C6(t,e),t.prototype.compare=function(e,t){return e===t},t.prototype._next=function(e){var t;try{var n=this.keySelector;t=n?n(e):e}catch(e){return this.destination.error(e)}var r=!1;if(this.hasKey)try{r=(0,this.compare)(this.key,t)}catch(e){return this.destination.error(e)}else this.hasKey=!0;r||(this.key=t,this.destination.next(e))},t}(p.v);function Ne(e,t){return Ae((function(n,r){return t?t(n[e],r[e]):n[e]===r[e]}))}var Oe=n(692),De=n(9610),Re=n(3700);function Pe(e){return void 0===e&&(e=Fe),function(t){return t.lift(new Le(e))}}var Le=function(){function e(e){this.errorFactory=e}return e.prototype.call=function(e,t){return t.subscribe(new Me(e,this.errorFactory))},e}(),Me=function(e){function t(t,n){var r=e.call(this,t)||this;return r.errorFactory=n,r.hasValue=!1,r}return r.C6(t,e),t.prototype._next=function(e){this.hasValue=!0,this.destination.next(e)},t.prototype._complete=function(){if(this.hasValue)return this.destination.complete();var e=void 0;try{e=this.errorFactory()}catch(t){e=t}this.destination.error(e)},t}(p.v);function Fe(){return new Re.G}var Ve=n(4833);function Ue(e){return function(t){return 0===e?(0,Ve.I)():t.lift(new je(e))}}var je=function(){function e(e){if(this.total=e,this.total<0)throw new Oe.k}return e.prototype.call=function(e,t){return t.subscribe(new Be(e,this.total))},e}(),Be=function(e){function t(t,n){var r=e.call(this,t)||this;return r.total=n,r.count=0,r}return r.C6(t,e),t.prototype._next=function(e){var t=this.total,n=++this.count;n<=t&&(this.destination.next(e),n===t&&(this.destination.complete(),this.unsubscribe()))},t}(p.v);function qe(e,t){if(e<0)throw new Oe.k;var n=arguments.length>=2;return function(r){return r.pipe((0,De.p)((function(t,n){return n===e})),Ue(1),n?oe(t):Pe((function(){return new Oe.k})))}}var ze=n(8927);function Ge(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t){return(0,G.x)(t,ze.of.apply(void 0,e))}}function Ke(e,t){return function(n){return n.lift(new We(e,t,n))}}var We=function(){function e(e,t,n){this.predicate=e,this.thisArg=t,this.source=n}return e.prototype.call=function(e,t){return t.subscribe(new $e(e,this.predicate,this.thisArg,this.source))},e}(),$e=function(e){function t(t,n,r,i){var s=e.call(this,t)||this;return s.predicate=n,s.thisArg=r,s.source=i,s.index=0,s.thisArg=r||s,s}return r.C6(t,e),t.prototype.notifyComplete=function(e){this.destination.next(e),this.destination.complete()},t.prototype._next=function(e){var t=!1;try{t=this.predicate.call(this.thisArg,e,this.index++,this.source)}catch(e){return void this.destination.error(e)}t||this.notifyComplete(!1)},t.prototype._complete=function(){this.notifyComplete(!0)},t}(p.v);function He(){return function(e){return e.lift(new Qe)}}var Qe=function(){function e(){}return e.prototype.call=function(e,t){return t.subscribe(new Je(e))},e}(),Je=function(e){function t(t){var n=e.call(this,t)||this;return n.hasCompleted=!1,n.hasSubscription=!1,n}return r.C6(t,e),t.prototype._next=function(e){this.hasSubscription||(this.hasSubscription=!0,this.add((0,i.tS)(e,new i.zA(this))))},t.prototype._complete=function(){this.hasCompleted=!0,this.hasSubscription||this.destination.complete()},t.prototype.notifyComplete=function(){this.hasSubscription=!1,this.hasCompleted&&this.destination.complete()},t}(i.gn),Ye=n(8100);function Xe(e,t){return t?function(n){return n.pipe(Xe((function(n,r){return(0,q.H)(e(n,r)).pipe((0,Ye.T)((function(e,i){return t(n,e,r,i)})))})))}:function(t){return t.lift(new Ze(e))}}var Ze=function(){function e(e){this.project=e}return e.prototype.call=function(e,t){return t.subscribe(new et(e,this.project))},e}(),et=function(e){function t(t,n){var r=e.call(this,t)||this;return r.project=n,r.hasSubscription=!1,r.hasCompleted=!1,r.index=0,r}return r.C6(t,e),t.prototype._next=function(e){this.hasSubscription||this.tryNext(e)},t.prototype.tryNext=function(e){var t,n=this.index++;try{t=this.project(e,n)}catch(e){return void this.destination.error(e)}this.hasSubscription=!0,this._innerSub(t)},t.prototype._innerSub=function(e){var t=new i.zA(this),n=this.destination;n.add(t);var r=(0,i.tS)(e,t);r!==t&&n.add(r)},t.prototype._complete=function(){this.hasCompleted=!0,this.hasSubscription||this.destination.complete(),this.unsubscribe()},t.prototype.notifyNext=function(e){this.destination.next(e)},t.prototype.notifyError=function(e){this.destination.error(e)},t.prototype.notifyComplete=function(){this.hasSubscription=!1,this.hasCompleted&&this.destination.complete()},t}(i.gn);function tt(e,t,n){return void 0===t&&(t=Number.POSITIVE_INFINITY),t=(t||0)<1?Number.POSITIVE_INFINITY:t,function(r){return r.lift(new nt(e,t,n))}}var nt=function(){function e(e,t,n){this.project=e,this.concurrent=t,this.scheduler=n}return e.prototype.call=function(e,t){return t.subscribe(new rt(e,this.project,this.concurrent,this.scheduler))},e}(),rt=function(e){function t(t,n,r,i){var s=e.call(this,t)||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.C6(t,e),t.dispatch=function(e){var t=e.subscriber,n=e.result,r=e.value,i=e.index;t.subscribeToProjection(n,r,i)},t.prototype._next=function(e){var n=this.destination;if(n.closed)this._complete();else{var r=this.index++;if(this.active<this.concurrent){n.next(e);try{var i=(0,this.project)(e,r);if(this.scheduler){var s={subscriber:this,result:i,value:e,index:r};this.destination.add(this.scheduler.schedule(t.dispatch,0,s))}else this.subscribeToProjection(i,e,r)}catch(e){n.error(e)}}else this.buffer.push(e)}},t.prototype.subscribeToProjection=function(e,t,n){this.active++,this.destination.add((0,i.tS)(e,new i.zA(this)))},t.prototype._complete=function(){this.hasCompleted=!0,this.hasCompleted&&0===this.active&&this.destination.complete(),this.unsubscribe()},t.prototype.notifyNext=function(e){this._next(e)},t.prototype.notifyComplete=function(){var e=this.buffer;this.active--,e&&e.length>0&&this._next(e.shift()),this.hasCompleted&&0===this.active&&this.destination.complete()},t}(i.gn);function it(e){return function(t){return t.lift(new st(e))}}var st=function(){function e(e){this.callback=e}return e.prototype.call=function(e,t){return t.subscribe(new ot(e,this.callback))},e}(),ot=function(e){function t(t,n){var r=e.call(this,t)||this;return r.add(new A.y(n)),r}return r.C6(t,e),t}(p.v);function at(e,t){if("function"!=typeof e)throw new TypeError("predicate is not a function");return function(n){return n.lift(new ct(e,n,!1,t))}}var ct=function(){function e(e,t,n,r){this.predicate=e,this.source=t,this.yieldIndex=n,this.thisArg=r}return e.prototype.call=function(e,t){return t.subscribe(new ut(e,this.predicate,this.source,this.yieldIndex,this.thisArg))},e}(),ut=function(e){function t(t,n,r,i,s){var o=e.call(this,t)||this;return o.predicate=n,o.source=r,o.yieldIndex=i,o.thisArg=s,o.index=0,o}return r.C6(t,e),t.prototype.notifyComplete=function(e){var t=this.destination;t.next(e),t.complete(),this.unsubscribe()},t.prototype._next=function(e){var t=this.predicate,n=this.thisArg,r=this.index++;try{t.call(n||this,e,r,this.source)&&this.notifyComplete(this.yieldIndex?r:e)}catch(e){this.destination.error(e)}},t.prototype._complete=function(){this.notifyComplete(this.yieldIndex?-1:void 0)},t}(p.v);function lt(e,t){return function(n){return n.lift(new ct(e,n,!0,t))}}var ht=n(1015);function dt(e,t){var n=arguments.length>=2;return function(r){return r.pipe(e?(0,De.p)((function(t,n){return e(t,n,r)})):ht.D,Ue(1),n?oe(t):Pe((function(){return new Re.G})))}}var ft=n(3108);function pt(){return function(e){return e.lift(new mt)}}var mt=function(){function e(){}return e.prototype.call=function(e,t){return t.subscribe(new gt(e))},e}(),gt=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r.C6(t,e),t.prototype._next=function(e){},t}(p.v);function yt(){return function(e){return e.lift(new vt)}}var vt=function(){function e(){}return e.prototype.call=function(e,t){return t.subscribe(new bt(e))},e}(),bt=function(e){function t(t){return e.call(this,t)||this}return r.C6(t,e),t.prototype.notifyComplete=function(e){var t=this.destination;t.next(e),t.complete()},t.prototype._next=function(e){this.notifyComplete(!1)},t.prototype._complete=function(){this.notifyComplete(!0)},t}(p.v);function wt(e){return function(t){return 0===e?(0,Ve.I)():t.lift(new _t(e))}}var _t=function(){function e(e){if(this.total=e,this.total<0)throw new Oe.k}return e.prototype.call=function(e,t){return t.subscribe(new It(e,this.total))},e}(),It=function(e){function t(t,n){var r=e.call(this,t)||this;return r.total=n,r.ring=new Array,r.count=0,r}return r.C6(t,e),t.prototype._next=function(e){var t=this.ring,n=this.total,r=this.count++;t.length<n?t.push(e):t[r%n]=e},t.prototype._complete=function(){var e=this.destination,t=this.count;if(t>0)for(var n=this.count>=this.total?this.total:this.count,r=this.ring,i=0;i<n;i++){var s=t++%n;e.next(r[s])}e.complete()},t}(p.v);function Et(e,t){var n=arguments.length>=2;return function(r){return r.pipe(e?(0,De.p)((function(t,n){return e(t,n,r)})):ht.D,wt(1),n?oe(t):Pe((function(){return new Re.G})))}}function Tt(e){return function(t){return t.lift(new St(e))}}var St=function(){function e(e){this.value=e}return e.prototype.call=function(e,t){return t.subscribe(new Ct(e,this.value))},e}(),Ct=function(e){function t(t,n){var r=e.call(this,t)||this;return r.value=n,r}return r.C6(t,e),t.prototype._next=function(e){this.destination.next(this.value)},t}(p.v);function At(){return function(e){return e.lift(new xt)}}var xt=function(){function e(){}return e.prototype.call=function(e,t){return t.subscribe(new kt(e))},e}(),kt=function(e){function t(t){return e.call(this,t)||this}return r.C6(t,e),t.prototype._next=function(e){this.destination.next(le.E.createNext(e))},t.prototype._error=function(e){var t=this.destination;t.next(le.E.createError(e)),t.complete()},t.prototype._complete=function(){var e=this.destination;e.next(le.E.createComplete()),e.complete()},t}(p.v);function Nt(e,t){var n=!1;return arguments.length>=2&&(n=!0),function(r){return r.lift(new Ot(e,t,n))}}var Ot=function(){function e(e,t,n){void 0===n&&(n=!1),this.accumulator=e,this.seed=t,this.hasSeed=n}return e.prototype.call=function(e,t){return t.subscribe(new Dt(e,this.accumulator,this.seed,this.hasSeed))},e}(),Dt=function(e){function t(t,n,r,i){var s=e.call(this,t)||this;return s.accumulator=n,s._seed=r,s.hasSeed=i,s.index=0,s}return r.C6(t,e),Object.defineProperty(t.prototype,"seed",{get:function(){return this._seed},set:function(e){this.hasSeed=!0,this._seed=e},enumerable:!0,configurable:!0}),t.prototype._next=function(e){if(this.hasSeed)return this._tryNext(e);this.seed=e,this.destination.next(e)},t.prototype._tryNext=function(e){var t,n=this.index++;try{t=this.accumulator(this.seed,e,n)}catch(e){this.destination.error(e)}this.seed=t,this.destination.next(t)},t}(p.v),Rt=n(6833);function Pt(e,t){return arguments.length>=2?function(n){return(0,Rt.F)(Nt(e,t),wt(1),oe(t))(n)}:function(t){return(0,Rt.F)(Nt((function(t,n,r){return e(t,n,r+1)})),wt(1))(t)}}function Lt(e){return Pt("function"==typeof e?function(t,n){return e(t,n)>0?t:n}:function(e,t){return e>t?e:t})}var Mt=n(3767);function Ft(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t){return t.lift.call(Mt.h.apply(void 0,[t].concat(e)))}}var Vt=n(6723);function Ut(e,t,n){return void 0===n&&(n=Number.POSITIVE_INFINITY),"function"==typeof t?(0,$.ZZ)((function(){return e}),t,n):("number"==typeof t&&(n=t),(0,$.ZZ)((function(){return e}),n))}function jt(e,t,n){return void 0===n&&(n=Number.POSITIVE_INFINITY),function(r){return r.lift(new Bt(e,t,n))}}var Bt=function(){function e(e,t,n){this.accumulator=e,this.seed=t,this.concurrent=n}return e.prototype.call=function(e,t){return t.subscribe(new qt(e,this.accumulator,this.seed,this.concurrent))},e}(),qt=function(e){function t(t,n,r,i){var s=e.call(this,t)||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.C6(t,e),t.prototype._next=function(e){if(this.active<this.concurrent){var t=this.index++,n=this.destination,r=void 0;try{r=(0,this.accumulator)(this.acc,e,t)}catch(e){return n.error(e)}this.active++,this._innerSub(r)}else this.buffer.push(e)},t.prototype._innerSub=function(e){var t=new i.zA(this),n=this.destination;n.add(t);var r=(0,i.tS)(e,t);r!==t&&n.add(r)},t.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()},t.prototype.notifyNext=function(e){var t=this.destination;this.acc=e,this.hasValue=!0,t.next(e)},t.prototype.notifyComplete=function(){var e=this.buffer;this.active--,e.length>0?this._next(e.shift()):0===this.active&&this.hasCompleted&&(!1===this.hasValue&&this.destination.next(this.acc),this.destination.complete())},t}(i.gn);function zt(e){return Pt("function"==typeof e?function(t,n){return e(t,n)<0?t:n}:function(e,t){return e<t?e:t})}var Gt=n(4491);function Kt(e,t){return function(n){var r;if(r="function"==typeof e?e:function(){return e},"function"==typeof t)return n.lift(new Wt(r,t));var i=Object.create(n,Gt.f);return i.source=n,i.subjectFactory=r,i}}var Wt=function(){function e(e,t){this.subjectFactory=e,this.selector=t}return e.prototype.call=function(e,t){var n=this.selector,r=this.subjectFactory(),i=n(r).subscribe(e);return i.add(t.subscribe(r)),i},e}(),$t=n(3947);function Ht(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return 1===e.length&&(0,B.c)(e[0])&&(e=e[0]),function(t){return t.lift(new Qt(e))}}var Qt=function(){function e(e){this.nextSources=e}return e.prototype.call=function(e,t){return t.subscribe(new Jt(e,this.nextSources))},e}(),Jt=function(e){function t(t,n){var r=e.call(this,t)||this;return r.destination=t,r.nextSources=n,r}return r.C6(t,e),t.prototype.notifyError=function(){this.subscribeToNextSource()},t.prototype.notifyComplete=function(){this.subscribeToNextSource()},t.prototype._error=function(e){this.subscribeToNextSource(),this.unsubscribe()},t.prototype._complete=function(){this.subscribeToNextSource(),this.unsubscribe()},t.prototype.subscribeToNextSource=function(){var e=this.nextSources.shift();if(e){var t=new i.zA(this),n=this.destination;n.add(t);var r=(0,i.tS)(e,t);r!==t&&n.add(r)}else this.destination.complete()},t}(i.gn);function Yt(){return function(e){return e.lift(new Xt)}}var Xt=function(){function e(){}return e.prototype.call=function(e,t){return t.subscribe(new Zt(e))},e}(),Zt=function(e){function t(t){var n=e.call(this,t)||this;return n.hasPrev=!1,n}return r.C6(t,e),t.prototype._next=function(e){var t;this.hasPrev?t=[this.prev,e]:this.hasPrev=!0,this.prev=e,t&&this.destination.next(t)},t}(p.v),en=n(3428);function tn(e,t){return function(n){return[(0,De.p)(e,t)(n),(0,De.p)((0,en.A)(e,t))(n)]}}function nn(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e.length;if(0===n)throw new Error("list of properties cannot be empty.");return function(t){return(0,Ye.T)(function(e,t){return function(n){for(var r=n,i=0;i<t;i++){var s=null!=r?r[e[i]]:void 0;if(void 0===s)return;r=s}return r}}(e,n))(t)}}var rn=n(6988);function sn(e){return e?Kt((function(){return new rn.B7}),e):Kt(new rn.B7)}var on=n(2430);function an(e){return function(t){return Kt(new on.t(e))(t)}}var cn=n(1934);function un(){return function(e){return Kt(new cn.h)(e)}}var ln=n(8977);function hn(e,t,n,r){n&&"function"!=typeof n&&(r=n);var i="function"==typeof n?n:void 0,s=new ln.m(e,t,r);return function(e){return Kt((function(){return s}),i)(e)}}var dn=n(8071);function fn(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t){return 1===e.length&&(0,B.c)(e[0])&&(e=e[0]),t.lift.call(dn.O4.apply(void 0,[t].concat(e)))}}function pn(e){return void 0===e&&(e=-1),function(t){return 0===e?(0,Ve.I)():e<0?t.lift(new mn(-1,t)):t.lift(new mn(e-1,t))}}var mn=function(){function e(e,t){this.count=e,this.source=t}return e.prototype.call=function(e,t){return t.subscribe(new gn(e,this.count,this.source))},e}(),gn=function(e){function t(t,n,r){var i=e.call(this,t)||this;return i.count=n,i.source=r,i}return r.C6(t,e),t.prototype.complete=function(){if(!this.isStopped){var t=this.source,n=this.count;if(0===n)return e.prototype.complete.call(this);n>-1&&(this.count=n-1),t.subscribe(this._unsubscribeAndRecycle())}},t}(p.v);function yn(e){return function(t){return t.lift(new vn(e))}}var vn=function(){function e(e){this.notifier=e}return e.prototype.call=function(e,t){return t.subscribe(new bn(e,this.notifier,t))},e}(),bn=function(e){function t(t,n,r){var i=e.call(this,t)||this;return i.notifier=n,i.source=r,i.sourceIsBeingSubscribedTo=!0,i}return r.C6(t,e),t.prototype.notifyNext=function(){this.sourceIsBeingSubscribedTo=!0,this.source.subscribe(this)},t.prototype.notifyComplete=function(){if(!1===this.sourceIsBeingSubscribedTo)return e.prototype.complete.call(this)},t.prototype.complete=function(){if(this.sourceIsBeingSubscribedTo=!1,!this.isStopped){if(this.retries||this.subscribeToRetries(),!this.retriesSubscription||this.retriesSubscription.closed)return e.prototype.complete.call(this);this._unsubscribeAndRecycle(),this.notifications.next(void 0)}},t.prototype._unsubscribe=function(){var e=this.notifications,t=this.retriesSubscription;e&&(e.unsubscribe(),this.notifications=void 0),t&&(t.unsubscribe(),this.retriesSubscription=void 0),this.retries=void 0},t.prototype._unsubscribeAndRecycle=function(){var t=this._unsubscribe;return this._unsubscribe=null,e.prototype._unsubscribeAndRecycle.call(this),this._unsubscribe=t,this},t.prototype.subscribeToRetries=function(){var t;this.notifications=new rn.B7;try{t=(0,this.notifier)(this.notifications)}catch(t){return e.prototype.complete.call(this)}this.retries=t,this.retriesSubscription=(0,i.tS)(t,new i.zA(this))},t}(i.gn);function wn(e){return void 0===e&&(e=-1),function(t){return t.lift(new _n(e,t))}}var _n=function(){function e(e,t){this.count=e,this.source=t}return e.prototype.call=function(e,t){return t.subscribe(new In(e,this.count,this.source))},e}(),In=function(e){function t(t,n,r){var i=e.call(this,t)||this;return i.count=n,i.source=r,i}return r.C6(t,e),t.prototype.error=function(t){if(!this.isStopped){var n=this.source,r=this.count;if(0===r)return e.prototype.error.call(this,t);r>-1&&(this.count=r-1),n.subscribe(this._unsubscribeAndRecycle())}},t}(p.v);function En(e){return function(t){return t.lift(new Tn(e,t))}}var Tn=function(){function e(e,t){this.notifier=e,this.source=t}return e.prototype.call=function(e,t){return t.subscribe(new Sn(e,this.notifier,this.source))},e}(),Sn=function(e){function t(t,n,r){var i=e.call(this,t)||this;return i.notifier=n,i.source=r,i}return r.C6(t,e),t.prototype.error=function(t){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 rn.B7;try{r=(0,this.notifier)(n)}catch(t){return e.prototype.error.call(this,t)}s=(0,i.tS)(r,new i.zA(this))}this._unsubscribeAndRecycle(),this.errors=n,this.retries=r,this.retriesSubscription=s,n.next(t)}},t.prototype._unsubscribe=function(){var e=this.errors,t=this.retriesSubscription;e&&(e.unsubscribe(),this.errors=void 0),t&&(t.unsubscribe(),this.retriesSubscription=void 0),this.retries=void 0},t.prototype.notifyNext=function(){var e=this._unsubscribe;this._unsubscribe=null,this._unsubscribeAndRecycle(),this._unsubscribe=e,this.source.subscribe(this)},t}(i.gn),Cn=n(1764);function An(e){return function(t){return t.lift(new xn(e))}}var xn=function(){function e(e){this.notifier=e}return e.prototype.call=function(e,t){var n=new kn(e),r=t.subscribe(n);return r.add((0,i.tS)(this.notifier,new i.zA(n))),r},e}(),kn=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.hasValue=!1,t}return r.C6(t,e),t.prototype._next=function(e){this.value=e,this.hasValue=!0},t.prototype.notifyNext=function(){this.emitValue()},t.prototype.notifyComplete=function(){this.emitValue()},t.prototype.emitValue=function(){this.hasValue&&(this.hasValue=!1,this.destination.next(this.value))},t}(i.gn);function Nn(e,t){return void 0===t&&(t=c.b),function(n){return n.lift(new On(e,t))}}var On=function(){function e(e,t){this.period=e,this.scheduler=t}return e.prototype.call=function(e,t){return t.subscribe(new Dn(e,this.period,this.scheduler))},e}(),Dn=function(e){function t(t,n,r){var i=e.call(this,t)||this;return i.period=n,i.scheduler=r,i.hasValue=!1,i.add(r.schedule(Rn,n,{subscriber:i,period:n})),i}return r.C6(t,e),t.prototype._next=function(e){this.lastValue=e,this.hasValue=!0},t.prototype.notifyNext=function(){this.hasValue&&(this.hasValue=!1,this.destination.next(this.lastValue))},t}(p.v);function Rn(e){var t=e.subscriber,n=e.period;t.notifyNext(),this.schedule(e,n)}function Pn(e,t){return function(n){return n.lift(new Ln(e,t))}}var Ln=function(){function e(e,t){this.compareTo=e,this.comparator=t}return e.prototype.call=function(e,t){return t.subscribe(new Mn(e,this.compareTo,this.comparator))},e}(),Mn=function(e){function t(t,n,r){var i=e.call(this,t)||this;return i.compareTo=n,i.comparator=r,i._a=[],i._b=[],i._oneComplete=!1,i.destination.add(n.subscribe(new Fn(t,i))),i}return r.C6(t,e),t.prototype._next=function(e){this._oneComplete&&0===this._b.length?this.emit(!1):(this._a.push(e),this.checkValues())},t.prototype._complete=function(){this._oneComplete?this.emit(0===this._a.length&&0===this._b.length):this._oneComplete=!0,this.unsubscribe()},t.prototype.checkValues=function(){for(var e=this,t=e._a,n=e._b,r=e.comparator;t.length>0&&n.length>0;){var i=t.shift(),s=n.shift(),o=!1;try{o=r?r(i,s):i===s}catch(e){this.destination.error(e)}o||this.emit(!1)}},t.prototype.emit=function(e){var t=this.destination;t.next(e),t.complete()},t.prototype.nextB=function(e){this._oneComplete&&0===this._a.length?this.emit(!1):(this._b.push(e),this.checkValues())},t.prototype.completeB=function(){this._oneComplete?this.emit(0===this._a.length&&0===this._b.length):this._oneComplete=!0},t}(p.v),Fn=function(e){function t(t,n){var r=e.call(this,t)||this;return r.parent=n,r}return r.C6(t,e),t.prototype._next=function(e){this.parent.nextB(e)},t.prototype._error=function(e){this.parent.error(e),this.unsubscribe()},t.prototype._complete=function(){this.parent.completeB(),this.unsubscribe()},t}(p.v);function Vn(){return new rn.B7}function Un(){return function(e){return(0,Cn.B)()(Kt(Vn)(e))}}function jn(e,t,n){var r;return r=e&&"object"==typeof e?e:{bufferSize:e,windowTime:t,refCount:!1,scheduler:n},function(e){return e.lift(function(e){var t,n,r=e.bufferSize,i=void 0===r?Number.POSITIVE_INFINITY:r,s=e.windowTime,o=void 0===s?Number.POSITIVE_INFINITY:s,a=e.refCount,c=e.scheduler,u=0,l=!1,h=!1;return function(e){var r;u++,!t||l?(l=!1,t=new ln.m(i,o,c),r=t.subscribe(this),n=e.subscribe({next:function(e){t.next(e)},error:function(e){l=!0,t.error(e)},complete:function(){h=!0,n=void 0,t.complete()}}),h&&(n=void 0)):r=t.subscribe(this),this.add((function(){u--,r.unsubscribe(),r=void 0,n&&!h&&a&&0===u&&(n.unsubscribe(),n=void 0,t=void 0)}))}}(r))}}function Bn(e){return function(t){return t.lift(new qn(e,t))}}var qn=function(){function e(e,t){this.predicate=e,this.source=t}return e.prototype.call=function(e,t){return t.subscribe(new zn(e,this.predicate,this.source))},e}(),zn=function(e){function t(t,n,r){var i=e.call(this,t)||this;return i.predicate=n,i.source=r,i.seenValue=!1,i.index=0,i}return r.C6(t,e),t.prototype.applySingleValue=function(e){this.seenValue?this.destination.error("Sequence contains more than one element"):(this.seenValue=!0,this.singleValue=e)},t.prototype._next=function(e){var t=this.index++;this.predicate?this.tryNext(e,t):this.applySingleValue(e)},t.prototype.tryNext=function(e,t){try{this.predicate(e,t,this.source)&&this.applySingleValue(e)}catch(e){this.destination.error(e)}},t.prototype._complete=function(){var e=this.destination;this.index>0?(e.next(this.seenValue?this.singleValue:void 0),e.complete()):e.error(new Re.G)},t}(p.v);function Gn(e){return function(t){return t.lift(new Kn(e))}}var Kn=function(){function e(e){this.total=e}return e.prototype.call=function(e,t){return t.subscribe(new Wn(e,this.total))},e}(),Wn=function(e){function t(t,n){var r=e.call(this,t)||this;return r.total=n,r.count=0,r}return r.C6(t,e),t.prototype._next=function(e){++this.count>this.total&&this.destination.next(e)},t}(p.v);function $n(e){return function(t){return t.lift(new Hn(e))}}var Hn=function(){function e(e){if(this._skipCount=e,this._skipCount<0)throw new Oe.k}return e.prototype.call=function(e,t){return 0===this._skipCount?t.subscribe(new p.v(e)):t.subscribe(new Qn(e,this._skipCount))},e}(),Qn=function(e){function t(t,n){var r=e.call(this,t)||this;return r._skipCount=n,r._count=0,r._ring=new Array(n),r}return r.C6(t,e),t.prototype._next=function(e){var t=this._skipCount,n=this._count++;if(n<t)this._ring[n]=e;else{var r=n%t,i=this._ring,s=i[r];i[r]=e,this.destination.next(s)}},t}(p.v);function Jn(e){return function(t){return t.lift(new Yn(e))}}var Yn=function(){function e(e){this.notifier=e}return e.prototype.call=function(e,t){return t.subscribe(new Xn(e,this.notifier))},e}(),Xn=function(e){function t(t,n){var r=e.call(this,t)||this;r.hasValue=!1;var s=new i.zA(r);r.add(s),r.innerSubscription=s;var o=(0,i.tS)(n,s);return o!==s&&(r.add(o),r.innerSubscription=o),r}return r.C6(t,e),t.prototype._next=function(t){this.hasValue&&e.prototype._next.call(this,t)},t.prototype.notifyNext=function(){this.hasValue=!0,this.innerSubscription&&this.innerSubscription.unsubscribe()},t.prototype.notifyComplete=function(){},t}(i.gn);function Zn(e){return function(t){return t.lift(new er(e))}}var er=function(){function e(e){this.predicate=e}return e.prototype.call=function(e,t){return t.subscribe(new tr(e,this.predicate))},e}(),tr=function(e){function t(t,n){var r=e.call(this,t)||this;return r.predicate=n,r.skipping=!0,r.index=0,r}return r.C6(t,e),t.prototype._next=function(e){var t=this.destination;this.skipping&&this.tryCallPredicate(e),this.skipping||t.next(e)},t.prototype.tryCallPredicate=function(e){try{var t=this.predicate(e,this.index++);this.skipping=Boolean(t)}catch(e){this.destination.error(e)}},t}(p.v);function nr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e[e.length-1];return(0,b.m)(n)?(e.pop(),function(t){return(0,G.x)(e,t,n)}):function(t){return(0,G.x)(e,t)}}var rr=n(9081),ir=n(6290),sr=function(e){function t(t,n,r){void 0===n&&(n=0),void 0===r&&(r=rr.I);var i=e.call(this)||this;return i.source=t,i.delayTime=n,i.scheduler=r,(!(0,ir.k)(n)||n<0)&&(i.delayTime=0),r&&"function"==typeof r.schedule||(i.scheduler=rr.I),i}return r.C6(t,e),t.create=function(e,n,r){return void 0===n&&(n=0),void 0===r&&(r=rr.I),new t(e,n,r)},t.dispatch=function(e){var t=e.source,n=e.subscriber;return this.add(t.subscribe(n))},t.prototype._subscribe=function(e){var n=this.delayTime,r=this.source;return this.scheduler.schedule(t.dispatch,n,{source:r,subscriber:e})},t}(me.c);function or(e,t){return void 0===t&&(t=0),function(n){return n.lift(new ar(e,t))}}var ar=function(){function e(e,t){this.scheduler=e,this.delay=t}return e.prototype.call=function(e,t){return new sr(t,this.delay,this.scheduler).subscribe(e)},e}();function cr(e,t){return"function"==typeof t?function(n){return n.pipe(cr((function(n,r){return(0,q.H)(e(n,r)).pipe((0,Ye.T)((function(e,i){return t(n,e,r,i)})))})))}:function(t){return t.lift(new ur(e))}}var ur=function(){function e(e){this.project=e}return e.prototype.call=function(e,t){return t.subscribe(new lr(e,this.project))},e}(),lr=function(e){function t(t,n){var r=e.call(this,t)||this;return r.project=n,r.index=0,r}return r.C6(t,e),t.prototype._next=function(e){var t,n=this.index++;try{t=this.project(e,n)}catch(e){return void this.destination.error(e)}this._innerSub(t)},t.prototype._innerSub=function(e){var t=this.innerSubscription;t&&t.unsubscribe();var n=new i.zA(this),r=this.destination;r.add(n),this.innerSubscription=(0,i.tS)(e,n),this.innerSubscription!==n&&r.add(this.innerSubscription)},t.prototype._complete=function(){var t=this.innerSubscription;t&&!t.closed||e.prototype._complete.call(this),this.unsubscribe()},t.prototype._unsubscribe=function(){this.innerSubscription=void 0},t.prototype.notifyComplete=function(){this.innerSubscription=void 0,this.isStopped&&e.prototype._complete.call(this)},t.prototype.notifyNext=function(e){this.destination.next(e)},t}(i.gn);function hr(){return cr(ht.D)}function dr(e,t){return t?cr((function(){return e}),t):cr((function(){return e}))}function fr(e){return function(t){return t.lift(new pr(e))}}var pr=function(){function e(e){this.notifier=e}return e.prototype.call=function(e,t){var n=new mr(e),r=(0,i.tS)(this.notifier,new i.zA(n));return r&&!n.seenValue?(n.add(r),t.subscribe(n)):n},e}(),mr=function(e){function t(t){var n=e.call(this,t)||this;return n.seenValue=!1,n}return r.C6(t,e),t.prototype.notifyNext=function(){this.seenValue=!0,this.complete()},t.prototype.notifyComplete=function(){},t}(i.gn);function gr(e,t){return void 0===t&&(t=!1),function(n){return n.lift(new yr(e,t))}}var yr=function(){function e(e,t){this.predicate=e,this.inclusive=t}return e.prototype.call=function(e,t){return t.subscribe(new vr(e,this.predicate,this.inclusive))},e}(),vr=function(e){function t(t,n,r){var i=e.call(this,t)||this;return i.predicate=n,i.inclusive=r,i.index=0,i}return r.C6(t,e),t.prototype._next=function(e){var t,n=this.destination;try{t=this.predicate(e,this.index++)}catch(e){return void n.error(e)}this.nextOrComplete(e,t)},t.prototype.nextOrComplete=function(e,t){var n=this.destination;Boolean(t)?n.next(e):(this.inclusive&&n.next(e),n.complete())},t}(p.v),br=n(1193),wr=n(9029);function _r(e,t,n){return function(r){return r.lift(new Ir(e,t,n))}}var Ir=function(){function e(e,t,n){this.nextOrObserver=e,this.error=t,this.complete=n}return e.prototype.call=function(e,t){return t.subscribe(new Er(e,this.nextOrObserver,this.error,this.complete))},e}(),Er=function(e){function t(t,n,r,i){var s=e.call(this,t)||this;return s._tapNext=br.l,s._tapError=br.l,s._tapComplete=br.l,s._tapError=r||br.l,s._tapComplete=i||br.l,(0,wr.T)(n)?(s._context=s,s._tapNext=n):n&&(s._context=n,s._tapNext=n.next||br.l,s._tapError=n.error||br.l,s._tapComplete=n.complete||br.l),s}return r.C6(t,e),t.prototype._next=function(e){try{this._tapNext.call(this._context,e)}catch(e){return void this.destination.error(e)}this.destination.next(e)},t.prototype._error=function(e){try{this._tapError.call(this._context,e)}catch(e){return void this.destination.error(e)}this.destination.error(e)},t.prototype._complete=function(){try{this._tapComplete.call(this._context)}catch(e){return void this.destination.error(e)}return this.destination.complete()},t}(p.v),Tr={leading:!0,trailing:!1};function Sr(e,t){return void 0===t&&(t=Tr),function(n){return n.lift(new Cr(e,!!t.leading,!!t.trailing))}}var Cr=function(){function e(e,t,n){this.durationSelector=e,this.leading=t,this.trailing=n}return e.prototype.call=function(e,t){return t.subscribe(new Ar(e,this.durationSelector,this.leading,this.trailing))},e}(),Ar=function(e){function t(t,n,r,i){var s=e.call(this,t)||this;return s.destination=t,s.durationSelector=n,s._leading=r,s._trailing=i,s._hasValue=!1,s}return r.C6(t,e),t.prototype._next=function(e){this._hasValue=!0,this._sendValue=e,this._throttled||(this._leading?this.send():this.throttle(e))},t.prototype.send=function(){var e=this._hasValue,t=this._sendValue;e&&(this.destination.next(t),this.throttle(t)),this._hasValue=!1,this._sendValue=void 0},t.prototype.throttle=function(e){var t=this.tryDurationSelector(e);t&&this.add(this._throttled=(0,i.tS)(t,new i.zA(this)))},t.prototype.tryDurationSelector=function(e){try{return this.durationSelector(e)}catch(e){return this.destination.error(e),null}},t.prototype.throttlingDone=function(){var e=this._throttled,t=this._trailing;e&&e.unsubscribe(),this._throttled=void 0,t&&this.send()},t.prototype.notifyNext=function(){this.throttlingDone()},t.prototype.notifyComplete=function(){this.throttlingDone()},t}(i.gn);function xr(e,t,n){return void 0===t&&(t=c.b),void 0===n&&(n=Tr),function(r){return r.lift(new kr(e,t,n.leading,n.trailing))}}var kr=function(){function e(e,t,n,r){this.duration=e,this.scheduler=t,this.leading=n,this.trailing=r}return e.prototype.call=function(e,t){return t.subscribe(new Nr(e,this.duration,this.scheduler,this.leading,this.trailing))},e}(),Nr=function(e){function t(t,n,r,i,s){var o=e.call(this,t)||this;return o.duration=n,o.scheduler=r,o.leading=i,o.trailing=s,o._hasTrailingValue=!1,o._trailingValue=null,o}return r.C6(t,e),t.prototype._next=function(e){this.throttled?this.trailing&&(this._trailingValue=e,this._hasTrailingValue=!0):(this.add(this.throttled=this.scheduler.schedule(Or,this.duration,{subscriber:this})),this.leading?this.destination.next(e):this.trailing&&(this._trailingValue=e,this._hasTrailingValue=!0))},t.prototype._complete=function(){this._hasTrailingValue?(this.destination.next(this._trailingValue),this.destination.complete()):this.destination.complete()},t.prototype.clearThrottle=function(){var e=this.throttled;e&&(this.trailing&&this._hasTrailingValue&&(this.destination.next(this._trailingValue),this._trailingValue=null,this._hasTrailingValue=!1),e.unsubscribe(),this.remove(e),this.throttled=null)},t}(p.v);function Or(e){e.subscriber.clearThrottle()}var Dr=n(560);function Rr(e){return void 0===e&&(e=c.b),function(t){return(0,Dr.v)((function(){return t.pipe(Nt((function(t,n){var r=t.current;return{value:n,current:e.now(),last:r}}),{current:e.now(),value:void 0,last:void 0}),(0,Ye.T)((function(e){var t=e.current,n=e.last,r=e.value;return new Pr(r,t-n)})))}))}}var Pr=function(){return function(e,t){this.value=e,this.interval=t}}(),Lr=n(34);function Mr(e,t,n){return void 0===n&&(n=c.b),function(r){var i=ue(e),s=i?+e-n.now():Math.abs(e);return r.lift(new Fr(s,i,t,n))}}var Fr=function(){function e(e,t,n,r){this.waitFor=e,this.absoluteTimeout=t,this.withObservable=n,this.scheduler=r}return e.prototype.call=function(e,t){return t.subscribe(new Vr(e,this.absoluteTimeout,this.waitFor,this.withObservable,this.scheduler))},e}(),Vr=function(e){function t(t,n,r,i,s){var o=e.call(this,t)||this;return o.absoluteTimeout=n,o.waitFor=r,o.withObservable=i,o.scheduler=s,o.scheduleTimeout(),o}return r.C6(t,e),t.dispatchTimeout=function(e){var t=e.withObservable;e._unsubscribeAndRecycle(),e.add((0,i.tS)(t,new i.zA(e)))},t.prototype.scheduleTimeout=function(){var e=this.action;e?this.action=e.schedule(this,this.waitFor):this.add(this.action=this.scheduler.schedule(t.dispatchTimeout,this.waitFor,this))},t.prototype._next=function(t){this.absoluteTimeout||this.scheduleTimeout(),e.prototype._next.call(this,t)},t.prototype._unsubscribe=function(){this.action=void 0,this.scheduler=null,this.withObservable=null},t}(i.gn),Ur=n(7404);function jr(e,t){return void 0===t&&(t=c.b),Mr(e,(0,Ur.$)(new Lr.M),t)}function Br(e){return void 0===e&&(e=c.b),(0,Ye.T)((function(t){return new qr(t,e.now())}))}var qr=function(){return function(e,t){this.value=e,this.timestamp=t}}();function zr(e,t,n){return 0===n?[t]:(e.push(t),e)}function Gr(){return Pt(zr,[])}function Kr(e){return function(t){return t.lift(new Wr(e))}}var Wr=function(){function e(e){this.windowBoundaries=e}return e.prototype.call=function(e,t){var n=new $r(e),r=t.subscribe(n);return r.closed||n.add((0,i.tS)(this.windowBoundaries,new i.zA(n))),r},e}(),$r=function(e){function t(t){var n=e.call(this,t)||this;return n.window=new rn.B7,t.next(n.window),n}return r.C6(t,e),t.prototype.notifyNext=function(){this.openWindow()},t.prototype.notifyError=function(e){this._error(e)},t.prototype.notifyComplete=function(){this._complete()},t.prototype._next=function(e){this.window.next(e)},t.prototype._error=function(e){this.window.error(e),this.destination.error(e)},t.prototype._complete=function(){this.window.complete(),this.destination.complete()},t.prototype._unsubscribe=function(){this.window=null},t.prototype.openWindow=function(){var e=this.window;e&&e.complete();var t=this.destination,n=this.window=new rn.B7;t.next(n)},t}(i.gn);function Hr(e,t){return void 0===t&&(t=0),function(n){return n.lift(new Qr(e,t))}}var Qr=function(){function e(e,t){this.windowSize=e,this.startWindowEvery=t}return e.prototype.call=function(e,t){return t.subscribe(new Jr(e,this.windowSize,this.startWindowEvery))},e}(),Jr=function(e){function t(t,n,r){var i=e.call(this,t)||this;return i.destination=t,i.windowSize=n,i.startWindowEvery=r,i.windows=[new rn.B7],i.count=0,t.next(i.windows[0]),i}return r.C6(t,e),t.prototype._next=function(e){for(var t=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(e);var a=this.count-r+1;if(a>=0&&a%t==0&&!this.closed&&i.shift().complete(),++this.count%t==0&&!this.closed){var c=new rn.B7;i.push(c),n.next(c)}},t.prototype._error=function(e){var t=this.windows;if(t)for(;t.length>0&&!this.closed;)t.shift().error(e);this.destination.error(e)},t.prototype._complete=function(){var e=this.windows;if(e)for(;e.length>0&&!this.closed;)e.shift().complete();this.destination.complete()},t.prototype._unsubscribe=function(){this.count=0,this.windows=null},t}(p.v);function Yr(e){var t=c.b,n=null,r=Number.POSITIVE_INFINITY;return(0,b.m)(arguments[3])&&(t=arguments[3]),(0,b.m)(arguments[2])?t=arguments[2]:(0,ir.k)(arguments[2])&&(r=Number(arguments[2])),(0,b.m)(arguments[1])?t=arguments[1]:(0,ir.k)(arguments[1])&&(n=Number(arguments[1])),function(i){return i.lift(new Xr(e,n,r,t))}}var Xr=function(){function e(e,t,n,r){this.windowTimeSpan=e,this.windowCreationInterval=t,this.maxWindowSize=n,this.scheduler=r}return e.prototype.call=function(e,t){return t.subscribe(new ei(e,this.windowTimeSpan,this.windowCreationInterval,this.maxWindowSize,this.scheduler))},e}(),Zr=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._numberOfNextedValues=0,t}return r.C6(t,e),t.prototype.next=function(t){this._numberOfNextedValues++,e.prototype.next.call(this,t)},Object.defineProperty(t.prototype,"numberOfNextedValues",{get:function(){return this._numberOfNextedValues},enumerable:!0,configurable:!0}),t}(rn.B7),ei=function(e){function t(t,n,r,i,s){var o=e.call(this,t)||this;o.destination=t,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(ri,n,c)),o.add(s.schedule(ni,r,u))}else{var l={subscriber:o,window:a,windowTimeSpan:n};o.add(s.schedule(ti,n,l))}return o}return r.C6(t,e),t.prototype._next=function(e){for(var t=this.windows,n=t.length,r=0;r<n;r++){var i=t[r];i.closed||(i.next(e),i.numberOfNextedValues>=this.maxWindowSize&&this.closeWindow(i))}},t.prototype._error=function(e){for(var t=this.windows;t.length>0;)t.shift().error(e);this.destination.error(e)},t.prototype._complete=function(){for(var e=this.windows;e.length>0;){var t=e.shift();t.closed||t.complete()}this.destination.complete()},t.prototype.openWindow=function(){var e=new Zr;return this.windows.push(e),this.destination.next(e),e},t.prototype.closeWindow=function(e){e.complete();var t=this.windows;t.splice(t.indexOf(e),1)},t}(p.v);function ti(e){var t=e.subscriber,n=e.windowTimeSpan,r=e.window;r&&t.closeWindow(r),e.window=t.openWindow(),this.schedule(e,n)}function ni(e){var t=e.windowTimeSpan,n=e.subscriber,r=e.scheduler,i=e.windowCreationInterval,s=n.openWindow(),o=this,a={action:o,subscription:null},c={subscriber:n,window:s,context:a};a.subscription=r.schedule(ri,t,c),o.add(a.subscription),o.schedule(e,i)}function ri(e){var t=e.subscriber,n=e.window,r=e.context;r&&r.action&&r.subscription&&r.action.remove(r.subscription),t.closeWindow(n)}function ii(e,t){return function(n){return n.lift(new si(e,t))}}var si=function(){function e(e,t){this.openings=e,this.closingSelector=t}return e.prototype.call=function(e,t){return t.subscribe(new oi(e,this.openings,this.closingSelector))},e}(),oi=function(e){function t(t,n,r){var i=e.call(this,t)||this;return i.openings=n,i.closingSelector=r,i.contexts=[],i.add(i.openSubscription=(0,x.F)(i,n,n)),i}return r.C6(t,e),t.prototype._next=function(e){var t=this.contexts;if(t)for(var n=t.length,r=0;r<n;r++)t[r].window.next(e)},t.prototype._error=function(t){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(t),s.subscription.unsubscribe()}e.prototype._error.call(this,t)},t.prototype._complete=function(){var t=this.contexts;if(this.contexts=null,t)for(var n=t.length,r=-1;++r<n;){var i=t[r];i.window.complete(),i.subscription.unsubscribe()}e.prototype._complete.call(this)},t.prototype._unsubscribe=function(){var e=this.contexts;if(this.contexts=null,e)for(var t=e.length,n=-1;++n<t;){var r=e[n];r.window.unsubscribe(),r.subscription.unsubscribe()}},t.prototype.notifyNext=function(e,t,n,r,i){if(e===this.openings){var s=void 0;try{s=(0,this.closingSelector)(t)}catch(e){return this.error(e)}var o=new rn.B7,a=new A.y,c={window:o,subscription:a};this.contexts.push(c);var u=(0,x.F)(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(e))},t.prototype.notifyError=function(e){this.error(e)},t.prototype.notifyComplete=function(e){e!==this.openSubscription&&this.closeWindow(this.contexts.indexOf(e.context))},t.prototype.closeWindow=function(e){if(-1!==e){var t=this.contexts,n=t[e],r=n.window,i=n.subscription;t.splice(e,1),r.complete(),i.unsubscribe()}},t}(k.E);function ai(e){return function(t){return t.lift(new ci(e))}}var ci=function(){function e(e){this.closingSelector=e}return e.prototype.call=function(e,t){return t.subscribe(new ui(e,this.closingSelector))},e}(),ui=function(e){function t(t,n){var r=e.call(this,t)||this;return r.destination=t,r.closingSelector=n,r.openWindow(),r}return r.C6(t,e),t.prototype.notifyNext=function(e,t,n,r,i){this.openWindow(i)},t.prototype.notifyError=function(e){this._error(e)},t.prototype.notifyComplete=function(e){this.openWindow(e)},t.prototype._next=function(e){this.window.next(e)},t.prototype._error=function(e){this.window.error(e),this.destination.error(e),this.unsubscribeClosingNotification()},t.prototype._complete=function(){this.window.complete(),this.destination.complete(),this.unsubscribeClosingNotification()},t.prototype.unsubscribeClosingNotification=function(){this.closingNotification&&this.closingNotification.unsubscribe()},t.prototype.openWindow=function(e){void 0===e&&(e=null),e&&(this.remove(e),e.unsubscribe());var t=this.window;t&&t.complete();var n,r=this.window=new rn.B7;this.destination.next(r);try{n=(0,this.closingSelector)()}catch(e){return this.destination.error(e),void this.window.error(e)}this.add(this.closingNotification=(0,x.F)(this,n))},t}(k.E);function li(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t){var n;"function"==typeof e[e.length-1]&&(n=e.pop());var r=e;return t.lift(new hi(r,n))}}var hi=function(){function e(e,t){this.observables=e,this.project=t}return e.prototype.call=function(e,t){return t.subscribe(new di(e,this.observables,this.project))},e}(),di=function(e){function t(t,n,r){var i=e.call(this,t)||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,x.F)(i,a,void 0,o))}return i}return r.C6(t,e),t.prototype.notifyNext=function(e,t,n){this.values[n]=t;var r=this.toRespond;if(r.length>0){var i=r.indexOf(n);-1!==i&&r.splice(i,1)}},t.prototype.notifyComplete=function(){},t.prototype._next=function(e){if(0===this.toRespond.length){var t=[e].concat(this.values);this.project?this._tryProject(t):this.destination.next(t)}},t.prototype._tryProject=function(e){var t;try{t=this.project.apply(this,e)}catch(e){return void this.destination.error(e)}this.destination.next(t)},t}(k.E),fi=n(4219);function pi(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t){return t.lift.call(fi.yU.apply(void 0,[t].concat(e)))}}function mi(e){return function(t){return t.lift(new fi.ee(e))}}},7272:(e,t,n)=>{"use strict";n.d(t,{C6:()=>i});var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},r(e,t)};function i(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}},6032:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,s){function o(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,i,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=s(n(6765)),a=s(n(2733)),c=n(1673),u=n(1613),l=function(){function e(e){this.clientConfig=e,this.tokenStorageKey="RIO_TOKENS_KEY.".concat(e.projectId)}return e.prototype.setHttp=function(e){this.http=e},e.prototype.storeTokenData=function(e){return r(this,void 0,void 0,(function(){var t,n;return i(this,(function(r){return t=(0,c.getRuntime)(),void 0===e||(t===u.Runtime.web&&(localStorage.setItem(this.tokenStorageKey,JSON.stringify(e)),(null===(n=this.clientConfig)||void 0===n?void 0:n.useCookies)&&a.default.set(this.tokenStorageKey,JSON.stringify(e))),this.currentTokenData=e),[2]}))}))},e.prototype.clearTokenData=function(){return r(this,void 0,void 0,(function(){return i(this,(function(e){return(0,c.getRuntime)()===u.Runtime.web&&(localStorage.removeItem(this.tokenStorageKey),a.default.remove(this.tokenStorageKey)),this.currentTokenData=void 0,[2]}))}))},e.prototype.getCurrentTokenData=function(){return r(this,void 0,void 0,(function(){var e,t,n;return i(this,(function(r){return(0,c.getRuntime)()===u.Runtime.web?((null===(n=this.clientConfig)||void 0===n?void 0:n.useCookies)&&(t=a.default.get(this.tokenStorageKey))&&"undefined"!==t&&(e=JSON.parse(t)),e||(t=localStorage.getItem(this.tokenStorageKey))&&"undefined"!==t&&(e=JSON.parse(t))):e=this.currentTokenData,!e||e.accessTokenDecoded&&e.refreshTokenDecoded||(e.accessTokenDecoded=this.decodeToken(e.accessToken),e.refreshTokenDecoded=this.decodeToken(e.refreshToken)),[2,e]}))}))},e.prototype.getCurrentUser=function(){return r(this,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,this.getCurrentTokenData()];case 1:return[2,null==(e=t.sent())?void 0:e.accessTokenDecoded]}}))}))},e.prototype.getTokenData=function(){return r(this,void 0,void 0,(function(){var e,t,n,r,s,o;return i(this,(function(i){switch(i.label){case 0:return[4,this.getCurrentTokenData()];case 1:return(e=i.sent())?(t=e.diff+Math.round((new Date).getTime()/1e3)+30,e.accessTokenDecoded=this.decodeToken(e.accessToken),e.refreshTokenDecoded=this.decodeToken(e.refreshToken),n=null!==(s=e.accessTokenDecoded.exp)&&void 0!==s?s:0,(null!==(o=e.refreshTokenDecoded.exp)&&void 0!==o?o:0)>t&&n<=t?[4,this.getFreshToken(e.refreshToken,e.accessToken)]:[3,3]):[2,void 0];case 2:return(r=i.sent()).accessTokenDecoded=this.decodeToken(r.accessToken),r.refreshTokenDecoded=this.decodeToken(r.refreshToken),[2,r];case 3:return[2,e]}}))}))},e.prototype.decodeToken=function(e){return(0,o.default)(e)},e.prototype.formatTokenData=function(e){return e.accessTokenDecoded=this.decodeToken(e.accessToken),e.refreshTokenDecoded=this.decodeToken(e.refreshToken),e.accessTokenDecoded.iat&&(e.diff=e.accessTokenDecoded.iat-Math.floor(Date.now()/1e3)),e},e.prototype.getFreshToken=function(e,t){return r(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.http.call(this.clientConfig.projectId,"/TOKEN/refresh",{method:"post",data:{refreshToken:e,accessToken:t}})];case 1:return n=r.sent(),[2,this.formatTokenData(n.data)]}}))}))},e.prototype.signIn=function(e){return r(this,void 0,void 0,(function(){var t;return i(this,(function(n){switch(n.label){case 0:return[4,this.http.call(this.clientConfig.projectId,"/TOKEN/auth",{method:"post",data:{customToken:e}})];case 1:return t=n.sent().data,[2,this.formatTokenData(t)]}}))}))},e.prototype.signOut=function(){return r(this,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return t.trys.push([0,4,,5]),[4,this.getCurrentTokenData()];case 1:return(e=t.sent())?[4,this.http.call(this.clientConfig.projectId,"/TOKEN/signOut",{method:"post",headers:{Authorization:"Bearer ".concat(e.accessToken)}})]:[3,3];case 2:t.sent(),t.label=3;case 3:return[3,5];case 4:return t.sent(),[3,5];case 5:return[2]}}))}))},e.prototype.getAuthStatus=function(e){if(e&&e.accessTokenDecoded){var t=e.accessTokenDecoded;return{uid:t.userId,identity:t.identity,authStatus:u.RetterAuthStatus.SIGNED_IN}}return{authStatus:u.RetterAuthStatus.SIGNED_OUT}},e}();t.default=l},5281:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},r.apply(this,arguments)},i=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,s){function o(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((r=r.apply(e,t||[])).next())}))},s=this&&this.__generator||function(e,t){var n,r,i,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var a=o(n(6425)),c=n(1673),u=n(1613),l=n(7514),h=[{id:u.RetterRegion.euWest1,url:"api.retter.io"},{id:u.RetterRegion.euWest1Beta,url:"test-api.retter.io"}],d=function(){function e(e){var t;this.createAxiosInstance(),this.url=e.url,e.region||(e.region=u.RetterRegion.euWest1),this.region=h.find((function(t){return t.id===e.region})),this.culture=e.culture,this.platform=e.platform,(null===(t=e.memoryCache)||void 0===t?void 0:t.enabled)&&(this.rioFetch=new l.RioCache(this.axiosInstance,e.memoryCache.maxEntryCount,e.memoryCache.enableLogs))}return e.prototype.createAxiosInstance=function(){this.axiosInstance=a.default.create({responseType:"json",headers:{"Content-Type":"application/json"},timeout:3e4})},e.prototype.buildUrl=function(e,t){var n=this.url?"".concat(this.url):"".concat(e,".").concat(this.region.url);return"https://".concat(n,"/").concat(e,"/").concat(t.startsWith("/")?t.substring(1):t)},e.prototype.call=function(e,t,n){return i(this,void 0,void 0,(function(){var i,o,a;return s(this,(function(s){try{return!(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((0,c.sort)(n.data))),delete n.data,i.data=o,i.__isbase64=!0),a=r(r({url:this.buildUrl(e,t)},n),{params:i}),this.rioFetch&&"get"===n.method?[2,this.rioFetch.getWithCache(a)]:[2,this.axiosInstance(a)]}catch(e){throw e}return[2]}))}))},e}();t.default=d},7514:function(e,t){"use strict";var n=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,s){function o(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((r=r.apply(e,t||[])).next())}))},r=this&&this.__generator||function(e,t){var n,r,i,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.RioCache=void 0;var i=function(){function e(e,t,n){void 0===t&&(t=100),void 0===n&&(n=!1),this.cache=new Map,this.pendingRequests=new Map,this.axiosInstance=e,this.maxEntries=t,this.enableLogs=n}return e.prototype.getWithCache=function(e){return n(this,void 0,void 0,(function(){var t,n,i,s,o,a;return r(this,(function(r){switch(r.label){case 0:if(t=Date.now(),n=e.url,i=e.params,!n)throw new Error("Missing url");if(s="".concat(n,"?").concat(new URLSearchParams(i).toString()),this.cache.has(s)){if((o=this.cache.get(s)).expiry>t)return this.enableLogs&&console.log("Serving from cache:",s),this.cache.delete(s),this.cache.set(s,o),[2,o.data];this.cache.delete(s)}if(this.pendingRequests.has(s))return this.enableLogs&&console.log("Waiting for in-progress request: ".concat(s)),[2,this.pendingRequests.get(s)];a=this.getAndCache(s,e),this.pendingRequests.set(s,a),r.label=1;case 1:return r.trys.push([1,,3,4]),[4,a];case 2:return[2,r.sent()];case 3:return this.pendingRequests.delete(s),[7];case 4:return[2]}}))}))},e.prototype.getAndCache=function(e,t){return n(this,void 0,void 0,(function(){var n,i,s,o,a,c,u,l,h,d,f,p,m,g,y,v;return r(this,(function(r){switch(r.label){case 0:return n=Date.now(),[4,this.axiosInstance(t)];case 1:return i=r.sent(),s={status:i.status,statusText:i.statusText,headers:i.headers,data:i.data},o=i.headers["cache-control"],a=i.headers.age,c=i.headers.date,u=null==o?void 0:o.match(/max-age=(\d+)/),l=u?parseInt(u[1],10):0,h=a?parseInt(a,10):0,d=n,c&&(f=Date.parse(c),isNaN(f)||(d=f)),p=1e3*l,m=1e3*h,g=n-d,(y=Math.max(0,p-m-g))>0?(this.cache.size>=this.maxEntries&&(v=Array.from(this.cache.keys())[0],this.cache.delete(v),this.enableLogs&&console.log("Evicted cache entry: ".concat(v))),this.cache.set(e,{data:s,expiry:n+y}),this.enableLogs&&console.log("Caching response with remaining freshness: ".concat(y/1e3,"s"))):this.enableLogs&&console.log("No remaining freshness not caching."),[2,s]}}))}))},e}();t.RioCache=i},1673:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getRuntime=function(){return"undefined"!=typeof document?r.Runtime.web:r.Runtime.node},t.base64Encode=function(e){return Buffer.from(e).toString("base64")},t.sort=function e(t){return null==t?t:Array.isArray(t)?t.sort().map(e):"object"==typeof t?Object.keys(t).sort().reduce((function(n,r){return n[r]=e(t[r]),n}),{}):t};var r=n(1613)},8156:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},r.apply(this,arguments)},i=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),s=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,s){function o(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((r=r.apply(e,t||[])).next())}))},a=this&&this.__generator||function(e,t){var n,r,i,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var u=n(5577),l=n(9815),h=n(5052),d=n(4046),f=n(5758),p=c(n(6032)),m=c(n(5281)),g=n(1613);s(n(1613),t);var y=function(){function e(){this.initialized=!1,this.authQueue=new d.Subject,this.actionQueue=new d.Subject,this.authStatusSubject=new d.ReplaySubject(1),this.cloudObjects=[],this.listeners={}}return e.getInstance=function(t){var n=e.instances.find((function(e){var n;return(null===(n=e.clientConfig)||void 0===n?void 0:n.projectId)===t.projectId}));if(n)return n;var r=new e;return r.init(t),e.instances.push(r),r},e.prototype.init=function(e){var t=this;if(this.initialized)throw new Error("SDK already initialized.");this.initialized=!0,e.retryConfig||(e.retryConfig={}),e.retryConfig.delay||(e.retryConfig.delay=50),e.retryConfig.count||(e.retryConfig.count=3),e.retryConfig.rate||(e.retryConfig.rate=1.5),this.clientConfig=e,this.auth=new p.default(e),this.http=new m.default(e),this.auth.setHttp(this.http),this.processAuthQueue(),this.processActionQueue(),setTimeout((function(){return o(t,void 0,void 0,(function(){var e;return a(this,(function(t){switch(t.label){case 0:return[4,this.auth.getCurrentTokenData()];case 1:return e=t.sent(),this.fireAuthStatus({tokenData:e}),[2]}}))}))}),1)},e.prototype.processAuthQueue=function(){var e=this,t=this.authQueue.pipe((0,f.concatMap)((function(t){return(0,d.defer)((function(){return o(e,void 0,void 0,(function(){var e,n;return a(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.auth.signIn(t.data)];case 1:return e=r.sent(),[2,{action:t,response:e}];case 2:throw n=r.sent(),{action:t,responseError:n};case 3:return[2]}}))}))})).pipe((0,f.materialize)())})),(0,f.share)());t.pipe((0,f.filter)((function(e){return e.hasValue&&"N"===e.kind})),(0,f.map)((function(e){var t;return r(r({},e.value),{tokenData:null===(t=e.value)||void 0===t?void 0:t.response})})),(0,f.switchMap)((function(t){return o(e,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,this.storeTokenData(t)];case 1:return e.sent(),[2,t]}}))}))})),(0,f.switchMap)((function(t){return o(e,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return this.firebaseAuth?[4,(0,h.signOut)(this.firebaseAuth)]:[3,2];case 1:e.sent(),e.label=2;case 2:return this.clearFirebase(),t.tokenData?[4,this.initFirebase(t)]:[3,4];case 3:e.sent(),e.label=4;case 4:return this.fireAuthStatus(t),[2,t]}}))}))}))).subscribe((function(t){var n,r;(null===(n=t.action)||void 0===n?void 0:n.resolve)&&t.action.resolve(null===(r=e.auth)||void 0===r?void 0:r.getAuthStatus(t.tokenData))})),t.pipe((0,f.filter)((function(e){return!1===e.hasValue&&"E"===e.kind}))).subscribe((function(e){var t;if(e.error&&e.error.action&&e.error.action.resolve){var n={authStatus:g.RetterAuthStatus.AUTH_FAILED,message:null===(t=e.error.responseError.response)||void 0===t?void 0:t.data};e.error.action.resolve(n)}})),this.authStatus.subscribe()},e.prototype.processActionQueue=function(){var e=this,t=this.actionQueue.asObservable().pipe((0,f.concatMap)(this.getActionWithTokenData.bind(this)),(0,f.tap)(this.fireAuthStatus.bind(this)),(0,f.filter)((function(e){return null!==e.tokenData})),(0,f.switchMap)((function(t){return o(e,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,this.storeTokenData(t)];case 1:return e.sent(),[2,t]}}))}))})),(0,f.mergeMap)(this.processAction.bind(this)),(0,f.share)());t.pipe((0,f.filter)((function(e){return e.hasValue&&"N"===e.kind}))).subscribe((function(e){e.value&&e.value.action&&e.value.action.resolve&&e.value.response&&e.value.action.resolve(e.value.response)})),t.pipe((0,f.filter)((function(e){return!1===e.hasValue&&"E"===e.kind}))).subscribe((function(e){e.error&&e.error.action&&e.error.action.reject&&e.error.responseError&&e.error.action.reject(e.error.responseError)}))},e.prototype.sendToAuthQueue=function(e){return o(this,void 0,void 0,(function(){var t=this;return a(this,(function(n){return[2,new Promise((function(n,i){t.authQueue.next(r(r({},e),{reject:i,resolve:n}))}))]}))}))},e.prototype.sendToActionQueue=function(e){return o(this,void 0,void 0,(function(){var t=this;return a(this,(function(n){return[2,new Promise((function(n,i){t.actionQueue.next(r(r({},e),{reject:i,resolve:n}))}))]}))}))},e.prototype.getActionWithTokenData=function(e){return o(this,void 0,void 0,(function(){var t,n;return a(this,(function(r){switch(r.label){case 0:return r.trys.push([0,3,,5]),n={action:e},[4,this.auth.getTokenData()];case 1:return n.tokenData=r.sent(),t=n,[4,this.initFirebase(t)];case 2:return r.sent(),[2,t];case 3:return r.sent(),[4,this.signOut()];case 4:return r.sent(),[2,{action:e}];case 5:return[2]}}))}))},e.prototype.fireAuthStatus=function(e){var t=this.auth.getAuthStatus(e.tokenData);this.authStatusSubject.next(t)},e.prototype.storeTokenData=function(e){return o(this,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,this.auth.storeTokenData(e.tokenData)];case 1:return t.sent(),[2]}}))}))},e.prototype.processAction=function(e){var t,n=this;return(null===(t=e.action)||void 0===t?void 0:t.action)===g.RetterActions.EMPTY?(0,d.defer)((function(){return(0,d.of)(r(r({},e),{response:!0}))})).pipe((0,f.materialize)()):(0,d.defer)((function(){return o(n,void 0,void 0,(function(){var t,n,i;return a(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),t=this.getCosEndpoint(e),[4,this.http.call(this.clientConfig.projectId,t.path,t.params)];case 1:return n=s.sent(),[2,r(r({},e),{response:n})];case 2:throw(i=s.sent()).response&&403===i.response.status&&i.response.data&&"ACCESS_DENIED"===i.response.data.code&&this.signOut(),r(r({},e),{responseError:i});case 3:return[2]}}))}))})).pipe((0,f.materialize)())},e.prototype.initFirebase=function(e){return o(this,void 0,void 0,(function(){var t,n;return a(this,(function(r){switch(r.label){case 0:return!(t=null===(n=e.tokenData)||void 0===n?void 0:n.firebase)||this.firebase?[2,e]:(this.firebase=(0,u.initializeApp)({apiKey:t.apiKey,authDomain:t.projectId+".firebaseapp.com",projectId:t.projectId},this.clientConfig.projectId),this.firestore=(0,l.getFirestore)(this.firebase),this.firebaseAuth=(0,h.getAuth)(this.firebase),[4,(0,h.signInWithCustomToken)(this.firebaseAuth,t.customToken)]);case 1:return r.sent(),[2,e]}}))}))},e.prototype.clearFirebase=function(){this.firebase=void 0,this.firestore=void 0,this.firebaseAuth=void 0},e.prototype.getCosEndpoint=function(e){var t,n,i,s,o,a,c,u,l,h=e.action,d=h.data,f={};for(var p in d.queryStringParams||[])f[p]=d.queryStringParams[p];f.__culture=null!==(t=d.culture)&&void 0!==t?t:(null===(n=this.clientConfig)||void 0===n?void 0:n.culture)||"en-us",(d.platform||(null===(i=this.clientConfig)||void 0===i?void 0:i.platform))&&(f.__platform=null!==(s=d.platform)&&void 0!==s?s:null===(o=this.clientConfig)||void 0===o?void 0:o.platform);var m={params:f,method:null!==(a=d.httpMethod)&&void 0!==a?a:"post",data:d.body,base64Encode:null===(c=d.base64Encode)||void 0===c||c,headers:r({},d.headers)},y=null!==(u=d.token)&&void 0!==u?u:null===(l=e.tokenData)||void 0===l?void 0:l.accessToken;if(y&&(m.headers.Authorization="Bearer ".concat(y)),h.action===g.RetterActions.COS_INSTANCE){var v=d.key?"".concat(d.key.name,"!").concat(d.key.value):d.instanceId;return{path:"INSTANCE/".concat(d.classId).concat(v?"/".concat(v):""),params:m}}return h.action===g.RetterActions.COS_STATE?{path:"STATE/".concat(d.classId,"/").concat(d.instanceId),params:m}:h.action===g.RetterActions.COS_LIST?{path:"LIST/".concat(d.classId),params:m}:h.action===g.RetterActions.COS_STATIC_CALL?{path:"CALL/".concat(d.classId,"/").concat(d.method).concat(d.pathParams?"/".concat(d.pathParams):""),params:m}:{path:"CALL/".concat(d.classId,"/").concat(d.method,"/").concat(d.instanceId).concat(d.pathParams?"/".concat(d.pathParams):""),params:m}},e.prototype.getFirebaseListener=function(e,t,n){var r=(0,l.doc)(this.firestore,t,n);return(0,l.onSnapshot)(r,(function(t){for(var n=Object.assign({},t.data()),r=0,i=Object.keys(n);r<i.length;r++){var s=i[r];s.startsWith("__")&&delete n[s]}e.next(n)}))},e.prototype.getFirebaseState=function(e){return o(this,void 0,void 0,(function(){var t,n,r,i,s=this;return a(this,(function(o){switch(o.label){case 0:return t=this.clientConfig.projectId,[4,this.auth.getCurrentUser()];case 1:return n=o.sent(),r=[],[2,{state:{role:{queue:(i={role:new d.ReplaySubject(1),user:new d.ReplaySubject(1),public:new d.ReplaySubject(1)}).role,subscribe:function(o){if(!s.listeners["".concat(t,"_").concat(e.classId,"_").concat(e.instanceId,"_role")]){var a=s.getFirebaseListener(i.role,"/projects/".concat(t,"/classes/").concat(e.classId,"/instances/").concat(e.instanceId,"/roleState"),n.identity);r.push(a),s.listeners["".concat(t,"_").concat(e.classId,"_").concat(e.instanceId,"_role")]=a}return i.role.subscribe(o)}},user:{queue:i.user,subscribe:function(o){if(!s.listeners["".concat(t,"_").concat(e.classId,"_").concat(e.instanceId,"_user")]){var a=s.getFirebaseListener(i.user,"/projects/".concat(t,"/classes/").concat(e.classId,"/instances/").concat(e.instanceId,"/userState"),n.userId);r.push(a),s.listeners["".concat(t,"_").concat(e.classId,"_").concat(e.instanceId,"_user")]=a}return i.user.subscribe(o)}},public:{queue:i.public,subscribe:function(n){if(!s.listeners["".concat(t,"_").concat(e.classId,"_").concat(e.instanceId,"_public")]){var o=s.getFirebaseListener(i.public,"/projects/".concat(t,"/classes/").concat(e.classId,"/instances"),e.instanceId);r.push(o),s.listeners["".concat(t,"_").concat(e.classId,"_").concat(e.instanceId,"_public")]=o}return i.public.subscribe(n)}}},unsubscribers:r}]}}))}))},e.prototype.clearCloudObjects=function(){return o(this,void 0,void 0,(function(){var e;return a(this,(function(t){switch(t.label){case 0:return(e=Object.values(this.listeners)).length>0&&(e.map((function(e){return e()})),this.cloudObjects.map((function(e){var t,n,r,i,s,o;null===(n=null===(t=e.state)||void 0===t?void 0:t.role.queue)||void 0===n||n.complete(),null===(i=null===(r=e.state)||void 0===r?void 0:r.user.queue)||void 0===i||i.complete(),null===(o=null===(s=e.state)||void 0===s?void 0:s.public.queue)||void 0===o||o.complete()}))),this.listeners={},this.cloudObjects.map((function(e){return e.unsubscribers.map((function(e){return e()}))})),this.cloudObjects=[],this.firebaseAuth?[4,(0,h.signOut)(this.firebaseAuth)]:[3,2];case 1:t.sent(),t.label=2;case 2:return this.clearFirebase(),[2]}}))}))},e.prototype.authenticateWithCustomToken=function(e){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.sendToAuthQueue({action:g.RetterActions.SIGN_IN,data:e})];case 1:return[2,t.sent()]}}))}))},e.prototype.signOut=function(){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.clearCloudObjects()];case 1:return e.sent(),[4,this.auth.signOut()];case 2:return e.sent(),[4,this.auth.clearTokenData()];case 3:return e.sent(),this.fireAuthStatus({}),[2]}}))}))},e.prototype.getCurrentUser=function(){return o(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,this.auth.getCurrentUser()];case 1:return[2,e.sent()]}}))}))},e.prototype.getCloudObject=function(e){return o(this,void 0,void 0,(function(){var t,n,i,s,c,u,l,h,d,f,p,m,y,v,b=this;return a(this,(function(w){switch(w.label){case 0:if(!this.initialized)throw new Error("Retter SDK not initialized.");return e.instanceId&&e.useLocal?[4,this.sendToActionQueue({action:g.RetterActions.EMPTY})]:[3,2];case 1:return w.sent(),[3,4];case 2:return[4,this.sendToActionQueue({action:g.RetterActions.COS_INSTANCE,data:e})];case 3:n=w.sent().data,t=n,e.instanceId=t.instanceId,w.label=4;case 4:return(i=this.cloudObjects.find((function(t){return t.config.classId===e.classId&&t.config.instanceId===e.instanceId})))?[2,{call:i.call,state:i.state,listInstances:i.listInstances,getState:i.getState,methods:null!==(p=null==t?void 0:t.methods)&&void 0!==p?p:[],instanceId:e.instanceId,response:i.response,isNewInstance:!1}]:[4,this.getFirebaseState(e)];case 5:return s=w.sent(),c=s.state,u=s.unsubscribers,l=function(t){return o(b,void 0,void 0,(function(){var n;return a(this,(function(i){switch(i.label){case 0:t.retryConfig=r(r({},this.clientConfig.retryConfig),t.retryConfig),i.label=1;case 1:return i.trys.push([1,3,,8]),[4,this.sendToActionQueue({action:g.RetterActions.COS_CALL,data:r(r({},t),{classId:e.classId,instanceId:e.instanceId})})];case 2:return[2,i.sent()];case 3:return n=i.sent(),--t.retryConfig.count,t.retryConfig.delay*=t.retryConfig.rate,n.response&&570===n.response.status&&t.retryConfig.count>0?[4,new Promise((function(e){return setTimeout(e,t.retryConfig.delay)}))]:[3,6];case 4:return i.sent(),[4,l(t)];case 5:return[2,i.sent()];case 6:throw n;case 7:return[3,8];case 8:return[2]}}))}))},h=function(t){return o(b,void 0,void 0,(function(){return a(this,(function(n){switch(n.label){case 0:return[4,this.sendToActionQueue({action:g.RetterActions.COS_STATE,data:r(r({},t),{classId:e.classId,instanceId:e.instanceId})})];case 1:return[2,n.sent()]}}))}))},d=function(t){return o(b,void 0,void 0,(function(){return a(this,(function(n){switch(n.label){case 0:return[4,this.sendToActionQueue({action:g.RetterActions.COS_LIST,data:r(r({},t),{classId:e.classId})})];case 1:return[2,n.sent().data.instanceIds]}}))}))},f={call:l,state:c,getState:h,listInstances:d,methods:null!==(m=null==t?void 0:t.methods)&&void 0!==m?m:[],response:null!==(y=null==t?void 0:t.response)&&void 0!==y?y:null,instanceId:e.instanceId,isNewInstance:null!==(v=null==t?void 0:t.newInstance)&&void 0!==v&&v},this.cloudObjects.push(r(r({},f),{config:e,unsubscribers:u})),[2,f]}}))}))},e.prototype.makeStaticCall=function(e){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:g.RetterActions.COS_STATIC_CALL,data:r(r({},e),{classId:e.classId})})];case 1:return[2,t.sent()]}}))}))},Object.defineProperty(e.prototype,"authStatus",{get:function(){return this.authStatusSubject.asObservable().pipe((0,f.distinctUntilChanged)((function(e,t){return e.authStatus===t.authStatus&&e.identity===t.identity&&e.uid===t.uid})))},enumerable:!1,configurable:!0}),e.instances=[],e}();t.default=y},1613:(e,t)=>{"use strict";var n,r,i,s;Object.defineProperty(t,"__esModule",{value:!0}),t.Runtime=t.RetterAuthStatus=t.RetterActions=t.RetterRegion=void 0,function(e){e[e.euWest1=0]="euWest1",e[e.euWest1Beta=1]="euWest1Beta"}(n||(t.RetterRegion=n={})),function(e){e.EMPTY="EMPTY",e.SIGN_IN="SIGN_IN",e.COS_CALL="COS_CALL",e.COS_LIST="COS_LIST",e.COS_STATE="COS_STATE",e.COS_INSTANCE="COS_INSTANCE",e.COS_STATIC_CALL="COS_STATIC_CALL"}(r||(t.RetterActions=r={})),function(e){e.SIGNED_IN="SIGNED_IN",e.SIGNED_OUT="SIGNED_OUT",e.AUTH_FAILED="AUTH_FAILED"}(i||(t.RetterAuthStatus=i={})),function(e){e.web="web",e.node="node"}(s||(t.Runtime=s={}))},6425:(e,t,n)=>{"use strict";function r(e,t){return function(){return e.apply(t,arguments)}}const{toString:i}=Object.prototype,{getPrototypeOf:s}=Object,o=(a=Object.create(null),e=>{const t=i.call(e);return a[t]||(a[t]=t.slice(8,-1).toLowerCase())});var a;const c=e=>(e=e.toLowerCase(),t=>o(t)===e),u=e=>t=>typeof t===e,{isArray:l}=Array,h=u("undefined"),d=c("ArrayBuffer"),f=u("string"),p=u("function"),m=u("number"),g=e=>null!==e&&"object"==typeof e,y=e=>{if("object"!==o(e))return!1;const t=s(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)},v=c("Date"),b=c("File"),w=c("Blob"),_=c("FileList"),I=c("URLSearchParams"),[E,T,S,C]=["ReadableStream","Request","Response","Headers"].map(c);function A(e,t,{allOwnKeys:n=!1}={}){if(null==e)return;let r,i;if("object"!=typeof e&&(e=[e]),l(e))for(r=0,i=e.length;r<i;r++)t.call(null,e[r],r,e);else{const i=n?Object.getOwnPropertyNames(e):Object.keys(e),s=i.length;let o;for(r=0;r<s;r++)o=i[r],t.call(null,e[o],o,e)}}function x(e,t){t=t.toLowerCase();const n=Object.keys(e);let r,i=n.length;for(;i-- >0;)if(r=n[i],t===r.toLowerCase())return r;return null}const k="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:n.g,N=e=>!h(e)&&e!==k,O=(D="undefined"!=typeof Uint8Array&&s(Uint8Array),e=>D&&e instanceof D);var D;const R=c("HTMLFormElement"),P=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),L=c("RegExp"),M=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};A(n,((n,i)=>{let s;!1!==(s=t(n,i,e))&&(r[i]=s||n)})),Object.defineProperties(e,r)},F="abcdefghijklmnopqrstuvwxyz",V="0123456789",U={DIGIT:V,ALPHA:F,ALPHA_DIGIT:F+F.toUpperCase()+V},j=c("AsyncFunction"),B=(q="function"==typeof setImmediate,z=p(k.postMessage),q?setImmediate:z?(G=`axios@${Math.random()}`,K=[],k.addEventListener("message",(({source:e,data:t})=>{e===k&&t===G&&K.length&&K.shift()()}),!1),e=>{K.push(e),k.postMessage(G,"*")}):e=>setTimeout(e));var q,z,G,K;const W="undefined"!=typeof queueMicrotask?queueMicrotask.bind(k):"undefined"!=typeof process&&process.nextTick||B;var $={isArray:l,isArrayBuffer:d,isBuffer:function(e){return null!==e&&!h(e)&&null!==e.constructor&&!h(e.constructor)&&p(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||p(e.append)&&("formdata"===(t=o(e))||"object"===t&&p(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&d(e.buffer),t},isString:f,isNumber:m,isBoolean:e=>!0===e||!1===e,isObject:g,isPlainObject:y,isReadableStream:E,isRequest:T,isResponse:S,isHeaders:C,isUndefined:h,isDate:v,isFile:b,isBlob:w,isRegExp:L,isFunction:p,isStream:e=>g(e)&&p(e.pipe),isURLSearchParams:I,isTypedArray:O,isFileList:_,forEach:A,merge:function e(){const{caseless:t}=N(this)&&this||{},n={},r=(r,i)=>{const s=t&&x(n,i)||i;y(n[s])&&y(r)?n[s]=e(n[s],r):y(r)?n[s]=e({},r):l(r)?n[s]=r.slice():n[s]=r};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&A(arguments[e],r);return n},extend:(e,t,n,{allOwnKeys:i}={})=>(A(t,((t,i)=>{n&&p(t)?e[i]=r(t,n):e[i]=t}),{allOwnKeys:i}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},toFlatObject:(e,t,n,r)=>{let i,o,a;const c={};if(t=t||{},null==e)return t;do{for(i=Object.getOwnPropertyNames(e),o=i.length;o-- >0;)a=i[o],r&&!r(a,e,t)||c[a]||(t[a]=e[a],c[a]=!0);e=!1!==n&&s(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:o,kindOfTest:c,endsWith:(e,t,n)=>{e=String(e),(void 0===n||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return-1!==r&&r===n},toArray:e=>{if(!e)return null;if(l(e))return e;let t=e.length;if(!m(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},forEachEntry:(e,t)=>{const n=(e&&e[Symbol.iterator]).call(e);let r;for(;(r=n.next())&&!r.done;){const n=r.value;t.call(e,n[0],n[1])}},matchAll:(e,t)=>{let n;const r=[];for(;null!==(n=e.exec(t));)r.push(n);return r},isHTMLForm:R,hasOwnProperty:P,hasOwnProp:P,reduceDescriptors:M,freezeMethods:e=>{M(e,((t,n)=>{if(p(e)&&-1!==["arguments","caller","callee"].indexOf(n))return!1;const r=e[n];p(r)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")}))}))},toObjectSet:(e,t)=>{const n={},r=e=>{e.forEach((e=>{n[e]=!0}))};return l(e)?r(e):r(String(e).split(t)),n},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(e,t,n){return t.toUpperCase()+n})),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:x,global:k,isContextDefined:N,ALPHABET:U,generateString:(e=16,t=U.ALPHA_DIGIT)=>{let n="";const{length:r}=t;for(;e--;)n+=t[Math.random()*r|0];return n},isSpecCompliantForm:function(e){return!!(e&&p(e.append)&&"FormData"===e[Symbol.toStringTag]&&e[Symbol.iterator])},toJSONObject:e=>{const t=new Array(10),n=(e,r)=>{if(g(e)){if(t.indexOf(e)>=0)return;if(!("toJSON"in e)){t[r]=e;const i=l(e)?[]:{};return A(e,((e,t)=>{const s=n(e,r+1);!h(s)&&(i[t]=s)})),t[r]=void 0,i}}return e};return n(e,0)},isAsyncFn:j,isThenable:e=>e&&(g(e)||p(e))&&p(e.then)&&p(e.catch),setImmediate:B,asap:W};function H(e,t,n,r,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),i&&(this.response=i,this.status=i.status?i.status:null)}$.inherits(H,Error,{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:$.toJSONObject(this.config),code:this.code,status:this.status}}});const Q=H.prototype,J={};function Y(e){return $.isPlainObject(e)||$.isArray(e)}function X(e){return $.endsWith(e,"[]")?e.slice(0,-2):e}function Z(e,t,n){return e?e.concat(t).map((function(e,t){return e=X(e),!n&&t?"["+e+"]":e})).join(n?".":""):t}["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((e=>{J[e]={value:e}})),Object.defineProperties(H,J),Object.defineProperty(Q,"isAxiosError",{value:!0}),H.from=(e,t,n,r,i,s)=>{const o=Object.create(Q);return $.toFlatObject(e,o,(function(e){return e!==Error.prototype}),(e=>"isAxiosError"!==e)),H.call(o,e.message,t,n,r,i),o.cause=e,o.name=e.name,s&&Object.assign(o,s),o};const ee=$.toFlatObject($,{},null,(function(e){return/^is[A-Z]/.test(e)}));function te(e,t,n){if(!$.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const r=(n=$.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!$.isUndefined(t[e])}))).metaTokens,i=n.visitor||u,s=n.dots,o=n.indexes,a=(n.Blob||"undefined"!=typeof Blob&&Blob)&&$.isSpecCompliantForm(t);if(!$.isFunction(i))throw new TypeError("visitor must be a function");function c(e){if(null===e)return"";if($.isDate(e))return e.toISOString();if(!a&&$.isBlob(e))throw new H("Blob is not supported. Use a Buffer instead.");return $.isArrayBuffer(e)||$.isTypedArray(e)?a&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function u(e,n,i){let a=e;if(e&&!i&&"object"==typeof e)if($.endsWith(n,"{}"))n=r?n:n.slice(0,-2),e=JSON.stringify(e);else if($.isArray(e)&&function(e){return $.isArray(e)&&!e.some(Y)}(e)||($.isFileList(e)||$.endsWith(n,"[]"))&&(a=$.toArray(e)))return n=X(n),a.forEach((function(e,r){!$.isUndefined(e)&&null!==e&&t.append(!0===o?Z([n],r,s):null===o?n:n+"[]",c(e))})),!1;return!!Y(e)||(t.append(Z(i,n,s),c(e)),!1)}const l=[],h=Object.assign(ee,{defaultVisitor:u,convertValue:c,isVisitable:Y});if(!$.isObject(e))throw new TypeError("data must be an object");return function e(n,r){if(!$.isUndefined(n)){if(-1!==l.indexOf(n))throw Error("Circular reference detected in "+r.join("."));l.push(n),$.forEach(n,(function(n,s){!0===(!($.isUndefined(n)||null===n)&&i.call(t,n,$.isString(s)?s.trim():s,r,h))&&e(n,r?r.concat(s):[s])})),l.pop()}}(e),t}function ne(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,(function(e){return t[e]}))}function re(e,t){this._pairs=[],e&&te(e,this,t)}const ie=re.prototype;function se(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function oe(e,t,n){if(!t)return e;const r=n&&n.encode||se;$.isFunction(n)&&(n={serialize:n});const i=n&&n.serialize;let s;if(s=i?i(t,n):$.isURLSearchParams(t)?t.toString():new re(t,n).toString(r),s){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+s}return e}ie.append=function(e,t){this._pairs.push([e,t])},ie.toString=function(e){const t=e?function(t){return e.call(this,t,ne)}:ne;return this._pairs.map((function(e){return t(e[0])+"="+t(e[1])}),"").join("&")};var ae=class{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){$.forEach(this.handlers,(function(t){null!==t&&e(t)}))}},ce={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},ue={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:re,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const le="undefined"!=typeof window&&"undefined"!=typeof document,he="object"==typeof navigator&&navigator||void 0,de=le&&(!he||["ReactNative","NativeScript","NS"].indexOf(he.product)<0),fe="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,pe=le&&window.location.href||"http://localhost";var me={...Object.freeze({__proto__:null,hasBrowserEnv:le,hasStandardBrowserWebWorkerEnv:fe,hasStandardBrowserEnv:de,navigator:he,origin:pe}),...ue};function ge(e){function t(e,n,r,i){let s=e[i++];if("__proto__"===s)return!0;const o=Number.isFinite(+s),a=i>=e.length;return s=!s&&$.isArray(r)?r.length:s,a?($.hasOwnProp(r,s)?r[s]=[r[s],n]:r[s]=n,!o):(r[s]&&$.isObject(r[s])||(r[s]=[]),t(e,n,r[s],i)&&$.isArray(r[s])&&(r[s]=function(e){const t={},n=Object.keys(e);let r;const i=n.length;let s;for(r=0;r<i;r++)s=n[r],t[s]=e[s];return t}(r[s])),!o)}if($.isFormData(e)&&$.isFunction(e.entries)){const n={};return $.forEachEntry(e,((e,r)=>{t(function(e){return $.matchAll(/\w+|\[(\w*)]/g,e).map((e=>"[]"===e[0]?"":e[1]||e[0]))}(e),r,n,0)})),n}return null}const ye={transitional:ce,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",r=n.indexOf("application/json")>-1,i=$.isObject(e);if(i&&$.isHTMLForm(e)&&(e=new FormData(e)),$.isFormData(e))return r?JSON.stringify(ge(e)):e;if($.isArrayBuffer(e)||$.isBuffer(e)||$.isStream(e)||$.isFile(e)||$.isBlob(e)||$.isReadableStream(e))return e;if($.isArrayBufferView(e))return e.buffer;if($.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let s;if(i){if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return te(e,new me.classes.URLSearchParams,Object.assign({visitor:function(e,t,n,r){return me.isNode&&$.isBuffer(e)?(this.append(t,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((s=$.isFileList(e))||n.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return te(s?{"files[]":e}:e,t&&new t,this.formSerializer)}}return i||r?(t.setContentType("application/json",!1),function(e){if($.isString(e))try{return(0,JSON.parse)(e),$.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(0,JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||ye.transitional,n=t&&t.forcedJSONParsing,r="json"===this.responseType;if($.isResponse(e)||$.isReadableStream(e))return e;if(e&&$.isString(e)&&(n&&!this.responseType||r)){const n=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e)}catch(e){if(n){if("SyntaxError"===e.name)throw H.from(e,H.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:me.classes.FormData,Blob:me.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};$.forEach(["delete","get","head","post","put","patch"],(e=>{ye.headers[e]={}}));var ve=ye;const be=$.toObjectSet(["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"]),we=Symbol("internals");function _e(e){return e&&String(e).trim().toLowerCase()}function Ie(e){return!1===e||null==e?e:$.isArray(e)?e.map(Ie):String(e)}function Ee(e,t,n,r,i){return $.isFunction(r)?r.call(this,t,n):(i&&(t=n),$.isString(t)?$.isString(r)?-1!==t.indexOf(r):$.isRegExp(r)?r.test(t):void 0:void 0)}class Te{constructor(e){e&&this.set(e)}set(e,t,n){const r=this;function i(e,t,n){const i=_e(t);if(!i)throw new Error("header name must be a non-empty string");const s=$.findKey(r,i);(!s||void 0===r[s]||!0===n||void 0===n&&!1!==r[s])&&(r[s||t]=Ie(e))}const s=(e,t)=>$.forEach(e,((e,n)=>i(e,n,t)));if($.isPlainObject(e)||e instanceof this.constructor)s(e,t);else if($.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))s((e=>{const t={};let n,r,i;return e&&e.split("\n").forEach((function(e){i=e.indexOf(":"),n=e.substring(0,i).trim().toLowerCase(),r=e.substring(i+1).trim(),!n||t[n]&&be[n]||("set-cookie"===n?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)})),t})(e),t);else if($.isHeaders(e))for(const[t,r]of e.entries())i(r,t,n);else null!=e&&i(t,e,n);return this}get(e,t){if(e=_e(e)){const n=$.findKey(this,e);if(n){const e=this[n];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}(e);if($.isFunction(t))return t.call(this,e,n);if($.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=_e(e)){const n=$.findKey(this,e);return!(!n||void 0===this[n]||t&&!Ee(0,this[n],n,t))}return!1}delete(e,t){const n=this;let r=!1;function i(e){if(e=_e(e)){const i=$.findKey(n,e);!i||t&&!Ee(0,n[i],i,t)||(delete n[i],r=!0)}}return $.isArray(e)?e.forEach(i):i(e),r}clear(e){const t=Object.keys(this);let n=t.length,r=!1;for(;n--;){const i=t[n];e&&!Ee(0,this[i],i,e,!0)||(delete this[i],r=!0)}return r}normalize(e){const t=this,n={};return $.forEach(this,((r,i)=>{const s=$.findKey(n,i);if(s)return t[s]=Ie(r),void delete t[i];const o=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,((e,t,n)=>t.toUpperCase()+n))}(i):String(i).trim();o!==i&&delete t[i],t[o]=Ie(r),n[o]=!0})),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return $.forEach(this,((n,r)=>{null!=n&&!1!==n&&(t[r]=e&&$.isArray(n)?n.join(", "):n)})),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map((([e,t])=>e+": "+t)).join("\n")}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const n=new this(e);return t.forEach((e=>n.set(e))),n}static accessor(e){const t=(this[we]=this[we]={accessors:{}}).accessors,n=this.prototype;function r(e){const r=_e(e);t[r]||(function(e,t){const n=$.toCamelCase(" "+t);["get","set","has"].forEach((r=>{Object.defineProperty(e,r+n,{value:function(e,n,i){return this[r].call(this,t,e,n,i)},configurable:!0})}))}(n,e),t[r]=!0)}return $.isArray(e)?e.forEach(r):r(e),this}}Te.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),$.reduceDescriptors(Te.prototype,(({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}})),$.freezeMethods(Te);var Se=Te;function Ce(e,t){const n=this||ve,r=t||n,i=Se.from(r.headers);let s=r.data;return $.forEach(e,(function(e){s=e.call(n,s,i.normalize(),t?t.status:void 0)})),i.normalize(),s}function Ae(e){return!(!e||!e.__CANCEL__)}function xe(e,t,n){H.call(this,null==e?"canceled":e,H.ERR_CANCELED,t,n),this.name="CanceledError"}function ke(e,t,n){const r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(new H("Request failed with status code "+n.status,[H.ERR_BAD_REQUEST,H.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}$.inherits(xe,H,{__CANCEL__:!0});const Ne=(e,t,n=3)=>{let r=0;const i=function(e,t){e=e||10;const n=new Array(e),r=new Array(e);let i,s=0,o=0;return t=void 0!==t?t:1e3,function(a){const c=Date.now(),u=r[o];i||(i=c),n[s]=a,r[s]=c;let l=o,h=0;for(;l!==s;)h+=n[l++],l%=e;if(s=(s+1)%e,s===o&&(o=(o+1)%e),c-i<t)return;const d=u&&c-u;return d?Math.round(1e3*h/d):void 0}}(50,250);return function(e,t){let n,r,i=0,s=1e3/t;const o=(t,s=Date.now())=>{i=s,n=null,r&&(clearTimeout(r),r=null),e.apply(null,t)};return[(...e)=>{const t=Date.now(),a=t-i;a>=s?o(e,t):(n=e,r||(r=setTimeout((()=>{r=null,o(n)}),s-a)))},()=>n&&o(n)]}((n=>{const s=n.loaded,o=n.lengthComputable?n.total:void 0,a=s-r,c=i(a);r=s,e({loaded:s,total:o,progress:o?s/o:void 0,bytes:a,rate:c||void 0,estimated:c&&o&&s<=o?(o-s)/c:void 0,event:n,lengthComputable:null!=o,[t?"download":"upload"]:!0})}),n)},Oe=(e,t)=>{const n=null!=e;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},De=e=>(...t)=>$.asap((()=>e(...t)));var Re=me.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,me.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(me.origin),me.navigator&&/(msie|trident)/i.test(me.navigator.userAgent)):()=>!0,Pe=me.hasStandardBrowserEnv?{write(e,t,n,r,i,s){const o=[e+"="+encodeURIComponent(t)];$.isNumber(n)&&o.push("expires="+new Date(n).toGMTString()),$.isString(r)&&o.push("path="+r),$.isString(i)&&o.push("domain="+i),!0===s&&o.push("secure"),document.cookie=o.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function Le(e,t){return e&&!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const Me=e=>e instanceof Se?{...e}:e;function Fe(e,t){t=t||{};const n={};function r(e,t,n,r){return $.isPlainObject(e)&&$.isPlainObject(t)?$.merge.call({caseless:r},e,t):$.isPlainObject(t)?$.merge({},t):$.isArray(t)?t.slice():t}function i(e,t,n,i){return $.isUndefined(t)?$.isUndefined(e)?void 0:r(void 0,e,0,i):r(e,t,0,i)}function s(e,t){if(!$.isUndefined(t))return r(void 0,t)}function o(e,t){return $.isUndefined(t)?$.isUndefined(e)?void 0:r(void 0,e):r(void 0,t)}function a(n,i,s){return s in t?r(n,i):s in e?r(void 0,n):void 0}const c={url:s,method:s,data:s,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:a,headers:(e,t,n)=>i(Me(e),Me(t),0,!0)};return $.forEach(Object.keys(Object.assign({},e,t)),(function(r){const s=c[r]||i,o=s(e[r],t[r],r);$.isUndefined(o)&&s!==a||(n[r]=o)})),n}var Ve=e=>{const t=Fe({},e);let n,{data:r,withXSRFToken:i,xsrfHeaderName:s,xsrfCookieName:o,headers:a,auth:c}=t;if(t.headers=a=Se.from(a),t.url=oe(Le(t.baseURL,t.url),e.params,e.paramsSerializer),c&&a.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),$.isFormData(r))if(me.hasStandardBrowserEnv||me.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if(!1!==(n=a.getContentType())){const[e,...t]=n?n.split(";").map((e=>e.trim())).filter(Boolean):[];a.setContentType([e||"multipart/form-data",...t].join("; "))}if(me.hasStandardBrowserEnv&&(i&&$.isFunction(i)&&(i=i(t)),i||!1!==i&&Re(t.url))){const e=s&&o&&Pe.read(o);e&&a.set(s,e)}return t},Ue="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise((function(t,n){const r=Ve(e);let i=r.data;const s=Se.from(r.headers).normalize();let o,a,c,u,l,{responseType:h,onUploadProgress:d,onDownloadProgress:f}=r;function p(){u&&u(),l&&l(),r.cancelToken&&r.cancelToken.unsubscribe(o),r.signal&&r.signal.removeEventListener("abort",o)}let m=new XMLHttpRequest;function g(){if(!m)return;const r=Se.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders());ke((function(e){t(e),p()}),(function(e){n(e),p()}),{data:h&&"text"!==h&&"json"!==h?m.response:m.responseText,status:m.status,statusText:m.statusText,headers:r,config:e,request:m}),m=null}m.open(r.method.toUpperCase(),r.url,!0),m.timeout=r.timeout,"onloadend"in m?m.onloadend=g:m.onreadystatechange=function(){m&&4===m.readyState&&(0!==m.status||m.responseURL&&0===m.responseURL.indexOf("file:"))&&setTimeout(g)},m.onabort=function(){m&&(n(new H("Request aborted",H.ECONNABORTED,e,m)),m=null)},m.onerror=function(){n(new H("Network Error",H.ERR_NETWORK,e,m)),m=null},m.ontimeout=function(){let t=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const i=r.transitional||ce;r.timeoutErrorMessage&&(t=r.timeoutErrorMessage),n(new H(t,i.clarifyTimeoutError?H.ETIMEDOUT:H.ECONNABORTED,e,m)),m=null},void 0===i&&s.setContentType(null),"setRequestHeader"in m&&$.forEach(s.toJSON(),(function(e,t){m.setRequestHeader(t,e)})),$.isUndefined(r.withCredentials)||(m.withCredentials=!!r.withCredentials),h&&"json"!==h&&(m.responseType=r.responseType),f&&([c,l]=Ne(f,!0),m.addEventListener("progress",c)),d&&m.upload&&([a,u]=Ne(d),m.upload.addEventListener("progress",a),m.upload.addEventListener("loadend",u)),(r.cancelToken||r.signal)&&(o=t=>{m&&(n(!t||t.type?new xe(null,e,m):t),m.abort(),m=null)},r.cancelToken&&r.cancelToken.subscribe(o),r.signal&&(r.signal.aborted?o():r.signal.addEventListener("abort",o)));const y=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(r.url);y&&-1===me.protocols.indexOf(y)?n(new H("Unsupported protocol "+y+":",H.ERR_BAD_REQUEST,e)):m.send(i||null)}))},je=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let n,r=new AbortController;const i=function(e){if(!n){n=!0,o();const t=e instanceof Error?e:this.reason;r.abort(t instanceof H?t:new xe(t instanceof Error?t.message:t))}};let s=t&&setTimeout((()=>{s=null,i(new H(`timeout ${t} of ms exceeded`,H.ETIMEDOUT))}),t);const o=()=>{e&&(s&&clearTimeout(s),s=null,e.forEach((e=>{e.unsubscribe?e.unsubscribe(i):e.removeEventListener("abort",i)})),e=null)};e.forEach((e=>e.addEventListener("abort",i)));const{signal:a}=r;return a.unsubscribe=()=>$.asap(o),a}};const Be=function*(e,t){let n=e.byteLength;if(!t||n<t)return void(yield e);let r,i=0;for(;i<n;)r=i+t,yield e.slice(i,r),i=r},qe=(e,t,n,r)=>{const i=async function*(e,t){for await(const n of async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);const t=e.getReader();try{for(;;){const{done:e,value:n}=await t.read();if(e)break;yield n}}finally{await t.cancel()}}(e))yield*Be(n,t)}(e,t);let s,o=0,a=e=>{s||(s=!0,r&&r(e))};return new ReadableStream({async pull(e){try{const{done:t,value:r}=await i.next();if(t)return a(),void e.close();let s=r.byteLength;if(n){let e=o+=s;n(e)}e.enqueue(new Uint8Array(r))}catch(e){throw a(e),e}},cancel:e=>(a(e),i.return())},{highWaterMark:2})},ze="function"==typeof fetch&&"function"==typeof Request&&"function"==typeof Response,Ge=ze&&"function"==typeof ReadableStream,Ke=ze&&("function"==typeof TextEncoder?(We=new TextEncoder,e=>We.encode(e)):async e=>new Uint8Array(await new Response(e).arrayBuffer()));var We;const $e=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},He=Ge&&$e((()=>{let e=!1;const t=new Request(me.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t})),Qe=Ge&&$e((()=>$.isReadableStream(new Response("").body))),Je={stream:Qe&&(e=>e.body)};var Ye;ze&&(Ye=new Response,["text","arrayBuffer","blob","formData","stream"].forEach((e=>{!Je[e]&&(Je[e]=$.isFunction(Ye[e])?t=>t[e]():(t,n)=>{throw new H(`Response type '${e}' is not supported`,H.ERR_NOT_SUPPORT,n)})})));const Xe={http:null,xhr:Ue,fetch:ze&&(async e=>{let{url:t,method:n,data:r,signal:i,cancelToken:s,timeout:o,onDownloadProgress:a,onUploadProgress:c,responseType:u,headers:l,withCredentials:h="same-origin",fetchOptions:d}=Ve(e);u=u?(u+"").toLowerCase():"text";let f,p=je([i,s&&s.toAbortSignal()],o);const m=p&&p.unsubscribe&&(()=>{p.unsubscribe()});let g;try{if(c&&He&&"get"!==n&&"head"!==n&&0!==(g=await(async(e,t)=>{const n=$.toFiniteNumber(e.getContentLength());return null==n?(async e=>{if(null==e)return 0;if($.isBlob(e))return e.size;if($.isSpecCompliantForm(e)){const t=new Request(me.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return $.isArrayBufferView(e)||$.isArrayBuffer(e)?e.byteLength:($.isURLSearchParams(e)&&(e+=""),$.isString(e)?(await Ke(e)).byteLength:void 0)})(t):n})(l,r))){let e,n=new Request(t,{method:"POST",body:r,duplex:"half"});if($.isFormData(r)&&(e=n.headers.get("content-type"))&&l.setContentType(e),n.body){const[e,t]=Oe(g,Ne(De(c)));r=qe(n.body,65536,e,t)}}$.isString(h)||(h=h?"include":"omit");const i="credentials"in Request.prototype;f=new Request(t,{...d,signal:p,method:n.toUpperCase(),headers:l.normalize().toJSON(),body:r,duplex:"half",credentials:i?h:void 0});let s=await fetch(f);const o=Qe&&("stream"===u||"response"===u);if(Qe&&(a||o&&m)){const e={};["status","statusText","headers"].forEach((t=>{e[t]=s[t]}));const t=$.toFiniteNumber(s.headers.get("content-length")),[n,r]=a&&Oe(t,Ne(De(a),!0))||[];s=new Response(qe(s.body,65536,n,(()=>{r&&r(),m&&m()})),e)}u=u||"text";let y=await Je[$.findKey(Je,u)||"text"](s,e);return!o&&m&&m(),await new Promise(((t,n)=>{ke(t,n,{data:y,headers:Se.from(s.headers),status:s.status,statusText:s.statusText,config:e,request:f})}))}catch(t){if(m&&m(),t&&"TypeError"===t.name&&/fetch/i.test(t.message))throw Object.assign(new H("Network Error",H.ERR_NETWORK,e,f),{cause:t.cause||t});throw H.from(t,t&&t.code,e,f)}})};$.forEach(Xe,((e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}}));const Ze=e=>`- ${e}`,et=e=>$.isFunction(e)||null===e||!1===e;var tt=e=>{e=$.isArray(e)?e:[e];const{length:t}=e;let n,r;const i={};for(let s=0;s<t;s++){let t;if(n=e[s],r=n,!et(n)&&(r=Xe[(t=String(n)).toLowerCase()],void 0===r))throw new H(`Unknown adapter '${t}'`);if(r)break;i[t||"#"+s]=r}if(!r){const e=Object.entries(i).map((([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build")));throw new H("There is no suitable adapter to dispatch the request "+(t?e.length>1?"since :\n"+e.map(Ze).join("\n"):" "+Ze(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return r};function nt(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new xe(null,e)}function rt(e){return nt(e),e.headers=Se.from(e.headers),e.data=Ce.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1),tt(e.adapter||ve.adapter)(e).then((function(t){return nt(e),t.data=Ce.call(e,e.transformResponse,t),t.headers=Se.from(t.headers),t}),(function(t){return Ae(t)||(nt(e),t&&t.response&&(t.response.data=Ce.call(e,e.transformResponse,t.response),t.response.headers=Se.from(t.response.headers))),Promise.reject(t)}))}const it={};["object","boolean","number","function","string","symbol"].forEach(((e,t)=>{it[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}}));const st={};it.transitional=function(e,t,n){function r(e,t){return"[Axios v1.7.9] Transitional option '"+e+"'"+t+(n?". "+n:"")}return(n,i,s)=>{if(!1===e)throw new H(r(i," has been removed"+(t?" in "+t:"")),H.ERR_DEPRECATED);return t&&!st[i]&&(st[i]=!0,console.warn(r(i," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,i,s)}},it.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};var ot={assertOptions:function(e,t,n){if("object"!=typeof e)throw new H("options must be an object",H.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let i=r.length;for(;i-- >0;){const s=r[i],o=t[s];if(o){const t=e[s],n=void 0===t||o(t,s,e);if(!0!==n)throw new H("option "+s+" must be "+n,H.ERR_BAD_OPTION_VALUE)}else if(!0!==n)throw new H("Unknown option "+s,H.ERR_BAD_OPTION)}},validators:it};const at=ot.validators;class ct{constructor(e){this.defaults=e,this.interceptors={request:new ae,response:new ae}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=new Error;const n=t.stack?t.stack.replace(/^.+\n/,""):"";try{e.stack?n&&!String(e.stack).endsWith(n.replace(/^.+\n.+\n/,""))&&(e.stack+="\n"+n):e.stack=n}catch(e){}}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=Fe(this.defaults,t);const{transitional:n,paramsSerializer:r,headers:i}=t;void 0!==n&&ot.assertOptions(n,{silentJSONParsing:at.transitional(at.boolean),forcedJSONParsing:at.transitional(at.boolean),clarifyTimeoutError:at.transitional(at.boolean)},!1),null!=r&&($.isFunction(r)?t.paramsSerializer={serialize:r}:ot.assertOptions(r,{encode:at.function,serialize:at.function},!0)),ot.assertOptions(t,{baseUrl:at.spelling("baseURL"),withXsrfToken:at.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let s=i&&$.merge(i.common,i[t.method]);i&&$.forEach(["delete","get","head","post","put","patch","common"],(e=>{delete i[e]})),t.headers=Se.concat(s,i);const o=[];let a=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(a=a&&e.synchronous,o.unshift(e.fulfilled,e.rejected))}));const c=[];let u;this.interceptors.response.forEach((function(e){c.push(e.fulfilled,e.rejected)}));let l,h=0;if(!a){const e=[rt.bind(this),void 0];for(e.unshift.apply(e,o),e.push.apply(e,c),l=e.length,u=Promise.resolve(t);h<l;)u=u.then(e[h++],e[h++]);return u}l=o.length;let d=t;for(h=0;h<l;){const e=o[h++],t=o[h++];try{d=e(d)}catch(e){t.call(this,e);break}}try{u=rt.call(this,d)}catch(e){return Promise.reject(e)}for(h=0,l=c.length;h<l;)u=u.then(c[h++],c[h++]);return u}getUri(e){return oe(Le((e=Fe(this.defaults,e)).baseURL,e.url),e.params,e.paramsSerializer)}}$.forEach(["delete","get","head","options"],(function(e){ct.prototype[e]=function(t,n){return this.request(Fe(n||{},{method:e,url:t,data:(n||{}).data}))}})),$.forEach(["post","put","patch"],(function(e){function t(t){return function(n,r,i){return this.request(Fe(i||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:r}))}}ct.prototype[e]=t(),ct.prototype[e+"Form"]=t(!0)}));var ut=ct;class lt{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise((function(e){t=e}));const n=this;this.promise.then((e=>{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null})),this.promise.then=e=>{let t;const r=new Promise((e=>{n.subscribe(e),t=e})).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e((function(e,r,i){n.reason||(n.reason=new xe(e,r,i),t(n.reason))}))}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new lt((function(t){e=t})),cancel:e}}}var ht=lt;const dt={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(dt).forEach((([e,t])=>{dt[t]=e}));var ft=dt;const pt=function e(t){const n=new ut(t),i=r(ut.prototype.request,n);return $.extend(i,ut.prototype,n,{allOwnKeys:!0}),$.extend(i,n,null,{allOwnKeys:!0}),i.create=function(n){return e(Fe(t,n))},i}(ve);pt.Axios=ut,pt.CanceledError=xe,pt.CancelToken=ht,pt.isCancel=Ae,pt.VERSION="1.7.9",pt.toFormData=te,pt.AxiosError=H,pt.Cancel=pt.CanceledError,pt.all=function(e){return Promise.all(e)},pt.spread=function(e){return function(t){return e.apply(null,t)}},pt.isAxiosError=function(e){return $.isObject(e)&&!0===e.isAxiosError},pt.mergeConfig=Fe,pt.AxiosHeaders=Se,pt.formToJSON=e=>ge($.isHTMLForm(e)?new FormData(e):e),pt.getAdapter=tt,pt.HttpStatusCode=ft,pt.default=pt,e.exports=pt},6148:(e,t,n)=>{"use strict";n.r(t),n.d(t,{deleteDB:()=>g,openDB:()=>m,unwrap:()=>p,wrap:()=>f});const r=(e,t)=>t.some((t=>e instanceof t));let i,s;const o=new WeakMap,a=new WeakMap,c=new WeakMap,u=new WeakMap,l=new WeakMap;let h={get(e,t,n){if(e instanceof IDBTransaction){if("done"===t)return a.get(e);if("objectStoreNames"===t)return e.objectStoreNames||c.get(e);if("store"===t)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return f(e[t])},set:(e,t,n)=>(e[t]=n,!0),has:(e,t)=>e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e};function d(e){return"function"==typeof e?(t=e)!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?(s||(s=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(t)?function(...e){return t.apply(p(this),e),f(o.get(this))}:function(...e){return f(t.apply(p(this),e))}:function(e,...n){const r=t.call(p(this),e,...n);return c.set(r,e.sort?e.sort():[e]),f(r)}:(e instanceof IDBTransaction&&function(e){if(a.has(e))return;const t=new Promise(((t,n)=>{const r=()=>{e.removeEventListener("complete",i),e.removeEventListener("error",s),e.removeEventListener("abort",s)},i=()=>{t(),r()},s=()=>{n(e.error||new DOMException("AbortError","AbortError")),r()};e.addEventListener("complete",i),e.addEventListener("error",s),e.addEventListener("abort",s)}));a.set(e,t)}(e),r(e,i||(i=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]))?new Proxy(e,h):e);var t}function f(e){if(e instanceof IDBRequest)return function(e){const t=new Promise(((t,n)=>{const r=()=>{e.removeEventListener("success",i),e.removeEventListener("error",s)},i=()=>{t(f(e.result)),r()},s=()=>{n(e.error),r()};e.addEventListener("success",i),e.addEventListener("error",s)}));return t.then((t=>{t instanceof IDBCursor&&o.set(t,e)})).catch((()=>{})),l.set(t,e),t}(e);if(u.has(e))return u.get(e);const t=d(e);return t!==e&&(u.set(e,t),l.set(t,e)),t}const p=e=>l.get(e);function m(e,t,{blocked:n,upgrade:r,blocking:i,terminated:s}={}){const o=indexedDB.open(e,t),a=f(o);return r&&o.addEventListener("upgradeneeded",(e=>{r(f(o.result),e.oldVersion,e.newVersion,f(o.transaction),e)})),n&&o.addEventListener("blocked",(e=>n(e.oldVersion,e.newVersion,e))),a.then((e=>{s&&e.addEventListener("close",(()=>s())),i&&e.addEventListener("versionchange",(e=>i(e.oldVersion,e.newVersion,e)))})).catch((()=>{})),a}function g(e,{blocked:t}={}){const n=indexedDB.deleteDatabase(e);return t&&n.addEventListener("blocked",(e=>t(e.oldVersion,e))),f(n).then((()=>{}))}const y=["get","getKey","getAll","getAllKeys","count"],v=["put","add","delete","clear"],b=new Map;function w(e,t){if(!(e instanceof IDBDatabase)||t in e||"string"!=typeof t)return;if(b.get(t))return b.get(t);const n=t.replace(/FromIndex$/,""),r=t!==n,i=v.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!i&&!y.includes(n))return;const s=async function(e,...t){const s=this.transaction(e,i?"readwrite":"readonly");let o=s.store;return r&&(o=o.index(t.shift())),(await Promise.all([o[n](...t),i&&s.done]))[0]};return b.set(t,s),s}var _;_=h,h={..._,get:(e,t,n)=>w(e,t)||_.get(e,t,n),has:(e,t)=>!!w(e,t)||_.has(e,t)}},1635:(e,t,n)=>{"use strict";n.r(t),n.d(t,{__addDisposableResource:()=>P,__assign:()=>s,__asyncDelegator:()=>S,__asyncGenerator:()=>T,__asyncValues:()=>C,__await:()=>E,__awaiter:()=>p,__classPrivateFieldGet:()=>O,__classPrivateFieldIn:()=>R,__classPrivateFieldSet:()=>D,__createBinding:()=>g,__decorate:()=>a,__disposeResources:()=>M,__esDecorate:()=>u,__exportStar:()=>y,__extends:()=>i,__generator:()=>m,__importDefault:()=>N,__importStar:()=>k,__makeTemplateObject:()=>A,__metadata:()=>f,__param:()=>c,__propKey:()=>h,__read:()=>b,__rest:()=>o,__runInitializers:()=>l,__setFunctionName:()=>d,__spread:()=>w,__spreadArray:()=>I,__spreadArrays:()=>_,__values:()=>v,default:()=>F});var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)};function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var s=function(){return s=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},s.apply(this,arguments)};function o(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}function a(e,t,n,r){var i,s=arguments.length,o=s<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(o=(s<3?i(o):s>3?i(t,n,o):i(t,n))||o);return s>3&&o&&Object.defineProperty(t,n,o),o}function c(e,t){return function(n,r){t(n,r,e)}}function u(e,t,n,r,i,s){function o(e){if(void 0!==e&&"function"!=typeof e)throw new TypeError("Function expected");return e}for(var a,c=r.kind,u="getter"===c?"get":"setter"===c?"set":"value",l=!t&&e?r.static?e:e.prototype:null,h=t||(l?Object.getOwnPropertyDescriptor(l,r.name):{}),d=!1,f=n.length-1;f>=0;f--){var p={};for(var m in r)p[m]="access"===m?{}:r[m];for(var m in r.access)p.access[m]=r.access[m];p.addInitializer=function(e){if(d)throw new TypeError("Cannot add initializers after decoration has completed");s.push(o(e||null))};var g=(0,n[f])("accessor"===c?{get:h.get,set:h.set}:h[u],p);if("accessor"===c){if(void 0===g)continue;if(null===g||"object"!=typeof g)throw new TypeError("Object expected");(a=o(g.get))&&(h.get=a),(a=o(g.set))&&(h.set=a),(a=o(g.init))&&i.unshift(a)}else(a=o(g))&&("field"===c?i.unshift(a):h[u]=a)}l&&Object.defineProperty(l,r.name,h),d=!0}function l(e,t,n){for(var r=arguments.length>2,i=0;i<t.length;i++)n=r?t[i].call(e,n):t[i].call(e);return r?n:void 0}function h(e){return"symbol"==typeof e?e:"".concat(e)}function d(e,t,n){return"symbol"==typeof t&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:n?"".concat(n," ",t):t})}function f(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function p(e,t,n,r){return new(n||(n=Promise))((function(i,s){function o(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((r=r.apply(e,t||[])).next())}))}function m(e,t){var n,r,i,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}var g=Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]};function y(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||g(t,e,n)}function v(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function b(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,s=n.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(r=s.next()).done;)o.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(i)throw i.error}}return o}function w(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(b(arguments[t]));return e}function _(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),i=0;for(t=0;t<n;t++)for(var s=arguments[t],o=0,a=s.length;o<a;o++,i++)r[i]=s[o];return r}function I(e,t,n){if(n||2===arguments.length)for(var r,i=0,s=t.length;i<s;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}function E(e){return this instanceof E?(this.v=e,this):new E(e)}function T(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,i=n.apply(e,t||[]),s=[];return r=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),o("next"),o("throw"),o("return",(function(e){return function(t){return Promise.resolve(t).then(e,u)}})),r[Symbol.asyncIterator]=function(){return this},r;function o(e,t){i[e]&&(r[e]=function(t){return new Promise((function(n,r){s.push([e,t,n,r])>1||a(e,t)}))},t&&(r[e]=t(r[e])))}function a(e,t){try{(n=i[e](t)).value instanceof E?Promise.resolve(n.value.v).then(c,u):l(s[0][2],n)}catch(e){l(s[0][3],e)}var n}function c(e){a("next",e)}function u(e){a("throw",e)}function l(e,t){e(t),s.shift(),s.length&&a(s[0][0],s[0][1])}}function S(e){var t,n;return t={},r("next"),r("throw",(function(e){throw e})),r("return"),t[Symbol.iterator]=function(){return this},t;function r(r,i){t[r]=e[r]?function(t){return(n=!n)?{value:E(e[r](t)),done:!1}:i?i(t):t}:i}}function C(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=v(e),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise((function(r,i){!function(e,t,n,r){Promise.resolve(r).then((function(t){e({value:t,done:n})}),t)}(r,i,(t=e[n](t)).done,t.value)}))}}}function A(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var x=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t};function k(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&g(t,e,n);return x(t,e),t}function N(e){return e&&e.__esModule?e:{default:e}}function O(e,t,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(e):r?r.value:t.get(e)}function D(e,t,n,r,i){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?i.call(e,n):i?i.value=n:t.set(e,n),n}function R(e,t){if(null===t||"object"!=typeof t&&"function"!=typeof t)throw new TypeError("Cannot use 'in' operator on non-object");return"function"==typeof e?t===e:e.has(t)}function P(e,t,n){if(null!=t){if("object"!=typeof t&&"function"!=typeof t)throw new TypeError("Object expected.");var r,i;if(n){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");r=t[Symbol.asyncDispose]}if(void 0===r){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");r=t[Symbol.dispose],n&&(i=r)}if("function"!=typeof r)throw new TypeError("Object not disposable.");i&&(r=function(){try{i.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:r,async:n})}else n&&e.stack.push({async:!0});return t}var L="function"==typeof SuppressedError?SuppressedError:function(e,t,n){var r=new Error(n);return r.name="SuppressedError",r.error=e,r.suppressed=t,r};function M(e){function t(t){e.error=e.hasError?new L(t,e.error,"An error was suppressed during disposal."):t,e.hasError=!0}var n,r=0;return function i(){for(;n=e.stack.pop();)try{if(!n.async&&1===r)return r=0,e.stack.push(n),Promise.resolve().then(i);if(n.dispose){var s=n.dispose.call(n.value);if(n.async)return r|=2,Promise.resolve(s).then(i,(function(e){return t(e),i()}))}else r|=1}catch(e){t(e)}if(1===r)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}()}const F={__extends:i,__assign:s,__rest:o,__decorate:a,__param:c,__metadata:f,__awaiter:p,__generator:m,__createBinding:g,__exportStar:y,__values:v,__read:b,__spread:w,__spreadArrays:_,__spreadArray:I,__await:E,__asyncGenerator:T,__asyncDelegator:S,__asyncValues:C,__makeTemplateObject:A,__importStar:k,__importDefault:N,__classPrivateFieldGet:O,__classPrivateFieldSet:D,__classPrivateFieldIn:R,__addDisposableResource:P,__disposeResources:M}}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var s=t[r]={exports:{}};return e[r].call(s.exports,s,s.exports,n),s.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r=n(8156);return r.default})()));