PageSourceSearch

https://play.zensimu.com/assets/DWdpTwXK.js

js zensimu.com collected 2026-10-08 06:33:56 UTC 503,526 bytes, 3,518 lines download raw bytes

1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._posthogChunkIds=e._posthogChunkIds||{},e._posthogChunkIds[n]="01a0ecf6-50c2-73d1-a7c7-f8179acc7ff9")}catch(e){}}();const hf=()=>{};var vc={};/**
2 * @license
3 * Copyright 2017 Google LLC
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 *   http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */const nl=function(n){const e=[];let t=0;for(let r=0;r<n.length;r++){let s=n.charCodeAt(r);s<128?e[t++]=s:s<2048?(e[t++]=s>>6|192,e[t++]=s&63|128):(s&64512)===55296&&r+1<n.length&&(n.charCodeAt(r+1)&64512)===56320?(s=65536+((s&1023)<<10)+(n.charCodeAt(++r)&1023),e[t++]=s>>18|240,e[t++]=s>>12&63|128,e[t++]=s>>6&63|128,e[t++]=s&63|128):(e[t++]=s>>12|224,e[t++]=s>>6&63|128,e[t++]=s&63|128)}return e},df=function(n){const e=[];let t=0,r=0;for(;t<n.length;){const s=n[t++];if(s<128)e[r++]=String.fromCharCode(s);else if(s>191&&s<224){const o=n[t++];e[r++]=String.fromCharCode((s&31)<<6|o&63)}else if(s>239&&s<365){const o=n[t++],a=n[t++],u=n[t++],h=((s&7)<<18|(o&63)<<12|(a&63)<<6|u&63)-65536;e[r++]=String.fromCharCode(55296+(h>>10)),e[r++]=String.fromCharCode(56320+(h&1023))}else{const o=n[t++],a=n[t++];e[r++]=String.fromCharCode((s&15)<<12|(o&63)<<6|a&63)}}return e.join("")},rl={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:typeof atob=="function",encodeByteArray(n,e){if(!Array.isArray(n))throw Error("encodeByteArray takes an array as a parameter");this.init_();const t=e?this.byteToCharMapWebSafe_:this.byteToCharMap_,r=[];for(let s=0;s<n.length;s+=3){const o=n[s],a=s+1<n.length,u=a?n[s+1]:0,h=s+2<n.length,d=h?n[s+2]:0,p=o>>2,_=(o&3)<<4|u>>4;let E=(u&15)<<2|d>>6,S=d&63;h||(S=64,a||(E=64)),r.push(t[p],t[_],t[E],t[S])}return r.join("")},encodeString(n,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(n):this.encodeByteArray(nl(n),e)},decodeString(n,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(n):df(this.decodeStringToByteArray(n,e))},decodeStringToByteArray(n,e){this.init_();const t=e?this.charToByteMapWebSafe_:this.charToByteMap_,r=[];for(let s=0;s<n.length;){const o=t[n.charAt(s++)],u=s<n.length?t[n.charAt(s)]:0;++s;const d=s<n.length?t[n.charAt(s)]:64;++s;const _=s<n.length?t[n.charAt(s)]:64;if(++s,o==null||u==null||d==null||_==null)throw new ff;const E=o<<2|u>>4;if(r.push(E),d!==64){const S=u<<4&240|d>>2;if(r.push(S),_!==64){const b=d<<6&192|_;r.push(b)}}}return r},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let n=0;n<this.ENCODED_VALS.length;n++)this.byteToCharMap_[n]=this.ENCODED_VALS.charAt(n),this.charToByteMap_[this.byteToCharMap_[n]]=n,this.byteToCharMapWebSafe_[n]=this.ENCODED_VALS_WEBSAFE.charAt(n),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[n]]=n,n>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(n)]=n,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(n)]=n)}}};class ff extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}const pf=function(n){const e=nl(n);return rl.encodeByteArray(e,!0)},fs=function(n){return pf(n).replace(/\./g,"")},sl=function(n){try{return rl.decodeString(n,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};/**
17 * @license
18 * Copyright 2022 Google LLC
19 *
20 * Licensed under the Apache License, Version 2.0 (the "License");
21 * you may not use this file except in compliance with the License.
22 * You may obtain a copy of the License at
23 *
24 *   http://www.apache.org/licenses/LICENSE-2.0
25 *
26 * Unless required by applicable law or agreed to in writing, software
27 * distributed under the License is distributed on an "AS IS" BASIS,
28 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29 * See the License for the specific language governing permissions and
30 * limitations under the License.
31 */function mf(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("Unable to locate global object.")}/**
32 * @license
33 * Copyright 2022 Google LLC
34 *
35 * Licensed under the Apache License, Version 2.0 (the "License");
36 * you may not use this file except in compliance with the License.
37 * You may obtain a copy of the License at
38 *
39 *   http://www.apache.org/licenses/LICENSE-2.0
40 *
41 * Unless required by applicable law or agreed to in writing, software
42 * distributed under the License is distributed on an "AS IS" BASIS,
43 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
44 * See the License for the specific language governing permissions and
45 * limitations under the License.
46 */const gf=()=>mf().__FIREBASE_DEFAULTS__,_f=()=>{if(typeof process>"u"||typeof vc>"u")return;const n=vc.__FIREBASE_DEFAULTS__;if(n)return JSON.parse(n)},yf=()=>{if(typeof document>"u")return;let n;try{n=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch{return}const e=n&&sl(n[1]);return e&&JSON.parse(e)},Os=()=>{try{return hf()||gf()||_f()||yf()}catch(n){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${n}`);return}},il=n=>{var e,t;return(t=(e=Os())==null?void 0:e.emulatorHosts)==null?void 0:t[n]},Ef=n=>{const e=il(n);if(!e)return;const t=e.lastIndexOf(":");if(t<=0||t+1===e.length)throw new Error(`Invalid host ${e} with no separate hostname and port!`);const r=parseInt(e.substring(t+1),10);return e[0]==="["?[e.substring(1,t-1),r]:[e.substring(0,t),r]},ol=()=>{var n;return(n=Os())==null?void 0:n.config},al=n=>{var e;return(e=Os())==null?void 0:e[`_${n}`]};/**
47 * @license
48 * Copyright 2017 Google LLC
49 *
50 * Licensed under the Apache License, Version 2.0 (the "License");
51 * you may not use this file except in compliance with the License.
52 * You may obtain a copy of the License at
53 *
54 *   http://www.apache.org/licenses/LICENSE-2.0
55 *
56 * Unless required by applicable law or agreed to in writing, software
57 * distributed under the License is distributed on an "AS IS" BASIS,
58 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
59 * See the License for the specific language governing permissions and
60 * limitations under the License.
61 */class Tf{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}wrapCallback(e){return(t,r)=>{t?this.reject(t):this.resolve(r),typeof e=="function"&&(this.promise.catch(()=>{}),e.length===1?e(t):e(t,r))}}}/**
62 * @license
63 * Copyright 2025 Google LLC
64 *
65 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
67 * You may obtain a copy of the License at
68 *
69 *   http://www.apache.org/licenses/LICENSE-2.0
70 *
71 * Unless required by applicable law or agreed to in writing, software
72 * distributed under the License is distributed on an "AS IS" BASIS,
73 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
74 * See the License for the specific language governing permissions and
75 * limitations under the License.
76 */function Yt(n){try{return(n.startsWith("http://")||n.startsWith("https://")?new URL(n).hostname:n).endsWith(".cloudworkstations.dev")}catch{return!1}}async function yo(n){return(await fetch(n,{credentials:"include"})).ok}/**
77 * @license
78 * Copyright 2021 Google LLC
79 *
80 * Licensed under the Apache License, Version 2.0 (the "License");
81 * you may not use this file except in compliance with the License.
82 * You may obtain a copy of the License at
83 *
84 *   http://www.apache.org/licenses/LICENSE-2.0
85 *
86 * Unless required by applicable law or agreed to in writing, softw
86are
87 * distributed under the License is distributed on an "AS IS" BASIS,
88 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
89 * See the License for the specific language governing permissions and
90 * limitations under the License.
91 */function UT(n,e){if(n.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');const t={alg:"none",type:"JWT"},r=e||"demo-project",s=n.iat||0,o=n.sub||n.user_id;if(!o)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const a={iss:`https://securetoken.google.com/${r}`,aud:r,iat:s,exp:s+3600,auth_time:s,sub:o,user_id:o,firebase:{sign_in_provider:"custom",identities:{}},...n};return[fs(JSON.stringify(t)),fs(JSON.stringify(a)),""].join(".")}const tr={};function If(){const n={prod:[],emulator:[]};for(const e of Object.keys(tr))tr[e]?n.emulator.push(e):n.prod.push(e);return n}function wf(n){let e=document.getElementById(n),t=!1;return e||(e=document.createElement("div"),e.setAttribute("id",n),t=!0),{created:t,element:e}}let Ac=!1;function cl(n,e){if(typeof window>"u"||typeof document>"u"||!Yt(window.location.host)||tr[n]===e||tr[n]||Ac)return;tr[n]=e;function t(E){return`__firebase__banner__${E}`}const r="__firebase__banner",o=If().prod.length>0;function a(){const E=document.getElementById(r);E&&E.remove()}function u(E){E.style.display="flex",E.style.background="#7faaf0",E.style.position="fixed",E.style.bottom="5px",E.style.left="5px",E.style.padding=".5em",E.style.borderRadius="5px",E.style.alignItems="center"}function h(E,S){E.setAttribute("width","24"),E.setAttribute("id",S),E.setAttribute("height","24"),E.setAttribute("viewBox","0 0 24 24"),E.setAttribute("fill","none"),E.style.marginLeft="-6px"}function d(){const E=document.createElement("span");return E.style.cursor="pointer",E.style.marginLeft="16px",E.style.fontSize="24px",E.innerHTML=" &times;",E.onclick=()=>{Ac=!0,a()},E}function p(E,S){E.setAttribute("id",S),E.innerText="Learn more",E.href="https://firebase.google.com/docs/studio/preview-apps#preview-backend",E.setAttribute("target","__blank"),E.style.paddingLeft="5px",E.style.textDecoration="underline"}function _(){const E=wf(r),S=t("text"),b=document.getElementById(S)||document.createElement("span"),D=t("learnmore"),N=document.getElementById(D)||document.createElement("a"),q=t("preprendIcon"),B=document.getElementById(q)||document.createElementNS("http://www.w3.org/2000/svg","svg");if(E.created){const W=E.element;u(W),p(N,D);const se=d();h(B,q),W.append(B,b,N,se),document.body.appendChild(W)}o?(b.innerText="Preview backend disconnected.",B.innerHTML=`<g clip-path="url(#clip0_6013_33858)">
92<path d="M4.8 17.6L12 5.6L19.2 17.6H4.8ZM6.91667 16.4H17.0833L12 7.93333L6.91667 16.4ZM12 15.6C12.1667 15.6 12.3056 15.5444 12.4167 15.4333C12.5389 15.3111 12.6 15.1667 12.6 15C12.6 14.8333 12.5389 14.6944 12.4167 14.5833C12.3056 14.4611 12.1667 14.4 12 14.4C11.8333 14.4 11.6889 14.4611 11.5667 14.5833C11.4556 14.6944 11.4 14.8333 11.4 15C11.4 15.1667 11.4556 15.3111 11.5667 15.4333C11.6889 15.5444 11.8333 15.6 12 15.6ZM11.4 13.6H12.6V10.4H11.4V13.6Z" fill="#212121"/>
93</g>
94<defs>
95<clipPath id="clip0_6013_33858">
96<rect width="24" height="24" fill="white"/>
97</clipPath>
98</defs>`):(B.innerHTML=`<g clip-path="url(#clip0_6083_34804)">
99<path d="M11.4 15.2H12.6V11.2H11.4V15.2ZM12 10C12.1667 10 12.3056 9.94444 12.4167 9.83333C12.5389 9.71111 12.6 9.56667 12.6 9.4C12.6 9.23333 12.5389 9.09444 12.4167 8.98333C12.3056 8.86111 12.1667 8.8 12 8.8C11.8333 8.8 11.6889 8.86111 11.5667 8.98333C11.4556 9.09444 11.4 9.23333 11.4 9.4C11.4 9.56667 11.4556 9.71111 11.5667 9.83333C11.6889 9.94444 11.8333 10 12 10ZM12 18.4C11.1222 18.4 10.2944 18.2333 9.51667 17.9C8.73889 17.5667 8.05556 17.1111 7.46667 16.5333C6.88889 15.9444 6.43333 15.2611 6.1 14.4833C5.76667 13.7056 5.6 12.8778 5.6 12C5.6 11.1111 5.76667 10.2833 6.1 9.51667C6.43333 8.73889 6.88889 8.06111 7.46667 7.48333C8.05556 6.89444 8.73889 6.43333 9.51667 6.1C10.2944 5.76667 11.1222 5.6 12 5.6C12.8889 5.6 13.7167 5.76667 14.4833 6.1C15.2611 6.43333 15.9389 6.89444 16.5167 7.48333C17.1056 8.06111 17.5667 8.73889 17.9 9.51667C18.2333 10.2833 18.4 11.1111 18.4 12C18.4 12.8778 18.2333 13.7056 17.9 14.4833C17.5667 15.2611 17.1056 15.9444 16.5167 16.5333C15.9389 17.1111 15.2611 17.5667 14.4833 17.9C13.7167 18.2333 12.8889 18.4 12 18.4ZM12 17.2C13.4444 17.2 14.6722 16.6944 15.6833 15.6833C16.6944 14.6722 17.2 13.4444 17.2 12C17.2 10.5556 16.6944 9.32778 15.6833 8.31667C14.6722 7.30555 13.4444 6.8 12 6.8C10.5556 6.8 9.32778 7.30555 8.31667 8.31667C7.30556 9.32778 6.8 10.5556 6.8 12C6.8 13.4444 7.30556 14.6722 8.31667 15.6833C9.32778 16.6944 10.5556 17.2 12 17.2Z" fill="#212121"/>
100</g>
101<defs>
102<clipPath id="clip0_6083_34804">
103<rect width="24" height="24" fill="white"/>
104</clipPath>
105</defs>`,b.innerText="Preview backend running in this workspace."),b.setAttribute("id",S)}document.readyState==="loading"?window.addEventListener("DOMContentLoaded",_):_()}/**
106 * @license
107 * Copyright 2017 Google LLC
108 *
109 * Licensed under the Apache License, Version 2.0 (the "License");
110 * you may not use this file except in compliance with the License.
111 * You may obtain a copy of the License at
112 *
113 *   http://www.apache.org/licenses/LICENSE-2.0
114 *
115 * Unless required by applicable law or agreed to in writing, software
116 * distributed under the License is distributed on an "AS IS" BASIS,
117 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
118 * See the License for the specific language governing permissions and
119 * limitations under the License.
120 */function ve(){return typeof navigator<"u"&&typeof navigator.userAgent=="string"?navigator.userAgent:""}function vf(){return typeof window<"u"&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(ve())}function Af(){var e;const n=(e=Os())==null?void 0:e.forceEnvironment;if(n==="node")return!0;if(n==="browser")return!1;try{return Object.prototype.toString.call(global.process)==="[object process]"}catch{return!1}}function Rf(){return typeof navigator<"u"&&navigator.userAgent==="Cloudflare-Workers"}function Sf(){const n=typeof chrome=="object"?chrome.runtime:typeof browser=="object"?browser.runtime:void 0;return typeof n=="object"&&n.id!==void 0}function Pf(){return typeof navigator=="object"&&navigator.product==="ReactNative"}function Cf(){const n=ve();return n.indexOf("MSIE ")>=0||n.indexOf("Trident/")>=0}function bf(){return!Af()&&!!navigator.userAgent&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}function kf(){try{return typeof indexedDB=="object"}catch{return!1}}function Nf(){return new Promise((n,e)=>{try{let t=!0;const r="validate-browser-context-for-indexeddb-analytics-module",s=self.indexedDB.open(r);s.onsuccess=()=>{s.result.close(),t||self.indexedDB.deleteDatabase(r),n(!0)},s.onupgradeneeded=()=>{t=!1},s.onerror=()=>{var o;e(((o=s.error)==null?void 0:o.message)||"")}}catch(t){e(t)}})}/**
121 * @license
122 * Copyright 2017 Google LLC
123 *
124 * Licensed under the Apache License, Version 2.0 (the "License");
125 * you may not use this file except in compliance with the License.
126 * You may obtain a copy of the License at
127 *
128 *   http://www.apache.org/licenses/LICENSE-2.0
129 *
130 * Unless required by applicable law or agreed to in writing, software
131 * distributed under the License is distributed on an "AS IS" BASIS,
132 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
133 * See the License for the specific language governing permissions and
134 * limitations under the License.
135 */const Vf="FirebaseError";class Ze extends Error{constructor(e,t,r){super(t),this.code=e,this.customData=r,this.name=Vf,Object.setPrototypeOf(this,Ze.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,yr.prototype.create)}}class yr{constructor(e,t,r){this.service=e,this.serviceName=t,this.errors=r}create(e,...t){const r=t[0]||{},s=`${this.service}/${e}`,o=this.errors[e],a=o?Df(o,r):"Error",u=`${this.serviceName}: ${a} (${s}).`;return new Ze(s,u,r)}}function Df(n,e){return n.replace(Of,(t,r)=>{const s=e[r];return s!=null?String(s):`<${r}?>`})}const Of=/\{\$([^}]+)}/g;function Mf(n){for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e))return!1;return!0}function ut(n,e){if(n===e)return!0;const t=Object.keys(n),r=Object.keys(e);for(const s of t){if(!r.includes(s))return!1;const o=n[s],a=e[s];if(Rc(o)&&Rc(a)){if(!ut(o,a))return!1}else if(o!==a)return!1}for(const s of r)if(!t.includes(s))return!1;return!0}function Rc(n){return n!==null&&typeof n=="object"}/**
136 * @license
137 * Copyright 2017 Google LLC
138 *
139 * Licensed under the Apache License, Version 2.0 (the "License");
140 * you may not use this file except in compliance with the License.
141 * You may obtain a copy of the License at
142 *
143 *   http://www.apache.org/licenses/LICENSE-2.0
144 *
145 * Unless required by applicable law or agreed to in writing, software
146 * distributed under the License is distributed on an "AS IS" BASIS,
147 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
148 * See the License for the specific language governing permissions and
149 * limitations under the License.
150 */function Er(n){const e=[];for(const[t,r]of Object.entries(n))Array.isArray(r)?r.forEach(s=>{e.push(encodeURIComponent(t)+"="+encodeURIComponent(s))}):e.push(encodeURIComponent(t)+"="+encodeURIComponent(r));return e.length?"&"+e.join("&"):""}function Qn(n){const e={};return n.replace(/^\?/,"").split("&").forEach(r=>{if(r){const[s,o]=r.split("=");e[decodeURIComponent(s)]=decodeURIComponent(o)}}),e}function Jn(n){const e=n.indexOf("?");if(!e)return"";const t=n.indexOf("#",e);return n.substring(e,t>0?t:void 0)}function Lf(n,e){const t=new xf(n,e);return t.subscribe.bind(t)}class xf{constructor(e,t){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Prom
150ise.resolve(),this.finalized=!1,this.onNoObservers=t,this.task.then(()=>{e(this)}).catch(r=>{this.error(r)})}next(e){this.forEachObserver(t=>{t.next(e)})}error(e){this.forEachObserver(t=>{t.error(e)}),this.close(e)}complete(){this.forEachObserver(e=>{e.complete()}),this.close()}subscribe(e,t,r){let s;if(e===void 0&&t===void 0&&r===void 0)throw new Error("Missing Observer.");Ff(e,["next","error","complete"])?s=e:s={next:e,error:t,complete:r},s.next===void 0&&(s.next=ki),s.error===void 0&&(s.error=ki),s.complete===void 0&&(s.complete=ki);const o=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(()=>{try{this.finalError?s.error(this.finalError):s.complete()}catch{}}),this.observers.push(s),o}unsubscribeOne(e){this.observers===void 0||this.observers[e]===void 0||(delete this.observers[e],this.observerCount-=1,this.observerCount===0&&this.onNoObservers!==void 0&&this.onNoObservers(this))}forEachObserver(e){if(!this.finalized)for(let t=0;t<this.observers.length;t++)this.sendOne(t,e)}sendOne(e,t){this.task.then(()=>{if(this.observers!==void 0&&this.observers[e]!==void 0)try{t(this.observers[e])}catch(r){typeof console<"u"&&console.error&&console.error(r)}})}close(e){this.finalized||(this.finalized=!0,e!==void 0&&(this.finalError=e),this.task.then(()=>{this.observers=void 0,this.onNoObservers=void 0}))}}function Ff(n,e){if(typeof n!="object"||n===null)return!1;for(const t of e)if(t in n&&typeof n[t]=="function")return!0;return!1}function ki(){}/**
151 * @license
152 * Copyright 2019 Google LLC
153 *
154 * Licensed under the Apache License, Version 2.0 (the "License");
155 * you may not use this file except in compliance with the License.
156 * You may obtain a copy of the License at
157 *
158 *   http://www.apache.org/licenses/LICENSE-2.0
159 *
160 * Unless required by applicable law or agreed to in writing, software
161 * distributed under the License is distributed on an "AS IS" BASIS,
162 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
163 * See the License for the specific language governing permissions and
164 * limitations under the License.
165 */const Uf=1e3,Bf=2,qf=4*60*60*1e3,jf=.5;function BT(n,e=Uf,t=Bf){const r=e*Math.pow(t,n),s=Math.round(jf*r*(Math.random()-.5)*2);return Math.min(qf,r+s)}/**
166 * @license
167 * Copyright 2021 Google LLC
168 *
169 * Licensed under the Apache License, Version 2.0 (the "License");
170 * you may not use this file except in compliance with the License.
171 * You may obtain a copy of the License at
172 *
173 *   http://www.apache.org/licenses/LICENSE-2.0
174 *
175 * Unless required by applicable law or agreed to in writing, software
176 * distributed under the License is distributed on an "AS IS" BASIS,
177 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
178 * See the License for the specific language governing permissions and
179 * limitations under the License.
180 */function G(n){return n&&n._delegate?n._delegate:n}class kt{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}}/**
181 * @license
182 * Copyright 2019 Google LLC
183 *
184 * Licensed under the Apache License, Version 2.0 (the "License");
185 * you may not use this file except in compliance with the License.
186 * You may obtain a copy of the License at
187 *
188 *   http://www.apache.org/licenses/LICENSE-2.0
189 *
190 * Unless required by applicable law or agreed to in writing, software
191 * distributed under the License is distributed on an "AS IS" BASIS,
192 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
193 * See the License for the specific language governing permissions and
194 * limitations under the License.
195 */const $t="[DEFAULT]";/**
196 * @license
197 * Copyright 2019 Google LLC
198 *
199 * Licensed under the Apache License, Version 2.0 (the "License");
200 * you may not use this file except in compliance with the License.
201 * You may obtain a copy of the License at
202 *
203 *   http://www.apache.org/licenses/LICENSE-2.0
204 *
205 * Unless required by applicable law or agreed to in writing, softw
205are
206 * distributed under the License is distributed on an "AS IS" BASIS,
207 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
208 * See the License for the specific language governing permissions and
209 * limitations under the License.
210 */class $f{constructor(e,t){this.name=e,this.container=t,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(e){const t=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(t)){const r=new Tf;if(this.instancesDeferred.set(t,r),this.isInitialized(t)||this.shouldAutoInitialize())try{const s=this.getOrInitializeService({instanceIdentifier:t});s&&r.resolve(s)}catch{}}return this.instancesDeferred.get(t).promise}getImmediate(e){const t=this.normalizeInstanceIdentifier(e==null?void 0:e.identifier),r=(e==null?void 0:e.optional)??!1;if(this.isInitialized(t)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:t})}catch(s){if(r)return null;throw s}else{if(r)return null;throw Error(`Service ${this.name} is not available`)}}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(Hf(e))try{this.getOrInitializeService({instanceIdentifier:$t})}catch{}for(const[t,r]of this.instancesDeferred.entries()){const s=this.normalizeInstanceIdentifier(t);try{const o=this.getOrInitializeService({instanceIdentifier:s});r.resolve(o)}catch{}}}}clearInstance(e=$t){this.instancesDeferred.delete(e),this.instancesOptions.delete(e),this.instances.delete(e)}async delete(){const e=Array.from(this.instances.values());await Promise.all([...e.filter(t=>"INTERNAL"in t).map(t=>t.INTERNAL.delete()),...e.filter(t=>"_delete"in t).map(t=>t._delete())])}isComponentSet(){return this.component!=null}isInitialized(e=$t){return this.instances.has(e)}getOptions(e=$t){return this.instancesOptions.get(e)||{}}initialize(e={}){const{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`);const s=this.getOrInitializeService({instanceIdentifier:r,options:t});for(const[o,a]of this.instancesDeferred.entries()){const u=this.normalizeInstanceIdentifier(o);r===u&&a.resolve(s)}return s}onInit(e,t){const r=this.normalizeInstanceIdentifier(t),s=this.onInitCallbacks.get(r)??new Set;s.add(e),this.onInitCallbacks.set(r,s);const o=this.instances.get(r);return o&&e(o,r),()=>{s.delete(e)}}invokeOnInitCallbacks(e,t){const r=this.onInitCallbacks.get(t);if(r)for(const s of r)try{s(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:zf(e),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{}return r||null}normalizeInstanceIdentifier(e=$t){return this.component?this.component.multipleInstances?e:$t:e}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!=="EXPLICIT"}}function zf(n){return n===$t?void 0:n}function Hf(n){return n.instantiationMode==="EAGER"}/**
211 * @license
212 * Copyright 2019 Google LLC
213 *
214 * Licensed under the Apache License, Version 2.0 (the "License");
215 * you may not use this file except in compliance with the License.
216 * You may obtain a copy of the License at
217 *
218 *   http://www.apache.org/licenses/LICENSE-2.0
219 *
220 * Unless required by applicable law or agreed to in writing, software
221 * distributed under the License is distributed on an "AS IS" BASIS,
222 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
223 * See the License for the specific language governing permissions and
224 * limitations under the License.
225 */class Wf{constructor(e){this.name=e,this.providers=new Map}addComponent(e){const t=this.getProvider(e.name);if(t.isComponentSet())throw new Error(`Component ${e.name} has already been registered with ${this.name}`);t.setComponent(e)}addOrOverwriteComponent(e){this.getProvider(e.name).isComponentSet()&&this.providers.delete(e.name),this.addComponent(e)}getProvider(e){if(this.providers.has(e))return this.providers.get(e);const t=new $f(e,this);return this.providers.set(e,t),t}getProviders(){return Array.from(this.providers.values())}}/**
226 * @license
227 * Copyright 2017 Google LLC
228 *
229 * Licensed under the Apache License, Version 2.0 (the "License");
230 * you may not use this file except in compliance with the License.
231 * You may obtain a copy of the License at
232 *
233 *   http://www.apache.org/licenses/LICENSE-2.0
234 *
235 * Unless required by applicable law or agreed to in writing, software
236 * distributed under the License is distributed on an "AS IS" BASIS,
237 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
238 * See the License for the specific language governing permissions and
239 * limitations under the License.
240 */var j;(function(n){n[n.DEBUG=0]="DEBUG",n[n.VERBOSE=1]="VERBOSE",n[n.INFO=2]="INFO",n[n.WARN=3]="WARN",n[n.ERROR=4]="ERROR",n[n.SILENT=5]="SILENT"})(j||(j={}));const Gf={debug:j.DEBUG,verbose:j.VERBOSE,info:j.INFO,warn:j.WARN,error:j.ERROR,silent:j.SILENT},Kf=j.INFO,Qf={[j.DEBUG]:"log",[j.VERBOSE]:"log",[j.INFO]:"info",[j.WARN]:"warn",[j.ERROR]:"error"},Jf=(n,e,...t)=>{if(e<n.logLevel)return;const r=new Date().toISOString(),s=Qf[e];if(s)console[s](`[${r}]  ${n.name}:`,...t);else throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`)};class Eo{constructor(e){this.name=e,this._logLevel=Kf,this._logHandler=Jf,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in j))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel=typeof e=="string"?Gf[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if(typeof e!="function")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,j.DEBUG,...e),this._logHandler(this,j.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,j.VERBOSE,...e),this._logHandler(this,j.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,j.INFO,...e),this._logHandler(this,j.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,j.WARN,...e),this._logHandler(this,j.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,j.ERROR,...e),this._logHandler(this,j.ERROR,...e)}}const Yf=(n,e)=>e.some(t=>n instanceof t);let Sc,Pc;function Xf(){return Sc||(Sc=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Zf(){return Pc||(Pc=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const ul=new WeakMap,$i=new WeakMap,ll=new WeakMap,Ni=new WeakMap,To=new WeakMap;function ep(n){const e=new Promise((t,r)=>{const s=()=>{n.removeEventListener("success",o),n.removeEventListener("error",a)},o=()=>{t(Rt(n.result)),s()},a=()=>{r(n.error),s()};n.addEventListener("success",o),n.addEventListener("error",a)});return e.then(t=>{t instanceof IDBCursor&&ul.set(t,n)}).catch(()=>{}),To.set(e,n),e}function tp(n){if($i.has(n))return;const e=new Promise((t,r)=>{const s=()=>{n.removeEventListener("complete",o),n.removeEventListener("error",a),n.removeEventListener("abort",a)},o=()=>{t(),s()},a=()=>{r(n.error||new DOMException("AbortError","AbortError")),s()};n.addEventListener("complete",o),n.addEventListener("error",a),n.addEventListener("abort",a)});$i.set(n,e)}let zi={get(n,e,t){if(n instanceof IDBTransaction){if(e==="done")return $i.get(n);if(e==="objectStoreNames")return n.objectStoreNames||ll.get(n);if(e==="store")return t.objectStoreNames[1]?void 0:t.objectStore(t.objectStoreNames[0])}return Rt(n[e])},set(n,e,t){return n[e]=t,!0},has(n,e){return n instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in n}};function np(n){zi=n(zi)}function rp(n){return n===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...t){const r=n.call(Vi(this),e,...t);return ll.set(r,e.sort?e.sort():[e]),Rt(r)}:Zf().includes(n)?function(...e){return n.apply(Vi(this),e),Rt(ul.get(this))}:function(...e){return Rt(n.apply(Vi(this),e))}}function sp(n){return typeof n=="function"?rp(n):(n instanceof IDBTransaction&&tp(n),Yf(n,Xf())?new Proxy(n,zi):n)}function Rt(n){if(n instanceof IDBRequest)return ep(n);if(Ni.has(n))return Ni.get(n);const e=sp(n);return e!==n&&(Ni.set(n,e),To.set(e,n)),e}const Vi=n=>To.get(n);function ip(n,e,{blocked:t,upgrade:r,blocking:s,terminated:o}={}){const a=indexedDB.open(n,e),u=Rt(a);return r&&a.addEventListener("upgradeneeded",h=>{r(Rt(a.result),h.oldVersion,h.newVersion,Rt(a.transaction),h)}),t&&a.addEventListener("blocked",h=>t(h.oldVersion,h.newVersion,h)),u.then(h=>{o&&h.addEventListener("close",()=>o()),s&&h.addEventListener("versionchange",d=>s(d.oldVersion,d.newVersion,d))}).catch(()=>{}),u}const op=["get","getKey","getAll","getAllKeys","count"],ap=["put","add","delete","clear"],Di=new Map;function Cc(n,e){if(!(n instanceof IDBDatabase&&!(e in n)&&typeof e=="string"))return;if(Di.get(e))return Di.get(e);const t=e.replace(/FromIndex$/,""),r=e!==t,s=ap.includes(t);if(!(t in(r?IDBIndex:IDBObjectStore).prototype)||!(s||op.includes(t)))return;const o=async function(a,...u){const h=this.transaction(a,s?"readwrite":"readonly");let d=h.store;
240return r&&(d=d.index(u.shift())),(await Promise.all([d[t](...u),s&&h.done]))[0]};return Di.set(e,o),o}np(n=>({...n,get:(e,t,r)=>Cc(e,t)||n.get(e,t,r),has:(e,t)=>!!Cc(e,t)||n.has(e,t)}));/**
241 * @license
242 * Copyright 2019 Google LLC
243 *
244 * Licensed under the Apache License, Version 2.0 (the "License");
245 * you may not use this file except in compliance with the License.
246 * You may obtain a copy of the License at
247 *
248 *   http://www.apache.org/licenses/LICENSE-2.0
249 *
250 * Unless required by applicable law or agreed to in writing, software
251 * distributed under the License is distributed on an "AS IS" BASIS,
252 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
253 * See the License for the specific language governing permissions and
254 * limitations under the License.
255 */class cp{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(t=>{if(up(t)){const r=t.getImmediate();return`${r.library}/${r.version}`}else return null}).filter(t=>t).join(" ")}}function up(n){const e=n.getComponent();return(e==null?void 0:e.type)==="VERSION"}const Hi="@firebase/app",bc="0.14.1";/**
256 * @license
257 * Copyright 2019 Google LLC
258 *
259 * Licensed under the Apache License, Version 2.0 (the "License");
260 * you may not use this file except in compliance with the License.
261 * You may obtain a copy of the License at
262 *
263 *   http://www.apache.org/licenses/LICENSE-2.0
264 *
265 * Unless required by applicable law or agreed to in writing, software
266 * distributed under the License is distributed on an "AS IS" BASIS,
267 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
268 * See the License for the specific language governing permissions and
269 * limitations under the License.
270 */const lt=new Eo("@firebase/app"),lp="@firebase/app-compat",hp="@firebase/analytics-compat",dp="@firebase/analytics",fp="@firebase/app-check-compat",pp="@firebase/app-check",mp="@firebase/auth",gp="@firebase/auth-compat",_p="@firebase/database",yp="@firebase/data-connect",Ep="@firebase/database-compat",Tp="@firebase/functions",Ip="@firebase/functions-compat",wp="@firebase/installations",vp="@firebase/installations-compat",Ap="@firebase/messaging",Rp="@firebase/messaging-compat",Sp="@firebase/performance",Pp="@firebase/performance-compat",Cp="@firebase/remote-config",bp="@firebase/remote-config-compat",kp="@firebase/storage",Np="@f
270irebase/storage-compat",Vp="@firebase/firestore",Dp="@firebase/ai",Op="@firebase/firestore-compat",Mp="firebase",Lp="12.1.0";/**
271 * @license
272 * Copyright 2019 Google LLC
273 *
274 * Licensed under the Apache License, Version 2.0 (the "License");
275 * you may not use this file except in compliance with the License.
276 * You may obtain a copy of the License at
277 *
278 *   http://www.apache.org/licenses/LICENSE-2.0
279 *
280 * Unless required by applicable law or agreed to in writing, software
281 * distributed under the License is distributed on an "AS IS" BASIS,
282 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
283 * See the License for the specific language governing permissions and
284 * limitations under the License.
285 */const Wi="[DEFAULT]",xp={[Hi]:"fire-core",[lp]:"fire-core-compat",[dp]:"fire-analytics",[hp]:"fire-analytics-compat",[pp]:"fire-app-check",[fp]:"fire-app-check-compat",[mp]:"fire-auth",[gp]:"fire-auth-compat",[_p]:"fire-rtdb",[yp]:"fire-data-connect",[Ep]:"fire-rtdb-compat",[Tp]:"fire-fn",[Ip]:"fire-fn-compat",[wp]:"fire-iid",[vp]:"fire-iid-compat",[Ap]:"fire-fcm",[Rp]:"fire-fcm-compat",[Sp]:"fire-perf",[Pp]:"fire-perf-compat",[Cp]:"fire-rc",[bp]:"fire-rc-compat",[kp]:"fire-gcs",[Np]:"fire-gcs-compat",[Vp]:"fire-fst",[Op]:"fire-fst-compat",[Dp]:"fire-vertex","fire-js":"fire-js",[Mp]:"fire-js-all"};/**
286 * @license
287 * Copyright 2019 Google LLC
288 *
289 * Licensed under the Apache License, Version 2.0 (the "License");
290 * you may not use this file except in compliance with the License.
291 * You may obtain a copy of the License at
292 *
293 *   http://www.apache.org/licenses/LICENSE-2.0
294 *
295 * Unless required by applicable law or agreed to in writing, software
296 * distributed under the License is distributed on an "AS IS" BASIS,
297 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
298 * See the License for the specific language governing permissions and
299 * limitations under the License.
300 */const ps=new Map,Fp=new Map,Gi=new Map;function kc(n,e){try{n.container.addComponent(e)}catch(t){lt.debug(`Component ${e.name} failed to register with FirebaseApp ${n.name}`,t)}}function Gt(n){const e=n.name;if(Gi.has(e))return lt.debug(`There were multiple attempts to register component ${e}.`),!1;Gi.set(e,n);for(const t of ps.values())kc(t,n);for(const t of Fp.values())kc(t,n);return!0}function Ms(n,e){const t=n.container.getProvider("heartbeat").getImmediate({optional:!0});return t&&t.triggerHeartbeat(),n.container.getProvider(e)}function pe(n){return n==null?!1:n.settings!==void 0}/**
301 * @license
302 * Copyright 2019 Google LLC
303 *
304 * Licensed under the Apache License, Version 2.0 (the "License");
305 * you may not use this file except in compliance with the License.
306 * You may obtain a copy of the License at
307 *
308 *   http://www.apache.org/licenses/LICENSE-2.0
309 *
310 * Unless required by applicable law or agreed to in writing, software
311 * distributed under the License is distributed on an "AS IS" BASIS,
312 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
313 * See the License for the specific language governing permissions and
314 * limitations under the License.
315 */const Up={"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.","invali
315d-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."},St=new yr("app","Firebase",Up);/**
316 * @license
317 * Copyright 2019 Google LLC
318 *
319 * Licensed under the Apache License, Version 2.0 (the "License");
320 * you may not use this file except in compliance with the License.
321 * You may obtain a copy of the License at
322 *
323 *   http://www.apache.org/licenses/LICENSE-2.0
324 *
325 * Unless required by applicable law or agreed to in writing, software
326 * distributed under the License is distributed on an "AS IS" BASIS,
327 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
328 * See the License for the specific language governing permissions and
329 * limitations under the License.
330 */class Bp{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 kt("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 St.create("app-deleted",{appName:this._name})}}/**
331 * @license
332 * Copyright 2019 Google LLC
333 *
334 * Licensed under the Apache License, Version 2.0 (the "License");
335 * you may not use this file except in compliance with the License.
336 * You may obtain a copy of the License at
337 *
338 *   http://www.apache.org/licenses/LICENSE-2.0
339 *
340 * Unless required by applicable law or agreed to in writing, software
341 * distributed under the License is distributed on an "AS IS" BASIS,
342 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
343 * See the License for the specific language governing permissions and
344 * limitations under the License.
345 */const vn=Lp;function qp(n,e={}){let t=n;typeof e!="object"&&(e={name:e});const r={name:Wi,automaticDataCollectionEnabled:!0,...e},s=r.name;if(typeof s!="string"||!s)throw St.create("bad-app-name",{appName:String(s)});if(t||(t=ol()),!t)throw St.create("no-options");const o=ps.get(s);if(o){if(ut(t,o.options)&&ut(r,o.config))return o;throw St.create("duplicate-app",{appName:s})}const a=new Wf(s);for(const h of Gi.values())a.addComponent(h);const u=new Bp(t,r,a);return ps.set(s,u),u}function hl(n=Wi){const e=ps.get(n);if(!e&&n===Wi&&ol())return qp();if(!e)throw St.create("no-app",{appName:n});return e}function He(n,e,t){let r=xp[n]??n;t&&(r+=`-${t}`);const s=r.match(/\s|\//),o=e.match(/\s|\//);if(s||o){const a=[`Unable to register library "${r}" with version "${e}":`];s&&a.push(`library name "${r}" contains illegal characters (whitespace or "/")`),s&&o&&a.push("and"),o&&a.push(`version name "${e}" contains illegal characters (whitespace or "/")`),lt.warn(a.join(" "));return}Gt(new kt(`${r}-version`,()=>({library:r,version:e}),"VERSION"))}/**
346 * @license
347 * Copyright 2021 Google LLC
348 *
349 * Licensed under the Apache License, Version 2.0 (the "License");
350 * you may not use this file except in compliance with the License.
351 * You may obtain a copy of the License at
352 *
353 *   http://www.apache.org/licenses/LICENSE-2.0
354 *
355 * Unless required by applicable law or agreed to in writing, softw
355are
356 * distributed under the License is distributed on an "AS IS" BASIS,
357 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
358 * See the License for the specific language governing permissions and
359 * limitations under the License.
360 */const jp="firebase-heartbeat-database",$p=1,ar="firebase-heartbeat-store";let Oi=null;function dl(){return Oi||(Oi=ip(jp,$p,{upgrade:(n,e)=>{switch(e){case 0:try{n.createObjectStore(ar)}catch(t){console.warn(t)}}}}).catch(n=>{throw St.create("idb-open",{originalErrorMessage:n.message})})),Oi}async function zp(n){try{const t=(await dl()).transaction(ar),r=await t.objectStore(ar).get(fl(n));return await t.done,r}catch(e){if(e instanceof Ze)lt.warn(e.message);else{const t=St.create("idb-get",{originalErrorMessage:e==null?void 0:e.message});lt.warn(t.message)}}}async function Nc(n,e){try{const r=(await dl()).transaction(ar,"readwrite");await r.objectStore(ar).put(e,fl(n)),await r.done}catch(t){if(t instanceof Ze)lt.warn(t.message);else{const r=St.create("idb-set",{originalErrorMessage:t==null?void 0:t.message});lt.warn(r.message)}}}function fl(n){return`${n.name}!${n.options.appId}`}/**
361 * @license
362 * Copyright 2021 Google LLC
363 *
364 * Licensed under the Apache License, Version 2.0 (the "License");
365 * you may not use this file except in compliance with the License.
366 * You may obtain a copy of the License at
367 *
368 *   http://www.apache.org/licenses/LICENSE-2.0
369 *
370 * Unless required by applicable law or agreed to in writing, software
371 * distributed under the License is distributed on an "AS IS" BASIS,
372 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
373 * See the License for the specific language governing permissions and
374 * limitations under the License.
375 */const Hp=1024,Wp=30;class Gp{constructor(e){this.container=e,this._heartbeatsCache=null;const t=this.container.getProvider("app").getImmediate();this._storage=new Qp(t),this._heartbeatsCachePromise=this._storage.read().then(r=>(this._heartbeatsCache=r,r))}async triggerHeartbeat(){var e,t;try{const s=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),o=Vc();if(((e=this._heartbeatsCache)==null?void 0:e.heartbeats)==null&&(this._heartbeatsCache=await this._heartbeatsCachePromise,((t=this._heartbeatsCache)==null?void 0:t.heartbeats)==null)||this._heartbeatsCache.lastSentHeartbeatDate===o||this._heartbeatsCache.heartbeats.some(a=>a.date===o))return;if(this._heartbeatsCache.heartbeats.push({date:o,agent:s}),this._heartbeatsCache.heartbeats.length>Wp){const a=Jp(this._heartbeatsCache.heartbeats);this._heartbeatsCache.heartbeats.splice(a,1)}return this._storage.overwrite(this._heartbeatsCache)}catch(r){lt.warn(r)}}async getHeartbeatsHeader(){var e;try{if(this._heartbeatsCache===null&&await this._heartbeatsCachePromise,((e=this._heartbeatsCache)==null?void 0:e.heartbeats)==null||this._heartbeatsCache.heartbeats.length===0)return"";const t=Vc(),{heartbeatsToSend:r,unsentEntries:s}=Kp(this._heartbeatsCache.heartbeats),o=fs(JSON.stringify({version:2,heartbeats:r}));return this._heartbeatsCache.lastSentHeartbeatDate=t,s.length>0?(this._heartbeatsCache.heartbeats=s,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),o}catch(t){return lt.warn(t),""}}}function Vc(){return new Date().toISOString().substring(0,10)}function Kp(n,e=Hp){const t=[];let r=n.slice();for(const s of n){const o=t.find(a=>a.agent===s.agent);if(o){if(o.dates.push(s.date),Dc(t)>e){o.dates.pop();break}}else if(t.push({agent:s.agent,dates:[s.date]}),Dc(t)>e){t.pop();break}r=r.slice(1)}return{heartbeatsToSend:t,unsentEntries:r}}class Qp{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return kf()?Nf().then(()=>!0).catch(()=>!1):!1}async read(){if(await this._canUseIndexedDBPromise){const t=await zp(this.app);return t!=null&&t.heartbeats?t:{heartbeats:[]}}else return{heartbeats:[]}}async overwrite(e){if(await this._canUseIndexedDBPromise){const r=await this.read();return Nc(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??r.lastSentHeartbeatDate,heartbeats:e.heartbeats})}else return}async add(e){if(await this._canUseIndexedDBPromise){const r=await this.read();return Nc(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??r.lastSentHeartbeatDate,heartbeats:[...r.heartbeats,...e.heartbeats]})}else return}}function Dc(n){return fs(JSON.stringify({version:2,heartbeats:n})).length}function Jp(n){if(n.length===0)return-1;let e=0,t=n[0].date;for(let r=1;r<n.length;r++)n[r].date<t&&(t=n[r].date,e=r);return e}/**
376 * @license
377 * Copyright 2019 Google LLC
378 *
379 * Licensed under the Apache License, Version 2.0 (the "License");
380 * you may not use this file except in compliance with the License.
381 * You may obtain a copy of the License at
382 *
383 *   http://www.apache.org/licenses/LICENSE-2.0
384 *
385 * Unless required by applicable law or agreed to in writing, software
386 * distributed under the License is distributed on an "AS IS" BASIS,
387 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
388 * See the License for the specific language governing permissions and
389 * limitations under the License.
390 */function Yp(n){Gt(new kt("platform-logger",e=>new cp(e),"PRIVATE")),Gt(new kt("heartbeat",e=>new Gp(e),"PRIVATE")),He(Hi,bc,n),He(Hi,bc,"esm2020"),He("fire-js","")}Yp("");var Oc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/** @license
391Copyright The Closure Library Authors.
392SPDX-License-Identifier: Apache-2.0
393*/var Pt,pl;(function(){var n;/** @license
394
395 Copyright The Closure Library Authors.
396 SPDX-License-Identifier: Apache-2.0
397*/function e(w,m){function y(){}y.prototype=m.prototype,w.D=m.prototype,w.prototype=new y,w.prototype.constructor=w,w.C=function(T,I,A){for(var g=Array(arguments.length-2),nt=2;nt<arguments.length;nt++)g[nt-2]=arguments[nt];return m.prototype[I].apply(T,g)}}function t(){this.blockSize=-1}function r(){this.blockSize=-1,this.blockSize=64,this.g=Array(4),this.B=Array(this.blockSize),this.o=this.h=0,this.s()}e(r,t),r.prototype.s=function(){this.g[0]=1732584193,this.g[1]=4023233417,this.g[2]=2562383102,this.g[3]=271733878,this.o=this.h=0};function s(w,m,y){y||(y=0);var T=Array(16);if(typeof m=="string")for(var I=0;16>I;++I)T[I]=m.charCodeAt(y++)|m.charCodeAt(y++)<<8|m.charCodeAt(y++)<<16|m.charCodeAt(y++)<<24;else for(I=0;16>I;++I)T[I]=m[y++]|m[y++]<<8|m[y++]<<16|m[y++]<<24;m=w.g[0],y=w.g[1],I=w.g[2];var A=w.g[3],g=m+(A^y&(I^A))+T[0]+3614090360&4294967295;m=y+(g<<7&4294967295|g>>>25),g=A+(I^m&(y^I))+T[1]+3905402710&4294967295,A=m+(g<<12&4294967295|g>>>20),g=I+(y^A&(m^y))+T[2]+606105819&4294967295,I=A+(g<<17&4294967295|g>>>15),g=y+(m^I&(A^m))+T[3]+3250441966&4294967295,y=I+(g<<22&4294967295|g>>>10),g=m+(A^y&(I^A))+T[4]+4118548399&4294967295,m=y+(g<<7&4294967295|g>>>25),g=A+(I^m&(y^I))+T[5]+1200080426&4294967295,A=m+(g<<12&4294967295|g>>>20),g=I+(y^A&(m^y))+T[6]+2821735955&4294967295,I=A+(g<<17&4294967295|g>>>15),g=y+(m^I&(A^m))+T[7]+4249261313&4294967295,y=I+(g<<22&4294967295|g>>>10),g=m+(A^y&(I^A))+T[8]+1770035416&4294967295,m=y+(g<<7&4294967295|g>>>25),g=A+(I^m&(y^I))+T[9]+2336552879&4294967295,A=m+(g<<12&4294967295|g>>>20),g=I+(y^A&(m^y))+T[10]+4294925233&4294967295,I=A+(g<<17&4294967295|g>>>15),g=y+(m^I&(A^m))+T[11]+2304563134&4294967295,y=I+(g<<22&4294967295|g>>>10),g=m+(A^y&(I^A))+T[12]+1804603682&4294967295,m=y+(g<<7&4294967295|g>>>25),g=A+(I^m&(y^I))+T[13]+4254626195&4294967295,A=m+(g<<12&4294967295|g>>>20),g=I+(y^A&(m^y))+T[14]+2792965006&4294967295,I=A+(g<<17&4294967295|g>>>15),g=y+(m^I&(A^m))+T[15]+1236535329&4294967295,y=I+(g<<22&4294967295|g>>>10),g=m+(I^A&(y^I))+T[1]+4129170786&4294967295,m=y+(g<<5&4294967295|g>>>27),g=A+(y^I&(m^y))+T[6]+3225465664&4294967295,A=m+(g<<9&4294967295|g>>>23),g=I+(m^y&(A^m))+T[11]+643717713&4294967295,I=A+(g<<14&4294967295|g>>>18),g=y+(A^m&(I^A))+T[0]+3921069994&4294967295,y=I+(g<<20&4294967295|g>>>12),g=m+(I^A&(y^I))+T[5]+3593408605&4294967295,m=y+(g<<5&4294967295|g>>>27),g=A+(y^I&(m^y))+T[10]+38016083&4294967295,A=m+(g<<9&4294967295|g>>>23),g=I+(m^y&(A^m))+T[15]+3634488961&4294967295,I=A+(g<<14&4294967295|g>>>18),g=y+(A^m&(I^A))+T[4]+3889429448&4294967295,y=I+(g<<20&4294967295|g>>>12),g=m+(I^A&(y^I))+T[9]+568446438&4294967295,m=y+(g<<5&4294967295|g>>>27),g=A+(y^I&(m^y))+T[14]+3275163606&4294967295,A=m+(g<<9&4294967295|g>>>23),g=I+(m^y&(A^m))+T[3]+4107603335&4294967295,I=A+(g<<14&4294967295|g>>>18),g=y+(A^m&(I^A))+T[8]+1163531501&4294967295,y=I+(g<<20&4294967295|g>>>12),g=m+(I^A&(y^I))+T[13]+2850285829&4294967295,m=y+(g<<5&4294967295|g>>>27),g=A+(y^I&(m^y))+T[2]+4243563512&4294967295,A=m+(g<<9&4294967295|g>>>23),g=I+(m^y&(A^m))+T[7]+1735328473&4294967295,I=A+(g<<14&4294967295|g>>>18),g=y+(A^m&(I^A))+T[12]+2368359562&4294967295,y=I+(g<<20&4294967295|g>>>12),g=m+(y^I^A)+T[5]+4294588738&4294967295,m=y+(g<<4&4294967295|g>>>28),g=A+(m^y^I)+T[8]+2272392833&4294967295,A=m+(g<<11&4294967295|g>>>21),g=I+(A^m^y)+T[11]+1839030562&4294967295,I=A+(g<<16&4294967295|g>>>16),g=y+(I^A^m)+T[14]+4259657740&4294967295,y=I+(g<<23&4294967295|g>>>9),g=m+(y^I^A)+T[1]+2763975236&4294967295,m=y+(g<<4&4294967295|g>>>28),g=A+(m^y^I)+T[4]+1272893353&4294967295,A=m+(g<<11&4294967295|g>>>21),g=I+(A^m^y)+T[7]+4139469664&4294967295,I=A+(g<<16&4294967295|g>>>16),g=y+(I^A^m)+T[10]+3200236656&4294967295,y=I+(g<<23&4294967295|g>>>9),g=m+(y^I^A)+T[13]+681279174&4294967295,m=y+(g<<4&4294967295|g>>>28),g=A+(m^y^I)+T[0]+3936430074&4294967295,A=m+(g<<11&4294967295|g>>>21),g=I+(A^m^y)+T[3]+3572445317&4294967295,I=A+(g<<16&4294967295|g>>>16),g=y+(I^A^m)+T[6]+76029189&4294967295,y=I+(g<<23&4294967295|g>>>9),g=m+(y^I^A)+T[9]+3654602809&4294967295,m=y+(g<<4&4294967295|g>>>28),g=A+(m^y^I)+T[12]+3873151461&4294967295,A=m+(g<<11&4294967295|g>>>21),g=I+(A^m^y)+T[15]+530742520&4294967295,I=A+(g<<16&4294967295|g>>>16),g=y+(I^A^m)+T[2]+3299628645&4294967295,y=I+(g<<23&4294967295|g>>>9),g=m+(I^(y|~A))+T[0]+4096336452&4294967295,m=y+(g<<6&4294967295|g>>>26),g=A+(y^(m|~I))+T[7]+1126891415&4294967295,A=m+(g<<10&4294967295|g>>>22),g=I+(m^(A|~y))+T[14]+2878612391&4294967295,I=A+(g<<15&4294967295|g>>>17),g=y+(A^(I|~m))+T[5]+4237533241&4294967295,y=I+(g<<21&4294967295|g>>>11),g=m+(I^(y|~A))+T[12]+1700485571&4294967295,m=y+(g<<6&4294967295|g>>>26),g=A+(y^(m|~I))+T[3]+2399980690&4294967295,A=m+(g<<10&4294967295|g>>>22),g=I+(m^(A|~y))+T[10]+4293915773&4294967295,I=A+(g<<15&4294967295|g>>>17),g=y+(A^(I|~m))+T[1]+2240044497&4294967295,y=I+(g<<21&4294967295|g>>>11),g=m+(I^(y|~A))+T[8]+1873313359&4294967295,m=y+(g<<6&4294967295|g>>>26),g=A+(y^(m|~I))+T[15]+4264355552&4294967295,A=m+(g<<10&4294967295|g>>>22),g=I+(m^(A|~y))+T[6]+2734768916&4294967295,I=A+(g<<15&4294967295|g>>>17),g=y+(A^(I|~m))+T[13]+1309151649&4294967295,y=I+(g<<21&4294967295|g>>>11),g=m+(I^(y|~A))+T[4]+4149444226&4294967295,m=y+(g<<6&4294967295|g>>>26),g=A+(y^(m|~I))+T[11]+3174756917&4294967295,A=m+(g<<10&4294967295|g>>>22),g=I+(m^(A|~y))+T[2]+718787259&4294967295,I=A+(g<<15&4294967295|g>>>17),g=y+(A^(I|~m))+T[9]+3951481745&4294967295,w.g[0]=w.g[0]+m&4294967295,w.g[1]=w.g[1]+(I+(g<<21&4294967295|g>>>11))&4294967295,w.g[2]=w.g[2]+I&4294967295,w.g[3]=w.g[3]+A&4294967295}r.prototype.u=function(w,m){m===void 0&&(m=w.length);for(var y=m-this.blockSize,T=this.B,I=this.h,A=0;A<m;){if(I==0)for(;A<=y;)s(this,w,A),A+=this.blockSize;if(typeof w=="string"){for(;A<m;)if(T[I++]=w.charCodeAt(A++),I==this.blockSize){s(this,T),I=0;break}}else for(;A<m;)if(T[I++]=w[A++],I==this.blockSize){s(this,T),I=0;break}}this.h=I,this.o+=m},r.prototype.v=function(){var w=Array((56>this.h?this.blockSize:2*this.blockSize)-this.h);w[0]=128;for(var m=1;m<w.length-8;++m)w[m]=0;var y=8*this.o;for(m=w.length-8;m<w.length;++m)w[m]=y&255,y/=256;for(this.u(w),w=Array(16),m=y=0;4>m;++m)for(var T=0;32>T;T+=8)w[y++]=this.g[m]>>>T&255;return w};function o(w,m){var y=u;return Object.prototype.hasOwnProperty.call(y,w)?y[w]:y[w]=m(w)}function a(w,m){this.h=m;for(var y=[],T=!0,I=w.length-1;0<=I;I--){var A=w[I]|0;T&&A==m||(y[I]=A,T=!1)}this.g=y}var u={};function h(w){return-128<=w&&128>w?o(w,function(m){return new a([m|0],0>m?-1:0)}):new a([w|0],0>w?-1:0)}
vendor: 42,862 bytes, lines 397-412
397function d(w){if(isNaN(w)||!isFinite(w))return _;if(0>w)return N(d(-w));for(var m=[],y=1,T=0;w>=y;T++)m[T]=w/y|0,y*=4294967296;return new a(m,0)}function p(w,m){if(w.length==0)throw Error("number format error: empty string");if(m=m||10,2>m||36<m)throw Error("radix out of range: "+m);if(w.charAt(0)=="-")return N(p(w.substring(1),m));if(0<=w.indexOf("-"))throw Error('number format error: interior "-" character');for(var y=d(Math.pow(m,8)),T=_,I=0;I<w.length;I+=8){var A=Math.min(8,w.length-I),g=parseInt(w.substring(I,I+A),m);8>A?(A=d(Math.pow(m,A)),T=T.j(A).add(d(g))):(T=T.j(y),T=T.add(d(g)))}return T}var _=h(0),E=h(1),S=h(16777216);n=a.prototype,n.m=function(){if(D(this))return-N(this).m();for(var w=0,m=1,y=0;y<this.g.length;y++){var T=this.i(y);w+=(0<=T?T:4294967296+T)*m,m*=4294967296}return w},n.toString=function(w){if(w=w||10,2>w||36<w)throw Error("radix out of range: "+w);if(b(this))return"0";if(D(this))return"-"+N(this).toString(w);for(var m=d(Math.pow(w,6)),y=this,T="";;){var I=se(y,m).g;y=q(y,I.j(m));var A=((0<y.g.length?y.g[0]:y.h)>>>0).toString(w);if(y=I,b(y))return A+T;for(;6>A.length;)A="0"+A;T=A+T}},n.i=function(w){return 0>w?0:w<this.g.length?this.g[w]:this.h};function b(w){if(w.h!=0)return!1;for(var m=0;m<w.g.length;m++)if(w.g[m]!=0)return!1;return!0}function D(w){return w.h==-1}n.l=function(w){return w=q(this,w),D(w)?-1:b(w)?0:1};function N(w){for(var m=w.g.length,y=[],T=0;T<m;T++)y[T]=~w.g[T];return new a(y,~w.h).add(E)}n.abs=function(){return D(this)?N(this):this},n.add=function(w){for(var m=Math.max(this.g.length,w.g.length),y=[],T=0,I=0;I<=m;I++){var A=T+(this.i(I)&65535)+(w.i(I)&65535),g=(A>>>16)+(this.i(I)>>>16)+(w.i(I)>>>16);T=g>>>16,A&=65535,g&=65535,y[I]=g<<16|A}return new a(y,y[y.length-1]&-2147483648?-1:0)};function q(w,m){return w.add(N(m))}n.j=function(w){if(b(this)||b(w))return _;if(D(this))return D(w)?N(this).j(N(w)):N(N(this).j(w));if(D(w))return N(this.j(N(w)));if(0>this.l(S)&&0>w.l(S))return d(this.m()*w.m());for(var m=this.g.length+w.g.length,y=[],T=0;T<2*m;T++)y[T]=0;for(T=0;T<this.g.length;T++)for(var I=0;I<w.g.length;I++){var A=this.i(T)>>>16,g=this.i(T)&65535,nt=w.i(I)>>>16,Vn=w.i(I)&65535;y[2*T+2*I]+=g*Vn,B(y,2*T+2*I),y[2*T+2*I+1]+=A*Vn,B(y,2*T+2*I+1),y[2*T+2*I+1]+=g*nt,B(y,2*T+2*I+1),y[2*T+2*I+2]+=A*nt,B(y,2*T+2*I+2)}for(T=0;T<m;T++)y[T]=y[2*T+1]<<16|y[2*T];for(T=m;T<2*m;T++)y[T]=0;return new a(y,0)};function B(w,m){for(;(w[m]&65535)!=w[m];)w[m+1]+=w[m]>>>16,w[m]&=65535,m++}function W(w,m){this.g=w,this.h=m}function se(w,m){if(b(m))throw Error("division by zero");if(b(w))return new W(_,_);if(D(w))return m=se(N(w),m),new W(N(m.g),N(m.h));if(D(m))return m=se(w,N(m)),new W(N(m.g),m.h);if(30<w.g.length){if(D(w)||D(m))throw Error("slowDivide_ only works with positive integers.");for(var y=E,T=m;0>=T.l(w);)y=tt(y),T=tt(T);var I=he(y,1),A=he(T,1);for(T=he(T,2),y=he(y,2);!b(T);){var g=A.add(T);0>=g.l(w)&&(I=I.add(y),A=g),T=he(T,1),y=he(y,1)}return m=q(w,I.j(m)),new W(I,m)}for(I=_;0<=w.l(m);){for(y=Math.max(1,Math.floor(w.m()/m.m())),T=Math.ceil(Math.log(y)/Math.LN2),T=48>=T?1:Math.pow(2,T-48),A=d(y),g=A.j(m);D(g)||0<g.l(w);)y-=T,A=d(y),g=A.j(m);b(A)&&(A=E),I=I.add(A),w=q(w,g)}return new W(I,w)}n.A=function(w){return se(this,w).h},n.and=function(w){for(var m=Math.max(this.g.length,w.g.length),y=[],T=0;T<m;T++)y[T]=this.i(T)&w.i(T);return new a(y,this.h&w.h)},n.or=function(w){for(var m=Math.max(this.g.length,w.g.length),y=[],T=0;T<m;T++)y[T]=this.i(T)|w.i(T);return new a(y,this.h|w.h)},n.xor=function(w){for(var m=Math.max(this.g.length,w.g.length),y=[],T=0;T<m;T++)y[T]=this.i(T)^w.i(T);return new a(y,this.h^w.h)};function tt(w){for(var m=w.g.length+1,y=[],T=0;T<m;T++)y[T]=w.i(T)<<1|w.i(T-1)>>>31;return new a(y,w.h)}function he(w,m){var y=m>>5;m%=32;for(var T=w.g.length-y,I=[],A=0;A<T;A++)I[A]=0<m?w.i(A+y)>>>m|w.i(A+y+1)<<32-m:w.i(A+y);return new a(I,w.h)}r.prototype.digest=r.prototype.v,r.prototype.reset=r.prototype.s,r.prototype.update=r.prototype.u,pl=r,a.prototype.add=a.prototype.add,a.prototype.multiply=a.prototype.j,a.prototype.modulo=a.prototype.A,a.prototype.compare=a.prototype.l,a.prototype.toNumber=a.prototype.m,a.prototype.toString=a.prototype.toString,a.prototype.getBits=a.prototype.i,a.fromNumber=d,a.fromString=p,Pt=a}).apply(typeof Oc<"u"?Oc:typeof self<"u"?self:typeof window<"u"?window:{});var Jr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/** @license
398Copyright The Closure Library Authors.
399SPDX-License-Identifier: Apache-2.0
400*/var ml,Yn,gl,ns,Ki,_l,yl,El;(function(){var n,e=typeof Object.defineProperties=="function"?Object.defineProperty:function(i,c,l){return i==Array.prototype||i==Object.prototype||(i[c]=l.value),i};function t(i){i=[typeof globalThis=="object"&&globalThis,i,typeof window=="object"&&window,typeof self=="object"&&self,typeof Jr=="object"&&Jr];for(var c=0;c<i.length;++c){var l=i[c];if(l&&l.Math==Math)return l}throw Error("Cannot find global object")}var r=t(this);function s(i,c){if(c)e:{var l=r;i=i.split(".");for(var f=0;f<i.length-1;f++){var v=i[f];if(!(v in l))break e;l=l[v]}i=i[i.length-1],f=l[i],c=c(f),c!=f&&c!=null&&e(l,i,{configurable:!0,writable:!0,value:c})}}function o(i,c){i instanceof String&&(i+="");var l=0,f=!1,v={next:function(){if(!f&&l<i.length){var R=l++;return{value:c(R,i[R]),done:!1}}return f=!0,{done:!0,value:void 0}}};return v[Symbol.iterator]=function(){return v},v}s("Array.prototype.values",function(i){return i||function(){return o(this,function(c,l){return l})}});/** @license
401
402 Copyright The Closure Library Authors.
403 SPDX-License-Identifier: Apache-2.0
404*/var a=a||{},u=this||self;function h(i){var c=typeof i;return c=c!="object"?c:i?Array.isArray(i)?"array":c:"null",c=="array"||c=="object"&&typeof i.length=="number"}function d(i){var c=typeof i;return c=="object"&&i!=null||c=="function"}function p(i,c,l){return i.call.apply(i.bind,arguments)}function _(i,c,l){if(!i)throw Error();if(2<arguments.length){var f=Array.prototype.slice.call(arguments,2);return function(){var v=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(v,f),i.apply(c,v)}}return function(){return i.apply(c,arguments)}}function E(i,c,l){return E=Function.prototype.bind&&Function.prototype.bind.toString().indexOf("native code")!=-1?p:_,E.apply(null,arguments)}function S(i,c){var l=Array.prototype.slice.call(arguments,1);return function(){var f=l.slice();return f.push.apply(f,arguments),i.apply(this,f)}}function b(i,c){function l(){}l.prototype=c.prototype,i.aa=c.prototype,i.prototype=new l,i.prototype.constructor=i,i.Qb=function(f,v,R){for(var k=Array(arguments.length-2),J=2;J<arguments.length;J++)k[J-2]=arguments[J];return c.prototype[v].apply(f,k)}}function D(i){const c=i.length;if(0<c){const l=Array(c);for(let f=0;f<c;f++)l[f]=i[f];return l}return[]}function N(i,c){for(let l=1;l<arguments.length;l++){const f=arguments[l];if(h(f)){const v=i.length||0,R=f.length||0;i.length=v+R;for(let k=0;k<R;k++)i[v+k]=f[k]}else i.push(f)}}class q{constructor(c,l){this.i=c,this.j=l,this.h=0,this.g=null}get(){let c;return 0<this.h?(this.h--,c=this.g,this.g=c.next,c.next=null):c=this.i(),c}}function B(i){return/^[\s\xa0]*$/.test(i)}function W(){var i=u.navigator;return i&&(i=i.userAgent)?i:""}function se(i){return se[" "](i),i}se[" "]=function(){};var tt=W().indexOf("Gecko")!=-1&&!(W().toLowerCase().indexOf("webkit")!=-1&&W().indexOf("Edge")==-1)&&!(W().indexOf("Trident")!=-1||W().indexOf("MSIE")!=-1)&&W().indexOf("Edge")==-1;function he(i,c,l){for(const f in i)c.call(l,i[f],f,i)}function w(i,c){for(const l in i)c.call(void 0,i[l],l,i)}function m(i){const c={};for(const l in i)c[l]=i[l];return c}const y="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function T(i,c){let l,f;for(let v=1;v<arguments.length;v++){f=arguments[v];for(l in f)i[l]=f[l];for(let R=0;R<y.length;R++)l=y[R],Object.prototype.hasOwnProperty.call(f,l)&&(i[l]=f[l])}}function I(i){var c=1;i=i.split(":");const l=[];for(;0<c&&i.length;)l.push(i.shift()),c--;return i.length&&l.push(i.join(":")),l}function A(i){u.setTimeout(()=>{throw i},0)}function g(){var i=oi;let c=null;return i.g&&(c=i.g,i.g=i.g.next,i.g||(i.h=null),c.next=null),c}class nt{constructor(){this.h=this.g=null}add(c,l){const f=Vn.get();f.set(c,l),this.h?this.h.next=f:this.g=f,this.h=f}}var Vn=new q(()=>new bd,i=>i.reset());class bd{constructor(){this.next=this.g=this.h=null}set(c,l){this.h=c,this.g=l,this.next=null}reset(){this.next=this.g=this.h=null}}let Dn,On=!1,oi=new nt,va=()=>{const i=u.Promise.resolve(void 0);Dn=()=>{i.then(kd)}};var kd=()=>{for(var i;i=g();){try{i.h.call(i.g)}catch(l){A(l)}var c=Vn;c.j(i),100>c.h&&(c.h++,i.next=c.g,c.g=i)}On=!1};function mt(){this.s=this.s,this.C=this.C}mt.prototype.s=!1,mt.prototype.ma=function(){this.s||(this.s=!0,this.N())},mt.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()};function _e(i,c){this.type=i,this.g=this.target=c,this.defaultPrevented=!1}_e.prototype.h=function(){this.defaultPrevented=!0};var Nd=function(){if(!u.addEventListener||!Object.defineProperty)return!1;var i=!1,c=Object.defineProperty({},"passive",{get:function(){i=!0}});try{const l=()=>{};u.addEventListener("test",l,c),u.removeEventListener("test",l,c)}catch{}return i}();function Mn(i,c){if(_e.call(this,i?i.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,i){var l=this.type=i.type,f=i.changedTouches&&i.changedTouches.length?i.changedTouches[0]:null;if(this.target=i.target||i.srcElement,this.g=c,c=i.relatedTarget){if(tt){e:{try{se(c.nodeName);var v=!0;break e}catch{}v=!1}v||(c=null)}}else l=="mouseover"?c=i.fromElement:l=="mouseout"&&(c=i.toElement);this.relatedTarget=c,f?(this.clientX=f.clientX!==void 0?f.clientX:f.pageX,this.clientY=f.clientY!==void 0?f.clientY:f.pageY,this.screenX=f.screenX||0,this.screenY=f.screenY||0):(this.clientX=i.clientX!==void 0?i.clientX:i.pageX,this.clientY=i.clientY!==void 0?i.clientY:i.pageY,this.screenX=i.screenX||0,this.screenY=i.screenY||0),this.button=i.button,this.key=i.key||"",this.ctrlKey=i.ctrlKey,this.altKey=i.altKey,this.shiftKey=i.shiftKey,this.metaKey=i.metaKey,this.pointerId=i.pointerId||0,this.pointerType=typeof i.pointerType=="string"?i.pointerType:Vd[i.pointerType]||"",this.state=i.state,this.i=i,i.defaultPrevented&&Mn.aa.h.call(this)}}b(Mn,_e);var Vd={2:"touch",3:"pen",4:"mouse"};Mn.prototype.h=function(){Mn.aa.h.call(this);var i=this.i;i.preventDefault?i.preventDefault():i.returnValue=!1};var Nr="closure_listenable_"+(1e6*Math.random()|0),Dd=0;function Od(i,c,l,f,v){this.listener=i,this.proxy=null,this.src=c,this.type=l,this.capture=!!f,this.ha=v,this.key=++Dd,this.da=this.fa=!1}function Vr(i){i.da=!0,i.listener=null,i.proxy=null,i.src=null,i.ha=null}function Dr(i){this.src=i,this.g={},this.h=0}Dr.prototype.add=function(i,c,l,f,v){var R=i.toString();i=this.g[R],i||(i=this.g[R]=[],this.h++);var k=ci(i,c,f,v);return-1<k?(c=i[k],l||(c.fa=!1)):(c=new Od(c,this.src,R,!!f,v),c.fa=l,i.push(c)),c};function ai(i,c){var l=c.type;if(l in i.g){var f=i.g[l],v=Array.prototype.indexOf.call(f,c,void 0),R;(R=0<=v)&&Array.prototype.splice.call(f,v,1),R&&(Vr(c),i.g[l].length==0&&(delete i.g[l],i.h--))}}function ci(i,c,l,f){for(var v=0;v<i.length;++v){var R=i[v];if(!R.da&&R.listener==c&&R.capture==!!l&&R.ha==f)return v}return-1}var ui="closure_lm_"+(1e6*Math.random()|0),li={};function Aa(i,c,l,f,v){if(Array.isArray(c)){for(var R=0;R<c.length;R++)Aa(i,c[R],l,f,v);return null}return l=Pa(l),i&&i[Nr]?i.K(c,l,d(f)?!!f.capture:!1,v):Md(i,c,l,!1,f,v)}function Md(i,c,l,f,v,R){if(!c)throw Error("Invalid event type");var k=d(v)?!!v.capture:!!v,J=di(i);if(J||(i[ui]=J=new Dr(i)),l=J.add(c,l,f,k,R),l.proxy)return l;if(f=Ld(),l.proxy=f,f.src=i,f.listener=l,i.addEventListener)Nd||(v=k),v===void 0&&(v=!1),i.addEventListener(c.toString(),f,v);else if(i.attachEvent)i.attachEvent(Sa(c.toString()),f);else if(i.addListener&&i.removeListener)i.addListener(f);else throw Error("addEventListener and attachEvent are unavailable.");return l}function Ld(){function i(l){return c.call(i.src,i.listener,l)}const c=xd;return i}function Ra(i,c,l,f,v){if(Array.isArray(c))for(var R=0;R<c.length;R++)Ra(i,c[R],l,f,v);else f=d(f)?!!f.capture:!!f,l=Pa(l),i&&i[Nr]?(i=i.i,c=String(c).toString(),c in i.g&&(R=i.g[c],l=ci(R,l,f,v),-1<l&&(Vr(R[l]),Array.prototype.splice.call(R,l,1),R.length==0&&(delete i.g[c],i.h--)))):i&&(i=di(i))&&(c=i.g[c.toString()],i=-1,c&&(i=ci(c,l,f,v)),(l=-1<i?c[i]:null)&&hi(l))}function hi(i){if(typeof i!="number"&&i&&!i.da){var c=i.src;if(c&&c[Nr])ai(c.i,i);else{var l=i.type,f=i.proxy;c.removeEventListener?c.removeEventListener(l,f,i.capture):c.detachEvent?c.detachEvent(Sa(l),f):c.addListener&&c.removeListener&&c.removeListener(f),(l=di(c))?(ai(l,i),l.h==0&&(l.src=null,c[ui]=null)):Vr(i)}}}function Sa(i){return i in li?li[i]:li[i]="on"+i}function xd(i,c){if(i.da)i=!0;else{c=new Mn(c,this);var l=i.listener,f=i.ha||i.src;i.fa&&hi(i),i=l.call(f,c)}return i}function di(i){return i=i[ui],i instanceof Dr?i:null}var fi="__closure_events_fn_"+(1e9*Math.random()>>>0);function Pa(i){return typeof i=="function"?i:(i[fi]||(i[fi]=function(c){return i.handleEvent(c)}),i[fi])}function ye(){mt.call(this),this.i=new Dr(this),this.M=this,this.F=null}b(ye,mt),ye.prototype[Nr]=!0,ye.prototype.removeEventListener=function(i,c,l,f){Ra(this,i,c,l,f)};function Ae(i,c){var l,f=i.F;if(f)for(l=[];f;f=f.F)l.push(f);if(i=i.M,f=c.type||c,typeof c=="string")c=new _e(c,i);else if(c instanceof _e)c.target=c.target||i;else{var v=c;c=new _e(f,i),T(c,v)}if(v=!0,l)for(var R=l.length-1;0<=R;R--){var k=c.g=l[R];v=Or(k,f,!0,c)&&v}if(k=c.g=i,v=Or(k,f,!0,c)&&v,v=Or(k,f,!1,c)&&v,l)for(R=0;R<l.length;R++)k=c.g=l[R],v=Or(k,f,!1,c)&&v}ye.prototype.N=function(){if(ye.aa.N.call(this),this.i){var i=this.i,c;for(c in i.g){for(var l=i.g[c],f=0;f<l.length;f++)Vr(l[f]);delete i.g[c],i.h--}}this.F=null},ye.prototype.K=function(i,c,l,f){return this.i.add(String(i),c,!1,l,f)},ye.prototype.L=function(i,c,l,f){return this.i.add(String(i),c,!0,l,f)};function Or(i,c,l,f){if(c=i.i.g[String(c)],!c)return!0;c=c.concat();for(var v=!0,R=0;R<c.length;++R){var k=c[R];if(k&&!k.da&&k.capture==l){var J=k.listener,de=k.ha||k.src;k.fa&&ai(i.i,k),v=J.call(de,f)!==!1&&v}}return v&&!f.defaultPrevented}function Ca(i,c,l){if(typeof i=="function")l&&(i=E(i,l));else if(i&&typeof i.handleEvent=="function")i=E(i.handleEvent,i);else throw Error("Invalid listener argument");return 2147483647<Number(c)?-1:u.setTimeout(i,c||0)}function ba(i){i.g=Ca(()=>{i.g=null,i.i&&(i.i=!1,ba(i))},i.l);const c=i.h;i.h=null,i.m.apply(null,c)}class Fd extends mt{constructor(c,l){super(),this.m=c,this.l=l,this.h=null,this.i=!1,this.g=null}j(c){this.h=arguments,this.g?this.i=!0:ba(this)}N(){super.N(),this.g&&(u.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function Ln(i){mt.call(this),this.h=i,this.g={}}b(Ln,mt);var ka=[];function Na(i){he(i.g,function(c,l){this.g.hasOwnProperty(l)&&hi(c)},i),i.g={}}Ln.prototype.N=function(){Ln.aa.N.call(this),Na(this)},Ln.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var pi=u.JSON.stringify,Ud=u.JSON.parse,Bd=class{stringify(i){return u.JSON.stringify(i,void 0)}parse(i){return u.JSON.parse(i,void 0)}};function mi(){}mi.prototype.h=null;function Va(i){return i.h||(i.h=i.i())}function Da(){}var xn={OPEN:"a",kb:"b",Ja:"c",wb:"d"};function gi(){_e.call(this,"d")}b(gi,_e);function _i(){_e.call(this,"c")}b(_i,_e);var Ut={},Oa=null;function Mr(){return Oa=Oa||new ye}Ut.La="serverreachability";function Ma(i){_e.call(this,Ut.La,i)}b(Ma,_e);function Fn(i){const c=Mr();Ae(c,new Ma(c))}Ut.STAT_EVENT="statevent";function La(i,c){_e.call(this,Ut.STAT_EVENT,i),this.stat=c}b(La,_e);function Re(i){const c=Mr();Ae(c,new La(c,i))}Ut.Ma="timingevent";function xa(i,c){_e.call(this,Ut.Ma,i),this.size=c}b(xa,_e);function Un(i,c){if(typeof i!="function")throw Error("Fn must not be null and must be a function");return u.setTimeout(function(){i()},c)}function Bn(){this.g=!0}Bn.prototype.xa=function(){this.g=!1};function qd(i,c,l,f,v,R){i.info(function(){if(i.g)if(R)for(var k="",J=R.split("&"),de=0;de<J.length;de++){var K=J[de].split("=");if(1<K.length){var Ee=K[0];K=K[1];var Te=Ee.split("_");k=2<=Te.length&&Te[1]=="type"?k+(Ee+"="+K+"&"):k+(Ee+"=redacted&")}}else k=null;else k=R;return"XMLHTTP REQ ("+f+") [attempt "+v+"]: "+c+`
405`+l+`
406`+k})}function jd(i,c,l,f,v,R,k){i.info(function(){return"XMLHTTP RESP ("+f+") [ attempt "+v+"]: "+c+`
407`+l+`
408`+R+" "+k})}function rn(i,c,l,f){i.info(function(){return"XMLHTTP TEXT ("+c+"): "+zd(i,l)+(f?" "+f:"")})}function $d(i,c){i.info(function(){return"TIMEOUT: "+c})}Bn.prototype.info=function(){};function zd(i,c){if(!i.g)return c;if(!c)return null;try{var l=JSON.parse(c);if(l){for(i=0;i<l.length;i++)if(Array.isArray(l[i])){var f=l[i];if(!(2>f.length)){var v=f[1];if(Array.isArray(v)&&!(1>v.length)){var R=v[0];if(R!="noop"&&R!="stop"&&R!="close")for(var k=1;k<v.length;k++)v[k]=""}}}}return pi(l)}catch{return c}}var Lr={NO_ERROR:0,gb:1,tb:2,sb:3,nb:4,rb:5,ub:6,Ia:7,TIMEOUT:8,xb:9},Fa={lb:"complete",Hb:"success",Ja:"error",Ia:"abort",zb:"ready",Ab:"readystatechange",TIMEOUT:"timeout",vb:"incrementaldata",yb:"progress",ob:"downloadprogress",Pb:"uploadprogress"},yi;function xr(){}b(xr,mi),xr.prototype.g=function(){return new XMLHttpRequest},xr.prototype.i=function(){return{}},yi=new xr;function gt(i,c,l,f){this.j=i,this.i=c,this.l=l,this.R=f||1,this.U=new Ln(this),this.I=45e3,this.H=null,this.o=!1,this.m=this.A=this.v=this.L=this.F=this.S=this.B=null,this.D=[],this.g=null,this.C=0,this.s=this.u=null,this.X=-1,this.J=!1,this.O=0,this.M=null,this.W=this.K=this.T=this.P=!1,this.h=new Ua}function Ua(){this.i=null,this.g="",this.h=!1}var Ba={},Ei={};function Ti(i,c,l){i.L=1,i.v=qr(rt(c)),i.m=l,i.P=!0,qa(i,null)}function qa(i,c){i.F=Date.now(),Fr(i),i.A=rt(i.v);var l=i.A,f=i.R;Array.isArray(f)||(f=[String(f)]),tc(l.i,"t",f),i.C=0,l=i.j.J,i.h=new Ua,i.g=Ec(i.j,l?c:null,!i.m),0<i.O&&(i.M=new Fd(E(i.Y,i,i.g),i.O)),c=i.U,l=i.g,f=i.ca;var v="readystatechange";Array.isArray(v)||(v&&(ka[0]=v.toString()),v=ka);for(var R=0;R<v.length;R++){var k=Aa(l,v[R],f||c.handleEvent,!1,c.h||c);if(!k)break;c.g[k.key]=k}c=i.H?m(i.H):{},i.m?(i.u||(i.u="POST"),c["Content-Type"]="application/x-www-form-urlencoded",i.g.ea(i.A,i.u,i.m,c)):(i.u="GET",i.g.ea(i.A,i.u,null,c)),Fn(),qd(i.i,i.u,i.A,i.l,i.R,i.m)}gt.prototype.ca=function(i){i=i.target;const c=this.M;c&&st(i)==3?c.j():this.Y(i)},gt.prototype.Y=function(i){try{if(i==this.g)e:{const Te=st(this.g);var c=this.g.Ba();const an=this.g.Z();if(!(3>Te)&&(Te!=3||this.g&&(this.h.h||this.g.oa()||cc(this.g)))){this.J||Te!=4||c==7||(c==8||0>=an?Fn(3):Fn(2)),Ii(this);var l=this.g.Z();this.X=l;t:if(ja(this)){var f=cc(this.g);i="";var v=f.length,R=st(this.g)==4;if(!this.h.i){if(typeof TextDecoder>"u"){Bt(this),qn(this);var k="";break t}this.h.i=new u.TextDecoder}for(c=0;c<v;c++)this.h.h=!0,i+=this.h.i.decode(f[c],{stream:!(R&&c==v-1)});f.length=0,this.h.g+=i,this.C=0,k=this.h.g}else k=this.g.oa();if(this.o=l==200,jd(this.i,this.u,this.A,this.l,this.R,Te,l),this.o){if(this.T&&!this.K){t:{if(this.g){var J,de=this.g;if((J=de.g?de.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!B(J)){var K=J;break t}}K=null}if(l=K)rn(this.i,this.l,l,"Initial handshake response via X-HTTP-Initial-Response"),this.K=!0,wi(this,l);else{this.o=!1,this.s=3,Re(12),Bt(this),qn(this);break e}}if(this.P){l=!0;let Fe;for(;!this.J&&this.C<k.length;)if(Fe=Hd(this,k),Fe==Ei){Te==4&&(this.s=4,Re(14),l=!1),rn(this.i,this.l,null,"[Incomplete Response]");break}else if(Fe==Ba){this.s=4,Re(15),rn(this.i,this.l,k,"[Invalid Chunk]"),l=!1;break}else rn(this.i,this.l,Fe,null),wi(this,Fe);if(ja(this)&&this.C!=0&&(this.h.g=this.h.g.slice(this.C),this.C=0),Te!=4||k.length!=0||this.h.h||(this.s=1,Re(16),l=!1),this.o=this.o&&l,!l)rn(this.i,this.l,k,"[Invalid Chunked Response]"),Bt(this),qn(this);else if(0<k.length&&!this.W){this.W=!0;var Ee=this.j;Ee.g==this&&Ee.ba&&!Ee.M&&(Ee.j.info("Great, no buffering proxy detected. Bytes received: "+k.length),Ci(Ee),Ee.M=!0,Re(11))}}else rn(this.i,this.l,k,null),wi(this,k);Te==4&&Bt(this),this.o&&!this.J&&(Te==4?mc(this.j,this):(this.o=!1,Fr(this)))}else uf(this.g),l==400&&0<k.indexOf("Unknown SID")?(this.s=3,Re(12)):(this.s=0,Re(13)),Bt(this),qn(this)}}}catch{}finally{}};function ja(i){return i.g?i.u=="GET"&&i.L!=2&&i.j.Ca:!1}function Hd(i,c){var l=i.C,f=c.indexOf(`
409`,l);return f==-1?Ei:(l=Number(c.substring(l,f)),isNaN(l)?Ba:(f+=1,f+l>c.length?Ei:(c=c.slice(f,f+l),i.C=f+l,c)))}gt.prototype.cancel=function(){this.J=!0,Bt(this)};function Fr(i){i.S=Date.now()+i.I,$a(i,i.I)}function $a(i,c){if(i.B!=null)throw Error("WatchDog timer not null");i.B=Un(E(i.ba,i),c)}function Ii(i){i.B&&(u.clearTimeout(i.B),i.B=null)}gt.prototype.ba=function(){this.B=null;const i=Date.now();0<=i-this.S?($d(this.i,this.A),this.L!=2&&(Fn(),Re(17)),Bt(this),this.s=2,qn(this)):$a(this,this.S-i)};function qn(i){i.j.G==0||i.J||mc(i.j,i)}function Bt(i){Ii(i);var c=i.M;c&&typeof c.ma=="function"&&c.ma(),i.M=null,Na(i.U),i.g&&(c=i.g,i.g=null,c.abort(),c.ma())}function wi(i,c){try{var l=i.j;if(l.G!=0&&(l.g==i||vi(l.h,i))){if(!i.K&&vi(l.h,i)&&l.G==3){try{var f=l.Da.g.parse(c)}catch{f=null}if(Array.isArray(f)&&f.length==3){var v=f;if(v[0]==0){e:if(!l.u){if(l.g)if(l.g.F+3e3<i.F)Gr(l),Hr(l);else break e;Pi(l),Re(18)}}else l.za=v[1],0<l.za-l.T&&37500>v[2]&&l.F&&l.v==0&&!l.C&&(l.C=Un(E(l.Za,l),6e3));if(1>=Wa(l.h)&&l.ca){try{l.ca()}catch{}l.ca=void 0}}else jt(l,11)}else if((i.K||l.g==i)&&Gr(l),!B(c))for(v=l.Da.g.parse(c),c=0;c<v.length;c++){let K=v[c];if(l.T=K[0],K=K[1],l.G==2)if(K[0]=="c"){l.K=K[1],l.ia=K[2];const Ee=K[3];Ee!=null&&(l.la=Ee,l.j.info("VER="+l.la));const Te=K[4];Te!=null&&(l.Aa=Te,l.j.info("SVER="+l.Aa));const an=K[5];an!=null&&typeof an=="number"&&0<an&&(f=1.5*an,l.L=f,l.j.info("backChannelRequestTimeoutMs_="+f)),f=l;const Fe=i.g;if(Fe){const Qr=Fe.g?Fe.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(Qr){var R=f.h;R.g||Qr.indexOf("spdy")==-1&&Qr.indexOf("quic")==-1&&Qr.indexOf("h2")==-1||(R.j=R.l,R.g=new Set,R.h&&(Ai(R,R.h),R.h=null))}if(f.D){const bi=Fe.g?Fe.g.getResponseHeader("X-HTTP-Session-Id"):null;bi&&(f.ya=bi,X(f.I,f.D,bi))}}l.G=3,l.l&&l.l.ua(),l.ba&&(l.R=Date.now()-i.F,l.j.info("Handshake RTT: "+l.R+"ms")),f=l;var k=i;if(f.qa=yc(f,f.J?f.ia:null,f.W),k.K){Ga(f.h,k);var J=k,de=f.L;de&&(J.I=de),J.B&&(Ii(J),Fr(J)),f.g=k}else fc(f);0<l.i.length&&Wr(l)}else K[0]!="stop"&&K[0]!="close"||jt(l,7);else l.G==3&&(K[0]=="stop"||K[0]=="close"?K[0]=="stop"?jt(l,7):Si(l):K[0]!="noop"&&l.l&&l.l.ta(K),l.v=0)}}Fn(4)}catch{}}var Wd=class{constructor(i,c){this.g=i,this.map=c}};function za(i){this.l=i||10,u.PerformanceNavigationTiming?(i=u.performance.getEntriesByType("navigation"),i=0<i.length&&(i[0].nextHopProtocol=="hq"||i[0].nextHopProtocol=="h2")):i=!!(u.chrome&&u.chrome.loadTimes&&u.chrome.loadTimes()&&u.chrome.loadTimes().wasFetchedViaSpdy),this.j=i?this.l:1,this.g=null,1<this.j&&(this.g=new Set),this.h=null,this.i=[]}function Ha(i){return i.h?!0:i.g?i.g.size>=i.j:!1}function Wa(i){return i.h?1:i.g?i.g.size:0}function vi(i,c){return i.h?i.h==c:i.g?i.g.has(c):!1}function Ai(i,c){i.g?i.g.add(c):i.h=c}function Ga(i,c){i.h&&i.h==c?i.h=null:i.g&&i.g.has(c)&&i.g.delete(c)}za.prototype.cancel=function(){if(this.i=Ka(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&this.g.size!==0){for(const i of this.g.values())i.cancel();this.g.clear()}};function Ka(i){if(i.h!=null)return i.i.concat(i.h.D);if(i.g!=null&&i.g.size!==0){let c=i.i;for(const l of i.g.values())c=c.concat(l.D);return c}return D(i.i)}function Gd(i){if(i.V&&typeof i.V=="function")return i.V();if(typeof Map<"u"&&i instanceof Map||typeof Set<"u"&&i instanceof Set)return Array.from(i.values());if(typeof i=="string")return i.split("");if(h(i)){for(var c=[],l=i.length,f=0;f<l;f++)c.push(i[f]);return c}c=[],l=0;for(f in i)c[l++]=i[f];return c}function Kd(i){if(i.na&&typeof i.na=="function")return i.na();if(!i.V||typeof i.V!="function"){if(typeof Map<"u"&&i instanceof Map)return Array.from(i.keys());if(!(typeof Set<"u"&&i instanceof Set)){if(h(i)||typeof i=="string"){var c=[];i=i.length;for(var l=0;l<i;l++)c.push(l);return c}c=[],l=0;for(const f in i)c[l++]=f;return c}}}function Qa(i,c){if(i.forEach&&typeof i.forEach=="function")i.forEach(c,void 0);else if(h(i)||typeof i=="string")Array.prototype.forEach.call(i,c,void 0);else for(var l=Kd(i),f=Gd(i),v=f.length,R=0;R<v;R++)c.call(void 0,f[R],l&&l[R],i)}var Ja=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function Qd(i,c){if(i){i=i.split("&");for(var l=0;l<i.length;l++){var f=i[l].indexOf("="),v=null;if(0<=f){var R=i[l].substring(0,f);v=i[l].substring(f+1)}else R=i[l];c(R,v?decodeURIComponent(v.replace(/\+/g," ")):"")}}}function qt(i){if(this.g=this.o=this.j="",this.s=null,this.m=this.l="",this.h=!1,i instanceof qt){this.h=i.h,Ur(this,i.j),this.o=i.o,this.g=i.g,Br(this,i.s),this.l=i.l;var c=i.i,l=new zn;l.i=c.i,c.g&&(l.g=new Map(c.g),l.h=c.h),Ya(this,l),this.m=i.m}else i&&(c=String(i).match(Ja))?(this.h=!1,Ur(this,c[1]||"",!0),this.o=jn(c[2]||""),this.g=jn(c[3]||"",!0),Br(this,c[4]),this.l=jn(c[5]||"",!0),Ya(this,c[6]||"",!0),this.m=jn(c[7]||"")):(this.h=!1,this.i=new zn(null,this.h))}qt.prototype.toString=function(){var i=[],c=this.j;c&&i.push($n(c,Xa,!0),":");var l=this.g;return(l||c=="file")&&(i.push("//"),(c=this.o)&&i.push($n(c,Xa,!0),"@"),i.push(encodeURIComponent(String(l)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),l=this.s,l!=null&&i.push(":",String(l))),(l=this.l)&&(this.g&&l.charAt(0)!="/"&&i.push("/"),i.push($n(l,l.charAt(0)=="/"?Xd:Yd,!0))),(l=this.i.toString())&&i.push("?",l),(l=this.m)&&i.push("#",$n(l,ef)),i.join("")};function rt(i){return new qt(i)}function Ur(i,c,l){i.j=l?jn(c,!0):c,i.j&&(i.j=i.j.replace(/:$/,""))}function Br(i,c){if(c){if(c=Number(c),isNaN(c)||0>c)throw Error("Bad port number "+c);i.s=c}else i.s=null}function Ya(i,c,l){c instanceof zn?(i.i=c,tf(i.i,i.h)):(l||(c=$n(c,Zd)),i.i=new zn(c,i.h))}function X(i,c,l){i.i.set(c,l)}function qr(i){return X(i,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)),i}function jn(i,c){return i?c?decodeURI(i.replace(/%25/g,"%2525")):decodeURIComponent(i):""}function $n(i,c,l){return typeof i=="string"?(i=encodeURI(i).replace(c,Jd),l&&(i=i.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),i):null}function Jd(i){return i=i.charCodeAt(0),"%"+(i>>4&15).toString(16)+(i&15).toString(16)}var Xa=/[#\/\?@]/g,Yd=/[#\?:]/g,Xd=/[#\?]/g,Zd=/[#\?@]/g,ef=/#/g;function zn(i,c){this.h=this.g=null,this.i=i||null,this.j=!!c}function _t(i){i.g||(i.g=new Map,i.h=0,i.i&&Qd(i.i,function(c,l){i.add(decodeURIComponent(c.replace(/\+/g," ")),l)}))}n=zn.prototype,n.add=function(i,c){_t(this),this.i=null,i=sn(this,i);var l=this.g.get(i);return l||this.g.set(i,l=[]),l.push(c),this.h+=1,this};function Za(i,c){_t(i),c=sn(i,c),i.g.has(c)&&(i.i=null,i.h-=i.g.get(c).length,i.g.delete(c))}function ec(i,c){return _t(i),c=sn(i,c),i.g.has(c)}n.forEach=function(i,c){_t(this),this.g.forEach(function(l,f){l.forEach(function(v){i.call(c,v,f,this)},this)},this)},n.na=function(){_t(this);const i=Array.from(this.g.values()),c=Array.from(this.g.keys()),l=[];for(let f=0;f<c.length;f++){const v=i[f];for(let R=0;R<v.length;R++)l.push(c[f])}return l},n.V=function(i){_t(this);let c=[];if(typeof i=="string")ec(this,i)&&(c=c.concat(this.g.get(sn(this,i))));else{i=Array.from(this.g.values());for(let l=0;l<i.length;l++)c=c.concat(i[l])}return c},n.set=function(i,c){return _t(this),this.i=null,i=sn(this,i),ec(this,i)&&(this.h-=this.g.get(i).length),this.g.set(i,[c]),this.h+=1,this},n.get=function(i,c){return i?(i=this.V(i),0<i.length?String(i[0]):c):c};function tc(i,c,l){Za(i,c),0<l.length&&(i.i=null,i.g.set(sn(i,c),D(l)),i.h+=l.length)}n.toString=function(){if(this.i)return this.i;if(!this.g)return"";const i=[],c=Array.from(this.g.keys());for(var l=0;l<c.length;l++){var f=c[l];const R=encodeURIComponent(String(f)),k=this.V(f);for(f=0;f<k.length;f++){var v=R;k[f]!==""&&(v+="="+encodeURIComponent(String(k[f]))),i.push(v)}}return this.i=i.join("&")};function sn(i,c){return c=String(c),i.j&&(c=c.toLowerCase()),c}function tf(i,c){c&&!i.j&&(_t(i),i.i=null,i.g.forEach(function(l,f){var v=f.toLowerCase();f!=v&&(Za(this,f),tc(this,v,l))},i)),i.j=c}function nf(i,c){const l=new Bn;if(u.Image){const f=new Image;f.onload=S(yt,l,"TestLoadImage: loaded",!0,c,f),f.onerror=S(yt,l,"TestLoadImage: error",!1,c,f),f.onabort=S(yt,l,"TestLoadImage: abort",!1,c,f),f.ontimeout=S(yt,l,"TestLoadImage: timeout",!1,c,f),u.setTimeout(function(){f.ontimeout&&f.ontimeout()},1e4),f.src=i}else c(!1)}function rf(i,c){const l=new Bn,f=new AbortController,v=setTimeout(()=>{f.abort(),yt(l,"TestPingServer: timeout",!1,c)},1e4);fetch(i,{signal:f.signal}).then(R=>{clearTimeout(v),R.ok?yt(l,"TestPingServer: ok",!0,c):yt(l,"TestPingServer: server error",!1,c)}).catch(()=>{clearTimeout(v),yt(l,"TestPingServer: error",!1,c)})}function yt(i,c,l,f,v){try{v&&(v.onload=null,v.onerror=null,v.onabort=null,v.ontimeout=null),f(l)}catch{}}function sf(){this.g=new Bd}function of(i,c,l){const f=l||"";try{Qa(i,function(v,R){let k=v;d(v)&&(k=pi(v)),c.push(f+R+"="+encodeURIComponent(k))})}catch(v){throw c.push(f+"type="+encodeURIComponent("_badmap")),v}}function jr(i){this.l=i.Ub||null,this.j=i.eb||!1}b(jr,mi),jr.prototype.g=function(){return new $r(this.l,this.j)},jr.prototype.i=function(i){return function(){return i}}({});function $r(i,c){ye.call(this),this.D=i,this.o=c,this.m=void 0,this.status=this.readyState=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.u=new Headers,this.h=null,this.B="GET",this.A="",this.g=!1,this.v=this.j=this.l=null}b($r,ye),n=$r.prototype,n.open=function(i,c){if(this.readyState!=0)throw this.abort(),Error("Error reopening a connection");this.B=i,this.A=c,this.readyState=1,Wn(this)},n.send=function(i){if(this.readyState!=1)throw this.abort(),Error("need to call open() first. ");this.g=!0;const c={headers:this.u,method:this.B,credentials:this.m,cache:void 0};i&&(c.body=i),(this.D||u).fetch(new Request(this.A,c)).then(this.Sa.bind(this),this.ga.bind(this))},n.abort=function(){this.response=this.responseText="",this.u=new Headers,this.status=0,this.j&&this.j.cancel("Request was aborted.").catch(()=>{}),1<=this.readyState&&this.g&&this.readyState!=4&&(this.g=!1,Hn(this)),this.readyState=0},n.Sa=function(i){if(this.g&&(this.l=i,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=i.headers,this.readyState=2,Wn(this)),this.g&&(this.readyState=3,Wn(this),this.g)))if(this.responseType==="arraybuffer")i.arrayBuffer().then(this.Qa.bind(this),this.ga.bind(this));else if(typeof u.ReadableStream<"u"&&"body"in i){if(this.j=i.body.getReader(),this.o){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.v=new TextDecoder;nc(this)}else i.text().then(this.Ra.bind(this),this.ga.bind(this))};function nc(i){i.j.read().then(i.Pa.bind(i)).catch(i.ga.bind(i))}n.Pa=function(i){if(this.g){if(this.o&&i.value)this.response.push(i.value);else if(!this.o){var c=i.value?i.value:new Uint8Array(0);(c=this.v.decode(c,{stream:!i.done}))&&(this.response=this.responseText+=c)}i.done?Hn(this):Wn(this),this.readyState==3&&nc(this)}},n.Ra=function(i){this.g&&(this.response=this.responseText=i,Hn(this))},n.Qa=function(i){this.g&&(this.response=i,Hn(this))},n.ga=function(){this.g&&Hn(this)};function Hn(i){i.readyState=4,i.l=null,i.j=null,i.v=null,Wn(i)}n.setRequestHeader=function(i,c){this.u.append(i,c)},n.getResponseHeader=function(i){return this.h&&this.h.get(i.toLowerCase())||""},n.getAllResponseHeaders=function(){if(!this.h)return"";const i=[],c=this.h.entries();for(var l=c.next();!l.done;)l=l.value,i.push(l[0]+": "+l[1]),l=c.next();return i.join(`\r
410`)};function Wn(i){i.onreadystatechange&&i.onreadystatechange.call(i)}Object.defineProperty($r.prototype,"withCredentials",{get:function(){return this.m==="include"},set:function(i){this.m=i?"include":"same-origin"}});function rc(i){let c="";return he(i,function(l,f){c+=f,c+=":",c+=l,c+=`\r
411`}),c}function Ri(i,c,l){e:{for(f in l){var f=!1;break e}f=!0}f||(l=rc(l),typeof i=="string"?l!=null&&encodeURIComponent(String(l)):X(i,c,l))}function ne(i){ye.call(this),this.headers=new Map,this.o=i||null,this.h=!1,this.v=this.g=null,this.D="",this.m=0,this.l="",this.j=this.B=this.u=this.A=!1,this.I=null,this.H="",this.J=!1}b(ne,ye);var af=/^https?$/i,cf=["POST","PUT"];n=ne.prototype,n.Ha=function(i){this.J=i},n.ea=function(i,c,l,f){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.D+"; newUri="+i);c=c?c.toUpperCase():"GET",this.D=i,this.l="",this.m=0,this.A=!1,this.h=!0,this.g=this.o?this.o.g():yi.g(),this.v=this.o?Va(this.o):Va(yi),this.g.onreadystatechange=E(this.Ea,this);try{this.B=!0,this.g.open(c,String(i),!0),this.B=!1}catch(R){sc(this,R);return}if(i=l||"",l=new Map(this.headers),f)if(Object.getPrototypeOf(f)===Object.prototype)for(var v in f)l.set(v,f[v]);else if(typeof f.keys=="function"&&typeof f.get=="function")for(const R of f.keys())l.set(R,f.get(R));else throw Error("Unknown input type for opt_headers: "+String(f));f=Array.from(l.keys()).find(R=>R.toLowerCase()=="content-type"),v=u.FormData&&i instanceof u.FormData,!(0<=Array.prototype.indexOf.call(cf,c,void 0))||f||v||l.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");for(const[R,k]of l)this.g.setRequestHeader(R,k);this.H&&(this.g.responseType=this.H),"withCredentials"in this.g&&this.g.withCredentials!==this.J&&(this.g.withCredentials=this.J);try{ac(this),this.u=!0,this.g.send(i),this.u=!1}catch(R){sc(this,R)}};function sc(i,c){i.h=!1,i.g&&(i.j=!0,i.g.abort(),i.j=!1),i.l=c,i.m=5,ic(i),zr(i)}function ic(i){i.A||(i.A=!0,Ae(i,"complete"),Ae(i,"error"))}n.abort=function(i){this.g&&this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1,this.m=i||7,Ae(this,"complete"),Ae(this,"abort"),zr(this))},n.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),zr(this,!0)),ne.aa.N.call(this)},n.Ea=function(){this.s||(this.B||this.u||this.j?oc(this):this.bb())},n.bb=function(){oc(this)};function oc(i){if(i.h&&typeof a<"u"&&(!i.v[1]||st(i)!=4||i.Z()!=2)){if(i.u&&st(i)==4)Ca(i.Ea,0,i);else if(Ae(i,"readystatechange"),st(i)==4){i.h=!1;try{const k=i.Z();e:switch(k){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var c=!0;break e;default:c=!1}var l;if(!(l=c)){var f;if(f=k===0){var v=String(i.D).match(Ja)[1]||null;!v&&u.self&&u.self.location&&(v=u.self.location.protocol.slice(0,-1)),f=!af.test(v?v.toLowerCase():"")}l=f}if(l)Ae(i,"complete"),Ae(i,"success");else{i.m=6;try{var R=2<st(i)?i.g.statusText:""}catch{R=""}i.l=R+" ["+i.Z()+"]",ic(i)}}finally{zr(i)}}}}function zr(i,c){if(i.g){ac(i);const l=i.g,f=i.v[0]?()=>{}:null;i.g=null,i.v=null,c||Ae(i,"ready");try{l.onreadystatechange=f}catch{}}}function ac(i){i.I&&(u.clearTimeout(i.I),i.I=null)}n.isActive=function(){return!!this.g};function st(i){return i.g?i.g.readyState:0}n.Z=function(){try{return 2<st(this)?this.g.status:-1}catch{return-1}},n.oa=function(){try{return this.g?this.g.responseText:""}catch{return""}},n.Oa=function(i){if(this.g){var c=this.g.responseText;return i&&c.indexOf(i)==0&&(c=c.substring(i.length)),Ud(c)}};function cc(i){try{if(!i.g)return null;if("response"in i.g)return i.g.response;switch(i.H){case"":case"text":return i.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in i.g)return i.g.mozResponseArrayBuffer}return null}catch{return null}}function uf(i){const c={};i=(i.g&&2<=st(i)&&i.g.getAllResponseHeaders()||"").split(`\r
412`);for(let f=0;f<i.length;f++){if(B(i[f]))continue;var l=I(i[f]);const v=l[0];if(l=l[1],typeof l!="string")continue;l=l.trim();const R=c[v]||[];c[v]=R,R.push(l)}w(c,function(f){return f.join(", ")})}n.Ba=function(){return this.m},n.Ka=function(){return typeof this.l=="string"?this.l:String(this.l)};function Gn(i,c,l){return l&&l.internalChannelParams&&l.internalChannelParams[i]||c}function uc(i){this.Aa=0,this.i=[],this.j=new Bn,this.ia=this.qa=this.I=this.W=this.g=this.ya=this.D=this.H=this.m=this.S=this.o=null,this.Ya=this.U=0,this.Va=Gn("failFast",!1,i),this.F=this.C=this.u=this.s=this.l=null,this.X=!0,this.za=this.T=-1,this.Y=this.v=this.B=0,this.Ta=Gn("baseRetryDelayMs",5e3,i),this.cb=Gn("retryDelaySeedMs",1e4,i),this.Wa=Gn("forwardChannelMaxRetries",2,i),this.wa=Gn("forwardChannelRequestTimeoutMs",2e4,i),this.pa=i&&i.xmlHttpFactory||void 0,this.Xa=i&&i.Tb||void 0,this.Ca=i&&i.useFetchStreams||!1,this.L=void 0,this.J=i&&i.supportsCrossDomainXhr||!1,this.K="",this.h=new za(i&&i.concurrentRequestLimit),this.Da=new sf,this.P=i&&i.fastHandshake||!1,this.O=i&&i.encodeInitMessageHeaders||!1,this.P&&this.O&&(this.O=!1),this.Ua=i&&i.Rb||!1,i&&i.xa&&this.j.xa(),i&&i.forceLongPolling&&(this.X=!1),this.ba=!this.P&&this.X&&i&&i.detectBufferingProxy||!1,this.ja=void 0,i&&i.longPollingTimeout&&0<i.longPollingTimeout&&(this.ja=i.longPollingTimeout),this.ca=void 0,this.R=0,this.M=!1,this.ka=this.A=null}n=uc.prototype,n.la=8,n.G=1,n.connect=function(i,c,l,f){Re(0),this.W=i,this.H=c||{},l&&f!==void 0&&(this.H.OSID=l,this.H.OAID=f),this.F=this.X,this.I=yc(this,null,this.W),Wr(this)};function Si(i){if(lc(i),i.G==3){var c=i.U++,l=rt(i.I);if(X(l,"SID",i.K),X(l,"RID",c),X(l,"TYPE","terminate"),Kn(i,l),c=new gt(i,i.j,c),c.L=2,c.v=qr(rt(l)),l=!1,u.navigator&&u.navigator.sendBeacon)try{l=u.navigator.sendBeacon(c.v.toString(),"")}catch{}!l&&u.Image&&(new Image().src=c.v,l=!0),l||(c.g=Ec(c.j,null),c.g.ea(c.v)),c.F=Date.now(),Fr(c)}_c(i)}function Hr(i){i.g&&(Ci(i),i.g.cancel(),i.g=null)}function lc(i){Hr(i),i.u&&(u.clearTimeout(i.u),i.u=null),Gr(i),i.h.cancel(),i.s&&(typeof i.s=="number"&&u.clearTimeout(i.s),i.s=null)}function Wr(i){if(!Ha(i.h)&&!i.s){i.s=!0;var c=i.Ga;Dn||va(),On||(Dn(),On=!0),oi.add(c,i),i.B=0}}function lf(i,c){return Wa(i.h)>=i.h.j-(i.s?1:0)?!1:i.s?(i.i=c.D.concat(i.i),!0):i.G==1||i.G==2||i.B>=(i.Va?0:i.Wa)?!1:(i.s=Un(E(i.Ga,i,c),gc(i,i.B)),i.B++,!0)}n.Ga=function(i){if(this.s)if(this.s=null,this.G==1){if(!i){this.U=Math.floor(1e5*Math.random()),i=this.U++;const v=new gt(this,this.j,i);let R=this.o;if(this.S&&(R?(R=m(R),T(R,this.S)):R=this.S),this.m!==null||this.O||(v.H=R,R=null),this.P)e:{for(var c=0,l=0;l<this.i.length;l++){t:{var f=this.i[l];if("__data__"in f.map&&(f=f.map.__data__,typeof f=="string")){f=f.length;break t}f=void 0}if(f===void 0)break;if(c+=f,4096<c){c=l;break e}if(c===4096||l===this.i.length-1){c=l+1;break e}}c=1e3}else c=1e3;c=dc(this,v,c),l=rt(this.I),X(l,"RID",i),X(l,"CVER",22),this.D&&X(l,"X-HTTP-Session-Id",this.D),Kn(this,l),R&&(this.O?c="headers="+encodeURIComponent(String(rc(R)))+"&"+c:this.m&&Ri(l,this.m,R)),Ai(this.h,v),this.Ua&&X(l,"TYPE","init"),this.P?(X(l,"$req",c),X(l,"SID","null"),v.T=!0,Ti(v,l,null)):Ti(v,l,c),this.G=2}}else this.G==3&&(i?hc(this,i):this.i.length==0||Ha(this.h)||hc(this))};function hc(i,c){var l;c?l=c.l:l=i.U++;const f=rt(i.I);X(f,"SID",i.K),X(f,"RID",l),X(f,"AID",i.T),Kn(i,f),i.m&&i.o&&Ri(f,i.m,i.o),l=new gt(i,i.j,l,i.B+1),i.m===null&&(l.H=i.o),c&&(i.i=c.D.concat(i.i)),c=dc(i,l,1e3),l.I=Math.round(.5*i.wa)+Math.round(.5*i.wa*Math.random()),Ai(i.h,l),Ti(l,f,c)}function Kn(i,c){i.H&&he(i.H,function(l,f){X(c,f,l)}),i.l&&Qa({},function(l,f){X(c,f,l)})}function dc(i,c,l){l=Math.min(i.i.length,l);var f=i.l?E(i.l.Na,i.l,i):null;e:{var v=i.i;let R=-1;for(;;){const k=["count="+l];R==-1?0<l?(R=v[0].g,k.push("ofs="+R)):R=0:k.push("ofs="+R);let J=!0;for(let de=0;de<l;de++){let K=v[de].g;const Ee=v[de].map;if(K-=R,0>K)R=Math.max(0,v[de].g-100),J=!1;else try{of(Ee,k,"req"+K+"_")}catch{f&&f(Ee)}}if(J){f=k.join("&");break e}}}return i=i.i.splice(0,l),c.D=i,f}function fc(i){if(!i.g&&!i.u){i.Y=1;var c=i.Fa;Dn||va(),On||(Dn(),On=!0),oi.add(c,i),i.v=0}}function Pi(i){return i.g||i.u||3<=i.v?!1:(i.Y++,i.u=Un(E(i.Fa,i),gc(i,i.v)),i.v++,!0)}n.Fa=function(){if(this.u=null,pc(this),this.ba&&!(this.M||this.g==null||0>=this.R)){var i=2*this.R;this.j.info("BP detection timer enabled: "+i),this.A=Un(E(this.ab,this),i)}},n.ab=function(){this.A&&(this.A=null,this.j.info("BP detection timeout reached."),this.j.info("Buffering proxy detected and switch to long-polling!"),this.F=!1,this.M=!0,Re(10),Hr(this),pc(this))};function Ci(i){i.A!=null&&(u.clearTimeout(i.A),i.A=null)}function pc(i){i.g=new gt(i,i.j,"rpc",i.Y),i.m===null&&(i.g.H=i.o),i.g.O=0;var c=rt(i.qa);X(c,"RID","rpc"),X(c,"SID",i.K),X(c,"AID",i.T),X(c,"CI",i.F?"0":"1"),!i.F&&i.ja&&X(c,"TO",i.ja),X(c,"TYPE","xmlhttp"),Kn(i,c),i.m&&i.o&&Ri(c,i.m,i.o),i.L&&(i.g.I=i.L);var l=i.g;i=i.ia,l.L=1,l.v=qr(rt(c)),l.m=null,l.P=!0,qa(l,i)}n.Za=function(){this.C!=null&&(this.C=null,Hr(this),Pi(this),Re(19))};function Gr(i){i.C!=null&&(u.clearTimeout(i.C),i.C=null)}function mc(i,c){var l=null;if(i.g==c){Gr(i),Ci(i),i.g=null;var f=2}else if(vi(i.h,c))l=c.D,Ga(i.h,c),f=1;else return;if(i.G!=0){if(c.o)if(f==1){l=c.m?c.m.length:0,c=Date.now()-c.F;var v=i.B;f=Mr(),Ae(f,new xa(f,l)),Wr(i)}else fc(i);else if(v=c.s,v==3||v==0&&0<c.X||!(f==1&&lf(i,c)||f==2&&Pi(i)))switch(l&&0<l.length&&(c=i.h,c.i=c.i.concat(l)),v){case 1:jt(i,5);break;case 4:jt(i,10);break;case 3:jt(i,6);break;default:jt(i,2)}}}function gc(i,c){let l=i.Ta+Math.floor(Math.random()*i.cb);return i.isActive()||(l*=2),l*c}function jt(i,c){if(i.j.info("Error code "+c),c==2){var l=E(i.fb,i),f=i.Xa;const v=!f;f=new qt(f||"//www.google.com/images/cleardot.gif"),u.location&&u.location.protocol=="http"||Ur(f,"https"),qr(f),v?nf(f.toString(),l):rf(f.toString(),l)}else Re(2);i.G=0,i.l&&i.l.sa(c),_c(i),lc(i)}n.fb=function(i){i?(this.j.info("Successfully pinged google.com"),Re(2)):(this.j.info("Failed to ping google.com"),Re(1))};function _c(i){if(i.G=0,i.ka=[],i.l){const c=Ka(i.h);(c.length!=0||i.i.length!=0)&&(N(i.ka,c),N(i.ka,i.i),i.h.i.length=0,D(i.i),i.i.length=0),i.l.ra()}}function yc(i,c,l){var f=l instanceof qt?rt(l):new qt(l);if(f.g!="")c&&(f.g=c+"."+f.g),Br(f,f.s);else{var v=u.location;f=v.protocol,c=c?c+"."+v.hostname:v.hostname,v=+v.port;var R=new qt(null);f&&Ur(R,f),c&&(R.g=c),v&&Br(R,v),l&&(R.l=l),f=R}return l=i.D,c=i.ya,l&&c&&X(f,l,c),X(f,"VER",i.la),Kn(i,f),f}function Ec(i,c,l){if(c&&!i.J)throw Error("Can't create secondary domain capable XhrIo object.");return c=i.Ca&&!i.pa?new ne(new jr({eb:l})):new ne(i.pa),c.Ha(i.J),c}n.isActive=function(){return!!this.l&&this.l.isActive(this)};function Tc(){}n=Tc.prototype,n.ua=function(){},n.ta=function(){},n.sa=function(){},n.ra=function(){},n.isActive=function(){return!0},n.Na=function(){};function Kr(){}
412Kr.prototype.g=function(i,c){return new Ne(i,c)};function Ne(i,c){ye.call(this),this.g=new uc(c),this.l=i,this.h=c&&c.messageUrlParams||null,i=c&&c.messageHeaders||null,c&&c.clientProtocolHeaderRequired&&(i?i["X-Client-Protocol"]="webchannel":i={"X-Client-Protocol":"webchannel"}),this.g.o=i,i=c&&c.initMessageHeaders||null,c&&c.messageContentType&&(i?i["X-WebChannel-Content-Type"]=c.messageContentType:i={"X-WebChannel-Content-Type":c.messageContentType}),c&&c.va&&(i?i["X-WebChannel-Client-Profile"]=c.va:i={"X-WebChannel-Client-Profile":c.va}),this.g.S=i,(i=c&&c.Sb)&&!B(i)&&(this.g.m=i),this.v=c&&c.supportsCrossDomainXhr||!1,this.u=c&&c.sendRawJson||!1,(c=c&&c.httpSessionIdParam)&&!B(c)&&(this.g.D=c,i=this.h,i!==null&&c in i&&(i=this.h,c in i&&delete i[c])),this.j=new on(this)}b(Ne,ye),Ne.prototype.m=function(){this.g.l=this.j,this.v&&(this.g.J=!0),this.g.connect(this.l,this.h||void 0)},Ne.prototype.close=function(){Si(this.g)},Ne.prototype.o=function(i){var c=this.g;if(typeof i=="string"){var l={};l.__data__=i,i=l}else this.u&&(l={},l.__data__=pi(i),i=l);c.i.push(new Wd(c.Ya++,i)),c.G==3&&Wr(c)},Ne.prototype.N=function(){this.g.l=null,delete this.j,Si(this.g),delete this.g,Ne.aa.N.call(this)};function Ic(i){gi.call(this),i.__headers__&&(this.headers=i.__headers__,this.statusCode=i.__status__,delete i.__headers__,delete i.__status__);var c=i.__sm__;if(c){e:{for(const l in c){i=l;break e}i=void 0}(this.i=i)&&(i=this.i,c=c!==null&&i in c?c[i]:void 0),this.data=c}else this.data=i}b(Ic,gi);function wc(){_i.call(this),this.status=1}b(wc,_i);function on(i){this.g=i}b(on,Tc),on.prototype.ua=function(){Ae(this.g,"a")},on.prototype.ta=function(i){Ae(this.g,new Ic(i))},on.prototype.sa=function(i){Ae(this.g,new wc)},on.prototype.ra=function(){Ae(this.g,"b")},Kr.prototype.createWebChannel=Kr.prototype.g,Ne.prototype.send=Ne.prototype.o,Ne.prototype.open=Ne.prototype.m,Ne.prototype.close=Ne.prototype.close,El=function(){return new Kr},yl=function(){return Mr()},_l=Ut,Ki={mb:0,pb:1,qb:2,Jb:3,Ob:4,Lb:5,Mb:6,Kb:7,Ib:8,Nb:9,PROXY:10,NOPROXY:11,Gb:12,Cb:13,Db:14,Bb:15,Eb:16,Fb:17,ib:18,hb:19,jb:20},Lr.NO_ERROR=0,Lr.TIMEOUT=8,Lr.HTTP_ERROR=6,ns=Lr,Fa.COMPLETE="complete",gl=Fa,Da.EventType=xn,xn.OPEN="a",xn.CLOSE="b",xn.ERROR="c",xn.MESSAGE="d",ye.prototype.listen=ye.prototype.K,Yn=Da,ne.prototype.listenOnce=ne.prototype.L,ne.prototype.getLastError=ne.prototype.Ka,ne.prototype.getLastErrorCode=ne.prototype.Ba,ne.prototype.getStatus=ne.prototype.Z,ne.prototype.getResponseJson=ne.prototype.Oa,ne.prototype.getResponseText=ne.prototype.oa,ne.prototype.send=ne.prototype.ea,ne.prototype.setWithCredentials=ne.prototype.Ha,ml=ne}).apply(typeof Jr<"u"?Jr:typeof self<"u"?self:typeof window<"u"?window:{});const Mc="@firebase/firestore",Lc="4.9.0";/**
413 * @license
414 * Copyright 2017 Google LLC
415 *
416 * Licensed under the Apache License, Version 2.0 (the "License");
417 * you may not use this file except in compliance with the License.
418 * You may obtain a copy of the License at
419 *
420 *   http://www.apache.org/licenses/LICENSE-2.0
421 *
422 * Unless required by applicable law or agreed to in writing, software
423 * distributed under the License is distributed on an "AS IS" BASIS,
424 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
425 * See the License for the specific language governing permissions and
426 * limitations under the License.
427 */class Pe{constructor(e){this.uid=e}isAuthenticated(){return this.uid!=null}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(e){return e.uid===this.uid}}Pe.UNAUTHENTICATED=new Pe(null),Pe.GOOGLE_CREDENTIALS=new Pe("google-credentials-uid"),Pe.FIRST_PARTY=new Pe("first-party-uid"),Pe.MOCK_USER=new Pe("mock-user");/**
428 * @license
429 * Copyright 2017 Google LLC
430 *
431 * Licensed under the Apache License, Version 2.0 (the "License");
432 * you may not use this file except in compliance with the License.
433 * You may obtain a copy of the License at
434 *
435 *   http://www.apache.org/licenses/LICENSE-2.0
436 *
437 * Unless required by applicable law or agreed to in writing, software
438 * distributed under the License is distributed on an "AS IS" BASIS,
439 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
440 * See the License for the specific language governing permissions and
441 * limitations under the License.
442 */let An="12.0.0";/**
443 * @license
444 * Copyright 2017 Google LLC
445 *
446 * Licensed under the Apache License, Version 2.0 (the "License");
447 * you may not use this file except in compliance with the License.
448 * You may obtain a copy of the License at
449 *
450 *   http://www.apache.org/licenses/LICENSE-2.0
451 *
452 * Unless required by applicable law or agreed to in writing, software
453 * distributed under the License is distributed on an "AS IS" BASIS,
454 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
455 * See the License for the specific language governing permissions and
456 * limitations under the License.
457 */const Kt=new Eo("@firebase/firestore");function cn(){return Kt.logLevel}function O(n,...e){if(Kt.logLevel<=j.DEBUG){const t=e.map(Io);Kt.debug(`Firestore (${An}): ${n}`,...t)}}function ht(n,...e){if(Kt.logLevel<=j.ERROR){const t=e.map(Io);Kt.error(`Firestore (${An}): ${n}`,...t)}}function cr(n,...e){if(Kt.logLevel<=j.WARN){const t=e.map(Io);Kt.warn(`Firestore (${An}): ${n}`,...t)}}function Io(n){if(typeof n=="string")return n;try{/**
458* @license
459* Copyright 2020 Google LLC
460*
461* Licensed under the Apache License, Version 2.0 (the "License");
462* you may not use this file except in compliance with the License.
463* You may obtain a copy of the License at
464*
465*   http://www.apache.org/licenses/LICENSE-2.0
466*
467* Unless required by applicable law or agreed to in writing, software
468* distributed under the License is distributed on an "AS IS" BASIS,
469* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
470* See the License for the specific language governing permissions and
471* limitations under the License.
472*/return function(t){return JSON.stringify(t)}(n)}catch{return n}}/**
473 * @license
474 * Copyright 2017 Google LLC
475 *
476 * Licensed under the Apache License, Version 2.0 (the "License");
477 * you may not use this file except in compliance with the License.
478 * You may obtain a copy of the License at
479 *
480 *   http://www.apache.org/licenses/LICENSE-2.0
481 *
482 * Unless required by applicable law or agreed to in writing, software
483 * distributed under the License is distributed on an "AS IS" BASIS,
484 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
485 * See the License for the specific language governing permissions and
486 * limitations under the License.
487 */function x(n,e,t){let r="Unexpected state";typeof e=="string"?r=e:t=e,Tl(n,r,t)}function Tl(n,e,t){let r=`FIRESTORE (${An}) INTERNAL ASSERTION FAILED: ${e} (ID: ${n.toString(16)})`;if(t!==void 0)try{r+=" CONTEXT: "+JSON.stringify(t)}catch{r+=" CONTEXT: "+t}throw ht(r),new Error(r)}function Q(n,e,t,r){let s="Unexpected state";typeof t=="string"?s=t:r=t,n||Tl(e,s,r)}function U(n,e){return n}/**
488 * @license
489 * Copyright 2017 Google LLC
490 *
491 * Licensed under the Apache License, Version 2.0 (the "License");
492 * you may not use this file except in compliance with the License.
493 * You may obtain a copy of the License at
494 *
495 *   http://www.apache.org/licenses/LICENSE-2.0
496 *
497 * Unless required by applicable law or agreed to in writing, software
498 * distributed under the License is distributed on an "AS IS" BASIS,
499 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
500 * See the License for the specific language governing permissions and
501 * limitations under the License.
502 */const P={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 V extends Ze{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}/**
503 * @license
504 * Copyright 2017 Google LLC
505 *
506 * Licensed under the Apache License, Version 2.0 (the "License");
507 * you may not use this file except in compliance with the License.
508 * You may obtain a copy of the License at
509 *
510 *   http://www.apache.org/licenses/LICENSE-2.0
511 *
512 * Unless required by applicable law or agreed to in writing, softw
512are
513 * distributed under the License is distributed on an "AS IS" BASIS,
514 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
515 * See the License for the specific language governing permissions and
516 * limitations under the License.
517 */class at{constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}/**
518 * @license
519 * Copyright 2017 Google LLC
520 *
521 * Licensed under the Apache License, Version 2.0 (the "License");
522 * you may not use this file except in compliance with the License.
523 * You may obtain a copy of the License at
524 *
525 *   http://www.apache.org/licenses/LICENSE-2.0
526 *
527 * Unless required by applicable law or agreed to in writing, software
528 * distributed under the License is distributed on an "AS IS" BASIS,
529 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
530 * See the License for the specific language governing permissions and
531 * limitations under the License.
532 */class Xp{constructor(e,t){this.user=t,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class Zp{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable(()=>t(Pe.UNAUTHENTICATED))}shutdown(){}}class em{constructor(e){this.t=e,this.currentUser=Pe.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,t){Q(this.o===void 0,42304);let r=this.i;const s=h=>this.i!==r?(r=this.i,t(h)):Promise.resolve();let o=new at;this.o=()=>{this.i++,this.currentUser=this.u(),o.resolve(),o=new at,e.enqueueRetryable(()=>s(this.currentUser))};const a=()=>{const h=o;e.enqueueRetryable(async()=>{await h.promise,await s(this.currentUser)})},u=h=>{O("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=h,this.o&&(this.auth.addAuthTokenListener(this.o),a())};this.t.onInit(h=>u(h)),setTimeout(()=>{if(!this.auth){const h=this.t.getImmediate({optional:!0});h?u(h):(O("FirebaseAuthCredentialsProvider","Auth not yet detected"),o.resolve(),o=new at)}},0),a()}getToken(){const e=this.i,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then(r=>this.i!==e?(O("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):r?(Q(typeof r.accessToken=="string",31837,{l:r}),new Xp(r.accessToken,this.currentUser)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.o&&this.auth.removeAuthTokenListener(this.o),this.o=void 0}u(){const e=this.auth&&this.auth.getUid();return Q(e===null||typeof e=="string",2055,{h:e}),new Pe(e)}}class tm{constructor(e,t,r){this.P=e,this.T=t,this.I=r,this.type="FirstParty",this.user=Pe.FIRST_PARTY,this.A=new Map}R(){return this.I?this.I():null}get headers(){this.A.set("X-Goog-AuthUser",this.P);const e=this.R();return e&&this.A.set("Authorization",e),this.T&&this.A.set("X-Goog-Iam-Authorization-Token",this.T),this.A}}class nm{constructor(e,t,r){this.P=e,this.T=t,this.I=r}getToken(){return Promise.resolve(new tm(this.P,this.T,this.I))}start(e,t){e.enqueueRetryable(()=>t(Pe.FIRST_PARTY))}shutdown(){}invalidateToken(){}}class xc{constructor(e){this.value=e,this.type="AppCheck",this.headers=new Map,e&&e.length>0&&this.headers.set("x-firebase-appcheck",this.value)}}class rm{constructor(e,t){this.V=t,this.forceRefresh=!1,this.appCheck=null,this.m=null,this.p=null,pe(e)&&e.settings.appCheckToken&&(this.p=e.settings.appCheckToken)}start(e,t){Q(this.o===void 0,3512);const r=o=>{o.error!=null&&O("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${o.error.message}`);const a=o.token!==this.m;return this.m=o.token,O("FirebaseAppCheckTokenProvider",`Received ${a?"new":"existing"} token.`),a?t(o.token):Promise.resolve()};this.o=o=>{e.enqueueRetryable(()=>r(o))};const s=o=>{O("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=o,this.o&&this.appCheck.addTokenListener(this.o)};this.V.onInit(o=>s(o)),setTimeout(()=>{if(!this.appCheck){const o=this.V.getImmediate({optional:!0});o?s(o):O("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}},0)}getToken(){if(this.p)return Promise.resolve(new xc(this.p));const e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then(t=>t?(Q(typeof t.token=="string",44558,{tokenResult:t}),this.m=t.token,new xc(t.token)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.o&&this.appCheck.removeTokenListener(this.o),this.o=void 0}}/**
533 * @license
534 * Copyright 2020 Google LLC
535 *
536 * Licensed under the Apache License, Version 2.0 (the "License");
537 * you may not use this file except in compliance with the License.
538 * You may obtain a copy of the License at
539 *
540 *   http://www.apache.org/licenses/LICENSE-2.0
541 *
542 * Unless required by applicable law or agreed to in writing, software
543 * distributed under the License is distributed on an "AS IS" BASIS,
544 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
545 * See the License for the specific language governing permissions and
546 * limitations under the License.
547 */function sm(n){const e=typeof self<"u"&&(self.crypto||self.msCrypto),t=new Uint8Array(n);if(e&&typeof e.getRandomValues=="function")e.getRandomValues(t);else for(let r=0;r<n;r++)t[r]=Math.floor(256*Math.random());return t}/**
548 * @license
549 * Copyright 2017 Google LLC
550 *
551 * Licensed under the Apache License, Version 2.0 (the "License");
552 * you may not use this file except in compliance with the License.
553 * You may obtain a copy of the License at
554 *
555 *   http://www.apache.org/licenses/LICENSE-2.0
556 *
557 * Unless required by applicable law or agreed to in writing, software
558 * distributed under the License is distributed on an "AS IS" BASIS,
559 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
560 * See the License for the specific language governing permissions and
561 * limitations under the License.
562 */class wo{static newId(){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t=62*Math.floor(4.129032258064516);let r="";for(;r.length<20;){const s=sm(40);for(let o=0;o<s.length;++o)r.length<20&&s[o]<t&&(r+=e.charAt(s[o]%62))}return r}}function $(n,e){return n<e?-1:n>e?1:0}function Qi(n,e){const t=Math.min(n.length,e.length);for(let r=0;r<t;r++){const s=n.charAt(r),o=e.charAt(r);if(s!==o)return Mi(s)===Mi(o)?$(s,o):Mi(s)?1:-1}return $(n.length,e.length)}const im=55296,om=57343;function Mi(n){const e=n.charCodeAt(0);return e>=im&&e<=om}function mn(n,e,t){return n.length===e.length&&n.every((r,s)=>t(r,e[s]))}/**
563 * @license
564 * Copyright 2017 Google LLC
565 *
566 * Licensed under the Apache License, Version 2.0 (the "License");
567 * you may not use this file except in compliance with the License.
568 * You may obtain a copy of the License at
569 *
570 *   http://www.apache.org/licenses/LICENSE-2.0
571 *
572 * Unless required by applicable law or agreed to in writing, software
573 * distributed under the License is distributed on an "AS IS" BASIS,
574 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
575 * See the License for the specific language governing permissions and
576 * limitations under the License.
577 */const Fc="__name__";class ze{constructor(e,t,r){t===void 0?t=0:t>e.length&&x(637,{offset:t,range:e.length}),r===void 0?r=e.length-t:r>e.length-t&&x(1746,{length:r,range:e.length-t}),this.segments=e,this.offset=t,this.len=r}get length(){return this.len}isEqual(e){return ze.comparator(this,e)===0}child(e){const t=this.segments.slice(this.offset,this.limit());return e instanceof ze?e.forEach(r=>{t.push(r)}):t.push(e),this.construct(t)}limit(){return this.offset+this.length}popFirst(e){return e=e===void 0?1:e,this.construct(this.segments,this.offset+e,this.length-e)}popLast(){return this.construct(this.segments,this.offset,this.length-1)}firstSegment(){return this.segments[this.offset]}lastSegment(){return this.get(this.length-1)}get(e){return this.segments[this.offset+e]}isEmpty(){return this.length===0}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(e,t){const r=Math.min(e.length,t.length);for(let s=0;s<r;s++){const o=ze.compareSegments(e.get(s),t.get(s));if(o!==0)return o}return $(e.length,t.length)}static compareSegments(e,t){const r=ze.isNumericId(e),s=ze.isNumericId(t);return r&&!s?-1:!r&&s?1:r&&s?ze.extractNumericId(e).compare(ze.extractNumericId(t)):Qi(e,t)}static isNumericId(e){return e.startsWith("__id")&&e.endsWith("__")}static extractNumericId(e){return Pt.fromString(e.substring(4,e.length-2))}}class Y extends ze{construct(e,t,r){return new Y(e,t,r)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}
577toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...e){const t=[];for(const r of e){if(r.indexOf("//")>=0)throw new V(P.INVALID_ARGUMENT,`Invalid segment (${r}). Paths must not contain // in them.`);t.push(...r.split("/").filter(s=>s.length>0))}return new Y(t)}static emptyPath(){return new Y([])}}const am=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class me extends ze{construct(e,t,r){return new me(e,t,r)}static isValidIdentifier(e){return am.test(e)}canonicalString(){return this.toArray().map(e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),me.isValidIdentifier(e)||(e="`"+e+"`"),e)).join(".")}toString(){return this.canonicalString()}isKeyField(){return this.length===1&&this.get(0)===Fc}static keyField(){return new me([Fc])}static fromServerFormat(e){const t=[];let r="",s=0;const o=()=>{if(r.length===0)throw new V(P.INVALID_ARGUMENT,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);t.push(r),r=""};let a=!1;for(;s<e.length;){const u=e[s];if(u==="\\"){if(s+1===e.length)throw new V(P.INVALID_ARGUMENT,"Path has trailing escape character: "+e);const h=e[s+1];if(h!=="\\"&&h!=="."&&h!=="`")throw new V(P.INVALID_ARGUMENT,"Path has invalid escape sequence: "+e);r+=h,s+=2}else u==="`"?(a=!a,s++):u!=="."||a?(r+=u,s++):(o(),s++)}if(o(),a)throw new V(P.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new me(t)}static emptyPath(){return new me([])}}/**
578 * @license
579 * Copyright 2017 Google LLC
580 *
581 * Licensed under the Apache License, Version 2.0 (the "License");
582 * you may not use this file except in compliance with the License.
583 * You may obtain a copy of the License at
584 *
585 *   http://www.apache.org/licenses/LICENSE-2.0
586 *
587 * Unless required by applicable law or agreed to in writing, software
588 * distributed under the License is distributed on an "AS IS" BASIS,
589 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
590 * See the License for the specific language governing permissions and
591 * limitations under the License.
592 */class L{constructor(e){this.path=e}static fromPath(e){return new L(Y.fromString(e))}static fromName(e){return new L(Y.fromString(e).popFirst(5))}static empty(){return new L(Y.emptyPath())}get collectionGroup(){return this.path.popLast().lastSegment()}hasCollectionId(e){return this.path.length>=2&&this.path.get(this.path.length-2)===e}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(e){return e!==null&&Y.comparator(this.path,e.path)===0}toString(){return this.path.toString()}static comparator(e,t){return Y.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new L(new Y(e.slice()))}}/**
593 * @license
594 * Copyright 2017 Google LLC
595 *
596 * Licensed under the Apache License, Version 2.0 (the "License");
597 * you may not use this file except in compliance with the License.
598 * You may obtain a copy of the License at
599 *
600 *   http://www.apache.org/licenses/LICENSE-2.0
601 *
602 * Unless required by applicable law or agreed to in writing, software
603 * distributed under the License is distributed on an "AS IS" BASIS,
604 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
605 * See the License for the specific language governing permissions and
606 * limitations under the License.
607 */function Il(n,e,t){if(!t)throw new V(P.INVALID_ARGUMENT,`Function ${n}() cannot be called with an empty ${e}.`)}function cm(n,e,t,r){if(e===!0&&r===!0)throw new V(P.INVALID_ARGUMENT,`${n} and ${t} cannot be used together.`)}function Uc(n){if(!L.isDocumentKey(n))throw new V(P.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${n} has ${n.length}.`)}function Bc(n){if(L.isDocumentKey(n))throw new V(P.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${n} has ${n.length}.`)}function wl(n){return typeof n=="object"&&n!==null&&(Object.getPrototypeOf(n)===Object.prototype||Object.getPrototypeOf(n)===null)}function Ls(n){if(n===void 0)return"undefined";if(n===null)return"null";if(typeof n=="string")return n.length>20&&(n=`${n.substring(0,20)}...`),JSON.stringify(n);if(typeof n=="number"||typeof n=="boolean")return""+n;if(typeof n=="object"){if(n instanceof Array)return"an array";{const e=function(r){return r.constructor?r.constructor.name:null}(n);return e?`a custom ${e} object`:"an object"}}return typeof n=="function"?"a function":x(12329,{type:typeof n})}function le(n,e){if("_delegate"in n&&(n=n._delegate),!(n instanceof e)){if(e.name===n.constructor.name)throw new V(P.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{const t=Ls(n);throw new V(P.INVALID_ARGUMENT,`Expected type '${e.name}', but it was: ${t}`)}}return n}function um(n,e){if(e<=0)throw new V(P.INVALID_ARGUMENT,`Function ${n}() requires a positive number, but it was: ${e}.`)}/**
608 * @license
609 * Copyright 2025 Google LLC
610 *
611 * Licensed under the Apache License, Version 2.0 (the "License");
612 * you may not use this file except in compliance with the License.
613 * You may obtain a copy of the License at
614 *
615 *   http://www.apache.org/licenses/LICENSE-2.0
616 *
617 * Unless required by applicable law or agreed to in writing, software
618 * distributed under the License is distributed on an "AS IS" BASIS,
619 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
620 * See the License for the specific language governing permissions and
621 * limitations under the License.
622 */function ae(n,e){const t={typeString:n};return e&&(t.value=e),t}function Tr(n,e){if(!wl(n))throw new V(P.INVALID_ARGUMENT,"JSON must be an object");let t;for(const r in e)if(e[r]){const s=e[r].typeString,o="value"in e[r]?{value:e[r].value}:void 0;if(!(r in n)){t=`JSON missing required field: '${r}'`;break}const a=n[r];if(s&&typeof a!==s){t=`JSON field '${r}' must be a ${s}.`;break}if(o!==void 0&&a!==o.value){t=`Expected '${r}' field to equal '${o.value}'`;break}}if(t)throw new V(P.INVALID_ARGUMENT,t);return!0}/**
623 * @license
624 * Copyright 2017 Google LLC
625 *
626 * Licensed under the Apache License, Version 2.0 (the "License");
627 * you may not use this file except in compliance with the License.
628 * You may obtain a copy of the License at
629 *
630 *   http://www.apache.org/licenses/LICENSE-2.0
631 *
632 * Unless required by applicable law or agreed to in writing, software
633 * distributed under the License is distributed on an "AS IS" BASIS,
634 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
635 * See the License for the specific language governing permissions and
636 * limitations under the License.
637 */const qc=-62135596800,jc=1e6;class Z{static now(){return Z.fromMillis(Date.now())}static fromDate(e){return Z.fromMillis(e.getTime())}static fromMillis(e){const t=Math.floor(e/1e3),r=Math.floor((e-1e3*t)*jc);return new Z(t,r)}constructor(e,t){if(this.seconds=e,this.nanoseconds=t,t<0)throw new V(P.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(t>=1e9)throw new V(P.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(e<qc)throw new V(P.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e);if(e>=253402300800)throw new V(P.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/jc}_compareTo(e){return this.seconds===e.seconds?$(this.nanoseconds,e.nanoseconds):$(this.seconds,e.seconds)}isEqual(e){return e.seconds===this.seconds&&e.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{type:Z._jsonSchemaVersion,seconds:this.seconds,nanoseconds:this.nanoseconds}}static fromJSON(e){if(Tr(e,Z._jsonSchema))return new Z(e.seconds,e.nanoseconds)}valueOf(){const e=this.seconds-qc;return String(e).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}Z._jsonSchemaVersion="firestore/timestamp/1.0",Z._jsonSchema={type:ae("string",Z._jsonSchemaVersion),seconds:ae("number"),nanoseconds:ae("number")};/**
638 * @license
639 * Copyright 2017 Google LLC
640 *
641 * Licensed under the Apache License, Version 2.0 (the "License");
642 * you may not use this file except in compliance with the License.
643 * You may obtain a copy of the License at
644 *
645 *   http://www.apache.org/licenses/LICENSE-2.0
646 *
647 * Unless required by applicable law or agreed to in writing, software
648 * distributed under the License is distributed on an "AS IS" BASIS,
649 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
650 * See the License for the specific language governing permissions and
651 * limitations under the License.
652 */class F{static fromTimestamp(e){return new F(e)}static min(){return new F(new Z(0,0))}static max(){return new F(new Z(253402300799,999999999))}constructor(e){this.timestamp=e}compareTo(e){return this.timestamp._compareTo(e.timestamp)}isEqual(e){return this.timestamp.isEqual(e.timestamp)}toMicroseconds(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}toString(){return"SnapshotVersion("+this.timestamp.toString()+")"}toTimestamp(){return this.timestamp}}/**
653 * @license
654 * Copyright 2021 Google LLC
655 *
656 * Licensed under the Apache License, Version 2.0 (the "License");
657 * you may not use this file except in compliance with the License.
658 * You may obtain a copy of the License at
659 *
660 *   http://www.apache.org/licenses/LICENSE-2.0
661 *
662 * Unless required by applicable law or agreed to in writing, software
663 * distributed under the License is distributed on an "AS IS" BASIS,
664 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
665 * See the License for the specific language governing permissions and
666 * limitations under the License.
667 */const ur=-1;function lm(n,e){const t=n.toTimestamp().seconds,r=n.toTimestamp().nanoseconds+1,s=F.fromTimestamp(r===1e9?new Z(t+1,0):new Z(t,r));return new Nt(s,L.empty(),e)}function hm(n){return new Nt(n.readTime,n.key,ur)}class Nt{constructor(e,t,r){this.readTime=e,this.documentKey=t,this.largestBatchId=r}static min(){return new Nt(F.min(),L.empty(),ur)}static max(){return new Nt(F.max(),L.empty(),ur)}}function dm(n,e){let t=n.readTime.compareTo(e.readTime);return t!==0?t:(t=L.comparator(n.documentKey,e.documentKey),t!==0?t:$(n.largestBatchId,e.largestBatchId))}/**
668 * @license
669 * Copyright 2020 Google LLC
670 *
671 * Licensed under the Apache License, Version 2.0 (the "License");
672 * you may not use this file except in compliance with the License.
673 * You may obtain a copy of the License at
674 *
675 *   http://www.apache.org/licenses/LICENSE-2.0
676 *
677 * Unless required by applicable law or agreed to in writing, software
678 * distributed under the License is distributed on an "AS IS" BASIS,
679 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
680 * See the License for the specific language governing permissions and
681 * limitations under the License.
682 */const fm="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class pm{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach(e=>e())}}/**
683 * @license
684 * Copyright 2017 Google LLC
685 *
686 * Licensed under the Apache License, Version 2.0 (the "License");
687 * you may not use this file except in compliance with the License.
688 * You may obtain a copy of the License at
689 *
690 *   http://www.apache.org/licenses/LICENSE-2.0
691 *
692 * Unless required by applicable law or agreed to in writing, software
693 * distributed under the License is distributed on an "AS IS" BASIS,
694 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
695 * See the License for the specific language governing permissions and
696 * limitations under the License.
697 */async function Rn(n){if(n.code!==P.FAILED_PRECONDITION||n.message!==fm)throw n;O("LocalStore","Unexpectedly lost primary lease")}/**
698 * @license
699 * Copyright 2017 Google LLC
700 *
701 * Licensed under the Apache License, Version 2.0 (the "License");
702 * you may not use this file except in compliance with the License.
703 * You may obtain a copy of the License at
704 *
705 *   http://www.apache.org/licenses/LICENSE-2.0
706 *
707 * Unless required by applicable law or agreed to in writing, software
708 * distributed under the License is distributed on an "AS IS" BASIS,
709 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
710 * See the License for the specific language governing permissions and
711 * limitations under the License.
712 */class C{constructor(e){this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,e(t=>{this.isDone=!0,this.result=t,this.nextCallback&&this.nextCallback(t)},t=>{this.isDone=!0,this.error=t,this.catchCallback&&this.catchCallback(t)})}catch(e){return this.next(void 0,e)}next(e,t){return this.callbackAttached&&x(59440),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(t,this.error):this.wrapSuccess(e,this.result):new C((r,s)=>{this.nextCallback=o=>{this.wrapSuccess(e,o).next(r,s)},this.catchCallback=o=>{this.wrapFailure(t,o).next(r,s)}})}toPromise(){return new Promise((e,t)=>{this.next(e,t)})}wrapUserFunction(e){try{const t=e();return t instanceof C?t:C.resolve(t)}catch(t){return C.reject(t)}}wrapSuccess(e,t){return e?this.wrapUserFunction(()=>e(t)):C.resolve(t)}wrapFailure(e,t){return e?this.wrapUserFunction(()=>e(t)):C.reject(t)}static resolve(e){return new C((t,r)=>{t(e)})}static reject(e){return new C((t,r)=>{r(e)})}static waitFor(e){return new C((t,r)=>{let s=0,o=0,a=!1;e.forEach(u=>{++s,u.next(()=>{++o,a&&o===s&&t()},h=>r(h))}),a=!0,o===s&&t()})}static or(e){let t=C.resolve(!1);for(const r of e)t=t.next(s=>s?C.resolve(s):r());return t}static forEach(e,t){const r=[];return e.forEach((s,o)=>{r.push(t.call(this,s,o))}),this.waitFor(r)}static mapArray(e,t){return new C((r,s)=>{const o=e.length,a=new Array(o);let u=0;for(let h=0;h<o;h++){const d=h;t(e[d]).next(p=>{a[d]=p,++u,u===o&&r(a)},p=>s(p))}})}static doWhile(e,t){return new C((r,s)=>{const o=()=>{e()===!0?t().next(()=>{o()},s):r()};o()})}}function mm(n){const e=n.match(/Android ([\d.]+)/i),t=e?e[1].split(".").slice(0,2).join("."):"-1";return Number(t)}function Sn(n){return n.name==="IndexedDbTransactionError"}/**
713 * @license
714 * Copyright 2018 Google LLC
715 *
716 * Licensed under the Apache License, Version 2.0 (the "License");
717 * you may not use this file except in compliance with the License.
718 * You may obtain a copy of the License at
719 *
720 *   http://www.apache.org/licenses/LICENSE-2.0
721 *
722 * Unless required by applicable law or agreed to in writing, software
723 * distributed under the License is distributed on an "AS IS" BASIS,
724 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
725 * See the License for the specific language governing permissions and
726 * limitations under the License.
727 */class xs{constructor(e,t){this.previousValue=e,t&&(t.sequenceNumberHandler=r=>this.ae(r),this.ue=r=>t.writeSequenceNumber(r))}ae(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}next(){const e=++this.previousValue;return this.ue&&this.ue(e),e}}xs.ce=-1;/**
728 * @license
729 * Copyright 2017 Google LLC
730 *
731 * Licensed under the Apache License, Version 2.0 (the "License");
732 * you may not use this file except in compliance with the License.
733 * You may obtain a copy of the License at
734 *
735 *   http://www.apache.org/licenses/LICENSE-2.0
736 *
737 * Unless required by applicable law or agreed to in writing, software
738 * distributed under the License is distributed on an "AS IS" BASIS,
739 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
740 * See the License for the specific language governing permissions and
741 * limitations under the License.
742 */const vo=-1;function Fs(n){return n==null}function ms(n){return n===0&&1/n==-1/0}function gm(n){return typeof n=="number"&&Number.isInteger(n)&&!ms(n)&&n<=Number.MAX_SAFE_INTEGER&&n>=Number.MIN_SAFE_INTEGER}/**
743 * @license
744 * Copyright 2017 Google LLC
745 *
746 * Licensed under the Apache License, Version 2.0 (the "License");
747 * you may not use this file except in compliance with the License.
748 * You may obtain a copy of the License at
749 *
750 *   http://www.apache.org/licenses/LICENSE-2.0
751 *
752 * Unless required by applicable law or agreed to in writing, software
753 * distributed under the License is distributed on an "AS IS" BASIS,
754 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
755 * See the License for the specific language governing permissions and
756 * limitations under the License.
757 */const vl="�";function _m(n){let e="";for(let t=0;t<n.length;t++)e.length>0&&(e=$c(e)),e=ym(n.get(t),e);return $c(e)}function ym(n,e){let t=e;const r=n.length;for(let s=0;s<r;s++){const o=n.charAt(s);switch(o){case"\0":t+="��";break;case vl:t+="��";break;default:t+=o}}return t}function $c(n){return n+vl+"�"}/**
758 * @license
759 * Copyright 2017 Google LLC
760 *
761 * Licensed under the Apache License, Version 2.0 (the "License");
762 * you may not use this file except in compliance with the License.
763 * You may obtain a copy of the License at
764 *
765 *   http://www.apache.org/licenses/LICENSE-2.0
766 *
767 * Unless required by applicable law or agreed to in writing, software
768 * distributed under the License is distributed on an "AS IS" BASIS,
769 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
770 * See the License for the specific language governing permissions and
771 * limitations under the License.
772 */function zc(n){let e=0;for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&e++;return e}function xt(n,e){for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&e(t,n[t])}function Al(n){for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e))return!1;return!0}/**
773 * @license
774 * Copyright 2017 Google LLC
775 *
776 * Licensed under the Apache License, Version 2.0 (the "License");
777 * you may not use this file except in compliance with the License.
778 * You may obtain a copy of the License at
779 *
780 *   http://www.apache.org/licenses/LICENSE-2.0
781 *
782 * Unless required by applicable law or agreed to in writing, software
783 * distributed under the License is distributed on an "AS IS" BASIS,
784 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
785 * See the License for the specific language governing permissions and
786 * limitations under the License.
787 */class te{constructor(e,t){this.comparator=e,this.root=t||fe.EMPTY}insert(e,t){return new te(this.comparator,this.root.insert(e,t,this.comparator).copy(null,null,fe.BLACK,null,
787null))}remove(e){return new te(this.comparator,this.root.remove(e,this.comparator).copy(null,null,fe.BLACK,null,null))}get(e){let t=this.root;for(;!t.isEmpty();){const r=this.comparator(e,t.key);if(r===0)return t.value;r<0?t=t.left:r>0&&(t=t.right)}return null}indexOf(e){let t=0,r=this.root;for(;!r.isEmpty();){const s=this.comparator(e,r.key);if(s===0)return t+r.left.size;s<0?r=r.left:(t+=r.left.size+1,r=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(e){this.inorderTraversal((t,r)=>(e(t,r),!1))}toString(){const e=[];return this.inorderTraversal((t,r)=>(e.push(`${t}:${r}`),!1)),`{${e.join(", ")}}`}reverseTraversal(e){return this.root.reverseTraversal(e)}getIterator(){return new Yr(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new Yr(this.root,e,this.comparator,!1)}getReverseIterator(){return new Yr(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new Yr(this.root,e,this.comparator,!0)}}class Yr{constructor(e,t,r,s){this.isReverse=s,this.nodeStack=[];let o=1;for(;!e.isEmpty();)if(o=t?r(e.key,t):1,t&&s&&(o*=-1),o<0)e=this.isReverse?e.left:e.right;else{if(o===0){this.nodeStack.push(e);break}this.nodeStack.push(e),e=this.isReverse?e.right:e.left}}getNext(){let e=this.nodeStack.pop();const t={key:e.key,value:e.value};if(this.isReverse)for(e=e.left;!e.isEmpty();)this.nodeStack.push(e),e=e.right;else for(e=e.right;!e.isEmpty();)this.nodeStack.push(e),e=e.left;return t}hasNext(){return this.nodeStack.length>0}peek(){if(this.nodeStack.length===0)return null;const e=this.nodeStack[this.nodeStack.length-1];return{key:e.key,value:e.value}}}class fe{constructor(e,t,r,s,o){this.key=e,this.value=t,this.color=r??fe.RED,this.left=s??fe.EMPTY,this.right=o??fe.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,t,r,s,o){return new fe(e??this.key,t??this.value,r??this.color,s??this.left,o??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){let s=this;const o=r(e,s.key);return s=o<0?s.copy(null,null,null,s.left.insert(e,t,r),null):o===0?s.copy(null,t,null,null,null):s.copy(null,null,null,null,s.right.insert(e,t,r)),s.fixUp()}removeMin(){if(this.left.isEmpty())return fe.EMPTY;let e=this;return e.left.isRed()||e.left.left.isRed()||(e=e.moveRedLeft()),e=e.copy(null,null,null,e.left.removeMin(),null),e.fixUp()}remove(e,t){let r,s=this;if(t(e,s.key)<0)s.left.isEmpty()||s.left.isRed()||s.left.left.isRed()||(s=s.moveRedLeft()),s=s.copy(null,null,null,s.left.remove(e,t),null);else{if(s.left.isRed()&&(s=s.rotateRight()),s.right.isEmpty()||s.right.isRed()||s.right.left.isRed()||(s=s.moveRedRight()),t(e,s.key)===0){if(s.right.isEmpty())return fe.EMPTY;r=s.right.min(),s=s.copy(r.key,r.value,null,null,s.right.removeMin())}s=s.copy(null,null,null,null,s.right.remove(e,t))}return s.fixUp()}isRed(){return this.color}fixUp(){let e=this;return e.right.isRed()&&!e.left.isRed()&&(e=e.rotateLeft()),e.left.isRed()&&e.left.left.isRed()&&(e=e.rotateRight()),e.left.isRed()&&e.right.isRed()&&(e=e.colorFlip()),e}moveRedLeft(){let e=this.colorFlip();return e.right.left.isRed()&&(e=e.copy(null,null,null,null,e.right.rotateRight()),e=e.rotateLeft(),e=e.colorFlip()),e}moveRedRight(){let e=this.colorFlip();return e.left.left.isRed()&&(e=e.rotateRight(),e=e.colorFlip()),e}rotateLeft(){const e=this.copy(null,null,fe.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){const e=this.copy(null,null,fe.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip(){const e=this.left.copy(null,null,!this.left.color,null,null),t=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,t)}checkMaxDepth(){const e=this.check();return Math.pow(2,e)<=this.size+1}check(){if(this.isRed()&&this.left.isRed())throw x(43730,{key:this.key,value:this.value});if(this.right.isRed())throw x(14113,{key:this.key,value:this.value});const e=this.left.check();if(e!==this.right.check())throw x(27949);return e+(this.isRed()?0:1)}}fe.EMPTY=null,fe.RED=!0,fe.BLACK=!1;
787fe.EMPTY=new class{constructor(){this.size=0}get key(){throw x(57766)}get value(){throw x(16141)}get color(){throw x(16727)}get left(){throw x(29726)}get right(){throw x(36894)}copy(e,t,r,s,o){return this}insert(e,t,r){return new fe(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}};/**
788 * @license
789 * Copyright 2017 Google LLC
790 *
791 * Licensed under the Apache License, Version 2.0 (the "License");
792 * you may not use this file except in compliance with the License.
793 * You may obtain a copy of the License at
794 *
795 *   http://www.apache.org/licenses/LICENSE-2.0
796 *
797 * Unless required by applicable law or agreed to in writing, software
798 * distributed under the License is distributed on an "AS IS" BASIS,
799 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
800 * See the License for the specific language governing permissions and
801 * limitations under the License.
802 */class ce{constructor(e){this.comparator=e,this.data=new te(this.comparator)}has(e){return this.data.get(e)!==null}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(e){return this.data.indexOf(e)}forEach(e){this.data.inorderTraversal((t,r)=>(e(t),!1))}forEachInRange(e,t){const r=this.data.getIteratorFrom(e[0]);for(;r.hasNext();){const s=r.getNext();if(this.comparator(s.key,e[1])>=0)return;t(s.key)}}forEachWhile(e,t){let r;for(r=t!==void 0?this.data.getIteratorFrom(t):this.data.getIterator();r.hasNext();)if(!e(r.getNext().key))return}firstAfterOrEqual(e){const t=this.data.getIteratorFrom(e);return t.hasNext()?t.getNext().key:null}getIterator(){return new Hc(this.data.getIterator())}getIteratorFrom(e){return new Hc(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(r=>{t=t.add(r)}),t}isEqual(e){if(!(e instanceof ce)||this.size!==e.size)return!1;const t=this.data.getIterator(),r=e.data.getIterator();for(;t.hasNext();){const s=t.getNext().key,o=r.getNext().key;if(this.comparator(s,o)!==0)return!1}return!0}toArray(){const e=[];return this.forEach(t=>{e.push(t)}),e}toString(){const e=[];return this.forEach(t=>e.push(t)),"SortedSet("+e.toString()+")"}copy(e){const t=new ce(this.comparator);return t.data=e,t}}class Hc{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}/**
803 * @license
804 * Copyright 2020 Google LLC
805 *
806 * Licensed under the Apache License, Version 2.0 (the "License");
807 * you may not use this file except in compliance with the License.
808 * You may obtain a copy of the License at
809 *
810 *   http://www.apache.org/licenses/LICENSE-2.0
811 *
812 * Unless required by applicable law or agreed to in writing, software
813 * distributed under the License is distributed on an "AS IS" BASIS,
814 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
815 * See the License for the specific language governing permissions and
816 * limitations under the License.
817 */class Ve{constructor(e){this.fields=e,e.sort(me.comparator)}static empty(){return new Ve([])}unionWith(e){let t=new ce(me.comparator);for(const r of this.fields)t=t.add(r);for(const r of e)t=t.add(r);return new Ve(t.toArray())}covers(e){for(const t of this.fields)if(t.isPrefixOf(e))return!0;return!1}isEqual(e){return mn(this.fields,e.fields,(t,r)=>t.isEqual(r))}}/**
818 * @license
819 * Copyright 2023 Google LLC
820 *
821 * Licensed under the Apache License, Version 2.0 (the "License");
822 * you may not use this file except in compliance with the License.
823 * You may obtain a copy of the License at
824 *
825 *   http://www.apache.org/licenses/LICENSE-2.0
826 *
827 * Unless required by applicable law or agreed to in writing, software
828 * distributed under the License is distributed on an "AS IS" BASIS,
829 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
830 * See the License for the specific language governing permissions and
831 * limitations under the License.
832 */class Rl extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}/**
833 * @license
834 * Copyright 2020 Google LLC
835 *
836 * Licensed under the Apache License, Version 2.0 (the "License");
837 * you may not use this file except in compliance with the License.
838 * You may obtain a copy of the License at
839 *
840 *   http://www.apache.org/licenses/LICENSE-2.0
841 *
842 * Unless required by applicable law or agreed to in writing, software
843 * distributed under the License is distributed on an "AS IS" BASIS,
844 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
845 * See the License for the specific language governing permissions and
846 * limitations under the License.
847 */class ge{constructor(e){this.binaryString=e}static fromBase64String(e){const t=function(s){try{return atob(s)}catch(o){throw typeof DOMException<"u"&&o instanceof DOMException?new Rl("Invalid base64 string: "+o):o}}(e);return new ge(t)}static fromUint8Array(e){const t=function(s){let o="";for(let a=0;a<s.length;++a)o+=String.fromCharCode(s[a]);return o}(e);return new ge(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 function(t){return btoa(t)}(this.binaryString)}toUint8Array(){return function(t){const r=new Uint8Array(t.length);for(let s=0;s<t.length;s++)r[s]=t.charCodeAt(s);return r}(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(e){return $(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}}ge.EMPTY_BYTE_STRING=new ge("");const Em=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function Vt(n){if(Q(!!n,39018),typeof n=="string"){let e=0;const t=Em.exec(n);if(Q(!!t,46558,{timestamp:n}),t[1]){let s=t[1];s=(s+"000000000").substr(0,9),e=Number(s)}const r=new Date(n);return{seconds:Math.floor(r.getTime()/1e3),nanos:e}}return{seconds:re(n.seconds),nanos:re(n.nanos)}}function re(n){return typeof n=="number"?n:typeof n=="string"?Number(n):0}function Dt(n){return typeof n=="string"?ge.fromBase64String(n):ge.fromUint8Array(n)}/**
848 * @license
849 * Copyright 2020 Google LLC
850 *
851 * Licensed under the Apache License, Version 2.0 (the "License");
852 * you may not use this file except in compliance with the License.
853 * You may obtain a copy of the License at
854 *
855 *   http://www.apache.org/licenses/LICENSE-2.0
856 *
857 * Unless required by applicable law or agreed to in writing, software
858 * distributed under the License is distributed on an "AS IS" BASIS,
859 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
860 * See the License for the specific language governing permissions and
861 * limitations under the License.
862 */const Sl="server_timestamp",Pl="__type__",Cl="__previous_value__",bl="__local_write_time__";function Ao(n){var t,r;return((r=(((t=n==null?void 0:n.mapValue)==null?void 0:t.fields)||{})[Pl])==null?void 0:r.stringValue)===Sl}function Us(n){const e=n.mapValue.fields[Cl];return Ao(e)?Us(e):e}function lr(n){const e=Vt(n.mapValue.fields[bl].timestampValue);return new Z(e.seconds,e.nanos)}/**
863 * @license
864 * Copyright 2017 Google LLC
865 *
866 * Licensed under the Apache License, Version 2.0 (the "License");
867 * you may not use this file except in compliance with the License.
868 * You may obtain a copy of the License at
869 *
870 *   http://www.apache.org/licenses/LICENSE-2.0
871 *
872 * Unless required by applicable law or agreed to in writing, software
873 * distributed under the License is distributed on an "AS IS" BASIS,
874 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
875 * See the License for the specific language governing permissions and
876 * limitations under the License.
877 */class Tm{constructor(e,t,r,s,o,a,u,h,d,p){this.databaseId=e,this.appId=t,this.persistenceKey=r,this.host=s,this.ssl=o,this.forceLongPolling=a,this.autoDetectLongPolling=u,this.longPollingOptions=h,this.useFetchStreams=d,this.isUsingEmulator=p}}const gs="(default)";class hr{constructor(e,t){this.projectId=e,this.database=t||gs}static empty(){return new hr("","")}get isDefaultDatabase(){return this.database===gs}isEqual(e){return e instanceof hr&&e.projectId===this.projectId&&e.database===this.database}}/**
878 * @license
879 * Copyright 2020 Google LLC
880 *
881 * Licensed under the Apache License, Version 2.0 (the "License");
882 * you may not use this file except in compliance with the License.
883 * You may obtain a copy of the License at
884 *
885 *   http://www.apache.org/licenses/LICENSE-2.0
886 *
887 * Unless required by applicable law or agreed to in writing, software
888 * distributed under the License is distributed on an "AS IS" BASIS,
889 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
890 * See the License for the specific language governing permissions and
891 * limitations under the License.
892 */const kl="__type__",Im="__max__",Xr={mapValue:{}},Nl="__vector__",_s="value";function Ot(n){return"nullValue"in n?0:"booleanValue"in n?1:"integerValue"in n||"doubleValue"in n?2:"timestampValue"in n?3:"stringValue"in n?5:"bytesValue"in n?6:"referenceValue"in n?7:"geoPointValue"in n?8:"arrayValue"in n?9:"mapValue"in n?Ao(n)?4:vm(n)?9007199254740991:wm(n)?10:11:x(28295,{value:n})}function Ye(n,e){if(n===e)return!0;const t=Ot(n);if(t!==Ot(e))return!1;switch(t){case 0:case 9007199254740991:return!0;case 1:return n.booleanValue===e.booleanValue;case 4:return lr(n).isEqual(lr(e));case 3:return function(s,o){if(typeof s.timestampValue=="string"&&typeof o.timestampValue=="string"&&s.timestampValue.length===o.timestampValue.length)return s.timestampValue===o.timestampValue;const a=Vt(s.timestampValue),u=Vt(o.timestampValue);return a.seconds===u.seconds&&a.nanos===u.nanos}(n,e);case 5:return n.stringValue===e.stringValue;case 6:return function(s,o){return Dt(s.bytesValue).isEqual(Dt(o.bytesValue))}(n,e);case 7:return n.referenceValue===e.referenceValue;case 8:return function(s,o){return re(s.geoPointValue.latitude)===re(o.geoPointValue.latitude)&&re(s.geoPointValue.longitude)===re(o.geoPointValue.longitude)}(n,e);case 2:return function(s,o){if("integerValue"in s&&"integerValue"in o)return re(s.integerValue)===re(o.integerValue);if("doubleValue"in s&&"doubleValue"in o){const a=re(s.doubleValue),u=re(o.doubleValue);return a===u?ms(a)===ms(u):isNaN(a)&&isNaN(u)}return!1}(n,e);case 9:return mn(n.arrayValue.values||[],e.arrayValue.values||[],Ye);case 10:case 11:return function(s,o){const a=s.mapValue.fields||{},u=o.mapValue.fields||{};if(zc(a)!==zc(u))return!1;for(const h in a)if(a.hasOwnProperty(h)&&(u[h]===void 0||!Ye(a[h],u[h])))return!1;return!0}(n,e);default:return x(52216,{left:n})}}function dr(n,e){return(n.values||[]).find(t=>Ye(t,e))!==void 0}function gn(n,e){if(n===e)return 0;const t=Ot(n),r=Ot(e);if(t!==r)return $(t,r);switch(t){case 0:case 9007199254740991:return 0;case 1:return $(n.booleanValue,e.booleanValue);case 2:return function(o,a){const u=re(o.integerValue||o.doubleValue),h=re(a.integerValue||a.doubleValue);return u<h?-1:u>h?1:u===h?0:isNaN(u)?isNaN(h)?0:-1:1}(n,e);case 3:return Wc(n.timestampValue,e.timestampValue);case 4:return Wc(lr(n),lr(e));case 5:return Qi(n.stringValue,e.stringValue);case 6:return function(o,a){const u=Dt(o),h=Dt(a);return u.compareTo(h)}(n.bytesValue,e.bytesValue);case 7:return function(o,a){const u=o.split("/"),h=a.split("/");for(let d=0;d<u.length&&d<h.length;d++){const p=$(u[d],h[d]);if(p!==0)return p}return $(u.length,h.length)}(n.referenceValue,e.referenceValue);case 8:return function(o,a){const u=$(re(o.latitude),re(a.latitude));return u!==0?u:$(re(o.longitude),re(a.longitude))}(n.geoPointValue,e.geoPointValue);case 9:return Gc(n.arrayValue,e.arrayValue);case 10:return function(o,a){var E,S,b,D;const u=o.fields||{},h=a.fields||{},d=(E=u[_s])==null?void 0:E.arrayValue,p=(S=h[_s])==null?void 0:S.arrayValue,_=$(((b=d==null?void 0:d.values)==null?void 0:b.length)||0,((D=p==null?void 0:p.values)==null?void 0:D.length)||0);return _!==0?_:Gc(d,p)}(n.mapValue,e.mapValue);case 11:return function(o,a){if(o===Xr.mapValue&&a===Xr.mapValue)return 0;if(o===Xr.mapValue)return 1;if(a===Xr.mapValue)return-1;const u=o.fields||{},h=Object.keys(u),d=a.fields||{},p=Object.keys(d);h.sort(),p.sort();for(let _=0;_<h.length&&_<p.length;++_){const E=Qi(h[_],p[_]);if(E!==0)return E;const S=gn(u[h[_]],d[p[_]]);if(S!==0)return S}return $(h.length,p.length)}(n.mapValue,e.mapValue);default:throw x(23264,{he:t})}}function Wc(n,e){if(typeof n=="string"&&typeof e=="string"&&n.length===e.length)return $(n,e);const t=Vt(n),r=Vt(e),s=$(t.seconds,r.seconds);return s!==0?s:$(t.nanos,r.nanos)}function Gc(n,e){const t=n.values||[],r=e.values||[];for(let s=0;s<t.length&&s<r.length;++s){const o=gn(t[s],r[s]);if(o)return o}return $(t.length,r.length)}function _n(n){return Ji(n)}function Ji(n){return"nullValue"in n?"null":"booleanValue"in n?""+n.booleanValue:"integerValue"in n?""+n.integerValue:"doubleValue"in n?""+n.doubleValue:"timestampValue"in n?function(t){const r=Vt(t);return`time(${r.seconds},${r.nanos})`}(n.timestampValue):"stringValue"in n?n.stringValue:"bytesValue"in n?function(t){return Dt(t).toBase64()}(n.bytesValue):"referenceValue"in n?function(t){return L.fromName(t).toString()}(n.referenceValue):"geoPointValue"in n?function(t){return`geo(${t.latitude},${t.longitude})`}(n.geoPointValue):"arrayValue"in n?function(t){let r="[",s=!0;for(const o of t.values||[])s?s=!1:r+=",",r+=Ji(o);return r+"]"}(n.arrayValue):"mapValue"in n?function(t){const r=Object.keys(t.fields||{}).sort();let s="{",o=!0;for(const a of r)o?o=!1:s+=",",s+=`${a}:${Ji(t.fields[a])}`;return s+"}"}(n.mapValue):x(61005,{value:n})}function rs(n){switch(Ot(n)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:const e=Us(n);return e?16+rs(e):16;case 5:return 2*n.stringValue.length;case 6:return Dt(n.bytesValue).approximateByteSize();case 7:return n.referenceValue.length;case 9:return function(r){return(r.values||[]).reduce((s,o)=>s+rs(o),0)}(n.arrayValue);case 10:case 11:return function(r){let s=0;return xt(r.fields,(o,a)=>{s+=o.length+rs(a)}),s}(n.mapValue);default:throw x(13486,{value:n})}}function Kc(n,e){return{referenceValue:`projects/${n.projectId}/databases/${n.database}/documents/${e.path.canonicalString()}`}}function Yi(n){return!!n&&"integerValue"in n}function Ro(n){return!!n&&"arrayValue"in n}function Qc(n){return!!n&&"nullValue"in n}
892function Jc(n){return!!n&&"doubleValue"in n&&isNaN(Number(n.doubleValue))}function ss(n){return!!n&&"mapValue"in n}function wm(n){var t,r;return((r=(((t=n==null?void 0:n.mapValue)==null?void 0:t.fields)||{})[kl])==null?void 0:r.stringValue)===Nl}function nr(n){if(n.geoPointValue)return{geoPointValue:{...n.geoPointValue}};if(n.timestampValue&&typeof n.timestampValue=="object")return{timestampValue:{...n.timestampValue}};if(n.mapValue){const e={mapValue:{fields:{}}};return xt(n.mapValue.fields,(t,r)=>e.mapValue.fields[t]=nr(r)),e}if(n.arrayValue){const e={arrayValue:{values:[]}};for(let t=0;t<(n.arrayValue.values||[]).length;++t)e.arrayValue.values[t]=nr(n.arrayValue.values[t]);return e}return{...n}}function vm(n){return(((n.mapValue||{}).fields||{}).__type__||{}).stringValue===Im}/**
893 * @license
894 * Copyright 2017 Google LLC
895 *
896 * Licensed under the Apache License, Version 2.0 (the "License");
897 * you may not use this file except in compliance with the License.
898 * You may obtain a copy of the License at
899 *
900 *   http://www.apache.org/licenses/LICENSE-2.0
901 *
902 * Unless required by applicable law or agreed to in writing, software
903 * distributed under the License is distributed on an "AS IS" BASIS,
904 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
905 * See the License for the specific language governing permissions and
906 * limitations under the License.
907 */class be{constructor(e){this.value=e}static empty(){return new be({mapValue:{}})}field(e){if(e.isEmpty())return this.value;{let t=this.value;for(let r=0;r<e.length-1;++r)if(t=(t.mapValue.fields||{})[e.get(r)],!ss(t))return null;return t=(t.mapValue.fields||{})[e.lastSegment()],t||null}}set(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=nr(t)}setAll(e){let t=me.emptyPath(),r={},s=[];e.forEach((a,u)=>{if(!t.isImmediateParentOf(u)){const h=this.getFieldsMap(t);this.applyChanges(h,r,s),r={},s=[],t=u.popLast()}a?r[u.lastSegment()]=nr(a):s.push(u.lastSegment())});const o=this.getFieldsMap(t);this.applyChanges(o,r,s)}delete(e){const t=this.field(e.popLast());ss(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return Ye(this.value,e.value)}getFieldsMap(e){let t=this.value;t.mapValue.fields||(t.mapValue={fields:{}});for(let r=0;r<e.length;++r){let s=t.mapValue.fields[e.get(r)];ss(s)&&s.mapValue.fields||(s={mapValue:{fields:{}}},t.mapValue.fields[e.get(r)]=s),t=s}return t.mapValue.fields}applyChanges(e,t,r){xt(t,(s,o)=>e[s]=o);for(const s of r)delete e[s]}clone(){return new be(nr(this.value))}}function Vl(n){const e=[];return xt(n.fields,(t,r)=>{const s=new me([t]);if(ss(r)){const o=Vl(r.mapValue).fields;
907if(o.length===0)e.push(s);else for(const a of o)e.push(s.child(a))}else e.push(s)}),new Ve(e)}/**
908 * @license
909 * Copyright 2017 Google LLC
910 *
911 * Licensed under the Apache License, Version 2.0 (the "License");
912 * you may not use this file except in compliance with the License.
913 * You may obtain a copy of the License at
914 *
915 *   http://www.apache.org/licenses/LICENSE-2.0
916 *
917 * Unless required by applicable law or agreed to in writing, software
918 * distributed under the License is distributed on an "AS IS" BASIS,
919 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
920 * See the License for the specific language governing permissions and
921 * limitations under the License.
922 */class we{constructor(e,t,r,s,o,a,u){this.key=e,this.documentType=t,this.version=r,this.readTime=s,this.createTime=o,this.data=a,this.documentState=u}static newInvalidDocument(e){return new we(e,0,F.min(),F.min(),F.min(),be.empty(),0)}static newFoundDocument(e,t,r,s){return new we(e,1,t,F.min(),r,s,0)}static newNoDocument(e,t){return new we(e,2,t,F.min(),F.min(),be.empty(),0)}static newUnknownDocument(e,t){return new we(e,3,t,F.min(),F.min(),be.empty(),2)}convertToFoundDocument(e,t){return!this.createTime.isEqual(F.min())||this.documentType!==2&&this.documentType!==0||(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=be.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=be.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=F.min(),this}setReadTime(e){return this.readTime=e,this}get hasLocalMutations(){return this.documentState===1}get hasCommittedMutations(){return this.documentState===2}get hasPendingWrites(){return this.hasLocalMutations||this.hasCommittedMutations}isValidDocument(){return this.documentType!==0}isFoundDocument(){return this.documentType===1}isNoDocument(){return this.documentType===2}isUnknownDocument(){return this.documentType===3}isEqual(e){return e instanceof we&&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 we(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}})`}}/**
923 * @license
924 * Copyright 2022 Google LLC
925 *
926 * Licensed under the Apache License, Version 2.0 (the "License");
927 * you may not use this file except in compliance with the License.
928 * You may obtain a copy of the License at
929 *
930 *   http://www.apache.org/licenses/LICENSE-2.0
931 *
932 * Unless required by applicable law or agreed to in writing, software
933 * distributed under the License is distributed on an "AS IS" BASIS,
934 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
935 * See the License for the specific language governing permissions and
936 * limitations under the License.
937 */class ys{constructor(e,t){this.position=e,this.inclusive=t}}function Yc(n,e,t){let r=0;for(let s=0;s<n.position.length;s++){const o=e[s],a=n.position[s];if(o.field.isKeyField()?r=L.comparator(L.fromName(a.referenceValue),t.key):r=gn(a,t.data.field(o.field)),o.dir==="desc"&&(r*=-1),r!==0)break}return r}function Xc(n,e){if(n===null)return e===null;if(e===null||n.inclusive!==e.inclusive||n.position.length!==e.position.length)return!1;for(let t=0;t<n.position.length;t++)if(!Ye(n.position[t],e.position[t]))return!1;return!0}/**
938 * @license
939 * Copyright 2022 Google LLC
940 *
941 * Licensed under the Apache License, Version 2.0 (the "License");
942 * you may not use this file except in compliance with the License.
943 * You may obtain a copy of the License at
944 *
945 *   http://www.apache.org/licenses/LICENSE-2.0
946 *
947 * Unless required by applicable law or agreed to in writing, softw
947are
948 * distributed under the License is distributed on an "AS IS" BASIS,
949 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
950 * See the License for the specific language governing permissions and
951 * limitations under the License.
952 */class fr{constructor(e,t="asc"){this.field=e,this.dir=t}}function Am(n,e){return n.dir===e.dir&&n.field.isEqual(e.field)}/**
953 * @license
954 * Copyright 2022 Google LLC
955 *
956 * Licensed under the Apache License, Version 2.0 (the "License");
957 * you may not use this file except in compliance with the License.
958 * You may obtain a copy of the License at
959 *
960 *   http://www.apache.org/licenses/LICENSE-2.0
961 *
962 * Unless required by applicable law or agreed to in writing, software
963 * distributed under the License is distributed on an "AS IS" BASIS,
964 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
965 * See the License for the specific language governing permissions and
966 * limitations under the License.
967 */class Dl{}class oe extends Dl{constructor(e,t,r){super(),this.field=e,this.op=t,this.value=r}static create(e,t,r){return e.isKeyField()?t==="in"||t==="not-in"?this.createKeyFieldInFilter(e,t,r):new Sm(e,t,r):t==="array-contains"?new bm(e,r):t==="in"?new km(e,r):t==="not-in"?new Nm(e,r):t==="array-contains-any"?new Vm(e,r):new oe(e,t,r)}static createKeyFieldInFilter(e,t,r){return t==="in"?new Pm(e,r):new Cm(e,r)}matches(e){const t=e.data.field(this.field);return this.op==="!="?t!==null&&t.nullValue===void 0&&this.matchesComparison(gn(t,this.value)):t!==null&&Ot(this.value)===Ot(t)&&this.matchesComparison(gn(t,this.value))}matchesComparison(e){switch(this.op){case"<":return e<0;case"<=":return e<=0;case"==":return e===0;case"!=":return e!==0;case">":return e>0;case">=":return e>=0;default:return x(47266,{operator:this.op})}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class qe extends Dl{constructor(e,t){super(),this.filters=e,this.op=t,this.Pe=null}static create(e,t){return new qe(e,t)}matches(e){return Ol(this)?this.filters.find(t=>!t.matches(e))===void 0:this.filters.find(t=>t.matches(e))!==void 0}getFlattenedFilters(){return this.Pe!==null||(this.Pe=this.filters.reduce((e,t)=>e.concat(t.getFlattenedFilters()),[])),this.Pe}getFilters(){return Object.assign([],this.filters)}}function Ol(n){return n.op==="and"}function Ml(n){return Rm(n)&&Ol(n)}function Rm(n){for(const e of n.filters)if(e instanceof qe)return!1;return!0}function Xi(n){if(n instanceof oe)return n.field.canonicalString()+n.op.toString()+_n(n.value);if(Ml(n))return n.filters.map(e=>Xi(e)).join(",");{const e=n.filters.map(t=>Xi(t)).join(",");return`${n.op}(${e})`}}function Ll(n,e){return n instanceof oe?function(r,s){return s instanceof oe&&r.op===s.op&&r.field.isEqual(s.field)&&Ye(r.value,s.value)}(n,e):n instanceof qe?function(r,s){return s instanceof qe&&r.op===s.op&&r.filters.length===s.filters.length?r.filters.reduce((o,a,u)=>o&&Ll(a,s.filters[u]),!0):!1}(n,e):void x(19439)}function xl(n){return n instanceof oe?function(t){return`${t.field.canonicalString()} ${t.op} ${_n(t.value)}`}(n):n instanceof qe?function(t){return t.op.toString()+" {"+t.getFilters().map(xl).join(" ,")+"}"}(n):"Filter"}class Sm extends oe{constructor(e,t,r){super(e,t,r),this.key=L.fromName(r.referenceValue)}matches(e){const t=L.comparator(e.key,this.key);return this.matchesComparison(t)}}class Pm extends oe{constructor(e,t){super(e,"in",t),this.keys=Fl("in",t)}matches(e){return this.keys.some(t=>t.isEqual(e.key))}}class Cm extends oe{constructor(e,t){super(e,"not-in",t),this.keys=Fl("not-in",t)}matches(e){return!this.keys.some(t=>t.isEqual(e.key))}}function Fl(n,e){var t;return(((t=e.arrayValue)==null?void 0:t.values)||[]).map(r=>L.fromName(r.referenceValue))}class bm extends oe{constructor(e,t){super(e,"array-contains",t)}matches(e){const t=e.data.field(this.field);return Ro(t)&&dr(t.arrayValue,this.value)}}class km extends oe{constructor(e,t){super(e,"in",t)}matches(e){const t=e.data.field(this.field);return t!==null&&dr(this.value.arrayValue,t)}}class Nm extends oe{constructor(e,t){super(e,"not-in",t)}matches(e){if(dr(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const t=e.data.field(this.field);return t!==null&&t.nullValue===void 0&&!dr(this.value.arrayValue,t)}}class Vm extends oe{constructor(e,t){super(e,"array-contains-any",t)}matches(e){const t=e.data.field(this.field);return!(!Ro(t)||!t.arrayValue.values)&&t.arrayValue.values.some(r=>dr(this.value.arrayValue,r))}}/**
968 * @license
969 * Copyright 2019 Google LLC
970 *
971 * Licensed under the Apache License, Version 2.0 (the "License");
972 * you may not use this file except in compliance with the License.
973 * You may obtain a copy of the License at
974 *
975 *   http://www.apache.org/licenses/LICENSE-2.0
976 *
977 * Unless required by applicable law or agreed to in writing, software
978 * distributed under the License is distributed on an "AS IS" BASIS,
979 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
980 * See the License for the specific language governing permissions and
981 * limitations under the License.
982 */class Dm{constructor(e,t=null,r=[],s=[],o=null,a=null,u=null){this.path=e,this.collectionGroup=t,this.orderBy=r,this.filters=s,this.limit=o,this.startAt=a,this.endAt=u,this.Te=null}}function Zc(n,e=null,t=[],r=[],s=null,o=null,a=null){return new Dm(n,e,t,r,s,o,a)}function So(n){const e=U(n);if(e.Te===null){let t=e.path.canonicalString();e.collectionGroup!==null&&(t+="|cg:"+e.collectionGroup),t+="|f:",t+=e.filters.map(r=>Xi(r)).join(","),t+="|ob:",t+=e.orderBy.map(r=>function(o){return o.field.canonicalString()+o.dir}(r)).join(","),Fs(e.limit)||(t+="|l:",t+=e.limit),e.startAt&&(t+="|lb:",t+=e.startAt.inclusive?"b:":"a:",t+=e.startAt.position.map(r=>_n(r)).join(",")),e.endAt&&(t+="|ub:",t+=e.endAt.inclusive?"a:":"b:",t+=e.endAt.position.map(r=>_n(r)).join(",")),e.Te=t}return e.Te}function Po(n,e){if(n.limit!==e.limit||n.orderBy.length!==e.orderBy.length)return!1;for(let t=0;t<n.orderBy.length;t++)if(!Am(n.orderBy[t],e.orderBy[t]))return!1;if(n.filters.length!==e.filters.length)return!1;for(let t=0;t<n.filters.length;t++)if(!Ll(n.filters[t],e.filters[t]))return!1;return n.collectionGroup===e.collectionGroup&&!!n.path.isEqual(e.path)&&!!Xc(n.startAt,e.startAt)&&Xc(n.endAt,e.endAt)}function Zi(n){return L.isDocumentKey(n.path)&&n.collectionGroup===null&&n.filters.length===0}/**
983 * @license
984 * Copyright 2017 Google LLC
985 *
986 * Licensed under the Apache License, Version 2.0 (the "License");
987 * you may not use this file except in compliance with the License.
988 * You may obtain a copy of the License at
989 *
990 *   http://www.apache.org/licenses/LICENSE-2.0
991 *
992 * Unless required by applicable law or agreed to in writing, software
993 * distributed under the License is distributed on an "AS IS" BASIS,
994 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
995 * See the License for the specific language governing permissions and
996 * limitations under the License.
997 */class Pn{constructor(e,t=null,r=[],s=[],o=null,a="F",u=null,h=null){this.path=e,this.collectionGroup=t,this.explicitOrderBy=r,this.filters=s,this.limit=o,this.limitType=a,this.startAt=u,this.endAt=h,this.Ie=null,this.Ee=null,this.de=null,this.startAt,this.endAt}}function Om(n,e,t,r,s,o,a,u){return new Pn(n,e,t,r,s,o,a,u)}function Bs(n){return new Pn(n)}function eu(n){return n.filters.length===0&&n.limit===null&&n.startAt==null&&n.endAt==null&&(n.explicitOrderBy.length===0||n.explicitOrderBy.length===1&&n.explicitOrderBy[0].field.isKeyField())}function Ul(n){return n.collectionGroup!==null}function rr(n){const e=U(n);if(e.Ie===null){e.Ie=[];const t=new Set;for(const o of e.explicitOrderBy)e.Ie.push(o),t.add(o.field.canonicalString());const r=e.explicitOrderBy.length>0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";(function(a){let u=new ce(me.comparator);return a.filters.forEach(h=>{h.getFlattenedFilters().forEach(d=>{d.isInequality()&&(u=u.add(d.field))})}),u})(e).forEach(o=>{t.has(o.canonicalString())||o.isKeyField()||e.Ie.push(new fr(o,r))}),t.has(me.keyField().canonicalString())||e.Ie.push(new fr(me.keyField(),r))}return e.Ie}function We(n){const e=U(n);return e.Ee||(e.Ee=Mm(e,rr(n))),e.Ee}function Mm(n,e){if(n.limitType==="F")return Zc(n.path,n.collectionGroup,e,n.filters,n.limit,n.startAt,n.endAt);{e=e.map(s=>{const o=s.dir==="desc"?"asc":"desc";return new fr(s.field,o)});const t=n.endAt?new ys(n.endAt.position,n.endAt.inclusive):null,r=n.startAt?new ys(n.startAt.position,n.startAt.inclusive):null;return Zc(n.path,n.collectionGroup,e,n.filters,n.limit,t,r)}}function eo(n,e){const t=n.filters.concat([e]);return new Pn(n.path,n.collectionGroup,n.explicitOrderBy.slice(),t,n.limit,n.limitType,n.startAt,n.endAt)}function Es(n,e,t){return new Pn(n.path,n.collectionGroup,n.explicitOrderBy.slice(),n.filters.slice(),e,t,n.startAt,n.endAt)}function qs(n,e){return Po(We(n),We(e))&&n.limitType===e.limitType}function Bl(n){return`${So(We(n))}|lt:${n.limitType}`}function un(n){return`Query(target=${function(t){let r=t.path.canonicalString();return t.collectionGroup!==null&&(r+=" collectionGroup="+t.collectionGroup),t.filters.length>0&&(r+=`, filters: [${t.filters.map(s=>xl(s)).join(", ")}]`),Fs(t.limit)||(r+=", limit: "+t.limit),t.orderBy.length>0&&(r+=`, orderBy: [${t.orderBy.map(s=>function(a){return`${a.field.canonicalString()} (${a.dir})`}(s)).join(", ")}]`),t.startAt&&(r+=", startAt: ",r+=t.startAt.inclusive?"b:":"a:",r+=t.startAt.position.map(s=>_n(s)).join(",")),t.endAt&&(r+=", endAt: ",r+=t.endAt.inclusive?"a:":"b:",r+=t.endAt.position.map(s=>_n(s)).join(",")),`Target(${r})`}(We(n))}; limitType=${n.limitType})`}function js(n,e){return e.isFoundDocument()&&function(r,s){const o=s.key.path;return r.collectionGroup!==null?s.key.hasCollectionId(r.collectionGroup)&&r.path.isPrefixOf(o):L.isDocumentKey(r.path)?r.path.isEqual(o):r.path.isImmediateParentOf(o)}(n,e)&&function(r,s){for(const o of rr(r))if(!o.field.isKeyField()&&s.data.field(o.field)===null)return!1;return!0}(n,e)&&function(r,s){for(const o of r.filters)if(!o.matches(s))return!1;return!0}(n,e)&&function(r,s){return!(r.startAt&&!function(a,u,h){const d=Yc(a,u,h);return a.inclusive?d<=0:d<0}(r.startAt,rr(r),s)||r.endAt&&!function(a,u,h){const d=Yc(a,u,h);return a.inclusive?d>=0:d>0}(r.endAt,rr(r),s))}(n,e)}function Lm(n){return n.collectionGroup||(n.path.length%2==1?n.path.lastSegment():n.path.get(n.path.length-2))}function ql(n){return(e,t)=>{let r=!1;for(const s of rr(n)){const o=xm(s,e,t);if(o!==0)return o;r=r||s.field.isKeyField()}return 0}}function xm(n,e,t){const r=n.field.isKeyField()?L.comparator(e.key,t.key):function(o,a,u){const h=a.data.field(o),d=u.data.field(o);return h!==null&&d!==null?gn(h,d):x(42886)}(n.field,e,t);switch(n.dir){case"asc":return r;case"desc":return-1*r;default:return x(19790,{direction:n.dir})}}/**
998 * @license
999 * Copyright 2017 Google LLC
1000 *
1001 * Licensed under the Apache License, Version 2.0 (the "License");
1002 * you may not use this file except in compliance with the License.
1003 * You may obtain a copy of the License at
1004 *
1005 *   http://www.apache.org/licenses/LICENSE-2.0
1006 *
1007 * Unless required by applicable law or agreed to in writing, software
1008 * distributed under the License is distributed on an "AS IS" BASIS,
1009 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1010 * See the License for the specific language governing permissions and
1011 * limitations under the License.
1012 */class Xt{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.innerSize=0}get(e){const t=this.mapKeyFn(e),r=this.inner[t];if(r!==void 0){for(const[s,o]of r)if(this.equalsFn(s,e))return o}}has(e){return this.get(e)!==void 0}set(e,t){const r=this.mapKeyFn(e),s=this.inner[r];if(s===void 0)return this.inner[r]=[[e,t]],void this.innerSize++;for(let o=0;o<s.length;o++)if(this.equalsFn(s[o][0],e))return void(s[o]=[e,t]);s.push([e,t]),this.innerSize++}delete(e){const t=this.mapKeyFn(e),r=this.inner[t];if(r===void 0)return!1;for(let s=0;s<r.length;s++)if(this.equalsFn(r[s][0],e))return r.length===1?delete this.inner[t]:r.splice(s,1),this.innerSize--,!0;return!1}forEach(e){xt(this.inner,(t,r)=>{for(const[s,o]of r)e(s,o)})}isEmpty(){return Al(this.inner)}size(){return this.innerSize}}/**
1013 * @license
1014 * Copyright 2017 Google LLC
1015 *
1016 * Licensed under the Apache License, Version 2.0 (the "License");
1017 * you may not use this file except in compliance with the License.
1018 * You may obtain a copy of the License at
1019 *
1020 *   http://www.apache.org/licenses/LICENSE-2.0
1021 *
1022 * Unless required by applicable law or agreed to in writing, software
1023 * distributed under the License is distributed on an "AS IS" BASIS,
1024 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1025 * See the License for the specific language governing permissions and
1026 * limitations under the License.
1027 */const Fm=new te(L.comparator);function dt(){return Fm}const jl=new te(L.comparator);function Xn(...n){let e=jl;for(const t of n)e=e.insert(t.key,t);return e}function $l(n){let e=jl;return n.forEach((t,r)=>e=e.insert(t,r.overlayedDocument)),e}function zt(){return sr()}function zl(){return sr()}function sr(){return new Xt(n=>n.toString(),(n,e)=>n.isEqual(e))}const Um=new te(L.comparator),Bm=new ce(L.comparator);function z(...n){let e=Bm;for(const t of n)e=e.add(t);return e}const qm=new ce($);function jm(){return qm}/**
1028 * @license
1029 * Copyright 2020 Google LLC
1030 *
1031 * Licensed under the Apache License, Version 2.0 (the "License");
1032 * you may not use this file except in compliance with the License.
1033 * You may obtain a copy of the License at
1034 *
1035 *   http://www.apache.org/licenses/LICENSE-2.0
1036 *
1037 * Unless required by applicable law or agreed to in writing, software
1038 * distributed under the License is distributed on an "AS IS" BASIS,
1039 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1040 * See the License for the specific language governing permissions and
1041 * limitations under the License.
1042 */function Co(n,e){if(n.useProto3Json){if(isNaN(e))return{doubleValue:"NaN"};if(e===1/0)return{doubleValue:"Infinity"};if(e===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:ms(e)?"-0":e}}function Hl(n){return{integerValue:""+n}}function Wl(n,e){return gm(e)?Hl(e):Co(n,e)}/**
1043 * @license
1044 * Copyright 2018 Google LLC
1045 *
1046 * Licensed under the Apache License, Version 2.0 (the "License");
1047 * you may not use this file except in compliance with the License.
1048 * You may obtain a copy of the License at
1049 *
1050 *   http://www.apache.org/licenses/LICENSE-2.0
1051 *
1052 * Unless required by applicable law or agreed to in writing, software
1053 * distributed under the License is distributed on an "AS IS" BASIS,
1054 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1055 * See the License for the specific language governing permissions and
1056 * limitations under the License.
1057 */class $s{constructor(){this._=void 0}}function $m(n,e,t){return n instanceof pr?function(s,o){const a={fields:{[Pl]:{stringValue:Sl},[bl]:{timestampValue:{seconds:s.seconds,nanos:s.nanoseconds}}}};return o&&Ao(o)&&(o=Us(o)),o&&(a.fields[Cl]=o),{mapValue:a}}(t,e):n instanceof yn?Kl(n,e):n instanceof En?Ql(n,e):function(s,o){const a=Gl(s,o),u=tu(a)+tu(s.Ae);return Yi(a)&&Yi(s.Ae)?Hl(u):Co(s.serializer,u)}(n,e)}function zm(n,e,t){return n instanceof yn?Kl(n,e):n instanceof En?Ql(n,e):t}function Gl(n,e){return n instanceof mr?function(r){return Yi(r)||function(o){return!!o&&"doubleValue"in o}(r)}(e)?e:{integerValue:0}:null}class pr extends $s{}class yn extends $s{constructor(e){super(),this.elements=e}}function Kl(n,e){const t=Jl(e);for(const r of n.elements)t.some(s=>Ye(s,r))||t.push(r);return{arrayValue:{values:t}}}class En extends $s{constructor(e){super(),this.elements=e}}function Ql(n,e){let t=Jl(e);for(const r of n.elements)t=t.filter(s=>!Ye(s,r));return{arrayValue:{values:t}}}
1057class mr extends $s{constructor(e,t){super(),this.serializer=e,this.Ae=t}}function tu(n){return re(n.integerValue||n.doubleValue)}function Jl(n){return Ro(n)&&n.arrayValue.values?n.arrayValue.values.slice():[]}/**
1058 * @license
1059 * Copyright 2017 Google LLC
1060 *
1061 * Licensed under the Apache License, Version 2.0 (the "License");
1062 * you may not use this file except in compliance with the License.
1063 * You may obtain a copy of the License at
1064 *
1065 *   http://www.apache.org/licenses/LICENSE-2.0
1066 *
1067 * Unless required by applicable law or agreed to in writing, software
1068 * distributed under the License is distributed on an "AS IS" BASIS,
1069 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1070 * See the License for the specific language governing permissions and
1071 * limitations under the License.
1072 */class zs{constructor(e,t){this.field=e,this.transform=t}}function Hm(n,e){return n.field.isEqual(e.field)&&function(r,s){return r instanceof yn&&s instanceof yn||r instanceof En&&s instanceof En?mn(r.elements,s.elements,Ye):r instanceof mr&&s instanceof mr?Ye(r.Ae,s.Ae):r instanceof pr&&s instanceof pr}(n.transform,e.transform)}class Wm{constructor(e,t){this.version=e,this.transformResults=t}}class Se{constructor(e,t){this.updateTime=e,this.exists=t}static none(){return new Se}static exists(e){return new Se(void 0,e)}static updateTime(e){return new Se(e)}get isNone(){return this.updateTime===void 0&&this.exists===void 0}isEqual(e){return this.exists===e.exists&&(this.updateTime?!!e.updateTime&&this.updateTime.isEqual(e.updateTime):!e.updateTime)}}function is(n,e){return n.updateTime!==void 0?e.isFoundDocument()&&e.version.isEqual(n.updateTime):n.exists===void 0||n.exists===e.isFoundDocument()}class Hs{}function Yl(n,e){if(!n.hasLocalMutations||e&&e.fields.length===0)return null;if(e===null)return n.isNoDocument()?new Ws(n.key,Se.none()):new Ir(n.key,n.data,Se.none());{const t=n.data,r=be.empty();let s=new ce(me.comparator);for(let o of e.fields)if(!s.has(o)){let a=t.field(o);a===null&&o.length>1&&(o=o.popLast(),a=t.field(o)),a===null?r.delete(o):r.set(o,a),s=s.add(o)}return new Ft(n.key,r,new Ve(s.toArray()),Se.none())}}function Gm(n,e,t){n instanceof Ir?function(s,o,a){const u=s.value.clone(),h=ru(s.fieldTransforms,o,a.transformResults);u.setAll(h),o.convertToFoundDocument(a.version,u).setHasCommittedMutations()}(n,e,t):n instanceof Ft?function(s,o,a){if(!is(s.precondition,o))return void o.convertToUnknownDocument(a.version);const u=ru(s.fieldTransforms,o,a.transformResults),h=o.data;h.setAll(Xl(s)),h.setAll(u),o.convertToFoundDocument(a.version,h).setHasCommittedMutations()}(n,e,t):function(s,o,a){o.convertToNoDocument(a.version).setHasCommittedMutations()}(0,e,t)}function ir(n,e,t,r){return n instanceof Ir?function(o,a,u,h){if(!is(o.precondition,a))return u;const d=o.value.clone(),p=su(o.fieldTransforms,h,a);return d.setAll(p),a.convertToFoundDocument(a.version,d).setHasLocalMutations(),null}(n,e,t,r):n instanceof Ft?function(o,a,u,h){if(!is(o.precondition,a))return u;const d=su(o.fieldTransforms,h,a),p=a.data;return p.setAll(Xl(o)),p.setAll(d),a.convertToFoundDocument(a.version,p).setHasLocalMutations(),u===null?null:u.unionWith(o.fieldMask.fields).unionWith(o.fieldTransforms.map(_=>_.field))}(n,e,t,r):function(o,a,u){return is(o.precondition,a)?(a.convertToNoDocument(a.version).setHasLocalMutations(),null):u}(n,e,t)}function Km(n,e){let t=null;for(const r of n.fieldTransforms){const s=e.data.field(r.field),o=Gl(r.transform,s||null);o!=null&&(t===null&&(t=be.empty()),t.set(r.field,o))}return t||null}function nu(n,e){return n.type===e.type&&!!n.key.isEqual(e.key)&&!!n.precondition.isEqual(e.precondition)&&!!function(r,s){return r===void 0&&s===void 0||!(!r||!s)&&mn(r,s,(o,a)=>Hm(o,a))}(n.fieldTransforms,e.fieldTransforms)&&(n.type===0?n.value.isEqual(e.value):n.type!==1||n.data.isEqual(e.data)&&n.fieldMask.isEqual(e.fieldMask))}class Ir extends Hs{constructor(e,t,r,s=[]){super(),this.key=e,this.value=t,this.precondition=r,this.fieldTransforms=s,this.type=0}getFieldMask(){return null}}class Ft extends Hs{constructor(e,t,r,s,o=[]){super(),this.key=e,this.data=t,this.fieldMask=r,this.prec
1072ondition=s,this.fieldTransforms=o,this.type=1}getFieldMask(){return this.fieldMask}}function Xl(n){const e=new Map;return n.fieldMask.fields.forEach(t=>{if(!t.isEmpty()){const r=n.data.field(t);e.set(t,r)}}),e}function ru(n,e,t){const r=new Map;Q(n.length===t.length,32656,{Re:t.length,Ve:n.length});for(let s=0;s<t.length;s++){const o=n[s],a=o.transform,u=e.data.field(o.field);r.set(o.field,zm(a,u,t[s]))}return r}function su(n,e,t){const r=new Map;for(const s of n){const o=s.transform,a=t.data.field(s.field);r.set(s.field,$m(o,a,e))}return r}class Ws extends Hs{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}class Qm extends Hs{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}}/**
1073 * @license
1074 * Copyright 2017 Google LLC
1075 *
1076 * Licensed under the Apache License, Version 2.0 (the "License");
1077 * you may not use this file except in compliance with the License.
1078 * You may obtain a copy of the License at
1079 *
1080 *   http://www.apache.org/licenses/LICENSE-2.0
1081 *
1082 * Unless required by applicable law or agreed to in writing, software
1083 * distributed under the License is distributed on an "AS IS" BASIS,
1084 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1085 * See the License for the specific language governing permissions and
1086 * limitations under the License.
1087 */class Jm{constructor(e,t,r,s){this.batchId=e,this.localWriteTime=t,this.baseMutations=r,this.mutations=s}applyToRemoteDocument(e,t){const r=t.mutationResults;for(let s=0;s<this.mutations.length;s++){const o=this.mutations[s];o.key.isEqual(e.key)&&Gm(o,e,r[s])}}applyToLocalView(e,t){for(const r of this.baseMutations)r.key.isEqual(e.key)&&(t=ir(r,e,t,this.localWriteTime));for(const r of this.mutations)r.key.isEqual(e.key)&&(t=ir(r,e,t,this.localWriteTime));return t}applyToLocalDocumentSet(e,t){const r=zl();return this.mutations.forEach(s=>{const o=e.get(s.key),a=o.overlayedDocument;let u=this.applyToLocalView(a,o.mutatedFields);u=t.has(s.key)?null:u;const h=Yl(a,u);h!==null&&r.set(s.key,h),a.isValidDocument()||a.convertToNoDocument(F.min())}),r}keys(){return this.mutations.reduce((e,t)=>e.add(t.key),z())}isEqual(e){return this.batchId===e.batchId&&mn(this.mutations,e.mutations,(t,r)=>nu(t,r))&&mn(this.baseMutations,e.baseMutations,(t,r)=>nu(t,r))}}class bo{constructor(e,t,r,s){this.batch=e,this.commitVersion=t,this.mutationResults=r,this.docVersions=s}static from(e,t,r){Q(e.mutations.length===r.length,58842,{me:e.mutations.length,fe:r.length});let s=function(){return Um}();const o=e.mutations;for(let a=0;a<o.length;a++)s=s.insert(o[a].key,r[a].version);return new bo(e,t,r,s)}}/**
1088 * @license
1089 * Copyright 2022 Google LLC
1090 *
1091 * Licensed under the Apache License, Version 2.0 (the "License");
1092 * you may not use this file except in compliance with the License.
1093 * You may obtain a copy of the License at
1094 *
1095 *   http://www.apache.org/licenses/LICENSE-2.0
1096 *
1097 * Unless required by applicable law or agreed to in writing, software
1098 * distributed under the License is distributed on an "AS IS" BASIS,
1099 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1100 * See the License for the specific language governing permissions and
1101 * limitations under the License.
1102 */class Ym{constructor(e,t){this.largestBatchId=e,this.mutation=t}getKey(){return this.mutation.key}isEqual(e){return e!==null&&this.mutation===e.mutation}toString(){return`Overlay{
1103      largestBatchId: ${this.largestBatchId},
1104      mutation: ${this.mutation.toString()}
1105    }`}}/**
1106 * @license
1107 * Copyright 2017 Google LLC
1108 *
1109 * Licensed under the Apache License, Version 2.0 (the "License");
1110 * you may not use this file except in compliance with the License.
1111 * You may obtain a copy of the License at
1112 *
1113 *   http://www.apache.org/licenses/LICENSE-2.0
1114 *
1115 * Unless required by applicable law or agreed to in writing, software
1116 * distributed under the License is distributed on an "AS IS" BASIS,
1117 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1118 * See the License for the specific language governing permissions and
1119 * limitations under the License.
1120 */class Xm{constructor(e,t){this.count=e,this.unchangedNames=t}}/**
1121 * @license
1122 * Copyright 2017 Google LLC
1123 *
1124 * Licensed under the Apache License, Version 2.0 (the "License");
1125 * you may not use this file except in compliance with the License.
1126 * You may obtain a copy of the License at
1127 *
1128 *   http://www.apache.org/licenses/LICENSE-2.0
1129 *
1130 * Unless required by applicable law or agreed to in writing, software
1131 * distributed under the License is distributed on an "AS IS" BASIS,
1132 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1133 * See the License for the specific language governing permissions and
1134 * limitations under the License.
1135 */var ie,H;function Zm(n){switch(n){case P.OK:return x(64938);case P.CANCELLED:case P.UNKNOWN:case P.DEADLINE_EXCEEDED:case P.RESOURCE_EXHAUSTED:case P.INTERNAL:case P.UNAVAILABLE:case P.UNAUTHENTICATED:return!1;case P.INVALID_ARGUMENT:case P.NOT_FOUND:case P.ALREADY_EXISTS:case P.PERMISSION_DENIED:case P.FAILED_PRECONDITION:case P.ABORTED:case P.OUT_OF_RANGE:case P.UNIMPLEMENTED:case P.DATA_LOSS:return!0;default:return x(15467,{code:n})}}function Zl(n){if(n===void 0)return ht("GRPC error has no .code"),P.UNKNOWN;switch(n){case ie.OK:return P.OK;case ie.CANCELLED:return P.CANCELLED;case ie.UNKNOWN:return P.UNKNOWN;case ie.DEADLINE_EXCEEDED:return P.DEADLINE_EXCEEDED;case ie.RESOURCE_EXHAUSTED:return P.RESOURCE_EXHAUSTED;case ie.INTERNAL:return P.INTERNAL;case ie.UNAVAILABLE:return P.UNAVAILABLE;case ie.UNAUTHENTICATED:return P.UNAUTHENTICATED;case ie.INVALID_ARGUMENT:return P.INVALID_ARGUMENT;case ie.NOT_FOUND:return P.NOT_FOUND;case ie.ALREADY_EXISTS:return P.ALREADY_EXISTS;case ie.PERMISSION_DENIED:return P.PERMISSION_DENIED;case ie.FAILED_PRECONDITION:return P.FAILED_PRECONDITION;case ie.ABORTED:return P.ABORTED;case ie.OUT_OF_RANGE:return P.OUT_OF_RANGE;case ie.UNIMPLEMENTED:return P.UNIMPLEMENTED;case ie.DATA_LOSS:return P.DATA_LOSS;default:return x(39323,{code:n})}}
1135(H=ie||(ie={}))[H.OK=0]="OK",H[H.CANCELLED=1]="CANCELLED",H[H.UNKNOWN=2]="UNKNOWN",H[H.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",H[H.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",H[H.NOT_FOUND=5]="NOT_FOUND",H[H.ALREADY_EXISTS=6]="ALREADY_EXISTS",H[H.PERMISSION_DENIED=7]="PERMISSION_DENIED",H[H.UNAUTHENTICATED=16]="UNAUTHENTICATED",H[H.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",H[H.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",H[H.ABORTED=10]="ABORTED",H[H.OUT_OF_RANGE=11]="OUT_OF_RANGE",H[H.UNIMPLEMENTED=12]="UNIMPLEMENTED",H[H.INTERNAL=13]="INTERNAL",H[H.UNAVAILABLE=14]="UNAVAILABLE",H[H.DATA_LOSS=15]="DATA_LOSS";/**
1136 * @license
1137 * Copyright 2023 Google LLC
1138 *
1139 * Licensed under the Apache License, Version 2.0 (the "License");
1140 * you may not use this file except in compliance with the License.
1141 * You may obtain a copy of the License at
1142 *
1143 *   http://www.apache.org/licenses/LICENSE-2.0
1144 *
1145 * Unless required by applicable law or agreed to in writing, software
1146 * distributed under the License is distributed on an "AS IS" BASIS,
1147 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1148 * See the License for the specific language governing permissions and
1149 * limitations under the License.
1150 */function eg(){return new TextEncoder}/**
1151 * @license
1152 * Copyright 2022 Google LLC
1153 *
1154 * Licensed under the Apache License, Version 2.0 (the "License");
1155 * you may not use this file except in compliance with the License.
1156 * You may obtain a copy of the License at
1157 *
1158 *   http://www.apache.org/licenses/LICENSE-2.0
1159 *
1160 * Unless required by applicable law or agreed to in writing, software
1161 * distributed under the License is distributed on an "AS IS" BASIS,
1162 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1163 * See the License for the specific language governing permissions and
1164 * limitations under the License.
1165 */const tg=new Pt([4294967295,4294967295],0);function iu(n){const e=eg().encode(n),t=new pl;return t.update(e),new Uint8Array(t.digest())}function ou(n){const e=new DataView(n.buffer),t=e.getUint32(0,!0),r=e.getUint32(4,!0),s=e.getUint32(8,!0),o=e.getUint32(12,!0);return[new Pt([t,r],0),new Pt([s,o],0)]}class ko{constructor(e,t,r){if(this.bitmap=e,this.padding=t,this.hashCount=r,t<0||t>=8)throw new Zn(`Invalid padding: ${t}`);if(r<0)throw new Zn(`Invalid hash count: ${r}`);if(e.length>0&&this.hashCount===0)throw new Zn(`Invalid hash count: ${r}`);if(e.length===0&&t!==0)throw new Zn(`Invalid padding when bitmap length is 0: ${t}`);this.ge=8*e.length-t,this.pe=Pt.fromNumber(this.ge)}ye(e,t,r){let s=e.add(t.multiply(Pt.fromNumber(r)));return s.compare(tg)===1&&(s=new Pt([s.getBits(0),s.getBits(1)],0)),s.modulo(this.pe).toNumber()}we(e){return!!(this.bitmap[Math.floor(e/8)]&1<<e%8)}mightContain(e){if(this.ge===0)return!1;const t=iu(e),[r,s]=ou(t);for(let o=0;o<this.hashCount;o++){const a=this.ye(r,s,o);if(!this.we(a))return!1}return!0}static create(e,t,r){const s=e%8==0?0:8-e%8,o=new Uint8Array(Math.ceil(e/8)),a=new ko(o,s,t);return r.forEach(u=>a.insert(u)),a}insert(e){if(this.ge===0)return;const t=iu(e),[r,s]=ou(t);for(let o=0;o<this.hashCount;o++){const a=this.ye(r,s,o);this.Se(a)}}Se(e){const t=Math.floor(e/8),r=e%8;this.bitmap[t]|=1<<r}}class Zn extends Error{constructor(){super(...arguments),this.name="BloomFilterError"}}/**
1166 * @license
1167 * Copyright 2017 Google LLC
1168 *
1169 * Licensed under the Apache License, Version 2.0 (the "License");
1170 * you may not use this file except in compliance with the License.
1171 * You may obtain a copy of the License at
1172 *
1173 *   http://www.apache.org/licenses/LICENSE-2.0
1174 *
1175 * Unless required by applicable law or agreed to in writing, software
1176 * distributed under the License is distributed on an "AS IS" BASIS,
1177 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1178 * See the License for the specific language governing permissions and
1179 * limitations under the License.
1180 */class Gs{constructor(e,t,r,s,o){this.snapshotVersion=e,this.targetChanges=t,this.targetMismatches=r,this.documentUpdates=s,this.resolvedLimboDocuments=o}static createSynthesizedRemoteEventForCurrentChange(e,t,r){const s=new Map;return s.set(e,wr.createSynthesizedTargetChangeForCurrentChange(e,t,r)),new Gs(F.min(),s,new te($),dt(),z())}}class wr{constructor(e,t,r,s,o){this.resumeToken=e,this.current=t,this.addedDocuments=r,this.modifiedDocuments=s,this.removedDocuments=o}static createSynthesizedTargetChangeForCurrentChange(e,t,r){return new wr(r,t,z(),z(),z())}}/**
1181 * @license
1182 * Copyright 2017 Google LLC
1183 *
1184 * Licensed under the Apache License, Version 2.0 (the "License");
1185 * you may not use this file except in compliance with the License.
1186 * You may obtain a copy of the License at
1187 *
1188 *   http://www.apache.org/licenses/LICENSE-2.0
1189 *
1190 * Unless required by applicable law or agreed to in writing, software
1191 * distributed under the License is distributed on an "AS IS" BASIS,
1192 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1193 * See the License for the specific language governing permissions and
1194 * limitations under the License.
1195 */class os{constructor(e,t,r,s){this.be=e,this.removedTargetIds=t,this.key=r,this.De=s}}class eh{constructor(e,t){this.targetId=e,this.Ce=t}}class th{constructor(e,t,r=ge.EMPTY_BYTE_STRING,s=null){this.state=e,this.targetIds=t,this.resumeToken=r,this.cause=s}}class au{constructor(){this.ve=0,this.Fe=cu(),this.Me=ge.EMPTY_BYTE_STRING,this.xe=!1,this.Oe=!0}get current(){return this.xe}get resumeToken(){return this.Me}get Ne(){return this.ve!==0}get Be(){return this.Oe}Le(e){e.approximateByteSize()>0&&(this.Oe=!0,this.Me=e)}ke(){let e=z(),t=z(),r=z();return this.Fe.forEach((s,o)=>{switch(o){case 0:e=e.add(s);break;case 2:t=t.add(s);break;case 1:r=r.add(s);break;default:x(38017,{changeType:o})}}),new wr(this.Me,this.xe,e,t,r)}qe(){this.Oe=!1,this.Fe=cu()}Qe(e,t){this.Oe=!0,this.Fe=this.Fe.insert(e,t)}$e(e){this.Oe=!0,this.Fe=this.Fe.remove(e)}Ue(){this.ve+=1}Ke(){this.ve-=1,Q(this.ve>=0,3241,{ve:this.ve})}We(){this.Oe=!0,this.xe=!0}}class ng{constructor(e){this.Ge=e,this.ze=new Map,this.je=dt(),this.Je=Zr(),this.He=Zr(),this.Ye=new te($)}Ze(e){for(const t of e.be)e.De&&e.De.isFoundDocument()?this.Xe(t,e.De):this.et(t,e.key,e.De);for(const t of e.removedTargetIds)this.et(t,e.key,e.De)}tt(e){this.forEachTarget(e,t=>{const r=this.nt(t);switch(e.state){case 0:this.rt(t)&&r.Le(e.resumeToken);break;case 1:r.Ke(),r.Ne||r.qe(),r.Le(e.resumeToken);break;case 2:r.Ke(),r.Ne||this.removeTarget(t);break;case 3:this.rt(t)&&(r.We(),r.Le(e.resumeToken));break;case 4:this.rt(t)&&(this.it(t),r.Le(e.resumeToken));break;default:x(56790,{state:e.state})}})}forEachTarget(e,t){e.targetIds.length>0?e.targetIds.forEach(t):this.ze.forEach((r,s)=>{this.rt(s)&&t(s)})}st(e){const t=e.targetId,r=e.Ce.count,s=this.ot(t);if(s){const o=s.target;if(Zi(o))if(r===0){const a=new L(o.path);this.et(t,a,we.newNoDocument(a,F.min()))}else Q(r===1,20013,{expectedCount:r});else{const a=this._t(t);if(a!==r){const u=this.ut(e),h=u?this.ct(u,e,a):1;if(h!==0){this.it(t);const d=h===2?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch";this.Ye=this.Ye.insert(t,d)}}}}}ut(e){const t=e.Ce.unchangedNames;if(!t||!t.bits)return null;const{bits:{bitmap:r="",padding:s=0},hashCount:o=0}=t;let a,u;try{a=Dt(r).toUint8Array()}catch(h){if(h instanceof Rl)return cr("Decoding the base64 bloom filter in existence filter failed ("+h.message+"); ignoring the bloom filter and falling back to full re-query."),null;throw h}try{u=new ko(a,s,o)}catch(h){return cr(h instanceof Zn?"BloomFilter error: ":"Applying bloom filter failed: ",h),null}return u.ge===0?null:u}ct(e,t,r){return t.Ce.count===r-this.Pt(e,t.targetId)?0:2}Pt(e,t){const r=this.Ge.getRemoteKeysForTarget(t);let s=0;return r.forEach(o=>{const a=this.Ge.ht(),u=`projects/${a.projectId}/databases/${a.database}/documents/${o.path.canonicalString()}`;e.mightContain(u)||(this.et(t,o,null),s++)}),s}Tt(e){const t=new Map;this.ze.forEach((o,a)=>{const u=this.ot(a);if(u){if(o.current&&Zi(u.target)){const h=new L(u.target.path);this.It(h).has(a)||this.Et(a,h)||this.et(a,h,we.newNoDocument(h,e))}o.Be&&(t.set(a,o.ke()),o.qe())}});let r=z();this.He.forEach((o,a)=>{let u=!0;a.forEachWhile(h=>{const d=this.ot(h);return!d||d.purpose==="TargetPurposeLimboResolution"||(u=!1,!1)}),u&&(r=r.add(o))}),this.je.forEach((o,a)=>a.setReadTime(e));const s=new Gs(e,t,this.Ye,this.je,r);return this.je=dt(),this.Je=Zr(),this.He=Zr(),this.Ye=new te($),s}Xe(e,t){if(!this.rt(e))return;const r=this.Et(e,t.key)?2:0;this.nt(e).Qe(t.key,r),this.je=this.je.insert(t.key,t),this.Je=this.Je.insert(t.key,this.It(t.key).add(e)),this.He=this.He.insert(t.key,this.dt(t.key).add(e))}et(e,t,r){if(!this.rt(e))return;const s=this.nt(e);this.Et(e,t)?s.Qe(t,1):s.$e(t),this.He=this.He.insert(t,this.dt(t).delete(e)),this.He=this.He.insert(t,this.dt(t).add(e)),r&&(this.je=this.je.insert(t,r))}removeTarget(e){this.ze.delete(e)}_t(e){const t=this.nt(e).ke();return this.Ge.getRemoteKeysForTarget(e).size+t.addedDocuments.size-t.removedDocuments.size}Ue(e){this.nt(e).Ue()}nt(e){let t=this.ze.get(e);return t||(t=new au,this.ze.set(e,t)),t}dt(e){let t=this.He.get(e);return t||(t=new ce($),this.He=this.He.insert(e,t)),t}It(e){let t=this.Je.get(e);return t||(t=new ce($),this.Je=this.Je.insert(e,t)),t}rt(e){const t=this.ot(e)!==null;return t||O("WatchChangeAggregator","Detected inactive target",e),t}ot(e){const t=this.ze.get(e);return t&&t.Ne?null:this.Ge.At(e)}it(e){this.ze.set(e,new au),this.Ge.getRemoteKeysForTarget(e).forEach(t=>{this.et(e,t,null)})}Et(e,t){return this.Ge.getRemoteKeysForTarget(e).has(t)}}function Zr(){return new te(L.comparator)}function cu(){return new te(L.comparator)}const rg={asc:"ASCENDING",desc:"DESCENDING"},sg={"<":"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"},ig={and:"AND",or:"OR"};class og{constructor(e,t){this.databaseId=e,this.useProto3Json=t}}function to(n,e){return n.useProto3Json||Fs(e)?e:{value:e}}function Ts(n,e){return n.useProto3Json?`${new Date(1e3*e.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+e.nanoseconds).slice(-9)}Z`:{seconds:""+e.seconds,nanos:e.nanoseconds}}function nh(n,e){return n.useProto3Json?e.toBase64():e.toUint8Array()}function ag(n,e){return Ts(n,e.toTimestamp())}function Ge(n){return Q(!!n,49232),F.fromTimestamp(function(t){const r=Vt(t);return new Z(r.seconds,r.nanos)}(n))}function No(n,e){return no(n,e).canonicalString()}function no(n,e){const t=function(s){return new Y(["projects",s.projectId,"databases",s.database])}(n).child("documents");return e===void 0?t:t.child(e)}function rh(n){const e=Y.fromString(n);return Q(ch(e),10190,{key:e.toString()}),e}function ro(n,e){return No(n.databaseId,e.path)}function Li(n,e){const t=rh(e);if(t.get(1)!==n.databaseId.projectId)throw new V(P.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+t.get(1)+" vs "+n.databaseId.projectId);if(t.get(3)!==n.databaseId.database)throw new V(P.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+t.get(3)+" vs "+n.databaseId.database);return new L(ih(t))}function sh(n,e){return No(n.databaseId,e)}function cg(n){const e=rh(n);return e.length===4?Y.emptyPath():ih(e)}function so(n){return new Y(["projects",n.databaseId.projectId,"databases",n.databaseId.database]).canonicalString()}function ih(n){return Q(n.length>4&&n.get(4)==="documents",29091,{key:n.toString()}),n.popFirst(5)}function uu(n,e,t){return{name:ro(n,e),fields:t.value.mapValue.fields}}function ug(n,e){let t;if("targetChange"in e){e.targetChange;const r=function(d){return d==="NO_CHANGE"?0:d==="ADD"?1:d==="REMOVE"?2:d==="CURRENT"?3:d==="RESET"?4:x(39313,{state:d})}(e.targetChange.targetChangeType||"NO_CHANGE"),s=e.targetChange.targetIds||[],o=function(d,p){return d.useProto3Json?(Q(p===void 0||typeof p=="string",58123),ge.fromBase64String(p||"")):(Q(p===void 0||p instanceof Buffer||p instanceof Uint8Array,16193),ge.fromUint8Array(p||new Uint8Array))}(n,e.targetChange.resumeToken),a=e.targetChange.cause,u=a&&function(d){const p=d.code===void 0?P.UNKNOWN:Zl(d.code);return new V(p,d.message||"")}(a);t=new th(r,s,o,u||null)}else if("documentChange"in e){e.documentChange;const r=e.documentChange;r.document,r.document.name,r.document.updateTime;const s=Li(n,r.document.name),o=Ge(r.document.updateTime),a=r.document.createTime?Ge(r.document.createTime):F.min(),u=new be({mapValue:{fields:r.document.fields}}),h=we.newFoundDocument(s,o,a,u),d=r.targetIds||[],p=r.removedTargetIds||[];t=new os(d,p,h.key,h)}else if("documentDelete"in e){e.documentDelete;const r=e.documentDelete;r.document;const s=Li(n,r.document),o=r.readTime?Ge(r.readTime):F.min(),a=we.newNoDocument(s,o),u=r.removedTargetIds||[];t=new os([],u,a.key,a)}else if("documentRemove"in e){e.documentRemove;const r=e.documentRemove;r.document;const s=Li(n,r.document),o=r.removedTargetIds||[];t=new os([],o,s,null)}else{if(!("filter"in e))return x(11601,{Rt:e});{e.filter;const r=e.filter;r.targetId;const{count:s=0,unchangedNames:o}=r,a=new Xm(s,o),u=r.targetId;t=new eh(u,a)}}return t}function lg(n,e){let t;if(e instanceof Ir)t={update:uu(n,e.key,e.value)};else if(e instanceof Ws)t={delete:ro(n,e.key)};else if(e instanceof Ft)t={update:uu(n,e.key,e.data),updateMask:Eg(e.fieldMask)};else{if(!(e instanceof Qm))return x(16599,{Vt:e.type});t={verify:ro(n,e.key)}}return e.fieldTransforms.length>0&&(t.updateTransforms=e.fieldTransforms.map(r=>function(o,a){const u=a.transform;if(u instanceof pr)return{fieldPath:a.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(u instanceof yn)return{fieldPath:a.field.canonicalString(),appendMissingElements:{values:u.elements}};if(u instanceof En)return{fieldPath:a.field.canonicalString(),removeAllFromArray:{values:u.elements}};if(u instanceof mr)return{fieldPath:a.field.canonicalString(),increment:u.Ae};throw x(20930,{transform:a.transform})}(0,r))),e.precondition.isNone||(t.currentDocument=function(s,o){return o.updateTime!==void 0?{updateTime:ag(s,o.updateTime)}:o.exists!==void 0?{exists:o.exists}:x(27497)}(n,e.precondition)),t}function hg(n,e){return n&&n.length>0?(Q(e!==void 0,14353),n.map(t=>function(s,o){let a=s.updateTime?Ge(s.updateTime):Ge(o);return a.isEqual(F.min())&&(a=Ge(o)),new Wm(a,s.transformResults||[])}(t,e))):[]}function dg(n,e){return{documents:[sh(n,e.path)]}}function fg(n,e){const t={structuredQuery:{}},r=e.path;let s;e.collectionGroup!==null?(s=r,t.structuredQuery.from=[{collectionId:e.collectionGroup,allDescendants:!0}]):(s=r.popLast(),t.structuredQuery.from=[{collectionId:r.lastSegment()}]),t.parent=sh(n,s);const o=function(d){if(d.length!==0)return ah(qe.create(d,"and"))}(e.filters);o&&(t.structuredQuery.where=o);const a=function(d){if(d.length!==0)return d.map(p=>function(E){return{field:ln(E.field),direction:gg(E.dir)}}(p))}(e.orderBy);a&&(t.structuredQuery.orderBy=a);const u=to(n,e.limit);return u!==null&&(t.structuredQuery.limit=u),e.startAt&&(t.structuredQuery.startAt=function(d){return{before:d.inclusive,values:d.position}}(e.startAt)),e.endAt&&(t.structuredQuery.endAt=function(d){return{before:!d.inclusive,values:d.position}}(e.endAt)),{ft:t,parent:s}}function pg(n){let e=cg(n.parent);
1195const t=n.structuredQuery,r=t.from?t.from.length:0;let s=null;if(r>0){Q(r===1,65062);const p=t.from[0];p.allDescendants?s=p.collectionId:e=e.child(p.collectionId)}let o=[];t.where&&(o=function(_){const E=oh(_);return E instanceof qe&&Ml(E)?E.getFilters():[E]}(t.where));let a=[];t.orderBy&&(a=function(_){return _.map(E=>function(b){return new fr(hn(b.field),function(N){switch(N){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(b.direction))}(E))}(t.orderBy));let u=null;t.limit&&(u=function(_){let E;return E=typeof _=="object"?_.value:_,Fs(E)?null:E}(t.limit));let h=null;t.startAt&&(h=function(_){const E=!!_.before,S=_.values||[];return new ys(S,E)}(t.startAt));let d=null;return t.endAt&&(d=function(_){const E=!_.before,S=_.values||[];return new ys(S,E)}(t.endAt)),Om(e,s,a,o,u,"F",h,d)}function mg(n,e){const t=function(s){switch(s){case"TargetPurposeListen":return null;case"TargetPurposeExistenceFilterMismatch":return"existence-filter-mismatch";case"TargetPurposeExistenceFilterMismatchBloom":return"existence-filter-mismatch-bloom";case"TargetPurposeLimboResolution":return"limbo-document";default:return x(28987,{purpose:s})}}(e.purpose);return t==null?null:{"goog-listen-tags":t}}function oh(n){return n.unaryFilter!==void 0?function(t){switch(t.unaryFilter.op){case"IS_NAN":const r=hn(t.unaryFilter.field);return oe.create(r,"==",{doubleValue:NaN});case"IS_NULL":const s=hn(t.unaryFilter.field);return oe.create(s,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":const o=hn(t.unaryFilter.field);return oe.create(o,"!=",{doubleValue:NaN});case"IS_NOT_NULL":const a=hn(t.unaryFilter.field);return oe.create(a,"!=",{nullValue:"NULL_VALUE"});case"OPERATOR_UNSPECIFIED":return x(61313);default:return x(60726)}}(n):n.fieldFilter!==void 0?function(t){return oe.create(hn(t.fieldFilter.field),function(s){switch(s){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 x(58110);default:return x(50506)}}(t.fieldFilter.op),t.fieldFilter.value)}(n):n.compositeFilter!==void 0?function(t){return qe.create(t.compositeFilter.filters.map(r=>oh(r)),function(s){switch(s){case"AND":return"and";case"OR":return"or";default:return x(1026)}}(t.compositeFilter.op))}(n):x(30097,{filter:n})}function gg(n){return rg[n]}function _g(n){return sg[n]}function yg(n){return ig[n]}function ln(n){return{fieldPath:n.canonicalString()}}function hn(n){return me.fromServerFormat(n.fieldPath)}function ah(n){return n instanceof oe?function(t){if(t.op==="=="){if(Jc(t.value))return{unaryFilter:{field:ln(t.field),op:"IS_NAN"}};if(Qc(t.value))return{unaryFilter:{field:ln(t.field),op:"IS_NULL"}}}else if(t.op==="!="){if(Jc(t.value))return{unaryFilter:{field:ln(t.field),op:"IS_NOT_NAN"}};if(Qc(t.value))return{unaryFilter:{field:ln(t.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:ln(t.field),op:_g(t.op),value:t.value}}}(n):n instanceof qe?function(t){const r=t.getFilters().map(s=>ah(s));return r.length===1?r[0]:{compositeFilter:{op:yg(t.op),filters:r}}}(n):x(54877,{filter:n})}function Eg(n){const e=[];return n.fields.forEach(t=>e.push(t.canonicalString())),{fieldPaths:e}}function ch(n){return n.length>=4&&n.get(0)==="projects"&&n.get(2)==="databases"}/**
1196 * @license
1197 * Copyright 2017 Google LLC
1198 *
1199 * Licensed under the Apache License, Version 2.0 (the "License");
1200 * you may not use this file except in compliance with the License.
1201 * You may obtain a copy of the License at
1202 *
1203 *   http://www.apache.org/licenses/LICENSE-2.0
1204 *
1205 * Unless required by applicable law or agreed to in writing, software
1206 * distributed under the License is distributed on an "AS IS" BASIS,
1207 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1208 * See the License for the specific language governing permissions and
1209 * limitations under the License.
1210 */class At{constructor(e,t,r,s,o=F.min(),a=F.min(),u=ge.EMPTY_BYTE_STRING,h=null){this.target=e,this.targetId=t,this.purpose=r,this.sequenceNumber=s,this.snapshotVersion=o,this.lastLimboFreeSnapshotVersion=a,this.resumeToken=u,this.expectedCount=h}withSequenceNumber(e){return new At(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(e,t){return new At(this.target,this.targetId,this.purpose,this.sequenceNumber,t,this.lastLimboFreeSnapshotVersion,e,null)}withExpectedCount(e){return new At(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,e)}withLastLimboFreeSnapshotVersion(e){return new At(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken,this.expectedCount)}}/**
1211 * @license
1212 * Copyright 2017 Google LLC
1213 *
1214 * Licensed under the Apache License, Version 2.0 (the "License");
1215 * you may not use this file except in compliance with the License.
1216 * You may obtain a copy of the License at
1217 *
1218 *   http://www.apache.org/licenses/LICENSE-2.0
1219 *
1220 * Unless required by applicable law or agreed to in writing, software
1221 * distributed under the License is distributed on an "AS IS" BASIS,
1222 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1223 * See the License for the specific language governing permissions and
1224 * limitations under the License.
1225 */class Tg{constructor(e){this.yt=e}}function Ig(n){const e=pg({parent:n.parent,structuredQuery:n.structuredQuery});return n.limitType==="LAST"?Es(e,e.limit,"L"):e}/**
1226 * @license
1227 * Copyright 2019 Google LLC
1228 *
1229 * Licensed under the Apache License, Version 2.0 (the "License");
1230 * you may not use this file except in compliance with the License.
1231 * You may obtain a copy of the License at
1232 *
1233 *   http://www.apache.org/licenses/LICENSE-2.0
1234 *
1235 * Unless required by applicable law or agreed to in writing, software
1236 * distributed under the License is distributed on an "AS IS" BASIS,
1237 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1238 * See the License for the specific language governing permissions and
1239 * limitations under the License.
1240 */class wg{constructor(){this.Cn=new vg}addToCollectionParentIndex(e,t){return this.Cn.add(t),C.resolve()}getCollectionParents(e,t){return C.resolve(this.Cn.getEntries(t))}addFieldIndex(e,t){return C.resolve()}deleteFieldIndex(e,t){return C.resolve()}deleteAllFieldIndexes(e){return C.resolve()}createTargetIndexes(e,t){return C.resolve()}getDocumentsMatchingTarget(e,t){return C.resolve(null)}getIndexType(e,t){return C.resolve(0)}getFieldIndexes(e,t){return C.resolve([])}getNextCollectionGroupToUpdate(e){return C.resolve(null)}getMinOffset(e,t){return C.resolve(Nt.min())}getMinOffsetFromCollectionGroup(e,t){return C.resolve(Nt.min())}updateCollectionGroup(e,t,r){return C.resolve()}updateIndexEntries(e,t){return C.resolve()}}class vg{constructor(){this.index={}}add(e){const t=e.lastSegment(),r=e.popLast(),s=this.index[t]||new ce(Y.comparator),o=!s.has(r);return this.index[t]=s.add(r),o}has(e){const t=e.lastSegment(),r=e.popLast(),s=this.index[t];return s&&s.has(r)}getEntries(e){return(this.index[e]||new ce(Y.comparator)).toArray()}}/**
1241 * @license
1242 * Copyright 2018 Google LLC
1243 *
1244 * Licensed under the Apache License, Version 2.0 (the "License");
1245 * you may not use this file except in compliance with the License.
1246 * You may obtain a copy of the License at
1247 *
1248 *   http://www.apache.org/licenses/LICENSE-2.0
1249 *
1250 * Unless required by applicable law or agreed to in writing, software
1251 * distributed under the License is distributed on an "AS IS" BASIS,
1252 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1253 * See the License for the specific language governing permissions and
1254 * limitations under the License.
1255 */const lu={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0},uh=41943040;class Ce{static withCacheSize(e){return new Ce(e,Ce.DEFAULT_COLLECTION_PERCENTILE,Ce.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}constructor(e,t,r){this.cacheSizeCollectionThreshold=e,this.percentileToCollect=t,this.maximumSequenceNumbersToCollect=r}}/**
1256 * @license
1257 * Copyright 2017 Google LLC
1258 *
1259 * Licensed under the Apache License, Version 2.0 (the "License");
1260 * you may not use this file except in compliance with the License.
1261 * You may obtain a copy of the License at
1262 *
1263 *   http://www.apache.org/licenses/LICENSE-2.0
1264 *
1265 * Unless required by applicable law or agreed to in writing, software
1266 * distributed under the License is distributed on an "AS IS" BASIS,
1267 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1268 * See the License for the specific language governing permissions and
1269 * limitations under the License.
1270 */Ce.DEFAULT_COLLECTION_PERCENTILE=10,Ce.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,Ce.DEFAULT=new Ce(uh,Ce.DEFAULT_COLLECTION_PERCENTILE,Ce.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),Ce.DISABLED=new Ce(-1,0,0);/**
1271 * @license
1272 * Copyright 2017 Google LLC
1273 *
1274 * Licensed under the Apache License, Version 2.0 (the "License");
1275 * you may not use this file except in compliance with the License.
1276 * You may obtain a copy of the License at
1277 *
1278 *   http://www.apache.org/licenses/LICENSE-2.0
1279 *
1280 * Unless required by applicable law or agreed to in writing, software
1281 * distributed under the License is distributed on an "AS IS" BASIS,
1282 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1283 * See the License for the specific language governing permissions and
1284 * limitations under the License.
1285 */class Tn{constructor(e){this.ar=e}next(){return this.ar+=2,this.ar}static ur(){return new Tn(0)}static cr(){return new Tn(-1)}}/**
1286 * @license
1287 * Copyright 2020 Google LLC
1288 *
1289 * Licensed under the Apache License, Version 2.0 (the "License");
1290 * you may not use this file except in compliance with the License.
1291 * You may obtain a copy of the License at
1292 *
1293 *   http://www.apache.org/licenses/LICENSE-2.0
1294 *
1295 * Unless required by applicable law or agreed to in writing, software
1296 * distributed under the License is distributed on an "AS IS" BASIS,
1297 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1298 * See the License for the specific language governing permissions and
1299 * limitations under the License.
1300 */const hu="LruGarbageCollector",lh=1048576;function du([n,e],[t,r]){const s=$(n,t);return s===0?$(e,r):s}class Ag{constructor(e){this.Ir=e,this.buffer=new ce(du),this.Er=0}dr(){return++this.Er}Ar(e){const t=[e,this.dr()];if(this.buffer.size<this.Ir)this.buffer=this.buffer.add(t);else{const r=this.buffer.last();du(t,r)<0&&(this.buffer=this.buffer.delete(r).add(t))}}get maxValue(){return this.buffer.last()[0]}}class Rg{constructor(e,t,r){this.garbageCollector=e,this.asyncQueue=t,this.localStore=r,this.Rr=null}start(){this.garbageCollector.params.cacheSizeCollectionThreshold!==-1&&this.Vr(6e4)}stop(){this.Rr&&(this.Rr.cancel(),this.Rr=null)}get started(){return this.Rr!==null}Vr(e){O(hu,`Garbage collection scheduled in ${e}ms`),this.Rr=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",e,async()=>{this.Rr=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(t){Sn(t)?O(hu,"Ignoring IndexedDB error during garbage collection: ",t):await Rn(t)}await this.Vr(3e5)})}}class Sg{constructor(e,t){this.mr=e,this.params=t}calculateTargetCount(e,t){return this.mr.gr(e).next(r=>Math.floor(t/100*r))}nthSequenceNumber(e,t){if(t===0)return C.resolve(xs.ce);const r=new Ag(t);return this.mr.forEachTarget(e,s=>r.Ar(s.sequenceNumber)).next(()=>this.mr.pr(e,s=>r.Ar(s))).next(()=>r.maxValue)}removeTargets(e,t,r){return this.mr.removeTargets(e,t,r)}removeOrphanedDocuments(e,t){return this.mr.removeOrphanedDocuments(e,t)}collect(e,t){return this.params.cacheSizeCollectionThreshold===-1?(O("LruGarbageCollector","Garbage collection skipped; disabled"),C.resolve(lu)):this.getCacheSize(e).next(r=>r<this.params.cacheSizeCollectionThreshold?(O("LruGarbageCollector",`Garbage collection skipped; Cache size ${r} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),lu):this.yr(e,t))}getCacheSize(e){return this.mr.getCacheSize(e)}yr(e,t){let r,s,o,a,u,h,d;const p=Date.now();return this.calculateTargetCount(e,this.params.percentileToCollect).next(_=>(_>this.params.maximumSequenceNumbersToCollect?(O("LruGarbageCollector",`C
1300apping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${_}`),s=this.params.maximumSequenceNumbersToCollect):s=_,a=Date.now(),this.nthSequenceNumber(e,s))).next(_=>(r=_,u=Date.now(),this.removeTargets(e,r,t))).next(_=>(o=_,h=Date.now(),this.removeOrphanedDocuments(e,r))).next(_=>(d=Date.now(),cn()<=j.DEBUG&&O("LruGarbageCollector",`LRU Garbage Collection
1301	Counted targets in ${a-p}ms
1302	Determined least recently used ${s} in `+(u-a)+`ms
1303	Removed ${o} targets in `+(h-u)+`ms
1304	Removed ${_} documents in `+(d-h)+`ms
1305Total Duration: ${d-p}ms`),C.resolve({didRun:!0,sequenceNumbersCollected:s,targetsRemoved:o,documentsRemoved:_})))}}function Pg(n,e){return new Sg(n,e)}/**
1306 * @license
1307 * Copyright 2017 Google LLC
1308 *
1309 * Licensed under the Apache License, Version 2.0 (the "License");
1310 * you may not use this file except in compliance with the License.
1311 * You may obtain a copy of the License at
1312 *
1313 *   http://www.apache.org/licenses/LICENSE-2.0
1314 *
1315 * Unless required by applicable law or agreed to in writing, software
1316 * distributed under the License is distributed on an "AS IS" BASIS,
1317 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1318 * See the License for the specific language governing permissions and
1319 * limitations under the License.
1320 */class Cg{constructor(){this.changes=new Xt(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,we.newInvalidDocument(e).setReadTime(t))}getEntry(e,t){this.assertNotApplied();const r=this.changes.get(t);return r!==void 0?C.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(){}}/**
1321 * @license
1322 * Copyright 2017 Google LLC
1323 *
1324 * Licensed under the Apache License, Version 2.0 (the "License");
1325 * you may not use this file except in compliance with the License.
1326 * You may obtain a copy of the License at
1327 *
1328 *   http://www.apache.org/licenses/LICENSE-2.0
1329 *
1330 * Unless required by applicable law or agreed to in writing, software
1331 * distributed under the License is distributed on an "AS IS" BASIS,
1332 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1333 * See the License for the specific language governing permissions and
1334 * limitations under the License.
1335 *//**
1336 * @license
1337 * Copyright 2022 Google LLC
1338 *
1339 * Licensed under the Apache License, Version 2.0 (the "License");
1340 * you may not use this file except in compliance with the License.
1341 * You may obtain a copy of the License at
1342 *
1343 *   http://www.apache.org/licenses/LICENSE-2.0
1344 *
1345 * Unless required by applicable law or agreed to in writing, software
1346 * distributed under the License is distributed on an "AS IS" BASIS,
1347 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1348 * See the License for the specific language governing permissions and
1349 * limitations under the License.
1350 */class bg{constructor(e,t){this.overlayedDocument=e,this.mutatedFields=t}}/**
1351 * @license
1352 * Copyright 2017 Google LLC
1353 *
1354 * Licensed under the Apache License, Version 2.0 (the "License");
1355 * you may not use this file except in compliance with the License.
1356 * You may obtain a copy of the License at
1357 *
1358 *   http://www.apache.org/licenses/LICENSE-2.0
1359 *
1360 * Unless required by applicable law or agreed to in writing, software
1361 * distributed under the License is distributed on an "AS IS" BASIS,
1362 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1363 * See the License for the specific language governing permissions and
1364 * limitations under the License.
1365 */class kg{constructor(e,t,r,s){this.remoteDocumentCache=e,this.mutationQueue=t,this.documentOverlayCache=r,this.indexManager=s}getDocument(e,t){let r=null;return this.documentOverlayCache.getOverlay(e,t).next(s=>(r=s,this.remoteDocumentCache.getEntry(e,t))).next(s=>(r!==null&&ir(r.mutation,s,Ve.empty(),Z.now()),s))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next(r=>this.getLocalViewOfDocuments(e,r,z()).next(()=>r))}getLocalViewOfDocuments(e,t,r=z()){const s=zt();return this.populateOverlays(e,s,t).next(()=>this.computeViews(e,t,s,r).next(o=>{let a=Xn();return o.forEach((u,h)=>{a=a.insert(u,h.overlayedDocument)}),a}))}getOverlayedDocuments(e,t){const r=zt();return this.populateOverlays(e,r,t).next(()=>this.computeViews(e,t,r,z()))}populateOverlays(e,t,r){const s=[];return r.forEach(o=>{t.has(o)||s.push(o)}),this.documentOverlayCache.getOverlays(e,s).next(o=>{o.forEach((a,u)=>{t.set(a,u)})})}computeViews(e,t,r,s){let o=dt();const a=sr(),u=function(){return sr()}();return t.forEach((h,d)=>{const p=r.get(d.key);s.has(d.key)&&(p===void 0||p.mutation instanceof Ft)?o=o.insert(d.
1365key,d):p!==void 0?(a.set(d.key,p.mutation.getFieldMask()),ir(p.mutation,d,p.mutation.getFieldMask(),Z.now())):a.set(d.key,Ve.empty())}),this.recalculateAndSaveOverlays(e,o).next(h=>(h.forEach((d,p)=>a.set(d,p)),t.forEach((d,p)=>u.set(d,new bg(p,a.get(d)??null))),u))}recalculateAndSaveOverlays(e,t){const r=sr();let s=new te((a,u)=>a-u),o=z();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,t).next(a=>{for(const u of a)u.keys().forEach(h=>{const d=t.get(h);if(d===null)return;let p=r.get(h)||Ve.empty();p=u.applyToLocalView(d,p),r.set(h,p);const _=(s.get(u.batchId)||z()).add(h);s=s.insert(u.batchId,_)})}).next(()=>{const a=[],u=s.getReverseIterator();for(;u.hasNext();){const h=u.getNext(),d=h.key,p=h.value,_=zl();p.forEach(E=>{if(!o.has(E)){const S=Yl(t.get(E),r.get(E));S!==null&&_.set(E,S),o=o.add(E)}}),a.push(this.documentOverlayCache.saveOverlays(e,d,_))}return C.waitFor(a)}).next(()=>r)}recalculateAndSaveOverlaysForDocumentKeys(e,t){return this.remoteDocumentCache.getEntries(e,t).next(r=>this.recalculateAndSaveOverlays(e,r))}getDocumentsMatchingQuery(e,t,r,s){return function(a){return L.isDocumentKey(a.path)&&a.collectionGroup===null&&a.filters.length===0}(t)?this.getDocumentsMatchingDocumentQuery(e,t.path):Ul(t)?this.getDocumentsMatchingCollectionGroupQuery(e,t,r,s):this.getDocumentsMatchingCollectionQuery(e,t,r,s)}getNextDocuments(e,t,r,s){return this.remoteDocumentCache.getAllFromCollectionGroup(e,t,r,s).next(o=>{const a=s-o.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(e,t,r.largestBatchId,s-o.size):C.resolve(zt());let u=ur,h=o;return a.next(d=>C.forEach(d,(p,_)=>(u<_.largestBatchId&&(u=_.largestBatchId),o.get(p)?C.resolve():this.remoteDocumentCache.getEntry(e,p).next(E=>{h=h.insert(p,E)}))).next(()=>this.populateOverlays(e,d,o)).next(()=>this.computeViews(e,h,d,z())).next(p=>({batchId:u,changes:$l(p)})))})}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new L(t)).next(r=>{let s=Xn();return r.isFoundDocument()&&(s=s.insert(r.key,r)),s})}getDocumentsMatchingCollectionGroupQuery(e,t,r,s){const o=t.collectionGroup;let a=Xn();return this.indexManager.getCollectionParents(e,o).next(u=>C.forEach(u,h=>{const d=function(_,E){return new Pn(E,null,_.explicitOrderBy.slice(),_.filters.slice(),_.limit,_.limitType,_.startAt,_.endAt)}(t,h.child(o));return this.getDocumentsMatchingCollectionQuery(e,d,r,s).next(p=>{p.forEach((_,E)=>{a=a.insert(_,E)})})}).next(()=>a))}getDocumentsMatchingCollectionQuery(e,t,r,s){let o;return this.documentOverlayCache.getOverlaysForCollection(e,t.path,r.largestBatchId).next(a=>(o=a,this.remoteDocumentCache.getDocumentsMatchingQuery(e,t,r,o,s))).next(a=>{o.forEach((h,d)=>{const p=d.getKey();a.get(p)===null&&(a=a.insert(p,we.newInvalidDocument(p)))});let u=Xn();return a.forEach((h,d)=>{const p=o.get(h);p!==void 0&&ir(p.mutation,d,Ve.empty(),Z.now()),js(t,d)&&(u=u.insert(h,d))}),u})}}/**
1366 * @license
1367 * Copyright 2020 Google LLC
1368 *
1369 * Licensed under the Apache License, Version 2.0 (the "License");
1370 * you may not use this file except in compliance with the License.
1371 * You may obtain a copy of the License at
1372 *
1373 *   http://www.apache.org/licenses/LICENSE-2.0
1374 *
1375 * Unless required by applicable law or agreed to in writing, software
1376 * distributed under the License is distributed on an "AS IS" BASIS,
1377 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1378 * See the License for the specific language governing permissions and
1379 * limitations under the License.
1380 */class Ng{constructor(e){this.serializer=e,this.Lr=new Map,this.kr=new Map}getBundleMetadata(e,t){return C.resolve(this.Lr.get(t))}saveBundleMetadata(e,t){return this.Lr.set(t.id,function(s){return{id:s.id,version:s.version,createTime:Ge(s.createTime)}}(t)),C.resolve()}getNamedQuery(e,t){return C.resolve(this.kr.get(t))}saveNamedQuery(e,t){return this.kr.set(t.name,function(s){return{name:s.name,query:Ig(s.bundledQuery),readTime:Ge(s.readTime)}}(t)),C.resolve()}}/**
1381 * @license
1382 * Copyright 2022 Google LLC
1383 *
1384 * Licensed under the Apache License, Version 2.0 (the "License");
1385 * you may not use this file except in compliance with the License.
1386 * You may obtain a copy of the License at
1387 *
1388 *   http://www.apache.org/licenses/LICENSE-2.0
1389 *
1390 * Unless required by applicable law or agreed to in writing, software
1391 * distributed under the License is distributed on an "AS IS" BASIS,
1392 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1393 * See the License for the specific language governing permissions and
1394 * limitations under the License.
1395 */class Vg{constructor(){this.overlays=new te(L.comparator),this.qr=new Map}getOverlay(e,t){return C.resolve(this.overlays.get(t))}getOverlays(e,t){const r=zt();return C.forEach(t,s=>this.getOverlay(e,s).next(o=>{o!==null&&r.set(s,o)})).next(()=>r)}saveOverlays(e,t,r){return r.forEach((s,o)=>{this.St(e,t,o)}),C.resolve()}removeOverlaysForBatchId(e,t,r){const s=this.qr.get(r);return s!==void 0&&(s.forEach(o=>this.overlays=this.overlays.remove(o)),this.qr.delete(r)),C.resolve()}getOverlaysForCollection(e,t,r){const s=zt(),o=t.length+1,a=new L(t.child("")),u=this.overlays.getIteratorFrom(a);for(;u.hasNext();){const h=u.getNext().value,d=h.getKey();if(!t.isPrefixOf(d.path))break;d.path.length===o&&h.largestBatchId>r&&s.set(h.getKey(),h)}return C.resolve(s)}getOverlaysForCollectionGroup(e,t,r,s){let o=new te((d,p)=>d-p);const a=this.overlays.getIterator();for(;a.hasNext();){const d=a.getNext().value;if(d.getKey().getCollectionGroup()===t&&d.largestBatchId>r){let p=o.get(d.largestBatchId);p===null&&(p=zt(),o=o.insert(d.largestBatchId,p)),p.set(d.getKey(),d)}}const u=zt(),h=o.getIterator();for(;h.hasNext()&&(h.getNext().value.forEach((d,p)=>u.set(d,p)),!(u.size()>=s)););return C.resolve(u)}St(e,t,r){const s=this.overlays.get(r.key);if(s!==null){const a=this.qr.get(s.largestBatchId).delete(r.key);this.qr.set(s.largestBatchId,a)}this.overlays=this.overlays.insert(r.key,new Ym(t,r));let o=this.qr.get(t);o===void 0&&(o=z(),this.qr.set(t,o)),this.qr.set(t,o.add(r.key))}}/**
1396 * @license
1397 * Copyright 2024 Google LLC
1398 *
1399 * Licensed under the Apache License, Version 2.0 (the "License");
1400 * you may not use this file except in compliance with the License.
1401 * You may obtain a copy of the License at
1402 *
1403 *   http://www.apache.org/licenses/LICENSE-2.0
1404 *
1405 * Unless required by applicable law or agreed to in writing, software
1406 * distributed under the License is distributed on an "AS IS" BASIS,
1407 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1408 * See the License for the specific language governing permissions and
1409 * limitations under the License.
1410 */class Dg{constructor(){this.sessionToken=ge.EMPTY_BYTE_STRING}getSessionToken(e){return C.resolve(this.sessionToken)}setSessionToken(e,t){return this.sessionToken=t,C.resolve()}}/**
1411 * @license
1412 * Copyright 2017 Google LLC
1413 *
1414 * Licensed under the Apache License, Version 2.0 (the "License");
1415 * you may not use this file except in compliance with the License.
1416 * You may obtain a copy of the License at
1417 *
1418 *   http://www.apache.org/licenses/LICENSE-2.0
1419 *
1420 * Unless required by applicable law or agreed to in writing, software
1421 * distributed under the License is distributed on an "AS IS" BASIS,
1422 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1423 * See the License for the specific language governing permissions and
1424 * limitations under the License.
1425 */class Vo{constructor(){this.Qr=new ce(ue.$r),this.Ur=new ce(ue.Kr)}isEmpty(){return this.Qr.isEmpty()}addReference(e,t){const r=new ue(e,t);this.Qr=this.Qr.add(r),this.Ur=this.Ur.add(r)}Wr(e,t){e.forEach(r=>this.addReference(r,t))}removeReference(e,t){this.Gr(new ue(e,t))}zr(e,t){e.forEach(r=>this.removeReference(r,t))}jr(e){const t=new L(new Y([])),r=new ue(t,e),s=new ue(t,e+1),o=[];return this.Ur.forEachInRange([r,s],a=>{this.Gr(a),o.push(a.key)}),o}Jr(){this.Qr.forEach(e=>this.Gr(e))}Gr(e){this.Qr=this.Qr.delete(e),this.Ur=this.Ur.delete(e)}Hr(e){const t=new L(new Y([])),r=new ue(t,e),s=new ue(t,e+1);let o=z();return this.Ur.forEachInRange([r,s],a=>{o=o.add(a.key)}),o}containsKey(e){const t=new ue(e,0),r=this.Qr.firstAfterOrEqual(t);return r!==null&&e.isEqual(r.key)}}class ue{constructor(e,t){this.key=e,this.Yr=t}static $r(e,t){return L.comparator(e.key,t.key)||$(e.Yr,t.Yr)}static Kr(e,t){return $(e.Yr,t.Yr)||L.comparator(e.key,t.key)}}/**
1426 * @license
1427 * Copyright 2017 Google LLC
1428 *
1429 * Licensed under the Apache License, Version 2.0 (the "License");
1430 * you may not use this file except in compliance with the License.
1431 * You may obtain a copy of the License at
1432 *
1433 *   http://www.apache.org/licenses/LICENSE-2.0
1434 *
1435 * Unless required by applicable law or agreed to in writing, software
1436 * distributed under the License is distributed on an "AS IS" BASIS,
1437 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1438 * See the License for the specific language governing permissions and
1439 * limitations under the License.
1440 */class Og{constructor(e,t){this.indexManager=e,this.referenceDelegate=t,this.mutationQueue=[],this.tr=1,this.Zr=new ce(ue.$r)}checkEmpty(e){return C.resolve(this.mutationQueue.length===0)}addMutationBatch(e,t,r,s){const o=this.tr;this.tr++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];const a=new Jm(o,t,r,s);this.mutationQueue.push(a);for(const u of s)this.Zr=this.Zr.add(new ue(u.key,o)),this.indexManager.addToCollectionParentIndex(e,u.key.path.popLast());return C.resolve(a)}lookupMutationBatch(e,t){return C.resolve(this.Xr(t))}getNextMutationBatchAfterBatchId(e,t){const r=t+1,s=this.ei(r),o=s<0?0:s;return C.resolve(this.mutationQueue.length>o?this.mutationQueue[o]:null)}getHighestUnacknowledgedBatchId(){return C.resolve(this.mutationQueue.length===0?vo:this.tr-1)}getAllMutationBatches(e){return C.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){const r=new ue(t,0),s=new ue(t,Number.POSITIVE_INFINITY),o=[];return this.Zr.forEachInRange([r,s],a=>{const u=this.Xr(a.Yr);o.push(u)}),C.resolve(o)}getAllMutationBatchesAffectingDocumentKeys(e,t){let r=new ce($);return t.forEach(s=>{const o=new ue(s,0),a=new ue(s,Number.POSITIVE_INFINITY);this.Zr.forEachInRange([o,a],u=>{r=r.add(u.Yr)})}),C.resolve(this.ti(r))}getAllMutationBatchesAffectingQuery(e,t){const r=t.path,s=r.length+1;let o=r;L.isDocumentKey(o)||(o=o.child(""));const a=new ue(new L(o),0);let u=new ce($);return this.Zr.forEachWhile(h=>{const d=h.key.path;return!!r.isPrefixOf(d)&&(d.length===s&&(u=u.add(h.Yr)),!0)},a),C.resolve(this.ti(u))}ti(e){const t=[];return e.forEach(r=>{const s=this.Xr(r);s!==null&&t.push(s)}),t}removeMutationBatch(e,t){Q(this.ni(t.batchId,"removed")===0,55003),this.mutationQueue.shift();let r=this.Zr;
1440return C.forEach(t.mutations,s=>{const o=new ue(s.key,t.batchId);return r=r.delete(o),this.referenceDelegate.markPotentiallyOrphaned(e,s.key)}).next(()=>{this.Zr=r})}ir(e){}containsKey(e,t){const r=new ue(t,0),s=this.Zr.firstAfterOrEqual(r);return C.resolve(t.isEqual(s&&s.key))}performConsistencyCheck(e){return this.mutationQueue.length,C.resolve()}ni(e,t){return this.ei(e)}ei(e){return this.mutationQueue.length===0?0:e-this.mutationQueue[0].batchId}Xr(e){const t=this.ei(e);return t<0||t>=this.mutationQueue.length?null:this.mutationQueue[t]}}/**
1441 * @license
1442 * Copyright 2017 Google LLC
1443 *
1444 * Licensed under the Apache License, Version 2.0 (the "License");
1445 * you may not use this file except in compliance with the License.
1446 * You may obtain a copy of the License at
1447 *
1448 *   http://www.apache.org/licenses/LICENSE-2.0
1449 *
1450 * Unless required by applicable law or agreed to in writing, software
1451 * distributed under the License is distributed on an "AS IS" BASIS,
1452 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1453 * See the License for the specific language governing permissions and
1454 * limitations under the License.
1455 */class Mg{constructor(e){this.ri=e,this.docs=function(){return new te(L.comparator)}(),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,t){const r=t.key,s=this.docs.get(r),o=s?s.size:0,a=this.ri(t);return this.docs=this.docs.insert(r,{document:t.mutableCopy(),size:a}),this.size+=a-o,this.indexManager.addToCollectionParentIndex(e,r.path.popLast())}removeEntry(e){const t=this.docs.get(e);t&&(this.docs=this.docs.remove(e),this.size-=t.size)}getEntry(e,t){const r=this.docs.get(t);return C.resolve(r?r.document.mutableCopy():we.newInvalidDocument(t))}getEntries(e,t){let r=dt();return t.forEach(s=>{const o=this.docs.get(s);r=r.insert(s,o?o.document.mutableCopy():we.newInvalidDocument(s))}),C.resolve(r)}getDocumentsMatchingQuery(e,t,r,s){let o=dt();const a=t.path,u=new L(a.child("__id-9223372036854775808__")),h=this.docs.getIteratorFrom(u);for(;h.hasNext();){const{key:d,value:{document:p}}=h.getNext();if(!a.isPrefixOf(d.path))break;d.path.length>a.length+1||dm(hm(p),r)<=0||(s.has(p.key)||js(t,p))&&(o=o.insert(p.key,p.mutableCopy()))}return C.resolve(o)}getAllFromCollectionGroup(e,t,r,s){x(9500)}
1455ii(e,t){return C.forEach(this.docs,r=>t(r))}newChangeBuffer(e){return new Lg(this)}getSize(e){return C.resolve(this.size)}}class Lg extends Cg{constructor(e){super(),this.Nr=e}applyChanges(e){const t=[];return this.changes.forEach((r,s)=>{s.isValidDocument()?t.push(this.Nr.addEntry(e,s)):this.Nr.removeEntry(r)}),C.waitFor(t)}getFromCache(e,t){return this.Nr.getEntry(e,t)}getAllFromCache(e,t){return this.Nr.getEntries(e,t)}}/**
1456 * @license
1457 * Copyright 2017 Google LLC
1458 *
1459 * Licensed under the Apache License, Version 2.0 (the "License");
1460 * you may not use this file except in compliance with the License.
1461 * You may obtain a copy of the License at
1462 *
1463 *   http://www.apache.org/licenses/LICENSE-2.0
1464 *
1465 * Unless required by applicable law or agreed to in writing, software
1466 * distributed under the License is distributed on an "AS IS" BASIS,
1467 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1468 * See the License for the specific language governing permissions and
1469 * limitations under the License.
1470 */class xg{constructor(e){this.persistence=e,this.si=new Xt(t=>So(t),Po),this.lastRemoteSnapshotVersion=F.min(),this.highestTargetId=0,this.oi=0,this._i=new Vo,this.targetCount=0,this.ai=Tn.ur()}forEachTarget(e,t){return this.si.forEach((r,s)=>t(s)),C.resolve()}getLastRemoteSnapshotVersion(e){return C.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return C.resolve(this.oi)}allocateTargetId(e){return this.highestTargetId=this.ai.next(),C.resolve(this.highestTargetId)}setTargetsMetadata(e,t,r){return r&&(this.lastRemoteSnapshotVersion=r),t>this.oi&&(this.oi=t),C.resolve()}Pr(e){this.si.set(e.target,e);const t=e.targetId;t>this.highestTargetId&&(this.ai=new Tn(t),this.highestTargetId=t),e.sequenceNumber>this.oi&&(this.oi=e.sequenceNumber)}addTargetData(e,t){return this.Pr(t),this.targetCount+=1,C.resolve()}updateTargetData(e,t){return this.Pr(t),C.resolve()}removeTargetData(e,t){return this.si.delete(t.target),this._i.jr(t.targetId),this.targetCount-=1,C.resolve()}removeTargets(e,t,r){let s=0;const o=[];return this.si.forEach((a,u)=>{u.sequenceNumber<=t&&r.get(u.targetId)===null&&(this.si.delete(a),o.push(this.removeMatchingKeysForTargetId(e,u.targetId)),s++)}),C.waitFor(o).next(()=>s)}getTargetCount(e){return C.resolve(this.targetCount)}getTargetData(e,t){const r=this.si.get(t)||null;return C.resolve(r)}addMatchingKeys(e,t,r){return this._i.Wr(t,r),C.resolve()}removeMatchingKeys(e,t,r){this._i.zr(t,r);const s=this.persistence.referenceDelegate,o=[];return s&&t.forEach(a=>{o.push(s.markPotentiallyOrphaned(e,a))}),C.waitFor(o)}removeMatchingKeysForTargetId(e,t){return this._i.jr(t),C.resolve()}getMatchingKeysForTargetId(e,t){const r=this._i.Hr(t);return C.resolve(r)}containsKey(e,t){return C.resolve(this._i.containsKey(t))}}/**
1471 * @license
1472 * Copyright 2017 Google LLC
1473 *
1474 * Licensed under the Apache License, Version 2.0 (the "License");
1475 * you may not use this file except in compliance with the License.
1476 * You may obtain a copy of the License at
1477 *
1478 *   http://www.apache.org/licenses/LICENSE-2.0
1479 *
1480 * Unless required by applicable law or agreed to in writing, software
1481 * distributed under the License is distributed on an "AS IS" BASIS,
1482 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1483 * See the License for the specific language governing permissions and
1484 * limitations under the License.
1485 */class hh{constructor(e,t){this.ui={},this.overlays={},this.ci=new xs(0),this.li=!1,this.li=!0,this.hi=new Dg,this.referenceDelegate=e(this),this.Pi=new xg(this),this.indexManager=new wg,this.remoteDocumentCache=function(s){return new Mg(s)}(r=>this.referenceDelegate.Ti(r)),this.serializer=new Tg(t),this.Ii=new Ng(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.li=!1,Promise.resolve()}get started(){return this.li}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let t=this.overlays[e.toKey()];return t||(t=new Vg,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let r=this.ui[e.toKey()];return r||(r=new Og(t,this.referenceDelegate),this.ui[e.toKey()]=r),r}getGlobalsCache(){return this.hi}getTargetCache(){return this.Pi}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Ii}runTransaction(e,t,r){O("MemoryPersistence","Starting transaction:",e);const s=new Fg(this.ci.next());return this.referenceDelegate.Ei(),r(s).next(o=>this.referenceDelegate.di(s).next(()=>o)).toPromise().then(o=>(s.raiseOnCommittedEvent(),o))}Ai(e,t){return C.or(Object.values(this.ui).map(r=>()=>r.containsKey(e,t)))}}class Fg extends pm{constructor(e){super(),this.currentSequenceNumber=e}}class Do{constructor(e){this.persistence=e,this.Ri=new Vo,this.Vi=null}static mi(e){return new Do(e)}get fi(){if(this.Vi)return this.Vi;throw x(60996)}addReference(e,t,r){return this.Ri.addReference(r,t),this.fi.delete(r.toString()),C.resolve()}removeReference(e,t,r){return this.Ri.removeReference(r,t),this.fi.add(r.toString()),C.resolve()}markPotentiallyOrphaned(e,t){return this.fi.add(t.toString()),C.resolve()}
1485removeTarget(e,t){this.Ri.jr(t.targetId).forEach(s=>this.fi.add(s.toString()));const r=this.persistence.getTargetCache();return r.getMatchingKeysForTargetId(e,t.targetId).next(s=>{s.forEach(o=>this.fi.add(o.toString()))}).next(()=>r.removeTargetData(e,t))}Ei(){this.Vi=new Set}di(e){const t=this.persistence.getRemoteDocumentCache().newChangeBuffer();return C.forEach(this.fi,r=>{const s=L.fromPath(r);return this.gi(e,s).next(o=>{o||t.removeEntry(s,F.min())})}).next(()=>(this.Vi=null,t.apply(e)))}updateLimboDocument(e,t){return this.gi(e,t).next(r=>{r?this.fi.delete(t.toString()):this.fi.add(t.toString())})}Ti(e){return 0}gi(e,t){return C.or([()=>C.resolve(this.Ri.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.Ai(e,t)])}}class Is{constructor(e,t){this.persistence=e,this.pi=new Xt(r=>_m(r.path),(r,s)=>r.isEqual(s)),this.garbageCollector=Pg(this,t)}static mi(e,t){return new Is(e,t)}Ei(){}di(e){return C.resolve()}forEachTarget(e,t){return this.persistence.getTargetCache().forEachTarget(e,t)}gr(e){const t=this.wr(e);return this.persistence.getTargetCache().getTargetCount(e).next(r=>t.next(s=>r+s))}wr(e){let t=0;return this.pr(e,r=>{t++}).next(()=>t)}
1485pr(e,t){return C.forEach(this.pi,(r,s)=>this.br(e,r,s).next(o=>o?C.resolve():t(s)))}removeTargets(e,t,r){return this.persistence.getTargetCache().removeTargets(e,t,r)}removeOrphanedDocuments(e,t){let r=0;const s=this.persistence.getRemoteDocumentCache(),o=s.newChangeBuffer();return s.ii(e,a=>this.br(e,a,t).next(u=>{u||(r++,o.removeEntry(a,F.min()))})).next(()=>o.apply(e)).next(()=>r)}markPotentiallyOrphaned(e,t){return this.pi.set(t,e.currentSequenceNumber),C.resolve()}removeTarget(e,t){const r=t.withSequenceNumber(e.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(e,r)}addReference(e,t,r){return this.pi.set(r,e.currentSequenceNumber),C.resolve()}removeReference(e,t,r){return this.pi.set(r,e.currentSequenceNumber),C.resolve()}updateLimboDocument(e,t){return this.pi.set(t,e.currentSequenceNumber),C.resolve()}Ti(e){let t=e.key.toString().length;return e.isFoundDocument()&&(t+=rs(e.data.value)),t}br(e,t,r){return C.or([()=>this.persistence.Ai(e,t),()=>this.persistence.getTargetCache().containsKey(e,t),()=>{const s=this.pi.get(t);return C.resolve(s!==void 0&&s>r)}])}getCacheSize(e){return this.persistence.getRemoteDocumentCache().getSize(e)}}/**
1486 * @license
1487 * Copyright 2017 Google LLC
1488 *
1489 * Licensed under the Apache License, Version 2.0 (the "License");
1490 * you may not use this file except in compliance with the License.
1491 * You may obtain a copy of the License at
1492 *
1493 *   http://www.apache.org/licenses/LICENSE-2.0
1494 *
1495 * Unless required by applicable law or agreed to in writing, software
1496 * distributed under the License is distributed on an "AS IS" BASIS,
1497 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1498 * See the License for the specific language governing permissions and
1499 * limitations under the License.
1500 */class Oo{constructor(e,t,r,s){this.targetId=e,this.fromCache=t,this.Es=r,this.ds=s}static As(e,t){let r=z(),s=z();for(const o of t.docChanges)switch(o.type){case 0:r=r.add(o.doc.key);break;case 1:s=s.add(o.doc.key)}return new Oo(e,t.fromCache,r,s)}}/**
1501 * @license
1502 * Copyright 2023 Google LLC
1503 *
1504 * Licensed under the Apache License, Version 2.0 (the "License");
1505 * you may not use this file except in compliance with the License.
1506 * You may obtain a copy of the License at
1507 *
1508 *   http://www.apache.org/licenses/LICENSE-2.0
1509 *
1510 * Unless required by applicable law or agreed to in writing, software
1511 * distributed under the License is distributed on an "AS IS" BASIS,
1512 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1513 * See the License for the specific language governing permissions and
1514 * limitations under the License.
1515 */class Ug{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(e){this._documentReadCount+=e}}/**
1516 * @license
1517 * Copyright 2019 Google LLC
1518 *
1519 * Licensed under the Apache License, Version 2.0 (the "License");
1520 * you may not use this file except in compliance with the License.
1521 * You may obtain a copy of the License at
1522 *
1523 *   http://www.apache.org/licenses/LICENSE-2.0
1524 *
1525 * Unless required by applicable law or agreed to in writing, software
1526 * distributed under the License is distributed on an "AS IS" BASIS,
1527 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1528 * See the License for the specific language governing permissions and
1529 * limitations under the License.
1530 */class Bg{constructor(){this.Rs=!1,this.Vs=!1,this.fs=100,this.gs=function(){return bf()?8:mm(ve())>0?6:4}()}initialize(e,t){this.ps=e,this.indexManager=t,this.Rs=!0}getDocumentsMatchingQuery(e,t,r,s){const o={result:null};return this.ys(e,t).next(a=>{o.result=a}).next(()=>{if(!o.result)return this.ws(e,t,s,r).next(a=>{o.result=a})}).next(()=>{if(o.result)return;const a=new Ug;return this.Ss(e,t,a).next(u=>{if(o.result=u,this.Vs)return this.bs(e,t,a,u.size)})}).next(()=>o.result)}bs(e,t,r,s){return r.documentReadCount<this.fs?(cn()<=j.DEBUG&&O("QueryEngine","SDK will not create cache indexes for query:",un(t),"since it only creates cache indexes for collection contains","more than or equal to",this.fs,"documents"),C.resolve()):(cn()<=j.DEBUG&&O("QueryEngine","Query:",un(t),"scans",r.documentReadCount,"local documents and returns",s,"documents as results."),r.documentReadCount>this.gs*s?(cn()<=j.DEBUG&&O("QueryEngine","The SDK decides to create cache indexes for query:",un(t),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(e,We(t))):C.resolve())}ys(e,t){if(eu(t))return C.resolve(null);let r=We(t);return this.indexManager.getIndexType(e,r).next(s=>s===0?null:(t.limit!==null&&s===1&&(t=Es(t,null,"F"),r=We(t)),this.indexManager.getDocumentsMatchingTarget(e,r).next(o=>{const a=z(...o);return this.ps.getDocuments(e,a).next(u=>this.indexManager.getMinOffset(e,r).next(h=>{const d=this.Ds(t,u);return this.Cs(t,d,a,h.readTime)?this.ys(e,Es(t,null,"F")):this.vs(e,d,t,h)}))})))}ws(e,t,r,s){return eu(t)||s.isEqual(F.min())?C.resolve(null):this.ps.getDocuments(e,r).next(o=>{const a=this.Ds(t,o);return this.Cs(t,a,r,s)?C.resolve(null):(cn()<=j.DEBUG&&O("QueryEngine","Re-using previous result from %s to execute query: %s",s.toString(),un(t)),this.vs(e,a,t,lm(s,ur)).next(u=>u))})}Ds(e,t){let r=new ce(ql(e));return t.forEach((s,o)=>{js(e,o)&&(r=r.add(o))}),r}Cs(e,t,r,s){if(e.limit===null)return!1;if(r.size!==t.size)return!0;const o=e.limitType==="F"?t.last():t.first();return!!o&&(o.hasPendingWrites||o.version.compareTo(s)>0)}Ss(e,t,r){return cn()<=j.DEBUG&&O("QueryEngine","Using full collection scan to execute query:",un(t)),this.ps.getDocumentsMatchingQuery(e,t,Nt.min(),r)}vs(e,t,r,s){return this.ps.getDocumentsMatchingQuery(e,r,s).next(o=>(t.forEach(a=>{o=o.insert(a.key,a)}),o))}}/**
1531 * @license
1532 * Copyright 2020 Google LLC
1533 *
1534 * Licensed under the Apache License, Version 2.0 (the "License");
1535 * you may not use this file except in compliance with the License.
1536 * You may obtain a copy of the License at
1537 *
1538 *   http://www.apache.org/licenses/LICENSE-2.0
1539 *
1540 * Unless required by applicable law or agreed to in writing, software
1541 * distributed under the License is distributed on an "AS IS" BASIS,
1542 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1543 * See the License for the specific language governing permissions and
1544 * limitations under the License.
1545 */const Mo="LocalStore",qg=3e8;class jg{constructor(e,t,r,s){this.persistence=e,this.Fs=t,this.serializer=s,this.Ms=new te($),this.xs=new Xt(o=>So(o),Po),this.Os=new Map,this.Ns=e.getRemoteDocumentCache(),this.Pi=e.getTargetCache(),this.Ii=e.getBundleCache(),this.Bs(r)}Bs(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new kg(this.Ns,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.Ns.setIndexManager(this.indexManager),this.Fs.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction("Collect garbage","readwrite-primary",t=>e.collect(t,this.Ms))}}function $g(n,e,t,r){return new jg(n,e,t,r)}async function dh(n,e){const t=U(n);return await t.persistence.runTransaction("Handle user change","readonly",r=>{let s;return t.mutationQueue.getAllMutationBatches(r).next(o=>(s=o,t.Bs(e),t.mutationQueue.getAllMutationBatches(r))).next(o=>{const a=[],u=[];let h=z();for(const d of s){a.push(d.batchId);for(const p of d.mutations)h=h.add(p.key)}for(const d of o){u.push(d.batchId);for(const p of d.mutations)h=h.add(p.key)}return t.localDocuments.getDocuments(r,h).next(d=>({Ls:d,removedBatchIds:a,addedBatchIds:u}))})})}function zg(n,e){const t=U(n);return t.persistence.runTransaction("Acknowledge batch","readwrite-primary",r=>{const s=e.batch.keys(),o=t.Ns.newChangeBuffer({trackRemovals:!0});return function(u,h,d,p){const _=d.batch,E=_.keys();let S=C.resolve();return E.forEach(b=>{S=S.next(()=>p.getEntry(h,b)).next(D=>{const N=d.docVersions.get(b);Q(N!==null,48541),D.version.compareTo(N)<0&&(_.applyToRemoteDocument(D,d),D.isValidDocument()&&(D.setReadTime(d.commitVersion),p.addEntry(D)))})}),S.next(()=>u.mutationQueue.removeMutationBatch(h,_))}(t,r,e,o).next(()=>o.apply(r)).next(()=>t.mutationQueue.performConsistencyCheck(r)).next(()=>t.documentOverlayCache.removeOverlaysForBatchId(r,s,e.batch.batchId)).next(()=>t.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(r,function(u){let h=z();for(let d=0;d<u.mutationResults.length;++d)u.mutationResults[d].transformResults.length>0&&(h=h.add(u.batch.mutations[d].key));return h}(e))).next(()=>t.localDocuments.getDocuments(r,s))})}function fh(n){const e=U(n);return e.persistence.runTransaction("Get last remote snapshot version","readonly",t=>e.Pi.getLastRemoteSnapshotVersion(t))}function Hg(n,e){const t=U(n),r=e.snapshotVersion;let s=t.Ms;return t.persistence.runTransaction("Apply remote event","readwrite-primary",o=>{const a=t.Ns.newChangeBuffer({trackRemovals:!0});s=t.Ms;const u=[];
1545e.targetChanges.forEach((p,_)=>{const E=s.get(_);if(!E)return;u.push(t.Pi.removeMatchingKeys(o,p.removedDocuments,_).next(()=>t.Pi.addMatchingKeys(o,p.addedDocuments,_)));let S=E.withSequenceNumber(o.currentSequenceNumber);e.targetMismatches.get(_)!==null?S=S.withResumeToken(ge.EMPTY_BYTE_STRING,F.min()).withLastLimboFreeSnapshotVersion(F.min()):p.resumeToken.approximateByteSize()>0&&(S=S.withResumeToken(p.resumeToken,r)),s=s.insert(_,S),function(D,N,q){return D.resumeToken.approximateByteSize()===0||N.snapshotVersion.toMicroseconds()-D.snapshotVersion.toMicroseconds()>=qg?!0:q.addedDocuments.size+q.modifiedDocuments.size+q.removedDocuments.size>0}(E,S,p)&&u.push(t.Pi.updateTargetData(o,S))});let h=dt(),d=z();if(e.documentUpdates.forEach(p=>{e.resolvedLimboDocuments.has(p)&&u.push(t.persistence.referenceDelegate.updateLimboDocument(o,p))}),u.push(Wg(o,a,e.documentUpdates).next(p=>{h=p.ks,d=p.qs})),!r.isEqual(F.min())){const p=t.Pi.getLastRemoteSnapshotVersion(o).next(_=>t.Pi.setTargetsMetadata(o,o.currentSequenceNumber,r));u.push(p)}return C.waitFor(u).next(()=>a.apply(o)).next(()=>t.localDocuments.getLocalViewOfDocuments(o,h,d)).next(()=>h)}).then(o=>(t.Ms=s,o))}function Wg(n,e,t){let r=z(),s=z();return t.forEach(o=>r=r.add(o)),e.getEntries(n,r).next(o=>{let a=dt();return t.forEach((u,h)=>{const d=o.get(u);h.isFoundDocument()!==d.isFoundDocument()&&(s=s.add(u)),h.isNoDocument()&&h.version.isEqual(F.min())?(e.removeEntry(u,h.readTime),a=a.insert(u,h)):!d.isValidDocument()||h.version.compareTo(d.version)>0||h.version.compareTo(d.version)===0&&d.hasPendingWrites?(e.addEntry(h),a=a.insert(u,h)):O(Mo,"Ignoring outdated watch update for ",u,". Current version:",d.version," Watch version:",h.version)}),{ks:a,qs:s}})}function Gg(n,e){const t=U(n);return t.persistence.runTransaction("Get next mutation batch","readonly",r=>(e===void 0&&(e=vo),t.mutationQueue.getNextMutationBatchAfterBatchId(r,e)))}function Kg(n,e){const t=U(n);return t.persistence.runTransaction("Allocate target","readwrite",r=>{let s;return t.Pi.getTargetData(r,e).next(o=>o?(s=o,C.resolve(s)):t.Pi.allocateTargetId(r).next(a=>(s=new At(e,a,"TargetPurposeListen",r.currentSequenceNumber),t.Pi.addTargetData(r,s).next(()=>s))))}).then(r=>{const s=t.Ms.get(r.targetId);return(s===null||r.snapshotVersion.compareTo(s.snapshotVersion)>0)&&(t.Ms=t.Ms.insert(r.targetId,r),t.xs.set(e,r.targetId)),r})}async function io(n,e,t){const r=U(n),s=r.Ms.get(e),o=t?"readwrite":"readwrite-primary";try{t||await r.persistence.runTransaction("Release target",o,a=>r.persistence.referenceDelegate.removeTarget(a,s))}catch(a){if(!Sn(a))throw a;O(Mo,`Failed to update sequence numbers for target ${e}: ${a}`)}r.Ms=r.Ms.remove(e),r.xs.delete(s.target)}function fu(n,e,t){const r=U(n);let s=F.min(),o=z();return r.persistence.runTransaction("Execute query","readwrite",a=>function(h,d,p){const _=U(h),E=_.xs.get(p);return E!==void 0?C.resolve(_.Ms.get(E)):_.Pi.getTargetData(d,p)}(r,a,We(e)).next(u=>{if(u)return s=u.lastLimboFreeSnapshotVersion,r.Pi.getMatchingKeysForTargetId(a,u.targetId).next(h=>{o=h})}).next(()=>r.Fs.getDocumentsMatchingQuery(a,e,t?s:F.min(),t?o:z())).next(u=>(Qg(r,Lm(e),u),{documents:u,Qs:o})))}function Qg(n,e,t){let r=n.Os.get(e)||F.min();t.forEach((s,o)=>{o.readTime.compareTo(r)>0&&(r=o.readTime)}),n.Os.set(e,r)}class pu{constructor(){this.activeTargetIds=jm()}zs(e){this.activeTargetIds=this.activeTargetIds.add(e)}js(e){this.activeTargetIds=this.activeTargetIds.delete(e)}Gs(){const e={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(e)}}class Jg{constructor(){this.Mo=new pu,this.xo={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,t,r){}addLocalQueryTarget(e,t=!0){return t&&this.Mo.zs(e),this.xo[e]||"not-current"}updateQueryState(e,t,r){this.xo[e]=t}removeLocalQueryTarget(e){this.Mo.js(e)}isLocalQueryTarget(e){return this.Mo.activeTargetIds.has(e)}clearQueryState(e){delete this.xo[e]}getAllActiveQueryTargets(){return this.Mo.activeTargetIds}isActiveQueryTarget(e){return this.Mo.activeTargetIds.has(e)}start(){return this.Mo=new pu,Promise.resolve()}handleUserChange(e,t,r){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}}/**
1546 * @license
1547 * Copyright 2019 Google LLC
1548 *
1549 * Licensed under the Apache License, Version 2.0 (the "License");
1550 * you may not use this file except in compliance with the License.
1551 * You may obtain a copy of the License at
1552 *
1553 *   http://www.apache.org/licenses/LICENSE-2.0
1554 *
1555 * Unless required by applicable law or agreed to in writing, software
1556 * distributed under the License is distributed on an "AS IS" BASIS,
1557 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1558 * See the License for the specific language governing permissions and
1559 * limitations under the License.
1560 */class Yg{Oo(e){}shutdown(){}}/**
1561 * @license
1562 * Copyright 2019 Google LLC
1563 *
1564 * Licensed under the Apache License, Version 2.0 (the "License");
1565 * you may not use this file except in compliance with the License.
1566 * You may obtain a copy of the License at
1567 *
1568 *   http://www.apache.org/licenses/LICENSE-2.0
1569 *
1570 * Unless required by applicable law or agreed to in writing, software
1571 * distributed under the License is distributed on an "AS IS" BASIS,
1572 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1573 * See the License for the specific language governing permissions and
1574 * limitations under the License.
1575 */const mu="ConnectivityMonitor";class gu{constructor(){this.No=()=>this.Bo(),this.Lo=()=>this.ko(),this.qo=[],this.Qo()}Oo(e){this.qo.push(e)}shutdown(){window.removeEventListener("online",this.No),window.removeEventListener("offline",this.Lo)}Qo(){window.addEventListener("online",this.No),window.addEventListener("offline",this.Lo)}Bo(){O(mu,"Network connectivity changed: AVAILABLE");for(const e of this.qo)e(0)}ko(){O(mu,"Network connectivity changed: UNAVAILABLE");for(const e of this.qo)e(1)}static v(){return typeof window<"u"&&window.addEventListener!==void 0&&window.removeEventListener!==void 0}}/**
1576 * @license
1577 * Copyright 2023 Google LLC
1578 *
1579 * Licensed under the Apache License, Version 2.0 (the "License");
1580 * you may not use this file except in compliance with the License.
1581 * You may obtain a copy of the License at
1582 *
1583 *   http://www.apache.org/licenses/LICENSE-2.0
1584 *
1585 * Unless required by applicable law or agreed to in writing, software
1586 * distributed under the License is distributed on an "AS IS" BASIS,
1587 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1588 * See the License for the specific language governing permissions and
1589 * limitations under the License.
1590 */let es=null;function oo(){return es===null?es=function(){return 268435456+Math.round(2147483648*Math.random())}():es++,"0x"+es.toString(16)}/**
1591 * @license
1592 * Copyright 2020 Google LLC
1593 *
1594 * Licensed under the Apache License, Version 2.0 (the "License");
1595 * you may not use this file except in compliance with the License.
1596 * You may obtain a copy of the License at
1597 *
1598 *   http://www.apache.org/licenses/LICENSE-2.0
1599 *
1600 * Unless required by applicable law or agreed to in writing, software
1601 * distributed under the License is distributed on an "AS IS" BASIS,
1602 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1603 * See the License for the specific language governing permissions and
1604 * limitations under the License.
1605 */const xi="RestConnection",Xg={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery"};class Zg{get $o(){return!1}constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;const t=e.ssl?"https":"http",r=encodeURIComponent(this.databaseId.projectId),s=encodeURIComponent(this.databaseId.database);this.Uo=t+"://"+e.host,this.Ko=`projects/${r}/databases/${s}`,this.Wo=this.databaseId.database===gs?`project_id=${r}`:`project_id=${r}&database_id=${s}`}Go(e,t,r,s,o){const a=oo(),u=this.zo(e,t.toUriEncodedString());O(xi,`Sending RPC '${e}' ${a}:`,u,r);const h={"google-cloud-resource-prefix":this.Ko,"x-goog-request-params":this.Wo};this.jo(h,s,o);const{host:d}=new URL(u),p=Yt(d);return this.Jo(e,u,h,r,p).then(_=>(O(xi,`Received RPC '${e}' ${a}: `,_),_),_=>{throw cr(xi,`RPC '${e}' ${a} failed with error: `,_,"url: ",u,"request:",r),_})}Ho(e,t,r,s,o,a){return this.Go(e,t,r,s,o)}jo(e,t,r){e["X-Goog-Api-Client"]=function(){return"gl-js/ fire/"+An}(),e["Content-Type"]="text/plain",this.databaseInfo.appId&&(e["X-Firebase-GMPID"]=this.databaseInfo.appId),t&&t.headers.forEac
1605h((s,o)=>e[o]=s),r&&r.headers.forEach((s,o)=>e[o]=s)}zo(e,t){const r=Xg[e];return`${this.Uo}/v1/${t}:${r}`}terminate(){}}/**
1606 * @license
1607 * Copyright 2017 Google LLC
1608 *
1609 * Licensed under the Apache License, Version 2.0 (the "License");
1610 * you may not use this file except in compliance with the License.
1611 * You may obtain a copy of the License at
1612 *
1613 *   http://www.apache.org/licenses/LICENSE-2.0
1614 *
1615 * Unless required by applicable law or agreed to in writing, software
1616 * distributed under the License is distributed on an "AS IS" BASIS,
1617 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1618 * See the License for the specific language governing permissions and
1619 * limitations under the License.
1620 */class e_{constructor(e){this.Yo=e.Yo,this.Zo=e.Zo}Xo(e){this.e_=e}t_(e){this.n_=e}r_(e){this.i_=e}onMessage(e){this.s_=e}close(){this.Zo()}send(e){this.Yo(e)}o_(){this.e_()}__(){this.n_()}a_(e){this.i_(e)}u_(e){this.s_(e)}}/**
1621 * @license
1622 * Copyright 2017 Google LLC
1623 *
1624 * Licensed under the Apache License, Version 2.0 (the "License");
1625 * you may not use this file except in compliance with the License.
1626 * You may obtain a copy of the License at
1627 *
1628 *   http://www.apache.org/licenses/LICENSE-2.0
1629 *
1630 * Unless required by applicable law or agreed to in writing, software
1631 * distributed under the License is distributed on an "AS IS" BASIS,
1632 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1633 * See the License for the specific language governing permissions and
1634 * limitations under the License.
1635 */const Ie="WebChannelConnection";class t_ extends Zg{constructor(e){super(e),this.c_=[],this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}Jo(e,t,r,s,o){const a=oo();return new Promise((u,h)=>{const d=new ml;d.setWithCredentials(!0),d.listenOnce(gl.COMPLETE,()=>{try{switch(d.getLastErrorCode()){case ns.NO_ERROR:const _=d.getResponseJson();O(Ie,`XHR for RPC '${e}' ${a} received:`,JSON.stringify(_)),u(_);break;case ns.TIMEOUT:O(Ie,`RPC '${e}' ${a} timed out`),h(new V(P.DEADLINE_EXCEEDED,"Request time out"));break;case ns.HTTP_ERROR:const E=d.getStatus();if(O(Ie,`RPC '${e}' ${a} failed with status:`,E,"response text:",d.getResponseText()),E>0){let S=d.getResponseJson();Array.isArray(S)&&(S=S[0]);const b=S==null?void 0:S.error;if(b&&b.status&&b.message){const D=function(q){const B=q.toLowerCase().replace(/_/g,"-");return Object.values(P).indexOf(B)>=0?B:P.UNKNOWN}(b.status);h(new V(D,b.message))}else h(new V(P.UNKNOWN,"Server responded with status "+d.getStatus()))}else h(new V(P.UNAVAILABLE,"Connection failed."));break;default:x(9055,{l_:e,streamId:a,h_:d.getLastErrorCode(),P_:d.getLastError()})}}finally{O(Ie,`RPC '${e}' ${a} completed.`)}});const p=JSON.stringify(s);O(Ie,`RPC '${e}' ${a} sending request:`,s),d.send(t,"POST",p,r,15)})}T_(e,t,r){const s=oo(),o=[this.Uo,"/","google.firestore.v1.Firestore","/",e,"/channel"],a=El(),u=yl(),h={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},d=this.longPollingOptions.timeoutSeconds;d!==void 0&&(h.longPollingTimeout=Math.round(1e3*d)),this.useFetchStreams&&(h.useFetchStreams=!0),this.jo(h.initMessageHeaders,t,r),h.encodeInitMessageHeaders=!0;const p=o.join("");O(Ie,`Creating RPC '${e}' stream ${s}: ${p}`,h);const _=a.createWebChannel(p,h);this.I_(_);let E=!1,S=!1;const b=new e_({Yo:N=>{S?O(Ie,`Not sending because RPC '${e}' stream ${s} is closed:`,N):(E||(O(Ie,`Opening RPC '${e}' stream ${s} transport.`),_.open(),E=!0),O(Ie,`RPC '${e}' stream ${s} sending:`,N),_.send(N))},Zo:()=>_.close()}),D=(N,q,B)=>{N.listen(q,W=>{try{B(W)}catch(se){setTimeout(()=>{throw se},0)}})};return D(_,Yn.EventType.OPEN,()=>{S||(O(Ie,`RPC '${e}' stream ${s} transport opened.`),b.o_())}),D(_,Yn.EventType.CLOSE,()=>{S||(S=!0,O(Ie,`RPC '${e}' stream ${s} transport closed`),b.a_(),this.E_(_))}
1635),D(_,Yn.EventType.ERROR,N=>{S||(S=!0,cr(Ie,`RPC '${e}' stream ${s} transport errored. Name:`,N.name,"Message:",N.message),b.a_(new V(P.UNAVAILABLE,"The operation could not be completed")))}),D(_,Yn.EventType.MESSAGE,N=>{var q;if(!S){const B=N.data[0];Q(!!B,16349);const W=B,se=(W==null?void 0:W.error)||((q=W[0])==null?void 0:q.error);if(se){O(Ie,`RPC '${e}' stream ${s} received error:`,se);const tt=se.status;let he=function(y){const T=ie[y];if(T!==void 0)return Zl(T)}(tt),w=se.message;he===void 0&&(he=P.INTERNAL,w="Unknown error status: "+tt+" with message "+se.message),S=!0,b.a_(new V(he,w)),_.close()}else O(Ie,`RPC '${e}' stream ${s} received:`,B),b.u_(B)}}),D(u,_l.STAT_EVENT,N=>{N.stat===Ki.PROXY?O(Ie,`RPC '${e}' stream ${s} detected buffering proxy`):N.stat===Ki.NOPROXY&&O(Ie,`RPC '${e}' stream ${s} detected no buffering proxy`)}),setTimeout(()=>{b.__()},0),b}terminate(){this.c_.forEach(e=>e.close()),this.c_=[]}I_(e){this.c_.push(e)}E_(e){this.c_=this.c_.filter(t=>t===e)}}function Fi(){return typeof document<"u"?document:null}/**
1636 * @license
1637 * Copyright 2020 Google LLC
1638 *
1639 * Licensed under the Apache License, Version 2.0 (the "License");
1640 * you may not use this file except in compliance with the License.
1641 * You may obtain a copy of the License at
1642 *
1643 *   http://www.apache.org/licenses/LICENSE-2.0
1644 *
1645 * Unless required by applicable law or agreed to in writing, software
1646 * distributed under the License is distributed on an "AS IS" BASIS,
1647 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1648 * See the License for the specific language governing permissions and
1649 * limitations under the License.
1650 */function Ks(n){return new og(n,!0)}/**
1651 * @license
1652 * Copyright 2017 Google LLC
1653 *
1654 * Licensed under the Apache License, Version 2.0 (the "License");
1655 * you may not use this file except in compliance with the License.
1656 * You may obtain a copy of the License at
1657 *
1658 *   http://www.apache.org/licenses/LICENSE-2.0
1659 *
1660 * Unless required by applicable law or agreed to in writing, software
1661 * distributed under the License is distributed on an "AS IS" BASIS,
1662 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1663 * See the License for the specific language governing permissions and
1664 * limitations under the License.
1665 */class ph{constructor(e,t,r=1e3,s=1.5,o=6e4){this.Mi=e,this.timerId=t,this.d_=r,this.A_=s,this.R_=o,this.V_=0,this.m_=null,this.f_=Date.now(),this.reset()}reset(){this.V_=0}g_(){this.V_=this.R_}p_(e){this.cancel();const t=Math.floor(this.V_+this.y_()),r=Math.max(0,Date.now()-this.f_),s=Math.max(0,t-r);s>0&&O("ExponentialBackoff",`Backing off for ${s} ms (base delay: ${this.V_} ms, delay with jitter: ${t} ms, last attempt: ${r} ms ago)`),this.m_=this.Mi.enqueueAfterDelay(this.timerId,s,()=>(this.f_=Date.now(),e())),this.V_*=this.A_,this.V_<this.d_&&(this.V_=this.d_),this.V_>this.R_&&(this.V_=this.R_)}w_(){this.m_!==null&&(this.m_.skipDelay(),this.m_=null)}cancel(){this.m_!==null&&(this.m_.cancel(),this.m_=null)}y_(){return(Math.random()-.5)*this.V_}}/**
1666 * @license
1667 * Copyright 2017 Google LLC
1668 *
1669 * Licensed under the Apache License, Version 2.0 (the "License");
1670 * you may not use this file except in compliance with the License.
1671 * You may obtain a copy of the License at
1672 *
1673 *   http://www.apache.org/licenses/LICENSE-2.0
1674 *
1675 * Unless required by applicable law or agreed to in writing, software
1676 * distributed under the License is distributed on an "AS IS" BASIS,
1677 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1678 * See the License for the specific language governing permissions and
1679 * limitations under the License.
1680 */const _u="PersistentStream";class mh{constructor(e,t,r,s,o,a,u,h){this.Mi=e,this.S_=r,this.b_=s,this.connection=o,this.authCredentialsProvider=a,this.appCheckCredentialsProvider=u,this.listener=h,this.state=0,this.D_=0,this.C_=null,this.v_=null,this.stream=null,this.F_=0,this.M_=new ph(e,t)}x_(){return this.state===1||this.state===5||this.O_()}O_(){return this.state===2||this.state===3}start(){this.F_=0,this.state!==4?this.auth():this.N_()}async stop(){this.x_()&&await this.close(0)}B_(){this.state=0,this.M_.reset()}L_(){this.O_()&&this.C_===null&&(this.C_=this.Mi.enqueueAfterDelay(this.S_,6e4,()=>this.k_()))}q_(e){this.Q_(),this.stream.send(e)}
1680async k_(){if(this.O_())return this.close(0)}Q_(){this.C_&&(this.C_.cancel(),this.C_=null)}U_(){this.v_&&(this.v_.cancel(),this.v_=null)}async close(e,t){this.Q_(),this.U_(),this.M_.cancel(),this.D_++,e!==4?this.M_.reset():t&&t.code===P.RESOURCE_EXHAUSTED?(ht(t.toString()),ht("Using maximum backoff delay to prevent overloading the backend."),this.M_.g_()):t&&t.code===P.UNAUTHENTICATED&&this.state!==3&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),this.stream!==null&&(this.K_(),this.stream.close(),this.stream=null),this.state=e,await this.listener.r_(t)}K_(){}auth(){this.state=1;const e=this.W_(this.D_),t=this.D_;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then(([r,s])=>{this.D_===t&&this.G_(r,s)},r=>{e(()=>{const s=new V(P.UNKNOWN,"Fetching auth token failed: "+r.message);return this.z_(s)})})}G_(e,t){const r=this.W_(this.D_);this.stream=this.j_(e,t),this.stream.Xo(()=>{r(()=>this.listener.Xo())}),this.stream.t_(()=>{r(()=>(this.state=2,this.v_=this.Mi.enqueueAfterDelay(this.b_,1e4,()=>(this.O_()&&(this.state=3),Promise.resolve())),this.listener.t_()))}),this.stream.r_(s=>{r(()=>this.z_(s))}),this.stream.onMessage(s=>{r(()=>++this.F_==1?this.J_(s):this.onNext(s))})}N_(){this.state=5,this.M_.p_(async()=>{this.state=0,this.start()})}z_(e){return O(_u,`close with error: ${e}`),this.stream=null,this.close(4,e)}W_(e){return t=>{this.Mi.enqueueAndForget(()=>this.D_===e?t():(O(_u,"stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve()))}}}class n_ extends mh{constructor(e,t,r,s,o,a){super(e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",t,r,s,a),this.serializer=o}j_(e,t){return this.connection.T_("Listen",e,t)}J_(e){return this.onNext(e)}onNext(e){this.M_.reset();const t=ug(this.serializer,e),r=function(o){if(!("targetChange"in o))return F.min();const a=o.targetChange;return a.targetIds&&a.targetIds.length?F.min():a.readTime?Ge(a.readTime):F.min()}(e);return this.listener.H_(t,r)}Y_(e){const t={};t.database=so(this.serializer),t.addTarget=function(o,a){let u;const h=a.target;if(u=Zi(h)?{documents:dg(o,h)}:{query:fg(o,h).ft},u.targetId=a.targetId,a.resumeToken.approximateByteSize()>0){u.resumeToken=nh(o,a.resumeToken);const d=to(o,a.expectedCount);d!==null&&(u.expectedCount=d)}else if(a.snapshotVersion.compareTo(F.min())>0){u.readTime=Ts(o,a.snapshotVersion.toTimestamp());const d=to(o,a.expectedCount);d!==null&&(u.expectedCount=d)}return u}(this.serializer,e);const r=mg(this.serializer,e);r&&(t.labels=r),this.q_(t)}Z_(e){const t={};t.database=so(this.serializer),t.removeTarget=e,this.q_(t)}}class r_ extends mh{constructor(e,t,r,s,o,a){super(e,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",t,r,s,a),this.serializer=o}get X_(){return this.F_>0}start(){this.lastStreamToken=void 0,super.start()}K_(){this.X_&&this.ea([])}j_(e,t){return this.connection.T_("Write",e,t)}J_(e){return Q(!!e.streamToken,31322),this.lastStreamToken=e.streamToken,Q(!e.writeResults||e.writeResults.length===0,55816),this.listener.ta()}onNext(e){Q(!!e.streamToken,12678),this.lastStreamToken=e.streamToken,this.M_.reset();const t=hg(e.writeResults,e.commitTime),r=Ge(e.commitTime);return this.listener.na(r,t)}ra(){const e={};e.database=so(this.serializer),this.q_(e)}ea(e){const t={streamToken:this.lastStreamToken,writes:e.map(r=>lg(this.serializer,r))};this.q_(t)}}/**
1681 * @license
1682 * Copyright 2017 Google LLC
1683 *
1684 * Licensed under the Apache License, Version 2.0 (the "License");
1685 * you may not use this file except in compliance with the License.
1686 * You may obtain a copy of the License at
1687 *
1688 *   http://www.apache.org/licenses/LICENSE-2.0
1689 *
1690 * Unless required by applicable law or agreed to in writing, software
1691 * distributed under the License is distributed on an "AS IS" BASIS,
1692 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1693 * See the License for the specific language governing permissions and
1694 * limitations under the License.
1695 */class s_{}class i_ extends s_{constructor(e,t,r,s){super(),this.authCredentials=e,this.appCheckCredentials=t,this.connection=r,this.serializer
1695=s,this.ia=!1}sa(){if(this.ia)throw new V(P.FAILED_PRECONDITION,"The client has already been terminated.")}Go(e,t,r,s){return this.sa(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([o,a])=>this.connection.Go(e,no(t,r),s,o,a)).catch(o=>{throw o.name==="FirebaseError"?(o.code===P.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),o):new V(P.UNKNOWN,o.toString())})}Ho(e,t,r,s,o){return this.sa(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([a,u])=>this.connection.Ho(e,no(t,r),s,a,u,o)).catch(a=>{throw a.name==="FirebaseError"?(a.code===P.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),a):new V(P.UNKNOWN,a.toString())})}terminate(){this.ia=!0,this.connection.terminate()}}class o_{constructor(e,t){this.asyncQueue=e,this.onlineStateHandler=t,this.state="Unknown",this.oa=0,this._a=null,this.aa=!0}ua(){this.oa===0&&(this.ca("Unknown"),this._a=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,()=>(this._a=null,this.la("Backend didn't respond within 10 seconds."),this.ca("Offline"),Promise.resolve())))}ha(e){this.state==="Online"?this.ca("Unknown"):(this.oa++,this.oa>=1&&(this.Pa(),this.la(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.ca("Offline")))}set(e){this.Pa(),this.oa=0,e==="Online"&&(this.aa=!1),this.ca(e)}ca(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}la(e){const t=`Could not reach Cloud Firestore backend. ${e}
1696This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.`;this.aa?(ht(t),this.aa=!1):O("OnlineStateTracker",t)}Pa(){this._a!==null&&(this._a.cancel(),this._a=null)}}/**
1697 * @license
1698 * Copyright 2017 Google LLC
1699 *
1700 * Licensed under the Apache License, Version 2.0 (the "License");
1701 * you may not use this file except in compliance with the License.
1702 * You may obtain a copy of the License at
1703 *
1704 *   http://www.apache.org/licenses/LICENSE-2.0
1705 *
1706 * Unless required by applicable law or agreed to in writing, software
1707 * distributed under the License is distributed on an "AS IS" BASIS,
1708 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1709 * See the License for the specific language governing permissions and
1710 * limitations under the License.
1711 */const Qt="RemoteStore";class a_{constructor(e,t,r,s,o){this.localStore=e,this.datastore=t,this.asyncQueue=r,this.remoteSyncer={},this.Ta=[],this.Ia=new Map,this.Ea=new Set,this.da=[],this.Aa=o,this.Aa.Oo(a=>{r.enqueueAndForget(async()=>{Zt(this)&&(O(Qt,"Restarting streams for network reachability change."),await async function(h){const d=U(h);d.Ea.add(4),await vr(d),d.Ra.set("Unknown"),d.Ea.delete(4),await Qs(d)}(this))})}),this.Ra=new o_(r,s)}}async function Qs(n){if(Zt(n))for(const e of n.da)await e(!0)}async function vr(n){for(const e of n.da)await e(!1)}function gh(n,e){const t=U(n);t.Ia.has(e.targetId)||(t.Ia.set(e.targetId,e),Uo(t)?Fo(t):Cn(t).O_()&&xo(t,e))}function Lo(n,e){const t=U(n),r=Cn(t);t.Ia.delete(e),r.O_()&&_h(t,e),t.Ia.size===0&&(r.O_()?r.L_():Zt(t)&&t.Ra.set("Unknown"))}function xo(n,e){if(n.Va.Ue(e.targetId),e.resumeToken.approximateByteSize()>0||e.snapshotVersion.compareTo(F.min())>0){const t=n.remoteSyncer.getRemoteKeysForTarget(e.targetId).size;e=e.withExpectedCount(t)}Cn(n).Y_(e)}function _h(n,e){n.Va.Ue(e),Cn(n).Z_(e)}function Fo(n){n.Va=new ng({getRemoteKeysForTarget:e=>n.remoteSyncer.getRemoteKeysForTarget(e),At:e=>n.Ia.get(e)||null,ht:()=>n.datastore.serializer.databaseId}),Cn(n).start(),n.Ra.ua()}function Uo(n){return Zt(n)&&!Cn(n).x_()&&n.Ia.size>0}function Zt(n){return U(n).Ea.size===0}function yh(n){n.Va=void 0}async function c_(n){n.Ra.set("Online")}async function u_(n){n.Ia.forEach((e,t)=>{xo(n,e)})}async function l_(n,e){yh(n),Uo(n)?(n.Ra.ha(e),Fo(n)):n.Ra.set("Unknown")}async function h_(n,e,t){if(n.Ra.set("Online"),e instanceof th&&e.state===2&&e.cause)try{await async function(s,o){const a=o.cause;for(const u of o.targetIds)s.Ia.has(u)&&(await s.remoteSyncer.rejectListen(u,a),s.Ia.delete(u),s.Va.removeTarget(u))}(n,e)}catch(r){O(Qt,"Failed to remove targets %s: %s ",e.targetIds.join(","),r),await ws(n,r)}else if(e instanceof os?n.Va.Ze(e):e instanceof eh?n.Va.st(e):n.Va.tt(e),!t.isEqual(F.min()))try{const r=await fh(n.localStore);t.compareTo(r)>=0&&await function(o,a){const u=o.Va.Tt(a);
1711return u.targetChanges.forEach((h,d)=>{if(h.resumeToken.approximateByteSize()>0){const p=o.Ia.get(d);p&&o.Ia.set(d,p.withResumeToken(h.resumeToken,a))}}),u.targetMismatches.forEach((h,d)=>{const p=o.Ia.get(h);if(!p)return;o.Ia.set(h,p.withResumeToken(ge.EMPTY_BYTE_STRING,p.snapshotVersion)),_h(o,h);const _=new At(p.target,h,d,p.sequenceNumber);xo(o,_)}),o.remoteSyncer.applyRemoteEvent(u)}(n,t)}catch(r){O(Qt,"Failed to raise snapshot:",r),await ws(n,r)}}async function ws(n,e,t){if(!Sn(e))throw e;n.Ea.add(1),await vr(n),n.Ra.set("Offline"),t||(t=()=>fh(n.localStore)),n.asyncQueue.enqueueRetryable(async()=>{O(Qt,"Retrying IndexedDB access"),await t(),n.Ea.delete(1),await Qs(n)})}function Eh(n,e){return e().catch(t=>ws(n,t,e))}async function Js(n){const e=U(n),t=Mt(e);let r=e.Ta.length>0?e.Ta[e.Ta.length-1].batchId:vo;for(;d_(e);)try{const s=await Gg(e.localStore,r);if(s===null){e.Ta.length===0&&t.L_();break}r=s.batchId,f_(e,s)}catch(s){await ws(e,s)}Th(e)&&Ih(e)}function d_(n){return Zt(n)&&n.Ta.length<10}function f_(n,e){n.Ta.push(e);const t=Mt(n);t.O_()&&t.X_&&t.ea(e.mutations)}function Th(n){return Zt(n)&&!Mt(n).x_()&&n.Ta.length>0}function Ih(n){Mt(n).start()}async function p_(n){Mt(n).ra()}async function m_(n){const e=Mt(n);for(const t of n.Ta)e.ea(t.mutations)}async function g_(n,e,t){const r=n.Ta.shift(),s=bo.from(r,e,t);await Eh(n,()=>n.remoteSyncer.applySuccessfulWrite(s)),await Js(n)}async function __(n,e){e&&Mt(n).X_&&await async function(r,s){if(function(a){return Zm(a)&&a!==P.ABORTED}(s.code)){const o=r.Ta.shift();Mt(r).B_(),await Eh(r,()=>r.remoteSyncer.rejectFailedWrite(o.batchId,s)),await Js(r)}}(n,e),Th(n)&&Ih(n)}async function yu(n,e){const t=U(n);t.asyncQueue.verifyOperationInProgress(),O(Qt,"RemoteStore received new credentials");const r=Zt(t);t.Ea.add(3),await vr(t),r&&t.Ra.set("Unknown"),await t.remoteSyncer.handleCredentialChange(e),t.Ea.delete(3),await Qs(t)}async function y_(n,e){const t=U(n);e?(t.Ea.delete(2),await Qs(t)):e||(t.Ea.add(2),await vr(t),t.Ra.set("Unknown"))}function Cn(n){return n.ma||(n.ma=function(t,r,s){const o=U(t);return o.sa(),new n_(r,o.connection,o.authCredentials,o.appCheckCredentials,o.serializer,s)}(n.datastore,n.asyncQueue,{Xo:c_.bind(null,n),t_:u_.bind(null,n),r_:l_.bind(null,n),H_:h_.bind(null,n)}),n.da.push(async e=>{e?(n.ma.B_(),Uo(n)?Fo(n):n.Ra.set("Unknown")):(await n.ma.stop(),yh(n))})),n.ma}function Mt(n){return n.fa||(n.fa=function(t,r,s){const o=U(t);return o.sa(),new r_(r,o.connection,o.authCredentials,o.appCheckCredentials,o.serializer,s)}(n.datastore,n.asyncQueue,{Xo:()=>Promise.resolve(),t_:p_.bind(null,n),r_:__.bind(null,n),ta:m_.bind(null,n),na:g_.bind(null,n)}),n.da.push(async e=>{e?(n.fa.B_(),await Js(n)):(await n.fa.stop(),n.Ta.length>0&&(O(Qt,`Stopping write stream with ${n.Ta.length} pending writes`),n.Ta=[]))})),n.fa}/**
1712 * @license
1713 * Copyright 2017 Google LLC
1714 *
1715 * Licensed under the Apache License, Version 2.0 (the "License");
1716 * you may not use this file except in compliance with the License.
1717 * You may obtain a copy of the License at
1718 *
1719 *   http://www.apache.org/licenses/LICENSE-2.0
1720 *
1721 * Unless required by applicable law or agreed to in writing, software
1722 * distributed under the License is distributed on an "AS IS" BASIS,
1723 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1724 * See the License for the specific language governing permissions and
1725 * limitations under the License.
1726 */class Bo{constructor(e,t,r,s,o){this.asyncQueue=e,this.timerId=t,this.targetTimeMs=r,this.op=s,this.removalCallback=o,this.deferred=new at,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch(a=>{})}get promise(){return this.deferred.promise}static createAndSchedule(e,t,r,s,o){const a=Date.now()+r,u=new Bo(e,t,a,s,o);return u.start(r),u}start(e){this.timerHandle=setTimeout(()=>this.handleDelayElapsed(),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){this.timerHandle!==null&&(this.clearTimeout(),this.deferred.reject(new V(P.CANCELLED,"Operation cancelled"+(e?": "+e:""))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget(()=>this.timerHandle!==null?(this.clearTimeout(),this.op().then(e=>this.deferred.resolve(e))):Promise.resolve())}clearTimeout(){this.timerHandle!==null&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}}function qo(n,e){if(ht("AsyncQueue",`${e}: ${n}`),Sn(n))return new V(P.UNAVAILABLE,`${e}: ${n}`);throw n}/**
1727 * @license
1728 * Copyright 2017 Google LLC
1729 *
1730 * Licensed under the Apache License, Version 2.0 (the "License");
1731 * you may not use this file except in compliance with the License.
1732 * You may obtain a copy of the License at
1733 *
1734 *   http://www.apache.org/licenses/LICENSE-2.0
1735 *
1736 * Unless required by applicable law or agreed to in writing, software
1737 * distributed under the License is distributed on an "AS IS" BASIS,
1738 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1739 * See the License for the specific language governing permissions and
1740 * limitations under the License.
1741 */class dn{static emptySet(e){return new dn(e.comparator)}constructor(e){this.comparator=e?(t,r)=>e(t,r)||L.comparator(t.key,r.key):(t,r)=>L.comparator(t.key,r.key),this.keyedMap=Xn(),this.sortedSet=new te(this.comparator)}has(e){return this.keyedMap.get(e)!=null}get(e){return this.keyedMap.get(e)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(e){const t=this.keyedMap.get(e);return t?this.sortedSet.indexOf(t):-1}get size(){return this.sortedSet.size}forEach(e){this.sortedSet.inorderTraversal((t,r)=>(e(t),!1))}add(e){const t=this.delete(e.key);return t.copy(t.keyedMap.insert(e.key,e),t.sortedSet.insert(e,null))}delete(e){const t=this.get(e);return t?this.copy(this.keyedMap.remove(e),this.sortedSet.remove(t)):this}isEqual(e){if(!(e instanceof dn)||this.size!==e.size)return!1;const t=this.sortedSet.getIterator(),r=e.sortedSet.getIterator();for(;t.hasNext();){const s=t.getNext().key,o=r.getNext().key;if(!s.isEqual(o))return!1}return!0}toString(){const e=[];return this.forEach(t=>{e.push(t.toString())}),e.length===0?"DocumentSet ()":`DocumentSet (
1742  `+e.join(`  
1743`)+`
1744)`}copy(e,t){const r=new dn;return r.comparator=this.comparator,r.keyedMap=e,r.sortedSet=t,r}}/**
1745 * @license
1746 * Copyright 2017 Google LLC
1747 *
1748 * Licensed under the Apache License, Version 2.0 (the "License");
1749 * you may not use this file except in compliance with the License.
1750 * You may obtain a copy of the License at
1751 *
1752 *   http://www.apache.org/licenses/LICENSE-2.0
1753 *
1754 * Unless required by applicable law or agreed to in writing, software
1755 * distributed under the License is distributed on an "AS IS" BASIS,
1756 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1757 * See the License for the specific language governing permissions and
1758 * limitations under the License.
1759 */class Eu{constructor(){this.ga=new te(L.comparator)}track(e){const t=e.doc.key,r=this.ga.get(t);r?e.type!==0&&r.type===3?this.ga=this.ga.insert(t,e):e.type===3&&r.type!==1?this.ga=this.ga.insert(t,{type:r.type,doc:e.doc}):e.type===2&&r.type===2?this.ga=this.ga.insert(t,{type:2,doc:e.doc}):e.type===2&&r.type===0?this.ga=this.ga.insert(t,{type:0,doc:e.doc}):e.type===1&&r.type===0?this.ga=this.ga.remove(t):e.type===1&&r.type===2?this.ga=this.ga.insert(t,{type:1,doc:r.doc}):e.type===0&&r.type===1?this.ga=this.ga.insert(t,{type:2,doc:e.doc}):x(63341,{Rt:e,pa:r}):this.ga=this.ga.insert(t,e)}ya(){const e=[];return this.ga.inorderTraversal((t,r)=>{e.push(r)}),e}}class In{constructor(e,t,r,s,o,a,u,h,d){this.query=e,this.docs=t,this.oldDocs=r,this.docChanges=s,this.mutatedKeys=o,this.fromCache=a,this.syncStateChanged=u,this.excludesMetadataChanges=h,this.hasCachedResults=d}static fromInitialDocuments(e,t,r,s,o){const a=[];return t.forEach(u=>{a.push({type:0,doc:u})}),new In(e,t,dn.emptySet(t),a,r,s,!0,!1,o)}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)&&qs(this.query,e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;const t=this.docChanges,r=e.docChanges;if(t.length!==r.length)return!1;for(let s=0;s<t.length;s++)if(t[s].type!==r[s].type||!t[s].doc.isEqual(r[s].doc))return!1;return!0}}/**
1760 * @license
1761 * Copyright 2017 Google LLC
1762 *
1763 * Licensed under the Apache License, Version 2.0 (the "License");
1764 * you may not use this file except in compliance with the License.
1765 * You may obtain a copy of the License at
1766 *
1767 *   http://www.apache.org/licenses/LICENSE-2.0
1768 *
1769 * Unless required by applicable law or agreed to in writing, softw
1769are
1770 * distributed under the License is distributed on an "AS IS" BASIS,
1771 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1772 * See the License for the specific language governing permissions and
1773 * limitations under the License.
1774 */class E_{constructor(){this.wa=void 0,this.Sa=[]}ba(){return this.Sa.some(e=>e.Da())}}class T_{constructor(){this.queries=Tu(),this.onlineState="Unknown",this.Ca=new Set}terminate(){(function(t,r){const s=U(t),o=s.queries;s.queries=Tu(),o.forEach((a,u)=>{for(const h of u.Sa)h.onError(r)})})(this,new V(P.ABORTED,"Firestore shutting down"))}}function Tu(){return new Xt(n=>Bl(n),qs)}async function jo(n,e){const t=U(n);let r=3;const s=e.query;let o=t.queries.get(s);o?!o.ba()&&e.Da()&&(r=2):(o=new E_,r=e.Da()?0:1);try{switch(r){case 0:o.wa=await t.onListen(s,!0);break;case 1:o.wa=await t.onListen(s,!1);break;case 2:await t.onFirstRemoteStoreListen(s)}}catch(a){const u=qo(a,`Initialization of query '${un(e.query)}' failed`);return void e.onError(u)}t.queries.set(s,o),o.Sa.push(e),e.va(t.onlineState),o.wa&&e.Fa(o.wa)&&zo(t)}async function $o(n,e){const t=U(n),r=e.query;let s=3;const o=t.queries.get(r);if(o){const a=o.Sa.indexOf(e);a>=0&&(o.Sa.splice(a,1),o.Sa.length===0?s=e.Da()?0:1:!o.ba()&&e.Da()&&(s=2))}switch(s){case 0:return t.queries.delete(r),t.onUnlisten(r,!0);case 1:return t.queries.delete(r),t.onUnlisten(r,!1);case 2:return t.onLastRemoteStoreUnlisten(r);default:return}}function I_(n,e){const t=U(n);let r=!1;for(const s of e){const o=s.query,a=t.queries.get(o);if(a){for(const u of a.Sa)u.Fa(s)&&(r=!0);a.wa=s}}r&&zo(t)}function w_(n,e,t){const r=U(n),s=r.queries.get(e);if(s)for(const o of s.Sa)o.onError(t);r.queries.delete(e)}function zo(n){n.Ca.forEach(e=>{e.next()})}var ao,Iu;(Iu=ao||(ao={})).Ma="default",Iu.Cache="cache";class Ho{constructor(e,t,r){this.query=e,this.xa=t,this.Oa=!1,this.Na=null,this.onlineState="Unknown",this.options=r||{}}Fa(e){if(!this.options.includeMetadataChanges){const r=[];for(const s of e.docChanges)s.type!==3&&r.push(s);e=new In(e.query,e.docs,e.oldDocs,r,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let t=!1;return this.Oa?this.Ba(e)&&(this.xa.next(e),t=!0):this.La(e,this.onlineState)&&(this.ka(e),t=!0),this.Na=e,t}onError(e){this.xa.error(e)}va(e){this.onlineState=e;let t=!1;return this.Na&&!this.Oa&&this.La(this.Na,e)&&(this.ka(this.Na),t=!0),t}La(e,t){if(!e.fromCache||!this.Da())return!0;const r=t!=="Offline";return(!this.options.qa||!r)&&(!e.docs.isEmpty()||e.hasCachedResults||t==="Offline")}Ba(e){if(e.docChanges.length>0)return!0;const t=this.Na&&this.Na.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&this.options.includeMetadataChanges===!0}ka(e){e=In.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.Oa=!0,this.xa.next(e)}Da(){return this.options.source!==ao.Cache}}/**
1775 * @license
1776 * Copyright 2017 Google LLC
1777 *
1778 * Licensed under the Apache License, Version 2.0 (the "License");
1779 * you may not use this file except in compliance with the License.
1780 * You may obtain a copy of the License at
1781 *
1782 *   http://www.apache.org/licenses/LICENSE-2.0
1783 *
1784 * Unless required by applicable law or agreed to in writing, software
1785 * distributed under the License is distributed on an "AS IS" BASIS,
1786 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1787 * See the License for the specific language governing permissions and
1788 * limitations under the License.
1789 */class wh{constructor(e){this.key=e}}class vh{constructor(e){this.key=e}}class v_{constructor(e,t){this.query=e,this.Ya=t,this.Za=null,this.hasCachedResults=!1,this.current=!1,this.Xa=z(),this.mutatedKeys=z(),this.eu=ql(e),this.tu=new dn(this.eu)}get nu(){return this.Ya}ru(e,t){const r=t?t.iu:new Eu,s=t?t.tu:this.tu;let o=t?t.mutatedKeys:this.mutatedKeys,a=s,u=!1;const h=this.query.limitType==="F"&&s.size===this.query.limit?s.last():null,d=this.query.limitType==="L"&&s.size===this.query.limit?s.first():null;if(e.inorderTraversal((p,_)=>{const E=s.get(p),S=js(this.query,_)?_:null,b=!!E&&this.mutatedKeys.has(E.key),D=!!S&&(S.hasLocalMutations||this.mutatedKeys.has(S.key)&&S.hasCommittedMutations);let N=!1;E&&S?E.data.isEqual(S.data)?b!==D&&(r.track({type:3,doc:S}),N=!0):this.su(E,S)||(r.track({type:2,doc:S}),N=!0,(h&&this.eu(S,h)>0||d&&this.eu(S,d)<0)&&(u=!0)):!E&&S?(r.track({type:0,doc:S}),N=!0):E&&!S&&(r.track({type:1,doc:E}),N=!0,(h||d)&&(u=!0)),N&&(S?(a=a.add(S),o=D?o.add(p):o.delete(p)):(a=a.delete(p),o=o.delete(p)))}),this.query.limit!==null)for(;a.size>this.query.limit;){const p=this.query.limitType==="F"?a.last():a.first();a=a.delete(p.key),o=o.delete(p.key),r.track({type:1,doc:p})}return{tu:a,iu:r,Cs:u,mutatedKeys:o}}su(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}
1789applyChanges(e,t,r,s){const o=this.tu;this.tu=e.tu,this.mutatedKeys=e.mutatedKeys;const a=e.iu.ya();a.sort((p,_)=>function(S,b){const D=N=>{switch(N){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return x(20277,{Rt:N})}};return D(S)-D(b)}(p.type,_.type)||this.eu(p.doc,_.doc)),this.ou(r),s=s??!1;const u=t&&!s?this._u():[],h=this.Xa.size===0&&this.current&&!s?1:0,d=h!==this.Za;return this.Za=h,a.length!==0||d?{snapshot:new In(this.query,e.tu,o,a,e.mutatedKeys,h===0,d,!1,!!r&&r.resumeToken.approximateByteSize()>0),au:u}:{au:u}}va(e){return this.current&&e==="Offline"?(this.current=!1,this.applyChanges({tu:this.tu,iu:new Eu,mutatedKeys:this.mutatedKeys,Cs:!1},!1)):{au:[]}}uu(e){return!this.Ya.has(e)&&!!this.tu.has(e)&&!this.tu.get(e).hasLocalMutations}ou(e){e&&(e.addedDocuments.forEach(t=>this.Ya=this.Ya.add(t)),e.modifiedDocuments.forEach(t=>{}),e.removedDocuments.forEach(t=>this.Ya=this.Ya.delete(t)),this.current=e.current)}_u(){if(!this.current)return[];const e=this.Xa;this.Xa=z(),this.tu.forEach(r=>{this.uu(r.key)&&(this.Xa=this.Xa.add(r.key))});const t=[];return e.forEach(r=>{this.Xa.has(r)||t.push(new vh(r))}),this.Xa.forEach(r=>{e.has(r)||t.push(new wh(r))}),t}cu(e){this.Ya=e.Qs,this.Xa=z();const t=this.ru(e.documents);return this.applyChanges(t,!0)}lu(){return In.fromInitialDocuments(this.query,this.tu,this.mutatedKeys,this.Za===0,this.hasCachedResults)}}const Wo="SyncEngine";class A_{constructor(e,t,r){this.query=e,this.targetId=t,this.view=r}}class R_{constructor(e){this.key=e,this.hu=!1}}class S_{constructor(e,t,r,s,o,a){this.localStore=e,this.remoteStore=t,this.eventManager=r,this.sharedClientState=s,this.currentUser=o,this.maxConcurrentLimboResolutions=a,this.Pu={},this.Tu=new Xt(u=>Bl(u),qs),this.Iu=new Map,this.Eu=new Set,this.du=new te(L.comparator),this.Au=new Map,this.Ru=new Vo,this.Vu={},this.mu=new Map,this.fu=Tn.cr(),this.onlineState="Unknown",this.gu=void 0}get isPrimaryClient(){return this.gu===!0}}async function P_(n,e,t=!0){const r=bh(n);let s;const o=r.Tu.get(e);return o?(r.sharedClientState.addLocalQueryTarget(o.targetId),s=o.view.lu()):s=await Ah(r,e,t,!0),s}async function C_(n,e){const t=bh(n);await Ah(t,e,!0,!1)}async function Ah(n,e,t,r){const s=await Kg(n.localStore,We(e)),o=s.targetId,a=n.sharedClientState.addLocalQueryTarget(o,t);let u;return r&&(u=await b_(n,e,o,a==="current",s.resumeToken)),n.isPrimaryClient&&t&&gh(n.remoteStore,s),u}async function b_(n,e,t,r,s){n.pu=(_,E,S)=>async function(D,N,q,B){let W=N.view.ru(q);W.Cs&&(W=await fu(D.localStore,N.query,!1).then(({documents:w})=>N.view.ru(w,W)));const se=B&&B.targetChanges.get(N.targetId),tt=B&&B.targetMismatches.get(N.targetId)!=null,he=N.view.applyChanges(W,D.isPrimaryClient,se,tt);return vu(D,N.targetId,he.au),he.snapshot}(n,_,E,S);const o=await fu(n.localStore,e,!0),a=new v_(e,o.Qs),u=a.ru(o.documents),h=wr.createSynthesizedTargetChangeForCurrentChange(t,r&&n.onlineState!=="Offline",s),d=a.applyChanges(u,n.isPrimaryClient,h);vu(n,t,d.au);const p=new A_(e,t,a);return n.Tu.set(e,p),n.Iu.has(t)?n.Iu.get(t).push(e):n.Iu.set(t,[e]),d.snapshot}async function k_(n,e,t){const r=U(n),s=r.Tu.get(e),o=r.Iu.get(s.targetId);if(o.length>1)return r.Iu.set(s.targetId,o.filter(a=>!qs(a,e))),void r.Tu.delete(e);r.isPrimaryClient?(r.sharedClientState.removeLocalQueryTarget(s.targetId),r.sharedCl
1789ientState.isActiveQueryTarget(s.targetId)||await io(r.localStore,s.targetId,!1).then(()=>{r.sharedClientState.clearQueryState(s.targetId),t&&Lo(r.remoteStore,s.targetId),co(r,s.targetId)}).catch(Rn)):(co(r,s.targetId),await io(r.localStore,s.targetId,!0))}async function N_(n,e){const t=U(n),r=t.Tu.get(e),s=t.Iu.get(r.targetId);t.isPrimaryClient&&s.length===1&&(t.sharedClientState.removeLocalQueryTarget(r.targetId),Lo(t.remoteStore,r.targetId))}async function V_(n,e,t){const r=U_(n);try{const s=await function(a,u){const h=U(a),d=Z.now(),p=u.reduce((S,b)=>S.add(b.key),z());let _,E;return h.persistence.runTransaction("Locally write mutations","readwrite",S=>{let b=dt(),D=z();return h.Ns.getEntries(S,p).next(N=>{b=N,b.forEach((q,B)=>{B.isValidDocument()||(D=D.add(q))})}).next(()=>h.localDocuments.getOverlayedDocuments(S,b)).next(N=>{_=N;const q=[];for(const B of u){const W=Km(B,_.get(B.key).overlayedDocument);W!=null&&q.push(new Ft(B.key,W,Vl(W.value.mapValue),Se.exists(!0)))}return h.mutationQueue.addMutationBatch(S,d,q,u)}).next(N=>{E=N;const q=N.applyToLocalDocumentSet(_,D);return h.documentOverlayCache.saveOverlays(S,N.batchId,q)})}).then(()=>({batchId:E.batchId,changes:$l(_)}))}(r.localStore,e);r.sharedClientState.addPendingMutation(s.batchId),function(a,u,h){let d=a.Vu[a.currentUser.toKey()];d||(d=new te($)),d=d.insert(u,h),a.Vu[a.currentUser.toKey()]=d}(r,s.batchId,t),await Ar(r,s.changes),await Js(r.remoteStore)}catch(s){const o=qo(s,"Failed to persist write");t.reject(o)}}async function Rh(n,e){const t=U(n);try{const r=await Hg(t.localStore,e);
1789e.targetChanges.forEach((s,o)=>{const a=t.Au.get(o);a&&(Q(s.addedDocuments.size+s.modifiedDocuments.size+s.removedDocuments.size<=1,22616),s.addedDocuments.size>0?a.hu=!0:s.modifiedDocuments.size>0?Q(a.hu,14607):s.removedDocuments.size>0&&(Q(a.hu,42227),a.hu=!1))}),await Ar(t,r,e)}catch(r){await Rn(r)}}function wu(n,e,t){const r=U(n);if(r.isPrimaryClient&&t===0||!r.isPrimaryClient&&t===1){const s=[];r.Tu.forEach((o,a)=>{const u=a.view.va(e);u.snapshot&&s.push(u.snapshot)}),function(a,u){const h=U(a);h.onlineState=u;let d=!1;h.queries.forEach((p,_)=>{for(const E of _.Sa)E.va(u)&&(d=!0)}),d&&zo(h)}(r.eventManager,e),s.length&&r.Pu.H_(s),r.onlineState=e,r.isPrimaryClient&&r.sharedClientState.setOnlineState(e)}}async function D_(n,e,t){const r=U(n);r.sharedClientState.updateQueryState(e,"rejected",t);const s=r.Au.get(e),o=s&&s.key;if(o){let a=new te(L.comparator);a=a.insert(o,we.newNoDocument(o,F.min()));const u=z().add(o),h=new Gs(F.min(),new Map,new te($),a,u);await Rh(r,h),r.du=r.du.remove(o),r.Au.delete(e),Go(r)}else await io(r.localStore,e,!1).then(()=>co(r,e,t)).catch(Rn)}async function O_(n,e){const t=U(n),r=e.batch.batchId;try{const s=await zg(t.localStore,e);Ph(t,r,null),Sh(t,r),t.sharedClientState.updateMutationState(r,"acknowledged"),await Ar(t,s)}catch(s){await Rn(s)}}async function M_(n,e,t){const r=U(n);try{const s=await function(a,u){const h=U(a);return h.persistence.runTransaction("Reject batch","readwrite-primary",d=>{let p;return h.mutationQueue.lookupMutationBatch(d,u).next(_=>(Q(_!==null,37113),p=_.keys(),h.mutationQueue.removeMutationBatch(d,_))).next(()=>h.mutationQueue.performConsistencyCheck(d)).next(()=>h.documentOverlayCache.removeOverlaysForBatchId(d,p,u)).next(()=>h.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(d,p)).next(()=>h.localDocuments.getDocuments(d,p))})}(r.localStore,e);Ph(r,e,t),Sh(r,e),r.sharedClientState.updateMutationState(e,"rejected",t),await Ar(r,s)}catch(s){await Rn(s)}}function Sh(n,e){(n.mu.get(e)||[]).forEach(t=>{t.resolve()}),n.mu.delete(e)}function Ph(n,e,t){const r=U(n);let s=r.Vu[r.currentUser.toKey()];if(s){const o=s.get(e);o&&(t?o.reject(t):o.resolve(),s=s.remove(e)),r.Vu[r.currentUser.toKey()]=s}}function co(n,e,t=null){n.sharedClientState.removeLocalQueryTarget(e);for(const r of n.Iu.get(e))n.Tu.delete(r),t&&n.Pu.yu(r,t);n.Iu.delete(e),n.isPrimaryClient&&n.Ru.jr(e).forEach(r=>{n.Ru.containsKey(r)||Ch(n,r)})}function Ch(n,e){n.Eu.delete(e.path.canonicalString());const t=n.du.get(e);t!==null&&(Lo(n.remoteStore,t),n.du=n.du.remove(e),n.Au.delete(t),Go(n))}function vu(n,e,t){for(const r of t)r instanceof wh?(n.Ru.addReference(r.key,e),L_(n,r)):r instanceof vh?(O(Wo,"Document no longer in limbo: "+r.key),n.Ru.removeReference(r.key,e),n.Ru.containsKey(r.key)||Ch(n,r.key)):x(19791,{wu:r})}function L_(n,e){const t=e.key,r=t.path.canonicalString();n.du.get(t)||n.Eu.has(r)||(O(Wo,"New document in limbo: "+t),n.Eu.add(r),Go(n))}function Go(n){for(;n.Eu.size>0&&n.du.size<n.maxConcurrentLimboResolutions;){const e=n.Eu.values().next().value;n.Eu.delete(e);const t=new L(Y.fromString(e)),r=n.fu.next();n.Au.set(r,new R_(t)),n.du=n.du.insert(t,r),gh(n.remoteStore,new At(We(Bs(t.path)),r,"TargetPurposeLimboResolution",xs.ce))}}async function Ar(n,e,t){const r=U(n),s=[],o=[],a=[];r.Tu.isEmpty()||(r.Tu.forEach((u,h)=>{a.push(r.pu(h,e,t).then(d=>{var p;if((d||t)&&r.isPrimaryClient){const _=d?!d.fromCache:(p=t==null?void 0:t.targetChanges.get(h.targetId))==null?void 0:p.current;
1789r.sharedClientState.updateQueryState(h.targetId,_?"current":"not-current")}if(d){s.push(d);const _=Oo.As(h.targetId,d);o.push(_)}}))}),await Promise.all(a),r.Pu.H_(s),await async function(h,d){const p=U(h);try{await p.persistence.runTransaction("notifyLocalViewChanges","readwrite",_=>C.forEach(d,E=>C.forEach(E.Es,S=>p.persistence.referenceDelegate.addReference(_,E.targetId,S)).next(()=>C.forEach(E.ds,S=>p.persistence.referenceDelegate.removeReference(_,E.targetId,S)))))}catch(_){if(!Sn(_))throw _;O(Mo,"Failed to update sequence numbers: "+_)}for(const _ of d){const E=_.targetId;if(!_.fromCache){const S=p.Ms.get(E),b=S.snapshotVersion,D=S.withLastLimboFreeSnapshotVersion(b);p.Ms=p.Ms.insert(E,D)}}}(r.localStore,o))}async function x_(n,e){const t=U(n);if(!t.currentUser.isEqual(e)){O(Wo,"User change. New user:",e.toKey());const r=await dh(t.localStore,e);t.currentUser=e,function(o,a){o.mu.forEach(u=>{u.forEach(h=>{h.reject(new V(P.CANCELLED,a))})}),o.mu.clear()}(t,"'waitForPendingWrites' promise is rejected due to a user change."),t.sharedClientState.handleUserChange(e,r.removedBatchIds,r.addedBatchIds),await Ar(t,r.Ls)}}function F_(n,e){const t=U(n),r=t.Au.get(e);if(r&&r.hu)return z().add(r.key);{let s=z();const o=t.Iu.get(e);if(!o)return s;for(const a of o){const u=t.Tu.get(a);s=s.unionWith(u.view.nu)}return s}}function bh(n){const e=U(n);return e.remoteStore.remoteSyncer.applyRemoteEvent=Rh.bind(null,e),e.remoteStore.remoteSyncer.getRemoteKeysForTarget=F_.bind(null,e),e.remoteStore.remoteSyncer.rejectListen=D_.bind(null,e),e.Pu.H_=I_.bind(null,e.eventManager),e.Pu.yu=w_.bind(null,e.eventManager),e}function U_(n){const e=U(n);return e.remoteStore.remoteSyncer.applySuccessfulWrite=O_.bind(null,e),e.remoteStore.remoteSyncer.rejectFailedWrite=M_.bind(null,e),e}class vs{constructor(){this.kind="memory",this.synchronizeTabs=!1}async initialize(e){this.serializer=Ks(e.databaseInfo.databaseId),this.sharedClientState=this.Du(e),this.persistence=this.Cu(e),await this.persistence.start(),this.localStore=this.vu(e),this.gcScheduler=this.Fu(e,this.localStore),this.indexBackfillerScheduler=this.Mu(e,this.localStore)}Fu(e,t){return null}Mu(e,t){return null}vu(e){return $g(this.persistence,new Bg,e.initialUser,this.serializer)}Cu(e){return new hh(Do.mi,this.serializer)}Du(e){return new Jg}async terminate(){var e,t;(e=this.gcScheduler)==null||e.stop(),(t=this.indexBackfillerScheduler)==null||t.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}}vs.provider={build:()=>new vs};class B_ extends vs{constructor(e){super(),this.cacheSizeBytes=e}Fu(e,t){Q(this.persistence.referenceDelegate instanceof Is,46915);const r=this.persistence.referenceDelegate.garbageCollector;return new Rg(r,e.asyncQueue,t)}Cu(e){const t=this.cacheSizeBytes!==void 0?Ce.withCacheSize(this.cacheSizeBytes):Ce.DEFAULT;return new hh(r=>Is.mi(r,t),this.serializer)}}class uo{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=r=>wu(this.syncEngine,r,1),this.remoteStore.remoteSyncer.handleCredentialChange=x_.bind(null,this.syncEngine),await y_(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return function(){return new T_}()}createDatastore(e){const t=Ks(e.databaseInfo.databaseId),r=function(o){return new t_(o)}(e.databaseInfo);return function(o,a,u,h){return new i_(o,a,u,h)}(e.authCredentials,e.appCheckCredentials,r,t)}createRemoteStore(e){return function(r,s,o,a,u){return new a_(r,s,o,a,u)}(this.localStore,this.datastore,e.asyncQueue,t=>wu(this.syncEngine,t,0),function(){return gu.v()?new gu:new Yg}())}createSyncEngine(e,t){return function(s,o,a,u,h,d,p){const _=new S_(s,o,a,u,h,d);return p&&(_.gu=!0),_}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,e.initialUser,e.maxConcurrentLimboResolutions,t)}async terminate(){var e,t;await async function(s){const o=U(s);O(Qt,"RemoteStore shutting down."),o.Ea.add(5),await vr(o),o.Aa.shutdown(),o.Ra.set("Unknown")}(this.remoteStore),(e=this.datastore)==null||e.terminate(),(t=this.eventManager)==null||t.terminate()}}uo.provider={build:()=>new uo};/**
1790 * @license
1791 * Copyright 2020 Google LLC
1792 *
1793 * Licensed under the Apache License, Version 2.0 (the "License");
1794 * you may not use this file except in compliance with the License.
1795 * You may obtain a copy of the License at
1796 *
1797 *   http://www.apache.org/licenses/LICENSE-2.0
1798 *
1799 * Unless required by applicable law or agreed to in writing, software
1800 * distributed under the License is distributed on an "AS IS" BASIS,
1801 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1802 * See the License for the specific language governing permissions and
1803 * limitations under the License.
1804 *//**
1805 * @license
1806 * Copyright 2017 Google LLC
1807 *
1808 * Licensed under the Apache License, Version 2.0 (the "License");
1809 * you may not use this file except in compliance with the License.
1810 * You may obtain a copy of the License at
1811 *
1812 *   http://www.apache.org/licenses/LICENSE-2.0
1813 *
1814 * Unless required by applicable law or agreed to in writing, software
1815 * distributed under the License is distributed on an "AS IS" BASIS,
1816 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1817 * See the License for the specific language governing permissions and
1818 * limitations under the License.
1819 */class Ko{constructor(e){this.observer=e,this.muted=!1}next(e){this.muted||this.observer.next&&this.Ou(this.observer.next,e)}error(e){this.muted||(this.observer.error?this.Ou(this.observer.error,e):ht("Uncaught Error in snapshot listener:",e.toString()))}Nu(){this.muted=!0}Ou(e,t){setTimeout(()=>{this.muted||e(t)},0)}}/**
1820 * @license
1821 * Copyright 2017 Google LLC
1822 *
1823 * Licensed under the Apache License, Version 2.0 (the "License");
1824 * you may not use this file except in compliance with the License.
1825 * You may obtain a copy of the License at
1826 *
1827 *   http://www.apache.org/licenses/LICENSE-2.0
1828 *
1829 * Unless required by applicable law or agreed to in writing, software
1830 * distributed under the License is distributed on an "AS IS" BASIS,
1831 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1832 * See the License for the specific language governing permissions and
1833 * limitations under the License.
1834 */const Lt="FirestoreClient";class q_{constructor(e,t,r,s,o){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=r,this.databaseInfo=s,this.user=Pe.UNAUTHENTICATED,this.clientId=wo.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=o,this.authCredentials.start(r,async a=>{O(Lt,"Received user=",a.uid),await this.authCredentialListener(a),this.user=a}),this.appCheckCredentials.start(r,a=>(O(Lt,"Received new app check token=",a),this.appCheckCredentialListener(a,this.user)))}get configuration(){return{asyncQueue:this.asyncQueue,databaseInfo:this.databaseInfo,clientId:this.clientId,authCredentials:this.authCredentials,appCheckCredentials:this.appCheckCredentials,initialUser:this.user,maxConcurrentLimboResolutions:100}}setCredentialChangeListener(e){this.authCredentialListener=e}setAppCheckTokenChangeListener(e){this.appCheckCredentialListener=e}terminate(){this.asyncQueue.enterRestrictedMode();const e=new at;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted(async()=>{try{this._onlineComponents&&await this._onlineComponents.terminate(),this._offlineComponents&&await this._offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),e.resolve()}catch(t){const r=qo(t,"Failed to shutdown persistence");e.reject(r)}}),e.promise}}async function Ui(n,e){n.asyncQueue.verifyOperationInProgress(),O(Lt,"Initializing OfflineComponentProvider");const t=n.configuration;await e.initialize(t);let r=t.initialUser;n.setCredentialChangeListener(async s=>{r.isEqual(s)||(await dh(e.localStore,s),r=s)}),e.persistence.setDatabaseDeletedListener(()=>n.terminate()),n._offlineComponents=e}async function Au(n,e){n.asyncQueue.verifyOperationInProgress();const t=await j_(n);O(Lt,"Initializing OnlineComponentProvider"),await e.initialize(t,n.configuration),n.setCredentialChangeListener(r=>yu(e.remoteStore,r)),n.setAppCheckTokenChangeListener((r,s)=>yu(e.remoteStore,s)),n._onlineComponents=e}async function j_(n){if(!n._offlineComponents)if(n._uninitializedComponentsProvider){O(Lt,"Using user provided OfflineComponentProvider");try{await Ui(n,n._uninitializedComponentsProvider._offline)}catch(e){const t=e;if(!function(s){return s.name==="FirebaseError"?s.code===P.FAILED_PRECONDITION||s.code===P.UNIMPLEMENT
1834ED:!(typeof DOMException<"u"&&s instanceof DOMException)||s.code===22||s.code===20||s.code===11}(t))throw t;cr("Error using user provided cache. Falling back to memory cache: "+t),await Ui(n,new vs)}}else O(Lt,"Using default OfflineComponentProvider"),await Ui(n,new B_(void 0));return n._offlineComponents}async function kh(n){return n._onlineComponents||(n._uninitializedComponentsProvider?(O(Lt,"Using user provided OnlineComponentProvider"),await Au(n,n._uninitializedComponentsProvider._online)):(O(Lt,"Using default OnlineComponentProvider"),await Au(n,new uo))),n._onlineComponents}function $_(n){return kh(n).then(e=>e.syncEngine)}async function As(n){const e=await kh(n),t=e.eventManager;return t.onListen=P_.bind(null,e.syncEngine),t.onUnlisten=k_.bind(null,e.syncEngine),t.onFirstRemoteStoreListen=C_.bind(null,e.syncEngine),t.onLastRemoteStoreUnlisten=N_.bind(null,e.syncEngine),t}function Nh(n,e,t={}){const r=new at;return n.asyncQueue.enqueueAndForget(async()=>function(o,a,u,h,d){const p=new Ko({next:E=>{p.Nu(),a.enqueueAndForget(()=>$o(o,_));const S=E.docs.has(u);!S&&E.fromCache?d.reject(new V(P.UNAVAILABLE,"Failed to get document because the client is offline.")):S&&E.fromCache&&h&&h.source==="server"?d.reject(new V(P.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.)')):d.resolve(E)},error:E=>d.reject(E)}),_=new Ho(Bs(u.path),p,{includeMetadataChanges:!0,qa:!0});return jo(o,_)}(await As(n),n.asyncQueue,e,t,r)),r.promise}function Vh(n,e,t={}){const r=new at;return n.asyncQueue.enqueueAndForget(async()=>function(o,a,u,h,d){const p=new Ko({next:E=>{p.Nu(),a.enqueueAndForget(()=>$o(o,_)),E.fromCache&&h.source==="server"?d.reject(new V(P.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.)')):d.resolve(E)},error:E=>d.reject(E)}),_=new Ho(u,p,{includeMetadataChanges:!0,qa:!0});return jo(o,_)}(await As(n),n.asyncQueue,e,t,r)),r.promise}/**
1835 * @license
1836 * Copyright 2023 Google LLC
1837 *
1838 * Licensed under the Apache License, Version 2.0 (the "License");
1839 * you may not use this file except in compliance with the License.
1840 * You may obtain a copy of the License at
1841 *
1842 *   http://www.apache.org/licenses/LICENSE-2.0
1843 *
1844 * Unless required by applicable law or agreed to in writing, software
1845 * distributed under the License is distributed on an "AS IS" BASIS,
1846 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1847 * See the License for the specific language governing permissions and
1848 * limitations under the License.
1849 */function Dh(n){const e={};return n.timeoutSeconds!==void 0&&(e.timeoutSeconds=n.timeoutSeconds),e}/**
1850 * @license
1851 * Copyright 2020 Google LLC
1852 *
1853 * Licensed under the Apache License, Version 2.0 (the "License");
1854 * you may not use this file except in compliance with the License.
1855 * You may obtain a copy of the License at
1856 *
1857 *   http://www.apache.org/licenses/LICENSE-2.0
1858 *
1859 * Unless required by applicable law or agreed to in writing, software
1860 * distributed under the License is distributed on an "AS IS" BASIS,
1861 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1862 * See the License for the specific language governing permissions and
1863 * limitations under the License.
1864 */const Ru=new Map;/**
1865 * @license
1866 * Copyright 2020 Google LLC
1867 *
1868 * Licensed under the Apache License, Version 2.0 (the "License");
1869 * you may not use this file except in compliance with the License.
1870 * You may obtain a copy of the License at
1871 *
1872 *   http://www.apache.org/licenses/LICENSE-2.0
1873 *
1874 * Unless required by applicable law or agreed to in writing, software
1875 * distributed under the License is distributed on an "AS IS" BASIS,
1876 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1877 * See the License for the specific language governing permissions and
1878 * limitations under the License.
1879 */const z_="firestore.googleapis.com",Su=!0;class Pu{constructor(e){if(e.host===void 0){if(e.ssl!==void 0)throw new V(P.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host=z_,this.ssl=Su}else this.host=e.host,this.ssl=e.ssl??Su;if(this.isUsingEmulator=e.emulatorOptions!==void 0,this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,this.localCache=e.localCache,e.cacheSizeBytes===void 0)this.cacheSizeBytes=uh;
1879else{if(e.cacheSizeBytes!==-1&&e.cacheSizeBytes<lh)throw new V(P.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}cm("experimentalForceLongPolling",e.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",e.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!e.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:e.experimentalAutoDetectLongPolling===void 0?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!e.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=Dh(e.experimentalLongPollingOptions??{}),function(r){if(r.timeoutSeconds!==void 0){if(isNaN(r.timeoutSeconds))throw new V(P.INVALID_ARGUMENT,`invalid long polling timeout: ${r.timeoutSeconds} (must not be NaN)`);if(r.timeoutSeconds<5)throw new V(P.INVALID_ARGUMENT,`invalid long polling timeout: ${r.timeoutSeconds} (minimum allowed value is 5)`);if(r.timeoutSeconds>30)throw new V(P.INVALID_ARGUMENT,`invalid long polling timeout: ${r.timeoutSeconds} (maximum allowed value is 30)`)}}(this.experimentalLongPollingOptions),this.useFetchStreams=!!e.useFetchStreams}isEqual(e){return this.host===e.host&&this.ssl===e.ssl&&this.credentials===e.credentials&&this.cacheSizeBytes===e.cacheSizeBytes&&this.experimentalForceLongPolling===e.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===e.experimentalAutoDetectLongPolling&&function(r,s){return r.timeoutSeconds===s.timeoutSeconds}(this.experimentalLongPollingOptions,e.experimentalLongPollingOptions)&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams}}class Qo{constructor(e,t,r,s){this._authCredentials=e,this._appCheckCredentials=t,this._databaseId=r,this._app=s,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new Pu({}),this._settingsFrozen=!1,this._emulatorOptions={},this._terminateTask="notTerminated"}get app(){if(!this._app)throw new V(P.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app}get _initialized(){return this._settingsFrozen}get _terminated(){return this._terminateTask!=="notTerminated"}_setSettings(e){if(this._settingsFrozen)throw new V(P.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 Pu(e),this._emulatorOptions=e.emulatorOptions||{},e.credentials!==void 0&&(this._authCredentials=function(r){if(!r)return new Zp;switch(r.type){case"firstParty":return new nm(r.sessionIndex||"0",r.iamToken||null,r.authTokenFactory||null);case"provider":return r.client;default:throw new V(P.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 this._terminateTask==="notTerminated"&&(this._terminateTask=this._terminate()),this._terminateTask}async _restart(){this._terminateTask==="notTerminated"?await this._terminate():this._terminateTask="notTerminated"}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return function(t){const r=Ru.get(t);r&&(O("ComponentProvider","Removing Datastore"),Ru.delete(t),r.terminate())}(this),Promise.resolve()}}/**
1880 * @license
1881 * Copyright 2020 Google LLC
1882 *
1883 * Licensed under the Apache License, Version 2.0 (the "License");
1884 * you may not use this file except in compliance with the License.
1885 * You may obtain a copy of the License at
1886 *
1887 *   http://www.apache.org/licenses/LICENSE-2.0
1888 *
1889 * Unless required by applicable law or agreed to in writing, software
1890 * distributed under the License is distributed on an "AS IS" BASIS,
1891 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1892 * See the License for the specific language governing permissions and
1893 * limitations under the License.
1894 */class et{constructor(e,t,r){this.converter=t,this._query=r,this.type="query",this.firestore=e}withConverter(e){return new et(this.firestore,e,this._query)}}class ee{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()}
1894get path(){return this._key.path.canonicalString()}get parent(){return new Ct(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new ee(this.firestore,e,this._key)}toJSON(){return{type:ee._jsonSchemaVersion,referencePath:this._key.toString()}}static fromJSON(e,t,r){if(Tr(t,ee._jsonSchema))return new ee(e,r||null,new L(Y.fromString(t.referencePath)))}}ee._jsonSchemaVersion="firestore/documentReference/1.0",ee._jsonSchema={type:ae("string",ee._jsonSchemaVersion),referencePath:ae("string")};class Ct extends et{constructor(e,t,r){super(e,t,Bs(r)),this._path=r,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){const e=this._path.popLast();return e.isEmpty()?null:new ee(this.firestore,null,new L(e))}withConverter(e){return new Ct(this.firestore,e,this._path)}}function jT(n,e,...t){if(n=G(n),Il("collection","path",e),n instanceof Qo){const r=Y.fromString(e,...t);return Bc(r),new Ct(n,null,r)}{if(!(n instanceof ee||n instanceof Ct))throw new V(P.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=n._path.child(Y.fromString(e,...t));return Bc(r),new Ct(n.firestore,null,r)}}function H_(n,e,...t){if(n=G(n),arguments.length===1&&(e=wo.newId()),Il("doc","path",e),n instanceof Qo){const r=Y.fromString(e,...t);return Uc(r),new ee(n,null,new L(r))}{if(!(n instanceof ee||n instanceof Ct))throw new V(P.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=n._path.child(Y.fromString(e,...t));return Uc(r),new ee(n.firestore,n instanceof Ct?n.converter:null,new L(r))}}/**
1895 * @license
1896 * Copyright 2020 Google LLC
1897 *
1898 * Licensed under the Apache License, Version 2.0 (the "License");
1899 * you may not use this file except in compliance with the License.
1900 * You may obtain a copy of the License at
1901 *
1902 *   http://www.apache.org/licenses/LICENSE-2.0
1903 *
1904 * Unless required by applicable law or agreed to in writing, software
1905 * distributed under the License is distributed on an "AS IS" BASIS,
1906 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1907 * See the License for the specific language governing permissions and
1908 * limitations under the License.
1909 */const Cu="AsyncQueue";class bu{constructor(e=Promise.resolve()){this.Xu=[],this.ec=!1,this.tc=[],this.nc=null,this.rc=!1,this.sc=!1,this.oc=[],this.M_=new ph(this,"async_queue_retry"),this._c=()=>{const r=Fi();r&&O(Cu,"Visibility state changed to "+r.visibilityState),this.M_.w_()},this.ac=e;const t=Fi();t&&typeof t.addEventListener=="function"&&t.addEventListener("visibilitychange",this._c)}get isShuttingDown(){return this.ec}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.uc(),this.cc(e)}enterRestrictedMode(e){if(!this.ec){this.ec=!0,this.sc=e||!1;const t=Fi();t&&typeof t.removeEventListener=="function"&&t.removeEventListener("visibilitychange",this._c)}}enqueue(e){if(this.uc(),this.ec)return new Promise(()=>{});const t=new at;return this.cc(()=>this.ec&&this.sc?Promise.resolve():(e().then(t.resolve,t.reject),t.promise)).then(()=>t.promise)}enqueueRetryable(e){this.enqueueAndForget(()=>(this.Xu.push(e),this.lc()))}async lc(){if(this.Xu.length!==0){try{await this.Xu[0](),this.Xu.shift(),this.M_.reset()}catch(e){if(!Sn(e))throw e;O(Cu,"Operation failed with retryable error: "+e)}this.Xu.length>0&&this.M_.p_(()=>this.lc())}}cc(e){const t=this.ac.then(()=>(this.rc=!0,e().catch(r=>{throw this.nc=r,this.rc=!1,ht("INTERNAL UNHANDLED ERROR: ",ku(r)),r}).then(r=>(this.rc=!1,r))));return this.ac=t,t}enqueueAfterDelay(e,t,r){this.uc(),this.oc.indexOf(e)>-1&&(t=0);const s=Bo.createAndSchedule(this,e,t,r,o=>this.hc(o));return this.tc.push(s),s}uc(){this.nc&&x(47125,{Pc:ku(this.nc)})}verifyOperationInProgress(){}async Tc(){let e;do e=this.ac,await e;while(e!==this.ac)}Ic(e){for(const t of this.tc)if(t.timerId===e)return!0;return!1}Ec(e){return this.Tc().then(()=>{this.tc.sort((t,r)=>t.targetTimeMs-r.targetTimeMs);for(const t of this.tc)if(t.skipDelay(),e!=="all"&&t.timerId===e)break;return this.Tc()})}dc(e){this.oc.push(e)}hc(e){const t=this.tc.indexOf(e);this.tc.splice(t,1)}}function ku(n){let e=n.message||"";return n.stack&&(e=n.stack.includes(n.message)?n.stack:n.message+`
1910`+n.stack),e}/**
1911 * @license
1912 * Copyright 2017 Google LLC
1913 *
1914 * Licensed under the Apache License, Version 2.0 (the "License");
1915 * you may not use this file except in compliance with the License.
1916 * You may obtain a copy of the License at
1917 *
1918 *   http://www.apache.org/licenses/LICENSE-2.0
1919 *
1920 * Unless required by applicable law or agreed to in writing, software
1921 * distributed under the License is distributed on an "AS IS" BASIS,
1922 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1923 * See the License for the specific language governing permissions and
1924 * limitations under the License.
1925 */function Nu(n){return function(t,r){if(typeof t!="object"||t===null)return!1;const s=t;for(const o of r)if(o in s&&typeof s[o]=="function")return!0;return!1}(n,["next","error","complete"])}class Le extends Qo{constructor(e,t,r,s){super(e,t,r,s),this.type="firestore",this._queue=new bu,this._persistenceKey=(s==null?void 0:s.name)||"[DEFAULT]"}async _terminate(){if(this._firestoreClient){const e=this._firestoreClient.terminate();this._queue=new bu(e),this._firestoreClient=void 0,await e}}}function $T(n,e,t){t||(t=gs);const r=Ms(n,"firestore");if(r.isInitialized(t)){const s=r.getImmediate({identifier:t}),o=r.getOptions(t);if(ut(o,e))return s;throw new V(P.FAILED_PRECONDITION,"initializeFirestore() has already been called with different options. To avoid this error, call initializeFirestore() with the same options as when it was originally called, or call getFirestore() to return the already initialized instance.")}if(e.cacheSizeBytes!==void 0&&e.localCache!==void 0)throw new V(P.INVALID_ARGUMENT,"cache and cacheSizeBytes cannot be specified at the same time as cacheSizeBytes willbe deprecated. Instead, specify the cache size in the cache object");if(e.cacheSizeBytes!==void 0&&e.cacheSizeBytes!==-1&&e.cacheSizeBytes<lh)throw new V(P.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");return e.host&&Yt(e.host)&&yo(e.host),r.initialize({options:e,instanceIdentifier:t})}function en(n){if(n._terminated)throw new V(P.FAILED_PRECONDITION,"The client has already been terminated.");return n._firestoreClient||W_(n),n._firestoreClient}function W_(n){var r,s,o;const e=n._freezeSettings(),t=function(u,h,d,p){return new Tm(u,h,d,p.host,p.ssl,p.experimentalForceLongPolling,p.experimentalAutoDetectLongPolling,Dh(p.experimentalLongPollingOptions),p.useFetchStreams,p.isUsingEmulator)}(n._databaseId,((r=n._app)==null?void 0:r.options.appId)||"",n._persistenceKey,e);n._componentsProvider||(s=e.localCache)!=null&&s._offlineComponentProvider&&((o=e.localCache)!=null&&o._onlineComponentProvider)&&(n._componentsProvider={_offline:e.localCache._offlineComponentProvider,_online:e.localCache._onlineComponentProvider}),n._firestoreClient=new q_(n._authCredentials,n._appCheckCredentials,n._queue,t,n._componentsProvider&&function(u){const h=u==null?void 0:u._online.build();return{_offline:u==null?void 0:u._offline.build(h),_online:h}}(n._componentsProvider))}/**
1926 * @license
1927 * Copyright 2020 Google LLC
1928 *
1929 * Licensed under the Apache License, Version 2.0 (the "License");
1930 * you may not use this file except in compliance with the License.
1931 * You may obtain a copy of the License at
1932 *
1933 *   http://www.apache.org/licenses/LICENSE-2.0
1934 *
1935 * Unless required by applicable law or agreed to in writing, software
1936 * distributed under the License is distributed on an "AS IS" BASIS,
1937 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1938 * See the License for the specific language governing permissions and
1939 * limitations under the License.
1940 */class Oe{constructor(e){this._byteString=e}static fromBase64String(e){try{return new Oe(ge.fromBase64String(e))}catch(t){throw new V(P.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+t)}}static fromUint8Array(e){return new Oe(ge.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:Oe._jsonSchemaVersion,bytes:this.toBase64()}}static fromJSON(e){if(Tr(e,Oe._jsonSchema))return Oe.fromBase64String(e.bytes)}}
1940Oe._jsonSchemaVersion="firestore/bytes/1.0",Oe._jsonSchema={type:ae("string",Oe._jsonSchemaVersion),bytes:ae("string")};/**
1941 * @license
1942 * Copyright 2020 Google LLC
1943 *
1944 * Licensed under the Apache License, Version 2.0 (the "License");
1945 * you may not use this file except in compliance with the License.
1946 * You may obtain a copy of the License at
1947 *
1948 *   http://www.apache.org/licenses/LICENSE-2.0
1949 *
1950 * Unless required by applicable law or agreed to in writing, software
1951 * distributed under the License is distributed on an "AS IS" BASIS,
1952 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1953 * See the License for the specific language governing permissions and
1954 * limitations under the License.
1955 */class Rr{constructor(...e){for(let t=0;t<e.length;++t)if(e[t].length===0)throw new V(P.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new me(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}}/**
1956 * @license
1957 * Copyright 2020 Google LLC
1958 *
1959 * Licensed under the Apache License, Version 2.0 (the "License");
1960 * you may not use this file except in compliance with the License.
1961 * You may obtain a copy of the License at
1962 *
1963 *   http://www.apache.org/licenses/LICENSE-2.0
1964 *
1965 * Unless required by applicable law or agreed to in writing, software
1966 * distributed under the License is distributed on an "AS IS" BASIS,
1967 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1968 * See the License for the specific language governing permissions and
1969 * limitations under the License.
1970 */class tn{constructor(e){this._methodName=e}}/**
1971 * @license
1972 * Copyright 2017 Google LLC
1973 *
1974 * Licensed under the Apache License, Version 2.0 (the "License");
1975 * you may not use this file except in compliance with the License.
1976 * You may obtain a copy of the License at
1977 *
1978 *   http://www.apache.org/licenses/LICENSE-2.0
1979 *
1980 * Unless required by applicable law or agreed to in writing, software
1981 * distributed under the License is distributed on an "AS IS" BASIS,
1982 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1983 * See the License for the specific language governing permissions and
1984 * limitations under the License.
1985 */class Ke{constructor(e,t){if(!isFinite(e)||e<-90||e>90)throw new V(P.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(t)||t<-180||t>180)throw new V(P.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 $(this._lat,e._lat)||$(this._long,e._long)}toJSON(){return{latitude:this._lat,longitude:this._long,type:Ke._jsonSchemaVersion}}static fromJSON(e){if(Tr(e,Ke._jsonSchema))return new Ke(e.latitude,e.longitude)}}Ke._jsonSchemaVersion="firestore/geoPoint/1.0",Ke._jsonSchema={type:ae("string",Ke._jsonSchemaVersion),latitude:ae("number"),longitude:ae("number")};/**
1986 * @license
1987 * Copyright 2024 Google LLC
1988 *
1989 * Licensed under the Apache License, Version 2.0 (the "License");
1990 * you may not use this file except in compliance with the License.
1991 * You may obtain a copy of the License at
1992 *
1993 *   http://www.apache.org/licenses/LICENSE-2.0
1994 *
1995 * Unless required by applicable law or agreed to in writing, software
1996 * distributed under the License is distributed on an "AS IS" BASIS,
1997 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1998 * See the License for the specific language governing permissions and
1999 * limitations under the License.
2000 */class Qe{constructor(e){this._values=(e||[]).map(t=>t)}toArray(){return this._values.map(e=>e)}isEqual(e){return function(r,s){if(r.length!==s.length)return!1;for(let o=0;o<r.length;++o)if(r[o]!==s[o])return!1;return!0}(this._values,e._values)}toJSON(){return{type:Qe._jsonSchemaVersion,vectorValues:this._values}}static fromJSON(e){if(Tr(e,Qe._jsonSchema)){if(Array.isArray(e.vectorValues)&&e.vectorValues.every(t=>typeof t=="number"))return new Qe(e.vectorValues);throw new V(P.INVALID_ARGUMENT,"Expected 'vectorValues' field to be a number array")}}}Qe._jsonSchemaVersion="firestore/vectorValue/1.0",Qe._jsonSchema={type:ae("string",Qe._jsonSchemaVersion),vectorValues:ae("object")};/**
2001 * @license
2002 * Copyright 2017 Google LLC
2003 *
2004 * Licensed under the Apache License, Version 2.0 (the "License");
2005 * you may not use this file except in compliance with the License.
2006 * You may obtain a copy of the License at
2007 *
2008 *   http://www.apache.org/licenses/LICENSE-2.0
2009 *
2010 * Unless required by applicable law or agreed to in writing, software
2011 * distributed under the License is distributed on an "AS IS" BASIS,
2012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2013 * See the License for the specific language governing permissions and
2014 * limitations under the License.
2015 */const G_=/^__.*__$/;class K_{constructor(e,t,r){this.data=e,this.fieldMask=t,this.fieldTransforms=r}toMutation(e,t){return this.fieldMask!==null?new Ft(e,this.data,this.fieldMask,t,this.fieldTransforms):new Ir(e,this.data,t,this.fieldTransforms)}}class Oh{constructor(e,t,r){this.data=e,this.fieldMask=t,this.fieldTransforms=r}toMutation(e,t){return new Ft(e,this.data,this.fieldMask,t,this.fieldTransforms)}}function Mh(n){switch(n){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw x(40011,{Ac:n})}}class Ys{constructor(e,t,r,s,o,a){this.settings=e,this.databaseId=t,this.serializer=r,this.ignoreUndefinedProperties=s,o===void 0&&this.Rc(),this.fieldTransforms=o||[],this.fieldMask=a||[]}get path(){return this.settings.path}get Ac(){return this.settings.Ac}Vc(e){return new Ys({...this.settings,...e},this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}mc(e){var s;const t=(s=this.path)==null?void 0:s.child(e),r=this.Vc({path:t,fc:!1});return r.gc(e),r}yc(e){var s;const t=(s=this.path)==null?void 0:s.child(e),r=this.Vc({path:t,fc:!1});return r.Rc(),r}wc(e){return this.Vc({path:void 0,fc:!0})}Sc(e){return Rs(e,this.settings.methodName,this.settings.bc||!1,this.path,this.settings.Dc)}contains(e){return this.fieldMask.find(t=>e.isPrefixOf(t))!==void 0||this.fieldTransforms.find(t=>e.isPrefixOf(t.field))!==void 0}Rc(){if(this.path)for(let e=0;e<this.path.length;e++)this.gc(this.path.get(e))}gc(e){if(e.length===0)throw this.Sc("Document fields must not be empty");if(Mh(this.Ac)&&G_.test(e))throw this.Sc('Document fields cannot begin and end with "__"')}}class Q_{constructor(e,t,r){this.databaseId=e,this.ignoreUndefinedProperties=t,this.serializer=r||Ks(e)}Cc(e,t,r,s=!1){return new Ys({Ac:e,methodName:t,Dc:r,path:me.emptyPath(),fc:!1,bc:s},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}}function Sr(n){const e=n._freezeSettings(),t=Ks(n._databaseId);return new Q_(n._databaseId,!!e.ignoreUndefinedProperties,t)}function Jo(n,e,t,r,s,o={}){const a=n.Cc(o.merge||o.mergeFields?2:0,e,t,s);ta("Data must be an object, but it was:",a,r);const u=Uh(r,a);let h,d;if(o.merge)h=new Ve(a.fieldMask),d=a.fieldTransforms;else if(o.mergeFields){const p=[];for(const _ of o.mergeFields){const E=lo(e,_,t);if(!a.contains(E))throw new V(P.INVALID_ARGUMENT,`Field '${E}' is specified in your field mask but missing from your input data.`);qh(p,E)||p.push(E)}h=new Ve(p),d=a.fieldTransforms.filter(_=>h.covers(_.field))}else h=null,d=a.fieldTransforms;return new K_(new be(u),h,d)}class Pr extends tn{_toFieldTransform(e){if(e.Ac!==2)throw e.Ac===1?e.Sc(`${this._methodName}() can only appear at the top level of your update data`):e.Sc(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return e.fieldMask.push(e.path),null}isEqual(e){return e instanceof Pr}}function Lh(n,e,t){return new Ys({Ac:3,Dc:e.settings.Dc,methodName:n._methodName,fc:t},e.databaseId,e.serializer,e.ignoreUndefinedProperties)}class Yo extends tn{_toFieldTransform(e){return new zs(e.path,new pr)}isEqual(e){return e instanceof Yo}}class Xo extends tn{constructor(e,t){super(e),this.vc=t}_toFieldTransform(e){const t=Lh(this,e,!0),r=this.vc.map(o=>nn(o,t)),s=new yn(r);return new zs(e.path,s)}isEqual(e){return e instanceof Xo&&ut(this.vc,e.vc)}}class Zo extends tn{constructor(e,t){super(e),this.vc=t}_toFieldTransform(e){const t=Lh(this,e,!0),r=this.vc.map(o=>nn(o,t)),s=new En(r);return new zs(e.path,s)}isEqual(e){return e instanceof Zo&&ut(this.vc,e.vc)}}class ea extends tn{constructor(e,t){super(e),this.Fc=t}_toFieldTransform(e){const t=new mr(e.serializer,Wl(e.serializer,this.Fc));return new zs(e.path,t)}isEqual(e){return e instanceof ea&&this.Fc===e.Fc}}function xh(n,e,t,r){const s=n.Cc(1,e,t);ta("Data must be an object, but it was:",s,r);const o=[],a=be.empty();xt(r,(h,d)=>{const p=na(e,h,t);d=G(d);const _=s.yc(p);if(d instanceof Pr)o.push(p);else{const E=nn(d,_);E!=null&&(o.push(p),a.set(p,E))}});const u=new Ve(o);return new Oh(a,u,s.fieldTransforms)}function Fh(n,e,t,r,s,o){const a=n.Cc(1,e,t),u=[lo(e,r,t)],h=[s];if(o.length%2!=0)throw new V(P.INVALID_ARGUMENT,`Function ${e}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let E=0;E<o.length;E+=2)u.push(lo(e,o[E])),h.push(o[E+1]);const d=[],p=be.empty();for(let E=u.length-1;E>=0;--E)if(!qh(d,u[E])){const S=u[E];let b=h[E];b=G(b);const D=a.yc(S);if(b instanceof Pr)d.push(S);else{const N=nn(b,D);N!=null&&(d.push(S),p.set(S,N))}}const _=new Ve(d);return new Oh(p,_,a.fieldTransforms)}function J_(n,e,t,r=!1){return nn(t,n.Cc(r?4:3,e))}function nn(n,e){if(Bh(n=G(n)))return ta("Unsupported field value:",e,n),Uh(n,e);
2015if(n instanceof tn)return function(r,s){if(!Mh(s.Ac))throw s.Sc(`${r._methodName}() can only be used with update() and set()`);if(!s.path)throw s.Sc(`${r._methodName}() is not currently supported inside arrays`);const o=r._toFieldTransform(s);o&&s.fieldTransforms.push(o)}(n,e),null;if(n===void 0&&e.ignoreUndefinedProperties)return null;if(e.path&&e.fieldMask.push(e.path),n instanceof Array){if(e.settings.fc&&e.Ac!==4)throw e.Sc("Nested arrays are not supported");return function(r,s){const o=[];let a=0;for(const u of r){let h=nn(u,s.wc(a));h==null&&(h={nullValue:"NULL_VALUE"}),o.push(h),a++}return{arrayValue:{values:o}}}(n,e)}return function(r,s){if((r=G(r))===null)return{nullValue:"NULL_VALUE"};if(typeof r=="number")return Wl(s.serializer,r);if(typeof r=="boolean")return{booleanValue:r};if(typeof r=="string")return{stringValue:r};if(r instanceof Date){const o=Z.fromDate(r);return{timestampValue:Ts(s.serializer,o)}}if(r instanceof Z){const o=new Z(r.seconds,1e3*Math.floor(r.nanoseconds/1e3));return{timestampValue:Ts(s.serializer,o)}}if(r instanceof Ke)return{geoPointValue:{latitude:r.latitude,longitude:r.longitude}};if(r instanceof Oe)return{bytesValue:nh(s.serializer,r._byteString)};if(r instanceof ee){const o=s.databaseId,a=r.firestore._databaseId;if(!a.isEqual(o))throw s.Sc(`Document reference is for database ${a.projectId}/${a.database} but should be for database ${o.projectId}/${o.database}`);return{referenceValue:No(r.firestore._databaseId||s.databaseId,r._key.path)}}if(r instanceof Qe)return function(a,u){return{mapValue:{fields:{[kl]:{stringValue:Nl},[_s]:{arrayValue:{values:a.toArray().map(d=>{if(typeof d!="number")throw u.Sc("VectorValues must only contain numeric values.");return Co(u.serializer,d)})}}}}}}(r,s);throw s.Sc(`Unsupported field value: ${Ls(r)}`)}(n,e)}function Uh(n,e){const t={};return Al(n)?e.path&&e.path.length>0&&e.fieldMask.push(e.path):xt(n,(r,s)=>{const o=nn(s,e.mc(r));o!=null&&(t[r]=o)}),{mapValue:{fields:t}}}function Bh(n){return!(typeof n!="object"||n===null||n instanceof Array||n instanceof Date||n instanceof Z||n instanceof Ke||n instanceof Oe||n instanceof ee||n instanceof tn||n instanceof Qe)}function ta(n,e,t){if(!Bh(t)||!wl(t)){const r=Ls(t);throw r==="an object"?e.Sc(n+" a custom object"):e.Sc(n+" "+r)}}function lo(n,e,t){if((e=G(e))instanceof Rr)return e._internalPath;if(typeof e=="string")return na(n,e);throw Rs("Field path arguments must be of type string or ",n,!1,void 0,t)}const Y_=new RegExp("[~\\*/\\[\\]]");function na(n,e,t){if(e.search(Y_)>=0)throw Rs(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`,n,!1,void 0,t);try{return new Rr(...e.split("."))._internalPath}catch{throw Rs(`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,n,!1,void 0,t)}}function Rs(n,e,t,r,s){const o=r&&!r.isEmpty(),a=s!==void 0;let u=`Function ${e}() called with invalid data`;t&&(u+=" (via `toFirestore()`)"),u+=". ";let h="";return(o||a)&&(h+=" (found",o&&(h+=` in field ${r}`),a&&(h+=` in document ${s}`),h+=")"),new V(P.INVALID_ARGUMENT,u+n+h)}function qh(n,e){return n.some(t=>t.isEqual(e))}/**
2016 * @license
2017 * Copyright 2020 Google LLC
2018 *
2019 * Licensed under the Apache License, Version 2.0 (the "License");
2020 * you may not use this file except in compliance with the License.
2021 * You may obtain a copy of the License at
2022 *
2023 *   http://www.apache.org/licenses/LICENSE-2.0
2024 *
2025 * Unless required by applicable law or agreed to in writing, software
2026 * distributed under the License is distributed on an "AS IS" BASIS,
2027 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2028 * See the License for the specific language governing permissions and
2029 * limitations under the License.
2030 */class jh{constructor(e,t,r,s,o){this._firestore=e,this._userDataWriter=t,this._key=r,this._document=s,this._converter=o}get id(){return this._key.path.lastSegment()}get ref(){return new ee(this._firestore,this._converter,this._key)}exists(){return this._document!==null}data(){if(this._document){if(this._converter){const e=new X_(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(e)}return this._userDataWriter.convertValue(this._document.data.value)}}get(e){if(this._document){const t=this._document.data.field(Xs("DocumentSnapshot.get",e));if(t!==null)return this._userDataWriter.convertValue(t)}}}class X_ extends jh{data(){return super.data()}}function Xs(n,e){return typeof e=="string"?na(n,e):e instanceof Rr?e._internalPath:e._delegate._internalPath}/**
2031 * @license
2032 * Copyright 2020 Google LLC
2033 *
2034 * Licensed under the Apache License, Version 2.0 (the "License");
2035 * you may not use this file except in compliance with the License.
2036 * You may obtain a copy of the License at
2037 *
2038 *   http://www.apache.org/licenses/LICENSE-2.0
2039 *
2040 * Unless required by applicable law or agreed to in writing, software
2041 * distributed under the License is distributed on an "AS IS" BASIS,
2042 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2043 * See the License for the specific language governing permissions and
2044 * limitations under the License.
2045 */function $h(n){if(n.limitType==="L"&&n.explicitOrderBy.length===0)throw new V(P.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class ra{}class sa extends ra{}function zT(n,e,...t){let r=[];e instanceof ra&&r.push(e),r=r.concat(t),function(o){const a=o.filter(h=>h instanceof ia).length,u=o.filter(h=>h instanceof Zs).length;if(a>1||a>0&&u>0)throw new V(P.INVALID_ARGUMENT,"InvalidQuery. When using composite filters, you cannot use more than one filter at the top level. Consider nesting the multiple filters within an `and(...)` statement. For example: change `query(query, where(...), or(...))` to `query(query, and(where(...), or(...)))`.")}(r);for(const s of r)n=s._apply(n);return n}class Zs extends sa{constructor(e,t,r){super(),this._field=e,this._op=t,this._value=r,this.type="where"}static _create(e,t,r){return new Zs(e,t,r)}_apply(e){const t=this._parse(e);return zh(e._query,t),new et(e.firestore,e.converter,eo(e._query,t))}_parse(e){const t=Sr(e.firestore);return function(o,a,u,h,d,p,_){let E;if(d.isKeyField()){if(p==="array-contains"||p==="array-contains-any")throw new V(P.INVALID_ARGUMENT,`Invalid Query. You can't perform '${p}' queries on documentId().`);if(p==="in"||p==="not-in"){Du(_,p);const b=[];for(const D of _)b.push(Vu(h,o,D));E={arrayValue:{values:b}}}else E=Vu(h,o,_)}else p!=="in"&&p!=="not-in"&&p!=="array-contains-any"||Du(_,p),E=J_(u,a,_,p==="in"||p==="not-in");return oe.create(d,p,E)}(e._query,"where",t,e.firestore._databaseId,this._field,this._op,this._value)}}function HT(n,e,t){const r=e,s=Xs("where",n);return Zs._create(s,r,t)}class ia extends ra{constructor(e,t){super(),this.type=e,this._queryConstraints=t}static _create(e,t){return new ia(e,t)}_parse(e){const t=this._queryConstraints.map(r=>r._parse(e)).filter(r=>r.getFilters().length>0);return t.length===1?t[0]:qe.create(t,this._getOperator())}_apply(e){const t=this._parse(e);return t.getFilters().length===0?e:(function(s,o){let a=s;const u=o.getFlattenedFilters();for(const h of u)zh(a,h),a=eo(a,h)}(e._query,t),new et(e.firestore,e.converter,eo(e._query,t)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return this.type==="and"?"and":"or"}}class oa extends sa{constructor(e,t){super(),this._field=e,this._direction=t,this.type="orderBy"}static _create(e,t){return new oa(e,t)}_apply(e){const t=function(s,o,a){if(s.startAt!==null)throw new V(P.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(s.endAt!==null)throw new V(P.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");return new fr(o,a)}(e._query,this._field,this._direction);return new et(e.firestore,e.converter,function(s,o){const a=s.explicitOrderBy.concat([o]);return new Pn(s.path,s.collectionGroup,a,s.filters.slice(),s.limit,s.limitType,s.startAt,s.endAt)}(e._query,t))}}function WT(n,e="asc"){const t=e,r=Xs("orderBy",n);return oa._create(r,t)}class aa extends sa{constructor(e,t,r){super(),this.type=e,this._limit=t,this._limitType=r}static _create(e,t,r){return new aa(e,t,r)}_apply(e){return new et(e.firestore,e.converter,Es(e._query,this._limit,this._limitType))}}function GT(n){return um("limit",n),aa._create("limit",n,"F")}function Vu(n,e,t){if(typeof(t=G(t))=="string"){if(t==="")throw new V(P.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!Ul(e)&&t.indexOf("/")!==-1)throw new V(P.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${t}' contains a '/' character.`);const r=e.path.child(Y.fromString(t));if(!L.isDocumentKey(r))throw new V(P.INVALID_ARGUMENT,`Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${r}' is not because it has an odd number of segments (${r.length}).`);return Kc(n,new L(r))}if(t instanceof ee)return Kc(n,t._key);throw new V(P.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${Ls(t)}.`)}function Du(n,e){if(!Array.isArray(n)||n.length===0)throw new V(P.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${e.toString()}' filters.`)}function zh(n,e){const t=function(s,o){for(const a of s)for(const u of a.getFlattenedFilters())if(o.indexOf(u.op)>=0)return u.op;return null}(n.filters,function(s){switch(s){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[]}}(e.op));if(t!==null)throw t===e.op?new V(P.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${e.op.toString()}' filter.`):new V(P.INVALID_ARGUMENT,`Invalid query. You cannot use '${e.op.toString()}' filters with '${t.toString()}' filters.`)}class Z_{convertValue(e,t="none"){switch(Ot(e)){case 0:return null;case 1:return e.booleanValue;case 2:return re(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(Dt(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 x(62114,{value:e})}}convertObject(e,t){return this.convertObjectMap(e.fields,t)}convertObjectMap(e,t="none"){const r={};return xt(e,(s,o)=>{r[s]=this.convertValue(o,t)}),r}convertVectorValue(e){var r,s,o;const t=(o=(s=(r=e.fields)==null?void 0:r[_s].arrayValue)==null?void 0:s.values)==null?void 0:o.map(a=>re(a.doubleValue));return new Qe(t)}convertGeoPoint(e){return new Ke(re(e.latitude),re(e.longitude))}convertArray(e,t){return(e.values||[]).map(r=>this.convertValue(r,t))}convertServerTimestamp(e,t){switch(t){case"previous":const r=Us(e);return r==null?null:this.convertValue(r,t);case"estimate":return this.convertTimestamp(lr(e));default:return null}}convertTimestamp(e){const t=Vt(e);return new Z(t.seconds,t.nanos)}convertDocumentKey(e,t){const r=Y.fromString(e);Q(ch(r),9688,{name:e});const s=new hr(r.get(1),r.get(3)),o=new L(r.popFirst(5));return s.isEqual(t)||ht(`Document ${o} contains a document reference within a different database (${s.projectId}/${s.database}) which is not supported. It will be treated as a reference in the current database (${t.projectId}/${t.database}) instead.`),o}}/**
2046 * @license
2047 * Copyright 2020 Google LLC
2048 *
2049 * Licensed under the Apache License, Version 2.0 (the "License");
2050 * you may not use this file except in compliance with the License.
2051 * You may obtain a copy of the License at
2052 *
2053 *   http://www.apache.org/licenses/LICENSE-2.0
2054 *
2055 * Unless required by applicable law or agreed to in writing, software
2056 * distributed under the License is distributed on an "AS IS" BASIS,
2057 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2058 * See the License for the specific language governing permissions and
2059 * limitations under the License.
2060 */function ca(n,e,t){let r;return r=n?t&&(t.merge||t.mergeFields)?n.toFirestore(e,t):n.toFirestore(e):e,r}class er{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}}class Wt extends jh{constructor(e,t,r,s,o,a){super(e,t,r,s,a),this._firestore=e,this._firestoreImpl=e,this.metadata=o}exists(){return super.exists()}data(e={}){if(this._document){if(this._converter){const t=new as(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(t,e)}return this._userDataWriter.convertValue(this._document.data.value,e.serverTimestamps)}}get(e,t={}){if(this._document){const r=this._document.data.field(Xs("DocumentSnapshot.get",e));if(r!==null)return this._userDataWriter.convertValue(r,t.serverTimestamps)}}toJSON(){if(this.metadata.hasPendingWrites)throw new V(P.FAILED_PRECONDITION,"DocumentSnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");const e=this._document,t={};return t.type=Wt._jsonSchemaVersion,t.bundle="",t.bundleSource="DocumentSnapshot",t.bundleName=this._key.toString(),!e||!e.isValidDocument()||!e.isFoundDocument()?t:(this._userDataWriter.convertObjectMap(e.data.value.mapValue.fields,"previous"),t.bundle=(this._firestore,this.ref.path,"NOT SUPPORTED"),t)}}Wt._jsonSchemaVersion="firestore/documentSnapshot/1.0",Wt._jsonSchema={type:ae("string",Wt._jsonSchemaVersion),bundleSource:ae("string","DocumentSnapshot"),bundleName:ae("string"),bundle:ae("string")};class as extends Wt{data(e={}){return super.data(e)}}class bt{constructor(e,t,r,s){this._firestore=e,this._userDataWriter=t,this._snapshot=s,this.metadata=new er(s.hasPendingWrites,s.fromCache),this.query=r}get docs(){const e=[];return this.forEach(t=>e.push(t)),e}get size(){return this._snapshot.docs.size}get empty(){return this.size===0}forEach(e,t){this._snapshot.docs.forEach(r=>{e.call(t,new as(this._firestore,this._userDataWriter,r.key,r,new er(this._snapshot.mutatedKeys.has(r.key),this._snapshot.fromCache),this.query.converter))})}docChanges(e={}){const t=!!e.includeMetadataChanges;if(t&&this._snapshot.excludesMetadataChanges)throw new V(P.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===t||(this._cachedChanges=function(s,o){if(s._snapshot.oldDocs.isEmpty()){let a=0;return s._snapshot.docChanges.map(u=>{const h=new as(s._firestore,s._userDataWriter,u.doc.key,u.doc,new er(s._snapshot.mutatedKeys.has(u.doc.key),s._snapshot.fromCache),s.query.converter);return u.doc,{type:"added",doc:h,oldIndex:-1,newIndex:a++}})}{let a=s._snapshot.oldDocs;return s._snapshot.docChanges.filter(u=>o||u.type!==3).map(u=>{const h=new as(s._firestore,s._userDataWriter,u.doc.key,u.doc,new er(s._snapshot.mutatedKeys.has(u.doc.key),s._snapshot.fromCache),s.query.converter);let d=-1,p=-1;return u.type!==0&&(d=a.indexOf(u.doc.key),a=a.delete(u.doc.key)),u.type!==1&&(a=a.add(u.doc),p=a.indexOf(u.doc.key)),{type:ey(u.type),doc:h,oldIndex:d,newIndex:p}})}}(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}toJSON(){if(this.metadata.hasPendingWrites)throw new V(P.FAILED_PRECONDITION,"QuerySnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");const e={};e.type=bt._jsonSchemaVersion,e.bundleSource="QuerySnapshot",e.bundleName=wo.newId(),this._firestore._databaseId.database,this._firestore._databaseId.projectId;const t=[],r=[],s=[];return this.docs.forEach(o=>{o._document!==null&&(t.push(o._document),r.push(this._userDataWriter.convertObjectMap(o._document.data.value.mapValue.fields,"previous")),s.push(o.ref.path))}),e.bundle=(this._firestore,this.query._query,e.bundleName,"NOT SUPPORTED"),e}}function ey(n){switch(n){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return x(61501,{type:n})}}/**
2061 * @license
2062 * Copyright 2020 Google LLC
2063 *
2064 * Licensed under the Apache License, Version 2.0 (the "License");
2065 * you may not use this file except in compliance with the License.
2066 * You may obtain a copy of the License at
2067 *
2068 *   http://www.apache.org/licenses/LICENSE-2.0
2069 *
2070 * Unless required by applicable law or agreed to in writing, software
2071 * distributed under the License is distributed on an "AS IS" BASIS,
2072 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2073 * See the License for the specific language governing permissions and
2074 * limitations under the License.
2075 */function KT(n){n=le(n,ee);const e=le(n.firestore,Le);return Nh(en(e),n._key).then(t=>ua(e,n,t))}bt._jsonSchemaVersion="firestore/querySnapshot/1.0",bt._jsonSchema={type:ae("string",bt._jsonSchemaVersion),bundleSource:ae("string","QuerySnapshot"),bundleName:ae("string"),bundle:ae("string")};class ei extends Z_{constructor(e){super(),this.firestore=e}convertBytes(e){return new Oe(e)}convertReference(e){const t=this.convertDocumentKey(e,this.firestore._databaseId);return new ee(this.firestore,null,t)}}function QT(n){n=le(n,ee);const e=le(n.firestore,Le);return Nh(en(e),n._key,{source:"server"}).then(t=>ua(e,n,t))}function JT(n){n=le(n,et);const e=le(n.firestore,Le),t=en(e),r=new ei(e);return $h(n._query),Vh(t,n._query).then(s=>new bt(e,r,n,s))}function YT(n){n=le(n,et);const e=le(n.firestore,Le),t=en(e),r=new ei(e);return Vh(t,n._query,{source:"server"}).then(s=>new bt(e,r,n,s))}function XT(n,e,t){n=le(n,ee);const r=le(n.firestore,Le),s=ca(n.converter,e,t);return Cr(r,[Jo(Sr(r),"setDoc",n._key,s,n.converter!==null,t).toMutation(n._key,Se.none())])}function ZT(n,e,t,...r){n=le(n,ee);const s=le(n.firestore,Le),o=Sr(s);let a;return a=typeof(e=G(e))=="string"||e instanceof Rr?Fh(o,"updateDoc",n._key,e,t,r):xh(o,"updateDoc",n._key,e),Cr(s,[a.toMutation(n._key,Se.exists(!0))])}function eI(n){return Cr(le(n.firestore,Le),[new Ws(n._key,Se.none())])}function tI(n,e){const t=le(n.firestore,Le),r=H_(n),s=ca(n.converter,e);return Cr(t,[Jo(Sr(n.firestore),"addDoc",r._key,s,n.converter!==null,{}).toMutation(r._key,Se.exists(!1))]).then(()=>r)}function nI(n,...e){var h,d,p;n=G(n);let t={includeMetadataChanges:!1,source:"default"},r=0;typeof e[r]!="object"||Nu(e[r])||(t=e[r++]);const s={includeMetadataChanges:t.includeMetadataChanges,source:t.source};if(Nu(e[r])){const _=e[r];e[r]=(h=_.next)==null?void 0:h.bind(_),e[r+1]=(d=_.error)==null?void 0:d.bind(_),e[r+2]=(p=_.complete)==null?void 0:p.bind(_)}let o,a,u;if(n instanceof ee)a=le(n.firestore,Le),u=Bs(n._key.path),o={next:_=>{e[r]&&e[r](ua(a,n,_))},error:e[r+1],complete:e[r+2]};else{const _=le(n,et);a=le(_.firestore,Le),u=_._query;const E=new ei(a);o={next:S=>{e[r]&&e[r](new bt(a,E,_,S))},error:e[r+1],complete:e[r+2]},$h(n._query)}return function(E,S,b,D){const N=new Ko(D),q=new Ho(S,N,b);return E.asyncQueue.enqueueAndForget(async()=>jo(await As(E),q)),()=>{N.Nu(),E.asyncQueue.enqueueAndForget(async()=>$o(await As(E),q))}}(en(a),u,s,o)}function Cr(n,e){return function(r,s){const o=new at;return r.asyncQueue.enqueueAndForget(async()=>V_(await $_(r),s,o)),o.promise}(en(n),e)}function ua(n,e,t){const r=t.docs.get(e._key),s=new ei(n);return new Wt(n,s,e._key,r,new er(t.hasPendingWrites,t.fromCache),e.converter)}/**
2076 * @license
2077 * Copyright 2020 Google LLC
2078 *
2079 * Licensed under the Apache License, Version 2.0 (the "License");
2080 * you may not use this file except in compliance with the License.
2081 * You may obtain a copy of the License at
2082 *
2083 *   http://www.apache.org/licenses/LICENSE-2.0
2084 *
2085 * Unless required by applicable law or agreed to in writing, software
2086 * distributed under the License is distributed on an "AS IS" BASIS,
2087 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2088 * See the License for the specific language governing permissions and
2089 * limitations under the License.
2090 */class ty{constructor(e,t){this._firestore=e,this._commitHandler=t,this._mutations=[],this._committed=!1,this._dataReader=Sr(e)}set(e,t,r){this._verifyNotCommitted();const s=Bi(e,this._firestore),o=ca(s.converter,t,r),a=Jo(this._dataReader,"WriteBatch.set",s._key,o,s.converter!==null,r);return this._mutations.push(a.toMutation(s._key,Se.none())),this}update(e,t,r,...s){this._verifyNotCommitted();const o=Bi(e,this._firestore);let a;return a=typeof(t=G(t))=="string"||t instanceof Rr?Fh(this._dataReader,"WriteBatch.update",o._key,t,r,s):xh(this._dataReader,"WriteBatch.update",o._key,t),this._mutations.push(a.toMutation(o._key,Se.exists(!0))),this}delete(e){this._verifyNotCommitted();const t=Bi(e,this._firestore);return this._mutations=this._mutations.concat(new Ws(t._key,Se.none())),this}commit(){return this._verifyNotCommitted(),this._committed=!0,this._mutations.length>0?this._commitHandler(this._mutations):Promise.resolve()}_verifyNotCommitted(){if(this._committed)throw new V(P.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")}}function Bi(n,e){if((n=G(n)).firestore!==e)throw new V(P.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return n}/**
2091 * @license
2092 * Copyright 2020 Google LLC
2093 *
2094 * Licensed under the Apache License, Version 2.0 (the "License");
2095 * you may not use this file except in compliance with the License.
2096 * You may obtain a copy of the License at
2097 *
2098 *   http://www.apache.org/licenses/LICENSE-2.0
2099 *
2100 * Unless required by applicable law or agreed to in writing, software
2101 * distributed under the License is distributed on an "AS IS" BASIS,
2102 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2103 * See the License for the specific language governing permissions and
2104 * limitations under the License.
2105 */function rI(){return new Pr("deleteField")}function sI(){return new Yo("serverTimestamp")}function iI(...n){return new Xo("arrayUnion",n)}function oI(...n){return new Zo("arrayRemove",n)}function aI(n){return new ea("increment",n)}/**
2106 * @license
2107 * Copyright 2020 Google LLC
2108 *
2109 * Licensed under the Apache License, Version 2.0 (the "License");
2110 * you may not use this file except in compliance with the License.
2111 * You may obtain a copy of the License at
2112 *
2113 *   http://www.apache.org/licenses/LICENSE-2.0
2114 *
2115 * Unless required by applicable law or agreed to in writing, software
2116 * distributed under the License is distributed on an "AS IS" BASIS,
2117 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2118 * See the License for the specific language governing permissions and
2119 * limitations under the License.
2120 */function cI(n){return en(n=le(n,Le)),new ty(n,e=>Cr(n,e))}(function(e,t=!0){(function(s){An=s})(vn),Gt(new kt("firestore",(r,{instanceIdentifier:s,options:o})=>{const a=r.getProvider("app").getImmediate(),u=new Le(new em(r.getProvider("auth-internal")),new rm(a,r.getProvider("app-check-internal")),function(d,p){if(!Object.prototype.hasOwnProperty.apply(d.options,["projectId"]))throw new V(P.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new hr(d.options.projectId,p)}(a,s),a);return o={useFetchStreams:t,...o},u._setSettings(o),u},"PUBLIC").setMultipleInstances(!0)),He(Mc,Lc,e),He(Mc,Lc,"esm2020")})();var ny="firebase",ry="12.1.0";/**
2121 * @license
2122 * Copyright 2020 Google LLC
2123 *
2124 * Licensed under the Apache License, Version 2.0 (the "License");
2125 * you may not use this file except in compliance with the License.
2126 * You may obtain a copy of the License at
2127 *
2128 *   http://www.apache.org/licenses/LICENSE-2.0
2129 *
2130 * Unless required by applicable law or agreed to in writing, software
2131 * distributed under the License is distributed on an "AS IS" BASIS,
2132 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2133 * See the License for the specific language governing permissions and
2134 * limitations under the License.
2135 */He(ny,ry,"app");/**
2136 * @license
2137 * Copyright 2017 Google LLC
2138 *
2139 * Licensed under the Apache License, Version 2.0 (the "License");
2140 * you may not use this file except in compliance with the License.
2141 * You may obtain a copy of the License at
2142 *
2143 *   http://www.apache.org/licenses/LICENSE-2.0
2144 *
2145 * Unless required by applicable law or agreed to in writing, software
2146 * distributed under the License is distributed on an "AS IS" BASIS,
2147 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2148 * See the License for the specific language governing permissions and
2149 * limitations under the License.
2150 */const sy="type.googleapis.com/google.protobuf.Int64Value",iy="type.googleapis.com/google.protobuf.UInt64Value";function Hh(n,e){const t={};for(const r in n)n.hasOwnProperty(r)&&(t[r]=e(n[r]));return t}function Ss(n){if(n==null)return null;if(n instanceof Number&&(n=n.valueOf()),typeof n=="number"&&isFinite(n)||n===!0||n===!1||Object.prototype.toString.call(n)==="[object String]")return n;if(n instanceof Date)return n.toISOString();if(Array.isArray(n))return n.map(e=>Ss(e));if(typeof n=="function"||typeof n=="object")return Hh(n,e=>Ss(e));throw new Error("Data cannot be encoded in JSON: "+n)}function wn(n){if(n==null)return n;if(n["@type"])switch(n["@type"]){case sy:case iy:{const e=Number(n.value);if(isNaN(e))throw new Error("Data cannot be decoded from JSON: "+n);return e}default:throw new Error("Data cannot be decoded from JSON: "+n)}return Array.isArray(n)?n.map(e=>wn(e)):typeof n=="function"||typeof n=="object"?Hh(n,e=>wn(e)):n}/**
2151 * @license
2152 * Copyright 2020 Google LLC
2153 *
2154 * Licensed under the Apache License, Version 2.0 (the "License");
2155 * you may not use this file except in compliance with the License.
2156 * You may obtain a copy of the License at
2157 *
2158 *   http://www.apache.org/licenses/LICENSE-2.0
2159 *
2160 * Unless required by applicable law or agreed to in writing, software
2161 * distributed under the License is distributed on an "AS IS" BASIS,
2162 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2163 * See the License for the specific language governing permissions and
2164 * limitations under the License.
2165 */const la="functions";/**
2166 * @license
2167 * Copyright 2017 Google LLC
2168 *
2169 * Licensed under the Apache License, Version 2.0 (the "License");
2170 * you may not use this file except in compliance with the License.
2171 * You may obtain a copy of the License at
2172 *
2173 *   http://www.apache.org/licenses/LICENSE-2.0
2174 *
2175 * Unless required by applicable law or agreed to in writing, software
2176 * distributed under the License is distributed on an "AS IS" BASIS,
2177 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2178 * See the License for the specific language governing permissions and
2179 * limitations under the License.
2180 */const Ou={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 ke extends Ze{constructor(e,t,r){super(`${la}/${e}`,t||""),this.details=r,Object.setPrototypeOf(this,ke.prototype)}}function oy(n){if(n>=200&&n<300)return"ok";switch(n){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"}function Ps(n,e){let t=oy(n),r=t,s;try{const o=e&&e.error;if(o){const a=o.status;if(typeof a=="string"){if(!Ou[a])return new ke("internal","internal");t=Ou[a],r=a}const u=o.message;typeof u=="string"&&(r=u),s=o.details,s!==void 0&&(s=wn(s))}}catch{}return t==="ok"?null:new ke(t,r,s)}/**
2181 * @license
2182 * Copyright 2017 Google LLC
2183 *
2184 * Licensed under the Apache License, Version 2.0 (the "License");
2185 * you may not use this file except in compliance with the License.
2186 * You may obtain a copy of the License at
2187 *
2188 *   http://www.apache.org/licenses/LICENSE-2.0
2189 *
2190 * Unless required by applicable law or agreed to in writing, software
2191 * distributed under the License is distributed on an "AS IS" BASIS,
2192 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2193 * See the License for the specific language governing permissions and
2194 * limitations under the License.
2195 */class ay{constructor(e,t,r,s){this.app=e,this.auth=null,this.messaging=null,this.appCheck=null,this.serverAppAppCheckToken=null,pe(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(o=>this.auth=o,()=>{}),this.messaging||r.get().then(o=>this.messaging=o,()=>{}),this.appCheck||s==null||s.get().then(o=>this.appCheck=o,()=>{})}async getAuthToken(){if(this.auth)try{const e=await this.auth.getToken();return e==null?void 0:e.accessToken}catch{return}}async getMessagingToken(){if(!(!this.messaging||!("Notification"in self)||Notification.permission!=="granted"))try{return await this.messaging.getToken()}catch{return}}async getAppCheckToken(e){if(this.serverAppAppCheckToken)return this.serverAppAppCheckToken;if(this.appCheck){const t=e?await this.appCheck.getLimitedUseToken():await this.appCheck.getToken();return t.error?null:t.token}return null}async getContext(e){const t=await this.getAuthToken(),r=await this.getMessagingToken(),s=await this.getAppCheckToken(e);
2195return{authToken:t,messagingToken:r,appCheckToken:s}}}/**
2196 * @license
2197 * Copyright 2017 Google LLC
2198 *
2199 * Licensed under the Apache License, Version 2.0 (the "License");
2200 * you may not use this file except in compliance with the License.
2201 * You may obtain a copy of the License at
2202 *
2203 *   http://www.apache.org/licenses/LICENSE-2.0
2204 *
2205 * Unless required by applicable law or agreed to in writing, software
2206 * distributed under the License is distributed on an "AS IS" BASIS,
2207 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2208 * See the License for the specific language governing permissions and
2209 * limitations under the License.
2210 */const ho="us-central1",cy=/^data: (.*?)(?:\n|$)/;function uy(n){let e=null;return{promise:new Promise((t,r)=>{e=setTimeout(()=>{r(new ke("deadline-exceeded","deadline-exceeded"))},n)}),cancel:()=>{e&&clearTimeout(e)}}}class ly{constructor(e,t,r,s,o=ho,a=(...u)=>fetch(...u)){this.app=e,this.fetchImpl=a,this.emulatorOrigin=null,this.contextProvider=new ay(e,t,r,s),this.cancelAllRequests=new Promise(u=>{this.deleteService=()=>Promise.resolve(u())});try{const u=new URL(o);this.customDomain=u.origin+(u.pathname==="/"?"":u.pathname),this.region=ho}catch{this.customDomain=null,this.region=o}}_delete(){return this.deleteService()}_url(e){const t=this.app.options.projectId;return this.emulatorOrigin!==null?`${this.emulatorOrigin}/${t}/${this.region}/${e}`:this.customDomain!==null?`${this.customDomain}/${e}`:`https://${this.region}-${t}.cloudfunctions.net/${e}`}}function hy(n,e,t){const r=Yt(e);n.emulatorOrigin=`http${r?"s":""}://${e}:${t}`,r&&(yo(n.emulatorOrigin),cl("Functions",!0))}function dy(n,e,t){const r=s=>py(n,e,s,{});return r.stream=(s,o)=>gy(n,e,s,o),r}async function fy(n,e,t,r){t["Content-Type"]="application/json";let s;try{s=await r(n,{method:"POST",body:JSON.stringify(e),headers:t})}catch{return{status:0,json:null}}let o=null;try{o=await s.json()}catch{}return{status:s.status,json:o}}async function Wh(n,e){const t={},r=await n.contextProvider.getContext(e.limitedUseAppCheckTokens);return r.authToken&&(t.Authorization="Bearer "+r.authToken),r.messagingToken&&(t["Firebase-Instance-ID-Token"]=r.messagingToken),r.appCheckToken!==null&&(t["X-Firebase-AppCheck"]=r.appCheckToken),t}function py(n,e,t,r){const s=n._url(e);return my(n,s,t,r)}async function my(n,e,t,r){t=Ss(t);const s={data:t},o=await Wh(n,r),a=r.timeout||7e4,u=uy(a),h=await Promise.race([fy(e,s,o,n.fetchImpl),u.promise,n.cancelAllRequests]);if(u.cancel(),!h)throw new ke("cancelled","Firebase Functions instance was deleted.");const d=Ps(h.status,h.json);if(d)throw d;if(!h.json)throw new ke("internal","Response is not valid JSON object.");let p=h.json.data;if(typeof p>"u"&&(p=h.json.result),typeof p>"u")throw new ke("internal","Response is missing data field.");return{data:wn(p)}}function gy(n,e,t,r){const s=n._url(e);return _y(n,s,t,r||{})}async function _y(n,e,t,r){var E;t=Ss(t);const s={data:t},o=await Wh(n,r);o["Content-Type"]="application/json",o.Accept="text/event-stream";let a;try{a=await n.fetchImpl(e,{method:"POST",body:JSON.stringify(s),headers:o,signal:r==null?void 0:r.signal})}catch(S){if(S instanceof Error&&S.name==="AbortError"){const D=new ke("cancelled","Request was cancelled.");return{data:Promise.reject(D),stream:{[Symbol.asyncIterator](){return{next(){return Promise.reject(D)}}}}}}const b=Ps(0,null);return{data:Promise.reject(b),stream:{[Symbol.asyncIterator](){return{next(){return Promise.reject(b)}}}}}}let u,h;const d=new Promise((S,b)=>{u=S,h=b});(E=r==null?void 0:r.signal)==null||E.addEventListener("abort",()=>{const S=new ke("cancelled","Request was cancelled.");h(S)});const p=a.body.getReader(),_=yy(p,u,h,r==null?void 0:r.signal);return{stream:{[Symbol.asyncIterator](){const S=_.getReader();return{async next(){const{value:b,done:D}=await S.read();return{value:b,done:D}},async return(){return await S.cancel(),{done:!0,value:void 0}}}}},data:d}}function yy(n,e,t,r){const s=(a,u)=>{const h=a.match(cy);if(!h)return;const d=h[1];try{const p=JSON.parse(d);if("result"in p){e(wn(p.result));return}if("message"in p){u.enqueue(wn(p.message));return}if("error"in p){const _=Ps(0,p);u.error(_),t(_);return}}catch(p){if(p instanceof ke){u.error(p),t(p);return}}},o=new TextDecoder;return new ReadableStream({start(a){let u="";return h();async function h(){if(r!=null&&r.aborted){const d=new ke("cancelled","Request was cancelled");return a.error(d),t(d),Promise.resolve()}try{const{value:d,done:p}=await n.read();if(p){u.trim()&&s(u.trim(),a),a.close();return}if(r!=null&&r.aborted){const E=new ke("cancelled","Request was cancelled");a.error(E),t(E),await n.cancel();return}u+=o.decode(d,{stream:!0});const _=u.split(`
2211`);u=_.pop()||"";for(const E of _)E.trim()&&s(E.trim(),a);return h()}catch(d){const p=d instanceof ke?d:Ps(0,null);a.error(p),t(p)}}},cancel(){return n.cancel()}})}const Mu="@firebase/functions",Lu="0.13.0";/**
2212 * @license
2213 * Copyright 2019 Google LLC
2214 *
2215 * Licensed under the Apache License, Version 2.0 (the "License");
2216 * you may not use this file except in compliance with the License.
2217 * You may obtain a copy of the License at
2218 *
2219 *   http://www.apache.org/licenses/LICENSE-2.0
2220 *
2221 * Unless required by applicable law or agreed to in writing, software
2222 * distributed under the License is distributed on an "AS IS" BASIS,
2223 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2224 * See the License for the specific language governing permissions and
2225 * limitations under the License.
2226 */const Ey="auth-internal",Ty="app-check-internal",Iy="messaging-internal";function wy(n){const e=(t,{instanceIdentifier:r})=>{const s=t.getProvider("app").getImmediate(),o=t.getProvider(Ey),a=t.getProvider(Iy),u=t.getProvider(Ty);return new ly(s,o,a,u,r)};Gt(new kt(la,e,"PUBLIC").setMultipleInstances(!0)),He(Mu,Lu,n),He(Mu,Lu,"esm2020")}/**
2227 * @license
2228 * Copyright 2020 Google LLC
2229 *
2230 * Licensed under the Apache License, Version 2.0 (the "License");
2231 * you may not use this file except in compliance with the License.
2232 * You may obtain a copy of the License at
2233 *
2234 *   http://www.apache.org/licenses/LICENSE-2.0
2235 *
2236 * Unless required by applicable law or agreed to in writing, software
2237 * distributed under the License is distributed on an "AS IS" BASIS,
2238 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2239 * See the License for the specific language governing permissions and
2240 * limitations under the License.
2241 */function uI(n=hl(),e=ho){const r=Ms(G(n),la).getImmediate({identifier:e}),s=Ef("functions");return s&&vy(r,...s),r}function vy(n,e,t){hy(G(n),e,t)}function lI(n,e,t){return dy(G(n),e)}wy();function Gh(){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."}}const Ay=Gh,Kh=new yr("auth","Firebase",Gh());/**
2242 * @license
2243 * Copyright 2020 Google LLC
2244 *
2245 * Licensed under the Apache License, Version 2.0 (the "License");
2246 * you may not use this file except in compliance with the License.
2247 * You may obtain a copy of the License at
2248 *
2249 *   http://www.apache.org/licenses/LICENSE-2.0
2250 *
2251 * Unless required by applicable law or agreed to in writing, software
2252 * distributed under the License is distributed on an "AS IS" BASIS,
2253 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2254 * See the License for the specific language governing permissions and
2255 * limitations under the License.
2256 */const Cs=new Eo("@firebase/auth");function Ry(n,...e){Cs.logLevel<=j.WARN&&Cs.warn(`Auth (${vn}): ${n}`,...e)}function cs(n,...e){Cs.logLevel<=j.ERROR&&Cs.error(`Auth (${vn}): ${n}`,...e)}/**
2257 * @license
2258 * Copyright 2020 Google LLC
2259 *
2260 * Licensed under the Apache License, Version 2.0 (the "License");
2261 * you may not use this file except in compliance with the License.
2262 * You may obtain a copy of the License at
2263 *
2264 *   http://www.apache.org/licenses/LICENSE-2.0
2265 *
2266 * Unless required by applicable law or agreed to in writing, software
2267 * distributed under the License is distributed on an "AS IS" BASIS,
2268 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2269 * See the License for the specific language governing permissions and
2270 * limitations under the License.
2271 */function De(n,...e){throw da(n,...e)}function Be(n,...e){return da(n,...e)}function ha(n,e,t){const r={...Ay(),[e]:t};return new yr("auth","Firebase",r).create(e,{appName:n.name})}function Me(n){return ha(n,"operation-not-supported-in-this-environment","Operations that alter the current user are not supported in conjunction with FirebaseServerApp")}function Sy(n,e,t){const r=t;if(!(e instanceof r))throw r.name!==e.constructor.name&&De(n,"argument-error"),ha(n,"argument-error",`Type of ${e.constructor.name} does not match expected instance.Did you pass a reference from a different Auth SDK?`)}function da(n,...e){if(typeof n!="string"){const t=e[0],r=[...e.slice(1)];return r[0]&&(r[0].appName=n.name),n._errorFactory.create(t,...r)}return Kh.create(n,...e)}function M(n,e,...t){if(!n)throw da(e,...t)}function it(n){const e="INTERNAL ASSERTION FAILED: "+n;throw cs(e),new Error(e)}function ft(n,e){n||it(e)}/**
2272 * @license
2273 * Copyright 2020 Google LLC
2274 *
2275 * Licensed under the Apache License, Version 2.0 (the "License");
2276 * you may not use this file except in compliance with the License.
2277 * You may obtain a copy of the License at
2278 *
2279 *   http://www.apache.org/licenses/LICENSE-2.0
2280 *
2281 * Unless required by applicable law or agreed to in writing, software
2282 * distributed under the License is distributed on an "AS IS" BASIS,
2283 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2284 * See the License for the specific language governing permissions and
2285 * limitations under the License.
2286 */function fo(){var n;return typeof self<"u"&&((n=self.location)==null?void 0:n.href)||""}function Py(){return xu()==="http:"||xu()==="https:"}function xu(){var n;return typeof self<"u"&&((n=self.location)==null?void 0:n.protocol)||null}/**
2287 * @license
2288 * Copyright 2020 Google LLC
2289 *
2290 * Licensed under the Apache License, Version 2.0 (the "License");
2291 * you may not use this file except in compliance with the License.
2292 * You may obtain a copy of the License at
2293 *
2294 *   http://www.apache.org/licenses/LICENSE-2.0
2295 *
2296 * Unless required by applicable law or agreed to in writing, software
2297 * distributed under the License is distributed on an "AS IS" BASIS,
2298 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2299 * See the License for the specific language governing permissions and
2300 * limitations under the License.
2301 */function Cy(){return typeof navigator<"u"&&navigator&&"onLine"in navigator&&typeof navigator.onLine=="boolean"&&(Py()||Sf()||"connection"in navigator)?navigator.onLine:!0}function by(){if(typeof navigator>"u")return null;const n=navigator;return n.languages&&n.languages[0]||n.language||null}/**
2302 * @license
2303 * Copyright 2020 Google LLC
2304 *
2305 * Licensed under the Apache License, Version 2.0 (the "License");
2306 * you may not use this file except in compliance with the License.
2307 * You may obtain a copy of the License at
2308 *
2309 *   http://www.apache.org/licenses/LICENSE-2.0
2310 *
2311 * Unless required by applicable law or agreed to in writing, software
2312 * distributed under the License is distributed on an "AS IS" BASIS,
2313 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2314 * See the License for the specific language governing permissions and
2315 * limitations under the License.
2316 */class br{constructor(e,t){this.shortDelay=e,this.longDelay=t,ft(t>e,"Short delay should be less than long delay!"),this.isMobile=vf()||Pf()}get(){return Cy()?this.isMobile?this.longDelay:this.shortDelay:Math.min(5e3,this.shortDelay)}}/**
2317 * @license
2318 * Copyright 2020 Google LLC
2319 *
2320 * Licensed under the Apache License, Version 2.0 (the "License");
2321 * you may not use this file except in compliance with the License.
2322 * You may obtain a copy of the License at
2323 *
2324 *   http://www.apache.org/licenses/LICENSE-2.0
2325 *
2326 * Unless required by applicable law or agreed to in writing, software
2327 * distributed under the License is distributed on an "AS IS" BASIS,
2328 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2329 * See the License for the specific language governing permissions and
2330 * limitations under the License.
2331 */function fa(n,e){ft(n.emulator,"Emulator should always be set here");const{url:t}=n.emulator;return e?`${t}${e.startsWith("/")?e.slice(1):e}`:t}/**
2332 * @license
2333 * Copyright 2020 Google LLC
2334 *
2335 * Licensed under the Apache License, Version 2.0 (the "License");
2336 * you may not use this file except in compliance with the License.
2337 * You may obtain a copy of the License at
2338 *
2339 *   http://www.apache.org/licenses/LICENSE-2.0
2340 *
2341 * Unless required by applicable law or agreed to in writing, software
2342 * distributed under the License is distributed on an "AS IS" BASIS,
2343 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2344 * See the License for the specific language governing permissions and
2345 * limitations under the License.
2346 */class Qh{static initialize(e,t,r){this.fetchImpl=e,t&&(this.headersImpl=t),r&&(this.responseImpl=r)}static fetch(){if(this.fetchImpl)return this.fetchImpl;if(typeof self<"u"&&"fetch"in self)return self.fetch;if(typeof globalThis<"u"&&globalThis.fetch)return globalThis.fetch;if(typeof fetch<"u")return fetch;it("Could not find fetch implementation, make sure you call FetchProvi
2346der.initialize() with an appropriate polyfill")}static headers(){if(this.headersImpl)return this.headersImpl;if(typeof self<"u"&&"Headers"in self)return self.Headers;if(typeof globalThis<"u"&&globalThis.Headers)return globalThis.Headers;if(typeof Headers<"u")return Headers;it("Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static response(){if(this.responseImpl)return this.responseImpl;if(typeof self<"u"&&"Response"in self)return self.Response;if(typeof globalThis<"u"&&globalThis.Response)return globalThis.Response;if(typeof Response<"u")return Response;it("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}}/**
2347 * @license
2348 * Copyright 2020 Google LLC
2349 *
2350 * Licensed under the Apache License, Version 2.0 (the "License");
2351 * you may not use this file except in compliance with the License.
2352 * You may obtain a copy of the License at
2353 *
2354 *   http://www.apache.org/licenses/LICENSE-2.0
2355 *
2356 * Unless required by applicable law or agreed to in writing, software
2357 * distributed under the License is distributed on an "AS IS" BASIS,
2358 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2359 * See the License for the specific language governing permissions and
2360 * limitations under the License.
2361 */const ky={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"};/**
2362 * @license
2363 * Copyright 2020 Google LLC
2364 *
2365 * Licensed under the Apache License, Version 2.0 (the "License");
2366 * you may not use this file except in compliance with the License.
2367 * You may obtain a copy of the License at
2368 *
2369 *   http://www.apache.org/licenses/LICENSE-2.0
2370 *
2371 * Unless required by applicable law or agreed to in writing, software
2372 * distributed under the License is distributed on an "AS IS" BASIS,
2373 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2374 * See the License for the specific language governing permissions and
2375 * limitations under the License.
2376 */const Ny=["/v1/accounts:signInWithCustomToken","/v1/accounts:signInWithEmailLink","/v1/accounts:signInWithIdp","/v1/accounts:signInWithPassword","/v1/accounts:signInWithPhoneNumber","/v1/token"],Vy=new br(3e4,6e4);function je(n,e){return n.tenantId&&!e.tenantId?{...e,tenantId:n.tenantId}:e}async function xe(n,e,t,r,s={}){return Jh(n,s,async()=>{let o={},a={};r&&(e==="GET"?a=r:o={body:JSON.stringify(r)});const u=Er({key:n.config.apiKey,...a}
2376).slice(1),h=await n._getAdditionalHeaders();h["Content-Type"]="application/json",n.languageCode&&(h["X-Firebase-Locale"]=n.languageCode);const d={method:e,headers:h,...o};return Rf()||(d.referrerPolicy="no-referrer"),n.emulatorConfig&&Yt(n.emulatorConfig.host)&&(d.credentials="include"),Qh.fetch()(await Yh(n,n.config.apiHost,t,u),d)})}async function Jh(n,e,t){n._canInitEmulator=!1;const r={...ky,...e};try{const s=new Oy(n),o=await Promise.race([t(),s.promise]);s.clearNetworkTimeout();const a=await o.json();if("needConfirmation"in a)throw ts(n,"account-exists-with-different-credential",a);if(o.ok&&!("errorMessage"in a))return a;{const u=o.ok?a.errorMessage:a.error.message,[h,d]=u.split(" : ");if(h==="FEDERATED_USER_ID_ALREADY_LINKED")throw ts(n,"credential-already-in-use",a);if(h==="EMAIL_EXISTS")throw ts(n,"email-already-in-use",a);if(h==="USER_DISABLED")throw ts(n,"user-disabled",a);const p=r[h]||h.toLowerCase().replace(/[_\s]+/g,"-");if(d)throw ha(n,p,d);De(n,p)}}catch(s){if(s instanceof Ze)throw s;De(n,"network-request-failed",{message:String(s)})}}async function bn(n,e,t,r,s={}){const o=await xe(n,e,t,r,s);return"mfaPendingCredential"in o&&De(n,"multi-factor-auth-required",{_serverResponse:o}),o}async function Yh(n,e,t,r){const s=`${e}${t}?${r}`,o=n,a=o.config.emulator?fa(n.config,s):`${n.config.apiScheme}://${s}`;return Ny.includes(t)&&(await o._persistenceManagerAvailable,o._getPersistenceType()==="COOKIE")?o._getPersistence()._getFinalTarget(a).toString():a}function Dy(n){switch(n){case"ENFORCE":return"ENFORCE";case"AUDIT":return"AUDIT";case"OFF":return"OFF";default:return"ENFORCEMENT_STATE_UNSPECIFIED"}}class Oy{clearNetworkTimeout(){clearTimeout(this.timer)}constructor(e){this.auth=e,this.timer=null,this.promise=new Promise((t,r)=>{this.timer=setTimeout(()=>r(Be(this.auth,"network-request-failed")),Vy.get())})}}function ts(n,e,t){const r={appName:n.name};t.email&&(r.email=t.email),t.phoneNumber&&(r.phoneNumber=t.phoneNumber);const s=Be(n,e,r);return s.customData._tokenResponse=t,s}function Fu(n){return n!==void 0&&n.enterprise!==void 0}class My{constructor(e){if(this.siteKey="",this.recaptchaEnforcementState=[],e.recaptchaKey===void 0)throw new Error("recaptchaKey undefined");this.siteKey=e.recaptchaKey.split("/")[3],this.recaptchaEnforcementState=e.recaptchaEnforcementState}getProviderEnforcementState(e){if(!this.recaptchaEnforcementState||this.recaptchaEnforcementState.length===0)return null;for(const t of this.recaptchaEnforcementState)if(t.provider&&t.provider===e)return Dy(t.enforcementState);return null}isProviderEnabled(e){return this.getProviderEnforcementState(e)==="ENFORCE"||this.getProviderEnforcementState(e)==="AUDIT"}isAnyProviderEnabled(){return this.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")||this.isProviderEnabled("PHONE_PROVIDER")}}async function Ly(n,e){return xe(n,"GET","/v2/recaptchaConfig",je(n,e))}/**
2377 * @license
2378 * Copyright 2020 Google LLC
2379 *
2380 * Licensed under the Apache License, Version 2.0 (the "License");
2381 * you may not use this file except in compliance with the License.
2382 * You may obtain a copy of the License at
2383 *
2384 *   http://www.apache.org/licenses/LICENSE-2.0
2385 *
2386 * Unless required by applicable law or agreed to in writing, software
2387 * distributed under the License is distributed on an "AS IS" BASIS,
2388 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2389 * See the License for the specific language governing permissions and
2390 * limitations under the License.
2391 */async function xy(n,e){return xe(n,"POST","/v1/accounts:delete",e)}async function bs(n,e){return xe(n,"POST","/v1/accounts:lookup",e)}/**
2392 * @license
2393 * Copyright 2020 Google LLC
2394 *
2395 * Licensed under the Apache License, Version 2.0 (the "License");
2396 * you may not use this file except in compliance with the License.
2397 * You may obtain a copy of the License at
2398 *
2399 *   http://www.apache.org/licenses/LICENSE-2.0
2400 *
2401 * Unless required by applicable law or agreed to in writing, software
2402 * distributed under the License is distributed on an "AS IS" BASIS,
2403 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2404 * See the License for the specific language governing permissions and
2405 * limitations under the License.
2406 */function or(n){if(n)try{const e=new Date(Number(n));if(!isNaN(e.getTime()))return e.toUTCString()}catch{}}/**
2407 * @license
2408 * Copyright 2020 Google LLC
2409 *
2410 * Licensed under the Apache License, Version 2.0 (the "License");
2411 * you may not use this file except in compliance with the License.
2412 * You may obtain a copy of the License at
2413 *
2414 *   http://www.apache.org/licenses/LICENSE-2.0
2415 *
2416 * Unless required by applicable law or agreed to in writing, software
2417 * distributed under the License is distributed on an "AS IS" BASIS,
2418 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2419 * See the License for the specific language governing permissions and
2420 * limitations under the License.
2421 */function hI(n,e=!1){return G(n).getIdToken(e)}async function Fy(n,e=!1){const t=G(n),r=await t.getIdToken(e),s=pa(r);M(s&&s.exp&&s.auth_time&&s.iat,t.auth,"internal-error");const o=typeof s.firebase=="object"?s.firebase:void 0,a=o==null?void 0:o.sign_in_provider;return{claims:s,token:r,authTime:or(qi(s.auth_time)),issuedAtTime:or(qi(s.iat)),expirationTime:or(qi(s.exp)),signInProvider:a||null,signInSecondFactor:(o==null?void 0:o.sign_in_second_factor)||null}}function qi(n){return Number(n)*1e3}function pa(n){const[e,t,r]=n.split(".");if(e===void 0||t===void 0||r===void 0)return cs("JWT malformed, contained fewer than 3 sections"),null;try{const s=sl(t);return s?JSON.parse(s):(cs("Failed to decode base64 JWT payload"),null)}catch(s){return cs("Caught error parsing JWT payload as JSON",s==null?void 0:s.toString()),null}}function Uu(n){const e=pa(n);return M(e,"internal-error"),M(typeof e.exp<"u","internal-error"),M(typeof e.iat<"u","internal-error"),Number(e.exp)-Number(e.iat)}/**
2422 * @license
2423 * Copyright 2020 Google LLC
2424 *
2425 * Licensed under the Apache License, Version 2.0 (the "License");
2426 * you may not use this file except in compliance with the License.
2427 * You may obtain a copy of the License at
2428 *
2429 *   http://www.apache.org/licenses/LICENSE-2.0
2430 *
2431 * Unless required by applicable law or agreed to in writing, software
2432 * distributed under the License is distributed on an "AS IS" BASIS,
2433 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2434 * See the License for the specific language governing permissions and
2435 * limitations under the License.
2436 */async function Jt(n,e,t=!1){if(t)return e;try{return await e}catch(r){throw r instanceof Ze&&Uy(r)&&n.auth.currentUser===n&&await n.auth.signOut(),r}}function Uy({code:n}){return n==="auth/user-disabled"||n==="auth/user-token-expired"}/**
2437 * @license
2438 * Copyright 2020 Google LLC
2439 *
2440 * Licensed under the Apache License, Version 2.0 (the "License");
2441 * you may not use this file except in compliance with the License.
2442 * You may obtain a copy of the License at
2443 *
2444 *   http://www.apache.org/licenses/LICENSE-2.0
2445 *
2446 * Unless required by applicable law or agreed to in writing, software
2447 * distributed under the License is distributed on an "AS IS" BASIS,
2448 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2449 * See the License for the specific language governing permissions and
2450 * limitations under the License.
2451 */class By{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,this.timerId!==null&&clearTimeout(this.timerId))}getInterval(e){if(e){const t=this.errorBackoff;return this.errorBackoff=Math.min(this.errorBackoff*2,96e4),t}else{this.errorBackoff=3e4;const r=(this.user.stsTokenManager.expirationTime??0)-Date.now()-3e5;return Math.max(0,r)}}schedule(e=!1){if(!this.isRunning)return;const t=this.getInterval(e);this.timerId=setTimeout(async()=>{await this.iteration()},t)}async iteration(){try{await this.user.getIdToken(!0)}catch(e){(e==null?void 0:e.code)==="auth/network-request-failed"&&this.schedule(!0);return}this.schedule()}}/**
2452 * @license
2453 * Copyright 2020 Google LLC
2454 *
2455 * Licensed under the Apache License, Version 2.0 (the "License");
2456 * you may not use this file except in compliance with the License.
2457 * You may obtain a copy of the License at
2458 *
2459 *   http://www.apache.org/licenses/LICENSE-2.0
2460 *
2461 * Unless required by applicable law or agreed to in writing, software
2462 * distributed under the License is distributed on an "AS IS" BASIS,
2463 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2464 * See the License for the specific language governing permissions and
2465 * limitations under the License.
2466 */class po{constructor(e,t){this.createdAt=e,this.lastLoginAt=t,this._initializeTime()}_initializeTime(){this.lastSignInTime=or(this.lastLoginAt),this.creationTime=or(this.createdAt)}_copy(e){this.createdAt=e.createdAt,this.lastLoginAt=e.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}/**
2467 * @license
2468 * Copyright 2019 Google LLC
2469 *
2470 * Licensed under the Apache License, Version 2.0 (the "License");
2471 * you may not use this file except in compliance with the License.
2472 * You may obtain a copy of the License at
2473 *
2474 *   http://www.apache.org/licenses/LICENSE-2.0
2475 *
2476 * Unless required by applicable law or agreed to in writing, software
2477 * distributed under the License is distributed on an "AS IS" BASIS,
2478 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2479 * See the License for the specific language governing permissions and
2480 * limitations under the License.
2481 */async function ks(n){var _;const e=n.auth,t=await n.getIdToken(),r=await Jt(n,bs(e,{idToken:t}));M(r==null?void 0:r.users.length,e,"internal-error");const s=r.users[0];n._notifyReloadListener(s);const o=(_=s.providerUserInfo)!=null&&_.length?Xh(s.providerUserInfo):[],a=jy(n.providerData,o),u=n.isAnonymous,h=!(n.email&&s.passwordHash)&&!(a!=null&&a.length),d=u?h:!1,p={uid:s.localId,displayName:s.displayName||null,photoURL:s.photoUrl||null,email:s.email||null,emailVerified:s.emailVerified||!1,phoneNumber:s.phoneNumber||null,tenantId:s.tenantId||null,providerData:a,metadata:new po(s.createdAt,s.lastLoginAt),isAnonymous:d};Object.assign(n,p)}async function qy(n){const e=G(n);await ks(e),await e.auth._persistUserIfCurrent(e),e.auth._notifyListenersIfCurrent(e)}function jy(n,e){return[...n.filter(r=>!e.some(s=>s.providerId===r.providerId)),...e]}function Xh(n){return n.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}))}/**
2482 * @license
2483 * Copyright 2020 Google LLC
2484 *
2485 * Licensed under the Apache License, Version 2.0 (the "License");
2486 * you may not use this file except in compliance with the License.
2487 * You may obtain a copy of the License at
2488 *
2489 *   http://www.apache.org/licenses/LICENSE-2.0
2490 *
2491 * Unless required by applicable law or agreed to in writing, software
2492 * distributed under the License is distributed on an "AS IS" BASIS,
2493 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2494 * See the License for the specific language governing permissions and
2495 * limitations under the License.
2496 */async function $y(n,e){const t=await Jh(n,{},async()=>{const r=Er({grant_type:"refresh_token",refresh_token:e}).slice(1),{tokenApiHost:s,apiKey:o}=n.config,a=await Yh(n,s,"/v1/token",`key=${o}`),u=await n._getAdditionalHeaders();u["Content-Type"]="application/x-www-form-urlencoded";const h={method:"POST",headers:u,body:r};return n.emulatorConfig&&Yt(n.emulatorConfig.host)&&(h.credentials="include"),Qh.fetch()(a,h)});return{accessToken:t.access_token,expiresIn:t.expires_in,refreshToken:t.refresh_token}}async function zy(n,e){return xe(n,"POST","/v2/accounts:revokeToken",je(n,e))}/**
2497 * @license
2498 * Copyright 2020 Google LLC
2499 *
2500 * Licensed under the Apache License, Version 2.0 (the "License");
2501 * you may not use this file except in compliance with the License.
2502 * You may obtain a copy of the License at
2503 *
2504 *   http://www.apache.org/licenses/LICENSE-2.0
2505 *
2506 * Unless required by applicable law or agreed to in writing, software
2507 * distributed under the License is distributed on an "AS IS" BASIS,
2508 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2509 * See the License for the specific language governing permissions and
2510 * limitations under the License.
2511 */class fn{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(typeof e.idToken<"u","internal-error"),M(typeof e.refreshToken<"u","internal-error");const t="expiresIn"in e&&typeof e.expiresIn<"u"?Number(e.expiresIn):Uu(e.idToken);this.updateTokensAndExpiration(e.idToken,e.refreshToken,t)}updateFromIdToken(e){M(e.length!==0,"internal-error");const t=Uu(e);this.updateTokensAndExpiration(e,null,t)}async getToken(e,t=!1){return!t&&this.accessToken&&!this.isExpired?this.accessToken:(M(this.refreshToken,e,"user-token-expired"),this.refreshToken?(await this.refresh(e,this.refreshToken),this.accessToken):null)}clearRefreshToken(){this.refreshToken=null}async refresh(e,t){const{accessToken:r,refreshToken:s,expiresIn:o}=await $y(e,t);this.updateTokensAndExpiration(r,s,Number(o))}updateTokensAndExpiration(e,t,r){this.refreshToken=t||null,this.accessToken=e||null,this.expirationTime=Date.now()+r*1e3}static fromJSON(e,t){const{refreshToken:r,accessToken:s,expirationTime:o}=t,a=new fn;return r&&(M(typeof r=="string","internal-error",{appName:e}),a.refreshToken=r),s&&(M(typeof s=="string","internal-error",{appName:e}),a.accessToken=s),o&&(M(typeof o=="number","internal-error",{appName:e}),a.expirationTime=o),a}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 fn,this.toJSON())}_performRefresh(){return it("not implemented")}}/**
2512 * @license
2513 * Copyright 2020 Google LLC
2514 *
2515 * Licensed under the Apache License, Version 2.0 (the "License");
2516 * you may not use this file except in compliance with the License.
2517 * You may obtain a copy of the License at
2518 *
2519 *   http://www.apache.org/licenses/LICENSE-2.0
2520 *
2521 * Unless required by applicable law or agreed to in writing, software
2522 * distributed under the License is distributed on an "AS IS" BASIS,
2523 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2524 * See the License for the specific language governing permissions and
2525 * limitations under the License.
2526 */function Et(n,e){M(typeof n=="string"||typeof n>"u","internal-error",{appName:e})}class Ue{constructor({uid:e,auth:t,stsTokenManager:r,...s}){this.providerId="firebase",this.proactiveRefresh=new By(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=e,this.auth=t,this.stsTokenManager=r,this.accessToken=r.accessToken,this.displayName=s.displayName||null,this.email=s.email||null,this.emailVerified=s.emailVerified||!1,this.phoneNumber=s.phoneNumber||null,this.photoURL=s.photoURL||null,this.isAnonymous=s.isAnonymous||!1,this.tenantId=s.tenantId||null,this.providerData=s.providerData?[...s.providerData]:[],this.metadata=new po(s.createdAt||void 0,s.lastLoginAt||void 0)}async getIdToken(e){const t=await Jt(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 Fy(this,e)}reload(){return qy(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(t=>({...t})),this.metadata._copy(e.metadata),this.stsTokenManager._assign(e.stsTokenManager))}_clone(e){const t=new Ue({...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 ks(this),await this.auth._persistUserIfCurrent(this),r&&this.auth._notifyListenersIfCurrent(this)}async delete(){if(pe(this.auth.app))return Promise.reject(Me(this.auth));const e=await this.getIdToken();return await Jt(this,xy(this.auth,{idToken:e})),this.stsTokenManager.clearRefreshToken(),this.auth.signOut()}toJSON(){return{uid:this.uid,email:this.email||void 0,emailVerified:this.emailVerified,displayName:this.displayName||void 0,isAnonymous:this.isAnonymous,photoURL:this.photoURL||void 0,phoneNumber:this.phoneNumber||void 0,tenantId:this.tenantId||void 0,providerData:this.providerData.map(e=>({...e})),stsTokenManager:this.stsTokenManager.toJSON(),_redirectEventId:this._redirectEventId,...this.metadata.toJSON(),apiKey:this.auth.config.apiKey,appName:this.auth.name}}get refreshToken(){return this.stsTokenManager.refreshToken||""}static _fromJSON(e,t){const r=t.displayName??void 0,s=t.email??void 0,o=t.phoneNumber??void 0,a=t.photoURL??void 0,u=t.tenantId??void 0,h=t._redirectEventId??void 0,d=t.createdAt??void 0,p=t.lastLoginAt??void 0,{uid:_,emailVerified:E,isAnonymous:S,providerData:b,stsTokenManager:D}=t;M(_&&D,e,"internal-error");const N=fn.fromJSON(this.name,D);M(typeof _=="string",e,"internal-error"),Et(r,e.name),Et(s,e.name),M(typeof E=="boolean",e,"internal-error"),M(typeof S=="boolean",e,"internal-error"),Et(o,e.name),Et(a,e.name),Et(u,e.name),Et(h,e.name),Et(d,e.name),Et(p,e.name);const q=new Ue({uid:_,auth:e,email:s,emailVerified:E,displayName:r,isAnonymous:S,photoURL:a,phoneNumber:o,tenantId:u,stsTokenManager:N,createdAt:d,lastLoginAt:p});return b&&Array.isArray(b)&&(q.providerData=b.map(B=>({...B}))),h&&(q._redirectEventId=h),q}static async _fromIdTokenResponse(e,t,r=!1){const s=new fn;s.updateFromServerResponse(t);const o=new Ue({uid:t.localId,auth:e,stsTokenManager:s,isAnonymous:r});return await ks(o),o}static async _fromGetAccountInfoResponse(e,t,r){const s=t.users[0];M(s.localId!==void 0,"internal-error");const o=s.providerUserInfo!==void 0?Xh(s.providerUserInfo):[],a=!(s.email&&s.passwordHash)&&!(o!=null&&o.length),u=new fn;u.updateFromIdToken(r);const h=new Ue({uid:s.localId,auth:e,stsTokenManager:u,isAnonymous:a}),d={uid:s.localId,displayName:s.displayName||null,photoURL:s.photoUrl||null,email:s.email||null,emailVerified:s.emailVerified||!1,phoneNumber:s.phoneNumber||null,tenantId:s.tenantId||null,providerData:o,metadata:new po(s.createdAt,s.lastLoginAt),isAnonymous:!(s.email&&s.passwordHash)&&!(o!=null&&o.length)};return Object.assign(h,d),h}}/**
2527 * @license
2528 * Copyright 2020 Google LLC
2529 *
2530 * Licensed under the Apache License, Version 2.0 (the "License");
2531 * you may not use this file except in compliance with the License.
2532 * You may obtain a copy of the License at
2533 *
2534 *   http://www.apache.org/licenses/LICENSE-2.0
2535 *
2536 * Unless required by applicable law or agreed to in writing, software
2537 * distributed under the License is distributed on an "AS IS" BASIS,
2538 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2539 * See the License for the specific language governing permissions and
2540 * limitations under the License.
2541 */const Bu=new Map;function ot(n){ft(n instanceof Function,"Expected a class definition");let e=Bu.get(n);return e?(ft(e instanceof n,"Instance stored in cache mismatched with class"),e):(e=new n,Bu.set(n,e),e)}/**
2542 * @license
2543 * Copyright 2019 Google LLC
2544 *
2545 * Licensed under the Apache License, Version 2.0 (the "License");
2546 * you may not use this file except in compliance with the License.
2547 * You may obtain a copy of the License at
2548 *
2549 *   http://www.apache.org/licenses/LICENSE-2.0
2550 *
2551 * Unless required by applicable law or agreed to in writing, software
2552 * distributed under the License is distributed on an "AS IS" BASIS,
2553 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2554 * See the License for the specific language governing permissions and
2555 * limitations under the License.
2556 */class Zh{constructor(){this.type="NONE",this.storage={}}async _isAvailable(){return!0}async _set(e,t){this.storage[e]=t}async _get(e){const t=this.storage[e];return t===void 0?null:t}async _remove(e){delete this.storage[e]}_addListener(e,t){}_removeListener(e,t){}}Zh.type="NONE";const qu=Zh;/**
2557 * @license
2558 * Copyright 2019 Google LLC
2559 *
2560 * Licensed under the Apache License, Version 2.0 (the "License");
2561 * you may not use this file except in compliance with the License.
2562 * You may obtain a copy of the License at
2563 *
2564 *   http://www.apache.org/licenses/LICENSE-2.0
2565 *
2566 * Unless required by applicable law or agreed to in writing, software
2567 * distributed under the License is distributed on an "AS IS" BASIS,
2568 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2569 * See the License for the specific language governing permissions and
2570 * limitations under the License.
2571 */function us(n,e,t){return`firebase:${n}:${e}:${t}`}class pn{constructor(e,t,r){this.persistence=e,this.auth=t,this.userKey=r;const{config:s,name:o}=this.auth;this.fullUserKey=us(this.userKey,s.apiKey,o),this.fullPersistenceKey=us("persistence",s.apiKey,o),this.boundEventHandler=t._onStorageEvent.bind(t),this.persistence._addListener(this.fullUserKey,this.boundEventHandler)}setCurrentUser(e){return this.persistence._set(this.fullUserKey,e.toJSON())}async getCurrentUser(){const e=await this.persistence._get(this.fullUserKey);if(!e)return null;if(typeof e=="string"){const t=await bs(this.auth,{idToken:e}).catch(()=>{});return t?Ue._fromGetAccountInfoResponse(this.auth,t,e):null}return Ue._fromJSON(this.auth,e)}removeCurrentUser(){return this.persistence._remove(this.fullUserKey)}savePersistenceForRedirect(){return this.persistence._set(this.fullPersistenceKey,this.persistence.type)}async setPersistence(e){if(this.persistence===e)return;const t=await this.getCurrentUser();if(await this.removeCurrentUser(),this.persistence=e,t)return this.setCurrentUser(t)}delete(){this.persistence._removeListener(this.fullUserKey,this.boundEventHandler)}static async create(e,t,r="authUser"){if(!t.length)return new pn(ot(qu),e,r);const s=(await Promise.all(t.map(async d=>{if(await d._isAvailable())return d}))).filter(d=>d);let o=s[0]||ot(qu);const a=us(r,e.config.apiKey,e.name);let u=null;for(const d of t)try{const p=await d._get(a);if(p){let _;if(typeof p=="string"){const E=await bs(e,{idToken:p}).catch(()=>{});if(!E)break;_=await Ue._fromGetAccountInfoResponse(e,E,p)}else _=Ue._fromJSON(e,p);d!==o&&(u=_),o=d;break}}catch{}const h=s.filter(d=>d._shouldAllowMigration);return!o._shouldAllowMigration||!h.length?new pn(o,e,r):(o=h[0],u&&await o._set(a,u.toJSON()),await Promise.all(t.map(async d=>{if(d!==o)try{await d._remove(a)}catch{}})),new pn(o,e,r))}}/**
2572 * @license
2573 * Copyright 2020 Google LLC
2574 *
2575 * Licensed under the Apache License, Version 2.0 (the "License");
2576 * you may not use this file except in compliance with the License.
2577 * You may obtain a copy of the License at
2578 *
2579 *   http://www.apache.org/licenses/LICENSE-2.0
2580 *
2581 * Unless required by applicable law or agreed to in writing, software
2582 * distributed under the License is distributed on an "AS IS" BASIS,
2583 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2584 * See the License for the specific language governing permissions and
2585 * limitations under the License.
2586 */function ju(n){const e=n.toLowerCase();if(e.includes("opera/")||e.includes("opr/")||e.includes("opios/"))return"Opera";if(rd(e))return"IEMobile";if(e.includes("msie")||e.includes("trident/"))return"IE";if(e.includes("edge/"))return"Edge";if(ed(e))return"Firefox";if(e.includes("silk/"))return"Silk";if(id(e))return"Blackberry";if(od(e))return"Webos";if(td(e))return"Safari";if((e.includes("chrome/")||nd(e))&&!e.includes("edge/"))return"Chrome";if(sd(e))return"Android";{const t=/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/,r=n.match(t);if((r==null?void 0:r.length)===2)return r[1]}return"Other"}function ed(n=ve()){return/firefox\//i.test(n)}function td(n=ve()){const e=n.toLowerCase();return e.includes("safari/")&&!e.includes("chrome/")&&!e.includes("crios/")&&!e.includes("android")}function nd(n=ve()){return/crios\//i.test(n)}function rd(n=ve()){return/iemobile/i.test(n)}function sd(n=ve()){return/android/i.test(n)}function id(n=ve()){return/blackberry/i.test(n)}function od(n=ve()){return/webos/i.test(n)}function ma(n=ve()){return/iphone|ipad|ipod/i.test(n)||/macintosh/i.test(n)&&/mobile/i.test(n)}function Hy(n=ve()){var e;return ma(n)&&!!((e=window.navigator)!=null&&e.standalone)}function Wy(){return Cf()&&document.documentMode===10}function ad(n=ve()){return ma(n)||sd(n)||od(n)||id(n)||/windows phone/i.test(n)||rd(n)}/**
2587 * @license
2588 * Copyright 2020 Google LLC
2589 *
2590 * Licensed under the Apache License, Version 2.0 (the "License");
2591 * you may not use this file except in compliance with the License.
2592 * You may obtain a copy of the License at
2593 *
2594 *   http://www.apache.org/licenses/LICENSE-2.0
2595 *
2596 * Unless required by applicable law or agreed to in writing, software
2597 * distributed under the License is distributed on an "AS IS" BASIS,
2598 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2599 * See the License for the specific language governing permissions and
2600 * limitations under the License.
2601 */function cd(n,e=[]){let t;switch(n){case"Browser":t=ju(ve());break;case"Worker":t=`${ju(ve())}-${n}`;break;default:t=n}const r=e.length?e.join(","):"FirebaseCore-web";return`${t}/JsCore/${vn}/${r}`}/**
2602 * @license
2603 * Copyright 2022 Google LLC
2604 *
2605 * Licensed under the Apache License, Version 2.0 (the "License");
2606 * you may not use this file except in compliance with the License.
2607 * You may obtain a copy of the License at
2608 *
2609 *   http://www.apache.org/licenses/LICENSE-2.0
2610 *
2611 * Unless required by applicable law or agreed to in writing, software
2612 * distributed under the License is distributed on an "AS IS" BASIS,
2613 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2614 * See the License for the specific language governing permissions and
2615 * limitations under the License.
2616 */class Gy{constructor(e){this.auth=e,this.queue=[]}pushCallback(e,t){const r=o=>new Promise((a,u)=>{try{const h=e(o);a(h)}catch(h){u(h)}});r.onAbort=t,this.queue.push(r);const s=this.queue.length-1;return()=>{this.queue[s]=()=>Promise.resolve()}}async runMiddleware(e){if(this.auth.currentUser===e)return;const t=[];try{for(const r of this.queue)await r(e),r.onAbort&&t.push(r.onAbort)}catch(r){t.reverse();for(const s of t)try{s()}catch{}throw this.auth._errorFactory.create("login-blocked",{originalMessage:r==null?void 0:r.message})}}}/**
2617 * @license
2618 * Copyright 2023 Google LLC
2619 *
2620 * Licensed under the Apache License, Version 2.0 (the "License");
2621 * you may not use this file except in compliance with the License.
2622 * You may obtain a copy of the License at
2623 *
2624 *   http://www.apache.org/licenses/LICENSE-2.0
2625 *
2626 * Unless required by applicable law or agreed to in writing, softw
2626are
2627 * distributed under the License is distributed on an "AS IS" BASIS,
2628 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2629 * See the License for the specific language governing permissions and
2630 * limitations under the License.
2631 */async function Ky(n,e={}){return xe(n,"GET","/v2/passwordPolicy",je(n,e))}/**
2632 * @license
2633 * Copyright 2023 Google LLC
2634 *
2635 * Licensed under the Apache License, Version 2.0 (the "License");
2636 * you may not use this file except in compliance with the License.
2637 * You may obtain a copy of the License at
2638 *
2639 *   http://www.apache.org/licenses/LICENSE-2.0
2640 *
2641 * Unless required by applicable law or agreed to in writing, software
2642 * distributed under the License is distributed on an "AS IS" BASIS,
2643 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2644 * See the License for the specific language governing permissions and
2645 * limitations under the License.
2646 */const Qy=6;class Jy{constructor(e){var r;const t=e.customStrengthOptions;this.customStrengthOptions={},this.customStrengthOptions.minPasswordLength=t.minPasswordLength??Qy,t.maxPasswordLength&&(this.customStrengthOptions.maxPasswordLength=t.maxPasswordLength),t.containsLowercaseCharacter!==void 0&&(this.customStrengthOptions.containsLowercaseLetter=t.containsLowercaseCharacter),t.containsUppercaseCharacter!==void 0&&(this.customStrengthOptions.containsUppercaseLetter=t.containsUppercaseCharacter),t.containsNumericCharacter!==void 0&&(this.customStrengthOptions.containsNumericCharacter=t.containsNumericCharacter),t.containsNonAlphanumericCharacter!==void 0&&(this.customStrengthOptions.containsNonAlphanumericCharacter=t.containsNonAlphanumericCharacter),this.enforcementState=e.enforcementState,this.enforcementState==="ENFORCEMENT_STATE_UNSPECIFIED"&&(this.enforcementState="OFF"),this.allowedNonAlphanumericCharacters=((r=e.allowedNonAlphanumericCharacters)==null?void 0:r.join(""))??"",this.forceUpgradeOnSignin=e.forceUpgradeOnSignin??!1,this.schemaVersion=e.schemaVersion}validatePassword(e){const t={isValid:!0,passwordPolicy:this};return this.validatePasswordLengthOptions(e,t),this.validatePasswordCharacterOptions(e,t),t.isValid&&(t.isValid=t.meetsMinPasswordLength??!0),t.isValid&&(t.isValid=t.meetsMaxPasswordLength??!0),t.isValid&&(t.isValid=t.containsLowercaseLetter??!0),t.isValid&&(t.isValid=t.containsUppercaseLetter??!0),t.isValid&&(t.isValid=t.containsNumericCharacter??!0),t.isValid&&(t.isValid=t.containsNonAlphanumericCharacter??!0),t}validatePasswordLengthOptions(e,t){const r=this.customStrengthOptions.minPasswordLength,s=this.customStrengthOptions.maxPasswordLength;r&&(t.meetsMinPasswordLength=e.length>=r),s&&(t.meetsMaxPasswordLength=e.length<=s)}validatePasswordCharacterOptions(e,t){this.updatePasswordCharacterOptionsStatuses(t,!1,!1,!1,!1);let r;for(let s=0;s<e.length;s++)r=e.charAt(s),this.updatePasswordCharacterOptionsStatuses(t,r>="a"&&r<="z",r>="A"&&r<="Z",r>="0"&&r<="9",this.allowedNonAlphanumericCharacters.includes(r))}updatePasswordCharacterOptionsStatuses(e,t,r,s,o){this.customStrengthOptions.containsLowercaseLetter&&(e.containsLowercaseLetter||(e.containsLowercaseLetter=t)),this.customStrengthOptions.containsUppercaseLetter&&(e.containsUppercaseLetter||(e.containsUppercaseLetter=r)),this.customStrengthOptions.containsNumericCharacter&&(e.containsNumericCharacter||(e.containsNumericCharacter=s)),this.customStrengthOptions.containsNonAlphanumericCharacter&&(e.containsNonAlphanumericCharacter||(e.containsNonAlphanumericCharacter=o))}}/**
2647 * @license
2648 * Copyright 2020 Google LLC
2649 *
2650 * Licensed under the Apache License, Version 2.0 (the "License");
2651 * you may not use this file except in compliance with the License.
2652 * You may obtain a copy of the License at
2653 *
2654 *   http://www.apache.org/licenses/LICENSE-2.0
2655 *
2656 * Unless required by applicable law or agreed to in writing, software
2657 * distributed under the License is distributed on an "AS IS" BASIS,
2658 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2659 * See the License for the specific language governing permissions and
2660 * limitations under the License.
2661 */class Yy{constructor(e,t,r,s){this.app=e,this.heartbeatServiceProvider=t,this.appCheckServiceProvider=r,this.config=s,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new $u(this),this.idTokenSubscription=new $u(this),this.beforeStateQueue=new Gy(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=Kh,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=s.sdkClientVersion,this._persistenceManagerAvailable=new Promise(o=>this._resolvePersistenceManagerAvailable=o)}_initializeWithPersistence(e,t){return t&&(this._popupRedirectResolver=ot(t)),this._initializationPromise=this.queue(async()=>{var r,s,o;if(!this._deleted&&(this.persistenceManager=await pn.create(this,e),(r=this._resolvePersistenceManagerAvailable)==null||r.call(this),!this._deleted)){if
2661((s=this._popupRedirectResolver)!=null&&s._shouldInitProactively)try{await this._popupRedirectResolver._initialize(this)}catch{}await this.initializeCurrentUser(t),this.lastNotifiedUid=((o=this.currentUser)==null?void 0:o.uid)||null,!this._deleted&&(this._isInitialized=!0)}}),this._initializationPromise}async _onStorageEvent(){if(this._deleted)return;const e=await this.assertedPersistence.getCurrentUser();if(!(!this.currentUser&&!e)){if(this.currentUser&&e&&this.currentUser.uid===e.uid){this._currentUser._assign(e),await this.currentUser.getIdToken();return}await this._updateCurrentUser(e,!0)}}async initializeCurrentUserFromIdToken(e){try{const t=await bs(this,{idToken:e}),r=await Ue._fromGetAccountInfoResponse(this,t,e);await this.directlySetCurrentUser(r)}catch(t){console.warn("FirebaseServerApp could not login user with provided authIdToken: ",t),await this.directlySetCurrentUser(null)}}async initializeCurrentUser(e){var o;if(pe(this.app)){const a=this.app.settings.authIdToken;return a?new Promise(u=>{setTimeout(()=>this.initializeCurrentUserFromIdToken(a).then(u,u))}):this.directlySetCurrentUser(null)}const t=await this.assertedPersistence.getCurrentUser();let r=t,s=!1;if(e&&this.config.authDomain){await this.getOrInitRedirectPersistenceManager();const a=(o=this.redirectUser)==null?void 0:o._redirectEventId,u=r==null?void 0:r._redirectEventId,h=await this.tryRedirectSignIn(e);(!a||a===u)&&(h!=null&&h.user)&&(r=h.user,s=!0)}if(!r)return this.directlySetCurrentUser(null);if(!r._redirectEventId){if(s)try{await this.beforeStateQueue.runMiddleware(r)}catch(a){r=t,this._popupRedirectResolver._overrideRedirectResult(this,()=>Promise.reject(a))}return r?this.reloadAndSetCurrentUserOrClear(r):this.directlySetCurrentUser(null)}return M(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===r._redirectEventId?this.directlySetCurrentUser(r):this.reloadAndSetCurrentUserOrClear(r)}async tryRedirectSignIn(e){let t=null;try{t=await this._popupRedirectResolver._completeRedirectFn(this,e,!0)}catch{await this._setRedirectUser(null)}return t}async reloadAndSetCurrentUserOrClear(e){try{await ks(e)}catch(t){if((t==null?void 0:t.code)!=="auth/network-request-failed")return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(e)}useDeviceLanguage(){this.languageCode=by()}async _delete(){this._deleted=!0}async updateCurrentUser(e){if(pe(this.app))return Promise.reject(Me(this));const t=e?G(e):null;return t&&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 pe(this.app)?Promise.reject(Me(this)):(await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0))}setPersistence(e){return pe(this.app)?Promise.reject(Me(this)):this.queue(async()=>{await this.assertedPersistence.setPersistence(ot(e))})}_getRecaptchaConfig(){return this.tenantId==null?this._agentRecaptchaConfig:this._tenantRecaptchaConfigs[this.tenantId]}async validatePassword(e){this._getPasswordPolicyInternal()||await this._updatePasswordPolicy();const t=this._getPasswordPolicyInternal();return t.schemaVersion!==this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION?Promise.reject(this._errorFactory.create("unsupported-password-policy-schema-version",{})):t.validatePassword(e)}_getPasswordPolicyInternal(){return this.tenantId===null?this._projectPasswordPolicy:this._tenantPasswordPolicies[this.tenantId]}async _updatePasswordPolicy(){const e=await Ky(this),t=new Jy(e);this.tenantId===null?this._projectPasswordPolicy=t:this._tenantPasswordPolicies[this.tenantId]=t}_getPersistenceType(){return this.assertedPersistence.persistence.type}_getPersistence(){return this.assertedPersistence.persistence}_updateErrorMap(e){this._errorFactory=new yr("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((e,t)=>
2661{if(this.currentUser)e();else{const r=this.onAuthStateChanged(()=>{r(),e()},t)}})}async revokeAccessToken(e){if(this.currentUser){const t=await this.currentUser.getIdToken(),r={providerId:"apple.com",tokenType:"ACCESS_TOKEN",token:e,idToken:t};this.tenantId!=null&&(r.tenantId=this.tenantId),await zy(this,r)}}toJSON(){var e;return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:(e=this._currentUser)==null?void 0:e.toJSON()}}async _setRedirectUser(e,t){const r=await this.getOrInitRedirectPersistenceManager(t);return e===null?r.removeCurrentUser():r.setCurrentUser(e)}async getOrInitRedirectPersistenceManager(e){if(!this.redirectPersistenceManager){const t=e&&ot(e)||this._popupRedirectResolver;M(t,this,"argument-error"),this.redirectPersistenceManager=await pn.create(this,[ot(t._redirectPersistence)],"redirectUser"),this.redirectUser=await this.redirectPersistenceManager.getCurrentUser()}return this.redirectPersistenceManager}async _redirectUserForId(e){var t,r;return this._isInitialized&&await this.queue(async()=>{}),((t=this._currentUser)==null?void 0:t._redirectEventId)===e?this._currentUser:((r=this.redirectUser)==null?void 0:r._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 t;if(!this._isInitialized)return;this.idTokenSubscription.next(this.currentUser);const e=((t=this.currentUser)==null?void 0:t.uid)??null;this.lastNotifiedUid!==e&&(this.lastNotifiedUid=e,this.authStateSubscription.next(this.currentUser))}registerStateListener(e,t,r,s){if(this._deleted)return()=>{};const o=typeof t=="function"?t:t.next.bind(t);let a=!1;const u=this._isInitialized?Promise.resolve():this._initializationPromise;if(M(u,this,"internal-error"),u.then(()=>{a||o(this.currentUser)}),typeof t=="function"){const h=e.addObserver(t,r,s);return()=>{a=!0,h()}}else{const h=e.addObserver(t);return()=>{a=!0,h()}}}async directlySetCurrentUser(e){this.currentUser&&this.currentUser!==e&&this._currentUser._stopProactiveRefresh(),e&&this.isProactiveRefreshEnabled&&e._startProactiveRefresh(),this.currentUser=e,e?await this.assertedPersistence.setCurrentUser(e):await this.assertedPersistence.removeCurrentUser()}queue(e){return this.operations=this.operations.then(e,e),this.operations}get assertedPersistence(){return M(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(e){!e||this.frameworks.includes(e)||(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=cd(this.config.clientPlatform,this._getFrameworks()))}_getFrameworks(){return this.frameworks}async _getAdditionalHeaders(){var s;const e={"X-Client-Version":this.clientVersion};this.app.options.appId&&(e["X-Firebase-gmpid"]=this.app.options.appId);const t=await((s=this.heartbeatServiceProvider.getImmediate({optional:!0}))==null?void 0:s.getHeartbeatsHeader());t&&(e["X-Firebase-Client"]=t);const r=await this._getAppCheckToken();return r&&(e["X-Firebase-AppCheck"]=r),e}async _getAppCheckToken(){var t;if(pe(this.app)&&this.app.settings.appCheckToken)return this.app.settings.appCheckToken;const e=await((t=this.appCheckServiceProvider.getImmediate({optional:!0}))==null?void 0:t.getToken());return e!=null&&e.error&&Ry(`Error while retrieving App Check token: ${e.error}`),e==null?void 0:e.token}}function $e(n){return G(n)}class $u{constructor(e){this.auth=e,this.observer=null,this.addObserver=Lf(t=>this.observer=t)}get next(){return M(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}/**
2662 * @license
2663 * Copyright 2020 Google LLC
2664 *
2665 * Licensed under the Apache License, Version 2.0 (the "License");
2666 * you may not use this file except in compliance with the License.
2667 * You may obtain a copy of the License at
2668 *
2669 *   http://www.apache.org/licenses/LICENSE-2.0
2670 *
2671 * Unless required by applicable law or agreed to in writing, software
2672 * distributed under the License is distributed on an "AS IS" BASIS,
2673 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2674 * See the License for the specific language governing permissions and
2675 * limitations under the License.
2676 */let ti={async loadJS(){throw new Error("Unable to load external scripts")},recaptchaV2Script:"",recaptchaEnterpriseScript:"",gapiScript:""};function Xy(n){ti=n}function ud(n){return ti.loadJS(n)}function Zy(){return ti.recaptchaEnterpriseScript}function eE(){return ti.gapiScript}function tE(n){return`__${n}${Math.floor(Math.random()*1e6)}`}class nE{constructor(){this.enterprise=new rE}ready(e){e()}execute(e,t){return Promise.resolve("token")}render(e,t){return""}}class rE{ready(e){e()}execute(e,t){return Promise.resolve("token")}render(e,t){return""}}const sE="recaptcha-enterprise",ld="NO_RECAPTCHA";class iE{constructor(e){this.type=sE,this.auth=$e(e)}async verify(e="verify",t=!1){async function r(o){if(!t){if(o.tenantId==null&&o._agentRecaptchaConfig!=null)return o._agentRecaptchaConfig.siteKey;if(o.tenantId!=null&&o._tenantRecaptchaConfigs[o.tenantId]!==void 0)return o._tenantRecaptchaConfigs[o.tenantId].siteKey}return new Promise(async(a,u)=>{Ly(o,{clientType:"CLIENT_TYPE_WEB",version:"RECAPTCHA_ENTERPRISE"}).then(h=>{if(h.recaptchaKey===void 0)u(new Error("recaptcha Enterprise site key undefined"));else{const d=new My(h);return o.tenantId==null?o._agentRecaptchaConfig=d:o._tenantRecaptchaConfigs[o.tenantId]=d,a(d.siteKey)}}).catch(h=>{u(h)})})}function s(o,a,u){const h=window.grecaptcha;Fu(h)?h.enterprise.ready(()=>{h.enterprise.execute(o,{action:e}).then(d=>{a(d)}).catch(()=>{a(ld)})}):u(Error("No reCAPTCHA enterprise script loaded."))}return this.auth.settings.appVerificationDisabledForTesting?new nE().execute("siteKey",{action:"verify"}):new Promise((o,a)=>{r(this.auth).then(u=>{if(!t&&Fu(window.grecaptcha))s(u,o,a);else{if(typeof window>"u"){a(new Error("RecaptchaVerifier is only supported in browser"));return}let h=Zy();h.length!==0&&(h+=u),ud(h).then(()=>{s(u,o,a)}).catch(d=>{a(d)})}}).catch(u=>{a(u)})})}}async function zu(n,e,t,r=!1,s=!1){const o=new iE(n);let a;if(s)a=ld;else try{a=await o.verify(t)}catch{a=await o.verify(t,!0)}const u={...e};if(t==="mfaSmsEnrollment"||t==="mfaSmsSignIn"){if("phoneEnrollmentInfo"in u){const h=u.phoneEnrollmentInfo.phoneNumber,d=u.phoneEnrollmentInfo.recaptchaToken;Object.assign(u,{phoneEnrollmentInfo:{phoneNumber:h,recaptchaToken:d,captchaResponse:a,clientType:"CLIENT_TYPE_WEB",recaptchaVersion:"RECAPTCHA_ENTERPRISE"}})}else if("phoneSignInInfo"in u){const h=u.phoneSignInInfo.recaptchaToken;Object.assign(u,{phoneSignInInfo:{recaptchaToken:h,captchaResponse:a,clientType:"CLIENT_TYPE_WEB",recaptchaVersion:"RECAPTCHA_ENTERPRISE"}})}return u}return r?Object.assign(u,{captchaResp:a}):Object.assign(u,{captchaResponse:a}),Object.assign(u,{clientType:"CLIENT_TYPE_WEB"}),Object.assign(u,{recaptchaVersion:"RECAPTCHA_ENTERPRISE"}),u}async function mo(n,e,t,r,s){var o;if((o=n._getRecaptchaConfig())!=null&&o.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")){const a=await zu(n,e,t,t==="getOobCode");return r(n,a)}else return r(n,e).catch(async a=>{if(a.code==="auth/missing-recaptcha-token"){console.log(`${t} is protected by reCAPTCHA Enterprise for this project. Automatically triggering the reCAPTCHA flow and restarting the flow.`);const u=await zu(n,e,t,t==="getOobCode");return r(n,u)}else return Promise.reject(a)})}/**
2677 * @license
2678 * Copyright 2020 Google LLC
2679 *
2680 * Licensed under the Apache License, Version 2.0 (the "License");
2681 * you may not use this file except in compliance with the License.
2682 * You may obtain a copy of the License at
2683 *
2684 *   http://www.apache.org/licenses/LICENSE-2.0
2685 *
2686 * Unless required by applicable law or agreed to in writing, software
2687 * distributed under the License is distributed on an "AS IS" BASIS,
2688 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2689 * See the License for the specific language governing permissions and
2690 * limitations under the License.
2691 */function oE(n,e){const t=Ms(n,"auth");if(t.isInitialized()){const s=t.getImmediate(),o=t.getOptions();if(ut(o,e??{}))return s;De(s,"already-initialized")}return t.initialize({options:e})}function aE(n,e){const t=(e==null?void 0:e.persistence)||[],r=(Array.isArray(t)?t:[t]).map(ot);e!=null&&e.errorMap&&n._updateErrorMap(e.errorMap),n._initializeWithPersistence(r,e==null?void 0:e.popupRedirectResolver)}function cE(n,e,t){const r=$e(n);
2691M(/^https?:\/\//.test(e),r,"invalid-emulator-scheme");const s=!1,o=hd(e),{host:a,port:u}=uE(e),h=u===null?"":`:${u}`,d={url:`${o}//${a}${h}/`},p=Object.freeze({host:a,port:u,protocol:o.replace(":",""),options:Object.freeze({disableWarnings:s})});if(!r._canInitEmulator){M(r.config.emulator&&r.emulatorConfig,r,"emulator-config-failed"),M(ut(d,r.config.emulator)&&ut(p,r.emulatorConfig),r,"emulator-config-failed");return}r.config.emulator=d,r.emulatorConfig=p,r.settings.appVerificationDisabledForTesting=!0,Yt(a)?(yo(`${o}//${a}${h}`),cl("Auth",!0)):lE()}function hd(n){const e=n.indexOf(":");return e<0?"":n.substr(0,e+1)}function uE(n){const e=hd(n),t=/(\/\/)?([^?#/]+)/.exec(n.substr(e.length));if(!t)return{host:"",port:null};const r=t[2].split("@").pop()||"",s=/^(\[[^\]]+\])(:|$)/.exec(r);if(s){const o=s[1];return{host:o,port:Hu(r.substr(o.length+1))}}else{const[o,a]=r.split(":");return{host:o,port:Hu(a)}}}function Hu(n){if(!n)return null;const e=Number(n);return isNaN(e)?null:e}function lE(){function n(){const e=document.createElement("p"),t=e.style;e.innerText="Running in emulator mode. Do not use with production credentials.",t.position="fixed",t.width="100%",t.backgroundColor="#ffffff",t.border=".1em solid #000000",t.color="#b50000",t.bottom="0px",t.left="0px",t.margin="0px",t.zIndex="10000",t.textAlign="center",e.classList.add("firebase-emulator-warning"),document.body.appendChild(e)}typeof console<"u"&&typeof console.info=="function"&&console.info("WARNING: You are using the Auth Emulator, which is intended for local testing only.  Do not use with production credentials."),typeof window<"u"&&typeof document<"u"&&(document.readyState==="loading"?window.addEventListener("DOMContentLoaded",n):n())}/**
2692 * @license
2693 * Copyright 2020 Google LLC
2694 *
2695 * Licensed under the Apache License, Version 2.0 (the "License");
2696 * you may not use this file except in compliance with the License.
2697 * You may obtain a copy of the License at
2698 *
2699 *   http://www.apache.org/licenses/LICENSE-2.0
2700 *
2701 * Unless required by applicable law or agreed to in writing, software
2702 * distributed under the License is distributed on an "AS IS" BASIS,
2703 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2704 * See the License for the specific language governing permissions and
2705 * limitations under the License.
2706 */class ni{constructor(e,t){this.providerId=e,this.signInMethod=t}toJSON(){return it("not implemented")}_getIdTokenResponse(e){return it("not implemented")}_linkToIdToken(e,t){return it("not implemented")}_getReauthenticationResolver(e){return it("not implemented")}}/**
2707 * @license
2708 * Copyright 2020 Google LLC
2709 *
2710 * Licensed under the Apache License, Version 2.0 (the "License");
2711 * you may not use this file except in compliance with the License.
2712 * You may obtain a copy of the License at
2713 *
2714 *   http://www.apache.org/licenses/LICENSE-2.0
2715 *
2716 * Unless required by applicable law or agreed to in writing, software
2717 * distributed under the License is distributed on an "AS IS" BASIS,
2718 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2719 * See the License for the specific language governing permissions and
2720 * limitations under the License.
2721 */async function dd(n,e){return xe(n,"POST","/v1/accounts:resetPassword",je(n,e))}async function hE(n,e){return xe(n,"POST","/v1/accounts:update",e)}async function dE(n,e){return xe(n,"POST","/v1/accounts:signUp",e)}async function fE(n,e){return xe(n,"POST","/v1/accounts:update",je(n,e))}/**
2722 * @license
2723 * Copyright 2020 Google LLC
2724 *
2725 * Licensed under the Apache License, Version 2.0 (the "License");
2726 * you may not use this file except in compliance with the License.
2727 * You may obtain a copy of the License at
2728 *
2729 *   http://www.apache.org/licenses/LICENSE-2.0
2730 *
2731 * Unless required by applicable law or agreed to in writing, software
2732 * distributed under the License is distributed on an "AS IS" BASIS,
2733 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2734 * See the License for the specific language governing permissions and
2735 * limitations under the License.
2736 */async function pE(n,e){return bn(n,"POST","/v1/accounts:signInWithPassword",je(n,e))}/**
2737 * @license
2738 * Copyright 2020 Google LLC
2739 *
2740 * Licensed under the Apache License, Version 2.0 (the "License");
2741 * you may not use this file except in compliance with the License.
2742 * You may obtain a copy of the License at
2743 *
2744 *   http://www.apache.org/licenses/LICENSE-2.0
2745 *
2746 * Unless required by applicable law or agreed to in writing, software
2747 * distributed under the License is distributed on an "AS IS" BASIS,
2748 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2749 * See the License for the specific language governing permissions and
2750 * limitations under the License.
2751 */async function mE(n,e){return bn(n,"POST","/v1/accounts:signInWithEmailLink",je(n,e))}async function gE(n,e){return bn(n,"POST","/v1/accounts:signInWithEmailLink",je(n,e))}/**
2752 * @license
2753 * Copyright 2020 Google LLC
2754 *
2755 * Licensed under the Apache License, Version 2.0 (the "License");
2756 * you may not use this file except in compliance with the License.
2757 * You may obtain a copy of the License at
2758 *
2759 *   http://www.apache.org/licenses/LICENSE-2.0
2760 *
2761 * Unless required by applicable law or agreed to in writing, software
2762 * distributed under the License is distributed on an "AS IS" BASIS,
2763 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2764 * See the License for the specific language governing permissions and
2765 * limitations under the License.
2766 */class gr extends ni{constructor(e,t,r,s=null){super("password",r),this._email=e,this._password=t,this._tenantId=s}static _fromEmailAndPassword(e,t){return new gr(e,t,"password")}static _fromEmailAndCode(e,t,r=null){return new gr(e,t,"emailLink",r)}toJSON(){return{email:this._email,password:this._password,signInMethod:this.signInMethod,tenantId:this._tenantId}}static fromJSON(e){const t=typeof e=="string"?JSON.parse(e):e;if(t!=null&&t.email&&(t!=null&&t.password)){if(t.signInMethod==="password")return this._fromEmailAndPassword(t.email,t.password);if(t.signInMethod==="emailLink")return this._fromEmailAndCode(t.email,t.password,t.tenantId)}return null}async _getIdTokenResponse(e){switch(this.signInMethod){case"password":const t={returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"};return mo(e,t,"signInWithPassword",pE);case"emailLink":return mE(e,{email:this._email,oobCode:this._password});default:De(e,"internal-error")}}async _linkToIdToken(e,t){switch(this.signInMethod){case"password":const r={idToken:t,returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"};return mo(e,r,"signUpPassword",dE);case"emailLink":return gE(e,{idToken:t,email:this._email,oobCode:this._password});default:De(e,"internal-error")}}_getReauthenticationResolver(e){return this._getIdTokenResponse(e)}}/**
2767 * @license
2768 * Copyright 2020 Google LLC
2769 *
2770 * Licensed under the Apache License, Version 2.0 (the "License");
2771 * you may not use this file except in compliance with the License.
2772 * You may obtain a copy of the License at
2773 *
2774 *   http://www.apache.org/licenses/LICENSE-2.0
2775 *
2776 * Unless required by applicable law or agreed to in writing, software
2777 * distributed under the License is distributed on an "AS IS" BASIS,
2778 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2779 * See the License for the specific language governing permissions and
2780 * limitations under the License.
2781 */async function ct(n,e){return bn(n,"POST","/v1/accounts:signInWithIdp",je(n,e))}/**
2782 * @license
2783 * Copyright 2020 Google LLC
2784 *
2785 * Licensed under the Apache License, Version 2.0 (the "License");
2786 * you may not use this file except in compliance with the License.
2787 * You may obtain a copy of the License at
2788 *
2789 *   http://www.apache.org/licenses/LICENSE-2.0
2790 *
2791 * Unless required by applicable law or agreed to in writing, software
2792 * distributed under the License is distributed on an "AS IS" BASIS,
2793 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2794 * See the License for the specific language governing permissions and
2795 * limitations under the License.
2796 */const _E="http://localhost";class pt extends ni{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(e){const t=new pt(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&&
2796(t.nonce=e.nonce),e.pendingToken&&(t.pendingToken=e.pendingToken)):e.oauthToken&&e.oauthTokenSecret?(t.accessToken=e.oauthToken,t.secret=e.oauthTokenSecret):De("argument-error"),t}toJSON(){return{idToken:this.idToken,accessToken:this.accessToken,secret:this.secret,nonce:this.nonce,pendingToken:this.pendingToken,providerId:this.providerId,signInMethod:this.signInMethod}}static fromJSON(e){const t=typeof e=="string"?JSON.parse(e):e,{providerId:r,signInMethod:s,...o}=t;if(!r||!s)return null;const a=new pt(r,s);return a.idToken=o.idToken||void 0,a.accessToken=o.accessToken||void 0,a.secret=o.secret,a.nonce=o.nonce,a.pendingToken=o.pendingToken||null,a}_getIdTokenResponse(e){const t=this.buildRequest();return ct(e,t)}_linkToIdToken(e,t){const r=this.buildRequest();return r.idToken=t,ct(e,r)}_getReauthenticationResolver(e){const t=this.buildRequest();return t.autoCreate=!1,ct(e,t)}buildRequest(){const e={requestUri:_E,returnSecureToken:!0};if(this.pendingToken)e.pendingToken=this.pendingToken;else{const t={};this.idToken&&(t.id_token=this.idToken),this.accessToken&&(t.access_token=this.accessToken),this.secret&&(t.oauth_token_secret=this.secret),t.providerId=this.providerId,this.nonce&&!this.pendingToken&&(t.nonce=this.nonce),e.postBody=Er(t)}return e}}/**
2797 * @license
2798 * Copyright 2020 Google LLC
2799 *
2800 * Licensed under the Apache License, Version 2.0 (the "License");
2801 * you may not use this file except in compliance with the License.
2802 * You may obtain a copy of the License at
2803 *
2804 *   http://www.apache.org/licenses/LICENSE-2.0
2805 *
2806 * Unless required by applicable law or agreed to in writing, software
2807 * distributed under the License is distributed on an "AS IS" BASIS,
2808 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2809 * See the License for the specific language governing permissions and
2810 * limitations under the License.
2811 */function yE(n){switch(n){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}}function EE(n){const e=Qn(Jn(n)).link,t=e?Qn(Jn(e)).deep_link_id:null,r=Qn(Jn(n)).deep_link_id;return(r?Qn(Jn(r)).link:null)||r||t||e||n}class ga{constructor(e){const t=Qn(Jn(e)),r=t.apiKey??null,s=t.oobCode??null,o=yE(t.mode??null);M(r&&s&&o,"argument-error"),this.apiKey=r,this.operation=o,this.code=s,this.continueUrl=t.continueUrl??null,this.languageCode=t.lang??null,this.tenantId=t.tenantId??null}static parseLink(e){const t=EE(e);try{return new ga(t)}catch{return null}}}/**
2812 * @license
2813 * Copyright 2020 Google LLC
2814 *
2815 * Licensed under the Apache License, Version 2.0 (the "License");
2816 * you may not use this file except in compliance with the License.
2817 * You may obtain a copy of the License at
2818 *
2819 *   http://www.apache.org/licenses/LICENSE-2.0
2820 *
2821 * Unless required by applicable law or agreed to in writing, software
2822 * distributed under the License is distributed on an "AS IS" BASIS,
2823 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2824 * See the License for the specific language governing permissions and
2825 * limitations under the License.
2826 */class kn{constructor(){this.providerId=kn.PROVIDER_ID}static credential(e,t){return gr._fromEmailAndPassword(e,t)}static credentialWithLink(e,t){const r=ga.parseLink(t);return M(r,"argument-error"),gr._fromEmailAndCode(e,r.code,r.tenantId)}}kn.PROVIDER_ID="password";kn.EMAIL_PASSWORD_SIGN_IN_METHOD="password";kn.EMAIL_LINK_SIGN_IN_METHOD="emailLink";/**
2827 * @license
2828 * Copyright 2020 Google LLC
2829 *
2830 * Licensed under the Apache License, Version 2.0 (the "License");
2831 * you may not use this file except in compliance with the License.
2832 * You may obtain a copy of the License at
2833 *
2834 *   http://www.apache.org/licenses/LICENSE-2.0
2835 *
2836 * Unless required by applicable law or agreed to in writing, software
2837 * distributed under the License is distributed on an "AS IS" BASIS,
2838 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2839 * See the License for the specific language governing permissions and
2840 * limitations under the License.
2841 */class ri{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}}/**
2842 * @license
2843 * Copyright 2019 Google LLC
2844 *
2845 * Licensed under the Apache License, Version 2.0 (the "License");
2846 * you may not use this file except in compliance with the License.
2847 * You may obtain a copy of the License at
2848 *
2849 *   http://www.apache.org/licenses/LICENSE-2.0
2850 *
2851 * Unless required by applicable law or agreed to in writing, software
2852 * distributed under the License is distributed on an "AS IS" BASIS,
2853 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2854 * See the License for the specific language governing permissions and
2855 * limitations under the License.
2856 */class Nn extends ri{constructor(){super(...arguments),this.scopes=[]}addScope(e){return this.scopes.includes(e)||this.scopes.push(e),this}getScopes(){return[...this.scopes]}}class ls extends Nn{static credentialFromJSON(e){const t=typeof e=="string"?JSON.parse(e):e;return M("providerId"in t&&"signInMethod"in t,"argument-error"),pt._fromParams(t)}credential(e){return this._credential({...e,nonce:e.rawNonce})}_credential(e){return M(e.idToken||e.accessToken,"argument-error"),pt._fromParams({...e,providerId:this.providerId,signInMethod:this.providerId})}static credentialFromResult(e){return ls.oauthCredentialFromTaggedObject(e)}static credentialFromError(e){return ls.oauthCredentialFromTaggedObject(e.customData||{})}static oauthCredentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthIdToken:t,oauthAccessToken:r,oauthTokenSecret:s,pendingToken:o,nonce:a,providerId:u}=e;if(!r&&!s&&!t&&!o||!u)return null;try{return new ls(u)._credential({idToken:t,accessToken:r,nonce:a,pendingToken:o})}catch{return null}}}/**
2857 * @license
2858 * Copyright 2020 Google LLC
2859 *
2860 * Licensed under the Apache License, Version 2.0 (the "License");
2861 * you may not use this file except in compliance with the License.
2862 * You may obtain a copy of the License at
2863 *
2864 *   http://www.apache.org/licenses/LICENSE-2.0
2865 *
2866 * Unless required by applicable law or agreed to in writing, software
2867 * distributed under the License is distributed on an "AS IS" BASIS,
2868 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2869 * See the License for the specific language governing permissions and
2870 * limitations under the License.
2871 */class Tt extends Nn{constructor(){super("facebook.com")}static credential(e){return pt._fromParams({providerId:Tt.PROVIDER_ID,signInMethod:Tt.FACEBOOK_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return Tt.credentialFromTaggedObject(e)}static credentialFromError(e){return Tt.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return Tt.credential(e.oauthAccessToken)}catch{return null}}}Tt.FACEBOOK_SIGN_IN_METHOD="facebook.com";Tt.PROVIDER_ID="facebook.com";/**
2872 * @license
2873 * Copyright 2020 Google LLC
2874 *
2875 * Licensed under the Apache License, Version 2.0 (the "License");
2876 * you may not use this file except in compliance with the License.
2877 * You may obtain a copy of the License at
2878 *
2879 *   http://www.apache.org/licenses/LICENSE-2.0
2880 *
2881 * Unless required by applicable law or agreed to in writing, software
2882 * distributed under the License is distributed on an "AS IS" BASIS,
2883 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2884 * See the License for the specific language governing permissions and
2885 * limitations under the License.
2886 */class It extends Nn{constructor(){super("google.com"),this.addScope("profile")}static credential(e,t){return pt._fromParams({providerId:It.PROVIDER_ID,signInMethod:It.GOOGLE_SIGN_IN_METHOD,idToken:e,accessToken:t})}static credentialFromResult(e){return It.credentialFromTaggedObject(e)}static credentialFromError(e){return It.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthIdToken:t,oauthAccessToken:r}=e;if(!t&&!r)return null;try{return It.credential(t,r)}catch{return null}}}It.GOOGLE_SIGN_IN_METHOD="google.com";It.PROVIDER_ID="google.com";/**
2887 * @license
2888 * Copyright 2020 Google LLC
2889 *
2890 * Licensed under the Apache License, Version 2.0 (the "License");
2891 * you may not use this file except in compliance with the License.
2892 * You may obtain a copy of the License at
2893 *
2894 *   http://www.apache.org/licenses/LICENSE-2.0
2895 *
2896 * Unless required by applicable law or agreed to in writing, softw
2896are
2897 * distributed under the License is distributed on an "AS IS" BASIS,
2898 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2899 * See the License for the specific language governing permissions and
2900 * limitations under the License.
2901 */class wt extends Nn{constructor(){super("github.com")}static credential(e){return pt._fromParams({providerId:wt.PROVIDER_ID,signInMethod:wt.GITHUB_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return wt.credentialFromTaggedObject(e)}static credentialFromError(e){return wt.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return wt.credential(e.oauthAccessToken)}catch{return null}}}wt.GITHUB_SIGN_IN_METHOD="github.com";wt.PROVIDER_ID="github.com";/**
2902 * @license
2903 * Copyright 2020 Google LLC
2904 *
2905 * Licensed under the Apache License, Version 2.0 (the "License");
2906 * you may not use this file except in compliance with the License.
2907 * You may obtain a copy of the License at
2908 *
2909 *   http://www.apache.org/licenses/LICENSE-2.0
2910 *
2911 * Unless required by applicable law or agreed to in writing, software
2912 * distributed under the License is distributed on an "AS IS" BASIS,
2913 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2914 * See the License for the specific language governing permissions and
2915 * limitations under the License.
2916 */const TE="http://localhost";class _r extends ni{constructor(e,t){super(e,e),this.pendingToken=t}_getIdTokenResponse(e){const t=this.buildRequest();return ct(e,t)}_linkToIdToken(e,t){const r=this.buildRequest();return r.idToken=t,ct(e,r)}_getReauthenticationResolver(e){const t=this.buildRequest();return t.autoCreate=!1,ct(e,t)}toJSON(){return{signInMethod:this.signInMethod,providerId:this.providerId,pendingToken:this.pendingToken}}static fromJSON(e){const t=typeof e=="string"?JSON.parse(e):e,{providerId:r,signInMethod:s,pendingToken:o}=t;return!r||!s||!o||r!==s?null:new _r(r,o)}static _create(e,t){return new _r(e,t)}buildRequest(){return{requestUri:TE,returnSecureToken:!0,pendingToken:this.pendingToken}}}/**
2917 * @license
2918 * Copyright 2020 Google LLC
2919 *
2920 * Licensed under the Apache License, Version 2.0 (the "License");
2921 * you may not use this file except in compliance with the License.
2922 * You may obtain a copy of the License at
2923 *
2924 *   http://www.apache.org/licenses/LICENSE-2.0
2925 *
2926 * Unless required by applicable law or agreed to in writing, software
2927 * distributed under the License is distributed on an "AS IS" BASIS,
2928 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2929 * See the License for the specific language governing permissions and
2930 * limitations under the License.
2931 */const IE="saml.";class go extends ri{constructor(e){M(e.startsWith(IE),"argument-error"),super(e)}static credentialFromResult(e){return go.samlCredentialFromTaggedObject(e)}static credentialFromError(e){return go.samlCredentialFromTaggedObject(e.customData||{})}static credentialFromJSON(e){const t=_r.fromJSON(e);return M(t,"argument-error"),t}static samlCredentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{pendingToken:t,providerId:r}=e;if(!t||!r)return null;try{return _r._create(r,t)}catch{return null}}}/**
2932 * @license
2933 * Copyright 2020 Google LLC
2934 *
2935 * Licensed under the Apache License, Version 2.0 (the "License");
2936 * you may not use this file except in compliance with the License.
2937 * You may obtain a copy of the License at
2938 *
2939 *   http://www.apache.org/licenses/LICENSE-2.0
2940 *
2941 * Unless required by applicable law or agreed to in writing, software
2942 * distributed under the License is distributed on an "AS IS" BASIS,
2943 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2944 * See the License for the specific language governing permissions and
2945 * limitations under the License.
2946 */class vt extends Nn{constructor(){super("twitter.com")}static credential(e,t){return pt._fromParams({providerId:vt.PROVIDER_ID,signInMethod:vt.TWITTER_SIGN_IN_METHOD,oauthToken:e,oauthTokenSecret:t})}static credentialFromResult(e){return vt.credentialFromTaggedObject(e)}static credentialFromError(e){return vt.credentialFromTaggedObject(e.customData||{})}
2946static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthAccessToken:t,oauthTokenSecret:r}=e;if(!t||!r)return null;try{return vt.credential(t,r)}catch{return null}}}vt.TWITTER_SIGN_IN_METHOD="twitter.com";vt.PROVIDER_ID="twitter.com";/**
2947 * @license
2948 * Copyright 2020 Google LLC
2949 *
2950 * Licensed under the Apache License, Version 2.0 (the "License");
2951 * you may not use this file except in compliance with the License.
2952 * You may obtain a copy of the License at
2953 *
2954 *   http://www.apache.org/licenses/LICENSE-2.0
2955 *
2956 * Unless required by applicable law or agreed to in writing, software
2957 * distributed under the License is distributed on an "AS IS" BASIS,
2958 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2959 * See the License for the specific language governing permissions and
2960 * limitations under the License.
2961 */async function fd(n,e){return bn(n,"POST","/v1/accounts:signUp",je(n,e))}/**
2962 * @license
2963 * Copyright 2020 Google LLC
2964 *
2965 * Licensed under the Apache License, Version 2.0 (the "License");
2966 * you may not use this file except in compliance with the License.
2967 * You may obtain a copy of the License at
2968 *
2969 *   http://www.apache.org/licenses/LICENSE-2.0
2970 *
2971 * Unless required by applicable law or agreed to in writing, software
2972 * distributed under the License is distributed on an "AS IS" BASIS,
2973 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2974 * See the License for the specific language governing permissions and
2975 * limitations under the License.
2976 */class Xe{constructor(e){this.user=e.user,this.providerId=e.providerId,this._tokenResponse=e._tokenResponse,this.operationType=e.operationType}static async _fromIdTokenResponse(e,t,r,s=!1){const o=await Ue._fromIdTokenResponse(e,r,s),a=Wu(r);return new Xe({user:o,providerId:a,_tokenResponse:r,operationType:t})}static async _forOperation(e,t,r){await e._updateTokensIfNecessary(r,!0);const s=Wu(r);return new Xe({user:e,providerId:s,_tokenResponse:r,operationType:t})}}function Wu(n){return n.providerId?n.providerId:"phoneNumber"in n?"phone":null}/**
2977 * @license
2978 * Copyright 2020 Google LLC
2979 *
2980 * Licensed under the Apache License, Version 2.0 (the "License");
2981 * you may not use this file except in compliance with the License.
2982 * You may obtain a copy of the License at
2983 *
2984 *   http://www.apache.org/licenses/LICENSE-2.0
2985 *
2986 * Unless required by applicable law or agreed to in writing, software
2987 * distributed under the License is distributed on an "AS IS" BASIS,
2988 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2989 * See the License for the specific language governing permissions and
2990 * limitations under the License.
2991 */async function dI(n){var s;if(pe(n.app))return Promise.reject(Me(n));const e=$e(n);if(await e._initializationPromise,(s=e.currentUser)!=null&&s.isAnonymous)return new Xe({user:e.currentUser,providerId:null,operationType:"signIn"});const t=await fd(e,{returnSecureToken:!0}),r=await Xe._fromIdTokenResponse(e,"signIn",t,!0);return await e._updateCurrentUser(r.user),r}/**
2992 * @license
2993 * Copyright 2020 Google LLC
2994 *
2995 * Licensed under the Apache License, Version 2.0 (the "License");
2996 * you may not use this file except in compliance with the License.
2997 * You may obtain a copy of the License at
2998 *
2999 *   http://www.apache.org/licenses/LICENSE-2.0
3000 *
3001 * Unless required by applicable law or agreed to in writing, software
3002 * distributed under the License is distributed on an "AS IS" BASIS,
3003 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3004 * See the License for the specific language governing permissions and
3005 * limitations under the License.
3006 */class Ns extends Ze{constructor(e,t,r,s){super(t.code,t.message),this.operationType=r,this.user=s,Object.setPrototypeOf(this,Ns.prototype),this.customData={appName:e.name,tenantId:e.tenantId??void 0,_serverResponse:t.customData._serverResponse,operationType:r}}static _fromErrorAndOperation(e,t,r,s){return new Ns(e,t,r,s)}}function pd(n,e,t,r){return(e==="reauthenticate"?t._getReauthenticationResolver(n):t._getIdTokenResponse(n)).catch(o=>
3006{throw o.code==="auth/multi-factor-auth-required"?Ns._fromErrorAndOperation(n,o,e,r):o})}async function wE(n,e,t=!1){const r=await Jt(n,e._linkToIdToken(n.auth,await n.getIdToken()),t);return Xe._forOperation(n,"link",r)}/**
3007 * @license
3008 * Copyright 2019 Google LLC
3009 *
3010 * Licensed under the Apache License, Version 2.0 (the "License");
3011 * you may not use this file except in compliance with the License.
3012 * You may obtain a copy of the License at
3013 *
3014 *   http://www.apache.org/licenses/LICENSE-2.0
3015 *
3016 * Unless required by applicable law or agreed to in writing, software
3017 * distributed under the License is distributed on an "AS IS" BASIS,
3018 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3019 * See the License for the specific language governing permissions and
3020 * limitations under the License.
3021 */async function md(n,e,t=!1){const{auth:r}=n;if(pe(r.app))return Promise.reject(Me(r));const s="reauthenticate";try{const o=await Jt(n,pd(r,s,e,n),t);M(o.idToken,r,"internal-error");const a=pa(o.idToken);M(a,r,"internal-error");const{sub:u}=a;return M(n.uid===u,r,"user-mismatch"),Xe._forOperation(n,s,o)}catch(o){throw(o==null?void 0:o.code)==="auth/user-not-found"&&De(r,"user-mismatch"),o}}/**
3022 * @license
3023 * Copyright 2020 Google LLC
3024 *
3025 * Licensed under the Apache License, Version 2.0 (the "License");
3026 * you may not use this file except in compliance with the License.
3027 * You may obtain a copy of the License at
3028 *
3029 *   http://www.apache.org/licenses/LICENSE-2.0
3030 *
3031 * Unless required by applicable law or agreed to in writing, software
3032 * distributed under the License is distributed on an "AS IS" BASIS,
3033 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3034 * See the License for the specific language governing permissions and
3035 * limitations under the License.
3036 */async function gd(n,e,t=!1){if(pe(n.app))return Promise.reject(Me(n));const r="signIn",s=await pd(n,r,e),o=await Xe._fromIdTokenResponse(n,r,s);return t||await n._updateCurrentUser(o.user),o}async function vE(n,e){return gd($e(n),e)}async function fI(n,e){return md(G(n),e)}/**
3037 * @license
3038 * Copyright 2020 Google LLC
3039 *
3040 * Licensed under the Apache License, Version 2.0 (the "License");
3041 * you may not use this file except in compliance with the License.
3042 * You may obtain a copy of the License at
3043 *
3044 *   http://www.apache.org/licenses/LICENSE-2.0
3045 *
3046 * Unless required by applicable law or agreed to in writing, software
3047 * distributed under the License is distributed on an "AS IS" BASIS,
3048 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3049 * See the License for the specific language governing permissions and
3050 * limitations under the License.
3051 */async function AE(n,e){return bn(n,"POST","/v1/accounts:signInWithCustomToken",je(n,e))}/**
3052 * @license
3053 * Copyright 2020 Google LLC
3054 *
3055 * Licensed under the Apache License, Version 2.0 (the "License");
3056 * you may not use this file except in compliance with the License.
3057 * You may obtain a copy of the License at
3058 *
3059 *   http://www.apache.org/licenses/LICENSE-2.0
3060 *
3061 * Unless required by applicable law or agreed to in writing, software
3062 * distributed under the License is distributed on an "AS IS" BASIS,
3063 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3064 * See the License for the specific language governing permissions and
3065 * limitations under the License.
3066 */async function pI(n,e){if(pe(n.app))return Promise.reject(Me(n));const t=$e(n),r=await AE(t,{token:e,returnSecureToken:!0}),s=await Xe._fromIdTokenResponse(t,"signIn",r);return await t._updateCurrentUser(s.user),s}/**
3067 * @license
3068 * Copyright 2020 Google LLC
3069 *
3070 * Licensed under the Apache License, Version 2.0 (the "License");
3071 * you may not use this file except in compliance with the License.
3072 * You may obtain a copy of the License at
3073 *
3074 *   http://www.apache.org/licenses/LICENSE-2.0
3075 *
3076 * Unless required by applicable law or agreed to in writing, software
3077 * distributed under the License is distributed on an "AS IS" BASIS,
3078 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3079 * See the License for the specific language governing permissions and
3080 * limitations under the License.
3081 */class _a{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?ya._fromServerResponse(e,t):"totpInfo"in t?Ea._fromServerResponse(e,t):De(e,"internal-error")}}class ya extends _a{constructor(e){super("phone",e),this.phoneNumber=e.phoneInfo}static _fromServerResponse(e,t){return new ya(t)}}class Ea extends _a{constructor(e){super("totp",e)}static _fromServerResponse(e,t){return new Ea(t)}}/**
3082 * @license
3083 * Copyright 2020 Google LLC
3084 *
3085 * Licensed under the Apache License, Version 2.0 (the "License");
3086 * you may not use this file except in compliance with the License.
3087 * You may obtain a copy of the License at
3088 *
3089 *   http://www.apache.org/licenses/LICENSE-2.0
3090 *
3091 * Unless required by applicable law or agreed to in writing, software
3092 * distributed under the License is distributed on an "AS IS" BASIS,
3093 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3094 * See the License for the specific language governing permissions and
3095 * limitations under the License.
3096 */async function Ta(n){const e=$e(n);e._getPasswordPolicyInternal()&&await e._updatePasswordPolicy()}async function mI(n,e,t){await dd(G(n),{oobCode:e,newPassword:t}).catch(async r=>{throw r.code==="auth/password-does-not-meet-requirements"&&Ta(n),r})}async function gI(n,e){await fE(G(n),{oobCode:e})}async function RE(n,e){const t=G(n),r=await dd(t,{oobCode:e}),s=r.requestType;switch(M(s,t,"internal-error"),s){case"EMAIL_SIGNIN":break;case"VERIFY_AND_CHANGE_EMAIL":M(r.newEmail,t,"internal-error");break;case"REVERT_SECOND_FACTOR_ADDITION":M(r.mfaInfo,t,"internal-error");default:M(r.email,t,"internal-error")}let o=null;return r.mfaInfo&&(o=_a._fromServerResponse($e(t),r.mfaInfo)),{data:{email:(r.requestType==="VERIFY_AND_CHANGE_EMAIL"?r.newEmail:r.email)||null,previousEmail:(r.requestType==="VERIFY_AND_CHANGE_EMAIL"?r.email:r.newEmail)||null,multiFactorInfo:o},operation:s}}async function _I(n,e){const{data:t}=await RE(G(n),e);return t.email}async function yI(n,e,t){if(pe(n.app))return Promise.reject(Me(n));const r=$e(n),a=await mo(r,{returnSecureToken:!0,email:e,password:t,clientType:"CLIENT_TYPE_WEB"},"signUpPassword",fd).catch(h=>{throw h.code==="auth/password-does-not-meet-requirements"&&Ta(n),h}),u=await Xe._fromIdTokenResponse(r,"signIn",a);return await r._updateCurrentUser(u.user),u}function EI(n,e,t){return pe(n.app)?Promise.reject(Me(n)):vE(G(n),kn.credential(e,t)).catch(async r=>{throw r.code==="auth/password-does-not-meet-requirements"&&Ta(n),r})}/**
3097 * @license
3098 * Copyright 2020 Google LLC
3099 *
3100 * Licensed under the Apache License, Version 2.0 (the "License");
3101 * you may not use this file except in compliance with the License.
3102 * You may obtain a copy of the License at
3103 *
3104 *   http://www.apache.org/licenses/LICENSE-2.0
3105 *
3106 * Unless required by applicable law or agreed to in writing, software
3107 * distributed under the License is distributed on an "AS IS" BASIS,
3108 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3109 * See the License for the specific language governing permissions and
3110 * limitations under the License.
3111 */async function SE(n,e){return xe(n,"POST","/v1/accounts:update",e)}/**
3112 * @license
3113 * Copyright 2020 Google LLC
3114 *
3115 * Licensed under the Apache License, Version 2.0 (the "License");
3116 * you may not use this file except in compliance with the License.
3117 * You may obtain a copy of the License at
3118 *
3119 *   http://www.apache.org/licenses/LICENSE-2.0
3120 *
3121 * Unless required by applicable law or agreed to in writing, software
3122 * distributed under the License is distributed on an "AS IS" BASIS,
3123 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3124 * See the License for the specific language governing permissions and
3125 * limitations under the License.
3126 */async function TI(n,{displayName:e,photoURL:t}){if(e===void 0&&t===void 0)return;const r=G(n),o={idToken:await r.getIdToken(),displayName:e,photoUrl:t,returnSecureToken:!0},a=await Jt(r,SE(r.auth,o));r.displayName=a.displayName||null,r.photoURL=a.photoUrl||null;const u=r.providerData.find(({providerId:h})=>h==="password");u&&(u.displayName=r.displayName,u.photoURL=r.photoURL),await r._updateTokensIfNecessary(a)}function II(n,e){const t=G(n);return pe(t.auth.app)?Promise.reject(Me(t.auth)):_d(t,e,null)}function wI(n,e){return _d(G(n),null,e)}async function _d(n,e,t){const{auth:r}=n,o={idToken:await n.getIdToken(),returnSecureToken:!0};e&&(o.email=e),t&&(o.password=t);const a=await Jt(n,hE(r,o));await n._updateTokensIfNecessary(a,!0)}function PE(n,e,t,r){return G(n).onIdTokenChanged(e,t,r)}function CE(n,e,t){return G(n).beforeAuthStateChanged(e,t)}function vI(n,e,t,r){return G(n).onAuthStateChanged(e,t,r)}function AI(n){return G(n).signOut()}const Vs="__sak";/**
3127 * @license
3128 * Copyright 2019 Google LLC
3129 *
3130 * Licensed under the Apache License, Version 2.0 (the "License");
3131 * you may not use this file except in compliance with the License.
3132 * You may obtain a copy of the License at
3133 *
3134 *   http://www.apache.org/licenses/LICENSE-2.0
3135 *
3136 * Unless required by applicable law or agreed to in writing, software
3137 * distributed under the License is distributed on an "AS IS" BASIS,
3138 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3139 * See the License for the specific language governing permissions and
3140 * limitations under the License.
3141 */class yd{constructor(e,t){this.storageRetriever=e,this.type=t}_isAvailable(){try{return this.storage?(this.storage.setItem(Vs,"1"),this.storage.removeItem(Vs),Promise.resolve(!0)):Promise.resolve(!1)}catch{return Promise.resolve(!1)}}_set(e,t){return this.storage.setItem(e,JSON.stringify(t)),Promise.resolve()}_get(e){const t=this.storage.getItem(e);return Promise.resolve(t?JSON.parse(t):null)}_remove(e){return this.storage.removeItem(e),Promise.resolve()}get storage(){return this.storageRetriever()}}/**
3142 * @license
3143 * Copyright 2020 Google LLC
3144 *
3145 * Licensed under the Apache License, Version 2.0 (the "License");
3146 * you may not use this file except in compliance with the License.
3147 * You may obtain a copy of the License at
3148 *
3149 *   http://www.apache.org/licenses/LICENSE-2.0
3150 *
3151 * Unless required by applicable law or agreed to in writing, software
3152 * distributed under the License is distributed on an "AS IS" BASIS,
3153 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3154 * See the License for the specific language governing permissions and
3155 * limitations under the License.
3156 */const bE=1e3,kE=10;class Ed extends yd{constructor(){super(()=>window.localStorage,"LOCAL"),this.boundEventHandler=(e,t)=>this.onStorageEvent(e,t),this.listeners={},this.localCache={},this.pollTimer=null,this.fallbackToPolling=ad(),this._shouldAllowMigration=!0}forAllChangedKeys(e){for(const t of Object.keys(this.listeners)){const r=this.storage.getItem(t),s=this.localCache[t];r!==s&&e(t,s,r)}}onStorageEvent(e,t=!1){if(!e.key){this.forAllChangedKeys((a,u,h)=>{this.notifyListeners(a,h)});return}const r=e.key;t?this.detachListener():this.stopPolling();const s=()=>{const a=this.storage.getItem(r);!t&&this.localCache[r]===a||this.notifyListeners(r,a)},o=this.storage.getItem(r);Wy()&&o!==e.newValue&&e.newValue!==e.oldValue?setTimeout(s,kE):s()}notifyListeners(e,t){this.localCache[e]=t;const r=this.listeners[e];if(r)for(const s of Array.from(r))s(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)})},bE)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}attachListener(){window.addEventListener("storage",this.boundEventHandler)}detachListener(){window.removeEventListener("storage",this.boundEventHandler)}_addListener(e,t){Object.keys(this.listeners).length===0&&(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),this.listeners[e].size===0&&delete this.listeners[e]),Ob
3156ject.keys(this.listeners).length===0&&(this.detachListener(),this.stopPolling())}async _set(e,t){await super._set(e,t),this.localCache[e]=JSON.stringify(t)}async _get(e){const t=await super._get(e);return this.localCache[e]=JSON.stringify(t),t}async _remove(e){await super._remove(e),delete this.localCache[e]}}Ed.type="LOCAL";const NE=Ed;/**
3157 * @license
3158 * Copyright 2020 Google LLC
3159 *
3160 * Licensed under the Apache License, Version 2.0 (the "License");
3161 * you may not use this file except in compliance with the License.
3162 * You may obtain a copy of the License at
3163 *
3164 *   http://www.apache.org/licenses/LICENSE-2.0
3165 *
3166 * Unless required by applicable law or agreed to in writing, software
3167 * distributed under the License is distributed on an "AS IS" BASIS,
3168 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3169 * See the License for the specific language governing permissions and
3170 * limitations under the License.
3171 */class Td extends yd{constructor(){super(()=>window.sessionStorage,"SESSION")}_addListener(e,t){}_removeListener(e,t){}}Td.type="SESSION";const Id=Td;/**
3172 * @license
3173 * Copyright 2019 Google LLC
3174 *
3175 * Licensed under the Apache License, Version 2.0 (the "License");
3176 * you may not use this file except in compliance with the License.
3177 * You may obtain a copy of the License at
3178 *
3179 *   http://www.apache.org/licenses/LICENSE-2.0
3180 *
3181 * Unless required by applicable law or agreed to in writing, software
3182 * distributed under the License is distributed on an "AS IS" BASIS,
3183 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3184 * See the License for the specific language governing permissions and
3185 * limitations under the License.
3186 */function VE(n){return Promise.all(n.map(async e=>{try{return{fulfilled:!0,value:await e}}catch(t){return{fulfilled:!1,reason:t}}}))}/**
3187 * @license
3188 * Copyright 2019 Google LLC
3189 *
3190 * Licensed under the Apache License, Version 2.0 (the "License");
3191 * you may not use this file except in compliance with the License.
3192 * You may obtain a copy of the License at
3193 *
3194 *   http://www.apache.org/licenses/LICENSE-2.0
3195 *
3196 * Unless required by applicable law or agreed to in writing, software
3197 * distributed under the License is distributed on an "AS IS" BASIS,
3198 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3199 * See the License for the specific language governing permissions and
3200 * limitations under the License.
3201 */class si{constructor(e){this.eventTarget=e,this.handlersMap={},this.boundEventHandler=this.handleEvent.bind(this)}static _getInstance(e){const t=this.receivers.find(s=>s.isListeningto(e));if(t)return t;const r=new si(e);return this.receivers.push(r),r}isListeningto(e){return this.eventTarget===e}async handleEvent(e){const t=e,{eventId:r,eventType:s,data:o}=t.data,a=this.handlersMap[s];if(!(a!=null&&a.size))return;t.ports[0].postMessage({status:"ack",eventId:r,eventType:s});const u=Array.from(a).map(async d=>d(t.origin,o)),h=await VE(u);t.ports[0].postMessage({status:"done",eventId:r,eventType:s,response:h})}_subscribe(e,t){Object.keys(this.handlersMap).length===0&&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||this.handlersMap[e].size===0)&&delete this.handlersMap[e],Object.keys(this.handlersMap).length===0&&this.eventTarget.removeEventListener("message",this.boundEventHandler)}}si.receivers=[];/**
3202 * @license
3203 * Copyright 2020 Google LLC
3204 *
3205 * Licensed under the Apache License, Version 2.0 (the "License");
3206 * you may not use this file except in compliance with the License.
3207 * You may obtain a copy of the License at
3208 *
3209 *   http://www.apache.org/licenses/LICENSE-2.0
3210 *
3211 * Unless required by applicable law or agreed to in writing, software
3212 * distributed under the License is distributed on an "AS IS" BASIS,
3213 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3214 * See the License for the specific language governing permissions and
3215 * limitations under the License.
3216 */function Ia(n="",e=10){let t="";for(let r=0;r<e;r++)t+=Math.floor(Math.random()*10);return n+t}/**
3217 * @license
3218 * Copyright 2019 Google LLC
3219 *
3220 * Licensed under the Apache License, Version 2.0 (the "License");
3221 * you may not use this file except in compliance with the License.
3222 * You may obtain a copy of the License at
3223 *
3224 *   http://www.apache.org/licenses/LICENSE-2.0
3225 *
3226 * Unless required by applicable law or agreed to in writing, software
3227 * distributed under the License is distributed on an "AS IS" BASIS,
3228 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3229 * See the License for the specific language governing permissions and
3230 * limitations under the License.
3231 */class DE{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,r=50){const s=typeof MessageChannel<"u"?new MessageChannel:null;if(!s)throw new Error("connection_unavailable");let o,a;return new Promise((u,h)=>{const d=Ia("",20);s.port1.start();const p=setTimeout(()=>{h(new Error("unsupported_event"))},r);a={messageChannel:s,onMessage(_){const E=_;if(E.data.eventId===d)switch(E.data.status){case"ack":clearTimeout(p),o=setTimeout(()=>{h(new Error("timeout"))},3e3);break;case"done":clearTimeout(o),u(E.data.response);break;default:clearTimeout(p),clearTimeout(o),h(new Error("invalid_response"));break}}},this.handlers.add(a),s.port1.addEventListener("message",a.onMessage),this.target.postMessage({eventType:e,eventId:d,data:t},[s.port2])}).finally(()=>{a&&this.removeMessageHandler(a)})}}/**
3232 * @license
3233 * Copyright 2020 Google LLC
3234 *
3235 * Licensed under the Apache License, Version 2.0 (the "License");
3236 * you may not use this file except in compliance with the License.
3237 * You may obtain a copy of the License at
3238 *
3239 *   http://www.apache.org/licenses/LICENSE-2.0
3240 *
3241 * Unless required by applicable law or agreed to in writing, software
3242 * distributed under the License is distributed on an "AS IS" BASIS,
3243 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3244 * See the License for the specific language governing permissions and
3245 * limitations under the License.
3246 */function Je(){return window}function OE(n){Je().location.href=n}/**
3247 * @license
3248 * Copyright 2020 Google LLC.
3249 *
3250 * Licensed under the Apache License, Version 2.0 (the "License");
3251 * you may not use this file except in compliance with the License.
3252 * You may obtain a copy of the License at
3253 *
3254 *   http://www.apache.org/licenses/LICENSE-2.0
3255 *
3256 * Unless required by applicable law or agreed to in writing, software
3257 * distributed under the License is distributed on an "AS IS" BASIS,
3258 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3259 * See the License for the specific language governing permissions and
3260 * limitations under the License.
3261 */function wd(){return typeof Je().WorkerGlobalScope<"u"&&typeof Je().importScripts=="function"}async function ME(){if(!(navigator!=null&&navigator.serviceWorker))return null;try{return(await navigator.serviceWorker.ready).active}catch{return null}}function LE(){var n;return((n=navigator==null?void 0:navigator.serviceWorker)==null?void 0:n.controller)||null}function xE(){return wd()?self:null}/**
3262 * @license
3263 * Copyright 2019 Google LLC
3264 *
3265 * Licensed under the Apache License, Version 2.0 (the "License");
3266 * you may not use this file except in compliance with the License.
3267 * You may obtain a copy of the License at
3268 *
3269 *   http://www.apache.org/licenses/LICENSE-2.0
3270 *
3271 * Unless required by applicable law or agreed to in writing, software
3272 * distributed under the License is distributed on an "AS IS" BASIS,
3273 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3274 * See the License for the specific language governing permissions and
3275 * limitations under the License.
3276 */const vd="firebaseLocalStorageDb",FE=1,Ds="firebaseLocalStorage",Ad="fbase_key";class kr{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 ii(n,e){return n.transaction([Ds],e?"readwrite":"readonly").objectStore(Ds)}function UE(){const n=indexedDB.deleteDatabase(vd);return new kr(n).toPromise()}function _o(){const n=indexedDB.open(vd,FE);return new Promise((e,t)=>
3276{n.addEventListener("error",()=>{t(n.error)}),n.addEventListener("upgradeneeded",()=>{const r=n.result;try{r.createObjectStore(Ds,{keyPath:Ad})}catch(s){t(s)}}),n.addEventListener("success",async()=>{const r=n.result;r.objectStoreNames.contains(Ds)?e(r):(r.close(),await UE(),e(await _o()))})})}async function Gu(n,e,t){const r=ii(n,!0).put({[Ad]:e,value:t});return new kr(r).toPromise()}async function BE(n,e){const t=ii(n,!1).get(e),r=await new kr(t).toPromise();return r===void 0?null:r.value}function Ku(n,e){const t=ii(n,!0).delete(e);return new kr(t).toPromise()}const qE=800,jE=3;class Rd{constructor(){this.type="LOCAL",this._shouldAllowMigration=!0,this.listeners={},this.localCache={},this.pollTimer=null,this.pendingWrites=0,this.receiver=null,this.sender=null,this.serviceWorkerReceiverAvailable=!1,this.activeServiceWorker=null,this._workerInitializationPromise=this.initializeServiceWorkerMessaging().then(()=>{},()=>{})}async _openDb(){return this.db?this.db:(this.db=await _o(),this.db)}async _withRetries(e){let t=0;for(;;)try{const r=await this._openDb();return await e(r)}catch(r){if(t++>jE)throw r;this.db&&(this.db.close(),this.db=void 0)}}async initializeServiceWorkerMessaging(){return wd()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=si._getInstance(xE()),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 t,r;if(this.activeServiceWorker=await ME(),!this.activeServiceWorker)return;this.sender=new DE(this.activeServiceWorker);const e=await this.sender._send("ping",{},800);e&&(t=e[0])!=null&&t.fulfilled&&(r=e[0])!=null&&r.value.includes("keyChanged")&&(this.serviceWorkerReceiverAvailable=!0)}async notifyServiceWorker(e){if(!(!this.sender||!this.activeServiceWorker||LE()!==this.activeServiceWorker))try{await this.sender._send("keyChanged",{key:e},this.serviceWorkerReceiverAvailable?800:50)}catch{}}async _isAvailable(){try{if(!indexedDB)return!1;const e=await _o();return await Gu(e,Vs,"1"),await Ku(e,Vs),!0}catch{}return!1}async _withPendingWrite(e){this.pendingWrites++;try{await e()}finally{this.pendingWrites--}}async _set(e,t){return this._withPendingWrite(async()=>(await this._withRetries(r=>Gu(r,e,t)),this.localCache[e]=t,this.notifyServiceWorker(e)))}async _get(e){const t=await this._withRetries(r=>BE(r,e));return this.localCache[e]=t,t}async _remove(e){return this._withPendingWrite(async()=>(await this._withRetries(t=>Ku(t,e)),delete this.localCache[e],this.notifyServiceWorker(e)))}async _poll(){const e=await this._withRetries(s=>{const o=ii(s,!1).getAll();return new kr(o).toPromise()});if(!e)return[];if(this.pendingWrites!==0)return[];const t=[],r=new Set;if(e.length!==0)for(const{fbase_key:s,value:o}of e)r.add(s),JSON.stringify(this.localCache[s])!==JSON.stringify(o)&&(this.notifyListeners(s,o),t.push(s));for(const s of Object.keys(this.localCache))this.localCache[s]&&!r.has(s)&&(this.notifyListeners(s,null),t.push(s));return t}notifyListeners(e,t){this.localCache[e]=t;const r=this.listeners[e];if(r)for(const s of Array.from(r))s(t)}startPolling(){this.stopPolling(),this.pollTimer=setInterval(async()=>this._poll(),qE)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}_addListener(e,t){Object.keys(this.listeners).length===0&&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),this.listeners[e].size===0&&delete this.listeners[e]),Ob
3276ject.keys(this.listeners).length===0&&this.stopPolling()}}Rd.type="LOCAL";const $E=Rd;new br(3e4,6e4);/**
3277 * @license
3278 * Copyright 2021 Google LLC
3279 *
3280 * Licensed under the Apache License, Version 2.0 (the "License");
3281 * you may not use this file except in compliance with the License.
3282 * You may obtain a copy of the License at
3283 *
3284 *   http://www.apache.org/licenses/LICENSE-2.0
3285 *
3286 * Unless required by applicable law or agreed to in writing, software
3287 * distributed under the License is distributed on an "AS IS" BASIS,
3288 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3289 * See the License for the specific language governing permissions and
3290 * limitations under the License.
3291 */function Sd(n,e){return e?ot(e):(M(n._popupRedirectResolver,n,"argument-error"),n._popupRedirectResolver)}/**
3292 * @license
3293 * Copyright 2019 Google LLC
3294 *
3295 * Licensed under the Apache License, Version 2.0 (the "License");
3296 * you may not use this file except in compliance with the License.
3297 * You may obtain a copy of the License at
3298 *
3299 *   http://www.apache.org/licenses/LICENSE-2.0
3300 *
3301 * Unless required by applicable law or agreed to in writing, software
3302 * distributed under the License is distributed on an "AS IS" BASIS,
3303 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3304 * See the License for the specific language governing permissions and
3305 * limitations under the License.
3306 */class wa extends ni{constructor(e){super("custom","custom"),this.params=e}_getIdTokenResponse(e){return ct(e,this._buildIdpRequest())}_linkToIdToken(e,t){return ct(e,this._buildIdpRequest(t))}_getReauthenticationResolver(e){return ct(e,this._buildIdpRequest())}_buildIdpRequest(e){const t={requestUri:this.params.requestUri,sessionId:this.params.sessionId,postBody:this.params.postBody,tenantId:this.params.tenantId,pendingToken:this.params.pendingToken,returnSecureToken:!0,returnIdpCredential:!0};return e&&(t.idToken=e),t}}function zE(n){return gd(n.auth,new wa(n),n.bypassAuthState)}function HE(n){const{auth:e,user:t}=n;return M(t,e,"internal-error"),md(t,new wa(n),n.bypassAuthState)}async function WE(n){const{auth:e,user:t}=n;return M(t,e,"internal-error"),wE(t,new wa(n),n.bypassAuthState)}/**
3307 * @license
3308 * Copyright 2020 Google LLC
3309 *
3310 * Licensed under the Apache License, Version 2.0 (the "License");
3311 * you may not use this file except in compliance with the License.
3312 * You may obtain a copy of the License at
3313 *
3314 *   http://www.apache.org/licenses/LICENSE-2.0
3315 *
3316 * Unless required by applicable law or agreed to in writing, software
3317 * distributed under the License is distributed on an "AS IS" BASIS,
3318 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3319 * See the License for the specific language governing permissions and
3320 * limitations under the License.
3321 */class Pd{constructor(e,t,r,s,o=!1){this.auth=e,this.resolver=r,this.user=s,this.bypassAuthState=o,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(r){this.reject(r)}})}async onAuthEvent(e){const{urlResponse:t,sessionId:r,postBody:s,tenantId:o,error:a,type:u}=e;if(a){this.reject(a);return}const h={auth:this.auth,requestUri:t,sessionId:r,tenantId:o||void 0,postBody:s||void 0,user:this.user,bypassAuthState:this.bypassAuthState};try{this.resolve(await this.getIdpTask(u)(h))}catch(d){this.reject(d)}}onError(e){this.reject(e)}getIdpTask(e){switch(e){case"signInViaPopup":case"signInViaRedirect":return zE;case"linkViaPopup":case"linkViaRedirect":return WE;case"reauthViaPopup":case"reauthViaRedirect":return HE;default:De(this.auth,"internal-error")}}resolve(e){ft(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){ft(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()}}/**
3322 * @license
3323 * Copyright 2020 Google LLC
3324 *
3325 * Licensed under the Apache License, Version 2.0 (the "License");
3326 * you may not use this file except in compliance with the License.
3327 * You may obtain a copy of the License at
3328 *
3329 *   http://www.apache.org/licenses/LICENSE-2.0
3330 *
3331 * Unless required by applicable law or agreed to in writing, software
3332 * distributed under the License is distributed on an "AS IS" BASIS,
3333 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3334 * See the License for the specific language governing permissions and
3335 * limitations under the License.
3336 */const GE=new br(2e3,1e4);async function RI(n,e,t){if(pe(n.app))return Promise.reject(Be(n,"operation-not-supported-in-this-environment"));const r=$e(n);Sy(n,e,ri);const s=Sd(r,t);return new Ht(r,"signInViaPopup",e,s).executeNotNull()}class Ht extends Pd{constructor(e,t,r,s,o){super(e,t,s,o),this.provider=r,this.authWindow=null,this.pollId=null,Ht.currentPopupAction&&Ht.currentPopupAction.cancel(),Ht.currentPopupAction=this}async executeNotNull(){const e=await this.execute();return M(e,this.auth,"internal-error"),e}async onExecution(){ft(this.filter.length===1,"Popup operations only handle one event");const e=Ia();this.authWindow=await this.resolver._openPopup(this.auth,this.provider,this.filter[0],e),this.authWindow.associatedEvent=e,this.resolver._originValidation(this.auth).catch(t=>{this.reject(t)}),this.resolver._isIframeWebStorageSupported(this.auth,t=>{t||this.reject(Be(this.auth,"web-storage-unsupported"))}),this.pollUserCancellation()}get eventId(){var e;return((e=this.authWindow)==null?void 0:e.associatedEvent)||null}cancel(){this.reject(Be(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,Ht.currentPopupAction=null}pollUserCancellation(){const e=()=>{var t,r;if((r=(t=this.authWindow)==null?void 0:t.window)!=null&&r.closed){this.pollId=window.setTimeout(()=>{this.pollId=null,this.reject(Be(this.auth,"popup-closed-by-user"))},8e3);return}this.pollId=window.setTimeout(e,GE.get())};e()}}Ht.currentPopupAction=null;/**
3337 * @license
3338 * Copyright 2020 Google LLC
3339 *
3340 * Licensed under the Apache License, Version 2.0 (the "License");
3341 * you may not use this file except in compliance with the License.
3342 * You may obtain a copy of the License at
3343 *
3344 *   http://www.apache.org/licenses/LICENSE-2.0
3345 *
3346 * Unless required by applicable law or agreed to in writing, software
3347 * distributed under the License is distributed on an "AS IS" BASIS,
3348 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3349 * See the License for the specific language governing permissions and
3350 * limitations under the License.
3351 */const KE="pendingRedirect",hs=new Map;class QE extends Pd{constructor(e,t,r=!1){super(e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],t,void 0,r),this.eventId=null}async execute(){let e=hs.get(this.auth._key());if(!e){try{const r=await JE(this.resolver,this.auth)?await super.execute():null;e=()=>Promise.resolve(r)}catch(t){e=()=>Promise.reject(t)}hs.set(this.auth._key(),e)}return this.bypassAuthState||hs.set(this.auth._key(),()=>Promise.resolve(null)),e()}async onAuthEvent(e){if(e.type==="signInViaRedirect")return super.onAuthEvent(e);if(e.type==="unknown"){this.resolve(null);return}if(e.eventId){const t=await this.auth._redirectUserForId(e.eventId);if(t)return this.user=t,super.onAuthEvent(e);this.resolve(null)}}async onExecution(){}cleanUp(){}}async function JE(n,e){const t=ZE(e),r=XE(n);if(!await r._isAvailable())return!1;const s=await r._get(t)==="true";return await r._remove(t),s}function YE(n,e){hs.set(n._key(),e)}function XE(n){return ot(n._redirectPersistence)}function ZE(n){return us(KE,n.config.apiKey,n.name)}async function eT(n,e,t=!1){if(pe(n.app))return Promise.reject(Me(n));const r=$e(n),s=Sd(r,e),a=await new QE(r,s,t).execute();return a&&!t&&(delete a.user._redirectEventId,await r._persistUserIfCurrent(a.user),await r._setRedirectUser(null,e)),a}/**
3352 * @license
3353 * Copyright 2020 Google LLC
3354 *
3355 * Licensed under the Apache License, Version 2.0 (the "License");
3356 * you may not use this file except in compliance with the License.
3357 * You may obtain a copy of the License at
3358 *
3359 *   http://www.apache.org/licenses/LICENSE-2.0
3360 *
3361 * Unless required by applicable law or agreed to in writing, softw
3361are
3362 * distributed under the License is distributed on an "AS IS" BASIS,
3363 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3364 * See the License for the specific language governing permissions and
3365 * limitations under the License.
3366 */const tT=10*60*1e3;class nT{constructor(e){this.auth=e,this.cachedEventUids=new Set,this.consumers=new Set,this.queuedRedirectEvent=null,this.hasHandledPotentialRedirect=!1,this.lastProcessedEventTime=Date.now()}registerConsumer(e){this.consumers.add(e),this.queuedRedirectEvent&&this.isEventForConsumer(this.queuedRedirectEvent,e)&&(this.sendToConsumer(this.queuedRedirectEvent,e),this.saveEventToCache(this.queuedRedirectEvent),this.queuedRedirectEvent=null)}unregisterConsumer(e){this.consumers.delete(e)}onEvent(e){if(this.hasEventBeenHandled(e))return!1;let t=!1;return this.consumers.forEach(r=>{this.isEventForConsumer(e,r)&&(t=!0,this.sendToConsumer(e,r),this.saveEventToCache(e))}),this.hasHandledPotentialRedirect||!rT(e)||(this.hasHandledPotentialRedirect=!0,t||(this.queuedRedirectEvent=e,t=!0)),t}sendToConsumer(e,t){var r;if(e.error&&!Cd(e)){const s=((r=e.error.code)==null?void 0:r.split("auth/")[1])||"internal-error";t.onError(Be(this.auth,s))}else t.onAuthEvent(e)}isEventForConsumer(e,t){const r=t.eventId===null||!!e.eventId&&e.eventId===t.eventId;return t.filter.includes(e.type)&&r}hasEventBeenHandled(e){return Date.now()-this.lastProcessedEventTime>=tT&&this.cachedEventUids.clear(),this.cachedEventUids.has(Qu(e))}saveEventToCache(e){this.cachedEventUids.add(Qu(e)),this.lastProcessedEventTime=Date.now()}}function Qu(n){return[n.type,n.eventId,n.sessionId,n.tenantId].filter(e=>e).join("-")}function Cd({type:n,error:e}){return n==="unknown"&&(e==null?void 0:e.code)==="auth/no-auth-event"}function rT(n){switch(n.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return!0;case"unknown":return Cd(n);default:return!1}}/**
3367 * @license
3368 * Copyright 2020 Google LLC
3369 *
3370 * Licensed under the Apache License, Version 2.0 (the "License");
3371 * you may not use this file except in compliance with the License.
3372 * You may obtain a copy of the License at
3373 *
3374 *   http://www.apache.org/licenses/LICENSE-2.0
3375 *
3376 * Unless required by applicable law or agreed to in writing, software
3377 * distributed under the License is distributed on an "AS IS" BASIS,
3378 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3379 * See the License for the specific language governing permissions and
3380 * limitations under the License.
3381 */async function sT(n,e={}){return xe(n,"GET","/v1/projects",e)}/**
3382 * @license
3383 * Copyright 2020 Google LLC
3384 *
3385 * Licensed under the Apache License, Version 2.0 (the "License");
3386 * you may not use this file except in compliance with the License.
3387 * You may obtain a copy of the License at
3388 *
3389 *   http://www.apache.org/licenses/LICENSE-2.0
3390 *
3391 * Unless required by applicable law or agreed to in writing, software
3392 * distributed under the License is distributed on an "AS IS" BASIS,
3393 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3394 * See the License for the specific language governing permissions and
3395 * limitations under the License.
3396 */const iT=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,oT=/^https?/;async function aT(n){if(n.config.emulator)return;const{authorizedDomains:e}=await sT(n);for(const t of e)try{if(cT(t))return}catch{}De(n,"unauthorized-domain")}function cT(n){const e=fo(),{protocol:t,hostname:r}=new URL(e);if(n.startsWith("chrome-extension://")){const a=new URL(n);return a.hostname===""&&r===""?t==="chrome-extension:"&&n.replace("chrome-extension://","")===e.replace("chrome-extension://",""):t==="chrome-extension:"&&a.hostname===r}if(!oT.test(t))return!1;if(iT.test(n))return r===n;const s=n.replace(/\./g,"\\.");return new RegExp("^(.+\\."+s+"|"+s+")$","i").test(r)}/**
3397 * @license
3398 * Copyright 2020 Google LLC.
3399 *
3400 * Licensed under the Apache License, Version 2.0 (the "License");
3401 * you may not use this file except in compliance with the License.
3402 * You may obtain a copy of the License at
3403 *
3404 *   http://www.apache.org/licenses/LICENSE-2.0
3405 *
3406 * Unless required by applicable law or agreed to in writing, softw
3406are
3407 * distributed under the License is distributed on an "AS IS" BASIS,
3408 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3409 * See the License for the specific language governing permissions and
3410 * limitations under the License.
3411 */const uT=new br(3e4,6e4);function Ju(){const n=Je().___jsl;if(n!=null&&n.H){for(const e of Object.keys(n.H))if(n.H[e].r=n.H[e].r||[],n.H[e].L=n.H[e].L||[],n.H[e].r=[...n.H[e].L],n.CP)for(let t=0;t<n.CP.length;t++)n.CP[t]=null}}function lT(n){return new Promise((e,t)=>{var s,o,a;function r(){Ju(),gapi.load("gapi.iframes",{callback:()=>{e(gapi.iframes.getContext())},ontimeout:()=>{Ju(),t(Be(n,"network-request-failed"))},timeout:uT.get()})}if((o=(s=Je().gapi)==null?void 0:s.iframes)!=null&&o.Iframe)e(gapi.iframes.getContext());else if((a=Je().gapi)!=null&&a.load)r();else{const u=tE("iframefcb");return Je()[u]=()=>{gapi.load?r():t(Be(n,"network-request-failed"))},ud(`${eE()}?onload=${u}`).catch(h=>t(h))}}).catch(e=>{throw ds=null,e})}let ds=null;function hT(n){return ds=ds||lT(n),ds}/**
3412 * @license
3413 * Copyright 2020 Google LLC.
3414 *
3415 * Licensed under the Apache License, Version 2.0 (the "License");
3416 * you may not use this file except in compliance with the License.
3417 * You may obtain a copy of the License at
3418 *
3419 *   http://www.apache.org/licenses/LICENSE-2.0
3420 *
3421 * Unless required by applicable law or agreed to in writing, software
3422 * distributed under the License is distributed on an "AS IS" BASIS,
3423 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3424 * See the License for the specific language governing permissions and
3425 * limitations under the License.
3426 */const dT=new br(5e3,15e3),fT="__/auth/iframe",pT="emulator/auth/iframe",mT={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},gT=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);function _T(n){const e=n.config;M(e.authDomain,n,"auth-domain-config-required");const t=e.emulator?fa(e,pT):`https://${n.config.authDomain}/${fT}`,r={apiKey:e.apiKey,appName:n.name,v:vn},s=gT.get(n.config.apiHost);s&&(r.eid=s);const o=n._getFrameworks();return o.length&&(r.fw=o.join(",")),`${t}?${Er(r).slice(1)}`}async function yT(n){const e=await hT(n),t=Je().gapi;return M(t,n,"internal-error"),e.open({where:document.body,url:_T(n),messageHandlersFilter:t.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:mT,dontclear:!0},r=>new Promise(async(s,o)=>{await r.restyle({setHideOnLeave:!1});const a=Be(n,"network-request-failed"),u=Je().setTimeout(()=>{o(a)},dT.get());function h(){Je().clearTimeout(u),s(r)}r.ping(h).then(h,()=>{o(a)})}))}/**
3427 * @license
3428 * Copyright 2020 Google LLC.
3429 *
3430 * Licensed under the Apache License, Version 2.0 (the "License");
3431 * you may not use this file except in compliance with the License.
3432 * You may obtain a copy of the License at
3433 *
3434 *   http://www.apache.org/licenses/LICENSE-2.0
3435 *
3436 * Unless required by applicable law or agreed to in writing, software
3437 * distributed under the License is distributed on an "AS IS" BASIS,
3438 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3439 * See the License for the specific language governing permissions and
3440 * limitations under the License.
3441 */const ET={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"},TT=500,IT=600,wT="_blank",vT="http://localhost";class Yu{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch{}}}function AT(n,e,t,r=TT,s=IT){const o=Math.max((window.screen.availHeight-s)/2,0).toString(),a=Math.max((window.screen.availWidth-r)/2,0).toString();let u="";const h={...ET,width:r.toString(),height:s.toString(),top:o,left:a},d=ve().toLowerCase();t&&(u=nd(d)?wT:t),ed(d)&&(e=e||vT,h.scrollbars="yes");const p=Object.entries(h).reduce((E,[S,b])=>`${E}${S}=${b},`,"");if(Hy(d)&&u!=="_self")return RT(e||"",u),new Yu(null);const _=window.open(e||"",u,p);M(_,n,"popup-blocked");try{_.focus()}catch{}return new Yu(_)}function RT(n,e){const t=document.createElement("a");t.href=n,t.target=e;const r=document.createEvent("MouseEvent");
3441r.initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,1,null),t.dispatchEvent(r)}/**
3442 * @license
3443 * Copyright 2021 Google LLC
3444 *
3445 * Licensed under the Apache License, Version 2.0 (the "License");
3446 * you may not use this file except in compliance with the License.
3447 * You may obtain a copy of the License at
3448 *
3449 *   http://www.apache.org/licenses/LICENSE-2.0
3450 *
3451 * Unless required by applicable law or agreed to in writing, software
3452 * distributed under the License is distributed on an "AS IS" BASIS,
3453 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3454 * See the License for the specific language governing permissions and
3455 * limitations under the License.
3456 */const ST="__/auth/handler",PT="emulator/auth/handler",CT=encodeURIComponent("fac");async function Xu(n,e,t,r,s,o){M(n.config.authDomain,n,"auth-domain-config-required"),M(n.config.apiKey,n,"invalid-api-key");const a={apiKey:n.config.apiKey,appName:n.name,authType:t,redirectUrl:r,v:vn,eventId:s};if(e instanceof ri){e.setDefaultLanguage(n.languageCode),a.providerId=e.providerId||"",Mf(e.getCustomParameters())||(a.customParameters=JSON.stringify(e.getCustomParameters()));for(const[p,_]of Object.entries({}))a[p]=_}if(e instanceof Nn){const p=e.getScopes().filter(_=>_!=="");p.length>0&&(a.scopes=p.join(","))}n.tenantId&&(a.tid=n.tenantId);const u=a;for(const p of Object.keys(u))u[p]===void 0&&delete u[p];const h=await n._getAppCheckToken(),d=h?`#${CT}=${encodeURIComponent(h)}`:"";return`${bT(n)}?${Er(u).slice(1)}${d}`}function bT({config:n}){return n.emulator?fa(n,PT):`https://${n.authDomain}/${ST}`}/**
3457 * @license
3458 * Copyright 2020 Google LLC
3459 *
3460 * Licensed under the Apache License, Version 2.0 (the "License");
3461 * you may not use this file except in compliance with the License.
3462 * You may obtain a copy of the License at
3463 *
3464 *   http://www.apache.org/licenses/LICENSE-2.0
3465 *
3466 * Unless required by applicable law or agreed to in writing, software
3467 * distributed under the License is distributed on an "AS IS" BASIS,
3468 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3469 * See the License for the specific language governing permissions and
3470 * limitations under the License.
3471 */const ji="webStorageSupport";class kT{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=Id,this._completeRedirectFn=eT,this._overrideRedirectResult=YE}async _openPopup(e,t,r,s){var a;ft((a=this.eventManagers[e._key()])==null?void 0:a.manager,"_initialize() not called before _openPopup()");const o=await Xu(e,t,r,fo(),s);return AT(e,o,Ia())}async _openRedirect(e,t,r,s){await this._originValidation(e);const o=await Xu(e,t,r,fo(),s);return OE(o),new Promise(()=>{})}_initialize(e){const t=e._key();if(this.eventManagers[t]){const{manager:s,promise:o}=this.eventManagers[t];return s?Promise.resolve(s):(ft(o,"If manager is not set, promise should be"),o)}const r=this.initAndGetManager(e);return this.eventManagers[t]={promise:r},r.catch(()=>{delete this.eventManagers[t]}),r}async initAndGetManager(e){const t=await yT(e),r=new nT(e);return t.register("authEvent",s=>(M(s==null?void 0:s.authEvent,e,"invalid-auth-event"),{status:r.onEvent(s.authEvent)?"ACK":"ERROR"}),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[e._key()]={manager:r},this.iframes[e._key()]=t,r}_isIframeWebStorageSupported(e,t){this.iframes[e._key()].send(ji,{type:ji},s=>{var a;const o=(a=s==null?void 0:s[0])==null?void 0:a[ji];o!==void 0&&t(!!o),De(e,"internal-error")},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){const t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=aT(e)),this.originValidationPromises[t]}get _shouldInitProactively(){return ad()||td()||ma()}}const NT=kT;var Zu="@firebase/auth",el="1.11.0";/**
3472 * @license
3473 * Copyright 2020 Google LLC
3474 *
3475 * Licensed under the Apache License, Version 2.0 (the "License");
3476 * you may not use this file except in compliance with the License.
3477 * You may obtain a copy of the License at
3478 *
3479 *   http://www.apache.org/licenses/LICENSE-2.0
3480 *
3481 * Unless required by applicable law or agreed to in writing, softw
3481are
3482 * distributed under the License is distributed on an "AS IS" BASIS,
3483 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3484 * See the License for the specific language governing permissions and
3485 * limitations under the License.
3486 */class VT{constructor(e){this.auth=e,this.internalListeners=new Map}getUid(){var e;return this.assertAuthConfigured(),((e=this.auth.currentUser)==null?void 0:e.uid)||null}async getToken(e){return this.assertAuthConfigured(),await this.auth._initializationPromise,this.auth.currentUser?{accessToken:await this.auth.currentUser.getIdToken(e)}:null}addAuthTokenListener(e){if(this.assertAuthConfigured(),this.internalListeners.has(e))return;const t=this.auth.onIdTokenChanged(r=>{e((r==null?void 0:r.stsTokenManager.accessToken)||null)});this.internalListeners.set(e,t),this.updateProactiveRefresh()}removeAuthTokenListener(e){this.assertAuthConfigured();const t=this.internalListeners.get(e);t&&(this.internalListeners.delete(e),t(),this.updateProactiveRefresh())}assertAuthConfigured(){M(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}/**
3487 * @license
3488 * Copyright 2020 Google LLC
3489 *
3490 * Licensed under the Apache License, Version 2.0 (the "License");
3491 * you may not use this file except in compliance with the License.
3492 * You may obtain a copy of the License at
3493 *
3494 *   http://www.apache.org/licenses/LICENSE-2.0
3495 *
3496 * Unless required by applicable law or agreed to in writing, software
3497 * distributed under the License is distributed on an "AS IS" BASIS,
3498 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3499 * See the License for the specific language governing permissions and
3500 * limitations under the License.
3501 */function DT(n){switch(n){case"Node":return"node";case"ReactNative":return"rn";case"Worker":return"webworker";case"Cordova":return"cordova";case"WebExtension":return"web-extension";default:return}}function OT(n){Gt(new kt("auth",(e,{options:t})=>{const r=e.getProvider("app").getImmediate(),s=e.getProvider("heartbeat"),o=e.getProvider("app-check-internal"),{apiKey:a,authDomain:u}=r.options;M(a&&!a.includes(":"),"invalid-api-key",{appName:r.name});const h={apiKey:a,authDomain:u,clientPlatform:n,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:cd(n)},d=new Yy(r,s,o,h);return aE(d,t),d},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((e,t,r)=>{e.getProvider("auth-internal").initialize()})),Gt(new kt("auth-internal",e=>{const t=$e(e.getProvider("auth").getImmediate());return(r=>new VT(r))(t)},"PRIVATE").setInstantiationMode("EXPLICIT")),He(Zu,el,DT(n)),He(Zu,el,"esm2020")}/**
3502 * @license
3503 * Copyright 2021 Google LLC
3504 *
3505 * Licensed under the Apache License, Version 2.0 (the "License");
3506 * you may not use this file except in compliance with the License.
3507 * You may obtain a copy of the License at
3508 *
3509 *   http://www.apache.org/licenses/LICENSE-2.0
3510 *
3511 * Unless required by applicable law or agreed to in writing, software
3512 * distributed under the License is distributed on an "AS IS" BASIS,
3513 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3514 * See the License for the specific language governing permissions and
3515 * limitations under the License.
3516 */const MT=5*60,LT=al("authIdTokenMaxAge")||MT;let tl=null;const xT=n=>async e=>{const t=e&&await e.getIdTokenResult(),r=t&&(new Date().getTime()-Date.parse(t.issuedAtTime))/1e3;if(r&&r>LT)return;const s=t==null?void 0:t.token;tl!==s&&(tl=s,await fetch(n,{method:s?"POST":"DELETE",headers:s?{Authorization:`Bearer ${s}`}:{}}))};function SI(n=hl()){const e=Ms(n,"auth");if(e.isInitialized())return e.getImmediate();const t=oE(n,{popupRedirectResolver:NT,persistence:[$E,NE,Id]}),r=al("authTokenSyncURL");if(r&&typeof isSecureContext=="boolean"&&isSecureContext){const o=new URL(r,location.origin);if(location.origin===o.origin){const a=xT(o.toString());CE(t,a,()=>a(t.currentUser)),PE(t,u=>a(u))}}const s=il("auth");return s&&cE(t,`http://${s}`),t}function FT(){var n;return((n=document.getElementsByTagName("head"))==null?void 0:n[0])??document}Xy({loadJS(n){return new Promise((e,t)=>
3516{const r=document.createElement("script");r.setAttribute("src",n),r.onload=e,r.onerror=s=>{const o=Be("internal-error");o.customData=s,t(o)},r.type="text/javascript",r.charset="UTF-8",FT().appendChild(r)})},gapiScript:"https://apis.google.com/js/api.js",recaptchaV2Script:"https://www.google.com/recaptcha/api.js",recaptchaEnterpriseScript:"https://www.google.com/recaptcha/enterprise.js?render="});OT("Browser");export{yI as $,kn as A,fI as B,kt as C,Tf as D,yr as E,II as F,wI as G,eI as H,tI as I,JT as J,WT as K,Eo as L,pI as M,mI as N,_I as O,RE as P,gI as Q,vI as R,AI as S,Z as T,dI as U,go as V,ls as W,RI as X,It as Y,EI as Z,Gt as _,G as a,nI as a0,hI as a1,QT as a2,YT as a3,iI as a4,Ef as a5,Yt as a6,yo as a7,cl as a8,UT as a9,pe as aa,Ze as ab,vn as ac,oI as ad,rl as b,Ms as c,mf as d,BT as e,qp as f,hl as g,$T as h,kf as i,SI as j,uI as k,H_ as l,jT as m,XT as n,rI as o,KT as p,aI as q,He as r,sI as s,lI as t,ZT as u,zT as v,cI as w,GT as x,HT as y,TI as z};
3517
3518//# chunkId=01a0ecf6-50c2-73d1-a7c7-f8179acc7ff9

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.