📄 firebase-compat.js
/home/palash/git/site/node_modules/firebase/firebase-compat.js
Language: js • Lines: 27
((e,t)=>{"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).firebase=t()})(this,function(){let n=()=>{},a={NODE_CLIENT:!1,NODE_ADMIN:!1,SDK_VERSION:"${JSCORE_VERSION}"},g=function(e,t){if(!e)throw V(t)},V=function(e){return new Error("Firebase Database ("+a.SDK_VERSION+") INTERNAL ASSERT FAILED: "+e)},o=function(t){var r=[];let n=0;for(let i=0;i<t.length;i++){let e=t.charCodeAt(i);e<128?r[n++]=e:(e<2048?r[n++]=e>>6|192:(55296==(64512&e)&&i+1<t.length&&56320==(64512&t.charCodeAt(i+1))?(e=65536+((1023&e)<<10)+(1023&t.charCodeAt(++i)),r[n++]=e>>18|240,r[n++]=e>>12&63|128):r[n++]=e>>12|224,r[n++]=e>>6&63|128),r[n++]=63&e|128)}return r},B={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(r,e){if(!Array.isArray(r))throw Error("encodeByteArray takes an array as a parameter");this.init_();var n=e?this.byteToCharMapWebSafe_:this.byteToCharMap_,i=[];for(let h=0;h<r.length;h+=3){var s=r[h],a=h+1<r.length,o=a?r[h+1]:0,l=h+2<r.length,u=l?r[h+2]:0;let e=(15&o)<<2|u>>6,t=63&u;l||(t=64,a)||(e=64),i.push(n[s>>2],n[(3&s)<<4|o>>4],n[e],n[t])}return i.join("")},encodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?btoa(e):this.encodeByteArray(o(e),t)},decodeString(r,n){if(this.HAS_NATIVE_SUPPORT&&!n)return atob(r);{var i=this.decodeStringToByteArray(r,n);var s=[];let e=0,t=0;for(;e<i.length;){var a,o,l,u=i[e++];u<128?s[t++]=String.fromCharCode(u):191<u&&u<224?(a=i[e++],s[t++]=String.fromCharCode((31&u)<<6|63&a)):239<u&&u<365?(a=((7&u)<<18|(63&i[e++])<<12|(63&i[e++])<<6|63&i[e++])-65536,s[t++]=String.fromCharCode(55296+(a>>10)),s[t++]=String.fromCharCode(56320+(1023&a))):(o=i[e++],l=i[e++],s[t++]=String.fromCharCode((15&u)<<12|(63&o)<<6|63&l))}return s.join("");return}},decodeStringToByteArray(e,t){this.init_();var r=t?this.charToByteMapWebSafe_:this.charToByteMap_,n=[];for(let l=0;l<e.length;){var i=r[e.charAt(l++)],s=l<e.length?r[e.charAt(l)]:0,a=++l<e.length?r[e.charAt(l)]:64,o=++l<e.length?r[e.charAt(l)]:64;if(++l,null==i||null==s||null==a||null==o)throw new q;n.push(i<<2|s>>4),64!==a&&(n.push(s<<4&240|a>>2),64!==o)&&n.push(a<<6&192|o)}return n},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)>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(e)]=e,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(e)]=e)}}};class q extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}let j=function(e){var t=o(e);return B.encodeByteArray(t,!0)},z=function(e){return j(e).replace(/\./g,"")},H=function(e){try{return B.decodeString(e,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};function K(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(var r in t)t.hasOwnProperty(r)&&"__proto__"!==r&&(e[r]=K(e[r],t[r]));return e}function G(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("Unable to locate global object.")}let W=()=>G().__FIREBASE_DEFAULTS__,$=()=>{var e;return"undefined"!=typeof process&&void 0!==process.env&&(e=process.env.__FIREBASE_DEFAULTS__)?JSON.parse(e):void 0},Y=()=>{if("undefined"!=typeof document){let e;try{e=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch(e){return}var t=e&&H(e[1]);return t&&JSON.parse(t)}},Q=()=>{try{return n()||W()||$()||Y()}catch(e){console.info("Unable to get __FIREBASE_DEFAULTS__ due to: "+e)}},J=()=>Q()?.config;var p,X;class Z{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}wrapCallback(r){return(e,t)=>{e?this.reject(e):this.resolve(t),"function"==typeof r&&(this.promise.catch(()=>{}),1===r.length?r(e):r(e,t))}}}function ee(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.');var r=t||"demo-project",n=e.iat||0,i=e.sub||e.user_id;if(i)return r={iss:"https://securetoken.google.com/"+r,aud:r,iat:n,exp:n+3600,auth_time:n,sub:i,user_id:i,firebase:{sign_in_provider:"custom",identities:{}},...e},[z(JSON.stringify({alg:"none",type:"JWT"})),z(JSON.stringify(r)),""].join(".");throw new Error("mockUserToken must contain 'sub' or 'user_id' field!")}function te(){return"undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:""}function re(){return"undefined"!=typeof window&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(te())}function ne(){var e=Q()?.forceEnvironment;if("node"===e)return!0;if("browser"===e)return!1;try{return"[object process]"===Object.prototype.toString.call(global.process)}catch(e){return!1}}function ie(){return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope}function se(){var e="object"==typeof chrome?chrome.runtime:"object"==typeof browser?browser.runtime:void 0;return"object"==typeof e&&void 0!==e.id}function ae(){return"object"==typeof navigator&&"ReactNative"===navigator.product}function oe(){var e=te();return 0<=e.indexOf("MSIE ")||0<=e.indexOf("Trident/")}function le(){return!0===a.NODE_ADMIN}function ue(){return!ne()&&navigator.userAgent&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}function he(){return!ne()&&navigator.userAgent&&(navigator.userAgent.includes("Safari")||navigator.userAgent.includes("WebKit"))&&!navigator.userAgent.includes("Chrome")}function ce(){try{return"object"==typeof indexedDB}catch(e){return!1}}function de(){return new Promise((n,i)=>{try{let e=!0,t="validate-browser-context-for-indexeddb-analytics-module",r=self.indexedDB.open(t);r.onsuccess=()=>{r.result.close(),e||self.indexedDB.deleteDatabase(t),n(!0)},r.onupgradeneeded=()=>{e=!1},r.onerror=()=>{i(r.error?.message||"")}}catch(e){i(e)}})}function pe(){return!("undefined"==typeof navigator||!navigator.cookieEnabled)}class fe extends Error{constructor(e,t,r){super(t),this.code=e,this.customData=r,this.name="FirebaseError",Object.setPrototypeOf(this,fe.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,ge.prototype.create)}}class ge{constructor(e,t,r){this.service=e,this.serviceName=t,this.errors=r}create(e,...t){var n,r=t[0]||{},i=this.service+"/"+e,s=this.errors[e],s=s?(n=r,s.replace(me,(e,t)=>{var r=n[t];return null!=r?String(r):`<${t}?>`})):"Error",s=this.serviceName+`: ${s} (${i}).`;return new fe(i,s,r)}}let me=/\{\$([^}]+)}/g;function ve(e){return JSON.parse(e)}function _e(e){return JSON.stringify(e)}let ye=function(e){let t={},r={},n={},i="";try{var s=e.split(".");t=ve(H(s[0])||""),r=ve(H(s[1])||""),i=s[2],n=r.d||{},delete r.d}catch(e){}return{header:t,claims:r,data:n,signature:i}};function we(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function be(e,t){if(Object.prototype.hasOwnProperty.call(e,t))return e[t]}function Te(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}function Ee(e,t,r){var n,i={};for(n in e)Object.prototype.hasOwnProperty.call(e,n)&&(i[n]=t.call(r,e[n],n,e));return i}function Ie(e,t){if(e!==t){var r,n,i=Object.keys(e),s=Object.keys(t);for(r of i){if(!s.includes(r))return!1;var a=e[r],o=t[r];if(Ce(a)&&Ce(o)){if(!Ie(a,o))return!1}else if(a!==o)return!1}for(n of s)if(!i.includes(n))return!1}return!0}function Ce(e){return null!==e&&"object"==typeof e}function Se(e){let t=[];for(let[r,n]of Object.entries(e))Array.isArray(n)?n.forEach(e=>{t.push(encodeURIComponent(r)+"="+encodeURIComponent(e))}):t.push(encodeURIComponent(r)+"="+encodeURIComponent(n));return t.length?"&"+t.join("&"):""}function ke(e){let n={};return e.replace(/^\?/,"").split("&").forEach(e=>{var t,r;e&&([t,r]=e.split("="),n[decodeURIComponent(t)]=decodeURIComponent(r))}),n}function Ae(e){var t,r=e.indexOf("?");return r?(t=e.indexOf("#",r),e.substring(r,0<t?t:void 0)):""}class Ne{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_(r,n){n=n||0;var i=this.W_;if("string"==typeof r)for(let e=0;e<16;e++)i[e]=r.charCodeAt(n)<<24|r.charCodeAt(n+1)<<16|r.charCodeAt(n+2)<<8|r.charCodeAt(n+3),n+=4;else for(let t=0;t<16;t++)i[t]=r[n]<<24|r[n+1]<<16|r[n+2]<<8|r[n+3],n+=4;for(let d=16;d<80;d++){var e=i[d-3]^i[d-8]^i[d-14]^i[d-16];i[d]=4294967295&(e<<1|e>>>31)}let t=this.chain_[0],s=this.chain_[1],a=this.chain_[2],o=this.chain_[3],l=this.chain_[4],u,h;for(let p=0;p<80;p++){h=p<40?p<20?(u=o^s&(a^o),1518500249):(u=s^a^o,1859775393):p<60?(u=s&a|o&(s|a),2400959708):(u=s^a^o,3395469782);var c=(t<<5|t>>>27)+u+l+h+i[p]&4294967295;l=o,o=a,a=4294967295&(s<<30|s>>>2),s=t,t=c}this.chain_[0]=this.chain_[0]+t&4294967295,this.chain_[1]=this.chain_[1]+s&4294967295,this.chain_[2]=this.chain_[2]+a&4294967295,this.chain_[3]=this.chain_[3]+o&4294967295,this.chain_[4]=this.chain_[4]+l&4294967295}update(r,n){if(null!=r){var i=(n=void 0===n?r.length:n)-this.blockSize;let e=0;var s=this.buf_;let t=this.inbuf_;for(;e<n;){if(0===t)for(;e<=i;)this.compress_(r,e),e+=this.blockSize;if("string"==typeof r){for(;e<n;)if(s[t]=r.charCodeAt(e),++t,++e,t===this.blockSize){this.compress_(s),t=0;break}}else for(;e<n;)if(s[t]=r[e],++t,++e,t===this.blockSize){this.compress_(s),t=0;break}}this.inbuf_=t,this.total_+=n}}digest(){var t=[];let e=8*this.total_;this.inbuf_<56?this.update(this.pad_,56-this.inbuf_):this.update(this.pad_,this.blockSize-(this.inbuf_-56));for(let n=this.blockSize-1;56<=n;n--)this.buf_[n]=255&e,e/=256;this.compress_(this.buf_);let r=0;for(let i=0;i<5;i++)for(let e=24;0<=e;e-=8)t[r]=this.chain_[i]>>e&255,++r;return t}}function Re(e,t){var r=new Pe(e,t);return r.subscribe.bind(r)}class Pe{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(t){this.forEachObserver(e=>{e.next(t)})}error(t){this.forEachObserver(e=>{e.error(t)}),this.close(t)}complete(){this.forEachObserver(e=>{e.complete()}),this.close()}subscribe(e,t,r){let n;if(void 0===e&&void 0===t&&void 0===r)throw new Error("Missing Observer.");void 0===(n=((e,t)=>{if("object"==typeof e&&null!==e)for(var r of t)if(r in e&&"function"==typeof e[r])return 1})(e,["next","error","complete"])?e:{next:e,error:t,complete:r}).next&&(n.next=xe),void 0===n.error&&(n.error=xe),void 0===n.complete&&(n.complete=xe);var i=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(()=>{try{this.finalError?n.error(this.finalError):n.complete()}catch(e){}}),this.observers.push(n),i}unsubscribeOne(e){void 0!==this.observers&&void 0!==this.observers[e]&&(delete this.observers[e],--this.observerCount,0===this.observerCount)&&void 0!==this.onNoObservers&&this.onNoObservers(this)}forEachObserver(t){if(!this.finalized)for(let e=0;e<this.observers.length;e++)this.sendOne(e,t)}sendOne(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 xe(){}function l(e,t,r,n){let i;var s;if(n<t?i="at least "+t:r<n&&(i=0===r?"none":"no more than "+r),i)throw s=e+" failed: Was called with "+n+(1===n?" argument.":" arguments.")+" Expects "+i+".",new Error(s)}function De(e,t){return e+` failed: ${t} argument `}function Oe(e,t,r,n){if((!n||r)&&"function"!=typeof r)throw new Error(De(e,t)+"must be a valid function.")}function Le(e,t,r,n){if((!n||r)&&("object"!=typeof r||null===r))throw new Error(De(e,t)+"must be a valid context object.")}let Me=function(t){var r,n,i=[];let s=0;for(let a=0;a<t.length;a++){let e=t.charCodeAt(a);55296<=e&&e<=56319&&(r=e-55296,a++,g(a<t.length,"Surrogate pair missing trail surrogate."),n=t.charCodeAt(a)-56320,e=65536+(r<<10)+n),e<128?i[s++]=e:(e<2048?i[s++]=e>>6|192:(e<65536?i[s++]=e>>12|224:(i[s++]=e>>18|240,i[s++]=e>>12&63|128),i[s++]=e>>6&63|128),i[s++]=63&e|128)}return i},Fe=function(e){let t=0;for(let n=0;n<e.length;n++){var r=e.charCodeAt(n);r<128?t++:r<2048?t+=2:55296<=r&&r<=56319?(t+=4,n++):t+=3}return t},Ue=1e3,Ve=2,Be=144e5,qe=.5;function je(e,t=Ue,r=Ve){var n=t*Math.pow(r,e),i=Math.round(qe*n*(Math.random()-.5)*2);return Math.min(Be,n+i)}function w(e){return e&&e._delegate?e._delegate:e}function ze(e){try{return(e.startsWith("http://")||e.startsWith("https://")?new URL(e).hostname:e).endsWith(".cloudworkstations.dev")}catch{return!1}}async function He(e){return(await fetch(e,{credentials:"include"})).ok}class h{constructor(e,t,r){this.name=e,this.instanceFactory=t,this.type=r,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}}let Ke="[DEFAULT]";class Ge{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){var t=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(t)){var r=new Z;if(this.instancesDeferred.set(t,r),this.isInitialized(t)||this.shouldAutoInitialize())try{var n=this.getOrInitializeService({instanceIdentifier:t});n&&r.resolve(n)}catch(e){}}return this.instancesDeferred.get(t).promise}getImmediate(e){var t=this.normalizeInstanceIdentifier(e?.identifier),r=e?.optional??!1;if(!this.isInitialized(t)&&!this.shouldAutoInitialize()){if(r)return null;throw Error(`Service ${this.name} is not available`)}try{return this.getOrInitializeService({instanceIdentifier:t})}catch(e){if(r)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("EAGER"===e.instantiationMode)try{this.getOrInitializeService({instanceIdentifier:Ke})}catch(e){}for(var[t,r]of this.instancesDeferred.entries()){t=this.normalizeInstanceIdentifier(t);try{var n=this.getOrInitializeService({instanceIdentifier:t});r.resolve(n)}catch(e){}}}}clearInstance(e=Ke){this.instancesDeferred.delete(e),this.instancesOptions.delete(e),this.instances.delete(e)}async delete(){var 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=Ke){return this.instances.has(e)}getOptions(e=Ke){return this.instancesOptions.get(e)||{}}initialize(e={}){var{options:t={}}=e,r=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(r))throw Error(this.name+`(${r}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);var n,i,s=this.getOrInitializeService({instanceIdentifier:r,options:t});for([n,i]of this.instancesDeferred.entries())r===this.normalizeInstanceIdentifier(n)&&i.resolve(s);return s}onInit(e,t){var r=this.normalizeInstanceIdentifier(t);let n=this.onInitCallbacks.get(r)??new Set;n.add(e),this.onInitCallbacks.set(r,n);var i=this.instances.get(r);return i&&e(i,r),()=>{n.delete(e)}}invokeOnInitCallbacks(e,t){var r=this.onInitCallbacks.get(t);if(r)for(var n of r)try{n(e,t)}catch{}}getOrInitializeService({instanceIdentifier:e,options:t={}}){let r=this.instances.get(e);if(!r&&this.component&&(r=this.component.instanceFactory(this.container,{instanceIdentifier:(n=e)===Ke?void 0:n,options:t}),this.instances.set(e,r),this.instancesOptions.set(e,t),this.invokeOnInitCallbacks(r,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,r)}catch{}var n;return r||null}normalizeInstanceIdentifier(e=Ke){return!this.component||this.component.multipleInstances?e:Ke}shouldAutoInitialize(){return!!this.component&&"EXPLICIT"!==this.component.instantiationMode}}class We{constructor(e){this.name=e,this.providers=new Map}addComponent(e){var 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){var t;return this.providers.has(e)?this.providers.get(e):(t=new Ge(e,this),this.providers.set(e,t),t)}getProviders(){return Array.from(this.providers.values())}}let $e=[],Ye=((t=p=p||{})[t.DEBUG=0]="DEBUG",t[t.VERBOSE=1]="VERBOSE",t[t.INFO=2]="INFO",t[t.WARN=3]="WARN",t[t.ERROR=4]="ERROR",t[t.SILENT=5]="SILENT",{debug:p.DEBUG,verbose:p.VERBOSE,info:p.INFO,warn:p.WARN,error:p.ERROR,silent:p.SILENT}),Qe=p.INFO,Je={[p.DEBUG]:"log",[p.VERBOSE]:"log",[p.INFO]:"info",[p.WARN]:"warn",[p.ERROR]:"error"},Xe=(e,t,...r)=>{if(!(t<e.logLevel)){var n=(new Date).toISOString(),i=Je[t];if(!i)throw new Error(`Attempted to log a message with an invalid logType (value: ${t})`);console[i](`[${n}]  ${e.name}:`,...r)}};class Ze{constructor(e){this.name=e,this._logLevel=Qe,this._logHandler=Xe,this._userLogHandler=null,$e.push(this)}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in p))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel="string"==typeof e?Ye[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,p.DEBUG,...e),this._logHandler(this,p.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,p.VERBOSE,...e),this._logHandler(this,p.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,p.INFO,...e),this._logHandler(this,p.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,p.WARN,...e),this._logHandler(this,p.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,p.ERROR,...e),this._logHandler(this,p.ERROR,...e)}}let et=(t,e)=>e.some(e=>t instanceof e),tt,rt;let nt=new WeakMap,it=new WeakMap,st=new WeakMap,at=new WeakMap,ot=new WeakMap;let lt={get(e,t,r){if(e instanceof IDBTransaction){if("done"===t)return it.get(e);if("objectStoreNames"===t)return e.objectStoreNames||st.get(e);if("store"===t)return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return ct(e[t])},set(e,t,r){return e[t]=r,!0},has(e,t){return e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e}};function ut(n){return n!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?(rt=rt||[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey]).includes(n)?function(...e){return n.apply(dt(this),e),ct(nt.get(this))}:function(...e){return ct(n.apply(dt(this),e))}:function(e,...t){var r=n.call(dt(this),e,...t);return st.set(r,e.sort?e.sort():[e]),ct(r)}}function ht(e){var s,t;return"function"==typeof e?ut(e):(e instanceof IDBTransaction&&(s=e,it.has(s)||(t=new Promise((e,t)=>{let r=()=>{s.removeEventListener("complete",n),s.removeEventListener("error",i),s.removeEventListener("abort",i)},n=()=>{e(),r()},i=()=>{t(s.error||new DOMException("AbortError","AbortError")),r()};s.addEventListener("complete",n),s.addEventListener("error",i),s.addEventListener("abort",i)}),it.set(s,t))),et(e,tt=tt||[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])?new Proxy(e,lt):e)}function ct(e){var s,t;return e instanceof IDBRequest?(s=e,(t=new Promise((e,t)=>{let r=()=>{s.removeEventListener("success",n),s.removeEventListener("error",i)},n=()=>{e(ct(s.result)),r()},i=()=>{t(s.error),r()};s.addEventListener("success",n),s.addEventListener("error",i)})).then(e=>{e instanceof IDBCursor&&nt.set(e,s)}).catch(()=>{}),ot.set(t,s),t):at.has(e)?at.get(e):((t=ht(e))!==e&&(at.set(e,t),ot.set(t,e)),t)}let dt=e=>ot.get(e);function pt(e,t,{blocked:r,upgrade:n,blocking:i,terminated:s}={}){let a=indexedDB.open(e,t);var o=ct(a);return n&&a.addEventListener("upgradeneeded",e=>{n(ct(a.result),e.oldVersion,e.newVersion,ct(a.transaction),e)}),r&&a.addEventListener("blocked",e=>r(e.oldVersion,e.newVersion,e)),o.then(e=>{s&&e.addEventListener("close",()=>s()),i&&e.addEventListener("versionchange",e=>i(e.oldVersion,e.newVersion,e))}).catch(()=>{}),o}function ft(e,{blocked:t}={}){var r=indexedDB.deleteDatabase(e);return t&&r.addEventListener("blocked",e=>t(e.oldVersion,e)),ct(r).then(()=>{})}let gt=["get","getKey","getAll","getAllKeys","count"],mt=["put","add","delete","clear"],vt=new Map;function _t(e,t){if(e instanceof IDBDatabase&&!(t in e)&&"string"==typeof t){if(vt.get(t))return vt.get(t);let i=t.replace(/FromIndex$/,""),s=t!==i,a=mt.includes(i);var r;return i in(s?IDBIndex:IDBObjectStore).prototype&&(a||gt.includes(i))?(r=async function(e,...t){var r=this.transaction(e,a?"readwrite":"readonly");let n=r.store;return s&&(n=n.index(t.shift())),(await Promise.all([n[i](...t),a&&r.done]))[0]},vt.set(t,r),r):void 0}}lt={...X=lt,get:(e,t,r)=>_t(e,t)||X.get(e,t,r),has:(e,t)=>!!_t(e,t)||X.has(e,t)};class yt{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(e=>{var t;return"VERSION"===e.getComponent()?.type?(t=e.getImmediate()).library+"/"+t.version:null}).filter(e=>e).join(" ")}}let wt="@firebase/app",bt="0.15.0",Tt=new Ze("@firebase/app");let Et="[DEFAULT]",It={[wt]:"fire-core","@firebase/app-compat":"fire-core-compat","@firebase/analytics":"fire-analytics","@firebase/analytics-compat":"fire-analytics-compat","@firebase/app-check":"fire-app-check","@firebase/app-check-compat":"fire-app-check-compat","@firebase/auth":"fire-auth","@firebase/auth-compat":"fire-auth-compat","@firebase/database":"fire-rtdb","@firebase/data-connect":"fire-data-connect","@firebase/database-compat":"fire-rtdb-compat","@firebase/functions":"fire-fn","@firebase/functions-compat":"fire-fn-compat","@firebase/installations":"fire-iid","@firebase/installations-compat":"fire-iid-compat","@firebase/messaging":"fire-fcm","@firebase/messaging-compat":"fire-fcm-compat","@firebase/performance":"fire-perf","@firebase/performance-compat":"fire-perf-compat","@firebase/remote-config":"fire-rc","@firebase/remote-config-compat":"fire-rc-compat","@firebase/storage":"fire-gcs","@firebase/storage-compat":"fire-gcs-compat","@firebase/firestore":"fire-fst","@firebase/firestore-compat":"fire-fst-compat","@firebase/ai":"fire-vertex","fire-js":"fire-js",firebase:"fire-js-all"},Ct=new Map,St=new Map,kt=new Map;function At(t,r){try{t.container.addComponent(r)}catch(e){Tt.debug(`Component ${r.name} failed to register with FirebaseApp `+t.name,e)}}function Nt(e,t){e.container.addOrOverwriteComponent(t)}function Rt(e){var t,r,n=e.name;if(kt.has(n))return Tt.debug(`There were multiple attempts to register component ${n}.`),!1;kt.set(n,e);for(t of Ct.values())At(t,e);for(r of St.values())At(r,e);return!0}function Pt(e,t){var r=e.container.getProvider("heartbeat").getImmediate({optional:!0});return r&&r.triggerHeartbeat(),e.container.getProvider(t)}function xt(e){return void 0!==e.options}function Dt(e){return!xt(e)&&("authIdToken"in e||"appCheckToken"in e||"releaseOnDeref"in e||"automaticDataCollectionEnabled"in e)}function Ot(e){return null!=e&&void 0!==e.settings}let Lt=new ge("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 Mt{constructor(e,t,r){this._isDeleted=!1,this._options={...e},this._config={...t},this._name=t.name,this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled,this._container=r,this.container.addComponent(new h("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 Lt.create("app-deleted",{appName:this._name})}}function Ft(e,t){var r=H(e.split(".")[1]);null===r?console.error(`FirebaseServerApp ${t} is invalid: second part could not be parsed.`):void 0===JSON.parse(r).exp?console.error(`FirebaseServerApp ${t} is invalid: expiration claim could not be parsed`):1e3*JSON.parse(r).exp-(new Date).getTime()<=0&&console.error(`FirebaseServerApp ${t} is invalid: the token has expired.`)}class Ut extends Mt{constructor(e,t,r,n){var i=void 0===t.automaticDataCollectionEnabled||t.automaticDataCollectionEnabled,s={name:r,automaticDataCollectionEnabled:i};void 0!==e.apiKey?super(e,s,n):super(e.options,s,n),this._serverConfig={automaticDataCollectionEnabled:i,...t},this._serverConfig.authIdToken&&Ft(this._serverConfig.authIdToken,"authIdToken"),this._serverConfig.appCheckToken&&Ft(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,zt(wt,bt,"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(){jt(this)}get settings(){return this.checkDestroyed(),this._serverConfig}checkDestroyed(){if(this.isDeleted)throw Lt.create("server-app-deleted")}}let Vt="12.15.0";function Bt(e,t={}){let r=e;if("object"!=typeof t){let e=t;t={name:e}}var n={name:Et,automaticDataCollectionEnabled:!0,...t};let i=n.name;if("string"!=typeof i||!i)throw Lt.create("bad-app-name",{appName:String(i)});if(!(r=r||J()))throw Lt.create("no-options");var s=Ct.get(i);if(s){if(Ie(r,s.options)&&Ie(n,s.config))return s;throw Lt.create("duplicate-app",{appName:i})}var a,o=new We(i);for(a of kt.values())o.addComponent(a);s=new Mt(r,n,o);return Ct.set(i,s),s}function qt(e=Et){var t=Ct.get(e);if(!t&&e===Et&&J())return Bt();if(t)return t;throw Lt.create("no-app",{appName:e})}async function jt(e){let t=!1;var r=e.name;Ct.has(r)?(t=!0,Ct.delete(r)):St.has(r)&&e.decRefCount()<=0&&(St.delete(r),t=!0),t&&(await Promise.all(e.container.getProviders().map(e=>e.delete())),e.isDeleted=!0)}function zt(e,t,r){let n=It[e]??e;r&&(n+="-"+r);var i,s=n.match(/\s|\//),a=t.match(/\s|\//);s||a?(i=[`Unable to register library "${n}" with version "${t}":`],s&&i.push(`library name "${n}" contains illegal characters (whitespace or "/")`),s&&a&&i.push("and"),a&&i.push(`version name "${t}" contains illegal characters (whitespace or "/")`),Tt.warn(i.join(" "))):Rt(new h(n+"-version",()=>({library:n,version:t}),"VERSION"))}function Ht(e,t){if(null!==e&&"function"!=typeof e)throw Lt.create("invalid-log-argument");var r,s=e,n=t;for(r of $e){let i=null;n&&n.level&&(i=Ye[n.level]),r.userLogHandler=null===s?null:(e,t,...r)=>{var n=r.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(" ");t>=(i??e.logLevel)&&s({level:p[t].toLowerCase(),message:n,args:r,type:e.name})}}}function Kt(e){var t;t=e,$e.forEach(e=>{e.setLogLevel(t)})}let Gt="firebase-heartbeat-database",Wt=1,$t="firebase-heartbeat-store",Yt=null;function Qt(){return Yt=Yt||pt(Gt,Wt,{upgrade:(e,t)=>{if(0===t)try{e.createObjectStore($t)}catch(e){console.warn(e)}}}).catch(e=>{throw Lt.create("idb-open",{originalErrorMessage:e.message})})}async function Jt(e,t){try{var r=(await Qt()).transaction($t,"readwrite");await r.objectStore($t).put(t,Xt(e)),await r.done}catch(e){e instanceof fe?Tt.warn(e.message):(r=Lt.create("idb-set",{originalErrorMessage:e?.message}),Tt.warn(r.message))}}function Xt(e){return e.name+"!"+e.options.appId}let Zt=1024;class er{constructor(e){this.container=e,this._heartbeatsCache=null;var t=this.container.getProvider("app").getImmediate();this._storage=new rr(t),this._heartbeatsCachePromise=this._storage.read().then(e=>this._heartbeatsCache=e)}async triggerHeartbeat(){try{var e,r=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString();let t=tr();if(null!=this._heartbeatsCache?.heartbeats||(this._heartbeatsCache=await this._heartbeatsCachePromise,null!=this._heartbeatsCache?.heartbeats))if(this._heartbeatsCache.lastSentHeartbeatDate!==t&&!this._heartbeatsCache.heartbeats.some(e=>e.date===t))return this._heartbeatsCache.heartbeats.push({date:t,agent:r}),30<this._heartbeatsCache.heartbeats.length&&(e=(e=>{if(0===e.length)return-1;let t=0,r=e[0].date;for(let n=1;n<e.length;n++)e[n].date<r&&(r=e[n].date,t=n);return t})(this._heartbeatsCache.heartbeats),this._heartbeatsCache.heartbeats.splice(e,1)),this._storage.overwrite(this._heartbeatsCache)}catch(e){Tt.warn(e)}}async getHeartbeatsHeader(){try{var e,t,r,n;return(null===this._heartbeatsCache&&await this._heartbeatsCachePromise,null==this._heartbeatsCache?.heartbeats||0===this._heartbeatsCache.heartbeats.length)?"":(e=tr(),{heartbeatsToSend:t,unsentEntries:r}=((e,t=Zt)=>{let r=[],n=e.slice();for(let s of e){var i=r.find(e=>e.agent===s.agent);if(i){if(i.dates.push(s.date),nr(r)>t){i.dates.pop();break}}else if(r.push({agent:s.agent,dates:[s.date]}),nr(r)>t){r.pop();break}n=n.slice(1)}return{heartbeatsToSend:r,unsentEntries:n}})(this._heartbeatsCache.heartbeats),n=z(JSON.stringify({version:2,heartbeats:t})),this._heartbeatsCache.lastSentHeartbeatDate=e,0<r.length?(this._heartbeatsCache.heartbeats=r,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),n)}catch(e){return Tt.warn(e),""}}}function tr(){return(new Date).toISOString().substring(0,10)}class rr{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return!!ce()&&de().then(()=>!0).catch(()=>!1)}async read(){var e;return await this._canUseIndexedDBPromise&&(e=await(async e=>{try{var t=(await Qt()).transaction($t),r=await t.objectStore($t).get(Xt(e));return await t.done,r}catch(e){e instanceof fe?Tt.warn(e.message):(t=Lt.create("idb-get",{originalErrorMessage:e?.message}),Tt.warn(t.message))}})(this.app))?.heartbeats?e:{heartbeats:[]}}async overwrite(e){var t;if(await this._canUseIndexedDBPromise)return t=await this.read(),Jt(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??t.lastSentHeartbeatDate,heartbeats:e.heartbeats})}async add(e){var t;if(await this._canUseIndexedDBPromise)return t=await this.read(),Jt(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??t.lastSentHeartbeatDate,heartbeats:[...t.heartbeats,...e.heartbeats]})}}function nr(e){return z(JSON.stringify({version:2,heartbeats:e})).length}t="",Rt(new h("platform-logger",e=>new yt(e),"PRIVATE")),Rt(new h("heartbeat",e=>new er(e),"PRIVATE")),zt(wt,bt,t),zt(wt,bt,"esm2020"),zt("fire-js","");var ir=Object.freeze({__proto__:null,SDK_VERSION:Vt,_DEFAULT_ENTRY_NAME:Et,_addComponent:At,_addOrOverwriteComponent:Nt,_apps:Ct,_clearComponents:function(){kt.clear()},_components:kt,_getProvider:Pt,_isFirebaseApp:xt,_isFirebaseServerApp:Ot,_isFirebaseServerAppSettings:Dt,_registerComponent:Rt,_removeServiceInstance:function(e,t,r=Et){Pt(e,t).clearInstance(r)},_serverApps:St,deleteApp:jt,getApp:qt,getApps:function(){return Array.from(Ct.values())},initializeApp:Bt,initializeServerApp:function(e,t={}){if(("undefined"!=typeof window||ie())&&!ie())throw Lt.create("invalid-server-app-environment");let r,n=t||{};if(e&&(xt(e)?r=e.options:Dt(e)?n=e:r=e),void 0===n.automaticDataCollectionEnabled&&(n.automaticDataCollectionEnabled=!0),!(r=r||J()))throw Lt.create("no-options");var i={...n,...r};if(void 0!==i.releaseOnDeref&&delete i.releaseOnDeref,void 0!==n.releaseOnDeref&&"undefined"==typeof FinalizationRegistry)throw Lt.create("finalization-registry-not-supported",{});var i=""+[...JSON.stringify(i)].reduce((e,t)=>Math.imul(31,e)+t.charCodeAt(0)|0,0),s=St.get(i);if(s)s.incRefCount(n.releaseOnDeref);else{var a,o=new We(i);for(a of kt.values())o.addComponent(a);s=new Ut(r,n,i,o),St.set(i,s)}return s},onLog:Ht,registerVersion:zt,setLogLevel:Kt,FirebaseError:fe});class sr{constructor(e,t){this._delegate=e,this.firebase=t,At(e,new h("app-compat",()=>this,"PUBLIC")),this.container=e.container}get automaticDataCollectionEnabled(){return this._delegate.automaticDataCollectionEnabled}set automaticDataCollectionEnabled(e){this._delegate.automaticDataCollectionEnabled=e}get name(){return this._delegate.name}get options(){return this._delegate.options}delete(){return new Promise(e=>{this._delegate.checkDestroyed(),e()}).then(()=>(this.firebase.INTERNAL.removeApp(this.name),jt(this._delegate)))}_getService(e,t=Et){this._delegate.checkDestroyed();var r=this._delegate.container.getProvider(e);return r.isInitialized()||"EXPLICIT"!==r.getComponent()?.instantiationMode||r.initialize(),r.getImmediate({identifier:t})}_removeServiceInstance(e,t=Et){this._delegate.container.getProvider(e).clearInstance(t)}_addComponent(e){At(this._delegate,e)}_addOrOverwriteComponent(e){Nt(this._delegate,e)}toJSON(){return{name:this.name,automaticDataCollectionEnabled:this.automaticDataCollectionEnabled,options:this.options}}}let ar=new ge("app-compat","Firebase",{"no-app":"No Firebase App '{$appName}' has been created - call Firebase App.initializeApp()","invalid-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance."});function or(i){let s={},a={__esModule:!0,initializeApp:function(e,t={}){var r=Bt(e,t);if(we(s,r.name))return s[r.name];var n=new i(r,a);return s[r.name]=n},app:o,registerVersion:zt,setLogLevel:Kt,onLog:Ht,apps:null,SDK_VERSION:Vt,INTERNAL:{registerComponent:function(t){let r=t.name,n=r.replace("-compat","");{var e;Rt(t)&&"PUBLIC"===t.type&&(e=(e=o())=>{if("function"!=typeof e[n])throw ar.create("invalid-app-argument",{appName:r});return e[n]()},void 0!==t.serviceProps&&K(e,t.serviceProps),a[n]=e,i.prototype[n]=function(...e){return this._getService.bind(this,r).apply(this,t.multipleInstances?e:[])})}return"PUBLIC"===t.type?a[n]:null},removeApp:function(e){delete s[e]},useAsService:function(e,t){if("serverAuth"===t)return null;var r=t;return r},modularAPIs:ir}};function o(e){if(e=e||Et,we(s,e))return s[e];throw ar.create("no-app",{appName:e})}return a.default=a,Object.defineProperty(a,"apps",{get:function(){return Object.keys(s).map(e=>s[e])}}),o.App=i,a}var lr=function e(){let t=or(sr);return t.INTERNAL={...t.INTERNAL,createFirebaseNamespace:e,extendNamespace:function(e){K(t,e)},createSubscribe:Re,ErrorFactory:ge,deepExtend:K},t}(),ur=new Ze("@firebase/app-compat");let hr="@firebase/app-compat",cr="0.5.14";try{var dr=G();void 0!==dr.firebase&&(ur.warn(`
      Warning: Firebase is already defined in the global scope. Please make sure
      Firebase library is only loaded once.
    `),fr=dr.firebase.SDK_VERSION)&&0<=fr.indexOf("LITE")&&ur.warn(`
        Warning: You are trying to load Firebase while using Firebase Performance standalone script.
        You should load Firebase Performance with this instance of Firebase to avoid loading duplicate code.
        `)}catch{}let pr=lr;zt(hr,cr,void 0);pr.registerVersion("firebase","12.15.0","app-compat");var dr="@firebase/installations",fr="0.6.22";let gr=1e4,mr="w:"+fr,vr="FIS_v2",_r="https://firebaseinstallations.googleapis.com/v1",yr=36e5;let wr=new ge("installations","Installations",{"missing-app-config-values":'Missing App configuration value: "{$valueName}"',"not-registered":"Firebase Installation is not registered.","installation-not-found":"Firebase Installation not found.","request-failed":'{$requestName} request failed with error "{$serverCode} {$serverStatus}: {$serverMessage}"',"app-offline":"Could not process request. Application offline.","delete-pending-registration":"Can't delete installation while there is a pending registration request."});function br(e){return e instanceof fe&&e.code.includes("request-failed")}function Tr({projectId:e}){return _r+`/projects/${e}/installations`}function Er(e){return{token:e.token,requestStatus:2,expiresIn:Number(e.expiresIn.replace("s","000")),creationTime:Date.now()}}async function Ir(e,t){var r=(await t.json()).error;return wr.create("request-failed",{requestName:e,serverCode:r.code,serverMessage:r.message,serverStatus:r.status})}function Cr({apiKey:e}){return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":e})}function Sr(e,{refreshToken:t}){var r=Cr(e);return r.append("Authorization",(e=t,vr+" "+e)),r}async function kr(e){var t=await e();return 500<=t.status&&t.status<600?e():t}function Ar(t){return new Promise(e=>{setTimeout(e,t)})}let Nr=/^[cdef][\w-]{21}$/,Rr="";function Pr(){try{var e=new Uint8Array(17),t=((self.crypto||self.msCrypto).getRandomValues(e),e[0]=112+e[0]%16,(e=>btoa(String.fromCharCode(...e)).replace(/\+/g,"-").replace(/\//g,"_"))(e).substr(0,22));return Nr.test(t)?t:Rr}catch{return Rr}}function xr(e){return e.appName+"!"+e.appId}let Dr=new Map;function Or(e,t){var r=xr(e),e=(Lr(r,t),r),r=Fr();r&&r.postMessage({key:e,fid:t}),Ur()}function Lr(e,t){var r=Dr.get(e);if(r)for(var n of r)n(t)}let Mr=null;function Fr(){return!Mr&&"BroadcastChannel"in self&&((Mr=new BroadcastChannel("[Firebase] FID Change")).onmessage=e=>{Lr(e.data.key,e.data.fid)}),Mr}function Ur(){0===Dr.size&&Mr&&(Mr.close(),Mr=null)}let Vr="firebase-installations-database",Br=1,qr="firebase-installations-store",jr=null;function zr(){return jr=jr||pt(Vr,Br,{upgrade:(e,t)=>{0===t&&e.createObjectStore(qr)}})}async function Hr(e,t){var r=xr(e),n=(await zr()).transaction(qr,"readwrite"),i=n.objectStore(qr),s=await i.get(r);return await i.put(t,r),await n.done,s&&s.fid===t.fid||Or(e,t.fid),t}async function Kr(e){var t=xr(e),r=(await zr()).transaction(qr,"readwrite");await r.objectStore(qr).delete(t),await r.done}async function Gr(e,t){var r=xr(e),n=(await zr()).transaction(qr,"readwrite"),i=n.objectStore(qr),s=await i.get(r),a=t(s);return void 0===a?await i.delete(r):await i.put(a,r),await n.done,!a||s&&s.fid===a.fid||Or(e,a.fid),a}async function Wr(r){let n;var e=await Gr(r.appConfig,e=>{var t=Yr(e||{fid:Pr(),registrationStatus:0}),t=((e,t)=>{var r,n;return 0===t.registrationStatus?navigator.onLine?(r={fid:t.fid,registrationStatus:1,registrationTime:Date.now()},n=(async(t,r)=>{try{var e=await(async({appConfig:e,heartbeatServiceProvider:t},{fid:r})=>{let n=Tr(e);var i=Cr(e),s=((s=t.getImmediate({optional:!0}))&&(s=await s.getHeartbeatsHeader())&&i.append("x-firebase-client",s),{fid:r,authVersion:vr,appId:e.appId,sdkVersion:mr});let a={method:"POST",headers:i,body:JSON.stringify(s)};if((i=await kr(()=>fetch(n,a))).ok)return{fid:(s=await i.json()).fid||r,registrationStatus:2,refreshToken:s.refreshToken,authToken:Er(s.authToken)};throw await Ir("Create Installation",i)})(t,r);return Hr(t.appConfig,e)}catch(e){throw br(e)&&409===e.customData.serverCode?await Kr(t.appConfig):await Hr(t.appConfig,{fid:r.fid,registrationStatus:0}),e}})(e,r),{installationEntry:r,registrationPromise:n}):(r=Promise.reject(wr.create("app-offline")),{installationEntry:t,registrationPromise:r}):1===t.registrationStatus?{installationEntry:t,registrationPromise:(async e=>{let t=await $r(e.appConfig);for(;1===t.registrationStatus;)await Ar(100),t=await $r(e.appConfig);var r,n;return 0!==t.registrationStatus?t:({installationEntry:r,registrationPromise:n}=await Wr(e),n||r)})(e)}:{installationEntry:t}})(r,t);return n=t.registrationPromise,t.installationEntry});return e.fid===Rr?{installationEntry:await n}:{installationEntry:e,registrationPromise:n}}function $r(e){return Gr(e,e=>{if(e)return Yr(e);throw wr.create("installation-not-found")})}function Yr(e){var t;return 1===(t=e).registrationStatus&&t.registrationTime+gr<Date.now()?{fid:e.fid,registrationStatus:0}:e}async function Qr({appConfig:e,heartbeatServiceProvider:t},r){[i,s]=[e,r.fid];let n=Tr(i)+`/${s}/authTokens:generate`;var i,s,a=Sr(e,r),o=t.getImmediate({optional:!0}),o=(o&&(o=await o.getHeartbeatsHeader())&&a.append("x-firebase-client",o),{installation:{sdkVersion:mr,appId:e.appId}});let l={method:"POST",headers:a,body:JSON.stringify(o)};a=await kr(()=>fetch(n,l));if(a.ok)return Er(await a.json());throw await Ir("Generate Auth Token",a)}async function Jr(n,i=!1){let s;var e=await Gr(n.appConfig,e=>{if(!Zr(e))throw wr.create("not-registered");var t,r=e.authToken;if(i||2!==(t=r).requestStatus||(e=>{var t=Date.now();return t<e.creationTime||e.creationTime+e.expiresIn<t+yr})(t)){if(1===r.requestStatus)return s=(async(e,t)=>{let r=await Xr(e.appConfig);for(;1===r.authToken.requestStatus;)await Ar(100),r=await Xr(e.appConfig);var n=r.authToken;return 0===n.requestStatus?Jr(e,t):n})(n,i),e;if(navigator.onLine)return t=e,r={requestStatus:1,requestTime:Date.now()},r={...t,authToken:r},s=(async(t,r)=>{try{var e=await Qr(t,r),n={...r,authToken:e};return await Hr(t.appConfig,n),e}catch(e){var i;throw!br(e)||401!==e.customData.serverCode&&404!==e.customData.serverCode?(i={...r,authToken:{requestStatus:0}},await Hr(t.appConfig,i)):await Kr(t.appConfig),e}})(n,r),r;throw wr.create("app-offline")}return e});return s?await s:e.authToken}function Xr(e){return Gr(e,e=>{var t,r;if(Zr(e))return t=e.authToken,1===(r=t).requestStatus&&r.requestTime+gr<Date.now()?{...e,authToken:{requestStatus:0}}:e;throw wr.create("not-registered")})}function Zr(e){return void 0!==e&&2===e.registrationStatus}async function en(e,t=!1){var r=e,n=(await(!(n=(await Wr(r)).registrationPromise)||!await n),await Jr(r,t));return n.token}function tn(t,i){let s=t.appConfig;{t=s;var r=i,n=(Fr(),xr(t));let e=Dr.get(n);e||(e=new Set,Dr.set(n,e)),e.add(r)}return()=>{var e,t,r,n;e=s,t=i,r=xr(e),(n=Dr.get(r))&&(n.delete(t),0===n.size&&Dr.delete(r),Ur())}}function rn(e){return wr.create("missing-app-config-values",{valueName:e})}let nn="installations",sn="installations-internal",an=e=>{var t=e.getProvider("app").getImmediate();return{app:t,appConfig:(e=>{if(!e||!e.options)throw rn("App Configuration");if(!e.name)throw rn("App Name");var t;for(t of["projectId","apiKey","appId"])if(!e.options[t])throw rn(t);return{appName:e.name,projectId:e.options.projectId,apiKey:e.options.apiKey,appId:e.options.appId}})(t),heartbeatServiceProvider:Pt(t,"heartbeat"),_delete:()=>Promise.resolve()}},on=e=>{let t=Pt(e.getProvider("app").getImmediate(),nn).getImmediate();return{getId:()=>(async e=>{var t=e,{installationEntry:r,registrationPromise:n}=await Wr(t);return(n||Jr(t)).catch(console.error),r.fid})(t),getToken:e=>en(t,e)}};Rt(new h(nn,an,"PUBLIC")),Rt(new h(sn,on,"PRIVATE")),zt(dr,fr),zt(dr,fr,"esm2020");let ln="analytics",un="firebase_id",hn="origin",cn=6e4,dn="https://firebase.googleapis.com/v1alpha/projects/-/apps/{app-id}/webConfig",pn="https://www.googletagmanager.com/gtag/js",fn=new Ze("@firebase/analytics"),gn=new ge("analytics","Analytics",{"already-exists":"A Firebase Analytics instance with the appId {$id}  already exists. Only one Firebase Analytics instance can be created for each appId.","already-initialized":"initializeAnalytics() cannot be called again with different options than those it was initially called with. It can be called again with the same options to return the existing instance, or getAnalytics() can be used to get a reference to the already-initialized instance.","already-initialized-settings":"Firebase Analytics has already been initialized.settings() must be called before initializing any Analytics instanceor it will have no effect.","interop-component-reg-failed":"Firebase Analytics Interop Component failed to instantiate: {$reason}","invalid-analytics-context":"Firebase Analytics is not supported in this environment. Wrap initialization of analytics in analytics.isSupported() to prevent initialization in unsupported environments. Details: {$errorInfo}","indexeddb-unavailable":"IndexedDB unavailable or restricted in this environment. Wrap initialization of analytics in analytics.isSupported() to prevent initialization in unsupported environments. Details: {$errorInfo}","fetch-throttle":"The config fetch request timed out while in an exponential backoff state. Unix timestamp in milliseconds when fetch request throttling ends: {$throttleEndTimeMillis}.","config-fetch-failed":"Dynamic config fetch failed: [{$httpStatus}] {$responseMessage}","no-api-key":'The "apiKey" field is empty in the local Firebase config. Firebase Analytics requires this field tocontain a valid API key.',"no-app-id":'The "appId" field is empty in the local Firebase config. Firebase Analytics requires this field tocontain a valid app ID.',"no-client-id":'The "client_id" field is empty.',"invalid-gtag-resource":"Trusted Types detected an invalid gtag resource: {$gtagURL}."});function mn(e){var t;return e.startsWith(pn)?e:(t=gn.create("invalid-gtag-resource",{gtagURL:e}),fn.warn(t.message),"")}function vn(e){return Promise.all(e.map(e=>e.catch(e=>e)))}function _n(e,t){var r=((e,t)=>{let r;return r=window.trustedTypes?window.trustedTypes.createPolicy(e,t):r})("firebase-js-sdk-policy",{createScriptURL:mn}),n=document.createElement("script"),i=pn+`?l=${e}&id=`+t;n.src=r?r?.createScriptURL(i):i,n.async=!0,document.head.appendChild(n)}function yn(k,A,N,R){return async function(e,...t){try{if("event"===e){var[r,n]=t,i=k,s=A,a=N,o=r,l=n;try{let r=[];if(l&&l.send_to){let e=l.send_to;Array.isArray(e)||(e=[e]);var u=await vn(a);for(let t of e){var h=u.find(e=>e.measurementId===t),c=h&&s[h.appId];if(!c){r=[];break}r.push(c)}}0===r.length&&(r=Object.values(s)),await Promise.all(r),i("event",o,l||{})}catch(e){fn.error(e)}}else if("config"===e){var d,[p,f]=t,g=k,m=A,v=N,_=p,y=f,w=R[_];try{w?await m[w]:(d=(await vn(v)).find(e=>e.measurementId===_))&&await m[d.appId]}catch(e){fn.error(e)}g("config",_,y)}else{var b,T,E,I,C,S;"consent"===e?([b,T]=t,k("consent",b,T)):"get"===e?([E,I,C]=t,k("get",E,I,C)):"set"===e?([S]=t,k("set",S)):k(e,...t)}}catch(e){fn.error(e)}}}let wn=30;let bn=new class{constructor(e={},t=1e3){this.throttleMetadata=e,this.intervalMillis=t}getThrottleMetadata(e){return this.throttleMetadata[e]}setThrottleMetadata(e,t){this.throttleMetadata[e]=t}deleteThrottleMetadata(e){delete this.throttleMetadata[e]}};async function Tn(e){var{appId:t,apiKey:r}=e,r={method:"GET",headers:new Headers({Accept:"application/json","x-goog-api-key":r})},t=dn.replace("{app-id}",t),t=await fetch(t,r);if(200===t.status||304===t.status)return t.json();{let e="";try{var n=await t.json();n.error?.message&&(e=n.error.message)}catch(e){}throw gn.create("config-fetch-failed",{httpStatus:t.status,responseMessage:e})}}async function En(e,t=bn,r){var{appId:n,apiKey:i,measurementId:s}=e.options;if(!n)throw gn.create("no-app-id");if(!i){if(s)return{measurementId:s,appId:n};throw gn.create("no-api-key")}var a=t.getThrottleMetadata(n)||{backoffCount:0,throttleEndTimeMillis:Date.now()};let o=new Sn;return setTimeout(async()=>{o.abort()},void 0!==r?r:cn),async function i(s,{throttleEndTimeMillis:e,backoffCount:a},o,l=bn){let{appId:u,measurementId:h}=s;try{await In(o,e)}catch(e){if(h)return fn.warn("Timed out fetching this Firebase app's measurement ID from the server. Falling back to the measurement ID "+h+` provided in the "measurementId" field in the local Firebase config. [${e?.message}]`),{appId:u,measurementId:h};throw e}try{let e=await Tn(s);return l.deleteThrottleMetadata(u),e}catch(e){let t=e;if(!Cn(t)){if(l.deleteThrottleMetadata(u),h)return fn.warn("Failed to fetch this Firebase app's measurement ID from the server. Falling back to the measurement ID "+h+` provided in the "measurementId" field in the local Firebase config. [${t?.message}]`),{appId:u,measurementId:h};throw e}let r=503===Number(t?.customData?.httpStatus)?je(a,l.intervalMillis,wn):je(a,l.intervalMillis),n={throttleEndTimeMillis:Date.now()+r,backoffCount:a+1};return l.setThrottleMetadata(u,n),fn.debug(`Calling attemptFetch again in ${r} millis`),i(s,n,o,l)}}({appId:n,apiKey:i,measurementId:s},a,o,t)}function In(i,s){return new Promise((e,t)=>{var r=Math.max(s-Date.now(),0);let n=setTimeout(e,r);i.addEventListener(()=>{clearTimeout(n),t(gn.create("fetch-throttle",{throttleEndTimeMillis:s}))})})}function Cn(e){var t;return!!(e instanceof fe&&e.customData)&&(429===(t=Number(e.customData.httpStatus))||500===t||503===t||504===t)}class Sn{constructor(){this.listeners=[]}addEventListener(e){this.listeners.push(e)}abort(){this.listeners.forEach(e=>e())}}async function kn(t,e,r,n,i,s,a){var o=En(t),l=(o.then(e=>{r[e.measurementId]=e.appId,t.options.measurementId&&e.measurementId!==t.options.measurementId&&fn.warn(`The measurement ID in the local Firebase config (${t.options.measurementId})`+` does not match the measurement ID fetched from the server (${e.measurementId}).`+" To ensure analytics events are always sent to the correct Analytics property, update the measurement ID field in the local config or remove it from the local config.")}).catch(e=>fn.error(e)),e.push(o),(async()=>{if(!ce())return fn.warn(gn.create("indexeddb-unavailable",{errorInfo:"IndexedDB is not available in this environment."}).message),!1;try{await de()}catch(e){return fn.warn(gn.create("indexeddb-unavailable",{errorInfo:e?.toString()}).message),!1}return!0})().then(e=>{if(e)return n.getId()})),[o,l]=await Promise.all([o,l]),u=((e=>{var t,r=window.document.getElementsByTagName("script");for(t of Object.values(r))if(t.src&&t.src.includes(pn)&&t.src.includes(e))return t})(s)||_n(s,o.measurementId),i("js",new Date),a?.config??{});return u[hn]="firebase",u.update=!0,null!=l&&(u[un]=l),i("config",o.measurementId,u),o.measurementId}class An{constructor(e){this.app=e}_delete(){return delete Nn[this.app.options.appId],Promise.resolve()}}let Nn={},Rn=[],Pn={},xn="dataLayer",Dn="gtag",On,Ln,Mn=!1;function Fn(e){if(Mn)throw gn.create("already-initialized");e.dataLayerName&&(xn=e.dataLayerName),e.gtagName&&(Dn=e.gtagName)}function Un(e,t,r){n=[],se()&&n.push("This is a browser extension environment."),pe()||n.push("Cookies are not available."),0<n.length&&(n=n.map((e,t)=>`(${t+1}) `+e).join(" "),n=gn.create("invalid-analytics-context",{errorInfo:n}),fn.warn(n.message));var n=e.options.appId;if(!n)throw gn.create("no-app-id");if(!e.options.apiKey){if(!e.options.measurementId)throw gn.create("no-api-key");fn.warn('The "apiKey" field is empty in the local Firebase config. This is needed to fetch the latest measurement ID for this Firebase app. Falling back to the measurement ID '+e.options.measurementId+' provided in the "measurementId" field in the local Firebase config.')}if(null!=Nn[n])throw gn.create("already-exists",{id:n});if(!Mn){{var i=xn;let e=[];Array.isArray(window[i])?e=window[i]:window[i]=e,e}var{wrappedGtag:s,gtagCore:a}=((e,t,r,n,i)=>{let s=function(){window[n].push(arguments)};return window[i]&&"function"==typeof window[i]&&(s=window[i]),window[i]=yn(s,e,t,r),{gtagCore:s,wrappedGtag:window[i]}})(Nn,Rn,Pn,xn,Dn);Ln=s,On=a,Mn=!0}return Nn[n]=kn(e,Rn,Pn,t,On,xn,r),new An(e)}async function Vn(){if(se())return!1;if(!pe())return!1;if(!ce())return!1;try{return await de()}catch(e){return!1}}function Bn(e,t,r){e=w(e),(async(e,t,r,n)=>{if(n&&n.global)return e("set",{screen_name:r}),Promise.resolve();e("config",await t,{update:!0,screen_name:r})})(Ln,Nn[e.app.options.appId],t,r).catch(e=>fn.error(e))}function qn(e,t,r){e=w(e),(async(e,t,r,n)=>{if(n&&n.global)return e("set",{user_id:r}),Promise.resolve();e("config",await t,{update:!0,user_id:r})})(Ln,Nn[e.app.options.appId],t,r).catch(e=>fn.error(e))}function jn(e,t,r){e=w(e),(async(e,t,r,n)=>{if(n&&n.global){var i,s={};for(i of Object.keys(r))s["user_properties."+i]=r[i];return e("set",s),Promise.resolve()}e("config",await t,{update:!0,user_properties:r})})(Ln,Nn[e.app.options.appId],t,r).catch(e=>fn.error(e))}function zn(e,t){e=w(e),(async(e,t)=>{var r=await e;window["ga-disable-"+r]=!t})(Nn[e.app.options.appId],t).catch(e=>fn.error(e))}function Hn(e,t,r,n){e=w(e),(async(e,t,r,n,i)=>{var s;i&&i.global?e("event",r,n):(s=await t,e("event",r,{...n,send_to:s}))})(Ln,Nn[e.app.options.appId],t,r,n).catch(e=>fn.error(e))}let Kn="@firebase/analytics",Gn="0.10.22";Rt(new h(ln,(e,{options:t})=>Un(e.getProvider("app").getImmediate(),e.getProvider("installations-internal").getImmediate(),t),"PUBLIC")),Rt(new h("analytics-internal",function(e){try{let n=e.getProvider(ln).getImmediate();return{logEvent:(e,t,r)=>Hn(n,e,t,r),setUserProperties:(e,t)=>jn(n,e,t)}}catch(e){throw gn.create("interop-component-reg-failed",{reason:e})}},"PRIVATE")),zt(Kn,Gn),zt(Kn,Gn,"esm2020");class Wn{constructor(e,t){this.app=e,this._delegate=t}logEvent(e,t,r){Hn(this._delegate,e,t,r)}setCurrentScreen(e,t){Bn(this._delegate,e,t)}setUserId(e,t){qn(this._delegate,e,t)}setUserProperties(e,t){jn(this._delegate,e,t)}setAnalyticsCollectionEnabled(e){zn(this._delegate,e)}}(t=e=e||{}).ADD_SHIPPING_INFO="add_shipping_info",t.ADD_PAYMENT_INFO="add_payment_info",t.ADD_TO_CART="add_to_cart",t.ADD_TO_WISHLIST="add_to_wishlist",t.BEGIN_CHECKOUT="begin_checkout",t.CHECKOUT_PROGRESS="checkout_progress",t.EXCEPTION="exception",t.GENERATE_LEAD="generate_lead",t.LOGIN="login",t.PAGE_VIEW="page_view",t.PURCHASE="purchase",t.REFUND="refund",t.REMOVE_FROM_CART="remove_from_cart",t.SCREEN_VIEW="screen_view",t.SEARCH="search",t.SELECT_CONTENT="select_content",t.SELECT_ITEM="select_item",t.SELECT_PROMOTION="select_promotion",t.SET_CHECKOUT_OPTION="set_checkout_option",t.SHARE="share",t.SIGN_UP="sign_up",t.TIMING_COMPLETE="timing_complete",t.VIEW_CART="view_cart",t.VIEW_ITEM="view_item",t.VIEW_ITEM_LIST="view_item_list",t.VIEW_PROMOTION="view_promotion",t.VIEW_SEARCH_RESULTS="view_search_results";let $n=e=>{var t=e.getProvider("app-compat").getImmediate(),r=e.getProvider("analytics").getImmediate();return new Wn(t,r)};ur={Analytics:Wn,settings:Fn,isSupported:Vn,EventName:e},pr.INTERNAL.registerComponent(new h("analytics-compat",$n,"PUBLIC").setServiceProps(ur).setMultipleInstances(!0)),pr.registerVersion("@firebase/analytics-compat","0.2.28");let Yn=new Map,Qn={activated:!1,tokenObservers:[]},Jn={initialized:!1,enabled:!1};function Xn(e){return Yn.get(e)||{...Qn}}let Zn="https://content-firebaseappcheck.googleapis.com/v1",ei="exchangeRecaptchaV3Token",ti="exchangeRecaptchaEnterpriseToken",ri="exchangeDebugToken",ni={OFFSET_DURATION:3e5,RETRIAL_MIN_WAIT:3e4,RETRIAL_MAX_WAIT:96e4},ii=864e5;class si{constructor(e,t,r,n,i){if(this.operation=e,this.retryPolicy=t,this.getWaitDuration=r,this.lowerBound=n,this.upperBound=i,this.pending=null,i<(this.nextErrorWaitInterval=n))throw new Error("Proactive refresh lower bound greater than upper bound!")}start(){this.nextErrorWaitInterval=this.lowerBound,this.process(!0).catch(()=>{})}stop(){this.pending&&(this.pending.reject("cancelled"),this.pending=null)}isRunning(){return!!this.pending}async process(e){this.stop();try{this.pending=new Z,this.pending.promise.catch(e=>{}),t=this.getNextRun(e),await new Promise(e=>{setTimeout(e,t)}),this.pending.resolve(),await this.pending.promise,this.pending=new Z,this.pending.promise.catch(e=>{}),await this.operation(),this.pending.resolve(),await this.pending.promise,this.process(!0).catch(()=>{})}catch(e){this.retryPolicy(e)?this.process(!1).catch(()=>{}):this.stop()}var t}getNextRun(e){var t;return e?(this.nextErrorWaitInterval=this.lowerBound,this.getWaitDuration()):(t=this.nextErrorWaitInterval,this.nextErrorWaitInterval*=2,this.nextErrorWaitInterval>this.upperBound&&(this.nextErrorWaitInterval=this.upperBound),t)}}let ai=new ge("appCheck","AppCheck",{"already-initialized":"You have already called initializeAppCheck() for FirebaseApp {$appName} with different options. To avoid this error, call initializeAppCheck() with the same options as when it was originally called. This will return the already initialized instance.","already-internally-initialized":"App Check has already been automatically initialized by {$initializerName} with default options. If you want to initialize App Check with custom options, call initializeAppCheck() with those options before initializing {$initializerName}.","use-before-activation":"App Check is being used before initializeAppCheck() is called for FirebaseApp {$appName}. Call initializeAppCheck() before instantiating other Firebase services.","fetch-network-error":"Fetch failed to connect to a network. Check Internet connection. Original error: {$originalErrorMessage}.","fetch-parse-error":"Fetch client could not parse response. Original error: {$originalErrorMessage}.","fetch-status-error":"Fetch server returned an HTTP error status. HTTP status: {$httpStatus}.","storage-open":"Error thrown when opening storage. Original error: {$originalErrorMessage}.","storage-get":"Error thrown when reading from storage. Original error: {$originalErrorMessage}.","storage-set":"Error thrown when writing to storage. Original error: {$originalErrorMessage}.","recaptcha-error":"ReCAPTCHA error.","no-provider":"No attestation provider was passed to initializeAppCheck() and no ReCAPTCHA Enterprise site key was found in the Firebase config.","initial-throttle":"{$httpStatus} error. Attempts allowed again after {$time}",throttled:"Requests throttled due to previous {$httpStatus} error. Attempts allowed again after {$time}"});function oi(e=!1){return e?self.grecaptcha?.enterprise:self.grecaptcha}function li(e){if(!Xn(e).activated)throw ai.create("use-before-activation",{appName:e.name})}function ui(e){var t=Math.round(e/1e3),r=Math.floor(t/86400),n=Math.floor((t-3600*r*24)/3600),i=Math.floor((t-3600*r*24-3600*n)/60),t=t-3600*r*24-3600*n-60*i;let s="";return r&&(s+=hi(r)+"d:"),n&&(s+=hi(n)+"h:"),s+=hi(i)+"m:"+hi(t)+"s"}function hi(e){return 0===e?"00":10<=e?e.toString():"0"+e}async function ci({url:e,body:t},r){var n={"Content-Type":"application/json"},i=r.getImmediate({optional:!0}),i=(i&&(i=await i.getHeartbeatsHeader())&&(n["X-Firebase-Client"]=i),{method:"POST",body:JSON.stringify(t),headers:n});let s;try{s=await fetch(e,i)}catch(e){throw ai.create("fetch-network-error",{originalErrorMessage:e?.message})}if(200!==s.status)throw ai.create("fetch-status-error",{httpStatus:s.status});let a;try{a=await s.json()}catch(e){throw ai.create("fetch-parse-error",{originalErrorMessage:e?.message})}var n=a.ttl.match(/^([\d.]+)(s)$/);if(n&&n[2]&&!isNaN(Number(n[1])))return i=1e3*Number(n[1]),n=Date.now(),{token:a.token,expireTimeMillis:n+i,issuedAtTimeMillis:n};throw ai.create("fetch-parse-error",{originalErrorMessage:"ttl field (timeToLive) is not in standard Protobuf Duration format: "+a.ttl})}function di(e,t){var{projectId:r,appId:n,apiKey:i}=e.options;return{url:`${Zn}/projects/${r}/apps/${n}:${ri}?key=`+i,body:{debug_token:t}}}let pi="firebase-app-check-database",fi=1,gi="firebase-app-check-store",mi="debug-token",vi=null;function _i(){return vi=vi||new Promise((t,r)=>{try{var e=indexedDB.open(pi,fi);e.onsuccess=e=>{t(e.target.result)},e.onerror=e=>{r(ai.create("storage-open",{originalErrorMessage:e.target.error?.message}))},e.onupgradeneeded=e=>{var t=e.target.result;0===e.oldVersion&&t.createObjectStore(gi,{keyPath:"compositeKey"})}}catch(e){r(ai.create("storage-open",{originalErrorMessage:e?.message}))}})}async function yi(e,t){let n=(await _i()).transaction(gi,"readwrite"),i=n.objectStore(gi).put({compositeKey:e,value:t});return new Promise((t,r)=>{i.onsuccess=e=>{t()},n.onerror=e=>{r(ai.create("storage-set",{originalErrorMessage:e.target.error?.message}))}})}async function wi(e){let n=(await _i()).transaction(gi,"readonly"),i=n.objectStore(gi).get(e);return new Promise((r,t)=>{i.onsuccess=e=>{var t=e.target.result;r(t?t.value:void 0)},n.onerror=e=>{t(ai.create("storage-get",{originalErrorMessage:e.target.error?.message}))}})}function bi(e){return e.options.appId+"-"+e.name}let Ti=new Ze("@firebase/app-check");async function Ei(t){if(ce()){let e=void 0;try{e=await wi(bi(t))}catch(e){Ti.warn("Failed to read token from IndexedDB. Error: "+e)}return e}}function Ii(e,t){return ce()?yi(bi(e),t).catch(e=>{Ti.warn("Failed to write token to IndexedDB. Error: "+e)}):Promise.resolve()}async function Ci(){let e=void 0;try{e=await wi(mi)}catch(e){}var t,r;return e||(t=crypto.randomUUID(),r=t,yi(mi,r).catch(e=>Ti.warn("Failed to persist debug token to IndexedDB. Error: "+e)),t)}function Si(){return Jn.enabled}async function ki(){var e=Jn;if(e.enabled&&e.token)return e.token.promise;throw Error(`
            Can't get debug token in production mode.
        `)}let Ai={error:"UNKNOWN_ERROR"};async function Ni(e,t=!1,r=!1){var n,i=e.app;li(i);let s=Xn(i),a=s.token,o=void 0;if(a&&!Oi(a)&&(s.token=void 0,a=void 0),a||(n=await s.cachedTokenPromise)&&(Oi(n)?a=n:await Ii(i,void 0)),!t&&a&&Oi(a))return{token:a.token};let l=!1;if(Si())try{var u=await ki(),h=(s.exchangeTokenPromise||(s.exchangeTokenPromise=ci(di(i,u),e.heartbeatServiceProvider).finally(()=>{s.exchangeTokenPromise=void 0}),l=!0),await s.exchangeTokenPromise);return await Ii(i,h),{token:(s.token=h).token}}catch(e){return"appCheck/throttled"===e.code||"appCheck/initial-throttle"===e.code?Ti.warn(e.message):r&&Ti.error(e),Li(e)}try{s.exchangeTokenPromise||(s.exchangeTokenPromise=s.provider.getToken().finally(()=>{s.exchangeTokenPromise=void 0}),l=!0),a=await Xn(i).exchangeTokenPromise}catch(e){"appCheck/throttled"===e.code||"appCheck/initial-throttle"===e.code?Ti.warn(e.message):r&&Ti.error(e),o=e}let c;return a?o?c=Oi(a)?{token:a.token,internalError:o}:Li(o):(c={token:a.token},await Ii(i,s.token=a)):c=Li(o),l&&Di(i,c),c}function Ri(t,e,r,n){var i=t.app,i=Xn(i),s={next:r,error:n,type:e};if(i.tokenObservers=[...i.tokenObservers,s],i.token&&Oi(i.token)){let e=i.token;Promise.resolve().then(()=>{r({token:e.token}),xi(t)}).catch(()=>{})}i.cachedTokenPromise.then(()=>xi(t))}function Pi(e,t){var r=Xn(e),n=r.tokenObservers.filter(e=>e.next!==t);0===n.length&&r.tokenRefresher&&r.tokenRefresher.isRunning()&&r.tokenRefresher.stop(),r.tokenObservers=n}function xi(e){var t=e.app,t=Xn(t);let r=t.tokenRefresher;r||(r=(r=>{let n=r.app;return new si(async()=>{var e=Xn(n);let t;if((t=e.token?await Ni(r,!0):await Ni(r)).error)throw t.error;if(t.internalError)throw t.internalError},()=>!0,()=>{var e,t=Xn(n);return t.token?(e=t.token.issuedAtTimeMillis+.5*(t.token.expireTimeMillis-t.token.issuedAtTimeMillis)+3e5,t=t.token.expireTimeMillis-3e5,e=Math.min(e,t),Math.max(0,e-Date.now())):0},ni.RETRIAL_MIN_WAIT,ni.RETRIAL_MAX_WAIT)})(e),t.tokenRefresher=r),!r.isRunning()&&t.isTokenAutoRefreshEnabled&&r.start()}function Di(e,t){var r;for(r of Xn(e).tokenObservers)try{"EXTERNAL"===r.type&&null!=t.error?r.error(t.error):r.next(t)}catch(e){}}function Oi(e){return 0<e.expireTimeMillis-Date.now()}function Li(e){return{token:(t=Ai,B.encodeString(JSON.stringify(t),!1)),error:e};var t}class Mi{constructor(e,t){this.app=e,this.heartbeatServiceProvider=t}_delete(){var e,t=Xn(this.app).tokenObservers;for(e of t)Pi(this.app,e.next);return Promise.resolve()}}function Fi(t){return{getToken:e=>Ni(t,e),getLimitedUseToken:()=>(async e=>{var t=e.app,r=(li(t),Xn(t)).provider;return Si()?{token:t=((t=di(t,await ki())).body.limited_use=!0,await ci(t,e.heartbeatServiceProvider)).token}:{token:t=(await r.getToken(!0)).token}})(t),addTokenListener:e=>Ri(t,"INTERNAL",e),removeTokenListener:e=>Pi(t.app,e)}}let Ui="@firebase/app-check",Vi="0.12.0",Bi="https://www.google.com/recaptcha/api.js",qi="https://www.google.com/recaptcha/enterprise.js";function ji(t,r){let n=new Z;Xn(t).reCAPTCHAState={initialized:n};let i=Ki(t);var e,s=oi(!1);return s?Hi(t,r,s,i,n):(e=()=>{var e=oi(!1);if(!e)throw new Error("no recaptcha");Hi(t,r,e,i,n)},(s=document.createElement("script")).src=Bi,s.onload=e,document.head.appendChild(s)),n.promise}function zi(t,r){let n=new Z;Xn(t).reCAPTCHAState={initialized:n};let i=Ki(t);var e,s=oi(!0);return s?Hi(t,r,s,i,n):(e=()=>{var e=oi(!0);if(!e)throw new Error("no recaptcha");Hi(t,r,e,i,n)},(s=document.createElement("script")).src=qi+"?render=explicit",s.onload=e,document.head.appendChild(s)),n.promise}function Hi(n,i,s,a,o){s.ready(()=>{var e,t,r;e=n,t=s.render(a,{sitekey:i,size:"invisible",callback:()=>{Xn(e).reCAPTCHAState.succeeded=!0},"error-callback":()=>{Xn(e).reCAPTCHAState.succeeded=!1}}),(r=Xn(e)).reCAPTCHAState={...r.reCAPTCHAState,widgetId:t},o.resolve(s)})}function Ki(e){var t="fire_app_check_"+e.name,r=document.createElement("div");return r.id=t,r.style.display="none",document.body.appendChild(r),t}async function Gi(n){li(n);let i=await Xn(n).reCAPTCHAState.initialized.promise;return new Promise((e,t)=>{let r=Xn(n).reCAPTCHAState;i.ready(()=>{e(i.execute(r.widgetId,{action:"fire_app_check"}))})})}class Wi{constructor(e){this._siteKey=e,this._throttleData=null}async getToken(e=!1){Ji(this._throttleData);var t=await Gi(this._app).catch(e=>{throw ai.create("recaptcha-error")});if(!Xn(this._app).reCAPTCHAState?.succeeded)throw ai.create("recaptcha-error");let r;try{var n=((e,t)=>{var{projectId:r,appId:n,apiKey:i}=e.options;return{url:`${Zn}/projects/${r}/apps/${n}:${ei}?key=`+i,body:{recaptcha_v3_token:t}}})(this._app,t);e&&(n.body.limited_use=!0),r=await ci(n,this._heartbeatServiceProvider)}catch(e){throw e.code?.includes("fetch-status-error")?(this._throttleData=Qi(Number(e.customData?.httpStatus),this._throttleData),ai.create("initial-throttle",{time:ui(this._throttleData.allowRequestsAfter-Date.now()),httpStatus:this._throttleData.httpStatus})):e}return this._throttleData=null,r}initialize(e){this._app=e,this._heartbeatServiceProvider=Pt(e,"heartbeat"),ji(e,this._siteKey).catch(()=>{})}isEqual(e){return e instanceof Wi&&this._siteKey===e._siteKey}}class $i{constructor(e){this._siteKey=e,this._throttleData=null}async getToken(e=!1){Ji(this._throttleData);var t=await Gi(this._app).catch(e=>{throw ai.create("recaptcha-error")});if(!Xn(this._app).reCAPTCHAState?.succeeded)throw ai.create("recaptcha-error");let r;try{var n=((e,t)=>{var{projectId:r,appId:n,apiKey:i}=e.options;return{url:`${Zn}/projects/${r}/apps/${n}:${ti}?key=`+i,body:{recaptcha_enterprise_token:t}}})(this._app,t);e&&(n.body.limited_use=!0),r=await ci(n,this._heartbeatServiceProvider)}catch(e){throw e.code?.includes("fetch-status-error")?(this._throttleData=Qi(Number(e.customData?.httpStatus),this._throttleData),ai.create("initial-throttle",{time:ui(this._throttleData.allowRequestsAfter-Date.now()),httpStatus:this._throttleData.httpStatus})):e}return this._throttleData=null,r}initialize(e){this._app=e,this._heartbeatServiceProvider=Pt(e,"heartbeat"),zi(e,this._siteKey).catch(()=>{})}isEqual(e){return e instanceof $i&&this._siteKey===e._siteKey}}class Yi{constructor(e){this._customProviderOptions=e}async getToken(){var e,t=await this._customProviderOptions.getToken(),r=(e=t.token,"object"==typeof(r=ye(e).claims)&&r.hasOwnProperty("iat")?r.iat:null),r=null!==r&&r<Date.now()&&0<r?1e3*r:Date.now();return{...t,issuedAtTimeMillis:r}}initialize(e){this._app=e}isEqual(e){return e instanceof Yi&&this._customProviderOptions.getToken.toString()===e._customProviderOptions.getToken.toString()}}function Qi(e,t){var r,n;return 404===e||403===e?{backoffCount:1,allowRequestsAfter:Date.now()+ii,httpStatus:e}:(n=je(r=t?t.backoffCount:0,1e3,2),{backoffCount:r+1,allowRequestsAfter:Date.now()+n,httpStatus:e})}function Ji(e){if(e&&Date.now()-e.allowRequestsAfter<=0)throw ai.create("throttled",{time:ui(e.allowRequestsAfter-Date.now()),httpStatus:e.httpStatus})}function Xi(e=qt(),r){e=w(e),Jn.initialized||(i=G(),(n=Jn).initialized=!0,"string"!=typeof i.FIREBASE_APPCHECK_DEBUG_TOKEN&&!0!==i.FIREBASE_APPCHECK_DEBUG_TOKEN)||(n.enabled=!0,s=new Z,n.token=s,"string"==typeof i.FIREBASE_APPCHECK_DEBUG_TOKEN?s.resolve(i.FIREBASE_APPCHECK_DEBUG_TOKEN):s.resolve(Ci())),Si()&&ki().then(e=>console.log(`App Check debug token: ${e}. You will need to add it to your app's App Check settings in the Firebase console for it to work.`));let t;if(!r?.provider&&e.options.recaptchaSiteKey&&(t=new $i(e.options.recaptchaSiteKey)),!r?.provider&&!t)throw ai.create("no-provider");var n={...r,provider:r?.provider||t},i=Pt(e,"app-check");if(i.isInitialized()){var s=i.getImmediate(),a=i.getOptions();if(a.isTokenAutoRefreshEnabled===n.isTokenAutoRefreshEnabled&&a.provider?.isEqual(n.provider))return s;if("string"==typeof Xn(e).internallyInitializedBy)throw ai.create("already-internally-initialized",{initializerName:Xn(e).internallyInitializedBy});throw ai.create("already-initialized",{appName:e.name})}a=i.initialize({options:n});{var[o,r,l=!1]=[e,n.provider,n.isTokenAutoRefreshEnabled];let t=((e,t)=>(Yn.set(e,t),Yn.get(e)))(o,{...Qn});t.activated=!0,t.provider=r,t.cachedTokenPromise=Ei(o).then(e=>(e&&Oi(e)&&(t.token=e,Di(o,{token:e.token})),e)),t.isTokenAutoRefreshEnabled=l&&o.automaticDataCollectionEnabled,!o.automaticDataCollectionEnabled&&l&&Ti.warn("`isTokenAutoRefreshEnabled` is true but `automaticDataCollectionEnabled` was set to false during `initializeApp()`. This blocks automatic token refresh."),t.provider.initialize(o)}return Xn(e).isTokenAutoRefreshEnabled&&Ri(a,"INTERNAL",()=>{}),a}let Zi="app-check",es="app-check-internal";Rt(new h(Zi,e=>{var t,r=e.getProvider("app").getImmediate(),n=e.getProvider("heartbeat");return e=r,t=n,new Mi(e,t)},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((e,t,r)=>{e.getProvider(es).initialize()})),Rt(new h(es,e=>Fi(e.getProvider("app-check").getImmediate()),"PUBLIC").setInstantiationMode("EXPLICIT")),zt(Ui,Vi);let ts=new ge("appCheck","AppCheck",{"use-before-activation":"App Check is being used before activate() is called for FirebaseApp {$appName}. Call activate() before instantiating other Firebase services."});class rs{constructor(e){this.app=e}activate(e,t){let r;r="string"==typeof e?new Wi(e):e instanceof $i||e instanceof Wi||e instanceof Yi?e:new Yi({getToken:e.getToken}),this._delegate=Xi(this.app,{provider:r,isTokenAutoRefreshEnabled:t})}setTokenAutoRefreshEnabled(e){if(!this._delegate)throw ts.create("use-before-activation",{appName:this.app.name});var t,r;t=this._delegate,e=e,(r=Xn(t.app)).tokenRefresher&&(!0===e?r.tokenRefresher.start():r.tokenRefresher.stop()),r.isTokenAutoRefreshEnabled=e}getToken(e){if(this._delegate)return(async(e,t)=>{var r=await Ni(e,t);if(r.error)throw r.error;if(r.internalError)throw r.internalError;return{token:r.token}})(this._delegate,e);throw ts.create("use-before-activation",{appName:this.app.name})}onTokenChanged(r,n,e){if(this._delegate){var i=this._delegate;let e=()=>{},t=()=>{};return e=null!=r.next?r.next.bind(r):r,null!=r.error?t=r.error.bind(r):n&&(t=n),Ri(i,"EXTERNAL",e,t),()=>Pi(i.app,e)}throw ts.create("use-before-activation",{appName:this.app.name})}}let ns=e=>{var t=e.getProvider("app-compat").getImmediate();return new rs(t)};pr.INTERNAL.registerComponent(new h("appCheck-compat",ns,"PUBLIC").setServiceProps({ReCaptchaEnterpriseProvider:$i,ReCaptchaV3Provider:Wi,CustomProvider:Yi})),pr.registerVersion("@firebase/app-check-compat","0.4.5");let is={FACEBOOK:"facebook.com",GITHUB:"github.com",GOOGLE:"google.com",PASSWORD:"password",PHONE:"phone",TWITTER:"twitter.com"},ss={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"};function as(){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."}}function os(){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`)."}}let ls=as,us=new ge("auth","Firebase",as()),hs=new Ze("@firebase/auth");function cs(e,...t){hs.logLevel<=p.ERROR&&hs.error(`Auth (${Vt}): `+e,...t)}function ds(e,...t){throw vs(e,...t)}function ps(e,...t){return vs(e,...t)}function fs(e,t,r){var n={...ls(),[t]:r};return new ge("auth","Firebase",n).create(t,{appName:e.name})}function gs(e){return fs(e,"operation-not-supported-in-this-environment","Operations that alter the current user are not supported in conjunction with FirebaseServerApp")}function ms(e,t,r){var n=r;if(!(t instanceof n))throw n.name!==t.constructor.name&&ds(e,"argument-error"),fs(e,"argument-error",`Type of ${t.constructor.name} does not match expected instance.`+"Did you pass a reference from a different Auth SDK?")}function vs(e,...t){var r,n;return"string"!=typeof e?(r=t[0],(n=[...t.slice(1)])[0]&&(n[0].appName=e.name),e._errorFactory.create(r,...n)):us.create(e,...t)}function m(e,t,...r){if(!e)throw vs(t,...r)}function _s(e){var t="INTERNAL ASSERTION FAILED: "+e;throw cs(t),new Error(t)}function ys(e,t){e||_s(t)}function ws(){return"undefined"!=typeof self&&self.location?.href||""}function bs(){return"http:"===Ts()||"https:"===Ts()}function Ts(){return"undefined"!=typeof self&&self.location?.protocol||null}class Es{constructor(e,t){ys((this.shortDelay=e)<(this.longDelay=t),"Short delay should be less than long delay!"),this.isMobile=re()||ae()}get(){return"undefined"!=typeof navigator&&navigator&&"onLine"in navigator&&"boolean"==typeof navigator.onLine&&(bs()||se()||"connection"in navigator)&&!navigator.onLine?Math.min(5e3,this.shortDelay):this.isMobile?this.longDelay:this.shortDelay}}function Is(e,t){ys(e.emulator,"Emulator should always be set here");var r=e.emulator.url;return t?""+r+(t.startsWith("/")?t.slice(1):t):r}class Cs{static initialize(e,t,r){this.fetchImpl=e,t&&(this.headersImpl=t),r&&(this.responseImpl=r)}static fetch(){return this.fetchImpl||("undefined"!=typeof self&&"fetch"in self?self.fetch:"undefined"!=typeof globalThis&&globalThis.fetch?globalThis.fetch:"undefined"!=typeof fetch?fetch:void _s("Could not find fetch implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill"))}static headers(){return this.headersImpl||("undefined"!=typeof self&&"Headers"in self?self.Headers:"undefined"!=typeof globalThis&&globalThis.Headers?globalThis.Headers:"undefined"!=typeof Headers?Headers:void _s("Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill"))}static response(){return this.responseImpl||("undefined"!=typeof self&&"Response"in self?self.Response:"undefined"!=typeof globalThis&&globalThis.Response?globalThis.Response:"undefined"!=typeof Response?Response:void _s("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill"))}}let Ss={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"},ks=["/v1/accounts:signInWithCustomToken","/v1/accounts:signInWithEmailLink","/v1/accounts:signInWithIdp","/v1/accounts:signInWithPassword","/v1/accounts:signInWithPhoneNumber","/v1/token"],As=new Es(3e4,6e4);function Ns(e,t){return e.tenantId&&!t.tenantId?{...t,tenantId:e.tenantId}:t}async function Rs(i,s,a,o,e={}){return Ps(i,e,async()=>{let e={},t={};o&&("GET"===s?t=o:e={body:JSON.stringify(o)});var r=Se({...t,key:i.config.apiKey}).slice(1),n=await i._getAdditionalHeaders(),n=(n["Content-Type"]="application/json",i.languageCode&&(n["X-Firebase-Locale"]=i.languageCode),{method:s,headers:n,...e});return"undefined"!=typeof navigator&&"Cloudflare-Workers"===navigator.userAgent||(n.referrerPolicy="strict-origin-when-cross-origin"),i.emulatorConfig&&ze(i.emulatorConfig.host)&&(n.credentials="include"),Cs.fetch()(await Ds(i,i.config.apiHost,a,r),n)})}async function Ps(t,e,r){t._canInitEmulator=!1;var n={...Ss,...e};try{var i=new Os(t),s=await Promise.race([r(),i.promise]),a=(i.clearNetworkTimeout(),await s.json());if("needConfirmation"in a)throw Ls(t,"account-exists-with-different-credential",a);if(s.ok&&!("errorMessage"in a))return a;var[o,l]=(s.ok?a.errorMessage:a.error.message).split(" : ");if("FEDERATED_USER_ID_ALREADY_LINKED"===o)throw Ls(t,"credential-already-in-use",a);if("EMAIL_EXISTS"===o)throw Ls(t,"email-already-in-use",a);if("USER_DISABLED"===o)throw Ls(t,"user-disabled",a);var u=n[o]||o.toLowerCase().replace(/[_\s]+/g,"-");if(l)throw fs(t,u,l);ds(t,u)}catch(e){if(e instanceof fe)throw e;ds(t,"network-request-failed",{message:String(e)})}}async function xs(e,t,r,n,i={}){var s=await Rs(e,t,r,n,i);return"mfaPendingCredential"in s&&ds(e,"multi-factor-auth-required",{_serverResponse:s}),s}async function Ds(e,t,r,n){var i=""+t+r+"?"+n,s=e,i=s.config.emulator?Is(e.config,i):e.config.apiScheme+"://"+i;if(ks.includes(r)&&(await s._persistenceManagerAvailable,"COOKIE"===s._getPersistenceType()))return s._getPersistence()._getFinalTarget(i).toString();return i}class Os{clearNetworkTimeout(){clearTimeout(this.timer)}constructor(e){this.auth=e,this.timer=null,this.promise=new Promise((e,t)=>{this.timer=setTimeout(()=>t(ps(this.auth,"network-request-failed")),As.get())})}}function Ls(e,t,r){var n={appName:e.name},n=(r.email&&(n.email=r.email),r.phoneNumber&&(n.phoneNumber=r.phoneNumber),ps(e,t,n));return n.customData._tokenResponse=r,n}function Ms(e){return void 0!==e&&void 0!==e.getResponse}function Fs(e){return void 0!==e&&void 0!==e.enterprise}class Us{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(t){if(this.recaptchaEnforcementState&&0!==this.recaptchaEnforcementState.length)for(let e of this.recaptchaEnforcementState)if(e.provider&&e.provider===t){switch(e.enforcementState){case"ENFORCE":return"ENFORCE";case"AUDIT":return"AUDIT";case"OFF":return"OFF";default:return"ENFORCEMENT_STATE_UNSPECIFIED"}return}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 Vs(e,t){return Rs(e,"GET","/v2/recaptchaConfig",Ns(e,t))}async function Bs(e,t){return Rs(e,"POST","/v1/accounts:lookup",t)}function qs(e){if(e)try{var t=new Date(Number(e));if(!isNaN(t.getTime()))return t.toUTCString()}catch(e){}}function js(e){return 1e3*Number(e)}function zs(e){var[t,r,n]=e.split(".");if(void 0===t||void 0===r||void 0===n)return cs("JWT malformed, contained fewer than 3 sections"),null;try{var i=H(r);return i?JSON.parse(i):(cs("Failed to decode base64 JWT payload"),null)}catch(e){return cs("Caught error parsing JWT payload as JSON",e?.toString()),null}}function Hs(e){var t=zs(e);return m(t,"internal-error"),m(void 0!==t.exp,"internal-error"),m(void 0!==t.iat,"internal-error"),Number(t.exp)-Number(t.iat)}async function Ks(t,e,r=!1){if(r)return e;try{return await e}catch(e){throw e instanceof fe&&(r=[e.code][0],"auth/user-disabled"===r||"auth/user-token-expired"===r)&&(t.auth.currentUser===t&&await t.auth.signOut()),e}}class Gs{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;return e?(t=this.errorBackoff,this.errorBackoff=Math.min(2*this.errorBackoff,96e4),t):(this.errorBackoff=3e4,t=(this.user.stsTokenManager.expirationTime??0)-Date.now()-3e5,Math.max(0,t))}schedule(e=!1){var t;this.isRunning&&(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 Ws{constructor(e,t){this.createdAt=e,this.lastLoginAt=t,this._initializeTime()}_initializeTime(){this.lastSignInTime=qs(this.lastLoginAt),this.creationTime=qs(this.createdAt)}_copy(e){this.createdAt=e.createdAt,this.lastLoginAt=e.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}async function $s(e){var t,r,n=e.auth,i=await e.getIdToken(),i=await Ks(e,Bs(n,{idToken:i})),n=(m(i?.users.length,n,"internal-error"),i.users[0]),i=(e._notifyReloadListener(n),n.providerUserInfo?.length?Ys(n.providerUserInfo):[]),i=(t=e.providerData,r=i,[...t.filter(t=>!r.some(e=>e.providerId===t.providerId)),...r]),s=!(e.email&&n.passwordHash||i.length),s=!!e.isAnonymous&&s,i={uid:n.localId,displayName:n.displayName||null,photoURL:n.photoUrl||null,email:n.email||null,emailVerified:n.emailVerified||!1,phoneNumber:n.phoneNumber||null,tenantId:n.tenantId||null,providerData:i,metadata:new Ws(n.createdAt,n.lastLoginAt),isAnonymous:s};Object.assign(e,i)}function Ys(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 Qs{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){m(e.idToken,"internal-error"),m(void 0!==e.idToken,"internal-error"),m(void 0!==e.refreshToken,"internal-error");var t="expiresIn"in e&&void 0!==e.expiresIn?Number(e.expiresIn):Hs(e.idToken);this.updateTokensAndExpiration(e.idToken,e.refreshToken,t)}updateFromIdToken(e){m(0!==e.length,"internal-error");var t=Hs(e);this.updateTokensAndExpiration(e,null,t)}async getToken(e,t=!1){return t||!this.accessToken||this.isExpired?(m(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){i=t;var n,i,{accessToken:r,refreshToken:s,expiresIn:a}=await{accessToken:(r=await Ps(n=e,{},async()=>{var e=Se({grant_type:"refresh_token",refresh_token:i}).slice(1),{tokenApiHost:t,apiKey:r}=n.config,t=await Ds(n,t,"/v1/token","key="+r),r=await n._getAdditionalHeaders(),r=(r["Content-Type"]="application/x-www-form-urlencoded",{method:"POST",headers:r,body:e});return n.emulatorConfig&&ze(n.emulatorConfig.host)&&(r.credentials="include"),Cs.fetch()(t,r)})).access_token,expiresIn:r.expires_in,refreshToken:r.refresh_token};this.updateTokensAndExpiration(r,s,Number(a))}updateTokensAndExpiration(e,t,r){this.refreshToken=t||null,this.accessToken=e||null,this.expirationTime=Date.now()+1e3*r}static fromJSON(e,t){var{refreshToken:r,accessToken:n,expirationTime:i}=t,s=new Qs;return r&&(m("string"==typeof r,"internal-error",{appName:e}),s.refreshToken=r),n&&(m("string"==typeof n,"internal-error",{appName:e}),s.accessToken=n),i&&(m("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 Qs,this.toJSON())}_performRefresh(){return _s("not implemented")}}function Js(e,t){m("string"==typeof e||void 0===e,"internal-error",{appName:t})}class Xs{constructor({uid:e,auth:t,stsTokenManager:r,...n}){this.providerId="firebase",this.proactiveRefresh=new Gs(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=e,this.auth=t,this.stsTokenManager=r,this.accessToken=r.accessToken,this.displayName=n.displayName||null,this.email=n.email||null,this.emailVerified=n.emailVerified||!1,this.phoneNumber=n.phoneNumber||null,this.photoURL=n.photoURL||null,this.isAnonymous=n.isAnonymous||!1,this.tenantId=n.tenantId||null,this.providerData=n.providerData?[...n.providerData]:[],this.metadata=new Ws(n.createdAt||void 0,n.lastLoginAt||void 0)}async getIdToken(e){var t=await Ks(this,this.stsTokenManager.getToken(this.auth,e));return m(t,this.auth,"internal-error"),this.accessToken!==t&&(this.accessToken=t,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),t}getIdTokenResult(e){return(async(e,t=!1)=>{var r=w(e),n=await r.getIdToken(t),i=zs(n),s=(m(i&&i.exp&&i.auth_time&&i.iat,r.auth,"internal-error"),(r="object"==typeof i.firebase?i.firebase:void 0)?.sign_in_provider);return{claims:i,token:n,authTime:qs(js(i.auth_time)),issuedAtTime:qs(js(i.iat)),expirationTime:qs(js(i.exp)),signInProvider:s||null,signInSecondFactor:r?.sign_in_second_factor||null}})(this,e)}reload(){return(async e=>{var t=w(e);await $s(t),await t.auth._persistUserIfCurrent(t),t.auth._notifyListenersIfCurrent(t)})(this)}_assign(e){this!==e&&(m(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){var t=new Xs({...this,auth:e,stsTokenManager:this.stsTokenManager._clone()});return t.metadata._copy(this.metadata),t}_onReload(e){m(!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 r=!1;e.idToken&&e.idToken!==this.stsTokenManager.accessToken&&(this.stsTokenManager.updateFromServerResponse(e),r=!0),t&&await $s(this),await this.auth._persistUserIfCurrent(this),r&&this.auth._notifyListenersIfCurrent(this)}async delete(){var e;return Ot(this.auth.app)?Promise.reject(gs(this.auth)):(e=await this.getIdToken(),await Ks(this,(async(e,t)=>Rs(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){var r=t.displayName??void 0,n=t.email??void 0,i=t.phoneNumber??void 0,s=t.photoURL??void 0,a=t.tenantId??void 0,o=t._redirectEventId??void 0,l=t.createdAt??void 0,u=t.lastLoginAt??void 0,{uid:h,emailVerified:c,isAnonymous:d,providerData:p,stsTokenManager:f}=t,f=(m(h&&f,e,"internal-error"),Qs.fromJSON(this.name,f)),h=(m("string"==typeof h,e,"internal-error"),Js(r,e.name),Js(n,e.name),m("boolean"==typeof c,e,"internal-error"),m("boolean"==typeof d,e,"internal-error"),Js(i,e.name),Js(s,e.name),Js(a,e.name),Js(o,e.name),Js(l,e.name),Js(u,e.name),new Xs({uid:h,auth:e,email:n,emailVerified:c,displayName:r,isAnonymous:d,photoURL:s,phoneNumber:i,tenantId:a,stsTokenManager:f,createdAt:l,lastLoginAt:u}));return p&&Array.isArray(p)&&(h.providerData=p.map(e=>({...e}))),o&&(h._redirectEventId=o),h}static async _fromIdTokenResponse(e,t,r=!1){var n=new Qs,n=(n.updateFromServerResponse(t),new Xs({uid:t.localId,auth:e,stsTokenManager:n,isAnonymous:r}));return await $s(n),n}static async _fromGetAccountInfoResponse(e,t,r){var n=t.users[0],i=(m(void 0!==n.localId,"internal-error"),void 0!==n.providerUserInfo?Ys(n.providerUserInfo):[]),s=!(n.email&&n.passwordHash||i?.length),a=new Qs,a=(a.updateFromIdToken(r),new Xs({uid:n.localId,auth:e,stsTokenManager:a,isAnonymous:s})),s={uid:n.localId,displayName:n.displayName||null,photoURL:n.photoUrl||null,email:n.email||null,emailVerified:n.emailVerified||!1,phoneNumber:n.phoneNumber||null,tenantId:n.tenantId||null,providerData:i,metadata:new Ws(n.createdAt,n.lastLoginAt),isAnonymous:!(n.email&&n.passwordHash||i?.length)};return Object.assign(a,s),a}}let Zs=new Map;function ea(e){ys(e instanceof Function,"Expected a class definition");var t=Zs.get(e);return t?ys(t instanceof e,"Instance stored in cache mismatched with class"):(t=new e,Zs.set(e,t)),t}class ta{constructor(){this.type="NONE",this.storage={}}async _isAvailable(){return!0}async _set(e,t){this.storage[e]=t}async _get(e){var t=this.storage[e];return void 0===t?null:t}async _remove(e){delete this.storage[e]}_addListener(e,t){}_removeListener(e,t){}}ta.type="NONE";let ra=ta;function na(e,t,r){return`firebase:${e}:${t}:`+r}class ia{constructor(e,t,r){this.persistence=e,this.auth=t,this.userKey=r;var{config:n,name:i}=this.auth;this.fullUserKey=na(this.userKey,n.apiKey,i),this.fullPersistenceKey=na("persistence",n.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(){var e,t=await this.persistence._get(this.fullUserKey);return t?"string"==typeof t?(e=await Bs(this.auth,{idToken:t}).catch(()=>{}))?Xs._fromGetAccountInfoResponse(this.auth,e,t):null:Xs._fromJSON(this.auth,t):null}removeCurrentUser(){return this.persistence._remove(this.fullUserKey)}savePersistenceForRedirect(){return this.persistence._set(this.fullPersistenceKey,this.persistence.type)}async setPersistence(e){var t;if(this.persistence!==e)return t=await this.getCurrentUser(),await this.removeCurrentUser(),this.persistence=e,t?this.setCurrentUser(t):void 0}delete(){this.persistence._removeListener(this.fullUserKey,this.boundEventHandler)}static async create(t,e,r="authUser"){if(!e.length)return new ia(ea(ra),t,r);var n,i=(await Promise.all(e.map(async e=>{if(await e._isAvailable())return e}))).filter(e=>e);let s=i[0]||ea(ra),a=na(r,t.config.apiKey,t.name),o=null;for(n of e)try{var l=await n._get(a);if(l){let e;if("string"==typeof l){var u=await Bs(t,{idToken:l}).catch(()=>{});if(!u)break;e=await Xs._fromGetAccountInfoResponse(t,u,l)}else e=Xs._fromJSON(t,l);n!==s&&(o=e),s=n;break}}catch{}i=i.filter(e=>e._shouldAllowMigration);return s._shouldAllowMigration&&i.length&&(s=i[0],o&&await s._set(a,o.toJSON()),await Promise.all(e.map(async e=>{if(e!==s)try{await e._remove(a)}catch{}}))),new ia(s,t,r)}}function sa(e){var t=e.toLowerCase();return t.includes("opera/")||t.includes("opr/")||t.includes("opios/")?"Opera":ua(t)?"IEMobile":t.includes("msie")||t.includes("trident/")?"IE":t.includes("edge/")?"Edge":aa(t)?"Firefox":t.includes("silk/")?"Silk":ca(t)?"Blackberry":da(t)?"Webos":oa(t)?"Safari":!t.includes("chrome/")&&!la(t)||t.includes("edge/")?ha(t)?"Android":2===(t=e.match(/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/))?.length?t[1]:"Other":"Chrome"}function aa(e=te()){return/firefox\//i.test(e)}function oa(e=te()){var t=e.toLowerCase();return t.includes("safari/")&&!t.includes("chrome/")&&!t.includes("crios/")&&!t.includes("android")}function la(e=te()){return/crios\//i.test(e)}function ua(e=te()){return/iemobile/i.test(e)}function ha(e=te()){return/android/i.test(e)}function ca(e=te()){return/blackberry/i.test(e)}function da(e=te()){return/webos/i.test(e)}function pa(e=te()){return/iphone|ipad|ipod/i.test(e)||/macintosh/i.test(e)&&/mobile/i.test(e)}function fa(e=te()){return pa(e)||ha(e)||da(e)||ca(e)||/windows phone/i.test(e)||ua(e)}function ga(e,t=[]){let r;switch(e){case"Browser":r=sa(te());break;case"Worker":r=sa(te())+"-"+e;break;default:r=e}var n=t.length?t.join(","):"FirebaseCore-web";return`${r}/JsCore/${Vt}/`+n}class ma{constructor(e){this.auth=e,this.queue=[]}pushCallback(n,e){var t=r=>new Promise((e,t)=>{try{e(n(r))}catch(e){t(e)}});t.onAbort=e,this.queue.push(t);let r=this.queue.length-1;return()=>{this.queue[r]=()=>Promise.resolve()}}async runMiddleware(e){if(this.auth.currentUser!==e){var t=[];try{for(var r of this.queue)await r(e),r.onAbort&&t.push(r.onAbort)}catch(e){t.reverse();for(var n of t)try{n()}catch(e){}throw this.auth._errorFactory.create("login-blocked",{originalMessage:e?.message})}}}}class va{constructor(e){var 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){var 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){var r=this.customStrengthOptions.minPasswordLength,n=this.customStrengthOptions.maxPasswordLength;r&&(t.meetsMinPasswordLength=e.length>=r),n&&(t.meetsMaxPasswordLength=e.length<=n)}validatePasswordCharacterOptions(e,t){var r;this.updatePasswordCharacterOptionsStatuses(t,!1,!1,!1,!1);for(let n=0;n<e.length;n++)r=e.charAt(n),this.updatePasswordCharacterOptionsStatuses(t,"a"<=r&&r<="z","A"<=r&&r<="Z","0"<=r&&r<="9",this.allowedNonAlphanumericCharacters.includes(r))}updatePasswordCharacterOptionsStatuses(e,t,r,n,i){this.customStrengthOptions.containsLowercaseLetter&&!e.containsLowercaseLetter&&(e.containsLowercaseLetter=t),this.customStrengthOptions.containsUppercaseLetter&&!e.containsUppercaseLetter&&(e.containsUppercaseLetter=r),this.customStrengthOptions.containsNumericCharacter&&!e.containsNumericCharacter&&(e.containsNumericCharacter=n),this.customStrengthOptions.containsNonAlphanumericCharacter&&!e.containsNonAlphanumericCharacter&&(e.containsNonAlphanumericCharacter=i)}}class _a{constructor(e,t,r,n){this.app=e,this.heartbeatServiceProvider=t,this.appCheckServiceProvider=r,this.config=n,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new wa(this),this.idTokenSubscription=new wa(this),this.beforeStateQueue=new ma(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=us,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=n.sdkClientVersion,this._persistenceManagerAvailable=new Promise(e=>this._resolvePersistenceManagerAvailable=e)}_initializeWithPersistence(e,t){return t&&(this._popupRedirectResolver=ea(t)),this._initializationPromise=this.queue(async()=>{if(!this._deleted&&(this.persistenceManager=await ia.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(){var e;!this._deleted&&(e=await this.assertedPersistence.getCurrentUser(),this.currentUser||e)&&(this.currentUser&&e&&this.currentUser.uid===e.uid?(this._currentUser._assign(e),await this.currentUser.getIdToken()):await this._updateCurrentUser(e,!0))}async initializeCurrentUserFromIdToken(e){try{var t=await Bs(this,{idToken:e}),r=await Xs._fromGetAccountInfoResponse(this,t,e);await this.directlySetCurrentUser(r)}catch(e){console.warn("FirebaseServerApp could not login user with provided authIdToken: ",e),await this.directlySetCurrentUser(null)}}async initializeCurrentUser(e){if(Ot(this.app)){let t=this.app.settings.authIdToken;return t?new Promise(e=>{setTimeout(()=>this.initializeCurrentUserFromIdToken(t).then(e,e))}):this.directlySetCurrentUser(null)}var t,r,n,i=await this.assertedPersistence.getCurrentUser();let s=i,a=!1;if(e&&this.config.authDomain&&(await this.getOrInitRedirectPersistenceManager(),t=this.redirectUser?._redirectEventId,r=s?._redirectEventId,n=await this.tryRedirectSignIn(e),t&&t!==r||!n?.user||(s=n.user,a=!0)),!s)return this.directlySetCurrentUser(null);if(s._redirectEventId)return m(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===s._redirectEventId?this.directlySetCurrentUser(s):this.reloadAndSetCurrentUserOrClear(s);if(a)try{await this.beforeStateQueue.runMiddleware(s)}catch(e){s=i,this._popupRedirectResolver._overrideRedirectResult(this,()=>Promise.reject(e))}return s?this.reloadAndSetCurrentUserOrClear(s):this.directlySetCurrentUser(null)}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 $s(e)}catch(e){if("auth/network-request-failed"!==e?.code)return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(e)}useDeviceLanguage(){var e;this.languageCode="undefined"!=typeof navigator&&((e=navigator).languages&&e.languages[0]||e.language)||null}async _delete(){this._deleted=!0}async updateCurrentUser(e){var t;return Ot(this.app)?Promise.reject(gs(this)):((t=e?w(e):null)&&m(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&&m(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 Ot(this.app)?Promise.reject(gs(this)):(await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0))}setPersistence(e){return Ot(this.app)?Promise.reject(gs(this)):this.queue(async()=>{await this.assertedPersistence.setPersistence(ea(e))})}_getRecaptchaConfig(){return null==this.tenantId?this._agentRecaptchaConfig:this._tenantRecaptchaConfigs[this.tenantId]}async validatePassword(e){this._getPasswordPolicyInternal()||await this._updatePasswordPolicy();var 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(){var e,t=await Rs(e=this,"GET","/v2/passwordPolicy",Ns(e,{})),t=new va(t);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 ge("auth","Firebase",e())}onAuthStateChanged(e,t,r){return this.registerStateListener(this.authStateSubscription,e,t,r)}beforeAuthStateChanged(e,t){return this.beforeStateQueue.pushCallback(e,t)}onIdTokenChanged(e,t,r){return this.registerStateListener(this.idTokenSubscription,e,t,r)}authStateReady(){return new Promise((t,r)=>{if(this.currentUser)t();else{let e=this.onAuthStateChanged(()=>{e(),t()},r)}})}async revokeAccessToken(e){var t;this.currentUser&&(t={providerId:"apple.com",tokenType:"ACCESS_TOKEN",token:e,idToken:await this.currentUser.getIdToken()},null!=this.tenantId&&(t.tenantId=this.tenantId),await Rs(e=this,"POST","/v2/accounts:revokeToken",Ns(e,t)))}toJSON(){return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:this._currentUser?.toJSON()}}async _setRedirectUser(e,t){var r=await this.getOrInitRedirectPersistenceManager(t);return null===e?r.removeCurrentUser():r.setCurrentUser(e)}async getOrInitRedirectPersistenceManager(e){var t;return this.redirectPersistenceManager||(m(t=e&&ea(e)||this._popupRedirectResolver,this,"argument-error"),this.redirectPersistenceManager=await ia.create(this,[ea(t._redirectPersistence)],"redirectUser"),this.redirectUser=await this.redirectPersistenceManager.getCurrentUser()),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(){var e;this._isInitialized&&(this.idTokenSubscription.next(this.currentUser),e=this.currentUser?.uid??null,this.lastNotifiedUid!==e)&&(this.lastNotifiedUid=e,this.authStateSubscription.next(this.currentUser))}registerStateListener(t,r,n,i){if(this._deleted)return()=>{};let e="function"==typeof r?r:r.next.bind(r),s=!1;var a=this._isInitialized?Promise.resolve():this._initializationPromise;if(m(a,this,"internal-error"),a.then(()=>{s||e(this.currentUser)}),"function"==typeof r){let e=t.addObserver(r,n,i);return()=>{s=!0,e()}}{let e=t.addObserver(r);return()=>{s=!0,e()}}}async directlySetCurrentUser(e){this.currentUser&&this.currentUser!==e&&this._currentUser._stopProactiveRefresh(),e&&this.isProactiveRefreshEnabled&&e._startProactiveRefresh(),(this.currentUser=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 m(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(e){e&&!this.frameworks.includes(e)&&(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=ga(this.config.clientPlatform,this._getFrameworks()))}_getFrameworks(){return this.frameworks}async _getAdditionalHeaders(){var e={"X-Client-Version":this.clientVersion},t=(this.app.options.appId&&(e["X-Firebase-gmpid"]=this.app.options.appId),await this.heartbeatServiceProvider.getImmediate({optional:!0})?.getHeartbeatsHeader()),t=(t&&(e["X-Firebase-Client"]=t),await this._getAppCheckToken());return t&&(e["X-Firebase-AppCheck"]=t),e}async _getAppCheckToken(){var e,t,r;return Ot(this.app)&&this.app.settings.appCheckToken?this.app.settings.appCheckToken:((e=await this.appCheckServiceProvider.getImmediate({optional:!0})?.getToken())?.error&&(t="Error while retrieving App Check token: "+e.error,r=[],hs.logLevel<=p.WARN)&&hs.warn(`Auth (${Vt}): `+t,...r),e?.token)}}function ya(e){return w(e)}class wa{constructor(e){this.auth=e,this.observer=null,this.addObserver=Re(e=>this.observer=e)}get next(){return m(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}let ba={async loadJS(){throw new Error("Unable to load external scripts")},recaptchaV2Script:"",recaptchaEnterpriseScript:"",gapiScript:""};function Ta(e){return ba.loadJS(e)}function Ea(e){return"__"+e+Math.floor(1e6*Math.random())}class Ia{constructor(e){this.auth=e,this.counter=1e12,this._widgets=new Map}render(e,t){var r=this.counter;return this._widgets.set(r,new ka(e,this.auth.name,t||{})),this.counter++,r}reset(e){var t=e||1e12;this._widgets.get(t)?.delete(),this._widgets.delete(t)}getResponse(e){return this._widgets.get(e||1e12)?.getResponse()||""}async execute(e){return this._widgets.get(e||1e12)?.execute(),""}}class Ca{constructor(){this.enterprise=new Sa}ready(e){e()}execute(e,t){return Promise.resolve("token")}render(e,t){return""}}class Sa{ready(e){e()}execute(e,t){return Promise.resolve("token")}render(e,t){return""}}class ka{constructor(e,t,r){this.params=r,this.timerId=null,this.deleted=!1,this.responseToken=null,this.clickHandler=()=>{this.execute()};var n="string"==typeof e?document.getElementById(e):e;m(n,"argument-error",{appName:t}),this.container=n,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=(e=>{var t=[],r="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";for(let n=0;n<e;n++)t.push(r.charAt(Math.floor(Math.random()*r.length)));return t.join("")})(50);let{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!")}}let Aa="NO_RECAPTCHA",Na="onFirebaseAuthREInstanceReady";class Ra{constructor(e){this.type="recaptcha-enterprise",this.auth=ya(e)}async verify(i="verify",e=!1){function s(e,t,r){let n=window.grecaptcha;Fs(n)?n.enterprise.ready(()=>{n.enterprise.execute(e,{action:i}).then(e=>{t(e)}).catch(()=>{t(Aa)})}):r(Error("No reCAPTCHA enterprise script loaded."))}return this.auth.settings.appVerificationDisabledForTesting?(new Ca).execute("siteKey",{action:"verify"}):new Promise((r,n)=>{(async i=>{if(!e){if(null==i.tenantId&&null!=i._agentRecaptchaConfig)return i._agentRecaptchaConfig.siteKey;if(null!=i.tenantId&&void 0!==i._tenantRecaptchaConfigs[i.tenantId])return i._tenantRecaptchaConfigs[i.tenantId].siteKey}return new Promise(async(r,n)=>{Vs(i,{clientType:"CLIENT_TYPE_WEB",version:"RECAPTCHA_ENTERPRISE"}).then(e=>{var t;if(void 0!==e.recaptchaKey)return t=new Us(e),null==i.tenantId?i._agentRecaptchaConfig=t:i._tenantRecaptchaConfigs[i.tenantId]=t,r(t.siteKey);n(new Error("recaptcha Enterprise site key undefined"))}).catch(e=>{n(e)})})})(this.auth).then(async t=>{if(!e&&Fs(window.grecaptcha)&&Ra.scriptInjectionDeferred)await Ra.scriptInjectionDeferred.promise,s(t,r,n);else if("undefined"==typeof window)n(new Error("RecaptchaVerifier is only supported in browser"));else{let e=ba.recaptchaEnterpriseScript;0!==e.length&&(e+=t+("&onload="+Na)),Ra.scriptInjectionDeferred=new Z,window[Na]=()=>{Ra.scriptInjectionDeferred?.resolve()},Ta(e).then(()=>Ra.scriptInjectionDeferred?.promise).then(()=>{s(t,r,n)}).catch(e=>{n(e)})}}).catch(e=>{n(e)})})}}async function Pa(e,t,r,n=!1,i=!1){var s=new Ra(e);let a;if(i)a=Aa;else try{a=await s.verify(r)}catch(e){a=await s.verify(r,!0)}var o,l,s={...t};return"mfaSmsEnrollment"===r||"mfaSmsSignIn"===r?"phoneEnrollmentInfo"in s?(l=s.phoneEnrollmentInfo.phoneNumber,o=s.phoneEnrollmentInfo.recaptchaToken,Object.assign(s,{phoneEnrollmentInfo:{phoneNumber:l,recaptchaToken:o,captchaResponse:a,clientType:"CLIENT_TYPE_WEB",recaptchaVersion:"RECAPTCHA_ENTERPRISE"}})):"phoneSignInInfo"in s&&(l=s.phoneSignInInfo.recaptchaToken,Object.assign(s,{phoneSignInInfo:{recaptchaToken:l,captchaResponse:a,clientType:"CLIENT_TYPE_WEB",recaptchaVersion:"RECAPTCHA_ENTERPRISE"}})):(n?Object.assign(s,{captchaResp:a}):Object.assign(s,{captchaResponse:a}),Object.assign(s,{clientType:"CLIENT_TYPE_WEB"}),Object.assign(s,{recaptchaVersion:"RECAPTCHA_ENTERPRISE"})),s}async function xa(r,n,i,s,e){var t;return"EMAIL_PASSWORD_PROVIDER"===e?r._getRecaptchaConfig()?.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")?(t=await Pa(r,n,i,"getOobCode"===i),s(r,t)):s(r,n).catch(async e=>{var t;return"auth/missing-recaptcha-token"===e.code?(console.log(i+" is protected by reCAPTCHA Enterprise for this project. Automatically triggering the reCAPTCHA flow and restarting the flow."),t=await Pa(r,n,i,"getOobCode"===i),s(r,t)):Promise.reject(e)}):"PHONE_PROVIDER"===e?r._getRecaptchaConfig()?.isProviderEnabled("PHONE_PROVIDER")?(t=await Pa(r,n,i),s(r,t).catch(async e=>{var t;if("AUDIT"===r._getRecaptchaConfig()?.getProviderEnforcementState("PHONE_PROVIDER")&&("auth/missing-recaptcha-token"===e.code||"auth/invalid-app-credential"===e.code))return console.log(`Failed to verify with reCAPTCHA Enterprise. Automatically triggering the reCAPTCHA v2 flow to complete the ${i} flow.`),t=await Pa(r,n,i,!1,!0),s(r,t);return Promise.reject(e)})):(t=await Pa(r,n,i,!1,!0),s(r,t)):Promise.reject(e+" provider is not supported.")}function Da(e,t,r){var n=ya(e),i=(m(/^https?:\/\//.test(t),n,"invalid-emulator-scheme"),!!r?.disableWarnings),s=Oa(t),{host:a,port:o}=(e=>{var t,r=Oa(e);return(r=/(\/\/)?([^?#/]+)/.exec(e.substr(r.length)))?(r=r[2].split("@").pop()||"",(t=/^(\[[^\]]+\])(:|$)/.exec(r))?{host:t=t[1],port:La(r.substr(t.length+1))}:([t,r]=r.split(":"),{host:t,port:La(r)})):{host:"",port:null}})(t),l=null===o?"":":"+o,u={url:s+`//${a}${l}/`},o=Object.freeze({host:a,port:o,protocol:s.replace(":",""),options:Object.freeze({disableWarnings:i})});function h(){var e=document.createElement("p"),t=e.style;e.innerText="Running in emulator mode. Do not use with production credentials.",t.position="fixed",t.width="100%",t.backgroundColor="#ffffff",t.border=".1em solid #000000",t.color="#b50000",t.bottom="0px",t.left="0px",t.margin="0px",t.zIndex="10000",t.textAlign="center",e.classList.add("firebase-emulator-warning"),document.body.appendChild(e)}n._canInitEmulator?(n.config.emulator=u,n.emulatorConfig=o,n.settings.appVerificationDisabledForTesting=!0,ze(a)?He(s+"//"+a+l):i||("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",h):h()))):(m(n.config.emulator&&n.emulatorConfig,n,"emulator-config-failed"),m(Ie(u,n.config.emulator)&&Ie(o,n.emulatorConfig),n,"emulator-config-failed"))}function Oa(e){var t=e.indexOf(":");return t<0?"":e.substr(0,t+1)}function La(e){var t;return!e||(t=Number(e),isNaN(t))?null:t}Ra.scriptInjectionDeferred=null;class Ma{constructor(e,t){this.providerId=e,this.signInMethod=t}toJSON(){return _s("not implemented")}_getIdTokenResponse(e){return _s("not implemented")}_linkToIdToken(e,t){return _s("not implemented")}_getReauthenticationResolver(e){return _s("not implemented")}}async function Fa(e,t){return Rs(e,"POST","/v1/accounts:resetPassword",Ns(e,t))}async function Ua(e,t){return Rs(e,"POST","/v1/accounts:signUp",t)}async function Va(e,t){return xs(e,"POST","/v1/accounts:signInWithPassword",Ns(e,t))}async function Ba(e,t){return Rs(e,"POST","/v1/accounts:sendOobCode",Ns(e,t))}async function qa(e,t){return Ba(e,t)}async function ja(e,t){return Ba(e,t)}class za extends Ma{constructor(e,t,r,n=null){super("password",r),this._email=e,this._password=t,this._tenantId=n}static _fromEmailAndPassword(e,t){return new za(e,t,"password")}static _fromEmailAndCode(e,t,r=null){return new za(e,t,"emailLink",r)}toJSON(){return{email:this._email,password:this._password,signInMethod:this.signInMethod,tenantId:this._tenantId}}static fromJSON(e){var 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 xa(e,{returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"},"signInWithPassword",Va,"EMAIL_PASSWORD_PROVIDER");case"emailLink":return(async(e,t)=>xs(e,"POST","/v1/accounts:signInWithEmailLink",Ns(e,t)))(e,{email:this._email,oobCode:this._password});default:ds(e,"internal-error")}}async _linkToIdToken(e,t){switch(this.signInMethod){case"password":return xa(e,{idToken:t,returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"},"signUpPassword",Ua,"EMAIL_PASSWORD_PROVIDER");case"emailLink":return(async(e,t)=>xs(e,"POST","/v1/accounts:signInWithEmailLink",Ns(e,t)))(e,{idToken:t,email:this._email,oobCode:this._password});default:ds(e,"internal-error")}}_getReauthenticationResolver(e){return this._getIdTokenResponse(e)}}async function Ha(e,t){return xs(e,"POST","/v1/accounts:signInWithIdp",Ns(e,t))}class Ka extends Ma{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(e){var t=new Ka(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):ds("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){var t;let{providerId:r,signInMethod:n,...i}="string"==typeof e?JSON.parse(e):e;return r&&n?((t=new Ka(r,n)).idToken=i.idToken||void 0,t.accessToken=i.accessToken||void 0,t.secret=i.secret,t.nonce=i.nonce,t.pendingToken=i.pendingToken||null,t):null}_getIdTokenResponse(e){return Ha(e,this.buildRequest())}_linkToIdToken(e,t){var r=this.buildRequest();return r.idToken=t,Ha(e,r)}_getReauthenticationResolver(e){var t=this.buildRequest();return t.autoCreate=!1,Ha(e,t)}buildRequest(){var e,t={requestUri:"http://localhost",returnSecureToken:!0};return this.pendingToken?t.pendingToken=this.pendingToken:(e={},this.idToken&&(e.id_token=this.idToken),this.accessToken&&(e.access_token=this.accessToken),this.secret&&(e.oauth_token_secret=this.secret),e.providerId=this.providerId,this.nonce&&!this.pendingToken&&(e.nonce=this.nonce),t.postBody=Se(e)),t}}async function Ga(e,t){return Rs(e,"POST","/v1/accounts:sendVerificationCode",Ns(e,t))}let Wa={USER_NOT_FOUND:"user-not-found"};class $a extends Ma{constructor(e){super("phone","phone"),this.params=e}static _fromVerification(e,t){return new $a({verificationId:e,verificationCode:t})}static _fromTokenResponse(e,t){return new $a({phoneNumber:e,temporaryProof:t})}_getIdTokenResponse(e){return(async(e,t)=>xs(e,"POST","/v1/accounts:signInWithPhoneNumber",Ns(e,t)))(e,this._makeVerificationRequest())}_linkToIdToken(e,t){return(async(e,t)=>{var r=await xs(e,"POST","/v1/accounts:signInWithPhoneNumber",Ns(e,t));if(r.temporaryProof)throw Ls(e,"account-exists-with-different-credential",r);return r})(e,{idToken:t,...this._makeVerificationRequest()})}_getReauthenticationResolver(e){return(async(e,t)=>xs(e,"POST","/v1/accounts:signInWithPhoneNumber",Ns(e,{...t,operation:"REAUTH"}),Wa))(e,this._makeVerificationRequest())}_makeVerificationRequest(){var{temporaryProof:e,phoneNumber:t,verificationId:r,verificationCode:n}=this.params;return e&&t?{temporaryProof:e,phoneNumber:t}:{sessionInfo:r,code:n}}toJSON(){var e={providerId:this.providerId};return this.params.phoneNumber&&(e.phoneNumber=this.params.phoneNumber),this.params.temporaryProof&&(e.temporaryProof=this.params.temporaryProof),this.params.verificationCode&&(e.verificationCode=this.params.verificationCode),this.params.verificationId&&(e.verificationId=this.params.verificationId),e}static fromJSON(e){var{verificationId:t,verificationCode:r,phoneNumber:n,temporaryProof:i}=e="string"==typeof e?JSON.parse(e):e;return r||t||n||i?new $a({verificationId:t,verificationCode:r,phoneNumber:n,temporaryProof:i}):null}}class Ya{constructor(e){var t=ke(Ae(e)),r=t.apiKey??null,n=t.oobCode??null,i=(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);m(r&&n&&i,"argument-error"),this.apiKey=r,this.operation=i,this.code=n,this.continueUrl=t.continueUrl??null,this.languageCode=t.lang??null,this.tenantId=t.tenantId??null}static parseLink(e){t=ke(Ae(e=e)).link,r=t?ke(Ae(t)).deep_link_id:null;var t,r,n=((n=ke(Ae(e)).deep_link_id)?ke(Ae(n)).link:null)||n||r||t||e;try{return new Ya(n)}catch{return null}}}class Qa{constructor(){this.providerId=Qa.PROVIDER_ID}static credential(e,t){return za._fromEmailAndPassword(e,t)}static credentialWithLink(e,t){var r=Ya.parseLink(t);return m(r,"argument-error"),za._fromEmailAndCode(e,r.code,r.tenantId)}}Qa.PROVIDER_ID="password",Qa.EMAIL_PASSWORD_SIGN_IN_METHOD="password",Qa.EMAIL_LINK_SIGN_IN_METHOD="emailLink";class Ja{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 Xa extends Ja{constructor(){super(...arguments),this.scopes=[]}addScope(e){return this.scopes.includes(e)||this.scopes.push(e),this}getScopes(){return[...this.scopes]}}class Za extends Xa{static credentialFromJSON(e){var t="string"==typeof e?JSON.parse(e):e;return m("providerId"in t&&"signInMethod"in t,"argument-error"),Ka._fromParams(t)}credential(e){return this._credential({...e,nonce:e.rawNonce})}_credential(e){return m(e.idToken||e.accessToken,"argument-error"),Ka._fromParams({...e,providerId:this.providerId,signInMethod:this.providerId})}static credentialFromResult(e){return Za.oauthCredentialFromTaggedObject(e)}static credentialFromError(e){return Za.oauthCredentialFromTaggedObject(e.customData||{})}static oauthCredentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;var{oauthIdToken:t,oauthAccessToken:r,oauthTokenSecret:n,pendingToken:i,nonce:s,providerId:a}=e;if(!(r||n||t||i))return null;if(!a)return null;try{return new Za(a)._credential({idToken:t,accessToken:r,nonce:s,pendingToken:i})}catch(e){return null}}}class eo extends Xa{constructor(){super("facebook.com")}static credential(e){return Ka._fromParams({providerId:eo.PROVIDER_ID,signInMethod:eo.FACEBOOK_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return eo.credentialFromTaggedObject(e)}static credentialFromError(e){return eo.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!(e&&"oauthAccessToken"in e))return null;if(!e.oauthAccessToken)return null;try{return eo.credential(e.oauthAccessToken)}catch{return null}}}eo.FACEBOOK_SIGN_IN_METHOD="facebook.com",eo.PROVIDER_ID="facebook.com";class to extends Xa{constructor(){super("google.com"),this.addScope("profile")}static credential(e,t){return Ka._fromParams({providerId:to.PROVIDER_ID,signInMethod:to.GOOGLE_SIGN_IN_METHOD,idToken:e,accessToken:t})}static credentialFromResult(e){return to.credentialFromTaggedObject(e)}static credentialFromError(e){return to.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;var{oauthIdToken:t,oauthAccessToken:r}=e;if(!t&&!r)return null;try{return to.credential(t,r)}catch{return null}}}to.GOOGLE_SIGN_IN_METHOD="google.com",to.PROVIDER_ID="google.com";class ro extends Xa{constructor(){super("github.com")}static credential(e){return Ka._fromParams({providerId:ro.PROVIDER_ID,signInMethod:ro.GITHUB_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return ro.credentialFromTaggedObject(e)}static credentialFromError(e){return ro.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!(e&&"oauthAccessToken"in e))return null;if(!e.oauthAccessToken)return null;try{return ro.credential(e.oauthAccessToken)}catch{return null}}}ro.GITHUB_SIGN_IN_METHOD="github.com",ro.PROVIDER_ID="github.com";class no extends Ma{constructor(e,t){super(e,e),this.pendingToken=t}_getIdTokenResponse(e){return Ha(e,this.buildRequest())}_linkToIdToken(e,t){var r=this.buildRequest();return r.idToken=t,Ha(e,r)}_getReauthenticationResolver(e){var t=this.buildRequest();return t.autoCreate=!1,Ha(e,t)}toJSON(){return{signInMethod:this.signInMethod,providerId:this.providerId,pendingToken:this.pendingToken}}static fromJSON(e){var{providerId:t,signInMethod:r,pendingToken:n}="string"==typeof e?JSON.parse(e):e;return t&&r&&n&&t===r?new no(t,n):null}static _create(e,t){return new no(e,t)}buildRequest(){return{requestUri:"http://localhost",returnSecureToken:!0,pendingToken:this.pendingToken}}}class io extends Ja{constructor(e){m(e.startsWith("saml."),"argument-error"),super(e)}static credentialFromResult(e){return io.samlCredentialFromTaggedObject(e)}static credentialFromError(e){return io.samlCredentialFromTaggedObject(e.customData||{})}static credentialFromJSON(e){var t=no.fromJSON(e);return m(t,"argument-error"),t}static samlCredentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;var{pendingToken:t,providerId:r}=e;if(!t||!r)return null;try{return no._create(r,t)}catch(e){return null}}}class so extends Xa{constructor(){super("twitter.com")}static credential(e,t){return Ka._fromParams({providerId:so.PROVIDER_ID,signInMethod:so.TWITTER_SIGN_IN_METHOD,oauthToken:e,oauthTokenSecret:t})}static credentialFromResult(e){return so.credentialFromTaggedObject(e)}static credentialFromError(e){return so.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;var{oauthAccessToken:t,oauthTokenSecret:r}=e;if(!t||!r)return null;try{return so.credential(t,r)}catch{return null}}}async function ao(e,t){return xs(e,"POST","/v1/accounts:signUp",Ns(e,t))}so.TWITTER_SIGN_IN_METHOD="twitter.com",so.PROVIDER_ID="twitter.com";class oo{constructor(e){this.user=e.user,this.providerId=e.providerId,this._tokenResponse=e._tokenResponse,this.operationType=e.operationType}static async _fromIdTokenResponse(e,t,r,n=!1){var i=await Xs._fromIdTokenResponse(e,r,n),s=lo(r);return new oo({user:i,providerId:s,_tokenResponse:r,operationType:t})}static async _forOperation(e,t,r){await e._updateTokensIfNecessary(r,!0);var n=lo(r);return new oo({user:e,providerId:n,_tokenResponse:r,operationType:t})}}function lo(e){return e.providerId||("phoneNumber"in e?"phone":null)}class uo extends fe{constructor(e,t,r,n){super(t.code,t.message),this.operationType=r,this.user=n,Object.setPrototypeOf(this,uo.prototype),this.customData={appName:e.name,tenantId:e.tenantId??void 0,_serverResponse:t.customData._serverResponse,operationType:r}}static _fromErrorAndOperation(e,t,r,n){return new uo(e,t,r,n)}}function ho(t,r,e,n){return("reauthenticate"===r?e._getReauthenticationResolver(t):e._getIdTokenResponse(t)).catch(e=>{if("auth/multi-factor-auth-required"===e.code)throw uo._fromErrorAndOperation(t,e,r,n);throw e})}function co(e){return new Set(e.map(({providerId:e})=>e).filter(e=>!!e))}async function po(e,t){var r=w(e),n=(await go(!0,r,t),e=r.auth,t={idToken:await r.getIdToken(),deleteProvider:[t]},await Rs(e,"POST","/v1/accounts:update",t)).providerUserInfo;let i=co(n||[]);return r.providerData=r.providerData.filter(e=>i.has(e.providerId)),i.has("phone")||(r.phoneNumber=null),await r.auth._persistUserIfCurrent(r),r}async function fo(e,t,r=!1){var n=await Ks(e,t._linkToIdToken(e.auth,await e.getIdToken()),r);return oo._forOperation(e,"link",n)}async function go(e,t,r){await $s(t);var n=!1===e?"provider-already-linked":"no-such-provider";m(co(t.providerData).has(r)===e,t.auth,n)}async function mo(e,t,r=!1){var n=e.auth;if(Ot(n.app))return Promise.reject(gs(n));var i="reauthenticate";try{var s=await Ks(e,ho(n,i,t,e),r),a=(m(s.idToken,n,"internal-error"),zs(s.idToken)),o=(m(a,n,"internal-error"),a).sub;return m(e.uid===o,n,"user-mismatch"),oo._forOperation(e,i,s)}catch(e){throw"auth/user-not-found"===e?.code&&ds(n,"user-mismatch"),e}}async function vo(e,t,r=!1){var n;return Ot(e.app)?Promise.reject(gs(e)):(n=await ho(e,"signIn",t),n=await oo._fromIdTokenResponse(e,"signIn",n),r||await e._updateCurrentUser(n.user),n)}async function _o(e,t){return vo(ya(e),t)}async function yo(e,t){var r=w(e);return await go(!1,r,t.providerId),fo(r,t)}async function wo(e,t){return mo(w(e),t)}async function bo(e,t){var r,n;return Ot(e.app)?Promise.reject(gs(e)):(n=await xs(r=ya(e),"POST","/v1/accounts:signInWithCustomToken",Ns(r,{token:t,returnSecureToken:!0})),n=await oo._fromIdTokenResponse(r,"signIn",n),await r._updateCurrentUser(n.user),n)}class To{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?Eo._fromServerResponse(e,t):"totpInfo"in t?Io._fromServerResponse(e,t):ds(e,"internal-error")}}class Eo extends To{constructor(e){super("phone",e),this.phoneNumber=e.phoneInfo}static _fromServerResponse(e,t){return new Eo(t)}}class Io extends To{constructor(e){super("totp",e)}static _fromServerResponse(e,t){return new Io(t)}}function Co(e,t,r){m(0<r.url?.length,e,"invalid-continue-uri"),m(void 0===r.dynamicLinkDomain||0<r.dynamicLinkDomain.length,e,"invalid-dynamic-link-domain"),m(void 0===r.linkDomain||0<r.linkDomain.length,e,"invalid-hosting-link-domain"),t.continueUrl=r.url,t.dynamicLinkDomain=r.dynamicLinkDomain,t.linkDomain=r.linkDomain,t.canHandleCodeInApp=r.handleCodeInApp,r.iOS&&(m(0<r.iOS.bundleId.length,e,"missing-ios-bundle-id"),t.iOSBundleId=r.iOS.bundleId),r.android&&(m(0<r.android.packageName.length,e,"missing-android-pkg-name"),t.androidInstallApp=r.android.installApp,t.androidMinimumVersionCode=r.android.minimumVersion,t.androidPackageName=r.android.packageName)}async function So(e){var t=ya(e);t._getPasswordPolicyInternal()&&await t._updatePasswordPolicy()}async function ko(e,t){await Rs(e=w(e),"POST","/v1/accounts:update",Ns(e,{oobCode:t}))}async function Ao(e,t){var r=w(e),n=await Fa(r,{oobCode:t}),i=n.requestType;switch(m(i,r,"internal-error"),i){case"EMAIL_SIGNIN":break;case"VERIFY_AND_CHANGE_EMAIL":m(n.newEmail,r,"internal-error");break;case"REVERT_SECOND_FACTOR_ADDITION":m(n.mfaInfo,r,"internal-error");default:m(n.email,r,"internal-error")}let s=null;return n.mfaInfo&&(s=To._fromServerResponse(ya(r),n.mfaInfo)),{data:{email:("VERIFY_AND_CHANGE_EMAIL"===n.requestType?n.newEmail:n.email)||null,previousEmail:("VERIFY_AND_CHANGE_EMAIL"===n.requestType?n.email:n.newEmail)||null,multiFactorInfo:s},operation:i}}async function No(e,t){var r=bs()?ws():"http://localhost",r=(await Rs(e=w(e),"POST","/v1/accounts:createAuthUri",Ns(e,{identifier:t,continueUri:r}))).signinMethods;return r||[]}async function Ro(e,t){var r=w(e),n={requestType:"VERIFY_EMAIL",idToken:await e.getIdToken()},r=(t&&Co(r.auth,n,t),await Ba(r.auth,n)).email;r!==e.email&&await e.reload()}async function Po(e,t,r){var n=w(e),i={requestType:"VERIFY_AND_CHANGE_EMAIL",idToken:await e.getIdToken(),newEmail:t},n=(r&&Co(n.auth,i,r),await Ba(n.auth,i)).email;n!==e.email&&await e.reload()}async function xo(e,{displayName:t,photoURL:r}){var n,i,s;void 0===t&&void 0===r||(i=await(n=w(e)).getIdToken(),i=await Ks(n,(async(e,t)=>Rs(e,"POST","/v1/accounts:update",t))(n.auth,{idToken:i,displayName:t,photoUrl:r,returnSecureToken:!0})),n.displayName=i.displayName||null,n.photoURL=i.photoUrl||null,(s=n.providerData.find(({providerId:e})=>"password"===e))&&(s.displayName=n.displayName,s.photoURL=n.photoURL),await n._updateTokensIfNecessary(i))}async function Do(e,t,r){var n=e.auth,i={idToken:await e.getIdToken(),returnSecureToken:!0},n=(t&&(i.email=t),r&&(i.password=r),await Ks(e,(async(e,t)=>Rs(e,"POST","/v1/accounts:update",t))(n,i)));await e._updateTokensIfNecessary(n,!0)}class Oo{constructor(e,t,r={}){this.isNewUser=e,this.providerId=t,this.profile=r}}class Lo extends Oo{constructor(e,t,r,n){super(e,t,r),this.username=n}}class Mo extends Oo{constructor(e,t){super(e,"facebook.com",t)}}class Fo extends Lo{constructor(e,t){super(e,"github.com",t,"string"==typeof t?.login?t?.login:null)}}class Uo extends Oo{constructor(e,t){super(e,"google.com",t)}}class Vo extends Lo{constructor(e,t,r){super(e,"twitter.com",t,r)}}function Bo(e){var{user:t,_tokenResponse:r}=e;if(t.isAnonymous&&!r)return{providerId:null,isNewUser:!1,profile:null};var n=r;if(!n)return null;var i=n.providerId,s=n.rawUserInfo?JSON.parse(n.rawUserInfo):{},a=n.isNewUser||"identitytoolkit#SignupNewUserResponse"===n.kind;if(!i&&n?.idToken){t=zs(n.idToken)?.firebase?.sign_in_provider;if(t)return t="anonymous"!==t&&"custom"!==t?t:null,new Oo(a,t)}if(!i)return null;switch(i){case"facebook.com":return new Mo(a,s);case"github.com":return new Fo(a,s);case"google.com":return new Uo(a,s);case"twitter.com":return new Vo(a,s,n.screenName||null);case"custom":case"anonymous":return new Oo(a,null);default:return new Oo(a,i,s)}}class qo{constructor(e,t,r){this.type=e,this.credential=t,this.user=r}static _fromIdtoken(e,t){return new qo("enroll",e,t)}static _fromMfaPendingCredential(e){return new qo("signin",e)}toJSON(){return{multiFactorSession:{["enroll"===this.type?"idToken":"pendingCredential"]:this.credential}}}static fromJSON(e){if(e?.multiFactorSession){if(e.multiFactorSession?.pendingCredential)return qo._fromMfaPendingCredential(e.multiFactorSession.pendingCredential);if(e.multiFactorSession?.idToken)return qo._fromIdtoken(e.multiFactorSession.idToken)}return null}}class jo{constructor(e,t,r){this.session=e,this.hints=t,this.signInResolver=r}static _fromError(e,i){let s=ya(e),a=i.customData._serverResponse;var t=(a.mfaInfo||[]).map(e=>To._fromServerResponse(s,e));m(a.mfaPendingCredential,s,"internal-error");let o=qo._fromMfaPendingCredential(a.mfaPendingCredential);return new jo(o,t,async e=>{var t=await e._process(s,o),r=(delete a.mfaInfo,delete a.mfaPendingCredential,{...a,idToken:t.idToken,refreshToken:t.refreshToken});switch(i.operationType){case"signIn":var n=await oo._fromIdTokenResponse(s,i.operationType,r);return await s._updateCurrentUser(n.user),n;case"reauthenticate":return m(i.user,s,"internal-error"),oo._forOperation(i.user,i.operationType,r);default:ds(s,"internal-error")}})}async resolveSignIn(e){return this.signInResolver(e)}}function zo(e,t){return Rs(e,"POST","/v2/accounts/mfaEnrollment:start",Ns(e,t))}class Ho{constructor(t){this.user=t,this.enrolledFactors=[],t._onReload(e=>{e.mfaInfo&&(this.enrolledFactors=e.mfaInfo.map(e=>To._fromServerResponse(t.auth,e)))})}static _fromUser(e){return new Ho(e)}async getSession(){return qo._fromIdtoken(await this.user.getIdToken(),this.user)}async enroll(e,t){var r=e,n=await this.getSession(),r=await Ks(this.user,r._process(this.user.auth,n,t));return await this.user._updateTokensIfNecessary(r),this.user.reload()}async unenroll(e){let t="string"==typeof e?e:e.uid;var r,n,i=await this.user.getIdToken();try{var s=await Ks(this.user,(r=this.user.auth,n={idToken:i,mfaEnrollmentId:t},Rs(r,"POST","/v2/accounts/mfaEnrollment:withdraw",Ns(r,n))));this.enrolledFactors=this.enrolledFactors.filter(({uid:e})=>e!==t),await this.user._updateTokensIfNecessary(s),await this.user.reload()}catch(e){throw e}}}let Ko=new WeakMap;let Go="__sak";class Wo{constructor(e,t){this.storageRetriever=e,this.type=t}_isAvailable(){try{return this.storage?(this.storage.setItem(Go,"1"),this.storage.removeItem(Go),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){var 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 $o extends Wo{constructor(){super(()=>window.localStorage,"LOCAL"),this.boundEventHandler=(e,t)=>this.onStorageEvent(e,t),this.listeners={},this.localCache={},this.pollTimer=null,this.fallbackToPolling=fa(),this._shouldAllowMigration=!0}forAllChangedKeys(e){for(var t of Object.keys(this.listeners)){var r=this.storage.getItem(t),n=this.localCache[t];r!==n&&e(t,n,r)}}onStorageEvent(e,r=!1){if(e.key){let t=e.key;r?this.detachListener():this.stopPolling();var n=()=>{var e=this.storage.getItem(t);!r&&this.localCache[t]===e||this.notifyListeners(t,e)},i=this.storage.getItem(t);oe()&&10===document.documentMode&&i!==e.newValue&&e.newValue!==e.oldValue?setTimeout(n,10):n()}else this.forAllChangedKeys((e,t,r)=>{this.notifyListeners(e,r)})}notifyListeners(e,t){this.localCache[e]=t;var r=this.listeners[e];if(r)for(var n of Array.from(r))n(t&&JSON.parse(t))}startPolling(){this.stopPolling(),this.pollTimer=setInterval(()=>{this.forAllChangedKeys((e,t,r)=>{this.onStorageEvent(new StorageEvent("storage",{key:e,oldValue:t,newValue:r}),!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){var t=await super._get(e);return this.localCache[e]=JSON.stringify(t),t}async _remove(e){await super._remove(e),delete this.localCache[e]}}$o.type="LOCAL";let Yo=$o;class Qo extends Wo{constructor(){super(()=>window.sessionStorage,"SESSION")}_addListener(e,t){}_removeListener(e,t){}}Qo.type="SESSION";let Jo=Qo;class Xo{constructor(e){this.eventTarget=e,this.handlersMap={},this.boundEventHandler=this.handleEvent.bind(this)}static _getInstance(t){var e=this.receivers.find(e=>e.isListeningto(t));return e||(e=new Xo(t),this.receivers.push(e),e)}isListeningto(e){return this.eventTarget===e}async handleEvent(e){let t=e,{eventId:r,eventType:n,data:i}=t.data;var s=this.handlersMap[n];s?.size&&(t.ports[0].postMessage({status:"ack",eventId:r,eventType:n}),s=Array.from(s).map(async e=>e(t.origin,i)),s=await Promise.all(s.map(async e=>{try{return{fulfilled:!0,value:await e}}catch(e){return{fulfilled:!1,reason:e}}})),t.ports[0].postMessage({status:"done",eventId:r,eventType:n,response:s}))}_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 Zo(e="",t=10){let r="";for(let n=0;n<t;n++)r+=Math.floor(10*Math.random());return e+r}Xo.receivers=[];class el{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,a=50){let o="undefined"!=typeof MessageChannel?new MessageChannel:null;if(!o)throw new Error("connection_unavailable");let l,u;return new Promise((r,n)=>{let i=Zo("",20),s=(o.port1.start(),setTimeout(()=>{n(new Error("unsupported_event"))},a));u={messageChannel:o,onMessage(e){var t=e;if(t.data.eventId===i)switch(t.data.status){case"ack":clearTimeout(s),l=setTimeout(()=>{n(new Error("timeout"))},3e3);break;case"done":clearTimeout(l),r(t.data.response);break;default:clearTimeout(s),clearTimeout(l),n(new Error("invalid_response"))}}},this.handlers.add(u),o.port1.addEventListener("message",u.onMessage),this.target.postMessage({eventType:e,eventId:i,data:t},[o.port2])}).finally(()=>{u&&this.removeMessageHandler(u)})}}function tl(){return window}function rl(){return void 0!==tl().WorkerGlobalScope&&"function"==typeof tl().importScripts}let nl="firebaseLocalStorageDb",il=1,sl="firebaseLocalStorage",al="fbase_key";class ol{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 ll(e,t){return e.transaction([sl],t?"readwrite":"readonly").objectStore(sl)}function ul(){let n=indexedDB.open(nl,il);return new Promise((t,r)=>{n.addEventListener("error",()=>{r(n.error)}),n.addEventListener("upgradeneeded",()=>{var e=n.result;try{e.createObjectStore(sl,{keyPath:al})}catch(e){r(e)}}),n.addEventListener("success",async()=>{var e=n.result;e.objectStoreNames.contains(sl)?t(e):(e.close(),e=indexedDB.deleteDatabase(nl),await new ol(e).toPromise(),t(await ul()))})})}async function hl(e,t,r){var n=ll(e,!0).put({[al]:t,value:r});return new ol(n).toPromise()}function cl(e,t){var r=ll(e,!0).delete(t);return new ol(r).toPromise()}class dl{constructor(){this.type="LOCAL",this.dbPromise=null,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.dbPromise||(this.dbPromise=ul(),this.dbPromise.catch(()=>{this.dbPromise=null})),this.dbPromise}async _withRetries(e){let t=0;for(;;)try{return await e(await this._openDb())}catch(e){if(3<t++)throw e;this.dbPromise&&((await this.dbPromise).close(),this.dbPromise=null)}}async initializeServiceWorkerMessaging(){return rl()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=Xo._getInstance(rl()?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;this.activeServiceWorker=await(async()=>{if(!navigator?.serviceWorker)return null;try{return(await navigator.serviceWorker.ready).active}catch{return null}})(),this.activeServiceWorker&&(this.sender=new el(this.activeServiceWorker),e=await this.sender._send("ping",{},800))&&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{return indexedDB?(await this._withRetries(async e=>{await hl(e,Go,"1"),await cl(e,Go)}),!0):!1}catch{}return!1}async _withPendingWrite(e){this.pendingWrites++;try{await e()}finally{this.pendingWrites--}}async _set(t,r){return this._withPendingWrite(async()=>(await this._withRetries(e=>hl(e,t,r)),this.localCache[t]=r,this.notifyServiceWorker(t)))}async _get(t){var e=await this._withRetries(e=>(async(e,t)=>{var r=ll(e,!1).get(t);return void 0===(r=await new ol(r).toPromise())?null:r.value})(e,t));return this.localCache[t]=e}async _remove(t){return this._withPendingWrite(async()=>(await this._withRetries(e=>cl(e,t)),delete this.localCache[t],this.notifyServiceWorker(t)))}async _poll(){var e=await this._withRetries(e=>{var t=ll(e,!1).getAll();return new ol(t).toPromise()});if(!e)return[];if(0!==this.pendingWrites)return[];var t,r=[],n=new Set;if(0!==e.length)for(var{fbase_key:i,value:s}of e)n.add(i),JSON.stringify(this.localCache[i])!==JSON.stringify(s)&&(this.notifyListeners(i,s),r.push(i));for(t of Object.keys(this.localCache))this.localCache[t]&&!n.has(t)&&(this.notifyListeners(t,null),r.push(t));return r}notifyListeners(e,t){this.localCache[e]=t;var r=this.listeners[e];if(r)for(var n of Array.from(r))n(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()}}dl.type="LOCAL";let pl=dl;function fl(e,t){return Rs(e,"POST","/v2/accounts/mfaSignIn:start",Ns(e,t))}let gl=Ea("rcb"),ml=new Es(3e4,6e4);class vl{constructor(){this.hostLanguage="",this.counter=0,this.librarySeparatelyLoaded=!!tl().grecaptcha?.render}load(i,s=""){var e;return m((e=s).length<=6&&/^\s*[a-zA-Z0-9\-]*\s*$/.test(e),i,"argument-error"),this.shouldResolveImmediately(s)&&Ms(tl().grecaptcha)?Promise.resolve(tl().grecaptcha):new Promise((t,r)=>{let n=tl().setTimeout(()=>{r(ps(i,"network-request-failed"))},ml.get());tl()[gl]=()=>{tl().clearTimeout(n),delete tl()[gl];var e=tl().grecaptcha;if(e&&Ms(e)){let n=e.render;e.render=(e,t)=>{var r=n(e,t);return this.counter++,r},this.hostLanguage=s,t(e)}else r(ps(i,"internal-error"))},Ta(ba.recaptchaV2Script+"?"+Se({onload:gl,render:"explicit",hl:s})).catch(()=>{clearTimeout(n),r(ps(i,"internal-error"))})})}clearedOneInstance(){this.counter--}shouldResolveImmediately(e){return!!tl().grecaptcha?.render&&(e===this.hostLanguage||0<this.counter||this.librarySeparatelyLoaded)}}class _l{async load(e){return new Ia(e)}clearedOneInstance(){}}let yl="recaptcha",wl={theme:"light",type:"image"};class bl{constructor(e,t,r={...wl}){this.parameters=r,this.type=yl,this.destroyed=!1,this.widgetId=null,this.tokenChangeListeners=new Set,this.renderPromise=null,this.recaptcha=null,this.auth=ya(e),this.isInvisible="invisible"===this.parameters.size,m("undefined"!=typeof document,this.auth,"operation-not-supported-in-this-environment");var n="string"==typeof t?document.getElementById(t):t;m(n,this.auth,"argument-error"),this.container=n,this.parameters.callback=this.makeTokenCallback(this.parameters.callback),this._recaptchaLoader=new(this.auth.settings.appVerificationDisabledForTesting?_l:vl),this.validateStartingState()}async verify(){this.assertNotDestroyed();let e=await this.render(),n=this.getAssertedRecaptcha();var t=n.getResponse(e);return t||new Promise(t=>{let r=e=>{e&&(this.tokenChangeListeners.delete(r),t(e))};this.tokenChangeListeners.add(r),this.isInvisible&&n.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(){m(!this.parameters.sitekey,this.auth,"argument-error"),m(this.isInvisible||!this.container.hasChildNodes(),this.auth,"argument-error"),m("undefined"!=typeof document,this.auth,"operation-not-supported-in-this-environment")}makeTokenCallback(r){return t=>{var e;this.tokenChangeListeners.forEach(e=>e(t)),"function"==typeof r?r(t):"string"==typeof r&&"function"==typeof(e=tl()[r])&&e(t)}}assertNotDestroyed(){m(!this.destroyed,this.auth,"internal-error")}async makeRenderPromise(){if(await this.init(),!this.widgetId){let e=this.container;var t;this.isInvisible||(t=document.createElement("div"),e.appendChild(t),e=t),this.widgetId=this.getAssertedRecaptcha().render(e,this.parameters)}return this.widgetId}async init(){m(bs()&&!rl(),this.auth,"internal-error"),await(()=>{let t=null;return new Promise(e=>{"complete"===document.readyState?e():(t=()=>e(),window.addEventListener("load",t))}).catch(e=>{throw t&&window.removeEventListener("load",t),e})})(),this.recaptcha=await this._recaptchaLoader.load(this.auth,this.auth.languageCode||void 0);var e=await((await Rs(this.auth,"GET","/v1/recaptchaParams")).recaptchaSiteKey||"");m(e,this.auth,"internal-error"),this.parameters.sitekey=e}getAssertedRecaptcha(){return m(this.recaptcha,this.auth,"internal-error"),this.recaptcha}}class Tl{constructor(e,t){this.verificationId=e,this.onConfirmation=t}confirm(e){var t=$a._fromVerification(this.verificationId,e);return this.onConfirmation(t)}}async function El(t,r,n){if(!t._getRecaptchaConfig())try{e=ya(t),i=await Vs(e,{clientType:"CLIENT_TYPE_WEB",version:"RECAPTCHA_ENTERPRISE"}),i=new Us(i),null==e.tenantId?e._agentRecaptchaConfig=i:e._tenantRecaptchaConfigs[e.tenantId]=i,await(!i.isAnyProviderEnabled()||!new Ra(e).verify())}catch(e){console.log("Failed to initialize reCAPTCHA Enterprise config. Triggering the reCAPTCHA v2 verification.")}var e,i,s,a,o,l,u;try{let e;return("session"in(e="string"==typeof r?{phoneNumber:r}:r)?(s=e.session,"phoneNumber"in e?(m("enroll"===s.type,t,"internal-error"),a={idToken:s.credential,phoneEnrollmentInfo:{phoneNumber:e.phoneNumber,clientType:"CLIENT_TYPE_WEB"}},(await xa(t,a,"mfaSmsEnrollment",async(e,t)=>t.phoneEnrollmentInfo.captchaResponse===Aa?(m(n?.type===yl,e,"argument-error"),zo(e,await Il(e,t,n))):zo(e,t),"PHONE_PROVIDER").catch(e=>Promise.reject(e))).phoneSessionInfo):(m("signin"===s.type,t,"internal-error"),m(o=e.multiFactorHint?.uid||e.multiFactorUid,t,"missing-multi-factor-info"),l={mfaPendingCredential:s.credential,mfaEnrollmentId:o,phoneSignInInfo:{clientType:"CLIENT_TYPE_WEB"}},(await xa(t,l,"mfaSmsSignIn",async(e,t)=>t.phoneSignInInfo.captchaResponse===Aa?(m(n?.type===yl,e,"argument-error"),fl(e,await Il(e,t,n))):fl(e,t),"PHONE_PROVIDER").catch(e=>Promise.reject(e))).phoneResponseInfo)):(u={phoneNumber:e.phoneNumber,clientType:"CLIENT_TYPE_WEB"},await xa(t,u,"sendVerificationCode",async(e,t)=>t.captchaResponse===Aa?(m(n?.type===yl,e,"argument-error"),Ga(e,await Il(e,t,n))):Ga(e,t),"PHONE_PROVIDER").catch(e=>Promise.reject(e)))).sessionInfo}finally{n?._reset()}}async function Il(e,t,r){m(r.type===yl,e,"argument-error");var n,i,s,a,o=await r.verify(),l=(m("string"==typeof o,e,"argument-error"),{...t});return"phoneEnrollmentInfo"in l?(i=l.phoneEnrollmentInfo.phoneNumber,s=l.phoneEnrollmentInfo.captchaResponse,a=l.phoneEnrollmentInfo.clientType,n=l.phoneEnrollmentInfo.recaptchaVersion,Object.assign(l,{phoneEnrollmentInfo:{phoneNumber:i,recaptchaToken:o,captchaResponse:s,clientType:a,recaptchaVersion:n}})):"phoneSignInInfo"in l?(i=l.phoneSignInInfo.captchaResponse,s=l.phoneSignInInfo.clientType,a=l.phoneSignInInfo.recaptchaVersion,Object.assign(l,{phoneSignInInfo:{recaptchaToken:o,captchaResponse:i,clientType:s,recaptchaVersion:a}})):Object.assign(l,{recaptchaToken:o}),l}class Cl{constructor(e){this.providerId=Cl.PROVIDER_ID,this.auth=ya(e)}verifyPhoneNumber(e,t){return El(this.auth,e,w(t))}static credential(e,t){return $a._fromVerification(e,t)}static credentialFromResult(e){var t=e;return Cl.credentialFromTaggedObject(t)}static credentialFromError(e){return Cl.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){var t,r;return e&&({phoneNumber:t,temporaryProof:r}=e,t)&&r?$a._fromTokenResponse(t,r):null}}function Sl(e,t){return t?ea(t):(m(e._popupRedirectResolver,e,"argument-error"),e._popupRedirectResolver)}Cl.PROVIDER_ID="phone",Cl.PHONE_SIGN_IN_METHOD="phone";class kl extends Ma{constructor(e){super("custom","custom"),this.params=e}_getIdTokenResponse(e){return Ha(e,this._buildIdpRequest())}_linkToIdToken(e,t){return Ha(e,this._buildIdpRequest(t))}_getReauthenticationResolver(e){return Ha(e,this._buildIdpRequest())}_buildIdpRequest(e){var t={requestUri:this.params.requestUri,sessionId:this.params.sessionId,postBody:this.params.postBody,tenantId:this.params.tenantId,pendingToken:this.params.pendingToken,returnSecureToken:!0,returnIdpCredential:!0};return e&&(t.idToken=e),t}}function Al(e){return vo(e.auth,new kl(e),e.bypassAuthState)}function Nl(e){var{auth:t,user:r}=e;return m(r,t,"internal-error"),mo(r,new kl(e),e.bypassAuthState)}async function Rl(e){var{auth:t,user:r}=e;return m(r,t,"internal-error"),fo(r,new kl(e),e.bypassAuthState)}class Pl{constructor(e,t,r,n,i=!1){this.auth=e,this.resolver=r,this.user=n,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){var{urlResponse:t,sessionId:r,postBody:n,tenantId:i,error:s,type:a}=e;if(s)this.reject(s);else{s={auth:this.auth,requestUri:t,sessionId:r,tenantId:i||void 0,postBody:n||void 0,user:this.user,bypassAuthState:this.bypassAuthState};try{this.resolve(await this.getIdpTask(a)(s))}catch(e){this.reject(e)}}}onError(e){this.reject(e)}getIdpTask(e){switch(e){case"signInViaPopup":case"signInViaRedirect":return Al;case"linkViaPopup":case"linkViaRedirect":return Rl;case"reauthViaPopup":case"reauthViaRedirect":return Nl;default:ds(this.auth,"internal-error")}}resolve(e){ys(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){ys(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()}}let xl=new Es(2e3,1e4);class Dl extends Pl{constructor(e,t,r,n,i){super(e,t,n,i),this.provider=r,this.authWindow=null,this.pollId=null,Dl.currentPopupAction&&Dl.currentPopupAction.cancel(),Dl.currentPopupAction=this}async executeNotNull(){var e=await this.execute();return m(e,this.auth,"internal-error"),e}async onExecution(){ys(1===this.filter.length,"Popup operations only handle one event");var e=Zo();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(ps(this.auth,"web-storage-unsupported"))}),this.pollUserCancellation()}get eventId(){return this.authWindow?.associatedEvent||null}cancel(){this.reject(ps(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,Dl.currentPopupAction=null}pollUserCancellation(){let e=()=>{this.authWindow?.window?.closed?this.pollId=window.setTimeout(()=>{this.pollId=null,this.reject(ps(this.auth,"popup-closed-by-user"))},8e3):this.pollId=window.setTimeout(e,xl.get())};e()}}Dl.currentPopupAction=null;let Ol="pendingRedirect",Ll=new Map;class Ml extends Pl{constructor(e,t,r=!1){super(e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],t,void 0,r),this.eventId=null}async execute(){let t=Ll.get(this.auth._key());if(!t){try{let e=await(async(e,t)=>{var r,n=Bl(t),i=Vl(e);return!!await i._isAvailable()&&(r="true"===await i._get(n),await i._remove(n),r)})(this.resolver,this.auth)?await super.execute():null;t=()=>Promise.resolve(e)}catch(e){t=()=>Promise.reject(e)}Ll.set(this.auth._key(),t)}return this.bypassAuthState||Ll.set(this.auth._key(),()=>Promise.resolve(null)),t()}async onAuthEvent(e){if("signInViaRedirect"===e.type)return super.onAuthEvent(e);if("unknown"===e.type)this.resolve(null);else if(e.eventId){var t=await this.auth._redirectUserForId(e.eventId);if(t)return this.user=t,super.onAuthEvent(e);this.resolve(null)}}async onExecution(){}cleanUp(){}}async function Fl(e,t){return Vl(e)._set(Bl(t),"true")}function Ul(e,t){Ll.set(e._key(),t)}function Vl(e){return ea(e._redirectPersistence)}function Bl(e){return na(Ol,e.config.apiKey,e.name)}function ql(e,t,r){return(async(e,t,r)=>{var n,i;return Ot(e.app)?Promise.reject(gs(e)):(n=ya(e),ms(e,t,Ja),await n._initializationPromise,await Fl(i=Sl(n,r),n),i._openRedirect(n,t,"signInViaRedirect"))})(e,t,r)}function jl(e,t,r){return(async(e,t,r)=>{var n=w(e);if(ms(n.auth,t,Ja),Ot(n.auth.app))return Promise.reject(gs(n.auth));await n.auth._initializationPromise;var i=Sl(n.auth,r),s=(await Fl(i,n.auth),await Kl(n));return i._openRedirect(n.auth,t,"reauthViaRedirect",s)})(e,t,r)}function zl(e,t,r){return(async(e,t,r)=>{var n=w(e),i=(ms(n.auth,t,Ja),await n.auth._initializationPromise,Sl(n.auth,r)),s=(await go(!1,n,t.providerId),await Fl(i,n.auth),await Kl(n));return i._openRedirect(n.auth,t,"linkViaRedirect",s)})(e,t,r)}async function Hl(e,t,r=!1){var n,i;return Ot(e.app)?Promise.reject(gs(e)):(i=Sl(n=ya(e),t),(i=await new Ml(n,i,r).execute())&&!r&&(delete i.user._redirectEventId,await n._persistUserIfCurrent(i.user),await n._setRedirectUser(null,t)),i)}async function Kl(e){var t=Zo(e.uid+":::");return e._redirectEventId=t,await e.auth._setRedirectUser(e),await e.auth._persistUserIfCurrent(e),t}class Gl{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(t){if(this.hasEventBeenHandled(t))return!1;let r=!1;return this.consumers.forEach(e=>{this.isEventForConsumer(t,e)&&(r=!0,this.sendToConsumer(t,e),this.saveEventToCache(t))}),this.hasHandledPotentialRedirect||!(e=>{switch(e.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return 1;case"unknown":return $l(e);default:return}})(t)||(this.hasHandledPotentialRedirect=!0,r)||(this.queuedRedirectEvent=t,r=!0),r}sendToConsumer(e,t){var r;e.error&&!$l(e)?(r=e.error.code?.split("auth/")[1]||"internal-error",t.onError(ps(this.auth,r))):t.onAuthEvent(e)}isEventForConsumer(e,t){var r=null===t.eventId||!!e.eventId&&e.eventId===t.eventId;return t.filter.includes(e.type)&&r}hasEventBeenHandled(e){return 6e5<=Date.now()-this.lastProcessedEventTime&&this.cachedEventUids.clear(),this.cachedEventUids.has(Wl(e))}saveEventToCache(e){this.cachedEventUids.add(Wl(e)),this.lastProcessedEventTime=Date.now()}}function Wl(e){return[e.type,e.eventId,e.sessionId,e.tenantId].filter(e=>e).join("-")}function $l({type:e,error:t}){return"unknown"===e&&"auth/no-auth-event"===t?.code}async function Yl(e,t={}){return Rs(e,"GET","/v1/projects",t)}let Ql=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,Jl=/^https?/;async function Xl(e){if(!e.config.emulator){var t,r=(await Yl(e)).authorizedDomains;for(t of r)try{if((e=>{var t,r=ws(),{protocol:n,hostname:i}=new URL(r);return e.startsWith("chrome-extension://")?""===(t=new URL(e)).hostname&&""===i?"chrome-extension:"===n&&e.replace("chrome-extension://","")===r.replace("chrome-extension://",""):"chrome-extension:"===n&&t.hostname===i:Jl.test(n)&&(Ql.test(e)?i===e:(r=e.replace(/\./g,"\\."),(t=new RegExp("^(.+\\."+r+"|"+r+")$","i")).test(i)))})(t))return}catch{}ds(e,"unauthorized-domain")}}let Zl=new Es(3e4,6e4);function eu(){var t=tl().___jsl;if(t?.H)for(var r of Object.keys(t.H))if(t.H[r].r=t.H[r].r||[],t.H[r].L=t.H[r].L||[],t.H[r].r=[...t.H[r].L],t.CP)for(let e=0;e<t.CP.length;e++)t.CP[e]=null}function tu(i){return new Promise((e,t)=>{function r(){eu(),gapi.load("gapi.iframes",{callback:()=>{e(gapi.iframes.getContext())},ontimeout:()=>{eu(),t(ps(i,"network-request-failed"))},timeout:Zl.get()})}if(tl().gapi?.iframes?.Iframe)e(gapi.iframes.getContext());else{var n;if(!tl().gapi?.load)return n=Ea("iframefcb"),tl()[n]=()=>{gapi.load?r():t(ps(i,"network-request-failed"))},Ta(ba.gapiScript+"?onload="+n).catch(e=>t(e));r()}}).catch(e=>{throw ru=null,e})}let ru=null;let nu=new Es(5e3,15e3),iu="__/auth/iframe",su="emulator/auth/iframe",au={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},ou=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);async function lu(a){e=a;var e,t,r,n=await(ru=ru||tu(e)),i=tl().gapi;return m(i,a,"internal-error"),n.open({where:document.body,url:(m((n=(e=a).config).authDomain,e,"auth-domain-config-required"),t=n.emulator?Is(n,su):`https://${e.config.authDomain}/`+iu,n={apiKey:n.apiKey,appName:e.name,v:Vt},(r=ou.get(e.config.apiHost))&&(n.eid=r),(r=e._getFrameworks()).length&&(n.fw=r.join(",")),t+"?"+Se(n).slice(1)),messageHandlersFilter:i.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:au,dontclear:!0},s=>new Promise(async(e,t)=>{await s.restyle({setHideOnLeave:!1});let r=ps(a,"network-request-failed"),n=tl().setTimeout(()=>{t(r)},nu.get());function i(){tl().clearTimeout(n),e(s)}s.ping(i).then(i,()=>{t(r)})}))}let uu={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"},hu=500,cu=600,du="_blank",pu="http://localhost";class fu{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch(e){}}}function gu(e,t,r,n=hu,i=cu){var s=Math.max((window.screen.availHeight-i)/2,0).toString(),a=Math.max((window.screen.availWidth-n)/2,0).toString();let o="";var l,s={...uu,width:n.toString(),height:i.toString(),top:s,left:a},a=te().toLowerCase(),s=(r&&(o=la(a)?du:r),aa(a)&&(t=t||pu,s.scrollbars="yes"),Object.entries(s).reduce((e,[t,r])=>""+e+t+`=${r},`,""));if([n=te()]=[a],pa(n)&&window.navigator?.standalone&&"_self"!==o)return i=t||"",r=o,(a=document.createElement("a")).href=i,a.target=r,(l=document.createEvent("MouseEvent")).initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,1,null),a.dispatchEvent(l),new fu(null);a=window.open(t||"",o,s);m(a,e,"popup-blocked");try{a.focus()}catch(e){}return new fu(a)}let mu="__/auth/handler",vu="emulator/auth/handler",_u=encodeURIComponent("fac");async function yu(e,t,r,n,i,s){m(e.config.authDomain,e,"auth-domain-config-required"),m(e.config.apiKey,e,"invalid-api-key");var a={apiKey:e.config.apiKey,appName:e.name,authType:r,redirectUrl:n,v:Vt,eventId:i};if(t instanceof Ja){t.setDefaultLanguage(e.languageCode),a.providerId=t.providerId||"",Te(t.getCustomParameters())||(a.customParameters=JSON.stringify(t.getCustomParameters()));for(var[o,l]of Object.entries(s||{}))a[o]=l}t instanceof Xa&&0<(c=t.getScopes().filter(e=>""!==e)).length&&(a.scopes=c.join(",")),e.tenantId&&(a.tid=e.tenantId);var u,h=a;for(u of Object.keys(h))void 0===h[u]&&delete h[u];var c=await e._getAppCheckToken(),c=c?`#${_u}=`+encodeURIComponent(c):"";return`${r=[e.config][0],r.emulator?Is(r,vu):`https://${r.authDomain}/`+mu}?`+Se(h).slice(1)+c}let wu="webStorageSupport";class bu{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=Jo,this._completeRedirectFn=Hl,this._overrideRedirectResult=Ul}async _openPopup(e,t,r,n){return ys(this.eventManagers[e._key()]?.manager,"_initialize() not called before _openPopup()"),gu(e,await yu(e,t,r,ws(),n),Zo())}async _openRedirect(e,t,r,n){await this._originValidation(e);var i=await yu(e,t,r,ws(),n);return tl().location.href=i,new Promise(()=>{})}_initialize(e){let r=e._key();if(this.eventManagers[r]){let{manager:e,promise:t}=this.eventManagers[r];return e?Promise.resolve(e):(ys(t,"If manager is not set, promise should be"),t)}let t=this.initAndGetManager(e);return this.eventManagers[r]={promise:t},t.catch(()=>{delete this.eventManagers[r]}),t}async initAndGetManager(t){var e=await lu(t);let r=new Gl(t);return e.register("authEvent",e=>(m(e?.authEvent,t,"invalid-auth-event"),{status:r.onEvent(e.authEvent)?"ACK":"ERROR"}),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[t._key()]={manager:r},this.iframes[t._key()]=e,r}_isIframeWebStorageSupported(r,n){this.iframes[r._key()].send(wu,{type:wu},e=>{var t=e?.[0]?.[wu];void 0!==t&&n(!!t),ds(r,"internal-error")},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){var t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=Xl(e)),this.originValidationPromises[t]}get _shouldInitProactively(){return fa()||oa()||pa()}}let Tu=bu;class Eu extends class{constructor(e){this.factorId=e}_process(e,t,r){switch(t.type){case"enroll":return this._finalizeEnroll(e,t.credential,r);case"signin":return this._finalizeSignIn(e,t.credential);default:return _s("unexpected MultiFactorSessionType")}}}{constructor(e){super("phone"),this.credential=e}static _fromCredential(e){return new Eu(e)}_finalizeEnroll(e,t,r){return e=e,t={idToken:t,displayName:r,phoneVerificationInfo:this.credential._makeVerificationRequest()},Rs(e,"POST","/v2/accounts/mfaEnrollment:finalize",Ns(e,t))}_finalizeSignIn(e,t){return e=e,t={mfaPendingCredential:t,phoneVerificationInfo:this.credential._makeVerificationRequest()},Rs(e,"POST","/v2/accounts/mfaSignIn:finalize",Ns(e,t))}}class Iu{constructor(){}static assertion(e){return Eu._fromCredential(e)}}Iu.FACTOR_ID="phone";lr="@firebase/auth",dr="1.13.3";class Cu{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(t){var e;this.assertAuthConfigured(),this.internalListeners.has(t)||(e=this.auth.onIdTokenChanged(e=>{t(e?.stsTokenManager.accessToken||null)}),this.internalListeners.set(t,e),this.updateProactiveRefresh())}removeAuthTokenListener(e){this.assertAuthConfigured();var t=this.internalListeners.get(e);t&&(this.internalListeners.delete(e),t(),this.updateProactiveRefresh())}assertAuthConfigured(){m(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){0<this.internalListeners.size?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}var Su;function ku(){return window}Q()?._authIdTokenMaxAge,ba={loadJS(n){return new Promise((e,r)=>{var t=document.createElement("script");t.setAttribute("src",n),t.onload=e,t.onerror=e=>{var t=ps("internal-error");t.customData=e,r(t)},t.type="text/javascript",t.charset="UTF-8",(document.getElementsByTagName("head")?.[0]??document).appendChild(t)})},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="},Su="Browser",Rt(new h("auth",(e,{options:t})=>{var r=e.getProvider("app").getImmediate(),n=e.getProvider("heartbeat"),i=e.getProvider("app-check-internal"),{apiKey:s,authDomain:a}=r.options,s=(m(s&&!s.includes(":"),"invalid-api-key",{appName:r.name}),{apiKey:s,authDomain:a,clientPlatform:Su,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:ga(Su)}),a=new _a(r,n,i,s);return e=a,r=(t=t)?.persistence||[],r=(Array.isArray(r)?r:[r]).map(ea),t?.errorMap&&e._updateErrorMap(t.errorMap),e._initializeWithPersistence(r,t?.popupRedirectResolver),a},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((e,t,r)=>{e.getProvider("auth-internal").initialize()})),Rt(new h("auth-internal",e=>{var t=ya(e.getProvider("auth").getImmediate());return e=t,new Cu(e)},"PRIVATE").setInstantiationMode("EXPLICIT")),zt(lr,dr,(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}})(Su)),zt(lr,dr,"esm2020");let Au=2e3;async function Nu(e,t,r){var n=ku().BuildInfo,i=(ys(t.sessionId,"AuthEvent did not contain a session ID"),i=(e=>{if(ys(/[0-9a-zA-Z]+/.test(e),"Can only convert alpha-numeric strings"),"undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);var t=new ArrayBuffer(e.length),r=new Uint8Array(t);for(let n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return r})(t.sessionId),i=await crypto.subtle.digest("SHA-256",i),await(i=Array.from(new Uint8Array(i))).map(e=>e.toString(16).padStart(2,"0")).join("")),s={};return pa()?s.ibi=n.packageName:ha()?s.apn=n.packageName:ds(e,"operation-not-supported-in-this-environment"),n.displayName&&(s.appDisplayName=n.displayName),s.sessionId=i,yu(e,r,t.type,void 0,t.eventId??void 0,s)}function Ru(n){let i=ku().cordova;return new Promise(r=>{i.plugins.browsertab.isAvailable(e=>{let t=null;e?i.plugins.browsertab.openUrl(n):t=i.InAppBrowser.open(n,(e=te(),/(iPad|iPhone|iPod).*OS 7_\d/i.test(e)||/(iPad|iPhone|iPod).*OS 8_\d/i.test(e)?"_blank":"_system"),"location=yes"),r(t)})})}let Pu=20;class xu extends Gl{constructor(){super(...arguments),this.passiveListeners=new Set,this.initPromise=new Promise(e=>{this.resolveInitialized=e})}addPassiveListener(e){this.passiveListeners.add(e)}removePassiveListener(e){this.passiveListeners.delete(e)}resetRedirect(){this.queuedRedirectEvent=null,this.hasHandledPotentialRedirect=!1}onEvent(t){return this.resolveInitialized(),this.passiveListeners.forEach(e=>e(t)),super.onEvent(t)}async initialized(){await this.initPromise}}function Du(e,t,r=null){return{type:t,eventId:r,urlResponse:null,sessionId:(()=>{var e=[],t="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";for(let n=0;n<Pu;n++){var r=Math.floor(Math.random()*t.length);e.push(t.charAt(r))}return e.join("")})(),postBody:null,tenantId:e.tenantId,error:ps(e,"no-auth-event")}}async function Ou(e){var t=await Mu()._get(Fu(e));return t&&await Mu()._remove(Fu(e)),t}function Lu(e,t){i=Uu(t=t),r=i.link?decodeURIComponent(i.link):void 0,n=Uu(r).link,i=i.deep_link_id?decodeURIComponent(i.deep_link_id):void 0;var r,n,i=Uu(i).link||i||n||r||t;return i.includes("/__/auth/callback")?(n=(r=((n=Uu(i)).firebaseError?(e=>{try{return JSON.parse(e)}catch(e){return null}})(decodeURIComponent(n.firebaseError)):null)?.code?.split("auth/")?.[1])?ps(r):null)?{type:e.type,eventId:e.eventId,tenantId:e.tenantId,error:n,urlResponse:null,sessionId:null,postBody:null}:{type:e.type,eventId:e.eventId,tenantId:e.tenantId,sessionId:e.sessionId,urlResponse:i,postBody:null}:null}function Mu(){return ea(Yo)}function Fu(e){return na("authEvent",e.config.apiKey,e.name)}function Uu(e){var t,r;return e?.includes("?")?([t,...r]=e.split("?"),ke(r.join("?"))):{}}class Vu{constructor(){this._redirectPersistence=Jo,this._shouldInitProactively=!0,this.eventManagers=new Map,this.originValidationPromises={},this._completeRedirectFn=Hl,this._overrideRedirectResult=Ul}async _initialize(e){var t=e._key();let r=this.eventManagers.get(t);return r||(r=new xu(e),this.eventManagers.set(t,r),this.attachCallbackListeners(e,r)),r}_openPopup(e){ds(e,"operation-not-supported-in-this-environment")}async _openRedirect(e,t,r,n){i=e,m("function"==typeof(s=ku())?.universalLinks?.subscribe,i,"invalid-cordova-configuration",{missingPlugin:"cordova-universal-links-plugin-fix"}),m(void 0!==s?.BuildInfo?.packageName,i,"invalid-cordova-configuration",{missingPlugin:"cordova-plugin-buildInfo"}),m("function"==typeof s?.cordova?.plugins?.browsertab?.openUrl,i,"invalid-cordova-configuration",{missingPlugin:"cordova-plugin-browsertab"}),m("function"==typeof s?.cordova?.plugins?.browsertab?.isAvailable,i,"invalid-cordova-configuration",{missingPlugin:"cordova-plugin-browsertab"}),m("function"==typeof s?.cordova?.InAppBrowser?.open,i,"invalid-cordova-configuration",{missingPlugin:"cordova-plugin-inappbrowser"});var i,s=await this._initialize(e),a=(await s.initialized(),s.resetRedirect(),Ll.clear(),await this._originValidation(e),Du(e,r,n)),a=(i=e,r=a,await Mu()._set(Fu(i),r),await Nu(e,a,t));return(async(a,o,l)=>{let u=ku().cordova,h=()=>{};try{await new Promise((t,e)=>{let r=null;function n(){t();var e=u.plugins.browsertab?.close;"function"==typeof e&&e(),"function"==typeof l?.close&&l.close()}function i(){r=r||window.setTimeout(()=>{e(ps(a,"redirect-cancelled-by-user"))},Au)}function s(){"visible"===document?.visibilityState&&i()}o.addPassiveListener(n),document.addEventListener("resume",i,!1),ha()&&document.addEventListener("visibilitychange",s,!1),h=()=>{o.removePassiveListener(n),document.removeEventListener("resume",i,!1),document.removeEventListener("visibilitychange",s,!1),r&&window.clearTimeout(r)}})}finally{h()}})(e,s,await Ru(a))}_isIframeWebStorageSupported(e,t){throw new Error("Method not implemented.")}_originValidation(e){var t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=(async e=>{var t=ku().BuildInfo,r={};pa()?r.iosBundleId=t.packageName:ha()?r.androidPackageName=t.packageName:ds(e,"operation-not-supported-in-this-environment"),await Yl(e,r)})(e)),this.originValidationPromises[t]}attachCallbackListeners(n,i){var{universalLinks:e,handleOpenURL:t,BuildInfo:r}=ku();let s=setTimeout(async()=>{await Ou(n),i.onEvent(qu())},500),a=async e=>{clearTimeout(s);var t=await Ou(n);let r=null;t&&e?.url&&(r=Lu(t,e.url)),i.onEvent(r||qu())},o=(void 0!==e&&"function"==typeof e.subscribe&&e.subscribe(null,a),t),l=r.packageName.toLowerCase()+"://";ku().handleOpenURL=async e=>{if(e.toLowerCase().startsWith(l)&&a({url:e}),"function"==typeof o)try{o(e)}catch(e){console.error(e)}}}}let Bu=Vu;function qu(){return{type:"unknown",eventId:null,sessionId:null,urlResponse:null,postBody:null,tenantId:null,error:ps("no-auth-event")}}var fr="@firebase/auth-compat",e="0.6.8";let ju=1e3;function zu(){return self?.location?.protocol||null}function Hu(e=te()){return!("file:"!==zu()&&"ionic:"!==zu()&&"capacitor:"!==zu()||!e.toLowerCase().match(/iphone|ipad|ipod|android/))}function Ku(e=te()){return oe()&&11===document?.documentMode||([e=te()]=[e],/Edge\/\d+/.test(e))}function Gu(){try{var e=self.localStorage,t=Zo();if(e)return e.setItem(t,"1"),e.removeItem(t),!Ku()||ce()}catch(e){return Wu()&&ce()}return!1}function Wu(){return"undefined"!=typeof global&&"WorkerGlobalScope"in global&&"importScripts"in global}function $u(){return("http:"===zu()||"https:"===zu()||se()||Hu())&&!(ae()||ne())&&Gu()&&!Wu()}function Yu(){return Hu()&&"undefined"!=typeof document}let Qu={LOCAL:"local",NONE:"none",SESSION:"session"},Ju=m,Xu="persistence";async function Zu(e){await e._initializationPromise;var t=eh(),r=na(Xu,e.config.apiKey,e.name);t&&t.setItem(r,e._getPersistenceType())}function eh(){try{return("undefined"!=typeof window?window:null)?.sessionStorage||null}catch(e){return null}}let th=m;class rh{constructor(){this.browserResolver=ea(Tu),this.cordovaResolver=ea(Bu),this.underlyingResolver=null,this._redirectPersistence=Jo,this._completeRedirectFn=Hl,this._overrideRedirectResult=Ul}async _initialize(e){return await this.selectUnderlyingResolver(),this.assertedUnderlyingResolver._initialize(e)}async _openPopup(e,t,r,n){return await this.selectUnderlyingResolver(),this.assertedUnderlyingResolver._openPopup(e,t,r,n)}async _openRedirect(e,t,r,n){return await this.selectUnderlyingResolver(),this.assertedUnderlyingResolver._openRedirect(e,t,r,n)}_isIframeWebStorageSupported(e,t){this.assertedUnderlyingResolver._isIframeWebStorageSupported(e,t)}_originValidation(e){return this.assertedUnderlyingResolver._originValidation(e)}get _shouldInitProactively(){return Yu()||this.browserResolver._shouldInitProactively}get assertedUnderlyingResolver(){return th(this.underlyingResolver,"internal-error"),this.underlyingResolver}async selectUnderlyingResolver(){var e;this.underlyingResolver||(e=await(!!Yu()&&new Promise(e=>{let t=setTimeout(()=>{e(!1)},ju);document.addEventListener("deviceready",()=>{clearTimeout(t),e(!0)})})),this.underlyingResolver=e?this.cordovaResolver:this.browserResolver)}}function nh(e){return e.unwrap()}function ih(e,t){var r,n,i,s=t.customData?._tokenResponse;"auth/multi-factor-auth-required"===t?.code?t.resolver=new lh(e,(r=t,n=w(e),m((i=r).customData.operationType,n,"argument-error"),m(i.customData._serverResponse?.mfaPendingCredential,n,"argument-error"),jo._fromError(n,i))):s&&(i=sh(n=t))&&(n.credential=i,n.tenantId=s.tenantId||void 0,n.email=s.email||void 0,n.phoneNumber=s.phoneNumber||void 0)}function sh(e){var t=(e instanceof fe?e.customData:e)._tokenResponse;if(!t)return null;if(!(e instanceof fe)&&"temporaryProof"in t&&"phoneNumber"in t)return Cl.credentialFromResult(e);var r=t.providerId;if(!r||r===is.PASSWORD)return null;let n;switch(r){case is.GOOGLE:n=to;break;case is.FACEBOOK:n=eo;break;case is.GITHUB:n=ro;break;case is.TWITTER:n=so;break;default:var{oauthIdToken:i,oauthAccessToken:s,oauthTokenSecret:a,pendingToken:o,nonce:l}=t;return s||a||i||o?o?r.startsWith("saml.")?no._create(r,o):Ka._fromParams({providerId:r,signInMethod:r,pendingToken:o,idToken:i,accessToken:s}):new Za(r).credential({idToken:i,accessToken:s,rawNonce:l}):null}return e instanceof fe?n.credentialFromError(e):n.credentialFromResult(e)}function ah(t,e){return e.catch(e=>{throw e instanceof fe&&ih(t,e),e}).then(e=>{var t=e.operationType,r=e.user;return{operationType:t,credential:sh(e),additionalUserInfo:Bo(e),user:uh.getOrCreate(r)}})}async function oh(t,e){let r=await e;return{verificationId:r.verificationId,confirm:e=>ah(t,r.confirm(e))}}class lh{constructor(e,t){this.resolver=t,this.auth=e.wrapped()}get session(){return this.resolver.session}get hints(){return this.resolver.hints}resolveSignIn(e){return ah(nh(this.auth),this.resolver.resolveSignIn(e))}}class uh{constructor(e){var t;this._delegate=e,this.multiFactor=(t=w(e),Ko.has(t)||Ko.set(t,Ho._fromUser(t)),Ko.get(t))}static getOrCreate(e){return uh.USER_MAP.has(e)||uh.USER_MAP.set(e,new uh(e)),uh.USER_MAP.get(e)}delete(){return this._delegate.delete()}reload(){return this._delegate.reload()}toJSON(){return this._delegate.toJSON()}getIdTokenResult(e){return this._delegate.getIdTokenResult(e)}getIdToken(e){return this._delegate.getIdToken(e)}linkAndRetrieveDataWithCredential(e){return this.linkWithCredential(e)}async linkWithCredential(e){return ah(this.auth,yo(this._delegate,e))}async linkWithPhoneNumber(e,t){return oh(this.auth,(async(e,t,r)=>{let n=w(e);await go(!1,n,"phone");var i=await El(n.auth,t,w(r));return new Tl(i,e=>yo(n,e))})(this._delegate,e,t))}async linkWithPopup(e){return ah(this.auth,(async(e,t,r)=>{var n=w(e),i=(ms(n.auth,t,Ja),Sl(n.auth,r));return new Dl(n.auth,"linkViaPopup",t,i,n).executeNotNull()})(this._delegate,e,rh))}async linkWithRedirect(e){return await Zu(ya(this.auth)),zl(this._delegate,e,rh)}reauthenticateAndRetrieveDataWithCredential(e){return this.reauthenticateWithCredential(e)}async reauthenticateWithCredential(e){return ah(this.auth,wo(this._delegate,e))}reauthenticateWithPhoneNumber(e,t){return oh(this.auth,(async(e,t,r)=>{let n=w(e);var i;return Ot(n.auth.app)?Promise.reject(gs(n.auth)):(i=await El(n.auth,t,w(r)),new Tl(i,e=>wo(n,e)))})(this._delegate,e,t))}reauthenticateWithPopup(e){return ah(this.auth,(async(e,t,r)=>{var n=w(e);if(Ot(n.auth.app))return Promise.reject(ps(n.auth,"operation-not-supported-in-this-environment"));ms(n.auth,t,Ja);var i=Sl(n.auth,r);return new Dl(n.auth,"reauthViaPopup",t,i,n).executeNotNull()})(this._delegate,e,rh))}async reauthenticateWithRedirect(e){return await Zu(ya(this.auth)),jl(this._delegate,e,rh)}sendEmailVerification(e){return Ro(this._delegate,e)}async unlink(e){return await po(this._delegate,e),this}updateEmail(e){return t=this._delegate,e=e,Ot((r=w(t)).auth.app)?Promise.reject(gs(r.auth)):Do(r,e,null);var t,r}updatePassword(e){return Do(w(this._delegate),null,e)}updatePhoneNumber(e){return(async(e,t)=>{var r=w(e);if(Ot(r.auth.app))return Promise.reject(gs(r.auth));await fo(r,t)})(this._delegate,e)}updateProfile(e){return xo(this._delegate,e)}verifyBeforeUpdateEmail(e,t){return Po(this._delegate,e,t)}get emailVerified(){return this._delegate.emailVerified}get isAnonymous(){return this._delegate.isAnonymous}get metadata(){return this._delegate.metadata}get phoneNumber(){return this._delegate.phoneNumber}get providerData(){return this._delegate.providerData}get refreshToken(){return this._delegate.refreshToken}get tenantId(){return this._delegate.tenantId}get displayName(){return this._delegate.displayName}get email(){return this._delegate.email}get photoURL(){return this._delegate.photoURL}get providerId(){return this._delegate.providerId}get uid(){return this._delegate.uid}get auth(){return this._delegate.auth}}uh.USER_MAP=new WeakMap;let hh=m;class ch{constructor(e,t){var r,n;this.app=e,t.isInitialized()?this._delegate=t.getImmediate():(r=e.options.apiKey,hh(r,"invalid-api-key",{appName:e.name}),hh(r,"invalid-api-key",{appName:e.name}),n="undefined"!=typeof window?rh:void 0,this._delegate=t.initialize({options:{persistence:((e,t)=>{var r=((e,t)=>{var r=eh();if(!r)return[];var n=na(Xu,e,t);switch(r.getItem(n)){case Qu.NONE:return[ra];case Qu.LOCAL:return[pl,Jo];case Qu.SESSION:return[Jo];default:return[]}})(e,t);if("undefined"==typeof self||r.includes(pl)||r.push(pl),"undefined"!=typeof window)for(var n of[Yo,Jo])r.includes(n)||r.push(n);return r.includes(ra)||r.push(ra),r})(r,e.name),popupRedirectResolver:n}}),this._delegate._updateErrorMap(os)),this.linkUnderlyingAuth()}get emulatorConfig(){return this._delegate.emulatorConfig}get currentUser(){return this._delegate.currentUser?uh.getOrCreate(this._delegate.currentUser):null}get languageCode(){return this._delegate.languageCode}set languageCode(e){this._delegate.languageCode=e}get settings(){return this._delegate.settings}get tenantId(){return this._delegate.tenantId}set tenantId(e){this._delegate.tenantId=e}useDeviceLanguage(){this._delegate.useDeviceLanguage()}signOut(){return this._delegate.signOut()}useEmulator(e,t){Da(this._delegate,e,t)}applyActionCode(e){return ko(this._delegate,e)}checkActionCode(e){return Ao(this._delegate,e)}confirmPasswordReset(e,t){return(async(t,e,r)=>{await Fa(w(t),{oobCode:e,newPassword:r}).catch(async e=>{throw"auth/password-does-not-meet-requirements"===e.code&&So(t),e})})(this._delegate,e,t)}async createUserWithEmailAndPassword(e,t){return ah(this._delegate,(async(t,e,r)=>{var n,i;return Ot(t.app)?Promise.reject(gs(t)):(i=await xa(n=ya(t),{returnSecureToken:!0,email:e,password:r,clientType:"CLIENT_TYPE_WEB"},"signUpPassword",ao,"EMAIL_PASSWORD_PROVIDER").catch(e=>{throw"auth/password-does-not-meet-requirements"===e.code&&So(t),e}),i=await oo._fromIdTokenResponse(n,"signIn",i),await n._updateCurrentUser(i.user),i)})(this._delegate,e,t))}fetchProvidersForEmail(e){return this.fetchSignInMethodsForEmail(e)}fetchSignInMethodsForEmail(e){return No(this._delegate,e)}isSignInWithEmailLink(e){return this._delegate,e=e,"EMAIL_SIGNIN"===Ya.parseLink(e)?.operation}async getRedirectResult(){hh($u(),this._delegate,"operation-not-supported-in-this-environment");e=this._delegate,t=rh,await ya(e)._initializationPromise;var e,t,r=await Hl(e,t,!1);return r?ah(this._delegate,Promise.resolve(r)):{credential:null,user:null}}addFrameworkForLogging(e){ya(this._delegate)._logFramework(e)}onAuthStateChanged(e,t,r){var{next:n,error:i,complete:s}=dh(e,t,r);return this._delegate.onAuthStateChanged(n,i,s)}onIdTokenChanged(e,t,r){var{next:n,error:i,complete:s}=dh(e,t,r);return this._delegate.onIdTokenChanged(n,i,s)}sendSignInLinkToEmail(e,t){return(async(e,t,r)=>{let n=ya(e);var i={requestType:"EMAIL_SIGNIN",email:t,clientType:"CLIENT_TYPE_WEB"};e=i,m((t=r).handleCodeInApp,n,"argument-error"),t&&Co(n,e,t),await xa(n,i,"getOobCode",ja,"EMAIL_PASSWORD_PROVIDER")})(this._delegate,e,t)}sendPasswordResetEmail(e,t){return(async(e,t,r)=>{var n=ya(e),i={requestType:"PASSWORD_RESET",email:t,clientType:"CLIENT_TYPE_WEB"};r&&Co(n,i,r),await xa(n,i,"getOobCode",qa,"EMAIL_PASSWORD_PROVIDER")})(this._delegate,e,t||void 0)}async setPersistence(e){var t,r;t=this._delegate,r=e,Ju(Object.values(Qu).includes(r),t,"invalid-persistence-type"),ae()?Ju(r!==Qu.SESSION,t,"unsupported-persistence-type"):ne()?Ju(r===Qu.NONE,t,"unsupported-persistence-type"):Wu()?Ju(r===Qu.NONE||r===Qu.LOCAL&&ce(),t,"unsupported-persistence-type"):Ju(r===Qu.NONE||Gu(),t,"unsupported-persistence-type");let n;switch(e){case Qu.SESSION:n=Jo;break;case Qu.LOCAL:var i=await ea(pl)._isAvailable();n=i?pl:Yo;break;case Qu.NONE:n=ra;break;default:return ds("argument-error",{appName:this._delegate.name})}return this._delegate.setPersistence(n)}signInAndRetrieveDataWithCredential(e){return this.signInWithCredential(e)}signInAnonymously(){return ah(this._delegate,(async e=>{var t,r;return Ot(e.app)?Promise.reject(gs(e)):(await(t=ya(e))._initializationPromise,t.currentUser?.isAnonymous?new oo({user:t.currentUser,providerId:null,operationType:"signIn"}):(r=await ao(t,{returnSecureToken:!0}),r=await oo._fromIdTokenResponse(t,"signIn",r,!0),await t._updateCurrentUser(r.user),r))})(this._delegate))}signInWithCredential(e){return ah(this._delegate,_o(this._delegate,e))}signInWithCustomToken(e){return ah(this._delegate,bo(this._delegate,e))}signInWithEmailAndPassword(e,t){return ah(this._delegate,(r=this._delegate,e=e,t=t,Ot(r.app)?Promise.reject(gs(r)):_o(w(r),Qa.credential(e,t)).catch(async e=>{throw"auth/password-does-not-meet-requirements"===e.code&&So(r),e})));var r}signInWithEmailLink(e,t){return ah(this._delegate,(async(e,t,r)=>{var n,i;return Ot(e.app)?Promise.reject(gs(e)):(n=w(e),m((i=Qa.credentialWithLink(t,r||ws()))._tenantId===(n.tenantId||null),n,"tenant-id-mismatch"),_o(n,i))})(this._delegate,e,t))}signInWithPhoneNumber(e,t){return oh(this._delegate,(async(e,t,r)=>{if(Ot(e.app))return Promise.reject(gs(e));let n=ya(e);var i=await El(n,t,w(r));return new Tl(i,e=>_o(n,e))})(this._delegate,e,t))}async signInWithPopup(e){return hh($u(),this._delegate,"operation-not-supported-in-this-environment"),ah(this._delegate,(async(e,t,r)=>{var n,i;return Ot(e.app)?Promise.reject(ps(e,"operation-not-supported-in-this-environment")):(n=ya(e),ms(e,t,Ja),i=Sl(n,r),new Dl(n,"signInViaPopup",t,i).executeNotNull())})(this._delegate,e,rh))}async signInWithRedirect(e){return hh($u(),this._delegate,"operation-not-supported-in-this-environment"),await Zu(this._delegate),ql(this._delegate,e,rh)}updateCurrentUser(e){return this._delegate.updateCurrentUser(e)}verifyPasswordResetCode(e){return(async(e,t)=>{var r=(await Ao(w(e),t)).data;return r.email})(this._delegate,e)}unwrap(){return this._delegate}_delete(){return this._delegate._delete()}linkUnderlyingAuth(){this._delegate.wrapped=()=>this}}function dh(e,t,r){let n=e,i=("function"!=typeof e&&({next:n,error:t,complete:r}=e),n);return{next:e=>i(e&&uh.getOrCreate(e)),error:t,complete:r}}ch.Persistence=Qu;class ph{static credential(e,t){return Cl.credential(e,t)}constructor(){this.providerId="phone",this._delegate=new Cl(nh(pr.auth()))}verifyPhoneNumber(e,t){return this._delegate.verifyPhoneNumber(e,t)}unwrap(){return this._delegate}}ph.PHONE_SIGN_IN_METHOD=Cl.PHONE_SIGN_IN_METHOD,ph.PROVIDER_ID=Cl.PROVIDER_ID;let fh=m;class gh{constructor(e,t,r=pr.app()){fh(r.options?.apiKey,"invalid-api-key",{appName:r.name}),this._delegate=new bl(r.auth(),e,t),this.type=this._delegate.type}clear(){this._delegate.clear()}render(){return this._delegate.render()}verify(){return this._delegate.verify()}}let mh="auth-compat";(t=pr).INTERNAL.registerComponent(new h(mh,e=>{var t=e.getProvider("app-compat").getImmediate(),r=e.getProvider("auth");return new ch(t,r)},"PUBLIC").setServiceProps({ActionCodeInfo:{Operation:{EMAIL_SIGNIN:ss.EMAIL_SIGNIN,PASSWORD_RESET:ss.PASSWORD_RESET,RECOVER_EMAIL:ss.RECOVER_EMAIL,REVERT_SECOND_FACTOR_ADDITION:ss.REVERT_SECOND_FACTOR_ADDITION,VERIFY_AND_CHANGE_EMAIL:ss.VERIFY_AND_CHANGE_EMAIL,VERIFY_EMAIL:ss.VERIFY_EMAIL}},EmailAuthProvider:Qa,FacebookAuthProvider:eo,GithubAuthProvider:ro,GoogleAuthProvider:to,OAuthProvider:Za,SAMLAuthProvider:io,PhoneAuthProvider:ph,PhoneMultiFactorGenerator:Iu,RecaptchaVerifier:gh,TwitterAuthProvider:so,Auth:ch,AuthCredential:Ma,Error:fe}).setInstantiationMode("LAZY").setMultipleInstances(!1)),t.registerVersion(fr,e);let vh="@firebase/database",_h="1.1.3",yh="";function wh(e){yh=e}class bh{constructor(e){this.domStorage_=e,this.prefix_="firebase:"}set(e,t){null==t?this.domStorage_.removeItem(this.prefixedName_(e)):this.domStorage_.setItem(this.prefixedName_(e),_e(t))}get(e){var t=this.domStorage_.getItem(this.prefixedName_(e));return null==t?null:ve(t)}remove(e){this.domStorage_.removeItem(this.prefixedName_(e))}prefixedName_(e){return this.prefix_+e}toString(){return this.domStorage_.toString()}}class Th{constructor(){this.cache_={},this.isInMemoryStorage=!0}set(e,t){null==t?delete this.cache_[e]:this.cache_[e]=t}get(e){return we(this.cache_,e)?this.cache_[e]:null}remove(e){delete this.cache_[e]}}function Eh(e){try{var t;if("undefined"!=typeof window&&void 0!==window[e])return(t=window[e]).setItem("firebase:sentinel","cache"),t.removeItem("firebase:sentinel"),new bh(t)}catch(e){}return new Th}var Ih;function Ch(e){var t=Me(e),r=new Ne,t=(r.update(t),r.digest());return B.encodeByteArray(t)}function Sh(t){return function(...e){Uh(t,...e)}}function kh(...e){var t="FIREBASE INTERNAL ERROR: "+Oh(...e);xh.error(t)}function Ah(e,t){if(t&&e in t)return t[e];throw new Error("Missing required key ("+e+") in object: "+_e(t))}function Nh(e,t){var r=e.length;if(r<=t)return[e];var n=[];for(let i=0;i<r;i+=t)i+t>r?n.push(e.substring(i,r)):n.push(e.substring(i,i+t));return n}let Rh=Eh("localStorage"),Ph=Eh("sessionStorage"),xh=new Ze("@firebase/database"),Dh=(()=>{let e=1;return function(){return e++}})(),Oh=function(...e){let t="";for(let n=0;n<e.length;n++){var r=e[n];Array.isArray(r)||r&&"object"==typeof r&&"number"==typeof r.length?t+=Oh.apply(null,r):t+="object"==typeof r?_e(r):r,t+=" "}return t},Lh=null,Mh=!0,Fh=function(e,t){g(!t||!0===e||!1===e,"Can't turn on custom loggers persistently."),!0===e?(xh.logLevel=p.VERBOSE,Lh=xh.log.bind(xh),t&&Ph.set("logging_enabled",!0)):"function"==typeof e?Lh=e:(Lh=null,Ph.remove("logging_enabled"))},Uh=function(...e){var t;!0===Mh&&(Mh=!1,null===Lh)&&!0===Ph.get("logging_enabled")&&Fh(!0),Lh&&(t=Oh.apply(null,e),Lh(t))},Vh=function(...e){var t="FIREBASE FATAL ERROR: "+Oh(...e);throw xh.error(t),new Error(t)},Bh=function(...e){var t="FIREBASE WARNING: "+Oh(...e);xh.warn(t)},qh=function(){"undefined"!=typeof window&&window.location&&window.location.protocol&&-1!==window.location.protocol.indexOf("https:")&&Bh("Insecure Firebase access from a secure page. Please use https in calls to new Firebase().")},jh=function(e){return"number"==typeof e&&(e!=e||e===Number.POSITIVE_INFINITY||e===Number.NEGATIVE_INFINITY)},zh="[MIN_NAME]",Hh="[MAX_NAME]",Kh=function(e,t){var r,n;return e===t?0:e===zh||t===Hh?-1:t===zh||e===Hh?1:(r=ec(e),n=ec(t),null!==r?null!==n?r-n==0?e.length-t.length:r-n:-1:null===n&&e<t?-1:1)},Gh=function(e,t){return e===t?0:e<t?-1:1},Wh=function(e){if("object"!=typeof e||null===e)return _e(e);var t,r=[];for(t in e)r.push(t);r.sort();let n="{";for(let i=0;i<r.length;i++)0!==i&&(n+=","),n=(n=n+_e(r[i])+":")+Wh(e[r[i]]);return n+="}"};function $h(e,t){for(var r in e)e.hasOwnProperty(r)&&t(r,e[r])}let Yh=function(e){g(!jh(e),"Invalid JSON number");let t,r,n,i,s;0===e?(r=0,n=0,t=1/e==-1/0?1:0):(t=e<0,e=Math.abs(e),n=e>=Math.pow(2,-1022)?(i=Math.min(Math.floor(Math.log(e)/Math.LN2),1023),r=i+1023,Math.round(e*Math.pow(2,52-i)-Math.pow(2,52))):(r=0,Math.round(e/Math.pow(2,-1074))));var a=[];for(s=52;s;--s)a.push(n%2?1:0),n=Math.floor(n/2);for(s=11;s;--s)a.push(r%2?1:0),r=Math.floor(r/2);a.push(t?1:0),a.reverse();var o=a.join("");let l="";for(s=0;s<64;s+=8){let e=parseInt(o.substr(s,8),2).toString(16);1===e.length&&(e="0"+e),l+=e}return l.toLowerCase()};function Qh(e,t){var r=setTimeout(e,t);return"number"==typeof r&&"undefined"!=typeof Deno&&Deno.unrefTimer?Deno.unrefTimer(r):"object"==typeof r&&r.unref&&r.unref(),r}let Jh=new RegExp("^-?(0*)\\d{1,10}$"),Xh=-2147483648,Zh=2147483647,ec=function(e){if(Jh.test(e)){var t=Number(e);if(t>=Xh&&t<=Zh)return t}return null},tc=function(e){try{e()}catch(t){setTimeout(()=>{var e=t.stack||"";throw Bh("Exception was thrown by user callback.",e),t},Math.floor(0))}},rc=function(){return 0<=("object"==typeof window&&window.navigator&&window.navigator.userAgent||"").search(/googlebot|google webmaster tools|bingbot|yahoo! slurp|baiduspider|yandexbot|duckduckbot/i)};class nc{constructor(e,t){this.appCheckProvider=t,this.appName=e.name,Ot(e)&&e.settings.appCheckToken&&(this.serverAppAppCheckToken=e.settings.appCheckToken),this.appCheck=t?.getImmediate({optional:!0}),this.appCheck||t?.get().then(e=>this.appCheck=e)}getToken(r){if(this.serverAppAppCheckToken){if(r)throw new Error("Attempted reuse of `FirebaseServerApp.appCheckToken` after previous usage failed.");return Promise.resolve({token:this.serverAppAppCheckToken})}return this.appCheck?this.appCheck.getToken(r):new Promise((e,t)=>{setTimeout(()=>{this.appCheck?this.getToken(r).then(e,t):e(null)},0)})}addTokenChangeListener(t){this.appCheckProvider?.get().then(e=>e.addTokenListener(t))}notifyForInvalidToken(){Bh(`Provided AppCheck credentials for the app named "${this.appName}" `+"are invalid. This usually indicates your app was not initialized correctly.")}}class ic{constructor(e,t,r){this.appName_=e,this.firebaseOptions_=t,this.authProvider_=r,this.auth_=null,this.auth_=r.getImmediate({optional:!0}),this.auth_||r.onInit(e=>this.auth_=e)}getToken(r){return this.auth_?this.auth_.getToken(r).catch(e=>e&&"auth/token-not-initialized"===e.code?(Uh("Got auth/token-not-initialized error.  Treating as null token."),null):Promise.reject(e)):new Promise((e,t)=>{setTimeout(()=>{this.auth_?this.getToken(r).then(e,t):e(null)},0)})}addTokenChangeListener(t){this.auth_?this.auth_.addAuthTokenListener(t):this.authProvider_.get().then(e=>e.addAuthTokenListener(t))}removeTokenChangeListener(t){this.authProvider_.get().then(e=>e.removeAuthTokenListener(t))}notifyForInvalidToken(){let e='Provided authentication credentials for the app named "'+this.appName_+'" are invalid. This usually indicates your app was not initialized correctly. ';"credential"in this.firebaseOptions_?e+='Make sure the "credential" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':"serviceAccount"in this.firebaseOptions_?e+='Make sure the "serviceAccount" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':e+='Make sure the "apiKey" and "databaseURL" properties provided to initializeApp() match the values provided for your app at https://console.firebase.google.com/.',Bh(e)}}class sc{constructor(e){this.accessToken=e}getToken(e){return Promise.resolve({accessToken:this.accessToken})}addTokenChangeListener(e){e(this.accessToken)}removeTokenChangeListener(e){}notifyForInvalidToken(){}}sc.OWNER="owner";let ac=/(console\.firebase|firebase-console-\w+\.corp|firebase\.corp)\.google\.com/,oc="websocket",lc="long_polling";class uc{constructor(e,t,r,n,i=!1,s="",a=!1,o=!1,l=null){this.secure=t,this.namespace=r,this.webSocketOnly=n,this.nodeAdmin=i,this.persistenceKey=s,this.includeNamespaceInQueryParams=a,this.isUsingEmulator=o,this.emulatorOptions=l,this._host=e.toLowerCase(),this._domain=this._host.substr(this._host.indexOf(".")+1),this.internalHost=Rh.get("host:"+e)||this._host}isCacheableHost(){return"s-"===this.internalHost.substr(0,2)}isCustomHost(){return"firebaseio.com"!==this._domain&&"firebaseio-demo.com"!==this._domain}get host(){return this._host}set host(e){e!==this.internalHost&&(this.internalHost=e,this.isCacheableHost())&&Rh.set("host:"+this._host,this.internalHost)}toString(){let e=this.toURLString();return this.persistenceKey&&(e+="<"+this.persistenceKey+">"),e}toURLString(){var e=this.secure?"https://":"http://",t=this.includeNamespaceInQueryParams?"?ns="+this.namespace:"";return e+this.host+"/"+t}}function hc(e,t,r){g("string"==typeof t,"typeof type must == string"),g("object"==typeof r,"typeof params must == object");let n;if(t===oc)n=(e.secure?"wss://":"ws://")+e.internalHost+"/.ws?";else{if(t!==lc)throw new Error("Unknown connection type: "+t);n=(e.secure?"https://":"http://")+e.internalHost+"/.lp?"}((t=e).host!==t.internalHost||t.isCustomHost()||t.includeNamespaceInQueryParams)&&(r.ns=e.namespace);let i=[];return $h(r,(e,t)=>{i.push(e+"="+t)}),n+i.join("&")}class cc{constructor(){this.counters_={}}incrementCounter(e,t=1){we(this.counters_,e)||(this.counters_[e]=0),this.counters_[e]+=t}get(){return K(void 0,this.counters_)}}let dc={},pc={};function fc(e){var t=e.toString();return dc[t]||(dc[t]=new cc),dc[t]}class gc{constructor(e){this.onMessage_=e,this.pendingResponses=[],this.currentResponseNum=0,this.closeAfterResponse=-1,this.onClose=null}closeAfter(e,t){this.closeAfterResponse=e,this.onClose=t,this.closeAfterResponse<this.currentResponseNum&&(this.onClose(),this.onClose=null)}handleResponse(e,t){for(this.pendingResponses[e]=t;this.pendingResponses[this.currentResponseNum];){let e=this.pendingResponses[this.currentResponseNum];delete this.pendingResponses[this.currentResponseNum];for(let t=0;t<e.length;++t)e[t]&&tc(()=>{this.onMessage_(e[t])});if(this.currentResponseNum===this.closeAfterResponse){this.onClose&&(this.onClose(),this.onClose=null);break}this.currentResponseNum++}}}class mc{constructor(e,t,r,n,i,s,a){this.connId=e,this.repoInfo=t,this.applicationId=r,this.appCheckToken=n,this.authToken=i,this.transportSessionId=s,this.lastSessionId=a,this.bytesSent=0,this.bytesReceived=0,this.everConnected_=!1,this.log_=Sh(e),this.stats_=fc(t),this.urlFn=e=>(this.appCheckToken&&(e.ac=this.appCheckToken),hc(t,lc,e))}open(e,t){this.curSegmentNum=0,this.onDisconnect_=t,this.myPacketOrderer=new gc(e),this.isClosed_=!1,this.connectTimeoutTimer_=setTimeout(()=>{this.log_("Timed out trying to connect."),this.onClosed_(),this.connectTimeoutTimer_=null},Math.floor(3e4));var r=()=>{var e;this.isClosed_||(this.scriptTagHolder=new vc((...e)=>{var[t,r,n,,,]=e;if(this.incrementIncomingBytes_(e),this.scriptTagHolder)if(this.connectTimeoutTimer_&&(clearTimeout(this.connectTimeoutTimer_),this.connectTimeoutTimer_=null),this.everConnected_=!0,"start"===t)this.id=r,this.password=n;else{if("close"!==t)throw new Error("Unrecognized command received: "+t);r?(this.scriptTagHolder.sendNewPolls=!1,this.myPacketOrderer.closeAfter(r,()=>{this.onClosed_()})):this.onClosed_()}},(...e)=>{var[t,r]=e;this.incrementIncomingBytes_(e),this.myPacketOrderer.handleResponse(t,r)},()=>{this.onClosed_()},this.urlFn),(e={start:"t"}).ser=Math.floor(1e8*Math.random()),this.scriptTagHolder.uniqueCallbackIdentifier&&(e.cb=this.scriptTagHolder.uniqueCallbackIdentifier),e.v="5",this.transportSessionId&&(e.s=this.transportSessionId),this.lastSessionId&&(e.ls=this.lastSessionId),this.applicationId&&(e.p=this.applicationId),this.appCheckToken&&(e.ac=this.appCheckToken),"undefined"!=typeof location&&location.hostname&&ac.test(location.hostname)&&(e.r="f"),e=this.urlFn(e),this.log_("Connecting via long-poll to "+e),this.scriptTagHolder.addTag(e,()=>{}))};if("complete"===document.readyState)r();else{let e=!1,t=function(){document.body?e||(e=!0,r()):setTimeout(t,Math.floor(10))};document.addEventListener?(document.addEventListener("DOMContentLoaded",t,!1),window.addEventListener("load",t,!1)):document.attachEvent&&(document.attachEvent("onreadystatechange",()=>{"complete"===document.readyState&&t()}),window.attachEvent("onload",t))}}start(){this.scriptTagHolder.startLongPoll(this.id,this.password),this.addDisconnectPingFrame(this.id,this.password)}static forceAllow(){mc.forceAllow_=!0}static forceDisallow(){mc.forceDisallow_=!0}static isAvailable(){return!!mc.forceAllow_||!(mc.forceDisallow_||"undefined"==typeof document||null==document.createElement||"object"==typeof window&&window.chrome&&window.chrome.extension&&!/^chrome/.test(window.location.href)||"object"==typeof Windows&&"object"==typeof Windows.UI)}markConnectionHealthy(){}shutdown_(){this.isClosed_=!0,this.scriptTagHolder&&(this.scriptTagHolder.close(),this.scriptTagHolder=null),this.myDisconnFrame&&(document.body.removeChild(this.myDisconnFrame),this.myDisconnFrame=null),this.connectTimeoutTimer_&&(clearTimeout(this.connectTimeoutTimer_),this.connectTimeoutTimer_=null)}onClosed_(){this.isClosed_||(this.log_("Longpoll is closing itself"),this.shutdown_(),this.onDisconnect_&&(this.onDisconnect_(this.everConnected_),this.onDisconnect_=null))}close(){this.isClosed_||(this.log_("Longpoll is being closed."),this.shutdown_())}send(e){var t=_e(e),t=(this.bytesSent+=t.length,this.stats_.incrementCounter("bytes_sent",t.length),j(t)),r=Nh(t,1840);for(let n=0;n<r.length;n++)this.scriptTagHolder.enqueueSegment(this.curSegmentNum,r.length,r[n]),this.curSegmentNum++}addDisconnectPingFrame(e,t){this.myDisconnFrame=document.createElement("iframe");var r={dframe:"t"};r.id=e,r.pw=t,this.myDisconnFrame.src=this.urlFn(r),this.myDisconnFrame.style.display="none",document.body.appendChild(this.myDisconnFrame)}incrementIncomingBytes_(e){var t=_e(e).length;this.bytesReceived+=t,this.stats_.incrementCounter("bytes_received",t)}}class vc{constructor(t,r,e,n){this.onDisconnect=e,this.urlFn=n,this.outstandingRequests=new Set,this.pendingSegs=[],this.currentSerial=Math.floor(1e8*Math.random()),this.sendNewPolls=!0;{this.uniqueCallbackIdentifier=Dh(),window["pLPCommand"+this.uniqueCallbackIdentifier]=t,window["pRTLPCB"+this.uniqueCallbackIdentifier]=r,this.myIFrame=vc.createIFrame_();let e="";this.myIFrame.src&&"javascript:"===this.myIFrame.src.substr(0,"javascript:".length)&&(i=document.domain,e='<script>document.domain="'+i+'";<\/script>');var i="<html><body>"+e+"</body></html>";try{this.myIFrame.doc.open(),this.myIFrame.doc.write(i),this.myIFrame.doc.close()}catch(e){Uh("frame writing exception"),e.stack&&Uh(e.stack),Uh(e)}}}static createIFrame_(){var t=document.createElement("iframe");if(t.style.display="none",!document.body)throw"Document body has not initialized. Wait to initialize Firebase until after the document is ready.";document.body.appendChild(t);try{t.contentWindow.document||Uh("No IE domain setting required")}catch(e){var r=document.domain;t.src="javascript:void((function(){document.open();document.domain='"+r+"';document.close();})())"}return t.contentDocument?t.doc=t.contentDocument:t.contentWindow?t.doc=t.contentWindow.document:t.document&&(t.doc=t.document),t}close(){this.alive=!1,this.myIFrame&&(this.myIFrame.doc.body.textContent="",setTimeout(()=>{null!==this.myIFrame&&(document.body.removeChild(this.myIFrame),this.myIFrame=null)},Math.floor(0)));var e=this.onDisconnect;e&&(this.onDisconnect=null,e())}startLongPoll(e,t){for(this.myID=e,this.myPW=t,this.alive=!0;this.newRequest_(););}newRequest_(){if(this.alive&&this.sendNewPolls&&this.outstandingRequests.size<(0<this.pendingSegs.length?2:1)){this.currentSerial++;var r={},r=(r.id=this.myID,r.pw=this.myPW,r.ser=this.currentSerial,this.urlFn(r));let e="",t=0;for(;0<this.pendingSegs.length;){if(!(this.pendingSegs[0].d.length+30+e.length<=1870))break;var n=this.pendingSegs.shift();e=e+"&seg"+t+"="+n.seg+"&ts"+t+"="+n.ts+"&d"+t+"="+n.d,t++}return r+=e,this.addLongPollTag_(r,this.currentSerial),!0}return!1}enqueueSegment(e,t,r){this.pendingSegs.push({seg:e,ts:t,d:r}),this.alive&&this.newRequest_()}addLongPollTag_(e,t){this.outstandingRequests.add(t);let r=()=>{this.outstandingRequests.delete(t),this.newRequest_()},n=setTimeout(r,Math.floor(25e3));this.addTag(e,()=>{clearTimeout(n),r()})}addTag(e,r){setTimeout(()=>{try{if(this.sendNewPolls){let t=this.myIFrame.doc.createElement("script");t.type="text/javascript",t.async=!0,t.src=e,t.onload=t.onreadystatechange=function(){var e=t.readyState;e&&"loaded"!==e&&"complete"!==e||(t.onload=t.onreadystatechange=null,t.parentNode&&t.parentNode.removeChild(t),r())},t.onerror=()=>{Uh("Long-poll script failed to load: "+e),this.sendNewPolls=!1,this.close()},this.myIFrame.doc.body.appendChild(t)}}catch(e){}},Math.floor(1))}}let _c=null;"undefined"!=typeof MozWebSocket?_c=MozWebSocket:"undefined"!=typeof WebSocket&&(_c=WebSocket);class yc{constructor(e,t,r,n,i,s,a){this.connId=e,this.applicationId=r,this.appCheckToken=n,this.authToken=i,this.keepaliveTimer=null,this.frames=null,this.totalFrames=0,this.bytesSent=0,this.bytesReceived=0,this.log_=Sh(this.connId),this.stats_=fc(t),this.connURL=yc.connectionURL_(t,s,a,n,r),this.nodeAdmin=t.nodeAdmin}static connectionURL_(e,t,r,n,i){var s={v:"5"};return"undefined"!=typeof location&&location.hostname&&ac.test(location.hostname)&&(s.r="f"),t&&(s.s=t),r&&(s.ls=r),n&&(s.ac=n),i&&(s.p=i),hc(e,oc,s)}open(e,t){this.onDisconnect=t,this.onMessage=e,this.log_("Websocket connecting to "+this.connURL),this.everConnected_=!1,Rh.set("previous_websocket_failure",!0);try{le(),this.mySock=new _c(this.connURL,[],void 0)}catch(e){this.log_("Error instantiating WebSocket.");var r=e.message||e.data;return r&&this.log_(r),void this.onClosed_()}this.mySock.onopen=()=>{this.log_("Websocket connected."),this.everConnected_=!0},this.mySock.onclose=()=>{this.log_("Websocket connection was disconnected."),this.mySock=null,this.onClosed_()},this.mySock.onmessage=e=>{this.handleIncomingFrame(e)},this.mySock.onerror=e=>{this.log_("WebSocket error.  Closing connection.");var t=e.message||e.data;t&&this.log_(t),this.onClosed_()}}start(){}static forceDisallow(){yc.forceDisallow_=!0}static isAvailable(){let e=!1;var t;return!(e="undefined"!=typeof navigator&&navigator.userAgent&&(t=navigator.userAgent.match(/Android ([0-9]{0,}\.[0-9]{0,})/))&&1<t.length&&parseFloat(t[1])<4.4?!0:e)&&null!==_c&&!yc.forceDisallow_}static previouslyFailed(){return Rh.isInMemoryStorage||!0===Rh.get("previous_websocket_failure")}markConnectionHealthy(){Rh.remove("previous_websocket_failure")}appendFrame_(e){var t;this.frames.push(e),this.frames.length===this.totalFrames&&(t=this.frames.join(""),this.frames=null,t=ve(t),this.onMessage(t))}handleNewFrameCount_(e){this.totalFrames=e,this.frames=[]}extractFrameCount_(e){if(g(null===this.frames,"We already have a frame buffer"),e.length<=6){var t=Number(e);if(!isNaN(t))return this.handleNewFrameCount_(t),null}return this.handleNewFrameCount_(1),e}handleIncomingFrame(e){var t;null!==this.mySock&&(t=e.data,this.bytesReceived+=t.length,this.stats_.incrementCounter("bytes_received",t.length),this.resetKeepAlive(),null!==this.frames?this.appendFrame_(t):null!==(t=this.extractFrameCount_(t))&&this.appendFrame_(t))}send(e){this.resetKeepAlive();var t=_e(e),r=(this.bytesSent+=t.length,this.stats_.incrementCounter("bytes_sent",t.length),Nh(t,16384));1<r.length&&this.sendString_(String(r.length));for(let n=0;n<r.length;n++)this.sendString_(r[n])}shutdown_(){this.isClosed_=!0,this.keepaliveTimer&&(clearInterval(this.keepaliveTimer),this.keepaliveTimer=null),this.mySock&&(this.mySock.close(),this.mySock=null)}onClosed_(){this.isClosed_||(this.log_("WebSocket is closing itself"),this.shutdown_(),this.onDisconnect&&(this.onDisconnect(this.everConnected_),this.onDisconnect=null))}close(){this.isClosed_||(this.log_("WebSocket is being closed"),this.shutdown_())}resetKeepAlive(){clearInterval(this.keepaliveTimer),this.keepaliveTimer=setInterval(()=>{this.mySock&&this.sendString_("0"),this.resetKeepAlive()},Math.floor(45e3))}sendString_(e){try{this.mySock.send(e)}catch(e){this.log_("Exception thrown from WebSocket.send():",e.message||e.data,"Closing connection."),setTimeout(this.onClosed_.bind(this),0)}}}yc.responsesRequiredToBeHealthy=2,yc.healthyTimeout=3e4;class wc{static get ALL_TRANSPORTS(){return[mc,yc]}static get IS_TRANSPORT_INITIALIZED(){return this.globalTransportInitialized_}constructor(e){this.initTransports_(e)}initTransports_(e){var t=yc&&yc.isAvailable();let r=t&&!yc.previouslyFailed();if(e.webSocketOnly&&(t||Bh("wss:// URL used, but browser isn't known to support websockets.  Trying anyway."),r=!0),r)this.transports_=[yc];else{var n,i=this.transports_=[];for(n of wc.ALL_TRANSPORTS)n&&n.isAvailable()&&i.push(n);wc.globalTransportInitialized_=!0}}initialTransport(){if(0<this.transports_.length)return this.transports_[0];throw new Error("No transports available")}upgradeTransport(){return 1<this.transports_.length?this.transports_[1]:null}}wc.globalTransportInitialized_=!1;class bc{constructor(e,t,r,n,i,s,a,o,l,u){this.id=e,this.repoInfo_=t,this.applicationId_=r,this.appCheckToken_=n,this.authToken_=i,this.onMessage_=s,this.onReady_=a,this.onDisconnect_=o,this.onKill_=l,this.lastSessionId=u,this.connectionCount=0,this.pendingDataMessages=[],this.state_=0,this.log_=Sh("c:"+this.id+":"),this.transportManager_=new wc(t),this.log_("Connection created"),this.start_()}start_(){var e=this.transportManager_.initialTransport();this.conn_=new e(this.nextTransportId_(),this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,null,this.lastSessionId),this.primaryResponsesRequired_=e.responsesRequiredToBeHealthy||0;let t=this.connReceiver_(this.conn_),r=this.disconnReceiver_(this.conn_);this.tx_=this.conn_,this.rx_=this.conn_,this.secondaryConn_=null,this.isHealthy_=!1,setTimeout(()=>{this.conn_&&this.conn_.open(t,r)},Math.floor(0));e=e.healthyTimeout||0;0<e&&(this.healthyTimeout_=Qh(()=>{this.healthyTimeout_=null,this.isHealthy_||(this.conn_&&102400<this.conn_.bytesReceived?(this.log_("Connection exceeded healthy timeout but has received "+this.conn_.bytesReceived+" bytes.  Marking connection healthy."),this.isHealthy_=!0,this.conn_.markConnectionHealthy()):this.conn_&&10240<this.conn_.bytesSent?this.log_("Connection exceeded healthy timeout but has sent "+this.conn_.bytesSent+" bytes.  Leaving connection alive."):(this.log_("Closing unhealthy connection after timeout."),this.close()))},Math.floor(e)))}nextTransportId_(){return"c:"+this.id+":"+this.connectionCount++}disconnReceiver_(t){return e=>{t===this.conn_?this.onConnectionLost_(e):t===this.secondaryConn_?(this.log_("Secondary connection lost."),this.onSecondaryConnectionLost_()):this.log_("closing an old connection")}}connReceiver_(t){return e=>{2!==this.state_&&(t===this.rx_?this.onPrimaryMessageReceived_(e):t===this.secondaryConn_?this.onSecondaryMessageReceived_(e):this.log_("message on old connection"))}}sendRequest(e){this.sendData_({t:"d",d:e})}tryCleanupConnection(){this.tx_===this.secondaryConn_&&this.rx_===this.secondaryConn_&&(this.log_("cleaning up and promoting a connection: "+this.secondaryConn_.connId),this.conn_=this.secondaryConn_,this.secondaryConn_=null)}onSecondaryControl_(e){var t;"t"in e&&("a"===(t=e.t)?this.upgradeIfSecondaryHealthy_():"r"===t?(this.log_("Got a reset on secondary, closing it"),this.secondaryConn_.close(),this.tx_!==this.secondaryConn_&&this.rx_!==this.secondaryConn_||this.close()):"o"===t&&(this.log_("got pong on secondary."),this.secondaryResponsesRequired_--,this.upgradeIfSecondaryHealthy_()))}onSecondaryMessageReceived_(e){var t=Ah("t",e),r=Ah("d",e);if("c"===t)this.onSecondaryControl_(r);else{if("d"!==t)throw new Error("Unknown protocol layer: "+t);this.pendingDataMessages.push(r)}}upgradeIfSecondaryHealthy_(){this.secondaryResponsesRequired_<=0?(this.log_("Secondary connection is healthy."),this.isHealthy_=!0,this.secondaryConn_.markConnectionHealthy(),this.proceedWithUpgrade_()):(this.log_("sending ping on secondary."),this.secondaryConn_.send({t:"c",d:{t:"p",d:{}}}))}proceedWithUpgrade_(){this.secondaryConn_.start(),this.log_("sending client ack on secondary"),this.secondaryConn_.send({t:"c",d:{t:"a",d:{}}}),this.log_("Ending transmission on primary"),this.conn_.send({t:"c",d:{t:"n",d:{}}}),this.tx_=this.secondaryConn_,this.tryCleanupConnection()}onPrimaryMessageReceived_(e){var t=Ah("t",e),r=Ah("d",e);"c"===t?this.onControl_(r):"d"===t&&this.onDataMessage_(r)}onDataMessage_(e){this.onPrimaryResponse_(),this.onMessage_(e)}onPrimaryResponse_(){this.isHealthy_||(this.primaryResponsesRequired_--,this.primaryResponsesRequired_<=0&&(this.log_("Primary connection is healthy."),this.isHealthy_=!0,this.conn_.markConnectionHealthy()))}onControl_(e){var t=Ah("t",e);if("d"in e){var r=e.d;if("h"===t){var n={...r};this.repoInfo_.isUsingEmulator&&(n.h=this.repoInfo_.host),this.onHandshake_(n)}else if("n"===t){this.log_("recvd end transmission on primary"),this.rx_=this.secondaryConn_;for(let e=0;e<this.pendingDataMessages.length;++e)this.onDataMessage_(this.pendingDataMessages[e]);this.pendingDataMessages=[],this.tryCleanupConnection()}else"s"===t?this.onConnectionShutdown_(r):"r"===t?this.onReset_(r):"e"===t?kh("Server Error: "+r):"o"===t?(this.log_("got pong on primary."),this.onPrimaryResponse_(),this.sendPingOnPrimaryIfNecessary_()):kh("Unknown control packet command: "+t)}}onHandshake_(e){var t=e.ts,r=e.v,n=e.h;this.sessionId=e.s,this.repoInfo_.host=n,0===this.state_&&(this.conn_.start(),this.onConnectionEstablished_(this.conn_,t),"5"!==r&&Bh("Protocol version mismatch detected"),this.tryStartUpgrade_())}tryStartUpgrade_(){var e=this.transportManager_.upgradeTransport();e&&this.startUpgrade_(e)}startUpgrade_(e){this.secondaryConn_=new e(this.nextTransportId_(),this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,this.sessionId),this.secondaryResponsesRequired_=e.responsesRequiredToBeHealthy||0;var t=this.connReceiver_(this.secondaryConn_),r=this.disconnReceiver_(this.secondaryConn_);this.secondaryConn_.open(t,r),Qh(()=>{this.secondaryConn_&&(this.log_("Timed out trying to upgrade."),this.secondaryConn_.close())},Math.floor(6e4))}onReset_(e){this.log_("Reset packet received.  New host: "+e),this.repoInfo_.host=e,1===this.state_?this.close():(this.closeConnections_(),this.start_())}onConnectionEstablished_(e,t){this.log_("Realtime connection established."),this.conn_=e,this.state_=1,this.onReady_&&(this.onReady_(t,this.sessionId),this.onReady_=null),0===this.primaryResponsesRequired_?(this.log_("Primary connection is healthy."),this.isHealthy_=!0):Qh(()=>{this.sendPingOnPrimaryIfNecessary_()},Math.floor(5e3))}sendPingOnPrimaryIfNecessary_(){this.isHealthy_||1!==this.state_||(this.log_("sending ping on primary."),this.sendData_({t:"c",d:{t:"p",d:{}}}))}onSecondaryConnectionLost_(){var e=this.secondaryConn_;this.secondaryConn_=null,this.tx_!==e&&this.rx_!==e||this.close()}onConnectionLost_(e){this.conn_=null,e||0!==this.state_?1===this.state_&&this.log_("Realtime connection lost."):(this.log_("Realtime connection failed."),this.repoInfo_.isCacheableHost()&&(Rh.remove("host:"+this.repoInfo_.host),this.repoInfo_.internalHost=this.repoInfo_.host)),this.close()}onConnectionShutdown_(e){this.log_("Connection shutdown command received. Shutting down..."),this.onKill_&&(this.onKill_(e),this.onKill_=null),this.onDisconnect_=null,this.close()}sendData_(e){if(1!==this.state_)throw"Connection is not connected";this.tx_.send(e)}close(){2!==this.state_&&(this.log_("Closing realtime connection."),this.state_=2,this.closeConnections_(),this.onDisconnect_)&&(this.onDisconnect_(),this.onDisconnect_=null)}closeConnections_(){this.log_("Shutting down all connections"),this.conn_&&(this.conn_.close(),this.conn_=null),this.secondaryConn_&&(this.secondaryConn_.close(),this.secondaryConn_=null),this.healthyTimeout_&&(clearTimeout(this.healthyTimeout_),this.healthyTimeout_=null)}}class Tc{put(e,t,r,n){}merge(e,t,r,n){}refreshAuthToken(e){}refreshAppCheckToken(e){}onDisconnectPut(e,t,r){}onDisconnectMerge(e,t,r){}onDisconnectCancel(e,t){}reportStats(e){}}class Ec{constructor(e){this.allowedEvents_=e,this.listeners_={},g(Array.isArray(e)&&0<e.length,"Requires a non-empty array")}trigger(t,...r){if(Array.isArray(this.listeners_[t])){var n=[...this.listeners_[t]];for(let e=0;e<n.length;e++)n[e].callback.apply(n[e].context,r)}}on(e,t,r){this.validateEventType_(e),this.listeners_[e]=this.listeners_[e]||[],this.listeners_[e].push({callback:t,context:r});var n=this.getInitialEvent(e);n&&t.apply(r,n)}off(e,t,r){this.validateEventType_(e);var n=this.listeners_[e]||[];for(let i=0;i<n.length;i++)if(n[i].callback===t&&(!r||r===n[i].context))return void n.splice(i,1)}validateEventType_(t){g(this.allowedEvents_.find(e=>e===t),"Unknown event: "+t)}}class Ic extends Ec{static getInstance(){return new Ic}constructor(){super(["online"]),this.online_=!0,"undefined"==typeof window||void 0===window.addEventListener||re()||(window.addEventListener("online",()=>{this.online_||(this.online_=!0,this.trigger("online",!0))},!1),window.addEventListener("offline",()=>{this.online_&&(this.online_=!1,this.trigger("online",!1))},!1))}getInitialEvent(e){return g("online"===e,"Unknown event type: "+e),[this.online_]}currentlyOnline(){return this.online_}}let Cc=32,Sc=768;class kc{constructor(r,e){if(void 0===e){this.pieces_=r.split("/");let e=0;for(let t=0;t<this.pieces_.length;t++)0<this.pieces_[t].length&&(this.pieces_[e]=this.pieces_[t],e++);this.pieces_.length=e,this.pieceNum_=0}else this.pieces_=r,this.pieceNum_=e}toString(){let e="";for(let t=this.pieceNum_;t<this.pieces_.length;t++)""!==this.pieces_[t]&&(e+="/"+this.pieces_[t]);return e||"/"}}function Ac(){return new kc("")}function v(e){return e.pieceNum_>=e.pieces_.length?null:e.pieces_[e.pieceNum_]}function Nc(e){return e.pieces_.length-e.pieceNum_}function Rc(e){let t=e.pieceNum_;return t<e.pieces_.length&&t++,new kc(e.pieces_,t)}function Pc(e){return e.pieceNum_<e.pieces_.length?e.pieces_[e.pieces_.length-1]:null}function xc(e,t=0){return e.pieces_.slice(e.pieceNum_+t)}function Dc(e){if(e.pieceNum_>=e.pieces_.length)return null;var t=[];for(let r=e.pieceNum_;r<e.pieces_.length-1;r++)t.push(e.pieces_[r]);return new kc(t,0)}function Oc(e,t){var r=[];for(let i=e.pieceNum_;i<e.pieces_.length;i++)r.push(e.pieces_[i]);if(t instanceof kc)for(let e=t.pieceNum_;e<t.pieces_.length;e++)r.push(t.pieces_[e]);else{var n=t.split("/");for(let e=0;e<n.length;e++)0<n[e].length&&r.push(n[e])}return new kc(r,0)}function _(e){return e.pieceNum_>=e.pieces_.length}function Lc(e,t){var r=v(e),n=v(t);if(null===r)return t;if(r===n)return Lc(Rc(e),Rc(t));throw new Error("INTERNAL ERROR: innerPath ("+t+") is not within outerPath ("+e+")")}function Mc(e,t){var r=xc(e,0),n=xc(t,0);for(let s=0;s<r.length&&s<n.length;s++){var i=Kh(r[s],n[s]);if(0!==i)return i}return r.length===n.length?0:r.length<n.length?-1:1}function Fc(e,t){if(Nc(e)!==Nc(t))return!1;for(let r=e.pieceNum_,n=t.pieceNum_;r<=e.pieces_.length;r++,n++)if(e.pieces_[r]!==t.pieces_[n])return!1;return!0}function Uc(e,t){let r=e.pieceNum_,n=t.pieceNum_;if(Nc(e)>Nc(t))return!1;for(;r<e.pieces_.length;){if(e.pieces_[r]!==t.pieces_[n])return!1;++r,++n}return!0}class Vc{constructor(e,t){this.errorPrefix_=t,this.parts_=xc(e,0),this.byteLength_=Math.max(1,this.parts_.length);for(let r=0;r<this.parts_.length;r++)this.byteLength_+=Fe(this.parts_[r]);Bc(this)}}function Bc(e){if(e.byteLength_>Sc)throw new Error(e.errorPrefix_+"has a key path longer than "+Sc+" bytes ("+e.byteLength_+").");if(e.parts_.length>Cc)throw new Error(e.errorPrefix_+"path specified exceeds the maximum depth that can be written ("+Cc+") or object contains a cycle "+qc(e))}function qc(e){return 0===e.parts_.length?"":"in property '"+e.parts_.join(".")+"'"}class jc extends Ec{static getInstance(){return new jc}constructor(){super(["visible"]);let t,e;"undefined"!=typeof document&&void 0!==document.addEventListener&&(void 0!==document.hidden?(e="visibilitychange",t="hidden"):void 0!==document.mozHidden?(e="mozvisibilitychange",t="mozHidden"):void 0!==document.msHidden?(e="msvisibilitychange",t="msHidden"):void 0!==document.webkitHidden&&(e="webkitvisibilitychange",t="webkitHidden")),this.visible_=!0,e&&document.addEventListener(e,()=>{var e=!document[t];e!==this.visible_&&(this.visible_=e,this.trigger("visible",e))},!1)}getInitialEvent(e){return g("visible"===e,"Unknown event type: "+e),[this.visible_]}}class zc extends Tc{constructor(e,t,r,n,i,s,a,o){if(super(),this.repoInfo_=e,this.applicationId_=t,this.onDataUpdate_=r,this.onConnectStatus_=n,this.onServerInfoUpdate_=i,this.authTokenProvider_=s,this.appCheckTokenProvider_=a,this.authOverride_=o,this.id=zc.nextPersistentConnectionId_++,this.log_=Sh("p:"+this.id+":"),this.interruptReasons_={},this.listens=new Map,this.outstandingPuts_=[],this.outstandingGets_=[],this.outstandingPutCount_=0,this.outstandingGetCount_=0,this.onDisconnectRequestQueue_=[],this.connected_=!1,this.reconnectDelay_=1e3,this.maxReconnectDelay_=3e5,this.securityDebugCallback_=null,this.lastSessionId=null,this.establishConnectionTimer_=null,this.visible_=!1,this.requestCBHash_={},this.requestNumber_=0,this.realtime_=null,this.authToken_=null,this.appCheckToken_=null,this.forceTokenRefresh_=!1,this.invalidAuthTokenCount_=0,this.invalidAppCheckTokenCount_=0,this.firstConnection_=!0,this.lastConnectionAttemptTime_=null,this.lastConnectionEstablishedTime_=null,o&&!le())throw new Error("Auth override specified in options, but not supported on non Node.js platforms");jc.getInstance().on("visible",this.onVisible_,this),-1===e.host.indexOf("fblocal")&&Ic.getInstance().on("online",this.onOnline_,this)}sendRequest(e,t,r){var n=++this.requestNumber_,i={r:n,a:e,b:t};this.log_(_e(i)),g(this.connected_,"sendRequest call when we're not connected not allowed."),this.realtime_.sendRequest(i),r&&(this.requestCBHash_[n]=r)}get(e){this.initConnection_();let r=new Z;var t={p:e._path.toString(),q:e._queryObject},t=(this.outstandingGets_.push({action:"g",request:t,onComplete:e=>{var t=e.d;"ok"===e.s?r.resolve(t):r.reject(t)}}),this.outstandingGetCount_++,this.outstandingGets_.length-1);return this.connected_&&this.sendGet_(t),r.promise}listen(e,t,r,n){this.initConnection_();var i=e._queryIdentifier,s=e._path.toString(),a=(this.log_("Listen called for "+s+" "+i),this.listens.has(s)||this.listens.set(s,new Map),g(e._queryParams.isDefault()||!e._queryParams.loadsAllData(),"listen() called for non-default but complete query"),g(!this.listens.get(s).has(i),"listen() called twice for same path/queryId."),{onComplete:n,hashFn:t,query:e,tag:r});this.listens.get(s).set(i,a),this.connected_&&this.sendListen_(a)}sendGet_(t){let r=this.outstandingGets_[t];this.sendRequest("g",r.request,e=>{delete this.outstandingGets_[t],this.outstandingGetCount_--,0===this.outstandingGetCount_&&(this.outstandingGets_=[]),r.onComplete&&r.onComplete(e)})}sendListen_(i){let s=i.query,a=s._path.toString(),o=s._queryIdentifier;this.log_("Listen on "+a+" for "+o);var e={p:a};i.tag&&(e.q=s._queryObject,e.t=i.tag),e.h=i.hashFn(),this.sendRequest("q",e,e=>{var t=e.d,r=e.s,n=(zc.warnOnListenWarnings_(t,s),this.listens.get(a)&&this.listens.get(a).get(o));n===i&&(this.log_("listen response",e),"ok"!==r&&this.removeListen_(a,o),i.onComplete)&&i.onComplete(r,t)})}static warnOnListenWarnings_(e,t){var r,n;e&&"object"==typeof e&&we(e,"w")&&(r=be(e,"w"),Array.isArray(r))&&~r.indexOf("no_index")&&(r='".indexOn": "'+t._queryParams.getIndex().toString()+'"',n=t._path.toString(),Bh("Using an unspecified index. Your data will be downloaded and "+`filtered on the client. Consider adding ${r} at `+n+" to your security rules for better performance."))}refreshAuthToken(e){this.authToken_=e,this.log_("Auth token refreshed"),this.authToken_?this.tryAuth():this.connected_&&this.sendRequest("unauth",{},()=>{}),this.reduceReconnectDelayIfAdminCredential_(e)}reduceReconnectDelayIfAdminCredential_(e){var t;(e&&40===e.length||(e=e,"object"==typeof(t=ye(e).claims)&&!0===t.admin))&&(this.log_("Admin auth credential detected.  Reducing max reconnect time."),this.maxReconnectDelay_=3e4)}refreshAppCheckToken(e){this.appCheckToken_=e,this.log_("App check token refreshed"),this.appCheckToken_?this.tryAppCheck():this.connected_&&this.sendRequest("unappeck",{},()=>{})}tryAuth(){if(this.connected_&&this.authToken_){let n=this.authToken_;r=n;var e=!!(e=ye(r).claims)&&"object"==typeof e&&e.hasOwnProperty("iat")?"auth":"gauth",t={cred:n};null===this.authOverride_?t.noauth=!0:"object"==typeof this.authOverride_&&(t.authvar=this.authOverride_),this.sendRequest(e,t,e=>{var t=e.s,r=e.d||"error";this.authToken_===n&&("ok"===t?this.invalidAuthTokenCount_=0:this.onAuthRevoked_(t,r))})}var r,e}tryAppCheck(){this.connected_&&this.appCheckToken_&&this.sendRequest("appcheck",{token:this.appCheckToken_},e=>{var t=e.s,r=e.d||"error";"ok"===t?this.invalidAppCheckTokenCount_=0:this.onAppCheckRevoked_(t,r)})}unlisten(e,t){var r=e._path.toString(),n=e._queryIdentifier,i=(this.log_("Unlisten called for "+r+" "+n),g(e._queryParams.isDefault()||!e._queryParams.loadsAllData(),"unlisten() called for non-default but complete query"),this.removeListen_(r,n));i&&this.connected_&&this.sendUnlisten_(r,n,e._queryObject,t)}sendUnlisten_(e,t,r,n){this.log_("Unlisten on "+e+" for "+t);var i={p:e};n&&(i.q=r,i.t=n),this.sendRequest("n",i)}onDisconnectPut(e,t,r){this.initConnection_(),this.connected_?this.sendOnDisconnect_("o",e,t,r):this.onDisconnectRequestQueue_.push({pathString:e,action:"o",data:t,onComplete:r})}onDisconnectMerge(e,t,r){this.initConnection_(),this.connected_?this.sendOnDisconnect_("om",e,t,r):this.onDisconnectRequestQueue_.push({pathString:e,action:"om",data:t,onComplete:r})}onDisconnectCancel(e,t){this.initConnection_(),this.connected_?this.sendOnDisconnect_("oc",e,null,t):this.onDisconnectRequestQueue_.push({pathString:e,action:"oc",data:null,onComplete:t})}sendOnDisconnect_(e,t,r,n){var i={p:t,d:r};this.log_("onDisconnect "+e,i),this.sendRequest(e,i,e=>{n&&setTimeout(()=>{n(e.s,e.d)},Math.floor(0))})}put(e,t,r,n){this.putInternal("p",e,t,r,n)}merge(e,t,r,n){this.putInternal("m",e,t,r,n)}putInternal(e,t,r,n,i){this.initConnection_();var s={p:t,d:r},s=(void 0!==i&&(s.h=i),this.outstandingPuts_.push({action:e,request:s,onComplete:n}),this.outstandingPutCount_++,this.outstandingPuts_.length-1);this.connected_?this.sendPut_(s):this.log_("Buffering put: "+t)}sendPut_(t){let r=this.outstandingPuts_[t].action;var e=this.outstandingPuts_[t].request;let n=this.outstandingPuts_[t].onComplete;this.outstandingPuts_[t].queued=this.connected_,this.sendRequest(r,e,e=>{this.log_(r+" response",e),delete this.outstandingPuts_[t],this.outstandingPutCount_--,0===this.outstandingPutCount_&&(this.outstandingPuts_=[]),n&&n(e.s,e.d)})}reportStats(e){var t;this.connected_&&(this.log_("reportStats",t={c:e}),this.sendRequest("s",t,e=>{var t;"ok"!==e.s&&(t=e.d,this.log_("reportStats","Error sending stats: "+t))}))}onDataMessage_(e){if("r"in e){this.log_("from server: "+_e(e));var t=e.r,r=this.requestCBHash_[t];r&&(delete this.requestCBHash_[t],r(e.b))}else{if("error"in e)throw"A server-side error has occurred: "+e.error;"a"in e&&this.onDataPush_(e.a,e.b)}}onDataPush_(e,t){this.log_("handleServerMessage",e,t),"d"===e?this.onDataUpdate_(t.p,t.d,!1,t.t):"m"===e?this.onDataUpdate_(t.p,t.d,!0,t.t):"c"===e?this.onListenRevoked_(t.p,t.q):"ac"===e?this.onAuthRevoked_(t.s,t.d):"apc"===e?this.onAppCheckRevoked_(t.s,t.d):"sd"===e?this.onSecurityDebugPacket_(t):kh("Unrecognized action received from server: "+_e(e)+"\nAre you using the latest client?")}onReady_(e,t){this.log_("connection ready"),this.connected_=!0,this.lastConnectionEstablishedTime_=(new Date).getTime(),this.handleTimestamp_(e),this.lastSessionId=t,this.firstConnection_&&this.sendConnectStats_(),this.restoreState_(),this.firstConnection_=!1,this.onConnectStatus_(!0)}scheduleConnect_(e){g(!this.realtime_,"Scheduling a connect when we're already connected/ing?"),this.establishConnectionTimer_&&clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=setTimeout(()=>{this.establishConnectionTimer_=null,this.establishConnection_()},Math.floor(e))}initConnection_(){!this.realtime_&&this.firstConnection_&&this.scheduleConnect_(0)}onVisible_(e){e&&!this.visible_&&this.reconnectDelay_===this.maxReconnectDelay_&&(this.log_("Window became visible.  Reducing delay."),this.reconnectDelay_=1e3,this.realtime_||this.scheduleConnect_(0)),this.visible_=e}onOnline_(e){e?(this.log_("Browser went online."),this.reconnectDelay_=1e3,this.realtime_||this.scheduleConnect_(0)):(this.log_("Browser went offline.  Killing connection."),this.realtime_&&this.realtime_.close())}onRealtimeDisconnect_(){var e;this.log_("data client disconnected"),this.connected_=!1,this.realtime_=null,this.cancelSentTransactions_(),this.requestCBHash_={},this.shouldReconnect_()&&(this.visible_?this.lastConnectionEstablishedTime_&&(3e4<(new Date).getTime()-this.lastConnectionEstablishedTime_&&(this.reconnectDelay_=1e3),this.lastConnectionEstablishedTime_=null):(this.log_("Window isn't visible.  Delaying reconnect."),this.reconnectDelay_=this.maxReconnectDelay_,this.lastConnectionAttemptTime_=(new Date).getTime()),e=Math.max(0,(new Date).getTime()-this.lastConnectionAttemptTime_),e=Math.max(0,this.reconnectDelay_-e),e=Math.random()*e,this.log_("Trying to reconnect in "+e+"ms"),this.scheduleConnect_(e),this.reconnectDelay_=Math.min(this.maxReconnectDelay_,1.3*this.reconnectDelay_)),this.onConnectStatus_(!1)}async establishConnection_(){if(this.shouldReconnect_()){this.log_("Making a connection attempt"),this.lastConnectionAttemptTime_=(new Date).getTime(),this.lastConnectionEstablishedTime_=null;var n=this.onDataMessage_.bind(this),i=this.onReady_.bind(this);let e=this.onRealtimeDisconnect_.bind(this);var s=this.id+":"+zc.nextConnectionId_++,a=this.lastSessionId;let t=!1,r=null;var o=function(){r?r.close():(t=!0,e())},l=(this.realtime_={close:o,sendRequest:function(e){g(r,"sendRequest call when we're not connected not allowed."),r.sendRequest(e)}},this.forceTokenRefresh_);this.forceTokenRefresh_=!1;try{var[u,h]=await Promise.all([this.authTokenProvider_.getToken(l),this.appCheckTokenProvider_.getToken(l)]);t?Uh("getToken() completed but was canceled"):(Uh("getToken() completed. Creating connection."),this.authToken_=u&&u.accessToken,this.appCheckToken_=h&&h.token,r=new bc(s,this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,n,i,e,e=>{Bh(e+" ("+this.repoInfo_.toString()+")"),this.interrupt("server_kill")},a))}catch(e){this.log_("Failed to get token: "+e),t||(this.repoInfo_.nodeAdmin&&Bh(e),o())}}}interrupt(e){Uh("Interrupting connection for reason: "+e),this.interruptReasons_[e]=!0,this.realtime_?this.realtime_.close():(this.establishConnectionTimer_&&(clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=null),this.connected_&&this.onRealtimeDisconnect_())}resume(e){Uh("Resuming connection for reason: "+e),delete this.interruptReasons_[e],Te(this.interruptReasons_)&&(this.reconnectDelay_=1e3,this.realtime_||this.scheduleConnect_(0))}handleTimestamp_(e){var t=e-(new Date).getTime();this.onServerInfoUpdate_({serverTimeOffset:t})}cancelSentTransactions_(){for(let t=0;t<this.outstandingPuts_.length;t++){var e=this.outstandingPuts_[t];e&&"h"in e.request&&e.queued&&(e.onComplete&&e.onComplete("disconnect"),delete this.outstandingPuts_[t],this.outstandingPutCount_--)}0===this.outstandingPutCount_&&(this.outstandingPuts_=[])}onListenRevoked_(e,t){let r;r=t?t.map(e=>Wh(e)).join("$"):"default";var n=this.removeListen_(e,r);n&&n.onComplete&&n.onComplete("permission_denied")}removeListen_(e,t){var r,n=new kc(e).toString();let i;return this.listens.has(n)?(r=this.listens.get(n),i=r.get(t),r.delete(t),0===r.size&&this.listens.delete(n)):i=void 0,i}onAuthRevoked_(e,t){Uh("Auth token revoked: "+e+"/"+t),this.authToken_=null,this.forceTokenRefresh_=!0,this.realtime_.close(),"invalid_token"!==e&&"permission_denied"!==e||(this.invalidAuthTokenCount_++,3<=this.invalidAuthTokenCount_&&(this.reconnectDelay_=3e4,this.authTokenProvider_.notifyForInvalidToken()))}onAppCheckRevoked_(e,t){Uh("App check token revoked: "+e+"/"+t),this.appCheckToken_=null,this.forceTokenRefresh_=!0,"invalid_token"!==e&&"permission_denied"!==e||(this.invalidAppCheckTokenCount_++,3<=this.invalidAppCheckTokenCount_&&this.appCheckTokenProvider_.notifyForInvalidToken())}onSecurityDebugPacket_(e){this.securityDebugCallback_?this.securityDebugCallback_(e):"msg"in e&&console.log("FIREBASE: "+e.msg.replace("\n","\nFIREBASE: "))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(var e of this.listens.values())for(var t of e.values())this.sendListen_(t);for(let n=0;n<this.outstandingPuts_.length;n++)this.outstandingPuts_[n]&&this.sendPut_(n);for(;this.onDisconnectRequestQueue_.length;){var r=this.onDisconnectRequestQueue_.shift();this.sendOnDisconnect_(r.action,r.pathString,r.data,r.onComplete)}for(let i=0;i<this.outstandingGets_.length;i++)this.outstandingGets_[i]&&this.sendGet_(i)}sendConnectStats_(){var e={};e["sdk.js."+yh.replace(/\./g,"-")]=1,re()?e["framework.cordova"]=1:ae()&&(e["framework.reactnative"]=1),this.reportStats(e)}shouldReconnect_(){var e=Ic.getInstance().currentlyOnline();return Te(this.interruptReasons_)&&e}}zc.nextPersistentConnectionId_=0,zc.nextConnectionId_=0;class d{constructor(e,t){this.name=e,this.node=t}static Wrap(e,t){return new d(e,t)}}class Hc{getCompare(){return this.compare.bind(this)}indexedValueChanged(e,t){var r=new d(zh,e),n=new d(zh,t);return 0!==this.compare(r,n)}minPost(){return d.MIN}}let Kc;class Gc extends Hc{static get __EMPTY_NODE(){return Kc}static set __EMPTY_NODE(e){Kc=e}compare(e,t){return Kh(e.name,t.name)}isDefinedOn(e){throw V("KeyIndex.isDefinedOn not expected to be called.")}indexedValueChanged(e,t){return!1}minPost(){return d.MIN}maxPost(){return new d(Hh,Kc)}makePost(e,t){return g("string"==typeof e,"KeyIndex indexValue must always be a string."),new d(e,Kc)}toString(){return".key"}}let Wc=new Gc;class $c{constructor(e,t,r,n,i=null){this.isReverse_=n,this.resultGenerator_=i,this.nodeStack_=[];let s=1;for(;!e.isEmpty();)if(s=t?r(e.key,t):1,n&&(s*=-1),s<0)e=this.isReverse_?e.left:e.right;else{if(0===s){this.nodeStack_.push(e);break}this.nodeStack_.push(e),e=this.isReverse_?e.right:e.left}}getNext(){if(0===this.nodeStack_.length)return null;let e=this.nodeStack_.pop(),t;if(t=this.resultGenerator_?this.resultGenerator_(e.key,e.value):{key:e.key,value:e.value},this.isReverse_)for(e=e.left;!e.isEmpty();)this.nodeStack_.push(e),e=e.right;else for(e=e.right;!e.isEmpty();)this.nodeStack_.push(e),e=e.left;return t}hasNext(){return 0<this.nodeStack_.length}peek(){var e;return 0===this.nodeStack_.length?null:(e=this.nodeStack_[this.nodeStack_.length-1],this.resultGenerator_?this.resultGenerator_(e.key,e.value):{key:e.key,value:e.value})}}class Yc{constructor(e,t,r,n,i){this.key=e,this.value=t,this.color=null!=r?r:Yc.RED,this.left=null!=n?n:Jc.EMPTY_NODE,this.right=null!=i?i:Jc.EMPTY_NODE}copy(e,t,r,n,i){return new Yc(null!=e?e:this.key,null!=t?t:this.value,null!=r?r:this.color,null!=n?n:this.left,null!=i?i:this.right)}count(){return this.left.count()+1+this.right.count()}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,r){let n=this;var i=r(e,n.key);return(n=i<0?n.copy(null,null,null,n.left.insert(e,t,r),null):0===i?n.copy(null,t,null,null,null):n.copy(null,null,null,null,n.right.insert(e,t,r))).fixUp_()}removeMin_(){if(this.left.isEmpty())return Jc.EMPTY_NODE;let e=this;return(e=(e=e.left.isRed_()||e.left.left.isRed_()?e:e.moveRedLeft_()).copy(null,null,null,e.left.removeMin_(),null)).fixUp_()}remove(e,t){let r,n;if(t(e,(r=this).key)<0)r=(r=r.left.isEmpty()||r.left.isRed_()||r.left.left.isRed_()?r:r.moveRedLeft_()).copy(null,null,null,r.left.remove(e,t),null);else{if(0===t(e,(r=(r=r.left.isRed_()?r.rotateRight_():r).right.isEmpty()||r.right.isRed_()||r.right.left.isRed_()?r:r.moveRedRight_()).key)){if(r.right.isEmpty())return Jc.EMPTY_NODE;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=(e=(e=e.right.isRed_()&&!e.left.isRed_()?e.rotateLeft_():e).left.isRed_()&&e.left.left.isRed_()?e.rotateRight_():e).left.isRed_()&&e.right.isRed_()?e.colorFlip_():e}moveRedLeft_(){let e=this.colorFlip_();return e=e.right.left.isRed_()?(e=(e=e.copy(null,null,null,null,e.right.rotateRight_())).rotateLeft_()).colorFlip_():e}moveRedRight_(){let e=this.colorFlip_();return e=e.left.left.isRed_()?(e=e.rotateRight_()).colorFlip_():e}rotateLeft_(){var e=this.copy(null,null,Yc.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight_(){var e=this.copy(null,null,Yc.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip_(){var e=this.left.copy(null,null,!this.left.color,null,null),t=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,t)}checkMaxDepth_(){var e=this.check_();return Math.pow(2,e)<=this.count()+1}check_(){if(this.isRed_()&&this.left.isRed_())throw new Error("Red node has red child("+this.key+","+this.value+")");if(this.right.isRed_())throw new Error("Right child of ("+this.key+","+this.value+") is red");var e=this.left.check_();if(e!==this.right.check_())throw new Error("Black depths differ");return e+(this.isRed_()?0:1)}}Yc.RED=!0,Yc.BLACK=!1;class Qc{copy(e,t,r,n,i){return this}insert(e,t,r){return new Yc(e,t,null)}remove(e,t){return this}count(){return 0}isEmpty(){return!0}inorderTraversal(e){return!1}reverseTraversal(e){return!1}minKey(){return null}maxKey(){return null}check_(){return 0}isRed_(){return!1}}class Jc{constructor(e,t=Jc.EMPTY_NODE){this.comparator_=e,this.root_=t}insert(e,t){return new Jc(this.comparator_,this.root_.insert(e,t,this.comparator_).copy(null,null,Yc.BLACK,null,null))}remove(e){return new Jc(this.comparator_,this.root_.remove(e,this.comparator_).copy(null,null,Yc.BLACK,null,null))}get(e){var t;let r=this.root_;for(;!r.isEmpty();){if(0===(t=this.comparator_(e,r.key)))return r.value;t<0?r=r.left:0<t&&(r=r.right)}return null}getPredecessorKey(e){let t,r=this.root_,n=null;for(;!r.isEmpty();){if(0===(t=this.comparator_(e,r.key))){if(r.left.isEmpty())return n?n.key:null;for(r=r.left;!r.right.isEmpty();)r=r.right;return r.key}t<0?r=r.left:0<t&&(r=(n=r).right)}throw new Error("Attempted to find predecessor key for a nonexistent key.  What gives?")}isEmpty(){return this.root_.isEmpty()}count(){return this.root_.count()}minKey(){return this.root_.minKey()}maxKey(){return this.root_.maxKey()}inorderTraversal(e){return this.root_.inorderTraversal(e)}reverseTraversal(e){return this.root_.reverseTraversal(e)}getIterator(e){return new $c(this.root_,null,this.comparator_,!1,e)}getIteratorFrom(e,t){return new $c(this.root_,e,this.comparator_,!1,t)}getReverseIteratorFrom(e,t){return new $c(this.root_,e,this.comparator_,!0,t)}getReverseIterator(e){return new $c(this.root_,null,this.comparator_,!0,e)}}function Xc(e,t){return Kh(e.name,t.name)}function Zc(e,t){return Kh(e,t)}Jc.EMPTY_NODE=new Qc;let ed;function td(e){return"number"==typeof e?"number:"+Yh(e):"string:"+e}function rd(e){var t;e.isLeafNode()?(t=e.val(),g("string"==typeof t||"number"==typeof t||"object"==typeof t&&we(t,".sv"),"Priority must be a string or number.")):g(e===ed||e.isEmpty(),"priority of unexpected type."),g(e===ed||e.getPriority().isEmpty(),"Priority nodes can't have a priority of their own.")}let nd;class id{static set __childrenNodeConstructor(e){nd=e}static get __childrenNodeConstructor(){return nd}constructor(e,t=id.__childrenNodeConstructor.EMPTY_NODE){this.value_=e,this.priorityNode_=t,this.lazyHash_=null,g(null!=this.value_,"LeafNode shouldn't be created with null/undefined value."),rd(this.priorityNode_)}isLeafNode(){return!0}getPriority(){return this.priorityNode_}updatePriority(e){return new id(this.value_,e)}getImmediateChild(e){return".priority"===e?this.priorityNode_:id.__childrenNodeConstructor.EMPTY_NODE}getChild(e){return _(e)?this:".priority"===v(e)?this.priorityNode_:id.__childrenNodeConstructor.EMPTY_NODE}hasChild(){return!1}getPredecessorChildName(e,t){return null}updateImmediateChild(e,t){return".priority"===e?this.updatePriority(t):t.isEmpty()&&".priority"!==e?this:id.__childrenNodeConstructor.EMPTY_NODE.updateImmediateChild(e,t).updatePriority(this.priorityNode_)}updateChild(e,t){var r=v(e);return null===r?t:t.isEmpty()&&".priority"!==r?this:(g(".priority"!==r||1===Nc(e),".priority must be the last token in a path"),this.updateImmediateChild(r,id.__childrenNodeConstructor.EMPTY_NODE.updateChild(Rc(e),t)))}isEmpty(){return!1}numChildren(){return 0}forEachChild(e,t){return!1}val(e){return e&&!this.getPriority().isEmpty()?{".value":this.getValue(),".priority":this.getPriority().val()}:this.getValue()}hash(){if(null===this.lazyHash_){let e="";this.priorityNode_.isEmpty()||(e+="priority:"+td(this.priorityNode_.val())+":");var t=typeof this.value_;e=(e+=t+":")+("number"==t?Yh(this.value_):this.value_),this.lazyHash_=Ch(e)}return this.lazyHash_}getValue(){return this.value_}compareTo(e){return e===id.__childrenNodeConstructor.EMPTY_NODE?1:e instanceof id.__childrenNodeConstructor?-1:(g(e.isLeafNode(),"Unknown node type"),this.compareToLeafNode_(e))}compareToLeafNode_(e){var t=typeof e.value_,r=typeof this.value_,n=id.VALUE_TYPE_ORDER.indexOf(t),i=id.VALUE_TYPE_ORDER.indexOf(r);return g(0<=n,"Unknown leaf type: "+t),g(0<=i,"Unknown leaf type: "+r),n===i?"object"==r?0:this.value_<e.value_?-1:this.value_===e.value_?0:1:i-n}withIndex(){return this}isIndexed(){return!0}equals(e){return e===this||!!e.isLeafNode()&&this.value_===e.value_&&this.priorityNode_.equals(e.priorityNode_)}}id.VALUE_TYPE_ORDER=["object","boolean","number","string"];let sd,ad;class od extends Hc{compare(e,t){var r=e.node.getPriority(),n=t.node.getPriority(),r=r.compareTo(n);return 0===r?Kh(e.name,t.name):r}isDefinedOn(e){return!e.getPriority().isEmpty()}indexedValueChanged(e,t){return!e.getPriority().equals(t.getPriority())}minPost(){return d.MIN}maxPost(){return new d(Hh,new id("[PRIORITY-POST]",ad))}makePost(e,t){var r=sd(e);return new d(t,new id("[PRIORITY-POST]",r))}toString(){return".priority"}}let ld=new od,ud=Math.log(2);class hd{constructor(e){this.count=(t=e+1,parseInt(Math.log(t)/ud,10)),this.current_=this.count-1,t=this.count;var t,r=parseInt(Array(t+1).join("1"),2);this.bits_=e+1&r}nextBitIsOne(){var e=!(this.bits_&1<<this.current_);return this.current_--,e}}let cd=function(l,e,u,t){l.sort(e);let h=function(e,t){var r,n,i=t-e;let s,a;return 0==i?null:1==i?(s=l[e],a=u?u(s):s,new Yc(a,s.node,Yc.BLACK,null,null)):(i=parseInt(i/2,10)+e,r=h(e,i),n=h(i+1,t),s=l[i],a=u?u(s):s,new Yc(a,s.node,Yc.BLACK,r,n))};var r=(e=>{let s=null,a=null,o=l.length;function t(e,t){var r=o-e,n=o,n=(o-=e,h(1+r,n)),r=l[r],i=u?u(r):r,e=new Yc(i,r.node,t,null,n);s=(s?s.left=e:a=e,e)}for(let i=0;i<e.count;++i){var r=e.nextBitIsOne(),n=Math.pow(2,e.count-(i+1));r?t(n,Yc.BLACK):(t(n,Yc.BLACK),t(n,Yc.RED))}return a})(new hd(l.length));return new Jc(t||e,r)},dd,pd={};class fd{static get Default(){return g((pd,ld),"ChildrenNode.ts has not been loaded"),dd=dd||new fd({".priority":pd},{".priority":ld})}constructor(e,t){this.indexes_=e,this.indexSet_=t}get(e){var t=be(this.indexes_,e);if(t)return t instanceof Jc?t:null;throw new Error("No index defined for "+e)}hasIndex(e){return we(this.indexSet_,e.toString())}addIndex(e,t){g(e!==Wc,"KeyIndex always exists and isn't meant to be added to the IndexMap.");var r=[];let n=!1;var i=t.getIterator(d.Wrap);let s=i.getNext();for(;s;)n=n||e.isDefinedOn(s.node),r.push(s),s=i.getNext();let a;a=n?cd(r,e.getCompare()):pd;var o=e.toString(),l={...this.indexSet_},u=(l[o]=e,{...this.indexes_});return u[o]=a,new fd(u,l)}addToIndexes(s,a){var e=Ee(this.indexes_,(t,e)=>{var r=be(this.indexSet_,e);if(g(r,"Missing index implementation for "+e),t===pd){if(r.isDefinedOn(s.node)){var n=[],i=a.getIterator(d.Wrap);let e=i.getNext();for(;e;)e.name!==s.name&&n.push(e),e=i.getNext();return n.push(s),cd(n,r.getCompare())}return pd}{r=a.get(s.name);let e=t;return(e=r?e.remove(new d(s.name,r)):e).insert(s,s.node)}});return new fd(e,this.indexSet_)}removeFromIndexes(r,n){var e=Ee(this.indexes_,e=>{var t;return e!==pd&&(t=n.get(r.name))?e.remove(new d(r.name,t)):e});return new fd(e,this.indexSet_)}}let gd;class y{static get EMPTY_NODE(){return gd=gd||new y(new Jc(Zc),null,fd.Default)}constructor(e,t,r){this.children_=e,this.priorityNode_=t,this.indexMap_=r,this.lazyHash_=null,this.priorityNode_&&rd(this.priorityNode_),this.children_.isEmpty()&&g(!this.priorityNode_||this.priorityNode_.isEmpty(),"An empty node cannot have a priority")}isLeafNode(){return!1}getPriority(){return this.priorityNode_||gd}updatePriority(e){return this.children_.isEmpty()?this:new y(this.children_,e,this.indexMap_)}getImmediateChild(e){var t;return".priority"===e?this.getPriority():null===(t=this.children_.get(e))?gd:t}getChild(e){var t=v(e);return null===t?this:this.getImmediateChild(t).getChild(Rc(e))}hasChild(e){return null!==this.children_.get(e)}updateImmediateChild(r,n){if(g(n,"We should always be passing snapshot nodes"),".priority"===r)return this.updatePriority(n);{var i=new d(r,n);let e,t;t=n.isEmpty()?(e=this.children_.remove(r),this.indexMap_.removeFromIndexes(i,this.children_)):(e=this.children_.insert(r,n),this.indexMap_.addToIndexes(i,this.children_));i=e.isEmpty()?gd:this.priorityNode_;return new y(e,i,t)}}updateChild(e,t){var r,n=v(e);return null===n?t:(g(".priority"!==v(e)||1===Nc(e),".priority must be the last token in a path"),r=this.getImmediateChild(n).updateChild(Rc(e),t),this.updateImmediateChild(n,r))}isEmpty(){return this.children_.isEmpty()}numChildren(){return this.children_.count()}val(r){if(this.isEmpty())return null;let n={},i=0,s=0,a=!0;if(this.forEachChild(ld,(e,t)=>{n[e]=t.val(r),i++,a&&y.INTEGER_REGEXP_.test(e)?s=Math.max(s,Number(e)):a=!1}),!r&&a&&s<2*i){var e,t=[];for(e in n)t[e]=n[e];return t}return r&&!this.getPriority().isEmpty()&&(n[".priority"]=this.getPriority().val()),n}hash(){if(null===this.lazyHash_){let n="";this.getPriority().isEmpty()||(n+="priority:"+td(this.getPriority().val())+":"),this.forEachChild(ld,(e,t)=>{var r=t.hash();""!==r&&(n+=":"+e+":"+r)}),this.lazyHash_=""===n?"":Ch(n)}return this.lazyHash_}getPredecessorChildName(e,t,r){var n=this.resolveIndex_(r);return n?(n=n.getPredecessorKey(new d(e,t)))?n.name:null:this.children_.getPredecessorKey(e)}getFirstChildName(e){var t=this.resolveIndex_(e);return t?(t=t.minKey())&&t.name:this.children_.minKey()}getFirstChild(e){var t=this.getFirstChildName(e);return t?new d(t,this.children_.get(t)):null}getLastChildName(e){var t=this.resolveIndex_(e);return t?(t=t.maxKey())&&t.name:this.children_.maxKey()}getLastChild(e){var t=this.getLastChildName(e);return t?new d(t,this.children_.get(t)):null}forEachChild(e,t){var r=this.resolveIndex_(e);return r?r.inorderTraversal(e=>t(e.name,e.node)):this.children_.inorderTraversal(t)}getIterator(e){return this.getIteratorFrom(e.minPost(),e)}getIteratorFrom(t,r){var e=this.resolveIndex_(r);if(e)return e.getIteratorFrom(t,e=>e);{var n=this.children_.getIteratorFrom(t.name,d.Wrap);let e=n.peek();for(;null!=e&&r.compare(e,t)<0;)n.getNext(),e=n.peek();return n}}getReverseIterator(e){return this.getReverseIteratorFrom(e.maxPost(),e)}getReverseIteratorFrom(t,r){var e=this.resolveIndex_(r);if(e)return e.getReverseIteratorFrom(t,e=>e);{var n=this.children_.getReverseIteratorFrom(t.name,d.Wrap);let e=n.peek();for(;null!=e&&0<r.compare(e,t);)n.getNext(),e=n.peek();return n}}compareTo(e){return this.isEmpty()?e.isEmpty()?0:-1:e.isLeafNode()||e.isEmpty()?1:e===vd?-1:0}withIndex(e){var t;return e===Wc||this.indexMap_.hasIndex(e)?this:(t=this.indexMap_.addIndex(e,this.children_),new y(this.children_,this.priorityNode_,t))}isIndexed(e){return e===Wc||this.indexMap_.hasIndex(e)}equals(e){if(e===this)return!0;if(!e.isLeafNode()){var r=e;if(this.getPriority().equals(r.getPriority())){if(this.children_.count()!==r.children_.count())return!1;{var n=this.getIterator(ld),i=r.getIterator(ld);let e=n.getNext(),t=i.getNext();for(;e&&t;){if(e.name!==t.name||!e.node.equals(t.node))return!1;e=n.getNext(),t=i.getNext()}return null===e&&null===t}}}return!1}resolveIndex_(e){return e===Wc?null:this.indexMap_.get(e.toString())}}y.INTEGER_REGEXP_=/^(0|[1-9]\d*)$/;class md extends y{constructor(){super(new Jc(Zc),y.EMPTY_NODE,fd.Default)}compareTo(e){return e===this?0:1}equals(e){return e===this}getPriority(){return this}getImmediateChild(e){return y.EMPTY_NODE}isEmpty(){return!1}}let vd=new md,_d=(Object.defineProperties(d,{MIN:{value:new d(zh,y.EMPTY_NODE)},MAX:{value:new d(Hh,vd)}}),Gc.__EMPTY_NODE=y.EMPTY_NODE,id.__childrenNodeConstructor=y,t=vd,ed=t,t=vd,ad=t,!0);function yd(s,e=null){if(null===s)return y.EMPTY_NODE;var t,r;if("object"==typeof s&&".priority"in s&&(e=s[".priority"]),g(null===e||"string"==typeof e||"number"==typeof e||"object"==typeof e&&".sv"in e,"Invalid priority type found: "+typeof e),"object"!=typeof(s="object"==typeof s&&".value"in s&&null!==s[".value"]?s[".value"]:s)||".sv"in s)return t=s,new id(t,yd(e));if(s instanceof Array||!_d){let n=y.EMPTY_NODE;return $h(s,(e,t)=>{var r;!we(s,e)||"."===e.substring(0,1)||!(r=yd(t)).isLeafNode()&&r.isEmpty()||(n=n.updateImmediateChild(e,r))}),n.updatePriority(yd(e))}{let n=[],i=!1;return $h(s,(e,t)=>{var r;"."===e.substring(0,1)||(r=yd(t)).isEmpty()||(i=i||!r.getPriority().isEmpty(),n.push(new d(e,r)))}),0===n.length?y.EMPTY_NODE:(t=cd(n,Xc,e=>e.name,Zc),i?(r=cd(n,ld.getCompare()),new y(t,yd(e),new fd({".priority":r},{".priority":ld}))):new y(t,yd(e),fd.Default))}}sd=yd;class wd extends Hc{constructor(e){super(),this.indexPath_=e,g(!_(e)&&".priority"!==v(e),"Can't create PathIndex with empty path or .priority key")}extractChild(e){return e.getChild(this.indexPath_)}isDefinedOn(e){return!e.getChild(this.indexPath_).isEmpty()}compare(e,t){var r=this.extractChild(e.node),n=this.extractChild(t.node),r=r.compareTo(n);return 0===r?Kh(e.name,t.name):r}makePost(e,t){var r=yd(e),r=y.EMPTY_NODE.updateChild(this.indexPath_,r);return new d(t,r)}maxPost(){var e=y.EMPTY_NODE.updateChild(this.indexPath_,vd);return new d(Hh,e)}toString(){return xc(this.indexPath_,0).join("/")}}class bd extends Hc{compare(e,t){var r=e.node.compareTo(t.node);return 0===r?Kh(e.name,t.name):r}isDefinedOn(e){return!0}indexedValueChanged(e,t){return!e.equals(t)}minPost(){return d.MIN}maxPost(){return d.MAX}makePost(e,t){var r=yd(e);return new d(t,r)}toString(){return".value"}}let Td=new bd;function Ed(e){return{type:"value",snapshotNode:e}}function Id(e,t){return{type:"child_added",snapshotNode:t,childName:e}}function Cd(e,t){return{type:"child_removed",snapshotNode:t,childName:e}}function Sd(e,t,r){return{type:"child_changed",snapshotNode:t,childName:e,oldSnap:r}}class kd{constructor(e){this.index_=e}updateChild(e,t,r,n,i,s){g(e.isIndexed(this.index_),"A node must be indexed if only a child is updated");var a=e.getImmediateChild(t);return a.getChild(n).equals(r.getChild(n))&&a.isEmpty()===r.isEmpty()||(null!=s&&(r.isEmpty()?e.hasChild(t)?s.trackChildChange(Cd(t,a)):g(e.isLeafNode(),"A child remove without an old child only makes sense on a leaf node"):a.isEmpty()?s.trackChildChange(Id(t,r)):s.trackChildChange(Sd(t,r,a))),e.isLeafNode()&&r.isEmpty())?e:e.updateImmediateChild(t,r).withIndex(this.index_)}updateFullNode(n,r,i){return null!=i&&(n.isLeafNode()||n.forEachChild(ld,(e,t)=>{r.hasChild(e)||i.trackChildChange(Cd(e,t))}),r.isLeafNode()||r.forEachChild(ld,(e,t)=>{var r;n.hasChild(e)?(r=n.getImmediateChild(e)).equals(t)||i.trackChildChange(Sd(e,t,r)):i.trackChildChange(Id(e,t))})),r.withIndex(this.index_)}updatePriority(e,t){return e.isEmpty()?y.EMPTY_NODE:e.updatePriority(t)}filtersNodes(){return!1}getIndexedFilter(){return this}getIndex(){return this.index_}}class Ad{constructor(e){this.indexedFilter_=new kd(e.getIndex()),this.index_=e.getIndex(),this.startPost_=Ad.getStartPost_(e),this.endPost_=Ad.getEndPost_(e),this.startIsInclusive_=!e.startAfterSet_,this.endIsInclusive_=!e.endBeforeSet_}getStartPost(){return this.startPost_}getEndPost(){return this.endPost_}matches(e){var t=this.startIsInclusive_?this.index_.compare(this.getStartPost(),e)<=0:this.index_.compare(this.getStartPost(),e)<0,r=this.endIsInclusive_?this.index_.compare(e,this.getEndPost())<=0:this.index_.compare(e,this.getEndPost())<0;return t&&r}updateChild(e,t,r,n,i,s){return this.matches(new d(t,r))||(r=y.EMPTY_NODE),this.indexedFilter_.updateChild(e,t,r,n,i,s)}updateFullNode(e,t,r){let n=(t=t.isLeafNode()?y.EMPTY_NODE:t).withIndex(this.index_),i=(n=n.updatePriority(y.EMPTY_NODE),this);return t.forEachChild(ld,(e,t)=>{i.matches(new d(e,t))||(n=n.updateImmediateChild(e,y.EMPTY_NODE))}),this.indexedFilter_.updateFullNode(e,n,r)}updatePriority(e,t){return e}filtersNodes(){return!0}getIndexedFilter(){return this.indexedFilter_}getIndex(){return this.index_}static getStartPost_(e){var t;return e.hasStart()?(t=e.getIndexStartName(),e.getIndex().makePost(e.getIndexStartValue(),t)):e.getIndex().minPost()}static getEndPost_(e){var t;return e.hasEnd()?(t=e.getIndexEndName(),e.getIndex().makePost(e.getIndexEndValue(),t)):e.getIndex().maxPost()}}class Nd{constructor(e){this.withinDirectionalStart=e=>this.reverse_?this.withinEndPost(e):this.withinStartPost(e),this.withinDirectionalEnd=e=>this.reverse_?this.withinStartPost(e):this.withinEndPost(e),this.withinStartPost=e=>{var t=this.index_.compare(this.rangedFilter_.getStartPost(),e);return this.startIsInclusive_?t<=0:t<0},this.withinEndPost=e=>{var t=this.index_.compare(e,this.rangedFilter_.getEndPost());return this.endIsInclusive_?t<=0:t<0},this.rangedFilter_=new Ad(e),this.index_=e.getIndex(),this.limit_=e.getLimit(),this.reverse_=!e.isViewFromLeft(),this.startIsInclusive_=!e.startAfterSet_,this.endIsInclusive_=!e.endBeforeSet_}updateChild(e,t,r,n,i,s){return this.rangedFilter_.matches(new d(t,r))||(r=y.EMPTY_NODE),e.getImmediateChild(t).equals(r)?e:e.numChildren()<this.limit_?this.rangedFilter_.getIndexedFilter().updateChild(e,t,r,n,i,s):this.fullLimitUpdateChild_(e,t,r,i,s)}updateFullNode(e,r,t){let n;if(r.isLeafNode()||r.isEmpty())n=y.EMPTY_NODE.withIndex(this.index_);else if(2*this.limit_<r.numChildren()&&r.isIndexed(this.index_)){n=y.EMPTY_NODE.withIndex(this.index_);let e,t=(e=this.reverse_?r.getReverseIteratorFrom(this.rangedFilter_.getEndPost(),this.index_):r.getIteratorFrom(this.rangedFilter_.getStartPost(),this.index_),0);for(;e.hasNext()&&t<this.limit_;){var i=e.getNext();if(this.withinDirectionalStart(i)){if(!this.withinDirectionalEnd(i))break;n=n.updateImmediateChild(i.name,i.node),t++}}}else{n=(n=r.withIndex(this.index_)).updatePriority(y.EMPTY_NODE);let e,t=(e=this.reverse_?n.getReverseIterator(this.index_):n.getIterator(this.index_),0);for(;e.hasNext();){var s=e.getNext();t<this.limit_&&this.withinDirectionalStart(s)&&this.withinDirectionalEnd(s)?t++:n=n.updateImmediateChild(s.name,y.EMPTY_NODE)}}return this.rangedFilter_.getIndexedFilter().updateFullNode(e,n,t)}updatePriority(e,t){return e}filtersNodes(){return!0}getIndexedFilter(){return this.rangedFilter_.getIndexedFilter()}getIndex(){return this.index_}fullLimitUpdateChild_(e,t,r,n,i){let s;if(this.reverse_){let r=this.index_.getCompare();s=(e,t)=>r(t,e)}else s=this.index_.getCompare();var a=e,o=(g(a.numChildren()===this.limit_,""),new d(t,r)),l=this.reverse_?a.getFirstChild(this.index_):a.getLastChild(this.index_),u=this.rangedFilter_.matches(o);if(a.hasChild(t)){var h=a.getImmediateChild(t);let e=n.getChildAfterChild(this.index_,l,this.reverse_);for(;null!=e&&(e.name===t||a.hasChild(e.name));)e=n.getChildAfterChild(this.index_,e,this.reverse_);var c=null==e?1:s(e,o);return u&&!r.isEmpty()&&0<=c?(null!=i&&i.trackChildChange(Sd(t,r,h)),a.updateImmediateChild(t,r)):(null!=i&&i.trackChildChange(Cd(t,h)),c=a.updateImmediateChild(t,y.EMPTY_NODE),null!=e&&this.rangedFilter_.matches(e)?(null!=i&&i.trackChildChange(Id(e.name,e.node)),c.updateImmediateChild(e.name,e.node)):c)}return!r.isEmpty()&&u&&0<=s(l,o)?(null!=i&&(i.trackChildChange(Cd(l.name,l.node)),i.trackChildChange(Id(t,r))),a.updateImmediateChild(t,r).updateImmediateChild(l.name,y.EMPTY_NODE)):e}}class Rd{constructor(){this.limitSet_=!1,this.startSet_=!1,this.startNameSet_=!1,this.startAfterSet_=!1,this.endSet_=!1,this.endNameSet_=!1,this.endBeforeSet_=!1,this.limit_=0,this.viewFrom_="",this.indexStartValue_=null,this.indexStartName_="",this.indexEndValue_=null,this.indexEndName_="",this.index_=ld}hasStart(){return this.startSet_}isViewFromLeft(){return""===this.viewFrom_?this.startSet_:"l"===this.viewFrom_}getIndexStartValue(){return g(this.startSet_,"Only valid if start has been set"),this.indexStartValue_}getIndexStartName(){return g(this.startSet_,"Only valid if start has been set"),this.startNameSet_?this.indexStartName_:zh}hasEnd(){return this.endSet_}getIndexEndValue(){return g(this.endSet_,"Only valid if end has been set"),this.indexEndValue_}getIndexEndName(){return g(this.endSet_,"Only valid if end has been set"),this.endNameSet_?this.indexEndName_:Hh}hasLimit(){return this.limitSet_}hasAnchoredLimit(){return this.limitSet_&&""!==this.viewFrom_}getLimit(){return g(this.limitSet_,"Only valid if limit has been set"),this.limit_}getIndex(){return this.index_}loadsAllData(){return!(this.startSet_||this.endSet_||this.limitSet_)}isDefault(){return this.loadsAllData()&&this.index_===ld}copy(){var e=new Rd;return e.limitSet_=this.limitSet_,e.limit_=this.limit_,e.startSet_=this.startSet_,e.startAfterSet_=this.startAfterSet_,e.indexStartValue_=this.indexStartValue_,e.startNameSet_=this.startNameSet_,e.indexStartName_=this.indexStartName_,e.endSet_=this.endSet_,e.endBeforeSet_=this.endBeforeSet_,e.indexEndValue_=this.indexEndValue_,e.endNameSet_=this.endNameSet_,e.indexEndName_=this.indexEndName_,e.index_=this.index_,e.viewFrom_=this.viewFrom_,e}}function Pd(e,t,r){var n=e.copy();return n.startSet_=!0,n.indexStartValue_=t=void 0===t?null:t,null!=r?(n.startNameSet_=!0,n.indexStartName_=r):(n.startNameSet_=!1,n.indexStartName_=""),n}function xd(e,t,r){var n=e.copy();return n.endSet_=!0,n.indexEndValue_=t=void 0===t?null:t,void 0!==r?(n.endNameSet_=!0,n.indexEndName_=r):(n.endNameSet_=!1,n.indexEndName_=""),n}function Dd(e,t){var r=e.copy();return r.index_=t,r}function Od(t){var r,n={};if(!t.isDefault()){let e;e=t.index_===ld?"$priority":t.index_===Td?"$value":t.index_===Wc?"$key":(g(t.index_ instanceof wd,"Unrecognized index type!"),t.index_.toString()),n.orderBy=_e(e),t.startSet_&&(n[r=t.startAfterSet_?"startAfter":"startAt"]=_e(t.indexStartValue_),t.startNameSet_)&&(n[r]+=","+_e(t.indexStartName_)),t.endSet_&&(n[r=t.endBeforeSet_?"endBefore":"endAt"]=_e(t.indexEndValue_),t.endNameSet_)&&(n[r]+=","+_e(t.indexEndName_)),t.limitSet_&&(t.isViewFromLeft()?n.limitToFirst=t.limit_:n.limitToLast=t.limit_)}return n}function Ld(t){var r={};if(t.startSet_&&(r.sp=t.indexStartValue_,t.startNameSet_&&(r.sn=t.indexStartName_),r.sin=!t.startAfterSet_),t.endSet_&&(r.ep=t.indexEndValue_,t.endNameSet_&&(r.en=t.indexEndName_),r.ein=!t.endBeforeSet_),t.limitSet_){r.l=t.limit_;let e=t.viewFrom_;""===e&&(e=t.isViewFromLeft()?"l":"r"),r.vf=e}return t.index_!==ld&&(r.i=t.index_.toString()),r}class Md extends Tc{reportStats(e){throw new Error("Method not implemented.")}static getListenId_(e,t){return void 0!==t?"tag$"+t:(g(e._queryParams.isDefault(),"should have a tag if it's not a default query."),e._path.toString())}constructor(e,t,r,n){super(),this.repoInfo_=e,this.onDataUpdate_=t,this.authTokenProvider_=r,this.appCheckTokenProvider_=n,this.log_=Sh("p:rest:"),this.listens_={}}listen(e,t,n,i){let s=e._path.toString(),a=(this.log_("Listen called for "+s+" "+e._queryIdentifier),Md.getListenId_(e,n)),o={};this.listens_[a]=o;var r=Od(e._queryParams);this.restRequest_(s+".json",r,(t,e)=>{let r=e;if(null===(t=404===t?r=null:t)&&this.onDataUpdate_(s,r,!1,n),be(this.listens_,a)===o){let e;e=t?401===t?"permission_denied":"rest_error:"+t:"ok",i(e,null)}})}unlisten(e,t){var r=Md.getListenId_(e,t);delete this.listens_[r]}get(e){var t=Od(e._queryParams);let n=e._path.toString(),i=new Z;return this.restRequest_(n+".json",t,(e,t)=>{let r=t;null===(e=404===e?r=null:e)?(this.onDataUpdate_(n,r,!1,null),i.resolve(r)):i.reject(new Error(r))}),i.promise}refreshAuthToken(e){}restRequest_(i,s={},a){return s.format="export",Promise.all([this.authTokenProvider_.getToken(!1),this.appCheckTokenProvider_.getToken(!1)]).then(([e,t])=>{e&&e.accessToken&&(s.auth=e.accessToken),t&&t.token&&(s.ac=t.token);let r=(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host+i+"?ns="+this.repoInfo_.namespace+Se(s),n=(this.log_("Sending REST request for "+r),new XMLHttpRequest);n.onreadystatechange=()=>{if(a&&4===n.readyState){this.log_("REST Response for "+r+" received. status:",n.status,"response:",n.responseText);let e=null;if(200<=n.status&&n.status<300){try{e=ve(n.responseText)}catch(e){Bh("Failed to parse JSON response for "+r+": "+n.responseText)}a(null,e)}else 401!==n.status&&404!==n.status&&Bh("Got unsuccessful REST response for "+r+" Status: "+n.status),a(n.status);a=null}},n.open("GET",r,!0),n.send()})}}class Fd{constructor(){this.rootNode_=y.EMPTY_NODE}getNode(e){return this.rootNode_.getChild(e)}updateSnapshot(e,t){this.rootNode_=this.rootNode_.updateChild(e,t)}}function Ud(){return{value:null,children:new Map}}function Vd(e,t,r){var n;_(t)?(e.value=r,e.children.clear()):null!==e.value?e.value=e.value.updateChild(t,r):(n=v(t),e.children.has(n)||e.children.set(n,Ud()),Vd(e.children.get(n),t=Rc(t),r))}function Bd(e,r,n){var i;null!==e.value?n(r,e.value):(i=(e,t)=>{Bd(t,new kc(r.toString()+"/"+e),n)},e.children.forEach((e,t)=>{i(t,e)}))}class qd{constructor(e){this.collection_=e,this.last_=null}get(){var e=this.collection_.get();let r={...e};return this.last_&&$h(this.last_,(e,t)=>{r[e]=r[e]-t}),this.last_=e,r}}class jd{constructor(e,t){this.server_=t,this.statsToReport_={},this.statsListener_=new qd(e);var r=1e4+2e4*Math.random();Qh(this.reportStats_.bind(this),Math.floor(r))}reportStats_(){var e=this.statsListener_.get();let r={},n=!1;$h(e,(e,t)=>{0<t&&we(this.statsToReport_,e)&&(r[e]=t,n=!0)}),n&&this.server_.reportStats(r),Qh(this.reportStats_.bind(this),Math.floor(2*Math.random()*3e5))}}function zd(){return{fromUser:!0,fromServer:!1,queryId:null,tagged:!1}}function Hd(){return{fromUser:!1,fromServer:!0,queryId:null,tagged:!1}}function Kd(e){return{fromUser:!1,fromServer:!0,queryId:e,tagged:!0}}(t=Ih=Ih||{})[t.OVERWRITE=0]="OVERWRITE",t[t.MERGE=1]="MERGE",t[t.ACK_USER_WRITE=2]="ACK_USER_WRITE",t[t.LISTEN_COMPLETE=3]="LISTEN_COMPLETE";class Gd{constructor(e,t,r){this.path=e,this.affectedTree=t,this.revert=r,this.type=Ih.ACK_USER_WRITE,this.source=zd()}operationForChild(e){var t;return _(this.path)?null!=this.affectedTree.value?(g(this.affectedTree.children.isEmpty(),"affectedTree should not have overlapping affected paths."),this):(t=this.affectedTree.subtree(new kc(e)),new Gd(Ac(),t,this.revert)):(g(v(this.path)===e,"operationForChild called for unrelated child."),new Gd(Rc(this.path),this.affectedTree,this.revert))}}class Wd{constructor(e,t){this.source=e,this.path=t,this.type=Ih.LISTEN_COMPLETE}operationForChild(e){return _(this.path)?new Wd(this.source,Ac()):new Wd(this.source,Rc(this.path))}}class $d{constructor(e,t,r){this.source=e,this.path=t,this.snap=r,this.type=Ih.OVERWRITE}operationForChild(e){return _(this.path)?new $d(this.source,Ac(),this.snap.getImmediateChild(e)):new $d(this.source,Rc(this.path),this.snap)}}class Yd{constructor(e,t,r){this.source=e,this.path=t,this.children=r,this.type=Ih.MERGE}operationForChild(e){var t;return _(this.path)?(t=this.children.subtree(new kc(e))).isEmpty()?null:t.value?new $d(this.source,Ac(),t.value):new Yd(this.source,Ac(),t):(g(v(this.path)===e,"Can't get a merge for a child not on the path of the operation"),new Yd(this.source,Rc(this.path),this.children))}toString(){return"Operation("+this.path+": "+this.source.toString()+" merge: "+this.children.toString()+")"}}class Qd{constructor(e,t,r){this.node_=e,this.fullyInitialized_=t,this.filtered_=r}isFullyInitialized(){return this.fullyInitialized_}isFiltered(){return this.filtered_}isCompleteForPath(e){var t;return _(e)?this.isFullyInitialized()&&!this.filtered_:(t=v(e),this.isCompleteForChild(t))}isCompleteForChild(e){return this.isFullyInitialized()&&!this.filtered_||this.node_.hasChild(e)}getNode(){return this.node_}}class Jd{constructor(e){this.query_=e,this.index_=this.query_._queryParams.getIndex()}}function Xd(r,e,t,n){var i=[];let s=[];return e.forEach(e=>{var t;"child_changed"===e.type&&r.index_.indexedValueChanged(e.oldSnap,e.snapshotNode)&&s.push((t=e.childName,{type:"child_moved",snapshotNode:e.snapshotNode,childName:t}))}),Zd(r,i,"child_removed",e,n,t),Zd(r,i,"child_added",e,n,t),Zd(r,i,"child_moved",s,n,t),Zd(r,i,"child_changed",e,n,t),Zd(r,i,"value",e,n,t),i}function Zd(s,a,t,e,o,l){var r=e.filter(e=>e.type===t);r.sort((e,t)=>{var r=s;if(null==e.childName||null==t.childName)throw V("Should only compare child_ events.");var n=new d(e.childName,e.snapshotNode),i=new d(t.childName,t.snapshotNode);return r.index_.compare(n,i)}),r.forEach(t=>{e=s,i=l,"value"!==(n=t).type&&"child_removed"!==n.type&&(n.prevName=i.getPredecessorChildName(n.childName,n.snapshotNode,e.index_));let r=n;var e,n,i;o.forEach(e=>{e.respondsTo(t.type)&&a.push(e.createEvent(r,s.query_))})})}function e1(e,t){return{eventCache:e,serverCache:t}}function t1(e,t,r,n){return e1(new Qd(t,r,n),e.serverCache)}function r1(e,t,r,n){return e1(e.eventCache,new Qd(t,r,n))}function n1(e){return e.eventCache.isFullyInitialized()?e.eventCache.getNode():null}function i1(e){return e.serverCache.isFullyInitialized()?e.serverCache.getNode():null}let s1;class a1{static fromObject(e){let r=new a1(null);return $h(e,(e,t)=>{r=r.set(new kc(e),t)}),r}constructor(e,t=s1=s1||new Jc(Gh)){this.value=e,this.children=t}isEmpty(){return null===this.value&&this.children.isEmpty()}findRootMostMatchingPathAndValue(e,t){var r,n;return null!=this.value&&t(this.value)?{path:Ac(),value:this.value}:!_(e)&&(r=v(e),null!==(n=this.children.get(r)))&&null!=(n=n.findRootMostMatchingPathAndValue(Rc(e),t))?{path:Oc(new kc(r),n.path),value:n.value}:null}findRootMostValueAndPath(e){return this.findRootMostMatchingPathAndValue(e,()=>!0)}subtree(e){var t;return _(e)?this:(t=v(e),null!==(t=this.children.get(t))?t.subtree(Rc(e)):new a1(null))}set(e,t){var r,n;return _(e)?new a1(t,this.children):(n=v(e),r=(this.children.get(n)||new a1(null)).set(Rc(e),t),n=this.children.insert(n,r),new a1(this.value,n))}remove(t){if(_(t))return this.children.isEmpty()?new a1(null):new a1(null,this.children);var r=v(t),n=this.children.get(r);if(n){n=n.remove(Rc(t));let e;return e=n.isEmpty()?this.children.remove(r):this.children.insert(r,n),null===this.value&&e.isEmpty()?new a1(null):new a1(this.value,e)}return this}get(e){var t;return _(e)?this.value:(t=v(e),(t=this.children.get(t))?t.get(Rc(e)):null)}setTree(t,r){if(_(t))return r;{var n=v(t),i=(this.children.get(n)||new a1(null)).setTree(Rc(t),r);let e;return e=i.isEmpty()?this.children.remove(n):this.children.insert(n,i),new a1(this.value,e)}}fold(e){return this.fold_(Ac(),e)}fold_(r,n){let i={};return this.children.inorderTraversal((e,t)=>{i[e]=t.fold_(Oc(r,e),n)}),n(r,this.value,i)}findOnPath(e,t){return this.findOnPath_(e,Ac(),t)}findOnPath_(e,t,r){var n,i=!!this.value&&r(t,this.value);return i||(!_(e)&&(i=v(e),n=this.children.get(i))?n.findOnPath_(Rc(e),Oc(t,i),r):null)}foreachOnPath(e,t){return this.foreachOnPath_(e,Ac(),t)}foreachOnPath_(e,t,r){var n,i;return _(e)?this:(this.value&&r(t,this.value),n=v(e),(i=this.children.get(n))?i.foreachOnPath_(Rc(e),Oc(t,n),r):new a1(null))}foreach(e){this.foreach_(Ac(),e)}foreach_(r,n){this.children.inorderTraversal((e,t)=>{t.foreach_(Oc(r,e),n)}),this.value&&n(r,this.value)}foreachChild(r){this.children.inorderTraversal((e,t)=>{t.value&&r(e,t.value)})}}class o1{constructor(e){this.writeTree_=e}static empty(){return new o1(new a1(null))}}function l1(t,r,n){if(_(r))return new o1(new a1(n));var i=t.writeTree_.findRootMostValueAndPath(r);if(null==i)return s=new a1(n),s=t.writeTree_.setTree(r,s),new o1(s);{var s=i.path;let e=i.value;i=Lc(s,r);return e=e.updateChild(i,n),new o1(t.writeTree_.set(s,e))}}function u1(e,r,t){let n=e;return $h(t,(e,t)=>{n=l1(n,Oc(r,e),t)}),n}function h1(e,t){var r;return _(t)?o1.empty():(r=e.writeTree_.setTree(t,new a1(null)),new o1(r))}function c1(e,t){return null!=d1(e,t)}function d1(e,t){var r=e.writeTree_.findRootMostValueAndPath(t);return null!=r?e.writeTree_.get(r.path).getChild(Lc(r.path,t)):null}function p1(e){let r=[];var t=e.writeTree_.value;return null!=t?t.isLeafNode()||t.forEachChild(ld,(e,t)=>{r.push(new d(e,t))}):e.writeTree_.children.inorderTraversal((e,t)=>{null!=t.value&&r.push(new d(e,t.value))}),r}function f1(e,t){var r;return _(t)?e:null!=(r=d1(e,t))?new o1(new a1(r)):new o1(e.writeTree_.subtree(t))}function g1(e){return e.writeTree_.isEmpty()}function m1(e,t){return function n(i,e,s){{if(null!=e.value)return s.updateChild(i,e.value);{let r=null;return e.children.inorderTraversal((e,t)=>{".priority"===e?(g(null!==t.value,"Priority writes must always be leaf nodes"),r=t.value):s=n(Oc(i,e),t,s)}),s=s.getChild(i).isEmpty()||null===r?s:s.updateChild(Oc(i,".priority"),r)}}}(Ac(),e.writeTree_,t)}function v1(e,t){return N1(t,e)}function _1(t,r){var e,n=t.allWrites.findIndex(e=>e.writeId===r);g(0<=n,"removeWrite called with nonexistent writeId.");let i=t.allWrites[n],s=(t.allWrites.splice(n,1),i.visible),a=!1,o=t.allWrites.length-1;for(;s&&0<=o;){var l=t.allWrites[o];l.visible&&(o>=n&&((e,t)=>{if(e.snap)return Uc(e.path,t);for(var r in e.children)if(e.children.hasOwnProperty(r)&&Uc(Oc(e.path,r),t))return 1})(l,i.path)?s=!1:Uc(i.path,l.path)&&(a=!0)),o--}return!!s&&(a?((e=t).visibleWrites=w1(e.allWrites,y1,Ac()),0<e.allWrites.length?e.lastWriteId=e.allWrites[e.allWrites.length-1].writeId:e.lastWriteId=-1):i.snap?t.visibleWrites=h1(t.visibleWrites,i.path):$h(i.children,e=>{t.visibleWrites=h1(t.visibleWrites,Oc(i.path,e))}),!0)}function y1(e){return e.visible}function w1(e,t,r){let n=o1.empty();for(let a=0;a<e.length;++a){var i=e[a];if(t(i)){var s=i.path;let e;if(i.snap)Uc(r,s)?(e=Lc(r,s),n=l1(n,e,i.snap)):Uc(s,r)&&(e=Lc(s,r),n=l1(n,Ac(),i.snap.getChild(e)));else{if(!i.children)throw V("WriteRecord should have .snap or .children");Uc(r,s)?(e=Lc(r,s),n=u1(n,e,i.children)):Uc(s,r)&&(_(e=Lc(s,r))?n=u1(n,Ac(),i.children):(s=be(i.children,v(e)))&&(i=s.getChild(Rc(e)),n=l1(n,Ac(),i)))}}}return n}function b1(e,t,r,n,i){var s;return n||i?(s=f1(e.visibleWrites,t),!i&&g1(s)?r:i||null!=r||c1(s,Ac())?m1(w1(e.allWrites,function(e){return(e.visible||i)&&(!n||!~n.indexOf(e.writeId))&&(Uc(e.path,t)||Uc(t,e.path))},t),r||y.EMPTY_NODE):null):null!=(s=d1(e.visibleWrites,t))?s:g1(s=f1(e.visibleWrites,t))?r:null!=r||c1(s,Ac())?m1(s,r||y.EMPTY_NODE):null}function T1(e,t,r,n){return b1(e.writeTree,e.treePath,t,r,n)}function E1(e,t){{var r=e.writeTree;e=e.treePath;let i=y.EMPTY_NODE;var n=d1(r.visibleWrites,e);if(n)n.isLeafNode()||n.forEachChild(ld,(e,t)=>{i=i.updateImmediateChild(e,t)});else if(t){let n=f1(r.visibleWrites,e);t.forEachChild(ld,(e,t)=>{var r=m1(f1(n,new kc(e)),t);i=i.updateImmediateChild(e,r)}),p1(n).forEach(e=>{i=i.updateImmediateChild(e.name,e.node)})}else p1(f1(r.visibleWrites,e)).forEach(e=>{i=i.updateImmediateChild(e.name,e.node)});return i}}function I1(e,t,r,n){return i=e.writeTree,e=e.treePath,t=t,r=r,n=n,g(r||n,"Either existingEventSnap or existingServerSnap must exist"),s=Oc(e,t),c1(i.visibleWrites,s)?null:g1(s=f1(i.visibleWrites,s))?n.getChild(t):m1(s,n.getChild(t));var i,s}function C1(e,t){return r=e.writeTree,e=Oc(e.treePath,t),d1(r.visibleWrites,e);var r}function S1(e,r,n,i,s,a){{var o=e.writeTree,l=(e=e.treePath,n),u=i;n=s,i=a;let t;var h=f1(o.visibleWrites,e),c=d1(h,Ac());if(null!=c)t=c;else{if(null==r)return[];t=m1(h,r)}if((t=t.withIndex(i)).isEmpty()||t.isLeafNode())return[];{var d=[],p=i.getCompare(),f=n?t.getReverseIteratorFrom(l,i):t.getIteratorFrom(l,i);let e=f.getNext();for(;e&&d.length<u;)0!==p(e,l)&&d.push(e),e=f.getNext();return d}}}function k1(e,t,r){return n=e.writeTree,r=r,i=Oc(e.treePath,e=t),null!=(s=d1(n.visibleWrites,i))?s:r.isCompleteForChild(e)?m1(f1(n.visibleWrites,i),r.getNode().getImmediateChild(e)):null;var n,i,s}function A1(e,t){return N1(Oc(e.treePath,t),e.writeTree)}function N1(e,t){return{treePath:e,writeTree:t}}class R1{constructor(){this.changeMap=new Map}trackChildChange(e){var t=e.type,r=e.childName,n=(g("child_added"===t||"child_changed"===t||"child_removed"===t,"Only child changes supported for tracking"),g(".priority"!==r,"Only non-priority child changes can be tracked."),this.changeMap.get(r));if(n){var i=n.type;if("child_added"===t&&"child_removed"===i)this.changeMap.set(r,Sd(r,e.snapshotNode,n.snapshotNode));else if("child_removed"===t&&"child_added"===i)this.changeMap.delete(r);else if("child_removed"===t&&"child_changed"===i)this.changeMap.set(r,Cd(r,n.oldSnap));else if("child_changed"===t&&"child_added"===i)this.changeMap.set(r,Id(r,e.snapshotNode));else{if("child_changed"!==t||"child_changed"!==i)throw V("Illegal combination of changes: "+e+" occurred after "+n);this.changeMap.set(r,Sd(r,e.snapshotNode,n.oldSnap))}}else this.changeMap.set(r,e)}getChanges(){return Array.from(this.changeMap.values())}}let P1=new class{getCompleteChild(e){return null}getChildAfterChild(e,t,r){return null}};class x1{constructor(e,t,r=null){this.writes_=e,this.viewCache_=t,this.optCompleteServerCache_=r}getCompleteChild(e){var t=this.viewCache_.eventCache;return t.isCompleteForChild(e)?t.getNode().getImmediateChild(e):(t=null!=this.optCompleteServerCache_?new Qd(this.optCompleteServerCache_,!0,!1):this.viewCache_.serverCache,k1(this.writes_,e,t))}getChildAfterChild(e,t,r){var n=null!=this.optCompleteServerCache_?this.optCompleteServerCache_:i1(this.viewCache_),n=S1(this.writes_,n,t,1,r,e);return 0===n.length?null:n[0]}}function D1(e,t,r,n,i){var s=new R1;let a,o;if(r.type===Ih.OVERWRITE){var l=r;a=l.source.fromUser?M1(e,t,l.path,l.snap,n,i,s):(g(l.source.fromServer,"Unknown source."),o=l.source.tagged||t.serverCache.isFiltered()&&!_(l.path),L1(e,t,l.path,l.snap,n,i,o,s))}else if(r.type===Ih.MERGE){var l=r;a=l.source.fromUser?((n,i,s,e,a,o,l)=>{let u=i;return e.foreach((e,t)=>{var r=Oc(s,e);F1(i,v(r))&&(u=M1(n,u,r,t,a,o,l))}),e.foreach((e,t)=>{var r=Oc(s,e);F1(i,v(r))||(u=M1(n,u,r,t,a,o,l))}),u})(e,t,l.path,l.children,n,i,s):(g(l.source.fromServer,"Unknown source."),o=l.source.tagged||t.serverCache.isFiltered(),V1(e,t,l.path,l.children,n,i,o,s))}else if(r.type===Ih.ACK_USER_WRITE){l=r;a=l.revert?((r,n,i,s,e,a)=>{let o;if(null!=C1(s,i))return n;{var l=new x1(s,n,e),u=n.eventCache.getNode();let t;if(_(i)||".priority"===v(i)){let e;e=e=n.serverCache.isFullyInitialized()?T1(s,i1(n)):(h=n.serverCache.getNode(),g(h instanceof y,"serverChildren would be complete if leaf node"),E1(s,h)),t=r.filter.updateFullNode(u,e,a)}else{var h=v(i);let e=k1(s,h,n.serverCache);null==e&&n.serverCache.isCompleteForChild(h)&&(e=u.getImmediateChild(h)),(t=null!=e?r.filter.updateChild(u,h,e,Rc(i),l,a):n.eventCache.getNode().hasChild(h)?r.filter.updateChild(u,h,y.EMPTY_NODE,Rc(i),l,a):u).isEmpty()&&n.serverCache.isFullyInitialized()&&(o=T1(s,i1(n))).isLeafNode()&&(t=r.filter.updateFullNode(t,o,a))}return o=n.serverCache.isFullyInitialized()||null!=C1(s,Ac()),t1(n,t,o,r.filter.filtersNodes())}})(e,t,l.path,n,i,s):((e,t,i,r,s,a,o)=>{if(null!=C1(s,i))return t;let l=t.serverCache.isFiltered(),u=t.serverCache;if(null!=r.value){if(_(i)&&u.isFullyInitialized()||u.isCompleteForPath(i))return L1(e,t,i,u.getNode().getChild(i),s,a,l,o);if(_(i)){let r=new a1(null);return u.getNode().forEachChild(Wc,(e,t)=>{r=r.set(new kc(e),t)}),V1(e,t,i,r,s,a,l,o)}return t}{let n=new a1(null);return r.foreach((e,t)=>{var r=Oc(i,e);u.isCompleteForPath(r)&&(n=n.set(e,u.getNode().getChild(r)))}),V1(e,t,i,n,s,a,l,o)}})(e,t,l.path,l.affectedTree,n,i,s)}else{if(r.type!==Ih.LISTEN_COMPLETE)throw V("Unknown operation type: "+r.type);a=(i=e,e=r.path,r=n,n=s,l=t.serverCache,l=r1(t,l.getNode(),l.isFullyInitialized()||_(e),l.isFiltered()),O1(i,l,e,r,P1,n))}var u,h,s=s.getChanges(),i=t,e=a,r=s,c=e.eventCache;return c.isFullyInitialized()&&(u=c.getNode().isLeafNode()||c.getNode().isEmpty(),h=n1(i),0<r.length||!i.eventCache.isFullyInitialized()||u&&!c.getNode().equals(h)||!c.getNode().getPriority().equals(h.getPriority()))&&r.push(Ed(n1(e))),{viewCache:a,changes:s}}function O1(n,i,s,a,o,l){var u=i.eventCache;if(null!=C1(a,s))return i;{let t,r;if(_(s))g(i.serverCache.isFullyInitialized(),"If change path is empty, we must have complete server data"),t=i.serverCache.isFiltered()?(h=E1(a,(h=i1(i))instanceof y?h:y.EMPTY_NODE),n.filter.updateFullNode(i.eventCache.getNode(),h,l)):(h=T1(a,i1(i)),n.filter.updateFullNode(i.eventCache.getNode(),h,l));else{var h=v(s);if(".priority"===h){g(1===Nc(s),"Can't have a priority with additional path components");var c=u.getNode(),d=I1(a,s,c,r=i.serverCache.getNode());t=null!=d?n.filter.updatePriority(c,d):u.getNode()}else{c=Rc(s);let e;e=u.isCompleteForChild(h)?(r=i.serverCache.getNode(),null!=(d=I1(a,s,u.getNode(),r))?u.getNode().getImmediateChild(h).updateChild(c,d):u.getNode().getImmediateChild(h)):k1(a,h,i.serverCache),t=null!=e?n.filter.updateChild(u.getNode(),h,e,c,o,l):u.getNode()}}return t1(i,t,u.isFullyInitialized()||_(s),n.filter.filtersNodes())}}function L1(e,t,r,n,i,s,a,o){var l=t.serverCache;let u;var h=a?e.filter:e.filter.getIndexedFilter();if(_(r))u=h.updateFullNode(l.getNode(),n,null);else if(h.filtersNodes()&&!l.isFiltered()){var c=l.getNode().updateChild(r,n);u=h.updateFullNode(l.getNode(),c,null)}else{c=v(r);if(!l.isCompleteForPath(r)&&1<Nc(r))return t;var d=Rc(r),p=l.getNode().getImmediateChild(c).updateChild(d,n);u=".priority"===c?h.updatePriority(l.getNode(),p):h.updateChild(l.getNode(),c,p,d,P1,null)}c=r1(t,u,l.isFullyInitialized()||_(r),h.filtersNodes());return O1(e,c,r,i,new x1(i,c,s),o)}function M1(t,r,n,i,e,s,a){var o=r.eventCache;let l,u;var h=new x1(e,r,s);if(_(n))u=t.filter.updateFullNode(r.eventCache.getNode(),i,a),l=t1(r,u,!0,t.filter.filtersNodes());else{var c=v(n);if(".priority"===c)u=t.filter.updatePriority(r.eventCache.getNode(),i),l=t1(r,u,o.isFullyInitialized(),o.isFiltered());else{var d,p=Rc(n),f=o.getNode().getImmediateChild(c);let e;e=_(p)?i:null!=(d=h.getCompleteChild(c))?".priority"===Pc(p)&&d.getChild(Dc(p)).isEmpty()?d:d.updateChild(p,i):y.EMPTY_NODE,l=f.equals(e)?r:t1(r,t.filter.updateChild(o.getNode(),c,e,p,h,a),o.isFullyInitialized(),t.filter.filtersNodes())}}return l}function F1(e,t){return e.eventCache.isCompleteForChild(t)}function U1(e,r,t){return t.foreach((e,t)=>{r=r.updateChild(e,t)}),r}function V1(n,i,e,t,s,a,o,l){if(i.serverCache.getNode().isEmpty()&&!i.serverCache.isFullyInitialized())return i;let u=i,r,h=(r=_(e)?t:new a1(null).setTree(e,t),i.serverCache.getNode());return r.children.inorderTraversal((e,t)=>{var r;h.hasChild(e)&&(r=U1(0,i.serverCache.getNode().getImmediateChild(e),t),u=L1(n,u,new kc(e),r,s,a,o,l))}),r.children.inorderTraversal((e,t)=>{var r=!i.serverCache.isCompleteForChild(e)&&null===t.value;h.hasChild(e)||r||(r=U1(0,i.serverCache.getNode().getImmediateChild(e),t),u=L1(n,u,new kc(e),r,s,a,o,l))}),u}class B1{constructor(e,t){this.query_=e,this.eventRegistrations_=[];var r=this.query_._queryParams,n=new kd(r.getIndex()),r=(e=r).loadsAllData()?new kd(e.getIndex()):new(e.hasLimit()?Nd:Ad)(e),i=(this.processor_={filter:r},t.serverCache),s=t.eventCache,a=n.updateFullNode(y.EMPTY_NODE,i.getNode(),null),o=r.updateFullNode(y.EMPTY_NODE,s.getNode(),null),a=new Qd(a,i.isFullyInitialized(),n.filtersNodes()),i=new Qd(o,s.isFullyInitialized(),r.filtersNodes());this.viewCache_=e1(i,a),this.eventGenerator_=new Jd(this.query_)}get query(){return this.query_}}function q1(e){return 0===e.eventRegistrations_.length}function j1(n,i,s){let a=[];if(s){g(null==i,"A cancel should cancel all event registrations.");let r=n.query._path;n.eventRegistrations_.forEach(e=>{var t=e.createCancelEvent(s,r);t&&a.push(t)})}if(i){let e=[];for(let t=0;t<n.eventRegistrations_.length;++t){var r=n.eventRegistrations_[t];if(r.matches(i)){if(i.hasAnyCallback()){e=e.concat(n.eventRegistrations_.slice(t+1));break}}else e.push(r)}n.eventRegistrations_=e}else n.eventRegistrations_=[];return a}function z1(e,t,r,n){t.type===Ih.MERGE&&null!==t.source.queryId&&(g(i1(e.viewCache_),"We should always have a full cache before handling merges"),g(n1(e.viewCache_),"Missing event cache, even though we have a server cache"));var i=e.viewCache_,s=D1(e.processor_,i,t,r,n);return t=e.processor_,r=s.viewCache,g(r.eventCache.getNode().isIndexed(t.filter.getIndex()),"Event snap not indexed"),g(r.serverCache.getNode().isIndexed(t.filter.getIndex()),"Server snap not indexed"),g(s.viewCache.serverCache.isFullyInitialized()||!i.serverCache.isFullyInitialized(),"Once a server snap is complete, it should never go back"),e.viewCache_=s.viewCache,H1(e,s.changes,s.viewCache.eventCache.getNode(),null)}function H1(e,t,r,n){var i=n?[n]:e.eventRegistrations_;return Xd(e.eventGenerator_,t,r,i)}let K1;class G1{constructor(){this.views=new Map}}function W1(t,r,n,i){var e=r.source.queryId;if(null!==e)return e=t.views.get(e),g(null!=e,"SyncTree gave us an op for an invalid query."),z1(e,r,n,i);{let e=[];for(var s of t.views.values())e=e.concat(z1(s,r,n,i));return e}}function $1(e,r,n,i,s){var a=r._queryIdentifier,a=e.views.get(a);if(a)return a;{let e=T1(n,s?i:null),t=!1;t=!!e||(e=i instanceof y?E1(n,i):y.EMPTY_NODE,!1);a=e1(new Qd(e,t,!1),new Qd(i,s,!1));return new B1(r,a)}}function Y1(e,t,n,i,s,r){var a=$1(e,t,i,s,r);e.views.has(t._queryIdentifier)||e.views.set(t._queryIdentifier,a),a.eventRegistrations_.push(n);{s=n,a=(i=a).viewCache_.eventCache;let r=[];return a.getNode().isLeafNode()||a.getNode().forEachChild(ld,(e,t)=>{r.push(Id(e,t))}),a.isFullyInitialized()&&r.push(Ed(a.getNode())),H1(i,r,a.getNode(),s)}}function Q1(e,t,r,n){var i=t._queryIdentifier,s=[];let a=[];var o=tp(e);if("default"===i)for(var[l,u]of e.views.entries())a=a.concat(j1(u,r,n)),q1(u)&&(e.views.delete(l),u.query._queryParams.loadsAllData()||s.push(u.query));else{var h=e.views.get(i);h&&(a=a.concat(j1(h,r,n)),q1(h))&&(e.views.delete(i),h.query._queryParams.loadsAllData()||s.push(h.query))}return o&&!tp(e)&&s.push((g(K1,"Reference.ts has not been loaded"),new K1(t._repo,t._path))),{removed:s,events:a}}function J1(e){var t,r=[];for(t of e.views.values())t.query._queryParams.loadsAllData()||r.push(t);return r}function X1(e,t){let r=null;for(var n of e.views.values())r=r||(i=n,s=t,n=void 0,(n=i1(i.viewCache_))&&(i.query._queryParams.loadsAllData()||!_(s)&&!n.getImmediateChild(v(s)).isEmpty())?n.getChild(s):null);var i,s;return r}function Z1(e,t){var r;return t._queryParams.loadsAllData()?rp(e):(r=t._queryIdentifier,e.views.get(r))}function ep(e,t){return null!=Z1(e,t)}function tp(e){return null!=rp(e)}function rp(e){for(var t of e.views.values())if(t.query._queryParams.loadsAllData())return t;return null}let np;let ip=1;class sp{constructor(e){this.listenProvider_=e,this.syncPointTree_=new a1(null),this.pendingWriteTree_={visibleWrites:o1.empty(),allWrites:[],lastWriteId:-1},this.tagToQueryMap=new Map,this.queryToTagMap=new Map}}function ap(e,t,r,n,i){var s,a,o,l;return s=e.pendingWriteTree_,a=t,o=r,n=n,l=i,g(n>s.lastWriteId,"Stacking an older write on top of newer ones"),s.allWrites.push({path:a,snap:o,writeId:n,visible:l=void 0===l?!0:l}),l&&(s.visibleWrites=l1(s.visibleWrites,a,o)),s.lastWriteId=n,i?gp(e,new $d(zd(),t,r)):[]}function op(e,t,r,n){i=e.pendingWriteTree_,s=t,a=r,n=n,g(n>i.lastWriteId,"Stacking an older merge on top of newer ones"),i.allWrites.push({path:s,children:a,writeId:n,visible:!0}),i.visibleWrites=u1(i.visibleWrites,s,a),i.lastWriteId=n;var i,s,a,o=a1.fromObject(r);return gp(e,new Yd(zd(),t,o))}function lp(e,t,r=!1){var n=((e,t)=>{for(let n=0;n<e.allWrites.length;n++){var r=e.allWrites[n];if(r.writeId===t)return r}return null})(e.pendingWriteTree_,t);if(_1(e.pendingWriteTree_,t)){let t=new a1(null);return null!=n.snap?t=t.set(Ac(),!0):$h(n.children,e=>{t=t.set(new kc(e),!0)}),gp(e,new Gd(n.path,t,r))}return[]}function up(e,t,r){return gp(e,new $d(Hd(),t,r))}function hp(r,t,n,i,s=!1){var a=t._path,o=r.syncPointTree_.get(a);let l=[];if(o&&("default"===t._queryIdentifier||ep(o,t))){var u=Q1(o,t,n,i),o=(0===o.views.size&&(r.syncPointTree_=r.syncPointTree_.remove(a)),u.removed);if(l=u.events,!s){var u=-1!==o.findIndex(e=>e._queryParams.loadsAllData()),h=r.syncPointTree_.findOnPath(a,(e,t)=>tp(t));if(u&&!h){a=r.syncPointTree_.subtree(a);if(!a.isEmpty()){var c=a.fold((e,t,n)=>{if(t&&tp(t))return[rp(t)];{let r=[];return t&&(r=J1(t)),$h(n,(e,t)=>{r=r.concat(t)}),r}});for(let e=0;e<c.length;++e){var d=c[e],p=d.query,d=vp(r,d);r.listenProvider_.startListening(Ep(p),_p(r,p),d.hashFn,d.onComplete)}}}!h&&0<o.length&&!i&&(u?r.listenProvider_.stopListening(Ep(t),null):o.forEach(e=>{var t=r.queryToTagMap.get(yp(e));r.listenProvider_.stopListening(Ep(e),t)}))}var f=r,g=o;for(let e=0;e<g.length;++e){var m,v=g[e];v._queryParams.loadsAllData()||(v=yp(v),m=f.queryToTagMap.get(v),f.queryToTagMap.delete(v),f.tagToQueryMap.delete(m))}}return l}function cp(e,t,r,n){var i,s,a=wp(e,n);return null!=a?(i=(a=bp(a)).path,a=a.queryId,s=Lc(i,t),Tp(e,i,new $d(Kd(a),s,r))):[]}function dp(e,t,r,n=!1){let i=t._path,s=null,a=!1,o=(e.syncPointTree_.foreachOnPath(i,(e,t)=>{var r=Lc(e,i);s=s||X1(t,r),a=a||tp(t)}),e.syncPointTree_.get(i));o?(a=a||tp(o),s=s||X1(o,Ac())):(o=new G1,e.syncPointTree_=e.syncPointTree_.set(i,o));let l;null!=s?l=!0:(l=!1,s=y.EMPTY_NODE,e.syncPointTree_.subtree(i).foreachChild((e,t)=>{var r=X1(t,Ac());r&&(s=s.updateImmediateChild(e,r))}));var u,h=ep(o,t),c=(h||t._queryParams.loadsAllData()||(u=yp(t),g(!e.queryToTagMap.has(u),"View does not exist, but we have a tag"),c=ip++,e.queryToTagMap.set(u,c),e.tagToQueryMap.set(c,u)),v1(e.pendingWriteTree_,i));let d=Y1(o,t,r,c,s,l);return h||a||n||(u=Z1(o,t),d=d.concat(((t,e,r)=>{var n=e._path,i=_p(t,e),s=vp(t,r),s=t.listenProvider_.startListening(Ep(e),i,s.hashFn,s.onComplete),n=t.syncPointTree_.subtree(n);if(i)g(!tp(n.value),"If we're adding a query, it shouldn't be shadowed");else{var a=n.fold((e,t,n)=>{if(!_(e)&&t&&tp(t))return[rp(t).query];{let r=[];return t&&(r=r.concat(J1(t).map(e=>e.query))),$h(n,(e,t)=>{r=r.concat(t)}),r}});for(let e=0;e<a.length;++e){var o=a[e];t.listenProvider_.stopListening(Ep(o),_p(t,o))}}return s})(e,t,u))),d}function pp(e,n,t){var r=e.pendingWriteTree_,i=e.syncPointTree_.findOnPath(n,(e,t)=>{var r=X1(t,Lc(e,n));if(r)return r});return b1(r,n,i,t,!0)}function fp(e,t){let n=t._path,i=null,r=(e.syncPointTree_.foreachOnPath(n,(e,t)=>{var r=Lc(e,n);i=i||X1(t,r)}),e.syncPointTree_.get(n));r?i=i||X1(r,Ac()):(r=new G1,e.syncPointTree_=e.syncPointTree_.set(n,r));var s=null!=i,a=s?new Qd(i,!0,!1):null,o=v1(e.pendingWriteTree_,t._path);return n1($1(r,t,o,s?a.getNode():y.EMPTY_NODE,s).viewCache_)}function gp(e,t){return function a(t,o,l,u){{if(_(t.path))return mp(t,o,l,u);{let e=o.get(Ac()),r=(null==l&&null!=e&&(l=X1(e,Ac())),[]),n=v(t.path),i=t.operationForChild(n),s=o.children.get(n);if(s&&i){let e=l?l.getImmediateChild(n):null,t=A1(u,n);r=r.concat(a(i,s,e,t))}return r=e?r.concat(W1(e,t,u,l)):r}}}(t,e.syncPointTree_,null,v1(e.pendingWriteTree_,Ac()))}function mp(s,e,a,o){var t=e.get(Ac());null==a&&null!=t&&(a=X1(t,Ac()));let l=[];return e.children.inorderTraversal((e,t)=>{var r=a?a.getImmediateChild(e):null,n=A1(o,e),i=s.operationForChild(e);i&&(l=l.concat(mp(i,t,r,n)))}),l=t?l.concat(W1(t,s,o,a)):l}function vp(o,e){let l=e.query,u=_p(o,l);return{hashFn:()=>(e.viewCache_.serverCache.getNode()||y.EMPTY_NODE).hash(),onComplete:e=>{var t,r,n,i,s,a;return"ok"===e?u?(t=o,r=l._path,n=u,(a=wp(t,n))?(i=(a=bp(a)).path,a=a.queryId,s=Lc(i,r),Tp(t,i,new Wd(Kd(a),s))):[]):(n=o,r=l._path,gp(n,new Wd(Hd(),r))):(i=((e,t)=>{let r="Unknown Error";"too_big"===e?r="The data requested exceeds the maximum size that can be accessed with a single request.":"permission_denied"===e?r="Client doesn't have permission to access the desired data.":"unavailable"===e&&(r="The service is unavailable");var n=new Error(e+" at "+t._path.toString()+": "+r);return n.code=e.toUpperCase(),n})(e,l),hp(o,l,null,i))}}}function _p(e,t){var r=yp(t);return e.queryToTagMap.get(r)}function yp(e){return e._path.toString()+"$"+e._queryIdentifier}function wp(e,t){return e.tagToQueryMap.get(t)}function bp(e){var t=e.indexOf("$");return g(-1!==t&&t<e.length-1,"Bad queryKey."),{queryId:e.substr(t+1),path:new kc(e.substr(0,t))}}function Tp(e,t,r){var n=e.syncPointTree_.get(t),i=(g(n,"Missing sync point for query tag that we're tracking"),v1(e.pendingWriteTree_,t));return W1(n,r,i,null)}function Ep(e){return e._queryParams.loadsAllData()&&!e._queryParams.isDefault()?(g(np,"Reference.ts has not been loaded"),new np(e._repo,e._path)):e}class Ip{constructor(e){this.node_=e}getImmediateChild(e){var t=this.node_.getImmediateChild(e);return new Ip(t)}node(){return this.node_}}class Cp{constructor(e,t){this.syncTree_=e,this.path_=t}getImmediateChild(e){var t=Oc(this.path_,e);return new Cp(this.syncTree_,t)}node(){return pp(this.syncTree_,this.path_)}}let Sp=function(e){return(e=e||{}).timestamp=e.timestamp||(new Date).getTime(),e},kp=function(e,t,r){return e&&"object"==typeof e?(g(".sv"in e,"Unexpected leaf node or priority contents"),"string"==typeof e[".sv"]?Ap(e[".sv"],t,r):"object"==typeof e[".sv"]?Np(e[".sv"],t):void g(!1,"Unexpected server value: "+JSON.stringify(e,null,2))):e},Ap=function(e,t,r){if("timestamp"===e)return r.timestamp;g(!1,"Unexpected server value: "+e)},Np=function(e,t,r){e.hasOwnProperty("increment")||g(!1,"Unexpected server value: "+JSON.stringify(e,null,2));var n=e.increment,i=("number"!=typeof n&&g(!1,"Unexpected increment value: "+n),t.node());return g(null!=i,"Expected ChildrenNode.EMPTY_NODE for nulls"),!i.isLeafNode()||"number"!=typeof(i=i.getValue())?n:i+n},Rp=function(e,t,r,n){return xp(t,new Cp(r,e),n)},Pp=function(e,t,r){return xp(e,new Ip(t),r)};function xp(e,n,i){var t,r,s=e.getPriority().val(),s=kp(s,n.getImmediateChild(".priority"),i);let a;return e.isLeafNode()?(r=e,(t=kp(r.getValue(),n,i))!==r.getValue()||s!==r.getPriority().val()?new id(t,yd(s)):e):(r=e,s!==(a=r).getPriority().val()&&(a=a.updatePriority(new id(s))),r.forEachChild(ld,(e,t)=>{var r=xp(t,n.getImmediateChild(e),i);r!==t&&(a=a.updateImmediateChild(e,r))}),a)}class Dp{constructor(e="",t=null,r={children:{},childCount:0}){this.name=e,this.parent=t,this.node=r}}function Op(e,t){let r=t instanceof kc?t:new kc(t),n=e,i=v(r);for(;null!==i;){var s=be(n.node.children,i)||{children:{},childCount:0};n=new Dp(i,n,s),r=Rc(r),i=v(r)}return n}function Lp(e){return e.node.value}function Mp(e,t){e.node.value=t,Bp(e)}function Fp(e){return 0<e.node.childCount}function Up(r,n){$h(r.node.children,(e,t)=>{n(new Dp(e,r,t))})}function Vp(e){return new kc(null===e.parent?e.name:Vp(e.parent)+"/"+e.name)}function Bp(e){var t,r,n,i;null!==e.parent&&(t=e.parent,r=e.name,n=(e=>void 0===Lp(e)&&!Fp(e))(e=e),i=we(t.node.children,r),n&&i?(delete t.node.children[r],t.node.childCount--,Bp(t)):n||i||(t.node.children[r]=e.node,t.node.childCount++,Bp(t)))}let qp=/[\[\].#$\/\u0000-\u001F\u007F]/,jp=/[\[\].#$\u0000-\u001F\u007F]/,zp=10485760,Hp=function(e){return"string"==typeof e&&0!==e.length&&!qp.test(e)},Kp=function(e){return"string"==typeof e&&0!==e.length&&!jp.test(e)},Gp=function(e){return e=e&&e.replace(/^\/*\.info(\/|$)/,"/"),Kp(e)},Wp=function(e){return null===e||"string"==typeof e||"number"==typeof e&&!jh(e)||e&&"object"==typeof e&&we(e,".sv")},$p=function(e,t,r,n){n&&void 0===t||Yp(De(e,"value"),t,r)},Yp=function(a,e,t){let o=t instanceof kc?new Vc(t,a):t;if(void 0===e)throw new Error(a+"contains undefined "+qc(o));if("function"==typeof e)throw new Error(a+"contains a function "+qc(o)+" with contents = "+e.toString());if(jh(e))throw new Error(a+"contains "+e.toString()+" "+qc(o));if("string"==typeof e&&e.length>zp/3&&Fe(e)>zp)throw new Error(a+"contains a string greater than "+zp+" utf8 bytes "+qc(o)+" ('"+e.substring(0,50)+"...')");if(e&&"object"==typeof e){let i=!1,s=!1;if($h(e,(e,t)=>{if(".value"===e)i=!0;else if(".priority"!==e&&".sv"!==e&&(s=!0,!Hp(e)))throw new Error(a+" contains an invalid key ("+e+") "+qc(o)+'.  Keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]"');var r,n;r=o,e=e,0<r.parts_.length&&(r.byteLength_+=1),r.parts_.push(e),r.byteLength_+=Fe(e),Bc(r),Yp(a,t,o),e=o,n=e.parts_.pop(),e.byteLength_-=Fe(n),0<e.parts_.length&&--e.byteLength_}),i&&s)throw new Error(a+' contains ".value" child '+qc(o)+" in addition to actual children.")}},Qp=function(t,r){let n,i;for(n=0;n<r.length;n++){var s=xc(i=r[n]);for(let e=0;e<s.length;e++)if((".priority"!==s[e]||e!==s.length-1)&&!Hp(s[e]))throw new Error(t+"contains an invalid key ("+s[e]+") in path "+i.toString()+'. Keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]"')}r.sort(Mc);let e=null;for(n=0;n<r.length;n++){if(i=r[n],null!==e&&Uc(e,i))throw new Error(t+"contains a path "+e.toString()+" that is ancestor of another path "+i.toString());e=i}},Jp=function(e,t,s,r){if(!r||void 0!==t){let n=De(e,"values");if(!t||"object"!=typeof t||Array.isArray(t))throw new Error(n+" must be an object containing the children to replace.");let i=[];$h(t,(e,t)=>{var r=new kc(e);if(Yp(n,t,Oc(s,r)),".priority"===Pc(r)&&!Wp(t))throw new Error(n+"contains an invalid value for '"+r.toString()+"', which must be a valid Firebase priority (a string, finite number, server value, or null).");i.push(r)}),Qp(n,i)}},Xp=function(e,t,r){if(!r||void 0!==t){if(jh(t))throw new Error(De(e,"priority")+"is "+t.toString()+", but must be a valid Firebase priority (a string, finite number, server value, or null).");if(!Wp(t))throw new Error(De(e,"priority")+"must be a valid Firebase priority (a string, finite number, server value, or null).")}},Zp=function(e,t,r,n){if(!(n&&void 0===r||Hp(r)))throw new Error(De(e,t)+'was an invalid key = "'+r+'".  Firebase keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]").')},ef=function(e,t,r,n){if(!(n&&void 0===r||Kp(r)))throw new Error(De(e,t)+'was an invalid path = "'+r+'". Paths must be non-empty strings and can\'t contain ".", "#", "$", "[", or "]"')},tf=function(e,t,r,n){r=r&&r.replace(/^\/*\.info(\/|$)/,"/"),ef(e,t,r,n)},rf=function(e,t){if(".info"===v(t))throw new Error(e+" failed = Can't modify data under /.info/")},nf=function(e,t){var r=t.path.toString();if("string"!=typeof t.repoInfo.host||0===t.repoInfo.host.length||!Hp(t.repoInfo.namespace)&&"localhost"!==t.repoInfo.host.split(":")[0]||0!==r.length&&!Gp(r))throw new Error(De(e,"url")+'must be a valid firebase URL and the path can\'t contain ".", "#", "$", "[", or "]".')};class sf{constructor(){this.eventLists_=[],this.recursionDepth_=0}}function af(e,t){let r=null;for(let s=0;s<t.length;s++){var n=t[s],i=n.getPath();null===r||Fc(i,r.path)||(e.eventLists_.push(r),r=null),(r=null===r?{events:[],path:i}:r).events.push(n)}r&&e.eventLists_.push(r)}function of(e,t,r){af(e,r),uf(e,e=>Fc(e,t))}function lf(e,t,r){af(e,r),uf(e,e=>Uc(e,t)||Uc(t,e))}function uf(t,e){t.recursionDepth_++;let r=!0;for(let o=0;o<t.eventLists_.length;o++){var n=t.eventLists_[o];if(n)if(e(n.path)){s=a=i=void 0;var i=t.eventLists_[o];for(let e=0;e<i.events.length;e++){var s,a=i.events[e];null!==a&&(i.events[e]=null,s=a.getEventRunner(),Lh&&Uh("event: "+a.toString()),tc(s))}t.eventLists_[o]=null}else r=!1}r&&(t.eventLists_=[]),t.recursionDepth_--}let hf="repo_interrupt",cf=25;class df{constructor(e,t,r,n){this.repoInfo_=e,this.forceRestClient_=t,this.authTokenProvider_=r,this.appCheckProvider_=n,this.dataUpdateCount=0,this.statsListener_=null,this.eventQueue_=new sf,this.nextWriteId_=1,this.interceptServerDataCallback_=null,this.onDisconnect_=Ud(),this.transactionQueueTree_=new Dp,this.persistentConnection_=null,this.key=this.repoInfo_.toURLString()}toString(){return(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host}}function pf(a,e,t){if(a.stats_=fc(a.repoInfo_),a.forceRestClient_||rc())a.server_=new Md(a.repoInfo_,(e,t,r,n)=>{mf(a,e,t,r,n)},a.authTokenProvider_,a.appCheckProvider_),setTimeout(()=>vf(a,!0),0);else{if(null!=t){if("object"!=typeof t)throw new Error("Only objects are supported for option databaseAuthVariableOverride");try{_e(t)}catch(e){throw new Error("Invalid authOverride provided: "+e)}}a.persistentConnection_=new zc(a.repoInfo_,e,(e,t,r,n)=>{mf(a,e,t,r,n)},e=>{vf(a,e)},e=>{var r;r=a,$h(e,(e,t)=>{_f(r,e,t)})},a.authTokenProvider_,a.appCheckProvider_,t),a.server_=a.persistentConnection_}var r;a.authTokenProvider_.addTokenChangeListener(e=>{a.server_.refreshAuthToken(e)}),a.appCheckProvider_.addTokenChangeListener(e=>{a.server_.refreshAppCheckToken(e.token)}),a.statsReporter_=(e=()=>new jd(a.stats_,a.server_),r=a.repoInfo_.toString(),pc[r]||(pc[r]=e()),pc[r]),a.infoData_=new Fd,a.infoSyncTree_=new sp({startListening:(e,t,r,n)=>{let i=[];var s=a.infoData_.getNode(e._path);return s.isEmpty()||(i=up(a.infoSyncTree_,e._path,s),setTimeout(()=>{n("ok")},0)),i},stopListening:()=>{}}),_f(a,"connected",!1),a.serverSyncTree_=new sp({startListening:(n,e,t,i)=>(a.server_.listen(n,t,e,(e,t)=>{var r=i(e,t);lf(a.eventQueue_,n._path,r)}),[]),stopListening:(e,t)=>{a.server_.unlisten(e,t)}})}function ff(e){var t=e.infoData_.getNode(new kc(".info/serverTimeOffset")).val()||0;return(new Date).getTime()+t}function gf(e){return Sp({timestamp:ff(e)})}function mf(e,t,r,n,i){e.dataUpdateCount++;var s,a,o,l,u,h,c=new kc(t);r=e.interceptServerDataCallback_?e.interceptServerDataCallback_(t,r):r;let d=[],p=c;0<(d=i?n?(h=Ee(r,e=>yd(e)),t=e.serverSyncTree_,s=c,a=h,(h=wp(t,i))?(o=(h=bp(h)).path,h=h.queryId,l=Lc(o,s),u=a1.fromObject(a),Tp(t,o,new Yd(Kd(h),l,u))):[]):(o=yd(r),cp(e.serverSyncTree_,c,o,i)):n?(h=Ee(r,e=>yd(e)),s=e.serverSyncTree_,a=c,t=h,l=a1.fromObject(t),gp(s,new Yd(Hd(),a,l))):(u=yd(r),up(e.serverSyncTree_,c,u))).length&&(p=Nf(e,c)),lf(e.eventQueue_,p,d)}function vf(e,t){if(_f(e,"connected",t),!1===t){var a=e;Cf(a,"onDisconnectEvents");let n=gf(a),i=Ud(),s=(Bd(a.onDisconnect_,Ac(),(e,t)=>{var r=Rp(e,t,a.serverSyncTree_,n);Vd(i,e,r)}),[]);Bd(i,Ac(),(e,t)=>{s=s.concat(up(a.serverSyncTree_,e,t));var r=Df(a,e);Nf(a,r)}),a.onDisconnect_=Ud(),lf(a.eventQueue_,Ac(),s)}}function _f(e,t,r){var n=new kc("/.info/"+t),i=yd(r),i=(e.infoData_.updateSnapshot(n,i),up(e.infoSyncTree_,n,i));lf(e.eventQueue_,n,i)}function yf(e){return e.nextWriteId_++}function wf(n,i,e,t,s){Cf(n,"set",{path:i.toString(),value:e,priority:t});var r=gf(n),a=yd(e,t),o=pp(n.serverSyncTree_,i),o=Pp(a,o,r);let l=yf(n);r=ap(n.serverSyncTree_,i,o,l,!0),af(n.eventQueue_,r),n.server_.put(i.toString(),a.val(!0),(e,t)=>{var r="ok"===e,r=(r||Bh("set at "+i+" failed: "+e),lp(n.serverSyncTree_,l,!r));lf(n.eventQueue_,i,r),Sf(0,s,e,t)}),o=Df(n,i);Nf(n,o),lf(n.eventQueue_,o,[])}function bf(r,n,i){r.server_.onDisconnectCancel(n.toString(),(e,t)=>{"ok"===e&&!function e(r,t){var n;return _(t)?(r.value=null,r.children.clear(),!0):null!==r.value?!r.value.isLeafNode()&&(n=r.value,r.value=null,n.forEachChild(ld,(e,t)=>{Vd(r,new kc(e),t)}),e(r,t)):!(0<r.children.size)||(n=v(t),t=Rc(t),r.children.has(n)&&e(r.children.get(n),t)&&r.children.delete(n),0===r.children.size)}(r.onDisconnect_,n),Sf(0,i,e,t)})}function Tf(r,n,e,i){let s=yd(e);r.server_.onDisconnectPut(n.toString(),s.val(!0),(e,t)=>{"ok"===e&&Vd(r.onDisconnect_,n,s),Sf(0,i,e,t)})}function Ef(e,t,r){let n;n=".info"===v(t._path)?hp(e.infoSyncTree_,t,r):hp(e.serverSyncTree_,t,r),of(e.eventQueue_,t._path,n)}function If(e){e.persistentConnection_&&e.persistentConnection_.interrupt(hf)}function Cf(e,...t){let r="";e.persistentConnection_&&(r=e.persistentConnection_.id+":"),Uh(r,...t)}function Sf(e,n,i,s){n&&tc(()=>{if("ok"===i)n(null);else{var t=(i||"error").toUpperCase();let e=t;s&&(e+=": "+s);var r=new Error(e);r.code=t,n(r)}})}function kf(e,t,r){return pp(e.serverSyncTree_,t,r)||y.EMPTY_NODE}function Af(o,l=o.transactionQueueTree_){if(l||xf(o,l),Lp(l)){var u=Pf(o,l),e=(g(0<u.length,"Sending zero length transaction queue"),u.every(e=>0===e.status));if(e){var h=o;var c=Vp(l);var d=u;let e=d.map(e=>e.currentWriteId),t=kf(h,c,e),r=t,n=t.hash();for(let a=0;a<d.length;a++){var p=d[a],f=(g(0===p.status,"tryToSendTransactionQueue_: items in queue should all be run."),p.status=1,p.retryCount++,Lc(c,p.path));r=r.updateChild(f,p.currentOutputSnapshotRaw)}let i=r.val(!0),s=c;h.server_.put(s.toString(),i,t=>{Cf(h,"transaction put response",{path:s.toString(),status:t});let r=[];if("ok"===t){var n=[];for(let e=0;e<d.length;e++)d[e].status=2,r=r.concat(lp(h.serverSyncTree_,d[e].currentWriteId)),d[e].onComplete&&n.push(()=>d[e].onComplete(null,!0,d[e].currentOutputSnapshotResolved)),d[e].unwatcher();xf(h,Op(h.transactionQueueTree_,c)),Af(h,h.transactionQueueTree_),lf(h.eventQueue_,c,r);for(let t=0;t<n.length;t++)tc(n[t])}else{if("datastale"===t)for(let e=0;e<d.length;e++)3===d[e].status?d[e].status=4:d[e].status=0;else{Bh("transaction at "+s.toString()+" failed: "+t);for(let e=0;e<d.length;e++)d[e].status=4,d[e].abortReason=t}Nf(h,c)}},n)}}else Fp(l)&&Up(l,e=>{Af(o,e)})}function Nf(e,t){var r=Rf(e,t),n=Vp(r),r=Pf(e,r),i=e,s=r,a=n;if(0!==s.length){var o=[];let r=[];var l=s.filter(e=>0===e.status).map(e=>e.currentWriteId);for(let n=0;n<s.length;n++){var u=s[n],h=Lc(a,u.path);let e=!1,t;if(g(null!==h,"rerunTransactionsUnderNode_: relativePath should not be null."),4===u.status)e=!0,t=u.abortReason,r=r.concat(lp(i.serverSyncTree_,u.currentWriteId,!0));else if(0===u.status)if(u.retryCount>=cf)e=!0,t="maxretry",r=r.concat(lp(i.serverSyncTree_,u.currentWriteId,!0));else{var h=kf(i,u.path,l),c=(u.currentInputSnapshot=h,s[n].update(h.val()));if(void 0!==c){Yp("transaction failed: Data returned ",c,u.path);let e=yd(c);"object"==typeof c&&null!=c&&we(c,".priority")||(e=e.updatePriority(h.getPriority()));var c=u.currentWriteId,d=gf(i),h=Pp(e,h,d);u.currentOutputSnapshotRaw=e,u.currentOutputSnapshotResolved=h,u.currentWriteId=yf(i),l.splice(l.indexOf(c),1),r=(r=r.concat(ap(i.serverSyncTree_,u.path,h,u.currentWriteId,u.applyLocally))).concat(lp(i.serverSyncTree_,c,!0))}else e=!0,t="nodata",r=r.concat(lp(i.serverSyncTree_,u.currentWriteId,!0))}lf(i.eventQueue_,a,r),r=[],e&&(s[n].status=2,(e=>{setTimeout(e,Math.floor(0))})(s[n].unwatcher),s[n].onComplete)&&("nodata"===t?o.push(()=>s[n].onComplete(null,!1,s[n].currentInputSnapshot)):o.push(()=>s[n].onComplete(new Error(t),!1,null)))}xf(i,i.transactionQueueTree_);for(let e=0;e<o.length;e++)tc(o[e]);Af(i,i.transactionQueueTree_)}return n}function Rf(e,t){let r,n=e.transactionQueueTree_;for(r=v(t);null!==r&&void 0===Lp(n);)n=Op(n,r),t=Rc(t),r=v(t);return n}function Pf(e,t){var r=[];return function t(r,e,n){let i=Lp(e);if(i)for(let e=0;e<i.length;e++)n.push(i[e]);Up(e,e=>{t(r,e,n)})}(e,t,r),r.sort((e,t)=>e.order-t.order),r}function xf(t,r){var n=Lp(r);if(n){let e=0;for(let t=0;t<n.length;t++)2!==n[t].status&&(n[e]=n[t],e++);n.length=e,Mp(r,0<n.length?n:void 0)}Up(r,e=>{xf(t,e)})}function Df(t,e){var r=Vp(Rf(t,e)),n=Op(t.transactionQueueTree_,e);return((e,t,r)=>{let n=r?e:e.parent;for(;null!==n;){if(t(n))return;n=n.parent}})(n,e=>{Of(t,e)}),Of(t,n),function t(e,r,n,i){n&&!i&&r(e),Up(e,e=>{t(e,r,!0,i)}),n&&i&&r(e)}(n,e=>{Of(t,e)}),r}function Of(i,s){var a=Lp(s);if(a){var o=[];let e=[],t=-1;for(let r=0;r<a.length;r++)3!==a[r].status&&(1===a[r].status?(g(t===r-1,"All SENT items should be at beginning of queue."),a[t=r].status=3,a[r].abortReason="set"):(g(0===a[r].status,"Unexpected transaction status in abort"),a[r].unwatcher(),e=e.concat(lp(i.serverSyncTree_,a[r].currentWriteId,!0)),a[r].onComplete&&o.push(a[r].onComplete.bind(null,new Error("set"),!1,null))));-1===t?Mp(s,void 0):a.length=t+1,lf(i.eventQueue_,Vp(s),e);for(let n=0;n<o.length;n++)tc(o[n])}}let Lf=function(e,t){var r=Mf(e),n=r.namespace,i=("firebase.com"===r.domain&&Vh(r.host+" is no longer supported. Please use <YOUR FIREBASE>.firebaseio.com instead"),n&&"undefined"!==n||"localhost"===r.domain||Vh("Cannot parse Firebase url. Please use https://<YOUR FIREBASE>.firebaseio.com"),r.secure||qh(),"ws"===r.scheme||"wss"===r.scheme);return{repoInfo:new uc(r.host,r.secure,n,i,t,"",n!==r.subdomain),path:new kc(r.pathString)}},Mf=function(n){let i="",s="",a="",o="",l="",u=!0,h="https",c=443;if("string"==typeof n){let e=n.indexOf("//"),t=(0<=e&&(h=n.substring(0,e-1),n=n.substring(e+2)),n.indexOf("/")),r=(-1===t&&(t=n.length),n.indexOf("?"));-1===r&&(r=n.length),i=n.substring(0,Math.min(t,r)),t<r&&(o=(e=>{let t="";var r=e.split("/");for(let n=0;n<r.length;n++)if(0<r[n].length){let e=r[n];try{e=decodeURIComponent(e.replace(/\+/g," "))}catch(e){}t+="/"+e}return t})(n.substring(t,r)));var d=(e=>{var t,r,n={};for(t of(e="?"===e.charAt(0)?e.substring(1):e).split("&"))0!==t.length&&(2===(r=t.split("=")).length?n[decodeURIComponent(r[0])]=decodeURIComponent(r[1]):Bh(`Invalid query segment '${t}' in query '${e}'`));return n})(n.substring(Math.min(n.length,r))),p=(0<=(e=i.indexOf(":"))?(u="https"===h||"wss"===h,c=parseInt(i.substring(e+1),10)):e=i.length,i.slice(0,e));"localhost"===p.toLowerCase()?s="localhost":p.split(".").length<=2?s=p:(p=i.indexOf("."),a=i.substring(0,p).toLowerCase(),s=i.substring(p+1),l=a),"ns"in d&&(l=d.ns)}return{host:i,port:c,domain:s,subdomain:a,secure:u,scheme:h,pathString:o,namespace:l}},Ff="-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz",Uf=(()=>{let s=0,a=[];return function(e){var t=e===s;s=e;let r;var n=new Array(8);for(r=7;0<=r;r--)n[r]=Ff.charAt(e%64),e=Math.floor(e/64);g(0===e,"Cannot push at time == 0");let i=n.join("");if(t){for(r=11;0<=r&&63===a[r];r--)a[r]=0;a[r]++}else for(r=0;r<12;r++)a[r]=Math.floor(64*Math.random());for(r=0;r<12;r++)i+=Ff.charAt(a[r]);return g(20===i.length,"nextPushId: Length should be 20."),i}})();class Vf{constructor(e,t,r,n){this.eventType=e,this.eventRegistration=t,this.snapshot=r,this.prevName=n}getPath(){var e=this.snapshot.ref;return("value"===this.eventType?e:e.parent)._path}getEventType(){return this.eventType}getEventRunner(){return this.eventRegistration.getEventRunner(this)}toString(){return this.getPath().toString()+":"+this.eventType+":"+_e(this.snapshot.exportVal())}}class Bf{constructor(e,t,r){this.eventRegistration=e,this.error=t,this.path=r}getPath(){return this.path}getEventType(){return"cancel"}getEventRunner(){return this.eventRegistration.getEventRunner(this)}toString(){return this.path.toString()+":cancel"}}class qf{constructor(e,t){this.snapshotCallback=e,this.cancelCallback=t}onValue(e,t){this.snapshotCallback.call(null,e,t)}onCancel(e){return g(this.hasCancelCallback,"Raising a cancel event on a listener with no cancel callback"),this.cancelCallback.call(null,e)}get hasCancelCallback(){return!!this.cancelCallback}matches(e){return this.snapshotCallback===e.snapshotCallback||void 0!==this.snapshotCallback.userCallback&&this.snapshotCallback.userCallback===e.snapshotCallback.userCallback&&this.snapshotCallback.context===e.snapshotCallback.context}}class jf{constructor(e,t){this._repo=e,this._path=t}cancel(){var e=new Z;return bf(this._repo,this._path,e.wrapCallback(()=>{})),e.promise}remove(){rf("OnDisconnect.remove",this._path);var e=new Z;return Tf(this._repo,this._path,null,e.wrapCallback(()=>{})),e.promise}set(e){rf("OnDisconnect.set",this._path),$p("OnDisconnect.set",e,this._path,!1);var t=new Z;return Tf(this._repo,this._path,e,t.wrapCallback(()=>{})),t.promise}setWithPriority(e,t){rf("OnDisconnect.setWithPriority",this._path),$p("OnDisconnect.setWithPriority",e,this._path,!1),Xp("OnDisconnect.setWithPriority",t,!1);var n=new Z;{var i=this._repo,s=this._path,a=n.wrapCallback(()=>{});let r=yd(e,t);i.server_.onDisconnectPut(s.toString(),r.val(!0),(e,t)=>{"ok"===e&&Vd(i.onDisconnect_,s,r),Sf(0,a,e,t)})}return n.promise}update(e){rf("OnDisconnect.update",this._path),Jp("OnDisconnect.update",e,this._path,!1);var n,i,r,s,t=new Z;return n=this._repo,i=this._path,r=e,s=t.wrapCallback(()=>{}),Te(r)?(Uh("onDisconnect().update() called with empty data.  Don't do anything."),Sf(0,s,"ok",void 0)):n.server_.onDisconnectMerge(i.toString(),r,(e,t)=>{"ok"===e&&$h(r,(e,t)=>{var r=yd(t);Vd(n.onDisconnect_,Oc(i,e),r)}),Sf(0,s,e,t)}),t.promise}}class zf{constructor(e,t,r,n){this._repo=e,this._path=t,this._queryParams=r,this._orderByCalled=n}get key(){return _(this._path)?null:Pc(this._path)}get ref(){return new Wf(this._repo,this._path)}get _queryIdentifier(){var e=Ld(this._queryParams),e=Wh(e);return"{}"===e?"default":e}get _queryObject(){return Ld(this._queryParams)}isEqual(e){var t,r,n;return(e=w(e))instanceof zf&&(t=this._repo===e._repo,r=Fc(this._path,e._path),n=this._queryIdentifier===e._queryIdentifier,t)&&r&&n}toJSON(){return this.toString()}toString(){return this._repo.toString()+(e=>{let t="";for(let r=e.pieceNum_;r<e.pieces_.length;r++)""!==e.pieces_[r]&&(t+="/"+encodeURIComponent(String(e.pieces_[r])));return t||"/"})(this._path)}}function Hf(e,t){if(!0===e._orderByCalled)throw new Error(t+": You can't combine multiple orderBy calls.")}function Kf(e){let t=null,r=null;if(e.hasStart()&&(t=e.getIndexStartValue()),e.hasEnd()&&(r=e.getIndexEndValue()),e.getIndex()===Wc){var n="Query: When ordering by key, you may only pass one argument to startAt(), endAt(), or equalTo().",i="Query: When ordering by key, the argument passed to startAt(), startAfter(), endAt(), endBefore(), or equalTo() must be a string.";if(e.hasStart()){if(e.getIndexStartName()!==zh)throw new Error(n);if("string"!=typeof t)throw new Error(i)}if(e.hasEnd()){if(e.getIndexEndName()!==Hh)throw new Error(n);if("string"!=typeof r)throw new Error(i)}}else if(e.getIndex()===ld){if(null!=t&&!Wp(t)||null!=r&&!Wp(r))throw new Error("Query: When ordering by priority, the first argument passed to startAt(), startAfter() endAt(), endBefore(), or equalTo() must be a valid priority value (null, a number, or a string).")}else if(g(e.getIndex()instanceof wd||e.getIndex()===Td,"unknown index type."),null!=t&&"object"==typeof t||null!=r&&"object"==typeof r)throw new Error("Query: First argument passed to startAt(), startAfter(), endAt(), endBefore(), or equalTo() cannot be an object.")}function Gf(e){if(e.hasStart()&&e.hasEnd()&&e.hasLimit()&&!e.hasAnchoredLimit())throw new Error("Query: Can't combine startAt(), startAfter(), endAt(), endBefore(), and limit(). Use limitToFirst() or limitToLast() instead.")}class Wf extends zf{constructor(e,t){super(e,t,new Rd,!1)}get parent(){var e=Dc(this._path);return null===e?null:new Wf(this._repo,e)}get root(){let e=this;for(;null!==e.parent;)e=e.parent;return e}}class $f{constructor(e,t,r){this._node=e,this.ref=t,this._index=r}get priority(){return this._node.getPriority().val()}get key(){return this.ref.key}get size(){return this._node.numChildren()}child(e){var t=new kc(e),r=Jf(this.ref,e);return new $f(this._node.getChild(t),r,ld)}exists(){return!this._node.isEmpty()}exportVal(){return this._node.val(!0)}forEach(r){return!this._node.isLeafNode()&&!!this._node.forEachChild(this._index,(e,t)=>r(new $f(t,Jf(this.ref,e),ld)))}hasChild(e){var t=new kc(e);return!this._node.getChild(t).isEmpty()}hasChildren(){return!this._node.isLeafNode()&&!this._node.isEmpty()}toJSON(){return this.exportVal()}val(){return this._node.val()}}function Yf(e,t){return(e=w(e))._checkNotDeleted("ref"),void 0!==t?Jf(e._root,t):e._root}function Qf(e,t){(e=w(e))._checkNotDeleted("refFromURL");var r=Lf(t,e._repo.repoInfo_.nodeAdmin),n=(nf("refFromURL",r),r.repoInfo);return e._repo.repoInfo_.isCustomHost()||n.host===e._repo.repoInfo_.host||Vh("refFromURL: Host name does not match the current database: (found "+n.host+" but expected "+e._repo.repoInfo_.host+")"),Yf(e,r.path.toString())}function Jf(e,t){return(null===v((e=w(e))._path)?tf:ef)("child","path",t,!1),new Wf(e._repo,Oc(e._path,t))}function Xf(e,t){e=w(e),rf("set",e._path),$p("set",t,e._path,!1);var r=new Z;return wf(e._repo,e._path,t,null,r.wrapCallback(()=>{})),r.promise}function Zf(e,t){Jp("update",t,e._path,!1);var i=new Z;{var a=e._repo,o=e._path,l=(e=t,i.wrapCallback(()=>{}));Cf(a,"update",{path:o.toString(),value:e});let r=!0,n=gf(a),s={};if($h(e,(e,t)=>{r=!1,s[e]=Rp(Oc(o,e),yd(t),a.serverSyncTree_,n)}),r)Uh("update() called with empty data.  Don't do anything."),Sf(0,l,"ok",void 0);else{let i=yf(a);var u=op(a.serverSyncTree_,o,s,i);af(a.eventQueue_,u),a.server_.merge(o.toString(),e,(e,t)=>{var r="ok"===e,r=(r||Bh("update at "+o+" failed: "+e),lp(a.serverSyncTree_,i,!r)),n=0<r.length?Nf(a,o):o;lf(a.eventQueue_,n,r),Sf(0,l,e,t)}),$h(e,e=>{var t=Df(a,Oc(o,e));Nf(a,t)}),lf(a.eventQueue_,o,[])}}return i.promise}function eg(t){t=w(t);var i,s,a,e=new qf(()=>{}),e=new tg(e);return i=t._repo,s=t,a=e,(null!=(e=fp(i.serverSyncTree_,s))?Promise.resolve(e):i.server_.get(s).then(e=>{var t,r=yd(e).withIndex(s._queryParams.getIndex());dp(i.serverSyncTree_,s,a,!0);let n;return n=s._queryParams.loadsAllData()?up(i.serverSyncTree_,s._path,r):(t=_p(i.serverSyncTree_,s),cp(i.serverSyncTree_,s._path,r,t)),lf(i.eventQueue_,s._path,n),hp(i.serverSyncTree_,s,a,null,!0),r},e=>(Cf(i,"get for query "+_e(s)+" failed: "+e),Promise.reject(new Error(e))))).then(e=>new $f(e,new Wf(t._repo,t._path),t._queryParams.getIndex()))}class tg{constructor(e){this.callbackContext=e}respondsTo(e){return"value"===e}createEvent(e,t){var r=t._queryParams.getIndex();return new Vf("value",this,new $f(e.snapshotNode,new Wf(t._repo,t._path),r))}getEventRunner(e){return"cancel"===e.getEventType()?()=>this.callbackContext.onCancel(e.error):()=>this.callbackContext.onValue(e.snapshot,null)}createCancelEvent(e,t){return this.callbackContext.hasCancelCallback?new Bf(this,e,t):null}matches(e){return e instanceof tg&&(!e.callbackContext||!this.callbackContext||e.callbackContext.matches(this.callbackContext))}hasAnyCallback(){return null!==this.callbackContext}}class rg{constructor(e,t){this.eventType=e,this.callbackContext=t}respondsTo(e){var t="children_added"===e?"child_added":e;return this.eventType===("children_removed"===t?"child_removed":t)}createCancelEvent(e,t){return this.callbackContext.hasCancelCallback?new Bf(this,e,t):null}createEvent(e,t){g(null!=e.childName,"Child events should have a childName.");var r=Jf(new Wf(t._repo,t._path),e.childName),n=t._queryParams.getIndex();return new Vf(e.type,this,new $f(e.snapshotNode,r,n),e.prevName)}getEventRunner(e){return"cancel"===e.getEventType()?()=>this.callbackContext.onCancel(e.error):()=>this.callbackContext.onValue(e.snapshot,e.prevName)}matches(e){return e instanceof rg&&this.eventType===e.eventType&&(!this.callbackContext||!e.callbackContext||this.callbackContext.matches(e.callbackContext))}hasAnyCallback(){return!!this.callbackContext}}function ng(n,e,t,r,i){let s;if("object"==typeof r&&(s=void 0,i=r),"function"==typeof r&&(s=r),i&&i.onlyOnce){let r=t;var a=(e,t)=>{Ef(n._repo,n,o),r(e,t)};a.userCallback=t.userCallback,a.context=t.context,t=a}a=new qf(t,s||void 0);let o="value"===e?new tg(a):new rg(e,a);{r=n._repo,i=n,t=o;let e;e=".info"===v(i._path)?dp(r.infoSyncTree_,i,t):dp(r.serverSyncTree_,i,t),of(r.eventQueue_,i._path,e)}return()=>Ef(n._repo,n,o)}function ig(e,t,r,n){return ng(e,"value",t,r,n)}function sg(e,t,r,n){ng(e,"child_added",t,r,n)}function ag(e,t,r,n){ng(e,"child_changed",t,r,n)}function og(e,t,r,n){ng(e,"child_moved",t,r,n)}function lg(e,t,r,n){ng(e,"child_removed",t,r,n)}function ug(e,t,r){let n=null;var i=r?new qf(r):null;"value"===t?n=new tg(i):t&&(n=new rg(t,i)),Ef(e._repo,e,n)}class hg{}class cg extends hg{constructor(e,t){super(),this._value=e,this._key=t,this.type="endAt"}_apply(e){$p("endAt",this._value,e._path,!0);var t=xd(e._queryParams,this._value,this._key);if(Gf(t),Kf(t),e._queryParams.hasEnd())throw new Error("endAt: Starting point was already set (by another call to endAt, endBefore or equalTo).");return new zf(e._repo,e._path,t,e._orderByCalled)}}class dg extends hg{constructor(e,t){super(),this._value=e,this._key=t,this.type="endBefore"}_apply(e){$p("endBefore",this._value,e._path,!1);var t=((e,t,r)=>{let n;return(n=e.index_===Wc||r?xd(e,t,r):xd(e,t,zh)).endBeforeSet_=!0,n})(e._queryParams,this._value,this._key);if(Gf(t),Kf(t),e._queryParams.hasEnd())throw new Error("endBefore: Starting point was already set (by another call to endAt, endBefore or equalTo).");return new zf(e._repo,e._path,t,e._orderByCalled)}}class pg extends hg{constructor(e,t){super(),this._value=e,this._key=t,this.type="startAt"}_apply(e){$p("startAt",this._value,e._path,!0);var t=Pd(e._queryParams,this._value,this._key);if(Gf(t),Kf(t),e._queryParams.hasStart())throw new Error("startAt: Starting point was already set (by another call to startAt, startBefore or equalTo).");return new zf(e._repo,e._path,t,e._orderByCalled)}}class fg extends hg{constructor(e,t){super(),this._value=e,this._key=t,this.type="startAfter"}_apply(e){$p("startAfter",this._value,e._path,!1);var t=((e,t,r)=>{let n;return(n=e.index_===Wc||r?Pd(e,t,r):Pd(e,t,Hh)).startAfterSet_=!0,n})(e._queryParams,this._value,this._key);if(Gf(t),Kf(t),e._queryParams.hasStart())throw new Error("startAfter: Starting point was already set (by another call to startAt, startAfter, or equalTo).");return new zf(e._repo,e._path,t,e._orderByCalled)}}class gg extends hg{constructor(e){super(),this._limit=e,this.type="limitToFirst"}_apply(e){if(e._queryParams.hasLimit())throw new Error("limitToFirst: Limit was already set (by another call to limitToFirst or limitToLast).");return new zf(e._repo,e._path,(t=e._queryParams,r=this._limit,(n=t.copy()).limitSet_=!0,n.limit_=r,n.viewFrom_="l",n),e._orderByCalled);var t,r,n}}class mg extends hg{constructor(e){super(),this._limit=e,this.type="limitToLast"}_apply(e){if(e._queryParams.hasLimit())throw new Error("limitToLast: Limit was already set (by another call to limitToFirst or limitToLast).");return new zf(e._repo,e._path,(t=e._queryParams,r=this._limit,(n=t.copy()).limitSet_=!0,n.limit_=r,n.viewFrom_="r",n),e._orderByCalled);var t,r,n}}class vg extends hg{constructor(e){super(),this._path=e,this.type="orderByChild"}_apply(e){Hf(e,"orderByChild");var t=new kc(this._path);if(_(t))throw new Error("orderByChild: cannot pass in empty path. Use orderByValue() instead.");t=new wd(t),t=Dd(e._queryParams,t);return Kf(t),new zf(e._repo,e._path,t,!0)}}class _g extends hg{constructor(){super(...arguments),this.type="orderByKey"}_apply(e){Hf(e,"orderByKey");var t=Dd(e._queryParams,Wc);return Kf(t),new zf(e._repo,e._path,t,!0)}}class yg extends hg{constructor(){super(...arguments),this.type="orderByPriority"}_apply(e){Hf(e,"orderByPriority");var t=Dd(e._queryParams,ld);return Kf(t),new zf(e._repo,e._path,t,!0)}}class wg extends hg{constructor(){super(...arguments),this.type="orderByValue"}_apply(e){Hf(e,"orderByValue");var t=Dd(e._queryParams,Td);return Kf(t),new zf(e._repo,e._path,t,!0)}}class bg extends hg{constructor(e,t){super(),this._value=e,this._key=t,this.type="equalTo"}_apply(e){if($p("equalTo",this._value,e._path,!1),e._queryParams.hasStart())throw new Error("equalTo: Starting point was already set (by another call to startAt/startAfter or equalTo).");if(e._queryParams.hasEnd())throw new Error("equalTo: Ending point was already set (by another call to endAt/endBefore or equalTo).");return new cg(this._value,this._key)._apply(new pg(this._value,this._key)._apply(e))}}function Tg(e,...t){let r=w(e);for(var n of t)r=n._apply(r);return r}t=Wf,g(!K1,"__referenceConstructor has already been defined"),K1=t,t=Wf,g(!np,"__referenceConstructor has already been defined"),np=t;let Eg="FIREBASE_DATABASE_EMULATOR_HOST",Ig={},Cg=!1;function Sg(e,t,r,n,i){let s=n||e.options.databaseURL,a=(void 0===s&&(e.options.projectId||Vh("Can't determine Firebase Database URL. Be sure to include  a Project ID when calling firebase.initializeApp()."),Uh("Using default host for project ",e.options.projectId),s=e.options.projectId+"-default-rtdb.firebaseio.com"),Lf(s,i)),o=a.repoInfo,l,u=void 0;(u="undefined"!=typeof process&&process.env?process.env[Eg]:u)?(l=!0,s=`http://${u}?ns=`+o.namespace,a=Lf(s,i),o=a.repoInfo):l=!a.repoInfo.secure;var h=i&&l?new sc(sc.OWNER):new ic(e.name,e.options,t),h=(nf("Invalid Firebase Database URL",a),_(a.path)||Vh("Database URL must point to the root of a Firebase Database (not including a child path)."),((e,t,r,n)=>{let i=Ig[t.name];var s;return i||(i={},Ig[t.name]=i),(s=i[e.toURLString()])&&Vh("Database initialized multiple times. Please make sure the format of the database URL matches with each database() call."),s=new df(e,Cg,r,n),i[e.toURLString()]=s})(o,e,h,new nc(e,r)));return new kg(h,e)}class kg{constructor(e,t){this._repoInternal=e,this.app=t,this.type="database",this._instanceStarted=!1}get _repo(){return this._instanceStarted||(pf(this._repoInternal,this.app.options.appId,this.app.options.databaseAuthVariableOverride),this._instanceStarted=!0),this._repoInternal}get _root(){return this._rootInternal||(this._rootInternal=new Wf(this._repo,Ac())),this._rootInternal}_delete(){var e,t,r;return null!==this._rootInternal&&(e=this._repo,t=this.app.name,(r=Ig[t])&&r[e.key]===e||Vh(`Database ${t}(${e.repoInfo_}) has already been deleted.`),If(e),delete r[e.key],this._repoInternal=null,this._rootInternal=null),Promise.resolve()}_checkNotDeleted(e){null===this._rootInternal&&Vh("Cannot call "+e+" on a deleted database.")}}function Ag(){wc.IS_TRANSPORT_INITIALIZED&&Bh("Transport has already been initialized. Please call this function before calling ref or setting up a listener")}function Ng(){Ag(),mc.forceDisallow()}function Rg(){Ag(),yc.forceDisallow(),mc.forceAllow()}function Pg(e,t,r,n={}){(e=w(e))._checkNotDeleted("useEmulator");var i,s=t+":"+r,a=e._repoInternal;if(e._instanceStarted){if(s===e._repoInternal.repoInfo_.host&&Ie(n,a.repoInfo_.emulatorOptions))return;Vh("connectDatabaseEmulator() cannot initialize or alter the emulator configuration after the database instance has started.")}let o=void 0;a.repoInfo_.nodeAdmin?(n.mockUserToken&&Vh('mockUserToken is not supported by the Admin SDK. For client access with mock users, please use the "firebase" package instead of "firebase-admin".'),o=new sc(sc.OWNER)):n.mockUserToken&&(i="string"==typeof n.mockUserToken?n.mockUserToken:ee(n.mockUserToken,e.app.options.projectId),o=new sc(i)),ze(t)&&He(t),r=a,e=s,t=n,n=o,i=e.lastIndexOf(":"),i=ze(e.substring(0,i)),r.repoInfo_=new uc(e,i,r.repoInfo_.namespace,r.repoInfo_.webSocketOnly,r.repoInfo_.nodeAdmin,r.repoInfo_.persistenceKey,r.repoInfo_.includeNamespaceInQueryParams,!0,t),n&&(r.authTokenProvider_=n)}function xg(e){(e=w(e))._checkNotDeleted("goOnline"),(e=e._repo).persistentConnection_&&e.persistentConnection_.resume(hf)}function Dg(e,t){Fh(e,t)}let Og={".sv":"timestamp"};class Lg{constructor(e,t){this.committed=e,this.snapshot=t}toJSON(){return{committed:this.committed,snapshot:this.snapshot.toJSON()}}}function Mg(i,e,t){if(i=w(i),rf("Reference.transaction",i._path),".length"===i.key||".keys"===i.key)throw"Reference.transaction failed: "+i.key+" is a read-only object.";var r=t?.applyLocally??!0;let s=new Z;var n=ig(i,()=>{}),t=i._repo,a=i._path,o=(e,t,r)=>{var n;e?s.reject(e):(n=new $f(r,new Wf(i._repo,i._path),ld),s.resolve(new Lg(t,n)))},l=n,u=r;Cf(t,"transaction on "+a);var h,n={path:a,update:e,onComplete:o,status:null,order:Dh(),applyLocally:u,retryCount:0,unwatcher:l,abortReason:null,currentWriteId:null,currentInputSnapshot:null,currentOutputSnapshotRaw:null,currentOutputSnapshotResolved:null},r=kf(t,a,void 0);if(n.currentInputSnapshot=r,void 0===(h=n.update(r.val())))n.unwatcher(),n.currentOutputSnapshotRaw=null,n.currentOutputSnapshotResolved=null,n.onComplete&&n.onComplete(null,!1,n.currentInputSnapshot);else{Yp("transaction failed: Data returned ",h,n.path),n.status=0;var c=Op(t.transactionQueueTree_,a),d=Lp(c)||[];d.push(n),Mp(c,d);let e;"object"==typeof h&&null!==h&&we(h,".priority")?(e=be(h,".priority"),g(Wp(e),"Invalid priority returned by transaction. Priority must be a valid string, finite number, server value, or null.")):(c=pp(t.serverSyncTree_,a)||y.EMPTY_NODE,e=c.getPriority().val());d=gf(t),c=yd(h,e),h=Pp(c,r,d),r=(n.currentOutputSnapshotRaw=c,n.currentOutputSnapshotResolved=h,n.currentWriteId=yf(t),ap(t.serverSyncTree_,a,h,n.currentWriteId,n.applyLocally));lf(t.eventQueue_,a,r),Af(t,t.transactionQueueTree_)}return s.promise}zc.prototype.simpleListen=function(e,t){this.sendRequest("q",{p:e},t)},zc.prototype.echo=function(e,t){this.sendRequest("echo",{d:e},t)},wh(Vt),Rt(new h("database",(e,{instanceIdentifier:t})=>Sg(e.getProvider("app").getImmediate(),e.getProvider("auth-internal"),e.getProvider("app-check-internal"),t),"PUBLIC").setMultipleInstances(!0)),zt(vh,_h,GN),zt(vh,_h,"esm2020");function Fg(e){var t="FIREBASE WARNING: "+e;Bg.warn(t)}let Ug="@firebase/database-compat",Vg="2.1.4",Bg=new Ze("@firebase/database-compat");class qg{constructor(e){this._delegate=e}cancel(t){l("OnDisconnect.cancel",0,1,arguments.length),Oe("OnDisconnect.cancel","onComplete",t,!0);var e=this._delegate.cancel();return t&&e.then(()=>t(null),e=>t(e)),e}remove(t){l("OnDisconnect.remove",0,1,arguments.length),Oe("OnDisconnect.remove","onComplete",t,!0);var e=this._delegate.remove();return t&&e.then(()=>t(null),e=>t(e)),e}set(e,t){l("OnDisconnect.set",1,2,arguments.length),Oe("OnDisconnect.set","onComplete",t,!0);var r=this._delegate.set(e);return t&&r.then(()=>t(null),e=>t(e)),r}setWithPriority(e,t,r){l("OnDisconnect.setWithPriority",2,3,arguments.length),Oe("OnDisconnect.setWithPriority","onComplete",r,!0);var n=this._delegate.setWithPriority(e,t);return r&&n.then(()=>r(null),e=>r(e)),n}update(t,r){if(l("OnDisconnect.update",1,2,arguments.length),Array.isArray(t)){var n={};for(let e=0;e<t.length;++e)n[""+e]=t[e];t=n,Fg("Passing an Array to firebase.database.onDisconnect().update() is deprecated. Use set() if you want to overwrite the existing data, or an Object with integer keys if you really do want to only update some of the children.")}Oe("OnDisconnect.update","onComplete",r,!0);var e=this._delegate.update(t);return r&&e.then(()=>r(null),e=>r(e)),e}}class jg{constructor(e,t){this.committed=e,this.snapshot=t}toJSON(){return l("TransactionResult.toJSON",0,1,arguments.length),{committed:this.committed,snapshot:this.snapshot.toJSON()}}}class zg{constructor(e,t){this._database=e,this._delegate=t}val(){return l("DataSnapshot.val",0,0,arguments.length),this._delegate.val()}exportVal(){return l("DataSnapshot.exportVal",0,0,arguments.length),this._delegate.exportVal()}toJSON(){return l("DataSnapshot.toJSON",0,1,arguments.length),this._delegate.toJSON()}exists(){return l("DataSnapshot.exists",0,0,arguments.length),this._delegate.exists()}child(e){return l("DataSnapshot.child",0,1,arguments.length),e=String(e),ef("DataSnapshot.child","path",e,!1),new zg(this._database,this._delegate.child(e))}hasChild(e){return l("DataSnapshot.hasChild",1,1,arguments.length),ef("DataSnapshot.hasChild","path",e,!1),this._delegate.hasChild(e)}getPriority(){return l("DataSnapshot.getPriority",0,0,arguments.length),this._delegate.priority}forEach(t){return l("DataSnapshot.forEach",1,1,arguments.length),Oe("DataSnapshot.forEach","action",t,!1),this._delegate.forEach(e=>t(new zg(this._database,e)))}hasChildren(){return l("DataSnapshot.hasChildren",0,0,arguments.length),this._delegate.hasChildren()}get key(){return this._delegate.key}numChildren(){return l("DataSnapshot.numChildren",0,0,arguments.length),this._delegate.size}getRef(){return l("DataSnapshot.ref",0,0,arguments.length),new Kg(this._database,this._delegate.ref)}get ref(){return this.getRef()}}class Hg{constructor(e,t){this.database=e,this._delegate=t}on(e,r,t,n){l("Query.on",2,4,arguments.length),Oe("Query.on","callback",r,!1);let i=Hg.getCancelAndContextArgs_("Query.on",t,n);var s=(e,t)=>{r.call(i.context,new zg(this.database,e),t)},a=(s.userCallback=r,s.context=i.context,i.cancel?.bind(i.context));switch(e){case"value":return ig(this._delegate,s,a),r;case"child_added":return sg(this._delegate,s,a),r;case"child_removed":return lg(this._delegate,s,a),r;case"child_changed":return ag(this._delegate,s,a),r;case"child_moved":return og(this._delegate,s,a),r;default:throw new Error(De("Query.on","eventType")+'must be a valid event type = "value", "child_added", "child_removed", "child_changed", or "child_moved".')}}off(e,t,r){l("Query.off",0,3,arguments.length);var n,i="Query.off",s=e,a=!0;if(!a||void 0!==s)switch(s){case"value":case"child_added":case"child_removed":case"child_changed":case"child_moved":break;default:throw new Error(De(i,"eventType")+'must be a valid event type = "value", "child_added", "child_removed", "child_changed", or "child_moved".')}Oe("Query.off","callback",t,!0),Le("Query.off","context",r,!0),t?((n=()=>{}).userCallback=t,n.context=r,ug(this._delegate,e,n)):ug(this._delegate,e)}get(){return eg(this._delegate).then(e=>new zg(this.database,e))}once(e,n,t,r){l("Query.once",1,4,arguments.length),Oe("Query.once","callback",n,!0);let i=Hg.getCancelAndContextArgs_("Query.once",t,r),s=new Z;var a=(e,t)=>{var r=new zg(this.database,e);n&&n.call(i.context,r,t),s.resolve(r)},o=(a.userCallback=n,a.context=i.context,e=>{i.cancel&&i.cancel.call(i.context,e),s.reject(e)});switch(e){case"value":ig(this._delegate,a,o,{onlyOnce:!0});break;case"child_added":sg(this._delegate,a,o,{onlyOnce:!0});break;case"child_removed":lg(this._delegate,a,o,{onlyOnce:!0});break;case"child_changed":ag(this._delegate,a,o,{onlyOnce:!0});break;case"child_moved":og(this._delegate,a,o,{onlyOnce:!0});break;default:throw new Error(De("Query.once","eventType")+'must be a valid event type = "value", "child_added", "child_removed", "child_changed", or "child_moved".')}return s.promise}limitToFirst(e){return l("Query.limitToFirst",1,1,arguments.length),new Hg(this.database,Tg(this._delegate,(e=>{if("number"!=typeof e||Math.floor(e)!==e||e<=0)throw new Error("limitToFirst: First argument must be a positive integer.");return new gg(e)})(e)))}limitToLast(e){return l("Query.limitToLast",1,1,arguments.length),new Hg(this.database,Tg(this._delegate,(e=>{if("number"!=typeof e||Math.floor(e)!==e||e<=0)throw new Error("limitToLast: First argument must be a positive integer.");return new mg(e)})(e)))}orderByChild(e){return l("Query.orderByChild",1,1,arguments.length),new Hg(this.database,Tg(this._delegate,(e=>{if("$key"===e)throw new Error('orderByChild: "$key" is invalid.  Use orderByKey() instead.');if("$priority"===e)throw new Error('orderByChild: "$priority" is invalid.  Use orderByPriority() instead.');if("$value"===e)throw new Error('orderByChild: "$value" is invalid.  Use orderByValue() instead.');return ef("orderByChild","path",e,!1),new vg(e)})(e)))}orderByKey(){return l("Query.orderByKey",0,0,arguments.length),new Hg(this.database,Tg(this._delegate,new _g))}orderByPriority(){return l("Query.orderByPriority",0,0,arguments.length),new Hg(this.database,Tg(this._delegate,new yg))}orderByValue(){return l("Query.orderByValue",0,0,arguments.length),new Hg(this.database,Tg(this._delegate,new wg))}startAt(e=null,t){return l("Query.startAt",0,2,arguments.length),new Hg(this.database,Tg(this._delegate,([e=null,t]=[e,t],Zp("startAt","key",t,!0),new pg(e,t))))}startAfter(e=null,t){return l("Query.startAfter",0,2,arguments.length),new Hg(this.database,Tg(this._delegate,(e=e,t=t,Zp("startAfter","key",t,!0),new fg(e,t))))}endAt(e=null,t){return l("Query.endAt",0,2,arguments.length),new Hg(this.database,Tg(this._delegate,(e=e,t=t,Zp("endAt","key",t,!0),new cg(e,t))))}endBefore(e=null,t){return l("Query.endBefore",0,2,arguments.length),new Hg(this.database,Tg(this._delegate,(e=e,t=t,Zp("endBefore","key",t,!0),new dg(e,t))))}equalTo(e,t){return l("Query.equalTo",1,2,arguments.length),new Hg(this.database,Tg(this._delegate,(e=e,t=t,Zp("equalTo","key",t,!0),new bg(e,t))))}toString(){return l("Query.toString",0,0,arguments.length),this._delegate.toString()}toJSON(){return l("Query.toJSON",0,1,arguments.length),this._delegate.toJSON()}isEqual(e){if(l("Query.isEqual",1,1,arguments.length),e instanceof Hg)return this._delegate.isEqual(e._delegate);throw new Error("Query.isEqual failed: First argument must be an instance of firebase.database.Query.")}static getCancelAndContextArgs_(e,t,r){var n={cancel:void 0,context:void 0};if(t&&r)n.cancel=t,Oe(e,"cancel",n.cancel,!0),n.context=r,Le(e,"context",n.context,!0);else if(t)if("object"==typeof t&&null!==t)n.context=t;else{if("function"!=typeof t)throw new Error(De(e,"cancelOrContext")+" must either be a cancel callback or a context object.");n.cancel=t}return n}get ref(){return new Kg(this.database,new Wf(this._delegate._repo,this._delegate._path))}}class Kg extends Hg{constructor(e,t){super(e,new zf(t._repo,t._path,new Rd,!1)),this.database=e,this._delegate=t}getKey(){return l("Reference.key",0,0,arguments.length),this._delegate.key}child(e){return l("Reference.child",1,1,arguments.length),"number"==typeof e&&(e=String(e)),new Kg(this.database,Jf(this._delegate,e))}getParent(){l("Reference.parent",0,0,arguments.length);var e=this._delegate.parent;return e?new Kg(this.database,e):null}getRoot(){return l("Reference.root",0,0,arguments.length),new Kg(this.database,this._delegate.root)}set(e,t){l("Reference.set",1,2,arguments.length),Oe("Reference.set","onComplete",t,!0);var r=Xf(this._delegate,e);return t&&r.then(()=>t(null),e=>t(e)),r}update(t,r){if(l("Reference.update",1,2,arguments.length),Array.isArray(t)){var n={};for(let e=0;e<t.length;++e)n[""+e]=t[e];t=n,Fg("Passing an Array to Firebase.update() is deprecated. Use set() if you want to overwrite the existing data, or an Object with integer keys if you really do want to only update some of the children.")}rf("Reference.update",this._delegate._path),Oe("Reference.update","onComplete",r,!0);var e=Zf(this._delegate,t);return r&&e.then(()=>r(null),e=>r(e)),e}setWithPriority(e,t,r){l("Reference.setWithPriority",2,3,arguments.length),Oe("Reference.setWithPriority","onComplete",r,!0);var n=((e,t,r)=>{if(rf("setWithPriority",e._path),$p("setWithPriority",t,e._path,!1),Xp("setWithPriority",r,!1),".length"===e.key||".keys"===e.key)throw"setWithPriority failed: "+e.key+" is a read-only object.";var n=new Z;return wf(e._repo,e._path,t,r,n.wrapCallback(()=>{})),n.promise})(this._delegate,e,t);return r&&n.then(()=>r(null),e=>r(e)),n}remove(t){l("Reference.remove",0,1,arguments.length),Oe("Reference.remove","onComplete",t,!0);e=this._delegate,rf("remove",e._path);var e,r=Xf(e,null);return t&&r.then(()=>t(null),e=>t(e)),r}transaction(e,t,r){l("Reference.transaction",1,3,arguments.length),Oe("Reference.transaction","transactionUpdate",e,!1),Oe("Reference.transaction","onComplete",t,!0);var n,i="Reference.transaction",s="applyLocally",a=r,o=!0;if(o&&void 0===a||"boolean"==typeof a)return n=Mg(this._delegate,e,{applyLocally:r}).then(e=>new jg(e.committed,new zg(this.database,e.snapshot))),t&&n.then(e=>t(null,e.committed,e.snapshot),e=>t(e,!1,null)),n;throw new Error(De(i,s)+"must be a boolean.")}setPriority(e,t){l("Reference.setPriority",1,2,arguments.length),Oe("Reference.setPriority","onComplete",t,!0);r=this._delegate,e=e,r=w(r),rf("setPriority",r._path),Xp("setPriority",e,!1),n=new Z,wf(r._repo,Oc(r._path,".priority"),e,null,n.wrapCallback(()=>{}));var r,n=n.promise;return t&&n.then(()=>t(null),e=>t(e)),n}push(e,t){l("Reference.push",0,2,arguments.length),Oe("Reference.push","onComplete",t,!0);var r=((e,t)=>{e=w(e),rf("push",e._path),$p("push",t,e._path,!0);var r=ff(e._repo),r=Uf(r),n=Jf(e,r);let i=Jf(e,r),s;return s=null!=t?Xf(i,t).then(()=>i):Promise.resolve(i),n.then=s.then.bind(s),n.catch=s.then.bind(s,void 0),n})(this._delegate,e),n=r.then(e=>new Kg(this.database,e)),r=(t&&n.then(()=>t(null),e=>t(e)),new Kg(this.database,r));return r.then=n.then.bind(n),r.catch=n.catch.bind(n,void 0),r}onDisconnect(){return rf("Reference.onDisconnect",this._delegate._path),new qg(new jf(this._delegate._repo,this._delegate._path))}get key(){return this.getKey()}get parent(){return this.getParent()}get root(){return this.getRoot()}}class Gg{constructor(e,t){this._delegate=e,this.app=t,this.INTERNAL={delete:()=>this._delegate._delete(),forceWebSockets:Ng,forceLongPolling:Rg}}useEmulator(e,t,r={}){Pg(this._delegate,e,t,r)}ref(e){var t;return l("database.ref",0,1,arguments.length),e instanceof Kg?(t=Qf(this._delegate,e.toString()),new Kg(this,t)):(t=Yf(this._delegate,e),new Kg(this,t))}refFromURL(e){l("database.refFromURL",1,1,arguments.length);var t=Qf(this._delegate,e);return new Kg(this,t)}goOffline(){var e;l("database.goOffline",0,0,arguments.length),(e=w(e=this._delegate))._checkNotDeleted("goOffline"),If(e._repo)}goOnline(){return l("database.goOnline",0,0,arguments.length),xg(this._delegate)}}Gg.ServerValue={TIMESTAMP:Og,increment:e=>({".sv":{increment:e}})};ur=Object.freeze({__proto__:null,initStandalone:function({app:e,url:t,version:r,customAuthImpl:n,customAppCheckImpl:i,namespace:s,nodeAdmin:a=!1}){wh(r);var o=new We("database-standalone"),l=new Ge("auth-internal",o);l.setComponent(new h("auth-internal",()=>n,"PRIVATE"));let u=void 0;return i&&(u=new Ge("app-check-internal",o)).setComponent(new h("app-check-internal",()=>i,"PRIVATE")),{instance:new Gg(Sg(e,l,u,t,a),e),namespace:s}}});let Wg=Gg.ServerValue;(t=pr).INTERNAL.registerComponent(new h("database-compat",(e,{instanceIdentifier:t})=>{var r=e.getProvider("app-compat").getImmediate(),n=e.getProvider("database").getImmediate({identifier:t});return new Gg(n,r)},"PUBLIC").setServiceProps({Reference:Kg,Query:Hg,Database:Gg,DataSnapshot:zg,enableLogging:Dg,INTERNAL:ur,ServerValue:Wg}).setMultipleInstances(!0)),t.registerVersion(Ug,Vg);var $g,Yg,Qg,Jg,Xg,Zg,em,tm,rm,nm,lr="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},im=(!(function(){var e,t,s;function r(){this.blockSize=-1,this.blockSize=64,this.g=Array(4),this.C=Array(this.blockSize),this.o=this.h=0,this.u()}function n(){}function a(e,t,r){r=r||0;var n=Array(16);if("string"==typeof t)for(var i=0;i<16;++i)n[i]=t.charCodeAt(r++)|t.charCodeAt(r++)<<8|t.charCodeAt(r++)<<16|t.charCodeAt(r++)<<24;else for(i=0;i<16;++i)n[i]=t[r++]|t[r++]<<8|t[r++]<<16|t[r++]<<24;t=e.g[0],r=e.g[1];var i=e.g[2],s=e.g[3],a=t+(s^r&(i^s))+n[0]+3614090360&4294967295;a=(r=(i=(s=(t=(r=(i=(s=(t=(r=(i=(s=(t=(r=(i=(s=(t=(r=(i=(s=(t=(r=(i=(s=(t=(r=(i=(s=(t=(r=(i=(s=(t=(r=(i=(s=(t=(r=(i=(s=(t=(r=(i=(s=(t=(r=(i=(s=(t=(r=(i=(s=(t=(r=(i=(s=(t=(r=(i=(s=(t=r+(a<<7&4294967295|a>>>25))+((a=s+(i^t&(r^i))+n[1]+3905402710&4294967295)<<12&4294967295|a>>>20))+((a=i+(r^s&(t^r))+n[2]+606105819&4294967295)<<17&4294967295|a>>>15))+((a=r+(t^i&(s^t))+n[3]+3250441966&4294967295)<<22&4294967295|a>>>10))+((a=t+(s^r&(i^s))+n[4]+4118548399&4294967295)<<7&4294967295|a>>>25))+((a=s+(i^t&(r^i))+n[5]+1200080426&4294967295)<<12&4294967295|a>>>20))+((a=i+(r^s&(t^r))+n[6]+2821735955&4294967295)<<17&4294967295|a>>>15))+((a=r+(t^i&(s^t))+n[7]+4249261313&4294967295)<<22&4294967295|a>>>10))+((a=t+(s^r&(i^s))+n[8]+1770035416&4294967295)<<7&4294967295|a>>>25))+((a=s+(i^t&(r^i))+n[9]+2336552879&4294967295)<<12&4294967295|a>>>20))+((a=i+(r^s&(t^r))+n[10]+4294925233&4294967295)<<17&4294967295|a>>>15))+((a=r+(t^i&(s^t))+n[11]+2304563134&4294967295)<<22&4294967295|a>>>10))+((a=t+(s^r&(i^s))+n[12]+1804603682&4294967295)<<7&4294967295|a>>>25))+((a=s+(i^t&(r^i))+n[13]+4254626195&4294967295)<<12&4294967295|a>>>20))+((a=i+(r^s&(t^r))+n[14]+2792965006&4294967295)<<17&4294967295|a>>>15))+((a=r+(t^i&(s^t))+n[15]+1236535329&4294967295)<<22&4294967295|a>>>10))+((a=t+(i^s&(r^i))+n[1]+4129170786&4294967295)<<5&4294967295|a>>>27))+((a=s+(r^i&(t^r))+n[6]+3225465664&4294967295)<<9&4294967295|a>>>23))+((a=i+(t^r&(s^t))+n[11]+643717713&4294967295)<<14&4294967295|a>>>18))+((a=r+(s^t&(i^s))+n[0]+3921069994&4294967295)<<20&4294967295|a>>>12))+((a=t+(i^s&(r^i))+n[5]+3593408605&4294967295)<<5&4294967295|a>>>27))+((a=s+(r^i&(t^r))+n[10]+38016083&4294967295)<<9&4294967295|a>>>23))+((a=i+(t^r&(s^t))+n[15]+3634488961&4294967295)<<14&4294967295|a>>>18))+((a=r+(s^t&(i^s))+n[4]+3889429448&4294967295)<<20&4294967295|a>>>12))+((a=t+(i^s&(r^i))+n[9]+568446438&4294967295)<<5&4294967295|a>>>27))+((a=s+(r^i&(t^r))+n[14]+3275163606&4294967295)<<9&4294967295|a>>>23))+((a=i+(t^r&(s^t))+n[3]+4107603335&4294967295)<<14&4294967295|a>>>18))+((a=r+(s^t&(i^s))+n[8]+1163531501&4294967295)<<20&4294967295|a>>>12))+((a=t+(i^s&(r^i))+n[13]+2850285829&4294967295)<<5&4294967295|a>>>27))+((a=s+(r^i&(t^r))+n[2]+4243563512&4294967295)<<9&4294967295|a>>>23))+((a=i+(t^r&(s^t))+n[7]+1735328473&4294967295)<<14&4294967295|a>>>18))+((a=r+(s^t&(i^s))+n[12]+2368359562&4294967295)<<20&4294967295|a>>>12))+((a=t+(r^i^s)+n[5]+4294588738&4294967295)<<4&4294967295|a>>>28))+((a=s+(t^r^i)+n[8]+2272392833&4294967295)<<11&4294967295|a>>>21))+((a=i+(s^t^r)+n[11]+1839030562&4294967295)<<16&4294967295|a>>>16))+((a=r+(i^s^t)+n[14]+4259657740&4294967295)<<23&4294967295|a>>>9))+((a=t+(r^i^s)+n[1]+2763975236&4294967295)<<4&4294967295|a>>>28))+((a=s+(t^r^i)+n[4]+1272893353&4294967295)<<11&4294967295|a>>>21))+((a=i+(s^t^r)+n[7]+4139469664&4294967295)<<16&4294967295|a>>>16))+((a=r+(i^s^t)+n[10]+3200236656&4294967295)<<23&4294967295|a>>>9))+((a=t+(r^i^s)+n[13]+681279174&4294967295)<<4&4294967295|a>>>28))+((a=s+(t^r^i)+n[0]+3936430074&4294967295)<<11&4294967295|a>>>21))+((a=i+(s^t^r)+n[3]+3572445317&4294967295)<<16&4294967295|a>>>16))+((a=r+(i^s^t)+n[6]+76029189&4294967295)<<23&4294967295|a>>>9))+((a=t+(r^i^s)+n[9]+3654602809&4294967295)<<4&4294967295|a>>>28))+((a=s+(t^r^i)+n[12]+3873151461&4294967295)<<11&4294967295|a>>>21))+((a=i+(s^t^r)+n[15]+530742520&4294967295)<<16&4294967295|a>>>16))+((a=r+(i^s^t)+n[2]+3299628645&4294967295)<<23&4294967295|a>>>9))+((a=t+(i^(r|~s))+n[0]+4096336452&4294967295)<<6&4294967295|a>>>26))+((a=s+(r^(t|~i))+n[7]+1126891415&4294967295)<<10&4294967295|a>>>22))+((a=i+(t^(s|~r))+n[14]+2878612391&4294967295)<<15&4294967295|a>>>17))+((a=r+(s^(i|~t))+n[5]+4237533241&4294967295)<<21&4294967295|a>>>11))+((a=t+(i^(r|~s))+n[12]+1700485571&4294967295)<<6&4294967295|a>>>26))+((a=s+(r^(t|~i))+n[3]+2399980690&4294967295)<<10&4294967295|a>>>22))+((a=i+(t^(s|~r))+n[10]+4293915773&4294967295)<<15&4294967295|a>>>17))+((a=r+(s^(i|~t))+n[1]+2240044497&4294967295)<<21&4294967295|a>>>11))+((a=t+(i^(r|~s))+n[8]+1873313359&4294967295)<<6&4294967295|a>>>26))+((a=s+(r^(t|~i))+n[15]+4264355552&4294967295)<<10&4294967295|a>>>22))+((a=i+(t^(s|~r))+n[6]+2734768916&4294967295)<<15&4294967295|a>>>17))+((a=r+(s^(i|~t))+n[13]+1309151649&4294967295)<<21&4294967295|a>>>11))+((s=(t=r+((a=t+(i^(r|~s))+n[4]+4149444226&4294967295)<<6&4294967295|a>>>26))+((a=s+(r^(t|~i))+n[11]+3174756917&4294967295)<<10&4294967295|a>>>22))^((i=s+((a=i+(t^(s|~r))+n[2]+718787259&4294967295)<<15&4294967295|a>>>17))|~t))+n[9]+3951481745&4294967295,e.g[0]=e.g[0]+t&4294967295,e.g[1]=e.g[1]+(i+(a<<21&4294967295|a>>>11))&4294967295,e.g[2]=e.g[2]+i&4294967295,e.g[3]=e.g[3]+s&4294967295}function l(e,t){this.h=t;var r=[];let n=!0;for(let s=e.length-1;0<=s;s--){var i=0|e[s];n&&i==t||(r[s]=i,n=!1)}this.g=r}t=r,s=function(){this.blockSize=-1},n.prototype=s.prototype,t.F=s.prototype,t.prototype=new n,(t.prototype.constructor=t).D=function(e,t,r){for(var n=Array(arguments.length-2),i=2;i<arguments.length;i++)n[i-2]=arguments[i];return s.prototype[t].apply(e,n)},r.prototype.u=function(){this.g[0]=1732584193,this.g[1]=4023233417,this.g[2]=2562383102,this.g[3]=271733878,this.o=this.h=0},r.prototype.v=function(e,t){var r=(t=void 0===t?e.length:t)-this.blockSize,n=this.C;let i=this.h,s=0;for(;s<t;){if(0==i)for(;s<=r;)a(this,e,s),s+=this.blockSize;if("string"==typeof e){for(;s<t;)if(n[i++]=e.charCodeAt(s++),i==this.blockSize){a(this,n),i=0;break}}else for(;s<t;)if(n[i++]=e[s++],i==this.blockSize){a(this,n),i=0;break}}this.h=i,this.o+=t},r.prototype.A=function(){var t=Array((this.h<56?this.blockSize:2*this.blockSize)-this.h);t[0]=128;for(var r=1;r<t.length-8;++r)t[r]=0;for(var r=8*this.o,n=t.length-8;n<t.length;++n)t[n]=255&r,r/=256;for(this.v(t),t=Array(16),n=r=0;n<4;++n)for(let e=0;e<32;e+=8)t[r++]=this.g[n]>>>e&255;return t};var i={};function o(e){return-128<=e&&e<128?(t=e,r=function(e){return new l([0|e],e<0?-1:0)},n=i,Object.prototype.hasOwnProperty.call(n,t)?n[t]:n[t]=r(t)):new l([0|e],e<0?-1:0);var t,r,n}function u(e){if(isNaN(e)||!isFinite(e))return h;if(e<0)return g(u(-e));var t=[];let r=1;for(let n=0;e>=r;n++)t[n]=e/r|0,r*=4294967296;return new l(t,0)}var h=o(0),c=o(1),d=o(16777216);function p(t){if(0==t.h){for(let e=0;e<t.g.length;e++)if(0!=t.g[e])return;return 1}}function f(e){return-1==e.h}function g(e){var t=e.g.length,r=[];for(let n=0;n<t;n++)r[n]=~e.g[n];return new l(r,~e.h).add(c)}function m(e,t){return e.add(g(t))}function v(e,t){for(;(65535&e[t])!=e[t];)e[t+1]+=e[t]>>>16,e[t]&=65535,t++}function _(e,t){this.g=e,this.h=t}function y(e,t){if(p(t))throw Error("division by zero");if(p(e))return new _(h,h);if(f(e))return t=y(g(e),t),new _(g(t.g),g(t.h));if(f(t))return t=y(e,g(t)),new _(g(t.g),t.h);if(30<e.g.length){if(f(e)||f(t))throw Error("slowDivide_ only works with positive integers.");for(var r=c,n=t;n.l(e)<=0;)r=w(r),n=w(n);for(var i=b(r,1),s=b(n,1),n=b(n,2),r=b(r,2);!p(n);){var a=s.add(n);a.l(e)<=0&&(i=i.add(r),s=a),n=b(n,1),r=b(r,1)}return t=m(e,i.j(t)),new _(i,t)}for(i=h;0<=e.l(t);){for(r=Math.max(1,Math.floor(e.m()/t.m())),n=(n=Math.ceil(Math.log(r)/Math.LN2))<=48?1:Math.pow(2,n-48),a=(s=u(r)).j(t);f(a)||0<a.l(e);)a=(s=u(r-=n)).j(t);p(s)&&(s=c),i=i.add(s),e=m(e,a)}return new _(i,e)}function w(e){var t=e.g.length+1,r=[];for(let n=0;n<t;n++)r[n]=e.i(n)<<1|e.i(n-1)>>>31;return new l(r,e.h)}function b(e,t){var r=t>>5,n=(t%=32,e.g.length-r),i=[];for(let s=0;s<n;s++)i[s]=0<t?e.i(s+r)>>>t|e.i(s+r+1)<<32-t:e.i(s+r);return new l(i,e.h)}(e=l.prototype).m=function(){if(f(this))return-g(this).m();let e=0,t=1;for(let n=0;n<this.g.length;n++){var r=this.i(n);e+=(0<=r?r:4294967296+r)*t,t*=4294967296}return e},e.toString=function(t){if((t=t||10)<2||36<t)throw Error("radix out of range: "+t);if(p(this))return"0";if(f(this))return"-"+g(this).toString(t);var r=u(Math.pow(t,6)),n=this;let i="";for(;;){var s=y(n,r).g;let e=((0<(n=m(n,s.j(r))).g.length?n.g[0]:n.h)>>>0).toString(t);if(p(n=s))return e+i;for(;e.length<6;)e="0"+e;i=e+i}},e.i=function(e){return e<0?0:e<this.g.length?this.g[e]:this.h},e.l=function(e){return f(e=m(this,e))?-1:p(e)?0:1},e.abs=function(){return f(this)?g(this):this},e.add=function(e){var t=Math.max(this.g.length,e.g.length),r=[];let n=0;for(let a=0;a<=t;a++){var i=n+(65535&this.i(a))+(65535&e.i(a)),s=(i>>>16)+(this.i(a)>>>16)+(e.i(a)>>>16);n=s>>>16,i&=65535,s&=65535,r[a]=s<<16|i}return new l(r,-2147483648&r[r.length-1]?-1:0)},e.j=function(t){if(p(this)||p(t))return h;if(f(this))return f(t)?g(this).j(g(t)):g(g(this).j(t));if(f(t))return g(this.j(g(t)));if(this.l(d)<0&&t.l(d)<0)return u(this.m()*t.m());for(var e=this.g.length+t.g.length,r=[],n=0;n<2*e;n++)r[n]=0;for(n=0;n<this.g.length;n++)for(let e=0;e<t.g.length;e++){var i=this.i(n)>>>16,s=65535&this.i(n),a=t.i(e)>>>16,o=65535&t.i(e);r[2*n+2*e]+=s*o,v(r,2*n+2*e),r[2*n+2*e+1]+=i*o,v(r,2*n+2*e+1),r[2*n+2*e+1]+=s*a,v(r,2*n+2*e+1),r[2*n+2*e+2]+=i*a,v(r,2*n+2*e+2)}for(t=0;t<e;t++)r[t]=r[2*t+1]<<16|r[2*t];for(t=e;t<2*e;t++)r[t]=0;return new l(r,0)},e.B=function(e){return y(this,e).h},e.and=function(e){var t=Math.max(this.g.length,e.g.length),r=[];for(let n=0;n<t;n++)r[n]=this.i(n)&e.i(n);return new l(r,this.h&e.h)},e.or=function(e){var t=Math.max(this.g.length,e.g.length),r=[];for(let n=0;n<t;n++)r[n]=this.i(n)|e.i(n);return new l(r,this.h|e.h)},e.xor=function(e){var t=Math.max(this.g.length,e.g.length),r=[];for(let n=0;n<t;n++)r[n]=this.i(n)^e.i(n);return new l(r,this.h^e.h)},r.prototype.digest=r.prototype.A,r.prototype.reset=r.prototype.u,r.prototype.update=r.prototype.v,Yg=r,l.prototype.multiply=l.prototype.j,l.prototype.modulo=l.prototype.B,l.prototype.compare=l.prototype.l,l.prototype.toNumber=l.prototype.m,l.prototype.getBits=l.prototype.i,l.fromNumber=u,l.fromString=function e(t,r){if(0==t.length)throw Error("number format error: empty string");if((r=r||10)<2||36<r)throw Error("radix out of range: "+r);if("-"==t.charAt(0))return g(e(t.substring(1),r));if(0<=t.indexOf("-"))throw Error('number format error: interior "-" character');var n=u(Math.pow(r,8));let i=h;for(let o=0;o<t.length;o+=8){var s=Math.min(8,t.length-o),a=parseInt(t.substring(o,o+s),r);i=(s<8?(s=u(Math.pow(r,s)),i.j(s)):i=i.j(n)).add(u(a))}return i},$g=l}).apply(void 0!==lr?lr:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{}),"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{});!(function(){var e,M=Object.defineProperty;var F=(e=>{e=["object"==typeof globalThis&&globalThis,e,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof im&&im];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 U(e,t){if(t)e:{var r=F;e=e.split(".");for(var n=0;n<e.length-1;n++){var i=e[n];if(!(i in r))break e;r=r[i]}(t=t(n=r[e=e[e.length-1]]))!=n&&null!=t&&M(r,e,{configurable:!0,writable:!0,value:t})}}U("Symbol.dispose",function(e){return e||Symbol("Symbol.dispose")}),U("Array.prototype.values",function(e){return e||function(){return this[Symbol.iterator]()}}),U("Object.entries",function(e){return e||function(e){var t,r=[];for(t in e)Object.prototype.hasOwnProperty.call(e,t)&&r.push([t,e[t]]);return r}});var V=V||{},N=this||self;function d(e){var t=typeof e;return"object"==t&&null!=e||"function"==t}function B(e,t,r){return e.call.apply(e.bind,arguments)}function v(e,t,r){return(v=B).apply(null,arguments)}function q(t){var r=Array.prototype.slice.call(arguments,1);return function(){var e=r.slice();return e.push.apply(e,arguments),t.apply(this,e)}}function t(e,s){function t(){}t.prototype=s.prototype,e.Z=s.prototype,e.prototype=new t,(e.prototype.constructor=e).Ob=function(e,t,r){for(var n=Array(arguments.length-2),i=2;i<arguments.length;i++)n[i-2]=arguments[i];return s.prototype[t].apply(e,n)}}var j="undefined"!=typeof AsyncContext&&"function"==typeof AsyncContext.Snapshot?e=>e&&AsyncContext.Snapshot.wrap(e):e=>e;function z(t){var r=t.length;if(0<r){var n=Array(r);for(let e=0;e<r;e++)n[e]=t[e];return n}return[]}function H(t){for(let e=1;e<arguments.length;e++){var r=arguments[e];if("array"==(n="object"!=(n=typeof r)?n:r?Array.isArray(r)?"array":n:"null")||"object"==n&&"number"==typeof r.length){var n=t.length||0,i=r.length||0;t.length=n+i;for(let e=0;e<i;e++)t[n+e]=r[e]}else t.push(r)}}var K=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 G,e=>e.reset());class G{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 r,n=!1,W=new class{constructor(){this.h=this.g=null}add(e,t){var r=K.get();r.set(e,t),this.h?this.h.next=r:this.g=r,this.h=r}},$=()=>{let e=Promise.resolve(void 0);r=()=>{e.then(Y)}};function Y(){for(var e;e=(()=>{let e=W,t=null;return e.g&&(t=e.g,e.g=e.g.next,e.g||(e.h=null),t.next=null),t})();){try{e.h.call(e.g)}catch(e){(e=>{N.setTimeout(()=>{throw e},0)})(e)}var t=K;t.j(e),t.h<100&&(t.h++,e.next=t.g,t.g=e)}n=!1}function i(){this.u=this.u,this.C=this.C}function o(e,t){this.type=e,this.g=this.target=t,this.defaultPrevented=!1}i.prototype.u=!1,i.prototype.dispose=function(){this.u||(this.u=!0,this.N())},i.prototype[Symbol.dispose]=function(){this.dispose()},i.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()},o.prototype.h=function(){this.defaultPrevented=!0};var Q=(()=>{if(!N.addEventListener||!Object.defineProperty)return!1;var e=!1,t=Object.defineProperty({},"passive",{get:function(){e=!0}});try{var r=()=>{};N.addEventListener("test",r,t),N.removeEventListener("test",r,t)}catch(e){}return e})();function R(e){return/^[\s\xa0]*$/.test(e)}function s(e,t){o.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)}t(s,o),s.prototype.init=function(e,t){var r=this.type=e.type,n=e.changedTouches&&e.changedTouches.length?e.changedTouches[0]:null;this.target=e.target||e.srcElement,this.g=t,(t=e.relatedTarget)||("mouseover"==r?t=e.fromElement:"mouseout"==r&&(t=e.toElement)),this.relatedTarget=t,n?(this.clientX=void 0!==n.clientX?n.clientX:n.pageX,this.clientY=void 0!==n.clientY?n.clientY:n.pageY,this.screenX=n.screenX||0,this.screenY=n.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).defaultPrevented&&s.Z.h.call(this)},s.prototype.h=function(){s.Z.h.call(this);var e=this.i;e.preventDefault?e.preventDefault():e.returnValue=!1};var l="closure_listenable_"+(1e6*Math.random()|0),J=0;function X(e,t,r,n,i){this.listener=e,this.proxy=null,this.src=t,this.type=r,this.capture=!!n,this.ha=i,this.key=++J,this.da=this.fa=!1}function Z(e){e.da=!0,e.listener=null,e.proxy=null,e.src=null,e.ha=null}function ee(e,t,r){for(var n in e)t.call(r,e[n],n,e)}function te(e){var t,r={};for(t in e)r[t]=e[t];return r}let re="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function ne(t){let r,n;for(let i=1;i<arguments.length;i++){for(r in n=arguments[i])t[r]=n[r];for(let e=0;e<re.length;e++)r=re[e],Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}}function ie(e){this.src=e,this.g={},this.h=0}function se(e,t){var r,n,i,s=t.type;s in e.g&&(r=e.g[s],(i=0<=(n=Array.prototype.indexOf.call(r,t,void 0)))&&Array.prototype.splice.call(r,n,1),i)&&(Z(t),0==e.g[s].length)&&(delete e.g[s],e.h--)}function ae(e,t,r,n){for(let s=0;s<e.length;++s){var i=e[s];if(!i.da&&i.listener==t&&i.capture==!!r&&i.ha==n)return s}return-1}ie.prototype.add=function(e,t,r,n,i){var s=e.toString(),a=((e=this.g[s])||(e=this.g[s]=[],this.h++),ae(e,t,n,i));return-1<a?(t=e[a],r||(t.fa=!1)):((t=new X(t,this.src,s,!!n,i)).fa=r,e.push(t)),t};var oe="closure_lm_"+(1e6*Math.random()|0),le={};function ue(t,r,n,i,s){if(i&&i.once)return function t(r,n,i,s,a){if(Array.isArray(n)){for(let e=0;e<n.length;e++)t(r,n[e],i,s,a);return null}i=me(i);return r&&r[l]?r.K(n,i,d(s)?!!s.capture:!!s,a):he(r,n,i,!0,s,a)}(t,r,n,i,s);if(Array.isArray(r)){for(let e=0;e<r.length;e++)ue(t,r[e],n,i,s);return null}return n=me(n),t&&t[l]?t.J(r,n,d(i)?!!i.capture:!!i,s):he(t,r,n,!1,i,s)}function he(e,t,r,n,i,s){if(!t)throw Error("Invalid event type");var a=d(i)?!!i.capture:!!i;let o=fe(e);if(o||(e[oe]=o=new ie(e)),!(r=o.add(t,r,n,a,s)).proxy)if(n=(()=>{let r=pe;return function e(t){return r.call(e.src,e.listener,t)}})(),(r.proxy=n).src=e,n.listener=r,e.addEventListener)void 0===(i=Q?i:a)&&(i=!1),e.addEventListener(t.toString(),n,i);else if(e.attachEvent)e.attachEvent(de(t.toString()),n);else{if(!e.addListener||!e.removeListener)throw Error("addEventListener and attachEvent are unavailable.");e.addListener(n)}return r}function ce(e){var t,r,n;"number"!=typeof e&&e&&!e.da&&((t=e.src)&&t[l]?se(t.i,e):(r=e.type,n=e.proxy,t.removeEventListener?t.removeEventListener(r,n,e.capture):t.detachEvent?t.detachEvent(de(r),n):t.addListener&&t.removeListener&&t.removeListener(n),(r=fe(t))?(se(r,e),0==r.h&&(r.src=null,t[oe]=null)):Z(e)))}function de(e){return e in le?le[e]:le[e]="on"+e}function pe(e,t){var r,n;return e=!!e.da||(t=new s(t,this),r=e.listener,n=e.ha||e.src,e.fa&&ce(e),r.call(n,t))}function fe(e){return(e=e[oe])instanceof ie?e:null}var ge="__closure_events_fn_"+(1e9*Math.random()>>>0);function me(t){return"function"==typeof t?t:(t[ge]||(t[ge]=function(e){return t.handleEvent(e)}),t[ge])}function a(){i.call(this),this.i=new ie(this),(this.M=this).G=null}function u(e,t){var r,n,i=e.G;if(i)for(r=[];i;i=i.G)r.push(i);e=e.M,i=t.type||t,"string"==typeof t?t=new o(t,e):t instanceof o?t.target=t.target||e:(n=t,ne(t=new o(i,e),n)),n=!0;let s,a;if(r)for(a=r.length-1;0<=a;a--)n=ve(s=t.g=r[a],i,!0,t)&&n;if(n=ve(s=t.g=e,i,!0,t)&&n,n=ve(s,i,!1,t)&&n,r)for(a=0;a<r.length;a++)n=ve(s=t.g=r[a],i,!1,t)&&n}function ve(e,t,r,n){if(!(t=e.i.g[String(t)]))return!0;t=t.concat();let i=!0;for(let l=0;l<t.length;++l){var s,a,o=t[l];o&&!o.da&&o.capture==r&&(s=o.listener,a=o.ha||o.src,o.fa&&se(e.i,o),i=!1!==s.call(a,n)&&i)}return i&&!n.defaultPrevented}function _e(e){e.g=((e,t)=>{if("function"!=typeof e){if(!e||"function"!=typeof e.handleEvent)throw Error("Invalid listener argument");e=v(e.handleEvent,e)}return 2147483647<Number(t)?-1:N.setTimeout(e,t||0)})(()=>{e.g=null,e.i&&(e.i=!1,_e(e))},e.l);var t=e.h;e.h=null,e.m.apply(null,t)}t(a,i),a.prototype[l]=!0,a.prototype.removeEventListener=function(e,t,r,n){!function e(t,r,n,i,s){if(Array.isArray(r))for(var a=0;a<r.length;a++)e(t,r[a],n,i,s);else i=d(i)?!!i.capture:!!i,n=me(n),t&&t[l]?(t=t.i,(a=String(r).toString())in t.g&&-1<(n=ae(r=t.g[a],n,i,s))&&(Z(r[n]),Array.prototype.splice.call(r,n,1),0==r.length)&&(delete t.g[a],t.h--)):(t=t&&fe(t))&&(r=t.g[r.toString()],n=(t=-1)<(t=r?ae(r,n,i,s):t)?r[t]:null)&&ce(n)}(this,e,t,r,n)},a.prototype.N=function(){if(a.Z.N.call(this),this.i){var t,r=this.i;for(t in r.g){var n=r.g[t];for(let e=0;e<n.length;e++)Z(n[e]);delete r.g[t],r.h--}}this.G=null},a.prototype.J=function(e,t,r,n){return this.i.add(String(e),t,!1,r,n)},a.prototype.K=function(e,t,r,n){return this.i.add(String(e),t,!0,r,n)};class ye extends i{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:_e(this)}N(){super.N(),this.g&&(N.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function h(e){i.call(this),this.h=e,this.g={}}t(h,i);var we=[];function be(e){ee(e.g,function(e,t){this.g.hasOwnProperty(t)&&ce(e)},e),e.g={}}h.prototype.N=function(){h.Z.N.call(this),be(this)},h.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var Te=N.JSON.stringify,Ee=N.JSON.parse,Ie=class{stringify(e){return N.JSON.stringify(e,void 0)}parse(e){return N.JSON.parse(e,void 0)}};function Ce(){}function Se(){}var ke={OPEN:"a",hb:"b",ERROR:"c",tb:"d"};function Ae(){o.call(this,"d")}function Ne(){o.call(this,"c")}t(Ae,o),t(Ne,o);var c={},Re=null;function Pe(){return Re=Re||new a}function xe(e){o.call(this,c.Ia,e)}function De(){var e=Pe();u(e,new xe(e))}function Oe(e,t){o.call(this,c.STAT_EVENT,e),this.stat=t}function P(e){var t=Pe();u(t,new Oe(t,e))}function Le(e,t){o.call(this,c.Ja,e),this.size=t}function _(e,t){if("function"!=typeof e)throw Error("Fn must not be null and must be a function");return N.setTimeout(function(){e()},t)}function p(){this.g=!0}function x(e,t,r,n){e.info(function(){return"XMLHTTP TEXT ("+t+"): "+((e,t)=>{if(!e.g)return t;if(!t)return null;try{var r=JSON.parse(t);if(r)for(e=0;e<r.length;e++)if(Array.isArray(r[e])){var n=r[e];if(!(n.length<2)){var i=n[1];if(Array.isArray(i)&&!(i.length<1)){var s=i[0];if("noop"!=s&&"stop"!=s&&"close"!=s)for(let e=1;e<i.length;e++)i[e]=""}}}return Te(r)}catch(e){return t}})(e,r)+(n?" "+n:"")})}c.Ia="serverreachability",t(xe,o),c.STAT_EVENT="statevent",t(Oe,o),c.Ja="timingevent",t(Le,o),p.prototype.ua=function(){this.g=!1},p.prototype.info=function(){};var Me={NO_ERROR:0,cb:1,qb:2,pb:3,kb:4,ob:5,rb:6,Ga:7,TIMEOUT:8,ub:9},Fe={ib:"complete",Fb:"success",ERROR:"error",Ga:"abort",xb:"ready",yb:"readystatechange",TIMEOUT:"timeout",sb:"incrementaldata",wb:"progress",lb:"downloadprogress",Nb:"uploadprogress"};function Ue(){}function f(e){return encodeURIComponent(String(e))}function g(e,t,r,n){this.j=e,this.i=t,this.l=r,this.S=n||1,this.V=new h(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 Ve}function Ve(){this.i=null,this.g="",this.h=!1}t(Ue,Ce),Ue.prototype.g=function(){return new XMLHttpRequest};var Be=new Ue,qe={},je={};function ze(e,t,r){e.M=1,e.A=ot(y(t)),e.u=r,e.R=!0,He(e,null)}function He(e,t){e.F=Date.now(),Ge(e),e.B=y(e.A);var a,o,l,u,h,c,r=e.B,n=e.S,i=(Array.isArray(n)||(n=[String(n)]),wt(r.i,"t",n),e.C=0,r=e.j.L,e.h=new Ve,e.g=tr(e.j,r?t:null,!e.u),0<e.P&&(e.O=new ye(v(e.Y,e,e.g),e.P)),t=e.V,r=e.g,n=e.ba,"readystatechange");Array.isArray(i)||(i&&(we[0]=i.toString()),i=we);for(let d=0;d<i.length;d++){var s=ue(r,i[d],n||t.handleEvent,!1,t.h||t);if(!s)break;t.g[s.key]=s}t=e.J?te(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)),De(),a=e.i,o=e.v,l=e.B,u=e.l,h=e.S,c=e.u,a.info(function(){if(a.g)if(c){var t="",r=c.split("&");for(let e=0;e<r.length;e++){var n,i,s=r[e].split("=");1<s.length&&(n=s[0],s=s[1],t=2<=(i=n.split("_")).length&&"type"==i[1]?t+(n+"=")+s+"&":t+(n+"=redacted&"))}}else t=null;else t=c;return"XMLHTTP REQ ("+u+") [attempt "+h+"]: "+o+"\n"+l+"\n"+t})}function Ke(e){return e.g&&"GET"==e.v&&2!=e.M&&e.j.Aa}function Ge(e){e.T=Date.now()+e.H,We(e,e.H)}function We(e,t){if(null!=e.D)throw Error("WatchDog timer not null");e.D=_(v(e.aa,e),t)}function $e(e){e.D&&(N.clearTimeout(e.D),e.D=null)}function D(e){0==e.j.I||e.K||Jt(e.j,e)}function O(e){$e(e);var t=e.O;t&&"function"==typeof t.dispose&&t.dispose(),e.O=null,be(e.V),e.g&&(t=e.g,e.g=null,t.abort(),t.dispose())}function Ye(e,t){try{var r=e.j;if(0!=r.I&&(r.g==e||et(r.h,e)))if(!e.L&&et(r.h,e)&&3==r.I){try{var n=r.Ba.g.parse(t)}catch(e){n=null}if(Array.isArray(n)&&3==n.length){var i=n;if(0==i[0]){e:if(!r.v){if(r.g){if(!(r.g.F+3e3<e.F))break e;Qt(r),Bt(r)}Wt(r),P(18)}}else r.xa=i[1],0<r.xa-r.K&&i[2]<37500&&r.F&&0==r.A&&!r.C&&(r.C=_(v(r.Va,r),6e3));Ze(r.h)<=1&&r.ta&&(r.ta=void 0)}else S(r,11)}else if(!e.L&&r.g!=e||Qt(r),!R(t))for(i=r.Ba.g.parse(t),t=0;t<i.length;t++){var s,a,o,l,u,h,c,d,p,f,g=i[t],m=g[0];m<=r.K||(r.K=m,g=g[1],2==r.I?"c"==g[0]?(r.M=g[1],r.ba=g[2],null!=(s=g[3])&&(r.ka=s,r.j.info("VER="+r.ka)),null!=(a=g[4])&&(r.za=a,r.j.info("SVER="+r.za)),null!=(o=g[5])&&"number"==typeof o&&0<o&&(n=1.5*o,r.O=n,r.j.info("backChannelRequestTimeoutMs_="+n)),n=r,(l=e.g)&&(!(u=l.g?l.g.getResponseHeader("X-Client-Wire-Protocol"):null)||(h=n.h).g||-1==u.indexOf("spdy")&&-1==u.indexOf("quic")&&-1==u.indexOf("h2")||(h.j=h.l,h.g=new Set,h.h&&(tt(h,h.h),h.h=null)),n.G)&&(c=l.g?l.g.getResponseHeader("X-HTTP-Session-Id"):null)&&(n.wa=c,b(n.J,n.G,c)),r.I=3,r.l&&r.l.ra(),r.aa&&(r.T=Date.now()-e.F,r.j.info("Handshake RTT: "+r.T+"ms")),d=e,(n=r).na=er(n,n.L?n.ba:null,n.W),d.L?(rt(n.h,d),p=d,(f=n.O)&&(p.H=f),p.D&&($e(p),Ge(p)),n.g=d):Gt(n),0<r.i.length&&jt(r)):"stop"!=g[0]&&"close"!=g[0]||S(r,7):3==r.I&&("stop"==g[0]||"close"==g[0]?"stop"==g[0]?S(r,7):Vt(r):"noop"!=g[0]&&r.l&&r.l.qa(g),r.A=0))}De()}catch(e){}}g.prototype.ba=function(e){e=e.target;var t=this.O;t&&3==L(e)?t.j():this.Y(e)},g.prototype.Y=function(e){try{if(e==this.g)e:{var t=L(this.g),r=this.g.ya();this.g.ca();if(!(t<3)&&(3!=t||this.g&&(this.h.h||this.g.la()||Mt(this.g)))){this.K||4!=t||7==r||De(),$e(this);var n,i,s=this.g.ca(),a=(this.X=s,(e=>{if(!Ke(e))return e.g.la();var t=Mt(e.g);if(""===t)return"";let r="",n=t.length,i=4==L(e.g);if(!e.h.i){if("undefined"==typeof TextDecoder)return O(e),D(e),"";e.h.i=new N.TextDecoder}for(let s=0;s<n;s++)e.h.h=!0,r+=e.h.i.decode(t[s],{stream:!(i&&s==n-1)});return t.length=0,e.h.g+=r,e.C=0,e.h.g})(this));if(this.o=200==s,T=this.i,E=this.v,I=this.B,C=this.l,S=this.S,k=t,A=s,T.info(function(){return"XMLHTTP RESP ("+C+") [ attempt "+S+"]: "+E+"\n"+I+"\n"+k+" "+A}),this.o){if(this.U&&!this.L){t:{if(this.g){var o,l=this.g;if((o=l.g?l.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!R(o)){var u=o;break t}}u=null}if(!(e=u)){this.o=!1,this.m=3,P(12),O(this),D(this);break e}x(this.i,this.l,e,"Initial handshake response via X-HTTP-Initial-Response"),this.L=!0,Ye(this,e)}if(this.R){for(e=!0;!this.K&&this.C<a.length;){if(y=a,b=w=void 0,w=(_=this).C,(n=-1==(b=y.indexOf("\n",w))?je:(w=Number(y.substring(w,b)),isNaN(w)?qe:(b+=1)+w>y.length?je:(y=y.slice(b,b+w),_.C=b+w,y)))==je){4==t&&(this.m=4,P(14),e=!1),x(this.i,this.l,null,"[Incomplete Response]");break}if(n==qe){this.m=4,P(15),x(this.i,this.l,a,"[Invalid Chunk]"),e=!1;break}x(this.i,this.l,n,null),Ye(this,n)}Ke(this)&&0!=this.C&&(this.h.g=this.h.g.slice(this.C),this.C=0),4!=t||0!=a.length||this.h.h||(this.m=1,P(16),e=!1),this.o=this.o&&e,e?0<a.length&&!this.W&&(this.W=!0,(i=this.j).g==this)&&i.aa&&!i.P&&(i.j.info("Great, no buffering proxy detected. Bytes received: "+a.length),$t(i),i.P=!0,P(11)):(x(this.i,this.l,a,"[Invalid Chunked Response]"),O(this),D(this))}else x(this.i,this.l,a,null),Ye(this,a);4==t&&O(this),this.o&&!this.K&&(4==t?Jt(this.j,this):(this.o=!1,Ge(this)))}else{{var h=this.g;var c,d,p,f={};h=(h.g&&2<=L(h)&&h.g.getAllResponseHeaders()||"").split("\r\n");for(let e=0;e<h.length;e++)R(h[e])||(c=(e=>{for(var t=1,r=(e=e.split(":"),[]);0<t&&e.length;)r.push(e.shift()),t--;return e.length&&r.push(e.join(":")),r})(h[e]),d=c[0],"string"==typeof(c=c[1])&&(c=c.trim(),p=f[d]||[],(f[d]=p).push(c)));var g,m=f,v=function(e){return e.join(", ")};for(g in m)v.call(void 0,m[g],g,m)}400==s&&0<a.indexOf("Unknown SID")?(this.m=3,P(12)):(this.m=0,P(13)),O(this),D(this)}}}}catch(e){}var _,y,w,b,T,E,I,C,S,k,A},g.prototype.cancel=function(){this.K=!0,O(this)},g.prototype.aa=function(){this.D=null;var e,t,r=Date.now();0<=r-this.T?(e=this.i,t=this.B,e.info(function(){return"TIMEOUT: "+t}),2!=this.M&&(De(),P(17)),O(this),this.m=2,D(this)):We(this,this.T-r)};var Qe=class{constructor(e,t){this.g=e,this.map=t}};function Je(e){this.l=e||10,e=N.PerformanceNavigationTiming?0<(e=N.performance.getEntriesByType("navigation")).length&&("hq"==e[0].nextHopProtocol||"h2"==e[0].nextHopProtocol):!!(N.chrome&&N.chrome.loadTimes&&N.chrome.loadTimes()&&N.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 Xe(e){return e.h||e.g&&e.g.size>=e.j}function Ze(e){return e.h?1:e.g?e.g.size:0}function et(e,t){return e.h?e.h==t:e.g&&e.g.has(t)}function tt(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 nt(t){if(null!=t.h)return t.i.concat(t.h.G);if(null==t.g||0===t.g.size)return z(t.i);{let e=t.i;for(var r of t.g.values())e=e.concat(r.G);return e}}Je.prototype.cancel=function(){if(this.i=nt(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&0!==this.g.size){for(var e of this.g.values())e.cancel();this.g.clear()}};var it=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function m(e){this.g=this.o=this.j="",this.u=null,this.m=this.h="",this.l=!1;let t;e instanceof m?(this.l=e.l,w(this,e.j),this.o=e.o,this.g=e.g,st(this,e.u),this.h=e.h,at(this,bt(e.i)),this.m=e.m):e&&(t=String(e).match(it))?(this.l=!1,w(this,t[1]||"",!0),this.o=lt(t[2]||""),this.g=lt(t[3]||"",!0),st(this,t[4]),this.h=lt(t[5]||"",!0),at(this,t[6]||"",!0),this.m=lt(t[7]||"")):(this.l=!1,this.i=new mt(null,this.l))}function y(e){return new m(e)}function w(e,t,r){e.j=r?lt(t,!0):t,e.j&&(e.j=e.j.replace(/:$/,""))}function st(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 at(e,t,r){var n,i;t instanceof mt?(e.i=t,n=e.i,(i=e.l)&&!n.j&&(T(n),n.i=null,n.g.forEach(function(e,t){var r=t.toLowerCase();t!=r&&(vt(this,t),wt(this,r,e))},n)),n.j=i):(r||(t=ut(t,ft)),e.i=new mt(t,e.l))}function b(e,t,r){e.i.set(t,r)}function ot(e){return b(e,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)),e}function lt(e,t){return e?t?decodeURI(e.replace(/%25/g,"%2525")):decodeURIComponent(e):""}function ut(e,t,r){return"string"==typeof e?(e=encodeURI(e).replace(t,ht),e=r?e.replace(/%25([0-9a-fA-F]{2})/g,"%$1"):e):null}function ht(e){return"%"+((e=e.charCodeAt(0))>>4&15).toString(16)+(15&e).toString(16)}m.prototype.toString=function(){var e=[],t=this.j,r=(t&&e.push(ut(t,ct,!0),":"),this.g);return!r&&"file"!=t||(e.push("//"),(t=this.o)&&e.push(ut(t,ct,!0),"@"),e.push(f(r).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),null==(r=this.u))||e.push(":",String(r)),(r=this.h)&&(this.g&&"/"!=r.charAt(0)&&e.push("/"),e.push(ut(r,"/"==r.charAt(0)?pt:dt,!0))),(r=this.i.toString())&&e.push("?",r),(r=this.m)&&e.push("#",ut(r,gt)),e.join("")},m.prototype.resolve=function(e){var t=y(this);let r=!!e.j;r?w(t,e.j):r=!!e.o,r?t.o=e.o:r=!!e.g,r?t.g=e.g:r=null!=e.u;var n=e.h;if(r)st(t,e.u);else if(r=!!e.h)if("/"!=n.charAt(0)&&(this.g&&!this.h?n="/"+n:-1!=(i=t.h.lastIndexOf("/"))&&(n=t.h.slice(0,i+1)+n)),".."==(i=n)||"."==i)n="";else if(-1!=i.indexOf("./")||-1!=i.indexOf("/.")){var n=0==i.lastIndexOf("/",0),i=i.split("/"),s=[];for(let e=0;e<i.length;){var a=i[e++];"."==a?n&&e==i.length&&s.push(""):".."==a?((1<s.length||1==s.length&&""!=s[0])&&s.pop(),n&&e==i.length&&s.push("")):(s.push(a),n=!0)}n=s.join("/")}else n=i;return r?t.h=n:r=""!==e.i.toString(),r?at(t,bt(e.i)):r=!!e.m,r&&(t.m=e.m),t};var ct=/[#\/\?@]/g,dt=/[#\?:]/g,pt=/[#\?]/g,ft=/[#\?@]/g,gt=/#/g;function mt(e,t){this.h=this.g=null,this.i=e||null,this.j=!!t}function T(r){if(!r.g&&(r.g=new Map,r.h=0,r.i)){var n=r.i,i=function(e,t){r.add(decodeURIComponent(e.replace(/\+/g," ")),t)};if(n){n=n.split("&");for(let r=0;r<n.length;r++){var s=n[r].indexOf("=");let e,t=null;0<=s?(e=n[r].substring(0,s),t=n[r].substring(s+1)):e=n[r],i(e,t?decodeURIComponent(t.replace(/\+/g," ")):"")}}}}function vt(e,t){T(e),t=E(e,t),e.g.has(t)&&(e.i=null,e.h-=e.g.get(t).length,e.g.delete(t))}function _t(e,t){return T(e),t=E(e,t),e.g.has(t)}function yt(e,t){T(e);let r=[];if("string"==typeof t)_t(e,t)&&(r=r.concat(e.g.get(E(e,t))));else for(e=Array.from(e.g.values()),t=0;t<e.length;t++)r=r.concat(e[t]);return r}function wt(e,t,r){vt(e,t),0<r.length&&(e.i=null,e.g.set(E(e,t),z(r)),e.h+=r.length)}function bt(e){var t=new mt;return t.i=e.i,e.g&&(t.g=new Map(e.g),t.h=e.h),t}function E(e,t){return t=String(t),t=e.j?t.toLowerCase():t}function I(e,t,r,n,i){try{i&&(i.onload=null,i.onerror=null,i.onabort=null,i.ontimeout=null),n(r)}catch(e){}}function Tt(){this.g=new Ie}function Et(e){this.i=e.Sb||null,this.h=e.ab||!1}function It(e,t){a.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 Ct(e){e.j.read().then(e.Ma.bind(e)).catch(e.ga.bind(e))}function St(e){e.readyState=4,e.l=null,e.j=null,e.B=null,kt(e)}function kt(e){e.onreadystatechange&&e.onreadystatechange.call(e)}function At(e){let r="";return ee(e,function(e,t){r=(r=r+t+":")+e+"\r\n"}),r}function Nt(e,t,r){e:{for(n in r){var n=!1;break e}n=!0}n||(r=At(r),"string"==typeof e?null!=r&&f(r):b(e,t,r))}function C(e){a.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}(e=mt.prototype).add=function(e,t){T(this),this.i=null,e=E(this,e);let r=this.g.get(e);return r||this.g.set(e,r=[]),r.push(t),this.h+=1,this},e.forEach=function(r,n){T(this),this.g.forEach(function(e,t){e.forEach(function(e){r.call(n,e,t,this)},this)},this)},e.set=function(e,t){return T(this),this.i=null,_t(this,e=E(this,e))&&(this.h-=this.g.get(e).length),this.g.set(e,[t]),this.h+=1,this},e.get=function(e,t){return e&&0<(e=yt(this,e)).length?String(e[0]):t},e.toString=function(){if(this.i)return this.i;if(!this.g)return"";var r=[],e=Array.from(this.g.keys());for(let s=0;s<e.length;s++){var n=f(i=e[s]),i=yt(this,i);for(let t=0;t<i.length;t++){let e=n;""!==i[t]&&(e+="="+f(i[t])),r.push(e)}}return this.i=r.join("&")},t(Et,Ce),Et.prototype.g=function(){return new It(this.i,this.h)},t(It,a),(e=It.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,kt(this)},e.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;var t={headers:this.A,method:this.F,credentials:this.m,cache:void 0,signal:this.v.signal};e&&(t.body=e),(this.H||N).fetch(new Request(this.D,t)).then(this.Pa.bind(this),this.ga.bind(this))},e.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(()=>{}),1<=this.readyState&&this.g&&4!=this.readyState&&(this.g=!1,St(this)),this.readyState=0},e.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,kt(this)),this.g)&&(this.readyState=3,kt(this),this.g))if("arraybuffer"===this.responseType)e.arrayBuffer().then(this.Na.bind(this),this.ga.bind(this));else if(void 0!==N.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;Ct(this)}else e.text().then(this.Oa.bind(this),this.ga.bind(this))},e.Ma=function(e){var t;this.g&&(this.o&&e.value?this.response.push(e.value):!this.o&&(t=e.value||new Uint8Array(0),t=this.B.decode(t,{stream:!e.done}))&&(this.response=this.responseText+=t),(e.done?St:kt)(this),3==this.readyState)&&Ct(this)},e.Oa=function(e){this.g&&(this.response=this.responseText=e,St(this))},e.Na=function(e){this.g&&(this.response=e,St(this))},e.ga=function(){this.g&&St(this)},e.setRequestHeader=function(e,t){this.A.append(e,t)},e.getResponseHeader=function(e){return this.h&&this.h.get(e.toLowerCase())||""},e.getAllResponseHeaders=function(){if(!this.h)return"";for(var e=[],t=this.h.entries(),r=t.next();!r.done;)r=r.value,e.push(r[0]+": "+r[1]),r=t.next();return e.join("\r\n")},Object.defineProperty(It.prototype,"withCredentials",{get:function(){return"include"===this.m},set:function(e){this.m=e?"include":"same-origin"}}),t(C,a);var Rt=/^https?$/i,Pt=["POST","PUT"];function xt(e,t){e.h=!1,e.g&&(e.j=!0,e.g.abort(),e.j=!1),e.l=t,e.o=5,Dt(e),Lt(e)}function Dt(e){e.A||(e.A=!0,u(e,"complete"),u(e,"error"))}function Ot(t){if(t.h&&void 0!==V)if(t.v&&4==L(t))setTimeout(t.Ca.bind(t),0);else if(u(t,"readystatechange"),4==L(t)){t.h=!1;try{var e,r,n=t.ca();switch(n){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var i=!0;break;default:i=!1}if(!(e=i)){if(r=0===n){let e=String(t.D).match(it)[1]||null;!e&&N.self&&N.self.location&&(e=N.self.location.protocol.slice(0,-1)),r=!Rt.test(e?e.toLowerCase():"")}e=r}if(e)u(t,"complete"),u(t,"success");else{t.o=6;try{var s=2<L(t)?t.g.statusText:""}catch(e){s=""}t.l=s+" ["+t.ca()+"]",Dt(t)}}finally{Lt(t)}}}function Lt(e,t){if(e.g){e.m&&(clearTimeout(e.m),e.m=null);var r=e.g;e.g=null,t||u(e,"ready");try{r.onreadystatechange=null}catch(e){}}}function L(e){return e.g?e.g.readyState:0}function Mt(e){try{if(e.g){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 Ft(e,t,r){return r&&r.internalChannelParams&&r.internalChannelParams[e]||t}function Ut(e){this.za=0,this.i=[],this.j=new p,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=Ft("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=Ft("baseRetryDelayMs",5e3,e),this.Za=Ft("retryDelaySeedMs",1e4,e),this.Ta=Ft("forwardChannelMaxRetries",2,e),this.va=Ft("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 Je(e&&e.concurrentRequestLimit),this.Ba=new Tt,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&&0<e.longPollingTimeout&&(this.ia=e.longPollingTimeout),this.ta=void 0,this.T=0,this.P=!1,this.ja=this.B=null}function Vt(e){if(qt(e),3==e.I){var t=e.V++,r=y(e.J);if(b(r,"SID",e.M),b(r,"RID",t),b(r,"TYPE","terminate"),Ht(e,r),(t=new g(e,e.j,t)).M=2,t.A=ot(y(r)),r=!1,N.navigator&&N.navigator.sendBeacon)try{r=N.navigator.sendBeacon(t.A.toString(),"")}catch(e){}!r&&N.Image&&((new Image).src=t.A,r=!0),r||(t.g=tr(t.j,null),t.g.ea(t.A)),t.F=Date.now(),Ge(t)}Zt(e)}function Bt(e){e.g&&($t(e),e.g.cancel(),e.g=null)}function qt(e){Bt(e),e.v&&(N.clearTimeout(e.v),e.v=null),Qt(e),e.h.cancel(),e.m&&("number"==typeof e.m&&N.clearTimeout(e.m),e.m=null)}function jt(e){var t;Xe(e.h)||e.m||(e.m=!0,t=e.Ea,r||$(),n||(r(),n=!0),W.add(t,e),e.D=0)}function zt(e,t){var r=t?t.l:e.V++,n=y(e.J);b(n,"SID",e.M),b(n,"RID",r),b(n,"AID",e.K),Ht(e,n),e.u&&e.o&&Nt(n,e.u,e.o),r=new g(e,e.j,r,e.D+1),null===e.u&&(r.J=e.o),t&&(e.i=t.G.concat(e.i)),t=Kt(e,r,1e3),r.H=Math.round(.5*e.va)+Math.round(.5*e.va*Math.random()),tt(e.h,r),ze(r,n,t)}function Ht(e,r){e.H&&ee(e.H,function(e,t){b(r,t,e)}),e.l&&ee({},function(e,t){b(r,t,e)})}function Kt(e,t,i){i=Math.min(e.i.length,i);var s=e.l?v(e.l.Ka,e.l,e):null;e:{let r=e.i,n=-1;for(;;){var a=["count="+i];-1==n?0<i?(n=r[0].g,a.push("ofs="+n)):n=0:a.push("ofs="+n);let e=!0;for(let t=0;t<i;t++){var o=r[t].g,l=r[t].map;if((o-=n)<0)n=Math.max(0,r[t].g-100),e=!1;else try{o="req"+o+"_"||"";try{var u,h,c=l instanceof Map?l:Object.entries(l);for([u,h]of c){let e=h;d(h)&&(e=Te(h)),a.push(o+u+"="+encodeURIComponent(e))}}catch(e){throw a.push(o+"type="+encodeURIComponent("_badmap")),e}}catch(e){s&&s(l)}}if(e){c=a.join("&");break e}}c=void 0}return e=e.i.splice(0,i),t.G=e,c}function Gt(e){var t;e.g||e.v||(e.Y=1,t=e.Da,r||$(),n||(r(),n=!0),W.add(t,e),e.A=0)}function Wt(e){return!(e.g||e.v||3<=e.A)&&(e.Y++,e.v=_(v(e.Da,e),Xt(e,e.A)),e.A++,1)}function $t(e){null!=e.B&&(N.clearTimeout(e.B),e.B=null)}function Yt(e){e.g=new g(e,e.j,"rpc",e.Y),null===e.u&&(e.g.J=e.o),e.g.P=0;var t=y(e.na),r=(b(t,"RID","rpc"),b(t,"SID",e.M),b(t,"AID",e.K),b(t,"CI",e.F?"0":"1"),!e.F&&e.ia&&b(t,"TO",e.ia),b(t,"TYPE","xmlhttp"),Ht(e,t),e.u&&e.o&&Nt(t,e.u,e.o),e.O&&(e.g.H=e.O),e.g);e=e.ba,r.M=1,r.A=ot(y(t)),r.u=null,r.R=!0,He(r,e)}function Qt(e){null!=e.C&&(N.clearTimeout(e.C),e.C=null)}function Jt(e,t){var r,n,i,s=null;if(e.g==t){Qt(e),$t(e),e.g=null;var a=2}else{if(!et(e.h,t))return;s=t.G,rt(e.h,t),a=1}if(0!=e.I)if(t.o)(1==a?(s=t.u?t.u.length:0,t=Date.now()-t.F,r=e.D,u(a=Pe(),new Le(a,s)),jt):Gt)(e);else if(3==(r=t.m)||0==r&&0<t.X||(1!=a||(i=t,Ze((n=e).h)>=n.h.j-(n.m?1:0))||(n.m?(n.i=i.G.concat(n.i),0):1==n.I||2==n.I||n.D>=(n.Sa?0:n.Ta)||(n.m=_(v(n.Ea,n,i),Xt(n,n.D)),n.D++,0)))&&(2!=a||!Wt(e)))switch(s&&0<s.length&&(t=e.h,t.i=t.i.concat(s)),r){case 1:S(e,5);break;case 4:S(e,10);break;case 3:S(e,6);break;default:S(e,2)}}function Xt(e,t){let r=e.Qa+Math.floor(Math.random()*e.Za);return e.isActive()||(r*=2),r*t}function S(e,t){var r,n,i;e.j.info("Error code "+t),2==t?(r=v(e.bb,e),n=!(i=e.Ua),i=new m(i||"//www.google.com/images/cleardot.gif"),N.location&&"http"==N.location.protocol||w(i,"https"),ot(i),(n?(t,r)=>{var n=new p;if(N.Image){let e=new Image;e.onload=q(I,n,"TestLoadImage: loaded",!0,r,e),e.onerror=q(I,n,"TestLoadImage: error",!1,r,e),e.onabort=q(I,n,"TestLoadImage: abort",!1,r,e),e.ontimeout=q(I,n,"TestLoadImage: timeout",!1,r,e),N.setTimeout(function(){e.ontimeout&&e.ontimeout()},1e4),e.src=t}else r(!1)}:(e,t)=>{let r=new p,n=new AbortController,i=setTimeout(()=>{n.abort(),I(r,0,!1,t)},1e4);fetch(e,{signal:n.signal}).then(e=>{clearTimeout(i),e.ok?I(r,0,!0,t):I(r,0,!1,t)}).catch(()=>{clearTimeout(i),I(r,0,!1,t)})})(i.toString(),r)):P(2),e.I=0,e.l&&e.l.pa(t),Zt(e),qt(e)}function Zt(e){var t;e.I=0,e.ja=[],e.l&&(0==(t=nt(e.h)).length&&0==e.i.length||(H(e.ja,t),H(e.ja,e.i),e.h.i.length=0,z(e.i),e.i.length=0),e.l.oa())}function er(e,t,r){var n,i,s=r instanceof m?y(r):new m(r);return""!=s.g?(t&&(s.g=t+"."+s.g),st(s,s.u)):(s=(n=N.location).protocol,t=t?t+"."+n.hostname:n.hostname,n=+n.port,i=new m(null),s&&w(i,s),t&&(i.g=t),n&&st(i,n),r&&(i.h=r),s=i),r=e.G,t=e.wa,r&&t&&b(s,r,t),b(s,"VER",e.ka),Ht(e,s),s}function tr(e,t,r){if(t&&!e.L)throw Error("Can't create secondary domain capable XhrIo object.");return(t=e.Aa&&!e.ma?new C(new Et({ab:r})):new C(e.ma)).Fa(e.L),t}function rr(){}function nr(){}function k(e,t){a.call(this),this.g=new Ut(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)&&!R(e)&&(this.g.u=e),this.A=t&&t.supportsCrossDomainXhr||!1,this.v=t&&t.sendRawJson||!1,(t=t&&t.httpSessionIdParam)&&!R(t)&&(this.g.G=t,null!==(e=this.h))&&t in e&&t in(e=this.h)&&delete e[t],this.j=new A(this)}function ir(e){Ae.call(this),e.__headers__&&(this.headers=e.__headers__,this.statusCode=e.__status__,delete e.__headers__,delete e.__status__);var t=e.__sm__;if(t){e:{for(var r in t){e=r;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 sr(){Ne.call(this),this.status=1}function A(e){this.g=e}(e=C.prototype).Fa=function(e){this.H=e},e.ea=function(e,t,r,n){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||Be).g(),this.g.onreadystatechange=j(v(this.Ca,this));try{this.B=!0,this.g.open(t,String(e),!0),this.B=!1}catch(e){return void xt(this,e)}if(e=r||"",r=new Map(this.headers),n)if(Object.getPrototypeOf(n)===Object.prototype)for(var i in n)r.set(i,n[i]);else{if("function"!=typeof n.keys||"function"!=typeof n.get)throw Error("Unknown input type for opt_headers: "+String(n));for(var s of n.keys())r.set(s,n.get(s))}n=Array.from(r.keys()).find(e=>"content-type"==e.toLowerCase()),i=N.FormData&&e instanceof N.FormData,0<=Array.prototype.indexOf.call(Pt,t,void 0)&&!n&&!i&&r.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");for(var[a,o]of r)this.g.setRequestHeader(a,o);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){xt(this,e)}},e.abort=function(e){this.g&&this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1,this.o=e||7,u(this,"complete"),u(this,"abort"),Lt(this))},e.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),Lt(this,!0)),C.Z.N.call(this)},e.Ca=function(){this.u||(this.B||this.v||this.j?Ot(this):this.Xa())},e.Xa=function(){Ot(this)},e.isActive=function(){return!!this.g},e.ca=function(){try{return 2<L(this)?this.g.status:-1}catch(e){return-1}},e.la=function(){try{return this.g?this.g.responseText:""}catch(e){return""}},e.La=function(e){var t;if(this.g)return t=this.g.responseText,e&&0==t.indexOf(e)&&(t=t.substring(e.length)),Ee(t)},e.ya=function(){return this.o},e.Ha=function(){return"string"==typeof this.l?this.l:String(this.l)},(e=Ut.prototype).ka=8,e.I=1,e.connect=function(e,t,r,n){P(0),this.W=e,this.H=t||{},r&&void 0!==n&&(this.H.OSID=r,this.H.OAID=n),this.F=this.X,this.J=er(this,null,this.W),jt(this)},e.Ea=function(t){if(this.m)if(this.m=null,1==this.I){if(!t){this.V=Math.floor(1e5*Math.random()),t=this.V++;var r=new g(this,this.j,t);let e=this.o;if(this.U&&(e?ne(e=te(e),this.U):e=this.U),null!==this.u||this.R||(r.J=e,e=null),this.S)e:{for(var n=0,i=0;i<this.i.length;i++){var s=this.i[i];if("__data__"in s.map&&"string"==typeof(s=s.map.__data__)?s=s.length:s=void 0,void 0===s)break;if(4096<(n+=s)){n=i;break e}if(4096===n||i===this.i.length-1){n=i+1;break e}}n=1e3}else n=1e3;n=Kt(this,r,n),b(i=y(this.J),"RID",t),b(i,"CVER",22),this.G&&b(i,"X-HTTP-Session-Id",this.G),Ht(this,i),e&&(this.R?n="headers="+f(At(e))+"&"+n:this.u&&Nt(i,this.u,e)),tt(this.h,r),this.Ra&&b(i,"TYPE","init"),this.S?(b(i,"$req",n),b(i,"SID","null"),r.U=!0,ze(r,i,null)):ze(r,i,n),this.I=2}}else 3==this.I&&(t?zt(this,t):0==this.i.length||Xe(this.h)||zt(this))},e.Da=function(){var e;this.v=null,Yt(this),this.aa&&!(this.P||null==this.g||this.T<=0)&&(e=4*this.T,this.j.info("BP detection timer enabled: "+e),this.B=_(v(this.Wa,this),e))},e.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,P(10),Bt(this),Yt(this))},e.Va=function(){null!=this.C&&(this.C=null,Bt(this),Wt(this),P(19))},e.bb=function(e){e?(this.j.info("Successfully pinged google.com"),P(2)):(this.j.info("Failed to ping google.com"),P(1))},e.isActive=function(){return!!this.l&&this.l.isActive(this)},(e=rr.prototype).ra=function(){},e.qa=function(){},e.pa=function(){},e.oa=function(){},e.isActive=function(){return!0},e.Ka=function(){},nr.prototype.g=function(e,t){return new k(e,t)},t(k,a),k.prototype.m=function(){this.g.l=this.j,this.A&&(this.g.L=!0),this.g.connect(this.l,this.h||void 0)},k.prototype.close=function(){Vt(this.g)},k.prototype.o=function(e){var t,r=this.g;"string"==typeof e?((t={}).__data__=e,e=t):this.v&&((t={}).__data__=Te(e),e=t),r.i.push(new Qe(r.Ya++,e)),3==r.I&&jt(r)},k.prototype.N=function(){this.g.l=null,delete this.j,Vt(this.g),delete this.g,k.Z.N.call(this)},t(ir,Ae),t(sr,Ne),t(A,rr),A.prototype.ra=function(){u(this.g,"a")},A.prototype.qa=function(e){u(this.g,new ir(e))},A.prototype.pa=function(e){u(this.g,new sr)},A.prototype.oa=function(){u(this.g,"b")},nr.prototype.createWebChannel=nr.prototype.g,k.prototype.send=k.prototype.o,k.prototype.open=k.prototype.m,nm=function(){return new nr},rm=Pe,tm=c,em={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},Me.NO_ERROR=0,Me.TIMEOUT=8,Me.HTTP_ERROR=6,Zg=Me,Fe.COMPLETE="complete",Xg=Fe,(Se.EventType=ke).OPEN="a",ke.CLOSE="b",ke.ERROR="c",ke.MESSAGE="d",a.prototype.listen=a.prototype.J,Jg=Se,C.prototype.listenOnce=C.prototype.K,C.prototype.getLastError=C.prototype.Ha,C.prototype.getLastErrorCode=C.prototype.ya,C.prototype.getStatus=C.prototype.ca,C.prototype.getResponseJson=C.prototype.La,C.prototype.getResponseText=C.prototype.la,C.prototype.send=C.prototype.ea,C.prototype.setWithCredentials=C.prototype.Fa,Qg=C}).apply(void 0!==im?im:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{});class E{static FOLD_CASE=1;static LITERAL=2;static CLASS_NL=4;static DOT_NL=8;static ONE_LINE=16;static NON_GREEDY=32;static PERL_X=64;static UNICODE_GROUPS=128;static WAS_DOLLAR=256;static MATCH_NL=E.CLASS_NL|E.DOT_NL;static PERL=E.CLASS_NL|E.ONE_LINE|E.PERL_X|E.UNICODE_GROUPS;static POSIX=0;static UNANCHORED=0;static ANCHOR_START=1;static ANCHOR_BOTH=2}class f{static CODES=new Map([["",7],["\b",8],["\t",9],["\n",10],["\v",11],["\f",12],["\r",13],[" ",32],['"',34],["$",36],["&",38],["(",40],[")",41],["*",42],["+",43],["-",45],[".",46],["0",48],["1",49],["2",50],["3",51],["4",52],["5",53],["6",54],["7",55],["8",56],["9",57],[":",58],["<",60],[">",62],["?",63],["A",65],["B",66],["C",67],["F",70],["P",80],["Q",81],["U",85],["Z",90],["[",91],["\\",92],["]",93],["^",94],["_",95],["a",97],["b",98],["f",102],["i",105],["m",109],["n",110],["r",114],["s",115],["t",116],["v",118],["x",120],["z",122],["{",123],["|",124],["}",125]]);static toUpperCase(e){var t,r=String.fromCodePoint(e).toUpperCase();return 1<r.length||1<(t=String.fromCodePoint(r.codePointAt(0)).toLowerCase()).length||t.codePointAt(0)!==e?e:r.codePointAt(0)}static toLowerCase(e){var t,r=String.fromCodePoint(e).toLowerCase();return 1<r.length||1<(t=String.fromCodePoint(r.codePointAt(0)).toUpperCase()).length||t.codePointAt(0)!==e?e:r.codePointAt(0)}}class r{static CASE_ORBIT=new Map([[75,107],[107,8490],[8490,75],[83,115],[115,383],[383,83],[181,924],[924,956],[956,181],[197,229],[229,8491],[8491,197],[452,453],[453,454],[454,452],[455,456],[456,457],[457,455],[458,459],[459,460],[460,458],[497,498],[498,499],[499,497],[837,921],[921,953],[953,8126],[8126,837],[914,946],[946,976],[976,914],[917,949],[949,1013],[1013,917],[920,952],[952,977],[977,1012],[1012,920],[922,954],[954,1008],[1008,922],[928,960],[960,982],[982,928],[929,961],[961,1009],[1009,929],[931,962],[962,963],[963,931],[934,966],[966,981],[981,934],[937,969],[969,8486],[8486,937],[1042,1074],[1074,7296],[7296,1042],[1044,1076],[1076,7297],[7297,1044],[1054,1086],[1086,7298],[7298,1054],[1057,1089],[1089,7299],[7299,1057],[1058,1090],[1090,7300],[7300,7301],[7301,1058],[1066,1098],[1098,7302],[7302,1066],[1122,1123],[1123,7303],[7303,1122],[7304,42570],[42570,42571],[42571,7304],[7776,7777],[7777,7835],[7835,7776],[223,7838],[7838,223],[8064,8072],[8072,8064],[8065,8073],[8073,8065],[8066,8074],[8074,8066],[8067,8075],[8075,8067],[8068,8076],[8076,8068],[8069,8077],[8077,8069],[8070,8078],[8078,8070],[8071,8079],[8079,8071],[8080,8088],[8088,8080],[8081,8089],[8089,8081],[8082,8090],[8090,8082],[8083,8091],[8091,8083],[8084,8092],[8092,8084],[8085,8093],[8093,8085],[8086,8094],[8094,8086],[8087,8095],[8095,8087],[8096,8104],[8104,8096],[8097,8105],[8105,8097],[8098,8106],[8106,8098],[8099,8107],[8107,8099],[8100,8108],[8108,8100],[8101,8109],[8109,8101],[8102,8110],[8110,8102],[8103,8111],[8111,8103],[8115,8124],[8124,8115],[8131,8140],[8140,8131],[912,8147],[8147,912],[944,8163],[8163,944],[8179,8188],[8188,8179],[64261,64262],[64262,64261],[66560,66600],[66600,66560],[66561,66601],[66601,66561],[66562,66602],[66602,66562],[66563,66603],[66603,66563],[66564,66604],[66604,66564],[66565,66605],[66605,66565],[66566,66606],[66606,66566],[66567,66607],[66607,66567],[66568,66608],[66608,66568],[66569,66609],[66609,66569],[66570,66610],[66610,66570],[66571,66611],[66611,66571],[66572,66612],[66612,66572],[66573,66613],[66613,66573],[66574,66614],[66614,66574],[66575,66615],[66615,66575],[66576,66616],[66616,66576],[66577,66617],[66617,66577],[66578,66618],[66618,66578],[66579,66619],[66619,66579],[66580,66620],[66620,66580],[66581,66621],[66621,66581],[66582,66622],[66622,66582],[66583,66623],[66623,66583],[66584,66624],[66624,66584],[66585,66625],[66625,66585],[66586,66626],[66626,66586],[66587,66627],[66627,66587],[66588,66628],[66628,66588],[66589,66629],[66629,66589],[66590,66630],[66630,66590],[66591,66631],[66631,66591],[66592,66632],[66632,66592],[66593,66633],[66633,66593],[66594,66634],[66634,66594],[66595,66635],[66635,66595],[66596,66636],[66636,66596],[66597,66637],[66637,66597],[66598,66638],[66638,66598],[66599,66639],[66639,66599],[66736,66776],[66776,66736],[66737,66777],[66777,66737],[66738,66778],[66778,66738],[66739,66779],[66779,66739],[66740,66780],[66780,66740],[66741,66781],[66781,66741],[66742,66782],[66782,66742],[66743,66783],[66783,66743],[66744,66784],[66784,66744],[66745,66785],[66785,66745],[66746,66786],[66786,66746],[66747,66787],[66787,66747],[66748,66788],[66788,66748],[66749,66789],[66789,66749],[66750,66790],[66790,66750],[66751,66791],[66791,66751],[66752,66792],[66792,66752],[66753,66793],[66793,66753],[66754,66794],[66794,66754],[66755,66795],[66795,66755],[66756,66796],[66796,66756],[66757,66797],[66797,66757],[66758,66798],[66798,66758],[66759,66799],[66799,66759],[66760,66800],[66800,66760],[66761,66801],[66801,66761],[66762,66802],[66802,66762],[66763,66803],[66803,66763],[66764,66804],[66804,66764],[66765,66805],[66805,66765],[66766,66806],[66806,66766],[66767,66807],[66807,66767],[66768,66808],[66808,66768],[66769,66809],[66809,66769],[66770,66810],[66810,66770],[66771,66811],[66811,66771],[66928,66967],[66967,66928],[66929,66968],[66968,66929],[66930,66969],[66969,66930],[66931,66970],[66970,66931],[66932,66971],[66971,66932],[66933,66972],[66972,66933],[66934,66973],[66973,66934],[66935,66974],[66974,66935],[66936,66975],[66975,66936],[66937,66976],[66976,66937],[66938,66977],[66977,66938],[66940,66979],[66979,66940],[66941,66980],[66980,66941],[66942,66981],[66981,66942],[66943,66982],[66982,66943],[66944,66983],[66983,66944],[66945,66984],[66984,66945],[66946,66985],[66985,66946],[66947,66986],[66986,66947],[66948,66987],[66987,66948],[66949,66988],[66988,66949],[66950,66989],[66989,66950],[66951,66990],[66990,66951],[66952,66991],[66991,66952],[66953,66992],[66992,66953],[66954,66993],[66993,66954],[66956,66995],[66995,66956],[66957,66996],[66996,66957],[66958,66997],[66997,66958],[66959,66998],[66998,66959],[66960,66999],[66999,66960],[66961,67e3],[67e3,66961],[66962,67001],[67001,66962],[66964,67003],[67003,66964],[66965,67004],[67004,66965],[68736,68800],[68800,68736],[68737,68801],[68801,68737],[68738,68802],[68802,68738],[68739,68803],[68803,68739],[68740,68804],[68804,68740],[68741,68805],[68805,68741],[68742,68806],[68806,68742],[68743,68807],[68807,68743],[68744,68808],[68808,68744],[68745,68809],[68809,68745],[68746,68810],[68810,68746],[68747,68811],[68811,68747],[68748,68812],[68812,68748],[68749,68813],[68813,68749],[68750,68814],[68814,68750],[68751,68815],[68815,68751],[68752,68816],[68816,68752],[68753,68817],[68817,68753],[68754,68818],[68818,68754],[68755,68819],[68819,68755],[68756,68820],[68820,68756],[68757,68821],[68821,68757],[68758,68822],[68822,68758],[68759,68823],[68823,68759],[68760,68824],[68824,68760],[68761,68825],[68825,68761],[68762,68826],[68826,68762],[68763,68827],[68827,68763],[68764,68828],[68828,68764],[68765,68829],[68829,68765],[68766,68830],[68830,68766],[68767,68831],[68831,68767],[68768,68832],[68832,68768],[68769,68833],[68833,68769],[68770,68834],[68834,68770],[68771,68835],[68835,68771],[68772,68836],[68836,68772],[68773,68837],[68837,68773],[68774,68838],[68838,68774],[68775,68839],[68839,68775],[68776,68840],[68840,68776],[68777,68841],[68841,68777],[68778,68842],[68842,68778],[68779,68843],[68843,68779],[68780,68844],[68844,68780],[68781,68845],[68845,68781],[68782,68846],[68846,68782],[68783,68847],[68847,68783],[68784,68848],[68848,68784],[68785,68849],[68849,68785],[68786,68850],[68850,68786],[71840,71872],[71872,71840],[71841,71873],[71873,71841],[71842,71874],[71874,71842],[71843,71875],[71875,71843],[71844,71876],[71876,71844],[71845,71877],[71877,71845],[71846,71878],[71878,71846],[71847,71879],[71879,71847],[71848,71880],[71880,71848],[71849,71881],[71881,71849],[71850,71882],[71882,71850],[71851,71883],[71883,71851],[71852,71884],[71884,71852],[71853,71885],[71885,71853],[71854,71886],[71886,71854],[71855,71887],[71887,71855],[71856,71888],[71888,71856],[71857,71889],[71889,71857],[71858,71890],[71890,71858],[71859,71891],[71891,71859],[71860,71892],[71892,71860],[71861,71893],[71893,71861],[71862,71894],[71894,71862],[71863,71895],[71895,71863],[71864,71896],[71896,71864],[71865,71897],[71897,71865],[71866,71898],[71898,71866],[71867,71899],[71899,71867],[71868,71900],[71900,71868],[71869,71901],[71901,71869],[71870,71902],[71902,71870],[71871,71903],[71903,71871],[93760,93792],[93792,93760],[93761,93793],[93793,93761],[93762,93794],[93794,93762],[93763,93795],[93795,93763],[93764,93796],[93796,93764],[93765,93797],[93797,93765],[93766,93798],[93798,93766],[93767,93799],[93799,93767],[93768,93800],[93800,93768],[93769,93801],[93801,93769],[93770,93802],[93802,93770],[93771,93803],[93803,93771],[93772,93804],[93804,93772],[93773,93805],[93805,93773],[93774,93806],[93806,93774],[93775,93807],[93807,93775],[93776,93808],[93808,93776],[93777,93809],[93809,93777],[93778,93810],[93810,93778],[93779,93811],[93811,93779],[93780,93812],[93812,93780],[93781,93813],[93813,93781],[93782,93814],[93814,93782],[93783,93815],[93815,93783],[93784,93816],[93816,93784],[93785,93817],[93817,93785],[93786,93818],[93818,93786],[93787,93819],[93819,93787],[93788,93820],[93820,93788],[93789,93821],[93821,93789],[93790,93822],[93822,93790],[93791,93823],[93823,93791],[125184,125218],[125218,125184],[125185,125219],[125219,125185],[125186,125220],[125220,125186],[125187,125221],[125221,125187],[125188,125222],[125222,125188],[125189,125223],[125223,125189],[125190,125224],[125224,125190],[125191,125225],[125225,125191],[125192,125226],[125226,125192],[125193,125227],[125227,125193],[125194,125228],[125228,125194],[125195,125229],[125229,125195],[125196,125230],[125230,125196],[125197,125231],[125231,125197],[125198,125232],[125232,125198],[125199,125233],[125233,125199],[125200,125234],[125234,125200],[125201,125235],[125235,125201],[125202,125236],[125236,125202],[125203,125237],[125237,125203],[125204,125238],[125238,125204],[125205,125239],[125239,125205],[125206,125240],[125240,125206],[125207,125241],[125241,125207],[125208,125242],[125242,125208],[125209,125243],[125243,125209],[125210,125244],[125244,125210],[125211,125245],[125245,125211],[125212,125246],[125246,125212],[125213,125247],[125247,125213],[125214,125248],[125248,125214],[125215,125249],[125249,125215],[125216,125250],[125250,125216],[125217,125251],[125251,125217]]);static C=[[0,31,1],[127,159,1],[173,888,715],[889,896,7],[897,899,1],[907,909,2],[930,1328,398],[1367,1368,1],[1419,1420,1],[1424,1480,56],[1481,1487,1],[1515,1518,1],[1525,1541,1],[1564,1757,193],[1806,1807,1],[1867,1868,1],[1970,1983,1],[2043,2044,1],[2094,2095,1],[2111,2140,29],[2141,2143,2],[2155,2159,1],[2191,2199,1],[2274,2436,162],[2445,2446,1],[2449,2450,1],[2473,2481,8],[2483,2485,1],[2490,2491,1],[2501,2502,1],[2505,2506,1],[2511,2518,1],[2520,2523,1],[2526,2532,6],[2533,2559,26],[2560,2564,4],[2571,2574,1],[2577,2578,1],[2601,2609,8],[2612,2618,3],[2619,2621,2],[2627,2630,1],[2633,2634,1],[2638,2640,1],[2642,2648,1],[2653,2655,2],[2656,2661,1],[2679,2688,1],[2692,2702,10],[2706,2729,23],[2737,2740,3],[2746,2747,1],[2758,2766,4],[2767,2769,2],[2770,2783,1],[2788,2789,1],[2802,2808,1],[2816,2820,4],[2829,2830,1],[2833,2834,1],[2857,2865,8],[2868,2874,6],[2875,2885,10],[2886,2889,3],[2890,2894,4],[2895,2900,1],[2904,2907,1],[2910,2916,6],[2917,2936,19],[2937,2945,1],[2948,2955,7],[2956,2957,1],[2961,2966,5],[2967,2968,1],[2971,2973,2],[2976,2978,1],[2981,2983,1],[2987,2989,1],[3002,3005,1],[3011,3013,1],[3017,3022,5],[3023,3025,2],[3026,3030,1],[3032,3045,1],[3067,3071,1],[3085,3089,4],[3113,3130,17],[3131,3141,10],[3145,3150,5],[3151,3156,1],[3159,3163,4],[3164,3166,2],[3167,3172,5],[3173,3184,11],[3185,3190,1],[3213,3217,4],[3241,3252,11],[3258,3259,1],[3269,3273,4],[3278,3284,1],[3287,3292,1],[3295,3300,5],[3301,3312,11],[3316,3327,1],[3341,3345,4],[3397,3401,4],[3408,3411,1],[3428,3429,1],[3456,3460,4],[3479,3481,1],[3506,3516,10],[3518,3519,1],[3527,3529,1],[3531,3534,1],[3541,3543,2],[3552,3557,1],[3568,3569,1],[3573,3584,1],[3643,3646,1],[3676,3712,1],[3715,3717,2],[3723,3748,25],[3750,3774,24],[3775,3781,6],[3783,3791,8],[3802,3803,1],[3808,3839,1],[3912,3949,37],[3950,3952,1],[3992,4029,37],[4045,4059,14],[4060,4095,1],[4294,4296,2],[4297,4300,1],[4302,4303,1],[4681,4686,5],[4687,4695,8],[4697,4702,5],[4703,4745,42],[4750,4751,1],[4785,4790,5],[4791,4799,8],[4801,4806,5],[4807,4823,16],[4881,4886,5],[4887,4955,68],[4956,4989,33],[4990,4991,1],[5018,5023,1],[5110,5111,1],[5118,5119,1],[5789,5791,1],[5881,5887,1],[5910,5918,1],[5943,5951,1],[5972,5983,1],[5997,6001,4],[6004,6015,1],[6110,6111,1],[6122,6127,1],[6138,6143,1],[6158,6170,12],[6171,6175,1],[6265,6271,1],[6315,6319,1],[6390,6399,1],[6431,6444,13],[6445,6447,1],[6460,6463,1],[6465,6467,1],[6510,6511,1],[6517,6527,1],[6572,6575,1],[6602,6607,1],[6619,6621,1],[6684,6685,1],[6751,6781,30],[6782,6794,12],[6795,6799,1],[6810,6815,1],[6830,6831,1],[6863,6911,1],[6989,6991,1],[7039,7156,117],[7157,7163,1],[7224,7226,1],[7242,7244,1],[7305,7311,1],[7355,7356,1],[7368,7375,1],[7419,7423,1],[7958,7959,1],[7966,7967,1],[8006,8007,1],[8014,8015,1],[8024,8030,2],[8062,8063,1],[8117,8133,16],[8148,8149,1],[8156,8176,20],[8177,8181,4],[8191,8203,12],[8204,8207,1],[8234,8238,1],[8288,8303,1],[8306,8307,1],[8335,8349,14],[8350,8351,1],[8385,8399,1],[8433,8447,1],[8588,8591,1],[9255,9279,1],[9291,9311,1],[11124,11125,1],[11158,11508,350],[11509,11512,1],[11558,11560,2],[11561,11564,1],[11566,11567,1],[11624,11630,1],[11633,11646,1],[11671,11679,1],[11687,11743,8],[11870,11903,1],[11930,12020,90],[12021,12031,1],[12246,12271,1],[12352,12439,87],[12440,12544,104],[12545,12548,1],[12592,12687,95],[12772,12782,1],[12831,42125,29294],[42126,42127,1],[42183,42191,1],[42540,42559,1],[42744,42751,1],[42955,42959,1],[42962,42964,2],[42970,42993,1],[43053,43055,1],[43066,43071,1],[43128,43135,1],[43206,43213,1],[43226,43231,1],[43348,43358,1],[43389,43391,1],[43470,43482,12],[43483,43485,1],[43519,43575,56],[43576,43583,1],[43598,43599,1],[43610,43611,1],[43715,43738,1],[43767,43776,1],[43783,43784,1],[43791,43792,1],[43799,43807,1],[43815,43823,8],[43884,43887,1],[44014,44015,1],[44026,44031,1],[55204,55215,1],[55239,55242,1],[55292,63743,1],[64110,64111,1],[64218,64255,1],[64263,64274,1],[64280,64284,1],[64311,64317,6],[64319,64325,3],[64451,64466,1],[64912,64913,1],[64968,64974,1],[64976,65007,1],[65050,65055,1],[65107,65127,20],[65132,65135,1],[65141,65277,136],[65278,65280,1],[65471,65473,1],[65480,65481,1],[65488,65489,1],[65496,65497,1],[65501,65503,1],[65511,65519,8],[65520,65531,1],[65534,65535,1],[65548,65575,27],[65595,65598,3],[65614,65615,1],[65630,65663,1],[65787,65791,1],[65795,65798,1],[65844,65846,1],[65935,65949,14],[65950,65951,1],[65953,65999,1],[66046,66175,1],[66205,66207,1],[66257,66271,1],[66300,66303,1],[66340,66348,1],[66379,66383,1],[66427,66431,1],[66462,66500,38],[66501,66503,1],[66518,66559,1],[66718,66719,1],[66730,66735,1],[66772,66775,1],[66812,66815,1],[66856,66863,1],[66916,66926,1],[66939,66955,16],[66963,66966,3],[66978,66994,16],[67002,67005,3],[67006,67071,1],[67383,67391,1],[67414,67423,1],[67432,67455,1],[67462,67505,43],[67515,67583,1],[67590,67591,1],[67593,67638,45],[67641,67643,1],[67645,67646,1],[67670,67743,73],[67744,67750,1],[67760,67807,1],[67827,67830,3],[67831,67834,1],[67868,67870,1],[67898,67902,1],[67904,67967,1],[68024,68027,1],[68048,68049,1],[68100,68103,3],[68104,68107,1],[68116,68120,4],[68150,68151,1],[68155,68158,1],[68169,68175,1],[68185,68191,1],[68256,68287,1],[68327,68330,1],[68343,68351,1],[68406,68408,1],[68438,68439,1],[68467,68471,1],[68498,68504,1],[68509,68520,1],[68528,68607,1],[68681,68735,1],[68787,68799,1],[68851,68857,1],[68904,68911,1],[68922,69215,1],[69247,69290,43],[69294,69295,1],[69298,69372,1],[69416,69423,1],[69466,69487,1],[69514,69551,1],[69580,69599,1],[69623,69631,1],[69710,69713,1],[69750,69758,1],[69821,69827,6],[69828,69839,1],[69865,69871,1],[69882,69887,1],[69941,69960,19],[69961,69967,1],[70007,70015,1],[70112,70133,21],[70134,70143,1],[70162,70210,48],[70211,70271,1],[70279,70281,2],[70286,70302,16],[70314,70319,1],[70379,70383,1],[70394,70399,1],[70404,70413,9],[70414,70417,3],[70418,70441,23],[70449,70452,3],[70458,70469,11],[70470,70473,3],[70474,70478,4],[70479,70481,2],[70482,70486,1],[70488,70492,1],[70500,70501,1],[70509,70511,1],[70517,70655,1],[70748,70754,6],[70755,70783,1],[70856,70863,1],[70874,71039,1],[71094,71095,1],[71134,71167,1],[71237,71247,1],[71258,71263,1],[71277,71295,1],[71354,71359,1],[71370,71423,1],[71451,71452,1],[71468,71471,1],[71495,71679,1],[71740,71839,1],[71923,71934,1],[71943,71944,1],[71946,71947,1],[71956,71959,3],[71990,71993,3],[71994,72007,13],[72008,72015,1],[72026,72095,1],[72104,72105,1],[72152,72153,1],[72165,72191,1],[72264,72271,1],[72355,72367,1],[72441,72447,1],[72458,72703,1],[72713,72759,46],[72774,72783,1],[72813,72815,1],[72848,72849,1],[72872,72887,15],[72888,72959,1],[72967,72970,3],[73015,73017,1],[73019,73022,3],[73032,73039,1],[73050,73055,1],[73062,73065,3],[73103,73106,3],[73113,73119,1],[73130,73439,1],[73465,73471,1],[73489,73531,42],[73532,73533,1],[73562,73647,1],[73649,73663,1],[73714,73726,1],[74650,74751,1],[74863,74869,6],[74870,74879,1],[75076,77711,1],[77811,77823,1],[78896,78911,1],[78934,82943,1],[83527,92159,1],[92729,92735,1],[92767,92778,11],[92779,92781,1],[92863,92874,11],[92875,92879,1],[92910,92911,1],[92918,92927,1],[92998,93007,1],[93018,93026,8],[93048,93052,1],[93072,93759,1],[93851,93951,1],[94027,94030,1],[94088,94094,1],[94112,94175,1],[94181,94191,1],[94194,94207,1],[100344,100351,1],[101590,101631,1],[101641,110575,1],[110580,110588,8],[110591,110883,292],[110884,110897,1],[110899,110927,1],[110931,110932,1],[110934,110947,1],[110952,110959,1],[111356,113663,1],[113771,113775,1],[113789,113791,1],[113801,113807,1],[113818,113819,1],[113824,118527,1],[118574,118575,1],[118599,118607,1],[118724,118783,1],[119030,119039,1],[119079,119080,1],[119155,119162,1],[119275,119295,1],[119366,119487,1],[119508,119519,1],[119540,119551,1],[119639,119647,1],[119673,119807,1],[119893,119965,72],[119968,119969,1],[119971,119972,1],[119975,119976,1],[119981,119994,13],[119996,120004,8],[120070,120075,5],[120076,120085,9],[120093,120122,29],[120127,120133,6],[120135,120137,1],[120145,120486,341],[120487,120780,293],[120781,121484,703],[121485,121498,1],[121504,121520,16],[121521,122623,1],[122655,122660,1],[122667,122879,1],[122887,122905,18],[122906,122914,8],[122917,122923,6],[122924,122927,1],[122990,123022,1],[123024,123135,1],[123181,123183,1],[123198,123199,1],[123210,123213,1],[123216,123535,1],[123567,123583,1],[123642,123646,1],[123648,124111,1],[124154,124895,1],[124903,124908,5],[124911,124927,16],[125125,125126,1],[125143,125183,1],[125260,125263,1],[125274,125277,1],[125280,126064,1],[126133,126208,1],[126270,126463,1],[126468,126496,28],[126499,126501,2],[126502,126504,2],[126515,126520,5],[126522,126524,2],[126525,126529,1],[126531,126534,1],[126536,126540,2],[126544,126547,3],[126549,126550,1],[126552,126560,2],[126563,126565,2],[126566,126571,5],[126579,126589,5],[126591,126602,11],[126620,126624,1],[126628,126634,6],[126652,126703,1],[126706,126975,1],[127020,127023,1],[127124,127135,1],[127151,127152,1],[127168,127184,16],[127222,127231,1],[127406,127461,1],[127491,127503,1],[127548,127551,1],[127561,127567,1],[127570,127583,1],[127590,127743,1],[128728,128731,1],[128749,128751,1],[128765,128767,1],[128887,128890,1],[128986,128991,1],[129004,129007,1],[129009,129023,1],[129036,129039,1],[129096,129103,1],[129114,129119,1],[129160,129167,1],[129198,129199,1],[129202,129279,1],[129620,129631,1],[129646,129647,1],[129661,129663,1],[129673,129679,1],[129726,129734,8],[129735,129741,1],[129756,129759,1],[129769,129775,1],[129785,129791,1],[129939,129995,56],[129996,130031,1],[130042,131071,1],[173792,173823,1],[177978,177983,1],[178206,178207,1],[183970,183983,1],[191457,191471,1],[192094,194559,1],[195102,196607,1],[201547,201551,1],[205744,917759,1],[918e3,1114111,1]];static Cc=[[0,31,1],[127,159,1]];static Cf=[[173,1536,1363],[1537,1541,1],[1564,1757,193],[1807,2192,385],[2193,2274,81],[6158,8203,2045],[8204,8207,1],[8234,8238,1],[8288,8292,1],[8294,8303,1],[65279,65529,250],[65530,65531,1],[69821,69837,16],[78896,78911,1],[113824,113827,1],[119155,119162,1],[917505,917536,31],[917537,917631,1]];static Co=[[57344,63743,1],[983040,1048573,1],[1048576,1114109,1]];static Cs=[[55296,57343,1]];static L=[[65,90,1],[97,122,1],[170,181,11],[186,192,6],[193,214,1],[216,246,1],[248,705,1],[710,721,1],[736,740,1],[748,750,2],[880,884,1],[886,887,1],[890,893,1],[895,902,7],[904,906,1],[908,910,2],[911,929,1],[931,1013,1],[1015,1153,1],[1162,1327,1],[1329,1366,1],[1369,1376,7],[1377,1416,1],[1488,1514,1],[1519,1522,1],[1568,1610,1],[1646,1647,1],[1649,1747,1],[1749,1765,16],[1766,1774,8],[1775,1786,11],[1787,1788,1],[1791,1808,17],[1810,1839,1],[1869,1957,1],[1969,1994,25],[1995,2026,1],[2036,2037,1],[2042,2048,6],[2049,2069,1],[2074,2084,10],[2088,2112,24],[2113,2136,1],[2144,2154,1],[2160,2183,1],[2185,2190,1],[2208,2249,1],[2308,2361,1],[2365,2384,19],[2392,2401,1],[2417,2432,1],[2437,2444,1],[2447,2448,1],[2451,2472,1],[2474,2480,1],[2482,2486,4],[2487,2489,1],[2493,2510,17],[2524,2525,1],[2527,2529,1],[2544,2545,1],[2556,2565,9],[2566,2570,1],[2575,2576,1],[2579,2600,1],[2602,2608,1],[2610,2611,1],[2613,2614,1],[2616,2617,1],[2649,2652,1],[2654,2674,20],[2675,2676,1],[2693,2701,1],[2703,2705,1],[2707,2728,1],[2730,2736,1],[2738,2739,1],[2741,2745,1],[2749,2768,19],[2784,2785,1],[2809,2821,12],[2822,2828,1],[2831,2832,1],[2835,2856,1],[2858,2864,1],[2866,2867,1],[2869,2873,1],[2877,2908,31],[2909,2911,2],[2912,2913,1],[2929,2947,18],[2949,2954,1],[2958,2960,1],[2962,2965,1],[2969,2970,1],[2972,2974,2],[2975,2979,4],[2980,2984,4],[2985,2986,1],[2990,3001,1],[3024,3077,53],[3078,3084,1],[3086,3088,1],[3090,3112,1],[3114,3129,1],[3133,3160,27],[3161,3162,1],[3165,3168,3],[3169,3200,31],[3205,3212,1],[3214,3216,1],[3218,3240,1],[3242,3251,1],[3253,3257,1],[3261,3293,32],[3294,3296,2],[3297,3313,16],[3314,3332,18],[3333,3340,1],[3342,3344,1],[3346,3386,1],[3389,3406,17],[3412,3414,1],[3423,3425,1],[3450,3455,1],[3461,3478,1],[3482,3505,1],[3507,3515,1],[3517,3520,3],[3521,3526,1],[3585,3632,1],[3634,3635,1],[3648,3654,1],[3713,3714,1],[3716,3718,2],[3719,3722,1],[3724,3747,1],[3749,3751,2],[3752,3760,1],[3762,3763,1],[3773,3776,3],[3777,3780,1],[3782,3804,22],[3805,3807,1],[3840,3904,64],[3905,3911,1],[3913,3948,1],[3976,3980,1],[4096,4138,1],[4159,4176,17],[4177,4181,1],[4186,4189,1],[4193,4197,4],[4198,4206,8],[4207,4208,1],[4213,4225,1],[4238,4256,18],[4257,4293,1],[4295,4301,6],[4304,4346,1],[4348,4680,1],[4682,4685,1],[4688,4694,1],[4696,4698,2],[4699,4701,1],[4704,4744,1],[4746,4749,1],[4752,4784,1],[4786,4789,1],[4792,4798,1],[4800,4802,2],[4803,4805,1],[4808,4822,1],[4824,4880,1],[4882,4885,1],[4888,4954,1],[4992,5007,1],[5024,5109,1],[5112,5117,1],[5121,5740,1],[5743,5759,1],[5761,5786,1],[5792,5866,1],[5873,5880,1],[5888,5905,1],[5919,5937,1],[5952,5969,1],[5984,5996,1],[5998,6e3,1],[6016,6067,1],[6103,6108,5],[6176,6264,1],[6272,6276,1],[6279,6312,1],[6314,6320,6],[6321,6389,1],[6400,6430,1],[6480,6509,1],[6512,6516,1],[6528,6571,1],[6576,6601,1],[6656,6678,1],[6688,6740,1],[6823,6917,94],[6918,6963,1],[6981,6988,1],[7043,7072,1],[7086,7087,1],[7098,7141,1],[7168,7203,1],[7245,7247,1],[7258,7293,1],[7296,7304,1],[7312,7354,1],[7357,7359,1],[7401,7404,1],[7406,7411,1],[7413,7414,1],[7418,7424,6],[7425,7615,1],[7680,7957,1],[7960,7965,1],[7968,8005,1],[8008,8013,1],[8016,8023,1],[8025,8031,2],[8032,8061,1],[8064,8116,1],[8118,8124,1],[8126,8130,4],[8131,8132,1],[8134,8140,1],[8144,8147,1],[8150,8155,1],[8160,8172,1],[8178,8180,1],[8182,8188,1],[8305,8319,14],[8336,8348,1],[8450,8455,5],[8458,8467,1],[8469,8473,4],[8474,8477,1],[8484,8490,2],[8491,8493,1],[8495,8505,1],[8508,8511,1],[8517,8521,1],[8526,8579,53],[8580,11264,2684],[11265,11492,1],[11499,11502,1],[11506,11507,1],[11520,11557,1],[11559,11565,6],[11568,11623,1],[11631,11648,17],[11649,11670,1],[11680,11686,1],[11688,11694,1],[11696,11702,1],[11704,11710,1],[11712,11718,1],[11720,11726,1],[11728,11734,1],[11736,11742,1],[11823,12293,470],[12294,12337,43],[12338,12341,1],[12347,12348,1],[12353,12438,1],[12445,12447,1],[12449,12538,1],[12540,12543,1],[12549,12591,1],[12593,12686,1],[12704,12735,1],[12784,12799,1],[13312,19903,1],[19968,42124,1],[42192,42237,1],[42240,42508,1],[42512,42527,1],[42538,42539,1],[42560,42606,1],[42623,42653,1],[42656,42725,1],[42775,42783,1],[42786,42888,1],[42891,42954,1],[42960,42961,1],[42963,42965,2],[42966,42969,1],[42994,43009,1],[43011,43013,1],[43015,43018,1],[43020,43042,1],[43072,43123,1],[43138,43187,1],[43250,43255,1],[43259,43261,2],[43262,43274,12],[43275,43301,1],[43312,43334,1],[43360,43388,1],[43396,43442,1],[43471,43488,17],[43489,43492,1],[43494,43503,1],[43514,43518,1],[43520,43560,1],[43584,43586,1],[43588,43595,1],[43616,43638,1],[43642,43646,4],[43647,43695,1],[43697,43701,4],[43702,43705,3],[43706,43709,1],[43712,43714,2],[43739,43741,1],[43744,43754,1],[43762,43764,1],[43777,43782,1],[43785,43790,1],[43793,43798,1],[43808,43814,1],[43816,43822,1],[43824,43866,1],[43868,43881,1],[43888,44002,1],[44032,55203,1],[55216,55238,1],[55243,55291,1],[63744,64109,1],[64112,64217,1],[64256,64262,1],[64275,64279,1],[64285,64287,2],[64288,64296,1],[64298,64310,1],[64312,64316,1],[64318,64320,2],[64321,64323,2],[64324,64326,2],[64327,64433,1],[64467,64829,1],[64848,64911,1],[64914,64967,1],[65008,65019,1],[65136,65140,1],[65142,65276,1],[65313,65338,1],[65345,65370,1],[65382,65470,1],[65474,65479,1],[65482,65487,1],[65490,65495,1],[65498,65500,1],[65536,65547,1],[65549,65574,1],[65576,65594,1],[65596,65597,1],[65599,65613,1],[65616,65629,1],[65664,65786,1],[66176,66204,1],[66208,66256,1],[66304,66335,1],[66349,66368,1],[66370,66377,1],[66384,66421,1],[66432,66461,1],[66464,66499,1],[66504,66511,1],[66560,66717,1],[66736,66771,1],[66776,66811,1],[66816,66855,1],[66864,66915,1],[66928,66938,1],[66940,66954,1],[66956,66962,1],[66964,66965,1],[66967,66977,1],[66979,66993,1],[66995,67001,1],[67003,67004,1],[67072,67382,1],[67392,67413,1],[67424,67431,1],[67456,67461,1],[67463,67504,1],[67506,67514,1],[67584,67589,1],[67592,67594,2],[67595,67637,1],[67639,67640,1],[67644,67647,3],[67648,67669,1],[67680,67702,1],[67712,67742,1],[67808,67826,1],[67828,67829,1],[67840,67861,1],[67872,67897,1],[67968,68023,1],[68030,68031,1],[68096,68112,16],[68113,68115,1],[68117,68119,1],[68121,68149,1],[68192,68220,1],[68224,68252,1],[68288,68295,1],[68297,68324,1],[68352,68405,1],[68416,68437,1],[68448,68466,1],[68480,68497,1],[68608,68680,1],[68736,68786,1],[68800,68850,1],[68864,68899,1],[69248,69289,1],[69296,69297,1],[69376,69404,1],[69415,69424,9],[69425,69445,1],[69488,69505,1],[69552,69572,1],[69600,69622,1],[69635,69687,1],[69745,69746,1],[69749,69763,14],[69764,69807,1],[69840,69864,1],[69891,69926,1],[69956,69959,3],[69968,70002,1],[70006,70019,13],[70020,70066,1],[70081,70084,1],[70106,70108,2],[70144,70161,1],[70163,70187,1],[70207,70208,1],[70272,70278,1],[70280,70282,2],[70283,70285,1],[70287,70301,1],[70303,70312,1],[70320,70366,1],[70405,70412,1],[70415,70416,1],[70419,70440,1],[70442,70448,1],[70450,70451,1],[70453,70457,1],[70461,70480,19],[70493,70497,1],[70656,70708,1],[70727,70730,1],[70751,70753,1],[70784,70831,1],[70852,70853,1],[70855,71040,185],[71041,71086,1],[71128,71131,1],[71168,71215,1],[71236,71296,60],[71297,71338,1],[71352,71424,72],[71425,71450,1],[71488,71494,1],[71680,71723,1],[71840,71903,1],[71935,71942,1],[71945,71948,3],[71949,71955,1],[71957,71958,1],[71960,71983,1],[71999,72001,2],[72096,72103,1],[72106,72144,1],[72161,72163,2],[72192,72203,11],[72204,72242,1],[72250,72272,22],[72284,72329,1],[72349,72368,19],[72369,72440,1],[72704,72712,1],[72714,72750,1],[72768,72818,50],[72819,72847,1],[72960,72966,1],[72968,72969,1],[72971,73008,1],[73030,73056,26],[73057,73061,1],[73063,73064,1],[73066,73097,1],[73112,73440,328],[73441,73458,1],[73474,73476,2],[73477,73488,1],[73490,73523,1],[73648,73728,80],[73729,74649,1],[74880,75075,1],[77712,77808,1],[77824,78895,1],[78913,78918,1],[82944,83526,1],[92160,92728,1],[92736,92766,1],[92784,92862,1],[92880,92909,1],[92928,92975,1],[92992,92995,1],[93027,93047,1],[93053,93071,1],[93760,93823,1],[93952,94026,1],[94032,94099,67],[94100,94111,1],[94176,94177,1],[94179,94208,29],[94209,100343,1],[100352,101589,1],[101632,101640,1],[110576,110579,1],[110581,110587,1],[110589,110590,1],[110592,110882,1],[110898,110928,30],[110929,110930,1],[110933,110948,15],[110949,110951,1],[110960,111355,1],[113664,113770,1],[113776,113788,1],[113792,113800,1],[113808,113817,1],[119808,119892,1],[119894,119964,1],[119966,119967,1],[119970,119973,3],[119974,119977,3],[119978,119980,1],[119982,119993,1],[119995,119997,2],[119998,120003,1],[120005,120069,1],[120071,120074,1],[120077,120084,1],[120086,120092,1],[120094,120121,1],[120123,120126,1],[120128,120132,1],[120134,120138,4],[120139,120144,1],[120146,120485,1],[120488,120512,1],[120514,120538,1],[120540,120570,1],[120572,120596,1],[120598,120628,1],[120630,120654,1],[120656,120686,1],[120688,120712,1],[120714,120744,1],[120746,120770,1],[120772,120779,1],[122624,122654,1],[122661,122666,1],[122928,122989,1],[123136,123180,1],[123191,123197,1],[123214,123536,322],[123537,123565,1],[123584,123627,1],[124112,124139,1],[124896,124902,1],[124904,124907,1],[124909,124910,1],[124912,124926,1],[124928,125124,1],[125184,125251,1],[125259,126464,1205],[126465,126467,1],[126469,126495,1],[126497,126498,1],[126500,126503,3],[126505,126514,1],[126516,126519,1],[126521,126523,2],[126530,126535,5],[126537,126541,2],[126542,126543,1],[126545,126546,1],[126548,126551,3],[126553,126561,2],[126562,126564,2],[126567,126570,1],[126572,126578,1],[126580,126583,1],[126585,126588,1],[126590,126592,2],[126593,126601,1],[126603,126619,1],[126625,126627,1],[126629,126633,1],[126635,126651,1],[131072,173791,1],[173824,177977,1],[177984,178205,1],[178208,183969,1],[183984,191456,1],[191472,192093,1],[194560,195101,1],[196608,201546,1],[201552,205743,1]];static foldL=[[837,837,1]];static Ll=[[97,122,1],[181,223,42],[224,246,1],[248,255,1],[257,311,2],[312,328,2],[329,375,2],[378,382,2],[383,384,1],[387,389,2],[392,396,4],[397,402,5],[405,409,4],[410,411,1],[414,417,3],[419,421,2],[424,426,2],[427,429,2],[432,436,4],[438,441,3],[442,445,3],[446,447,1],[454,460,3],[462,476,2],[477,495,2],[496,499,3],[501,505,4],[507,563,2],[564,569,1],[572,575,3],[576,578,2],[583,591,2],[592,659,1],[661,687,1],[881,883,2],[887,891,4],[892,893,1],[912,940,28],[941,974,1],[976,977,1],[981,983,1],[985,1007,2],[1008,1011,1],[1013,1019,3],[1020,1072,52],[1073,1119,1],[1121,1153,2],[1163,1215,2],[1218,1230,2],[1231,1327,2],[1376,1416,1],[4304,4346,1],[4349,4351,1],[5112,5117,1],[7296,7304,1],[7424,7467,1],[7531,7543,1],[7545,7578,1],[7681,7829,2],[7830,7837,1],[7839,7935,2],[7936,7943,1],[7952,7957,1],[7968,7975,1],[7984,7991,1],[8e3,8005,1],[8016,8023,1],[8032,8039,1],[8048,8061,1],[8064,8071,1],[8080,8087,1],[8096,8103,1],[8112,8116,1],[8118,8119,1],[8126,8130,4],[8131,8132,1],[8134,8135,1],[8144,8147,1],[8150,8151,1],[8160,8167,1],[8178,8180,1],[8182,8183,1],[8458,8462,4],[8463,8467,4],[8495,8505,5],[8508,8509,1],[8518,8521,1],[8526,8580,54],[11312,11359,1],[11361,11365,4],[11366,11372,2],[11377,11379,2],[11380,11382,2],[11383,11387,1],[11393,11491,2],[11492,11500,8],[11502,11507,5],[11520,11557,1],[11559,11565,6],[42561,42605,2],[42625,42651,2],[42787,42799,2],[42800,42801,1],[42803,42865,2],[42866,42872,1],[42874,42876,2],[42879,42887,2],[42892,42894,2],[42897,42899,2],[42900,42901,1],[42903,42921,2],[42927,42933,6],[42935,42947,2],[42952,42954,2],[42961,42969,2],[42998,43002,4],[43824,43866,1],[43872,43880,1],[43888,43967,1],[64256,64262,1],[64275,64279,1],[65345,65370,1],[66600,66639,1],[66776,66811,1],[66967,66977,1],[66979,66993,1],[66995,67001,1],[67003,67004,1],[68800,68850,1],[71872,71903,1],[93792,93823,1],[119834,119859,1],[119886,119892,1],[119894,119911,1],[119938,119963,1],[119990,119993,1],[119995,119997,2],[119998,120003,1],[120005,120015,1],[120042,120067,1],[120094,120119,1],[120146,120171,1],[120198,120223,1],[120250,120275,1],[120302,120327,1],[120354,120379,1],[120406,120431,1],[120458,120485,1],[120514,120538,1],[120540,120545,1],[120572,120596,1],[120598,120603,1],[120630,120654,1],[120656,120661,1],[120688,120712,1],[120714,120719,1],[120746,120770,1],[120772,120777,1],[120779,122624,1845],[122625,122633,1],[122635,122654,1],[122661,122666,1],[125218,125251,1]];static foldLl=[[65,90,1],[192,214,1],[216,222,1],[256,302,2],[306,310,2],[313,327,2],[330,376,2],[377,381,2],[385,386,1],[388,390,2],[391,393,2],[394,395,1],[398,401,1],[403,404,1],[406,408,1],[412,413,1],[415,416,1],[418,422,2],[423,425,2],[428,430,2],[431,433,2],[434,435,1],[437,439,2],[440,444,4],[452,453,1],[455,456,1],[458,459,1],[461,475,2],[478,494,2],[497,498,1],[500,502,2],[503,504,1],[506,562,2],[570,571,1],[573,574,1],[577,579,2],[580,582,1],[584,590,2],[837,880,43],[882,886,4],[895,902,7],[904,906,1],[908,910,2],[911,913,2],[914,929,1],[931,939,1],[975,984,9],[986,1006,2],[1012,1015,3],[1017,1018,1],[1021,1071,1],[1120,1152,2],[1162,1216,2],[1217,1229,2],[1232,1326,2],[1329,1366,1],[4256,4293,1],[4295,4301,6],[5024,5109,1],[7312,7354,1],[7357,7359,1],[7680,7828,2],[7838,7934,2],[7944,7951,1],[7960,7965,1],[7976,7983,1],[7992,7999,1],[8008,8013,1],[8025,8031,2],[8040,8047,1],[8072,8079,1],[8088,8095,1],[8104,8111,1],[8120,8124,1],[8136,8140,1],[8152,8155,1],[8168,8172,1],[8184,8188,1],[8486,8490,4],[8491,8498,7],[8579,11264,2685],[11265,11311,1],[11360,11362,2],[11363,11364,1],[11367,11373,2],[11374,11376,1],[11378,11381,3],[11390,11392,1],[11394,11490,2],[11499,11501,2],[11506,42560,31054],[42562,42604,2],[42624,42650,2],[42786,42798,2],[42802,42862,2],[42873,42877,2],[42878,42886,2],[42891,42893,2],[42896,42898,2],[42902,42922,2],[42923,42926,1],[42928,42932,1],[42934,42948,2],[42949,42951,1],[42953,42960,7],[42966,42968,2],[42997,65313,22316],[65314,65338,1],[66560,66599,1],[66736,66771,1],[66928,66938,1],[66940,66954,1],[66956,66962,1],[66964,66965,1],[68736,68786,1],[71840,71871,1],[93760,93791,1],[125184,125217,1]];static Lm=[[688,705,1],[710,721,1],[736,740,1],[748,750,2],[884,890,6],[1369,1600,231],[1765,1766,1],[2036,2037,1],[2042,2074,32],[2084,2088,4],[2249,2417,168],[3654,3782,128],[4348,6103,1755],[6211,6823,612],[7288,7293,1],[7468,7530,1],[7544,7579,35],[7580,7615,1],[8305,8319,14],[8336,8348,1],[11388,11389,1],[11631,11823,192],[12293,12337,44],[12338,12341,1],[12347,12445,98],[12446,12540,94],[12541,12542,1],[40981,42232,1251],[42233,42237,1],[42508,42623,115],[42652,42653,1],[42775,42783,1],[42864,42888,24],[42994,42996,1],[43e3,43001,1],[43471,43494,23],[43632,43741,109],[43763,43764,1],[43868,43871,1],[43881,65392,21511],[65438,65439,1],[67456,67461,1],[67463,67504,1],[67506,67514,1],[92992,92995,1],[94099,94111,1],[94176,94177,1],[94179,110576,16397],[110577,110579,1],[110581,110587,1],[110589,110590,1],[122928,122989,1],[123191,123197,1],[124139,125259,1120]];static Lo=[[170,186,16],[443,448,5],[449,451,1],[660,1488,828],[1489,1514,1],[1519,1522,1],[1568,1599,1],[1601,1610,1],[1646,1647,1],[1649,1747,1],[1749,1774,25],[1775,1786,11],[1787,1788,1],[1791,1808,17],[1810,1839,1],[1869,1957,1],[1969,1994,25],[1995,2026,1],[2048,2069,1],[2112,2136,1],[2144,2154,1],[2160,2183,1],[2185,2190,1],[2208,2248,1],[2308,2361,1],[2365,2384,19],[2392,2401,1],[2418,2432,1],[2437,2444,1],[2447,2448,1],[2451,2472,1],[2474,2480,1],[2482,2486,4],[2487,2489,1],[2493,2510,17],[2524,2525,1],[2527,2529,1],[2544,2545,1],[2556,2565,9],[2566,2570,1],[2575,2576,1],[2579,2600,1],[2602,2608,1],[2610,2611,1],[2613,2614,1],[2616,2617,1],[2649,2652,1],[2654,2674,20],[2675,2676,1],[2693,2701,1],[2703,2705,1],[2707,2728,1],[2730,2736,1],[2738,2739,1],[2741,2745,1],[2749,2768,19],[2784,2785,1],[2809,2821,12],[2822,2828,1],[2831,2832,1],[2835,2856,1],[2858,2864,1],[2866,2867,1],[2869,2873,1],[2877,2908,31],[2909,2911,2],[2912,2913,1],[2929,2947,18],[2949,2954,1],[2958,2960,1],[2962,2965,1],[2969,2970,1],[2972,2974,2],[2975,2979,4],[2980,2984,4],[2985,2986,1],[2990,3001,1],[3024,3077,53],[3078,3084,1],[3086,3088,1],[3090,3112,1],[3114,3129,1],[3133,3160,27],[3161,3162,1],[3165,3168,3],[3169,3200,31],[3205,3212,1],[3214,3216,1],[3218,3240,1],[3242,3251,1],[3253,3257,1],[3261,3293,32],[3294,3296,2],[3297,3313,16],[3314,3332,18],[3333,3340,1],[3342,3344,1],[3346,3386,1],[3389,3406,17],[3412,3414,1],[3423,3425,1],[3450,3455,1],[3461,3478,1],[3482,3505,1],[3507,3515,1],[3517,3520,3],[3521,3526,1],[3585,3632,1],[3634,3635,1],[3648,3653,1],[3713,3714,1],[3716,3718,2],[3719,3722,1],[3724,3747,1],[3749,3751,2],[3752,3760,1],[3762,3763,1],[3773,3776,3],[3777,3780,1],[3804,3807,1],[3840,3904,64],[3905,3911,1],[3913,3948,1],[3976,3980,1],[4096,4138,1],[4159,4176,17],[4177,4181,1],[4186,4189,1],[4193,4197,4],[4198,4206,8],[4207,4208,1],[4213,4225,1],[4238,4352,114],[4353,4680,1],[4682,4685,1],[4688,4694,1],[4696,4698,2],[4699,4701,1],[4704,4744,1],[4746,4749,1],[4752,4784,1],[4786,4789,1],[4792,4798,1],[4800,4802,2],[4803,4805,1],[4808,4822,1],[4824,4880,1],[4882,4885,1],[4888,4954,1],[4992,5007,1],[5121,5740,1],[5743,5759,1],[5761,5786,1],[5792,5866,1],[5873,5880,1],[5888,5905,1],[5919,5937,1],[5952,5969,1],[5984,5996,1],[5998,6e3,1],[6016,6067,1],[6108,6176,68],[6177,6210,1],[6212,6264,1],[6272,6276,1],[6279,6312,1],[6314,6320,6],[6321,6389,1],[6400,6430,1],[6480,6509,1],[6512,6516,1],[6528,6571,1],[6576,6601,1],[6656,6678,1],[6688,6740,1],[6917,6963,1],[6981,6988,1],[7043,7072,1],[7086,7087,1],[7098,7141,1],[7168,7203,1],[7245,7247,1],[7258,7287,1],[7401,7404,1],[7406,7411,1],[7413,7414,1],[7418,8501,1083],[8502,8504,1],[11568,11623,1],[11648,11670,1],[11680,11686,1],[11688,11694,1],[11696,11702,1],[11704,11710,1],[11712,11718,1],[11720,11726,1],[11728,11734,1],[11736,11742,1],[12294,12348,54],[12353,12438,1],[12447,12449,2],[12450,12538,1],[12543,12549,6],[12550,12591,1],[12593,12686,1],[12704,12735,1],[12784,12799,1],[13312,19903,1],[19968,40980,1],[40982,42124,1],[42192,42231,1],[42240,42507,1],[42512,42527,1],[42538,42539,1],[42606,42656,50],[42657,42725,1],[42895,42999,104],[43003,43009,1],[43011,43013,1],[43015,43018,1],[43020,43042,1],[43072,43123,1],[43138,43187,1],[43250,43255,1],[43259,43261,2],[43262,43274,12],[43275,43301,1],[43312,43334,1],[43360,43388,1],[43396,43442,1],[43488,43492,1],[43495,43503,1],[43514,43518,1],[43520,43560,1],[43584,43586,1],[43588,43595,1],[43616,43631,1],[43633,43638,1],[43642,43646,4],[43647,43695,1],[43697,43701,4],[43702,43705,3],[43706,43709,1],[43712,43714,2],[43739,43740,1],[43744,43754,1],[43762,43777,15],[43778,43782,1],[43785,43790,1],[43793,43798,1],[43808,43814,1],[43816,43822,1],[43968,44002,1],[44032,55203,1],[55216,55238,1],[55243,55291,1],[63744,64109,1],[64112,64217,1],[64285,64287,2],[64288,64296,1],[64298,64310,1],[64312,64316,1],[64318,64320,2],[64321,64323,2],[64324,64326,2],[64327,64433,1],[64467,64829,1],[64848,64911,1],[64914,64967,1],[65008,65019,1],[65136,65140,1],[65142,65276,1],[65382,65391,1],[65393,65437,1],[65440,65470,1],[65474,65479,1],[65482,65487,1],[65490,65495,1],[65498,65500,1],[65536,65547,1],[65549,65574,1],[65576,65594,1],[65596,65597,1],[65599,65613,1],[65616,65629,1],[65664,65786,1],[66176,66204,1],[66208,66256,1],[66304,66335,1],[66349,66368,1],[66370,66377,1],[66384,66421,1],[66432,66461,1],[66464,66499,1],[66504,66511,1],[66640,66717,1],[66816,66855,1],[66864,66915,1],[67072,67382,1],[67392,67413,1],[67424,67431,1],[67584,67589,1],[67592,67594,2],[67595,67637,1],[67639,67640,1],[67644,67647,3],[67648,67669,1],[67680,67702,1],[67712,67742,1],[67808,67826,1],[67828,67829,1],[67840,67861,1],[67872,67897,1],[67968,68023,1],[68030,68031,1],[68096,68112,16],[68113,68115,1],[68117,68119,1],[68121,68149,1],[68192,68220,1],[68224,68252,1],[68288,68295,1],[68297,68324,1],[68352,68405,1],[68416,68437,1],[68448,68466,1],[68480,68497,1],[68608,68680,1],[68864,68899,1],[69248,69289,1],[69296,69297,1],[69376,69404,1],[69415,69424,9],[69425,69445,1],[69488,69505,1],[69552,69572,1],[69600,69622,1],[69635,69687,1],[69745,69746,1],[69749,69763,14],[69764,69807,1],[69840,69864,1],[69891,69926,1],[69956,69959,3],[69968,70002,1],[70006,70019,13],[70020,70066,1],[70081,70084,1],[70106,70108,2],[70144,70161,1],[70163,70187,1],[70207,70208,1],[70272,70278,1],[70280,70282,2],[70283,70285,1],[70287,70301,1],[70303,70312,1],[70320,70366,1],[70405,70412,1],[70415,70416,1],[70419,70440,1],[70442,70448,1],[70450,70451,1],[70453,70457,1],[70461,70480,19],[70493,70497,1],[70656,70708,1],[70727,70730,1],[70751,70753,1],[70784,70831,1],[70852,70853,1],[70855,71040,185],[71041,71086,1],[71128,71131,1],[71168,71215,1],[71236,71296,60],[71297,71338,1],[71352,71424,72],[71425,71450,1],[71488,71494,1],[71680,71723,1],[71935,71942,1],[71945,71948,3],[71949,71955,1],[71957,71958,1],[71960,71983,1],[71999,72001,2],[72096,72103,1],[72106,72144,1],[72161,72163,2],[72192,72203,11],[72204,72242,1],[72250,72272,22],[72284,72329,1],[72349,72368,19],[72369,72440,1],[72704,72712,1],[72714,72750,1],[72768,72818,50],[72819,72847,1],[72960,72966,1],[72968,72969,1],[72971,73008,1],[73030,73056,26],[73057,73061,1],[73063,73064,1],[73066,73097,1],[73112,73440,328],[73441,73458,1],[73474,73476,2],[73477,73488,1],[73490,73523,1],[73648,73728,80],[73729,74649,1],[74880,75075,1],[77712,77808,1],[77824,78895,1],[78913,78918,1],[82944,83526,1],[92160,92728,1],[92736,92766,1],[92784,92862,1],[92880,92909,1],[92928,92975,1],[93027,93047,1],[93053,93071,1],[93952,94026,1],[94032,94208,176],[94209,100343,1],[100352,101589,1],[101632,101640,1],[110592,110882,1],[110898,110928,30],[110929,110930,1],[110933,110948,15],[110949,110951,1],[110960,111355,1],[113664,113770,1],[113776,113788,1],[113792,113800,1],[113808,113817,1],[122634,123136,502],[123137,123180,1],[123214,123536,322],[123537,123565,1],[123584,123627,1],[124112,124138,1],[124896,124902,1],[124904,124907,1],[124909,124910,1],[124912,124926,1],[124928,125124,1],[126464,126467,1],[126469,126495,1],[126497,126498,1],[126500,126503,3],[126505,126514,1],[126516,126519,1],[126521,126523,2],[126530,126535,5],[126537,126541,2],[126542,126543,1],[126545,126546,1],[126548,126551,3],[126553,126561,2],[126562,126564,2],[126567,126570,1],[126572,126578,1],[126580,126583,1],[126585,126588,1],[126590,126592,2],[126593,126601,1],[126603,126619,1],[126625,126627,1],[126629,126633,1],[126635,126651,1],[131072,173791,1],[173824,177977,1],[177984,178205,1],[178208,183969,1],[183984,191456,1],[191472,192093,1],[194560,195101,1],[196608,201546,1],[201552,205743,1]];static Lt=[[453,459,3],[498,8072,7574],[8073,8079,1],[8088,8095,1],[8104,8111,1],[8124,8140,16],[8188,8188,1]];static foldLt=[[452,454,2],[455,457,2],[458,460,2],[497,499,2],[8064,8071,1],[8080,8087,1],[8096,8103,1],[8115,8131,16],[8179,8179,1]];static Lu=[[65,90,1],[192,214,1],[216,222,1],[256,310,2],[313,327,2],[330,376,2],[377,381,2],[385,386,1],[388,390,2],[391,393,2],[394,395,1],[398,401,1],[403,404,1],[406,408,1],[412,413,1],[415,416,1],[418,422,2],[423,425,2],[428,430,2],[431,433,2],[434,435,1],[437,439,2],[440,444,4],[452,461,3],[463,475,2],[478,494,2],[497,500,3],[502,504,1],[506,562,2],[570,571,1],[573,574,1],[577,579,2],[580,582,1],[584,590,2],[880,882,2],[886,895,9],[902,904,2],[905,906,1],[908,910,2],[911,913,2],[914,929,1],[931,939,1],[975,978,3],[979,980,1],[984,1006,2],[1012,1015,3],[1017,1018,1],[1021,1071,1],[1120,1152,2],[1162,1216,2],[1217,1229,2],[1232,1326,2],[1329,1366,1],[4256,4293,1],[4295,4301,6],[5024,5109,1],[7312,7354,1],[7357,7359,1],[7680,7828,2],[7838,7934,2],[7944,7951,1],[7960,7965,1],[7976,7983,1],[7992,7999,1],[8008,8013,1],[8025,8031,2],[8040,8047,1],[8120,8123,1],[8136,8139,1],[8152,8155,1],[8168,8172,1],[8184,8187,1],[8450,8455,5],[8459,8461,1],[8464,8466,1],[8469,8473,4],[8474,8477,1],[8484,8490,2],[8491,8493,1],[8496,8499,1],[8510,8511,1],[8517,8579,62],[11264,11311,1],[11360,11362,2],[11363,11364,1],[11367,11373,2],[11374,11376,1],[11378,11381,3],[11390,11392,1],[11394,11490,2],[11499,11501,2],[11506,42560,31054],[42562,42604,2],[42624,42650,2],[42786,42798,2],[42802,42862,2],[42873,42877,2],[42878,42886,2],[42891,42893,2],[42896,42898,2],[42902,42922,2],[42923,42926,1],[42928,42932,1],[42934,42948,2],[42949,42951,1],[42953,42960,7],[42966,42968,2],[42997,65313,22316],[65314,65338,1],[66560,66599,1],[66736,66771,1],[66928,66938,1],[66940,66954,1],[66956,66962,1],[66964,66965,1],[68736,68786,1],[71840,71871,1],[93760,93791,1],[119808,119833,1],[119860,119885,1],[119912,119937,1],[119964,119966,2],[119967,119973,3],[119974,119977,3],[119978,119980,1],[119982,119989,1],[120016,120041,1],[120068,120069,1],[120071,120074,1],[120077,120084,1],[120086,120092,1],[120120,120121,1],[120123,120126,1],[120128,120132,1],[120134,120138,4],[120139,120144,1],[120172,120197,1],[120224,120249,1],[120276,120301,1],[120328,120353,1],[120380,120405,1],[120432,120457,1],[120488,120512,1],[120546,120570,1],[120604,120628,1],[120662,120686,1],[120720,120744,1],[120778,125184,4406],[125185,125217,1]];static Upper=this.Lu;static foldLu=[[97,122,1],[181,223,42],[224,246,1],[248,255,1],[257,303,2],[307,311,2],[314,328,2],[331,375,2],[378,382,2],[383,384,1],[387,389,2],[392,396,4],[402,405,3],[409,410,1],[414,417,3],[419,421,2],[424,429,5],[432,436,4],[438,441,3],[445,447,2],[453,454,1],[456,457,1],[459,460,1],[462,476,2],[477,495,2],[498,499,1],[501,505,4],[507,543,2],[547,563,2],[572,575,3],[576,578,2],[583,591,2],[592,596,1],[598,599,1],[601,603,2],[604,608,4],[609,613,2],[614,616,2],[617,620,1],[623,625,2],[626,629,3],[637,640,3],[642,643,1],[647,652,1],[658,669,11],[670,837,167],[881,883,2],[887,891,4],[892,893,1],[940,943,1],[945,974,1],[976,977,1],[981,983,1],[985,1007,2],[1008,1011,1],[1013,1019,3],[1072,1119,1],[1121,1153,2],[1163,1215,2],[1218,1230,2],[1231,1327,2],[1377,1414,1],[4304,4346,1],[4349,4351,1],[5112,5117,1],[7296,7304,1],[7545,7549,4],[7566,7681,115],[7683,7829,2],[7835,7841,6],[7843,7935,2],[7936,7943,1],[7952,7957,1],[7968,7975,1],[7984,7991,1],[8e3,8005,1],[8017,8023,2],[8032,8039,1],[8048,8061,1],[8112,8113,1],[8126,8144,18],[8145,8160,15],[8161,8165,4],[8526,8580,54],[11312,11359,1],[11361,11365,4],[11366,11372,2],[11379,11382,3],[11393,11491,2],[11500,11502,2],[11507,11520,13],[11521,11557,1],[11559,11565,6],[42561,42605,2],[42625,42651,2],[42787,42799,2],[42803,42863,2],[42874,42876,2],[42879,42887,2],[42892,42897,5],[42899,42900,1],[42903,42921,2],[42933,42947,2],[42952,42954,2],[42961,42967,6],[42969,42998,29],[43859,43888,29],[43889,43967,1],[65345,65370,1],[66600,66639,1],[66776,66811,1],[66967,66977,1],[66979,66993,1],[66995,67001,1],[67003,67004,1],[68800,68850,1],[71872,71903,1],[93792,93823,1],[125218,125251,1]];static M=[[768,879,1],[1155,1161,1],[1425,1469,1],[1471,1473,2],[1474,1476,2],[1477,1479,2],[1552,1562,1],[1611,1631,1],[1648,1750,102],[1751,1756,1],[1759,1764,1],[1767,1768,1],[1770,1773,1],[1809,1840,31],[1841,1866,1],[1958,1968,1],[2027,2035,1],[2045,2070,25],[2071,2073,1],[2075,2083,1],[2085,2087,1],[2089,2093,1],[2137,2139,1],[2200,2207,1],[2250,2273,1],[2275,2307,1],[2362,2364,1],[2366,2383,1],[2385,2391,1],[2402,2403,1],[2433,2435,1],[2492,2494,2],[2495,2500,1],[2503,2504,1],[2507,2509,1],[2519,2530,11],[2531,2558,27],[2561,2563,1],[2620,2622,2],[2623,2626,1],[2631,2632,1],[2635,2637,1],[2641,2672,31],[2673,2677,4],[2689,2691,1],[2748,2750,2],[2751,2757,1],[2759,2761,1],[2763,2765,1],[2786,2787,1],[2810,2815,1],[2817,2819,1],[2876,2878,2],[2879,2884,1],[2887,2888,1],[2891,2893,1],[2901,2903,1],[2914,2915,1],[2946,3006,60],[3007,3010,1],[3014,3016,1],[3018,3021,1],[3031,3072,41],[3073,3076,1],[3132,3134,2],[3135,3140,1],[3142,3144,1],[3146,3149,1],[3157,3158,1],[3170,3171,1],[3201,3203,1],[3260,3262,2],[3263,3268,1],[3270,3272,1],[3274,3277,1],[3285,3286,1],[3298,3299,1],[3315,3328,13],[3329,3331,1],[3387,3388,1],[3390,3396,1],[3398,3400,1],[3402,3405,1],[3415,3426,11],[3427,3457,30],[3458,3459,1],[3530,3535,5],[3536,3540,1],[3542,3544,2],[3545,3551,1],[3570,3571,1],[3633,3636,3],[3637,3642,1],[3655,3662,1],[3761,3764,3],[3765,3772,1],[3784,3790,1],[3864,3865,1],[3893,3897,2],[3902,3903,1],[3953,3972,1],[3974,3975,1],[3981,3991,1],[3993,4028,1],[4038,4139,101],[4140,4158,1],[4182,4185,1],[4190,4192,1],[4194,4196,1],[4199,4205,1],[4209,4212,1],[4226,4237,1],[4239,4250,11],[4251,4253,1],[4957,4959,1],[5906,5909,1],[5938,5940,1],[5970,5971,1],[6002,6003,1],[6068,6099,1],[6109,6155,46],[6156,6157,1],[6159,6277,118],[6278,6313,35],[6432,6443,1],[6448,6459,1],[6679,6683,1],[6741,6750,1],[6752,6780,1],[6783,6832,49],[6833,6862,1],[6912,6916,1],[6964,6980,1],[7019,7027,1],[7040,7042,1],[7073,7085,1],[7142,7155,1],[7204,7223,1],[7376,7378,1],[7380,7400,1],[7405,7412,7],[7415,7417,1],[7616,7679,1],[8400,8432,1],[11503,11505,1],[11647,11744,97],[11745,11775,1],[12330,12335,1],[12441,12442,1],[42607,42610,1],[42612,42621,1],[42654,42655,1],[42736,42737,1],[43010,43014,4],[43019,43043,24],[43044,43047,1],[43052,43136,84],[43137,43188,51],[43189,43205,1],[43232,43249,1],[43263,43302,39],[43303,43309,1],[43335,43347,1],[43392,43395,1],[43443,43456,1],[43493,43561,68],[43562,43574,1],[43587,43596,9],[43597,43643,46],[43644,43645,1],[43696,43698,2],[43699,43700,1],[43703,43704,1],[43710,43711,1],[43713,43755,42],[43756,43759,1],[43765,43766,1],[44003,44010,1],[44012,44013,1],[64286,65024,738],[65025,65039,1],[65056,65071,1],[66045,66272,227],[66422,66426,1],[68097,68099,1],[68101,68102,1],[68108,68111,1],[68152,68154,1],[68159,68325,166],[68326,68900,574],[68901,68903,1],[69291,69292,1],[69373,69375,1],[69446,69456,1],[69506,69509,1],[69632,69634,1],[69688,69702,1],[69744,69747,3],[69748,69759,11],[69760,69762,1],[69808,69818,1],[69826,69888,62],[69889,69890,1],[69927,69940,1],[69957,69958,1],[70003,70016,13],[70017,70018,1],[70067,70080,1],[70089,70092,1],[70094,70095,1],[70188,70199,1],[70206,70209,3],[70367,70378,1],[70400,70403,1],[70459,70460,1],[70462,70468,1],[70471,70472,1],[70475,70477,1],[70487,70498,11],[70499,70502,3],[70503,70508,1],[70512,70516,1],[70709,70726,1],[70750,70832,82],[70833,70851,1],[71087,71093,1],[71096,71104,1],[71132,71133,1],[71216,71232,1],[71339,71351,1],[71453,71467,1],[71724,71738,1],[71984,71989,1],[71991,71992,1],[71995,71998,1],[72e3,72002,2],[72003,72145,142],[72146,72151,1],[72154,72160,1],[72164,72193,29],[72194,72202,1],[72243,72249,1],[72251,72254,1],[72263,72273,10],[72274,72283,1],[72330,72345,1],[72751,72758,1],[72760,72767,1],[72850,72871,1],[72873,72886,1],[73009,73014,1],[73018,73020,2],[73021,73023,2],[73024,73029,1],[73031,73098,67],[73099,73102,1],[73104,73105,1],[73107,73111,1],[73459,73462,1],[73472,73473,1],[73475,73524,49],[73525,73530,1],[73534,73538,1],[78912,78919,7],[78920,78933,1],[92912,92916,1],[92976,92982,1],[94031,94033,2],[94034,94087,1],[94095,94098,1],[94180,94192,12],[94193,113821,19628],[113822,118528,4706],[118529,118573,1],[118576,118598,1],[119141,119145,1],[119149,119154,1],[119163,119170,1],[119173,119179,1],[119210,119213,1],[119362,119364,1],[121344,121398,1],[121403,121452,1],[121461,121476,15],[121499,121503,1],[121505,121519,1],[122880,122886,1],[122888,122904,1],[122907,122913,1],[122915,122916,1],[122918,122922,1],[123023,123184,161],[123185,123190,1],[123566,123628,62],[123629,123631,1],[124140,124143,1],[125136,125142,1],[125252,125258,1],[917760,917999,1]];static foldM=[[921,953,32],[8126,8126,1]];static Mc=[[2307,2363,56],[2366,2368,1],[2377,2380,1],[2382,2383,1],[2434,2435,1],[2494,2496,1],[2503,2504,1],[2507,2508,1],[2519,2563,44],[2622,2624,1],[2691,2750,59],[2751,2752,1],[2761,2763,2],[2764,2818,54],[2819,2878,59],[2880,2887,7],[2888,2891,3],[2892,2903,11],[3006,3007,1],[3009,3010,1],[3014,3016,1],[3018,3020,1],[3031,3073,42],[3074,3075,1],[3137,3140,1],[3202,3203,1],[3262,3264,2],[3265,3268,1],[3271,3272,1],[3274,3275,1],[3285,3286,1],[3315,3330,15],[3331,3390,59],[3391,3392,1],[3398,3400,1],[3402,3404,1],[3415,3458,43],[3459,3535,76],[3536,3537,1],[3544,3551,1],[3570,3571,1],[3902,3903,1],[3967,4139,172],[4140,4145,5],[4152,4155,3],[4156,4182,26],[4183,4194,11],[4195,4196,1],[4199,4205,1],[4227,4228,1],[4231,4236,1],[4239,4250,11],[4251,4252,1],[5909,5940,31],[6070,6078,8],[6079,6085,1],[6087,6088,1],[6435,6438,1],[6441,6443,1],[6448,6449,1],[6451,6456,1],[6681,6682,1],[6741,6743,2],[6753,6755,2],[6756,6765,9],[6766,6770,1],[6916,6965,49],[6971,6973,2],[6974,6977,1],[6979,6980,1],[7042,7073,31],[7078,7079,1],[7082,7143,61],[7146,7148,1],[7150,7154,4],[7155,7204,49],[7205,7211,1],[7220,7221,1],[7393,7415,22],[12334,12335,1],[43043,43044,1],[43047,43136,89],[43137,43188,51],[43189,43203,1],[43346,43347,1],[43395,43444,49],[43445,43450,5],[43451,43454,3],[43455,43456,1],[43567,43568,1],[43571,43572,1],[43597,43643,46],[43645,43755,110],[43758,43759,1],[43765,44003,238],[44004,44006,2],[44007,44009,2],[44010,44012,2],[69632,69634,2],[69762,69808,46],[69809,69810,1],[69815,69816,1],[69932,69957,25],[69958,70018,60],[70067,70069,1],[70079,70080,1],[70094,70188,94],[70189,70190,1],[70194,70195,1],[70197,70368,171],[70369,70370,1],[70402,70403,1],[70462,70463,1],[70465,70468,1],[70471,70472,1],[70475,70477,1],[70487,70498,11],[70499,70709,210],[70710,70711,1],[70720,70721,1],[70725,70832,107],[70833,70834,1],[70841,70843,2],[70844,70846,1],[70849,71087,238],[71088,71089,1],[71096,71099,1],[71102,71216,114],[71217,71218,1],[71227,71228,1],[71230,71340,110],[71342,71343,1],[71350,71456,106],[71457,71462,5],[71724,71726,1],[71736,71984,248],[71985,71989,1],[71991,71992,1],[71997,72e3,3],[72002,72145,143],[72146,72147,1],[72156,72159,1],[72164,72249,85],[72279,72280,1],[72343,72751,408],[72766,72873,107],[72881,72884,3],[73098,73102,1],[73107,73108,1],[73110,73461,351],[73462,73475,13],[73524,73525,1],[73534,73535,1],[73537,94033,20496],[94034,94087,1],[94192,94193,1],[119141,119142,1],[119149,119154,1]];static Me=[[1160,1161,1],[6846,8413,1567],[8414,8416,1],[8418,8420,1],[42608,42610,1]];static Mn=[[768,879,1],[1155,1159,1],[1425,1469,1],[1471,1473,2],[1474,1476,2],[1477,1479,2],[1552,1562,1],[1611,1631,1],[1648,1750,102],[1751,1756,1],[1759,1764,1],[1767,1768,1],[1770,1773,1],[1809,1840,31],[1841,1866,1],[1958,1968,1],[2027,2035,1],[2045,2070,25],[2071,2073,1],[2075,2083,1],[2085,2087,1],[2089,2093,1],[2137,2139,1],[2200,2207,1],[2250,2273,1],[2275,2306,1],[2362,2364,2],[2369,2376,1],[2381,2385,4],[2386,2391,1],[2402,2403,1],[2433,2492,59],[2497,2500,1],[2509,2530,21],[2531,2558,27],[2561,2562,1],[2620,2625,5],[2626,2631,5],[2632,2635,3],[2636,2637,1],[2641,2672,31],[2673,2677,4],[2689,2690,1],[2748,2753,5],[2754,2757,1],[2759,2760,1],[2765,2786,21],[2787,2810,23],[2811,2815,1],[2817,2876,59],[2879,2881,2],[2882,2884,1],[2893,2901,8],[2902,2914,12],[2915,2946,31],[3008,3021,13],[3072,3076,4],[3132,3134,2],[3135,3136,1],[3142,3144,1],[3146,3149,1],[3157,3158,1],[3170,3171,1],[3201,3260,59],[3263,3270,7],[3276,3277,1],[3298,3299,1],[3328,3329,1],[3387,3388,1],[3393,3396,1],[3405,3426,21],[3427,3457,30],[3530,3538,8],[3539,3540,1],[3542,3633,91],[3636,3642,1],[3655,3662,1],[3761,3764,3],[3765,3772,1],[3784,3790,1],[3864,3865,1],[3893,3897,2],[3953,3966,1],[3968,3972,1],[3974,3975,1],[3981,3991,1],[3993,4028,1],[4038,4141,103],[4142,4144,1],[4146,4151,1],[4153,4154,1],[4157,4158,1],[4184,4185,1],[4190,4192,1],[4209,4212,1],[4226,4229,3],[4230,4237,7],[4253,4957,704],[4958,4959,1],[5906,5908,1],[5938,5939,1],[5970,5971,1],[6002,6003,1],[6068,6069,1],[6071,6077,1],[6086,6089,3],[6090,6099,1],[6109,6155,46],[6156,6157,1],[6159,6277,118],[6278,6313,35],[6432,6434,1],[6439,6440,1],[6450,6457,7],[6458,6459,1],[6679,6680,1],[6683,6742,59],[6744,6750,1],[6752,6754,2],[6757,6764,1],[6771,6780,1],[6783,6832,49],[6833,6845,1],[6847,6862,1],[6912,6915,1],[6964,6966,2],[6967,6970,1],[6972,6978,6],[7019,7027,1],[7040,7041,1],[7074,7077,1],[7080,7081,1],[7083,7085,1],[7142,7144,2],[7145,7149,4],[7151,7153,1],[7212,7219,1],[7222,7223,1],[7376,7378,1],[7380,7392,1],[7394,7400,1],[7405,7412,7],[7416,7417,1],[7616,7679,1],[8400,8412,1],[8417,8421,4],[8422,8432,1],[11503,11505,1],[11647,11744,97],[11745,11775,1],[12330,12333,1],[12441,12442,1],[42607,42612,5],[42613,42621,1],[42654,42655,1],[42736,42737,1],[43010,43014,4],[43019,43045,26],[43046,43052,6],[43204,43205,1],[43232,43249,1],[43263,43302,39],[43303,43309,1],[43335,43345,1],[43392,43394,1],[43443,43446,3],[43447,43449,1],[43452,43453,1],[43493,43561,68],[43562,43566,1],[43569,43570,1],[43573,43574,1],[43587,43596,9],[43644,43696,52],[43698,43700,1],[43703,43704,1],[43710,43711,1],[43713,43756,43],[43757,43766,9],[44005,44008,3],[44013,64286,20273],[65024,65039,1],[65056,65071,1],[66045,66272,227],[66422,66426,1],[68097,68099,1],[68101,68102,1],[68108,68111,1],[68152,68154,1],[68159,68325,166],[68326,68900,574],[68901,68903,1],[69291,69292,1],[69373,69375,1],[69446,69456,1],[69506,69509,1],[69633,69688,55],[69689,69702,1],[69744,69747,3],[69748,69759,11],[69760,69761,1],[69811,69814,1],[69817,69818,1],[69826,69888,62],[69889,69890,1],[69927,69931,1],[69933,69940,1],[70003,70016,13],[70017,70070,53],[70071,70078,1],[70089,70092,1],[70095,70191,96],[70192,70193,1],[70196,70198,2],[70199,70206,7],[70209,70367,158],[70371,70378,1],[70400,70401,1],[70459,70460,1],[70464,70502,38],[70503,70508,1],[70512,70516,1],[70712,70719,1],[70722,70724,1],[70726,70750,24],[70835,70840,1],[70842,70847,5],[70848,70850,2],[70851,71090,239],[71091,71093,1],[71100,71101,1],[71103,71104,1],[71132,71133,1],[71219,71226,1],[71229,71231,2],[71232,71339,107],[71341,71344,3],[71345,71349,1],[71351,71453,102],[71454,71455,1],[71458,71461,1],[71463,71467,1],[71727,71735,1],[71737,71738,1],[71995,71996,1],[71998,72003,5],[72148,72151,1],[72154,72155,1],[72160,72193,33],[72194,72202,1],[72243,72248,1],[72251,72254,1],[72263,72273,10],[72274,72278,1],[72281,72283,1],[72330,72342,1],[72344,72345,1],[72752,72758,1],[72760,72765,1],[72767,72850,83],[72851,72871,1],[72874,72880,1],[72882,72883,1],[72885,72886,1],[73009,73014,1],[73018,73020,2],[73021,73023,2],[73024,73029,1],[73031,73104,73],[73105,73109,4],[73111,73459,348],[73460,73472,12],[73473,73526,53],[73527,73530,1],[73536,73538,2],[78912,78919,7],[78920,78933,1],[92912,92916,1],[92976,92982,1],[94031,94095,64],[94096,94098,1],[94180,113821,19641],[113822,118528,4706],[118529,118573,1],[118576,118598,1],[119143,119145,1],[119163,119170,1],[119173,119179,1],[119210,119213,1],[119362,119364,1],[121344,121398,1],[121403,121452,1],[121461,121476,15],[121499,121503,1],[121505,121519,1],[122880,122886,1],[122888,122904,1],[122907,122913,1],[122915,122916,1],[122918,122922,1],[123023,123184,161],[123185,123190,1],[123566,123628,62],[123629,123631,1],[124140,124143,1],[125136,125142,1],[125252,125258,1],[917760,917999,1]];static foldMn=[[921,953,32],[8126,8126,1]];static N=[[48,57,1],[178,179,1],[185,188,3],[189,190,1],[1632,1641,1],[1776,1785,1],[1984,1993,1],[2406,2415,1],[2534,2543,1],[2548,2553,1],[2662,2671,1],[2790,2799,1],[2918,2927,1],[2930,2935,1],[3046,3058,1],[3174,3183,1],[3192,3198,1],[3302,3311,1],[3416,3422,1],[3430,3448,1],[3558,3567,1],[3664,3673,1],[3792,3801,1],[3872,3891,1],[4160,4169,1],[4240,4249,1],[4969,4988,1],[5870,5872,1],[6112,6121,1],[6128,6137,1],[6160,6169,1],[6470,6479,1],[6608,6618,1],[6784,6793,1],[6800,6809,1],[6992,7001,1],[7088,7097,1],[7232,7241,1],[7248,7257,1],[8304,8308,4],[8309,8313,1],[8320,8329,1],[8528,8578,1],[8581,8585,1],[9312,9371,1],[9450,9471,1],[10102,10131,1],[11517,12295,778],[12321,12329,1],[12344,12346,1],[12690,12693,1],[12832,12841,1],[12872,12879,1],[12881,12895,1],[12928,12937,1],[12977,12991,1],[42528,42537,1],[42726,42735,1],[43056,43061,1],[43216,43225,1],[43264,43273,1],[43472,43481,1],[43504,43513,1],[43600,43609,1],[44016,44025,1],[65296,65305,1],[65799,65843,1],[65856,65912,1],[65930,65931,1],[66273,66299,1],[66336,66339,1],[66369,66378,9],[66513,66517,1],[66720,66729,1],[67672,67679,1],[67705,67711,1],[67751,67759,1],[67835,67839,1],[67862,67867,1],[68028,68029,1],[68032,68047,1],[68050,68095,1],[68160,68168,1],[68221,68222,1],[68253,68255,1],[68331,68335,1],[68440,68447,1],[68472,68479,1],[68521,68527,1],[68858,68863,1],[68912,68921,1],[69216,69246,1],[69405,69414,1],[69457,69460,1],[69573,69579,1],[69714,69743,1],[69872,69881,1],[69942,69951,1],[70096,70105,1],[70113,70132,1],[70384,70393,1],[70736,70745,1],[70864,70873,1],[71248,71257,1],[71360,71369,1],[71472,71483,1],[71904,71922,1],[72016,72025,1],[72784,72812,1],[73040,73049,1],[73120,73129,1],[73552,73561,1],[73664,73684,1],[74752,74862,1],[92768,92777,1],[92864,92873,1],[93008,93017,1],[93019,93025,1],[93824,93846,1],[119488,119507,1],[119520,119539,1],[119648,119672,1],[120782,120831,1],[123200,123209,1],[123632,123641,1],[124144,124153,1],[125127,125135,1],[125264,125273,1],[126065,126123,1],[126125,126127,1],[126129,126132,1],[126209,126253,1],[126255,126269,1],[127232,127244,1],[130032,130041,1]];static Nd=[[48,57,1],[1632,1641,1],[1776,1785,1],[1984,1993,1],[2406,2415,1],[2534,2543,1],[2662,2671,1],[2790,2799,1],[2918,2927,1],[3046,3055,1],[3174,3183,1],[3302,3311,1],[3430,3439,1],[3558,3567,1],[3664,3673,1],[3792,3801,1],[3872,3881,1],[4160,4169,1],[4240,4249,1],[6112,6121,1],[6160,6169,1],[6470,6479,1],[6608,6617,1],[6784,6793,1],[6800,6809,1],[6992,7001,1],[7088,7097,1],[7232,7241,1],[7248,7257,1],[42528,42537,1],[43216,43225,1],[43264,43273,1],[43472,43481,1],[43504,43513,1],[43600,43609,1],[44016,44025,1],[65296,65305,1],[66720,66729,1],[68912,68921,1],[69734,69743,1],[69872,69881,1],[69942,69951,1],[70096,70105,1],[70384,70393,1],[70736,70745,1],[70864,70873,1],[71248,71257,1],[71360,71369,1],[71472,71481,1],[71904,71913,1],[72016,72025,1],[72784,72793,1],[73040,73049,1],[73120,73129,1],[73552,73561,1],[92768,92777,1],[92864,92873,1],[93008,93017,1],[120782,120831,1],[123200,123209,1],[123632,123641,1],[124144,124153,1],[125264,125273,1],[130032,130041,1]];static Nl=[[5870,5872,1],[8544,8578,1],[8581,8584,1],[12295,12321,26],[12322,12329,1],[12344,12346,1],[42726,42735,1],[65856,65908,1],[66369,66378,9],[66513,66517,1],[74752,74862,1]];static No=[[178,179,1],[185,188,3],[189,190,1],[2548,2553,1],[2930,2935,1],[3056,3058,1],[3192,3198,1],[3416,3422,1],[3440,3448,1],[3882,3891,1],[4969,4988,1],[6128,6137,1],[6618,8304,1686],[8308,8313,1],[8320,8329,1],[8528,8543,1],[8585,9312,727],[9313,9371,1],[9450,9471,1],[10102,10131,1],[11517,12690,1173],[12691,12693,1],[12832,12841,1],[12872,12879,1],[12881,12895,1],[12928,12937,1],[12977,12991,1],[43056,43061,1],[65799,65843,1],[65909,65912,1],[65930,65931,1],[66273,66299,1],[66336,66339,1],[67672,67679,1],[67705,67711,1],[67751,67759,1],[67835,67839,1],[67862,67867,1],[68028,68029,1],[68032,68047,1],[68050,68095,1],[68160,68168,1],[68221,68222,1],[68253,68255,1],[68331,68335,1],[68440,68447,1],[68472,68479,1],[68521,68527,1],[68858,68863,1],[69216,69246,1],[69405,69414,1],[69457,69460,1],[69573,69579,1],[69714,69733,1],[70113,70132,1],[71482,71483,1],[71914,71922,1],[72794,72812,1],[73664,73684,1],[93019,93025,1],[93824,93846,1],[119488,119507,1],[119520,119539,1],[119648,119672,1],[125127,125135,1],[126065,126123,1],[126125,126127,1],[126129,126132,1],[126209,126253,1],[126255,126269,1],[127232,127244,1]];static P=[[33,35,1],[37,42,1],[44,47,1],[58,59,1],[63,64,1],[91,93,1],[95,123,28],[125,161,36],[167,171,4],[182,183,1],[187,191,4],[894,903,9],[1370,1375,1],[1417,1418,1],[1470,1472,2],[1475,1478,3],[1523,1524,1],[1545,1546,1],[1548,1549,1],[1563,1565,2],[1566,1567,1],[1642,1645,1],[1748,1792,44],[1793,1805,1],[2039,2041,1],[2096,2110,1],[2142,2404,262],[2405,2416,11],[2557,2678,121],[2800,3191,391],[3204,3572,368],[3663,3674,11],[3675,3844,169],[3845,3858,1],[3860,3898,38],[3899,3901,1],[3973,4048,75],[4049,4052,1],[4057,4058,1],[4170,4175,1],[4347,4960,613],[4961,4968,1],[5120,5742,622],[5787,5788,1],[5867,5869,1],[5941,5942,1],[6100,6102,1],[6104,6106,1],[6144,6154,1],[6468,6469,1],[6686,6687,1],[6816,6822,1],[6824,6829,1],[7002,7008,1],[7037,7038,1],[7164,7167,1],[7227,7231,1],[7294,7295,1],[7360,7367,1],[7379,8208,829],[8209,8231,1],[8240,8259,1],[8261,8273,1],[8275,8286,1],[8317,8318,1],[8333,8334,1],[8968,8971,1],[9001,9002,1],[10088,10101,1],[10181,10182,1],[10214,10223,1],[10627,10648,1],[10712,10715,1],[10748,10749,1],[11513,11516,1],[11518,11519,1],[11632,11776,144],[11777,11822,1],[11824,11855,1],[11858,11869,1],[12289,12291,1],[12296,12305,1],[12308,12319,1],[12336,12349,13],[12448,12539,91],[42238,42239,1],[42509,42511,1],[42611,42622,11],[42738,42743,1],[43124,43127,1],[43214,43215,1],[43256,43258,1],[43260,43310,50],[43311,43359,48],[43457,43469,1],[43486,43487,1],[43612,43615,1],[43742,43743,1],[43760,43761,1],[44011,64830,20819],[64831,65040,209],[65041,65049,1],[65072,65106,1],[65108,65121,1],[65123,65128,5],[65130,65131,1],[65281,65283,1],[65285,65290,1],[65292,65295,1],[65306,65307,1],[65311,65312,1],[65339,65341,1],[65343,65371,28],[65373,65375,2],[65376,65381,1],[65792,65794,1],[66463,66512,49],[66927,67671,744],[67871,67903,32],[68176,68184,1],[68223,68336,113],[68337,68342,1],[68409,68415,1],[68505,68508,1],[69293,69461,168],[69462,69465,1],[69510,69513,1],[69703,69709,1],[69819,69820,1],[69822,69825,1],[69952,69955,1],[70004,70005,1],[70085,70088,1],[70093,70107,14],[70109,70111,1],[70200,70205,1],[70313,70731,418],[70732,70735,1],[70746,70747,1],[70749,70854,105],[71105,71127,1],[71233,71235,1],[71264,71276,1],[71353,71484,131],[71485,71486,1],[71739,72004,265],[72005,72006,1],[72162,72255,93],[72256,72262,1],[72346,72348,1],[72350,72354,1],[72448,72457,1],[72769,72773,1],[72816,72817,1],[73463,73464,1],[73539,73551,1],[73727,74864,1137],[74865,74868,1],[77809,77810,1],[92782,92783,1],[92917,92983,66],[92984,92987,1],[92996,93847,851],[93848,93850,1],[94178,113823,19645],[121479,121483,1],[125278,125279,1]];static Pc=[[95,8255,8160],[8256,8276,20],[65075,65076,1],[65101,65103,1],[65343,65343,1]];static Pd=[[45,1418,1373],[1470,5120,3650],[6150,8208,2058],[8209,8213,1],[11799,11802,3],[11834,11835,1],[11840,11869,29],[12316,12336,20],[12448,65073,52625],[65074,65112,38],[65123,65293,170],[69293,69293,1]];static Pe=[[41,93,52],[125,3899,3774],[3901,5788,1887],[8262,8318,56],[8334,8969,635],[8971,9002,31],[10089,10101,2],[10182,10215,33],[10217,10223,2],[10628,10648,2],[10713,10715,2],[10749,11811,1062],[11813,11817,2],[11862,11868,2],[12297,12305,2],[12309,12315,2],[12318,12319,1],[64830,65048,218],[65078,65092,2],[65096,65114,18],[65116,65118,2],[65289,65341,52],[65373,65379,3]];static Pf=[[187,8217,8030],[8221,8250,29],[11779,11781,2],[11786,11789,3],[11805,11809,4]];static Pi=[[171,8216,8045],[8219,8220,1],[8223,8249,26],[11778,11780,2],[11785,11788,3],[11804,11808,4]];static Po=[[33,35,1],[37,39,1],[42,46,2],[47,58,11],[59,63,4],[64,92,28],[161,167,6],[182,183,1],[191,894,703],[903,1370,467],[1371,1375,1],[1417,1472,55],[1475,1478,3],[1523,1524,1],[1545,1546,1],[1548,1549,1],[1563,1565,2],[1566,1567,1],[1642,1645,1],[1748,1792,44],[1793,1805,1],[2039,2041,1],[2096,2110,1],[2142,2404,262],[2405,2416,11],[2557,2678,121],[2800,3191,391],[3204,3572,368],[3663,3674,11],[3675,3844,169],[3845,3858,1],[3860,3973,113],[4048,4052,1],[4057,4058,1],[4170,4175,1],[4347,4960,613],[4961,4968,1],[5742,5867,125],[5868,5869,1],[5941,5942,1],[6100,6102,1],[6104,6106,1],[6144,6149,1],[6151,6154,1],[6468,6469,1],[6686,6687,1],[6816,6822,1],[6824,6829,1],[7002,7008,1],[7037,7038,1],[7164,7167,1],[7227,7231,1],[7294,7295,1],[7360,7367,1],[7379,8214,835],[8215,8224,9],[8225,8231,1],[8240,8248,1],[8251,8254,1],[8257,8259,1],[8263,8273,1],[8275,8277,2],[8278,8286,1],[11513,11516,1],[11518,11519,1],[11632,11776,144],[11777,11782,5],[11783,11784,1],[11787,11790,3],[11791,11798,1],[11800,11801,1],[11803,11806,3],[11807,11818,11],[11819,11822,1],[11824,11833,1],[11836,11839,1],[11841,11843,2],[11844,11855,1],[11858,11860,1],[12289,12291,1],[12349,12539,190],[42238,42239,1],[42509,42511,1],[42611,42622,11],[42738,42743,1],[43124,43127,1],[43214,43215,1],[43256,43258,1],[43260,43310,50],[43311,43359,48],[43457,43469,1],[43486,43487,1],[43612,43615,1],[43742,43743,1],[43760,43761,1],[44011,65040,21029],[65041,65046,1],[65049,65072,23],[65093,65094,1],[65097,65100,1],[65104,65106,1],[65108,65111,1],[65119,65121,1],[65128,65130,2],[65131,65281,150],[65282,65283,1],[65285,65287,1],[65290,65294,2],[65295,65306,11],[65307,65311,4],[65312,65340,28],[65377,65380,3],[65381,65792,411],[65793,65794,1],[66463,66512,49],[66927,67671,744],[67871,67903,32],[68176,68184,1],[68223,68336,113],[68337,68342,1],[68409,68415,1],[68505,68508,1],[69461,69465,1],[69510,69513,1],[69703,69709,1],[69819,69820,1],[69822,69825,1],[69952,69955,1],[70004,70005,1],[70085,70088,1],[70093,70107,14],[70109,70111,1],[70200,70205,1],[70313,70731,418],[70732,70735,1],[70746,70747,1],[70749,70854,105],[71105,71127,1],[71233,71235,1],[71264,71276,1],[71353,71484,131],[71485,71486,1],[71739,72004,265],[72005,72006,1],[72162,72255,93],[72256,72262,1],[72346,72348,1],[72350,72354,1],[72448,72457,1],[72769,72773,1],[72816,72817,1],[73463,73464,1],[73539,73551,1],[73727,74864,1137],[74865,74868,1],[77809,77810,1],[92782,92783,1],[92917,92983,66],[92984,92987,1],[92996,93847,851],[93848,93850,1],[94178,113823,19645],[121479,121483,1],[125278,125279,1]];static Ps=[[40,91,51],[123,3898,3775],[3900,5787,1887],[8218,8222,4],[8261,8317,56],[8333,8968,635],[8970,9001,31],[10088,10100,2],[10181,10214,33],[10216,10222,2],[10627,10647,2],[10712,10714,2],[10748,11810,1062],[11812,11816,2],[11842,11861,19],[11863,11867,2],[12296,12304,2],[12308,12314,2],[12317,64831,52514],[65047,65077,30],[65079,65091,2],[65095,65113,18],[65115,65117,2],[65288,65339,51],[65371,65375,4],[65378,65378,1]];static S=[[36,43,7],[60,62,1],[94,96,2],[124,126,2],[162,166,1],[168,169,1],[172,174,2],[175,177,1],[180,184,4],[215,247,32],[706,709,1],[722,735,1],[741,747,1],[749,751,2],[752,767,1],[885,900,15],[901,1014,113],[1154,1421,267],[1422,1423,1],[1542,1544,1],[1547,1550,3],[1551,1758,207],[1769,1789,20],[1790,2038,248],[2046,2047,1],[2184,2546,362],[2547,2554,7],[2555,2801,246],[2928,3059,131],[3060,3066,1],[3199,3407,208],[3449,3647,198],[3841,3843,1],[3859,3861,2],[3862,3863,1],[3866,3871,1],[3892,3896,2],[4030,4037,1],[4039,4044,1],[4046,4047,1],[4053,4056,1],[4254,4255,1],[5008,5017,1],[5741,6107,366],[6464,6622,158],[6623,6655,1],[7009,7018,1],[7028,7036,1],[8125,8127,2],[8128,8129,1],[8141,8143,1],[8157,8159,1],[8173,8175,1],[8189,8190,1],[8260,8274,14],[8314,8316,1],[8330,8332,1],[8352,8384,1],[8448,8449,1],[8451,8454,1],[8456,8457,1],[8468,8470,2],[8471,8472,1],[8478,8483,1],[8485,8489,2],[8494,8506,12],[8507,8512,5],[8513,8516,1],[8522,8525,1],[8527,8586,59],[8587,8592,5],[8593,8967,1],[8972,9e3,1],[9003,9254,1],[9280,9290,1],[9372,9449,1],[9472,10087,1],[10132,10180,1],[10183,10213,1],[10224,10626,1],[10649,10711,1],[10716,10747,1],[10750,11123,1],[11126,11157,1],[11159,11263,1],[11493,11498,1],[11856,11857,1],[11904,11929,1],[11931,12019,1],[12032,12245,1],[12272,12287,1],[12292,12306,14],[12307,12320,13],[12342,12343,1],[12350,12351,1],[12443,12444,1],[12688,12689,1],[12694,12703,1],[12736,12771,1],[12783,12800,17],[12801,12830,1],[12842,12871,1],[12880,12896,16],[12897,12927,1],[12938,12976,1],[12992,13311,1],[19904,19967,1],[42128,42182,1],[42752,42774,1],[42784,42785,1],[42889,42890,1],[43048,43051,1],[43062,43065,1],[43639,43641,1],[43867,43882,15],[43883,64297,20414],[64434,64450,1],[64832,64847,1],[64975,65020,45],[65021,65023,1],[65122,65124,2],[65125,65126,1],[65129,65284,155],[65291,65308,17],[65309,65310,1],[65342,65344,2],[65372,65374,2],[65504,65510,1],[65512,65518,1],[65532,65533,1],[65847,65855,1],[65913,65929,1],[65932,65934,1],[65936,65948,1],[65952,66e3,48],[66001,66044,1],[67703,67704,1],[68296,71487,3191],[73685,73713,1],[92988,92991,1],[92997,113820,20823],[118608,118723,1],[118784,119029,1],[119040,119078,1],[119081,119140,1],[119146,119148,1],[119171,119172,1],[119180,119209,1],[119214,119274,1],[119296,119361,1],[119365,119552,187],[119553,119638,1],[120513,120539,26],[120571,120597,26],[120629,120655,26],[120687,120713,26],[120745,120771,26],[120832,121343,1],[121399,121402,1],[121453,121460,1],[121462,121475,1],[121477,121478,1],[123215,123647,432],[126124,126128,4],[126254,126704,450],[126705,126976,271],[126977,127019,1],[127024,127123,1],[127136,127150,1],[127153,127167,1],[127169,127183,1],[127185,127221,1],[127245,127405,1],[127462,127490,1],[127504,127547,1],[127552,127560,1],[127568,127569,1],[127584,127589,1],[127744,128727,1],[128732,128748,1],[128752,128764,1],[128768,128886,1],[128891,128985,1],[128992,129003,1],[129008,129024,16],[129025,129035,1],[129040,129095,1],[129104,129113,1],[129120,129159,1],[129168,129197,1],[129200,129201,1],[129280,129619,1],[129632,129645,1],[129648,129660,1],[129664,129672,1],[129680,129725,1],[129727,129733,1],[129742,129755,1],[129760,129768,1],[129776,129784,1],[129792,129938,1],[129940,129994,1]];static Sc=[[36,162,126],[163,165,1],[1423,1547,124],[2046,2047,1],[2546,2547,1],[2555,2801,246],[3065,3647,582],[6107,8352,2245],[8353,8384,1],[43064,65020,21956],[65129,65284,155],[65504,65505,1],[65509,65510,1],[73693,73696,1],[123647,126128,2481]];static Sk=[[94,96,2],[168,175,7],[180,184,4],[706,709,1],[722,735,1],[741,747,1],[749,751,2],[752,767,1],[885,900,15],[901,2184,1283],[8125,8127,2],[8128,8129,1],[8141,8143,1],[8157,8159,1],[8173,8175,1],[8189,8190,1],[12443,12444,1],[42752,42774,1],[42784,42785,1],[42889,42890,1],[43867,43882,15],[43883,64434,20551],[64435,64450,1],[65342,65344,2],[65507,127995,62488],[127996,127999,1]];static Sm=[[43,60,17],[61,62,1],[124,126,2],[172,177,5],[215,247,32],[1014,1542,528],[1543,1544,1],[8260,8274,14],[8314,8316,1],[8330,8332,1],[8472,8512,40],[8513,8516,1],[8523,8592,69],[8593,8596,1],[8602,8603,1],[8608,8614,3],[8622,8654,32],[8655,8658,3],[8660,8692,32],[8693,8959,1],[8992,8993,1],[9084,9115,31],[9116,9139,1],[9180,9185,1],[9655,9665,10],[9720,9727,1],[9839,10176,337],[10177,10180,1],[10183,10213,1],[10224,10239,1],[10496,10626,1],[10649,10711,1],[10716,10747,1],[10750,11007,1],[11056,11076,1],[11079,11084,1],[64297,65122,825],[65124,65126,1],[65291,65308,17],[65309,65310,1],[65372,65374,2],[65506,65513,7],[65514,65516,1],[120513,120539,26],[120571,120597,26],[120629,120655,26],[120687,120713,26],[120745,120771,26],[126704,126705,1]];static So=[[166,169,3],[174,176,2],[1154,1421,267],[1422,1550,128],[1551,1758,207],[1769,1789,20],[1790,2038,248],[2554,2928,374],[3059,3064,1],[3066,3199,133],[3407,3449,42],[3841,3843,1],[3859,3861,2],[3862,3863,1],[3866,3871,1],[3892,3896,2],[4030,4037,1],[4039,4044,1],[4046,4047,1],[4053,4056,1],[4254,4255,1],[5008,5017,1],[5741,6464,723],[6622,6655,1],[7009,7018,1],[7028,7036,1],[8448,8449,1],[8451,8454,1],[8456,8457,1],[8468,8470,2],[8471,8478,7],[8479,8483,1],[8485,8489,2],[8494,8506,12],[8507,8522,15],[8524,8525,1],[8527,8586,59],[8587,8597,10],[8598,8601,1],[8604,8607,1],[8609,8610,1],[8612,8613,1],[8615,8621,1],[8623,8653,1],[8656,8657,1],[8659,8661,2],[8662,8691,1],[8960,8967,1],[8972,8991,1],[8994,9e3,1],[9003,9083,1],[9085,9114,1],[9140,9179,1],[9186,9254,1],[9280,9290,1],[9372,9449,1],[9472,9654,1],[9656,9664,1],[9666,9719,1],[9728,9838,1],[9840,10087,1],[10132,10175,1],[10240,10495,1],[11008,11055,1],[11077,11078,1],[11085,11123,1],[11126,11157,1],[11159,11263,1],[11493,11498,1],[11856,11857,1],[11904,11929,1],[11931,12019,1],[12032,12245,1],[12272,12287,1],[12292,12306,14],[12307,12320,13],[12342,12343,1],[12350,12351,1],[12688,12689,1],[12694,12703,1],[12736,12771,1],[12783,12800,17],[12801,12830,1],[12842,12871,1],[12880,12896,16],[12897,12927,1],[12938,12976,1],[12992,13311,1],[19904,19967,1],[42128,42182,1],[43048,43051,1],[43062,43063,1],[43065,43639,574],[43640,43641,1],[64832,64847,1],[64975,65021,46],[65022,65023,1],[65508,65512,4],[65517,65518,1],[65532,65533,1],[65847,65855,1],[65913,65929,1],[65932,65934,1],[65936,65948,1],[65952,66e3,48],[66001,66044,1],[67703,67704,1],[68296,71487,3191],[73685,73692,1],[73697,73713,1],[92988,92991,1],[92997,113820,20823],[118608,118723,1],[118784,119029,1],[119040,119078,1],[119081,119140,1],[119146,119148,1],[119171,119172,1],[119180,119209,1],[119214,119274,1],[119296,119361,1],[119365,119552,187],[119553,119638,1],[120832,121343,1],[121399,121402,1],[121453,121460,1],[121462,121475,1],[121477,121478,1],[123215,126124,2909],[126254,126976,722],[126977,127019,1],[127024,127123,1],[127136,127150,1],[127153,127167,1],[127169,127183,1],[127185,127221,1],[127245,127405,1],[127462,127490,1],[127504,127547,1],[127552,127560,1],[127568,127569,1],[127584,127589,1],[127744,127994,1],[128e3,128727,1],[128732,128748,1],[128752,128764,1],[128768,128886,1],[128891,128985,1],[128992,129003,1],[129008,129024,16],[129025,129035,1],[129040,129095,1],[129104,129113,1],[129120,129159,1],[129168,129197,1],[129200,129201,1],[129280,129619,1],[129632,129645,1],[129648,129660,1],[129664,129672,1],[129680,129725,1],[129727,129733,1],[129742,129755,1],[129760,129768,1],[129776,129784,1],[129792,129938,1],[129940,129994,1]];static Z=[[32,160,128],[5760,8192,2432],[8193,8202,1],[8232,8233,1],[8239,8287,48],[12288,12288,1]];static Zl=[[8232,8232,1]];static Zp=[[8233,8233,1]];static Zs=[[32,160,128],[5760,8192,2432],[8193,8202,1],[8239,8287,48],[12288,12288,1]];static Adlam=[[125184,125259,1],[125264,125273,1],[125278,125279,1]];static Ahom=[[71424,71450,1],[71453,71467,1],[71472,71494,1]];static Anatolian_Hieroglyphs=[[82944,83526,1]];static Arabic=[[1536,1540,1],[1542,1547,1],[1549,1562,1],[1564,1566,1],[1568,1599,1],[1601,1610,1],[1622,1647,1],[1649,1756,1],[1758,1791,1],[1872,1919,1],[2160,2190,1],[2192,2193,1],[2200,2273,1],[2275,2303,1],[64336,64450,1],[64467,64829,1],[64832,64911,1],[64914,64967,1],[64975,65008,33],[65009,65023,1],[65136,65140,1],[65142,65276,1],[69216,69246,1],[69373,69375,1],[126464,126467,1],[126469,126495,1],[126497,126498,1],[126500,126503,3],[126505,126514,1],[126516,126519,1],[126521,126523,2],[126530,126535,5],[126537,126541,2],[126542,126543,1],[126545,126546,1],[126548,126551,3],[126553,126561,2],[126562,126564,2],[126567,126570,1],[126572,126578,1],[126580,126583,1],[126585,126588,1],[126590,126592,2],[126593,126601,1],[126603,126619,1],[126625,126627,1],[126629,126633,1],[126635,126651,1],[126704,126705,1]];static Armenian=[[1329,1366,1],[1369,1418,1],[1421,1423,1],[64275,64279,1]];static Avestan=[[68352,68405,1],[68409,68415,1]];static Balinese=[[6912,6988,1],[6992,7038,1]];static Bamum=[[42656,42743,1],[92160,92728,1]];static Bassa_Vah=[[92880,92909,1],[92912,92917,1]];static Batak=[[7104,7155,1],[7164,7167,1]];static Bengali=[[2432,2435,1],[2437,2444,1],[2447,2448,1],[2451,2472,1],[2474,2480,1],[2482,2486,4],[2487,2489,1],[2492,2500,1],[2503,2504,1],[2507,2510,1],[2519,2524,5],[2525,2527,2],[2528,2531,1],[2534,2558,1]];static Bhaiksuki=[[72704,72712,1],[72714,72758,1],[72760,72773,1],[72784,72812,1]];static Bopomofo=[[746,747,1],[12549,12591,1],[12704,12735,1]];static Brahmi=[[69632,69709,1],[69714,69749,1],[69759,69759,1]];static Braille=[[10240,10495,1]];static Buginese=[[6656,6683,1],[6686,6687,1]];static Buhid=[[5952,5971,1]];static Canadian_Aboriginal=[[5120,5759,1],[6320,6389,1],[72368,72383,1]];static Carian=[[66208,66256,1]];static Caucasian_Albanian=[[66864,66915,1],[66927,66927,1]];static Chakma=[[69888,69940,1],[69942,69959,1]];static Cham=[[43520,43574,1],[43584,43597,1],[43600,43609,1],[43612,43615,1]];static Cherokee=[[5024,5109,1],[5112,5117,1],[43888,43967,1]];static Chorasmian=[[69552,69579,1]];static Common=[[0,64,1],[91,96,1],[123,169,1],[171,185,1],[187,191,1],[215,247,32],[697,735,1],[741,745,1],[748,767,1],[884,894,10],[901,903,2],[1541,1548,7],[1563,1567,4],[1600,1757,157],[2274,2404,130],[2405,3647,1242],[4053,4056,1],[4347,5867,1520],[5868,5869,1],[5941,5942,1],[6146,6147,1],[6149,7379,1230],[7393,7401,8],[7402,7404,1],[7406,7411,1],[7413,7415,1],[7418,8192,774],[8193,8203,1],[8206,8292,1],[8294,8304,1],[8308,8318,1],[8320,8334,1],[8352,8384,1],[8448,8485,1],[8487,8489,1],[8492,8497,1],[8499,8525,1],[8527,8543,1],[8585,8587,1],[8592,9254,1],[9280,9290,1],[9312,10239,1],[10496,11123,1],[11126,11157,1],[11159,11263,1],[11776,11869,1],[12272,12292,1],[12294,12296,2],[12297,12320,1],[12336,12343,1],[12348,12351,1],[12443,12444,1],[12448,12539,91],[12540,12688,148],[12689,12703,1],[12736,12771,1],[12783,12832,49],[12833,12895,1],[12927,13007,1],[13055,13144,89],[13145,13311,1],[19904,19967,1],[42752,42785,1],[42888,42890,1],[43056,43065,1],[43310,43471,161],[43867,43882,15],[43883,64830,20947],[64831,65040,209],[65041,65049,1],[65072,65106,1],[65108,65126,1],[65128,65131,1],[65279,65281,2],[65282,65312,1],[65339,65344,1],[65371,65381,1],[65392,65438,46],[65439,65504,65],[65505,65510,1],[65512,65518,1],[65529,65533,1],[65792,65794,1],[65799,65843,1],[65847,65855,1],[65936,65948,1],[66e3,66044,1],[66273,66299,1],[113824,113827,1],[118608,118723,1],[118784,119029,1],[119040,119078,1],[119081,119142,1],[119146,119162,1],[119171,119172,1],[119180,119209,1],[119214,119274,1],[119488,119507,1],[119520,119539,1],[119552,119638,1],[119648,119672,1],[119808,119892,1],[119894,119964,1],[119966,119967,1],[119970,119973,3],[119974,119977,3],[119978,119980,1],[119982,119993,1],[119995,119997,2],[119998,120003,1],[120005,120069,1],[120071,120074,1],[120077,120084,1],[120086,120092,1],[120094,120121,1],[120123,120126,1],[120128,120132,1],[120134,120138,4],[120139,120144,1],[120146,120485,1],[120488,120779,1],[120782,120831,1],[126065,126132,1],[126209,126269,1],[126976,127019,1],[127024,127123,1],[127136,127150,1],[127153,127167,1],[127169,127183,1],[127185,127221,1],[127232,127405,1],[127462,127487,1],[127489,127490,1],[127504,127547,1],[127552,127560,1],[127568,127569,1],[127584,127589,1],[127744,128727,1],[128732,128748,1],[128752,128764,1],[128768,128886,1],[128891,128985,1],[128992,129003,1],[129008,129024,16],[129025,129035,1],[129040,129095,1],[129104,129113,1],[129120,129159,1],[129168,129197,1],[129200,129201,1],[129280,129619,1],[129632,129645,1],[129648,129660,1],[129664,129672,1],[129680,129725,1],[129727,129733,1],[129742,129755,1],[129760,129768,1],[129776,129784,1],[129792,129938,1],[129940,129994,1],[130032,130041,1],[917505,917536,31],[917537,917631,1]];static foldCommon=[[924,956,32]];static Coptic=[[994,1007,1],[11392,11507,1],[11513,11519,1]];static Cuneiform=[[73728,74649,1],[74752,74862,1],[74864,74868,1],[74880,75075,1]];static Cypriot=[[67584,67589,1],[67592,67594,2],[67595,67637,1],[67639,67640,1],[67644,67647,3]];static Cypro_Minoan=[[77712,77810,1]];static Cyrillic=[[1024,1156,1],[1159,1327,1],[7296,7304,1],[7467,7544,77],[11744,11775,1],[42560,42655,1],[65070,65071,1],[122928,122989,1],[123023,123023,1]];static Deseret=[[66560,66639,1]];static Devanagari=[[2304,2384,1],[2389,2403,1],[2406,2431,1],[43232,43263,1],[72448,72457,1]];static Dives_Akuru=[[71936,71942,1],[71945,71948,3],[71949,71955,1],[71957,71958,1],[71960,71989,1],[71991,71992,1],[71995,72006,1],[72016,72025,1]];static Dogra=[[71680,71739,1]];static Duployan=[[113664,113770,1],[113776,113788,1],[113792,113800,1],[113808,113817,1],[113820,113823,1]];static Egyptian_Hieroglyphs=[[77824,78933,1]];static Elbasan=[[66816,66855,1]];static Elymaic=[[69600,69622,1]];static Ethiopic=[[4608,4680,1],[4682,4685,1],[4688,4694,1],[4696,4698,2],[4699,4701,1],[4704,4744,1],[4746,4749,1],[4752,4784,1],[4786,4789,1],[4792,4798,1],[4800,4802,2],[4803,4805,1],[4808,4822,1],[4824,4880,1],[4882,4885,1],[4888,4954,1],[4957,4988,1],[4992,5017,1],[11648,11670,1],[11680,11686,1],[11688,11694,1],[11696,11702,1],[11704,11710,1],[11712,11718,1],[11720,11726,1],[11728,11734,1],[11736,11742,1],[43777,43782,1],[43785,43790,1],[43793,43798,1],[43808,43814,1],[43816,43822,1],[124896,124902,1],[124904,124907,1],[124909,124910,1],[124912,124926,1]];static Georgian=[[4256,4293,1],[4295,4301,6],[4304,4346,1],[4348,4351,1],[7312,7354,1],[7357,7359,1],[11520,11557,1],[11559,11565,6]];static Glagolitic=[[11264,11359,1],[122880,122886,1],[122888,122904,1],[122907,122913,1],[122915,122916,1],[122918,122922,1]];static Gothic=[[66352,66378,1]];static Grantha=[[70400,70403,1],[70405,70412,1],[70415,70416,1],[70419,70440,1],[70442,70448,1],[70450,70451,1],[70453,70457,1],[70460,70468,1],[70471,70472,1],[70475,70477,1],[70480,70487,7],[70493,70499,1],[70502,70508,1],[70512,70516,1]];static Greek=[[880,883,1],[885,887,1],[890,893,1],[895,900,5],[902,904,2],[905,906,1],[908,910,2],[911,929,1],[931,993,1],[1008,1023,1],[7462,7466,1],[7517,7521,1],[7526,7530,1],[7615,7936,321],[7937,7957,1],[7960,7965,1],[7968,8005,1],[8008,8013,1],[8016,8023,1],[8025,8031,2],[8032,8061,1],[8064,8116,1],[8118,8132,1],[8134,8147,1],[8150,8155,1],[8157,8175,1],[8178,8180,1],[8182,8190,1],[8486,43877,35391],[65856,65934,1],[65952,119296,53344],[119297,119365,1]];static foldGreek=[[181,837,656]];static Gujarati=[[2689,2691,1],[2693,2701,1],[2703,2705,1],[2707,2728,1],[2730,2736,1],[2738,2739,1],[2741,2745,1],[2748,2757,1],[2759,2761,1],[2763,2765,1],[2768,2784,16],[2785,2787,1],[2790,2801,1],[2809,2815,1]];static Gunjala_Gondi=[[73056,73061,1],[73063,73064,1],[73066,73102,1],[73104,73105,1],[73107,73112,1],[73120,73129,1]];static Gurmukhi=[[2561,2563,1],[2565,2570,1],[2575,2576,1],[2579,2600,1],[2602,2608,1],[2610,2611,1],[2613,2614,1],[2616,2617,1],[2620,2622,2],[2623,2626,1],[2631,2632,1],[2635,2637,1],[2641,2649,8],[2650,2652,1],[2654,2662,8],[2663,2678,1]];static Han=[[11904,11929,1],[11931,12019,1],[12032,12245,1],[12293,12295,2],[12321,12329,1],[12344,12347,1],[13312,19903,1],[19968,40959,1],[63744,64109,1],[64112,64217,1],[94178,94179,1],[94192,94193,1],[131072,173791,1],[173824,177977,1],[177984,178205,1],[178208,183969,1],[183984,191456,1],[191472,192093,1],[194560,195101,1],[196608,201546,1],[201552,205743,1]];static Hangul=[[4352,4607,1],[12334,12335,1],[12593,12686,1],[12800,12830,1],[12896,12926,1],[43360,43388,1],[44032,55203,1],[55216,55238,1],[55243,55291,1],[65440,65470,1],[65474,65479,1],[65482,65487,1],[65490,65495,1],[65498,65500,1]];static Hanifi_Rohingya=[[68864,68903,1],[68912,68921,1]];static Hanunoo=[[5920,5940,1]];static Hatran=[[67808,67826,1],[67828,67829,1],[67835,67839,1]];static Hebrew=[[1425,1479,1],[1488,1514,1],[1519,1524,1],[64285,64310,1],[64312,64316,1],[64318,64320,2],[64321,64323,2],[64324,64326,2],[64327,64335,1]];static Hiragana=[[12353,12438,1],[12445,12447,1],[110593,110879,1],[110898,110928,30],[110929,110930,1],[127488,127488,1]];static Imperial_Aramaic=[[67648,67669,1],[67671,67679,1]];static Inherited=[[768,879,1],[1157,1158,1],[1611,1621,1],[1648,2385,737],[2386,2388,1],[6832,6862,1],[7376,7378,1],[7380,7392,1],[7394,7400,1],[7405,7412,7],[7416,7417,1],[7616,7679,1],[8204,8205,1],[8400,8432,1],[12330,12333,1],[12441,12442,1],[65024,65039,1],[65056,65069,1],[66045,66272,227],[70459,118528,48069],[118529,118573,1],[118576,118598,1],[119143,119145,1],[119163,119170,1],[119173,119179,1],[119210,119213,1],[917760,917999,1]];static foldInherited=[[921,953,32],[8126,8126,1]];static Inscriptional_Pahlavi=[[68448,68466,1],[68472,68479,1]];static Inscriptional_Parthian=[[68416,68437,1],[68440,68447,1]];static Javanese=[[43392,43469,1],[43472,43481,1],[43486,43487,1]];static Kaithi=[[69760,69826,1],[69837,69837,1]];static Kannada=[[3200,3212,1],[3214,3216,1],[3218,3240,1],[3242,3251,1],[3253,3257,1],[3260,3268,1],[3270,3272,1],[3274,3277,1],[3285,3286,1],[3293,3294,1],[3296,3299,1],[3302,3311,1],[3313,3315,1]];static Katakana=[[12449,12538,1],[12541,12543,1],[12784,12799,1],[13008,13054,1],[13056,13143,1],[65382,65391,1],[65393,65437,1],[110576,110579,1],[110581,110587,1],[110589,110590,1],[110592,110880,288],[110881,110882,1],[110933,110948,15],[110949,110951,1]];static Kawi=[[73472,73488,1],[73490,73530,1],[73534,73561,1]];static Kayah_Li=[[43264,43309,1],[43311,43311,1]];static Kharoshthi=[[68096,68099,1],[68101,68102,1],[68108,68115,1],[68117,68119,1],[68121,68149,1],[68152,68154,1],[68159,68168,1],[68176,68184,1]];static Khitan_Small_Script=[[94180,101120,6940],[101121,101589,1]];static Khmer=[[6016,6109,1],[6112,6121,1],[6128,6137,1],[6624,6655,1]];static Khojki=[[70144,70161,1],[70163,70209,1]];static Khudawadi=[[70320,70378,1],[70384,70393,1]];static Lao=[[3713,3714,1],[3716,3718,2],[3719,3722,1],[3724,3747,1],[3749,3751,2],[3752,3773,1],[3776,3780,1],[3782,3784,2],[3785,3790,1],[3792,3801,1],[3804,3807,1]];static Latin=[[65,90,1],[97,122,1],[170,186,16],[192,214,1],[216,246,1],[248,696,1],[736,740,1],[7424,7461,1],[7468,7516,1],[7522,7525,1],[7531,7543,1],[7545,7614,1],[7680,7935,1],[8305,8319,14],[8336,8348,1],[8490,8491,1],[8498,8526,28],[8544,8584,1],[11360,11391,1],[42786,42887,1],[42891,42954,1],[42960,42961,1],[42963,42965,2],[42966,42969,1],[42994,43007,1],[43824,43866,1],[43868,43876,1],[43878,43881,1],[64256,64262,1],[65313,65338,1],[65345,65370,1],[67456,67461,1],[67463,67504,1],[67506,67514,1],[122624,122654,1],[122661,122666,1]];static Lepcha=[[7168,7223,1],[7227,7241,1],[7245,7247,1]];static Limbu=[[6400,6430,1],[6432,6443,1],[6448,6459,1],[6464,6468,4],[6469,6479,1]];static Linear_A=[[67072,67382,1],[67392,67413,1],[67424,67431,1]];static Linear_B=[[65536,65547,1],[65549,65574,1],[65576,65594,1],[65596,65597,1],[65599,65613,1],[65616,65629,1],[65664,65786,1]];static Lisu=[[42192,42239,1],[73648,73648,1]];static Lycian=[[66176,66204,1]];static Lydian=[[67872,67897,1],[67903,67903,1]];static Mahajani=[[69968,70006,1]];static Makasar=[[73440,73464,1]];static Malayalam=[[3328,3340,1],[3342,3344,1],[3346,3396,1],[3398,3400,1],[3402,3407,1],[3412,3427,1],[3430,3455,1]];static Mandaic=[[2112,2139,1],[2142,2142,1]];static Manichaean=[[68288,68326,1],[68331,68342,1]];static Marchen=[[72816,72847,1],[72850,72871,1],[72873,72886,1]];static Masaram_Gondi=[[72960,72966,1],[72968,72969,1],[72971,73014,1],[73018,73020,2],[73021,73023,2],[73024,73031,1],[73040,73049,1]];static Medefaidrin=[[93760,93850,1]];static Meetei_Mayek=[[43744,43766,1],[43968,44013,1],[44016,44025,1]];static Mende_Kikakui=[[124928,125124,1],[125127,125142,1]];static Meroitic_Cursive=[[68e3,68023,1],[68028,68047,1],[68050,68095,1]];static Meroitic_Hieroglyphs=[[67968,67999,1]];static Miao=[[93952,94026,1],[94031,94087,1],[94095,94111,1]];static Modi=[[71168,71236,1],[71248,71257,1]];static Mongolian=[[6144,6145,1],[6148,6150,2],[6151,6169,1],[6176,6264,1],[6272,6314,1],[71264,71276,1]];static Mro=[[92736,92766,1],[92768,92777,1],[92782,92783,1]];static Multani=[[70272,70278,1],[70280,70282,2],[70283,70285,1],[70287,70301,1],[70303,70313,1]];static Myanmar=[[4096,4255,1],[43488,43518,1],[43616,43647,1]];static Nabataean=[[67712,67742,1],[67751,67759,1]];static Nag_Mundari=[[124112,124153,1]];static Nandinagari=[[72096,72103,1],[72106,72151,1],[72154,72164,1]];static New_Tai_Lue=[[6528,6571,1],[6576,6601,1],[6608,6618,1],[6622,6623,1]];static Newa=[[70656,70747,1],[70749,70753,1]];static Nko=[[1984,2042,1],[2045,2047,1]];static Nushu=[[94177,110960,16783],[110961,111355,1]];static Nyiakeng_Puachue_Hmong=[[123136,123180,1],[123184,123197,1],[123200,123209,1],[123214,123215,1]];static Ogham=[[5760,5788,1]];static Ol_Chiki=[[7248,7295,1]];static Old_Hungarian=[[68736,68786,1],[68800,68850,1],[68858,68863,1]];static Old_Italic=[[66304,66339,1],[66349,66351,1]];static Old_North_Arabian=[[68224,68255,1]];static Old_Permic=[[66384,66426,1]];static Old_Persian=[[66464,66499,1],[66504,66517,1]];static Old_Sogdian=[[69376,69415,1]];static Old_South_Arabian=[[68192,68223,1]];static Old_Turkic=[[68608,68680,1]];static Old_Uyghur=[[69488,69513,1]];static Oriya=[[2817,2819,1],[2821,2828,1],[2831,2832,1],[2835,2856,1],[2858,2864,1],[2866,2867,1],[2869,2873,1],[2876,2884,1],[2887,2888,1],[2891,2893,1],[2901,2903,1],[2908,2909,1],[2911,2915,1],[2918,2935,1]];static Osage=[[66736,66771,1],[66776,66811,1]];static Osmanya=[[66688,66717,1],[66720,66729,1]];static Pahawh_Hmong=[[92928,92997,1],[93008,93017,1],[93019,93025,1],[93027,93047,1],[93053,93071,1]];static Palmyrene=[[67680,67711,1]];static Pau_Cin_Hau=[[72384,72440,1]];static Phags_Pa=[[43072,43127,1]];static Phoenician=[[67840,67867,1],[67871,67871,1]];static Psalter_Pahlavi=[[68480,68497,1],[68505,68508,1],[68521,68527,1]];static Rejang=[[43312,43347,1],[43359,43359,1]];static Runic=[[5792,5866,1],[5870,5880,1]];static Samaritan=[[2048,2093,1],[2096,2110,1]];static Saurashtra=[[43136,43205,1],[43214,43225,1]];static Sharada=[[70016,70111,1]];static Shavian=[[66640,66687,1]];static Siddham=[[71040,71093,1],[71096,71133,1]];static SignWriting=[[120832,121483,1],[121499,121503,1],[121505,121519,1]];static Sinhala=[[3457,3459,1],[3461,3478,1],[3482,3505,1],[3507,3515,1],[3517,3520,3],[3521,3526,1],[3530,3535,5],[3536,3540,1],[3542,3544,2],[3545,3551,1],[3558,3567,1],[3570,3572,1],[70113,70132,1]];static Sogdian=[[69424,69465,1]];static Sora_Sompeng=[[69840,69864,1],[69872,69881,1]];static Soyombo=[[72272,72354,1]];static Sundanese=[[7040,7103,1],[7360,7367,1]];static Syloti_Nagri=[[43008,43052,1]];static Syriac=[[1792,1805,1],[1807,1866,1],[1869,1871,1],[2144,2154,1]];static Tagalog=[[5888,5909,1],[5919,5919,1]];static Tagbanwa=[[5984,5996,1],[5998,6e3,1],[6002,6003,1]];static Tai_Le=[[6480,6509,1],[6512,6516,1]];static Tai_Tham=[[6688,6750,1],[6752,6780,1],[6783,6793,1],[6800,6809,1],[6816,6829,1]];static Tai_Viet=[[43648,43714,1],[43739,43743,1]];static Takri=[[71296,71353,1],[71360,71369,1]];static Tamil=[[2946,2947,1],[2949,2954,1],[2958,2960,1],[2962,2965,1],[2969,2970,1],[2972,2974,2],[2975,2979,4],[2980,2984,4],[2985,2986,1],[2990,3001,1],[3006,3010,1],[3014,3016,1],[3018,3021,1],[3024,3031,7],[3046,3066,1],[73664,73713,1],[73727,73727,1]];static Tangsa=[[92784,92862,1],[92864,92873,1]];static Tangut=[[94176,94208,32],[94209,100343,1],[100352,101119,1],[101632,101640,1]];static Telugu=[[3072,3084,1],[3086,3088,1],[3090,3112,1],[3114,3129,1],[3132,3140,1],[3142,3144,1],[3146,3149,1],[3157,3158,1],[3160,3162,1],[3165,3168,3],[3169,3171,1],[3174,3183,1],[3191,3199,1]];static Thaana=[[1920,1969,1]];static Thai=[[3585,3642,1],[3648,3675,1]];static Tibetan=[[3840,3911,1],[3913,3948,1],[3953,3991,1],[3993,4028,1],[4030,4044,1],[4046,4052,1],[4057,4058,1]];static Tifinagh=[[11568,11623,1],[11631,11632,1],[11647,11647,1]];static Tirhuta=[[70784,70855,1],[70864,70873,1]];static Toto=[[123536,123566,1]];static Ugaritic=[[66432,66461,1],[66463,66463,1]];static Vai=[[42240,42539,1]];static Vithkuqi=[[66928,66938,1],[66940,66954,1],[66956,66962,1],[66964,66965,1],[66967,66977,1],[66979,66993,1],[66995,67001,1],[67003,67004,1]];static Wancho=[[123584,123641,1],[123647,123647,1]];static Warang_Citi=[[71840,71922,1],[71935,71935,1]];static Yezidi=[[69248,69289,1],[69291,69293,1],[69296,69297,1]];static Yi=[[40960,42124,1],[42128,42182,1]];static Zanabazar_Square=[[72192,72263,1]];static CATEGORIES=new Map([["C",r.C],["Cc",r.Cc],["Cf",r.Cf],["Co",r.Co],["Cs",r.Cs],["L",r.L],["Ll",r.Ll],["Lm",r.Lm],["Lo",r.Lo],["Lt",r.Lt],["Lu",r.Lu],["M",r.M],["Mc",r.Mc],["Me",r.Me],["Mn",r.Mn],["N",r.N],["Nd",r.Nd],["Nl",r.Nl],["No",r.No],["P",r.P],["Pc",r.Pc],["Pd",r.Pd],["Pe",r.Pe],["Pf",r.Pf],["Pi",r.Pi],["Po",r.Po],["Ps",r.Ps],["S",r.S],["Sc",r.Sc],["Sk",r.Sk],["Sm",r.Sm],["So",r.So],["Z",r.Z],["Zl",r.Zl],["Zp",r.Zp],["Zs",r.Zs]]);static SCRIPTS=new Map([["Adlam",r.Adlam],["Ahom",r.Ahom],["Anatolian_Hieroglyphs",r.Anatolian_Hieroglyphs],["Arabic",r.Arabic],["Armenian",r.Armenian],["Avestan",r.Avestan],["Balinese",r.Balinese],["Bamum",r.Bamum],["Bassa_Vah",r.Bassa_Vah],["Batak",r.Batak],["Bengali",r.Bengali],["Bhaiksuki",r.Bhaiksuki],["Bopomofo",r.Bopomofo],["Brahmi",r.Brahmi],["Braille",r.Braille],["Buginese",r.Buginese],["Buhid",r.Buhid],["Canadian_Aboriginal",r.Canadian_Aboriginal],["Carian",r.Carian],["Caucasian_Albanian",r.Caucasian_Albanian],["Chakma",r.Chakma],["Cham",r.Cham],["Cherokee",r.Cherokee],["Chorasmian",r.Chorasmian],["Common",r.Common],["Coptic",r.Coptic],["Cuneiform",r.Cuneiform],["Cypriot",r.Cypriot],["Cypro_Minoan",r.Cypro_Minoan],["Cyrillic",r.Cyrillic],["Deseret",r.Deseret],["Devanagari",r.Devanagari],["Dives_Akuru",r.Dives_Akuru],["Dogra",r.Dogra],["Duployan",r.Duployan],["Egyptian_Hieroglyphs",r.Egyptian_Hieroglyphs],["Elbasan",r.Elbasan],["Elymaic",r.Elymaic],["Ethiopic",r.Ethiopic],["Georgian",r.Georgian],["Glagolitic",r.Glagolitic],["Gothic",r.Gothic],["Grantha",r.Grantha],["Greek",r.Greek],["Gujarati",r.Gujarati],["Gunjala_Gondi",r.Gunjala_Gondi],["Gurmukhi",r.Gurmukhi],["Han",r.Han],["Hangul",r.Hangul],["Hanifi_Rohingya",r.Hanifi_Rohingya],["Hanunoo",r.Hanunoo],["Hatran",r.Hatran],["Hebrew",r.Hebrew],["Hiragana",r.Hiragana],["Imperial_Aramaic",r.Imperial_Aramaic],["Inherited",r.Inherited],["Inscriptional_Pahlavi",r.Inscriptional_Pahlavi],["Inscriptional_Parthian",r.Inscriptional_Parthian],["Javanese",r.Javanese],["Kaithi",r.Kaithi],["Kannada",r.Kannada],["Katakana",r.Katakana],["Kawi",r.Kawi],["Kayah_Li",r.Kayah_Li],["Kharoshthi",r.Kharoshthi],["Khitan_Small_Script",r.Khitan_Small_Script],["Khmer",r.Khmer],["Khojki",r.Khojki],["Khudawadi",r.Khudawadi],["Lao",r.Lao],["Latin",r.Latin],["Lepcha",r.Lepcha],["Limbu",r.Limbu],["Linear_A",r.Linear_A],["Linear_B",r.Linear_B],["Lisu",r.Lisu],["Lycian",r.Lycian],["Lydian",r.Lydian],["Mahajani",r.Mahajani],["Makasar",r.Makasar],["Malayalam",r.Malayalam],["Mandaic",r.Mandaic],["Manichaean",r.Manichaean],["Marchen",r.Marchen],["Masaram_Gondi",r.Masaram_Gondi],["Medefaidrin",r.Medefaidrin],["Meetei_Mayek",r.Meetei_Mayek],["Mende_Kikakui",r.Mende_Kikakui],["Meroitic_Cursive",r.Meroitic_Cursive],["Meroitic_Hieroglyphs",r.Meroitic_Hieroglyphs],["Miao",r.Miao],["Modi",r.Modi],["Mongolian",r.Mongolian],["Mro",r.Mro],["Multani",r.Multani],["Myanmar",r.Myanmar],["Nabataean",r.Nabataean],["Nag_Mundari",r.Nag_Mundari],["Nandinagari",r.Nandinagari],["New_Tai_Lue",r.New_Tai_Lue],["Newa",r.Newa],["Nko",r.Nko],["Nushu",r.Nushu],["Nyiakeng_Puachue_Hmong",r.Nyiakeng_Puachue_Hmong],["Ogham",r.Ogham],["Ol_Chiki",r.Ol_Chiki],["Old_Hungarian",r.Old_Hungarian],["Old_Italic",r.Old_Italic],["Old_North_Arabian",r.Old_North_Arabian],["Old_Permic",r.Old_Permic],["Old_Persian",r.Old_Persian],["Old_Sogdian",r.Old_Sogdian],["Old_South_Arabian",r.Old_South_Arabian],["Old_Turkic",r.Old_Turkic],["Old_Uyghur",r.Old_Uyghur],["Oriya",r.Oriya],["Osage",r.Osage],["Osmanya",r.Osmanya],["Pahawh_Hmong",r.Pahawh_Hmong],["Palmyrene",r.Palmyrene],["Pau_Cin_Hau",r.Pau_Cin_Hau],["Phags_Pa",r.Phags_Pa],["Phoenician",r.Phoenician],["Psalter_Pahlavi",r.Psalter_Pahlavi],["Rejang",r.Rejang],["Runic",r.Runic],["Samaritan",r.Samaritan],["Saurashtra",r.Saurashtra],["Sharada",r.Sharada],["Shavian",r.Shavian],["Siddham",r.Siddham],["SignWriting",r.SignWriting],["Sinhala",r.Sinhala],["Sogdian",r.Sogdian],["Sora_Sompeng",r.Sora_Sompeng],["Soyombo",r.Soyombo],["Sundanese",r.Sundanese],["Syloti_Nagri",r.Syloti_Nagri],["Syriac",r.Syriac],["Tagalog",r.Tagalog],["Tagbanwa",r.Tagbanwa],["Tai_Le",r.Tai_Le],["Tai_Tham",r.Tai_Tham],["Tai_Viet",r.Tai_Viet],["Takri",r.Takri],["Tamil",r.Tamil],["Tangsa",r.Tangsa],["Tangut",r.Tangut],["Telugu",r.Telugu],["Thaana",r.Thaana],["Thai",r.Thai],["Tibetan",r.Tibetan],["Tifinagh",r.Tifinagh],["Tirhuta",r.Tirhuta],["Toto",r.Toto],["Ugaritic",r.Ugaritic],["Vai",r.Vai],["Vithkuqi",r.Vithkuqi],["Wancho",r.Wancho],["Warang_Citi",r.Warang_Citi],["Yezidi",r.Yezidi],["Yi",r.Yi],["Zanabazar_Square",r.Zanabazar_Square]]);static FOLD_CATEGORIES=new Map([["L",r.foldL],["Ll",r.foldLl],["Lt",r.foldLt],["Lu",r.foldLu],["M",r.foldM],["Mn",r.foldMn]]);static FOLD_SCRIPT=new Map([["Common",r.foldCommon],["Greek",r.foldGreek],["Inherited",r.foldInherited]])}class c{static MAX_RUNE=1114111;static MAX_ASCII=127;static MAX_LATIN1=255;static MAX_BMP=65535;static MIN_FOLD=65;static MAX_FOLD=125251;static is32(e,t){let r=0,n=e.length;for(;r<n;){var i=r+Math.floor((n-r)/2),s=e[i];if(s[0]<=t&&t<=s[1])return(t-s[0])%s[2]==0;t<s[0]?n=i:r=i+1}return!1}static is(e,t){if(t<=this.MAX_LATIN1){for(var r of e)if(!(t>r[1]))return!(t<r[0])&&(t-r[0])%r[2]==0;return!1}return 0<e.length&&t>=e[0][0]&&this.is32(e,t)}static isUpper(e){var t;return e<=this.MAX_LATIN1?(t=String.fromCodePoint(e)).toUpperCase()===t&&t.toLowerCase()!==t:this.is(r.Upper,e)}static isPrint(e){return e<=this.MAX_LATIN1?32<=e&&e<127||161<=e&&173!==e:this.is(r.L,e)||this.is(r.M,e)||this.is(r.N,e)||this.is(r.P,e)||this.is(r.S,e)}static simpleFold(e){var t;return r.CASE_ORBIT.has(e)?r.CASE_ORBIT.get(e):(t=f.toLowerCase(e))!==e?t:f.toUpperCase(e)}static equalsIgnoreCase(e,t){if(e<0||t<0||e===t)return!0;if(e<=this.MAX_ASCII&&t<=this.MAX_ASCII)return f.CODES.get("A")<=e&&e<=f.CODES.get("Z")&&(e|=32),f.CODES.get("A")<=t&&t<=f.CODES.get("Z")&&(t|=32),e===t;for(let r=this.simpleFold(e);r!==e;r=this.simpleFold(r))if(r===t)return!0;return!1}}class b{static METACHARACTERS="\\.+*?()|[]{}^$";static EMPTY_BEGIN_LINE=1;static EMPTY_END_LINE=2;static EMPTY_BEGIN_TEXT=4;static EMPTY_END_TEXT=8;static EMPTY_WORD_BOUNDARY=16;static EMPTY_NO_WORD_BOUNDARY=32;static EMPTY_ALL=-1;static emptyInts(){return[]}static isalnum(e){return f.CODES.get("0")<=e&&e<=f.CODES.get("9")||f.CODES.get("a")<=e&&e<=f.CODES.get("z")||f.CODES.get("A")<=e&&e<=f.CODES.get("Z")}static unhex(e){return f.CODES.get("0")<=e&&e<=f.CODES.get("9")?e-f.CODES.get("0"):f.CODES.get("a")<=e&&e<=f.CODES.get("f")?e-f.CODES.get("a")+10:f.CODES.get("A")<=e&&e<=f.CODES.get("F")?e-f.CODES.get("A")+10:-1}static escapeRune(e){let t="";if(c.isPrint(e))0<=this.METACHARACTERS.indexOf(String.fromCodePoint(e))&&(t+="\\"),t+=String.fromCodePoint(e);else switch(e){case f.CODES.get('"'):t+='\\"';break;case f.CODES.get("\\"):t+="\\\\";break;case f.CODES.get("\t"):t+="\\t";break;case f.CODES.get("\n"):t+="\\n";break;case f.CODES.get("\r"):t+="\\r";break;case f.CODES.get("\b"):t+="\\b";break;case f.CODES.get("\f"):t+="\\f";break;default:var r=e.toString(16);e<256?(t+="\\x",1===r.length&&(t+="0"),t+=r):t+=`\\x{${r}}`}return t}static stringToRunes(e){return String(e).split("").map(e=>e.codePointAt(0))}static runeToString(e){return String.fromCodePoint(e)}static isWordRune(e){return f.CODES.get("a")<=e&&e<=f.CODES.get("z")||f.CODES.get("A")<=e&&e<=f.CODES.get("Z")||f.CODES.get("0")<=e&&e<=f.CODES.get("9")||e===f.CODES.get("_")}static emptyOpContext(e,t){let r=0;return e<0&&(r|=this.EMPTY_BEGIN_TEXT|this.EMPTY_BEGIN_LINE),e===f.CODES.get("\n")&&(r|=this.EMPTY_BEGIN_LINE),t<0&&(r|=this.EMPTY_END_TEXT|this.EMPTY_END_LINE),t===f.CODES.get("\n")&&(r|=this.EMPTY_END_LINE),this.isWordRune(e)!==this.isWordRune(t)?r|=this.EMPTY_WORD_BOUNDARY:r|=this.EMPTY_NO_WORD_BOUNDARY,r}static quoteMeta(e){return e.split("").map(e=>0<=this.METACHARACTERS.indexOf(e)?"\\"+e:e).join("")}static charCount(e){return e>c.MAX_BMP?2:1}static stringToUtf8ByteArray(i){if(globalThis.TextEncoder)return Array.from((new TextEncoder).encode(i));{let t=[],r=0;for(let n=0;n<i.length;n++){let e=i.charCodeAt(n);e<128?t[r++]=e:(e<2048?t[r++]=e>>6|192:(55296==(64512&e)&&n+1<i.length&&56320==(64512&i.charCodeAt(n+1))?(e=65536+((1023&e)<<10)+(1023&i.charCodeAt(++n)),t[r++]=e>>18|240,t[r++]=e>>12&63|128):t[r++]=e>>12|224,t[r++]=e>>6&63|128),t[r++]=63&e|128)}return t}}static utf8ByteArrayToString(n){if(globalThis.TextDecoder)return new TextDecoder("utf-8").decode(new Uint8Array(n));{let e=[],t=0,r=0;for(;t<n.length;){var i,s,a,o=n[t++];o<128?e[r++]=String.fromCharCode(o):191<o&&o<224?(i=n[t++],e[r++]=String.fromCharCode((31&o)<<6|63&i)):239<o&&o<365?(i=((7&o)<<18|(63&n[t++])<<12|(63&n[t++])<<6|63&n[t++])-65536,e[r++]=String.fromCharCode(55296+(i>>10)),e[r++]=String.fromCharCode(56320+(1023&i))):(s=n[t++],a=n[t++],e[r++]=String.fromCharCode((15&o)<<12|(63&s)<<6|63&a))}return e.join("")}}}let sm=(e=[],t=0)=>{var r={};for(let s=0;s<e.length;s++){var n=e[s],i=t+s;r[n]=i,r[i]=n}return Object.freeze(r)};class am{static Encoding=sm(["UTF_16","UTF_8"]);getEncoding(){throw Error("not implemented")}isUTF8Encoding(){return this.getEncoding()===am.Encoding.UTF_8}isUTF16Encoding(){return this.getEncoding()===am.Encoding.UTF_16}}class om extends am{constructor(e=null){super(),this.bytes=e}getEncoding(){return am.Encoding.UTF_8}asCharSequence(){return b.utf8ByteArrayToString(this.bytes)}asBytes(){return this.bytes}length(){return this.bytes.length}}class lm extends am{constructor(e=null){super(),this.charSequence=e}getEncoding(){return am.Encoding.UTF_16}asCharSequence(){return this.charSequence}asBytes(){return this.charSequence.toString().split("").map(e=>e.codePointAt(0))}length(){return this.charSequence.length}}class um{static utf16(e){return new lm(e)}static utf8(e){return Array.isArray(e)?new om(e):new om(b.stringToUtf8ByteArray(e))}}class hm extends Error{constructor(e){super(e),this.name="RE2JSException"}}class cm extends hm{constructor(e,t=null){let r="error parsing regexp: "+e;t&&(r+=`: \`${t}\``),super(r),this.name="RE2JSSyntaxException",this.message=r,this.error=e,this.input=t}getDescription(){return this.error}getPattern(){return this.input}}class dm extends hm{constructor(e){super(e),this.name="RE2JSCompileException"}}class pm extends hm{constructor(e){super(e),this.name="RE2JSGroupException"}}class fm extends hm{constructor(e){super(e),this.name="RE2JSFlagsException"}}class gm{static quoteReplacement(e){return e.indexOf("\\")<0&&e.indexOf("$")<0?e:e.split("").map(e=>{var t=e.codePointAt(0);return t===f.CODES["\\"]||t===f.CODES.$?"\\"+e:e}).join("")}constructor(e,t){if(null===e)throw new Error("pattern is null");this.patternInput=e;var r=this.patternInput.re2();this.patternGroupCount=r.numberOfCapturingGroups(),this.groups=[],this.namedGroups=r.namedGroups,t instanceof am?this.resetMatcherInput(t):Array.isArray(t)?this.resetMatcherInput(um.utf8(t)):this.resetMatcherInput(um.utf16(t))}pattern(){return this.patternInput}reset(){return this.matcherInputLength=this.matcherInput.length(),this.appendPos=0,this.hasMatch=!1,this.hasGroups=!1,this.anchorFlag=0,this}resetMatcherInput(e){if(null===e)throw new Error("input is null");return this.matcherInput=e,this.reset(),this}start(e=0){if("string"==typeof e){var t=this.namedGroups[e];if(!Number.isFinite(t))throw new pm(`group '${e}' not found`);e=t}return this.loadGroup(e),this.groups[2*e]}end(e=0){if("string"==typeof e){var t=this.namedGroups[e];if(!Number.isFinite(t))throw new pm(`group '${e}' not found`);e=t}return this.loadGroup(e),this.groups[2*e+1]}group(e=0){if("string"==typeof e){var t=this.namedGroups[e];if(!Number.isFinite(t))throw new pm(`group '${e}' not found`);e=t}var t=this.start(e),r=this.end(e);return t<0&&r<0?null:this.substring(t,r)}groupCount(){return this.patternGroupCount}loadGroup(e){if(e<0||e>this.patternGroupCount)throw new pm("Group index out of bounds: "+e);if(!this.hasMatch)throw new pm("perhaps no match attempted");if(0!==e&&!this.hasGroups){let e=this.groups[1]+1;e>this.matcherInputLength&&(e=this.matcherInputLength);var t=this.patternInput.re2().matchMachineInput(this.matcherInput,this.groups[0],e,this.anchorFlag,1+this.patternGroupCount);if(!t[0])throw new pm("inconsistency in matching group data");this.groups=t[1],this.hasGroups=!0}}matches(){return this.genMatch(0,E.ANCHOR_BOTH)}lookingAt(){return this.genMatch(0,E.ANCHOR_START)}find(e=null){if(null===e)return e=0,this.hasMatch&&(e=this.groups[1],this.groups[0]===this.groups[1])&&e++,this.genMatch(e,E.UNANCHORED);if(e<0||e>this.matcherInputLength)throw new pm("start index out of bounds: "+e);return this.reset(),this.genMatch(e,0)}genMatch(e,t){var r=this.patternInput.re2().matchMachineInput(this.matcherInput,e,this.matcherInputLength,t,1);return!!r[0]&&(this.groups=r[1],this.hasMatch=!0,this.hasGroups=!1,this.anchorFlag=t,!0)}substring(e,t){return this.matcherInput.isUTF8Encoding()?b.utf8ByteArrayToString(this.matcherInput.asBytes().slice(e,t)):this.matcherInput.asCharSequence().substring(e,t).toString()}inputLength(){return this.matcherInputLength}appendReplacement(e,t=!1){let r="";var n=this.start(),i=this.end();return this.appendPos<n&&(r+=this.substring(this.appendPos,n)),this.appendPos=i,r+=t?this.appendReplacementInternalPerl(e):this.appendReplacementInternal(e)}appendReplacementInternal(r){let n="",i=0;var s=r.length;for(let o=0;o<s-1;o++)if(r.codePointAt(o)===f.CODES.get("\\"))i<o&&(n+=r.substring(i,o)),o++,i=o;else if(r.codePointAt(o)===f.CODES.get("$")){let t=r.codePointAt(o+1);if(f.CODES.get("0")<=t&&t<=f.CODES.get("9")){let e=t-f.CODES.get("0");for(i<o&&(n+=r.substring(i,o)),o+=2;o<s&&!((t=r.codePointAt(o))<f.CODES.get("0")||t>f.CODES.get("9")||10*e+t-f.CODES.get("0")>this.patternGroupCount);o++)e=10*e+t-f.CODES.get("0");if(e>this.patternGroupCount)throw new pm("n > number of groups: "+e);var a=this.group(e);null!==a&&(n+=a),i=o,o--}else if(t===f.CODES.get("{")){i<o&&(n+=r.substring(i,o));let e=++o+1;for(;e<r.length&&r.codePointAt(e)!==f.CODES.get("}")&&r.codePointAt(e)!==f.CODES.get(" ");)e++;if(e===r.length||r.codePointAt(e)!==f.CODES.get("}"))throw new pm("named capture group is missing trailing '}'");a=r.substring(o+1,e);n+=this.group(a),i=e+1}}return i<s&&(n+=r.substring(i,s)),n}appendReplacementInternalPerl(r){let n="",i=0;var s,a=r.length;for(let l=0;l<a-1;l++)if(r.codePointAt(l)===f.CODES.get("$")){let t=r.codePointAt(l+1);if(f.CODES.get("$")===t)i<l&&(n+=r.substring(i,l)),n+="$",l++,i=l+1;else if(f.CODES.get("&")===t){i<l&&(n+=r.substring(i,l));var o=this.group(0);n+=null!==o?o:"$&",l++,i=l+1}else if(f.CODES.get("1")<=t&&t<=f.CODES.get("9")){let e=t-f.CODES.get("0");for(i<l&&(n+=r.substring(i,l)),l+=2;l<a&&!((t=r.codePointAt(l))<f.CODES.get("0")||t>f.CODES.get("9")||10*e+t-f.CODES.get("0")>this.patternGroupCount);l++)e=10*e+t-f.CODES.get("0");e>this.patternGroupCount?(n+="$"+e,i=l,l--):(null!==(o=this.group(e))&&(n+=o),i=l,l--)}else if(t===f.CODES.get("<")){i<l&&(n+=r.substring(i,l));let e=++l+1;for(;e<r.length&&r.codePointAt(e)!==f.CODES.get(">")&&r.codePointAt(e)!==f.CODES.get(" ");)e++;e===r.length||r.codePointAt(e)!==f.CODES.get(">")?(n+=r.substring(l-1,e+1),i=e+1):(s=r.substring(l+1,e),Object.prototype.hasOwnProperty.call(this.namedGroups,s)?n+=this.group(s):n+=`$<${s}>`,i=e+1)}}return i<a&&(n+=r.substring(i,a)),n}appendTail(){return this.substring(this.appendPos,this.matcherInputLength)}replaceAll(e,t=!1){return this.replace(e,!0,t)}replaceFirst(e,t=!1){return this.replace(e,!1,t)}replace(e,t=!0,r=!1){let n="";for(this.reset();this.find()&&(n+=this.appendReplacement(e,r),t););return n+=this.appendTail()}}class mm{static EOF(){return-8}canCheckPrefix(){return!0}endPos(){return this.end}}class vm extends mm{constructor(e,t=0,r=e.length){super(),this.bytes=e,this.start=t,this.end=r}step(e){if((e+=this.start)>=this.end)return mm.EOF();let t=255&this.bytes[e++];return 0==(128&t)?t<<3|1:192==(224&t)?(t&=31,e>=this.end?mm.EOF():(t=t<<6|63&this.bytes[e++])<<3|2):224==(240&t)?(t&=15,e+1>=this.end?mm.EOF():(t=(t=t<<6|63&this.bytes[e++])<<6|63&this.bytes[e++])<<3|3):(t&=7,e+2>=this.end?mm.EOF():(t=(t=(t=t<<6|63&this.bytes[e++])<<6|63&this.bytes[e++])<<6|63&this.bytes[e++])<<3|4)}index(e,t){t+=this.start;var r=this.indexOf(this.bytes,e.prefixUTF8,t);return r<0?r:r-t}context(r){let n=-1;if((r+=this.start)>this.start&&r<=this.end){let t=r-1;if(128<=(n=this.bytes[t--])){let e=r-4;for(e<this.start&&(e=this.start);t>=e&&128==(192&this.bytes[t]);)t--;t<this.start&&(t=this.start),n=this.step(t)>>3}}var e=r<this.end?this.step(r)>>3:-1;return b.emptyOpContext(n,e)}indexOf(r,n,i=0){var s=n.length;if(0!==s){var a=r.length;for(let t=i;t<=a-s;t++)for(let e=0;e<s&&r[t+e]===n[e];e++)if(e===s-1)return t}return-1}}class _m extends mm{constructor(e,t=0,r=e.length){super(),this.charSequence=e,this.start=t,this.end=r}step(e){var t;return(e+=this.start)<this.end?(t=this.charSequence.codePointAt(e))<<3|b.charCount(t):mm.EOF()}index(e,t){t+=this.start;var r=this.charSequence.indexOf(e.prefix,t);return r<0?r:r-t}context(e){var t=0<(e+=this.start)&&e<=this.charSequence.length?this.charSequence.codePointAt(e-1):-1,r=e<this.charSequence.length?this.charSequence.codePointAt(e):-1;return b.emptyOpContext(t,r)}}class ym{static fromUTF8(e,t=0,r=e.length){return new vm(e,t,r)}static fromUTF16(e,t=0,r=e.length){return new _m(e,t,r)}}class I{static Op=sm(["NO_MATCH","EMPTY_MATCH","LITERAL","CHAR_CLASS","ANY_CHAR_NOT_NL","ANY_CHAR","BEGIN_LINE","END_LINE","BEGIN_TEXT","END_TEXT","WORD_BOUNDARY","NO_WORD_BOUNDARY","CAPTURE","STAR","PLUS","QUEST","REPEAT","CONCAT","ALTERNATE","LEFT_PAREN","VERTICAL_BAR"]);static isPseudoOp(e){return e>=I.Op.LEFT_PAREN}static emptySubs(){return[]}static quoteIfHyphen(e){return e===f.CODES.get("-")?"\\":""}static fromRegexp(e){var t=new I(e.op);return t.flags=e.flags,t.subs=e.subs,t.runes=e.runes,t.cap=e.cap,t.min=e.min,t.max=e.max,t.name=e.name,t.namedGroups=e.namedGroups,t}constructor(e){this.op=e,this.flags=0,this.subs=I.emptySubs(),this.runes=null,this.min=0,this.max=0,this.cap=0,this.name=null,this.namedGroups={}}reinit(){this.flags=0,this.subs=I.emptySubs(),this.runes=null,this.cap=0,this.min=0,this.max=0,this.name=null,this.namedGroups={}}toString(){return this.appendTo()}appendTo(){let t="";switch(this.op){case I.Op.NO_MATCH:t+="[^\\x00-\\x{10FFFF}]";break;case I.Op.EMPTY_MATCH:t+="(?:)";break;case I.Op.STAR:case I.Op.PLUS:case I.Op.QUEST:case I.Op.REPEAT:var e=this.subs[0];switch(e.op>I.Op.CAPTURE||e.op===I.Op.LITERAL&&1<e.runes.length?t+=`(?:${e.appendTo()})`:t+=e.appendTo(),this.op){case I.Op.STAR:t+="*";break;case I.Op.PLUS:t+="+";break;case I.Op.QUEST:t+="?";break;case I.Op.REPEAT:t+="{"+this.min,this.min!==this.max&&(t+=",",0<=this.max)&&(t+=this.max),t+="}"}0!=(this.flags&E.NON_GREEDY)&&(t+="?");break;case I.Op.CONCAT:for(var r of this.subs)r.op===I.Op.ALTERNATE?t+=`(?:${r.appendTo()})`:t+=r.appendTo();break;case I.Op.ALTERNATE:{let e="";for(var n of this.subs)t+=e,e="|",t+=n.appendTo();break}case I.Op.LITERAL:0!=(this.flags&E.FOLD_CASE)&&(t+="(?i:");for(var i of this.runes)t+=b.escapeRune(i);0!=(this.flags&E.FOLD_CASE)&&(t+=")");break;case I.Op.ANY_CHAR_NOT_NL:t+="(?-s:.)";break;case I.Op.ANY_CHAR:t+="(?s:.)";break;case I.Op.CAPTURE:null===this.name||0===this.name.length?t+="(":t+=`(?P<${this.name}>`,this.subs[0].op!==I.Op.EMPTY_MATCH&&(t+=this.subs[0].appendTo()),t+=")";break;case I.Op.BEGIN_TEXT:t+="\\A";break;case I.Op.END_TEXT:0!=(this.flags&E.WAS_DOLLAR)?t+="(?-m:$)":t+="\\z";break;case I.Op.BEGIN_LINE:t+="^";break;case I.Op.END_LINE:t+="$";break;case I.Op.WORD_BOUNDARY:t+="\\b";break;case I.Op.NO_WORD_BOUNDARY:t+="\\B";break;case I.Op.CHAR_CLASS:if(this.runes.length%2!=0)t+="[invalid char class]";else{if(t+="[",0===this.runes.length)t+="^\\x00-\\x{10FFFF}";else if(0===this.runes[0]&&this.runes[this.runes.length-1]===c.MAX_RUNE){t+="^";for(let e=1;e<this.runes.length-1;e+=2){var s=this.runes[e]+1,a=this.runes[e+1]-1;t=(t+=I.quoteIfHyphen(s))+b.escapeRune(s),s!==a&&(t=(t=(t+="-")+I.quoteIfHyphen(a))+b.escapeRune(a))}}else for(let e=0;e<this.runes.length;e+=2){var o=this.runes[e],l=this.runes[e+1];t=(t+=I.quoteIfHyphen(o))+b.escapeRune(o),o!==l&&(t=(t=(t+="-")+I.quoteIfHyphen(l))+b.escapeRune(l))}t+="]"}break;default:t+=this.op}return t}maxCap(){let e=0;if(this.op===I.Op.CAPTURE&&(e=this.cap),null!==this.subs)for(var t of this.subs){t=t.maxCap();e<t&&(e=t)}return e}equals(t){if(!(null!==t&&t instanceof I))return!1;if(this.op!==t.op)return!1;switch(this.op){case I.Op.END_TEXT:if((this.flags&E.WAS_DOLLAR)!=(t.flags&E.WAS_DOLLAR))return!1;break;case I.Op.LITERAL:case I.Op.CHAR_CLASS:if(null!==this.runes||null!==t.runes){if(null===this.runes||null===t.runes)return!1;if(this.runes.length!==t.runes.length)return!1;for(let e=0;e<this.runes.length;e++)if(this.runes[e]!==t.runes[e])return!1}break;case I.Op.ALTERNATE:case I.Op.CONCAT:if(this.subs.length!==t.subs.length)return!1;for(let e=0;e<this.subs.length;++e)if(!this.subs[e].equals(t.subs[e]))return!1;break;case I.Op.STAR:case I.Op.PLUS:case I.Op.QUEST:if((this.flags&E.NON_GREEDY)==(t.flags&E.NON_GREEDY)&&this.subs[0].equals(t.subs[0]))break;return!1;case I.Op.REPEAT:if((this.flags&E.NON_GREEDY)==(t.flags&E.NON_GREEDY)&&this.min===t.min&&this.max===t.max&&this.subs[0].equals(t.subs[0]))break;return!1;case I.Op.CAPTURE:if(this.cap!==t.cap||(null===this.name?null!==t.name:this.name!==t.name)||!this.subs[0].equals(t.subs[0]))return!1}return!0}}class T{static ALT=1;static ALT_MATCH=2;static CAPTURE=3;static EMPTY_WIDTH=4;static FAIL=5;static MATCH=6;static NOP=7;static RUNE=8;static RUNE1=9;static RUNE_ANY=10;static RUNE_ANY_NOT_NL=11;static isRuneOp(e){return T.RUNE<=e&&e<=T.RUNE_ANY_NOT_NL}static escapeRunes(e){let t='"';for(var r of e)t+=b.escapeRune(r);return t+='"'}constructor(e){this.op=e,this.out=0,this.arg=0,this.runes=null}matchRune(e){var t;if(1===this.runes.length)return t=this.runes[0],0!=(this.arg&E.FOLD_CASE)?c.equalsIgnoreCase(t,e):e===t;for(let s=0;s<this.runes.length&&s<=8;s+=2){if(e<this.runes[s])return!1;if(e<=this.runes[s+1])return!0}let r=0,n=this.runes.length/2|0;for(;r<n;){var i=r+((n-r)/2|0);if(this.runes[2*i]<=e){if(e<=this.runes[2*i+1])return!0;r=i+1}else n=i}return!1}toString(){switch(this.op){case T.ALT:return`alt -> ${this.out}, `+this.arg;case T.ALT_MATCH:return`altmatch -> ${this.out}, `+this.arg;case T.CAPTURE:return`cap ${this.arg} -> `+this.out;case T.EMPTY_WIDTH:return`empty ${this.arg} -> `+this.out;case T.MATCH:return"match";case T.FAIL:return"fail";case T.NOP:return"nop -> "+this.out;case T.RUNE:return null===this.runes?"rune <null>":["rune ",T.escapeRunes(this.runes),0!=(this.arg&E.FOLD_CASE)?"/i":""," -> ",this.out].join("");case T.RUNE1:return`rune1 ${T.escapeRunes(this.runes)} -> `+this.out;case T.RUNE_ANY:return"any -> "+this.out;case T.RUNE_ANY_NOT_NL:return"anynotnl -> "+this.out;default:throw new Error("unhandled case in Inst.toString")}}}class wm{constructor(){this.inst=[],this.start=0,this.numCap=2}getInst(e){return this.inst[e]}numInst(){return this.inst.length}addInst(e){this.inst.push(new T(e))}skipNop(e){let t=this.inst[e];for(;t.op===T.NOP||t.op===T.CAPTURE;)e=(t=this.inst[e]).out;return t}prefix(){let e="",t=this.skipNop(this.start);if(T.isRuneOp(t.op)&&1===t.runes.length)for(;T.isRuneOp(t.op)&&1===t.runes.length&&0==(t.arg&E.FOLD_CASE);)e+=String.fromCodePoint(t.runes[0]),t=this.skipNop(t.out);return[t.op===T.MATCH,e]}startCond(){let e=0,t=this.start;e:for(;;){var r=this.inst[t];switch(r.op){case T.EMPTY_WIDTH:e|=r.arg;break;case T.FAIL:return-1;case T.CAPTURE:case T.NOP:break;default:break e}t=r.out}return e}next(e){var t=this.inst[e>>1];return 0==(1&e)?t.out:t.arg}patch(e,t){for(;0!==e;){var r=this.inst[e>>1];0==(1&e)?(e=r.out,r.out=t):(e=r.arg,r.arg=t)}}append(t,r){if(0===t)return r;if(0!==r){let e=t;for(;;){var n=this.next(e);if(0===n)break;e=n}var i=this.inst[e>>1];0==(1&e)?i.out=r:i.arg=r}return t}toString(){let e="";for(let r=0;r<this.inst.length;r++){var t=e.length;e+=r,r===this.start&&(e+="*"),e=(e+="        ".substring(e.length-t))+this.inst[r]+"\n"}return e}}class bm{constructor(e=0,t=0,r=!1){this.i=e,this.out=t,this.nullable=r}}class Tm{static ANY_RUNE_NOT_NL(){return[0,f.CODES.get("\n")-1,f.CODES.get("\n")+1,c.MAX_RUNE]}static ANY_RUNE(){return[0,c.MAX_RUNE]}static compileRegexp(e){var t=new Tm,r=t.compile(e);return t.prog.patch(r.out,t.newInst(T.MATCH).i),t.prog.start=r.i,t.prog}constructor(){this.prog=new wm,this.newInst(T.FAIL)}newInst(e){return this.prog.addInst(e),new bm(this.prog.numInst()-1,0,!0)}nop(){var e=this.newInst(T.NOP);return e.out=e.i<<1,e}fail(){return new bm}cap(e){var t=this.newInst(T.CAPTURE);return t.out=t.i<<1,this.prog.getInst(t.i).arg=e,this.prog.numCap<e+1&&(this.prog.numCap=e+1),t}cat(e,t){return 0===e.i||0===t.i?this.fail():(this.prog.patch(e.out,t.i),new bm(e.i,t.out,e.nullable&&t.nullable))}alt(e,t){var r,n;return 0===e.i?t:0===t.i?e:(r=this.newInst(T.ALT),(n=this.prog.getInst(r.i)).out=e.i,n.arg=t.i,r.out=this.prog.append(e.out,t.out),r.nullable=e.nullable||t.nullable,r)}loop(e,t){var r=this.newInst(T.ALT),n=this.prog.getInst(r.i);return t?(n.arg=e.i,r.out=r.i<<1):(n.out=e.i,r.out=r.i<<1|1),this.prog.patch(e.out,r.i),r}quest(e,t){var r=this.newInst(T.ALT),n=this.prog.getInst(r.i);return t?(n.arg=e.i,r.out=r.i<<1):(n.out=e.i,r.out=r.i<<1|1),r.out=this.prog.append(r.out,e.out),r}star(e,t){return e.nullable?this.quest(this.plus(e,t),t):this.loop(e,t)}plus(e,t){return new bm(e.i,this.loop(e,t).out,e.nullable)}empty(e){var t=this.newInst(T.EMPTY_WIDTH);return this.prog.getInst(t.i).arg=e,t.out=t.i<<1,t}rune(e,t){var r=this.newInst(T.RUNE),n=(r.nullable=!1,this.prog.getInst(r.i));return n.runes=e,t&=E.FOLD_CASE,1===e.length&&c.simpleFold(e[0])!==e[0]||(t&=~E.FOLD_CASE),n.arg=t,r.out=r.i<<1,0==(t&E.FOLD_CASE)&&1===e.length||2===e.length&&e[0]===e[1]?n.op=T.RUNE1:2===e.length&&0===e[0]&&e[1]===c.MAX_RUNE?n.op=T.RUNE_ANY:4===e.length&&0===e[0]&&e[1]===f.CODES.get("\n")-1&&e[2]===f.CODES.get("\n")+1&&e[3]===c.MAX_RUNE&&(n.op=T.RUNE_ANY_NOT_NL),r}compile(t){switch(t.op){case I.Op.NO_MATCH:return this.fail();case I.Op.EMPTY_MATCH:return this.nop();case I.Op.LITERAL:if(0===t.runes.length)return this.nop();{let e=null;for(var r of t.runes){r=this.rune([r],t.flags);e=null===e?r:this.cat(e,r)}return e}case I.Op.CHAR_CLASS:return this.rune(t.runes,t.flags);case I.Op.ANY_CHAR_NOT_NL:return this.rune(Tm.ANY_RUNE_NOT_NL(),0);case I.Op.ANY_CHAR:return this.rune(Tm.ANY_RUNE(),0);case I.Op.BEGIN_LINE:return this.empty(b.EMPTY_BEGIN_LINE);case I.Op.END_LINE:return this.empty(b.EMPTY_END_LINE);case I.Op.BEGIN_TEXT:return this.empty(b.EMPTY_BEGIN_TEXT);case I.Op.END_TEXT:return this.empty(b.EMPTY_END_TEXT);case I.Op.WORD_BOUNDARY:return this.empty(b.EMPTY_WORD_BOUNDARY);case I.Op.NO_WORD_BOUNDARY:return this.empty(b.EMPTY_NO_WORD_BOUNDARY);case I.Op.CAPTURE:var e=this.cap(t.cap<<1),n=this.compile(t.subs[0]),i=this.cap(t.cap<<1|1);return this.cat(this.cat(e,n),i);case I.Op.STAR:return this.star(this.compile(t.subs[0]),0!=(t.flags&E.NON_GREEDY));case I.Op.PLUS:return this.plus(this.compile(t.subs[0]),0!=(t.flags&E.NON_GREEDY));case I.Op.QUEST:return this.quest(this.compile(t.subs[0]),0!=(t.flags&E.NON_GREEDY));case I.Op.CONCAT:if(0===t.subs.length)return this.nop();{let e=null;for(var s of t.subs){s=this.compile(s);e=null===e?s:this.cat(e,s)}return e}case I.Op.ALTERNATE:if(0===t.subs.length)return this.nop();{let e=null;for(var a of t.subs){a=this.compile(a);e=null===e?a:this.alt(e,a)}return e}default:throw new dm("regexp: unhandled case in compile")}}}class Em{static simplify(n){if(null===n)return null;switch(n.op){case I.Op.CAPTURE:case I.Op.CONCAT:case I.Op.ALTERNATE:{let e=n;for(let t=0;t<n.subs.length;t++){var r=n.subs[t],i=Em.simplify(r);e===n&&i!==r&&((e=I.fromRegexp(n)).runes=null,e.subs=n.subs.slice(0,n.subs.length)),e!==n&&(e.subs[t]=i)}return e}case I.Op.STAR:case I.Op.PLUS:case I.Op.QUEST:var t=Em.simplify(n.subs[0]);return Em.simplify1(n.op,n.flags,t,n);case I.Op.REPEAT:{if(0===n.min&&0===n.max)return new I(I.Op.EMPTY_MATCH);var s=Em.simplify(n.subs[0]);if(-1===n.max){if(0===n.min)return Em.simplify1(I.Op.STAR,n.flags,s,null);if(1===n.min)return Em.simplify1(I.Op.PLUS,n.flags,s,null);var t=new I(I.Op.CONCAT),a=[];for(let e=0;e<n.min-1;e++)a.push(s);return a.push(Em.simplify1(I.Op.PLUS,n.flags,s,null)),t.subs=a.slice(0),t}if(1===n.min&&1===n.max)return s;let r=null;if(0<n.min){r=[];for(let e=0;e<n.min;e++)r.push(s)}if(n.min<n.max){let e=Em.simplify1(I.Op.QUEST,n.flags,s,null);for(let t=n.min+1;t<n.max;t++){var o=new I(I.Op.CONCAT);o.subs=[s,e],e=Em.simplify1(I.Op.QUEST,n.flags,o,null)}if(null===r)return e;r.push(e)}return null!==r?((t=new I(I.Op.CONCAT)).subs=r.slice(0),t):new I(I.Op.NO_MATCH)}}return n}static simplify1(e,t,r,n){return r.op===I.Op.EMPTY_MATCH||e===r.op&&(t&E.NON_GREEDY)==(r.flags&E.NON_GREEDY)?r:(null!==n&&n.op===e&&(n.flags&E.NON_GREEDY)==(t&E.NON_GREEDY)&&r===n.subs[0]||((n=new I(e)).flags=t,n.subs=[r]),n)}}class Im{constructor(e,t){this.sign=e,this.cls=t}}e=[48,57],ur=[9,10,12,13,32,32],lr=[48,57,65,90,95,95,97,122];let Cm=new Map([["\\d",new Im(1,e)],["\\D",new Im(-1,e)],["\\s",new Im(1,ur)],["\\S",new Im(-1,ur)],["\\w",new Im(1,lr)],["\\W",new Im(-1,lr)]]);var Sm,km,e=[48,57,65,90,97,122],ur=[65,90,97,122],lr=[0,127],Am=[9,9,32,32],Nm=[0,31,127,127],Rm=[48,57],Pm=[33,126],xm=[97,122],Dm=[32,126],Om=[33,47,58,64,91,96,123,126],Lm=[9,13,32,32],Mm=[65,90],Fm=[48,57,65,90,95,95,97,122],Um=[48,57,65,70,97,102];let Vm=new Map([["[:alnum:]",new Im(1,e)],["[:^alnum:]",new Im(-1,e)],["[:alpha:]",new Im(1,ur)],["[:^alpha:]",new Im(-1,ur)],["[:ascii:]",new Im(1,lr)],["[:^ascii:]",new Im(-1,lr)],["[:blank:]",new Im(1,Am)],["[:^blank:]",new Im(-1,Am)],["[:cntrl:]",new Im(1,Nm)],["[:^cntrl:]",new Im(-1,Nm)],["[:digit:]",new Im(1,Rm)],["[:^digit:]",new Im(-1,Rm)],["[:graph:]",new Im(1,Pm)],["[:^graph:]",new Im(-1,Pm)],["[:lower:]",new Im(1,xm)],["[:^lower:]",new Im(-1,xm)],["[:print:]",new Im(1,Dm)],["[:^print:]",new Im(-1,Dm)],["[:punct:]",new Im(1,Om)],["[:^punct:]",new Im(-1,Om)],["[:space:]",new Im(1,Lm)],["[:^space:]",new Im(-1,Lm)],["[:upper:]",new Im(1,Mm)],["[:^upper:]",new Im(-1,Mm)],["[:word:]",new Im(1,Fm)],["[:^word:]",new Im(-1,Fm)],["[:xdigit:]",new Im(1,Um)],["[:^xdigit:]",new Im(-1,Um)]]);class Bm{static charClassToString(e,t){let r="[";for(let s=0;s<t;s+=2){0<s&&(r+=" ");var n=e[s],i=e[s+1];r+=n===i?"0x"+n.toString(16):`0x${n.toString(16)}-0x`+i.toString(16)}return r+="]"}static cmp(e,t,r,n){var i=e[t]-r;return 0!=i?i:n-e[t+1]}static qsortIntPair(e,t,r){var n,i=-2&((t+r)/2|0),s=e[i],a=e[1+i];let o=t,l=r;for(;o<=l;){for(;o<r&&Bm.cmp(e,o,s,a)<0;)o+=2;for(;l>t&&0<Bm.cmp(e,l,s,a);)l-=2;o<=l&&(o!==l&&(n=e[o],e[o]=e[l],e[l]=n,n=e[o+1],e[o+1]=e[l+1],e[l+1]=n),o+=2,l-=2)}t<l&&Bm.qsortIntPair(e,t,l),o<r&&Bm.qsortIntPair(e,o,r)}constructor(e=b.emptyInts()){this.r=e,this.len=e.length}toArray(){return this.len===this.r.length?this.r:this.r.slice(0,this.len)}cleanClass(){if(!(this.len<4)){Bm.qsortIntPair(this.r,0,this.len-2);let e=2;for(let t=2;t<this.len;t+=2){var r=this.r[t],n=this.r[t+1];r<=this.r[e-1]+1?n>this.r[e-1]&&(this.r[e-1]=n):(this.r[e]=r,this.r[e+1]=n,e+=2)}this.len=e}return this}appendLiteral(e,t){return 0!=(t&E.FOLD_CASE)?this.appendFoldedRange(e,e):this.appendRange(e,e)}appendRange(t,r){if(0<this.len)for(let e=2;e<=4;e+=2)if(this.len>=e){var n=this.r[this.len-e],i=this.r[this.len-e+1];if(t<=i+1&&n<=r+1)return t<n&&(this.r[this.len-e]=t),i<r&&(this.r[this.len-e+1]=r),this}return this.r[this.len++]=t,this.r[this.len++]=r,this}appendFoldedRange(e,t){if(e<=c.MIN_FOLD&&t>=c.MAX_FOLD)return this.appendRange(e,t);if(t<c.MIN_FOLD||e>c.MAX_FOLD)return this.appendRange(e,t);e<c.MIN_FOLD&&(this.appendRange(e,c.MIN_FOLD-1),e=c.MIN_FOLD),t>c.MAX_FOLD&&(this.appendRange(c.MAX_FOLD+1,t),t=c.MAX_FOLD);for(let r=e;r<=t;r++){this.appendRange(r,r);for(let e=c.simpleFold(r);e!==r;e=c.simpleFold(e))this.appendRange(e,e)}return this}appendClass(e){for(let t=0;t<e.length;t+=2)this.appendRange(e[t],e[t+1]);return this}appendFoldedClass(e){for(let t=0;t<e.length;t+=2)this.appendFoldedRange(e[t],e[t+1]);return this}appendNegatedClass(e){let t=0;for(let i=0;i<e.length;i+=2){var r=e[i],n=e[i+1];t<=r-1&&this.appendRange(t,r-1),t=n+1}return t<=c.MAX_RUNE&&this.appendRange(t,c.MAX_RUNE),this}appendTable(e){for(var t of e){var r=t[0],n=t[1],i=t[2];if(1===i)this.appendRange(r,n);else for(let e=r;e<=n;e+=i)this.appendRange(e,e)}return this}appendNegatedTable(e){let t=0;for(var r of e){var n=r[0],i=r[1],s=r[2];if(1===s)t<=n-1&&this.appendRange(t,n-1),t=i+1;else for(let e=n;e<=i;e+=s)t<=e-1&&this.appendRange(t,e-1),t=e+1}return t<=c.MAX_RUNE&&this.appendRange(t,c.MAX_RUNE),this}appendTableWithSign(e,t){return t<0?this.appendNegatedTable(e):this.appendTable(e)}negateClass(){let e=0,t=0;for(let i=0;i<this.len;i+=2){var r=this.r[i],n=this.r[i+1];e<=r-1&&(this.r[t]=e,this.r[t+1]=r-1,t+=2),e=n+1}return this.len=t,e<=c.MAX_RUNE&&(this.r[this.len++]=e,this.r[this.len++]=c.MAX_RUNE),this}appendClassWithSign(e,t){return t<0?this.appendNegatedClass(e):this.appendClass(e)}appendGroup(e,t){let r=e.cls;return t&&(r=(new Bm).appendFoldedClass(r).cleanClass().toArray()),this.appendClassWithSign(r,e.sign)}toString(){return Bm.charClassToString(this.r,this.len)}}class qm{static of(e,t){return new qm(e,t)}constructor(e,t){this.first=e,this.second=t}}class jm{constructor(e){this.str=e,this.position=0}pos(){return this.position}rewindTo(e){this.position=e}more(){return this.position<this.str.length}peek(){return this.str.codePointAt(this.position)}skip(e){this.position+=e}skipString(e){this.position+=e.length}pop(){var e=this.str.codePointAt(this.position);return this.position+=b.charCount(e),e}lookingAt(e){return this.rest().startsWith(e)}rest(){return this.str.substring(this.position)}from(e){return this.str.substring(e,this.position)}toString(){return this.rest()}}class C{static ERR_INTERNAL_ERROR="regexp/syntax: internal error";static ERR_INVALID_CHAR_RANGE="invalid character class range";static ERR_INVALID_ESCAPE="invalid escape sequence";static ERR_INVALID_NAMED_CAPTURE="invalid named capture";static ERR_INVALID_PERL_OP="invalid or unsupported Perl syntax";static ERR_INVALID_REPEAT_OP="invalid nested repetition operator";static ERR_INVALID_REPEAT_SIZE="invalid repeat count";static ERR_MISSING_BRACKET="missing closing ]";static ERR_MISSING_PAREN="missing closing )";static ERR_MISSING_REPEAT_ARGUMENT="missing argument to repetition operator";static ERR_TRAILING_BACKSLASH="trailing backslash at end of expression";static ERR_DUPLICATE_NAMED_CAPTURE="duplicate capture group name";static ANY_TABLE(){return[[0,c.MAX_RUNE,1]]}static unicodeTable(e){return"Any"===e?qm.of(C.ANY_TABLE(),C.ANY_TABLE()):r.CATEGORIES.has(e)?qm.of(r.CATEGORIES.get(e),r.FOLD_CATEGORIES.get(e)):r.SCRIPTS.has(e)?qm.of(r.SCRIPTS.get(e),r.FOLD_SCRIPT.get(e)):null}static minFoldRune(e){if(e<c.MIN_FOLD||e>c.MAX_FOLD)return e;let t=e;var r=e;for(e=c.simpleFold(e);e!==r;e=c.simpleFold(e))t>e&&(t=e);return t}static leadingRegexp(e){var t;return e.op===I.Op.EMPTY_MATCH?null:e.op===I.Op.CONCAT&&0<e.subs.length?(t=e.subs[0]).op===I.Op.EMPTY_MATCH?null:t:e}static literalRegexp(e,t){var r=new I(I.Op.LITERAL);return r.flags=t,r.runes=b.stringToRunes(e),r}static parse(e,t){return new C(e,t).parseInternal()}static parseRepeat(e){var t=e.pos();if(!e.more()||!e.lookingAt("{"))return-1;e.skip(1);var r=C.parseInt(e);if(-1===r)return-1;if(!e.more())return-1;let n;if(e.lookingAt(",")){if(e.skip(1),!e.more())return-1;if(e.lookingAt("}"))n=-1;else if(-1===(n=C.parseInt(e)))return-1}else n=r;if(!e.more()||!e.lookingAt("}"))return-1;if(e.skip(1),r<0||1e3<r||-2===n||1e3<n||0<=n&&r>n)throw new cm(C.ERR_INVALID_REPEAT_SIZE,e.from(t));return r<<16|n&c.MAX_BMP}static isValidCaptureName(e){if(0===e.length)return!1;for(let r=0;r<e.length;r++){var t=e.codePointAt(r);if(t!==f.CODES.get("_")&&!b.isalnum(t))return!1}return!0}static parseInt(e){for(var t=e.pos();e.more()&&e.peek()>=f.CODES.get("0")&&e.peek()<=f.CODES.get("9");)e.skip(1);t=e.from(t);return 0===t.length||1<t.length&&t.codePointAt(0)===f.CODES.get("0")?-1:8<t.length?-2:parseFloat(t,10)}static isCharClass(e){return e.op===I.Op.LITERAL&&1===e.runes.length||e.op===I.Op.CHAR_CLASS||e.op===I.Op.ANY_CHAR_NOT_NL||e.op===I.Op.ANY_CHAR}static matchRune(t,r){switch(t.op){case I.Op.LITERAL:return 1===t.runes.length&&t.runes[0]===r;case I.Op.CHAR_CLASS:for(let e=0;e<t.runes.length;e+=2)if(t.runes[e]<=r&&r<=t.runes[e+1])return!0;return!1;case I.Op.ANY_CHAR_NOT_NL:return r!==f.CODES.get("\n");case I.Op.ANY_CHAR:return!0}return!1}static mergeCharClass(e,t){switch(e.op){case I.Op.ANY_CHAR:break;case I.Op.ANY_CHAR_NOT_NL:C.matchRune(t,f.CODES.get("\n"))&&(e.op=I.Op.ANY_CHAR);break;case I.Op.CHAR_CLASS:t.op===I.Op.LITERAL?e.runes=new Bm(e.runes).appendLiteral(t.runes[0],t.flags).toArray():e.runes=new Bm(e.runes).appendClass(t.runes).toArray();break;case I.Op.LITERAL:t.runes[0]===e.runes[0]&&t.flags===e.flags||(e.op=I.Op.CHAR_CLASS,e.runes=(new Bm).appendLiteral(e.runes[0],e.flags).appendLiteral(t.runes[0],t.flags).toArray())}}static parseEscape(r){var e=r.pos();if(r.skip(1),!r.more())throw new cm(C.ERR_TRAILING_BACKSLASH);let n=r.pop();e:switch(n){case f.CODES.get("1"):case f.CODES.get("2"):case f.CODES.get("3"):case f.CODES.get("4"):case f.CODES.get("5"):case f.CODES.get("6"):case f.CODES.get("7"):if(!r.more()||r.peek()<f.CODES.get("0")||r.peek()>f.CODES.get("7"))break;case f.CODES.get("0"):{let e=n-f.CODES.get("0");for(let t=1;t<3&&!(!r.more()||r.peek()<f.CODES.get("0")||r.peek()>f.CODES.get("7"));t++)e=8*e+r.peek()-f.CODES.get("0"),r.skip(1);return e}case f.CODES.get("x"):if(!r.more())break;if((n=r.pop())===f.CODES.get("{")){let e=0,t=0;for(;;){if(!r.more())break e;if((n=r.pop())===f.CODES.get("}"))break;var i=b.unhex(n);if(i<0)break e;if((t=16*t+i)>c.MAX_RUNE)break e;e++}if(0===e)break;return t}var t=b.unhex(n);if(!r.more())break;n=r.pop();var s=b.unhex(n);if(t<0||s<0)break;return 16*t+s;case f.CODES.get("a"):return f.CODES.get("");case f.CODES.get("f"):return f.CODES.get("\f");case f.CODES.get("n"):return f.CODES.get("\n");case f.CODES.get("r"):return f.CODES.get("\r");case f.CODES.get("t"):return f.CODES.get("\t");case f.CODES.get("v"):return f.CODES.get("\v");default:if(b.isalnum(n))break;return n}throw new cm(C.ERR_INVALID_ESCAPE,r.from(e))}static parseClassChar(e,t){if(e.more())return e.lookingAt("\\")?C.parseEscape(e):e.pop();throw new cm(C.ERR_MISSING_BRACKET,e.from(t))}static concatRunes(e,t){return[...e,...t]}constructor(e,t=0){this.wholeRegexp=e,this.flags=t,this.numCap=0,this.namedGroups={},this.stack=[],this.free=null}newRegexp(e){let t=this.free;return null!==t&&null!==t.subs&&0<t.subs.length?(this.free=t.subs[0],t.reinit(),t.op=e):t=new I(e),t}reuse(e){null!==e.subs&&0<e.subs.length&&(e.subs[0]=this.free),this.free=e}pop(){return this.stack.pop()}popToPseudo(){var e=this.stack.length;let t=e;for(;0<t&&!I.isPseudoOp(this.stack[t-1].op);)t--;e=this.stack.slice(t,e);return this.stack=this.stack.slice(0,t),e}push(e){if(e.op===I.Op.CHAR_CLASS&&2===e.runes.length&&e.runes[0]===e.runes[1]){if(this.maybeConcat(e.runes[0],this.flags&~E.FOLD_CASE))return null;e.op=I.Op.LITERAL,e.runes=[e.runes[0]],e.flags=this.flags&~E.FOLD_CASE}else if(e.op===I.Op.CHAR_CLASS&&4===e.runes.length&&e.runes[0]===e.runes[1]&&e.runes[2]===e.runes[3]&&c.simpleFold(e.runes[0])===e.runes[2]&&c.simpleFold(e.runes[2])===e.runes[0]||e.op===I.Op.CHAR_CLASS&&2===e.runes.length&&e.runes[0]+1===e.runes[1]&&c.simpleFold(e.runes[0])===e.runes[1]&&c.simpleFold(e.runes[1])===e.runes[0]){if(this.maybeConcat(e.runes[0],this.flags|E.FOLD_CASE))return null;e.op=I.Op.LITERAL,e.runes=[e.runes[0]],e.flags=this.flags|E.FOLD_CASE}else this.maybeConcat(-1,0);return this.stack.push(e),e}maybeConcat(e,t){var r=this.stack.length;if(!(r<2)){var n=this.stack[r-1],r=this.stack[r-2];if(n.op===I.Op.LITERAL&&r.op===I.Op.LITERAL&&(n.flags&E.FOLD_CASE)==(r.flags&E.FOLD_CASE)){if(r.runes=C.concatRunes(r.runes,n.runes),0<=e)return n.runes=[e],n.flags=t,!0;this.pop(),this.reuse(n)}}return!1}newLiteral(e,t){var r=this.newRegexp(I.Op.LITERAL);return 0!=((r.flags=t)&E.FOLD_CASE)&&(e=C.minFoldRune(e)),r.runes=[e],r}literal(e){this.push(this.newLiteral(e,this.flags))}op(e){var t=this.newRegexp(e);return t.flags=this.flags,this.push(t)}repeat(e,t,r,n,i,s){let a=this.flags;if(0!=(a&E.PERL_X)&&(i.more()&&i.lookingAt("?")&&(i.skip(1),a^=E.NON_GREEDY),-1!==s))throw new cm(C.ERR_INVALID_REPEAT_OP,i.from(s));var o=this.stack.length;if(0===o)throw new cm(C.ERR_MISSING_REPEAT_ARGUMENT,i.from(n));var l=this.stack[o-1];if(I.isPseudoOp(l.op))throw new cm(C.ERR_MISSING_REPEAT_ARGUMENT,i.from(n));var u=this.newRegexp(e);u.min=t,u.max=r,u.flags=a,u.subs=[l],this.stack[o-1]=u}concat(){this.maybeConcat(-1,0);var e=this.popToPseudo();return 0===e.length?this.push(this.newRegexp(I.Op.EMPTY_MATCH)):this.push(this.collapse(e,I.Op.CONCAT))}alternate(){var e=this.popToPseudo();return 0<e.length&&this.cleanAlt(e[e.length-1]),0===e.length?this.push(this.newRegexp(I.Op.NO_MATCH)):this.push(this.collapse(e,I.Op.ALTERNATE))}cleanAlt(e){e.op===I.Op.CHAR_CLASS&&(e.runes=new Bm(e.runes).cleanClass().toArray(),2===e.runes.length&&0===e.runes[0]&&e.runes[1]===c.MAX_RUNE?(e.runes=null,e.op=I.Op.ANY_CHAR):4===e.runes.length&&0===e.runes[0]&&e.runes[1]===f.CODES.get("\n")-1&&e.runes[2]===f.CODES.get("\n")+1&&e.runes[3]===c.MAX_RUNE&&(e.runes=null,e.op=I.Op.ANY_CHAR_NOT_NL))}collapse(e,t){if(1===e.length)return e[0];let r=0;for(var n of e)r+=n.op===t?n.subs.length:1;var i,s,a=new Array(r).fill(null);let o=0;for(i of e)i.op===t?(a.splice(o,i.subs.length,...i.subs),o+=i.subs.length,this.reuse(i)):a[o++]=i;let l=this.newRegexp(t);return l.subs=a,t===I.Op.ALTERNATE&&(l.subs=this.factor(l.subs),1===l.subs.length)&&(l=(s=l).subs[0],this.reuse(s)),l}factor(i){if(i.length<2)return i;let s=0,a=i.length,o=0,l=null,u=0,h=0,c=0;for(let w=0;w<=a;w++){let t=null,r=0,n=0;if(w<a){let e=i[s+w];if((e=e.op===I.Op.CONCAT&&0<e.subs.length?e.subs[0]:e).op===I.Op.LITERAL&&(t=e.runes,r=e.runes.length,n=e.flags&E.FOLD_CASE),n===h){let e=0;for(;e<u&&e<r&&l[e]===t[e];)e++;if(0<e){u=e;continue}}}if(w!==c)if(w===c+1)i[o++]=i[s+c];else{var d=this.newRegexp(I.Op.LITERAL);d.flags=h,d.runes=l.slice(0,u);for(let e=c;e<w;e++)i[s+e]=this.removeLeadingString(i[s+e],u);var p=this.collapse(i.slice(s+c,s+w),I.Op.ALTERNATE),f=this.newRegexp(I.Op.CONCAT);f.subs=[d,p],i[o++]=f}c=w,l=t,u=r,h=n}a=o,s=0,c=0;let t=null;for(let b=o=0;b<=a;b++){let e=null;if(!(b<a&&(e=C.leadingRegexp(i[s+b]),null!==t)&&t.equals(e)&&(C.isCharClass(t)||t.op===I.Op.REPEAT&&t.min===t.max&&C.isCharClass(t.subs[0])))){if(b!==c)if(b===c+1)i[o++]=i[s+c];else{var r=t;for(let e=c;e<b;e++){var n=e!==c;i[s+e]=this.removeLeadingRegexp(i[s+e],n)}var g=this.collapse(i.slice(s+c,s+b),I.Op.ALTERNATE),m=this.newRegexp(I.Op.CONCAT);m.subs=[r,g],i[o++]=m}c=b,t=e}}a=o,s=0,c=0;for(let T=o=0;T<=a;T++)if(!(T<a&&C.isCharClass(i[s+T]))){if(T!==c){if(T!==c+1){let e=c;for(let t=c+1;t<T;t++){var v=i[s+e],_=i[s+t];(v.op<_.op||v.op===_.op&&(null!==v.runes?v.runes.length:0)<(null!==_.runes?_.runes.length:0))&&(e=t)}var y=i[s+c];i[s+c]=i[s+e],i[s+e]=y;for(let r=c+1;r<T;r++)C.mergeCharClass(i[s+c],i[s+r]),this.reuse(i[s+r]);this.cleanAlt(i[s+c])}i[o++]=i[s+c]}T<a&&(i[o++]=i[s+T]),c=T+1}a=o,s=0,c=0;for(let e=o=0;e<a;++e)e+1<a&&i[s+e].op===I.Op.EMPTY_MATCH&&i[s+e+1].op===I.Op.EMPTY_MATCH||(i[o++]=i[s+e]);return a=o,s=0,i.slice(s,a)}removeLeadingString(e,t){if(e.op===I.Op.CONCAT&&0<e.subs.length){var r=this.removeLeadingString(e.subs[0],t);if((e.subs[0]=r).op===I.Op.EMPTY_MATCH)switch(this.reuse(r),e.subs.length){case 0:case 1:e.op=I.Op.EMPTY_MATCH,e.subs=null;break;case 2:var n=e;e=e.subs[1],this.reuse(n);break;default:e.subs=e.subs.slice(1,e.subs.length)}}else e.op===I.Op.LITERAL&&(e.runes=e.runes.slice(t,e.runes.length),0===e.runes.length)&&(e.op=I.Op.EMPTY_MATCH);return e}removeLeadingRegexp(e,t){if(e.op===I.Op.CONCAT&&0<e.subs.length){switch(t&&this.reuse(e.subs[0]),e.subs=e.subs.slice(1,e.subs.length),e.subs.length){case 0:e.op=I.Op.EMPTY_MATCH,e.subs=I.emptySubs();break;case 1:var r=e;e=e.subs[0],this.reuse(r)}return e}return t&&this.reuse(e),this.newRegexp(I.Op.EMPTY_MATCH)}parseInternal(){if(0!=(this.flags&E.LITERAL))return C.literalRegexp(this.wholeRegexp,this.flags);let r=-1,n=-1,i=-1;for(var s=new jm(this.wholeRegexp);s.more();){let t=-1;e:switch(s.peek()){case f.CODES.get("("):0!=(this.flags&E.PERL_X)&&s.lookingAt("(?")?this.parsePerlFlags(s):(this.op(I.Op.LEFT_PAREN).cap=++this.numCap,s.skip(1));break;case f.CODES.get("|"):this.parseVerticalBar(),s.skip(1);break;case f.CODES.get(")"):this.parseRightParen(),s.skip(1);break;case f.CODES.get("^"):0!=(this.flags&E.ONE_LINE)?this.op(I.Op.BEGIN_TEXT):this.op(I.Op.BEGIN_LINE),s.skip(1);break;case f.CODES.get("$"):0!=(this.flags&E.ONE_LINE)?this.op(I.Op.END_TEXT).flags|=E.WAS_DOLLAR:this.op(I.Op.END_LINE),s.skip(1);break;case f.CODES.get("."):0!=(this.flags&E.DOT_NL)?this.op(I.Op.ANY_CHAR):this.op(I.Op.ANY_CHAR_NOT_NL),s.skip(1);break;case f.CODES.get("["):this.parseClass(s);break;case f.CODES.get("*"):case f.CODES.get("+"):case f.CODES.get("?"):{t=s.pos();let e=null;switch(s.pop()){case f.CODES.get("*"):e=I.Op.STAR;break;case f.CODES.get("+"):e=I.Op.PLUS;break;case f.CODES.get("?"):e=I.Op.QUEST}this.repeat(e,n,i,t,s,r);break}case f.CODES.get("{"):t=s.pos();var e=C.parseRepeat(s);e<0?(s.rewindTo(t),this.literal(s.pop())):(n=e>>16,i=(e&c.MAX_BMP)<<16>>16,this.repeat(I.Op.REPEAT,n,i,t,s,r));break;case f.CODES.get("\\"):var a=s.pos();if(s.skip(1),0!=(this.flags&E.PERL_X)&&s.more())switch(s.pop()){case f.CODES.get("A"):this.op(I.Op.BEGIN_TEXT);break e;case f.CODES.get("b"):this.op(I.Op.WORD_BOUNDARY);break e;case f.CODES.get("B"):this.op(I.Op.NO_WORD_BOUNDARY);break e;case f.CODES.get("C"):throw new cm(C.ERR_INVALID_ESCAPE,"\\C");case f.CODES.get("Q"):{let e=s.rest();var o=e.indexOf("\\E");0<=o&&(e=e.substring(0,o)),s.skipString(e),s.skipString("\\E");let t=0;for(;t<e.length;){var l=e.codePointAt(t);this.literal(l),t+=b.charCount(l)}break e}case f.CODES.get("z"):this.op(I.Op.END_TEXT);break e;default:s.rewindTo(a)}var u=this.newRegexp(I.Op.CHAR_CLASS);if(u.flags=this.flags,s.lookingAt("\\p")||s.lookingAt("\\P")){e=new Bm;if(this.parseUnicodeClass(s,e)){u.runes=e.toArray(),this.push(u);break}}var h=new Bm;this.parsePerlClassEscape(s,h)?(u.runes=h.toArray(),this.push(u)):(s.rewindTo(a),this.reuse(u),this.literal(C.parseEscape(s)));break;default:this.literal(s.pop())}r=t}if(this.concat(),this.swapVerticalBar()&&this.pop(),this.alternate(),1!==this.stack.length)throw new cm(C.ERR_MISSING_PAREN,this.wholeRegexp);return this.stack[0].namedGroups=this.namedGroups,this.stack[0]}parsePerlFlags(n){var i=n.pos(),e=n.rest();if(!e.startsWith("(?P<")&&!e.startsWith("(?<")){n.skip(2);let e=this.flags,t=1,r=!1;e:for(;n.more();){var s=n.pop();switch(s){case f.CODES.get("i"):e|=E.FOLD_CASE,r=!0;break;case f.CODES.get("m"):e&=~E.ONE_LINE,r=!0;break;case f.CODES.get("s"):e|=E.DOT_NL,r=!0;break;case f.CODES.get("U"):e|=E.NON_GREEDY,r=!0;break;case f.CODES.get("-"):if(t<0)break e;t=-1,e=~e,r=!1;break;case f.CODES.get(":"):case f.CODES.get(")"):if(t<0){if(!r)break e;e=~e}return s===f.CODES.get(":")&&this.op(I.Op.LEFT_PAREN),void(this.flags=e);default:break e}}throw new cm(C.ERR_INVALID_PERL_OP,n.from(i))}var i="P"===e.charAt(2)?4:3,t=e.indexOf(">");if(t<0)throw new cm(C.ERR_INVALID_NAMED_CAPTURE,e);var r=e.substring(i,t);if(n.skipString(r),n.skip(1+i),!C.isValidCaptureName(r))throw new cm(C.ERR_INVALID_NAMED_CAPTURE,e.substring(0,t+1));i=this.op(I.Op.LEFT_PAREN);if(i.cap=++this.numCap,this.namedGroups[r])throw new cm(C.ERR_DUPLICATE_NAMED_CAPTURE,r);this.namedGroups[r]=this.numCap,i.name=r}parseVerticalBar(){this.concat(),this.swapVerticalBar()||this.op(I.Op.VERTICAL_BAR)}swapVerticalBar(){var r=this.stack.length;if(3<=r&&this.stack[r-2].op===I.Op.VERTICAL_BAR&&C.isCharClass(this.stack[r-1])&&C.isCharClass(this.stack[r-3])){let e=this.stack[r-1],t=this.stack[r-3];return e.op>t.op&&(n=t,t=e,e=n,this.stack[r-3]=t),C.mergeCharClass(t,e),this.reuse(e),this.pop(),!0}if(2<=r){var n=this.stack[r-1],e=this.stack[r-2];if(e.op===I.Op.VERTICAL_BAR)return 3<=r&&this.cleanAlt(this.stack[r-3]),this.stack[r-2]=n,this.stack[r-1]=e,!0}return!1}parseRightParen(){if(this.concat(),this.swapVerticalBar()&&this.pop(),this.alternate(),this.stack.length<2)throw new cm(C.ERR_INTERNAL_ERROR,"stack underflow");var e=this.pop(),t=this.pop();if(t.op!==I.Op.LEFT_PAREN)throw new cm(C.ERR_MISSING_PAREN,this.wholeRegexp);this.flags=t.flags,0===t.cap?this.push(e):(t.op=I.Op.CAPTURE,t.subs=[e],this.push(t))}parsePerlClassEscape(e,t){var r=e.pos();if(0==(this.flags&E.PERL_X)||!e.more()||e.pop()!==f.CODES.get("\\")||!e.more())return!1;e.pop();r=e.from(r),r=Cm.has(r)?Cm.get(r):null;return null!==r&&(t.appendGroup(r,0!=(this.flags&E.FOLD_CASE)),!0)}parseNamedClass(e,t){var r=e.rest(),n=r.indexOf(":]");if(n<0)return!1;r=r.substring(0,n+2),e.skipString(r),n=Vm.has(r)?Vm.get(r):null;if(null===n)throw new cm(C.ERR_INVALID_CHAR_RANGE,r);return t.appendGroup(n,0!=(this.flags&E.FOLD_CASE)),!0}parseUnicodeClass(e,t){var r=e.pos();if(0==(this.flags&E.UNICODE_GROUPS)||!e.lookingAt("\\p")&&!e.lookingAt("\\P"))return!1;e.skip(1);let n=1;if(e.pop()===f.CODES.get("P")&&(n=-1),!e.more())throw e.rewindTo(r),new cm(C.ERR_INVALID_CHAR_RANGE,e.rest());let i;if((s=e.pop())!==f.CODES.get("{"))i=b.runeToString(s);else{var s=e.rest(),a=s.indexOf("}");if(a<0)throw e.rewindTo(r),new cm(C.ERR_INVALID_CHAR_RANGE,e.rest());i=s.substring(0,a),e.skipString(i),e.skip(1)}0!==i.length&&i.codePointAt(0)===f.CODES.get("^")&&(n=0-n,i=i.substring(1));s=C.unicodeTable(i);if(null===s)throw new cm(C.ERR_INVALID_CHAR_RANGE,e.from(r));a=s.first,r=s.second;return 0==(this.flags&E.FOLD_CASE)||null===r?t.appendTableWithSign(a,n):(s=(new Bm).appendTable(a).appendTable(r).cleanClass().toArray(),t.appendClassWithSign(s,n)),!0}parseClass(t){var r=t.pos(),e=(t.skip(1),this.newRegexp(I.Op.CHAR_CLASS)),n=(e.flags=this.flags,new Bm);let i=1,s=(t.more()&&t.lookingAt("^")&&(i=-1,t.skip(1),0==(this.flags&E.CLASS_NL))&&n.appendRange(f.CODES.get("\n"),f.CODES.get("\n")),!0);for(;!t.more()||t.peek()!==f.CODES.get("]")||s;){if(t.more()&&t.lookingAt("-")&&0==(this.flags&E.PERL_X)&&!s){var a=t.rest();if("-"===a||!a.startsWith("-]"))throw t.rewindTo(r),new cm(C.ERR_INVALID_CHAR_RANGE,t.rest())}s=!1;a=t.pos();if(t.lookingAt("[:")){if(this.parseNamedClass(t,n))continue;t.rewindTo(a)}if(!this.parseUnicodeClass(t,n)&&!this.parsePerlClassEscape(t,n)){t.rewindTo(a);var o=C.parseClassChar(t,r);let e=o;if(t.more()&&t.lookingAt("-"))if(t.skip(1),t.more()&&t.lookingAt("]"))t.skip(-1);else if((e=C.parseClassChar(t,r))<o)throw new cm(C.ERR_INVALID_CHAR_RANGE,t.from(a));0==(this.flags&E.FOLD_CASE)?n.appendRange(o,e):n.appendFoldedRange(o,e)}}t.skip(1),n.cleanClass(),i<0&&n.negateClass(),e.runes=n.toArray(),this.push(e)}}class zm{constructor(){this.inst=null,this.cap=[]}}class Hm{constructor(){this.sparse=[],this.densePcs=[],this.denseThreads=[],this.size=0}contains(e){var t=this.sparse[e];return t<this.size&&this.densePcs[t]===e}isEmpty(){return 0===this.size}add(e){var t=this.size++;return this.sparse[e]=t,this.denseThreads[t]=null,this.densePcs[t]=e,t}clear(){this.sparse=[],this.densePcs=[],this.denseThreads=[],this.size=0}toString(){let e="{";for(let t=0;t<this.size;t++)0!==t&&(e+=", "),e+=this.densePcs[t];return e+="}"}}class Km{static fromRE2(e){var t=new Km;return t.prog=e.prog,t.re2=e,t.q0=new Hm(t.prog.numInst()),t.q1=new Hm(t.prog.numInst()),t.pool=[],t.poolSize=0,t.matched=!1,t.matchcap=Array(t.prog.numCap<2?2:t.prog.numCap).fill(0),t.ncap=0,t}static fromMachine(e){var t=new Km;return t.re2=e.re2,t.prog=e.prog,t.q0=e.q0,t.q1=e.q1,t.pool=e.pool,t.poolSize=e.poolSize,t.matched=e.matched,t.matchcap=e.matchcap,t.ncap=e.ncap,t}init(e){(this.ncap=e)>this.matchcap.length?this.initNewCap(e):this.resetCap(e)}resetCap(e){for(let t=0;t<this.poolSize;t++)this.pool[t].cap=Array(e).fill(0)}initNewCap(e){for(let t=0;t<this.poolSize;t++)this.pool[t].cap=Array(e).fill(0);this.matchcap=Array(e).fill(0)}submatches(){return 0===this.ncap?b.emptyInts():this.matchcap.slice(0,this.ncap)}alloc(e){let t;return(t=0<this.poolSize?(this.poolSize--,this.pool[this.poolSize]):new zm).inst=e,t}freeQueue(e,t=0){var r=e.size-t,r=this.poolSize+r;this.pool.length<r&&(this.pool=this.pool.slice(0,Math.max(2*this.pool.length,r)));for(let i=t;i<e.size;i++){var n=e.denseThreads[i];null!==n&&(this.pool[this.poolSize]=n,this.poolSize++)}e.clear()}freeThread(e){this.pool.length<=this.poolSize&&(this.pool=this.pool.slice(0,2*this.pool.length)),this.pool[this.poolSize]=e,this.poolSize++}match(e,t,r){var n=this.re2.cond;if(n===b.EMPTY_ALL)return!1;if((r===E.ANCHOR_START||r===E.ANCHOR_BOTH)&&0!==t)return!1;this.matched=!1,this.matchcap=Array(this.prog.numCap).fill(-1);let i=this.q0,s=this.q1,a=e.step(t),o=a>>3,l=7&a,u=-1,h=0;a!==mm.EOF()&&(a=e.step(t+l),u=a>>3,h=7&a);let c;for(c=0===t?b.emptyOpContext(-1,o):e.context(t);;){if(i.isEmpty()){if(0!=(n&b.EMPTY_BEGIN_TEXT)&&0!==t)break;if(this.matched)break;if(0!==this.re2.prefix.length&&u!==this.re2.prefixRune&&e.canCheckPrefix()){var d=e.index(this.re2,t);if(d<0)break;t+=d,a=e.step(t),o=a>>3,l=7&a,a=e.step(t+l),u=a>>3,h=7&a}}this.matched||0!==t&&r!==E.UNANCHORED||(0<this.ncap&&(this.matchcap[0]=t),this.add(i,this.prog.start,t,this.matchcap,c,null));d=t+l;if(c=e.context(d),this.step(i,s,t,d,o,c,r,t===e.endPos()),0===l)break;if(0===this.ncap&&this.matched)break;t+=l,o=u,l=h,-1!==o&&(a=e.step(t+l),u=a>>3,h=7&a);var p=i;i=s,s=p}return this.freeQueue(s),this.matched}step(r,n,i,s,a,o,l,u){var h=this.re2.longest;for(let d=0;d<r.size;d++){let t=r.denseThreads[d];if(null!==t)if(h&&this.matched&&0<this.ncap&&this.matchcap[0]<t.cap[0])this.freeThread(t);else{var c=t.inst;let e=!1;switch(c.op){case T.MATCH:l===E.ANCHOR_BOTH&&!u||(0<this.ncap&&(!h||!this.matched||this.matchcap[1]<i)&&(t.cap[1]=i,this.matchcap=t.cap.slice(0,this.ncap)),h||this.freeQueue(r,d+1),this.matched=!0);break;case T.RUNE:e=c.matchRune(a);break;case T.RUNE1:e=a===c.runes[0];break;case T.RUNE_ANY:e=!0;break;case T.RUNE_ANY_NOT_NL:e=a!==f.CODES.get("\n");break;default:throw new Error("bad inst")}null!==(t=e?this.add(n,c.out,s,t.cap,o,t):t)&&(this.freeThread(t),r.denseThreads[d]=null)}}r.clear()}add(e,t,r,n,i,s){if(0!==t&&!e.contains(t)){var a,o=e.add(t),l=this.prog.inst[t];switch(l.op){case T.FAIL:break;case T.ALT:case T.ALT_MATCH:s=this.add(e,l.out,r,n,i,s),s=this.add(e,l.arg,r,n,i,s);break;case T.EMPTY_WIDTH:0==(l.arg&~i)&&(s=this.add(e,l.out,r,n,i,s));break;case T.NOP:s=this.add(e,l.out,r,n,i,s);break;case T.CAPTURE:l.arg<this.ncap?(a=n[l.arg],n[l.arg]=r,this.add(e,l.out,r,n,i,null),n[l.arg]=a):s=this.add(e,l.out,r,n,i,s);break;case T.MATCH:case T.RUNE:case T.RUNE1:case T.RUNE_ANY:case T.RUNE_ANY_NOT_NL:null===s?s=this.alloc(l):s.inst=l,0<this.ncap&&s.cap!==n&&(s.cap=n.slice(0,this.ncap)),e.denseThreads[o]=s,s=null;break;default:throw new Error("unhandled")}}return s}}class Gm{constructor(e){this.value=e}get(){return this.value}set(e){this.value=e}compareAndSet(e,t){return this.value===e&&(this.value=t,!0)}}class Wm{static initTest(e){var t=Wm.compile(e),r=new Wm(t.expr,t.prog,t.numSubexp,t.longest);return r.cond=t.cond,r.prefix=t.prefix,r.prefixUTF8=t.prefixUTF8,r.prefixComplete=t.prefixComplete,r.prefixRune=t.prefixRune,r}static compile(e){return Wm.compileImpl(e,E.PERL,!1)}static compilePOSIX(e){return Wm.compileImpl(e,E.POSIX,!0)}static compileImpl(e,t,r){let n=C.parse(e,t);var i=n.maxCap(),s=(n=Em.simplify(n),Tm.compileRegexp(n)),i=new Wm(e,s,i,r),[s,a]=s.prefix();return i.prefixComplete=s,i.prefix=a,i.prefixUTF8=b.stringToUtf8ByteArray(i.prefix),0<i.prefix.length&&(i.prefixRune=i.prefix.codePointAt(0)),i.namedGroups=n.namedGroups,i}static match(e,t){return Wm.compile(e).match(t)}constructor(e,t,r=0,n=0){this.expr=e,this.prog=t,this.numSubexp=r,this.longest=n,this.cond=t.startCond(),this.prefix=null,this.prefixUTF8=null,this.prefixComplete=!1,this.prefixRune=0,this.pooled=new Gm}numberOfCapturingGroups(){return this.numSubexp}get(){let e;for(;(e=this.pooled.get())&&!this.pooled.compareAndSet(e,e.next););return e}reset(){this.pooled.set(null)}put(e,t){var r;for(this.pooled.get();r=this.pooled.get(),!t&&r&&(e=Km.fromMachine(e),t=!0),e.next!==r&&(e.next=r),!this.pooled.compareAndSet(r,e););}toString(){return this.expr}doExecute(e,t,r,n){let i=this.get(),s=!1;i?null!==i.next&&(i=Km.fromMachine(i),s=!0):(i=Km.fromRE2(this),s=!0),i.init(n);var a=i.match(e,t,r)?i.submatches():null;return this.put(i,s),a}match(e){return null!==this.doExecute(ym.fromUTF16(e),0,E.UNANCHORED,0)}matchWithGroup(e,t,r,n,i){return e instanceof am||(e=um.utf16(e)),this.matchMachineInput(e,t,r,n,i)}matchMachineInput(e,t,r,n,i){var s;return r<t||(s=e.isUTF16Encoding()?ym.fromUTF16(e.asCharSequence(),0,r):ym.fromUTF8(e.asBytes(),0,r),null===(s=this.doExecute(s,t,n,2*i)))?[!1,null]:[!0,s]}matchUTF8(e){return null!==this.doExecute(ym.fromUTF8(e),0,E.UNANCHORED,0)}replaceAll(e,t){return this.replaceAllFunc(e,()=>t,2*e.length+1)}replaceFirst(e,t){return this.replaceAllFunc(e,()=>t,1)}replaceAllFunc(e,t,r){let n=0,i=0,s="";var a=ym.fromUTF16(e);let o=0;for(;i<=e.length;){var l=this.doExecute(a,i,E.UNANCHORED,2);if(null===l||0===l.length)break;s+=e.substring(n,l[0]),(l[1]>n||0===l[0])&&(s+=t(e.substring(l[0],l[1])),o++),n=l[1];var u=7&a.step(i);if(i+u>l[1]?i+=u:i+1>l[1]?i++:i=l[1],o>=r)break}return s+=e.substring(n)}pad(t){if(null===t)return null;var r=2*(1+this.numSubexp);if(t.length<r){var n=new Array(r).fill(-1);for(let e=0;e<t.length;e++)n[e]=t[e];t=n}return t}allMatches(t,e,r=e=>e){var n=[],i=t.endPos();e<0&&(e=i+1);let s=0,a=0,o=-1;for(;a<e&&s<=i;){var l,u=this.doExecute(t,s,E.UNANCHORED,this.prog.numCap);if(null===u||0===u.length)break;let e=!0;u[1]===s?(u[0]===o&&(e=!1),(l=t.step(s))<0?s=i+1:s+=7&l):s=u[1],o=u[1],e&&(n.push(r(this.pad(u))),a++)}return n}findUTF8(e){var t=this.doExecute(ym.fromUTF8(e),0,E.UNANCHORED,2);return null===t?null:e.slice(t[0],t[1])}findUTF8Index(e){var t=this.doExecute(ym.fromUTF8(e),0,E.UNANCHORED,2);return null===t?null:t.slice(0,2)}find(e){var t=this.doExecute(ym.fromUTF16(e),0,E.UNANCHORED,2);return null===t?"":e.substring(t[0],t[1])}findIndex(e){return this.doExecute(ym.fromUTF16(e),0,E.UNANCHORED,2)}findUTF8Submatch(e){var t=this.doExecute(ym.fromUTF8(e),0,E.UNANCHORED,this.prog.numCap);if(null===t)return null;var r=new Array(1+this.numSubexp).fill(null);for(let n=0;n<r.length;n++)2*n<t.length&&0<=t[2*n]&&(r[n]=e.slice(t[2*n],t[2*n+1]));return r}findUTF8SubmatchIndex(e){return this.pad(this.doExecute(ym.fromUTF8(e),0,E.UNANCHORED,this.prog.numCap))}findSubmatch(e){var t=this.doExecute(ym.fromUTF16(e),0,E.UNANCHORED,this.prog.numCap);if(null===t)return null;var r=new Array(1+this.numSubexp).fill(null);for(let n=0;n<r.length;n++)2*n<t.length&&0<=t[2*n]&&(r[n]=e.substring(t[2*n],t[2*n+1]));return r}findSubmatchIndex(e){return this.pad(this.doExecute(ym.fromUTF16(e),0,E.UNANCHORED,this.prog.numCap))}findAllUTF8(t,e){var r=this.allMatches(ym.fromUTF8(t),e,e=>t.slice(e[0],e[1]));return 0===r.length?null:r}findAllUTF8Index(e,t){var r=this.allMatches(ym.fromUTF8(e),t,e=>e.slice(0,2));return 0===r.length?null:r}findAll(t,e){var r=this.allMatches(ym.fromUTF16(t),e,e=>t.substring(e[0],e[1]));return 0===r.length?null:r}findAllIndex(e,t){var r=this.allMatches(ym.fromUTF16(e),t,e=>e.slice(0,2));return 0===r.length?null:r}findAllUTF8Submatch(n,e){var t=this.allMatches(ym.fromUTF8(n),e,e=>{var t=new Array(e.length/2|0).fill(null);for(let r=0;r<t.length;r++)0<=e[2*r]&&(t[r]=n.slice(e[2*r],e[2*r+1]));return t});return 0===t.length?null:t}findAllUTF8SubmatchIndex(e,t){var r=this.allMatches(ym.fromUTF8(e),t);return 0===r.length?null:r}findAllSubmatch(n,e){var t=this.allMatches(ym.fromUTF16(n),e,e=>{var t=new Array(e.length/2|0).fill(null);for(let r=0;r<t.length;r++)0<=e[2*r]&&(t[r]=n.substring(e[2*r],e[2*r+1]));return t});return 0===t.length?null:t}findAllSubmatchIndex(e,t){var r=this.allMatches(ym.fromUTF16(e),t);return 0===r.length?null:r}}class $m{static CASE_INSENSITIVE=1;static DOTALL=2;static MULTILINE=4;static DISABLE_UNICODE_GROUPS=8;static LONGEST_MATCH=16;static quote(e){return b.quoteMeta(e)}static compile(e,t=0){let r=e;if(0!=(t&$m.CASE_INSENSITIVE)&&(r="(?i)"+r),0!=(t&$m.DOTALL)&&(r="(?s)"+r),0!=(t&$m.MULTILINE)&&(r="(?m)"+r),0!=(t&~($m.MULTILINE|$m.DOTALL|$m.CASE_INSENSITIVE|$m.DISABLE_UNICODE_GROUPS|$m.LONGEST_MATCH)))throw new fm("Flags should only be a combination of MULTILINE, DOTALL, CASE_INSENSITIVE, DISABLE_UNICODE_GROUPS, LONGEST_MATCH");let n=E.PERL;0!=(t&$m.DISABLE_UNICODE_GROUPS)&&(n&=~E.UNICODE_GROUPS);var i=new $m(e,t);return i.re2Input=Wm.compileImpl(r,n,0!=(t&$m.LONGEST_MATCH)),i}static matches(e,t){return $m.compile(e).matcher(t).matches()}static initTest(e,t,r){if(null==e)throw new Error("pattern is null");if(null==r)throw new Error("re2 is null");var n=new $m(e,t);return n.re2Input=r,n}constructor(e,t){this.patternInput=e,this.flagsInput=t}reset(){this.re2Input.reset()}flags(){return this.flagsInput}pattern(){return this.patternInput}re2(){return this.re2Input}matches(e){return this.matcher(e).matches()}matcher(e){return Array.isArray(e)&&(e=um.utf8(e)),new gm(this,e)}split(e,t=0){var r=this.matcher(e),n=[];let i=0,s=0;for(;r.find();){if(0===s&&0===r.end());else{if(0<t&&n.length===t-1)break;if(s===r.start()){if(0===t){i+=1,s=r.end();continue}}else for(;0<i;)n.push(""),--i;n.push(r.substring(s,r.start()))}s=r.end()}if(0===t&&s!==r.inputLength()){for(;0<i;)n.push(""),--i;n.push(r.substring(s,r.inputLength()))}return 0===t&&0!==n.length||n.push(r.substring(s,r.inputLength())),n}toString(){return this.patternInput}groupCount(){return this.re2Input.numberOfCapturingGroups()}namedGroups(){return this.re2Input.namedGroups}equals(e){return this===e||null!==e&&this.constructor===e.constructor&&this.flagsInput===e.flagsInput&&this.patternInput===e.patternInput}}class Ym{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}}Ym.UNAUTHENTICATED=new Ym(null),Ym.GOOGLE_CREDENTIALS=new Ym("google-credentials-uid"),Ym.FIRST_PARTY=new Ym("first-party-uid"),Ym.MOCK_USER=new Ym("mock-user");let Qm="12.15.0";let Jm=new Ze("@firebase/firestore");function Xm(){return Jm.logLevel}function S(e,...t){var r;Jm.logLevel<=p.DEBUG&&(r=t.map(t2),Jm.debug(`Firestore (${Qm}): `+e,...r))}function Zm(e,...t){var r;Jm.logLevel<=p.ERROR&&(r=t.map(t2),Jm.error(`Firestore (${Qm}): `+e,...r))}function e2(e,...t){var r;Jm.logLevel<=p.WARN&&(r=t.map(t2),Jm.warn(`Firestore (${Qm}): `+e,...r))}function t2(t){if("string"==typeof t)return t;try{return JSON.stringify(t)}catch(e){return t}}function k(e,t,r){let n="Unexpected state";"string"==typeof t?n=t:r=t,r2(e,n,r)}function r2(e,t,r){let n=`FIRESTORE (${Qm}) INTERNAL ASSERTION FAILED: ${t} (ID: ${e.toString(16)})`;if(void 0!==r)try{n+=" CONTEXT: "+JSON.stringify(r)}catch(e){n+=" CONTEXT: "+r}throw Zm(n),new Error(n)}function A(e,t,r,n){let i="Unexpected state";"string"==typeof r?i=r:n=r,e||r2(t,i,n)}let N={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 R extends fe{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: `+this.message}}class n2{constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}class i2{constructor(e,t){this.user=t,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization","Bearer "+e)}}class s2{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable(()=>t(Ym.UNAUTHENTICATED))}shutdown(){}}class a2{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 o2{constructor(e){this.t=e,this.currentUser=Ym.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(t,r){A(void 0===this.o,42304);let n=this.i,i=e=>this.i!==n?(n=this.i,r(e)):Promise.resolve(),s=new n2,a=(this.o=()=>{this.i++,this.currentUser=this.u(),s.resolve(),s=new n2,t.enqueueRetryable(()=>i(this.currentUser))},()=>{let e=s;t.enqueueRetryable(async()=>{await e.promise,await i(this.currentUser)})}),o=e=>{S("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=e,this.o&&(this.auth.addAuthTokenListener(this.o),a())};this.t.onInit(e=>o(e)),setTimeout(()=>{var e;this.auth||((e=this.t.getImmediate({optional:!0}))?o(e):(S("FirebaseAuthCredentialsProvider","Auth not yet detected"),s.resolve(),s=new n2))},0),a()}getToken(){let t=this.i,e=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(e).then(e=>this.i!==t?(S("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):e?(A("string"==typeof e.accessToken,31837,{l:e}),new i2(e.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(){var e=this.auth&&this.auth.getUid();return A(null===e||"string"==typeof e,2055,{h:e}),new Ym(e)}}class l2{constructor(e,t,r){this.T=e,this.P=t,this.R=r,this.type="FirstParty",this.user=Ym.FIRST_PARTY,this.I=new Map}A(){return this.R?this.R():null}get headers(){this.I.set("X-Goog-AuthUser",this.T);var e=this.A();return e&&this.I.set("Authorization",e),this.P&&this.I.set("X-Goog-Iam-Authorization-Token",this.P),this.I}}class u2{constructor(e,t,r){this.T=e,this.P=t,this.R=r}getToken(){return Promise.resolve(new l2(this.T,this.P,this.R))}start(e,t){e.enqueueRetryable(()=>t(Ym.FIRST_PARTY))}shutdown(){}invalidateToken(){}}class h2{constructor(e){this.value=e,this.type="AppCheck",this.headers=new Map,e&&0<e.length&&this.headers.set("x-firebase-appcheck",this.value)}}class c2{constructor(e,t){this.V=t,this.forceRefresh=!1,this.appCheck=null,this.m=null,this.p=null,Ot(e)&&e.settings.appCheckToken&&(this.p=e.settings.appCheckToken)}start(t,r){A(void 0===this.o,3512);let n=e=>{null!=e.error&&S("FirebaseAppCheckTokenProvider","Error getting App Check token; using placeholder token instead. Error: "+e.error.message);var t=e.token!==this.m;return this.m=e.token,S("FirebaseAppCheckTokenProvider",`Received ${t?"new":"existing"} token.`),t?r(e.token):Promise.resolve()},i=(this.o=e=>{t.enqueueRetryable(()=>n(e))},e=>{S("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=e,this.o&&this.appCheck.addTokenListener(this.o)});this.V.onInit(e=>i(e)),setTimeout(()=>{var e;this.appCheck||((e=this.V.getImmediate({optional:!0}))?i(e):S("FirebaseAppCheckTokenProvider","AppCheck not yet detected"))},0)}getToken(){var e;return this.p?Promise.resolve(new h2(this.p)):(e=this.forceRefresh,this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then(e=>e?(A("string"==typeof e.token,44558,{tokenResult:e}),this.m=e.token,new h2(e.token)):null):Promise.resolve(null))}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.o&&this.appCheck.removeTokenListener(this.o),this.o=void 0}}class d2{static newId(){var t=62*Math.floor(256/62);let r="";for(;r.length<20;){var n=(t=>{var r="undefined"!=typeof self&&(self.crypto||self.msCrypto),n=new Uint8Array(t);if(r&&"function"==typeof r.getRandomValues)r.getRandomValues(n);else for(let e=0;e<t;e++)n[e]=Math.floor(256*Math.random());return n})(40);for(let e=0;e<n.length;++e)r.length<20&&n[e]<t&&(r+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(n[e]%62))}return r}}function P(e,t){return e<t?-1:t<e?1:0}function p2(r,n){let e=Math.min(r.length,n.length);for(let i=0;i<e;i++){let e=r.charAt(i),t=n.charAt(i);if(e!==t)return m2(e)===m2(t)?P(e,t):m2(e)?1:-1}return P(r.length,n.length)}let f2=55296,g2=57343;function m2(e){var t=e.charCodeAt(0);return t>=f2&&t<=g2}function v2(e,r,n){return e.length===r.length&&e.every((e,t)=>n(e,r[t]))}function _2(e){return e+"\0"}let y2="__name__";class w2{constructor(e,t,r){void 0===t?t=0:t>e.length&&k(637,{offset:t,range:e.length}),void 0===r?r=e.length-t:r>e.length-t&&k(1746,{length:r,range:e.length-t}),this.segments=e,this.offset=t,this.len=r}get length(){return this.len}isEqual(e){return 0===w2.comparator(this,e)}child(e){let t=this.segments.slice(this.offset,this.limit());return e instanceof w2?e.forEach(e=>{t.push(e)}):t.push(e),this.construct(t)}limit(){return this.offset+this.length}popFirst(e){return this.construct(this.segments,this.offset+(e=void 0===e?1: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,r=this.limit();t<r;t++)e(this.segments[t])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(t,r){let e=Math.min(t.length,r.length);for(let n=0;n<e;n++){let e=w2.compareSegments(t.get(n),r.get(n));if(0!==e)return e}return P(t.length,r.length)}static compareSegments(e,t){var r=w2.isNumericId(e),n=w2.isNumericId(t);return r&&!n?-1:!r&&n?1:r&&n?w2.extractNumericId(e).compare(w2.extractNumericId(t)):p2(e,t)}static isNumericId(e){return e.startsWith("__id")&&e.endsWith("__")}static extractNumericId(e){return $g.fromString(e.substring(4,e.length-2))}}class x extends w2{construct(e,t,r){return new x(e,t,r)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}toStringWithLeadingSlash(){return"/"+this.canonicalString()}toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...e){var t,r=[];for(t of e){if(0<=t.indexOf("//"))throw new R(N.INVALID_ARGUMENT,`Invalid segment (${t}). Paths must not contain // in them.`);r.push(...t.split("/").filter(e=>0<e.length))}return new x(r)}static emptyPath(){return new x([])}}let b2=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class T2 extends w2{construct(e,t,r){return new T2(e,t,r)}static isValidIdentifier(e){return b2.test(e)}canonicalString(){return this.toArray().map(e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),e=T2.isValidIdentifier(e)?e:"`"+e+"`")).join(".")}toString(){return this.canonicalString()}isKeyField(){return 1===this.length&&this.get(0)===y2}static keyField(){return new T2([y2])}static fromServerFormat(t){let e=[],r="",n=0;var i=()=>{if(0===r.length)throw new R(N.INVALID_ARGUMENT,`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);e.push(r),r=""};let s=!1;for(;n<t.length;){let e=t[n];if("\\"===e){if(n+1===t.length)throw new R(N.INVALID_ARGUMENT,"Path has trailing escape character: "+t);let e=t[n+1];if("\\"!==e&&"."!==e&&"`"!==e)throw new R(N.INVALID_ARGUMENT,"Path has invalid escape sequence: "+t);r+=e,n+=2}else"`"===e?s=!s:"."!==e||s?r+=e:i(),n++}if(i(),s)throw new R(N.INVALID_ARGUMENT,"Unterminated ` in path: "+t);return new T2(e)}static emptyPath(){return new T2([])}}class D{constructor(e){this.path=e}static fromPath(e){return new D(x.fromString(e))}static fromName(e){return new D(x.fromString(e).popFirst(5))}static empty(){return new D(x.emptyPath())}get collectionGroup(){return this.path.popLast().lastSegment()}hasCollectionId(e){return 2<=this.path.length&&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===x.comparator(this.path,e.path)}toString(){return this.path.toString()}static comparator(e,t){return x.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new D(new x(e.slice()))}}function E2(e,t,r){if(!r)throw new R(N.INVALID_ARGUMENT,`Function ${e}() cannot be called with an empty ${t}.`)}function I2(e,t,r,n){if(!0===t&&!0===n)throw new R(N.INVALID_ARGUMENT,e+` and ${r} cannot be used together.`)}function C2(e){if(!D.isDocumentKey(e))throw new R(N.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${e} has ${e.length}.`)}function S2(e){if(D.isDocumentKey(e))throw new R(N.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${e} has ${e.length}.`)}function k2(e){return"object"==typeof e&&null!==e&&(Object.getPrototypeOf(e)===Object.prototype||null===Object.getPrototypeOf(e))}function A2(e){var t,r;return void 0===e?"undefined":null===e?"null":"string"==typeof e?(20<e.length&&(e=e.substring(0,20)+"..."),JSON.stringify(e)):"number"==typeof e||"boolean"==typeof e?""+e:"object"==typeof e?e instanceof Array?"an array":(t=(r=e).constructor?r.constructor.name:null)?`a custom ${t} object`:"an object":"function"==typeof e?"a function":k(12329,{type:typeof e})}function N2(e,t){if((e="_delegate"in e?e._delegate:e)instanceof t)return e;if(t.name===e.constructor.name)throw new R(N.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");var r=A2(e);throw new R(N.INVALID_ARGUMENT,`Expected type '${t.name}', but it was: `+r)}function R2(e,t){if(t<=0)throw new R(N.INVALID_ARGUMENT,`Function ${e}() requires a positive number, but it was: ${t}.`)}function P2(e,t){var r={typeString:e};return t&&(r.value=t),r}function x2(e,t){if(!k2(e))throw new R(N.INVALID_ARGUMENT,"JSON must be an object");let r;for(var n in t)if(t[n]){var i=t[n].typeString,s="value"in t[n]?{value:t[n].value}:void 0;if(!(n in e)){r=`JSON missing required field: '${n}'`;break}var a=e[n];if(i&&typeof a!==i){r=`JSON field '${n}' must be a ${i}.`;break}if(void 0!==s&&a!==s.value){r=`Expected '${n}' field to equal '${s.value}'`;break}}if(r)throw new R(N.INVALID_ARGUMENT,r);return 1}let D2=-62135596800;class O2{static now(){return O2.fromMillis(Date.now())}static fromDate(e){return O2.fromMillis(e.getTime())}static fromMillis(e){var t=Math.floor(e/1e3),r=Math.floor(1e6*(e-1e3*t));return new O2(t,r)}constructor(e,t){if(this.seconds=e,(this.nanoseconds=t)<0)throw new R(N.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(1e9<=t)throw new R(N.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(e<D2)throw new R(N.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e);if(253402300800<=e)throw new R(N.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e)}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{type:O2._jsonSchemaVersion,seconds:this.seconds,nanoseconds:this.nanoseconds}}static fromJSON(e){if(x2(e,O2._jsonSchema))return new O2(e.seconds,e.nanoseconds)}valueOf(){var e=this.seconds-D2;return String(e).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}O2._jsonSchemaVersion="firestore/timestamp/1.0",O2._jsonSchema={type:P2("string",O2._jsonSchemaVersion),seconds:P2("number"),nanoseconds:P2("number")};class O{static fromTimestamp(e){return new O(e)}static min(){return new O(new O2(0,0))}static max(){return new O(new O2(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}}let L2=-1;class M2{constructor(e,t,r,n){this.indexId=e,this.collectionGroup=t,this.fields=r,this.indexState=n}}function F2(e){return e.fields.find(e=>2===e.kind)}function U2(e){return e.fields.filter(e=>2!==e.kind)}M2.UNKNOWN_ID=-1;class V2{constructor(e,t){this.fieldPath=e,this.kind=t}}class B2{constructor(e,t){this.sequenceNumber=e,this.offset=t}static empty(){return new B2(0,z2.min())}}function q2(e,t){var r=e.toTimestamp().seconds,n=e.toTimestamp().nanoseconds+1,r=O.fromTimestamp(1e9===n?new O2(r+1,0):new O2(r,n));return new z2(r,D.empty(),t)}function j2(e){return new z2(e.readTime,e.key,L2)}class z2{constructor(e,t,r){this.readTime=e,this.documentKey=t,this.largestBatchId=r}static min(){return new z2(O.min(),D.empty(),L2)}static max(){return new z2(O.max(),D.empty(),L2)}}function H2(e,t){var r=e.readTime.compareTo(t.readTime);return 0!==r||0!==(r=D.comparator(e.documentKey,t.documentKey))?r:P(e.largestBatchId,t.largestBatchId)}let K2="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class G2{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach(e=>e())}}async function W2(e){if(e.code!==N.FAILED_PRECONDITION||e.message!==K2)throw e;S("LocalStore","Unexpectedly lost primary lease")}class L{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(n,i){return this.callbackAttached&&k(59440),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(i,this.error):this.wrapSuccess(n,this.result):new L((t,r)=>{this.nextCallback=e=>{this.wrapSuccess(n,e).next(t,r)},this.catchCallback=e=>{this.wrapFailure(i,e).next(t,r)}})}toPromise(){return new Promise((e,t)=>{this.next(e,t)})}wrapUserFunction(e){try{var t=e();return t instanceof L?t:L.resolve(t)}catch(e){return L.reject(e)}}wrapSuccess(e,t){return e?this.wrapUserFunction(()=>e(t)):L.resolve(t)}wrapFailure(e,t){return e?this.wrapUserFunction(()=>e(t)):L.reject(t)}static resolve(r){return new L((e,t)=>{e(r)})}static reject(r){return new L((e,t)=>{t(r)})}static waitFor(e){return new L((t,r)=>{let n=0,i=0,s=!1;e.forEach(e=>{++n,e.next(()=>{++i,s&&i===n&&t()},e=>r(e))}),s=!0,i===n&&t()})}static or(e){let t=L.resolve(!1);for(let r of e)t=t.next(e=>e?L.resolve(e):r());return t}static forEach(e,r){let n=[];return e.forEach((e,t)=>{n.push(r.call(this,e,t))}),this.waitFor(n)}static mapArray(o,l){return new L((r,n)=>{let i=o.length,s=new Array(i),a=0;for(let e=0;e<i;e++){let t=e;l(o[t]).next(e=>{s[t]=e,++a===i&&r(s)},e=>n(e))}})}static doWhile(n,i){return new L((e,t)=>{let r=()=>{!0===n()?i().next(()=>{r()},t):e()};r()})}}let $2="SimpleDb";class Y2{static open(e,t,r,n){try{return new Y2(t,e.transaction(n,r))}catch(e){throw new Z2(t,e)}}constructor(r,e){this.action=r,this.transaction=e,this.aborted=!1,this.v=new n2,this.transaction.oncomplete=()=>{this.v.resolve()},this.transaction.onabort=()=>{e.error?this.v.reject(new Z2(r,e.error)):this.v.resolve()},this.transaction.onerror=e=>{var t=i0(e.target.error);this.v.reject(new Z2(r,t))}}get S(){return this.v.promise}abort(e){e&&this.v.reject(e),this.aborted||(S($2,"Aborting transaction:",e?e.message:"Client-initiated abort"),this.aborted=!0,this.transaction.abort())}D(){var e=this.transaction;this.aborted||"function"!=typeof e.commit||e.commit()}store(e){var t=this.transaction.objectStore(e);return new t0(t)}}class Q2{static delete(e){return S($2,"Removing database:",e),r0(G().indexedDB.deleteDatabase(e)).toPromise()}static C(){var e,t,r;return!(!ce()||!Q2.F()&&(e=te(),t=0<(t=Q2.O(e))&&t<10,r=0<(r=J2(e))&&r<4.5,0<e.indexOf("MSIE ")||0<e.indexOf("Trident/")||0<e.indexOf("Edge/")||t||r))}static F(){return"undefined"!=typeof process&&"YES"===process.__PRIVATE_env?.__PRIVATE_USE_MOCK_PERSISTENCE}static M(e,t){return e.store(t)}static O(e){var t=e.match(/i(?:phone|pad|pod) os ([\d_]+)/i),t=t?t[1].split("_").slice(0,2).join("."):"-1";return Number(t)}constructor(e,t,r){this.name=e,this.version=t,this.N=r,this.L=null,12.2===Q2.O(te())&&Zm("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 B(s){return this.db||(S($2,"Opening database:",this.name),this.db=await new Promise((r,n)=>{let i=indexedDB.open(this.name,this.version);i.onsuccess=e=>{var t=e.target.result;r(t)},i.onblocked=()=>{n(new Z2(s,"Cannot upgrade IndexedDB schema while another tab is open. Close all tabs that access Firestore and reload this page to proceed."))},i.onerror=e=>{var t=e.target.error;"VersionError"===t.name?n(new R(N.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"===t.name?n(new R(N.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: "+t)):n(new Z2(s,t))},i.onupgradeneeded=e=>{S($2,'Database "'+this.name+'" requires upgrade from version:',e.oldVersion);var t=e.target.result;this.N.U(t,i.transaction,e.oldVersion,this.version).next(()=>{S($2,"Database upgrade to version "+this.version+" complete")})}})),this.k&&(this.db.onversionchange=e=>this.k(e)),this.db}q(t){this.k=t,this.db&&(this.db.onversionchange=e=>t(e))}async runTransaction(r,e,n,i){var s="readonly"===e;let a=0;for(;;){++a;try{this.db=await this.B(r);let t=Y2.open(this.db,r,s?"readonly":"readwrite",n),e=i(t).next(e=>(t.D(),e)).catch(e=>(t.abort(e),L.reject(e))).toPromise();return e.catch(()=>{}),await t.S,e}catch(r){let e=r,t="FirebaseError"!==e.name&&a<3;if(S($2,"Transaction failed with error:",e.message,"Retrying:",t),this.close(),!t)return Promise.reject(e)}}}close(){this.db&&this.db.close(),this.db=void 0}}function J2(e){var t=e.match(/Android ([\d.]+)/i),t=t?t[1].split(".").slice(0,2).join("."):"-1";return Number(t)}class X2{constructor(e){this.$=e,this.K=!1,this.W=null}get isDone(){return this.K}get G(){return this.W}set cursor(e){this.$=e}done(){this.K=!0}j(e){this.W=e}delete(){return r0(this.$.delete())}}class Z2 extends R{constructor(e,t){super(N.UNAVAILABLE,`IndexedDB transaction '${e}' failed: `+t),this.name="IndexedDbTransactionError"}}function e0(e){return"IndexedDbTransactionError"===e.name}class t0{constructor(e){this.store=e}put(e,t){let r;return r0(r=void 0!==t?(S($2,"PUT",this.store.name,e,t),this.store.put(t,e)):(S($2,"PUT",this.store.name,"<auto-key>",e),this.store.put(e)))}add(e){return S($2,"ADD",this.store.name,e,e),r0(this.store.add(e))}get(t){return r0(this.store.get(t)).next(e=>(void 0===e&&(e=null),S($2,"GET",this.store.name,t,e),e))}delete(e){return S($2,"DELETE",this.store.name,e),r0(this.store.delete(e))}count(){return S($2,"COUNT",this.store.name),r0(this.store.count())}H(e,t){var n=this.options(e,t),r=n.index?this.store.index(n.index):this.store;if("function"==typeof r.getAll){let e=r.getAll(n.range);return new L((t,r)=>{e.onerror=e=>{r(e.target.error)},e.onsuccess=e=>{t(e.target.result)}})}{let e=this.cursor(n),r=[];return this.J(e,(e,t)=>{r.push(t)}).next(()=>r)}}Y(e,t){let n=this.store.getAll(e,null===t?void 0:t);return new L((t,r)=>{n.onerror=e=>{r(e.target.error)},n.onsuccess=e=>{t(e.target.result)}})}Z(e,t){S($2,"DELETE ALL",this.store.name);var r=this.options(e,t),r=(r.X=!1,this.cursor(r));return this.J(r,(e,t,r)=>r.delete())}ee(e,t){let r;t?r=e:(r={},t=e);var n=this.cursor(r);return this.J(n,t)}te(i){let e=this.cursor({});return new L((r,n)=>{e.onerror=e=>{var t=i0(e.target.error);n(t)},e.onsuccess=e=>{let t=e.target.result;t?i(t.primaryKey,t.value).next(e=>{e?t.continue():r()}):r()}})}J(e,s){let a=[];return new L((i,t)=>{e.onerror=e=>{t(e.target.error)},e.onsuccess=e=>{var n=e.target.result;if(n){let t=new X2(n),r=s(n.primaryKey,n.value,t);if(r instanceof L){let e=r.catch(e=>(t.done(),L.reject(e)));a.push(e)}t.isDone?i():null===t.G?n.continue():n.continue(t.G)}else i()}}).next(()=>L.waitFor(a))}options(e,t){let r;return void 0!==e&&("string"==typeof e?r=e:t=e),{index:r,range:t}}cursor(e){let t="next";var r;return e.reverse&&(t="prev"),e.index?(r=this.store.index(e.index),e.X?r.openKeyCursor(e.range,t):r.openCursor(e.range,t)):this.store.openCursor(e.range,t)}}function r0(e){return new L((r,n)=>{e.onsuccess=e=>{var t=e.target.result;r(t)},e.onerror=e=>{var t=i0(e.target.error);n(t)}})}let n0=!1;function i0(e){let t=Q2.O(te());if(12.2<=t&&t<13){let t="An internal error was encountered in the Indexed Database server";if(0<=e.message.indexOf(t)){let e=new R("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 n0||(n0=!0,setTimeout(()=>{throw e},0)),e}}return e}let s0="IndexBackfiller";class a0{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){S(s0,`Scheduled in ${e}ms`),this.task=this.asyncQueue.enqueueAfterDelay("index_backfill",e,async()=>{this.task=null;try{var e=await this.ne.ie();S(s0,"Documents written: "+e)}catch(e){e0(e)?S(s0,"Ignoring IndexedDB error during index backfill: ",e):await W2(e)}await this.re(6e4)})}}class o0{constructor(e,t){this.localStore=e,this.persistence=t}async ie(t=50){return this.persistence.runTransaction("Backfill Indexes","readwrite-primary",e=>this.se(e,t))}se(e,t){let r=new Set,n=t,i=!0;return L.doWhile(()=>!0===i&&0<n,()=>this.localStore.indexManager.getNextCollectionGroupToUpdate(e).next(t=>{if(null!==t&&!r.has(t))return S(s0,"Processing collection: "+t),this._e(e,t,n).next(e=>{n-=e,r.add(t)});i=!1})).next(()=>t-n)}_e(n,i,e){return this.localStore.indexManager.getMinOffsetFromCollectionGroup(n,i).next(r=>this.localStore.localDocuments.getNextDocuments(n,i,r,e).next(e=>{let t=e.changes;return this.localStore.indexManager.updateIndexEntries(n,t).next(()=>this.oe(r,e)).next(e=>(S(s0,"Updating offset: "+e),this.localStore.indexManager.updateCollectionGroup(n,i,e))).next(()=>t.size)}))}oe(e,t){let n=e;return t.changes.forEach((e,t)=>{var r=j2(t);0<H2(r,n)&&(n=r)}),new z2(n.readTime,n.documentKey,Math.max(t.batchId,e.largestBatchId))}}class l0{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(){var e=++this.previousValue;return this.ue&&this.ue(e),e}}let u0=l0.ce=-1;function h0(e){return null==e}function c0(e){return 0===e&&1/e==-1/0}function d0(e){return"number"==typeof e&&Number.isInteger(e)&&!c0(e)&&e<=Number.MAX_SAFE_INTEGER&&e>=Number.MIN_SAFE_INTEGER}let p0="";function f0(e){let t="";for(let r=0;r<e.length;r++)0<t.length&&(t=g0(t)),t=((t,e)=>{let r=e,n=t.length;for(let i=0;i<n;i++){let e=t.charAt(i);switch(e){case"\0":r+="";break;case p0:r+="";break;default:r+=e}}return r})(e.get(r),t);return g0(t)}function g0(e){return e+p0+""}function m0(r){let e=r.length;if(A(2<=e,64408,{path:r}),2===e)return A(r.charAt(0)===p0&&""===r.charAt(1),56145,{path:r}),x.emptyPath();var __PRIVATE_lastReasonableEscapeIndex=e-2,n=[];let i="";for(let a=0;a<e;){let t=r.indexOf(p0,a);switch((t<0||t>__PRIVATE_lastReasonableEscapeIndex)&&k(50515,{path:r}),r.charAt(t+1)){case"":var s=r.substring(a,t);let e;0===i.length?e=s:(i+=s,e=i,i=""),n.push(e);break;case"":i=i+r.substring(a,t)+"\0";break;case"":i+=r.substring(a,t+1);break;default:k(61167,{path:r})}a=t+2}return new x(n)}let v0="remoteDocuments",_0="owner",y0="owner",w0="mutationQueues",b0="mutations",T0="batchId",E0="userMutationsIndex",I0=["userId","batchId"];function C0(e,t){return[e,f0(t)]}function S0(e,t,r){return[e,f0(t),r]}let k0={},A0="documentMutations",N0="remoteDocumentsV14",R0=["prefixPath","collectionGroup","readTime","documentId"],P0="documentKeyIndex",x0=["prefixPath","collectionGroup","documentId"],D0="collectionGroupIndex",O0=["collectionGroup","readTime","prefixPath","documentId"],L0="remoteDocumentGlobal",M0="remoteDocumentGlobalKey",F0="targets",U0="queryTargetsIndex",V0=["canonicalId","targetId"],B0="targetDocuments",q0=["targetId","path"],j0="documentTargetsIndex",z0=["path","targetId"],H0="targetGlobalKey",K0="targetGlobal",G0="collectionParents",W0=["collectionId","parent"],$0="clientMetadata",Y0="bundles",Q0="namedQueries",J0="indexConfiguration",X0="collectionGroupIndex",Z0="indexState",e6=["indexId","uid"],t6="sequenceNumberIndex",r6=["uid","sequenceNumber"],n6="indexEntries",i6=["indexId","uid","arrayValue","directionalValue","orderedDocumentKey","documentKey"],s6="documentKeyIndex",a6=["indexId","uid","orderedDocumentKey"],o6="documentOverlays",l6=["userId","collectionPath","documentId"],u6="collectionPathOverlayIndex",h6=["userId","collectionPath","largestBatchId"],c6="collectionGroupOverlayIndex",d6=["userId","collectionGroup","largestBatchId"],p6="globals",f6=[w0,b0,A0,v0,F0,_0,K0,B0,$0,L0,G0,Y0,Q0],g6=[...f6,o6],m6=[w0,b0,A0,N0,F0,_0,K0,B0,$0,L0,G0,Y0,Q0,o6],v6=m6,_6=[...v6,J0,Z0,n6],y6=_6,w6=[..._6,p6],b6=w6;class T6 extends G2{constructor(e,t){super(),this.le=e,this.currentSequenceNumber=t}}function E6(e,t){var r=e;return Q2.M(r.le,t)}class I6{constructor(e,t){this.comparator=e,this.root=t||S6.EMPTY}insert(e,t){return new I6(this.comparator,this.root.insert(e,t,this.comparator).copy(null,null,S6.BLACK,null,null))}remove(e){return new I6(this.comparator,this.root.remove(e,this.comparator).copy(null,null,S6.BLACK,null,null))}get(e){let t=this.root;for(;!t.isEmpty();){var r=this.comparator(e,t.key);if(0===r)return t.value;r<0?t=t.left:0<r&&(t=t.right)}return null}indexOf(e){let t=0,r=this.root;for(;!r.isEmpty();){var n=this.comparator(e,r.key);if(0===n)return t+r.left.size;r=n<0?r.left:(t+=r.left.size+1,r.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(r){this.inorderTraversal((e,t)=>(r(e,t),!1))}toString(){let r=[];return this.inorderTraversal((e,t)=>(r.push(e+":"+t),!1)),`{${r.join(", ")}}`}reverseTraversal(e){return this.root.reverseTraversal(e)}getIterator(){return new C6(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new C6(this.root,e,this.comparator,!1)}getReverseIterator(){return new C6(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new C6(this.root,e,this.comparator,!0)}}class C6{constructor(e,t,r,n){this.isReverse=n,this.nodeStack=[];let i=1;for(;!e.isEmpty();)if(i=t?r(e.key,t):1,t&&n&&(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();var 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 0<this.nodeStack.length}peek(){var e;return 0===this.nodeStack.length?null:{key:(e=this.nodeStack[this.nodeStack.length-1]).key,value:e.value}}}class S6{constructor(e,t,r,n,i){this.key=e,this.value=t,this.color=null!=r?r:S6.RED,this.left=null!=n?n:S6.EMPTY,this.right=null!=i?i:S6.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,t,r,n,i){return new S6(null!=e?e:this.key,null!=t?t:this.value,null!=r?r:this.color,null!=n?n: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,r){var n=this,i=r(e,n.key);return(n=i<0?n.copy(null,null,null,n.left.insert(e,t,r),null):0===i?n.copy(null,t,null,null,null):n.copy(null,null,null,null,n.right.insert(e,t,r))).fixUp()}removeMin(){if(this.left.isEmpty())return S6.EMPTY;let e=this;return(e=(e=e.left.isRed()||e.left.left.isRed()?e:e.moveRedLeft()).copy(null,null,null,e.left.removeMin(),null)).fixUp()}remove(e,t){let r,n=this;if(t(e,n.key)<0)n=(n=n.left.isEmpty()||n.left.isRed()||n.left.left.isRed()?n:n.moveRedLeft()).copy(null,null,null,n.left.remove(e,t),null);else{if(0===t(e,(n=(n=n.left.isRed()?n.rotateRight():n).right.isEmpty()||n.right.isRed()||n.right.left.isRed()?n:n.moveRedRight()).key)){if(n.right.isEmpty())return S6.EMPTY;r=n.right.min(),n=n.copy(r.key,r.value,null,null,n.right.removeMin())}n=n.copy(null,null,null,null,n.right.remove(e,t))}return n.fixUp()}isRed(){return this.color}fixUp(){let e=this;return e=(e=(e=e.right.isRed()&&!e.left.isRed()?e.rotateLeft():e).left.isRed()&&e.left.left.isRed()?e.rotateRight():e).left.isRed()&&e.right.isRed()?e.colorFlip():e}moveRedLeft(){let e=this.colorFlip();return e=e.right.left.isRed()?(e=(e=e.copy(null,null,null,null,e.right.rotateRight())).rotateLeft()).colorFlip():e}moveRedRight(){let e=this.colorFlip();return e=e.left.left.isRed()?(e=e.rotateRight()).colorFlip():e}rotateLeft(){var e=this.copy(null,null,S6.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){var e=this.copy(null,null,S6.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip(){var e=this.left.copy(null,null,!this.left.color,null,null),t=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,t)}checkMaxDepth(){var e=this.check();return Math.pow(2,e)<=this.size+1}check(){if(this.isRed()&&this.left.isRed())throw k(43730,{key:this.key,value:this.value});if(this.right.isRed())throw k(14113,{key:this.key,value:this.value});var e=this.left.check();if(e!==this.right.check())throw k(27949);return e+(this.isRed()?0:1)}}S6.EMPTY=null,S6.RED=!0,S6.BLACK=!1,S6.EMPTY=new class{constructor(){this.size=0}get key(){throw k(57766)}get value(){throw k(16141)}get color(){throw k(16727)}get left(){throw k(29726)}get right(){throw k(36894)}copy(e,t,r,n,i){return this}insert(e,t,r){return new S6(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 k6{constructor(e){this.comparator=e,this.data=new I6(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(r){this.data.inorderTraversal((e,t)=>(r(e),!1))}forEachInRange(e,t){for(var r=this.data.getIteratorFrom(e[0]);r.hasNext();){var n=r.getNext();if(0<=this.comparator(n.key,e[1]))return;t(n.key)}}forEachWhile(e,t){for(var r=void 0!==t?this.data.getIteratorFrom(t):this.data.getIterator();r.hasNext();)if(!e(r.getNext().key))return}firstAfterOrEqual(e){var t=this.data.getIteratorFrom(e);return t.hasNext()?t.getNext().key:null}getIterator(){return new A6(this.data.getIterator())}getIteratorFrom(e){return new A6(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 k6))return!1;if(this.size!==e.size)return!1;for(var r=this.data.getIterator(),n=e.data.getIterator();r.hasNext();){let e=r.getNext().key,t=n.getNext().key;if(0!==this.comparator(e,t))return!1}return!0}toArray(){let t=[];return this.forEach(e=>{t.push(e)}),t}toString(){let t=[];return this.forEach(e=>t.push(e)),"SortedSet("+t.toString()+")"}copy(e){var t=new k6(this.comparator);return t.data=e,t}}class A6{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}function N6(e){return e.hasNext()?e.getNext():void 0}class R6{constructor(e){(this.fields=e).sort(T2.comparator)}static empty(){return new R6([])}unionWith(e){let t=new k6(T2.comparator);for(let e of this.fields)t=t.add(e);for(var r of e)t=t.add(r);return new R6(t.toArray())}covers(e){for(var t of this.fields)if(t.isPrefixOf(e))return!0;return!1}isEqual(e){return v2(this.fields,e.fields,(e,t)=>e.isEqual(t))}}function P6(e){let t=0;for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}function x6(e,t){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t(r,e[r])}function D6(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}class O6 extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}class L6{constructor(e){this.binaryString=e}static fromBase64String(e){var t=(e=>{try{return atob(e)}catch(e){throw"undefined"!=typeof DOMException&&e instanceof DOMException?new O6("Invalid base64 string: "+e):e}})(e);return new L6(t)}static fromUint8Array(e){var t=(e=>{let t="";for(let r=0;r<e.length;++r)t+=String.fromCharCode(e[r]);return t})(e);return new L6(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(){var e=this.binaryString,t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}approximateByteSize(){return 2*this.binaryString.length}compareTo(e){return P(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}}L6.EMPTY_BYTE_STRING=new L6("");let M6=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function F6(t){if(A(!!t,39018),"string"!=typeof t)return{seconds:U6(t.seconds),nanos:U6(t.nanos)};{let e=0;var r=M6.exec(t),r=(A(!!r,46558,{timestamp:t}),r[1]&&(r=((r=r[1])+"000000000").substr(0,9),e=Number(r)),new Date(t));return{seconds:Math.floor(r.getTime()/1e3),nanos:e}}}function U6(e){return"number"==typeof e?e:"string"==typeof e?Number(e):0}function V6(e){return"string"==typeof e?L6.fromBase64String(e):L6.fromUint8Array(e)}let B6="server_timestamp",q6="__type__",j6="__previous_value__",z6="__local_write_time__";function H6(e){return(e?.mapValue?.fields||{})[q6]?.stringValue===B6}function K6(e){var t=e.mapValue.fields[j6];return H6(t)?K6(t):t}function G6(e){var t=F6(e.mapValue.fields[z6].timestampValue);return new O2(t.seconds,t.nanos)}class W6{constructor(e,t,r,n,i,s,a,o,l,u,h){this.databaseId=e,this.appId=t,this.persistenceKey=r,this.host=n,this.ssl=i,this.forceLongPolling=s,this.autoDetectLongPolling=a,this.longPollingOptions=o,this.useFetchStreams=l,this.isUsingEmulator=u,this.apiKey=h}}let $6="(default)";class Y6{constructor(e,t){this.projectId=e,this.database=t||$6}static empty(){return new Y6("","")}get isDefaultDatabase(){return this.database===$6}isEqual(e){return e instanceof Y6&&e.projectId===this.projectId&&e.database===this.database}}let Q6="__type__",J6="__max__",X6={mapValue:{fields:{__type__:{stringValue:J6}}}},Z6="__vector__",ev="value",tv={nullValue:"NULL_VALUE"},rv={booleanValue:!0},nv={booleanValue:!1};function iv(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?H6(e)?4:Tv(e)?9007199254740991:yv(e)?10:11:k(28295,{value:e})}function sv(r,n,i){if(r===n)return!0;var t,s,a,o,e=iv(r);if(e!==iv(n))return!1;switch(e){case 0:case 9007199254740991:return!0;case 1:return r.booleanValue===n.booleanValue;case 4:return G6(r).isEqual(G6(n));case 3:return s=n,"string"==typeof(t=r).timestampValue&&"string"==typeof s.timestampValue&&t.timestampValue.length===s.timestampValue.length?t.timestampValue===s.timestampValue:(a=F6(t.timestampValue),o=F6(s.timestampValue),a.seconds===o.seconds&&a.nanos===o.nanos);case 5:return r.stringValue===n.stringValue;case 6:return t=n,V6(r.bytesValue).isEqual(V6(t.bytesValue));case 7:return r.referenceValue===n.referenceValue;case 8:return s=n,U6((l=r).geoPointValue.latitude)===U6(s.geoPointValue.latitude)&&U6(l.geoPointValue.longitude)===U6(s.geoPointValue.longitude);case 2:{var l=r;var u=n;var h=i;if("integerValue"in l&&"integerValue"in u)return U6(l.integerValue)===U6(u.integerValue);let e,t;if("doubleValue"in l&&"doubleValue"in u)e=U6(l.doubleValue),t=U6(u.doubleValue);else{if(!h?.Ee)return!1;e=U6(l.integerValue??l.doubleValue),t=U6(u.integerValue??u.doubleValue)}return e===t?!!h?.he||c0(e)===c0(t):!(void 0!==h&&!h.Te)&&isNaN(e)&&isNaN(t);return}case 9:return v2(r.arrayValue.values||[],n.arrayValue.values||[],(e,t)=>sv(e,t,i));case 10:case 11:var c=r,u=n,d=i,p=c.mapValue.fields||{},f=u.mapValue.fields||{};if(P6(p)!==P6(f))return!1;for(let e in p)if(p.hasOwnProperty(e)&&(void 0===f[e]||!sv(p[e],f[e],d)))return!1;return!0;default:return k(52216,{left:r})}}function av(e,t){return void 0!==(e.values||[]).find(e=>sv(e,t))}function ov(e,n){if(e===n)return 0;var i,s,a,o,l,u,h,c,d=iv(e),t=iv(n);if(d!==t)return P(d,t);switch(d){case 0:case 9007199254740991:return 0;case 1:return P(e.booleanValue,n.booleanValue);case 2:return u=n,h=U6((l=e).integerValue||l.doubleValue),c=U6(u.integerValue||u.doubleValue),h<c?-1:c<h?1:h===c?0:isNaN(h)?isNaN(c)?0:-1:1;case 3:return lv(e.timestampValue,n.timestampValue);case 4:return lv(G6(e),G6(n));case 5:return p2(e.stringValue,n.stringValue);case 6:return l=e.bytesValue,u=n.bytesValue,h=V6(l),c=V6(u),h.compareTo(c);case 7:var p=e.referenceValue,f=n.referenceValue,g=p.split("/"),m=f.split("/");for(let t=0;t<g.length&&t<m.length;t++){let e=P(g[t],m[t]);if(0!==e)return e}return P(g.length,m.length);case 8:return p=e.geoPointValue,f=n.geoPointValue,0!==(o=P(U6(p.latitude),U6(f.latitude)))?o:P(U6(p.longitude),U6(f.longitude));case 9:return uv(e.arrayValue,n.arrayValue);case 10:return v=e.mapValue,i=n.mapValue,o=v.fields||{},s=i.fields||{},o=o[ev]?.arrayValue,s=s[ev]?.arrayValue,0!==(a=P(o?.values?.length||0,s?.values?.length||0))?a:uv(o,s);case 11:var v=e.mapValue,_=n.mapValue;if(v===X6.mapValue&&_===X6.mapValue)return 0;if(v===X6.mapValue)return 1;if(_===X6.mapValue)return-1;var y=v.fields||{},w=Object.keys(y),b=_.fields||{},T=Object.keys(b);w.sort(),T.sort();for(let r=0;r<w.length&&r<T.length;++r){let e=p2(w[r],T[r]);if(0!==e)return e;var E=ov(y[w[r]],b[T[r]]);if(0!==E)return E}return P(w.length,T.length);default:throw k(23264,{Pe:d})}}function lv(e,t){var r,n,i;return"string"==typeof e&&"string"==typeof t&&e.length===t.length?P(e,t):(r=F6(e),n=F6(t),0!==(i=P(r.seconds,n.seconds))?i:P(r.nanos,n.nanos))}function uv(e,t){var r=e.values||[],n=t.values||[];for(let i=0;i<r.length&&i<n.length;++i){let e=ov(r[i],n[i]);if(void 0!==e&&0!==e)return e}return P(r.length,n.length)}function hv(e){return function s(e){return"nullValue"in e?"null":"booleanValue"in e?""+e.booleanValue:"integerValue"in e?""+e.integerValue:"doubleValue"in e?""+e.doubleValue:"timestampValue"in e?(e=>{let t=F6(e);return`time(${t.seconds},${t.nanos})`})(e.timestampValue):"stringValue"in e?e.stringValue:"bytesValue"in e?(e=>V6(e).toBase64())(e.bytesValue):"referenceValue"in e?(e=>D.fromName(e).toString())(e.referenceValue):"geoPointValue"in e?(e=>`geo(${e.latitude},${e.longitude})`)(e.geoPointValue):"arrayValue"in e?(e=>{let t="[",r=!0;for(var n of e.values||[])r?r=!1:t+=",",t+=s(n);return t+"]"})(e.arrayValue):"mapValue"in e?(e=>{let t=Object.keys(e.fields||{}).sort(),r="{",n=!0;for(var i of t)n?n=!1:r+=",",r+=i+":"+s(e.fields[i]);return r+"}"})(e.mapValue):k(61005,{value:e})}(e)}function cv(e,t){return{referenceValue:`projects/${e.projectId}/databases/${e.database}/documents/`+t.path.canonicalString()}}function dv(e){return!!e&&"integerValue"in e}function pv(e){return!!e&&"doubleValue"in e}function fv(e){return dv(e)||pv(e)}function gv(e){return!!e&&"arrayValue"in e}function mv(e){return e&&"nullValue"in e}function vv(e){return e&&"doubleValue"in e&&isNaN(Number(e.doubleValue))}function _v(e){return e&&"mapValue"in e}function yv(e){return(e?.mapValue?.fields||{})[Q6]?.stringValue===Z6}function wv(e){return(e?.mapValue?.fields||{})[ev]?.arrayValue}function bv(t){if(t.geoPointValue)return{geoPointValue:{...t.geoPointValue}};if(t.timestampValue&&"object"==typeof t.timestampValue)return{timestampValue:{...t.timestampValue}};if(t.mapValue){let r={mapValue:{fields:{}}};return x6(t.mapValue.fields,(e,t)=>r.mapValue.fields[e]=bv(t)),r}if(t.arrayValue){var r={arrayValue:{values:[]}};for(let e=0;e<(t.arrayValue.values||[]).length;++e)r.arrayValue.values[e]=bv(t.arrayValue.values[e]);return r}return{...t}}function Tv(e){return(((e.mapValue||{}).fields||{}).__type__||{}).stringValue===J6}let Ev={mapValue:{fields:{[Q6]:{stringValue:Z6},[ev]:{arrayValue:{}}}}};function Iv(e,t){var r=ov(e.value,t.value);return 0!==r?r:e.inclusive&&!t.inclusive?-1:!e.inclusive&&t.inclusive?1:0}function Cv(e,t){var r=ov(e.value,t.value);return 0!==r?r:e.inclusive&&!t.inclusive?1:!e.inclusive&&t.inclusive?-1:0}class Sv{constructor(e){this.value=e}static empty(){return new Sv({mapValue:{}})}field(r){if(r.isEmpty())return this.value;{let e=this.value;for(let t=0;t<r.length-1;++t)if(!_v(e=(e.mapValue.fields||{})[r.get(t)]))return null;return(e=(e.mapValue.fields||{})[r.lastSegment()])||null}}set(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=bv(t)}setAll(e){let r=T2.emptyPath(),n={},i=[];e.forEach((e,t)=>{if(!r.isImmediateParentOf(t)){let e=this.getFieldsMap(r);this.applyChanges(e,n,i),n={},i=[],r=t.popLast()}e?n[t.lastSegment()]=bv(e):i.push(t.lastSegment())});var t=this.getFieldsMap(r);this.applyChanges(t,n,i)}delete(e){var t=this.field(e.popLast());_v(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return sv(this.value,e.value)}getFieldsMap(t){let r=this.value;r.mapValue.fields||(r.mapValue={fields:{}});for(let n=0;n<t.length;++n){let e=r.mapValue.fields[t.get(n)];_v(e)&&e.mapValue.fields||(e={mapValue:{fields:{}}},r.mapValue.fields[t.get(n)]=e),r=e}return r.mapValue.fields}applyChanges(r,e,t){x6(e,(e,t)=>r[e]=t);for(let e of t)delete r[e]}clone(){return new Sv(bv(this.value))}}function kv(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:c0(t)?"-0":t}}function Av(e){return{integerValue:""+e}}function Nv(e,t,r){return Number.isInteger(t)&&r?.preferIntegers||d0(t)?Av(t):kv(e,t)}class Rv{constructor(){this._=void 0}}function Pv(e,t){return e instanceof Uv?fv(t)?t:{integerValue:0}:null}class xv extends Rv{}class Dv extends Rv{constructor(e){super(),this.elements=e}}function Ov(e,t){var r=zv(t);for(let t of e.elements)r.some(e=>sv(e,t))||r.push(t);return{arrayValue:{values:r}}}class Lv extends Rv{constructor(e){super(),this.elements=e}}function Mv(e,t){let r=zv(t);for(let t of e.elements)r=r.filter(e=>!sv(e,t));return{arrayValue:{values:r}}}class Fv extends Rv{constructor(e,t){super(),this.serializer=e,this.Re=t}}class Uv extends Fv{}class Vv extends Fv{}class Bv extends Fv{}function qv(e,t,r){var n;return fv(t)?(n=r(jv(t),jv(e.Re)),dv(t)&&dv(e.Re)?Av(n):kv(e.serializer,n)):e.Re}function jv(e){return U6(e.integerValue||e.doubleValue)}function zv(e){return gv(e)&&e.arrayValue.values?e.arrayValue.values.slice():[]}class Hv{constructor(e,t){this.field=e,this.transform=t}}class Kv{constructor(e,t){this.version=e,this.transformResults=t}}class Gv{constructor(e,t){this.updateTime=e,this.exists=t}static none(){return new Gv}static exists(e){return new Gv(void 0,e)}static updateTime(e){return new Gv(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 Wv(e,t){return void 0!==e.updateTime?t.isFoundDocument()&&t.version.isEqual(e.updateTime):void 0===e.exists||e.exists===t.isFoundDocument()}class $v{}function Yv(e,r){if(!e.hasLocalMutations||r&&0===r.fields.length)return null;if(null===r)return e.isNoDocument()?new n_(e.key,Gv.none()):new Xv(e.key,e.data,Gv.none());{var n,i=e.data,s=Sv.empty();let t=new k6(T2.comparator);for(n of r.fields)if(!t.has(n)){let e=i.field(n);null===e&&1<n.length&&(n=n.popLast(),e=i.field(n)),null===e?s.delete(n):s.set(n,e),t=t.add(n)}return new Zv(e.key,s,new R6(t.toArray()),Gv.none())}}function Qv(e,t,r,n){return e instanceof Xv?(s=t,a=r,o=n,Wv((i=e).precondition,s)?(l=i.value.clone(),u=r_(i.fieldTransforms,o,s),l.setAll(u),s.convertToFoundDocument(s.version,l).setHasLocalMutations(),null):a):e instanceof Zv?(i=t,o=r,s=n,Wv((a=e).precondition,i)?(u=r_(a.fieldTransforms,s,i),(l=i.data).setAll(e_(a)),l.setAll(u),i.convertToFoundDocument(i.version,l).setHasLocalMutations(),null===o?null:o.unionWith(a.fieldMask.fields).unionWith(a.fieldTransforms.map(e=>e.field))):o):(n=t,t=r,Wv(e.precondition,n)?(n.convertToNoDocument(n.version).setHasLocalMutations(),null):t);var i,s,a,o,l,u}function Jv(e,t){return e.type===t.type&&!!e.key.isEqual(t.key)&&!!e.precondition.isEqual(t.precondition)&&(r=e.fieldTransforms,n=t.fieldTransforms,!!(void 0===r&&void 0===n||r&&n&&v2(r,n,(e,t)=>(t=t,(e=e).field.isEqual(t.field)&&(e=e.transform,t=t.transform,e instanceof Dv&&t instanceof Dv||e instanceof Lv&&t instanceof Lv?v2(e.elements,t.elements,sv):e instanceof Uv&&t instanceof Uv||e instanceof Vv&&t instanceof Vv||e instanceof Bv&&t instanceof Bv?sv(e.Re,t.Re):e instanceof xv&&t instanceof xv)))))&&(0===e.type?e.value.isEqual(t.value):1!==e.type||e.data.isEqual(t.data)&&e.fieldMask.isEqual(t.fieldMask));var r,n}class Xv extends $v{constructor(e,t,r,n=[]){super(),this.key=e,this.value=t,this.precondition=r,this.fieldTransforms=n,this.type=0}getFieldMask(){return null}}class Zv extends $v{constructor(e,t,r,n,i=[]){super(),this.key=e,this.data=t,this.fieldMask=r,this.precondition=n,this.fieldTransforms=i,this.type=1}getFieldMask(){return this.fieldMask}}function e_(r){let n=new Map;return r.fieldMask.fields.forEach(e=>{var t;e.isEmpty()||(t=r.data.field(e),n.set(e,t))}),n}function t_(e,t,r){var n,i,s,a=new Map;A(e.length===r.length,32656,{Ie:r.length,Ae:e.length});for(let h=0;h<r.length;h++){var o=e[h],l=o.transform,u=t.data.field(o.field);a.set(o.field,(n=l,i=u,s=r[h],n instanceof Dv?Ov(n,i):n instanceof Lv?Mv(n,i):s))}return a}function r_(e,r,n){var i,s,a,o,l,u,h,c=new Map;for(i of e){let e=i.transform,t=n.data.field(i.field);c.set(i.field,(s=e,a=t,o=r,h=u=l=void 0,s instanceof xv?(o=o,u=a,h={fields:{[q6]:{stringValue:B6},[z6]:{timestampValue:{seconds:o.seconds,nanos:o.nanoseconds}}}},(u=u&&H6(u)?K6(u):u)&&(h.fields[j6]=u),{mapValue:h}):s instanceof Dv?Ov(s,a):s instanceof Lv?Mv(s,a):s instanceof Uv?(h=Pv(o=s,a),l=jv(h)+jv(o.Re),dv(h)&&dv(o.Re)?Av(l):kv(o.serializer,l)):s instanceof Vv?qv(s,a,Math.min):s instanceof Bv?qv(s,a,Math.max):void 0))}return c}class n_ extends $v{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}class i_ extends $v{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}}class s_{constructor(e,t){this.position=e,this.inclusive=t}}function a_(e,t,r){let n=0;for(let a=0;a<e.position.length;a++){var i=t[a],s=e.position[a];if(n=i.field.isKeyField()?D.comparator(D.fromName(s.referenceValue),r.key):ov(s,r.data.field(i.field)),"desc"===i.dir&&(n*=-1),0!==n)break}return n}function o_(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 r=0;r<e.position.length;r++)if(!sv(e.position[r],t.position[r]))return!1;return!0}class l_{}class M extends l_{constructor(e,t,r){super(),this.field=e,this.op=t,this.value=r}static create(e,t,r){return e.isKeyField()?"in"===t||"not-in"===t?this.createKeyFieldInFilter(e,t,r):new m_(e,t,r):"array-contains"===t?new w_(e,r):"in"===t?new b_(e,r):"not-in"===t?new T_(e,r):"array-contains-any"===t?new E_(e,r):new M(e,t,r)}static createKeyFieldInFilter(e,t,r){return new("in"===t?v_:__)(e,r)}matches(e){var t=e.data.field(this.field);return"!="===this.op?null!==t&&void 0===t.nullValue&&this.matchesComparison(ov(t,this.value)):null!==t&&iv(this.value)===iv(t)&&this.matchesComparison(ov(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 0<e;case">=":return 0<=e;default:return k(47266,{operator:this.op})}}isInequality(){return 0<=["<","<=",">",">=","!=","not-in"].indexOf(this.op)}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class u_ extends l_{constructor(e,t){super(),this.filters=e,this.op=t,this.Ve=null}static create(e,t){return new u_(e,t)}matches(t){return h_(this)?void 0===this.filters.find(e=>!e.matches(t)):void 0!==this.filters.find(e=>e.matches(t))}getFlattenedFilters(){return null===this.Ve&&(this.Ve=this.filters.reduce((e,t)=>e.concat(t.getFlattenedFilters()),[])),this.Ve}getFilters(){return Object.assign([],this.filters)}}function h_(e){return"and"===e.op}function c_(e){return"or"===e.op}function d_(e){return p_(e)&&h_(e)}function p_(e){for(var t of e.filters)if(t instanceof u_)return!1;return!0}function f_(e,t){var r=e.filters.concat(t);return u_.create(r,e.op)}function g_(e){return e instanceof M?`${(t=e).field.canonicalString()} ${t.op} `+hv(t.value):e instanceof u_?(t=e).op.toString()+" {"+t.getFilters().map(g_).join(" ,")+"}":"Filter";var t}class m_ extends M{constructor(e,t,r){super(e,t,r),this.key=D.fromName(r.referenceValue)}matches(e){var t=D.comparator(e.key,this.key);return this.matchesComparison(t)}}class v_ extends M{constructor(e,t){super(e,"in",t),this.keys=y_(0,t)}matches(t){return this.keys.some(e=>e.isEqual(t.key))}}class __ extends M{constructor(e,t){super(e,"not-in",t),this.keys=y_(0,t)}matches(t){return!this.keys.some(e=>e.isEqual(t.key))}}function y_(e,t){return(t.arrayValue?.values||[]).map(e=>D.fromName(e.referenceValue))}class w_ extends M{constructor(e,t){super(e,"array-contains",t)}matches(e){var t=e.data.field(this.field);return gv(t)&&av(t.arrayValue,this.value)}}class b_ extends M{constructor(e,t){super(e,"in",t)}matches(e){var t=e.data.field(this.field);return null!==t&&av(this.value.arrayValue,t)}}class T_ extends M{constructor(e,t){super(e,"not-in",t)}matches(e){var t;return!av(this.value.arrayValue,{nullValue:"NULL_VALUE"})&&null!==(t=e.data.field(this.field))&&void 0===t.nullValue&&!av(this.value.arrayValue,t)}}class E_ extends M{constructor(e,t){super(e,"array-contains-any",t)}matches(e){var t=e.data.field(this.field);return!(!gv(t)||!t.arrayValue.values)&&t.arrayValue.values.some(e=>av(this.value.arrayValue,e))}}class I_{constructor(e,t="asc"){this.field=e,this.dir=t}}class C_{constructor(e,t,r,n,i,s,a){this.key=e,this.documentType=t,this.version=r,this.readTime=n,this.createTime=i,this.data=s,this.documentState=a}static newInvalidDocument(e){return new C_(e,0,O.min(),O.min(),O.min(),Sv.empty(),0)}static newFoundDocument(e,t,r,n){return new C_(e,1,t,O.min(),r,n,0)}static newNoDocument(e,t){return new C_(e,2,t,O.min(),O.min(),Sv.empty(),0)}static newUnknownDocument(e,t){return new C_(e,3,t,O.min(),O.min(),Sv.empty(),2)}convertToFoundDocument(e,t){return!this.createTime.isEqual(O.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=Sv.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=Sv.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=O.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 C_&&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 C_(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 S_{constructor(e,t=null,r=[],n=[],i=null,s=null,a=null){this.path=e,this.collectionGroup=t,this.orderBy=r,this.filters=n,this.limit=i,this.startAt=s,this.endAt=a,this.de=null}}function k_(e,t=null,r=[],n=[],i=null,s=null,a=null){return new S_(e,t,r,n,i,s,a)}function A_(e){var t=e;if(null===t.de){let e=t.path.canonicalString();null!==t.collectionGroup&&(e+="|cg:"+t.collectionGroup),e=(e=(e+="|f:")+t.filters.map(e=>function t(e){var r;return e instanceof M?e.field.canonicalString()+e.op.toString()+hv(e.value):d_(e)?e.filters.map(e=>t(e)).join(","):(r=e.filters.map(e=>t(e)).join(","),e.op+`(${r})`)}(e)).join(",")+"|ob:")+t.orderBy.map(e=>(e=e).field.canonicalString()+e.dir).join(","),h0(t.limit)||(e=(e+="|l:")+t.limit),t.startAt&&(e=(e=(e+="|lb:")+(t.startAt.inclusive?"b:":"a:"))+t.startAt.position.map(e=>hv(e)).join(",")),t.endAt&&(e=(e=(e+="|ub:")+(t.endAt.inclusive?"a:":"b:"))+t.endAt.position.map(e=>hv(e)).join(",")),t.de=e}return t.de}function N_(e,t){if(e.limit!==t.limit)return!1;if(e.orderBy.length!==t.orderBy.length)return!1;for(let i=0;i<e.orderBy.length;i++)if(r=e.orderBy[i],n=t.orderBy[i],r.dir!==n.dir||!r.field.isEqual(n.field))return!1;var r,n;if(e.filters.length!==t.filters.length)return!1;for(let s=0;s<e.filters.length;s++)if(!function n(e,t){return e instanceof M?(r=e,(s=t)instanceof M&&r.op===s.op&&r.field.isEqual(s.field)&&sv(r.value,s.value)):e instanceof u_?(r=e,(i=t)instanceof u_&&r.op===i.op&&r.filters.length===i.filters.length&&r.filters.reduce((e,t,r)=>e&&n(t,i.filters[r]),!0)):void k(19439);var i,r,s}(e.filters[s],t.filters[s]))return!1;return e.collectionGroup===t.collectionGroup&&!!e.path.isEqual(t.path)&&!!o_(e.startAt,t.startAt)&&o_(e.endAt,t.endAt)}function R_(e){return e.isCorePipeline}function P_(e){return!!e.path&&D.isDocumentKey(e.path)&&null===e.collectionGroup&&0===e.filters.length}function x_(e,t){return e.filters.filter(e=>e instanceof M&&e.field.isEqual(t))}function D_(e,r,n){let i=tv,s=!0;for(let n of x_(e,r)){let e=tv,t=!0;switch(n.op){case"<":case"<=":e="nullValue"in(a=n.value)?tv:"booleanValue"in a?{booleanValue:!1}:"integerValue"in a||"doubleValue"in a?{doubleValue:NaN}:"timestampValue"in a?{timestampValue:{seconds:Number.MIN_SAFE_INTEGER}}:"stringValue"in a?{stringValue:""}:"bytesValue"in a?{bytesValue:""}:"referenceValue"in a?cv(Y6.empty(),D.empty()):"geoPointValue"in a?{geoPointValue:{latitude:-90,longitude:-180}}:"arrayValue"in a?{arrayValue:{}}:"mapValue"in a?yv(a)?Ev:{mapValue:{}}:k(35942,{value:a});break;case"==":case"in":case">=":e=n.value;break;case">":e=n.value,t=!1;break;case"!=":case"not-in":e=tv}Iv({value:i,inclusive:s},{value:e,inclusive:t})<0&&(i=e,s=t)}var a;if(null!==n)for(let t=0;t<e.orderBy.length;++t)if(e.orderBy[t].field.isEqual(r)){let e=n.position[t];Iv({value:i,inclusive:s},{value:e,inclusive:n.inclusive})<0&&(i=e,s=n.inclusive);break}return{value:i,inclusive:s}}function O_(e,r,n){let i=X6,s=!0;for(let n of x_(e,r)){let e=X6,t=!0;switch(n.op){case">=":case">":e="nullValue"in(a=n.value)?{booleanValue:!1}:"booleanValue"in a?{doubleValue:NaN}:"integerValue"in a||"doubleValue"in a?{timestampValue:{seconds:Number.MIN_SAFE_INTEGER}}:"timestampValue"in a?{stringValue:""}:"stringValue"in a?{bytesValue:""}:"bytesValue"in a?cv(Y6.empty(),D.empty()):"referenceValue"in a?{geoPointValue:{latitude:-90,longitude:-180}}:"geoPointValue"in a?{arrayValue:{}}:"arrayValue"in a?Ev:"mapValue"in a?yv(a)?{mapValue:{}}:X6:k(61959,{value:a}),t=!1;break;case"==":case"in":case"<=":e=n.value;break;case"<":e=n.value,t=!1;break;case"!=":case"not-in":e=X6}0<Cv({value:i,inclusive:s},{value:e,inclusive:t})&&(i=e,s=t)}var a;if(null!==n)for(let t=0;t<e.orderBy.length;++t)if(e.orderBy[t].field.isEqual(r)){let e=n.position[t];0<Cv({value:i,inclusive:s},{value:e,inclusive:n.inclusive})&&(i=e,s=n.inclusive);break}return{value:i,inclusive:s}}class L_{constructor(e,t=null,r=[],n=[],i=null,s="F",a=null,o=null){this.path=e,this.collectionGroup=t,this.explicitOrderBy=r,this.filters=n,this.limit=i,this.limitType=s,this.startAt=a,this.endAt=o,this.fe=null,this.me=null,this.pe=null,this.startAt,this.endAt}}function M_(e,t,r,n,i,s,a,o){return new L_(e,t,r,n,i,s,a,o)}function F_(e){return new L_(e)}function U_(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 V_(e){return null!==e.collectionGroup}function B_(e){let n=e;if(null===n.fe){n.fe=[];let t=new Set;for(var i of n.explicitOrderBy)n.fe.push(i),t.add(i.field.canonicalString());let r=0<n.explicitOrderBy.length?n.explicitOrderBy[n.explicitOrderBy.length-1].dir:"asc",e=(e=>{let t=new k6(T2.comparator);return e.filters.forEach(e=>{e.getFlattenedFilters().forEach(e=>{e.isInequality()&&(t=t.add(e.field))})}),t})(n);e.forEach(e=>{t.has(e.canonicalString())||e.isKeyField()||n.fe.push(new I_(e,r))}),t.has(T2.keyField().canonicalString())||n.fe.push(new I_(T2.keyField(),r))}return n.fe}function q_(e){var t=e;return t.me||(t.me=((e,t)=>{if("F"===e.limitType)return k_(e.path,e.collectionGroup,t,e.filters,e.limit,e.startAt,e.endAt);t=t.map(e=>{var t="desc"===e.dir?"asc":"desc";return new I_(e.field,t)});var r=e.endAt?new s_(e.endAt.position,e.endAt.inclusive):null,n=e.startAt?new s_(e.startAt.position,e.startAt.inclusive):null;return k_(e.path,e.collectionGroup,t,e.filters,e.limit,r,n)})(t,B_(e))),t.me}function j_(e,t){var r=e.filters.concat([t]);return new L_(e.path,e.collectionGroup,e.explicitOrderBy.slice(),r,e.limit,e.limitType,e.startAt,e.endAt)}function z_(e,t,r){return new L_(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),t,r,e.startAt,e.endAt)}function H_(e,t){return N_(q_(e),q_(t))&&e.limitType===t.limitType}function K_(e){return`Query(target=${(e=>{let t=e.path.canonicalString();return null!==e.collectionGroup&&(t+=" collectionGroup="+e.collectionGroup),0<e.filters.length&&(t+=`, filters: [${e.filters.map(e=>g_(e)).join(", ")}]`),h0(e.limit)||(t+=", limit: "+e.limit),0<e.orderBy.length&&(t+=`, orderBy: [${e.orderBy.map(e=>`${(e=e).field.canonicalString()} (${e.dir})`).join(", ")}]`),e.startAt&&(t=(t=(t+=", startAt: ")+(e.startAt.inclusive?"b:":"a:"))+e.startAt.position.map(e=>hv(e)).join(",")),`Target(${t=e.endAt?(t=(t+=", endAt: ")+(e.endAt.inclusive?"a:":"b:"))+e.endAt.position.map(e=>hv(e)).join(","):t})`})(q_(e))}; limitType=${e.limitType})`}function G_(e,t){return t.isFoundDocument()&&(s=e,o=(a=t).key.path,null!==s.collectionGroup?a.key.hasCollectionId(s.collectionGroup)&&s.path.isPrefixOf(o):D.isDocumentKey(s.path)?s.path.isEqual(o):s.path.isImmediateParentOf(o))&&((e,t)=>{for(var r of B_(e))if(!r.field.isKeyField()&&null===t.data.field(r.field))return!1;return!0})(e,t)&&((e,t)=>{for(var r of e.filters)if(!r.matches(t))return!1;return!0})(e,t)&&(a=t,!(s=e).startAt||(n=s.startAt,r=B_(s),i=a_(n,r,a),n.inclusive?i<=0:i<0))&&(!s.endAt||(r=s.endAt,n=B_(s),i=a_(r,n,a),r.inclusive?0<=i:0<i));var r,n,i,s,a,o}function W_(e){return(t,r)=>{let n=!1;for(var i of B_(e)){let e=((e,t,r)=>{var n=e.field.isKeyField()?D.comparator(t.key,r.key):((e,t,r)=>{var n=t.data.field(e),i=r.data.field(e);return null!==n&&null!==i?ov(n,i):k(42886)})(e.field,t,r);switch(e.dir){case"asc":return n;case"desc":return-1*n;default:return k(19790,{direction:e.dir})}})(i,t,r);if(0!==e)return e;n=n||i.field.isKeyField()}return 0}}class $_{constructor(e,t){this.count=e,this.unchangedNames=t}}function Y_(e){switch(e){case N.OK:return k(64938);case N.CANCELLED:case N.UNKNOWN:case N.DEADLINE_EXCEEDED:case N.RESOURCE_EXHAUSTED:case N.INTERNAL:case N.UNAVAILABLE:case N.UNAUTHENTICATED:return!1;case N.INVALID_ARGUMENT:case N.NOT_FOUND:case N.ALREADY_EXISTS:case N.PERMISSION_DENIED:case N.FAILED_PRECONDITION:case N.ABORTED:case N.OUT_OF_RANGE:case N.UNIMPLEMENTED:case N.DATA_LOSS:return!0;default:return k(15467,{code:e})}}function Q_(e){if(void 0===e)return Zm("GRPC error has no .code"),N.UNKNOWN;switch(e){case Sm.OK:return N.OK;case Sm.CANCELLED:return N.CANCELLED;case Sm.UNKNOWN:return N.UNKNOWN;case Sm.DEADLINE_EXCEEDED:return N.DEADLINE_EXCEEDED;case Sm.RESOURCE_EXHAUSTED:return N.RESOURCE_EXHAUSTED;case Sm.INTERNAL:return N.INTERNAL;case Sm.UNAVAILABLE:return N.UNAVAILABLE;case Sm.UNAUTHENTICATED:return N.UNAUTHENTICATED;case Sm.INVALID_ARGUMENT:return N.INVALID_ARGUMENT;case Sm.NOT_FOUND:return N.NOT_FOUND;case Sm.ALREADY_EXISTS:return N.ALREADY_EXISTS;case Sm.PERMISSION_DENIED:return N.PERMISSION_DENIED;case Sm.FAILED_PRECONDITION:return N.FAILED_PRECONDITION;case Sm.ABORTED:return N.ABORTED;case Sm.OUT_OF_RANGE:return N.OUT_OF_RANGE;case Sm.UNIMPLEMENTED:return N.UNIMPLEMENTED;case Sm.DATA_LOSS:return N.DATA_LOSS;default:return k(39323,{code:e})}}(e=Sm=Sm||{})[e.OK=0]="OK",e[e.CANCELLED=1]="CANCELLED",e[e.UNKNOWN=2]="UNKNOWN",e[e.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",e[e.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",e[e.NOT_FOUND=5]="NOT_FOUND",e[e.ALREADY_EXISTS=6]="ALREADY_EXISTS",e[e.PERMISSION_DENIED=7]="PERMISSION_DENIED",e[e.UNAUTHENTICATED=16]="UNAUTHENTICATED",e[e.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",e[e.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",e[e.ABORTED=10]="ABORTED",e[e.OUT_OF_RANGE=11]="OUT_OF_RANGE",e[e.UNIMPLEMENTED=12]="UNIMPLEMENTED",e[e.INTERNAL=13]="INTERNAL",e[e.UNAVAILABLE=14]="UNAVAILABLE",e[e.DATA_LOSS=15]="DATA_LOSS";class J_{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.innerSize=0}get(r){let e=this.mapKeyFn(r),n=this.inner[e];if(void 0!==n)for(let[e,t]of n)if(this.equalsFn(e,r))return t}has(e){return void 0!==this.get(e)}set(t,r){var e=this.mapKeyFn(t),n=this.inner[e];if(void 0===n)this.inner[e]=[[t,r]];else{for(let e=0;e<n.length;e++)if(this.equalsFn(n[e][0],t))return void(n[e]=[t,r]);n.push([t,r])}this.innerSize++}delete(t){var r=this.mapKeyFn(t),n=this.inner[r];if(void 0!==n)for(let e=0;e<n.length;e++)if(this.equalsFn(n[e][0],t))return 1===n.length?delete this.inner[r]:n.splice(e,1),this.innerSize--,!0;return!1}forEach(n){x6(this.inner,(e,t)=>{for(let[e,r]of t)n(e,r)})}isEmpty(){return D6(this.inner)}size(){return this.innerSize}}let X_=new I6(D.comparator);let Z_=new I6(D.comparator);function ey(...e){let t=Z_;for(var r of e)t=t.insert(r.key,r);return t}function ty(e){let r=Z_;return e.forEach((e,t)=>r=r.insert(e,t.overlayedDocument)),r}function ry(){return new J_(e=>e.toString(),(e,t)=>e.isEqual(t))}let ny=new I6(D.comparator),iy=new k6(D.comparator);function F(...e){let t=iy;for(var r of e)t=t.add(r);return t}let sy=new k6(P);function ay(){return new TextEncoder}let oy=new $g([4294967295,4294967295],0);function ly(e){var t=ay().encode(e),r=new Yg;return r.update(t),new Uint8Array(r.digest())}function uy(e){var t=new DataView(e.buffer),r=t.getUint32(0,!0),n=t.getUint32(4,!0),i=t.getUint32(8,!0),t=t.getUint32(12,!0);return[new $g([r,n],0),new $g([i,t],0)]}class hy{constructor(e,t,r){if(this.bitmap=e,this.padding=t,this.hashCount=r,t<0||8<=t)throw new cy("Invalid padding: "+t);if(r<0)throw new cy("Invalid hash count: "+r);if(0<e.length&&0===this.hashCount)throw new cy("Invalid hash count: "+r);if(0===e.length&&0!==t)throw new cy("Invalid padding when bitmap length is 0: "+t);this.ge=8*e.length-t,this.ye=$g.fromNumber(this.ge)}we(e,t,r){let n=e.add(t.multiply($g.fromNumber(r)));return(n=1===n.compare(oy)?new $g([n.getBits(0),n.getBits(1)],0):n).modulo(this.ye).toNumber()}be(e){return!!(this.bitmap[Math.floor(e/8)]&1<<e%8)}mightContain(e){if(0===this.ge)return!1;let t=ly(e),[r,n]=uy(t);for(let i=0;i<this.hashCount;i++){let e=this.we(r,n,i);if(!this.be(e))return!1}return!0}static create(e,t,r){let n=e%8==0?0:8-e%8,i=new Uint8Array(Math.ceil(e/8)),s=new hy(i,n,t);return r.forEach(e=>s.insert(e)),s}insert(i){if(0!==this.ge){let e=ly(i),[t,r]=uy(e);for(let n=0;n<this.hashCount;n++){let e=this.we(t,r,n);this.ve(e)}}}ve(e){var t=Math.floor(e/8);this.bitmap[t]|=1<<e%8}}class cy extends Error{constructor(){super(...arguments),this.name="BloomFilterError"}}class dy{constructor(e,t,r,n,i,s){this.snapshotVersion=e,this.targetChanges=t,this.targetMismatches=r,this.documentUpdates=n,this.augmentedDocumentUpdates=i,this.resolvedLimboDocuments=s}static createSynthesizedRemoteEventForCurrentChange(e,t,r){var n=new Map;return n.set(e,py.createSynthesizedTargetChangeForCurrentChange(e,t,r)),new dy(O.min(),n,new I6(P),X_,X_,F())}}class py{constructor(e,t,r,n,i){this.resumeToken=e,this.current=t,this.addedDocuments=r,this.modifiedDocuments=n,this.removedDocuments=i}static createSynthesizedTargetChangeForCurrentChange(e,t,r){return new py(r,t,F(),F(),F())}}class fy{constructor(e,t,r,n){this.Se=e,this.removedTargetIds=t,this.key=r,this.De=n}}class gy{constructor(e,t){this.targetId=e,this.xe=t}}class my{constructor(e,t,r=L6.EMPTY_BYTE_STRING,n=null){this.state=e,this.targetIds=t,this.resumeToken=r,this.cause=n}}class vy{constructor(e){this.targetId=e,this.Ce=0,this.Fe=by(),this.Oe=L6.EMPTY_BYTE_STRING,this.Me=!1,this.Ne=!0}get current(){return this.Me}get resumeToken(){return this.Oe}get Le(){return 0!==this.Ce}get Be(){return this.Ne}Ue(e){0<e.approximateByteSize()&&(this.Ne=!0,this.Oe=e)}ke(){let r=F(),n=F(),i=F();return this.Fe.forEach((e,t)=>{switch(t){case 0:r=r.add(e);break;case 2:n=n.add(e);break;case 1:i=i.add(e);break;default:k(38017,{changeType:t})}}),new py(this.Oe,this.Me,r,n,i)}qe(){this.Ne=!1,this.Fe=by()}$e(e,t){this.Ne=!0,this.Fe=this.Fe.insert(e,t)}Ke(e){this.Ne=!0,this.Fe=this.Fe.remove(e)}We(){this.Ce+=1}Qe(){--this.Ce,A(0<=this.Ce,3241,{Ce:this.Ce,targetId:this.targetId})}Ge(){this.Ne=!0,this.Me=!0}}let _y="WatchChangeAggregator";class yy{constructor(e){this.ze=e,this.je=new Map,this.He=X_,this.Je=wy(),this.Ye=X_,this.Ze=wy(),this.Xe=new I6(P)}et(e){for(var t of e.Se)e.De&&e.De.isFoundDocument()?this.tt(t,e.De):this.nt(t,e.key,e.De);for(var r of e.removedTargetIds)this.nt(r,e.key,e.De)}rt(r){this.forEachTarget(r,e=>{var t=this.je.get(e);if(t)switch(r.state){case 0:this.it(e)&&t.Ue(r.resumeToken);break;case 1:t.Qe(),t.Le||t.qe(),t.Ue(r.resumeToken);break;case 2:t.Qe(),t.Le||this.removeTarget(e);break;case 3:this.it(e)&&(t.Ge(),t.Ue(r.resumeToken));break;case 4:this.it(e)&&(this.st(e),t.Ue(r.resumeToken));break;default:k(56790,{state:r.state})}else S(_y,`handleTargetChange received targetChange for untracked target ID (${e}) with state (${r.state})`)})}forEachTarget(e,r){0<e.targetIds.length?e.targetIds.forEach(r):this.je.forEach((e,t)=>{this.it(t)&&r(t)})}_t(e){return R_(e)?"documents"===e.getPipelineSourceType()&&1===e.getPipelineDocuments()?.length:P_(e)}ot(n){let i=n.targetId,e=n.xe.count,t=this.ut(i);if(t){var r=t.target;if(this._t(r))if(0===e){let e=new D(R_(r)?x.fromString(r.getPipelineDocuments()[0]):r.path);this.nt(i,e,C_.newNoDocument(e,O.min()))}else A(1===e,20013,"Single document existence filter with count: "+e);else{let r=this.ct(i);if(r!==e){let e=this.lt(n),t=e?this.Et(e,n,r):1;if(0!==t){this.st(i);let e=2===t?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch";this.Xe=this.Xe.insert(i,e)}}}}}lt(e){var t=e.xe.unchangedNames;if(!t||!t.bits)return null;var{bits:{bitmap:t="",padding:r=0},hashCount:n=0}=t;let i,s;try{i=V6(t).toUint8Array()}catch(e){if(e instanceof O6)return e2("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 hy(i,r,n)}catch(e){return e2(e instanceof cy?"BloomFilter error: ":"Applying bloom filter failed: ",e),null}return 0===s.ge?null:s}Et(e,t,r){return t.xe.count===r-this.Pt(e,t.targetId)?0:2}Pt(r,n){var e=this.ze.getRemoteKeysForTarget(n);let i=0;return e.forEach(e=>{var t=this.ze.Tt(),t=`projects/${t.projectId}/databases/${t.database}/documents/`+e.path.canonicalString();r.mightContain(t)||(this.nt(n,e,null),i++)}),i}Rt(i){let t=new Map,n=(this.je.forEach((e,r)=>{var n=this.ut(r);if(n){if(e.current&&this._t(n.target)){let e=R_(n.target)?x.fromString(n.target.getPipelineDocuments()[0]):n.target.path,t=new D(e);this.It(t).has(r)||this.At(r,t)||this.nt(r,t,C_.newNoDocument(t,i))}e.Be&&(t.set(r,e.ke()),e.qe())}}),F());this.Ze.forEach((e,t)=>{let r=!0;t.forEachWhile(e=>{var t=this.ut(e);return!t||"TargetPurposeLimboResolution"===t.purpose||(r=!1)}),r&&(n=n.add(e))}),this.He.forEach((e,t)=>t.setReadTime(i)),this.Ye.forEach((e,t)=>t.setReadTime(i));var e=new dy(i,t,this.Xe,this.He,this.Ye,n);return this.He=X_,this.Je=wy(),this.Ye=X_,this.Ze=wy(),this.Xe=new I6(P),e}tt(e,t){var r,n=this.je.get(e);n&&this.it(e)?(r=this.At(e,t.key)?2:0,n.$e(t.key,r),R_(this.ut(e).target)&&"exact"!==this.ut(e).target.getPipelineFlavor()?this.Ye=this.Ye.insert(t.key,t):this.He=this.He.insert(t.key,t),this.Je=this.Je.insert(t.key,this.It(t.key).add(e)),this.Ze=this.Ze.insert(t.key,this.Vt(t.key).add(e))):S(_y,`addDocumentToTarget received document for unknown inactive target (${e})`)}nt(e,t,r){var n=this.je.get(e);n&&this.it(e)?(this.At(e,t)?n.$e(t,1):n.Ke(t),this.Ze=this.Ze.insert(t,this.Vt(t).delete(e)),this.Ze=this.Ze.insert(t,this.Vt(t).add(e)),r&&(R_(this.ut(e).target)&&"exact"!==this.ut(e).target.getPipelineFlavor()?this.Ye=this.Ye.insert(t,r):this.He=this.He.insert(t,r))):S(_y,`removeDocumentFromTarget received document for unknown or inactive target (${e})`)}removeTarget(e){this.je.delete(e)}ct(e){var t=this.je.get(e);return t?(t=t.ke(),this.ze.getRemoteKeysForTarget(e).size+t.addedDocuments.size-t.removedDocuments.size):0}We(e){let t=this.je.get(e);t||(S(_y,"recordPendingTargetRequest set up tracking for target ID "+e),t=new vy(e),this.je.set(e,t)),t.We()}Vt(e){let t=this.Ze.get(e);return t||(t=new k6(P),this.Ze=this.Ze.insert(e,t)),t}It(e){let t=this.Je.get(e);return t||(t=new k6(P),this.Je=this.Je.insert(e,t)),t}it(e){var t=null!==this.ut(e);return t||S(_y,"Detected inactive target",e),t}ut(e){var t=this.je.get(e);return void 0===t||t.Le?null:this.ze.dt(e)}st(t){this.je.set(t,new vy(t)),this.ze.getRemoteKeysForTarget(t).forEach(e=>{this.nt(t,e,null)})}At(e,t){return this.ze.getRemoteKeysForTarget(e).has(t)}}function wy(){return new I6(D.comparator)}function by(){return new I6(D.comparator)}let Ty={asc:"ASCENDING",desc:"DESCENDING"},Ey={"<":"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"},Iy={and:"AND",or:"OR"};class Cy{constructor(e,t){this.databaseId=e,this.useProto3Json=t}}function Sy(e,t){return e.useProto3Json||h0(t)?t:{value:t}}function ky(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 Ay(e){var t=F6(e);return new O2(t.seconds,t.nanos)}function Ny(e,t){return e.useProto3Json?t.toBase64():t.toUint8Array()}function Ry(e,t){return ky(e,t.toTimestamp())}function Py(e){return A(!!e,49232),O.fromTimestamp(Ay(e))}function xy(e,t){return Dy(e,t).canonicalString()}function Dy(e,t){e=e;var r=new x(["projects",e.projectId,"databases",e.database]).child("documents");return void 0===t?r:r.child(t)}function Oy(e){var t=x.fromString(e);return A(t7(t),10190,{key:t.toString()}),t}function Ly(e,t){return xy(e.databaseId,t.path)}function My(e,t){var r=Oy(t);if(r.get(1)!==e.databaseId.projectId)throw new R(N.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+r.get(1)+" vs "+e.databaseId.projectId);if(r.get(3)!==e.databaseId.database)throw new R(N.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+r.get(3)+" vs "+e.databaseId.database);return new D(By(r))}function Fy(e,t){return xy(e.databaseId,t)}function Uy(e){var t=Oy(e);return 4===t.length?x.emptyPath():By(t)}function Vy(e){return new x(["projects",e.databaseId.projectId,"databases",e.databaseId.database]).canonicalString()}function By(e){return A(4<e.length&&"documents"===e.get(4),29091,{key:e.toString()}),e.popFirst(5)}function qy(e,t,r){return{name:Ly(e,t),fields:r.value.mapValue.fields}}function jy(e,t,r){var n=My(e,t.name),i=Py(t.updateTime),s=t.createTime?Py(t.createTime):O.min(),a=new Sv({mapValue:{fields:t.fields}}),n=C_.newFoundDocument(n,i,s,a);return r&&n.setHasCommittedMutations(),r?n.setHasCommittedMutations():n}function zy(e,t){let r;if(t instanceof Xv)r={update:qy(e,t.key,t.value)};else if(t instanceof n_)r={delete:Ly(e,t.key)};else if(t instanceof Zv)r={update:qy(e,t.key,t.data),updateMask:(e=>{let t=[];return e.fields.forEach(e=>t.push(e.canonicalString())),{fieldPaths:t}})(t.fieldMask)};else{if(!(t instanceof i_))return k(16599,{gt:t.type});r={verify:Ly(e,t.key)}}return 0<t.fieldTransforms.length&&(r.updateTransforms=t.fieldTransforms.map(e=>{var t=e.transform;if(t instanceof xv)return{fieldPath:e.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(t instanceof Dv)return{fieldPath:e.field.canonicalString(),appendMissingElements:{values:t.elements}};if(t instanceof Lv)return{fieldPath:e.field.canonicalString(),removeAllFromArray:{values:t.elements}};if(t instanceof Uv)return{fieldPath:e.field.canonicalString(),increment:t.Re};if(t instanceof Vv)return{fieldPath:e.field.canonicalString(),minimum:t.Re};if(t instanceof Bv)return{fieldPath:e.field.canonicalString(),maximum:t.Re};throw k(20930,{transform:e.transform})})),t.precondition.isNone||(r.currentDocument=(e=e,void 0!==(t=t.precondition).updateTime?{updateTime:Ry(e,t.updateTime)}:void 0!==t.exists?{exists:t.exists}:k(27497))),r}function Hy(i,t){let r=t.currentDocument?void 0!==(s=t.currentDocument).updateTime?Gv.updateTime(Py(s.updateTime)):void 0!==s.exists?Gv.exists(s.exists):Gv.none():Gv.none(),n=t.updateTransforms?t.updateTransforms.map(r=>{{var e=i;let t=null;if("setToServerValue"in r)A("REQUEST_TIME"===r.setToServerValue,16630,{proto:r}),t=new xv;else if("appendMissingElements"in r){let e=r.appendMissingElements.values||[];t=new Dv(e)}else if("removeAllFromArray"in r){let e=r.removeAllFromArray.values||[];t=new Lv(e)}else"increment"in r?t=new Uv(e,r.increment):"minimum"in r?t=new Vv(e,r.minimum):"maximum"in r?t=new Bv(e,r.maximum):k(16584,{proto:r});var n=T2.fromServerFormat(r.fieldPath);return new Hv(n,t)}}):[];var s,a;if(t.update){t.update.name;var o=My(i,t.update.name),l=new Sv({mapValue:{fields:t.update.fields}});if(t.updateMask){s=t.updateMask,a=s.fieldPaths||[];let e=new R6(a.map(e=>T2.fromServerFormat(e)));return new Zv(o,l,e,r,n)}return new Xv(o,l,r,n)}if(t.delete){let e=My(i,t.delete);return new n_(e,r)}if(t.verify){let e=My(i,t.verify);return new i_(e,r)}return k(1463,{proto:t})}function Ky(e,n){return e&&0<e.length?(A(void 0!==n,14353),e.map(t=>{{var r=n;let e=t.updateTime?Py(t.updateTime):Py(r);return e.isEqual(O.min())&&(e=Py(r)),new Kv(e,t.transformResults||[])}})):[]}function Gy(e,t){return{documents:[Fy(e,t.path)]}}function Wy(e,t){var r={structuredQuery:{}},n=t.path;let i;null!==t.collectionGroup?(i=n,r.structuredQuery.from=[{collectionId:t.collectionGroup,allDescendants:!0}]):(i=n.popLast(),r.structuredQuery.from=[{collectionId:n.lastSegment()}]),r.parent=Fy(e,i);n=(e=>{if(0!==e.length)return function r(e){return e instanceof M?(e=>{if("=="===e.op){if(vv(e.value))return{unaryFilter:{field:Zy(e.field),op:"IS_NAN"}};if(mv(e.value))return{unaryFilter:{field:Zy(e.field),op:"IS_NULL"}}}else if("!="===e.op){if(vv(e.value))return{unaryFilter:{field:Zy(e.field),op:"IS_NOT_NAN"}};if(mv(e.value))return{unaryFilter:{field:Zy(e.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:Zy(e.field),op:Jy(e.op),value:e.value}}})(e):e instanceof u_?(e=>{let t=e.getFilters().map(e=>r(e));return 1===t.length?t[0]:{compositeFilter:{op:Xy(e.op),filters:t}}})(e):k(54877,{filter:e})}(u_.create(e,"and"))})(t.filters),n&&(r.structuredQuery.where=n),n=(e=>{if(0!==e.length)return e.map(e=>({field:Zy((e=e).field),direction:(e=e.dir,Ty[e])}))})(t.orderBy),n&&(r.structuredQuery.orderBy=n),n=Sy(e,t.limit);return null!==n&&(r.structuredQuery.limit=n),t.startAt&&(r.structuredQuery.startAt={before:(e=t.startAt).inclusive,values:e.position}),t.endAt&&(r.structuredQuery.endAt={before:!(e=t.endAt).inclusive,values:e.position}),{yt:r,parent:i}}function $y(e){let t=Uy(e.parent);var r,n=e.structuredQuery,i=n.from?n.from.length:0;let s=null;if(0<i){A(1===i,65062);let e=n.from[0];e.allDescendants?s=e.collectionId:t=t.child(e.collectionId)}let a=[],o=(n.where&&(a=(e=n.where,(i=function t(e){return void 0!==e.unaryFilter?(i=>{switch(i.unaryFilter.op){case"IS_NAN":let e=e7(i.unaryFilter.field);return M.create(e,"==",{doubleValue:NaN});case"IS_NULL":let t=e7(i.unaryFilter.field);return M.create(t,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":let r=e7(i.unaryFilter.field);return M.create(r,"!=",{doubleValue:NaN});case"IS_NOT_NULL":let n=e7(i.unaryFilter.field);return M.create(n,"!=",{nullValue:"NULL_VALUE"});case"OPERATOR_UNSPECIFIED":return k(61313);default:return k(60726)}})(e):void 0!==e.fieldFilter?(e=>M.create(e7(e.fieldFilter.field),(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 k(58110);default:return k(50506)}})(e.fieldFilter.op),e.fieldFilter.value))(e):void 0!==e.compositeFilter?(e=>u_.create(e.compositeFilter.filters.map(e=>t(e)),(e=>{switch(e){case"AND":return"and";case"OR":return"or";default:return k(1026)}})(e.compositeFilter.op)))(e):k(30097,{filter:e})}(e))instanceof u_&&d_(i)?i.getFilters():[i])),[]),l=(n.orderBy&&(o=n.orderBy.map(e=>(e=e,new I_(e7(e.field),(e=>{switch(e){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}})(e.direction))))),null),u=(n.limit&&(l=(e=n.limit,h0(i="object"==typeof e?e.value:e)?null:i)),null),h=(n.startAt&&(u=(e=n.startAt,i=!!e.before,r=e.values||[],new s_(r,i))),null);return n.endAt&&(h=(e=n.endAt,r=!e.before,i=e.values||[],new s_(i,r))),M_(t,s,o,a,l,"F",u,h)}function Yy(e,t){var r=(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 k(28987,{purpose:e})}})(t.purpose);return null==r?null:{"goog-listen-tags":r}}function Qy(t,e){return{structuredPipeline:{pipeline:{stages:e.stages.map(e=>e._toProto(t))}}}}function Jy(e){return Ey[e]}function Xy(e){return Iy[e]}function Zy(e){return{fieldPath:e.canonicalString()}}function e7(e){return T2.fromServerFormat(e.fieldPath)}function t7(e){return 4<=e.length&&"projects"===e.get(0)&&"databases"===e.get(2)}function r7(e){return e&&"function"==typeof e._toProto&&"ProtoValue"===e._protoValueType}function n7(r,e){let n={fields:{}};return e.forEach((e,t)=>{if("string"!=typeof t)throw new Error("Cannot encode map with non-string key: "+t);n.fields[t]=e._toProto(r)}),{mapValue:n}}function i7(e){return{stringValue:e}}function s7(e){return new Cy(e,!0)}class a7{constructor(e){this._byteString=e}static fromBase64String(e){try{return new a7(L6.fromBase64String(e))}catch(e){throw new R(N.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+e)}}static fromUint8Array(e){return new a7(L6.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:a7._jsonSchemaVersion,bytes:this.toBase64()}}static fromJSON(e){if(x2(e,a7._jsonSchema))return a7.fromBase64String(e.bytes)}}a7._jsonSchemaVersion="firestore/bytes/1.0",a7._jsonSchema={type:P2("string",a7._jsonSchemaVersion),bytes:P2("string")};class o7{constructor(...e){for(let t=0;t<e.length;++t)if(0===e[t].length)throw new R(N.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new T2(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}}class l7{constructor(e){this._methodName=e}}class u7{constructor(e,t){if(!isFinite(e)||e<-90||90<e)throw new R(N.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(t)||t<-180||180<t)throw new R(N.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 P(this._lat,e._lat)||P(this._long,e._long)}toJSON(){return{latitude:this._lat,longitude:this._long,type:u7._jsonSchemaVersion}}static fromJSON(e){if(x2(e,u7._jsonSchema))return new u7(e.latitude,e.longitude)}}function h7(e){var t={};return void 0!==e.timeoutSeconds&&(t.timeoutSeconds=e.timeoutSeconds),t}u7._jsonSchemaVersion="firestore/geoPoint/1.0",u7._jsonSchema={type:P2("string",u7._jsonSchemaVersion),latitude:P2("number"),longitude:P2("number")};class c7{bt(e){}shutdown(){}}let d7="ConnectivityMonitor";class p7{constructor(){this.vt=()=>this.St(),this.Dt=()=>this.xt(),this.Ct=[],this.Ft()}bt(e){this.Ct.push(e)}shutdown(){window.removeEventListener("online",this.vt),window.removeEventListener("offline",this.Dt)}Ft(){window.addEventListener("online",this.vt),window.addEventListener("offline",this.Dt)}St(){S(d7,"Network connectivity changed: AVAILABLE");for(var e of this.Ct)e(0)}xt(){S(d7,"Network connectivity changed: UNAVAILABLE");for(var e of this.Ct)e(1)}static C(){return"undefined"!=typeof window&&void 0!==window.addEventListener&&void 0!==window.removeEventListener}}let f7=null;function g7(){return null===f7?f7=268435456+Math.round(2147483648*Math.random()):f7++,"0x"+f7.toString(16)}let m7="RestConnection",v7={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery",ExecutePipeline:"executePipeline"};class _7{constructor(e){this.Kt=e.Kt,this.Wt=e.Wt}Qt(e){this.Gt=e}zt(e){this.jt=e}Ht(e){this.Jt=e}onMessage(e){this.Yt=e}close(){this.Wt()}send(e){this.Kt(e)}Zt(){this.Gt()}Xt(){this.jt()}en(e){this.Jt(e)}tn(e){this.Yt(e)}}let y7="WebChannelConnection",w7=(e,t,r)=>{e.listen(t,e=>{try{r(e)}catch(e){setTimeout(()=>{throw e},0)}})};class b7 extends class{get Ot(){return!1}constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;var t=e.ssl?"https":"http",r=encodeURIComponent(this.databaseId.projectId),n=encodeURIComponent(this.databaseId.database);this.Mt=t+"://"+e.host,this.Nt=`projects/${r}/databases/`+n,this.Lt=this.databaseId.database===$6?"project_id="+r:`project_id=${r}&database_id=`+n}Bt(t,e,r,n,i){let s=g7(),a=this.Ut(t,e.toUriEncodedString());S(m7,`Sending RPC '${t}' ${s}:`,a,r);var o={"google-cloud-resource-prefix":this.Nt,"x-goog-request-params":this.Lt},l=(this.kt(o,n,i),new URL(a)).host,l=ze(l);return this.qt(t,a,o,r,l).then(e=>(S(m7,`Received RPC '${t}' ${s}: `,e),e),e=>{throw e2(m7,`RPC '${t}' ${s} failed with error: `,e,"url: ",a,"request:",r),e})}$t(e,t,r,n,i,s){return this.Bt(e,t,r,n,i)}kt(r,e,t){r["X-Goog-Api-Client"]="gl-js/ fire/"+Qm,r["Content-Type"]="text/plain",this.databaseInfo.appId&&(r["X-Firebase-GMPID"]=this.databaseInfo.appId),e&&e.headers.forEach((e,t)=>r[t]=e),t&&t.headers.forEach((e,t)=>r[t]=e)}Ut(e,t){var r=v7[e];let n=this.Mt+`/v1/${t}:`+r;return n=this.databaseInfo.apiKey?n+"?key="+encodeURIComponent(this.databaseInfo.apiKey):n}terminate(){}}{constructor(e){super(e),this.nn=[],this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}static rn(){var e;b7.sn||(e=rm(),w7(e,tm.STAT_EVENT,e=>{e.stat===em.PROXY?S(y7,"STAT_EVENT: detected buffering proxy"):e.stat===em.NOPROXY&&S(y7,"STAT_EVENT: detected no buffering proxy")}),b7.sn=!0)}qt(l,t,r,n,e){let u=g7();return new Promise((s,a)=>{let o=new Qg;o.setWithCredentials(!0),o.listenOnce(Xg.COMPLETE,()=>{try{switch(o.getLastErrorCode()){case Zg.NO_ERROR:var e=o.getResponseJson();S(y7,`XHR for RPC '${l}' ${u} received:`,JSON.stringify(e)),s(e);break;case Zg.TIMEOUT:S(y7,`RPC '${l}' ${u} timed out`),a(new R(N.DEADLINE_EXCEEDED,"Request time out"));break;case Zg.HTTP_ERROR:var t=o.getStatus();if(S(y7,`RPC '${l}' ${u} failed with status:`,t,"response text:",o.getResponseText()),0<t){let e=o.getResponseJson();var r=(e=Array.isArray(e)?e[0]:e)?.error;if(r&&r.status&&r.message){n=r.status,i=n.toLowerCase().replace(/_/g,"-");let e=0<=Object.values(N).indexOf(i)?i:N.UNKNOWN;a(new R(e,r.message))}else a(new R(N.UNKNOWN,"Server responded with status "+o.getStatus()))}else a(new R(N.UNAVAILABLE,"Connection failed."));break;default:k(9055,{_n:l,streamId:u,an:o.getLastErrorCode(),un:o.getLastError()})}}finally{S(y7,`RPC '${l}' ${u} completed.`)}var n,i});var e=JSON.stringify(n);S(y7,`RPC '${l}' ${u} sending request:`,n),o.send(t,"POST",e,r,15)})}cn(i,e,t){let s=g7(),r=[this.Mt,"/","google.firestore.v1.Firestore","/",i,"/channel"],n=this.createWebChannelTransport(),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},o=this.longPollingOptions.timeoutSeconds;void 0!==o&&(a.longPollingTimeout=Math.round(1e3*o)),this.useFetchStreams&&(a.useFetchStreams=!0),this.kt(a.initMessageHeaders,e,t),a.encodeInitMessageHeaders=!0;var l=r.join("");S(y7,`Creating RPC '${i}' stream ${s}: `+l,a);let u=n.createWebChannel(l,a),h=(this.En(u),!1),c=!1,d=new _7({Kt:e=>{c?S(y7,`Not sending because RPC '${i}' stream ${s} is closed:`,e):(h||(S(y7,`Opening RPC '${i}' stream ${s} transport.`),u.open(),h=!0),S(y7,`RPC '${i}' stream ${s} sending:`,e),u.send(e))},Wt:()=>u.close()});return w7(u,Jg.EventType.OPEN,()=>{c||(S(y7,`RPC '${i}' stream ${s} transport opened.`),d.Zt())}),w7(u,Jg.EventType.CLOSE,()=>{c||(c=!0,S(y7,`RPC '${i}' stream ${s} transport closed`),d.en(),this.hn(u))}),w7(u,Jg.EventType.ERROR,e=>{c||(c=!0,e2(y7,`RPC '${i}' stream ${s} transport errored. Name:`,e.name,"Message:",e.message),d.en(new R(N.UNAVAILABLE,"The operation could not be completed")))}),w7(u,Jg.EventType.MESSAGE,e=>{if(!c){var t=e.data[0],n=(A(!!t,16349),t),n=n?.error||n[0]?.error;if(n){S(y7,`RPC '${i}' stream ${s} received error:`,n);let e=n.status,t=(e=>{var t=Sm[e];if(void 0!==t)return Q_(t)})(e),r=n.message;"NOT_FOUND"===e&&r.includes("database")&&r.includes("does not exist")&&r.includes(this.databaseId.database)&&e2(`Database '${this.databaseId.database}' not found. Please check your project configuration.`),void 0===t&&(t=N.INTERNAL,r="Unknown error status: "+e+" with message "+n.message),c=!0,d.en(new R(t,r)),u.close()}else S(y7,`RPC '${i}' stream ${s} received:`,t),d.tn(t)}}),b7.rn(),setTimeout(()=>{d.Xt()},0),d}terminate(){this.nn.forEach(e=>e.close()),this.nn=[]}En(e){this.nn.push(e)}hn(t){this.nn=this.nn.filter(e=>e===t)}kt(e,t,r){super.kt(e,t,r),this.databaseInfo.apiKey&&(e["x-goog-api-key"]=this.databaseInfo.apiKey)}createWebChannelTransport(){return nm()}}b7.sn=!1;class T7{constructor(e,t,r=1e3,n=1.5,i=6e4){this.Tn=e,this.timerId=t,this.Pn=r,this.Rn=n,this.In=i,this.An=0,this.Vn=null,this.dn=Date.now(),this.reset()}reset(){this.An=0}fn(){this.An=this.In}mn(e){this.cancel();var t=Math.floor(this.An+this.pn()),r=Math.max(0,Date.now()-this.dn),n=Math.max(0,t-r);0<n&&S("ExponentialBackoff",`Backing off for ${n} ms (base delay: ${this.An} ms, delay with jitter: ${t} ms, last attempt: ${r} ms ago)`),this.Vn=this.Tn.enqueueAfterDelay(this.timerId,n,()=>(this.dn=Date.now(),e())),this.An*=this.Rn,this.An<this.Pn&&(this.An=this.Pn),this.An>this.In&&(this.An=this.In)}gn(){null!==this.Vn&&(this.Vn.skipDelay(),this.Vn=null)}cancel(){null!==this.Vn&&(this.Vn.cancel(),this.Vn=null)}pn(){return(Math.random()-.5)*this.An}}let E7="PersistentStream";class I7{constructor(e,t,r,n,i,s,a,o){this.Tn=e,this.yn=r,this.wn=n,this.connection=i,this.authCredentialsProvider=s,this.appCheckCredentialsProvider=a,this.listener=o,this.state=0,this.bn=0,this.vn=null,this.Sn=null,this.stream=null,this.Dn=0,this.xn=new T7(e,t)}Cn(){return 1===this.state||5===this.state||this.Fn()}Fn(){return 2===this.state||3===this.state}start(){this.Dn=0,4!==this.state?this.auth():this.On()}async stop(){this.Cn()&&await this.close(0)}Mn(){this.state=0,this.xn.reset()}Nn(){this.Fn()&&null===this.vn&&(this.vn=this.Tn.enqueueAfterDelay(this.yn,6e4,()=>this.Ln()))}Bn(e){this.Un(),this.stream.send(e)}async Ln(){if(this.Fn())return this.close(0)}Un(){this.vn&&(this.vn.cancel(),this.vn=null)}kn(){this.Sn&&(this.Sn.cancel(),this.Sn=null)}async close(e,t){this.Un(),this.kn(),this.xn.cancel(),this.bn++,4!==e?this.xn.reset():t&&t.code===N.RESOURCE_EXHAUSTED?(Zm(t.toString()),Zm("Using maximum backoff delay to prevent overloading the backend."),this.xn.fn()):t&&t.code===N.UNAUTHENTICATED&&3!==this.state&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),null!==this.stream&&(this.qn(),this.stream.close(),this.stream=null),this.state=e,await this.listener.Ht(t)}qn(){}auth(){this.state=1;let e=this.$n(this.bn),r=this.bn;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then(([e,t])=>{this.bn===r&&this.Kn(e,t)},t=>{e(()=>{var e=new R(N.UNKNOWN,"Fetching auth token failed: "+t.message);return this.Wn(e)})})}Kn(e,t){let r=this.$n(this.bn);this.stream=this.Qn(e,t),this.stream.Qt(()=>{r(()=>this.listener.Qt())}),this.stream.zt(()=>{r(()=>(this.state=2,this.Sn=this.Tn.enqueueAfterDelay(this.wn,1e4,()=>(this.Fn()&&(this.state=3),Promise.resolve())),this.listener.zt()))}),this.stream.Ht(e=>{r(()=>this.Wn(e))}),this.stream.onMessage(e=>{r(()=>1==++this.Dn?this.Gn(e):this.onNext(e))})}On(){this.state=5,this.xn.mn(async()=>{this.state=0,this.start()})}Wn(e){return S(E7,"close with error: "+e),this.stream=null,this.close(4,e)}$n(t){return e=>{this.Tn.enqueueAndForget(()=>this.bn===t?e():(S(E7,"stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve()))}}}class C7 extends I7{constructor(e,t,r,n,i,s){super(e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",t,r,n,s),this.serializer=i}Qn(e,t){return this.connection.cn("Listen",e,t)}Gn(e){return this.onNext(e)}onNext(e){this.xn.reset();var t=((e,t)=>{let r;if("targetChange"in t){t.targetChange;var n="NO_CHANGE"===(l=t.targetChange.targetChangeType||"NO_CHANGE")?0:"ADD"===l?1:"REMOVE"===l?2:"CURRENT"===l?3:"RESET"===l?4:k(39313,{state:l}),i=t.targetChange.targetIds||[],s=(l=t.targetChange.resumeToken,e.useProto3Json?(A(void 0===l||"string"==typeof l,58123),L6.fromBase64String(l||"")):(A(void 0===l||l instanceof Buffer||l instanceof Uint8Array,16193),L6.fromUint8Array(l||new Uint8Array))),a=t.targetChange.cause,a=a&&(a=void 0===(l=a).code?N.UNKNOWN:Q_(l.code),new R(a,l.message||""));r=new my(n,i,s,a||null)}else if("documentChange"in t){t.documentChange;var n=t.documentChange,i=(n.document,n.document.name,n.document.updateTime,My(e,n.document.name)),s=Py(n.document.updateTime),a=n.document.createTime?Py(n.document.createTime):O.min(),o=new Sv({mapValue:{fields:n.document.fields}}),i=C_.newFoundDocument(i,s,a,o),s=n.targetIds||[],o=n.removedTargetIds||[];r=new fy(s,o,i.key,i)}else if("documentDelete"in t){t.documentDelete;n=t.documentDelete,s=(n.document,My(e,n.document)),o=n.readTime?Py(n.readTime):O.min(),i=C_.newNoDocument(s,o),s=n.removedTargetIds||[];r=new fy([],s,i.key,i)}else if("documentRemove"in t){t.documentRemove;o=t.documentRemove,n=(o.document,My(e,o.document)),s=o.removedTargetIds||[];r=new fy([],s,n,null)}else{if(!("filter"in t))return k(11601,{ft:t});{t.filter;let e=t.filter;e.targetId;var{count:i=0,unchangedNames:o}=e,s=new $_(i,o),n=e.targetId;r=new gy(n,s)}}var l;return r})(this.serializer,e),r="targetChange"in(e=e)&&(!(r=e.targetChange).targetIds||!r.targetIds.length)&&r.readTime?Py(r.readTime):O.min();return this.listener.zn(t,r)}jn(e){var t={},r=(t.database=Vy(this.serializer),t.addTarget=((t,r)=>{var n;let e=r.target;if((n=R_(e)?{pipelineQuery:Qy(t,e)}:P_(e)?{documents:Gy(t,e)}:{query:Wy(t,e).yt}).targetId=r.targetId,0<r.resumeToken.approximateByteSize()){n.resumeToken=Ny(t,r.resumeToken);let e=Sy(t,r.expectedCount);null!==e&&(n.expectedCount=e)}else if(0<r.snapshotVersion.compareTo(O.min())){n.readTime=ky(t,r.snapshotVersion.toTimestamp());let e=Sy(t,r.expectedCount);null!==e&&(n.expectedCount=e)}return n})(this.serializer,e),Yy(this.serializer,e));r&&(t.labels=r),this.Bn(t)}Hn(e){var t={};t.database=Vy(this.serializer),t.removeTarget=e,this.Bn(t)}}class S7 extends I7{constructor(e,t,r,n,i,s){super(e,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",t,r,n,s),this.serializer=i}get Jn(){return 0<this.Dn}start(){this.lastStreamToken=void 0,super.start()}qn(){this.Jn&&this.Yn([])}Qn(e,t){return this.connection.cn("Write",e,t)}Gn(e){return A(!!e.streamToken,31322),this.lastStreamToken=e.streamToken,A(!e.writeResults||0===e.writeResults.length,55816),this.listener.Zn()}onNext(e){A(!!e.streamToken,12678),this.lastStreamToken=e.streamToken,this.xn.reset();var t=Ky(e.writeResults,e.commitTime),r=Py(e.commitTime);return this.listener.Xn(r,t)}er(){var e={};e.database=Vy(this.serializer),this.Bn(e)}Yn(e){var t={streamToken:this.lastStreamToken,writes:e.map(e=>zy(this.serializer,e))};this.Bn(t)}}class k7 extends class{}{constructor(e,t,r,n){super(),this.authCredentials=e,this.appCheckCredentials=t,this.connection=r,this.serializer=n,this.tr=!1}nr(){if(this.tr)throw new R(N.FAILED_PRECONDITION,"The client has already been terminated.")}Bt(r,n,i,s){return this.nr(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([e,t])=>this.connection.Bt(r,Dy(n,i),s,e,t)).catch(e=>{throw"FirebaseError"===e.name?(e.code===N.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new R(N.UNKNOWN,e.toString())})}$t(r,n,i,s,a){return this.nr(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([e,t])=>this.connection.$t(r,Dy(n,i),s,e,t,a)).catch(e=>{throw"FirebaseError"===e.name?(e.code===N.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new R(N.UNKNOWN,e.toString())})}terminate(){this.tr=!0,this.connection.terminate()}}let A7=new Map;let N7={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0};class R7{static withCacheSize(e){return new R7(e,R7.DEFAULT_COLLECTION_PERCENTILE,R7.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}constructor(e,t,r){this.cacheSizeCollectionThreshold=e,this.percentileToCollect=t,this.maximumSequenceNumbersToCollect=r}}R7.DEFAULT_COLLECTION_PERCENTILE=10,R7.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,R7.DEFAULT=new R7(41943040,R7.DEFAULT_COLLECTION_PERCENTILE,R7.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),R7.DISABLED=new R7(-1,0,0);let P7="LruGarbageCollector";function x7([e,t],[r,n]){var i=P(e,r);return 0===i?P(t,n):i}class D7{constructor(e){this.rr=e,this.buffer=new k6(x7),this.ir=0}sr(){return++this.ir}_r(e){var t=[e,this.sr()];if(this.buffer.size<this.rr)this.buffer=this.buffer.add(t);else{let e=this.buffer.last();x7(t,e)<0&&(this.buffer=this.buffer.delete(e).add(t))}}get maxValue(){return this.buffer.last()[0]}}class O7{constructor(e,t,r){this.garbageCollector=e,this.asyncQueue=t,this.localStore=r,this.ar=null}start(){-1!==this.garbageCollector.params.cacheSizeCollectionThreshold&&this.ur(6e4)}stop(){this.ar&&(this.ar.cancel(),this.ar=null)}get started(){return null!==this.ar}ur(e){S(P7,`Garbage collection scheduled in ${e}ms`),this.ar=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",e,async()=>{this.ar=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(e){e0(e)?S(P7,"Ignoring IndexedDB error during garbage collection: ",e):await W2(e)}await this.ur(3e5)})}}class L7{constructor(e,t){this.cr=e,this.params=t}calculateTargetCount(e,t){return this.cr.lr(e).next(e=>Math.floor(t/100*e))}nthSequenceNumber(e,t){if(0===t)return L.resolve(l0.ce);let r=new D7(t);return this.cr.forEachTarget(e,e=>r._r(e.sequenceNumber)).next(()=>this.cr.Er(e,e=>r._r(e))).next(()=>r.maxValue)}removeTargets(e,t,r){return this.cr.removeTargets(e,t,r)}removeOrphanedDocuments(e,t){return this.cr.removeOrphanedDocuments(e,t)}collect(t,r){return-1===this.params.cacheSizeCollectionThreshold?(S("LruGarbageCollector","Garbage collection skipped; disabled"),L.resolve(N7)):this.getCacheSize(t).next(e=>e<this.params.cacheSizeCollectionThreshold?(S("LruGarbageCollector",`Garbage collection skipped; Cache size ${e} is lower than threshold `+this.params.cacheSizeCollectionThreshold),N7):this.hr(t,r))}getCacheSize(e){return this.cr.getCacheSize(e)}hr(t,r){let n,i,s,a,o,l,u,h=Date.now();return this.calculateTargetCount(t,this.params.percentileToCollect).next(e=>(i=e>this.params.maximumSequenceNumbersToCollect?(S("LruGarbageCollector",`Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from `+e),this.params.maximumSequenceNumbersToCollect):e,a=Date.now(),this.nthSequenceNumber(t,i))).next(e=>(n=e,o=Date.now(),this.removeTargets(t,n,r))).next(e=>(s=e,l=Date.now(),this.removeOrphanedDocuments(t,n))).next(e=>(u=Date.now(),Xm()<=p.DEBUG&&S("LruGarbageCollector",`LRU Garbage Collection
	Counted targets in ${a-h}ms
	Determined least recently used ${i} in `+(o-a)+"ms\n"+`	Removed ${s} targets in `+(l-o)+"ms\n"+`	Removed ${e} documents in `+(u-l)+"ms\n"+`Total Duration: ${u-h}ms`),L.resolve({didRun:!0,sequenceNumbersCollected:i,targetsRemoved:s,documentsRemoved:e})))}}function M7(e,t){return new L7(e,t)}let F7="firestore.googleapis.com";class U7{constructor(e){if(void 0===e.host){if(void 0!==e.ssl)throw new R(N.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host=F7,this.ssl=!0}else this.host=e.host,this.ssl=e.ssl??!0;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=41943040;else{if(-1!==e.cacheSizeBytes&&e.cacheSizeBytes<1048576)throw new R(N.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}I2("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=h7(e.experimentalLongPollingOptions??{});var t=this.experimentalLongPollingOptions;if(void 0!==t.timeoutSeconds){if(isNaN(t.timeoutSeconds))throw new R(N.INVALID_ARGUMENT,`invalid long polling timeout: ${t.timeoutSeconds} (must not be NaN)`);if(t.timeoutSeconds<5)throw new R(N.INVALID_ARGUMENT,`invalid long polling timeout: ${t.timeoutSeconds} (minimum allowed value is 5)`);if(30<t.timeoutSeconds)throw new R(N.INVALID_ARGUMENT,`invalid long polling timeout: ${t.timeoutSeconds} (maximum allowed value is 30)`)}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&&(t=this.experimentalLongPollingOptions,r=e.experimentalLongPollingOptions,t.timeoutSeconds===r.timeoutSeconds)&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams;var t,r}}class V7{constructor(e,t,r,n){this._authCredentials=e,this._appCheckCredentials=t,this._databaseId=r,this._app=n,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new U7({}),this._settingsFrozen=!1,this._emulatorOptions={},this._terminateTask="notTerminated"}get app(){if(this._app)return this._app;throw new R(N.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available")}get _initialized(){return this._settingsFrozen}get _terminated(){return"notTerminated"!==this._terminateTask}_setSettings(e){if(this._settingsFrozen)throw new R(N.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 U7(e),this._emulatorOptions=e.emulatorOptions||{},void 0!==e.credentials&&(this._authCredentials=(e=>{if(!e)return new s2;switch(e.type){case"firstParty":return new u2(e.sessionIndex||"0",e.iamToken||null,e.authTokenFactory||null);case"provider":return e.client;default:throw new R(N.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 e=this,(t=A7.get(e))&&(S("ComponentProvider","Removing Datastore"),A7.delete(e),t.terminate()),Promise.resolve();var e,t}}class B7{constructor(e,t,r){this.converter=t,this._query=r,this.type="query",this.firestore=e}withConverter(e){return new B7(this.firestore,e,this._query)}}class q7{constructor(e,t,r){this.converter=t,this._key=r,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 j7(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new q7(this.firestore,e,this._key)}toJSON(){return{type:q7._jsonSchemaVersion,referencePath:this._key.toString()}}static fromJSON(e,t,r){if(x2(t,q7._jsonSchema))return new q7(e,r||null,new D(x.fromString(t.referencePath)))}}q7._jsonSchemaVersion="firestore/documentReference/1.0",q7._jsonSchema={type:P2("string",q7._jsonSchemaVersion),referencePath:P2("string")};class j7 extends B7{constructor(e,t,r){super(e,t,F_(r)),this._path=r,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){var e=this._path.popLast();return e.isEmpty()?null:new q7(this.firestore,null,new D(e))}withConverter(e){return new j7(this.firestore,e,this._path)}}function z7(e,t,...r){var n;if(e=w(e),E2("collection","path",t),e instanceof V7)return S2(n=x.fromString(t,...r)),new j7(e,null,n);if(e instanceof q7||e instanceof j7)return S2(n=e._path.child(x.fromString(t,...r))),new j7(e.firestore,null,n);throw new R(N.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore")}function H7(e,t,...r){var n;if(e=w(e),E2("doc","path",t=1===arguments.length?d2.newId():t),e instanceof V7)return C2(n=x.fromString(t,...r)),new q7(e,null,new D(n));if(e instanceof q7||e instanceof j7)return C2(n=e._path.child(x.fromString(t,...r))),new q7(e.firestore,e instanceof j7?e.converter:null,new D(n));throw new R(N.INVALID_ARGUMENT,"Expected first argument to doc() to be a CollectionReference, a DocumentReference or FirebaseFirestore")}function K7(e,t){return e=w(e),t=w(t),(e instanceof q7||e instanceof j7)&&(t instanceof q7||t instanceof j7)&&e.firestore===t.firestore&&e.path===t.path&&e.converter===t.converter}function G7(e,t){return e=w(e),t=w(t),e instanceof B7&&t instanceof B7&&e.firestore===t.firestore&&H_(e._query,t._query)&&e.converter===t.converter}class W7{constructor(e){this._values=(e||[]).map(e=>e)}toArray(){return this._values.map(e=>e)}isEqual(e){var t=this._values,r=e._values;if(t.length!==r.length)return!1;for(let n=0;n<t.length;++n)if(t[n]!==r[n])return!1;return!0}toJSON(){return{type:W7._jsonSchemaVersion,vectorValues:this._values}}static fromJSON(e){if(x2(e,W7._jsonSchema)){if(Array.isArray(e.vectorValues)&&e.vectorValues.every(e=>"number"==typeof e))return new W7(e.vectorValues);throw new R(N.INVALID_ARGUMENT,"Expected 'vectorValues' field to be a number array")}}}W7._jsonSchemaVersion="firestore/vectorValue/1.0",W7._jsonSchema={type:P2("string",W7._jsonSchemaVersion),vectorValues:P2("object")};let $7=/^__.*__$/;class Y7{constructor(e,t,r){this.data=e,this.fieldMask=t,this.fieldTransforms=r}toMutation(e,t){return null!==this.fieldMask?new Zv(e,this.data,this.fieldMask,t,this.fieldTransforms):new Xv(e,this.data,t,this.fieldTransforms)}}class Q7{constructor(e,t,r){this.data=e,this.fieldMask=t,this.fieldTransforms=r}toMutation(e,t){return new Zv(e,this.data,this.fieldMask,t,this.fieldTransforms)}}function J7(e){switch(e){case 0:case 2:case 1:return 1;case 3:case 4:return;default:throw k(40011,{dataSource:e})}}class X7{constructor(e,t,r,n,i,s){this.settings=e,this.databaseId=t,this.serializer=r,this.ignoreUndefinedProperties=n,void 0===i&&this.validatePath(),this.fieldTransforms=i||[],this.fieldMask=s||[]}get path(){return this.settings.path}get dataSource(){return this.settings.dataSource}contextWith(e){return new X7({...this.settings,...e},this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}childContextForField(e){var t=this.path?.child(e),t=this.contextWith({path:t,arrayElement:!1});return t.validatePathSegment(e),t}childContextForFieldPath(e){var t=this.path?.child(e),t=this.contextWith({path:t,arrayElement:!1});return t.validatePath(),t}childContextForArray(e){return this.contextWith({path:void 0,arrayElement:!0})}createError(e){return _4(e,this.settings.methodName,this.settings.hasConverter||!1,this.path,this.settings.targetDoc)}contains(t){return void 0!==this.fieldMask.find(e=>t.isPrefixOf(e))||void 0!==this.fieldTransforms.find(e=>t.isPrefixOf(e.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(J7(this.dataSource)&&$7.test(e))throw this.createError('Document fields cannot begin and end with "__"')}}class Z7{constructor(e,t,r){this.databaseId=e,this.ignoreUndefinedProperties=t,this.serializer=r||s7(e)}createContext(e,t,r,n=!1){return new X7({dataSource:e,methodName:t,targetDoc:r,path:T2.emptyPath(),arrayElement:!1,hasConverter:n},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}}function e4(e){var t=e._freezeSettings(),r=s7(e._databaseId);return new Z7(e._databaseId,!!t.ignoreUndefinedProperties,r)}function t4(e,n,i,t,r,s={}){var a=e.createContext(s.merge||s.mergeFields?2:0,n,i,r),o=(f4("Data must be an object, but it was:",a,t),d4(t,a));let l,u;if(s.merge)l=new R6(a.fieldMask),u=a.fieldTransforms;else if(s.mergeFields){let t=[];for(let r of s.mergeFields){let e=g4(n,r,i);if(!a.contains(e))throw new R(N.INVALID_ARGUMENT,`Field '${e}' is specified in your field mask but missing from your input data.`);y4(t,e)||t.push(e)}l=new R6(t),u=a.fieldTransforms.filter(e=>l.covers(e.field))}else l=null,u=a.fieldTransforms;return new Y7(new Sv(o),l,u)}class r4 extends l7{_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 r4}}function n4(e,t,r){return new X7({dataSource:3,targetDoc:t.settings.targetDoc,methodName:e._methodName,arrayElement:r},t.databaseId,t.serializer,t.ignoreUndefinedProperties)}class i4 extends l7{_toFieldTransform(e){return new Hv(e.path,new xv)}isEqual(e){return e instanceof i4}}class s4 extends l7{constructor(e,t){super(e),this.Tr=t}_toFieldTransform(e){let t=n4(this,e,!0),r=this.Tr.map(e=>c4(e,t)),n=new Dv(r);return new Hv(e.path,n)}isEqual(e){return e instanceof s4&&Ie(this.Tr,e.Tr)}}class a4 extends l7{constructor(e,t){super(e),this.Tr=t}_toFieldTransform(e){let t=n4(this,e,!0),r=this.Tr.map(e=>c4(e,t)),n=new Lv(r);return new Hv(e.path,n)}isEqual(e){return e instanceof a4&&Ie(this.Tr,e.Tr)}}class o4 extends l7{constructor(e,t){super(e),this.Pr=t}_toFieldTransform(e){var t=new Uv(e.serializer,Nv(e.serializer,this.Pr));return new Hv(e.path,t)}isEqual(e){return e instanceof o4&&(this.Pr===e.Pr||Number.isNaN(this.Pr)&&Number.isNaN(e.Pr))}}function l4(e,i,s,t){let a=e.createContext(1,i,s),o=(f4("Data must be an object, but it was:",a,t),[]),l=Sv.empty();x6(t,(e,t)=>{var r=v4(i,e,s),n=(t=w(t),a.childContextForFieldPath(r));if(t instanceof r4)o.push(r);else{let e=c4(t,n);null!=e&&(o.push(r),l.set(r,e))}});var r=new R6(o);return new Q7(l,r,a.fieldTransforms)}function u4(e,t,r,n,i,s){var a=e.createContext(1,t,r),o=[g4(t,n,r)],l=[i];if(s.length%2!=0)throw new R(N.INVALID_ARGUMENT,`Function ${t}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let p=0;p<s.length;p+=2)o.push(g4(t,s[p])),l.push(s[p+1]);var u=[],h=Sv.empty();for(let f=o.length-1;0<=f;--f)if(!y4(u,o[f])){let t=o[f];var c=w(l[f]);let r=a.childContextForFieldPath(t);if(c instanceof r4)u.push(t);else{let e=c4(c,r);null!=e&&(u.push(t),h.set(t,e))}}var d=new R6(u);return new Q7(h,d,a.fieldTransforms)}function h4(e,t,r,n=!1){return c4(r,e.createContext(n?4:3,t))}function c4(e,r,t){if(p4(e=w(e)))return f4("Unsupported field value:",r,e),d4(e,r);if(e instanceof l7){{var n=e;var i=r;if(!J7(i.dataSource))throw i.createError(n._methodName+"() can only be used with update() and set()");if(!i.path)throw i.createError(n._methodName+"() is not currently supported inside arrays");var s=n._toFieldTransform(i);s&&i.fieldTransforms.push(s)}return null}if(void 0===e&&r.ignoreUndefinedProperties)return null;if(r.path&&r.fieldMask.push(r.path),e instanceof Array){if(r.settings.arrayElement&&4!==r.dataSource)throw r.createError("Nested arrays are not supported");{var a,o=r,l=[];let t=0;for(a of e){let e=c4(a,o.childContextForArray(t));null==e&&(e={nullValue:"NULL_VALUE"}),l.push(e),t++}return{arrayValue:{values:l}}}}var u,n=e,i=r,h=t;if(null===(n=w(n)))return{nullValue:"NULL_VALUE"};if("number"==typeof n)return Nv(i.serializer,n,h);if("boolean"==typeof n)return{booleanValue:n};if("string"==typeof n)return{stringValue:n};if(n instanceof Date){let e=O2.fromDate(n);return{timestampValue:ky(i.serializer,e)}}if(n instanceof O2){let e=new O2(n.seconds,1e3*Math.floor(n.nanoseconds/1e3));return{timestampValue:ky(i.serializer,e)}}if(n instanceof u7)return{geoPointValue:{latitude:n.latitude,longitude:n.longitude}};if(n instanceof a7)return{bytesValue:Ny(i.serializer,n._byteString)};if(n instanceof q7){let e=i.databaseId,t=n.firestore._databaseId;if(t.isEqual(e))return{referenceValue:xy(n.firestore._databaseId||i.databaseId,n._key.path)};throw i.createError(`Document reference is for database ${t.projectId}/${t.database} but should be for database ${e.projectId}/`+e.database)}if(n instanceof W7)return u=i,s=(h=n)instanceof W7?h.toArray():h,{mapValue:{fields:{[Q6]:{stringValue:Z6},[ev]:{arrayValue:{values:s.map(e=>{if("number"!=typeof e)throw u.createError("VectorValues must only contain numeric values.");return kv(u.serializer,e)})}}}}};if(r7(n))return n._toProto(i.serializer);throw i.createError("Unsupported field value: "+A2(n))}function d4(e,n){let i={};return D6(e)?n.path&&0<n.path.length&&n.fieldMask.push(n.path):x6(e,(e,t)=>{var r=c4(t,n.childContextForField(e));null!=r&&(i[e]=r)}),{mapValue:{fields:i}}}function p4(e){return!("object"!=typeof e||null===e||e instanceof Array||e instanceof Date||e instanceof O2||e instanceof u7||e instanceof a7||e instanceof q7||e instanceof l7||e instanceof W7||r7(e))}function f4(e,t,r){var n;if(!p4(r)||!k2(r))throw"an object"===(n=A2(r))?t.createError(e+" a custom object"):t.createError(e+" "+n)}function g4(e,t,r){if((t=w(t))instanceof o7)return t._internalPath;if("string"==typeof t)return v4(e,t);throw _4("Field path arguments must be of type string or ",e,!1,void 0,r)}let m4=new RegExp("[~\\*/\\[\\]]");function v4(t,r,n){if(0<=r.search(m4))throw _4(`Invalid field path (${r}). Paths must not contain '~', '*', '/', '[', or ']'`,t,!1,void 0,n);try{return new o7(...r.split("."))._internalPath}catch(e){throw _4(`Invalid field path (${r}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,t,!1,void 0,n)}}function _4(e,t,r,n,i){var s=n&&!n.isEmpty(),a=void 0!==i;let o=`Function ${t}() called with invalid data`,l=(r&&(o+=" (via `toFirestore()`)"),o+=". ","");return(s||a)&&(l+=" (found",s&&(l+=" in field "+n),a&&(l+=" in document "+i),l+=")"),new R(N.INVALID_ARGUMENT,o+e+l)}function y4(e,t){return e.some(e=>e.isEqual(t))}function w4(e){return"function"==typeof e._readUserData}class b4{constructor(e){this.optionDefinitions=e}_getKnownOptions(t,r){var n,i=Sv.empty();for(n in this.optionDefinitions)if(this.optionDefinitions.hasOwnProperty(n)){var s=this.optionDefinitions[n];if(n in t){var a=t[n];let e;s.nestedOptions&&k2(a)?e={mapValue:{fields:new b4(s.nestedOptions).getOptionsProto(r,a)}}:a&&(e=c4(a,r)??void 0),e&&i.set(T2.fromServerFormat(s.serverName),e)}}return i}getOptionsProto(r,e,t){var n=this._getKnownOptions(e,r);if(t){let e=new Map(((e,t)=>{var r,n=[];for(r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.push(t(e[r],r,e));return n})(t,(e,t)=>[T2.fromServerFormat(t),void 0!==e?c4(e,r):null]));n.setAll(e)}return n.value.mapValue.fields??{}}}function i(e){return e instanceof I4?e:k2(e)?(e=>{var t,r=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t=e[n],r.push(x4(n)),r.push(i(t)));return new s("map",r,"map")})(e):e instanceof Array?((e,t)=>new s("array",e.map(e=>i(e)),t))(e,"array"):D4(e,void 0)}function T4(e){if(e instanceof I4)return e;if(e instanceof W7)return x4(e);if(Array.isArray(e))return x4((t=e,new W7(t)));var t;throw new Error("Unsupported value: "+typeof e)}function E4(e){return("string"==typeof e?R4:i)(e)}class I4{constructor(){this._protoValueType="ProtoValue"}add(e){return new s("add",[this,i(e)],"add")}asBoolean(){if(this instanceof O4)return this;if(this instanceof P4)return new M4(this);if(this instanceof N4)return new F4(this);if(this instanceof s)return new L4(this);throw new R("invalid-argument",`Conversion of type ${typeof this} to BooleanExpression not supported.`)}subtract(e){return new s("subtract",[this,i(e)],"subtract")}multiply(e){return new s("multiply",[this,i(e)],"multiply")}divide(e){return new s("divide",[this,i(e)],"divide")}mod(e){return new s("mod",[this,i(e)],"mod")}equal(e){return new s("equal",[this,i(e)],"equal").asBoolean()}notEqual(e){return new s("not_equal",[this,i(e)],"notEqual").asBoolean()}lessThan(e){return new s("less_than",[this,i(e)],"lessThan").asBoolean()}lessThanOrEqual(e){return new s("less_than_or_equal",[this,i(e)],"lessThanOrEqual").asBoolean()}greaterThan(e){return new s("greater_than",[this,i(e)],"greaterThan").asBoolean()}greaterThanOrEqual(e){return new s("greater_than_or_equal",[this,i(e)],"greaterThanOrEqual").asBoolean()}arrayConcat(e,...t){var r=[e,...t].map(e=>i(e));return new s("array_concat",[this,...r],"arrayConcat")}arrayContains(e){return new s("array_contains",[this,i(e)],"arrayContains").asBoolean()}arrayContainsAll(e){var t=Array.isArray(e)?new A4(e.map(i),"arrayContainsAll"):e;return new s("array_contains_all",[this,t],"arrayContainsAll").asBoolean()}arrayContainsAny(e){var t=Array.isArray(e)?new A4(e.map(i),"arrayContainsAny"):e;return new s("array_contains_any",[this,t],"arrayContainsAny").asBoolean()}arrayReverse(){return new s("array_reverse",[this])}arrayLength(){return new s("array_length",[this],"arrayLength")}equalAny(e){var t=Array.isArray(e)?new A4(e.map(i),"equalAny"):e;return new s("equal_any",[this,t],"equalAny").asBoolean()}notEqualAny(e){var t=Array.isArray(e)?new A4(e.map(i),"notEqualAny"):e;return new s("not_equal_any",[this,t],"notEqualAny").asBoolean()}exists(){return new s("exists",[this],"exists").asBoolean()}charLength(){return new s("char_length",[this],"charLength")}like(e){return new s("like",[this,i(e)],"like").asBoolean()}regexContains(e){return new s("regex_contains",[this,i(e)],"regexContains").asBoolean()}regexFind(e){return new s("regex_find",[this,i(e)],"regexFind")}regexFindAll(e){return new s("regex_find_all",[this,i(e)],"regexFindAll")}regexMatch(e){return new s("regex_match",[this,i(e)],"regexMatch").asBoolean()}stringContains(e){return new s("string_contains",[this,i(e)],"stringContains").asBoolean()}startsWith(e){return new s("starts_with",[this,i(e)],"startsWith").asBoolean()}endsWith(e){return new s("ends_with",[this,i(e)],"endsWith").asBoolean()}toLower(){return new s("to_lower",[this],"toLower")}toUpper(){return new s("to_upper",[this],"toUpper")}trim(e){var t=[this];return e&&t.push(i(e)),new s("trim",t,"trim")}ltrim(e){var t=[this];return e&&t.push(i(e)),new s("ltrim",t,"ltrim")}rtrim(e){var t=[this];return e&&t.push(i(e)),new s("rtrim",t,"rtrim")}type(){return new s("type",[this])}isType(e){return new s("is_type",[this,x4(e)],"isType").asBoolean()}stringConcat(e,...t){var r=[e,...t].map(i);return new s("string_concat",[this,...r],"stringConcat")}stringIndexOf(e){return new s("string_index_of",[this,i(e)],"stringIndexOf")}stringRepeat(e){return new s("string_repeat",[this,i(e)],"stringRepeat")}stringReplaceAll(e,t){return new s("string_replace_all",[this,i(e),i(t)],"stringReplaceAll")}stringReplaceOne(e,t){return new s("string_replace_one",[this,i(e),i(t)],"stringReplaceOne")}concat(e,...t){var r=[e,...t].map(i);return new s("concat",[this,...r],"concat")}reverse(){return new s("reverse",[this],"reverse")}arrayFilter(e,t){return new s("array_filter",[this,i(e),t],"arrayFilter")}arrayTransform(e,t){return new s("array_transform",[this,i(e),t],"arrayTransform")}arrayTransformWithIndex(e,t,r){return new s("array_transform",[this,i(e),i(t),r],"arrayTransformWithIndex")}arraySlice(e,t){var r=[this,i(e)];return void 0!==t&&r.push(i(t)),new s("array_slice",r,"arraySlice")}arrayFirst(){return new s("array_first",[this],"arrayFirst")}arrayFirstN(e){return new s("array_first_n",[this,i(e)],"arrayFirstN")}arrayLast(){return new s("array_last",[this],"arrayLast")}arrayLastN(e){return new s("array_last_n",[this,i(e)],"arrayLastN")}arrayMaximum(){return new s("maximum",[this],"arrayMaximum")}arrayMaximumN(e){return new s("maximum_n",[this,i(e)],"arrayMaximumN")}arrayMinimum(){return new s("minimum",[this],"arrayMinimum")}arrayMinimumN(e){return new s("minimum_n",[this,i(e)],"arrayMinimumN")}arrayIndexOf(e){return new s("array_index_of",[this,i(e),i("first")],"arrayIndexOf")}arrayLastIndexOf(e){return new s("array_index_of",[this,i(e),i("last")],"arrayLastIndexOf")}arrayIndexOfAll(e){return new s("array_index_of_all",[this,i(e)],"arrayIndexOfAll")}byteLength(){return new s("byte_length",[this],"byteLength")}ceil(){return new s("ceil",[this])}floor(){return new s("floor",[this])}abs(){return new s("abs",[this])}exp(){return new s("exp",[this])}mapGet(e){return new s("map_get",[this,x4(e)],"mapGet")}mapSet(e,t,...r){var n=[this,i(e),i(t),...r.map(i)];return new s("map_set",n,"mapSet")}mapKeys(){return new s("map_keys",[this],"mapKeys")}mapValues(){return new s("map_values",[this],"mapValues")}mapEntries(){return new s("map_entries",[this],"mapEntries")}getField(e){return new s("get_field",[this,i(e)],"get_field")}count(){return C4._create("count",[this],"count")}sum(){return C4._create("sum",[this],"sum")}average(){return C4._create("average",[this],"average")}minimum(){return C4._create("minimum",[this],"minimum")}maximum(){return C4._create("maximum",[this],"maximum")}first(){return C4._create("first",[this],"first")}last(){return C4._create("last",[this],"last")}arrayAgg(){return C4._create("array_agg",[this],"arrayAgg")}arrayAggDistinct(){return C4._create("array_agg_distinct",[this],"arrayAggDistinct")}countDistinct(){return C4._create("count_distinct",[this],"countDistinct")}logicalMaximum(e,...t){var r=[e,...t];return new s("maximum",[this,...r.map(i)],"logicalMaximum")}logicalMinimum(e,...t){var r=[e,...t];return new s("minimum",[this,...r.map(i)],"minimum")}vectorLength(){return new s("vector_length",[this],"vectorLength")}cosineDistance(e){return new s("cosine_distance",[this,T4(e)],"cosineDistance")}dotProduct(e){return new s("dot_product",[this,T4(e)],"dotProduct")}euclideanDistance(e){return new s("euclidean_distance",[this,T4(e)],"euclideanDistance")}unixMicrosToTimestamp(){return new s("unix_micros_to_timestamp",[this],"unixMicrosToTimestamp")}timestampToUnixMicros(){return new s("timestamp_to_unix_micros",[this],"timestampToUnixMicros")}unixMillisToTimestamp(){return new s("unix_millis_to_timestamp",[this],"unixMillisToTimestamp")}timestampToUnixMillis(){return new s("timestamp_to_unix_millis",[this],"timestampToUnixMillis")}unixSecondsToTimestamp(){return new s("unix_seconds_to_timestamp",[this],"unixSecondsToTimestamp")}timestampToUnixSeconds(){return new s("timestamp_to_unix_seconds",[this],"timestampToUnixSeconds")}timestampAdd(e,t){return new s("timestamp_add",[this,i(e),i(t)],"timestampAdd")}timestampSubtract(e,t){return new s("timestamp_subtract",[this,i(e),i(t)],"timestampSubtract")}timestampDiff(e,t){return new s("timestamp_diff",[this,E4(e),i(t)],"timestampDiff")}timestampExtract(e,t){var r=[this,i(e)];return t&&r.push(i(t)),new s("timestamp_extract",r,"timestampExtract")}documentId(){return new s("document_id",[this],"documentId")}parent(){return new s("parent",[this],"parent")}substring(e,t){var r=i(e);return new s("substring",void 0===t?[this,r]:[this,r,i(t)],"substring")}arrayGet(e){return new s("array_get",[this,i(e)],"arrayGet")}isError(){return new s("is_error",[this],"isError").asBoolean()}ifError(e){var t=new s("if_error",[this,i(e)],"ifError");return e instanceof O4?t.asBoolean():t}isAbsent(){return new s("is_absent",[this],"isAbsent").asBoolean()}mapRemove(e){return new s("map_remove",[this,i(e)],"mapRemove")}mapMerge(e,...t){var r=i(e),n=t.map(i);return new s("map_merge",[this,r,...n],"mapMerge")}pow(e){return new s("pow",[this,i(e)])}trunc(e){return void 0===e?new s("trunc",[this]):new s("trunc",[this,i(e)],"trunc")}round(e){return void 0===e?new s("round",[this]):new s("round",[this,i(e)],"round")}collectionId(){return new s("collection_id",[this])}length(){return new s("length",[this])}ln(){return new s("ln",[this])}sqrt(){return new s("sqrt",[this])}stringReverse(){return new s("string_reverse",[this])}ifAbsent(e){return new s("if_absent",[this,i(e)],"ifAbsent")}ifNull(e){return new s("if_null",[this,i(e)],"ifNull")}coalesce(e,...t){return new s("coalesce",[this,i(e),...t.map(i)],"coalesce")}join(e){return new s("join",[this,i(e)],"join")}log10(){return new s("log10",[this])}arraySum(){return new s("sum",[this])}split(e){return new s("split",[this,i(e)])}timestampTruncate(e,t){var r=[this,i(e)];return t&&r.push(i(t)),new s("timestamp_trunc",r)}ascending(){return new U4(E4(this),"ascending","ascending")}descending(){return new U4(E4(this),"descending","descending")}as(e){return new k4(this,e,"as")}}class C4{constructor(e,t){this.name=e,this.params=t,this.exprType="AggregateFunction",this._protoValueType="ProtoValue"}static _create(e,t,r){var n=new C4(e,t);return n._methodName=r,n}as(e){return new S4(this,e,"as")}_toProto(t){return{functionValue:{name:this.name,args:this.params.map(e=>e._toProto(t))}}}_readUserData(t){t=this._methodName?t.contextWith({methodName:this._methodName}):t,this.params.forEach(e=>e._readUserData(t))}}class S4{constructor(e,t,r){this.aggregate=e,this.alias=t,this._methodName=r}_readUserData(e){this.aggregate._readUserData(e)}}class k4{constructor(e,t,r){this.expr=e,this.alias=t,this._methodName=r,this.exprType="AliasedExpression",this.selectable=!0}_readUserData(e){this.expr._readUserData(e)}}class A4 extends I4{constructor(e,t){super(),this.Rr=e,this._methodName=t,this.expressionType="ListOfExpressions"}_toProto(t){return{arrayValue:{values:this.Rr.map(e=>e._toProto(t))}}}_readUserData(t){this.Rr.forEach(e=>e._readUserData(t))}}class N4 extends I4{constructor(e,t){super(),this.fieldPath=e,this._methodName=t,this.expressionType="Field",this.selectable=!0}get _fieldPath(){return this.fieldPath}get fieldName(){return this.fieldPath.canonicalString()}get alias(){return this.fieldName}get expr(){return this}geoDistance(e){return new s("geo_distance",[this,i(e)],"geoDistance")}_toProto(e){return{fieldReferenceValue:this.fieldPath.canonicalString()}}_readUserData(e){}}function R4(e){return e=e,t="field",new N4("string"==typeof e?y2===e?new o7(y2)._internalPath:g4("field",e):e._internalPath,t);var t}class P4 extends I4{constructor(e,t){super(),this.value=e,this._methodName=t,this.expressionType="Constant"}static _fromProto(e){var t=new P4(e,void 0);return t._protoValue=e,t}_toProto(e){return A(void 0!==this._protoValue,237),this._protoValue}_getValue(){return this._protoValue}_readUserData(e){var t,r,n,i;e=this._methodName?e.contextWith({methodName:this._methodName}):e,"object"==typeof(t=this._protoValue)&&null!==t&&("nullValue"in t&&(null===t.nullValue||"NULL_VALUE"===t.nullValue)||"booleanValue"in t&&(null===t.booleanValue||"boolean"==typeof t.booleanValue)||"integerValue"in t&&(null===t.integerValue||"number"==typeof t.integerValue||"string"==typeof t.integerValue)||"doubleValue"in t&&(null===t.doubleValue||"number"==typeof t.doubleValue)||"timestampValue"in t&&(null===t.timestampValue||"object"==typeof(i=t.timestampValue)&&null!==i&&"seconds"in i&&(null===i.seconds||"number"==typeof i.seconds||"string"==typeof i.seconds)&&"nanos"in i&&(null===i.nanos||"number"==typeof i.nanos))||"stringValue"in t&&(null===t.stringValue||"string"==typeof t.stringValue)||"bytesValue"in t&&(null===t.bytesValue||t.bytesValue instanceof Uint8Array)||"referenceValue"in t&&(null===t.referenceValue||"string"==typeof t.referenceValue)||"geoPointValue"in t&&(null===t.geoPointValue||"object"==typeof(i=t.geoPointValue)&&null!==i&&"latitude"in i&&(null===i.latitude||"number"==typeof i.latitude)&&"longitude"in i&&(null===i.longitude||"number"==typeof i.longitude))||"arrayValue"in t&&(null===t.arrayValue||"object"==typeof(n=t.arrayValue)&&null!==n&&"values"in n&&(null===n.values||Array.isArray(n.values)))||"mapValue"in t&&(null===t.mapValue||"object"==typeof(n=t.mapValue)&&null!==n&&"fields"in n&&(null===n.fields||k2(n.fields)))||"fieldReferenceValue"in t&&(null===t.fieldReferenceValue||"string"==typeof t.fieldReferenceValue)||"functionValue"in t&&(null===t.functionValue||"object"==typeof(r=t.functionValue)&&null!==r&&"name"in r&&(null===r.name||"string"==typeof r.name)&&"args"in r&&(null===r.args||Array.isArray(r.args)))||"pipelineValue"in t&&(null===t.pipelineValue||"object"==typeof(r=t.pipelineValue)&&null!==r&&"stages"in r&&(null===r.stages||Array.isArray(r.stages))))||(this._protoValue=c4(this.value,e))}}function x4(e){return D4(e,"constant")}function D4(e,t){var r=new P4(e,t);return"boolean"==typeof e?new M4(r):r}class s extends I4{constructor(e,t,r,n){super(),this.name=e,this.params=t,this.expressionType="Function",(this._optionsProto=void 0)!==r&&(this._methodName=r),void 0!==n&&(this._options=n)}get _optionsUtil(){return new b4({})}_toProto(t){var e={functionValue:{name:this.name,args:this.params.map(e=>e._toProto(t))}};return this._optionsProto&&(e.functionValue.options=this._optionsProto),e}_readUserData(t){t=this._methodName?t.contextWith({methodName:this._methodName}):t,this.params.forEach(e=>e._readUserData(t)),this._options&&(this._optionsProto=this._optionsUtil.getOptionsProto(t,this._options))}}class O4 extends I4{get _methodName(){return this._expr._methodName}countIf(){return C4._create("count_if",[this],"countIf")}not(){return new s("not",[this],"not").asBoolean()}conditional(e,t){return new s("conditional",[this,e,t],"conditional")}ifError(e){var t=i(e),r=new s("if_error",[this,t],"ifError");return t instanceof O4?r.asBoolean():r}_toProto(e){return this._expr._toProto(e)}_readUserData(e){this._expr._readUserData(e)}}class L4 extends O4{constructor(e){super(),this._expr=e,this.expressionType="Function"}}class M4 extends O4{constructor(e){super(),this._expr=e,this.expressionType="Constant"}_getValue(){return this._expr._getValue()}}class F4 extends O4{constructor(e){super(),this._expr=e,this.expressionType="Field"}}class U4{constructor(e,t,r){this.expr=e,this.direction=t,this._methodName=r,this._protoValueType="ProtoValue"}_toProto(e){return{mapValue:{fields:{direction:i7(this.direction),expression:this.expr._toProto(e)}}}}_readUserData(e){this.expr._readUserData(e)}}class V4{constructor(e){this.optionsProto=void 0,{rawOptions:this.rawOptions,...this.knownOptions}=e}_readUserData(e){this.optionsProto=this._optionsUtil.getOptionsProto(e,this.knownOptions,this.rawOptions)}_toProto(e){return{name:this._name,options:this.optionsProto}}}class B4 extends V4{get _name(){return"add_fields"}get _optionsUtil(){return new b4({})}constructor(e,t){super(t),this.fields=e}_toProto(e){return{...super._toProto(e),args:[n7(e,this.fields)]}}_readUserData(e){super._readUserData(e),X4(this.fields,e)}}class q4 extends V4{get _name(){return"aggregate"}get _optionsUtil(){return new b4({})}constructor(e,t,r){super(r),this.groups=e,this.accumulators=t}_toProto(e){return{...super._toProto(e),args:[n7(e,this.accumulators),n7(e,this.groups)]}}_readUserData(e){super._readUserData(e),X4(this.groups,e),X4(this.accumulators,e)}}class j4 extends V4{get _name(){return"distinct"}get _optionsUtil(){return new b4({})}constructor(e,t){super(t),this.groups=e}_toProto(e){return{...super._toProto(e),args:[n7(e,this.groups)]}}_readUserData(e){super._readUserData(e),X4(this.groups,e)}}class z4 extends V4{get _name(){return"collection"}get _optionsUtil(){return new b4({forceIndex:{serverName:"force_index"}})}constructor(e,t){super(t),this.Vr=e.startsWith("/")?e:"/"+e}_toProto(e){return{...super._toProto(e),args:[{referenceValue:this.Vr}]}}_readUserData(e){super._readUserData(e)}}class H4 extends V4{get _name(){return"collection_group"}get _optionsUtil(){return new b4({forceIndex:{serverName:"force_index"}})}constructor(e,t){super(t),this.collectionId=e}_toProto(e){return{...super._toProto(e),args:[{referenceValue:""},{stringValue:this.collectionId}]}}_readUserData(e){super._readUserData(e)}}class K4 extends V4{get _name(){return"database"}get _optionsUtil(){return new b4({})}_toProto(e){return{...super._toProto(e)}}_readUserData(e){super._readUserData(e)}}class G4 extends V4{get _name(){return"documents"}get _optionsUtil(){return new b4({})}constructor(e,t){if(super(t),!e||0===e.length)throw new R(N.INVALID_ARGUMENT,"Empty document paths are not allowed in DocumentsSource");var r=e.map(e=>e.startsWith("/")?e:"/"+e),n=new Set(r);if(n.size!==r.length)throw new R(N.INVALID_ARGUMENT,"Duplicate document paths are not allowed in DocumentsSource");this.dr=r,this.mr=n}_toProto(e){return{...super._toProto(e),args:this.dr.map(e=>({referenceValue:e}))}}_readUserData(e){super._readUserData(e)}}class W4 extends V4{get _name(){return"where"}get _optionsUtil(){return new b4({})}constructor(e,t){super(t),this.condition=e}_toProto(e){return{...super._toProto(e),args:[this.condition._toProto(e)]}}_readUserData(e){super._readUserData(e),X4(this.condition,e)}}class $4 extends V4{get _name(){return"limit"}get _optionsUtil(){return new b4({})}constructor(e,t){A(!isNaN(e)&&e!==1/0&&e!==-1/0,34860),super(t),this.limit=e}_toProto(e){return{...super._toProto(e),args:[Nv(e,this.limit)]}}}class Y4 extends V4{get _name(){return"select"}get _optionsUtil(){return new b4({})}constructor(e,t){super(t),this.selections=e}_toProto(e){return{...super._toProto(e),args:[n7(e,this.selections)]}}_readUserData(e){super._readUserData(e),X4(this.selections,e)}}class Q4 extends V4{get _name(){return"sort"}get _optionsUtil(){return new b4({})}constructor(e,t){super(t),this.orderings=e}_toProto(t){return{...super._toProto(t),args:this.orderings.map(e=>e._toProto(t))}}_readUserData(e){super._readUserData(e),X4(this.orderings,e)}}class J4 extends V4{get _name(){return"replace_with"}get _optionsUtil(){return new b4({})}constructor(e,t){super(t),this.map=e}_toProto(e){return{...super._toProto(e),args:[this.map._toProto(e),i7(J4.pr)]}}_readUserData(e){super._readUserData(e),X4(this.map,e)}}function X4(e,t){w4(e)?e._readUserData(t):Array.isArray(e)?e.forEach(e=>e._readUserData(t)):e instanceof Map?e.forEach(e=>e._readUserData(t)):Object.values(e).forEach(e=>e._readUserData(t))}J4.pr="full_replace";class Z4{constructor(e,t,r){this.serializer=e,this.stages=t,this.listenOptions=r,this.isCorePipeline=!0}getPipelineCollection(){return t3(this)}getPipelineCollectionGroup(){return r3(this)}getPipelineCollectionId(){return n3(this)}getPipelineDocuments(){return i3(this)}getPipelineFlavor(){{var n=this;let r="exact";return n.stages.forEach((e,t)=>{e._name!==j4.name&&e._name!==q4.name||(r="keyless"),e._name===Y4.name&&"exact"===r&&(r="augmented"),e._name===B4.name&&t<n.stages.length-1&&"exact"===r&&(r="augmented")}),r}}getPipelineSourceType(){return e3(this)}}function e3(e){var t=e.stages[0];return t instanceof z4||t instanceof H4||t instanceof K4||t instanceof G4?t._name:"unknown"}function t3(e){if("collection"===e3(e))return e.stages[0].Vr}function r3(e){if("collection_group"===e3(e))return e.stages[0].collectionId}function n3(e){switch(e3(e)){case"collection":return x.fromString(t3(e)).lastSegment();case"collection_group":return r3(e);default:return}}function i3(e){if("documents"===e3(e))return e.stages[0].dr}class u{constructor(e,t){this.type=e,this.value=t}static vr(){return new u("ERROR",void 0)}static Sr(){return new u("UNSET",void 0)}static Dr(){return new u("NULL",tv)}static newValue(e){return mv(e)?new u("NULL",tv):(t=e)&&"booleanValue"in t?new u("BOOLEAN",e):dv(e)?new u("INT",e):pv(e)?new u("DOUBLE",e):(t=e)&&"timestampValue"in t&&t.timestampValue?new u("TIMESTAMP",e):(t=e)&&"stringValue"in t?new u("STRING",e):(t=e)&&"bytesValue"in t?new u("BYTES",e):e.referenceValue?new u("REFERENCE",e):e.geoPointValue?new u("GEO_POINT",e):gv(e)?new u("ARRAY",e):yv(e)?new u("VECTOR",e):_v(e)?new u("MAP",e):new u("ERROR",void 0);var t}Cr(){return"ERROR"===this.type||"UNSET"===this.type}Fr(){return"NULL"===this.type}}function s3(e){if(!e.Cr())return e.value}function a3(e){return e instanceof O4?e._expr:e}function U(e){if((e=a3(e))instanceof N4)return new o3(e);if(e instanceof P4)return new l3(e);if(e instanceof A4)return new u3(e);if(e instanceof s){if("add"===e.name)return new m3(e);if("subtract"===e.name)return new v3(e);if("multiply"===e.name)return new _3(e);if("divide"===e.name)return new y3(e);if("mod"===e.name)return new w3(e);if("and"===e.name)return new b3(e);if("equal"===e.name)return new F3(e);if("not_equal"===e.name)return new U3(e);if("less_than"===e.name)return new V3(e);if("less_than_or_equal"===e.name)return new B3(e);if("greater_than"===e.name)return new q3(e);if("greater_than_or_equal"===e.name)return new j3(e);if("array_concat"===e.name)return new z3(e);if("array_reverse"===e.name)return new H3(e);if("array_contains"===e.name)return new K3(e);if("array_contains_all"===e.name)return new G3(e);if("array_contains_any"===e.name)return new W3(e);if("array_length"===e.name)return new $3(e);if("array_element"===e.name)return new Y3(e);if("equal_any"===e.name)return new C3(e);if("not_equal_any"===e.name)return new S3(e);if("is_nan"===e.name)return new k3(e);if("is_not_nan"===e.name)return new A3(e);if("is_null"===e.name)return new N3(e);if("is_not_null"===e.name)return new R3(e);if("is_error"===e.name)return new P3(e);if("exists"===e.name)return new x3(e);if("not"===e.name)return new T3(e);if("or"===e.name)return new E3(e);if("xor"===e.name)return new I3(e);if("conditional"===e.name)return new D3(e);if("maximum"===e.name)return new O3(e);if("minimum"===e.name)return new L3(e);if("reverse"===e.name)return new Q3(e);if("replace_first"===e.name)return new J3(e);if("replace_all"===e.name)return new X3(e);if("char_length"===e.name)return new Z3(e);if("byte_length"===e.name)return new ew(e);if("like"===e.name)return new rw(e);if("regex_contains"===e.name)return new nw(e);if("regex_match"===e.name)return new iw(e);if("string_contains"===e.name)return new sw(e);if("starts_with"===e.name)return new aw(e);if("ends_with"===e.name)return new ow(e);if("to_lower"===e.name)return new lw(e);if("to_upper"===e.name)return new uw(e);if("trim"===e.name)return new hw(e);if("string_concat"===e.name)return new cw(e);if("map_get"===e.name)return new dw(e);if("cosine_distance"===e.name)return new fw(e);if("dot_product"===e.name)return new gw(e);if("euclidean_distance"===e.name)return new mw(e);if("vector_length"===e.name)return new vw(e);if("unix_micros_to_timestamp"===e.name)return new xw(e);if("timestamp_to_unix_micros"===e.name)return new Mw(e);if("unix_millis_to_timestamp"===e.name)return new Dw(e);if("timestamp_to_unix_millis"===e.name)return new Fw(e);if("unix_seconds_to_timestamp"===e.name)return new Ow(e);if("timestamp_to_unix_seconds"===e.name)return new Uw(e);if("timestamp_add"===e.name)return new Bw(e);if("timestamp_subtract"===e.name)return new qw(e)}throw new Error("Unknown Expr : "+e)}class o3{constructor(e){this.expr=e}evaluate(e,t){var r;return this.expr.fieldName===y2?u.newValue({referenceValue:Ly(e.serializer,t.key)}):"__update_time__"===this.expr.fieldName?u.newValue({timestampValue:Ry(e.serializer,t.version)}):"__create_time__"===this.expr.fieldName?u.newValue({timestampValue:Ry(e.serializer,t.createTime)}):(r=t.data.field(this.expr._fieldPath))?H6(r)?u.newValue(((e,t)=>{if("estimate"===e.serverTimestampBehavior)return{timestampValue:Ry(e.serializer,O.fromTimestamp(G6(t)))};if("previous"===e.serverTimestampBehavior){let e=K6(t);if(e)return e}return{nullValue:"NULL_VALUE"}})(e,r)):u.newValue(r):u.Sr()}}class l3{constructor(e){this.expr=e}evaluate(e,t){return u.newValue(this.expr._getValue())}}class u3{constructor(e){this.expr=e}evaluate(t,r){var e=this.expr.Rr.map(e=>U(e).evaluate(t,r));return e.some(e=>e.Cr())?u.vr():u.newValue({arrayValue:{values:e.map(e=>e.value)}})}}function h3(e){return pv(e)?Number(e.doubleValue):Number(e.integerValue)}function c3(e){return BigInt(e.integerValue)}let d3=BigInt("0x7fffffffffffffff"),p3=-BigInt("0x8000000000000000");class f3{constructor(e){this.expr=e}evaluate(t,r){A(2<=this.expr.params.length,24778);let n=U(this.expr.params[0]).evaluate(t,r),e=U(this.expr.params[1]).evaluate(t,r),i=this.Or(n,e);for(let n of this.expr.params.slice(2)){let e=U(n).evaluate(t,r);i=this.Or(i,e)}return i}Or(e,t){if(!e.Cr()&&!t.Cr()){if(e.Fr()||t.Fr())return u.Dr();var r=e.value,n=t.value;if((pv(r)||dv(r))&&(pv(n)||dv(n))){if(pv(r)||pv(n)){let e=this.Mr(r,n);return e?u.newValue(e):u.vr()}if(dv(r)&&dv(n)){let e=this.Nr(r,n);return void 0===e?u.vr():"number"==typeof e?u.newValue({doubleValue:e}):e<p3||e>d3?u.vr():u.newValue({integerValue:""+e})}}}return u.vr()}}function g3(r,n){{if(iv(r)!==iv(n))return"TYPE_MISMATCH";if(vv(r)||vv(n))return"NOT_EQ";if(mv(r)&&mv(n))return"EQ";if(mv(r)||mv(n))return"NULL";if(gv(r)&&gv(n)){var i=r.arrayValue,s=n.arrayValue;if(i.values?.length!==s.values?.length)return"NOT_EQ";let e=!1;for(let t=0;t<(i.values?.length??0);t++){var a=i.values[t],o=s.values[t];switch(g3(a,o)){case"EQ":break;case"NOT_EQ":case"TYPE_MISMATCH":return"NOT_EQ";case"NULL":e=!0;break;default:k(44609,{Lr:a,Br:o})}}return e?"NULL":"EQ"}if(yv(r)&&yv(n)||_v(r)&&_v(n)){var l=r.mapValue,u=n.mapValue,h=l.fields||{},c=u.fields||{};if(P6(h)!==P6(c))return"NOT_EQ";let e=!1;for(let t in h)if(h.hasOwnProperty(t)){if(void 0===c[t])return"NOT_EQ";switch(g3(h[t],c[t])){case"NOT_EQ":case"TYPE_MISMATCH":return"NOT_EQ";case"NULL":e=!0}}return e?"NULL":"EQ"}return sv(r,n,{Te:!1,Ee:!0,he:!0})?"EQ":"NOT_EQ"}}class m3 extends f3{Nr(e,t){return c3(e)+c3(t)}Mr(e,t){return{doubleValue:h3(e)+h3(t)}}}class v3 extends f3{constructor(e){super(e),this.expr=e}Nr(e,t){return c3(e)-c3(t)}Mr(e,t){return{doubleValue:h3(e)-h3(t)}}}class _3 extends f3{constructor(e){super(e),this.expr=e}Nr(e,t){return c3(e)*c3(t)}Mr(e,t){return{doubleValue:h3(e)*h3(t)}}}class y3 extends f3{constructor(e){super(e),this.expr=e}Nr(e,t){var r=c3(t);if(r!==BigInt(0))return c3(e)/r}Mr(e,t){var r=h3(t);return 0===r?{doubleValue:c0(r)?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY}:{doubleValue:h3(e)/r}}}class w3 extends f3{constructor(e){super(e),this.expr=e}Nr(e,t){var r=c3(t);if(r!==BigInt(0))return c3(e)%r}Mr(e,t){var r=h3(t);if(0!==r)return{doubleValue:h3(e)%r}}}class b3{constructor(e){this.expr=e}evaluate(e,t){let r=!1,n=!1;for(var i of this.expr.params){var s=U(i).evaluate(e,t);switch(s.type){case"BOOLEAN":if(s.value?.booleanValue)break;return u.newValue(nv);case"NULL":n=!0;break;default:r=!0}}return r?u.vr():n?u.Dr():u.newValue(rv)}}class T3{constructor(e){this.expr=e}evaluate(e,t){A(1===this.expr.params.length,9634);var r=U(this.expr.params[0]).evaluate(e,t);switch(r.type){case"BOOLEAN":return u.newValue({booleanValue:!r.value?.booleanValue});case"NULL":return u.Dr();default:return u.vr()}}}class E3{constructor(e){this.expr=e}evaluate(e,t){let r=!1,n=!1;for(var i of this.expr.params){var s=U(i).evaluate(e,t);switch(s.type){case"BOOLEAN":if(s.value?.booleanValue)return u.newValue(rv);break;case"NULL":n=!0;break;default:r=!0}}return r?u.vr():n?u.Dr():u.newValue(nv)}}class I3{constructor(e){this.expr=e}evaluate(e,t){let r=!1,n=!1;for(var i of this.expr.params){var s=U(i).evaluate(e,t);switch(s.type){case"BOOLEAN":r=I3.xor(r,!!s.value?.booleanValue);break;case"NULL":n=!0;break;default:return u.vr()}}return n?u.Dr():u.newValue({booleanValue:r})}static xor(e,t){return(e||t)&&!(e&&t)}}class C3{constructor(e){this.expr=e}evaluate(e,t){A(2===this.expr.params.length,55094);let r=!1;var n=U(this.expr.params[0]).evaluate(e,t);switch(n.type){case"NULL":r=!0;break;case"ERROR":case"UNSET":return u.vr()}var i=U(this.expr.params[1]).evaluate(e,t);switch(i.type){case"ARRAY":break;case"NULL":r=!0;break;default:return u.vr()}if(r)return u.Dr();for(let e of i.value?.arrayValue?.values??[])switch(mv(n.value)&&mv(e)?"EQ":g3(n.value,e)){case"EQ":return u.newValue(rv);case"NOT_EQ":case"TYPE_MISMATCH":break;case"NULL":r=!0;break;default:k(44608,{value:n.value,candidate:e})}return r?u.Dr():u.newValue(nv)}}class S3{constructor(e){this.expr=e}evaluate(e,t){return new T3(new s("not",[new s("equal_any",this.expr.params)])).evaluate(e,t)}}class k3{constructor(e){this.expr=e}evaluate(e,t){A(1===this.expr.params.length,23322);var r=U(this.expr.params[0]).evaluate(e,t);switch(r.type){case"INT":return u.newValue(nv);case"DOUBLE":return u.newValue({booleanValue:isNaN(h3(r.value))});case"NULL":return u.Dr();default:return u.vr()}}}class A3{constructor(e){this.expr=e}evaluate(e,t){return A(1===this.expr.params.length,50406),new T3(new s("not",[new s("is_nan",this.expr.params)])).evaluate(e,t)}}class N3{constructor(e){this.expr=e}evaluate(e,t){switch(A(1===this.expr.params.length,23123),U(this.expr.params[0]).evaluate(e,t).type){case"NULL":return u.newValue(rv);case"UNSET":case"ERROR":return u.vr();default:return u.newValue(nv)}}}class R3{constructor(e){this.expr=e}evaluate(e,t){return A(1===this.expr.params.length,23167),new T3(new s("not",[new s("is_null",this.expr.params)])).evaluate(e,t)}}class P3{constructor(e){this.expr=e}evaluate(e,t){return A(1===this.expr.params.length,5228),"ERROR"===U(this.expr.params[0]).evaluate(e,t).type?u.newValue(rv):u.newValue(nv)}}class x3{constructor(e){this.expr=e}evaluate(e,t){switch(A(1===this.expr.params.length,6877),U(this.expr.params[0]).evaluate(e,t).type){case"ERROR":return u.vr();case"UNSET":return u.newValue(nv);default:return u.newValue(rv)}}}class D3{constructor(e){this.expr=e}evaluate(e,t){A(3===this.expr.params.length,11706);var r=U(this.expr.params[0]).evaluate(e,t);switch(r.type){case"BOOLEAN":return(r.value?.booleanValue?U(this.expr.params[1]):U(this.expr.params[2])).evaluate(e,t);case"NULL":return U(this.expr.params[2]).evaluate(e,t);default:return u.vr()}}}class O3{constructor(e){this.expr=e}evaluate(t,r){var e=this.expr.params.map(e=>U(e).evaluate(t,r));let n;for(let t of e)switch(t.type){case"ERROR":case"UNSET":case"NULL":continue;default:n=void 0===n||0<ov(t.value,n.value)?t:n}return void 0===n?u.Dr():n}}class L3{constructor(e){this.expr=e}evaluate(t,r){var e=this.expr.params.map(e=>U(e).evaluate(t,r));let n;for(let t of e)switch(t.type){case"ERROR":case"UNSET":case"NULL":continue;default:n=void 0===n||ov(t.value,n.value)<0?t:n}return void 0===n?u.Dr():n}}class M3{constructor(e){this.expr=e}evaluate(e,t){A(2===this.expr.params.length,31033,this.expr.name+"() function should have exactly 2 params");var r=U(this.expr.params[0]).evaluate(e,t);switch(r.type){case"ERROR":case"UNSET":return u.vr()}var n=U(this.expr.params[1]).evaluate(e,t);switch(n.type){case"ERROR":case"UNSET":return u.vr()}return this.Ur(r,n)}}class F3 extends M3{constructor(e){super(e),this.expr=e}Ur(e,t){if(e.Fr()&&t.Fr())return u.newValue(rv);if(e.Fr()||t.Fr())return u.newValue(nv);if(vv(e.value)||vv(t.value))return u.newValue(nv);if(iv(e.value)!==iv(t.value))return u.newValue(nv);switch(g3(e.value,t.value)){case"EQ":return u.newValue(rv);case"NOT_EQ":return u.newValue(nv);case"NULL":return u.Dr();default:k(44615,{left:e,right:t})}}}class U3 extends M3{constructor(e){super(e),this.expr=e}Ur(e,t){switch(g3(e.value,t.value)){case"EQ":return u.newValue(nv);case"NOT_EQ":case"TYPE_MISMATCH":return u.newValue(rv);case"NULL":return u.Dr();default:k(44614,{left:e,right:t})}}}class V3 extends M3{constructor(e){super(e),this.expr=e}Ur(e,t){return iv(e.value)!==iv(t.value)||vv(e.value)||vv(t.value)?u.newValue(nv):u.newValue({booleanValue:ov(e.value,t.value)<0})}}class B3 extends M3{constructor(e){super(e),this.expr=e}Ur(e,t){return iv(e.value)!==iv(t.value)||vv(e.value)||vv(t.value)?u.newValue(nv):"EQ"===g3(e.value,t.value)?u.newValue(rv):u.newValue({booleanValue:ov(e.value,t.value)<0})}}class q3 extends M3{constructor(e){super(e),this.expr=e}Ur(e,t){return iv(e.value)!==iv(t.value)||vv(e.value)||vv(t.value)?u.newValue(nv):u.newValue({booleanValue:0<ov(e.value,t.value)})}}class j3 extends M3{constructor(e){super(e),this.expr=e}Ur(e,t){return iv(e.value)!==iv(t.value)||vv(e.value)||vv(t.value)?u.newValue(nv):"EQ"===g3(e.value,t.value)?u.newValue(rv):u.newValue({booleanValue:0<ov(e.value,t.value)})}}class z3{constructor(e){this.expr=e}evaluate(e,t){throw new Error("Unimplemented")}}class H3{constructor(e){this.expr=e}evaluate(e,t){A(1===this.expr.params.length,216);var r=U(this.expr.params[0]).evaluate(e,t);switch(r.type){case"NULL":return u.Dr();case"ARRAY":{let e=r.value.arrayValue?.values??[];return u.newValue({arrayValue:{values:[...e].reverse()}})}default:return u.vr()}}}class K3{constructor(e){this.expr=e}evaluate(e,t){return A(2===this.expr.params.length,52884),new C3(new s("eq_any",[this.expr.params[1],this.expr.params[0]])).evaluate(e,t)}}class G3{constructor(e){this.expr=e}evaluate(r,e){A(2===this.expr.params.length,1392);let n=!1,t=U(this.expr.params[0]).evaluate(r,e);switch(t.type){case"ARRAY":break;case"NULL":n=!0;break;default:return u.vr()}var i=U(this.expr.params[1]).evaluate(r,e);switch(i.type){case"ARRAY":break;case"NULL":n=!0;break;default:return u.vr()}if(n)return u.Dr();var i=i.value?.arrayValue?.values??[],s=t.value?.arrayValue?.values??[];for(let r of i){let e=!1;n=!1;for(let t of s){switch(mv(r)&&mv(t)?"EQ":g3(r,t)){case"EQ":e=!0;break;case"NOT_EQ":case"TYPE_MISMATCH":break;case"NULL":n=!0;break;default:k(44613,{value:t,search:r})}if(e)break}if(!e)return u.newValue(nv)}return u.newValue(rv)}}class W3{constructor(e){this.expr=e}evaluate(t,e){A(2===this.expr.params.length,2680);let r=!1;var n=U(this.expr.params[0]).evaluate(t,e);switch(n.type){case"ARRAY":break;case"NULL":r=!0;break;default:return u.vr()}var i=U(this.expr.params[1]).evaluate(t,e);switch(i.type){case"ARRAY":break;case"NULL":r=!0;break;default:return u.vr()}if(r)return u.Dr();var s=i.value?.arrayValue?.values??[];for(let t of n.value?.arrayValue?.values??[])for(let e of s)switch(mv(t)&&mv(e)?"EQ":g3(t,e)){case"EQ":return u.newValue(rv);case"NOT_EQ":case"TYPE_MISMATCH":break;case"NULL":r=!0;break;default:k(44608,{value:t,search:e})}return r?u.Dr():u.newValue(nv)}}class $3{constructor(e){this.expr=e}evaluate(e,t){A(1===this.expr.params.length,38605);var r=U(this.expr.params[0]).evaluate(e,t);switch(r.type){case"NULL":return u.Dr();case"ARRAY":return u.newValue({integerValue:""+(r.value?.arrayValue?.values?.length??0)});default:return u.vr()}}}class Y3{constructor(e){this.expr=e}evaluate(e,t){throw new Error("Unimplemented")}}class Q3{constructor(e){this.expr=e}evaluate(e,t){A(1===this.expr.params.length,1508);var n=U(this.expr.params[0]).evaluate(e,t);switch(n.type){case"NULL":return u.Dr();case"BYTES":{let t=n.value?.bytesValue;if("string"!=typeof t)return u.newValue({bytesValue:new Uint8Array(t).reverse()});{let e=L6.fromBase64String(t).toUint8Array();return e.reverse(),u.newValue({bytesValue:L6.fromUint8Array(e).toBase64()})}}case"STRING":{let e=n.value?.stringValue,t=new Intl.__PRIVATE_Segmenter(void 0,{granularity:"grapheme"}).segment(e),r=Array.from(t,e=>e.segment).reverse();return u.newValue({stringValue:r.join("")})}default:return u.vr()}}}class J3{constructor(e){this.expr=e}evaluate(e,t){throw new Error("Unimplemented")}}class X3{constructor(e){this.expr=e}evaluate(e,t){throw new Error("Unimplemented")}}class Z3{constructor(e){this.expr=e}evaluate(e,t){A(1===this.expr.params.length,19400);var r=U(this.expr.params[0]).evaluate(e,t);switch(r.type){case"NULL":return u.Dr();case"STRING":{let e=(e=>{let t=0;for(let i=0;i<e.length;i++){var r,n=e.codePointAt(i);if(void 0===n)return;if(n<=65535)55296<=n&&n<=57343&&n<=56319&&void 0!==(r=e.codePointAt(i+1))&&56320<=r&&r<=57343?(t+=1,i++):t+=1;else{if(!(n<=1114111))return;t+=1,i++}}return t})(r.value.stringValue);return void 0===e?u.vr():u.newValue({integerValue:e})}default:return u.vr()}}}class ew{constructor(e){this.expr=e}evaluate(e,t){A(1===this.expr.params.length,8486);var r=U(this.expr.params[0]).evaluate(e,t);switch(r.type){case"BYTES":{let e=r.value?.bytesValue;return"string"==typeof e?u.newValue({integerValue:L6.fromBase64String(e).toUint8Array().length}):u.newValue({integerValue:new Uint8Array(e).length})}case"STRING":{let e=(e=>{let t=0;for(let i=0;i<e.length;i++){var r=e.codePointAt(i);if(void 0===r)return;if(55296<=r&&r<=57343){if(!(r<=56319))return;var n=e.codePointAt(i+1);if(void 0===n||!(56320<=n&&n<=57343))return;t+=4,i++}else if(r<=127)t+=1;else if(r<=2047)t+=2;else if(r<=65535)t+=3;else{if(!(r<=1114111))return;t+=4,i++}}return t})(r.value?.stringValue);return void 0===e?u.vr():u.newValue({integerValue:e})}case"NULL":return u.Dr();default:return u.vr()}}}class tw{constructor(e){this.expr=e}evaluate(e,t){A(2===this.expr.params.length,39773,this.expr.name+"() function should have exactly two parameters");let r=!1;var n=U(this.expr.params[0]).evaluate(e,t);switch(n.type){case"STRING":break;case"NULL":r=!0;break;default:return u.vr()}var i=U(this.expr.params[1]).evaluate(e,t);switch(i.type){case"STRING":break;case"NULL":r=!0;break;default:return u.vr()}return r?u.Dr():this.kr(n.value?.stringValue,i.value?.stringValue)}}class rw extends tw{kr(e,t){try{var r=(e=>{let t="";for(let n=0;n<e.length;n++){var r=e.charAt(n);switch(r){case"_":t+=".";break;case"%":t+=".*";break;case"\\":case".":case"*":case"?":case"+":case"^":case"$":case"|":case"(":case")":case"[":case"]":case"{":case"}":t+="\\"+r;break;default:t+=r}}return"^"+t+"$"})(t),n=$m.compile(r);return u.newValue({booleanValue:n.matches(e)})}catch(e){return e2(`Invalid LIKE pattern converted to regex: ${t}, returning error. Error: `+e),u.vr()}}}class nw extends tw{kr(e,t){try{var r=$m.compile(t);return u.newValue({booleanValue:r.matcher(e).find()})}catch(e){return e2(`Invalid regex pattern found in regex_contains: ${t}, returning error`),u.vr()}}}class iw extends tw{kr(e,t){try{return u.newValue({booleanValue:$m.compile(t).matches(e)})}catch(e){return e2(`Invalid regex pattern found in regex_match: ${t}, returning error`),u.vr()}}}class sw extends tw{kr(e,t){return u.newValue({booleanValue:e.includes(t)})}}class aw extends tw{kr(e,t){return u.newValue({booleanValue:e.startsWith(t)})}}class ow extends tw{kr(e,t){return u.newValue({booleanValue:e.endsWith(t)})}}class lw{constructor(e){this.expr=e}evaluate(e,t){A(1===this.expr.params.length,29079);var r=U(this.expr.params[0]).evaluate(e,t);switch(r.type){case"STRING":return u.newValue({stringValue:r.value?.stringValue?.toLowerCase()});case"NULL":return u.Dr();default:return u.vr()}}}class uw{constructor(e){this.expr=e}evaluate(e,t){A(1===this.expr.params.length,60487);var r=U(this.expr.params[0]).evaluate(e,t);switch(r.type){case"STRING":return u.newValue({stringValue:r.value?.stringValue?.toUpperCase()});case"NULL":return u.Dr();default:return u.vr()}}}class hw{constructor(e){this.expr=e}evaluate(e,t){A(1===this.expr.params.length,28544);var r=U(this.expr.params[0]).evaluate(e,t);switch(r.type){case"STRING":return u.newValue({stringValue:r.value?.stringValue?.trim()});case"NULL":return u.Dr();default:return u.vr()}}}class cw{constructor(e){this.expr=e}evaluate(t,r){var e=this.expr.params.map(e=>U(e).evaluate(t,r));let n="",i=!1;for(let t of e)switch(t.type){case"STRING":n+=t.value.stringValue;break;case"NULL":i=!0;break;default:return u.vr()}return i?u.Dr():u.newValue({stringValue:n})}}class dw{constructor(e){this.expr=e}evaluate(e,t){A(2===this.expr.params.length,4483);var r=U(this.expr.params[0]).evaluate(e,t);switch(r.type){case"UNSET":return u.Sr();case"MAP":break;default:return u.vr()}var n=U(this.expr.params[1]).evaluate(e,t);return"STRING"!==n.type?u.vr():void 0===(r=r.value?.mapValue?.fields?.[n.value?.stringValue])?u.Sr():u.newValue(r)}}class pw{constructor(e){this.expr=e}evaluate(e,t){A(2===this.expr.params.length,25231,this.expr.name+"() function should have exactly 2 params");let r=!1;var n=U(this.expr.params[0]).evaluate(e,t);switch(n.type){case"VECTOR":break;case"NULL":r=!0;break;default:return u.vr()}var i=U(this.expr.params[1]).evaluate(e,t);switch(i.type){case"VECTOR":break;case"NULL":r=!0;break;default:return u.vr()}return r?u.Dr():(n=wv(n.value),i=wv(i.value),void 0===n||void 0===i||n.values?.length!==i.values?.length||void 0===(n=this.qr(n,i))||isNaN(n)?u.vr():u.newValue({doubleValue:n}))}}class fw extends pw{qr(e,t){var a=e?.values??[],o=t?.values??[];if(0!==a.length){let r=0,n=0,i=0;for(let s=0;s<a.length;s++){if(!fv(a[s])||!fv(o[s]))return;let e=h3(a[s]),t=h3(o[s]);r+=e*t,n+=e*e,i+=t*t}let e=Math.sqrt(n)*Math.sqrt(i);if(0!==e)return 1-Math.max(-1,Math.min(1,r/e))}}}class gw extends pw{qr(e,t){var r=e?.values??[],n=t?.values??[];if(0===r.length)return 0;let i=0;for(let s=0;s<r.length;s++){if(!fv(r[s])||!fv(n[s]))return;i+=h3(r[s])*h3(n[s])}return i}}class mw extends pw{qr(e,t){var r=e?.values??[],n=t?.values??[];if(0===r.length)return 0;let i=0;for(let s=0;s<r.length;s++){if(!fv(r[s])||!fv(n[s]))return;let e=h3(r[s]),t=h3(n[s]);i+=Math.pow(e-t,2)}return Math.sqrt(i)}}class vw{constructor(e){this.expr=e}evaluate(e,t){A(1===this.expr.params.length,39044);var r=U(this.expr.params[0]).evaluate(e,t);switch(r.type){case"VECTOR":{let e=wv(r.value);return u.newValue({integerValue:e?.values?.length??0})}case"NULL":return u.Dr();default:return u.vr()}}}let _w=BigInt(-62135596800),yw=BigInt(253402300799),ww=BigInt(1e3),bw=BigInt(1e6),Tw=_w*ww,Ew=yw*ww+BigInt(999),Iw=_w*bw,Cw=yw*bw+BigInt(999999);function Sw(e){return e>=Iw&&e<=Cw}function kw(e){return e>=_w&&e<=yw}function Aw(e,t){var r=BigInt(e);return!(r<_w||r>yw||t<0||1e9<=t||r===_w&&0!==t||r===yw&&999999999<t)}function Nw(e,t){return t<0?{seconds:e-1,nanos:t+1e9}:{seconds:e,nanos:t}}function Rw(e){return BigInt(e.seconds)*bw+BigInt(Math.trunc(e.nanoseconds/1e3))}class Pw{constructor(e){this.expr=e}evaluate(e,t){A(1===this.expr.params.length,49262,this.expr.name+"() function should have exactly one parameter");var r=U(this.expr.params[0]).evaluate(e,t);switch(r.type){case"INT":return this.toTimestamp(BigInt(r.value.integerValue));case"NULL":return u.Dr();default:return u.vr()}}}class xw extends Pw{toTimestamp(e){var t,r;return Sw(e)&&Aw(t=(r=Nw(Number(e/bw),Number(e%bw*BigInt(1e3)))).seconds,r=r.nanos)?u.newValue({timestampValue:{seconds:t,nanos:r}}):u.vr()}}class Dw extends Pw{toTimestamp(e){var t,r,n;return(t=e)>=Tw&&t<=Ew&&Aw(r=(n=Nw(Number(e/ww),Number(e%ww*BigInt(1e6)))).seconds,n=n.nanos)?u.newValue({timestampValue:{seconds:r,nanos:n}}):u.vr()}}class Ow extends Pw{toTimestamp(e){var t;return kw(e)?(t=Number(e),u.newValue({timestampValue:{seconds:t,nanos:0}})):u.vr()}}class Lw{constructor(e){this.expr=e}evaluate(e,t){A(1===this.expr.params.length,1265,this.expr.name+"() function should have exactly one parameter");var r=U(this.expr.params[0]).evaluate(e,t);switch(r.type){case"TIMESTAMP":break;case"NULL":return u.Dr();default:return u.vr()}r=Ay(r.value.timestampValue);return Aw(r.seconds,r.nanoseconds)?this.$r(r):u.vr()}}class Mw extends Lw{$r(e){var t=Rw(e);return Sw(t)?u.newValue({integerValue:""+t.toString()}):u.vr()}}class Fw extends Lw{$r(e){var t=Rw(e),r=t/BigInt(1e3),t=t%BigInt(1e3);return r>BigInt(0)||t===BigInt(0)?u.newValue({integerValue:r.toString()}):u.newValue({integerValue:(r-BigInt(1)).toString()})}}class Uw extends Lw{$r(e){var t=BigInt(e.seconds);return kw(t)?u.newValue({integerValue:t.toString()}):u.vr()}}class Vw{constructor(e){this.expr=e}evaluate(e,t){A(3===this.expr.params.length,2775,this.expr.name+"() function should have exactly 3 parameters");let r=!1;var n=U(this.expr.params[0]).evaluate(e,t);switch(n.type){case"TIMESTAMP":break;case"NULL":r=!0;break;default:return u.vr()}var i=U(this.expr.params[1]).evaluate(e,t);let s;switch(i.type){case"STRING":if(void 0===(s=(e=>{switch(e){case"microsecond":return"microsecond";case"millisecond":return"millisecond";case"second":return"second";case"minute":return"minute";case"hour":return"hour";case"day":return"day";default:return}})(i.value.stringValue)))return u.vr();break;case"NULL":r=!0;break;default:return u.vr()}var a=U(this.expr.params[2]).evaluate(e,t);switch(a.type){case"INT":break;case"NULL":r=!0;break;default:return u.vr()}if(r)return u.Dr();var o=BigInt(a.value.integerValue);let l;try{switch(s){case"microsecond":l=o;break;case"millisecond":l=o*BigInt(1e3);break;case"second":l=o*BigInt(1e6);break;case"minute":l=o*BigInt(6e7);break;case"hour":l=o*BigInt(36e8);break;case"day":l=o*BigInt(864e8);break;default:return u.vr()}if("microsecond"!==s&&o!==BigInt(0)&&l/o!==BigInt(this.Kr(s)))return u.vr()}catch(e){return e2("Error during timestamp arithmetic: "+e),u.vr()}var a=Ay(n.value.timestampValue);return Aw(a.seconds,a.nanoseconds)&&(n=Rw(a),Sw(a=this.Wr(n,l)))&&(n=Number(a/bw),Aw(n=(a=a%bw)<0?n-1:n,a=Number((a<0?a+bw:a)*BigInt(1e3))))?u.newValue({timestampValue:{seconds:n,nanos:a}}):u.vr()}Kr(e){switch(e){case"millisecond":return 1e3;case"second":return 1e6;case"minute":return 6e7;case"hour":return 36e8;case"day":return 864e8;default:return 1}}}class Bw extends Vw{Wr(e,t){return e+t}}class qw extends Vw{Wr(e,t){return e-t}}function jw(e){if((e=a3(e))instanceof N4)return`fld(${e.fieldName})`;if(e instanceof P4)return`cst(${t=e.value,null===t?"null":"number"==typeof t?t.toString():"string"==typeof t?`"${t}"`:t instanceof q7?`ref(${t.path})`:t instanceof W7?`vec(${JSON.stringify(t)})`:JSON.stringify(t)})`;var t;if(e instanceof s)return`fn(${e.name},[${e.params.map(jw).join(",")}])`;if("ListOfExpressions"===e.expressionType)return`list([${e.Rr.map(jw).join(",")}])`;throw new Error("Unrecognized expr "+JSON.stringify(e,null,2))}function zw(e){return""+Array.from(e.entries()).sort().map(([e,t])=>e+"="+jw(t)).join(",")}function Hw(e){return e.stages.map(t=>{var e;if(t instanceof B4)return`${t._name}(${zw(t.fields)})`;if(t instanceof q4){let e=`${t._name}(${zw(t.accumulators)})`;return 0<t.groups.size&&(e+=`grouping(${zw(t.groups)})`),e}if(t instanceof j4)return`${t._name}(${zw(t.groups)})`;if(t instanceof z4)return t._name+`(${t.Vr})`;if(t instanceof H4)return t._name+`(${t.collectionId})`;if(t instanceof K4)return t._name+"()";if(t instanceof G4)return`${t._name}(${t.dr.sort()})`;if(t instanceof W4)return`${t._name}(${jw(t.condition)})`;if(t instanceof $4)return t._name+`(${t.limit})`;if(t instanceof Q4)return`${t._name}(${e=t.orderings,e.map(e=>""+jw(e.expr)+e.direction).join(",")})`;throw new Error("Unrecognized stage "+t._name)}).join("|")}function Kw(e,t){return Hw(e)===Hw(t)}function Gw(e){return e instanceof Z4}function Ww(e){return(Gw(e)?Hw:K_)(e)}function $w(e){return Gw(e)?Hw(e):A_(q_(e=e))+"|lt:"+e.limitType}function Yw(e,t){return e instanceof Z4&&t instanceof Z4?Kw(e,t):!(e instanceof Z4&&!(t instanceof Z4)||!(e instanceof Z4)&&t instanceof Z4)&&H_(e,t)}function Qw(e){return(R_(e)?Hw:A_)(e)}function Jw(e,t){return e instanceof Z4&&t instanceof Z4?Kw(e,t):!(e instanceof Z4&&!(t instanceof Z4)||!(e instanceof Z4)&&t instanceof Z4)&&N_(e,t)}function Xw(e,t){var r=(e=>{let t=!1;var r,n=[];for(r of e)if(r instanceof Q4)if(t=!0,r.orderings.some(e=>e.expr instanceof N4&&e.expr.fieldName===y2))n.push(r);else{let e=r.orderings.map(e=>e);e.push(R4(y2).ascending()),n.push(new Q4(e,{}))}else r instanceof $4&&(t||(n.push(new Q4([R4(y2).ascending()],{})),t=!0)),n.push(r);return t||n.push(new Q4([R4(y2).ascending()],{})),n})(e.stages);if(e.userDataReader){let t=e.userDataReader.createContext(3,"toCorePipeline");r.forEach(e=>e._readUserData(t))}return new Z4(e.userDataReader.serializer,r,t)}class Zw{constructor(e,t,r,n){this.batchId=e,this.localWriteTime=t,this.baseMutations=r,this.mutations=n}applyToRemoteDocument(e,t){var r,n,i,s,a,o,l,u=t.mutationResults;for(let c=0;c<this.mutations.length;c++){var h=this.mutations[c];h.key.isEqual(e.key)&&(r=h,n=e,i=u[c],l=h=o=a=s=void 0,r instanceof Xv?(a=n,o=i,h=(s=r).value.clone(),l=t_(s.fieldTransforms,a,o.transformResults),h.setAll(l),a.convertToFoundDocument(o.version,h).setHasCommittedMutations()):r instanceof Zv?(s=n,a=i,Wv((o=r).precondition,s)?(l=t_(o.fieldTransforms,s,a.transformResults),(h=s.data).setAll(e_(o)),h.setAll(l),s.convertToFoundDocument(a.version,h).setHasCommittedMutations()):s.convertToUnknownDocument(a.version)):n.convertToNoDocument(i.version).setHasCommittedMutations())}}applyToLocalView(e,t){for(var r of this.baseMutations)r.key.isEqual(e.key)&&(t=Qv(r,e,t,this.localWriteTime));for(var n of this.mutations)n.key.isEqual(e.key)&&(t=Qv(n,e,t,this.localWriteTime));return t}applyToLocalDocumentSet(n,i){let s=ry();return this.mutations.forEach(e=>{var t=n.get(e.key),r=t.overlayedDocument,t=this.applyToLocalView(r,t.mutatedFields),t=Yv(r,i.has(e.key)?null:t);null!==t&&s.set(e.key,t),r.isValidDocument()||r.convertToNoDocument(O.min())}),s}keys(){return this.mutations.reduce((e,t)=>e.add(t.key),F())}isEqual(e){return this.batchId===e.batchId&&v2(this.mutations,e.mutations,(e,t)=>Jv(e,t))&&v2(this.baseMutations,e.baseMutations,(e,t)=>Jv(e,t))}}class e9{constructor(e,t,r,n){this.batch=e,this.commitVersion=t,this.mutationResults=r,this.docVersions=n}static from(e,t,r){A(e.mutations.length===r.length,58842,{Qr:e.mutations.length,Gr:r.length});let n=ny;var i=e.mutations;for(let s=0;s<i.length;s++)n=n.insert(i[s].key,r[s].version);return new e9(e,t,r,n)}}class t9{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{
      largestBatchId: ${this.largestBatchId},
      mutation: ${this.mutation.toString()}
    }`}}class r9{constructor(e,t,r,n,i=O.min(),s=O.min(),a=L6.EMPTY_BYTE_STRING,o=null){this.target=e,this.targetId=t,this.purpose=r,this.sequenceNumber=n,this.snapshotVersion=i,this.lastLimboFreeSnapshotVersion=s,this.resumeToken=a,this.expectedCount=o}withSequenceNumber(e){return new r9(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(e,t){return new r9(this.target,this.targetId,this.purpose,this.sequenceNumber,t,this.lastLimboFreeSnapshotVersion,e,null)}withExpectedCount(e){return new r9(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,e)}withLastLimboFreeSnapshotVersion(e){return new r9(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken,this.expectedCount)}}class n9{constructor(e){this.zr=e}}function i9(e,t){var r,n=t.key,i={prefixPath:n.getCollectionPath().popLast().toArray(),collectionGroup:n.collectionGroup,documentId:n.path.lastSegment(),readTime:s9(t.readTime),hasCommittedMutations:t.hasCommittedMutations};if(t.isFoundDocument())i.document={name:Ly(e=e.zr,(r=t).key),fields:r.data.value.mapValue.fields,updateTime:ky(e,r.version.toTimestamp()),createTime:ky(e,r.createTime.toTimestamp())};else if(t.isNoDocument())i.noDocument={path:n.path.toArray(),readTime:a9(t.version)};else{if(!t.isUnknownDocument())return k(57904,{document:t});i.unknownDocument={path:n.path.toArray(),version:a9(t.version)}}return i}function s9(e){var t=e.toTimestamp();return[t.seconds,t.nanoseconds]}function a9(e){var t=e.toTimestamp();return{seconds:t.seconds,nanoseconds:t.nanoseconds}}function o9(e){var t=new O2(e.seconds,e.nanoseconds);return O.fromTimestamp(t)}function l9(t,r){let e=(r.baseMutations||[]).map(e=>Hy(t.zr,e));for(let s=0;s<r.mutations.length-1;++s){let t=r.mutations[s];if(s+1<r.mutations.length&&void 0!==r.mutations[s+1].transform){let e=r.mutations[s+1];t.updateTransforms=e.transform.fieldTransforms,r.mutations.splice(s+1,1),++s}}let n=r.mutations.map(e=>Hy(t.zr,e)),i=O2.fromMillis(r.localWriteTimeMs);return new Zw(r.batchId,i,e,n)}function u9(e,t){var r,n,i=o9(t.readTime),s=void 0!==t.lastLimboFreeSnapshotVersion?o9(t.lastLimboFreeSnapshotVersion):O.min(),a=void 0!==t.query.structuredPipeline?(r=t.query,e=e.zr,A(0<((n=r.structuredPipeline)?.pipeline?.stages??[]).length,1845),n=n?.pipeline?.stages.map(g9),new Z4(e,n)):void 0!==t.query.documents?(r=t.query,A(1===(n=r.documents.length),1966,{count:n}),q_(F_(Uy(r.documents[0])))):q_($y(t.query));return new r9(a,t.targetId,"TargetPurposeListen",t.lastListenSequenceNumber,i,s,L6.fromBase64String(t.resumeToken))}function h9(e,t){var r=a9(t.snapshotVersion),n=a9(t.lastLimboFreeSnapshotVersion),i=R_(t.target)?Qy(e.zr,t.target):P_(t.target)?Gy(e.zr,t.target):Wy(e.zr,t.target).yt,s=t.resumeToken.toBase64();return{targetId:t.targetId,canonicalId:Qw(t.target),readTime:r,resumeToken:s,lastListenSequenceNumber:t.sequenceNumber,lastLimboFreeSnapshotVersion:n,query:i}}function c9(e){var t=$y({parent:e.parent,structuredQuery:e.structuredQuery});return"LAST"===e.limitType?z_(t,t.limit,"L"):t}function d9(e,t){return new t9(t.largestBatchId,Hy(e.zr,t.overlayMutation))}function p9(e,t){var r=t.path.lastSegment();return[e,f0(t.path.popLast()),r]}function f9(e,t,r,n){return{indexId:e,uid:t,sequenceNumber:r,readTime:a9(n.readTime),documentKey:f0(n.documentKey.path),largestBatchId:n.largestBatchId}}function g9(e){switch(e.name){case"collection":return new z4(e.args[0].referenceValue,{});case"collection_group":return new H4(e.args[1].stringValue,{});case"database":return new K4({});case"documents":return new G4(e.args.map(e=>e.referenceValue),{});case"where":return new W4(m9(e.args[0]),{});case"limit":var t=e.args[0].integerValue??e.args[0].doubleValue;return new $4("number"==typeof t?t:Number(t),{});case"sort":return new Q4(e.args.map(e=>{return t=e.mapValue?.fields,new U4(m9(t.expression),t.direction?.stringValue,"orderingFromProto");var t}),{});default:throw new Error(`Stage type: ${e.name} not supported.`)}}function m9(e){return e.fieldReferenceValue?new N4(g4("_exprFromProto",e.fieldReferenceValue),"_exprFromProto"):e.functionValue?(t=e,new s(t.functionValue.name,t.functionValue.args?.map(m9)||[])):P4._fromProto(e);var t}class v9{getBundleMetadata(e,t){return _9(e).get(t).next(e=>{if(e)return{id:(e=e).bundleId,createTime:o9(e.createTime),version:e.version}})}saveBundleMetadata(e,t){return _9(e).put({bundleId:(e=t).id,createTime:a9(Py(e.createTime)),version:e.version})}getNamedQuery(e,t){return y9(e).get(t).next(e=>{if(e)return{name:(e=e).name,query:c9(e.bundledQuery),readTime:o9(e.readTime)}})}saveNamedQuery(e,t){return y9(e).put({name:(e=t).name,readTime:a9(Py(e.readTime)),bundledQuery:e.bundledQuery})}}function _9(e){return E6(e,Y0)}function y9(e){return E6(e,Q0)}class w9{constructor(e,t){this.serializer=e,this.userId=t}static jr(e,t){var r=t.uid||"";return new w9(e,r)}getOverlay(e,t){return b9(e).get(p9(this.userId,t)).next(e=>e?d9(this.serializer,e):null)}getOverlays(e,t){let r=ry();return L.forEach(t,t=>this.getOverlay(e,t).next(e=>{null!==e&&r.set(t,e)})).next(()=>r)}getAllOverlays(e,n){let i=ry();return b9(e).ee((e,t)=>{var r=d9(this.serializer,t);r.largestBatchId>n&&i.set(r.getKey(),r)}).next(()=>i)}saveOverlays(n,i,e){let s=[];return e.forEach((e,t)=>{var r=new t9(i,t);s.push(this.Hr(n,r))}),L.waitFor(s)}removeOverlaysForBatchId(r,e,n){let t=new Set,i=(e.forEach(e=>t.add(f0(e.getCollectionPath()))),[]);return t.forEach(e=>{var t=IDBKeyRange.bound([this.userId,e,n],[this.userId,e,n+1],!1,!0);i.push(b9(r).Z(u6,t))}),L.waitFor(i)}getOverlaysForCollection(e,t,r){let n=ry(),i=f0(t),s=IDBKeyRange.bound([this.userId,i,r],[this.userId,i,Number.POSITIVE_INFINITY],!0);return b9(e).H(u6,s).next(e=>{for(var t of e){let e=d9(this.serializer,t);n.set(e.getKey(),e)}return n})}getOverlaysForCollectionGroup(e,t,r,i){let s=ry(),a;var n=IDBKeyRange.bound([this.userId,t,r],[this.userId,t,Number.POSITIVE_INFINITY],!0);return b9(e).ee({index:c6,range:n},(e,t,r)=>{var n=d9(this.serializer,t);s.size()<i||n.largestBatchId===a?(s.set(n.getKey(),n),a=n.largestBatchId):r.done()}).next(()=>s)}Hr(e,t){return b9(e).put(((e,t,r)=>{var[,n,i]=p9(t,r.mutation.key);return{userId:t,collectionPath:n,documentId:i,collectionGroup:r.mutation.key.getCollectionGroup(),largestBatchId:r.largestBatchId,overlayMutation:zy(e.zr,r.mutation)}})(this.serializer,this.userId,t))}}function b9(e){return E6(e,o6)}class T9{Jr(e){return E6(e,p6)}getSessionToken(e){return this.Jr(e).get("sessionToken").next(e=>{var t=e?.value;return t?L6.fromUint8Array(t):L6.EMPTY_BYTE_STRING})}setSessionToken(e,t){return this.Jr(e).put({name:"sessionToken",value:t.toUint8Array()})}}class E9{constructor(){}Yr(e,t){this.Zr(e,t),t.Xr()}Zr(t,r){if("nullValue"in t)this.ei(r,5);else if("booleanValue"in t)this.ei(r,10),r.ti(t.booleanValue?1:0);else if("integerValue"in t)this.ei(r,15),r.ti(U6(t.integerValue));else if("doubleValue"in t){var e=U6(t.doubleValue);isNaN(e)?this.ei(r,13):(this.ei(r,15),c0(e)?r.ti(0):r.ti(e))}else if("timestampValue"in t){let e=t.timestampValue;this.ei(r,20),"string"==typeof e&&(e=F6(e)),r.ni(""+(e.seconds||"")),r.ti(e.nanos||0)}else"stringValue"in t?(this.ri(t.stringValue,r),this.ii(r)):"bytesValue"in t?(this.ei(r,30),r.si(V6(t.bytesValue)),this.ii(r)):"referenceValue"in t?this._i(t.referenceValue,r):"geoPointValue"in t?(e=t.geoPointValue,this.ei(r,45),r.ti(e.latitude||0),r.ti(e.longitude||0)):"mapValue"in t?Tv(t)?this.ei(r,Number.MAX_SAFE_INTEGER):yv(t)?this.oi(t.mapValue,r):(this.ai(t.mapValue,r),this.ii(r)):"arrayValue"in t?(this.ui(t.arrayValue,r),this.ii(r)):k(19022,{ci:t})}ri(e,t){this.ei(t,25),this.li(e,t)}li(e,t){t.ni(e)}ai(e,t){var r=e.fields||{};this.ei(t,55);for(let e of Object.keys(r))this.ri(e,t),this.Zr(r[e],t)}oi(e,t){var r=e.fields||{},n=(this.ei(t,53),ev),i=r[n].arrayValue?.values?.length||0;this.ei(t,15),t.ti(U6(i)),this.ri(n,t),this.Zr(r[n],t)}ui(e,t){var r=e.values||[];this.ei(t,50);for(let e of r)this.Zr(e,t)}_i(e,t){this.ei(t,37),D.fromName(e).path.forEach(e=>{this.ei(t,60),this.li(e,t)})}ei(e,t){e.ti(t)}ii(e){e.ti(2)}}E9.Ei=new E9;function I9(e){var t=64-(e=>{let t=0;for(let n=0;n<8;++n){var r=(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})(255&e[n]);if(t+=r,8!==r)break}return t})(e);return Math.ceil(t/8)}class C9{constructor(){this.buffer=new Uint8Array(1024),this.position=0}hi(e){var t=e[Symbol.iterator]();let r=t.next();for(;!r.done;)this.Ti(r.value),r=t.next();this.Pi()}Ri(e){var t=e[Symbol.iterator]();let r=t.next();for(;!r.done;)this.Ii(r.value),r=t.next();this.Ai()}Vi(e){for(var t of e){let e=t.charCodeAt(0);if(e<128)this.Ti(e);else if(e<2048)this.Ti(960|e>>>6),this.Ti(128|63&e);else if(t<"\ud800"||"\udbff"<t)this.Ti(480|e>>>12),this.Ti(128|63&e>>>6),this.Ti(128|63&e);else{let e=t.codePointAt(0);this.Ti(240|e>>>18),this.Ti(128|63&e>>>12),this.Ti(128|63&e>>>6),this.Ti(128|63&e)}}this.Pi()}di(e){for(var t of e){let e=t.charCodeAt(0);if(e<128)this.Ii(e);else if(e<2048)this.Ii(960|e>>>6),this.Ii(128|63&e);else if(t<"\ud800"||"\udbff"<t)this.Ii(480|e>>>12),this.Ii(128|63&e>>>6),this.Ii(128|63&e);else{let e=t.codePointAt(0);this.Ii(240|e>>>18),this.Ii(128|63&e>>>12),this.Ii(128|63&e>>>6),this.Ii(128|63&e)}}this.Ai()}fi(e){var t=this.mi(e),r=I9(t);this.pi(1+r),this.buffer[this.position++]=255&r;for(let n=t.length-r;n<t.length;++n)this.buffer[this.position++]=255&t[n]}gi(e){var t=this.mi(e),r=I9(t);this.pi(1+r),this.buffer[this.position++]=~(255&r);for(let n=t.length-r;n<t.length;++n)this.buffer[this.position++]=~(255&t[n])}yi(){this.wi(255),this.wi(255)}bi(){this.Si(255),this.Si(255)}reset(){this.position=0}seed(e){this.pi(e.length),this.buffer.set(e,this.position),this.position+=e.length}Di(){return this.buffer.slice(0,this.position)}mi(e){e=e,(t=new DataView(new ArrayBuffer(8))).setFloat64(0,e,!1);var t,r=new Uint8Array(t.buffer),n=!!(128&r[0]);r[0]^=n?255:128;for(let i=1;i<r.length;++i)r[i]^=n?255:0;return r}Ti(e){var t=255&e;0==t?(this.wi(0),this.wi(255)):255==t?(this.wi(255),this.wi(0)):this.wi(t)}Ii(e){var t=255&e;0==t?(this.Si(0),this.Si(255)):255==t?(this.Si(255),this.Si(0)):this.Si(e)}Pi(){this.wi(0),this.wi(1)}Ai(){this.Si(0),this.Si(1)}wi(e){this.pi(1),this.buffer[this.position++]=e}Si(e){this.pi(1),this.buffer[this.position++]=~e}pi(e){var t=e+this.position;if(!(t<=this.buffer.length)){let e=2*this.buffer.length;e<t&&(e=t);t=new Uint8Array(e);t.set(this.buffer),this.buffer=t}}}class S9{constructor(e){this.xi=e}si(e){this.xi.hi(e)}ni(e){this.xi.Vi(e)}ti(e){this.xi.fi(e)}Xr(){this.xi.yi()}}class k9{constructor(e){this.xi=e}si(e){this.xi.Ri(e)}ni(e){this.xi.di(e)}ti(e){this.xi.gi(e)}Xr(){this.xi.bi()}}class A9{constructor(){this.xi=new C9,this.ascending=new S9(this.xi),this.descending=new k9(this.xi)}seed(e){this.xi.seed(e)}Ci(e){return 0===e?this.ascending:this.descending}Di(){return this.xi.Di()}reset(){this.xi.reset()}}class N9{constructor(e,t,r,n){this.Fi=e,this.Oi=t,this.Mi=r,this.Ni=n}Li(){var e=this.Ni.length,t=0===e||255===this.Ni[e-1]?e+1:e,r=new Uint8Array(t);return r.set(this.Ni,0),t!==e?r.set([0],this.Ni.length):++r[r.length-1],new N9(this.Fi,this.Oi,this.Mi,r)}Bi(e,t,r){return{indexId:this.Fi,uid:e,arrayValue:x9(this.Mi),directionalValue:x9(this.Ni),orderedDocumentKey:x9(t),documentKey:r.path.toArray()}}Ui(e,t,r){var n=this.Bi(e,t,r);return[n.indexId,n.uid,n.arrayValue,n.directionalValue,n.orderedDocumentKey,n.documentKey]}}function R9(e,t){var r=e.Fi-t.Fi;return 0!=r||0!==(r=P9(e.Mi,t.Mi))||0!==(r=P9(e.Ni,t.Ni))?r:D.comparator(e.Oi,t.Oi)}function P9(e,t){for(let n=0;n<e.length&&n<t.length;++n){var r=e[n]-t[n];if(0!=r)return r}return e.length-t.length}function x9(r){if(he()){var n=r;let e="";for(let t=0;t<n.length;t++)e+=String.fromCharCode(n[t]);return e}return r}function D9(e){if("string"!=typeof e)return e;var t=e,r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}class O9{constructor(e){this.ki=new k6((e,t)=>T2.comparator(e.field,t.field)),this.collectionId=null!=e.collectionGroup?e.collectionGroup:e.path.lastSegment(),this.qi=e.orderBy,this.$i=[];for(var t of e.filters){let e=t;e.isInequality()?this.ki=this.ki.add(e):this.$i.push(e)}}get Ki(){return 1<this.ki.size}Wi(e){if(A(e.collectionGroup===this.collectionId,49279),this.Ki)return!1;let t=F2(e);if(void 0!==t&&!this.Qi(t))return!1;var r=U2(e);let n=new Set,i=0,s=0;for(;i<r.length&&this.Qi(r[i]);++i)n=n.add(r[i].fieldPath.canonicalString());if(i!==r.length){if(0<this.ki.size){let t=this.ki.getIterator().getNext();if(!n.has(t.field.canonicalString())){let e=r[i];if(!this.Gi(t,e)||!this.zi(this.qi[s++],e))return!1}++i}for(;i<r.length;++i){let e=r[i];if(s>=this.qi.length||!this.zi(this.qi[s++],e))return!1}}return!0}ji(){if(this.Ki)return null;let e=new k6(T2.comparator);var t,r,n=[];for(t of this.$i)t.field.isKeyField()||("array-contains"===t.op||"array-contains-any"===t.op?n.push(new V2(t.field,2)):e.has(t.field)||(e=e.add(t.field),n.push(new V2(t.field,0))));for(r of this.qi)r.field.isKeyField()||e.has(r.field)||(e=e.add(r.field),n.push(new V2(r.field,"asc"===r.dir?0:1)));return new M2(M2.UNKNOWN_ID,this.collectionId,n,B2.empty())}Qi(e){for(var t of this.$i)if(this.Gi(t,e))return!0;return!1}Gi(e,t){var r;return!(void 0===e||!e.field.isEqual(t.fieldPath))&&(r="array-contains"===e.op||"array-contains-any"===e.op,2===t.kind==r)}zi(e,t){return!!e.field.isEqual(t.fieldPath)&&(0===t.kind&&"asc"===e.dir||1===t.kind&&"desc"===e.dir)}}function L9(e){var t;return 0===e.getFilters().length?[]:(t=function t(e){if(A(e instanceof M||e instanceof u_,34018),e instanceof M)return e;if(1===e.filters.length)return t(e.filters[0]);let r=e.filters.map(e=>t(e));let n=u_.create(r,e.op);return n=q9(n),U9(n)?n:(A(n instanceof u_,64498),A(h_(n),40251),A(1<n.filters.length,57927),n.filters.reduce((e,t)=>V9(e,t)))}(function t(r){if(A(r instanceof M||r instanceof u_,20012),r instanceof M){if(r instanceof b_){let e=r.value.arrayValue?.values?.map(e=>M.create(r.field,"==",e))||[];return u_.create(e,"or")}return r}let e=r.filters.map(e=>t(e));return u_.create(e,r.op)}(e)),A(U9(t),7391),M9(t)||F9(t)?[t]:t.getFilters())}function M9(e){return e instanceof M}function F9(e){return e instanceof u_&&d_(e)}function U9(e){return M9(e)||F9(e)||(e=>{if(e instanceof u_&&c_(e)){for(var t of e.getFilters())if(!M9(t)&&!F9(t))return!1;return!0}return!1})(e)}function V9(e,t){var r,n;return A(e instanceof M||e instanceof u_,38388),A(t instanceof M||t instanceof u_,25473),q9(e instanceof M?t instanceof M?(r=e,n=t,u_.create([r,n],"and")):B9(e,t):t instanceof M?B9(t,e):((e,t)=>{if(A(0<e.filters.length&&0<t.filters.length,48005),h_(e)&&h_(t))return f_(e,t.getFilters());let r=c_(e)?e:t,n=c_(e)?t:e,i=r.filters.map(e=>V9(e,n));return u_.create(i,"or")})(e,t))}function B9(t,e){var r;return h_(e)?f_(e,t.getFilters()):(r=e.filters.map(e=>V9(t,e)),u_.create(r,"or"))}function q9(t){if(A(t instanceof M||t instanceof u_,11850),t instanceof M)return t;var e=t.getFilters();if(1===e.length)return q9(e[0]);if(p_(t))return t;let r=e.map(e=>q9(e)),n=[];return r.forEach(e=>{e instanceof M?n.push(e):e instanceof u_&&(e.op===t.op?n.push(...e.filters):n.push(e))}),1===n.length?n[0]:u_.create(n,t.op)}class j9{constructor(){this.Hi=new z9}addToCollectionParentIndex(e,t){return this.Hi.add(t),L.resolve()}getCollectionParents(e,t){return L.resolve(this.Hi.getEntries(t))}addFieldIndex(e,t){return L.resolve()}deleteFieldIndex(e,t){return L.resolve()}deleteAllFieldIndexes(e){return L.resolve()}createTargetIndexes(e,t){return L.resolve()}getDocumentsMatchingTarget(e,t){return L.resolve(null)}getIndexType(e,t){return L.resolve(0)}getFieldIndexes(e,t){return L.resolve([])}getNextCollectionGroupToUpdate(e){return L.resolve(null)}getMinOffset(e,t){return L.resolve(z2.min())}getMinOffsetFromCollectionGroup(e,t){return L.resolve(z2.min())}updateCollectionGroup(e,t,r){return L.resolve()}updateIndexEntries(e,t){return L.resolve()}}class z9{constructor(){this.index={}}add(e){var t=e.lastSegment(),r=e.popLast(),n=this.index[t]||new k6(x.comparator),i=!n.has(r);return this.index[t]=n.add(r),i}has(e){var t=e.lastSegment(),r=e.popLast(),t=this.index[t];return t&&t.has(r)}getEntries(e){return(this.index[e]||new k6(x.comparator)).toArray()}}let H9="IndexedDbIndexManager",K9=new Uint8Array(0);class G9{constructor(e,t){this.databaseId=t,this.Ji=new z9,this.Yi=new J_(e=>A_(e),(e,t)=>N_(e,t)),this.uid=e.uid||""}addToCollectionParentIndex(e,t){var r,n;return this.Ji.has(t)?L.resolve():(n=t.lastSegment(),r=t.popLast(),e.addOnCommittedListener(()=>{this.Ji.add(t)}),n={collectionId:n,parent:f0(r)},W9(e).put(n))}getCollectionParents(e,r){let n=[],t=IDBKeyRange.bound([r,""],[_2(r),""],!1,!0);return W9(e).H(t).next(e=>{for(var t of e){if(t.collectionId!==r)break;n.push(m0(t.parent))}return n})}addFieldIndex(e,r){let t=Y9(e),n={indexId:r.indexId,collectionGroup:r.collectionGroup,fields:r.fields.map(e=>[e.fieldPath.canonicalString(),e.kind])};delete n.indexId;var i=t.add(n);if(r.indexState){let t=Q9(e);return i.next(e=>{t.put(f9(e,this.uid,r.indexState.sequenceNumber,r.indexState.offset))})}return i.next()}deleteFieldIndex(e,t){let r=Y9(e),n=Q9(e),i=$9(e);return r.delete(t.indexId).next(()=>n.delete(IDBKeyRange.bound([t.indexId],[t.indexId+1],!1,!0))).next(()=>i.delete(IDBKeyRange.bound([t.indexId],[t.indexId+1],!1,!0)))}deleteAllFieldIndexes(e){let t=Y9(e),r=$9(e),n=Q9(e);return t.Z().next(()=>r.Z()).next(()=>n.Z())}createTargetIndexes(r,e){return L.forEach(this.Zi(e),t=>this.getIndexType(r,t).next(e=>{if(0===e||1===e){let e=new O9(t).ji();if(null!=e)return this.addFieldIndex(r,e)}}))}getDocumentsMatchingTarget(e,c){let d=$9(e),r=!0,n=new Map;return L.forEach(this.Zi(c),t=>this.Xi(e,t).next(e=>{r=r&&!!e,n.set(t,e)})).next(()=>{if(r){let u=F(),h=[];return L.forEach(n,(e,t)=>{S(H9,`Using index ${r=e,`id=${r.indexId}|cg=${r.collectionGroup}|f=`+r.fields.map(e=>e.fieldPath+":"+e.kind).join(",")} to execute `+A_(c));var r,n=((t,e)=>{var r=F2(e);if(void 0!==r)for(let e of x_(t,r.fieldPath))switch(e.op){case"array-contains-any":return e.value.arrayValue.values||[];case"array-contains":return[e.value]}return null})(t,e),i=((t,r)=>{var n,i=new Map;for(n of U2(r))for(let e of x_(t,n.fieldPath))switch(e.op){case"==":case"in":i.set(n.fieldPath.canonicalString(),e.value);break;case"not-in":case"!=":return i.set(n.fieldPath.canonicalString(),e.value),Array.from(i.values())}return null})(t,e),s=((t,e)=>{var r,n=[];let i=!0;for(r of U2(e)){let e=(0===r.kind?D_:O_)(t,r.fieldPath,t.startAt);n.push(e.value),i=i&&e.inclusive}return new s_(n,i)})(t,e),a=((t,e)=>{var r,n=[];let i=!0;for(r of U2(e)){let e=(0===r.kind?O_:D_)(t,r.fieldPath,t.endAt);n.push(e.value),i=i&&e.inclusive}return new s_(n,i)})(t,e),o=this.es(e,t,s),l=this.es(e,t,a),i=this.ts(e,t,i),n=this.ns(e.indexId,n,o,s.inclusive,l,a.inclusive,i);return L.forEach(n,e=>d.Y(e,c.limit).next(e=>{e.forEach(e=>{var t=D.fromSegments(e.documentKey);u.has(t)||(u=u.add(t),h.push(t))})}))}).next(()=>h)}return L.resolve(null)})}Zi(t){let e=this.Yi.get(t);return e||(e=0===t.filters.length?[t]:L9(u_.create(t.filters,"and")).map(e=>k_(t.path,t.collectionGroup,t.orderBy,e.getFilters(),t.limit,t.startAt,t.endAt)),this.Yi.set(t,e)),e}ns(i,s,a,o,l,u,h){let e=(null!=s?s.length:1)*Math.max(a.length,l.length),c=e/(null!=s?s.length:1),d=[];for(let p=0;p<e;++p){let t=s?this.rs(s[p/c]):K9,e=this.ss(i,t,a[p%c],o),r=this._s(i,t,l[p%c],u),n=h.map(e=>this.ss(i,t,e,!0));d.push(...this.createRange(e,r,n))}return d}ss(e,t,r,n){var i=new N9(e,D.empty(),t,r);return n?i:i.Li()}_s(e,t,r,n){var i=new N9(e,D.empty(),t,r);return n?i.Li():i}Xi(e,t){let n=new O9(t),r=null!=t.collectionGroup?t.collectionGroup:t.path.lastSegment();return this.getFieldIndexes(e,r).next(e=>{let t=null;for(var r of e)n.Wi(r)&&(!t||r.fields.length>t.fields.length)&&(t=r);return t})}getIndexType(e,t){let r=2,n=this.Zi(t);return L.forEach(n,t=>this.Xi(e,t).next(e=>{e?0!==r&&e.fields.length<(t=>{let r=new k6(T2.comparator),n=!1;for(var i of t.filters)for(let e of i.getFlattenedFilters())e.field.isKeyField()||("array-contains"===e.op||"array-contains-any"===e.op?n=!0:r=r.add(e.field));for(let n of t.orderBy)n.field.isKeyField()||(r=r.add(n.field));return r.size+(n?1:0)})(t)&&(r=1):r=0})).next(()=>null!==t.limit&&1<n.length&&2===r?1:r)}us(e,t){var r,n=new A9;for(r of U2(e)){let e=t.data.field(r.fieldPath);if(null==e)return null;var i=n.Ci(r.kind);E9.Ei.Yr(e,i)}return n.Di()}rs(e){var t=new A9;return E9.Ei.Yr(e,t.Ci(0)),t.Di()}cs(e,t){var r,n=new A9;return E9.Ei.Yr(cv(this.databaseId,t),n.Ci(0===(r=U2(e)).length?0:r[r.length-1].kind)),n.Di()}ts(e,n,i){if(null===i)return[];let s=[],a=(s.push(new A9),0);for(var o of U2(e)){let t=i[a++];for(let r of s)if(this.ls(n,o.fieldPath)&&gv(t))s=this.Es(s,o,t);else{let e=r.Ci(o.kind);E9.Ei.Yr(t,e)}}return this.hs(s)}es(e,t,r){return this.ts(e,t,r.position)}hs(e){var t=[];for(let r=0;r<e.length;++r)t[r]=e[r].Di();return t}Es(r,n,e){let i=[...r],s=[];for(let r of e.arrayValue.values||[])for(let t of i){let e=new A9;e.seed(t.Di()),E9.Ei.Yr(r,e.Ci(n.kind)),s.push(e)}return s}ls(e,t){return!!e.filters.find(e=>e instanceof M&&e.field.isEqual(t)&&("in"===e.op||"not-in"===e.op))}getFieldIndexes(e,t){let r=Y9(e),n=Q9(e);return(t?r.H(X0,IDBKeyRange.bound(t,t)):r.H()).next(e=>{let s=[];return L.forEach(e,i=>n.get([i.indexId,this.uid]).next(e=>{var t,r,n;s.push((t=i,r=(e=e)?new B2(e.sequenceNumber,new z2(o9(e.readTime),new D(m0(e.documentKey)),e.largestBatchId)):B2.empty(),n=t.fields.map(([e,t])=>new V2(T2.fromServerFormat(e),t)),new M2(t.indexId,t.collectionGroup,n,r)))})).next(()=>s)})}getNextCollectionGroupToUpdate(e){return this.getFieldIndexes(e).next(e=>0===e.length?null:(e.sort((e,t)=>{var r=e.indexState.sequenceNumber-t.indexState.sequenceNumber;return 0!=r?r:P(e.collectionGroup,t.collectionGroup)}),e[0].collectionGroup))}updateCollectionGroup(e,r,n){let i=Y9(e),s=Q9(e);return this.Ts(e).next(t=>i.H(X0,IDBKeyRange.bound(r,r)).next(e=>L.forEach(e,e=>s.put(f9(e.indexId,this.uid,t,n)))))}updateIndexEntries(i,e){let r=new Map;return L.forEach(e,(t,n)=>{var e=r.get(t.collectionGroup);return(e?L.resolve(e):this.getFieldIndexes(i,t.collectionGroup)).next(e=>(r.set(t.collectionGroup,e),L.forEach(e,r=>this.Ps(i,t,r).next(e=>{var t=this.Rs(n,r);return e.isEqual(t)?L.resolve():this.Is(i,n,r,e,t)}))))})}As(e,t,r,n){return $9(e).put(n.Bi(this.uid,this.cs(r,t.key),t.key))}Vs(e,t,r,n){return $9(e).delete(n.Ui(this.uid,this.cs(r,t.key),t.key))}Ps(e,r,n){var t=$9(e);let i=new k6(R9);return t.ee({index:s6,range:IDBKeyRange.only([n.indexId,this.uid,x9(this.cs(n,r))])},(e,t)=>{i=i.add(new N9(n.indexId,r,D9(t.arrayValue),D9(t.directionalValue)))}).next(()=>i)}Rs(t,r){let n=new k6(R9);var i=this.us(r,t);if(null!=i){let e=F2(r);if(null!=e){var s=t.data.field(e.fieldPath);if(gv(s))for(let e of s.arrayValue.values||[])n=n.add(new N9(r.indexId,t.key,this.rs(e),i))}else n=n.add(new N9(r.indexId,t.key,K9,i))}return n}Is(t,r,s,e,a){S(H9,"Updating index entries for document '%s'",r.key);let o=[];{var l=R9,u=e=>{o.push(this.As(t,r,s,e))},h=e=>{o.push(this.Vs(t,r,s,e))},c=e.getIterator(),d=a.getIterator();let n=N6(c),i=N6(d);for(;n||i;){let t=!1,r=!1;if(n&&i){let e=l(n,i);e<0?r=!0:0<e&&(t=!0)}else null!=n?r=!0:t=!0;t?(u(i),i=N6(d)):r?(h(n),n=N6(c)):(n=N6(c),i=N6(d))}}return L.waitFor(o)}Ts(e){let n=1;return Q9(e).ee({index:t6,reverse:!0,range:IDBKeyRange.upperBound([this.uid,Number.MAX_SAFE_INTEGER])},(e,t,r)=>{r.done(),n=t.sequenceNumber+1}).next(()=>n)}createRange(r,n,e){e=e.sort((e,t)=>R9(e,t)).filter((e,t,r)=>!t||0!==R9(e,r[t-1]));var i=[];i.push(r);for(let s of e){let e=R9(s,r),t=R9(s,n);if(0===e)i[0]=r.Li();else if(0<e&&t<0)i.push(s),i.push(s.Li());else if(0<t)break}i.push(n);let s=[];for(let a=0;a<i.length;a+=2){if(this.ds(i[a],i[a+1]))return[];let e=i[a].Ui(this.uid,K9,D.empty()),t=i[a+1].Ui(this.uid,K9,D.empty());s.push(IDBKeyRange.bound(e,t))}return s}ds(e,t){return 0<R9(e,t)}getMinOffsetFromCollectionGroup(e,t){return this.getFieldIndexes(e,t).next(J9)}getMinOffset(t,e){return L.mapArray(this.Zi(e),e=>this.Xi(t,e).next(e=>e||k(44426))).next(J9)}}function W9(e){return E6(e,G0)}function $9(e){return E6(e,n6)}function Y9(e){return E6(e,J0)}function Q9(e){return E6(e,Z0)}function J9(e){A(0!==e.length,28825);let t=e[0].indexState.offset,r=t.largestBatchId;for(let i=1;i<e.length;i++){var n=e[i].indexState.offset;H2(n,t)<0&&(t=n),r<n.largestBatchId&&(r=n.largestBatchId)}return new z2(t.readTime,t.documentKey,r)}function X9(t,r,n){let e=t.store(b0),i=t.store(A0),s=[],a=IDBKeyRange.only(n.batchId),o=0;var l=e.ee({range:a},(e,t,r)=>(o++,r.delete()));s.push(l.next(()=>{A(1===o,47070,{batchId:n.batchId})}));let u=[];for(let t of n.mutations){let e=S0(r,t.key.path,n.batchId);s.push(i.delete(e)),u.push(t.key)}return L.waitFor(s).next(()=>u)}function Z9(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 k(14731);t=e.noDocument}return JSON.stringify(t).length}class e8{constructor(e,t,r,n){this.userId=e,this.serializer=t,this.indexManager=r,this.referenceDelegate=n,this.fs={}}static jr(e,t,r,n){A(""!==e.uid,64387);var i=e.isAuthenticated()?e.uid:"";return new e8(i,t,r,n)}checkEmpty(e){let n=!0;var t=IDBKeyRange.bound([this.userId,Number.NEGATIVE_INFINITY],[this.userId,Number.POSITIVE_INFINITY]);return r8(e).ee({index:E0,range:t},(e,t,r)=>{n=!1,r.done()}).next(()=>n)}addMutationBatch(c,d,p,f){let g=n8(c),m=r8(c);return m.add({}).next(t=>{A("number"==typeof t,49019);let e=new Zw(t,d,p,f),r=(i=this.serializer,s=this.userId,a=e,o=a.baseMutations.map(e=>zy(i.zr,e)),l=a.mutations.map(e=>zy(i.zr,e)),{userId:s,batchId:a.batchId,localWriteTimeMs:a.localWriteTime.toMillis(),baseMutations:o,mutations:l}),n=[];var i,s,a,o,l;let u=new k6((e,t)=>P(e.canonicalString(),t.canonicalString()));for(let h of f){let e=S0(this.userId,h.key.path,t);u=u.add(h.key.path.popLast()),n.push(m.put(r)),n.push(g.put(e,k0))}return u.forEach(e=>{n.push(this.indexManager.addToCollectionParentIndex(c,e))}),c.addOnCommittedListener(()=>{this.fs[t]=e.keys()}),L.waitFor(n).next(()=>e)})}lookupMutationBatch(e,t){return r8(e).get(t).next(e=>e?(A(e.userId===this.userId,48,"Unexpected user for mutation batch",{userId:e.userId,batchId:t}),l9(this.serializer,e)):null)}ps(e,r){return this.fs[r]?L.resolve(this.fs[r]):this.lookupMutationBatch(e,r).next(e=>{var t;return e?(t=e.keys(),this.fs[r]=t):null})}getNextMutationBatchAfterBatchId(e,t){let n=t+1,r=IDBKeyRange.lowerBound([this.userId,n]),i=null;return r8(e).ee({index:E0,range:r},(e,t,r)=>{t.userId===this.userId&&(A(t.batchId>=n,47524,{gs:n}),i=l9(this.serializer,t)),r.done()}).next(()=>i)}getHighestUnacknowledgedBatchId(e){var t=IDBKeyRange.upperBound([this.userId,Number.POSITIVE_INFINITY]);let n=u0;return r8(e).ee({index:E0,range:t,reverse:!0},(e,t,r)=>{n=t.batchId,r.done()}).next(()=>n)}getAllMutationBatches(e){var t=IDBKeyRange.bound([this.userId,u0],[this.userId,Number.POSITIVE_INFINITY]);return r8(e).H(E0,t).next(e=>e.map(e=>l9(this.serializer,e)))}getAllMutationBatchesAffectingDocumentKey(o,l){let e=C0(this.userId,l.path),t=IDBKeyRange.lowerBound(e),u=[];return n8(o).ee({range:t},(t,e,r)=>{let[n,i,s]=t,a=m0(i);if(n===this.userId&&l.path.isEqual(a))return r8(o).get(s).next(e=>{if(!e)throw k(61480,{ys:t,batchId:s});A(e.userId===this.userId,10503,"Unexpected user for mutation batch",{userId:e.userId,batchId:s}),u.push(l9(this.serializer,e))});r.done()}).next(()=>u)}getAllMutationBatchesAffectingDocumentKeys(t,e){let o=new k6(P),r=[];return e.forEach(a=>{var e=C0(this.userId,a.path),e=IDBKeyRange.lowerBound(e),e=n8(t).ee({range:e},(e,t,r)=>{var[n,i,s]=e,i=m0(i);n===this.userId&&a.path.isEqual(i)?o=o.add(s):r.done()});r.push(e)}),L.waitFor(r).next(()=>this.ws(t,o))}getAllMutationBatchesAffectingQuery(e,t){let a=t.path,o=a.length+1,r=C0(this.userId,a),n=IDBKeyRange.lowerBound(r),l=new k6(P);return n8(e).ee({range:n},(e,t,r)=>{var[n,i,s]=e,i=m0(i);n===this.userId&&a.isPrefixOf(i)?i.length===o&&(l=l.add(s)):r.done()}).next(()=>this.ws(e,l))}ws(e,t){let r=[],n=[];return t.forEach(t=>{n.push(r8(e).get(t).next(e=>{if(null===e)throw k(35274,{batchId:t});A(e.userId===this.userId,9748,"Unexpected user for mutation batch",{userId:e.userId,batchId:t}),r.push(l9(this.serializer,e))}))}),L.waitFor(n).next(()=>r)}removeMutationBatch(t,r){return X9(t.le,this.userId,r).next(e=>(t.addOnCommittedListener(()=>{this.bs(r.batchId)}),L.forEach(e,e=>this.referenceDelegate.markPotentiallyOrphaned(t,e))))}bs(e){delete this.fs[e]}performConsistencyCheck(r){return this.checkEmpty(r).next(e=>{if(!e)return L.resolve();let t=IDBKeyRange.lowerBound([this.userId]),n=[];return n8(r).ee({range:t},(t,e,r)=>{if(t[0]===this.userId){let e=m0(t[1]);n.push(e)}else r.done()}).next(()=>{A(0===n.length,56720,{vs:n.map(e=>e.canonicalString())})})})}containsKey(e,t){return t8(e,this.userId,t)}Ss(e){return i8(e).get(this.userId).next(e=>e||{userId:this.userId,lastAcknowledgedBatchId:u0,lastStreamToken:""})}}function t8(e,s,t){let r=C0(s,t.path),a=r[1],n=IDBKeyRange.lowerBound(r),o=!1;return n8(e).ee({range:n,X:!0},(e,t,r)=>{var[n,i,,]=e;n===s&&i===a&&(o=!0),r.done()}).next(()=>o)}function r8(e){return E6(e,b0)}function n8(e){return E6(e,A0)}function i8(e){return E6(e,w0)}class s8{constructor(e){this.Ds=e}next(){return this.Ds+=2,this.Ds}static xs(){return new s8(0)}static Cs(){return new s8(-1)}}class a8{constructor(e,t){this.referenceDelegate=e,this.serializer=t}allocateTargetId(r){return this.Fs(r).next(e=>{var t=new s8(e.highestTargetId);return e.highestTargetId=t.next(),this.Os(r,e).next(()=>e.highestTargetId)})}getLastRemoteSnapshotVersion(e){return this.Fs(e).next(e=>O.fromTimestamp(new O2(e.lastRemoteSnapshotVersion.seconds,e.lastRemoteSnapshotVersion.nanoseconds)))}getHighestSequenceNumber(e){return this.Fs(e).next(e=>e.highestListenSequenceNumber)}setTargetsMetadata(t,r,n){return this.Fs(t).next(e=>(e.highestListenSequenceNumber=r,n&&(e.lastRemoteSnapshotVersion=n.toTimestamp()),e.highestListenSequenceNumber<r&&(e.highestListenSequenceNumber=r),this.Os(t,e)))}addTargetData(t,r){return this.Ms(t,r).next(()=>this.Fs(t).next(e=>(e.targetCount+=1,this.Ns(r,e),this.Os(t,e))))}updateTargetData(e,t){return this.Ms(e,t)}removeTargetData(t,e){return this.removeMatchingKeysForTargetId(t,e.targetId).next(()=>o8(t).delete(e.targetId)).next(()=>this.Fs(t)).next(e=>(A(0<e.targetCount,8065),--e.targetCount,this.Os(t,e)))}removeTargets(n,i,s){let a=0,o=[];return o8(n).ee((e,t)=>{var r=u9(this.serializer,t);r.sequenceNumber<=i&&null===s.get(r.targetId)&&(a++,o.push(this.removeTargetData(n,r)))}).next(()=>L.waitFor(o)).next(()=>a)}forEachTarget(e,n){return o8(e).ee((e,t)=>{var r=u9(this.serializer,t);n(r)})}Fs(e){return l8(e).get(H0).next(e=>(A(null!==e,2888),e))}Os(e,t){return l8(e).put(H0,t)}Ms(e,t){return o8(e).put(h9(this.serializer,t))}Ns(e,t){let r=!1;return e.targetId>t.highestTargetId&&(t.highestTargetId=e.targetId,r=!0),t.highestListenSequenceNumber<e.sequenceNumber&&(t.highestListenSequenceNumber=e.sequenceNumber,r=!0),r}getTargetCount(e){return this.Fs(e).next(e=>e.targetCount)}getTargetData(e,i){var t=Qw(i),t=IDBKeyRange.bound([t,Number.NEGATIVE_INFINITY],[t,Number.POSITIVE_INFINITY]);let s=null;return o8(e).ee({range:t,index:U0},(e,t,r)=>{var n=u9(this.serializer,t);Jw(i,n.target)&&(s=n,r.done())}).next(()=>s)}addMatchingKeys(r,e,n){let i=[],s=u8(r);return e.forEach(e=>{var t=f0(e.path);i.push(s.put({targetId:n,path:t})),i.push(this.referenceDelegate.addReference(r,n,e))}),L.waitFor(i)}removeMatchingKeys(r,e,n){let i=u8(r);return L.forEach(e,e=>{var t=f0(e.path);return L.waitFor([i.delete([n,t]),this.referenceDelegate.removeReference(r,n,e)])})}removeMatchingKeysForTargetId(e,t){var r=u8(e),n=IDBKeyRange.bound([t],[t+1],!1,!0);return r.delete(n)}getMatchingKeysForTargetId(e,t){var r=IDBKeyRange.bound([t],[t+1],!1,!0),n=u8(e);let i=F();return n.ee({range:r,X:!0},(e,t,r)=>{var n=m0(e[1]),n=new D(n);i=i.add(n)}).next(()=>i)}containsKey(e,t){var r=f0(t.path),r=IDBKeyRange.bound([r],[_2(r)],!1,!0);let n=0;return u8(e).ee({index:j0,X:!0,range:r},([e],t,r)=>{0!==e&&(n++,r.done())}).next(()=>0<n)}dt(e,t){return o8(e).get(t).next(e=>e?u9(this.serializer,e):null)}}function o8(e){return E6(e,F0)}function l8(e){return E6(e,K0)}function u8(e){return E6(e,B0)}class h8{constructor(e,t){this.db=e,this.garbageCollector=M7(this,t)}lr(e){let r=this.Ls(e);return this.db.getTargetCache().getTargetCount(e).next(t=>r.next(e=>t+e))}Ls(e){let t=0;return this.Er(e,e=>{t++}).next(()=>t)}forEachTarget(e,t){return this.db.getTargetCache().forEachTarget(e,t)}Er(e,r){return this.Bs(e,(e,t)=>r(t))}addReference(e,t,r){return c8(e,r)}removeReference(e,t,r){return c8(e,r)}removeTargets(e,t,r){return this.db.getTargetCache().removeTargets(e,t,r)}markPotentiallyOrphaned(e,t){return c8(e,t)}Us(e,r){{var n=e,i=r;let t=!1;return i8(n).te(e=>t8(n,e,i).next(e=>(e&&(t=!0),L.resolve(!e)))).next(()=>t)}}removeOrphanedDocuments(r,n){let i=this.db.getRemoteDocumentCache().newChangeBuffer(),s=[],a=0;return this.Bs(r,(t,e)=>{if(e<=n){let e=this.Us(r,t).next(e=>{if(!e)return a++,i.getEntry(r,t).next(()=>(i.removeEntry(t,O.min()),u8(r).delete([0,f0(t.path)])))});s.push(e)}}).next(()=>L.waitFor(s)).next(()=>i.apply(r)).next(()=>a)}removeTarget(e,t){var r=t.withSequenceNumber(e.currentSequenceNumber);return this.db.getTargetCache().updateTargetData(e,r)}updateLimboDocument(e,t){return c8(e,t)}Bs(e,n){var t=u8(e);let i,s=l0.ce;return t.ee({index:j0},([e],{path:t,sequenceNumber:r})=>{0===e?(s!==l0.ce&&n(new D(m0(i)),s),s=r,i=t):s=l0.ce}).next(()=>{s!==l0.ce&&n(new D(m0(i)),s)})}getCacheSize(e){return this.db.getRemoteDocumentCache().getSize(e)}}function c8(e,t){return u8(e).put((e=e.currentSequenceNumber,{targetId:0,path:f0(t.path),sequenceNumber:e}))}function d8(e,t){let r=t;for(let t of e.stages)r=((t,r,n)=>{var i,s,a,o,l;if(r instanceof z4)return i=r,n.filter(e=>e.isFoundDocument()&&"/"+e.key.getCollectionPath().canonicalString()===i.Vr);if(r instanceof W4)return s=t,a=r,n.filter(e=>{var t=s3(U(a.condition).evaluate(s,e));return void 0!==t&&sv(t,rv)});if(r instanceof H4)return o=r,n.filter(e=>e.isFoundDocument()&&e.key.getCollectionPath().lastSegment()===o.collectionId);if(r instanceof K4)return n.filter(e=>e.isFoundDocument());if(r instanceof G4)return l=r,n.filter(e=>e.isFoundDocument()&&l.mr.has(e.key.path.toStringWithLeadingSlash()));if(r instanceof $4)return n.slice(0,r.limit);if(r instanceof Q4){var u=t,t=n;let e=r.orderings.map(e=>({ks:U(e.expr),direction:e.direction}));return[...t].sort((n,i)=>{for(var{ks:s,direction:a}of e){let e=s3(s.evaluate(u,n)),t=s3(s.evaluate(u,i)),r=ov(e??tv,t??tv);if(0!==r)return"ascending"===a?r:-r}return 0})}throw new Error("Unknown stage: "+r._name)})({serializer:e.serializer,serverTimestampBehavior:e.listenOptions?.serverTimestampBehavior},t,r);return r}function p8(e,t){return 0<d8(e,[t]).length}function f8(e,t){return(Gw(e)?p8:G_)(e,t)}function g8(a){let e=(e=>{for(let r=e.stages.length-1;0<=r;r--){var t=e.stages[r];if(t instanceof Q4)return t.orderings}throw new Error("Pipeline must contain at least one Sort stage")})(a);return(n,i)=>{for(var s of e){let e=s3(U(s.expr).evaluate({serializer:a.serializer},n)),t=s3(U(s.expr).evaluate({serializer:a.serializer},i)),r=ov(e||tv,t||tv);if(0!==r)return"ascending"===s.direction?r:-r}return 0}}function m8(e){for(let r=e.stages.length-1;0<=r;r--){var t=e.stages[r];if(t instanceof $4)return{limit:t.limit}}}class v8{constructor(){this.changes=new J_(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,C_.newInvalidDocument(e).setReadTime(t))}getEntry(e,t){this.assertNotApplied();var r=this.changes.get(t);return void 0!==r?L.resolve(r):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 _8{constructor(e){this.serializer=e}setIndexManager(e){this.indexManager=e}addEntry(e,t,r){return T8(e).put(r)}removeEntry(e,t,r){return T8(e).delete((e=r,[(n=t.path.toArray()).slice(0,n.length-2),n[n.length-2],s9(e),n[n.length-1]]));var n}updateMetadata(t,r){return this.getMetadata(t).next(e=>(e.byteSize+=r,this.qs(t,e)))}getEntry(e,r){let n=C_.newInvalidDocument(r);return T8(e).ee({index:P0,range:IDBKeyRange.only(E8(r))},(e,t)=>{n=this.$s(r,t)}).next(()=>n)}Ks(e,r){let n={size:0,document:C_.newInvalidDocument(r)};return T8(e).ee({index:P0,range:IDBKeyRange.only(E8(r))},(e,t)=>{n={document:this.$s(r,t),size:Z9(t)}}).next(()=>n)}getEntries(e,t){let n=X_;return this.Ws(e,t,(e,t)=>{var r=this.$s(e,t);n=n.insert(e,r)}).next(()=>n)}getAllEntries(e){let n=X_;return T8(e).ee((e,t)=>{var r=this.$s(D.fromSegments(t.prefixPath.concat(t.collectionGroup,t.documentId)),t);n=n.insert(r.key,r)}).next(()=>n)}Qs(e,t){let n=X_,i=new I6(D.comparator);return this.Ws(e,t,(e,t)=>{var r=this.$s(e,t);n=n.insert(e,r),i=i.insert(e,Z9(t))}).next(()=>({documents:n,Gs:i}))}Ws(e,t,i){if(t.isEmpty())return L.resolve();let r=new k6(C8),n=(t.forEach(e=>r=r.add(e)),IDBKeyRange.bound(E8(r.first()),E8(r.last()))),s=r.getIterator(),a=s.getNext();return T8(e).ee({index:P0,range:n},(e,t,r)=>{for(var n=D.fromSegments([...t.prefixPath,t.collectionGroup,t.documentId]);a&&C8(a,n)<0;)i(a,null),a=s.getNext();a&&a.isEqual(n)&&(i(a,t),a=s.hasNext()?s.getNext():null),a?r.j(E8(a)):r.done()}).next(()=>{for(;a;)i(a,null),a=s.hasNext()?s.getNext():null})}getDocumentsMatchingQuery(e,n,t,i,s){var r=Gw(n)?x.fromString(t3(n)):n.path,a=[r.popLast().toArray(),r.lastSegment(),s9(t.readTime),t.documentKey.path.isEmpty()?"":t.documentKey.path.lastSegment()],r=[r.popLast().toArray(),r.lastSegment(),[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],""];return T8(e).H(IDBKeyRange.bound(a,r,!0)).next(e=>{s?.incrementDocumentReadCount(e.length);let t=X_;for(let r of e){let e=this.$s(D.fromSegments(r.prefixPath.concat(r.collectionGroup,r.documentId)),r);e.isFoundDocument()&&(f8(n,e)||i.has(e.key))&&(t=t.insert(e.key,e))}return t})}getAllFromCollectionGroup(e,t,r,i){let s=X_;var n=I8(t,r),a=I8(t,z2.max());return T8(e).ee({index:D0,range:IDBKeyRange.bound(n,a,!0)},(e,t,r)=>{var n=this.$s(D.fromSegments(t.prefixPath.concat(t.collectionGroup,t.documentId)),t);(s=s.insert(n.key,n)).size===i&&r.done()}).next(()=>s)}newChangeBuffer(e){return new w8(this,!!e&&e.trackRemovals)}getSize(e){return this.getMetadata(e).next(e=>e.byteSize)}getMetadata(e){return b8(e).get(M0).next(e=>(A(!!e,20021),e))}qs(e,t){return b8(e).put(M0,t)}$s(e,t){if(t){let e=((e,r)=>{let n;if(r.document)n=jy(e.zr,r.document,!!r.hasCommittedMutations);else if(r.noDocument){let e=D.fromSegments(r.noDocument.path),t=o9(r.noDocument.readTime);n=C_.newNoDocument(e,t),r.hasCommittedMutations&&n.setHasCommittedMutations()}else{if(!r.unknownDocument)return k(56709);{let e=D.fromSegments(r.unknownDocument.path),t=o9(r.unknownDocument.version);n=C_.newUnknownDocument(e,t)}}return r.readTime&&n.setReadTime((e=r.readTime,t=new O2(e[0],e[1]),O.fromTimestamp(t))),n;var t})(this.serializer,t);if(!e.isNoDocument()||!e.version.isEqual(O.min()))return e}return C_.newInvalidDocument(e)}}function y8(e){return new _8(e)}class w8 extends v8{constructor(e,t){super(),this.zs=e,this.trackRemovals=t,this.js=new J_(e=>e.toString(),(e,t)=>e.isEqual(t))}applyChanges(s){let a=[],o=0,l=new k6((e,t)=>P(e.canonicalString(),t.canonicalString()));return this.changes.forEach((t,r)=>{var e=this.js.get(t);if(a.push(this.zs.removeEntry(s,t,e.readTime)),r.isValidDocument()){var n=i9(this.zs.serializer,r),i=(l=l.add(t.path.popLast()),Z9(n));o+=i-e.size,a.push(this.zs.addEntry(s,t,n))}else if(o-=e.size,this.trackRemovals){let e=i9(this.zs.serializer,r.convertToNoDocument(O.min()));a.push(this.zs.addEntry(s,t,e))}}),l.forEach(e=>{a.push(this.zs.indexManager.addToCollectionParentIndex(s,e))}),a.push(this.zs.updateMetadata(s,o)),L.waitFor(a)}getFromCache(e,t){return this.zs.Ks(e,t).next(e=>(this.js.set(t,{size:e.size,readTime:e.document.readTime}),e.document))}getAllFromCache(e,t){return this.zs.Qs(e,t).next(({documents:r,Gs:e})=>(e.forEach((e,t)=>{this.js.set(e,{size:t,readTime:r.get(e).readTime})}),r))}}function b8(e){return E6(e,L0)}function T8(e){return E6(e,N0)}function E8(e){var t=e.path.toArray();return[t.slice(0,t.length-2),t[t.length-2],t[t.length-1]]}function I8(e,t){var r=t.documentKey.path.toArray();return[e,s9(t.readTime),r.slice(0,r.length-2),0<r.length?r[r.length-1]:""]}function C8(e,t){var r=e.path.toArray(),n=t.path.toArray();let i=0;for(let s=0;s<r.length-2&&s<n.length-2;++s)if(i=P(r[s],n[s]))return i;return(i=P(r.length,n.length))||(i=P(r[r.length-2],n[n.length-2]))||P(r[r.length-1],n[n.length-1])}class S8{constructor(e,t){this.overlayedDocument=e,this.mutatedFields=t}}class k8{constructor(e,t,r,n){this.remoteDocumentCache=e,this.mutationQueue=t,this.documentOverlayCache=r,this.indexManager=n}getDocument(t,r){let n=null;return this.documentOverlayCache.getOverlay(t,r).next(e=>(n=e,this.remoteDocumentCache.getEntry(t,r))).next(e=>(null!==n&&Qv(n.mutation,e,R6.empty(),O2.now()),e))}getDocuments(t,e){return this.remoteDocumentCache.getEntries(t,e).next(e=>this.getLocalViewOfDocuments(t,e,F()).next(()=>e))}getLocalViewOfDocuments(e,t,r=F()){let n=ry();return this.populateOverlays(e,n,t).next(()=>this.computeViews(e,t,n,r).next(e=>{let r=ey();return e.forEach((e,t)=>{r=r.insert(e,t.overlayedDocument)}),r}))}getOverlayedDocuments(e,t){let r=ry();return this.populateOverlays(e,r,t).next(()=>this.computeViews(e,t,r,F()))}populateOverlays(e,r,t){let n=[];return t.forEach(e=>{r.has(e)||n.push(e)}),this.documentOverlayCache.getOverlays(e,n).next(e=>{e.forEach((e,t)=>{r.set(e,t)})})}computeViews(e,t,n,i){let s=X_,a=ry(),r=ry();return t.forEach((e,t)=>{var r=n.get(t.key);i.has(t.key)&&(void 0===r||r.mutation instanceof Zv)?s=s.insert(t.key,t):void 0!==r?(a.set(t.key,r.mutation.getFieldMask()),Qv(r.mutation,t,r.mutation.getFieldMask(),O2.now())):a.set(t.key,R6.empty())}),this.recalculateAndSaveOverlays(e,s).next(e=>(e.forEach((e,t)=>a.set(e,t)),t.forEach((e,t)=>r.set(e,new S8(t,a.get(e)??null))),r))}recalculateAndSaveOverlays(a,o){let l=ry(),u=new I6((e,t)=>e-t),h=F();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(a,o).next(e=>{for(let n of e)n.keys().forEach(e=>{var t,r=o.get(e);null!==r&&(t=l.get(e)||R6.empty(),t=n.applyToLocalView(r,t),l.set(e,t),r=(u.get(n.batchId)||F()).add(e),u=u.insert(n.batchId,r))})}).next(()=>{for(var i=[],s=u.getReverseIterator();s.hasNext();){let e=s.getNext(),t=e.key,r=e.value,n=ry();r.forEach(e=>{var t;h.has(e)||(null!==(t=Yv(o.get(e),l.get(e)))&&n.set(e,t),h=h.add(e))}),i.push(this.documentOverlayCache.saveOverlays(a,t,n))}return L.waitFor(i)}).next(()=>l)}recalculateAndSaveOverlaysForDocumentKeys(t,e){return this.remoteDocumentCache.getEntries(t,e).next(e=>this.recalculateAndSaveOverlays(t,e))}getDocumentsMatchingQuery(e,t,r,n){return Gw(t)?this.getDocumentsMatchingPipeline(e,t,r,n):(i=t,D.isDocumentKey(i.path)&&null===i.collectionGroup&&0===i.filters.length?this.getDocumentsMatchingDocumentQuery(e,t.path):V_(t)?this.getDocumentsMatchingCollectionGroupQuery(e,t,r,n):this.getDocumentsMatchingCollectionQuery(e,t,r,n));var i}getNextDocuments(s,t,a,o){return this.remoteDocumentCache.getAllFromCollectionGroup(s,t,a,o).next(r=>{var e=0<o-r.size?this.documentOverlayCache.getOverlaysForCollectionGroup(s,t,a.largestBatchId,o-r.size):L.resolve(ry());let n=L2,i=r;return e.next(e=>L.forEach(e,(t,e)=>(n<e.largestBatchId&&(n=e.largestBatchId),r.get(t)?L.resolve():this.remoteDocumentCache.getEntry(s,t).next(e=>{i=i.insert(t,e)}))).next(()=>this.populateOverlays(s,e,r)).next(()=>this.computeViews(s,i,e,F())).next(e=>({batchId:n,changes:ty(e)})))})}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new D(t)).next(e=>{let t=ey();return t=e.isFoundDocument()?t.insert(e.key,e):t})}getDocumentsMatchingCollectionGroupQuery(n,i,s,a){let o=i.collectionGroup,l=ey();return this.indexManager.getCollectionParents(n,o).next(e=>L.forEach(e,e=>{t=i,e=e.child(o);var t,r=new L_(e,null,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,t.startAt,t.endAt);return this.getDocumentsMatchingCollectionQuery(n,r,s,a).next(e=>{e.forEach((e,t)=>{l=l.insert(e,t)})})}).next(()=>l))}getDocumentsMatchingCollectionQuery(t,r,n,i){let s;return this.documentOverlayCache.getOverlaysForCollection(t,r.path,n.largestBatchId).next(e=>(s=e,this.remoteDocumentCache.getDocumentsMatchingQuery(t,r,n,s,i))).next(e=>this.retrieveMatchingLocalDocuments(s,e,e=>G_(r,e)))}getDocumentsMatchingPipeline(a,o,l,u){if("collection_group"===e3(o)){let i=r3(o),s=ey();return this.indexManager.getCollectionParents(a,i).next(e=>L.forEach(e,e=>{t=o,r=e.child(i),n=t.stages.map(e=>e instanceof H4?new z4(r.canonicalString(),{}):e);var t,r,n=new Z4(t.serializer,n);return this.getDocumentsMatchingPipeline(a,n,l,u).next(e=>{e.forEach((e,t)=>{s=s.insert(e,t)})})}).next(()=>s))}{let r;return this.getOverlaysForPipeline(a,o,l.largestBatchId).next(e=>{switch(r=e,e3(o)){case"collection":return this.remoteDocumentCache.getDocumentsMatchingQuery(a,o,l,r,u);case"documents":let e=F();for(let t of i3(o))e=e.add(D.fromPath(t));return this.remoteDocumentCache.getEntries(a,e);case"database":return this.remoteDocumentCache.getAllEntries(a);default:throw new R("invalid-argument","Invalid pipeline source to execute offline: "+Hw(o))}}).next(e=>this.retrieveMatchingLocalDocuments(r,e,e=>p8(o,e)))}}retrieveMatchingLocalDocuments(n,i,s){n.forEach((e,t)=>{var r=t.getKey();null===i.get(r)&&(i=i.insert(r,C_.newInvalidDocument(r)))});let a=ey();return i.forEach((e,t)=>{var r=n.get(e);void 0!==r&&Qv(r.mutation,t,R6.empty(),O2.now()),s(t)&&(a=a.insert(e,t))}),a}getOverlaysForPipeline(e,t,r){switch(e3(t)){case"collection":return this.documentOverlayCache.getOverlaysForCollection(e,x.fromString(t3(t)),r);case"collection_group":throw new R("invalid-argument","Unexpected collection group pipeline: "+Hw(t));case"documents":return this.documentOverlayCache.getOverlays(e,i3(t).map(e=>D.fromPath(e)));case"database":return this.documentOverlayCache.getAllOverlays(e,r);default:throw new R("invalid-argument","Failed to get overlays for pipeline: "+Hw(t))}}}class A8{constructor(e){this.serializer=e,this.Hs=new Map,this.Js=new Map}getBundleMetadata(e,t){return L.resolve(this.Hs.get(t))}saveBundleMetadata(e,t){return this.Hs.set(t.id,{id:t.id,version:t.version,createTime:Py(t.createTime)}),L.resolve()}getNamedQuery(e,t){return L.resolve(this.Js.get(t))}saveNamedQuery(e,t){return this.Js.set(t.name,{name:(t=t).name,query:c9(t.bundledQuery),readTime:Py(t.readTime)}),L.resolve()}}class N8{constructor(){this.overlays=new I6(D.comparator),this.Ys=new Map}getOverlay(e,t){return L.resolve(this.overlays.get(t))}getOverlays(e,t){let r=ry();return L.forEach(t,t=>this.getOverlay(e,t).next(e=>{null!==e&&r.set(t,e)})).next(()=>r)}getAllOverlays(e,r){let n=ry();return this.overlays.forEach((e,t)=>{t.largestBatchId>r&&n.set(e,t)}),L.resolve(n)}saveOverlays(r,n,e){return e.forEach((e,t)=>{this.Hr(r,n,t)}),L.resolve()}removeOverlaysForBatchId(e,t,r){var n=this.Ys.get(r);return void 0!==n&&(n.forEach(e=>this.overlays=this.overlays.remove(e)),this.Ys.delete(r)),L.resolve()}getOverlaysForCollection(e,r,n){let i=ry(),s=r.length+1,t=new D(r.child("")),a=this.overlays.getIteratorFrom(t);for(;a.hasNext();){let e=a.getNext().value,t=e.getKey();if(!r.isPrefixOf(t.path))break;t.path.length===s&&e.largestBatchId>n&&i.set(e.getKey(),e)}return L.resolve(i)}getOverlaysForCollectionGroup(e,r,n,t){let i=new I6((e,t)=>e-t);for(var s=this.overlays.getIterator();s.hasNext();){let t=s.getNext().value;if(t.getKey().getCollectionGroup()===r&&t.largestBatchId>n){let e=i.get(t.largestBatchId);null===e&&(e=ry(),i=i.insert(t.largestBatchId,e)),e.set(t.getKey(),t)}}let a=ry(),o=i.getIterator();for(;o.hasNext()&&(o.getNext().value.forEach((e,t)=>a.set(e,t)),!(a.size()>=t)););return L.resolve(a)}Hr(e,t,r){var n=this.overlays.get(r.key);if(null!==n){let e=this.Ys.get(n.largestBatchId).delete(r.key);this.Ys.set(n.largestBatchId,e)}this.overlays=this.overlays.insert(r.key,new t9(t,r));let i=this.Ys.get(t);void 0===i&&(i=F(),this.Ys.set(t,i)),this.Ys.set(t,i.add(r.key))}}class R8{constructor(){this.sessionToken=L6.EMPTY_BYTE_STRING}getSessionToken(e){return L.resolve(this.sessionToken)}setSessionToken(e,t){return this.sessionToken=t,L.resolve()}}class P8{constructor(){this.Zs=new k6(x8.Xs),this.e_=new k6(x8.t_)}isEmpty(){return this.Zs.isEmpty()}addReference(e,t){var r=new x8(e,t);this.Zs=this.Zs.add(r),this.e_=this.e_.add(r)}n_(e,t){e.forEach(e=>this.addReference(e,t))}removeReference(e,t){this.r_(new x8(e,t))}i_(e,t){e.forEach(e=>this.removeReference(e,t))}s_(e){let t=new D(new x([])),r=new x8(t,e),n=new x8(t,e+1),i=[];return this.e_.forEachInRange([r,n],e=>{this.r_(e),i.push(e.key)}),i}__(){this.Zs.forEach(e=>this.r_(e))}r_(e){this.Zs=this.Zs.delete(e),this.e_=this.e_.delete(e)}o_(e){var t=new D(new x([])),r=new x8(t,e),t=new x8(t,e+1);let n=F();return this.e_.forEachInRange([r,t],e=>{n=n.add(e.key)}),n}containsKey(e){var t=new x8(e,0),t=this.Zs.firstAfterOrEqual(t);return null!==t&&e.isEqual(t.key)}}class x8{constructor(e,t){this.key=e,this.a_=t}static Xs(e,t){return D.comparator(e.key,t.key)||P(e.a_,t.a_)}static t_(e,t){return P(e.a_,t.a_)||D.comparator(e.key,t.key)}}class D8{constructor(e,t){this.indexManager=e,this.referenceDelegate=t,this.mutationQueue=[],this.gs=1,this.u_=new k6(x8.Xs)}checkEmpty(e){return L.resolve(0===this.mutationQueue.length)}addMutationBatch(e,t,r,n){var i=this.gs,s=(this.gs++,0<this.mutationQueue.length&&this.mutationQueue[this.mutationQueue.length-1],new Zw(i,t,r,n));this.mutationQueue.push(s);for(let t of n)this.u_=this.u_.add(new x8(t.key,i)),this.indexManager.addToCollectionParentIndex(e,t.key.path.popLast());return L.resolve(s)}lookupMutationBatch(e,t){return L.resolve(this.c_(t))}getNextMutationBatchAfterBatchId(e,t){var r=this.l_(t+1),r=r<0?0:r;return L.resolve(this.mutationQueue.length>r?this.mutationQueue[r]:null)}getHighestUnacknowledgedBatchId(){return L.resolve(0===this.mutationQueue.length?u0:this.gs-1)}getAllMutationBatches(e){return L.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){let r=new x8(t,0),n=new x8(t,Number.POSITIVE_INFINITY),i=[];return this.u_.forEachInRange([r,n],e=>{var t=this.c_(e.a_);i.push(t)}),L.resolve(i)}getAllMutationBatchesAffectingDocumentKeys(e,t){let n=new k6(P);return t.forEach(e=>{var t=new x8(e,0),r=new x8(e,Number.POSITIVE_INFINITY);this.u_.forEachInRange([t,r],e=>{n=n.add(e.a_)})}),L.resolve(this.E_(n))}getAllMutationBatchesAffectingQuery(e,t){let r=t.path,n=r.length+1,i=r;D.isDocumentKey(i)||(i=i.child(""));var s=new x8(new D(i),0);let a=new k6(P);return this.u_.forEachWhile(e=>{var t=e.key.path;return!!r.isPrefixOf(t)&&(t.length===n&&(a=a.add(e.a_)),!0)},s),L.resolve(this.E_(a))}E_(e){let r=[];return e.forEach(e=>{var t=this.c_(e);null!==t&&r.push(t)}),r}removeMutationBatch(r,n){A(0===this.h_(n.batchId,"removed"),55003),this.mutationQueue.shift();let i=this.u_;return L.forEach(n.mutations,e=>{var t=new x8(e.key,n.batchId);return i=i.delete(t),this.referenceDelegate.markPotentiallyOrphaned(r,e.key)}).next(()=>{this.u_=i})}bs(e){}containsKey(e,t){var r=new x8(t,0),r=this.u_.firstAfterOrEqual(r);return L.resolve(t.isEqual(r&&r.key))}performConsistencyCheck(e){return this.mutationQueue.length,L.resolve()}h_(e,t){return this.l_(e)}l_(e){return 0===this.mutationQueue.length?0:e-this.mutationQueue[0].batchId}c_(e){var t=this.l_(e);return t<0||t>=this.mutationQueue.length?null:this.mutationQueue[t]}}class O8{constructor(e){this.T_=e,this.docs=new I6(D.comparator),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,t){var r=t.key,n=this.docs.get(r),n=n?n.size:0,i=this.T_(t);return this.docs=this.docs.insert(r,{document:t.mutableCopy(),size:i}),this.size+=i-n,this.indexManager.addToCollectionParentIndex(e,r.path.popLast())}removeEntry(e){var t=this.docs.get(e);t&&(this.docs=this.docs.remove(e),this.size-=t.size)}getEntry(e,t){var r=this.docs.get(t);return L.resolve(r?r.document.mutableCopy():C_.newInvalidDocument(t))}getEntries(e,t){let r=X_;return t.forEach(e=>{var t=this.docs.get(e);r=r.insert(e,t?t.document.mutableCopy():C_.newInvalidDocument(e))}),L.resolve(r)}getAllEntries(e){let r=X_;return this.docs.forEach((e,t)=>{r=r.insert(e,t.document)}),L.resolve(r)}getDocumentsMatchingQuery(e,t,r,n){let i,s,a=(s=Gw(t)?(i=x.fromString(t3(t)),e=>p8(t,e)):(i=t.path,e=>G_(t,e)),X_);for(var o=new D(i.child("__id-9223372036854775808__")),l=this.docs.getIteratorFrom(o);l.hasNext();){let{key:e,value:{document:t}}=l.getNext();if(!i.isPrefixOf(e.path))break;e.path.length>i.length+1||H2(j2(t),r)<=0||(n.has(t.key)||s(t))&&(a=a.insert(t.key,t.mutableCopy()))}return L.resolve(a)}getAllFromCollectionGroup(e,t,r,n){k(9500)}P_(e,t){return L.forEach(this.docs,e=>t(e))}newChangeBuffer(e){return new L8(this)}getSize(e){return L.resolve(this.size)}}class L8 extends v8{constructor(e){super(),this.zs=e}applyChanges(r){let n=[];return this.changes.forEach((e,t)=>{t.isValidDocument()?n.push(this.zs.addEntry(r,t)):this.zs.removeEntry(e)}),L.waitFor(n)}getFromCache(e,t){return this.zs.getEntry(e,t)}getAllFromCache(e,t){return this.zs.getEntries(e,t)}}class M8{constructor(e){this.persistence=e,this.R_=new J_(e=>Qw(e),Jw),this.lastRemoteSnapshotVersion=O.min(),this.highestTargetId=0,this.I_=0,this.A_=new P8,this.targetCount=0,this.V_=s8.xs()}forEachTarget(e,r){return this.R_.forEach((e,t)=>r(t)),L.resolve()}getLastRemoteSnapshotVersion(e){return L.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return L.resolve(this.I_)}allocateTargetId(e){return this.highestTargetId=this.V_.next(),L.resolve(this.highestTargetId)}setTargetsMetadata(e,t,r){return r&&(this.lastRemoteSnapshotVersion=r),t>this.I_&&(this.I_=t),L.resolve()}Ms(e){this.R_.set(e.target,e);var t=e.targetId;t>this.highestTargetId&&(this.V_=new s8(t),this.highestTargetId=t),e.sequenceNumber>this.I_&&(this.I_=e.sequenceNumber)}addTargetData(e,t){return this.Ms(t),this.targetCount+=1,L.resolve()}updateTargetData(e,t){return this.Ms(t),L.resolve()}removeTargetData(e,t){return this.R_.delete(t.target),this.A_.s_(t.targetId),--this.targetCount,L.resolve()}removeTargets(r,n,i){let s=0,a=[];return this.R_.forEach((e,t)=>{t.sequenceNumber<=n&&null===i.get(t.targetId)&&(this.R_.delete(e),a.push(this.removeMatchingKeysForTargetId(r,t.targetId)),s++)}),L.waitFor(a).next(()=>s)}getTargetCount(e){return L.resolve(this.targetCount)}getTargetData(e,t){var r=this.R_.get(t)||null;return L.resolve(r)}addMatchingKeys(e,t,r){return this.A_.n_(t,r),L.resolve()}removeMatchingKeys(t,e,r){this.A_.i_(e,r);let n=this.persistence.referenceDelegate,i=[];return n&&e.forEach(e=>{i.push(n.markPotentiallyOrphaned(t,e))}),L.waitFor(i)}removeMatchingKeysForTargetId(e,t){return this.A_.s_(t),L.resolve()}getMatchingKeysForTargetId(e,t){var r=this.A_.o_(t);return L.resolve(r)}containsKey(e,t){return L.resolve(this.A_.containsKey(t))}}class F8{constructor(e,t){this.d_={},this.overlays={},this.f_=new l0(0),this.m_=!1,this.m_=!0,this.p_=new R8,this.referenceDelegate=e(this),this.g_=new M8(this),this.indexManager=new j9,this.remoteDocumentCache=(e=e=>this.referenceDelegate.y_(e),new O8(e)),this.serializer=new n9(t),this.w_=new A8(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.m_=!1,Promise.resolve()}get started(){return this.m_}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let t=this.overlays[e.toKey()];return t||(t=new N8,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let r=this.d_[e.toKey()];return r||(r=new D8(t,this.referenceDelegate),this.d_[e.toKey()]=r),r}getGlobalsCache(){return this.p_}getTargetCache(){return this.g_}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.w_}runTransaction(e,t,r){S("MemoryPersistence","Starting transaction:",e);let n=new U8(this.f_.next());return this.referenceDelegate.b_(),r(n).next(e=>this.referenceDelegate.v_(n).next(()=>e)).toPromise().then(e=>(n.raiseOnCommittedEvent(),e))}S_(t,r){return L.or(Object.values(this.d_).map(e=>()=>e.containsKey(t,r)))}}class U8 extends G2{constructor(e){super(),this.currentSequenceNumber=e}}class V8{constructor(e){this.persistence=e,this.D_=new P8,this.x_=null}static C_(e){return new V8(e)}get F_(){if(this.x_)return this.x_;throw k(60996)}addReference(e,t,r){return this.D_.addReference(r,t),this.F_.delete(r.toString()),L.resolve()}removeReference(e,t,r){return this.D_.removeReference(r,t),this.F_.add(r.toString()),L.resolve()}markPotentiallyOrphaned(e,t){return this.F_.add(t.toString()),L.resolve()}removeTarget(e,t){this.D_.s_(t.targetId).forEach(e=>this.F_.add(e.toString()));let r=this.persistence.getTargetCache();return r.getMatchingKeysForTargetId(e,t.targetId).next(e=>{e.forEach(e=>this.F_.add(e.toString()))}).next(()=>r.removeTargetData(e,t))}b_(){this.x_=new Set}v_(r){let n=this.persistence.getRemoteDocumentCache().newChangeBuffer();return L.forEach(this.F_,e=>{let t=D.fromPath(e);return this.O_(r,t).next(e=>{e||n.removeEntry(t,O.min())})}).next(()=>(this.x_=null,n.apply(r)))}updateLimboDocument(e,t){return this.O_(e,t).next(e=>{e?this.F_.delete(t.toString()):this.F_.add(t.toString())})}y_(e){return 0}O_(e,t){return L.or([()=>L.resolve(this.D_.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.S_(e,t)])}}class B8{constructor(e,t){this.persistence=e,this.M_=new J_(e=>f0(e.path),(e,t)=>e.isEqual(t)),this.garbageCollector=M7(this,t)}static C_(e,t){return new B8(e,t)}b_(){}v_(e){return L.resolve()}forEachTarget(e,t){return this.persistence.getTargetCache().forEachTarget(e,t)}lr(e){let r=this.Ls(e);return this.persistence.getTargetCache().getTargetCount(e).next(t=>r.next(e=>t+e))}Ls(e){let t=0;return this.Er(e,e=>{t++}).next(()=>t)}Er(r,n){return L.forEach(this.M_,(e,t)=>this.Us(r,e,t).next(e=>e?L.resolve():n(t)))}removeTargets(e,t,r){return this.persistence.getTargetCache().removeTargets(e,t,r)}removeOrphanedDocuments(e,r){let n=0,t=this.persistence.getRemoteDocumentCache(),i=t.newChangeBuffer();return t.P_(e,t=>this.Us(e,t,r).next(e=>{e||(n++,i.removeEntry(t,O.min()))})).next(()=>i.apply(e)).next(()=>n)}markPotentiallyOrphaned(e,t){return this.M_.set(t,e.currentSequenceNumber),L.resolve()}removeTarget(e,t){var r=t.withSequenceNumber(e.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(e,r)}addReference(e,t,r){return this.M_.set(r,e.currentSequenceNumber),L.resolve()}removeReference(e,t,r){return this.M_.set(r,e.currentSequenceNumber),L.resolve()}updateLimboDocument(e,t){return this.M_.set(t,e.currentSequenceNumber),L.resolve()}y_(e){let t=e.key.toString().length;return e.isFoundDocument()&&(t+=function n(e){switch(iv(e)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:var t=K6(e);return t?16+n(t):16;case 5:return 2*e.stringValue.length;case 6:return V6(e.bytesValue).approximateByteSize();case 7:return e.referenceValue.length;case 9:return(e.arrayValue.values||[]).reduce((e,t)=>e+n(t),0);case 10:case 11:{var i=e.mapValue;let r=0;return x6(i.fields,(e,t)=>{r+=e.length+n(t)}),r}default:throw k(13486,{value:e})}}(e.data.value)),t}Us(e,t,r){return L.or([()=>this.persistence.S_(e,t),()=>this.persistence.getTargetCache().containsKey(e,t),()=>{var e=this.M_.get(t);return L.resolve(void 0!==e&&r<e)}])}getCacheSize(e){return this.persistence.getRemoteDocumentCache().getSize(e)}}class q8{constructor(e){this.serializer=e}U(t,e,r,n){let s=new Y2("createOrUpgrade",e);var i;r<1&&1<=n&&(t.createObjectStore(_0),(i=t).createObjectStore(w0,{keyPath:"userId"}),i.createObjectStore(b0,{keyPath:T0,autoIncrement:!0}).createIndex(E0,I0,{unique:!0}),i.createObjectStore(A0),j8(t),t.createObjectStore(v0));let a=L.resolve();return r<3&&3<=n&&(0!==r&&((i=t).deleteObjectStore(B0),i.deleteObjectStore(F0),i.deleteObjectStore(K0),j8(t)),a=a.next(()=>{return e=s,t=e.store(K0),r={highestTargetId:0,highestListenSequenceNumber:0,lastRemoteSnapshotVersion:O.min().toTimestamp(),targetCount:0},t.put(H0,r);var e,t,r})),r<4&&4<=n&&(a=(a=0!==r?a.next(()=>{return n=t,(i=s).store(b0).H().next(e=>{n.deleteObjectStore(b0),n.createObjectStore(b0,{keyPath:T0,autoIncrement:!0}).createIndex(E0,I0,{unique:!0});let t=i.store(b0),r=e.map(e=>t.put(e));return L.waitFor(r)});var n,i}):a).next(()=>{t.createObjectStore($0,{keyPath:"clientId"})})),r<5&&5<=n&&(a=a.next(()=>this.N_(s))),r<6&&6<=n&&(a=a.next(()=>(t.createObjectStore(L0),this.L_(s)))),r<7&&7<=n&&(a=a.next(()=>this.B_(s))),r<8&&8<=n&&(a=a.next(()=>this.U_(t,s))),r<9&&9<=n&&(a=a.next(()=>{var e;(e=t).objectStoreNames.contains("remoteDocumentChanges")&&e.deleteObjectStore("remoteDocumentChanges")})),r<10&&10<=n&&(a=a.next(()=>this.k_(s))),r<11&&11<=n&&(a=a.next(()=>{t.createObjectStore(Y0,{keyPath:"bundleId"}),t.createObjectStore(Q0,{keyPath:"name"})})),r<12&&12<=n&&(a=a.next(()=>{var e;(e=t.createObjectStore(o6,{keyPath:l6})).createIndex(u6,h6,{unique:!1}),e.createIndex(c6,d6,{unique:!1})})),r<13&&13<=n&&(a=a.next(()=>{var e;(e=t.createObjectStore(N0,{keyPath:R0})).createIndex(P0,x0),e.createIndex(D0,O0)}).next(()=>this.q_(t,s)).next(()=>t.deleteObjectStore(v0))),r<14&&14<=n&&(a=a.next(()=>this.K_(t,s))),r<15&&15<=n&&(a=a.next(()=>{var e;(e=t).createObjectStore(J0,{keyPath:"indexId",autoIncrement:!0}).createIndex(X0,"collectionGroup",{unique:!1}),e.createObjectStore(Z0,{keyPath:e6}).createIndex(t6,r6,{unique:!1}),e.createObjectStore(n6,{keyPath:i6}).createIndex(s6,a6,{unique:!1})})),r<16&&16<=n&&(a=a.next(()=>{e.objectStore(Z0).clear()}).next(()=>{e.objectStore(n6).clear()})),r<17&&17<=n&&(a=a.next(()=>{t.createObjectStore(p6,{keyPath:"name"})})),a=r<18&&18<=n&&he()?a.next(()=>{e.objectStore(Z0).clear()}).next(()=>{e.objectStore(n6).clear()}):a}L_(t){let r=0;return t.store(v0).ee((e,t)=>{r+=Z9(t)}).next(()=>{var e={byteSize:r};return t.store(L0).put(M0,e)})}N_(n){let e=n.store(w0),t=n.store(b0);return e.H().next(e=>L.forEach(e,r=>{var e=IDBKeyRange.bound([r.userId,u0],[r.userId,r.lastAcknowledgedBatchId]);return t.H(E0,e).next(e=>L.forEach(e,e=>{A(e.userId===r.userId,18650,"Cannot process batch from unexpected user",{batchId:e.batchId});var t=l9(this.serializer,e);return X9(n,r.userId,t).next(()=>{})}))}))}B_(e){let a=e.store(B0),t=e.store(v0);return e.store(K0).get(H0).next(i=>{let s=[];return t.ee((e,t)=>{let r=new x(e),n=[0,f0(r)];s.push(a.get(n).next(e=>e?L.resolve():(e=r,a.put({targetId:0,path:f0(e),sequenceNumber:i.highestListenSequenceNumber}))))}).next(()=>L.waitFor(s))})}U_(e,t){e.createObjectStore(G0,{keyPath:W0});let n=t.store(G0),i=new z9,s=r=>{if(i.add(r)){let e=r.lastSegment(),t=r.popLast();return n.put({collectionId:e,parent:f0(t)})}};return t.store(v0).ee({X:!0},(e,t)=>{var r=new x(e);return s(r.popLast())}).next(()=>t.store(A0).ee({X:!0},([,e],t)=>{var r=m0(e);return s(r.popLast())}))}k_(e){let n=e.store(F0);return n.ee((e,t)=>{var r=u9(this.serializer,t),r=h9(this.serializer,r);return n.put(r)})}q_(e,s){let t=s.store(v0),a=[];return t.ee((e,t)=>{var r,n=s.store(N0),i=((r=t).document?new D(x.fromString(r.document.name).popFirst(5)):r.noDocument?D.fromSegments(r.noDocument.path):r.unknownDocument?D.fromSegments(r.unknownDocument.path):k(36783)).path.toArray(),i={prefixPath:i.slice(0,i.length-2),collectionGroup:i[i.length-2],documentId:i[i.length-1],readTime:t.readTime||[0,0],unknownDocument:t.unknownDocument,noDocument:t.noDocument,document:t.document,hasCommittedMutations:!!t.hasCommittedMutations};a.push(n.put(i))}).next(()=>L.waitFor(a))}K_(e,s){let t=s.store(b0),a=y8(this.serializer),o=new F8(V8.C_,this.serializer.zr);return t.H().next(e=>{let r=new Map;return e.forEach(e=>{let t=r.get(e.userId)??F();l9(this.serializer,e).keys().forEach(e=>t=t.add(e)),r.set(e.userId,t)}),L.forEach(r,(e,t)=>{var r=new Ym(t),n=w9.jr(this.serializer,r),i=o.getIndexManager(r),r=e8.jr(r,this.serializer,i,o.referenceDelegate);return new k8(a,r,n,i).recalculateAndSaveOverlaysForDocumentKeys(new T6(s,l0.ce),e).next()})})}}function j8(e){e.createObjectStore(B0,{keyPath:q0}).createIndex(j0,z0,{unique:!0}),e.createObjectStore(F0,{keyPath:"targetId"}).createIndex(U0,V0,{unique:!0}),e.createObjectStore(K0)}let z8="IndexedDbPersistence",H8="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.",K8="main";class G8{constructor(e,t,r,n,i,s,a,o,l,u,h=18){if(this.allowTabSynchronization=e,this.persistenceKey=t,this.clientId=r,this.Tn=i,this.window=s,this.document=a,this.W_=l,this.Q_=u,this.G_=h,this.f_=null,this.m_=!1,this.isPrimary=!1,this.networkEnabled=!0,this.z_=null,this.inForeground=!1,this.j_=null,this.H_=null,this.J_=Number.NEGATIVE_INFINITY,this.Y_=e=>Promise.resolve(),!G8.C())throw new R(N.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");this.referenceDelegate=new h8(this,n),this.Z_=t+K8,this.serializer=new n9(o),this.X_=new Q2(this.Z_,this.G_,new q8(this.serializer)),this.p_=new T9,this.g_=new a8(this.referenceDelegate,this.serializer),this.remoteDocumentCache=y8(this.serializer),this.w_=new v9,this.window&&this.window.localStorage?this.eo=this.window.localStorage:(this.eo=null,!1===u&&Zm(z8,"LocalStorage is unavailable. As a result, persistence may not work reliably. In particular enablePersistence() could fail immediately after refreshing the page."))}start(){return this.no().then(()=>{if(this.isPrimary||this.allowTabSynchronization)return this.ro(),this.io(),this.so(),this.runTransaction("getHighestListenSequenceNumber","readonly",e=>this.g_.getHighestSequenceNumber(e));throw new R(N.FAILED_PRECONDITION,H8)}).then(e=>{this.f_=new l0(e,this.W_)}).then(()=>{this.m_=!0}).catch(e=>(this.X_&&this.X_.close(),Promise.reject(e)))}_o(t){return this.Y_=async e=>{if(this.started)return t(e)},t(this.isPrimary)}setDatabaseDeletedListener(t){this.X_.q(async e=>{null===e.newVersion&&await t()})}setNetworkEnabled(e){this.networkEnabled!==e&&(this.networkEnabled=e,this.Tn.enqueueAndForget(async()=>{this.started&&await this.no()}))}no(){return this.runTransaction("updateClientMetadataAndTryBecomePrimary","readwrite",t=>$8(t).put({clientId:this.clientId,updateTimeMs:Date.now(),networkEnabled:this.networkEnabled,inForeground:this.inForeground}).next(()=>{if(this.isPrimary)return this.oo(t).next(e=>{e||(this.isPrimary=!1,this.Tn.enqueueRetryable(()=>this.Y_(!1)))})}).next(()=>this.ao(t)).next(e=>this.isPrimary&&!e?this.uo(t).next(()=>!1):!!e&&this.co(t).next(()=>!0))).catch(e=>{if(e0(e))return S(z8,"Failed to extend owner lease: ",e),this.isPrimary;if(this.allowTabSynchronization)return S(z8,"Releasing owner lease after error during lease refresh",e),!1;throw e}).then(e=>{this.isPrimary!==e&&this.Tn.enqueueRetryable(()=>this.Y_(e)),this.isPrimary=e})}oo(e){return W8(e).get(y0).next(e=>L.resolve(this.lo(e)))}Eo(e){return $8(e).delete(this.clientId)}async ho(){if(this.isPrimary&&!this.To(this.J_,18e5)){this.J_=Date.now();var e=await this.runTransaction("maybeGarbageCollectMultiClientState","readwrite-primary",e=>{let n=E6(e,$0);return n.H().next(e=>{let t=this.Po(e,18e5),r=e.filter(e=>-1===t.indexOf(e));return L.forEach(r,e=>n.delete(e.clientId)).next(()=>r)})}).catch(()=>[]);if(this.eo)for(var t of e)this.eo.removeItem(this.Ro(t.clientId))}}so(){this.H_=this.Tn.enqueueAfterDelay("client_metadata_refresh",4e3,()=>this.no().then(()=>this.ho()).then(()=>this.so()))}lo(e){return!!e&&e.ownerId===this.clientId}ao(t){return this.Q_?L.resolve(!0):W8(t).get(y0).next(e=>{if(null!==e&&this.To(e.leaseTimestampMs,5e3)&&!this.Io(e.ownerId)){if(this.lo(e)&&this.networkEnabled)return!0;if(!this.lo(e)){if(e.allowTabSynchronization)return!1;throw new R(N.FAILED_PRECONDITION,H8)}}return!(!this.networkEnabled||!this.inForeground)||$8(t).H().next(e=>void 0===this.Po(e,5e3).find(e=>{if(this.clientId!==e.clientId){var t=!this.networkEnabled&&e.networkEnabled,r=!this.inForeground&&e.inForeground,n=this.networkEnabled===e.networkEnabled;if(t||r&&n)return!0}return!1}))}).next(e=>(this.isPrimary!==e&&S(z8,`Client ${e?"is":"is not"} eligible for a primary lease.`),e))}async shutdown(){this.m_=!1,this.Ao(),this.H_&&(this.H_.cancel(),this.H_=null),this.Vo(),this.fo(),await this.X_.runTransaction("shutdown","readwrite",[_0,$0],e=>{let t=new T6(e,l0.ce);return this.uo(t).next(()=>this.Eo(t))}),this.X_.close(),this.mo()}Po(e,t){return e.filter(e=>this.To(e.updateTimeMs,t)&&!this.Io(e.clientId))}po(){return this.runTransaction("getActiveClients","readonly",e=>$8(e).H().next(e=>this.Po(e,18e5).map(e=>e.clientId)))}get started(){return this.m_}getGlobalsCache(){return this.p_}getMutationQueue(e,t){return e8.jr(e,this.serializer,t,this.referenceDelegate)}getTargetCache(){return this.g_}getRemoteDocumentCache(){return this.remoteDocumentCache}getIndexManager(e){return new G9(e,this.serializer.zr.databaseId)}getDocumentOverlayCache(e){return w9.jr(this.serializer,e)}getBundleCache(){return this.w_}runTransaction(t,r,n){S(z8,"Starting transaction:",t);var e,i="readonly"===r?"readonly":"readwrite",s=18===(e=this.G_)?b6:17===e?w6:16===e?y6:15===e?_6:14===e?v6:13===e?m6:12===e?g6:11===e?f6:void k(60245);let a;return this.X_.runTransaction(t,i,s,e=>(a=new T6(e,this.f_?this.f_.next():l0.ce),"readwrite-primary"===r?this.oo(a).next(e=>!!e||this.ao(a)).next(e=>{if(e)return n(a);throw Zm(`Failed to obtain primary lease for action '${t}'.`),this.isPrimary=!1,this.Tn.enqueueRetryable(()=>this.Y_(!1)),new R(N.FAILED_PRECONDITION,K2)}).next(e=>this.co(a).next(()=>e)):this.yo(a).next(()=>n(a)))).then(e=>(a.raiseOnCommittedEvent(),e))}yo(e){return W8(e).get(y0).next(e=>{if(null!==e&&this.To(e.leaseTimestampMs,5e3)&&!this.Io(e.ownerId)&&!this.lo(e)&&!(this.Q_||this.allowTabSynchronization&&e.allowTabSynchronization))throw new R(N.FAILED_PRECONDITION,H8)})}co(e){var t={ownerId:this.clientId,allowTabSynchronization:this.allowTabSynchronization,leaseTimestampMs:Date.now()};return W8(e).put(y0,t)}static C(){return Q2.C()}uo(e){let t=W8(e);return t.get(y0).next(e=>this.lo(e)?(S(z8,"Releasing primary lease."),t.delete(y0)):L.resolve())}To(e,t){var r=Date.now();return!(e<r-t||r<e&&(Zm(`Detected an update time that is in the future: ${e} > `+r),1))}ro(){null!==this.document&&"function"==typeof this.document.addEventListener&&(this.j_=()=>{this.Tn.enqueueAndForget(()=>(this.inForeground="visible"===this.document.visibilityState,this.no()))},this.document.addEventListener("visibilitychange",this.j_),this.inForeground="visible"===this.document.visibilityState)}Vo(){this.j_&&(this.document.removeEventListener("visibilitychange",this.j_),this.j_=null)}io(){"function"==typeof this.window?.addEventListener&&(this.z_=()=>{this.Ao();var e=/(?:Version|Mobile)\/1[456]/;ue()&&(navigator.appVersion.match(e)||navigator.userAgent.match(e))&&this.Tn.enterRestrictedMode(!0),this.Tn.enqueueAndForget(()=>this.shutdown())},this.window.addEventListener("pagehide",this.z_))}fo(){this.z_&&(this.window.removeEventListener("pagehide",this.z_),this.z_=null)}Io(e){try{var t=null!==this.eo?.getItem(this.Ro(e));return S(z8,`Client '${e}' ${t?"is":"is not"} zombied in LocalStorage`),t}catch(e){return Zm(z8,"Failed to get zombied client id.",e),!1}}Ao(){if(this.eo)try{this.eo.setItem(this.Ro(this.clientId),String(Date.now()))}catch(e){Zm("Failed to set zombie client id.",e)}}mo(){if(this.eo)try{this.eo.removeItem(this.Ro(this.clientId))}catch(e){}}Ro(e){return`firestore_zombie_${this.persistenceKey}_`+e}}function W8(e){return E6(e,_0)}function $8(e){return E6(e,$0)}function Y8(e,t){let r=e.projectId;return e.isDefaultDatabase||(r+="."+e.database),"firestore/"+t+"/"+r+"/"}class Q8{constructor(e,t,r,n){this.targetId=e,this.fromCache=t,this.wo=r,this.bo=n}static vo(e,t){let r=F(),n=F();for(let e of t.docChanges)switch(e.type){case 0:r=r.add(e.doc.key);break;case 1:n=n.add(e.doc.key)}return new Q8(e,t.fromCache,r,n)}}function J8(e,t){return D.comparator(e.key,t.key)}class X8{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(e){this._documentReadCount+=e}}class Z8{constructor(){this.So=!1,this.Do=!1,this.xo=100,this.Co=ue()?8:0<J2(te())?6:4}initialize(e,t){this.Fo=e,this.indexManager=t,this.So=!0}getDocumentsMatchingQuery(r,n,e,t){let i={result:null};return this.Oo(r,n).next(e=>{i.result=e}).next(()=>{if(!i.result)return this.Mo(r,n,t,e).next(e=>{i.result=e})}).next(()=>{if(!i.result){let t=new X8;return this.No(r,n,t).next(e=>{if(i.result=e,this.Do)return this.Lo(r,n,t,e.size)})}}).next(()=>i.result)}Lo(e,t,r,n){return Gw(t)?L.resolve():r.documentReadCount<this.xo?(Xm()<=p.DEBUG&&S("QueryEngine","SDK will not create cache indexes for query:",K_(t),"since it only creates cache indexes for collection contains","more than or equal to",this.xo,"documents"),L.resolve()):(Xm()<=p.DEBUG&&S("QueryEngine","Query:",K_(t),"scans",r.documentReadCount,"local documents and returns",n,"documents as results."),r.documentReadCount>this.Co*n?(Xm()<=p.DEBUG&&S("QueryEngine","The SDK decides to create cache indexes for query:",K_(t),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(e,q_(t))):L.resolve())}Oo(i,e){if(Gw(e))return L.resolve(null);let s=e;if(U_(s))return L.resolve(null);let t=q_(s);return this.indexManager.getIndexType(i,t).next(e=>0===e?null:(null!==s.limit&&1===e&&(s=z_(s,null,"F"),t=q_(s)),this.indexManager.getDocumentsMatchingTarget(i,t).next(e=>{let n=F(...e);return this.Fo.getDocuments(i,n).next(r=>this.indexManager.getMinOffset(i,t).next(e=>{var t=this.Bo(s,r);return this.Uo(s,t,n,e.readTime)?this.Oo(i,z_(s,null,"F")):this.ko(i,t,s,e)}))})))}Mo(r,n,i,s){return(Gw(n)?e=>{for(var t of e.stages){if(t instanceof $4||!1)return;if(t instanceof W4&&!(t.condition instanceof L4&&"exists"===t.condition._expr.name&&t.condition._expr.params[0]instanceof N4&&t.condition._expr.params[0].fieldName===y2))return}return 1}:U_)(n)||s.isEqual(O.min())?L.resolve(null):this.Fo.getDocuments(r,i).next(e=>{var t=this.Bo(n,e);return this.Uo(n,t,i,s)?L.resolve(null):(Xm()<=p.DEBUG&&S("QueryEngine","Re-using previous result from %s to execute query: %s",s.toString(),Ww(n)),this.ko(r,t,n,q2(s,L2)).next(e=>e))})}Bo(t,e){let r,n;return n=Gw(t)?(r=new k6(J8),e=>p8(t,e)):(r=new k6(W_(t)),e=>G_(t,e)),e.forEach((e,t)=>{n(t)&&(r=r.add(t))}),r}Uo(e,t,r,n){var i;return Gw(e)?e.stages.some(e=>e instanceof $4||!1):null!==e.limit&&(r.size!==t.size||!!(i="F"===e.limitType?t.last():t.first())&&(i.hasPendingWrites||0<i.version.compareTo(n)))}No(e,t,r){return Xm()<=p.DEBUG&&S("QueryEngine","Using full collection scan to execute query:",Ww(t)),this.Fo.getDocumentsMatchingQuery(e,t,z2.min(),r)}ko(e,r,t,n){return this.Fo.getDocumentsMatchingQuery(e,t,n).next(t=>(r.forEach(e=>{t=t.insert(e.key,e)}),t))}}let e5="LocalStore",t5=3e8;class r5{constructor(e,t,r,n){this.persistence=e,this.qo=t,this.serializer=n,this.$o=new I6(P),this.Ko=new J_(e=>Qw(e),Jw),this.Wo=new Map,this.Qo=e.getRemoteDocumentCache(),this.g_=e.getTargetCache(),this.w_=e.getBundleCache(),this.Go(r)}Go(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new k8(this.Qo,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.Qo.setIndexManager(this.indexManager),this.qo.initialize(this.localDocuments,this.indexManager)}collectGarbage(t){return this.persistence.runTransaction("Collect garbage","readwrite-primary",e=>t.collect(e,this.$o))}}function n5(e,t,r,n){return new r5(e,t,r,n)}async function i5(e,t){let o=e;return o.persistence.runTransaction("Handle user change","readonly",s=>{let a;return o.mutationQueue.getAllMutationBatches(s).next(e=>(a=e,o.Go(t),o.mutationQueue.getAllMutationBatches(s))).next(e=>{let t=[],r=[],n=F();for(let i of a){t.push(i.batchId);for(let e of i.mutations)n=n.add(e.key)}for(let i of e){r.push(i.batchId);for(let e of i.mutations)n=n.add(e.key)}return o.localDocuments.getDocuments(s,n).next(e=>({zo:e,removedBatchIds:t,addedBatchIds:r}))})})}function s5(e,n){let i=e;return i.persistence.runTransaction("Acknowledge batch","readwrite-primary",e=>{let t=n.batch.keys(),r=i.Qo.newChangeBuffer({trackRemovals:!0});return((e,t,n,i)=>{let s=n.batch,r=s.keys(),a=L.resolve();return r.forEach(r=>{a=a.next(()=>i.getEntry(t,r)).next(e=>{var t=n.docVersions.get(r);A(null!==t,48541),e.version.compareTo(t)<0&&(s.applyToRemoteDocument(e,n),e.isValidDocument())&&(e.setReadTime(n.commitVersion),i.addEntry(e))})}),a.next(()=>e.mutationQueue.removeMutationBatch(t,s))})(i,e,n,r).next(()=>r.apply(e)).next(()=>i.mutationQueue.performConsistencyCheck(e)).next(()=>i.documentOverlayCache.removeOverlaysForBatchId(e,t,n.batch.batchId)).next(()=>i.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(e,(e=>{let t=F();for(let r=0;r<e.mutationResults.length;++r)0<e.mutationResults[r].transformResults.length&&(t=t.add(e.batch.mutations[r].key));return t})(n))).next(()=>i.localDocuments.getDocuments(e,t))})}function a5(e){let t=e;return t.persistence.runTransaction("Get last remote snapshot version","readonly",e=>t.g_.getLastRemoteSnapshotVersion(e))}function o5(e,u){let h=e,c=u.snapshotVersion,d=h.$o;return h.persistence.runTransaction("Apply remote event","readwrite-primary",o=>{let e=h.Qo.newChangeBuffer({trackRemovals:!0}),l=(d=h.$o,[]),t=(u.targetChanges.forEach((t,r)=>{var n,i,s,a=d.get(r);if(a){l.push(h.g_.removeMatchingKeys(o,t.removedDocuments,r).next(()=>h.g_.addMatchingKeys(o,t.addedDocuments,r)));let e=a.withSequenceNumber(o.currentSequenceNumber);null!==u.targetMismatches.get(r)?e=e.withResumeToken(L6.EMPTY_BYTE_STRING,O.min()).withLastLimboFreeSnapshotVersion(O.min()):0<t.resumeToken.approximateByteSize()&&(e=e.withResumeToken(t.resumeToken,c)),d=d.insert(r,e),n=a,i=e,s=t,(0===n.resumeToken.approximateByteSize()||i.snapshotVersion.toMicroseconds()-n.snapshotVersion.toMicroseconds()>=t5||0<s.addedDocuments.size+s.modifiedDocuments.size+s.removedDocuments.size)&&l.push(h.g_.updateTargetData(o,e))}}),X_),r=F();if(u.documentUpdates.forEach(e=>{u.resolvedLimboDocuments.has(e)&&l.push(h.persistence.referenceDelegate.updateLimboDocument(o,e))}),l.push(l5(o,e,u.documentUpdates).next(e=>{t=e.jo,r=e.Ho})),!c.isEqual(O.min())){let e=h.g_.getLastRemoteSnapshotVersion(o).next(e=>h.g_.setTargetsMetadata(o,o.currentSequenceNumber,c));l.push(e)}return L.waitFor(l).next(()=>e.apply(o)).next(()=>h.localDocuments.getLocalViewOfDocuments(o,t,r)).next(()=>t)}).then(e=>(h.$o=d,e))}function l5(e,s,t){let r=F(),a=F();return t.forEach(e=>r=r.add(e)),s.getEntries(e,r).next(n=>{let i=X_;return t.forEach((e,t)=>{var r=n.get(e);t.isFoundDocument()!==r.isFoundDocument()&&(a=a.add(e)),t.isNoDocument()&&t.version.isEqual(O.min())?(s.removeEntry(e,t.readTime),i=i.insert(e,t)):!r.isValidDocument()||0<t.version.compareTo(r.version)||0===t.version.compareTo(r.version)&&r.hasPendingWrites?(s.addEntry(t),i=i.insert(e,t)):S(e5,"Ignoring outdated watch update for ",e,". Current version:",r.version," Watch version:",t.version)}),{jo:i,Ho:a}})}function u5(e,n){let i=e;return i.persistence.runTransaction("Allocate target","readwrite",t=>{let r;return i.g_.getTargetData(t,n).next(e=>e?(r=e,L.resolve(r)):i.g_.allocateTargetId(t).next(e=>(r=new r9(n,e,"TargetPurposeListen",t.currentSequenceNumber),i.g_.addTargetData(t,r).next(()=>r))))}).then(e=>{var t=i.$o.get(e.targetId);return(null===t||0<e.snapshotVersion.compareTo(t.snapshotVersion))&&(i.$o=i.$o.insert(e.targetId,e),i.Ko.set(n,e.targetId)),e})}async function h5(e,t,r){let n=e,i=n.$o.get(t),s=r?"readwrite":"readwrite-primary";try{r||await n.persistence.runTransaction("Release target",s,e=>n.persistence.referenceDelegate.removeTarget(e,i))}catch(e){if(!e0(e))throw e;S(e5,`Failed to update sequence numbers for target ${t}: `+e)}n.$o=n.$o.remove(t),n.Ko.delete(i.target)}function c5(e,a,o){let l=e,u=O.min(),h=F();return l.persistence.runTransaction("Execute query","readwrite",t=>{return e=l,r=t,n=Gw(a)?a:q_(a),(void 0!==(s=(i=e).Ko.get(n))?L.resolve(i.$o.get(s)):i.g_.getTargetData(r,n)).next(e=>{if(e)return u=e.lastLimboFreeSnapshotVersion,l.g_.getMatchingKeysForTargetId(t,e.targetId).next(e=>{h=e})}).next(()=>l.qo.getDocumentsMatchingQuery(t,a,o?u:O.min(),o?h:F())).next(e=>(f5(l,e),{documents:e,Jo:h}));var e,r,n,i,s})}function d5(e,t){let r=e,n=r.g_,i=r.$o.get(t);return i?Promise.resolve(i.target??null):r.persistence.runTransaction("Get target data","readonly",e=>n.dt(e,t).next(e=>e?.target??null))}function p5(e,t){let r=e,n=r.Wo.get(t)||O.min();return r.persistence.runTransaction("Get new document changes","readonly",e=>r.Qo.getAllFromCollectionGroup(e,t,q2(n,L2),Number.MAX_SAFE_INTEGER)).then(e=>(f5(r,e),e))}function f5(i,e){e.forEach((e,t)=>{var r=t.key.getCollectionGroup(),n=i.Wo.get(r)||O.min();0<t.readTime.compareTo(n)&&i.Wo.set(r,t.readTime)})}let g5="firestore_clients";function m5(e,t){return g5+`_${e}_`+t}let v5="firestore_mutations";function _5(e,t,r){let n=v5+`_${e}_`+r;return t.isAuthenticated()&&(n+="_"+t.uid),n}let y5="firestore_targets";function w5(e,t){return y5+`_${e}_`+t}let b5="SharedClientState";class T5{constructor(e,t,r,n){this.user=e,this.batchId=t,this.state=r,this.error=n}static ea(e,t,r){var n=JSON.parse(r);let i,s="object"==typeof n&&-1!==["pending","acknowledged","rejected"].indexOf(n.state)&&(void 0===n.error||"object"==typeof n.error);return s&&n.error&&(s="string"==typeof n.error.message&&"string"==typeof n.error.code)&&(i=new R(n.error.code,n.error.message)),s?new T5(e,t,n.state,i):(Zm(b5,`Failed to parse mutation state for ID '${t}': `+r),null)}ta(){var e={state:this.state,updateTimeMs:Date.now()};return this.error&&(e.error={code:this.error.code,message:this.error.message}),JSON.stringify(e)}}class E5{constructor(e,t,r){this.targetId=e,this.state=t,this.error=r}static ea(e,t){var r=JSON.parse(t);let n,i="object"==typeof r&&-1!==["not-current","current","rejected"].indexOf(r.state)&&(void 0===r.error||"object"==typeof r.error);return i&&r.error&&(i="string"==typeof r.error.message&&"string"==typeof r.error.code)&&(n=new R(r.error.code,r.error.message)),i?new E5(e,r.state,n):(Zm(b5,`Failed to parse target state for ID '${e}': `+t),null)}ta(){var e={state:this.state,updateTimeMs:Date.now()};return this.error&&(e.error={code:this.error.code,message:this.error.message}),JSON.stringify(e)}}class I5{constructor(e,t){this.clientId=e,this.activeTargetIds=t}static ea(e,t){var r=JSON.parse(t);let n="object"==typeof r&&r.activeTargetIds instanceof Array,i=sy;for(let s=0;n&&s<r.activeTargetIds.length;++s)n=d0(r.activeTargetIds[s]),i=i.add(r.activeTargetIds[s]);return n?new I5(e,i):(Zm(b5,`Failed to parse client data for instance '${e}': `+t),null)}}class C5{constructor(e,t){this.clientId=e,this.onlineState=t}static ea(e){var t=JSON.parse(e);return"object"==typeof t&&-1!==["Unknown","Online","Offline"].indexOf(t.onlineState)&&"string"==typeof t.clientId?new C5(t.clientId,t.onlineState):(Zm(b5,"Failed to parse online state: "+e),null)}}class S5{constructor(){this.activeTargetIds=sy}na(e){this.activeTargetIds=this.activeTargetIds.add(e)}ra(e){this.activeTargetIds=this.activeTargetIds.delete(e)}ta(){var e={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(e)}}class k5{constructor(e,t,r,n,i){this.window=e,this.Tn=t,this.persistenceKey=r,this.ia=n,this.syncEngine=null,this.onlineStateHandler=null,this.sequenceNumberHandler=null,this.sa=this._a.bind(this),this.oa=new I6(P),this.started=!1,this.aa=[];var s=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");this.storage=this.window.localStorage,this.currentUser=i,this.ua=m5(this.persistenceKey,this.ia),this.ca="firestore_sequence_number_"+this.persistenceKey,this.oa=this.oa.insert(this.ia,new S5),this.la=new RegExp(`^${g5}_${s}_([^_]*)$`),this.Ea=new RegExp(`^${v5}_${s}_(\\d+)(?:_(.*))?$`),this.ha=new RegExp(`^${y5}_${s}_(\\d+)$`),this.Ta="firestore_online_state_"+this.persistenceKey,this.Pa="firestore_bundle_loaded_v2_"+this.persistenceKey,this.window.addEventListener("storage",this.sa)}static C(e){return!(!e||!e.localStorage)}async start(){let e=await this.syncEngine.po();for(let r of e)if(r!==this.ia){let e=this.getItem(m5(this.persistenceKey,r));var t;e&&(t=I5.ea(r,e))&&(this.oa=this.oa.insert(t.clientId,t))}this.Ra();let r=this.storage.getItem(this.Ta);if(r){let e=this.Ia(r);e&&this.Aa(e)}for(let e of this.aa)this._a(e);this.aa=[],this.window.addEventListener("pagehide",()=>this.shutdown()),this.started=!0}writeSequenceNumber(e){this.setItem(this.ca,JSON.stringify(e))}getAllActiveQueryTargets(){return this.Va(this.oa)}isActiveQueryTarget(r){let n=!1;return this.oa.forEach((e,t)=>{t.activeTargetIds.has(r)&&(n=!0)}),n}addPendingMutation(e){this.da(e,"pending")}updateMutationState(e,t,r){this.da(e,t,r),this.fa(e)}addLocalQueryTarget(t,e=!0){let r="not-current";if(this.isActiveQueryTarget(t)){let e=this.storage.getItem(w5(this.persistenceKey,t));var n;e&&(n=E5.ea(t,e))&&(r=n.state)}return e&&this.ma.na(t),this.Ra(),r}removeLocalQueryTarget(e){this.ma.ra(e),this.Ra()}isLocalQueryTarget(e){return this.ma.activeTargetIds.has(e)}clearQueryState(e){this.removeItem(w5(this.persistenceKey,e))}updateQueryState(e,t,r){this.pa(e,t,r)}handleUserChange(e,t,r){t.forEach(e=>{this.fa(e)}),this.currentUser=e,r.forEach(e=>{this.addPendingMutation(e)})}setOnlineState(e){this.ga(e)}notifyBundleLoaded(e){this.ya(e)}shutdown(){this.started&&(this.window.removeEventListener("storage",this.sa),this.removeItem(this.ua),this.started=!1)}getItem(e){var t=this.storage.getItem(e);return S(b5,"READ",e,t),t}setItem(e,t){S(b5,"SET",e,t),this.storage.setItem(e,t)}removeItem(e){S(b5,"REMOVE",e),this.storage.removeItem(e)}_a(e){let t=e;t.storageArea===this.storage&&(S(b5,"EVENT",t.key,t.newValue),t.key===this.ua?Zm("Received WebStorage notification for local change. Another client might have garbage-collected our state"):this.Tn.enqueueRetryable(async()=>{if(this.started){if(null!==t.key){if(this.la.test(t.key))return null==t.newValue?(e=this.wa(t.key),this.ba(e,null)):(e=this.va(t.key,t.newValue))?this.ba(e.clientId,e):void 0;if(this.Ea.test(t.key)){if(null!==t.newValue){var e=this.Sa(t.key,t.newValue);if(e)return this.Da(e)}}else if(this.ha.test(t.key)){if(null!==t.newValue){var e=this.xa(t.key,t.newValue);if(e)return this.Ca(e)}}else if(t.key===this.Ta){if(null!==t.newValue){var e=this.Ia(t.newValue);if(e)return this.Aa(e)}}else t.key===this.ca?(e=(e=>{let t=l0.ce;if(null!=e)try{var r=JSON.parse(e);A("number"==typeof r,30636,{Fa:e}),t=r}catch(e){Zm(b5,"Failed to read sequence number from WebStorage",e)}return t})(t.newValue))!==l0.ce&&this.sequenceNumberHandler(e):t.key===this.Pa&&(e=this.Oa(t.newValue),await Promise.all(e.map(e=>this.syncEngine.Ma(e))))}}else this.aa.push(t)}))}get ma(){return this.oa.get(this.ia)}Ra(){this.setItem(this.ua,this.ma.ta())}da(e,t,r){var n=new T5(this.currentUser,e,t,r),i=_5(this.persistenceKey,this.currentUser,e);this.setItem(i,n.ta())}fa(e){var t=_5(this.persistenceKey,this.currentUser,e);this.removeItem(t)}ga(e){var t={clientId:this.ia,onlineState:e};this.storage.setItem(this.Ta,JSON.stringify(t))}pa(e,t,r){var n=w5(this.persistenceKey,e),i=new E5(e,t,r);this.setItem(n,i.ta())}ya(e){var t=JSON.stringify(Array.from(e));this.setItem(this.Pa,t)}wa(e){var t=this.la.exec(e);return t?t[1]:null}va(e,t){var r=this.wa(e);return I5.ea(r,t)}Sa(e,t){var r=this.Ea.exec(e),n=Number(r[1]),r=void 0!==r[2]?r[2]:null;return T5.ea(new Ym(r),n,t)}xa(e,t){var r=this.ha.exec(e),r=Number(r[1]);return E5.ea(r,t)}Ia(e){return C5.ea(e)}Oa(e){return JSON.parse(e)}async Da(e){if(e.user.uid===this.currentUser.uid)return this.syncEngine.Na(e.batchId,e.state,e.error);S(b5,"Ignoring mutation for non-active user "+e.user.uid)}Ca(e){return this.syncEngine.La(e.targetId,e.state,e.error)}ba(e,t){let r=t?this.oa.insert(e,t):this.oa.remove(e),n=this.Va(this.oa),i=this.Va(r),s=[],a=[];return i.forEach(e=>{n.has(e)||s.push(e)}),n.forEach(e=>{i.has(e)||a.push(e)}),this.syncEngine.Ba(s,a).then(()=>{this.oa=r})}Aa(e){this.oa.get(e.clientId)&&this.onlineStateHandler(e.onlineState)}Va(e){let r=sy;return e.forEach((e,t)=>{r=r.unionWith(t.activeTargetIds)}),r}}class A5{constructor(){this.Ua=new S5,this.ka={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,t,r){}addLocalQueryTarget(e,t=!0){return t&&this.Ua.na(e),this.ka[e]||"not-current"}updateQueryState(e,t,r){this.ka[e]=t}removeLocalQueryTarget(e){this.Ua.ra(e)}isLocalQueryTarget(e){return this.Ua.activeTargetIds.has(e)}clearQueryState(e){delete this.ka[e]}getAllActiveQueryTargets(){return this.Ua.activeTargetIds}isActiveQueryTarget(e){return this.Ua.activeTargetIds.has(e)}start(){return this.Ua=new S5,Promise.resolve()}handleUserChange(e,t,r){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}}function N5(){return"undefined"!=typeof window?window:null}function R5(){return"undefined"!=typeof document?document:null}class P5{constructor(e,t){this.asyncQueue=e,this.onlineStateHandler=t,this.state="Unknown",this.qa=0,this.$a=null,this.Ka=!0}Wa(){0===this.qa&&(this.Qa("Unknown"),this.$a=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,()=>(this.$a=null,this.Ga("Backend didn't respond within 10 seconds."),this.Qa("Offline"),Promise.resolve())))}za(e){"Online"===this.state?this.Qa("Unknown"):(this.qa++,1<=this.qa&&(this.ja(),this.Ga("Connection failed 1 times. Most recent error: "+e.toString()),this.Qa("Offline")))}set(e){this.ja(),this.qa=0,"Online"===e&&(this.Ka=!1),this.Qa(e)}Qa(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}Ga(e){var t=`Could not reach Cloud Firestore backend. ${e}
This 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.Ka?(Zm(t),this.Ka=!1):S("OnlineStateTracker",t)}ja(){null!==this.$a&&(this.$a.cancel(),this.$a=null)}}let x5="RemoteStore";class D5{constructor(e,t,r,n,i){this.localStore=e,this.datastore=t,this.asyncQueue=r,this.remoteSyncer={},this.Ha=[],this.Ja=new Map,this.Ya=new Map,this.Za=new Map,this.Xa=new s8(1e3),this.eu=new s8(1001),this.tu=new Set,this.nu=[],this.ru=i,this.ru.bt(e=>{r.enqueueAndForget(async()=>{var e;z5(this)&&(S(x5,"Restarting streams for network reachability change."),(e=this).tu.add(4),await L5(e),e.iu.set("Unknown"),e.tu.delete(4),await O5(e))})}),this.iu=new P5(r,n)}}async function O5(e){if(z5(e))for(var t of e.nu)await t(!0)}async function L5(e){for(var t of e.nu)await t(!1)}function M5(e,t){return e.Ya.get(t)||void 0}function F5(e,t){var r,n,i,s=e,a=M5(s,t.targetId);void 0!==a&&s.Ja.has(a)||(void 0!==(a=M5(e=s,r=t.targetId))&&e.Za.delete(a),n=e,a=(r%2!=0?n.eu:n.Xa).next(),e.Ya.set(r,a),e.Za.set(a,r),a=a,S(x5,"remoteStoreListen mapping SDK target ID to remote",t.targetId,a),i=new r9(t.target,a,t.purpose,t.sequenceNumber,t.snapshotVersion,t.lastLimboFreeSnapshotVersion,t.resumeToken),s.Ja.set(a,i),j5(s)?q5(s):Z5(s).Fn()&&V5(s,i))}function U5(e,t){var r=e,n=Z5(r),i=M5(r,t);S(x5,"remoteStoreUnlisten removing mapping of SDK target ID to remote",t,i),r.Ja.delete(i),r.Ya.delete(t),r.Za.delete(i),n.Fn()&&B5(r,i),0===r.Ja.size&&(n.Fn()?n.Nn():z5(r)&&r.iu.set("Unknown"))}function V5(e,t){if(e.su.We(t.targetId),0<t.resumeToken.approximateByteSize()||0<t.snapshotVersion.compareTo(O.min())){var r=e.Za.get(t.targetId);if(void 0===r)return S(x5,"SDK target ID not found for remote ID: "+t.targetId);r=e.remoteSyncer.getRemoteKeysForTarget(r).size;t=t.withExpectedCount(r)}Z5(e).jn(t)}function B5(e,t){e.su.We(t),Z5(e).Hn(t)}function q5(r){r.su=new yy({getRemoteKeysForTarget:e=>{var t=r.Za.get(e);return void 0!==t?r.remoteSyncer.getRemoteKeysForTarget(t):F()},dt:e=>r.Ja.get(e)||null,Tt:()=>r.datastore.serializer.databaseId}),Z5(r).start(),r.iu.Wa()}function j5(e){return z5(e)&&!Z5(e).Cn()&&0<e.Ja.size}function z5(e){return 0===e.tu.size}function H5(e){e.su=void 0}async function K5(t,e,r){if(t.iu.set("Online"),e instanceof my&&2===e.state&&e.cause)try{var n,i=t,s=e,a=s.cause;for(n of s.targetIds){if(i.Ja.has(n)){let e=i.Za.get(n);void 0!==e&&(await i.remoteSyncer.rejectListen(e,a),i.Ya.delete(e),i.Za.delete(n)),i.Ja.delete(n)}i.su.removeTarget(n)}}catch(r){S(x5,"Failed to remove targets %s: %s ",e.targetIds.join(","),r),await G5(t,r)}else if(e instanceof fy?t.su.et(e):e instanceof gy?t.su.ot(e):t.su.rt(e),!r.isEqual(O.min()))try{let e=await a5(t.localStore);0<=r.compareTo(e)&&(l=r,(u=(o=t).su.Rt(l)).targetChanges.forEach((e,t)=>{var r;0<e.resumeToken.approximateByteSize()&&(r=o.Ja.get(t))&&o.Ja.set(t,r.withResumeToken(e.resumeToken,l))}),u.targetMismatches.forEach((e,t)=>{var r=o.Ja.get(e);r&&(o.Ja.set(e,r.withResumeToken(L6.EMPTY_BYTE_STRING,r.snapshotVersion)),B5(o,e),r=new r9(r.target,e,t,r.sequenceNumber),V5(o,r))}),u=((n,e)=>{let i=new Map,s=(e.targetChanges.forEach((e,t)=>{var r=n.Za.get(t);void 0!==r&&i.set(r,e)}),new I6(P));return e.targetMismatches.forEach((e,t)=>{var r=n.Za.get(e);void 0!==r&&(s=s.insert(r,t))}),new dy(e.snapshotVersion,i,s,e.documentUpdates,e.augmentedDocumentUpdates,e.resolvedLimboDocuments)})(o,u),await o.remoteSyncer.applyRemoteEvent(u))}catch(e){S(x5,"Failed to raise snapshot:",e),await G5(t,e)}var o,l,u}async function G5(e,t,r){if(!e0(t))throw t;e.tu.add(1),await L5(e),e.iu.set("Offline"),r=r||(()=>a5(e.localStore)),e.asyncQueue.enqueueRetryable(async()=>{S(x5,"Retrying IndexedDB access"),await r(),e.tu.delete(1),await O5(e)})}function W5(t,r){return r().catch(e=>G5(t,e,r))}async function $5(e){var t,r,n,i,s=e,a=eb(s);let o=0<s.Ha.length?s.Ha[s.Ha.length-1].batchId:u0;for(;z5(i=s)&&i.Ha.length<10;)try{let e=await((e,t)=>{let r=e;return r.persistence.runTransaction("Get next mutation batch","readonly",e=>(void 0===t&&(t=u0),r.mutationQueue.getNextMutationBatchAfterBatchId(e,t)))})(s.localStore,o);if(null===e){0===s.Ha.length&&a.Nn();break}o=e.batchId,t=s,r=e,n=void 0,t.Ha.push(r),(n=eb(t)).Fn()&&n.Jn&&n.Yn(r.mutations)}catch(e){await G5(s,e)}Y5(s)&&Q5(s)}function Y5(e){return z5(e)&&!eb(e).Cn()&&0<e.Ha.length}function Q5(e){eb(e).start()}async function J5(e,t){var r=e,n=(r.asyncQueue.verifyOperationInProgress(),S(x5,"RemoteStore received new credentials"),z5(r));r.tu.add(3),await L5(r),n&&r.iu.set("Unknown"),await r.remoteSyncer.handleCredentialChange(t),r.tu.delete(3),await O5(r)}async function X5(e,t){var r=e;t?(r.tu.delete(2),await O5(r)):(r.tu.add(2),await L5(r),r.iu.set("Unknown"))}function Z5(t){return t._u||(t._u=(e=t.datastore,r=t.asyncQueue,n={Qt:(async function(e){e.iu.set("Online")}).bind(null,t),zt:(async function(r){r.Ja.forEach((e,t)=>{V5(r,e)})}).bind(null,t),Ht:(async function(e,t){H5(e),j5(e)?(e.iu.za(t),q5(e)):e.iu.set("Unknown")}).bind(null,t),zn:K5.bind(null,t)},(i=e).nr(),new C7(r,i.connection,i.authCredentials,i.appCheckCredentials,i.serializer,n)),t.nu.push(async e=>{e?(t._u.Mn(),j5(t)?q5(t):t.iu.set("Unknown")):(await t._u.stop(),H5(t))})),t._u;var e,r,n,i}function eb(t){return t.ou||(t.ou=(e=t.datastore,r=t.asyncQueue,n={Qt:()=>Promise.resolve(),zt:(async function(e){eb(e).er()}).bind(null,t),Ht:(async function(e,t){if(t&&eb(e).Jn){var r=e,n=t;if(Y_(t=n.code)&&t!==N.ABORTED){let e=r.Ha.shift();eb(r).Mn(),await W5(r,()=>r.remoteSyncer.rejectFailedWrite(e.batchId,n)),await $5(r)}await 0}Y5(e)&&Q5(e)}).bind(null,t),Zn:(async function(e){var t,r=eb(e);for(t of e.Ha)r.Yn(t.mutations)}).bind(null,t),Xn:(async function(e,t,r){let n=e.Ha.shift(),i=e9.from(n,t,r);await W5(e,()=>e.remoteSyncer.applySuccessfulWrite(i)),await $5(e)}).bind(null,t)},(i=e).nr(),new S7(r,i.connection,i.authCredentials,i.appCheckCredentials,i.serializer,n)),t.nu.push(async e=>{e?(t.ou.Mn(),await $5(t)):(await t.ou.stop(),0<t.Ha.length&&(S(x5,`Stopping write stream with ${t.Ha.length} pending writes`),t.Ha=[]))})),t.ou;var e,r,n,i}class tb{constructor(e,t,r,n,i){this.asyncQueue=e,this.timerId=t,this.targetTimeMs=r,this.op=n,this.removalCallback=i,this.deferred=new n2,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,r,n,i){var s=Date.now()+r,s=new tb(e,t,s,n,i);return s.start(r),s}start(e){this.timerHandle=setTimeout(()=>this.handleDelayElapsed(),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){null!==this.timerHandle&&(this.clearTimeout(),this.deferred.reject(new R(N.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 rb(e,t){if(Zm("AsyncQueue",t+": "+e),e0(e))return new R(N.UNAVAILABLE,t+": "+e);throw e}class nb{static emptySet(e){return new nb(e.comparator)}constructor(r){this.comparator=r?(e,t)=>r(e,t)||D.comparator(e.key,t.key):(e,t)=>D.comparator(e.key,t.key),this.keyedMap=ey(),this.sortedSet=new I6(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){var t=this.keyedMap.get(e);return t?this.sortedSet.indexOf(t):-1}get size(){return this.sortedSet.size}forEach(r){this.sortedSet.inorderTraversal((e,t)=>(r(e),!1))}add(e){var t=this.delete(e.key);return t.copy(t.keyedMap.insert(e.key,e),t.sortedSet.insert(e,null))}delete(e){var t=this.get(e);return t?this.copy(this.keyedMap.remove(e),this.sortedSet.remove(t)):this}isEqual(e){if(!(e instanceof nb))return!1;if(this.size!==e.size)return!1;for(var r=this.sortedSet.getIterator(),n=e.sortedSet.getIterator();r.hasNext();){let e=r.getNext().key,t=n.getNext().key;if(!e.isEqual(t))return!1}return!0}toString(){let t=[];return this.forEach(e=>{t.push(e.toString())}),0===t.length?"DocumentSet ()":"DocumentSet (\n  "+t.join("  \n")+"\n)"}copy(e,t){var r=new nb;return r.comparator=this.comparator,r.keyedMap=e,r.sortedSet=t,r}}class ib{constructor(){this.au=new I6(D.comparator)}track(e){var t=e.doc.key,r=this.au.get(t);!r||0!==e.type&&3===r.type?this.au=this.au.insert(t,e):3===e.type&&1!==r.type?this.au=this.au.insert(t,{type:r.type,doc:e.doc}):2===e.type&&2===r.type?this.au=this.au.insert(t,{type:2,doc:e.doc}):2===e.type&&0===r.type?this.au=this.au.insert(t,{type:0,doc:e.doc}):1===e.type&&0===r.type?this.au=this.au.remove(t):1===e.type&&2===r.type?this.au=this.au.insert(t,{type:1,doc:r.doc}):0===e.type&&1===r.type?this.au=this.au.insert(t,{type:2,doc:e.doc}):k(63341,{ft:e,uu:r})}cu(){let r=[];return this.au.inorderTraversal((e,t)=>{r.push(t)}),r}}class sb{constructor(e,t,r,n,i,s,a,o,l){this.query=e,this.docs=t,this.oldDocs=r,this.docChanges=n,this.mutatedKeys=i,this.fromCache=s,this.syncStateChanged=a,this.excludesMetadataChanges=o,this.hasCachedResults=l}static fromInitialDocuments(e,t,r,n,i){let s=[];return t.forEach(e=>{s.push({type:0,doc:e})}),new sb(e,t,nb.emptySet(t),s,r,n,!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)&&Yw(this.query,e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;var t=this.docChanges,r=e.docChanges;if(t.length!==r.length)return!1;for(let n=0;n<t.length;n++)if(t[n].type!==r[n].type||!t[n].doc.isEqual(r[n].doc))return!1;return!0}}class ab{constructor(){this.lu=void 0,this.Eu=[]}hu(){return this.Eu.some(e=>e.Tu())}}class ob{constructor(){this.queries=lb(),this.onlineState="Unknown",this.Pu=new Set}terminate(){var e,r,t,n;e=this,r=new R(N.ABORTED,"Firestore shutting down"),n=(t=e).queries,t.queries=lb(),n.forEach((e,t)=>{for(let e of t.Eu)e.onError(r)})}}function lb(){return new J_(e=>$w(e),Yw)}async function ub(t,r){let e=t,n=3;var i=r.query;let s=e.queries.get(i);s?!s.hu()&&r.Tu()&&(n=2):(s=new ab,n=r.Tu()?0:1);try{switch(n){case 0:s.lu=await e.onListen(i,!0);break;case 1:s.lu=await e.onListen(i,!1);break;case 2:await e.onFirstRemoteStoreListen(i)}}catch(t){let e=rb(t,`Initialization of query '${(Gw(r.query)?Hw:K_)(r.query)}' failed`);return void r.onError(e)}e.queries.set(i,s),s.Eu.push(r),r.Ru(e.onlineState),s.lu&&r.Iu(s.lu)&&cb(e)}async function hb(e,t){var r=e,n=t.query;let i=3;var s=r.queries.get(n);if(s){let e=s.Eu.indexOf(t);0<=e&&(s.Eu.splice(e,1),0===s.Eu.length?i=t.Tu()?0:1:!s.hu()&&t.Tu()&&(i=2))}switch(i){case 0:return r.queries.delete(n),r.onUnlisten(n,!0);case 1:return r.queries.delete(n),r.onUnlisten(n,!1);case 2:return r.onLastRemoteStoreUnlisten(n);default:return}}function cb(e){e.Pu.forEach(e=>{e.next()})}(GN=km=km||{}).Default="default",GN.Cache="cache";class db{constructor(e,t,r){this.query=e,this.Au=t,this.Vu=!1,this.du=null,this.onlineState="Unknown",this.options=r||{}}Iu(t){if(!this.options.includeMetadataChanges){let e=[];for(var r of t.docChanges)3!==r.type&&e.push(r);t=new sb(t.query,t.docs,t.oldDocs,e,t.mutatedKeys,t.fromCache,t.syncStateChanged,!0,t.hasCachedResults)}let e=!1;return this.Vu?this.fu(t)&&(this.Au.next(t),e=!0):this.mu(t,this.onlineState)&&(this.pu(t),e=!0),this.du=t,e}onError(e){this.Au.error(e)}Ru(e){this.onlineState=e;let t=!1;return this.du&&!this.Vu&&this.mu(this.du,e)&&(this.pu(this.du),t=!0),t}mu(e,t){return!e.fromCache||!this.Tu()||(!this.options.waitForSyncWhenOnline||!("Offline"!==t))&&(!e.docs.isEmpty()||e.hasCachedResults||"Offline"===t)}fu(e){var t;return 0<e.docChanges.length||(t=this.du&&this.du.hasPendingWrites!==e.hasPendingWrites,!(!e.syncStateChanged&&!t)&&!0===this.options.includeMetadataChanges)}pu(e){e=sb.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.Vu=!0,this.Au.next(e)}Tu(){return this.options.source!==km.Cache}}class pb{constructor(e,t){this.gu=e,this.byteLength=t}yu(){return"metadata"in this.gu}}class fb{constructor(e){this.serializer=e}Yo(e){return My(this.serializer,e)}Zo(e){return e.metadata.exists?jy(this.serializer,e.document,!1):C_.newNoDocument(this.Yo(e.metadata.name),this.Xo(e.metadata.readTime))}Xo(e){return Py(e)}}class gb{constructor(e,t){this.wu=e,this.serializer=t,this.bu=[],this.vu=[],this.collectionGroups=new Set,this.progress=mb(e)}get queries(){return this.bu}get documents(){return this.vu}o(e){this.progress.bytesLoaded+=e.byteLength;let t=this.progress.documentsLoaded;var r;return e.gu.namedQuery?this.bu.push(e.gu.namedQuery):e.gu.documentMetadata?(this.vu.push({metadata:e.gu.documentMetadata}),e.gu.documentMetadata.exists||++t,r=x.fromString(e.gu.documentMetadata.name),this.collectionGroups.add(r.get(r.length-2))):e.gu.document&&(this.vu[this.vu.length-1].document=e.gu.document,++t),t!==this.progress.documentsLoaded?(this.progress.documentsLoaded=t,{...this.progress}):null}Du(e){let r=new Map,n=new fb(this.serializer);for(var i of e)if(i.metadata.queries){let e=n.Yo(i.metadata.name);for(let t of i.metadata.queries){var s=(r.get(t)||F()).add(e);r.set(t,s)}}return r}async xu(e){let t=await(async(r,n,e,t)=>{let i=r,s=F(),a=X_;for(let r of e){let e=n.Yo(r.metadata.name),t=(r.document&&(s=s.add(e)),n.Zo(r));t.setReadTime(n.Xo(r.metadata.readTime)),a=a.insert(e,t)}let o=i.Qo.newChangeBuffer({trackRemovals:!0}),l=await u5(i,(r=t,q_(F_(x.fromString("__bundle__/docs/"+r)))));return i.persistence.runTransaction("Apply bundle documents","readwrite",t=>l5(t,o,a).next(e=>(o.apply(t),e)).next(e=>i.g_.removeMatchingKeysForTargetId(t,l.targetId).next(()=>i.g_.addMatchingKeys(t,s,l.targetId)).next(()=>i.localDocuments.getLocalViewOfDocuments(t,e.jo,e.Ho)).next(()=>e.jo)))})(e,new fb(this.serializer),this.vu,this.wu.id),r=this.Du(this.documents);for(let t of this.bu)await(async(e,r,n=F())=>{let i=await u5(e,q_(c9(r.bundledQuery))),s=e;return s.persistence.runTransaction("Save named query","readwrite",e=>{var t=Py(r.readTime);return 0<=i.snapshotVersion.compareTo(t)?s.w_.saveNamedQuery(e,r):(t=i.withResumeToken(L6.EMPTY_BYTE_STRING,t),s.$o=s.$o.insert(t.targetId,t),s.g_.updateTargetData(e,t).next(()=>s.g_.removeMatchingKeysForTargetId(e,i.targetId)).next(()=>s.g_.addMatchingKeys(e,n,i.targetId)).next(()=>s.w_.saveNamedQuery(e,r)))})})(e,t,r.get(t.name));return this.progress.taskState="Success",{progress:this.progress,Cu:this.collectionGroups,Fu:t}}}function mb(e){return{taskState:"Running",documentsLoaded:0,bytesLoaded:0,totalDocuments:e.totalDocuments,totalBytes:e.totalBytes}}class vb{constructor(e){this.key=e}}class _b{constructor(e){this.key=e}}class yb{constructor(e,t){this.query=e,this.Ou=t,this.Mu=null,this.hasCachedResults=!1,this.current=!1,this.Nu=F(),this.mutatedKeys=F(),this.Lu=(Gw(e)?g8:W_)(e),this.Bu=new nb(this.Lu)}get Uu(){return this.Ou}ku(e,t){let o=t?t.qu:new ib,l=(t||this).Bu,u=(t||this).mutatedKeys,h=l,c=!1,[d,p]=this.$u(this.query,l);e.inorderTraversal((e,t)=>{var r=l.get(e),n=f8(this.query,t)?t:null,i=!!r&&this.mutatedKeys.has(r.key),s=!!n&&(n.hasLocalMutations||this.mutatedKeys.has(n.key)&&n.hasCommittedMutations);let a=!1;r&&n?r.data.isEqual(n.data)?i!==s&&(o.track({type:3,doc:n}),a=!0):!this.Ku(r,n)&&(o.track({type:2,doc:n}),a=!0,d&&0<this.Lu(n,d)||p&&this.Lu(n,p)<0)&&(c=!0):!r&&n?(o.track({type:0,doc:n}),a=!0):r&&!n&&(o.track({type:1,doc:r}),a=!0,d||p)&&(c=!0),a&&(u=n?(h=h.add(n),s?u.add(e):u.delete(e)):(h=h.delete(e),u.delete(e)))});var r=this.Wu(this.query);if(r)if(Gw(this.query)){let t=[],e=(h.forEach(e=>t.push(e)),d8(this.query,t)),r=new nb(g8(this.query));for(let t of e)r=r.add(t);h.forEach(e=>{r.has(e.key)||(u=u.delete(e.key),o.track({type:1,doc:e}))}),h=r}else{let t=this.Qu(this.query);for(;h.size>r;){let e="F"===t?h.last():h.first();h=h.delete(e.key),u=u.delete(e.key),o.track({type:1,doc:e})}}return{Bu:h,qu:o,Uo:c,mutatedKeys:u}}Wu(e){return Gw(e)?m8(e)?.limit:e.limit||void 0}Qu(e){var t;return Gw(e)?(t=m8(e))&&t.limit<0?"L":"F":e.limitType}$u(e,t){var r;return Gw(e)?(r=m8(e)?.limit,[t.size===r?t.last():null,null]):["F"===e.limitType&&t.size===this.Wu(this.query)?t.last():null,"L"===e.limitType&&t.size===this.Wu(this.query)?t.first():null]}Ku(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}applyChanges(e,t,r,n){var i=this.Bu,s=(this.Bu=e.Bu,this.mutatedKeys=e.mutatedKeys,e.qu.cu()),a=(s.sort((e,t)=>{return r=e.type,n=t.type,(i=e=>{switch(e){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return k(20277,{ft:e})}})(r)-i(n)||this.Lu(e.doc,t.doc);var r,n,i}),this.Gu(r),n=n??!1,t&&!n?this.zu():[]),o=0===this.Nu.size&&this.current&&!n?1:0,l=o!==this.Mu;return this.Mu=o,0!==s.length||l?{snapshot:new sb(this.query,e.Bu,i,s,e.mutatedKeys,0==o,l,!1,!!r&&0<r.resumeToken.approximateByteSize()),ju:a}:{ju:a}}Ru(e){return this.current&&"Offline"===e?(this.current=!1,this.applyChanges({Bu:this.Bu,qu:new ib,mutatedKeys:this.mutatedKeys,Uo:!1},!1)):{ju:[]}}Hu(e){return!this.Ou.has(e)&&!!this.Bu.has(e)&&!this.Bu.get(e).hasLocalMutations}Gu(e){e&&(e.addedDocuments.forEach(e=>this.Ou=this.Ou.add(e)),e.modifiedDocuments.forEach(e=>{}),e.removedDocuments.forEach(e=>this.Ou=this.Ou.delete(e)),this.current=e.current)}zu(){if(!this.current)return[];let t=this.Nu,r=(this.Nu=F(),this.Bu.forEach(e=>{this.Hu(e.key)&&(this.Nu=this.Nu.add(e.key))}),[]);return t.forEach(e=>{this.Nu.has(e)||r.push(new _b(e))}),this.Nu.forEach(e=>{t.has(e)||r.push(new vb(e))}),r}Ju(e){this.Ou=e.Jo,this.Nu=F();var t=this.ku(e.documents);return this.applyChanges(t,!0)}Yu(){return sb.fromInitialDocuments(this.query,this.Bu,this.mutatedKeys,0===this.Mu,this.hasCachedResults)}}let wb="SyncEngine";class bb{constructor(e,t,r){this.query=e,this.targetId=t,this.view=r}}class Tb{constructor(e){this.key=e,this.Zu=!1}}class Eb{constructor(e,t,r,n,i,s){this.localStore=e,this.remoteStore=t,this.eventManager=r,this.sharedClientState=n,this.currentUser=i,this.maxConcurrentLimboResolutions=s,this.Xu={},this.ec=new J_(e=>$w(e),Yw),this.tc=new Map,this.nc=new Set,this.rc=new I6(D.comparator),this.sc=new Map,this._c=new P8,this.oc={},this.ac=new Map,this.uc=s8.Cs(),this.onlineState="Unknown",this.cc=void 0}get isPrimaryClient(){return!0===this.cc}}async function Ib(e,t,r,n){var i=await u5(e.localStore,Gw(t)?t:q_(t)),s=i.targetId,a=e.sharedClientState.addLocalQueryTarget(s,r);let o;return n&&(o=await Cb(e,t,s,"current"===a,i.resumeToken)),e.isPrimaryClient&&r&&F5(e.remoteStore,i),o}async function Cb(n,e,t,r,i){n.lc=(e,t,r)=>(async(e,t,r,n)=>{let i=t.view.ku(r);i.Uo&&(i=await c5(e.localStore,t.query,!1).then(({documents:e})=>t.view.ku(e,i)));var s=n&&n.targetChanges.get(t.targetId),a=n&&null!=n.targetMismatches.get(t.targetId),s=t.view.applyChanges(i,e.isPrimaryClient,s,a);return Lb(e,t.targetId,s.ju),s.snapshot})(n,e,t,r);var s=await c5(n.localStore,e,!0),a=new yb(e,s.Jo),s=a.ku(s.documents),o=py.createSynthesizedTargetChangeForCurrentChange(t,r&&"Offline"!==n.onlineState,i),s=a.applyChanges(s,n.isPrimaryClient,o),o=(Lb(n,t,s.ju),new bb(e,t,a));return n.ec.set(e,o),n.tc.has(t)?n.tc.get(t).push(e):n.tc.set(t,[e]),s.snapshot}async function Sb(t,e,r){var n=zb(t);try{let t=await((e,i)=>{let s=e,a=O2.now(),o=i.reduce((e,t)=>e.add(t.key),F()),l,u;return s.persistence.runTransaction("Locally write mutations","readwrite",n=>{let t=X_,r=F();return s.Qo.getEntries(n,o).next(e=>{(t=e).forEach((e,t)=>{t.isValidDocument()||(r=r.add(e))})}).next(()=>s.localDocuments.getOverlayedDocuments(n,t)).next(e=>{l=e;var t=[];for(let r of i){let e=((e,r)=>{let n=null;for(var i of e.fieldTransforms){let e=r.data.field(i.field),t=Pv(i.transform,e||null);null!=t&&(n=null===n?Sv.empty():n).set(i.field,t)}return n||null})(r,l.get(r.key).overlayedDocument);null!=e&&t.push(new Zv(r.key,e,function i(e){let s=[];return x6(e.fields,(e,r)=>{var n=new T2([e]);if(_v(r)){let t=i(r.mapValue).fields;if(0===t.length)s.push(n);else for(let e of t)s.push(n.child(e))}else s.push(n)}),new R6(s)}(e.value.mapValue),Gv.exists(!0)))}return s.mutationQueue.addMutationBatch(n,a,t,i)}).next(e=>{var t=(u=e).applyToLocalDocumentSet(l,r);return s.documentOverlayCache.saveOverlays(n,e.batchId,t)})}).then(()=>({batchId:u.batchId,changes:ty(l)}))})(n.localStore,e);n.sharedClientState.addPendingMutation(t.batchId);{var i=n;var s=t.batchId;var a=r;let e=i.oc[i.currentUser.toKey()];e=(e=e||new I6(P)).insert(s,a),i.oc[i.currentUser.toKey()]=e}await Fb(n,t.changes),await $5(n.remoteStore)}catch(t){let e=rb(t,"Failed to persist write");r.reject(e)}}async function kb(e,t){let n=e;try{let e=await o5(n.localStore,t);t.targetChanges.forEach((e,t)=>{var r=n.sc.get(t);r&&(A(e.addedDocuments.size+e.modifiedDocuments.size+e.removedDocuments.size<=1,22616),0<e.addedDocuments.size?r.Zu=!0:0<e.modifiedDocuments.size?A(r.Zu,14607):0<e.removedDocuments.size&&(A(r.Zu,42227),r.Zu=!1))}),await Fb(n,e,t)}catch(e){await W2(e)}}function Ab(e,i,t){var s=e;if(s.isPrimaryClient&&0===t||!s.isPrimaryClient&&1===t){let n=[];s.ec.forEach((e,t)=>{var r=t.view.Ru(i);r.snapshot&&n.push(r.snapshot)});{t=s.eventManager;var a=i;var o=t;o.onlineState=a;let r=!1;o.queries.forEach((e,t)=>{for(let e of t.Eu)e.Ru(a)&&(r=!0)}),r&&cb(o)}n.length&&s.Xu.zn(n),s.onlineState=i,s.isPrimaryClient&&s.sharedClientState.setOnlineState(i)}}async function Nb(e,t,r){var n=e;try{let e=await((e,n)=>{let i=e;return i.persistence.runTransaction("Reject batch","readwrite-primary",t=>{let r;return i.mutationQueue.lookupMutationBatch(t,n).next(e=>(A(null!==e,37113),r=e.keys(),i.mutationQueue.removeMutationBatch(t,e))).next(()=>i.mutationQueue.performConsistencyCheck(t)).next(()=>i.documentOverlayCache.removeOverlaysForBatchId(t,r,n)).next(()=>i.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(t,r)).next(()=>i.localDocuments.getDocuments(t,r))})})(n.localStore,t);xb(n,t,r),Pb(n,t),n.sharedClientState.updateMutationState(t,"rejected",r),await Fb(n,e)}catch(r){await W2(r)}}async function Rb(t,r){let n=t;z5(n.remoteStore)||S(wb,"The network is disabled. The task returned by 'awaitPendingWrites()' will not complete until the network is enabled.");try{let e=await(e=>{let t=e;return t.persistence.runTransaction("Get highest unacknowledged batch id","readonly",e=>t.mutationQueue.getHighestUnacknowledgedBatchId(e))})(n.localStore);var i;e===u0?r.resolve():((i=n.ac.get(e)||[]).push(r),n.ac.set(e,i))}catch(t){let e=rb(t,"Initialization of waitForPendingWrites() operation failed");r.reject(e)}}function Pb(e,t){(e.ac.get(t)||[]).forEach(e=>{e.resolve()}),e.ac.delete(t)}function xb(e,t,r){var n=e;let i=n.oc[n.currentUser.toKey()];if(i){let e=i.get(t);e&&(r?e.reject(r):e.resolve(),i=i.remove(t)),n.oc[n.currentUser.toKey()]=i}}function Db(t,e,r=null){t.sharedClientState.removeLocalQueryTarget(e);for(var n of t.tc.get(e))t.ec.delete(n),r&&t.Xu.Ec(n,r);t.tc.delete(e),t.isPrimaryClient&&t._c.s_(e).forEach(e=>{t._c.containsKey(e)||Ob(t,e)})}function Ob(e,t){e.nc.delete(t.path.canonicalString());var r=e.rc.get(t);null!==r&&(U5(e.remoteStore,r),e.rc=e.rc.remove(t),e.sc.delete(r),Mb(e))}function Lb(e,t,r){for(var n of r)n instanceof vb?(e._c.addReference(n.key,t),i=e,s=n,o=a=void 0,a=s.key,o=a.path.canonicalString(),i.rc.get(a)||i.nc.has(o)||(S(wb,"New document in limbo: "+a),i.nc.add(o),Mb(i))):n instanceof _b?(S(wb,"Document no longer in limbo: "+n.key),e._c.removeReference(n.key,t),e._c.containsKey(n.key)||Ob(e,n.key)):k(19791,{hc:n});var i,s,a,o}function Mb(e){for(;0<e.nc.size&&e.rc.size<e.maxConcurrentLimboResolutions;){var t=e.nc.values().next().value,t=(e.nc.delete(t),new D(x.fromString(t))),r=e.uc.next();e.sc.set(r,new Tb(t)),e.rc=e.rc.insert(t,r),F5(e.remoteStore,new r9(q_(F_(t.path)),r,"TargetPurposeLimboResolution",l0.ce))}}async function Fb(e,t,n){let s=e,i=[],a=[],o=[];if(!s.ec.isEmpty()){s.ec.forEach((e,r)=>{o.push(s.lc(r,t,n).then(e=>{var t;(e||n)&&s.isPrimaryClient&&(t=e?!e.fromCache:n?.targetChanges.get(r.targetId)?.current,s.sharedClientState.updateQueryState(r.targetId,t?"current":"not-current")),e&&(i.push(e),t=Q8.vo(r.targetId,e),a.push(t))}))}),await Promise.all(o),s.Xu.zn(i);{var r=s.localStore,l=a;let i=r;try{await i.persistence.runTransaction("notifyLocalViewChanges","readwrite",r=>L.forEach(l,t=>L.forEach(t.wo,e=>i.persistence.referenceDelegate.addReference(r,t.targetId,e)).next(()=>L.forEach(t.bo,e=>i.persistence.referenceDelegate.removeReference(r,t.targetId,e)))))}catch(r){if(!e0(r))throw r;S(e5,"Failed to update sequence numbers: "+r)}for(let e of l){let n=e.targetId;if(!e.fromCache){let e=i.$o.get(n),t=e.snapshotVersion,r=e.withLastLimboFreeSnapshotVersion(t);i.$o=i.$o.insert(n,r)}}}}}async function Ub(e,t,r,n){var i=e,s=await((e,r)=>{let n=e,i=n.mutationQueue;return n.persistence.runTransaction("Lookup mutation documents","readonly",t=>i.ps(t,r).next(e=>e?n.localDocuments.getDocuments(t,e):L.resolve(null)))})(i.localStore,t);null!==s?("pending"===r?await $5(i.remoteStore):"acknowledged"===r||"rejected"===r?(xb(i,t,n||null),Pb(i,t),i.localStore.mutationQueue.bs(t)):k(6720,"Unknown batchState",{Tc:r}),await Fb(i,s)):S(wb,"Cannot apply mutation batch with id: "+t)}async function Vb(r,e){var n,i,s,a=r,o=[],l=[];for(let r of e){let t,e=a.tc.get(r);if(e&&0!==e.length){t=await u5(a.localStore,Gw(e[0])?e[0]:q_(e[0]));for(let r of e){let e=a.ec.get(r),t=(n=e,s=i=void 0,s=await c5((i=a).localStore,n.query,!0),s=n.view.Ju(s),i.isPrimaryClient&&Lb(i,n.targetId,s.ju),await s);t.snapshot&&l.push(t.snapshot)}}else{let e=await d5(a.localStore,r);t=await u5(a.localStore,e),await Cb(a,Bb(e),r,!1,t.resumeToken)}o.push(t)}return a.Xu.zn(l),o}function Bb(e){return R_(e)?e:M_(e.path,e.collectionGroup,e.orderBy,e.filters,e.limit,"F",e.startAt,e.endAt)}async function qb(e,r,n,t){var i=e;if(i.cc)S(wb,"Ignoring unexpected query state notification.");else{var s,a=i.tc.get(r);if(a&&0<a.length)switch(n){case"current":case"not-current":{let e;if(Gw(a[0]))switch(e3(a[0])){case"collection_group":case"collection":e=await p5(i.localStore,n3(a[0]));break;case"documents":e=await((e,t)=>{let r=e,n=F(...i3(t).map(e=>D.fromPath(e)));return r.persistence.runTransaction("Get documents for pipeline","readonly",e=>r.Qo.getEntries(e,n)).then(e=>e)})(i.localStore,a[0]);break;default:e2(""),e=ey()}else e=await p5(i.localStore,(s=a[0]).collectionGroup||(s.path.length%2==1?s.path.lastSegment():s.path.get(s.path.length-2)));let t=dy.createSynthesizedRemoteEventForCurrentChange(r,"current"===n,L6.EMPTY_BYTE_STRING);await Fb(i,e,t);break}case"rejected":await h5(i.localStore,r,!0),Db(i,r,t);break;default:k(64155,n)}}}function jb(e){var t=e;return t.remoteStore.remoteSyncer.applyRemoteEvent=kb.bind(null,t),t.remoteStore.remoteSyncer.getRemoteKeysForTarget=(function(e,t){let n=e,r=n.sc.get(t);if(r&&r.Zu)return F().add(r.key);{let r=F(),e=n.tc.get(t);if(e)for(let t of e??[]){let e=n.ec.get(t);r=r.unionWith(e.view.Uu)}return r}}).bind(null,t),t.remoteStore.remoteSyncer.rejectListen=(async function(e,n,t){let i=e,r=(i.sharedClientState.updateQueryState(n,"rejected",t),i.sc.get(n)),s=r&&r.key;if(s){let e=new I6(D.comparator),t=(e=e.insert(s,C_.newNoDocument(s,O.min())),F().add(s)),r=new dy(O.min(),new Map,new I6(P),e,X_,t);await kb(i,r),i.rc=i.rc.remove(s),i.sc.delete(n),Mb(i)}else await h5(i.localStore,n,!1).then(()=>Db(i,n,t)).catch(W2)}).bind(null,t),t.Xu.zn=(function(r,e){var n=r;let i=!1;for(let r of e){let e=r.query,t=n.queries.get(e);if(t){for(let e of t.Eu)e.Iu(r)&&(i=!0);t.lu=r}}i&&cb(n)}).bind(null,t.eventManager),t.Xu.Ec=(function(e,t,r){var n=e,i=n.queries.get(t);if(i)for(let e of i.Eu)e.onError(r);n.queries.delete(t)}).bind(null,t.eventManager),t}function zb(e){var t=e;return t.remoteStore.remoteSyncer.applySuccessfulWrite=(async function(e,t){var r=e,n=t.batch.batchId;try{let e=await s5(r.localStore,t);xb(r,n,null),Pb(r,n),r.sharedClientState.updateMutationState(n,"acknowledged"),await Fb(r,e)}catch(e){await W2(e)}}).bind(null,t),t.remoteStore.remoteSyncer.rejectFailedWrite=Nb.bind(null,t),t}function Hb(e,t,r){let n=e;(async(e,r,n)=>{try{var i=await r.getMetadata();if(await((e,t)=>{let r=e,n=Py(t.createTime);return r.persistence.runTransaction("hasNewerBundle","readonly",e=>r.w_.getBundleMetadata(e,t.id)).then(e=>!!e&&0<=e.createTime.compareTo(n))})(e.localStore,i))return await r.close(),n._completeWith({taskState:"Success",documentsLoaded:i.totalDocuments,bytesLoaded:i.totalBytes,totalDocuments:i.totalDocuments,totalBytes:i.totalBytes}),Promise.resolve(new Set);n._updateProgress(mb(i));var s=new gb(i,r.serializer);let t=await r.Pc();for(;t;){let e=await s.o(t);e&&n._updateProgress(e),t=await r.Pc()}var a=await s.xu(e.localStore);return await Fb(e,a.Fu,void 0),await((e,t)=>{let r=e;return r.persistence.runTransaction("Save bundle","readwrite",e=>r.w_.saveBundleMetadata(e,t))})(e.localStore,i),n._completeWith(a.progress),Promise.resolve(a.Cu)}catch(e){return e2(wb,"Loading bundle failed with "+e),n._failWith(e),Promise.resolve(new Set)}})(n,t,r).then(e=>{n.sharedClientState.notifyBundleLoaded(e)})}class Kb{constructor(){this.kind="memory",this.synchronizeTabs=!1}async initialize(e){this.serializer=s7(e.databaseInfo.databaseId),this.sharedClientState=this.Rc(e),this.persistence=this.Ic(e),await this.persistence.start(),this.localStore=this.Ac(e),this.gcScheduler=this.Vc(e,this.localStore),this.indexBackfillerScheduler=this.dc(e,this.localStore)}Vc(e,t){return null}dc(e,t){return null}Ac(e){return n5(this.persistence,new Z8,e.initialUser,this.serializer)}Ic(e){return new F8(V8.C_,this.serializer)}Rc(e){return new A5}async terminate(){this.gcScheduler?.stop(),this.indexBackfillerScheduler?.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}}Kb.provider={build:()=>new Kb};class Gb extends Kb{constructor(e){super(),this.cacheSizeBytes=e}Vc(e,t){A(this.persistence.referenceDelegate instanceof B8,46915);var r=this.persistence.referenceDelegate.garbageCollector;return new O7(r,e.asyncQueue,t)}Ic(e){let t=void 0!==this.cacheSizeBytes?R7.withCacheSize(this.cacheSizeBytes):R7.DEFAULT;return new F8(e=>B8.C_(e,t),this.serializer)}}class Wb extends Kb{constructor(e,t,r){super(),this.fc=e,this.cacheSizeBytes=t,this.forceOwnership=r,this.kind="persistent",this.synchronizeTabs=!1}async initialize(e){await super.initialize(e),await this.fc.initialize(this,e),await zb(this.fc.syncEngine),await $5(this.fc.remoteStore),await this.persistence._o(()=>(this.gcScheduler&&!this.gcScheduler.started&&this.gcScheduler.start(),this.indexBackfillerScheduler&&!this.indexBackfillerScheduler.started&&this.indexBackfillerScheduler.start(),Promise.resolve()))}Ac(e){return n5(this.persistence,new Z8,e.initialUser,this.serializer)}Vc(e,t){var r=this.persistence.referenceDelegate.garbageCollector;return new O7(r,e.asyncQueue,t)}dc(e,t){var r=new o0(t,this.persistence);return new a0(e.asyncQueue,r)}Ic(e){var t=Y8(e.databaseInfo.databaseId,e.databaseInfo.persistenceKey),r=void 0!==this.cacheSizeBytes?R7.withCacheSize(this.cacheSizeBytes):R7.DEFAULT;return new G8(this.synchronizeTabs,t,e.clientId,r,e.asyncQueue,N5(),R5(),this.serializer,this.sharedClientState,!!this.forceOwnership)}Rc(e){return new A5}}class $b extends Wb{constructor(e,t){super(e,t,!1),this.fc=e,this.cacheSizeBytes=t,this.synchronizeTabs=!0}async initialize(e){await super.initialize(e);var t=this.fc.syncEngine;this.sharedClientState instanceof k5&&(this.sharedClientState.syncEngine={Na:Ub.bind(null,t),La:qb.bind(null,t),Ba:(async function(e,t,n){let i=jb(e);if(i.cc){for(let r of t)if(i.tc.has(r)&&i.sharedClientState.isActiveQueryTarget(r))S(wb,"Adding an already active target "+r);else{let e=await d5(i.localStore,r),t=await u5(i.localStore,e);await Cb(i,Bb(e),t.targetId,!1,t.resumeToken),F5(i.remoteStore,t)}for(let r of n)i.tc.has(r)&&await h5(i.localStore,r,!1).then(()=>{U5(i.remoteStore,r),Db(i,r)}).catch(W2)}}).bind(null,t),po:(function(e){return e.localStore.persistence.po()}).bind(null,t),Ma:(async function(e,t){let r=e;return p5(r.localStore,t).then(e=>Fb(r,e))}).bind(null,t)},await this.sharedClientState.start()),await this.persistence._o(async e=>{{var t=this.fc.syncEngine,s=e;let i=t;if(jb(i),zb(i),!0===s&&!0!==i.cc){let e=i.sharedClientState.getAllActiveQueryTargets(),t=await Vb(i,e.toArray());i.cc=!0,await X5(i.remoteStore,!0);for(let e of t)F5(i.remoteStore,e)}else if(!1===s&&!1!==i.cc){let r=[],n=Promise.resolve();i.tc.forEach((e,t)=>{i.sharedClientState.isLocalQueryTarget(t)?r.push(t):n=n.then(()=>(Db(i,t),h5(i.localStore,t,!0))),U5(i.remoteStore,t)}),await n,await Vb(i,r);{s=i;let r=s;r.sc.forEach((e,t)=>{U5(r.remoteStore,t)}),r._c.__(),r.sc=new Map,r.rc=new I6(D.comparator)}i.cc=!1,await X5(i.remoteStore,!1)}}await 0,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())})}Rc(e){var t,r=N5();if(k5.C(r))return t=Y8(e.databaseInfo.databaseId,e.databaseInfo.persistenceKey),new k5(r,e.asyncQueue,t,e.clientId,e.initialUser);throw new R(N.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.")}}class Yb{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=>Ab(this.syncEngine,e,1),this.remoteStore.remoteSyncer.handleCredentialChange=(async function(e,t){var r,n,i=e;if(!i.currentUser.isEqual(t)){S(wb,"User change. New user:",t.toKey());let e=await i5(i.localStore,t);i.currentUser=t,n="'waitForPendingWrites' promise is rejected due to a user change.",(r=i).ac.forEach(e=>{e.forEach(e=>{e.reject(new R(N.CANCELLED,n))})}),r.ac.clear(),i.sharedClientState.handleUserChange(t,e.removedBatchIds,e.addedBatchIds),await Fb(i,e.zo)}}).bind(null,this.syncEngine),await X5(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return new ob}createDatastore(e){var t,r,n,i=s7(e.databaseInfo.databaseId),s=(t=e.databaseInfo,new b7(t));return t=e.authCredentials,e=e.appCheckCredentials,r=s,n=i,new k7(t,e,r,n)}createRemoteStore(e){return t=this.localStore,r=this.datastore,e=e.asyncQueue,n=e=>Ab(this.syncEngine,e,0),i=new(p7.C()?p7:c7),new D5(t,r,e,n,i);var t,r,n,i}createSyncEngine(e,t){return r=this.localStore,n=this.remoteStore,i=this.eventManager,s=this.sharedClientState,a=e.initialUser,e=e.maxConcurrentLimboResolutions,t=t,o=new Eb(r,n,i,s,a,e),t&&(o.cc=!0),o;var r,n,i,s,a,o}async terminate(){var e,t;e=this.remoteStore,t=e,S(x5,"RemoteStore shutting down."),t.tu.add(5),await L5(t),t.ru.shutdown(),await!t.iu.set("Unknown"),this.datastore?.terminate(),this.eventManager?.terminate()}}function Qb(t,r=10240){let n=0;return{async read(){var e;return n<t.byteLength?(e={value:t.slice(n,n+r),done:!1},n+=r,e):{done:!0}},async cancel(){},releaseLock(){},closed:Promise.resolve()}}Yb.provider={build:()=>new Yb};class Jb{constructor(e){this.observer=e,this.muted=!1}next(e){this.muted||this.observer.next&&this.mc(this.observer.next,e)}error(e){this.muted||(this.observer.error?this.mc(this.observer.error,e):Zm("Uncaught Error in snapshot listener:",e.toString()))}gc(){this.muted=!0}mc(e,t){setTimeout(()=>{this.muted||e(t)},0)}}class Xb{constructor(e,t){this.yc=e,this.serializer=t,this.metadata=new n2,this.buffer=new Uint8Array,this.wc=new TextDecoder("utf-8"),this.bc().then(e=>{e&&e.yu()?this.metadata.resolve(e.gu.metadata):this.metadata.reject(new Error(`The first element of the bundle is not a metadata, it is
             `+JSON.stringify(e?.gu)))},e=>this.metadata.reject(e))}close(){return this.yc.cancel()}async getMetadata(){return this.metadata.promise}async Pc(){return await this.getMetadata(),this.bc()}async bc(){var e,t,r=await this.vc();return null===r?null:(t=this.wc.decode(r),e=Number(t),isNaN(e)&&this.Sc(`length string (${t}) is not valid number`),t=await this.Dc(e),new pb(JSON.parse(t),r.length+e))}xc(){return this.buffer.findIndex(e=>e==="{".charCodeAt(0))}async vc(){for(;this.xc()<0&&!await this.Cc(););var e,t;return 0===this.buffer.length?null:((e=this.xc())<0&&this.Sc("Reached the end of bundle when a length string is expected."),t=this.buffer.slice(0,e),this.buffer=this.buffer.slice(e),t)}async Dc(e){for(;this.buffer.length<e;)await this.Cc()&&this.Sc("Reached the end of bundle when more is expected.");var t=this.wc.decode(this.buffer.slice(0,e));return this.buffer=this.buffer.slice(e),t}Sc(e){throw this.yc.cancel(),new Error("Invalid bundle format: "+e)}async Cc(){var e,t=await this.yc.read();return t.done||((e=new Uint8Array(this.buffer.length+t.value.length)).set(this.buffer),e.set(t.value,this.buffer.length),this.buffer=e),t.done}}class Zb{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(),0<this.mutations.length)throw this.lastTransactionError=new R(N.INVALID_ARGUMENT,"Firestore transactions require all reads to be executed before all writes."),this.lastTransactionError;var t=await(async(e,t)=>{let l=e,r={documents:t.map(e=>Ly(l.serializer,e))},n=await l.$t("BatchGetDocuments",l.serializer.databaseId,x.emptyPath(),r,t.length),u=new Map,i=(n.forEach(e=>{t=l.serializer;var t,r,n,i,s,a,o="found"in(e=e)?(r=t,A(!!(n=e).found,43571),n.found.name,n.found.updateTime,i=My(r,n.found.name),s=Py(n.found.updateTime),o=n.found.createTime?Py(n.found.createTime):O.min(),a=new Sv({mapValue:{fields:n.found.fields}}),C_.newFoundDocument(i,s,o,a)):"missing"in e?(r=t,A(!!(n=e).missing,3894),A(!!n.readTime,22933),i=My(r,n.missing),s=Py(n.readTime),C_.newNoDocument(i,s)):k(7234,{result:e});u.set(o.key.toString(),o)}),[]);return t.forEach(e=>{var t=u.get(e.toString());A(!!t,55234,{key:e}),i.push(t)}),i})(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 n_(e,this.precondition(e))),this.writtenDocs.add(e.toString())}async commit(){if(this.ensureCommitNotCalled(),this.lastTransactionError)throw this.lastTransactionError;let t=this.readVersions;this.mutations.forEach(e=>{t.delete(e.key.toString())}),t.forEach((e,t)=>{var r=D.fromPath(t);this.mutations.push(new i_(r,this.precondition(r)))});{var r=this.datastore,n=this.mutations;let t=r,e={writes:n.map(e=>zy(t.serializer,e))};await t.Bt("Commit",t.serializer.databaseId,x.emptyPath(),e)}await 0,this.committed=!0}recordVersion(e){let t;if(e.isFoundDocument())t=e.version;else{if(!e.isNoDocument())throw k(50498,{Oc:e.constructor.name});t=O.min()}var r=this.readVersions.get(e.key.toString());if(r){if(!t.isEqual(r))throw new R(N.ABORTED,"Document version changed between two reads.")}else this.readVersions.set(e.key.toString(),t)}precondition(e){var t=this.readVersions.get(e.toString());return!this.writtenDocs.has(e.toString())&&t?t.isEqual(O.min())?Gv.exists(!1):Gv.updateTime(t):Gv.none()}preconditionForUpdate(e){var t=this.readVersions.get(e.toString());if(this.writtenDocs.has(e.toString())||!t)return Gv.exists(!0);if(t.isEqual(O.min()))throw new R(N.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return Gv.updateTime(t)}write(e){this.ensureCommitNotCalled(),this.mutations.push(e)}ensureCommitNotCalled(){}}class eT{constructor(e,t,r,n,i){this.asyncQueue=e,this.datastore=t,this.options=r,this.updateFunction=n,this.deferred=i,this.Mc=r.maxAttempts,this.xn=new T7(this.asyncQueue,"transaction_retry")}Nc(){--this.Mc,this.Lc()}Lc(){this.xn.mn(async()=>{let t=new Zb(this.datastore),e=this.Bc(t);e&&e.then(e=>{this.asyncQueue.enqueueAndForget(()=>t.commit().then(()=>{this.deferred.resolve(e)}).catch(e=>{this.Uc(e)}))}).catch(e=>{this.Uc(e)})})}Bc(e){try{var t=this.updateFunction(e);return!h0(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}}Uc(e){0<this.Mc&&this.kc(e)?(--this.Mc,this.asyncQueue.enqueueAndForget(()=>(this.Lc(),Promise.resolve()))):this.deferred.reject(e)}kc(e){var t;return"FirebaseError"===e?.name&&("aborted"===(t=e.code)||"failed-precondition"===t||"already-exists"===t||!Y_(t))}}let tT="FirestoreClient";class rT{constructor(e,t,r,n,i){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=r,this._databaseInfo=n,this.user=Ym.UNAUTHENTICATED,this.clientId=d2.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=i,this.authCredentials.start(r,async e=>{S(tT,"Received user=",e.uid),await this.authCredentialListener(e),this.user=e}),this.appCheckCredentials.start(r,e=>(S(tT,"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();let r=new n2;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted(async()=>{try{this._onlineComponents&&await this._onlineComponents.terminate(),this._offlineComponents&&await this._offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),r.resolve()}catch(e){var t=rb(e,"Failed to shutdown persistence");r.reject(t)}}),r.promise}}async function nT(e,t){e.asyncQueue.verifyOperationInProgress(),S(tT,"Initializing OfflineComponentProvider");var r=e.configuration;await t.initialize(r);let n=r.initialUser;e.setCredentialChangeListener(async e=>{n.isEqual(e)||(await i5(t.localStore,e),n=e)}),t.persistence.setDatabaseDeletedListener(()=>e.terminate()),e._offlineComponents=t}async function iT(e,r){e.asyncQueue.verifyOperationInProgress();var t=await sT(e);S(tT,"Initializing OnlineComponentProvider"),await r.initialize(t,e.configuration),e.setCredentialChangeListener(e=>J5(r.remoteStore,e)),e.setAppCheckTokenChangeListener((e,t)=>J5(r.remoteStore,t)),e._onlineComponents=r}async function sT(t){if(!t._offlineComponents)if(t._uninitializedComponentsProvider){S(tT,"Using user provided OfflineComponentProvider");try{await nT(t,t._uninitializedComponentsProvider._offline)}catch(e){var r=e;if(!("FirebaseError"===(n=r).name?n.code===N.FAILED_PRECONDITION||n.code===N.UNIMPLEMENTED:!("undefined"!=typeof DOMException&&n instanceof DOMException)||22===n.code||20===n.code||11===n.code))throw r;e2("Error using user provided cache. Falling back to memory cache: "+r),await nT(t,new Kb)}}else S(tT,"Using default OfflineComponentProvider"),await nT(t,new Gb(void 0));var n;return t._offlineComponents}async function aT(e){return e._onlineComponents||(e._uninitializedComponentsProvider?(S(tT,"Using user provided OnlineComponentProvider"),await iT(e,e._uninitializedComponentsProvider._online)):(S(tT,"Using default OnlineComponentProvider"),await iT(e,new Yb))),e._onlineComponents}function oT(e){return sT(e).then(e=>e.persistence)}function lT(e){return sT(e).then(e=>e.localStore)}function uT(e){return aT(e).then(e=>e.remoteStore)}function hT(e){return aT(e).then(e=>e.syncEngine)}async function cT(e){var t=await aT(e),r=t.eventManager;return r.onListen=(async function(e,t,r=!0){var n=jb(e);let i;var s=n.ec.get(t);return i=s?(n.sharedClientState.addLocalQueryTarget(s.targetId),s.view.Yu()):await Ib(n,t,r,!0)}).bind(null,t.syncEngine),r.onUnlisten=(async function(e,t,r){let n=e,i=n.ec.get(t),s=n.tc.get(i.targetId);1<s.length?(n.tc.set(i.targetId,s.filter(e=>!Yw(e,t))),n.ec.delete(t)):n.isPrimaryClient?(n.sharedClientState.removeLocalQueryTarget(i.targetId),n.sharedClientState.isActiveQueryTarget(i.targetId)||await h5(n.localStore,i.targetId,!1).then(()=>{n.sharedClientState.clearQueryState(i.targetId),r&&U5(n.remoteStore,i.targetId),Db(n,i.targetId)}).catch(W2)):(Db(n,i.targetId),await h5(n.localStore,i.targetId,!0))}).bind(null,t.syncEngine),r.onFirstRemoteStoreListen=(async function(e,t){await Ib(jb(e),t,!0,!1)}).bind(null,t.syncEngine),r.onLastRemoteStoreUnlisten=(async function(e,t){var r=e,n=r.ec.get(t),i=r.tc.get(n.targetId);r.isPrimaryClient&&1===i.length&&(r.sharedClientState.removeLocalQueryTarget(n.targetId),U5(r.remoteStore,n.targetId))}).bind(null,t.syncEngine),r}function dT(r){return r.asyncQueue.enqueue(async()=>{var e=await oT(r),t=await uT(r);return e.setNetworkEnabled(!1),(async e=>{var t=e;t.tu.add(0),await L5(t),t.iu.set("Offline")})(t)})}function pT(e,t){let r=new n2;return e.asyncQueue.enqueueAndForget(async()=>(async(e,t,r)=>{try{var n=await((e,t)=>{let r=e;return r.persistence.runTransaction("read document","readonly",e=>r.localDocuments.getDocument(e,t))})(e,t);n.isFoundDocument()?r.resolve(n):n.isNoDocument()?r.resolve(null):r.reject(new R(N.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){n=rb(e,`Failed to get document '${t} from cache`);r.reject(n)}})(await lT(e),t,r)),r.promise}function fT(e,t,u={}){let h=new n2;return e.asyncQueue.enqueueAndForget(async()=>{{var i=await cT(e),s=e.asyncQueue,a=t,o=u,l=h;let r=new Jb({next:e=>{r.gc(),s.enqueueAndForget(()=>hb(i,n));var t=e.docs.has(a);!t&&e.fromCache?l.reject(new R(N.UNAVAILABLE,"Failed to get document because the client is offline.")):t&&e.fromCache&&o&&"server"===o.source?l.reject(new R(N.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.)')):l.resolve(e)},error:e=>l.reject(e)}),n=new db(F_(a.path),r,{includeMetadataChanges:!0,waitForSyncWhenOnline:!0});return ub(i,n)}}),h.promise}function gT(e,t){let r=new n2;return e.asyncQueue.enqueueAndForget(async()=>(async(e,t,r)=>{try{var n=await c5(e,t,!0),i=new yb(t,n.Jo),s=i.ku(n.documents),a=i.applyChanges(s,!1);r.resolve(a.snapshot)}catch(e){n=rb(e,`Failed to execute query '${t} against cache`);r.reject(n)}})(await lT(e),t,r)),r.promise}function mT(o,l,u={}){let h=new n2;return o.asyncQueue.enqueueAndForget(async()=>{{var n=await cT(o),i=o.asyncQueue,e=l,s=u,a=h;let t=new Jb({next:e=>{t.gc(),i.enqueueAndForget(()=>hb(n,r)),e.fromCache&&"server"===s.source?a.reject(new R(N.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.)')):a.resolve(e)},error:e=>a.reject(e)}),r=new db(!1?Xw(e):e,t,{includeMetadataChanges:!0,waitForSyncWhenOnline:!0});return ub(n,r)}}),h.promise}function vT(r,e){let n=new Jb(e);return r.asyncQueue.enqueueAndForget(async()=>{return e=await cT(r),t=n,e.Pu.add(t),void t.next();var e,t}),()=>{n.gc(),r.asyncQueue.enqueueAndForget(async()=>{var e,t;e=await cT(r),t=n,e.Pu.delete(t)})}}function _T(t,r,n){let i=new n2;return t.asyncQueue.enqueueAndForget(async()=>{var e=await aT(t).then(e=>e.datastore);new eT(t.asyncQueue,e,n,r,i).Nc()}),i.promise}function yT(e,t,r,n){r=r,t=s7(t),s="string"==typeof r?ay().encode(r):r,r=((e,t)=>{if(e instanceof Uint8Array)return Qb(e,t);if(e instanceof ArrayBuffer)return Qb(new Uint8Array(e),t);if(e instanceof ReadableStream)return e.getReader();throw new Error("Source of `toByteStreamReader` has to be a ArrayBuffer or ReadableStream")})(s),t=t;let i=new Xb(r,t);var s;e.asyncQueue.enqueueAndForget(async()=>{Hb(await hT(e),i,n)})}function wT(n,i){return n.asyncQueue.enqueue(async()=>{{var e=await lT(n),r=i;let t=e;return t.persistence.runTransaction("Get named query","readonly",e=>t.w_.getNamedQuery(e,r))}})}let bT="AsyncQueue";class TT{constructor(e=Promise.resolve()){this.qc=[],this.$c=!1,this.Kc=[],this.Wc=null,this.Qc=!1,this.Gc=!1,this.zc=[],this.xn=new T7(this,"async_queue_retry"),this.jc=()=>{var e=R5();e&&S(bT,"Visibility state changed to "+e.visibilityState),this.xn.gn()},this.Hc=e;var t=R5();t&&"function"==typeof t.addEventListener&&t.addEventListener("visibilitychange",this.jc)}get isShuttingDown(){return this.$c}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.Jc(),this.Yc(e)}enterRestrictedMode(e){var t;this.$c||(this.$c=!0,this.Gc=e||!1,(t=R5())&&"function"==typeof t.removeEventListener&&t.removeEventListener("visibilitychange",this.jc))}enqueue(e){if(this.Jc(),this.$c)return new Promise(()=>{});let t=new n2;return this.Yc(()=>this.$c&&this.Gc?Promise.resolve():(e().then(t.resolve,t.reject),t.promise)).then(()=>t.promise)}enqueueRetryable(e){this.enqueueAndForget(()=>(this.qc.push(e),this.Zc()))}async Zc(){if(0!==this.qc.length){try{await this.qc[0](),this.qc.shift(),this.xn.reset()}catch(e){if(!e0(e))throw e;S(bT,"Operation failed with retryable error: "+e)}0<this.qc.length&&this.xn.mn(()=>this.Zc())}}Yc(e){var t=this.Hc.then(()=>(this.Qc=!0,e().catch(e=>{throw this.Wc=e,this.Qc=!1,Zm("INTERNAL UNHANDLED ERROR: ",ET(e)),e}).then(e=>(this.Qc=!1,e))));return this.Hc=t}enqueueAfterDelay(e,t,r){this.Jc(),-1<this.zc.indexOf(e)&&(t=0);var n=tb.createAndSchedule(this,e,t,r,e=>this.Xc(e));return this.Kc.push(n),n}Jc(){this.Wc&&k(47125,{el:ET(this.Wc)})}verifyOperationInProgress(){}async tl(){for(var e;await(e=this.Hc),e!==this.Hc;);}nl(e){for(var t of this.Kc)if(t.timerId===e)return!0;return!1}rl(t){return this.tl().then(()=>{this.Kc.sort((e,t)=>e.targetTimeMs-t.targetTimeMs);for(var e of this.Kc)if(e.skipDelay(),"all"!==t&&e.timerId===t)break;return this.tl()})}il(e){this.zc.push(e)}Xc(e){var t=this.Kc.indexOf(e);this.Kc.splice(t,1)}}function ET(e){let t=e.message||"";return t=e.stack?e.stack.includes(e.message)?e.stack:e.message+"\n"+e.stack:t}class IT{constructor(){this._progressObserver={},this._taskCompletionResolver=new n2,this._lastProgress={taskState:"Running",totalBytes:0,totalDocuments:0,bytesLoaded:0,documentsLoaded:0}}onProgress(e,t,r){this._progressObserver={next:e,error:t,complete:r}}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)}}var CT,ST;class kT extends V7{constructor(e,t,r,n){super(e,t,r,n),this.type="firestore",this._queue=new TT,this._persistenceKey=n?.name||"[DEFAULT]"}async _terminate(){var e;this._firestoreClient&&(e=this._firestoreClient.terminate(),this._queue=new TT(e),this._firestoreClient=void 0,await e)}}function AT(e){if(e._terminated)throw new R(N.FAILED_PRECONDITION,"The client has already been terminated.");return e._firestoreClient||NT(e),e._firestoreClient}function NT(e){var t,r,n,i,s,a=e._freezeSettings(),o=(s=e._databaseId,t=e._app?.options.appId||"",r=e._persistenceKey,n=e._app?.options.apiKey,i=a,new W6(s,t,r,i.host,i.ssl,i.experimentalForceLongPolling,i.experimentalAutoDetectLongPolling,h7(i.experimentalLongPollingOptions),i.useFetchStreams,i.isUsingEmulator,n));e._componentsProvider||a.localCache?._offlineComponentProvider&&a.localCache?._onlineComponentProvider&&(e._componentsProvider={_offline:a.localCache._offlineComponentProvider,_online:a.localCache._onlineComponentProvider}),e._firestoreClient=new rT(e._authCredentials,e._appCheckCredentials,e._queue,o,e._componentsProvider&&(s=e._componentsProvider,a=s?._online.build(),{_offline:s?._offline.build(a),_online:a}))}function RT(e,t,r){if((e=N2(e,kT))._firestoreClient||e._terminated)throw new R(N.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 R(N.FAILED_PRECONDITION,"SDK cache is already specified.");e._componentsProvider={_online:t,_offline:r},NT(e)}function PT(r){if(r._initialized&&!r._terminated)throw new R(N.FAILED_PRECONDITION,"Persistence can only be cleared before a Firestore instance is initialized or after it is terminated.");let n=new n2;return r._queue.enqueueAndForgetEvenWhileRestricted(async()=>{try{e=Y8(r._databaseId,r._persistenceKey),await(Q2.C()?(t=e+K8,void await Q2.delete(t)):Promise.resolve()),n.resolve()}catch(e){n.reject(e)}var e,t}),n.promise}function xT(e){return(r=AT(e=N2(e,kT))).asyncQueue.enqueue(async()=>{var e=await oT(r),t=await uT(r);return e.setNetworkEnabled(!0),(e=t).tu.delete(0),O5(e)});var r}class DT{convertValue(e,t="none"){switch(iv(e)){case 0:return null;case 1:return e.booleanValue;case 2:return U6(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(V6(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 k(62114,{value:e})}}convertObject(e,t){return this.convertObjectMap(e.fields,t)}convertObjectMap(e,r="none"){let n={};return x6(e,(e,t)=>{n[e]=this.convertValue(t,r)}),n}convertVectorValue(e){var t=e.fields?.[ev].arrayValue?.values?.map(e=>U6(e.doubleValue));return new W7(t)}convertGeoPoint(e){return new u7(U6(e.latitude),U6(e.longitude))}convertArray(e,t){return(e.values||[]).map(e=>this.convertValue(e,t))}convertServerTimestamp(e,t){switch(t){case"previous":var r=K6(e);return null==r?null:this.convertValue(r,t);case"estimate":return this.convertTimestamp(G6(e));default:return null}}convertTimestamp(e){var t=F6(e);return new O2(t.seconds,t.nanos)}convertDocumentKey(e,t){var r=x.fromString(e),n=(A(t7(r),9688,{name:e}),new Y6(r.get(1),r.get(3))),r=new D(r.popFirst(5));return n.isEqual(t)||Zm(`Document ${r} contains a document reference within a different database (${n.projectId}/${n.database}) which is not supported. It will be treated as a reference in the current database (${t.projectId}/${t.database}) instead.`),r}}class OT extends DT{constructor(e){super(),this.firestore=e}convertBytes(e){return new a7(e)}convertReference(e){var t=this.convertDocumentKey(e,this.firestore._databaseId);return new q7(this.firestore,null,t)}}let LT="@firebase/firestore";function MT(t){var r=t,t=["next","error","complete"];if("object"==typeof r&&null!==r){var n=r;for(let e of t)if(e in n&&"function"==typeof n[e])return 1}}class FT{constructor(e,t,r,n,i){this._firestore=e,this._userDataWriter=t,this._key=r,this._document=n,this._converter=i}get id(){return this._key.path.lastSegment()}get ref(){return new q7(this._firestore,this._converter,this._key)}exists(){return null!==this._document}data(){var e;if(this._document)return this._converter?(e=new UT(this._firestore,this._userDataWriter,this._key,this._document,null),this._converter.fromFirestore(e)):this._userDataWriter.convertValue(this._document.data.value)}_fieldsProto(){return this._document?.data.clone().value.mapValue.fields??void 0}get(e){if(this._document){var t=this._document.data.field(g4("DocumentSnapshot.get",e));if(null!==t)return this._userDataWriter.convertValue(t)}}}class UT extends FT{data(){return super.data()}}function VT(e){if("L"===e.limitType&&0===e.explicitOrderBy.length)throw new R(N.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class BT{}class qT extends BT{}function jT(e,t,...r){let n=[];t instanceof BT&&n.push(t);var t=n=n.concat(r),i=t.filter(e=>!1).length,s=t.filter(e=>e instanceof zT).length;if(1<i||0<i&&0<s)throw new R(N.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(...)))`.");for(let t of n)e=t._apply(e);return e}class zT extends qT{constructor(e,t,r){super(),this._field=e,this._op=t,this._value=r,this.type="where"}static _create(e,t,r){return new zT(e,t,r)}_apply(e){var t=this._parse(e);return JT(e._query,t),new B7(e.firestore,e.converter,j_(e._query,t))}_parse(e){var t=e4(e.firestore);{var n=e._query,i="where",s=t,a=e.firestore._databaseId,o=(e=this._field,this._op),l=this._value;let r;if(e.isKeyField()){if("array-contains"===o||"array-contains-any"===o)throw new R(N.INVALID_ARGUMENT,`Invalid Query. You can't perform '${o}' queries on documentId().`);if("in"===o||"not-in"===o){QT(l,o);let e=[];for(let t of l)e.push(YT(a,n,t));r={arrayValue:{values:e}}}else r=YT(a,n,l)}else"in"!==o&&"not-in"!==o&&"array-contains-any"!==o||QT(l,o),r=h4(s,i,l,"in"===o||"not-in"===o);return M.create(e,o,r)}}}(class extends BT{});class HT extends qT{constructor(e,t){super(),this._field=e,this._direction=t,this.type="orderBy"}static _create(e,t){return new HT(e,t)}_apply(e){var t=((e,t,r)=>{if(null!==e.startAt)throw new R(N.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(null!==e.endAt)throw new R(N.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");return new I_(t,r)})(e._query,this._field,this._direction);return new B7(e.firestore,e.converter,(t=(e=e._query).explicitOrderBy.concat([t]),new L_(e.path,e.collectionGroup,t,e.filters.slice(),e.limit,e.limitType,e.startAt,e.endAt)))}}class KT extends qT{constructor(e,t,r){super(),this.type=e,this._limit=t,this._limitType=r}static _create(e,t,r){return new KT(e,t,r)}_apply(e){return new B7(e.firestore,e.converter,z_(e._query,this._limit,this._limitType))}}class GT extends qT{constructor(e,t,r){super(),this.type=e,this._docOrFields=t,this._inclusive=r}static _create(e,t,r){return new GT(e,t,r)}_apply(e){var t,r=$T(e,this.type,this._docOrFields,this._inclusive);return new B7(e.firestore,e.converter,(e=e._query,t=r,new L_(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),e.limit,e.limitType,t,e.endAt)))}}class WT extends qT{constructor(e,t,r){super(),this.type=e,this._docOrFields=t,this._inclusive=r}static _create(e,t,r){return new WT(e,t,r)}_apply(e){var t,r=$T(e,this.type,this._docOrFields,this._inclusive);return new B7(e.firestore,e.converter,(e=e._query,t=r,new L_(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),e.limit,e.limitType,e.startAt,t)))}}function $T(e,r,n,i){if(n[0]=w(n[0]),n[0]instanceof FT){var s=e._query,a=e.firestore._databaseId,o=r,l=n[0]._document,u=i;if(!l)throw new R(N.NOT_FOUND,`Can't use a DocumentSnapshot that doesn't exist for ${o}().`);var h=[];for(let t of B_(s))if(t.field.isKeyField())h.push(cv(a,l.key));else{let e=l.data.field(t.field);if(H6(e))throw new R(N.INVALID_ARGUMENT,'Invalid query. You are trying to start or end a query using a document for which the field "'+t.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){let e=t.field.canonicalString();throw new R(N.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.`)}h.push(e)}return new s_(h,u)}var t=e4(e.firestore),c=e._query,d=e.firestore._databaseId,p=t,f=r,g=n,o=i,m=c.explicitOrderBy;if(g.length>m.length)throw new R(N.INVALID_ARGUMENT,`Too many arguments provided to ${f}(). The number of arguments must be less than or equal to the number of orderBy() clauses`);var v=[];for(let y=0;y<g.length;y++){var _=g[y];if(m[y].field.isKeyField()){if("string"!=typeof _)throw new R(N.INVALID_ARGUMENT,`Invalid query. Expected a string for document ID in ${f}(), but got a `+typeof _);if(!V_(c)&&-1!==_.indexOf("/"))throw new R(N.INVALID_ARGUMENT,`Invalid query. When querying a collection and ordering by documentId(), the value passed to ${f}() must be a plain document ID, but '${_}' contains a slash.`);let e=c.path.child(x.fromString(_));if(!D.isDocumentKey(e))throw new R(N.INVALID_ARGUMENT,`Invalid query. When querying a collection group and ordering by documentId(), the value passed to ${f}() must result in a valid document path, but '${e}' is not because it contains an odd number of segments.`);let t=new D(e);v.push(cv(d,t))}else{let e=h4(p,f,_);v.push(e)}}return new s_(v,o)}function YT(e,t,r){if("string"==typeof(r=w(r))){if(""===r)throw new R(N.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!V_(t)&&-1!==r.indexOf("/"))throw new R(N.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${r}' contains a '/' character.`);var n=t.path.child(x.fromString(r));if(D.isDocumentKey(n))return cv(e,new D(n));throw new R(N.INVALID_ARGUMENT,`Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${n}' is not because it has an odd number of segments (${n.length}).`)}if(r instanceof q7)return cv(e,r._key);throw new R(N.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${A2(r)}.`)}function QT(e,t){if(!Array.isArray(e)||0===e.length)throw new R(N.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${t.toString()}' filters.`)}function JT(e,t){var r=((t,r)=>{for(var n of t)for(let e of n.getFlattenedFilters())if(0<=r.indexOf(e.op))return e.op;return null})(e.filters,(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!==r)throw r===t.op?new R(N.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${t.op.toString()}' filter.`):new R(N.INVALID_ARGUMENT,`Invalid query. You cannot use '${t.op.toString()}' filters with '${r.toString()}' filters.`)}function XT(e,t,r){return e?r&&(r.merge||r.mergeFields)?e.toFirestore(t,r):e.toFirestore(t):t}class ZT extends DT{constructor(e){super(),this.firestore=e}convertBytes(e){return new a7(e)}convertReference(e){var t=this.convertDocumentKey(e,this.firestore._databaseId);return new q7(this.firestore,null,t)}}class eE{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}}class tE extends FT{constructor(e,t,r,n,i,s){super(e,t,r,n,s),this._firestore=e,this._firestoreImpl=e,this.metadata=i}exists(){return super.exists()}data(e={}){var t;if(this._document)return this._converter?(t=new rE(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null),this._converter.fromFirestore(t,e)):this._userDataWriter.convertValue(this._document.data.value,e.serverTimestamps)}get(e,t={}){if(this._document){var r=this._document.data.field(g4("DocumentSnapshot.get",e));if(null!==r)return this._userDataWriter.convertValue(r,t.serverTimestamps)}}toJSON(){if(this.metadata.hasPendingWrites)throw new R(N.FAILED_PRECONDITION,"DocumentSnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");var e=this._document,t={};return t.type=tE._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}}tE._jsonSchemaVersion="firestore/documentSnapshot/1.0",tE._jsonSchema={type:P2("string",tE._jsonSchemaVersion),bundleSource:P2("string","DocumentSnapshot"),bundleName:P2("string"),bundle:P2("string")};class rE extends tE{data(e={}){return super.data(e)}}class nE{constructor(e,t,r,n){this._firestore=e,this._userDataWriter=t,this._snapshot=n,this.metadata=new eE(n.hasPendingWrites,n.fromCache),this.query=r}get docs(){let t=[];return this.forEach(e=>t.push(e)),t}get size(){return this._snapshot.docs.size}get empty(){return 0===this.size}forEach(t,r){this._snapshot.docs.forEach(e=>{t.call(r,new rE(this._firestore,this._userDataWriter,e.key,e,new eE(this._snapshot.mutatedKeys.has(e.key),this._snapshot.fromCache),this.query.converter))})}docChanges(e={}){var t=!!e.includeMetadataChanges;if(t&&this._snapshot.excludesMetadataChanges)throw new R(N.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=((s,t)=>{if(s._snapshot.oldDocs.isEmpty()){let r=0;return s._snapshot.docChanges.map(e=>{Gw(s._snapshot.query)?g8(s._snapshot.query):W_(s.query._query);var t=new rE(s._firestore,s._userDataWriter,e.doc.key,e.doc,new eE(s._snapshot.mutatedKeys.has(e.doc.key),s._snapshot.fromCache),s.query.converter);return e.doc,{type:"added",doc:t,oldIndex:-1,newIndex:r++}})}{let i=s._snapshot.oldDocs;return s._snapshot.docChanges.filter(e=>t||3!==e.type).map(e=>{var t=new rE(s._firestore,s._userDataWriter,e.doc.key,e.doc,new eE(s._snapshot.mutatedKeys.has(e.doc.key),s._snapshot.fromCache),s.query.converter);let r=-1,n=-1;return 0!==e.type&&(r=i.indexOf(e.doc.key),i=i.delete(e.doc.key)),1!==e.type&&(i=i.add(e.doc),n=i.indexOf(e.doc.key)),{type:(e=>{switch(e){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return k(61501,{type:e})}})(e.type),doc:t,oldIndex:r,newIndex:n}})}})(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}toJSON(){if(this.metadata.hasPendingWrites)throw new R(N.FAILED_PRECONDITION,"QuerySnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");var e={};e.type=nE._jsonSchemaVersion,e.bundleSource="QuerySnapshot",e.bundleName=d2.newId(),this._firestore._databaseId.database,this._firestore._databaseId.projectId;let t=[],r=[],n=[];return this.docs.forEach(e=>{null!==e._document&&(t.push(e._document),r.push(this._userDataWriter.convertObjectMap(e._document.data.value.mapValue.fields,"previous")),n.push(e.ref.path))}),e.bundle=(this._firestore,this.query._query,"NOT SUPPORTED"),e}}function iE(e,t){return e instanceof tE&&t instanceof tE?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 nE&&t instanceof nE&&e._firestore===t._firestore&&G7(e.query,t.query)&&e.metadata.isEqual(t.metadata)&&e._snapshot.isEqual(t._snapshot)}nE._jsonSchemaVersion="firestore/querySnapshot/1.0",nE._jsonSchema={type:P2("string",nE._jsonSchemaVersion),bundleSource:P2("string","QuerySnapshot"),bundleName:P2("string"),bundle:P2("string")};let sE={maxAttempts:5};class aE{constructor(e,t){this._firestore=e,this._commitHandler=t,this._mutations=[],this._committed=!1,this._dataReader=e4(e)}set(e,t,r){this._verifyNotCommitted();var n=oE(e,this._firestore),i=XT(n.converter,t,r),i=t4(this._dataReader,"WriteBatch.set",n._key,i,null!==n.converter,r);return this._mutations.push(i.toMutation(n._key,Gv.none())),this}update(e,t,r,...n){this._verifyNotCommitted();var i=oE(e,this._firestore),s="string"==typeof(t=w(t))||t instanceof o7?u4(this._dataReader,"WriteBatch.update",i._key,t,r,n):l4(this._dataReader,"WriteBatch.update",i._key,t);return this._mutations.push(s.toMutation(i._key,Gv.exists(!0))),this}delete(e){this._verifyNotCommitted();var t=oE(e,this._firestore);return this._mutations=this._mutations.concat(new n_(t._key,Gv.none())),this}commit(){return this._verifyNotCommitted(),this._committed=!0,0<this._mutations.length?this._commitHandler(this._mutations):Promise.resolve()}_verifyNotCommitted(){if(this._committed)throw new R(N.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")}}function oE(e,t){if((e=w(e)).firestore!==t)throw new R(N.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return e}class lE extends class{constructor(e,t){this._firestore=e,this._transaction=t,this._dataReader=e4(e)}get(e){let r=oE(e,this._firestore),n=new ZT(this._firestore);return this._transaction.lookup([r._key]).then(e=>{if(!e||1!==e.length)return k(24041);var t=e[0];if(t.isFoundDocument())return new FT(this._firestore,n,t.key,t,r.converter);if(t.isNoDocument())return new FT(this._firestore,n,r._key,null,r.converter);throw k(18433,{doc:t})})}set(e,t,r){var n=oE(e,this._firestore),i=XT(n.converter,t,r),i=t4(this._dataReader,"Transaction.set",n._key,i,null!==n.converter,r);return this._transaction.set(n._key,i),this}update(e,t,r,...n){var i=oE(e,this._firestore),s="string"==typeof(t=w(t))||t instanceof o7?u4(this._dataReader,"Transaction.update",i._key,t,r,n):l4(this._dataReader,"Transaction.update",i._key,t);return this._transaction.update(i._key,s),this}delete(e){var t=oE(e,this._firestore);return this._transaction.delete(t._key),this}}{constructor(e,t){super(e,t),this._firestore=e}get(e){let t=oE(e,this._firestore),r=new OT(this._firestore);return super.get(e).then(e=>new tE(this._firestore,r,t._key,e._document,new eE(!1,!1),t.converter))}}function uE(e,t,r){e=N2(e,q7);var n=N2(e.firestore,kT),i=XT(e.converter,t,r);return dE(n,[t4(e4(n),"setDoc",e._key,i,null!==e.converter,r).toMutation(e._key,Gv.none())])}function hE(e,t,r,...n){e=N2(e,q7);var i=N2(e.firestore,kT),s=e4(i);return dE(i,[("string"==typeof(t=w(t))||t instanceof o7?u4(s,"updateDoc",e._key,t,r,n):l4(s,"updateDoc",e._key,t)).toMutation(e._key,Gv.exists(!0))])}function cE(n,...i){n=w(n);let e={includeMetadataChanges:!1,source:"default"},s=0,r={includeMetadataChanges:(e="object"!=typeof i[s]||MT(i[s])?e:i[s++]).includeMetadataChanges,source:e.source};if(MT(i[s])){let e=i[s];i[s]=e.next?.bind(e),i[s+1]=e.error?.bind(e),i[s+2]=e.complete?.bind(e)}let a,o,l;if(n instanceof q7)o=N2(n.firestore,kT),l=F_(n._key.path),a={next:e=>{i[s]&&i[s](pE(o,n,e))},error:i[s+1],complete:i[s+2]};else{let t=N2(n,B7),r=(o=N2(t.firestore,kT),l=t._query,new OT(o));a={next:e=>{i[s]&&i[s](new nE(o,r,t,e))},error:i[s+1],complete:i[s+2]},VT(n._query)}var u=AT(o);{var h=u,c=l,d=r,p=a;let e=new Jb(p),t=new db(c,e,d);return h.asyncQueue.enqueueAndForget(async()=>ub(await cT(h),t)),()=>{e.gc(),h.asyncQueue.enqueueAndForget(async()=>hb(await cT(h),t))}}}function dE(e,t){var r=AT(e);{var n=r,i=t;let e=new n2;return n.asyncQueue.enqueueAndForget(async()=>Sb(await hT(n),i,e)),e.promise}}function pE(e,t,r){var n=r.docs.get(t._key),i=new OT(e);return new tE(e,i,t._key,n,new eE(r.hasPendingWrites,r.fromCache),t.converter)}CT=!0,t=Vt,Qm=t,Rt(new h("firestore",(e,{instanceIdentifier:t,options:r})=>{var n=e.getProvider("app").getImmediate(),n=new kT(new o2(e.getProvider("auth-internal")),new c2(n,e.getProvider("app-check-internal")),((e,t)=>{if(Object.prototype.hasOwnProperty.apply(e.options,["projectId"]))return new Y6(e.options.projectId,t);throw new R(N.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.')})(n,t),n);return r={useFetchStreams:CT,...r},n._setSettings(r),n},"PUBLIC").setMultipleInstances(!0)),zt(LT,"4.16.0",zS),zt(LT,"4.16.0","esm2020");let fE="@firebase/firestore-compat",gE="0.4.11";function mE(e,t){if(void 0===t)return{merge:!1};if(void 0!==t.mergeFields&&void 0!==t.merge)throw new R("invalid-argument",`Invalid options passed to function ${e}(): You cannot `+'specify both "merge" and "mergeFields".');return t}function vE(){if("undefined"==typeof Uint8Array)throw new R("unimplemented","Uint8Arrays are not available in this environment.")}function _E(){if("undefined"==typeof atob)throw new R("unimplemented","Blobs are unavailable in Firestore in this environment.")}class yE{constructor(e){this._delegate=e}static fromBase64String(e){return _E(),new yE(a7.fromBase64String(e))}static fromUint8Array(e){return vE(),new yE(a7.fromUint8Array(e))}toBase64(){return _E(),this._delegate.toBase64()}toUint8Array(){return vE(),this._delegate.toUint8Array()}isEqual(e){return this._delegate.isEqual(e._delegate)}toString(){return"Blob(base64: "+this.toBase64()+")"}}function wE(e){var t=["next","error","complete"];if("object"==typeof e&&null!==e){var r,n=e;for(r of t)if(r in n&&"function"==typeof n[r])return 1}}class bE{enableIndexedDbPersistence(e,r){{e=e._delegate;var n={forceOwnership:r};e2("enableIndexedDbPersistence() will be deprecated in the future, you can use `FirestoreSettings.cache` instead.");let t=e._freezeSettings();return RT(e,Yb.provider,{build:e=>new Wb(e,t.cacheSizeBytes,n?.forceOwnership)}),Promise.resolve()}}enableMultiTabIndexedDbPersistence(e){return(async e=>{e2("enableMultiTabIndexedDbPersistence() will be deprecated in the future, you can use `FirestoreSettings.cache` instead.");let t=e._freezeSettings();RT(e,Yb.provider,{build:e=>new $b(e,t.cacheSizeBytes)})})(e._delegate)}clearIndexedDbPersistence(e){return PT(e._delegate)}}class TE{constructor(e,t,r){this._delegate=t,this._persistenceProvider=r,this.INTERNAL={delete:()=>this.terminate()},e instanceof Y6||(this._appCompat=e)}get _databaseId(){return this._delegate._databaseId}settings(e){var t=this._delegate._getSettings();e.merge||t.host===e.host||e2("You are overriding the original host. If you did not intend to override your settings, use {merge: true}."),e.merge&&delete(e={...t,...e}).merge,this._delegate._setSettings(e)}useEmulator(i,s,a={}){{var[i,s,a,o={}]=[this._delegate,i,s,a];i=N2(i,V7);let e=ze(s),t=i._getSettings(),r={...t,emulatorOptions:i._getEmulatorOptions()},n=s+":"+a;e&&He("https://"+n),t.host!==F7&&t.host!==n&&e2("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used.");var l={...t,host:n,ssl:e,emulatorOptions:o};if(!Ie(l,r)&&(i._setSettings(l),o.mockUserToken)){let t,r;if("string"==typeof o.mockUserToken)t=o.mockUserToken,r=Ym.MOCK_USER;else{t=ee(o.mockUserToken,i._app?.options.projectId);let e=o.mockUserToken.sub||o.mockUserToken.user_id;if(!e)throw new R(N.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");r=new Ym(e)}i._authCredentials=new a2(new i2(t,r))}}}enableNetwork(){return xT(this._delegate)}disableNetwork(){return dT(AT(N2(this._delegate,kT)))}enablePersistence(e){let t=!1,r=!1;return e&&(t=!!e.synchronizeTabs,r=!!e.experimentalForceOwningTab,I2("synchronizeTabs",t,"experimentalForceOwningTab",r)),t?this._persistenceProvider.enableMultiTabIndexedDbPersistence(this):this._persistenceProvider.enableIndexedDbPersistence(this,r)}clearPersistence(){return this._persistenceProvider.clearIndexedDbPersistence(this)}terminate(){return this._appCompat&&(this._appCompat._removeServiceInstance("firestore-compat"),this._appCompat._removeServiceInstance("firestore")),this._delegate._delete()}waitForPendingWrites(){var t=this._delegate;{var r=AT(t=N2(t,kT));let e=new n2;return r.asyncQueue.enqueueAndForget(async()=>Rb(await hT(r),e)),e.promise}}onSnapshotsInSync(e){return t=this._delegate,e=e,vT(AT(t=N2(t,kT)),MT(e)?e:{next:e});var t}get app(){if(this._appCompat)return this._appCompat;throw new R("failed-precondition","Firestore was not initialized using the Firebase SDK. 'app' is not available")}collection(e){try{return new ME(this,z7(this._delegate,e))}catch(e){throw AE(e,"collection()","Firestore.collection()")}}doc(e){try{return new kE(this,H7(this._delegate,e))}catch(e){throw AE(e,"doc()","Firestore.doc()")}}collectionGroup(e){try{return new DE(this,((e,t)=>{if(e=N2(e,V7),E2("collectionGroup","collection id",t),0<=t.indexOf("/"))throw new R(N.INVALID_ARGUMENT,`Invalid collection ID '${t}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);return new B7(e,null,(e=t,new L_(x.emptyPath(),e)))})(this._delegate,e))}catch(e){throw AE(e,"collectionGroup()","Firestore.collectionGroup()")}}runTransaction(t){var r=this._delegate,n=e=>t(new IE(this,e)),e=void 0,i=(r=N2(r,kT),{...sE,...e});if(i.maxAttempts<1)throw new R(N.INVALID_ARGUMENT,"Max attempts must be at least 1");return _T(AT(r),e=>n(new lE(r,e)),i)}batch(){return AT(this._delegate),new CE(new aE(this._delegate,e=>dE(this._delegate,e)))}loadBundle(e){return t=this._delegate,e=e,r=AT(t=N2(t,kT)),n=new IT,yT(r,t._databaseId,e,n),n;var t,r,n}namedQuery(e){return t=this._delegate,e=e,wT(AT(t=N2(t,kT)),e).then(e=>e?new B7(t,null,e.query):null).then(e=>e?new DE(this,e):null);var t}}class EE extends DT{constructor(e){super(),this.firestore=e}convertBytes(e){return new yE(new a7(e))}convertReference(e){var t=this.convertDocumentKey(e,this.firestore._databaseId);return kE.forKey(t,this.firestore,null)}}class IE{constructor(e,t){this._firestore=e,this._delegate=t,this._userDataWriter=new EE(e)}get(e){let t=FE(e);return this._delegate.get(t).then(e=>new PE(this._firestore,new tE(this._firestore._delegate,this._userDataWriter,e._key,e._document,e.metadata,t.converter)))}set(e,t,r){var n=FE(e);return r?(mE("Transaction.set",r),this._delegate.set(n,t,r)):this._delegate.set(n,t),this}update(e,t,r,...n){var i=FE(e);return 2===arguments.length?this._delegate.update(i,t):this._delegate.update(i,t,r,...n),this}delete(e){var t=FE(e);return this._delegate.delete(t),this}}class CE{constructor(e){this._delegate=e}set(e,t,r){var n=FE(e);return r?(mE("WriteBatch.set",r),this._delegate.set(n,t,r)):this._delegate.set(n,t),this}update(e,t,r,...n){var i=FE(e);return 2===arguments.length?this._delegate.update(i,t):this._delegate.update(i,t,r,...n),this}delete(e){var t=FE(e);return this._delegate.delete(t),this}commit(){return this._delegate.commit()}}class SE{constructor(e,t,r){this._firestore=e,this._userDataWriter=t,this._delegate=r}fromFirestore(e,t){var r=new rE(this._firestore._delegate,this._userDataWriter,e._key,e._document,e.metadata,null);return this._delegate.fromFirestore(new xE(this._firestore,r),t??{})}toFirestore(e,t){return t?this._delegate.toFirestore(e,t):this._delegate.toFirestore(e)}static getInstance(e,t){var r=SE.INSTANCES;let n=r.get(e),i=(n||(n=new WeakMap,r.set(e,n)),n.get(t));return i||(i=new SE(e,new EE(e),t),n.set(t,i)),i}}SE.INSTANCES=new WeakMap;class kE{constructor(e,t){this.firestore=e,this._delegate=t,this._userDataWriter=new EE(e)}static forPath(e,t,r){if(e.length%2!=0)throw new R("invalid-argument","Invalid document reference. Document references must have an even number of segments, but "+e.canonicalString()+" has "+e.length);return new kE(t,new q7(t._delegate,r,new D(e)))}static forKey(e,t,r){return new kE(t,new q7(t._delegate,r,e))}get id(){return this._delegate.id}get parent(){return new ME(this.firestore,this._delegate.parent)}get path(){return this._delegate.path}collection(e){try{return new ME(this.firestore,z7(this._delegate,e))}catch(e){throw AE(e,"collection()","DocumentReference.collection()")}}isEqual(e){return(e=w(e))instanceof q7&&K7(this._delegate,e)}set(e,t){t=mE("DocumentReference.set",t);try{return t?uE(this._delegate,e,t):uE(this._delegate,e)}catch(e){throw AE(e,"setDoc()","DocumentReference.set()")}}update(e,t,...r){try{return 1===arguments.length?hE(this._delegate,e):hE(this._delegate,e,t,...r)}catch(e){throw AE(e,"updateDoc()","DocumentReference.update()")}}delete(){return dE(N2((e=this._delegate).firestore,kT),[new n_(e._key,Gv.none())]);var e}onSnapshot(...e){var t=NE(e),r=RE(e,e=>new PE(this.firestore,new tE(this.firestore._delegate,this._userDataWriter,e._key,e._document,e.metadata,this._delegate.converter)));return cE(this._delegate,t,r)}get(e){let t;return(t=("cache"===e?.source?t=>{t=N2(t,q7);let r=N2(t.firestore,kT),e=AT(r),n=new OT(r);return pT(e,t._key).then(e=>new tE(r,n,t._key,e,new eE(null!==e&&e.hasLocalMutations,!0),t.converter))}:"server"===e?.source?t=>{t=N2(t,q7);let r=N2(t.firestore,kT),e=AT(r);return fT(e,t._key,{source:"server"}).then(e=>pE(r,t,e))}:t=>{t=N2(t,q7);let r=N2(t.firestore,kT),e=AT(r);return fT(e,t._key).then(e=>pE(r,t,e))})(this._delegate)).then(e=>new PE(this.firestore,new tE(this.firestore._delegate,this._userDataWriter,e._key,e._document,e.metadata,this._delegate.converter)))}withConverter(e){return new kE(this.firestore,e?this._delegate.withConverter(SE.getInstance(this.firestore,e)):this._delegate.withConverter(null))}}function AE(e,t,r){return e.message=e.message.replace(t,r),e}function NE(e){for(var t of e)if("object"==typeof t&&!wE(t))return t;return{}}function RE(e,t){let r;return{next:e=>{r.next&&r.next(t(e))},error:(r=wE(e[0])?e[0]:wE(e[1])?e[1]:"function"==typeof e[0]?{next:e[0],error:e[1],complete:e[2]}:{next:e[1],error:e[2],complete:e[3]}).error?.bind(r),complete:r.complete?.bind(r)}}class PE{constructor(e,t){this._firestore=e,this._delegate=t}get ref(){return new kE(this._firestore,this._delegate.ref)}get id(){return this._delegate.id}get metadata(){return this._delegate.metadata}get exists(){return this._delegate.exists()}data(e){return this._delegate.data(e)}get(e,t){return this._delegate.get(e,t)}isEqual(e){return iE(this._delegate,e._delegate)}}class xE extends PE{data(e){var t=this._delegate.data(e);return this._delegate._converter||(e="Document in a QueryDocumentSnapshot should exist",void 0!==t)||k(57014,e),t}}class DE{constructor(e,t){this.firestore=e,this._delegate=t,this._userDataWriter=new EE(e)}where(e,t,r){try{return new DE(this.firestore,jT(this._delegate,(n=r,i=t,s=g4("where",e),zT._create(s,i,n))))}catch(e){throw AE(e,/(orderBy|where)\(\)/,"Query.$1()")}var n,i,s}orderBy(e,t){try{return new DE(this.firestore,jT(this._delegate,([r,n="asc"]=[e,t],i=n,s=g4("orderBy",r),HT._create(s,i))))}catch(e){throw AE(e,/(orderBy|where)\(\)/,"Query.$1()")}var r,n,i,s}limit(e){try{return new DE(this.firestore,jT(this._delegate,(R2("limit",t=e),KT._create("limit",t,"F"))))}catch(e){throw AE(e,"limit()","Query.limit()")}var t}limitToLast(e){try{return new DE(this.firestore,jT(this._delegate,(R2("limitToLast",t=e),KT._create("limitToLast",t,"L"))))}catch(e){throw AE(e,"limitToLast()","Query.limitToLast()")}var t}startAt(...e){try{return new DE(this.firestore,jT(this._delegate,([...t]=[...e],GT._create("startAt",t,!0))))}catch(e){throw AE(e,"startAt()","Query.startAt()")}var t}startAfter(...e){try{return new DE(this.firestore,jT(this._delegate,([...t]=[...e],GT._create("startAfter",t,!1))))}catch(e){throw AE(e,"startAfter()","Query.startAfter()")}var t}endBefore(...e){try{return new DE(this.firestore,jT(this._delegate,([...t]=[...e],WT._create("endBefore",t,!1))))}catch(e){throw AE(e,"endBefore()","Query.endBefore()")}var t}endAt(...e){try{return new DE(this.firestore,jT(this._delegate,([...t]=[...e],WT._create("endAt",t,!0))))}catch(e){throw AE(e,"endAt()","Query.endAt()")}var t}isEqual(e){return G7(this._delegate,e._delegate)}get(e){let t;return(t=("cache"===e?.source?t=>{t=N2(t,B7);let r=N2(t.firestore,kT),e=AT(r),n=new OT(r);return gT(e,t._query).then(e=>new nE(r,n,t,e))}:"server"===e?.source?t=>{t=N2(t,B7);let r=N2(t.firestore,kT),e=AT(r),n=new OT(r);return mT(e,t._query,{source:"server"}).then(e=>new nE(r,n,t,e))}:t=>{t=N2(t,B7);let r=N2(t.firestore,kT),e=AT(r),n=new OT(r);return VT(t._query),mT(e,t._query).then(e=>new nE(r,n,t,e))})(this._delegate)).then(e=>new LE(this.firestore,new nE(this.firestore._delegate,this._userDataWriter,this._delegate,e._snapshot)))}onSnapshot(...e){var t=NE(e),r=RE(e,e=>new LE(this.firestore,new nE(this.firestore._delegate,this._userDataWriter,this._delegate,e._snapshot)));return cE(this._delegate,t,r)}withConverter(e){return new DE(this.firestore,e?this._delegate.withConverter(SE.getInstance(this.firestore,e)):this._delegate.withConverter(null))}}class OE{constructor(e,t){this._firestore=e,this._delegate=t}get type(){return this._delegate.type}get doc(){return new xE(this._firestore,this._delegate.doc)}get oldIndex(){return this._delegate.oldIndex}get newIndex(){return this._delegate.newIndex}}class LE{constructor(e,t){this._firestore=e,this._delegate=t}get query(){return new DE(this._firestore,this._delegate.query)}get metadata(){return this._delegate.metadata}get size(){return this._delegate.size}get empty(){return this._delegate.empty}get docs(){return this._delegate.docs.map(e=>new xE(this._firestore,e))}docChanges(e){return this._delegate.docChanges(e).map(e=>new OE(this._firestore,e))}forEach(t,r){this._delegate.forEach(e=>{t.call(r,new xE(this._firestore,e))})}isEqual(e){return iE(this._delegate,e._delegate)}}class ME extends DE{constructor(e,t){super(e,t),this.firestore=e,this._delegate=t}get id(){return this._delegate.id}get path(){return this._delegate.path}get parent(){var e=this._delegate.parent;return e?new kE(this.firestore,e):null}doc(e){try{return void 0===e?new kE(this.firestore,H7(this._delegate)):new kE(this.firestore,H7(this._delegate,e))}catch(e){throw AE(e,"doc()","CollectionReference.doc()")}}add(e){return((e,t)=>{let r=N2(e.firestore,kT),n=H7(e),i=XT(e.converter,t),s=e4(e.firestore);return dE(r,[t4(s,"addDoc",n._key,i,null!==e.converter,{}).toMutation(n._key,Gv.exists(!1))]).then(()=>n)})(this._delegate,e).then(e=>new kE(this.firestore,e))}isEqual(e){return K7(this._delegate,e._delegate)}withConverter(e){return new ME(this.firestore,e?this._delegate.withConverter(SE.getInstance(this.firestore,e)):this._delegate.withConverter(null))}}function FE(e){return N2(e,q7)}class UE{static serverTimestamp(){var e=new i4("serverTimestamp");return e._methodName="FieldValue.serverTimestamp",new UE(e)}static delete(){var e=new r4("deleteField");return e._methodName="FieldValue.delete",new UE(e)}static arrayUnion(...e){[...e]=[...e];var t=new s4("arrayUnion",e);return t._methodName="FieldValue.arrayUnion",new UE(t)}static arrayRemove(...e){[...e]=[...e];var t=new a4("arrayRemove",e);return t._methodName="FieldValue.arrayRemove",new UE(t)}static increment(e){e=e;var t=new o4("increment",e);return t._methodName="FieldValue.increment",new UE(t)}constructor(e){this._delegate=e}isEqual(e){return this._delegate.isEqual(e._delegate)}}let VE={Firestore:TE,GeoPoint:u7,Timestamp:O2,Blob:yE,Transaction:IE,WriteBatch:CE,DocumentReference:kE,DocumentSnapshot:PE,Query:DE,QueryDocumentSnapshot:xE,QuerySnapshot:LE,CollectionReference:ME,FieldPath:class VP{constructor(...e){this._delegate=new o7(...e)}static documentId(){return new VP(T2.keyField().canonicalString())}isEqual(e){return(e=w(e))instanceof o7&&this._delegate._internalPath.isEqual(e._internalPath)}},FieldValue:UE,setLogLevel:function(e){e=e,Jm.setLogLevel(e)},CACHE_SIZE_UNLIMITED:-1};GN=pr,ST=(e,t)=>new TE(e,t,new bE),GN.INTERNAL.registerComponent(new h("firestore-compat",e=>{var t=e.getProvider("app-compat").getImmediate(),r=e.getProvider("firestore").getImmediate();return ST(t,r)},"PUBLIC").setServiceProps({...VE})),GN.registerVersion(fE,gE);let BE="type.googleapis.com/google.protobuf.Int64Value",qE="type.googleapis.com/google.protobuf.UInt64Value";function jE(e,t){var r,n={};for(r in e)e.hasOwnProperty(r)&&(n[r]=t(e[r]));return n}function zE(e){if(null==e)return null;if("number"==typeof(e=e instanceof Number?e.valueOf():e)&&isFinite(e))return e;if(!0===e||!1===e)return e;if("[object String]"===Object.prototype.toString.call(e))return e;if(e instanceof Date)return e.toISOString();if(Array.isArray(e))return e.map(e=>zE(e));if("function"==typeof e||"object"==typeof e)return jE(e,e=>zE(e));throw new Error("Data cannot be encoded in JSON: "+e)}function HE(e){if(null==e)return e;if(e["@type"])switch(e["@type"]){case BE:case qE:var t=Number(e.value);if(isNaN(t))throw new Error("Data cannot be decoded from JSON: "+e);return t;default:throw new Error("Data cannot be decoded from JSON: "+e)}return Array.isArray(e)?e.map(e=>HE(e)):"function"==typeof e||"object"==typeof e?jE(e,e=>HE(e)):e}let KE="functions",GE={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 WE extends fe{constructor(e,t,r){super(KE+"/"+e,t||""),this.details=r,Object.setPrototypeOf(this,WE.prototype)}}function $E(e,t){let r=(e=>{if(200<=e&&e<300)return"ok";switch(e){case 0:return"internal";case 400:return"invalid-argument";case 401:return"unauthenticated";case 403:return"permission-denied";case 404:return"not-found";case 409:return"aborted";case 429:return"resource-exhausted";case 499:return"cancelled";case 500:return"internal";case 501:return"unimplemented";case 503:return"unavailable";case 504:return"deadline-exceeded"}return"unknown"})(e),n=r,i=void 0;try{var s=t&&t.error;if(s){let e=s.status;if("string"==typeof e){if(!GE[e])return new WE("internal","internal");r=GE[e],n=e}var a=s.message;"string"==typeof a&&(n=a),void 0!==(i=s.details)&&(i=HE(i))}}catch(e){}return"ok"===r?null:new WE(r,n,i)}class YE{constructor(e,t,r,n){this.app=e,this.auth=null,this.messaging=null,this.appCheck=null,this.serverAppAppCheckToken=null,Ot(e)&&e.settings.appCheckToken&&(this.serverAppAppCheckToken=e.settings.appCheckToken),this.auth=t.getImmediate({optional:!0}),this.messaging=r.getImmediate({optional:!0}),this.auth||t.get().then(e=>this.auth=e,()=>{}),this.messaging||r.get().then(e=>this.messaging=e,()=>{}),this.appCheck||n?.get().then(e=>this.appCheck=e,()=>{})}async getAuthToken(){if(this.auth)try{return(await this.auth.getToken())?.accessToken}catch(e){}}async getMessagingToken(){if(this.messaging&&"Notification"in self&&"granted"===Notification.permission)try{return await this.messaging.getToken()}catch(e){}}async getAppCheckToken(e){var t;return this.serverAppAppCheckToken||(!this.appCheck||(t=e?await this.appCheck.getLimitedUseToken():await this.appCheck.getToken()).error?null:t.token)}async getContext(e){return{authToken:await this.getAuthToken(),messagingToken:await this.getMessagingToken(),appCheckToken:await this.getAppCheckToken(e)}}}let QE="us-central1",JE=/^data: (.*?)(?:\n|$)/;class XE{constructor(e,t,r,n,i=QE,s=(...e)=>fetch(...e)){this.app=e,this.fetchImpl=s,this.emulatorOrigin=null,this.contextProvider=new YE(e,t,r,n),this.cancelAllRequests=new Promise(e=>{this.deleteService=()=>Promise.resolve(e())});try{var a=new URL(i);this.customDomain=a.origin+("/"===a.pathname?"":a.pathname),this.region=QE}catch(e){this.customDomain=null,this.region=i}}_delete(){return this.deleteService()}_url(e){var t=this.app.options.projectId;return null!==this.emulatorOrigin?`${this.emulatorOrigin}/${t}/${this.region}/`+e:null!==this.customDomain?this.customDomain+"/"+e:`https://${this.region}-${t}.cloudfunctions.net/`+e}}function ZE(i,s,a){var e=e=>{return e=e,r=a||{},n=(t=i)._url(s),rI(t,n,e,r);var t,r,n};return e.stream=(e,t)=>{return e=e,t=t,n=(r=i)._url(s),nI(r,n,e,t||{});var r,n},e}function eI(e){return e.emulatorOrigin&&ze(e.emulatorOrigin)?"include":void 0}async function tI(e,t){var r={},n=await e.contextProvider.getContext(t.limitedUseAppCheckTokens);return n.authToken&&(r.Authorization="Bearer "+n.authToken),n.messagingToken&&(r["Firebase-Instance-ID-Token"]=n.messagingToken),null!==n.appCheckToken&&(r["X-Firebase-AppCheck"]=n.appCheckToken),r}async function rI(e,t,r,n){var i={data:r=zE(r)},s=await tI(e,n),a=(r=>{let n=null;return{promise:new Promise((e,t)=>{n=setTimeout(()=>{t(new WE("deadline-exceeded","deadline-exceeded"))},r)}),cancel:()=>{n&&clearTimeout(n)}}})(n.timeout||7e4),i=await Promise.race([(async(e,t,r,n,i)=>{r["Content-Type"]="application/json";let s;try{s=await n(e,{method:"POST",body:JSON.stringify(t),headers:r,credentials:eI(i)})}catch(e){return{status:0,json:null}}let a=null;try{a=await s.json()}catch(e){}return{status:s.status,json:a}})(t,i,s,e.fetchImpl,e),a.promise,e.cancelAllRequests]);if(a.cancel(),!i)throw new WE("cancelled","Firebase Functions instance was deleted.");s=$E(i.status,i.json);if(s)throw s;if(!i.json)throw new WE("internal","Response is not valid JSON object.");let o=i.json.data;if(void 0===(o=void 0===o?i.json.result:o))throw new WE("internal","Response is missing data field.");return{data:HE(o)}}async function nI(e,t,r,n){var i={data:r=zE(r)},s=await tI(e,n);s["Content-Type"]="application/json",s.Accept="text/event-stream";let a;try{a=await e.fetchImpl(t,{method:"POST",body:JSON.stringify(i),headers:s,signal:n?.signal,credentials:eI(e)})}catch(e){if(e instanceof Error&&"AbortError"===e.name){let e=new WE("cancelled","Request was cancelled.");return{data:Promise.reject(e),stream:{[Symbol.asyncIterator](){return{next(){return Promise.reject(e)}}}}}}let t=$E(0,null);return{data:Promise.reject(t),stream:{[Symbol.asyncIterator](){return{next(){return Promise.reject(t)}}}}}}let o,l;i=new Promise((e,t)=>{o=e,l=t}),n?.signal?.addEventListener("abort",()=>{var e=new WE("cancelled","Request was cancelled.");l(e)}),s=a.body.getReader();let u=((a,s,o,l)=>{let u=(e,t)=>{var r=e.match(JE);if(r){r=r[1];try{var n,i=JSON.parse(r);"result"in i?s(HE(i.result)):"message"in i?t.enqueue(HE(i.message)):"error"in i&&(n=$E(0,i),t.error(n),o(n))}catch(e){e instanceof WE&&(t.error(e),o(e))}}},h=new TextDecoder;return new ReadableStream({start(i){let s="";return async function r(){if(l?.aborted){let e=new WE("cancelled","Request was cancelled");return i.error(e),o(e),Promise.resolve()}try{let{value:t,done:e}=await a.read();if(e)s.trim()&&u(s.trim(),i),i.close();else{if(!l?.aborted){let e=(s+=h.decode(t,{stream:!0})).split("\n");s=e.pop()||"";for(var n of e)n.trim()&&u(n.trim(),i);return r()}{let e=new WE("cancelled","Request was cancelled");i.error(e),o(e),void await a.cancel()}}}catch(e){let t=e instanceof WE?e:$E(0,null);i.error(t),o(t)}}()},cancel(){return a.cancel()}})})(s,o,l,n?.signal);return{stream:{[Symbol.asyncIterator](){let r=u.getReader();return{async next(){var{value:e,done:t}=await r.read();return{value:e,done:t}},async return(){return await r.cancel(),{done:!0,value:void 0}}}}},data:i}}let iI="@firebase/functions",sI="0.13.5",aI="auth-internal",oI="app-check-internal",lI="messaging-internal";function uI(e,t,r){var n;e=w(e),r=r,n=ze(t=t),e.emulatorOrigin=`http${n?"s":""}://${t}:`+r,n&&He(e.emulatorOrigin+"/backends")}function hI(e,t,r){return n=w(e),i=t,s=r,(a=e=>rI(n,i,e,s||{})).stream=(e,t)=>nI(n,i,e,t||{}),a;var n,i,s,a}Rt(new h(KE,(e,{instanceIdentifier:t})=>{var r=e.getProvider("app").getImmediate(),n=e.getProvider(aI),i=e.getProvider(lI),s=e.getProvider(oI);return new XE(r,n,i,s,t)},"PUBLIC").setMultipleInstances(!0)),zt(iI,sI,WN),zt(iI,sI,"esm2020");var cI,dI,pI;class fI{constructor(e,t){this.app=e,this._delegate=t,this._region=this._delegate.region,this._customDomain=this._delegate.customDomain}httpsCallable(e,t){return ZE(w(this._delegate),e,t)}httpsCallableFromURL(e,t){return hI(this._delegate,e,t)}useFunctionsEmulator(e){var t=e.match("[a-zA-Z]+://([a-zA-Z0-9.-]+)(?::([0-9]+))?");if(null==t)throw new fe("functions","No origin provided to useFunctionsEmulator()");if(null==t[2])throw new fe("functions","Port missing in origin provided to useFunctionsEmulator()");return uI(this._delegate,t[1],Number(t[2]))}useEmulator(e,t){return uI(this._delegate,e,t)}}let gI="us-central1",mI=(e,{instanceIdentifier:t})=>{var r=e.getProvider("app-compat").getImmediate(),n=e.getProvider("functions").getImmediate({identifier:t??gI});return new fI(r,n)};ur={Functions:fI},pr.INTERNAL.registerComponent(new h("functions-compat",mI,"PUBLIC").setServiceProps(ur).setMultipleInstances(!0)),pr.registerVersion("@firebase/functions-compat","0.4.5");let vI="/firebase-messaging-sw.js",_I="/firebase-cloud-messaging-push-scope",yI="BDOU99-h67HcA6JeFXHbSNMu7e2yNNu3RzoMj8TM4W88jITfq7ZmPvIM1Iv-4_l2LxQcYwhqby2xGpWwzjfAnG4",wI="https://fcmregistrations.googleapis.com/v1",bI="google.c.a.c_id",TI="google.c.a.c_l",EI="google.c.a.ts",II="google.c.a.e",CI=1e4;function SI(e){var t=new Uint8Array(e);return btoa(String.fromCharCode(...t)).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function kI(e){var t=(e+"=".repeat((4-e.length%4)%4)).replace(/\-/g,"+").replace(/_/g,"/"),r=atob(t),n=new Uint8Array(r.length);for(let i=0;i<r.length;++i)n[i]=r.charCodeAt(i);return n}(t=cI=cI||{}).PUSH_RECEIVED="push-received",t.NOTIFICATION_CLICKED="notification-clicked",t.FID_REGISTERED="fid-registered";let AI="fcm_token_details_db",NI=5,RI="fcm_token_object_Store";async function PI(a){if("databases"in indexedDB&&!(await indexedDB.databases()).map(e=>e.name).includes(AI))return null;let o=null;return(await pt(AI,NI,{upgrade:async(e,t,r,n)=>{var i,s;t<2||e.objectStoreNames.contains(RI)&&(i=await(s=n.objectStore(RI)).index("fcmSenderId").get(a),await s.clear(),i)&&(2===t?(s=i).auth&&s.p256dh&&s.endpoint&&(o={token:s.fcmToken,createTime:s.createTime??Date.now(),subscriptionOptions:{auth:s.auth,p256dh:s.p256dh,endpoint:s.endpoint,swScope:s.swScope,vapidKey:"string"==typeof s.vapidKey?s.vapidKey:SI(s.vapidKey)}}):3===t?(s=i,o={token:s.fcmToken,createTime:s.createTime,subscriptionOptions:{auth:SI(s.auth),p256dh:SI(s.p256dh),endpoint:s.endpoint,swScope:s.swScope,vapidKey:SI(s.vapidKey)}}):4===t&&(s=i,o={token:s.fcmToken,createTime:s.createTime,subscriptionOptions:{auth:SI(s.auth),p256dh:SI(s.p256dh),endpoint:s.endpoint,swScope:s.swScope,vapidKey:SI(s.vapidKey)}}))}})).close(),await ft(AI),await ft("fcm_vapid_details_db"),await ft("undefined"),(e=>{var t;if(e&&e.subscriptionOptions)return t=e.subscriptionOptions,"number"==typeof e.createTime&&0<e.createTime&&"string"==typeof e.token&&0<e.token.length&&"string"==typeof t.auth&&0<t.auth.length&&"string"==typeof t.p256dh&&0<t.p256dh.length&&"string"==typeof t.endpoint&&0<t.endpoint.length&&"string"==typeof t.swScope&&0<t.swScope.length&&"string"==typeof t.vapidKey&&0<t.vapidKey.length})(o)?o:null}let xI=new ge("messaging","Messaging",{"missing-app-config-values":'Missing App configuration value: "{$valueName}"',"only-available-in-window":"This method is available in a Window context.","only-available-in-sw":"This method is available in a service worker context.","permission-default":"The notification permission was not granted and dismissed instead.","permission-blocked":"The notification permission was not granted and blocked instead.","unsupported-browser":"This browser doesn't support the API's required to use the Firebase SDK.","indexed-db-unsupported":"This browser doesn't support indexedDb.open() (ex. Safari iFrame, Firefox Private Browsing, etc)","failed-service-worker-registration":"We are unable to register the default service worker. {$browserErrorMessage}","token-subscribe-failed":"A problem occurred while subscribing the user to FCM: {$errorInfo}","token-subscribe-no-token":"FCM returned no token when subscribing the user to push.","fid-registration-failed":"A problem occurred while creating an FCM registration via FID: {$errorInfo}","fid-unregister-failed":"A problem occurred while unregistering the FCM registration via FID: {$errorInfo}","fid-registration-idb-schema-unavailable":"Unable to read or persist FID registration metadata because the messaging IndexedDB schema is unavailable (for example, the database could not be upgraded to the latest version).","token-unsubscribe-failed":"A problem occurred while unsubscribing the user from FCM: {$errorInfo}","token-update-failed":"A problem occurred while updating the user from FCM: {$errorInfo}","token-update-no-token":"FCM returned no token when updating the user to push.","use-sw-after-get-token":"The useServiceWorker() method may only be called once and must be called before calling getToken() to ensure your service worker is used.","invalid-sw-registration":"The input to useServiceWorker() must be a ServiceWorkerRegistration.","invalid-bg-handler":"The input to setBackgroundMessageHandler() must be a function.","invalid-vapid-key":"The public VAPID key must be a string.","use-vapid-key-after-get-token":"The usePublicVapidKey() method may only be called once and must be called before calling getToken() to ensure your VAPID key is used.","invalid-on-registered-handler":"No onRegistered callback handler was provided or registered. Implement onRegistered() before register()."}),DI="firebase-messaging-database",OI=2,LI="firebase-messaging-store",MI="firebase-messaging-fid-registration-store",FI={openDB:pt,deleteDB:ft},UI=null;function VI(i){return{upgrade:(e,t)=>{var r=e,n=i;switch(t){case 0:if(r.createObjectStore(LI),1===n)break;case 1:2===n&&r.createObjectStore(MI)}},blocked:()=>{},blocking:(e,t,r)=>{UI=null,r.target?.close()},terminated:()=>{UI=null}}}function BI(){var e;return UI||(e=FI.openDB(DI,OI,VI(2)),UI=e.catch(()=>FI.openDB(DI,OI-1,VI(1)))),UI}function qI(e,t){return e.objectStoreNames.contains(t)}function jI(e){if(!qI(e,MI))throw xI.create("fid-registration-idb-schema-unavailable")}async function zI(e){var t=GI(e),t=await(await BI()).transaction(LI).objectStore(LI).get(t);return t||((t=await PI(e.appConfig.senderId))?(await HI(e,t),t):void 0)}async function HI(e,t){var r=GI(e),n=await BI(),i=[LI],s=qI(n,MI),n=(s&&i.push(MI),n.transaction(i,"readwrite"));return await n.objectStore(LI).put(t,r),s&&await n.objectStore(MI).delete(r),await n.done,t}async function KI(e){var t=GI(e),r=await BI();return jI(r),r.transaction(MI).objectStore(MI).get(t)}function GI({appConfig:e}){return e.appId}let WI="@firebase/messaging",$I="0.13.0",YI=3,QI=1e3;async function JI(e,t){var r=await tC(e),n=rC(t,e.appConfig.appName,!0);let i={method:"POST",headers:r,body:JSON.stringify(n)},s;try{s=await(async(e,t,r)=>{let n;for(let i=0;i<t;i++)try{return await e()}catch(e){if(n=e,i<t-1){let t=r*Math.pow(2,i);await new Promise(e=>setTimeout(e,t))}}throw n})(()=>fetch(eC(e.appConfig),i),YI,QI)}catch(e){throw xI.create("fid-registration-failed",{errorInfo:e?.toString()})}if(s.ok)return{responseFid:await(async e=>{var t=await e.text();if(!t.trim())throw xI.create("fid-registration-failed",{errorInfo:"CreateRegistration succeeded but response body is empty"});let r;try{r=JSON.parse(t)}catch{throw xI.create("fid-registration-failed",{errorInfo:"CreateRegistration succeeded but response body is not valid JSON"})}if("string"!=typeof(t=r.name)||0===t.length)throw xI.create("fid-registration-failed",{errorInfo:"CreateRegistration succeeded but response did not include a non-empty name"});if(-1!==(t=(e=t).indexOf(XI))){t=e.slice(t+XI.length);if(0<t.length)return t}throw xI.create("fid-registration-failed",{errorInfo:"CreateRegistration succeeded but response name is not a valid registration resource name"})})(s)};let a;try{a=await s.json()}catch(e){throw xI.create("fid-registration-failed",{errorInfo:s.statusText})}r=a.error?.message??s.statusText;throw xI.create("fid-registration-failed",{errorInfo:r})}let XI="/registrations/";async function ZI(e,t){var r={method:"DELETE",headers:await tC(e)};try{var n,i=await(await fetch(eC(e.appConfig)+"/"+t,r)).json();if(i.error)throw n=i.error.message,xI.create("token-unsubscribe-failed",{errorInfo:n})}catch(e){throw xI.create("token-unsubscribe-failed",{errorInfo:e?.toString()})}}function eC({projectId:e}){return wI+`/projects/${e}/registrations`}async function tC({appConfig:e,installations:t}){var r=await t.getToken();return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":e.apiKey,"x-goog-firebase-installations-auth":"FIS "+r})}function rC({p256dh:e,auth:t,endpoint:r,vapidKey:n,swScope:i},s,a){var o={web:{origin:((e,t)=>{try{if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(e))return new URL(e).host}catch{}try{if("undefined"!=typeof self&&self.location?.href)return new URL(e,self.location.origin).host}catch{}return"undefined"!=typeof self&&self.location?.host?self.location.host:t})(i,s),endpoint:r,auth:t,p256dh:e}};return a&&(o.fcm_sdk_version=$I),n!==yI&&(o.web.applicationPubKey=n),o}let nC=6048e5;async function iC(e){var t,r,n,i,s,a=await(async(e,t)=>{var r=await e.pushManager.getSubscription();return r||e.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:kI(t)})})(e.swRegistration,e.vapidKey),a={vapidKey:e.vapidKey,swScope:e.swRegistration.scope,endpoint:a.endpoint,auth:SI(a.getKey("auth")),p256dh:SI(a.getKey("p256dh"))},o=await zI(e.firebaseDependencies);if(o){if(t=o.subscriptionOptions,r=a.vapidKey===t.vapidKey,n=a.endpoint===t.endpoint,i=a.auth===t.auth,s=a.p256dh===t.p256dh,r&&n&&i&&s)return Date.now()>=o.createTime+nC?(async(e,t)=>{try{var r=await(async(e,t)=>{var r=await tC(e),n=rC(t.subscriptionOptions,e.appConfig.appName,!1),r={method:"PATCH",headers:r,body:JSON.stringify(n)};let i;try{var s=await fetch(eC(e.appConfig)+"/"+t.token,r);i=await s.json()}catch(e){throw xI.create("token-update-failed",{errorInfo:e?.toString()})}if(i.error)throw n=i.error.message,xI.create("token-update-failed",{errorInfo:n});if(i.token)return i.token;throw xI.create("token-update-no-token")})(e.firebaseDependencies,t),n={...t,token:r,createTime:Date.now()};return await HI(e.firebaseDependencies,n),r}catch(e){throw e}})(e,{token:o.token,createTime:Date.now(),subscriptionOptions:a}):o.token;try{await ZI(e.firebaseDependencies,o.token)}catch(e){console.warn(e)}}return oC(e.firebaseDependencies,a)}async function sC(e,t){var r,n;await ZI(e.firebaseDependencies,t.token),r=GI(e.firebaseDependencies),await(n=(await BI()).transaction(LI,"readwrite")).objectStore(LI).delete(r),await n.done,await lC(e.firebaseDependencies)}async function aC(e){var r=(await KI(e.firebaseDependencies).catch(()=>{}))?.fid;if(r){{var n=e.firebaseDependencies;var i=r;var s={method:"DELETE",headers:await tC(n)};let t;try{t=await fetch(eC(n.appConfig)+"/"+i,s)}catch(e){throw xI.create("fid-unregister-failed",{errorInfo:e?.toString()})}if(!t.ok)try{throw(await t.json()).error?.message??t.statusText}catch(e){throw xI.create("fid-unregister-failed",{errorInfo:"string"==typeof e&&e||t.statusText||e?.toString()})}}await 0}await lC(e.firebaseDependencies),r&&(n=r,s=e.onUnregisteredHandler)&&("function"==typeof s?s(n):s.next(n))}async function oC(e,t){var r={token:await(async(e,t)=>{var r=await tC(e),n=rC(t,e.appConfig.appName,!1),r={method:"POST",headers:r,body:JSON.stringify(n)};let i;try{var s=await fetch(eC(e.appConfig),r);i=await s.json()}catch(e){throw xI.create("token-subscribe-failed",{errorInfo:e?.toString()})}if(i.error)throw n=i.error.message,xI.create("token-subscribe-failed",{errorInfo:n});if(i.token)return i.token;throw xI.create("token-subscribe-no-token")})(e,t),createTime:Date.now(),subscriptionOptions:t};return await HI(e,r),r.token}async function lC(e){try{t=GI(e),jI(r=await BI()),await(r=r.transaction(MI,"readwrite")).objectStore(MI).delete(t),await r.done}catch{}var t,r}async function uC(e){try{e.swRegistration=await navigator.serviceWorker.register(vI,{scope:_I}),e.swRegistration.update().catch(()=>{}),i=e.swRegistration,await new Promise((t,e)=>{let r=setTimeout(()=>e(new Error(`Service worker not registered after ${CI} ms`)),CI),n=i.installing||i.waiting;i.active?(clearTimeout(r),t()):n?n.onstatechange=e=>{"activated"===e.target?.state&&(n.onstatechange=null,clearTimeout(r),t())}:(clearTimeout(r),e(new Error("No incoming service worker found.")))})}catch(e){throw xI.create("failed-service-worker-registration",{browserErrorMessage:e?.message})}var i}async function hC(e,t){if(t||e.swRegistration||await uC(e),t||!e.swRegistration){if(!(t instanceof ServiceWorkerRegistration))throw xI.create("invalid-sw-registration");e.swRegistration=t}}async function cC(e,t){t?e.vapidKey=t:e.vapidKey||(e.vapidKey=yI)}let dC=3;async function pC(e,t){var r=await(async(e,t)=>{var r=await e.pushManager.getSubscription();return r||e.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:kI(t)})})(e.swRegistration,e.vapidKey),n={vapidKey:e.vapidKey,swScope:e.swRegistration.scope,endpoint:r.endpoint,auth:SI(r.getKey("auth")),p256dh:SI(r.getKey("p256dh"))},i=e.firebaseDependencies.installations;for(let a=0;a<dC;a++){var s=(await JI(e.firebaseDependencies,n)).responseFid;if(s===t)return;a<dC-1&&await i.getToken(!0)}throw xI.create("fid-registration-failed",{errorInfo:"CreateRegistration response FID does not match Firebase Installation ID"})}let fC=6048e5;async function gC(s,e){if(!navigator)throw xI.create("only-available-in-window");if("default"===Notification.permission&&await Notification.requestPermission(),"granted"!==Notification.permission)throw xI.create("permission-blocked");if(!s.onRegisteredHandler)throw xI.create("invalid-on-registered-handler");await cC(s,e?.vapidKey),await hC(s,e?.serviceWorkerRegistration);var t=s._registerNotifyChain.catch(()=>{});return s._registerNotifyChain=t.then(async()=>{var e,t,r=await s.firebaseDependencies.installations.getId(),n=await KI(s.firebaseDependencies),i=Date.now(),n=((!n||n.fid!==r||i>=n.lastRegisterTime+fC)&&(await pC(s,r),t=s.firebaseDependencies,e={fid:r,lastRegisterTime:i,vapidKey:s.vapidKey},n=GI(t),jI(i=await BI()),await(i=i.transaction([LI,MI],"readwrite")).objectStore(MI).put(e,n),await i.objectStore(LI).delete(n),await i.done,await e),s.onRegisteredHandler);if(!n)throw xI.create("invalid-on-registered-handler");t=r,(i=s.onRegisteredHandler)&&("function"==typeof i?i(t):i.next(t))}),s._registerNotifyChain}function mC(e){var t,r,n,i={from:e.from,collapseKey:e.collapse_key,messageId:e.fcmMessageId};return r=i,(t=e).notification&&(r.notification={},(n=t.notification.title)&&(r.notification.title=n),(n=t.notification.body)&&(r.notification.body=n),(n=t.notification.image)&&(r.notification.image=n),n=t.notification.icon)&&(r.notification.icon=n),t=i,(r=e).data&&(t.data=r.data),t=i,((r=e).fcmOptions||r.notification?.click_action)&&(t.fcmOptions={},(n=r.fcmOptions?.link??r.notification?.click_action)&&(t.fcmOptions.link=n),n=r.fcmOptions?.analytics_label)&&(t.fcmOptions.analyticsLabel=n),i}var vC="AzSCbw63g1R0nCw85jG8",_C="Iaya3yLKwmgvh7cF0q4",yC=[];for(let BP=0;BP<vC.length;BP++)yC.push(vC.charAt(BP)),BP<_C.length&&yC.push(_C.charAt(BP));function wC(e){return xI.create("missing-app-config-values",{valueName:e})}yC.join("");class bC{constructor(e,t,r){this.deliveryMetricsExportedToBigQueryEnabled=!1,this.onBackgroundMessageHandler=null,this.onMessageHandler=null,this.onRegisteredHandler=null,this.onUnregisteredHandler=null,this._registerNotifyChain=Promise.resolve(),this._fidChangeUnsubscribe=null,this.logEvents=[],this.logQueue={state:"stopped"};var n=(e=>{if(!e||!e.options)throw wC("App Configuration Object");if(!e.name)throw wC("App Name");var t,r=e.options;for(t of["projectId","apiKey","appId","messagingSenderId"])if(!r[t])throw wC(t);return{appName:e.name,projectId:r.projectId,apiKey:r.apiKey,appId:r.appId,senderId:r.messagingSenderId}})(e);this.firebaseDependencies={app:e,appConfig:n,installations:t,analyticsProvider:r}}_delete(){return this._fidChangeUnsubscribe&&(this._fidChangeUnsubscribe(),this._fidChangeUnsubscribe=null),"scheduled"===this.logQueue.state&&clearTimeout(this.logQueue.timerId),this.logQueue={state:"stopped"},Promise.resolve()}}async function TC(e,t){if(!navigator)throw xI.create("only-available-in-window");if("default"===Notification.permission&&await Notification.requestPermission(),"granted"!==Notification.permission)throw xI.create("permission-blocked");return await cC(e,t?.vapidKey),await hC(e,t?.serviceWorkerRegistration),iC(e)}async function EC(e,t,r){var n=(e=>{switch(e){case cI.NOTIFICATION_CLICKED:return"notification_open";case cI.PUSH_RECEIVED:return"notification_foreground";default:throw new Error}})(t);(await e.firebaseDependencies.analyticsProvider.get()).logEvent(n,{message_id:r[bI],message_name:r[TI],message_time:r[EI],message_device_time:Math.floor(Date.now()/1e3)})}async function IC(e,t){var r,n=t.data;n.isFirebaseMessaging&&(e.onMessageHandler&&n.messageType===cI.PUSH_RECEIVED&&("function"==typeof e.onMessageHandler?e.onMessageHandler(mC(n)):e.onMessageHandler.next(mC(n))),e.onRegisteredHandler&&n.messageType===cI.FID_REGISTERED&&(r=n.fid,"function"==typeof e.onRegisteredHandler?e.onRegisteredHandler(r):e.onRegisteredHandler.next(r)),"object"==typeof(t=r=n.data))&&t&&bI in t&&"1"===r[II]&&await EC(e,n.messageType,r)}let CC=e=>{let t=new bC(e.getProvider("app").getImmediate(),e.getProvider("installations-internal").getImmediate(),e.getProvider("analytics-internal"));var r;return navigator.serviceWorker.addEventListener("message",e=>IC(t,e)),t._fidChangeUnsubscribe=(r=t,tn(e.getProvider("installations").getImmediate(),()=>{(async()=>{r.onRegisteredHandler&&await KI(r.firebaseDependencies)&&await gC(r).catch(()=>{})})()})),t},SC=e=>{let t=e.getProvider("messaging").getImmediate();return{getToken:e=>TC(t,e),register:e=>gC(t,e)}};async function kC(e){if(navigator)return e.swRegistration||await uC(e),(async e=>{var t=await zI(e.firebaseDependencies);return t?await sC(e,t):await aC(e),!(t=await e.swRegistration.pushManager.getSubscription())||t.unsubscribe()})(e);throw xI.create("only-available-in-window")}function AC(e,t){var r=e=w(e),e=t;if(navigator)return r.onMessageHandler=e,()=>{r.onMessageHandler=null};throw xI.create("only-available-in-window")}Rt(new h("messaging",CC,"PUBLIC")),Rt(new h("messaging-internal",SC,"PRIVATE")),zt(WI,$I),zt(WI,$I,"esm2020");let NC="BDOU99-h67HcA6JeFXHbSNMu7e2yNNu3RzoMj8TM4W88jITfq7ZmPvIM1Iv-4_l2LxQcYwhqby2xGpWwzjfAnG4",RC="https://fcmregistrations.googleapis.com/v1",PC="FCM_MSG",xC="google.c.a.c_id",DC=1e3,OC=3,LC=864e5,MC=5e3,FC=1249,UC=3,VC=1;function BC(e){var t=new Uint8Array(e);return btoa(String.fromCharCode(...t)).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function qC(e){var t=(e+"=".repeat((4-e.length%4)%4)).replace(/\-/g,"+").replace(/_/g,"/"),r=atob(t),n=new Uint8Array(r.length);for(let i=0;i<r.length;++i)n[i]=r.charCodeAt(i);return n}(zS=dI=dI||{})[zS.DATA_MESSAGE=1]="DATA_MESSAGE",zS[zS.DISPLAY_NOTIFICATION=3]="DISPLAY_NOTIFICATION",(GN=pI=pI||{}).PUSH_RECEIVED="push-received",GN.NOTIFICATION_CLICKED="notification-clicked",GN.FID_REGISTERED="fid-registered";let jC="fcm_token_details_db",zC=5,HC="fcm_token_object_Store";async function KC(a){if("databases"in indexedDB&&!(await indexedDB.databases()).map(e=>e.name).includes(jC))return null;let o=null;return(await pt(jC,zC,{upgrade:async(e,t,r,n)=>{var i,s;t<2||e.objectStoreNames.contains(HC)&&(i=await(s=n.objectStore(HC)).index("fcmSenderId").get(a),await s.clear(),i)&&(2===t?(s=i).auth&&s.p256dh&&s.endpoint&&(o={token:s.fcmToken,createTime:s.createTime??Date.now(),subscriptionOptions:{auth:s.auth,p256dh:s.p256dh,endpoint:s.endpoint,swScope:s.swScope,vapidKey:"string"==typeof s.vapidKey?s.vapidKey:BC(s.vapidKey)}}):3===t?(s=i,o={token:s.fcmToken,createTime:s.createTime,subscriptionOptions:{auth:BC(s.auth),p256dh:BC(s.p256dh),endpoint:s.endpoint,swScope:s.swScope,vapidKey:BC(s.vapidKey)}}):4===t&&(s=i,o={token:s.fcmToken,createTime:s.createTime,subscriptionOptions:{auth:BC(s.auth),p256dh:BC(s.p256dh),endpoint:s.endpoint,swScope:s.swScope,vapidKey:BC(s.vapidKey)}}))}})).close(),await ft(jC),await ft("fcm_vapid_details_db"),await ft("undefined"),(e=>{var t;if(e&&e.subscriptionOptions)return t=e.subscriptionOptions,"number"==typeof e.createTime&&0<e.createTime&&"string"==typeof e.token&&0<e.token.length&&"string"==typeof t.auth&&0<t.auth.length&&"string"==typeof t.p256dh&&0<t.p256dh.length&&"string"==typeof t.endpoint&&0<t.endpoint.length&&"string"==typeof t.swScope&&0<t.swScope.length&&"string"==typeof t.vapidKey&&0<t.vapidKey.length})(o)?o:null}let GC=new ge("messaging","Messaging",{"missing-app-config-values":'Missing App configuration value: "{$valueName}"',"only-available-in-window":"This method is available in a Window context.","only-available-in-sw":"This method is available in a service worker context.","permission-default":"The notification permission was not granted and dismissed instead.","permission-blocked":"The notification permission was not granted and blocked instead.","unsupported-browser":"This browser doesn't support the API's required to use the Firebase SDK.","indexed-db-unsupported":"This browser doesn't support indexedDb.open() (ex. Safari iFrame, Firefox Private Browsing, etc)","failed-service-worker-registration":"We are unable to register the default service worker. {$browserErrorMessage}","token-subscribe-failed":"A problem occurred while subscribing the user to FCM: {$errorInfo}","token-subscribe-no-token":"FCM returned no token when subscribing the user to push.","fid-registration-failed":"A problem occurred while creating an FCM registration via FID: {$errorInfo}","fid-unregister-failed":"A problem occurred while unregistering the FCM registration via FID: {$errorInfo}","fid-registration-idb-schema-unavailable":"Unable to read or persist FID registration metadata because the messaging IndexedDB schema is unavailable (for example, the database could not be upgraded to the latest version).","token-unsubscribe-failed":"A problem occurred while unsubscribing the user from FCM: {$errorInfo}","token-update-failed":"A problem occurred while updating the user from FCM: {$errorInfo}","token-update-no-token":"FCM returned no token when updating the user to push.","use-sw-after-get-token":"The useServiceWorker() method may only be called once and must be called before calling getToken() to ensure your service worker is used.","invalid-sw-registration":"The input to useServiceWorker() must be a ServiceWorkerRegistration.","invalid-bg-handler":"The input to setBackgroundMessageHandler() must be a function.","invalid-vapid-key":"The public VAPID key must be a string.","use-vapid-key-after-get-token":"The usePublicVapidKey() method may only be called once and must be called before calling getToken() to ensure your VAPID key is used.","invalid-on-registered-handler":"No onRegistered callback handler was provided or registered. Implement onRegistered() before register()."}),WC="firebase-messaging-database",$C=2,YC="firebase-messaging-store",QC="firebase-messaging-fid-registration-store",JC={openDB:pt,deleteDB:ft},XC=null;function ZC(i){return{upgrade:(e,t)=>{var r=e,n=i;switch(t){case 0:if(r.createObjectStore(YC),1===n)break;case 1:2===n&&r.createObjectStore(QC)}},blocked:()=>{},blocking:(e,t,r)=>{XC=null,r.target?.close()},terminated:()=>{XC=null}}}function eS(){var e;return XC||(e=JC.openDB(WC,$C,ZC(2)),XC=e.catch(()=>JC.openDB(WC,$C-1,ZC(1)))),XC}function tS(e,t){return e.objectStoreNames.contains(t)}function rS(e){if(!tS(e,QC))throw GC.create("fid-registration-idb-schema-unavailable")}async function nS(e){var t=aS(e),t=await(await eS()).transaction(YC).objectStore(YC).get(t);return t||((t=await KC(e.appConfig.senderId))?(await iS(e,t),t):void 0)}async function iS(e,t){var r=aS(e),n=await eS(),i=[YC],s=tS(n,QC),n=(s&&i.push(QC),n.transaction(i,"readwrite"));return await n.objectStore(YC).put(t,r),s&&await n.objectStore(QC).delete(r),await n.done,t}async function sS(e){var t=aS(e),r=await eS();return rS(r),r.transaction(QC).objectStore(QC).get(t)}function aS({appConfig:e}){return e.appId}let oS="0.13.0",lS=3,uS=1e3;async function hS(e,t){var r=await fS(e),n=gS(t,e.appConfig.appName,!0);let i={method:"POST",headers:r,body:JSON.stringify(n)},s;try{s=await(async(e,t,r)=>{let n;for(let i=0;i<t;i++)try{return await e()}catch(e){if(n=e,i<t-1){let t=r*Math.pow(2,i);await new Promise(e=>setTimeout(e,t))}}throw n})(()=>fetch(pS(e.appConfig),i),lS,uS)}catch(e){throw GC.create("fid-registration-failed",{errorInfo:e?.toString()})}if(s.ok)return{responseFid:await(async e=>{var t=await e.text();if(!t.trim())throw GC.create("fid-registration-failed",{errorInfo:"CreateRegistration succeeded but response body is empty"});let r;try{r=JSON.parse(t)}catch{throw GC.create("fid-registration-failed",{errorInfo:"CreateRegistration succeeded but response body is not valid JSON"})}if("string"!=typeof(t=r.name)||0===t.length)throw GC.create("fid-registration-failed",{errorInfo:"CreateRegistration succeeded but response did not include a non-empty name"});if(-1!==(t=(e=t).indexOf(cS))){t=e.slice(t+cS.length);if(0<t.length)return t}throw GC.create("fid-registration-failed",{errorInfo:"CreateRegistration succeeded but response name is not a valid registration resource name"})})(s)};let a;try{a=await s.json()}catch(e){throw GC.create("fid-registration-failed",{errorInfo:s.statusText})}r=a.error?.message??s.statusText;throw GC.create("fid-registration-failed",{errorInfo:r})}let cS="/registrations/";async function dS(e,t){var r={method:"DELETE",headers:await fS(e)};try{var n,i=await(await fetch(pS(e.appConfig)+"/"+t,r)).json();if(i.error)throw n=i.error.message,GC.create("token-unsubscribe-failed",{errorInfo:n})}catch(e){throw GC.create("token-unsubscribe-failed",{errorInfo:e?.toString()})}}function pS({projectId:e}){return RC+`/projects/${e}/registrations`}async function fS({appConfig:e,installations:t}){var r=await t.getToken();return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":e.apiKey,"x-goog-firebase-installations-auth":"FIS "+r})}function gS({p256dh:e,auth:t,endpoint:r,vapidKey:n,swScope:i},s,a){var o={web:{origin:((e,t)=>{try{if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(e))return new URL(e).host}catch{}try{if("undefined"!=typeof self&&self.location?.href)return new URL(e,self.location.origin).host}catch{}return"undefined"!=typeof self&&self.location?.host?self.location.host:t})(i,s),endpoint:r,auth:t,p256dh:e}};return a&&(o.fcm_sdk_version=oS),n!==NC&&(o.web.applicationPubKey=n),o}let mS=6048e5;async function vS(e){var t,r,n,i,s,a=await(async(e,t)=>{var r=await e.pushManager.getSubscription();return r||e.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:qC(t)})})(e.swRegistration,e.vapidKey),a={vapidKey:e.vapidKey,swScope:e.swRegistration.scope,endpoint:a.endpoint,auth:BC(a.getKey("auth")),p256dh:BC(a.getKey("p256dh"))},o=await nS(e.firebaseDependencies);if(o){if(t=o.subscriptionOptions,r=a.vapidKey===t.vapidKey,n=a.endpoint===t.endpoint,i=a.auth===t.auth,s=a.p256dh===t.p256dh,r&&n&&i&&s)return Date.now()>=o.createTime+mS?(async(e,t)=>{try{var r=await(async(e,t)=>{var r=await fS(e),n=gS(t.subscriptionOptions,e.appConfig.appName,!1),r={method:"PATCH",headers:r,body:JSON.stringify(n)};let i;try{var s=await fetch(pS(e.appConfig)+"/"+t.token,r);i=await s.json()}catch(e){throw GC.create("token-update-failed",{errorInfo:e?.toString()})}if(i.error)throw n=i.error.message,GC.create("token-update-failed",{errorInfo:n});if(i.token)return i.token;throw GC.create("token-update-no-token")})(e.firebaseDependencies,t),n={...t,token:r,createTime:Date.now()};return await iS(e.firebaseDependencies,n),r}catch(e){throw e}})(e,{token:o.token,createTime:Date.now(),subscriptionOptions:a}):o.token;try{await dS(e.firebaseDependencies,o.token)}catch(e){console.warn(e)}}return bS(e.firebaseDependencies,a)}async function _S(e,t){var r,n;await dS(e.firebaseDependencies,t.token),r=aS(e.firebaseDependencies),await(n=(await eS()).transaction(YC,"readwrite")).objectStore(YC).delete(r),await n.done,await TS(e.firebaseDependencies)}async function yS(e){var r=(await sS(e.firebaseDependencies).catch(()=>{}))?.fid;if(r){{var n=e.firebaseDependencies;var i=r;var s={method:"DELETE",headers:await fS(n)};let t;try{t=await fetch(pS(n.appConfig)+"/"+i,s)}catch(e){throw GC.create("fid-unregister-failed",{errorInfo:e?.toString()})}if(!t.ok)try{throw(await t.json()).error?.message??t.statusText}catch(e){throw GC.create("fid-unregister-failed",{errorInfo:"string"==typeof e&&e||t.statusText||e?.toString()})}}await 0}await TS(e.firebaseDependencies),r&&(n=r,s=e.onUnregisteredHandler)&&("function"==typeof s?s(n):s.next(n))}async function wS(e){var t=await nS(e.firebaseDependencies),t=(t?await _S(e,t):await yS(e),await e.swRegistration.pushManager.getSubscription());return!t||t.unsubscribe()}async function bS(e,t){var r={token:await(async(e,t)=>{var r=await fS(e),n=gS(t,e.appConfig.appName,!1),r={method:"POST",headers:r,body:JSON.stringify(n)};let i;try{var s=await fetch(pS(e.appConfig),r);i=await s.json()}catch(e){throw GC.create("token-subscribe-failed",{errorInfo:e?.toString()})}if(i.error)throw n=i.error.message,GC.create("token-subscribe-failed",{errorInfo:n});if(i.token)return i.token;throw GC.create("token-subscribe-no-token")})(e,t),createTime:Date.now(),subscriptionOptions:t};return await iS(e,r),r.token}async function TS(e){try{t=aS(e),rS(r=await eS()),await(r=r.transaction(QC,"readwrite")).objectStore(QC).delete(t),await r.done}catch{}var t,r}let ES=3;async function IS(e,t){var r=await(async(e,t)=>{var r=await e.pushManager.getSubscription();return r||e.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:qC(t)})})(e.swRegistration,e.vapidKey),n={vapidKey:e.vapidKey,swScope:e.swRegistration.scope,endpoint:r.endpoint,auth:BC(r.getKey("auth")),p256dh:BC(r.getKey("p256dh"))},i=e.firebaseDependencies.installations;for(let a=0;a<ES;a++){var s=(await hS(e.firebaseDependencies,n)).responseFid;if(s===t)return;a<ES-1&&await i.getToken(!0)}throw GC.create("fid-registration-failed",{errorInfo:"CreateRegistration response FID does not match Firebase Installation ID"})}async function CS(e){var t,r,n,i,s=await sS(e.firebaseDependencies).catch(()=>{});if(s)return t=e,await!((n=s.vapidKey)?t.vapidKey=n:t.vapidKey||(t.vapidKey=NC)),s=await e.firebaseDependencies.installations.getId(),await IS(e,s),n=e.firebaseDependencies,t={fid:s,lastRegisterTime:Date.now(),vapidKey:e.vapidKey},i=aS(n),rS(r=await eS()),await(r=r.transaction([YC,QC],"readwrite")).objectStore(QC).put(t,i),await r.objectStore(YC).delete(i),await r.done,await t,n=s,(i=e.onRegisteredHandler)&&("function"==typeof i?i(n):i.next(n)),s}let SS="https://play.google.com/log?format=json_proto3",kS=0,AS=((e,t)=>{var r=[];for(let n=0;n<e.length;n++)r.push(e.charAt(n)),n<t.length&&r.push(t.charAt(n));return r.join("")})("AzSCbw63g1R0nCw85jG8","Iaya3yLKwmgvh7cF0q4");function NS(a,e){"scheduled"===a.logQueue.state&&clearTimeout(a.logQueue.timerId),a.logQueue={state:"stopped"},a.deliveryMetricsExportedToBigQueryEnabled?a.logQueue={state:"scheduled",timerId:setTimeout(async()=>{if(a.logQueue={state:"flushing"},!a.logEvents.length)return NS(a,LC);var e=a,t=e.logEvents;e.logEvents=[];for(let s=0,r=t.length;s<r;s+=DC){var n=t.slice(s,s+DC);if(!n.length)break;var i=(e=>{var t={};return t.log_source=FC.toString(),t.log_event=e,t})(n);let r=0,e={};do{try{if((e=await fetch(SS.concat("&key=",AS),{method:"POST",body:JSON.stringify(i)})).ok||!e.ok&&!RS(e))break;if(!e.ok&&RS(e))throw new Error("a retriable Non-200 code is returned in fetch to Firelog endpoint. Retry")}catch(e){if(r===OC)break}let t;try{t=Number((await e.json()).nextRequestWaitMillis)}catch(e){t=MC}await new Promise(e=>setTimeout(e,t)),r++}while(r<OC)}NS(e,e.logEvents.length?kS:LC)},e)}:a.logEvents=[]}function RS(e){var t=e.status;return 429===t||500===t||503===t||504===t}async function PS(e,t){var r=((e,t)=>{var r={};return e.from&&(r.project_number=e.from),e.fcmMessageId&&(r.message_id=e.fcmMessageId),r.instance_id=t,r.message_type=(e.notification?dI.DISPLAY_NOTIFICATION:dI.DATA_MESSAGE).toString(),r.sdk_platform=UC.toString(),r.package_name=self.origin.replace(/(^\w+:|^)\/\//,""),e.collapse_key&&(r.collapse_key=e.collapse_key),r.event=VC.toString(),e.fcmOptions?.analytics_label&&(r.analytics_label=e.fcmOptions?.analytics_label),r})(t,await e.firebaseDependencies.installations.getId()),n=e,i=r,t=t.productId,r={};r.event_time_ms=Math.floor(Date.now()).toString(),r.source_extension_json_proto3=JSON.stringify({messaging_client_event:i}),t&&(r.compliance_data=(e=>({privacy_context:{prequest:{origin_associated_product_id:e}}}))(t)),n.logEvents.push(r),"stopped"===(i=e).logQueue.state&&0<i.logEvents.length&&NS(i,kS)}async function xS(e,t){t.swRegistration||(t.swRegistration=self.registration);var r=e.newSubscription;if(r)if(await sS(t.firebaseDependencies).catch(()=>{})){r=await CS(t).catch(()=>{});if(r){var n=await MS();if(LS(n)){var i,e=n,s=r,a={isFirebaseMessaging:!0,messageType:pI.FID_REGISTERED,fid:s};for(i of e)i.postMessage(a)}}}else{n=await nS(t.firebaseDependencies);await wS(t),t.vapidKey=n?.subscriptionOptions?.vapidKey??NC,await vS(t)}else await wS(t)}async function DS(e,t){var r=(({data:e})=>{if(!e)return null;try{return e.json()}catch(e){return null}})(e);if(r){t.deliveryMetricsExportedToBigQueryEnabled&&await PS(t,r);var n,i,s,a=await MS();if(LS(a)){var o,e=a,l=r;l.isFirebaseMessaging=!0,l.messageType=pI.PUSH_RECEIVED;for(o of e)o.postMessage(l)}else r.notification&&await(e=>{var t=e.actions,r=Notification.maxActions;return t&&r&&t.length>r&&console.warn(`This browser only supports ${r} actions. The remaining actions will not be displayed.`),self.registration.showNotification(e.title??"",e)})(((a={...(e=r).notification}).data={[PC]:e},a)),t&&t.onBackgroundMessageHandler&&(a={from:(e=r).from,collapseKey:e.collapse_key,messageId:e.fcmMessageId},i=a,(n=e).notification&&(i.notification={},(s=n.notification.title)&&(i.notification.title=s),(s=n.notification.body)&&(i.notification.body=s),(s=n.notification.image)&&(i.notification.image=s),s=n.notification.icon)&&(i.notification.icon=s),n=a,(i=e).data&&(n.data=i.data),n=a,((i=e).fcmOptions||i.notification?.click_action)&&(n.fcmOptions={},(s=i.fcmOptions?.link??i.notification?.click_action)&&(n.fcmOptions.link=s),s=i.fcmOptions?.analytics_label)&&(n.fcmOptions.analyticsLabel=s),r=a,"function"==typeof t.onBackgroundMessageHandler?await t.onBackgroundMessageHandler(r):t.onBackgroundMessageHandler.next(r))}}async function OS(e){var t=e.notification?.data?.[PC];if(t&&!e.action){e.stopImmediatePropagation(),e.notification.close();var r=(e=>{var t=e.fcmOptions?.link??e.notification?.click_action;return t||((e=>"object"==typeof e&&e&&xC in e)(e.data)?self.location.origin:null)})(t);if(r){var n,i=new URL(r,self.location.href),s=new URL(self.location.origin);if(i.host===s.host){let e=await(async e=>{var t;for(t of await MS()){var r=new URL(t.url,self.location.href);if(e.host===r.host)return t}return null})(i);if(e?e=await e.focus():(e=await self.clients.openWindow(r),n=3e3,await new Promise(e=>{setTimeout(e,n)})),e)return t.messageType=pI.NOTIFICATION_CLICKED,t.isFirebaseMessaging=!0,e.postMessage(t)}}}}function LS(e){return e.some(e=>"visible"===e.visibilityState&&!e.url.startsWith("chrome-extension://"))}function MS(){return self.clients.matchAll({type:"window",includeUncontrolled:!0})}function FS(e){return GC.create("missing-app-config-values",{valueName:e})}class US{constructor(e,t,r){this.deliveryMetricsExportedToBigQueryEnabled=!1,this.onBackgroundMessageHandler=null,this.onMessageHandler=null,this.onRegisteredHandler=null,this.onUnregisteredHandler=null,this._registerNotifyChain=Promise.resolve(),this._fidChangeUnsubscribe=null,this.logEvents=[],this.logQueue={state:"stopped"};var n=(e=>{if(!e||!e.options)throw FS("App Configuration Object");if(!e.name)throw FS("App Name");var t,r=e.options;for(t of["projectId","apiKey","appId","messagingSenderId"])if(!r[t])throw FS(t);return{appName:e.name,projectId:r.projectId,apiKey:r.apiKey,appId:r.appId,senderId:r.messagingSenderId}})(e);this.firebaseDependencies={app:e,appConfig:n,installations:t,analyticsProvider:r}}_delete(){return this._fidChangeUnsubscribe&&(this._fidChangeUnsubscribe(),this._fidChangeUnsubscribe=null),"scheduled"===this.logQueue.state&&clearTimeout(this.logQueue.timerId),this.logQueue={state:"stopped"},Promise.resolve()}}let VS=e=>{let t=new US(e.getProvider("app").getImmediate(),e.getProvider("installations-internal").getImmediate(),e.getProvider("analytics-internal"));return self.addEventListener("push",e=>{e.waitUntil(DS(e,t))}),self.addEventListener("pushsubscriptionchange",e=>{e.waitUntil(xS(e,t))}),self.addEventListener("notificationclick",e=>{e.waitUntil(OS(e))}),t};function BS(e,t){var r=e=w(e),e=t;if(void 0!==self.document)throw GC.create("only-available-in-sw");return r.onBackgroundMessageHandler=e,()=>{r.onBackgroundMessageHandler=null}}Rt(new h("messaging-sw",VS,"PUBLIC"));var qS,jS,zS;class HS{constructor(e,t){this.app=e,this._delegate=t,this.app=e,this._delegate=t}async getToken(e){return(async(e,t)=>TC(e=w(e),t))(this._delegate,e)}async deleteToken(){return kC(w(this._delegate))}onMessage(e){return AC(this._delegate,e)}onBackgroundMessage(e){return BS(this._delegate,e)}}let KS=e=>self&&"ServiceWorkerGlobalScope"in self?new HS(e.getProvider("app-compat").getImmediate(),e.getProvider("messaging-sw").getImmediate()):new HS(e.getProvider("app-compat").getImmediate(),e.getProvider("messaging").getImmediate()),GS={isSupported:function(){return self&&"ServiceWorkerGlobalScope"in self?ce()&&"PushManager"in self&&"Notification"in self&&ServiceWorkerRegistration.prototype.hasOwnProperty("showNotification")&&PushSubscription.prototype.hasOwnProperty("getKey"):"undefined"!=typeof window&&ce()&&pe()&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window&&"fetch"in window&&ServiceWorkerRegistration.prototype.hasOwnProperty("showNotification")&&PushSubscription.prototype.hasOwnProperty("getKey")}};pr.INTERNAL.registerComponent(new h("messaging-compat",KS,"PUBLIC").setServiceProps(GS)),pr.registerVersion("@firebase/messaging-compat","0.2.27");let WS="firebasestorage.googleapis.com",$S="storageBucket";class YS extends fe{constructor(e,t,r=0){super(QS(e),`Firebase Storage: ${t} (${QS(e)})`),this.status_=r,this.customData={serverResponse:null},this._baseMessage=this.message,Object.setPrototypeOf(this,YS.prototype)}get status(){return this.status_}set status(e){this.status_=e}_codeEquals(e){return QS(e)===this.code}get serverResponse(){return this.customData.serverResponse}set serverResponse(e){this.customData.serverResponse=e,this.customData.serverResponse?this.message=this._baseMessage+`
`+this.customData.serverResponse:this.message=this._baseMessage}}function QS(e){return"storage/"+e}function JS(){return new YS(qS.UNKNOWN,"An unknown error occurred, please check the error payload for server response.")}function XS(){return new YS(qS.RETRY_LIMIT_EXCEEDED,"Max retry time for operation exceeded, please try again.")}function ZS(){return new YS(qS.CANCELED,"User canceled the upload/download.")}function ek(){return new YS(qS.CANNOT_SLICE_BLOB,"Cannot slice blob for upload. Please retry the upload.")}function tk(e){return new YS(qS.INVALID_ARGUMENT,e)}function rk(){return new YS(qS.APP_DELETED,"The Firebase app was deleted.")}function nk(e){return new YS(qS.INVALID_ROOT_OPERATION,"The operation '"+e+"' cannot be performed on a root reference, create a non-root reference using child, such as .child('file.png').")}function ik(e,t){return new YS(qS.INVALID_FORMAT,"String does not match format '"+e+"': "+t)}function sk(e){throw new YS(qS.INTERNAL_ERROR,"Internal error: "+e)}(WN=qS=qS||{}).UNKNOWN="unknown",WN.OBJECT_NOT_FOUND="object-not-found",WN.BUCKET_NOT_FOUND="bucket-not-found",WN.PROJECT_NOT_FOUND="project-not-found",WN.QUOTA_EXCEEDED="quota-exceeded",WN.UNAUTHENTICATED="unauthenticated",WN.UNAUTHORIZED="unauthorized",WN.UNAUTHORIZED_APP="unauthorized-app",WN.RETRY_LIMIT_EXCEEDED="retry-limit-exceeded",WN.INVALID_CHECKSUM="invalid-checksum",WN.CANCELED="canceled",WN.INVALID_EVENT_NAME="invalid-event-name",WN.INVALID_URL="invalid-url",WN.INVALID_DEFAULT_BUCKET="invalid-default-bucket",WN.NO_DEFAULT_BUCKET="no-default-bucket",WN.CANNOT_SLICE_BLOB="cannot-slice-blob",WN.SERVER_FILE_WRONG_SIZE="server-file-wrong-size",WN.NO_DOWNLOAD_URL="no-download-url",WN.INVALID_ARGUMENT="invalid-argument",WN.INVALID_ARGUMENT_COUNT="invalid-argument-count",WN.APP_DELETED="app-deleted",WN.INVALID_ROOT_OPERATION="invalid-root-operation",WN.INVALID_FORMAT="invalid-format",WN.INTERNAL_ERROR="internal-error",WN.UNSUPPORTED_ENVIRONMENT="unsupported-environment";class ak{constructor(e,t){this.bucket=e,this.path_=t}get path(){return this.path_}get isRoot(){return 0===this.path.length}fullServerUrl(){var e=encodeURIComponent;return"/b/"+e(this.bucket)+"/o/"+e(this.path)}bucketOnlyServerUrl(){return"/b/"+encodeURIComponent(this.bucket)+"/o"}static makeFromBucketSpec(t,e){let r;try{r=ak.makeFromUrl(t,e)}catch(e){return new ak(t,"")}if(""===r.path)return r;throw e=t,new YS(qS.INVALID_DEFAULT_BUCKET,"Invalid default bucket '"+e+"'.")}static makeFromUrl(e,t){let r=null;var n="([A-Za-z0-9.\\-_]+)";var i=new RegExp("^gs://"+n+"(/(.*))?$","i");function s(e){e.path_=decodeURIComponent(e.path)}var a=t.replace(/[.]/g,"\\."),a=new RegExp(`^https?://${a}/v[A-Za-z0-9_]+/b/${n}/o(/([^?#]*).*)?$`,"i"),o=t===WS?"(?:storage.googleapis.com|storage.cloud.google.com)":t,l=[{regex:i,indices:{bucket:1,path:3},postModify:function(e){"/"===e.path.charAt(e.path.length-1)&&(e.path_=e.path_.slice(0,-1))}},{regex:a,indices:{bucket:1,path:3},postModify:s},{regex:new RegExp(`^https?://${o}/${n}/([^?#]*)`,"i"),indices:{bucket:1,path:2},postModify:s}];for(let d=0;d<l.length;d++){var u=l[d],h=u.regex.exec(e);if(h){var c=h[u.indices.bucket];let e=h[u.indices.path];e=e||"",r=new ak(c,e),u.postModify(r);break}}if(null==r)throw t=e,new YS(qS.INVALID_URL,"Invalid URL '"+t+"'.");return r}}class ok{constructor(e){this.promise_=Promise.reject(e)}getPromise(){return this.promise_}cancel(e=0){}}function lk(e){return"string"==typeof e||e instanceof String}function uk(e){return hk()&&e instanceof Blob}function hk(){return"undefined"!=typeof Blob}function ck(e,t,r,n){if(n<t)throw tk(`Invalid value for '${e}'. Expected ${t} or greater.`);if(r<n)throw tk(`Invalid value for '${e}'. Expected ${r} or less.`)}function dk(e,t,r){let n=null==r?"https://"+t:t;return`${r}://${n}/v0`+e}function pk(e){var t,r,n=encodeURIComponent;let i="?";for(t in e)e.hasOwnProperty(t)&&(r=n(t)+"="+n(e[t]),i=i+r+"&");return i=i.slice(0,-1)}function fk(e,t){var r=500<=e&&e<600,n=-1!==[408,429].indexOf(e),i=-1!==t.indexOf(e);return r||n||i}(t=jS=jS||{})[t.NO_ERROR=0]="NO_ERROR",t[t.NETWORK_ERROR=1]="NETWORK_ERROR",t[t.ABORT=2]="ABORT";class gk{constructor(e,t,r,n,i,s,a,o,l,u,h,c=!0,d=!1){this.url_=e,this.method_=t,this.headers_=r,this.body_=n,this.successCodes_=i,this.additionalRetryCodes_=s,this.callback_=a,this.errorCallback_=o,this.timeout_=l,this.progressCallback_=u,this.connectionFactory_=h,this.retry=c,this.isUsingEmulator=d,this.pendingConnection_=null,this.backoffId_=null,this.canceled_=!1,this.appDelete_=!1,this.promise_=new Promise((e,t)=>{this.resolve_=e,this.reject_=t,this.start_()})}start_(){var e=(i,e)=>{if(e)i(!1,new mk(!1,null,!0));else{let r=this.connectionFactory_(),n=(this.pendingConnection_=r,e=>{var t=e.loaded,r=e.lengthComputable?e.total:-1;null!==this.progressCallback_&&this.progressCallback_(t,r)});null!==this.progressCallback_&&r.addUploadProgressListener(n),r.send(this.url_,this.method_,this.isUsingEmulator,this.body_,this.headers_).then(()=>{null!==this.progressCallback_&&r.removeUploadProgressListener(n),this.pendingConnection_=null;var e=r.getErrorCode()===jS.NO_ERROR,t=r.getStatus();!e||fk(t,this.additionalRetryCodes_)&&this.retry?(e=r.getErrorCode()===jS.ABORT,i(!1,new mk(!1,null,e))):(e=-1!==this.successCodes_.indexOf(t),i(!0,new mk(e,r)))})}},t=(e,t)=>{var r=this.resolve_,n=this.reject_,i=t.connection;if(t.wasSuccessCode)try{var s=this.callback_(i,i.getResponse());void 0!==s?r(s):r()}catch(e){n(e)}else null!==i?((s=JS()).serverResponse=i.getErrorText(),this.errorCallback_?n(this.errorCallback_(i,s)):n(s)):t.canceled?n((this.appDelete_?rk:ZS)()):n(XS())};this.canceled_?t(0,new mk(!1,null,!0)):this.backoffId_=((t,r,e)=>{let n=1,i=null,s=null,a=!1,o=0;function l(){return 2===o}let u=!1;function h(...e){u||(u=!0,r.apply(null,e))}function c(e){i=setTimeout(()=>{i=null,t(p,l())},e)}function d(){s&&clearTimeout(s)}function p(e,...t){if(u)d();else if(e)d(),h.call(null,e,...t);else if(l()||a)d(),h.call(null,e,...t);else{n<64&&(n*=2);let e;c(e=1===o?(o=2,0):1e3*(n+Math.random()))}}let f=!1;function g(e){f||(f=!0,d(),u)||(null!==i?(e||(o=2),clearTimeout(i),c(0)):e||(o=1))}return c(0),s=setTimeout(()=>{g(a=!0)},e),g})(e,t,this.timeout_)}getPromise(){return this.promise_}cancel(e){this.canceled_=!0,this.appDelete_=e||!1,null!==this.backoffId_&&(0,this.backoffId_)(!1),null!==this.pendingConnection_&&this.pendingConnection_.abort()}}class mk{constructor(e,t,r){this.wasSuccessCode=e,this.connection=t,this.canceled=!!r}}function vk(...t){var r="undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof WebKitBlobBuilder?WebKitBlobBuilder:void 0;if(void 0!==r){var n=new r;for(let e=0;e<t.length;e++)n.append(t[e]);return n.getBlob()}if(hk())return new Blob(t);throw new YS(qS.UNSUPPORTED_ENVIRONMENT,"This browser doesn't seem to support creating Blobs")}function _k(e){if("undefined"==typeof atob)throw new YS(qS.UNSUPPORTED_ENVIRONMENT,"base-64 is missing. Make sure to install the required polyfills. See https://firebase.google.com/docs/web/environments-js-sdk#polyfills for more information.");return atob(e)}let yk={RAW:"raw",BASE64:"base64",BASE64URL:"base64url",DATA_URL:"data_url"};class wk{constructor(e,t){this.data=e,this.contentType=t||null}}function bk(e,t){switch(e){case yk.RAW:return new wk(Tk(t));case yk.BASE64:case yk.BASE64URL:return new wk(Ek(e,t));case yk.DATA_URL:return new wk((r=t,(n=new Ik(r)).base64?Ek(yk.BASE64,n.rest):(e=>{let t;try{t=decodeURIComponent(e)}catch(e){throw ik(yk.DATA_URL,"Malformed data URL.")}return Tk(t)})(n.rest)),(r=t,new Ik(r).contentType))}var r,n;throw JS()}function Tk(t){var r,n,i=[];for(let s=0;s<t.length;s++){let e=t.charCodeAt(s);e<=127?i.push(e):e<=2047?i.push(192|e>>6,128|63&e):55296==(64512&e)?s<t.length-1&&56320==(64512&t.charCodeAt(s+1))?(r=e,n=t.charCodeAt(++s),e=65536|(1023&r)<<10|1023&n,i.push(240|e>>18,128|e>>12&63,128|e>>6&63,128|63&e)):i.push(239,191,189):56320==(64512&e)?i.push(239,191,189):i.push(224|e>>12,128|e>>6&63,128|63&e)}return new Uint8Array(i)}function Ek(t,e){switch(t){case yk.BASE64:var r=-1!==e.indexOf("-"),n=-1!==e.indexOf("_");if(r||n)throw ik(t,"Invalid character '"+(r?"-":"_")+"' found: is it base64url encoded?");break;case yk.BASE64URL:n=-1!==e.indexOf("+"),r=-1!==e.indexOf("/");if(n||r)throw ik(t,"Invalid character '"+(n?"+":"/")+"' found: is it base64 encoded?");e=e.replace(/-/g,"+").replace(/_/g,"/")}let i;try{i=_k(e)}catch(e){if(e.message.includes("polyfill"))throw e;throw ik(t,"Invalid character found")}var s=new Uint8Array(i.length);for(let a=0;a<i.length;a++)s[a]=i.charCodeAt(a);return s}class Ik{constructor(e){this.base64=!1,this.contentType=null;var t=e.match(/^data:([^,]+)?,/);if(null===t)throw ik(yk.DATA_URL,"Must be formatted 'data:[<mediatype>][;base64],<data>");var r,n,t=t[1]||null;null!=t&&(this.base64=(n=";base64",(r=t).length>=n.length&&r.substring(r.length-n.length)===n),this.contentType=this.base64?t.substring(0,t.length-";base64".length):t),this.rest=e.substring(e.indexOf(",")+1)}}class Ck{constructor(e,t){let r=0,n="";uk(e)?(this.data_=e,r=e.size,n=e.type):e instanceof ArrayBuffer?(t?this.data_=new Uint8Array(e):(this.data_=new Uint8Array(e.byteLength),this.data_.set(new Uint8Array(e))),r=this.data_.length):e instanceof Uint8Array&&(t?this.data_=e:(this.data_=new Uint8Array(e.length),this.data_.set(e)),r=e.length),this.size_=r,this.type_=n}size(){return this.size_}type(){return this.type_}slice(e,t){var r,n,i,s;return uk(this.data_)?(r=this.data_,i=e,s=t,null===(r=(n=r).webkitSlice?n.webkitSlice(i,s):n.mozSlice?n.mozSlice(i,s):n.slice?n.slice(i,s):null)?null:new Ck(r)):(r=new Uint8Array(this.data_.buffer,e,t-e),new Ck(r,!0))}static getBlob(...e){if(hk())return i=e.map(e=>e instanceof Ck?e.data_:e),new Ck(vk.apply(null,i));{var i=e.map(e=>lk(e)?bk(yk.RAW,e).data:e.data_);let t=0,r=(i.forEach(e=>{t+=e.byteLength}),new Uint8Array(t)),n=0;return i.forEach(e=>{for(let t=0;t<e.length;t++)r[n++]=e[t]}),new Ck(r,!0)}}uploadData(){return this.data_}}function Sk(e){let t;try{t=JSON.parse(e)}catch(e){return null}return"object"!=typeof(e=t)||Array.isArray(e)?null:t}function kk(e){var t=e.lastIndexOf("/",e.length-2);return-1===t?e:e.slice(t+1)}function Ak(e,t){return t}class Nk{constructor(e,t,r,n){this.server=e,this.local=t||e,this.writable=!!r,this.xform=n||Ak}}let Rk=null;function Pk(){var e,t;return Rk||((e=[]).push(new Nk("bucket")),e.push(new Nk("generation")),e.push(new Nk("metageneration")),e.push(new Nk("name","fullPath",!0)),(t=new Nk("name")).xform=function(e,t){return!lk(t=t)||t.length<2?t:kk(t)},e.push(t),(t=new Nk("size")).xform=function(e,t){return void 0!==t?Number(t):t},e.push(t),e.push(new Nk("timeCreated")),e.push(new Nk("updated")),e.push(new Nk("md5Hash",null,!0)),e.push(new Nk("cacheControl",null,!0)),e.push(new Nk("contentDisposition",null,!0)),e.push(new Nk("contentEncoding",null,!0)),e.push(new Nk("contentLanguage",null,!0)),e.push(new Nk("contentType",null,!0)),e.push(new Nk("metadata","customMetadata",!0)),Rk=e),Rk}function xk(r,n){Object.defineProperty(r,"ref",{get:function(){var e=r.bucket,t=r.fullPath,e=new ak(e,t);return n._makeStorageReference(e)}})}function Dk(e,t,r){var n=Sk(t);if(null===n)return null;var t=e,i=n,s=r,a={type:"file"},o=s.length;for(let u=0;u<o;u++){var l=s[u];a[l.local]=l.xform(a,i[l.server])}return xk(a,t),a}function Ok(e,t){var r={},n=t.length;for(let s=0;s<n;s++){var i=t[s];i.writable&&(r[i.server]=e[i.local])}return JSON.stringify(r)}let Lk="prefixes",Mk="items";function Fk(e,t,r){var n=Sk(r);if(null===n)return null;var i=e,s=t,r=n,a={prefixes:[],items:[],nextPageToken:r.nextPageToken};if(r[Lk])for(var o of r[Lk]){o=o.replace(/\/$/,""),o=i._makeStorageReference(new ak(s,o));a.prefixes.push(o)}if(r[Mk])for(var l of r[Mk]){l=i._makeStorageReference(new ak(s,l.name));a.items.push(l)}return a}class Uk{constructor(e,t,r,n){this.url=e,this.method=t,this.handler=r,this.timeout=n,this.urlParams={},this.headers={},this.body=null,this.errorHandler=null,this.progressCallback=null,this.successCodes=[200],this.additionalRetryCodes=[]}}function Vk(e){if(!e)throw JS()}function Bk(n,i){return function(e,t){var r=Dk(n,t,i);return Vk(null!==r),r}}function qk(n,i){return function(e,t){var r=Fk(n,i,t);return Vk(null!==r),r}}function jk(o,n){return function(e,t){var r=Dk(o,t,n);Vk(null!==r);{var i=r,s=o.host,a=o._protocol;if(null===(r=Sk(t)))return null;if(!lk(r.downloadTokens))return null;if(0===(r=r.downloadTokens).length)return null;let n=encodeURIComponent;return r.split(",").map(e=>{var t=i.bucket,r=i.fullPath;return dk("/b/"+n(t)+"/o/"+n(r),s,a)+pk({alt:"media",token:e})})[0]}}}function zk(i){return function(e,t){let r;var n;return(r=401===e.getStatus()?e.getErrorText().includes("Firebase App Check token is invalid")?new YS(qS.UNAUTHORIZED_APP,"This app does not have permission to access Firebase Storage on this project."):new YS(qS.UNAUTHENTICATED,"User is not authenticated, please authenticate using Firebase Authentication and try again."):402===e.getStatus()?(n=i.bucket,new YS(qS.QUOTA_EXCEEDED,"Quota for bucket '"+n+"' exceeded, please view quota on https://firebase.google.com/pricing/.")):403===e.getStatus()?(n=i.path,new YS(qS.UNAUTHORIZED,"User does not have permission to access '"+n+"'.")):t).status=e.getStatus(),r.serverResponse=t.serverResponse,r}}function Hk(n){let i=zk(n);return function(e,t){let r=i(e,t);return(r=404===e.getStatus()?(e=n.path,new YS(qS.OBJECT_NOT_FOUND,"Object '"+e+"' does not exist.")):r).serverResponse=t.serverResponse,r}}function Kk(e,t,r){var n=dk(t.fullServerUrl(),e.host,e._protocol),i=e.maxOperationRetryTime,n=new Uk(n,"GET",Bk(e,r),i);return n.errorHandler=Hk(t),n}function Gk(e,t,r){var n=Object.assign({},r);return n.fullPath=e.path,n.size=t.size(),n.contentType||(n.contentType=(r=t,(e=null)&&e.contentType||r&&r.type()||"application/octet-stream")),n}function Wk(e,t,r,n,i){var s=t.bucketOnlyServerUrl(),a={"X-Goog-Upload-Protocol":"multipart"};var o=(()=>{let e="";for(let t=0;t<2;t++)e+=Math.random().toString().slice(2);return e})(),l=(a["Content-Type"]="multipart/related; boundary="+o,Gk(t,n,i)),u="--"+o+"\r\nContent-Type: application/json; charset=utf-8\r\n\r\n"+Ok(l,r)+"\r\n--"+o+"\r\nContent-Type: "+l.contentType+"\r\n\r\n",o="\r\n--"+o+"--",u=Ck.getBlob(u,n,o);if(null===u)throw ek();o={name:l.fullPath},l=dk(s,e.host,e._protocol),s=e.maxUploadRetryTime,l=new Uk(l,"POST",Bk(e,r),s);return l.urlParams=o,l.headers=a,l.body=u.uploadData(),l.errorHandler=zk(t),l}class $k{constructor(e,t,r,n){this.current=e,this.total=t,this.finalized=!!r,this.metadata=n||null}}function Yk(e,t){let r=null;try{r=e.getResponseHeader("X-Goog-Upload-Status")}catch(e){Vk(!1)}return Vk(!!r&&-1!==(t||["active"]).indexOf(r)),r}function Qk(e,t,r,n,i){var s=t.bucketOnlyServerUrl(),a=Gk(t,n,i),o={name:a.fullPath},s=dk(s,e.host,e._protocol),l={"X-Goog-Upload-Protocol":"resumable","X-Goog-Upload-Command":"start","X-Goog-Upload-Header-Content-Length":""+n.size(),"X-Goog-Upload-Header-Content-Type":a.contentType,"Content-Type":"application/json; charset=utf-8"},a=Ok(a,r),u=e.maxUploadRetryTime;s=new Uk(s,"POST",function(e){Yk(e);let t;try{t=e.getResponseHeader("X-Goog-Upload-URL")}catch(e){Vk(!1)}return Vk(lk(t)),t},u);return s.urlParams=o,s.headers=l,s.body=a,s.errorHandler=zk(t),s}function Jk(e,t,r,i){var n=e.maxUploadRetryTime,n=new Uk(r,"POST",function(e){var t=Yk(e,["active","final"]);let r=null;try{r=e.getResponseHeader("X-Goog-Upload-Size-Received")}catch(e){Vk(!1)}r||Vk(!1);var n=Number(r);return Vk(!isNaN(n)),new $k(n,i.size(),"final"===t)},n);return n.headers={"X-Goog-Upload-Command":"query"},n.errorHandler=zk(t),n}function Xk(e,a,t,o,r,l,n,i){let u=new $k(0,0);if(n?(u.current=n.current,u.total=n.total):(u.current=0,u.total=o.size()),o.size()!==u.total)throw new YS(qS.SERVER_FILE_WRONG_SIZE,"Server recorded incorrect upload file size, please retry the upload.");var s=u.total-u.current;let h=s;0<r&&(h=Math.min(h,r));var c=u.current,d=c+h;let p="";s={"X-Goog-Upload-Command":p=0===h?"finalize":s===h?"upload, finalize":"upload","X-Goog-Upload-Offset":""+u.current},c=o.slice(c,d);if(null===c)throw ek();d=a.maxUploadRetryTime,d=new Uk(t,"POST",function(e,t){var r=Yk(e,["active","final"]),n=u.current+h,i=o.size();let s;return s="final"===r?Bk(a,l)(e,t):null,new $k(n,i,"final"===r,s)},d);return d.headers=s,d.body=c.uploadData(),d.progressCallback=i||null,d.errorHandler=zk(e),d}let Zk={STATE_CHANGED:"state_changed"},eA={RUNNING:"running",PAUSED:"paused",SUCCESS:"success",CANCELED:"canceled",ERROR:"error"};function tA(e){switch(e){case"running":case"pausing":case"canceling":return eA.RUNNING;case"paused":return eA.PAUSED;case"success":return eA.SUCCESS;case"canceled":return eA.CANCELED;default:return eA.ERROR}}class rA{constructor(e,t,r){var n;"function"==typeof e||null!=t||null!=r?(this.next=e,this.error=t??void 0,this.complete=r??void 0):(this.next=(n=e).next,this.error=n.error,this.complete=n.complete)}}function nA(t){return(...e)=>{Promise.resolve().then(()=>t(...e))}}class iA extends class{constructor(){this.sent_=!1,this.xhr_=new XMLHttpRequest,this.initXhr(),this.errorCode_=jS.NO_ERROR,this.sendPromise_=new Promise(e=>{this.xhr_.addEventListener("abort",()=>{this.errorCode_=jS.ABORT,e()}),this.xhr_.addEventListener("error",()=>{this.errorCode_=jS.NETWORK_ERROR,e()}),this.xhr_.addEventListener("load",()=>{e()})})}send(e,t,r,n,i){if(this.sent_)throw sk("cannot .send() more than once");if(ze(e)&&r&&(this.xhr_.withCredentials=!0),this.sent_=!0,this.xhr_.open(t,e,!0),void 0!==i)for(var s in i)i.hasOwnProperty(s)&&this.xhr_.setRequestHeader(s,i[s].toString());return void 0!==n?this.xhr_.send(n):this.xhr_.send(),this.sendPromise_}getErrorCode(){if(this.sent_)return this.errorCode_;throw sk("cannot .getErrorCode() before sending")}getStatus(){if(!this.sent_)throw sk("cannot .getStatus() before sending");try{return this.xhr_.status}catch(e){return-1}}getResponse(){if(this.sent_)return this.xhr_.response;throw sk("cannot .getResponse() before sending")}getErrorText(){if(this.sent_)return this.xhr_.statusText;throw sk("cannot .getErrorText() before sending")}abort(){this.xhr_.abort()}getResponseHeader(e){return this.xhr_.getResponseHeader(e)}addUploadProgressListener(e){null!=this.xhr_.upload&&this.xhr_.upload.addEventListener("progress",e)}removeUploadProgressListener(e){null!=this.xhr_.upload&&this.xhr_.upload.removeEventListener("progress",e)}}{initXhr(){this.xhr_.responseType="text"}}function sA(){return new iA}class aA{isExponentialBackoffExpired(){return this.sleepTime>this.maxSleepTime}constructor(e,t,r=null){this._transferred=0,this._needToFetchStatus=!1,this._needToFetchMetadata=!1,this._observers=[],this._error=void 0,this._uploadUrl=void 0,this._request=void 0,this._chunkMultiplier=1,this._resolve=void 0,this._reject=void 0,this._ref=e,this._blob=t,this._metadata=r,this._mappings=Pk(),this._resumable=this._shouldDoResumable(this._blob),this._state="running",this._errorHandler=e=>{if(this._request=void 0,this._chunkMultiplier=1,e._codeEquals(qS.CANCELED))this._needToFetchStatus=!0,this.completeTransitions_();else{var t=this.isExponentialBackoffExpired();if(fk(e.status,[])){if(!t)return this.sleepTime=Math.max(2*this.sleepTime,1e3),this._needToFetchStatus=!0,void this.completeTransitions_();e=XS()}this._error=e,this._transition("error")}},this._metadataErrorHandler=e=>{this._request=void 0,e._codeEquals(qS.CANCELED)?this.completeTransitions_():(this._error=e,this._transition("error"))},this.sleepTime=0,this.maxSleepTime=this._ref.storage.maxUploadRetryTime,this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t,this._start()}),this._promise.then(null,()=>{})}_makeProgressCallback(){let t=this._transferred;return e=>this._updateProgress(t+e)}_shouldDoResumable(e){return 262144<e.size()}_start(){"running"===this._state&&void 0===this._request&&(this._resumable?void 0===this._uploadUrl?this._createResumable():this._needToFetchStatus?this._fetchStatus():this._needToFetchMetadata?this._fetchMetadata():this.pendingTimeout=setTimeout(()=>{this.pendingTimeout=void 0,this._continueUpload()},this.sleepTime):this._oneShotUpload())}_resolveToken(r){Promise.all([this._ref.storage._getAuthToken(),this._ref.storage._getAppCheckToken()]).then(([e,t])=>{switch(this._state){case"running":r(e,t);break;case"canceling":this._transition("canceled");break;case"pausing":this._transition("paused")}})}_createResumable(){this._resolveToken((e,t)=>{var r=Qk(this._ref.storage,this._ref._location,this._mappings,this._blob,this._metadata),r=this._ref.storage._makeRequest(r,sA,e,t);(this._request=r).getPromise().then(e=>{this._request=void 0,this._uploadUrl=e,this._needToFetchStatus=!1,this.completeTransitions_()},this._errorHandler)})}_fetchStatus(){let n=this._uploadUrl;this._resolveToken((e,t)=>{var r=Jk(this._ref.storage,this._ref._location,n,this._blob),r=this._ref.storage._makeRequest(r,sA,e,t);(this._request=r).getPromise().then(e=>{this._request=void 0,this._updateProgress(e.current),this._needToFetchStatus=!1,e.finalized&&(this._needToFetchMetadata=!0),this.completeTransitions_()},this._errorHandler)})}_continueUpload(){let i=262144*this._chunkMultiplier,s=new $k(this._transferred,this._blob.size()),a=this._uploadUrl;this._resolveToken((e,t)=>{let r;try{r=Xk(this._ref._location,this._ref.storage,a,this._blob,i,this._mappings,s,this._makeProgressCallback())}catch(e){return this._error=e,void this._transition("error")}var n=this._ref.storage._makeRequest(r,sA,e,t,!1);(this._request=n).getPromise().then(e=>{this._increaseMultiplier(),this._request=void 0,this._updateProgress(e.current),e.finalized?(this._metadata=e.metadata,this._transition("success")):this.completeTransitions_()},this._errorHandler)})}_increaseMultiplier(){2*(262144*this._chunkMultiplier)<33554432&&(this._chunkMultiplier*=2)}_fetchMetadata(){this._resolveToken((e,t)=>{var r=Kk(this._ref.storage,this._ref._location,this._mappings),r=this._ref.storage._makeRequest(r,sA,e,t);(this._request=r).getPromise().then(e=>{this._request=void 0,this._metadata=e,this._transition("success")},this._metadataErrorHandler)})}_oneShotUpload(){this._resolveToken((e,t)=>{var r=Wk(this._ref.storage,this._ref._location,this._mappings,this._blob,this._metadata),r=this._ref.storage._makeRequest(r,sA,e,t);(this._request=r).getPromise().then(e=>{this._request=void 0,this._metadata=e,this._updateProgress(this._blob.size()),this._transition("success")},this._errorHandler)})}_updateProgress(e){var t=this._transferred;this._transferred=e,this._transferred!==t&&this._notifyObservers()}_transition(e){if(this._state!==e)switch(e){case"canceling":case"pausing":this._state=e,void 0!==this._request?this._request.cancel():this.pendingTimeout&&(clearTimeout(this.pendingTimeout),this.pendingTimeout=void 0,this.completeTransitions_());break;case"running":var t="paused"===this._state;this._state=e,t&&(this._notifyObservers(),this._start());break;case"paused":this._state=e,this._notifyObservers();break;case"canceled":this._error=ZS(),this._state=e,this._notifyObservers();break;case"error":case"success":this._state=e,this._notifyObservers()}}completeTransitions_(){switch(this._state){case"pausing":this._transition("paused");break;case"canceling":this._transition("canceled");break;case"running":this._start()}}get snapshot(){var e=tA(this._state);return{bytesTransferred:this._transferred,totalBytes:this._blob.size(),state:e,metadata:this._metadata,task:this,ref:this._ref}}on(e,t,r,n){let i=new rA(t||void 0,r||void 0,n||void 0);return this._addObserver(i),()=>{this._removeObserver(i)}}then(e,t){return this._promise.then(e,t)}catch(e){return this.then(null,e)}_addObserver(e){this._observers.push(e),this._notifyObserver(e)}_removeObserver(e){var t=this._observers.indexOf(e);-1!==t&&this._observers.splice(t,1)}_notifyObservers(){this._finishPromise(),this._observers.slice().forEach(e=>{this._notifyObserver(e)})}_finishPromise(){if(void 0!==this._resolve){let e=!0;switch(tA(this._state)){case eA.SUCCESS:nA(this._resolve.bind(null,this.snapshot))();break;case eA.CANCELED:case eA.ERROR:nA(this._reject.bind(null,this._error))();break;default:e=!1}e&&(this._resolve=void 0,this._reject=void 0)}}_notifyObserver(e){switch(tA(this._state)){case eA.RUNNING:case eA.PAUSED:e.next&&nA(e.next.bind(e,this.snapshot))();break;case eA.SUCCESS:e.complete&&nA(e.complete.bind(e))();break;case eA.CANCELED:case eA.ERROR:default:e.error&&nA(e.error.bind(e,this._error))()}}resume(){var e="paused"===this._state||"pausing"===this._state;return e&&this._transition("running"),e}pause(){var e="running"===this._state;return e&&this._transition("pausing"),e}cancel(){var e="running"===this._state||"pausing"===this._state;return e&&this._transition("canceling"),e}}class oA{constructor(e,t){this._service=e,t instanceof ak?this._location=t:this._location=ak.makeFromUrl(t,e.host)}toString(){return"gs://"+this._location.bucket+"/"+this._location.path}_newRef(e,t){return new oA(e,t)}get root(){var e=new ak(this._location.bucket,"");return this._newRef(this._service,e)}get bucket(){return this._location.bucket}get fullPath(){return this._location.path}get name(){return kk(this._location.path)}get storage(){return this._service}get parent(){var e,t,r=0===(e=this._location.path).length?null:-1===(r=e.lastIndexOf("/"))?"":e.slice(0,r);return null===r?null:(t=new ak(this._location.bucket,r),new oA(this._service,t))}_throwIfRoot(e){if(""===this._location.path)throw nk(e)}}function lA(e){let t={prefixes:[],items:[]};return async function e(t,r,n){let i={pageToken:n};let s=await uA(t,i);r.prefixes.push(...s.prefixes);r.items.push(...s.items);null!=s.nextPageToken&&await e(t,r,s.nextPageToken)}(e,t).then(()=>t)}function uA(e,t){null!=t&&"number"==typeof t.maxResults&&ck("options.maxResults",1,1e3,t.maxResults);var r,n,i,s,a,o=t||{},l=(t=e.storage,r=e._location,n="/",i=o.pageToken,s=o.maxResults,o={},r.isRoot?o.prefix="":o.prefix=r.path+"/",n&&0<n.length&&(o.delimiter=n),i&&(o.pageToken=i),s&&(o.maxResults=s),a=dk(a=r.bucketOnlyServerUrl(),t.host,t._protocol),l=t.maxOperationRetryTime,(a=new Uk(a,"GET",qk(t,r.bucket),l)).urlParams=o,a.errorHandler=zk(r),a);return e.storage.makeRequestWithTokens(l,sA)}function hA(e,t){e._throwIfRoot("updateMetadata");r=e.storage,n=e._location,t=t,i=Pk(),s=dk(n.fullServerUrl(),r.host,r._protocol),a=Ok(t,i),o=r.maxOperationRetryTime,(s=new Uk(s,"PATCH",Bk(r,i),o)).headers={"Content-Type":"application/json; charset=utf-8"},s.body=a,s.errorHandler=Hk(n);var r,n,i,s,a,o=s;return e.storage.makeRequestWithTokens(o,sA)}function cA(e){e._throwIfRoot("getDownloadURL");t=e.storage,r=e._location,n=Pk(),i=dk(r.fullServerUrl(),t.host,t._protocol),s=t.maxOperationRetryTime,(i=new Uk(i,"GET",jk(t,n),s)).errorHandler=Hk(r);var t,r,n,i,s=i;return e.storage.makeRequestWithTokens(s,sA).then(e=>{if(null===e)throw new YS(qS.NO_DOWNLOAD_URL,"The given file does not have any download URLs.");return e})}function dA(e){e._throwIfRoot("deleteObject");t=e.storage,n=dk((r=e._location).fullServerUrl(),t.host,t._protocol),i=t.maxOperationRetryTime,(n=new Uk(n,"DELETE",function(e,t){},i)).successCodes=[200,204],n.errorHandler=Hk(r);var t,r,n,i=n;return e.storage.makeRequestWithTokens(i,sA)}function pA(e,t){r=e._location.path,n=t.split("/").filter(e=>0<e.length).join("/");var r,n=0===r.length?n:r+"/"+n,n=new ak(e._location.bucket,n);return new oA(e.storage,n)}function fA(e,t){if(e instanceof vA){var r=e;if(null==r._bucket)throw new YS(qS.NO_DEFAULT_BUCKET,"No default bucket found. Did you set the '"+$S+"' property when initializing the app?");r=new oA(r,r._bucket);return null!=t?fA(r,t):r}return void 0!==t?pA(e,t):e}function gA(e,t){if(t&&/^[A-Za-z]+:\/\//.test(t)){if(e instanceof vA)return r=e,n=t,new oA(r,n);throw tk("To use ref(service, url), the first argument must be a Storage instance.")}return fA(e,t);var r,n}function mA(e,t){var r=t?.[$S];return null==r?null:ak.makeFromBucketSpec(r,e)}class vA{constructor(e,t,r,n,i,s=!1){this.app=e,this._authProvider=t,this._appCheckProvider=r,this._url=n,this._firebaseVersion=i,this._isUsingEmulator=s,this._bucket=null,this._host=WS,this._protocol="https",this._appId=null,this._deleted=!1,this._maxOperationRetryTime=12e4,this._maxUploadRetryTime=6e5,this._requests=new Set,this._bucket=null!=n?ak.makeFromBucketSpec(n,this._host):mA(this._host,this.app.options)}get host(){return this._host}set host(e){this._host=e,null!=this._url?this._bucket=ak.makeFromBucketSpec(this._url,e):this._bucket=mA(e,this.app.options)}get maxUploadRetryTime(){return this._maxUploadRetryTime}set maxUploadRetryTime(e){ck("time",0,Number.POSITIVE_INFINITY,e),this._maxUploadRetryTime=e}get maxOperationRetryTime(){return this._maxOperationRetryTime}set maxOperationRetryTime(e){ck("time",0,Number.POSITIVE_INFINITY,e),this._maxOperationRetryTime=e}async _getAuthToken(){if(this._overrideAuthToken)return this._overrideAuthToken;var e=this._authProvider.getImmediate({optional:!0});if(e){e=await e.getToken();if(null!==e)return e.accessToken}return null}async _getAppCheckToken(){var e;return Ot(this.app)&&this.app.settings.appCheckToken?this.app.settings.appCheckToken:(e=this._appCheckProvider.getImmediate({optional:!0}))?(await e.getToken()).token:null}_delete(){return this._deleted||(this._deleted=!0,this._requests.forEach(e=>e.cancel()),this._requests.clear()),Promise.resolve()}_makeStorageReference(e){return new oA(this,e)}_makeRequest(t,r,n,i,s=!0){if(this._deleted)return new ok(rk());{[t,n,i,r,s,a,o=!0,l=!1]=[t,this._appId,n,i,r,this._firebaseVersion,s,this._isUsingEmulator],h=pk(t.urlParams),h=t.url+h,c=Object.assign({},t.headers),u=c,(n=n)&&(u["X-Firebase-GMPID"]=n),u=c,null!==(n=i)&&0<n.length&&(u.Authorization="Firebase "+n),c["X-Firebase-Storage-Version"]="webjs/"+(a??"AppManager"),i=c,null!==(u=r)&&(i["X-Firebase-AppCheck"]=u);let e=new gk(h,t.method,c,t.body,t.successCodes,t.additionalRetryCodes,t.handler,t.errorHandler,t.timeout,t.progressCallback,s,o,l);return this._requests.add(e),e.getPromise().then(()=>this._requests.delete(e),()=>this._requests.delete(e)),e}var a,o,l,u,h,c}async makeRequestWithTokens(e,t){var[r,n]=await Promise.all([this._getAuthToken(),this._getAppCheckToken()]);return this._makeRequest(e,t,r,n).getPromise()}}let _A="@firebase/storage",yA="0.14.3",wA="storage";function bA(e,t,r){return e=w(e),t=t,r=r,(e=e)._throwIfRoot("uploadBytesResumable"),new aA(e,new Ck(t),r)}function TA(e){return e=w(e),(e=e)._throwIfRoot("getMetadata"),t=Kk(e.storage,e._location,Pk()),e.storage.makeRequestWithTokens(t,sA);var t}function EA(e,t){return gA(e=w(e),t)}function IA(e,t,r,n={}){var i;[e,t,r,n={}]=[e,t,r,n],e.host=t+":"+r,(i=((i=ze(t))&&He(`https://${e.host}/b`),e._isUsingEmulator=!0,e._protocol=i?"https":"http",n).mockUserToken)&&(e._overrideAuthToken="string"==typeof i?i:ee(i,e.app.options.projectId))}function CA(e,{instanceIdentifier:t}){var r=e.getProvider("app").getImmediate(),n=e.getProvider("auth-internal"),i=e.getProvider("app-check-internal");return new vA(r,n,i,t,Vt)}Rt(new h(wA,CA,"PUBLIC").setMultipleInstances(!0)),zt(_A,yA,""),zt(_A,yA,"esm2020");class SA{constructor(e,t,r){this._delegate=e,this.task=t,this.ref=r}get bytesTransferred(){return this._delegate.bytesTransferred}get metadata(){return this._delegate.metadata}get state(){return this._delegate.state}get totalBytes(){return this._delegate.totalBytes}}class kA{constructor(e,t){this._delegate=e,this._ref=t,this.cancel=this._delegate.cancel.bind(this._delegate),this.catch=this._delegate.catch.bind(this._delegate),this.pause=this._delegate.pause.bind(this._delegate),this.resume=this._delegate.resume.bind(this._delegate)}get snapshot(){return new SA(this._delegate.snapshot,this,this._ref)}then(t,e){return this._delegate.then(e=>{if(t)return t(new SA(e,this,this._ref))},e)}on(e,t,r,n){let i=void 0;return t&&(i="function"==typeof t?e=>t(new SA(e,this,this._ref)):{next:t.next?e=>t.next(new SA(e,this,this._ref)):void 0,complete:t.complete||void 0,error:t.error||void 0}),this._delegate.on(e,i,r||void 0,n||void 0)}}class AA{constructor(e,t){this._delegate=e,this._service=t}get prefixes(){return this._delegate.prefixes.map(e=>new NA(e,this._service))}get items(){return this._delegate.items.map(e=>new NA(e,this._service))}get nextPageToken(){return this._delegate.nextPageToken||null}}class NA{constructor(e,t){this._delegate=e,this.storage=t}get name(){return this._delegate.name}get bucket(){return this._delegate.bucket}get fullPath(){return this._delegate.fullPath}toString(){return this._delegate.toString()}child(e){var t=pA(this._delegate,e);return new NA(t,this.storage)}get root(){return new NA(this._delegate.root,this.storage)}get parent(){var e=this._delegate.parent;return null==e?null:new NA(e,this.storage)}put(e,t){return this._throwIfRoot("put"),new kA(bA(this._delegate,e,t),this)}putString(e,t=yk.RAW,r){this._throwIfRoot("putString");var n=bk(t,e),i={...r};return null==i.contentType&&null!=n.contentType&&(i.contentType=n.contentType),new kA(new aA(this._delegate,new Ck(n.data,!0),i),this)}listAll(){return lA(w(this._delegate)).then(e=>new AA(e,this.storage))}list(e){return t=this._delegate,e=e||void 0,uA(t=w(t),e).then(e=>new AA(e,this.storage));var t}getMetadata(){return TA(this._delegate)}updateMetadata(e){return hA(w(this._delegate),e)}getDownloadURL(){return cA(w(this._delegate))}delete(){return this._throwIfRoot("delete"),dA(w(this._delegate))}_throwIfRoot(e){if(""===this._delegate._location.path)throw nk(e)}}class RA{constructor(e,t){this.app=e,this._delegate=t}get maxOperationRetryTime(){return this._delegate.maxOperationRetryTime}get maxUploadRetryTime(){return this._delegate.maxUploadRetryTime}ref(e){if(PA(e))throw tk("ref() expected a child path but got a URL, use refFromURL instead.");return new NA(EA(this._delegate,e),this)}refFromURL(e){if(!PA(e))throw tk("refFromURL() expected a full URL but got a child path, use ref() instead.");try{ak.makeFromUrl(e,this._delegate.host)}catch(e){throw tk("refFromUrl() expected a valid full URL but got an invalid one.")}return new NA(EA(this._delegate,e),this)}setMaxUploadRetryTime(e){this._delegate.maxUploadRetryTime=e}setMaxOperationRetryTime(e){this._delegate.maxOperationRetryTime=e}useEmulator(e,t,r={}){IA(this._delegate,e,t,r)}}function PA(e){return/^[A-Za-z]+:\/\//.test(e)}let xA="@firebase/storage-compat",DA="0.4.3",OA="storage-compat";function LA(e,{instanceIdentifier:t}){var r=e.getProvider("app-compat").getImmediate(),n=e.getProvider("storage").getImmediate({identifier:t});return new RA(r,n)}zS=pr,lr={TaskState:eA,TaskEvent:Zk,StringFormat:yk,Storage:RA,Reference:NA},zS.INTERNAL.registerComponent(new h(OA,LA,"PUBLIC").setServiceProps(lr).setMultipleInstances(!0)),zS.registerVersion(xA,DA);function MA(i,e){var a,o;a=function(e){r={},(e=e).entries.length&&(t=e.entries.reduce(function(e,t){return e&&e.value>t.value?e:t}))&&t.sources&&t.sources.length&&(n=(n=t.sources).find(function(e){return e.node&&1===e.node.nodeType})||n[0])&&(r={largestShiftTarget:HA(n.node),largestShiftTime:t.startTime,largestShiftValue:t.value,largestShiftSource:n,largestShiftEntry:t,loadState:jA(t.startTime)});var t,r,n=Object.assign(e,{attribution:r});i(n)},o=e||{},uN(eN(function(){function e(e){e.forEach(function(e){var t,r;e.hadRecentInput||(t=i[0],r=i[i.length-1],n&&e.startTime-r.startTime<1e3&&e.startTime-t.startTime<5e3?(n+=e.value,i.push(e)):(n=e.value,i=[e]))}),n>r.value&&(r.value=n,r.entries=i,t())}var t,r=YA("CLS",0),n=0,i=[],s=QA("layout-shift",e);s&&(t=JA(a,r,hN,o.reportAllChanges),ZA(function(){e(s.takeRecords()),t(!0)}),WA(function(){r=YA("CLS",n=0),t=JA(a,r,hN,o.reportAllChanges),XA(function(){return t()})}),setTimeout(t,0))}))}function FA(l,e){BA=BA||QA("long-animation-frame",xN),CN(function(e){t=(e=e).entries[0],o=NN.get(t),r=t.processingStart,n=o.processingEnd,o=o.entries.sort(function(e,t){return e.processingStart-t.processingStart}),i=LN(t.startTime,n),s=(s=e.entries.find(function(e){return e.target}))&&s.target||RN.get(t.interactionId),a=[t.startTime+t.duration,n].concat(i.map(function(e){return e.startTime+e.duration})),a=Math.max.apply(Math,a),s={interactionTarget:HA(s),interactionTargetElement:s,interactionType:t.name.startsWith("key")?"keyboard":"pointer",interactionTime:t.startTime,nextPaintTime:a,processedEventEntries:o,longAnimationFrameEntries:i,inputDelay:r-t.startTime,processingDuration:n-r,presentationDelay:Math.max(a-n,0),loadState:jA(t.startTime)};var t,r,n,i,s,a,o=Object.assign(e,{attribution:s});l(o)},e)}function UA(u,e){var a,o;a=function(e){o={timeToFirstByte:0,resourceLoadDelay:0,resourceLoadDuration:0,elementRenderDelay:(e=e).value},e.entries.length&&(t=qA())&&(a=t.activationStart||0,n=(r=e.entries[e.entries.length-1]).url&&performance.getEntriesByType("resource").filter(function(e){return e.name===r.url})[0],l=Math.max(0,t.responseStart-a),i=Math.max(l,n?(n.requestStart||n.startTime)-a:0),s=Math.max(i,n?n.responseEnd-a:0),a=Math.max(s,r.startTime-a),o={element:HA(r.element),timeToFirstByte:l,resourceLoadDelay:i-l,resourceLoadDuration:s-i,elementRenderDelay:a-s,navigationEntry:t,lcpEntry:r},r.url&&(o.url=r.url),n)&&(o.lcpResourceEntry=n);var t,r,n,i,s,a,o,l=Object.assign(e,{attribution:o});u(l)},o=e||{},oN(function(){function e(e){(e=o.reportAllChanges?e:e.slice(-1)).forEach(function(e){e.startTime<n.firstHiddenTime&&(i.value=Math.max(e.startTime-$A(),0),i.entries=[e],t())})}var t,r,n=aN(),i=YA("LCP"),s=QA("largest-contentful-paint",e);s&&(t=JA(a,i,MN,o.reportAllChanges),r=eN(function(){FN[i.id]||(e(s.takeRecords()),s.disconnect(),FN[i.id]=!0,t(!0))}),["keydown","click"].forEach(function(e){addEventListener(e,function(){return EN(r)},{once:!0,capture:!0})}),ZA(r),WA(function(e){i=YA("LCP"),t=JA(a,i,MN,o.reportAllChanges),XA(function(){i.value=performance.now()-e.timeStamp,FN[i.id]=!0,t(!0)})}))})}var VA,BA,qA=function(){var e=self.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0];if(e&&0<e.responseStart&&e.responseStart<performance.now())return e},jA=function(e){if("loading"===document.readyState)return"loading";var t=qA();if(t){if(e<t.domInteractive)return"loading";if(0===t.domContentLoadedEventStart||e<t.domContentLoadedEventStart)return"dom-interactive";if(0===t.domComplete||e<t.domComplete)return"dom-content-loaded"}return"complete"},zA=function(e){var t=e.nodeName;return 1===e.nodeType?t.toLowerCase():t.toUpperCase().replace(/^#/,"")},HA=function(e,t){var r="";try{for(;e&&9!==e.nodeType;){var n=e,i=n.id?"#"+n.id:zA(n)+(n.classList&&n.classList.value&&n.classList.value.trim()&&n.classList.value.trim().length?"."+n.classList.value.trim().replace(/\s+/g,"."):"");if(r.length+i.length>(t||100)-1)return r||i;if(r=r?i+">"+r:i,n.id)break;e=n.parentNode}}catch(e){}return r},KA=-1,GA=function(){return KA},WA=function(t){addEventListener("pageshow",function(e){e.persisted&&(KA=e.timeStamp,t(e))},!0)},$A=function(){var e=qA();return e&&e.activationStart||0},YA=function(e,t){var r=qA(),n="navigate";return 0<=GA()?n="back-forward-cache":r&&(document.prerendering||0<$A()?n="prerender":document.wasDiscarded?n="restore":r.type&&(n=r.type.replace(/_/g,"-"))),{name:e,value:void 0===t?-1:t,rating:"good",delta:0,entries:[],id:"v4-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:n}},QA=function(e,t,r){try{var n;if(PerformanceObserver.supportedEntryTypes.includes(e))return(n=new PerformanceObserver(function(e){Promise.resolve().then(function(){t(e.getEntries())})})).observe(Object.assign({type:e,buffered:!0},r||{})),n}catch(e){}},JA=function(t,r,n,i){var s,a;return function(e){0<=r.value&&(e||i)&&((a=r.value-(s||0))||void 0===s)&&(s=r.value,r.delta=a,r.rating=(e=r.value)>n[1]?"poor":e>n[0]?"needs-improvement":"good",t(r))}},XA=function(e){requestAnimationFrame(function(){return requestAnimationFrame(function(){return e()})})},ZA=function(e){document.addEventListener("visibilitychange",function(){"hidden"===document.visibilityState&&e()})},eN=function(e){var t=!1;return function(){t||(e(),t=!0)}},tN=-1,rN=function(){return"hidden"!==document.visibilityState||document.prerendering?1/0:0},nN=function(e){"hidden"===document.visibilityState&&-1<tN&&(tN="visibilitychange"===e.type?e.timeStamp:0,sN())},iN=function(){addEventListener("visibilitychange",nN,!0),addEventListener("prerenderingchange",nN,!0)},sN=function(){removeEventListener("visibilitychange",nN,!0),removeEventListener("prerenderingchange",nN,!0)},aN=function(){return tN<0&&(tN=rN(),iN(),WA(function(){setTimeout(function(){tN=rN(),iN()},0)})),{get firstHiddenTime(){return tN}}},oN=function(e){document.prerendering?addEventListener("prerenderingchange",function(){return e()},!0):e()},lN=[1800,3e3],uN=function(s,a){a=a||{},oN(function(){var t,r=aN(),n=YA("FCP"),i=QA("paint",function(e){e.forEach(function(e){"first-contentful-paint"===e.name&&(i.disconnect(),e.startTime<r.firstHiddenTime)&&(n.value=Math.max(e.startTime-$A(),0),n.entries.push(e),t(!0))})});i&&(t=JA(s,n,lN,a.reportAllChanges),WA(function(e){n=YA("FCP"),t=JA(s,n,lN,a.reportAllChanges),XA(function(){n.value=performance.now()-e.timeStamp,t(!0)})}))})},hN=[.1,.25],cN=0,dN=1/0,pN=0,fN=function(e){e.forEach(function(e){e.interactionId&&(dN=Math.min(dN,e.interactionId),pN=Math.max(pN,e.interactionId),cN=pN?(pN-dN)/7+1:0)})},gN=function(){return VA?cN:performance.interactionCount||0},mN=function(){"interactionCount"in performance||(VA=VA||QA("event",fN,{type:"event",buffered:!0,durationThreshold:0}))},vN=[],_N=new Map,yN=0,wN=function(){var e=Math.min(vN.length-1,Math.floor((gN()-yN)/50));return vN[e]},bN=[],TN=function(t){var e,r;bN.forEach(function(e){return e(t)}),!t.interactionId&&"first-input"!==t.entryType||(r=vN[vN.length-1],((e=_N.get(t.interactionId))||vN.length<10||t.duration>r.latency)&&(e?t.duration>e.latency?(e.entries=[t],e.latency=t.duration):t.duration===e.latency&&t.startTime===e.entries[0].startTime&&e.entries.push(t):(r={id:t.interactionId,latency:t.duration,entries:[t]},_N.set(r.id,r),vN.push(r)),vN.sort(function(e,t){return t.latency-e.latency}),10<vN.length)&&vN.splice(10).forEach(function(e){return _N.delete(e.id)}))},EN=function(e){var t=self.requestIdleCallback||self.setTimeout,r=-1;return e=eN(e),"hidden"===document.visibilityState?e():(r=t(e),ZA(e)),r},IN=[200,500],CN=function(s,a){"PerformanceEventTiming"in self&&"interactionId"in PerformanceEventTiming.prototype&&(a=a||{},oN(function(){var e;mN();function t(t){EN(function(){t.forEach(TN);var e=wN();e&&e.latency!==r.value&&(r.value=e.latency,r.entries=e.entries,i())})}var r=YA("INP"),n=QA("event",t,{durationThreshold:null!=(e=a.durationThreshold)?e:40}),i=JA(s,r,IN,a.reportAllChanges);n&&(n.observe({type:"first-input",buffered:!0}),ZA(function(){t(n.takeRecords()),i(!0)}),WA(function(){yN=gN(),vN.length=0,_N.clear(),r=YA("INP"),i=JA(s,r,IN,a.reportAllChanges)}))}))},SN=[],kN=[],AN=0,NN=new WeakMap,RN=new Map,PN=-1,xN=function(e){SN=SN.concat(e),DN()},DN=function(){PN<0&&(PN=EN(ON))},ON=function(){10<RN.size&&RN.forEach(function(e,t){_N.has(t)||RN.delete(t)});var r=vN.map(function(e){return NN.get(e.entries[0])}),n=kN.length-50;kN=kN.filter(function(e,t){return n<=t||r.includes(e)});for(var i=new Set,e=0;e<kN.length;e++){var t=kN[e];LN(t.startTime,t.processingEnd).forEach(function(e){i.add(e)})}var s=SN.length-1-50;SN=SN.filter(function(e,t){return e.startTime>AN&&s<t||i.has(e)}),PN=-1},LN=(bN.push(function(e){e.interactionId&&e.target&&!RN.has(e.interactionId)&&RN.set(e.interactionId,e.target)},function(e){var t,r=e.startTime+e.duration;AN=Math.max(AN,e.processingEnd);for(var n=kN.length-1;0<=n;n--){var i=kN[n];if(Math.abs(r-i.renderTime)<=8){(t=i).startTime=Math.min(e.startTime,t.startTime),t.processingStart=Math.min(e.processingStart,t.processingStart),t.processingEnd=Math.max(e.processingEnd,t.processingEnd),t.entries.push(e);break}}t||(t={startTime:e.startTime,processingStart:e.processingStart,processingEnd:e.processingEnd,renderTime:r,entries:[e]},kN.push(t)),!e.interactionId&&"first-input"!==e.entryType||NN.set(e,t),DN()}),function(e,t){for(var r,n=[],i=0;r=SN[i];i++)if(!(r.startTime+r.duration<e)){if(r.startTime>t)break;n.push(r)}return n}),MN=[2500,4e3],FN={};let UN="@firebase/performance",VN="0.7.12",BN=VN,qN="FB-PERF-TRACE-MEASURE",jN="_wt_",zN="@firebase/performance/config",HN="@firebase/performance/configexpire";var KN,GN,WN,t,Am="Performance";let $N=new ge("performance",Am,{"trace started":"Trace {$traceName} was started before.","trace stopped":"Trace {$traceName} is not running.","nonpositive trace startTime":"Trace {$traceName} startTime should be positive.","nonpositive trace duration":"Trace {$traceName} duration should be positive.","no window":"Window is not available.","no app id":"App id is not available.","no project id":"Project id is not available.","no api key":"Api key is not available.","invalid cc log":"Attempted to queue invalid cc event","FB not default":"Performance can only start when Firebase app instance is the default one.","RC response not ok":"RC response is not ok","invalid attribute name":"Attribute name {$attributeName} is invalid.","invalid attribute value":"Attribute value {$attributeValue} is invalid.","invalid custom metric name":"Custom metric name {$customMetricName} is invalid","invalid String merger input":"Input for String merger is invalid, contact support team to resolve.","already initialized":"initializePerformance() has already been called with different options. To avoid this error, call initializePerformance() with the same options as when it was originally called, or call getPerformance() to return the already initialized instance."}),YN=new Ze(Am);YN.logLevel=p.INFO;let QN,JN;class XN{constructor(e){if(!(this.window=e))throw $N.create("no window");this.performance=e.performance,this.PerformanceObserver=e.PerformanceObserver,this.windowLocation=e.location,this.navigator=e.navigator,this.document=e.document,this.navigator&&this.navigator.cookieEnabled&&(this.localStorage=e.localStorage),e.perfMetrics&&e.perfMetrics.onFirstInputDelay&&(this.onFirstInputDelay=e.perfMetrics.onFirstInputDelay),this.onLCP=UA,this.onINP=FA,this.onCLS=MA}getUrl(){return this.windowLocation.href.split("?")[0]}mark(e){this.performance&&this.performance.mark&&this.performance.mark(e)}measure(e,t,r){this.performance&&this.performance.measure&&this.performance.measure(e,t,r)}getEntriesByType(e){return this.performance&&this.performance.getEntriesByType?this.performance.getEntriesByType(e):[]}getEntriesByName(e){return this.performance&&this.performance.getEntriesByName?this.performance.getEntriesByName(e):[]}getTimeOrigin(){return this.performance&&(this.performance.timeOrigin||this.performance.timing.navigationStart)}requiredApisAvailable(){return fetch&&Promise&&pe()?!!ce()||(YN.info("IndexedDB is not supported by current browser"),!1):(YN.info("Firebase Performance cannot start if browser does not support fetch and Promise or cookie is disabled."),!1)}setupObserver(e,r){this.PerformanceObserver&&new this.PerformanceObserver(e=>{for(var t of e.getEntries())r(t)}).observe({entryTypes:[e]})}static getInstance(){return QN=void 0===QN?new XN(JN):QN}}let ZN;function eR(e,t){var r=e.length-t.length;if(r<0||1<r)throw $N.create("invalid String merger input");var n=[];for(let i=0;i<e.length;i++)n.push(e.charAt(i)),t.length>i&&n.push(t.charAt(i));return n.join("")}let tR;class rR{constructor(){this.instrumentationEnabled=!0,this.dataCollectionEnabled=!0,this.loggingEnabled=!1,this.tracesSamplingRate=1,this.networkRequestsSamplingRate=1,this.logEndPointUrl="https://firebaselogging.googleapis.com/v0cc/log?format=json_proto",this.flTransportEndpointUrl=eR("hts/frbslgigp.ogepscmv/ieo/eaylg","tp:/ieaeogn-agolai.o/1frlglgc/o"),this.transportKey=eR("AzSC8r6ReiGqFMyfvgow","Iayx0u-XT3vksVM-pIV"),this.logSource=462,this.logTraceAfterSampling=!1,this.logNetworkAfterSampling=!1,this.configTimeToLive=12,this.logMaxFlushSize=40}getFlTransportFullUrl(){return this.flTransportEndpointUrl.concat("?key=",this.transportKey)}static getInstance(){return tR=void 0===tR?new rR:tR}}(GN=KN=KN||{})[GN.UNKNOWN=0]="UNKNOWN",GN[GN.VISIBLE=1]="VISIBLE",GN[GN.HIDDEN=2]="HIDDEN";let nR=["firebase_","google_","ga_"],iR=new RegExp("^[a-zA-Z]\\w*$"),sR=40,aR=100;function oR(e){var t=e.options?.appId;if(t)return t;throw $N.create("no app id")}let lR="0.0.1",uR={loggingEnabled:!0},hR="FIREBASE_INSTALLATIONS_AUTH";function cR(e,t){var n,i,r=(()=>{var e=XN.getInstance().localStorage;if(e){var t=e.getItem(HN);if(t&&(e=>Number(e)>Date.now())(t)){t=e.getItem(zN);if(t)try{return JSON.parse(t)}catch{}}}})();return r?(pR(r),Promise.resolve()):(i=t,(e=>{var t=e.getToken();return t.then(e=>{}),t})((n=e).installations).then(e=>{var t=(e=>{var t=e.options?.projectId;if(t)return t;throw $N.create("no project id")})(n.app),r=(e=>{var t=e.options?.apiKey;if(t)return t;throw $N.create("no api key")})(n.app),t=new Request(`https://firebaseremoteconfig.googleapis.com/v1/projects/${t}/namespaces/fireperf:fetch?key=`+r,{method:"POST",headers:{Authorization:hR+" "+e},body:JSON.stringify({app_instance_id:i,app_instance_id_token:e,app_id:oR(n.app),app_version:BN,sdk_version:lR})});return fetch(t).then(e=>{if(e.ok)return e.json();throw $N.create("RC response not ok")})}).catch(()=>{YN.info(dR)}).then(pR).then(e=>{var t;e=e,t=XN.getInstance().localStorage,e&&t&&(t.setItem(zN,JSON.stringify(e)),t.setItem(HN,String(Date.now()+60*rR.getInstance().configTimeToLive*60*1e3)))},()=>{}))}let dR="Could not fetch config, will use default configs";function pR(e){var t,r;return e&&(t=rR.getInstance(),void 0!==(r=e.entries||{}).fpr_enabled?t.loggingEnabled="true"===String(r.fpr_enabled):t.loggingEnabled=uR.loggingEnabled,r.fpr_log_source?t.logSource=Number(r.fpr_log_source):uR.logSource&&(t.logSource=uR.logSource),r.fpr_log_endpoint_url?t.logEndPointUrl=r.fpr_log_endpoint_url:uR.logEndPointUrl&&(t.logEndPointUrl=uR.logEndPointUrl),r.fpr_log_transport_key?t.transportKey=r.fpr_log_transport_key:uR.transportKey&&(t.transportKey=uR.transportKey),void 0!==r.fpr_vc_network_request_sampling_rate?t.networkRequestsSamplingRate=Number(r.fpr_vc_network_request_sampling_rate):void 0!==uR.networkRequestsSamplingRate&&(t.networkRequestsSamplingRate=uR.networkRequestsSamplingRate),void 0!==r.fpr_vc_trace_sampling_rate?t.tracesSamplingRate=Number(r.fpr_vc_trace_sampling_rate):void 0!==uR.tracesSamplingRate&&(t.tracesSamplingRate=uR.tracesSamplingRate),r.fpr_log_max_flush_size?t.logMaxFlushSize=Number(r.fpr_log_max_flush_size):uR.logMaxFlushSize&&(t.logMaxFlushSize=uR.logMaxFlushSize),t.logTraceAfterSampling=fR(t.tracesSamplingRate),t.logNetworkAfterSampling=fR(t.networkRequestsSamplingRate)),e}function fR(e){return Math.random()<=e}let gR=1,mR;function vR(e){var r;return gR=2,mR=mR||(r=e,(()=>{let r=XN.getInstance().document;return new Promise(t=>{if(r&&"complete"!==r.readyState){let e=()=>{"complete"===r.readyState&&(r.removeEventListener("readystatechange",e),t())};r.addEventListener("readystatechange",e)}else t()})})().then(()=>{return e=r.installations,(t=e.getId()).then(e=>{ZN=e}),t;var e,t}).then(e=>cR(r,e)).then(()=>_R(),()=>_R()))}function _R(){gR=3}let yR=1e4,wR=5500,bR=1e3,TR=3,ER=65536,IR=new TextEncoder,CR=TR,SR=[],kR=!1;function AR(e){setTimeout(()=>{if(!(CR<=0)){if(0<SR.length){let e=SR.splice(0,bR),t=NR(e);(e=>{var t=rR.getInstance().getFlTransportFullUrl();return IR.encode(e).length<=ER&&navigator.sendBeacon&&navigator.sendBeacon(t,e)?Promise.resolve():fetch(t,{method:"POST",body:e})})(t).then(()=>{CR=TR}).catch(()=>{SR=[...e,...SR],CR--,YN.info(`Tries left: ${CR}.`),AR(yR)})}AR(yR)}},e)}function NR(e){var t=e.map(e=>({source_extension_json_proto3:e.message,event_time_ms:String(e.eventTime)})),t={request_time_ms:String(Date.now()),client_info:{client_type:1,js_client_info:{}},log_source:rR.getInstance().logSource,log_event:t};return JSON.stringify(t)}function RR(t){return(...e)=>{e={message:t(...e),eventTime:Date.now()};if(!e.eventTime||!e.message)throw $N.create("invalid cc log");SR=[...SR,e]}}function PR(){for(var e,t=rR.getInstance().getFlTransportFullUrl();0<SR.length;){var r=SR.splice(-rR.getInstance().logMaxFlushSize),n=NR(r);if(!navigator.sendBeacon||!navigator.sendBeacon(t,n)){SR=[...SR,...r];break}}0<SR.length&&(e=NR(SR),fetch(t,{method:"POST",body:e}).catch(()=>{YN.info("Failed flushing queued events.")}))}let xR;function DR(e,t){(xR=xR||{send:RR(MR),flush:PR}).send(e,t)}function OR(e){var t=rR.getInstance();!t.instrumentationEnabled&&e.isAuto||(t.dataCollectionEnabled||e.isAuto)&&XN.getInstance().requiredApisAvailable()&&(3===gR?LR(e):vR(e.performanceController).then(()=>LR(e),()=>LR(e)))}function LR(e){var t;ZN&&(t=rR.getInstance()).loggingEnabled&&t.logTraceAfterSampling&&DR(e,1)}function MR(e,t){var r,n;return 0===t?(r={url:e.url,http_method:e.httpMethod||0,http_response_code:200,response_payload_bytes:e.responsePayloadBytes,client_start_time_us:e.startTimeUs,time_to_response_initiated_us:e.timeToResponseInitiatedUs,time_to_response_completed_us:e.timeToResponseCompletedUs},r={application_info:FR(e.performanceController.app),network_request_metric:r},JSON.stringify(r)):(r={name:(t=e).name,is_auto:t.isAuto,client_start_time_us:t.startTimeUs,duration_us:t.durationUs},0!==Object.keys(t.counters).length&&(r.counters=t.counters),n=t.getAttributes(),0!==Object.keys(n).length&&(r.custom_attributes=n),n={application_info:FR(t.performanceController.app),trace_metric:r},JSON.stringify(n))}function FR(e){return{google_app_id:oR(e),app_instance_id:ZN,web_app_info:{sdk_version:BN,page_url:XN.getInstance().getUrl(),service_worker_status:(t=XN.getInstance().navigator)?.serviceWorker?t.serviceWorker.controller?2:3:1,visibility_state:(()=>{switch(XN.getInstance().document.visibilityState){case"visible":return KN.VISIBLE;case"hidden":return KN.HIDDEN;default:return KN.UNKNOWN}})(),effective_connection_type:(()=>{var e=XN.getInstance().navigator.connection;switch(e&&e.effectiveType){case"slow-2g":return 1;case"2g":return 2;case"3g":return 3;case"4g":return 4;default:return 0}})()},application_process_state:0};var t}function UR(e,t){var r,n,i,s=t;s&&void 0!==s.responseStart&&(i=XN.getInstance().getTimeOrigin(),i=Math.floor(1e3*(s.startTime+i)),r=s.responseStart?Math.floor(1e3*(s.responseStart-s.startTime)):void 0,n=Math.floor(1e3*(s.responseEnd-s.startTime)),s={performanceController:e,url:s.name&&s.name.split("?")[0],responsePayloadBytes:s.transferSize,startTimeUs:i,timeToResponseInitiatedUs:r,timeToResponseCompletedUs:n},t=s,(i=rR.getInstance()).instrumentationEnabled)&&(r=t.url,n=i.logEndPointUrl.split("?")[0],s=i.flTransportEndpointUrl.split("?")[0],r!==n)&&r!==s&&i.loggingEnabled&&i.logNetworkAfterSampling&&DR(t,0)}let VR=100,BR="_",qR=["_fp","_fcp","_fid","_lcp","_cls","_inp"];class jR{constructor(e,t,r=!1,n){this.performanceController=e,this.name=t,this.isAuto=r,this.state=1,this.customAttributes={},this.counters={},this.api=XN.getInstance(),this.randomId=Math.floor(1e6*Math.random()),this.isAuto||(this.traceStartMark=`FB-PERF-TRACE-START-${this.randomId}-`+this.name,this.traceStopMark=`FB-PERF-TRACE-STOP-${this.randomId}-`+this.name,this.traceMeasure=n||`${qN}-${this.randomId}-`+this.name,n&&this.calculateTraceMetrics())}start(){if(1!==this.state)throw $N.create("trace started",{traceName:this.name});this.api.mark(this.traceStartMark),this.state=2}stop(){if(2!==this.state)throw $N.create("trace stopped",{traceName:this.name});this.state=3,this.api.mark(this.traceStopMark),this.api.measure(this.traceMeasure,this.traceStartMark,this.traceStopMark),this.calculateTraceMetrics(),OR(this)}record(e,t,r){if(e<=0)throw $N.create("nonpositive trace startTime",{traceName:this.name});if(t<=0)throw $N.create("nonpositive trace duration",{traceName:this.name});if(this.durationUs=Math.floor(1e3*t),this.startTimeUs=Math.floor(1e3*e),r&&r.attributes&&(this.customAttributes={...r.attributes}),r&&r.metrics)for(var n of Object.keys(r.metrics))isNaN(Number(r.metrics[n]))||(this.counters[n]=Math.floor(Number(r.metrics[n])));OR(this)}incrementMetric(e,t=1){void 0===this.counters[e]?this.putMetric(e,t):this.putMetric(e,this.counters[e]+t)}putMetric(e,t){if(n=e,i=this.name,0===n.length||n.length>VR||!(i&&i.startsWith(jN)&&-1<qR.indexOf(n))&&n.startsWith(BR))throw $N.create("invalid custom metric name",{customMetricName:e});var r,n,i;this.counters[e]=(i=t??0,(r=Math.floor(i))<i&&YN.info(`Metric value should be an Integer, setting the value as : ${r}.`),r)}getMetric(e){return this.counters[e]||0}putAttribute(e,t){var r,n,i=!(0===(r=e).length||r.length>sR||nR.some(e=>r.startsWith(e))||!r.match(iR)),s=0!==(n=t).length&&n.length<=aR;if(i&&s)this.customAttributes[e]=t;else{if(!i)throw $N.create("invalid attribute name",{attributeName:e});if(!s)throw $N.create("invalid attribute value",{attributeValue:t})}}getAttribute(e){return this.customAttributes[e]}removeAttribute(e){void 0!==this.customAttributes[e]&&delete this.customAttributes[e]}getAttributes(){return{...this.customAttributes}}setStartTime(e){this.startTimeUs=e}setDuration(e){this.durationUs=e}calculateTraceMetrics(){var e=this.api.getEntriesByName(this.traceMeasure),e=e&&e[0];e&&(this.durationUs=Math.floor(1e3*e.duration),this.startTimeUs=Math.floor(1e3*(e.startTime+this.api.getTimeOrigin())))}static createOobTrace(e,t,r,n,i){var s=XN.getInstance().getUrl();if(s){var s=new jR(e,jN+s,!0),a=Math.floor(1e3*XN.getInstance().getTimeOrigin());s.setStartTime(a),t&&t[0]&&(s.setDuration(Math.floor(1e3*t[0].duration)),s.putMetric("domInteractive",Math.floor(1e3*t[0].domInteractive)),s.putMetric("domContentLoadedEventEnd",Math.floor(1e3*t[0].domContentLoadedEventEnd)),s.putMetric("loadEventEnd",Math.floor(1e3*t[0].loadEventEnd)));r&&((a=r.find(e=>"first-paint"===e.name))&&a.startTime&&s.putMetric("_fp",Math.floor(1e3*a.startTime)),(a=r.find(e=>"first-contentful-paint"===e.name))&&a.startTime&&s.putMetric("_fcp",Math.floor(1e3*a.startTime)),i)&&s.putMetric("_fid",Math.floor(1e3*i)),this.addWebVitalMetric(s,"_lcp","lcp_element",n.lcp),this.addWebVitalMetric(s,"_cls","cls_largestShiftTarget",n.cls),this.addWebVitalMetric(s,"_inp","inp_interactionTarget",n.inp),OR(s),xR&&xR.flush()}}static addWebVitalMetric(e,t,r,n){n&&(e.putMetric(t,Math.floor(1e3*n.value)),n.elementAttribution)&&(n.elementAttribution.length>aR?e.putAttribute(r,n.elementAttribution.substring(0,aR)):e.putAttribute(r,n.elementAttribution))}static createUserTimingTrace(e,t){OR(new jR(e,t,!1,t))}}let zR={},HR=!1,KR;function GR(n){ZN&&(setTimeout(()=>{{var t=n;let e=XN.getInstance();"onpagehide"in window?e.document.addEventListener("pagehide",()=>$R(t)):e.document.addEventListener("unload",()=>$R(t)),e.document.addEventListener("visibilitychange",()=>{"hidden"===e.document.visibilityState&&$R(t)}),e.onFirstInputDelay&&e.onFirstInputDelay(e=>{KR=e}),e.onLCP(e=>{zR.lcp={value:e.value,elementAttribution:e.attribution?.element}}),e.onCLS(e=>{zR.cls={value:e.value,elementAttribution:e.attribution?.largestShiftTarget}}),e.onINP(e=>{zR.inp={value:e.value,elementAttribution:e.attribution?.interactionTarget}})}},0),setTimeout(()=>{var e,t=n,r=XN.getInstance();for(e of r.getEntriesByType("resource"))UR(t,e);r.setupObserver("resource",e=>UR(t,e))},0),setTimeout(()=>{var e,t=n,r=XN.getInstance();for(e of r.getEntriesByType("measure"))WR(t,e);r.setupObserver("measure",e=>WR(t,e))},0))}function WR(e,t){var r=t.name;r.substring(0,qN.length)!==qN&&jR.createUserTimingTrace(e,r)}function $R(r){if(!HR){HR=!0;var n=XN.getInstance();let e=n.getEntriesByType("navigation"),t=n.getEntriesByType("paint");setTimeout(()=>{jR.createOobTrace(r,e,t,zR,KR)},0)}}class YR{constructor(e,t){this.app=e,this.installations=t,this.initialized=!1}_init(e){this.initialized||(void 0!==e?.dataCollectionEnabled&&(this.dataCollectionEnabled=e.dataCollectionEnabled),void 0!==e?.instrumentationEnabled&&(this.instrumentationEnabled=e.instrumentationEnabled),XN.getInstance().requiredApisAvailable()?de().then(e=>{e&&(kR||(AR(wR),kR=!0),vR(this).then(()=>GR(this),()=>GR(this)),this.initialized=!0)}).catch(e=>{YN.info("Environment doesn't support IndexedDB: "+e)}):YN.info('Firebase Performance cannot start if the browser does not support "Fetch" and "Promise", or cookies are disabled.'))}set instrumentationEnabled(e){rR.getInstance().instrumentationEnabled=e}get instrumentationEnabled(){return rR.getInstance().instrumentationEnabled}set dataCollectionEnabled(e){rR.getInstance().dataCollectionEnabled=e}get dataCollectionEnabled(){return rR.getInstance().dataCollectionEnabled}}let QR="[DEFAULT]";let JR=(e,{options:t})=>{var r=e.getProvider("app").getImmediate(),n=e.getProvider("installations-internal").getImmediate();if(r.name!==QR)throw $N.create("FB not default");if("undefined"==typeof window)throw $N.create("no window");e=window,JN=e;r=new YR(r,n);return r._init(t),r};Rt(new h("performance",JR,"PUBLIC")),zt(UN,VN),zt(UN,VN,"esm2020");class XR{constructor(e,t){this.app=e,this._delegate=t}get instrumentationEnabled(){return this._delegate.instrumentationEnabled}set instrumentationEnabled(e){this._delegate.instrumentationEnabled=e}get dataCollectionEnabled(){return this._delegate.dataCollectionEnabled}set dataCollectionEnabled(e){this._delegate.dataCollectionEnabled=e}trace(e){return t=this._delegate,e=e,t=w(t),new jR(t,e);var t}}let ZR="@firebase/performance-compat",eP="0.2.25";function tP(e){var t=e.getProvider("app-compat").getImmediate(),r=e.getProvider("performance").getImmediate();return new XR(t,r)}(WN=pr).INTERNAL.registerComponent(new h("performance-compat",tP,"PUBLIC")),WN.registerVersion(ZR,eP);let rP="@firebase/remote-config",nP="0.8.5";class iP{constructor(){this.listeners=[]}addEventListener(e){this.listeners.push(e)}abort(){this.listeners.forEach(e=>e())}}let sP="remote-config",aP=100,oP=new ge("remoteconfig","Remote Config",{"already-initialized":"Remote Config already initialized","registration-window":"Undefined window object. This SDK only supports usage in a browser environment.","registration-project-id":"Undefined project identifier. Check Firebase app initialization.","registration-api-key":"Undefined API key. Check Firebase app initialization.","registration-app-id":"Undefined app identifier. Check Firebase app initialization.","storage-open":"Error thrown when opening storage. Original error: {$originalErrorMessage}.","storage-get":"Error thrown when reading from storage. Original error: {$originalErrorMessage}.","storage-set":"Error thrown when writing to storage. Original error: {$originalErrorMessage}.","storage-delete":"Error thrown when deleting from storage. Original error: {$originalErrorMessage}.","fetch-client-network":"Fetch client failed to connect to a network. Check Internet connection. Original error: {$originalErrorMessage}.","fetch-timeout":'The config fetch request timed out.  Configure timeout using "fetchTimeoutMillis" SDK setting.',"fetch-throttle":'The config fetch request timed out while in an exponential backoff state. Configure timeout using "fetchTimeoutMillis" SDK setting. Unix timestamp in milliseconds when fetch request throttling ends: {$throttleEndTimeMillis}.',"fetch-client-parse":"Fetch client could not parse response. Original error: {$originalErrorMessage}.","fetch-status":"Fetch server returned an HTTP error status. HTTP status: {$httpStatus}.","indexed-db-unavailable":"Indexed DB is not supported by current browser","custom-signal-max-allowed-signals":"Setting more than {$maxSignals} custom signals is not supported.","stream-error":"The stream was not able to connect to the backend: {$originalErrorMessage}.","realtime-unavailable":"The Realtime service is unavailable: {$originalErrorMessage}","update-message-invalid":"The stream invalidation message was unparsable: {$originalErrorMessage}","update-not-fetched":"Unable to fetch the latest config: {$originalErrorMessage}","analytics-unavailable":"Connection to Firebase Analytics failed: {$originalErrorMessage}"});let lP=["1","true","t","yes","y","on"];class uP{constructor(e,t=""){this._source=e,this._value=t}asString(){return this._value}asBoolean(){return"static"!==this._source&&0<=lP.indexOf(this._value.toLowerCase())}asNumber(){if("static"===this._source)return 0;let e=Number(this._value);return e=isNaN(e)?0:e}getSource(){return this._source}}class hP{constructor(e){this.storage=e._storage,this.logger=e._logger,this.analyticsProvider=e._analyticsProvider}async updateActiveExperiments(e){var t=await this.storage.getActiveExperiments()||new Set,r=this.createExperimentInfoMap(e);return this.addActiveExperiments(r),this.removeInactiveExperiments(t,r),this.storage.setActiveExperiments(new Set(r.keys()))}createExperimentInfoMap(e){var t,r=new Map;for(t of e)r.set(t.experimentId,t);return r}addActiveExperiments(e){var t,r,n={};for([t,r]of e.entries())n["firebase"+t]=r.variantId;this.addExperimentToAnalytics(n)}removeInactiveExperiments(e,t){var r,n={};for(r of e)t.has(r)||(n["firebase"+r]=null);this.addExperimentToAnalytics(n)}addExperimentToAnalytics(e){if(0!==Object.keys(e).length)try{var t=this.analyticsProvider.getImmediate({optional:!0});t?(t.setUserProperties(e),t.logEvent("set_firebase_experiment_state")):this.logger.warn("Analytics import failed. Verify if you have imported Firebase Analytics in your app code.")}catch(e){throw oP.create("analytics-unavailable",{originalErrorMessage:e?.message})}}}async function cP(e){var t=w(e),[r,n]=await Promise.all([t._storage.getLastSuccessfulFetchResponse(),t._storage.getActiveConfigEtag()]);return!!(r&&r.config&&r.eTag&&r.templateVersion&&r.eTag!==n)&&(n=new hP(t).updateActiveExperiments(r.experiments||[]),await Promise.all([t._storageCache.setActiveConfig(r.config),t._storage.setActiveConfigEtag(r.eTag),t._storage.setActiveConfigTemplateVersion(r.templateVersion),n]),!0)}function dP(e){let t=w(e);return t._initializePromise||(t._initializePromise=t._storageCache.loadFromStorage().then(()=>{t._isInitializationComplete=!0})),t._initializePromise}async function pP(t){var r=w(t);let e=new iP;setTimeout(async()=>{e.abort()},r.settings.fetchTimeoutMillis);var n,i=r._storageCache.getCustomSignals();i&&r._logger.debug("Fetching config with custom signals: "+JSON.stringify(i));try{await r._client.fetch({cacheMaxAgeMillis:r.settings.minimumFetchIntervalMillis,signal:e,customSignals:i}),await r._storageCache.setLastFetchStatus("success")}catch(e){t="fetch-throttle";i=(n=e)instanceof fe&&-1!==n.code.indexOf(t)?"throttle":"failure";throw await r._storageCache.setLastFetchStatus(i),e}}function fP(r){var e,t,n=w(r);return[e={},t={}]=[n._storageCache.getActiveConfig(),n.defaultConfig],Object.keys({...e,...t}).reduce((e,t)=>(e[t]=gP(r,t),e),{})}function gP(e,t){var r=w(e),n=(r._isInitializationComplete||r._logger.debug(`A value was requested for key "${t}" before SDK initialization completed.`+" Await on ensureInitialized if the intent was to get a previously activated value."),r._storageCache.getActiveConfig());return n&&void 0!==n[t]?new uP("remote",n[t]):r.defaultConfig&&void 0!==r.defaultConfig[t]?new uP("default",String(r.defaultConfig[t])):(r._logger.debug(`Returning static value for key "${t}".`+" Define a default or remote value if this is unintentional."),new uP("static"))}class mP{constructor(e,t,r,n){this.client=e,this.storage=t,this.storageCache=r,this.logger=n}isCachedDataFresh(e,t){var r;return t?(r=Date.now()-t,this.logger.debug("Config fetch cache check."+` Cache age millis: ${r}.`+` Cache max age millis (minimumFetchIntervalMillis setting): ${e}.`+` Is cache hit: ${r=r<=e}.`),r):(this.logger.debug("Config fetch cache check. Cache unpopulated."),!1)}async fetch(e){var[t,r]=await Promise.all([this.storage.getLastSuccessfulFetchTimestampMillis(),this.storage.getLastSuccessfulFetchResponse()]);if(r&&this.isCachedDataFresh(e.cacheMaxAgeMillis,t))return r;e.eTag=r&&r.eTag;t=await this.client.fetch(e),r=[this.storageCache.setLastSuccessfulFetchTimestampMillis(Date.now())];return 200===t.status&&r.push(this.storage.setLastSuccessfulFetchResponse(t)),await Promise.all(r),t}}class vP{constructor(e,t,r,n,i,s){this.firebaseInstallations=e,this.sdkVersion=t,this.namespace=r,this.projectId=n,this.apiKey=i,this.appId=s}async fetch(r){var e,[t,n]=await Promise.all([this.firebaseInstallations.getId(),this.firebaseInstallations.getToken()]),i=`${window.FIREBASE_REMOTE_CONFIG_URL_BASE||"https://firebaseremoteconfig.googleapis.com"}/v1/projects/${this.projectId}/namespaces/${this.namespace}:fetch?key=`+this.apiKey,s={"Content-Type":"application/json","Content-Encoding":"gzip","If-None-Match":r.eTag||"*"},t={sdk_version:this.sdkVersion,app_instance_id:t,app_instance_id_token:n,app_id:this.appId,language_code:(e=navigator).languages&&e.languages[0]||e.language,custom_signals:r.customSignals},n={method:"POST",headers:s,body:JSON.stringify(t)},s=fetch(i,n),t=new Promise((e,t)=>{r.signal.addEventListener(()=>{var e=new Error("The operation was aborted.");e.name="AbortError",t(e)})});let a;try{await Promise.race([s,t]),a=await s}catch(e){let t="fetch-client-network";throw"AbortError"===e?.name&&(t="fetch-timeout"),oP.create(t,{originalErrorMessage:e?.message})}let o=a.status;i=a.headers.get("ETag")||void 0;let l,u,h,c;if(200===a.status){let e;try{e=await a.json()}catch(e){throw oP.create("fetch-client-parse",{originalErrorMessage:e?.message})}l=e.entries,u=e.state,h=e.templateVersion,c=e.experimentDescriptions}if("INSTANCE_STATE_UNSPECIFIED"===u?o=500:"NO_CHANGE"===u?o=304:"NO_TEMPLATE"!==u&&"EMPTY_CONFIG"!==u||(l={},c=[]),304!==o&&200!==o)throw oP.create("fetch-status",{httpStatus:o});return{status:o,eTag:i,config:l,templateVersion:h,experiments:c}}}class _P{constructor(e,t){this.client=e,this.storage=t}async fetch(e){var t=await this.storage.getThrottleMetadata()||{backoffCount:0,throttleEndTimeMillis:Date.now()};return this.attemptFetch(e,t)}async attemptFetch(t,{throttleEndTimeMillis:e,backoffCount:r}){var i,s;i=t.signal,s=e,await new Promise((e,t)=>{var r=Math.max(s-Date.now(),0);let n=setTimeout(e,r);i.addEventListener(()=>{clearTimeout(n),t(oP.create("fetch-throttle",{throttleEndTimeMillis:s}))})});try{var n=await this.client.fetch(t);return await this.storage.deleteThrottleMetadata(),n}catch(e){if((e=>{var t;return e instanceof fe&&e.customData&&(429===(t=Number(e.customData.httpStatus))||500===t||503===t||504===t)})(e))return n={throttleEndTimeMillis:Date.now()+je(r),backoffCount:r+1},await this.storage.setThrottleMetadata(n),this.attemptFetch(t,n);throw e}}}class yP{get fetchTimeMillis(){return this._storageCache.getLastSuccessfulFetchTimestampMillis()||-1}get lastFetchStatus(){return this._storageCache.getLastFetchStatus()||"no-fetch-yet"}constructor(e,t,r,n,i,s,a){this.app=e,this._client=t,this._storageCache=r,this._storage=n,this._logger=i,this._realtimeHandler=s,this._analyticsProvider=a,this._isInitializationComplete=!1,this.settings={fetchTimeoutMillis:6e4,minimumFetchIntervalMillis:432e5},this.defaultConfig={}}}function wP(e,t){var r=e.target.error||void 0;return oP.create(t,{originalErrorMessage:r&&r?.message})}let bP="app_namespace_store",TP="firebase_remote_config",EP=1;class IP{getLastFetchStatus(){return this.get("last_fetch_status")}setLastFetchStatus(e){return this.set("last_fetch_status",e)}getLastSuccessfulFetchTimestampMillis(){return this.get("last_successful_fetch_timestamp_millis")}setLastSuccessfulFetchTimestampMillis(e){return this.set("last_successful_fetch_timestamp_millis",e)}getLastSuccessfulFetchResponse(){return this.get("last_successful_fetch_response")}setLastSuccessfulFetchResponse(e){return this.set("last_successful_fetch_response",e)}getActiveConfig(){return this.get("active_config")}setActiveConfig(e){return this.set("active_config",e)}getActiveConfigEtag(){return this.get("active_config_etag")}setActiveConfigEtag(e){return this.set("active_config_etag",e)}getActiveExperiments(){return this.get("active_experiments")}setActiveExperiments(e){return this.set("active_experiments",e)}getThrottleMetadata(){return this.get("throttle_metadata")}setThrottleMetadata(e){return this.set("throttle_metadata",e)}deleteThrottleMetadata(){return this.delete("throttle_metadata")}getCustomSignals(){return this.get("custom_signals")}getRealtimeBackoffMetadata(){return this.get("realtime_backoff_metadata")}setRealtimeBackoffMetadata(e){return this.set("realtime_backoff_metadata",e)}getActiveConfigTemplateVersion(){return this.get("last_known_template_version")}setActiveConfigTemplateVersion(e){return this.set("last_known_template_version",e)}}class CP extends IP{constructor(e,t,r,n=(()=>new Promise((t,r)=>{try{var e=indexedDB.open(TP,EP);e.onerror=e=>{r(wP(e,"storage-open"))},e.onsuccess=e=>{t(e.target.result)},e.onupgradeneeded=e=>{var t=e.target.result;0===e.oldVersion&&t.createObjectStore(bP,{keyPath:"compositeKey"})}}catch(e){r(oP.create("storage-open",{originalErrorMessage:e?.message}))}}))()){super(),this.appId=e,this.appName=t,this.namespace=r,this.openDbPromise=n}async setCustomSignals(e){var t=(await this.openDbPromise).transaction([bP],"readwrite"),r=kP(e,await this.getWithTransaction("custom_signals",t)||{});return await this.setWithTransaction("custom_signals",r,t),r}async getWithTransaction(s,a){return new Promise((r,t)=>{var e=a.objectStore(bP),n=this.createCompositeKey(s);try{var i=e.get(n);i.onerror=e=>{t(wP(e,"storage-get"))},i.onsuccess=e=>{var t=e.target.result;r(t?t.value:void 0)}}catch(e){t(oP.create("storage-get",{originalErrorMessage:e?.message}))}})}async setWithTransaction(s,a,o){return new Promise((e,t)=>{var r=o.objectStore(bP),n=this.createCompositeKey(s);try{var i=r.put({compositeKey:n,value:a});i.onerror=e=>{t(wP(e,"storage-set"))},i.onsuccess=()=>{e()}}catch(e){t(oP.create("storage-set",{originalErrorMessage:e?.message}))}})}async get(e){var t=(await this.openDbPromise).transaction([bP],"readonly");return this.getWithTransaction(e,t)}async set(e,t){var r=(await this.openDbPromise).transaction([bP],"readwrite");return this.setWithTransaction(e,t,r)}async delete(s){let a=await this.openDbPromise;return new Promise((e,t)=>{var r=a.transaction([bP],"readwrite").objectStore(bP),n=this.createCompositeKey(s);try{var i=r.delete(n);i.onerror=e=>{t(wP(e,"storage-delete"))},i.onsuccess=()=>{e()}}catch(e){t(oP.create("storage-delete",{originalErrorMessage:e?.message}))}})}createCompositeKey(e){return[this.appId,this.appName,this.namespace,e].join()}}class SP extends IP{constructor(){super(...arguments),this.storage={}}async get(e){return Promise.resolve(this.storage[e])}async set(e,t){return this.storage[e]=t,Promise.resolve(void 0)}async delete(e){return this.storage[e]=void 0,Promise.resolve()}async setCustomSignals(e){var t=this.storage.custom_signals||{};return this.storage.custom_signals=kP(e,t),Promise.resolve(this.storage.custom_signals)}}function kP(e,t){var r={...t,...e},r=Object.fromEntries(Object.entries(r).filter(([,e])=>null!==e).map(([e,t])=>"number"==typeof t?[e,t.toString()]:[e,t]));if(Object.keys(r).length>aP)throw oP.create("custom-signal-max-allowed-signals",{maxSignals:aP});return r}class AP{constructor(e){this.storage=e}getLastFetchStatus(){return this.lastFetchStatus}getLastSuccessfulFetchTimestampMillis(){return this.lastSuccessfulFetchTimestampMillis}getActiveConfig(){return this.activeConfig}getCustomSignals(){return this.customSignals}async loadFromStorage(){var e=this.storage.getLastFetchStatus(),t=this.storage.getLastSuccessfulFetchTimestampMillis(),r=this.storage.getActiveConfig(),n=this.storage.getCustomSignals(),e=await e,e=(e&&(this.lastFetchStatus=e),await t),t=(e&&(this.lastSuccessfulFetchTimestampMillis=e),await r),e=(t&&(this.activeConfig=t),await n);e&&(this.customSignals=e)}setLastFetchStatus(e){return this.lastFetchStatus=e,this.storage.setLastFetchStatus(e)}setLastSuccessfulFetchTimestampMillis(e){return this.lastSuccessfulFetchTimestampMillis=e,this.storage.setLastSuccessfulFetchTimestampMillis(e)}setActiveConfig(e){return this.activeConfig=e,this.storage.setActiveConfig(e)}async setCustomSignals(e){this.customSignals=await this.storage.setCustomSignals(e)}}class NP extends class{constructor(e){this.allowedEvents_=e,this.listeners_={},g(Array.isArray(e)&&0<e.length,"Requires a non-empty array")}trigger(t,...r){if(Array.isArray(this.listeners_[t])){var n=[...this.listeners_[t]];for(let e=0;e<n.length;e++)n[e].callback.apply(n[e].context,r)}}on(e,t,r){this.validateEventType_(e),this.listeners_[e]=this.listeners_[e]||[],this.listeners_[e].push({callback:t,context:r});var n=this.getInitialEvent(e);n&&t.apply(r,n)}off(e,t,r){this.validateEventType_(e);var n=this.listeners_[e]||[];for(let i=0;i<n.length;i++)if(n[i].callback===t&&(!r||r===n[i].context))return void n.splice(i,1)}validateEventType_(t){g(this.allowedEvents_.find(e=>e===t),"Unknown event: "+t)}}{static getInstance(){return new NP}constructor(){super(["visible"]);let t,e;"undefined"!=typeof document&&void 0!==document.addEventListener&&(void 0!==document.hidden?(e="visibilitychange",t="hidden"):void 0!==document.mozHidden?(e="mozvisibilitychange",t="mozHidden"):void 0!==document.msHidden?(e="msvisibilitychange",t="msHidden"):void 0!==document.webkitHidden&&(e="webkitvisibilitychange",t="webkitHidden")),this.visible_=!0,e&&document.addEventListener(e,()=>{var e=!document[t];e!==this.visible_&&(this.visible_=e,this.trigger("visible",e))},!1)}getInitialEvent(e){return g("visible"===e,"Unknown event type: "+e),[this.visible_]}}let RP="featureDisabled",PP="retryIntervalSeconds",xP="latestTemplateVersionNumber";class DP{constructor(e,t,r,n,i,s,a,o,l,u){this.firebaseInstallations=e,this.storage=t,this.sdkVersion=r,this.namespace=n,this.projectId=i,this.apiKey=s,this.appId=a,this.logger=o,this.storageCache=l,this.cachingClient=u,this.observers=new Set,this.isConnectionActive=!1,this.isRealtimeDisabled=!1,this.httpRetriesRemaining=8,this.isInBackground=!1,this.decoder=new TextDecoder("utf-8"),this.isClosingConnection=!1,this.propagateError=t=>this.observers.forEach(e=>e.error?.(t)),this.isStatusCodeRetryable=e=>!e||[408,429,502,503,504].includes(e),this.setRetriesRemaining(),NP.getInstance().on("visible",this.onVisibilityChange,this)}async setRetriesRemaining(){var e=(await this.storage.getRealtimeBackoffMetadata())?.numFailedStreams||0;this.httpRetriesRemaining=Math.max(8-e,1)}async updateBackoffMetadataWithLastFailedStreamConnectionTime(e){var t=((await this.storage.getRealtimeBackoffMetadata())?.numFailedStreams||0)+1,r=je(t,6e4,2);await this.storage.setRealtimeBackoffMetadata({backoffEndTimeMillis:new Date(e.getTime()+r),numFailedStreams:t})}async updateBackoffMetadataWithRetryInterval(e){var t=Date.now(),t=new Date(t+1e3*e);await this.storage.setRealtimeBackoffMetadata({backoffEndTimeMillis:t,numFailedStreams:0}),await this.retryHttpConnectionWhenBackoffEnds()}async closeRealtimeHttpConnection(){if(!this.isClosingConnection){this.isClosingConnection=!0;try{this.reader&&await this.reader.cancel()}catch(e){this.logger.debug("Failed to cancel the reader, connection was lost.")}finally{this.reader=void 0}this.controller&&(await this.controller.abort(),this.controller=void 0),this.isClosingConnection=!1}}async resetRealtimeBackoff(){await this.storage.setRealtimeBackoffMetadata({backoffEndTimeMillis:new Date(-1),numFailedStreams:0})}resetRetryCount(){this.httpRetriesRemaining=8}async establishRealtimeConnection(e,t,r,n){var i=await this.storage.getActiveConfigEtag(),s=await this.storage.getActiveConfigTemplateVersion(),i={"X-Goog-Api-Key":this.apiKey,"X-Goog-Firebase-Installations-Auth":r,"Content-Type":"application/json",Accept:"application/json","If-None-Match":i||"*","Content-Encoding":"gzip"},s={project:this.projectId,namespace:this.namespace,lastKnownVersionNumber:s,appId:this.appId,sdkVersion:this.sdkVersion,appInstanceId:t};return await fetch(e,{method:"POST",headers:i,body:JSON.stringify(s),signal:n})}getRealtimeUrl(){var e=`${window.FIREBASE_REMOTE_CONFIG_URL_BASE||"https://firebaseremoteconfigrealtime.googleapis.com"}/v1/projects/${this.projectId}/namespaces/${this.namespace}:streamFetchInvalidations?key=`+this.apiKey;return new URL(e)}async createRealtimeConnection(){var[e,t]=await Promise.all([this.firebaseInstallations.getId(),this.firebaseInstallations.getToken(!1)]),r=(this.controller=new AbortController,this.getRealtimeUrl());return await this.establishRealtimeConnection(r,e,t,this.controller.signal)}async retryHttpConnectionWhenBackoffEnds(){let e=await this.storage.getRealtimeBackoffMetadata();e=e||{backoffEndTimeMillis:new Date(-1),numFailedStreams:0};var t=new Date(e.backoffEndTimeMillis).getTime(),r=Date.now(),t=Math.max(0,t-r);await this.makeRealtimeHttpConnection(t)}setIsHttpConnectionRunning(e){this.isConnectionActive=e}checkAndSetHttpConnectionFlagIfNotRunning(){var e=this.canEstablishStreamConnection();return e&&this.setIsHttpConnectionRunning(!0),e}fetchResponseIsUpToDate(e,t){return null!=e.config&&e.templateVersion?e.templateVersion>=t:"success"===this.storageCache.getLastFetchStatus()}parseAndValidateConfigUpdateMessage(e){var t=e.indexOf("{"),r=e.indexOf("}",t);return t<0||r<0||r<=t?"":e.substring(t,r+1)}isEventListenersEmpty(){return 0===this.observers.size}getRandomInt(e){return Math.floor(Math.random()*e)}executeAllListenerCallbacks(t){this.observers.forEach(e=>e.next(t))}getChangedParams(e,t,r,n){var i,s,a,o,l=new Set,u=new Set(Object.keys(e||{})),h=new Set(Object.keys(t||{})),c=r.experiments||[],d=n?.experiments||[],p=this.createExperimentsMap(c),f=this.createExperimentsMap(d);for(i of u)h.has(i)&&e[i]===t[i]||l.add(i),p.has(i)!==f.has(i)?l.add(i):(s=p.get(i),a=f.get(i),s&&a&&!this.areExperimentsEqual(s,a)&&l.add(i));for(o of h)u.has(o)||l.add(o);return l}areExperimentsEqual(e,t){return e.experimentId===t.experimentId&&e.variantId===t.variantId&&e.timeToLiveMillis===t.timeToLiveMillis&&e.triggerTimeoutMillis===t.triggerTimeoutMillis}createExperimentsMap(e){var t,r=new Map;for(t of e)if(t.affectedParameterKeys&&!t.experimentId.startsWith("_exp_rollout"))for(var n of t.affectedParameterKeys)r.set(n,t);return r}async fetchLatestConfig(e,r){var n=e-1,i=3-n,s=this.storageCache.getCustomSignals(),a=(s&&this.logger.debug("Fetching config with custom signals: "+JSON.stringify(s)),new iP);try{var o,l={cacheMaxAgeMillis:0,signal:a,customSignals:s,fetchType:"REALTIME",fetchAttempt:i},u=await this.storage.getLastSuccessfulFetchResponse(),h=await this.cachingClient.fetch(l);let t=await this.storage.getActiveConfig();if(this.fetchResponseIsUpToDate(h,r))if(null==h.config)this.logger.debug("The fetch succeeded, but the backend had no updates.");else{null==t&&(t={});let e=this.getChangedParams(h.config,t,h,u);0===e.size?this.logger.debug("Config was fetched, but no params changed."):(o={getUpdatedKeys(){return new Set(e)}},this.executeAllListenerCallbacks(o))}else this.logger.debug("Fetched template version is the same as SDK's current version. Retrying fetch."),await this.autoFetch(n,r)}catch(e){a=e instanceof Error?e.message:String(e),s=oP.create("update-not-fetched",{originalErrorMessage:"Failed to auto-fetch config update: "+a});this.propagateError(s)}}async autoFetch(e,r){var t;if(0===e)t=oP.create("update-not-fetched",{originalErrorMessage:"Unable to fetch the latest version of the template."}),this.propagateError(t);else{let t=1e3*this.getRandomInt(4);await new Promise(e=>setTimeout(e,t)),await this.fetchLatestConfig(e,r)}}async handleNotifications(e){let t="";for(;;){var{done:r,value:n}=await e.read();if(r)break;if(r=this.decoder.decode(n,{stream:!0}),t+=r,r.includes("}")&&0!==(t=this.parseAndValidateConfigUpdateMessage(t)).length){try{var i,s,a,o=JSON.parse(t);if(this.isEventListenersEmpty())break;if(RP in o&&!0===o[RP]){var l=oP.create("realtime-unavailable",{originalErrorMessage:"The server is temporarily unavailable. Try again in a few minutes."});this.propagateError(l);break}xP in o&&(i=await this.storage.getActiveConfigTemplateVersion(),s=Number(o[xP]),i)&&i<s&&await this.autoFetch(3,s),PP in o&&(a=Number(o[PP]),await this.updateBackoffMetadataWithRetryInterval(a))}catch(e){this.logger.debug("Unable to parse latest config update message.",e);n=e instanceof Error?e.message:String(e);this.propagateError(oP.create("update-message-invalid",{originalErrorMessage:n}))}t=""}}}async listenForNotifications(e){try{await this.handleNotifications(e)}catch(e){this.isInBackground||this.logger.debug("Real-time connection was closed due to an exception.")}}async prepareAndBeginRealtimeHttpStream(){if(this.checkAndSetHttpConnectionFlagIfNotRunning()){let e=await this.storage.getRealtimeBackoffMetadata();var r=(e=e||{backoffEndTimeMillis:new Date(-1),numFailedStreams:0}).backoffEndTimeMillis.getTime();if(Date.now()<r)await this.retryHttpConnectionWhenBackoffEnds();else{let e,t;try{e=await this.createRealtimeConnection(),t=e.status,e.ok&&e.body&&(this.resetRetryCount(),await this.resetRealtimeBackoff(),n=e.body.getReader(),this.reader=n,await this.listenForNotifications(n))}catch(e){this.isInBackground?this.resetRetryCount():this.logger.debug("Exception connecting to real-time RC backend. Retrying the connection...:",e)}finally{await this.closeRealtimeHttpConnection(),this.setIsHttpConnectionRunning(!1);var n,r=!this.isInBackground&&(void 0===t||this.isStatusCodeRetryable(t));r&&await this.updateBackoffMetadataWithLastFailedStreamConnectionTime(new Date),r||e?.ok?await this.retryHttpConnectionWhenBackoffEnds():(n="Unable to connect to the server. HTTP status code: "+t,r=oP.create("stream-error",{originalErrorMessage:n}),this.propagateError(r))}}}}canEstablishStreamConnection(){var e=0<this.observers.size,t=!this.isRealtimeDisabled,r=!this.isConnectionActive,n=!this.isInBackground;return e&&t&&r&&n}async makeRealtimeHttpConnection(t){var e;this.canEstablishStreamConnection()&&(0<this.httpRetriesRemaining?(this.httpRetriesRemaining--,await new Promise(e=>setTimeout(e,t)),this.prepareAndBeginRealtimeHttpStream()):this.isInBackground||(e=oP.create("stream-error",{originalErrorMessage:"Unable to connect to the server. Check your connection and try again."}),this.propagateError(e)))}async beginRealtime(){0<this.observers.size&&await this.makeRealtimeHttpConnection(0)}addObserver(e){this.observers.add(e),this.beginRealtime()}removeObserver(e){this.observers.has(e)&&this.observers.delete(e)}async onVisibilityChange(e){this.isInBackground=!e,e?await this.beginRealtime():await this.closeRealtimeHttpConnection()}}async function OP(){if(!ce())return!1;try{return await de()}catch(e){return!1}}Rt(new h(sP,function(e,{options:t}){var r=e.getProvider("app").getImmediate(),n=e.getProvider("installations-internal").getImmediate(),i=e.getProvider("analytics-internal"),{projectId:s,apiKey:a,appId:o}=r.options;if(!s)throw oP.create("registration-project-id");if(!a)throw oP.create("registration-api-key");if(!o)throw oP.create("registration-app-id");var l=t?.templateId||"firebase",u=ce()?new CP(o,r.name,l):new SP,h=new AP(u),c=new Ze(rP),d=(c.logLevel=p.ERROR,new vP(n,Vt,l,s,a,o)),d=new _P(d,u),d=new mP(d,u,h,c),n=new DP(n,u,Vt,l,s,a,o,c,h,d),l=new yP(r,d,h,u,c,n,i);return dP(l),l},"PUBLIC").setMultipleInstances(!0)),zt(rP,nP),zt(rP,nP,"esm2020");class LP{constructor(e,t){this.app=e,this._delegate=t}get defaultConfig(){return this._delegate.defaultConfig}set defaultConfig(e){this._delegate.defaultConfig=e}get fetchTimeMillis(){return this._delegate.fetchTimeMillis}get lastFetchStatus(){return this._delegate.lastFetchStatus}get settings(){return this._delegate.settings}set settings(e){this._delegate.settings=e}activate(){return cP(this._delegate)}ensureInitialized(){return dP(this._delegate)}fetch(){return pP(this._delegate)}fetchAndActivate(){return(async e=>(await pP(e=w(e)),cP(e)))(this._delegate)}getAll(){return fP(this._delegate)}getBoolean(e){return gP(w(this._delegate),e).asBoolean()}getNumber(e){return gP(w(this._delegate),e).asNumber()}getString(e){return gP(w(this._delegate),e).asString()}getValue(e){return gP(this._delegate,e)}setLogLevel(e){var t=this._delegate,r=w(t);switch(e){case"debug":r._logger.logLevel=p.DEBUG;break;case"silent":r._logger.logLevel=p.SILENT;break;default:r._logger.logLevel=p.ERROR}}}let MP="@firebase/remote-config-compat",FP="0.2.26";function UP(e,{instanceIdentifier:t}){var r=e.getProvider("app-compat").getImmediate(),n=e.getProvider("remote-config").getImmediate({identifier:t});return new LP(r,n)}return(t=pr).INTERNAL.registerComponent(new h("remoteConfig-compat",UP,"PUBLIC").setMultipleInstances(!0).setServiceProps({isSupported:OP})),t.registerVersion(MP,FP),console.warn(`
It looks like you're using the development build of the Firebase JS SDK.
When deploying Firebase apps to production, it is advisable to only import
the individual SDK components you intend to use.

For the CDN builds, these are available in the following manner
(replace <PACKAGE> with the name of a component - i.e. auth, database, etc):

https://www.gstatic.com/firebasejs/5.0.0/firebase-<PACKAGE>.js
`),pr.registerVersion("firebase","12.15.0","compat-cdn"),pr});
//# sourceMappingURL=firebase-compat.js.map