@retter/sdk 0.9.0 → 0.10.0

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={8449:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r,i,s=n(7517),o=n(5482),a=n(7336),c=n(776),u=n(3844),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-store",O=null;function D(){return O||(O=u.openDB("firebase-heartbeat-database",1,{upgrade:function(e,t){if(0===t)try{e.createObjectStore(N)}catch(e){console.warn(e)}}}).catch((function(e){throw T.create("idb-open",{originalErrorMessage:e.message})}))),O}function R(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,D()];case 1:return t=o.sent(),[4,(n=t.transaction(N)).objectStore(N).get(L(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 P(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,D()];case 1:return n=o.sent(),[4,(r=n.transaction(N,"readwrite")).objectStore(N).put(t,L(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 L(e){return"".concat(e.name,"!").concat(e.options.appId)}var M=function(){function e(e){var t=this;this.container=e,this._heartbeatsCache=null;var n=this.container.getProvider("app").getImmediate();this._storage=new V(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=F(),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=F(),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),U(i)>t)return n.dates.pop(),"break"}else if(i.push({agent:e.agent,dates:[e.date]}),U(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 F(){return(new Date).toISOString().substring(0,10)}var V=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,R(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,P(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,P(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 U(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 M(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)}},7956:(e,t,n)=>{"use strict";var r=n(8449),i=n(776),s=n(7336),o=n(5482),a=n(7517);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=new Map;class Tn extends wn{constructor(e,t,n=!1){super(e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],t,void 0,n),this.eventId=null}async execute(){let e=En.get(this.auth._key());if(!e){try{const t=await async function(e,t){const n=xn(t),r=An(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)}En.set(this.auth._key(),e)}return this.bypassAuthState||En.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 Sn(e,t){return An(e)._set(xn(t),"true")}function Cn(e,t){En.set(e._key(),t)}function An(e){return re(e._redirectPersistence)}function xn(e){return oe("pendingRedirect",e.config.apiKey,e.name)}async function kn(e,t,n=!1){if(r._isFirebaseServerApp(e.app))return Promise.reject(m(e));const i=Ie(e),s=mn(i,t),o=new Tn(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 Nn(e){const t=qt(`${e.uid}:::`);return e._redirectEventId=t,await e.auth._setRedirectUser(e),await e.auth._persistUserIfCurrent(e),t}class On{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 Rn(e);default:return!1}}(e)||(this.hasHandledPotentialRedirect=!0,t||(this.queuedRedirectEvent=e,t=!0)),t}sendToConsumer(e,t){var n;if(e.error&&!Rn(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(Dn(e))}saveEventToCache(e){this.cachedEventUids.add(Dn(e)),this.lastProcessedEventTime=Date.now()}}function Dn(e){return[e.type,e.eventId,e.sessionId,e.tenantId].filter((e=>e)).join("-")}function Rn({type:e,error:t}){return"unknown"===e&&"auth/no-auth-event"===(null==t?void 0:t.code)}async function Pn(e,t={}){return N(e,"GET","/v1/projects",t)}const Ln=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,Mn=/^https?/;function Fn(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(!Mn.test(n))return!1;if(Ln.test(e))return r===e;const i=e.replace(/\./g,"\\.");return new RegExp("^(.+\\."+i+"|"+i+")$","i").test(r)}const Vn=new T(3e4,6e4);function Un(){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 jn(e){return new Promise(((t,n)=>{var r,i,s;function o(){Un(),gapi.load("gapi.iframes",{callback:()=>{t(gapi.iframes.getContext())},ontimeout:()=>{Un(),n(f(e,"network-request-failed"))},timeout:Vn.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 Bn=null,e}))}let Bn=null;const qn=new T(5e3,15e3),zn={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},Gn=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);function Kn(e){const t=e.config;v(t.authDomain,e,"auth-domain-config-required");const n=t.emulator?S(t,"emulator/auth/iframe"):`https://${e.config.authDomain}/__/auth/iframe`,s={apiKey:t.apiKey,appName:e.name,v:r.SDK_VERSION},o=Gn.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 Wn={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"};class $n{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch(e){}}}const Hn=encodeURIComponent("fac");async function Qn(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?`#${Hn}=${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 Jn="webStorageSupport",Yn=class{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=jt,this._completeRedirectFn=kn,this._overrideRedirectResult=Cn}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({},Wn),{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 $n(null);const d=window.open(t||"",c,h);v(d,e,"popup-blocked");try{d.focus()}catch(e){}return new $n(d)}(e,await Qn(e,t,n,_(),r),qt())}async _openRedirect(e,t,n,r){return await this._originValidation(e),i=await Qn(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 Bn=Bn||jn(e),Bn}(e),n=Gt().gapi;return v(n,e,"internal-error"),t.open({where:document.body,url:Kn(e),messageHandlersFilter:n.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:zn,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)}),qn.get());function o(){Gt().clearTimeout(s),n(t)}t.ping(o).then(o,(()=>{r(i)}))}))))}(e),n=new On(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(Jn,{type:Jn},(n=>{var r;const i=null===(r=null==n?void 0:n[0])||void 0===r?void 0:r[Jn];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 Pn(e);for(const e of t)try{if(Fn(e))return}catch(e){}d(e,"unauthorized-domain")}(e)),this.originValidationPromises[t]}get _shouldInitProactively(){return ye()||le()||ge()}};class Xn{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 Zn extends Xn{constructor(e){super("phone"),this.credential=e}static _fromCredential(e){return new Zn(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 er{constructor(){}static assertion(e){return Zn._fromCredential(e)}}er.FACTOR_ID="phone";class tr{static assertionForEnrollment(e,t){return nr._fromSecret(e,t)}static assertionForSignIn(e,t){return nr._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 rr._fromStartTotpMfaEnrollmentResponse(r,n.user.auth)}}tr.FACTOR_ID="totp";class nr extends Xn{constructor(e,t,n){super("totp"),this.otp=e,this.enrollmentId=t,this.secret=n}static _fromSecret(e,t){return new nr(t,void 0,e)}static _fromEnrollmentId(e,t){return new nr(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 rr{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 rr(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(ir(e)||ir(t))&&(r=!0),r&&(ir(e)&&(e=(null===(n=this.auth.currentUser)||void 0===n?void 0:n.email)||"unknownuser"),ir(t)&&(t=this.auth.name)),`otpauth://totp/${t}:${e}?secret=${this.secretKey}&issuer=${t}&algorithm=${this.hashingAlgorithm}&digits=${this.codeLength}`}}function ir(e){return void 0===e||0===(null==e?void 0:e.length)}var sr="@firebase/auth",or="1.7.9";class ar{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 cr=i.getExperimentalSetting("authIdTokenMaxAge")||300;let ur=null;var lr;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="},lr="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:lr,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:ve(lr)},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 ar(t);var t}),"PRIVATE").setInstantiationMode("EXPLICIT")),r.registerVersion(sr,or,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}}(lr)),r.registerVersion(sr,or,"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=On,t.AuthImpl=_e,t.AuthPopup=$n,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=er,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=tr,t.TotpSecret=rr,t.TwitterAuthProvider=nt,t.UserImpl=te,t._assert=v,t._castAuth=Ie,t._clearRedirectOutcomes=function(){En.clear()},t._createError=f,t._fail=d,t._generateEventId=qt,t._getClientVersion=ve,t._getInstance=re,t._getProjectConfig=Pn,t._getRedirectResult=kn,t._getRedirectUrl=Qn,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=Cn,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=Yn,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:Yn,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>cr)return;const r=null==t?void 0:t.token;ur!==r&&(ur=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,kn(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 Sn(s,r.auth);const o=await Nn(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 Sn(o,s.auth);const a=await Nn(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 Sn(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}},6720:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(7956);n(8449),n(776),n(7336),n(5482),n(7517),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},7517:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(5482),i=n(776),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},256:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(8449),i=n(7517),s=n(7336),o=n(776),a=n(2109),c=n(901);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)))}},7336:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r,i,s=n(5482),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])}},776:(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.")}},2109:(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:{})},901:(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:{})},9177:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(8449);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]}})}))},8860:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(6720);Object.keys(r).forEach((function(e){"default"===e||t.hasOwnProperty(e)||Object.defineProperty(t,e,{enumerable:!0,get:function(){return r[e]}})}))},2439:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(256);Object.keys(r).forEach((function(e){"default"===e||t.hasOwnProperty(e)||Object.defineProperty(t,e,{enumerable:!0,get:function(){return r[e]}})}))},7649: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:"/"})}()},8471:(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)}}},9114:(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(9748),i=n(3495),s=n(3768),o=n(8292),a=n(9032),c=n(3234),u=n(157),l=n(5194),h=n(4490),d=n(5190),f=n(4684),p=n(5890),m=n(2271),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(7869),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(1033),E=n(4695),T=n(3140),S=n(4285),C=n(2061),A=n(1221),x=n(3699);function k(e){return!!e&&(e instanceof r.c||"function"==typeof e.lift&&"function"==typeof e.subscribe)}var N=n(2464),O=n(7472),D=n(4167),R=n(6669),P=n(1270),L=n(552),M=n(8375),F=n(72),V=n(2484);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(5334),$=n(410),H=n(2396),Q=n(4821),J=n(2418),Y=n(5474);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(3929);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(3326);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(2016),he=new r.c(A.l);function de(){return he}var fe=n(995);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(3848),ve=n(5629),be=n(3806);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(5779);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(5544),Se=n(7105);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(3879),xe=n(2849),ke=n(8304)},5194:(e,t,n)=>{"use strict";n.d(t,{h:()=>o});var r=n(5890),i=n(9032),s=n(4695),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)},3234:(e,t,n)=>{"use strict";n.d(t,{t:()=>o});var r=n(5890),i=n(9032),s=n(4167),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)},4285:(e,t,n)=>{"use strict";n.d(t,{E:()=>a,I:()=>r});var r,i=n(4821),s=n(995),o=n(5544);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}()},9748:(e,t,n)=>{"use strict";n.d(t,{c:()=>l});var r=n(8375),i=n(3140),s=n(4437),o=n(1952),a=n(8292),c=n(2061),u=n(8304),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}},1952:(e,t,n)=>{"use strict";n.d(t,{I:()=>s});var r=n(8304),i=n(5347),s={closed:!0,next:function(e){},error:function(e){if(r.$.useDeprecatedSynchronousErrorHandling)throw e;(0,i.T)(e)},complete:function(){}}},9089:(e,t,n)=>{"use strict";n.d(t,{E:()=>i});var r=n(5890),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(3140).v)},157:(e,t,n)=>{"use strict";n.d(t,{m:()=>l});var r=n(5890),i=n(9032),s=n(4684),o=n(4695),a=n(1751),c=n(4167),u=n(5329),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}}()},1033:(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}()},9032:(e,t,n)=>{"use strict";n.d(t,{B7:()=>h,PJ:()=>l});var r=n(5890),i=n(9748),s=n(3140),o=n(4695),a=n(4167),c=n(5329),u=n(4437),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)},5329:(e,t,n)=>{"use strict";n.d(t,{Y:()=>i});var r=n(5890),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(4695).y)},3140:(e,t,n)=>{"use strict";n.d(t,{v:()=>l});var r=n(5890),i=n(3929),s=n(1952),o=n(4695),a=n(4437),c=n(8304),u=n(5347),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)},4695:(e,t,n)=>{"use strict";n.d(t,{y:()=>a});var r=n(72),i=n(2418),s=n(3929),o=n(6669),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)}),[])}},8304:(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}}},7582:(e,t,n)=>{"use strict";n.d(t,{gn:()=>c,tS:()=>u,zA:()=>a});var r=n(5890),i=n(3140),s=n(9748),o=n(5629),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}}},3495:(e,t,n)=>{"use strict";n.d(t,{G:()=>c,f:()=>u});var r=n(5890),i=n(9032),s=n(9748),o=n(4695),a=n(2664),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)},5334:(e,t,n)=>{"use strict";n.d(t,{ZS:()=>h,zV:()=>l});var r=n(5890),i=n(2484),s=n(72),o=n(9089),a=n(6942),c=n(925),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)},410:(e,t,n)=>{"use strict";n.d(t,{x:()=>s});var r=n(995),i=n(9993);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))}},2396:(e,t,n)=>{"use strict";n.d(t,{v:()=>o});var r=n(9748),i=n(5474),s=n(4821);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)}))}},4821:(e,t,n)=>{"use strict";n.d(t,{I:()=>s,w:()=>i});var r=n(9748),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}},5474:(e,t,n)=>{"use strict";n.d(t,{H:()=>o});var r=n(9748),i=n(5629),s=n(2849);function o(e,t){return t?(0,s.c)(e,t):e instanceof r.c?e:new r.c((0,i.i)(e))}},925:(e,t,n)=>{"use strict";n.d(t,{c:()=>o});var r=n(9748),i=n(1667),s=n(2918);function o(e,t){return t?(0,s.V)(e,t):new r.c((0,i.v)(e))}},2016:(e,t,n)=>{"use strict";n.d(t,{h:()=>a});var r=n(9748),i=n(2484),s=n(3511),o=n(925);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))}},995:(e,t,n)=>{"use strict";n.d(t,{of:()=>o});var r=n(2484),i=n(925),s=n(2918);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)}},5779:(e,t,n)=>{"use strict";n.d(t,{O4:()=>c});var r=n(5890),i=n(72),s=n(925),o=n(9089),a=n(6942);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)},5544:(e,t,n)=>{"use strict";n.d(t,{$:()=>i});var r=n(9748);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)}},7105:(e,t,n)=>{"use strict";n.d(t,{O:()=>a});var r=n(9748),i=n(5190),s=n(3326),o=n(2484);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)}}},3879:(e,t,n)=>{"use strict";n.d(t,{ee:()=>l,yU:()=>u});var r=n(5890),i=n(925),s=n(72),o=n(3140),a=n(3499),c=n(7582);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)},9993:(e,t,n)=>{"use strict";n.d(t,{K:()=>i});var r=n(3511);function i(){return(0,r.U)(1)}},3806:(e,t,n)=>{"use strict";n.d(t,{p:()=>s});var r=n(5890),i=n(3140);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)},3768:(e,t,n)=>{"use strict";n.d(t,{$:()=>c,k:()=>d});var r=n(5890),i=n(3140),s=n(4695),o=n(9748),a=n(9032);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)},552:(e,t,n)=>{"use strict";n.d(t,{T:()=>s});var r=n(5890),i=n(3140);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)},3511:(e,t,n)=>{"use strict";n.d(t,{U:()=>s});var r=n(9430),i=n(3699);function s(e){return void 0===e&&(e=Number.POSITIVE_INFINITY),(0,r.ZZ)(i.D,e)}},9430:(e,t,n)=>{"use strict";n.d(t,{ZZ:()=>a,qI:()=>l});var r=n(5890),i=n(552),s=n(5474),o=n(7582);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},1751:(e,t,n)=>{"use strict";n.d(t,{QE:()=>o,YZ:()=>c});var r=n(5890),i=n(3140),s=n(4285);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}}()},2664:(e,t,n)=>{"use strict";n.d(t,{B:()=>s});var r=n(5890),i=n(3140);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)},2918:(e,t,n)=>{"use strict";n.d(t,{V:()=>s});var r=n(9748),i=n(4695);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}))}},2849:(e,t,n)=>{"use strict";n.d(t,{c:()=>l});var r=n(9748),i=n(4695),s=n(8292),o=n(2918),a=n(3499),c=n(1840),u=n(5311);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")}},2271:(e,t,n)=>{"use strict";n.d(t,{R:()=>i});var r=n(5890),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(4695).y))},7869:(e,t,n)=>{"use strict";n.d(t,{q:()=>s});var r=n(5890),i=n(1033),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._)},4490:(e,t,n)=>{"use strict";n.d(t,{I:()=>l,$:()=>u});var r=n(5890),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(2271).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(7869).q))(c),l=u},5190:(e,t,n)=>{"use strict";n.d(t,{E:()=>i,b:()=>s});var r=n(2271),i=new(n(7869).q)(r.R),s=i},4684:(e,t,n)=>{"use strict";n.d(t,{g:()=>o,T:()=>s});var r=n(5890),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(2271).R),s=new(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r.C6(t,e),t}(n(7869).q))(i),o=s},3499:(e,t,n)=>{"use strict";function r(){return"function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator"}n.d(t,{lJ:()=>i});var i=r()},8292:(e,t,n)=>{"use strict";n.d(t,{s:()=>r});var r=function(){return"function"==typeof Symbol&&Symbol.observable||"@@observable"}()},4437:(e,t,n)=>{"use strict";n.d(t,{D:()=>r});var r=function(){return"function"==typeof Symbol?Symbol("rxSubscriber"):"@@rxSubscriber_"+Math.random()}()},2464:(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}()},7472:(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}()},4167:(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}()},1270:(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}()},6669:(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}()},8375:(e,t,n)=>{"use strict";n.d(t,{H:()=>i});var r=n(3140);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}},5347:(e,t,n)=>{"use strict";function r(e){setTimeout((function(){throw e}),0)}n.d(t,{T:()=>r})},3699:(e,t,n)=>{"use strict";function r(e){return e}n.d(t,{D:()=>r})},72:(e,t,n)=>{"use strict";n.d(t,{c:()=>r});var r=function(){return Array.isArray||function(e){return e&&"number"==typeof e.length}}()},5311:(e,t,n)=>{"use strict";n.d(t,{X:()=>r});var r=function(e){return e&&"number"==typeof e.length&&"function"!=typeof e}},3929:(e,t,n)=>{"use strict";function r(e){return"function"==typeof e}n.d(t,{T:()=>r})},3326:(e,t,n)=>{"use strict";n.d(t,{k:()=>i});var r=n(72);function i(e){return!(0,r.c)(e)&&e-parseFloat(e)+1>=0}},2418:(e,t,n)=>{"use strict";function r(e){return null!==e&&"object"==typeof e}n.d(t,{G:()=>r})},1840:(e,t,n)=>{"use strict";function r(e){return!!e&&"function"!=typeof e.subscribe&&"function"==typeof e.then}n.d(t,{y:()=>r})},2484:(e,t,n)=>{"use strict";function r(e){return e&&"function"==typeof e.schedule}n.d(t,{m:()=>r})},1221:(e,t,n)=>{"use strict";function r(){}n.d(t,{l:()=>r})},3848:(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})},2061:(e,t,n)=>{"use strict";n.d(t,{F:()=>i,m:()=>s});var r=n(3699);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)}}},5629:(e,t,n)=>{"use strict";n.d(t,{i:()=>l});var r=n(1667),i=n(5347),s=n(3499),o=n(8292),a=n(5311),c=n(1840),u=n(2418),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.")}},1667:(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()}}},6942:(e,t,n)=>{"use strict";n.d(t,{F:()=>a});var r=n(5890),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(3140).v),s=n(5629),o=n(9748);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)}},4930:(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(5890),i=n(7582);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(5190),u=n(7105);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(3140);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(2484);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(4695),x=n(6942),k=n(9089);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(5334);function j(e){return function(t){return t.lift(new U.ZS(e))}}var B=n(72),q=n(5474);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(410);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(9993),$=n(9430);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(4285);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(9748);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(2464),De=n(3806),Re=n(7472);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(4821);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(995);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(552);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(3699);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(3768);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(2061);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(2016);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(3511);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(3495);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(1751);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(3848);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(9032);function sn(e){return e?Kt((function(){return new rn.B7}),e):Kt(new rn.B7)}var on=n(3234);function an(e){return function(t){return Kt(new on.t(e))(t)}}var cn=n(5194);function un(){return function(e){return Kt(new cn.h)(e)}}var ln=n(157);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(5779);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(2664);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(4490),ir=n(3326),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(1221),wr=n(3929);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(2396);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(1270);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(5544);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(3879);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))}}},5058: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(8471)),a=s(n(7649)),c=n(7535),u=n(8183),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},2143: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(4088)),c=n(7535),u=n(8183),l=n(1467),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},1467: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("rio-cache: 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("rio-cache: 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("rio-cache: Evicted cache entry: ".concat(v))),this.cache.set(e,{data:s,expiry:n+y}),this.enableLogs&&console.log("rio-cache: Caching response with remaining freshness: ".concat(y/1e3,"s - ").concat(e))):this.enableLogs&&console.log("rio-cache: No remaining freshness not caching: ".concat(e)),[2,s]}}))}))},e}();t.RioCache=i},7535:(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(8183)},5854: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(9177),l=n(2439),h=n(8860),d=n(9114),f=n(4930),p=c(n(5058)),m=c(n(2143)),g=n(8183);s(n(8183),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,r;return(null===(n=e.clientConfig)||void 0===n?void 0:n.projectId)===t.projectId&&(null===(r=e.clientConfig)||void 0===r?void 0:r.instanceKey)===t.instanceKey}));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,w,_,I,E,T,S,C,A=this;return a(this,(function(x){switch(x.label){case 0:if(!this.initialized)throw new Error("Retter SDK not initialized.");return n={},e.instanceId&&e.useLocal?[4,this.sendToActionQueue({action:g.RetterActions.EMPTY})]:[3,2];case 1:return x.sent(),[3,4];case 2:return[4,this.sendToActionQueue({action:g.RetterActions.COS_INSTANCE,data:e})];case 3:i=x.sent(),s=i.data,c=i.headers,t=s,e.instanceId=t.instanceId,n=null!=c?c:{},x.label=4;case 4:return(u=this.cloudObjects.find((function(t){return t.config.classId===e.classId&&t.config.instanceId===e.instanceId})))?[2,{call:u.call,state:u.state,listInstances:u.listInstances,getState:u.getState,init:null!==(v=null==t?void 0:t.init)&&void 0!==v?v:{},get:null!==(b=null==t?void 0:t.get)&&void 0!==b?b:{},methods:null!==(w=null==t?void 0:t.methods)&&void 0!==w?w:[],instanceId:e.instanceId,response:null!==(_=null==t?void 0:t.response)&&void 0!==_?_:null,headers:n,isNewInstance:!1}]:[4,this.getFirebaseState(e)];case 5:return l=x.sent(),h=l.state,d=l.unsubscribers,f=function(t){return o(A,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,f(t)];case 5:return[2,i.sent()];case 6:throw n;case 7:return[3,8];case 8:return[2]}}))}))},p=function(t){return o(A,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()]}}))}))},m=function(t){return o(A,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]}}))}))},y={call:f,state:h,getState:p,listInstances:m,init:null!==(I=null==t?void 0:t.init)&&void 0!==I?I:{},get:null!==(E=null==t?void 0:t.get)&&void 0!==E?E:{},methods:null!==(T=null==t?void 0:t.methods)&&void 0!==T?T:[],response:null!==(S=null==t?void 0:t.response)&&void 0!==S?S:null,headers:n,instanceId:e.instanceId,isNewInstance:null!==(C=null==t?void 0:t.newInstance)&&void 0!==C&&C},this.cloudObjects.push(r(r({},y),{config:e,unsubscribers:d})),[2,y]}}))}))},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},8183:(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={}))},5890:(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)}},4088:(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},3844:(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)}},5482:(e,t,n)=>{"use strict";n.r(t),n.d(t,{__addDisposableResource:()=>L,__assign:()=>s,__asyncDelegator:()=>S,__asyncGenerator:()=>T,__asyncValues:()=>C,__await:()=>E,__awaiter:()=>p,__classPrivateFieldGet:()=>D,__classPrivateFieldIn:()=>P,__classPrivateFieldSet:()=>R,__createBinding:()=>g,__decorate:()=>a,__disposeResources:()=>F,__esDecorate:()=>u,__exportStar:()=>y,__extends:()=>i,__generator:()=>m,__importDefault:()=>O,__importStar:()=>N,__makeTemplateObject:()=>A,__metadata:()=>f,__param:()=>c,__propKey:()=>h,__read:()=>b,__rest:()=>o,__rewriteRelativeImportExtension:()=>V,__runInitializers:()=>l,__setFunctionName:()=>d,__spread:()=>w,__spreadArray:()=>I,__spreadArrays:()=>_,__values:()=>v,default:()=>U});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},k=function(e){return k=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},k(e)};function N(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n=k(e),r=0;r<n.length;r++)"default"!==n[r]&&g(t,e,n[r]);return x(t,e),t}function O(e){return e&&e.__esModule?e:{default:e}}function D(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 R(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 P(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 L(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 M="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 F(e){function t(t){e.error=e.hasError?new M(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}()}function V(e,t){return"string"==typeof e&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,(function(e,n,r,i,s){return n?t?".jsx":".js":!r||i&&s?r+i+"."+s.toLowerCase()+"js":e})):e}const U={__extends:i,__assign:s,__rest:o,__decorate:a,__param:c,__esDecorate:u,__runInitializers:l,__propKey:h,__setFunctionName:d,__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:N,__importDefault:O,__classPrivateFieldGet:D,__classPrivateFieldSet:R,__classPrivateFieldIn:P,__addDisposableResource:L,__disposeResources:F,__rewriteRelativeImportExtension:V}}},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(5854);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=n(5319),i=n(5844),o=n(6336),s=n(6148);class a{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(e=>{if(function(e){const t=e.getComponent();return"VERSION"===t?.type}(e)){const t=e.getImmediate();return`${t.library}/${t.version}`}return null}).filter(e=>e).join(" ")}}const c="@firebase/app",u="0.14.9",l=new i.Logger("@firebase/app"),h="@firebase/app-compat",d="@firebase/analytics-compat",f="@firebase/analytics",p="@firebase/app-check-compat",m="@firebase/app-check",g="@firebase/auth",y="@firebase/auth-compat",v="@firebase/database",b="@firebase/data-connect",_="@firebase/database-compat",w="@firebase/functions",I="@firebase/functions-compat",E="@firebase/installations",T="@firebase/installations-compat",S="@firebase/messaging",A="@firebase/messaging-compat",O="@firebase/performance",P="@firebase/performance-compat",C="@firebase/remote-config",R="@firebase/remote-config-compat",k="@firebase/storage",N="@firebase/storage-compat",x="@firebase/firestore",D="@firebase/ai",M="@firebase/firestore-compat",L="firebase",j="[DEFAULT]",F={[c]:"fire-core",[h]:"fire-core-compat",[f]:"fire-analytics",[d]:"fire-analytics-compat",[m]:"fire-app-check",[p]:"fire-app-check-compat",[g]:"fire-auth",[y]:"fire-auth-compat",[v]:"fire-rtdb",[b]:"fire-data-connect",[_]:"fire-rtdb-compat",[w]:"fire-fn",[I]:"fire-fn-compat",[E]:"fire-iid",[T]:"fire-iid-compat",[S]:"fire-fcm",[A]:"fire-fcm-compat",[O]:"fire-perf",[P]:"fire-perf-compat",[C]:"fire-rc",[R]:"fire-rc-compat",[k]:"fire-gcs",[N]:"fire-gcs-compat",[x]:"fire-fst",[M]:"fire-fst-compat",[D]:"fire-vertex","fire-js":"fire-js",[L]:"fire-js-all"},V=new Map,U=new Map,q=new Map;function B(e,t){try{e.container.addComponent(t)}catch(n){l.debug(`Component ${t.name} failed to register with FirebaseApp ${e.name}`,n)}}function z(e){const t=e.name;if(q.has(t))return l.debug(`There were multiple attempts to register component ${t}.`),!1;q.set(t,e);for(const t of V.values())B(t,e);for(const t of U.values())B(t,e);return!0}function W(e,t){const n=e.container.getProvider("heartbeat").getImmediate({optional:!0});return n&&n.triggerHeartbeat(),e.container.getProvider(t)}function G(e){return void 0!==e.options}function K(e){return!G(e)&&("authIdToken"in e||"appCheckToken"in e||"releaseOnDeref"in e||"automaticDataCollectionEnabled"in e)}const $=new o.ErrorFactory("app","Firebase",{"no-app":"No Firebase App '{$appName}' has been created - call initializeApp() first","bad-app-name":"Illegal App name: '{$appName}'","duplicate-app":"Firebase App named '{$appName}' already exists with different options or config","app-deleted":"Firebase App named '{$appName}' already deleted","server-app-deleted":"Firebase Server App has been deleted","no-options":"Need to provide options, when not being deployed to hosting via source.","invalid-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance.","invalid-log-argument":"First argument to `onLog` must be null or a function.","idb-open":"Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.","idb-get":"Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.","idb-set":"Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.","idb-delete":"Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.","finalization-registry-not-supported":"FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.","invalid-server-app-environment":"FirebaseServerApp is not for use in browser environments."});class H{constructor(e,t,n){this._isDeleted=!1,this._options={...e},this._config={...t},this._name=t.name,this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled,this._container=n,this.container.addComponent(new r.Component("app",()=>this,"PUBLIC"))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(e){this.checkDestroyed(),this._automaticDataCollectionEnabled=e}get name(){return this.checkDestroyed(),this._name}get options(){return this.checkDestroyed(),this._options}get config(){return this.checkDestroyed(),this._config}get container(){return this._container}get isDeleted(){return this._isDeleted}set isDeleted(e){this._isDeleted=e}checkDestroyed(){if(this.isDeleted)throw $.create("app-deleted",{appName:this._name})}}function Q(e,t){const n=o.base64Decode(e.split(".")[1]);null!==n?void 0!==JSON.parse(n).exp?1e3*JSON.parse(n).exp-(new Date).getTime()<=0&&console.error(`FirebaseServerApp ${t} is invalid: the token has expired.`):console.error(`FirebaseServerApp ${t} is invalid: expiration claim could not be parsed`):console.error(`FirebaseServerApp ${t} is invalid: second part could not be parsed.`)}class J extends H{constructor(e,t,n,r){const i=void 0===t.automaticDataCollectionEnabled||t.automaticDataCollectionEnabled,o={name:n,automaticDataCollectionEnabled:i};void 0!==e.apiKey?super(e,o,r):super(e.options,o,r),this._serverConfig={automaticDataCollectionEnabled:i,...t},this._serverConfig.authIdToken&&Q(this._serverConfig.authIdToken,"authIdToken"),this._serverConfig.appCheckToken&&Q(this._serverConfig.appCheckToken,"appCheckToken"),this._finalizationRegistry=null,"undefined"!=typeof FinalizationRegistry&&(this._finalizationRegistry=new FinalizationRegistry(()=>{this.automaticCleanup()})),this._refCount=0,this.incRefCount(this._serverConfig.releaseOnDeref),this._serverConfig.releaseOnDeref=void 0,t.releaseOnDeref=void 0,Z(c,u,"serverapp")}toJSON(){}get refCount(){return this._refCount}incRefCount(e){this.isDeleted||(this._refCount++,void 0!==e&&null!==this._finalizationRegistry&&this._finalizationRegistry.register(e,this))}decRefCount(){return this.isDeleted?0:--this._refCount}automaticCleanup(){X(this)}get settings(){return this.checkDestroyed(),this._serverConfig}checkDestroyed(){if(this.isDeleted)throw $.create("server-app-deleted")}}function Y(e,t={}){let n=e;"object"!=typeof t&&(t={name:t});const i={name:j,automaticDataCollectionEnabled:!0,...t},s=i.name;if("string"!=typeof s||!s)throw $.create("bad-app-name",{appName:String(s)});if(n||(n=o.getDefaultAppConfig()),!n)throw $.create("no-options");const a=V.get(s);if(a){if(o.deepEqual(n,a.options)&&o.deepEqual(i,a.config))return a;throw $.create("duplicate-app",{appName:s})}const c=new r.ComponentContainer(s);for(const e of q.values())c.addComponent(e);const u=new H(n,i,c);return V.set(s,u),u}async function X(e){let t=!1;const n=e.name;V.has(n)?(t=!0,V.delete(n)):U.has(n)&&e.decRefCount()<=0&&(U.delete(n),t=!0),t&&(await Promise.all(e.container.getProviders().map(e=>e.delete())),e.isDeleted=!0)}function Z(e,t,n){let i=F[e]??e;n&&(i+=`-${n}`);const o=i.match(/\s|\//),s=t.match(/\s|\//);if(o||s){const e=[`Unable to register library "${i}" with version "${t}":`];return o&&e.push(`library name "${i}" contains illegal characters (whitespace or "/")`),o&&s&&e.push("and"),s&&e.push(`version name "${t}" contains illegal characters (whitespace or "/")`),void l.warn(e.join(" "))}z(new r.Component(`${i}-version`,()=>({library:i,version:t}),"VERSION"))}const ee="firebase-heartbeat-store";let te=null;function ne(){return te||(te=s.openDB("firebase-heartbeat-database",1,{upgrade:(e,t)=>{if(0===t)try{e.createObjectStore(ee)}catch(e){console.warn(e)}}}).catch(e=>{throw $.create("idb-open",{originalErrorMessage:e.message})})),te}async function re(e,t){try{const n=(await ne()).transaction(ee,"readwrite"),r=n.objectStore(ee);await r.put(t,ie(e)),await n.done}catch(e){if(e instanceof o.FirebaseError)l.warn(e.message);else{const t=$.create("idb-set",{originalErrorMessage:e?.message});l.warn(t.message)}}}function ie(e){return`${e.name}!${e.options.appId}`}class oe{constructor(e){this.container=e,this._heartbeatsCache=null;const t=this.container.getProvider("app").getImmediate();this._storage=new ae(t),this._heartbeatsCachePromise=this._storage.read().then(e=>(this._heartbeatsCache=e,e))}async triggerHeartbeat(){try{const e=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),t=se();if(null==this._heartbeatsCache?.heartbeats&&(this._heartbeatsCache=await this._heartbeatsCachePromise,null==this._heartbeatsCache?.heartbeats))return;if(this._heartbeatsCache.lastSentHeartbeatDate===t||this._heartbeatsCache.heartbeats.some(e=>e.date===t))return;if(this._heartbeatsCache.heartbeats.push({date:t,agent:e}),this._heartbeatsCache.heartbeats.length>30){const e=function(e){if(0===e.length)return-1;let t=0,n=e[0].date;for(let r=1;r<e.length;r++)e[r].date<n&&(n=e[r].date,t=r);return t}(this._heartbeatsCache.heartbeats);this._heartbeatsCache.heartbeats.splice(e,1)}return this._storage.overwrite(this._heartbeatsCache)}catch(e){l.warn(e)}}async getHeartbeatsHeader(){try{if(null===this._heartbeatsCache&&await this._heartbeatsCachePromise,null==this._heartbeatsCache?.heartbeats||0===this._heartbeatsCache.heartbeats.length)return"";const e=se(),{heartbeatsToSend:t,unsentEntries:n}=function(e,t=1024){const n=[];let r=e.slice();for(const i of e){const e=n.find(e=>e.agent===i.agent);if(e){if(e.dates.push(i.date),ce(n)>t){e.dates.pop();break}}else if(n.push({agent:i.agent,dates:[i.date]}),ce(n)>t){n.pop();break}r=r.slice(1)}return{heartbeatsToSend:n,unsentEntries:r}}(this._heartbeatsCache.heartbeats),r=o.base64urlEncodeWithoutPadding(JSON.stringify({version:2,heartbeats:t}));return this._heartbeatsCache.lastSentHeartbeatDate=e,n.length>0?(this._heartbeatsCache.heartbeats=n,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),r}catch(e){return l.warn(e),""}}}function se(){return(new Date).toISOString().substring(0,10)}class ae{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return!!o.isIndexedDBAvailable()&&o.validateIndexedDBOpenable().then(()=>!0).catch(()=>!1)}async read(){if(await this._canUseIndexedDBPromise){const e=await async function(e){try{const t=(await ne()).transaction(ee),n=await t.objectStore(ee).get(ie(e));return await t.done,n}catch(e){if(e instanceof o.FirebaseError)l.warn(e.message);else{const t=$.create("idb-get",{originalErrorMessage:e?.message});l.warn(t.message)}}}(this.app);return e?.heartbeats?e:{heartbeats:[]}}return{heartbeats:[]}}async overwrite(e){if(await this._canUseIndexedDBPromise){const t=await this.read();return re(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??t.lastSentHeartbeatDate,heartbeats:e.heartbeats})}}async add(e){if(await this._canUseIndexedDBPromise){const t=await this.read();return re(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??t.lastSentHeartbeatDate,heartbeats:[...t.heartbeats,...e.heartbeats]})}}}function ce(e){return o.base64urlEncodeWithoutPadding(JSON.stringify({version:2,heartbeats:e})).length}z(new r.Component("platform-logger",e=>new a(e),"PRIVATE")),z(new r.Component("heartbeat",e=>new oe(e),"PRIVATE")),Z(c,u,"node"),Z(c,u,"cjs2020"),Z("fire-js",""),Object.defineProperty(t,"FirebaseError",{enumerable:!0,get:function(){return o.FirebaseError}}),t.SDK_VERSION="12.10.0",t._DEFAULT_ENTRY_NAME=j,t._addComponent=B,t._addOrOverwriteComponent=function(e,t){e.container.addOrOverwriteComponent(t)},t._apps=V,t._clearComponents=function(){q.clear()},t._components=q,t._getProvider=W,t._isFirebaseApp=G,t._isFirebaseServerApp=function(e){return null!=e&&void 0!==e.settings},t._isFirebaseServerAppSettings=K,t._registerComponent=z,t._removeServiceInstance=function(e,t,n=j){W(e,t).clearInstance(n)},t._serverApps=U,t.deleteApp=X,t.getApp=function(e=j){const t=V.get(e);if(!t&&e===j&&o.getDefaultAppConfig())return Y();if(!t)throw $.create("no-app",{appName:e});return t},t.getApps=function(){return Array.from(V.values())},t.initializeApp=Y,t.initializeServerApp=function(e,t={}){if(o.isBrowser()&&!o.isWebWorker())throw $.create("invalid-server-app-environment");let n,i=t||{};if(e&&(G(e)?n=e.options:K(e)?i=e:n=e),void 0===i.automaticDataCollectionEnabled&&(i.automaticDataCollectionEnabled=!0),n||(n=o.getDefaultAppConfig()),!n)throw $.create("no-options");const s={...i,...n};if(void 0!==s.releaseOnDeref&&delete s.releaseOnDeref,void 0!==i.releaseOnDeref&&"undefined"==typeof FinalizationRegistry)throw $.create("finalization-registry-not-supported",{});const a=""+(c=JSON.stringify(s),[...c].reduce((e,t)=>Math.imul(31,e)+t.charCodeAt(0)|0,0));var c;const u=U.get(a);if(u)return u.incRefCount(i.releaseOnDeref),u;const l=new r.ComponentContainer(a);for(const e of q.values())l.addComponent(e);const h=new J(n,i,a,l);return U.set(a,h),h},t.onLog=function(e,t){if(null!==e&&"function"!=typeof e)throw $.create("invalid-log-argument");i.setUserLogHandler(e,t)},t.registerVersion=Z,t.setLogLevel=function(e){i.setLogLevel(e)}},6259(e,t,n){"use strict";var r=n(6199),i=n(6336),o=n(5844),s=n(5319);const a=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."}},c=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."}),u=new o.Logger("@firebase/auth");function l(e,...t){u.logLevel<=o.LogLevel.ERROR&&u.error(`Auth (${r.SDK_VERSION}): ${e}`,...t)}function h(e,...t){throw g(e,...t)}function d(e,...t){return g(e,...t)}function f(e,t,n){const r={...a(),[t]:n};return new i.ErrorFactory("auth","Firebase",r).create(t,{appName:e.name})}function p(e){return f(e,"operation-not-supported-in-this-environment","Operations that alter the current user are not supported in conjunction with FirebaseServerApp")}function m(e,t,n){if(!(t instanceof n))throw n.name!==t.constructor.name&&h(e,"argument-error"),f(e,"argument-error",`Type of ${t.constructor.name} does not match expected instance.Did you pass a reference from a different Auth SDK?`)}function g(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 c.create(e,...t)}function y(e,t,...n){if(!e)throw g(t,...n)}function v(e){const t="INTERNAL ASSERTION FAILED: "+e;throw l(t),new Error(t)}function b(e,t){e||v(t)}function _(){return"undefined"!=typeof self&&self.location?.href||""}function w(){return"http:"===I()||"https:"===I()}function I(){return"undefined"!=typeof self&&self.location?.protocol||null}class E{constructor(e,t){this.shortDelay=e,this.longDelay=t,b(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&&(w()||i.isBrowserExtension()||"connection"in navigator)&&!navigator.onLine?Math.min(5e3,this.shortDelay):this.isMobile?this.longDelay:this.shortDelay}}function T(e,t){b(e.emulator,"Emulator should always be set here");const{url:n}=e.emulator;return t?`${n}${t.startsWith("/")?t.slice(1):t}`:n}class S{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 v("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 v("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 v("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"},O=["/v1/accounts:signInWithCustomToken","/v1/accounts:signInWithEmailLink","/v1/accounts:signInWithIdp","/v1/accounts:signInWithPassword","/v1/accounts:signInWithPhoneNumber","/v1/token"],P=new E(3e4,6e4);function C(e,t){return e.tenantId&&!t.tenantId?{...t,tenantId:e.tenantId}:t}async function R(e,t,n,r,o={}){return k(e,o,async()=>{let o={},s={};r&&("GET"===t?s=r:o={body:JSON.stringify(r)});const a=i.querystring({key:e.config.apiKey,...s}).slice(1),c=await e._getAdditionalHeaders();c["Content-Type"]="application/json",e.languageCode&&(c["X-Firebase-Locale"]=e.languageCode);const u={method:t,headers:c,...o};return i.isCloudflareWorker()||(u.referrerPolicy="no-referrer"),e.emulatorConfig&&i.isCloudWorkstation(e.emulatorConfig.host)&&(u.credentials="include"),S.fetch()(await x(e,e.config.apiHost,n,a),u)})}async function k(e,t,n){e._canInitEmulator=!1;const r={...A,...t};try{const t=new M(e),i=await Promise.race([n(),t.promise]);t.clearNetworkTimeout();const o=await i.json();if("needConfirmation"in o)throw L(e,"account-exists-with-different-credential",o);if(i.ok&&!("errorMessage"in o))return o;{const t=i.ok?o.errorMessage:o.error.message,[n,s]=t.split(" : ");if("FEDERATED_USER_ID_ALREADY_LINKED"===n)throw L(e,"credential-already-in-use",o);if("EMAIL_EXISTS"===n)throw L(e,"email-already-in-use",o);if("USER_DISABLED"===n)throw L(e,"user-disabled",o);const a=r[n]||n.toLowerCase().replace(/[_\s]+/g,"-");if(s)throw f(e,a,s);h(e,a)}}catch(t){if(t instanceof i.FirebaseError)throw t;h(e,"network-request-failed",{message:String(t)})}}async function N(e,t,n,r,i={}){const o=await R(e,t,n,r,i);return"mfaPendingCredential"in o&&h(e,"multi-factor-auth-required",{_serverResponse:o}),o}async function x(e,t,n,r){const i=`${t}${n}?${r}`,o=e,s=o.config.emulator?T(e.config,i):`${e.config.apiScheme}://${i}`;return O.includes(n)&&(await o._persistenceManagerAvailable,"COOKIE"===o._getPersistenceType())?o._getPersistence()._getFinalTarget(s).toString():s}function D(e){switch(e){case"ENFORCE":return"ENFORCE";case"AUDIT":return"AUDIT";case"OFF":return"OFF";default:return"ENFORCEMENT_STATE_UNSPECIFIED"}}class M{clearNetworkTimeout(){clearTimeout(this.timer)}constructor(e){this.auth=e,this.timer=null,this.promise=new Promise((e,t)=>{this.timer=setTimeout(()=>t(d(this.auth,"network-request-failed")),P.get())})}}function L(e,t,n){const r={appName:e.name};n.email&&(r.email=n.email),n.phoneNumber&&(r.phoneNumber=n.phoneNumber);const i=d(e,t,r);return i.customData._tokenResponse=n,i}function j(e){return void 0!==e&&void 0!==e.getResponse}function F(e){return void 0!==e&&void 0!==e.enterprise}class V{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 D(t.enforcementState);return null}isProviderEnabled(e){return"ENFORCE"===this.getProviderEnforcementState(e)||"AUDIT"===this.getProviderEnforcementState(e)}isAnyProviderEnabled(){return this.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")||this.isProviderEnabled("PHONE_PROVIDER")}}async function U(e,t){return R(e,"GET","/v2/recaptchaConfig",C(e,t))}async function q(e,t){return R(e,"POST","/v1/accounts:lookup",t)}function B(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),o=G(r);y(o&&o.exp&&o.auth_time&&o.iat,n.auth,"internal-error");const s="object"==typeof o.firebase?o.firebase:void 0,a=s?.sign_in_provider;return{claims:o,token:r,authTime:B(W(o.auth_time)),issuedAtTime:B(W(o.iat)),expirationTime:B(W(o.exp)),signInProvider:a||null,signInSecondFactor:s?.sign_in_second_factor||null}}function W(e){return 1e3*Number(e)}function G(e){const[t,n,r]=e.split(".");if(void 0===t||void 0===n||void 0===r)return l("JWT malformed, contained fewer than 3 sections"),null;try{const e=i.base64Decode(n);return e?JSON.parse(e):(l("Failed to decode base64 JWT payload"),null)}catch(e){return l("Caught error parsing JWT payload as JSON",e?.toString()),null}}function K(e){const t=G(e);return y(t,"internal-error"),y(void 0!==t.exp,"internal-error"),y(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){if(e){const e=this.errorBackoff;return this.errorBackoff=Math.min(2*this.errorBackoff,96e4),e}{this.errorBackoff=3e4;const e=(this.user.stsTokenManager.expirationTime??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"===e?.code&&this.schedule(!0))}this.schedule()}}class Q{constructor(e,t){this.createdAt=e,this.lastLoginAt=t,this._initializeTime()}_initializeTime(){this.lastSignInTime=B(this.lastLoginAt),this.creationTime=B(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){const t=e.auth,n=await e.getIdToken(),r=await $(e,q(t,{idToken:n}));y(r?.users.length,t,"internal-error");const i=r.users[0];e._notifyReloadListener(i);const o=i.providerUserInfo?.length?X(i.providerUserInfo):[],s=(a=e.providerData,c=o,[...a.filter(e=>!c.some(t=>t.providerId===e.providerId)),...c]);var a,c;const u=e.isAnonymous,l=!(e.email&&i.passwordHash||s?.length),h=!!u&&l,d={uid:i.localId,displayName:i.displayName||null,photoURL:i.photoUrl||null,email:i.email||null,emailVerified:i.emailVerified||!1,phoneNumber:i.phoneNumber||null,tenantId:i.tenantId||null,providerData:s,metadata:new Q(i.createdAt,i.lastLoginAt),isAnonymous:h};Object.assign(e,d)}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(({providerId:e,...t})=>({providerId:e,uid:t.rawId||"",displayName:t.displayName||null,email:t.email||null,phoneNumber:t.phoneNumber||null,photoURL:t.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){y(e.idToken,"internal-error"),y(void 0!==e.idToken,"internal-error"),y(void 0!==e.refreshToken,"internal-error");const t="expiresIn"in e&&void 0!==e.expiresIn?Number(e.expiresIn):K(e.idToken);this.updateTokensAndExpiration(e.idToken,e.refreshToken,t)}updateFromIdToken(e){y(0!==e.length,"internal-error");const t=K(e);this.updateTokensAndExpiration(e,null,t)}async getToken(e,t=!1){return t||!this.accessToken||this.isExpired?(y(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:o}=await async function(e,t){const n=await k(e,{},async()=>{const n=i.querystring({grant_type:"refresh_token",refresh_token:t}).slice(1),{tokenApiHost:r,apiKey:o}=e.config,s=await x(e,r,"/v1/token",`key=${o}`),a=await e._getAdditionalHeaders();a["Content-Type"]="application/x-www-form-urlencoded";const c={method:"POST",headers:a,body:n};return e.emulatorConfig&&i.isCloudWorkstation(e.emulatorConfig.host)&&(c.credentials="include"),S.fetch()(s,c)});return{accessToken:n.access_token,expiresIn:n.expires_in,refreshToken:n.refresh_token}}(e,t);this.updateTokensAndExpiration(n,r,Number(o))}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,o=new Z;return n&&(y("string"==typeof n,"internal-error",{appName:e}),o.refreshToken=n),r&&(y("string"==typeof r,"internal-error",{appName:e}),o.accessToken=r),i&&(y("number"==typeof i,"internal-error",{appName:e}),o.expirationTime=i),o}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 v("not implemented")}}function ee(e,t){y("string"==typeof e||void 0===e,"internal-error",{appName:t})}class te{constructor({uid:e,auth:t,stsTokenManager:n,...r}){this.providerId="firebase",this.proactiveRefresh=new H(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=e,this.auth=t,this.stsTokenManager=n,this.accessToken=n.accessToken,this.displayName=r.displayName||null,this.email=r.email||null,this.emailVerified=r.emailVerified||!1,this.phoneNumber=r.phoneNumber||null,this.photoURL=r.photoURL||null,this.isAnonymous=r.isAnonymous||!1,this.tenantId=r.tenantId||null,this.providerData=r.providerData?[...r.providerData]:[],this.metadata=new Q(r.createdAt||void 0,r.lastLoginAt||void 0)}async getIdToken(e){const t=await $(this,this.stsTokenManager.getToken(this.auth,e));return y(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&&(y(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=>({...e})),this.metadata._copy(e.metadata),this.stsTokenManager._assign(e.stsTokenManager))}_clone(e){const t=new te({...this,auth:e,stsTokenManager:this.stsTokenManager._clone()});return t.metadata._copy(this.metadata),t}_onReload(e){y(!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(p(this.auth));const e=await this.getIdToken();return await $(this,async function(e,t){return R(e,"POST","/v1/accounts:delete",t)}(this.auth,{idToken:e})),this.stsTokenManager.clearRefreshToken(),this.auth.signOut()}toJSON(){return{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=>({...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){const n=t.displayName??void 0,r=t.email??void 0,i=t.phoneNumber??void 0,o=t.photoURL??void 0,s=t.tenantId??void 0,a=t._redirectEventId??void 0,c=t.createdAt??void 0,u=t.lastLoginAt??void 0,{uid:l,emailVerified:h,isAnonymous:d,providerData:f,stsTokenManager:p}=t;y(l&&p,e,"internal-error");const m=Z.fromJSON(this.name,p);y("string"==typeof l,e,"internal-error"),ee(n,e.name),ee(r,e.name),y("boolean"==typeof h,e,"internal-error"),y("boolean"==typeof d,e,"internal-error"),ee(i,e.name),ee(o,e.name),ee(s,e.name),ee(a,e.name),ee(c,e.name),ee(u,e.name);const g=new te({uid:l,auth:e,email:r,emailVerified:h,displayName:n,isAnonymous:d,photoURL:o,phoneNumber:i,tenantId:s,stsTokenManager:m,createdAt:c,lastLoginAt:u});return f&&Array.isArray(f)&&(g.providerData=f.map(e=>({...e}))),a&&(g._redirectEventId=a),g}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];y(void 0!==r.localId,"internal-error");const i=void 0!==r.providerUserInfo?X(r.providerUserInfo):[],o=!(r.email&&r.passwordHash||i?.length),s=new Z;s.updateFromIdToken(n);const a=new te({uid:r.localId,auth:e,stsTokenManager:s,isAnonymous:o}),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||i?.length)};return Object.assign(a,c),a}}const ne=new Map;function re(e){b(e instanceof Function,"Expected a class definition");let t=ne.get(e);return t?(b(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 oe=ie;function se(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=se(this.userKey,r.apiKey,i),this.fullPersistenceKey=se("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);if(!e)return null;if("string"==typeof e){const t=await q(this.auth,{idToken:e}).catch(()=>{});return t?te._fromGetAccountInfoResponse(this.auth,t,e):null}return te._fromJSON(this.auth,e)}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(oe),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(oe);const o=se(n,e.config.apiKey,e.name);let s=null;for(const n of t)try{const t=await n._get(o);if(t){let r;if("string"==typeof t){const n=await q(e,{idToken:t}).catch(()=>{});if(!n)break;r=await te._fromGetAccountInfoResponse(e,n,t)}else r=te._fromJSON(e,t);n!==i&&(s=r),i=n;break}}catch{}const a=r.filter(e=>e._shouldAllowMigration);return i._shouldAllowMigration&&a.length?(i=a[0],s&&await i._set(o,s.toJSON()),await Promise.all(t.map(async e=>{if(e!==i)try{await e._remove(o)}catch{}})),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===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 o=t.length?t.join(","):"FirebaseCore-web";return`${n}/JsCore/${r.SDK_VERSION}/${o}`}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:e?.message})}}}class _e{constructor(e){const t=e.customStrengthOptions;this.customStrengthOptions={},this.customStrengthOptions.minPasswordLength=t.minPasswordLength??6,t.maxPasswordLength&&(this.customStrengthOptions.maxPasswordLength=t.maxPasswordLength),void 0!==t.containsLowercaseCharacter&&(this.customStrengthOptions.containsLowercaseLetter=t.containsLowercaseCharacter),void 0!==t.containsUppercaseCharacter&&(this.customStrengthOptions.containsUppercaseLetter=t.containsUppercaseCharacter),void 0!==t.containsNumericCharacter&&(this.customStrengthOptions.containsNumericCharacter=t.containsNumericCharacter),void 0!==t.containsNonAlphanumericCharacter&&(this.customStrengthOptions.containsNonAlphanumericCharacter=t.containsNonAlphanumericCharacter),this.enforcementState=e.enforcementState,"ENFORCEMENT_STATE_UNSPECIFIED"===this.enforcementState&&(this.enforcementState="OFF"),this.allowedNonAlphanumericCharacters=e.allowedNonAlphanumericCharacters?.join("")??"",this.forceUpgradeOnSignin=e.forceUpgradeOnSignin??!1,this.schemaVersion=e.schemaVersion}validatePassword(e){const t={isValid:!0,passwordPolicy:this};return this.validatePasswordLengthOptions(e,t),this.validatePasswordCharacterOptions(e,t),t.isValid&&(t.isValid=t.meetsMinPasswordLength??!0),t.isValid&&(t.isValid=t.meetsMaxPasswordLength??!0),t.isValid&&(t.isValid=t.containsLowercaseLetter??!0),t.isValid&&(t.isValid=t.containsUppercaseLetter??!0),t.isValid&&(t.isValid=t.containsNumericCharacter??!0),t.isValid&&(t.isValid=t.containsNonAlphanumericCharacter??!0),t}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 we{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=c,this._agentRecaptchaConfig=null,this._tenantRecaptchaConfigs={},this._projectPasswordPolicy=null,this._tenantPasswordPolicies={},this._resolvePersistenceManagerAvailable=void 0,this.lastNotifiedUid=void 0,this.languageCode=null,this.tenantId=null,this.settings={appVerificationDisabledForTesting:!1},this.frameworks=[],this.name=e.name,this.clientVersion=r.sdkClientVersion,this._persistenceManagerAvailable=new Promise(e=>this._resolvePersistenceManagerAvailable=e)}_initializeWithPersistence(e,t){return t&&(this._popupRedirectResolver=re(t)),this._initializationPromise=this.queue(async()=>{if(!this._deleted&&(this.persistenceManager=await ae.create(this,e),this._resolvePersistenceManagerAvailable?.(),!this._deleted)){if(this._popupRedirectResolver?._shouldInitProactively)try{await this._popupRedirectResolver._initialize(this)}catch(e){}await this.initializeCurrentUser(t),this.lastNotifiedUid=this.currentUser?.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 q(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){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 t=await this.assertedPersistence.getCurrentUser();let n=t,i=!1;if(e&&this.config.authDomain){await this.getOrInitRedirectPersistenceManager();const t=this.redirectUser?._redirectEventId,r=n?._redirectEventId,o=await this.tryRedirectSignIn(e);t&&t!==r||!o?.user||(n=o.user,i=!0)}if(!n)return this.directlySetCurrentUser(null);if(!n._redirectEventId){if(i)try{await this.beforeStateQueue.runMiddleware(n)}catch(e){n=t,this._popupRedirectResolver._overrideRedirectResult(this,()=>Promise.reject(e))}return n?this.reloadAndSetCurrentUserOrClear(n):this.directlySetCurrentUser(null)}return y(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===n._redirectEventId?this.directlySetCurrentUser(n):this.reloadAndSetCurrentUserOrClear(n)}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"!==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(p(this));const t=e?i.getModularInstance(e):null;return t&&y(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&&y(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(p(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(p(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 R(e,"GET","/v2/passwordPolicy",C(e,t))}(this),t=new _e(e);null===this.tenantId?this._projectPasswordPolicy=t:this._tenantPasswordPolicies[this.tenantId]=t}_getPersistenceType(){return this.assertedPersistence.persistence.type}_getPersistence(){return this.assertedPersistence.persistence}_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 R(e,"POST","/v2/accounts:revokeToken",C(e,t))}(this,t)}}toJSON(){return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:this._currentUser?.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;y(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){return this._isInitialized&&await this.queue(async()=>{}),this._currentUser?._redirectEventId===e?this._currentUser:this.redirectUser?._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(){if(!this._isInitialized)return;this.idTokenSubscription.next(this.currentUser);const e=this.currentUser?.uid??null;this.lastNotifiedUid!==e&&(this.lastNotifiedUid=e,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 o=!1;const s=this._isInitialized?Promise.resolve():this._initializationPromise;if(y(s,this,"internal-error"),s.then(()=>{o||i(this.currentUser)}),"function"==typeof t){const i=e.addObserver(t,n,r);return()=>{o=!0,i()}}{const n=e.addObserver(t);return()=>{o=!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 y(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(){const e={"X-Client-Version":this.clientVersion};this.app.options.appId&&(e["X-Firebase-gmpid"]=this.app.options.appId);const t=await(this.heartbeatServiceProvider.getImmediate({optional:!0})?.getHeartbeatsHeader());t&&(e["X-Firebase-Client"]=t);const n=await this._getAppCheckToken();return n&&(e["X-Firebase-AppCheck"]=n),e}async _getAppCheckToken(){if(r._isFirebaseServerApp(this.app)&&this.app.settings.appCheckToken)return this.app.settings.appCheckToken;const e=await(this.appCheckServiceProvider.getImmediate({optional:!0})?.getToken());return e?.error&&function(e,...t){u.logLevel<=o.LogLevel.WARN&&u.warn(`Auth (${r.SDK_VERSION}): ${e}`,...t)}(`Error while retrieving App Check token: ${e.error}`),e?.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 y(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 Ae(e){return`__${e}${Math.floor(1e6*Math.random())}`}const Oe=1e12;class Pe{constructor(e){this.auth=e,this.counter=Oe,this._widgets=new Map}render(e,t){const n=this.counter;return this._widgets.set(n,new ke(e,this.auth.name,t||{})),this.counter++,n}reset(e){const t=e||Oe;this._widgets.get(t)?.delete(),this._widgets.delete(t)}getResponse(e){const t=e||Oe;return this._widgets.get(t)?.getResponse()||""}async execute(e){const t=e||Oe;return this._widgets.get(t)?.execute(),""}}class Ce{constructor(){this.enterprise=new Re}ready(e){e()}execute(e,t){return Promise.resolve("token")}render(e,t){return""}}class Re{ready(e){e()}execute(e,t){return Promise.resolve("token")}render(e,t){return""}}class ke{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;y(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 Ne="NO_RECAPTCHA";class xe{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;F(i)?i.enterprise.ready(()=>{i.enterprise.execute(t,{action:e}).then(e=>{n(e)}).catch(()=>{n(Ne)})}):r(Error("No reCAPTCHA enterprise script loaded."))}return this.auth.settings.appVerificationDisabledForTesting?(new Ce).execute("siteKey",{action:"verify"}):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)=>{U(e,{clientType:"CLIENT_TYPE_WEB",version:"RECAPTCHA_ENTERPRISE"}).then(r=>{if(void 0!==r.recaptchaKey){const n=new V(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&&F(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 De(e,t,n,r=!1,i=!1){const o=new xe(e);let s;if(i)s=Ne;else try{s=await o.verify(n)}catch(e){s=await o.verify(n,!0)}const a={...t};if("mfaSmsEnrollment"===n||"mfaSmsSignIn"===n){if("phoneEnrollmentInfo"in a){const e=a.phoneEnrollmentInfo.phoneNumber,t=a.phoneEnrollmentInfo.recaptchaToken;Object.assign(a,{phoneEnrollmentInfo:{phoneNumber:e,recaptchaToken:t,captchaResponse:s,clientType:"CLIENT_TYPE_WEB",recaptchaVersion:"RECAPTCHA_ENTERPRISE"}})}else if("phoneSignInInfo"in a){const e=a.phoneSignInInfo.recaptchaToken;Object.assign(a,{phoneSignInInfo:{recaptchaToken:e,captchaResponse:s,clientType:"CLIENT_TYPE_WEB",recaptchaVersion:"RECAPTCHA_ENTERPRISE"}})}return a}return r?Object.assign(a,{captchaResp:s}):Object.assign(a,{captchaResponse:s}),Object.assign(a,{clientType:"CLIENT_TYPE_WEB"}),Object.assign(a,{recaptchaVersion:"RECAPTCHA_ENTERPRISE"}),a}async function Me(e,t,n,r,i){if("EMAIL_PASSWORD_PROVIDER"===i){if(e._getRecaptchaConfig()?.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")){const i=await De(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 De(e,t,n,"getOobCode"===n);return r(e,i)}return Promise.reject(i)})}if("PHONE_PROVIDER"===i){if(e._getRecaptchaConfig()?.isProviderEnabled("PHONE_PROVIDER")){const i=await De(e,t,n);return r(e,i).catch(async i=>{if("AUDIT"===e._getRecaptchaConfig()?.getProviderEnforcementState("PHONE_PROVIDER")&&("auth/missing-recaptcha-token"===i.code||"auth/invalid-app-credential"===i.code)){console.log(`Failed to verify with reCAPTCHA Enterprise. Automatically triggering the reCAPTCHA v2 flow to complete the ${n} flow.`);const i=await De(e,t,n,!1,!0);return r(e,i)}return Promise.reject(i)})}{const i=await De(e,t,n,!1,!0);return r(e,i)}}return Promise.reject(i+" provider is not supported.")}async function Le(e){const t=Ie(e),n=await U(t,{clientType:"CLIENT_TYPE_WEB",version:"RECAPTCHA_ENTERPRISE"}),r=new V(n);null==t.tenantId?t._agentRecaptchaConfig=r:t._tenantRecaptchaConfigs[t.tenantId]=r,r.isAnyProviderEnabled()&&new xe(t).verify()}function je(e,t){const n=r._getProvider(e,"auth");if(n.isInitialized()){const e=n.getImmediate(),r=n.getOptions();if(i.deepEqual(r,t??{}))return e;h(e,"already-initialized")}return n.initialize({options:t})}function Fe(e,t,n){const r=Ie(e);y(/^https?:\/\//.test(t),r,"invalid-emulator-scheme");const o=!!n?.disableWarnings,s=Ve(t),{host:a,port:c}=function(e){const t=Ve(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:Ue(r.substr(e.length+1))}}{const[e,t]=r.split(":");return{host:e,port:Ue(t)}}}(t),u=null===c?"":`:${c}`,l={url:`${s}//${a}${u}/`},h=Object.freeze({host:a,port:c,protocol:s.replace(":",""),options:Object.freeze({disableWarnings:o})});if(!r._canInitEmulator)return y(r.config.emulator&&r.emulatorConfig,r,"emulator-config-failed"),void y(i.deepEqual(l,r.config.emulator)&&i.deepEqual(h,r.emulatorConfig),r,"emulator-config-failed");r.config.emulator=l,r.emulatorConfig=h,r.settings.appVerificationDisabledForTesting=!0,i.isCloudWorkstation(a)?(i.pingServer(`${s}//${a}${u}`),i.updateEmulatorBanner("Auth",!0)):o||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 Ve(e){const t=e.indexOf(":");return t<0?"":e.substr(0,t+1)}function Ue(e){if(!e)return null;const t=Number(e);return isNaN(t)?null:t}class qe{constructor(e,t){this.providerId=e,this.signInMethod=t}toJSON(){return v("not implemented")}_getIdTokenResponse(e){return v("not implemented")}_linkToIdToken(e,t){return v("not implemented")}_getReauthenticationResolver(e){return v("not implemented")}}async function Be(e,t){return R(e,"POST","/v1/accounts:resetPassword",C(e,t))}async function ze(e,t){return R(e,"POST","/v1/accounts:signUp",t)}async function We(e,t){return N(e,"POST","/v1/accounts:signInWithPassword",C(e,t))}async function Ge(e,t){return R(e,"POST","/v1/accounts:sendOobCode",C(e,t))}async function Ke(e,t){return Ge(e,t)}async function $e(e,t){return Ge(e,t)}class He extends qe{constructor(e,t,n,r=null){super("password",n),this._email=e,this._password=t,this._tenantId=r}static _fromEmailAndPassword(e,t){return new He(e,t,"password")}static _fromEmailAndCode(e,t,n=null){return new He(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(t?.email&&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 Me(e,{returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"},"signInWithPassword",We,"EMAIL_PASSWORD_PROVIDER");case"emailLink":return async function(e,t){return N(e,"POST","/v1/accounts:signInWithEmailLink",C(e,t))}(e,{email:this._email,oobCode:this._password});default:h(e,"internal-error")}}async _linkToIdToken(e,t){switch(this.signInMethod){case"password":return Me(e,{idToken:t,returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"},"signUpPassword",ze,"EMAIL_PASSWORD_PROVIDER");case"emailLink":return async function(e,t){return N(e,"POST","/v1/accounts:signInWithEmailLink",C(e,t))}(e,{idToken:t,email:this._email,oobCode:this._password});default:h(e,"internal-error")}}_getReauthenticationResolver(e){return this._getIdTokenResponse(e)}}async function Qe(e,t){return N(e,"POST","/v1/accounts:signInWithIdp",C(e,t))}class Je extends qe{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(e){const t=new Je(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):h("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,...i}=t;if(!n||!r)return null;const o=new Je(n,r);return o.idToken=i.idToken||void 0,o.accessToken=i.accessToken||void 0,o.secret=i.secret,o.nonce=i.nonce,o.pendingToken=i.pendingToken||null,o}_getIdTokenResponse(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}}async function Ye(e,t){return R(e,"POST","/v1/accounts:sendVerificationCode",C(e,t))}const Xe={USER_NOT_FOUND:"user-not-found"};class Ze extends qe{constructor(e){super("phone","phone"),this.params=e}static _fromVerification(e,t){return new Ze({verificationId:e,verificationCode:t})}static _fromTokenResponse(e,t){return new Ze({phoneNumber:e,temporaryProof:t})}_getIdTokenResponse(e){return async function(e,t){return N(e,"POST","/v1/accounts:signInWithPhoneNumber",C(e,t))}(e,this._makeVerificationRequest())}_linkToIdToken(e,t){return async function(e,t){const n=await N(e,"POST","/v1/accounts:signInWithPhoneNumber",C(e,t));if(n.temporaryProof)throw L(e,"account-exists-with-different-credential",n);return n}(e,{idToken:t,...this._makeVerificationRequest()})}_getReauthenticationResolver(e){return async function(e,t){return N(e,"POST","/v1/accounts:signInWithPhoneNumber",C(e,{...t,operation:"REAUTH"}),Xe)}(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 Ze({verificationId:t,verificationCode:n,phoneNumber:r,temporaryProof:i}):null}}class et{constructor(e){const t=i.querystringDecode(i.extractQuerystring(e)),n=t.apiKey??null,r=t.oobCode??null,o=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}}(t.mode??null);y(n&&r&&o,"argument-error"),this.apiKey=n,this.operation=o,this.code=r,this.continueUrl=t.continueUrl??null,this.languageCode=t.lang??null,this.tenantId=t.tenantId??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 et(t)}catch{return null}}}class tt{constructor(){this.providerId=tt.PROVIDER_ID}static credential(e,t){return He._fromEmailAndPassword(e,t)}static credentialWithLink(e,t){const n=et.parseLink(t);return y(n,"argument-error"),He._fromEmailAndCode(e,n.code,n.tenantId)}}tt.PROVIDER_ID="password",tt.EMAIL_PASSWORD_SIGN_IN_METHOD="password",tt.EMAIL_LINK_SIGN_IN_METHOD="emailLink";class nt{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 rt extends nt{constructor(){super(...arguments),this.scopes=[]}addScope(e){return this.scopes.includes(e)||this.scopes.push(e),this}getScopes(){return[...this.scopes]}}class it extends rt{static credentialFromJSON(e){const t="string"==typeof e?JSON.parse(e):e;return y("providerId"in t&&"signInMethod"in t,"argument-error"),Je._fromParams(t)}credential(e){return this._credential({...e,nonce:e.rawNonce})}_credential(e){return y(e.idToken||e.accessToken,"argument-error"),Je._fromParams({...e,providerId:this.providerId,signInMethod:this.providerId})}static credentialFromResult(e){return it.oauthCredentialFromTaggedObject(e)}static credentialFromError(e){return it.oauthCredentialFromTaggedObject(e.customData||{})}static oauthCredentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthIdToken:t,oauthAccessToken:n,oauthTokenSecret:r,pendingToken:i,nonce:o,providerId:s}=e;if(!(n||r||t||i))return null;if(!s)return null;try{return new it(s)._credential({idToken:t,accessToken:n,nonce:o,pendingToken:i})}catch(e){return null}}}class ot extends rt{constructor(){super("facebook.com")}static credential(e){return Je._fromParams({providerId:ot.PROVIDER_ID,signInMethod:ot.FACEBOOK_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return ot.credentialFromTaggedObject(e)}static credentialFromError(e){return ot.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e))return null;if(!e.oauthAccessToken)return null;try{return ot.credential(e.oauthAccessToken)}catch{return null}}}ot.FACEBOOK_SIGN_IN_METHOD="facebook.com",ot.PROVIDER_ID="facebook.com";class st extends rt{constructor(){super("google.com"),this.addScope("profile")}static credential(e,t){return Je._fromParams({providerId:st.PROVIDER_ID,signInMethod:st.GOOGLE_SIGN_IN_METHOD,idToken:e,accessToken:t})}static credentialFromResult(e){return st.credentialFromTaggedObject(e)}static credentialFromError(e){return st.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthIdToken:t,oauthAccessToken:n}=e;if(!t&&!n)return null;try{return st.credential(t,n)}catch{return null}}}st.GOOGLE_SIGN_IN_METHOD="google.com",st.PROVIDER_ID="google.com";class at extends rt{constructor(){super("github.com")}static credential(e){return Je._fromParams({providerId:at.PROVIDER_ID,signInMethod:at.GITHUB_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return at.credentialFromTaggedObject(e)}static credentialFromError(e){return at.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e))return null;if(!e.oauthAccessToken)return null;try{return at.credential(e.oauthAccessToken)}catch{return null}}}at.GITHUB_SIGN_IN_METHOD="github.com",at.PROVIDER_ID="github.com";class ct extends qe{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 ct(n,i):null}static _create(e,t){return new ct(e,t)}buildRequest(){return{requestUri:"http://localhost",returnSecureToken:!0,pendingToken:this.pendingToken}}}class ut extends nt{constructor(e){y(e.startsWith("saml."),"argument-error"),super(e)}static credentialFromResult(e){return ut.samlCredentialFromTaggedObject(e)}static credentialFromError(e){return ut.samlCredentialFromTaggedObject(e.customData||{})}static credentialFromJSON(e){const t=ct.fromJSON(e);return y(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 ct._create(n,t)}catch(e){return null}}}class lt extends rt{constructor(){super("twitter.com")}static credential(e,t){return Je._fromParams({providerId:lt.PROVIDER_ID,signInMethod:lt.TWITTER_SIGN_IN_METHOD,oauthToken:e,oauthTokenSecret:t})}static credentialFromResult(e){return lt.credentialFromTaggedObject(e)}static credentialFromError(e){return lt.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthAccessToken:t,oauthTokenSecret:n}=e;if(!t||!n)return null;try{return lt.credential(t,n)}catch{return null}}}async function ht(e,t){return N(e,"POST","/v1/accounts:signUp",C(e,t))}lt.TWITTER_SIGN_IN_METHOD="twitter.com",lt.PROVIDER_ID="twitter.com";class dt{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),o=ft(n);return new dt({user:i,providerId:o,_tokenResponse:n,operationType:t})}static async _forOperation(e,t,n){await e._updateTokensIfNecessary(n,!0);const r=ft(n);return new dt({user:e,providerId:r,_tokenResponse:n,operationType:t})}}function ft(e){return e.providerId?e.providerId:"phoneNumber"in e?"phone":null}class pt extends i.FirebaseError{constructor(e,t,n,r){super(t.code,t.message),this.operationType=n,this.user=r,Object.setPrototypeOf(this,pt.prototype),this.customData={appName:e.name,tenantId:e.tenantId??void 0,_serverResponse:t.customData._serverResponse,operationType:n}}static _fromErrorAndOperation(e,t,n,r){return new pt(e,t,n,r)}}function mt(e,t,n,r){return("reauthenticate"===t?n._getReauthenticationResolver(e):n._getIdTokenResponse(e)).catch(n=>{if("auth/multi-factor-auth-required"===n.code)throw pt._fromErrorAndOperation(e,n,t,r);throw n})}function gt(e){return new Set(e.map(({providerId:e})=>e).filter(e=>!!e))}async function yt(e,t,n=!1){const r=await $(e,t._linkToIdToken(e.auth,await e.getIdToken()),n);return dt._forOperation(e,"link",r)}async function vt(e,t,n){await J(t);const r=!1===e?"provider-already-linked":"no-such-provider";y(gt(t.providerData).has(n)===e,t.auth,r)}async function bt(e,t,n=!1){const{auth:i}=e;if(r._isFirebaseServerApp(i.app))return Promise.reject(p(i));const o="reauthenticate";try{const r=await $(e,mt(i,o,t,e),n);y(r.idToken,i,"internal-error");const s=G(r.idToken);y(s,i,"internal-error");const{sub:a}=s;return y(e.uid===a,i,"user-mismatch"),dt._forOperation(e,o,r)}catch(e){throw"auth/user-not-found"===e?.code&&h(i,"user-mismatch"),e}}async function _t(e,t,n=!1){if(r._isFirebaseServerApp(e.app))return Promise.reject(p(e));const i="signIn",o=await mt(e,i,t),s=await dt._fromIdTokenResponse(e,i,o);return n||await e._updateCurrentUser(s.user),s}async function wt(e,t){return _t(Ie(e),t)}async function It(e,t){const n=i.getModularInstance(e);return await vt(!1,n,t.providerId),yt(n,t)}async function Et(e,t){return bt(i.getModularInstance(e),t)}class Tt{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?St._fromServerResponse(e,t):"totpInfo"in t?At._fromServerResponse(e,t):h(e,"internal-error")}}class St extends Tt{constructor(e){super("phone",e),this.phoneNumber=e.phoneInfo}static _fromServerResponse(e,t){return new St(t)}}class At extends Tt{constructor(e){super("totp",e)}static _fromServerResponse(e,t){return new At(t)}}function Ot(e,t,n){y(n.url?.length>0,e,"invalid-continue-uri"),y(void 0===n.dynamicLinkDomain||n.dynamicLinkDomain.length>0,e,"invalid-dynamic-link-domain"),y(void 0===n.linkDomain||n.linkDomain.length>0,e,"invalid-hosting-link-domain"),t.continueUrl=n.url,t.dynamicLinkDomain=n.dynamicLinkDomain,t.linkDomain=n.linkDomain,t.canHandleCodeInApp=n.handleCodeInApp,n.iOS&&(y(n.iOS.bundleId.length>0,e,"missing-ios-bundle-id"),t.iOSBundleId=n.iOS.bundleId),n.android&&(y(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 Pt(e){const t=Ie(e);t._getPasswordPolicyInternal()&&await t._updatePasswordPolicy()}async function Ct(e,t){const n=i.getModularInstance(e),r=await Be(n,{oobCode:t}),o=r.requestType;switch(y(o,n,"internal-error"),o){case"EMAIL_SIGNIN":break;case"VERIFY_AND_CHANGE_EMAIL":y(r.newEmail,n,"internal-error");break;case"REVERT_SECOND_FACTOR_ADDITION":y(r.mfaInfo,n,"internal-error");default:y(r.email,n,"internal-error")}let s=null;return r.mfaInfo&&(s=Tt._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:s},operation:o}}async function Rt(e,t,n){const{auth:r}=e,i={idToken:await e.getIdToken(),returnSecureToken:!0};t&&(i.email=t),n&&(i.password=n);const o=await $(e,async function(e,t){return R(e,"POST","/v1/accounts:update",t)}(r,i));await e._updateTokensIfNecessary(o,!0)}class kt{constructor(e,t,n={}){this.isNewUser=e,this.providerId=t,this.profile=n}}class Nt extends kt{constructor(e,t,n,r){super(e,t,n),this.username=r}}class xt extends kt{constructor(e,t){super(e,"facebook.com",t)}}class Dt extends Nt{constructor(e,t){super(e,"github.com",t,"string"==typeof t?.login?t?.login:null)}}class Mt extends kt{constructor(e,t){super(e,"google.com",t)}}class Lt extends Nt{constructor(e,t,n){super(e,"twitter.com",t,n)}}function jt(e,t,n,r){return i.getModularInstance(e).onIdTokenChanged(t,n,r)}function Ft(e,t,n){return i.getModularInstance(e).beforeAuthStateChanged(t,n)}class Vt{constructor(e,t,n){this.type=e,this.credential=t,this.user=n}static _fromIdtoken(e,t){return new Vt("enroll",e,t)}static _fromMfaPendingCredential(e){return new Vt("signin",e)}toJSON(){const e="enroll"===this.type?"idToken":"pendingCredential";return{multiFactorSession:{[e]:this.credential}}}static fromJSON(e){if(e?.multiFactorSession){if(e.multiFactorSession?.pendingCredential)return Vt._fromMfaPendingCredential(e.multiFactorSession.pendingCredential);if(e.multiFactorSession?.idToken)return Vt._fromIdtoken(e.multiFactorSession.idToken)}return null}}class Ut{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=>Tt._fromServerResponse(n,e));y(r.mfaPendingCredential,n,"internal-error");const o=Vt._fromMfaPendingCredential(r.mfaPendingCredential);return new Ut(o,i,async e=>{const i=await e._process(n,o);delete r.mfaInfo,delete r.mfaPendingCredential;const s={...r,idToken:i.idToken,refreshToken:i.refreshToken};switch(t.operationType){case"signIn":const e=await dt._fromIdTokenResponse(n,t.operationType,s);return await n._updateCurrentUser(e.user),e;case"reauthenticate":return y(t.user,n,"internal-error"),dt._forOperation(t.user,t.operationType,s);default:h(n,"internal-error")}})}async resolveSignIn(e){const t=e;return this.signInResolver(t)}}function qt(e,t){return R(e,"POST","/v2/accounts/mfaEnrollment:start",C(e,t))}class Bt{constructor(e){this.user=e,this.enrolledFactors=[],e._onReload(t=>{t.mfaInfo&&(this.enrolledFactors=t.mfaInfo.map(t=>Tt._fromServerResponse(e.auth,t)))})}static _fromUser(e){return new Bt(e)}async getSession(){return Vt._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},R(r,"POST","/v2/accounts/mfaEnrollment:withdraw",C(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 zt=new WeakMap,Wt="__sak";class Gt{constructor(e,t){this.storageRetriever=e,this.type=t}_isAvailable(){try{return this.storage?(this.storage.setItem(Wt,"1"),this.storage.removeItem(Wt),Promise.resolve(!0)):Promise.resolve(!1)}catch{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 Kt extends Gt{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)},o=this.storage.getItem(n);i.isIE()&&10===document.documentMode&&o!==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]}}Kt.type="LOCAL";const $t=Kt;function Ht(e){const t=e.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),n=RegExp(`${t}=([^;]+)`);return document.cookie.match(n)?.[1]??null}function Qt(e){return`${"http:"===window.location.protocol?"__dev_":"__HOST-"}FIREBASE_${e.split(":")[3]}`}class Jt{constructor(){this.type="COOKIE",this.listenerUnsubscribes=new Map}_getFinalTarget(e){if(void 0===typeof window)return e;const t=new URL(`${window.location.origin}/__cookies__`);return t.searchParams.set("finalTarget",e),t}async _isAvailable(){return!("boolean"==typeof isSecureContext&&!isSecureContext)&&"undefined"!=typeof navigator&&"undefined"!=typeof document&&(navigator.cookieEnabled??!0)}async _set(e,t){}async _get(e){if(!this._isAvailable())return null;const t=Qt(e);if(window.cookieStore){const e=await window.cookieStore.get(t);return e?.value}return Ht(t)}async _remove(e){if(!this._isAvailable())return;if(!await this._get(e))return;const t=Qt(e);document.cookie=`${t}=;Max-Age=34560000;Partitioned;Secure;SameSite=Strict;Path=/;Priority=High`,await fetch("/__cookies__",{method:"DELETE"}).catch(()=>{})}_addListener(e,t){if(!this._isAvailable())return;const n=Qt(e);if(window.cookieStore){const e=e=>{const r=e.changed.find(e=>e.name===n);r&&t(r.value),e.deleted.find(e=>e.name===n)&&t(null)},r=()=>window.cookieStore.removeEventListener("change",e);return this.listenerUnsubscribes.set(t,r),window.cookieStore.addEventListener("change",e)}let r=Ht(n);const i=setInterval(()=>{const e=Ht(n);e!==r&&(t(e),r=e)},1e3);this.listenerUnsubscribes.set(t,()=>clearInterval(i))}_removeListener(e,t){const n=this.listenerUnsubscribes.get(t);n&&(n(),this.listenerUnsubscribes.delete(t))}}Jt.type="COOKIE";const Yt=Jt;class Xt extends Gt{constructor(){super(()=>window.sessionStorage,"SESSION")}_addListener(e,t){}_removeListener(e,t){}}Xt.type="SESSION";const Zt=Xt;class en{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 en(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,o=this.handlersMap[r];if(!o?.size)return;t.ports[0].postMessage({status:"ack",eventId:n,eventType:r});const s=Array.from(o).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}}}))}(s);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 tn(e="",t=10){let n="";for(let e=0;e<t;e++)n+=Math.floor(10*Math.random());return e+n}en.receivers=[];class nn{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,o;return new Promise((s,a)=>{const c=tn("",20);r.port1.start();const u=setTimeout(()=>{a(new Error("unsupported_event"))},n);o={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),s(t.data.response);break;default:clearTimeout(u),clearTimeout(i),a(new Error("invalid_response"))}}},this.handlers.add(o),r.port1.addEventListener("message",o.onMessage),this.target.postMessage({eventType:e,eventId:c,data:t},[r.port2])}).finally(()=>{o&&this.removeMessageHandler(o)})}}function rn(){return window}function on(){return void 0!==rn().WorkerGlobalScope&&"function"==typeof rn().importScripts}const sn="firebaseLocalStorageDb",an="firebaseLocalStorage",cn="fbase_key";class un{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 ln(e,t){return e.transaction([an],t?"readwrite":"readonly").objectStore(an)}function hn(){const e=indexedDB.open(sn,1);return new Promise((t,n)=>{e.addEventListener("error",()=>{n(e.error)}),e.addEventListener("upgradeneeded",()=>{const t=e.result;try{t.createObjectStore(an,{keyPath:cn})}catch(e){n(e)}}),e.addEventListener("success",async()=>{const n=e.result;n.objectStoreNames.contains(an)?t(n):(n.close(),await function(){const e=indexedDB.deleteDatabase(sn);return new un(e).toPromise()}(),t(await hn()))})})}async function dn(e,t,n){const r=ln(e,!0).put({[cn]:t,value:n});return new un(r).toPromise()}function fn(e,t){const n=ln(e,!0).delete(t);return new un(n).toPromise()}class pn{constructor(){this.type="LOCAL",this._shouldAllowMigration=!0,this.listeners={},this.localCache={},this.pollTimer=null,this.pendingWrites=0,this.receiver=null,this.sender=null,this.serviceWorkerReceiverAvailable=!1,this.activeServiceWorker=null,this._workerInitializationPromise=this.initializeServiceWorkerMessaging().then(()=>{},()=>{})}async _openDb(){return this.db||(this.db=await hn()),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 on()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=en._getInstance(on()?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(){if(this.activeServiceWorker=await async function(){if(!navigator?.serviceWorker)return null;try{return(await navigator.serviceWorker.ready).active}catch{return null}}(),!this.activeServiceWorker)return;this.sender=new nn(this.activeServiceWorker);const e=await this.sender._send("ping",{},800);e&&e[0]?.fulfilled&&e[0]?.value.includes("keyChanged")&&(this.serviceWorkerReceiverAvailable=!0)}async notifyServiceWorker(e){if(this.sender&&this.activeServiceWorker&&(navigator?.serviceWorker?.controller||null)===this.activeServiceWorker)try{await this.sender._send("keyChanged",{key:e},this.serviceWorkerReceiverAvailable?800:50)}catch{}}async _isAvailable(){try{if(!indexedDB)return!1;const e=await hn();return await dn(e,Wt,"1"),await fn(e,Wt),!0}catch{}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=>dn(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=ln(e,!1).get(t),r=await new un(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=>fn(t,e)),delete this.localCache[e],this.notifyServiceWorker(e)))}async _poll(){const e=await this._withRetries(e=>{const t=ln(e,!1).getAll();return new un(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()}}pn.type="LOCAL";const mn=pn;function gn(e,t){return R(e,"POST","/v2/accounts/mfaSignIn:start",C(e,t))}const yn=Ae("rcb"),vn=new E(3e4,6e4);class bn{constructor(){this.hostLanguage="",this.counter=0,this.librarySeparatelyLoaded=!!rn().grecaptcha?.render}load(e,t=""){return y(function(e){return e.length<=6&&/^\s*[a-zA-Z0-9\-]*\s*$/.test(e)}(t),e,"argument-error"),this.shouldResolveImmediately(t)&&j(rn().grecaptcha)?Promise.resolve(rn().grecaptcha):new Promise((n,r)=>{const o=rn().setTimeout(()=>{r(d(e,"network-request-failed"))},vn.get());rn()[yn]=()=>{rn().clearTimeout(o),delete rn()[yn];const i=rn().grecaptcha;if(!i||!j(i))return void r(d(e,"internal-error"));const s=i.render;i.render=(e,t)=>{const n=s(e,t);return this.counter++,n},this.hostLanguage=t,n(i)},Se(`${Te.recaptchaV2Script}?${i.querystring({onload:yn,render:"explicit",hl:t})}`).catch(()=>{clearTimeout(o),r(d(e,"internal-error"))})})}clearedOneInstance(){this.counter--}shouldResolveImmediately(e){return!!rn().grecaptcha?.render&&(e===this.hostLanguage||this.counter>0||this.librarySeparatelyLoaded)}}class _n{async load(e){return new Pe(e)}clearedOneInstance(){}}const wn="recaptcha",In={theme:"light",type:"image"};class En{constructor(e,t){this.verificationId=e,this.onConfirmation=t}confirm(e){const t=Ze._fromVerification(this.verificationId,e);return this.onConfirmation(t)}}async function Tn(e,t,n){if(!e._getRecaptchaConfig())try{await Le(e)}catch(e){console.log("Failed to initialize reCAPTCHA Enterprise config. Triggering the reCAPTCHA v2 verification.")}try{let r;if(r="string"==typeof t?{phoneNumber:t}:t,"session"in r){const t=r.session;if("phoneNumber"in r){y("enroll"===t.type,e,"internal-error");const i=Me(e,{idToken:t.credential,phoneEnrollmentInfo:{phoneNumber:r.phoneNumber,clientType:"CLIENT_TYPE_WEB"}},"mfaSmsEnrollment",async(e,t)=>t.phoneEnrollmentInfo.captchaResponse===Ne?(y(n?.type===wn,e,"argument-error"),qt(e,await Sn(e,t,n))):qt(e,t),"PHONE_PROVIDER");return(await i.catch(e=>Promise.reject(e))).phoneSessionInfo.sessionInfo}{y("signin"===t.type,e,"internal-error");const i=r.multiFactorHint?.uid||r.multiFactorUid;y(i,e,"missing-multi-factor-info");const o=Me(e,{mfaPendingCredential:t.credential,mfaEnrollmentId:i,phoneSignInInfo:{clientType:"CLIENT_TYPE_WEB"}},"mfaSmsSignIn",async(e,t)=>t.phoneSignInInfo.captchaResponse===Ne?(y(n?.type===wn,e,"argument-error"),gn(e,await Sn(e,t,n))):gn(e,t),"PHONE_PROVIDER");return(await o.catch(e=>Promise.reject(e))).phoneResponseInfo.sessionInfo}}{const t=Me(e,{phoneNumber:r.phoneNumber,clientType:"CLIENT_TYPE_WEB"},"sendVerificationCode",async(e,t)=>t.captchaResponse===Ne?(y(n?.type===wn,e,"argument-error"),Ye(e,await Sn(e,t,n))):Ye(e,t),"PHONE_PROVIDER");return(await t.catch(e=>Promise.reject(e))).sessionInfo}}finally{n?._reset()}}async function Sn(e,t,n){y(n.type===wn,e,"argument-error");const r=await n.verify();y("string"==typeof r,e,"argument-error");const i={...t};if("phoneEnrollmentInfo"in i){const e=i.phoneEnrollmentInfo.phoneNumber,t=i.phoneEnrollmentInfo.captchaResponse,n=i.phoneEnrollmentInfo.clientType,o=i.phoneEnrollmentInfo.recaptchaVersion;return Object.assign(i,{phoneEnrollmentInfo:{phoneNumber:e,recaptchaToken:r,captchaResponse:t,clientType:n,recaptchaVersion:o}}),i}if("phoneSignInInfo"in i){const e=i.phoneSignInInfo.captchaResponse,t=i.phoneSignInInfo.clientType,n=i.phoneSignInInfo.recaptchaVersion;return Object.assign(i,{phoneSignInInfo:{recaptchaToken:r,captchaResponse:e,clientType:t,recaptchaVersion:n}}),i}return Object.assign(i,{recaptchaToken:r}),i}class An{constructor(e){this.providerId=An.PROVIDER_ID,this.auth=Ie(e)}verifyPhoneNumber(e,t){return Tn(this.auth,e,i.getModularInstance(t))}static credential(e,t){return Ze._fromVerification(e,t)}static credentialFromResult(e){const t=e;return An.credentialFromTaggedObject(t)}static credentialFromError(e){return An.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{phoneNumber:t,temporaryProof:n}=e;return t&&n?Ze._fromTokenResponse(t,n):null}}function On(e,t){return t?re(t):(y(e._popupRedirectResolver,e,"argument-error"),e._popupRedirectResolver)}An.PROVIDER_ID="phone",An.PHONE_SIGN_IN_METHOD="phone";class Pn extends qe{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 Cn(e){return _t(e.auth,new Pn(e),e.bypassAuthState)}function Rn(e){const{auth:t,user:n}=e;return y(n,t,"internal-error"),bt(n,new Pn(e),e.bypassAuthState)}async function kn(e){const{auth:t,user:n}=e;return y(n,t,"internal-error"),yt(n,new Pn(e),e.bypassAuthState)}class Nn{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:o,type:s}=e;if(o)return void this.reject(o);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(s)(a))}catch(e){this.reject(e)}}onError(e){this.reject(e)}getIdpTask(e){switch(e){case"signInViaPopup":case"signInViaRedirect":return Cn;case"linkViaPopup":case"linkViaRedirect":return kn;case"reauthViaPopup":case"reauthViaRedirect":return Rn;default:h(this.auth,"internal-error")}}resolve(e){b(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){b(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 xn=new E(2e3,1e4);class Dn extends Nn{constructor(e,t,n,r,i){super(e,t,r,i),this.provider=n,this.authWindow=null,this.pollId=null,Dn.currentPopupAction&&Dn.currentPopupAction.cancel(),Dn.currentPopupAction=this}async executeNotNull(){const e=await this.execute();return y(e,this.auth,"internal-error"),e}async onExecution(){b(1===this.filter.length,"Popup operations only handle one event");const e=tn();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(d(this.auth,"web-storage-unsupported"))}),this.pollUserCancellation()}get eventId(){return this.authWindow?.associatedEvent||null}cancel(){this.reject(d(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,Dn.currentPopupAction=null}pollUserCancellation(){const e=()=>{this.authWindow?.window?.closed?this.pollId=window.setTimeout(()=>{this.pollId=null,this.reject(d(this.auth,"popup-closed-by-user"))},8e3):this.pollId=window.setTimeout(e,xn.get())};e()}}Dn.currentPopupAction=null;const Mn=new Map;class Ln extends Nn{constructor(e,t,n=!1){super(e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],t,void 0,n),this.eventId=null}async execute(){let e=Mn.get(this.auth._key());if(!e){try{const t=await async function(e,t){const n=Un(t),r=Vn(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)}Mn.set(this.auth._key(),e)}return this.bypassAuthState||Mn.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 jn(e,t){return Vn(e)._set(Un(t),"true")}function Fn(e,t){Mn.set(e._key(),t)}function Vn(e){return re(e._redirectPersistence)}function Un(e){return se("pendingRedirect",e.config.apiKey,e.name)}async function qn(e,t,n=!1){if(r._isFirebaseServerApp(e.app))return Promise.reject(p(e));const i=Ie(e),o=On(i,t),s=new Ln(i,o,n),a=await s.execute();return a&&!n&&(delete a.user._redirectEventId,await i._persistUserIfCurrent(a.user),await i._setRedirectUser(null,t)),a}async function Bn(e){const t=tn(`${e.uid}:::`);return e._redirectEventId=t,await e.auth._setRedirectUser(e),await e.auth._persistUserIfCurrent(e),t}class zn{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 Gn(e);default:return!1}}(e)||(this.hasHandledPotentialRedirect=!0,t||(this.queuedRedirectEvent=e,t=!0)),t}sendToConsumer(e,t){if(e.error&&!Gn(e)){const n=e.error.code?.split("auth/")[1]||"internal-error";t.onError(d(this.auth,n))}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(Wn(e))}saveEventToCache(e){this.cachedEventUids.add(Wn(e)),this.lastProcessedEventTime=Date.now()}}function Wn(e){return[e.type,e.eventId,e.sessionId,e.tenantId].filter(e=>e).join("-")}function Gn({type:e,error:t}){return"unknown"===e&&"auth/no-auth-event"===t?.code}async function Kn(e,t={}){return R(e,"GET","/v1/projects",t)}const $n=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,Hn=/^https?/;function Qn(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(!Hn.test(n))return!1;if($n.test(e))return r===e;const i=e.replace(/\./g,"\\.");return new RegExp("^(.+\\."+i+"|"+i+")$","i").test(r)}const Jn=new E(3e4,6e4);function Yn(){const e=rn().___jsl;if(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 Xn(e){return new Promise((t,n)=>{function r(){Yn(),gapi.load("gapi.iframes",{callback:()=>{t(gapi.iframes.getContext())},ontimeout:()=>{Yn(),n(d(e,"network-request-failed"))},timeout:Jn.get()})}if(rn().gapi?.iframes?.Iframe)t(gapi.iframes.getContext());else{if(!rn().gapi?.load){const t=Ae("iframefcb");return rn()[t]=()=>{gapi.load?r():n(d(e,"network-request-failed"))},Se(`${Te.gapiScript}?onload=${t}`).catch(e=>n(e))}r()}}).catch(e=>{throw Zn=null,e})}let Zn=null;const er=new E(5e3,15e3),tr={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},nr=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);function rr(e){const t=e.config;y(t.authDomain,e,"auth-domain-config-required");const n=t.emulator?T(t,"emulator/auth/iframe"):`https://${e.config.authDomain}/__/auth/iframe`,o={apiKey:t.apiKey,appName:e.name,v:r.SDK_VERSION},s=nr.get(e.config.apiHost);s&&(o.eid=s);const a=e._getFrameworks();return a.length&&(o.fw=a.join(",")),`${n}?${i.querystring(o).slice(1)}`}const ir={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"};class or{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch(e){}}}const sr=encodeURIComponent("fac");async function ar(e,t,n,o,s,a){y(e.config.authDomain,e,"auth-domain-config-required"),y(e.config.apiKey,e,"invalid-api-key");const c={apiKey:e.config.apiKey,appName:e.name,authType:n,redirectUrl:o,v:r.SDK_VERSION,eventId:s};if(t instanceof nt){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 rt){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?`#${sr}=${encodeURIComponent(l)}`:"";return`${function({config:e}){return e.emulator?T(e,"emulator/auth/handler"):`https://${e.authDomain}/__/auth/handler`}(e)}?${i.querystring(u).slice(1)}${h}`}const cr="webStorageSupport",ur=class{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=Zt,this._completeRedirectFn=qn,this._overrideRedirectResult=Fn}async _openPopup(e,t,n,r){return b(this.eventManagers[e._key()]?.manager,"_initialize() not called before _openPopup()"),function(e,t,n,r=500,o=600){const s=Math.max((window.screen.availHeight-o)/2,0).toString(),a=Math.max((window.screen.availWidth-r)/2,0).toString();let c="";const u={...ir,width:r.toString(),height:o.toString(),top:s,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()){return ge(e)&&!!window.navigator?.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 or(null);const d=window.open(t||"",c,h);y(d,e,"popup-blocked");try{d.focus()}catch(e){}return new or(d)}(e,await ar(e,t,n,_(),r),tn())}async _openRedirect(e,t,n,r){return await this._originValidation(e),i=await ar(e,t,n,_(),r),rn().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):(b(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 Zn=Zn||Xn(e),Zn}(e),n=rn().gapi;return y(n,e,"internal-error"),t.open({where:document.body,url:rr(e),messageHandlersFilter:n.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:tr,dontclear:!0},t=>new Promise(async(n,r)=>{await t.restyle({setHideOnLeave:!1});const i=d(e,"network-request-failed"),o=rn().setTimeout(()=>{r(i)},er.get());function s(){rn().clearTimeout(o),n(t)}t.ping(s).then(s,()=>{r(i)})}))}(e),n=new zn(e);return t.register("authEvent",t=>(y(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(cr,{type:cr},n=>{const r=n?.[0]?.[cr];void 0!==r&&t(!!r),h(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 Kn(e);for(const e of t)try{if(Qn(e))return}catch{}h(e,"unauthorized-domain")}(e)),this.originValidationPromises[t]}get _shouldInitProactively(){return ye()||le()||ge()}};class lr{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 v("unexpected MultiFactorSessionType")}}}class hr extends lr{constructor(e){super("phone"),this.credential=e}static _fromCredential(e){return new hr(e)}_finalizeEnroll(e,t,n){return function(e,t){return R(e,"POST","/v2/accounts/mfaEnrollment:finalize",C(e,t))}(e,{idToken:t,displayName:n,phoneVerificationInfo:this.credential._makeVerificationRequest()})}_finalizeSignIn(e,t){return function(e,t){return R(e,"POST","/v2/accounts/mfaSignIn:finalize",C(e,t))}(e,{mfaPendingCredential:t,phoneVerificationInfo:this.credential._makeVerificationRequest()})}}class dr{constructor(){}static assertion(e){return hr._fromCredential(e)}}dr.FACTOR_ID="phone";class fr{static assertionForEnrollment(e,t){return pr._fromSecret(e,t)}static assertionForSignIn(e,t){return pr._fromEnrollmentId(e,t)}static async generateSecret(e){const t=e;y(void 0!==t.user?.auth,"internal-error");const n=await(r=t.user.auth,i={idToken:t.credential,totpEnrollmentInfo:{}},R(r,"POST","/v2/accounts/mfaEnrollment:start",C(r,i)));var r,i;return mr._fromStartTotpMfaEnrollmentResponse(n,t.user.auth)}}fr.FACTOR_ID="totp";class pr extends lr{constructor(e,t,n){super("totp"),this.otp=e,this.enrollmentId=t,this.secret=n}static _fromSecret(e,t){return new pr(t,void 0,e)}static _fromEnrollmentId(e,t){return new pr(t,e)}async _finalizeEnroll(e,t,n){return y(void 0!==this.secret,e,"argument-error"),function(e,t){return R(e,"POST","/v2/accounts/mfaEnrollment:finalize",C(e,t))}(e,{idToken:t,displayName:n,totpVerificationInfo:this.secret._makeTotpVerificationInfo(this.otp)})}async _finalizeSignIn(e,t){y(void 0!==this.enrollmentId&&void 0!==this.otp,e,"argument-error");const n={verificationCode:this.otp};return function(e,t){return R(e,"POST","/v2/accounts/mfaSignIn:finalize",C(e,t))}(e,{mfaPendingCredential:t,mfaEnrollmentId:this.enrollmentId,totpVerificationInfo:n})}}class mr{constructor(e,t,n,r,i,o,s){this.sessionInfo=o,this.auth=s,this.secretKey=e,this.hashingAlgorithm=t,this.codeLength=n,this.codeIntervalSeconds=r,this.enrollmentCompletionDeadline=i}static _fromStartTotpMfaEnrollmentResponse(e,t){return new mr(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){let n=!1;return(gr(e)||gr(t))&&(n=!0),n&&(gr(e)&&(e=this.auth.currentUser?.email||"unknownuser"),gr(t)&&(t=this.auth.name)),`otpauth://totp/${t}:${e}?secret=${this.secretKey}&issuer=${t}&algorithm=${this.hashingAlgorithm}&digits=${this.codeLength}`}}function gr(e){return void 0===e||0===e?.length}var yr="@firebase/auth",vr="1.12.1";class br{constructor(e){this.auth=e,this.internalListeners=new Map}getUid(){return this.assertAuthConfigured(),this.auth.currentUser?.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(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(){y(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}const _r=i.getExperimentalSetting("authIdTokenMaxAge")||300;let wr=null;var Ir;Te={loadJS:e=>new Promise((t,n)=>{const r=document.createElement("script");r.setAttribute("src",e),r.onload=t,r.onerror=e=>{const t=d("internal-error");t.customData=e,n(t)},r.type="text/javascript",r.charset="UTF-8",(document.getElementsByTagName("head")?.[0]??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="},Ir="Browser",r._registerComponent(new s.Component("auth",(e,{options:t})=>{const n=e.getProvider("app").getImmediate(),r=e.getProvider("heartbeat"),i=e.getProvider("app-check-internal"),{apiKey:o,authDomain:s}=n.options;y(o&&!o.includes(":"),"invalid-api-key",{appName:n.name});const a={apiKey:o,authDomain:s,clientPlatform:Ir,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:ve(Ir)},c=new we(n,r,i,a);return function(e,t){const n=t?.persistence||[],r=(Array.isArray(n)?n:[n]).map(re);t?.errorMap&&e._updateErrorMap(t.errorMap),e._initializeWithPersistence(r,t?.popupRedirectResolver)}(c,t),c},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((e,t,n)=>{e.getProvider("auth-internal").initialize()})),r._registerComponent(new s.Component("auth-internal",e=>{return t=Ie(e.getProvider("auth").getImmediate()),new br(t);var t},"PRIVATE").setInstantiationMode("EXPLICIT")),r.registerVersion(yr,vr,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}}(Ir)),r.registerVersion(yr,vr,"cjs2020"),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_PASSWORD:"auth/missing-password",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",INVALID_HOSTING_LINK_DOMAIN:"auth/invalid-hosting-link-domain"},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=et,t.AuthCredential=qe,t.AuthEventManager=zn,t.AuthImpl=we,t.AuthPopup=or,t.EmailAuthCredential=He,t.EmailAuthProvider=tt,t.FacebookAuthProvider=ot,t.FactorId={PHONE:"phone",TOTP:"totp"},t.FetchProvider=S,t.GithubAuthProvider=at,t.GoogleAuthProvider=st,t.OAuthCredential=Je,t.OAuthProvider=it,t.OperationType={LINK:"link",REAUTHENTICATE:"reauthenticate",SIGN_IN:"signIn"},t.PhoneAuthCredential=Ze,t.PhoneAuthProvider=An,t.PhoneMultiFactorGenerator=dr,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={...In}){this.parameters=n,this.type=wn,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,y("undefined"!=typeof document,this.auth,"operation-not-supported-in-this-environment");const r="string"==typeof t?document.getElementById(t):t;y(r,this.auth,"argument-error"),this.container=r,this.parameters.callback=this.makeTokenCallback(this.parameters.callback),this._recaptchaLoader=this.auth.settings.appVerificationDisabledForTesting?new _n:new bn,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(){y(!this.parameters.sitekey,this.auth,"argument-error"),y(this.isInvisible||!this.container.hasChildNodes(),this.auth,"argument-error"),y("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=rn()[e];"function"==typeof n&&n(t)}}}assertNotDestroyed(){y(!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(){y(w()&&!on(),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 R(e,"GET","/v1/recaptchaParams")).recaptchaSiteKey||""}(this.auth);y(e,this.auth,"internal-error"),this.parameters.sitekey=e}getAssertedRecaptcha(){return y(this.recaptcha,this.auth,"internal-error"),this.recaptcha}},t.SAMLAuthCredential=ct,t.SAMLAuthProvider=ut,t.SignInMethod={EMAIL_LINK:"emailLink",EMAIL_PASSWORD:"password",FACEBOOK:"facebook.com",GITHUB:"github.com",GOOGLE:"google.com",PHONE:"phone",TWITTER:"twitter.com"},t.TotpMultiFactorGenerator=fr,t.TotpSecret=mr,t.TwitterAuthProvider=lt,t.UserImpl=te,t._assert=y,t._castAuth=Ie,t._clearRedirectOutcomes=function(){Mn.clear()},t._createError=d,t._fail=h,t._generateEventId=tn,t._getClientVersion=ve,t._getInstance=re,t._getProjectConfig=Kn,t._getRedirectResult=qn,t._getRedirectUrl=ar,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=Fn,t._persistenceKeyName=se,t.applyActionCode=async function(e,t){await async function(e,t){return R(e,"POST","/v1/accounts:update",C(e,t))}(i.getModularInstance(e),{oobCode:t})},t.beforeAuthStateChanged=Ft,t.browserCookiePersistence=Yt,t.browserLocalPersistence=$t,t.browserPopupRedirectResolver=ur,t.browserSessionPersistence=Zt,t.checkActionCode=Ct,t.confirmPasswordReset=async function(e,t,n){await Be(i.getModularInstance(e),{oobCode:t,newPassword:n}).catch(async t=>{throw"auth/password-does-not-meet-requirements"===t.code&&Pt(e),t})},t.connectAuthEmulator=Fe,t.createUserWithEmailAndPassword=async function(e,t,n){if(r._isFirebaseServerApp(e.app))return Promise.reject(p(e));const i=Ie(e),o=Me(i,{returnSecureToken:!0,email:t,password:n,clientType:"CLIENT_TYPE_WEB"},"signUpPassword",ht,"EMAIL_PASSWORD_PROVIDER"),s=await o.catch(t=>{throw"auth/password-does-not-meet-requirements"===t.code&&Pt(e),t}),a=await dt._fromIdTokenResponse(i,"signIn",s);return await i._updateCurrentUser(a.user),a},t.debugAssert=b,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.","invalid-hosting-link-domain":"The provided Hosting link domain is not configured in Firebase Hosting or is not owned by the current project. This cannot be a default Hosting domain (`web.app` or `firebaseapp.com`)."}},t.deleteUser=async function(e){return i.getModularInstance(e).delete()},t.fetchSignInMethodsForEmail=async function(e,t){const n={identifier:t,continueUri:w()?_():"http://localhost"},{signinMethods:r}=await async function(e,t){return R(e,"POST","/v1/accounts:createAuthUri",C(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){if(!e)return null;const{providerId:t}=e,n=e.rawUserInfo?JSON.parse(e.rawUserInfo):{},r=e.isNewUser||"identitytoolkit#SignupNewUserResponse"===e.kind;if(!t&&e?.idToken){const t=G(e.idToken)?.firebase?.sign_in_provider;if(t)return new kt(r,"anonymous"!==t&&"custom"!==t?t:null)}if(!t)return null;switch(t){case"facebook.com":return new xt(r,n);case"github.com":return new Dt(r,n);case"google.com":return new Mt(r,n);case"twitter.com":return new Lt(r,n,e.screenName||null);case"custom":case"anonymous":return new kt(r,null);default:return new kt(r,t,n)}}(n)},t.getAuth=function(e=r.getApp()){const t=r._getProvider(e,"auth");if(t.isInitialized())return t.getImmediate();const n=je(e,{popupRedirectResolver:ur,persistence:[mn,$t,Zt]}),o=i.getExperimentalSetting("authTokenSyncURL");if(o&&"boolean"==typeof isSecureContext&&isSecureContext){const e=new URL(o,location.origin);if(location.origin===e.origin){const t=(s=e.toString(),async e=>{const t=e&&await e.getIdTokenResult(),n=t&&((new Date).getTime()-Date.parse(t.issuedAtTime))/1e3;if(n&&n>_r)return;const r=t?.token;wr!==r&&(wr=r,await fetch(s,{method:r?"POST":"DELETE",headers:r?{Authorization:`Bearer ${r}`}:{}}))});Ft(n,t,()=>t(n.currentUser)),jt(n,e=>t(e))}}var s;const a=i.getDefaultEmulatorHost("auth");return a&&Fe(n,`http://${a}`),n},t.getIdToken=function(e,t=!1){return i.getModularInstance(e).getIdToken(t)},t.getIdTokenResult=z,t.getMultiFactorResolver=function(e,t){const n=i.getModularInstance(e),r=t;return y(t.customData.operationType,n,"argument-error"),y(r.customData._serverResponse?.mfaPendingCredential,n,"argument-error"),Ut._fromError(n,r)},t.getRedirectResult=async function(e,t){return await Ie(e)._initializationPromise,qn(e,t,!1)},t.inMemoryPersistence=oe,t.indexedDBLocalPersistence=mn,t.initializeAuth=je,t.initializeRecaptchaConfig=function(e){return Le(e)},t.isSignInWithEmailLink=function(e,t){const n=et.parseLink(t);return"EMAIL_SIGNIN"===n?.operation},t.linkWithCredential=It,t.linkWithPhoneNumber=async function(e,t,n){const r=i.getModularInstance(e);await vt(!1,r,"phone");const o=await Tn(r.auth,t,i.getModularInstance(n));return new En(o,e=>It(r,e))},t.linkWithPopup=async function(e,t,n){const r=i.getModularInstance(e);m(r.auth,t,nt);const o=On(r.auth,n);return new Dn(r.auth,"linkViaPopup",t,o,r).executeNotNull()},t.linkWithRedirect=function(e,t,n){return async function(e,t,n){const r=i.getModularInstance(e);m(r.auth,t,nt),await r.auth._initializationPromise;const o=On(r.auth,n);await vt(!1,r,t.providerId),await jn(o,r.auth);const s=await Bn(r);return o._openRedirect(r.auth,t,"linkViaRedirect",s)}(e,t,n)},t.multiFactor=function(e){const t=i.getModularInstance(e);return zt.has(t)||zt.set(t,Bt._fromUser(t)),zt.get(t)},t.onAuthStateChanged=function(e,t,n,r){return i.getModularInstance(e).onAuthStateChanged(t,n,r)},t.onIdTokenChanged=jt,t.parseActionCodeURL=function(e){return et.parseLink(e)},t.prodErrorMap=a,t.reauthenticateWithCredential=Et,t.reauthenticateWithPhoneNumber=async function(e,t,n){const o=i.getModularInstance(e);if(r._isFirebaseServerApp(o.auth.app))return Promise.reject(p(o.auth));const s=await Tn(o.auth,t,i.getModularInstance(n));return new En(s,e=>Et(o,e))},t.reauthenticateWithPopup=async function(e,t,n){const o=i.getModularInstance(e);if(r._isFirebaseServerApp(o.auth.app))return Promise.reject(d(o.auth,"operation-not-supported-in-this-environment"));m(o.auth,t,nt);const s=On(o.auth,n);return new Dn(o.auth,"reauthViaPopup",t,s,o).executeNotNull()},t.reauthenticateWithRedirect=function(e,t,n){return async function(e,t,n){const o=i.getModularInstance(e);if(m(o.auth,t,nt),r._isFirebaseServerApp(o.auth.app))return Promise.reject(p(o.auth));await o.auth._initializationPromise;const s=On(o.auth,n);await jn(s,o.auth);const a=await Bn(o);return s._openRedirect(o.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&&Ot(n.auth,r,t);const{email:o}=await async function(e,t){return Ge(e,t)}(n.auth,r);o!==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&&Ot(r,i,n),await Me(r,i,"getOobCode",Ke,"EMAIL_PASSWORD_PROVIDER")},t.sendSignInLinkToEmail=async function(e,t,n){const r=Ie(e),i={requestType:"EMAIL_SIGNIN",email:t,clientType:"CLIENT_TYPE_WEB"};!function(e,t){y(t.handleCodeInApp,r,"argument-error"),t&&Ot(r,e,t)}(i,n),await Me(r,i,"getOobCode",$e,"EMAIL_PASSWORD_PROVIDER")},t.setPersistence=function(e,t){return i.getModularInstance(e).setPersistence(t)},t.signInAnonymously=async function(e){if(r._isFirebaseServerApp(e.app))return Promise.reject(p(e));const t=Ie(e);if(await t._initializationPromise,t.currentUser?.isAnonymous)return new dt({user:t.currentUser,providerId:null,operationType:"signIn"});const n=await ht(t,{returnSecureToken:!0}),i=await dt._fromIdTokenResponse(t,"signIn",n,!0);return await t._updateCurrentUser(i.user),i},t.signInWithCredential=wt,t.signInWithCustomToken=async function(e,t){if(r._isFirebaseServerApp(e.app))return Promise.reject(p(e));const n=Ie(e),i=await async function(e,t){return N(e,"POST","/v1/accounts:signInWithCustomToken",C(e,t))}(n,{token:t,returnSecureToken:!0}),o=await dt._fromIdTokenResponse(n,"signIn",i);return await n._updateCurrentUser(o.user),o},t.signInWithEmailAndPassword=function(e,t,n){return r._isFirebaseServerApp(e.app)?Promise.reject(p(e)):wt(i.getModularInstance(e),tt.credential(t,n)).catch(async t=>{throw"auth/password-does-not-meet-requirements"===t.code&&Pt(e),t})},t.signInWithEmailLink=async function(e,t,n){if(r._isFirebaseServerApp(e.app))return Promise.reject(p(e));const o=i.getModularInstance(e),s=tt.credentialWithLink(t,n||_());return y(s._tenantId===(o.tenantId||null),o,"tenant-id-mismatch"),wt(o,s)},t.signInWithPhoneNumber=async function(e,t,n){if(r._isFirebaseServerApp(e.app))return Promise.reject(p(e));const o=Ie(e),s=await Tn(o,t,i.getModularInstance(n));return new En(s,e=>wt(o,e))},t.signInWithPopup=async function(e,t,n){if(r._isFirebaseServerApp(e.app))return Promise.reject(d(e,"operation-not-supported-in-this-environment"));const i=Ie(e);m(e,t,nt);const o=On(i,n);return new Dn(i,"signInViaPopup",t,o).executeNotNull()},t.signInWithRedirect=function(e,t,n){return async function(e,t,n){if(r._isFirebaseServerApp(e.app))return Promise.reject(p(e));const i=Ie(e);m(e,t,nt),await i._initializationPromise;const o=On(i,n);return await jn(o,i),o._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 vt(!0,n,t);const{providerUserInfo:r}=await async function(e,t){return R(e,"POST","/v1/accounts:update",t)}(n.auth,{idToken:await n.getIdToken(),deleteProvider:[t]}),o=gt(r||[]);return n.providerData=n.providerData.filter(e=>o.has(e.providerId)),o.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(p(n.auth)):Rt(n,t,null)},t.updatePassword=function(e,t){return Rt(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(p(n.auth));await yt(n,t)},t.updateProfile=async function(e,{displayName:t,photoURL:n}){if(void 0===t&&void 0===n)return;const r=i.getModularInstance(e),o={idToken:await r.getIdToken(),displayName:t,photoUrl:n,returnSecureToken:!0},s=await $(r,async function(e,t){return R(e,"POST","/v1/accounts:update",t)}(r.auth,o));r.displayName=s.displayName||null,r.photoURL=s.photoUrl||null;const a=r.providerData.find(({providerId:e})=>"password"===e);a&&(a.displayName=r.displayName,a.photoURL=r.photoURL),await r._updateTokensIfNecessary(s)},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),o={requestType:"VERIFY_AND_CHANGE_EMAIL",idToken:await e.getIdToken(),newEmail:t};n&&Ot(r.auth,o,n);const{email:s}=await async function(e,t){return Ge(e,t)}(r.auth,o);s!==e.email&&await e.reload()},t.verifyPasswordResetCode=async function(e,t){const{data:n}=await Ct(i.getModularInstance(e),t);return n.email}},9970(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(6259);n(6199),n(6336),n(5844),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.browserCookiePersistence=r.browserCookiePersistence,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(6336);const i="[DEFAULT]";class o{constructor(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}get(e){const t=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(t)){const e=new r.Deferred;if(this.instancesDeferred.set(t,e),this.isInitialized(t)||this.shouldAutoInitialize())try{const n=this.getOrInitializeService({instanceIdentifier:t});n&&e.resolve(n)}catch(e){}}return this.instancesDeferred.get(t).promise}getImmediate(e){const t=this.normalizeInstanceIdentifier(e?.identifier),n=e?.optional??!1;if(!this.isInitialized(t)&&!this.shouldAutoInitialize()){if(n)return null;throw Error(`Service ${this.name} is not available`)}try{return this.getOrInitializeService({instanceIdentifier:t})}catch(e){if(n)return null;throw e}}getComponent(){return this.component}setComponent(e){if(e.name!==this.name)throw Error(`Mismatching Component ${e.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=e,this.shouldAutoInitialize()){if(function(e){return"EAGER"===e.instantiationMode}(e))try{this.getOrInitializeService({instanceIdentifier:i})}catch(e){}for(const[e,t]of this.instancesDeferred.entries()){const n=this.normalizeInstanceIdentifier(e);try{const e=this.getOrInitializeService({instanceIdentifier:n});t.resolve(e)}catch(e){}}}}clearInstance(e=i){this.instancesDeferred.delete(e),this.instancesOptions.delete(e),this.instances.delete(e)}async delete(){const e=Array.from(this.instances.values());await Promise.all([...e.filter(e=>"INTERNAL"in e).map(e=>e.INTERNAL.delete()),...e.filter(e=>"_delete"in e).map(e=>e._delete())])}isComponentSet(){return null!=this.component}isInitialized(e=i){return this.instances.has(e)}getOptions(e=i){return this.instancesOptions.get(e)||{}}initialize(e={}){const{options:t={}}=e,n=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(n))throw Error(`${this.name}(${n}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const r=this.getOrInitializeService({instanceIdentifier:n,options:t});for(const[e,t]of this.instancesDeferred.entries())n===this.normalizeInstanceIdentifier(e)&&t.resolve(r);return r}onInit(e,t){const n=this.normalizeInstanceIdentifier(t),r=this.onInitCallbacks.get(n)??new Set;r.add(e),this.onInitCallbacks.set(n,r);const i=this.instances.get(n);return i&&e(i,n),()=>{r.delete(e)}}invokeOnInitCallbacks(e,t){const n=this.onInitCallbacks.get(t);if(n)for(const r of n)try{r(e,t)}catch{}}getOrInitializeService({instanceIdentifier:e,options:t={}}){let n=this.instances.get(e);if(!n&&this.component&&(n=this.component.instanceFactory(this.container,{instanceIdentifier:(r=e,r===i?void 0:r),options:t}),this.instances.set(e,n),this.instancesOptions.set(e,t),this.invokeOnInitCallbacks(n,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,n)}catch{}var r;return n||null}normalizeInstanceIdentifier(e=i){return this.component?this.component.multipleInstances?e:i:e}shouldAutoInitialize(){return!!this.component&&"EXPLICIT"!==this.component.instantiationMode}}t.Component=class{constructor(e,t,n){this.name=e,this.instanceFactory=t,this.type=n,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(e){return this.instantiationMode=e,this}setMultipleInstances(e){return this.multipleInstances=e,this}setServiceProps(e){return this.serviceProps=e,this}setInstanceCreatedCallback(e){return this.onInstanceCreated=e,this}},t.ComponentContainer=class{constructor(e){this.name=e,this.providers=new Map}addComponent(e){const t=this.getProvider(e.name);if(t.isComponentSet())throw new Error(`Component ${e.name} has already been registered with ${this.name}`);t.setComponent(e)}addOrOverwriteComponent(e){this.getProvider(e.name).isComponentSet()&&this.providers.delete(e.name),this.addComponent(e)}getProvider(e){if(this.providers.has(e))return this.providers.get(e);const t=new o(e,this);return this.providers.set(e,t),t}getProviders(){return Array.from(this.providers.values())}},t.Provider=o},8584(e,t,n){"use strict";var r=n(6199),i=n(6336),o=n(860),s=n(5844),a=n(4832);class c{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}}c.UNAUTHENTICATED=new c(null),c.GOOGLE_CREDENTIALS=new c("google-credentials-uid"),c.FIRST_PARTY=new c("first-party-uid"),c.MOCK_USER=new c("mock-user");let u="12.10.0";const l=new s.Logger("@firebase/firestore");function h(){return l.logLevel}function d(e,...t){if(l.logLevel<=s.LogLevel.DEBUG){const n=t.map(m);l.debug(`Firestore (${u}): ${e}`,...n)}}function f(e,...t){if(l.logLevel<=s.LogLevel.ERROR){const n=t.map(m);l.error(`Firestore (${u}): ${e}`,...n)}}function p(e,...t){if(l.logLevel<=s.LogLevel.WARN){const n=t.map(m);l.warn(`Firestore (${u}): ${e}`,...n)}}function m(e){if("string"==typeof e)return e;try{return function(e){return JSON.stringify(e)}(e)}catch(t){return e}}function g(e,t,n){let r="Unexpected state";"string"==typeof t?r=t:n=t,y(e,r,n)}function y(e,t,n){let r=`FIRESTORE (${u}) INTERNAL ASSERTION FAILED: ${t} (ID: ${e.toString(16)})`;if(void 0!==n)try{r+=" CONTEXT: "+JSON.stringify(n)}catch(e){r+=" CONTEXT: "+n}throw f(r),new Error(r)}function v(e,t,n,r){let i="Unexpected state";"string"==typeof n?i=n:r=n,e||y(t,i,r)}function b(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 w extends i.FirebaseError{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}class I{constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}class E{constructor(e,t){this.user=t,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class T{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable(()=>t(c.UNAUTHENTICATED))}shutdown(){}}class S{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,t,n){this.P=e,this.T=t,this.I=n,this.type="FirstParty",this.user=c.FIRST_PARTY,this.R=new Map}A(){return this.I?this.I():null}get headers(){this.R.set("X-Goog-AuthUser",this.P);const e=this.A();return e&&this.R.set("Authorization",e),this.T&&this.R.set("X-Goog-Iam-Authorization-Token",this.T),this.R}}class O{constructor(e,t,n){this.P=e,this.T=t,this.I=n}getToken(){return Promise.resolve(new A(this.P,this.T,this.I))}start(e,t){e.enqueueRetryable(()=>t(c.FIRST_PARTY))}shutdown(){}invalidateToken(){}}class P{constructor(e){this.value=e,this.type="AppCheck",this.headers=new Map,e&&e.length>0&&this.headers.set("x-firebase-appcheck",this.value)}}function C(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=C(40);for(let r=0;r<n.length;++r)t.length<20&&n[r]<e&&(t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(n[r]%62))}return t}}function k(e,t){return e<t?-1:e>t?1:0}function N(e,t){const n=Math.min(e.length,t.length);for(let r=0;r<n;r++){const n=e.charAt(r),i=t.charAt(r);if(n!==i)return x(n)===x(i)?k(n,i):x(n)?1:-1}return k(e.length,t.length)}function x(e){const t=e.charCodeAt(0);return t>=55296&&t<=57343}function D(e,t,n){return e.length===t.length&&e.every((e,r)=>n(e,t[r]))}function M(e){return e+"\0"}const L="__name__";class j{constructor(e,t,n){void 0===t?t=0:t>e.length&&g(637,{offset:t,range:e.length}),void 0===n?n=e.length-t:n>e.length-t&&g(1746,{length:n,range:e.length-t}),this.segments=e,this.offset=t,this.len=n}get length(){return this.len}isEqual(e){return 0===j.comparator(this,e)}child(e){const t=this.segments.slice(this.offset,this.limit());return e instanceof j?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=j.compareSegments(e.get(r),t.get(r));if(0!==n)return n}return k(e.length,t.length)}static compareSegments(e,t){const n=j.isNumericId(e),r=j.isNumericId(t);return n&&!r?-1:!n&&r?1:n&&r?j.extractNumericId(e).compare(j.extractNumericId(t)):N(e,t)}static isNumericId(e){return e.startsWith("__id")&&e.endsWith("__")}static extractNumericId(e){return o.Integer.fromString(e.substring(4,e.length-2))}}class F extends j{construct(e,t,n){return new F(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 w(_.INVALID_ARGUMENT,`Invalid segment (${n}). Paths must not contain // in them.`);t.push(...n.split("/").filter(e=>e.length>0))}return new F(t)}static emptyPath(){return new F([])}}const V=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class U extends j{construct(e,t,n){return new U(e,t,n)}static isValidIdentifier(e){return V.test(e)}canonicalString(){return this.toArray().map(e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),U.isValidIdentifier(e)||(e="`"+e+"`"),e)).join(".")}toString(){return this.canonicalString()}isKeyField(){return 1===this.length&&this.get(0)===L}static keyField(){return new U([L])}static fromServerFormat(e){const t=[];let n="",r=0;const i=()=>{if(0===n.length)throw new w(_.INVALID_ARGUMENT,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);t.push(n),n=""};let o=!1;for(;r<e.length;){const t=e[r];if("\\"===t){if(r+1===e.length)throw new w(_.INVALID_ARGUMENT,"Path has trailing escape character: "+e);const t=e[r+1];if("\\"!==t&&"."!==t&&"`"!==t)throw new w(_.INVALID_ARGUMENT,"Path has invalid escape sequence: "+e);n+=t,r+=2}else"`"===t?(o=!o,r++):"."!==t||o?(n+=t,r++):(i(),r++)}if(i(),o)throw new w(_.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new U(t)}static emptyPath(){return new U([])}}class q{constructor(e){this.path=e}static fromPath(e){return new q(F.fromString(e))}static fromName(e){return new q(F.fromString(e).popFirst(5))}static empty(){return new q(F.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===F.comparator(this.path,e.path)}toString(){return this.path.toString()}static comparator(e,t){return F.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new q(new F(e.slice()))}}function B(e,t,n){if(!n)throw new w(_.INVALID_ARGUMENT,`Function ${e}() cannot be called with an empty ${t}.`)}function z(e,t,n,r){if(!0===t&&!0===r)throw new w(_.INVALID_ARGUMENT,`${e} and ${n} cannot be used together.`)}function W(e){if(!q.isDocumentKey(e))throw new w(_.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${e} has ${e.length}.`)}function G(e){if(q.isDocumentKey(e))throw new w(_.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${e} has ${e.length}.`)}function K(e){return"object"==typeof e&&null!==e&&(Object.getPrototypeOf(e)===Object.prototype||null===Object.getPrototypeOf(e))}function $(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":g(12329,{type:typeof e})}function H(e,t){if("_delegate"in e&&(e=e._delegate),!(e instanceof t)){if(t.name===e.constructor.name)throw new w(_.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{const n=$(e);throw new w(_.INVALID_ARGUMENT,`Expected type '${t.name}', but it was: ${n}`)}}return e}function Q(e,t){const n={typeString:e};return t&&(n.value=t),n}function J(e,t){if(!K(e))throw new w(_.INVALID_ARGUMENT,"JSON must be an object");let n;for(const r in t)if(t[r]){const i=t[r].typeString,o="value"in t[r]?{value:t[r].value}:void 0;if(!(r in e)){n=`JSON missing required field: '${r}'`;break}const s=e[r];if(i&&typeof s!==i){n=`JSON field '${r}' must be a ${i}.`;break}if(void 0!==o&&s!==o.value){n=`Expected '${r}' field to equal '${o.value}'`;break}}if(n)throw new w(_.INVALID_ARGUMENT,n);return!0}const Y=-62135596800,X=1e6;class Z{static now(){return Z.fromMillis(Date.now())}static fromDate(e){return Z.fromMillis(e.getTime())}static fromMillis(e){const t=Math.floor(e/1e3),n=Math.floor((e-1e3*t)*X);return new Z(t,n)}constructor(e,t){if(this.seconds=e,this.nanoseconds=t,t<0)throw new w(_.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(t>=1e9)throw new w(_.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(e<Y)throw new w(_.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e);if(e>=253402300800)throw new w(_.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/X}_compareTo(e){return this.seconds===e.seconds?k(this.nanoseconds,e.nanoseconds):k(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{type:Z._jsonSchemaVersion,seconds:this.seconds,nanoseconds:this.nanoseconds}}static fromJSON(e){if(J(e,Z._jsonSchema))return new Z(e.seconds,e.nanoseconds)}valueOf(){const e=this.seconds-Y;return String(e).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}Z._jsonSchemaVersion="firestore/timestamp/1.0",Z._jsonSchema={type:Q("string",Z._jsonSchemaVersion),seconds:Q("number"),nanoseconds:Q("number")};class ee{static fromTimestamp(e){return new ee(e)}static min(){return new ee(new Z(0,0))}static max(){return new ee(new Z(253402300799,999999999))}constructor(e){this.timestamp=e}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}}const te=-1;class ne{constructor(e,t,n,r){this.indexId=e,this.collectionGroup=t,this.fields=n,this.indexState=r}}function re(e){return e.fields.find(e=>2===e.kind)}function ie(e){return e.fields.filter(e=>2!==e.kind)}function oe(e,t){let n=k(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=ae(e.fields[r],t.fields[r]),0!==n)return n;return k(e.fields.length,t.fields.length)}ne.UNKNOWN_ID=-1;class se{constructor(e,t){this.fieldPath=e,this.kind=t}}function ae(e,t){const n=U.comparator(e.fieldPath,t.fieldPath);return 0!==n?n:k(e.kind,t.kind)}class ce{constructor(e,t){this.sequenceNumber=e,this.offset=t}static empty(){return new ce(0,he.min())}}function ue(e,t){const n=e.toTimestamp().seconds,r=e.toTimestamp().nanoseconds+1,i=ee.fromTimestamp(1e9===r?new Z(n+1,0):new Z(n,r));return new he(i,q.empty(),t)}function le(e){return new he(e.readTime,e.key,te)}class he{constructor(e,t,n){this.readTime=e,this.documentKey=t,this.largestBatchId=n}static min(){return new he(ee.min(),q.empty(),te)}static max(){return new he(ee.max(),q.empty(),te)}}function de(e,t){let n=e.readTime.compareTo(t.readTime);return 0!==n?n:(n=q.comparator(e.documentKey,t.documentKey),0!==n?n:k(e.largestBatchId,t.largestBatchId))}const fe="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class pe{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach(e=>e())}}async function me(e){if(e.code!==_.FAILED_PRECONDITION||e.message!==fe)throw e;d("LocalStore","Unexpectedly lost primary lease")}class ge{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&&g(59440),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(t,this.error):this.wrapSuccess(e,this.result):new ge((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 ge?t:ge.resolve(t)}catch(e){return ge.reject(e)}}wrapSuccess(e,t){return e?this.wrapUserFunction(()=>e(t)):ge.resolve(t)}wrapFailure(e,t){return e?this.wrapUserFunction(()=>e(t)):ge.reject(t)}static resolve(e){return new ge((t,n)=>{t(e)})}static reject(e){return new ge((t,n)=>{n(e)})}static waitFor(e){return new ge((t,n)=>{let r=0,i=0,o=!1;e.forEach(e=>{++r,e.next(()=>{++i,o&&i===r&&t()},e=>n(e))}),o=!0,i===r&&t()})}static or(e){let t=ge.resolve(!1);for(const n of e)t=t.next(e=>e?ge.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 ge((n,r)=>{const i=e.length,o=new Array(i);let s=0;for(let a=0;a<i;a++){const c=a;t(e[c]).next(e=>{o[c]=e,++s,s===i&&n(o)},e=>r(e))}})}static doWhile(e,t){return new ge((n,r)=>{const i=()=>{!0===e()?t().next(()=>{i()},r):n()};i()})}}const ye="SimpleDb";class ve{static open(e,t,n,r){try{return new ve(t,e.transaction(r,n))}catch(e){throw new Ie(t,e)}}constructor(e,t){this.action=e,this.transaction=t,this.aborted=!1,this.S=new I,this.transaction.oncomplete=()=>{this.S.resolve()},this.transaction.onabort=()=>{t.error?this.S.reject(new Ie(e,t.error)):this.S.resolve()},this.transaction.onerror=t=>{const n=Oe(t.target.error);this.S.reject(new Ie(e,n))}}get D(){return this.S.promise}abort(e){e&&this.S.reject(e),this.aborted||(d(ye,"Aborting transaction:",e?e.message:"Client-initiated abort"),this.aborted=!0,this.transaction.abort())}C(){const e=this.transaction;this.aborted||"function"!=typeof e.commit||e.commit()}store(e){const t=this.transaction.objectStore(e);return new Te(t)}}class be{static delete(e){return d(ye,"Removing database:",e),Se(i.getGlobal().indexedDB.deleteDatabase(e)).toPromise()}static v(){if(!i.isIndexedDBAvailable())return!1;if(be.F())return!0;const e=i.getUA(),t=be.M(e),n=0<t&&t<10,r=_e(e),o=0<r&&r<4.5;return!(e.indexOf("MSIE ")>0||e.indexOf("Trident/")>0||e.indexOf("Edge/")>0||n||o)}static F(){return"undefined"!=typeof process&&"YES"===process.__PRIVATE_env?.__PRIVATE_USE_MOCK_PERSISTENCE}static O(e,t){return e.store(t)}static M(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)}constructor(e,t,n){this.name=e,this.version=t,this.N=n,this.B=null,12.2===be.M(i.getUA())&&f("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.")}async L(e){return this.db||(d(ye,"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 Ie(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 w(_.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 w(_.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 Ie(e,r))},r.onupgradeneeded=e=>{d(ye,'Database "'+this.name+'" requires upgrade from version:',e.oldVersion);const t=e.target.result;this.N.k(t,r.transaction,e.oldVersion,this.version).next(()=>{d(ye,"Database upgrade to version "+this.version+" complete")})}})),this.K&&(this.db.onversionchange=e=>this.K(e)),this.db}q(e){this.K=e,this.db&&(this.db.onversionchange=t=>e(t))}async runTransaction(e,t,n,r){const i="readonly"===t;let o=0;for(;;){++o;try{this.db=await this.L(e);const t=ve.open(this.db,e,i?"readonly":"readwrite",n),o=r(t).next(e=>(t.C(),e)).catch(e=>(t.abort(e),ge.reject(e))).toPromise();return o.catch(()=>{}),await t.D,o}catch(e){const t=e,n="FirebaseError"!==t.name&&o<3;if(d(ye,"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 _e(e){const t=e.match(/Android ([\d.]+)/i),n=t?t[1].split(".").slice(0,2).join("."):"-1";return Number(n)}class we{constructor(e){this.U=e,this.$=!1,this.W=null}get isDone(){return this.$}get G(){return this.W}set cursor(e){this.U=e}done(){this.$=!0}j(e){this.W=e}delete(){return Se(this.U.delete())}}class Ie extends w{constructor(e,t){super(_.UNAVAILABLE,`IndexedDB transaction '${e}' failed: ${t}`),this.name="IndexedDbTransactionError"}}function Ee(e){return"IndexedDbTransactionError"===e.name}class Te{constructor(e){this.store=e}put(e,t){let n;return void 0!==t?(d(ye,"PUT",this.store.name,e,t),n=this.store.put(t,e)):(d(ye,"PUT",this.store.name,"<auto-key>",e),n=this.store.put(e)),Se(n)}add(e){return d(ye,"ADD",this.store.name,e,e),Se(this.store.add(e))}get(e){return Se(this.store.get(e)).next(t=>(void 0===t&&(t=null),d(ye,"GET",this.store.name,e,t),t))}delete(e){return d(ye,"DELETE",this.store.name,e),Se(this.store.delete(e))}count(){return d(ye,"COUNT",this.store.name),Se(this.store.count())}H(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 ge((t,n)=>{e.onerror=e=>{n(e.target.error)},e.onsuccess=e=>{t(e.target.result)}})}{const e=this.cursor(n),t=[];return this.J(e,(e,n)=>{t.push(n)}).next(()=>t)}}Z(e,t){const n=this.store.getAll(e,null===t?void 0:t);return new ge((e,t)=>{n.onerror=e=>{t(e.target.error)},n.onsuccess=t=>{e(t.target.result)}})}X(e,t){d(ye,"DELETE ALL",this.store.name);const n=this.options(e,t);n.Y=!1;const r=this.cursor(n);return this.J(r,(e,t,n)=>n.delete())}ee(e,t){let n;t?n=e:(n={},t=e);const r=this.cursor(n);return this.J(r,t)}te(e){const t=this.cursor({});return new ge((n,r)=>{t.onerror=e=>{const t=Oe(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()}})}J(e,t){const n=[];return new ge((r,i)=>{e.onerror=e=>{i(e.target.error)},e.onsuccess=e=>{const i=e.target.result;if(!i)return void r();const o=new we(i),s=t(i.primaryKey,i.value,o);if(s instanceof ge){const e=s.catch(e=>(o.done(),ge.reject(e)));n.push(e)}o.isDone?r():null===o.G?i.continue():i.continue(o.G)}}).next(()=>ge.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.Y?n.openKeyCursor(e.range,t):n.openCursor(e.range,t)}return this.store.openCursor(e.range,t)}}function Se(e){return new ge((t,n)=>{e.onsuccess=e=>{const n=e.target.result;t(n)},e.onerror=e=>{const t=Oe(e.target.error);n(t)}})}let Ae=!1;function Oe(e){const t=be.M(i.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 w("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 Ae||(Ae=!0,setTimeout(()=>{throw e},0)),e}}return e}const Pe="IndexBackfiller";class Ce{constructor(e,t){this.asyncQueue=e,this.ne=t,this.task=null}start(){this.re(15e3)}stop(){this.task&&(this.task.cancel(),this.task=null)}get started(){return null!==this.task}re(e){d(Pe,`Scheduled in ${e}ms`),this.task=this.asyncQueue.enqueueAfterDelay("index_backfill",e,async()=>{this.task=null;try{const e=await this.ne.ie();d(Pe,`Documents written: ${e}`)}catch(e){Ee(e)?d(Pe,"Ignoring IndexedDB error during index backfill: ",e):await me(e)}await this.re(6e4)})}}class Re{constructor(e,t){this.localStore=e,this.persistence=t}async ie(e=50){return this.persistence.runTransaction("Backfill Indexes","readwrite-primary",t=>this.se(t,e))}se(e,t){const n=new Set;let r=t,i=!0;return ge.doWhile(()=>!0===i&&r>0,()=>this.localStore.indexManager.getNextCollectionGroupToUpdate(e).next(t=>{if(null!==t&&!n.has(t))return d(Pe,`Processing collection: ${t}`),this.oe(e,t,r).next(e=>{r-=e,n.add(t)});i=!1})).next(()=>t-r)}oe(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._e(r,n)).next(n=>(d(Pe,`Updating offset: ${n}`),this.localStore.indexManager.updateCollectionGroup(e,t,n))).next(()=>i.size)}))}_e(e,t){let n=e;return t.changes.forEach((e,t)=>{const r=le(t);de(r,n)>0&&(n=r)}),new he(n.readTime,n.documentKey,Math.max(t.batchId,e.largestBatchId))}}class ke{constructor(e,t){this.previousValue=e,t&&(t.sequenceNumberHandler=e=>this.ae(e),this.ue=e=>t.writeSequenceNumber(e))}ae(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}next(){const e=++this.previousValue;return this.ue&&this.ue(e),e}}ke.ce=-1;const Ne=-1;function xe(e){return null==e}function De(e){return 0===e&&1/e==-1/0}function Me(e){return"number"==typeof e&&Number.isInteger(e)&&!De(e)&&e<=Number.MAX_SAFE_INTEGER&&e>=Number.MIN_SAFE_INTEGER}const Le="";function je(e){let t="";for(let n=0;n<e.length;n++)t.length>0&&(t=Ve(t)),t=Fe(e.get(n),t);return Ve(t)}function Fe(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 Le:n+="";break;default:n+=r}}return n}function Ve(e){return e+Le+""}function Ue(e){const t=e.length;if(v(t>=2,64408,{path:e}),2===t)return v(e.charAt(0)===Le&&""===e.charAt(1),56145,{path:e}),F.emptyPath();const n=t-2,r=[];let i="";for(let o=0;o<t;){const t=e.indexOf(Le,o);switch((t<0||t>n)&&g(50515,{path:e}),e.charAt(t+1)){case"":const n=e.substring(o,t);let s;0===i.length?s=n:(i+=n,s=i,i=""),r.push(s);break;case"":i+=e.substring(o,t),i+="\0";break;case"":i+=e.substring(o,t+1);break;default:g(61167,{path:e})}o=t+2}return new F(r)}const qe="remoteDocuments",Be="owner",ze="owner",We="mutationQueues",Ge="mutations",Ke="batchId",$e="userMutationsIndex",He=["userId","batchId"];function Qe(e,t){return[e,je(t)]}function Je(e,t,n){return[e,je(t),n]}const Ye={},Xe="documentMutations",Ze="remoteDocumentsV14",et=["prefixPath","collectionGroup","readTime","documentId"],tt="documentKeyIndex",nt=["prefixPath","collectionGroup","documentId"],rt="collectionGroupIndex",it=["collectionGroup","readTime","prefixPath","documentId"],ot="remoteDocumentGlobal",st="remoteDocumentGlobalKey",at="targets",ct="queryTargetsIndex",ut=["canonicalId","targetId"],lt="targetDocuments",ht=["targetId","path"],dt="documentTargetsIndex",ft=["path","targetId"],pt="targetGlobalKey",mt="targetGlobal",gt="collectionParents",yt=["collectionId","parent"],vt="clientMetadata",bt="bundles",_t="namedQueries",wt="indexConfiguration",It="collectionGroupIndex",Et="indexState",Tt=["indexId","uid"],St="sequenceNumberIndex",At=["uid","sequenceNumber"],Ot="indexEntries",Pt=["indexId","uid","arrayValue","directionalValue","orderedDocumentKey","documentKey"],Ct="documentKeyIndex",Rt=["indexId","uid","orderedDocumentKey"],kt="documentOverlays",Nt=["userId","collectionPath","documentId"],xt="collectionPathOverlayIndex",Dt=["userId","collectionPath","largestBatchId"],Mt="collectionGroupOverlayIndex",Lt=["userId","collectionGroup","largestBatchId"],jt="globals",Ft=[We,Ge,Xe,qe,at,Be,mt,lt,vt,ot,gt,bt,_t],Vt=[...Ft,kt],Ut=[We,Ge,Xe,Ze,at,Be,mt,lt,vt,ot,gt,bt,_t,kt],qt=Ut,Bt=[...qt,wt,Et,Ot],zt=Bt,Wt=[...Bt,jt],Gt=Wt;class Kt extends pe{constructor(e,t){super(),this.le=e,this.currentSequenceNumber=t}}function $t(e,t){const n=b(e);return be.O(n.le,t)}function Ht(e){let t=0;for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}function Qt(e,t){for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t(n,e[n])}function Jt(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 Yt(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}class Xt{constructor(e,t){this.comparator=e,this.root=t||en.EMPTY}insert(e,t){return new Xt(this.comparator,this.root.insert(e,t,this.comparator).copy(null,null,en.BLACK,null,null))}remove(e){return new Xt(this.comparator,this.root.remove(e,this.comparator).copy(null,null,en.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 Zt(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new Zt(this.root,e,this.comparator,!1)}getReverseIterator(){return new Zt(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new Zt(this.root,e,this.comparator,!0)}}class Zt{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 en{constructor(e,t,n,r,i){this.key=e,this.value=t,this.color=null!=n?n:en.RED,this.left=null!=r?r:en.EMPTY,this.right=null!=i?i:en.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,t,n,r,i){return new en(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 en.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 en.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,en.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){const e=this.copy(null,null,en.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 g(43730,{key:this.key,value:this.value});if(this.right.isRed())throw g(14113,{key:this.key,value:this.value});const e=this.left.check();if(e!==this.right.check())throw g(27949);return e+(this.isRed()?0:1)}}en.EMPTY=null,en.RED=!0,en.BLACK=!1,en.EMPTY=new class{constructor(){this.size=0}get key(){throw g(57766)}get value(){throw g(16141)}get color(){throw g(16727)}get left(){throw g(29726)}get right(){throw g(36894)}copy(e,t,n,r,i){return this}insert(e,t,n){return new en(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 tn{constructor(e){this.comparator=e,this.data=new Xt(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 nn(this.data.getIterator())}getIteratorFrom(e){return new nn(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 tn))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 tn(this.comparator);return t.data=e,t}}class nn{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}function rn(e){return e.hasNext()?e.getNext():void 0}class on{constructor(e){this.fields=e,e.sort(U.comparator)}static empty(){return new on([])}unionWith(e){let t=new tn(U.comparator);for(const e of this.fields)t=t.add(e);for(const n of e)t=t.add(n);return new on(t.toArray())}covers(e){for(const t of this.fields)if(t.isPrefixOf(e))return!0;return!1}isEqual(e){return D(this.fields,e.fields,(e,t)=>e.isEqual(t))}}class sn extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}class an{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 sn("Invalid base64 string: "+e):e}}(e);return new an(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 an(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 k(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}}an.EMPTY_BYTE_STRING=new an("");const cn=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function un(e){if(v(!!e,39018),"string"==typeof e){let t=0;const n=cn.exec(e);if(v(!!n,46558,{timestamp:e}),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:ln(e.seconds),nanos:ln(e.nanos)}}function ln(e){return"number"==typeof e?e:"string"==typeof e?Number(e):0}function hn(e){return"string"==typeof e?an.fromBase64String(e):an.fromUint8Array(e)}const dn="server_timestamp",fn="__type__",pn="__previous_value__",mn="__local_write_time__";function gn(e){const t=(e?.mapValue?.fields||{})[fn]?.stringValue;return t===dn}function yn(e){const t=e.mapValue.fields[pn];return gn(t)?yn(t):t}function vn(e){const t=un(e.mapValue.fields[mn].timestampValue);return new Z(t.seconds,t.nanos)}class bn{constructor(e,t,n,r,i,o,s,a,c,u,l){this.databaseId=e,this.appId=t,this.persistenceKey=n,this.host=r,this.ssl=i,this.forceLongPolling=o,this.autoDetectLongPolling=s,this.longPollingOptions=a,this.useFetchStreams=c,this.isUsingEmulator=u,this.apiKey=l}}const _n="(default)";class wn{constructor(e,t){this.projectId=e,this.database=t||_n}static empty(){return new wn("","")}get isDefaultDatabase(){return this.database===_n}isEqual(e){return e instanceof wn&&e.projectId===this.projectId&&e.database===this.database}}const In="__type__",En="__max__",Tn={mapValue:{fields:{__type__:{stringValue:En}}}},Sn="__vector__",An="value",On={nullValue:"NULL_VALUE"};function Pn(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?gn(e)?4:Gn(e)?9007199254740991:zn(e)?10:11:g(28295,{value:e})}function Cn(e,t){if(e===t)return!0;const n=Pn(e);if(n!==Pn(t))return!1;switch(n){case 0:case 9007199254740991:return!0;case 1:return e.booleanValue===t.booleanValue;case 4:return vn(e).isEqual(vn(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=un(e.timestampValue),r=un(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 hn(e.bytesValue).isEqual(hn(t.bytesValue))}(e,t);case 7:return e.referenceValue===t.referenceValue;case 8:return function(e,t){return ln(e.geoPointValue.latitude)===ln(t.geoPointValue.latitude)&&ln(e.geoPointValue.longitude)===ln(t.geoPointValue.longitude)}(e,t);case 2:return function(e,t){if("integerValue"in e&&"integerValue"in t)return ln(e.integerValue)===ln(t.integerValue);if("doubleValue"in e&&"doubleValue"in t){const n=ln(e.doubleValue),r=ln(t.doubleValue);return n===r?De(n)===De(r):isNaN(n)&&isNaN(r)}return!1}(e,t);case 9:return D(e.arrayValue.values||[],t.arrayValue.values||[],Cn);case 10:case 11:return function(e,t){const n=e.mapValue.fields||{},r=t.mapValue.fields||{};if(Ht(n)!==Ht(r))return!1;for(const e in n)if(n.hasOwnProperty(e)&&(void 0===r[e]||!Cn(n[e],r[e])))return!1;return!0}(e,t);default:return g(52216,{left:e})}}function Rn(e,t){return void 0!==(e.values||[]).find(e=>Cn(e,t))}function kn(e,t){if(e===t)return 0;const n=Pn(e),r=Pn(t);if(n!==r)return k(n,r);switch(n){case 0:case 9007199254740991:return 0;case 1:return k(e.booleanValue,t.booleanValue);case 2:return function(e,t){const n=ln(e.integerValue||e.doubleValue),r=ln(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 Nn(e.timestampValue,t.timestampValue);case 4:return Nn(vn(e),vn(t));case 5:return N(e.stringValue,t.stringValue);case 6:return function(e,t){const n=hn(e),r=hn(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=k(n[e],r[e]);if(0!==t)return t}return k(n.length,r.length)}(e.referenceValue,t.referenceValue);case 8:return function(e,t){const n=k(ln(e.latitude),ln(t.latitude));return 0!==n?n:k(ln(e.longitude),ln(t.longitude))}(e.geoPointValue,t.geoPointValue);case 9:return xn(e.arrayValue,t.arrayValue);case 10:return function(e,t){const n=e.fields||{},r=t.fields||{},i=n[An]?.arrayValue,o=r[An]?.arrayValue,s=k(i?.values?.length||0,o?.values?.length||0);return 0!==s?s:xn(i,o)}(e.mapValue,t.mapValue);case 11:return function(e,t){if(e===Tn.mapValue&&t===Tn.mapValue)return 0;if(e===Tn.mapValue)return 1;if(t===Tn.mapValue)return-1;const n=e.fields||{},r=Object.keys(n),i=t.fields||{},o=Object.keys(i);r.sort(),o.sort();for(let e=0;e<r.length&&e<o.length;++e){const t=N(r[e],o[e]);if(0!==t)return t;const s=kn(n[r[e]],i[o[e]]);if(0!==s)return s}return k(r.length,o.length)}(e.mapValue,t.mapValue);default:throw g(23264,{he:n})}}function Nn(e,t){if("string"==typeof e&&"string"==typeof t&&e.length===t.length)return k(e,t);const n=un(e),r=un(t),i=k(n.seconds,r.seconds);return 0!==i?i:k(n.nanos,r.nanos)}function xn(e,t){const n=e.values||[],r=t.values||[];for(let e=0;e<n.length&&e<r.length;++e){const t=kn(n[e],r[e]);if(t)return t}return k(n.length,r.length)}function Dn(e){return Mn(e)}function Mn(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=un(e);return`time(${t.seconds},${t.nanos})`}(e.timestampValue):"stringValue"in e?e.stringValue:"bytesValue"in e?function(e){return hn(e).toBase64()}(e.bytesValue):"referenceValue"in e?function(e){return q.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+=Mn(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}:${Mn(e.fields[i])}`;return n+"}"}(e.mapValue):g(61005,{value:e})}function Ln(e){switch(Pn(e)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:const t=yn(e);return t?16+Ln(t):16;case 5:return 2*e.stringValue.length;case 6:return hn(e.bytesValue).approximateByteSize();case 7:return e.referenceValue.length;case 9:return function(e){return(e.values||[]).reduce((e,t)=>e+Ln(t),0)}(e.arrayValue);case 10:case 11:return function(e){let t=0;return Qt(e.fields,(e,n)=>{t+=e.length+Ln(n)}),t}(e.mapValue);default:throw g(13486,{value:e})}}function jn(e,t){return{referenceValue:`projects/${e.projectId}/databases/${e.database}/documents/${t.path.canonicalString()}`}}function Fn(e){return!!e&&"integerValue"in e}function Vn(e){return!!e&&"arrayValue"in e}function Un(e){return!!e&&"nullValue"in e}function qn(e){return!!e&&"doubleValue"in e&&isNaN(Number(e.doubleValue))}function Bn(e){return!!e&&"mapValue"in e}function zn(e){const t=(e?.mapValue?.fields||{})[In]?.stringValue;return t===Sn}function Wn(e){if(e.geoPointValue)return{geoPointValue:{...e.geoPointValue}};if(e.timestampValue&&"object"==typeof e.timestampValue)return{timestampValue:{...e.timestampValue}};if(e.mapValue){const t={mapValue:{fields:{}}};return Qt(e.mapValue.fields,(e,n)=>t.mapValue.fields[e]=Wn(n)),t}if(e.arrayValue){const t={arrayValue:{values:[]}};for(let n=0;n<(e.arrayValue.values||[]).length;++n)t.arrayValue.values[n]=Wn(e.arrayValue.values[n]);return t}return{...e}}function Gn(e){return(((e.mapValue||{}).fields||{}).__type__||{}).stringValue===En}const Kn={mapValue:{fields:{[In]:{stringValue:Sn},[An]:{arrayValue:{}}}}};function $n(e){return"nullValue"in e?On:"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?jn(wn.empty(),q.empty()):"geoPointValue"in e?{geoPointValue:{latitude:-90,longitude:-180}}:"arrayValue"in e?{arrayValue:{}}:"mapValue"in e?zn(e)?Kn:{mapValue:{}}:g(35942,{value:e})}function Hn(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?jn(wn.empty(),q.empty()):"referenceValue"in e?{geoPointValue:{latitude:-90,longitude:-180}}:"geoPointValue"in e?{arrayValue:{}}:"arrayValue"in e?Kn:"mapValue"in e?zn(e)?{mapValue:{}}:Tn:g(61959,{value:e})}function Qn(e,t){const n=kn(e.value,t.value);return 0!==n?n:e.inclusive&&!t.inclusive?-1:!e.inclusive&&t.inclusive?1:0}function Jn(e,t){const n=kn(e.value,t.value);return 0!==n?n:e.inclusive&&!t.inclusive?1:!e.inclusive&&t.inclusive?-1:0}class Yn{constructor(e){this.value=e}static empty(){return new Yn({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)],!Bn(t))return null;return t=(t.mapValue.fields||{})[e.lastSegment()],t||null}}set(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=Wn(t)}setAll(e){let t=U.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()]=Wn(e):r.push(i.lastSegment())});const i=this.getFieldsMap(t);this.applyChanges(i,n,r)}delete(e){const t=this.field(e.popLast());Bn(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return Cn(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)];Bn(r)&&r.mapValue.fields||(r={mapValue:{fields:{}}},t.mapValue.fields[e.get(n)]=r),t=r}return t.mapValue.fields}applyChanges(e,t,n){Qt(t,(t,n)=>e[t]=n);for(const t of n)delete e[t]}clone(){return new Yn(Wn(this.value))}}function Xn(e){const t=[];return Qt(e.fields,(e,n)=>{const r=new U([e]);if(Bn(n)){const e=Xn(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 on(t)}class Zn{constructor(e,t,n,r,i,o,s){this.key=e,this.documentType=t,this.version=n,this.readTime=r,this.createTime=i,this.data=o,this.documentState=s}static newInvalidDocument(e){return new Zn(e,0,ee.min(),ee.min(),ee.min(),Yn.empty(),0)}static newFoundDocument(e,t,n,r){return new Zn(e,1,t,ee.min(),n,r,0)}static newNoDocument(e,t){return new Zn(e,2,t,ee.min(),ee.min(),Yn.empty(),0)}static newUnknownDocument(e,t){return new Zn(e,3,t,ee.min(),ee.min(),Yn.empty(),2)}convertToFoundDocument(e,t){return!this.createTime.isEqual(ee.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=Yn.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=Yn.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=ee.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 Zn&&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 Zn(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 er{constructor(e,t){this.position=e,this.inclusive=t}}function tr(e,t,n){let r=0;for(let i=0;i<e.position.length;i++){const o=t[i],s=e.position[i];if(r=o.field.isKeyField()?q.comparator(q.fromName(s.referenceValue),n.key):kn(s,n.data.field(o.field)),"desc"===o.dir&&(r*=-1),0!==r)break}return r}function nr(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(!Cn(e.position[n],t.position[n]))return!1;return!0}class rr{constructor(e,t="asc"){this.field=e,this.dir=t}}function ir(e,t){return e.dir===t.dir&&e.field.isEqual(t.field)}class or{}class sr extends or{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 gr(e,t,n):"array-contains"===t?new _r(e,n):"in"===t?new wr(e,n):"not-in"===t?new Ir(e,n):"array-contains-any"===t?new Er(e,n):new sr(e,t,n)}static createKeyFieldInFilter(e,t,n){return"in"===t?new yr(e,n):new vr(e,n)}matches(e){const t=e.data.field(this.field);return"!="===this.op?null!==t&&void 0===t.nullValue&&this.matchesComparison(kn(t,this.value)):null!==t&&Pn(this.value)===Pn(t)&&this.matchesComparison(kn(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 g(47266,{operator:this.op})}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class ar extends or{constructor(e,t){super(),this.filters=e,this.op=t,this.Pe=null}static create(e,t){return new ar(e,t)}matches(e){return cr(this)?void 0===this.filters.find(t=>!t.matches(e)):void 0!==this.filters.find(t=>t.matches(e))}getFlattenedFilters(){return null!==this.Pe||(this.Pe=this.filters.reduce((e,t)=>e.concat(t.getFlattenedFilters()),[])),this.Pe}getFilters(){return Object.assign([],this.filters)}}function cr(e){return"and"===e.op}function ur(e){return"or"===e.op}function lr(e){return hr(e)&&cr(e)}function hr(e){for(const t of e.filters)if(t instanceof ar)return!1;return!0}function dr(e){if(e instanceof sr)return e.field.canonicalString()+e.op.toString()+Dn(e.value);if(lr(e))return e.filters.map(e=>dr(e)).join(",");{const t=e.filters.map(e=>dr(e)).join(",");return`${e.op}(${t})`}}function fr(e,t){return e instanceof sr?function(e,t){return t instanceof sr&&e.op===t.op&&e.field.isEqual(t.field)&&Cn(e.value,t.value)}(e,t):e instanceof ar?function(e,t){return t instanceof ar&&e.op===t.op&&e.filters.length===t.filters.length&&e.filters.reduce((e,n,r)=>e&&fr(n,t.filters[r]),!0)}(e,t):void g(19439)}function pr(e,t){const n=e.filters.concat(t);return ar.create(n,e.op)}function mr(e){return e instanceof sr?function(e){return`${e.field.canonicalString()} ${e.op} ${Dn(e.value)}`}(e):e instanceof ar?function(e){return e.op.toString()+" {"+e.getFilters().map(mr).join(" ,")+"}"}(e):"Filter"}class gr extends sr{constructor(e,t,n){super(e,t,n),this.key=q.fromName(n.referenceValue)}matches(e){const t=q.comparator(e.key,this.key);return this.matchesComparison(t)}}class yr extends sr{constructor(e,t){super(e,"in",t),this.keys=br(0,t)}matches(e){return this.keys.some(t=>t.isEqual(e.key))}}class vr extends sr{constructor(e,t){super(e,"not-in",t),this.keys=br(0,t)}matches(e){return!this.keys.some(t=>t.isEqual(e.key))}}function br(e,t){return(t.arrayValue?.values||[]).map(e=>q.fromName(e.referenceValue))}class _r extends sr{constructor(e,t){super(e,"array-contains",t)}matches(e){const t=e.data.field(this.field);return Vn(t)&&Rn(t.arrayValue,this.value)}}class wr extends sr{constructor(e,t){super(e,"in",t)}matches(e){const t=e.data.field(this.field);return null!==t&&Rn(this.value.arrayValue,t)}}class Ir extends sr{constructor(e,t){super(e,"not-in",t)}matches(e){if(Rn(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const t=e.data.field(this.field);return null!==t&&void 0===t.nullValue&&!Rn(this.value.arrayValue,t)}}class Er extends sr{constructor(e,t){super(e,"array-contains-any",t)}matches(e){const t=e.data.field(this.field);return!(!Vn(t)||!t.arrayValue.values)&&t.arrayValue.values.some(e=>Rn(this.value.arrayValue,e))}}class Tr{constructor(e,t=null,n=[],r=[],i=null,o=null,s=null){this.path=e,this.collectionGroup=t,this.orderBy=n,this.filters=r,this.limit=i,this.startAt=o,this.endAt=s,this.Te=null}}function Sr(e,t=null,n=[],r=[],i=null,o=null,s=null){return new Tr(e,t,n,r,i,o,s)}function Ar(e){const t=b(e);if(null===t.Te){let e=t.path.canonicalString();null!==t.collectionGroup&&(e+="|cg:"+t.collectionGroup),e+="|f:",e+=t.filters.map(e=>dr(e)).join(","),e+="|ob:",e+=t.orderBy.map(e=>function(e){return e.field.canonicalString()+e.dir}(e)).join(","),xe(t.limit)||(e+="|l:",e+=t.limit),t.startAt&&(e+="|lb:",e+=t.startAt.inclusive?"b:":"a:",e+=t.startAt.position.map(e=>Dn(e)).join(",")),t.endAt&&(e+="|ub:",e+=t.endAt.inclusive?"a:":"b:",e+=t.endAt.position.map(e=>Dn(e)).join(",")),t.Te=e}return t.Te}function Or(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(!ir(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(!fr(e.filters[n],t.filters[n]))return!1;return e.collectionGroup===t.collectionGroup&&!!e.path.isEqual(t.path)&&!!nr(e.startAt,t.startAt)&&nr(e.endAt,t.endAt)}function Pr(e){return q.isDocumentKey(e.path)&&null===e.collectionGroup&&0===e.filters.length}function Cr(e,t){return e.filters.filter(e=>e instanceof sr&&e.field.isEqual(t))}function Rr(e,t,n){let r=On,i=!0;for(const n of Cr(e,t)){let e=On,t=!0;switch(n.op){case"<":case"<=":e=$n(n.value);break;case"==":case"in":case">=":e=n.value;break;case">":e=n.value,t=!1;break;case"!=":case"not-in":e=On}Qn({value:r,inclusive:i},{value:e,inclusive:t})<0&&(r=e,i=t)}if(null!==n)for(let o=0;o<e.orderBy.length;++o)if(e.orderBy[o].field.isEqual(t)){const e=n.position[o];Qn({value:r,inclusive:i},{value:e,inclusive:n.inclusive})<0&&(r=e,i=n.inclusive);break}return{value:r,inclusive:i}}function kr(e,t,n){let r=Tn,i=!0;for(const n of Cr(e,t)){let e=Tn,t=!0;switch(n.op){case">=":case">":e=Hn(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=Tn}Jn({value:r,inclusive:i},{value:e,inclusive:t})>0&&(r=e,i=t)}if(null!==n)for(let o=0;o<e.orderBy.length;++o)if(e.orderBy[o].field.isEqual(t)){const e=n.position[o];Jn({value:r,inclusive:i},{value:e,inclusive:n.inclusive})>0&&(r=e,i=n.inclusive);break}return{value:r,inclusive:i}}class Nr{constructor(e,t=null,n=[],r=[],i=null,o="F",s=null,a=null){this.path=e,this.collectionGroup=t,this.explicitOrderBy=n,this.filters=r,this.limit=i,this.limitType=o,this.startAt=s,this.endAt=a,this.Ie=null,this.Ee=null,this.Re=null,this.startAt,this.endAt}}function xr(e,t,n,r,i,o,s,a){return new Nr(e,t,n,r,i,o,s,a)}function Dr(e){return new Nr(e)}function Mr(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 Lr(e){return q.isDocumentKey(e.path)&&null===e.collectionGroup&&0===e.filters.length}function jr(e){return null!==e.collectionGroup}function Fr(e){const t=b(e);if(null===t.Ie){t.Ie=[];const e=new Set;for(const n of t.explicitOrderBy)t.Ie.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 tn(U.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.Ie.push(new rr(r,n))}),e.has(U.keyField().canonicalString())||t.Ie.push(new rr(U.keyField(),n))}return t.Ie}function Vr(e){const t=b(e);return t.Ee||(t.Ee=qr(t,Fr(e))),t.Ee}function Ur(e){const t=b(e);return t.Re||(t.Re=qr(t,e.explicitOrderBy)),t.Re}function qr(e,t){if("F"===e.limitType)return Sr(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 rr(e.field,t)});const n=e.endAt?new er(e.endAt.position,e.endAt.inclusive):null,r=e.startAt?new er(e.startAt.position,e.startAt.inclusive):null;return Sr(e.path,e.collectionGroup,t,e.filters,e.limit,n,r)}}function Br(e,t,n){return new Nr(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),t,n,e.startAt,e.endAt)}function zr(e,t){return Or(Vr(e),Vr(t))&&e.limitType===t.limitType}function Wr(e){return`${Ar(Vr(e))}|lt:${e.limitType}`}function Gr(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=>mr(e)).join(", ")}]`),xe(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=>Dn(e)).join(",")),e.endAt&&(t+=", endAt: ",t+=e.endAt.inclusive?"a:":"b:",t+=e.endAt.position.map(e=>Dn(e)).join(",")),`Target(${t})`}(Vr(e))}; limitType=${e.limitType})`}function Kr(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):q.isDocumentKey(e.path)?e.path.isEqual(n):e.path.isImmediateParentOf(n)}(e,t)&&function(e,t){for(const n of Fr(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=tr(e,t,n);return e.inclusive?r<=0:r<0}(e.startAt,Fr(e),t)||e.endAt&&!function(e,t,n){const r=tr(e,t,n);return e.inclusive?r>=0:r>0}(e.endAt,Fr(e),t))}(e,t)}function $r(e){return e.collectionGroup||(e.path.length%2==1?e.path.lastSegment():e.path.get(e.path.length-2))}function Hr(e){return(t,n)=>{let r=!1;for(const i of Fr(e)){const e=Qr(i,t,n);if(0!==e)return e;r=r||i.field.isKeyField()}return 0}}function Qr(e,t,n){const r=e.field.isKeyField()?q.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?kn(r,i):g(42886)}(e.field,t,n);switch(e.dir){case"asc":return r;case"desc":return-1*r;default:return g(19790,{direction:e.dir})}}class Jr{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){Qt(this.inner,(t,n)=>{for(const[t,r]of n)e(t,r)})}isEmpty(){return Yt(this.inner)}size(){return this.innerSize}}const Yr=new Xt(q.comparator);function Xr(){return Yr}const Zr=new Xt(q.comparator);function ei(...e){let t=Zr;for(const n of e)t=t.insert(n.key,n);return t}function ti(e){let t=Zr;return e.forEach((e,n)=>t=t.insert(e,n.overlayedDocument)),t}function ni(){return ii()}function ri(){return ii()}function ii(){return new Jr(e=>e.toString(),(e,t)=>e.isEqual(t))}const oi=new Xt(q.comparator),si=new tn(q.comparator);function ai(...e){let t=si;for(const n of e)t=t.add(n);return t}const ci=new tn(k);function ui(){return ci}function li(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:De(t)?"-0":t}}function hi(e){return{integerValue:""+e}}function di(e,t){return Me(t)?hi(t):li(e,t)}class fi{constructor(){this._=void 0}}function pi(e,t,n){return e instanceof yi?function(e,t){const n={fields:{[fn]:{stringValue:dn},[mn]:{timestampValue:{seconds:e.seconds,nanos:e.nanoseconds}}}};return t&&gn(t)&&(t=yn(t)),t&&(n.fields[pn]=t),{mapValue:n}}(n,t):e instanceof vi?bi(e,t):e instanceof _i?wi(e,t):function(e,t){const n=gi(e,t),r=Ei(n)+Ei(e.Ae);return Fn(n)&&Fn(e.Ae)?hi(r):li(e.serializer,r)}(e,t)}function mi(e,t,n){return e instanceof vi?bi(e,t):e instanceof _i?wi(e,t):n}function gi(e,t){return e instanceof Ii?function(e){return Fn(e)||function(e){return!!e&&"doubleValue"in e}(e)}(t)?t:{integerValue:0}:null}class yi extends fi{}class vi extends fi{constructor(e){super(),this.elements=e}}function bi(e,t){const n=Ti(t);for(const t of e.elements)n.some(e=>Cn(e,t))||n.push(t);return{arrayValue:{values:n}}}class _i extends fi{constructor(e){super(),this.elements=e}}function wi(e,t){let n=Ti(t);for(const t of e.elements)n=n.filter(e=>!Cn(e,t));return{arrayValue:{values:n}}}class Ii extends fi{constructor(e,t){super(),this.serializer=e,this.Ae=t}}function Ei(e){return ln(e.integerValue||e.doubleValue)}function Ti(e){return Vn(e)&&e.arrayValue.values?e.arrayValue.values.slice():[]}class Si{constructor(e,t){this.field=e,this.transform=t}}class Ai{constructor(e,t){this.version=e,this.transformResults=t}}class Oi{constructor(e,t){this.updateTime=e,this.exists=t}static none(){return new Oi}static exists(e){return new Oi(void 0,e)}static updateTime(e){return new Oi(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 Pi(e,t){return void 0!==e.updateTime?t.isFoundDocument()&&t.version.isEqual(e.updateTime):void 0===e.exists||e.exists===t.isFoundDocument()}class Ci{}function Ri(e,t){if(!e.hasLocalMutations||t&&0===t.fields.length)return null;if(null===t)return e.isNoDocument()?new Ui(e.key,Oi.none()):new Mi(e.key,e.data,Oi.none());{const n=e.data,r=Yn.empty();let i=new tn(U.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 Li(e.key,r,new on(i.toArray()),Oi.none())}}function ki(e,t,n){e instanceof Mi?function(e,t,n){const r=e.value.clone(),i=Fi(e.fieldTransforms,t,n.transformResults);r.setAll(i),t.convertToFoundDocument(n.version,r).setHasCommittedMutations()}(e,t,n):e instanceof Li?function(e,t,n){if(!Pi(e.precondition,t))return void t.convertToUnknownDocument(n.version);const r=Fi(e.fieldTransforms,t,n.transformResults),i=t.data;i.setAll(ji(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 Ni(e,t,n,r){return e instanceof Mi?function(e,t,n,r){if(!Pi(e.precondition,t))return n;const i=e.value.clone(),o=Vi(e.fieldTransforms,r,t);return i.setAll(o),t.convertToFoundDocument(t.version,i).setHasLocalMutations(),null}(e,t,n,r):e instanceof Li?function(e,t,n,r){if(!Pi(e.precondition,t))return n;const i=Vi(e.fieldTransforms,r,t),o=t.data;return o.setAll(ji(e)),o.setAll(i),t.convertToFoundDocument(t.version,o).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 Pi(e.precondition,t)?(t.convertToNoDocument(t.version).setHasLocalMutations(),null):n}(e,t,n)}function xi(e,t){let n=null;for(const r of e.fieldTransforms){const e=t.data.field(r.field),i=gi(r.transform,e||null);null!=i&&(null===n&&(n=Yn.empty()),n.set(r.field,i))}return n||null}function Di(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)&&D(e,t,(e,t)=>function(e,t){return e.field.isEqual(t.field)&&function(e,t){return e instanceof vi&&t instanceof vi||e instanceof _i&&t instanceof _i?D(e.elements,t.elements,Cn):e instanceof Ii&&t instanceof Ii?Cn(e.Ae,t.Ae):e instanceof yi&&t instanceof yi}(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 Mi extends Ci{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 Li extends Ci{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 ji(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 Fi(e,t,n){const r=new Map;v(e.length===n.length,32656,{Ve:n.length,de:e.length});for(let i=0;i<n.length;i++){const o=e[i],s=o.transform,a=t.data.field(o.field);r.set(o.field,mi(s,a,n[i]))}return r}function Vi(e,t,n){const r=new Map;for(const i of e){const e=i.transform,o=n.data.field(i.field);r.set(i.field,pi(e,o,t))}return r}class Ui extends Ci{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}class qi extends Ci{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}}class Bi{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)&&ki(r,e,n[t])}}applyToLocalView(e,t){for(const n of this.baseMutations)n.key.isEqual(e.key)&&(t=Ni(n,e,t,this.localWriteTime));for(const n of this.mutations)n.key.isEqual(e.key)&&(t=Ni(n,e,t,this.localWriteTime));return t}applyToLocalDocumentSet(e,t){const n=ri();return this.mutations.forEach(r=>{const i=e.get(r.key),o=i.overlayedDocument;let s=this.applyToLocalView(o,i.mutatedFields);s=t.has(r.key)?null:s;const a=Ri(o,s);null!==a&&n.set(r.key,a),o.isValidDocument()||o.convertToNoDocument(ee.min())}),n}keys(){return this.mutations.reduce((e,t)=>e.add(t.key),ai())}isEqual(e){return this.batchId===e.batchId&&D(this.mutations,e.mutations,(e,t)=>Di(e,t))&&D(this.baseMutations,e.baseMutations,(e,t)=>Di(e,t))}}class zi{constructor(e,t,n,r){this.batch=e,this.commitVersion=t,this.mutationResults=n,this.docVersions=r}static from(e,t,n){v(e.mutations.length===n.length,58842,{me:e.mutations.length,fe:n.length});let r=oi;const i=e.mutations;for(let e=0;e<i.length;e++)r=r.insert(i[e].key,n[e].version);return new zi(e,t,n,r)}}class Wi{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 Gi{constructor(e,t,n){this.alias=e,this.aggregateType=t,this.fieldPath=n}}class Ki{constructor(e,t){this.count=e,this.unchangedNames=t}}var $i,Hi;function Qi(e){switch(e){case _.OK:return g(64938);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;default:return g(15467,{code:e})}}function Ji(e){if(void 0===e)return f("GRPC error has no .code"),_.UNKNOWN;switch(e){case $i.OK:return _.OK;case $i.CANCELLED:return _.CANCELLED;case $i.UNKNOWN:return _.UNKNOWN;case $i.DEADLINE_EXCEEDED:return _.DEADLINE_EXCEEDED;case $i.RESOURCE_EXHAUSTED:return _.RESOURCE_EXHAUSTED;case $i.INTERNAL:return _.INTERNAL;case $i.UNAVAILABLE:return _.UNAVAILABLE;case $i.UNAUTHENTICATED:return _.UNAUTHENTICATED;case $i.INVALID_ARGUMENT:return _.INVALID_ARGUMENT;case $i.NOT_FOUND:return _.NOT_FOUND;case $i.ALREADY_EXISTS:return _.ALREADY_EXISTS;case $i.PERMISSION_DENIED:return _.PERMISSION_DENIED;case $i.FAILED_PRECONDITION:return _.FAILED_PRECONDITION;case $i.ABORTED:return _.ABORTED;case $i.OUT_OF_RANGE:return _.OUT_OF_RANGE;case $i.UNIMPLEMENTED:return _.UNIMPLEMENTED;case $i.DATA_LOSS:return _.DATA_LOSS;default:return g(39323,{code:e})}}(Hi=$i||($i={}))[Hi.OK=0]="OK",Hi[Hi.CANCELLED=1]="CANCELLED",Hi[Hi.UNKNOWN=2]="UNKNOWN",Hi[Hi.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",Hi[Hi.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",Hi[Hi.NOT_FOUND=5]="NOT_FOUND",Hi[Hi.ALREADY_EXISTS=6]="ALREADY_EXISTS",Hi[Hi.PERMISSION_DENIED=7]="PERMISSION_DENIED",Hi[Hi.UNAUTHENTICATED=16]="UNAUTHENTICATED",Hi[Hi.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",Hi[Hi.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",Hi[Hi.ABORTED=10]="ABORTED",Hi[Hi.OUT_OF_RANGE=11]="OUT_OF_RANGE",Hi[Hi.UNIMPLEMENTED=12]="UNIMPLEMENTED",Hi[Hi.INTERNAL=13]="INTERNAL",Hi[Hi.UNAVAILABLE=14]="UNAVAILABLE",Hi[Hi.DATA_LOSS=15]="DATA_LOSS";let Yi=null;function Xi(){return new TextEncoder}const Zi=new o.Integer([4294967295,4294967295],0);function eo(e){const t=Xi().encode(e),n=new o.Md5;return n.update(t),new Uint8Array(n.digest())}function to(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 o.Integer([n,r],0),new o.Integer([i,s],0)]}class no{constructor(e,t,n){if(this.bitmap=e,this.padding=t,this.hashCount=n,t<0||t>=8)throw new ro(`Invalid padding: ${t}`);if(n<0)throw new ro(`Invalid hash count: ${n}`);if(e.length>0&&0===this.hashCount)throw new ro(`Invalid hash count: ${n}`);if(0===e.length&&0!==t)throw new ro(`Invalid padding when bitmap length is 0: ${t}`);this.ge=8*e.length-t,this.pe=o.Integer.fromNumber(this.ge)}ye(e,t,n){let r=e.add(t.multiply(o.Integer.fromNumber(n)));return 1===r.compare(Zi)&&(r=new o.Integer([r.getBits(0),r.getBits(1)],0)),r.modulo(this.pe).toNumber()}we(e){return!!(this.bitmap[Math.floor(e/8)]&1<<e%8)}mightContain(e){if(0===this.ge)return!1;const t=eo(e),[n,r]=to(t);for(let e=0;e<this.hashCount;e++){const t=this.ye(n,r,e);if(!this.we(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)),o=new no(i,r,t);return n.forEach(e=>o.insert(e)),o}insert(e){if(0===this.ge)return;const t=eo(e),[n,r]=to(t);for(let e=0;e<this.hashCount;e++){const t=this.ye(n,r,e);this.be(t)}}be(e){const t=Math.floor(e/8),n=e%8;this.bitmap[t]|=1<<n}}class ro extends Error{constructor(){super(...arguments),this.name="BloomFilterError"}}class io{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,oo.createSynthesizedTargetChangeForCurrentChange(e,t,n)),new io(ee.min(),r,new Xt(k),Xr(),ai())}}class oo{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 oo(n,t,ai(),ai(),ai())}}class so{constructor(e,t,n,r){this.Se=e,this.removedTargetIds=t,this.key=n,this.De=r}}class ao{constructor(e,t){this.targetId=e,this.Ce=t}}class co{constructor(e,t,n=an.EMPTY_BYTE_STRING,r=null){this.state=e,this.targetIds=t,this.resumeToken=n,this.cause=r}}class uo{constructor(){this.ve=0,this.Fe=fo(),this.Me=an.EMPTY_BYTE_STRING,this.xe=!1,this.Oe=!0}get current(){return this.xe}get resumeToken(){return this.Me}get Ne(){return 0!==this.ve}get Be(){return this.Oe}Le(e){e.approximateByteSize()>0&&(this.Oe=!0,this.Me=e)}ke(){let e=ai(),t=ai(),n=ai();return this.Fe.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:g(38017,{changeType:i})}}),new oo(this.Me,this.xe,e,t,n)}Ke(){this.Oe=!1,this.Fe=fo()}qe(e,t){this.Oe=!0,this.Fe=this.Fe.insert(e,t)}Ue(e){this.Oe=!0,this.Fe=this.Fe.remove(e)}$e(){this.ve+=1}We(){this.ve-=1,v(this.ve>=0,3241,{ve:this.ve})}Qe(){this.Oe=!0,this.xe=!0}}class lo{constructor(e){this.Ge=e,this.ze=new Map,this.je=Xr(),this.He=ho(),this.Je=ho(),this.Ze=new Xt(k)}Xe(e){for(const t of e.Se)e.De&&e.De.isFoundDocument()?this.Ye(t,e.De):this.et(t,e.key,e.De);for(const t of e.removedTargetIds)this.et(t,e.key,e.De)}tt(e){this.forEachTarget(e,t=>{const n=this.nt(t);switch(e.state){case 0:this.rt(t)&&n.Le(e.resumeToken);break;case 1:n.We(),n.Ne||n.Ke(),n.Le(e.resumeToken);break;case 2:n.We(),n.Ne||this.removeTarget(t);break;case 3:this.rt(t)&&(n.Qe(),n.Le(e.resumeToken));break;case 4:this.rt(t)&&(this.it(t),n.Le(e.resumeToken));break;default:g(56790,{state:e.state})}})}forEachTarget(e,t){e.targetIds.length>0?e.targetIds.forEach(t):this.ze.forEach((e,n)=>{this.rt(n)&&t(n)})}st(e){const t=e.targetId,n=e.Ce.count,r=this.ot(t);if(r){const i=r.target;if(Pr(i))if(0===n){const e=new q(i.path);this.et(t,e,Zn.newNoDocument(e,ee.min()))}else v(1===n,20013,{expectedCount:n});else{const r=this._t(t);if(r!==n){const n=this.ut(e),i=n?this.ct(n,e,r):1;if(0!==i){this.it(t);const e=2===i?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch";this.Ze=this.Ze.insert(t,e)}Yi?.lt(function(e,t,n,r,i){const o={localCacheCount:e,existenceFilterCount:t.count,databaseId:n.database,projectId:n.projectId},s=t.unchangedNames;return s&&(o.bloomFilter={applied:0===i,hashCount:s?.hashCount??0,bitmapLength:s?.bits?.bitmap?.length??0,padding:s?.bits?.padding??0,mightContain:e=>r?.mightContain(e)??!1}),o}(r,e.Ce,this.Ge.ht(),n,i))}}}}ut(e){const t=e.Ce.unchangedNames;if(!t||!t.bits)return null;const{bits:{bitmap:n="",padding:r=0},hashCount:i=0}=t;let o,s;try{o=hn(n).toUint8Array()}catch(e){if(e instanceof sn)return p("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{s=new no(o,r,i)}catch(e){return p(e instanceof ro?"BloomFilter error: ":"Applying bloom filter failed: ",e),null}return 0===s.ge?null:s}ct(e,t,n){return t.Ce.count===n-this.Pt(e,t.targetId)?0:2}Pt(e,t){const n=this.Ge.getRemoteKeysForTarget(t);let r=0;return n.forEach(n=>{const i=this.Ge.ht(),o=`projects/${i.projectId}/databases/${i.database}/documents/${n.path.canonicalString()}`;e.mightContain(o)||(this.et(t,n,null),r++)}),r}Tt(e){const t=new Map;this.ze.forEach((n,r)=>{const i=this.ot(r);if(i){if(n.current&&Pr(i.target)){const t=new q(i.target.path);this.It(t).has(r)||this.Et(r,t)||this.et(r,t,Zn.newNoDocument(t,e))}n.Be&&(t.set(r,n.ke()),n.Ke())}});let n=ai();this.Je.forEach((e,t)=>{let r=!0;t.forEachWhile(e=>{const t=this.ot(e);return!t||"TargetPurposeLimboResolution"===t.purpose||(r=!1,!1)}),r&&(n=n.add(e))}),this.je.forEach((t,n)=>n.setReadTime(e));const r=new io(e,t,this.Ze,this.je,n);return this.je=Xr(),this.He=ho(),this.Je=ho(),this.Ze=new Xt(k),r}Ye(e,t){if(!this.rt(e))return;const n=this.Et(e,t.key)?2:0;this.nt(e).qe(t.key,n),this.je=this.je.insert(t.key,t),this.He=this.He.insert(t.key,this.It(t.key).add(e)),this.Je=this.Je.insert(t.key,this.Rt(t.key).add(e))}et(e,t,n){if(!this.rt(e))return;const r=this.nt(e);this.Et(e,t)?r.qe(t,1):r.Ue(t),this.Je=this.Je.insert(t,this.Rt(t).delete(e)),this.Je=this.Je.insert(t,this.Rt(t).add(e)),n&&(this.je=this.je.insert(t,n))}removeTarget(e){this.ze.delete(e)}_t(e){const t=this.nt(e).ke();return this.Ge.getRemoteKeysForTarget(e).size+t.addedDocuments.size-t.removedDocuments.size}$e(e){this.nt(e).$e()}nt(e){let t=this.ze.get(e);return t||(t=new uo,this.ze.set(e,t)),t}Rt(e){let t=this.Je.get(e);return t||(t=new tn(k),this.Je=this.Je.insert(e,t)),t}It(e){let t=this.He.get(e);return t||(t=new tn(k),this.He=this.He.insert(e,t)),t}rt(e){const t=null!==this.ot(e);return t||d("WatchChangeAggregator","Detected inactive target",e),t}ot(e){const t=this.ze.get(e);return t&&t.Ne?null:this.Ge.At(e)}it(e){this.ze.set(e,new uo),this.Ge.getRemoteKeysForTarget(e).forEach(t=>{this.et(e,t,null)})}Et(e,t){return this.Ge.getRemoteKeysForTarget(e).has(t)}}function ho(){return new Xt(q.comparator)}function fo(){return new Xt(q.comparator)}const po={asc:"ASCENDING",desc:"DESCENDING"},mo={"<":"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"},go={and:"AND",or:"OR"};class yo{constructor(e,t){this.databaseId=e,this.useProto3Json=t}}function vo(e,t){return e.useProto3Json||xe(t)?t:{value:t}}function bo(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 _o(e,t){return e.useProto3Json?t.toBase64():t.toUint8Array()}function wo(e,t){return bo(e,t.toTimestamp())}function Io(e){return v(!!e,49232),ee.fromTimestamp(function(e){const t=un(e);return new Z(t.seconds,t.nanos)}(e))}function Eo(e,t){return To(e,t).canonicalString()}function To(e,t){const n=function(e){return new F(["projects",e.projectId,"databases",e.database])}(e).child("documents");return void 0===t?n:n.child(t)}function So(e){const t=F.fromString(e);return v(Qo(t),10190,{key:t.toString()}),t}function Ao(e,t){return Eo(e.databaseId,t.path)}function Oo(e,t){const n=So(t);if(n.get(1)!==e.databaseId.projectId)throw new w(_.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 w(_.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+n.get(3)+" vs "+e.databaseId.database);return new q(ko(n))}function Po(e,t){return Eo(e.databaseId,t)}function Co(e){const t=So(e);return 4===t.length?F.emptyPath():ko(t)}function Ro(e){return new F(["projects",e.databaseId.projectId,"databases",e.databaseId.database]).canonicalString()}function ko(e){return v(e.length>4&&"documents"===e.get(4),29091,{key:e.toString()}),e.popFirst(5)}function No(e,t,n){return{name:Ao(e,t),fields:n.value.mapValue.fields}}function xo(e,t,n){const r={};t.transaction?.length&&(r.transaction=t.transaction);const i=t.executionTime?Io(t.executionTime):void 0;return r.executionTime=i,n&&(r.key=n.name?Oo(e,n.name):void 0,r.fields=new Yn({mapValue:{fields:n.fields}}),r.createTime=n.createTime?Io(n.createTime):void 0,r.updateTime=n.updateTime?Io(n.updateTime):void 0),r}function Do(e,t,n){const r=Oo(e,t.name),i=Io(t.updateTime),o=t.createTime?Io(t.createTime):ee.min(),s=new Yn({mapValue:{fields:t.fields}}),a=Zn.newFoundDocument(r,i,o,s);return n&&a.setHasCommittedMutations(),n?a.setHasCommittedMutations():a}function Mo(e,t){let n;if(t instanceof Mi)n={update:No(e,t.key,t.value)};else if(t instanceof Ui)n={delete:Ao(e,t.key)};else if(t instanceof Li)n={update:No(e,t.key,t.data),updateMask:Ho(t.fieldMask)};else{if(!(t instanceof qi))return g(16599,{dt:t.type});n={verify:Ao(e,t.key)}}return t.fieldTransforms.length>0&&(n.updateTransforms=t.fieldTransforms.map(e=>function(e,t){const n=t.transform;if(n instanceof yi)return{fieldPath:t.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(n instanceof vi)return{fieldPath:t.field.canonicalString(),appendMissingElements:{values:n.elements}};if(n instanceof _i)return{fieldPath:t.field.canonicalString(),removeAllFromArray:{values:n.elements}};if(n instanceof Ii)return{fieldPath:t.field.canonicalString(),increment:n.Ae};throw g(20930,{transform:t.transform})}(0,e))),t.precondition.isNone||(n.currentDocument=function(e,t){return void 0!==t.updateTime?{updateTime:wo(e,t.updateTime)}:void 0!==t.exists?{exists:t.exists}:g(27497)}(e,t.precondition)),n}function Lo(e,t){const n=t.currentDocument?function(e){return void 0!==e.updateTime?Oi.updateTime(Io(e.updateTime)):void 0!==e.exists?Oi.exists(e.exists):Oi.none()}(t.currentDocument):Oi.none(),r=t.updateTransforms?t.updateTransforms.map(t=>function(e,t){let n=null;if("setToServerValue"in t)v("REQUEST_TIME"===t.setToServerValue,16630,{proto:t}),n=new yi;else if("appendMissingElements"in t){const e=t.appendMissingElements.values||[];n=new vi(e)}else if("removeAllFromArray"in t){const e=t.removeAllFromArray.values||[];n=new _i(e)}else"increment"in t?n=new Ii(e,t.increment):g(16584,{proto:t});const r=U.fromServerFormat(t.fieldPath);return new Si(r,n)}(e,t)):[];if(t.update){t.update.name;const i=Oo(e,t.update.name),o=new Yn({mapValue:{fields:t.update.fields}});if(t.updateMask){const e=function(e){const t=e.fieldPaths||[];return new on(t.map(e=>U.fromServerFormat(e)))}(t.updateMask);return new Li(i,o,e,n,r)}return new Mi(i,o,n,r)}if(t.delete){const r=Oo(e,t.delete);return new Ui(r,n)}if(t.verify){const r=Oo(e,t.verify);return new qi(r,n)}return g(1463,{proto:t})}function jo(e,t){return{documents:[Po(e,t.path)]}}function Fo(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=Po(e,i);const o=function(e){if(0!==e.length)return $o(ar.create(e,"and"))}(t.filters);o&&(n.structuredQuery.where=o);const s=function(e){if(0!==e.length)return e.map(e=>function(e){return{field:Go(e.field),direction:Bo(e.dir)}}(e))}(t.orderBy);s&&(n.structuredQuery.orderBy=s);const a=vo(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)),{ft:n,parent:i}}function Vo(e,t,n,r){const{ft:i,parent:o}=Fo(e,t),s={},a=[];let c=0;return n.forEach(e=>{const t=r?e.alias:"aggregate_"+c++;s[t]=e.alias,"count"===e.aggregateType?a.push({alias:t,count:{}}):"avg"===e.aggregateType?a.push({alias:t,avg:{field:Go(e.fieldPath)}}):"sum"===e.aggregateType&&a.push({alias:t,sum:{field:Go(e.fieldPath)}})}),{request:{structuredAggregationQuery:{aggregations:a,structuredQuery:i.structuredQuery},parent:i.parent},gt:s,parent:o}}function Uo(e){let t=Co(e.parent);const n=e.structuredQuery,r=n.from?n.from.length:0;let i=null;if(r>0){v(1===r,65062);const e=n.from[0];e.allDescendants?i=e.collectionId:t=t.child(e.collectionId)}let o=[];n.where&&(o=function(e){const t=qo(e);return t instanceof ar&&lr(t)?t.getFilters():[t]}(n.where));let s=[];n.orderBy&&(s=function(e){return e.map(e=>function(e){return new rr(Ko(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,xe(t)?null:t}(n.limit));let c=null;n.startAt&&(c=function(e){const t=!!e.before,n=e.values||[];return new er(n,t)}(n.startAt));let u=null;return n.endAt&&(u=function(e){const t=!e.before,n=e.values||[];return new er(n,t)}(n.endAt)),xr(t,i,s,o,a,"F",c,u)}function qo(e){return void 0!==e.unaryFilter?function(e){switch(e.unaryFilter.op){case"IS_NAN":const t=Ko(e.unaryFilter.field);return sr.create(t,"==",{doubleValue:NaN});case"IS_NULL":const n=Ko(e.unaryFilter.field);return sr.create(n,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":const r=Ko(e.unaryFilter.field);return sr.create(r,"!=",{doubleValue:NaN});case"IS_NOT_NULL":const i=Ko(e.unaryFilter.field);return sr.create(i,"!=",{nullValue:"NULL_VALUE"});case"OPERATOR_UNSPECIFIED":return g(61313);default:return g(60726)}}(e):void 0!==e.fieldFilter?function(e){return sr.create(Ko(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";case"OPERATOR_UNSPECIFIED":return g(58110);default:return g(50506)}}(e.fieldFilter.op),e.fieldFilter.value)}(e):void 0!==e.compositeFilter?function(e){return ar.create(e.compositeFilter.filters.map(e=>qo(e)),function(e){switch(e){case"AND":return"and";case"OR":return"or";default:return g(1026)}}(e.compositeFilter.op))}(e):g(30097,{filter:e})}function Bo(e){return po[e]}function zo(e){return mo[e]}function Wo(e){return go[e]}function Go(e){return{fieldPath:e.canonicalString()}}function Ko(e){return U.fromServerFormat(e.fieldPath)}function $o(e){return e instanceof sr?function(e){if("=="===e.op){if(qn(e.value))return{unaryFilter:{field:Go(e.field),op:"IS_NAN"}};if(Un(e.value))return{unaryFilter:{field:Go(e.field),op:"IS_NULL"}}}else if("!="===e.op){if(qn(e.value))return{unaryFilter:{field:Go(e.field),op:"IS_NOT_NAN"}};if(Un(e.value))return{unaryFilter:{field:Go(e.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:Go(e.field),op:zo(e.op),value:e.value}}}(e):e instanceof ar?function(e){const t=e.getFilters().map(e=>$o(e));return 1===t.length?t[0]:{compositeFilter:{op:Wo(e.op),filters:t}}}(e):g(54877,{filter:e})}function Ho(e){const t=[];return e.fields.forEach(e=>t.push(e.canonicalString())),{fieldPaths:t}}function Qo(e){return e.length>=4&&"projects"===e.get(0)&&"databases"===e.get(2)}function Jo(e){return!!e&&"function"==typeof e._toProto&&"ProtoValue"===e._protoValueType}class Yo{constructor(e,t,n,r,i=ee.min(),o=ee.min(),s=an.EMPTY_BYTE_STRING,a=null){this.target=e,this.targetId=t,this.purpose=n,this.sequenceNumber=r,this.snapshotVersion=i,this.lastLimboFreeSnapshotVersion=o,this.resumeToken=s,this.expectedCount=a}withSequenceNumber(e){return new Yo(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(e,t){return new Yo(this.target,this.targetId,this.purpose,this.sequenceNumber,t,this.lastLimboFreeSnapshotVersion,e,null)}withExpectedCount(e){return new Yo(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,e)}withLastLimboFreeSnapshotVersion(e){return new Yo(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken,this.expectedCount)}}class Xo{constructor(e){this.yt=e}}function Zo(e,t){const n=t.key,r={prefixPath:n.getCollectionPath().popLast().toArray(),collectionGroup:n.collectionGroup,documentId:n.path.lastSegment(),readTime:es(t.readTime),hasCommittedMutations:t.hasCommittedMutations};if(t.isFoundDocument())r.document=function(e,t){return{name:Ao(e,t.key),fields:t.data.value.mapValue.fields,updateTime:bo(e,t.version.toTimestamp()),createTime:bo(e,t.createTime.toTimestamp())}}(e.yt,t);else if(t.isNoDocument())r.noDocument={path:n.path.toArray(),readTime:ts(t.version)};else{if(!t.isUnknownDocument())return g(57904,{document:t});r.unknownDocument={path:n.path.toArray(),version:ts(t.version)}}return r}function es(e){const t=e.toTimestamp();return[t.seconds,t.nanoseconds]}function ts(e){const t=e.toTimestamp();return{seconds:t.seconds,nanoseconds:t.nanoseconds}}function ns(e){const t=new Z(e.seconds,e.nanoseconds);return ee.fromTimestamp(t)}function rs(e,t){const n=(t.baseMutations||[]).map(t=>Lo(e.yt,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=>Lo(e.yt,t)),i=Z.fromMillis(t.localWriteTimeMs);return new Bi(t.batchId,i,n,r)}function is(e){const t=ns(e.readTime),n=void 0!==e.lastLimboFreeSnapshotVersion?ns(e.lastLimboFreeSnapshotVersion):ee.min();let r;return r=function(e){return void 0!==e.documents}(e.query)?function(e){const t=e.documents.length;return v(1===t,1966,{count:t}),Vr(Dr(Co(e.documents[0])))}(e.query):function(e){return Vr(Uo(e))}(e.query),new Yo(r,e.targetId,"TargetPurposeListen",e.lastListenSequenceNumber,t,n,an.fromBase64String(e.resumeToken))}function os(e,t){const n=ts(t.snapshotVersion),r=ts(t.lastLimboFreeSnapshotVersion);let i;i=Pr(t.target)?jo(e.yt,t.target):Fo(e.yt,t.target).ft;const o=t.resumeToken.toBase64();return{targetId:t.targetId,canonicalId:Ar(t.target),readTime:n,resumeToken:o,lastListenSequenceNumber:t.sequenceNumber,lastLimboFreeSnapshotVersion:r,query:i}}function ss(e){const t=Uo({parent:e.parent,structuredQuery:e.structuredQuery});return"LAST"===e.limitType?Br(t,t.limit,"L"):t}function as(e,t){return new Wi(t.largestBatchId,Lo(e.yt,t.overlayMutation))}function cs(e,t){const n=t.path.lastSegment();return[e,je(t.path.popLast()),n]}function us(e,t,n,r){return{indexId:e,uid:t,sequenceNumber:n,readTime:ts(r.readTime),documentKey:je(r.documentKey.path),largestBatchId:r.largestBatchId}}class ls{getBundleMetadata(e,t){return hs(e).get(t).next(e=>{if(e)return function(e){return{id:e.bundleId,createTime:ns(e.createTime),version:e.version}}(e)})}saveBundleMetadata(e,t){return hs(e).put(function(e){return{bundleId:e.id,createTime:ts(Io(e.createTime)),version:e.version}}(t))}getNamedQuery(e,t){return ds(e).get(t).next(e=>{if(e)return function(e){return{name:e.name,query:ss(e.bundledQuery),readTime:ns(e.readTime)}}(e)})}saveNamedQuery(e,t){return ds(e).put(function(e){return{name:e.name,readTime:ts(Io(e.readTime)),bundledQuery:e.bundledQuery}}(t))}}function hs(e){return $t(e,bt)}function ds(e){return $t(e,_t)}class fs{constructor(e,t){this.serializer=e,this.userId=t}static wt(e,t){const n=t.uid||"";return new fs(e,n)}getOverlay(e,t){return ps(e).get(cs(this.userId,t)).next(e=>e?as(this.serializer,e):null)}getOverlays(e,t){const n=ni();return ge.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 o=new Wi(t,i);r.push(this.bt(e,o))}),ge.waitFor(r)}removeOverlaysForBatchId(e,t,n){const r=new Set;t.forEach(e=>r.add(je(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(ps(e).X(xt,r))}),ge.waitFor(i)}getOverlaysForCollection(e,t,n){const r=ni(),i=je(t),o=IDBKeyRange.bound([this.userId,i,n],[this.userId,i,Number.POSITIVE_INFINITY],!0);return ps(e).H(xt,o).next(e=>{for(const t of e){const e=as(this.serializer,t);r.set(e.getKey(),e)}return r})}getOverlaysForCollectionGroup(e,t,n,r){const i=ni();let o;const s=IDBKeyRange.bound([this.userId,t,n],[this.userId,t,Number.POSITIVE_INFINITY],!0);return ps(e).ee({index:Mt,range:s},(e,t,n)=>{const s=as(this.serializer,t);i.size()<r||s.largestBatchId===o?(i.set(s.getKey(),s),o=s.largestBatchId):n.done()}).next(()=>i)}bt(e,t){return ps(e).put(function(e,t,n){const[r,i,o]=cs(t,n.mutation.key);return{userId:t,collectionPath:i,documentId:o,collectionGroup:n.mutation.key.getCollectionGroup(),largestBatchId:n.largestBatchId,overlayMutation:Mo(e.yt,n.mutation)}}(this.serializer,this.userId,t))}}function ps(e){return $t(e,kt)}class ms{St(e){return $t(e,jt)}getSessionToken(e){return this.St(e).get("sessionToken").next(e=>{const t=e?.value;return t?an.fromUint8Array(t):an.EMPTY_BYTE_STRING})}setSessionToken(e,t){return this.St(e).put({name:"sessionToken",value:t.toUint8Array()})}}class gs{constructor(){}Dt(e,t){this.Ct(e,t),t.vt()}Ct(e,t){if("nullValue"in e)this.Ft(t,5);else if("booleanValue"in e)this.Ft(t,10),t.Mt(e.booleanValue?1:0);else if("integerValue"in e)this.Ft(t,15),t.Mt(ln(e.integerValue));else if("doubleValue"in e){const n=ln(e.doubleValue);isNaN(n)?this.Ft(t,13):(this.Ft(t,15),De(n)?t.Mt(0):t.Mt(n))}else if("timestampValue"in e){let n=e.timestampValue;this.Ft(t,20),"string"==typeof n&&(n=un(n)),t.xt(`${n.seconds||""}`),t.Mt(n.nanos||0)}else if("stringValue"in e)this.Ot(e.stringValue,t),this.Nt(t);else if("bytesValue"in e)this.Ft(t,30),t.Bt(hn(e.bytesValue)),this.Nt(t);else if("referenceValue"in e)this.Lt(e.referenceValue,t);else if("geoPointValue"in e){const n=e.geoPointValue;this.Ft(t,45),t.Mt(n.latitude||0),t.Mt(n.longitude||0)}else"mapValue"in e?Gn(e)?this.Ft(t,Number.MAX_SAFE_INTEGER):zn(e)?this.kt(e.mapValue,t):(this.Kt(e.mapValue,t),this.Nt(t)):"arrayValue"in e?(this.qt(e.arrayValue,t),this.Nt(t)):g(19022,{Ut:e})}Ot(e,t){this.Ft(t,25),this.$t(e,t)}$t(e,t){t.xt(e)}Kt(e,t){const n=e.fields||{};this.Ft(t,55);for(const e of Object.keys(n))this.Ot(e,t),this.Ct(n[e],t)}kt(e,t){const n=e.fields||{};this.Ft(t,53);const r=An,i=n[r].arrayValue?.values?.length||0;this.Ft(t,15),t.Mt(ln(i)),this.Ot(r,t),this.Ct(n[r],t)}qt(e,t){const n=e.values||[];this.Ft(t,50);for(const e of n)this.Ct(e,t)}Lt(e,t){this.Ft(t,37),q.fromName(e).path.forEach(e=>{this.Ft(t,60),this.$t(e,t)})}Ft(e,t){e.Mt(t)}Nt(e){e.Mt(2)}}gs.Wt=new gs;const ys=255;function vs(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 bs(e){const t=64-function(e){let t=0;for(let n=0;n<8;++n){const r=vs(255&e[n]);if(t+=r,8!==r)break}return t}(e);return Math.ceil(t/8)}class _s{constructor(){this.buffer=new Uint8Array(1024),this.position=0}Qt(e){const t=e[Symbol.iterator]();let n=t.next();for(;!n.done;)this.Gt(n.value),n=t.next();this.zt()}jt(e){const t=e[Symbol.iterator]();let n=t.next();for(;!n.done;)this.Ht(n.value),n=t.next();this.Jt()}Zt(e){for(const t of e){const e=t.charCodeAt(0);if(e<128)this.Gt(e);else if(e<2048)this.Gt(960|e>>>6),this.Gt(128|63&e);else if(t<"\ud800"||"\udbff"<t)this.Gt(480|e>>>12),this.Gt(128|63&e>>>6),this.Gt(128|63&e);else{const e=t.codePointAt(0);this.Gt(240|e>>>18),this.Gt(128|63&e>>>12),this.Gt(128|63&e>>>6),this.Gt(128|63&e)}}this.zt()}Xt(e){for(const t of e){const e=t.charCodeAt(0);if(e<128)this.Ht(e);else if(e<2048)this.Ht(960|e>>>6),this.Ht(128|63&e);else if(t<"\ud800"||"\udbff"<t)this.Ht(480|e>>>12),this.Ht(128|63&e>>>6),this.Ht(128|63&e);else{const e=t.codePointAt(0);this.Ht(240|e>>>18),this.Ht(128|63&e>>>12),this.Ht(128|63&e>>>6),this.Ht(128|63&e)}}this.Jt()}Yt(e){const t=this.en(e),n=bs(t);this.tn(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]}nn(e){const t=this.en(e),n=bs(t);this.tn(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])}rn(){this.sn(ys),this.sn(255)}_n(){this.an(ys),this.an(255)}reset(){this.position=0}seed(e){this.tn(e.length),this.buffer.set(e,this.position),this.position+=e.length}un(){return this.buffer.slice(0,this.position)}en(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}Gt(e){const t=255&e;0===t?(this.sn(0),this.sn(255)):t===ys?(this.sn(ys),this.sn(0)):this.sn(t)}Ht(e){const t=255&e;0===t?(this.an(0),this.an(255)):t===ys?(this.an(ys),this.an(0)):this.an(e)}zt(){this.sn(0),this.sn(1)}Jt(){this.an(0),this.an(1)}sn(e){this.tn(1),this.buffer[this.position++]=e}an(e){this.tn(1),this.buffer[this.position++]=~e}tn(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 ws{constructor(e){this.cn=e}Bt(e){this.cn.Qt(e)}xt(e){this.cn.Zt(e)}Mt(e){this.cn.Yt(e)}vt(){this.cn.rn()}}class Is{constructor(e){this.cn=e}Bt(e){this.cn.jt(e)}xt(e){this.cn.Xt(e)}Mt(e){this.cn.nn(e)}vt(){this.cn._n()}}class Es{constructor(){this.cn=new _s,this.ascending=new ws(this.cn),this.descending=new Is(this.cn)}seed(e){this.cn.seed(e)}ln(e){return 0===e?this.ascending:this.descending}un(){return this.cn.un()}reset(){this.cn.reset()}}class Ts{constructor(e,t,n,r){this.hn=e,this.Pn=t,this.Tn=n,this.In=r}En(){const e=this.In.length,t=0===e||255===this.In[e-1]?e+1:e,n=new Uint8Array(t);return n.set(this.In,0),t!==e?n.set([0],this.In.length):++n[n.length-1],new Ts(this.hn,this.Pn,this.Tn,n)}Rn(e,t,n){return{indexId:this.hn,uid:e,arrayValue:Os(this.Tn),directionalValue:Os(this.In),orderedDocumentKey:Os(t),documentKey:n.path.toArray()}}An(e,t,n){const r=this.Rn(e,t,n);return[r.indexId,r.uid,r.arrayValue,r.directionalValue,r.orderedDocumentKey,r.documentKey]}}function Ss(e,t){let n=e.hn-t.hn;return 0!==n?n:(n=As(e.Tn,t.Tn),0!==n?n:(n=As(e.In,t.In),0!==n?n:q.comparator(e.Pn,t.Pn)))}function As(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}function Os(e){return i.isSafariOrWebkit()?function(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return t}(e):e}function Ps(e){return"string"!=typeof e?e:function(e){const t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}(e)}class Cs{constructor(e){this.Vn=new tn((e,t)=>U.comparator(e.field,t.field)),this.collectionId=null!=e.collectionGroup?e.collectionGroup:e.path.lastSegment(),this.dn=e.orderBy,this.mn=[];for(const t of e.filters){const e=t;e.isInequality()?this.Vn=this.Vn.add(e):this.mn.push(e)}}get fn(){return this.Vn.size>1}gn(e){if(v(e.collectionGroup===this.collectionId,49279),this.fn)return!1;const t=re(e);if(void 0!==t&&!this.pn(t))return!1;const n=ie(e);let r=new Set,i=0,o=0;for(;i<n.length&&this.pn(n[i]);++i)r=r.add(n[i].fieldPath.canonicalString());if(i===n.length)return!0;if(this.Vn.size>0){const e=this.Vn.getIterator().getNext();if(!r.has(e.field.canonicalString())){const t=n[i];if(!this.yn(e,t)||!this.wn(this.dn[o++],t))return!1}++i}for(;i<n.length;++i){const e=n[i];if(o>=this.dn.length||!this.wn(this.dn[o++],e))return!1}return!0}bn(){if(this.fn)return null;let e=new tn(U.comparator);const t=[];for(const n of this.mn)if(!n.field.isKeyField())if("array-contains"===n.op||"array-contains-any"===n.op)t.push(new se(n.field,2));else{if(e.has(n.field))continue;e=e.add(n.field),t.push(new se(n.field,0))}for(const n of this.dn)n.field.isKeyField()||e.has(n.field)||(e=e.add(n.field),t.push(new se(n.field,"asc"===n.dir?0:1)));return new ne(ne.UNKNOWN_ID,this.collectionId,t,ce.empty())}pn(e){for(const t of this.mn)if(this.yn(t,e))return!0;return!1}yn(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}wn(e,t){return!!e.field.isEqual(t.fieldPath)&&(0===t.kind&&"asc"===e.dir||1===t.kind&&"desc"===e.dir)}}function Rs(e){if(v(e instanceof sr||e instanceof ar,20012),e instanceof sr){if(e instanceof wr){const t=e.value.arrayValue?.values?.map(t=>sr.create(e.field,"==",t))||[];return ar.create(t,"or")}return e}const t=e.filters.map(e=>Rs(e));return ar.create(t,e.op)}function ks(e){if(0===e.getFilters().length)return[];const t=Ms(Rs(e));return v(Ds(t),7391),Ns(t)||xs(t)?[t]:t.getFilters()}function Ns(e){return e instanceof sr}function xs(e){return e instanceof ar&&lr(e)}function Ds(e){return Ns(e)||xs(e)||function(e){if(e instanceof ar&&ur(e)){for(const t of e.getFilters())if(!Ns(t)&&!xs(t))return!1;return!0}return!1}(e)}function Ms(e){if(v(e instanceof sr||e instanceof ar,34018),e instanceof sr)return e;if(1===e.filters.length)return Ms(e.filters[0]);const t=e.filters.map(e=>Ms(e));let n=ar.create(t,e.op);return n=Fs(n),Ds(n)?n:(v(n instanceof ar,64498),v(cr(n),40251),v(n.filters.length>1,57927),n.filters.reduce((e,t)=>Ls(e,t)))}function Ls(e,t){let n;return v(e instanceof sr||e instanceof ar,38388),v(t instanceof sr||t instanceof ar,25473),n=e instanceof sr?t instanceof sr?function(e,t){return ar.create([e,t],"and")}(e,t):js(e,t):t instanceof sr?js(t,e):function(e,t){if(v(e.filters.length>0&&t.filters.length>0,48005),cr(e)&&cr(t))return pr(e,t.getFilters());const n=ur(e)?e:t,r=ur(e)?t:e,i=n.filters.map(e=>Ls(e,r));return ar.create(i,"or")}(e,t),Fs(n)}function js(e,t){if(cr(t))return pr(t,e.getFilters());{const n=t.filters.map(t=>Ls(e,t));return ar.create(n,"or")}}function Fs(e){if(v(e instanceof sr||e instanceof ar,11850),e instanceof sr)return e;const t=e.getFilters();if(1===t.length)return Fs(t[0]);if(hr(e))return e;const n=t.map(e=>Fs(e)),r=[];return n.forEach(t=>{t instanceof sr?r.push(t):t instanceof ar&&(t.op===e.op?r.push(...t.filters):r.push(t))}),1===r.length?r[0]:ar.create(r,e.op)}class Vs{constructor(){this.Sn=new Us}addToCollectionParentIndex(e,t){return this.Sn.add(t),ge.resolve()}getCollectionParents(e,t){return ge.resolve(this.Sn.getEntries(t))}addFieldIndex(e,t){return ge.resolve()}deleteFieldIndex(e,t){return ge.resolve()}deleteAllFieldIndexes(e){return ge.resolve()}createTargetIndexes(e,t){return ge.resolve()}getDocumentsMatchingTarget(e,t){return ge.resolve(null)}getIndexType(e,t){return ge.resolve(0)}getFieldIndexes(e,t){return ge.resolve([])}getNextCollectionGroupToUpdate(e){return ge.resolve(null)}getMinOffset(e,t){return ge.resolve(he.min())}getMinOffsetFromCollectionGroup(e,t){return ge.resolve(he.min())}updateCollectionGroup(e,t,n){return ge.resolve()}updateIndexEntries(e,t){return ge.resolve()}}class Us{constructor(){this.index={}}add(e){const t=e.lastSegment(),n=e.popLast(),r=this.index[t]||new tn(F.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 tn(F.comparator)).toArray()}}const qs="IndexedDbIndexManager",Bs=new Uint8Array(0);class zs{constructor(e,t){this.databaseId=t,this.Dn=new Us,this.Cn=new Jr(e=>Ar(e),(e,t)=>Or(e,t)),this.uid=e.uid||""}addToCollectionParentIndex(e,t){if(!this.Dn.has(t)){const n=t.lastSegment(),r=t.popLast();e.addOnCommittedListener(()=>{this.Dn.add(t)});const i={collectionId:n,parent:je(r)};return Ws(e).put(i)}return ge.resolve()}getCollectionParents(e,t){const n=[],r=IDBKeyRange.bound([t,""],[M(t),""],!1,!0);return Ws(e).H(r).next(e=>{for(const r of e){if(r.collectionId!==t)break;n.push(Ue(r.parent))}return n})}addFieldIndex(e,t){const n=Ks(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=$s(e);return i.next(e=>{n.put(us(e,this.uid,t.indexState.sequenceNumber,t.indexState.offset))})}return i.next()}deleteFieldIndex(e,t){const n=Ks(e),r=$s(e),i=Gs(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=Ks(e),n=Gs(e),r=$s(e);return t.X().next(()=>n.X()).next(()=>r.X())}createTargetIndexes(e,t){return ge.forEach(this.vn(t),t=>this.getIndexType(e,t).next(n=>{if(0===n||1===n){const n=new Cs(t).bn();if(null!=n)return this.addFieldIndex(e,n)}}))}getDocumentsMatchingTarget(e,t){const n=Gs(e);let r=!0;const i=new Map;return ge.forEach(this.vn(t),t=>this.Fn(e,t).next(e=>{r&&(r=!!e),i.set(t,e)})).next(()=>{if(r){let e=ai();const r=[];return ge.forEach(i,(i,o)=>{d(qs,`Using index ${function(e){return`id=${e.indexId}|cg=${e.collectionGroup}|f=${e.fields.map(e=>`${e.fieldPath}:${e.kind}`).join(",")}`}(i)} to execute ${Ar(t)}`);const s=function(e,t){const n=re(t);if(void 0===n)return null;for(const t of Cr(e,n.fieldPath))switch(t.op){case"array-contains-any":return t.value.arrayValue.values||[];case"array-contains":return[t.value]}return null}(o,i),a=function(e,t){const n=new Map;for(const r of ie(t))for(const t of Cr(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}(o,i),c=function(e,t){const n=[];let r=!0;for(const i of ie(t)){const t=0===i.kind?Rr(e,i.fieldPath,e.startAt):kr(e,i.fieldPath,e.startAt);n.push(t.value),r&&(r=t.inclusive)}return new er(n,r)}(o,i),u=function(e,t){const n=[];let r=!0;for(const i of ie(t)){const t=0===i.kind?kr(e,i.fieldPath,e.endAt):Rr(e,i.fieldPath,e.endAt);n.push(t.value),r&&(r=t.inclusive)}return new er(n,r)}(o,i),l=this.Mn(i,o,c),h=this.Mn(i,o,u),f=this.xn(i,o,a),p=this.On(i.indexId,s,l,c.inclusive,h,u.inclusive,f);return ge.forEach(p,i=>n.Z(i,t.limit).next(t=>{t.forEach(t=>{const n=q.fromSegments(t.documentKey);e.has(n)||(e=e.add(n),r.push(n))})}))}).next(()=>r)}return ge.resolve(null)})}vn(e){let t=this.Cn.get(e);return t||(t=0===e.filters.length?[e]:ks(ar.create(e.filters,"and")).map(t=>Sr(e.path,e.collectionGroup,e.orderBy,t.getFilters(),e.limit,e.startAt,e.endAt)),this.Cn.set(e,t),t)}On(e,t,n,r,i,o,s){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.Nn(t[l/c]):Bs,h=this.Bn(e,a,n[l%c],r),d=this.Ln(e,a,i[l%c],o),f=s.map(t=>this.Bn(e,a,t,!0));u.push(...this.createRange(h,d,f))}return u}Bn(e,t,n,r){const i=new Ts(e,q.empty(),t,n);return r?i:i.En()}Ln(e,t,n,r){const i=new Ts(e,q.empty(),t,n);return r?i.En():i}Fn(e,t){const n=new Cs(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.gn(r)&&(!t||r.fields.length>t.fields.length)&&(t=r);return t})}getIndexType(e,t){let n=2;const r=this.vn(t);return ge.forEach(r,t=>this.Fn(e,t).next(e=>{e?0!==n&&e.fields.length<function(e){let t=new tn(U.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)}kn(e,t){const n=new Es;for(const r of ie(e)){const e=t.data.field(r.fieldPath);if(null==e)return null;const i=n.ln(r.kind);gs.Wt.Dt(e,i)}return n.un()}Nn(e){const t=new Es;return gs.Wt.Dt(e,t.ln(0)),t.un()}Kn(e,t){const n=new Es;return gs.Wt.Dt(jn(this.databaseId,t),n.ln(function(e){const t=ie(e);return 0===t.length?0:t[t.length-1].kind}(e))),n.un()}xn(e,t,n){if(null===n)return[];let r=[];r.push(new Es);let i=0;for(const o of ie(e)){const e=n[i++];for(const n of r)if(this.qn(t,o.fieldPath)&&Vn(e))r=this.Un(r,o,e);else{const t=n.ln(o.kind);gs.Wt.Dt(e,t)}}return this.$n(r)}Mn(e,t,n){return this.xn(e,t,n.position)}$n(e){const t=[];for(let n=0;n<e.length;++n)t[n]=e[n].un();return t}Un(e,t,n){const r=[...e],i=[];for(const e of n.arrayValue.values||[])for(const n of r){const r=new Es;r.seed(n.un()),gs.Wt.Dt(e,r.ln(t.kind)),i.push(r)}return i}qn(e,t){return!!e.filters.find(e=>e instanceof sr&&e.field.isEqual(t)&&("in"===e.op||"not-in"===e.op))}getFieldIndexes(e,t){const n=Ks(e),r=$s(e);return(t?n.H(It,IDBKeyRange.bound(t,t)):n.H()).next(e=>{const t=[];return ge.forEach(e,e=>r.get([e.indexId,this.uid]).next(n=>{t.push(function(e,t){const n=t?new ce(t.sequenceNumber,new he(ns(t.readTime),new q(Ue(t.documentKey)),t.largestBatchId)):ce.empty(),r=e.fields.map(([e,t])=>new se(U.fromServerFormat(e),t));return new ne(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:k(e.collectionGroup,t.collectionGroup)}),e[0].collectionGroup))}updateCollectionGroup(e,t,n){const r=Ks(e),i=$s(e);return this.Wn(e).next(e=>r.H(It,IDBKeyRange.bound(t,t)).next(t=>ge.forEach(t,t=>i.put(us(t.indexId,this.uid,e,n)))))}updateIndexEntries(e,t){const n=new Map;return ge.forEach(t,(t,r)=>{const i=n.get(t.collectionGroup);return(i?ge.resolve(i):this.getFieldIndexes(e,t.collectionGroup)).next(i=>(n.set(t.collectionGroup,i),ge.forEach(i,n=>this.Qn(e,t,n).next(t=>{const i=this.Gn(r,n);return t.isEqual(i)?ge.resolve():this.zn(e,r,n,t,i)}))))})}jn(e,t,n,r){return Gs(e).put(r.Rn(this.uid,this.Kn(n,t.key),t.key))}Hn(e,t,n,r){return Gs(e).delete(r.An(this.uid,this.Kn(n,t.key),t.key))}Qn(e,t,n){const r=Gs(e);let i=new tn(Ss);return r.ee({index:Ct,range:IDBKeyRange.only([n.indexId,this.uid,Os(this.Kn(n,t))])},(e,r)=>{i=i.add(new Ts(n.indexId,t,Ps(r.arrayValue),Ps(r.directionalValue)))}).next(()=>i)}Gn(e,t){let n=new tn(Ss);const r=this.kn(t,e);if(null==r)return n;const i=re(t);if(null!=i){const o=e.data.field(i.fieldPath);if(Vn(o))for(const i of o.arrayValue.values||[])n=n.add(new Ts(t.indexId,e.key,this.Nn(i),r))}else n=n.add(new Ts(t.indexId,e.key,Bs,r));return n}zn(e,t,n,r,i){d(qs,"Updating index entries for document '%s'",t.key);const o=[];return function(e,t,n,r,i){const o=e.getIterator(),s=t.getIterator();let a=rn(o),c=rn(s);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=rn(s)):t?(i(a),a=rn(o)):(a=rn(o),c=rn(s))}}(r,i,Ss,r=>{o.push(this.jn(e,t,n,r))},r=>{o.push(this.Hn(e,t,n,r))}),ge.waitFor(o)}Wn(e){let t=1;return $s(e).ee({index:St,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)=>Ss(e,t)).filter((e,t,n)=>!t||0!==Ss(e,n[t-1]));const r=[];r.push(e);for(const i of n){const n=Ss(i,e),o=Ss(i,t);if(0===n)r[0]=e.En();else if(n>0&&o<0)r.push(i),r.push(i.En());else if(o>0)break}r.push(t);const i=[];for(let e=0;e<r.length;e+=2){if(this.Jn(r[e],r[e+1]))return[];const t=r[e].An(this.uid,Bs,q.empty()),n=r[e+1].An(this.uid,Bs,q.empty());i.push(IDBKeyRange.bound(t,n))}return i}Jn(e,t){return Ss(e,t)>0}getMinOffsetFromCollectionGroup(e,t){return this.getFieldIndexes(e,t).next(Hs)}getMinOffset(e,t){return ge.mapArray(this.vn(t),t=>this.Fn(e,t).next(e=>e||g(44426))).next(Hs)}}function Ws(e){return $t(e,gt)}function Gs(e){return $t(e,Ot)}function Ks(e){return $t(e,wt)}function $s(e){return $t(e,Et)}function Hs(e){v(0!==e.length,28825);let t=e[0].indexState.offset,n=t.largestBatchId;for(let r=1;r<e.length;r++){const i=e[r].indexState.offset;de(i,t)<0&&(t=i),n<i.largestBatchId&&(n=i.largestBatchId)}return new he(t.readTime,t.documentKey,n)}const Qs={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0},Js=41943040;class Ys{static withCacheSize(e){return new Ys(e,Ys.DEFAULT_COLLECTION_PERCENTILE,Ys.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}constructor(e,t,n){this.cacheSizeCollectionThreshold=e,this.percentileToCollect=t,this.maximumSequenceNumbersToCollect=n}}function Xs(e,t,n){const r=e.store(Ge),i=e.store(Xe),o=[],s=IDBKeyRange.only(n.batchId);let a=0;const c=r.ee({range:s},(e,t,n)=>(a++,n.delete()));o.push(c.next(()=>{v(1===a,47070,{batchId:n.batchId})}));const u=[];for(const e of n.mutations){const r=Je(t,e.key.path,n.batchId);o.push(i.delete(r)),u.push(e.key)}return ge.waitFor(o).next(()=>u)}function Zs(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 g(14731);t=e.noDocument}return JSON.stringify(t).length}Ys.DEFAULT_COLLECTION_PERCENTILE=10,Ys.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,Ys.DEFAULT=new Ys(Js,Ys.DEFAULT_COLLECTION_PERCENTILE,Ys.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),Ys.DISABLED=new Ys(-1,0,0);class ea{constructor(e,t,n,r){this.userId=e,this.serializer=t,this.indexManager=n,this.referenceDelegate=r,this.Zn={}}static wt(e,t,n,r){v(""!==e.uid,64387);const i=e.isAuthenticated()?e.uid:"";return new ea(i,t,n,r)}checkEmpty(e){let t=!0;const n=IDBKeyRange.bound([this.userId,Number.NEGATIVE_INFINITY],[this.userId,Number.POSITIVE_INFINITY]);return na(e).ee({index:$e,range:n},(e,n,r)=>{t=!1,r.done()}).next(()=>t)}addMutationBatch(e,t,n,r){const i=ra(e),o=na(e);return o.add({}).next(s=>{v("number"==typeof s,49019);const a=new Bi(s,t,n,r),c=function(e,t,n){const r=n.baseMutations.map(t=>Mo(e.yt,t)),i=n.mutations.map(t=>Mo(e.yt,t));return{userId:t,batchId:n.batchId,localWriteTimeMs:n.localWriteTime.toMillis(),baseMutations:r,mutations:i}}(this.serializer,this.userId,a),u=[];let l=new tn((e,t)=>k(e.canonicalString(),t.canonicalString()));for(const e of r){const t=Je(this.userId,e.key.path,s);l=l.add(e.key.path.popLast()),u.push(o.put(c)),u.push(i.put(t,Ye))}return l.forEach(t=>{u.push(this.indexManager.addToCollectionParentIndex(e,t))}),e.addOnCommittedListener(()=>{this.Zn[s]=a.keys()}),ge.waitFor(u).next(()=>a)})}lookupMutationBatch(e,t){return na(e).get(t).next(e=>e?(v(e.userId===this.userId,48,"Unexpected user for mutation batch",{userId:e.userId,batchId:t}),rs(this.serializer,e)):null)}Xn(e,t){return this.Zn[t]?ge.resolve(this.Zn[t]):this.lookupMutationBatch(e,t).next(e=>{if(e){const n=e.keys();return this.Zn[t]=n,n}return null})}getNextMutationBatchAfterBatchId(e,t){const n=t+1,r=IDBKeyRange.lowerBound([this.userId,n]);let i=null;return na(e).ee({index:$e,range:r},(e,t,r)=>{t.userId===this.userId&&(v(t.batchId>=n,47524,{Yn:n}),i=rs(this.serializer,t)),r.done()}).next(()=>i)}getHighestUnacknowledgedBatchId(e){const t=IDBKeyRange.upperBound([this.userId,Number.POSITIVE_INFINITY]);let n=Ne;return na(e).ee({index:$e,range:t,reverse:!0},(e,t,r)=>{n=t.batchId,r.done()}).next(()=>n)}getAllMutationBatches(e){const t=IDBKeyRange.bound([this.userId,Ne],[this.userId,Number.POSITIVE_INFINITY]);return na(e).H($e,t).next(e=>e.map(e=>rs(this.serializer,e)))}getAllMutationBatchesAffectingDocumentKey(e,t){const n=Qe(this.userId,t.path),r=IDBKeyRange.lowerBound(n),i=[];return ra(e).ee({range:r},(n,r,o)=>{const[s,a,c]=n,u=Ue(a);if(s===this.userId&&t.path.isEqual(u))return na(e).get(c).next(e=>{if(!e)throw g(61480,{er:n,batchId:c});v(e.userId===this.userId,10503,"Unexpected user for mutation batch",{userId:e.userId,batchId:c}),i.push(rs(this.serializer,e))});o.done()}).next(()=>i)}getAllMutationBatchesAffectingDocumentKeys(e,t){let n=new tn(k);const r=[];return t.forEach(t=>{const i=Qe(this.userId,t.path),o=IDBKeyRange.lowerBound(i),s=ra(e).ee({range:o},(e,r,i)=>{const[o,s,a]=e,c=Ue(s);o===this.userId&&t.path.isEqual(c)?n=n.add(a):i.done()});r.push(s)}),ge.waitFor(r).next(()=>this.tr(e,n))}getAllMutationBatchesAffectingQuery(e,t){const n=t.path,r=n.length+1,i=Qe(this.userId,n),o=IDBKeyRange.lowerBound(i);let s=new tn(k);return ra(e).ee({range:o},(e,t,i)=>{const[o,a,c]=e,u=Ue(a);o===this.userId&&n.isPrefixOf(u)?u.length===r&&(s=s.add(c)):i.done()}).next(()=>this.tr(e,s))}tr(e,t){const n=[],r=[];return t.forEach(t=>{r.push(na(e).get(t).next(e=>{if(null===e)throw g(35274,{batchId:t});v(e.userId===this.userId,9748,"Unexpected user for mutation batch",{userId:e.userId,batchId:t}),n.push(rs(this.serializer,e))}))}),ge.waitFor(r).next(()=>n)}removeMutationBatch(e,t){return Xs(e.le,this.userId,t).next(n=>(e.addOnCommittedListener(()=>{this.nr(t.batchId)}),ge.forEach(n,t=>this.referenceDelegate.markPotentiallyOrphaned(e,t))))}nr(e){delete this.Zn[e]}performConsistencyCheck(e){return this.checkEmpty(e).next(t=>{if(!t)return ge.resolve();const n=IDBKeyRange.lowerBound(function(e){return[e]}(this.userId)),r=[];return ra(e).ee({range:n},(e,t,n)=>{if(e[0]===this.userId){const t=Ue(e[1]);r.push(t)}else n.done()}).next(()=>{v(0===r.length,56720,{rr:r.map(e=>e.canonicalString())})})})}containsKey(e,t){return ta(e,this.userId,t)}ir(e){return ia(e).get(this.userId).next(e=>e||{userId:this.userId,lastAcknowledgedBatchId:Ne,lastStreamToken:""})}}function ta(e,t,n){const r=Qe(t,n.path),i=r[1],o=IDBKeyRange.lowerBound(r);let s=!1;return ra(e).ee({range:o,Y:!0},(e,n,r)=>{const[o,a,c]=e;o===t&&a===i&&(s=!0),r.done()}).next(()=>s)}function na(e){return $t(e,Ge)}function ra(e){return $t(e,Xe)}function ia(e){return $t(e,We)}class oa{constructor(e){this.sr=e}next(){return this.sr+=2,this.sr}static _r(){return new oa(0)}static ar(){return new oa(-1)}}class sa{constructor(e,t){this.referenceDelegate=e,this.serializer=t}allocateTargetId(e){return this.ur(e).next(t=>{const n=new oa(t.highestTargetId);return t.highestTargetId=n.next(),this.cr(e,t).next(()=>t.highestTargetId)})}getLastRemoteSnapshotVersion(e){return this.ur(e).next(e=>ee.fromTimestamp(new Z(e.lastRemoteSnapshotVersion.seconds,e.lastRemoteSnapshotVersion.nanoseconds)))}getHighestSequenceNumber(e){return this.ur(e).next(e=>e.highestListenSequenceNumber)}setTargetsMetadata(e,t,n){return this.ur(e).next(r=>(r.highestListenSequenceNumber=t,n&&(r.lastRemoteSnapshotVersion=n.toTimestamp()),t>r.highestListenSequenceNumber&&(r.highestListenSequenceNumber=t),this.cr(e,r)))}addTargetData(e,t){return this.lr(e,t).next(()=>this.ur(e).next(n=>(n.targetCount+=1,this.hr(t,n),this.cr(e,n))))}updateTargetData(e,t){return this.lr(e,t)}removeTargetData(e,t){return this.removeMatchingKeysForTargetId(e,t.targetId).next(()=>aa(e).delete(t.targetId)).next(()=>this.ur(e)).next(t=>(v(t.targetCount>0,8065),t.targetCount-=1,this.cr(e,t)))}removeTargets(e,t,n){let r=0;const i=[];return aa(e).ee((o,s)=>{const a=is(s);a.sequenceNumber<=t&&null===n.get(a.targetId)&&(r++,i.push(this.removeTargetData(e,a)))}).next(()=>ge.waitFor(i)).next(()=>r)}forEachTarget(e,t){return aa(e).ee((e,n)=>{const r=is(n);t(r)})}ur(e){return ca(e).get(pt).next(e=>(v(null!==e,2888),e))}cr(e,t){return ca(e).put(pt,t)}lr(e,t){return aa(e).put(os(this.serializer,t))}hr(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.ur(e).next(e=>e.targetCount)}getTargetData(e,t){const n=Ar(t),r=IDBKeyRange.bound([n,Number.NEGATIVE_INFINITY],[n,Number.POSITIVE_INFINITY]);let i=null;return aa(e).ee({range:r,index:ct},(e,n,r)=>{const o=is(n);Or(t,o.target)&&(i=o,r.done())}).next(()=>i)}addMatchingKeys(e,t,n){const r=[],i=ua(e);return t.forEach(t=>{const o=je(t.path);r.push(i.put({targetId:n,path:o})),r.push(this.referenceDelegate.addReference(e,n,t))}),ge.waitFor(r)}removeMatchingKeys(e,t,n){const r=ua(e);return ge.forEach(t,t=>{const i=je(t.path);return ge.waitFor([r.delete([n,i]),this.referenceDelegate.removeReference(e,n,t)])})}removeMatchingKeysForTargetId(e,t){const n=ua(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=ua(e);let i=ai();return r.ee({range:n,Y:!0},(e,t,n)=>{const r=Ue(e[1]),o=new q(r);i=i.add(o)}).next(()=>i)}containsKey(e,t){const n=je(t.path),r=IDBKeyRange.bound([n],[M(n)],!1,!0);let i=0;return ua(e).ee({index:dt,Y:!0,range:r},([e,t],n,r)=>{0!==e&&(i++,r.done())}).next(()=>i>0)}At(e,t){return aa(e).get(t).next(e=>e?is(e):null)}}function aa(e){return $t(e,at)}function ca(e){return $t(e,mt)}function ua(e){return $t(e,lt)}const la="LruGarbageCollector",ha=1048576;function da([e,t],[n,r]){const i=k(e,n);return 0===i?k(t,r):i}class fa{constructor(e){this.Pr=e,this.buffer=new tn(da),this.Tr=0}Ir(){return++this.Tr}Er(e){const t=[e,this.Ir()];if(this.buffer.size<this.Pr)this.buffer=this.buffer.add(t);else{const e=this.buffer.last();da(t,e)<0&&(this.buffer=this.buffer.delete(e).add(t))}}get maxValue(){return this.buffer.last()[0]}}class pa{constructor(e,t,n){this.garbageCollector=e,this.asyncQueue=t,this.localStore=n,this.Rr=null}start(){-1!==this.garbageCollector.params.cacheSizeCollectionThreshold&&this.Ar(6e4)}stop(){this.Rr&&(this.Rr.cancel(),this.Rr=null)}get started(){return null!==this.Rr}Ar(e){d(la,`Garbage collection scheduled in ${e}ms`),this.Rr=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",e,async()=>{this.Rr=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(e){Ee(e)?d(la,"Ignoring IndexedDB error during garbage collection: ",e):await me(e)}await this.Ar(3e5)})}}class ma{constructor(e,t){this.Vr=e,this.params=t}calculateTargetCount(e,t){return this.Vr.dr(e).next(e=>Math.floor(t/100*e))}nthSequenceNumber(e,t){if(0===t)return ge.resolve(ke.ce);const n=new fa(t);return this.Vr.forEachTarget(e,e=>n.Er(e.sequenceNumber)).next(()=>this.Vr.mr(e,e=>n.Er(e))).next(()=>n.maxValue)}removeTargets(e,t,n){return this.Vr.removeTargets(e,t,n)}removeOrphanedDocuments(e,t){return this.Vr.removeOrphanedDocuments(e,t)}collect(e,t){return-1===this.params.cacheSizeCollectionThreshold?(d("LruGarbageCollector","Garbage collection skipped; disabled"),ge.resolve(Qs)):this.getCacheSize(e).next(n=>n<this.params.cacheSizeCollectionThreshold?(d("LruGarbageCollector",`Garbage collection skipped; Cache size ${n} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),Qs):this.gr(e,t))}getCacheSize(e){return this.Vr.getCacheSize(e)}gr(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?(d("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(),h()<=s.LogLevel.DEBUG&&d("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`),ge.resolve({didRun:!0,sequenceNumbersCollected:r,targetsRemoved:i,documentsRemoved:e})))}}function ga(e,t){return new ma(e,t)}class ya{constructor(e,t){this.db=e,this.garbageCollector=ga(this,t)}dr(e){const t=this.pr(e);return this.db.getTargetCache().getTargetCount(e).next(e=>t.next(t=>e+t))}pr(e){let t=0;return this.mr(e,e=>{t++}).next(()=>t)}forEachTarget(e,t){return this.db.getTargetCache().forEachTarget(e,t)}mr(e,t){return this.yr(e,(e,n)=>t(n))}addReference(e,t,n){return va(e,n)}removeReference(e,t,n){return va(e,n)}removeTargets(e,t,n){return this.db.getTargetCache().removeTargets(e,t,n)}markPotentiallyOrphaned(e,t){return va(e,t)}wr(e,t){return function(e,t){let n=!1;return ia(e).te(r=>ta(e,r,t).next(e=>(e&&(n=!0),ge.resolve(!e)))).next(()=>n)}(e,t)}removeOrphanedDocuments(e,t){const n=this.db.getRemoteDocumentCache().newChangeBuffer(),r=[];let i=0;return this.yr(e,(o,s)=>{if(s<=t){const t=this.wr(e,o).next(t=>{if(!t)return i++,n.getEntry(e,o).next(()=>(n.removeEntry(o,ee.min()),ua(e).delete(function(e){return[0,je(e.path)]}(o))))});r.push(t)}}).next(()=>ge.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 va(e,t)}yr(e,t){const n=ua(e);let r,i=ke.ce;return n.ee({index:dt},([e,n],{path:o,sequenceNumber:s})=>{0===e?(i!==ke.ce&&t(new q(Ue(r)),i),i=s,r=o):i=ke.ce}).next(()=>{i!==ke.ce&&t(new q(Ue(r)),i)})}getCacheSize(e){return this.db.getRemoteDocumentCache().getSize(e)}}function va(e,t){return ua(e).put(function(e,t){return{targetId:0,path:je(e.path),sequenceNumber:t}}(t,e.currentSequenceNumber))}class ba{constructor(){this.changes=new Jr(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,Zn.newInvalidDocument(e).setReadTime(t))}getEntry(e,t){this.assertNotApplied();const n=this.changes.get(t);return void 0!==n?ge.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 _a{constructor(e){this.serializer=e}setIndexManager(e){this.indexManager=e}addEntry(e,t,n){return Ta(e).put(n)}removeEntry(e,t,n){return Ta(e).delete(function(e,t){const n=e.path.toArray();return[n.slice(0,n.length-2),n[n.length-2],es(t),n[n.length-1]]}(t,n))}updateMetadata(e,t){return this.getMetadata(e).next(n=>(n.byteSize+=t,this.br(e,n)))}getEntry(e,t){let n=Zn.newInvalidDocument(t);return Ta(e).ee({index:tt,range:IDBKeyRange.only(Sa(t))},(e,r)=>{n=this.Sr(t,r)}).next(()=>n)}Dr(e,t){let n={size:0,document:Zn.newInvalidDocument(t)};return Ta(e).ee({index:tt,range:IDBKeyRange.only(Sa(t))},(e,r)=>{n={document:this.Sr(t,r),size:Zs(r)}}).next(()=>n)}getEntries(e,t){let n=Xr();return this.Cr(e,t,(e,t)=>{const r=this.Sr(e,t);n=n.insert(e,r)}).next(()=>n)}vr(e,t){let n=Xr(),r=new Xt(q.comparator);return this.Cr(e,t,(e,t)=>{const i=this.Sr(e,t);n=n.insert(e,i),r=r.insert(e,Zs(t))}).next(()=>({documents:n,Fr:r}))}Cr(e,t,n){if(t.isEmpty())return ge.resolve();let r=new tn(Oa);t.forEach(e=>r=r.add(e));const i=IDBKeyRange.bound(Sa(r.first()),Sa(r.last())),o=r.getIterator();let s=o.getNext();return Ta(e).ee({index:tt,range:i},(e,t,r)=>{const i=q.fromSegments([...t.prefixPath,t.collectionGroup,t.documentId]);for(;s&&Oa(s,i)<0;)n(s,null),s=o.getNext();s&&s.isEqual(i)&&(n(s,t),s=o.hasNext()?o.getNext():null),s?r.j(Sa(s)):r.done()}).next(()=>{for(;s;)n(s,null),s=o.hasNext()?o.getNext():null})}getDocumentsMatchingQuery(e,t,n,r,i){const o=t.path,s=[o.popLast().toArray(),o.lastSegment(),es(n.readTime),n.documentKey.path.isEmpty()?"":n.documentKey.path.lastSegment()],a=[o.popLast().toArray(),o.lastSegment(),[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],""];return Ta(e).H(IDBKeyRange.bound(s,a,!0)).next(e=>{i?.incrementDocumentReadCount(e.length);let n=Xr();for(const i of e){const e=this.Sr(q.fromSegments(i.prefixPath.concat(i.collectionGroup,i.documentId)),i);e.isFoundDocument()&&(Kr(t,e)||r.has(e.key))&&(n=n.insert(e.key,e))}return n})}getAllFromCollectionGroup(e,t,n,r){let i=Xr();const o=Aa(t,n),s=Aa(t,he.max());return Ta(e).ee({index:rt,range:IDBKeyRange.bound(o,s,!0)},(e,t,n)=>{const o=this.Sr(q.fromSegments(t.prefixPath.concat(t.collectionGroup,t.documentId)),t);i=i.insert(o.key,o),i.size===r&&n.done()}).next(()=>i)}newChangeBuffer(e){return new Ia(this,!!e&&e.trackRemovals)}getSize(e){return this.getMetadata(e).next(e=>e.byteSize)}getMetadata(e){return Ea(e).get(st).next(e=>(v(!!e,20021),e))}br(e,t){return Ea(e).put(st,t)}Sr(e,t){if(t){const e=function(e,t){let n;if(t.document)n=Do(e.yt,t.document,!!t.hasCommittedMutations);else if(t.noDocument){const e=q.fromSegments(t.noDocument.path),r=ns(t.noDocument.readTime);n=Zn.newNoDocument(e,r),t.hasCommittedMutations&&n.setHasCommittedMutations()}else{if(!t.unknownDocument)return g(56709);{const e=q.fromSegments(t.unknownDocument.path),r=ns(t.unknownDocument.version);n=Zn.newUnknownDocument(e,r)}}return t.readTime&&n.setReadTime(function(e){const t=new Z(e[0],e[1]);return ee.fromTimestamp(t)}(t.readTime)),n}(this.serializer,t);if(!e.isNoDocument()||!e.version.isEqual(ee.min()))return e}return Zn.newInvalidDocument(e)}}function wa(e){return new _a(e)}class Ia extends ba{constructor(e,t){super(),this.Mr=e,this.trackRemovals=t,this.Or=new Jr(e=>e.toString(),(e,t)=>e.isEqual(t))}applyChanges(e){const t=[];let n=0,r=new tn((e,t)=>k(e.canonicalString(),t.canonicalString()));return this.changes.forEach((i,o)=>{const s=this.Or.get(i);if(t.push(this.Mr.removeEntry(e,i,s.readTime)),o.isValidDocument()){const a=Zo(this.Mr.serializer,o);r=r.add(i.path.popLast());const c=Zs(a);n+=c-s.size,t.push(this.Mr.addEntry(e,i,a))}else if(n-=s.size,this.trackRemovals){const n=Zo(this.Mr.serializer,o.convertToNoDocument(ee.min()));t.push(this.Mr.addEntry(e,i,n))}}),r.forEach(n=>{t.push(this.Mr.indexManager.addToCollectionParentIndex(e,n))}),t.push(this.Mr.updateMetadata(e,n)),ge.waitFor(t)}getFromCache(e,t){return this.Mr.Dr(e,t).next(e=>(this.Or.set(t,{size:e.size,readTime:e.document.readTime}),e.document))}getAllFromCache(e,t){return this.Mr.vr(e,t).next(({documents:e,Fr:t})=>(t.forEach((t,n)=>{this.Or.set(t,{size:n,readTime:e.get(t).readTime})}),e))}}function Ea(e){return $t(e,ot)}function Ta(e){return $t(e,Ze)}function Sa(e){const t=e.path.toArray();return[t.slice(0,t.length-2),t[t.length-2],t[t.length-1]]}function Aa(e,t){const n=t.documentKey.path.toArray();return[e,es(t.readTime),n.slice(0,n.length-2),n.length>0?n[n.length-1]:""]}function Oa(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=k(n[e],r[e]),i)return i;return i=k(n.length,r.length),i||(i=k(n[n.length-2],r[r.length-2]),i||k(n[n.length-1],r[r.length-1]))}class Pa{constructor(e,t){this.overlayedDocument=e,this.mutatedFields=t}}class Ca{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&&Ni(n.mutation,e,on.empty(),Z.now()),e))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next(t=>this.getLocalViewOfDocuments(e,t,ai()).next(()=>t))}getLocalViewOfDocuments(e,t,n=ai()){const r=ni();return this.populateOverlays(e,r,t).next(()=>this.computeViews(e,t,r,n).next(e=>{let t=ei();return e.forEach((e,n)=>{t=t.insert(e,n.overlayedDocument)}),t}))}getOverlayedDocuments(e,t){const n=ni();return this.populateOverlays(e,n,t).next(()=>this.computeViews(e,t,n,ai()))}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=Xr();const o=ii(),s=ii();return t.forEach((e,t)=>{const s=n.get(t.key);r.has(t.key)&&(void 0===s||s.mutation instanceof Li)?i=i.insert(t.key,t):void 0!==s?(o.set(t.key,s.mutation.getFieldMask()),Ni(s.mutation,t,s.mutation.getFieldMask(),Z.now())):o.set(t.key,on.empty())}),this.recalculateAndSaveOverlays(e,i).next(e=>(e.forEach((e,t)=>o.set(e,t)),t.forEach((e,t)=>s.set(e,new Pa(t,o.get(e)??null))),s))}recalculateAndSaveOverlays(e,t){const n=ii();let r=new Xt((e,t)=>e-t),i=ai();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,t).next(e=>{for(const i of e)i.keys().forEach(e=>{const o=t.get(e);if(null===o)return;let s=n.get(e)||on.empty();s=i.applyToLocalView(o,s),n.set(e,s);const a=(r.get(i.batchId)||ai()).add(e);r=r.insert(i.batchId,a)})}).next(()=>{const o=[],s=r.getReverseIterator();for(;s.hasNext();){const r=s.getNext(),a=r.key,c=r.value,u=ri();c.forEach(e=>{if(!i.has(e)){const r=Ri(t.get(e),n.get(e));null!==r&&u.set(e,r),i=i.add(e)}}),o.push(this.documentOverlayCache.saveOverlays(e,a,u))}return ge.waitFor(o)}).next(()=>n)}recalculateAndSaveOverlaysForDocumentKeys(e,t){return this.remoteDocumentCache.getEntries(e,t).next(t=>this.recalculateAndSaveOverlays(e,t))}getDocumentsMatchingQuery(e,t,n,r){return Lr(t)?this.getDocumentsMatchingDocumentQuery(e,t.path):jr(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 o=r-i.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(e,t,n.largestBatchId,r-i.size):ge.resolve(ni());let s=te,a=i;return o.next(t=>ge.forEach(t,(t,n)=>(s<n.largestBatchId&&(s=n.largestBatchId),i.get(t)?ge.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,ai())).next(e=>({batchId:s,changes:ti(e)})))})}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new q(t)).next(e=>{let t=ei();return e.isFoundDocument()&&(t=t.insert(e.key,e)),t})}getDocumentsMatchingCollectionGroupQuery(e,t,n,r){const i=t.collectionGroup;let o=ei();return this.indexManager.getCollectionParents(e,i).next(s=>ge.forEach(s,s=>{const a=function(e,t){return new Nr(t,null,e.explicitOrderBy.slice(),e.filters.slice(),e.limit,e.limitType,e.startAt,e.endAt)}(t,s.child(i));return this.getDocumentsMatchingCollectionQuery(e,a,n,r).next(e=>{e.forEach((e,t)=>{o=o.insert(e,t)})})}).next(()=>o))}getDocumentsMatchingCollectionQuery(e,t,n,r){let i;return this.documentOverlayCache.getOverlaysForCollection(e,t.path,n.largestBatchId).next(o=>(i=o,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,Zn.newInvalidDocument(r)))});let n=ei();return e.forEach((e,r)=>{const o=i.get(e);void 0!==o&&Ni(o.mutation,r,on.empty(),Z.now()),Kr(t,r)&&(n=n.insert(e,r))}),n})}}class Ra{constructor(e){this.serializer=e,this.Nr=new Map,this.Br=new Map}getBundleMetadata(e,t){return ge.resolve(this.Nr.get(t))}saveBundleMetadata(e,t){return this.Nr.set(t.id,function(e){return{id:e.id,version:e.version,createTime:Io(e.createTime)}}(t)),ge.resolve()}getNamedQuery(e,t){return ge.resolve(this.Br.get(t))}saveNamedQuery(e,t){return this.Br.set(t.name,function(e){return{name:e.name,query:ss(e.bundledQuery),readTime:Io(e.readTime)}}(t)),ge.resolve()}}class ka{constructor(){this.overlays=new Xt(q.comparator),this.Lr=new Map}getOverlay(e,t){return ge.resolve(this.overlays.get(t))}getOverlays(e,t){const n=ni();return ge.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.bt(e,t,r)}),ge.resolve()}removeOverlaysForBatchId(e,t,n){const r=this.Lr.get(n);return void 0!==r&&(r.forEach(e=>this.overlays=this.overlays.remove(e)),this.Lr.delete(n)),ge.resolve()}getOverlaysForCollection(e,t,n){const r=ni(),i=t.length+1,o=new q(t.child("")),s=this.overlays.getIteratorFrom(o);for(;s.hasNext();){const e=s.getNext().value,o=e.getKey();if(!t.isPrefixOf(o.path))break;o.path.length===i&&e.largestBatchId>n&&r.set(e.getKey(),e)}return ge.resolve(r)}getOverlaysForCollectionGroup(e,t,n,r){let i=new Xt((e,t)=>e-t);const o=this.overlays.getIterator();for(;o.hasNext();){const e=o.getNext().value;if(e.getKey().getCollectionGroup()===t&&e.largestBatchId>n){let t=i.get(e.largestBatchId);null===t&&(t=ni(),i=i.insert(e.largestBatchId,t)),t.set(e.getKey(),e)}}const s=ni(),a=i.getIterator();for(;a.hasNext()&&(a.getNext().value.forEach((e,t)=>s.set(e,t)),!(s.size()>=r)););return ge.resolve(s)}bt(e,t,n){const r=this.overlays.get(n.key);if(null!==r){const e=this.Lr.get(r.largestBatchId).delete(n.key);this.Lr.set(r.largestBatchId,e)}this.overlays=this.overlays.insert(n.key,new Wi(t,n));let i=this.Lr.get(t);void 0===i&&(i=ai(),this.Lr.set(t,i)),this.Lr.set(t,i.add(n.key))}}class Na{constructor(){this.sessionToken=an.EMPTY_BYTE_STRING}getSessionToken(e){return ge.resolve(this.sessionToken)}setSessionToken(e,t){return this.sessionToken=t,ge.resolve()}}class xa{constructor(){this.kr=new tn(Da.Kr),this.qr=new tn(Da.Ur)}isEmpty(){return this.kr.isEmpty()}addReference(e,t){const n=new Da(e,t);this.kr=this.kr.add(n),this.qr=this.qr.add(n)}$r(e,t){e.forEach(e=>this.addReference(e,t))}removeReference(e,t){this.Wr(new Da(e,t))}Qr(e,t){e.forEach(e=>this.removeReference(e,t))}Gr(e){const t=new q(new F([])),n=new Da(t,e),r=new Da(t,e+1),i=[];return this.qr.forEachInRange([n,r],e=>{this.Wr(e),i.push(e.key)}),i}zr(){this.kr.forEach(e=>this.Wr(e))}Wr(e){this.kr=this.kr.delete(e),this.qr=this.qr.delete(e)}jr(e){const t=new q(new F([])),n=new Da(t,e),r=new Da(t,e+1);let i=ai();return this.qr.forEachInRange([n,r],e=>{i=i.add(e.key)}),i}containsKey(e){const t=new Da(e,0),n=this.kr.firstAfterOrEqual(t);return null!==n&&e.isEqual(n.key)}}class Da{constructor(e,t){this.key=e,this.Hr=t}static Kr(e,t){return q.comparator(e.key,t.key)||k(e.Hr,t.Hr)}static Ur(e,t){return k(e.Hr,t.Hr)||q.comparator(e.key,t.key)}}class Ma{constructor(e,t){this.indexManager=e,this.referenceDelegate=t,this.mutationQueue=[],this.Yn=1,this.Jr=new tn(Da.Kr)}checkEmpty(e){return ge.resolve(0===this.mutationQueue.length)}addMutationBatch(e,t,n,r){const i=this.Yn;this.Yn++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];const o=new Bi(i,t,n,r);this.mutationQueue.push(o);for(const t of r)this.Jr=this.Jr.add(new Da(t.key,i)),this.indexManager.addToCollectionParentIndex(e,t.key.path.popLast());return ge.resolve(o)}lookupMutationBatch(e,t){return ge.resolve(this.Zr(t))}getNextMutationBatchAfterBatchId(e,t){const n=t+1,r=this.Xr(n),i=r<0?0:r;return ge.resolve(this.mutationQueue.length>i?this.mutationQueue[i]:null)}getHighestUnacknowledgedBatchId(){return ge.resolve(0===this.mutationQueue.length?Ne:this.Yn-1)}getAllMutationBatches(e){return ge.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){const n=new Da(t,0),r=new Da(t,Number.POSITIVE_INFINITY),i=[];return this.Jr.forEachInRange([n,r],e=>{const t=this.Zr(e.Hr);i.push(t)}),ge.resolve(i)}getAllMutationBatchesAffectingDocumentKeys(e,t){let n=new tn(k);return t.forEach(e=>{const t=new Da(e,0),r=new Da(e,Number.POSITIVE_INFINITY);this.Jr.forEachInRange([t,r],e=>{n=n.add(e.Hr)})}),ge.resolve(this.Yr(n))}getAllMutationBatchesAffectingQuery(e,t){const n=t.path,r=n.length+1;let i=n;q.isDocumentKey(i)||(i=i.child(""));const o=new Da(new q(i),0);let s=new tn(k);return this.Jr.forEachWhile(e=>{const t=e.key.path;return!!n.isPrefixOf(t)&&(t.length===r&&(s=s.add(e.Hr)),!0)},o),ge.resolve(this.Yr(s))}Yr(e){const t=[];return e.forEach(e=>{const n=this.Zr(e);null!==n&&t.push(n)}),t}removeMutationBatch(e,t){v(0===this.ei(t.batchId,"removed"),55003),this.mutationQueue.shift();let n=this.Jr;return ge.forEach(t.mutations,r=>{const i=new Da(r.key,t.batchId);return n=n.delete(i),this.referenceDelegate.markPotentiallyOrphaned(e,r.key)}).next(()=>{this.Jr=n})}nr(e){}containsKey(e,t){const n=new Da(t,0),r=this.Jr.firstAfterOrEqual(n);return ge.resolve(t.isEqual(r&&r.key))}performConsistencyCheck(e){return this.mutationQueue.length,ge.resolve()}ei(e,t){return this.Xr(e)}Xr(e){return 0===this.mutationQueue.length?0:e-this.mutationQueue[0].batchId}Zr(e){const t=this.Xr(e);return t<0||t>=this.mutationQueue.length?null:this.mutationQueue[t]}}class La{constructor(e){this.ti=e,this.docs=new Xt(q.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,o=this.ti(t);return this.docs=this.docs.insert(n,{document:t.mutableCopy(),size:o}),this.size+=o-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 ge.resolve(n?n.document.mutableCopy():Zn.newInvalidDocument(t))}getEntries(e,t){let n=Xr();return t.forEach(e=>{const t=this.docs.get(e);n=n.insert(e,t?t.document.mutableCopy():Zn.newInvalidDocument(e))}),ge.resolve(n)}getDocumentsMatchingQuery(e,t,n,r){let i=Xr();const o=t.path,s=new q(o.child("__id-9223372036854775808__")),a=this.docs.getIteratorFrom(s);for(;a.hasNext();){const{key:e,value:{document:s}}=a.getNext();if(!o.isPrefixOf(e.path))break;e.path.length>o.length+1||de(le(s),n)<=0||(r.has(s.key)||Kr(t,s))&&(i=i.insert(s.key,s.mutableCopy()))}return ge.resolve(i)}getAllFromCollectionGroup(e,t,n,r){g(9500)}ni(e,t){return ge.forEach(this.docs,e=>t(e))}newChangeBuffer(e){return new ja(this)}getSize(e){return ge.resolve(this.size)}}class ja extends ba{constructor(e){super(),this.Mr=e}applyChanges(e){const t=[];return this.changes.forEach((n,r)=>{r.isValidDocument()?t.push(this.Mr.addEntry(e,r)):this.Mr.removeEntry(n)}),ge.waitFor(t)}getFromCache(e,t){return this.Mr.getEntry(e,t)}getAllFromCache(e,t){return this.Mr.getEntries(e,t)}}class Fa{constructor(e){this.persistence=e,this.ri=new Jr(e=>Ar(e),Or),this.lastRemoteSnapshotVersion=ee.min(),this.highestTargetId=0,this.ii=0,this.si=new xa,this.targetCount=0,this.oi=oa._r()}forEachTarget(e,t){return this.ri.forEach((e,n)=>t(n)),ge.resolve()}getLastRemoteSnapshotVersion(e){return ge.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return ge.resolve(this.ii)}allocateTargetId(e){return this.highestTargetId=this.oi.next(),ge.resolve(this.highestTargetId)}setTargetsMetadata(e,t,n){return n&&(this.lastRemoteSnapshotVersion=n),t>this.ii&&(this.ii=t),ge.resolve()}lr(e){this.ri.set(e.target,e);const t=e.targetId;t>this.highestTargetId&&(this.oi=new oa(t),this.highestTargetId=t),e.sequenceNumber>this.ii&&(this.ii=e.sequenceNumber)}addTargetData(e,t){return this.lr(t),this.targetCount+=1,ge.resolve()}updateTargetData(e,t){return this.lr(t),ge.resolve()}removeTargetData(e,t){return this.ri.delete(t.target),this.si.Gr(t.targetId),this.targetCount-=1,ge.resolve()}removeTargets(e,t,n){let r=0;const i=[];return this.ri.forEach((o,s)=>{s.sequenceNumber<=t&&null===n.get(s.targetId)&&(this.ri.delete(o),i.push(this.removeMatchingKeysForTargetId(e,s.targetId)),r++)}),ge.waitFor(i).next(()=>r)}getTargetCount(e){return ge.resolve(this.targetCount)}getTargetData(e,t){const n=this.ri.get(t)||null;return ge.resolve(n)}addMatchingKeys(e,t,n){return this.si.$r(t,n),ge.resolve()}removeMatchingKeys(e,t,n){this.si.Qr(t,n);const r=this.persistence.referenceDelegate,i=[];return r&&t.forEach(t=>{i.push(r.markPotentiallyOrphaned(e,t))}),ge.waitFor(i)}removeMatchingKeysForTargetId(e,t){return this.si.Gr(t),ge.resolve()}getMatchingKeysForTargetId(e,t){const n=this.si.jr(t);return ge.resolve(n)}containsKey(e,t){return ge.resolve(this.si.containsKey(t))}}class Va{constructor(e,t){this._i={},this.overlays={},this.ai=new ke(0),this.ui=!1,this.ui=!0,this.ci=new Na,this.referenceDelegate=e(this),this.li=new Fa(this),this.indexManager=new Vs,this.remoteDocumentCache=function(e){return new La(e)}(e=>this.referenceDelegate.hi(e)),this.serializer=new Xo(t),this.Pi=new Ra(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.ui=!1,Promise.resolve()}get started(){return this.ui}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let t=this.overlays[e.toKey()];return t||(t=new ka,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let n=this._i[e.toKey()];return n||(n=new Ma(t,this.referenceDelegate),this._i[e.toKey()]=n),n}getGlobalsCache(){return this.ci}getTargetCache(){return this.li}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Pi}runTransaction(e,t,n){d("MemoryPersistence","Starting transaction:",e);const r=new Ua(this.ai.next());return this.referenceDelegate.Ti(),n(r).next(e=>this.referenceDelegate.Ii(r).next(()=>e)).toPromise().then(e=>(r.raiseOnCommittedEvent(),e))}Ei(e,t){return ge.or(Object.values(this._i).map(n=>()=>n.containsKey(e,t)))}}class Ua extends pe{constructor(e){super(),this.currentSequenceNumber=e}}class qa{constructor(e){this.persistence=e,this.Ri=new xa,this.Ai=null}static Vi(e){return new qa(e)}get di(){if(this.Ai)return this.Ai;throw g(60996)}addReference(e,t,n){return this.Ri.addReference(n,t),this.di.delete(n.toString()),ge.resolve()}removeReference(e,t,n){return this.Ri.removeReference(n,t),this.di.add(n.toString()),ge.resolve()}markPotentiallyOrphaned(e,t){return this.di.add(t.toString()),ge.resolve()}removeTarget(e,t){this.Ri.Gr(t.targetId).forEach(e=>this.di.add(e.toString()));const n=this.persistence.getTargetCache();return n.getMatchingKeysForTargetId(e,t.targetId).next(e=>{e.forEach(e=>this.di.add(e.toString()))}).next(()=>n.removeTargetData(e,t))}Ti(){this.Ai=new Set}Ii(e){const t=this.persistence.getRemoteDocumentCache().newChangeBuffer();return ge.forEach(this.di,n=>{const r=q.fromPath(n);return this.mi(e,r).next(e=>{e||t.removeEntry(r,ee.min())})}).next(()=>(this.Ai=null,t.apply(e)))}updateLimboDocument(e,t){return this.mi(e,t).next(e=>{e?this.di.delete(t.toString()):this.di.add(t.toString())})}hi(e){return 0}mi(e,t){return ge.or([()=>ge.resolve(this.Ri.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.Ei(e,t)])}}class Ba{constructor(e,t){this.persistence=e,this.fi=new Jr(e=>je(e.path),(e,t)=>e.isEqual(t)),this.garbageCollector=ga(this,t)}static Vi(e,t){return new Ba(e,t)}Ti(){}Ii(e){return ge.resolve()}forEachTarget(e,t){return this.persistence.getTargetCache().forEachTarget(e,t)}dr(e){const t=this.pr(e);return this.persistence.getTargetCache().getTargetCount(e).next(e=>t.next(t=>e+t))}pr(e){let t=0;return this.mr(e,e=>{t++}).next(()=>t)}mr(e,t){return ge.forEach(this.fi,(n,r)=>this.wr(e,n,r).next(e=>e?ge.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.ni(e,r=>this.wr(e,r,t).next(e=>{e||(n++,i.removeEntry(r,ee.min()))})).next(()=>i.apply(e)).next(()=>n)}markPotentiallyOrphaned(e,t){return this.fi.set(t,e.currentSequenceNumber),ge.resolve()}removeTarget(e,t){const n=t.withSequenceNumber(e.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(e,n)}addReference(e,t,n){return this.fi.set(n,e.currentSequenceNumber),ge.resolve()}removeReference(e,t,n){return this.fi.set(n,e.currentSequenceNumber),ge.resolve()}updateLimboDocument(e,t){return this.fi.set(t,e.currentSequenceNumber),ge.resolve()}hi(e){let t=e.key.toString().length;return e.isFoundDocument()&&(t+=Ln(e.data.value)),t}wr(e,t,n){return ge.or([()=>this.persistence.Ei(e,t),()=>this.persistence.getTargetCache().containsKey(e,t),()=>{const e=this.fi.get(t);return ge.resolve(void 0!==e&&e>n)}])}getCacheSize(e){return this.persistence.getRemoteDocumentCache().getSize(e)}}class za{constructor(e){this.serializer=e}k(e,t,n,r){const o=new ve("createOrUpgrade",t);n<1&&r>=1&&(function(e){e.createObjectStore(Be)}(e),function(e){e.createObjectStore(We,{keyPath:"userId"}),e.createObjectStore(Ge,{keyPath:Ke,autoIncrement:!0}).createIndex($e,He,{unique:!0}),e.createObjectStore(Xe)}(e),Wa(e),function(e){e.createObjectStore(qe)}(e));let s=ge.resolve();return n<3&&r>=3&&(0!==n&&(function(e){e.deleteObjectStore(lt),e.deleteObjectStore(at),e.deleteObjectStore(mt)}(e),Wa(e)),s=s.next(()=>function(e){const t=e.store(mt),n={highestTargetId:0,highestListenSequenceNumber:0,lastRemoteSnapshotVersion:ee.min().toTimestamp(),targetCount:0};return t.put(pt,n)}(o))),n<4&&r>=4&&(0!==n&&(s=s.next(()=>function(e,t){return t.store(Ge).H().next(n=>{e.deleteObjectStore(Ge),e.createObjectStore(Ge,{keyPath:Ke,autoIncrement:!0}).createIndex($e,He,{unique:!0});const r=t.store(Ge),i=n.map(e=>r.put(e));return ge.waitFor(i)})}(e,o))),s=s.next(()=>{!function(e){e.createObjectStore(vt,{keyPath:"clientId"})}(e)})),n<5&&r>=5&&(s=s.next(()=>this.gi(o))),n<6&&r>=6&&(s=s.next(()=>(function(e){e.createObjectStore(ot)}(e),this.pi(o)))),n<7&&r>=7&&(s=s.next(()=>this.yi(o))),n<8&&r>=8&&(s=s.next(()=>this.wi(e,o))),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.bi(o))),n<11&&r>=11&&(s=s.next(()=>{!function(e){e.createObjectStore(bt,{keyPath:"bundleId"})}(e),function(e){e.createObjectStore(_t,{keyPath:"name"})}(e)})),n<12&&r>=12&&(s=s.next(()=>{!function(e){const t=e.createObjectStore(kt,{keyPath:Nt});t.createIndex(xt,Dt,{unique:!1}),t.createIndex(Mt,Lt,{unique:!1})}(e)})),n<13&&r>=13&&(s=s.next(()=>function(e){const t=e.createObjectStore(Ze,{keyPath:et});t.createIndex(tt,nt),t.createIndex(rt,it)}(e)).next(()=>this.Si(e,o)).next(()=>e.deleteObjectStore(qe))),n<14&&r>=14&&(s=s.next(()=>this.Di(e,o))),n<15&&r>=15&&(s=s.next(()=>function(e){e.createObjectStore(wt,{keyPath:"indexId",autoIncrement:!0}).createIndex(It,"collectionGroup",{unique:!1}),e.createObjectStore(Et,{keyPath:Tt}).createIndex(St,At,{unique:!1}),e.createObjectStore(Ot,{keyPath:Pt}).createIndex(Ct,Rt,{unique:!1})}(e))),n<16&&r>=16&&(s=s.next(()=>{t.objectStore(Et).clear()}).next(()=>{t.objectStore(Ot).clear()})),n<17&&r>=17&&(s=s.next(()=>{!function(e){e.createObjectStore(jt,{keyPath:"name"})}(e)})),n<18&&r>=18&&i.isSafariOrWebkit()&&(s=s.next(()=>{t.objectStore(Et).clear()}).next(()=>{t.objectStore(Ot).clear()})),s}pi(e){let t=0;return e.store(qe).ee((e,n)=>{t+=Zs(n)}).next(()=>{const n={byteSize:t};return e.store(ot).put(st,n)})}gi(e){const t=e.store(We),n=e.store(Ge);return t.H().next(t=>ge.forEach(t,t=>{const r=IDBKeyRange.bound([t.userId,Ne],[t.userId,t.lastAcknowledgedBatchId]);return n.H($e,r).next(n=>ge.forEach(n,n=>{v(n.userId===t.userId,18650,"Cannot process batch from unexpected user",{batchId:n.batchId});const r=rs(this.serializer,n);return Xs(e,t.userId,r).next(()=>{})}))}))}yi(e){const t=e.store(lt),n=e.store(qe);return e.store(mt).get(pt).next(e=>{const r=[];return n.ee((n,i)=>{const o=new F(n),s=function(e){return[0,je(e)]}(o);r.push(t.get(s).next(n=>n?ge.resolve():(n=>t.put({targetId:0,path:je(n),sequenceNumber:e.highestListenSequenceNumber}))(o)))}).next(()=>ge.waitFor(r))})}wi(e,t){e.createObjectStore(gt,{keyPath:yt});const n=t.store(gt),r=new Us,i=e=>{if(r.add(e)){const t=e.lastSegment(),r=e.popLast();return n.put({collectionId:t,parent:je(r)})}};return t.store(qe).ee({Y:!0},(e,t)=>{const n=new F(e);return i(n.popLast())}).next(()=>t.store(Xe).ee({Y:!0},([e,t,n],r)=>{const o=Ue(t);return i(o.popLast())}))}bi(e){const t=e.store(at);return t.ee((e,n)=>{const r=is(n),i=os(this.serializer,r);return t.put(i)})}Si(e,t){const n=t.store(qe),r=[];return n.ee((e,n)=>{const i=t.store(Ze),o=function(e){return e.document?new q(F.fromString(e.document.name).popFirst(5)):e.noDocument?q.fromSegments(e.noDocument.path):e.unknownDocument?q.fromSegments(e.unknownDocument.path):g(36783)}(n).path.toArray(),s={prefixPath:o.slice(0,o.length-2),collectionGroup:o[o.length-2],documentId:o[o.length-1],readTime:n.readTime||[0,0],unknownDocument:n.unknownDocument,noDocument:n.noDocument,document:n.document,hasCommittedMutations:!!n.hasCommittedMutations};r.push(i.put(s))}).next(()=>ge.waitFor(r))}Di(e,t){const n=t.store(Ge),r=wa(this.serializer),i=new Va(qa.Vi,this.serializer.yt);return n.H().next(e=>{const n=new Map;return e.forEach(e=>{let t=n.get(e.userId)??ai();rs(this.serializer,e).keys().forEach(e=>t=t.add(e)),n.set(e.userId,t)}),ge.forEach(n,(e,n)=>{const o=new c(n),s=fs.wt(this.serializer,o),a=i.getIndexManager(o),u=ea.wt(o,this.serializer,a,i.referenceDelegate);return new Ca(r,u,s,a).recalculateAndSaveOverlaysForDocumentKeys(new Kt(t,ke.ce),e).next()})})}}function Wa(e){e.createObjectStore(lt,{keyPath:ht}).createIndex(dt,ft,{unique:!0}),e.createObjectStore(at,{keyPath:"targetId"}).createIndex(ct,ut,{unique:!0}),e.createObjectStore(mt)}const Ga="IndexedDbPersistence",Ka=18e5,$a=5e3,Ha="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.",Qa="main";class Ja{constructor(e,t,n,r,i,o,s,a,c,u,l=18){if(this.allowTabSynchronization=e,this.persistenceKey=t,this.clientId=n,this.Ci=i,this.window=o,this.document=s,this.Fi=c,this.Mi=u,this.xi=l,this.ai=null,this.ui=!1,this.isPrimary=!1,this.networkEnabled=!0,this.Oi=null,this.inForeground=!1,this.Ni=null,this.Bi=null,this.Li=Number.NEGATIVE_INFINITY,this.ki=e=>Promise.resolve(),!Ja.v())throw new w(_.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");this.referenceDelegate=new ya(this,r),this.Ki=t+Qa,this.serializer=new Xo(a),this.qi=new be(this.Ki,this.xi,new za(this.serializer)),this.ci=new ms,this.li=new sa(this.referenceDelegate,this.serializer),this.remoteDocumentCache=wa(this.serializer),this.Pi=new ls,this.window&&this.window.localStorage?this.Ui=this.window.localStorage:(this.Ui=null,!1===u&&f(Ga,"LocalStorage is unavailable. As a result, persistence may not work reliably. In particular enablePersistence() could fail immediately after refreshing the page."))}start(){return this.$i().then(()=>{if(!this.isPrimary&&!this.allowTabSynchronization)throw new w(_.FAILED_PRECONDITION,Ha);return this.Wi(),this.Qi(),this.Gi(),this.runTransaction("getHighestListenSequenceNumber","readonly",e=>this.li.getHighestSequenceNumber(e))}).then(e=>{this.ai=new ke(e,this.Fi)}).then(()=>{this.ui=!0}).catch(e=>(this.qi&&this.qi.close(),Promise.reject(e)))}zi(e){return this.ki=async t=>{if(this.started)return e(t)},e(this.isPrimary)}setDatabaseDeletedListener(e){this.qi.q(async t=>{null===t.newVersion&&await e()})}setNetworkEnabled(e){this.networkEnabled!==e&&(this.networkEnabled=e,this.Ci.enqueueAndForget(async()=>{this.started&&await this.$i()}))}$i(){return this.runTransaction("updateClientMetadataAndTryBecomePrimary","readwrite",e=>Xa(e).put({clientId:this.clientId,updateTimeMs:Date.now(),networkEnabled:this.networkEnabled,inForeground:this.inForeground}).next(()=>{if(this.isPrimary)return this.ji(e).next(e=>{e||(this.isPrimary=!1,this.Ci.enqueueRetryable(()=>this.ki(!1)))})}).next(()=>this.Hi(e)).next(t=>this.isPrimary&&!t?this.Ji(e).next(()=>!1):!!t&&this.Zi(e).next(()=>!0))).catch(e=>{if(Ee(e))return d(Ga,"Failed to extend owner lease: ",e),this.isPrimary;if(!this.allowTabSynchronization)throw e;return d(Ga,"Releasing owner lease after error during lease refresh",e),!1}).then(e=>{this.isPrimary!==e&&this.Ci.enqueueRetryable(()=>this.ki(e)),this.isPrimary=e})}ji(e){return Ya(e).get(ze).next(e=>ge.resolve(this.Xi(e)))}Yi(e){return Xa(e).delete(this.clientId)}async es(){if(this.isPrimary&&!this.ts(this.Li,Ka)){this.Li=Date.now();const e=await this.runTransaction("maybeGarbageCollectMultiClientState","readwrite-primary",e=>{const t=$t(e,vt);return t.H().next(e=>{const n=this.ns(e,Ka),r=e.filter(e=>-1===n.indexOf(e));return ge.forEach(r,e=>t.delete(e.clientId)).next(()=>r)})}).catch(()=>[]);if(this.Ui)for(const t of e)this.Ui.removeItem(this.rs(t.clientId))}}Gi(){this.Bi=this.Ci.enqueueAfterDelay("client_metadata_refresh",4e3,()=>this.$i().then(()=>this.es()).then(()=>this.Gi()))}Xi(e){return!!e&&e.ownerId===this.clientId}Hi(e){return this.Mi?ge.resolve(!0):Ya(e).get(ze).next(t=>{if(null!==t&&this.ts(t.leaseTimestampMs,$a)&&!this.ss(t.ownerId)){if(this.Xi(t)&&this.networkEnabled)return!0;if(!this.Xi(t)){if(!t.allowTabSynchronization)throw new w(_.FAILED_PRECONDITION,Ha);return!1}}return!(!this.networkEnabled||!this.inForeground)||Xa(e).H().next(e=>void 0===this.ns(e,$a).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&&d(Ga,`Client ${e?"is":"is not"} eligible for a primary lease.`),e))}async shutdown(){this.ui=!1,this._s(),this.Bi&&(this.Bi.cancel(),this.Bi=null),this.us(),this.cs(),await this.qi.runTransaction("shutdown","readwrite",[Be,vt],e=>{const t=new Kt(e,ke.ce);return this.Ji(t).next(()=>this.Yi(t))}),this.qi.close(),this.ls()}ns(e,t){return e.filter(e=>this.ts(e.updateTimeMs,t)&&!this.ss(e.clientId))}hs(){return this.runTransaction("getActiveClients","readonly",e=>Xa(e).H().next(e=>this.ns(e,Ka).map(e=>e.clientId)))}get started(){return this.ui}getGlobalsCache(){return this.ci}getMutationQueue(e,t){return ea.wt(e,this.serializer,t,this.referenceDelegate)}getTargetCache(){return this.li}getRemoteDocumentCache(){return this.remoteDocumentCache}getIndexManager(e){return new zs(e,this.serializer.yt.databaseId)}getDocumentOverlayCache(e){return fs.wt(this.serializer,e)}getBundleCache(){return this.Pi}runTransaction(e,t,n){d(Ga,"Starting transaction:",e);const r="readonly"===t?"readonly":"readwrite",i=function(e){return 18===e?Gt:17===e?Wt:16===e?zt:15===e?Bt:14===e?qt:13===e?Ut:12===e?Vt:11===e?Ft:void g(60245)}(this.xi);let o;return this.qi.runTransaction(e,r,i,r=>(o=new Kt(r,this.ai?this.ai.next():ke.ce),"readwrite-primary"===t?this.ji(o).next(e=>!!e||this.Hi(o)).next(t=>{if(!t)throw f(`Failed to obtain primary lease for action '${e}'.`),this.isPrimary=!1,this.Ci.enqueueRetryable(()=>this.ki(!1)),new w(_.FAILED_PRECONDITION,fe);return n(o)}).next(e=>this.Zi(o).next(()=>e)):this.Ps(o).next(()=>n(o)))).then(e=>(o.raiseOnCommittedEvent(),e))}Ps(e){return Ya(e).get(ze).next(e=>{if(null!==e&&this.ts(e.leaseTimestampMs,$a)&&!this.ss(e.ownerId)&&!this.Xi(e)&&!(this.Mi||this.allowTabSynchronization&&e.allowTabSynchronization))throw new w(_.FAILED_PRECONDITION,Ha)})}Zi(e){const t={ownerId:this.clientId,allowTabSynchronization:this.allowTabSynchronization,leaseTimestampMs:Date.now()};return Ya(e).put(ze,t)}static v(){return be.v()}Ji(e){const t=Ya(e);return t.get(ze).next(e=>this.Xi(e)?(d(Ga,"Releasing primary lease."),t.delete(ze)):ge.resolve())}ts(e,t){const n=Date.now();return!(e<n-t||e>n&&(f(`Detected an update time that is in the future: ${e} > ${n}`),1))}Wi(){null!==this.document&&"function"==typeof this.document.addEventListener&&(this.Ni=()=>{this.Ci.enqueueAndForget(()=>(this.inForeground="visible"===this.document.visibilityState,this.$i()))},this.document.addEventListener("visibilitychange",this.Ni),this.inForeground="visible"===this.document.visibilityState)}us(){this.Ni&&(this.document.removeEventListener("visibilitychange",this.Ni),this.Ni=null)}Qi(){"function"==typeof this.window?.addEventListener&&(this.Oi=()=>{this._s();const e=/(?:Version|Mobile)\/1[456]/;i.isSafari()&&(navigator.appVersion.match(e)||navigator.userAgent.match(e))&&this.Ci.enterRestrictedMode(!0),this.Ci.enqueueAndForget(()=>this.shutdown())},this.window.addEventListener("pagehide",this.Oi))}cs(){this.Oi&&(this.window.removeEventListener("pagehide",this.Oi),this.Oi=null)}ss(e){try{const t=null!==this.Ui?.getItem(this.rs(e));return d(Ga,`Client '${e}' ${t?"is":"is not"} zombied in LocalStorage`),t}catch(e){return f(Ga,"Failed to get zombied client id.",e),!1}}_s(){if(this.Ui)try{this.Ui.setItem(this.rs(this.clientId),String(Date.now()))}catch(e){f("Failed to set zombie client id.",e)}}ls(){if(this.Ui)try{this.Ui.removeItem(this.rs(this.clientId))}catch(e){}}rs(e){return`firestore_zombie_${this.persistenceKey}_${e}`}}function Ya(e){return $t(e,Be)}function Xa(e){return $t(e,vt)}function Za(e,t){let n=e.projectId;return e.isDefaultDatabase||(n+="."+e.database),"firestore/"+t+"/"+n+"/"}class ec{constructor(e,t,n,r){this.targetId=e,this.fromCache=t,this.Ts=n,this.Is=r}static Es(e,t){let n=ai(),r=ai();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 ec(e,t.fromCache,n,r)}}class tc{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(e){this._documentReadCount+=e}}class nc{constructor(){this.Rs=!1,this.As=!1,this.Vs=100,this.ds=i.isSafari()?8:_e(i.getUA())>0?6:4}initialize(e,t){this.fs=e,this.indexManager=t,this.Rs=!0}getDocumentsMatchingQuery(e,t,n,r){const i={result:null};return this.gs(e,t).next(e=>{i.result=e}).next(()=>{if(!i.result)return this.ps(e,t,r,n).next(e=>{i.result=e})}).next(()=>{if(i.result)return;const n=new tc;return this.ys(e,t,n).next(r=>{if(i.result=r,this.As)return this.ws(e,t,n,r.size)})}).next(()=>i.result)}ws(e,t,n,r){return n.documentReadCount<this.Vs?(h()<=s.LogLevel.DEBUG&&d("QueryEngine","SDK will not create cache indexes for query:",Gr(t),"since it only creates cache indexes for collection contains","more than or equal to",this.Vs,"documents"),ge.resolve()):(h()<=s.LogLevel.DEBUG&&d("QueryEngine","Query:",Gr(t),"scans",n.documentReadCount,"local documents and returns",r,"documents as results."),n.documentReadCount>this.ds*r?(h()<=s.LogLevel.DEBUG&&d("QueryEngine","The SDK decides to create cache indexes for query:",Gr(t),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(e,Vr(t))):ge.resolve())}gs(e,t){if(Mr(t))return ge.resolve(null);let n=Vr(t);return this.indexManager.getIndexType(e,n).next(r=>0===r?null:(null!==t.limit&&1===r&&(t=Br(t,null,"F"),n=Vr(t)),this.indexManager.getDocumentsMatchingTarget(e,n).next(r=>{const i=ai(...r);return this.fs.getDocuments(e,i).next(r=>this.indexManager.getMinOffset(e,n).next(n=>{const o=this.bs(t,r);return this.Ss(t,o,i,n.readTime)?this.gs(e,Br(t,null,"F")):this.Ds(e,o,t,n)}))})))}ps(e,t,n,r){return Mr(t)||r.isEqual(ee.min())?ge.resolve(null):this.fs.getDocuments(e,n).next(i=>{const o=this.bs(t,i);return this.Ss(t,o,n,r)?ge.resolve(null):(h()<=s.LogLevel.DEBUG&&d("QueryEngine","Re-using previous result from %s to execute query: %s",r.toString(),Gr(t)),this.Ds(e,o,t,ue(r,te)).next(e=>e))})}bs(e,t){let n=new tn(Hr(e));return t.forEach((t,r)=>{Kr(e,r)&&(n=n.add(r))}),n}Ss(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)}ys(e,t,n){return h()<=s.LogLevel.DEBUG&&d("QueryEngine","Using full collection scan to execute query:",Gr(t)),this.fs.getDocumentsMatchingQuery(e,t,he.min(),n)}Ds(e,t,n,r){return this.fs.getDocumentsMatchingQuery(e,n,r).next(e=>(t.forEach(t=>{e=e.insert(t.key,t)}),e))}}const rc="LocalStore";class ic{constructor(e,t,n,r){this.persistence=e,this.Cs=t,this.serializer=r,this.vs=new Xt(k),this.Fs=new Jr(e=>Ar(e),Or),this.Ms=new Map,this.xs=e.getRemoteDocumentCache(),this.li=e.getTargetCache(),this.Pi=e.getBundleCache(),this.Os(n)}Os(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new Ca(this.xs,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.xs.setIndexManager(this.indexManager),this.Cs.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction("Collect garbage","readwrite-primary",t=>e.collect(t,this.vs))}}function oc(e,t,n,r){return new ic(e,t,n,r)}async function sc(e,t){const n=b(e);return await n.persistence.runTransaction("Handle user change","readonly",e=>{let r;return n.mutationQueue.getAllMutationBatches(e).next(i=>(r=i,n.Os(t),n.mutationQueue.getAllMutationBatches(e))).next(t=>{const i=[],o=[];let s=ai();for(const e of r){i.push(e.batchId);for(const t of e.mutations)s=s.add(t.key)}for(const e of t){o.push(e.batchId);for(const t of e.mutations)s=s.add(t.key)}return n.localDocuments.getDocuments(e,s).next(e=>({Ns:e,removedBatchIds:i,addedBatchIds:o}))})})}function ac(e){const t=b(e);return t.persistence.runTransaction("Get last remote snapshot version","readonly",e=>t.li.getLastRemoteSnapshotVersion(e))}function cc(e,t,n){let r=ai(),i=ai();return n.forEach(e=>r=r.add(e)),t.getEntries(e,r).next(e=>{let r=Xr();return n.forEach((n,o)=>{const s=e.get(n);o.isFoundDocument()!==s.isFoundDocument()&&(i=i.add(n)),o.isNoDocument()&&o.version.isEqual(ee.min())?(t.removeEntry(n,o.readTime),r=r.insert(n,o)):!s.isValidDocument()||o.version.compareTo(s.version)>0||0===o.version.compareTo(s.version)&&s.hasPendingWrites?(t.addEntry(o),r=r.insert(n,o)):d(rc,"Ignoring outdated watch update for ",n,". Current version:",s.version," Watch version:",o.version)}),{Bs:r,Ls:i}})}function uc(e,t){const n=b(e);return n.persistence.runTransaction("Get next mutation batch","readonly",e=>(void 0===t&&(t=Ne),n.mutationQueue.getNextMutationBatchAfterBatchId(e,t)))}function lc(e,t){const n=b(e);return n.persistence.runTransaction("Allocate target","readwrite",e=>{let r;return n.li.getTargetData(e,t).next(i=>i?(r=i,ge.resolve(r)):n.li.allocateTargetId(e).next(i=>(r=new Yo(t,i,"TargetPurposeListen",e.currentSequenceNumber),n.li.addTargetData(e,r).next(()=>r))))}).then(e=>{const r=n.vs.get(e.targetId);return(null===r||e.snapshotVersion.compareTo(r.snapshotVersion)>0)&&(n.vs=n.vs.insert(e.targetId,e),n.Fs.set(t,e.targetId)),e})}async function hc(e,t,n){const r=b(e),i=r.vs.get(t),o=n?"readwrite":"readwrite-primary";try{n||await r.persistence.runTransaction("Release target",o,e=>r.persistence.referenceDelegate.removeTarget(e,i))}catch(e){if(!Ee(e))throw e;d(rc,`Failed to update sequence numbers for target ${t}: ${e}`)}r.vs=r.vs.remove(t),r.Fs.delete(i.target)}function dc(e,t,n){const r=b(e);let i=ee.min(),o=ai();return r.persistence.runTransaction("Execute query","readwrite",e=>function(e,t,n){const r=b(e),i=r.Fs.get(n);return void 0!==i?ge.resolve(r.vs.get(i)):r.li.getTargetData(t,n)}(r,e,Vr(t)).next(t=>{if(t)return i=t.lastLimboFreeSnapshotVersion,r.li.getMatchingKeysForTargetId(e,t.targetId).next(e=>{o=e})}).next(()=>r.Cs.getDocumentsMatchingQuery(e,t,n?i:ee.min(),n?o:ai())).next(e=>(mc(r,$r(t),e),{documents:e,ks:o})))}function fc(e,t){const n=b(e),r=b(n.li),i=n.vs.get(t);return i?Promise.resolve(i.target):n.persistence.runTransaction("Get target data","readonly",e=>r.At(e,t).next(e=>e?e.target:null))}function pc(e,t){const n=b(e),r=n.Ms.get(t)||ee.min();return n.persistence.runTransaction("Get new document changes","readonly",e=>n.xs.getAllFromCollectionGroup(e,t,ue(r,te),Number.MAX_SAFE_INTEGER)).then(e=>(mc(n,t,e),e))}function mc(e,t,n){let r=e.Ms.get(t)||ee.min();n.forEach((e,t)=>{t.readTime.compareTo(r)>0&&(r=t.readTime)}),e.Ms.set(t,r)}async function gc(e,t,n=ai()){const r=await lc(e,Vr(ss(t.bundledQuery))),i=b(e);return i.persistence.runTransaction("Save named query","readwrite",e=>{const o=Io(t.readTime);if(r.snapshotVersion.compareTo(o)>=0)return i.Pi.saveNamedQuery(e,t);const s=r.withResumeToken(an.EMPTY_BYTE_STRING,o);return i.vs=i.vs.insert(s.targetId,s),i.li.updateTargetData(e,s).next(()=>i.li.removeMatchingKeysForTargetId(e,r.targetId)).next(()=>i.li.addMatchingKeys(e,n,r.targetId)).next(()=>i.Pi.saveNamedQuery(e,t))})}const yc="firestore_clients";function vc(e,t){return`${yc}_${e}_${t}`}const bc="firestore_mutations";function _c(e,t,n){let r=`${bc}_${e}_${n}`;return t.isAuthenticated()&&(r+=`_${t.uid}`),r}const wc="firestore_targets";function Ic(e,t){return`${wc}_${e}_${t}`}const Ec="SharedClientState";class Tc{constructor(e,t,n,r){this.user=e,this.batchId=t,this.state=n,this.error=r}static $s(e,t,n){const r=JSON.parse(n);let i,o="object"==typeof r&&-1!==["pending","acknowledged","rejected"].indexOf(r.state)&&(void 0===r.error||"object"==typeof r.error);return o&&r.error&&(o="string"==typeof r.error.message&&"string"==typeof r.error.code,o&&(i=new w(r.error.code,r.error.message))),o?new Tc(e,t,r.state,i):(f(Ec,`Failed to parse mutation state for ID '${t}': ${n}`),null)}Ws(){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 Sc{constructor(e,t,n){this.targetId=e,this.state=t,this.error=n}static $s(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 w(n.error.code,n.error.message))),i?new Sc(e,n.state,r):(f(Ec,`Failed to parse target state for ID '${e}': ${t}`),null)}Ws(){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 Ac{constructor(e,t){this.clientId=e,this.activeTargetIds=t}static $s(e,t){const n=JSON.parse(t);let r="object"==typeof n&&n.activeTargetIds instanceof Array,i=ui();for(let e=0;r&&e<n.activeTargetIds.length;++e)r=Me(n.activeTargetIds[e]),i=i.add(n.activeTargetIds[e]);return r?new Ac(e,i):(f(Ec,`Failed to parse client data for instance '${e}': ${t}`),null)}}class Oc{constructor(e,t){this.clientId=e,this.onlineState=t}static $s(e){const t=JSON.parse(e);return"object"==typeof t&&-1!==["Unknown","Online","Offline"].indexOf(t.onlineState)&&"string"==typeof t.clientId?new Oc(t.clientId,t.onlineState):(f(Ec,`Failed to parse online state: ${e}`),null)}}class Pc{constructor(){this.activeTargetIds=ui()}Qs(e){this.activeTargetIds=this.activeTargetIds.add(e)}Gs(e){this.activeTargetIds=this.activeTargetIds.delete(e)}Ws(){const e={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(e)}}class Cc{constructor(e,t,n,r,i){this.window=e,this.Ci=t,this.persistenceKey=n,this.zs=r,this.syncEngine=null,this.onlineStateHandler=null,this.sequenceNumberHandler=null,this.js=this.Hs.bind(this),this.Js=new Xt(k),this.started=!1,this.Zs=[];const o=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");this.storage=this.window.localStorage,this.currentUser=i,this.Xs=vc(this.persistenceKey,this.zs),this.Ys=function(e){return`firestore_sequence_number_${e}`}(this.persistenceKey),this.Js=this.Js.insert(this.zs,new Pc),this.eo=new RegExp(`^${yc}_${o}_([^_]*)$`),this.no=new RegExp(`^${bc}_${o}_(\\d+)(?:_(.*))?$`),this.ro=new RegExp(`^${wc}_${o}_(\\d+)$`),this.io=function(e){return`firestore_online_state_${e}`}(this.persistenceKey),this.so=function(e){return`firestore_bundle_loaded_v2_${e}`}(this.persistenceKey),this.window.addEventListener("storage",this.js)}static v(e){return!(!e||!e.localStorage)}async start(){const e=await this.syncEngine.hs();for(const t of e){if(t===this.zs)continue;const e=this.getItem(vc(this.persistenceKey,t));if(e){const n=Ac.$s(t,e);n&&(this.Js=this.Js.insert(n.clientId,n))}}this.oo();const t=this.storage.getItem(this.io);if(t){const e=this._o(t);e&&this.ao(e)}for(const e of this.Zs)this.Hs(e);this.Zs=[],this.window.addEventListener("pagehide",()=>this.shutdown()),this.started=!0}writeSequenceNumber(e){this.setItem(this.Ys,JSON.stringify(e))}getAllActiveQueryTargets(){return this.uo(this.Js)}isActiveQueryTarget(e){let t=!1;return this.Js.forEach((n,r)=>{r.activeTargetIds.has(e)&&(t=!0)}),t}addPendingMutation(e){this.co(e,"pending")}updateMutationState(e,t,n){this.co(e,t,n),this.lo(e)}addLocalQueryTarget(e,t=!0){let n="not-current";if(this.isActiveQueryTarget(e)){const t=this.storage.getItem(Ic(this.persistenceKey,e));if(t){const r=Sc.$s(e,t);r&&(n=r.state)}}return t&&this.ho.Qs(e),this.oo(),n}removeLocalQueryTarget(e){this.ho.Gs(e),this.oo()}isLocalQueryTarget(e){return this.ho.activeTargetIds.has(e)}clearQueryState(e){this.removeItem(Ic(this.persistenceKey,e))}updateQueryState(e,t,n){this.Po(e,t,n)}handleUserChange(e,t,n){t.forEach(e=>{this.lo(e)}),this.currentUser=e,n.forEach(e=>{this.addPendingMutation(e)})}setOnlineState(e){this.To(e)}notifyBundleLoaded(e){this.Io(e)}shutdown(){this.started&&(this.window.removeEventListener("storage",this.js),this.removeItem(this.Xs),this.started=!1)}getItem(e){const t=this.storage.getItem(e);return d(Ec,"READ",e,t),t}setItem(e,t){d(Ec,"SET",e,t),this.storage.setItem(e,t)}removeItem(e){d(Ec,"REMOVE",e),this.storage.removeItem(e)}Hs(e){const t=e;if(t.storageArea===this.storage){if(d(Ec,"EVENT",t.key,t.newValue),t.key===this.Xs)return void f("Received WebStorage notification for local change. Another client might have garbage-collected our state");this.Ci.enqueueRetryable(async()=>{if(this.started){if(null!==t.key)if(this.eo.test(t.key)){if(null==t.newValue){const e=this.Eo(t.key);return this.Ro(e,null)}{const e=this.Ao(t.key,t.newValue);if(e)return this.Ro(e.clientId,e)}}else if(this.no.test(t.key)){if(null!==t.newValue){const e=this.Vo(t.key,t.newValue);if(e)return this.mo(e)}}else if(this.ro.test(t.key)){if(null!==t.newValue){const e=this.fo(t.key,t.newValue);if(e)return this.po(e)}}else if(t.key===this.io){if(null!==t.newValue){const e=this._o(t.newValue);if(e)return this.ao(e)}}else if(t.key===this.Ys){const e=function(e){let t=ke.ce;if(null!=e)try{const n=JSON.parse(e);v("number"==typeof n,30636,{yo:e}),t=n}catch(e){f(Ec,"Failed to read sequence number from WebStorage",e)}return t}(t.newValue);e!==ke.ce&&this.sequenceNumberHandler(e)}else if(t.key===this.so){const e=this.wo(t.newValue);await Promise.all(e.map(e=>this.syncEngine.bo(e)))}}else this.Zs.push(t)})}}get ho(){return this.Js.get(this.zs)}oo(){this.setItem(this.Xs,this.ho.Ws())}co(e,t,n){const r=new Tc(this.currentUser,e,t,n),i=_c(this.persistenceKey,this.currentUser,e);this.setItem(i,r.Ws())}lo(e){const t=_c(this.persistenceKey,this.currentUser,e);this.removeItem(t)}To(e){const t={clientId:this.zs,onlineState:e};this.storage.setItem(this.io,JSON.stringify(t))}Po(e,t,n){const r=Ic(this.persistenceKey,e),i=new Sc(e,t,n);this.setItem(r,i.Ws())}Io(e){const t=JSON.stringify(Array.from(e));this.setItem(this.so,t)}Eo(e){const t=this.eo.exec(e);return t?t[1]:null}Ao(e,t){const n=this.Eo(e);return Ac.$s(n,t)}Vo(e,t){const n=this.no.exec(e),r=Number(n[1]),i=void 0!==n[2]?n[2]:null;return Tc.$s(new c(i),r,t)}fo(e,t){const n=this.ro.exec(e),r=Number(n[1]);return Sc.$s(r,t)}_o(e){return Oc.$s(e)}wo(e){return JSON.parse(e)}async mo(e){if(e.user.uid===this.currentUser.uid)return this.syncEngine.So(e.batchId,e.state,e.error);d(Ec,`Ignoring mutation for non-active user ${e.user.uid}`)}po(e){return this.syncEngine.Do(e.targetId,e.state,e.error)}Ro(e,t){const n=t?this.Js.insert(e,t):this.Js.remove(e),r=this.uo(this.Js),i=this.uo(n),o=[],s=[];return i.forEach(e=>{r.has(e)||o.push(e)}),r.forEach(e=>{i.has(e)||s.push(e)}),this.syncEngine.Co(o,s).then(()=>{this.Js=n})}ao(e){this.Js.get(e.clientId)&&this.onlineStateHandler(e.onlineState)}uo(e){let t=ui();return e.forEach((e,n)=>{t=t.unionWith(n.activeTargetIds)}),t}}class Rc{constructor(){this.vo=new Pc,this.Fo={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,t,n){}addLocalQueryTarget(e,t=!0){return t&&this.vo.Qs(e),this.Fo[e]||"not-current"}updateQueryState(e,t,n){this.Fo[e]=t}removeLocalQueryTarget(e){this.vo.Gs(e)}isLocalQueryTarget(e){return this.vo.activeTargetIds.has(e)}clearQueryState(e){delete this.Fo[e]}getAllActiveQueryTargets(){return this.vo.activeTargetIds}isActiveQueryTarget(e){return this.vo.activeTargetIds.has(e)}start(){return this.vo=new Pc,Promise.resolve()}handleUserChange(e,t,n){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}}class kc{Mo(e){}shutdown(){}}const Nc="ConnectivityMonitor";class xc{constructor(){this.xo=()=>this.Oo(),this.No=()=>this.Bo(),this.Lo=[],this.ko()}Mo(e){this.Lo.push(e)}shutdown(){window.removeEventListener("online",this.xo),window.removeEventListener("offline",this.No)}ko(){window.addEventListener("online",this.xo),window.addEventListener("offline",this.No)}Oo(){d(Nc,"Network connectivity changed: AVAILABLE");for(const e of this.Lo)e(0)}Bo(){d(Nc,"Network connectivity changed: UNAVAILABLE");for(const e of this.Lo)e(1)}static v(){return"undefined"!=typeof window&&void 0!==window.addEventListener&&void 0!==window.removeEventListener}}let Dc=null;function Mc(){return null===Dc?Dc=268435456+Math.round(2147483648*Math.random()):Dc++,"0x"+Dc.toString(16)}const Lc="RestConnection",jc={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery",ExecutePipeline:"executePipeline"};class Fc{get Ko(){return!1}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.qo=t+"://"+e.host,this.Uo=`projects/${n}/databases/${r}`,this.$o=this.databaseId.database===_n?`project_id=${n}`:`project_id=${n}&database_id=${r}`}Wo(e,t,n,r,o){const s=Mc(),a=this.Qo(e,t.toUriEncodedString());d(Lc,`Sending RPC '${e}' ${s}:`,a,n);const c={"google-cloud-resource-prefix":this.Uo,"x-goog-request-params":this.$o};this.Go(c,r,o);const{host:u}=new URL(a),l=i.isCloudWorkstation(u);return this.zo(e,a,c,n,l).then(t=>(d(Lc,`Received RPC '${e}' ${s}: `,t),t),t=>{throw p(Lc,`RPC '${e}' ${s} failed with error: `,t,"url: ",a,"request:",n),t})}jo(e,t,n,r,i,o){return this.Wo(e,t,n,r,i)}Go(e,t,n){e["X-Goog-Api-Client"]="gl-js/ fire/"+u,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)}Qo(e,t){const n=jc[e];let r=`${this.qo}/v1/${t}:${n}`;return this.databaseInfo.apiKey&&(r=`${r}?key=${encodeURIComponent(this.databaseInfo.apiKey)}`),r}terminate(){}}class Vc{constructor(e){this.Ho=e.Ho,this.Jo=e.Jo}Zo(e){this.Xo=e}Yo(e){this.e_=e}t_(e){this.n_=e}onMessage(e){this.r_=e}close(){this.Jo()}send(e){this.Ho(e)}i_(){this.Xo()}s_(){this.e_()}o_(e){this.n_(e)}__(e){this.r_(e)}}const Uc="WebChannelConnection",qc=(e,t,n)=>{e.listen(t,e=>{try{n(e)}catch(e){setTimeout(()=>{throw e},0)}})};class Bc extends Fc{constructor(e){super(e),this.a_=[],this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}static u_(){if(!Bc.c_){const e=a.getStatEventTarget();qc(e,a.Event.STAT_EVENT,e=>{e.stat===a.Stat.PROXY?d(Uc,"STAT_EVENT: detected buffering proxy"):e.stat===a.Stat.NOPROXY&&d(Uc,"STAT_EVENT: detected no buffering proxy")}),Bc.c_=!0}}zo(e,t,n,r,i){const o=Mc();return new Promise((i,s)=>{const c=new a.XhrIo;c.setWithCredentials(!0),c.listenOnce(a.EventType.COMPLETE,()=>{try{switch(c.getLastErrorCode()){case a.ErrorCode.NO_ERROR:const t=c.getResponseJson();d(Uc,`XHR for RPC '${e}' ${o} received:`,JSON.stringify(t)),i(t);break;case a.ErrorCode.TIMEOUT:d(Uc,`RPC '${e}' ${o} timed out`),s(new w(_.DEADLINE_EXCEEDED,"Request time out"));break;case a.ErrorCode.HTTP_ERROR:const n=c.getStatus();if(d(Uc,`RPC '${e}' ${o} failed with status:`,n,"response text:",c.getResponseText()),n>0){let e=c.getResponseJson();Array.isArray(e)&&(e=e[0]);const t=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);s(new w(e,t.message))}else s(new w(_.UNKNOWN,"Server responded with status "+c.getStatus()))}else s(new w(_.UNAVAILABLE,"Connection failed."));break;default:g(9055,{l_:e,streamId:o,h_:c.getLastErrorCode(),P_:c.getLastError()})}}finally{d(Uc,`RPC '${e}' ${o} completed.`)}});const u=JSON.stringify(r);d(Uc,`RPC '${e}' ${o} sending request:`,r),c.send(t,"POST",u,n,15)})}T_(e,t,n){const r=Mc(),i=[this.qo,"/","google.firestore.v1.Firestore","/",e,"/channel"],o=this.createWebChannelTransport(),s={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},c=this.longPollingOptions.timeoutSeconds;void 0!==c&&(s.longPollingTimeout=Math.round(1e3*c)),this.useFetchStreams&&(s.useFetchStreams=!0),this.Go(s.initMessageHeaders,t,n),s.encodeInitMessageHeaders=!0;const u=i.join("");d(Uc,`Creating RPC '${e}' stream ${r}: ${u}`,s);const l=o.createWebChannel(u,s);this.I_(l);let h=!1,f=!1;const m=new Vc({Ho:t=>{f?d(Uc,`Not sending because RPC '${e}' stream ${r} is closed:`,t):(h||(d(Uc,`Opening RPC '${e}' stream ${r} transport.`),l.open(),h=!0),d(Uc,`RPC '${e}' stream ${r} sending:`,t),l.send(t))},Jo:()=>l.close()});return qc(l,a.WebChannel.EventType.OPEN,()=>{f||(d(Uc,`RPC '${e}' stream ${r} transport opened.`),m.i_())}),qc(l,a.WebChannel.EventType.CLOSE,()=>{f||(f=!0,d(Uc,`RPC '${e}' stream ${r} transport closed`),m.o_(),this.E_(l))}),qc(l,a.WebChannel.EventType.ERROR,t=>{f||(f=!0,p(Uc,`RPC '${e}' stream ${r} transport errored. Name:`,t.name,"Message:",t.message),m.o_(new w(_.UNAVAILABLE,"The operation could not be completed")))}),qc(l,a.WebChannel.EventType.MESSAGE,t=>{if(!f){const n=t.data[0];v(!!n,16349);const i=n,o=i?.error||i[0]?.error;if(o){d(Uc,`RPC '${e}' stream ${r} received error:`,o);const t=o.status;let n=function(e){const t=$i[e];if(void 0!==t)return Ji(t)}(t),i=o.message;"NOT_FOUND"===t&&i.includes("database")&&i.includes("does not exist")&&i.includes(this.databaseId.database)&&p(`Database '${this.databaseId.database}' not found. Please check your project configuration.`),void 0===n&&(n=_.INTERNAL,i="Unknown error status: "+t+" with message "+o.message),f=!0,m.o_(new w(n,i)),l.close()}else d(Uc,`RPC '${e}' stream ${r} received:`,n),m.__(n)}}),Bc.u_(),setTimeout(()=>{m.s_()},0),m}terminate(){this.a_.forEach(e=>e.close()),this.a_=[]}I_(e){this.a_.push(e)}E_(e){this.a_=this.a_.filter(t=>t===e)}Go(e,t,n){super.Go(e,t,n),this.databaseInfo.apiKey&&(e["x-goog-api-key"]=this.databaseInfo.apiKey)}createWebChannelTransport(){return a.createWebChannelTransport()}}function zc(e){return new Bc(e)}function Wc(){return"undefined"!=typeof window?window:null}function Gc(){return"undefined"!=typeof document?document:null}function Kc(e){return new yo(e,!0)}Bc.c_=!1;class $c{constructor(e,t,n=1e3,r=1.5,i=6e4){this.Ci=e,this.timerId=t,this.R_=n,this.A_=r,this.V_=i,this.d_=0,this.m_=null,this.f_=Date.now(),this.reset()}reset(){this.d_=0}g_(){this.d_=this.V_}p_(e){this.cancel();const t=Math.floor(this.d_+this.y_()),n=Math.max(0,Date.now()-this.f_),r=Math.max(0,t-n);r>0&&d("ExponentialBackoff",`Backing off for ${r} ms (base delay: ${this.d_} ms, delay with jitter: ${t} ms, last attempt: ${n} ms ago)`),this.m_=this.Ci.enqueueAfterDelay(this.timerId,r,()=>(this.f_=Date.now(),e())),this.d_*=this.A_,this.d_<this.R_&&(this.d_=this.R_),this.d_>this.V_&&(this.d_=this.V_)}w_(){null!==this.m_&&(this.m_.skipDelay(),this.m_=null)}cancel(){null!==this.m_&&(this.m_.cancel(),this.m_=null)}y_(){return(Math.random()-.5)*this.d_}}const Hc="PersistentStream";class Qc{constructor(e,t,n,r,i,o,s,a){this.Ci=e,this.b_=n,this.S_=r,this.connection=i,this.authCredentialsProvider=o,this.appCheckCredentialsProvider=s,this.listener=a,this.state=0,this.D_=0,this.C_=null,this.v_=null,this.stream=null,this.F_=0,this.M_=new $c(e,t)}x_(){return 1===this.state||5===this.state||this.O_()}O_(){return 2===this.state||3===this.state}start(){this.F_=0,4!==this.state?this.auth():this.N_()}async stop(){this.x_()&&await this.close(0)}B_(){this.state=0,this.M_.reset()}L_(){this.O_()&&null===this.C_&&(this.C_=this.Ci.enqueueAfterDelay(this.b_,6e4,()=>this.k_()))}K_(e){this.q_(),this.stream.send(e)}async k_(){if(this.O_())return this.close(0)}q_(){this.C_&&(this.C_.cancel(),this.C_=null)}U_(){this.v_&&(this.v_.cancel(),this.v_=null)}async close(e,t){this.q_(),this.U_(),this.M_.cancel(),this.D_++,4!==e?this.M_.reset():t&&t.code===_.RESOURCE_EXHAUSTED?(f(t.toString()),f("Using maximum backoff delay to prevent overloading the backend."),this.M_.g_()):t&&t.code===_.UNAUTHENTICATED&&3!==this.state&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),null!==this.stream&&(this.W_(),this.stream.close(),this.stream=null),this.state=e,await this.listener.t_(t)}W_(){}auth(){this.state=1;const e=this.Q_(this.D_),t=this.D_;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then(([e,n])=>{this.D_===t&&this.G_(e,n)},t=>{e(()=>{const e=new w(_.UNKNOWN,"Fetching auth token failed: "+t.message);return this.z_(e)})})}G_(e,t){const n=this.Q_(this.D_);this.stream=this.j_(e,t),this.stream.Zo(()=>{n(()=>this.listener.Zo())}),this.stream.Yo(()=>{n(()=>(this.state=2,this.v_=this.Ci.enqueueAfterDelay(this.S_,1e4,()=>(this.O_()&&(this.state=3),Promise.resolve())),this.listener.Yo()))}),this.stream.t_(e=>{n(()=>this.z_(e))}),this.stream.onMessage(e=>{n(()=>1==++this.F_?this.H_(e):this.onNext(e))})}N_(){this.state=5,this.M_.p_(async()=>{this.state=0,this.start()})}z_(e){return d(Hc,`close with error: ${e}`),this.stream=null,this.close(4,e)}Q_(e){return t=>{this.Ci.enqueueAndForget(()=>this.D_===e?t():(d(Hc,"stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve()))}}}class Jc extends Qc{constructor(e,t,n,r,i,o){super(e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",t,n,r,o),this.serializer=i}j_(e,t){return this.connection.T_("Listen",e,t)}H_(e){return this.onNext(e)}onNext(e){this.M_.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:g(39313,{state:e})}(t.targetChange.targetChangeType||"NO_CHANGE"),i=t.targetChange.targetIds||[],o=function(e,t){return e.useProto3Json?(v(void 0===t||"string"==typeof t,58123),an.fromBase64String(t||"")):(v(void 0===t||t instanceof Buffer||t instanceof Uint8Array,16193),an.fromUint8Array(t||new Uint8Array))}(e,t.targetChange.resumeToken),s=t.targetChange.cause,a=s&&function(e){const t=void 0===e.code?_.UNKNOWN:Ji(e.code);return new w(t,e.message||"")}(s);n=new co(r,i,o,a||null)}else if("documentChange"in t){t.documentChange;const r=t.documentChange;r.document,r.document.name,r.document.updateTime;const i=Oo(e,r.document.name),o=Io(r.document.updateTime),s=r.document.createTime?Io(r.document.createTime):ee.min(),a=new Yn({mapValue:{fields:r.document.fields}}),c=Zn.newFoundDocument(i,o,s,a),u=r.targetIds||[],l=r.removedTargetIds||[];n=new so(u,l,c.key,c)}else if("documentDelete"in t){t.documentDelete;const r=t.documentDelete;r.document;const i=Oo(e,r.document),o=r.readTime?Io(r.readTime):ee.min(),s=Zn.newNoDocument(i,o),a=r.removedTargetIds||[];n=new so([],a,s.key,s)}else if("documentRemove"in t){t.documentRemove;const r=t.documentRemove;r.document;const i=Oo(e,r.document),o=r.removedTargetIds||[];n=new so([],o,i,null)}else{if(!("filter"in t))return g(11601,{Vt:t});{t.filter;const e=t.filter;e.targetId;const{count:r=0,unchangedNames:i}=e,o=new Ki(r,i),s=e.targetId;n=new ao(s,o)}}return n}(this.serializer,e),n=function(e){if(!("targetChange"in e))return ee.min();const t=e.targetChange;return t.targetIds&&t.targetIds.length?ee.min():t.readTime?Io(t.readTime):ee.min()}(e);return this.listener.J_(t,n)}Z_(e){const t={};t.database=Ro(this.serializer),t.addTarget=function(e,t){let n;const r=t.target;if(n=Pr(r)?{documents:jo(e,r)}:{query:Fo(e,r).ft},n.targetId=t.targetId,t.resumeToken.approximateByteSize()>0){n.resumeToken=_o(e,t.resumeToken);const r=vo(e,t.expectedCount);null!==r&&(n.expectedCount=r)}else if(t.snapshotVersion.compareTo(ee.min())>0){n.readTime=bo(e,t.snapshotVersion.toTimestamp());const r=vo(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 g(28987,{purpose:e})}}(t.purpose);return null==n?null:{"goog-listen-tags":n}}(this.serializer,e);n&&(t.labels=n),this.K_(t)}X_(e){const t={};t.database=Ro(this.serializer),t.removeTarget=e,this.K_(t)}}class Yc extends Qc{constructor(e,t,n,r,i,o){super(e,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",t,n,r,o),this.serializer=i}get Y_(){return this.F_>0}start(){this.lastStreamToken=void 0,super.start()}W_(){this.Y_&&this.ea([])}j_(e,t){return this.connection.T_("Write",e,t)}H_(e){return v(!!e.streamToken,31322),this.lastStreamToken=e.streamToken,v(!e.writeResults||0===e.writeResults.length,55816),this.listener.ta()}onNext(e){v(!!e.streamToken,12678),this.lastStreamToken=e.streamToken,this.M_.reset();const t=function(e,t){return e&&e.length>0?(v(void 0!==t,14353),e.map(e=>function(e,t){let n=e.updateTime?Io(e.updateTime):Io(t);return n.isEqual(ee.min())&&(n=Io(t)),new Ai(n,e.transformResults||[])}(e,t))):[]}(e.writeResults,e.commitTime),n=Io(e.commitTime);return this.listener.na(n,t)}ra(){const e={};e.database=Ro(this.serializer),this.K_(e)}ea(e){const t={streamToken:this.lastStreamToken,writes:e.map(e=>Mo(this.serializer,e))};this.K_(t)}}class Xc{}class Zc extends Xc{constructor(e,t,n,r){super(),this.authCredentials=e,this.appCheckCredentials=t,this.connection=n,this.serializer=r,this.ia=!1}sa(){if(this.ia)throw new w(_.FAILED_PRECONDITION,"The client has already been terminated.")}Wo(e,t,n,r){return this.sa(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([i,o])=>this.connection.Wo(e,To(t,n),r,i,o)).catch(e=>{throw"FirebaseError"===e.name?(e.code===_.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new w(_.UNKNOWN,e.toString())})}jo(e,t,n,r,i){return this.sa(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([o,s])=>this.connection.jo(e,To(t,n),r,o,s,i)).catch(e=>{throw"FirebaseError"===e.name?(e.code===_.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new w(_.UNKNOWN,e.toString())})}terminate(){this.ia=!0,this.connection.terminate()}}function eu(e,t,n,r){return new Zc(e,t,n,r)}class tu{constructor(e,t){this.asyncQueue=e,this.onlineStateHandler=t,this.state="Unknown",this.oa=0,this._a=null,this.aa=!0}ua(){0===this.oa&&(this.ca("Unknown"),this._a=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,()=>(this._a=null,this.la("Backend didn't respond within 10 seconds."),this.ca("Offline"),Promise.resolve())))}ha(e){"Online"===this.state?this.ca("Unknown"):(this.oa++,this.oa>=1&&(this.Pa(),this.la(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.ca("Offline")))}set(e){this.Pa(),this.oa=0,"Online"===e&&(this.aa=!1),this.ca(e)}ca(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}la(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.aa?(f(t),this.aa=!1):d("OnlineStateTracker",t)}Pa(){null!==this._a&&(this._a.cancel(),this._a=null)}}const nu="RemoteStore";class ru{constructor(e,t,n,r,i){this.localStore=e,this.datastore=t,this.asyncQueue=n,this.remoteSyncer={},this.Ta=[],this.Ia=new Map,this.Ea=new Set,this.Ra=[],this.Aa=i,this.Aa.Mo(e=>{n.enqueueAndForget(async()=>{du(this)&&(d(nu,"Restarting streams for network reachability change."),await async function(e){const t=b(e);t.Ea.add(4),await ou(t),t.Va.set("Unknown"),t.Ea.delete(4),await iu(t)}(this))})}),this.Va=new tu(n,r)}}async function iu(e){if(du(e))for(const t of e.Ra)await t(!0)}async function ou(e){for(const t of e.Ra)await t(!1)}function su(e,t){const n=b(e);n.Ia.has(t.targetId)||(n.Ia.set(t.targetId,t),hu(n)?lu(n):ku(n).O_()&&cu(n,t))}function au(e,t){const n=b(e),r=ku(n);n.Ia.delete(t),r.O_()&&uu(n,t),0===n.Ia.size&&(r.O_()?r.L_():du(n)&&n.Va.set("Unknown"))}function cu(e,t){if(e.da.$e(t.targetId),t.resumeToken.approximateByteSize()>0||t.snapshotVersion.compareTo(ee.min())>0){const n=e.remoteSyncer.getRemoteKeysForTarget(t.targetId).size;t=t.withExpectedCount(n)}ku(e).Z_(t)}function uu(e,t){e.da.$e(t),ku(e).X_(t)}function lu(e){e.da=new lo({getRemoteKeysForTarget:t=>e.remoteSyncer.getRemoteKeysForTarget(t),At:t=>e.Ia.get(t)||null,ht:()=>e.datastore.serializer.databaseId}),ku(e).start(),e.Va.ua()}function hu(e){return du(e)&&!ku(e).x_()&&e.Ia.size>0}function du(e){return 0===b(e).Ea.size}function fu(e){e.da=void 0}async function pu(e){e.Va.set("Online")}async function mu(e){e.Ia.forEach((t,n)=>{cu(e,t)})}async function gu(e,t){fu(e),hu(e)?(e.Va.ha(t),lu(e)):e.Va.set("Unknown")}async function yu(e,t,n){if(e.Va.set("Online"),t instanceof co&&2===t.state&&t.cause)try{await async function(e,t){const n=t.cause;for(const r of t.targetIds)e.Ia.has(r)&&(await e.remoteSyncer.rejectListen(r,n),e.Ia.delete(r),e.da.removeTarget(r))}(e,t)}catch(n){d(nu,"Failed to remove targets %s: %s ",t.targetIds.join(","),n),await vu(e,n)}else if(t instanceof so?e.da.Xe(t):t instanceof ao?e.da.st(t):e.da.tt(t),!n.isEqual(ee.min()))try{const t=await ac(e.localStore);n.compareTo(t)>=0&&await function(e,t){const n=e.da.Tt(t);return n.targetChanges.forEach((n,r)=>{if(n.resumeToken.approximateByteSize()>0){const i=e.Ia.get(r);i&&e.Ia.set(r,i.withResumeToken(n.resumeToken,t))}}),n.targetMismatches.forEach((t,n)=>{const r=e.Ia.get(t);if(!r)return;e.Ia.set(t,r.withResumeToken(an.EMPTY_BYTE_STRING,r.snapshotVersion)),uu(e,t);const i=new Yo(r.target,t,n,r.sequenceNumber);cu(e,i)}),e.remoteSyncer.applyRemoteEvent(n)}(e,n)}catch(t){d(nu,"Failed to raise snapshot:",t),await vu(e,t)}}async function vu(e,t,n){if(!Ee(t))throw t;e.Ea.add(1),await ou(e),e.Va.set("Offline"),n||(n=()=>ac(e.localStore)),e.asyncQueue.enqueueRetryable(async()=>{d(nu,"Retrying IndexedDB access"),await n(),e.Ea.delete(1),await iu(e)})}function bu(e,t){return t().catch(n=>vu(e,n,t))}async function _u(e){const t=b(e),n=Nu(t);let r=t.Ta.length>0?t.Ta[t.Ta.length-1].batchId:Ne;for(;wu(t);)try{const e=await uc(t.localStore,r);if(null===e){0===t.Ta.length&&n.L_();break}r=e.batchId,Iu(t,e)}catch(e){await vu(t,e)}Eu(t)&&Tu(t)}function wu(e){return du(e)&&e.Ta.length<10}function Iu(e,t){e.Ta.push(t);const n=Nu(e);n.O_()&&n.Y_&&n.ea(t.mutations)}function Eu(e){return du(e)&&!Nu(e).x_()&&e.Ta.length>0}function Tu(e){Nu(e).start()}async function Su(e){Nu(e).ra()}async function Au(e){const t=Nu(e);for(const n of e.Ta)t.ea(n.mutations)}async function Ou(e,t,n){const r=e.Ta.shift(),i=zi.from(r,t,n);await bu(e,()=>e.remoteSyncer.applySuccessfulWrite(i)),await _u(e)}async function Pu(e,t){t&&Nu(e).Y_&&await async function(e,t){if(function(e){return Qi(e)&&e!==_.ABORTED}(t.code)){const n=e.Ta.shift();Nu(e).B_(),await bu(e,()=>e.remoteSyncer.rejectFailedWrite(n.batchId,t)),await _u(e)}}(e,t),Eu(e)&&Tu(e)}async function Cu(e,t){const n=b(e);n.asyncQueue.verifyOperationInProgress(),d(nu,"RemoteStore received new credentials");const r=du(n);n.Ea.add(3),await ou(n),r&&n.Va.set("Unknown"),await n.remoteSyncer.handleCredentialChange(t),n.Ea.delete(3),await iu(n)}async function Ru(e,t){const n=b(e);t?(n.Ea.delete(2),await iu(n)):t||(n.Ea.add(2),await ou(n),n.Va.set("Unknown"))}function ku(e){return e.ma||(e.ma=function(e,t,n){const r=b(e);return r.sa(),new Jc(t,r.connection,r.authCredentials,r.appCheckCredentials,r.serializer,n)}(e.datastore,e.asyncQueue,{Zo:pu.bind(null,e),Yo:mu.bind(null,e),t_:gu.bind(null,e),J_:yu.bind(null,e)}),e.Ra.push(async t=>{t?(e.ma.B_(),hu(e)?lu(e):e.Va.set("Unknown")):(await e.ma.stop(),fu(e))})),e.ma}function Nu(e){return e.fa||(e.fa=function(e,t,n){const r=b(e);return r.sa(),new Yc(t,r.connection,r.authCredentials,r.appCheckCredentials,r.serializer,n)}(e.datastore,e.asyncQueue,{Zo:()=>Promise.resolve(),Yo:Su.bind(null,e),t_:Pu.bind(null,e),ta:Au.bind(null,e),na:Ou.bind(null,e)}),e.Ra.push(async t=>{t?(e.fa.B_(),await _u(e)):(await e.fa.stop(),e.Ta.length>0&&(d(nu,`Stopping write stream with ${e.Ta.length} pending writes`),e.Ta=[]))})),e.fa}class xu{constructor(e,t,n,r,i){this.asyncQueue=e,this.timerId=t,this.targetTimeMs=n,this.op=r,this.removalCallback=i,this.deferred=new I,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 o=Date.now()+n,s=new xu(e,t,o,r,i);return s.start(n),s}start(e){this.timerHandle=setTimeout(()=>this.handleDelayElapsed(),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){null!==this.timerHandle&&(this.clearTimeout(),this.deferred.reject(new w(_.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 Du(e,t){if(f("AsyncQueue",`${t}: ${e}`),Ee(e))return new w(_.UNAVAILABLE,`${t}: ${e}`);throw e}class Mu{static emptySet(e){return new Mu(e.comparator)}constructor(e){this.comparator=e?(t,n)=>e(t,n)||q.comparator(t.key,n.key):(e,t)=>q.comparator(e.key,t.key),this.keyedMap=ei(),this.sortedSet=new Xt(this.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 Mu))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 Mu;return n.comparator=this.comparator,n.keyedMap=e,n.sortedSet=t,n}}class Lu{constructor(){this.ga=new Xt(q.comparator)}track(e){const t=e.doc.key,n=this.ga.get(t);n?0!==e.type&&3===n.type?this.ga=this.ga.insert(t,e):3===e.type&&1!==n.type?this.ga=this.ga.insert(t,{type:n.type,doc:e.doc}):2===e.type&&2===n.type?this.ga=this.ga.insert(t,{type:2,doc:e.doc}):2===e.type&&0===n.type?this.ga=this.ga.insert(t,{type:0,doc:e.doc}):1===e.type&&0===n.type?this.ga=this.ga.remove(t):1===e.type&&2===n.type?this.ga=this.ga.insert(t,{type:1,doc:n.doc}):0===e.type&&1===n.type?this.ga=this.ga.insert(t,{type:2,doc:e.doc}):g(63341,{Vt:e,pa:n}):this.ga=this.ga.insert(t,e)}ya(){const e=[];return this.ga.inorderTraversal((t,n)=>{e.push(n)}),e}}class ju{constructor(e,t,n,r,i,o,s,a,c){this.query=e,this.docs=t,this.oldDocs=n,this.docChanges=r,this.mutatedKeys=i,this.fromCache=o,this.syncStateChanged=s,this.excludesMetadataChanges=a,this.hasCachedResults=c}static fromInitialDocuments(e,t,n,r,i){const o=[];return t.forEach(e=>{o.push({type:0,doc:e})}),new ju(e,t,Mu.emptySet(t),o,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)&&zr(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 Fu{constructor(){this.wa=void 0,this.ba=[]}Sa(){return this.ba.some(e=>e.Da())}}class Vu{constructor(){this.queries=Uu(),this.onlineState="Unknown",this.Ca=new Set}terminate(){!function(e,t){const n=b(e),r=n.queries;n.queries=Uu(),r.forEach((e,n)=>{for(const e of n.ba)e.onError(t)})}(this,new w(_.ABORTED,"Firestore shutting down"))}}function Uu(){return new Jr(e=>Wr(e),zr)}async function qu(e,t){const n=b(e);let r=3;const i=t.query;let o=n.queries.get(i);o?!o.Sa()&&t.Da()&&(r=2):(o=new Fu,r=t.Da()?0:1);try{switch(r){case 0:o.wa=await n.onListen(i,!0);break;case 1:o.wa=await n.onListen(i,!1);break;case 2:await n.onFirstRemoteStoreListen(i)}}catch(e){const n=Du(e,`Initialization of query '${Gr(t.query)}' failed`);return void t.onError(n)}n.queries.set(i,o),o.ba.push(t),t.va(n.onlineState),o.wa&&t.Fa(o.wa)&&Gu(n)}async function Bu(e,t){const n=b(e),r=t.query;let i=3;const o=n.queries.get(r);if(o){const e=o.ba.indexOf(t);e>=0&&(o.ba.splice(e,1),0===o.ba.length?i=t.Da()?0:1:!o.Sa()&&t.Da()&&(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 zu(e,t){const n=b(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.ba)t.Fa(e)&&(r=!0);i.wa=e}}r&&Gu(n)}function Wu(e,t,n){const r=b(e),i=r.queries.get(t);if(i)for(const e of i.ba)e.onError(n);r.queries.delete(t)}function Gu(e){e.Ca.forEach(e=>{e.next()})}var Ku,$u;($u=Ku||(Ku={})).Ma="default",$u.Cache="cache";class Hu{constructor(e,t,n){this.query=e,this.xa=t,this.Oa=!1,this.Na=null,this.onlineState="Unknown",this.options=n||{}}Fa(e){if(!this.options.includeMetadataChanges){const t=[];for(const n of e.docChanges)3!==n.type&&t.push(n);e=new ju(e.query,e.docs,e.oldDocs,t,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let t=!1;return this.Oa?this.Ba(e)&&(this.xa.next(e),t=!0):this.La(e,this.onlineState)&&(this.ka(e),t=!0),this.Na=e,t}onError(e){this.xa.error(e)}va(e){this.onlineState=e;let t=!1;return this.Na&&!this.Oa&&this.La(this.Na,e)&&(this.ka(this.Na),t=!0),t}La(e,t){if(!e.fromCache)return!0;if(!this.Da())return!0;const n="Offline"!==t;return(!this.options.Ka||!n)&&(!e.docs.isEmpty()||e.hasCachedResults||"Offline"===t)}Ba(e){if(e.docChanges.length>0)return!0;const t=this.Na&&this.Na.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&!0===this.options.includeMetadataChanges}ka(e){e=ju.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.Oa=!0,this.xa.next(e)}Da(){return this.options.source!==Ku.Cache}}class Qu{constructor(e,t){this.qa=e,this.byteLength=t}Ua(){return"metadata"in this.qa}}class Ju{constructor(e){this.serializer=e}Ks(e){return Oo(this.serializer,e)}qs(e){return e.metadata.exists?Do(this.serializer,e.document,!1):Zn.newNoDocument(this.Ks(e.metadata.name),this.Us(e.metadata.readTime))}Us(e){return Io(e)}}class Yu{constructor(e,t){this.$a=e,this.serializer=t,this.Wa=[],this.Qa=[],this.collectionGroups=new Set,this.progress=Xu(e)}get queries(){return this.Wa}get documents(){return this.Qa}Ga(e){this.progress.bytesLoaded+=e.byteLength;let t=this.progress.documentsLoaded;if(e.qa.namedQuery)this.Wa.push(e.qa.namedQuery);else if(e.qa.documentMetadata){this.Qa.push({metadata:e.qa.documentMetadata}),e.qa.documentMetadata.exists||++t;const n=F.fromString(e.qa.documentMetadata.name);this.collectionGroups.add(n.get(n.length-2))}else e.qa.document&&(this.Qa[this.Qa.length-1].document=e.qa.document,++t);return t!==this.progress.documentsLoaded?(this.progress.documentsLoaded=t,{...this.progress}):null}za(e){const t=new Map,n=new Ju(this.serializer);for(const r of e)if(r.metadata.queries){const e=n.Ks(r.metadata.name);for(const n of r.metadata.queries){const r=(t.get(n)||ai()).add(e);t.set(n,r)}}return t}async ja(e){const t=await async function(e,t,n,r){const i=b(e);let o=ai(),s=Xr();for(const e of n){const n=t.Ks(e.metadata.name);e.document&&(o=o.add(n));const r=t.qs(e);r.setReadTime(t.Us(e.metadata.readTime)),s=s.insert(n,r)}const a=i.xs.newChangeBuffer({trackRemovals:!0}),c=await lc(i,function(e){return Vr(Dr(F.fromString(`__bundle__/docs/${e}`)))}(r));return i.persistence.runTransaction("Apply bundle documents","readwrite",e=>cc(e,a,s).next(t=>(a.apply(e),t)).next(t=>i.li.removeMatchingKeysForTargetId(e,c.targetId).next(()=>i.li.addMatchingKeys(e,o,c.targetId)).next(()=>i.localDocuments.getLocalViewOfDocuments(e,t.Bs,t.Ls)).next(()=>t.Bs)))}(e,new Ju(this.serializer),this.Qa,this.$a.id),n=this.za(this.documents);for(const t of this.Wa)await gc(e,t,n.get(t.name));return this.progress.taskState="Success",{progress:this.progress,Ha:this.collectionGroups,Ja:t}}}function Xu(e){return{taskState:"Running",documentsLoaded:0,bytesLoaded:0,totalDocuments:e.totalDocuments,totalBytes:e.totalBytes}}class Zu{constructor(e){this.key=e}}class el{constructor(e){this.key=e}}class tl{constructor(e,t){this.query=e,this.Za=t,this.Xa=null,this.hasCachedResults=!1,this.current=!1,this.Ya=ai(),this.mutatedKeys=ai(),this.eu=Hr(e),this.tu=new Mu(this.eu)}get nu(){return this.Za}ru(e,t){const n=t?t.iu:new Lu,r=t?t.tu:this.tu;let i=t?t.mutatedKeys:this.mutatedKeys,o=r,s=!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=Kr(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.su(u,l)||(n.track({type:2,doc:l}),f=!0,(a&&this.eu(l,a)>0||c&&this.eu(l,c)<0)&&(s=!0)):!u&&l?(n.track({type:0,doc:l}),f=!0):u&&!l&&(n.track({type:1,doc:u}),f=!0,(a||c)&&(s=!0)),f&&(l?(o=o.add(l),i=d?i.add(e):i.delete(e)):(o=o.delete(e),i=i.delete(e)))}),null!==this.query.limit)for(;o.size>this.query.limit;){const e="F"===this.query.limitType?o.last():o.first();o=o.delete(e.key),i=i.delete(e.key),n.track({type:1,doc:e})}return{tu:o,iu:n,Ss:s,mutatedKeys:i}}su(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}applyChanges(e,t,n,r){const i=this.tu;this.tu=e.tu,this.mutatedKeys=e.mutatedKeys;const o=e.iu.ya();o.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 g(20277,{Vt:e})}};return n(e)-n(t)}(e.type,t.type)||this.eu(e.doc,t.doc)),this.ou(n),r=r??!1;const s=t&&!r?this._u():[],a=0===this.Ya.size&&this.current&&!r?1:0,c=a!==this.Xa;return this.Xa=a,0!==o.length||c?{snapshot:new ju(this.query,e.tu,i,o,e.mutatedKeys,0===a,c,!1,!!n&&n.resumeToken.approximateByteSize()>0),au:s}:{au:s}}va(e){return this.current&&"Offline"===e?(this.current=!1,this.applyChanges({tu:this.tu,iu:new Lu,mutatedKeys:this.mutatedKeys,Ss:!1},!1)):{au:[]}}uu(e){return!this.Za.has(e)&&!!this.tu.has(e)&&!this.tu.get(e).hasLocalMutations}ou(e){e&&(e.addedDocuments.forEach(e=>this.Za=this.Za.add(e)),e.modifiedDocuments.forEach(e=>{}),e.removedDocuments.forEach(e=>this.Za=this.Za.delete(e)),this.current=e.current)}_u(){if(!this.current)return[];const e=this.Ya;this.Ya=ai(),this.tu.forEach(e=>{this.uu(e.key)&&(this.Ya=this.Ya.add(e.key))});const t=[];return e.forEach(e=>{this.Ya.has(e)||t.push(new el(e))}),this.Ya.forEach(n=>{e.has(n)||t.push(new Zu(n))}),t}cu(e){this.Za=e.ks,this.Ya=ai();const t=this.ru(e.documents);return this.applyChanges(t,!0)}lu(){return ju.fromInitialDocuments(this.query,this.tu,this.mutatedKeys,0===this.Xa,this.hasCachedResults)}}const nl="SyncEngine";class rl{constructor(e,t,n){this.query=e,this.targetId=t,this.view=n}}class il{constructor(e){this.key=e,this.hu=!1}}class ol{constructor(e,t,n,r,i,o){this.localStore=e,this.remoteStore=t,this.eventManager=n,this.sharedClientState=r,this.currentUser=i,this.maxConcurrentLimboResolutions=o,this.Pu={},this.Tu=new Jr(e=>Wr(e),zr),this.Iu=new Map,this.Eu=new Set,this.Ru=new Xt(q.comparator),this.Au=new Map,this.Vu=new xa,this.du={},this.mu=new Map,this.fu=oa.ar(),this.onlineState="Unknown",this.gu=void 0}get isPrimaryClient(){return!0===this.gu}}async function sl(e,t,n=!0){const r=Ml(e);let i;const o=r.Tu.get(t);return o?(r.sharedClientState.addLocalQueryTarget(o.targetId),i=o.view.lu()):i=await cl(r,t,n,!0),i}async function al(e,t){const n=Ml(e);await cl(n,t,!0,!1)}async function cl(e,t,n,r){const i=await lc(e.localStore,Vr(t)),o=i.targetId,s=e.sharedClientState.addLocalQueryTarget(o,n);let a;return r&&(a=await ul(e,t,o,"current"===s,i.resumeToken)),e.isPrimaryClient&&n&&su(e.remoteStore,i),a}async function ul(e,t,n,r,i){e.pu=(t,n,r)=>async function(e,t,n,r){let i=t.view.ru(n);i.Ss&&(i=await dc(e.localStore,t.query,!1).then(({documents:e})=>t.view.ru(e,i)));const o=r&&r.targetChanges.get(t.targetId),s=r&&null!=r.targetMismatches.get(t.targetId),a=t.view.applyChanges(i,e.isPrimaryClient,o,s);return wl(e,t.targetId,a.au),a.snapshot}(e,t,n,r);const o=await dc(e.localStore,t,!0),s=new tl(t,o.ks),a=s.ru(o.documents),c=oo.createSynthesizedTargetChangeForCurrentChange(n,r&&"Offline"!==e.onlineState,i),u=s.applyChanges(a,e.isPrimaryClient,c);wl(e,n,u.au);const l=new rl(t,n,s);return e.Tu.set(t,l),e.Iu.has(n)?e.Iu.get(n).push(t):e.Iu.set(n,[t]),u.snapshot}async function ll(e,t,n){const r=b(e),i=r.Tu.get(t),o=r.Iu.get(i.targetId);if(o.length>1)return r.Iu.set(i.targetId,o.filter(e=>!zr(e,t))),void r.Tu.delete(t);r.isPrimaryClient?(r.sharedClientState.removeLocalQueryTarget(i.targetId),r.sharedClientState.isActiveQueryTarget(i.targetId)||await hc(r.localStore,i.targetId,!1).then(()=>{r.sharedClientState.clearQueryState(i.targetId),n&&au(r.remoteStore,i.targetId),bl(r,i.targetId)}).catch(me)):(bl(r,i.targetId),await hc(r.localStore,i.targetId,!0))}async function hl(e,t){const n=b(e),r=n.Tu.get(t),i=n.Iu.get(r.targetId);n.isPrimaryClient&&1===i.length&&(n.sharedClientState.removeLocalQueryTarget(r.targetId),au(n.remoteStore,r.targetId))}async function dl(e,t){const n=b(e);try{const e=await function(e,t){const n=b(e),r=t.snapshotVersion;let i=n.vs;return n.persistence.runTransaction("Apply remote event","readwrite-primary",e=>{const o=n.xs.newChangeBuffer({trackRemovals:!0});i=n.vs;const s=[];t.targetChanges.forEach((o,a)=>{const c=i.get(a);if(!c)return;s.push(n.li.removeMatchingKeys(e,o.removedDocuments,a).next(()=>n.li.addMatchingKeys(e,o.addedDocuments,a)));let u=c.withSequenceNumber(e.currentSequenceNumber);null!==t.targetMismatches.get(a)?u=u.withResumeToken(an.EMPTY_BYTE_STRING,ee.min()).withLastLimboFreeSnapshotVersion(ee.min()):o.resumeToken.approximateByteSize()>0&&(u=u.withResumeToken(o.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,o)&&s.push(n.li.updateTargetData(e,u))});let a=Xr(),c=ai();if(t.documentUpdates.forEach(r=>{t.resolvedLimboDocuments.has(r)&&s.push(n.persistence.referenceDelegate.updateLimboDocument(e,r))}),s.push(cc(e,o,t.documentUpdates).next(e=>{a=e.Bs,c=e.Ls})),!r.isEqual(ee.min())){const t=n.li.getLastRemoteSnapshotVersion(e).next(t=>n.li.setTargetsMetadata(e,e.currentSequenceNumber,r));s.push(t)}return ge.waitFor(s).next(()=>o.apply(e)).next(()=>n.localDocuments.getLocalViewOfDocuments(e,a,c)).next(()=>a)}).then(e=>(n.vs=i,e))}(n.localStore,t);t.targetChanges.forEach((e,t)=>{const r=n.Au.get(t);r&&(v(e.addedDocuments.size+e.modifiedDocuments.size+e.removedDocuments.size<=1,22616),e.addedDocuments.size>0?r.hu=!0:e.modifiedDocuments.size>0?v(r.hu,14607):e.removedDocuments.size>0&&(v(r.hu,42227),r.hu=!1))}),await Tl(n,e,t)}catch(e){await me(e)}}function fl(e,t,n){const r=b(e);if(r.isPrimaryClient&&0===n||!r.isPrimaryClient&&1===n){const e=[];r.Tu.forEach((n,r)=>{const i=r.view.va(t);i.snapshot&&e.push(i.snapshot)}),function(e,t){const n=b(e);n.onlineState=t;let r=!1;n.queries.forEach((e,n)=>{for(const e of n.ba)e.va(t)&&(r=!0)}),r&&Gu(n)}(r.eventManager,t),e.length&&r.Pu.J_(e),r.onlineState=t,r.isPrimaryClient&&r.sharedClientState.setOnlineState(t)}}async function pl(e,t,n){const r=b(e);r.sharedClientState.updateQueryState(t,"rejected",n);const i=r.Au.get(t),o=i&&i.key;if(o){let e=new Xt(q.comparator);e=e.insert(o,Zn.newNoDocument(o,ee.min()));const n=ai().add(o),i=new io(ee.min(),new Map,new Xt(k),e,n);await dl(r,i),r.Ru=r.Ru.remove(o),r.Au.delete(t),El(r)}else await hc(r.localStore,t,!1).then(()=>bl(r,t,n)).catch(me)}async function ml(e,t){const n=b(e),r=t.batch.batchId;try{const e=await function(e,t){const n=b(e);return n.persistence.runTransaction("Acknowledge batch","readwrite-primary",e=>{const r=t.batch.keys(),i=n.xs.newChangeBuffer({trackRemovals:!0});return function(e,t,n,r){const i=n.batch,o=i.keys();let s=ge.resolve();return o.forEach(e=>{s=s.next(()=>r.getEntry(t,e)).next(t=>{const o=n.docVersions.get(e);v(null!==o,48541),t.version.compareTo(o)<0&&(i.applyToRemoteDocument(t,n),t.isValidDocument()&&(t.setReadTime(n.commitVersion),r.addEntry(t)))})}),s.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=ai();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);vl(n,r,null),yl(n,r),n.sharedClientState.updateMutationState(r,"acknowledged"),await Tl(n,e)}catch(e){await me(e)}}async function gl(e,t,n){const r=b(e);try{const e=await function(e,t){const n=b(e);return n.persistence.runTransaction("Reject batch","readwrite-primary",e=>{let r;return n.mutationQueue.lookupMutationBatch(e,t).next(t=>(v(null!==t,37113),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);vl(r,t,n),yl(r,t),r.sharedClientState.updateMutationState(t,"rejected",n),await Tl(r,e)}catch(n){await me(n)}}function yl(e,t){(e.mu.get(t)||[]).forEach(e=>{e.resolve()}),e.mu.delete(t)}function vl(e,t,n){const r=b(e);let i=r.du[r.currentUser.toKey()];if(i){const e=i.get(t);e&&(n?e.reject(n):e.resolve(),i=i.remove(t)),r.du[r.currentUser.toKey()]=i}}function bl(e,t,n=null){e.sharedClientState.removeLocalQueryTarget(t);for(const r of e.Iu.get(t))e.Tu.delete(r),n&&e.Pu.yu(r,n);e.Iu.delete(t),e.isPrimaryClient&&e.Vu.Gr(t).forEach(t=>{e.Vu.containsKey(t)||_l(e,t)})}function _l(e,t){e.Eu.delete(t.path.canonicalString());const n=e.Ru.get(t);null!==n&&(au(e.remoteStore,n),e.Ru=e.Ru.remove(t),e.Au.delete(n),El(e))}function wl(e,t,n){for(const r of n)r instanceof Zu?(e.Vu.addReference(r.key,t),Il(e,r)):r instanceof el?(d(nl,"Document no longer in limbo: "+r.key),e.Vu.removeReference(r.key,t),e.Vu.containsKey(r.key)||_l(e,r.key)):g(19791,{wu:r})}function Il(e,t){const n=t.key,r=n.path.canonicalString();e.Ru.get(n)||e.Eu.has(r)||(d(nl,"New document in limbo: "+n),e.Eu.add(r),El(e))}function El(e){for(;e.Eu.size>0&&e.Ru.size<e.maxConcurrentLimboResolutions;){const t=e.Eu.values().next().value;e.Eu.delete(t);const n=new q(F.fromString(t)),r=e.fu.next();e.Au.set(r,new il(n)),e.Ru=e.Ru.insert(n,r),su(e.remoteStore,new Yo(Vr(Dr(n.path)),r,"TargetPurposeLimboResolution",ke.ce))}}async function Tl(e,t,n){const r=b(e),i=[],o=[],s=[];r.Tu.isEmpty()||(r.Tu.forEach((e,a)=>{s.push(r.pu(a,t,n).then(e=>{if((e||n)&&r.isPrimaryClient){const t=e?!e.fromCache:n?.targetChanges.get(a.targetId)?.current;r.sharedClientState.updateQueryState(a.targetId,t?"current":"not-current")}if(e){i.push(e);const t=ec.Es(a.targetId,e);o.push(t)}}))}),await Promise.all(s),r.Pu.J_(i),await async function(e,t){const n=b(e);try{await n.persistence.runTransaction("notifyLocalViewChanges","readwrite",e=>ge.forEach(t,t=>ge.forEach(t.Ts,r=>n.persistence.referenceDelegate.addReference(e,t.targetId,r)).next(()=>ge.forEach(t.Is,r=>n.persistence.referenceDelegate.removeReference(e,t.targetId,r)))))}catch(e){if(!Ee(e))throw e;d(rc,"Failed to update sequence numbers: "+e)}for(const e of t){const t=e.targetId;if(!e.fromCache){const e=n.vs.get(t),r=e.snapshotVersion,i=e.withLastLimboFreeSnapshotVersion(r);n.vs=n.vs.insert(t,i)}}}(r.localStore,o))}async function Sl(e,t){const n=b(e);if(!n.currentUser.isEqual(t)){d(nl,"User change. New user:",t.toKey());const e=await sc(n.localStore,t);n.currentUser=t,function(e){e.mu.forEach(e=>{e.forEach(e=>{e.reject(new w(_.CANCELLED,"'waitForPendingWrites' promise is rejected due to a user change."))})}),e.mu.clear()}(n),n.sharedClientState.handleUserChange(t,e.removedBatchIds,e.addedBatchIds),await Tl(n,e.Ns)}}function Al(e,t){const n=b(e),r=n.Au.get(t);if(r&&r.hu)return ai().add(r.key);{let e=ai();const r=n.Iu.get(t);if(!r)return e;for(const t of r){const r=n.Tu.get(t);e=e.unionWith(r.view.nu)}return e}}async function Ol(e,t){const n=b(e),r=await dc(n.localStore,t.query,!0),i=t.view.cu(r);return n.isPrimaryClient&&wl(n,t.targetId,i.au),i}async function Pl(e,t){const n=b(e);return pc(n.localStore,t).then(e=>Tl(n,e))}async function Cl(e,t,n,r){const i=b(e),o=await function(e,t){const n=b(e),r=b(n.mutationQueue);return n.persistence.runTransaction("Lookup mutation documents","readonly",e=>r.Xn(e,t).next(t=>t?n.localDocuments.getDocuments(e,t):ge.resolve(null)))}(i.localStore,t);null!==o?("pending"===n?await _u(i.remoteStore):"acknowledged"===n||"rejected"===n?(vl(i,t,r||null),yl(i,t),function(e,t){b(b(e).mutationQueue).nr(t)}(i.localStore,t)):g(6720,"Unknown batchState",{bu:n}),await Tl(i,o)):d(nl,"Cannot apply mutation batch with id: "+t)}async function Rl(e,t,n){const r=b(e),i=[],o=[];for(const e of t){let t;const n=r.Iu.get(e);if(n&&0!==n.length){t=await lc(r.localStore,Vr(n[0]));for(const e of n){const t=r.Tu.get(e),n=await Ol(r,t);n.snapshot&&o.push(n.snapshot)}}else{const n=await fc(r.localStore,e);t=await lc(r.localStore,n),await ul(r,kl(n),e,!1,t.resumeToken)}i.push(t)}return r.Pu.J_(o),i}function kl(e){return xr(e.path,e.collectionGroup,e.orderBy,e.filters,e.limit,"F",e.startAt,e.endAt)}function Nl(e){return function(e){return b(b(e).persistence).hs()}(b(e).localStore)}async function xl(e,t,n,r){const i=b(e);if(i.gu)return void d(nl,"Ignoring unexpected query state notification.");const o=i.Iu.get(t);if(o&&o.length>0)switch(n){case"current":case"not-current":{const e=await pc(i.localStore,$r(o[0])),r=io.createSynthesizedRemoteEventForCurrentChange(t,"current"===n,an.EMPTY_BYTE_STRING);await Tl(i,e,r);break}case"rejected":await hc(i.localStore,t,!0),bl(i,t,r);break;default:g(64155,n)}}async function Dl(e,t,n){const r=Ml(e);if(r.gu){for(const e of t){if(r.Iu.has(e)&&r.sharedClientState.isActiveQueryTarget(e)){d(nl,"Adding an already active target "+e);continue}const t=await fc(r.localStore,e),n=await lc(r.localStore,t);await ul(r,kl(t),n.targetId,!1,n.resumeToken),su(r.remoteStore,n)}for(const e of n)r.Iu.has(e)&&await hc(r.localStore,e,!1).then(()=>{au(r.remoteStore,e),bl(r,e)}).catch(me)}}function Ml(e){const t=b(e);return t.remoteStore.remoteSyncer.applyRemoteEvent=dl.bind(null,t),t.remoteStore.remoteSyncer.getRemoteKeysForTarget=Al.bind(null,t),t.remoteStore.remoteSyncer.rejectListen=pl.bind(null,t),t.Pu.J_=zu.bind(null,t.eventManager),t.Pu.yu=Wu.bind(null,t.eventManager),t}function Ll(e){const t=b(e);return t.remoteStore.remoteSyncer.applySuccessfulWrite=ml.bind(null,t),t.remoteStore.remoteSyncer.rejectFailedWrite=gl.bind(null,t),t}class jl{constructor(){this.kind="memory",this.synchronizeTabs=!1}async initialize(e){this.serializer=Kc(e.databaseInfo.databaseId),this.sharedClientState=this.Du(e),this.persistence=this.Cu(e),await this.persistence.start(),this.localStore=this.vu(e),this.gcScheduler=this.Fu(e,this.localStore),this.indexBackfillerScheduler=this.Mu(e,this.localStore)}Fu(e,t){return null}Mu(e,t){return null}vu(e){return oc(this.persistence,new nc,e.initialUser,this.serializer)}Cu(e){return new Va(qa.Vi,this.serializer)}Du(e){return new Rc}async terminate(){this.gcScheduler?.stop(),this.indexBackfillerScheduler?.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}}jl.provider={build:()=>new jl};class Fl extends jl{constructor(e){super(),this.cacheSizeBytes=e}Fu(e,t){v(this.persistence.referenceDelegate instanceof Ba,46915);const n=this.persistence.referenceDelegate.garbageCollector;return new pa(n,e.asyncQueue,t)}Cu(e){const t=void 0!==this.cacheSizeBytes?Ys.withCacheSize(this.cacheSizeBytes):Ys.DEFAULT;return new Va(e=>Ba.Vi(e,t),this.serializer)}}class Vl extends jl{constructor(e,t,n){super(),this.xu=e,this.cacheSizeBytes=t,this.forceOwnership=n,this.kind="persistent",this.synchronizeTabs=!1}async initialize(e){await super.initialize(e),await this.xu.initialize(this,e),await Ll(this.xu.syncEngine),await _u(this.xu.remoteStore),await this.persistence.zi(()=>(this.gcScheduler&&!this.gcScheduler.started&&this.gcScheduler.start(),this.indexBackfillerScheduler&&!this.indexBackfillerScheduler.started&&this.indexBackfillerScheduler.start(),Promise.resolve()))}vu(e){return oc(this.persistence,new nc,e.initialUser,this.serializer)}Fu(e,t){const n=this.persistence.referenceDelegate.garbageCollector;return new pa(n,e.asyncQueue,t)}Mu(e,t){const n=new Re(t,this.persistence);return new Ce(e.asyncQueue,n)}Cu(e){const t=Za(e.databaseInfo.databaseId,e.databaseInfo.persistenceKey),n=void 0!==this.cacheSizeBytes?Ys.withCacheSize(this.cacheSizeBytes):Ys.DEFAULT;return new Ja(this.synchronizeTabs,t,e.clientId,n,e.asyncQueue,Wc(),Gc(),this.serializer,this.sharedClientState,!!this.forceOwnership)}Du(e){return new Rc}}class Ul extends Vl{constructor(e,t){super(e,t,!1),this.xu=e,this.cacheSizeBytes=t,this.synchronizeTabs=!0}async initialize(e){await super.initialize(e);const t=this.xu.syncEngine;this.sharedClientState instanceof Cc&&(this.sharedClientState.syncEngine={So:Cl.bind(null,t),Do:xl.bind(null,t),Co:Dl.bind(null,t),hs:Nl.bind(null,t),bo:Pl.bind(null,t)},await this.sharedClientState.start()),await this.persistence.zi(async e=>{await async function(e,t){const n=b(e);if(Ml(n),Ll(n),!0===t&&!0!==n.gu){const e=n.sharedClientState.getAllActiveQueryTargets(),t=await Rl(n,e.toArray());n.gu=!0,await Ru(n.remoteStore,!0);for(const e of t)su(n.remoteStore,e)}else if(!1===t&&!1!==n.gu){const e=[];let t=Promise.resolve();n.Iu.forEach((r,i)=>{n.sharedClientState.isLocalQueryTarget(i)?e.push(i):t=t.then(()=>(bl(n,i),hc(n.localStore,i,!0))),au(n.remoteStore,i)}),await t,await Rl(n,e),function(e){const t=b(e);t.Au.forEach((e,n)=>{au(t.remoteStore,n)}),t.Vu.zr(),t.Au=new Map,t.Ru=new Xt(q.comparator)}(n),n.gu=!1,await Ru(n.remoteStore,!1)}}(this.xu.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())})}Du(e){const t=Wc();if(!Cc.v(t))throw new w(_.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");const n=Za(e.databaseInfo.databaseId,e.databaseInfo.persistenceKey);return new Cc(t,e.asyncQueue,n,e.clientId,e.initialUser)}}class ql{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=>fl(this.syncEngine,e,1),this.remoteStore.remoteSyncer.handleCredentialChange=Sl.bind(null,this.syncEngine),await Ru(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return new Vu}createDatastore(e){const t=Kc(e.databaseInfo.databaseId),n=zc(e.databaseInfo);return eu(e.authCredentials,e.appCheckCredentials,n,t)}createRemoteStore(e){return function(e,t,n,r,i){return new ru(e,t,n,r,i)}(this.localStore,this.datastore,e.asyncQueue,e=>fl(this.syncEngine,e,0),xc.v()?new xc:new kc)}createSyncEngine(e,t){return function(e,t,n,r,i,o,s){const a=new ol(e,t,n,r,i,o);return s&&(a.gu=!0),a}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,e.initialUser,e.maxConcurrentLimboResolutions,t)}async terminate(){await async function(e){const t=b(e);d(nu,"RemoteStore shutting down."),t.Ea.add(5),await ou(t),t.Aa.shutdown(),t.Va.set("Unknown")}(this.remoteStore),this.datastore?.terminate(),this.eventManager?.terminate()}}function Bl(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()}}ql.provider={build:()=>new ql};class zl{constructor(e){this.observer=e,this.muted=!1}next(e){this.muted||this.observer.next&&this.Ou(this.observer.next,e)}error(e){this.muted||(this.observer.error?this.Ou(this.observer.error,e):f("Uncaught Error in snapshot listener:",e.toString()))}Nu(){this.muted=!0}Ou(e,t){setTimeout(()=>{this.muted||e(t)},0)}}class Wl{constructor(e,t){this.Bu=e,this.serializer=t,this.metadata=new I,this.buffer=new Uint8Array,this.Lu=new TextDecoder("utf-8"),this.ku().then(e=>{e&&e.Ua()?this.metadata.resolve(e.qa.metadata):this.metadata.reject(new Error(`The first element of the bundle is not a metadata, it is\n ${JSON.stringify(e?.qa)}`))},e=>this.metadata.reject(e))}close(){return this.Bu.cancel()}async getMetadata(){return this.metadata.promise}async Su(){return await this.getMetadata(),this.ku()}async ku(){const e=await this.Ku();if(null===e)return null;const t=this.Lu.decode(e),n=Number(t);isNaN(n)&&this.qu(`length string (${t}) is not valid number`);const r=await this.Uu(n);return new Qu(JSON.parse(r),e.length+n)}$u(){return this.buffer.findIndex(e=>e==="{".charCodeAt(0))}async Ku(){for(;this.$u()<0&&!await this.Wu(););if(0===this.buffer.length)return null;const e=this.$u();e<0&&this.qu("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 Uu(e){for(;this.buffer.length<e;)await this.Wu()&&this.qu("Reached the end of bundle when more is expected.");const t=this.Lu.decode(this.buffer.slice(0,e));return this.buffer=this.buffer.slice(e),t}qu(e){throw this.Bu.cancel(),new Error(`Invalid bundle format: ${e}`)}async Wu(){const e=await this.Bu.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 Gl{constructor(e,t){this.bundleData=e,this.serializer=t,this.cursor=0,this.elements=[];let n=this.Su();if(!n||!n.Ua())throw new Error(`The first element of the bundle is not a metadata object, it is\n ${JSON.stringify(n?.qa)}`);this.metadata=n;do{n=this.Su(),null!==n&&this.elements.push(n)}while(null!==n)}getMetadata(){return this.metadata}Qu(){return this.elements}Su(){if(this.cursor===this.bundleData.length)return null;const e=this.Ku(),t=this.Uu(e);return new Qu(JSON.parse(t),e)}Uu(e){if(this.cursor+e>this.bundleData.length)throw new w(_.INTERNAL,"Reached the end of bundle when more is expected.");return this.bundleData.slice(this.cursor,this.cursor+=e)}Ku(){const e=this.cursor;let t=this.cursor;for(;t<this.bundleData.length;){if("{"===this.bundleData[t]){if(t===e)throw new Error("First character is a bracket and not a number");return this.cursor=t,Number(this.bundleData.slice(e,t))}t++}throw new Error("Reached the end of bundle when more is expected.")}}class Kl{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 w(_.INVALID_ARGUMENT,"Firestore transactions require all reads to be executed before all writes."),this.lastTransactionError;const t=await async function(e,t){const n=b(e),r={documents:t.map(e=>Ao(n.serializer,e))},i=await n.jo("BatchGetDocuments",n.serializer.databaseId,F.emptyPath(),r,t.length),o=new Map;i.forEach(e=>{const t=function(e,t){return"found"in t?function(e,t){v(!!t.found,43571),t.found.name,t.found.updateTime;const n=Oo(e,t.found.name),r=Io(t.found.updateTime),i=t.found.createTime?Io(t.found.createTime):ee.min(),o=new Yn({mapValue:{fields:t.found.fields}});return Zn.newFoundDocument(n,r,i,o)}(e,t):"missing"in t?function(e,t){v(!!t.missing,3894),v(!!t.readTime,22933);const n=Oo(e,t.missing),r=Io(t.readTime);return Zn.newNoDocument(n,r)}(e,t):g(7234,{result:t})}(n.serializer,e);o.set(t.key.toString(),t)});const s=[];return t.forEach(e=>{const t=o.get(e.toString());v(!!t,55234,{key:e}),s.push(t)}),s}(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 Ui(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=q.fromPath(t);this.mutations.push(new qi(n,this.precondition(n)))}),await async function(e,t){const n=b(e),r={writes:t.map(e=>Mo(n.serializer,e))};await n.Wo("Commit",n.serializer.databaseId,F.emptyPath(),r)}(this.datastore,this.mutations),this.committed=!0}recordVersion(e){let t;if(e.isFoundDocument())t=e.version;else{if(!e.isNoDocument())throw g(50498,{Gu:e.constructor.name});t=ee.min()}const n=this.readVersions.get(e.key.toString());if(n){if(!t.isEqual(n))throw new w(_.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(ee.min())?Oi.exists(!1):Oi.updateTime(t):Oi.none()}preconditionForUpdate(e){const t=this.readVersions.get(e.toString());if(!this.writtenDocs.has(e.toString())&&t){if(t.isEqual(ee.min()))throw new w(_.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return Oi.updateTime(t)}return Oi.exists(!0)}write(e){this.ensureCommitNotCalled(),this.mutations.push(e)}ensureCommitNotCalled(){}}class $l{constructor(e,t,n,r,i){this.asyncQueue=e,this.datastore=t,this.options=n,this.updateFunction=r,this.deferred=i,this.zu=n.maxAttempts,this.M_=new $c(this.asyncQueue,"transaction_retry")}ju(){this.zu-=1,this.Hu()}Hu(){this.M_.p_(async()=>{const e=new Kl(this.datastore),t=this.Ju(e);t&&t.then(t=>{this.asyncQueue.enqueueAndForget(()=>e.commit().then(()=>{this.deferred.resolve(t)}).catch(e=>{this.Zu(e)}))}).catch(e=>{this.Zu(e)})})}Ju(e){try{const t=this.updateFunction(e);return!xe(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}}Zu(e){this.zu>0&&this.Xu(e)?(this.zu-=1,this.asyncQueue.enqueueAndForget(()=>(this.Hu(),Promise.resolve()))):this.deferred.reject(e)}Xu(e){if("FirebaseError"===e?.name){const t=e.code;return"aborted"===t||"failed-precondition"===t||"already-exists"===t||!Qi(t)}return!1}}const Hl="FirestoreClient";class Ql{constructor(e,t,n,r,i){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=n,this._databaseInfo=r,this.user=c.UNAUTHENTICATED,this.clientId=R.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=i,this.authCredentials.start(n,async e=>{d(Hl,"Received user=",e.uid),await this.authCredentialListener(e),this.user=e}),this.appCheckCredentials.start(n,e=>(d(Hl,"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}terminate(){this.asyncQueue.enterRestrictedMode();const e=new I;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=Du(t,"Failed to shutdown persistence");e.reject(n)}}),e.promise}}async function Jl(e,t){e.asyncQueue.verifyOperationInProgress(),d(Hl,"Initializing OfflineComponentProvider");const n=e.configuration;await t.initialize(n);let r=n.initialUser;e.setCredentialChangeListener(async e=>{r.isEqual(e)||(await sc(t.localStore,e),r=e)}),t.persistence.setDatabaseDeletedListener(()=>e.terminate()),e._offlineComponents=t}async function Yl(e,t){e.asyncQueue.verifyOperationInProgress();const n=await Xl(e);d(Hl,"Initializing OnlineComponentProvider"),await t.initialize(n,e.configuration),e.setCredentialChangeListener(e=>Cu(t.remoteStore,e)),e.setAppCheckTokenChangeListener((e,n)=>Cu(t.remoteStore,n)),e._onlineComponents=t}async function Xl(e){if(!e._offlineComponents)if(e._uninitializedComponentsProvider){d(Hl,"Using user provided OfflineComponentProvider");try{await Jl(e,e._uninitializedComponentsProvider._offline)}catch(t){const n=t;if(!function(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}(n))throw n;p("Error using user provided cache. Falling back to memory cache: "+n),await Jl(e,new jl)}}else d(Hl,"Using default OfflineComponentProvider"),await Jl(e,new Fl(void 0));return e._offlineComponents}async function Zl(e){return e._onlineComponents||(e._uninitializedComponentsProvider?(d(Hl,"Using user provided OnlineComponentProvider"),await Yl(e,e._uninitializedComponentsProvider._online)):(d(Hl,"Using default OnlineComponentProvider"),await Yl(e,new ql))),e._onlineComponents}function eh(e){return Xl(e).then(e=>e.persistence)}function th(e){return Xl(e).then(e=>e.localStore)}function nh(e){return Zl(e).then(e=>e.remoteStore)}function rh(e){return Zl(e).then(e=>e.syncEngine)}function ih(e){return Zl(e).then(e=>e.datastore)}async function oh(e){const t=await Zl(e),n=t.eventManager;return n.onListen=sl.bind(null,t.syncEngine),n.onUnlisten=ll.bind(null,t.syncEngine),n.onFirstRemoteStoreListen=al.bind(null,t.syncEngine),n.onLastRemoteStoreUnlisten=hl.bind(null,t.syncEngine),n}function sh(e){const t={};return void 0!==e.timeoutSeconds&&(t.timeoutSeconds=e.timeoutSeconds),t}const ah="ComponentProvider",ch=new Map;function uh(e,t,n,r,i){return new bn(e,t,n,i.host,i.ssl,i.experimentalForceLongPolling,i.experimentalAutoDetectLongPolling,sh(i.experimentalLongPollingOptions),i.useFetchStreams,i.isUsingEmulator,r)}const lh="firestore.googleapis.com",hh=!0;class dh{constructor(e){if(void 0===e.host){if(void 0!==e.ssl)throw new w(_.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host=lh,this.ssl=hh}else this.host=e.host,this.ssl=e.ssl??hh;if(this.isUsingEmulator=void 0!==e.emulatorOptions,this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,this.localCache=e.localCache,void 0===e.cacheSizeBytes)this.cacheSizeBytes=Js;else{if(-1!==e.cacheSizeBytes&&e.cacheSizeBytes<ha)throw new w(_.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}z("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=sh(e.experimentalLongPollingOptions??{}),function(e){if(void 0!==e.timeoutSeconds){if(isNaN(e.timeoutSeconds))throw new w(_.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (must not be NaN)`);if(e.timeoutSeconds<5)throw new w(_.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (minimum allowed value is 5)`);if(e.timeoutSeconds>30)throw new w(_.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 fh{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 dh({}),this._settingsFrozen=!1,this._emulatorOptions={},this._terminateTask="notTerminated"}get app(){if(!this._app)throw new w(_.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"notTerminated"!==this._terminateTask}_setSettings(e){if(this._settingsFrozen)throw new w(_.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 dh(e),this._emulatorOptions=e.emulatorOptions||{},void 0!==e.credentials&&(this._authCredentials=function(e){if(!e)return new T;switch(e.type){case"firstParty":return new O(e.sessionIndex||"0",e.iamToken||null,e.authTokenFactory||null);case"provider":return e.client;default:throw new w(_.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invalid credential type")}}(e.credentials))}_getSettings(){return this._settings}_getEmulatorOptions(){return this._emulatorOptions}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return"notTerminated"===this._terminateTask&&(this._terminateTask=this._terminate()),this._terminateTask}async _restart(){"notTerminated"===this._terminateTask?await this._terminate():this._terminateTask="notTerminated"}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return function(e){const t=ch.get(e);t&&(d(ah,"Removing Datastore"),ch.delete(e),t.terminate())}(this),Promise.resolve()}}function ph(e,t,n,r={}){e=H(e,fh);const o=i.isCloudWorkstation(t),s=e._getSettings(),a={...s,emulatorOptions:e._getEmulatorOptions()},u=`${t}:${n}`;o&&(i.pingServer(`https://${u}`),i.updateEmulatorBanner("Firestore",!0)),s.host!==lh&&s.host!==u&&p("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used.");const l={...s,host:u,ssl:o,emulatorOptions:r};if(!i.deepEqual(l,a)&&(e._setSettings(l),r.mockUserToken)){let t,n;if("string"==typeof r.mockUserToken)t=r.mockUserToken,n=c.MOCK_USER;else{t=i.createMockUserToken(r.mockUserToken,e._app?.options.projectId);const o=r.mockUserToken.sub||r.mockUserToken.user_id;if(!o)throw new w(_.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");n=new c(o)}e._authCredentials=new S(new E(t,n))}}class mh{constructor(e,t,n){this.converter=t,this._query=n,this.type="query",this.firestore=e}withConverter(e){return new mh(this.firestore,e,this._query)}}class gh{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 yh(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new gh(this.firestore,e,this._key)}toJSON(){return{type:gh._jsonSchemaVersion,referencePath:this._key.toString()}}static fromJSON(e,t,n){if(J(t,gh._jsonSchema))return new gh(e,n||null,new q(F.fromString(t.referencePath)))}}gh._jsonSchemaVersion="firestore/documentReference/1.0",gh._jsonSchema={type:Q("string",gh._jsonSchemaVersion),referencePath:Q("string")};class yh extends mh{constructor(e,t,n){super(e,t,Dr(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 gh(this.firestore,null,new q(e))}withConverter(e){return new yh(this.firestore,e,this._path)}}const vh="AsyncQueue";class bh{constructor(e=Promise.resolve()){this.Yu=[],this.ec=!1,this.tc=[],this.nc=null,this.rc=!1,this.sc=!1,this.oc=[],this.M_=new $c(this,"async_queue_retry"),this._c=()=>{const e=Gc();e&&d(vh,"Visibility state changed to "+e.visibilityState),this.M_.w_()},this.ac=e;const t=Gc();t&&"function"==typeof t.addEventListener&&t.addEventListener("visibilitychange",this._c)}get isShuttingDown(){return this.ec}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.uc(),this.cc(e)}enterRestrictedMode(e){if(!this.ec){this.ec=!0,this.sc=e||!1;const t=Gc();t&&"function"==typeof t.removeEventListener&&t.removeEventListener("visibilitychange",this._c)}}enqueue(e){if(this.uc(),this.ec)return new Promise(()=>{});const t=new I;return this.cc(()=>this.ec&&this.sc?Promise.resolve():(e().then(t.resolve,t.reject),t.promise)).then(()=>t.promise)}enqueueRetryable(e){this.enqueueAndForget(()=>(this.Yu.push(e),this.lc()))}async lc(){if(0!==this.Yu.length){try{await this.Yu[0](),this.Yu.shift(),this.M_.reset()}catch(e){if(!Ee(e))throw e;d(vh,"Operation failed with retryable error: "+e)}this.Yu.length>0&&this.M_.p_(()=>this.lc())}}cc(e){const t=this.ac.then(()=>(this.rc=!0,e().catch(e=>{throw this.nc=e,this.rc=!1,f("INTERNAL UNHANDLED ERROR: ",_h(e)),e}).then(e=>(this.rc=!1,e))));return this.ac=t,t}enqueueAfterDelay(e,t,n){this.uc(),this.oc.indexOf(e)>-1&&(t=0);const r=xu.createAndSchedule(this,e,t,n,e=>this.hc(e));return this.tc.push(r),r}uc(){this.nc&&g(47125,{Pc:_h(this.nc)})}verifyOperationInProgress(){}async Tc(){let e;do{e=this.ac,await e}while(e!==this.ac)}Ic(e){for(const t of this.tc)if(t.timerId===e)return!0;return!1}Ec(e){return this.Tc().then(()=>{this.tc.sort((e,t)=>e.targetTimeMs-t.targetTimeMs);for(const t of this.tc)if(t.skipDelay(),"all"!==e&&t.timerId===e)break;return this.Tc()})}Rc(e){this.oc.push(e)}hc(e){const t=this.tc.indexOf(e);this.tc.splice(t,1)}}function _h(e){let t=e.message||"";return e.stack&&(t=e.stack.includes(e.message)?e.stack:e.message+"\n"+e.stack),t}class wh{constructor(){this._progressObserver={},this._taskCompletionResolver=new I,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 Ih extends fh{constructor(e,t,n,r){super(e,t,n,r),this.type="firestore",this._queue=new bh,this._persistenceKey=r?.name||"[DEFAULT]"}async _terminate(){if(this._firestoreClient){const e=this._firestoreClient.terminate();this._queue=new bh(e),this._firestoreClient=void 0,await e}}}function Eh(e){if(e._terminated)throw new w(_.FAILED_PRECONDITION,"The client has already been terminated.");return e._firestoreClient||Th(e),e._firestoreClient}function Th(e){const t=e._freezeSettings(),n=uh(e._databaseId,e._app?.options.appId||"",e._persistenceKey,e._app?.options.apiKey,t);e._componentsProvider||t.localCache?._offlineComponentProvider&&t.localCache?._onlineComponentProvider&&(e._componentsProvider={_offline:t.localCache._offlineComponentProvider,_online:t.localCache._onlineComponentProvider}),e._firestoreClient=new Ql(e._authCredentials,e._appCheckCredentials,e._queue,n,e._componentsProvider&&function(e){const t=e?._online.build();return{_offline:e?._offline.build(t),_online:t}}(e._componentsProvider))}function Sh(e,t,n){if((e=H(e,Ih))._firestoreClient||e._terminated)throw new w(_.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.");if(e._componentsProvider||e._getSettings().localCache)throw new w(_.FAILED_PRECONDITION,"SDK cache is already specified.");e._componentsProvider={_online:t,_offline:n},Th(e)}class Ah{constructor(e){this._byteString=e}static fromBase64String(e){try{return new Ah(an.fromBase64String(e))}catch(e){throw new w(_.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+e)}}static fromUint8Array(e){return new Ah(an.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)}toJSON(){return{type:Ah._jsonSchemaVersion,bytes:this.toBase64()}}static fromJSON(e){if(J(e,Ah._jsonSchema))return Ah.fromBase64String(e.bytes)}}Ah._jsonSchemaVersion="firestore/bytes/1.0",Ah._jsonSchema={type:Q("string",Ah._jsonSchemaVersion),bytes:Q("string")};class Oh{constructor(...e){for(let t=0;t<e.length;++t)if(0===e[t].length)throw new w(_.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new U(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}}class Ph{constructor(e){this._methodName=e}}class Ch{constructor(e,t){if(!isFinite(e)||e<-90||e>90)throw new w(_.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(t)||t<-180||t>180)throw new w(_.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}_compareTo(e){return k(this._lat,e._lat)||k(this._long,e._long)}toJSON(){return{latitude:this._lat,longitude:this._long,type:Ch._jsonSchemaVersion}}static fromJSON(e){if(J(e,Ch._jsonSchema))return new Ch(e.latitude,e.longitude)}}Ch._jsonSchemaVersion="firestore/geoPoint/1.0",Ch._jsonSchema={type:Q("string",Ch._jsonSchemaVersion),latitude:Q("number"),longitude:Q("number")};class Rh{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)}toJSON(){return{type:Rh._jsonSchemaVersion,vectorValues:this._values}}static fromJSON(e){if(J(e,Rh._jsonSchema)){if(Array.isArray(e.vectorValues)&&e.vectorValues.every(e=>"number"==typeof e))return new Rh(e.vectorValues);throw new w(_.INVALID_ARGUMENT,"Expected 'vectorValues' field to be a number array")}}}Rh._jsonSchemaVersion="firestore/vectorValue/1.0",Rh._jsonSchema={type:Q("string",Rh._jsonSchemaVersion),vectorValues:Q("object")};const kh=/^__.*__$/;class Nh{constructor(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}toMutation(e,t){return null!==this.fieldMask?new Li(e,this.data,this.fieldMask,t,this.fieldTransforms):new Mi(e,this.data,t,this.fieldTransforms)}}class xh{constructor(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}toMutation(e,t){return new Li(e,this.data,this.fieldMask,t,this.fieldTransforms)}}function Dh(e){switch(e){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw g(40011,{dataSource:e})}}class Mh{constructor(e,t,n,r,i,o){this.settings=e,this.databaseId=t,this.serializer=n,this.ignoreUndefinedProperties=r,void 0===i&&this.validatePath(),this.fieldTransforms=i||[],this.fieldMask=o||[]}get path(){return this.settings.path}get dataSource(){return this.settings.dataSource}contextWith(e){return new Mh({...this.settings,...e},this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}childContextForField(e){const t=this.path?.child(e),n=this.contextWith({path:t,arrayElement:!1});return n.validatePathSegment(e),n}childContextForFieldPath(e){const t=this.path?.child(e),n=this.contextWith({path:t,arrayElement:!1});return n.validatePath(),n}childContextForArray(e){return this.contextWith({path:void 0,arrayElement:!0})}createError(e){return Jh(e,this.settings.methodName,this.settings.hasConverter||!1,this.path,this.settings.targetDoc)}contains(e){return void 0!==this.fieldMask.find(t=>e.isPrefixOf(t))||void 0!==this.fieldTransforms.find(t=>e.isPrefixOf(t.field))}validatePath(){if(this.path)for(let e=0;e<this.path.length;e++)this.validatePathSegment(this.path.get(e))}validatePathSegment(e){if(0===e.length)throw this.createError("Document fields must not be empty");if(Dh(this.dataSource)&&kh.test(e))throw this.createError('Document fields cannot begin and end with "__"')}}class Lh{constructor(e,t,n){this.databaseId=e,this.ignoreUndefinedProperties=t,this.serializer=n||Kc(e)}createContext(e,t,n,r=!1){return new Mh({dataSource:e,methodName:t,targetDoc:n,path:U.emptyPath(),arrayElement:!1,hasConverter:r},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}}class jh extends Ph{_toFieldTransform(e){if(2!==e.dataSource)throw 1===e.dataSource?e.createError(`${this._methodName}() can only appear at the top level of your update data`):e.createError(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return e.fieldMask.push(e.path),null}isEqual(e){return e instanceof jh}}function Fh(e,t,n){return new Mh({dataSource:3,targetDoc:t.settings.targetDoc,methodName:e._methodName,arrayElement:n},t.databaseId,t.serializer,t.ignoreUndefinedProperties)}class Vh extends Ph{_toFieldTransform(e){return new Si(e.path,new yi)}isEqual(e){return e instanceof Vh}}class Uh extends Ph{constructor(e,t){super(e),this.Ac=t}_toFieldTransform(e){const t=Fh(this,e,!0),n=this.Ac.map(e=>zh(e,t)),r=new vi(n);return new Si(e.path,r)}isEqual(e){return e instanceof Uh&&i.deepEqual(this.Ac,e.Ac)}}class qh extends Ph{constructor(e,t){super(e),this.Ac=t}_toFieldTransform(e){const t=Fh(this,e,!0),n=this.Ac.map(e=>zh(e,t)),r=new _i(n);return new Si(e.path,r)}isEqual(e){return e instanceof qh&&i.deepEqual(this.Ac,e.Ac)}}class Bh extends Ph{constructor(e,t){super(e),this.Vc=t}_toFieldTransform(e){const t=new Ii(e.serializer,di(e.serializer,this.Vc));return new Si(e.path,t)}isEqual(e){return e instanceof Bh&&this.Vc===e.Vc}}function zh(e,t){if(Gh(e=i.getModularInstance(e)))return Kh("Unsupported field value:",t,e),Wh(e,t);if(e instanceof Ph)return function(e,t){if(!Dh(t.dataSource))throw t.createError(`${e._methodName}() can only be used with update() and set()`);if(!t.path)throw t.createError(`${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.arrayElement&&4!==t.dataSource)throw t.createError("Nested arrays are not supported");return function(e,t){const n=[];let r=0;for(const i of e){let e=zh(i,t.childContextForArray(r));null==e&&(e={nullValue:"NULL_VALUE"}),n.push(e),r++}return{arrayValue:{values:n}}}(e,t)}return function(e,t){if(null===(e=i.getModularInstance(e)))return{nullValue:"NULL_VALUE"};if("number"==typeof e)return di(t.serializer,e);if("boolean"==typeof e)return{booleanValue:e};if("string"==typeof e)return{stringValue:e};if(e instanceof Date){const n=Z.fromDate(e);return{timestampValue:bo(t.serializer,n)}}if(e instanceof Z){const n=new Z(e.seconds,1e3*Math.floor(e.nanoseconds/1e3));return{timestampValue:bo(t.serializer,n)}}if(e instanceof Ch)return{geoPointValue:{latitude:e.latitude,longitude:e.longitude}};if(e instanceof Ah)return{bytesValue:_o(t.serializer,e._byteString)};if(e instanceof gh){const n=t.databaseId,r=e.firestore._databaseId;if(!r.isEqual(n))throw t.createError(`Document reference is for database ${r.projectId}/${r.database} but should be for database ${n.projectId}/${n.database}`);return{referenceValue:Eo(e.firestore._databaseId||t.databaseId,e._key.path)}}if(e instanceof Rh)return function(e,t){const n=e instanceof Rh?e.toArray():e,r={fields:{[In]:{stringValue:Sn},[An]:{arrayValue:{values:n.map(e=>{if("number"!=typeof e)throw t.createError("VectorValues must only contain numeric values.");return li(t.serializer,e)})}}}};return{mapValue:r}}(e,t);if(Jo(e))return e._toProto(t.serializer);throw t.createError(`Unsupported field value: ${$(e)}`)}(e,t)}function Wh(e,t){const n={};return Yt(e)?t.path&&t.path.length>0&&t.fieldMask.push(t.path):Qt(e,(e,r)=>{const i=zh(r,t.childContextForField(e));null!=i&&(n[e]=i)}),{mapValue:{fields:n}}}function Gh(e){return!("object"!=typeof e||null===e||e instanceof Array||e instanceof Date||e instanceof Z||e instanceof Ch||e instanceof Ah||e instanceof gh||e instanceof Ph||e instanceof Rh||Jo(e))}function Kh(e,t,n){if(!Gh(n)||!K(n)){const r=$(n);throw"an object"===r?t.createError(e+" a custom object"):t.createError(e+" "+r)}}function $h(e,t,n){if((t=i.getModularInstance(t))instanceof Oh)return t._internalPath;if("string"==typeof t)return Qh(e,t);throw Jh("Field path arguments must be of type string or ",e,!1,void 0,n)}const Hh=new RegExp("[~\\*/\\[\\]]");function Qh(e,t,n){if(t.search(Hh)>=0)throw Jh(`Invalid field path (${t}). Paths must not contain '~', '*', '/', '[', or ']'`,e,!1,void 0,n);try{return new Oh(...t.split("."))._internalPath}catch(r){throw Jh(`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,e,!1,void 0,n)}}function Jh(e,t,n,r,i){const o=r&&!r.isEmpty(),s=void 0!==i;let a=`Function ${t}() called with invalid data`;n&&(a+=" (via `toFirestore()`)"),a+=". ";let c="";return(o||s)&&(c+=" (found",o&&(c+=` in field ${r}`),s&&(c+=` in document ${i}`),c+=")"),new w(_.INVALID_ARGUMENT,a+e+c)}function Yh(e,t){return e.some(e=>e.isEqual(t))}class Xh{convertValue(e,t="none"){switch(Pn(e)){case 0:return null;case 1:return e.booleanValue;case 2:return ln(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(hn(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 g(62114,{value:e})}}convertObject(e,t){return this.convertObjectMap(e.fields,t)}convertObjectMap(e,t="none"){const n={};return Qt(e,(e,r)=>{n[e]=this.convertValue(r,t)}),n}convertVectorValue(e){const t=e.fields?.[An].arrayValue?.values?.map(e=>ln(e.doubleValue));return new Rh(t)}convertGeoPoint(e){return new Ch(ln(e.latitude),ln(e.longitude))}convertArray(e,t){return(e.values||[]).map(e=>this.convertValue(e,t))}convertServerTimestamp(e,t){switch(t){case"previous":const n=yn(e);return null==n?null:this.convertValue(n,t);case"estimate":return this.convertTimestamp(vn(e));default:return null}}convertTimestamp(e){const t=un(e);return new Z(t.seconds,t.nanos)}convertDocumentKey(e,t){const n=F.fromString(e);v(Qo(n),9688,{name:e});const r=new wn(n.get(1),n.get(3)),i=new q(n.popFirst(5));return r.isEqual(t)||f(`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}}class Zh{constructor(e){this.optionDefinitions=e}_getKnownOptions(e,t){const n=Yn.empty();for(const r in this.optionDefinitions)if(this.optionDefinitions.hasOwnProperty(r)){const i=this.optionDefinitions[r];if(r in e){const o=e[r];let s;i.nestedOptions&&K(o)?s={mapValue:{fields:new Zh(i.nestedOptions).getOptionsProto(t,o)}}:o&&(s=zh(o,t)??void 0),s&&n.set(U.fromServerFormat(i.serverName),s)}}return n}getOptionsProto(e,t,n){const r=this._getKnownOptions(t,e);if(n){const t=new Map(Jt(n,(t,n)=>[U.fromServerFormat(n),void 0!==t?zh(t,e):null]));r.setAll(t)}return r.value.mapValue.fields??{}}}class ed{constructor(e={},t={}){this.dc=e,this.mc=t,this.fc=new Zh({indexMode:{serverName:"index_mode"}})}_readUserData(e){this.proto=this.fc.getOptionsProto(e,this.dc,this.mc)}}class td{constructor(e,t){this.pipeline=e,this.options=t}_toProto(e){return{pipeline:this.pipeline._toProto(e),options:this.options.proto}}}t.AbstractUserDataWriter=Xh,t.Bound=er,t.ByteString=an,t.Bytes=Ah,t.C=_,t.CollectionReference=yh,t.CompositeFilter=ar,t.DatabaseId=wn,t.DocumentKey=q,t.DocumentReference=gh,t.DocumentSet=Mu,t.FieldFilter=sr,t.FieldIndex=ne,t.FieldPath=Oh,t.FieldPath$1=U,t.FieldValue=Ph,t.Firestore=Ih,t.FirestoreError=w,t.GeoPoint=Ch,t.IndexSegment=se,t.IndexState=ce,t.LoadBundleTask=wh,t.M=L,t.ObjectValue=Yn,t.OnlineComponentProvider=ql,t.OptionsUtil=Zh,t.OrderBy=rr,t.Precondition=Oi,t.Query=mh,t.ResourcePath=F,t.StructuredPipeline=td,t.Timestamp=Z,t.UserDataReader=Lh,t.VectorValue=Rh,t.ViewSnapshot=ju,t.__PRIVATE_AggregateImpl=Gi,t.__PRIVATE_AutoId=R,t.__PRIVATE_BundleLoader=Yu,t.__PRIVATE_DeleteMutation=Ui,t.__PRIVATE_EmptyAppCheckTokenProvider=class{getToken(){return Promise.resolve(new P(""))}invalidateToken(){}start(e,t){}shutdown(){}},t.__PRIVATE_EmptyAuthCredentialsProvider=T,t.__PRIVATE_ExpUserDataWriter=class extends Xh{constructor(e){super(),this.firestore=e}convertBytes(e){return new Ah(e)}convertReference(e){const t=this.convertDocumentKey(e,this.firestore._databaseId);return new gh(this.firestore,null,t)}},t.__PRIVATE_FirebaseAppCheckTokenProvider=class{constructor(e,t){this.V=t,this.forceRefresh=!1,this.appCheck=null,this.m=null,this.p=null,r._isFirebaseServerApp(e)&&e.settings.appCheckToken&&(this.p=e.settings.appCheckToken)}start(e,t){v(void 0===this.o,3512);const n=e=>{null!=e.error&&d("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${e.error.message}`);const n=e.token!==this.m;return this.m=e.token,d("FirebaseAppCheckTokenProvider",`Received ${n?"new":"existing"} token.`),n?t(e.token):Promise.resolve()};this.o=t=>{e.enqueueRetryable(()=>n(t))};const r=e=>{d("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=e,this.o&&this.appCheck.addTokenListener(this.o)};this.V.onInit(e=>r(e)),setTimeout(()=>{if(!this.appCheck){const e=this.V.getImmediate({optional:!0});e?r(e):d("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}},0)}getToken(){if(this.p)return Promise.resolve(new P(this.p));const e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then(e=>e?(v("string"==typeof e.token,44558,{tokenResult:e}),this.m=e.token,new P(e.token)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.o&&this.appCheck.removeTokenListener(this.o),this.o=void 0}},t.__PRIVATE_FirebaseAuthCredentialsProvider=class{constructor(e){this.t=e,this.currentUser=c.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,t){v(void 0===this.o,42304);let n=this.i;const r=e=>this.i!==n?(n=this.i,t(e)):Promise.resolve();let i=new I;this.o=()=>{this.i++,this.currentUser=this.u(),i.resolve(),i=new I,e.enqueueRetryable(()=>r(this.currentUser))};const o=()=>{const t=i;e.enqueueRetryable(async()=>{await t.promise,await r(this.currentUser)})},s=e=>{d("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=e,this.o&&(this.auth.addAuthTokenListener(this.o),o())};this.t.onInit(e=>s(e)),setTimeout(()=>{if(!this.auth){const e=this.t.getImmediate({optional:!0});e?s(e):(d("FirebaseAuthCredentialsProvider","Auth not yet detected"),i.resolve(),i=new I)}},0),o()}getToken(){const e=this.i,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then(t=>this.i!==e?(d("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):t?(v("string"==typeof t.accessToken,31837,{l:t}),new E(t.accessToken,this.currentUser)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.o&&this.auth.removeAuthTokenListener(this.o),this.o=void 0}u(){const e=this.auth&&this.auth.getUid();return v(null===e||"string"==typeof e,2055,{h:e}),new c(e)}},t.__PRIVATE_IndexedDbOfflineComponentProvider=Vl,t.__PRIVATE_LruGcMemoryOfflineComponentProvider=Fl,t.__PRIVATE_MemoryOfflineComponentProvider=jl,t.__PRIVATE_MultiTabOfflineComponentProvider=Ul,t.__PRIVATE_StructuredPipelineOptions=ed,t.__PRIVATE_cast=H,t.__PRIVATE_createBundleReaderSync=function(e,t){return function(e,t){return new Gl(e,t)}(e,t)},t.__PRIVATE_databaseIdFromApp=function(e,t){if(!Object.prototype.hasOwnProperty.apply(e.options,["projectId"]))throw new w(_.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new wn(e.options.projectId,t)},t.__PRIVATE_debugAssert=function(e,t){e||g(57014,t)},t.__PRIVATE_documentKeySet=ai,t.__PRIVATE_fieldPathFromArgument=$h,t.__PRIVATE_fieldPathFromDotSeparatedString=Qh,t.__PRIVATE_firestoreClientAddSnapshotsInSyncListener=function(e,t){const n=new zl(t);return e.asyncQueue.enqueueAndForget(async()=>function(e,t){b(e).Ca.add(t),t.next()}(await oh(e),n)),()=>{n.Nu(),e.asyncQueue.enqueueAndForget(async()=>function(e,t){b(e).Ca.delete(t)}(await oh(e),n))}},t.__PRIVATE_firestoreClientDeleteAllFieldIndexes=function(e){return e.asyncQueue.enqueue(async()=>function(e){const t=b(e),n=t.indexManager;return t.persistence.runTransaction("Delete All Indexes","readwrite",e=>n.deleteAllFieldIndexes(e))}(await th(e)))},t.__PRIVATE_firestoreClientExecutePipeline=function(e,t){const n=new I;return e.asyncQueue.enqueueAndForget(async()=>{try{const r=await ih(e);n.resolve(async function(e,t){const n=b(e),r={database:Ro(n.serializer),structuredPipeline:t._toProto(n.serializer)},i=await n.jo("ExecutePipeline",n.serializer.databaseId,F.emptyPath(),r),o=[];return i.forEach(e=>{if(e.results&&0!==e.results.length)return e.results.forEach(t=>o.push(xo(n.serializer,e,t)));o.push(xo(n.serializer,e))}),o}(r,t))}catch(e){n.reject(e)}}),n.promise},t.__PRIVATE_firestoreClientGetDocumentFromLocalCache=function(e,t){const n=new I;return e.asyncQueue.enqueueAndForget(async()=>async function(e,t,n){try{const r=await function(e,t){const n=b(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 w(_.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=Du(e,`Failed to get document '${t} from cache`);n.reject(r)}}(await th(e),t,n)),n.promise},t.__PRIVATE_firestoreClientGetDocumentViaSnapshotListener=function(e,t,n={}){const r=new I;return e.asyncQueue.enqueueAndForget(async()=>function(e,t,n,r,i){const o=new zl({next:a=>{o.Nu(),t.enqueueAndForget(()=>Bu(e,s));const c=a.docs.has(n);!c&&a.fromCache?i.reject(new w(_.UNAVAILABLE,"Failed to get document because the client is offline.")):c&&a.fromCache&&r&&"server"===r.source?i.reject(new w(_.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(a)},error:e=>i.reject(e)}),s=new Hu(Dr(n.path),o,{includeMetadataChanges:!0,Ka:!0});return qu(e,s)}(await oh(e),e.asyncQueue,t,n,r)),r.promise},t.__PRIVATE_firestoreClientGetDocumentsFromLocalCache=function(e,t){const n=new I;return e.asyncQueue.enqueueAndForget(async()=>async function(e,t,n){try{const r=await dc(e,t,!0),i=new tl(t,r.ks),o=i.ru(r.documents),s=i.applyChanges(o,!1);n.resolve(s.snapshot)}catch(e){const r=Du(e,`Failed to execute query '${t} against cache`);n.reject(r)}}(await th(e),t,n)),n.promise},t.__PRIVATE_firestoreClientGetDocumentsViaSnapshotListener=function(e,t,n={}){const r=new I;return e.asyncQueue.enqueueAndForget(async()=>function(e,t,n,r,i){const o=new zl({next:n=>{o.Nu(),t.enqueueAndForget(()=>Bu(e,s)),n.fromCache&&"server"===r.source?i.reject(new w(_.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)}),s=new Hu(n,o,{includeMetadataChanges:!0,Ka:!0});return qu(e,s)}(await oh(e),e.asyncQueue,t,n,r)),r.promise},t.__PRIVATE_firestoreClientListen=function(e,t,n,r){const i=new zl(r),o=new Hu(t,i,n);return e.asyncQueue.enqueueAndForget(async()=>qu(await oh(e),o)),()=>{i.Nu(),e.asyncQueue.enqueueAndForget(async()=>Bu(await oh(e),o))}},t.__PRIVATE_firestoreClientRunAggregateQuery=function(e,t,n){const r=new I;return e.asyncQueue.enqueueAndForget(async()=>{try{const i=await ih(e);r.resolve(async function(e,t,n){const r=b(e),{request:i,gt:o,parent:s}=Vo(r.serializer,Ur(t),n);r.connection.Ko||delete i.parent;const a=(await r.jo("RunAggregationQuery",r.serializer.databaseId,s,i,1)).filter(e=>!!e.result);v(1===a.length,64727);const c=a[0].result?.aggregateFields;return Object.keys(c).reduce((e,t)=>(e[o[t]]=c[t],e),{})}(i,t,n))}catch(e){r.reject(e)}}),r.promise},t.__PRIVATE_firestoreClientSetIndexConfiguration=function(e,t){return e.asyncQueue.enqueue(async()=>async function(e,t){const n=b(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 o=e.length,s=t.length;let a=0,c=0;for(;a<s&&c<o;){const o=n(e[c],t[a]);o<0?i(e[c++]):o>0?r(t[a++]):(a++,c++)}for(;a<s;)r(t[a++]);for(;c<o;)i(e[c++])}(n,t,oe,t=>{i.push(r.addFieldIndex(e,t))},t=>{i.push(r.deleteFieldIndex(e,t))})).next(()=>ge.waitFor(i)))}(await th(e),t))},t.__PRIVATE_firestoreClientSetPersistentCacheIndexAutoCreationEnabled=function(e,t){return e.asyncQueue.enqueue(async()=>function(e,t){b(e).Cs.As=t}(await th(e),t))},t.__PRIVATE_firestoreClientTransaction=function(e,t,n){const r=new I;return e.asyncQueue.enqueueAndForget(async()=>{const i=await ih(e);new $l(e.asyncQueue,i,n,t,r).ju()}),r.promise},t.__PRIVATE_firestoreClientWrite=function(e,t){const n=new I;return e.asyncQueue.enqueueAndForget(async()=>async function(e,t,n){const r=Ll(e);try{const e=await function(e,t){const n=b(e),r=Z.now(),i=t.reduce((e,t)=>e.add(t.key),ai());let o,s;return n.persistence.runTransaction("Locally write mutations","readwrite",e=>{let a=Xr(),c=ai();return n.xs.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=>{o=i;const s=[];for(const e of t){const t=xi(e,o.get(e.key).overlayedDocument);null!=t&&s.push(new Li(e.key,t,Xn(t.value.mapValue),Oi.exists(!0)))}return n.mutationQueue.addMutationBatch(e,r,s,t)}).next(t=>{s=t;const r=t.applyToLocalDocumentSet(o,c);return n.documentOverlayCache.saveOverlays(e,t.batchId,r)})}).then(()=>({batchId:s.batchId,changes:ti(o)}))}(r.localStore,t);r.sharedClientState.addPendingMutation(e.batchId),function(e,t,n){let r=e.du[e.currentUser.toKey()];r||(r=new Xt(k)),r=r.insert(t,n),e.du[e.currentUser.toKey()]=r}(r,e.batchId,n),await Tl(r,e.changes),await _u(r.remoteStore)}catch(e){const t=Du(e,"Failed to persist write");n.reject(t)}}(await rh(e),t,n)),n.promise},t.__PRIVATE_fromBundledQuery=ss,t.__PRIVATE_fromDocument=Do,t.__PRIVATE_hardAssert=v,t.__PRIVATE_isBase64Available=function(){return"undefined"!=typeof atob},t.__PRIVATE_isCollectionGroupQuery=jr,t.__PRIVATE_isCollectionReference=function(e){return e instanceof yh},t.__PRIVATE_isDocumentQuery$1=Lr,t.__PRIVATE_isNumber$1=function(e){return"number"==typeof e},t.__PRIVATE_isOptionalEqual=function(e,t,n){return void 0===e&&void 0===t||void 0!==e&&void 0!==t&&n(e,t)},t.__PRIVATE_isPlainObject=K,t.__PRIVATE_isServerTimestamp=gn,t.__PRIVATE_isString=function(e){return"string"==typeof e},t.__PRIVATE_isUserData=function(e){return"function"==typeof e._readUserData},t.__PRIVATE_logDebug=d,t.__PRIVATE_logWarn=p,t.__PRIVATE_mapToArray=Jt,t.__PRIVATE_newQueryForPath=Dr,t.__PRIVATE_newSerializer=Kc,t.__PRIVATE_newUserDataReader=function(e){const t=e._freezeSettings(),n=Kc(e._databaseId);return new Lh(e._databaseId,!!t.ignoreUndefinedProperties,n)},t.__PRIVATE_parseData=zh,t.__PRIVATE_parseQueryValue=function(e,t,n,r=!1){return zh(n,e.createContext(r?4:3,t))},t.__PRIVATE_parseSetData=function(e,t,n,r,i,o={}){const s=e.createContext(o.merge||o.mergeFields?2:0,t,n,i);Kh("Data must be an object, but it was:",s,r);const a=Wh(r,s);let c,u;if(o.merge)c=new on(s.fieldMask),u=s.fieldTransforms;else if(o.mergeFields){const e=[];for(const r of o.mergeFields){const i=$h(t,r,n);if(!s.contains(i))throw new w(_.INVALID_ARGUMENT,`Field '${i}' is specified in your field mask but missing from your input data.`);Yh(e,i)||e.push(i)}c=new on(e),u=s.fieldTransforms.filter(e=>c.covers(e.field))}else c=null,u=s.fieldTransforms;return new Nh(new Yn(a),c,u)},t.__PRIVATE_parseUpdateData=function(e,t,n,r){const o=e.createContext(1,t,n);Kh("Data must be an object, but it was:",o,r);const s=[],a=Yn.empty();Qt(r,(e,r)=>{const c=Qh(t,e,n);r=i.getModularInstance(r);const u=o.childContextForFieldPath(c);if(r instanceof jh)s.push(c);else{const e=zh(r,u);null!=e&&(s.push(c),a.set(c,e))}});const c=new on(s);return new xh(a,c,o.fieldTransforms)},t.__PRIVATE_parseUpdateVarargs=function(e,t,n,r,o,s){const a=e.createContext(1,t,n),c=[$h(t,r,n)],u=[o];if(s.length%2!=0)throw new w(_.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($h(t,s[e])),u.push(s[e+1]);const l=[],h=Yn.empty();for(let e=c.length-1;e>=0;--e)if(!Yh(l,c[e])){const t=c[e];let n=u[e];n=i.getModularInstance(n);const r=a.childContextForFieldPath(t);if(n instanceof jh)l.push(t);else{const e=zh(n,r);null!=e&&(l.push(t),h.set(t,e))}}const d=new on(l);return new xh(h,d,a.fieldTransforms)},t.__PRIVATE_queryNormalizedOrderBy=Fr,t.__PRIVATE_queryWithAddedFilter=function(e,t){const n=e.filters.concat([t]);return new Nr(e.path,e.collectionGroup,e.explicitOrderBy.slice(),n,e.limit,e.limitType,e.startAt,e.endAt)},t.__PRIVATE_queryWithAddedOrderBy=function(e,t){const n=e.explicitOrderBy.concat([t]);return new Nr(e.path,e.collectionGroup,n,e.filters.slice(),e.limit,e.limitType,e.startAt,e.endAt)},t.__PRIVATE_queryWithEndAt=function(e,t){return new Nr(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),e.limit,e.limitType,e.startAt,t)},t.__PRIVATE_queryWithLimit=Br,t.__PRIVATE_queryWithStartAt=function(e,t){return new Nr(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),e.limit,e.limitType,t,e.endAt)},t.__PRIVATE_refValue=jn,t.__PRIVATE_setSDKVersion=function(e){u=e},t.__PRIVATE_setTestingHooksSpi=function(e){if(Yi)throw new Error("a TestingHooksSpi instance is already set");Yi=e},t.__PRIVATE_toMapValue=function(e,t){const n={fields:{}};return t.forEach((t,r)=>{if("string"!=typeof r)throw new Error(`Cannot encode map with non-string key: ${r}`);n.fields[r]=t._toProto(e)}),{mapValue:n}},t.__PRIVATE_toPipelineValue=function(e){return{pipelineValue:e}},t.__PRIVATE_toStringValue=function(e){return{stringValue:e}},t.__PRIVATE_validateIsNotUsedTogether=z,t.__PRIVATE_validateJSON=J,t.__PRIVATE_validatePositiveNumber=function(e,t){if(t<=0)throw new w(_.INVALID_ARGUMENT,`Function ${e}() requires a positive number, but it was: ${t}.`)},t.__PRIVATE_valueDescription=$,t._internalAggregationQueryToProtoRunAggregationQueryRequest=function(e,t){const n=Jt(t,(e,t)=>new Gi(t,e.aggregateType,e._internalFieldPath)),r=Eh(H(e.firestore,Ih)),i=r._onlineComponents?.datastore.serializer;return void 0===i?null:Vo(i,Ur(e._query),n,!0).request},t._internalPipelineToExecutePipelineRequestProto=function(e){const t=function(e){if(e._terminated)throw new w(_.FAILED_PRECONDITION,"The client has already been terminated.");if(!ch.has(e)){d(ah,"Initializing Datastore");const t=zc(uh(e._databaseId,e.app.options.appId||"",e._persistenceKey,e.app.options.apiKey,e._freezeSettings())),n=Kc(e._databaseId),r=eu(e._authCredentials,e._appCheckCredentials,t,n);ch.set(e,r)}return ch.get(e)}(H(e._db,Ih)).serializer;if(void 0===t)return null;const n=new td(e,new ed);return{database:Ro(t),structuredPipeline:n._toProto(t)}},t._internalQueryToProtoQueryTarget=function(e){const t=Eh(H(e.firestore,Ih)),n=t._onlineComponents?.datastore.serializer;return void 0===n?null:Fo(n,Vr(e._query)).ft},t.arrayRemove=function(...e){return new qh("arrayRemove",e)},t.arrayUnion=function(...e){return new Uh("arrayUnion",e)},t.clearIndexedDbPersistence=function(e){if(e._initialized&&!e._terminated)throw new w(_.FAILED_PRECONDITION,"Persistence can only be cleared before a Firestore instance is initialized or after it is terminated.");const t=new I;return e._queue.enqueueAndForgetEvenWhileRestricted(async()=>{try{await async function(e){if(!be.v())return Promise.resolve();const t=e+Qa;await be.delete(t)}(Za(e._databaseId,e._persistenceKey)),t.resolve()}catch(e){t.reject(e)}}),t.promise},t.collection=function(e,t,...n){if(e=i.getModularInstance(e),B("collection","path",t),e instanceof fh){const r=F.fromString(t,...n);return G(r),new yh(e,null,r)}{if(!(e instanceof gh||e instanceof yh))throw new w(_.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=e._path.child(F.fromString(t,...n));return G(r),new yh(e.firestore,null,r)}},t.collectionGroup=function(e,t){if(e=H(e,fh),B("collectionGroup","collection id",t),t.indexOf("/")>=0)throw new w(_.INVALID_ARGUMENT,`Invalid collection ID '${t}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);return new mh(e,null,function(e){return new Nr(F.emptyPath(),e)}(t))},t.connectFirestoreEmulator=ph,t.deleteField=function(){return new jh("deleteField")},t.disableNetwork=function(e){return function(e){return e.asyncQueue.enqueue(async()=>{const t=await eh(e),n=await nh(e);return t.setNetworkEnabled(!1),async function(e){const t=b(e);t.Ea.add(0),await ou(t),t.Va.set("Offline")}(n)})}(Eh(e=H(e,Ih)))},t.doc=function(e,t,...n){if(e=i.getModularInstance(e),1===arguments.length&&(t=R.newId()),B("doc","path",t),e instanceof fh){const r=F.fromString(t,...n);return W(r),new gh(e,null,new q(r))}{if(!(e instanceof gh||e instanceof yh))throw new w(_.INVALID_ARGUMENT,"Expected first argument to doc() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=e._path.child(F.fromString(t,...n));return W(r),new gh(e.firestore,e instanceof yh?e.converter:null,new q(r))}},t.documentId=function(){return new Oh(L)},t.enableIndexedDbPersistence=function(e,t){p("enableIndexedDbPersistence() will be deprecated in the future, you can use `FirestoreSettings.cache` instead.");const n=e._freezeSettings();return Sh(e,ql.provider,{build:e=>new Vl(e,n.cacheSizeBytes,t?.forceOwnership)}),Promise.resolve()},t.enableMultiTabIndexedDbPersistence=async function(e){p("enableMultiTabIndexedDbPersistence() will be deprecated in the future, you can use `FirestoreSettings.cache` instead.");const t=e._freezeSettings();Sh(e,ql.provider,{build:e=>new Ul(e,t.cacheSizeBytes)})},t.enableNetwork=function(e){return function(e){return e.asyncQueue.enqueue(async()=>{const t=await eh(e),n=await nh(e);return t.setNetworkEnabled(!0),function(e){const t=b(e);return t.Ea.delete(0),iu(t)}(n)})}(Eh(e=H(e,Ih)))},t.ensureFirestoreConfigured=Eh,t.fail=g,t.getFirestore=function(e,t){const n="object"==typeof e?e:r.getApp(),o="string"==typeof e?e:t||_n,s=r._getProvider(n,"firestore").getImmediate({identifier:o});if(!s._initialized){const e=i.getDefaultEmulatorHostnameAndPort("firestore");e&&ph(s,...e)}return s},t.increment=function(e){return new Bh("increment",e)},t.initializeFirestore=function(e,t,n){n||(n=_n);const o=r._getProvider(e,"firestore");if(o.isInitialized(n)){const e=o.getImmediate({identifier:n}),r=o.getOptions(n);if(i.deepEqual(r,t))return e;throw new w(_.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 w(_.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<ha)throw new w(_.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");return t.host&&i.isCloudWorkstation(t.host)&&i.pingServer(t.host),o.initialize({options:t,instanceIdentifier:n})},t.loadBundle=function(e,t){const n=Eh(e=H(e,Ih)),r=new wh;return function(e,t,n,r){const i=function(e,t){let n;return n="string"==typeof e?Xi().encode(e):e,function(e,t){return new Wl(e,t)}(function(e,t){if(e instanceof Uint8Array)return Bl(e,t);if(e instanceof ArrayBuffer)return Bl(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,Kc(t));e.asyncQueue.enqueueAndForget(async()=>{!function(e,t,n){const r=b(e);(async function(e,t,n){try{const r=await t.getMetadata();if(await function(e,t){const n=b(e),r=Io(t.createTime);return n.persistence.runTransaction("hasNewerBundle","readonly",e=>n.Pi.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(Xu(r));const i=new Yu(r,t.serializer);let o=await t.Su();for(;o;){const e=await i.Ga(o);e&&n._updateProgress(e),o=await t.Su()}const s=await i.ja(e.localStore);return await Tl(e,s.Ja,void 0),await function(e,t){const n=b(e);return n.persistence.runTransaction("Save bundle","readwrite",e=>n.Pi.saveBundleMetadata(e,t))}(e.localStore,r),n._completeWith(s.progress),Promise.resolve(s.Ha)}catch(e){return p(nl,`Loading bundle failed with ${e}`),n._failWith(e),Promise.resolve(new Set)}})(r,t,n).then(e=>{r.sharedClientState.notifyBundleLoaded(e)})}(await rh(e),i,r)})}(n,e._databaseId,t,r),r},t.namedQuery=function(e,t){return function(e,t){return e.asyncQueue.enqueue(async()=>function(e,t){const n=b(e);return n.persistence.runTransaction("Get named query","readonly",e=>n.Pi.getNamedQuery(e,t))}(await th(e),t))}(Eh(e=H(e,Ih)),t).then(t=>t?new mh(e,null,t.query):null)},t.on=-1,t.property=Q,t.queryEqual=function(e,t){return e=i.getModularInstance(e),t=i.getModularInstance(t),e instanceof mh&&t instanceof mh&&e.firestore===t.firestore&&zr(e._query,t._query)&&e.converter===t.converter},t.refEqual=function(e,t){return e=i.getModularInstance(e),t=i.getModularInstance(t),(e instanceof gh||e instanceof yh)&&(t instanceof gh||t instanceof yh)&&e.firestore===t.firestore&&e.path===t.path&&e.converter===t.converter},t.serverTimestamp=function(){return new Vh("serverTimestamp")},t.setLogLevel=function(e){l.setLogLevel(e)},t.terminate=function(e){return r._removeServiceInstance(e.app,"firestore",e._databaseId.database),e._delete()},t.toNumber=di,t.vector=function(e){return new Rh(e)},t.waitForPendingWrites=function(e){return function(e){const t=new I;return e.asyncQueue.enqueueAndForget(async()=>async function(e,t){const n=b(e);du(n.remoteStore)||d(nl,"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=b(e);return t.persistence.runTransaction("Get highest unacknowledged batch id","readonly",e=>t.mutationQueue.getHighestUnacknowledgedBatchId(e))}(n.localStore);if(e===Ne)return void t.resolve();const r=n.mu.get(e)||[];r.push(t),n.mu.set(e,r)}catch(e){const n=Du(e,"Initialization of waitForPendingWrites() operation failed");t.reject(n)}}(await rh(e),t)),t.promise}(Eh(e=H(e,Ih)))}},1241(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(6199),i=n(5319),o=n(8584),s=n(6336);n(860),n(5844),n(4832);const a="@firebase/firestore",c="4.12.0";function u(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 l{constructor(e="count",t){this._internalFieldPath=t,this.type="AggregateField",this.aggregateType=e}}class h{constructor(e,t,n){this._userDataWriter=t,this._data=n,this.type="AggregateQuerySnapshot",this.query=e}data(){return this._userDataWriter.convertObjectMap(this._data)}_fieldsProto(){return new o.ObjectValue({mapValue:{fields:this._data}}).clone().value.mapValue.fields}}class d{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 o.DocumentReference(this._firestore,this._converter,this._key)}exists(){return null!==this._document}data(){if(this._document){if(this._converter){const e=new f(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(e)}return this._userDataWriter.convertValue(this._document.data.value)}}_fieldsProto(){return this._document?.data.clone().value.mapValue.fields??void 0}get(e){if(this._document){const t=this._document.data.field(o.__PRIVATE_fieldPathFromArgument("DocumentSnapshot.get",e));if(null!==t)return this._userDataWriter.convertValue(t)}}}class f extends d{data(){return super.data()}}function p(e){if("L"===e.limitType&&0===e.explicitOrderBy.length)throw new o.FirestoreError(o.C.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class m{}class g extends m{}class y extends g{constructor(e,t,n){super(),this._field=e,this._op=t,this._value=n,this.type="where"}static _create(e,t,n){return new y(e,t,n)}_apply(e){const t=this._parse(e);return A(e._query,t),new o.Query(e.firestore,e.converter,o.__PRIVATE_queryWithAddedFilter(e._query,t))}_parse(e){const t=o.__PRIVATE_newUserDataReader(e.firestore),n=function(e,t,n,r,i,s,a){let c;if(i.isKeyField()){if("array-contains"===s||"array-contains-any"===s)throw new o.FirestoreError(o.C.INVALID_ARGUMENT,`Invalid Query. You can't perform '${s}' queries on documentId().`);if("in"===s||"not-in"===s){S(a,s);const t=[];for(const n of a)t.push(T(r,e,n));c={arrayValue:{values:t}}}else c=T(r,e,a)}else"in"!==s&&"not-in"!==s&&"array-contains-any"!==s||S(a,s),c=o.__PRIVATE_parseQueryValue(n,"where",a,"in"===s||"not-in"===s);return o.FieldFilter.create(i,s,c)}(e._query,0,t,e.firestore._databaseId,this._field,this._op,this._value);return n}}class v extends m{constructor(e,t){super(),this.type=e,this._queryConstraints=t}static _create(e,t){return new v(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]:o.CompositeFilter.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)A(n,e),n=o.__PRIVATE_queryWithAddedFilter(n,e)}(e._query,t),new o.Query(e.firestore,e.converter,o.__PRIVATE_queryWithAddedFilter(e._query,t)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return"and"===this.type?"and":"or"}}class b extends g{constructor(e,t){super(),this._field=e,this._direction=t,this.type="orderBy"}static _create(e,t){return new b(e,t)}_apply(e){const t=function(e,t,n){if(null!==e.startAt)throw new o.FirestoreError(o.C.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(null!==e.endAt)throw new o.FirestoreError(o.C.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");return new o.OrderBy(t,n)}(e._query,this._field,this._direction);return new o.Query(e.firestore,e.converter,o.__PRIVATE_queryWithAddedOrderBy(e._query,t))}}class _ extends g{constructor(e,t,n){super(),this.type=e,this._limit=t,this._limitType=n}static _create(e,t,n){return new _(e,t,n)}_apply(e){return new o.Query(e.firestore,e.converter,o.__PRIVATE_queryWithLimit(e._query,this._limit,this._limitType))}}class w extends g{constructor(e,t,n){super(),this.type=e,this._docOrFields=t,this._inclusive=n}static _create(e,t,n){return new w(e,t,n)}_apply(e){const t=E(e,this.type,this._docOrFields,this._inclusive);return new o.Query(e.firestore,e.converter,o.__PRIVATE_queryWithStartAt(e._query,t))}}class I extends g{constructor(e,t,n){super(),this.type=e,this._docOrFields=t,this._inclusive=n}static _create(e,t,n){return new I(e,t,n)}_apply(e){const t=E(e,this.type,this._docOrFields,this._inclusive);return new o.Query(e.firestore,e.converter,o.__PRIVATE_queryWithEndAt(e._query,t))}}function E(e,t,n,r){if(n[0]=s.getModularInstance(n[0]),n[0]instanceof d)return function(e,t,n,r,i){if(!r)throw new o.FirestoreError(o.C.NOT_FOUND,`Can't use a DocumentSnapshot that doesn't exist for ${n}().`);const s=[];for(const n of o.__PRIVATE_queryNormalizedOrderBy(e))if(n.field.isKeyField())s.push(o.__PRIVATE_refValue(t,r.key));else{const e=r.data.field(n.field);if(o.__PRIVATE_isServerTimestamp(e))throw new o.FirestoreError(o.C.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 o.FirestoreError(o.C.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 o.Bound(s,i)}(e._query,e.firestore._databaseId,t,n[0]._document,r);{const i=o.__PRIVATE_newUserDataReader(e.firestore);return function(e,t,n,r,i,s){const a=e.explicitOrderBy;if(i.length>a.length)throw new o.FirestoreError(o.C.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 c=[];for(let s=0;s<i.length;s++){const u=i[s];if(a[s].field.isKeyField()){if("string"!=typeof u)throw new o.FirestoreError(o.C.INVALID_ARGUMENT,`Invalid query. Expected a string for document ID in ${r}(), but got a ${typeof u}`);if(!o.__PRIVATE_isCollectionGroupQuery(e)&&-1!==u.indexOf("/"))throw new o.FirestoreError(o.C.INVALID_ARGUMENT,`Invalid query. When querying a collection and ordering by documentId(), the value passed to ${r}() must be a plain document ID, but '${u}' contains a slash.`);const n=e.path.child(o.ResourcePath.fromString(u));if(!o.DocumentKey.isDocumentKey(n))throw new o.FirestoreError(o.C.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 o.DocumentKey(n);c.push(o.__PRIVATE_refValue(t,i))}else{const e=o.__PRIVATE_parseQueryValue(n,r,u);c.push(e)}}return new o.Bound(c,s)}(e._query,e.firestore._databaseId,i,t,n,r)}}function T(e,t,n){if("string"==typeof(n=s.getModularInstance(n))){if(""===n)throw new o.FirestoreError(o.C.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!o.__PRIVATE_isCollectionGroupQuery(t)&&-1!==n.indexOf("/"))throw new o.FirestoreError(o.C.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(o.ResourcePath.fromString(n));if(!o.DocumentKey.isDocumentKey(r))throw new o.FirestoreError(o.C.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 o.__PRIVATE_refValue(e,new o.DocumentKey(r))}if(n instanceof o.DocumentReference)return o.__PRIVATE_refValue(e,n._key);throw new o.FirestoreError(o.C.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${o.__PRIVATE_valueDescription(n)}.`)}function S(e,t){if(!Array.isArray(e)||0===e.length)throw new o.FirestoreError(o.C.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${t.toString()}' filters.`)}function A(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 o.FirestoreError(o.C.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${t.op.toString()}' filter.`):new o.FirestoreError(o.C.INVALID_ARGUMENT,`Invalid query. You cannot use '${t.op.toString()}' filters with '${n.toString()}' filters.`)}function O(e,t){if(!(t instanceof y||t instanceof v))throw new o.FirestoreError(o.C.INVALID_ARGUMENT,`Function ${e}() requires AppliableConstraints created with a call to 'where(...)', 'or(...)', or 'and(...)'.`)}function P(e,t,n){let r;return r=e?n&&(n.merge||n.mergeFields)?e.toFirestore(t,n):e.toFirestore(t):t,r}class C extends o.AbstractUserDataWriter{constructor(e){super(),this.firestore=e}convertBytes(e){return new o.Bytes(e)}convertReference(e){const t=this.convertDocumentKey(e,this.firestore._databaseId);return new o.DocumentReference(this.firestore,null,t)}}function R(){return new l("count")}function k(e,t){const n=o.__PRIVATE_cast(e.firestore,o.Firestore),r=o.ensureFirestoreConfigured(n),i=o.__PRIVATE_mapToArray(t,(e,t)=>new o.__PRIVATE_AggregateImpl(t,e.aggregateType,e._internalFieldPath));return o.__PRIVATE_firestoreClientRunAggregateQuery(r,e._query,i).then(t=>function(e,t,n){const r=new o.__PRIVATE_ExpUserDataWriter(e);return new h(t,r,n)}(n,e,t))}class N{constructor(e){this.kind="memory",this._onlineComponentProvider=o.OnlineComponentProvider.provider,this._offlineComponentProvider=e?.garbageCollector?e.garbageCollector._offlineComponentProvider:{build:()=>new o.__PRIVATE_LruGcMemoryOfflineComponentProvider(void 0)}}toJSON(){return{kind:this.kind}}}class x{constructor(e){let t;this.kind="persistent",e?.tabManager?(e.tabManager._initialize(e),t=e.tabManager):(t=F(void 0),t._initialize(e)),this._onlineComponentProvider=t._onlineComponentProvider,this._offlineComponentProvider=t._offlineComponentProvider}toJSON(){return{kind:this.kind}}}class D{constructor(){this.kind="memoryEager",this._offlineComponentProvider=o.__PRIVATE_MemoryOfflineComponentProvider.provider}toJSON(){return{kind:this.kind}}}class M{constructor(e){this.kind="memoryLru",this._offlineComponentProvider={build:()=>new o.__PRIVATE_LruGcMemoryOfflineComponentProvider(e)}}toJSON(){return{kind:this.kind}}}class L{constructor(e){this.forceOwnership=e,this.kind="persistentSingleTab"}toJSON(){return{kind:this.kind}}_initialize(e){this._onlineComponentProvider=o.OnlineComponentProvider.provider,this._offlineComponentProvider={build:t=>new o.__PRIVATE_IndexedDbOfflineComponentProvider(t,e?.cacheSizeBytes,this.forceOwnership)}}}class j{constructor(){this.kind="PersistentMultipleTab"}toJSON(){return{kind:this.kind}}_initialize(e){this._onlineComponentProvider=o.OnlineComponentProvider.provider,this._offlineComponentProvider={build:t=>new o.__PRIVATE_MultiTabOfflineComponentProvider(t,e?.cacheSizeBytes)}}}function F(e){return new L(e?.forceOwnership)}const V="NOT SUPPORTED";class U{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}}class q extends d{constructor(e,t,n,r,i,o){super(e,t,n,r,o),this._firestore=e,this._firestoreImpl=e,this.metadata=i}exists(){return super.exists()}data(e={}){if(this._document){if(this._converter){const t=new B(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(o.__PRIVATE_fieldPathFromArgument("DocumentSnapshot.get",e));if(null!==n)return this._userDataWriter.convertValue(n,t.serverTimestamps)}}toJSON(){if(this.metadata.hasPendingWrites)throw new o.FirestoreError(o.C.FAILED_PRECONDITION,"DocumentSnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");const e=this._document,t={};return t.type=q._jsonSchemaVersion,t.bundle="",t.bundleSource="DocumentSnapshot",t.bundleName=this._key.toString(),e&&e.isValidDocument()&&e.isFoundDocument()?(this._userDataWriter.convertObjectMap(e.data.value.mapValue.fields,"previous"),t.bundle=(this._firestore,this.ref.path,"NOT SUPPORTED"),t):t}}q._jsonSchemaVersion="firestore/documentSnapshot/1.0",q._jsonSchema={type:o.property("string",q._jsonSchemaVersion),bundleSource:o.property("string","DocumentSnapshot"),bundleName:o.property("string"),bundle:o.property("string")};class B extends q{data(e={}){return super.data(e)}}class z{constructor(e,t,n,r){this._firestore=e,this._userDataWriter=t,this._snapshot=r,this.metadata=new U(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 B(this._firestore,this._userDataWriter,n.key,n,new U(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 o.FirestoreError(o.C.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 B(e._firestore,e._userDataWriter,n.doc.key,n.doc,new U(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 B(e._firestore,e._userDataWriter,t.doc.key,t.doc,new U(e._snapshot.mutatedKeys.has(t.doc.key),e._snapshot.fromCache),e.query.converter);let i=-1,o=-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),o=n.indexOf(t.doc.key)),{type:W(t.type),doc:r,oldIndex:i,newIndex:o}})}}(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}toJSON(){if(this.metadata.hasPendingWrites)throw new o.FirestoreError(o.C.FAILED_PRECONDITION,"QuerySnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");const e={};e.type=z._jsonSchemaVersion,e.bundleSource="QuerySnapshot",e.bundleName=o.__PRIVATE_AutoId.newId(),this._firestore._databaseId.database,this._firestore._databaseId.projectId;const t=[],n=[],r=[];return this.docs.forEach(e=>{null!==e._document&&(t.push(e._document),n.push(this._userDataWriter.convertObjectMap(e._document.data.value.mapValue.fields,"previous")),r.push(e.ref.path))}),e.bundle=(this._firestore,this.query._query,e.bundleName,"NOT SUPPORTED"),e}}function W(e){switch(e){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return o.fail(61501,{type:e})}}z._jsonSchemaVersion="firestore/querySnapshot/1.0",z._jsonSchema={type:o.property("string",z._jsonSchemaVersion),bundleSource:o.property("string","QuerySnapshot"),bundleName:o.property("string"),bundle:o.property("string")};const G={maxAttempts:5};class K{constructor(e,t){this._firestore=e,this._commitHandler=t,this._mutations=[],this._committed=!1,this._dataReader=o.__PRIVATE_newUserDataReader(e)}set(e,t,n){this._verifyNotCommitted();const r=$(e,this._firestore),i=P(r.converter,t,n),s=o.__PRIVATE_parseSetData(this._dataReader,"WriteBatch.set",r._key,i,null!==r.converter,n);return this._mutations.push(s.toMutation(r._key,o.Precondition.none())),this}update(e,t,n,...r){this._verifyNotCommitted();const i=$(e,this._firestore);let a;return a="string"==typeof(t=s.getModularInstance(t))||t instanceof o.FieldPath?o.__PRIVATE_parseUpdateVarargs(this._dataReader,"WriteBatch.update",i._key,t,n,r):o.__PRIVATE_parseUpdateData(this._dataReader,"WriteBatch.update",i._key,t),this._mutations.push(a.toMutation(i._key,o.Precondition.exists(!0))),this}delete(e){this._verifyNotCommitted();const t=$(e,this._firestore);return this._mutations=this._mutations.concat(new o.__PRIVATE_DeleteMutation(t._key,o.Precondition.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 o.FirestoreError(o.C.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")}}function $(e,t){if((e=s.getModularInstance(e)).firestore!==t)throw new o.FirestoreError(o.C.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return e}class H{constructor(e,t){this._firestore=e,this._transaction=t,this._dataReader=o.__PRIVATE_newUserDataReader(e)}get(e){const t=$(e,this._firestore),n=new C(this._firestore);return this._transaction.lookup([t._key]).then(e=>{if(!e||1!==e.length)return o.fail(24041);const r=e[0];if(r.isFoundDocument())return new d(this._firestore,n,r.key,r,t.converter);if(r.isNoDocument())return new d(this._firestore,n,t._key,null,t.converter);throw o.fail(18433,{doc:r})})}set(e,t,n){const r=$(e,this._firestore),i=P(r.converter,t,n),s=o.__PRIVATE_parseSetData(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=$(e,this._firestore);let a;return a="string"==typeof(t=s.getModularInstance(t))||t instanceof o.FieldPath?o.__PRIVATE_parseUpdateVarargs(this._dataReader,"Transaction.update",i._key,t,n,r):o.__PRIVATE_parseUpdateData(this._dataReader,"Transaction.update",i._key,t),this._transaction.update(i._key,a),this}delete(e){const t=$(e,this._firestore);return this._transaction.delete(t._key),this}}class Q extends H{constructor(e,t){super(e,t),this._firestore=e}get(e){const t=$(e,this._firestore),n=new o.__PRIVATE_ExpUserDataWriter(this._firestore);return super.get(e).then(e=>new q(this._firestore,n,t._key,e._document,new U(!1,!1),t.converter))}}function J(e,...t){e=s.getModularInstance(e);let n={includeMetadataChanges:!1,source:"default"},r=0;"object"!=typeof t[r]||u(t[r])||(n=t[r++]);const i={includeMetadataChanges:n.includeMetadataChanges,source:n.source};if(u(t[r])){const e=t[r];t[r]=e.next?.bind(e),t[r+1]=e.error?.bind(e),t[r+2]=e.complete?.bind(e)}let a,c,l;if(e instanceof o.DocumentReference)c=o.__PRIVATE_cast(e.firestore,o.Firestore),l=o.__PRIVATE_newQueryForPath(e._key.path),a={next:n=>{t[r]&&t[r](X(c,e,n))},error:t[r+1],complete:t[r+2]};else{const n=o.__PRIVATE_cast(e,o.Query);c=o.__PRIVATE_cast(n.firestore,o.Firestore),l=n._query;const i=new o.__PRIVATE_ExpUserDataWriter(c);a={next:e=>{t[r]&&t[r](new z(c,i,n,e))},error:t[r+1],complete:t[r+2]},p(e._query)}const h=o.ensureFirestoreConfigured(c);return o.__PRIVATE_firestoreClientListen(h,l,i,a)}function Y(e,t){const n=o.ensureFirestoreConfigured(e);return o.__PRIVATE_firestoreClientWrite(n,t)}function X(e,t,n){const r=n.docs.get(t._key),i=new o.__PRIVATE_ExpUserDataWriter(e);return new q(e,i,t._key,r,new U(n.hasPendingWrites,n.fromCache),t.converter)}function Z(e,t){if("string"!=typeof e[t])throw new o.FirestoreError(o.C.INVALID_ARGUMENT,"Missing string value for: "+t);return e[t]}class ee{constructor(e){this._firestore=e,this.type="PersistentCacheIndexManager"}}function te(e,t){const n=o.ensureFirestoreConfigured(e._firestore);o.__PRIVATE_firestoreClientSetPersistentCacheIndexAutoCreationEnabled(n,t).then(e=>o.__PRIVATE_logDebug(`setting persistent cache index auto creation isEnabled=${t} succeeded`)).catch(e=>o.__PRIVATE_logWarn(`setting persistent cache index auto creation isEnabled=${t} failed`,e))}const ne=new WeakMap;class re{constructor(){this.i=new Map}static get instance(){return ie||(ie=new re,o.__PRIVATE_setTestingHooksSpi(ie)),ie}u(e){this.i.forEach(t=>t(e))}onExistenceFilterMismatch(e){const t=Symbol(),n=this.i;return n.set(t,e),()=>n.delete(t)}}let ie=null;!function(e,t=!0){o.__PRIVATE_setSDKVersion(r.SDK_VERSION),r._registerComponent(new i.Component("firestore",(e,{instanceIdentifier:n,options:r})=>{const i=e.getProvider("app").getImmediate(),s=new o.Firestore(new o.__PRIVATE_FirebaseAuthCredentialsProvider(e.getProvider("auth-internal")),new o.__PRIVATE_FirebaseAppCheckTokenProvider(i,e.getProvider("app-check-internal")),o.__PRIVATE_databaseIdFromApp(i,n),i);return r={useFetchStreams:t,...r},s._setSettings(r),s},"PUBLIC").setMultipleInstances(!0)),r.registerVersion(a,c,e),r.registerVersion(a,c,"cjs2020")}(),t.AbstractUserDataWriter=o.AbstractUserDataWriter,t.Bytes=o.Bytes,t.CACHE_SIZE_UNLIMITED=o.on,t.CollectionReference=o.CollectionReference,t.DocumentReference=o.DocumentReference,t.FieldPath=o.FieldPath,t.FieldValue=o.FieldValue,t.Firestore=o.Firestore,t.FirestoreError=o.FirestoreError,t.GeoPoint=o.GeoPoint,t.LoadBundleTask=o.LoadBundleTask,t.Query=o.Query,t.Timestamp=o.Timestamp,t.VectorValue=o.VectorValue,t._AutoId=o.__PRIVATE_AutoId,t._ByteString=o.ByteString,t._DatabaseId=o.DatabaseId,t._DocumentKey=o.DocumentKey,t._EmptyAppCheckTokenProvider=o.__PRIVATE_EmptyAppCheckTokenProvider,t._EmptyAuthCredentialsProvider=o.__PRIVATE_EmptyAuthCredentialsProvider,t._FieldPath=o.FieldPath$1,t._cast=o.__PRIVATE_cast,t._debugAssert=o.__PRIVATE_debugAssert,t._internalAggregationQueryToProtoRunAggregationQueryRequest=o._internalAggregationQueryToProtoRunAggregationQueryRequest,t._internalQueryToProtoQueryTarget=o._internalQueryToProtoQueryTarget,t._isBase64Available=o.__PRIVATE_isBase64Available,t._logWarn=o.__PRIVATE_logWarn,t._validateIsNotUsedTogether=o.__PRIVATE_validateIsNotUsedTogether,t.arrayRemove=o.arrayRemove,t.arrayUnion=o.arrayUnion,t.clearIndexedDbPersistence=o.clearIndexedDbPersistence,t.collection=o.collection,t.collectionGroup=o.collectionGroup,t.connectFirestoreEmulator=o.connectFirestoreEmulator,t.deleteField=o.deleteField,t.disableNetwork=o.disableNetwork,t.doc=o.doc,t.documentId=o.documentId,t.enableIndexedDbPersistence=o.enableIndexedDbPersistence,t.enableMultiTabIndexedDbPersistence=o.enableMultiTabIndexedDbPersistence,t.enableNetwork=o.enableNetwork,t.ensureFirestoreConfigured=o.ensureFirestoreConfigured,t.getFirestore=o.getFirestore,t.increment=o.increment,t.initializeFirestore=o.initializeFirestore,t.loadBundle=o.loadBundle,t.namedQuery=o.namedQuery,t.queryEqual=o.queryEqual,t.refEqual=o.refEqual,t.serverTimestamp=o.serverTimestamp,t.setLogLevel=o.setLogLevel,t.terminate=o.terminate,t.vector=o.vector,t.waitForPendingWrites=o.waitForPendingWrites,t.AggregateField=l,t.AggregateQuerySnapshot=h,t.DocumentSnapshot=q,t.PersistentCacheIndexManager=ee,t.QueryCompositeFilterConstraint=v,t.QueryConstraint=g,t.QueryDocumentSnapshot=B,t.QueryEndAtConstraint=I,t.QueryFieldFilterConstraint=y,t.QueryLimitConstraint=_,t.QueryOrderByConstraint=b,t.QuerySnapshot=z,t.QueryStartAtConstraint=w,t.SnapshotMetadata=U,t.Transaction=Q,t.WriteBatch=K,t._TestingHooks=class{constructor(){throw new Error("instances of this class should not be created")}static onExistenceFilterMismatch(e){return re.instance.onExistenceFilterMismatch(e)}},t.addDoc=function(e,t){const n=o.__PRIVATE_cast(e.firestore,o.Firestore),r=o.doc(e),i=P(e.converter,t),s=o.__PRIVATE_newUserDataReader(e.firestore);return Y(n,[o.__PRIVATE_parseSetData(s,"addDoc",r._key,i,null!==e.converter,{}).toMutation(r._key,o.Precondition.exists(!1))]).then(()=>r)},t.aggregateFieldEqual=function(e,t){return e instanceof l&&t instanceof l&&e.aggregateType===t.aggregateType&&e._internalFieldPath?.canonicalString()===t._internalFieldPath?.canonicalString()},t.aggregateQuerySnapshotEqual=function(e,t){return o.queryEqual(e.query,t.query)&&s.deepEqual(e.data(),t.data())},t.and=function(...e){return e.forEach(e=>O("and",e)),v._create("and",e)},t.average=function(e){return new l("avg",o.__PRIVATE_fieldPathFromArgument("average",e))},t.count=R,t.deleteAllPersistentCacheIndexes=function(e){const t=o.ensureFirestoreConfigured(e._firestore);o.__PRIVATE_firestoreClientDeleteAllFieldIndexes(t).then(e=>o.__PRIVATE_logDebug("deleting all persistent cache indexes succeeded")).catch(e=>o.__PRIVATE_logWarn("deleting all persistent cache indexes failed",e))},t.deleteDoc=function(e){return Y(o.__PRIVATE_cast(e.firestore,o.Firestore),[new o.__PRIVATE_DeleteMutation(e._key,o.Precondition.none())])},t.disablePersistentCacheIndexAutoCreation=function(e){te(e,!1)},t.documentSnapshotFromJSON=function(e,t,n){if(o.__PRIVATE_validateJSON(t,q._jsonSchema)){if(t.bundle===V)throw new o.FirestoreError(o.C.INVALID_ARGUMENT,"The provided JSON object was created in a client environment, which is not supported.");const r=o.__PRIVATE_newSerializer(e._databaseId),i=o.__PRIVATE_createBundleReaderSync(t.bundle,r),s=i.t(),a=new o.__PRIVATE_BundleLoader(i.getMetadata(),r);for(const e of s)a.o(e);const c=a.documents;if(1!==c.length)throw new o.FirestoreError(o.C.INVALID_ARGUMENT,`Expected bundle data to contain 1 document, but it contains ${c.length} documents.`);const u=o.__PRIVATE_fromDocument(r,c[0].document),l=new o.DocumentKey(o.ResourcePath.fromString(t.bundleName));return new q(e,new C(e),l,u,new U(!1,!1),n||null)}},t.enablePersistentCacheIndexAutoCreation=function(e){te(e,!0)},t.endAt=function(...e){return I._create("endAt",e,!0)},t.endBefore=function(...e){return I._create("endBefore",e,!1)},t.executeWrite=Y,t.getAggregateFromServer=k,t.getCountFromServer=function(e){return k(e,{count:R()})},t.getDoc=function(e){e=o.__PRIVATE_cast(e,o.DocumentReference);const t=o.__PRIVATE_cast(e.firestore,o.Firestore),n=o.ensureFirestoreConfigured(t);return o.__PRIVATE_firestoreClientGetDocumentViaSnapshotListener(n,e._key).then(n=>X(t,e,n))},t.getDocFromCache=function(e){e=o.__PRIVATE_cast(e,o.DocumentReference);const t=o.__PRIVATE_cast(e.firestore,o.Firestore),n=o.ensureFirestoreConfigured(t),r=new o.__PRIVATE_ExpUserDataWriter(t);return o.__PRIVATE_firestoreClientGetDocumentFromLocalCache(n,e._key).then(n=>new q(t,r,e._key,n,new U(null!==n&&n.hasLocalMutations,!0),e.converter))},t.getDocFromServer=function(e){e=o.__PRIVATE_cast(e,o.DocumentReference);const t=o.__PRIVATE_cast(e.firestore,o.Firestore),n=o.ensureFirestoreConfigured(t);return o.__PRIVATE_firestoreClientGetDocumentViaSnapshotListener(n,e._key,{source:"server"}).then(n=>X(t,e,n))},t.getDocs=function(e){e=o.__PRIVATE_cast(e,o.Query);const t=o.__PRIVATE_cast(e.firestore,o.Firestore),n=o.ensureFirestoreConfigured(t),r=new o.__PRIVATE_ExpUserDataWriter(t);return p(e._query),o.__PRIVATE_firestoreClientGetDocumentsViaSnapshotListener(n,e._query).then(n=>new z(t,r,e,n))},t.getDocsFromCache=function(e){e=o.__PRIVATE_cast(e,o.Query);const t=o.__PRIVATE_cast(e.firestore,o.Firestore),n=o.ensureFirestoreConfigured(t),r=new o.__PRIVATE_ExpUserDataWriter(t);return o.__PRIVATE_firestoreClientGetDocumentsFromLocalCache(n,e._query).then(n=>new z(t,r,e,n))},t.getDocsFromServer=function(e){e=o.__PRIVATE_cast(e,o.Query);const t=o.__PRIVATE_cast(e.firestore,o.Firestore),n=o.ensureFirestoreConfigured(t),r=new o.__PRIVATE_ExpUserDataWriter(t);return o.__PRIVATE_firestoreClientGetDocumentsViaSnapshotListener(n,e._query,{source:"server"}).then(n=>new z(t,r,e,n))},t.getPersistentCacheIndexManager=function(e){e=o.__PRIVATE_cast(e,o.Firestore);const t=ne.get(e);if(t)return t;const n=o.ensureFirestoreConfigured(e);if("persistent"!==n._uninitializedComponentsProvider?._offline.kind)return null;const r=new ee(e);return ne.set(e,r),r},t.limit=function(e){return o.__PRIVATE_validatePositiveNumber("limit",e),_._create("limit",e,"F")},t.limitToLast=function(e){return o.__PRIVATE_validatePositiveNumber("limitToLast",e),_._create("limitToLast",e,"L")},t.memoryEagerGarbageCollector=function(){return new D},t.memoryLocalCache=function(e){return new N(e)},t.memoryLruGarbageCollector=function(e){return new M(e?.cacheSizeBytes)},t.onSnapshot=J,t.onSnapshotResume=function(e,t,...n){const r=s.getModularInstance(e),i=function(e){const t={bundle:"",bundleName:"",bundleSource:""},n=["bundle","bundleName","bundleSource"];for(const r of n){if(!(r in e)){t.error=`snapshotJson missing required field: ${r}`;break}const n=e[r];if("string"!=typeof n){t.error=`snapshotJson field '${r}' must be a string.`;break}if(0===n.length){t.error=`snapshotJson field '${r}' cannot be an empty string.`;break}"bundle"===r?t.bundle=n:"bundleName"===r?t.bundleName=n:"bundleSource"===r&&(t.bundleSource=n)}return t}(t);if(i.error)throw new o.FirestoreError(o.C.INVALID_ARGUMENT,i.error);let a,c=0;if("object"!=typeof n[c]||u(n[c])||(a=n[c++]),"QuerySnapshot"===i.bundleSource){let e=null;if("object"==typeof n[c]&&u(n[c])){const t=n[c++];e={next:t.next,error:t.error,complete:t.complete}}else e={next:n[c++],error:n[c++],complete:n[c++]};return function(e,t,n,r,i){let s,a=!1;return o.loadBundle(e,t.bundle).then(()=>o.namedQuery(e,t.bundleName)).then(e=>{e&&!a&&(i&&e.withConverter(i),s=J(e,n||{},r))}).catch(e=>(r.error&&r.error(e),()=>{})),()=>{a||(a=!0,s&&s())}}(r,i,a,e,n[c])}if("DocumentSnapshot"===i.bundleSource){let e=null;if("object"==typeof n[c]&&u(n[c])){const t=n[c++];e={next:t.next,error:t.error,complete:t.complete}}else e={next:n[c++],error:n[c++],complete:n[c++]};return function(e,t,n,r,i){let s,a=!1;return o.loadBundle(e,t.bundle).then(()=>{if(!a){const a=new o.DocumentReference(e,i||null,o.DocumentKey.fromPath(t.bundleName));s=J(a,n||{},r)}}).catch(e=>(r.error&&r.error(e),()=>{})),()=>{a||(a=!0,s&&s())}}(r,i,a,e,n[c])}throw new o.FirestoreError(o.C.INVALID_ARGUMENT,`unsupported bundle source: ${i.bundleSource}`)},t.onSnapshotsInSync=function(e,t){e=o.__PRIVATE_cast(e,o.Firestore);const n=o.ensureFirestoreConfigured(e),r=u(t)?t:{next:t};return o.__PRIVATE_firestoreClientAddSnapshotsInSyncListener(n,r)},t.or=function(...e){return e.forEach(e=>O("or",e)),v._create("or",e)},t.orderBy=function(e,t="asc"){const n=t,r=o.__PRIVATE_fieldPathFromArgument("orderBy",e);return b._create(r,n)},t.persistentLocalCache=function(e){return new x(e)},t.persistentMultipleTabManager=function(){return new j},t.persistentSingleTabManager=F,t.query=function(e,t,...n){let r=[];t instanceof m&&r.push(t),r=r.concat(n),function(e){const t=e.filter(e=>e instanceof v).length,n=e.filter(e=>e instanceof y).length;if(t>1||t>0&&n>0)throw new o.FirestoreError(o.C.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.querySnapshotFromJSON=function(e,t,n){if(o.__PRIVATE_validateJSON(t,z._jsonSchema)){if(t.bundle===V)throw new o.FirestoreError(o.C.INVALID_ARGUMENT,"The provided JSON object was created in a client environment, which is not supported.");const r=o.__PRIVATE_newSerializer(e._databaseId),i=o.__PRIVATE_createBundleReaderSync(t.bundle,r),s=i.t(),a=new o.__PRIVATE_BundleLoader(i.getMetadata(),r);for(const e of s)a.o(e);if(1!==a.queries.length)throw new o.FirestoreError(o.C.INVALID_ARGUMENT,`Snapshot data expected 1 query but found ${a.queries.length} queries.`);const c=o.__PRIVATE_fromBundledQuery(a.queries[0].bundledQuery),u=a.documents;let l=new o.DocumentSet;u.map(e=>{const t=o.__PRIVATE_fromDocument(r,e.document);l=l.add(t)});const h=o.ViewSnapshot.fromInitialDocuments(c,l,o.__PRIVATE_documentKeySet(),!1,!1),d=new o.Query(e,n||null,c);return new z(e,new C(e),d,h)}},t.runTransaction=function(e,t,n){e=o.__PRIVATE_cast(e,o.Firestore);const r={...G,...n};!function(e){if(e.maxAttempts<1)throw new o.FirestoreError(o.C.INVALID_ARGUMENT,"Max attempts must be at least 1")}(r);const i=o.ensureFirestoreConfigured(e);return o.__PRIVATE_firestoreClientTransaction(i,n=>t(new Q(e,n)),r)},t.setDoc=function(e,t,n){e=o.__PRIVATE_cast(e,o.DocumentReference);const r=o.__PRIVATE_cast(e.firestore,o.Firestore),i=P(e.converter,t,n),s=o.__PRIVATE_newUserDataReader(r);return Y(r,[o.__PRIVATE_parseSetData(s,"setDoc",e._key,i,null!==e.converter,n).toMutation(e._key,o.Precondition.none())])},t.setIndexConfiguration=function(e,t){e=o.__PRIVATE_cast(e,o.Firestore);const n=o.ensureFirestoreConfigured(e);if(!n._uninitializedComponentsProvider||"memory"===n._uninitializedComponentsProvider._offline.kind)return o.__PRIVATE_logWarn("Cannot enable indexes when persistence is disabled"),Promise.resolve();const r=function(e){const t="string"==typeof e?function(e){try{return JSON.parse(e)}catch(e){throw new o.FirestoreError(o.C.INVALID_ARGUMENT,"Failed to parse JSON: "+e?.message)}}(e):e,n=[];if(Array.isArray(t.indexes))for(const e of t.indexes){const t=Z(e,"collectionGroup"),r=[];if(Array.isArray(e.fields))for(const t of e.fields){const e=Z(t,"fieldPath"),n=o.__PRIVATE_fieldPathFromDotSeparatedString("setIndexConfiguration",e);"CONTAINS"===t.arrayConfig?r.push(new o.IndexSegment(n,2)):"ASCENDING"===t.order?r.push(new o.IndexSegment(n,0)):"DESCENDING"===t.order&&r.push(new o.IndexSegment(n,1))}n.push(new o.FieldIndex(o.FieldIndex.UNKNOWN_ID,t,r,o.IndexState.empty()))}return n}(t);return o.__PRIVATE_firestoreClientSetIndexConfiguration(n,r)},t.snapshotEqual=function(e,t){return e instanceof q&&t instanceof q?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 z&&t instanceof z&&e._firestore===t._firestore&&o.queryEqual(e.query,t.query)&&e.metadata.isEqual(t.metadata)&&e._snapshot.isEqual(t._snapshot)},t.startAfter=function(...e){return w._create("startAfter",e,!1)},t.startAt=function(...e){return w._create("startAt",e,!0)},t.sum=function(e){return new l("sum",o.__PRIVATE_fieldPathFromArgument("sum",e))},t.updateDoc=function(e,t,n,...r){e=o.__PRIVATE_cast(e,o.DocumentReference);const i=o.__PRIVATE_cast(e.firestore,o.Firestore),a=o.__PRIVATE_newUserDataReader(i);let c;return c="string"==typeof(t=s.getModularInstance(t))||t instanceof o.FieldPath?o.__PRIVATE_parseUpdateVarargs(a,"updateDoc",e._key,t,n,r):o.__PRIVATE_parseUpdateData(a,"updateDoc",e._key,t),Y(i,[c.toMutation(e._key,o.Precondition.exists(!0))])},t.where=function(e,t,n){const r=t,i=o.__PRIVATE_fieldPathFromArgument("where",e);return y._create(i,r,n)},t.writeBatch=function(e){return e=o.__PRIVATE_cast(e,o.Firestore),o.ensureFirestoreConfigured(e),new K(e,t=>Y(e,t))}},5844(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=[];var r;t.LogLevel=void 0,(r=t.LogLevel||(t.LogLevel={}))[r.DEBUG=0]="DEBUG",r[r.VERBOSE=1]="VERBOSE",r[r.INFO=2]="INFO",r[r.WARN=3]="WARN",r[r.ERROR=4]="ERROR",r[r.SILENT=5]="SILENT";const i={debug:t.LogLevel.DEBUG,verbose:t.LogLevel.VERBOSE,info:t.LogLevel.INFO,warn:t.LogLevel.WARN,error:t.LogLevel.ERROR,silent:t.LogLevel.SILENT},o=t.LogLevel.INFO,s={[t.LogLevel.DEBUG]:"log",[t.LogLevel.VERBOSE]:"log",[t.LogLevel.INFO]:"info",[t.LogLevel.WARN]:"warn",[t.LogLevel.ERROR]:"error"},a=(e,t,...n)=>{if(t<e.logLevel)return;const r=(new Date).toISOString(),i=s[t];if(!i)throw new Error(`Attempted to log a message with an invalid logType (value: ${t})`);console[i](`[${r}] ${e.name}:`,...n)};t.Logger=class{constructor(e){this.name=e,this._logLevel=o,this._logHandler=a,this._userLogHandler=null,n.push(this)}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in t.LogLevel))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel="string"==typeof e?i[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if("function"!=typeof e)throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e}get userLogHandler(){return this._userLogHandler}set userLogHandler(e){this._userLogHandler=e}debug(...e){this._userLogHandler&&this._userLogHandler(this,t.LogLevel.DEBUG,...e),this._logHandler(this,t.LogLevel.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,t.LogLevel.VERBOSE,...e),this._logHandler(this,t.LogLevel.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,t.LogLevel.INFO,...e),this._logHandler(this,t.LogLevel.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,t.LogLevel.WARN,...e),this._logHandler(this,t.LogLevel.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,t.LogLevel.ERROR,...e),this._logHandler(this,t.LogLevel.ERROR,...e)}},t.setLogLevel=function(e){n.forEach(t=>{t.setLogLevel(e)})},t.setUserLogHandler=function(e,r){for(const o of n){let n=null;r&&r.level&&(n=i[r.level]),o.userLogHandler=null===e?null:(r,i,...o)=>{const s=o.map(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(e=>e).join(" ");i>=(n??r.logLevel)&&e({level:t.LogLevel[i].toLowerCase(),message:s,args:o,type:r.name})}}}},6336(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(8873);const i={NODE_CLIENT:!1,NODE_ADMIN:!1,SDK_VERSION:"${JSCORE_VERSION}"},o=function(e,t){if(!e)throw s(t)},s=function(e){return new Error("Firebase Database ("+i.SDK_VERSION+") INTERNAL ASSERT FAILED: "+e)},a=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},c={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],o=t+1<e.length,s=o?e[t+1]:0,a=t+2<e.length,c=a?e[t+2]:0,u=i>>2,l=(3&i)<<4|s>>4;let h=(15&s)<<2|c>>6,d=63&c;a||(d=64,o||(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(a(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 o=e[n++];t[r++]=String.fromCharCode((31&i)<<6|63&o)}else if(i>239&&i<365){const o=((7&i)<<18|(63&e[n++])<<12|(63&e[n++])<<6|63&e[n++])-65536;t[r++]=String.fromCharCode(55296+(o>>10)),t[r++]=String.fromCharCode(56320+(1023&o))}else{const o=e[n++],s=e[n++];t[r++]=String.fromCharCode((15&i)<<12|(63&o)<<6|63&s)}}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++)],o=t<e.length?n[e.charAt(t)]:0;++t;const s=t<e.length?n[e.charAt(t)]:64;++t;const a=t<e.length?n[e.charAt(t)]:64;if(++t,null==i||null==o||null==s||null==a)throw new u;const c=i<<2|o>>4;if(r.push(c),64!==s){const e=o<<4&240|s>>2;if(r.push(e),64!==a){const e=s<<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 u extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}const l=function(e){const t=a(e);return c.encodeByteArray(t,!0)},h=function(e){return l(e).replace(/\./g,"")},d=function(e){try{return c.decodeString(e,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};function f(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)&&p(n)&&(e[n]=f(e[n],t[n]));return e}function p(e){return"__proto__"!==e}function m(){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 g=()=>{try{return r.getDefaultsFromPostinstall()||m().__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&&d(e[1]);return t&&JSON.parse(t)})()}catch(e){return void console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${e}`)}},y=e=>g()?.emulatorHosts?.[e];class v{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 b(e){try{return(e.startsWith("http://")||e.startsWith("https://")?new URL(e).hostname:e).endsWith(".cloudworkstations.dev")}catch{return!1}}const _={};let w=!1;function I(){return"undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:""}function E(){const e=g()?.forceEnvironment;if("node"===e)return!0;if("browser"===e)return!1;try{return"[object process]"===Object.prototype.toString.call(n.g.process)}catch(e){return!1}}function T(){return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope}class S extends Error{constructor(e,t,n){super(t),this.code=e,this.customData=n,this.name="FirebaseError",Object.setPrototypeOf(this,S.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,A.prototype.create)}}class A{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],o=i?function(e,t){return e.replace(O,(e,n)=>{const r=t[n];return null!=r?String(r):`<${n}?>`})}(i,n):"Error",s=`${this.serviceName}: ${o} (${r}).`;return new S(r,s,n)}}const O=/\{\$([^}]+)}/g;function P(e){return JSON.parse(e)}const C=function(e){let t={},n={},r={},i="";try{const o=e.split(".");t=P(d(o[0])||""),n=P(d(o[1])||""),i=o[2],r=n.d||{},delete n.d}catch(e){}return{header:t,claims:n,data:r,signature:i}};function R(e){return null!==e&&"object"==typeof e}class k{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=N),void 0===r.error&&(r.error=N),void 0===r.complete&&(r.complete=N);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 N(){}function x(e,t){return`${e} failed: ${t} argument `}const D=144e5;t.CONSTANTS=i,t.DecodeBase64StringError=u,t.Deferred=v,t.ErrorFactory=A,t.FirebaseError=S,t.MAX_VALUE_MILLIS=D,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,o=this.chain_[0],s=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^s&(a^c),i=1518500249):(r=s^a^c,i=1859775393):e<60?(r=s&a|c&(s|a),i=2400959708):(r=s^a^c,i=3395469782);const t=(o<<5|o>>>27)+r+u+i+n[e]&4294967295;u=c,c=a,a=4294967295&(s<<30|s>>>2),s=o,o=t}this.chain_[0]=this.chain_[0]+o&4294967295,this.chain_[1]=this.chain_[1]+s&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 o=this.inbuf_;for(;r<t;){if(0===o)for(;r<=n;)this.compress_(e,r),r+=this.blockSize;if("string"==typeof e){for(;r<t;)if(i[o]=e.charCodeAt(r),++o,++r,o===this.blockSize){this.compress_(i),o=0;break}}else for(;r<t;)if(i[o]=e[r],++o,++r,o===this.blockSize){this.compress_(i),o=0;break}}this.inbuf_=o,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=o,t.assertionError=s,t.async=function(e,t){return(...n)=>{Promise.resolve(!0).then(()=>{e(...n)}).catch(e=>{t&&t(e)})}},t.base64=c,t.base64Decode=d,t.base64Encode=l,t.base64urlEncodeWithoutPadding=h,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(D,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 o={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[h(JSON.stringify({alg:"none",type:"JWT"})),h(JSON.stringify(o)),""].join(".")},t.createSubscribe=function(e,t){const n=new k(e,t);return n.subscribe.bind(n)},t.decode=C,t.deepCopy=function(e){return f(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 o of r){if(!i.includes(o))return!1;const r=t[o],s=n[o];if(R(r)&&R(s)){if(!e(r,s))return!1}else if(r!==s)return!1}for(const e of i)if(!r.includes(e))return!1;return!0},t.deepExtend=f,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.generateSHA256Hash=async function(e){const t=(new TextEncoder).encode(e),n=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,"0")).join("")},t.getDefaultAppConfig=()=>g()?.config,t.getDefaultEmulatorHost=y,t.getDefaultEmulatorHostnameAndPort=e=>{const t=y(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=g,t.getExperimentalSetting=e=>g()?.[`_${e}`],t.getGlobal=m,t.getModularInstance=function(e){return e&&e._delegate?e._delegate:e},t.getUA=I,t.isAdmin=function(e){const t=C(e).claims;return"object"==typeof t&&!0===t.admin},t.isBrowser=function(){return"undefined"!=typeof window||T()},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.isCloudWorkstation=b,t.isCloudflareWorker=function(){return"undefined"!=typeof navigator&&"Cloudflare-Workers"===navigator.userAgent},t.isElectron=function(){return I().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=I();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(I())},t.isNode=E,t.isNodeSdk=function(){return!0===i.NODE_CLIENT||!0===i.NODE_ADMIN},t.isReactNative=function(){return"object"==typeof navigator&&"ReactNative"===navigator.product},t.isSafari=function(){return!E()&&!!navigator.userAgent&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")},t.isSafariOrWebkit=function(){return!E()&&!!navigator.userAgent&&(navigator.userAgent.includes("Safari")||navigator.userAgent.includes("WebKit"))&&!navigator.userAgent.includes("Chrome")},t.isUWP=function(){return I().indexOf("MSAppHost/")>=0},t.isValidFormat=function(e){const t=C(e).claims;return!!t&&"object"==typeof t&&t.hasOwnProperty("iat")},t.isValidTimestamp=function(e){const t=C(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=T,t.issuedAtTime=function(e){const t=C(e).claims;return"object"==typeof t&&t.hasOwnProperty("iat")?t.iat:null},t.jsonEval=P,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.pingServer=async function(e){return(await fetch(e,{credentials:"include"})).ok},t.promiseWithTimeout=function(e,t=2e3){const n=new v;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 i=e.charCodeAt(r);if(i>=55296&&i<=56319){const t=i-55296;r++,o(r<e.length,"Surrogate pair missing trail surrogate."),i=65536+(t<<10)+(e.charCodeAt(r)-56320)}i<128?t[n++]=i:i<2048?(t[n++]=i>>6|192,t[n++]=63&i|128):i<65536?(t[n++]=i>>12|224,t[n++]=i>>6&63|128,t[n++]=63&i|128):(t[n++]=i>>18|240,t[n++]=i>>12&63|128,t[n++]=i>>6&63|128,t[n++]=63&i|128)}return t},t.stringify=function(e){return JSON.stringify(e)},t.updateEmulatorBanner=function(e,t){if("undefined"==typeof window||"undefined"==typeof document||!b(window.location.host)||_[e]===t||_[e]||w)return;function n(e){return`__firebase__banner__${e}`}_[e]=t;const r="__firebase__banner",i=function(){const e={prod:[],emulator:[]};for(const t of Object.keys(_))_[t]?e.emulator.push(t):e.prod.push(t);return e}().prod.length>0;function o(){const e=function(e){let t=document.getElementById(e),n=!1;return t||(t=document.createElement("div"),t.setAttribute("id",e),n=!0),{created:n,element:t}}(r),t=n("text"),o=document.getElementById(t)||document.createElement("span"),s=n("learnmore"),a=document.getElementById(s)||document.createElement("a"),c=n("preprendIcon"),u=document.getElementById(c)||document.createElementNS("http://www.w3.org/2000/svg","svg");if(e.created){const t=e.element;!function(e){e.style.display="flex",e.style.background="#7faaf0",e.style.position="fixed",e.style.bottom="5px",e.style.left="5px",e.style.padding=".5em",e.style.borderRadius="5px",e.style.alignItems="center"}(t),function(e,t){e.setAttribute("id",t),e.innerText="Learn more",e.href="https://firebase.google.com/docs/studio/preview-apps#preview-backend",e.setAttribute("target","__blank"),e.style.paddingLeft="5px",e.style.textDecoration="underline"}(a,s);const n=function(){const e=document.createElement("span");return e.style.cursor="pointer",e.style.marginLeft="16px",e.style.fontSize="24px",e.innerHTML=" &times;",e.onclick=()=>{w=!0,function(){const e=document.getElementById(r);e&&e.remove()}()},e}();!function(e,t){e.setAttribute("width","24"),e.setAttribute("id",t),e.setAttribute("height","24"),e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("fill","none"),e.style.marginLeft="-6px"}(u,c),t.append(u,o,a,n),document.body.appendChild(t)}i?(o.innerText="Preview backend disconnected.",u.innerHTML='<g clip-path="url(#clip0_6013_33858)">\n<path d="M4.8 17.6L12 5.6L19.2 17.6H4.8ZM6.91667 16.4H17.0833L12 7.93333L6.91667 16.4ZM12 15.6C12.1667 15.6 12.3056 15.5444 12.4167 15.4333C12.5389 15.3111 12.6 15.1667 12.6 15C12.6 14.8333 12.5389 14.6944 12.4167 14.5833C12.3056 14.4611 12.1667 14.4 12 14.4C11.8333 14.4 11.6889 14.4611 11.5667 14.5833C11.4556 14.6944 11.4 14.8333 11.4 15C11.4 15.1667 11.4556 15.3111 11.5667 15.4333C11.6889 15.5444 11.8333 15.6 12 15.6ZM11.4 13.6H12.6V10.4H11.4V13.6Z" fill="#212121"/>\n</g>\n<defs>\n<clipPath id="clip0_6013_33858">\n<rect width="24" height="24" fill="white"/>\n</clipPath>\n</defs>'):(u.innerHTML='<g clip-path="url(#clip0_6083_34804)">\n<path d="M11.4 15.2H12.6V11.2H11.4V15.2ZM12 10C12.1667 10 12.3056 9.94444 12.4167 9.83333C12.5389 9.71111 12.6 9.56667 12.6 9.4C12.6 9.23333 12.5389 9.09444 12.4167 8.98333C12.3056 8.86111 12.1667 8.8 12 8.8C11.8333 8.8 11.6889 8.86111 11.5667 8.98333C11.4556 9.09444 11.4 9.23333 11.4 9.4C11.4 9.56667 11.4556 9.71111 11.5667 9.83333C11.6889 9.94444 11.8333 10 12 10ZM12 18.4C11.1222 18.4 10.2944 18.2333 9.51667 17.9C8.73889 17.5667 8.05556 17.1111 7.46667 16.5333C6.88889 15.9444 6.43333 15.2611 6.1 14.4833C5.76667 13.7056 5.6 12.8778 5.6 12C5.6 11.1111 5.76667 10.2833 6.1 9.51667C6.43333 8.73889 6.88889 8.06111 7.46667 7.48333C8.05556 6.89444 8.73889 6.43333 9.51667 6.1C10.2944 5.76667 11.1222 5.6 12 5.6C12.8889 5.6 13.7167 5.76667 14.4833 6.1C15.2611 6.43333 15.9389 6.89444 16.5167 7.48333C17.1056 8.06111 17.5667 8.73889 17.9 9.51667C18.2333 10.2833 18.4 11.1111 18.4 12C18.4 12.8778 18.2333 13.7056 17.9 14.4833C17.5667 15.2611 17.1056 15.9444 16.5167 16.5333C15.9389 17.1111 15.2611 17.5667 14.4833 17.9C13.7167 18.2333 12.8889 18.4 12 18.4ZM12 17.2C13.4444 17.2 14.6722 16.6944 15.6833 15.6833C16.6944 14.6722 17.2 13.4444 17.2 12C17.2 10.5556 16.6944 9.32778 15.6833 8.31667C14.6722 7.30555 13.4444 6.8 12 6.8C10.5556 6.8 9.32778 7.30555 8.31667 8.31667C7.30556 9.32778 6.8 10.5556 6.8 12C6.8 13.4444 7.30556 14.6722 8.31667 15.6833C9.32778 16.6944 10.5556 17.2 12 17.2Z" fill="#212121"/>\n</g>\n<defs>\n<clipPath id="clip0_6083_34804">\n<rect width="24" height="24" fill="white"/>\n</clipPath>\n</defs>',o.innerText="Preview backend running in this workspace."),o.setAttribute("id",t)}"loading"===document.readyState?window.addEventListener("DOMContentLoaded",o):o()},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=()=>{t(i.error?.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.")}},8873(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getDefaultsFromPostinstall=()=>{}},860(e,t,n){(function(){"use strict";var t;function n(){this.blockSize=-1,this.blockSize=64,this.g=Array(4),this.C=Array(this.blockSize),this.o=this.h=0,this.u()}function r(e,t,n){n||(n=0);const r=Array(16);if("string"==typeof t)for(var i=0;i<16;++i)r[i]=t.charCodeAt(n++)|t.charCodeAt(n++)<<8|t.charCodeAt(n++)<<16|t.charCodeAt(n++)<<24;else for(i=0;i<16;++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];let o,s=e.g[3];o=t+(s^n&(i^s))+r[0]+3614090360&4294967295,o=s+(i^(t=n+(o<<7&4294967295|o>>>25))&(n^i))+r[1]+3905402710&4294967295,s=t+(o<<12&4294967295|o>>>20),o=i+(n^s&(t^n))+r[2]+606105819&4294967295,o=n+(t^(i=s+(o<<17&4294967295|o>>>15))&(s^t))+r[3]+3250441966&4294967295,o=t+(s^(n=i+(o<<22&4294967295|o>>>10))&(i^s))+r[4]+4118548399&4294967295,o=s+(i^(t=n+(o<<7&4294967295|o>>>25))&(n^i))+r[5]+1200080426&4294967295,s=t+(o<<12&4294967295|o>>>20),o=i+(n^s&(t^n))+r[6]+2821735955&4294967295,o=n+(t^(i=s+(o<<17&4294967295|o>>>15))&(s^t))+r[7]+4249261313&4294967295,o=t+(s^(n=i+(o<<22&4294967295|o>>>10))&(i^s))+r[8]+1770035416&4294967295,o=s+(i^(t=n+(o<<7&4294967295|o>>>25))&(n^i))+r[9]+2336552879&4294967295,s=t+(o<<12&4294967295|o>>>20),o=i+(n^s&(t^n))+r[10]+4294925233&4294967295,o=n+(t^(i=s+(o<<17&4294967295|o>>>15))&(s^t))+r[11]+2304563134&4294967295,o=t+(s^(n=i+(o<<22&4294967295|o>>>10))&(i^s))+r[12]+1804603682&4294967295,o=s+(i^(t=n+(o<<7&4294967295|o>>>25))&(n^i))+r[13]+4254626195&4294967295,s=t+(o<<12&4294967295|o>>>20),o=i+(n^s&(t^n))+r[14]+2792965006&4294967295,o=n+(t^(i=s+(o<<17&4294967295|o>>>15))&(s^t))+r[15]+1236535329&4294967295,o=t+(i^s&((n=i+(o<<22&4294967295|o>>>10))^i))+r[1]+4129170786&4294967295,o=s+(n^i&((t=n+(o<<5&4294967295|o>>>27))^n))+r[6]+3225465664&4294967295,s=t+(o<<9&4294967295|o>>>23),o=i+(t^n&(s^t))+r[11]+643717713&4294967295,o=n+(s^t&((i=s+(o<<14&4294967295|o>>>18))^s))+r[0]+3921069994&4294967295,o=t+(i^s&((n=i+(o<<20&4294967295|o>>>12))^i))+r[5]+3593408605&4294967295,o=s+(n^i&((t=n+(o<<5&4294967295|o>>>27))^n))+r[10]+38016083&4294967295,s=t+(o<<9&4294967295|o>>>23),o=i+(t^n&(s^t))+r[15]+3634488961&4294967295,o=n+(s^t&((i=s+(o<<14&4294967295|o>>>18))^s))+r[4]+3889429448&4294967295,o=t+(i^s&((n=i+(o<<20&4294967295|o>>>12))^i))+r[9]+568446438&4294967295,o=s+(n^i&((t=n+(o<<5&4294967295|o>>>27))^n))+r[14]+3275163606&4294967295,s=t+(o<<9&4294967295|o>>>23),o=i+(t^n&(s^t))+r[3]+4107603335&4294967295,o=n+(s^t&((i=s+(o<<14&4294967295|o>>>18))^s))+r[8]+1163531501&4294967295,o=t+(i^s&((n=i+(o<<20&4294967295|o>>>12))^i))+r[13]+2850285829&4294967295,o=s+(n^i&((t=n+(o<<5&4294967295|o>>>27))^n))+r[2]+4243563512&4294967295,s=t+(o<<9&4294967295|o>>>23),o=i+(t^n&(s^t))+r[7]+1735328473&4294967295,o=n+(s^t&((i=s+(o<<14&4294967295|o>>>18))^s))+r[12]+2368359562&4294967295,o=t+((n=i+(o<<20&4294967295|o>>>12))^i^s)+r[5]+4294588738&4294967295,o=s+((t=n+(o<<4&4294967295|o>>>28))^n^i)+r[8]+2272392833&4294967295,s=t+(o<<11&4294967295|o>>>21),o=i+(s^t^n)+r[11]+1839030562&4294967295,o=n+((i=s+(o<<16&4294967295|o>>>16))^s^t)+r[14]+4259657740&4294967295,o=t+((n=i+(o<<23&4294967295|o>>>9))^i^s)+r[1]+2763975236&4294967295,o=s+((t=n+(o<<4&4294967295|o>>>28))^n^i)+r[4]+1272893353&4294967295,s=t+(o<<11&4294967295|o>>>21),o=i+(s^t^n)+r[7]+4139469664&4294967295,o=n+((i=s+(o<<16&4294967295|o>>>16))^s^t)+r[10]+3200236656&4294967295,o=t+((n=i+(o<<23&4294967295|o>>>9))^i^s)+r[13]+681279174&4294967295,o=s+((t=n+(o<<4&4294967295|o>>>28))^n^i)+r[0]+3936430074&4294967295,s=t+(o<<11&4294967295|o>>>21),o=i+(s^t^n)+r[3]+3572445317&4294967295,o=n+((i=s+(o<<16&4294967295|o>>>16))^s^t)+r[6]+76029189&4294967295,o=t+((n=i+(o<<23&4294967295|o>>>9))^i^s)+r[9]+3654602809&4294967295,o=s+((t=n+(o<<4&4294967295|o>>>28))^n^i)+r[12]+3873151461&4294967295,s=t+(o<<11&4294967295|o>>>21),o=i+(s^t^n)+r[15]+530742520&4294967295,o=n+((i=s+(o<<16&4294967295|o>>>16))^s^t)+r[2]+3299628645&4294967295,o=t+(i^((n=i+(o<<23&4294967295|o>>>9))|~s))+r[0]+4096336452&4294967295,o=s+(n^((t=n+(o<<6&4294967295|o>>>26))|~i))+r[7]+1126891415&4294967295,s=t+(o<<10&4294967295|o>>>22),o=i+(t^(s|~n))+r[14]+2878612391&4294967295,o=n+(s^((i=s+(o<<15&4294967295|o>>>17))|~t))+r[5]+4237533241&4294967295,o=t+(i^((n=i+(o<<21&4294967295|o>>>11))|~s))+r[12]+1700485571&4294967295,o=s+(n^((t=n+(o<<6&4294967295|o>>>26))|~i))+r[3]+2399980690&4294967295,s=t+(o<<10&4294967295|o>>>22),o=i+(t^(s|~n))+r[10]+4293915773&4294967295,o=n+(s^((i=s+(o<<15&4294967295|o>>>17))|~t))+r[1]+2240044497&4294967295,o=t+(i^((n=i+(o<<21&4294967295|o>>>11))|~s))+r[8]+1873313359&4294967295,o=s+(n^((t=n+(o<<6&4294967295|o>>>26))|~i))+r[15]+4264355552&4294967295,s=t+(o<<10&4294967295|o>>>22),o=i+(t^(s|~n))+r[6]+2734768916&4294967295,o=n+(s^((i=s+(o<<15&4294967295|o>>>17))|~t))+r[13]+1309151649&4294967295,o=t+(i^((n=i+(o<<21&4294967295|o>>>11))|~s))+r[4]+4149444226&4294967295,o=s+(n^((t=n+(o<<6&4294967295|o>>>26))|~i))+r[11]+3174756917&4294967295,s=t+(o<<10&4294967295|o>>>22),o=i+(t^(s|~n))+r[2]+718787259&4294967295,o=n+(s^((i=s+(o<<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;const n=[];let r=!0;for(let i=e.length-1;i>=0;i--){const o=0|e[i];r&&o==t||(n[i]=o,r=!1)}this.g=n}!function(e,t){function n(){}n.prototype=t.prototype,e.F=t.prototype,e.prototype=new n,e.prototype.constructor=e,e.D=function(e,n,r){for(var i=Array(arguments.length-2),o=2;o<arguments.length;o++)i[o-2]=arguments[o];return t.prototype[n].apply(e,i)}}(n,function(){this.blockSize=-1}),n.prototype.u=function(){this.g[0]=1732584193,this.g[1]=4023233417,this.g[2]=2562383102,this.g[3]=271733878,this.o=this.h=0},n.prototype.v=function(e,t){void 0===t&&(t=e.length);const n=t-this.blockSize,i=this.C;let o=this.h,s=0;for(;s<t;){if(0==o)for(;s<=n;)r(this,e,s),s+=this.blockSize;if("string"==typeof e){for(;s<t;)if(i[o++]=e.charCodeAt(s++),o==this.blockSize){r(this,i),o=0;break}}else for(;s<t;)if(i[o++]=e[s++],o==this.blockSize){r(this,i),o=0;break}}this.h=o,this.o+=t},n.prototype.A=function(){var e=Array((this.h<56?this.blockSize:2*this.blockSize)-this.h);e[0]=128;for(var t=1;t<e.length-8;++t)e[t]=0;t=8*this.o;for(var n=e.length-8;n<e.length;++n)e[n]=255&t,t/=256;for(this.v(e),e=Array(16),t=0,n=0;n<4;++n)for(let r=0;r<32;r+=8)e[t++]=this.g[n]>>>r&255;return e};var o={};function s(e){return-128<=e&&e<128?function(e){var t=o;return Object.prototype.hasOwnProperty.call(t,e)?t[e]:t[e]=function(e){return new i([0|e],e<0?-1:0)}(e)}(e):new i([0|e],e<0?-1:0)}function a(e){if(isNaN(e)||!isFinite(e))return c;if(e<0)return f(a(-e));const t=[];let n=1;for(let r=0;e>=n;r++)t[r]=e/n|0,n*=4294967296;return new i(t,0)}var c=s(0),u=s(1),l=s(16777216);function h(e){if(0!=e.h)return!1;for(let 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){const t=e.g.length,n=[];for(let 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(e.g.length>30){if(d(e)||d(t))throw Error("slowDivide_ only works with positive integers.");for(var n=u,r=t;r.l(e)<=0;)n=v(n),r=v(r);var i=b(n,1),o=b(r,1);for(r=b(r,2),n=b(n,2);!h(r);){var s=o.add(r);s.l(e)<=0&&(i=i.add(n),o=s),r=b(r,1),n=b(n,1)}return t=p(e,i.j(t)),new g(i,t)}for(i=c;e.l(t)>=0;){for(n=Math.max(1,Math.floor(e.m()/t.m())),r=(r=Math.ceil(Math.log(n)/Math.LN2))<=48?1:Math.pow(2,r-48),s=(o=a(n)).j(t);d(s)||s.l(e)>0;)s=(o=a(n-=r)).j(t);h(o)&&(o=u),i=i.add(o),e=p(e,s)}return new g(i,e)}function v(e){const t=e.g.length+1,n=[];for(let 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){const n=t>>5;t%=32;const r=e.g.length-n,o=[];for(let i=0;i<r;i++)o[i]=t>0?e.i(i+n)>>>t|e.i(i+n+1)<<32-t:e.i(i+n);return new i(o,e.h)}(t=i.prototype).m=function(){if(d(this))return-f(this).m();let e=0,t=1;for(let n=0;n<this.g.length;n++){const r=this.i(n);e+=(r>=0?r:4294967296+r)*t,t*=4294967296}return e},t.toString=function(e){if((e=e||10)<2||36<e)throw Error("radix out of range: "+e);if(h(this))return"0";if(d(this))return"-"+f(this).toString(e);const t=a(Math.pow(e,6));var n=this;let r="";for(;;){const i=y(n,t).g;let o=(((n=p(n,i.j(t))).g.length>0?n.g[0]:n.h)>>>0).toString(e);if(h(n=i))return o+r;for(;o.length<6;)o="0"+o;r=o+r}},t.i=function(e){return e<0?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){const t=Math.max(this.g.length,e.g.length),n=[];let r=0;for(let i=0;i<=t;i++){let t=r+(65535&this.i(i))+(65535&e.i(i)),o=(t>>>16)+(this.i(i)>>>16)+(e.i(i)>>>16);r=o>>>16,t&=65535,o&=65535,n[i]=o<<16|t}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(this.l(l)<0&&e.l(l)<0)return a(this.m()*e.m());const t=this.g.length+e.g.length,n=[];for(var r=0;r<2*t;r++)n[r]=0;for(r=0;r<this.g.length;r++)for(let t=0;t<e.g.length;t++){const i=this.i(r)>>>16,o=65535&this.i(r),s=e.i(t)>>>16,a=65535&e.i(t);n[2*r+2*t]+=o*a,m(n,2*r+2*t),n[2*r+2*t+1]+=i*a,m(n,2*r+2*t+1),n[2*r+2*t+1]+=o*s,m(n,2*r+2*t+1),n[2*r+2*t+2]+=i*s,m(n,2*r+2*t+2)}for(e=0;e<t;e++)n[e]=n[2*e+1]<<16|n[2*e];for(e=t;e<2*t;e++)n[e]=0;return new i(n,0)},t.B=function(e){return y(this,e).h},t.and=function(e){const t=Math.max(this.g.length,e.g.length),n=[];for(let 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){const t=Math.max(this.g.length,e.g.length),n=[];for(let 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){const t=Math.max(this.g.length,e.g.length),n=[];for(let 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.A,n.prototype.reset=n.prototype.u,n.prototype.update=n.prototype.v,e.exports.Md5=n,i.prototype.add=i.prototype.add,i.prototype.multiply=i.prototype.j,i.prototype.modulo=i.prototype.B,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((n=n||10)<2||36<n)throw Error("radix out of range: "+n);if("-"==t.charAt(0))return f(e(t.substring(1),n));if(t.indexOf("-")>=0)throw Error('number format error: interior "-" character');const r=a(Math.pow(n,8));let i=c;for(let e=0;e<t.length;e+=8){var o=Math.min(8,t.length-e);const s=parseInt(t.substring(e,e+o),n);o<8?(o=a(Math.pow(n,o)),i=i.j(o).add(a(s))):(i=i.j(r),i=i.add(a(s)))}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=Object.defineProperty,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 o(e,t){if(t)e:{var n=i;e=e.split(".");for(var o=0;o<e.length-1;o++){var s=e[o];if(!(s in n))break e;n=n[s]}(t=t(o=n[e=e[e.length-1]]))!=o&&null!=t&&r(n,e,{configurable:!0,writable:!0,value:t})}}o("Symbol.dispose",function(e){return e||Symbol("Symbol.dispose")}),o("Array.prototype.values",function(e){return e||function(){return this[Symbol.iterator]()}}),o("Object.entries",function(e){return e||function(e){var t,n=[];for(t in e)Object.prototype.hasOwnProperty.call(e,t)&&n.push([t,e[t]]);return n}});var s=s||{},a=this||self;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){return(l=u).apply(null,arguments)}function h(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 d(e,t){function n(){}n.prototype=t.prototype,e.Z=t.prototype,e.prototype=new n,e.prototype.constructor=e,e.Ob=function(e,n,r){for(var i=Array(arguments.length-2),o=2;o<arguments.length;o++)i[o-2]=arguments[o];return t.prototype[n].apply(e,i)}}var f="undefined"!=typeof AsyncContext&&"function"==typeof AsyncContext.Snapshot?e=>e&&AsyncContext.Snapshot.wrap(e):e=>e;function p(e){const t=e.length;if(t>0){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 r=arguments[t];var n=typeof r;if("array"==(n="object"!=n?n:r?Array.isArray(r)?"array":n:"null")||"object"==n&&"number"==typeof r.length){n=e.length||0;const t=r.length||0;e.length=n+t;for(let i=0;i<t;i++)e[n+i]=r[i]}else e.push(r)}}function g(e){a.setTimeout(()=>{throw e},0)}function y(){var e=I;let t=null;return e.g&&(t=e.g,e.g=e.g.next,e.g||(e.h=null),t.next=null),t}var v=new class{constructor(e,t){this.i=e,this.j=t,this.h=0,this.g=null}get(){let e;return this.h>0?(this.h--,e=this.g,this.g=e.next,e.next=null):e=this.i(),e}}(()=>new b,e=>e.reset());class b{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 _,w=!1,I=new class{constructor(){this.h=this.g=null}add(e,t){const n=v.get();n.set(e,t),this.h?this.h.next=n:this.g=n,this.h=n}},E=()=>{const e=Promise.resolve(void 0);_=()=>{e.then(T)}};function T(){for(var e;e=y();){try{e.h.call(e.g)}catch(e){g(e)}var t=v;t.j(e),t.h<100&&(t.h++,e.next=t.g,t.g=e)}w=!1}function S(){this.u=this.u,this.C=this.C}function A(e,t){this.type=e,this.g=this.target=t,this.defaultPrevented=!1}S.prototype.u=!1,S.prototype.dispose=function(){this.u||(this.u=!0,this.N())},S.prototype[Symbol.dispose]=function(){this.dispose()},S.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()},A.prototype.h=function(){this.defaultPrevented=!0};var O=function(){if(!a.addEventListener||!Object.defineProperty)return!1;var e=!1,t=Object.defineProperty({},"passive",{get:function(){e=!0}});try{const e=()=>{};a.addEventListener("test",e,t),a.removeEventListener("test",e,t)}catch(e){}return e}();function P(e){return/^[\s\xa0]*$/.test(e)}function C(e,t){A.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&&this.init(e,t)}d(C,A),C.prototype.init=function(e,t){const n=this.type=e.type,r=e.changedTouches&&e.changedTouches.length?e.changedTouches[0]:null;this.target=e.target||e.srcElement,this.g=t,(t=e.relatedTarget)||("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=e.pointerType,this.state=e.state,this.i=e,e.defaultPrevented&&C.Z.h.call(this)},C.prototype.h=function(){C.Z.h.call(this);const e=this.i;e.preventDefault?e.preventDefault():e.returnValue=!1};var R="closure_listenable_"+(1e6*Math.random()|0),k=0;function N(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=++k,this.da=this.fa=!1}function x(e){e.da=!0,e.listener=null,e.proxy=null,e.src=null,e.ha=null}function D(e,t,n){for(const r in e)t.call(n,e[r],r,e)}function M(e){const t={};for(const n in e)t[n]=e[n];return t}const L="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function j(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<L.length;t++)n=L[t],Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}}function F(e){this.src=e,this.g={},this.h=0}function V(e,t){const n=t.type;if(n in e.g){var r,i=e.g[n],o=Array.prototype.indexOf.call(i,t,void 0);(r=o>=0)&&Array.prototype.splice.call(i,o,1),r&&(x(t),0==e.g[n].length&&(delete e.g[n],e.h--))}}function U(e,t,n,r){for(let i=0;i<e.length;++i){const o=e[i];if(!o.da&&o.listener==t&&o.capture==!!n&&o.ha==r)return i}return-1}F.prototype.add=function(e,t,n,r,i){const o=e.toString();(e=this.g[o])||(e=this.g[o]=[],this.h++);const s=U(e,t,r,i);return s>-1?(t=e[s],n||(t.fa=!1)):((t=new N(t,this.src,o,!!r,i)).fa=n,e.push(t)),t};var q="closure_lm_"+(1e6*Math.random()|0),B={};function z(e,t,n,r,i){if(r&&r.once)return G(e,t,n,r,i);if(Array.isArray(t)){for(let o=0;o<t.length;o++)z(e,t[o],n,r,i);return null}return n=X(n),e&&e[R]?e.J(t,n,c(r)?!!r.capture:!!r,i):W(e,t,n,!1,r,i)}function W(e,t,n,r,i,o){if(!t)throw Error("Invalid event type");const s=c(i)?!!i.capture:!!i;let a=J(e);if(a||(e[q]=a=new F(e)),(n=a.add(t,n,r,s,o)).proxy)return n;if(r=function(){const e=Q;return function t(n){return e.call(t.src,t.listener,n)}}(),n.proxy=r,r.src=e,r.listener=n,e.addEventListener)O||(i=s),void 0===i&&(i=!1),e.addEventListener(t.toString(),r,i);else if(e.attachEvent)e.attachEvent(H(t.toString()),r);else{if(!e.addListener||!e.removeListener)throw Error("addEventListener and attachEvent are unavailable.");e.addListener(r)}return n}function G(e,t,n,r,i){if(Array.isArray(t)){for(let o=0;o<t.length;o++)G(e,t[o],n,r,i);return null}return n=X(n),e&&e[R]?e.K(t,n,c(r)?!!r.capture:!!r,i):W(e,t,n,!0,r,i)}function K(e,t,n,r,i){if(Array.isArray(t))for(var o=0;o<t.length;o++)K(e,t[o],n,r,i);else r=c(r)?!!r.capture:!!r,n=X(n),e&&e[R]?(e=e.i,(o=String(t).toString())in e.g&&(n=U(t=e.g[o],n,r,i))>-1&&(x(t[n]),Array.prototype.splice.call(t,n,1),0==t.length&&(delete e.g[o],e.h--))):e&&(e=J(e))&&(t=e.g[t.toString()],e=-1,t&&(e=U(t,n,r,i)),(n=e>-1?t[e]:null)&&$(n))}function $(e){if("number"!=typeof e&&e&&!e.da){var t=e.src;if(t&&t[R])V(t.i,e);else{var n=e.type,r=e.proxy;t.removeEventListener?t.removeEventListener(n,r,e.capture):t.detachEvent?t.detachEvent(H(n),r):t.addListener&&t.removeListener&&t.removeListener(r),(n=J(t))?(V(n,e),0==n.h&&(n.src=null,t[q]=null)):x(e)}}}function H(e){return e in B?B[e]:B[e]="on"+e}function Q(e,t){if(e.da)e=!0;else{t=new C(t,this);const n=e.listener,r=e.ha||e.src;e.fa&&$(e),e=n.call(r,t)}return e}function J(e){return(e=e[q])instanceof F?e:null}var Y="__closure_events_fn_"+(1e9*Math.random()>>>0);function X(e){return"function"==typeof e?e:(e[Y]||(e[Y]=function(t){return e.handleEvent(t)}),e[Y])}function Z(){S.call(this),this.i=new F(this),this.M=this,this.G=null}function ee(e,t){var n,r=e.G;if(r)for(n=[];r;r=r.G)n.push(r);if(e=e.M,r=t.type||t,"string"==typeof t)t=new A(t,e);else if(t instanceof A)t.target=t.target||e;else{var i=t;j(t=new A(r,e),i)}let o,s;if(i=!0,n)for(s=n.length-1;s>=0;s--)o=t.g=n[s],i=te(o,r,!0,t)&&i;if(o=t.g=e,i=te(o,r,!0,t)&&i,i=te(o,r,!1,t)&&i,n)for(s=0;s<n.length;s++)o=t.g=n[s],i=te(o,r,!1,t)&&i}function te(e,t,n,r){if(!(t=e.i.g[String(t)]))return!0;t=t.concat();let i=!0;for(let o=0;o<t.length;++o){const s=t[o];if(s&&!s.da&&s.capture==n){const t=s.listener,n=s.ha||s.src;s.fa&&V(e.i,s),i=!1!==t.call(n,r)&&i}}return i&&!r.defaultPrevented}function ne(e){e.g=function(e,t){if("function"!=typeof e){if(!e||"function"!=typeof e.handleEvent)throw Error("Invalid listener argument");e=l(e.handleEvent,e)}return Number(t)>2147483647?-1:a.setTimeout(e,t||0)}(()=>{e.g=null,e.i&&(e.i=!1,ne(e))},e.l);const t=e.h;e.h=null,e.m.apply(null,t)}d(Z,S),Z.prototype[R]=!0,Z.prototype.removeEventListener=function(e,t,n,r){K(this,e,t,n,r)},Z.prototype.N=function(){if(Z.Z.N.call(this),this.i){var e=this.i;let t=0;for(const n in e.g){const r=e.g[n];for(let e=0;e<r.length;e++)++t,x(r[e]);delete e.g[n],e.h--}}this.G=null},Z.prototype.J=function(e,t,n,r){return this.i.add(String(e),t,!1,n,r)},Z.prototype.K=function(e,t,n,r){return this.i.add(String(e),t,!0,n,r)};class re extends S{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:ne(this)}N(){super.N(),this.g&&(a.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function ie(e){S.call(this),this.h=e,this.g={}}d(ie,S);var oe=[];function se(e){D(e.g,function(e,t){this.g.hasOwnProperty(t)&&$(e)},e),e.g={}}ie.prototype.N=function(){ie.Z.N.call(this),se(this)},ie.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var ae=a.JSON.stringify,ce=a.JSON.parse,ue=class{stringify(e){return a.JSON.stringify(e,void 0)}parse(e){return a.JSON.parse(e,void 0)}};function le(){}function he(){}var de={OPEN:"a",hb:"b",ERROR:"c",tb:"d"};function fe(){A.call(this,"d")}function pe(){A.call(this,"c")}d(fe,A),d(pe,A);var me={},ge=null;function ye(){return ge=ge||new Z}function ve(e){A.call(this,me.Ia,e)}function be(e){const t=ye();ee(t,new ve(t,e))}function _e(e,t){A.call(this,me.STAT_EVENT,e),this.stat=t}function we(e){const t=ye();ee(t,new _e(t,e))}function Ie(e,t){A.call(this,me.Ja,e),this.size=t}function Ee(e,t){if("function"!=typeof e)throw Error("Fn must not be null and must be a function");return a.setTimeout(function(){e()},t)}function Te(){this.g=!0}function Se(e,t,n,r){e.info(function(){return"XMLHTTP TEXT ("+t+"): "+function(e,t){if(!e.g)return t;if(!t)return null;try{const o=JSON.parse(t);if(o)for(e=0;e<o.length;e++)if(Array.isArray(o[e])){var n=o[e];if(!(n.length<2)){var r=n[1];if(Array.isArray(r)&&!(r.length<1)){var i=r[0];if("noop"!=i&&"stop"!=i&&"close"!=i)for(let e=1;e<r.length;e++)r[e]=""}}}return ae(o)}catch(e){return t}}(e,n)+(r?" "+r:"")})}me.Ia="serverreachability",d(ve,A),me.STAT_EVENT="statevent",d(_e,A),me.Ja="timingevent",d(Ie,A),Te.prototype.ua=function(){this.g=!1},Te.prototype.info=function(){};var Ae,Oe={NO_ERROR:0,cb:1,qb:2,pb:3,kb:4,ob:5,rb:6,Ga:7,TIMEOUT:8,ub:9},Pe={ib:"complete",Fb:"success",ERROR:"error",Ga:"abort",xb:"ready",yb:"readystatechange",TIMEOUT:"timeout",sb:"incrementaldata",wb:"progress",lb:"downloadprogress",Nb:"uploadprogress"};function Ce(){}function Re(e){return encodeURIComponent(String(e))}function ke(e){var t=1;e=e.split(":");const n=[];for(;t>0&&e.length;)n.push(e.shift()),t--;return e.length&&n.push(e.join(":")),n}function Ne(e,t,n,r){this.j=e,this.i=t,this.l=n,this.S=r||1,this.V=new ie(this),this.H=45e3,this.J=null,this.o=!1,this.u=this.B=this.A=this.M=this.F=this.T=this.D=null,this.G=[],this.g=null,this.C=0,this.m=this.v=null,this.X=-1,this.K=!1,this.P=0,this.O=null,this.W=this.L=this.U=this.R=!1,this.h=new xe}function xe(){this.i=null,this.g="",this.h=!1}d(Ce,le),Ce.prototype.g=function(){return new XMLHttpRequest},Ae=new Ce;var De={},Me={};function Le(e,t,n){e.M=1,e.A=at(nt(t)),e.u=n,e.R=!0,je(e,null)}function je(e,t){e.F=Date.now(),Ue(e),e.B=nt(e.A);var n=e.B,r=e.S;Array.isArray(r)||(r=[String(r)]),wt(n.i,"t",r),e.C=0,n=e.j.L,e.h=new xe,e.g=cn(e.j,n?t:null,!e.u),e.P>0&&(e.O=new re(l(e.Y,e,e.g),e.P)),t=e.V,n=e.g,r=e.ba;var i="readystatechange";Array.isArray(i)||(i&&(oe[0]=i.toString()),i=oe);for(let e=0;e<i.length;e++){const o=z(n,i[e],r||t.handleEvent,!1,t.h||t);if(!o)break;t.g[o.key]=o}t=e.J?M(e.J):{},e.u?(e.v||(e.v="POST"),t["Content-Type"]="application/x-www-form-urlencoded",e.g.ea(e.B,e.v,e.u,t)):(e.v="GET",e.g.ea(e.B,e.v,null,t)),be(1),function(e,t,n,r,i,o){e.info(function(){if(e.g)if(o){var s="",a=o.split("&");for(let e=0;e<a.length;e++){var c=a[e].split("=");if(c.length>1){const e=c[0];c=c[1];const t=e.split("_");s=t.length>=2&&"type"==t[1]?s+(e+"=")+c+"&":s+(e+"=redacted&")}}}else s=null;else s=o;return"XMLHTTP REQ ("+r+") [attempt "+i+"]: "+t+"\n"+n+"\n"+s})}(e.i,e.v,e.B,e.l,e.S,e.u)}function Fe(e){return!!e.g&&"GET"==e.v&&2!=e.M&&e.j.Aa}function Ve(e,t){var n=e.C,r=t.indexOf("\n",n);return-1==r?Me:(n=Number(t.substring(n,r)),isNaN(n)?De:(r+=1)+n>t.length?Me:(t=t.slice(r,r+n),e.C=r+n,t))}function Ue(e){e.T=Date.now()+e.H,qe(e,e.H)}function qe(e,t){if(null!=e.D)throw Error("WatchDog timer not null");e.D=Ee(l(e.aa,e),t)}function Be(e){e.D&&(a.clearTimeout(e.D),e.D=null)}function ze(e){0==e.j.I||e.K||nn(e.j,e)}function We(e){Be(e);var t=e.O;t&&"function"==typeof t.dispose&&t.dispose(),e.O=null,se(e.V),e.g&&(t=e.g,e.g=null,t.abort(),t.dispose())}function Ge(e,t){try{var n=e.j;if(0!=n.I&&(n.g==e||Je(n.h,e)))if(!e.L&&Je(n.h,e)&&3==n.I){try{var r=n.Ba.g.parse(t)}catch(e){r=null}if(Array.isArray(r)&&3==r.length){var i=r;if(0==i[0]){e:if(!n.v){if(n.g){if(!(n.g.F+3e3<e.F))break e;tn(n),Gt(n)}Xt(n),we(18)}}else n.xa=i[1],0<n.xa-n.K&&i[2]<37500&&n.F&&0==n.A&&!n.C&&(n.C=Ee(l(n.Va,n),6e3));Qe(n.h)<=1&&n.ta&&(n.ta=void 0)}else on(n,11)}else if((e.L||n.g==e)&&tn(n),!P(t))for(i=n.Ba.g.parse(t),t=0;t<i.length;t++){let u=i[t];const l=u[0];if(!(l<=n.K))if(n.K=l,u=u[1],2==n.I)if("c"==u[0]){n.M=u[1],n.ba=u[2];const t=u[3];null!=t&&(n.ka=t,n.j.info("VER="+n.ka));const i=u[4];null!=i&&(n.za=i,n.j.info("SVER="+n.za));const l=u[5];null!=l&&"number"==typeof l&&l>0&&(r=1.5*l,n.O=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 o=r.h;o.g||-1==e.indexOf("spdy")&&-1==e.indexOf("quic")&&-1==e.indexOf("h2")||(o.j=o.l,o.g=new Set,o.h&&(Ye(o,o.h),o.h=null))}if(r.G){const e=h.g?h.g.getResponseHeader("X-HTTP-Session-Id"):null;e&&(r.wa=e,st(r.J,r.G,e))}}n.I=3,n.l&&n.l.ra(),n.aa&&(n.T=Date.now()-e.F,n.j.info("Handshake RTT: "+n.T+"ms"));var s=e;if((r=n).na=an(r,r.L?r.ba:null,r.W),s.L){Xe(r.h,s);var a=s,c=r.O;c&&(a.H=c),a.D&&(Be(a),Ue(a)),r.g=s}else Yt(r);n.i.length>0&&$t(n)}else"stop"!=u[0]&&"close"!=u[0]||on(n,7);else 3==n.I&&("stop"==u[0]||"close"==u[0]?"stop"==u[0]?on(n,7):Wt(n):"noop"!=u[0]&&n.l&&n.l.qa(u),n.A=0)}be(4)}catch(e){}}Ne.prototype.ba=function(e){e=e.target;const t=this.O;t&&3==Ut(e)?t.j():this.Y(e)},Ne.prototype.Y=function(e){try{if(e==this.g)e:{const c=Ut(this.g),u=this.g.ya(),l=this.g.ca();if(!(c<3)&&(3!=c||this.g&&(this.h.h||this.g.la()||qt(this.g)))){this.K||4!=c||7==u||be(8==u||l<=0?3:2),Be(this);var t=this.g.ca();this.X=t;var n=function(e){if(!Fe(e))return e.g.la();const t=qt(e.g);if(""===t)return"";let n="";const r=t.length,i=4==Ut(e.g);if(!e.h.i){if("undefined"==typeof TextDecoder)return We(e),ze(e),"";e.h.i=new a.TextDecoder}for(let o=0;o<r;o++)e.h.h=!0,n+=e.h.i.decode(t[o],{stream:!(i&&o==r-1)});return t.length=0,e.h.g+=n,e.C=0,e.h.g}(this);if(this.o=200==t,function(e,t,n,r,i,o,s){e.info(function(){return"XMLHTTP RESP ("+r+") [ attempt "+i+"]: "+t+"\n"+n+"\n"+o+" "+s})}(this.i,this.v,this.B,this.l,this.S,c,t),this.o){if(this.U&&!this.L){t:{if(this.g){var r,i=this.g;if((r=i.g?i.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!P(r)){var o=r;break t}}o=null}if(!(e=o)){this.o=!1,this.m=3,we(12),We(this),ze(this);break e}Se(this.i,this.l,e,"Initial handshake response via X-HTTP-Initial-Response"),this.L=!0,Ge(this,e)}if(this.R){let t;for(e=!0;!this.K&&this.C<n.length;){if(t=Ve(this,n),t==Me){4==c&&(this.m=4,we(14),e=!1),Se(this.i,this.l,null,"[Incomplete Response]");break}if(t==De){this.m=4,we(15),Se(this.i,this.l,n,"[Invalid Chunk]"),e=!1;break}Se(this.i,this.l,t,null),Ge(this,t)}if(Fe(this)&&0!=this.C&&(this.h.g=this.h.g.slice(this.C),this.C=0),4!=c||0!=n.length||this.h.h||(this.m=1,we(16),e=!1),this.o=this.o&&e,e){if(n.length>0&&!this.W){this.W=!0;var s=this.j;s.g==this&&s.aa&&!s.P&&(s.j.info("Great, no buffering proxy detected. Bytes received: "+n.length),Zt(s),s.P=!0,we(11))}}else Se(this.i,this.l,n,"[Invalid Chunked Response]"),We(this),ze(this)}else Se(this.i,this.l,n,null),Ge(this,n);4==c&&We(this),this.o&&!this.K&&(4==c?nn(this.j,this):(this.o=!1,Ue(this)))}else(function(e){const t={};e=(e.g&&Ut(e)>=2&&e.g.getAllResponseHeaders()||"").split("\r\n");for(let r=0;r<e.length;r++){if(P(e[r]))continue;var n=ke(e[r]);const i=n[0];if("string"!=typeof(n=n[1]))continue;n=n.trim();const o=t[i]||[];t[i]=o,o.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==t&&n.indexOf("Unknown SID")>0?(this.m=3,we(12)):(this.m=0,we(13)),We(this),ze(this)}}}catch(e){}},Ne.prototype.cancel=function(){this.K=!0,We(this)},Ne.prototype.aa=function(){this.D=null;const e=Date.now();e-this.T>=0?(function(e,t){e.info(function(){return"TIMEOUT: "+t})}(this.i,this.B),2!=this.M&&(be(3),we(17)),We(this),this.m=2,ze(this)):qe(this,this.T-e)};var Ke=class{constructor(e,t){this.g=e,this.map=t}};function $e(e){this.l=e||10,e=a.PerformanceNavigationTiming?(e=a.performance.getEntriesByType("navigation")).length>0&&("hq"==e[0].nextHopProtocol||"h2"==e[0].nextHopProtocol):!!(a.chrome&&a.chrome.loadTimes&&a.chrome.loadTimes()&&a.chrome.loadTimes().wasFetchedViaSpdy),this.j=e?this.l:1,this.g=null,this.j>1&&(this.g=new Set),this.h=null,this.i=[]}function He(e){return!!e.h||!!e.g&&e.g.size>=e.j}function Qe(e){return e.h?1:e.g?e.g.size:0}function Je(e,t){return e.h?e.h==t:!!e.g&&e.g.has(t)}function Ye(e,t){e.g?e.g.add(t):e.h=t}function Xe(e,t){e.h&&e.h==t?e.h=null:e.g&&e.g.has(t)&&e.g.delete(t)}function Ze(e){if(null!=e.h)return e.i.concat(e.h.G);if(null!=e.g&&0!==e.g.size){let t=e.i;for(const n of e.g.values())t=t.concat(n.G);return t}return p(e.i)}$e.prototype.cancel=function(){if(this.i=Ze(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 et=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function tt(e){let t;this.g=this.o=this.j="",this.u=null,this.m=this.h="",this.l=!1,e instanceof tt?(this.l=e.l,rt(this,e.j),this.o=e.o,this.g=e.g,it(this,e.u),this.h=e.h,ot(this,It(e.i)),this.m=e.m):e&&(t=String(e).match(et))?(this.l=!1,rt(this,t[1]||"",!0),this.o=ct(t[2]||""),this.g=ct(t[3]||"",!0),it(this,t[4]),this.h=ct(t[5]||"",!0),ot(this,t[6]||"",!0),this.m=ct(t[7]||"")):(this.l=!1,this.i=new gt(null,this.l))}function nt(e){return new tt(e)}function rt(e,t,n){e.j=n?ct(t,!0):t,e.j&&(e.j=e.j.replace(/:$/,""))}function it(e,t){if(t){if(t=Number(t),isNaN(t)||t<0)throw Error("Bad port number "+t);e.u=t}else e.u=null}function ot(e,t,n){t instanceof gt?(e.i=t,function(e,t){t&&!e.j&&(yt(e),e.i=null,e.g.forEach(function(e,t){const n=t.toLowerCase();t!=n&&(vt(this,t),wt(this,n,e))},e)),e.j=t}(e.i,e.l)):(n||(t=ut(t,pt)),e.i=new gt(t,e.l))}function st(e,t,n){e.i.set(t,n)}function at(e){return st(e,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)),e}function ct(e,t){return e?t?decodeURI(e.replace(/%25/g,"%2525")):decodeURIComponent(e):""}function ut(e,t,n){return"string"==typeof e?(e=encodeURI(e).replace(t,lt),n&&(e=e.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),e):null}function lt(e){return"%"+((e=e.charCodeAt(0))>>4&15).toString(16)+(15&e).toString(16)}tt.prototype.toString=function(){const e=[];var t=this.j;t&&e.push(ut(t,ht,!0),":");var n=this.g;return(n||"file"==t)&&(e.push("//"),(t=this.o)&&e.push(ut(t,ht,!0),"@"),e.push(Re(n).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),null!=(n=this.u)&&e.push(":",String(n))),(n=this.h)&&(this.g&&"/"!=n.charAt(0)&&e.push("/"),e.push(ut(n,"/"==n.charAt(0)?ft:dt,!0))),(n=this.i.toString())&&e.push("?",n),(n=this.m)&&e.push("#",ut(n,mt)),e.join("")},tt.prototype.resolve=function(e){const t=nt(this);let n=!!e.j;n?rt(t,e.j):n=!!e.o,n?t.o=e.o:n=!!e.g,n?t.g=e.g:n=null!=e.u;var r=e.h;if(n)it(t,e.u);else if(n=!!e.h){if("/"!=r.charAt(0))if(this.g&&!this.h)r="/"+r;else{var i=t.h.lastIndexOf("/");-1!=i&&(r=t.h.slice(0,i+1)+r)}if(".."==(i=r)||"."==i)r="";else if(-1!=i.indexOf("./")||-1!=i.indexOf("/.")){r=0==i.lastIndexOf("/",0),i=i.split("/");const e=[];for(let t=0;t<i.length;){const n=i[t++];"."==n?r&&t==i.length&&e.push(""):".."==n?((e.length>1||1==e.length&&""!=e[0])&&e.pop(),r&&t==i.length&&e.push("")):(e.push(n),r=!0)}r=e.join("/")}else r=i}return n?t.h=r:n=""!==e.i.toString(),n?ot(t,It(e.i)):n=!!e.m,n&&(t.m=e.m),t};var ht=/[#\/\?@]/g,dt=/[#\?:]/g,ft=/[#\?]/g,pt=/[#\?@]/g,mt=/#/g;function gt(e,t){this.h=this.g=null,this.i=e||null,this.j=!!t}function yt(e){e.g||(e.g=new Map,e.h=0,e.i&&function(e,t){if(e){e=e.split("&");for(let n=0;n<e.length;n++){const r=e[n].indexOf("=");let i,o=null;r>=0?(i=e[n].substring(0,r),o=e[n].substring(r+1)):i=e[n],t(i,o?decodeURIComponent(o.replace(/\+/g," ")):"")}}}(e.i,function(t,n){e.add(decodeURIComponent(t.replace(/\+/g," ")),n)}))}function vt(e,t){yt(e),t=Et(e,t),e.g.has(t)&&(e.i=null,e.h-=e.g.get(t).length,e.g.delete(t))}function bt(e,t){return yt(e),t=Et(e,t),e.g.has(t)}function _t(e,t){yt(e);let n=[];if("string"==typeof t)bt(e,t)&&(n=n.concat(e.g.get(Et(e,t))));else for(e=Array.from(e.g.values()),t=0;t<e.length;t++)n=n.concat(e[t]);return n}function wt(e,t,n){vt(e,t),n.length>0&&(e.i=null,e.g.set(Et(e,t),p(n)),e.h+=n.length)}function It(e){const t=new gt;return t.i=e.i,e.g&&(t.g=new Map(e.g),t.h=e.h),t}function Et(e,t){return t=String(t),e.j&&(t=t.toLowerCase()),t}function Tt(e,t,n,r,i){try{i&&(i.onload=null,i.onerror=null,i.onabort=null,i.ontimeout=null),r(n)}catch(e){}}function St(){this.g=new ue}function At(e){this.i=e.Sb||null,this.h=e.ab||!1}function Ot(e,t){Z.call(this),this.H=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.A=new Headers,this.h=null,this.F="GET",this.D="",this.g=!1,this.B=this.j=this.l=null,this.v=new AbortController}function Pt(e){e.j.read().then(e.Ma.bind(e)).catch(e.ga.bind(e))}function Ct(e){e.readyState=4,e.l=null,e.j=null,e.B=null,Rt(e)}function Rt(e){e.onreadystatechange&&e.onreadystatechange.call(e)}function kt(e){let t="";return D(e,function(e,n){t+=n,t+=":",t+=e,t+="\r\n"}),t}function Nt(e,t,n){e:{for(r in n){var r=!1;break e}r=!0}r||(n=kt(n),"string"==typeof e?(Re(t),null!=n&&Re(n)):st(e,t,n))}function xt(e){Z.call(this),this.headers=new Map,this.L=e||null,this.h=!1,this.g=null,this.D="",this.o=0,this.l="",this.j=this.B=this.v=this.A=!1,this.m=null,this.F="",this.H=!1}(t=gt.prototype).add=function(e,t){yt(this),this.i=null,e=Et(this,e);let n=this.g.get(e);return n||this.g.set(e,n=[]),n.push(t),this.h+=1,this},t.forEach=function(e,t){yt(this),this.g.forEach(function(n,r){n.forEach(function(n){e.call(t,n,r,this)},this)},this)},t.set=function(e,t){return yt(this),this.i=null,bt(this,e=Et(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&&(e=_t(this,e)).length>0?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(let r=0;r<t.length;r++){var n=t[r];const i=Re(n);n=_t(this,n);for(let t=0;t<n.length;t++){let r=i;""!==n[t]&&(r+="="+Re(n[t])),e.push(r)}}return this.i=e.join("&")},d(At,le),At.prototype.g=function(){return new Ot(this.i,this.h)},d(Ot,Z),(t=Ot.prototype).open=function(e,t){if(0!=this.readyState)throw this.abort(),Error("Error reopening a connection");this.F=e,this.D=t,this.readyState=1,Rt(this)},t.send=function(e){if(1!=this.readyState)throw this.abort(),Error("need to call open() first. ");if(this.v.signal.aborted)throw this.abort(),Error("Request was aborted.");this.g=!0;const t={headers:this.A,method:this.F,credentials:this.m,cache:void 0,signal:this.v.signal};e&&(t.body=e),(this.H||a).fetch(new Request(this.D,t)).then(this.Pa.bind(this),this.ga.bind(this))},t.abort=function(){this.response=this.responseText="",this.A=new Headers,this.status=0,this.v.abort(),this.j&&this.j.cancel("Request was aborted.").catch(()=>{}),this.readyState>=1&&this.g&&4!=this.readyState&&(this.g=!1,Ct(this)),this.readyState=0},t.Pa=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,Rt(this)),this.g&&(this.readyState=3,Rt(this),this.g)))if("arraybuffer"===this.responseType)e.arrayBuffer().then(this.Na.bind(this),this.ga.bind(this));else if(void 0!==a.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.B=new TextDecoder;Pt(this)}else e.text().then(this.Oa.bind(this),this.ga.bind(this))},t.Ma=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.B.decode(t,{stream:!e.done}))&&(this.response=this.responseText+=t)}e.done?Ct(this):Rt(this),3==this.readyState&&Pt(this)}},t.Oa=function(e){this.g&&(this.response=this.responseText=e,Ct(this))},t.Na=function(e){this.g&&(this.response=e,Ct(this))},t.ga=function(){this.g&&Ct(this)},t.setRequestHeader=function(e,t){this.A.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(Ot.prototype,"withCredentials",{get:function(){return"include"===this.m},set:function(e){this.m=e?"include":"same-origin"}}),d(xt,Z);var Dt=/^https?$/i,Mt=["POST","PUT"];function Lt(e,t){e.h=!1,e.g&&(e.j=!0,e.g.abort(),e.j=!1),e.l=t,e.o=5,jt(e),Vt(e)}function jt(e){e.A||(e.A=!0,ee(e,"complete"),ee(e,"error"))}function Ft(e){if(e.h&&void 0!==s)if(e.v&&4==Ut(e))setTimeout(e.Ca.bind(e),0);else if(ee(e,"readystatechange"),4==Ut(e)){e.h=!1;try{const o=e.ca();e:switch(o){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===o){let t=String(e.D).match(et)[1]||null;!t&&a.self&&a.self.location&&(t=a.self.location.protocol.slice(0,-1)),r=!Dt.test(t?t.toLowerCase():"")}n=r}if(n)ee(e,"complete"),ee(e,"success");else{e.o=6;try{var i=Ut(e)>2?e.g.statusText:""}catch(e){i=""}e.l=i+" ["+e.ca()+"]",jt(e)}}finally{Vt(e)}}}function Vt(e,t){if(e.g){e.m&&(clearTimeout(e.m),e.m=null);const n=e.g;e.g=null,t||ee(e,"ready");try{n.onreadystatechange=null}catch(e){}}}function Ut(e){return e.g?e.g.readyState:0}function qt(e){try{if(!e.g)return null;if("response"in e.g)return e.g.response;switch(e.F){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 Bt(e,t,n){return n&&n.internalChannelParams&&n.internalChannelParams[e]||t}function zt(e){this.za=0,this.i=[],this.j=new Te,this.ba=this.na=this.J=this.W=this.g=this.wa=this.G=this.H=this.u=this.U=this.o=null,this.Ya=this.V=0,this.Sa=Bt("failFast",!1,e),this.F=this.C=this.v=this.m=this.l=null,this.X=!0,this.xa=this.K=-1,this.Y=this.A=this.D=0,this.Qa=Bt("baseRetryDelayMs",5e3,e),this.Za=Bt("retryDelaySeedMs",1e4,e),this.Ta=Bt("forwardChannelMaxRetries",2,e),this.va=Bt("forwardChannelRequestTimeoutMs",2e4,e),this.ma=e&&e.xmlHttpFactory||void 0,this.Ua=e&&e.Rb||void 0,this.Aa=e&&e.useFetchStreams||!1,this.O=void 0,this.L=e&&e.supportsCrossDomainXhr||!1,this.M="",this.h=new $e(e&&e.concurrentRequestLimit),this.Ba=new St,this.S=e&&e.fastHandshake||!1,this.R=e&&e.encodeInitMessageHeaders||!1,this.S&&this.R&&(this.R=!1),this.Ra=e&&e.Pb||!1,e&&e.ua&&this.j.ua(),e&&e.forceLongPolling&&(this.X=!1),this.aa=!this.S&&this.X&&e&&e.detectBufferingProxy||!1,this.ia=void 0,e&&e.longPollingTimeout&&e.longPollingTimeout>0&&(this.ia=e.longPollingTimeout),this.ta=void 0,this.T=0,this.P=!1,this.ja=this.B=null}function Wt(e){if(Kt(e),3==e.I){var t=e.V++,n=nt(e.J);if(st(n,"SID",e.M),st(n,"RID",t),st(n,"TYPE","terminate"),Qt(e,n),(t=new Ne(e,e.j,t)).M=2,t.A=at(nt(n)),n=!1,a.navigator&&a.navigator.sendBeacon)try{n=a.navigator.sendBeacon(t.A.toString(),"")}catch(e){}!n&&a.Image&&((new Image).src=t.A,n=!0),n||(t.g=cn(t.j,null),t.g.ea(t.A)),t.F=Date.now(),Ue(t)}sn(e)}function Gt(e){e.g&&(Zt(e),e.g.cancel(),e.g=null)}function Kt(e){Gt(e),e.v&&(a.clearTimeout(e.v),e.v=null),tn(e),e.h.cancel(),e.m&&("number"==typeof e.m&&a.clearTimeout(e.m),e.m=null)}function $t(e){if(!He(e.h)&&!e.m){e.m=!0;var t=e.Ea;_||E(),w||(_(),w=!0),I.add(t,e),e.D=0}}function Ht(e,t){var n;n=t?t.l:e.V++;const r=nt(e.J);st(r,"SID",e.M),st(r,"RID",n),st(r,"AID",e.K),Qt(e,r),e.u&&e.o&&Nt(r,e.u,e.o),n=new Ne(e,e.j,n,e.D+1),null===e.u&&(n.J=e.o),t&&(e.i=t.G.concat(e.i)),t=Jt(e,n,1e3),n.H=Math.round(.5*e.va)+Math.round(.5*e.va*Math.random()),Ye(e.h,n),Le(n,r,t)}function Qt(e,t){e.H&&D(e.H,function(e,n){st(t,n,e)}),e.l&&D({},function(e,n){st(t,n,e)})}function Jt(e,t,n){n=Math.min(e.i.length,n);const r=e.l?l(e.l.Ka,e.l,e):null;e:{var i=e.i;let t=-1;for(;;){const e=["count="+n];-1==t?n>0?(t=i[0].g,e.push("ofs="+t)):t=0:e.push("ofs="+t);let a=!0;for(let u=0;u<n;u++){var o=i[u].g;const n=i[u].map;if((o-=t)<0)t=Math.max(0,i[u].g-100),a=!1;else try{o="req"+o+"_"||0;try{var s=n instanceof Map?n:Object.entries(n);for(const[t,n]of s){let r=n;c(n)&&(r=ae(n)),e.push(o+t+"="+encodeURIComponent(r))}}catch(t){throw e.push(o+"type="+encodeURIComponent("_badmap")),t}}catch(e){r&&r(n)}}if(a){s=e.join("&");break e}}s=void 0}return e=e.i.splice(0,n),t.G=e,s}function Yt(e){if(!e.g&&!e.v){e.Y=1;var t=e.Da;_||E(),w||(_(),w=!0),I.add(t,e),e.A=0}}function Xt(e){return!(e.g||e.v||e.A>=3||(e.Y++,e.v=Ee(l(e.Da,e),rn(e,e.A)),e.A++,0))}function Zt(e){null!=e.B&&(a.clearTimeout(e.B),e.B=null)}function en(e){e.g=new Ne(e,e.j,"rpc",e.Y),null===e.u&&(e.g.J=e.o),e.g.P=0;var t=nt(e.na);st(t,"RID","rpc"),st(t,"SID",e.M),st(t,"AID",e.K),st(t,"CI",e.F?"0":"1"),!e.F&&e.ia&&st(t,"TO",e.ia),st(t,"TYPE","xmlhttp"),Qt(e,t),e.u&&e.o&&Nt(t,e.u,e.o),e.O&&(e.g.H=e.O);var n=e.g;e=e.ba,n.M=1,n.A=at(nt(t)),n.u=null,n.R=!0,je(n,e)}function tn(e){null!=e.C&&(a.clearTimeout(e.C),e.C=null)}function nn(e,t){var n=null;if(e.g==t){tn(e),Zt(e),e.g=null;var r=2}else{if(!Je(e.h,t))return;n=t.G,Xe(e.h,t),r=1}if(0!=e.I)if(t.o)if(1==r){n=t.u?t.u.length:0,t=Date.now()-t.F;var i=e.D;ee(r=ye(),new Ie(r,n,t,i)),$t(e)}else Yt(e);else if(3==(i=t.m)||0==i&&t.X>0||!(1==r&&function(e,t){return!(Qe(e.h)>=e.h.j-(e.m?1:0)||(e.m?(e.i=t.G.concat(e.i),0):1==e.I||2==e.I||e.D>=(e.Sa?0:e.Ta)||(e.m=Ee(l(e.Ea,e,t),rn(e,e.D)),e.D++,0)))}(e,t)||2==r&&Xt(e)))switch(n&&n.length>0&&(t=e.h,t.i=t.i.concat(n)),i){case 1:on(e,5);break;case 4:on(e,10);break;case 3:on(e,6);break;default:on(e,2)}}function rn(e,t){let n=e.Qa+Math.floor(Math.random()*e.Za);return e.isActive()||(n*=2),n*t}function on(e,t){if(e.j.info("Error code "+t),2==t){var n=l(e.bb,e),r=e.Ua;const t=!r;r=new tt(r||"//www.google.com/images/cleardot.gif"),a.location&&"http"==a.location.protocol||rt(r,"https"),at(r),t?function(e,t){const n=new Te;if(a.Image){const r=new Image;r.onload=h(Tt,n,"TestLoadImage: loaded",!0,t,r),r.onerror=h(Tt,n,"TestLoadImage: error",!1,t,r),r.onabort=h(Tt,n,"TestLoadImage: abort",!1,t,r),r.ontimeout=h(Tt,n,"TestLoadImage: timeout",!1,t,r),a.setTimeout(function(){r.ontimeout&&r.ontimeout()},1e4),r.src=e}else t(!1)}(r.toString(),n):function(e,t){new Te;const n=new AbortController,r=setTimeout(()=>{n.abort(),Tt(0,0,!1,t)},1e4);fetch(e,{signal:n.signal}).then(e=>{clearTimeout(r),e.ok?Tt(0,0,!0,t):Tt(0,0,!1,t)}).catch(()=>{clearTimeout(r),Tt(0,0,!1,t)})}(r.toString(),n)}else we(2);e.I=0,e.l&&e.l.pa(t),sn(e),Kt(e)}function sn(e){if(e.I=0,e.ja=[],e.l){const t=Ze(e.h);0==t.length&&0==e.i.length||(m(e.ja,t),m(e.ja,e.i),e.h.i.length=0,p(e.i),e.i.length=0),e.l.oa()}}function an(e,t,n){var r=n instanceof tt?nt(n):new tt(n);if(""!=r.g)t&&(r.g=t+"."+r.g),it(r,r.u);else{var i=a.location;r=i.protocol,t=t?t+"."+i.hostname:i.hostname,i=+i.port;const e=new tt(null);r&&rt(e,r),t&&(e.g=t),i&&it(e,i),n&&(e.h=n),r=e}return n=e.G,t=e.wa,n&&t&&st(r,n,t),st(r,"VER",e.ka),Qt(e,r),r}function cn(e,t,n){if(t&&!e.L)throw Error("Can't create secondary domain capable XhrIo object.");return(t=e.Aa&&!e.ma?new xt(new At({ab:n})):new xt(e.ma)).Fa(e.L),t}function un(){}function ln(){}function hn(e,t){Z.call(this),this.g=new zt(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.sa&&(e?e["X-WebChannel-Client-Profile"]=t.sa:e={"X-WebChannel-Client-Profile":t.sa}),this.g.U=e,(e=t&&t.Qb)&&!P(e)&&(this.g.u=e),this.A=t&&t.supportsCrossDomainXhr||!1,this.v=t&&t.sendRawJson||!1,(t=t&&t.httpSessionIdParam)&&!P(t)&&(this.g.G=t,null!==(e=this.h)&&t in e&&t in(e=this.h)&&delete e[t]),this.j=new pn(this)}function dn(e){fe.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 fn(){pe.call(this),this.status=1}function pn(e){this.g=e}(t=xt.prototype).Fa=function(e){this.H=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.o=0,this.A=!1,this.h=!0,this.g=this.L?this.L.g():Ae.g(),this.g.onreadystatechange=f(l(this.Ca,this));try{this.B=!0,this.g.open(t,String(e),!0),this.B=!1}catch(e){return void Lt(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=a.FormData&&e instanceof a.FormData,!(Array.prototype.indexOf.call(Mt,t,void 0)>=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.F&&(this.g.responseType=this.F),"withCredentials"in this.g&&this.g.withCredentials!==this.H&&(this.g.withCredentials=this.H);try{this.m&&(clearTimeout(this.m),this.m=null),this.v=!0,this.g.send(e),this.v=!1}catch(e){Lt(this,e)}},t.abort=function(e){this.g&&this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1,this.o=e||7,ee(this,"complete"),ee(this,"abort"),Vt(this))},t.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),Vt(this,!0)),xt.Z.N.call(this)},t.Ca=function(){this.u||(this.B||this.v||this.j?Ft(this):this.Xa())},t.Xa=function(){Ft(this)},t.isActive=function(){return!!this.g},t.ca=function(){try{return Ut(this)>2?this.g.status:-1}catch(e){return-1}},t.la=function(){try{return this.g?this.g.responseText:""}catch(e){return""}},t.La=function(e){if(this.g){var t=this.g.responseText;return e&&0==t.indexOf(e)&&(t=t.substring(e.length)),ce(t)}},t.ya=function(){return this.o},t.Ha=function(){return"string"==typeof this.l?this.l:String(this.l)},(t=zt.prototype).ka=8,t.I=1,t.connect=function(e,t,n,r){we(0),this.W=e,this.H=t||{},n&&void 0!==r&&(this.H.OSID=n,this.H.OAID=r),this.F=this.X,this.J=an(this,null,this.W),$t(this)},t.Ea=function(e){if(this.m)if(this.m=null,1==this.I){if(!e){this.V=Math.floor(1e5*Math.random()),e=this.V++;const i=new Ne(this,this.j,e);let o=this.o;if(this.U&&(o?(o=M(o),j(o,this.U)):o=this.U),null!==this.u||this.R||(i.J=o,o=null),this.S)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((t+=r)>4096){t=n;break e}if(4096===t||n===this.i.length-1){t=n+1;break e}}t=1e3}else t=1e3;t=Jt(this,i,t),st(n=nt(this.J),"RID",e),st(n,"CVER",22),this.G&&st(n,"X-HTTP-Session-Id",this.G),Qt(this,n),o&&(this.R?t="headers="+Re(kt(o))+"&"+t:this.u&&Nt(n,this.u,o)),Ye(this.h,i),this.Ra&&st(n,"TYPE","init"),this.S?(st(n,"$req",t),st(n,"SID","null"),i.U=!0,Le(i,n,null)):Le(i,n,t),this.I=2}}else 3==this.I&&(e?Ht(this,e):0==this.i.length||He(this.h)||Ht(this))},t.Da=function(){if(this.v=null,en(this),this.aa&&!(this.P||null==this.g||this.T<=0)){var e=4*this.T;this.j.info("BP detection timer enabled: "+e),this.B=Ee(l(this.Wa,this),e)}},t.Wa=function(){this.B&&(this.B=null,this.j.info("BP detection timeout reached."),this.j.info("Buffering proxy detected and switch to long-polling!"),this.F=!1,this.P=!0,we(10),Gt(this),en(this))},t.Va=function(){null!=this.C&&(this.C=null,Gt(this),Xt(this),we(19))},t.bb=function(e){e?(this.j.info("Successfully pinged google.com"),we(2)):(this.j.info("Failed to ping google.com"),we(1))},t.isActive=function(){return!!this.l&&this.l.isActive(this)},(t=un.prototype).ra=function(){},t.qa=function(){},t.pa=function(){},t.oa=function(){},t.isActive=function(){return!0},t.Ka=function(){},ln.prototype.g=function(e,t){return new hn(e,t)},d(hn,Z),hn.prototype.m=function(){this.g.l=this.j,this.A&&(this.g.L=!0),this.g.connect(this.l,this.h||void 0)},hn.prototype.close=function(){Wt(this.g)},hn.prototype.o=function(e){var t=this.g;if("string"==typeof e){var n={};n.__data__=e,e=n}else this.v&&((n={}).__data__=ae(e),e=n);t.i.push(new Ke(t.Ya++,e)),3==t.I&&$t(t)},hn.prototype.N=function(){this.g.l=null,delete this.j,Wt(this.g),delete this.g,hn.Z.N.call(this)},d(dn,fe),d(fn,pe),d(pn,un),pn.prototype.ra=function(){ee(this.g,"a")},pn.prototype.qa=function(e){ee(this.g,new dn(e))},pn.prototype.pa=function(e){ee(this.g,new fn(e))},pn.prototype.oa=function(){ee(this.g,"b")},ln.prototype.createWebChannel=ln.prototype.g,hn.prototype.send=hn.prototype.o,hn.prototype.open=hn.prototype.m,hn.prototype.close=hn.prototype.close,e.exports.createWebChannelTransport=function(){return new ln},e.exports.getStatEventTarget=function(){return ye()},e.exports.Event=me,e.exports.Stat={jb:0,mb:1,nb:2,Hb:3,Mb:4,Jb:5,Kb:6,Ib:7,Gb:8,Lb:9,PROXY:10,NOPROXY:11,Eb:12,Ab:13,Bb:14,zb:15,Cb:16,Db:17,fb:18,eb:19,gb:20},Oe.NO_ERROR=0,Oe.TIMEOUT=8,Oe.HTTP_ERROR=6,e.exports.ErrorCode=Oe,Pe.COMPLETE="complete",e.exports.EventType=Pe,he.EventType=de,de.OPEN="a",de.CLOSE="b",de.ERROR="c",de.MESSAGE="d",Z.prototype.listen=Z.prototype.J,e.exports.WebChannel=he,e.exports.FetchXmlHttpFactory=At,xt.prototype.listenOnce=xt.prototype.K,xt.prototype.getLastError=xt.prototype.Ha,xt.prototype.getLastErrorCode=xt.prototype.ya,xt.prototype.getStatus=xt.prototype.ca,xt.prototype.getResponseJson=xt.prototype.La,xt.prototype.getResponseText=xt.prototype.la,xt.prototype.send=xt.prototype.ea,xt.prototype.setWithCredentials=xt.prototype.Fa,e.exports.XhrIo=xt}).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","12.10.0","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(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,o){if("undefined"!=typeof document){"number"==typeof(o=e({},r,o)).expires&&(o.expires=new Date(Date.now()+864e5*o.expires)),o.expires&&(o.expires=o.expires.toUTCString()),t=encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var s="";for(var a in o)o[a]&&(s+="; "+a,!0!==o[a]&&(s+="="+o[a].split(";")[0]));return document.cookie=t+"="+n.write(i,t)+s}}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 o=t[i].split("="),s=o.slice(1).join("=");try{var a=decodeURIComponent(o[0]);if(r[a]=n.read(s,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:"/"})}()},9364(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.interval=t.iif=t.generate=t.fromEventPattern=t.fromEvent=t.from=t.forkJoin=t.empty=t.defer=t.connectable=t.concat=t.combineLatest=t.bindNodeCallback=t.bindCallback=t.UnsubscriptionError=t.TimeoutError=t.SequenceError=t.ObjectUnsubscribedError=t.NotFoundError=t.EmptyError=t.ArgumentOutOfRangeError=t.firstValueFrom=t.lastValueFrom=t.isObservable=t.identity=t.noop=t.pipe=t.NotificationKind=t.Notification=t.Subscriber=t.Subscription=t.Scheduler=t.VirtualAction=t.VirtualTimeScheduler=t.animationFrameScheduler=t.animationFrame=t.queueScheduler=t.queue=t.asyncScheduler=t.async=t.asapScheduler=t.asap=t.AsyncSubject=t.ReplaySubject=t.BehaviorSubject=t.Subject=t.animationFrames=t.observable=t.ConnectableObservable=t.Observable=void 0,t.filter=t.expand=t.exhaustMap=t.exhaustAll=t.exhaust=t.every=t.endWith=t.elementAt=t.distinctUntilKeyChanged=t.distinctUntilChanged=t.distinct=t.dematerialize=t.delayWhen=t.delay=t.defaultIfEmpty=t.debounceTime=t.debounce=t.count=t.connect=t.concatWith=t.concatMapTo=t.concatMap=t.concatAll=t.combineLatestWith=t.combineLatestAll=t.combineAll=t.catchError=t.bufferWhen=t.bufferToggle=t.bufferTime=t.bufferCount=t.buffer=t.auditTime=t.audit=t.config=t.NEVER=t.EMPTY=t.scheduled=t.zip=t.using=t.timer=t.throwError=t.range=t.race=t.partition=t.pairs=t.onErrorResumeNext=t.of=t.never=t.merge=void 0,t.switchMap=t.switchAll=t.subscribeOn=t.startWith=t.skipWhile=t.skipUntil=t.skipLast=t.skip=t.single=t.shareReplay=t.share=t.sequenceEqual=t.scan=t.sampleTime=t.sample=t.refCount=t.retryWhen=t.retry=t.repeatWhen=t.repeat=t.reduce=t.raceWith=t.publishReplay=t.publishLast=t.publishBehavior=t.publish=t.pluck=t.pairwise=t.onErrorResumeNextWith=t.observeOn=t.multicast=t.min=t.mergeWith=t.mergeScan=t.mergeMapTo=t.mergeMap=t.flatMap=t.mergeAll=t.max=t.materialize=t.mapTo=t.map=t.last=t.isEmpty=t.ignoreElements=t.groupBy=t.first=t.findIndex=t.find=t.finalize=void 0,t.zipWith=t.zipAll=t.withLatestFrom=t.windowWhen=t.windowToggle=t.windowTime=t.windowCount=t.window=t.toArray=t.timestamp=t.timeoutWith=t.timeout=t.timeInterval=t.throwIfEmpty=t.throttleTime=t.throttle=t.tap=t.takeWhile=t.takeUntil=t.takeLast=t.take=t.switchScan=t.switchMapTo=void 0;var o=n(8051);Object.defineProperty(t,"Observable",{enumerable:!0,get:function(){return o.Observable}});var s=n(4359);Object.defineProperty(t,"ConnectableObservable",{enumerable:!0,get:function(){return s.ConnectableObservable}});var a=n(2884);Object.defineProperty(t,"observable",{enumerable:!0,get:function(){return a.observable}});var c=n(1875);Object.defineProperty(t,"animationFrames",{enumerable:!0,get:function(){return c.animationFrames}});var u=n(6808);Object.defineProperty(t,"Subject",{enumerable:!0,get:function(){return u.Subject}});var l=n(7314);Object.defineProperty(t,"BehaviorSubject",{enumerable:!0,get:function(){return l.BehaviorSubject}});var h=n(381);Object.defineProperty(t,"ReplaySubject",{enumerable:!0,get:function(){return h.ReplaySubject}});var d=n(5130);Object.defineProperty(t,"AsyncSubject",{enumerable:!0,get:function(){return d.AsyncSubject}});var f=n(2105);Object.defineProperty(t,"asap",{enumerable:!0,get:function(){return f.asap}}),Object.defineProperty(t,"asapScheduler",{enumerable:!0,get:function(){return f.asapScheduler}});var p=n(2326);Object.defineProperty(t,"async",{enumerable:!0,get:function(){return p.async}}),Object.defineProperty(t,"asyncScheduler",{enumerable:!0,get:function(){return p.asyncScheduler}});var m=n(9245);Object.defineProperty(t,"queue",{enumerable:!0,get:function(){return m.queue}}),Object.defineProperty(t,"queueScheduler",{enumerable:!0,get:function(){return m.queueScheduler}});var g=n(5887);Object.defineProperty(t,"animationFrame",{enumerable:!0,get:function(){return g.animationFrame}}),Object.defineProperty(t,"animationFrameScheduler",{enumerable:!0,get:function(){return g.animationFrameScheduler}});var y=n(875);Object.defineProperty(t,"VirtualTimeScheduler",{enumerable:!0,get:function(){return y.VirtualTimeScheduler}}),Object.defineProperty(t,"VirtualAction",{enumerable:!0,get:function(){return y.VirtualAction}});var v=n(5881);Object.defineProperty(t,"Scheduler",{enumerable:!0,get:function(){return v.Scheduler}});var b=n(9879);Object.defineProperty(t,"Subscription",{enumerable:!0,get:function(){return b.Subscription}});var _=n(2708);Object.defineProperty(t,"Subscriber",{enumerable:!0,get:function(){return _.Subscriber}});var w=n(1245);Object.defineProperty(t,"Notification",{enumerable:!0,get:function(){return w.Notification}}),Object.defineProperty(t,"NotificationKind",{enumerable:!0,get:function(){return w.NotificationKind}});var I=n(1898);Object.defineProperty(t,"pipe",{enumerable:!0,get:function(){return I.pipe}});var E=n(5717);Object.defineProperty(t,"noop",{enumerable:!0,get:function(){return E.noop}});var T=n(7699);Object.defineProperty(t,"identity",{enumerable:!0,get:function(){return T.identity}});var S=n(2560);Object.defineProperty(t,"isObservable",{enumerable:!0,get:function(){return S.isObservable}});var A=n(5761);Object.defineProperty(t,"lastValueFrom",{enumerable:!0,get:function(){return A.lastValueFrom}});var O=n(841);Object.defineProperty(t,"firstValueFrom",{enumerable:!0,get:function(){return O.firstValueFrom}});var P=n(7024);Object.defineProperty(t,"ArgumentOutOfRangeError",{enumerable:!0,get:function(){return P.ArgumentOutOfRangeError}});var C=n(9328);Object.defineProperty(t,"EmptyError",{enumerable:!0,get:function(){return C.EmptyError}});var R=n(3506);Object.defineProperty(t,"NotFoundError",{enumerable:!0,get:function(){return R.NotFoundError}});var k=n(839);Object.defineProperty(t,"ObjectUnsubscribedError",{enumerable:!0,get:function(){return k.ObjectUnsubscribedError}});var N=n(4708);Object.defineProperty(t,"SequenceError",{enumerable:!0,get:function(){return N.SequenceError}});var x=n(1713);Object.defineProperty(t,"TimeoutError",{enumerable:!0,get:function(){return x.TimeoutError}});var D=n(9517);Object.defineProperty(t,"UnsubscriptionError",{enumerable:!0,get:function(){return D.UnsubscriptionError}});var M=n(9750);Object.defineProperty(t,"bindCallback",{enumerable:!0,get:function(){return M.bindCallback}});var L=n(1946);Object.defineProperty(t,"bindNodeCallback",{enumerable:!0,get:function(){return L.bindNodeCallback}});var j=n(8246);Object.defineProperty(t,"combineLatest",{enumerable:!0,get:function(){return j.combineLatest}});var F=n(9546);Object.defineProperty(t,"concat",{enumerable:!0,get:function(){return F.concat}});var V=n(8590);Object.defineProperty(t,"connectable",{enumerable:!0,get:function(){return V.connectable}});var U=n(5884);Object.defineProperty(t,"defer",{enumerable:!0,get:function(){return U.defer}});var q=n(4885);Object.defineProperty(t,"empty",{enumerable:!0,get:function(){return q.empty}});var B=n(5266);Object.defineProperty(t,"forkJoin",{enumerable:!0,get:function(){return B.forkJoin}});var z=n(7058);Object.defineProperty(t,"from",{enumerable:!0,get:function(){return z.from}});var W=n(8616);Object.defineProperty(t,"fromEvent",{enumerable:!0,get:function(){return W.fromEvent}});var G=n(6920);Object.defineProperty(t,"fromEventPattern",{enumerable:!0,get:function(){return G.fromEventPattern}});var K=n(7281);Object.defineProperty(t,"generate",{enumerable:!0,get:function(){return K.generate}});var $=n(9380);Object.defineProperty(t,"iif",{enumerable:!0,get:function(){return $.iif}});var H=n(2275);Object.defineProperty(t,"interval",{enumerable:!0,get:function(){return H.interval}});var Q=n(5936);Object.defineProperty(t,"merge",{enumerable:!0,get:function(){return Q.merge}});var J=n(1934);Object.defineProperty(t,"never",{enumerable:!0,get:function(){return J.never}});var Y=n(1587);Object.defineProperty(t,"of",{enumerable:!0,get:function(){return Y.of}});var X=n(1903);Object.defineProperty(t,"onErrorResumeNext",{enumerable:!0,get:function(){return X.onErrorResumeNext}});var Z=n(8269);Object.defineProperty(t,"pairs",{enumerable:!0,get:function(){return Z.pairs}});var ee=n(7406);Object.defineProperty(t,"partition",{enumerable:!0,get:function(){return ee.partition}});var te=n(9795);Object.defineProperty(t,"race",{enumerable:!0,get:function(){return te.race}});var ne=n(4385);Object.defineProperty(t,"range",{enumerable:!0,get:function(){return ne.range}});var re=n(6680);Object.defineProperty(t,"throwError",{enumerable:!0,get:function(){return re.throwError}});var ie=n(5825);Object.defineProperty(t,"timer",{enumerable:!0,get:function(){return ie.timer}});var oe=n(5904);Object.defineProperty(t,"using",{enumerable:!0,get:function(){return oe.using}});var se=n(1415);Object.defineProperty(t,"zip",{enumerable:!0,get:function(){return se.zip}});var ae=n(131);Object.defineProperty(t,"scheduled",{enumerable:!0,get:function(){return ae.scheduled}});var ce=n(4885);Object.defineProperty(t,"EMPTY",{enumerable:!0,get:function(){return ce.EMPTY}});var ue=n(1934);Object.defineProperty(t,"NEVER",{enumerable:!0,get:function(){return ue.NEVER}}),i(n(6153),t);var le=n(3728);Object.defineProperty(t,"config",{enumerable:!0,get:function(){return le.config}});var he=n(8877);Object.defineProperty(t,"audit",{enumerable:!0,get:function(){return he.audit}});var de=n(1608);Object.defineProperty(t,"auditTime",{enumerable:!0,get:function(){return de.auditTime}});var fe=n(706);Object.defineProperty(t,"buffer",{enumerable:!0,get:function(){return fe.buffer}});var pe=n(9287);Object.defineProperty(t,"bufferCount",{enumerable:!0,get:function(){return pe.bufferCount}});var me=n(1719);Object.defineProperty(t,"bufferTime",{enumerable:!0,get:function(){return me.bufferTime}});var ge=n(1778);Object.defineProperty(t,"bufferToggle",{enumerable:!0,get:function(){return ge.bufferToggle}});var ye=n(6606);Object.defineProperty(t,"bufferWhen",{enumerable:!0,get:function(){return ye.bufferWhen}});var ve=n(2719);Object.defineProperty(t,"catchError",{enumerable:!0,get:function(){return ve.catchError}});var be=n(9244);Object.defineProperty(t,"combineAll",{enumerable:!0,get:function(){return be.combineAll}});var _e=n(7933);Object.defineProperty(t,"combineLatestAll",{enumerable:!0,get:function(){return _e.combineLatestAll}});var we=n(2044);Object.defineProperty(t,"combineLatestWith",{enumerable:!0,get:function(){return we.combineLatestWith}});var Ie=n(201);Object.defineProperty(t,"concatAll",{enumerable:!0,get:function(){return Ie.concatAll}});var Ee=n(9512);Object.defineProperty(t,"concatMap",{enumerable:!0,get:function(){return Ee.concatMap}});var Te=n(9913);Object.defineProperty(t,"concatMapTo",{enumerable:!0,get:function(){return Te.concatMapTo}});var Se=n(8032);Object.defineProperty(t,"concatWith",{enumerable:!0,get:function(){return Se.concatWith}});var Ae=n(7812);Object.defineProperty(t,"connect",{enumerable:!0,get:function(){return Ae.connect}});var Oe=n(8589);Object.defineProperty(t,"count",{enumerable:!0,get:function(){return Oe.count}});var Pe=n(3143);Object.defineProperty(t,"debounce",{enumerable:!0,get:function(){return Pe.debounce}});var Ce=n(1762);Object.defineProperty(t,"debounceTime",{enumerable:!0,get:function(){return Ce.debounceTime}});var Re=n(8799);Object.defineProperty(t,"defaultIfEmpty",{enumerable:!0,get:function(){return Re.defaultIfEmpty}});var ke=n(5797);Object.defineProperty(t,"delay",{enumerable:!0,get:function(){return ke.delay}});var Ne=n(2885);Object.defineProperty(t,"delayWhen",{enumerable:!0,get:function(){return Ne.delayWhen}});var xe=n(9818);Object.defineProperty(t,"dematerialize",{enumerable:!0,get:function(){return xe.dematerialize}});var De=n(7876);Object.defineProperty(t,"distinct",{enumerable:!0,get:function(){return De.distinct}});var Me=n(9663);Object.defineProperty(t,"distinctUntilChanged",{enumerable:!0,get:function(){return Me.distinctUntilChanged}});var Le=n(6035);Object.defineProperty(t,"distinctUntilKeyChanged",{enumerable:!0,get:function(){return Le.distinctUntilKeyChanged}});var je=n(1279);Object.defineProperty(t,"elementAt",{enumerable:!0,get:function(){return je.elementAt}});var Fe=n(6791);Object.defineProperty(t,"endWith",{enumerable:!0,get:function(){return Fe.endWith}});var Ve=n(1361);Object.defineProperty(t,"every",{enumerable:!0,get:function(){return Ve.every}});var Ue=n(1464);Object.defineProperty(t,"exhaust",{enumerable:!0,get:function(){return Ue.exhaust}});var qe=n(7977);Object.defineProperty(t,"exhaustAll",{enumerable:!0,get:function(){return qe.exhaustAll}});var Be=n(6632);Object.defineProperty(t,"exhaustMap",{enumerable:!0,get:function(){return Be.exhaustMap}});var ze=n(5544);Object.defineProperty(t,"expand",{enumerable:!0,get:function(){return ze.expand}});var We=n(5934);Object.defineProperty(t,"filter",{enumerable:!0,get:function(){return We.filter}});var Ge=n(7802);Object.defineProperty(t,"finalize",{enumerable:!0,get:function(){return Ge.finalize}});var Ke=n(8183);Object.defineProperty(t,"find",{enumerable:!0,get:function(){return Ke.find}});var $e=n(9035);Object.defineProperty(t,"findIndex",{enumerable:!0,get:function(){return $e.findIndex}});var He=n(9980);Object.defineProperty(t,"first",{enumerable:!0,get:function(){return He.first}});var Qe=n(5128);Object.defineProperty(t,"groupBy",{enumerable:!0,get:function(){return Qe.groupBy}});var Je=n(2959);Object.defineProperty(t,"ignoreElements",{enumerable:!0,get:function(){return Je.ignoreElements}});var Ye=n(9915);Object.defineProperty(t,"isEmpty",{enumerable:!0,get:function(){return Ye.isEmpty}});var Xe=n(2568);Object.defineProperty(t,"last",{enumerable:!0,get:function(){return Xe.last}});var Ze=n(6872);Object.defineProperty(t,"map",{enumerable:!0,get:function(){return Ze.map}});var et=n(3337);Object.defineProperty(t,"mapTo",{enumerable:!0,get:function(){return et.mapTo}});var tt=n(5019);Object.defineProperty(t,"materialize",{enumerable:!0,get:function(){return tt.materialize}});var nt=n(96);Object.defineProperty(t,"max",{enumerable:!0,get:function(){return nt.max}});var rt=n(8087);Object.defineProperty(t,"mergeAll",{enumerable:!0,get:function(){return rt.mergeAll}});var it=n(4613);Object.defineProperty(t,"flatMap",{enumerable:!0,get:function(){return it.flatMap}});var ot=n(7478);Object.defineProperty(t,"mergeMap",{enumerable:!0,get:function(){return ot.mergeMap}});var st=n(6075);Object.defineProperty(t,"mergeMapTo",{enumerable:!0,get:function(){return st.mergeMapTo}});var at=n(6707);Object.defineProperty(t,"mergeScan",{enumerable:!0,get:function(){return at.mergeScan}});var ct=n(9694);Object.defineProperty(t,"mergeWith",{enumerable:!0,get:function(){return ct.mergeWith}});var ut=n(142);Object.defineProperty(t,"min",{enumerable:!0,get:function(){return ut.min}});var lt=n(8464);Object.defineProperty(t,"multicast",{enumerable:!0,get:function(){return lt.multicast}});var ht=n(2071);Object.defineProperty(t,"observeOn",{enumerable:!0,get:function(){return ht.observeOn}});var dt=n(5513);Object.defineProperty(t,"onErrorResumeNextWith",{enumerable:!0,get:function(){return dt.onErrorResumeNextWith}});var ft=n(6744);Object.defineProperty(t,"pairwise",{enumerable:!0,get:function(){return ft.pairwise}});var pt=n(6355);Object.defineProperty(t,"pluck",{enumerable:!0,get:function(){return pt.pluck}});var mt=n(3197);Object.defineProperty(t,"publish",{enumerable:!0,get:function(){return mt.publish}});var gt=n(2955);Object.defineProperty(t,"publishBehavior",{enumerable:!0,get:function(){return gt.publishBehavior}});var yt=n(6569);Object.defineProperty(t,"publishLast",{enumerable:!0,get:function(){return yt.publishLast}});var vt=n(8710);Object.defineProperty(t,"publishReplay",{enumerable:!0,get:function(){return vt.publishReplay}});var bt=n(6677);Object.defineProperty(t,"raceWith",{enumerable:!0,get:function(){return bt.raceWith}});var _t=n(2070);Object.defineProperty(t,"reduce",{enumerable:!0,get:function(){return _t.reduce}});var wt=n(6131);Object.defineProperty(t,"repeat",{enumerable:!0,get:function(){return wt.repeat}});var It=n(2139);Object.defineProperty(t,"repeatWhen",{enumerable:!0,get:function(){return It.repeatWhen}});var Et=n(3352);Object.defineProperty(t,"retry",{enumerable:!0,get:function(){return Et.retry}});var Tt=n(3956);Object.defineProperty(t,"retryWhen",{enumerable:!0,get:function(){return Tt.retryWhen}});var St=n(9224);Object.defineProperty(t,"refCount",{enumerable:!0,get:function(){return St.refCount}});var At=n(3434);Object.defineProperty(t,"sample",{enumerable:!0,get:function(){return At.sample}});var Ot=n(4143);Object.defineProperty(t,"sampleTime",{enumerable:!0,get:function(){return Ot.sampleTime}});var Pt=n(5565);Object.defineProperty(t,"scan",{enumerable:!0,get:function(){return Pt.scan}});var Ct=n(3929);Object.defineProperty(t,"sequenceEqual",{enumerable:!0,get:function(){return Ct.sequenceEqual}});var Rt=n(3405);Object.defineProperty(t,"share",{enumerable:!0,get:function(){return Rt.share}});var kt=n(7782);Object.defineProperty(t,"shareReplay",{enumerable:!0,get:function(){return kt.shareReplay}});var Nt=n(5440);Object.defineProperty(t,"single",{enumerable:!0,get:function(){return Nt.single}});var xt=n(3079);Object.defineProperty(t,"skip",{enumerable:!0,get:function(){return xt.skip}});var Dt=n(2359);Object.defineProperty(t,"skipLast",{enumerable:!0,get:function(){return Dt.skipLast}});var Mt=n(7783);Object.defineProperty(t,"skipUntil",{enumerable:!0,get:function(){return Mt.skipUntil}});var Lt=n(5774);Object.defineProperty(t,"skipWhile",{enumerable:!0,get:function(){return Lt.skipWhile}});var jt=n(9054);Object.defineProperty(t,"startWith",{enumerable:!0,get:function(){return jt.startWith}});var Ft=n(5455);Object.defineProperty(t,"subscribeOn",{enumerable:!0,get:function(){return Ft.subscribeOn}});var Vt=n(6201);Object.defineProperty(t,"switchAll",{enumerable:!0,get:function(){return Vt.switchAll}});var Ut=n(680);Object.defineProperty(t,"switchMap",{enumerable:!0,get:function(){return Ut.switchMap}});var qt=n(761);Object.defineProperty(t,"switchMapTo",{enumerable:!0,get:function(){return qt.switchMapTo}});var Bt=n(8461);Object.defineProperty(t,"switchScan",{enumerable:!0,get:function(){return Bt.switchScan}});var zt=n(4383);Object.defineProperty(t,"take",{enumerable:!0,get:function(){return zt.take}});var Wt=n(5279);Object.defineProperty(t,"takeLast",{enumerable:!0,get:function(){return Wt.takeLast}});var Gt=n(6911);Object.defineProperty(t,"takeUntil",{enumerable:!0,get:function(){return Gt.takeUntil}});var Kt=n(598);Object.defineProperty(t,"takeWhile",{enumerable:!0,get:function(){return Kt.takeWhile}});var $t=n(7400);Object.defineProperty(t,"tap",{enumerable:!0,get:function(){return $t.tap}});var Ht=n(4880);Object.defineProperty(t,"throttle",{enumerable:!0,get:function(){return Ht.throttle}});var Qt=n(7245);Object.defineProperty(t,"throttleTime",{enumerable:!0,get:function(){return Qt.throttleTime}});var Jt=n(632);Object.defineProperty(t,"throwIfEmpty",{enumerable:!0,get:function(){return Jt.throwIfEmpty}});var Yt=n(2508);Object.defineProperty(t,"timeInterval",{enumerable:!0,get:function(){return Yt.timeInterval}});var Xt=n(1713);Object.defineProperty(t,"timeout",{enumerable:!0,get:function(){return Xt.timeout}});var Zt=n(597);Object.defineProperty(t,"timeoutWith",{enumerable:!0,get:function(){return Zt.timeoutWith}});var en=n(3866);Object.defineProperty(t,"timestamp",{enumerable:!0,get:function(){return en.timestamp}});var tn=n(3484);Object.defineProperty(t,"toArray",{enumerable:!0,get:function(){return tn.toArray}});var nn=n(8072);Object.defineProperty(t,"window",{enumerable:!0,get:function(){return nn.window}});var rn=n(2893);Object.defineProperty(t,"windowCount",{enumerable:!0,get:function(){return rn.windowCount}});var on=n(37);Object.defineProperty(t,"windowTime",{enumerable:!0,get:function(){return on.windowTime}});var sn=n(8996);Object.defineProperty(t,"windowToggle",{enumerable:!0,get:function(){return sn.windowToggle}});var an=n(5156);Object.defineProperty(t,"windowWhen",{enumerable:!0,get:function(){return an.windowWhen}});var cn=n(6975);Object.defineProperty(t,"withLatestFrom",{enumerable:!0,get:function(){return cn.withLatestFrom}});var un=n(5362);Object.defineProperty(t,"zipAll",{enumerable:!0,get:function(){return un.zipAll}});var ln=n(6977);Object.defineProperty(t,"zipWith",{enumerable:!0,get:function(){return ln.zipWith}})},5130(e,t,n){"use strict";var r,i=this&&this.__extends||(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(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)});Object.defineProperty(t,"__esModule",{value:!0}),t.AsyncSubject=void 0;var o=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._value=null,t._hasValue=!1,t._isComplete=!1,t}return i(t,e),t.prototype._checkFinalizedStatuses=function(e){var t=this,n=t.hasError,r=t._hasValue,i=t._value,o=t.thrownError,s=t.isStopped,a=t._isComplete;n?e.error(o):(s||a)&&(r&&e.next(i),e.complete())},t.prototype.next=function(e){this.isStopped||(this._value=e,this._hasValue=!0)},t.prototype.complete=function(){var t=this,n=t._hasValue,r=t._value;t._isComplete||(this._isComplete=!0,n&&e.prototype.next.call(this,r),e.prototype.complete.call(this))},t}(n(6808).Subject);t.AsyncSubject=o},7314(e,t,n){"use strict";var r,i=this&&this.__extends||(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(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)});Object.defineProperty(t,"__esModule",{value:!0}),t.BehaviorSubject=void 0;var o=function(e){function t(t){var n=e.call(this)||this;return n._value=t,n}return i(t,e),Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),t.prototype._subscribe=function(t){var n=e.prototype._subscribe.call(this,t);return!n.closed&&t.next(this._value),n},t.prototype.getValue=function(){var e=this,t=e.hasError,n=e.thrownError,r=e._value;if(t)throw n;return this._throwIfClosed(),r},t.prototype.next=function(t){e.prototype.next.call(this,this._value=t)},t}(n(6808).Subject);t.BehaviorSubject=o},1245(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.observeNotification=t.Notification=t.NotificationKind=void 0;var r,i=n(4885),o=n(1587),s=n(6680),a=n(281);(r=t.NotificationKind||(t.NotificationKind={})).NEXT="N",r.ERROR="E",r.COMPLETE="C";var c=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){return u(this,e)},e.prototype.do=function(e,t,n){var r=this,i=r.kind,o=r.value,s=r.error;return"N"===i?null==e?void 0:e(o):"E"===i?null==t?void 0:t(s):null==n?void 0:n()},e.prototype.accept=function(e,t,n){var r;return a.isFunction(null===(r=e)||void 0===r?void 0:r.next)?this.observe(e):this.do(e,t,n)},e.prototype.toObservable=function(){var e=this,t=e.kind,n=e.value,r=e.error,a="N"===t?o.of(n):"E"===t?s.throwError(function(){return r}):"C"===t?i.EMPTY:0;if(!a)throw new TypeError("Unexpected notification kind "+t);return a},e.createNext=function(t){return new e("N",t)},e.createError=function(t){return new e("E",void 0,t)},e.createComplete=function(){return e.completeNotification},e.completeNotification=new e("C"),e}();function u(e,t){var n,r,i,o=e,s=o.kind,a=o.value,c=o.error;if("string"!=typeof s)throw new TypeError('Invalid notification, missing "kind"');"N"===s?null===(n=t.next)||void 0===n||n.call(t,a):"E"===s?null===(r=t.error)||void 0===r||r.call(t,c):null===(i=t.complete)||void 0===i||i.call(t)}t.Notification=c,t.observeNotification=u},2767(e,t){"use strict";function n(e,t,n){return{kind:e,value:t,error:n}}Object.defineProperty(t,"__esModule",{value:!0}),t.createNotification=t.nextNotification=t.errorNotification=t.COMPLETE_NOTIFICATION=void 0,t.COMPLETE_NOTIFICATION=n("C",void 0,void 0),t.errorNotification=function(e){return n("E",void 0,e)},t.nextNotification=function(e){return n("N",e,void 0)},t.createNotification=n},8051(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Observable=void 0;var r=n(2708),i=n(9879),o=n(2884),s=n(1898),a=n(3728),c=n(281),u=n(2688),l=function(){function e(e){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 o,s=this,a=(o=e)&&o instanceof r.Subscriber||function(e){return e&&c.isFunction(e.next)&&c.isFunction(e.error)&&c.isFunction(e.complete)}(o)&&i.isSubscription(o)?e:new r.SafeSubscriber(e,t,n);return u.errorContext(function(){var e=s,t=e.operator,n=e.source;a.add(t?t.call(a,n):n?s._subscribe(a):s._trySubscribe(a))}),a},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var n=this;return new(t=h(t))(function(t,i){var o=new r.SafeSubscriber({next:function(t){try{e(t)}catch(e){i(e),o.unsubscribe()}},error:i,complete:t});n.subscribe(o)})},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[o.observable]=function(){return this},e.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return s.pipeFromArray(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){var t;return null!==(t=null!=e?e:a.config.Promise)&&void 0!==t?t:Promise}t.Observable=l},381(e,t,n){"use strict";var r,i=this&&this.__extends||(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(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)});Object.defineProperty(t,"__esModule",{value:!0}),t.ReplaySubject=void 0;var o=n(6808),s=n(3275),a=function(e){function t(t,n,r){void 0===t&&(t=1/0),void 0===n&&(n=1/0),void 0===r&&(r=s.dateTimestampProvider);var i=e.call(this)||this;return i._bufferSize=t,i._windowTime=n,i._timestampProvider=r,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=n===1/0,i._bufferSize=Math.max(1,t),i._windowTime=Math.max(1,n),i}return i(t,e),t.prototype.next=function(t){var n=this,r=n.isStopped,i=n._buffer,o=n._infiniteTimeWindow,s=n._timestampProvider,a=n._windowTime;r||(i.push(t),!o&&i.push(s.now()+a)),this._trimBuffer(),e.prototype.next.call(this,t)},t.prototype._subscribe=function(e){this._throwIfClosed(),this._trimBuffer();for(var t=this._innerSubscribe(e),n=this._infiniteTimeWindow,r=this._buffer.slice(),i=0;i<r.length&&!e.closed;i+=n?1:2)e.next(r[i]);return this._checkFinalizedStatuses(e),t},t.prototype._trimBuffer=function(){var e=this,t=e._bufferSize,n=e._timestampProvider,r=e._buffer,i=e._infiniteTimeWindow,o=(i?1:2)*t;if(t<1/0&&o<r.length&&r.splice(0,r.length-o),!i){for(var s=n.now(),a=0,c=1;c<r.length&&r[c]<=s;c+=2)a=c;a&&r.splice(0,a+1)}},t}(o.Subject);t.ReplaySubject=a},5881(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Scheduler=void 0;var r=n(3275),i=function(){function e(t,n){void 0===n&&(n=e.now),this.schedulerActionCtor=t,this.now=n}return e.prototype.schedule=function(e,t,n){return void 0===t&&(t=0),new this.schedulerActionCtor(this,e).schedule(n,t)},e.now=r.dateTimestampProvider.now,e}();t.Scheduler=i},6808(e,t,n){"use strict";var r,i=this&&this.__extends||(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(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)}),o=this&&this.__values||function(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.")};Object.defineProperty(t,"__esModule",{value:!0}),t.AnonymousSubject=t.Subject=void 0;var s=n(8051),a=n(9879),c=n(839),u=n(4830),l=n(2688),h=function(e){function t(){var t=e.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return i(t,e),t.prototype.lift=function(e){var t=new d(this,this);return t.operator=e,t},t.prototype._throwIfClosed=function(){if(this.closed)throw new c.ObjectUnsubscribedError},t.prototype.next=function(e){var t=this;l.errorContext(function(){var n,r;if(t._throwIfClosed(),!t.isStopped){t.currentObservers||(t.currentObservers=Array.from(t.observers));try{for(var i=o(t.currentObservers),s=i.next();!s.done;s=i.next())s.value.next(e)}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}}})},t.prototype.error=function(e){var t=this;l.errorContext(function(){if(t._throwIfClosed(),!t.isStopped){t.hasError=t.isStopped=!0,t.thrownError=e;for(var n=t.observers;n.length;)n.shift().error(e)}})},t.prototype.complete=function(){var e=this;l.errorContext(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var t=e.observers;t.length;)t.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return(null===(e=this.observers)||void 0===e?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this,n=this,r=n.hasError,i=n.isStopped,o=n.observers;return r||i?a.EMPTY_SUBSCRIPTION:(this.currentObservers=null,o.push(e),new a.Subscription(function(){t.currentObservers=null,u.arrRemove(o,e)}))},t.prototype._checkFinalizedStatuses=function(e){var t=this,n=t.hasError,r=t.thrownError,i=t.isStopped;n?e.error(r):i&&e.complete()},t.prototype.asObservable=function(){var e=new s.Observable;return e.source=this,e},t.create=function(e,t){return new d(e,t)},t}(s.Observable);t.Subject=h;var d=function(e){function t(t,n){var r=e.call(this)||this;return r.destination=t,r.source=n,r}return i(t,e),t.prototype.next=function(e){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===n||n.call(t,e)},t.prototype.error=function(e){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===n||n.call(t,e)},t.prototype.complete=function(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)},t.prototype._subscribe=function(e){var t,n;return null!==(n=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==n?n:a.EMPTY_SUBSCRIPTION},t}(h);t.AnonymousSubject=d},2708(e,t,n){"use strict";var r,i=this&&this.__extends||(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(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)});Object.defineProperty(t,"__esModule",{value:!0}),t.EMPTY_OBSERVER=t.SafeSubscriber=t.Subscriber=void 0;var o=n(281),s=n(9879),a=n(3728),c=n(2980),u=n(5717),l=n(2767),h=n(4808),d=n(2688),f=function(e){function n(n){var r=e.call(this)||this;return r.isStopped=!1,n?(r.destination=n,s.isSubscription(n)&&n.add(r)):r.destination=t.EMPTY_OBSERVER,r}return i(n,e),n.create=function(e,t,n){return new y(e,t,n)},n.prototype.next=function(e){this.isStopped?b(l.nextNotification(e),this):this._next(e)},n.prototype.error=function(e){this.isStopped?b(l.errorNotification(e),this):(this.isStopped=!0,this._error(e))},n.prototype.complete=function(){this.isStopped?b(l.COMPLETE_NOTIFICATION,this):(this.isStopped=!0,this._complete())},n.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},n.prototype._next=function(e){this.destination.next(e)},n.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},n.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},n}(s.Subscription);t.Subscriber=f;var p=Function.prototype.bind;function m(e,t){return p.call(e,t)}var g=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(e){v(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){v(e)}else v(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){v(e)}},e}(),y=function(e){function t(t,n,r){var i,s,c=e.call(this)||this;return o.isFunction(t)||!t?i={next:null!=t?t:void 0,error:null!=n?n:void 0,complete:null!=r?r:void 0}:c&&a.config.useDeprecatedNextContext?((s=Object.create(t)).unsubscribe=function(){return c.unsubscribe()},i={next:t.next&&m(t.next,s),error:t.error&&m(t.error,s),complete:t.complete&&m(t.complete,s)}):i=t,c.destination=new g(i),c}return i(t,e),t}(f);function v(e){a.config.useDeprecatedSynchronousErrorHandling?d.captureError(e):c.reportUnhandledError(e)}function b(e,t){var n=a.config.onStoppedNotification;n&&h.timeoutProvider.setTimeout(function(){return n(e,t)})}t.SafeSubscriber=y,t.EMPTY_OBSERVER={closed:!0,next:u.noop,error:function(e){throw e},complete:u.noop}},9879(e,t,n){"use strict";var r=this&&this.__values||function(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.")},i=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},o=this&&this.__spreadArray||function(e,t){for(var n=0,r=t.length,i=e.length;n<r;n++,i++)e[i]=t[n];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.isSubscription=t.EMPTY_SUBSCRIPTION=t.Subscription=void 0;var s=n(281),a=n(9517),c=n(4830),u=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}var t;return e.prototype.unsubscribe=function(){var e,t,n,c,u;if(!this.closed){this.closed=!0;var h=this._parentage;if(h)if(this._parentage=null,Array.isArray(h))try{for(var d=r(h),f=d.next();!f.done;f=d.next())f.value.remove(this)}catch(t){e={error:t}}finally{try{f&&!f.done&&(t=d.return)&&t.call(d)}finally{if(e)throw e.error}}else h.remove(this);var p=this.initialTeardown;if(s.isFunction(p))try{p()}catch(e){u=e instanceof a.UnsubscriptionError?e.errors:[e]}var m=this._finalizers;if(m){this._finalizers=null;try{for(var g=r(m),y=g.next();!y.done;y=g.next()){var v=y.value;try{l(v)}catch(e){u=null!=u?u:[],e instanceof a.UnsubscriptionError?u=o(o([],i(u)),i(e.errors)):u.push(e)}}}catch(e){n={error:e}}finally{try{y&&!y.done&&(c=g.return)&&c.call(g)}finally{if(n)throw n.error}}}if(u)throw new a.UnsubscriptionError(u)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)l(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(n=this._finalizers)&&void 0!==n?n:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&c.arrRemove(t,e)},e.prototype.remove=function(t){var n=this._finalizers;n&&c.arrRemove(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}();function l(e){s.isFunction(e)?e():e.unsubscribe()}t.Subscription=u,t.EMPTY_SUBSCRIPTION=u.EMPTY,t.isSubscription=function(e){return e instanceof u||e&&"closed"in e&&s.isFunction(e.remove)&&s.isFunction(e.add)&&s.isFunction(e.unsubscribe)}},3728(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.config=void 0,t.config={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1}},841(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.firstValueFrom=void 0;var r=n(9328),i=n(2708);t.firstValueFrom=function(e,t){var n="object"==typeof t;return new Promise(function(o,s){var a=new i.SafeSubscriber({next:function(e){o(e),a.unsubscribe()},error:s,complete:function(){n?o(t.defaultValue):s(new r.EmptyError)}});e.subscribe(a)})}},5761(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.lastValueFrom=void 0;var r=n(9328);t.lastValueFrom=function(e,t){var n="object"==typeof t;return new Promise(function(i,o){var s,a=!1;e.subscribe({next:function(e){s=e,a=!0},error:o,complete:function(){a?i(s):n?i(t.defaultValue):o(new r.EmptyError)}})})}},4359(e,t,n){"use strict";var r,i=this&&this.__extends||(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(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)});Object.defineProperty(t,"__esModule",{value:!0}),t.ConnectableObservable=void 0;var o=n(8051),s=n(9879),a=n(9224),c=n(7214),u=n(5212),l=function(e){function t(t,n){var r=e.call(this)||this;return r.source=t,r.subjectFactory=n,r._subject=null,r._refCount=0,r._connection=null,u.hasLift(t)&&(r.lift=t.lift),r}return i(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._teardown=function(){this._refCount=0;var e=this._connection;this._subject=this._connection=null,null==e||e.unsubscribe()},t.prototype.connect=function(){var e=this,t=this._connection;if(!t){t=this._connection=new s.Subscription;var n=this.getSubject();t.add(this.source.subscribe(c.createOperatorSubscriber(n,void 0,function(){e._teardown(),n.complete()},function(t){e._teardown(),n.error(t)},function(){return e._teardown()}))),t.closed&&(this._connection=null,t=s.Subscription.EMPTY)}return t},t.prototype.refCount=function(){return a.refCount()(this)},t}(o.Observable);t.ConnectableObservable=l},9750(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bindCallback=void 0;var r=n(7474);t.bindCallback=function(e,t,n){return r.bindCallbackInternals(!1,e,t,n)}},7474(e,t,n){"use strict";var r=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var n=0,r=t.length,i=e.length;n<r;n++,i++)e[i]=t[n];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.bindCallbackInternals=void 0;var o=n(8596),s=n(8051),a=n(5455),c=n(3916),u=n(2071),l=n(5130);t.bindCallbackInternals=function e(t,n,h,d){if(h){if(!o.isScheduler(h))return function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];return e(t,n,d).apply(this,r).pipe(c.mapOneOrManyArgs(h))};d=h}return d?function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];return e(t,n).apply(this,r).pipe(a.subscribeOn(d),u.observeOn(d))}:function(){for(var e=this,o=[],a=0;a<arguments.length;a++)o[a]=arguments[a];var c=new l.AsyncSubject,u=!0;return new s.Observable(function(s){var a=c.subscribe(s);if(u){u=!1;var l=!1,h=!1;n.apply(e,i(i([],r(o)),[function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(t){var r=e.shift();if(null!=r)return void c.error(r)}c.next(1<e.length?e:e[0]),h=!0,l&&c.complete()}])),h&&c.complete(),l=!0}return a})}}},1946(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bindNodeCallback=void 0;var r=n(7474);t.bindNodeCallback=function(e,t,n){return r.bindCallbackInternals(!0,e,t,n)}},8246(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.combineLatestInit=t.combineLatest=void 0;var r=n(8051),i=n(439),o=n(7058),s=n(7699),a=n(3916),c=n(6404),u=n(5810),l=n(7214),h=n(8619);function d(e,t,n){return void 0===n&&(n=s.identity),function(r){f(t,function(){for(var i=e.length,s=new Array(i),a=i,c=i,u=function(i){f(t,function(){var u=o.from(e[i],t),h=!1;u.subscribe(l.createOperatorSubscriber(r,function(e){s[i]=e,h||(h=!0,c--),c||r.next(n(s.slice()))},function(){--a||r.complete()}))},r)},h=0;h<i;h++)u(h)},r)}}function f(e,t,n){e?h.executeSchedule(n,e,t):t()}t.combineLatest=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=c.popScheduler(e),l=c.popResultSelector(e),h=i.argsArgArrayOrObject(e),f=h.args,p=h.keys;if(0===f.length)return o.from([],n);var m=new r.Observable(d(f,n,p?function(e){return u.createObject(p,e)}:s.identity));return l?m.pipe(a.mapOneOrManyArgs(l)):m},t.combineLatestInit=d},9546(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.concat=void 0;var r=n(201),i=n(6404),o=n(7058);t.concat=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return r.concatAll()(o.from(e,i.popScheduler(e)))}},8590(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.connectable=void 0;var r=n(6808),i=n(8051),o=n(5884),s={connector:function(){return new r.Subject},resetOnDisconnect:!0};t.connectable=function(e,t){void 0===t&&(t=s);var n=null,r=t.connector,a=t.resetOnDisconnect,c=void 0===a||a,u=r(),l=new i.Observable(function(e){return u.subscribe(e)});return l.connect=function(){return n&&!n.closed||(n=o.defer(function(){return e}).subscribe(u),c&&n.add(function(){return u=r()})),n},l}},5884(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defer=void 0;var r=n(8051),i=n(9724);t.defer=function(e){return new r.Observable(function(t){i.innerFrom(e()).subscribe(t)})}},1875(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.animationFrames=void 0;var r=n(8051),i=n(2931),o=n(5726);function s(e){return new r.Observable(function(t){var n=e||i.performanceTimestampProvider,r=n.now(),s=0,a=function(){t.closed||(s=o.animationFrameProvider.requestAnimationFrame(function(i){s=0;var o=n.now();t.next({timestamp:e?o:i,elapsed:o-r}),a()}))};return a(),function(){s&&o.animationFrameProvider.cancelAnimationFrame(s)}})}t.animationFrames=function(e){return e?s(e):a};var a=s()},4885(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.empty=t.EMPTY=void 0;var r=n(8051);t.EMPTY=new r.Observable(function(e){return e.complete()}),t.empty=function(e){return e?function(e){return new r.Observable(function(t){return e.schedule(function(){return t.complete()})})}(e):t.EMPTY}},5266(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.forkJoin=void 0;var r=n(8051),i=n(439),o=n(9724),s=n(6404),a=n(7214),c=n(3916),u=n(5810);t.forkJoin=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=s.popResultSelector(e),l=i.argsArgArrayOrObject(e),h=l.args,d=l.keys,f=new r.Observable(function(e){var t=h.length;if(t)for(var n=new Array(t),r=t,i=t,s=function(t){var s=!1;o.innerFrom(h[t]).subscribe(a.createOperatorSubscriber(e,function(e){s||(s=!0,i--),n[t]=e},function(){return r--},void 0,function(){r&&s||(i||e.next(d?u.createObject(d,n):n),e.complete())}))},c=0;c<t;c++)s(c);else e.complete()});return n?f.pipe(c.mapOneOrManyArgs(n)):f}},7058(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.from=void 0;var r=n(131),i=n(9724);t.from=function(e,t){return t?r.scheduled(e,t):i.innerFrom(e)}},8616(e,t,n){"use strict";var r=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s};Object.defineProperty(t,"__esModule",{value:!0}),t.fromEvent=void 0;var i=n(9724),o=n(8051),s=n(7478),a=n(4975),c=n(281),u=n(3916),l=["addListener","removeListener"],h=["addEventListener","removeEventListener"],d=["on","off"];function f(e,t){return function(n){return function(r){return e[n](t,r)}}}t.fromEvent=function e(t,n,p,m){if(c.isFunction(p)&&(m=p,p=void 0),m)return e(t,n,p).pipe(u.mapOneOrManyArgs(m));var g=r(function(e){return c.isFunction(e.addEventListener)&&c.isFunction(e.removeEventListener)}(t)?h.map(function(e){return function(r){return t[e](n,r,p)}}):function(e){return c.isFunction(e.addListener)&&c.isFunction(e.removeListener)}(t)?l.map(f(t,n)):function(e){return c.isFunction(e.on)&&c.isFunction(e.off)}(t)?d.map(f(t,n)):[],2),y=g[0],v=g[1];if(!y&&a.isArrayLike(t))return s.mergeMap(function(t){return e(t,n,p)})(i.innerFrom(t));if(!y)throw new TypeError("Invalid event target");return new o.Observable(function(e){var t=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return e.next(1<t.length?t:t[0])};return y(t),function(){return v(t)}})}},6920(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fromEventPattern=void 0;var r=n(8051),i=n(281),o=n(3916);t.fromEventPattern=function e(t,n,s){return s?e(t,n).pipe(o.mapOneOrManyArgs(s)):new r.Observable(function(e){var r=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return e.next(1===t.length?t[0]:t)},o=t(r);return i.isFunction(n)?function(){return n(r,o)}:void 0})}},1071(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fromSubscribable=void 0;var r=n(8051);t.fromSubscribable=function(e){return new r.Observable(function(t){return e.subscribe(t)})}},7281(e,t,n){"use strict";var r=this&&this.__generator||function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.generate=void 0;var i=n(7699),o=n(8596),s=n(5884),a=n(6805);t.generate=function(e,t,n,c,u){var l,h,d,f;function p(){var e;return r(this,function(r){switch(r.label){case 0:e=f,r.label=1;case 1:return t&&!t(e)?[3,4]:[4,d(e)];case 2:r.sent(),r.label=3;case 3:return e=n(e),[3,1];case 4:return[2]}})}return 1===arguments.length?(f=(l=e).initialState,t=l.condition,n=l.iterate,h=l.resultSelector,d=void 0===h?i.identity:h,u=l.scheduler):(f=e,!c||o.isScheduler(c)?(d=i.identity,u=c):d=c),s.defer(u?function(){return a.scheduleIterable(p(),u)}:p)}},9380(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.iif=void 0;var r=n(5884);t.iif=function(e,t,n){return r.defer(function(){return e()?t:n})}},9724(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},o=this&&this.__asyncValues||function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e="function"==typeof s?s(e):e[Symbol.iterator](),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)})}}},s=this&&this.__values||function(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.")};Object.defineProperty(t,"__esModule",{value:!0}),t.fromReadableStreamLike=t.fromAsyncIterable=t.fromIterable=t.fromPromise=t.fromArrayLike=t.fromInteropObservable=t.innerFrom=void 0;var a=n(4975),c=n(7552),u=n(8051),l=n(629),h=n(8263),d=n(6297),f=n(2187),p=n(5462),m=n(281),g=n(2980),y=n(2884);function v(e){return new u.Observable(function(t){var n=e[y.observable]();if(m.isFunction(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function b(e){return new u.Observable(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()})}function _(e){return new u.Observable(function(t){e.then(function(e){t.closed||(t.next(e),t.complete())},function(e){return t.error(e)}).then(null,g.reportUnhandledError)})}function w(e){return new u.Observable(function(t){var n,r;try{for(var i=s(e),o=i.next();!o.done;o=i.next()){var a=o.value;if(t.next(a),t.closed)return}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}t.complete()})}function I(e){return new u.Observable(function(t){(function(e,t){var n,s,a,c;return r(this,void 0,void 0,function(){var r,u;return i(this,function(i){switch(i.label){case 0:i.trys.push([0,5,6,11]),n=o(e),i.label=1;case 1:return[4,n.next()];case 2:if((s=i.sent()).done)return[3,4];if(r=s.value,t.next(r),t.closed)return[2];i.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return u=i.sent(),a={error:u},[3,11];case 6:return i.trys.push([6,,9,10]),s&&!s.done&&(c=n.return)?[4,c.call(n)]:[3,8];case 7:i.sent(),i.label=8;case 8:return[3,10];case 9:if(a)throw a.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})})(e,t).catch(function(e){return t.error(e)})})}function E(e){return I(p.readableStreamLikeToAsyncGenerator(e))}t.innerFrom=function(e){if(e instanceof u.Observable)return e;if(null!=e){if(l.isInteropObservable(e))return v(e);if(a.isArrayLike(e))return b(e);if(c.isPromise(e))return _(e);if(h.isAsyncIterable(e))return I(e);if(f.isIterable(e))return w(e);if(p.isReadableStreamLike(e))return E(e)}throw d.createInvalidObservableTypeError(e)},t.fromInteropObservable=v,t.fromArrayLike=b,t.fromPromise=_,t.fromIterable=w,t.fromAsyncIterable=I,t.fromReadableStreamLike=E},2275(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.interval=void 0;var r=n(2326),i=n(5825);t.interval=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=r.asyncScheduler),e<0&&(e=0),i.timer(e,e,t)}},5936(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.merge=void 0;var r=n(8087),i=n(9724),o=n(4885),s=n(6404),a=n(7058);t.merge=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=s.popScheduler(e),c=s.popNumber(e,1/0),u=e;return u.length?1===u.length?i.innerFrom(u[0]):r.mergeAll(c)(a.from(u,n)):o.EMPTY}},1934(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.never=t.NEVER=void 0;var r=n(8051),i=n(5717);t.NEVER=new r.Observable(i.noop),t.never=function(){return t.NEVER}},1587(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.of=void 0;var r=n(6404),i=n(7058);t.of=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=r.popScheduler(e);return i.from(e,n)}},1903(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.onErrorResumeNext=void 0;var r=n(8051),i=n(7652),o=n(7214),s=n(5717),a=n(9724);t.onErrorResumeNext=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=i.argsOrArgArray(e);return new r.Observable(function(e){var t=0,r=function(){if(t<n.length){var i=void 0;try{i=a.innerFrom(n[t++])}catch(e){return void r()}var c=new o.OperatorSubscriber(e,void 0,s.noop,s.noop);i.subscribe(c),c.add(r)}else e.complete()};r()})}},8269(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pairs=void 0;var r=n(7058);t.pairs=function(e,t){return r.from(Object.entries(e),t)}},7406(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.partition=void 0;var r=n(4120),i=n(5934),o=n(9724);t.partition=function(e,t,n){return[i.filter(t,n)(o.innerFrom(e)),i.filter(r.not(t,n))(o.innerFrom(e))]}},9795(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.raceInit=t.race=void 0;var r=n(8051),i=n(9724),o=n(7652),s=n(7214);function a(e){return function(t){for(var n=[],r=function(r){n.push(i.innerFrom(e[r]).subscribe(s.createOperatorSubscriber(t,function(e){if(n){for(var i=0;i<n.length;i++)i!==r&&n[i].unsubscribe();n=null}t.next(e)})))},o=0;n&&!t.closed&&o<e.length;o++)r(o)}}t.race=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return 1===(e=o.argsOrArgArray(e)).length?i.innerFrom(e[0]):new r.Observable(a(e))},t.raceInit=a},4385(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.range=void 0;var r=n(8051),i=n(4885);t.range=function(e,t,n){if(null==t&&(t=e,e=0),t<=0)return i.EMPTY;var o=t+e;return new r.Observable(n?function(t){var r=e;return n.schedule(function(){r<o?(t.next(r++),this.schedule()):t.complete()})}:function(t){for(var n=e;n<o&&!t.closed;)t.next(n++);t.complete()})}},6680(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.throwError=void 0;var r=n(8051),i=n(281);t.throwError=function(e,t){var n=i.isFunction(e)?e:function(){return e},o=function(e){return e.error(n())};return new r.Observable(t?function(e){return t.schedule(o,0,e)}:o)}},5825(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.timer=void 0;var r=n(8051),i=n(2326),o=n(8596),s=n(5345);t.timer=function(e,t,n){void 0===e&&(e=0),void 0===n&&(n=i.async);var a=-1;return null!=t&&(o.isScheduler(t)?n=t:a=t),new r.Observable(function(t){var r=s.isValidDate(e)?+e-n.now():e;r<0&&(r=0);var i=0;return n.schedule(function(){t.closed||(t.next(i++),0<=a?this.schedule(void 0,a):t.complete())},r)})}},5904(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.using=void 0;var r=n(8051),i=n(9724),o=n(4885);t.using=function(e,t){return new r.Observable(function(n){var r=e(),s=t(r);return(s?i.innerFrom(s):o.EMPTY).subscribe(n),function(){r&&r.unsubscribe()}})}},1415(e,t,n){"use strict";var r=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var n=0,r=t.length,i=e.length;n<r;n++,i++)e[i]=t[n];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.zip=void 0;var o=n(8051),s=n(9724),a=n(7652),c=n(4885),u=n(7214),l=n(6404);t.zip=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=l.popResultSelector(e),h=a.argsOrArgArray(e);return h.length?new o.Observable(function(e){var t=h.map(function(){return[]}),o=h.map(function(){return!1});e.add(function(){t=o=null});for(var a=function(a){s.innerFrom(h[a]).subscribe(u.createOperatorSubscriber(e,function(s){if(t[a].push(s),t.every(function(e){return e.length})){var c=t.map(function(e){return e.shift()});e.next(n?n.apply(void 0,i([],r(c))):c),t.some(function(e,t){return!e.length&&o[t]})&&e.complete()}},function(){o[a]=!0,!t[a].length&&e.complete()}))},c=0;!e.closed&&c<h.length;c++)a(c);return function(){t=o=null}}):c.EMPTY}},7214(e,t,n){"use strict";var r,i=this&&this.__extends||(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(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)});Object.defineProperty(t,"__esModule",{value:!0}),t.OperatorSubscriber=t.createOperatorSubscriber=void 0;var o=n(2708);t.createOperatorSubscriber=function(e,t,n,r,i){return new s(e,t,n,r,i)};var s=function(e){function t(t,n,r,i,o,s){var a=e.call(this,t)||this;return a.onFinalize=o,a.shouldUnsubscribe=s,a._next=n?function(e){try{n(e)}catch(e){t.error(e)}}:e.prototype._next,a._error=i?function(e){try{i(e)}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._error,a._complete=r?function(){try{r()}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._complete,a}return i(t,e),t.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;e.prototype.unsubscribe.call(this),!n&&(null===(t=this.onFinalize)||void 0===t||t.call(this))}},t}(o.Subscriber);t.OperatorSubscriber=s},8877(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.audit=void 0;var r=n(5212),i=n(9724),o=n(7214);t.audit=function(e){return r.operate(function(t,n){var r=!1,s=null,a=null,c=!1,u=function(){if(null==a||a.unsubscribe(),a=null,r){r=!1;var e=s;s=null,n.next(e)}c&&n.complete()},l=function(){a=null,c&&n.complete()};t.subscribe(o.createOperatorSubscriber(n,function(t){r=!0,s=t,a||i.innerFrom(e(t)).subscribe(a=o.createOperatorSubscriber(n,u,l))},function(){c=!0,(!r||!a||a.closed)&&n.complete()}))})}},1608(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.auditTime=void 0;var r=n(2326),i=n(8877),o=n(5825);t.auditTime=function(e,t){return void 0===t&&(t=r.asyncScheduler),i.audit(function(){return o.timer(e,t)})}},706(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.buffer=void 0;var r=n(5212),i=n(5717),o=n(7214),s=n(9724);t.buffer=function(e){return r.operate(function(t,n){var r=[];return t.subscribe(o.createOperatorSubscriber(n,function(e){return r.push(e)},function(){n.next(r),n.complete()})),s.innerFrom(e).subscribe(o.createOperatorSubscriber(n,function(){var e=r;r=[],n.next(e)},i.noop)),function(){r=null}})}},9287(e,t,n){"use strict";var r=this&&this.__values||function(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.")};Object.defineProperty(t,"__esModule",{value:!0}),t.bufferCount=void 0;var i=n(5212),o=n(7214),s=n(4830);t.bufferCount=function(e,t){return void 0===t&&(t=null),t=null!=t?t:e,i.operate(function(n,i){var a=[],c=0;n.subscribe(o.createOperatorSubscriber(i,function(n){var o,u,l,h,d=null;c++%t===0&&a.push([]);try{for(var f=r(a),p=f.next();!p.done;p=f.next())(y=p.value).push(n),e<=y.length&&(d=null!=d?d:[]).push(y)}catch(e){o={error:e}}finally{try{p&&!p.done&&(u=f.return)&&u.call(f)}finally{if(o)throw o.error}}if(d)try{for(var m=r(d),g=m.next();!g.done;g=m.next()){var y=g.value;s.arrRemove(a,y),i.next(y)}}catch(e){l={error:e}}finally{try{g&&!g.done&&(h=m.return)&&h.call(m)}finally{if(l)throw l.error}}},function(){var e,t;try{for(var n=r(a),o=n.next();!o.done;o=n.next()){var s=o.value;i.next(s)}}catch(t){e={error:t}}finally{try{o&&!o.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}i.complete()},void 0,function(){a=null}))})}},1719(e,t,n){"use strict";var r=this&&this.__values||function(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.")};Object.defineProperty(t,"__esModule",{value:!0}),t.bufferTime=void 0;var i=n(9879),o=n(5212),s=n(7214),a=n(4830),c=n(2326),u=n(6404),l=n(8619);t.bufferTime=function(e){for(var t,n,h=[],d=1;d<arguments.length;d++)h[d-1]=arguments[d];var f=null!==(t=u.popScheduler(h))&&void 0!==t?t:c.asyncScheduler,p=null!==(n=h[0])&&void 0!==n?n:null,m=h[1]||1/0;return o.operate(function(t,n){var o=[],c=!1,u=function(e){var t=e.buffer;e.subs.unsubscribe(),a.arrRemove(o,e),n.next(t),c&&h()},h=function(){if(o){var t=new i.Subscription;n.add(t);var r={buffer:[],subs:t};o.push(r),l.executeSchedule(t,f,function(){return u(r)},e)}};null!==p&&p>=0?l.executeSchedule(n,f,h,p,!0):c=!0,h();var d=s.createOperatorSubscriber(n,function(e){var t,n,i=o.slice();try{for(var s=r(i),a=s.next();!a.done;a=s.next()){var c=a.value,l=c.buffer;l.push(e),m<=l.length&&u(c)}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}},function(){for(;null==o?void 0:o.length;)n.next(o.shift().buffer);null==d||d.unsubscribe(),n.complete(),n.unsubscribe()},void 0,function(){return o=null});t.subscribe(d)})}},1778(e,t,n){"use strict";var r=this&&this.__values||function(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.")};Object.defineProperty(t,"__esModule",{value:!0}),t.bufferToggle=void 0;var i=n(9879),o=n(5212),s=n(9724),a=n(7214),c=n(5717),u=n(4830);t.bufferToggle=function(e,t){return o.operate(function(n,o){var l=[];s.innerFrom(e).subscribe(a.createOperatorSubscriber(o,function(e){var n=[];l.push(n);var r=new i.Subscription;r.add(s.innerFrom(t(e)).subscribe(a.createOperatorSubscriber(o,function(){u.arrRemove(l,n),o.next(n),r.unsubscribe()},c.noop)))},c.noop)),n.subscribe(a.createOperatorSubscriber(o,function(e){var t,n;try{for(var i=r(l),o=i.next();!o.done;o=i.next())o.value.push(e)}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}},function(){for(;l.length>0;)o.next(l.shift());o.complete()}))})}},6606(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bufferWhen=void 0;var r=n(5212),i=n(5717),o=n(7214),s=n(9724);t.bufferWhen=function(e){return r.operate(function(t,n){var r=null,a=null,c=function(){null==a||a.unsubscribe();var t=r;r=[],t&&n.next(t),s.innerFrom(e()).subscribe(a=o.createOperatorSubscriber(n,c,i.noop))};c(),t.subscribe(o.createOperatorSubscriber(n,function(e){return null==r?void 0:r.push(e)},function(){r&&n.next(r),n.complete()},void 0,function(){return r=a=null}))})}},2719(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.catchError=void 0;var r=n(9724),i=n(7214),o=n(5212);t.catchError=function e(t){return o.operate(function(n,o){var s,a=null,c=!1;a=n.subscribe(i.createOperatorSubscriber(o,void 0,void 0,function(i){s=r.innerFrom(t(i,e(t)(n))),a?(a.unsubscribe(),a=null,s.subscribe(o)):c=!0})),c&&(a.unsubscribe(),a=null,s.subscribe(o))})}},9244(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.combineAll=void 0;var r=n(7933);t.combineAll=r.combineLatestAll},4948(e,t,n){"use strict";var r=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var n=0,r=t.length,i=e.length;n<r;n++,i++)e[i]=t[n];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.combineLatest=void 0;var o=n(8246),s=n(5212),a=n(7652),c=n(3916),u=n(1898),l=n(6404);t.combineLatest=function e(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var h=l.popResultSelector(t);return h?u.pipe(e.apply(void 0,i([],r(t))),c.mapOneOrManyArgs(h)):s.operate(function(e,n){o.combineLatestInit(i([e],r(a.argsOrArgArray(t))))(n)})}},7933(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.combineLatestAll=void 0;var r=n(8246),i=n(719);t.combineLatestAll=function(e){return i.joinAllInternals(r.combineLatest,e)}},2044(e,t,n){"use strict";var r=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var n=0,r=t.length,i=e.length;n<r;n++,i++)e[i]=t[n];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.combineLatestWith=void 0;var o=n(4948);t.combineLatestWith=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return o.combineLatest.apply(void 0,i([],r(e)))}},6328(e,t,n){"use strict";var r=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var n=0,r=t.length,i=e.length;n<r;n++,i++)e[i]=t[n];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.concat=void 0;var o=n(5212),s=n(201),a=n(6404),c=n(7058);t.concat=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=a.popScheduler(e);return o.operate(function(t,o){s.concatAll()(c.from(i([t],r(e)),n)).subscribe(o)})}},201(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.concatAll=void 0;var r=n(8087);t.concatAll=function(){return r.mergeAll(1)}},9512(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.concatMap=void 0;var r=n(7478),i=n(281);t.concatMap=function(e,t){return i.isFunction(t)?r.mergeMap(e,t,1):r.mergeMap(e,1)}},9913(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.concatMapTo=void 0;var r=n(9512),i=n(281);t.concatMapTo=function(e,t){return i.isFunction(t)?r.concatMap(function(){return e},t):r.concatMap(function(){return e})}},8032(e,t,n){"use strict";var r=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var n=0,r=t.length,i=e.length;n<r;n++,i++)e[i]=t[n];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.concatWith=void 0;var o=n(6328);t.concatWith=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return o.concat.apply(void 0,i([],r(e)))}},7812(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.connect=void 0;var r=n(6808),i=n(9724),o=n(5212),s=n(1071),a={connector:function(){return new r.Subject}};t.connect=function(e,t){void 0===t&&(t=a);var n=t.connector;return o.operate(function(t,r){var o=n();i.innerFrom(e(s.fromSubscribable(o))).subscribe(r),r.add(t.subscribe(o))})}},8589(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.count=void 0;var r=n(2070);t.count=function(e){return r.reduce(function(t,n,r){return!e||e(n,r)?t+1:t},0)}},3143(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.debounce=void 0;var r=n(5212),i=n(5717),o=n(7214),s=n(9724);t.debounce=function(e){return r.operate(function(t,n){var r=!1,a=null,c=null,u=function(){if(null==c||c.unsubscribe(),c=null,r){r=!1;var e=a;a=null,n.next(e)}};t.subscribe(o.createOperatorSubscriber(n,function(t){null==c||c.unsubscribe(),r=!0,a=t,c=o.createOperatorSubscriber(n,u,i.noop),s.innerFrom(e(t)).subscribe(c)},function(){u(),n.complete()},void 0,function(){a=c=null}))})}},1762(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.debounceTime=void 0;var r=n(2326),i=n(5212),o=n(7214);t.debounceTime=function(e,t){return void 0===t&&(t=r.asyncScheduler),i.operate(function(n,r){var i=null,s=null,a=null,c=function(){if(i){i.unsubscribe(),i=null;var e=s;s=null,r.next(e)}};function u(){var n=a+e,o=t.now();if(o<n)return i=this.schedule(void 0,n-o),void r.add(i);c()}n.subscribe(o.createOperatorSubscriber(r,function(n){s=n,a=t.now(),i||(i=t.schedule(u,e),r.add(i))},function(){c(),r.complete()},void 0,function(){s=i=null}))})}},8799(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultIfEmpty=void 0;var r=n(5212),i=n(7214);t.defaultIfEmpty=function(e){return r.operate(function(t,n){var r=!1;t.subscribe(i.createOperatorSubscriber(n,function(e){r=!0,n.next(e)},function(){r||n.next(e),n.complete()}))})}},5797(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.delay=void 0;var r=n(2326),i=n(2885),o=n(5825);t.delay=function(e,t){void 0===t&&(t=r.asyncScheduler);var n=o.timer(e,t);return i.delayWhen(function(){return n})}},2885(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.delayWhen=void 0;var r=n(9546),i=n(4383),o=n(2959),s=n(3337),a=n(7478),c=n(9724);t.delayWhen=function e(t,n){return n?function(s){return r.concat(n.pipe(i.take(1),o.ignoreElements()),s.pipe(e(t)))}:a.mergeMap(function(e,n){return c.innerFrom(t(e,n)).pipe(i.take(1),s.mapTo(e))})}},9818(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dematerialize=void 0;var r=n(1245),i=n(5212),o=n(7214);t.dematerialize=function(){return i.operate(function(e,t){e.subscribe(o.createOperatorSubscriber(t,function(e){return r.observeNotification(e,t)}))})}},7876(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.distinct=void 0;var r=n(5212),i=n(7214),o=n(5717),s=n(9724);t.distinct=function(e,t){return r.operate(function(n,r){var a=new Set;n.subscribe(i.createOperatorSubscriber(r,function(t){var n=e?e(t):t;a.has(n)||(a.add(n),r.next(t))})),t&&s.innerFrom(t).subscribe(i.createOperatorSubscriber(r,function(){return a.clear()},o.noop))})}},9663(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.distinctUntilChanged=void 0;var r=n(7699),i=n(5212),o=n(7214);function s(e,t){return e===t}t.distinctUntilChanged=function(e,t){return void 0===t&&(t=r.identity),e=null!=e?e:s,i.operate(function(n,r){var i,s=!0;n.subscribe(o.createOperatorSubscriber(r,function(n){var o=t(n);!s&&e(i,o)||(s=!1,i=o,r.next(n))}))})}},6035(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.distinctUntilKeyChanged=void 0;var r=n(9663);t.distinctUntilKeyChanged=function(e,t){return r.distinctUntilChanged(function(n,r){return t?t(n[e],r[e]):n[e]===r[e]})}},1279(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.elementAt=void 0;var r=n(7024),i=n(5934),o=n(632),s=n(8799),a=n(4383);t.elementAt=function(e,t){if(e<0)throw new r.ArgumentOutOfRangeError;var n=arguments.length>=2;return function(c){return c.pipe(i.filter(function(t,n){return n===e}),a.take(1),n?s.defaultIfEmpty(t):o.throwIfEmpty(function(){return new r.ArgumentOutOfRangeError}))}}},6791(e,t,n){"use strict";var r=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var n=0,r=t.length,i=e.length;n<r;n++,i++)e[i]=t[n];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.endWith=void 0;var o=n(9546),s=n(1587);t.endWith=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t){return o.concat(t,s.of.apply(void 0,i([],r(e))))}}},1361(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.every=void 0;var r=n(5212),i=n(7214);t.every=function(e,t){return r.operate(function(n,r){var o=0;n.subscribe(i.createOperatorSubscriber(r,function(i){e.call(t,i,o++,n)||(r.next(!1),r.complete())},function(){r.next(!0),r.complete()}))})}},1464(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.exhaust=void 0;var r=n(7977);t.exhaust=r.exhaustAll},7977(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.exhaustAll=void 0;var r=n(6632),i=n(7699);t.exhaustAll=function(){return r.exhaustMap(i.identity)}},6632(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.exhaustMap=void 0;var r=n(6872),i=n(9724),o=n(5212),s=n(7214);t.exhaustMap=function e(t,n){return n?function(o){return o.pipe(e(function(e,o){return i.innerFrom(t(e,o)).pipe(r.map(function(t,r){return n(e,t,o,r)}))}))}:o.operate(function(e,n){var r=0,o=null,a=!1;e.subscribe(s.createOperatorSubscriber(n,function(e){o||(o=s.createOperatorSubscriber(n,void 0,function(){o=null,a&&n.complete()}),i.innerFrom(t(e,r++)).subscribe(o))},function(){a=!0,!o&&n.complete()}))})}},5544(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.expand=void 0;var r=n(5212),i=n(2574);t.expand=function(e,t,n){return void 0===t&&(t=1/0),t=(t||0)<1?1/0:t,r.operate(function(r,o){return i.mergeInternals(r,o,e,t,void 0,!0,n)})}},5934(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.filter=void 0;var r=n(5212),i=n(7214);t.filter=function(e,t){return r.operate(function(n,r){var o=0;n.subscribe(i.createOperatorSubscriber(r,function(n){return e.call(t,n,o++)&&r.next(n)}))})}},7802(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.finalize=void 0;var r=n(5212);t.finalize=function(e){return r.operate(function(t,n){try{t.subscribe(n)}finally{n.add(e)}})}},8183(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createFind=t.find=void 0;var r=n(5212),i=n(7214);function o(e,t,n){var r="index"===n;return function(n,o){var s=0;n.subscribe(i.createOperatorSubscriber(o,function(i){var a=s++;e.call(t,i,a,n)&&(o.next(r?a:i),o.complete())},function(){o.next(r?-1:void 0),o.complete()}))}}t.find=function(e,t){return r.operate(o(e,t,"value"))},t.createFind=o},9035(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.findIndex=void 0;var r=n(5212),i=n(8183);t.findIndex=function(e,t){return r.operate(i.createFind(e,t,"index"))}},9980(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.first=void 0;var r=n(9328),i=n(5934),o=n(4383),s=n(8799),a=n(632),c=n(7699);t.first=function(e,t){var n=arguments.length>=2;return function(u){return u.pipe(e?i.filter(function(t,n){return e(t,n,u)}):c.identity,o.take(1),n?s.defaultIfEmpty(t):a.throwIfEmpty(function(){return new r.EmptyError}))}}},4613(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.flatMap=void 0;var r=n(7478);t.flatMap=r.mergeMap},5128(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.groupBy=void 0;var r=n(8051),i=n(9724),o=n(6808),s=n(5212),a=n(7214);t.groupBy=function(e,t,n,c){return s.operate(function(s,u){var l;t&&"function"!=typeof t?(n=t.duration,l=t.element,c=t.connector):l=t;var h=new Map,d=function(e){h.forEach(e),e(u)},f=function(e){return d(function(t){return t.error(e)})},p=0,m=!1,g=new a.OperatorSubscriber(u,function(t){try{var s=e(t),d=h.get(s);if(!d){h.set(s,d=c?c():new o.Subject);var y=(b=s,_=d,(w=new r.Observable(function(e){p++;var t=_.subscribe(e);return function(){t.unsubscribe(),0===--p&&m&&g.unsubscribe()}})).key=b,w);if(u.next(y),n){var v=a.createOperatorSubscriber(d,function(){d.complete(),null==v||v.unsubscribe()},void 0,void 0,function(){return h.delete(s)});g.add(i.innerFrom(n(y)).subscribe(v))}}d.next(l?l(t):t)}catch(e){f(e)}var b,_,w},function(){return d(function(e){return e.complete()})},f,function(){return h.clear()},function(){return m=!0,0===p});s.subscribe(g)})}},2959(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ignoreElements=void 0;var r=n(5212),i=n(7214),o=n(5717);t.ignoreElements=function(){return r.operate(function(e,t){e.subscribe(i.createOperatorSubscriber(t,o.noop))})}},9915(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isEmpty=void 0;var r=n(5212),i=n(7214);t.isEmpty=function(){return r.operate(function(e,t){e.subscribe(i.createOperatorSubscriber(t,function(){t.next(!1),t.complete()},function(){t.next(!0),t.complete()}))})}},719(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.joinAllInternals=void 0;var r=n(7699),i=n(3916),o=n(1898),s=n(7478),a=n(3484);t.joinAllInternals=function(e,t){return o.pipe(a.toArray(),s.mergeMap(function(t){return e(t)}),t?i.mapOneOrManyArgs(t):r.identity)}},2568(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.last=void 0;var r=n(9328),i=n(5934),o=n(5279),s=n(632),a=n(8799),c=n(7699);t.last=function(e,t){var n=arguments.length>=2;return function(u){return u.pipe(e?i.filter(function(t,n){return e(t,n,u)}):c.identity,o.takeLast(1),n?a.defaultIfEmpty(t):s.throwIfEmpty(function(){return new r.EmptyError}))}}},6872(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.map=void 0;var r=n(5212),i=n(7214);t.map=function(e,t){return r.operate(function(n,r){var o=0;n.subscribe(i.createOperatorSubscriber(r,function(n){r.next(e.call(t,n,o++))}))})}},3337(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mapTo=void 0;var r=n(6872);t.mapTo=function(e){return r.map(function(){return e})}},5019(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.materialize=void 0;var r=n(1245),i=n(5212),o=n(7214);t.materialize=function(){return i.operate(function(e,t){e.subscribe(o.createOperatorSubscriber(t,function(e){t.next(r.Notification.createNext(e))},function(){t.next(r.Notification.createComplete()),t.complete()},function(e){t.next(r.Notification.createError(e)),t.complete()}))})}},96(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.max=void 0;var r=n(2070),i=n(281);t.max=function(e){return r.reduce(i.isFunction(e)?function(t,n){return e(t,n)>0?t:n}:function(e,t){return e>t?e:t})}},9330(e,t,n){"use strict";var r=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var n=0,r=t.length,i=e.length;n<r;n++,i++)e[i]=t[n];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.merge=void 0;var o=n(5212),s=n(8087),a=n(6404),c=n(7058);t.merge=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=a.popScheduler(e),u=a.popNumber(e,1/0);return o.operate(function(t,o){s.mergeAll(u)(c.from(i([t],r(e)),n)).subscribe(o)})}},8087(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mergeAll=void 0;var r=n(7478),i=n(7699);t.mergeAll=function(e){return void 0===e&&(e=1/0),r.mergeMap(i.identity,e)}},2574(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mergeInternals=void 0;var r=n(9724),i=n(8619),o=n(7214);t.mergeInternals=function(e,t,n,s,a,c,u,l){var h=[],d=0,f=0,p=!1,m=function(){!p||h.length||d||t.complete()},g=function(e){return d<s?y(e):h.push(e)},y=function(e){c&&t.next(e),d++;var l=!1;r.innerFrom(n(e,f++)).subscribe(o.createOperatorSubscriber(t,function(e){null==a||a(e),c?g(e):t.next(e)},function(){l=!0},void 0,function(){if(l)try{d--;for(var e=function(){var e=h.shift();u?i.executeSchedule(t,u,function(){return y(e)}):y(e)};h.length&&d<s;)e();m()}catch(e){t.error(e)}}))};return e.subscribe(o.createOperatorSubscriber(t,g,function(){p=!0,m()})),function(){null==l||l()}}},7478(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mergeMap=void 0;var r=n(6872),i=n(9724),o=n(5212),s=n(2574),a=n(281);t.mergeMap=function e(t,n,c){return void 0===c&&(c=1/0),a.isFunction(n)?e(function(e,o){return r.map(function(t,r){return n(e,t,o,r)})(i.innerFrom(t(e,o)))},c):("number"==typeof n&&(c=n),o.operate(function(e,n){return s.mergeInternals(e,n,t,c)}))}},6075(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mergeMapTo=void 0;var r=n(7478),i=n(281);t.mergeMapTo=function(e,t,n){return void 0===n&&(n=1/0),i.isFunction(t)?r.mergeMap(function(){return e},t,n):("number"==typeof t&&(n=t),r.mergeMap(function(){return e},n))}},6707(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mergeScan=void 0;var r=n(5212),i=n(2574);t.mergeScan=function(e,t,n){return void 0===n&&(n=1/0),r.operate(function(r,o){var s=t;return i.mergeInternals(r,o,function(t,n){return e(s,t,n)},n,function(e){s=e},!1,void 0,function(){return s=null})})}},9694(e,t,n){"use strict";var r=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var n=0,r=t.length,i=e.length;n<r;n++,i++)e[i]=t[n];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.mergeWith=void 0;var o=n(9330);t.mergeWith=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return o.merge.apply(void 0,i([],r(e)))}},142(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.min=void 0;var r=n(2070),i=n(281);t.min=function(e){return r.reduce(i.isFunction(e)?function(t,n){return e(t,n)<0?t:n}:function(e,t){return e<t?e:t})}},8464(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.multicast=void 0;var r=n(4359),i=n(281),o=n(7812);t.multicast=function(e,t){var n=i.isFunction(e)?e:function(){return e};return i.isFunction(t)?o.connect(t,{connector:n}):function(e){return new r.ConnectableObservable(e,n)}}},2071(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.observeOn=void 0;var r=n(8619),i=n(5212),o=n(7214);t.observeOn=function(e,t){return void 0===t&&(t=0),i.operate(function(n,i){n.subscribe(o.createOperatorSubscriber(i,function(n){return r.executeSchedule(i,e,function(){return i.next(n)},t)},function(){return r.executeSchedule(i,e,function(){return i.complete()},t)},function(n){return r.executeSchedule(i,e,function(){return i.error(n)},t)}))})}},5513(e,t,n){"use strict";var r=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var n=0,r=t.length,i=e.length;n<r;n++,i++)e[i]=t[n];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.onErrorResumeNext=t.onErrorResumeNextWith=void 0;var o=n(7652),s=n(1903);function a(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=o.argsOrArgArray(e);return function(e){return s.onErrorResumeNext.apply(void 0,i([e],r(n)))}}t.onErrorResumeNextWith=a,t.onErrorResumeNext=a},6744(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pairwise=void 0;var r=n(5212),i=n(7214);t.pairwise=function(){return r.operate(function(e,t){var n,r=!1;e.subscribe(i.createOperatorSubscriber(t,function(e){var i=n;n=e,r&&t.next([i,e]),r=!0}))})}},9516(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.partition=void 0;var r=n(4120),i=n(5934);t.partition=function(e,t){return function(n){return[i.filter(e,t)(n),i.filter(r.not(e,t))(n)]}}},6355(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pluck=void 0;var r=n(6872);t.pluck=function(){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 r.map(function(t){for(var r=t,i=0;i<n;i++){var o=null==r?void 0:r[e[i]];if(void 0===o)return;r=o}return r})}},3197(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.publish=void 0;var r=n(6808),i=n(8464),o=n(7812);t.publish=function(e){return e?function(t){return o.connect(e)(t)}:function(e){return i.multicast(new r.Subject)(e)}}},2955(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.publishBehavior=void 0;var r=n(7314),i=n(4359);t.publishBehavior=function(e){return function(t){var n=new r.BehaviorSubject(e);return new i.ConnectableObservable(t,function(){return n})}}},6569(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.publishLast=void 0;var r=n(5130),i=n(4359);t.publishLast=function(){return function(e){var t=new r.AsyncSubject;return new i.ConnectableObservable(e,function(){return t})}}},8710(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.publishReplay=void 0;var r=n(381),i=n(8464),o=n(281);t.publishReplay=function(e,t,n,s){n&&!o.isFunction(n)&&(s=n);var a=o.isFunction(n)?n:void 0;return function(n){return i.multicast(new r.ReplaySubject(e,t,s),a)(n)}}},6081(e,t,n){"use strict";var r=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var n=0,r=t.length,i=e.length;n<r;n++,i++)e[i]=t[n];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.race=void 0;var o=n(7652),s=n(6677);t.race=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return s.raceWith.apply(void 0,i([],r(o.argsOrArgArray(e))))}},6677(e,t,n){"use strict";var r=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var n=0,r=t.length,i=e.length;n<r;n++,i++)e[i]=t[n];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.raceWith=void 0;var o=n(9795),s=n(5212),a=n(7699);t.raceWith=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e.length?s.operate(function(t,n){o.raceInit(i([t],r(e)))(n)}):a.identity}},2070(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.reduce=void 0;var r=n(8531),i=n(5212);t.reduce=function(e,t){return i.operate(r.scanInternals(e,t,arguments.length>=2,!1,!0))}},9224(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.refCount=void 0;var r=n(5212),i=n(7214);t.refCount=function(){return r.operate(function(e,t){var n=null;e._refCount++;var r=i.createOperatorSubscriber(t,void 0,void 0,void 0,function(){if(!e||e._refCount<=0||0<--e._refCount)n=null;else{var r=e._connection,i=n;n=null,!r||i&&r!==i||r.unsubscribe(),t.unsubscribe()}});e.subscribe(r),r.closed||(n=e.connect())})}},6131(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.repeat=void 0;var r=n(4885),i=n(5212),o=n(7214),s=n(9724),a=n(5825);t.repeat=function(e){var t,n,c=1/0;return null!=e&&("object"==typeof e?(t=e.count,c=void 0===t?1/0:t,n=e.delay):c=e),c<=0?function(){return r.EMPTY}:i.operate(function(e,t){var r,i=0,u=function(){if(null==r||r.unsubscribe(),r=null,null!=n){var e="number"==typeof n?a.timer(n):s.innerFrom(n(i)),c=o.createOperatorSubscriber(t,function(){c.unsubscribe(),l()});e.subscribe(c)}else l()},l=function(){var n=!1;r=e.subscribe(o.createOperatorSubscriber(t,void 0,function(){++i<c?r?u():n=!0:t.complete()})),n&&u()};l()})}},2139(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.repeatWhen=void 0;var r=n(9724),i=n(6808),o=n(5212),s=n(7214);t.repeatWhen=function(e){return o.operate(function(t,n){var o,a,c=!1,u=!1,l=!1,h=function(){return l&&u&&(n.complete(),!0)},d=function(){l=!1,o=t.subscribe(s.createOperatorSubscriber(n,void 0,function(){l=!0,!h()&&(a||(a=new i.Subject,r.innerFrom(e(a)).subscribe(s.createOperatorSubscriber(n,function(){o?d():c=!0},function(){u=!0,h()}))),a).next()})),c&&(o.unsubscribe(),o=null,c=!1,d())};d()})}},3352(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.retry=void 0;var r=n(5212),i=n(7214),o=n(7699),s=n(5825),a=n(9724);t.retry=function(e){var t;void 0===e&&(e=1/0);var n=(t=e&&"object"==typeof e?e:{count:e}).count,c=void 0===n?1/0:n,u=t.delay,l=t.resetOnSuccess,h=void 0!==l&&l;return c<=0?o.identity:r.operate(function(e,t){var n,r=0,o=function(){var l=!1;n=e.subscribe(i.createOperatorSubscriber(t,function(e){h&&(r=0),t.next(e)},void 0,function(e){if(r++<c){var h=function(){n?(n.unsubscribe(),n=null,o()):l=!0};if(null!=u){var d="number"==typeof u?s.timer(u):a.innerFrom(u(e,r)),f=i.createOperatorSubscriber(t,function(){f.unsubscribe(),h()},function(){t.complete()});d.subscribe(f)}else h()}else t.error(e)})),l&&(n.unsubscribe(),n=null,o())};o()})}},3956(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.retryWhen=void 0;var r=n(9724),i=n(6808),o=n(5212),s=n(7214);t.retryWhen=function(e){return o.operate(function(t,n){var o,a,c=!1,u=function(){o=t.subscribe(s.createOperatorSubscriber(n,void 0,void 0,function(t){a||(a=new i.Subject,r.innerFrom(e(a)).subscribe(s.createOperatorSubscriber(n,function(){return o?u():c=!0}))),a&&a.next(t)})),c&&(o.unsubscribe(),o=null,c=!1,u())};u()})}},3434(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sample=void 0;var r=n(9724),i=n(5212),o=n(5717),s=n(7214);t.sample=function(e){return i.operate(function(t,n){var i=!1,a=null;t.subscribe(s.createOperatorSubscriber(n,function(e){i=!0,a=e})),r.innerFrom(e).subscribe(s.createOperatorSubscriber(n,function(){if(i){i=!1;var e=a;a=null,n.next(e)}},o.noop))})}},4143(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sampleTime=void 0;var r=n(2326),i=n(3434),o=n(2275);t.sampleTime=function(e,t){return void 0===t&&(t=r.asyncScheduler),i.sample(o.interval(e,t))}},5565(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.scan=void 0;var r=n(5212),i=n(8531);t.scan=function(e,t){return r.operate(i.scanInternals(e,t,arguments.length>=2,!0))}},8531(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.scanInternals=void 0;var r=n(7214);t.scanInternals=function(e,t,n,i,o){return function(s,a){var c=n,u=t,l=0;s.subscribe(r.createOperatorSubscriber(a,function(t){var n=l++;u=c?e(u,t,n):(c=!0,t),i&&a.next(u)},o&&function(){c&&a.next(u),a.complete()}))}}},3929(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sequenceEqual=void 0;var r=n(5212),i=n(7214),o=n(9724);t.sequenceEqual=function(e,t){return void 0===t&&(t=function(e,t){return e===t}),r.operate(function(n,r){var s={buffer:[],complete:!1},a={buffer:[],complete:!1},c=function(e){r.next(e),r.complete()},u=function(e,n){var o=i.createOperatorSubscriber(r,function(r){var i=n.buffer,o=n.complete;0===i.length?o?c(!1):e.buffer.push(r):!t(r,i.shift())&&c(!1)},function(){e.complete=!0;var t=n.complete,r=n.buffer;t&&c(0===r.length),null==o||o.unsubscribe()});return o};n.subscribe(u(s,a)),o.innerFrom(e).subscribe(u(a,s))})}},3405(e,t,n){"use strict";var r=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var n=0,r=t.length,i=e.length;n<r;n++,i++)e[i]=t[n];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.share=void 0;var o=n(9724),s=n(6808),a=n(2708),c=n(5212);function u(e,t){for(var n=[],s=2;s<arguments.length;s++)n[s-2]=arguments[s];if(!0!==t){if(!1!==t){var c=new a.SafeSubscriber({next:function(){c.unsubscribe(),e()}});return o.innerFrom(t.apply(void 0,i([],r(n)))).subscribe(c)}}else e()}t.share=function(e){void 0===e&&(e={});var t=e.connector,n=void 0===t?function(){return new s.Subject}:t,r=e.resetOnError,i=void 0===r||r,l=e.resetOnComplete,h=void 0===l||l,d=e.resetOnRefCountZero,f=void 0===d||d;return function(e){var t,r,s,l=0,d=!1,p=!1,m=function(){null==r||r.unsubscribe(),r=void 0},g=function(){m(),t=s=void 0,d=p=!1},y=function(){var e=t;g(),null==e||e.unsubscribe()};return c.operate(function(e,c){l++,p||d||m();var v=s=null!=s?s:n();c.add(function(){0!==--l||p||d||(r=u(y,f))}),v.subscribe(c),!t&&l>0&&(t=new a.SafeSubscriber({next:function(e){return v.next(e)},error:function(e){p=!0,m(),r=u(g,i,e),v.error(e)},complete:function(){d=!0,m(),r=u(g,h),v.complete()}}),o.innerFrom(e).subscribe(t))})(e)}}},7782(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.shareReplay=void 0;var r=n(381),i=n(3405);t.shareReplay=function(e,t,n){var o,s,a,c,u=!1;return e&&"object"==typeof e?(o=e.bufferSize,c=void 0===o?1/0:o,s=e.windowTime,t=void 0===s?1/0:s,u=void 0!==(a=e.refCount)&&a,n=e.scheduler):c=null!=e?e:1/0,i.share({connector:function(){return new r.ReplaySubject(c,t,n)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:u})}},5440(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.single=void 0;var r=n(9328),i=n(4708),o=n(3506),s=n(5212),a=n(7214);t.single=function(e){return s.operate(function(t,n){var s,c=!1,u=!1,l=0;t.subscribe(a.createOperatorSubscriber(n,function(r){u=!0,e&&!e(r,l++,t)||(c&&n.error(new i.SequenceError("Too many matching values")),c=!0,s=r)},function(){c?(n.next(s),n.complete()):n.error(u?new o.NotFoundError("No matching values"):new r.EmptyError)}))})}},3079(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.skip=void 0;var r=n(5934);t.skip=function(e){return r.filter(function(t,n){return e<=n})}},2359(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.skipLast=void 0;var r=n(7699),i=n(5212),o=n(7214);t.skipLast=function(e){return e<=0?r.identity:i.operate(function(t,n){var r=new Array(e),i=0;return t.subscribe(o.createOperatorSubscriber(n,function(t){var o=i++;if(o<e)r[o]=t;else{var s=o%e,a=r[s];r[s]=t,n.next(a)}})),function(){r=null}})}},7783(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.skipUntil=void 0;var r=n(5212),i=n(7214),o=n(9724),s=n(5717);t.skipUntil=function(e){return r.operate(function(t,n){var r=!1,a=i.createOperatorSubscriber(n,function(){null==a||a.unsubscribe(),r=!0},s.noop);o.innerFrom(e).subscribe(a),t.subscribe(i.createOperatorSubscriber(n,function(e){return r&&n.next(e)}))})}},5774(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.skipWhile=void 0;var r=n(5212),i=n(7214);t.skipWhile=function(e){return r.operate(function(t,n){var r=!1,o=0;t.subscribe(i.createOperatorSubscriber(n,function(t){return(r||(r=!e(t,o++)))&&n.next(t)}))})}},9054(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.startWith=void 0;var r=n(9546),i=n(6404),o=n(5212);t.startWith=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=i.popScheduler(e);return o.operate(function(t,i){(n?r.concat(e,t,n):r.concat(e,t)).subscribe(i)})}},5455(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.subscribeOn=void 0;var r=n(5212);t.subscribeOn=function(e,t){return void 0===t&&(t=0),r.operate(function(n,r){r.add(e.schedule(function(){return n.subscribe(r)},t))})}},6201(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.switchAll=void 0;var r=n(680),i=n(7699);t.switchAll=function(){return r.switchMap(i.identity)}},680(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.switchMap=void 0;var r=n(9724),i=n(5212),o=n(7214);t.switchMap=function(e,t){return i.operate(function(n,i){var s=null,a=0,c=!1,u=function(){return c&&!s&&i.complete()};n.subscribe(o.createOperatorSubscriber(i,function(n){null==s||s.unsubscribe();var c=0,l=a++;r.innerFrom(e(n,l)).subscribe(s=o.createOperatorSubscriber(i,function(e){return i.next(t?t(n,e,l,c++):e)},function(){s=null,u()}))},function(){c=!0,u()}))})}},761(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.switchMapTo=void 0;var r=n(680),i=n(281);t.switchMapTo=function(e,t){return i.isFunction(t)?r.switchMap(function(){return e},t):r.switchMap(function(){return e})}},8461(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.switchScan=void 0;var r=n(680),i=n(5212);t.switchScan=function(e,t){return i.operate(function(n,i){var o=t;return r.switchMap(function(t,n){return e(o,t,n)},function(e,t){return o=t,t})(n).subscribe(i),function(){o=null}})}},4383(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.take=void 0;var r=n(4885),i=n(5212),o=n(7214);t.take=function(e){return e<=0?function(){return r.EMPTY}:i.operate(function(t,n){var r=0;t.subscribe(o.createOperatorSubscriber(n,function(t){++r<=e&&(n.next(t),e<=r&&n.complete())}))})}},5279(e,t,n){"use strict";var r=this&&this.__values||function(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.")};Object.defineProperty(t,"__esModule",{value:!0}),t.takeLast=void 0;var i=n(4885),o=n(5212),s=n(7214);t.takeLast=function(e){return e<=0?function(){return i.EMPTY}:o.operate(function(t,n){var i=[];t.subscribe(s.createOperatorSubscriber(n,function(t){i.push(t),e<i.length&&i.shift()},function(){var e,t;try{for(var o=r(i),s=o.next();!s.done;s=o.next()){var a=s.value;n.next(a)}}catch(t){e={error:t}}finally{try{s&&!s.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}n.complete()},void 0,function(){i=null}))})}},6911(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.takeUntil=void 0;var r=n(5212),i=n(7214),o=n(9724),s=n(5717);t.takeUntil=function(e){return r.operate(function(t,n){o.innerFrom(e).subscribe(i.createOperatorSubscriber(n,function(){return n.complete()},s.noop)),!n.closed&&t.subscribe(n)})}},598(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.takeWhile=void 0;var r=n(5212),i=n(7214);t.takeWhile=function(e,t){return void 0===t&&(t=!1),r.operate(function(n,r){var o=0;n.subscribe(i.createOperatorSubscriber(r,function(n){var i=e(n,o++);(i||t)&&r.next(n),!i&&r.complete()}))})}},7400(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tap=void 0;var r=n(281),i=n(5212),o=n(7214),s=n(7699);t.tap=function(e,t,n){var a=r.isFunction(e)||t||n?{next:e,error:t,complete:n}:e;return a?i.operate(function(e,t){var n;null===(n=a.subscribe)||void 0===n||n.call(a);var r=!0;e.subscribe(o.createOperatorSubscriber(t,function(e){var n;null===(n=a.next)||void 0===n||n.call(a,e),t.next(e)},function(){var e;r=!1,null===(e=a.complete)||void 0===e||e.call(a),t.complete()},function(e){var n;r=!1,null===(n=a.error)||void 0===n||n.call(a,e),t.error(e)},function(){var e,t;r&&(null===(e=a.unsubscribe)||void 0===e||e.call(a)),null===(t=a.finalize)||void 0===t||t.call(a)}))}):s.identity}},4880(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.throttle=void 0;var r=n(5212),i=n(7214),o=n(9724);t.throttle=function(e,t){return r.operate(function(n,r){var s=null!=t?t:{},a=s.leading,c=void 0===a||a,u=s.trailing,l=void 0!==u&&u,h=!1,d=null,f=null,p=!1,m=function(){null==f||f.unsubscribe(),f=null,l&&(v(),p&&r.complete())},g=function(){f=null,p&&r.complete()},y=function(t){return f=o.innerFrom(e(t)).subscribe(i.createOperatorSubscriber(r,m,g))},v=function(){if(h){h=!1;var e=d;d=null,r.next(e),!p&&y(e)}};n.subscribe(i.createOperatorSubscriber(r,function(e){h=!0,d=e,(!f||f.closed)&&(c?v():y(e))},function(){p=!0,(!(l&&h&&f)||f.closed)&&r.complete()}))})}},7245(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.throttleTime=void 0;var r=n(2326),i=n(4880),o=n(5825);t.throttleTime=function(e,t,n){void 0===t&&(t=r.asyncScheduler);var s=o.timer(e,t);return i.throttle(function(){return s},n)}},632(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.throwIfEmpty=void 0;var r=n(9328),i=n(5212),o=n(7214);function s(){return new r.EmptyError}t.throwIfEmpty=function(e){return void 0===e&&(e=s),i.operate(function(t,n){var r=!1;t.subscribe(o.createOperatorSubscriber(n,function(e){r=!0,n.next(e)},function(){return r?n.complete():n.error(e())}))})}},2508(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TimeInterval=t.timeInterval=void 0;var r=n(2326),i=n(5212),o=n(7214);t.timeInterval=function(e){return void 0===e&&(e=r.asyncScheduler),i.operate(function(t,n){var r=e.now();t.subscribe(o.createOperatorSubscriber(n,function(t){var i=e.now(),o=i-r;r=i,n.next(new s(t,o))}))})};var s=function(e,t){this.value=e,this.interval=t};t.TimeInterval=s},1713(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.timeout=t.TimeoutError=void 0;var r=n(2326),i=n(5345),o=n(5212),s=n(9724),a=n(9619),c=n(7214),u=n(8619);function l(e){throw new t.TimeoutError(e)}t.TimeoutError=a.createErrorClass(function(e){return function(t){void 0===t&&(t=null),e(this),this.message="Timeout has occurred",this.name="TimeoutError",this.info=t}}),t.timeout=function(e,t){var n=i.isValidDate(e)?{first:e}:"number"==typeof e?{each:e}:e,a=n.first,h=n.each,d=n.with,f=void 0===d?l:d,p=n.scheduler,m=void 0===p?null!=t?t:r.asyncScheduler:p,g=n.meta,y=void 0===g?null:g;if(null==a&&null==h)throw new TypeError("No timeout provided.");return o.operate(function(e,t){var n,r,i=null,o=0,l=function(e){r=u.executeSchedule(t,m,function(){try{n.unsubscribe(),s.innerFrom(f({meta:y,lastValue:i,seen:o})).subscribe(t)}catch(e){t.error(e)}},e)};n=e.subscribe(c.createOperatorSubscriber(t,function(e){null==r||r.unsubscribe(),o++,t.next(i=e),h>0&&l(h)},void 0,void 0,function(){(null==r?void 0:r.closed)||null==r||r.unsubscribe(),i=null})),!o&&l(null!=a?"number"==typeof a?a:+a-m.now():h)})}},597(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.timeoutWith=void 0;var r=n(2326),i=n(5345),o=n(1713);t.timeoutWith=function(e,t,n){var s,a,c;if(n=null!=n?n:r.async,i.isValidDate(e)?s=e:"number"==typeof e&&(a=e),!t)throw new TypeError("No observable provided to switch to");if(c=function(){return t},null==s&&null==a)throw new TypeError("No timeout provided.");return o.timeout({first:s,each:a,scheduler:n,with:c})}},3866(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.timestamp=void 0;var r=n(3275),i=n(6872);t.timestamp=function(e){return void 0===e&&(e=r.dateTimestampProvider),i.map(function(t){return{value:t,timestamp:e.now()}})}},3484(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toArray=void 0;var r=n(2070),i=n(5212),o=function(e,t){return e.push(t),e};t.toArray=function(){return i.operate(function(e,t){r.reduce(o,[])(e).subscribe(t)})}},8072(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.window=void 0;var r=n(6808),i=n(5212),o=n(7214),s=n(5717),a=n(9724);t.window=function(e){return i.operate(function(t,n){var i=new r.Subject;n.next(i.asObservable());var c=function(e){i.error(e),n.error(e)};return t.subscribe(o.createOperatorSubscriber(n,function(e){return null==i?void 0:i.next(e)},function(){i.complete(),n.complete()},c)),a.innerFrom(e).subscribe(o.createOperatorSubscriber(n,function(){i.complete(),n.next(i=new r.Subject)},s.noop,c)),function(){null==i||i.unsubscribe(),i=null}})}},2893(e,t,n){"use strict";var r=this&&this.__values||function(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.")};Object.defineProperty(t,"__esModule",{value:!0}),t.windowCount=void 0;var i=n(6808),o=n(5212),s=n(7214);t.windowCount=function(e,t){void 0===t&&(t=0);var n=t>0?t:e;return o.operate(function(t,o){var a=[new i.Subject],c=0;o.next(a[0].asObservable()),t.subscribe(s.createOperatorSubscriber(o,function(t){var s,u;try{for(var l=r(a),h=l.next();!h.done;h=l.next())h.value.next(t)}catch(e){s={error:e}}finally{try{h&&!h.done&&(u=l.return)&&u.call(l)}finally{if(s)throw s.error}}var d=c-e+1;if(d>=0&&d%n===0&&a.shift().complete(),++c%n===0){var f=new i.Subject;a.push(f),o.next(f.asObservable())}},function(){for(;a.length>0;)a.shift().complete();o.complete()},function(e){for(;a.length>0;)a.shift().error(e);o.error(e)},function(){a=null}))})}},37(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.windowTime=void 0;var r=n(6808),i=n(2326),o=n(9879),s=n(5212),a=n(7214),c=n(4830),u=n(6404),l=n(8619);t.windowTime=function(e){for(var t,n,h=[],d=1;d<arguments.length;d++)h[d-1]=arguments[d];var f=null!==(t=u.popScheduler(h))&&void 0!==t?t:i.asyncScheduler,p=null!==(n=h[0])&&void 0!==n?n:null,m=h[1]||1/0;return s.operate(function(t,n){var i=[],s=!1,u=function(e){var t=e.window,n=e.subs;t.complete(),n.unsubscribe(),c.arrRemove(i,e),s&&h()},h=function(){if(i){var t=new o.Subscription;n.add(t);var s=new r.Subject,a={window:s,subs:t,seen:0};i.push(a),n.next(s.asObservable()),l.executeSchedule(t,f,function(){return u(a)},e)}};null!==p&&p>=0?l.executeSchedule(n,f,h,p,!0):s=!0,h();var d=function(e){return i.slice().forEach(e)},g=function(e){d(function(t){var n=t.window;return e(n)}),e(n),n.unsubscribe()};return t.subscribe(a.createOperatorSubscriber(n,function(e){d(function(t){t.window.next(e),m<=++t.seen&&u(t)})},function(){return g(function(e){return e.complete()})},function(e){return g(function(t){return t.error(e)})})),function(){i=null}})}},8996(e,t,n){"use strict";var r=this&&this.__values||function(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.")};Object.defineProperty(t,"__esModule",{value:!0}),t.windowToggle=void 0;var i=n(6808),o=n(9879),s=n(5212),a=n(9724),c=n(7214),u=n(5717),l=n(4830);t.windowToggle=function(e,t){return s.operate(function(n,s){var h=[],d=function(e){for(;0<h.length;)h.shift().error(e);s.error(e)};a.innerFrom(e).subscribe(c.createOperatorSubscriber(s,function(e){var n=new i.Subject;h.push(n);var r,f=new o.Subscription;try{r=a.innerFrom(t(e))}catch(e){return void d(e)}s.next(n.asObservable()),f.add(r.subscribe(c.createOperatorSubscriber(s,function(){l.arrRemove(h,n),n.complete(),f.unsubscribe()},u.noop,d)))},u.noop)),n.subscribe(c.createOperatorSubscriber(s,function(e){var t,n,i=h.slice();try{for(var o=r(i),s=o.next();!s.done;s=o.next())s.value.next(e)}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}},function(){for(;0<h.length;)h.shift().complete();s.complete()},d,function(){for(;0<h.length;)h.shift().unsubscribe()}))})}},5156(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.windowWhen=void 0;var r=n(6808),i=n(5212),o=n(7214),s=n(9724);t.windowWhen=function(e){return i.operate(function(t,n){var i,a,c=function(e){i.error(e),n.error(e)},u=function(){var t;null==a||a.unsubscribe(),null==i||i.complete(),i=new r.Subject,n.next(i.asObservable());try{t=s.innerFrom(e())}catch(e){return void c(e)}t.subscribe(a=o.createOperatorSubscriber(n,u,u,c))};u(),t.subscribe(o.createOperatorSubscriber(n,function(e){return i.next(e)},function(){i.complete(),n.complete()},c,function(){null==a||a.unsubscribe(),i=null}))})}},6975(e,t,n){"use strict";var r=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var n=0,r=t.length,i=e.length;n<r;n++,i++)e[i]=t[n];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.withLatestFrom=void 0;var o=n(5212),s=n(7214),a=n(9724),c=n(7699),u=n(5717),l=n(6404);t.withLatestFrom=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=l.popResultSelector(e);return o.operate(function(t,o){for(var l=e.length,h=new Array(l),d=e.map(function(){return!1}),f=!1,p=function(t){a.innerFrom(e[t]).subscribe(s.createOperatorSubscriber(o,function(e){h[t]=e,f||d[t]||(d[t]=!0,(f=d.every(c.identity))&&(d=null))},u.noop))},m=0;m<l;m++)p(m);t.subscribe(s.createOperatorSubscriber(o,function(e){if(f){var t=i([e],r(h));o.next(n?n.apply(void 0,i([],r(t))):t)}}))})}},6749(e,t,n){"use strict";var r=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var n=0,r=t.length,i=e.length;n<r;n++,i++)e[i]=t[n];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.zip=void 0;var o=n(1415),s=n(5212);t.zip=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return s.operate(function(t,n){o.zip.apply(void 0,i([t],r(e))).subscribe(n)})}},5362(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.zipAll=void 0;var r=n(1415),i=n(719);t.zipAll=function(e){return i.joinAllInternals(r.zip,e)}},6977(e,t,n){"use strict";var r=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var n=0,r=t.length,i=e.length;n<r;n++,i++)e[i]=t[n];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.zipWith=void 0;var o=n(6749);t.zipWith=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return o.zip.apply(void 0,i([],r(e)))}},4950(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.scheduleArray=void 0;var r=n(8051);t.scheduleArray=function(e,t){return new r.Observable(function(n){var r=0;return t.schedule(function(){r===e.length?n.complete():(n.next(e[r++]),n.closed||this.schedule())})})}},7873(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.scheduleAsyncIterable=void 0;var r=n(8051),i=n(8619);t.scheduleAsyncIterable=function(e,t){if(!e)throw new Error("Iterable cannot be null");return new r.Observable(function(n){i.executeSchedule(n,t,function(){var r=e[Symbol.asyncIterator]();i.executeSchedule(n,t,function(){r.next().then(function(e){e.done?n.complete():n.next(e.value)})},0,!0)})})}},6805(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.scheduleIterable=void 0;var r=n(8051),i=n(4891),o=n(281),s=n(8619);t.scheduleIterable=function(e,t){return new r.Observable(function(n){var r;return s.executeSchedule(n,t,function(){r=e[i.iterator](),s.executeSchedule(n,t,function(){var e,t,i;try{t=(e=r.next()).value,i=e.done}catch(e){return void n.error(e)}i?n.complete():n.next(t)},0,!0)}),function(){return o.isFunction(null==r?void 0:r.return)&&r.return()}})}},5650(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.scheduleObservable=void 0;var r=n(9724),i=n(2071),o=n(5455);t.scheduleObservable=function(e,t){return r.innerFrom(e).pipe(o.subscribeOn(t),i.observeOn(t))}},4530(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.schedulePromise=void 0;var r=n(9724),i=n(2071),o=n(5455);t.schedulePromise=function(e,t){return r.innerFrom(e).pipe(o.subscribeOn(t),i.observeOn(t))}},380(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.scheduleReadableStreamLike=void 0;var r=n(7873),i=n(5462);t.scheduleReadableStreamLike=function(e,t){return r.scheduleAsyncIterable(i.readableStreamLikeToAsyncGenerator(e),t)}},131(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.scheduled=void 0;var r=n(5650),i=n(4530),o=n(4950),s=n(6805),a=n(7873),c=n(629),u=n(7552),l=n(4975),h=n(2187),d=n(8263),f=n(6297),p=n(5462),m=n(380);t.scheduled=function(e,t){if(null!=e){if(c.isInteropObservable(e))return r.scheduleObservable(e,t);if(l.isArrayLike(e))return o.scheduleArray(e,t);if(u.isPromise(e))return i.schedulePromise(e,t);if(d.isAsyncIterable(e))return a.scheduleAsyncIterable(e,t);if(h.isIterable(e))return s.scheduleIterable(e,t);if(p.isReadableStreamLike(e))return m.scheduleReadableStreamLike(e,t)}throw f.createInvalidObservableTypeError(e)}},1666(e,t,n){"use strict";var r,i=this&&this.__extends||(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(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)});Object.defineProperty(t,"__esModule",{value:!0}),t.Action=void 0;var o=function(e){function t(t,n){return e.call(this)||this}return i(t,e),t.prototype.schedule=function(e,t){return void 0===t&&(t=0),this},t}(n(9879).Subscription);t.Action=o},6757(e,t,n){"use strict";var r,i=this&&this.__extends||(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(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)});Object.defineProperty(t,"__esModule",{value:!0}),t.AnimationFrameAction=void 0;var o=n(4772),s=n(5726),a=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.scheduler=t,r.work=n,r}return i(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=s.animationFrameProvider.requestAnimationFrame(function(){return t.flush(void 0)})))},t.prototype.recycleAsyncId=function(t,n,r){var i;if(void 0===r&&(r=0),null!=r?r>0:this.delay>0)return e.prototype.recycleAsyncId.call(this,t,n,r);var o=t.actions;null!=n&&n===t._scheduled&&(null===(i=o[o.length-1])||void 0===i?void 0:i.id)!==n&&(s.animationFrameProvider.cancelAnimationFrame(n),t._scheduled=void 0)},t}(o.AsyncAction);t.AnimationFrameAction=a},4478(e,t,n){"use strict";var r,i=this&&this.__extends||(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(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)});Object.defineProperty(t,"__esModule",{value:!0}),t.AnimationFrameScheduler=void 0;var o=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.flush=function(e){var t;this._active=!0,e?t=e.id:(t=this._scheduled,this._scheduled=void 0);var n,r=this.actions;e=e||r.shift();do{if(n=e.execute(e.state,e.delay))break}while((e=r[0])&&e.id===t&&r.shift());if(this._active=!1,n){for(;(e=r[0])&&e.id===t&&r.shift();)e.unsubscribe();throw n}},t}(n(9533).AsyncScheduler);t.AnimationFrameScheduler=o},432(e,t,n){"use strict";var r,i=this&&this.__extends||(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(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)});Object.defineProperty(t,"__esModule",{value:!0}),t.AsapAction=void 0;var o=n(4772),s=n(6002),a=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.scheduler=t,r.work=n,r}return i(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=s.immediateProvider.setImmediate(t.flush.bind(t,void 0))))},t.prototype.recycleAsyncId=function(t,n,r){var i;if(void 0===r&&(r=0),null!=r?r>0:this.delay>0)return e.prototype.recycleAsyncId.call(this,t,n,r);var o=t.actions;null!=n&&(null===(i=o[o.length-1])||void 0===i?void 0:i.id)!==n&&(s.immediateProvider.clearImmediate(n),t._scheduled===n&&(t._scheduled=void 0))},t}(o.AsyncAction);t.AsapAction=a},3952(e,t,n){"use strict";var r,i=this&&this.__extends||(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(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)});Object.defineProperty(t,"__esModule",{value:!0}),t.AsapScheduler=void 0;var o=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.flush=function(e){this._active=!0;var t=this._scheduled;this._scheduled=void 0;var n,r=this.actions;e=e||r.shift();do{if(n=e.execute(e.state,e.delay))break}while((e=r[0])&&e.id===t&&r.shift());if(this._active=!1,n){for(;(e=r[0])&&e.id===t&&r.shift();)e.unsubscribe();throw n}},t}(n(9533).AsyncScheduler);t.AsapScheduler=o},4772(e,t,n){"use strict";var r,i=this&&this.__extends||(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(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)});Object.defineProperty(t,"__esModule",{value:!0}),t.AsyncAction=void 0;var o=n(1666),s=n(8284),a=n(4830),c=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 i(t,e),t.prototype.schedule=function(e,t){var n;if(void 0===t&&(t=0),this.closed)return this;this.state=e;var r=this.id,i=this.scheduler;return null!=r&&(this.id=this.recycleAsyncId(i,r,t)),this.pending=!0,this.delay=t,this.id=null!==(n=this.id)&&void 0!==n?n:this.requestAsyncId(i,this.id,t),this},t.prototype.requestAsyncId=function(e,t,n){return void 0===n&&(n=0),s.intervalProvider.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;null!=t&&s.intervalProvider.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,r=!1;try{this.work(e)}catch(e){r=!0,n=e||new Error("Scheduled action threw falsy error")}if(r)return this.unsubscribe(),n},t.prototype.unsubscribe=function(){if(!this.closed){var t=this.id,n=this.scheduler,r=n.actions;this.work=this.state=this.scheduler=null,this.pending=!1,a.arrRemove(r,this),null!=t&&(this.id=this.recycleAsyncId(n,t,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(o.Action);t.AsyncAction=c},9533(e,t,n){"use strict";var r,i=this&&this.__extends||(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(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)});Object.defineProperty(t,"__esModule",{value:!0}),t.AsyncScheduler=void 0;var o=n(5881),s=function(e){function t(t,n){void 0===n&&(n=o.Scheduler.now);var r=e.call(this,t,n)||this;return r.actions=[],r._active=!1,r}return i(t,e),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}(o.Scheduler);t.AsyncScheduler=s},1983(e,t,n){"use strict";var r,i=this&&this.__extends||(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(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)});Object.defineProperty(t,"__esModule",{value:!0}),t.QueueAction=void 0;var o=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.scheduler=t,r.work=n,r}return i(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),0)},t}(n(4772).AsyncAction);t.QueueAction=o},2036(e,t,n){"use strict";var r,i=this&&this.__extends||(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(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)});Object.defineProperty(t,"__esModule",{value:!0}),t.QueueScheduler=void 0;var o=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t}(n(9533).AsyncScheduler);t.QueueScheduler=o},875(e,t,n){"use strict";var r,i=this&&this.__extends||(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(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)});Object.defineProperty(t,"__esModule",{value:!0}),t.VirtualAction=t.VirtualTimeScheduler=void 0;var o=n(4772),s=n(9879),a=function(e){function t(t,n){void 0===t&&(t=c),void 0===n&&(n=1/0);var r=e.call(this,t,function(){return r.frame})||this;return r.maxFrames=n,r.frame=0,r.index=-1,r}return i(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}(n(9533).AsyncScheduler);t.VirtualTimeScheduler=a;var c=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 i(t,e),t.prototype.schedule=function(n,r){if(void 0===r&&(r=0),Number.isFinite(r)){if(!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)}return s.Subscription.EMPTY},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),1},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}(o.AsyncAction);t.VirtualAction=c},5887(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.animationFrame=t.animationFrameScheduler=void 0;var r=n(6757),i=n(4478);t.animationFrameScheduler=new i.AnimationFrameScheduler(r.AnimationFrameAction),t.animationFrame=t.animationFrameScheduler},5726(e,t,n){"use strict";var r=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var n=0,r=t.length,i=e.length;n<r;n++,i++)e[i]=t[n];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.animationFrameProvider=void 0;var o=n(9879);t.animationFrameProvider={schedule:function(e){var n=requestAnimationFrame,r=cancelAnimationFrame,i=t.animationFrameProvider.delegate;i&&(n=i.requestAnimationFrame,r=i.cancelAnimationFrame);var s=n(function(t){r=void 0,e(t)});return new o.Subscription(function(){return null==r?void 0:r(s)})},requestAnimationFrame:function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var o=t.animationFrameProvider.delegate;return((null==o?void 0:o.requestAnimationFrame)||requestAnimationFrame).apply(void 0,i([],r(e)))},cancelAnimationFrame:function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var o=t.animationFrameProvider.delegate;return((null==o?void 0:o.cancelAnimationFrame)||cancelAnimationFrame).apply(void 0,i([],r(e)))},delegate:void 0}},2105(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.asap=t.asapScheduler=void 0;var r=n(432),i=n(3952);t.asapScheduler=new i.AsapScheduler(r.AsapAction),t.asap=t.asapScheduler},2326(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.async=t.asyncScheduler=void 0;var r=n(4772),i=n(9533);t.asyncScheduler=new i.AsyncScheduler(r.AsyncAction),t.async=t.asyncScheduler},3275(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dateTimestampProvider=void 0,t.dateTimestampProvider={now:function(){return(t.dateTimestampProvider.delegate||Date).now()},delegate:void 0}},6002(e,t,n){"use strict";var r=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var n=0,r=t.length,i=e.length;n<r;n++,i++)e[i]=t[n];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.immediateProvider=void 0;var o=n(2052),s=o.Immediate.setImmediate,a=o.Immediate.clearImmediate;t.immediateProvider={setImmediate:function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var o=t.immediateProvider.delegate;return((null==o?void 0:o.setImmediate)||s).apply(void 0,i([],r(e)))},clearImmediate:function(e){var n=t.immediateProvider.delegate;return((null==n?void 0:n.clearImmediate)||a)(e)},delegate:void 0}},8284(e,t){"use strict";var n=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},r=this&&this.__spreadArray||function(e,t){for(var n=0,r=t.length,i=e.length;n<r;n++,i++)e[i]=t[n];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.intervalProvider=void 0,t.intervalProvider={setInterval:function(e,i){for(var o=[],s=2;s<arguments.length;s++)o[s-2]=arguments[s];var a=t.intervalProvider.delegate;return(null==a?void 0:a.setInterval)?a.setInterval.apply(a,r([e,i],n(o))):setInterval.apply(void 0,r([e,i],n(o)))},clearInterval:function(e){var n=t.intervalProvider.delegate;return((null==n?void 0:n.clearInterval)||clearInterval)(e)},delegate:void 0}},2931(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.performanceTimestampProvider=void 0,t.performanceTimestampProvider={now:function(){return(t.performanceTimestampProvider.delegate||performance).now()},delegate:void 0}},9245(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.queue=t.queueScheduler=void 0;var r=n(1983),i=n(2036);t.queueScheduler=new i.QueueScheduler(r.QueueAction),t.queue=t.queueScheduler},4808(e,t){"use strict";var n=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},r=this&&this.__spreadArray||function(e,t){for(var n=0,r=t.length,i=e.length;n<r;n++,i++)e[i]=t[n];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.timeoutProvider=void 0,t.timeoutProvider={setTimeout:function(e,i){for(var o=[],s=2;s<arguments.length;s++)o[s-2]=arguments[s];var a=t.timeoutProvider.delegate;return(null==a?void 0:a.setTimeout)?a.setTimeout.apply(a,r([e,i],n(o))):setTimeout.apply(void 0,r([e,i],n(o)))},clearTimeout:function(e){var n=t.timeoutProvider.delegate;return((null==n?void 0:n.clearTimeout)||clearTimeout)(e)},delegate:void 0}},4891(e,t){"use strict";function n(){return"function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator"}Object.defineProperty(t,"__esModule",{value:!0}),t.iterator=t.getSymbolIterator=void 0,t.getSymbolIterator=n,t.iterator=n()},2884(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.observable=void 0,t.observable="function"==typeof Symbol&&Symbol.observable||"@@observable"},6153(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},7024(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ArgumentOutOfRangeError=void 0;var r=n(9619);t.ArgumentOutOfRangeError=r.createErrorClass(function(e){return function(){e(this),this.name="ArgumentOutOfRangeError",this.message="argument out of range"}})},9328(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EmptyError=void 0;var r=n(9619);t.EmptyError=r.createErrorClass(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}})},2052(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TestTools=t.Immediate=void 0;var n,r=1,i={};function o(e){return e in i&&(delete i[e],!0)}t.Immediate={setImmediate:function(e){var t=r++;return i[t]=!0,n||(n=Promise.resolve()),n.then(function(){return o(t)&&e()}),t},clearImmediate:function(e){o(e)}},t.TestTools={pending:function(){return Object.keys(i).length}}},3506(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NotFoundError=void 0;var r=n(9619);t.NotFoundError=r.createErrorClass(function(e){return function(t){e(this),this.name="NotFoundError",this.message=t}})},839(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ObjectUnsubscribedError=void 0;var r=n(9619);t.ObjectUnsubscribedError=r.createErrorClass(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})},4708(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SequenceError=void 0;var r=n(9619);t.SequenceError=r.createErrorClass(function(e){return function(t){e(this),this.name="SequenceError",this.message=t}})},9517(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UnsubscriptionError=void 0;var r=n(9619);t.UnsubscriptionError=r.createErrorClass(function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map(function(e,t){return t+1+") "+e.toString()}).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}})},6404(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.popNumber=t.popScheduler=t.popResultSelector=void 0;var r=n(281),i=n(8596);function o(e){return e[e.length-1]}t.popResultSelector=function(e){return r.isFunction(o(e))?e.pop():void 0},t.popScheduler=function(e){return i.isScheduler(o(e))?e.pop():void 0},t.popNumber=function(e,t){return"number"==typeof o(e)?e.pop():t}},439(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.argsArgArrayOrObject=void 0;var n=Array.isArray,r=Object.getPrototypeOf,i=Object.prototype,o=Object.keys;t.argsArgArrayOrObject=function(e){if(1===e.length){var t=e[0];if(n(t))return{args:t,keys:null};if((a=t)&&"object"==typeof a&&r(a)===i){var s=o(t);return{args:s.map(function(e){return t[e]}),keys:s}}}var a;return{args:e,keys:null}}},7652(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.argsOrArgArray=void 0;var n=Array.isArray;t.argsOrArgArray=function(e){return 1===e.length&&n(e[0])?e[0]:e}},4830(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.arrRemove=void 0,t.arrRemove=function(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}},9619(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createErrorClass=void 0,t.createErrorClass=function(e){var t=e(function(e){Error.call(e),e.stack=(new Error).stack});return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}},5810(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createObject=void 0,t.createObject=function(e,t){return e.reduce(function(e,n,r){return e[n]=t[r],e},{})}},2688(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.captureError=t.errorContext=void 0;var r=n(3728),i=null;t.errorContext=function(e){if(r.config.useDeprecatedSynchronousErrorHandling){var t=!i;if(t&&(i={errorThrown:!1,error:null}),e(),t){var n=i,o=n.errorThrown,s=n.error;if(i=null,o)throw s}}else e()},t.captureError=function(e){r.config.useDeprecatedSynchronousErrorHandling&&i&&(i.errorThrown=!0,i.error=e)}},8619(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.executeSchedule=void 0,t.executeSchedule=function(e,t,n,r,i){void 0===r&&(r=0),void 0===i&&(i=!1);var o=t.schedule(function(){n(),i?e.add(this.schedule(null,r)):this.unsubscribe()},r);if(e.add(o),!i)return o}},7699(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.identity=void 0,t.identity=function(e){return e}},4975(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isArrayLike=void 0,t.isArrayLike=function(e){return e&&"number"==typeof e.length&&"function"!=typeof e}},8263(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isAsyncIterable=void 0;var r=n(281);t.isAsyncIterable=function(e){return Symbol.asyncIterator&&r.isFunction(null==e?void 0:e[Symbol.asyncIterator])}},5345(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isValidDate=void 0,t.isValidDate=function(e){return e instanceof Date&&!isNaN(e)}},281(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isFunction=void 0,t.isFunction=function(e){return"function"==typeof e}},629(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isInteropObservable=void 0;var r=n(2884),i=n(281);t.isInteropObservable=function(e){return i.isFunction(e[r.observable])}},2187(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isIterable=void 0;var r=n(4891),i=n(281);t.isIterable=function(e){return i.isFunction(null==e?void 0:e[r.iterator])}},2560(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isObservable=void 0;var r=n(8051),i=n(281);t.isObservable=function(e){return!!e&&(e instanceof r.Observable||i.isFunction(e.lift)&&i.isFunction(e.subscribe))}},7552(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isPromise=void 0;var r=n(281);t.isPromise=function(e){return r.isFunction(null==e?void 0:e.then)}},5462(e,t,n){"use strict";var r=this&&this.__generator||function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},i=this&&this.__await||function(e){return this instanceof i?(this.v=e,this):new i(e)},o=this&&this.__asyncGenerator||function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,o=n.apply(e,t||[]),s=[];return r={},a("next"),a("throw"),a("return"),r[Symbol.asyncIterator]=function(){return this},r;function a(e){o[e]&&(r[e]=function(t){return new Promise(function(n,r){s.push([e,t,n,r])>1||c(e,t)})})}function c(e,t){try{(n=o[e](t)).value instanceof i?Promise.resolve(n.value.v).then(u,l):h(s[0][2],n)}catch(e){h(s[0][3],e)}var n}function u(e){c("next",e)}function l(e){c("throw",e)}function h(e,t){e(t),s.shift(),s.length&&c(s[0][0],s[0][1])}};Object.defineProperty(t,"__esModule",{value:!0}),t.isReadableStreamLike=t.readableStreamLikeToAsyncGenerator=void 0;var s=n(281);t.readableStreamLikeToAsyncGenerator=function(e){return o(this,arguments,function(){var t,n,o;return r(this,function(r){switch(r.label){case 0:t=e.getReader(),r.label=1;case 1:r.trys.push([1,,9,10]),r.label=2;case 2:return[4,i(t.read())];case 3:return n=r.sent(),o=n.value,n.done?[4,i(void 0)]:[3,5];case 4:return[2,r.sent()];case 5:return[4,i(o)];case 6:return[4,r.sent()];case 7:return r.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}})})},t.isReadableStreamLike=function(e){return s.isFunction(null==e?void 0:e.getReader)}},8596(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isScheduler=void 0;var r=n(281);t.isScheduler=function(e){return e&&r.isFunction(e.schedule)}},5212(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.operate=t.hasLift=void 0;var r=n(281);function i(e){return r.isFunction(null==e?void 0:e.lift)}t.hasLift=i,t.operate=function(e){return function(t){if(i(t))return t.lift(function(t){try{return e(t,this)}catch(e){this.error(e)}});throw new TypeError("Unable to lift unknown Observable type")}}},3916(e,t,n){"use strict";var r=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var n=0,r=t.length,i=e.length;n<r;n++,i++)e[i]=t[n];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.mapOneOrManyArgs=void 0;var o=n(6872),s=Array.isArray;t.mapOneOrManyArgs=function(e){return o.map(function(t){return function(e,t){return s(t)?e.apply(void 0,i([],r(t))):e(t)}(e,t)})}},5717(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.noop=void 0,t.noop=function(){}},4120(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.not=void 0,t.not=function(e,t){return function(n,r){return!e.call(t,n,r)}}},1898(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pipeFromArray=t.pipe=void 0;var r=n(7699);function i(e){return 0===e.length?r.identity:1===e.length?e[0]:function(t){return e.reduce(function(e,t){return t(e)},t)}}t.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return i(e)},t.pipeFromArray=i},2980(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.reportUnhandledError=void 0;var r=n(3728),i=n(4808);t.reportUnhandledError=function(e){i.timeoutProvider.setTimeout(function(){var t=r.config.onUnhandledError;if(!t)throw e;t(e)})}},6297(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createInvalidObservableTypeError=void 0,t.createInvalidObservableTypeError=function(e){return new TypeError("You provided "+(null!==e&&"object"==typeof e?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}},2794(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mergeAll=t.merge=t.max=t.materialize=t.mapTo=t.map=t.last=t.isEmpty=t.ignoreElements=t.groupBy=t.first=t.findIndex=t.find=t.finalize=t.filter=t.expand=t.exhaustMap=t.exhaustAll=t.exhaust=t.every=t.endWith=t.elementAt=t.distinctUntilKeyChanged=t.distinctUntilChanged=t.distinct=t.dematerialize=t.delayWhen=t.delay=t.defaultIfEmpty=t.debounceTime=t.debounce=t.count=t.connect=t.concatWith=t.concatMapTo=t.concatMap=t.concatAll=t.concat=t.combineLatestWith=t.combineLatest=t.combineLatestAll=t.combineAll=t.catchError=t.bufferWhen=t.bufferToggle=t.bufferTime=t.bufferCount=t.buffer=t.auditTime=t.audit=void 0,t.timeInterval=t.throwIfEmpty=t.throttleTime=t.throttle=t.tap=t.takeWhile=t.takeUntil=t.takeLast=t.take=t.switchScan=t.switchMapTo=t.switchMap=t.switchAll=t.subscribeOn=t.startWith=t.skipWhile=t.skipUntil=t.skipLast=t.skip=t.single=t.shareReplay=t.share=t.sequenceEqual=t.scan=t.sampleTime=t.sample=t.refCount=t.retryWhen=t.retry=t.repeatWhen=t.repeat=t.reduce=t.raceWith=t.race=t.publishReplay=t.publishLast=t.publishBehavior=t.publish=t.pluck=t.partition=t.pairwise=t.onErrorResumeNext=t.observeOn=t.multicast=t.min=t.mergeWith=t.mergeScan=t.mergeMapTo=t.mergeMap=t.flatMap=void 0,t.zipWith=t.zipAll=t.zip=t.withLatestFrom=t.windowWhen=t.windowToggle=t.windowTime=t.windowCount=t.window=t.toArray=t.timestamp=t.timeoutWith=t.timeout=void 0;var r=n(8877);Object.defineProperty(t,"audit",{enumerable:!0,get:function(){return r.audit}});var i=n(1608);Object.defineProperty(t,"auditTime",{enumerable:!0,get:function(){return i.auditTime}});var o=n(706);Object.defineProperty(t,"buffer",{enumerable:!0,get:function(){return o.buffer}});var s=n(9287);Object.defineProperty(t,"bufferCount",{enumerable:!0,get:function(){return s.bufferCount}});var a=n(1719);Object.defineProperty(t,"bufferTime",{enumerable:!0,get:function(){return a.bufferTime}});var c=n(1778);Object.defineProperty(t,"bufferToggle",{enumerable:!0,get:function(){return c.bufferToggle}});var u=n(6606);Object.defineProperty(t,"bufferWhen",{enumerable:!0,get:function(){return u.bufferWhen}});var l=n(2719);Object.defineProperty(t,"catchError",{enumerable:!0,get:function(){return l.catchError}});var h=n(9244);Object.defineProperty(t,"combineAll",{enumerable:!0,get:function(){return h.combineAll}});var d=n(7933);Object.defineProperty(t,"combineLatestAll",{enumerable:!0,get:function(){return d.combineLatestAll}});var f=n(4948);Object.defineProperty(t,"combineLatest",{enumerable:!0,get:function(){return f.combineLatest}});var p=n(2044);Object.defineProperty(t,"combineLatestWith",{enumerable:!0,get:function(){return p.combineLatestWith}});var m=n(6328);Object.defineProperty(t,"concat",{enumerable:!0,get:function(){return m.concat}});var g=n(201);Object.defineProperty(t,"concatAll",{enumerable:!0,get:function(){return g.concatAll}});var y=n(9512);Object.defineProperty(t,"concatMap",{enumerable:!0,get:function(){return y.concatMap}});var v=n(9913);Object.defineProperty(t,"concatMapTo",{enumerable:!0,get:function(){return v.concatMapTo}});var b=n(8032);Object.defineProperty(t,"concatWith",{enumerable:!0,get:function(){return b.concatWith}});var _=n(7812);Object.defineProperty(t,"connect",{enumerable:!0,get:function(){return _.connect}});var w=n(8589);Object.defineProperty(t,"count",{enumerable:!0,get:function(){return w.count}});var I=n(3143);Object.defineProperty(t,"debounce",{enumerable:!0,get:function(){return I.debounce}});var E=n(1762);Object.defineProperty(t,"debounceTime",{enumerable:!0,get:function(){return E.debounceTime}});var T=n(8799);Object.defineProperty(t,"defaultIfEmpty",{enumerable:!0,get:function(){return T.defaultIfEmpty}});var S=n(5797);Object.defineProperty(t,"delay",{enumerable:!0,get:function(){return S.delay}});var A=n(2885);Object.defineProperty(t,"delayWhen",{enumerable:!0,get:function(){return A.delayWhen}});var O=n(9818);Object.defineProperty(t,"dematerialize",{enumerable:!0,get:function(){return O.dematerialize}});var P=n(7876);Object.defineProperty(t,"distinct",{enumerable:!0,get:function(){return P.distinct}});var C=n(9663);Object.defineProperty(t,"distinctUntilChanged",{enumerable:!0,get:function(){return C.distinctUntilChanged}});var R=n(6035);Object.defineProperty(t,"distinctUntilKeyChanged",{enumerable:!0,get:function(){return R.distinctUntilKeyChanged}});var k=n(1279);Object.defineProperty(t,"elementAt",{enumerable:!0,get:function(){return k.elementAt}});var N=n(6791);Object.defineProperty(t,"endWith",{enumerable:!0,get:function(){return N.endWith}});var x=n(1361);Object.defineProperty(t,"every",{enumerable:!0,get:function(){return x.every}});var D=n(1464);Object.defineProperty(t,"exhaust",{enumerable:!0,get:function(){return D.exhaust}});var M=n(7977);Object.defineProperty(t,"exhaustAll",{enumerable:!0,get:function(){return M.exhaustAll}});var L=n(6632);Object.defineProperty(t,"exhaustMap",{enumerable:!0,get:function(){return L.exhaustMap}});var j=n(5544);Object.defineProperty(t,"expand",{enumerable:!0,get:function(){return j.expand}});var F=n(5934);Object.defineProperty(t,"filter",{enumerable:!0,get:function(){return F.filter}});var V=n(7802);Object.defineProperty(t,"finalize",{enumerable:!0,get:function(){return V.finalize}});var U=n(8183);Object.defineProperty(t,"find",{enumerable:!0,get:function(){return U.find}});var q=n(9035);Object.defineProperty(t,"findIndex",{enumerable:!0,get:function(){return q.findIndex}});var B=n(9980);Object.defineProperty(t,"first",{enumerable:!0,get:function(){return B.first}});var z=n(5128);Object.defineProperty(t,"groupBy",{enumerable:!0,get:function(){return z.groupBy}});var W=n(2959);Object.defineProperty(t,"ignoreElements",{enumerable:!0,get:function(){return W.ignoreElements}});var G=n(9915);Object.defineProperty(t,"isEmpty",{enumerable:!0,get:function(){return G.isEmpty}});var K=n(2568);Object.defineProperty(t,"last",{enumerable:!0,get:function(){return K.last}});var $=n(6872);Object.defineProperty(t,"map",{enumerable:!0,get:function(){return $.map}});var H=n(3337);Object.defineProperty(t,"mapTo",{enumerable:!0,get:function(){return H.mapTo}});var Q=n(5019);Object.defineProperty(t,"materialize",{enumerable:!0,get:function(){return Q.materialize}});var J=n(96);Object.defineProperty(t,"max",{enumerable:!0,get:function(){return J.max}});var Y=n(9330);Object.defineProperty(t,"merge",{enumerable:!0,get:function(){return Y.merge}});var X=n(8087);Object.defineProperty(t,"mergeAll",{enumerable:!0,get:function(){return X.mergeAll}});var Z=n(4613);Object.defineProperty(t,"flatMap",{enumerable:!0,get:function(){return Z.flatMap}});var ee=n(7478);Object.defineProperty(t,"mergeMap",{enumerable:!0,get:function(){return ee.mergeMap}});var te=n(6075);Object.defineProperty(t,"mergeMapTo",{enumerable:!0,get:function(){return te.mergeMapTo}});var ne=n(6707);Object.defineProperty(t,"mergeScan",{enumerable:!0,get:function(){return ne.mergeScan}});var re=n(9694);Object.defineProperty(t,"mergeWith",{enumerable:!0,get:function(){return re.mergeWith}});var ie=n(142);Object.defineProperty(t,"min",{enumerable:!0,get:function(){return ie.min}});var oe=n(8464);Object.defineProperty(t,"multicast",{enumerable:!0,get:function(){return oe.multicast}});var se=n(2071);Object.defineProperty(t,"observeOn",{enumerable:!0,get:function(){return se.observeOn}});var ae=n(5513);Object.defineProperty(t,"onErrorResumeNext",{enumerable:!0,get:function(){return ae.onErrorResumeNext}});var ce=n(6744);Object.defineProperty(t,"pairwise",{enumerable:!0,get:function(){return ce.pairwise}});var ue=n(9516);Object.defineProperty(t,"partition",{enumerable:!0,get:function(){return ue.partition}});var le=n(6355);Object.defineProperty(t,"pluck",{enumerable:!0,get:function(){return le.pluck}});var he=n(3197);Object.defineProperty(t,"publish",{enumerable:!0,get:function(){return he.publish}});var de=n(2955);Object.defineProperty(t,"publishBehavior",{enumerable:!0,get:function(){return de.publishBehavior}});var fe=n(6569);Object.defineProperty(t,"publishLast",{enumerable:!0,get:function(){return fe.publishLast}});var pe=n(8710);Object.defineProperty(t,"publishReplay",{enumerable:!0,get:function(){return pe.publishReplay}});var me=n(6081);Object.defineProperty(t,"race",{enumerable:!0,get:function(){return me.race}});var ge=n(6677);Object.defineProperty(t,"raceWith",{enumerable:!0,get:function(){return ge.raceWith}});var ye=n(2070);Object.defineProperty(t,"reduce",{enumerable:!0,get:function(){return ye.reduce}});var ve=n(6131);Object.defineProperty(t,"repeat",{enumerable:!0,get:function(){return ve.repeat}});var be=n(2139);Object.defineProperty(t,"repeatWhen",{enumerable:!0,get:function(){return be.repeatWhen}});var _e=n(3352);Object.defineProperty(t,"retry",{enumerable:!0,get:function(){return _e.retry}});var we=n(3956);Object.defineProperty(t,"retryWhen",{enumerable:!0,get:function(){return we.retryWhen}});var Ie=n(9224);Object.defineProperty(t,"refCount",{enumerable:!0,get:function(){return Ie.refCount}});var Ee=n(3434);Object.defineProperty(t,"sample",{enumerable:!0,get:function(){return Ee.sample}});var Te=n(4143);Object.defineProperty(t,"sampleTime",{enumerable:!0,get:function(){return Te.sampleTime}});var Se=n(5565);Object.defineProperty(t,"scan",{enumerable:!0,get:function(){return Se.scan}});var Ae=n(3929);Object.defineProperty(t,"sequenceEqual",{enumerable:!0,get:function(){return Ae.sequenceEqual}});var Oe=n(3405);Object.defineProperty(t,"share",{enumerable:!0,get:function(){return Oe.share}});var Pe=n(7782);Object.defineProperty(t,"shareReplay",{enumerable:!0,get:function(){return Pe.shareReplay}});var Ce=n(5440);Object.defineProperty(t,"single",{enumerable:!0,get:function(){return Ce.single}});var Re=n(3079);Object.defineProperty(t,"skip",{enumerable:!0,get:function(){return Re.skip}});var ke=n(2359);Object.defineProperty(t,"skipLast",{enumerable:!0,get:function(){return ke.skipLast}});var Ne=n(7783);Object.defineProperty(t,"skipUntil",{enumerable:!0,get:function(){return Ne.skipUntil}});var xe=n(5774);Object.defineProperty(t,"skipWhile",{enumerable:!0,get:function(){return xe.skipWhile}});var De=n(9054);Object.defineProperty(t,"startWith",{enumerable:!0,get:function(){return De.startWith}});var Me=n(5455);Object.defineProperty(t,"subscribeOn",{enumerable:!0,get:function(){return Me.subscribeOn}});var Le=n(6201);Object.defineProperty(t,"switchAll",{enumerable:!0,get:function(){return Le.switchAll}});var je=n(680);Object.defineProperty(t,"switchMap",{enumerable:!0,get:function(){return je.switchMap}});var Fe=n(761);Object.defineProperty(t,"switchMapTo",{enumerable:!0,get:function(){return Fe.switchMapTo}});var Ve=n(8461);Object.defineProperty(t,"switchScan",{enumerable:!0,get:function(){return Ve.switchScan}});var Ue=n(4383);Object.defineProperty(t,"take",{enumerable:!0,get:function(){return Ue.take}});var qe=n(5279);Object.defineProperty(t,"takeLast",{enumerable:!0,get:function(){return qe.takeLast}});var Be=n(6911);Object.defineProperty(t,"takeUntil",{enumerable:!0,get:function(){return Be.takeUntil}});var ze=n(598);Object.defineProperty(t,"takeWhile",{enumerable:!0,get:function(){return ze.takeWhile}});var We=n(7400);Object.defineProperty(t,"tap",{enumerable:!0,get:function(){return We.tap}});var Ge=n(4880);Object.defineProperty(t,"throttle",{enumerable:!0,get:function(){return Ge.throttle}});var Ke=n(7245);Object.defineProperty(t,"throttleTime",{enumerable:!0,get:function(){return Ke.throttleTime}});var $e=n(632);Object.defineProperty(t,"throwIfEmpty",{enumerable:!0,get:function(){return $e.throwIfEmpty}});var He=n(2508);Object.defineProperty(t,"timeInterval",{enumerable:!0,get:function(){return He.timeInterval}});var Qe=n(1713);Object.defineProperty(t,"timeout",{enumerable:!0,get:function(){return Qe.timeout}});var Je=n(597);Object.defineProperty(t,"timeoutWith",{enumerable:!0,get:function(){return Je.timeoutWith}});var Ye=n(3866);Object.defineProperty(t,"timestamp",{enumerable:!0,get:function(){return Ye.timestamp}});var Xe=n(3484);Object.defineProperty(t,"toArray",{enumerable:!0,get:function(){return Xe.toArray}});var Ze=n(8072);Object.defineProperty(t,"window",{enumerable:!0,get:function(){return Ze.window}});var et=n(2893);Object.defineProperty(t,"windowCount",{enumerable:!0,get:function(){return et.windowCount}});var tt=n(37);Object.defineProperty(t,"windowTime",{enumerable:!0,get:function(){return tt.windowTime}});var nt=n(8996);Object.defineProperty(t,"windowToggle",{enumerable:!0,get:function(){return nt.windowToggle}});var rt=n(5156);Object.defineProperty(t,"windowWhen",{enumerable:!0,get:function(){return rt.windowWhen}});var it=n(6975);Object.defineProperty(t,"withLatestFrom",{enumerable:!0,get:function(){return it.withLatestFrom}});var ot=n(6749);Object.defineProperty(t,"zip",{enumerable:!0,get:function(){return ot.zip}});var st=n(5362);Object.defineProperty(t,"zipAll",{enumerable:!0,get:function(){return st.zipAll}});var at=n(6977);Object.defineProperty(t,"zipWith",{enumerable:!0,get:function(){return at.zipWith}})},6032(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)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 o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}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 s=n(1278),a=o(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,o,s;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!==(o=e.accessTokenDecoded.exp)&&void 0!==o?o:0,(null!==(s=e.refreshTokenDecoded.exp)&&void 0!==s?s: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,s.jwtDecode)(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(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,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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(s,a)}c((r=r.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)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 o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}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 a=s(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,s,a;return o(this,function(o){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&&(s=(0,c.base64Encode)(JSON.stringify((0,c.sort)(n.data))),delete n.data,i.data=s,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}})})},e}();t.default=d},7514(e,t){"use strict";var n=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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(s,a)}c((r=r.apply(e,t||[])).next())})},r=this&&this.__generator||function(e,t){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)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 o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}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,o,s,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(o="".concat(n,"?").concat(new URLSearchParams(i).toString()),this.cache.has(o)){if((s=this.cache.get(o)).expiry>t)return this.enableLogs&&console.log("rio-cache: Serving from cache:",o),this.cache.delete(o),this.cache.set(o,s),[2,s.data];this.cache.delete(o)}if(this.pendingRequests.has(o))return this.enableLogs&&console.log("rio-cache: Waiting for in-progress request: ".concat(o)),[2,this.pendingRequests.get(o)];a=this.getAndCache(o,e),this.pendingRequests.set(o,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(o),[7];case 4:return[2]}})})},e.prototype.getAndCache=function(e,t){return n(this,void 0,void 0,function(){var n,i,o,s,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(),o={status:i.status,statusText:i.statusText,headers:i.headers,data:i.data},s=i.headers["cache-control"],a=i.headers.age,c=i.headers.date,u=null==s?void 0:s.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("rio-cache: Evicted cache entry: ".concat(v))),this.cache.set(e,{data:o,expiry:n+y}),this.enableLogs&&console.log("rio-cache: Caching response with remaining freshness: ".concat(y/1e3,"s - ").concat(e))):this.enableLogs&&console.log("rio-cache: No remaining freshness not caching: ".concat(e)),[2,o]}})})},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(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]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)},s=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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(s,a)}c((r=r.apply(e,t||[])).next())})},a=this&&this.__generator||function(e,t){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)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 o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}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(9364),f=n(2794),p=c(n(6032)),m=c(n(5281)),g=n(1613);o(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,r;return(null===(n=e.clientConfig)||void 0===n?void 0:n.projectId)===t.projectId&&(null===(r=e.clientConfig)||void 0===r?void 0:r.instanceKey)===t.instanceKey});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 s(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 s(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 s(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 s(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 s(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 s(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 s(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 s(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 s(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 s(n,void 0,void 0,function(){var t,n,i;return a(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),t=this.getCosEndpoint(e),[4,this.http.call(this.clientConfig.projectId,t.path,t.params)];case 1:return n=o.sent(),[2,r(r({},e),{response:n})];case 2:throw(i=o.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 s(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,o,s,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!==(o=d.platform)&&void 0!==o?o:null===(s=this.clientConfig)||void 0===s?void 0:s.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 o=i[r];o.startsWith("__")&&delete n[o]}e.next(n)})},e.prototype.getFirebaseState=function(e){return s(this,void 0,void 0,function(){var t,n,r,i,o=this;return a(this,function(s){switch(s.label){case 0:return t=this.clientConfig.projectId,[4,this.auth.getCurrentUser()];case 1:return n=s.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(s){if(!o.listeners["".concat(t,"_").concat(e.classId,"_").concat(e.instanceId,"_role")]){var a=o.getFirebaseListener(i.role,"/projects/".concat(t,"/classes/").concat(e.classId,"/instances/").concat(e.instanceId,"/roleState"),n.identity);r.push(a),o.listeners["".concat(t,"_").concat(e.classId,"_").concat(e.instanceId,"_role")]=a}return i.role.subscribe(s)}},user:{queue:i.user,subscribe:function(s){if(!o.listeners["".concat(t,"_").concat(e.classId,"_").concat(e.instanceId,"_user")]){var a=o.getFirebaseListener(i.user,"/projects/".concat(t,"/classes/").concat(e.classId,"/instances/").concat(e.instanceId,"/userState"),n.userId);r.push(a),o.listeners["".concat(t,"_").concat(e.classId,"_").concat(e.instanceId,"_user")]=a}return i.user.subscribe(s)}},public:{queue:i.public,subscribe:function(n){if(!o.listeners["".concat(t,"_").concat(e.classId,"_").concat(e.instanceId,"_public")]){var s=o.getFirebaseListener(i.public,"/projects/".concat(t,"/classes/").concat(e.classId,"/instances"),e.instanceId);r.push(s),o.listeners["".concat(t,"_").concat(e.classId,"_").concat(e.instanceId,"_public")]=s}return i.public.subscribe(n)}}},unsubscribers:r}]}})})},e.prototype.clearCloudObjects=function(){return s(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,o,s;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===(s=null===(o=e.state)||void 0===o?void 0:o.public.queue)||void 0===s||s.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 s(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 s(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 s(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 s(this,void 0,void 0,function(){var t,n,i,o,c,u,l,h,d,f,p,m,y,v,b,_,w,I,E,T,S,A,O=this;return a(this,function(P){switch(P.label){case 0:if(!this.initialized)throw new Error("Retter SDK not initialized.");return n={},e.instanceId&&e.useLocal?[4,this.sendToActionQueue({action:g.RetterActions.EMPTY})]:[3,2];case 1:return P.sent(),[3,4];case 2:return[4,this.sendToActionQueue({action:g.RetterActions.COS_INSTANCE,data:e})];case 3:i=P.sent(),o=i.data,c=i.headers,t=o,e.instanceId=t.instanceId,n=null!=c?c:{},P.label=4;case 4:return(u=this.cloudObjects.find(function(t){return t.config.classId===e.classId&&t.config.instanceId===e.instanceId}))?[2,{call:u.call,state:u.state,listInstances:u.listInstances,getState:u.getState,init:null!==(v=null==t?void 0:t.init)&&void 0!==v?v:{},get:null!==(b=null==t?void 0:t.get)&&void 0!==b?b:{},methods:null!==(_=null==t?void 0:t.methods)&&void 0!==_?_:[],instanceId:e.instanceId,response:null!==(w=null==t?void 0:t.response)&&void 0!==w?w:null,headers:n,isNewInstance:!1}]:[4,this.getFirebaseState(e)];case 5:return l=P.sent(),h=l.state,d=l.unsubscribers,f=function(t){return s(O,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,f(t)];case 5:return[2,i.sent()];case 6:throw n;case 7:return[3,8];case 8:return[2]}})})},p=function(t){return s(O,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()]}})})},m=function(t){return s(O,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]}})})},y={call:f,state:h,getState:p,listInstances:m,init:null!==(I=null==t?void 0:t.init)&&void 0!==I?I:{},get:null!==(E=null==t?void 0:t.get)&&void 0!==E?E:{},methods:null!==(T=null==t?void 0:t.methods)&&void 0!==T?T:[],response:null!==(S=null==t?void 0:t.response)&&void 0!==S?S:null,headers:n,instanceId:e.instanceId,isNewInstance:null!==(A=null==t?void 0:t.newInstance)&&void 0!==A&&A},this.cloudObjects.push(r(r({},y),{config:e,unsubscribers:d})),[2,y]}})})},e.prototype.makeStaticCall=function(e){return s(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,o;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"}(o||(t.Runtime=o={}))},6425(e,t,n){"use strict";function r(e,t){return function(){return e.apply(t,arguments)}}const{toString:i}=Object.prototype,{getPrototypeOf:o}=Object,{iterator:s,toStringTag:a}=Symbol,c=(u=Object.create(null),e=>{const t=i.call(e);return u[t]||(u[t]=t.slice(8,-1).toLowerCase())});var u;const l=e=>(e=e.toLowerCase(),t=>c(t)===e),h=e=>t=>typeof t===e,{isArray:d}=Array,f=h("undefined");function p(e){return null!==e&&!f(e)&&null!==e.constructor&&!f(e.constructor)&&y(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const m=l("ArrayBuffer"),g=h("string"),y=h("function"),v=h("number"),b=e=>null!==e&&"object"==typeof e,_=e=>{if("object"!==c(e))return!1;const t=o(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||a in e||s in e)},w=l("Date"),I=l("File"),E=l("Blob"),T=l("FileList"),S="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==n.g?n.g:{},A=void 0!==S.FormData?S.FormData:void 0,O=l("URLSearchParams"),[P,C,R,k]=["ReadableStream","Request","Response","Headers"].map(l);function N(e,t,{allOwnKeys:n=!1}={}){if(null==e)return;let r,i;if("object"!=typeof e&&(e=[e]),d(e))for(r=0,i=e.length;r<i;r++)t.call(null,e[r],r,e);else{if(p(e))return;const i=n?Object.getOwnPropertyNames(e):Object.keys(e),o=i.length;let s;for(r=0;r<o;r++)s=i[r],t.call(null,e[s],s,e)}}function x(e,t){if(p(e))return null;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 D="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:n.g,M=e=>!f(e)&&e!==D,L=(j="undefined"!=typeof Uint8Array&&o(Uint8Array),e=>j&&e instanceof j);var j;const F=l("HTMLFormElement"),V=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),U=l("RegExp"),q=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};N(n,(n,i)=>{let o;!1!==(o=t(n,i,e))&&(r[i]=o||n)}),Object.defineProperties(e,r)},B=l("AsyncFunction"),z=(W="function"==typeof setImmediate,G=y(D.postMessage),W?setImmediate:G?(K=`axios@${Math.random()}`,$=[],D.addEventListener("message",({source:e,data:t})=>{e===D&&t===K&&$.length&&$.shift()()},!1),e=>{$.push(e),D.postMessage(K,"*")}):e=>setTimeout(e));var W,G,K,$;const H="undefined"!=typeof queueMicrotask?queueMicrotask.bind(D):"undefined"!=typeof process&&process.nextTick||z;var Q={isArray:d,isArrayBuffer:m,isBuffer:p,isFormData:e=>{let t;return e&&(A&&e instanceof A||y(e.append)&&("formdata"===(t=c(e))||"object"===t&&y(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&m(e.buffer),t},isString:g,isNumber:v,isBoolean:e=>!0===e||!1===e,isObject:b,isPlainObject:_,isEmptyObject:e=>{if(!b(e)||p(e))return!1;try{return 0===Object.keys(e).length&&Object.getPrototypeOf(e)===Object.prototype}catch(e){return!1}},isReadableStream:P,isRequest:C,isResponse:R,isHeaders:k,isUndefined:f,isDate:w,isFile:I,isReactNativeBlob:e=>!(!e||void 0===e.uri),isReactNative:e=>e&&void 0!==e.getParts,isBlob:E,isRegExp:U,isFunction:y,isStream:e=>b(e)&&y(e.pipe),isURLSearchParams:O,isTypedArray:L,isFileList:T,forEach:N,merge:function e(){const{caseless:t,skipUndefined:n}=M(this)&&this||{},r={},i=(i,o)=>{if("__proto__"===o||"constructor"===o||"prototype"===o)return;const s=t&&x(r,o)||o;_(r[s])&&_(i)?r[s]=e(r[s],i):_(i)?r[s]=e({},i):d(i)?r[s]=i.slice():n&&f(i)||(r[s]=i)};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&N(arguments[e],i);return r},extend:(e,t,n,{allOwnKeys:i}={})=>(N(t,(t,i)=>{n&&y(t)?Object.defineProperty(e,i,{value:r(t,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,i,{value:t,writable:!0,enumerable:!0,configurable:!0})},{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),Object.defineProperty(e.prototype,"constructor",{value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},toFlatObject:(e,t,n,r)=>{let i,s,a;const c={};if(t=t||{},null==e)return t;do{for(i=Object.getOwnPropertyNames(e),s=i.length;s-- >0;)a=i[s],r&&!r(a,e,t)||c[a]||(t[a]=e[a],c[a]=!0);e=!1!==n&&o(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:c,kindOfTest:l,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(d(e))return e;let t=e.length;if(!v(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},forEachEntry:(e,t)=>{const n=(e&&e[s]).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:F,hasOwnProperty:V,hasOwnProp:V,reduceDescriptors:q,freezeMethods:e=>{q(e,(t,n)=>{if(y(e)&&-1!==["arguments","caller","callee"].indexOf(n))return!1;const r=e[n];y(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 d(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:D,isContextDefined:M,isSpecCompliantForm:function(e){return!!(e&&y(e.append)&&"FormData"===e[a]&&e[s])},toJSONObject:e=>{const t=new Array(10),n=(e,r)=>{if(b(e)){if(t.indexOf(e)>=0)return;if(p(e))return e;if(!("toJSON"in e)){t[r]=e;const i=d(e)?[]:{};return N(e,(e,t)=>{const o=n(e,r+1);!f(o)&&(i[t]=o)}),t[r]=void 0,i}}return e};return n(e,0)},isAsyncFn:B,isThenable:e=>e&&(b(e)||y(e))&&y(e.then)&&y(e.catch),setImmediate:z,asap:H,isIterable:e=>null!=e&&y(e[s])};class J extends Error{static from(e,t,n,r,i,o){const s=new J(e.message,t||e.code,n,r,i);return s.cause=e,s.name=e.name,null!=e.status&&null==s.status&&(s.status=e.status),o&&Object.assign(s,o),s}constructor(e,t,n,r,i){super(e),Object.defineProperty(this,"message",{value:e,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),i&&(this.response=i,this.status=i.status)}toJSON(){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:Q.toJSONObject(this.config),code:this.code,status:this.status}}}J.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE",J.ERR_BAD_OPTION="ERR_BAD_OPTION",J.ECONNABORTED="ECONNABORTED",J.ETIMEDOUT="ETIMEDOUT",J.ERR_NETWORK="ERR_NETWORK",J.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS",J.ERR_DEPRECATED="ERR_DEPRECATED",J.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE",J.ERR_BAD_REQUEST="ERR_BAD_REQUEST",J.ERR_CANCELED="ERR_CANCELED",J.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT",J.ERR_INVALID_URL="ERR_INVALID_URL";var Y=J;function X(e){return Q.isPlainObject(e)||Q.isArray(e)}function Z(e){return Q.endsWith(e,"[]")?e.slice(0,-2):e}function ee(e,t,n){return e?e.concat(t).map(function(e,t){return e=Z(e),!n&&t?"["+e+"]":e}).join(n?".":""):t}const te=Q.toFlatObject(Q,{},null,function(e){return/^is[A-Z]/.test(e)});function ne(e,t,n){if(!Q.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const r=(n=Q.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!Q.isUndefined(t[e])})).metaTokens,i=n.visitor||u,o=n.dots,s=n.indexes,a=(n.Blob||"undefined"!=typeof Blob&&Blob)&&Q.isSpecCompliantForm(t);if(!Q.isFunction(i))throw new TypeError("visitor must be a function");function c(e){if(null===e)return"";if(Q.isDate(e))return e.toISOString();if(Q.isBoolean(e))return e.toString();if(!a&&Q.isBlob(e))throw new Y("Blob is not supported. Use a Buffer instead.");return Q.isArrayBuffer(e)||Q.isTypedArray(e)?a&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function u(e,n,i){let a=e;if(Q.isReactNative(t)&&Q.isReactNativeBlob(e))return t.append(ee(i,n,o),c(e)),!1;if(e&&!i&&"object"==typeof e)if(Q.endsWith(n,"{}"))n=r?n:n.slice(0,-2),e=JSON.stringify(e);else if(Q.isArray(e)&&function(e){return Q.isArray(e)&&!e.some(X)}(e)||(Q.isFileList(e)||Q.endsWith(n,"[]"))&&(a=Q.toArray(e)))return n=Z(n),a.forEach(function(e,r){!Q.isUndefined(e)&&null!==e&&t.append(!0===s?ee([n],r,o):null===s?n:n+"[]",c(e))}),!1;return!!X(e)||(t.append(ee(i,n,o),c(e)),!1)}const l=[],h=Object.assign(te,{defaultVisitor:u,convertValue:c,isVisitable:X});if(!Q.isObject(e))throw new TypeError("data must be an object");return function e(n,r){if(!Q.isUndefined(n)){if(-1!==l.indexOf(n))throw Error("Circular reference detected in "+r.join("."));l.push(n),Q.forEach(n,function(n,o){!0===(!(Q.isUndefined(n)||null===n)&&i.call(t,n,Q.isString(o)?o.trim():o,r,h))&&e(n,r?r.concat(o):[o])}),l.pop()}}(e),t}function re(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(e){return t[e]})}function ie(e,t){this._pairs=[],e&&ne(e,this,t)}const oe=ie.prototype;function se(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function ae(e,t,n){if(!t)return e;const r=n&&n.encode||se,i=Q.isFunction(n)?{serialize:n}:n,o=i&&i.serialize;let s;if(s=o?o(t,i):Q.isURLSearchParams(t)?t.toString():new ie(t,i).toString(r),s){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+s}return e}oe.append=function(e,t){this._pairs.push([e,t])},oe.toString=function(e){const t=e?function(t){return e.call(this,t,re)}:re;return this._pairs.map(function(e){return t(e[0])+"="+t(e[1])},"").join("&")};var ce=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){Q.forEach(this.handlers,function(t){null!==t&&e(t)})}},ue={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},le={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:ie,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const he="undefined"!=typeof window&&"undefined"!=typeof document,de="object"==typeof navigator&&navigator||void 0,fe=he&&(!de||["ReactNative","NativeScript","NS"].indexOf(de.product)<0),pe="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,me=he&&window.location.href||"http://localhost";var ge={...Object.freeze({__proto__:null,hasBrowserEnv:he,hasStandardBrowserWebWorkerEnv:pe,hasStandardBrowserEnv:fe,navigator:de,origin:me}),...le};function ye(e){function t(e,n,r,i){let o=e[i++];if("__proto__"===o)return!0;const s=Number.isFinite(+o),a=i>=e.length;return o=!o&&Q.isArray(r)?r.length:o,a?(Q.hasOwnProp(r,o)?r[o]=[r[o],n]:r[o]=n,!s):(r[o]&&Q.isObject(r[o])||(r[o]=[]),t(e,n,r[o],i)&&Q.isArray(r[o])&&(r[o]=function(e){const t={},n=Object.keys(e);let r;const i=n.length;let o;for(r=0;r<i;r++)o=n[r],t[o]=e[o];return t}(r[o])),!s)}if(Q.isFormData(e)&&Q.isFunction(e.entries)){const n={};return Q.forEachEntry(e,(e,r)=>{t(function(e){return Q.matchAll(/\w+|\[(\w*)]/g,e).map(e=>"[]"===e[0]?"":e[1]||e[0])}(e),r,n,0)}),n}return null}const ve={transitional:ue,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",r=n.indexOf("application/json")>-1,i=Q.isObject(e);if(i&&Q.isHTMLForm(e)&&(e=new FormData(e)),Q.isFormData(e))return r?JSON.stringify(ye(e)):e;if(Q.isArrayBuffer(e)||Q.isBuffer(e)||Q.isStream(e)||Q.isFile(e)||Q.isBlob(e)||Q.isReadableStream(e))return e;if(Q.isArrayBufferView(e))return e.buffer;if(Q.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let o;if(i){if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return ne(e,new ge.classes.URLSearchParams,{visitor:function(e,t,n,r){return ge.isNode&&Q.isBuffer(e)?(this.append(t,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)},...t})}(e,this.formSerializer).toString();if((o=Q.isFileList(e))||n.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return ne(o?{"files[]":e}:e,t&&new t,this.formSerializer)}}return i||r?(t.setContentType("application/json",!1),function(e){if(Q.isString(e))try{return(0,JSON.parse)(e),Q.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(0,JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||ve.transitional,n=t&&t.forcedJSONParsing,r="json"===this.responseType;if(Q.isResponse(e)||Q.isReadableStream(e))return e;if(e&&Q.isString(e)&&(n&&!this.responseType||r)){const n=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e,this.parseReviver)}catch(e){if(n){if("SyntaxError"===e.name)throw Y.from(e,Y.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:ge.classes.FormData,Blob:ge.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Q.forEach(["delete","get","head","post","put","patch"],e=>{ve.headers[e]={}});var be=ve;const _e=Q.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 Ie(e){return e&&String(e).trim().toLowerCase()}function Ee(e){return!1===e||null==e?e:Q.isArray(e)?e.map(Ee):String(e)}function Te(e,t,n,r,i){return Q.isFunction(r)?r.call(this,t,n):(i&&(t=n),Q.isString(t)?Q.isString(r)?-1!==t.indexOf(r):Q.isRegExp(r)?r.test(t):void 0:void 0)}class Se{constructor(e){e&&this.set(e)}set(e,t,n){const r=this;function i(e,t,n){const i=Ie(t);if(!i)throw new Error("header name must be a non-empty string");const o=Q.findKey(r,i);(!o||void 0===r[o]||!0===n||void 0===n&&!1!==r[o])&&(r[o||t]=Ee(e))}const o=(e,t)=>Q.forEach(e,(e,n)=>i(e,n,t));if(Q.isPlainObject(e)||e instanceof this.constructor)o(e,t);else if(Q.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))o((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]&&_e[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(Q.isObject(e)&&Q.isIterable(e)){let n,r,i={};for(const t of e){if(!Q.isArray(t))throw TypeError("Object iterator must return a key-value pair");i[r=t[0]]=(n=i[r])?Q.isArray(n)?[...n,t[1]]:[n,t[1]]:t[1]}o(i,t)}else null!=e&&i(t,e,n);return this}get(e,t){if(e=Ie(e)){const n=Q.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(Q.isFunction(t))return t.call(this,e,n);if(Q.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=Ie(e)){const n=Q.findKey(this,e);return!(!n||void 0===this[n]||t&&!Te(0,this[n],n,t))}return!1}delete(e,t){const n=this;let r=!1;function i(e){if(e=Ie(e)){const i=Q.findKey(n,e);!i||t&&!Te(0,n[i],i,t)||(delete n[i],r=!0)}}return Q.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&&!Te(0,this[i],i,e,!0)||(delete this[i],r=!0)}return r}normalize(e){const t=this,n={};return Q.forEach(this,(r,i)=>{const o=Q.findKey(n,i);if(o)return t[o]=Ee(r),void delete t[i];const s=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}(i):String(i).trim();s!==i&&delete t[i],t[s]=Ee(r),n[s]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return Q.forEach(this,(n,r)=>{null!=n&&!1!==n&&(t[r]=e&&Q.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")}getSetCookie(){return this.get("set-cookie")||[]}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=Ie(e);t[r]||(function(e,t){const n=Q.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 Q.isArray(e)?e.forEach(r):r(e),this}}Se.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Q.reduceDescriptors(Se.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}}),Q.freezeMethods(Se);var Ae=Se;function Oe(e,t){const n=this||be,r=t||n,i=Ae.from(r.headers);let o=r.data;return Q.forEach(e,function(e){o=e.call(n,o,i.normalize(),t?t.status:void 0)}),i.normalize(),o}function Pe(e){return!(!e||!e.__CANCEL__)}var Ce=class extends Y{constructor(e,t,n){super(null==e?"canceled":e,Y.ERR_CANCELED,t,n),this.name="CanceledError",this.__CANCEL__=!0}};function Re(e,t,n){const r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(new Y("Request failed with status code "+n.status,[Y.ERR_BAD_REQUEST,Y.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}const ke=(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,o=0,s=0;return t=void 0!==t?t:1e3,function(a){const c=Date.now(),u=r[s];i||(i=c),n[o]=a,r[o]=c;let l=s,h=0;for(;l!==o;)h+=n[l++],l%=e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),c-i<t)return;const d=u&&c-u;return d?Math.round(1e3*h/d):void 0}}(50,250);return function(n,o){let s,a,c=0,u=1e3/o;const l=(n,o=Date.now())=>{c=o,s=null,a&&(clearTimeout(a),a=null),(n=>{const o=n.loaded,s=n.lengthComputable?n.total:void 0,a=o-r,c=i(a);r=o,e({loaded:o,total:s,progress:s?o/s:void 0,bytes:a,rate:c||void 0,estimated:c&&s&&o<=s?(s-o)/c:void 0,event:n,lengthComputable:null!=s,[t?"download":"upload"]:!0})})(...n)};return[(...e)=>{const t=Date.now(),n=t-c;n>=u?l(e,t):(s=e,a||(a=setTimeout(()=>{a=null,l(s)},u-n)))},()=>s&&l(s)]}(0,n)},Ne=(e,t)=>{const n=null!=e;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},xe=e=>(...t)=>Q.asap(()=>e(...t));var De=ge.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,ge.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(ge.origin),ge.navigator&&/(msie|trident)/i.test(ge.navigator.userAgent)):()=>!0,Me=ge.hasStandardBrowserEnv?{write(e,t,n,r,i,o,s){if("undefined"==typeof document)return;const a=[`${e}=${encodeURIComponent(t)}`];Q.isNumber(n)&&a.push(`expires=${new Date(n).toUTCString()}`),Q.isString(r)&&a.push(`path=${r}`),Q.isString(i)&&a.push(`domain=${i}`),!0===o&&a.push("secure"),Q.isString(s)&&a.push(`SameSite=${s}`),document.cookie=a.join("; ")},read(e){if("undefined"==typeof document)return null;const t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read:()=>null,remove(){}};function Le(e,t,n){let r=!("string"==typeof(i=t)&&/^([a-z][a-z\d+\-.]*:)?\/\//i.test(i));var i;return e&&(r||0==n)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const je=e=>e instanceof Ae?{...e}:e;function Fe(e,t){t=t||{};const n={};function r(e,t,n,r){return Q.isPlainObject(e)&&Q.isPlainObject(t)?Q.merge.call({caseless:r},e,t):Q.isPlainObject(t)?Q.merge({},t):Q.isArray(t)?t.slice():t}function i(e,t,n,i){return Q.isUndefined(t)?Q.isUndefined(e)?void 0:r(void 0,e,0,i):r(e,t,0,i)}function o(e,t){if(!Q.isUndefined(t))return r(void 0,t)}function s(e,t){return Q.isUndefined(t)?Q.isUndefined(e)?void 0:r(void 0,e):r(void 0,t)}function a(n,i,o){return o in t?r(n,i):o in e?r(void 0,n):void 0}const c={url:o,method:o,data:o,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:(e,t,n)=>i(je(e),je(t),0,!0)};return Q.forEach(Object.keys({...e,...t}),function(r){if("__proto__"===r||"constructor"===r||"prototype"===r)return;const o=Q.hasOwnProp(c,r)?c[r]:i,s=o(e[r],t[r],r);Q.isUndefined(s)&&o!==a||(n[r]=s)}),n}var Ve=e=>{const t=Fe({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:i,xsrfCookieName:o,headers:s,auth:a}=t;if(t.headers=s=Ae.from(s),t.url=ae(Le(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&s.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),Q.isFormData(n))if(ge.hasStandardBrowserEnv||ge.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if(Q.isFunction(n.getHeaders)){const e=n.getHeaders(),t=["content-type","content-length"];Object.entries(e).forEach(([e,n])=>{t.includes(e.toLowerCase())&&s.set(e,n)})}if(ge.hasStandardBrowserEnv&&(r&&Q.isFunction(r)&&(r=r(t)),r||!1!==r&&De(t.url))){const e=i&&o&&Me.read(o);e&&s.set(i,e)}return t},Ue="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise(function(t,n){const r=Ve(e);let i=r.data;const o=Ae.from(r.headers).normalize();let s,a,c,u,l,{responseType:h,onUploadProgress:d,onDownloadProgress:f}=r;function p(){u&&u(),l&&l(),r.cancelToken&&r.cancelToken.unsubscribe(s),r.signal&&r.signal.removeEventListener("abort",s)}let m=new XMLHttpRequest;function g(){if(!m)return;const r=Ae.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders());Re(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 Y("Request aborted",Y.ECONNABORTED,e,m)),m=null)},m.onerror=function(t){const r=t&&t.message?t.message:"Network Error",i=new Y(r,Y.ERR_NETWORK,e,m);i.event=t||null,n(i),m=null},m.ontimeout=function(){let t=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const i=r.transitional||ue;r.timeoutErrorMessage&&(t=r.timeoutErrorMessage),n(new Y(t,i.clarifyTimeoutError?Y.ETIMEDOUT:Y.ECONNABORTED,e,m)),m=null},void 0===i&&o.setContentType(null),"setRequestHeader"in m&&Q.forEach(o.toJSON(),function(e,t){m.setRequestHeader(t,e)}),Q.isUndefined(r.withCredentials)||(m.withCredentials=!!r.withCredentials),h&&"json"!==h&&(m.responseType=r.responseType),f&&([c,l]=ke(f,!0),m.addEventListener("progress",c)),d&&m.upload&&([a,u]=ke(d),m.upload.addEventListener("progress",a),m.upload.addEventListener("loadend",u)),(r.cancelToken||r.signal)&&(s=t=>{m&&(n(!t||t.type?new Ce(null,e,m):t),m.abort(),m=null)},r.cancelToken&&r.cancelToken.subscribe(s),r.signal&&(r.signal.aborted?s():r.signal.addEventListener("abort",s)));const y=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(r.url);y&&-1===ge.protocols.indexOf(y)?n(new Y("Unsupported protocol "+y+":",Y.ERR_BAD_REQUEST,e)):m.send(i||null)})},qe=(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,s();const t=e instanceof Error?e:this.reason;r.abort(t instanceof Y?t:new Ce(t instanceof Error?t.message:t))}};let o=t&&setTimeout(()=>{o=null,i(new Y(`timeout of ${t}ms exceeded`,Y.ETIMEDOUT))},t);const s=()=>{e&&(o&&clearTimeout(o),o=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=()=>Q.asap(s),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},ze=(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 o,s=0,a=e=>{o||(o=!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 o=r.byteLength;if(n){let e=s+=o;n(e)}e.enqueue(new Uint8Array(r))}catch(e){throw a(e),e}},cancel:e=>(a(e),i.return())},{highWaterMark:2})},{isFunction:We}=Q,Ge=(({Request:e,Response:t})=>({Request:e,Response:t}))(Q.global),{ReadableStream:Ke,TextEncoder:$e}=Q.global,He=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},Qe=e=>{e=Q.merge.call({skipUndefined:!0},Ge,e);const{fetch:t,Request:n,Response:r}=e,i=t?We(t):"function"==typeof fetch,o=We(n),s=We(r);if(!i)return!1;const a=i&&We(Ke),c=i&&("function"==typeof $e?(u=new $e,e=>u.encode(e)):async e=>new Uint8Array(await new n(e).arrayBuffer()));var u;const l=o&&a&&He(()=>{let e=!1;const t=new n(ge.origin,{body:new Ke,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),h=s&&a&&He(()=>Q.isReadableStream(new r("").body)),d={stream:h&&(e=>e.body)};i&&["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!d[e]&&(d[e]=(t,n)=>{let r=t&&t[e];if(r)return r.call(t);throw new Y(`Response type '${e}' is not supported`,Y.ERR_NOT_SUPPORT,n)})});return async e=>{let{url:i,method:s,data:a,signal:u,cancelToken:f,timeout:p,onDownloadProgress:m,onUploadProgress:g,responseType:y,headers:v,withCredentials:b="same-origin",fetchOptions:_}=Ve(e),w=t||fetch;y=y?(y+"").toLowerCase():"text";let I=qe([u,f&&f.toAbortSignal()],p),E=null;const T=I&&I.unsubscribe&&(()=>{I.unsubscribe()});let S;try{if(g&&l&&"get"!==s&&"head"!==s&&0!==(S=await(async(e,t)=>{const r=Q.toFiniteNumber(e.getContentLength());return null==r?(async e=>{if(null==e)return 0;if(Q.isBlob(e))return e.size;if(Q.isSpecCompliantForm(e)){const t=new n(ge.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return Q.isArrayBufferView(e)||Q.isArrayBuffer(e)?e.byteLength:(Q.isURLSearchParams(e)&&(e+=""),Q.isString(e)?(await c(e)).byteLength:void 0)})(t):r})(v,a))){let e,t=new n(i,{method:"POST",body:a,duplex:"half"});if(Q.isFormData(a)&&(e=t.headers.get("content-type"))&&v.setContentType(e),t.body){const[e,n]=Ne(S,ke(xe(g)));a=ze(t.body,65536,e,n)}}Q.isString(b)||(b=b?"include":"omit");const t=o&&"credentials"in n.prototype,u={..._,signal:I,method:s.toUpperCase(),headers:v.normalize().toJSON(),body:a,duplex:"half",credentials:t?b:void 0};E=o&&new n(i,u);let f=await(o?w(E,_):w(i,u));const p=h&&("stream"===y||"response"===y);if(h&&(m||p&&T)){const e={};["status","statusText","headers"].forEach(t=>{e[t]=f[t]});const t=Q.toFiniteNumber(f.headers.get("content-length")),[n,i]=m&&Ne(t,ke(xe(m),!0))||[];f=new r(ze(f.body,65536,n,()=>{i&&i(),T&&T()}),e)}y=y||"text";let A=await d[Q.findKey(d,y)||"text"](f,e);return!p&&T&&T(),await new Promise((t,n)=>{Re(t,n,{data:A,headers:Ae.from(f.headers),status:f.status,statusText:f.statusText,config:e,request:E})})}catch(t){if(T&&T(),t&&"TypeError"===t.name&&/Load failed|fetch/i.test(t.message))throw Object.assign(new Y("Network Error",Y.ERR_NETWORK,e,E,t&&t.response),{cause:t.cause||t});throw Y.from(t,t&&t.code,e,E,t&&t.response)}}},Je=new Map,Ye=e=>{let t=e&&e.env||{};const{fetch:n,Request:r,Response:i}=t,o=[r,i,n];let s,a,c=o.length,u=Je;for(;c--;)s=o[c],a=u.get(s),void 0===a&&u.set(s,a=c?new Map:Qe(t)),u=a;return a};Ye();const Xe={http:null,xhr:Ue,fetch:{get:Ye}};Q.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=>Q.isFunction(e)||null===e||!1===e;var tt=function(e,t){e=Q.isArray(e)?e:[e];const{length:n}=e;let r,i;const o={};for(let s=0;s<n;s++){let n;if(r=e[s],i=r,!et(r)&&(i=Xe[(n=String(r)).toLowerCase()],void 0===i))throw new Y(`Unknown adapter '${n}'`);if(i&&(Q.isFunction(i)||(i=i.get(t))))break;o[n||"#"+s]=i}if(!i){const e=Object.entries(o).map(([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build"));let t=n?e.length>1?"since :\n"+e.map(Ze).join("\n"):" "+Ze(e[0]):"as no adapter specified";throw new Y("There is no suitable adapter to dispatch the request "+t,"ERR_NOT_SUPPORT")}return i};function nt(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Ce(null,e)}function rt(e){return nt(e),e.headers=Ae.from(e.headers),e.data=Oe.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1),tt(e.adapter||be.adapter,e)(e).then(function(t){return nt(e),t.data=Oe.call(e,e.transformResponse,t),t.headers=Ae.from(t.headers),t},function(t){return Pe(t)||(nt(e),t&&t.response&&(t.response.data=Oe.call(e,e.transformResponse,t.response),t.response.headers=Ae.from(t.response.headers))),Promise.reject(t)})}const it="1.13.6",ot={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{ot[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const st={};ot.transitional=function(e,t,n){function r(e,t){return"[Axios v"+it+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}return(n,i,o)=>{if(!1===e)throw new Y(r(i," has been removed"+(t?" in "+t:"")),Y.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,o)}},ot.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};var at={assertOptions:function(e,t,n){if("object"!=typeof e)throw new Y("options must be an object",Y.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let i=r.length;for(;i-- >0;){const o=r[i],s=t[o];if(s){const t=e[o],n=void 0===t||s(t,o,e);if(!0!==n)throw new Y("option "+o+" must be "+n,Y.ERR_BAD_OPTION_VALUE);continue}if(!0!==n)throw new Y("Unknown option "+o,Y.ERR_BAD_OPTION)}},validators:ot};const ct=at.validators;class ut{constructor(e){this.defaults=e||{},this.interceptors={request:new ce,response:new ce}}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&&at.assertOptions(n,{silentJSONParsing:ct.transitional(ct.boolean),forcedJSONParsing:ct.transitional(ct.boolean),clarifyTimeoutError:ct.transitional(ct.boolean),legacyInterceptorReqResOrdering:ct.transitional(ct.boolean)},!1),null!=r&&(Q.isFunction(r)?t.paramsSerializer={serialize:r}:at.assertOptions(r,{encode:ct.function,serialize:ct.function},!0)),void 0!==t.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),at.assertOptions(t,{baseUrl:ct.spelling("baseURL"),withXsrfToken:ct.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=i&&Q.merge(i.common,i[t.method]);i&&Q.forEach(["delete","get","head","post","put","patch","common"],e=>{delete i[e]}),t.headers=Ae.concat(o,i);const s=[];let a=!0;this.interceptors.request.forEach(function(e){if("function"==typeof e.runWhen&&!1===e.runWhen(t))return;a=a&&e.synchronous;const n=t.transitional||ue;n&&n.legacyInterceptorReqResOrdering?s.unshift(e.fulfilled,e.rejected):s.push(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(...s),e.push(...c),l=e.length,u=Promise.resolve(t);h<l;)u=u.then(e[h++],e[h++]);return u}l=s.length;let d=t;for(;h<l;){const e=s[h++],t=s[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 ae(Le((e=Fe(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}}Q.forEach(["delete","get","head","options"],function(e){ut.prototype[e]=function(t,n){return this.request(Fe(n||{},{method:e,url:t,data:(n||{}).data}))}}),Q.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}))}}ut.prototype[e]=t(),ut.prototype[e+"Form"]=t(!0)});var lt=ut;class ht{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 Ce(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 ht(function(t){e=t}),cancel:e}}}var dt=ht;const ft={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,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(ft).forEach(([e,t])=>{ft[t]=e});var pt=ft;const mt=function e(t){const n=new lt(t),i=r(lt.prototype.request,n);return Q.extend(i,lt.prototype,n,{allOwnKeys:!0}),Q.extend(i,n,null,{allOwnKeys:!0}),i.create=function(n){return e(Fe(t,n))},i}(be);mt.Axios=lt,mt.CanceledError=Ce,mt.CancelToken=dt,mt.isCancel=Pe,mt.VERSION=it,mt.toFormData=ne,mt.AxiosError=Y,mt.Cancel=mt.CanceledError,mt.all=function(e){return Promise.all(e)},mt.spread=function(e){return function(t){return e.apply(null,t)}},mt.isAxiosError=function(e){return Q.isObject(e)&&!0===e.isAxiosError},mt.mergeConfig=Fe,mt.AxiosHeaders=Ae,mt.formToJSON=e=>ye(Q.isHTMLForm(e)?new FormData(e):e),mt.getAdapter=tt,mt.HttpStatusCode=pt,mt.default=mt,e.exports=mt},1278(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.jwtDecode=t.InvalidTokenError=void 0;class n extends Error{}t.InvalidTokenError=n,n.prototype.name="InvalidTokenError",t.jwtDecode=function(e,t){if("string"!=typeof e)throw new n("Invalid token specified: must be a string");t||(t={});const r=!0===t.header?0:1,i=e.split(".")[r];if("string"!=typeof i)throw new n(`Invalid token specified: missing part #${r+1}`);let o;try{o=function(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return function(e){return decodeURIComponent(atob(e).replace(/(.)/g,(e,t)=>{let n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n}))}(t)}catch(e){return atob(t)}}(i)}catch(e){throw new n(`Invalid token specified: invalid base64 for part #${r+1} (${e.message})`)}try{return JSON.parse(o)}catch(e){throw new n(`Invalid token specified: invalid json for part #${r+1} (${e.message})`)}}},6148(e,t,n){"use strict";let r,i;n.r(t),n.d(t,{deleteDB:()=>m,openDB:()=>p,unwrap:()=>f,wrap:()=>d});const o=new WeakMap,s=new WeakMap,a=new WeakMap,c=new WeakMap,u=new WeakMap;let l={get(e,t,n){if(e instanceof IDBTransaction){if("done"===t)return s.get(e);if("objectStoreNames"===t)return e.objectStoreNames||a.get(e);if("store"===t)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return d(e[t])},set:(e,t,n)=>(e[t]=n,!0),has:(e,t)=>e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e};function h(e){return"function"==typeof e?(t=e)!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?(i||(i=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(t)?function(...e){return t.apply(f(this),e),d(o.get(this))}:function(...e){return d(t.apply(f(this),e))}:function(e,...n){const r=t.call(f(this),e,...n);return a.set(r,e.sort?e.sort():[e]),d(r)}:(e instanceof IDBTransaction&&function(e){if(s.has(e))return;const t=new Promise((t,n)=>{const r=()=>{e.removeEventListener("complete",i),e.removeEventListener("error",o),e.removeEventListener("abort",o)},i=()=>{t(),r()},o=()=>{n(e.error||new DOMException("AbortError","AbortError")),r()};e.addEventListener("complete",i),e.addEventListener("error",o),e.addEventListener("abort",o)});s.set(e,t)}(e),n=e,(r||(r=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])).some(e=>n instanceof e)?new Proxy(e,l):e);var t,n}function d(e){if(e instanceof IDBRequest)return function(e){const t=new Promise((t,n)=>{const r=()=>{e.removeEventListener("success",i),e.removeEventListener("error",o)},i=()=>{t(d(e.result)),r()},o=()=>{n(e.error),r()};e.addEventListener("success",i),e.addEventListener("error",o)});return t.then(t=>{t instanceof IDBCursor&&o.set(t,e)}).catch(()=>{}),u.set(t,e),t}(e);if(c.has(e))return c.get(e);const t=h(e);return t!==e&&(c.set(e,t),u.set(t,e)),t}const f=e=>u.get(e);function p(e,t,{blocked:n,upgrade:r,blocking:i,terminated:o}={}){const s=indexedDB.open(e,t),a=d(s);return r&&s.addEventListener("upgradeneeded",e=>{r(d(s.result),e.oldVersion,e.newVersion,d(s.transaction),e)}),n&&s.addEventListener("blocked",e=>n(e.oldVersion,e.newVersion,e)),a.then(e=>{o&&e.addEventListener("close",()=>o()),i&&e.addEventListener("versionchange",e=>i(e.oldVersion,e.newVersion,e))}).catch(()=>{}),a}function m(e,{blocked:t}={}){const n=indexedDB.deleteDatabase(e);return t&&n.addEventListener("blocked",e=>t(e.oldVersion,e)),d(n).then(()=>{})}const g=["get","getKey","getAll","getAllKeys","count"],y=["put","add","delete","clear"],v=new Map;function b(e,t){if(!(e instanceof IDBDatabase)||t in e||"string"!=typeof t)return;if(v.get(t))return v.get(t);const n=t.replace(/FromIndex$/,""),r=t!==n,i=y.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!i&&!g.includes(n))return;const o=async function(e,...t){const o=this.transaction(e,i?"readwrite":"readonly");let s=o.store;return r&&(s=s.index(t.shift())),(await Promise.all([s[n](...t),i&&o.done]))[0]};return v.set(t,o),o}var _;_=l,l={..._,get:(e,t,n)=>b(e,t)||_.get(e,t,n),has:(e,t)=>!!b(e,t)||_.has(e,t)}}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return e[r].call(o.exports,o,o.exports,n),o.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})());