PageSourceSearch

https://docuguru.ai/v20260902-1702/assets/index.esm-BbmTDasi.js

js docuguru.ai collected 2026-10-05 14:27:17 UTC 490,598 bytes, 2,752 lines download raw bytes

1const cg=()=>{};var Fc={};/**
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 yh=function(r){const t=[];let e=0;for(let n=0;n<r.length;n++){let s=r.charCodeAt(n);s<128?t[e++]=s:s<2048?(t[e++]=s>>6|192,t[e++]=s&63|128):(s&64512)===55296&&n+1<r.length&&(r.charCodeAt(n+1)&64512)===56320?(s=65536+((s&1023)<<10)+(r.charCodeAt(++n)&1023),t[e++]=s>>18|240,t[e++]=s>>12&63|128,t[e++]=s>>6&63|128,t[e++]=s&63|128):(t[e++]=s>>12|224,t[e++]=s>>6&63|128,t[e++]=s&63|128)}return t},lg=function(r){const t=[];let e=0,n=0;for(;e<r.length;){const s=r[e++];if(s<128)t[n++]=String.fromCharCode(s);else if(s>191&&s<224){const i=r[e++];t[n++]=String.fromCharCode((s&31)<<6|i&63)}else if(s>239&&s<365){const i=r[e++],o=r[e++],u=r[e++],c=((s&7)<<18|(i&63)<<12|(o&63)<<6|u&63)-65536;t[n++]=String.fromCharCode(55296+(c>>10)),t[n++]=String.fromCharCode(56320+(c&1023))}else{const i=r[e++],o=r[e++];t[n++]=String.fromCharCode((s&15)<<12|(i&63)<<6|o&63)}}return t.join("")},Ih={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(r,t){if(!Array.isArray(r))throw Error("encodeByteArray takes an array as a parameter");this.init_();const e=t?this.byteToCharMapWebSafe_:this.byteToCharMap_,n=[];for(let s=0;s<r.length;s+=3){const i=r[s],o=s+1<r.length,u=o?r[s+1]:0,c=s+2<r.length,h=c?r[s+2]:0,f=i>>2,m=(i&3)<<4|u>>4;let p=(u&15)<<2|h>>6,v=h&63;c||(v=64,o||(p=64)),n.push(e[f],e[m],e[p],e[v])}return n.join("")},encodeString(r,t){return this.HAS_NATIVE_SUPPORT&&!t?btoa(r):this.encodeByteArray(yh(r),t)},decodeString(r,t){return this.HAS_NATIVE_SUPPORT&&!t?atob(r):lg(this.decodeStringToByteArray(r,t))},decodeStringToByteArray(r,t){this.init_();const e=t?this.charToByteMapWebSafe_:this.charToByteMap_,n=[];for(let s=0;s<r.length;){const i=e[r.charAt(s++)],u=s<r.length?e[r.charAt(s)]:0;++s;const h=s<r.length?e[r.charAt(s)]:64;++s;const m=s<r.length?e[r.charAt(s)]:64;if(++s,i==null||u==null||h==null||m==null)throw new hg;const p=i<<2|u>>4;if(n.push(p),h!==64){const v=u<<4&240|h>>2;if(n.push(v),m!==64){const C=h<<6&192|m;n.push(C)}}}return n},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let r=0;r<this.ENCODED_VALS.length;r++)this.byteToCharMap_[r]=this.ENCODED_VALS.charAt(r),this.charToByteMap_[this.byteToCharMap_[r]]=r,this.byteToCharMapWebSafe_[r]=this.ENCODED_VALS_WEBSAFE.charAt(r),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[r]]=r,r>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(r)]=r,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(r)]=r)}}};class hg extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}const dg=function(r){const t=yh(r);return Ih.encodeByteArray(t,!0)},mi=function(r){return dg(r).replace(/\./g,"")},fg=function(r){try{return Ih.decodeString(r,!0)}catch(t){console.error("base64Decode failed: ",t)}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, softw
26are
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 Eh(){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 mg=()=>Eh().__FIREBASE_DEFAULTS__,gg=()=>{if(typeof process>"u"||typeof Fc>"u")return;const r=Fc.__FIREBASE_DEFAULTS__;if(r)return JSON.parse(r)},pg=()=>{if(typeof document>"u")return;let r;try{r=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch{return}const t=r&&fg(r[1]);return t&&JSON.parse(t)},Ni=()=>{try{return cg()||mg()||gg()||pg()}catch(r){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${r}`);return}},_g=r=>Ni()?.emulatorHosts?.[r],yg=r=>{const t=_g(r);if(!t)return;const e=t.lastIndexOf(":");if(e<=0||e+1===t.length)throw new Error(`Invalid host ${t} with no separate hostname and port!`);const n=parseInt(t.substring(e+1),10);return t[0]==="["?[t.substring(1,e-1),n]:[t.substring(0,e),n]},Th=()=>Ni()?.config,MT=r=>Ni()?.[`_${r}`];/**
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 Ig{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((t,e)=>{this.resolve=t,this.reject=e})}wrapCallback(t){return(e,n)=>{e?this.reject(e):this.resolve(n),typeof t=="function"&&(this.promise.catch(()=>{}),t.length===1?t(e):t(e,n))}}}/**
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 ki(r){try{return(r.startsWith("http://")||r.startsWith("https://")?new URL(r).hostname:r).endsWith(".cloudworkstations.dev")}catch{return!1}}async function wh(r){return(await fetch(r,{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, software
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 Eg(r,t){if(r.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');const e={alg:"none",type:"JWT"},n=t||"demo-project",s=r.iat||0,i=r.sub||r.user_id;if(!i)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const o={iss:`https://securetoken.google.com/${n}`,aud:n,iat:s,exp:s+3600,auth_time:s,sub:i,user_id:i,firebase:{sign_in_provider:"custom",identities:{}},...r};return[mi(JSON.stringify(e)),mi(JSON.stringify(o)),""].join(".")}const Hr={};function Tg(){const r={prod:[],emulator:[]};for(const t of Object.keys(Hr))Hr[t]?r.emulator.push(t):r.prod.push(t);return r}function wg(r){let t=document.getElementById(r),e=!1;return t||(t=document.createElement("div"),t.setAttribute("id",r),e=!0),{created:e,element:t}}let Lc=!1;function Ag(r,t){if(typeof window>"u"||typeof document>"u"||!ki(window.location.host)||Hr[r]===t||Hr[r]||Lc)return;Hr[r]=t;function e(p){return`__firebase__banner__${p}`}const n="__firebase__banner",i=Tg().prod.length>0;function o(){const p=document.getElementById(n);p&&p.remove()}function u(p){p.style.display="flex",p.style.background="#7faaf0",p.style.position="fixed",p.style.bottom="5px",p.style.left="5px",p.style.padding=".5em",p.style.borderRadius="5px",p.style.alignItems="center"}function c(p,v){p.setAttribute("width","24"),p.setAttribute("id",v),p.setAttribute("height","24"),p.setAttribute("viewBox","0 0 24 24"),p.setAttribute("fill","none"),p.style.marginLeft="-6px"}function h(){const p=document.createElement("span");
91return p.style.cursor="pointer",p.style.marginLeft="16px",p.style.fontSize="24px",p.innerHTML=" &times;",p.onclick=()=>{Lc=!0,o()},p}function f(p,v){p.setAttribute("id",v),p.innerText="Learn more",p.href="https://firebase.google.com/docs/studio/preview-apps#preview-backend",p.setAttribute("target","__blank"),p.style.paddingLeft="5px",p.style.textDecoration="underline"}function m(){const p=wg(n),v=e("text"),C=document.getElementById(v)||document.createElement("span"),D=e("learnmore"),x=document.getElementById(D)||document.createElement("a"),B=e("preprendIcon"),j=document.getElementById(B)||document.createElementNS("http://www.w3.org/2000/svg","svg");if(p.created){const U=p.element;u(U),f(x,D);const Y=h();c(j,B),U.append(j,C,x,Y),document.body.appendChild(U)}i?(C.innerText="Preview backend disconnected.",j.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>`):(j.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>`,C.innerText="Preview backend running in this workspace."),C.setAttribute("id",v)}document.readyState==="loading"?window.addEventListener("DOMContentLoaded",m):m()}/**
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 zn(){return typeof navigator<"u"&&typeof navigator.userAgent=="string"?navigator.userAgent:""}function OT(){return typeof window<"u"&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(zn())}function Ah(){const r=Ni()?.forceEnvironment;if(r==="node")return!0;
120if(r==="browser")return!1;try{return Object.prototype.toString.call(global.process)==="[object process]"}catch{return!1}}function FT(){return typeof navigator<"u"&&navigator.userAgent==="Cloudflare-Workers"}function LT(){const r=typeof chrome=="object"?chrome.runtime:typeof browser=="object"?browser.runtime:void 0;return typeof r=="object"&&r.id!==void 0}function BT(){return typeof navigator=="object"&&navigator.product==="ReactNative"}function UT(){const r=zn();return r.indexOf("MSIE ")>=0||r.indexOf("Trident/")>=0}function vh(){return!Ah()&&!!navigator.userAgent&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}function bh(){return!Ah()&&!!navigator.userAgent&&(navigator.userAgent.includes("Safari")||navigator.userAgent.includes("WebKit"))&&!navigator.userAgent.includes("Chrome")}function Rh(){try{return typeof indexedDB=="object"}catch{return!1}}function vg(){return new Promise((r,t)=>{try{let e=!0;const n="validate-browser-context-for-indexeddb-analytics-module",s=self.indexedDB.open(n);s.onsuccess=()=>{s.result.close(),e||self.indexedDB.deleteDatabase(n),r(!0)},s.onupgradeneeded=()=>{e=!1},s.onerror=()=>{t(s.error?.message||"")}}catch(e){t(e)}})}/**
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 bg="FirebaseError";class hr extends Error{constructor(t,e,n){super(e),this.code=t,this.customData=n,this.name=bg,Object.setPrototypeOf(this,hr.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,Sh.prototype.create)}}class Sh{constructor(t,e,n){this.service=t,this.serviceName=e,this.errors=n}create(t,...e){const n=e[0]||{},s=`${this.service}/${t}`,i=this.errors[t],o=i?Rg(i,n):"Error",u=`${this.serviceName}: ${o} (${s}).`;return new hr(s,u,n)}}function Rg(r,t){return r.replace(Sg,(e,n)=>{const s=t[n];return s!=null?String(s):`<${n}?>`})}const Sg=/\{\$([^}]+)}/g;function qT(r){for(const t in r)if(Object.prototype.hasOwnProperty.call(r,t))return!1;return!0}function xe(r,t){if(r===t)return!0;const e=Object.keys(r),n=Object.keys(t);for(const s of e){if(!n.includes(s))return!1;const i=r[s],o=t[s];if(Bc(i)&&Bc(o)){if(!xe(i,o))return!1}else if(i!==o)return!1}for(const s of n)if(!e.includes(s))return!1;return!0}function Bc(r){return r!==null&&typeof r=="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 jT(r){const t=[];for(const[e,n]of Object.entries(r))Array.isArray(n)?n.forEach(s=>{t.push(encodeURIComponent(e)+"="+encodeURIComponent(s))}):t.push(encodeURIComponent(e)+"="+encodeURIComponent(n));return t.length?"&"+t.join("&"):""}function zT(r,t){const e=new Pg(r,t);return e.subscribe.bind(e)}class Pg{constructor(t,e){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=e,this.task.then(()=>{t(this)}).catch(n=>{this.error(n)})}next(t){this.forEachObserver(e=>{e.next(t)})}error(t){this.forEachObserver(e=>{e.error(t)}),this.close(t)}complete(){this.forEachObserver(t=>{t.complete()}),this.close()}subscribe(t,e,n){let s;if(t===void 0&&e===void 0&&n===void 0)throw new Error("Missing Observer.");Vg(t,["next","error","complete"])?s=t:s={next:t,error:e,complete:n},s.next===void 0&&(s.next=No),s.error===void 0&&(s.error=No),s.complete===void 0&&(s.complete=No);const i=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),i}unsubscribeOne(t){this.observers===void 0||this.observers[t]===void 0||(delete this.observers[t],this.observerCount-=1,this.observerCount===0&&this.onNoObservers!==void 0&&this.onNoObservers(this))}forEachObserver(t){if(!this.finalized)for(let e=0;e<this.observers.length;e++)this.sendOne(e,t)}sendOne(t,e){this.task.then(()=>
150{if(this.observers!==void 0&&this.observers[t]!==void 0)try{e(this.observers[t])}catch(n){typeof console<"u"&&console.error&&console.error(n)}})}close(t){this.finalized||(this.finalized=!0,t!==void 0&&(this.finalError=t),this.task.then(()=>{this.observers=void 0,this.onNoObservers=void 0}))}}function Vg(r,t){if(typeof r!="object"||r===null)return!1;for(const e of t)if(e in r&&typeof r[e]=="function")return!0;return!1}function No(){}/**
151 * @license
152 * Copyright 2021 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 */function Et(r){return r&&r._delegate?r._delegate:r}class os{constructor(t,e,n){this.name=t,this.instanceFactory=e,this.type=n,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(t){return this.instantiationMode=t,this}setMultipleInstances(t){return this.multipleInstances=t,this}setServiceProps(t){return this.serviceProps=t,this}setInstanceCreatedCallback(t){return this.onInstanceCreated=t,this}}/**
166 * @license
167 * Copyright 2019 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 */const nn="[DEFAULT]";/**
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 */class Cg{constructor(t,e){this.name=t,this.container=e,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(t){const e=this.normalizeInstanceIdentifier(t);if(!this.instancesDeferred.has(e)){const n=new Ig;if(this.instancesDeferred.set(e,n),this.isInitialized(e)||this.shouldAutoInitialize())try{const s=this.getOrInitializeService({instanceIdentifier:e});s&&n.resolve(s)}catch{}}return this.instancesDeferred.get(e).promise}getImmediate(t){const e=this.normalizeInstanceIdentifier(t?.identifier),n=t?.optional??!1;if(this.isInitialized(e)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:e})}catch(s){if(n)return null;throw s}else{if(n)return null;throw Error(`Service ${this.name} is not available`)}}getComponent(){return this.component}setComponent(t){if(t.name!==this.name)throw Error(`Mismatching Component ${t.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=t,!!this.shouldAutoInitialize()){if(xg(t))try{this.getOrInitializeService({instanceIdentifier:nn})}catch{}for(const[e,n]of this.instancesDeferred.entries()){const s=this.normalizeInstanceIdentifier(e);try{const i=this.getOrInitializeService({instanceIdentifier:s});n.resolve(i)}catch{}}}}clearInstance(t=nn){this.instancesDeferred.delete(t),this.instancesOptions.delete(t),this.instances.delete(t)}async delete(){const t=Array.from(this.instances.values());await Promise.all([...t.filter(e=>"INTERNAL"in e).map(e=>e.INTERNAL.delete()),...t.filter(e=>"_delete"in e).map(e=>e._delete())])}isComponentSet(){return this.component!=null}isInitialized(t=nn){return this.instances.has(t)}getOptions(t=nn){return this.instancesOptions.get(t)||{}}initialize(t={}){const{options:e={}}=t,n=this.normalizeInstanceIdentifier(t.instanceIdentifier);if(this.isInitialized(n))throw Error(`${this.name}(${n}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const s=this.getOrInitializeService({instanceIdentifier:n,options:e});for(const[i,o]of this.instancesDeferred.entries()){const u=this.normalizeInstanceIdentifier(i);n===u&&o.resolve(s)}return s}onInit(t,e){const n=this.normalizeInstanceIdentifier(e),s=this.onInitCallbacks.get(n)??new Set;s.add(t),this.onInitCallbacks.set(n,s);const i=this.instances.get(n);return i&&t(i,n),()=>{s.delete(t)}}invokeOnInitCallbacks(t,e){const n=this.onInitCallbacks.get(e);if(n)for(const s of n)try{s(t,e)}catch{}}getOrInitializeService({instanceIdentifier:t,options:e={}}){let n=this.instances.get(t);if(!n&&this.component&&(n=this.component.instanceFactory(this.container,{instanceIdentifier:Dg(t),options:e}),this.instances.set(t,n),this.instancesOptions.set(t,e),this.invokeOnInitCallbacks(n,t),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,t,n)}catch{}return n||null}normalizeInstanceIdentifier(t=nn){return this.component?this.component.multipleInstances?t:nn:t}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!=="EXPLICIT"}}function Dg(r){return r===nn?void 0:r}function xg(r){return r.instantiationMode==="EAGER"}/**
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, software
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 Ng{constructor(t){this.name=t,this.providers=new Map}addComponent(t){const e=this.getProvider(t.name);if(e.isComponentSet())throw new Error(`Component ${t.name} has already been registered with ${this.name}`);e.setComponent(t)}addOrOverwriteComponent(t){this.getProvider(t.name).isComponentSet()&&this.providers.delete(t.name),this.addComponent(t)}getProvider(t){if(this.providers.has(t))return this.providers.get(t);const e=new Cg(t,this);return this.providers.set(t,e),e}getProviders(){return Array.from(this.providers.values())}}/**
211 * @license
212 * Copyright 2017 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 */var X;(function(r){r[r.DEBUG=0]="DEBUG",r[r.VERBOSE=1]="VERBOSE",r[r.INFO=2]="INFO",r[r.WARN=3]="WARN",r[r.ERROR=4]="ERROR",r[r.SILENT=5]="SILENT"})(X||(X={}));const kg={debug:X.DEBUG,verbose:X.VERBOSE,info:X.INFO,warn:X.WARN,error:X.ERROR,silent:X.SILENT},Mg=X.INFO,Og={[X.DEBUG]:"log",[X.VERBOSE]:"log",[X.INFO]:"info",[X.WARN]:"warn",[X.ERROR]:"error"},Fg=(r,t,...e)=>{if(t<r.logLevel)return;const n=new Date().toISOString(),s=Og[t];if(s)console[s](`[${n}]  ${r.name}:`,...e);else throw new Error(`Attempted to log a message with an invalid logType (value: ${t})`)};class Ph{constructor(t){this.name=t,this._logLevel=Mg,this._logHandler=Fg,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(t){if(!(t in X))throw new TypeError(`Invalid value "${t}" assigned to \`logLevel\``);this._logLevel=t}setLogLevel(t){this._logLevel=typeof t=="string"?kg[t]:t}get logHandler(){return this._logHandler}set logHandler(t){if(typeof t!="function")throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=t}get userLogHandler(){return this._userLogHandler}set userLogHandler(t){this._userLogHandler=t}debug(...t){this._userLogHandler&&this._userLogHandler(this,X.DEBUG,...t),this._logHandler(this,X.DEBUG,...t)}log(...t){this._userLogHandler&&this._userLogHandler(this,X.VERBOSE,...t),this._logHandler(this,X.VERBOSE,...t)}info(...t){this._userLogHandler&&this._userLogHandler(this,X.INFO,...t),this._logHandler(this,X.INFO,...t)}warn(...t){this._userLogHandler&&this._userLogHandler(this,X.WARN,...t),this._logHandler(this,X.WARN,...t)}error(...t){this._userLogHandler&&this._userLogHandler(this,X.ERROR,...t),this._logHandler(this,X.ERROR,...t)}}const Lg=(r,t)=>t.some(e=>r instanceof e);let Uc,qc;function Bg(){return Uc||(Uc=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Ug(){return qc||(qc=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const Vh=new WeakMap,Qo=new WeakMap,Ch=new WeakMap,ko=new WeakMap,Sa=new WeakMap;function qg(r){const t=new Promise((e,n)=>{const s=()=>{r.removeEventListener("success",i),r.removeEventListener("error",o)},i=()=>{e(Pe(r.result)),s()},o=()=>{n(r.error),s()};r.addEventListener("success",i),r.addEventListener("error",o)});return t.then(e=>{e instanceof IDBCursor&&Vh.set(e,r)}).catch(()=>{}),Sa.set(t,r),t}function jg(r){if(Qo.has(r))return;const t=new Promise((e,n)=>{const s=()=>{r.removeEventListener("complete",i),r.removeEventListener("error",o),r.removeEventListener("abort",o)},i=()=>{e(),s()},o=()=>{n(r.error||new DOMException("AbortError","AbortError")),s()};r.addEventListener("complete",i),r.addEventListener("error",o),r.addEventListener("abort",o)});Qo.set(r,t)}let Wo={get(r,t,e){if(r instanceof IDBTransaction){if(t==="done")return Qo.get(r);if(t==="objectStoreNames")return r.objectStoreNames||Ch.get(r);if(t==="store")return e.objectStoreNames[1]?void 0:e.objectStore(e.objectStoreNames[0])}return Pe(r[t])},set(r,t,e){return r[t]=e,!0},has(r,t){return r instanceof IDBTransaction&&(t==="done"||t==="store")?!0:t in r}};function zg(r){Wo=r(Wo)}function Gg(r){return r===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(t,...e){const n=r.call(Mo(this),t,...e);return Ch.set(n,t.sort?t.sort():[t]),Pe(n)}:Ug().includes(r)?function(...t){return r.apply(Mo(this),t),Pe(Vh.get(this))}:function(...t){return Pe(r.apply(Mo(this),t))}}function $g(r){return typeof r=="function"?Gg(r):(r instanceof IDBTransaction&&jg(r),Lg(r,Bg())?new Proxy(r,Wo):r)}function Pe(r){if(r instanceof IDBRequest)return qg(r);if(ko.has(r))return ko.get(r);const t=$g(r);return t!==r&&(ko.set(r,t),Sa.set(t,r)),t}const Mo=r=>Sa.get(r);function Kg(r,t,{blocked:e,upgrade:n,blocking:s,terminated:i}={}){const o=indexedDB.open(r,t),u=Pe(o);return n&&o.addEventListener("upgradeneeded",c=>{n(Pe(o.result),c.oldVersion,c.newVersion,Pe(o.transaction),c)}),e&&o.addEventListener("blocked",c=>e(c.oldVersion,c.newVersion,c)),u.then(c=>{i&&c.addEventListener("close",()=>i()),s&&c.addEventListener("versionchange",h=>s(h.oldVersion,h.newVersion,h))}).catch(()=>{}),u}const Qg=["get","getKey","getAll","getAllKeys","count"],Wg=["put","add","delete","clear"],Oo=new Map;function jc(r,t){if(!(r instanceof IDBDatabase&&!(t in r)&&typeof t=="string"))return;if(Oo.get(t))return Oo.get(t);const e=t.replace(/FromIndex$/,""),n=t!==e,s=Wg.includes(e);if(!(e in(n?IDBIndex:IDBObjectStore).prototype)||!(s||Qg.includes(e)))return;const i=async function(o,...u){const c=this.transaction(o,s?"readwrite":"readonly");let h=c.store;
225return n&&(h=h.index(u.shift())),(await Promise.all([h[e](...u),s&&c.done]))[0]};return Oo.set(t,i),i}zg(r=>({...r,get:(t,e,n)=>jc(t,e)||r.get(t,e,n),has:(t,e)=>!!jc(t,e)||r.has(t,e)}));/**
226 * @license
227 * Copyright 2019 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 */class Hg{constructor(t){this.container=t}getPlatformInfoString(){return this.container.getProviders().map(e=>{if(Jg(e)){const n=e.getImmediate();return`${n.library}/${n.version}`}else return null}).filter(e=>e).join(" ")}}function Jg(r){return r.getComponent()?.type==="VERSION"}const Ho="@firebase/app",zc="0.14.5";/**
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 */const ue=new Ph("@firebase/app"),Xg="@firebase/app-compat",Yg="@firebase/analytics-compat",Zg="@firebase/analytics",tp="@firebase/app-check-compat",ep="@firebase/app-check",np="@firebase/auth",rp="@firebase/auth-compat",sp="@firebase/database",ip="@firebase/data-connect",op="@firebase/database-compat",ap="@firebase/functions",up="@firebase/functions-compat",cp="@firebase/installations",lp="@firebase/installations-compat",hp="@firebase/messaging",dp="@firebase/messaging-compat",fp="@firebase/performance",mp="@firebase/performance-compat",gp="@firebase/remote-config",pp="@firebase/remote-config-compat",_p="@firebase/storage",yp="@firebase/storage-compat",Ip="@firebase/firestore",Ep="@firebase/ai",Tp="@firebase/firestore-compat",wp="firebase",Ap="12.5.0";/**
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 gi="[DEFAULT]",vp={[Ho]:"fire-core",[Xg]:"fire-core-compat",[Zg]:"fire-analytics",[Yg]:"fire-analytics-compat",[ep]:"fire-app-check",[tp]:"fire-app-check-compat",[np]:"fire-auth",[rp]:"fire-auth-compat",[sp]:"fire-rtdb",[ip]:"fire-data-connect",[op]:"fire-rtdb-compat",[ap]:"fire-fn",[up]:"fire-fn-compat",[cp]:"fire-iid",[lp]:"fire-iid-compat",[hp]:"fire-fcm",[dp]:"fire-fcm-compat",[fp]:"fire-perf",[mp]:"fire-perf-compat",[gp]:"fire-rc",[pp]:"fire-rc-compat",[_p]:"fire-gcs",[yp]:"fire-gcs-compat",[Ip]:"fire-fst",[Tp]:"fire-fst-compat",[Ep]:"fire-vertex","fire-js":"fire-js",[wp]:"fire-js-all"};/**
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 pi=new Map,bp=new Map,Jo=new Map;function Gc(r,t){try{r.container.addComponent(t)}catch(e){ue.debug(`Component ${t.name} failed to register with FirebaseApp ${r.name}`,e)}}function _i(r){const t=r.name;if(Jo.has(t))return ue.debug(`There were multiple attempts to register component ${t}.`),!1;Jo.set(t,r);for(const e of pi.values())Gc(e,r);for(const e of bp.values())Gc(e,r);return!0}function Pa(r,t){const e=r.container.getProvider("heartbeat").getImmediate({optional:!0});return e&&e.triggerHeartbeat(),r.container.getProvider(t)}function Rp(r,t,e=gi){Pa(r,t).clearInstance(e)}function Sp(r){return r==null?!1:r.settings!==void 0}/**
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 Pp={"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
300d-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."},Ve=new Sh("app","Firebase",Pp);/**
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 */class Vp{constructor(t,e,n){this._isDeleted=!1,this._options={...t},this._config={...e},this._name=e.name,this._automaticDataCollectionEnabled=e.automaticDataCollectionEnabled,this._container=n,this.container.addComponent(new os("app",()=>this,"PUBLIC"))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(t){this.checkDestroyed(),this._automaticDataCollectionEnabled=t}get name(){return this.checkDestroyed(),this._name}get options(){return this.checkDestroyed(),this._options}get config(){return this.checkDestroyed(),this._config}get container(){return this._container}get isDeleted(){return this._isDeleted}set isDeleted(t){this._isDeleted=t}checkDestroyed(){if(this.isDeleted)throw Ve.create("app-deleted",{appName:this._name})}}/**
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 */const Cp=Ap;function Dp(r,t={}){let e=r;typeof t!="object"&&(t={name:t});const n={name:gi,automaticDataCollectionEnabled:!0,...t},s=n.name;if(typeof s!="string"||!s)throw Ve.create("bad-app-name",{appName:String(s)});if(e||(e=Th()),!e)throw Ve.create("no-options");const i=pi.get(s);if(i){if(xe(e,i.options)&&xe(n,i.config))return i;throw Ve.create("duplicate-app",{appName:s})}const o=new Ng(s);for(const c of Jo.values())o.addComponent(c);const u=new Vp(e,n,o);return pi.set(s,u),u}function xp(r=gi){const t=pi.get(r);if(!t&&r===gi&&Th())return Dp();if(!t)throw Ve.create("no-app",{appName:r});return t}function Jr(r,t,e){let n=vp[r]??r;e&&(n+=`-${e}`);const s=n.match(/\s|\//),i=t.match(/\s|\//);if(s||i){const o=[`Unable to register library "${n}" with version "${t}":`];s&&o.push(`library name "${n}" contains illegal characters (whitespace or "/")`),s&&i&&o.push("and"),i&&o.push(`version name "${t}" contains illegal characters (whitespace or "/")`),ue.warn(o.join(" "));return}_i(new os(`${n}-version`,()=>({library:n,version:t}),"VERSION"))}/**
331 * @license
332 * Copyright 2021 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, softw
340are
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 Np="firebase-heartbeat-database",kp=1,as="firebase-heartbeat-store";let Fo=null;function Dh(){return Fo||(Fo=Kg(Np,kp,{upgrade:(r,t)=>{switch(t){case 0:try{r.createObjectStore(as)}catch(e){console.warn(e)}}}}).catch(r=>{throw Ve.create("idb-open",{originalErrorMessage:r.message})})),Fo}async function Mp(r){try{const e=(await Dh()).transaction(as),n=await e.objectStore(as).get(xh(r));return await e.done,n}catch(t){if(t instanceof hr)ue.warn(t.message);else{const e=Ve.create("idb-get",{originalErrorMessage:t?.message});ue.warn(e.message)}}}async function $c(r,t){try{const n=(await Dh()).transaction(as,"readwrite");await n.objectStore(as).put(t,xh(r)),await n.done}catch(e){if(e instanceof hr)ue.warn(e.message);else{const n=Ve.create("idb-set",{originalErrorMessage:e?.message});ue.warn(n.message)}}}function xh(r){return`${r.name}!${r.options.appId}`}/**
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, software
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 Op=1024,Fp=30;class Lp{constructor(t){this.container=t,this._heartbeatsCache=null;const e=this.container.getProvider("app").getImmediate();this._storage=new Up(e),this._heartbeatsCachePromise=this._storage.read().then(n=>(this._heartbeatsCache=n,n))}async triggerHeartbeat(){try{const e=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),n=Kc();if(this._heartbeatsCache?.heartbeats==null&&(this._heartbeatsCache=await this._heartbeatsCachePromise,this._heartbeatsCache?.heartbeats==null)||this._heartbeatsCache.lastSentHeartbeatDate===n||this._heartbeatsCache.heartbeats.some(s=>s.date===n))return;if(this._heartbeatsCache.heartbeats.push({date:n,agent:e}),this._heartbeatsCache.heartbeats.length>Fp){const s=qp(this._heartbeatsCache.heartbeats);this._heartbeatsCache.heartbeats.splice(s,1)}return this._storage.overwrite(this._heartbeatsCache)}catch(t){ue.warn(t)}}async getHeartbeatsHeader(){try{if(this._heartbeatsCache===null&&await this._heartbeatsCachePromise,this._heartbeatsCache?.heartbeats==null||this._heartbeatsCache.heartbeats.length===0)return"";const t=Kc(),{heartbeatsToSend:e,unsentEntries:n}=Bp(this._heartbeatsCache.heartbeats),s=mi(JSON.stringify({version:2,heartbeats:e}));return this._heartbeatsCache.lastSentHeartbeatDate=t,n.length>0?(this._heartbeatsCache.heartbeats=n,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),s}catch(t){return ue.warn(t),""}}}function Kc(){return new Date().toISOString().substring(0,10)}function Bp(r,t=Op){const e=[];let n=r.slice();for(const s of r){const i=e.find(o=>o.agent===s.agent);if(i){if(i.dates.push(s.date),Qc(e)>t){i.dates.pop();break}}else if(e.push({agent:s.agent,dates:[s.date]}),Qc(e)>t){e.pop();break}n=n.slice(1)}return{heartbeatsToSend:e,unsentEntries:n}}class Up{constructor(t){this.app=t,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return Rh()?vg().then(()=>!0).catch(()=>!1):!1}async read(){if(await this._canUseIndexedDBPromise){const e=await Mp(this.app);return e?.heartbeats?e:{heartbeats:[]}}else return{heartbeats:[]}}async overwrite(t){if(await this._canUseIndexedDBPromise){const n=await this.read();return $c(this.app,{lastSentHeartbeatDate:t.lastSentHeartbeatDate??n.lastSentHeartbeatDate,heartbeats:t.heartbeats})}else return}async add(t){if(await this._canUseIndexedDBPromise){const n=await this.read();return $c(this.app,{lastSentHeartbeatDate:t.lastSentHeartbeatDate??n.lastSentHeartbeatDate,heartbeats:[...n.heartbeats,...t.heartbeats]})}else return}}function Qc(r){return mi(JSON.stringify({version:2,heartbeats:r})).length}function qp(r){if(r.length===0)return-1;let t=0,e=r[0].date;for(let n=1;n<r.length;n++)r[n].date<e&&(e=r[n].date,t=n);return t}/**
361 * @license
362 * Copyright 2019 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 */function jp(r){_i(new os("platform-logger",t=>new Hg(t),"PRIVATE")),_i(new os("heartbeat",t=>new Lp(t),"PRIVATE")),Jr(Ho,zc,r),Jr(Ho,zc,"esm2020"),Jr("fire-js","")}jp("");var Wc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/** @license
376Copyright The Closure Library Authors.
377SPDX-License-Identifier: Apache-2.0
378*/var Ce,Nh;(function(){var r;/** @license
379
380 Copyright The Closure Library Authors.
381 SPDX-License-Identifier: Apache-2.0
382*/function t(E,_){function I(){}I.prototype=_.prototype,E.F=_.prototype,E.prototype=new I,E.prototype.constructor=E,E.D=function(w,T,S){for(var y=Array(arguments.length-2),Ot=2;Ot<arguments.length;Ot++)y[Ot-2]=arguments[Ot];return _.prototype[T].apply(w,y)}}function e(){this.blockSize=-1}function n(){this.blockSize=-1,this.blockSize=64,this.g=Array(4),this.C=Array(this.blockSize),this.o=this.h=0,this.u()}t(n,e),n.prototype.u=function(){this.g[0]=1732584193,this.g[1]=4023233417,this.g[2]=2562383102,this.g[3]=271733878,this.o=this.h=0};function s(E,_,I){I||(I=0);const w=Array(16);if(typeof _=="string")for(var T=0;T<16;++T)w[T]=_.charCodeAt(I++)|_.charCodeAt(I++)<<8|_.charCodeAt(I++)<<16|_.charCodeAt(I++)<<24;else for(T=0;T<16;++T)w[T]=_[I++]|_[I++]<<8|_[I++]<<16|_[I++]<<24;_=E.g[0],I=E.g[1],T=E.g[2];let S=E.g[3],y;y=_+(S^I&(T^S))+w[0]+3614090360&4294967295,_=I+(y<<7&4294967295|y>>>25),y=S+(T^_&(I^T))+w[1]+3905402710&4294967295,S=_+(y<<12&4294967295|y>>>20),y=T+(I^S&(_^I))+w[2]+606105819&4294967295,T=S+(y<<17&4294967295|y>>>15),y=I+(_^T&(S^_))+w[3]+3250441966&4294967295,I=T+(y<<22&4294967295|y>>>10),y=_+(S^I&(T^S))+w[4]+4118548399&4294967295,_=I+(y<<7&4294967295|y>>>25),y=S+(T^_&(I^T))+w[5]+1200080426&4294967295,S=_+(y<<12&4294967295|y>>>20),y=T+(I^S&(_^I))+w[6]+2821735955&4294967295,T=S+(y<<17&4294967295|y>>>15),y=I+(_^T&(S^_))+w[7]+4249261313&4294967295,I=T+(y<<22&4294967295|y>>>10),y=_+(S^I&(T^S))+w[8]+1770035416&4294967295,_=I+(y<<7&4294967295|y>>>25),y=S+(T^_&(I^T))+w[9]+2336552879&4294967295,S=_+(y<<12&4294967295|y>>>20),y=T+(I^S&(_^I))+w[10]+4294925233&4294967295,T=S+(y<<17&4294967295|y>>>15),y=I+(_^T&(S^_))+w[11]+2304563134&4294967295,I=T+(y<<22&4294967295|y>>>10),y=_+(S^I&(T^S))+w[12]+1804603682&4294967295,_=I+(y<<7&4294967295|y>>>25),y=S+(T^_&(I^T))+w[13]+4254626195&4294967295,S=_+(y<<12&4294967295|y>>>20),y=T+(I^S&(_^I))+w[14]+2792965006&4294967295,T=S+(y<<17&4294967295|y>>>15),y=I+(_^T&(S^_))+w[15]+1236535329&4294967295,I=T+(y<<22&4294967295|y>>>10),y=_+(T^S&(I^T))+w[1]+4129170786&4294967295,_=I+(y<<5&4294967295|y>>>27),y=S+(I^T&(_^I))+w[6]+3225465664&4294967295,S=_+(y<<9&4294967295|y>>>23),y=T+(_^I&(S^_))+w[11]+643717713&4294967295,T=S+(y<<14&4294967295|y>>>18),y=I+(S^_&(T^S))+w[0]+3921069994&4294967295,I=T+(y<<20&4294967295|y>>>12),y=_+(T^S&(I^T))+w[5]+3593408605&4294967295,_=I+(y<<5&4294967295|y>>>27),y=S+(I^T&(_^I))+w[10]+38016083&4294967295,S=_+(y<<9&4294967295|y>>>23),y=T+(_^I&(S^_))+w[15]+3634488961&4294967295,T=S+(y<<14&4294967295|y>>>18),y=I+(S^_&(T^S))+w[4]+3889429448&4294967295,I=T+(y<<20&4294967295|y>>>12),y=_+(T^S&(I^T))+w[9]+568446438&4294967295,_=I+(y<<5&4294967295|y>>>27),y=S+(I^T&(_^I))+w[14]+3275163606&4294967295,S=_+(y<<9&4294967295|y>>>23),y=T+(_^I&(S^_))+w[3]+4107603335&4294967295,T=S+(y<<14&4294967295|y>>>18),y=I+(S^_&(T^S))+w[8]+1163531501&4294967295,I=T+(y<<20&4294967295|y>>>12),y=_+(T^S&(I^T))+w[13]+2850285829&4294967295,_=I+(y<<5&4294967295|y>>>27),y=S+(I^T&(_^I))+w[2]+4243563512&4294967295,S=_+(y<<9&4294967295|y>>>23),y=T+(_^I&(S^_))+w[7]+1735328473&4294967295,T=S+(y<<14&4294967295|y>>>18),y=I+(S^_&(T^S))+w[12]+2368359562&4294967295,I=T+(y<<20&4294967295|y>>>12),y=_+(I^T^S)+w[5]+4294588738&4294967295,_=I+(y<<4&4294967295|y>>>28),y=S+(_^I^T)+w[8]+2272392833&4294967295,S=_+(y<<11&4294967295|y>>>21),y=T+(S^_^I)+w[11]+1839030562&4294967295,T=S+(y<<16&4294967295|y>>>16),y=I+(T^S^_)+w[14]+4259657740&4294967295,I=T+(y<<23&4294967295|y>>>9),y=_+(I^T^S)+w[1]+2763975236&4294967295,_=I+(y<<4&4294967295|y>>>28),y=S+(_^I^T)+w[4]+1272893353&4294967295,S=_+(y<<11&4294967295|y>>>21),y=T+(S^_^I)+w[7]+4139469664&4294967295,T=S+(y<<16&4294967295|y>>>16),y=I+(T^S^_)+w[10]+3200236656&4294967295,I=T+(y<<23&4294967295|y>>>9),y=_+(I^T^S)+w[13]+681279174&4294967295,_=I+(y<<4&4294967295|y>>>28),y=S+(_^I^T)+w[0]+3936430074&4294967295,S=_+(y<<11&4294967295|y>>>21),y=T+(S^_^I)+w[3]+3572445317&4294967295,T=S+(y<<16&4294967295|y>>>16),y=I+(T^S^_)+w[6]+76029189&4294967295,I=T+(y<<23&4294967295|y>>>9),y=_+(I^T^S)+w[9]+3654602809&4294967295,_=I+(y<<4&4294967295|y>>>28),y=S+(_^I^T)+w[12]+3873151461&4294967295,S=_+(y<<11&4294967295|y>>>21),y=T+(S^_^I)+w[15]+530742520&4294967295,T=S+(y<<16&4294967295|y>>>16),y=I+(T^S^_)+w[2]+3299628645&4294967295,I=T+(y<<23&4294967295|y>>>9),y=_+(T^(I|~S))+w[0]+4096336452&4294967295,_=I+(y<<6&4294967295|y>>>26),y=S+(I^(_|~T))+w[7]+1126891415&4294967295,S=_+(y<<10&4294967295|y>>>22),y=T+(_^(S|~I))+w[14]+2878612391&4294967295,T=S+(y<<15&4294967295|y>>>17),y=I+(S^(T|~_))+w[5]+4237533241&4294967295,I=T+(y<<21&4294967295|y>>>11),y=_+(T^(I|~S))+w[12]+1700485571&4294967295,_=I+(y<<6&4294967295|y>>>26),y=S+(I^(_|~T))+w[3]+2399980690&4294967295,S=_+(y<<10&4294967295|y>>>22),y=T+(_^(S|~I))+w[10]+4293915773&4294967295,T=S+(y<<15&4294967295|y>>>17),y=I+(S^(T|~_))+w[1]+2240044497&4294967295,I=T+(y<<21&4294967295|y>>>11),y=_+(T^(I|~S))+w[8]+1873313359&4294967295,_=I+(y<<6&4294967295|y>>>26),y=S+(I^(_|~T))+w[15]+4264355552&4294967295,S=_+(y<<10&4294967295|y>>>22),y=T+(_^(S|~I))+w[6]+2734768916&4294967295,T=S+(y<<15&4294967295|y>>>17),y=I+(S^(T|~_))+w[13]+1309151649&4294967295,I=T+(y<<21&4294967295|y>>>11),y=_+(T^(I|~S))+w[4]+4149444226&4294967295,_=I+(y<<6&4294967295|y>>>26),y=S+(I^(_|~T))+w[11]+3174756917&4294967295,S=_+(y<<10&4294967295|y>>>22),y=T+(_^(S|~I))+w[2]+718787259&4294967295,T=S+(y<<15&4294967295|y>>>17),y=I+(S^(T|~_))+w[9]+3951481745&4294967295,E.g[0]=E.g[0]+_&4294967295,E.g[1]=E.g[1]+(T+(y<<21&4294967295|y>>>11))&4294967295,E.g[2]=E.g[2]+T&4294967295,E.g[3]=E.g[3]+S&4294967295}n.prototype.v=function(E,_){_===void 0&&(_=E.length);const I=_-this.blockSize,w=this.C;let T=this.h,S=0;for(;S<_;){if(T==0)for(;S<=I;)s(this,E,S),S+=this.blockSize;if(typeof E=="string"){for(;S<_;)if(w[T++]=E.charCodeAt(S++),T==this.blockSize){s(this,w),T=0;break}}else for(;S<_;)if(w[T++]=E[S++],T==this.blockSize){s(this,w),T=0;break}}this.h=T,this.o+=_},n.prototype.A=function(){var E=Array((this.h<56?this.blockSize:this.blockSize*2)-this.h);E[0]=128;for(var _=1;_<E.length-8;++_)E[_]=0;_=this.o*8;for(var I=E.length-8;I<E.length;++I)E[I]=_&255,_/=256;for(this.v(E),E=Array(16),_=0,I=0;I<4;++I)for(let w=0;w<32;w+=8)E[_++]=this.g[I]>>>w&255;return E};function i(E,_){var I=u;return Object.prototype.hasOwnProperty.call(I,E)?I[E]:I[E]=_(E)}function o(E,_){this.h=_;const I=[];let w=!0;for(let T=E.length-1;T>=0;T--){const S=E[T]|0;w&&S==_||(I[T]=S,w=!1)}this.g=I}var u={};function c(E){return-128<=E&&E<128?i(E,function(_){return new o([_|0],_<0?-1:0)}):new o([E|0],E<0?-1:0)}function h(E){if(isNaN(E)||!isFinite(E))return m;if(E<0)return x(h(-E));const _=[];let I=1;for(let w=0;E>=I;w++)_[w]=E/I|0,I*=4294967296;return new o(_,0)}function f(E,_){if(E.length==0)throw Error("number format error: empty string");if(_=_||10,_<2||36<_)throw Error("radix out of range: "+_);if(E.charAt(0)=="-")return x(f(E.substring(1),_));if(E.indexOf("-")>=0)throw Error('number format error: interior "-" character');const I=h(Math.pow(_,8));let w=m;for(let S=0;S<E.length;S+=8){var T=Math.min(8,E.length-S);const y=parseInt(E.substring(S,S+T),_);T<8?(T=h(Math.pow(_,T)),w=w.j(T).add(h(y))):(w=w.j(I),w=w.add(h(y)))}return w}var m=c(0),p=c(1),v=c(16777216);r=o.prototype,r.m=function(){if(D(this))return-x(this).m();let E=0,_=1;for(let I=0;I<this.g.length;I++){const w=this.i(I);E+=(w>=0?w:4294967296+w)*_,_*=4294967296}return E},r.toString=function(E){if(E=E||10,E<2||36<E)throw Error("radix out of range: "+E);if(C(this))return"0";if(D(this))return"-"+x(this).toString(E);const _=h(Math.pow(E,6));var I=this;let w="";for(;;){const T=Y(I,_).g;I=B(I,T.j(_));let S=((I.g.length>0?I.g[0]:I.h)>>>0).toString(E);if(I=T,C(I))return S+w;for(;S.length<6;)S="0"+S;w=S+w}},r.i=function(E){return E<0?0:E<this.g.length?this.g[E]:this.h};
382function C(E){if(E.h!=0)return!1;for(let _=0;_<E.g.length;_++)if(E.g[_]!=0)return!1;return!0}function D(E){return E.h==-1}r.l=function(E){return E=B(this,E),D(E)?-1:C(E)?0:1};function x(E){const _=E.g.length,I=[];for(let w=0;w<_;w++)I[w]=~E.g[w];return new o(I,~E.h).add(p)}r.abs=function(){return D(this)?x(this):this},r.add=function(E){const _=Math.max(this.g.length,E.g.length),I=[];let w=0;for(let T=0;T<=_;T++){let S=w+(this.i(T)&65535)+(E.i(T)&65535),y=(S>>>16)+(this.i(T)>>>16)+(E.i(T)>>>16);w=y>>>16,S&=65535,y&=65535,I[T]=y<<16|S}return new o(I,I[I.length-1]&-2147483648?-1:0)};function B(E,_){return E.add(x(_))}r.j=function(E){if(C(this)||C(E))return m;if(D(this))return D(E)?x(this).j(x(E)):x(x(this).j(E));if(D(E))return x(this.j(x(E)));if(this.l(v)<0&&E.l(v)<0)return h(this.m()*E.m());const _=this.g.length+E.g.length,I=[];for(var w=0;w<2*_;w++)I[w]=0;for(w=0;w<this.g.length;w++)for(let T=0;T<E.g.length;T++){const S=this.i(w)>>>16,y=this.i(w)&65535,Ot=E.i(T)>>>16,He=E.i(T)&65535;I[2*w+2*T]+=y*He,j(I,2*w+2*T),I[2*w+2*T+1]+=S*He,j(I,2*w+2*T+1),I[2*w+2*T+1]+=y*Ot,j(I,2*w+2*T+1),I[2*w+2*T+2]+=S*Ot,j(I,2*w+2*T+2)}for(E=0;E<_;E++)I[E]=I[2*E+1]<<16|I[2*E];for(E=_;E<2*_;E++)I[E]=0;return new o(I,0)};function j(E,_){for(;(E[_]&65535)!=E[_];)E[_+1]+=E[_]>>>16,E[_]&=65535,_++}function U(E,_){this.g=E,this.h=_}function Y(E,_){if(C(_))throw Error("division by zero");if(C(E))return new U(m,m);if(D(E))return _=Y(x(E),_),new U(x(_.g),x(_.h));if(D(_))return _=Y(E,x(_)),new U(x(_.g),_.h);if(E.g.length>30){if(D(E)||D(_))throw Error("slowDivide_ only works with positive integers.");for(var I=p,w=_;w.l(E)<=0;)I=Z(I),w=Z(w);var T=H(I,1),S=H(w,1);for(w=H(w,2),I=H(I,2);!C(w);){var y=S.add(w);y.l(E)<=0&&(T=T.add(I),S=y),w=H(w,1),I=H(I,1)}return _=B(E,T.j(_)),new U(T,_)}for(T=m;E.l(_)>=0;){for(I=Math.max(1,Math.floor(E.m()/_.m())),w=Math.ceil(Math.log(I)/Math.LN2),w=w<=48?1:Math.pow(2,w-48),S=h(I),y=S.j(_);D(y)||y.l(E)>0;)I-=w,S=h(I),y=S.j(_);C(S)&&(S=p),T=T.add(S),E=B(E,y)}return new U(T,E)}r.B=function(E){return Y(this,E).h},r.and=function(E){const _=Math.max(this.g.length,E.g.length),I=[];for(let w=0;w<_;w++)I[w]=this.i(w)&E.i(w);return new o(I,this.h&E.h)},r.or=function(E){const _=Math.max(this.g.length,E.g.length),I=[];for(let w=0;w<_;w++)I[w]=this.i(w)|E.i(w);return new o(I,this.h|E.h)},r.xor=function(E){const _=Math.max(this.g.length,E.g.length),I=[];for(let w=0;w<_;w++)I[w]=this.i(w)^E.i(w);return new o(I,this.h^E.h)};function Z(E){const _=E.g.length+1,I=[];for(let w=0;w<_;w++)I[w]=E.i(w)<<1|E.i(w-1)>>>31;return new o(I,E.h)}function H(E,_){const I=_>>5;_%=32;const w=E.g.length-I,T=[];for(let S=0;S<w;S++)T[S]=_>0?E.i(S+I)>>>_|E.i(S+I+1)<<32-_:E.i(S+I);return new o(T,E.h)}n.prototype.digest=n.prototype.A,n.prototype.reset=n.prototype.u,n.prototype.update=n.prototype.v,Nh=n,o.prototype.add=o.prototype.add,o.prototype.multiply=o.prototype.j,o.prototype.modulo=o.prototype.B,o.prototype.compare=o.prototype.l,o.prototype.toNumber=o.prototype.m,o.prototype.toString=o.prototype.toString,o.prototype.getBits=o.prototype.i,o.fromNumber=h,o.fromString=f,Ce=o}).apply(typeof Wc<"u"?Wc:typeof self<"u"?self:typeof window<"u"?window:{});var Js=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/** @license
383Copyright The Closure Library Authors.
384SPDX-License-Identifier: Apache-2.0
385*/var kh,$r,Mh,si,Xo,Oh,Fh,Lh;(function(){var r,t=Object.defineProperty;function e(a){a=[typeof globalThis=="object"&&globalThis,a,typeof window=="object"&&window,typeof self=="object"&&self,typeof Js=="object"&&Js];for(var l=0;l<a.length;++l){var d=a[l];if(d&&d.Math==Math)return d}throw Error("Cannot find global object")}var n=e(this);function s(a,l){if(l)t:{var d=n;a=a.split(".");for(var g=0;g<a.length-1;g++){var b=a[g];if(!(b in d))break t;d=d[b]}a=a[a.length-1],g=d[a],l=l(g),l!=g&&l!=null&&t(d,a,{configurable:!0,writable:!0,value:l})}}s("Symbol.dispose",function(a){return a||Symbol("Symbol.dispose")}),s("Array.prototype.values",function(a){return a||function(){return this[Symbol.iterator]()}}),s("Object.entries",function(a){return a||function(l){var d=[],g;for(g in l)Object.prototype.hasOwnProperty.call(l,g)&&d.push([g,l[g]]);return d}});/** @license
386
387 Copyright The Closure Library Authors.
388 SPDX-License-Identifier: Apache-2.0
389*/var i=i||{},o=this||self;function u(a){var l=typeof a;return l=="object"&&a!=null||l=="function"}function c(a,l,d){return a.call.apply(a.bind,arguments)}function h(a,l,d){return h=c,h.apply(null,arguments)}
389function f(a,l){var d=Array.prototype.slice.call(arguments,1);return function(){var g=d.slice();return g.push.apply(g,arguments),a.apply(this,g)}}function m(a,l){function d(){}d.prototype=l.prototype,a.Z=l.prototype,a.prototype=new d,a.prototype.constructor=a,a.Ob=function(g,b,P){for(var O=Array(arguments.length-2),$=2;$<arguments.length;$++)O[$-2]=arguments[$];return l.prototype[b].apply(g,O)}}var p=typeof AsyncContext<"u"&&typeof AsyncContext.Snapshot=="function"?a=>a&&AsyncContext.Snapshot.wrap(a):a=>a;function v(a){const l=a.length;if(l>0){const d=Array(l);for(let g=0;g<l;g++)d[g]=a[g];return d}return[]}function C(a,l){for(let g=1;g<arguments.length;g++){const b=arguments[g];var d=typeof b;if(d=d!="object"?d:b?Array.isArray(b)?"array":d:"null",d=="array"||d=="object"&&typeof b.length=="number"){d=a.length||0;const P=b.length||0;a.length=d+P;for(let O=0;O<P;O++)a[d+O]=b[O]}else a.push(b)}}class D{constructor(l,d){this.i=l,this.j=d,this.h=0,this.g=null}get(){let l;return this.h>0?(this.h--,l=this.g,this.g=l.next,l.next=null):l=this.i(),l}}function x(a){o.setTimeout(()=>{throw a},0)}function B(){var a=E;let l=null;return a.g&&(l=a.g,a.g=a.g.next,a.g||(a.h=null),l.next=null),l}class j{constructor(){this.h=this.g=null}add(l,d){const g=U.get();g.set(l,d),this.h?this.h.next=g:this.g=g,this.h=g}}var U=new D(()=>new Y,a=>a.reset());class Y{constructor(){this.next=this.g=this.h=null}set(l,d){this.h=l,this.g=d,this.next=null}reset(){this.next=this.g=this.h=null}}let Z,H=!1,E=new j,_=()=>{const a=Promise.resolve(void 0);Z=()=>{a.then(I)}};function I(){for(var a;a=B();){try{a.h.call(a.g)}catch(d){x(d)}var l=U;l.j(a),l.h<100&&(l.h++,a.next=l.g,l.g=a)}H=!1}function w(){this.u=this.u,this.C=this.C}w.prototype.u=!1,w.prototype.dispose=function(){this.u||(this.u=!0,this.N())},w.prototype[Symbol.dispose]=function(){this.dispose()},w.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()};function T(a,l){this.type=a,this.g=this.target=l,this.defaultPrevented=!1}T.prototype.h=function(){this.defaultPrevented=!0};var S=function(){if(!o.addEventListener||!Object.defineProperty)return!1;var a=!1,l=Object.defineProperty({},"passive",{get:function(){a=!0}});try{const d=()=>{};o.addEventListener("test",d,l),o.removeEventListener("test",d,l)}catch{}return a}();function y(a){return/^[\s\xa0]*$/.test(a)}function Ot(a,l){T.call(this,a?a.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,a&&this.init(a,l)}m(Ot,T),Ot.prototype.init=function(a,l){const d=this.type=a.type,g=a.changedTouches&&a.changedTouches.length?a.changedTouches[0]:null;this.target=a.target||a.srcElement,this.g=l,l=a.relatedTarget,l||(d=="mouseover"?l=a.fromElement:d=="mouseout"&&(l=a.toElement)),this.relatedTarget=l,g?(this.clientX=g.clientX!==void 0?g.clientX:g.pageX,this.clientY=g.clientY!==void 0?g.clientY:g.pageY,this.screenX=g.screenX||0,this.screenY=g.screenY||0):(this.clientX=a.clientX!==void 0?a.clientX:a.pageX,this.clientY=a.clientY!==void 0?a.clientY:a.pageY,this.screenX=a.screenX||0,this.screenY=a.screenY||0),this.button=a.button,this.key=a.key||"",this.ctrlKey=a.ctrlKey,this.altKey=a.altKey,this.shiftKey=a.shiftKey,this.metaKey=a.metaKey,this.pointerId=a.pointerId||0,this.pointerType=a.pointerType,this.state=a.state,this.i=a,a.defaultPrevented&&Ot.Z.h.call(this)},Ot.prototype.h=function(){Ot.Z.h.call(this);const a=this.i;a.preventDefault?a.preventDefault():a.returnValue=!1};var He="closure_listenable_"+(Math.random()*1e6|0),Dm=0;function xm(a,l,d,g,b){this.listener=a,this.proxy=null,this.src=l,this.type=d,this.capture=!!g,this.ha=b,this.key=++Dm,this.da=this.fa=!1}function Ms(a){a.da=!0,a.listener=null,a.proxy=null,a.src=null,a.ha=null}function Os(a,l,d){for(const g in a)l.call(d,a[g],g,a)}function Nm(a,l){for(const d in a)l.call(void 0,a[d],d,a)}function Ou(a){const l={};for(const d in a)l[d]=a[d];return l}const Fu="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleStr
389ing toString valueOf".split(" ");function Lu(a,l){let d,g;for(let b=1;b<arguments.length;b++){g=arguments[b];for(d in g)a[d]=g[d];for(let P=0;P<Fu.length;P++)d=Fu[P],Object.prototype.hasOwnProperty.call(g,d)&&(a[d]=g[d])}}function Fs(a){this.src=a,this.g={},this.h=0}Fs.prototype.add=function(a,l,d,g,b){const P=a.toString();a=this.g[P],a||(a=this.g[P]=[],this.h++);const O=co(a,l,g,b);return O>-1?(l=a[O],d||(l.fa=!1)):(l=new xm(l,this.src,P,!!g,b),l.fa=d,a.push(l)),l};function uo(a,l){const d=l.type;if(d in a.g){var g=a.g[d],b=Array.prototype.indexOf.call(g,l,void 0),P;(P=b>=0)&&Array.prototype.splice.call(g,b,1),P&&(Ms(l),a.g[d].length==0&&(delete a.g[d],a.h--))}}function co(a,l,d,g){for(let b=0;b<a.length;++b){const P=a[b];if(!P.da&&P.listener==l&&P.capture==!!d&&P.ha==g)return b}return-1}var lo="closure_lm_"+(Math.random()*1e6|0),ho={};function Bu(a,l,d,g,b){if(Array.isArray(l)){for(let P=0;P<l.length;P++)Bu(a,l[P],d,g,b);return null}return d=ju(d),a&&a[He]?a.J(l,d,u(g)?!!g.capture:!1,b):km(a,l,d,!1,g,b)}function km(a,l,d,g,b,P){if(!l)throw Error("Invalid event type");const O=u(b)?!!b.capture:!!b;let $=mo(a);if($||(a[lo]=$=new Fs(a)),d=$.add(l,d,g,O,P),d.proxy)return d;if(g=Mm(),d.proxy=g,g.src=a,g.listener=d,a.addEventListener)S||(b=O),b===void 0&&(b=!1),a.addEventListener(l.toString(),g,b);else if(a.attachEvent)a.attachEvent(qu(l.toString()),g);else if(a.addListener&&a.removeListener)a.addListener(g);else throw Error("addEventListener and attachEvent are unavailable.");return d}function Mm(){function a(d){return l.call(a.src,a.listener,d)}const l=Om;return a}function Uu(a,l,d,g,b){if(Array.isArray(l))for(var P=0;P<l.length;P++)Uu(a,l[P],d,g,b);else g=u(g)?!!g.capture:!!g,d=ju(d),a&&a[He]?(a=a.i,P=String(l).toString(),P in a.g&&(l=a.g[P],d=co(l,d,g,b),d>-1&&(Ms(l[d]),Array.prototype.splice.call(l,d,1),l.length==0&&(delete a.g[P],a.h--)))):a&&(a=mo(a))&&(l=a.g[l.toString()],a=-1,l&&(a=co(l,d,g,b)),(d=a>-1?l[a]:null)&&fo(d))}function fo(a){if(typeof a!="number"&&a&&!a.da){var l=a.src;if(l&&l[He])uo(l.i,a);else{var d=a.type,g=a.proxy;l.removeEventListener?l.removeEventListener(d,g,a.capture):l.detachEvent?l.detachEvent(qu(d),g):l.addListener&&l.removeListener&&l.removeListener(g),(d=mo(l))?(uo(d,a),d.h==0&&(d.src=null,l[lo]=null)):Ms(a)}}}function qu(a){return a in ho?ho[a]:ho[a]="on"+a}function Om(a,l){if(a.da)a=!0;else{l=new Ot(l,this);const d=a.listener,g=a.ha||a.src;a.fa&&fo(a),a=d.call(g,l)}return a}function mo(a){return a=a[lo],a instanceof Fs?a:null}var go="__closure_events_fn_"+(Math.random()*1e9>>>0);function ju(a){return typeof a=="function"?a:(a[go]||(a[go]=function(l){return a.handleEvent(l)}),a[go])}function Vt(){w.call(this),this.i=new Fs(this),this.M=this,this.G=null}m(Vt,w),Vt.prototype[He]=!0,Vt.prototype.removeEventListener=function(a,l,d,g){Uu(this,a,l,d,g)};function kt(a,l){var d,g=a.G;if(g)for(d=[];g;g=g.G)d.push(g);if(a=a.M,g=l.type||l,typeof l=="string")l=new T(l,a);else if(l instanceof T)l.target=l.target||a;else{var b=l;l=new T(g,a),Lu(l,b)}b=!0;let P,O;if(d)for(O=d.length-1;O>=0;O--)P=l.g=d[O],b=Ls(P,g,!0,l)&&b;if(P=l.g=a,b=Ls(P,g,!0,l)&&b,b=Ls(P,g,!1,l)&&b,d)for(O=0;O<d.length;O++)P=l.g=d[O],b=Ls(P,g,!1,l)&&b}Vt.prototype.N=function(){if(Vt.Z.N.call(this),this.i){var a=this.i;for(const l in a.g){const d=a.g[l];for(let g=0;g<d.length;
389g++)Ms(d[g]);delete a.g[l],a.h--}}this.G=null},Vt.prototype.J=function(a,l,d,g){return this.i.add(String(a),l,!1,d,g)},Vt.prototype.K=function(a,l,d,g){return this.i.add(String(a),l,!0,d,g)};function Ls(a,l,d,g){if(l=a.i.g[String(l)],!l)return!0;l=l.concat();let b=!0;for(let P=0;P<l.length;++P){const O=l[P];if(O&&!O.da&&O.capture==d){const $=O.listener,It=O.ha||O.src;O.fa&&uo(a.i,O),b=$.call(It,g)!==!1&&b}}return b&&!g.defaultPrevented}function Fm(a,l){if(typeof a!="function")if(a&&typeof a.handleEvent=="function")a=h(a.handleEvent,a);else throw Error("Invalid listener argument");return Number(l)>2147483647?-1:o.setTimeout(a,l||0)}function zu(a){a.g=Fm(()=>{a.g=null,a.i&&(a.i=!1,zu(a))},a.l);const l=a.h;a.h=null,a.m.apply(null,l)}class Lm extends w{constructor(l,d){super(),this.m=l,this.l=d,this.h=null,this.i=!1,this.g=null}j(l){this.h=arguments,this.g?this.i=!0:zu(this)}N(){super.N(),this.g&&(o.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function vr(a){w.call(this),this.h=a,this.g={}}m(vr,w);var Gu=[];function $u(a){Os(a.g,function(l,d){this.g.hasOwnProperty(d)&&fo(l)},a),a.g={}}vr.prototype.N=function(){vr.Z.N.call(this),$u(this)},vr.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var po=o.JSON.stringify,Bm=o.JSON.parse,Um=class{stringify(a){return o.JSON.stringify(a,void 0)}parse(a){return o.JSON.parse(a,void 0)}};function Ku(){}function Qu(){}var br={OPEN:"a",hb:"b",ERROR:"c",tb:"d"};function _o(){T.call(this,"d")}m(_o,T);function yo(){T.call(this,"c")}m(yo,T);var Je={},Wu=null;function Bs(){return Wu=Wu||new Vt}Je.Ia="serverreachability";function Hu(a){T.call(this,Je.Ia,a)}m(Hu,T);function Rr(a){const l=Bs();kt(l,new Hu(l))}Je.STAT_EVENT="statevent";function Ju(a,l){T.call(this,Je.STAT_EVENT,a),this.stat=l}m(Ju,T);function Mt(a){const l=Bs();kt(l,new Ju(l,a))}Je.Ja="timingevent";function Xu(a,l){T.call(this,Je.Ja,a),this.size=l}m(Xu,T);function Sr(a,l){if(typeof a!="function")throw Error("Fn must not be null and must be a function");return o.setTimeout(function(){a()},l)}function Pr(){this.g=!0}Pr.prototype.ua=function(){this.g=!1};function qm(a,l,d,g,b,P){a.info(function(){if(a.g)if(P){var O="",$=P.split("&");for(let it=0;it<$.length;it++){var It=$[it].split("=");if(It.length>1){const At=It[0];It=It[1];const Yt=At.split("_");O=Yt.length>=2&&Yt[1]=="type"?O+(At+"="+It+"&"):O+(At+"=redacted&")}}}else O=null;else O=P;return"XMLHTTP REQ ("+g+") [attempt "+b+"]: "+l+`
390`+d+`
391`+O})}function jm(a,l,d,g,b,P,O){a.info(function(){return"XMLHTTP RESP ("+g+") [ attempt "+b+"]: "+l+`
392`+d+`
393`+P+" "+O})}function Pn(a,l,d,g){a.info(function(){return"XMLHTTP TEXT ("+l+"): "+Gm(a,d)+(g?" "+g:"")})}function zm(a,l){a.info(function(){return"TIMEOUT: "+l})}Pr.prototype.info=function(){};function Gm(a,l){if(!a.g)return l;if(!l)return null;try{const P=JSON.parse(l);if(P){for(a=0;a<P.length;a++)if(Array.isArray(P[a])){var d=P[a];if(!(d.length<2)){var g=d[1];if(Array.isArray(g)&&!(g.length<1)){var b=g[0];if(b!="noop"&&b!="stop"&&b!="close")for(let O=1;O<g.length;O++)g[O]=""}}}}return po(P)}catch{return l}}var Us={NO_ERROR:0,cb:1,qb:2,pb:3,kb:4,ob:5,rb:6,Ga:7,TIMEOUT:8,ub:9},Yu={ib:"complete",Fb:"success",ERROR:"error",Ga:"abort",xb:"ready",yb:"readystatechange",TIMEOUT:"timeout",sb:"incrementaldata",wb:"progress",lb:"downloadprogress",Nb:"uploadprogress"},Zu;function Io(){}m(Io,Ku),Io.prototype.g=function(){return new XMLHttpRequest},Zu=new Io;function Vr(a){return encodeURIComponent(String(a))}function $m(a){var l=1;a=a.split(":");const d=[];for(;l>0&&a.length;)d.push(a.shift()),l--;return a.length&&d.push(a.join(":")),d}function ge(a,l,d,g){this.j=a,this.i=l,this.l=d,this.S=g||1,this.V=new vr(this),this.H=45e3,this.J=null,this.o=!1,this.u=this.B=this.A=this.M=this.F=this.T=this.D=null,this.G=[],this.g=null,this.C=0,this.m=this.v=null,this.X=-1,this.K=!1,this.P=0,this.O=null,this.W=this.L=this.U=this.R=!1,this.h=new tc}function tc(){this.i=null,this.g="",this.h=!1}var ec={},Eo={};function To(a,l,d){a.M=1,a.A=js(Xt(l)),a.u=d,a.R=!0,nc(a,null)}function nc(a,l){a.F=Date.now(),qs(a),a.B=Xt(a.A);var d=a.B,g=a.S;Array.isArray(g)||(g=[String(g)]),gc(d.i,"t",g),a.C=0,d=a.j.L,a.h=new tc,a.g=Nc(a.j,d?l:null,!a.u),a.P>0&&(a.O=new Lm(h(a.Y,a,a.g),a.P)),l=a.V,d=a.g,g=a.ba;var b="readystatechange";Array.isArray(b)||(b&&(Gu[0]=b.toString()),b=Gu);for(let P=0;P<b.length;P++){const O=Bu(d,b[P],g||l.handleEvent,!1,l.h||l);if(!O)break;l.g[O.key]=O}l=a.J?Ou(a.J):{}
393,a.u?(a.v||(a.v="POST"),l["Content-Type"]="application/x-www-form-urlencoded",a.g.ea(a.B,a.v,a.u,l)):(a.v="GET",a.g.ea(a.B,a.v,null,l)),Rr(),qm(a.i,a.v,a.B,a.l,a.S,a.u)}ge.prototype.ba=function(a){a=a.target;const l=this.O;l&&ye(a)==3?l.j():this.Y(a)},ge.prototype.Y=function(a){try{if(a==this.g)t:{const $=ye(this.g),It=this.g.ya(),it=this.g.ca();if(!($<3)&&($!=3||this.g&&(this.h.h||this.g.la()||wc(this.g)))){this.K||$!=4||It==7||(It==8||it<=0?Rr(3):Rr(2)),wo(this);var l=this.g.ca();this.X=l;var d=Km(this);if(this.o=l==200,jm(this.i,this.v,this.B,this.l,this.S,$,l),this.o){if(this.U&&!this.L){e:{if(this.g){var g,b=this.g;if((g=b.g?b.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!y(g)){var P=g;break e}}P=null}if(a=P)Pn(this.i,this.l,a,"Initial handshake response via X-HTTP-Initial-Response"),this.L=!0,Ao(this,a);else{this.o=!1,this.m=3,Mt(12),Xe(this),Cr(this);break t}}if(this.R){a=!0;let At;for(;!this.K&&this.C<d.length;)if(At=Qm(this,d),At==Eo){$==4&&(this.m=4,Mt(14),a=!1),Pn(this.i,this.l,null,"[Incomplete Response]");break}else if(At==ec){this.m=4,Mt(15),Pn(this.i,this.l,d,"[Invalid Chunk]"),a=!1;break}else Pn(this.i,this.l,At,null),Ao(this,At);if(rc(this)&&this.C!=0&&(this.h.g=this.h.g.slice(this.C),this.C=0),$!=4||d.length!=0||this.h.h||(this.m=1,Mt(16),a=!1),this.o=this.o&&a,!a)Pn(this.i,this.l,d,"[Invalid Chunked Response]"),Xe(this),Cr(this);else if(d.length>0&&!this.W){this.W=!0;var O=this.j;O.g==this&&O.aa&&!O.P&&(O.j.info("Great, no buffering proxy detected. Bytes received: "+d.length),Do(O),O.P=!0,Mt(11))}}else Pn(this.i,this.l,d,null),Ao(this,d);$==4&&Xe(this),this.o&&!this.K&&($==4?Vc(this.j,this):(this.o=!1,qs(this)))}else ag(this.g),l==400&&d.indexOf("Unknown SID")>0?(this.m=3,Mt(12)):(this.m=0,Mt(13)),Xe(this),Cr(this)}}}catch{}finally{}};function Km(a){if(!rc(a))return a.g.la();const l=wc(a.g);if(l==="")return"";let d="";const g=l.length,b=ye(a.g)==4;if(!a.h.i){if(typeof TextDecoder>"u")return Xe(a),Cr(a),"";a.h.i=new o.TextDecoder}for(let P=0;P<g;P++)a.h.h=!0,d+=a.h.i.decode(l[P],{stream:!(b&&P==g-1)});return l.length=0,a.h.g+=d,a.C=0,a.h.g}function rc(a){return a.g?a.v=="GET"&&a.M!=2&&a.j.Aa:!1}function Qm(a,l){var d=a.C,g=l.indexOf(`
394`,d);return g==-1?Eo:(d=Number(l.substring(d,g)),isNaN(d)?ec:(g+=1,g+d>l.length?Eo:(l=l.slice(g,g+d),a.C=g+d,l)))}ge.prototype.cancel=function(){this.K=!0,Xe(this)};function qs(a){a.T=Date.now()+a.H,sc(a,a.H)}function sc(a,l){if(a.D!=null)throw Error("WatchDog timer not null");a.D=Sr(h(a.aa,a),l)}function wo(a){a.D&&(o.clearTimeout(a.D),a.D=null)}ge.prototype.aa=function(){this.D=null;const a=Date.now();a-this.T>=0?(zm(this.i,this.B),this.M!=2&&(Rr(),Mt(17)),Xe(this),this.m=2,Cr(this)):sc(this,this.T-a)};function Cr(a){a.j.I==0||a.K||Vc(a.j,a)}function Xe(a){wo(a);var l=a.O;l&&typeof l.dispose=="function"&&l.dispose(),a.O=null,$u(a.V),a.g&&(l=a.g,a.g=null,l.abort(),l.dispose())}function Ao(a,l){try{var d=a.j;if(d.I!=0&&(d.g==a||vo(d.h,a))){if(!a.L&&vo(d.h,a)&&d.I==3){try{var g=d.Ba.g.parse(l)}catch{g=null}if(Array.isArray(g)&&g.length==3){var b=g;if(b[0]==0){t:if(!d.v){if(d.g)if(d.g.F+3e3<a.F)Qs(d),$s(d);else break t;Co(d),Mt(18)}}else d.xa=b[1],0<d.xa-d.K&&b[2]<37500&&d.F&&d.A==0&&!d.C&&(d.C=Sr(h(d.Va,d),6e3));ac(d.h)<=1&&d.ta&&(d.ta=void 0)}else Ze(d,11)}else if((a.L||d.g==a)&&Qs(d),!y(l))for(b=d.Ba.g.parse(l),l=0;l<b.length;l++){let it=b[l];const At=it[0];if(!(At<=d.K))if(d.K=At,it=it[1],d.I==2)if(it[0]=="c"){d.M=it[1],d.ba=it[2];const Yt=it[3];Yt!=null&&(d.ka=Yt,d.j.info("VER="+d.ka));const tn=it[4];tn!=null&&(d.za=tn,d.j.info("SVER="+d.za));const Ie=it[5];Ie!=null&&typeof Ie=="number"&&Ie>0&&(g=1.5*Ie,d.O=g,d.j.info("backChannelRequestTimeoutMs_="+g)),g=d;const Ee=a.g;if(Ee){const Hs=Ee.g?Ee.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(Hs){var P=g.h;P.g||Hs.indexOf("spdy")==-1&&Hs.indexOf("quic")==-1&&Hs.indexOf("h2")==-1||(P.j=P.l,P.g=new Set,P.h&&(bo(P,P.h),P.h=null))}if(g.G){const xo=Ee.g?Ee.g.getResponseHeader("X-HTTP-Session-Id"):null;xo&&(g.wa=xo,at(g.J,g.G,xo))}}d.I=3,d.l&&d.l.ra(),d.aa&&(d.T=Date.now()-a.F,d.j.info("Handshake RTT: "+d.T+"ms")),g=d;var O=a;if(g.na=xc(g,g.L?g.ba:null,g.W),O.L){uc(g.h,O);var $=O,It=g.O;It&&($.H=It),$.D&&(wo($),qs($)),g.g=O}else Sc(g);d.i.length>0&&Ks(d)}else it[0]!="stop"&&it[0]!="close"||Ze(d,7);else d.I==3&&(it[0]=="stop"||it[0]=="close"?it[0]=="stop"?Ze(d,7):Vo(d):it[0]!="noop"&&d.l&&d.l.qa(it),d.A=0)}}Rr(4)}catch{}}var Wm=class{constructor(a,l){this.g=a,this.map=l}};function ic(a){this.l=a||10,o.PerformanceNavigationTiming?(a=o.performance.getEntriesByType("navigation"),a=a.length>
3940&&(a[0].nextHopProtocol=="hq"||a[0].nextHopProtocol=="h2")):a=!!(o.chrome&&o.chrome.loadTimes&&o.chrome.loadTimes()&&o.chrome.loadTimes().wasFetchedViaSpdy),this.j=a?this.l:1,this.g=null,this.j>1&&(this.g=new Set),this.h=null,this.i=[]}function oc(a){return a.h?!0:a.g?a.g.size>=a.j:!1}function ac(a){return a.h?1:a.g?a.g.size:0}function vo(a,l){return a.h?a.h==l:a.g?a.g.has(l):!1}function bo(a,l){a.g?a.g.add(l):a.h=l}function uc(a,l){a.h&&a.h==l?a.h=null:a.g&&a.g.has(l)&&a.g.delete(l)}ic.prototype.cancel=function(){if(this.i=cc(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&this.g.size!==0){for(const a of this.g.values())a.cancel();this.g.clear()}};function cc(a){if(a.h!=null)return a.i.concat(a.h.G);if(a.g!=null&&a.g.size!==0){let l=a.i;for(const d of a.g.values())l=l.concat(d.G);return l}return v(a.i)}var lc=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function Hm(a,l){if(a){a=a.split("&");for(let d=0;d<a.length;d++){const g=a[d].indexOf("=");let b,P=null;g>=0?(b=a[d].substring(0,g),P=a[d].substring(g+1)):b=a[d],l(b,P?decodeURIComponent(P.replace(/\+/g," ")):"")}}}function pe(a){this.g=this.o=this.j="",this.u=null,this.m=this.h="",this.l=!1;let l;a instanceof pe?(this.l=a.l,Dr(this,a.j),this.o=a.o,this.g=a.g,xr(this,a.u),this.h=a.h,Ro(this,pc(a.i)),this.m=a.m):a&&(l=String(a).match(lc))?(this.l=!1,Dr(this,l[1]||"",!0),this.o=Nr(l[2]||""),this.g=Nr(l[3]||"",!0),xr(this,l[4]),this.h=Nr(l[5]||"",!0),Ro(this,l[6]||"",!0),this.m=Nr(l[7]||"")):(this.l=!1,this.i=new Mr(null,this.l))}pe.prototype.toString=function(){const a=[];var l=this.j;l&&a.push(kr(l,hc,!0),":");var d=this.g;return(d||l=="file")&&(a.push("//"),(l=this.o)&&a.push(kr(l,hc,!0),"@"),a.push(Vr(d).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),d=this.u,d!=null&&a.push(":",String(d))),(d=this.h)&&(this.g&&d.charAt(0)!="/"&&a.push("/"),a.push(kr(d,d.charAt(0)=="/"?Ym:Xm,!0))),(d=this.i.toString())&&a.push("?",d),(d=this.m)&&a.push("#",kr(d,tg)),a.join("")},pe.prototype.resolve=function(a){const l=Xt(this);let d=!!a.j;d?Dr(l,a.j):d=!!a.o,d?l.o=a.o:d=!!a.g,d?l.g=a.g:d=a.u!=null;var g=a.h;if(d)xr(l,a.u);else if(d=!!a.h){if(g.charAt(0)!="/")if(this.g&&!this.h)g="/"+g;else{var b=l.h.lastIndexOf("/");b!=-1&&(g=l.h.slice(0,b+1)+g)}if(b=g,b==".."||b==".")g="";else if(b.indexOf("./")!=-1||b.indexOf("/.")!=-1){g=b.lastIndexOf("/",0)==0,b=b.split("/");const P=[];for(let O=0;O<b.length;){const $=b[O++];$=="."?g&&O==b.length&&P.push(""):$==".."?((P.length>1||P.length==1&&P[0]!="")&&P.pop(),g&&O==b.length&&P.push("")):(P.push($),g=!0)}g=P.join("/")}else g=b}return d?l.h=g:d=a.i.toString()!=="",d?Ro(l,pc(a.i)):d=!!a.m,d&&(l.m=a.m),l};function Xt(a){return new pe(a)}function Dr(a,l,d){a.j=d?Nr(l,!0):l,a.j&&(a.j=a.j.replace(/:$/,""))}function xr(a,l){if(l){if(l=Number(l),isNaN(l)||l<0)throw Error("Bad port number "+l);a.u=l}else a.u=null}function Ro(a,l,d){l instanceof Mr?(a.i=l,eg(a.i,a.l)):(d||(l=kr(l,Zm)),a.i=new Mr(l,a.l))}function at(a,l,d){a.i.set(l,d)}function js(a){return at(a,"zx",Math.floor(Math.random()*2147483648).toString(36)+Math.abs(Math.floor(Math.random()*2147483648)^Date.now()).toString(36)),a}function Nr(a,l){return a?l?decodeURI(a.replace(/%25/g,"%2525")):decodeURIComponent(a):""}function kr(a,l,d){return typeof a=="string"?(a=encodeURI(a).replace(l,Jm),d&&(a=a.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),a):null}function Jm(a){return a=a.charCodeAt(0),"%"+(a>>4&15).toString(16)+(a&15).toString(16)}var hc=/[#\/\?@]/g,Xm=/[#\?:]/g,Ym=/[#\?]/g,Zm=/[#\?@]/g,tg=/#/g;function Mr(a,l){this.h=this.g=null,this.i=a||null,this.j=!!l}function Ye(a){a.g||(a.g=new Map,a.h=0,a.i&&Hm(a.i,function(l,d){a.add(decodeURIComponent(l.replace(/\+/g," ")),d)}))}r=Mr.prototype,r.add=function(a,l){Ye(this),this.i=null,a=Vn(this,a);let d=this.g.get(a);return d||this.g.set(a,d=[]),d.push(l),this.h+=1,this};function dc(a,l){Ye(a),l=Vn(a,l),a.g.has(l)&&(a.i=null,a.h-=a.g.get(l).length,a.g.delete(l))}function fc(a,l){return Ye(a),l=Vn(a,l),a.g.has(l)}r.forEach=function(a,l){Ye(this),this.g.forEach(function(d,g){d.forEach(function(b){a.call(l,b,g,this)},this)},this)};function mc(a,l){Ye(a);let d=[];if(typeof l=="string")fc(a,l)&&(d=d.concat(a.g.get(Vn(a,l))));else for(a=Array.from(a.g.values()),l=0;l<a.length;l++)d=d.concat(a[l]);return d}r.set=function(a,l){return Ye(this),this.i=null,a=Vn(this,a),fc(this,a)&&(this.h-=this.g.get(a).length),this.g.set(a,[l]),this.h+=1,this},r.get=function(a,l){return a?(a=mc(this,a),a.length>0?String(a[0]):l):l};function gc(a,l,d){dc(a,l),d.length>0&&(a.i=null,a.g.set(Vn(a,l),v(d)),a.h+=d.length)}r.toString=function(){if(this.i)return this.i;if(!this.g)return"";const a=[],l=Array.from(this.g.keys());for(let g=0;g<l.length;g++){var d=l[g];const b=Vr(d);d=mc(this,d);for(let P=0;P<d.length;P++){let O=b;d[P]!==""&&(O+="="+Vr(d[P])),a.push(O)}}return this.i=a.join("&")};function pc(a){const l=new Mr;return l.i=a.i,a.g&&(l.g=new Map(a.g),l.h=a.h),l}function Vn(a,l){return l=String(l),a.j&&(l=l.toLowerCase()),l}function eg(a,l){l&&!a.j&&(Ye(a),a.i=null,a.g.forEach(function(d,g){const b=g.toLowerCase();g!=b&&(dc(this,g),gc(this,b,d))},a)),a.j=l}function ng(a,l){const d=new Pr;if(o.Image){const g=new Image;g.onload=f(_e,d,"TestLoadImage: loaded",!0,l,g),g.onerror=f(_e,d,"TestLoadImage: error",!1,l,g),g.onabort=f(_e,d,"TestLoadImage: abort",!1,l,g),g.ontimeout=f(_e,d,"TestLoadImage: timeout",!1,l,g),o.setTimeout(function(){g.ontimeout&&g.ontimeout()},1e4),g.src=a}else l(!1)}function rg(a,l){const d=new Pr,g=new AbortController,b=setTimeout(()=>{g.abort(),_e(d,"TestPingServer: timeout",!1,l)},1e4);fetch(a,{signal:g.signal}).then(P=>{clearTimeout(b),P.ok?_e(d,"TestPingServer: ok",!0,l):_e(d,"TestPingServer: server error",!1,l)}
394).catch(()=>{clearTimeout(b),_e(d,"TestPingServer: error",!1,l)})}function _e(a,l,d,g,b){try{b&&(b.onload=null,b.onerror=null,b.onabort=null,b.ontimeout=null),g(d)}catch{}}function sg(){this.g=new Um}function So(a){this.i=a.Sb||null,this.h=a.ab||!1}m(So,Ku),So.prototype.g=function(){return new zs(this.i,this.h)};function zs(a,l){Vt.call(this),this.H=a,this.o=l,this.m=void 0,this.status=this.readyState=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.A=new Headers,this.h=null,this.F="GET",this.D="",this.g=!1,this.B=this.j=this.l=null,this.v=new AbortController}m(zs,Vt),r=zs.prototype,r.open=function(a,l){if(this.readyState!=0)throw this.abort(),Error("Error reopening a connection");this.F=a,this.D=l,this.readyState=1,Fr(this)},r.send=function(a){if(this.readyState!=1)throw this.abort(),Error("need to call open() first. ");if(this.v.signal.aborted)throw this.abort(),Error("Request was aborted.");this.g=!0;const l={headers:this.A,method:this.F,credentials:this.m,cache:void 0,signal:this.v.signal};a&&(l.body=a),(this.H||o).fetch(new Request(this.D,l)).then(this.Pa.bind(this),this.ga.bind(this))},r.abort=function(){this.response=this.responseText="",this.A=new Headers,this.status=0,this.v.abort(),this.j&&this.j.cancel("Request was aborted.").catch(()=>{}),this.readyState>=1&&this.g&&this.readyState!=4&&(this.g=!1,Or(this)),this.readyState=0},r.Pa=function(a){if(this.g&&(this.l=a,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=a.headers,this.readyState=2,Fr(this)),this.g&&(this.readyState=3,Fr(this),this.g)))if(this.responseType==="arraybuffer")a.arrayBuffer().then(this.Na.bind(this),this.ga.bind(this));else if(typeof o.ReadableStream<"u"&&"body"in a){if(this.j=a.body.getReader(),this.o){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.B=new TextDecoder;_c(this)}else a.text().then(this.Oa.bind(this),this.ga.bind(this))};function _c(a){a.j.read().then(a.Ma.bind(a)).catch(a.ga.bind(a))}r.Ma=function(a){if(this.g){if(this.o&&a.value)this.response.push(a.value);else if(!this.o){var l=a.value?a.value:new Uint8Array(0);(l=this.B.decode(l,{stream:!a.done}))&&(this.response=this.responseText+=l)}a.done?Or(this):Fr(this),this.readyState==3&&_c(this)}},r.Oa=function(a){this.g&&(this.response=this.responseText=a,Or(this))},r.Na=function(a){this.g&&(this.response=a,Or(this))},r.ga=function(){this.g&&Or(this)};function Or(a){a.readyState=4,a.l=null,a.j=null,a.B=null,Fr(a)}r.setRequestHeader=function(a,l){this.A.append(a,l)},r.getResponseHeader=function(a){return this.h&&this.h.get(a.toLowerCase())||""},r.getAllResponseHeaders=function(){if(!this.h)return"";const a=[],l=this.h.entries();for(var d=l.next();!d.done;)d=d.value,a.push(d[0]+": "+d[1]),d=l.next();return a.join(`\r
395`)};function Fr(a){a.onreadystatechange&&a.onreadystatechange.call(a)}Object.defineProperty(zs.prototype,"withCredentials",{get:function(){return this.m==="include"},set:function(a){this.m=a?"include":"same-origin"}});function yc(a){let l="";return Os(a,function(d,g){l+=g,l+=":",l+=d,l+=`\r
396`}),l}function Po(a,l,d){t:{for(g in d){var g=!1;break t}g=!0}g||(d=yc(d),typeof a=="string"?d!=null&&Vr(d):at(a,l,d))}function mt(a){Vt.call(this),this.headers=new Map,this.L=a||null,this.h=!1,this.g=null,this.D="",this.o=0,this.l="",this.j=this.B=this.v=this.A=!1,this.m=null,this.F="",this.H=!1}m(mt,Vt);var ig=/^https?$/i,og=["POST","PUT"];r=mt.prototype,r.Fa=function(a){this.H=a},r.ea=function(a,l,d,g){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.D+"; newUri="+a);l=l?l.toUpperCase():"GET",this.D=a,this.l="",this.o=0,this.A=!1,this.h=!0,this.g=this.L?this.L.g():Zu.g(),this.g.onreadystatechange=p(h(this.Ca,this));try{this.B=!0,this.g.open(l,String(a),!0),this.B=!1}catch(P){Ic(this,P);return}if(a=d||"",d=new Map(this.headers),g)if(Object.getPrototypeOf(g)===Object.prototype)for(var b in g)d.set(b,g[b]);else if(typeof g.keys=="function"&&typeof g.get=="function")for(const P of g.keys())d.set(P,g.get(P));else throw Error("Unknown input type for opt_headers: "+String(g));g=Array.from(d.keys()).find(P=>P.toLowerCase()=="content-type"),b=o.FormData&&a instanceof o.FormData,!(Array.prototype.indexOf.call(og,l,void 0)>=0)||g||b||d.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");for(const[P,O]of d)this.g.setRequestHeader(P,O);this.F&&(this.g.responseType=this.F),"withCredentials"in this.g&&this.g.withCredentials!==this.H&&(this.g.withCredentials=this.H);try{this.m&&(clearTimeout(this.m),this.m=null),this.v=!0,this.g.send(a),this.v=!1}catch(P){Ic(this,P)}};function Ic(a,l){a.h=!1,a.g&&(a.j=!0,a.g.abort(),a.j=!1),a.l=l,a.o=5,Ec(a),Gs(a)}
396function Ec(a){a.A||(a.A=!0,kt(a,"complete"),kt(a,"error"))}r.abort=function(a){this.g&&this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1,this.o=a||7,kt(this,"complete"),kt(this,"abort"),Gs(this))},r.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),Gs(this,!0)),mt.Z.N.call(this)},r.Ca=function(){this.u||(this.B||this.v||this.j?Tc(this):this.Xa())},r.Xa=function(){Tc(this)};function Tc(a){if(a.h&&typeof i<"u"){if(a.v&&ye(a)==4)setTimeout(a.Ca.bind(a),0);else if(kt(a,"readystatechange"),ye(a)==4){a.h=!1;try{const P=a.ca();t:switch(P){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var l=!0;break t;default:l=!1}var d;if(!(d=l)){var g;if(g=P===0){let O=String(a.D).match(lc)[1]||null;!O&&o.self&&o.self.location&&(O=o.self.location.protocol.slice(0,-1)),g=!ig.test(O?O.toLowerCase():"")}d=g}if(d)kt(a,"complete"),kt(a,"success");else{a.o=6;try{var b=ye(a)>2?a.g.statusText:""}catch{b=""}a.l=b+" ["+a.ca()+"]",Ec(a)}}finally{Gs(a)}}}}function Gs(a,l){if(a.g){a.m&&(clearTimeout(a.m),a.m=null);const d=a.g;a.g=null,l||kt(a,"ready");try{d.onreadystatechange=null}catch{}}}r.isActive=function(){return!!this.g};function ye(a){return a.g?a.g.readyState:0}r.ca=function(){try{return ye(this)>2?this.g.status:-1}catch{return-1}},r.la=function(){try{return this.g?this.g.responseText:""}catch{return""}},r.La=function(a){if(this.g){var l=this.g.responseText;return a&&l.indexOf(a)==0&&(l=l.substring(a.length)),Bm(l)}};function wc(a){try{if(!a.g)return null;if("response"in a.g)return a.g.response;switch(a.F){case"":case"text":return a.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in a.g)return a.g.mozResponseArrayBuffer}return null}catch{return null}}function ag(a){const l={};a=(a.g&&ye(a)>=2&&a.g.getAllResponseHeaders()||"").split(`\r
397`);for(let g=0;g<a.length;g++){if(y(a[g]))continue;var d=$m(a[g]);const b=d[0];if(d=d[1],typeof d!="string")continue;d=d.trim();const P=l[b]||[];l[b]=P,P.push(d)}Nm(l,function(g){return g.join(", ")})}r.ya=function(){return this.o},r.Ha=function(){return typeof this.l=="string"?this.l:String(this.l)};function Lr(a,l,d){return d&&d.internalChannelParams&&d.internalChannelParams[a]||l}function Ac(a){this.za=0,this.i=[],this.j=new Pr,this.ba=this.na=this.J=this.W=this.g=this.wa=this.G=this.H=this.u=this.U=this.o=null,this.Ya=this.V=0,this.Sa=Lr("failFast",!1,a),this.F=this.C=this.v=this.m=this.l=null,this.X=!0,this.xa=this.K=-1,this.Y=this.A=this.D=0,this.Qa=Lr("baseRetryDelayMs",5e3,a),this.Za=Lr("retryDelaySeedMs",1e4,a),this.Ta=Lr("forwardChannelMaxRetries",2,a),this.va=Lr("forwardChannelRequestTimeoutMs",2e4,a),this.ma=a&&a.xmlHttpFactory||void 0,this.Ua=a&&a.Rb||void 0,this.Aa=a&&a.useFetchStreams||!1,this.O=void 0,this.L=a&&a.supportsCrossDomainXhr||!1,this.M="",this.h=new ic(a&&a.concurrentRequestLimit),this.Ba=new sg,this.S=a&&a.fastHandshake||!1,this.R=a&&a.encodeInitMessageHeaders||!1,this.S&&this.R&&(this.R=!1),this.Ra=a&&a.Pb||!1,a&&a.ua&&this.j.ua(),a&&a.forceLongPolling&&(this.X=!1),this.aa=!this.S&&this.X&&a&&a.detectBufferingProxy||!1,this.ia=void 0,a&&a.longPollingTimeout&&a.longPollingTimeout>0&&(this.ia=a.longPollingTimeout),this.ta=void 0,this.T=0,this.P=!1,this.ja=this.B=null}r=Ac.prototype,r.ka=8,r.I=1,r.connect=function(a,l,d,g){Mt(0),this.W=a,this.H=l||{},d&&g!==void 0&&(this.H.OSID=d,this.H.OAID=g),this.F=this.X,this.J=xc(this,null,this.W),Ks(this)};function Vo(a){if(vc(a),a.I==3){var l=a.V++,d=Xt(a.J);if(at(d,"SID",a.M),at(d,"RID",l),at(d,"TYPE","terminate"),Br(a,d),l=new ge(a,a.j,l),l.M=2,l.A=js(Xt(d)),d=!1,o.navigator&&o.navigator.sendBeacon)try{d=o.navigator.sendBeacon(l.A.toString(),"")}catch{}!d&&o.Image&&(new Image().src=l.A,d=!0),d||(l.g=Nc(l.j,null),l.g.ea(l.A)),l.F=Date.now(),qs(l)}Dc(a)}function $s(a){a.g&&(Do(a),a.g.cancel(),a.g=null)}function vc(a){$s(a),a.v&&(o.clearTimeout(a.v),a.v=null),Qs(a),a.h.cancel(),a.m&&(typeof a.m=="number"&&o.clearTimeout(a.m),a.m=null)}function Ks(a){if(!oc(a.h)&&!a.m){a.m=!0;var l=a.Ea;Z||_(),H||(Z(),H=!0),E.add(l,a),a.D=0}}function ug(a,l){return ac(a.h)>=a.h.j-(a.m?1:0)?!1:a.m?(a.i=l.G.concat(a.i),!0):a.I==1||a.I==2||a.D>=(a.Sa?0:a.Ta)?!1:(a.m=Sr(h(a.Ea,a,l),Cc(a,a.D)),a.D++,!0)}
397r.Ea=function(a){if(this.m)if(this.m=null,this.I==1){if(!a){this.V=Math.floor(Math.random()*1e5),a=this.V++;const b=new ge(this,this.j,a);let P=this.o;if(this.U&&(P?(P=Ou(P),Lu(P,this.U)):P=this.U),this.u!==null||this.R||(b.J=P,P=null),this.S)t:{for(var l=0,d=0;d<this.i.length;d++){e:{var g=this.i[d];if("__data__"in g.map&&(g=g.map.__data__,typeof g=="string")){g=g.length;break e}g=void 0}if(g===void 0)break;if(l+=g,l>4096){l=d;break t}if(l===4096||d===this.i.length-1){l=d+1;break t}}l=1e3}else l=1e3;l=Rc(this,b,l),d=Xt(this.J),at(d,"RID",a),at(d,"CVER",22),this.G&&at(d,"X-HTTP-Session-Id",this.G),Br(this,d),P&&(this.R?l="headers="+Vr(yc(P))+"&"+l:this.u&&Po(d,this.u,P)),bo(this.h,b),this.Ra&&at(d,"TYPE","init"),this.S?(at(d,"$req",l),at(d,"SID","null"),b.U=!0,To(b,d,null)):To(b,d,l),this.I=2}}else this.I==3&&(a?bc(this,a):this.i.length==0||oc(this.h)||bc(this))};function bc(a,l){var d;l?d=l.l:d=a.V++;const g=Xt(a.J);at(g,"SID",a.M),at(g,"RID",d),at(g,"AID",a.K),Br(a,g),a.u&&a.o&&Po(g,a.u,a.o),d=new ge(a,a.j,d,a.D+1),a.u===null&&(d.J=a.o),l&&(a.i=l.G.concat(a.i)),l=Rc(a,d,1e3),d.H=Math.round(a.va*.5)+Math.round(a.va*.5*Math.random()),bo(a.h,d),To(d,g,l)}function Br(a,l){a.H&&Os(a.H,function(d,g){at(l,g,d)}),a.l&&Os({},function(d,g){at(l,g,d)})}function Rc(a,l,d){d=Math.min(a.i.length,d);const g=a.l?h(a.l.Ka,a.l,a):null;t:{var b=a.i;let $=-1;for(;;){const It=["count="+d];$==-1?d>0?($=b[0].g,It.push("ofs="+$)):$=0:It.push("ofs="+$);let it=!0;for(let At=0;At<d;At++){var P=b[At].g;const Yt=b[At].map;if(P-=$,P<0)$=Math.max(0,b[At].g-100),it=!1;else try{P="req"+P+"_"||"";try{var O=Yt instanceof Map?Yt:Object.entries(Yt);for(const[tn,Ie]of O){let Ee=Ie;u(Ie)&&(Ee=po(Ie)),It.push(P+tn+"="+encodeURIComponent(Ee))}}catch(tn){throw It.push(P+"type="+encodeURIComponent("_badmap")),tn}}catch{g&&g(Yt)}}if(it){O=It.join("&");break t}}O=void 0}return a=a.i.splice(0,d),l.G=a,O}function Sc(a){if(!a.g&&!a.v){a.Y=1;var l=a.Da;Z||_(),H||(Z(),H=!0),E.add(l,a),a.A=0}}function Co(a){return a.g||a.v||a.A>=3?!1:(a.Y++,a.v=Sr(h(a.Da,a),Cc(a,a.A)),a.A++,!0)}r.Da=function(){if(this.v=null,Pc(this),this.aa&&!(this.P||this.g==null||this.T<=0)){var a=4*this.T;this.j.info("BP detection timer enabled: "+a),this.B=Sr(h(this.Wa,this),a)}},r.Wa=function(){this.B&&(this.B=null,this.j.info("BP detection timeout reached."),this.j.info("Buffering proxy detected and switch to long-polling!"),this.F=!1,this.P=!0,Mt(10),$s(this),Pc(this))};function Do(a){a.B!=null&&(o.clearTimeout(a.B),a.B=null)}function Pc(a){a.g=new ge(a,a.j,"rpc",a.Y),a.u===null&&(a.g.J=a.o),a.g.P=0;var l=Xt(a.na);at(l,"RID","rpc"),at(l,"SID",a.M),at(l,"AID",a.K),at(l,"CI",a.F?"0":"1"),!a.F&&a.ia&&at(l,"TO",a.ia),at(l,"TYPE","xmlhttp"),Br(a,l),a.u&&a.o&&Po(l,a.u,a.o),a.O&&(a.g.H=a.O);var d=a.g;a=a.ba,d.M=1,d.A=js(Xt(l)),d.u=null,d.R=!0,nc(d,a)}r.Va=function(){this.C!=null&&(this.C=null,$s(this),Co(this),Mt(19))};function Qs(a){a.C!=null&&(o.clearTimeout(a.C),a.C=null)}function Vc(a,l){var d=null;if(a.g==l){Qs(a),Do(a),a.g=null;var g=2}else if(vo(a.h,l))d=l.G,uc(a.h,l),g=1;else return;if(a.I!=0){if(l.o)if(g==1){d=l.u?l.u.length:0,l=Date.now()-l.F;var b=a.D;g=Bs(),kt(g,new Xu(g,d)),Ks(a)}else Sc(a);else if(b=l.m,b==3||b==0&&l.X>0||!(g==1&&ug(a,l)||g==2&&Co(a)))switch(d&&d.length>0&&(l=a.h,l.i=l.i.concat(d)),b){case 1:Ze(a,5);break;case 4:Ze(a,10);break;case 3:Ze(a,6);break;default:Ze(a,2)}}}function Cc(a,l){let d=a.Qa+Math.floor(Math.random()*a.Za);return a.isActive()||(d*=2),d*l}function Ze(a,l){if(a.j.info("Error code "+l),l==2){var d=h(a.bb,a),g=a.Ua;const b=!g;g=new pe(g||"//www.google.com/images/cleardot.gif"),o.location&&o.location.protocol=="http"||Dr(g,"https"),js(g),b?ng(g.toString(),d):rg(g.toString(),d)}else Mt(2);a.I=0,a.l&&a.l.pa(l),Dc(a),vc(a)}r.bb=function(a){a?(this.j.info("Successfully pinged google.com"),Mt(2)):(this.j.info("Failed to ping google.com"),Mt(1))};function Dc(a){if(a.I=0,a.ja=[],a.l){const l=cc(a.h);(l.length!=0||a.i.length!=0)&&(C(a.ja,l),C(a.ja,a.i),a.h.i.length=0,v(a.i),a.i.length=0),a.l.oa()}}function xc(a,l,d){var g=d instanceof pe?Xt(d):new pe(d);if(g.g!="")l&&(g.g=l+"."+g.g),xr(g,g.u);else{var b=o.location;g=b.protocol,l=l?l+"."+b.hostname:b.hostname,b=+b.port;
397const P=new pe(null);g&&Dr(P,g),l&&(P.g=l),b&&xr(P,b),d&&(P.h=d),g=P}return d=a.G,l=a.wa,d&&l&&at(g,d,l),at(g,"VER",a.ka),Br(a,g),g}function Nc(a,l,d){if(l&&!a.L)throw Error("Can't create secondary domain capable XhrIo object.");return l=a.Aa&&!a.ma?new mt(new So({ab:d})):new mt(a.ma),l.Fa(a.L),l}r.isActive=function(){return!!this.l&&this.l.isActive(this)};function kc(){}r=kc.prototype,r.ra=function(){},r.qa=function(){},r.pa=function(){},r.oa=function(){},r.isActive=function(){return!0},r.Ka=function(){};function Ws(){}Ws.prototype.g=function(a,l){return new zt(a,l)};function zt(a,l){Vt.call(this),this.g=new Ac(l),this.l=a,this.h=l&&l.messageUrlParams||null,a=l&&l.messageHeaders||null,l&&l.clientProtocolHeaderRequired&&(a?a["X-Client-Protocol"]="webchannel":a={"X-Client-Protocol":"webchannel"}),this.g.o=a,a=l&&l.initMessageHeaders||null,l&&l.messageContentType&&(a?a["X-WebChannel-Content-Type"]=l.messageContentType:a={"X-WebChannel-Content-Type":l.messageContentType}),l&&l.sa&&(a?a["X-WebChannel-Client-Profile"]=l.sa:a={"X-WebChannel-Client-Profile":l.sa}),this.g.U=a,(a=l&&l.Qb)&&!y(a)&&(this.g.u=a),this.A=l&&l.supportsCrossDomainXhr||!1,this.v=l&&l.sendRawJson||!1,(l=l&&l.httpSessionIdParam)&&!y(l)&&(this.g.G=l,a=this.h,a!==null&&l in a&&(a=this.h,l in a&&delete a[l])),this.j=new Cn(this)}m(zt,Vt),zt.prototype.m=function(){this.g.l=this.j,this.A&&(this.g.L=!0),this.g.connect(this.l,this.h||void 0)},zt.prototype.close=function(){Vo(this.g)},zt.prototype.o=function(a){var l=this.g;if(typeof a=="string"){var d={};d.__data__=a,a=d}else this.v&&(d={},d.__data__=po(a),a=d);l.i.push(new Wm(l.Ya++,a)),l.I==3&&Ks(l)},zt.prototype.N=function(){this.g.l=null,delete this.j,Vo(this.g),delete this.g,zt.Z.N.call(this)};function Mc(a){_o.call(this),a.__headers__&&(this.headers=a.__headers__,this.statusCode=a.__status__,delete a.__headers__,delete a.__status__);var l=a.__sm__;if(l){t:{for(const d in l){a=d;break t}a=void 0}(this.i=a)&&(a=this.i,l=l!==null&&a in l?l[a]:void 0),this.data=l}else this.data=a}m(Mc,_o);function Oc(){yo.call(this),this.status=1}m(Oc,yo);function Cn(a){this.g=a}m(Cn,kc),Cn.prototype.ra=function(){kt(this.g,"a")},Cn.prototype.qa=function(a){kt(this.g,new Mc(a))},Cn.prototype.pa=function(a){kt(this.g,new Oc)},Cn.prototype.oa=function(){kt(this.g,"b")},Ws.prototype.createWebChannel=Ws.prototype.g,zt.prototype.send=zt.prototype.o,zt.prototype.open=zt.prototype.m,zt.prototype.close=zt.prototype.close,Lh=function(){return new Ws},Fh=function(){return Bs()},Oh=Je,Xo={jb:0,mb:1,nb:2,Hb:3,Mb:4,Jb:5,Kb:6,Ib:7,Gb:8,Lb:9,PROXY:10,NOPROXY:11,Eb:12,Ab:13,Bb:14,zb:15,Cb:16,Db:17,fb:18,eb:19,gb:20},Us.NO_ERROR=0,Us.TIMEOUT=8,Us.HTTP_ERROR=6,si=Us,Yu.COMPLETE="complete",Mh=Yu,Qu.EventType=br,br.OPEN="a",br.CLOSE="b",br.ERROR="c",br.MESSAGE="d",Vt.prototype.listen=Vt.prototype.J,$r=Qu,mt.prototype.listenOnce=mt.prototype.K,mt.prototype.getLastError=mt.prototype.Ha,mt.prototype.getLastErrorCode=mt.prototype.ya,mt.prototype.getStatus=mt.prototype.ca,mt.prototype.getResponseJson=mt.prototype.La,mt.prototype.getResponseText=mt.prototype.la,mt.prototype.send=mt.prototype.ea,mt.prototype.setWithCredentials=mt.prototype.Fa,kh=mt}).apply(typeof Js<"u"?Js:typeof self<"u"?self:typeof window<"u"?window:{});const Hc="@firebase/firestore",Jc="4.9.2";/**
398 * @license
399 * Copyright 2017 Google LLC
400 *
401 * Licensed under the Apache License, Version 2.0 (the "License");
402 * you may not use this file except in compliance with the License.
403 * You may obtain a copy of the License at
404 *
405 *   http://www.apache.org/licenses/LICENSE-2.0
406 *
407 * Unless required by applicable law or agreed to in writing, software
408 * distributed under the License is distributed on an "AS IS" BASIS,
409 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
410 * See the License for the specific language governing permissions and
411 * limitations under the License.
412 */class bt{constructor(t){this.uid=t}isAuthenticated(){return this.uid!=null}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(t){return t.uid===this.uid}}bt.UNAUTHENTICATED=new bt(null),bt.GOOGLE_CREDENTIALS=new bt("google-credentials-uid"),bt.FIRST_PARTY=new bt("first-party-uid"),bt.MOCK_USER=new bt("mock-user");/**
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 */let dr="12.3.0";/**
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 */const Ne=new Ph("@firebase/firestore");function Fn(){return Ne.logLevel}function zp(r){Ne.setLogLevel(r)}function N(r,...t){if(Ne.logLevel<=X.DEBUG){const e=t.map(Va);Ne.debug(`Firestore (${dr}): ${r}`,...e)}}function gt(r,...t){if(Ne.logLevel<=X.ERROR){const e=t.map(Va);Ne.error(`Firestore (${dr}): ${r}`,...e)}}function $t(r,...t){if(Ne.logLevel<=X.WARN){const e=t.map(Va);Ne.warn(`Firestore (${dr}): ${r}`,...e)}}function Va(r){if(typeof r=="string")return r;try{/**
443* @license
444* Copyright 2020 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*/return function(e){return JSON.stringify(e)}(r)}catch{return r}}/**
458 * @license
459 * Copyright 2017 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 */function F(r,t,e){let n="Unexpected state";typeof t=="string"?n=t:e=t,Bh(r,n,e)}function Bh(r,t,e){let n=`FIRESTORE (${dr}) INTERNAL ASSERTION FAILED: ${t} (ID: ${r.toString(16)})`;if(e!==void 0)try{n+=" CONTEXT: "+JSON.stringify(e)}catch{n+=" CONTEXT: "+e}throw gt(n),new Error(n)}function L(r,t,e,n){let s="Unexpected state";typeof e=="string"?s=e:n=e,r||Bh(t,s,n)}function Gp(r,t){r||F(57014,t)}function M(r,t){return r}/**
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 */const R={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",UNIMPLEMENT
487ED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class V extends hr{constructor(t,e){super(t,e),this.code=t,this.message=e,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}/**
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 */class Rt{constructor(){this.promise=new Promise((t,e)=>{this.resolve=t,this.reject=e})}}/**
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, software
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 Uh{constructor(t,e){this.user=e,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${t}`)}}class qh{getToken(){return Promise.resolve(null)}invalidateToken(){}start(t,e){t.enqueueRetryable(()=>e(bt.UNAUTHENTICATED))}shutdown(){}}class $p{constructor(t){this.token=t,this.changeListener=null}getToken(){return Promise.resolve(this.token)}invalidateToken(){}start(t,e){this.changeListener=e,t.enqueueRetryable(()=>e(this.token.user))}shutdown(){this.changeListener=null}}class Kp{constructor(t){this.t=t,this.currentUser=bt.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(t,e){L(this.o===void 0,42304);let n=this.i;const s=c=>this.i!==n?(n=this.i,e(c)):Promise.resolve();let i=new Rt;this.o=()=>{this.i++,this.currentUser=this.u(),i.resolve(),i=new Rt,t.enqueueRetryable(()=>s(this.currentUser))};const o=()=>{const c=i;t.enqueueRetryable(async()=>{await c.promise,await s(this.currentUser)})},u=c=>{N("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=c,this.o&&(this.auth.addAuthTokenListener(this.o),o())};this.t.onInit(c=>u(c)),setTimeout(()=>{if(!this.auth){const c=this.t.getImmediate({optional:!0});c?u(c):(N("FirebaseAuthCredentialsProvider","Auth not yet detected"),i.resolve(),i=new Rt)}},0),o()}getToken(){const t=this.i,e=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(e).then(n=>this.i!==t?(N("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):n?(L(typeof n.accessToken=="string",31837,{l:n}),new Uh(n.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 t=this.auth&&this.auth.getUid();return L(t===null||typeof t=="string",2055,{h:t}),new bt(t)}}class Qp{constructor(t,e,n){this.P=t,this.T=e,this.I=n,this.type="FirstParty",this.user=bt.FIRST_PARTY,this.A=new Map}R(){return this.I?this.I():null}get headers(){this.A.set("X-Goog-AuthUser",this.P);const t=this.R();return t&&this.A.set("Authorization",t),this.T&&this.A.set("X-Goog-Iam-Authorization-Token",this.T),this.A}}class Wp{constructor(t,e,n){this.P=t,this.T=e,this.I=n}getToken(){return Promise.resolve(new Qp(this.P,this.T,this.I))}start(t,e){t.enqueueRetryable(()=>e(bt.FIRST_PARTY))}shutdown(){}invalidateToken(){}}class Yo{constructor(t){this.value=t,this.type="AppCheck",this.headers=new Map,t&&t.length>0&&this.headers.set("x-firebase-appcheck",this.value)}}class Hp{constructor(t,e){this.V=e,this.forceRefresh=!1,this.appCheck=null,this.m=null,this.p=null,Sp(t)&&t.settings.appCheckToken&&(this.p=t.settings.appCheckToken)}start(t,e){L(this.o===void 0,3512);const n=i=>{i.error!=null&&N("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${i.error.message}`);const o=i.token!==this.m;return this.m=i.token,N("FirebaseAppCheckTokenProvider",`Received ${o?"new":"existing"} token.`),o?e(i.token):Promise.resolve()};this.o=i=>{t.enqueueRetryable(()=>n(i))};const s=i=>{N("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=i,this.o&&this.appCheck.addTokenListener(this.o)};this.V.onInit(i=>s(i)),setTimeout(()=>{if(!this.appCheck){const i=this.V.getImmediate({optional:!0});i?s(i):N("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}},0)}getToken(){if(this.p)return Promise.resolve(new Yo(this.p));const t=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(t).then(e=>e?(L(typeof e.token=="string",44558,{tokenResult:e}),this.m=e.token,new Yo(e.token)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.o&&this.appCheck.removeTokenListener(this.o),this.o=void 0}}class Jp{getToken(){return Promise.resolve(new Yo(""))}invalidateToken(){}start(t,e){}shutdown(){}}/**
518 * @license
519 * Copyright 2020 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 */function Xp(r){const t=typeof self<"u"&&(self.crypto||self.msCrypto),e=new Uint8Array(r);if(t&&typeof t.getRandomValues=="function")t.getRandomValues(e);else for(let n=0;n<r;n++)e[n]=Math.floor(256*Math.random());return e}/**
533 * @license
534 * Copyright 2017 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 */class Mi{static newId(){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e=62*Math.floor(4.129032258064516);let n="";for(;n.length<20;){const s=Xp(40);for(let i=0;i<s.length;++i)n.length<20&&s[i]<e&&(n+=t.charAt(s[i]%62))}return n}}function z(r,t){return r<t?-1:r>t?1:0}function Zo(r,t){const e=Math.min(r.length,t.length);for(let n=0;n<e;n++){const s=r.charAt(n),i=t.charAt(n);if(s!==i)return Lo(s)===Lo(i)?z(s,i):Lo(s)?1:-1}return z(r.length,t.length)}const Yp=55296,Zp=57343;function Lo(r){const t=r.charCodeAt(0);return t>=Yp&&t<=Zp}function Gn(r,t,e){return r.length===t.length&&r.every((n,s)=>e(n,t[s]))}function jh(r){return r+"\0"}/**
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 */const ta="__name__";class Zt{constructor(t,e,n){e===void 0?e=0:e>t.length&&F(637,{offset:e,range:t.length}),n===void 0?n=t.length-e:n>t.length-e&&F(1746,{length:n,range:t.length-e}),this.segments=t,this.offset=e,this.len=n}get length(){return this.len}isEqual(t){return Zt.comparator(this,t)===0}child(t){const e=this.segments.slice(this.offset,this.limit());return t instanceof Zt?t.forEach(n=>{e.push(n)}):e.push(t),this.construct(e)}limit(){return this.offset+this.length}popFirst(t){return t=t===void 0?1:t,this.construct(this.segments,this.offset+t,this.length-t)}popLast(){return this.construct(this.segments,this.offset,this.length-1)}firstSegment(){return this.segments[this.offset]}lastSegment(){return this.get(this.length-1)}get(t){return this.segments[this.offset+t]}isEmpty(){return this.length===0}isPrefixOf(t){if(t.length<this.length)return!1;for(let e=0;e<this.length;e++)if(this.get(e)!==t.get(e))return!1;return!0}isImmediateParentOf(t){if(this.length+1!==t.length)return!1;for(let e=0;e<this.length;e++)if(this.get(e)!==t.get(e))return!1;return!0}forEach(t){for(let e=this.offset,n=this.limit();e<n;e++)t(this.segments[e])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(t,e){const n=Math.min(t.length,e.length);for(let s=0;s<n;s++){const i=Zt.compareSegments(t.get(s),e.get(s));if(i!==0)return i}return z(t.length,e.length)}static compareSegments(t,e){const n=Zt.isNumericId(t),s=Zt.isNumericId(e);return n&&!s?-1:!n&&s?1:n&&s?Zt.extractNumericId(t).compare(Zt.extractNumericId(e)):Zo(t,e)}static isNumericId(t){return t.startsWith("__id")&&t.endsWith("__")}static extractNumericId(t){return Ce.fromString(t.substring(4,t.length-2))}}class K extends Zt{construct(t,e,n){return new K(t,e,n)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}
562toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...t){const e=[];for(const n of t){if(n.indexOf("//")>=0)throw new V(R.INVALID_ARGUMENT,`Invalid segment (${n}). Paths must not contain // in them.`);e.push(...n.split("/").filter(s=>s.length>0))}return new K(e)}static emptyPath(){return new K([])}}const t_=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class ct extends Zt{construct(t,e,n){return new ct(t,e,n)}static isValidIdentifier(t){return t_.test(t)}canonicalString(){return this.toArray().map(t=>(t=t.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),ct.isValidIdentifier(t)||(t="`"+t+"`"),t)).join(".")}toString(){return this.canonicalString()}isKeyField(){return this.length===1&&this.get(0)===ta}static keyField(){return new ct([ta])}static fromServerFormat(t){const e=[];let n="",s=0;const i=()=>{if(n.length===0)throw new V(R.INVALID_ARGUMENT,`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);e.push(n),n=""};let o=!1;for(;s<t.length;){const u=t[s];if(u==="\\"){if(s+1===t.length)throw new V(R.INVALID_ARGUMENT,"Path has trailing escape character: "+t);const c=t[s+1];if(c!=="\\"&&c!=="."&&c!=="`")throw new V(R.INVALID_ARGUMENT,"Path has invalid escape sequence: "+t);n+=c,s+=2}else u==="`"?(o=!o,s++):u!=="."||o?(n+=u,s++):(i(),s++)}if(i(),o)throw new V(R.INVALID_ARGUMENT,"Unterminated ` in path: "+t);return new ct(e)}static emptyPath(){return new ct([])}}/**
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 */class k{constructor(t){this.path=t}static fromPath(t){return new k(K.fromString(t))}static fromName(t){return new k(K.fromString(t).popFirst(5))}static empty(){return new k(K.emptyPath())}get collectionGroup(){return this.path.popLast().lastSegment()}hasCollectionId(t){return this.path.length>=2&&this.path.get(this.path.length-2)===t}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(t){return t!==null&&K.comparator(this.path,t.path)===0}toString(){return this.path.toString()}static comparator(t,e){return K.comparator(t.path,e.path)}static isDocumentKey(t){return t.length%2==0}static fromSegments(t){return new k(new K(t.slice()))}}/**
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 */function Ca(r,t,e){if(!e)throw new V(R.INVALID_ARGUMENT,`Function ${r}() cannot be called with an empty ${t}.`)}function zh(r,t,e,n){if(t===!0&&n===!0)throw new V(R.INVALID_ARGUMENT,`${r} and ${e} cannot be used together.`)}function Xc(r){if(!k.isDocumentKey(r))throw new V(R.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${r} has ${r.length}.`)}function Yc(r){if(k.isDocumentKey(r))throw new V(R.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${r} has ${r.length}.`)}function Gh(r){return typeof r=="object"&&r!==null&&(Object.getPrototypeOf(r)===Object.prototype||Object.getPrototypeOf(r)===null)}function Oi(r){if(r===void 0)return"undefined";if(r===null)return"null";if(typeof r=="string")return r.length>20&&(r=`${r.substring(0,20)}...`),JSON.stringify(r);if(typeof r=="number"||typeof r=="boolean")return""+r;if(typeof r=="object"){if(r instanceof Array)return"an array";{const t=function(n){return n.constructor?n.constructor.name:null}(r);return t?`a custom ${t} object`:"an object"}}return typeof r=="function"?"a function":F(12329,{type:typeof r})}function Q(r,t){if("_delegate"in r&&(r=r._delegate),!(r instanceof t)){if(t.name===r.constructor.name)throw new V(R.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{const e=Oi(r);throw new V(R.INVALID_ARGUMENT,`Expected type '${t.name}', but it was: ${e}`)}}return r}function $h(r,t){if(t<=0)throw new V(R.INVALID_ARGUMENT,`Function ${r}() requires a positive number, but it was: ${t}.`)}/**
593 * @license
594 * Copyright 2025 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 yt(r,t){const e={typeString:r};return t&&(e.value=t),e}function An(r,t){if(!Gh(r))throw new V(R.INVALID_ARGUMENT,"JSON must be an object");let e;for(const n in t)if(t[n]){const s=t[n].typeString,i="value"in t[n]?{value:t[n].value}:void 0;if(!(n in r)){e=`JSON missing required field: '${n}'`;break}const o=r[n];if(s&&typeof o!==s){e=`JSON field '${n}' must be a ${s}.`;break}if(i!==void 0&&o!==i.value){e=`Expected '${n}' field to equal '${i.value}'`;break}}if(e)throw new V(R.INVALID_ARGUMENT,e);return!0}/**
608 * @license
609 * Copyright 2017 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 */const Zc=-62135596800,tl=1e6;class tt{static now(){return tt.fromMillis(Date.now())}static fromDate(t){return tt.fromMillis(t.getTime())}static fromMillis(t){const e=Math.floor(t/1e3),n=Math.floor((t-1e3*e)*tl);return new tt(e,n)}constructor(t,e){if(this.seconds=t,this.nanoseconds=e,e<0)throw new V(R.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(e>=1e9)throw new V(R.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(t<Zc)throw new V(R.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t);if(t>=253402300800)throw new V(R.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/tl}_compareTo(t){return this.seconds===t.seconds?z(this.nanoseconds,t.nanoseconds):z(this.seconds,t.seconds)}isEqual(t){return t.seconds===this.seconds&&t.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{type:tt._jsonSchemaVersion,seconds:this.seconds,nanoseconds:this.nanoseconds}}static fromJSON(t){if(An(t,tt._jsonSchema))return new tt(t.seconds,t.nanoseconds)}valueOf(){const t=this.seconds-Zc;return String(t).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}tt._jsonSchemaVersion="firestore/timestamp/1.0",tt._jsonSchema={type:yt("string",tt._jsonSchemaVersion),seconds:yt("number"),nanoseconds:yt("number")};/**
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 */class q{static fromTimestamp(t){return new q(t)}static min(){return new q(new tt(0,0))}static max(){return new q(new tt(253402300799,999999999))}constructor(t){this.timestamp=t}compareTo(t){return this.timestamp._compareTo(t.timestamp)}isEqual(t){return this.timestamp.isEqual(t.timestamp)}toMicroseconds(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}toString(){return"SnapshotVersion("+this.timestamp.toString()+")"}toTimestamp(){return this.timestamp}}/**
638 * @license
639 * Copyright 2021 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 */const $n=-1;class Kn{constructor(t,e,n,s){this.indexId=t,this.collectionGroup=e,this.fields=n,this.indexState=s}}function ea(r){return r.fields.find(t=>t.kind===2)}function rn(r){return r.fields.filter(t=>t.kind!==2)}function e_(r,t){let e=z(r.collectionGroup,t.collectionGroup);if(e!==0)return e;for(let n=0;n<Math.min(r.fields.length,t.fields.length);++n)if(e=n_(r.fields[n],t.fields[n]),e!==0)return e;return z(r.fields.length,t.fields.length)}Kn.UNKNOWN_ID=-1;class hn{constructor(t,e){this.fieldPath=t,this.kind=e}}function n_(r,t){const e=ct.comparator(r.fieldPath,t.fieldPath);return e!==0?e:z(r.kind,t.kind)}class Qn{constructor(t,e){this.sequenceNumber=t,this.offset=e}static empty(){return new Qn(0,Kt.min())}}function Kh(r,t){const e=r.toTimestamp().seconds,n=r.toTimestamp().nanoseconds+1,s=q.fromTimestamp(n===1e9?new tt(e+1,0):new tt(e,n));return new Kt(s,k.empty(),t)}function Qh(r){return new Kt(r.readTime,r.key,$n)}class Kt{constructor(t,e,n){this.readTime=t,this.documentKey=e,this.largestBatchId=n}static min(){return new Kt(q.min(),k.empty(),$n)}static max(){return new Kt(q.max(),k.empty(),$n)}}function Da(r,t){let e=r.readTime.compareTo(t.readTime);return e!==0?e:(e=k.comparator(r.documentKey,t.documentKey),e!==0?e:z(r.largestBatchId,t.largestBatchId))}/**
653 * @license
654 * Copyright 2020 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 Wh="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class Hh{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(t){this.onCommittedListeners.push(t)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach(t=>t())}}/**
668 * @license
669 * Copyright 2017 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 */async function qe(r){if(r.code!==R.FAILED_PRECONDITION||r.message!==Wh)throw r;N("LocalStore","Unexpectedly lost primary lease")}/**
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 */class A{constructor(t){this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,t(e=>{this.isDone=!0,this.result=e,this.nextCallback&&this.nextCallback(e)},e=>{this.isDone=!0,this.error=e,this.catchCallback&&this.catchCallback(e)})}catch(t){return this.next(void 0,t)}next(t,e){return this.callbackAttached&&F(59440),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(e,this.error):this.wrapSuccess(t,this.result):new A((n,s)=>{this.nextCallback=i=>{this.wrapSuccess(t,i).next(n,s)},this.catchCallback=i=>{this.wrapFailure(e,i).next(n,s)}})}toPromise(){return new Promise((t,e)=>{this.next(t,e)})}wrapUserFunction(t){try{const e=t();return e instanceof A?e:A.resolve(e)}catch(e){return A.reject(e)}}wrapSuccess(t,e){return t?this.wrapUserFunction(()=>t(e)):A.resolve(e)}wrapFailure(t,e){return t?this.wrapUserFunction(()=>t(e)):A.reject(e)}static resolve(t){return new A((e,n)=>{e(t)})}static reject(t){return new A((e,n)=>{n(t)})}static waitFor(t){return new A((e,n)=>{let s=0,i=0,o=!1;t.forEach(u=>{++s,u.next(()=>{++i,o&&i===s&&e()},c=>n(c))}),o=!0,i===s&&e()})}static or(t){let e=A.resolve(!1);for(const n of t)e=e.next(s=>s?A.resolve(s):n());return e}static forEach(t,e){const n=[];return t.forEach((s,i)=>{n.push(e.call(this,s,i))}),this.waitFor(n)}static mapArray(t,e){return new A((n,s)=>{const i=t.length,o=new Array(i);let u=0;for(let c=0;c<i;c++){const h=c;e(t[h]).next(f=>{o[h]=f,++u,u===i&&n(o)},f=>s(f))}})}static doWhile(t,e){return new A((n,s)=>{const i=()=>{t()===!0?e().next(()=>{i()},s):n()};i()})}}/**
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 */const Gt="SimpleDb";class Fi{static open(t,e,n,s){try{return new Fi(e,t.transaction(s,n))}catch(i){throw new Xr(e,i)}}constructor(t,e){this.action=t,this.transaction=e,this.aborted=!1,this.S=new Rt,this.transaction.oncomplete=()=>{this.S.resolve()},this.transaction.onabort=()=>{e.error?this.S.reject(new Xr(t,e.error)):this.S.resolve()},this.transaction.onerror=n=>{const s=xa(n.target.error);this.S.reject(new Xr(t,s))}}get D(){return this.S.promise}abort(t){t&&this.S.reject(t),this.aborted||(N(Gt,"Aborting transaction:",t?t.message:"Client-initiated abort"),this.aborted=!0,this.transaction.abort())}C(){const t=this.transaction;this.aborted||typeof t.commit!="function"||t.commit()}store(t){const e=this.transaction.objectStore(t);return new s_(e)}}class re{static delete(t){return N(Gt,"Removing database:",t),on(Eh().indexedDB.deleteDatabase(t)).toPromise()}static v(){if(!Rh())return!1;if(re.F())return!0;const t=zn(),e=re.M(t),n=0<e&&e<10,s=Jh(t),i=0<s&&s<4.5;return!(t.indexOf("MSIE ")>0||t.indexOf("Trident/")>0||t.indexOf("Edge/")>0||n||i)}static F(){return typeof process<"u"&&process.__PRIVATE_env?.__PRIVATE_USE_MOCK_PERSISTENCE==="YES"}static O(t,e){return t.store(e)}static M(t){const e=t.match(/i(?:phone|pad|pod) os ([\d_]+)/i),n=e?e[1].split("_").slice(0,2).join("."):"-1";return Number(n)}constructor(t,e,n){this.name=t,this.version=e,this.N=n,this.B=null,re.M(zn())===12.2&&gt("Firestore persistence suffers from a bug in iOS 12.2 Safari that may cause your app to stop working. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.")}async L(t){return this.db||(N(Gt,"Opening database:",this.name),this.db=await new Promise((e,n)=>{const s=indexedDB.open(this.name,this.version);s.onsuccess=i=>{const o=i.target.result;e(o)},s.onblocked=()=>{n(new Xr(t,"Cannot upgrade IndexedDB schema while another tab is open. Close all tabs that access Firestore and reload this page to proceed."))},s.onerror=i=>{const o=i.target.error;o.name==="VersionError"?n(new V(R.FAILED_PRECONDITION,"A newer version of the Firestore SDK was previously used and so the persisted data is not compatible with the version of the SDK you are now using. The SDK will operate with persistence disabled. If you need persistence, please re-upgrade to a newer version of the SDK or else clear the persisted IndexedDB data for your app to start fresh.")):o.name==="InvalidStateError"?n(new V(R.FAILED_PRECONDITION,"Unable to open an IndexedDB connection. This could be due to running in a private browsing session on a browser whose private browsing sessions do not support IndexedDB: "+o)):n(new Xr(t,o))},s.onupgradeneeded=i=>{N(Gt,'Database "'+this.name+'" requires upgrade from version:',i.oldVersion);const o=i.target.result;this.N.k(o,s.transaction,i.oldVersion,this.version).next(()=>{N(Gt,"Database upgrade to version "+this.version+" complete")})}})),this.q&&(this.db.onversionchange=e=>this.q(e)),this.db}$(t){this.q=t,this.db&&(this.db.onversionchange=e=>t(e))}async runTransaction(t,e,n,s){const i=e==="readonly";let o=0;for(;;){++o;try{this.db=await this.L(t);const u=Fi.open(this.db,t,i?"readonly":"readwrite",n),c=s(u).next(h=>(u.C(),h)).catch(h=>(u.abort(h),A.reject(h))).toPromise();return c.catch(()=>{}),await u.D,c}catch(u){const c=u,h=c.name!=="FirebaseError"&&o<3;if(N(Gt,"Transaction failed with error:",c.message,"Retrying:",h),this.close(),!h)return Promise.reject(c)}}}close(){this.db&&this.db.close(),this.db=void 0}}function Jh(r){const t=r.match(/Android ([\d.]+)/i),e=t?t[1].split(".").slice(0,2).join("."):"-1";return Number(e)}class r_{constructor(t){this.U=t,this.K=!1,this.W=null}get isDone(){return this.K}get G(){return this.W}set cursor(t){this.U=t}done(){this.K=!0}j(t){this.W=t}delete(){return on(this.U.delete())}}class Xr extends V{constructor(t,e){super(R.UNAVAILABLE,`IndexedDB transaction '${t}' failed: ${e}`),this.name="IndexedDbTransactionError"}}function je(r){return r.name==="IndexedDbTransactionError"}class s_{constructor(t){this.store=t}put(t,e){let n;return e!==void 0?(N(Gt,"PUT",this.store.name,t,e),n=this.store.put(e,t)):(N(Gt,"PUT",this.store.name,"<auto-key>",t),n=this.store.put(t)),on(n)}add(t){return N(Gt,"ADD",this.store.name,t,t),on(this.store.add(t))}get(t){return on(this.store.get(t)).next(e=>(e===void 0&&(e=null),N(Gt,"GET",this.store.name,t,e),e))}delete(t){return N(Gt,"DELETE",this.store.name,t),on(this.store.delete(t))}count(){return N(Gt,"COUNT",this.store.name),on(this.store.count())}J(t,e){const n=this.options(t,e),s=n.index?this.store.index(n.index):this.store;if(typeof s.getAll=="function"){const i=s.getAll(n.range);return new A((o,u)=>{i.onerror=c=>{u(c.target.error)},i.onsuccess=c=>{o(c.target.result)}})}{const i=this.cursor(n),o=[];return this.H(i,(u,c)=>{o.push(c)}).next(()=>o)}}Y(t,e){const n=this.store.getAll(t,e===null?void 0:e);return new A((s,i)=>{n.onerror=o=>{i(o.target.error)},n.onsuccess=o=>{s(o.target.result)}})}Z(t,e){N(Gt,"DELETE ALL",this.store.name);const n=this.options(t,e);n.X=!1;const s=this.cursor(n);return this.H(s,(i,o,u)=>u.delete())}ee(t,e){let n;e?n=t:(n={},e=t);const s=this.cursor(n);return this.H(s,e)}te(t){const e=this.cursor({});return new A((n,s)=>{e.onerror=i=>{const o=xa(i.target.error);s(o)},e.onsuccess=i=>{const o=i.target.result;o?t(o.primaryKey,o.value).next(u=>{u?o.continue():n()}):n()}})}H(t,e){const n=[];return new A((s,i)=>{t.onerror=o=>{i(o.target.error)},t.onsuccess=o=>{const u=o.target.result;if(!u)return void s();const c=new r_(u),h=e(u.primaryKey,u.value,c);if(h instanceof A){const f=h.catch(m=>(c.done(),A.reject(m)));n.push(f)}c.isDone?s():c.G===null?u.continue():u.continue(c.G)}}).next(()=>A.waitFor(n))}options(t,e){let n;return t!==void 0&&(typeof t=="string"?n=t:e=t),{index:n,range:e}}cursor(t){let e="next";if(t.reverse&&(e="prev"),t.index){const n=this.store.index(t.index);return t.X?n.openKeyCursor(t.range,e):n.openCursor(t.range,e)}return this.store.openCursor(t.range,e)}}function on(r){return new A((t,e)=>{r.onsuccess=n=>{const s=n.target.result;t(s)},r.onerror=n=>{const s=xa(n.target.error);e(s)}})}let el=!1;function xa(r){const t=re.M(zn());if(t>=12.2&&t<13){const e="An internal error was encountered in the Indexed Database server";if(r.message.indexOf(e)>=0){const n=new V("internal",`IOS_INDEXEDDB_BUG1: IndexedDb has thrown '${e}'. This is likely due to an unavoidable bug in iOS. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.`);return el||(el=!0,setTimeout(()=>{throw n},0)),n}}return r}const Yr="IndexBackfiller";class i_{constructor(t,e){this.asyncQueue=t,this.ne=e,this.task=null}start(){this.re(15e3)}stop(){this.task&&(this.task.cancel(),this.task=null)}get started(){return this.task!==null}re(t){N(Yr,`Scheduled in ${t}ms`),this.task=this.asyncQueue.enqueueAfterDelay("index_backfill",t,async()=>{this.task=null;try{const e=await this.ne.ie();
712N(Yr,`Documents written: ${e}`)}catch(e){je(e)?N(Yr,"Ignoring IndexedDB error during index backfill: ",e):await qe(e)}await this.re(6e4)})}}class o_{constructor(t,e){this.localStore=t,this.persistence=e}async ie(t=50){return this.persistence.runTransaction("Backfill Indexes","readwrite-primary",e=>this.se(e,t))}se(t,e){const n=new Set;let s=e,i=!0;return A.doWhile(()=>i===!0&&s>0,()=>this.localStore.indexManager.getNextCollectionGroupToUpdate(t).next(o=>{if(o!==null&&!n.has(o))return N(Yr,`Processing collection: ${o}`),this.oe(t,o,s).next(u=>{s-=u,n.add(o)});i=!1})).next(()=>e-s)}oe(t,e,n){return this.localStore.indexManager.getMinOffsetFromCollectionGroup(t,e).next(s=>this.localStore.localDocuments.getNextDocuments(t,e,s,n).next(i=>{const o=i.changes;return this.localStore.indexManager.updateIndexEntries(t,o).next(()=>this._e(s,i)).next(u=>(N(Yr,`Updating offset: ${u}`),this.localStore.indexManager.updateCollectionGroup(t,e,u))).next(()=>o.size)}))}_e(t,e){let n=t;return e.changes.forEach((s,i)=>{const o=Qh(i);Da(o,n)>0&&(n=o)}),new Kt(n.readTime,n.documentKey,Math.max(e.batchId,t.largestBatchId))}}/**
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 Lt{constructor(t,e){this.previousValue=t,e&&(e.sequenceNumberHandler=n=>this.ae(n),this.ue=n=>e.writeSequenceNumber(n))}ae(t){return this.previousValue=Math.max(t,this.previousValue),this.previousValue}next(){const t=++this.previousValue;return this.ue&&this.ue(t),t}}Lt.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 De=-1;function Ts(r){return r==null}function us(r){return r===0&&1/r==-1/0}function Xh(r){return typeof r=="number"&&Number.isInteger(r)&&!us(r)&&r<=Number.MAX_SAFE_INTEGER&&r>=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 yi="�";function xt(r){let t="";for(let e=0;e<r.length;e++)t.length>0&&(t=nl(t)),t=a_(r.get(e),t);return nl(t)}function a_(r,t){let e=t;const n=r.length;for(let s=0;s<n;s++){const i=r.charAt(s);switch(i){case"\0":e+="��";break;case yi:e+="��";break;default:e+=i}}return e}function nl(r){return r+yi+"�"}function ee(r){const t=r.length;if(L(t>=2,64408,{path:r}),t===2)return L(r.charAt(0)===yi&&r.charAt(1)==="�",56145,{path:r}),K.emptyPath();const e=t-2,n=[];let s="";for(let i=0;i<t;){const o=r.indexOf(yi,i);switch((o<0||o>e)&&F(50515,{path:r}),r.charAt(o+1)){case"�":const u=r.substring(i,o);let c;s.length===0?c=u:(s+=u,c=s,s=""),n.push(c);break;case"�":s+=r.substring(i,o),s+="\0";break;case"�":s+=r.substring(i,o+1);break;default:F(61167,{path:r})}i=o+2}return new K(n)}/**
758 * @license
759 * Copyright 2022 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 */const sn="remoteDocuments",ws="owner",Dn="owner",cs="mutationQueues",u_="userId",Wt="mutations",rl="batchId",ln="userMutationsIndex",sl=["userId","batchId"];/**
773 * @license
774 * Copyright 2022 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 */function ii(r,t){return[r,xt(t)]}function Yh(r,t,e){return[r,xt(t),e]}const c_={},Wn="documentMutations",Ii="remoteDocumentsV14",l_=["prefixPath","collectionGroup","readTime","documentId"],oi="documentKeyIndex",h_=["prefixPath","collectionGroup","documentId"],Zh="collectionGroupIndex",d_=["collectionGroup","readTime","prefixPath","documentId"],ls="remoteDocumentGlobal",na="remoteDocumentGlobalKey",Hn="targets",td="queryTargetsIndex",f_=["canonicalId","targetId"],Jn="targetDocuments",m_=["targetId","path"],Na="documentTargetsIndex",g_=["path","targetId"],Ei="targetGlobalKey",dn="targetGlobal",hs="collectionParents",p_=["collectionId","parent"],Xn="clientMetadata",__="clientId",Li="bundles",y_="bundleId",Bi="namedQueries",I_="name",ka="indexConfiguration",E_="indexId",ra="collectionGroupIndex",T_="collectionGroup",Zr="indexState",w_=["indexId","uid"],ed="sequenceNumberIndex",A_=["uid","sequenceNumber"],ts="indexEntries",v_=["indexId","uid","arrayValue","directionalValue","orderedDocumentKey","documentKey"],nd="documentKeyIndex",b_=["indexId","uid","orderedDocumentKey"],Ui="documentOverlays",R_=["userId","collectionPath","documentId"],sa="collectionPathOverlayIndex",S_=["userId","collectionPath","largestBatchId"],rd="collectionGroupOverlayIndex",P_=["userId","collectionGroup","largestBatchId"],Ma="globals",V_="name",sd=[cs,Wt,Wn,sn,Hn,ws,dn,Jn,Xn,ls,hs,Li,Bi],C_=[...sd,Ui],id=[cs,Wt,Wn,Ii,Hn,ws,dn,Jn,Xn,ls,hs,Li,Bi,Ui],od=id,Oa=[...od,ka,Zr,ts],D_=Oa,ad=[...Oa,Ma],x_=ad;/**
788 * @license
789 * Copyright 2020 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 ia extends Hh{constructor(t,e){super(),this.le=t,this.currentSequenceNumber=e}}function wt(r,t){const e=M(r);return re.O(e.le,t)}/**
803 * @license
804 * Copyright 2017 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 */function il(r){let t=0;for(const e in r)Object.prototype.hasOwnProperty.call(r,e)&&t++;return t}function ze(r,t){for(const e in r)Object.prototype.hasOwnProperty.call(r,e)&&t(e,r[e])}function ud(r,t){const e=[];for(const n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.push(t(r[n],n,r));return e}function cd(r){for(const t in r)if(Object.prototype.hasOwnProperty.call(r,t))return!1;return!0}/**
818 * @license
819 * Copyright 2017 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 ot{constructor(t,e){this.comparator=t,this.root=e||St.EMPTY}insert(t,e){return new ot(this.comparator,this.root.insert(t,e,this.comparator).copy(null,null,St.BLACK,null,null))}remove(t){return new ot(this.comparator,this.root.remove(t,this.comparator).copy(null,null,St.BLACK,null,null))}get(t){let e=this.root;for(;!e.isEmpty();){const n=this.comparator(t,e.key);if(n===0)return e.value;n<0?e=e.left:n>0&&(e=e.right)}return null}indexOf(t){let e=0,n=this.root;for(;!n.isEmpty();){const s=this.comparator(t,n.key);if(s===0)return e+n.left.size;s<0?n=n.left:(e+=n.left.size+1,n=n.right)}return-1}isEmpty(){return this.root.isEmpty()}get size(){return this.root.size}minKey(){return this.root.minKey()}maxKey(){return this.root.maxKey()}inorderTraversal(t){return this.root.inorderTraversal(t)}forEach(t){this.inorderTraversal((e,n)=>(t(e,n),!1))}toString(){const t=[];return this.inorderTraversal((e,n)=>(t.push(`${e}:${n}`),!1)),`{${t.join(", ")}}`}reverseTraversal(t){return this.root.reverseTraversal(t)}getIterator(){return new Xs(this.root,null,this.comparator,!1)}getIteratorFrom(t){return new Xs(this.root,t,this.comparator,!1)}getReverseIterator(){return new Xs(this.root,null,this.comparator,!0)}getReverseIteratorFrom(t){return new Xs(this.root,t,this.comparator,!0)}}class Xs{constructor(t,e,n,s){this.isReverse=s,this.nodeStack=[];let i=1;for(;!t.isEmpty();)if(i=e?n(t.key,e):1,e&&s&&(i*=-1),i<0)t=this.isReverse?t.left:t.right;else{if(i===0){this.nodeStack.push(t);break}this.nodeStack.push(t),t=this.isReverse?t.right:t.left}}getNext(){let t=this.nodeStack.pop();const e={key:t.key,value:t.value};if(this.isReverse)for(t=t.left;!t.isEmpty();)this.nodeStack.push(t),t=t.right;else for(t=t.right;!t.isEmpty();)this.nodeStack.push(t),t=t.left;return e}hasNext(){return this.nodeStack.length>0}peek(){if(this.nodeStack.length===0)return null;const t=this.nodeStack[this.nodeStack.length-1];return{key:t.key,value:t.value}}}class St{constructor(t,e,n,s,i){this.key=t,this.value=e,this.color=n??St.RED,this.left=s??St.EMPTY,this.right=i??St.EMPTY,this.size=this.left.size+1+this.right.size}copy(t,e,n,s,i){return new St(t??this.key,e??this.value,n??this.color,s??this.left,i??this.right)}isEmpty(){return!1}inorderTraversal(t){return this.left.inorderTraversal(t)||t(this.key,this.value)||this.right.inorderTraversal(t)}reverseTraversal(t){return this.right.reverseTraversal(t)||t(this.key,this.value)||this.left.reverseTraversal(t)}min(){return this.left.isEmpty()?this:this.left.min()}minKey(){return this.min().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(t,e,n){let s=this;const i=n(t,s.key);return s=i<0?s.copy(null,null,null,s.left.insert(t,e,n),null):i===0?s.copy(null,e,null,null,null):s.copy(null,null,null,null,s.right.insert(t,e,n)),s.fixUp()}removeMin(){if(this.left.isEmpty())return St.EMPTY;let t=this;return t.left.isRed()||t.left.left.isRed()||(t=t.moveRedLeft()),t=t.copy(null,null,null,t.left.removeMin(),null),t.fixUp()}remove(t,e){let n,s=this;if(e(t,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(t,e),null);else{if(s.left.isRed()&&(s=s.rotateRight()),s.right.isEmpty()||s.right.isRed()||s.right.left.isRed()||(s=s.moveRedRight()),e(t,s.key)===0){if(s.right.isEmpty())return St.EMPTY;n=s.right.min(),s=s.copy(n.key,n.value,null,null,s.right.removeMin())}s=s.copy(null,null,null,null,s.right.remove(t,e))}return s.fixUp()}isRed(){return this.color}fixUp(){let t=this;return t.right.isRed()&&!t.left.isRed()&&(t=t.rotateLeft()),t.left.isRed()&&t.left.left.isRed()&&(t=t.rotateRight()),t.left.isRed()&&t.right.isRed()&&(t=t.colorFlip()),t}moveRedLeft(){let t=this.colorFlip();return t.right.left.isRed()&&(t=t.copy(null,null,null,null,t.right.rotateRight()),t=t.rotateLeft(),t=t.colorFlip()),t}moveRedRight(){let t=this.colorFlip();return t.left.left.isRed()&&(t=t.rotateRight(),t=t.colorFlip()),t}rotateLeft(){const t=this.copy(null,null,St.RED,null,this.right.left);return this.right.copy(null,null,this.color,t,null)}rotateRight(){const t=this.copy(null,null,St.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,t)}colorFlip(){const t=this.left.copy(null,null,!this.left.color,null,null),e=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,t,e)}checkMaxDepth(){const t=this.check();return Math.pow(2,t)<=this.size+1}check(){if(this.isRed()&&this.left.isRed())throw F(43730,{key:this.key,value:this.value});if(this.right.isRed())throw F(14113,{key:this.key,value:this.value});const t=this.left.check();if(t!==this.right.check())throw F(27949);return t+(this.isRed()?0:1)}}St.EMPTY=null,St.RED=!0,St.BLACK=!1;
832St.EMPTY=new class{constructor(){this.size=0}get key(){throw F(57766)}get value(){throw F(16141)}get color(){throw F(16727)}get left(){throw F(29726)}get right(){throw F(36894)}copy(t,e,n,s,i){return this}insert(t,e,n){return new St(t,e)}remove(t,e){return this}isEmpty(){return!0}inorderTraversal(t){return!1}reverseTraversal(t){return!1}minKey(){return null}maxKey(){return null}isRed(){return!1}checkMaxDepth(){return!0}check(){return 0}};/**
833 * @license
834 * Copyright 2017 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 rt{constructor(t){this.comparator=t,this.data=new ot(this.comparator)}has(t){return this.data.get(t)!==null}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(t){return this.data.indexOf(t)}forEach(t){this.data.inorderTraversal((e,n)=>(t(e),!1))}forEachInRange(t,e){const n=this.data.getIteratorFrom(t[0]);for(;n.hasNext();){const s=n.getNext();if(this.comparator(s.key,t[1])>=0)return;e(s.key)}}forEachWhile(t,e){let n;for(n=e!==void 0?this.data.getIteratorFrom(e):this.data.getIterator();n.hasNext();)if(!t(n.getNext().key))return}firstAfterOrEqual(t){const e=this.data.getIteratorFrom(t);return e.hasNext()?e.getNext().key:null}getIterator(){return new ol(this.data.getIterator())}getIteratorFrom(t){return new ol(this.data.getIteratorFrom(t))}add(t){return this.copy(this.data.remove(t).insert(t,!0))}delete(t){return this.has(t)?this.copy(this.data.remove(t)):this}isEmpty(){return this.data.isEmpty()}unionWith(t){let e=this;return e.size<t.size&&(e=t,t=this),t.forEach(n=>{e=e.add(n)}),e}isEqual(t){if(!(t instanceof rt)||this.size!==t.size)return!1;const e=this.data.getIterator(),n=t.data.getIterator();for(;e.hasNext();){const s=e.getNext().key,i=n.getNext().key;if(this.comparator(s,i)!==0)return!1}return!0}toArray(){const t=[];return this.forEach(e=>{t.push(e)}),t}toString(){const t=[];return this.forEach(e=>t.push(e)),"SortedSet("+t.toString()+")"}copy(t){const e=new rt(this.comparator);return e.data=t,e}}class ol{constructor(t){this.iter=t}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}function xn(r){return r.hasNext()?r.getNext():void 0}/**
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 */class Bt{constructor(t){this.fields=t,t.sort(ct.comparator)}static empty(){return new Bt([])}unionWith(t){let e=new rt(ct.comparator);for(const n of this.fields)e=e.add(n);for(const n of t)e=e.add(n);return new Bt(e.toArray())}covers(t){for(const e of this.fields)if(e.isPrefixOf(t))return!0;return!1}isEqual(t){return Gn(this.fields,t.fields,(e,n)=>e.isEqual(n))}}/**
863 * @license
864 * Copyright 2023 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 ld extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}/**
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 */function N_(){return typeof atob<"u"}/**
893 * @license
894 * Copyright 2020 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 ft{constructor(t){this.binaryString=t}static fromBase64String(t){const e=function(s){try{return atob(s)}catch(i){throw typeof DOMException<"u"&&i instanceof DOMException?new ld("Invalid base64 string: "+i):i}}(t);return new ft(e)}static fromUint8Array(t){const e=function(s){let i="";for(let o=0;o<s.length;++o)i+=String.fromCharCode(s[o]);return i}(t);return new ft(e)}[Symbol.iterator](){let t=0;return{next:()=>t<this.binaryString.length?{value:this.binaryString.charCodeAt(t++),done:!1}:{value:void 0,done:!0}}}toBase64(){return function(e){return btoa(e)}(this.binaryString)}toUint8Array(){return function(e){const n=new Uint8Array(e.length);for(let s=0;s<e.length;s++)n[s]=e.charCodeAt(s);return n}(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(t){return z(this.binaryString,t.binaryString)}isEqual(t){return this.binaryString===t.binaryString}}ft.EMPTY_BYTE_STRING=new ft("");const k_=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function ce(r){if(L(!!r,39018),typeof r=="string"){let t=0;const e=k_.exec(r);if(L(!!e,46558,{timestamp:r}),e[1]){let s=e[1];s=(s+"000000000").substr(0,9),t=Number(s)}const n=new Date(r);return{seconds:Math.floor(n.getTime()/1e3),nanos:t}}return{seconds:lt(r.seconds),nanos:lt(r.nanos)}}function lt(r){return typeof r=="number"?r:typeof r=="string"?Number(r):0}function le(r){return typeof r=="string"?ft.fromBase64String(r):ft.fromUint8Array(r)}/**
908 * @license
909 * Copyright 2020 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 */const hd="server_timestamp",dd="__type__",fd="__previous_value__",md="__local_write_time__";function qi(r){return(r?.mapValue?.fields||{})[dd]?.stringValue===hd}function ji(r){const t=r.mapValue.fields[fd];return qi(t)?ji(t):t}function ds(r){const t=ce(r.mapValue.fields[md].timestampValue);return new tt(t.seconds,t.nanos)}/**
923 * @license
924 * Copyright 2017 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 M_{constructor(t,e,n,s,i,o,u,c,h,f){this.databaseId=t,this.appId=e,this.persistenceKey=n,this.host=s,this.ssl=i,this.forceLongPolling=o,this.autoDetectLongPolling=u,this.longPollingOptions=c,this.useFetchStreams=h,this.isUsingEmulator=f}}const fs="(default)";class ke{constructor(t,e){this.projectId=t,this.database=e||fs}static empty(){return new ke("","")}get isDefaultDatabase(){return this.database===fs}isEqual(t){return t instanceof ke&&t.projectId===this.projectId&&t.database===this.database}}/**
938 * @license
939 * Copyright 2020 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, software
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 */const Fa="__type__",gd="__max__",Re={mapValue:{fields:{__type__:{stringValue:gd}}}},La="__vector__",Yn="value",ai={nullValue:"NULL_VALUE"};function Me(r){return"nullValue"in r?0:"booleanValue"in r?1:"integerValue"in r||"doubleValue"in r?2:"timestampValue"in r?3:"stringValue"in r?5:"bytesValue"in r?6:"referenceValue"in r?7:"geoPointValue"in r?8:"arrayValue"in r?9:"mapValue"in r?qi(r)?4:pd(r)?9007199254740991:zi(r)?10:11:F(28295,{value:r})}function ie(r,t){if(r===t)return!0;const e=Me(r);if(e!==Me(t))return!1;switch(e){case 0:case 9007199254740991:return!0;case 1:return r.booleanValue===t.booleanValue;case 4:return ds(r).isEqual(ds(t));case 3:return function(s,i){if(typeof s.timestampValue=="string"&&typeof i.timestampValue=="string"&&s.timestampValue.length===i.timestampValue.length)return s.timestampValue===i.timestampValue;const o=ce(s.timestampValue),u=ce(i.timestampValue);return o.seconds===u.seconds&&o.nanos===u.nanos}(r,t);case 5:return r.stringValue===t.stringValue;case 6:return function(s,i){return le(s.bytesValue).isEqual(le(i.bytesValue))}(r,t);case 7:return r.referenceValue===t.referenceValue;case 8:return function(s,i){return lt(s.geoPointValue.latitude)===lt(i.geoPointValue.latitude)&&lt(s.geoPointValue.longitude)===lt(i.geoPointValue.longitude)}(r,t);case 2:return function(s,i){if("integerValue"in s&&"integerValue"in i)return lt(s.integerValue)===lt(i.integerValue);if("doubleValue"in s&&"doubleValue"in i){const o=lt(s.doubleValue),u=lt(i.doubleValue);return o===u?us(o)===us(u):isNaN(o)&&isNaN(u)}return!1}(r,t);case 9:return Gn(r.arrayValue.values||[],t.arrayValue.values||[],ie);case 10:case 11:return function(s,i){const o=s.mapValue.fields||{},u=i.mapValue.fields||{};if(il(o)!==il(u))return!1;for(const c in o)if(o.hasOwnProperty(c)&&(u[c]===void 0||!ie(o[c],u[c])))return!1;return!0}(r,t);default:return F(52216,{left:r})}}function ms(r,t){return(r.values||[]).find(e=>ie(e,t))!==void 0}function Oe(r,t){if(r===t)return 0;const e=Me(r),n=Me(t);if(e!==n)return z(e,n);switch(e){case 0:case 9007199254740991:return 0;case 1:return z(r.booleanValue,t.booleanValue);case 2:return function(i,o){const u=lt(i.integerValue||i.doubleValue),c=lt(o.integerValue||o.doubleValue);return u<c?-1:u>c?1:u===c?0:isNaN(u)?isNaN(c)?0:-1:1}(r,t);case 3:return al(r.timestampValue,t.timestampValue);case 4:return al(ds(r),ds(t));case 5:return Zo(r.stringValue,t.stringValue);case 6:return function(i,o){const u=le(i),c=le(o);return u.compareTo(c)}(r.bytesValue,t.bytesValue);case 7:return function(i,o){const u=i.split("/"),c=o.split("/");for(let h=0;h<u.length&&h<c.length;h++){const f=z(u[h],c[h]);if(f!==0)return f}return z(u.length,c.length)}(r.referenceValue,t.referenceValue);case 8:return function(i,o){const u=z(lt(i.latitude),lt(o.latitude));return u!==0?u:z(lt(i.longitude),lt(o.longitude))}(r.geoPointValue,t.geoPointValue);case 9:return ul(r.arrayValue,t.arrayValue);case 10:return function(i,o){const u=i.fields||{},c=o.fields||{},h=u[Yn]?.arrayValue,f=c[Yn]?.arrayValue,m=z(h?.values?.length||0,f?.values?.length||0);return m!==0?m:ul(h,f)}(r.mapValue,t.mapValue);case 11:return function(i,o){if(i===Re.mapValue&&o===Re.mapValue)return 0;if(i===Re.mapValue)return 1;if(o===Re.mapValue)return-1;const u=i.fields||{},c=Object.keys(u),h=o.fields||{},f=Object.keys(h);c.sort(),f.sort();for(let m=0;m<c.length&&m<f.length;++m){const p=Zo(c[m],f[m]);if(p!==0)return p;const v=Oe(u[c[m]],h[f[m]]);if(v!==0)return v}return z(c.length,f.length)}(r.mapValue,t.mapValue);default:throw F(23264,{he:e})}}function al(r,t){if(typeof r=="string"&&typeof t=="string"&&r.length===t.length)return z(r,t);const e=ce(r),n=ce(t),s=z(e.seconds,n.seconds);return s!==0?s:z(e.nanos,n.nanos)}function ul(r,t){const e=r.values||[],n=t.values||[];for(let s=0;s<e.length&&s<n.length;++s){const i=Oe(e[s],n[s]);if(i)return i}return z(e.length,n.length)}function Zn(r){return oa(r)}function oa(r){return"nullValue"in r?"null":"booleanValue"in r?""+r.booleanValue:"integerValue"in r?""+r.integerValue:"doubleValue"in r?""+r.doubleValue:"timestampValue"in r?function(e){const n=ce(e);return`time(${n.seconds},${n.nanos})`}(r.timestampValue):"stringValue"in r?r.stringValue:"bytesValue"in r?function(e){return le(e).toBase64()}(r.bytesValue):"referenceValue"in r?function(e){return k.fromName(e).toString()}(r.referenceValue):"geoPointValue"in r?function(e){return`geo(${e.latitude},${e.longitude})`}(r.geoPointValue):"arrayValue"in r?function(e){let n="[",s=!0;for(const i of e.values||[])s?s=!1:n+=",",n+=oa(i);return n+"]"}(r.arrayValue):"mapValue"in r?function(e){const n=Object.keys(e.fields||{}).sort();let s="{",i=!0;for(const o of n)i?i=!1:s+=",",s+=`${o}:${oa(e.fields[o])}`;return s+"}"}(r.mapValue):F(61005,{value:r})}function ui(r){switch(Me(r)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:const t=ji(r);return t?16+ui(t):16;case 5:return 2*r.stringValue.length;case 6:return le(r.bytesValue).approximateByteSize();case 7:return r.referenceValue.length;case 9:return function(n){return(n.values||[]).reduce((s,i)=>s+ui(i),0)}(r.arrayValue);case 10:case 11:return function(n){let s=0;
952return ze(n.fields,(i,o)=>{s+=i.length+ui(o)}),s}(r.mapValue);default:throw F(13486,{value:r})}}function mn(r,t){return{referenceValue:`projects/${r.projectId}/databases/${r.database}/documents/${t.path.canonicalString()}`}}function aa(r){return!!r&&"integerValue"in r}function gs(r){return!!r&&"arrayValue"in r}function cl(r){return!!r&&"nullValue"in r}function ll(r){return!!r&&"doubleValue"in r&&isNaN(Number(r.doubleValue))}function ci(r){return!!r&&"mapValue"in r}function zi(r){return(r?.mapValue?.fields||{})[Fa]?.stringValue===La}function es(r){if(r.geoPointValue)return{geoPointValue:{...r.geoPointValue}};if(r.timestampValue&&typeof r.timestampValue=="object")return{timestampValue:{...r.timestampValue}};if(r.mapValue){const t={mapValue:{fields:{}}};return ze(r.mapValue.fields,(e,n)=>t.mapValue.fields[e]=es(n)),t}if(r.arrayValue){const t={arrayValue:{values:[]}};for(let e=0;e<(r.arrayValue.values||[]).length;++e)t.arrayValue.values[e]=es(r.arrayValue.values[e]);return t}return{...r}}function pd(r){return(((r.mapValue||{}).fields||{}).__type__||{}).stringValue===gd}const _d={mapValue:{fields:{[Fa]:{stringValue:La},[Yn]:{arrayValue:{}}}}};function O_(r){return"nullValue"in r?ai:"booleanValue"in r?{booleanValue:!1}:"integerValue"in r||"doubleValue"in r?{doubleValue:NaN}:"timestampValue"in r?{timestampValue:{seconds:Number.MIN_SAFE_INTEGER}}:"stringValue"in r?{stringValue:""}:"bytesValue"in r?{bytesValue:""}:"referenceValue"in r?mn(ke.empty(),k.empty()):"geoPointValue"in r?{geoPointValue:{latitude:-90,longitude:-180}}:"arrayValue"in r?{arrayValue:{}}:"mapValue"in r?zi(r)?_d:{mapValue:{}}:F(35942,{value:r})}function F_(r){return"nullValue"in r?{booleanValue:!1}:"booleanValue"in r?{doubleValue:NaN}:"integerValue"in r||"doubleValue"in r?{timestampValue:{seconds:Number.MIN_SAFE_INTEGER}}:"timestampValue"in r?{stringValue:""}:"stringValue"in r?{bytesValue:""}:"bytesValue"in r?mn(ke.empty(),k.empty()):"referenceValue"in r?{geoPointValue:{latitude:-90,longitude:-180}}:"geoPointValue"in r?{arrayValue:{}}:"arrayValue"in r?_d:"mapValue"in r?zi(r)?{mapValue:{}}:Re:F(61959,{value:r})}function hl(r,t){const e=Oe(r.value,t.value);return e!==0?e:r.inclusive&&!t.inclusive?-1:!r.inclusive&&t.inclusive?1:0}function dl(r,t){const e=Oe(r.value,t.value);return e!==0?e:r.inclusive&&!t.inclusive?1:!r.inclusive&&t.inclusive?-1:0}/**
953 * @license
954 * Copyright 2017 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 Pt{constructor(t){this.value=t}static empty(){return new Pt({mapValue:{}})}field(t){if(t.isEmpty())return this.value;{let e=this.value;for(let n=0;n<t.length-1;++n)if(e=(e.mapValue.fields||{})[t.get(n)],!ci(e))return null;return e=(e.mapValue.fields||{})[t.lastSegment()],e||null}}set(t,e){this.getFieldsMap(t.popLast())[t.lastSegment()]=es(e)}setAll(t){let e=ct.emptyPath(),n={},s=[];t.forEach((o,u)=>{if(!e.isImmediateParentOf(u)){const c=this.getFieldsMap(e);this.applyChanges(c,n,s),n={},s=[],e=u.popLast()}o?n[u.lastSegment()]=es(o):s.push(u.lastSegment())});const i=this.getFieldsMap(e);this.applyChanges(i,n,s)}delete(t){const e=this.field(t.popLast());ci(e)&&e.mapValue.fields&&delete e.mapValue.fields[t.lastSegment()]}isEqual(t){return ie(this.value,t.value)}getFieldsMap(t){let e=this.value;e.mapValue.fields||(e.mapValue={fields:{}});for(let n=0;n<t.length;++n){let s=e.mapValue.fields[t.get(n)];ci(s)&&s.mapValue.fields||(s={mapValue:{fields:{}}},e.mapValue.fields[t.get(n)]=s),e=s}return e.mapValue.fields}applyChanges(t,e,n){ze(e,(s,i)=>t[s]=i);for(const s of n)delete t[s]}clone(){return new Pt(es(this.value))}}function yd(r){const t=[];return ze(r.fields,(e,n)=>{const s=new ct([e]);if(ci(n)){const i=yd(n.mapValue).fields;if(i.length===0)t.push(s);else for(const o of i)t.push(s.child(o))}else t.push(s)}),new Bt(t)}/**
968 * @license
969 * Copyright 2017 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 ut{constructor(t,e,n,s,i,o,u){this.key=t,this.documentType=e,this.version=n,this.readTime=s,this.createTime=i,this.data=o,this.documentState=u}static newInvalidDocument(t){return new ut(t,0,q.min(),q.min(),q.min(),Pt.empty(),0)}static newFoundDocument(t,e,n,s){return new ut(t,1,e,q.min(),n,s,0)}static newNoDocument(t,e){return new ut(t,2,e,q.min(),q.min(),Pt.empty(),0)}static newUnknownDocument(t,e){return new ut(t,3,e,q.min(),q.min(),Pt.empty(),2)}convertToFoundDocument(t,e){return!this.createTime.isEqual(q.min())||this.documentType!==2&&this.documentType!==0||(this.createTime=t),this.version=t,this.documentType=1,this.data=e,this.documentState=0,this}convertToNoDocument(t){return this.version=t,this.documentType=2,this.data=Pt.empty(),this.documentState=0,this}convertToUnknownDocument(t){return this.version=t,this.documentType=3,this.data=Pt.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=q.min(),this}setReadTime(t){return this.readTime=t,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(t){return t instanceof ut&&this.key.isEqual(t.key)&&this.version.isEqual(t.version)&&this.documentType===t.documentType&&this.documentState===t.documentState&&this.data.isEqual(t.data)}mutableCopy(){return new ut(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}})`}}/**
983 * @license
984 * Copyright 2022 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 Fe{constructor(t,e){this.position=t,this.inclusive=e}}function fl(r,t,e){let n=0;for(let s=0;s<r.position.length;s++){const i=t[s],o=r.position[s];if(i.field.isKeyField()?n=k.comparator(k.fromName(o.referenceValue),e.key):n=Oe(o,e.data.field(i.field)),i.dir==="desc"&&(n*=-1),n!==0)break}return n}function ml(r,t){if(r===null)return t===null;if(t===null||r.inclusive!==t.inclusive||r.position.length!==t.position.length)return!1;for(let e=0;e<r.position.length;e++)if(!ie(r.position[e],t.position[e]))return!1;return!0}/**
998 * @license
999 * Copyright 2022 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 ps{constructor(t,e="asc"){this.field=t,this.dir=e}}function L_(r,t){return r.dir===t.dir&&r.field.isEqual(t.field)}/**
1013 * @license
1014 * Copyright 2022 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 */class Id{}class W extends Id{constructor(t,e,n){super(),this.field=t,this.op=e,this.value=n}static create(t,e,n){return t.isKeyField()?e==="in"||e==="not-in"?this.createKeyFieldInFilter(t,e,n):new B_(t,e,n):e==="array-contains"?new j_(t,n):e==="in"?new bd(t,n):e==="not-in"?new z_(t,n):e==="array-contains-any"?new G_(t,n):new W(t,e,n)}static createKeyFieldInFilter(t,e,n){return e==="in"?new U_(t,n):new q_(t,n)}matches(t){const e=t.data.field(this.field);return this.op==="!="?e!==null&&e.nullValue===void 0&&this.matchesComparison(Oe(e,this.value)):e!==null&&Me(this.value)===Me(e)&&this.matchesComparison(Oe(e,this.value))}matchesComparison(t){switch(this.op){case"<":return t<0;case"<=":return t<=0;case"==":return t===0;case"!=":return t!==0;case">":return t>0;case">=":return t>=0;default:return F(47266,{operator:this.op})}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class et extends Id{constructor(t,e){super(),this.filters=t,this.op=e,this.Pe=null}static create(t,e){return new et(t,e)}matches(t){return tr(this)?this.filters.find(e=>!e.matches(t))===void 0:this.filters.find(e=>e.matches(t))!==void 0}getFlattenedFilters(){return this.Pe!==null||(this.Pe=this.filters.reduce((t,e)=>t.concat(e.getFlattenedFilters()),[])),this.Pe}getFilters(){return Object.assign([],this.filters)}}function tr(r){return r.op==="and"}function ua(r){return r.op==="or"}function Ba(r){return Ed(r)&&tr(r)}function Ed(r){for(const t of r.filters)if(t instanceof et)return!1;return!0}function ca(r){if(r instanceof W)return r.field.canonicalString()+r.op.toString()+Zn(r.value);if(Ba(r))return r.filters.map(t=>ca(t)).join(",");{const t=r.filters.map(e=>ca(e)).join(",");return`${r.op}(${t})`}}function Td(r,t){return r instanceof W?function(n,s){return s instanceof W&&n.op===s.op&&n.field.isEqual(s.field)&&ie(n.value,s.value)}(r,t):r instanceof et?function(n,s){return s instanceof et&&n.op===s.op&&n.filters.length===s.filters.length?n.filters.reduce((i,o,u)=>i&&Td(o,s.filters[u]),!0):!1}(r,t):void F(19439)}function wd(r,t){const e=r.filters.concat(t);return et.create(e,r.op)}function Ad(r){return r instanceof W?function(e){return`${e.field.canonicalString()} ${e.op} ${Zn(e.value)}`}(r):r instanceof et?function(e){return e.op.toString()+" {"+e.getFilters().map(Ad).join(" ,")+"}"}(r):"Filter"}class B_ extends W{constructor(t,e,n){super(t,e,n),this.key=k.fromName(n.referenceValue)}matches(t){const e=k.comparator(t.key,this.key);return this.matchesComparison(e)}}class U_ extends W{constructor(t,e){super(t,"in",e),this.keys=vd("in",e)}matches(t){return this.keys.some(e=>e.isEqual(t.key))}}class q_ extends W{constructor(t,e){super(t,"not-in",e),this.keys=vd("not-in",e)}matches(t){return!this.keys.some(e=>e.isEqual(t.key))}}function vd(r,t){return(t.arrayValue?.values||[]).map(e=>k.fromName(e.referenceValue))}class j_ extends W{constructor(t,e){super(t,"array-contains",e)}matches(t){const e=t.data.field(this.field);return gs(e)&&ms(e.arrayValue,this.value)}}class bd extends W{constructor(t,e){super(t,"in",e)}matches(t){const e=t.data.field(this.field);return e!==null&&ms(this.value.arrayValue,e)}}class z_ extends W{constructor(t,e){super(t,"not-in",e)}matches(t){if(ms(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const e=t.data.field(this.field);return e!==null&&e.nullValue===void 0&&!ms(this.value.arrayValue,e)}}class G_ extends W{constructor(t,e){super(t,"array-contains-any",e)}matches(t){const e=t.data.field(this.field);return!(!gs(e)||!e.arrayValue.values)&&e.arrayValue.values.some(n=>ms(this.value.arrayValue,n))}}/**
1028 * @license
1029 * Copyright 2019 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 */class $_{constructor(t,e=null,n=[],s=[],i=null,o=null,u=null){this.path=t,this.collectionGroup=e,this.orderBy=n,this.filters=s,this.limit=i,this.startAt=o,this.endAt=u,this.Te=null}}function la(r,t=null,e=[],n=[],s=null,i=null,o=null){return new $_(r,t,e,n,s,i,o)}function gn(r){const t=M(r);if(t.Te===null){let e=t.path.canonicalString();t.collectionGroup!==null&&(e+="|cg:"+t.collectionGroup),e+="|f:",e+=t.filters.map(n=>ca(n)).join(","),e+="|ob:",e+=t.orderBy.map(n=>function(i){return i.field.canonicalString()+i.dir}(n)).join(","),Ts(t.limit)||(e+="|l:",e+=t.limit),t.startAt&&(e+="|lb:",e+=t.startAt.inclusive?"b:":"a:",e+=t.startAt.position.map(n=>Zn(n)).join(",")),t.endAt&&(e+="|ub:",e+=t.endAt.inclusive?"a:":"b:",e+=t.endAt.position.map(n=>Zn(n)).join(",")),t.Te=e}return t.Te}function As(r,t){if(r.limit!==t.limit||r.orderBy.length!==t.orderBy.length)return!1;for(let e=0;e<r.orderBy.length;e++)if(!L_(r.orderBy[e],t.orderBy[e]))return!1;if(r.filters.length!==t.filters.length)return!1;for(let e=0;e<r.filters.length;e++)if(!Td(r.filters[e],t.filters[e]))return!1;return r.collectionGroup===t.collectionGroup&&!!r.path.isEqual(t.path)&&!!ml(r.startAt,t.startAt)&&ml(r.endAt,t.endAt)}function Ti(r){return k.isDocumentKey(r.path)&&r.collectionGroup===null&&r.filters.length===0}function wi(r,t){return r.filters.filter(e=>e instanceof W&&e.field.isEqual(t))}function gl(r,t,e){let n=ai,s=!0;for(const i of wi(r,t)){let o=ai,u=!0;switch(i.op){case"<":case"<=":o=O_(i.value);break;case"==":case"in":case">=":o=i.value;break;case">":o=i.value,u=!1;break;case"!=":case"not-in":o=ai}hl({value:n,inclusive:s},{value:o,inclusive:u})<0&&(n=o,s=u)}if(e!==null){for(let i=0;i<r.orderBy.length;++i)if(r.orderBy[i].field.isEqual(t)){const o=e.position[i];hl({value:n,inclusive:s},{value:o,inclusive:e.inclusive})<0&&(n=o,s=e.inclusive);break}}return{value:n,inclusive:s}}function pl(r,t,e){let n=Re,s=!0;for(const i of wi(r,t)){let o=Re,u=!0;switch(i.op){case">=":case">":o=F_(i.value),u=!1;break;case"==":case"in":case"<=":o=i.value;break;case"<":o=i.value,u=!1;break;case"!=":case"not-in":o=Re}dl({value:n,inclusive:s},{value:o,inclusive:u})>0&&(n=o,s=u)}if(e!==null){for(let i=0;i<r.orderBy.length;++i)if(r.orderBy[i].field.isEqual(t)){const o=e.position[i];dl({value:n,inclusive:s},{value:o,inclusive:e.inclusive})>0&&(n=o,s=e.inclusive);break}}return{value:n,inclusive:s}}/**
1043 * @license
1044 * Copyright 2017 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 he{constructor(t,e=null,n=[],s=[],i=null,o="F",u=null,c=null){this.path=t,this.collectionGroup=e,this.explicitOrderBy=n,this.filters=s,this.limit=i,this.limitType=o,this.startAt=u,this.endAt=c,this.Ie=null,this.Ee=null,this.de=null,this.startAt,this.endAt}}function Rd(r,t,e,n,s,i,o,u){return new he(r,t,e,n,s,i,o,u)}function fr(r){return new he(r)}function _l(r){return r.filters.length===0&&r.limit===null&&r.startAt==null&&r.endAt==null&&(r.explicitOrderBy.length===0||r.explicitOrderBy.length===1&&r.explicitOrderBy[0].field.isKeyField())}function Ua(r){return r.collectionGroup!==null}function qn(r){const t=M(r);if(t.Ie===null){t.Ie=[];const e=new Set;for(const i of t.explicitOrderBy)t.Ie.push(i),e.add(i.field.canonicalString());const n=t.explicitOrderBy.length>0?t.explicitOrderBy[t.explicitOrderBy.length-1].dir:"asc";(function(o){let u=new rt(ct.comparator);
1057return o.filters.forEach(c=>{c.getFlattenedFilters().forEach(h=>{h.isInequality()&&(u=u.add(h.field))})}),u})(t).forEach(i=>{e.has(i.canonicalString())||i.isKeyField()||t.Ie.push(new ps(i,n))}),e.has(ct.keyField().canonicalString())||t.Ie.push(new ps(ct.keyField(),n))}return t.Ie}function Nt(r){const t=M(r);return t.Ee||(t.Ee=Pd(t,qn(r))),t.Ee}function Sd(r){const t=M(r);return t.de||(t.de=Pd(t,r.explicitOrderBy)),t.de}function Pd(r,t){if(r.limitType==="F")return la(r.path,r.collectionGroup,t,r.filters,r.limit,r.startAt,r.endAt);{t=t.map(s=>{const i=s.dir==="desc"?"asc":"desc";return new ps(s.field,i)});const e=r.endAt?new Fe(r.endAt.position,r.endAt.inclusive):null,n=r.startAt?new Fe(r.startAt.position,r.startAt.inclusive):null;return la(r.path,r.collectionGroup,t,r.filters,r.limit,e,n)}}function ha(r,t){const e=r.filters.concat([t]);return new he(r.path,r.collectionGroup,r.explicitOrderBy.slice(),e,r.limit,r.limitType,r.startAt,r.endAt)}function Ai(r,t,e){return new he(r.path,r.collectionGroup,r.explicitOrderBy.slice(),r.filters.slice(),t,e,r.startAt,r.endAt)}function vs(r,t){return As(Nt(r),Nt(t))&&r.limitType===t.limitType}function Vd(r){return`${gn(Nt(r))}|lt:${r.limitType}`}function Ln(r){return`Query(target=${function(e){let n=e.path.canonicalString();return e.collectionGroup!==null&&(n+=" collectionGroup="+e.collectionGroup),e.filters.length>0&&(n+=`, filters: [${e.filters.map(s=>Ad(s)).join(", ")}]`),Ts(e.limit)||(n+=", limit: "+e.limit),e.orderBy.length>0&&(n+=`, orderBy: [${e.orderBy.map(s=>function(o){return`${o.field.canonicalString()} (${o.dir})`}(s)).join(", ")}]`),e.startAt&&(n+=", startAt: ",n+=e.startAt.inclusive?"b:":"a:",n+=e.startAt.position.map(s=>Zn(s)).join(",")),e.endAt&&(n+=", endAt: ",n+=e.endAt.inclusive?"a:":"b:",n+=e.endAt.position.map(s=>Zn(s)).join(",")),`Target(${n})`}(Nt(r))}; limitType=${r.limitType})`}function bs(r,t){return t.isFoundDocument()&&function(n,s){const i=s.key.path;return n.collectionGroup!==null?s.key.hasCollectionId(n.collectionGroup)&&n.path.isPrefixOf(i):k.isDocumentKey(n.path)?n.path.isEqual(i):n.path.isImmediateParentOf(i)}(r,t)&&function(n,s){for(const i of qn(n))if(!i.field.isKeyField()&&s.data.field(i.field)===null)return!1;return!0}(r,t)&&function(n,s){for(const i of n.filters)if(!i.matches(s))return!1;return!0}(r,t)&&function(n,s){return!(n.startAt&&!function(o,u,c){const h=fl(o,u,c);return o.inclusive?h<=0:h<0}(n.startAt,qn(n),s)||n.endAt&&!function(o,u,c){const h=fl(o,u,c);return o.inclusive?h>=0:h>0}(n.endAt,qn(n),s))}(r,t)}function Cd(r){return r.collectionGroup||(r.path.length%2==1?r.path.lastSegment():r.path.get(r.path.length-2))}function Dd(r){return(t,e)=>{let n=!1;for(const s of qn(r)){const i=K_(s,t,e);if(i!==0)return i;n=n||s.field.isKeyField()}return 0}}function K_(r,t,e){const n=r.field.isKeyField()?k.comparator(t.key,e.key):function(i,o,u){const c=o.data.field(i),h=u.data.field(i);return c!==null&&h!==null?Oe(c,h):F(42886)}(r.field,t,e);switch(r.dir){case"asc":return n;case"desc":return-1*n;default:return F(19790,{direction:r.dir})}}/**
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 de{constructor(t,e){this.mapKeyFn=t,this.equalsFn=e,this.inner={},this.innerSize=0}get(t){const e=this.mapKeyFn(t),n=this.inner[e];if(n!==void 0){for(const[s,i]of n)if(this.equalsFn(s,t))return i}}has(t){return this.get(t)!==void 0}set(t,e){const n=this.mapKeyFn(t),s=this.inner[n];if(s===void 0)return this.inner[n]=[[t,e]],void this.innerSize++;for(let i=0;i<s.length;i++)if(this.equalsFn(s[i][0],t))return void(s[i]=[t,e]);s.push([t,e]),this.innerSize++}delete(t){const e=this.mapKeyFn(t),n=this.inner[e];if(n===void 0)return!1;for(let s=0;s<n.length;s++)if(this.equalsFn(n[s][0],t))return n.length===1?delete this.inner[e]:n.splice(s,1),this.innerSize--,!0;return!1}forEach(t){ze(this.inner,(e,n)=>{for(const[s,i]of n)t(s,i)})}isEmpty(){return cd(this.inner)}size(){return this.innerSize}}/**
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 */const Q_=new ot(k.comparator);function Ut(){return Q_}const xd=new ot(k.comparator);function Kr(...r){let t=xd;for(const e of r)t=t.insert(e.key,e);return t}function Nd(r){let t=xd;return r.forEach((e,n)=>t=t.insert(e,n.overlayedDocument)),t}function ne(){return ns()}function kd(){return ns()}function ns(){return new de(r=>r.toString(),(r,t)=>r.isEqual(t))}const W_=new ot(k.comparator),H_=new rt(k.comparator);function G(...r){let t=H_;for(const e of r)t=t.add(e);return t}const J_=new rt(z);function qa(){return J_}/**
1088 * @license
1089 * Copyright 2020 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 */function ja(r,t){if(r.useProto3Json){if(isNaN(t))return{doubleValue:"NaN"};if(t===1/0)return{doubleValue:"Infinity"};if(t===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:us(t)?"-0":t}}function Md(r){return{integerValue:""+r}}function Od(r,t){return Xh(t)?Md(t):ja(r,t)}/**
1103 * @license
1104 * Copyright 2018 Google LLC
1105 *
1106 * Licensed under the Apache License, Version 2.0 (the "License");
1107 * you may not use this file except in compliance with the License.
1108 * You may obtain a copy of the License at
1109 *
1110 *   http://www.apache.org/licenses/LICENSE-2.0
1111 *
1112 * Unless required by applicable law or agreed to in writing, software
1113 * distributed under the License is distributed on an "AS IS" BASIS,
1114 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1115 * See the License for the specific language governing permissions and
1116 * limitations under the License.
1117 */class Gi{constructor(){this._=void 0}}function X_(r,t,e){return r instanceof er?function(s,i){const o={fields:{[dd]:{stringValue:hd},[md]:{timestampValue:{seconds:s.seconds,nanos:s.nanoseconds}}}};return i&&qi(i)&&(i=ji(i)),i&&(o.fields[fd]=i),{mapValue:o}}(e,t):r instanceof pn?Ld(r,t):r instanceof _n?Bd(r,t):function(s,i){const o=Fd(s,i),u=yl(o)+yl(s.Ae);return aa(o)&&aa(s.Ae)?Md(u):ja(s.serializer,u)}(r,t)}function Y_(r,t,e){return r instanceof pn?Ld(r,t):r instanceof _n?Bd(r,t):e}function Fd(r,t){return r instanceof nr?function(n){return aa(n)||function(i){return!!i&&"doubleValue"in i}(n)}(t)?t:{integerValue:0}:null}class er extends Gi{}class pn extends Gi{constructor(t){super(),this.elements=t}}function Ld(r,t){const e=Ud(t);for(const n of r.elements)e.some(s=>ie(s,n))||e.push(n);return{arrayValue:{values:e}}}class _n extends Gi{constructor(t){super(),this.elements=t}}function Bd(r,t){let e=Ud(t);for(const n of r.elements)e=e.filter(s=>!ie(s,n));return{arrayValue:{values:e}}}class nr extends Gi{constructor(t,e){super(),this.serializer=t,this.Ae=e}}function yl(r){return lt(r.integerValue||r.doubleValue)}function Ud(r){return gs(r)&&r.arrayValue.values?r.arrayValue.values.slice():[]}/**
1118 * @license
1119 * Copyright 2017 Google LLC
1120 *
1121 * Licensed under the Apache License, Version 2.0 (the "License");
1122 * you may not use this file except in compliance with the License.
1123 * You may obtain a copy of the License at
1124 *
1125 *   http://www.apache.org/licenses/LICENSE-2.0
1126 *
1127 * Unless required by applicable law or agreed to in writing, software
1128 * distributed under the License is distributed on an "AS IS" BASIS,
1129 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1130 * See the License for the specific language governing permissions and
1131 * limitations under the License.
1132 */class Rs{constructor(t,e){this.field=t,this.transform=e}}function Z_(r,t){return r.field.isEqual(t.field)&&function(n,s){return n instanceof pn&&s instanceof pn||n instanceof _n&&s instanceof _n?Gn(n.elements,s.elements,ie):n instanceof nr&&s instanceof nr?ie(n.Ae,s.Ae):n instanceof er&&s instanceof er}(r.transform,t.transform)}class ty{constructor(t,e){this.version=t,this.transformResults=e}}class ht{constructor(t,e){this.updateTime=t,this.exists=e}static none(){return new ht}static exists(t){return new ht(void 0,t)}static updateTime(t){return new ht(t)}get isNone(){return this.updateTime===void 0&&this.exists===void 0}isEqual(t){return this.exists===t.exists&&(this.updateTime?!!t.updateTime&&this.updateTime.isEqual(t.updateTime):!t.updateTime)}}function li(r,t){return r.updateTime!==void 0?t.isFoundDocument()&&t.version.isEqual(r.updateTime):r.exists===void 0||r.exists===t.isFoundDocument()}class $i{}function qd(r,t){if(!r.hasLocalMutations||t&&t.fields.length===0)return null;if(t===null)return r.isNoDocument()?new gr(r.key,ht.none()):new mr(r.key,r.data,ht.none());{const e=r.data,n=Pt.empty();let s=new rt(ct.comparator);for(let i of t.fields)if(!s.has(i)){let o=e.field(i);o===null&&i.length>1&&(i=i.popLast(),o=e.field(i)),o===null?n.delete(i):n.set(i,o),s=s.add(i)}return new fe(r.key,n,new Bt(s.toArray()),ht.none())}}function ey(r,t,e){r instanceof mr?function(s,i,o){const u=s.value.clone(),c=El(s.fieldTransforms,i,o.transformResults);u.setAll(c),i.convertToFoundDocument(o.version,u).setHasCommittedMutations()}
1132(r,t,e):r instanceof fe?function(s,i,o){if(!li(s.precondition,i))return void i.convertToUnknownDocument(o.version);const u=El(s.fieldTransforms,i,o.transformResults),c=i.data;c.setAll(jd(s)),c.setAll(u),i.convertToFoundDocument(o.version,c).setHasCommittedMutations()}(r,t,e):function(s,i,o){i.convertToNoDocument(o.version).setHasCommittedMutations()}(0,t,e)}function rs(r,t,e,n){return r instanceof mr?function(i,o,u,c){if(!li(i.precondition,o))return u;const h=i.value.clone(),f=Tl(i.fieldTransforms,c,o);return h.setAll(f),o.convertToFoundDocument(o.version,h).setHasLocalMutations(),null}(r,t,e,n):r instanceof fe?function(i,o,u,c){if(!li(i.precondition,o))return u;const h=Tl(i.fieldTransforms,c,o),f=o.data;return f.setAll(jd(i)),f.setAll(h),o.convertToFoundDocument(o.version,f).setHasLocalMutations(),u===null?null:u.unionWith(i.fieldMask.fields).unionWith(i.fieldTransforms.map(m=>m.field))}(r,t,e,n):function(i,o,u){return li(i.precondition,o)?(o.convertToNoDocument(o.version).setHasLocalMutations(),null):u}(r,t,e)}function ny(r,t){let e=null;for(const n of r.fieldTransforms){const s=t.data.field(n.field),i=Fd(n.transform,s||null);i!=null&&(e===null&&(e=Pt.empty()),e.set(n.field,i))}return e||null}function Il(r,t){return r.type===t.type&&!!r.key.isEqual(t.key)&&!!r.precondition.isEqual(t.precondition)&&!!function(n,s){return n===void 0&&s===void 0||!(!n||!s)&&Gn(n,s,(i,o)=>Z_(i,o))}(r.fieldTransforms,t.fieldTransforms)&&(r.type===0?r.value.isEqual(t.value):r.type!==1||r.data.isEqual(t.data)&&r.fieldMask.isEqual(t.fieldMask))}class mr extends $i{constructor(t,e,n,s=[]){super(),this.key=t,this.value=e,this.precondition=n,this.fieldTransforms=s,this.type=0}getFieldMask(){return null}}class fe extends $i{constructor(t,e,n,s,i=[]){super(),this.key=t,this.data=e,this.fieldMask=n,this.precondition=s,this.fieldTransforms=i,this.type=1}getFieldMask(){return this.fieldMask}}function jd(r){const t=new Map;return r.fieldMask.fields.forEach(e=>{if(!e.isEmpty()){const n=r.data.field(e);t.set(e,n)}}),t}function El(r,t,e){const n=new Map;L(r.length===e.length,32656,{Re:e.length,Ve:r.length});for(let s=0;s<e.length;s++){const i=r[s],o=i.transform,u=t.data.field(i.field);n.set(i.field,Y_(o,u,e[s]))}return n}function Tl(r,t,e){const n=new Map;for(const s of r){const i=s.transform,o=e.data.field(s.field);n.set(s.field,X_(i,o,t))}return n}class gr extends $i{constructor(t,e){super(),this.key=t,this.precondition=e,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}class za extends $i{constructor(t,e){super(),this.key=t,this.precondition=e,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}}/**
1133 * @license
1134 * Copyright 2017 Google LLC
1135 *
1136 * Licensed under the Apache License, Version 2.0 (the "License");
1137 * you may not use this file except in compliance with the License.
1138 * You may obtain a copy of the License at
1139 *
1140 *   http://www.apache.org/licenses/LICENSE-2.0
1141 *
1142 * Unless required by applicable law or agreed to in writing, software
1143 * distributed under the License is distributed on an "AS IS" BASIS,
1144 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1145 * See the License for the specific language governing permissions and
1146 * limitations under the License.
1147 */class Ga{constructor(t,e,n,s){this.batchId=t,this.localWriteTime=e,this.baseMutations=n,this.mutations=s}applyToRemoteDocument(t,e){const n=e.mutationResults;for(let s=0;s<this.mutations.length;s++){const i=this.mutations[s];i.key.isEqual(t.key)&&ey(i,t,n[s])}}applyToLocalView(t,e){for(const n of this.baseMutations)n.key.isEqual(t.key)&&(e=rs(n,t,e,this.localWriteTime));for(const n of this.mutations)n.key.isEqual(t.key)&&(e=rs(n,t,e,this.localWriteTime));return e}applyToLocalDocumentSet(t,e){const n=kd();return this.mutations.forEach(s=>{const i=t.get(s.key),o=i.overlayedDocument;let u=this.applyToLocalView(o,i.mutatedFields);u=e.has(s.key)?null:u;const c=qd(o,u);c!==null&&n.set(s.key,c),o.isValidDocument()||o.convertToNoDocument(q.min())}),n}keys(){return this.mutations.reduce((t,e)=>t.add(e.key),G())}isEqual(t){return this.batchId===t.batchId&&Gn(this.mutations,t.mutations,(e,n)=>Il(e,n))&&Gn(this.baseMutations,t.baseMutations,(e,n)=>Il(e,n))}}class $a{constructor(t,e,n,s){this.batch=t,this.commitVersion=e,this.mutationResults=n,this.docVersions=s}static from(t,e,n){L(t.mutations.length===n.length,58842,{me:t.mutations.length,fe:n.length});let s=function(){return W_}();const i=t.mutations;for(let o=0;o<i.length;o++)s=s.insert(i[o].key,n[o].version);return new $a(t,e,n,s)}}/**
1148 * @license
1149 * Copyright 2022 Google LLC
1150 *
1151 * Licensed under the Apache License, Version 2.0 (the "License");
1152 * you may not use this file except in compliance with the License.
1153 * You may obtain a copy of the License at
1154 *
1155 *   http://www.apache.org/licenses/LICENSE-2.0
1156 *
1157 * Unless required by applicable law or agreed to in writing, software
1158 * distributed under the License is distributed on an "AS IS" BASIS,
1159 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1160 * See the License for the specific language governing permissions and
1161 * limitations under the License.
1162 */class Ka{constructor(t,e){this.largestBatchId=t,this.mutation=e}getKey(){return this.mutation.key}isEqual(t){return t!==null&&this.mutation===t.mutation}toString(){return`Overlay{
1163      largestBatchId: ${this.largestBatchId},
1164      mutation: ${this.mutation.toString()}
1165    }`}}/**
1166 * @license
1167 * Copyright 2023 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 zd{constructor(t,e,n){this.alias=t,this.aggregateType=e,this.fieldPath=n}}/**
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 ry{constructor(t,e){this.count=t,this.unchangedNames=e}}/**
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 */var _t,J;function Gd(r){switch(r){case R.OK:return F(64938);case R.CANCELLED:case R.UNKNOWN:case R.DEADLINE_EXCEEDED:case R.RESOURCE_EXHAUSTED:case R.INTERNAL:case R.UNAVAILABLE:case R.UNAUTHENTICATED:return!1;case R.INVALID_ARGUMENT:case R.NOT_FOUND:case R.ALREADY_EXISTS:case R.PERMISSION_DENIED:case R.FAILED_PRECONDITION:case R.ABORTED:case R.OUT_OF_RANGE:case R.UNIMPLEMENTED:case R.DATA_LOSS:return!0;default:return F(15467,{code:r})}}function $d(r){if(r===void 0)return gt("GRPC error has no .code"),R.UNKNOWN;switch(r){case _t.OK:return R.OK;case _t.CANCELLED:return R.CANCELLED;case _t.UNKNOWN:return R.UNKNOWN;case _t.DEADLINE_EXCEEDED:return R.DEADLINE_EXCEEDED;case _t.RESOURCE_EXHAUSTED:return R.RESOURCE_EXHAUSTED;case _t.INTERNAL:return R.INTERNAL;case _t.UNAVAILABLE:return R.UNAVAILABLE;case _t.UNAUTHENTICATED:return R.UNAUTHENTICATED;case _t.INVALID_ARGUMENT:return R.INVALID_ARGUMENT;case _t.NOT_FOUND:return R.NOT_FOUND;case _t.ALREADY_EXISTS:return R.ALREADY_EXISTS;case _t.PERMISSION_DENIED:return R.PERMISSION_DENIED;case _t.FAILED_PRECONDITION:return R.FAILED_PRECONDITION;case _t.ABORTED:return R.ABORTED;case _t.OUT_OF_RANGE:return R.OUT_OF_RANGE;case _t.UNIMPLEMENTED:return R.UNIMPLEMENTED;case _t.DATA_LOSS:return R.DATA_LOSS;default:return F(39323,{code:r})}}(J=_t||(_t={}))[J.OK=0]="OK",J[J.CANCELLED=1]="CANCELLED",J[J.UNKNOWN=2]="UNKNOWN",J[J.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",J[J.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",J[J.NOT_FOUND=5]="NOT_FOUND",J[J.ALREADY_EXISTS=6]="ALREADY_EXISTS",J[J.PERMISSION_DENIED=7]="PERMISSION_DENIED",J[J.UNAUTHENTICATED=16]="UNAUTHENTICATED",J[J.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",J[J.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",J[J.ABORTED=10]="ABORTED",J[J.OUT_OF_RANGE=11]="OUT_OF_RANGE",J[J.UNIMPLEMENT
1210ED=12]="UNIMPLEMENTED",J[J.INTERNAL=13]="INTERNAL",J[J.UNAVAILABLE=14]="UNAVAILABLE",J[J.DATA_LOSS=15]="DATA_LOSS";/**
1211 * @license
1212 * Copyright 2023 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 */let da=null;/**
1226 * @license
1227 * Copyright 2023 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 */function Kd(){return new TextEncoder}/**
1241 * @license
1242 * Copyright 2022 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 sy=new Ce([4294967295,4294967295],0);function wl(r){const t=Kd().encode(r),e=new Nh;return e.update(t),new Uint8Array(e.digest())}function Al(r){const t=new DataView(r.buffer),e=t.getUint32(0,!0),n=t.getUint32(4,!0),s=t.getUint32(8,!0),i=t.getUint32(12,!0);return[new Ce([e,n],0),new Ce([s,i],0)]}class Qa{constructor(t,e,n){if(this.bitmap=t,this.padding=e,this.hashCount=n,e<0||e>=8)throw new Qr(`Invalid padding: ${e}`);if(n<0)throw new Qr(`Invalid hash count: ${n}`);if(t.length>0&&this.hashCount===0)throw new Qr(`Invalid hash count: ${n}`);if(t.length===0&&e!==0)throw new Qr(`Invalid padding when bitmap length is 0: ${e}`);this.ge=8*t.length-e,this.pe=Ce.fromNumber(this.ge)}ye(t,e,n){let s=t.add(e.multiply(Ce.fromNumber(n)));return s.compare(sy)===1&&(s=new Ce([s.getBits(0),s.getBits(1)],0)),s.modulo(this.pe).toNumber()}we(t){return!!(this.bitmap[Math.floor(t/8)]&1<<t%8)}mightContain(t){if(this.ge===0)return!1;const e=wl(t),[n,s]=Al(e);for(let i=0;i<this.hashCount;i++){const o=this.ye(n,s,i);if(!this.we(o))return!1}return!0}static create(t,e,n){const s=t%8==0?0:8-t%8,i=new Uint8Array(Math.ceil(t/8)),o=new Qa(i,s,e);return n.forEach(u=>o.insert(u)),o}insert(t){if(this.ge===0)return;const e=wl(t),[n,s]=Al(e);for(let i=0;i<this.hashCount;i++){const o=this.ye(n,s,i);this.Se(o)}}Se(t){const e=Math.floor(t/8),n=t%8;this.bitmap[e]|=1<<n}}class Qr extends Error{constructor(){super(...arguments),this.name="BloomFilterError"}}/**
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 */class Ss{constructor(t,e,n,s,i){this.snapshotVersion=t,this.targetChanges=e,this.targetMismatches=n,this.documentUpdates=s,this.resolvedLimboDocuments=i}static createSynthesizedRemoteEventForCurrentChange(t,e,n){const s=new Map;return s.set(t,Ps.createSynthesizedTargetChangeForCurrentChange(t,e,n)),new Ss(q.min(),s,new ot(z),Ut(),G())}}class Ps{constructor(t,e,n,s,i){this.resumeToken=t,this.current=e,this.addedDocuments=n,this.modifiedDocuments=s,this.removedDocuments=i}static createSynthesizedTargetChangeForCurrentChange(t,e,n){return new Ps(n,e,G(),G(),G())}}/**
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 hi{constructor(t,e,n,s){this.be=t,this.removedTargetIds=e,this.key=n,this.De=s}}class Qd{constructor(t,e){this.targetId=t,this.Ce=e}}class Wd{constructor(t,e,n=ft.EMPTY_BYTE_STRING,s=null){this.state=t,this.targetIds=e,this.resumeToken=n,this.cause=s}}class vl{constructor(){this.ve=0,this.Fe=bl(),this.Me=ft.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(t){t.approximateByteSize()>0&&(this.Oe=!0,this.Me=t)}ke(){let t=G(),e=G(),n=G();return this.Fe.forEach((s,i)=>{switch(i){case 0:t=t.add(s);break;case 2:e=e.add(s);break;case 1:n=n.add(s);break;default:F(38017,{changeType:i})}}),new Ps(this.Me,this.xe,t,e,n)}qe(){this.Oe=!1,this.Fe=bl()}Qe(t,e){this.Oe=!0,this.Fe=this.Fe.insert(t,e)}$e(t){this.Oe=!0,this.Fe=this.Fe.remove(t)}Ue(){this.ve+=1}Ke(){this.ve-=1,L(this.ve>=0,3241,{ve:this.ve})}We(){this.Oe=!0,this.xe=!0}}class iy{constructor(t){this.Ge=t,this.ze=new Map,this.je=Ut(),this.Je=Ys(),this.He=Ys(),this.Ye=new ot(z)}Ze(t){for(const e of t.be)t.De&&t.De.isFoundDocument()?this.Xe(e,t.De):this.et(e,t.key,t.De);for(const e of t.removedTargetIds)this.et(e,t.key,t.De)}tt(t){this.forEachTarget(t,e=>{const n=this.nt(e);switch(t.state){case 0:this.rt(e)&&n.Le(t.resumeToken);break;case 1:n.Ke(),n.Ne||n.qe(),n.Le(t.resumeToken);break;case 2:n.Ke(),n.Ne||this.removeTarget(e);break;case 3:this.rt(e)&&(n.We(),n.Le(t.resumeToken));break;case 4:this.rt(e)&&(this.it(e),n.Le(t.resumeToken));break;default:F(56790,{state:t.state})}})}forEachTarget(t,e){t.targetIds.length>0?t.targetIds.forEach(e):this.ze.forEach((n,s)=>{this.rt(s)&&e(s)})}st(t){const e=t.targetId,n=t.Ce.count,s=this.ot(e);if(s){const i=s.target;if(Ti(i))if(n===0){const o=new k(i.path);this.et(e,o,ut.newNoDocument(o,q.min()))}else L(n===1,20013,{expectedCount:n});else{const o=this._t(e);if(o!==n){const u=this.ut(t),c=u?this.ct(u,t,o):1;if(c!==0){this.it(e);const h=c===2?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch";this.Ye=this.Ye.insert(e,h)}da?.lt(function(f,m,p,v,C){const D={localCacheCount:f,existenceFilterCount:m.count,databaseId:p.database,projectId:p.projectId},x=m.unchangedNames;return x&&(D.bloomFilter={applied:C===0,hashCount:x?.hashCount??0,bitmapLength:x?.bits?.bitmap?.length??0,padding:x?.bits?.padding??0,mightContain:B=>v?.mightContain(B)??!1}),D}(o,t.Ce,this.Ge.ht(),u,c))}}}}ut(t){const e=t.Ce.unchangedNames;if(!e||!e.bits)return null;const{bits:{bitmap:n="",padding:s=0},hashCount:i=0}=e;let o,u;try{o=le(n).toUint8Array()}catch(c){if(c instanceof ld)return $t("Decoding the base64 bloom filter in existence filter failed ("+c.message+"); ignoring the bloom filter and falling back to full re-query."),null;throw c}try{u=new Qa(o,s,i)}catch(c){return $t(c instanceof Qr?"BloomFilter error: ":"Applying bloom filter failed: ",c),null}return u.ge===0?null:u}ct(t,e,n){return e.Ce.count===n-this.Pt(t,e.targetId)?0:2}Pt(t,e){const n=this.Ge.getRemoteKeysForTarget(e);let s=0;return n.forEach(i=>{const o=this.Ge.ht(),u=`projects/${o.projectId}/databases/${o.database}/documents/${i.path.canonicalString()}`;t.mightContain(u)||(this.et(e,i,null),s++)}),s}Tt(t){const e=new Map;this.ze.forEach((i,o)=>{const u=this.ot(o);if(u){if(i.current&&Ti(u.target)){const c=new k(u.target.path);this.It(c).has(o)||this.Et(o,c)||this.et(o,c,ut.newNoDocument(c,t))}i.Be&&(e.set(o,i.ke()),i.qe())}});let n=G();this.He.forEach((i,o)=>{let u=!0;o.forEachWhile(c=>{const h=this.ot(c);return!h||h.purpose==="TargetPurposeLimboResolution"||(u=!1,!1)}),u&&(n=n.add(i))}),this.je.forEach((i,o)=>o.setReadTime(t));const s=new Ss(t,e,this.Ye,this.je,n);return this.je=Ut(),this.Je=Ys(),this.He=Ys(),this.Ye=new ot(z),s}Xe(t,e){if(!this.rt(t))return;const n=this.Et(t,e.key)?2:0;this.nt(t).Qe(e.key,n),this.je=this.je.insert(e.key,e),this.Je=this.Je.insert(e.key,this.It(e.key).add(t)),this.He=this.He.insert(e.key,this.dt(e.key).add(t))}et(t,e,n){if(!this.rt(t))return;const s=this.nt(t);this.Et(t,e)?s.Qe(e,1):s.$e(e),this.He=this.He.insert(e,this.dt(e).delete(t)),this.He=this.He.insert(e,this.dt(e).add(t)),n&&(this.je=this.je.insert(e,n))}removeTarget(t){this.ze.delete(t)}_t(t){const e=this.nt(t).ke();return this.Ge.getRemoteKeysForTarget(t).size+e.addedDocuments.size-e.removedDocuments.size}Ue(t){this.nt(t).Ue()}nt(t){let e=this.ze.get(t);return e||(e=new vl,this.ze.set(t,e)),e}dt(t){let e=this.He.get(t);return e||(e=new rt(z),this.He=this.He.insert(t,e)),e}It(t){let e=this.Je.get(t);return e||(e=new rt(z),this.Je=this.Je.insert(t,e)),e}rt(t){const e=this.ot(t)!==null;return e||N("WatchChangeAggregator","Detected inactive target",t),e}
1285ot(t){const e=this.ze.get(t);return e&&e.Ne?null:this.Ge.At(t)}it(t){this.ze.set(t,new vl),this.Ge.getRemoteKeysForTarget(t).forEach(e=>{this.et(t,e,null)})}Et(t,e){return this.Ge.getRemoteKeysForTarget(t).has(e)}}function Ys(){return new ot(k.comparator)}function bl(){return new ot(k.comparator)}const oy={asc:"ASCENDING",desc:"DESCENDING"},ay={"<":"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"},uy={and:"AND",or:"OR"};class cy{constructor(t,e){this.databaseId=t,this.useProto3Json=e}}function fa(r,t){return r.useProto3Json||Ts(t)?t:{value:t}}function rr(r,t){return r.useProto3Json?`${new Date(1e3*t.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+t.nanoseconds).slice(-9)}Z`:{seconds:""+t.seconds,nanos:t.nanoseconds}}function Hd(r,t){return r.useProto3Json?t.toBase64():t.toUint8Array()}function ly(r,t){return rr(r,t.toTimestamp())}function pt(r){return L(!!r,49232),q.fromTimestamp(function(e){const n=ce(e);return new tt(n.seconds,n.nanos)}(r))}function Wa(r,t){return ma(r,t).canonicalString()}function ma(r,t){const e=function(s){return new K(["projects",s.projectId,"databases",s.database])}(r).child("documents");return t===void 0?e:e.child(t)}function Jd(r){const t=K.fromString(r);return L(of(t),10190,{key:t.toString()}),t}function _s(r,t){return Wa(r.databaseId,t.path)}function se(r,t){const e=Jd(t);if(e.get(1)!==r.databaseId.projectId)throw new V(R.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+e.get(1)+" vs "+r.databaseId.projectId);if(e.get(3)!==r.databaseId.database)throw new V(R.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+e.get(3)+" vs "+r.databaseId.database);return new k(Zd(e))}function Xd(r,t){return Wa(r.databaseId,t)}function Yd(r){const t=Jd(r);return t.length===4?K.emptyPath():Zd(t)}function ga(r){return new K(["projects",r.databaseId.projectId,"databases",r.databaseId.database]).canonicalString()}function Zd(r){return L(r.length>4&&r.get(4)==="documents",29091,{key:r.toString()}),r.popFirst(5)}function Rl(r,t,e){return{name:_s(r,t),fields:e.value.mapValue.fields}}function Ki(r,t,e){const n=se(r,t.name),s=pt(t.updateTime),i=t.createTime?pt(t.createTime):q.min(),o=new Pt({mapValue:{fields:t.fields}}),u=ut.newFoundDocument(n,s,i,o);return e&&u.setHasCommittedMutations(),e?u.setHasCommittedMutations():u}function hy(r,t){return"found"in t?function(n,s){L(!!s.found,43571),s.found.name,s.found.updateTime;const i=se(n,s.found.name),o=pt(s.found.updateTime),u=s.found.createTime?pt(s.found.createTime):q.min(),c=new Pt({mapValue:{fields:s.found.fields}});return ut.newFoundDocument(i,o,u,c)}(r,t):"missing"in t?function(n,s){L(!!s.missing,3894),L(!!s.readTime,22933);const i=se(n,s.missing),o=pt(s.readTime);return ut.newNoDocument(i,o)}(r,t):F(7234,{result:t})}function dy(r,t){let e;if("targetChange"in t){t.targetChange;const n=function(h){return h==="NO_CHANGE"?0:h==="ADD"?1:h==="REMOVE"?2:h==="CURRENT"?3:h==="RESET"?4:F(39313,{state:h})}(t.targetChange.targetChangeType||"NO_CHANGE"),s=t.targetChange.targetIds||[],i=function(h,f){return h.useProto3Json?(L(f===void 0||typeof f=="string",58123),ft.fromBase64String(f||"")):(L(f===void 0||f instanceof Buffer||f instanceof Uint8Array,16193),ft.fromUint8Array(f||new Uint8Array))}(r,t.targetChange.resumeToken),o=t.targetChange.cause,u=o&&function(h){const f=h.code===void 0?R.UNKNOWN:$d(h.code);return new V(f,h.message||"")}(o);e=new Wd(n,s,i,u||null)}else if("documentChange"in t){t.documentChange;const n=t.documentChange;n.document,n.document.name,n.document.updateTime;const s=se(r,n.document.name),i=pt(n.document.updateTime),o=n.document.createTime?pt(n.document.createTime):q.min(),u=new Pt({mapValue:{fields:n.document.fields}}),c=ut.newFoundDocument(s,i,o,u),h=n.targetIds||[],f=n.removedTargetIds||[];e=new hi(h,f,c.key,c)}else if("documentDelete"in t){t.documentDelete;const n=t.documentDelete;n.document;const s=se(r,n.document),i=n.readTime?pt(n.readTime):q.min(),o=ut.newNoDocument(s,i),u=n.removedTargetIds||[];
1285e=new hi([],u,o.key,o)}else if("documentRemove"in t){t.documentRemove;const n=t.documentRemove;n.document;const s=se(r,n.document),i=n.removedTargetIds||[];e=new hi([],i,s,null)}else{if(!("filter"in t))return F(11601,{Rt:t});{t.filter;const n=t.filter;n.targetId;const{count:s=0,unchangedNames:i}=n,o=new ry(s,i),u=n.targetId;e=new Qd(u,o)}}return e}function ys(r,t){let e;if(t instanceof mr)e={update:Rl(r,t.key,t.value)};else if(t instanceof gr)e={delete:_s(r,t.key)};else if(t instanceof fe)e={update:Rl(r,t.key,t.data),updateMask:yy(t.fieldMask)};else{if(!(t instanceof za))return F(16599,{Vt:t.type});e={verify:_s(r,t.key)}}return t.fieldTransforms.length>0&&(e.updateTransforms=t.fieldTransforms.map(n=>function(i,o){const u=o.transform;if(u instanceof er)return{fieldPath:o.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(u instanceof pn)return{fieldPath:o.field.canonicalString(),appendMissingElements:{values:u.elements}};if(u instanceof _n)return{fieldPath:o.field.canonicalString(),removeAllFromArray:{values:u.elements}};if(u instanceof nr)return{fieldPath:o.field.canonicalString(),increment:u.Ae};throw F(20930,{transform:o.transform})}(0,n))),t.precondition.isNone||(e.currentDocument=function(s,i){return i.updateTime!==void 0?{updateTime:ly(s,i.updateTime)}:i.exists!==void 0?{exists:i.exists}:F(27497)}(r,t.precondition)),e}function pa(r,t){const e=t.currentDocument?function(i){return i.updateTime!==void 0?ht.updateTime(pt(i.updateTime)):i.exists!==void 0?ht.exists(i.exists):ht.none()}(t.currentDocument):ht.none(),n=t.updateTransforms?t.updateTransforms.map(s=>function(o,u){let c=null;if("setToServerValue"in u)L(u.setToServerValue==="REQUEST_TIME",16630,{proto:u}),c=new er;else if("appendMissingElements"in u){const f=u.appendMissingElements.values||[];c=new pn(f)}else if("removeAllFromArray"in u){const f=u.removeAllFromArray.values||[];c=new _n(f)}else"increment"in u?c=new nr(o,u.increment):F(16584,{proto:u});const h=ct.fromServerFormat(u.fieldPath);return new Rs(h,c)}(r,s)):[];if(t.update){t.update.name;const s=se(r,t.update.name),i=new Pt({mapValue:{fields:t.update.fields}});if(t.updateMask){const o=function(c){const h=c.fieldPaths||[];return new Bt(h.map(f=>ct.fromServerFormat(f)))}(t.updateMask);return new fe(s,i,o,e,n)}return new mr(s,i,e,n)}if(t.delete){const s=se(r,t.delete);return new gr(s,e)}if(t.verify){const s=se(r,t.verify);return new za(s,e)}return F(1463,{proto:t})}function fy(r,t){return r&&r.length>0?(L(t!==void 0,14353),r.map(e=>function(s,i){let o=s.updateTime?pt(s.updateTime):pt(i);return o.isEqual(q.min())&&(o=pt(i)),new ty(o,s.transformResults||[])}(e,t))):[]}function tf(r,t){return{documents:[Xd(r,t.path)]}}function Qi(r,t){const e={structuredQuery:{}},n=t.path;let s;t.collectionGroup!==null?(s=n,e.structuredQuery.from=[{collectionId:t.collectionGroup,allDescendants:!0}]):(s=n.popLast(),e.structuredQuery.from=[{collectionId:n.lastSegment()}]),e.parent=Xd(r,s);const i=function(h){if(h.length!==0)return sf(et.create(h,"and"))}(t.filters);i&&(e.structuredQuery.where=i);const o=function(h){if(h.length!==0)return h.map(f=>function(p){return{field:ve(p.field),direction:gy(p.dir)}}(f))}(t.orderBy);o&&(e.structuredQuery.orderBy=o);const u=fa(r,t.limit);return u!==null&&(e.structuredQuery.limit=u),t.startAt&&(e.structuredQuery.startAt=function(h){return{before:h.inclusive,values:h.position}}(t.startAt)),t.endAt&&(e.structuredQuery.endAt=function(h){return{before:!h.inclusive,values:h.position}}(t.endAt)),{ft:e,parent:s}}function ef(r,t,e,n){const{ft:s,parent:i}=Qi(r,t),o={},u=[];let c=0;return e.forEach(h=>{const f=n?h.alias:"aggregate_"+c++;o[f]=h.alias,h.aggregateType==="count"?u.push({alias:f,count:{}}):h.aggregateType==="avg"?u.push({alias:f,avg:{field:ve(h.fieldPath)}}):h.aggregateType==="sum"&&u.push({alias:f,sum:{field:ve(h.fieldPath)}})}),{request:{structuredAggregationQuery:{aggregations:u,structuredQuery:s.structuredQuery},parent:s.parent},gt:o,parent:i}}function nf(r){let t=Yd(r.parent);const e=r.structuredQuery,n=e.from?e.from.length:0;let s=null;if(n>0){L(n===1,65062);const f=e.from[0];f.allDescendants?s=f.collectionId:t=t.child(f.collectionId)}let i=[];e.where&&(i=function(m){const p=rf(m);
1285return p instanceof et&&Ba(p)?p.getFilters():[p]}(e.where));let o=[];e.orderBy&&(o=function(m){return m.map(p=>function(C){return new ps(Bn(C.field),function(x){switch(x){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(C.direction))}(p))}(e.orderBy));let u=null;e.limit&&(u=function(m){let p;return p=typeof m=="object"?m.value:m,Ts(p)?null:p}(e.limit));let c=null;e.startAt&&(c=function(m){const p=!!m.before,v=m.values||[];return new Fe(v,p)}(e.startAt));let h=null;return e.endAt&&(h=function(m){const p=!m.before,v=m.values||[];return new Fe(v,p)}(e.endAt)),Rd(t,s,o,i,u,"F",c,h)}function my(r,t){const e=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 F(28987,{purpose:s})}}(t.purpose);return e==null?null:{"goog-listen-tags":e}}function rf(r){return r.unaryFilter!==void 0?function(e){switch(e.unaryFilter.op){case"IS_NAN":const n=Bn(e.unaryFilter.field);return W.create(n,"==",{doubleValue:NaN});case"IS_NULL":const s=Bn(e.unaryFilter.field);return W.create(s,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":const i=Bn(e.unaryFilter.field);return W.create(i,"!=",{doubleValue:NaN});case"IS_NOT_NULL":const o=Bn(e.unaryFilter.field);return W.create(o,"!=",{nullValue:"NULL_VALUE"});case"OPERATOR_UNSPECIFIED":return F(61313);default:return F(60726)}}(r):r.fieldFilter!==void 0?function(e){return W.create(Bn(e.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 F(58110);default:return F(50506)}}(e.fieldFilter.op),e.fieldFilter.value)}(r):r.compositeFilter!==void 0?function(e){return et.create(e.compositeFilter.filters.map(n=>rf(n)),function(s){switch(s){case"AND":return"and";case"OR":return"or";default:return F(1026)}}(e.compositeFilter.op))}(r):F(30097,{filter:r})}function gy(r){return oy[r]}function py(r){return ay[r]}function _y(r){return uy[r]}function ve(r){return{fieldPath:r.canonicalString()}}function Bn(r){return ct.fromServerFormat(r.fieldPath)}function sf(r){return r instanceof W?function(e){if(e.op==="=="){if(ll(e.value))return{unaryFilter:{field:ve(e.field),op:"IS_NAN"}};if(cl(e.value))return{unaryFilter:{field:ve(e.field),op:"IS_NULL"}}}else if(e.op==="!="){if(ll(e.value))return{unaryFilter:{field:ve(e.field),op:"IS_NOT_NAN"}};if(cl(e.value))return{unaryFilter:{field:ve(e.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:ve(e.field),op:py(e.op),value:e.value}}}(r):r instanceof et?function(e){const n=e.getFilters().map(s=>sf(s));return n.length===1?n[0]:{compositeFilter:{op:_y(e.op),filters:n}}}(r):F(54877,{filter:r})}function yy(r){const t=[];return r.fields.forEach(e=>t.push(e.canonicalString())),{fieldPaths:t}}function of(r){return r.length>=4&&r.get(0)==="projects"&&r.get(2)==="databases"}/**
1286 * @license
1287 * Copyright 2017 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 */class oe{constructor(t,e,n,s,i=q.min(),o=q.min(),u=ft.EMPTY_BYTE_STRING,c=null){this.target=t,this.targetId=e,this.purpose=n,this.sequenceNumber=s,this.snapshotVersion=i,this.lastLimboFreeSnapshotVersion=o,this.resumeToken=u,this.expectedCount=c}withSequenceNumber(t){return new oe(this.target,this.targetId,this.purpose,t,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(t,e){return new oe(this.target,this.targetId,this.purpose,this.sequenceNumber,e,this.lastLimboFreeSnapshotVersion,t,null)}withExpectedCount(t){return new oe(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,t)}withLastLimboFreeSnapshotVersion(t){return new oe(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,t,this.resumeToken,this.expectedCount)}}/**
1301 * @license
1302 * Copyright 2017 Google LLC
1303 *
1304 * Licensed under the Apache License, Version 2.0 (the "License");
1305 * you may not use this file except in compliance with the License.
1306 * You may obtain a copy of the License at
1307 *
1308 *   http://www.apache.org/licenses/LICENSE-2.0
1309 *
1310 * Unless required by applicable law or agreed to in writing, software
1311 * distributed under the License is distributed on an "AS IS" BASIS,
1312 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313 * See the License for the specific language governing permissions and
1314 * limitations under the License.
1315 */class af{constructor(t){this.yt=t}}function Iy(r,t){let e;if(t.document)e=Ki(r.yt,t.document,!!t.hasCommittedMutations);else if(t.noDocument){const n=k.fromSegments(t.noDocument.path),s=In(t.noDocument.readTime);e=ut.newNoDocument(n,s),t.hasCommittedMutations&&e.setHasCommittedMutations()}else{if(!t.unknownDocument)return F(56709);{const n=k.fromSegments(t.unknownDocument.path),s=In(t.unknownDocument.version);e=ut.newUnknownDocument(n,s)}}return t.readTime&&e.setReadTime(function(s){const i=new tt(s[0],s[1]);return q.fromTimestamp(i)}(t.readTime)),e}function Sl(r,t){const e=t.key,n={prefixPath:e.getCollectionPath().popLast().toArray(),collectionGroup:e.collectionGroup,documentId:e.path.lastSegment(),readTime:vi(t.readTime),hasCommittedMutations:t.hasCommittedMutations};if(t.isFoundDocument())n.document=function(i,o){return{name:_s(i,o.key),fields:o.data.value.mapValue.fields,updateTime:rr(i,o.version.toTimestamp()),createTime:rr(i,o.createTime.toTimestamp())}}(r.yt,t);else if(t.isNoDocument())n.noDocument={path:e.path.toArray(),readTime:yn(t.version)};else{if(!t.isUnknownDocument())return F(57904,{document:t});n.unknownDocument={path:e.path.toArray(),version:yn(t.version)}}return n}function vi(r){const t=r.toTimestamp();return[t.seconds,t.nanoseconds]}function yn(r){const t=r.toTimestamp();return{seconds:t.seconds,nanoseconds:t.nanoseconds}}function In(r){const t=new tt(r.seconds,r.nanoseconds);return q.fromTimestamp(t)}function an(r,t){const e=(t.baseMutations||[]).map(i=>pa(r.yt,i));for(let i=0;i<t.mutations.length-1;++i){const o=t.mutations[i];if(i+1<t.mutations.length&&t.mutations[i+1].transform!==void 0){const u=t.mutations[i+1];o.updateTransforms=u.transform.fieldTransforms,t.mutations.splice(i+1,1),++i}}const n=t.mutations.map(i=>pa(r.yt,i)),s=tt.fromMillis(t.localWriteTimeMs);return new Ga(t.batchId,s,e,n)}function Wr(r){const t=In(r.readTime),e=r.lastLimboFreeSnapshotVersion!==void 0?In(r.lastLimboFreeSnapshotVersion):q.min();let n;return n=function(i){return i.documents!==void 0}(r.query)?function(i){const o=i.documents.length;return L(o===1,1966,{count:o}),Nt(fr(Yd(i.documents[0])))}(r.query):function(i){return Nt(nf(i))}(r.query),new oe(n,r.targetId,"TargetPurposeListen",r.lastListenSequenceNumber,t,e,ft.fromBase64String(r.resumeToken))}function uf(r,t){const e=yn(t.snapshotVersion),n=yn(t.lastLimboFreeSnapshotVersion);let s;s=Ti(t.target)?tf(r.yt,t.target):Qi(r.yt,t.target).ft;const i=t.resumeToken.toBase64();return{targetId:t.targetId,canonicalId:gn(t.target),readTime:e,resumeToken:i,lastListenSequenceNumber:t.sequenceNumber,lastLimboFreeSnapshotVersion:n,query:s}}function Wi(r){const t=nf({parent:r.parent,structuredQuery:r.structuredQuery});return r.limitType==="LAST"?Ai(t,t.limit,"L"):t}function Bo(r,t){return new Ka(t.largestBatchId,pa(r.yt,t.overlayMutation))}function Pl(r,t){const e=t.path.lastSegment();return[r,xt(t.path.popLast()),e]}function Vl(r,t,e,n){return{indexId:r,uid:t,sequenceNumber:e,readTime:yn(n.readTime),documentKey:xt(n.documentKey.path),largestBatchId:n.largestBatchId}}/**
1316 * @license
1317 * Copyright 2020 Google LLC
1318 *
1319 * Licensed under the Apache License, Version 2.0 (the "License");
1320 * you may not use this file except in compliance with the License.
1321 * You may obtain a copy of the License at
1322 *
1323 *   http://www.apache.org/licenses/LICENSE-2.0
1324 *
1325 * Unless required by applicable law or agreed to in writing, software
1326 * distributed under the License is distributed on an "AS IS" BASIS,
1327 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1328 * See the License for the specific language governing permissions and
1329 * limitations under the License.
1330 */class Ey{getBundleMetadata(t,e){return Cl(t).get(e).next(n=>{if(n)return function(i){return{id:i.bundleId,createTime:In(i.createTime),version:i.version}}(n)})}saveBundleMetadata(t,e){return Cl(t).put(function(s){return{bundleId:s.id,createTime:yn(pt(s.createTime)),version:s.version}}(e))}getNamedQuery(t,e){return Dl(t).get(e).next(n=>{if(n)return function(i){return{name:i.name,query:Wi(i.bundledQuery),readTime:In(i.readTime)}}(n)})}saveNamedQuery(t,e){return Dl(t).put(function(s){return{name:s.name,readTime:yn(pt(s.readTime)),bundledQuery:s.bundledQuery}}(e))}}function Cl(r){return wt(r,Li)}function Dl(r){return wt(r,Bi)}/**
1331 * @license
1332 * Copyright 2022 Google LLC
1333 *
1334 * Licensed under the Apache License, Version 2.0 (the "License");
1335 * you may not use this file except in compliance with the License.
1336 * You may obtain a copy of the License at
1337 *
1338 *   http://www.apache.org/licenses/LICENSE-2.0
1339 *
1340 * Unless required by applicable law or agreed to in writing, software
1341 * distributed under the License is distributed on an "AS IS" BASIS,
1342 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1343 * See the License for the specific language governing permissions and
1344 * limitations under the License.
1345 */class Hi{constructor(t,e){this.serializer=t,this.userId=e}static wt(t,e){const n=e.uid||"";return new Hi(t,n)}getOverlay(t,e){return Ur(t).get(Pl(this.userId,e)).next(n=>n?Bo(this.serializer,n):null)}getOverlays(t,e){const n=ne();return A.forEach(e,s=>this.getOverlay(t,s).next(i=>{i!==null&&n.set(s,i)})).next(()=>n)}saveOverlays(t,e,n){const s=[];return n.forEach((i,o)=>{const u=new Ka(e,o);s.push(this.St(t,u))}),A.waitFor(s)}removeOverlaysForBatchId(t,e,n){const s=new Set;e.forEach(o=>s.add(xt(o.getCollectionPath())));const i=[];return s.forEach(o=>{const u=IDBKeyRange.bound([this.userId,o,n],[this.userId,o,n+1],!1,!0);i.push(Ur(t).Z(sa,u))}),A.waitFor(i)}getOverlaysForCollection(t,e,n){const s=ne(),i=xt(e),o=IDBKeyRange.bound([this.userId,i,n],[this.userId,i,Number.POSITIVE_INFINITY],!0);return Ur(t).J(sa,o).next(u=>{for(const c of u){const h=Bo(this.serializer,c);s.set(h.getKey(),h)}return s})}getOverlaysForCollectionGroup(t,e,n,s){const i=ne();let o;const u=IDBKeyRange.bound([this.userId,e,n],[this.userId,e,Number.POSITIVE_INFINITY],!0);return Ur(t).ee({index:rd,range:u},(c,h,f)=>{const m=Bo(this.serializer,h);i.size()<s||m.largestBatchId===o?(i.set(m.getKey(),m),o=m.largestBatchId):f.done()}).next(()=>i)}St(t,e){return Ur(t).put(function(s,i,o){const[u,c,h]=Pl(i,o.mutation.key);return{userId:i,collectionPath:c,documentId:h,collectionGroup:o.mutation.key.getCollectionGroup(),largestBatchId:o.largestBatchId,overlayMutation:ys(s.yt,o.mutation)}}(this.serializer,this.userId,e))}}function Ur(r){return wt(r,Ui)}/**
1346 * @license
1347 * Copyright 2024 Google LLC
1348 *
1349 * Licensed under the Apache License, Version 2.0 (the "License");
1350 * you may not use this file except in compliance with the License.
1351 * You may obtain a copy of the License at
1352 *
1353 *   http://www.apache.org/licenses/LICENSE-2.0
1354 *
1355 * Unless required by applicable law or agreed to in writing, software
1356 * distributed under the License is distributed on an "AS IS" BASIS,
1357 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1358 * See the License for the specific language governing permissions and
1359 * limitations under the License.
1360 */class Ty{bt(t){return wt(t,Ma)}getSessionToken(t){return this.bt(t).get("sessionToken").next(e=>{const n=e?.value;return n?ft.fromUint8Array(n):ft.EMPTY_BYTE_STRING})}setSessionToken(t,e){return this.bt(t).put({name:"sessionToken",value:e.toUint8Array()})}}/**
1361 * @license
1362 * Copyright 2021 Google LLC
1363 *
1364 * Licensed under the Apache License, Version 2.0 (the "License");
1365 * you may not use this file except in compliance with the License.
1366 * You may obtain a copy of the License at
1367 *
1368 *   http://www.apache.org/licenses/LICENSE-2.0
1369 *
1370 * Unless required by applicable law or agreed to in writing, software
1371 * distributed under the License is distributed on an "AS IS" BASIS,
1372 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1373 * See the License for the specific language governing permissions and
1374 * limitations under the License.
1375 */class un{constructor(){}Dt(t,e){this.Ct(t,e),e.vt()}Ct(t,e){if("nullValue"in t)this.Ft(e,5);else if("booleanValue"in t)this.Ft(e,10),e.Mt(t.booleanValue?1:0);else if("integerValue"in t)this.Ft(e,15),e.Mt(lt(t.integerValue));else if("doubleValue"in t){const n=lt(t.doubleValue);isNaN(n)?this.Ft(e,13):(this.Ft(e,15),us(n)?e.Mt(0):e.Mt(n))}else if("timestampValue"in t){let n=t.timestampValue;this.Ft(e,20),typeof n=="string"&&(n=ce(n)),e.xt(`${n.seconds||""}`),e.Mt(n.nanos||0)}else if("stringValue"in t)this.Ot(t.stringValue,e),this.Nt(e);else if("bytesValue"in t)this.Ft(e,30),e.Bt(le(t.bytesValue)),this.Nt(e);else if("referenceValue"in t)this.Lt(t.referenceValue,e);else if("geoPointValue"in t){const n=t.geoPointValue;this.Ft(e,45),e.Mt(n.latitude||0),e.Mt(n.longitude||0)}else"mapValue"in t?pd(t)?this.Ft(e,Number.MAX_SAFE_INTEGER):zi(t)?this.kt(t.mapValue,e):(this.qt(t.mapValue,e),this.Nt(e)):"arrayValue"in t?(this.Qt(t.arrayValue,e),this.Nt(e)):F(19022,{$t:t})}Ot(t,e){this.Ft(e,25),this.Ut(t,e)}Ut(t,e){e.xt(t)}qt(t,e){const n=t.fields||{};this.Ft(e,55);for(const s of Object.keys(n))this.Ot(s,e),this.Ct(n[s],e)}kt(t,e){const n=t.fields||{};this.Ft(e,53);const s=Yn,i=n[s].arrayValue?.values?.length||0;this.Ft(e,15),e.Mt(lt(i)),this.Ot(s,e),this.Ct(n[s],e)}Qt(t,e){const n=t.values||[];this.Ft(e,50);for(const s of n)this.Ct(s,e)}Lt(t,e){this.Ft(e,37),k.fromName(t).path.forEach(n=>{this.Ft(e,60),this.Ut(n,e)})}Ft(t,e){t.Mt(e)}Nt(t){t.Mt(2)}}
1375un.Kt=new un;/**
1376 * @license
1377 * Copyright 2021 Google LLC
1378 *
1379 * Licensed under the Apache License, Version 2.0 (the "License");
1380 * you may not use this file except in compliance with the License.
1381 * You may obtain a copy of the License at
1382 *
1383 *   http://www.apache.org/licenses/LICENSE-2.0
1384 *
1385 * Unless required by applicable law | agreed to in writing, software
1386 * distributed under the License is distributed on an "AS IS" BASIS,
1387 * WITHOUT WARRANTIES | CONDITIONS OF ANY KIND, either express | implied.
1388 * See the License for the specific language governing permissions and
1389 * limitations under the License.
1390 */const Nn=255;function wy(r){if(r===0)return 8;let t=0;return r>>4||(t+=4,r<<=4),r>>6||(t+=2,r<<=2),r>>7||(t+=1),t}function xl(r){const t=64-function(n){let s=0;for(let i=0;i<8;++i){const o=wy(255&n[i]);if(s+=o,o!==8)break}return s}(r);return Math.ceil(t/8)}class Ay{constructor(){this.buffer=new Uint8Array(1024),this.position=0}Wt(t){const e=t[Symbol.iterator]();let n=e.next();for(;!n.done;)this.Gt(n.value),n=e.next();this.zt()}jt(t){const e=t[Symbol.iterator]();let n=e.next();for(;!n.done;)this.Jt(n.value),n=e.next();this.Ht()}Yt(t){for(const e of t){const n=e.charCodeAt(0);if(n<128)this.Gt(n);else if(n<2048)this.Gt(960|n>>>6),this.Gt(128|63&n);else if(e<"\uD800"||"\uDBFF"<e)this.Gt(480|n>>>12),this.Gt(128|63&n>>>6),this.Gt(128|63&n);else{const s=e.codePointAt(0);this.Gt(240|s>>>18),this.Gt(128|63&s>>>12),this.Gt(128|63&s>>>6),this.Gt(128|63&s)}}this.zt()}Zt(t){for(const e of t){const n=e.charCodeAt(0);if(n<128)this.Jt(n);else if(n<2048)this.Jt(960|n>>>6),this.Jt(128|63&n);else if(e<"\uD800"||"\uDBFF"<e)this.Jt(480|n>>>12),this.Jt(128|63&n>>>6),this.Jt(128|63&n);else{const s=e.codePointAt(0);this.Jt(240|s>>>18),this.Jt(128|63&s>>>12),this.Jt(128|63&s>>>6),this.Jt(128|63&s)}}this.Ht()}Xt(t){const e=this.en(t),n=xl(e);this.tn(1+n),this.buffer[this.position++]=255&n;for(let s=e.length-n;s<e.length;++s)this.buffer[this.position++]=255&e[s]}nn(t){const e=this.en(t),n=xl(e);this.tn(1+n),this.buffer[this.position++]=~(255&n);for(let s=e.length-n;s<e.length;++s)this.buffer[this.position++]=~(255&e[s])}rn(){this.sn(Nn),this.sn(255)}_n(){this.an(Nn),this.an(255)}reset(){this.position=0}seed(t){this.tn(t.length),this.buffer.set(t,this.position),this.position+=t.length}un(){return this.buffer.slice(0,this.position)}en(t){const e=function(i){const o=new DataView(new ArrayBuffer(8));return o.setFloat64(0,i,!1),new Uint8Array(o.buffer)}(t),n=!!(128&e[0]);e[0]^=n?255:128;for(let s=1;s<e.length;++s)e[s]^=n?255:0;return e}Gt(t){const e=255&t;e===0?(this.sn(0),this.sn(255)):e===Nn?(this.sn(Nn),this.sn(0)):this.sn(e)}Jt(t){const e=255&t;e===0?(this.an(0),this.an(255)):e===Nn?(this.an(Nn),this.an(0)):this.an(t)}zt(){this.sn(0),this.sn(1)}Ht(){this.an(0),this.an(1)}sn(t){this.tn(1),this.buffer[this.position++]=t}an(t){this.tn(1),this.buffer[this.position++]=~t}tn(t){const e=t+this.position;if(e<=this.buffer.length)return;let n=2*this.buffer.length;n<e&&(n=e);const s=new Uint8Array(n);s.set(this.buffer),this.buffer=s}}class vy{constructor(t){this.cn=t}Bt(t){this.cn.Wt(t)}xt(t){this.cn.Yt(t)}Mt(t){this.cn.Xt(t)}vt(){this.cn.rn()}}class by{constructor(t){this.cn=t}Bt(t){this.cn.jt(t)}xt(t){this.cn.Zt(t)}Mt(t){this.cn.nn(t)}vt(){this.cn._n()}}class qr{constructor(){this.cn=new Ay,this.ln=new vy(this.cn),this.hn=new by(this.cn)}seed(t){this.cn.seed(t)}Pn(t){return t===0?this.ln:this.hn}un(){return this.cn.un()}reset(){this.cn.reset()}}/**
1391 * @license
1392 * Copyright 2022 Google LLC
1393 *
1394 * Licensed under the Apache License, Version 2.0 (the "License");
1395 * you may not use this file except in compliance with the License.
1396 * You may obtain a copy of the License at
1397 *
1398 *   http://www.apache.org/licenses/LICENSE-2.0
1399 *
1400 * Unless required by applicable law or agreed to in writing, software
1401 * distributed under the License is distributed on an "AS IS" BASIS,
1402 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1403 * See the License for the specific language governing permissions and
1404 * limitations under the License.
1405 */class cn{constructor(t,e,n,s){this.Tn=t,this.In=e,this.En=n,this.dn=s}An(){const t=this.dn.length,e=t===0||this.dn[t-1]===255?t+1:t,n=new Uint8Array(e);return n.set(this.dn,0),e!==t?n.set([0],this.dn.length):++n[n.length-1],new cn(this.Tn,this.In,this.En,n)}Rn(t,e,n){return{indexId:this.Tn,uid:t,arrayValue:di(this.En),directionalValue:di(this.dn),orderedDocumentKey:di(e),documentKey:n.path.toArray()}}Vn(t,e,n){const s=this.Rn(t,e,n);return[s.indexId,s.uid,s.arrayValue,s.directionalValue,s.orderedDocumentKey,s.documentKey]}}function Te(r,t){let e=r.Tn-t.Tn;return e!==0?e:(e=Nl(r.En,t.En),e!==0?e:(e=Nl(r.dn,t.dn),e!==0?e:k.comparator(r.In,t.In)))}function Nl(r,t){for(let e=0;e<r.length&&e<t.length;++e){const n=r[e]-t[e];if(n!==0)return n}return r.length-t.length}function di(r){return bh()?function(e){let n="";for(let s=0;s<e.length;s++)n+=String.fromCharCode(e[s]);return n}(r):r}function kl(r){return typeof r!="string"?r:function(e){const n=new Uint8Array(e.length);for(let s=0;s<e.length;s++)n[s]=e.charCodeAt(s);return n}(r)}class Ml{constructor(t){this.mn=new rt((e,n)=>ct.comparator(e.field,n.field)),this.collectionId=t.collectionGroup!=null?t.collectionGroup:t.path.lastSegment(),this.fn=t.orderBy,this.gn=[];for(const e of t.filters){const n=e;n.isInequality()?this.mn=this.mn.add(n):this.gn.push(n)}}get pn(){return this.mn.size>1}yn(t){if(L(t.collectionGroup===this.collectionId,49279),this.pn)return!1;const e=ea(t);if(e!==void 0&&!this.wn(e))return!1;const n=rn(t);let s=new Set,i=0,o=0;for(;i<n.length&&this.wn(n[i]);++i)s=s.add(n[i].fieldPath.canonicalString());if(i===n.length)return!0;
1405if(this.mn.size>0){const u=this.mn.getIterator().getNext();if(!s.has(u.field.canonicalString())){const c=n[i];if(!this.Sn(u,c)||!this.bn(this.fn[o++],c))return!1}++i}for(;i<n.length;++i){const u=n[i];if(o>=this.fn.length||!this.bn(this.fn[o++],u))return!1}return!0}Dn(){if(this.pn)return null;let t=new rt(ct.comparator);const e=[];for(const n of this.gn)if(!n.field.isKeyField())if(n.op==="array-contains"||n.op==="array-contains-any")e.push(new hn(n.field,2));else{if(t.has(n.field))continue;t=t.add(n.field),e.push(new hn(n.field,0))}for(const n of this.fn)n.field.isKeyField()||t.has(n.field)||(t=t.add(n.field),e.push(new hn(n.field,n.dir==="asc"?0:1)));return new Kn(Kn.UNKNOWN_ID,this.collectionId,e,Qn.empty())}wn(t){for(const e of this.gn)if(this.Sn(e,t))return!0;return!1}Sn(t,e){if(t===void 0||!t.field.isEqual(e.fieldPath))return!1;const n=t.op==="array-contains"||t.op==="array-contains-any";return e.kind===2===n}bn(t,e){return!!t.field.isEqual(e.fieldPath)&&(e.kind===0&&t.dir==="asc"||e.kind===1&&t.dir==="desc")}}/**
1406 * @license
1407 * Copyright 2022 Google LLC
1408 *
1409 * Licensed under the Apache License, Version 2.0 (the "License");
1410 * you may not use this file except in compliance with the License.
1411 * You may obtain a copy of the License at
1412 *
1413 *   http://www.apache.org/licenses/LICENSE-2.0
1414 *
1415 * Unless required by applicable law or agreed to in writing, software
1416 * distributed under the License is distributed on an "AS IS" BASIS,
1417 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1418 * See the License for the specific language governing permissions and
1419 * limitations under the License.
1420 */function cf(r){if(L(r instanceof W||r instanceof et,20012),r instanceof W){if(r instanceof bd){const e=r.value.arrayValue?.values?.map(n=>W.create(r.field,"==",n))||[];return et.create(e,"or")}return r}const t=r.filters.map(e=>cf(e));return et.create(t,r.op)}function Ry(r){if(r.getFilters().length===0)return[];const t=Ia(cf(r));return L(lf(t),7391),_a(t)||ya(t)?[t]:t.getFilters()}function _a(r){return r instanceof W}function ya(r){return r instanceof et&&Ba(r)}function lf(r){return _a(r)||ya(r)||function(e){if(e instanceof et&&ua(e)){for(const n of e.getFilters())if(!_a(n)&&!ya(n))return!1;return!0}return!1}(r)}function Ia(r){if(L(r instanceof W||r instanceof et,34018),r instanceof W)return r;if(r.filters.length===1)return Ia(r.filters[0]);const t=r.filters.map(n=>Ia(n));let e=et.create(t,r.op);return e=bi(e),lf(e)?e:(L(e instanceof et,64498),L(tr(e),40251),L(e.filters.length>1,57927),e.filters.reduce((n,s)=>Ha(n,s)))}function Ha(r,t){let e;return L(r instanceof W||r instanceof et,38388),L(t instanceof W||t instanceof et,25473),e=r instanceof W?t instanceof W?function(s,i){return et.create([s,i],"and")}(r,t):Ol(r,t):t instanceof W?Ol(t,r):function(s,i){if(L(s.filters.length>0&&i.filters.length>0,48005),tr(s)&&tr(i))return wd(s,i.getFilters());const o=ua(s)?s:i,u=ua(s)?i:s,c=o.filters.map(h=>Ha(h,u));return et.create(c,"or")}(r,t),bi(e)}function Ol(r,t){if(tr(t))return wd(t,r.getFilters());{const e=t.filters.map(n=>Ha(r,n));return et.create(e,"or")}}function bi(r){if(L(r instanceof W||r instanceof et,11850),r instanceof W)return r;const t=r.getFilters();if(t.length===1)return bi(t[0]);if(Ed(r))return r;const e=t.map(s=>bi(s)),n=[];return e.forEach(s=>{s instanceof W?n.push(s):s instanceof et&&(s.op===r.op?n.push(...s.filters):n.push(s))}),n.length===1?n[0]:et.create(n,r.op)}/**
1421 * @license
1422 * Copyright 2019 Google LLC
1423 *
1424 * Licensed under the Apache License, Version 2.0 (the "License");
1425 * you may not use this file except in compliance with the License.
1426 * You may obtain a copy of the License at
1427 *
1428 *   http://www.apache.org/licenses/LICENSE-2.0
1429 *
1430 * Unless required by applicable law or agreed to in writing, software
1431 * distributed under the License is distributed on an "AS IS" BASIS,
1432 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1433 * See the License for the specific language governing permissions and
1434 * limitations under the License.
1435 */class Sy{constructor(){this.Cn=new Ja}addToCollectionParentIndex(t,e){return this.Cn.add(e),A.resolve()}getCollectionParents(t,e){return A.resolve(this.Cn.getEntries(e))}addFieldIndex(t,e){return A.resolve()}deleteFieldIndex(t,e){return A.resolve()}deleteAllFieldIndexes(t){return A.resolve()}createTargetIndexes(t,e){return A.resolve()}getDocumentsMatchingTarget(t,e){return A.resolve(null)}getIndexType(t,e){return A.resolve(0)}getFieldIndexes(t,e){return A.resolve([])}getNextCollectionGroupToUpdate(t){return A.resolve(null)}getMinOffset(t,e){return A.resolve(Kt.min())}getMinOffsetFromCollectionGroup(t,e){return A.resolve(Kt.min())}updateCollectionGroup(t,e,n){return A.resolve()}updateIndexEntries(t,e){return A.resolve()}}class Ja{constructor(){this.index={}}add(t){const e=t.lastSegment(),n=t.popLast(),s=this.index[e]||new rt(K.comparator),i=!s.has(n);return this.index[e]=s.add(n),i}has(t){const e=t.lastSegment(),n=t.popLast(),s=this.index[e];return s&&s.has(n)}getEntries(t){return(this.index[t]||new rt(K.comparator)).toArray()}}/**
1436 * @license
1437 * Copyright 2019 Google LLC
1438 *
1439 * Licensed under the Apache License, Version 2.0 (the "License");
1440 * you may not use this file except in compliance with the License.
1441 * You may obtain a copy of the License at
1442 *
1443 *   http://www.apache.org/licenses/LICENSE-2.0
1444 *
1445 * Unless required by applicable law or agreed to in writing, software
1446 * distributed under the License is distributed on an "AS IS" BASIS,
1447 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1448 * See the License for the specific language governing permissions and
1449 * limitations under the License.
1450 */const Fl="IndexedDbIndexManager",Zs=new Uint8Array(0);class Py{constructor(t,e){this.databaseId=e,this.vn=new Ja,this.Fn=new de(n=>gn(n),(n,s)=>As(n,s)),this.uid=t.uid||""}addToCollectionParentIndex(t,e){if(!this.vn.has(e)){const n=e.lastSegment(),s=e.popLast();t.addOnCommittedListener(()=>{this.vn.add(e)});const i={collectionId:n,parent:xt(s)};return Ll(t).put(i)}return A.resolve()}getCollectionParents(t,e){const n=[],s=IDBKeyRange.bound([e,""],[jh(e),""],!1,!0);return Ll(t).J(s).next(i=>{for(const o of i){if(o.collectionId!==e)break;n.push(ee(o.parent))}return n})}addFieldIndex(t,e){const n=jr(t),s=function(u){return{indexId:u.indexId,collectionGroup:u.collectionGroup,fields:u.fields.map(c=>[c.fieldPath.canonicalString(),c.kind])}}(e);delete s.indexId;const i=n.add(s);if(e.indexState){const o=Mn(t);return i.next(u=>{o.put(Vl(u,this.uid,e.indexState.sequenceNumber,e.indexState.offset))})}return i.next()}deleteFieldIndex(t,e){const n=jr(t),s=Mn(t),i=kn(t);return n.delete(e.indexId).next(()=>s.delete(IDBKeyRange.bound([e.indexId],[e.indexId+1],!1,!0))).next(()=>i.delete(IDBKeyRange.bound([e.indexId],[e.indexId+1],!1,!0)))}deleteAllFieldIndexes(t){const e=jr(t),n=kn(t),s=Mn(t);return e.Z().next(()=>n.Z()).next(()=>s.Z())}createTargetIndexes(t,e){return A.forEach(this.Mn(e),n=>this.getIndexType(t,n).next(s=>{if(s===0||s===1){const i=new Ml(n).Dn();if(i!=null)return this.addFieldIndex(t,i)}}))}getDocumentsMatchingTarget(t,e){const n=kn(t);let s=!0;const i=new Map;return A.forEach(this.Mn(e),o=>this.xn(t,o).next(u=>{s&&(s=!!u),i.set(o,u)})).next(()=>{if(s){let o=G();const u=[];return A.forEach(i,(c,h)=>{N(Fl,`Using index ${function(U){return`id=${U.indexId}|cg=${U.collectionGroup}|f=${U.fields.map(Y=>`${Y.fieldPath}:${Y.kind}`).join(",")}`}(c)} to execute ${gn(e)}`);const f=function(U,Y){const Z=ea(Y);if(Z===void 0)return null;for(const H of wi(U,Z.fieldPath))switch(H.op){case"array-contains-any":return H.value.arrayValue.values||[];case"array-contains":return[H.value]}return null}(h,c),m=function(U,Y){const Z=new Map;for(const H of rn(Y))for(const E of wi(U,H.fieldPath))switch(E.op){case"==":case"in":Z.set(H.fieldPath.canonicalString(),E.value);break;case"not-in":case"!=":return Z.set(H.fieldPath.canonicalString(),E.value),Array.from(Z.values())}return null}(h,c),p=function(U,Y){const Z=[];let H=!0;for(const E of rn(Y)){const _=E.kind===0?gl(U,E.fieldPath,U.startAt):pl(U,E.fieldPath,U.startAt);Z.push(_.value),H&&(H=_.inclusive)}return new Fe(Z,H)}(h,c),v=function(U,Y){const Z=[];let H=!0;for(const E of rn(Y)){const _=E.kind===0?pl(U,E.fieldPath,U.endAt):gl(U,E.fieldPath,U.endAt);Z.push(_.value),H&&(H=_.inclusive)}return new Fe(Z,H)}(h,c),C=this.On(c,h,p),D=this.On(c,h,v),x=this.Nn(c,h,m),B=this.Bn(c.indexId,f,C,p.inclusive,D,v.inclusive,x);return A.forEach(B,j=>n.Y(j,e.limit).next(U=>{U.forEach(Y=>{const Z=k.fromSegments(Y.documentKey);o.has(Z)||(o=o.add(Z),u.push(Z))})}))}).next(()=>u)}return A.resolve(null)})}Mn(t){let e=this.Fn.get(t);return e||(t.filters.length===0?e=[t]:e=Ry(et.create(t.filters,"and")).map(n=>la(t.path,t.collectionGroup,t.orderBy,n.getFilters(),t.limit,t.startAt,t.endAt)),this.Fn.set(t,e),e)}Bn(t,e,n,s,i,o,u){const c=(e!=null?e.length:1)*Math.max(n.length,i.length),h=c/(e!=null?e.length:1),f=[];for(let m=0;m<c;++m){const p=e?this.Ln(e[m/h]):Zs,v=this.kn(t,p,n[m%h],s),C=this.qn(t,p,i[m%h],o),D=u.map(x=>this.kn(t,p,x,!0));f.push(...this.createRange(v,C,D))}return f}kn(t,e,n,s){const i=new cn(t,k.empty(),e,n);return s?i:i.An()}qn(t,e,n,s){const i=new cn(t,k.empty(),e,n);return s?i.An():i}xn(t,e){const n=new Ml(e),s=e.collectionGroup!=null?e.collectionGroup:e.path.lastSegment();return this.getFieldIndexes(t,s).next(i=>{let o=null;for(const u of i)n.yn(u)&&(!o||u.fields.length>o.fields.length)&&(o=u);return o}
1450)}getIndexType(t,e){let n=2;const s=this.Mn(e);return A.forEach(s,i=>this.xn(t,i).next(o=>{o?n!==0&&o.fields.length<function(c){let h=new rt(ct.comparator),f=!1;for(const m of c.filters)for(const p of m.getFlattenedFilters())p.field.isKeyField()||(p.op==="array-contains"||p.op==="array-contains-any"?f=!0:h=h.add(p.field));for(const m of c.orderBy)m.field.isKeyField()||(h=h.add(m.field));return h.size+(f?1:0)}(i)&&(n=1):n=0})).next(()=>function(o){return o.limit!==null}(e)&&s.length>1&&n===2?1:n)}Qn(t,e){const n=new qr;for(const s of rn(t)){const i=e.data.field(s.fieldPath);if(i==null)return null;const o=n.Pn(s.kind);un.Kt.Dt(i,o)}return n.un()}Ln(t){const e=new qr;return un.Kt.Dt(t,e.Pn(0)),e.un()}$n(t,e){const n=new qr;return un.Kt.Dt(mn(this.databaseId,e),n.Pn(function(i){const o=rn(i);return o.length===0?0:o[o.length-1].kind}(t))),n.un()}Nn(t,e,n){if(n===null)return[];let s=[];s.push(new qr);let i=0;for(const o of rn(t)){const u=n[i++];for(const c of s)if(this.Un(e,o.fieldPath)&&gs(u))s=this.Kn(s,o,u);else{const h=c.Pn(o.kind);un.Kt.Dt(u,h)}}return this.Wn(s)}On(t,e,n){return this.Nn(t,e,n.position)}Wn(t){const e=[];for(let n=0;n<t.length;++n)e[n]=t[n].un();return e}Kn(t,e,n){const s=[...t],i=[];for(const o of n.arrayValue.values||[])for(const u of s){const c=new qr;c.seed(u.un()),un.Kt.Dt(o,c.Pn(e.kind)),i.push(c)}return i}Un(t,e){return!!t.filters.find(n=>n instanceof W&&n.field.isEqual(e)&&(n.op==="in"||n.op==="not-in"))}getFieldIndexes(t,e){const n=jr(t),s=Mn(t);return(e?n.J(ra,IDBKeyRange.bound(e,e)):n.J()).next(i=>{const o=[];return A.forEach(i,u=>s.get([u.indexId,this.uid]).next(c=>{o.push(function(f,m){const p=m?new Qn(m.sequenceNumber,new Kt(In(m.readTime),new k(ee(m.documentKey)),m.largestBatchId)):Qn.empty(),v=f.fields.map(([C,D])=>new hn(ct.fromServerFormat(C),D));return new Kn(f.indexId,f.collectionGroup,v,p)}(u,c))})).next(()=>o)})}getNextCollectionGroupToUpdate(t){return this.getFieldIndexes(t).next(e=>e.length===0?null:(e.sort((n,s)=>{const i=n.indexState.sequenceNumber-s.indexState.sequenceNumber;return i!==0?i:z(n.collectionGroup,s.collectionGroup)}),e[0].collectionGroup))}updateCollectionGroup(t,e,n){const s=jr(t),i=Mn(t);return this.Gn(t).next(o=>s.J(ra,IDBKeyRange.bound(e,e)).next(u=>A.forEach(u,c=>i.put(Vl(c.indexId,this.uid,o,n)))))}updateIndexEntries(t,e){const n=new Map;return A.forEach(e,(s,i)=>{const o=n.get(s.collectionGroup);return(o?A.resolve(o):this.getFieldIndexes(t,s.collectionGroup)).next(u=>(n.set(s.collectionGroup,u),A.forEach(u,c=>this.zn(t,s,c).next(h=>{const f=this.jn(i,c);return h.isEqual(f)?A.resolve():this.Jn(t,i,c,h,f)}))))})}Hn(t,e,n,s){return kn(t).put(s.Rn(this.uid,this.$n(n,e.key),e.key))}Yn(t,e,n,s){return kn(t).delete(s.Vn(this.uid,this.$n(n,e.key),e.key))}zn(t,e,n){const s=kn(t);let i=new rt(Te);return s.ee({index:nd,range:IDBKeyRange.only([n.indexId,this.uid,di(this.$n(n,e))])},(o,u)=>{i=i.add(new cn(n.indexId,e,kl(u.arrayValue),kl(u.directionalValue)))}).next(()=>i)}jn(t,e){let n=new rt(Te);const s=this.Qn(e,t);if(s==null)return n;const i=ea(e);if(i!=null){const o=t.data.field(i.fieldPath);if(gs(o))for(const u of o.arrayValue.values||[])n=n.add(new cn(e.indexId,t.key,this.Ln(u),s))}else n=n.add(new cn(e.indexId,t.key,Zs,s));return n}Jn(t,e,n,s,i){N(Fl,"Updating index entries for document '%s'",e.key);const o=[];return function(c,h,f,m,p){const v=c.getIterator(),C=h.getIterator();let D=xn(v),x=xn(C);for(;D||x;){let B=!1,j=!1;if(D&&x){const U=f(D,x);U<0?j=!0:U>0&&(B=!0)}else D!=null?j=!0:B=!0;B?(m(x),x=xn(C)):j?(p(D),D=xn(v)):(D=xn(v),x=xn(C))}}(s,i,Te,u=>{o.push(this.Hn(t,e,n,u))},u=>{o.push(this.Yn(t,e,n,u))}),A.waitFor(o)}Gn(t){let e=1;return Mn(t).ee({index:ed,reverse:!0,range:IDBKeyRange.upperBound([this.uid,Number.MAX_SAFE_INTEGER])},(n,s,i)=>{i.done(),e=s.sequenceNumber+1}).next(()=>e)}createRange(t,e,n){n=n.sort((o,u)=>Te(o,u)).filter((o,u,c)=>!u||Te(o,c[u-1])!==0);const s=[];
1450s.push(t);for(const o of n){const u=Te(o,t),c=Te(o,e);if(u===0)s[0]=t.An();else if(u>0&&c<0)s.push(o),s.push(o.An());else if(c>0)break}s.push(e);const i=[];for(let o=0;o<s.length;o+=2){if(this.Zn(s[o],s[o+1]))return[];const u=s[o].Vn(this.uid,Zs,k.empty()),c=s[o+1].Vn(this.uid,Zs,k.empty());i.push(IDBKeyRange.bound(u,c))}return i}Zn(t,e){return Te(t,e)>0}getMinOffsetFromCollectionGroup(t,e){return this.getFieldIndexes(t,e).next(Bl)}getMinOffset(t,e){return A.mapArray(this.Mn(e),n=>this.xn(t,n).next(s=>s||F(44426))).next(Bl)}}function Ll(r){return wt(r,hs)}function kn(r){return wt(r,ts)}function jr(r){return wt(r,ka)}function Mn(r){return wt(r,Zr)}function Bl(r){L(r.length!==0,28825);let t=r[0].indexState.offset,e=t.largestBatchId;for(let n=1;n<r.length;n++){const s=r[n].indexState.offset;Da(s,t)<0&&(t=s),e<s.largestBatchId&&(e=s.largestBatchId)}return new Kt(t.readTime,t.documentKey,e)}/**
1451 * @license
1452 * Copyright 2018 Google LLC
1453 *
1454 * Licensed under the Apache License, Version 2.0 (the "License");
1455 * you may not use this file except in compliance with the License.
1456 * You may obtain a copy of the License at
1457 *
1458 *   http://www.apache.org/licenses/LICENSE-2.0
1459 *
1460 * Unless required by applicable law or agreed to in writing, software
1461 * distributed under the License is distributed on an "AS IS" BASIS,
1462 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1463 * See the License for the specific language governing permissions and
1464 * limitations under the License.
1465 */const Ul={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0},hf=41943040;class Dt{static withCacheSize(t){return new Dt(t,Dt.DEFAULT_COLLECTION_PERCENTILE,Dt.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}constructor(t,e,n){this.cacheSizeCollectionThreshold=t,this.percentileToCollect=e,this.maximumSequenceNumbersToCollect=n}}/**
1466 * @license
1467 * Copyright 2020 Google LLC
1468 *
1469 * Licensed under the Apache License, Version 2.0 (the "License");
1470 * you may not use this file except in compliance with the License.
1471 * You may obtain a copy of the License at
1472 *
1473 *   http://www.apache.org/licenses/LICENSE-2.0
1474 *
1475 * Unless required by applicable law or agreed to in writing, software
1476 * distributed under the License is distributed on an "AS IS" BASIS,
1477 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1478 * See the License for the specific language governing permissions and
1479 * limitations under the License.
1480 */function df(r,t,e){const n=r.store(Wt),s=r.store(Wn),i=[],o=IDBKeyRange.only(e.batchId);let u=0;const c=n.ee({range:o},(f,m,p)=>(u++,p.delete()));i.push(c.next(()=>{L(u===1,47070,{batchId:e.batchId})}));const h=[];for(const f of e.mutations){const m=Yh(t,f.key.path,e.batchId);i.push(s.delete(m)),h.push(f.key)}return A.waitFor(i).next(()=>h)}function Ri(r){if(!r)return 0;let t;if(r.document)t=r.document;else if(r.unknownDocument)t=r.unknownDocument;else{if(!r.noDocument)throw F(14731);t=r.noDocument}return JSON.stringify(t).length}/**
1481 * @license
1482 * Copyright 2017 Google LLC
1483 *
1484 * Licensed under the Apache License, Version 2.0 (the "License");
1485 * you may not use this file except in compliance with the License.
1486 * You may obtain a copy of the License at
1487 *
1488 *   http://www.apache.org/licenses/LICENSE-2.0
1489 *
1490 * Unless required by applicable law or agreed to in writing, software
1491 * distributed under the License is distributed on an "AS IS" BASIS,
1492 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1493 * See the License for the specific language governing permissions and
1494 * limitations under the License.
1495 */Dt.DEFAULT_COLLECTION_PERCENTILE=10,Dt.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,Dt.DEFAULT=new Dt(hf,Dt.DEFAULT_COLLECTION_PERCENTILE,Dt.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),Dt.DISABLED=new Dt(-1,0,0);class Ji{constructor(t,e,n,s){this.userId=t,this.serializer=e,this.indexManager=n,this.referenceDelegate=s,this.Xn={}}static wt(t,e,n,s){L(t.uid!=="",64387);const i=t.isAuthenticated()?t.uid:"";return new Ji(i,e,n,s)}checkEmpty(t){let e=!0;const n=IDBKeyRange.bound([this.userId,Number.NEGATIVE_INFINITY],[this.userId,Number.POSITIVE_INFINITY]);return we(t).ee({index:ln,range:n},(s,i,o)=>{e=!1,o.done()}).next(()=>e)}addMutationBatch(t,e,n,s){const i=Un(t),o=we(t);return o.add({}).next(u=>{L(typeof u=="number",49019);const c=new Ga(u,e,n,s),h=function(v,C,D){const x=D.baseMutations.map(j=>ys(v.yt,j)),B=D.mutations.map(j=>ys(v.yt,j));return{userId:C,batchId:D.batchId,localWriteTimeMs:D.localWriteTime.toMillis(),baseMutations:x,mutations:B}}(this.serializer,this.userId,c),f=[];let m=new rt((p,v)=>z(p.canonicalString(),v.canonicalString()));for(const p of s){const v=Yh(this.userId,p.key.path,u);
1495m=m.add(p.key.path.popLast()),f.push(o.put(h)),f.push(i.put(v,c_))}return m.forEach(p=>{f.push(this.indexManager.addToCollectionParentIndex(t,p))}),t.addOnCommittedListener(()=>{this.Xn[u]=c.keys()}),A.waitFor(f).next(()=>c)})}lookupMutationBatch(t,e){return we(t).get(e).next(n=>n?(L(n.userId===this.userId,48,"Unexpected user for mutation batch",{userId:n.userId,batchId:e}),an(this.serializer,n)):null)}er(t,e){return this.Xn[e]?A.resolve(this.Xn[e]):this.lookupMutationBatch(t,e).next(n=>{if(n){const s=n.keys();return this.Xn[e]=s,s}return null})}getNextMutationBatchAfterBatchId(t,e){const n=e+1,s=IDBKeyRange.lowerBound([this.userId,n]);let i=null;return we(t).ee({index:ln,range:s},(o,u,c)=>{u.userId===this.userId&&(L(u.batchId>=n,47524,{tr:n}),i=an(this.serializer,u)),c.done()}).next(()=>i)}getHighestUnacknowledgedBatchId(t){const e=IDBKeyRange.upperBound([this.userId,Number.POSITIVE_INFINITY]);let n=De;return we(t).ee({index:ln,range:e,reverse:!0},(s,i,o)=>{n=i.batchId,o.done()}).next(()=>n)}getAllMutationBatches(t){const e=IDBKeyRange.bound([this.userId,De],[this.userId,Number.POSITIVE_INFINITY]);return we(t).J(ln,e).next(n=>n.map(s=>an(this.serializer,s)))}getAllMutationBatchesAffectingDocumentKey(t,e){const n=ii(this.userId,e.path),s=IDBKeyRange.lowerBound(n),i=[];return Un(t).ee({range:s},(o,u,c)=>{const[h,f,m]=o,p=ee(f);if(h===this.userId&&e.path.isEqual(p))return we(t).get(m).next(v=>{if(!v)throw F(61480,{nr:o,batchId:m});L(v.userId===this.userId,10503,"Unexpected user for mutation batch",{userId:v.userId,batchId:m}),i.push(an(this.serializer,v))});c.done()}).next(()=>i)}getAllMutationBatchesAffectingDocumentKeys(t,e){let n=new rt(z);const s=[];return e.forEach(i=>{const o=ii(this.userId,i.path),u=IDBKeyRange.lowerBound(o),c=Un(t).ee({range:u},(h,f,m)=>{const[p,v,C]=h,D=ee(v);p===this.userId&&i.path.isEqual(D)?n=n.add(C):m.done()});s.push(c)}),A.waitFor(s).next(()=>this.rr(t,n))}getAllMutationBatchesAffectingQuery(t,e){const n=e.path,s=n.length+1,i=ii(this.userId,n),o=IDBKeyRange.lowerBound(i);let u=new rt(z);return Un(t).ee({range:o},(c,h,f)=>{const[m,p,v]=c,C=ee(p);m===this.userId&&n.isPrefixOf(C)?C.length===s&&(u=u.add(v)):f.done()}).next(()=>this.rr(t,u))}rr(t,e){const n=[],s=[];return e.forEach(i=>{s.push(we(t).get(i).next(o=>{if(o===null)throw F(35274,{batchId:i});L(o.userId===this.userId,9748,"Unexpected user for mutation batch",{userId:o.userId,batchId:i}),n.push(an(this.serializer,o))}))}),A.waitFor(s).next(()=>n)}removeMutationBatch(t,e){return df(t.le,this.userId,e).next(n=>(t.addOnCommittedListener(()=>{this.ir(e.batchId)}),A.forEach(n,s=>this.referenceDelegate.markPotentiallyOrphaned(t,s))))}ir(t){delete this.Xn[t]}performConsistencyCheck(t){return this.checkEmpty(t).next(e=>{if(!e)return A.resolve();const n=IDBKeyRange.lowerBound(function(o){return[o]}(this.userId)),s=[];return Un(t).ee({range:n},(i,o,u)=>{if(i[0]===this.userId){const c=ee(i[1]);s.push(c)}else u.done()}).next(()=>{L(s.length===0,56720,{sr:s.map(i=>i.canonicalString())})})})}containsKey(t,e){return ff(t,this.userId,e)}_r(t){return mf(t).get(this.userId).next(e=>e||{userId:this.userId,lastAcknowledgedBatchId:De,lastStreamToken:""})}}function ff(r,t,e){const n=ii(t,e.path),s=n[1],i=IDBKeyRange.lowerBound(n);let o=!1;return Un(r).ee({range:i,X:!0},(u,c,h)=>{const[f,m,p]=u;f===t&&m===s&&(o=!0),h.done()}).next(()=>o)}function we(r){return wt(r,Wt)}function Un(r){return wt(r,Wn)}function mf(r){return wt(r,cs)}/**
1496 * @license
1497 * Copyright 2017 Google LLC
1498 *
1499 * Licensed under the Apache License, Version 2.0 (the "License");
1500 * you may not use this file except in compliance with the License.
1501 * You may obtain a copy of the License at
1502 *
1503 *   http://www.apache.org/licenses/LICENSE-2.0
1504 *
1505 * Unless required by applicable law or agreed to in writing, software
1506 * distributed under the License is distributed on an "AS IS" BASIS,
1507 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1508 * See the License for the specific language governing permissions and
1509 * limitations under the License.
1510 */class En{constructor(t){this.ar=t}next(){return this.ar+=2,this.ar}static ur(){return new En(0)}static cr(){return new En(-1)}}/**
1511 * @license
1512 * Copyright 2017 Google LLC
1513 *
1514 * Licensed under the Apache License, Version 2.0 (the "License");
1515 * you may not use this file except in compliance with the License.
1516 * You may obtain a copy of the License at
1517 *
1518 *   http://www.apache.org/licenses/LICENSE-2.0
1519 *
1520 * Unless required by applicable law or agreed to in writing, software
1521 * distributed under the License is distributed on an "AS IS" BASIS,
1522 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1523 * See the License for the specific language governing permissions and
1524 * limitations under the License.
1525 */class Vy{constructor(t,e){this.referenceDelegate=t,this.serializer=e}allocateTargetId(t){return this.lr(t).next(e=>{const n=new En(e.highestTargetId);return e.highestTargetId=n.next(),this.hr(t,e).next(()=>e.highestTargetId)})}getLastRemoteSnapshotVersion(t){return this.lr(t).next(e=>q.fromTimestamp(new tt(e.lastRemoteSnapshotVersion.seconds,e.lastRemoteSnapshotVersion.nanoseconds)))}getHighestSequenceNumber(t){return this.lr(t).next(e=>e.highestListenSequenceNumber)}setTargetsMetadata(t,e,n){return this.lr(t).next(s=>(s.highestListenSequenceNumber=e,n&&(s.lastRemoteSnapshotVersion=n.toTimestamp()),e>s.highestListenSequenceNumber&&(s.highestListenSequenceNumber=e),this.hr(t,s)))}addTargetData(t,e){return this.Pr(t,e).next(()=>this.lr(t).next(n=>(n.targetCount+=1,this.Tr(e,n),this.hr(t,n))))}updateTargetData(t,e){return this.Pr(t,e)}removeTargetData(t,e){return this.removeMatchingKeysForTargetId(t,e.targetId).next(()=>On(t).delete(e.targetId)).next(()=>this.lr(t)).next(n=>(L(n.targetCount>0,8065),n.targetCount-=1,this.hr(t,n)))}removeTargets(t,e,n){let s=0;const i=[];return On(t).ee((o,u)=>{const c=Wr(u);c.sequenceNumber<=e&&n.get(c.targetId)===null&&(s++,i.push(this.removeTargetData(t,c)))}).next(()=>A.waitFor(i)).next(()=>s)}forEachTarget(t,e){return On(t).ee((n,s)=>{const i=Wr(s);e(i)})}lr(t){return ql(t).get(Ei).next(e=>(L(e!==null,2888),e))}hr(t,e){return ql(t).put(Ei,e)}Pr(t,e){return On(t).put(uf(this.serializer,e))}Tr(t,e){let n=!1;return t.targetId>e.highestTargetId&&(e.highestTargetId=t.targetId,n=!0),t.sequenceNumber>e.highestListenSequenceNumber&&(e.highestListenSequenceNumber=t.sequenceNumber,n=!0),n}getTargetCount(t){return this.lr(t).next(e=>e.targetCount)}getTargetData(t,e){const n=gn(e),s=IDBKeyRange.bound([n,Number.NEGATIVE_INFINITY],[n,Number.POSITIVE_INFINITY]);let i=null;return On(t).ee({range:s,index:td},(o,u,c)=>{const h=Wr(u);As(e,h.target)&&(i=h,c.done())}).next(()=>i)}addMatchingKeys(t,e,n){const s=[],i=be(t);return e.forEach(o=>{const u=xt(o.path);s.push(i.put({targetId:n,path:u})),s.push(this.referenceDelegate.addReference(t,n,o))}),A.waitFor(s)}removeMatchingKeys(t,e,n){const s=be(t);return A.forEach(e,i=>{const o=xt(i.path);return A.waitFor([s.delete([n,o]),this.referenceDelegate.removeReference(t,n,i)])})}removeMatchingKeysForTargetId(t,e){const n=be(t),s=IDBKeyRange.bound([e],[e+1],!1,!0);return n.delete(s)}getMatchingKeysForTargetId(t,e){const n=IDBKeyRange.bound([e],[e+1],!1,!0),s=be(t);let i=G();return s.ee({range:n,X:!0},(o,u,c)=>{const h=ee(o[1]),f=new k(h);i=i.add(f)}).next(()=>i)}containsKey(t,e){const n=xt(e.path),s=IDBKeyRange.bound([n],[jh(n)],!1,!0);let i=0;return be(t).ee({index:Na,X:!0,range:s},([o,u],c,h)=>{o!==0&&(i++,h.done())}).next(()=>i>0)}At(t,e){return On(t).get(e).next(n=>n?Wr(n):null)}}function On(r){return wt(r,Hn)}function ql(r){return wt(r,dn)}function be(r){return wt(r,Jn)}/**
1526 * @license
1527 * Copyright 2020 Google LLC
1528 *
1529 * Licensed under the Apache License, Version 2.0 (the "License");
1530 * you may not use this file except in compliance with the License.
1531 * You may obtain a copy of the License at
1532 *
1533 *   http://www.apache.org/licenses/LICENSE-2.0
1534 *
1535 * Unless required by applicable law or agreed to in writing, software
1536 * distributed under the License is distributed on an "AS IS" BASIS,
1537 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1538 * See the License for the specific language governing permissions and
1539 * limitations under the License.
1540 */const jl="LruGarbageCollector",gf=1048576;function zl([r,t],[e,n]){const s=z(r,e);return s===0?z(t,n):s}class Cy{constructor(t){this.Ir=t,this.buffer=new rt(zl),this.Er=0}dr(){return++this.Er}Ar(t){const e=[t,this.dr()];if(this.buffer.size<this.Ir)this.buffer=this.buffer.add(e);else{const n=this.buffer.last();zl(e,n)<0&&(this.buffer=this.buffer.delete(n).add(e))}}get maxValue(){return this.buffer.last()[0]}}class pf{constructor(t,e,n){this.garbageCollector=t,this.asyncQueue=e,this.localStore=n,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(t){N(jl,`Garbage collection scheduled in ${t}ms`),this.Rr=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",t,async()=>{this.Rr=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(e){je(e)?N(jl,"Ignoring IndexedDB error during garbage collection: ",e):await qe(e)}await this.Vr(3e5)})}}class Dy{constructor(t,e){this.mr=t,this.params=e}calculateTargetCount(t,e){return this.mr.gr(t).next(n=>Math.floor(e/100*n))}nthSequenceNumber(t,e){if(e===0)return A.resolve(Lt.ce);const n=new Cy(e);return this.mr.forEachTarget(t,s=>n.Ar(s.sequenceNumber)).next(()=>this.mr.pr(t,s=>n.Ar(s))).next(()=>n.maxValue)}removeTargets(t,e,n){return this.mr.removeTargets(t,e,n)}removeOrphanedDocuments(t,e){return this.mr.removeOrphanedDocuments(t,e)}collect(t,e){return this.params.cacheSizeCollectionThreshold===-1?(N("LruGarbageCollector","Garbage collection skipped; disabled"),A.resolve(Ul)):this.getCacheSize(t).next(n=>n<this.params.cacheSizeCollectionThreshold?(N("LruGarbageCollector",`Garbage collection skipped; Cache size ${n} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),Ul):this.yr(t,e))}getCacheSize(t){return this.mr.getCacheSize(t)}
1540yr(t,e){let n,s,i,o,u,c,h;const f=Date.now();return this.calculateTargetCount(t,this.params.percentileToCollect).next(m=>(m>this.params.maximumSequenceNumbersToCollect?(N("LruGarbageCollector",`Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${m}`),s=this.params.maximumSequenceNumbersToCollect):s=m,o=Date.now(),this.nthSequenceNumber(t,s))).next(m=>(n=m,u=Date.now(),this.removeTargets(t,n,e))).next(m=>(i=m,c=Date.now(),this.removeOrphanedDocuments(t,n))).next(m=>(h=Date.now(),Fn()<=X.DEBUG&&N("LruGarbageCollector",`LRU Garbage Collection
1541	Counted targets in ${o-f}ms
1542	Determined least recently used ${s} in `+(u-o)+`ms
1543	Removed ${i} targets in `+(c-u)+`ms
1544	Removed ${m} documents in `+(h-c)+`ms
1545Total Duration: ${h-f}ms`),A.resolve({didRun:!0,sequenceNumbersCollected:s,targetsRemoved:i,documentsRemoved:m})))}}function _f(r,t){return new Dy(r,t)}/**
1546 * @license
1547 * Copyright 2020 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 xy{constructor(t,e){this.db=t,this.garbageCollector=_f(this,e)}gr(t){const e=this.wr(t);return this.db.getTargetCache().getTargetCount(t).next(n=>e.next(s=>n+s))}wr(t){let e=0;return this.pr(t,n=>{e++}).next(()=>e)}forEachTarget(t,e){return this.db.getTargetCache().forEachTarget(t,e)}pr(t,e){return this.Sr(t,(n,s)=>e(s))}addReference(t,e,n){return ti(t,n)}removeReference(t,e,n){return ti(t,n)}removeTargets(t,e,n){return this.db.getTargetCache().removeTargets(t,e,n)}markPotentiallyOrphaned(t,e){return ti(t,e)}br(t,e){return function(s,i){let o=!1;return mf(s).te(u=>ff(s,u,i).next(c=>(c&&(o=!0),A.resolve(!c)))).next(()=>o)}(t,e)}removeOrphanedDocuments(t,e){const n=this.db.getRemoteDocumentCache().newChangeBuffer(),s=[];let i=0;return this.Sr(t,(o,u)=>{if(u<=e){const c=this.br(t,o).next(h=>{if(!h)return i++,n.getEntry(t,o).next(()=>(n.removeEntry(o,q.min()),be(t).delete(function(m){return[0,xt(m.path)]}(o))))});s.push(c)}}).next(()=>A.waitFor(s)).next(()=>n.apply(t)).next(()=>i)}removeTarget(t,e){const n=e.withSequenceNumber(t.currentSequenceNumber);return this.db.getTargetCache().updateTargetData(t,n)}updateLimboDocument(t,e){return ti(t,e)}Sr(t,e){const n=be(t);let s,i=Lt.ce;return n.ee({index:Na},([o,u],{path:c,sequenceNumber:h})=>{o===0?(i!==Lt.ce&&e(new k(ee(s)),i),i=h,s=c):i=Lt.ce}).next(()=>{i!==Lt.ce&&e(new k(ee(s)),i)})}getCacheSize(t){return this.db.getRemoteDocumentCache().getSize(t)}}function ti(r,t){return be(r).put(function(n,s){return{targetId:0,path:xt(n.path),sequenceNumber:s}}(t,r.currentSequenceNumber))}/**
1561 * @license
1562 * Copyright 2017 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 */class yf{constructor(){this.changes=new de(t=>t.toString(),(t,e)=>t.isEqual(e)),this.changesApplied=!1}addEntry(t){this.assertNotApplied(),this.changes.set(t.key,t)}removeEntry(t,e){this.assertNotApplied(),this.changes.set(t,ut.newInvalidDocument(t).setReadTime(e))}getEntry(t,e){this.assertNotApplied();const n=this.changes.get(e);return n!==void 0?A.resolve(n):this.getFromCache(t,e)}getEntries(t,e){return this.getAllFromCache(t,e)}apply(t){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(t)}
vendor: 3,479 bytes, lines 1575-1590
1575assertNotApplied(){}}/**
1576 * @license
1577 * Copyright 2017 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 */class Ny{constructor(t){this.serializer=t}setIndexManager(t){this.indexManager=t}addEntry(t,e,n){return en(t).put(n)}removeEntry(t,e,n){return en(t).delete(function(i,o){const u=i.path.toArray();return[u.slice(0,u.length-2),u[u.length-2],vi(o),u[u.length-1]]}(e,n))}updateMetadata(t,e){return this.getMetadata(t).next(n=>(n.byteSize+=e,this.Dr(t,n)))}getEntry(t,e){let n=ut.newInvalidDocument(e);return en(t).ee({index:oi,range:IDBKeyRange.only(zr(e))},(s,i)=>{n=this.Cr(e,i)}).next(()=>n)}vr(t,e){let n={size:0,document:ut.newInvalidDocument(e)};return en(t).ee({index:oi,range:IDBKeyRange.only(zr(e))},(s,i)=>{n={document:this.Cr(e,i),size:Ri(i)}}).next(()=>n)}getEntries(t,e){let n=Ut();return this.Fr(t,e,(s,i)=>{const o=this.Cr(s,i);n=n.insert(s,o)}).next(()=>n)}Mr(t,e){let n=Ut(),s=new ot(k.comparator);return this.Fr(t,e,(i,o)=>{const u=this.Cr(i,o);n=n.insert(i,u),s=s.insert(i,Ri(o))}).next(()=>({documents:n,Or:s}))}Fr(t,e,n){if(e.isEmpty())return A.resolve();let s=new rt(Kl);e.forEach(c=>s=s.add(c));const i=IDBKeyRange.bound(zr(s.first()),zr(s.last())),o=s.getIterator();let u=o.getNext();return en(t).ee({index:oi,range:i},(c,h,f)=>{const m=k.fromSegments([...h.prefixPath,h.collectionGroup,h.documentId]);for(;u&&Kl(u,m)<0;)n(u,null),u=o.getNext();u&&u.isEqual(m)&&(n(u,h),u=o.hasNext()?o.getNext():null),u?f.j(zr(u)):f.done()}).next(()=>{for(;u;)n(u,null),u=o.hasNext()?o.getNext():null})}getDocumentsMatchingQuery(t,e,n,s,i){const o=e.path,u=[o.popLast().toArray(),o.lastSegment(),vi(n.readTime),n.documentKey.path.isEmpty()?"":n.documentKey.path.lastSegment()],c=[o.popLast().toArray(),o.lastSegment(),[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],""];return en(t).J(IDBKeyRange.bound(u,c,!0)).next(h=>{i?.incrementDocumentReadCount(h.length);let f=Ut();for(const m of h){const p=this.Cr(k.fromSegments(m.prefixPath.concat(m.collectionGroup,m.documentId)),m);p.isFoundDocument()&&(bs(e,p)||s.has(p.key))&&(f=f.insert(p.key,p))}return f})}getAllFromCollectionGroup(t,e,n,s){let i=Ut();const o=$l(e,n),u=$l(e,Kt.max());return en(t).ee({index:Zh,range:IDBKeyRange.bound(o,u,!0)},(c,h,f)=>{const m=this.Cr(k.fromSegments(h.prefixPath.concat(h.collectionGroup,h.documentId)),h);i=i.insert(m.key,m),i.size===s&&f.done()}).next(()=>i)}newChangeBuffer(t){return new ky(this,!!t&&t.trackRemovals)}getSize(t){return this.getMetadata(t).next(e=>e.byteSize)}getMetadata(t){return Gl(t).get(na).next(e=>(L(!!e,20021),e))}Dr(t,e){return Gl(t).put(na,e)}Cr(t,e){if(e){const n=Iy(this.serializer,e);if(!(n.isNoDocument()&&n.version.isEqual(q.min())))return n}return ut.newInvalidDocument(t)}}function If(r){return new Ny(r)}class ky extends yf{constructor(t,e){super(),this.Nr=t,this.trackRemovals=e,this.Br=new de(n=>n.toString(),(n,s)=>n.isEqual(s))}applyChanges(t){const e=[];let n=0,s=new rt((i,o)=>z(i.canonicalString(),o.canonicalString()));
1590return this.changes.forEach((i,o)=>{const u=this.Br.get(i);if(e.push(this.Nr.removeEntry(t,i,u.readTime)),o.isValidDocument()){const c=Sl(this.Nr.serializer,o);s=s.add(i.path.popLast());const h=Ri(c);n+=h-u.size,e.push(this.Nr.addEntry(t,i,c))}else if(n-=u.size,this.trackRemovals){const c=Sl(this.Nr.serializer,o.convertToNoDocument(q.min()));e.push(this.Nr.addEntry(t,i,c))}}),s.forEach(i=>{e.push(this.Nr.indexManager.addToCollectionParentIndex(t,i))}),e.push(this.Nr.updateMetadata(t,n)),A.waitFor(e)}getFromCache(t,e){return this.Nr.vr(t,e).next(n=>(this.Br.set(e,{size:n.size,readTime:n.document.readTime}),n.document))}getAllFromCache(t,e){return this.Nr.Mr(t,e).next(({documents:n,Or:s})=>(s.forEach((i,o)=>{this.Br.set(i,{size:o,readTime:n.get(i).readTime})}),n))}}function Gl(r){return wt(r,ls)}function en(r){return wt(r,Ii)}function zr(r){const t=r.path.toArray();return[t.slice(0,t.length-2),t[t.length-2],t[t.length-1]]}function $l(r,t){const e=t.documentKey.path.toArray();return[r,vi(t.readTime),e.slice(0,e.length-2),e.length>0?e[e.length-1]:""]}function Kl(r,t){const e=r.path.toArray(),n=t.path.toArray();let s=0;for(let i=0;i<e.length-2&&i<n.length-2;++i)if(s=z(e[i],n[i]),s)return s;return s=z(e.length,n.length),s||(s=z(e[e.length-2],n[n.length-2]),s||z(e[e.length-1],n[n.length-1]))}/**
1591 * @license
1592 * Copyright 2017 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 *//**
1606 * @license
1607 * Copyright 2022 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 My{constructor(t,e){this.overlayedDocument=t,this.mutatedFields=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 */class Ef{constructor(t,e,n,s){this.remoteDocumentCache=t,this.mutationQueue=e,this.documentOverlayCache=n,this.indexManager=s}getDocument(t,e){let n=null;return this.documentOverlayCache.getOverlay(t,e).next(s=>(n=s,this.remoteDocumentCache.getEntry(t,e))).next(s=>(n!==null&&rs(n.mutation,s,Bt.empty(),tt.now()),s))}getDocuments(t,e){return this.remoteDocumentCache.getEntries(t,e).next(n=>this.getLocalViewOfDocuments(t,n,G()).next(()=>n))}getLocalViewOfDocuments(t,e,n=G()){const s=ne();return this.populateOverlays(t,s,e).next(()=>this.computeViews(t,e,s,n).next(i=>{let o=Kr();return i.forEach((u,c)=>{o=o.insert(u,c.overlayedDocument)}),o}))}getOverlayedDocuments(t,e){const n=ne();return this.populateOverlays(t,n,e).next(()=>this.computeViews(t,e,n,G()))}populateOverlays(t,e,n){const s=[];return n.forEach(i=>{e.has(i)||s.push(i)}),this.documentOverlayCache.getOverlays(t,s).next(i=>{i.forEach((o,u)=>{e.set(o,u)})})}computeViews(t,e,n,s){let i=Ut();const o=ns(),u=function(){return ns()}();return e.forEach((c,h)=>{const f=n.get(h.key);s.has(h.key)&&(f===void 0||f.mutation instanceof fe)?i=i.insert(h.key,h):f!==void 0?(o.set(h.key,f.mutation.getFieldMask()),rs(f.mutation,h,f.mutation.getFieldMask(),tt.now())):o.set(h.key,Bt.empty())}),this.recalculateAndSaveOverlays(t,i).next(c=>(c.forEach((h,f)=>o.set(h,f)),e.forEach((h,f)=>u.set(h,new My(f,o.get(h)??null))),u))}recalculateAndSaveOverlays(t,e){const n=ns();let s=new ot((o,u)=>o-u),i=G();
1635return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(t,e).next(o=>{for(const u of o)u.keys().forEach(c=>{const h=e.get(c);if(h===null)return;let f=n.get(c)||Bt.empty();f=u.applyToLocalView(h,f),n.set(c,f);const m=(s.get(u.batchId)||G()).add(c);s=s.insert(u.batchId,m)})}).next(()=>{const o=[],u=s.getReverseIterator();for(;u.hasNext();){const c=u.getNext(),h=c.key,f=c.value,m=kd();f.forEach(p=>{if(!i.has(p)){const v=qd(e.get(p),n.get(p));v!==null&&m.set(p,v),i=i.add(p)}}),o.push(this.documentOverlayCache.saveOverlays(t,h,m))}return A.waitFor(o)}).next(()=>n)}recalculateAndSaveOverlaysForDocumentKeys(t,e){return this.remoteDocumentCache.getEntries(t,e).next(n=>this.recalculateAndSaveOverlays(t,n))}getDocumentsMatchingQuery(t,e,n,s){return function(o){return k.isDocumentKey(o.path)&&o.collectionGroup===null&&o.filters.length===0}(e)?this.getDocumentsMatchingDocumentQuery(t,e.path):Ua(e)?this.getDocumentsMatchingCollectionGroupQuery(t,e,n,s):this.getDocumentsMatchingCollectionQuery(t,e,n,s)}getNextDocuments(t,e,n,s){return this.remoteDocumentCache.getAllFromCollectionGroup(t,e,n,s).next(i=>{const o=s-i.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(t,e,n.largestBatchId,s-i.size):A.resolve(ne());let u=$n,c=i;return o.next(h=>A.forEach(h,(f,m)=>(u<m.largestBatchId&&(u=m.largestBatchId),i.get(f)?A.resolve():this.remoteDocumentCache.getEntry(t,f).next(p=>{c=c.insert(f,p)}))).next(()=>this.populateOverlays(t,h,i)).next(()=>this.computeViews(t,c,h,G())).next(f=>({batchId:u,changes:Nd(f)})))})}getDocumentsMatchingDocumentQuery(t,e){return this.getDocument(t,new k(e)).next(n=>{let s=Kr();return n.isFoundDocument()&&(s=s.insert(n.key,n)),s})}getDocumentsMatchingCollectionGroupQuery(t,e,n,s){const i=e.collectionGroup;let o=Kr();return this.indexManager.getCollectionParents(t,i).next(u=>A.forEach(u,c=>{const h=function(m,p){return new he(p,null,m.explicitOrderBy.slice(),m.filters.slice(),m.limit,m.limitType,m.startAt,m.endAt)}(e,c.child(i));return this.getDocumentsMatchingCollectionQuery(t,h,n,s).next(f=>{f.forEach((m,p)=>{o=o.insert(m,p)})})}).next(()=>o))}getDocumentsMatchingCollectionQuery(t,e,n,s){let i;return this.documentOverlayCache.getOverlaysForCollection(t,e.path,n.largestBatchId).next(o=>(i=o,this.remoteDocumentCache.getDocumentsMatchingQuery(t,e,n,i,s))).next(o=>{i.forEach((c,h)=>{const f=h.getKey();o.get(f)===null&&(o=o.insert(f,ut.newInvalidDocument(f)))});let u=Kr();return o.forEach((c,h)=>{const f=i.get(c);f!==void 0&&rs(f.mutation,h,Bt.empty(),tt.now()),bs(e,h)&&(u=u.insert(c,h))}),u})}}/**
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 */class Oy{constructor(t){this.serializer=t,this.Lr=new Map,this.kr=new Map}getBundleMetadata(t,e){return A.resolve(this.Lr.get(e))}saveBundleMetadata(t,e){return this.Lr.set(e.id,function(s){return{id:s.id,version:s.version,createTime:pt(s.createTime)}}(e)),A.resolve()}getNamedQuery(t,e){return A.resolve(this.kr.get(e))}saveNamedQuery(t,e){return this.kr.set(e.name,function(s){return{name:s.name,query:Wi(s.bundledQuery),readTime:pt(s.readTime)}}(e)),A.resolve()}}/**
1651 * @license
1652 * Copyright 2022 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 Fy{constructor(){this.overlays=new ot(k.comparator),this.qr=new Map}getOverlay(t,e){return A.resolve(this.overlays.get(e))}getOverlays(t,e){const n=ne();return A.forEach(e,s=>this.getOverlay(t,s).next(i=>{i!==null&&n.set(s,i)})).next(()=>n)}
1665saveOverlays(t,e,n){return n.forEach((s,i)=>{this.St(t,e,i)}),A.resolve()}removeOverlaysForBatchId(t,e,n){const s=this.qr.get(n);return s!==void 0&&(s.forEach(i=>this.overlays=this.overlays.remove(i)),this.qr.delete(n)),A.resolve()}getOverlaysForCollection(t,e,n){const s=ne(),i=e.length+1,o=new k(e.child("")),u=this.overlays.getIteratorFrom(o);for(;u.hasNext();){const c=u.getNext().value,h=c.getKey();if(!e.isPrefixOf(h.path))break;h.path.length===i&&c.largestBatchId>n&&s.set(c.getKey(),c)}return A.resolve(s)}getOverlaysForCollectionGroup(t,e,n,s){let i=new ot((h,f)=>h-f);const o=this.overlays.getIterator();for(;o.hasNext();){const h=o.getNext().value;if(h.getKey().getCollectionGroup()===e&&h.largestBatchId>n){let f=i.get(h.largestBatchId);f===null&&(f=ne(),i=i.insert(h.largestBatchId,f)),f.set(h.getKey(),h)}}const u=ne(),c=i.getIterator();for(;c.hasNext()&&(c.getNext().value.forEach((h,f)=>u.set(h,f)),!(u.size()>=s)););return A.resolve(u)}St(t,e,n){const s=this.overlays.get(n.key);if(s!==null){const o=this.qr.get(s.largestBatchId).delete(n.key);this.qr.set(s.largestBatchId,o)}this.overlays=this.overlays.insert(n.key,new Ka(e,n));let i=this.qr.get(e);i===void 0&&(i=G(),this.qr.set(e,i)),this.qr.set(e,i.add(n.key))}}/**
1666 * @license
1667 * Copyright 2024 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 */class Ly{constructor(){this.sessionToken=ft.EMPTY_BYTE_STRING}getSessionToken(t){return A.resolve(this.sessionToken)}setSessionToken(t,e){return this.sessionToken=e,A.resolve()}}/**
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 Xa{constructor(){this.Qr=new rt(vt.$r),this.Ur=new rt(vt.Kr)}isEmpty(){return this.Qr.isEmpty()}addReference(t,e){const n=new vt(t,e);this.Qr=this.Qr.add(n),this.Ur=this.Ur.add(n)}Wr(t,e){t.forEach(n=>this.addReference(n,e))}removeReference(t,e){this.Gr(new vt(t,e))}zr(t,e){t.forEach(n=>this.removeReference(n,e))}jr(t){const e=new k(new K([])),n=new vt(e,t),s=new vt(e,t+1),i=[];return this.Ur.forEachInRange([n,s],o=>{this.Gr(o),i.push(o.key)}),i}Jr(){this.Qr.forEach(t=>this.Gr(t))}Gr(t){this.Qr=this.Qr.delete(t),this.Ur=this.Ur.delete(t)}Hr(t){const e=new k(new K([])),n=new vt(e,t),s=new vt(e,t+1);let i=G();return this.Ur.forEachInRange([n,s],o=>{i=i.add(o.key)}),i}containsKey(t){const e=new vt(t,0),n=this.Qr.firstAfterOrEqual(e);return n!==null&&t.isEqual(n.key)}}class vt{constructor(t,e){this.key=t,this.Yr=e}static $r(t,e){return k.comparator(t.key,e.key)||z(t.Yr,e.Yr)}static Kr(t,e){return z(t.Yr,e.Yr)||k.comparator(t.key,e.key)}}/**
1696 * @license
1697 * Copyright 2017 Google LLC
1698 *
1699 * Licensed under the Apache License, Version 2.0 (the "License");
1700 * you may not use this file except in compliance with the License.
1701 * You may obtain a copy of the License at
1702 *
1703 *   http://www.apache.org/licenses/LICENSE-2.0
1704 *
1705 * Unless required by applicable law or agreed to in writing, software
1706 * distributed under the License is distributed on an "AS IS" BASIS,
1707 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1708 * See the License for the specific language governing permissions and
1709 * limitations under the License.
1710 */class By{constructor(t,e){this.indexManager=t,this.referenceDelegate=e,this.mutation
1710Queue=[],this.tr=1,this.Zr=new rt(vt.$r)}checkEmpty(t){return A.resolve(this.mutationQueue.length===0)}addMutationBatch(t,e,n,s){const i=this.tr;this.tr++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];const o=new Ga(i,e,n,s);this.mutationQueue.push(o);for(const u of s)this.Zr=this.Zr.add(new vt(u.key,i)),this.indexManager.addToCollectionParentIndex(t,u.key.path.popLast());return A.resolve(o)}lookupMutationBatch(t,e){return A.resolve(this.Xr(e))}getNextMutationBatchAfterBatchId(t,e){const n=e+1,s=this.ei(n),i=s<0?0:s;return A.resolve(this.mutationQueue.length>i?this.mutationQueue[i]:null)}getHighestUnacknowledgedBatchId(){return A.resolve(this.mutationQueue.length===0?De:this.tr-1)}getAllMutationBatches(t){return A.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(t,e){const n=new vt(e,0),s=new vt(e,Number.POSITIVE_INFINITY),i=[];return this.Zr.forEachInRange([n,s],o=>{const u=this.Xr(o.Yr);i.push(u)}),A.resolve(i)}getAllMutationBatchesAffectingDocumentKeys(t,e){let n=new rt(z);return e.forEach(s=>{const i=new vt(s,0),o=new vt(s,Number.POSITIVE_INFINITY);this.Zr.forEachInRange([i,o],u=>{n=n.add(u.Yr)})}),A.resolve(this.ti(n))}getAllMutationBatchesAffectingQuery(t,e){const n=e.path,s=n.length+1;let i=n;k.isDocumentKey(i)||(i=i.child(""));const o=new vt(new k(i),0);let u=new rt(z);return this.Zr.forEachWhile(c=>{const h=c.key.path;return!!n.isPrefixOf(h)&&(h.length===s&&(u=u.add(c.Yr)),!0)},o),A.resolve(this.ti(u))}ti(t){const e=[];return t.forEach(n=>{const s=this.Xr(n);s!==null&&e.push(s)}),e}removeMutationBatch(t,e){L(this.ni(e.batchId,"removed")===0,55003),this.mutationQueue.shift();let n=this.Zr;return A.forEach(e.mutations,s=>{const i=new vt(s.key,e.batchId);return n=n.delete(i),this.referenceDelegate.markPotentiallyOrphaned(t,s.key)}).next(()=>{this.Zr=n})}ir(t){}containsKey(t,e){const n=new vt(e,0),s=this.Zr.firstAfterOrEqual(n);return A.resolve(e.isEqual(s&&s.key))}performConsistencyCheck(t){return this.mutationQueue.length,A.resolve()}ni(t,e){return this.ei(t)}ei(t){return this.mutationQueue.length===0?0:t-this.mutationQueue[0].batchId}Xr(t){const e=this.ei(t);return e<0||e>=this.mutationQueue.length?null:this.mutationQueue[e]}}/**
1711 * @license
1712 * Copyright 2017 Google LLC
1713 *
1714 * Licensed under the Apache License, Version 2.0 (the "License");
1715 * you may not use this file except in compliance with the License.
1716 * You may obtain a copy of the License at
1717 *
1718 *   http://www.apache.org/licenses/LICENSE-2.0
1719 *
1720 * Unless required by applicable law or agreed to in writing, software
1721 * distributed under the License is distributed on an "AS IS" BASIS,
1722 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1723 * See the License for the specific language governing permissions and
1724 * limitations under the License.
1725 */class Uy{constructor(t){this.ri=t,this.docs=function(){return new ot(k.comparator)}(),this.size=0}setIndexManager(t){this.indexManager=t}addEntry(t,e){const n=e.key,s=this.docs.get(n),i=s?s.size:0,o=this.ri(e);return this.docs=this.docs.insert(n,{document:e.mutableCopy(),size:o}),this.size+=o-i,this.indexManager.addToCollectionParentIndex(t,n.path.popLast())}removeEntry(t){const e=this.docs.get(t);e&&(this.docs=this.docs.remove(t),this.size-=e.size)}getEntry(t,e){const n=this.docs.get(e);return A.resolve(n?n.document.mutableCopy():ut.newInvalidDocument(e))}getEntries(t,e){let n=Ut();return e.forEach(s=>{const i=this.docs.get(s);n=n.insert(s,i?i.document.mutableCopy():ut.newInvalidDocument(s))}),A.resolve(n)}getDocumentsMatchingQuery(t,e,n,s){let i=Ut();const o=e.path,u=new k(o.child("__id-9223372036854775808__")),c=this.docs.getIteratorFrom(u);for(;c.hasNext();){const{key:h,value:{document:f}}=c.getNext();if(!o.isPrefixOf(h.path))break;h.path.length>o.length+1||Da(Qh(f),n)<=0||(s.has(f.key)||bs(e,f))&&(i=i.insert(f.key,f.mutableCopy()))}return A.resolve(i)}getAllFromCollectionGroup(t,e,n,s){F(9500)}ii(t,e){return A.forEach(this.docs,n=>e(n))}newChangeBuffer(t){return new qy(this)}getSize(t){return A.resolve(this.size)}}class qy extends yf{constructor(t){super(),this.Nr=t}applyChanges(t){const e=[];
1725return this.changes.forEach((n,s)=>{s.isValidDocument()?e.push(this.Nr.addEntry(t,s)):this.Nr.removeEntry(n)}),A.waitFor(e)}getFromCache(t,e){return this.Nr.getEntry(t,e)}getAllFromCache(t,e){return this.Nr.getEntries(t,e)}}/**
1726 * @license
1727 * Copyright 2017 Google LLC
1728 *
1729 * Licensed under the Apache License, Version 2.0 (the "License");
1730 * you may not use this file except in compliance with the License.
1731 * You may obtain a copy of the License at
1732 *
1733 *   http://www.apache.org/licenses/LICENSE-2.0
1734 *
1735 * Unless required by applicable law or agreed to in writing, software
1736 * distributed under the License is distributed on an "AS IS" BASIS,
1737 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1738 * See the License for the specific language governing permissions and
1739 * limitations under the License.
1740 */class jy{constructor(t){this.persistence=t,this.si=new de(e=>gn(e),As),this.lastRemoteSnapshotVersion=q.min(),this.highestTargetId=0,this.oi=0,this._i=new Xa,this.targetCount=0,this.ai=En.ur()}forEachTarget(t,e){return this.si.forEach((n,s)=>e(s)),A.resolve()}getLastRemoteSnapshotVersion(t){return A.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(t){return A.resolve(this.oi)}allocateTargetId(t){return this.highestTargetId=this.ai.next(),A.resolve(this.highestTargetId)}setTargetsMetadata(t,e,n){return n&&(this.lastRemoteSnapshotVersion=n),e>this.oi&&(this.oi=e),A.resolve()}Pr(t){this.si.set(t.target,t);const e=t.targetId;e>this.highestTargetId&&(this.ai=new En(e),this.highestTargetId=e),t.sequenceNumber>this.oi&&(this.oi=t.sequenceNumber)}addTargetData(t,e){return this.Pr(e),this.targetCount+=1,A.resolve()}updateTargetData(t,e){return this.Pr(e),A.resolve()}removeTargetData(t,e){return this.si.delete(e.target),this._i.jr(e.targetId),this.targetCount-=1,A.resolve()}removeTargets(t,e,n){let s=0;const i=[];return this.si.forEach((o,u)=>{u.sequenceNumber<=e&&n.get(u.targetId)===null&&(this.si.delete(o),i.push(this.removeMatchingKeysForTargetId(t,u.targetId)),s++)}),A.waitFor(i).next(()=>s)}getTargetCount(t){return A.resolve(this.targetCount)}getTargetData(t,e){const n=this.si.get(e)||null;return A.resolve(n)}addMatchingKeys(t,e,n){return this._i.Wr(e,n),A.resolve()}removeMatchingKeys(t,e,n){this._i.zr(e,n);const s=this.persistence.referenceDelegate,i=[];return s&&e.forEach(o=>{i.push(s.markPotentiallyOrphaned(t,o))}),A.waitFor(i)}removeMatchingKeysForTargetId(t,e){return this._i.jr(e),A.resolve()}getMatchingKeysForTargetId(t,e){const n=this._i.Hr(e);return A.resolve(n)}containsKey(t,e){return A.resolve(this._i.containsKey(e))}}/**
1741 * @license
1742 * Copyright 2017 Google LLC
1743 *
1744 * Licensed under the Apache License, Version 2.0 (the "License");
1745 * you may not use this file except in compliance with the License.
1746 * You may obtain a copy of the License at
1747 *
1748 *   http://www.apache.org/licenses/LICENSE-2.0
1749 *
1750 * Unless required by applicable law or agreed to in writing, software
1751 * distributed under the License is distributed on an "AS IS" BASIS,
1752 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1753 * See the License for the specific language governing permissions and
1754 * limitations under the License.
1755 */class Ya{constructor(t,e){this.ui={},this.overlays={},this.ci=new Lt(0),this.li=!1,this.li=!0,this.hi=new Ly,this.referenceDelegate=t(this),this.Pi=new jy(this),this.indexManager=new Sy,this.remoteDocumentCache=function(s){return new Uy(s)}(n=>this.referenceDelegate.Ti(n)),this.serializer=new af(e),this.Ii=new Oy(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.li=!1,Promise.resolve()}get started(){return this.li}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(t){return this.indexManager}getDocumentOverlayCache(t){let e=this.overlays[t.toKey()];return e||(e=new Fy,this.overlays[t.toKey()]=e),e}getMutationQueue(t,e){let n=this.ui[t.toKey()];return n||(n=new By(e,this.referenceDelegate),this.ui[t.toKey()]=n),n}getGlobalsCache(){return this.hi}getTargetCache(){return this.Pi}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Ii}runTransaction(t,e,n){N("MemoryPersistence","Starting transaction:",t);const s=new zy(this.ci.next());return this.referenceDelegate.Ei(),n(s).next(i=>this.referenceDelegate.di(s).next(()=>i)).toPromise().then(i=>(s.raiseOnCommittedEvent(),i))}Ai(t,e){return A.or(Object.values(this.ui).map(n=>()=>n.containsKey(t,e)))}}class zy extends Hh{constructor(t){super(),this.currentSequenceNumber=t}}class Xi{constructor(t){this.persistence=t,this.Ri=new Xa,this.Vi=null}static mi(t){return new Xi(t)}get fi(){if(this.Vi)return this.Vi;throw F(60996)}addReference(t,e,n){return this.Ri.addReference(n,e),this.fi.delete(n.toString()),A.resolve()}removeReference(t,e,n){return this.Ri.removeReference(n,e),this.fi.add(n.toString()),A.resolve()}markPotentiallyOrphaned(t,e){return this.fi.add(e.toString()),A.resolve()}
1755removeTarget(t,e){this.Ri.jr(e.targetId).forEach(s=>this.fi.add(s.toString()));const n=this.persistence.getTargetCache();return n.getMatchingKeysForTargetId(t,e.targetId).next(s=>{s.forEach(i=>this.fi.add(i.toString()))}).next(()=>n.removeTargetData(t,e))}Ei(){this.Vi=new Set}di(t){const e=this.persistence.getRemoteDocumentCache().newChangeBuffer();return A.forEach(this.fi,n=>{const s=k.fromPath(n);return this.gi(t,s).next(i=>{i||e.removeEntry(s,q.min())})}).next(()=>(this.Vi=null,e.apply(t)))}updateLimboDocument(t,e){return this.gi(t,e).next(n=>{n?this.fi.delete(e.toString()):this.fi.add(e.toString())})}Ti(t){return 0}gi(t,e){return A.or([()=>A.resolve(this.Ri.containsKey(e)),()=>this.persistence.getTargetCache().containsKey(t,e),()=>this.persistence.Ai(t,e)])}}class Si{constructor(t,e){this.persistence=t,this.pi=new de(n=>xt(n.path),(n,s)=>n.isEqual(s)),this.garbageCollector=_f(this,e)}static mi(t,e){return new Si(t,e)}Ei(){}di(t){return A.resolve()}forEachTarget(t,e){return this.persistence.getTargetCache().forEachTarget(t,e)}gr(t){const e=this.wr(t);return this.persistence.getTargetCache().getTargetCount(t).next(n=>e.next(s=>n+s))}wr(t){let e=0;return this.pr(t,n=>{e++}).next(()=>e)}pr(t,e){return A.forEach(this.pi,(n,s)=>this.br(t,n,s).next(i=>i?A.resolve():e(s)))}removeTargets(t,e,n){return this.persistence.getTargetCache().removeTargets(t,e,n)}removeOrphanedDocuments(t,e){let n=0;const s=this.persistence.getRemoteDocumentCache(),i=s.newChangeBuffer();return s.ii(t,o=>this.br(t,o,e).next(u=>{u||(n++,i.removeEntry(o,q.min()))})).next(()=>i.apply(t)).next(()=>n)}markPotentiallyOrphaned(t,e){return this.pi.set(e,t.currentSequenceNumber),A.resolve()}removeTarget(t,e){const n=e.withSequenceNumber(t.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(t,n)}addReference(t,e,n){return this.pi.set(n,t.currentSequenceNumber),A.resolve()}removeReference(t,e,n){return this.pi.set(n,t.currentSequenceNumber),A.resolve()}updateLimboDocument(t,e){return this.pi.set(e,t.currentSequenceNumber),A.resolve()}Ti(t){let e=t.key.toString().length;return t.isFoundDocument()&&(e+=ui(t.data.value)),e}br(t,e,n){return A.or([()=>this.persistence.Ai(t,e),()=>this.persistence.getTargetCache().containsKey(t,e),()=>{const s=this.pi.get(e);return A.resolve(s!==void 0&&s>n)}])}getCacheSize(t){return this.persistence.getRemoteDocumentCache().getSize(t)}}/**
1756 * @license
1757 * Copyright 2020 Google LLC
1758 *
1759 * Licensed under the Apache License, Version 2.0 (the "License");
1760 * you may not use this file except in compliance with the License.
1761 * You may obtain a copy of the License at
1762 *
1763 *   http://www.apache.org/licenses/LICENSE-2.0
1764 *
1765 * Unless required by applicable law or agreed to in writing, software
1766 * distributed under the License is distributed on an "AS IS" BASIS,
1767 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1768 * See the License for the specific language governing permissions and
1769 * limitations under the License.
1770 */class Gy{constructor(t){this.serializer=t}k(t,e,n,s){const i=new Fi("createOrUpgrade",e);n<1&&s>=1&&(function(c){c.createObjectStore(ws)}(t),function(c){c.createObjectStore(cs,{keyPath:u_}),c.createObjectStore(Wt,{keyPath:rl,autoIncrement:!0}).createIndex(ln,sl,{unique:!0}),c.createObjectStore(Wn)}(t),Ql(t),function(c){c.createObjectStore(sn)}(t));let o=A.resolve();return n<3&&s>=3&&(n!==0&&(function(c){c.deleteObjectStore(Jn),c.deleteObjectStore(Hn),c.deleteObjectStore(dn)}(t),Ql(t)),o=o.next(()=>function(c){const h=c.store(dn),f={highestTargetId:0,highestListenSequenceNumber:0,lastRemoteSnapshotVersion:q.min().toTimestamp(),targetCount:0};return h.put(Ei,f)}(i))),n<4&&s>=4&&(n!==0&&(o=o.next(()=>function(c,h){return h.store(Wt).J().next(m=>{c.deleteObjectStore(Wt),c.createObjectStore(Wt,{keyPath:rl,autoIncrement:!0}).createIndex(ln,sl,{unique:!0});const p=h.store(Wt),v=m.map(C=>p.put(C));return A.waitFor(v)})}(t,i))),o=o.next(()=>{(function(c){c.createObjectStore(Xn,{keyPath:__})})(t)})),n<5&&s>=5&&(o=o.next(()=>this.yi(i))),n<6&&s>=6&&(o=o.next(()=>
1770(function(c){c.createObjectStore(ls)}(t),this.wi(i)))),n<7&&s>=7&&(o=o.next(()=>this.Si(i))),n<8&&s>=8&&(o=o.next(()=>this.bi(t,i))),n<9&&s>=9&&(o=o.next(()=>{(function(c){c.objectStoreNames.contains("remoteDocumentChanges")&&c.deleteObjectStore("remoteDocumentChanges")})(t)})),n<10&&s>=10&&(o=o.next(()=>this.Di(i))),n<11&&s>=11&&(o=o.next(()=>{(function(c){c.createObjectStore(Li,{keyPath:y_})})(t),function(c){c.createObjectStore(Bi,{keyPath:I_})}(t)})),n<12&&s>=12&&(o=o.next(()=>{(function(c){const h=c.createObjectStore(Ui,{keyPath:R_});h.createIndex(sa,S_,{unique:!1}),h.createIndex(rd,P_,{unique:!1})})(t)})),n<13&&s>=13&&(o=o.next(()=>function(c){const h=c.createObjectStore(Ii,{keyPath:l_});h.createIndex(oi,h_),h.createIndex(Zh,d_)}(t)).next(()=>this.Ci(t,i)).next(()=>t.deleteObjectStore(sn))),n<14&&s>=14&&(o=o.next(()=>this.Fi(t,i))),n<15&&s>=15&&(o=o.next(()=>function(c){c.createObjectStore(ka,{keyPath:E_,autoIncrement:!0}).createIndex(ra,T_,{unique:!1}),c.createObjectStore(Zr,{keyPath:w_}).createIndex(ed,A_,{unique:!1}),c.createObjectStore(ts,{keyPath:v_}).createIndex(nd,b_,{unique:!1})}(t))),n<16&&s>=16&&(o=o.next(()=>{e.objectStore(Zr).clear()}).next(()=>{e.objectStore(ts).clear()})),n<17&&s>=17&&(o=o.next(()=>{(function(c){c.createObjectStore(Ma,{keyPath:V_})})(t)})),n<18&&s>=18&&bh()&&(o=o.next(()=>{e.objectStore(Zr).clear()}).next(()=>{e.objectStore(ts).clear()})),o}wi(t){let e=0;return t.store(sn).ee((n,s)=>{e+=Ri(s)}).next(()=>{const n={byteSize:e};return t.store(ls).put(na,n)})}yi(t){const e=t.store(cs),n=t.store(Wt);return e.J().next(s=>A.forEach(s,i=>{const o=IDBKeyRange.bound([i.userId,De],[i.userId,i.lastAcknowledgedBatchId]);return n.J(ln,o).next(u=>A.forEach(u,c=>{L(c.userId===i.userId,18650,"Cannot process batch from unexpected user",{batchId:c.batchId});const h=an(this.serializer,c);return df(t,i.userId,h).next(()=>{})}))}))}Si(t){const e=t.store(Jn),n=t.store(sn);return t.store(dn).get(Ei).next(s=>{const i=[];return n.ee((o,u)=>{const c=new K(o),h=function(m){return[0,xt(m)]}(c);i.push(e.get(h).next(f=>f?A.resolve():(m=>e.put({targetId:0,path:xt(m),sequenceNumber:s.highestListenSequenceNumber}))(c)))}).next(()=>A.waitFor(i))})}bi(t,e){t.createObjectStore(hs,{keyPath:p_});const n=e.store(hs),s=new Ja,i=o=>{if(s.add(o)){const u=o.lastSegment(),c=o.popLast();return n.put({collectionId:u,parent:xt(c)})}};return e.store(sn).ee({X:!0},(o,u)=>{const c=new K(o);return i(c.popLast())}).next(()=>e.store(Wn).ee({X:!0},([o,u,c],h)=>{const f=ee(u);return i(f.popLast())}))}Di(t){const e=t.store(Hn);return e.ee((n,s)=>{const i=Wr(s),o=uf(this.serializer,i);return e.put(o)})}Ci(t,e){const n=e.store(sn),s=[];return n.ee((i,o)=>{const u=e.store(Ii),c=function(m){return m.document?new k(K.fromString(m.document.name).popFirst(5)):m.noDocument?k.fromSegments(m.noDocument.path):m.unknownDocument?k.fromSegments(m.unknownDocument.path):F(36783)}(o).path.toArray(),h={prefixPath:c.slice(0,c.length-2),collectionGroup:c[c.length-2],documentId:c[c.length-1],readTime:o.readTime||[0,0],unknownDocument:o.unknownDocument,noDocument:o.noDocument,document:o.document,hasCommittedMutations:!!o.hasCommittedMutations};s.push(u.put(h))}).next(()=>A.waitFor(s))}Fi(t,e){const n=e.store(Wt),s=If(this.serializer),i=new Ya(Xi.mi,this.serializer.yt);return n.J().next(o=>{const u=new Map;return o.forEach(c=>{let h=u.get(c.userId)??G();an(this.serializer,c).keys().forEach(f=>h=h.add(f)),u.set(c.userId,h)}),A.forEach(u,(c,h)=>{const f=new bt(h),m=Hi.wt(this.serializer,f),p=i.getIndexManager(f),v=Ji.wt(f,this.serializer,p,i.referenceDelegate);return new Ef(s,v,m,p).recalculateAndSaveOverlaysForDocumentKeys(new ia(e,Lt.ce),c).next()})})}}function Ql(r){r.createObjectStore(Jn,{keyPath:m_}).createIndex(Na,g_,{unique:!0}),r.createObjectStore(Hn,{keyPath:"targetId"}).createIndex(td,f_,{unique:!0}),r.createObjectStore(dn)}const Ae="IndexedDbPersistence",Uo=18e5,qo=5e3,jo="Failed to obtain exclusive access to the persistence layer. To allow shared access, multi-tab synchronization has to be enabled in all tabs. If you are using `experimentalForceOwningTab:true`, make sure that only one tab has persistence enabled at any given time.",Tf="main";class Za{constructor(t,e,n,s,i,o,u,c,h,f,m=18){if(this.allowTabSynchronization=t,this.persistenceKey=e,this.clientId=n,this.Mi=i,this.window=o,this.document=u,this.xi=h,this.Oi=f,this.Ni=m,this.ci=null,this.li=!1,this.isPrimary=!1,this.networkEnabled=!0,this.Bi=null,this.inForeground=!1,this.Li=null,this.ki=null,this.qi=Number.NEGATIVE_INFINITY,this.Qi=p=>
1770Promise.resolve(),!Za.v())throw new V(R.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");this.referenceDelegate=new xy(this,s),this.$i=e+Tf,this.serializer=new af(c),this.Ui=new re(this.$i,this.Ni,new Gy(this.serializer)),this.hi=new Ty,this.Pi=new Vy(this.referenceDelegate,this.serializer),this.remoteDocumentCache=If(this.serializer),this.Ii=new Ey,this.window&&this.window.localStorage?this.Ki=this.window.localStorage:(this.Ki=null,f===!1&&gt(Ae,"LocalStorage is unavailable. As a result, persistence may not work reliably. In particular enablePersistence() could fail immediately after refreshing the page."))}start(){return this.Wi().then(()=>{if(!this.isPrimary&&!this.allowTabSynchronization)throw new V(R.FAILED_PRECONDITION,jo);return this.Gi(),this.zi(),this.ji(),this.runTransaction("getHighestListenSequenceNumber","readonly",t=>this.Pi.getHighestSequenceNumber(t))}).then(t=>{this.ci=new Lt(t,this.xi)}).then(()=>{this.li=!0}).catch(t=>(this.Ui&&this.Ui.close(),Promise.reject(t)))}Ji(t){return this.Qi=async e=>{if(this.started)return t(e)},t(this.isPrimary)}setDatabaseDeletedListener(t){this.Ui.$(async e=>{e.newVersion===null&&await t()})}setNetworkEnabled(t){this.networkEnabled!==t&&(this.networkEnabled=t,this.Mi.enqueueAndForget(async()=>{this.started&&await this.Wi()}))}Wi(){return this.runTransaction("updateClientMetadataAndTryBecomePrimary","readwrite",t=>ei(t).put({clientId:this.clientId,updateTimeMs:Date.now(),networkEnabled:this.networkEnabled,inForeground:this.inForeground}).next(()=>{if(this.isPrimary)return this.Hi(t).next(e=>{e||(this.isPrimary=!1,this.Mi.enqueueRetryable(()=>this.Qi(!1)))})}).next(()=>this.Yi(t)).next(e=>this.isPrimary&&!e?this.Zi(t).next(()=>!1):!!e&&this.Xi(t).next(()=>!0))).catch(t=>{if(je(t))return N(Ae,"Failed to extend owner lease: ",t),this.isPrimary;if(!this.allowTabSynchronization)throw t;return N(Ae,"Releasing owner lease after error during lease refresh",t),!1}).then(t=>{this.isPrimary!==t&&this.Mi.enqueueRetryable(()=>this.Qi(t)),this.isPrimary=t})}Hi(t){return Gr(t).get(Dn).next(e=>A.resolve(this.es(e)))}ts(t){return ei(t).delete(this.clientId)}async ns(){if(this.isPrimary&&!this.rs(this.qi,Uo)){this.qi=Date.now();const t=await this.runTransaction("maybeGarbageCollectMultiClientState","readwrite-primary",e=>{const n=wt(e,Xn);return n.J().next(s=>{const i=this.ss(s,Uo),o=s.filter(u=>i.indexOf(u)===-1);return A.forEach(o,u=>n.delete(u.clientId)).next(()=>o)})}).catch(()=>[]);if(this.Ki)for(const e of t)this.Ki.removeItem(this._s(e.clientId))}}ji(){this.ki=this.Mi.enqueueAfterDelay("client_metadata_refresh",4e3,()=>this.Wi().then(()=>this.ns()).then(()=>this.ji()))}es(t){return!!t&&t.ownerId===this.clientId}Yi(t){return this.Oi?A.resolve(!0):Gr(t).get(Dn).next(e=>{if(e!==null&&this.rs(e.leaseTimestampMs,qo)&&!this.us(e.ownerId)){if(this.es(e)&&this.networkEnabled)return!0;if(!this.es(e)){if(!e.allowTabSynchronization)throw new V(R.FAILED_PRECONDITION,jo);return!1}}return!(!this.networkEnabled||!this.inForeground)||ei(t).J().next(n=>this.ss(n,qo).find(s=>{if(this.clientId!==s.clientId){const i=!this.networkEnabled&&s.networkEnabled,o=!this.inForeground&&s.inForeground,u=this.networkEnabled===s.networkEnabled;if(i||o&&u)return!0}return!1})===void 0)}).next(e=>(this.isPrimary!==e&&N(Ae,`Client ${e?"is":"is not"} eligible for a primary lease.`),e))}async shutdown(){this.li=!1,this.cs(),this.ki&&(this.ki.cancel(),this.ki=null),this.ls(),this.hs(),await this.Ui.runTransaction("shutdown","readwrite",[ws,Xn],t=>{const e=new ia(t,Lt.ce);return this.Zi(e).next(()=>this.ts(e))}),this.Ui.close(),this.Ps()}ss(t,e){return t.filter(n=>this.rs(n.updateTimeMs,e)&&!this.us(n.clientId))}Ts(){return this.runTransaction("getActiveClients","readonly",t=>ei(t).J().next(e=>this.ss(e,Uo).map(n=>n.clientId)))}get started(){return this.li}getGlobalsCache(){return this.hi}getMutationQueue(t,e){return Ji.wt(t,this.serializer,e,this.referenceDelegate)}getTargetCache(){return this.Pi}getRemoteDocumentCache(){return this.remoteDocumentCache}getIndexManager(t){return new Py(t,this.serializer.yt.databaseId)}getDocumentOverlayCache(t){return Hi.wt(this.serializer,t)}getBundleCache(){return this.Ii}runTransaction(t,e,n){N(Ae,"Starting transaction:",t);const s=e==="readonly"?"readonly":"readwrite",i=function(c){return c===18?x_:c===17?ad:c===16?D_:c===15?Oa:c===14?od:c===13?id:c===12?C_:c===11?sd:void F(60245)}(this.Ni);let o;return this.Ui.runTransaction(t,s,i,u=>(o=new ia(u,this.ci?this.ci.next():Lt.ce),e==="readwrite-primary"?this.Hi(o).next(c=>!!c||this.Yi(o)).next(c=>{if(!c)throw gt(`Failed to obtain primary lease for action '${t}'.`),this.isPrimary=!1,this.Mi.enqueueRetryable(()=>this.Qi(!1)),new V(R.FAILED_PRECONDITION,Wh);return n(o)}).next(c=>this.Xi(o).next(()=>c)):this.Is(o).next(()=>n(o)))).then(u=>(o.raiseOnCommittedEvent(),u))}Is(t){return Gr(t).get(Dn).next(e=>{if(e!==null&&this.rs(e.leaseTimestampMs,qo)&&!this.us(e.ownerId)&&!this.es(e)&&!(this.Oi||this.allowTabSynchronization&&e.allowTabSynchronization))throw new V(R.FAILED_PRECONDITION,jo)})}Xi(t){const e={ownerId:this.clientId,allowTabSynchronization:this.allowTabSynchronization,leaseTimestampMs:Date.now()};return Gr(t).put(Dn,e)}static v(){return re.v()}Zi(t){const e=Gr(t);return e.get(Dn).next(n=>this.es(n)?(N(Ae,"Releasing primary lease."),e.delete(Dn)):A.resolve())}rs(t,e){const n=Date.now();return!(t<n-e)&&(!(t>n)||(gt(`Detected an update time that is in the future: ${t} > ${n}`),!1))}Gi(){this.document!==null&&typeof this.document.addEventListener=="function"&&(this.Li=()=>{this.Mi.enqueueAndForget(()=>(this.inForeground=this.document.visibilityState==="visible",this.Wi()))},this.document.addEventListener("visibilitychange",this.Li),this.inForeground=this.document.visibilityState==="visible")}ls(){this.Li&&(this.document.removeEventListener("visibilitychange",this.Li),this.Li=null)}zi(){typeof this.window?.addEventListener=="function"&&(this.Bi=()=>{this.cs();const t=/(?:Version|Mobile)\/1[456]/;vh()&&(navigator.appVersion.match(t)||navigator.userAgent.match(t))&&this.Mi.enterRestrictedMode(!0),this.Mi.enqueueAndForget(()=>this.shutdown())},this.window.addEventListener("pagehide",this.Bi))}hs(){this.Bi&&(this.window.removeEventListener("pagehide",this.Bi),this.Bi=null)}us(t){try{const e=this.Ki?.getItem(this._s(t))!==null;return N(Ae,`Client '${t}' ${e?"is":"is not"} zombied in LocalStorage`),e}catch(e){return gt(Ae,"Failed to get zombied client id.",e),!1}}cs(){if(this.Ki)try{this.Ki.setItem(this._s(this.clientId),String(Date.now()))}catch(t){gt("Failed to set zombie client id.",t)}}Ps(){if(this.Ki)try{this.Ki.removeItem(this._s(this.clientId))}catch{}}_s(t){return`firestore_zombie_${this.persistenceKey}_${t}`}}function Gr(r){return wt(r,ws)}function ei(r){return wt(r,Xn)}function tu(r,t){let e=r.projectId;return r.isDefaultDatabase||(e+="."+r.database),"firestore/"+t+"/"+e+"/"}/**
1771 * @license
1772 * Copyright 2017 Google LLC
1773 *
1774 * Licensed under the Apache License, Version 2.0 (the "License");
1775 * you may not use this file except in compliance with the License.
1776 * You may obtain a copy of the License at
1777 *
1778 *   http://www.apache.org/licenses/LICENSE-2.0
1779 *
1780 * Unless required by applicable law or agreed to in writing, software
1781 * distributed under the License is distributed on an "AS IS" BASIS,
1782 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1783 * See the License for the specific language governing permissions and
1784 * limitations under the License.
1785 */class eu{constructor(t,e,n,s){this.targetId=t,this.fromCache=e,this.Es=n,this.ds=s}static As(t,e){let n=G(),s=G();for(const i of e.docChanges)switch(i.type){case 0:n=n.add(i.doc.key);break;case 1:s=s.add(i.doc.key)}return new eu(t,e.fromCache,n,s)}}/**
1786 * @license
1787 * Copyright 2023 Google LLC
1788 *
1789 * Licensed under the Apache License, Version 2.0 (the "License");
1790 * you may not use this file except in compliance with the License.
1791 * You may obtain a copy of the License at
1792 *
1793 *   http://www.apache.org/licenses/LICENSE-2.0
1794 *
1795 * Unless required by applicable law or agreed to in writing, software
1796 * distributed under the License is distributed on an "AS IS" BASIS,
1797 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1798 * See the License for the specific language governing permissions and
1799 * limitations under the License.
1800 */class $y{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(t){this._documentReadCount+=t}}/**
1801 * @license
1802 * Copyright 2019 Google LLC
1803 *
1804 * Licensed under the Apache License, Version 2.0 (the "License");
1805 * you may not use this file except in compliance with the License.
1806 * You may obtain a copy of the License at
1807 *
1808 *   http://www.apache.org/licenses/LICENSE-2.0
1809 *
1810 * Unless required by applicable law or agreed to in writing, software
1811 * distributed under the License is distributed on an "AS IS" BASIS,
1812 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1813 * See the License for the specific language governing permissions and
1814 * limitations under the License.
1815 */class wf{constructor(){this.Rs=!1,this.Vs=!1,this.fs=100,this.gs=function(){return vh()?8:Jh(zn())>0?6:4}()}initialize(t,e){this.ps=t,this.indexManager=e,this.Rs=!0}getDocumentsMatchingQuery(t,e,n,s){const i={result:null};return this.ys(t,e).next(o=>{i.result=o}).next(()=>{if(!i.result)return this.ws(t,e,s,n).next(o=>{i.result=o})}).next(()=>{if(i.result)return;const o=new $y;return this.Ss(t,e,o).next(u=>{if(i.result=u,this.Vs)return this.bs(t,e,o,u.size)})}).next(()=>i.result)}bs(t,e,n,s){return n.documentReadCount<this.fs?(Fn()<=X.DEBUG&&N("QueryEngine","SDK will not create cache indexes for query:",Ln(e),"since it only creates cache indexes for collection contains","more than or equal to",this.fs,"documents"),A.resolve()):(Fn()<=X.DEBUG&&N("QueryEngine","Query:",Ln(e),"scans",n.documentReadCount,"local documents and returns",s,"documents as results."),n.documentReadCount>this.gs*s?(Fn()<=X.DEBUG&&N("QueryEngine","The SDK decides to create cache indexes for query:",Ln(e),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(t,Nt(e))):A.resolve())}ys(t,e){if(_l(e))return A.resolve(null);let n=Nt(e);return this.indexManager.getIndexType(t,n).next(s=>s===0?null:(e.limit!==null&&s===1&&(e=Ai(e,null,"F"),n=Nt(e)),this.indexManager.getDocumentsMatchingTarget(t,n).next(i=>{const o=G(...i);return this.ps.getDocuments(t,o).next(u=>this.indexManager.getMinOffset(t,n).next(c=>{const h=this.Ds(e,u);return this.Cs(e,h,o,c.readTime)?this.ys(t,Ai(e,null,"F")):this.vs(t,h,e,c)}))})))}ws(t,e,n,s){return _l(e)||s.isEqual(q.min())?A.resolve(null):this.ps.getDocuments(t,n).next(i=>{const o=this.Ds(e,i);return this.Cs(e,o,n,s)?A.resolve(null):(Fn()<=X.DEBUG&&N("QueryEngine","Re-using previous result from %s to execute query: %s",s.toString(),Ln(e)),this.vs(t,o,e,Kh(s,$n)).next(u=>u))})}Ds(t,e){let n=new rt(Dd(t));return e.forEach((s,i)=>{bs(t,i)&&(n=n.add(i))}),n}Cs(t,e,n,s){if(t.limit===null)return!1;if(n.size!==e.size)return!0;const i=t.limitType==="F"?e.last():e.first();return!!i&&(i.hasPendingWrites||i.version.compareTo(s)>0)}Ss(t,e,n){return Fn()<=X.DEBUG&&N("QueryEngine","Using full collection scan to execute query:",Ln(e)),this.ps.getDocumentsMatchingQuery(t,e,Kt.min(),n)}vs(t,e,n,s){return this.ps.getDocumentsMatchingQuery(t,n,s).next(i=>(e.forEach(o=>{i=i.insert(o.key,o)}),i))}}/**
1816 * @license
1817 * Copyright 2020 Google LLC
1818 *
1819 * Licensed under the Apache License, Version 2.0 (the "License");
1820 * you may not use this file except in compliance with the License.
1821 * You may obtain a copy of the License at
1822 *
1823 *   http://www.apache.org/licenses/LICENSE-2.0
1824 *
1825 * Unless required by applicable law or agreed to in writing, software
1826 * distributed under the License is distributed on an "AS IS" BASIS,
1827 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1828 * See the License for the specific language governing permissions and
1829 * limitations under the License.
1830 */const nu="LocalStore",Ky=3e8;class Qy{constructor(t,e,n,s){this.persistence=t,this.Fs=e,this.serializer=s,this.Ms=new ot(z),this.xs=new de(i=>gn(i),As),this.Os=new Map,this.Ns=t.getRemoteDocumentCache(),this.Pi=t.getTargetCache(),this.Ii=t.getBundleCache(),this.Bs(n)}Bs(t){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(t),this.indexManager=this.persistence.getIndexManager(t),this.mutationQueue=this.persistence.getMutationQueue(t,this.indexManager),this.localDocuments=new Ef(this.Ns,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.Ns.setIndexManager(this.indexManager),this.Fs.initialize(this.localDocuments,this.indexManager)}collectGarbage(t){return this.persistence.runTransaction("Collect garbage","readwrite-primary",e=>t.collect(e,this.Ms))}}function Af(r,t,e,n){return new Qy(r,t,e,n)}async function vf(r,t){const e=M(r);return await e.persistence.runTransaction("Handle user change","readonly",n=>{let s;return e.mutationQueue.getAllMutationBatches(n).next(i=>(s=i,e.Bs(t),e.mutationQueue.getAllMutationBatches(n))).next(i=>{const o=[],u=[];let c=G();for(const h of s){o.push(h.batchId);for(const f of h.mutations)c=c.add(f.key)}for(const h of i){u.push(h.batchId);for(const f of h.mutations)c=c.add(f.key)}return e.localDocuments.getDocuments(n,c).next(h=>({Ls:h,removedBatchIds:o,addedBatchIds:u}))})})}function Wy(r,t){const e=M(r);return e.persistence.runTransaction("Acknowledge batch","readwrite-primary",n=>{const s=t.batch.keys(),i=e.Ns.newChangeBuffer({trackRemovals:!0});return function(u,c,h,f){const m=h.batch,p=m.keys();let v=A.resolve();return p.forEach(C=>{v=v.next(()=>f.getEntry(c,C)).next(D=>{const x=h.docVersions.get(C);L(x!==null,48541),D.version.compareTo(x)<0&&(m.applyToRemoteDocument(D,h),D.isValidDocument()&&(D.setReadTime(h.commitVersion),f.addEntry(D)))})}),v.next(()=>u.mutationQueue.removeMutationBatch(c,m))}(e,n,t,i).next(()=>i.apply(n)).next(()=>e.mutationQueue.performConsistencyCheck(n)).next(()=>e.documentOverlayCache.removeOverlaysForBatchId(n,s,t.batch.batchId)).next(()=>e.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(n,function(u){let c=G();for(let h=0;h<u.mutationResults.length;++h)u.mutationResults[h].transformResults.length>0&&(c=c.add(u.batch.mutations[h].key));return c}(t))).next(()=>e.localDocuments.getDocuments(n,s))})}function bf(r){const t=M(r);return t.persistence.runTransaction("Get last remote snapshot version","readonly",e=>t.Pi.getLastRemoteSnapshotVersion(e))}function Hy(r,t){const e=M(r),n=t.snapshotVersion;let s=e.Ms;return e.persistence.runTransaction("Apply remote event","readwrite-primary",i=>{const o=e.Ns.newChangeBuffer({trackRemovals:!0});s=e.Ms;const u=[];
1830t.targetChanges.forEach((f,m)=>{const p=s.get(m);if(!p)return;u.push(e.Pi.removeMatchingKeys(i,f.removedDocuments,m).next(()=>e.Pi.addMatchingKeys(i,f.addedDocuments,m)));let v=p.withSequenceNumber(i.currentSequenceNumber);t.targetMismatches.get(m)!==null?v=v.withResumeToken(ft.EMPTY_BYTE_STRING,q.min()).withLastLimboFreeSnapshotVersion(q.min()):f.resumeToken.approximateByteSize()>0&&(v=v.withResumeToken(f.resumeToken,n)),s=s.insert(m,v),function(D,x,B){return D.resumeToken.approximateByteSize()===0||x.snapshotVersion.toMicroseconds()-D.snapshotVersion.toMicroseconds()>=Ky?!0:B.addedDocuments.size+B.modifiedDocuments.size+B.removedDocuments.size>0}(p,v,f)&&u.push(e.Pi.updateTargetData(i,v))});let c=Ut(),h=G();if(t.documentUpdates.forEach(f=>{t.resolvedLimboDocuments.has(f)&&u.push(e.persistence.referenceDelegate.updateLimboDocument(i,f))}),u.push(Rf(i,o,t.documentUpdates).next(f=>{c=f.ks,h=f.qs})),!n.isEqual(q.min())){const f=e.Pi.getLastRemoteSnapshotVersion(i).next(m=>e.Pi.setTargetsMetadata(i,i.currentSequenceNumber,n));u.push(f)}return A.waitFor(u).next(()=>o.apply(i)).next(()=>e.localDocuments.getLocalViewOfDocuments(i,c,h)).next(()=>c)}).then(i=>(e.Ms=s,i))}function Rf(r,t,e){let n=G(),s=G();return e.forEach(i=>n=n.add(i)),t.getEntries(r,n).next(i=>{let o=Ut();return e.forEach((u,c)=>{const h=i.get(u);c.isFoundDocument()!==h.isFoundDocument()&&(s=s.add(u)),c.isNoDocument()&&c.version.isEqual(q.min())?(t.removeEntry(u,c.readTime),o=o.insert(u,c)):!h.isValidDocument()||c.version.compareTo(h.version)>0||c.version.compareTo(h.version)===0&&h.hasPendingWrites?(t.addEntry(c),o=o.insert(u,c)):N(nu,"Ignoring outdated watch update for ",u,". Current version:",h.version," Watch version:",c.version)}),{ks:o,qs:s}})}function Jy(r,t){const e=M(r);return e.persistence.runTransaction("Get next mutation batch","readonly",n=>(t===void 0&&(t=De),e.mutationQueue.getNextMutationBatchAfterBatchId(n,t)))}function sr(r,t){const e=M(r);return e.persistence.runTransaction("Allocate target","readwrite",n=>{let s;return e.Pi.getTargetData(n,t).next(i=>i?(s=i,A.resolve(s)):e.Pi.allocateTargetId(n).next(o=>(s=new oe(t,o,"TargetPurposeListen",n.currentSequenceNumber),e.Pi.addTargetData(n,s).next(()=>s))))}).then(n=>{const s=e.Ms.get(n.targetId);return(s===null||n.snapshotVersion.compareTo(s.snapshotVersion)>0)&&(e.Ms=e.Ms.insert(n.targetId,n),e.xs.set(t,n.targetId)),n})}async function ir(r,t,e){const n=M(r),s=n.Ms.get(t),i=e?"readwrite":"readwrite-primary";try{e||await n.persistence.runTransaction("Release target",i,o=>n.persistence.referenceDelegate.removeTarget(o,s))}catch(o){if(!je(o))throw o;N(nu,`Failed to update sequence numbers for target ${t}: ${o}`)}n.Ms=n.Ms.remove(t),n.xs.delete(s.target)}function Pi(r,t,e){const n=M(r);let s=q.min(),i=G();return n.persistence.runTransaction("Execute query","readwrite",o=>function(c,h,f){const m=M(c),p=m.xs.get(f);return p!==void 0?A.resolve(m.Ms.get(p)):m.Pi.getTargetData(h,f)}(n,o,Nt(t)).next(u=>{if(u)return s=u.lastLimboFreeSnapshotVersion,n.Pi.getMatchingKeysForTargetId(o,u.targetId).next(c=>{i=c})}).next(()=>n.Fs.getDocumentsMatchingQuery(o,t,e?s:q.min(),e?i:G())).next(u=>(Vf(n,Cd(t),u),{documents:u,Qs:i})))}function Sf(r,t){const e=M(r),n=M(e.Pi),s=e.Ms.get(t);return s?Promise.resolve(s.target):e.persistence.runTransaction("Get target data","readonly",i=>n.At(i,t).next(o=>o?o.target:null))}function Pf(r,t){const e=M(r),n=e.Os.get(t)||q.min();return e.persistence.runTransaction("Get new document changes","readonly",s=>e.Ns.getAllFromCollectionGroup(s,t,Kh(n,$n),Number.MAX_SAFE_INTEGER)).then(s=>(Vf(e,t,s),s))}function Vf(r,t,e){let n=r.Os.get(t)||q.min();e.forEach((s,i)=>{i.readTime.compareTo(n)>0&&(n=i.readTime)}),r.Os.set(t,n)}async function Xy(r,t,e,n){const s=M(r);let i=G(),o=Ut();for(const h of e){const f=t.$s(h.metadata.name);h.document&&(i=i.add(f));const m=t.Us(h);m.setReadTime(t.Ks(h.metadata.readTime)),o=o.insert(f,m)}const u=s.Ns.newChangeBuffer({trackRemovals:!0}),c=await sr(s,function(f){return Nt(fr(K.fromString(`__bundle__/docs/${f}`)))}(n));return s.persistence.runTransaction("Apply bundle documents","readwrite",h=>Rf(h,u,o).next(f=>(u.apply(h),f)).next(f=>s.Pi.removeMatchingKeysForTargetId(h,c.targetId).next(()=>s.Pi.addMatchingKeys(h,i,c.targetId)).next(()=>s.localDocuments.getLocalViewOfDocuments(h,f.ks,f.qs)).next(()=>f.ks)))}async function Yy(r,t,e=G()){const n=await sr(r,Nt(Wi(t.bundledQuery))),s=M(r);return s.persistence.runTransaction("Save named query","readwrite",i=>{const o=pt(t.readTime);if(n.snapshotVersion.compareTo(o)>=0)return s.Ii.saveNamedQuery(i,t);const u=n.withResumeToken(ft.EMPTY_BYTE_STRING,o);return s.Ms=s.Ms.insert(u.targetId,u),s.Pi.updateTargetData(i,u).next(()=>s.Pi.removeMatchingKeysForTargetId(i,n.targetId)).next(()=>s.Pi.addMatchingKeys(i,e,n.targetId)).next(()=>s.Ii.saveNamedQuery(i,t))})}/**
1831 * @license
1832 * Copyright 2019 Google LLC
1833 *
1834 * Licensed under the Apache License, Version 2.0 (the "License");
1835 * you may not use this file except in compliance with the License.
1836 * You may obtain a copy of the License at
1837 *
1838 *   http://www.apache.org/licenses/LICENSE-2.0
1839 *
1840 * Unless required by applicable law or agreed to in writing, software
1841 * distributed under the License is distributed on an "AS IS" BASIS,
1842 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1843 * See the License for the specific language governing permissions and
1844 * limitations under the License.
1845 */const Cf="firestore_clients";function Wl(r,t){return`${Cf}_${r}_${t}`}const Df="firestore_mutations";function Hl(r,t,e){let n=`${Df}_${r}_${e}`;return t.isAuthenticated()&&(n+=`_${t.uid}`),n}const xf="firestore_targets";function zo(r,t){return`${xf}_${r}_${t}`}/**
1846 * @license
1847 * Copyright 2018 Google LLC
1848 *
1849 * Licensed under the Apache License, Version 2.0 (the "License");
1850 * you may not use this file except in compliance with the License.
1851 * You may obtain a copy of the License at
1852 *
1853 *   http://www.apache.org/licenses/LICENSE-2.0
1854 *
1855 * Unless required by applicable law or agreed to in writing, software
1856 * distributed under the License is distributed on an "AS IS" BASIS,
1857 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1858 * See the License for the specific language governing permissions and
1859 * limitations under the License.
1860 */const te="SharedClientState";class Vi{constructor(t,e,n,s){this.user=t,this.batchId=e,this.state=n,this.error=s}static Ws(t,e,n){const s=JSON.parse(n);let i,o=typeof s=="object"&&["pending","acknowledged","rejected"].indexOf(s.state)!==-1&&(s.error===void 0||typeof s.error=="object");return o&&s.error&&(o=typeof s.error.message=="string"&&typeof s.error.code=="string",o&&(i=new V(s.error.code,s.error.message))),o?new Vi(t,e,s.state,i):(gt(te,`Failed to parse mutation state for ID '${e}': ${n}`),null)}Gs(){const t={state:this.state,updateTimeMs:Date.now()};return this.error&&(t.error={code:this.error.code,message:this.error.message}),JSON.stringify(t)}}class ss{constructor(t,e,n){this.targetId=t,this.state=e,this.error=n}static Ws(t,e){const n=JSON.parse(e);let s,i=typeof n=="object"&&["not-current","current","rejected"].indexOf(n.state)!==-1&&(n.error===void 0||typeof n.error=="object");return i&&n.error&&(i=typeof n.error.message=="string"&&typeof n.error.code=="string",i&&(s=new V(n.error.code,n.error.message))),i?new ss(t,n.state,s):(gt(te,`Failed to parse target state for ID '${t}': ${e}`),null)}Gs(){const t={state:this.state,updateTimeMs:Date.now()};return this.error&&(t.error={code:this.error.code,message:this.error.message}),JSON.stringify(t)}}class Ci{constructor(t,e){this.clientId=t,this.activeTargetIds=e}static Ws(t,e){const n=JSON.parse(e);let s=typeof n=="object"&&n.activeTargetIds instanceof Array,i=qa();for(let o=0;s&&o<n.activeTargetIds.length;++o)s=Xh(n.activeTargetIds[o]),i=i.add(n.activeTargetIds[o]);return s?new Ci(t,i):(gt(te,`Failed to parse client data for instance '${t}': ${e}`),null)}}class ru{constructor(t,e){this.clientId=t,this.onlineState=e}static Ws(t){const e=JSON.parse(t);return typeof e=="object"&&["Unknown","Online","Offline"].indexOf(e.onlineState)!==-1&&typeof e.clientId=="string"?new ru(e.clientId,e.onlineState):(gt(te,`Failed to parse online state: ${t}`),null)}}class Ea{constructor(){this.activeTargetIds=qa()}zs(t){this.activeTargetIds=this.activeTargetIds.add(t)}js(t){this.activeTargetIds=this.activeTargetIds.delete(t)}Gs(){const t={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(t)}}class Go{constructor(t,e,n,s,i){this.window=t,this.Mi=e,this.persistenceKey=n,this.Js=s,this.syncEngine=null,this.onlineStateHandler=null,this.sequenceNumberHandler=null,this.Hs=this.Ys.bind(this),this.Zs=new ot(z),this.started=!1,this.Xs=[];const o=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");this.storage=this.window.localStorage,this.currentUser=i,this.eo=Wl(this.persistenceKey,this.Js),this.no=function(c){return`firestore_sequence_number_${c}`}(this.persistenceKey),this.Zs=this.Zs.insert(this.Js,new Ea),this.ro=new RegExp(`^${Cf}_${o}_([^_]*)$`),this.io=new RegExp(`^${Df}_${o}_(\\d+)(?:_(.*))?$`),this.so=new RegExp(`^${xf}_${o}_(\\d+)$`),this.oo=function(c){return`firestore_online_state_${c}`}(this.persistenceKey),this._o=function(c){return`firestore_bundle_loaded_v2_${c}`}(this.persistenceKey),this.window.addEventListener("storage",this.Hs)}static v(t){return!(!t||!t.localStorage)}async start(){const t=await this.syncEngine.Ts();for(const n of t){if(n===this.Js)continue;const s=this.getItem(Wl(this.persistenceKey,n));if(s){const i=Ci.Ws(n,s);i&&(this.Zs=this.Zs.insert(i.clientId,i))}}this.ao();const e=this.storage.getItem(this.oo);if(e){const n=this.uo(e);n&&this.co(n)}for(const n of this.Xs)this.Ys(n);this.Xs=[],this.window.addEventListener("pagehide",()=>this.shutdown()),this.started=!0}writeSequenceNumber(t){this.setItem(this.no,JSON.stringify(t))}getAllActiveQueryTargets(){return this.lo(this.Zs)}isActiveQueryTarget(t){let e=!1;return this.Zs.forEach((n,s)=>{s.activeTargetIds.has(t)&&(e=!0)}),e}addPendingMutation(t){this.ho(t,"pending")}updateMutationState(t,e,n){this.ho(t,e,n),this.Po(t)}
1860addLocalQueryTarget(t,e=!0){let n="not-current";if(this.isActiveQueryTarget(t)){const s=this.storage.getItem(zo(this.persistenceKey,t));if(s){const i=ss.Ws(t,s);i&&(n=i.state)}}return e&&this.To.zs(t),this.ao(),n}removeLocalQueryTarget(t){this.To.js(t),this.ao()}isLocalQueryTarget(t){return this.To.activeTargetIds.has(t)}clearQueryState(t){this.removeItem(zo(this.persistenceKey,t))}updateQueryState(t,e,n){this.Io(t,e,n)}handleUserChange(t,e,n){e.forEach(s=>{this.Po(s)}),this.currentUser=t,n.forEach(s=>{this.addPendingMutation(s)})}setOnlineState(t){this.Eo(t)}notifyBundleLoaded(t){this.Ao(t)}shutdown(){this.started&&(this.window.removeEventListener("storage",this.Hs),this.removeItem(this.eo),this.started=!1)}getItem(t){const e=this.storage.getItem(t);return N(te,"READ",t,e),e}setItem(t,e){N(te,"SET",t,e),this.storage.setItem(t,e)}removeItem(t){N(te,"REMOVE",t),this.storage.removeItem(t)}Ys(t){const e=t;if(e.storageArea===this.storage){if(N(te,"EVENT",e.key,e.newValue),e.key===this.eo)return void gt("Received WebStorage notification for local change. Another client might have garbage-collected our state");this.Mi.enqueueRetryable(async()=>{if(this.started){if(e.key!==null){if(this.ro.test(e.key)){if(e.newValue==null){const n=this.Ro(e.key);return this.Vo(n,null)}{const n=this.mo(e.key,e.newValue);if(n)return this.Vo(n.clientId,n)}}else if(this.io.test(e.key)){if(e.newValue!==null){const n=this.fo(e.key,e.newValue);if(n)return this.po(n)}}else if(this.so.test(e.key)){if(e.newValue!==null){const n=this.yo(e.key,e.newValue);if(n)return this.wo(n)}}else if(e.key===this.oo){if(e.newValue!==null){const n=this.uo(e.newValue);if(n)return this.co(n)}}else if(e.key===this.no){const n=function(i){let o=Lt.ce;if(i!=null)try{const u=JSON.parse(i);L(typeof u=="number",30636,{So:i}),o=u}catch(u){gt(te,"Failed to read sequence number from WebStorage",u)}return o}(e.newValue);n!==Lt.ce&&this.sequenceNumberHandler(n)}else if(e.key===this._o){const n=this.bo(e.newValue);await Promise.all(n.map(s=>this.syncEngine.Do(s)))}}}else this.Xs.push(e)})}}get To(){return this.Zs.get(this.Js)}ao(){this.setItem(this.eo,this.To.Gs())}ho(t,e,n){const s=new Vi(this.currentUser,t,e,n),i=Hl(this.persistenceKey,this.currentUser,t);this.setItem(i,s.Gs())}Po(t){const e=Hl(this.persistenceKey,this.currentUser,t);this.removeItem(e)}Eo(t){const e={clientId:this.Js,onlineState:t};this.storage.setItem(this.oo,JSON.stringify(e))}Io(t,e,n){const s=zo(this.persistenceKey,t),i=new ss(t,e,n);this.setItem(s,i.Gs())}Ao(t){const e=JSON.stringify(Array.from(t));this.setItem(this._o,e)}Ro(t){const e=this.ro.exec(t);return e?e[1]:null}mo(t,e){const n=this.Ro(t);return Ci.Ws(n,e)}fo(t,e){const n=this.io.exec(t),s=Number(n[1]),i=n[2]!==void 0?n[2]:null;return Vi.Ws(new bt(i),s,e)}yo(t,e){const n=this.so.exec(t),s=Number(n[1]);return ss.Ws(s,e)}uo(t){return ru.Ws(t)}bo(t){return JSON.parse(t)}async po(t){if(t.user.uid===this.currentUser.uid)return this.syncEngine.Co(t.batchId,t.state,t.error);N(te,`Ignoring mutation for non-active user ${t.user.uid}`)}wo(t){return this.syncEngine.vo(t.targetId,t.state,t.error)}Vo(t,e){const n=e?this.Zs.insert(t,e):this.Zs.remove(t),s=this.lo(this.Zs),i=this.lo(n),o=[],u=[];return i.forEach(c=>{s.has(c)||o.push(c)}),s.forEach(c=>{i.has(c)||u.push(c)}),this.syncEngine.Fo(o,u).then(()=>{this.Zs=n})}co(t){this.Zs.get(t.clientId)&&this.onlineStateHandler(t.onlineState)}lo(t){let e=qa();return t.forEach((n,s)=>{e=e.unionWith(s.activeTargetIds)}),e}}class Nf{constructor(){this.Mo=new Ea,this.xo={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(t){}updateMutationState(t,e,n){}addLocalQueryTarget(t,e=!0){return e&&this.Mo.zs(t),this.xo[t]||"not-current"}updateQueryState(t,e,n){this.xo[t]=e}removeLocalQueryTarget(t){this.Mo.js(t)}isLocalQueryTarget(t){return this.Mo.activeTargetIds.has(t)}clearQueryState(t){delete this.xo[t]}getAllActiveQueryTargets(){return this.Mo.activeTargetIds}isActiveQueryTarget(t){return this.Mo.activeTargetIds.has(t)}start(){return this.Mo=new Ea,Promise.resolve()}handleUserChange(t,e,n){}setOnlineState(t){}shutdown(){}writeSequenceNumber(t){}notifyBundleLoaded(t){}}/**
1861 * @license
1862 * Copyright 2019 Google LLC
1863 *
1864 * Licensed under the Apache License, Version 2.0 (the "License");
1865 * you may not use this file except in compliance with the License.
1866 * You may obtain a copy of the License at
1867 *
1868 *   http://www.apache.org/licenses/LICENSE-2.0
1869 *
1870 * Unless required by applicable law or agreed to in writing, software
1871 * distributed under the License is distributed on an "AS IS" BASIS,
1872 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1873 * See the License for the specific language governing permissions and
1874 * limitations under the License.
1875 */class Zy{Oo(t){}shutdown(){}}/**
1876 * @license
1877 * Copyright 2019 Google LLC
1878 *
1879 * Licensed under the Apache License, Version 2.0 (the "License");
1880 * you may not use this file except in compliance with the License.
1881 * You may obtain a copy of the License at
1882 *
1883 *   http://www.apache.org/licenses/LICENSE-2.0
1884 *
1885 * Unless required by applicable law or agreed to in writing, software
1886 * distributed under the License is distributed on an "AS IS" BASIS,
1887 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1888 * See the License for the specific language governing permissions and
1889 * limitations under the License.
1890 */const Jl="ConnectivityMonitor";class Xl{constructor(){this.No=()=>this.Bo(),this.Lo=()=>this.ko(),this.qo=[],this.Qo()}Oo(t){this.qo.push(t)}shutdown(){window.removeEventListener("online",this.No),window.removeEventListener("offline",this.Lo)}Qo(){window.addEventListener("online",this.No),window.addEventListener("offline",this.Lo)}Bo(){N(Jl,"Network connectivity changed: AVAILABLE");for(const t of this.qo)t(0)}ko(){N(Jl,"Network connectivity changed: UNAVAILABLE");for(const t of this.qo)t(1)}static v(){return typeof window<"u"&&window.addEventListener!==void 0&&window.removeEventListener!==void 0}}/**
1891 * @license
1892 * Copyright 2023 Google LLC
1893 *
1894 * Licensed under the Apache License, Version 2.0 (the "License");
1895 * you may not use this file except in compliance with the License.
1896 * You may obtain a copy of the License at
1897 *
1898 *   http://www.apache.org/licenses/LICENSE-2.0
1899 *
1900 * Unless required by applicable law or agreed to in writing, software
1901 * distributed under the License is distributed on an "AS IS" BASIS,
1902 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1903 * See the License for the specific language governing permissions and
1904 * limitations under the License.
1905 */let ni=null;function Ta(){return ni===null?ni=function(){return 268435456+Math.round(2147483648*Math.random())}():ni++,"0x"+ni.toString(16)}/**
1906 * @license
1907 * Copyright 2020 Google LLC
1908 *
1909 * Licensed under the Apache License, Version 2.0 (the "License");
1910 * you may not use this file except in compliance with the License.
1911 * You may obtain a copy of the License at
1912 *
1913 *   http://www.apache.org/licenses/LICENSE-2.0
1914 *
1915 * Unless required by applicable law or agreed to in writing, software
1916 * distributed under the License is distributed on an "AS IS" BASIS,
1917 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1918 * See the License for the specific language governing permissions and
1919 * limitations under the License.
1920 */const $o="RestConnection",tI={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery"};class eI{get $o(){return!1}constructor(t){this.databaseInfo=t,this.databaseId=t.databaseId;const e=t.ssl?"https":"http",n=encodeURIComponent(this.databaseId.projectId),s=encodeURIComponent(this.databaseId.database);this.Uo=e+"://"+t.host,this.Ko=`projects/${n}/databases/${s}`,this.Wo=this.databaseId.database===fs?`project_id=${n}`:`project_id=${n}&database_id=${s}`}Go(t,e,n,s,i){const o=Ta(),u=this.zo(t,e.toUriEncodedString());N($o,`Sending RPC '${t}' ${o}:`,u,n);const c={"google-cloud-resource-prefix":this.Ko,"x-goog-request-params":this.Wo};this.jo(c,s,i);const{host:h}=new URL(u),f=ki(h);return this.Jo(t,u,c,n,f).then(m=>(N($o,`Received RPC '${t}' ${o}: `,m),m),m=>{throw $t($o,`RPC '${t}' ${o} failed with error: `,m,"url: ",u,"request:",n),m})}Ho(t,e,n,s,i,o){return this.Go(t,e,n,s,i)}jo(t,e,n){t["X-Goog-Api-Client"]=function(){return"gl-js/ fire/"+dr}(),t["Content-Type"]="text/plain",this.databaseInfo.appId&&(t["X-Firebase-GMPID"]=this.databaseInfo.appId),e&&e.headers.forEac
1920h((s,i)=>t[i]=s),n&&n.headers.forEach((s,i)=>t[i]=s)}zo(t,e){const n=tI[t];return`${this.Uo}/v1/${e}:${n}`}terminate(){}}/**
1921 * @license
1922 * Copyright 2017 Google LLC
1923 *
1924 * Licensed under the Apache License, Version 2.0 (the "License");
1925 * you may not use this file except in compliance with the License.
1926 * You may obtain a copy of the License at
1927 *
1928 *   http://www.apache.org/licenses/LICENSE-2.0
1929 *
1930 * Unless required by applicable law or agreed to in writing, software
1931 * distributed under the License is distributed on an "AS IS" BASIS,
1932 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1933 * See the License for the specific language governing permissions and
1934 * limitations under the License.
1935 */class nI{constructor(t){this.Yo=t.Yo,this.Zo=t.Zo}Xo(t){this.e_=t}t_(t){this.n_=t}r_(t){this.i_=t}onMessage(t){this.s_=t}close(){this.Zo()}send(t){this.Yo(t)}o_(){this.e_()}__(){this.n_()}a_(t){this.i_(t)}u_(t){this.s_(t)}}/**
1936 * @license
1937 * Copyright 2017 Google LLC
1938 *
1939 * Licensed under the Apache License, Version 2.0 (the "License");
1940 * you may not use this file except in compliance with the License.
1941 * You may obtain a copy of the License at
1942 *
1943 *   http://www.apache.org/licenses/LICENSE-2.0
1944 *
1945 * Unless required by applicable law or agreed to in writing, software
1946 * distributed under the License is distributed on an "AS IS" BASIS,
1947 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1948 * See the License for the specific language governing permissions and
1949 * limitations under the License.
1950 */const Ct="WebChannelConnection";class rI extends eI{constructor(t){super(t),this.c_=[],this.forceLongPolling=t.forceLongPolling,this.autoDetectLongPolling=t.autoDetectLongPolling,this.useFetchStreams=t.useFetchStreams,this.longPollingOptions=t.longPollingOptions}Jo(t,e,n,s,i){const o=Ta();return new Promise((u,c)=>{const h=new kh;h.setWithCredentials(!0),h.listenOnce(Mh.COMPLETE,()=>{try{switch(h.getLastErrorCode()){case si.NO_ERROR:const m=h.getResponseJson();N(Ct,`XHR for RPC '${t}' ${o} received:`,JSON.stringify(m)),u(m);break;case si.TIMEOUT:N(Ct,`RPC '${t}' ${o} timed out`),c(new V(R.DEADLINE_EXCEEDED,"Request time out"));break;case si.HTTP_ERROR:const p=h.getStatus();if(N(Ct,`RPC '${t}' ${o} failed with status:`,p,"response text:",h.getResponseText()),p>0){let v=h.getResponseJson();Array.isArray(v)&&(v=v[0]);const C=v?.error;if(C&&C.status&&C.message){const D=function(B){const j=B.toLowerCase().replace(/_/g,"-");return Object.values(R).indexOf(j)>=0?j:R.UNKNOWN}(C.status);c(new V(D,C.message))}else c(new V(R.UNKNOWN,"Server responded with status "+h.getStatus()))}else c(new V(R.UNAVAILABLE,"Connection failed."));break;default:F(9055,{l_:t,streamId:o,h_:h.getLastErrorCode(),P_:h.getLastError()})}}finally{N(Ct,`RPC '${t}' ${o} completed.`)}});const f=JSON.stringify(s);N(Ct,`RPC '${t}' ${o} sending request:`,s),h.send(e,"POST",f,n,15)})}T_(t,e,n){const s=Ta(),i=[this.Uo,"/","google.firestore.v1.Firestore","/",t,"/channel"],o=Lh(),u=Fh(),c={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},h=this.longPollingOptions.timeoutSeconds;h!==void 0&&(c.longPollingTimeout=Math.round(1e3*h)),this.useFetchStreams&&(c.useFetchStreams=!0),this.jo(c.initMessageHeaders,e,n),c.encodeInitMessageHeaders=!0;const f=i.join("");N(Ct,`Creating RPC '${t}' stream ${s}: ${f}`,c);const m=o.createWebChannel(f,c);this.I_(m);let p=!1,v=!1;const C=new nI({Yo:x=>{v?N(Ct,`Not sending because RPC '${t}' stream ${s} is closed:`,x):(p||(N(Ct,`Opening RPC '${t}' stream ${s} transport.`),m.open(),p=!0),N(Ct,`RPC '${t}' stream ${s} sending:`,x),m.send(x))},Zo:()=>m.close()}),D=(x,B,j)=>{x.listen(B,U=>{try{j(U)}catch(Y){setTimeout(()=>{throw Y},0)}})};return D(m,$r.EventType.OPEN,()=>{v||(N(Ct,`RPC '${t}' stream ${s} transport opened.`),C.o_())}),D(m,$r.EventType.CLOSE,()=>{v||(v=!0,N(Ct,`RPC '${t}' stream ${s} transport closed`),C.a_(),this.E_(m))}
1950),D(m,$r.EventType.ERROR,x=>{v||(v=!0,$t(Ct,`RPC '${t}' stream ${s} transport errored. Name:`,x.name,"Message:",x.message),C.a_(new V(R.UNAVAILABLE,"The operation could not be completed")))}),D(m,$r.EventType.MESSAGE,x=>{if(!v){const B=x.data[0];L(!!B,16349);const j=B,U=j?.error||j[0]?.error;if(U){N(Ct,`RPC '${t}' stream ${s} received error:`,U);const Y=U.status;let Z=function(_){const I=_t[_];if(I!==void 0)return $d(I)}(Y),H=U.message;Z===void 0&&(Z=R.INTERNAL,H="Unknown error status: "+Y+" with message "+U.message),v=!0,C.a_(new V(Z,H)),m.close()}else N(Ct,`RPC '${t}' stream ${s} received:`,B),C.u_(B)}}),D(u,Oh.STAT_EVENT,x=>{x.stat===Xo.PROXY?N(Ct,`RPC '${t}' stream ${s} detected buffering proxy`):x.stat===Xo.NOPROXY&&N(Ct,`RPC '${t}' stream ${s} detected no buffering proxy`)}),setTimeout(()=>{C.__()},0),C}terminate(){this.c_.forEach(t=>t.close()),this.c_=[]}I_(t){this.c_.push(t)}E_(t){this.c_=this.c_.filter(e=>e===t)}}/**
1951 * @license
1952 * Copyright 2020 Google LLC
1953 *
1954 * Licensed under the Apache License, Version 2.0 (the "License");
1955 * you may not use this file except in compliance with the License.
1956 * You may obtain a copy of the License at
1957 *
1958 *   http://www.apache.org/licenses/LICENSE-2.0
1959 *
1960 * Unless required by applicable law or agreed to in writing, software
1961 * distributed under the License is distributed on an "AS IS" BASIS,
1962 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1963 * See the License for the specific language governing permissions and
1964 * limitations under the License.
1965 *//**
1966 * @license
1967 * Copyright 2020 Google LLC
1968 *
1969 * Licensed under the Apache License, Version 2.0 (the "License");
1970 * you may not use this file except in compliance with the License.
1971 * You may obtain a copy of the License at
1972 *
1973 *   http://www.apache.org/licenses/LICENSE-2.0
1974 *
1975 * Unless required by applicable law or agreed to in writing, software
1976 * distributed under the License is distributed on an "AS IS" BASIS,
1977 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1978 * See the License for the specific language governing permissions and
1979 * limitations under the License.
1980 */function kf(){return typeof window<"u"?window:null}function fi(){return typeof document<"u"?document:null}/**
1981 * @license
1982 * Copyright 2020 Google LLC
1983 *
1984 * Licensed under the Apache License, Version 2.0 (the "License");
1985 * you may not use this file except in compliance with the License.
1986 * You may obtain a copy of the License at
1987 *
1988 *   http://www.apache.org/licenses/LICENSE-2.0
1989 *
1990 * Unless required by applicable law or agreed to in writing, software
1991 * distributed under the License is distributed on an "AS IS" BASIS,
1992 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1993 * See the License for the specific language governing permissions and
1994 * limitations under the License.
1995 */function vn(r){return new cy(r,!0)}/**
1996 * @license
1997 * Copyright 2017 Google LLC
1998 *
1999 * Licensed under the Apache License, Version 2.0 (the "License");
2000 * you may not use this file except in compliance with the License.
2001 * You may obtain a copy of the License at
2002 *
2003 *   http://www.apache.org/licenses/LICENSE-2.0
2004 *
2005 * Unless required by applicable law or agreed to in writing, software
2006 * distributed under the License is distributed on an "AS IS" BASIS,
2007 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2008 * See the License for the specific language governing permissions and
2009 * limitations under the License.
2010 */class su{constructor(t,e,n=1e3,s=1.5,i=6e4){this.Mi=t,this.timerId=e,this.d_=n,this.A_=s,this.R_=i,this.V_=0,this.m_=null,this.f_=Date.now(),this.reset()}reset(){this.V_=0}g_(){this.V_=this.R_}p_(t){this.cancel();const e=Math.floor(this.V_+this.y_()),n=Math.max(0,Date.now()-this.f_),s=Math.max(0,e-n);s>0&&N("ExponentialBackoff",`Backing off for ${s} ms (base delay: ${this.V_} ms, delay with jitter: ${e} ms, last attempt: ${n} ms ago)`),this.m_=this.Mi.enqueueAfterDelay(this.timerId,s,()=>(this.f_=Date.now(),t())),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_}}
2010/**
2011 * @license
2012 * Copyright 2017 Google LLC
2013 *
2014 * Licensed under the Apache License, Version 2.0 (the "License");
2015 * you may not use this file except in compliance with the License.
2016 * You may obtain a copy of the License at
2017 *
2018 *   http://www.apache.org/licenses/LICENSE-2.0
2019 *
2020 * Unless required by applicable law or agreed to in writing, software
2021 * distributed under the License is distributed on an "AS IS" BASIS,
2022 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2023 * See the License for the specific language governing permissions and
2024 * limitations under the License.
2025 */const Yl="PersistentStream";class Mf{constructor(t,e,n,s,i,o,u,c){this.Mi=t,this.S_=n,this.b_=s,this.connection=i,this.authCredentialsProvider=o,this.appCheckCredentialsProvider=u,this.listener=c,this.state=0,this.D_=0,this.C_=null,this.v_=null,this.stream=null,this.F_=0,this.M_=new su(t,e)}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_(t){this.Q_(),this.stream.send(t)}async k_(){if(this.O_())return this.close(0)}Q_(){this.C_&&(this.C_.cancel(),this.C_=null)}U_(){this.v_&&(this.v_.cancel(),this.v_=null)}async close(t,e){this.Q_(),this.U_(),this.M_.cancel(),this.D_++,t!==4?this.M_.reset():e&&e.code===R.RESOURCE_EXHAUSTED?(gt(e.toString()),gt("Using maximum backoff delay to prevent overloading the backend."),this.M_.g_()):e&&e.code===R.UNAUTHENTICATED&&this.state!==3&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),this.stream!==null&&(this.K_(),this.stream.close(),this.stream=null),this.state=t,await this.listener.r_(e)}K_(){}auth(){this.state=1;const t=this.W_(this.D_),e=this.D_;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then(([n,s])=>{this.D_===e&&this.G_(n,s)},n=>{t(()=>{const s=new V(R.UNKNOWN,"Fetching auth token failed: "+n.message);return this.z_(s)})})}G_(t,e){const n=this.W_(this.D_);this.stream=this.j_(t,e),this.stream.Xo(()=>{n(()=>this.listener.Xo())}),this.stream.t_(()=>{n(()=>(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=>{n(()=>this.z_(s))}),this.stream.onMessage(s=>{n(()=>++this.F_==1?this.J_(s):this.onNext(s))})}N_(){this.state=5,this.M_.p_(async()=>{this.state=0,this.start()})}z_(t){return N(Yl,`close with error: ${t}`),this.stream=null,this.close(4,t)}W_(t){return e=>{this.Mi.enqueueAndForget(()=>this.D_===t?e():(N(Yl,"stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve()))}}}class sI extends Mf{constructor(t,e,n,s,i,o){super(t,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",e,n,s,o),this.serializer=i}j_(t,e){return this.connection.T_("Listen",t,e)}J_(t){return this.onNext(t)}onNext(t){this.M_.reset();const e=dy(this.serializer,t),n=function(i){if(!("targetChange"in i))return q.min();const o=i.targetChange;return o.targetIds&&o.targetIds.length?q.min():o.readTime?pt(o.readTime):q.min()}(t);return this.listener.H_(e,n)}Y_(t){const e={};e.database=ga(this.serializer),e.addTarget=function(i,o){let u;const c=o.target;if(u=Ti(c)?{documents:tf(i,c)}:{query:Qi(i,c).ft},u.targetId=o.targetId,o.resumeToken.approximateByteSize()>0){u.resumeToken=Hd(i,o.resumeToken);const h=fa(i,o.expectedCount);h!==null&&(u.expectedCount=h)}else if(o.snapshotVersion.compareTo(q.min())>0){u.readTime=rr(i,o.snapshotVersion.toTimestamp());const h=fa(i,o.expectedCount);h!==null&&(u.expectedCount=h)}return u}(this.serializer,t);const n=my(this.serializer,t);n&&(e.labels=n),this.q_(e)}Z_(t){const e={};e.database=ga(this.serializer),e.removeTarget=t,this.q_(e)}}class iI extends Mf{constructor(t,e,n,s,i,o){super(t,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",e,n,s,o),this.serializer
2025=i}get X_(){return this.F_>0}start(){this.lastStreamToken=void 0,super.start()}K_(){this.X_&&this.ea([])}j_(t,e){return this.connection.T_("Write",t,e)}J_(t){return L(!!t.streamToken,31322),this.lastStreamToken=t.streamToken,L(!t.writeResults||t.writeResults.length===0,55816),this.listener.ta()}onNext(t){L(!!t.streamToken,12678),this.lastStreamToken=t.streamToken,this.M_.reset();const e=fy(t.writeResults,t.commitTime),n=pt(t.commitTime);return this.listener.na(n,e)}ra(){const t={};t.database=ga(this.serializer),this.q_(t)}ea(t){const e={streamToken:this.lastStreamToken,writes:t.map(n=>ys(this.serializer,n))};this.q_(e)}}/**
2026 * @license
2027 * Copyright 2017 Google LLC
2028 *
2029 * Licensed under the Apache License, Version 2.0 (the "License");
2030 * you may not use this file except in compliance with the License.
2031 * You may obtain a copy of the License at
2032 *
2033 *   http://www.apache.org/licenses/LICENSE-2.0
2034 *
2035 * Unless required by applicable law or agreed to in writing, software
2036 * distributed under the License is distributed on an "AS IS" BASIS,
2037 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2038 * See the License for the specific language governing permissions and
2039 * limitations under the License.
2040 */class oI{}class aI extends oI{constructor(t,e,n,s){super(),this.authCredentials=t,this.appCheckCredentials=e,this.connection=n,this.serializer=s,this.ia=!1}sa(){if(this.ia)throw new V(R.FAILED_PRECONDITION,"The client has already been terminated.")}Go(t,e,n,s){return this.sa(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([i,o])=>this.connection.Go(t,ma(e,n),s,i,o)).catch(i=>{throw i.name==="FirebaseError"?(i.code===R.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),i):new V(R.UNKNOWN,i.toString())})}Ho(t,e,n,s,i){return this.sa(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([o,u])=>this.connection.Ho(t,ma(e,n),s,o,u,i)).catch(o=>{throw o.name==="FirebaseError"?(o.code===R.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),o):new V(R.UNKNOWN,o.toString())})}terminate(){this.ia=!0,this.connection.terminate()}}class uI{constructor(t,e){this.asyncQueue=t,this.onlineStateHandler=e,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(t){this.state==="Online"?this.ca("Unknown"):(this.oa++,this.oa>=1&&(this.Pa(),this.la(`Connection failed 1 times. Most recent error: ${t.toString()}`),this.ca("Offline")))}set(t){this.Pa(),this.oa=0,t==="Online"&&(this.aa=!1),this.ca(t)}ca(t){t!==this.state&&(this.state=t,this.onlineStateHandler(t))}la(t){const e=`Could not reach Cloud Firestore backend. ${t}
2041This 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?(gt(e),this.aa=!1):N("OnlineStateTracker",e)}Pa(){this._a!==null&&(this._a.cancel(),this._a=null)}}/**
2042 * @license
2043 * Copyright 2017 Google LLC
2044 *
2045 * Licensed under the Apache License, Version 2.0 (the "License");
2046 * you may not use this file except in compliance with the License.
2047 * You may obtain a copy of the License at
2048 *
2049 *   http://www.apache.org/licenses/LICENSE-2.0
2050 *
2051 * Unless required by applicable law or agreed to in writing, software
2052 * distributed under the License is distributed on an "AS IS" BASIS,
2053 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2054 * See the License for the specific language governing permissions and
2055 * limitations under the License.
2056 */const Tn="RemoteStore";class cI{constructor(t,e,n,s,i){this.localStore=t,this.datastore=e,this.asyncQueue=n,this.remoteSyncer={},this.Ta=[],this.Ia=new Map,this.Ea=new Set,this.da=[],this.Aa=i,this.Aa.Oo(o=>{n.enqueueAndForget(async()=>
2056{Ge(this)&&(N(Tn,"Restarting streams for network reachability change."),await async function(c){const h=M(c);h.Ea.add(4),await pr(h),h.Ra.set("Unknown"),h.Ea.delete(4),await Vs(h)}(this))})}),this.Ra=new uI(n,s)}}async function Vs(r){if(Ge(r))for(const t of r.da)await t(!0)}async function pr(r){for(const t of r.da)await t(!1)}function Yi(r,t){const e=M(r);e.Ia.has(t.targetId)||(e.Ia.set(t.targetId,t),au(e)?ou(e):yr(e).O_()&&iu(e,t))}function or(r,t){const e=M(r),n=yr(e);e.Ia.delete(t),n.O_()&&Of(e,t),e.Ia.size===0&&(n.O_()?n.L_():Ge(e)&&e.Ra.set("Unknown"))}function iu(r,t){if(r.Va.Ue(t.targetId),t.resumeToken.approximateByteSize()>0||t.snapshotVersion.compareTo(q.min())>0){const e=r.remoteSyncer.getRemoteKeysForTarget(t.targetId).size;t=t.withExpectedCount(e)}yr(r).Y_(t)}function Of(r,t){r.Va.Ue(t),yr(r).Z_(t)}function ou(r){r.Va=new iy({getRemoteKeysForTarget:t=>r.remoteSyncer.getRemoteKeysForTarget(t),At:t=>r.Ia.get(t)||null,ht:()=>r.datastore.serializer.databaseId}),yr(r).start(),r.Ra.ua()}function au(r){return Ge(r)&&!yr(r).x_()&&r.Ia.size>0}function Ge(r){return M(r).Ea.size===0}function Ff(r){r.Va=void 0}async function lI(r){r.Ra.set("Online")}async function hI(r){r.Ia.forEach((t,e)=>{iu(r,t)})}async function dI(r,t){Ff(r),au(r)?(r.Ra.ha(t),ou(r)):r.Ra.set("Unknown")}async function fI(r,t,e){if(r.Ra.set("Online"),t instanceof Wd&&t.state===2&&t.cause)try{await async function(s,i){const o=i.cause;for(const u of i.targetIds)s.Ia.has(u)&&(await s.remoteSyncer.rejectListen(u,o),s.Ia.delete(u),s.Va.removeTarget(u))}(r,t)}catch(n){N(Tn,"Failed to remove targets %s: %s ",t.targetIds.join(","),n),await Di(r,n)}else if(t instanceof hi?r.Va.Ze(t):t instanceof Qd?r.Va.st(t):r.Va.tt(t),!e.isEqual(q.min()))try{const n=await bf(r.localStore);e.compareTo(n)>=0&&await function(i,o){const u=i.Va.Tt(o);
2056return u.targetChanges.forEach((c,h)=>{if(c.resumeToken.approximateByteSize()>0){const f=i.Ia.get(h);f&&i.Ia.set(h,f.withResumeToken(c.resumeToken,o))}}),u.targetMismatches.forEach((c,h)=>{const f=i.Ia.get(c);if(!f)return;i.Ia.set(c,f.withResumeToken(ft.EMPTY_BYTE_STRING,f.snapshotVersion)),Of(i,c);const m=new oe(f.target,c,h,f.sequenceNumber);iu(i,m)}),i.remoteSyncer.applyRemoteEvent(u)}(r,e)}catch(n){N(Tn,"Failed to raise snapshot:",n),await Di(r,n)}}async function Di(r,t,e){if(!je(t))throw t;r.Ea.add(1),await pr(r),r.Ra.set("Offline"),e||(e=()=>bf(r.localStore)),r.asyncQueue.enqueueRetryable(async()=>{N(Tn,"Retrying IndexedDB access"),await e(),r.Ea.delete(1),await Vs(r)})}function Lf(r,t){return t().catch(e=>Di(r,e,t))}async function _r(r){const t=M(r),e=Le(t);let n=t.Ta.length>0?t.Ta[t.Ta.length-1].batchId:De;for(;mI(t);)try{const s=await Jy(t.localStore,n);if(s===null){t.Ta.length===0&&e.L_();break}n=s.batchId,gI(t,s)}catch(s){await Di(t,s)}Bf(t)&&Uf(t)}function mI(r){return Ge(r)&&r.Ta.length<10}function gI(r,t){r.Ta.push(t);const e=Le(r);e.O_()&&e.X_&&e.ea(t.mutations)}function Bf(r){return Ge(r)&&!Le(r).x_()&&r.Ta.length>0}function Uf(r){Le(r).start()}async function pI(r){Le(r).ra()}async function _I(r){const t=Le(r);for(const e of r.Ta)t.ea(e.mutations)}async function yI(r,t,e){const n=r.Ta.shift(),s=$a.from(n,t,e);await Lf(r,()=>r.remoteSyncer.applySuccessfulWrite(s)),await _r(r)}async function II(r,t){t&&Le(r).X_&&await async function(n,s){if(function(o){return Gd(o)&&o!==R.ABORTED}(s.code)){const i=n.Ta.shift();Le(n).B_(),await Lf(n,()=>n.remoteSyncer.rejectFailedWrite(i.batchId,s)),await _r(n)}}(r,t),Bf(r)&&Uf(r)}async function Zl(r,t){const e=M(r);e.asyncQueue.verifyOperationInProgress(),N(Tn,"RemoteStore received new credentials");const n=Ge(e);e.Ea.add(3),await pr(e),n&&e.Ra.set("Unknown"),await e.remoteSyncer.handleCredentialChange(t),e.Ea.delete(3),await Vs(e)}async function wa(r,t){const e=M(r);t?(e.Ea.delete(2),await Vs(e)):t||(e.Ea.add(2),await pr(e),e.Ra.set("Unknown"))}function yr(r){return r.ma||(r.ma=function(e,n,s){const i=M(e);return i.sa(),new sI(n,i.connection,i.authCredentials,i.appCheckCredentials,i.serializer,s)}(r.datastore,r.asyncQueue,{Xo:lI.bind(null,r),t_:hI.bind(null,r),r_:dI.bind(null,r),H_:fI.bind(null,r)}),r.da.push(async t=>{t?(r.ma.B_(),au(r)?ou(r):r.Ra.set("Unknown")):(await r.ma.stop(),Ff(r))})),r.ma}function Le(r){return r.fa||(r.fa=function(e,n,s){const i=M(e);return i.sa(),new iI(n,i.connection,i.authCredentials,i.appCheckCredentials,i.serializer,s)}(r.datastore,r.asyncQueue,{Xo:()=>Promise.resolve(),t_:pI.bind(null,r),r_:II.bind(null,r),ta:_I.bind(null,r),na:yI.bind(null,r)}),r.da.push(async t=>{t?(r.fa.B_(),await _r(r)):(await r.fa.stop(),r.Ta.length>0&&(N(Tn,`Stopping write stream with ${r.Ta.length} pending writes`),r.Ta=[]))})),r.fa}/**
2057 * @license
2058 * Copyright 2017 Google LLC
2059 *
2060 * Licensed under the Apache License, Version 2.0 (the "License");
2061 * you may not use this file except in compliance with the License.
2062 * You may obtain a copy of the License at
2063 *
2064 *   http://www.apache.org/licenses/LICENSE-2.0
2065 *
2066 * Unless required by applicable law or agreed to in writing, software
2067 * distributed under the License is distributed on an "AS IS" BASIS,
2068 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2069 * See the License for the specific language governing permissions and
2070 * limitations under the License.
2071 */class uu{constructor(t,e,n,s,i){this.asyncQueue=t,this.timerId=e,this.targetTimeMs=n,this.op=s,this.removalCallback=i,this.deferred=new Rt,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch(o=>{})}get promise(){return this.deferred.promise}static createAndSchedule(t,e,n,s,i){const o=Date.now()+n,u=new uu(t,e,o,s,i);return u.start(n),u}start(t){this.timerHandle=setTimeout(()=>this.handleDelayElapsed(),t)}skipDelay(){return this.handleDelayElapsed()}cancel(t){this.timerHandle!==null&&(this.clearTimeout(),this.deferred.reject(new V(R.CANCELLED,"Operation cancelled"+(t?": "+t:"")))
2071)}handleDelayElapsed(){this.asyncQueue.enqueueAndForget(()=>this.timerHandle!==null?(this.clearTimeout(),this.op().then(t=>this.deferred.resolve(t))):Promise.resolve())}clearTimeout(){this.timerHandle!==null&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}}function Ir(r,t){if(gt("AsyncQueue",`${t}: ${r}`),je(r))return new V(R.UNAVAILABLE,`${t}: ${r}`);throw r}/**
2072 * @license
2073 * Copyright 2017 Google LLC
2074 *
2075 * Licensed under the Apache License, Version 2.0 (the "License");
2076 * you may not use this file except in compliance with the License.
2077 * You may obtain a copy of the License at
2078 *
2079 *   http://www.apache.org/licenses/LICENSE-2.0
2080 *
2081 * Unless required by applicable law or agreed to in writing, software
2082 * distributed under the License is distributed on an "AS IS" BASIS,
2083 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2084 * See the License for the specific language governing permissions and
2085 * limitations under the License.
2086 */class fn{static emptySet(t){return new fn(t.comparator)}constructor(t){this.comparator=t?(e,n)=>t(e,n)||k.comparator(e.key,n.key):(e,n)=>k.comparator(e.key,n.key),this.keyedMap=Kr(),this.sortedSet=new ot(this.comparator)}has(t){return this.keyedMap.get(t)!=null}get(t){return this.keyedMap.get(t)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(t){const e=this.keyedMap.get(t);return e?this.sortedSet.indexOf(e):-1}get size(){return this.sortedSet.size}forEach(t){this.sortedSet.inorderTraversal((e,n)=>(t(e),!1))}add(t){const e=this.delete(t.key);return e.copy(e.keyedMap.insert(t.key,t),e.sortedSet.insert(t,null))}delete(t){const e=this.get(t);return e?this.copy(this.keyedMap.remove(t),this.sortedSet.remove(e)):this}isEqual(t){if(!(t instanceof fn)||this.size!==t.size)return!1;const e=this.sortedSet.getIterator(),n=t.sortedSet.getIterator();for(;e.hasNext();){const s=e.getNext().key,i=n.getNext().key;if(!s.isEqual(i))return!1}return!0}toString(){const t=[];return this.forEach(e=>{t.push(e.toString())}),t.length===0?"DocumentSet ()":`DocumentSet (
2087  `+t.join(`  
2088`)+`
2089)`}copy(t,e){const n=new fn;return n.comparator=this.comparator,n.keyedMap=t,n.sortedSet=e,n}}/**
2090 * @license
2091 * Copyright 2017 Google LLC
2092 *
2093 * Licensed under the Apache License, Version 2.0 (the "License");
2094 * you may not use this file except in compliance with the License.
2095 * You may obtain a copy of the License at
2096 *
2097 *   http://www.apache.org/licenses/LICENSE-2.0
2098 *
2099 * Unless required by applicable law or agreed to in writing, software
2100 * distributed under the License is distributed on an "AS IS" BASIS,
2101 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2102 * See the License for the specific language governing permissions and
2103 * limitations under the License.
2104 */class th{constructor(){this.ga=new ot(k.comparator)}track(t){const e=t.doc.key,n=this.ga.get(e);n?t.type!==0&&n.type===3?this.ga=this.ga.insert(e,t):t.type===3&&n.type!==1?this.ga=this.ga.insert(e,{type:n.type,doc:t.doc}):t.type===2&&n.type===2?this.ga=this.ga.insert(e,{type:2,doc:t.doc}):t.type===2&&n.type===0?this.ga=this.ga.insert(e,{type:0,doc:t.doc}):t.type===1&&n.type===0?this.ga=this.ga.remove(e):t.type===1&&n.type===2?this.ga=this.ga.insert(e,{type:1,doc:n.doc}):t.type===0&&n.type===1?this.ga=this.ga.insert(e,{type:2,doc:t.doc}):F(63341,{Rt:t,pa:n}):this.ga=this.ga.insert(e,t)}ya(){const t=[];return this.ga.inorderTraversal((e,n)=>{t.push(n)}),t}}class wn{constructor(t,e,n,s,i,o,u,c,h){this.query=t,this.docs=e,this.oldDocs=n,this.docChanges=s,this.mutatedKeys=i,this.fromCache=o,this.syncStateChanged=u,this.excludesMetadataChanges=c,this.hasCachedResults=h}static fromInitialDocuments(t,e,n,s,i){const o=[];return e.forEach(u=>{o.push({type:0,doc:u})}),new wn(t,e,fn.emptySet(e),o,n,s,!0,!1,i)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(t){if(!(this.fromCache===t.fromCache&&this.hasCachedResults===t.hasCachedResults&&this.syncStateChanged===t.syncStateChanged&&this.mutatedKeys.isEqual(t.mutatedKeys)&&vs(this.query,t.query)&&this.docs.isEqual(t.docs)&&this.oldDocs.isEqual(t.oldDocs)))return!1;const e=this.docChanges,n=t.docChanges;if(e.length!==n.length)return!1;for(let s=0;s<e.length;s++)if(e[s].type!==n[s].type||!e[s].doc.isEqual(n[s].doc))return!1;return!0}}/**
2105 * @license
2106 * Copyright 2017 Google LLC
2107 *
2108 * Licensed under the Apache License, Version 2.0 (the "License");
2109 * you may not use this file except in compliance with the License.
2110 * You may obtain a copy of the License at
2111 *
2112 *   http://www.apache.org/licenses/LICENSE-2.0
2113 *
2114 * Unless required by applicable law or agreed to in writing, software
2115 * distributed under the License is distributed on an "AS IS" BASIS,
2116 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2117 * See the License for the specific language governing permissions and
2118 * limitations under the License.
2119 */class EI{constructor(){this.wa=void 0,this.Sa=[]}ba(){return this.Sa.some(t=>t.Da())}}class TI{constructor(){this.queries=eh(),this.onlineState="Unknown",this.Ca=new Set}terminate(){(function(e,n){const s=M(e),i=s.queries;s.queries=eh(),i.forEach((o,u)=>{for(const c of u.Sa)c.onError(n)})})(this,new V(R.ABORTED,"Firestore shutting down"))}}function eh(){return new de(r=>Vd(r),vs)}async function cu(r,t){const e=M(r);let n=3;const s=t.query;let i=e.queries.get(s);i?!i.ba()&&t.Da()&&(n=2):(i=new EI,n=t.Da()?0:1);try{switch(n){case 0:i.wa=await e.onListen(s,!0);break;case 1:i.wa=await e.onListen(s,!1);break;case 2:await e.onFirstRemoteStoreListen(s)}}catch(o){const u=Ir(o,`Initialization of query '${Ln(t.query)}' failed`);return void t.onError(u)}e.queries.set(s,i),i.Sa.push(t),t.va(e.onlineState),i.wa&&t.Fa(i.wa)&&hu(e)}async function lu(r,t){const e=M(r),n=t.query;let s=3;const i=e.queries.get(n);if(i){const o=i.Sa.indexOf(t);o>=0&&(i.Sa.splice(o,1),i.Sa.length===0?s=t.Da()?0:1:!i.ba()&&t.Da()&&(s=2))}switch(s){case 0:return e.queries.delete(n),e.onUnlisten(n,!0);case 1:return e.queries.delete(n),e.onUnlisten(n,!1);case 2:return e.onLastRemoteStoreUnlisten(n);default:return}}function wI(r,t){const e=M(r);let n=!1;for(const s of t){const i=s.query,o=e.queries.get(i);if(o){for(const u of o.Sa)u.Fa(s)&&(n=!0);o.wa=s}}n&&hu(e)}function AI(r,t,e){const n=M(r),s=n.queries.get(t);if(s)for(const i of s.Sa)i.onError(e);n.queries.delete(t)}function hu(r){r.Ca.forEach(t=>{t.next()})}var Aa,nh;(nh=Aa||(Aa={})).Ma="default",nh.Cache="cache";class du{constructor(t,e,n){this.query=t,this.xa=e,this.Oa=!1,this.Na=null,this.onlineState="Unknown",this.options=n||{}}Fa(t){if(!this.options.includeMetadataChanges){const n=[];for(const s of t.docChanges)s.type!==3&&n.push(s);t=new wn(t.query,t.docs,t.oldDocs,n,t.mutatedKeys,t.fromCache,t.syncStateChanged,!0,t.hasCachedResults)}let e=!1;return this.Oa?this.Ba(t)&&(this.xa.next(t),e=!0):this.La(t,this.onlineState)&&(this.ka(t),e=!0),this.Na=t,e}onError(t){this.xa.error(t)}va(t){this.onlineState=t;let e=!1;return this.Na&&!this.Oa&&this.La(this.Na,t)&&(this.ka(this.Na),e=!0),e}La(t,e){if(!t.fromCache||!this.Da())return!0;const n=e!=="Offline";return(!this.options.qa||!n)&&(!t.docs.isEmpty()||t.hasCachedResults||e==="Offline")}Ba(t){if(t.docChanges.length>0)return!0;const e=this.Na&&this.Na.hasPendingWrites!==t.hasPendingWrites;return!(!t.syncStateChanged&&!e)&&this.options.includeMetadataChanges===!0}ka(t){t=wn.fromInitialDocuments(t.query,t.docs,t.mutatedKeys,t.fromCache,t.hasCachedResults),this.Oa=!0,this.xa.next(t)}Da(){return this.options.source!==Aa.Cache}}/**
2120 * @license
2121 * Copyright 2020 Google LLC
2122 *
2123 * Licensed under the Apache License, Version 2.0 (the "License");
2124 * you may not use this file except in compliance with the License.
2125 * You may obtain a copy of the License at
2126 *
2127 *   http://www.apache.org/licenses/LICENSE-2.0
2128 *
2129 * Unless required by applicable law or agreed to in writing, software
2130 * distributed under the License is distributed on an "AS IS" BASIS,
2131 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2132 * See the License for the specific language governing permissions and
2133 * limitations under the License.
2134 */class qf{constructor(t,e){this.Qa=t,this.byteLength=e}$a(){return"metadata"in this.Qa}}/**
2135 * @license
2136 * Copyright 2020 Google LLC
2137 *
2138 * Licensed under the Apache License, Version 2.0 (the "License");
2139 * you may not use this file except in compliance with the License.
2140 * You may obtain a copy of the License at
2141 *
2142 *   http://www.apache.org/licenses/LICENSE-2.0
2143 *
2144 * Unless required by applicable law or agreed to in writing, softw
2144are
2145 * distributed under the License is distributed on an "AS IS" BASIS,
2146 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2147 * See the License for the specific language governing permissions and
2148 * limitations under the License.
2149 */class rh{constructor(t){this.serializer=t}$s(t){return se(this.serializer,t)}Us(t){return t.metadata.exists?Ki(this.serializer,t.document,!1):ut.newNoDocument(this.$s(t.metadata.name),this.Ks(t.metadata.readTime))}Ks(t){return pt(t)}}class fu{constructor(t,e){this.Ua=t,this.serializer=e,this.Ka=[],this.Wa=[],this.collectionGroups=new Set,this.progress=jf(t)}get queries(){return this.Ka}get documents(){return this.Wa}Ga(t){this.progress.bytesLoaded+=t.byteLength;let e=this.progress.documentsLoaded;if(t.Qa.namedQuery)this.Ka.push(t.Qa.namedQuery);else if(t.Qa.documentMetadata){this.Wa.push({metadata:t.Qa.documentMetadata}),t.Qa.documentMetadata.exists||++e;const n=K.fromString(t.Qa.documentMetadata.name);this.collectionGroups.add(n.get(n.length-2))}else t.Qa.document&&(this.Wa[this.Wa.length-1].document=t.Qa.document,++e);return e!==this.progress.documentsLoaded?(this.progress.documentsLoaded=e,{...this.progress}):null}za(t){const e=new Map,n=new rh(this.serializer);for(const s of t)if(s.metadata.queries){const i=n.$s(s.metadata.name);for(const o of s.metadata.queries){const u=(e.get(o)||G()).add(i);e.set(o,u)}}return e}async ja(t){const e=await Xy(t,new rh(this.serializer),this.Wa,this.Ua.id),n=this.za(this.documents);for(const s of this.Ka)await Yy(t,s,n.get(s.name));return this.progress.taskState="Success",{progress:this.progress,Ja:this.collectionGroups,Ha:e}}}function jf(r){return{taskState:"Running",documentsLoaded:0,bytesLoaded:0,totalDocuments:r.totalDocuments,totalBytes:r.totalBytes}}/**
2150 * @license
2151 * Copyright 2017 Google LLC
2152 *
2153 * Licensed under the Apache License, Version 2.0 (the "License");
2154 * you may not use this file except in compliance with the License.
2155 * You may obtain a copy of the License at
2156 *
2157 *   http://www.apache.org/licenses/LICENSE-2.0
2158 *
2159 * Unless required by applicable law or agreed to in writing, software
2160 * distributed under the License is distributed on an "AS IS" BASIS,
2161 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2162 * See the License for the specific language governing permissions and
2163 * limitations under the License.
2164 */class zf{constructor(t){this.key=t}}class Gf{constructor(t){this.key=t}}class $f{constructor(t,e){this.query=t,this.Ya=e,this.Za=null,this.hasCachedResults=!1,this.current=!1,this.Xa=G(),this.mutatedKeys=G(),this.eu=Dd(t),this.tu=new fn(this.eu)}get nu(){return this.Ya}ru(t,e){const n=e?e.iu:new th,s=e?e.tu:this.tu;let i=e?e.mutatedKeys:this.mutatedKeys,o=s,u=!1;const c=this.query.limitType==="F"&&s.size===this.query.limit?s.last():null,h=this.query.limitType==="L"&&s.size===this.query.limit?s.first():null;if(t.inorderTraversal((f,m)=>{const p=s.get(f),v=bs(this.query,m)?m:null,C=!!p&&this.mutatedKeys.has(p.key),D=!!v&&(v.hasLocalMutations||this.mutatedKeys.has(v.key)&&v.hasCommittedMutations);let x=!1;p&&v?p.data.isEqual(v.data)?C!==D&&(n.track({type:3,doc:v}),x=!0):this.su(p,v)||(n.track({type:2,doc:v}),x=!0,(c&&this.eu(v,c)>0||h&&this.eu(v,h)<0)&&(u=!0)):!p&&v?(n.track({type:0,doc:v}),x=!0):p&&!v&&(n.track({type:1,doc:p}),x=!0,(c||h)&&(u=!0)),x&&(v?(o=o.add(v),i=D?i.add(f):i.delete(f)):(o=o.delete(f),i=i.delete(f)))}),this.query.limit!==null)for(;o.size>this.query.limit;){const f=this.query.limitType==="F"?o.last():o.first();o=o.delete(f.key),i=i.delete(f.key),n.track({type:1,doc:f})}return{tu:o,iu:n,Cs:u,mutatedKeys:i}}su(t,e){return t.hasLocalMutations&&e.hasCommittedMutations&&!e.hasLocalMutations}applyChanges(t,e,n,s){const i=this.tu;this.tu=t.tu,this.mutatedKeys=t.mutatedKeys;const o=t.iu.ya();o.sort((f,m)=>function(v,C){const D=x=>{switch(x){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return F(20277,{Rt:x})}};return D(v)-D(C)}(f.type,m.type)||this.eu(f.doc,m.doc)),this.ou(n),s=s??!1;const u=e&&!s?this._u():[],c=this.Xa.size===0&&this.current&&!s?1:0,h=c!==this.Za;return this.Za=c,o.length!==0||h?{snapshot:new wn(this.query,t.tu,i,o,t.mutatedKeys,c===0,h,!1,!!n&&n.resumeToken.approximateByteSize()>
21640),au:u}:{au:u}}va(t){return this.current&&t==="Offline"?(this.current=!1,this.applyChanges({tu:this.tu,iu:new th,mutatedKeys:this.mutatedKeys,Cs:!1},!1)):{au:[]}}uu(t){return!this.Ya.has(t)&&!!this.tu.has(t)&&!this.tu.get(t).hasLocalMutations}ou(t){t&&(t.addedDocuments.forEach(e=>this.Ya=this.Ya.add(e)),t.modifiedDocuments.forEach(e=>{}),t.removedDocuments.forEach(e=>this.Ya=this.Ya.delete(e)),this.current=t.current)}_u(){if(!this.current)return[];const t=this.Xa;this.Xa=G(),this.tu.forEach(n=>{this.uu(n.key)&&(this.Xa=this.Xa.add(n.key))});const e=[];return t.forEach(n=>{this.Xa.has(n)||e.push(new Gf(n))}),this.Xa.forEach(n=>{t.has(n)||e.push(new zf(n))}),e}cu(t){this.Ya=t.Qs,this.Xa=G();const e=this.ru(t.documents);return this.applyChanges(e,!0)}lu(){return wn.fromInitialDocuments(this.query,this.tu,this.mutatedKeys,this.Za===0,this.hasCachedResults)}}const $e="SyncEngine";class vI{constructor(t,e,n){this.query=t,this.targetId=e,this.view=n}}class bI{constructor(t){this.key=t,this.hu=!1}}class RI{constructor(t,e,n,s,i,o){this.localStore=t,this.remoteStore=e,this.eventManager=n,this.sharedClientState=s,this.currentUser=i,this.maxConcurrentLimboResolutions=o,this.Pu={},this.Tu=new de(u=>Vd(u),vs),this.Iu=new Map,this.Eu=new Set,this.du=new ot(k.comparator),this.Au=new Map,this.Ru=new Xa,this.Vu={}
2164,this.mu=new Map,this.fu=En.cr(),this.onlineState="Unknown",this.gu=void 0}get isPrimaryClient(){return this.gu===!0}}async function SI(r,t,e=!0){const n=Zi(r);let s;const i=n.Tu.get(t);return i?(n.sharedClientState.addLocalQueryTarget(i.targetId),s=i.view.lu()):s=await Kf(n,t,e,!0),s}async function PI(r,t){const e=Zi(r);await Kf(e,t,!0,!1)}async function Kf(r,t,e,n){const s=await sr(r.localStore,Nt(t)),i=s.targetId,o=r.sharedClientState.addLocalQueryTarget(i,e);let u;return n&&(u=await mu(r,t,i,o==="current",s.resumeToken)),r.isPrimaryClient&&e&&Yi(r.remoteStore,s),u}async function mu(r,t,e,n,s){r.pu=(m,p,v)=>async function(D,x,B,j){let U=x.view.ru(B);U.Cs&&(U=await Pi(D.localStore,x.query,!1).then(({documents:E})=>x.view.ru(E,U)));const Y=j&&j.targetChanges.get(x.targetId),Z=j&&j.targetMismatches.get(x.targetId)!=null,H=x.view.applyChanges(U,D.isPrimaryClient,Y,Z);return va(D,x.targetId,H.au),H.snapshot}(r,m,p,v);const i=await Pi(r.localStore,t,!0),o=new $f(t,i.Qs),u=o.ru(i.documents),c=Ps.createSynthesizedTargetChangeForCurrentChange(e,n&&r.onlineState!=="Offline",s),h=o.applyChanges(u,r.isPrimaryClient,c);va(r,e,h.au);const f=new vI(t,e,o);return r.Tu.set(t,f),r.Iu.has(e)?r.Iu.get(e).push(t):r.Iu.set(e,[t]),h.snapshot}async function VI(r,t,e){const n=M(r),s=n.Tu.get(t),i=n.Iu.get(s.targetId);if(i.length>1)return n.Iu.set(s.targetId,i.filter(o=>!vs(o,t))),void n.Tu.delete(t);n.isPrimaryClient?(n.sharedClientState.removeLocalQueryTarget(s.targetId),n.sharedClientState.isActiveQueryTarget(s.targetId)||await ir(n.localStore,s.targetId,!1).then(()=>{n.sharedClientState.clearQueryState(s.targetId),e&&or(n.remoteStore,s.targetId),ar(n,s.targetId)}).catch(qe)):(ar(n,s.targetId),await ir(n.localStore,s.targetId,!0))}async function CI(r,t){const e=M(r),n=e.Tu.get(t),s=e.Iu.get(n.targetId);e.isPrimaryClient&&s.length===1&&(e.sharedClientState.removeLocalQueryTarget(n.targetId),or(e.remoteStore,n.targetId))}async function DI(r,t,e){const n=yu(r);try{const s=await function(o,u){const c=M(o),h=tt.now(),f=u.reduce((v,C)=>v.add(C.key),G());let m,p;return c.persistence.runTransaction("Locally write mutations","readwrite",v=>{let C=Ut(),D=G();return c.Ns.getEntries(v,f).next(x=>{C=x,C.forEach((B,j)=>{j.isValidDocument()||(D=D.add(B))})}).next(()=>c.localDocuments.getOverlayedDocuments(v,C)).next(x=>{m=x;const B=[];for(const j of u){const U=ny(j,m.get(j.key).overlayedDocument);U!=null&&B.push(new fe(j.key,U,yd(U.value.mapValue),ht.exists(!0)))}return c.mutationQueue.addMutationBatch(v,h,B,u)}).next(x=>{p=x;const B=x.applyToLocalDocumentSet(m,D);return c.documentOverlayCache.saveOverlays(v,x.batchId,B)})}).then(()=>({batchId:p.batchId,changes:Nd(m)}))}(n.localStore,t);n.sharedClientState.addPendingMutation(s.batchId),function(o,u,c){let h=o.Vu[o.currentUser.toKey()];h||(h=new ot(z)),h=h.insert(u,c),o.Vu[o.currentUser.toKey()]=h}(n,s.batchId,e),await me(n,s.changes),await _r(n.remoteStore)}catch(s){const i=Ir(s,"Failed to persist write");e.reject(i)}}async function Qf(r,t){const e=M(r);try{const n=await Hy(e.localStore,t);
2164t.targetChanges.forEach((s,i)=>{const o=e.Au.get(i);o&&(L(s.addedDocuments.size+s.modifiedDocuments.size+s.removedDocuments.size<=1,22616),s.addedDocuments.size>0?o.hu=!0:s.modifiedDocuments.size>0?L(o.hu,14607):s.removedDocuments.size>0&&(L(o.hu,42227),o.hu=!1))}),await me(e,n,t)}catch(n){await qe(n)}}function sh(r,t,e){const n=M(r);if(n.isPrimaryClient&&e===0||!n.isPrimaryClient&&e===1){const s=[];n.Tu.forEach((i,o)=>{const u=o.view.va(t);u.snapshot&&s.push(u.snapshot)}),function(o,u){const c=M(o);c.onlineState=u;let h=!1;c.queries.forEach((f,m)=>{for(const p of m.Sa)p.va(u)&&(h=!0)}),h&&hu(c)}(n.eventManager,t),s.length&&n.Pu.H_(s),n.onlineState=t,n.isPrimaryClient&&n.sharedClientState.setOnlineState(t)}}async function xI(r,t,e){const n=M(r);n.sharedClientState.updateQueryState(t,"rejected",e);const s=n.Au.get(t),i=s&&s.key;if(i){let o=new ot(k.comparator);o=o.insert(i,ut.newNoDocument(i,q.min()));const u=G().add(i),c=new Ss(q.min(),new Map,new ot(z),o,u);await Qf(n,c),n.du=n.du.remove(i),n.Au.delete(t),_u(n)}else await ir(n.localStore,t,!1).then(()=>ar(n,t,e)).catch(qe)}async function NI(r,t){const e=M(r),n=t.batch.batchId;try{const s=await Wy(e.localStore,t);pu(e,n,null),gu(e,n),e.sharedClientState.updateMutationState(n,"acknowledged"),await me(e,s)}catch(s){await qe(s)}}async function kI(r,t,e){const n=M(r);try{const s=await function(o,u){const c=M(o);return c.persistence.runTransaction("Reject batch","readwrite-primary",h=>{let f;return c.mutationQueue.lookupMutationBatch(h,u).next(m=>
2164(L(m!==null,37113),f=m.keys(),c.mutationQueue.removeMutationBatch(h,m))).next(()=>c.mutationQueue.performConsistencyCheck(h)).next(()=>c.documentOverlayCache.removeOverlaysForBatchId(h,f,u)).next(()=>c.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(h,f)).next(()=>c.localDocuments.getDocuments(h,f))})}(n.localStore,t);pu(n,t,e),gu(n,t),n.sharedClientState.updateMutationState(t,"rejected",e),await me(n,s)}catch(s){await qe(s)}}async function MI(r,t){const e=M(r);Ge(e.remoteStore)||N($e,"The network is disabled. The task returned by 'awaitPendingWrites()' will not complete until the network is enabled.");try{const n=await function(o){const u=M(o);return u.persistence.runTransaction("Get highest unacknowledged batch id","readonly",c=>u.mutationQueue.getHighestUnacknowledgedBatchId(c))}(e.localStore);if(n===De)return void t.resolve();const s=e.mu.get(n)||[];s.push(t),e.mu.set(n,s)}catch(n){const s=Ir(n,"Initialization of waitForPendingWrites() operation failed");t.reject(s)}}function gu(r,t){(r.mu.get(t)||[]).forEach(e=>{e.resolve()}),r.mu.delete(t)}function pu(r,t,e){const n=M(r);let s=n.Vu[n.currentUser.toKey()];if(s){const i=s.get(t);i&&(e?i.reject(e):i.resolve(),s=s.remove(t)),n.Vu[n.currentUser.toKey()]=s}}function ar(r,t,e=null){r.sharedClientState.removeLocalQueryTarget(t);for(const n of r.Iu.get(t))r.Tu.delete(n),e&&r.Pu.yu(n,e);r.Iu.delete(t),r.isPrimaryClient&&r.Ru.jr(t).forEach(n=>{r.Ru.containsKey(n)||Wf(r,n)})}function Wf(r,t){r.Eu.delete(t.path.canonicalString());const e=r.du.get(t);e!==null&&(or(r.remoteStore,e),r.du=r.du.remove(t),r.Au.delete(e),_u(r))}function va(r,t,e){for(const n of e)n instanceof zf?(r.Ru.addReference(n.key,t),OI(r,n)):n instanceof Gf?(N($e,"Document no longer in limbo: "+n.key),r.Ru.removeReference(n.key,t),r.Ru.containsKey(n.key)||Wf(r,n.key)):F(19791,{wu:n})}function OI(r,t){const e=t.key,n=e.path.canonicalString();r.du.get(e)||r.Eu.has(n)||(N($e,"New document in limbo: "+e),r.Eu.add(n),_u(r))}function _u(r){for(;r.Eu.size>0&&r.du.size<r.maxConcurrentLimboResolutions;){const t=r.Eu.values().next().value;r.Eu.delete(t);const e=new k(K.fromString(t)),n=r.fu.next();r.Au.set(n,new bI(e)),r.du=r.du.insert(e,n),Yi(r.remoteStore,new oe(Nt(fr(e.path)),n,"TargetPurposeLimboResolution",Lt.ce))}}async function me(r,t,e){const n=M(r),s=[],i=[],o=[];n.Tu.isEmpty()||(n.Tu.forEach((u,c)=>{o.push(n.pu(c,t,e).then(h=>{if((h||e)&&n.isPrimaryClient){const f=h?!h.fromCache:e?.targetChanges.get(c.targetId)?.current;n.sharedClientState.updateQueryState(c.targetId,f?"current":"not-current")}if(h){s.push(h);const f=eu.As(c.targetId,h);i.push(f)}}))}),await Promise.all(o),n.Pu.H_(s),await async function(c,h){const f=M(c);try{await f.persistence.runTransaction("notifyLocalViewChanges","readwrite",m=>A.forEach(h,p=>A.forEach(p.Es,v=>f.persistence.referenceDelegate.addReference(m,p.targetId,v)).next(()=>A.forEach(p.ds,v=>f.persistence.referenceDelegate.removeReference(m,p.targetId,v)))))}catch(m){if(!je(m))throw m;N(nu,"Failed to update sequence numbers: "+m)}for(const m of h){const p=m.targetId;if(!m.fromCache){const v=f.Ms.get(p),C=v.snapshotVersion,D=v.withLastLimboFreeSnapshotVersion(C);f.Ms=f.Ms.insert(p,D)}}}(n.localStore,i))}async function FI(r,t){const e=M(r);if(!e.currentUser.isEqual(t)){N($e,"User change. New user:",t.toKey());const n=await vf(e.localStore,t);e.currentUser=t,function(i,o){i.mu.forEach(u=>{u.forEach(c=>{c.reject(new V(R.CANCELLED,o))})}),i.mu.clear()}(e,"'waitForPendingWrites' promise is rejected due to a user change."),e.sharedClientState.handleUserChange(t,n.removedBatchIds,n.addedBatchIds),await me(e,n.Ls)}}function LI(r,t){const e=M(r),n=e.Au.get(t);if(n&&n.hu)return G().add(n.key);{let s=G();const i=e.Iu.get(t);if(!i)return s;for(const o of i){const u=e.Tu.get(o);s=s.unionWith(u.view.nu)}return s}}async function BI(r,t){const e=M(r),n=await Pi(e.localStore,t.query,!0),s=t.view.cu(n);return e.isPrimaryClient&&va(e,t.targetId,s.au),s}async function UI(r,t){const e=M(r);return Pf(e.localStore,t).then(n=>me(e,n))}async function qI(r,t,e,n){const s=M(r),i=await function(u,c){const h=M(u),f=M(h.mutation
2164Queue);return h.persistence.runTransaction("Lookup mutation documents","readonly",m=>f.er(m,c).next(p=>p?h.localDocuments.getDocuments(m,p):A.resolve(null)))}(s.localStore,t);i!==null?(e==="pending"?await _r(s.remoteStore):e==="acknowledged"||e==="rejected"?(pu(s,t,n||null),gu(s,t),function(u,c){M(M(u).mutationQueue).ir(c)}(s.localStore,t)):F(6720,"Unknown batchState",{Su:e}),await me(s,i)):N($e,"Cannot apply mutation batch with id: "+t)}async function jI(r,t){const e=M(r);if(Zi(e),yu(e),t===!0&&e.gu!==!0){const n=e.sharedClientState.getAllActiveQueryTargets(),s=await ih(e,n.toArray());e.gu=!0,await wa(e.remoteStore,!0);for(const i of s)Yi(e.remoteStore,i)}else if(t===!1&&e.gu!==!1){const n=[];let s=Promise.resolve();e.Iu.forEach((i,o)=>{e.sharedClientState.isLocalQueryTarget(o)?n.push(o):s=s.then(()=>(ar(e,o),ir(e.localStore,o,!0))),or(e.remoteStore,o)}),await s,await ih(e,n),function(o){const u=M(o);u.Au.forEach((c,h)=>{or(u.remoteStore,h)}),u.Ru.Jr(),u.Au=new Map,u.du=new ot(k.comparator)}(e),e.gu=!1,await wa(e.remoteStore,!1)}}async function ih(r,t,e){const n=M(r),s=[],i=[];for(const o of t){let u;const c=n.Iu.get(o);if(c&&c.length!==0){u=await sr(n.localStore,Nt(c[0]));for(const h of c){const f=n.Tu.get(h),m=await BI(n,f);m.snapshot&&i.push(m.snapshot)}}else{const h=await Sf(n.localStore,o);u=await sr(n.localStore,h),await mu(n,Hf(h),o,!1,u.resumeToken)}s.push(u)}return n.Pu.H_(i),s}function Hf(r){return Rd(r.path,r.collectionGroup,r.orderBy,r.filters,r.limit,"F",r.startAt,r.endAt)}function zI(r){return function(e){return M(M(e).persistence).Ts()}(M(r).localStore)}async function GI(r,t,e,n){const s=M(r);if(s.gu)return void N($e,"Ignoring unexpected query state notification.");const i=s.Iu.get(t);if(i&&i.length>0)switch(e){case"current":case"not-current":{const o=await Pf(s.localStore,Cd(i[0])),u=Ss.createSynthesizedRemoteEventForCurrentChange(t,e==="current",ft.EMPTY_BYTE_STRING);await me(s,o,u);break}case"rejected":await ir(s.localStore,t,!0),ar(s,t,n);break;default:F(64155,e)}}async function $I(r,t,e){const n=Zi(r);if(n.gu){for(const s of t){if(n.Iu.has(s)&&n.sharedClientState.isActiveQueryTarget(s)){N($e,"Adding an already active target "+s);continue}const i=await Sf(n.localStore,s),o=await sr(n.localStore,i);await mu(n,Hf(i),o.targetId,!1,o.resumeToken),Yi(n.remoteStore,o)}for(const s of e)n.Iu.has(s)&&await ir(n.localStore,s,!1).then(()=>{or(n.remoteStore,s),ar(n,s)}).catch(qe)}}function Zi(r){const t=M(r);return t.remoteStore.remoteSyncer.applyRemoteEvent=Qf.bind(null,t),t.remoteStore.remoteSyncer.getRemoteKeysForTarget=LI.bind(null,t),t.remoteStore.remoteSyncer.rejectListen=xI.bind(null,t),t.Pu.H_=wI.bind(null,t.eventManager),t.Pu.yu=AI.bind(null,t.eventManager),t}function yu(r){const t=M(r);return t.remoteStore.remoteSyncer.applySuccessfulWrite=NI.bind(null,t),t.remoteStore.remoteSyncer.rejectFailedWrite=kI.bind(null,t),t}function KI(r,t,e){const n=M(r);(async function(i,o,u){try{const c=await o.getMetadata();if(await function(v,C){const D=M(v),x=pt(C.createTime);return D.persistence.runTransaction("hasNewerBundle","readonly",B=>D.Ii.getBundleMetadata(B,C.id)).then(B=>!!B&&B.createTime.compareTo(x)>=0)}(i.localStore,c))return await o.close(),u._completeWith(function(v){return{taskState:"Success",documentsLoaded:v.totalDocuments,bytesLoaded:v.totalBytes,totalDocuments:v.totalDocuments,totalBytes:v.totalBytes}}(c)),Promise.resolve(new Set);u._updateProgress(jf(c));const h=new fu(c,o.serializer);let f=await o.bu();for(;f;){const p=await h.Ga(f);p&&u._updateProgress(p),f=await o.bu()}const m=await h.ja(i.localStore);return await me(i,m.Ha,void 0),await function(v,C){const D=M(v);return D.persistence.runTransaction("Save bundle","readwrite",x=>D.Ii.saveBundleMetadata(x,C))}(i.localStore,c),u._completeWith(m.progress),Promise.resolve(m.Ja)}catch(c){return $t($e,`Loading bundle failed with ${c}`),u._failWith(c),Promise.resolve(new Set)}})(n,t,e).then(s=>{n.sharedClientState.notifyBundleLoaded(s)})}class ur{constructor(){this.kind="memory",this.synchronizeTabs=!1}async initialize(t){this.serializer=vn(t.databaseInfo.databaseId),this.sharedCl
2164ientState=this.Du(t),this.persistence=this.Cu(t),await this.persistence.start(),this.localStore=this.vu(t),this.gcScheduler=this.Fu(t,this.localStore),this.indexBackfillerScheduler=this.Mu(t,this.localStore)}Fu(t,e){return null}Mu(t,e){return null}vu(t){return Af(this.persistence,new wf,t.initialUser,this.serializer)}Cu(t){return new Ya(Xi.mi,this.serializer)}Du(t){return new Nf}async terminate(){this.gcScheduler?.stop(),this.indexBackfillerScheduler?.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}}ur.provider={build:()=>new ur};class Iu extends ur{constructor(t){super(),this.cacheSizeBytes=t}Fu(t,e){L(this.persistence.referenceDelegate instanceof Si,46915);const n=this.persistence.referenceDelegate.garbageCollector;return new pf(n,t.asyncQueue,e)}Cu(t){const e=this.cacheSizeBytes!==void 0?Dt.withCacheSize(this.cacheSizeBytes):Dt.DEFAULT;return new Ya(n=>Si.mi(n,e),this.serializer)}}class Eu extends ur{constructor(t,e,n){super(),this.xu=t,this.cacheSizeBytes=e,this.forceOwnership=n,this.kind="persistent",this.synchronizeTabs=!1}async initialize(t){await super.initialize(t),await this.xu.initialize(this,t),await yu(this.xu.syncEngine),await _r(this.xu.remoteStore),await this.persistence.Ji(()=>(this.gcScheduler&&!this.gcScheduler.started&&this.gcScheduler.start(),this.indexBackfillerScheduler&&!this.indexBackfillerScheduler.started&&this.indexBackfillerScheduler.start(),Promise.resolve()))}vu(t){return Af(this.persistence,new wf,t.initialUser,this.serializer)}Fu(t,e){const n=this.persistence.referenceDelegate.garbageCollector;return new pf(n,t.asyncQueue,e)}Mu(t,e){const n=new o_(e,this.persistence);return new i_(t.asyncQueue,n)}Cu(t){const e=tu(t.databaseInfo.databaseId,t.databaseInfo.persistenceKey),n=this.cacheSizeBytes!==void 0?Dt.withCacheSize(this.cacheSizeBytes):Dt.DEFAULT;return new Za(this.synchronizeTabs,e,t.clientId,n,t.asyncQueue,kf(),fi(),this.serializer,this.sharedClientState,!!this.forceOwnership)}Du(t){return new Nf}}class Jf extends Eu{constructor(t,e){super(t,e,!1),this.xu=t,this.cacheSizeBytes=e,this.synchronizeTabs=!0}async initialize(t){await super.initialize(t);const e=this.xu.syncEngine;this.sharedClientState instanceof Go&&(this.sharedClientState.syncEngine={Co:qI.bind(null,e),vo:GI.bind(null,e),Fo:$I.bind(null,e),Ts:zI.bind(null,e),Do:UI.bind(null,e)},await this.sharedClientState.start()),await this.persistence.Ji(async n=>{await jI(this.xu.syncEngine,n),this.gcScheduler&&(n&&!this.gcScheduler.started?this.gcScheduler.start():n||this.gcScheduler.stop()),this.indexBackfillerScheduler&&(n&&!this.indexBackfillerScheduler.started?this.indexBackfillerScheduler.start():n||this.indexBackfillerScheduler.stop())})}Du(t){const e=kf();if(!Go.v(e))throw new V(R.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");const n=tu(t.databaseInfo.databaseId,t.databaseInfo.persistenceKey);return new Go(e,t.asyncQueue,n,t.clientId,t.initialUser)}}class Be{async initialize(t,e){this.localStore||(this.localStore=t.localStore,this.sharedClientState=t.sharedClientState,this.datastore=this.createDatastore(e),this.remoteStore=this.createRemoteStore(e),this.eventManager=this.createEventManager(e),this.syncEngine=this.createSyncEngine(e,!t.synchronizeTabs),this.sharedClientState.onlineStateHandler=n=>sh(this.syncEngine,n,1),this.remoteStore.remoteSyncer.handleCredentialChange=FI.bind(null,this.syncEngine),await wa(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(t){return function(){return new TI}()}createDatastore(t){const e=vn(t.databaseInfo.databaseId),n=function(i){return new rI(i)}(t.databaseInfo);return function(i,o,u,c){return new aI(i,o,u,c)}(t.authCredentials,t.appCheckCredentials,n,e)}createRemoteStore(t){return function(n,s,i,o,u){return new cI(n,s,i,o,u)}(this.localStore,this.datastore,t.asyncQueue,e=>sh(this.syncEngine,e,0),function(){return Xl.v()?new Xl:new Zy}())}createSyncEngine(t,e){return function(s,i,o,u,c,h,f){const m=new RI(s,i,o,u,c,h);return f&&(m.gu=!0),m}(this.localStore,this.remoteStore,this.eventManager,this.sharedCl
2164ientState,t.initialUser,t.maxConcurrentLimboResolutions,e)}async terminate(){await async function(e){const n=M(e);N(Tn,"RemoteStore shutting down."),n.Ea.add(5),await pr(n),n.Aa.shutdown(),n.Ra.set("Unknown")}(this.remoteStore),this.datastore?.terminate(),this.eventManager?.terminate()}}Be.provider={build:()=>new Be};function oh(r,t=10240){let e=0;return{async read(){if(e<r.byteLength){const n={value:r.slice(e,e+t),done:!1};return e+=t,n}return{done:!0}},async cancel(){},releaseLock(){},closed:Promise.resolve()}}/**
2165 * @license
2166 * Copyright 2020 Google LLC
2167 *
2168 * Licensed under the Apache License, Version 2.0 (the "License");
2169 * you may not use this file except in compliance with the License.
2170 * You may obtain a copy of the License at
2171 *
2172 *   http://www.apache.org/licenses/LICENSE-2.0
2173 *
2174 * Unless required by applicable law or agreed to in writing, software
2175 * distributed under the License is distributed on an "AS IS" BASIS,
2176 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2177 * See the License for the specific language governing permissions and
2178 * limitations under the License.
2179 *//**
2180 * @license
2181 * Copyright 2017 Google LLC
2182 *
2183 * Licensed under the Apache License, Version 2.0 (the "License");
2184 * you may not use this file except in compliance with the License.
2185 * You may obtain a copy of the License at
2186 *
2187 *   http://www.apache.org/licenses/LICENSE-2.0
2188 *
2189 * Unless required by applicable law or agreed to in writing, software
2190 * distributed under the License is distributed on an "AS IS" BASIS,
2191 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2192 * See the License for the specific language governing permissions and
2193 * limitations under the License.
2194 */class to{constructor(t){this.observer=t,this.muted=!1}next(t){this.muted||this.observer.next&&this.Ou(this.observer.next,t)}error(t){this.muted||(this.observer.error?this.Ou(this.observer.error,t):gt("Uncaught Error in snapshot listener:",t.toString()))}Nu(){this.muted=!0}Ou(t,e){setTimeout(()=>{this.muted||t(e)},0)}}/**
2195 * @license
2196 * Copyright 2020 Google LLC
2197 *
2198 * Licensed under the Apache License, Version 2.0 (the "License");
2199 * you may not use this file except in compliance with the License.
2200 * You may obtain a copy of the License at
2201 *
2202 *   http://www.apache.org/licenses/LICENSE-2.0
2203 *
2204 * Unless required by applicable law or agreed to in writing, software
2205 * distributed under the License is distributed on an "AS IS" BASIS,
2206 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2207 * See the License for the specific language governing permissions and
2208 * limitations under the License.
2209 */class QI{constructor(t,e){this.Bu=t,this.serializer=e,this.metadata=new Rt,this.buffer=new Uint8Array,this.Lu=function(){return new TextDecoder("utf-8")}(),this.ku().then(n=>{n&&n.$a()?this.metadata.resolve(n.Qa.metadata):this.metadata.reject(new Error(`The first element of the bundle is not a metadata, it is
2210             ${JSON.stringify(n?.Qa)}`))},n=>this.metadata.reject(n))}close(){return this.Bu.cancel()}async getMetadata(){return this.metadata.promise}async bu(){return await this.getMetadata(),this.ku()}async ku(){const t=await this.qu();if(t===null)return null;const e=this.Lu.decode(t),n=Number(e);isNaN(n)&&this.Qu(`length string (${e}) is not valid number`);const s=await this.$u(n);return new qf(JSON.parse(s),t.length+n)}Uu(){return this.buffer.findIndex(t=>t===123)}async qu(){for(;this.Uu()<0&&!await this.Ku(););if(this.buffer.length===0)return null;const t=this.Uu();t<0&&this.Qu("Reached the end of bundle when a length string is expected.");const e=this.buffer.slice(0,t);return this.buffer=this.buffer.slice(t),e}async $u(t){for(;this.buffer.length<t;)await this.Ku()&&this.Qu("Reached the end of bundle when more is expected.");const e=this.Lu.decode(this.buffer.slice(0,t));return this.buffer=this.buffer.slice(t),e}Qu(t){throw this.Bu.cancel(),new Error(`Invalid bundle format: ${t}`)}async Ku(){const t=await this.Bu.read();if(!t.done){const e=new Uint8Array(this.buffer.length+t.value.length);e.set(this.buffer),e.set(t.value,this.buffer.length),this.buffer=e}return t.done}}/**
2211 * @license
2212 * Copyright 2025 Google LLC
2213 *
2214 * Licensed under the Apache License, Version 2.0 (the "License");
2215 * you may not use this file except in compliance with the License.
2216 * You may obtain a copy of the License at
2217 *
2218 *   http://www.apache.org/licenses/LICENSE-2.0
2219 *
2220 * Unless required by applicable law or agreed to in writing, software
2221 * distributed under the License is distributed on an "AS IS" BASIS,
2222 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2223 * See the License for the specific language governing permissions and
2224 * limitations under the License.
2225 */class WI{constructor(t,e){this.bundleData=t,this.serializer=e,this.cursor=0,this.elements=[];let n=this.bu();if(!n||!n.$a())throw new Error(`The first element of the bundle is not a metadata object, it is
2226         ${JSON.stringify(n?.Qa)}`);this.metadata=n;do n=this.bu(),n!==null&&this.elements.push(n);while(n!==null)}getMetadata(){return this.metadata}Wu(){return this.elements}bu(){if(this.cursor===this.bundleData.length)return null;const t=this.qu(),e=this.$u(t);return new qf(JSON.parse(e),t)}$u(t){if(this.cursor+t>this.bundleData.length)throw new V(R.INTERNAL,"Reached the end of bundle when more is expected.");return this.bundleData.slice(this.cursor,this.cursor+=t)}qu(){const t=this.cursor;let e=this.cursor;for(;e<this.bundleData.length;){if(this.bundleData[e]==="{"){if(e===t)throw new Error("First character is a bracket and not a number");return this.cursor=e,Number(this.bundleData.slice(t,e))}e++}throw new Error("Reached the end of bundle when more is expected.")}}/**
2227 * @license
2228 * Copyright 2017 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 */class HI{constructor(t){this.datastore=t,this.readVersions=new Map,this.mutations=[],this.committed=!1,this.lastTransactionError=null,this.writtenDocs=new Set}async lookup(t){if(this.ensureCommitNotCalled(),this.mutations.length>0)throw this.lastTransactionError=new V(R.INVALID_ARGUMENT,"Firestore transactions require all reads to be executed before all writes."),this.lastTransactionError;const e=await async function(s,i){const o=M(s),u={documents:i.map(m=>_s(o.serializer,m))},c=await o.Ho("BatchGetDocuments",o.serializer.databaseId,K.emptyPath(),u,i.length),h=new Map;c.forEach(m=>{const p=hy(o.serializer,m);h.set(p.key.toString(),p)});const f=[];return i.forEach(m=>{const p=h.get(m.toString());L(!!p,55234,{key:m}),f.push(p)}),f}(this.datastore,t);return e.forEach(n=>this.recordVersion(n)),e}set(t,e){this.write(e.toMutation(t,this.precondition(t))),this.writtenDocs.add(t.toString())}update(t,e){try{this.write(e.toMutation(t,this.preconditionForUpdate(t)))}catch(n){this.lastTransactionError=n}this.writtenDocs.add(t.toString())}delete(t){this.write(new gr(t,this.precondition(t))),this.writtenDocs.add(t.toString())}async commit(){if(this.ensureCommitNotCalled(),this.lastTransactionError)throw this.lastTransactionError;const t=this.readVersions;this.mutations.forEach(e=>{t.delete(e.key.toString())}),t.forEach((e,n)=>{const s=k.fromPath(n);this.mutations.push(new za(s,this.precondition(s)))}),await async function(n,s){const i=M(n),o={writes:s.map(u=>ys(i.serializer,u))};await i.Go("Commit",i.serializer.databaseId,K.emptyPath(),o)}(this.datastore,this.mutations),this.committed=!0}recordVersion(t){let e;if(t.isFoundDocument())e=t.version;else{if(!t.isNoDocument())throw F(50498,{Gu:t.constructor.name});e=q.min()}const n=this.readVersions.get(t.key.toString());if(n){if(!e.isEqual(n))throw new V(R.ABORTED,"Document version changed between two reads.")}else this.readVersions.set(t.key.toString(),e)}precondition(t){const e=this.readVersions.get(t.toString());return!this.writtenDocs.has(t.toString())&&e?e.isEqual(q.min())?ht.exists(!1):ht.updateTime(e):ht.none()}preconditionForUpdate(t){const e=this.readVersions.get(t.toString());if(!this.writtenDocs.has(t.toString())&&e){if(e.isEqual(q.min()))throw new V(R.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return ht.updateTime(e)}return ht.exists(!0)}write(t){this.ensureCommitNotCalled(),this.mutations.push(t)}ensureCommitNotCalled(){}}/**
2242 * @license
2243 * Copyright 2019 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 */class JI{constructor(t,e,n,s,i){this.asyncQueue=t,this.datastore=e,this.options=n,this.updateFunction=s,this.deferred=i,this.zu=n.maxAttempts,this.M_=new su(this.asyncQueue,"transaction_retry")}ju(){this.zu-=1,this.Ju()}Ju(){this.M_.p_(async()=>{const t=new HI(this.datastore),e=this.Hu(t);e&&e.then(n=>{this.asyncQueue.enqueueAndForget(()=>t.commit().then(()=>{this.deferred.resolve(n)}).catch(s=>{this.Yu(s)}))}).catch(n=>{this.Yu(n)})})}Hu(t){try{const e=this.updateFunction(t);return!Ts(e)&&e.catch&&e.then?e:(this.deferred.reject(Error("Transaction callback must return a Promise")),null)}catch(e){return this.deferred.reject(e),null}}Yu(t){this.zu>0&&this.Zu(t)?(this.zu-=1,this.asyncQueue.enqueueAndForget(()=>(this.Ju(),Promise.resolve()))):this.deferred.reject(t)}Zu(t){if(t?.name==="FirebaseError"){const e=t.code;return e==="aborted"||e==="failed-precondition"||e==="already-exists"||!Gd(e)}return!1}}/**
2257 * @license
2258 * Copyright 2017 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 */const Ue="FirestoreClient";class XI{constructor(t,e,n,s,i){this.authCredentials=t,this.appCheckCredentials=e,this.asyncQueue=n,this.databaseInfo=s,this.user=bt.UNAUTHENTICATED,this.clientId=Mi.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=i,this.authCredentials.start(n,async o=>{N(Ue,"Received user=",o.uid),await this.authCredentialListener(o),this.user=o}),this.appCheckCredentials.start(n,o=>(N(Ue,"Received new app check token=",o),this.appCheckCredentialListener(o,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(t){this.authCredentialListener=t}setAppCheckTokenChangeListener(t){this.appCheckCredentialListener=t}terminate(){this.asyncQueue.enterRestrictedMode();const t=new Rt;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted(async()=>{try{this._onlineComponents&&await this._onlineComponents.terminate(),this._offlineComponents&&await this._offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),t.resolve()}catch(e){const n=Ir(e,"Failed to shutdown persistence");t.reject(n)}}),t.promise}}async function Ko(r,t){r.asyncQueue.verifyOperationInProgress(),N(Ue,"Initializing OfflineComponentProvider");const e=r.configuration;await t.initialize(e);let n=e.initialUser;r.setCredentialChangeListener(async s=>{n.isEqual(s)||(await vf(t.localStore,s),n=s)}),t.persistence.setDatabaseDeletedListener(()=>r.terminate()),r._offlineComponents=t}async function ah(r,t){r.asyncQueue.verifyOperationInProgress();const e=await Tu(r);N(Ue,"Initializing OnlineComponentProvider"),await t.initialize(e,r.configuration),r.setCredentialChangeListener(n=>Zl(t.remoteStore,n)),r.setAppCheckTokenChangeListener((n,s)=>Zl(t.remoteStore,s)),r._onlineComponents=t}async function Tu(r){if(!r._offlineComponents)if(r._uninitializedComponentsProvider){N(Ue,"Using user provided OfflineComponentProvider");try{await Ko(r,r._uninitializedComponentsProvider._offline)}catch(t){const e=t;if(!function(s){return s.name==="FirebaseError"?s.code===R.FAILED_PRECONDITION||s.code===R.UNIMPLEMENT
2271ED:!(typeof DOMException<"u"&&s instanceof DOMException)||s.code===22||s.code===20||s.code===11}(e))throw e;$t("Error using user provided cache. Falling back to memory cache: "+e),await Ko(r,new ur)}}else N(Ue,"Using default OfflineComponentProvider"),await Ko(r,new Iu(void 0));return r._offlineComponents}async function eo(r){return r._onlineComponents||(r._uninitializedComponentsProvider?(N(Ue,"Using user provided OnlineComponentProvider"),await ah(r,r._uninitializedComponentsProvider._online)):(N(Ue,"Using default OnlineComponentProvider"),await ah(r,new Be))),r._onlineComponents}function Xf(r){return Tu(r).then(t=>t.persistence)}function Er(r){return Tu(r).then(t=>t.localStore)}function Yf(r){return eo(r).then(t=>t.remoteStore)}function wu(r){return eo(r).then(t=>t.syncEngine)}function Zf(r){return eo(r).then(t=>t.datastore)}async function cr(r){const t=await eo(r),e=t.eventManager;return e.onListen=SI.bind(null,t.syncEngine),e.onUnlisten=VI.bind(null,t.syncEngine),e.onFirstRemoteStoreListen=PI.bind(null,t.syncEngine),e.onLastRemoteStoreUnlisten=CI.bind(null,t.syncEngine),e}function YI(r){return r.asyncQueue.enqueue(async()=>{const t=await Xf(r),e=await Yf(r);return t.setNetworkEnabled(!0),function(s){const i=M(s);return i.Ea.delete(0),Vs(i)}(e)})}function ZI(r){return r.asyncQueue.enqueue(async()=>{const t=await Xf(r),e=await Yf(r);return t.setNetworkEnabled(!1),async function(s){const i=M(s);i.Ea.add(0),await pr(i),i.Ra.set("Offline")}(e)})}function tE(r,t){const e=new Rt;return r.asyncQueue.enqueueAndForget(async()=>async function(s,i,o){try{const u=await function(h,f){const m=M(h);return m.persistence.runTransaction("read document","readonly",p=>m.localDocuments.getDocument(p,f))}(s,i);u.isFoundDocument()?o.resolve(u):u.isNoDocument()?o.resolve(null):o.reject(new V(R.UNAVAILABLE,"Failed to get document from cache. (However, this document may exist on the server. Run again without setting 'source' in the GetOptions to attempt to retrieve the document from the server.)"))}catch(u){const c=Ir(u,`Failed to get document '${i} from cache`);o.reject(c)}}(await Er(r),t,e)),e.promise}function tm(r,t,e={}){const n=new Rt;return r.asyncQueue.enqueueAndForget(async()=>function(i,o,u,c,h){const f=new to({next:p=>{f.Nu(),o.enqueueAndForget(()=>lu(i,m));const v=p.docs.has(u);!v&&p.fromCache?h.reject(new V(R.UNAVAILABLE,"Failed to get document because the client is offline.")):v&&p.fromCache&&c&&c.source==="server"?h.reject(new V(R.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.)')):h.resolve(p)},error:p=>h.reject(p)}),m=new du(fr(u.path),f,{includeMetadataChanges:!0,qa:!0});return cu(i,m)}(await cr(r),r.asyncQueue,t,e,n)),n.promise}function eE(r,t){const e=new Rt;return r.asyncQueue.enqueueAndForget(async()=>async function(s,i,o){try{const u=await Pi(s,i,!0),c=new $f(i,u.Qs),h=c.ru(u.documents),f=c.applyChanges(h,!1);o.resolve(f.snapshot)}catch(u){const c=Ir(u,`Failed to execute query '${i} against cache`);o.reject(c)}}(await Er(r),t,e)),e.promise}function em(r,t,e={}){const n=new Rt;return r.asyncQueue.enqueueAndForget(async()=>function(i,o,u,c,h){const f=new to({next:p=>{f.Nu(),o.enqueueAndForget(()=>lu(i,m)),p.fromCache&&c.source==="server"?h.reject(new V(R.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.)')):h.resolve(p)},error:p=>h.reject(p)}),m=new du(u,f,{includeMetadataChanges:!0,qa:!0});return cu(i,m)}(await cr(r),r.asyncQueue,t,e,n)),n.promise}function nE(r,t,e){const n=new Rt;return r.asyncQueue.enqueueAndForget(async()=>{try{const s=await Zf(r);n.resolve(async function(o,u,c){const h=M(o),{request:f,gt:m,parent:p}=ef(h.serializer,Sd(u),c);h.connection.$o||delete f.parent;const v=(await h.Ho("RunAggregationQuery",h.serializer.databaseId,p,f,1)).filter(D=>!!D.result);L(v.length===1,64727);const C=v[0].result?.aggregateFields;return Object.keys(C).reduce((D,x)=>(D[m[x]]=C[x],D),{})}(s,t,e))}catch(s){n.reject(s)}}),n.promise}function rE(r,t){const e=new to(t);return r.asyncQueue.enqueueAndForget(async()=>function(s,i){M(s).Ca.add(i),i.next()}(await cr(r),e)),()=>{e.Nu(),r.asyncQueue.enqueueAndForget(async()=>function(s,i){M(s).Ca.delete(i)}(await cr(r),e))}}function sE(r,t,e,n){const s=function(o,u){let c;
2271return c=typeof o=="string"?Kd().encode(o):o,function(f,m){return new QI(f,m)}(function(f,m){if(f instanceof Uint8Array)return oh(f,m);if(f instanceof ArrayBuffer)return oh(new Uint8Array(f),m);if(f instanceof ReadableStream)return f.getReader();throw new Error("Source of `toByteStreamReader` has to be a ArrayBuffer or ReadableStream")}(c),u)}(e,vn(t));r.asyncQueue.enqueueAndForget(async()=>{KI(await wu(r),s,n)})}function iE(r,t){return r.asyncQueue.enqueue(async()=>function(n,s){const i=M(n);return i.persistence.runTransaction("Get named query","readonly",o=>i.Ii.getNamedQuery(o,s))}(await Er(r),t))}function nm(r,t){return function(n,s){return new WI(n,s)}(r,t)}function oE(r,t){return r.asyncQueue.enqueue(async()=>async function(n,s){const i=M(n),o=i.indexManager,u=[];return i.persistence.runTransaction("Configure indexes","readwrite",c=>o.getFieldIndexes(c).next(h=>function(m,p,v,C,D){m=[...m],p=[...p],m.sort(v),p.sort(v);const x=m.length,B=p.length;let j=0,U=0;for(;j<B&&U<x;){const Y=v(m[U],p[j]);Y<0?D(m[U++]):Y>0?C(p[j++]):(j++,U++)}for(;j<B;)C(p[j++]);for(;U<x;)D(m[U++])}(h,s,e_,f=>{u.push(o.addFieldIndex(c,f))},f=>{u.push(o.deleteFieldIndex(c,f))})).next(()=>A.waitFor(u)))}(await Er(r),t))}function aE(r,t){return r.asyncQueue.enqueue(async()=>function(n,s){M(n).Fs.Vs=s}(await Er(r),t))}function uE(r){return r.asyncQueue.enqueue(async()=>function(e){const n=M(e),s=n.indexManager;return n.persistence.runTransaction("Delete All Indexes","readwrite",i=>s.deleteAllFieldIndexes(i))}(await Er(r)))}/**
2272 * @license
2273 * Copyright 2023 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 rm(r){const t={};return r.timeoutSeconds!==void 0&&(t.timeoutSeconds=r.timeoutSeconds),t}/**
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 */const uh=new Map;/**
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 */const sm="firestore.googleapis.com",ch=!0;class lh{constructor(t){if(t.host===void 0){if(t.ssl!==void 0)throw new V(R.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host=sm,this.ssl=ch}else this.host=t.host,this.ssl=t.ssl??ch;if(this.isUsingEmulator=t.emulatorOptions!==void 0,this.credentials=t.credentials,this.ignoreUndefinedProperties=!!t.ignoreUndefinedProperties,this.localCache=t.localCache,t.cacheSizeBytes===void 0)this.cacheSizeBytes=hf;else{if(t.cacheSizeBytes!==-1&&t.cacheSizeBytes<gf)throw new V(R.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=t.cacheSizeBytes}zh("experimentalForceLongPolling",t.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",t.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!t.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:t.experimentalAutoDetectLongPolling===void 0?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!t.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=rm(t.experimentalLongPollingOptions??{}),function(n){if(n.timeoutSeconds!==void 0){if(isNaN(n.timeoutSeconds))throw new V(R.INVALID_ARGUMENT,`invalid long polling timeout: ${n.timeoutSeconds} (must not be NaN)`);if(n.timeoutSeconds<5)throw new V(R.INVALID_ARGUMENT,`invalid long polling timeout: ${n.timeoutSeconds} (minimum allowed value is 5)`);if(n.timeoutSeconds>30)throw new V(R.INVALID_ARGUMENT,`invalid long polling timeout: ${n.timeoutSeconds} (maximum allowed value is 30)`)}}(this.experimentalLongPollingOptions),this.useFetchStreams=!!t.useFetchStreams}isEqual(t){return this.host===t.host&&this.ssl===t.ssl&&this.credentials===t.credentials&&this.cacheSizeBytes===t.cacheSizeBytes&&this.experimentalForceLongPolling===t.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===t.experimentalAutoDetectLongPolling&&function(n,s){return n.timeoutSeconds===s.timeoutSeconds}(this.experimentalLongPollingOptions,t.experimentalLongPollingOptions)&&this.ignoreUndefinedProperties===t.ignoreUndefinedProperties&&this.useFetchStreams===t.useFetchStreams}}class Cs{constructor(t,e,n,s){this._authCredentials=t,this._appCheckCredentials=e,this._databaseId=n,this._app=s,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new lh({}),this._settingsFrozen=!1,this._emulatorOptions={},this._terminateTask="notTerminated"}get app(){if(!this._app)throw new V(R.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(t){if(this._settingsFrozen)throw new V(R.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 lh(t),this._emulatorOptions=t.emulatorOptions||{},t.credentials!==void 0&&(this._authCredentials=function(n){if(!n)return new qh;switch(n.type){case"firstParty":return new Wp(n.sessionIndex||"0",n.iamToken||null,n.authTokenFactory||null);case"provider":return n.client;default:throw new V(R.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invali
2316d credential type")}}(t.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(e){const n=uh.get(e);n&&(N("ComponentProvider","Removing Datastore"),uh.delete(e),n.terminate())}(this),Promise.resolve()}}function im(r,t,e,n={}){r=Q(r,Cs);const s=ki(t),i=r._getSettings(),o={...i,emulatorOptions:r._getEmulatorOptions()},u=`${t}:${e}`;s&&(wh(`https://${u}`),Ag("Firestore",!0)),i.host!==sm&&i.host!==u&&$t("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used.");const c={...i,host:u,ssl:s,emulatorOptions:n};if(!xe(c,o)&&(r._setSettings(c),n.mockUserToken)){let h,f;if(typeof n.mockUserToken=="string")h=n.mockUserToken,f=bt.MOCK_USER;else{h=Eg(n.mockUserToken,r._app?.options.projectId);const m=n.mockUserToken.sub||n.mockUserToken.user_id;if(!m)throw new V(R.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");f=new bt(m)}r._authCredentials=new $p(new Uh(h,f))}}/**
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 */class Tt{constructor(t,e,n){this.converter=e,this._query=n,this.type="query",this.firestore=t}withConverter(t){return new Tt(this.firestore,t,this._query)}}class nt{constructor(t,e,n){this.converter=e,this._key=n,this.type="document",this.firestore=t}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new Ht(this.firestore,this.converter,this._key.path.popLast())}withConverter(t){return new nt(this.firestore,t,this._key)}toJSON(){return{type:nt._jsonSchemaVersion,referencePath:this._key.toString()}}static fromJSON(t,e,n){if(An(e,nt._jsonSchema))return new nt(t,n||null,new k(K.fromString(e.referencePath)))}}nt._jsonSchemaVersion="firestore/documentReference/1.0",nt._jsonSchema={type:yt("string",nt._jsonSchemaVersion),referencePath:yt("string")};class Ht extends Tt{constructor(t,e,n){super(t,e,fr(n)),this._path=n,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){const t=this._path.popLast();return t.isEmpty()?null:new nt(this.firestore,null,new k(t))}withConverter(t){return new Ht(this.firestore,t,this._path)}}function cE(r,t,...e){if(r=Et(r),Ca("collection","path",t),r instanceof Cs){const n=K.fromString(t,...e);return Yc(n),new Ht(r,null,n)}{if(!(r instanceof nt||r instanceof Ht))throw new V(R.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const n=r._path.child(K.fromString(t,...e));return Yc(n),new Ht(r.firestore,null,n)}}function lE(r,t){if(r=Q(r,Cs),Ca("collectionGroup","collection id",t),t.indexOf("/")>=0)throw new V(R.INVALID_ARGUMENT,`Invalid collection ID '${t}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);return new Tt(r,null,function(n){return new he(K.emptyPath(),n)}(t))}function om(r,t,...e){if(r=Et(r),arguments.length===1&&(t=Mi.newId()),Ca("doc","path",t),r instanceof Cs){const n=K.fromString(t,...e);return Xc(n),new nt(r,null,new k(n))}{if(!(r instanceof nt||r instanceof Ht))throw new V(R.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const n=r._path.child(K.fromString(t,...e));return Xc(n),new nt(r.firestore,r instanceof Ht?r.converter:null,new k(n))}}function hE(r,t){return r=Et(r),t=Et(t),(r instanceof nt||r instanceof Ht)&&(t instanceof nt||t instanceof Ht)&&r.firestore===t.firestore&&r.path===t.path&&r.converter===t.converter}function Au(r,t){return r=Et(r),t=Et(t),r instanceof Tt&&t instanceof Tt&&r.firestore===t.firestore&&vs(r._query,t._query)&&r.converter===t.converter}/**
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 */const hh="AsyncQueue";class dh{constructor(t=Promise.resolve()){this.Xu=[],this.ec=!1,this.tc=[],this.nc=null,this.rc=!1,this.sc=!1,this.oc=[],this.M_=new su(this,"async_queue_retry"),this._c=()=>{const n=fi();n&&N(hh,"Visibility state changed to "+n.visibilityState),this.M_.w_()},this.ac=t;const e=fi();e&&typeof e.addEventListener=="function"&&e.addEventListener("visibilitychange",this._c)}get isShuttingDown(){return this.ec}enqueueAndForget(t){this.enqueue(t)}enqueueAndForgetEvenWhileRestricted(t){this.uc(),this.cc(t)}enterRestrictedMode(t){if(!this.ec){this.ec=!0,this.sc=t||!1;const e=fi();e&&typeof e.removeEventListener=="function"&&e.removeEventListener("visibilitychange",this._c)}}enqueue(t){if(this.uc(),this.ec)return new Promise(()=>{});const e=new Rt;return this.cc(()=>this.ec&&this.sc?Promise.resolve():(t().then(e.resolve,e.reject),e.promise)).then(()=>e.promise)}enqueueRetryable(t){this.enqueueAndForget(()=>(this.Xu.push(t),this.lc()))}async lc(){if(this.Xu.length!==0){try{await this.Xu[0](),this.Xu.shift(),this.M_.reset()}catch(t){if(!je(t))throw t;N(hh,"Operation failed with retryable error: "+t)}this.Xu.length>0&&this.M_.p_(()=>this.lc())}}cc(t){const e=this.ac.then(()=>(this.rc=!0,t().catch(n=>{throw this.nc=n,this.rc=!1,gt("INTERNAL UNHANDLED ERROR: ",fh(n)),n}).then(n=>(this.rc=!1,n))));return this.ac=e,e}enqueueAfterDelay(t,e,n){this.uc(),this.oc.indexOf(t)>-1&&(e=0);const s=uu.createAndSchedule(this,t,e,n,i=>this.hc(i));return this.tc.push(s),s}uc(){this.nc&&F(47125,{Pc:fh(this.nc)})}verifyOperationInProgress(){}async Tc(){let t;do t=this.ac,await t;while(t!==this.ac)}Ic(t){for(const e of this.tc)if(e.timerId===t)return!0;return!1}Ec(t){return this.Tc().then(()=>{this.tc.sort((e,n)=>e.targetTimeMs-n.targetTimeMs);for(const e of this.tc)if(e.skipDelay(),t!=="all"&&e.timerId===t)break;return this.Tc()})}dc(t){this.oc.push(t)}hc(t){const e=this.tc.indexOf(t);this.tc.splice(e,1)}}function fh(r){let t=r.message||"";return r.stack&&(t=r.stack.includes(r.message)?r.stack:r.message+`
2347`+r.stack),t}/**
2348 * @license
2349 * Copyright 2017 Google LLC
2350 *
2351 * Licensed under the Apache License, Version 2.0 (the "License");
2352 * you may not use this file except in compliance with the License.
2353 * You may obtain a copy of the License at
2354 *
2355 *   http://www.apache.org/licenses/LICENSE-2.0
2356 *
2357 * Unless required by applicable law or agreed to in writing, software
2358 * distributed under the License is distributed on an "AS IS" BASIS,
2359 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2360 * See the License for the specific language governing permissions and
2361 * limitations under the License.
2362 */function jn(r){return function(e,n){if(typeof e!="object"||e===null)return!1;const s=e;for(const i of n)if(i in s&&typeof s[i]=="function")return!0;return!1}(r,["next","error","complete"])}class am{constructor(){this._progressObserver={},this._taskCompletionResolver=new Rt,this._lastProgress={taskState:"Running",totalBytes:0,totalDocuments:0,bytesLoaded:0,documentsLoaded:0}}onProgress(t,e,n){this._progressObserver={next:t,error:e,complete:n}}catch(t){return this._taskCompletionResolver.promise.catch(t)}then(t,e){return this._taskCompletionResolver.promise.then(t,e)}_completeWith(t){this._updateProgress(t),this._progressObserver.complete&&this._progressObserver.complete(),this._taskCompletionResolver.resolve(t)}_failWith(t){this._lastProgress.taskState="Error",this._progressObserver.next&&this._progressObserver.next(this._lastProgress),this._progressObserver.error&&this._progressObserver.error(t),this._taskCompletionResolver.reject(t)}_updateProgress(t){this._lastProgress=t,this._progressObserver.next&&this._progressObserver.next(t)}}/**
2363 * @license
2364 * Copyright 2020 Google LLC
2365 *
2366 * Licensed under the Apache License, Version 2.0 (the "License");
2367 * you may not use this file except in compliance with the License.
2368 * You may obtain a copy of the License at
2369 *
2370 *   http://www.apache.org/licenses/LICENSE-2.0
2371 *
2372 * Unless required by applicable law or agreed to in writing, software
2373 * distributed under the License is distributed on an "AS IS" BASIS,
2374 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2375 * See the License for the specific language governing permissions and
2376 * limitations under the License.
2377 */const dE=-1;class st extends Cs{constructor(t,e,n,s){super(t,e,n,s),this.type="firestore",this._queue=new dh,this._persistenceKey=s?.name||"[DEFAULT]"}async _terminate(){if(this._firestoreClient){const t=this._firestoreClient.terminate();this._queue=new dh(t),this._firestoreClient=void 0,await t}}}function fE(r,t,e){e||(e=fs);const n=Pa(r,"firestore");if(n.isInitialized(e)){const s=n.getImmediate({identifier:e}),i=n.getOptions(e);if(xe(i,t))return s;throw new V(R.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(t.cacheSizeBytes!==void 0&&t.localCache!==void 0)throw new V(R.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(t.cacheSizeBytes!==void 0&&t.cacheSizeBytes!==-1&&t.cacheSizeBytes<gf)throw new V(R.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");return t.host&&ki(t.host)&&wh(t.host),n.initialize({options:t,instanceIdentifier:e})}function mE(r,t){const e=typeof r=="object"?r:xp(),n=typeof r=="string"?r:t||fs,s=Pa(e,"firestore").getImmediate({identifier:n});if(!s._initialized){const i=yg("firestore");i&&im(s,...i)}return s}function dt(r){if(r._terminated)throw new V(R.FAILED_PRECONDITION,"The client has already been terminated.");return r._firestoreClient||um(r),r._firestoreClient}function um(r){const t=r._freezeSettings(),e=function(s,i,o,u){return new M_(s,i,o,u.host,u.ssl,u.experimentalForceLongPolling,u.experimentalAutoDetectLongPolling,rm(u.experimentalLongPollingOptions),u.useFetchStreams,u.isUsingEmulator)}(r._databaseId,r._app?.options.appId||"",r._persistenceKey,t);r._componentsProvider||t.localCache?._offlineComponentProvider&&t.localCache?._onlineComponentProvider&&(r._componentsProvider={_offline:t.localCache._offlineComponentProvider,_online:t.localCache._onlineComponentProvider}),r._firestoreClient=new XI(r._authCredentials,r._appCheckCredentials,r._queue,e,r._componentsProvider&&function(s){const i=s?._online.build();return{_offline:s?._offline.build(i),_online:i}}(r._componentsProvider))}function gE(r,t){$t("enableIndexedDbPersistence() will be deprecated 
2377in the future, you can use `FirestoreSettings.cache` instead.");const e=r._freezeSettings();return cm(r,Be.provider,{build:n=>new Eu(n,e.cacheSizeBytes,t?.forceOwnership)}),Promise.resolve()}async function pE(r){$t("enableMultiTabIndexedDbPersistence() will be deprecated in the future, you can use `FirestoreSettings.cache` instead.");const t=r._freezeSettings();cm(r,Be.provider,{build:e=>new Jf(e,t.cacheSizeBytes)})}function cm(r,t,e){if((r=Q(r,st))._firestoreClient||r._terminated)throw new V(R.FAILED_PRECONDITION,"Firestore has already been started and persistence can no longer be enabled. You can only enable persistence before calling any other methods on a Firestore object.");if(r._componentsProvider||r._getSettings().localCache)throw new V(R.FAILED_PRECONDITION,"SDK cache is already specified.");r._componentsProvider={_online:t,_offline:e},um(r)}function _E(r){if(r._initialized&&!r._terminated)throw new V(R.FAILED_PRECONDITION,"Persistence can only be cleared before a Firestore instance is initialized or after it is terminated.");const t=new Rt;return r._queue.enqueueAndForgetEvenWhileRestricted(async()=>{try{await async function(n){if(!re.v())return Promise.resolve();const s=n+Tf;await re.delete(s)}(tu(r._databaseId,r._persistenceKey)),t.resolve()}catch(e){t.reject(e)}}),t.promise}function yE(r){return function(e){const n=new Rt;return e.asyncQueue.enqueueAndForget(async()=>MI(await wu(e),n)),n.promise}(dt(r=Q(r,st)))}function IE(r){return YI(dt(r=Q(r,st)))}function EE(r){return ZI(dt(r=Q(r,st)))}function TE(r){return Rp(r.app,"firestore",r._databaseId.database),r._delete()}function ba(r,t){const e=dt(r=Q(r,st)),n=new am;return sE(e,r._databaseId,t,n),n}function lm(r,t){return iE(dt(r=Q(r,st)),t).then(e=>e?new Tt(r,null,e.query):null)}/**
2378 * @license
2379 * Copyright 2020 Google LLC
2380 *
2381 * Licensed under the Apache License, Version 2.0 (the "License");
2382 * you may not use this file except in compliance with the License.
2383 * You may obtain a copy of the License at
2384 *
2385 *   http://www.apache.org/licenses/LICENSE-2.0
2386 *
2387 * Unless required by applicable law or agreed to in writing, software
2388 * distributed under the License is distributed on an "AS IS" BASIS,
2389 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2390 * See the License for the specific language governing permissions and
2391 * limitations under the License.
2392 *//**
2393 * @license
2394 * Copyright 2022 Google LLC
2395 *
2396 * Licensed under the Apache License, Version 2.0 (the "License");
2397 * you may not use this file except in compliance with the License.
2398 * You may obtain a copy of the License at
2399 *
2400 *   http://www.apache.org/licenses/LICENSE-2.0
2401 *
2402 * Unless required by applicable law or agreed to in writing, software
2403 * distributed under the License is distributed on an "AS IS" BASIS,
2404 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2405 * See the License for the specific language governing permissions and
2406 * limitations under the License.
2407 */class lr{constructor(t="count",e){this._internalFieldPath=e,this.type="AggregateField",this.aggregateType=t}}class hm{constructor(t,e,n){this._userDataWriter=e,this._data=n,this.type="AggregateQuerySnapshot",this.query=t}data(){return this._userDataWriter.convertObjectMap(this._data)}}/**
2408 * @license
2409 * Copyright 2020 Google LLC
2410 *
2411 * Licensed under the Apache License, Version 2.0 (the "License");
2412 * you may not use this file except in compliance with the License.
2413 * You may obtain a copy of the License at
2414 *
2415 *   http://www.apache.org/licenses/LICENSE-2.0
2416 *
2417 * Unless required by applicable law or agreed to in writing, software
2418 * distributed under the License is distributed on an "AS IS" BASIS,
2419 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2420 * See the License for the specific language governing permissions and
2421 * limitations under the License.
2422 */class Ft{constructor(t){this._byteString=t}static fromBase64String(t){try{return new Ft(ft.fromBase64String(t))}catch(e){throw new V(R.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+e)}}static fromUint8Array(t){return new Ft(ft.fromUint8Array(t))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(t){return this._byteString.isEqual(t._byteString)}toJSON(){return{type:Ft._jsonSchemaVersion,bytes:this.toBase64()}}static fromJSON(t){if(An(t,Ft._jsonSchema))return Ft.fromBase64String(t.bytes)}}
2422Ft._jsonSchemaVersion="firestore/bytes/1.0",Ft._jsonSchema={type:yt("string",Ft._jsonSchemaVersion),bytes:yt("string")};/**
2423 * @license
2424 * Copyright 2020 Google LLC
2425 *
2426 * Licensed under the Apache License, Version 2.0 (the "License");
2427 * you may not use this file except in compliance with the License.
2428 * You may obtain a copy of the License at
2429 *
2430 *   http://www.apache.org/licenses/LICENSE-2.0
2431 *
2432 * Unless required by applicable law or agreed to in writing, software
2433 * distributed under the License is distributed on an "AS IS" BASIS,
2434 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2435 * See the License for the specific language governing permissions and
2436 * limitations under the License.
2437 */class Ke{constructor(...t){for(let e=0;e<t.length;++e)if(t[e].length===0)throw new V(R.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new ct(t)}isEqual(t){return this._internalPath.isEqual(t._internalPath)}}function wE(){return new Ke(ta)}/**
2438 * @license
2439 * Copyright 2020 Google LLC
2440 *
2441 * Licensed under the Apache License, Version 2.0 (the "License");
2442 * you may not use this file except in compliance with the License.
2443 * You may obtain a copy of the License at
2444 *
2445 *   http://www.apache.org/licenses/LICENSE-2.0
2446 *
2447 * Unless required by applicable law or agreed to in writing, software
2448 * distributed under the License is distributed on an "AS IS" BASIS,
2449 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2450 * See the License for the specific language governing permissions and
2451 * limitations under the License.
2452 */class Qe{constructor(t){this._methodName=t}}/**
2453 * @license
2454 * Copyright 2017 Google LLC
2455 *
2456 * Licensed under the Apache License, Version 2.0 (the "License");
2457 * you may not use this file except in compliance with the License.
2458 * You may obtain a copy of the License at
2459 *
2460 *   http://www.apache.org/licenses/LICENSE-2.0
2461 *
2462 * Unless required by applicable law or agreed to in writing, software
2463 * distributed under the License is distributed on an "AS IS" BASIS,
2464 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2465 * See the License for the specific language governing permissions and
2466 * limitations under the License.
2467 */class Jt{constructor(t,e){if(!isFinite(t)||t<-90||t>90)throw new V(R.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+t);if(!isFinite(e)||e<-180||e>180)throw new V(R.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+e);this._lat=t,this._long=e}get latitude(){return this._lat}get longitude(){return this._long}isEqual(t){return this._lat===t._lat&&this._long===t._long}_compareTo(t){return z(this._lat,t._lat)||z(this._long,t._long)}toJSON(){return{latitude:this._lat,longitude:this._long,type:Jt._jsonSchemaVersion}}static fromJSON(t){if(An(t,Jt._jsonSchema))return new Jt(t.latitude,t.longitude)}}Jt._jsonSchemaVersion="firestore/geoPoint/1.0",Jt._jsonSchema={type:yt("string",Jt._jsonSchemaVersion),latitude:yt("number"),longitude:yt("number")};/**
2468 * @license
2469 * Copyright 2024 Google LLC
2470 *
2471 * Licensed under the Apache License, Version 2.0 (the "License");
2472 * you may not use this file except in compliance with the License.
2473 * You may obtain a copy of the License at
2474 *
2475 *   http://www.apache.org/licenses/LICENSE-2.0
2476 *
2477 * Unless required by applicable law or agreed to in writing, software
2478 * distributed under the License is distributed on an "AS IS" BASIS,
2479 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2480 * See the License for the specific language governing permissions and
2481 * limitations under the License.
2482 */class Qt{constructor(t){this._values=(t||[]).map(e=>e)}toArray(){return this._values.map(t=>t)}isEqual(t){return function(n,s){if(n.length!==s.length)return!1;for(let i=0;i<n.length;++i)if(n[i]!==s[i])return!1;return!0}(this._values,t._values)}toJSON(){return{type:Qt._jsonSchemaVersion,vectorValues:this._values}}static fromJSON(t){if(An(t,Qt._jsonSchema)){if(Array.isArray(t.vectorValues)&&t.vectorValues.every(e=>typeof e=="number"))return new Qt(t.vectorValues);throw new V(R.INVALID_ARGUMENT,"Expected 'vectorValues' field to be a number array")}}}Qt._jsonSchemaVersion="firestore/vectorValue/1.0",Qt._jsonSchema={type:yt("string",Qt._jsonSchemaVersion),vectorValues:yt("object")};/**
2483 * @license
2484 * Copyright 2017 Google LLC
2485 *
2486 * Licensed under the Apache License, Version 2.0 (the "License");
2487 * you may not use this file except in compliance with the License.
2488 * You may obtain a copy of the License at
2489 *
2490 *   http://www.apache.org/licenses/LICENSE-2.0
2491 *
2492 * Unless required by applicable law or agreed to in writing, software
2493 * distributed under the License is distributed on an "AS IS" BASIS,
2494 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2495 * See the License for the specific language governing permissions and
2496 * limitations under the License.
2497 */const AE=/^__.*__$/;class vE{constructor(t,e,n){this.data=t,this.fieldMask=e,this.fieldTransforms=n}toMutation(t,e){return this.fieldMask!==null?new fe(t,this.data,this.fieldMask,e,this.fieldTransforms):new mr(t,this.data,e,this.fieldTransforms)}}class dm{constructor(t,e,n){this.data=t,this.fieldMask=e,this.fieldTransforms=n}toMutation(t,e){return new fe(t,this.data,this.fieldMask,e,this.fieldTransforms)}}function fm(r){switch(r){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw F(40011,{Ac:r})}}class no{constructor(t,e,n,s,i,o){this.settings=t,this.databaseId=e,this.serializer=n,this.ignoreUndefinedProperties=s,i===void 0&&this.Rc(),this.fieldTransforms=i||[],this.fieldMask=o||[]}get path(){return this.settings.path}get Ac(){return this.settings.Ac}Vc(t){return new no({...this.settings,...t},this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}mc(t){const e=this.path?.child(t),n=this.Vc({path:e,fc:!1});return n.gc(t),n}yc(t){const e=this.path?.child(t),n=this.Vc({path:e,fc:!1});return n.Rc(),n}wc(t){return this.Vc({path:void 0,fc:!0})}Sc(t){return xi(t,this.settings.methodName,this.settings.bc||!1,this.path,this.settings.Dc)}contains(t){return this.fieldMask.find(e=>t.isPrefixOf(e))!==void 0||this.fieldTransforms.find(e=>t.isPrefixOf(e.field))!==void 0}Rc(){if(this.path)for(let t=0;t<this.path.length;t++)this.gc(this.path.get(t))}gc(t){if(t.length===0)throw this.Sc("Document fields must not be empty");if(fm(this.Ac)&&AE.test(t))throw this.Sc('Document fields cannot begin and end with "__"')}}class bE{constructor(t,e,n){this.databaseId=t,this.ignoreUndefinedProperties=e,this.serializer=n||vn(t)}Cc(t,e,n,s=!1){return new no({Ac:t,methodName:e,Dc:n,path:ct.emptyPath(),fc:!1,bc:s},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}}function bn(r){const t=r._freezeSettings(),e=vn(r._databaseId);return new bE(r._databaseId,!!t.ignoreUndefinedProperties,e)}function ro(r,t,e,n,s,i={}){const o=r.Cc(i.merge||i.mergeFields?2:0,t,e,s);Cu("Data must be an object, but it was:",o,n);const u=pm(n,o);let c,h;if(i.merge)c=new Bt(o.fieldMask),h=o.fieldTransforms;else if(i.mergeFields){const f=[];for(const m of i.mergeFields){const p=Is(t,m,e);if(!o.contains(p))throw new V(R.INVALID_ARGUMENT,`Field '${p}' is specified in your field mask but missing from your input data.`);ym(f,p)||f.push(p)}c=new Bt(f),h=o.fieldTransforms.filter(m=>c.covers(m.field))}else c=null,h=o.fieldTransforms;return new vE(new Pt(u),c,h)}class Ds extends Qe{_toFieldTransform(t){if(t.Ac!==2)throw t.Ac===1?t.Sc(`${this._methodName}() can only appear at the top level of your update data`):t.Sc(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return t.fieldMask.push(t.path),null}isEqual(t){return t instanceof Ds}}function mm(r,t,e){return new no({Ac:3,Dc:t.settings.Dc,methodName:r._methodName,fc:e},t.databaseId,t.serializer,t.ignoreUndefinedProperties)}class vu extends Qe{_toFieldTransform(t){return new Rs(t.path,new er)}isEqual(t){return t instanceof vu}}class bu extends Qe{constructor(t,e){super(t),this.vc=e}_toFieldTransform(t){const e=mm(this,t,!0),n=this.vc.map(i=>Rn(i,e)),s=new pn(n);return new Rs(t.path,s)}isEqual(t){return t instanceof bu&&xe(this.vc,t.vc)}}class Ru extends Qe{constructor(t,e){super(t),this.vc=e}_toFieldTransform(t){const e=mm(this,t,!0),n=this.vc.map(i=>Rn(i,e)),s=new _n(n);return new Rs(t.path,s)}isEqual(t){return t instanceof Ru&&xe(this.vc,t.vc)}}class Su extends Qe{constructor(t,e){super(t),this.Fc=e}_toFieldTransform(t){const e=new nr(t.serializer,Od(t.serializer,this.Fc));return new Rs(t.path,e)}isEqual(t){return t instanceof Su&&this.Fc===t.Fc}}function Pu(r,t,e,n){const s=r.Cc(1,t,e);Cu("Data must be an object, but it was:",s,n);const i=[],o=Pt.empty();ze(n,(c,h)=>{const f=so(t,c,e);h=Et(h);const m=s.yc(f);if(h instanceof Ds)i.push(f);else{const p=Rn(h,m);p!=null&&(i.push(f),o.set(f,p))}});const u=new Bt(i);return new dm(o,u,s.fieldTransforms)}function Vu(r,t,e,n,s,i){const o=r.Cc(1,t,e),u=[Is(t,n,e)],c=[s];if(i.length%2!=0)throw new V(R.INVALID_ARGUMENT,`Function ${t}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let p=0;p<i.length;p+=2)u.push(Is(t,i[p])),c.push(i[p+1]);const h=[],f=Pt.empty();for(let p=u.length-1;p>=0;--p)if(!ym(h,u[p])){const v=u[p];let C=c[p];C=Et(C);const D=o.yc(v);if(C instanceof Ds)h.push(v);else{const x=Rn(C,D);x!=null&&(h.push(v),f.set(v,x))}}const m=new Bt(h);return new dm(f,m,o.fieldTransforms)}function gm(r,t,e,n=!1){return Rn(e,r.Cc(n?4:3,t))}function Rn(r,t){if(_m(r=Et(r)))return Cu("Unsupported field value:",t,r),pm(r,t);if(r instanceof Qe)return function(n,s){if(!fm(s.Ac))throw s.Sc(`${n._methodName}
2497() can only be used with update() and set()`);if(!s.path)throw s.Sc(`${n._methodName}() is not currently supported inside arrays`);const i=n._toFieldTransform(s);i&&s.fieldTransforms.push(i)}(r,t),null;if(r===void 0&&t.ignoreUndefinedProperties)return null;if(t.path&&t.fieldMask.push(t.path),r instanceof Array){if(t.settings.fc&&t.Ac!==4)throw t.Sc("Nested arrays are not supported");return function(n,s){const i=[];let o=0;for(const u of n){let c=Rn(u,s.wc(o));c==null&&(c={nullValue:"NULL_VALUE"}),i.push(c),o++}return{arrayValue:{values:i}}}(r,t)}return function(n,s){if((n=Et(n))===null)return{nullValue:"NULL_VALUE"};if(typeof n=="number")return Od(s.serializer,n);if(typeof n=="boolean")return{booleanValue:n};if(typeof n=="string")return{stringValue:n};if(n instanceof Date){const i=tt.fromDate(n);return{timestampValue:rr(s.serializer,i)}}if(n instanceof tt){const i=new tt(n.seconds,1e3*Math.floor(n.nanoseconds/1e3));return{timestampValue:rr(s.serializer,i)}}if(n instanceof Jt)return{geoPointValue:{latitude:n.latitude,longitude:n.longitude}};if(n instanceof Ft)return{bytesValue:Hd(s.serializer,n._byteString)};if(n instanceof nt){const i=s.databaseId,o=n.firestore._databaseId;if(!o.isEqual(i))throw s.Sc(`Document reference is for database ${o.projectId}/${o.database} but should be for database ${i.projectId}/${i.database}`);return{referenceValue:Wa(n.firestore._databaseId||s.databaseId,n._key.path)}}if(n instanceof Qt)return function(o,u){return{mapValue:{fields:{[Fa]:{stringValue:La},[Yn]:{arrayValue:{values:o.toArray().map(h=>{if(typeof h!="number")throw u.Sc("VectorValues must only contain numeric values.");return ja(u.serializer,h)})}}}}}}(n,s);throw s.Sc(`Unsupported field value: ${Oi(n)}`)}(r,t)}function pm(r,t){const e={};return cd(r)?t.path&&t.path.length>0&&t.fieldMask.push(t.path):ze(r,(n,s)=>{const i=Rn(s,t.mc(n));i!=null&&(e[n]=i)}),{mapValue:{fields:e}}}function _m(r){return!(typeof r!="object"||r===null||r instanceof Array||r instanceof Date||r instanceof tt||r instanceof Jt||r instanceof Ft||r instanceof nt||r instanceof Qe||r instanceof Qt)}function Cu(r,t,e){if(!_m(e)||!Gh(e)){const n=Oi(e);throw n==="an object"?t.Sc(r+" a custom object"):t.Sc(r+" "+n)}}function Is(r,t,e){if((t=Et(t))instanceof Ke)return t._internalPath;if(typeof t=="string")return so(r,t);throw xi("Field path arguments must be of type string or ",r,!1,void 0,e)}const RE=new RegExp("[~\\*/\\[\\]]");function so(r,t,e){if(t.search(RE)>=0)throw xi(`Invalid field path (${t}). Paths must not contain '~', '*', '/', '[', or ']'`,r,!1,void 0,e);try{return new Ke(...t.split("."))._internalPath}catch{throw xi(`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,r,!1,void 0,e)}}function xi(r,t,e,n,s){const i=n&&!n.isEmpty(),o=s!==void 0;let u=`Function ${t}() called with invalid data`;e&&(u+=" (via `toFirestore()`)"),u+=". ";let c="";return(i||o)&&(c+=" (found",i&&(c+=` in field ${n}`),o&&(c+=` in document ${s}`),c+=")"),new V(R.INVALID_ARGUMENT,u+r+c)}function ym(r,t){return r.some(e=>e.isEqual(t))}/**
2498 * @license
2499 * Copyright 2020 Google LLC
2500 *
2501 * Licensed under the Apache License, Version 2.0 (the "License");
2502 * you may not use this file except in compliance with the License.
2503 * You may obtain a copy of the License at
2504 *
2505 *   http://www.apache.org/licenses/LICENSE-2.0
2506 *
2507 * Unless required by applicable law or agreed to in writing, software
2508 * distributed under the License is distributed on an "AS IS" BASIS,
2509 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2510 * See the License for the specific language governing permissions and
2511 * limitations under the License.
2512 */class Es{constructor(t,e,n,s,i){this._firestore=t,this._userDataWriter=e,this._key=n,this._document=s,this._converter=i}get id(){return this._key.path.lastSegment()}get ref(){return new nt(this._firestore,this._converter,this._key)}exists(){return this._document!==null}data(){if(this._document){if(this._converter){const t=new SE(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(t)}return this._userDataWriter.convertValue(this._document.data.value)}}get(t){if(this._document){const e=this._document.data.field(io("DocumentSnapshot.get",t));if(e!==null)return this._userDataWriter.convertValue(e)}}}
2512class SE extends Es{data(){return super.data()}}function io(r,t){return typeof t=="string"?so(r,t):t instanceof Ke?t._internalPath:t._delegate._internalPath}/**
2513 * @license
2514 * Copyright 2020 Google LLC
2515 *
2516 * Licensed under the Apache License, Version 2.0 (the "License");
2517 * you may not use this file except in compliance with the License.
2518 * You may obtain a copy of the License at
2519 *
2520 *   http://www.apache.org/licenses/LICENSE-2.0
2521 *
2522 * Unless required by applicable law or agreed to in writing, software
2523 * distributed under the License is distributed on an "AS IS" BASIS,
2524 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2525 * See the License for the specific language governing permissions and
2526 * limitations under the License.
2527 */function Im(r){if(r.limitType==="L"&&r.explicitOrderBy.length===0)throw new V(R.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class Du{}class Tr extends Du{}function PE(r,t,...e){let n=[];t instanceof Du&&n.push(t),n=n.concat(e),function(i){const o=i.filter(c=>c instanceof Sn).length,u=i.filter(c=>c instanceof wr).length;if(o>1||o>0&&u>0)throw new V(R.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(...)))`.")}(n);for(const s of n)r=s._apply(r);return r}class wr extends Tr{constructor(t,e,n){super(),this._field=t,this._op=e,this._value=n,this.type="where"}static _create(t,e,n){return new wr(t,e,n)}_apply(t){const e=this._parse(t);return Tm(t._query,e),new Tt(t.firestore,t.converter,ha(t._query,e))}_parse(t){const e=bn(t.firestore);return function(i,o,u,c,h,f,m){let p;if(h.isKeyField()){if(f==="array-contains"||f==="array-contains-any")throw new V(R.INVALID_ARGUMENT,`Invalid Query. You can't perform '${f}' queries on documentId().`);if(f==="in"||f==="not-in"){gh(m,f);const C=[];for(const D of m)C.push(mh(c,i,D));p={arrayValue:{values:C}}}else p=mh(c,i,m)}else f!=="in"&&f!=="not-in"&&f!=="array-contains-any"||gh(m,f),p=gm(u,o,m,f==="in"||f==="not-in");return W.create(h,f,p)}(t._query,"where",e,t.firestore._databaseId,this._field,this._op,this._value)}}function VE(r,t,e){const n=t,s=io("where",r);return wr._create(s,n,e)}class Sn extends Du{constructor(t,e){super(),this.type=t,this._queryConstraints=e}static _create(t,e){return new Sn(t,e)}_parse(t){const e=this._queryConstraints.map(n=>n._parse(t)).filter(n=>n.getFilters().length>0);return e.length===1?e[0]:et.create(e,this._getOperator())}_apply(t){const e=this._parse(t);return e.getFilters().length===0?t:(function(s,i){let o=s;const u=i.getFlattenedFilters();for(const c of u)Tm(o,c),o=ha(o,c)}(t._query,e),new Tt(t.firestore,t.converter,ha(t._query,e)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return this.type==="and"?"and":"or"}}function CE(...r){return r.forEach(t=>wm("or",t)),Sn._create("or",r)}function DE(...r){return r.forEach(t=>wm("and",t)),Sn._create("and",r)}class oo extends Tr{constructor(t,e){super(),this._field=t,this._direction=e,this.type="orderBy"}static _create(t,e){return new oo(t,e)}_apply(t){const e=function(s,i,o){if(s.startAt!==null)throw new V(R.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(s.endAt!==null)throw new V(R.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");return new ps(i,o)}(t._query,this._field,this._direction);return new Tt(t.firestore,t.converter,function(s,i){const o=s.explicitOrderBy.concat([i]);return new he(s.path,s.collectionGroup,o,s.filters.slice(),s.limit,s.limitType,s.startAt,s.endAt)}(t._query,e))}}function xE(r,t="asc"){const e=t,n=io("orderBy",r);return oo._create(n,e)}class xs extends Tr{constructor(t,e,n){super(),this.type=t,this._limit=e,this._limitType=n}static _create(t,e,n){return new xs(t,e,n)}_apply(t){return new Tt(t.firestore,t.converter,Ai(t._query,this._limit,this._limitType))}}function NE(r){return $h("limit",r),xs._create("limit",r,"F")}function kE(r){return $h("limitToLast",r),xs._create("limitToLast",r,"L")}class Ns extends Tr{constructor(t,e,n){super(),this.type=t,this._docOrFields=e,this._inclusive=n}static _create(t,e,n){return new Ns(t,e,n)}_apply(t){const e=Em(t,this.type,this._docOrFields,this._inclusive);return new Tt(t.firestore,t.converter,function(s,i){return new he(s.path,s.collectionGroup,s.explicitOrderBy.slice(),s.filters.slice(),s.limit,s.limitType,i,s.endAt)}(t._query,e))}}function ME(...r){return Ns._create("startAt",r,!0)}function OE(...r){return Ns._create("startAfter",r,!1)}class ks extends Tr{constructor(t,e,n){super(),this.type=t,this._docOrFields=e,this._inclusive=n}static _create(t,e,n){return new ks(t,e,n)}_apply(t){const e=Em(t,this.type,this._docOrFields,this._inclusive);return new Tt(t.firestore,t.converter,function(s,i){return new he(s.path,s.collectionGroup,s.explicitOrderBy.slice(),s.filters.slice(),s.limit,s.limitType,s.startAt,i)}(t._query,e))}}function FE(...r){return ks._create("endBefore",r,!1)}function LE(...r){return ks._create("endAt",r,!0)}function Em(r,t,e,n){if(e[0]=Et(e[0]),e[0]instanceof Es)return function(i,o,u,c,h){if(!c)throw new V(R.NOT_FOUND,`Can't use a DocumentSnapshot that doesn't exist for ${u}().`);const f=[];for(const m of qn(i))if(m.field.isKeyField())f.push(mn(o,c.key));else{const p=c.data.field(m.field);if(qi(p))throw new V(R.INVALID_ARGUMENT,'Invalid query. You are trying to start or end a query using a document for which the field "'+m.field+'" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');if(p===null){const v=m.field.canonicalString();throw new V(R.INVALID_ARGUMENT,`Invalid query. You are trying to start or end a query using a document for which the field '${v}' (used as the orderBy) does not exist.`)}f.push(p)}return new Fe(f,h)}(r._query,r.firestore._databaseId,t,e[0]._document,n);{const s=bn(r.firestore);return function(o,u,c,h,f,m){const p=o.explicitOrderBy;if(f.length>p.length)throw new V(R.INVALID_ARGUMENT,`Too many arguments provided to ${h}(). The number of arguments must be less than or equal to the number of orderBy() clauses`);const v=[];for(let C=0;C<f.length;C++){const D=f[C];
2527if(p[C].field.isKeyField()){if(typeof D!="string")throw new V(R.INVALID_ARGUMENT,`Invalid query. Expected a string for document ID in ${h}(), but got a ${typeof D}`);if(!Ua(o)&&D.indexOf("/")!==-1)throw new V(R.INVALID_ARGUMENT,`Invalid query. When querying a collection and ordering by documentId(), the value passed to ${h}() must be a plain document ID, but '${D}' contains a slash.`);const x=o.path.child(K.fromString(D));if(!k.isDocumentKey(x))throw new V(R.INVALID_ARGUMENT,`Invalid query. When querying a collection group and ordering by documentId(), the value passed to ${h}() must result in a valid document path, but '${x}' is not because it contains an odd number of segments.`);const B=new k(x);v.push(mn(u,B))}else{const x=gm(c,h,D);v.push(x)}}return new Fe(v,m)}(r._query,r.firestore._databaseId,s,t,e,n)}}function mh(r,t,e){if(typeof(e=Et(e))=="string"){if(e==="")throw new V(R.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!Ua(t)&&e.indexOf("/")!==-1)throw new V(R.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${e}' contains a '/' character.`);const n=t.path.child(K.fromString(e));if(!k.isDocumentKey(n))throw new V(R.INVALID_ARGUMENT,`Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${n}' is not because it has an odd number of segments (${n.length}).`);return mn(r,new k(n))}if(e instanceof nt)return mn(r,e._key);throw new V(R.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${Oi(e)}.`)}function gh(r,t){if(!Array.isArray(r)||r.length===0)throw new V(R.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${t.toString()}' filters.`)}function Tm(r,t){const e=function(s,i){for(const o of s)for(const u of o.getFlattenedFilters())if(i.indexOf(u.op)>=0)return u.op;return null}(r.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[]}}(t.op));if(e!==null)throw e===t.op?new V(R.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${t.op.toString()}' filter.`):new V(R.INVALID_ARGUMENT,`Invalid query. You cannot use '${t.op.toString()}' filters with '${e.toString()}' filters.`)}function wm(r,t){if(!(t instanceof wr||t instanceof Sn))throw new V(R.INVALID_ARGUMENT,`Function ${r}() requires AppliableConstraints created with a call to 'where(...)', 'or(...)', or 'and(...)'.`)}class xu{convertValue(t,e="none"){switch(Me(t)){case 0:return null;case 1:return t.booleanValue;case 2:return lt(t.integerValue||t.doubleValue);case 3:return this.convertTimestamp(t.timestampValue);case 4:return this.convertServerTimestamp(t,e);case 5:return t.stringValue;case 6:return this.convertBytes(le(t.bytesValue));case 7:return this.convertReference(t.referenceValue);case 8:return this.convertGeoPoint(t.geoPointValue);case 9:return this.convertArray(t.arrayValue,e);case 11:return this.convertObject(t.mapValue,e);case 10:return this.convertVectorValue(t.mapValue);default:throw F(62114,{value:t})}}convertObject(t,e){return this.convertObjectMap(t.fields,e)}convertObjectMap(t,e="none"){const n={};return ze(t,(s,i)=>{n[s]=this.convertValue(i,e)}),n}convertVectorValue(t){const e=t.fields?.[Yn].arrayValue?.values?.map(n=>lt(n.doubleValue));return new Qt(e)}convertGeoPoint(t){return new Jt(lt(t.latitude),lt(t.longitude))}convertArray(t,e){return(t.values||[]).map(n=>this.convertValue(n,e))}convertServerTimestamp(t,e){switch(e){case"previous":const n=ji(t);return n==null?null:this.convertValue(n,e);case"estimate":return this.convertTimestamp(ds(t));default:return null}}convertTimestamp(t){const e=ce(t);return new tt(e.seconds,e.nanos)}convertDocumentKey(t,e){const n=K.fromString(t);L(of(n),9688,{name:t});const s=new ke(n.get(1),n.get(3)),i=new k(n.popFirst(5));return s.isEqual(e)||gt(`Document ${i} 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 (${e.projectId}/${e.database}) instead.`),i}}/**
2528 * @license
2529 * Copyright 2020 Google LLC
2530 *
2531 * Licensed under the Apache License, Version 2.0 (the "License");
2532 * you may not use this file except in compliance with the License.
2533 * You may obtain a copy of the License at
2534 *
2535 *   http://www.apache.org/licenses/LICENSE-2.0
2536 *
2537 * Unless required by applicable law or agreed to in writing, software
2538 * distributed under the License is distributed on an "AS IS" BASIS,
2539 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2540 * See the License for the specific language governing permissions and
2541 * limitations under the License.
2542 */function ao(r,t,e){let n;return n=r?e&&(e.merge||e.mergeFields)?r.toFirestore(t,e):r.toFirestore(t):t,n}class Nu extends xu{constructor(t){super(),this.firestore=t}convertBytes(t){return new Ft(t)}convertReference(t){const e=this.convertDocumentKey(t,this.firestore._databaseId);return new nt(this.firestore,null,e)}}/**
2543 * @license
2544 * Copyright 2022 Google LLC
2545 *
2546 * Licensed under the Apache License, Version 2.0 (the "License");
2547 * you may not use this file except in compliance with the License.
2548 * You may obtain a copy of the License at
2549 *
2550 *   http://www.apache.org/licenses/LICENSE-2.0
2551 *
2552 * Unless required by applicable law or agreed to in writing, software
2553 * distributed under the License is distributed on an "AS IS" BASIS,
2554 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2555 * See the License for the specific language governing permissions and
2556 * limitations under the License.
2557 */function BE(r){return new lr("sum",Is("sum",r))}function UE(r){return new lr("avg",Is("average",r))}function Am(){return new lr("count")}function qE(r,t){return r instanceof lr&&t instanceof lr&&r.aggregateType===t.aggregateType&&r._internalFieldPath?.canonicalString()===t._internalFieldPath?.canonicalString()}function jE(r,t){return Au(r.query,t.query)&&xe(r.data(),t.data())}/**
2558 * @license
2559 * Copyright 2025 Google LLC
2560 *
2561 * Licensed under the Apache License, Version 2.0 (the "License");
2562 * you may not use this file except in compliance with the License.
2563 * You may obtain a copy of the License at
2564 *
2565 *   http://www.apache.org/licenses/LICENSE-2.0
2566 *
2567 * Unless required by applicable law or agreed to in writing, software
2568 * distributed under the License is distributed on an "AS IS" BASIS,
2569 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2570 * See the License for the specific language governing permissions and
2571 * limitations under the License.
2572 *//**
2573 * @license
2574 * Copyright 2020 Google LLC
2575 *
2576 * Licensed under the Apache License, Version 2.0 (the "License");
2577 * you may not use this file except in compliance with the License.
2578 * You may obtain a copy of the License at
2579 *
2580 *   http://www.apache.org/licenses/LICENSE-2.0
2581 *
2582 * Unless required by applicable law or agreed to in writing, software
2583 * distributed under the License is distributed on an "AS IS" BASIS,
2584 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2585 * See the License for the specific language governing permissions and
2586 * limitations under the License.
2587 */const vm="NOT SUPPORTED";class ae{constructor(t,e){this.hasPendingWrites=t,this.fromCache=e}isEqual(t){return this.hasPendingWrites===t.hasPendingWrites&&this.fromCache===t.fromCache}}class qt extends Es{constructor(t,e,n,s,i,o){super(t,e,n,s,o),this._firestore=t,this._firestoreImpl=t,this.metadata=i}exists(){return super.exists()}data(t={}){if(this._document){if(this._converter){const e=new is(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(e,t)}return this._userDataWriter.convertValue(this._document.data.value,t.serverTimestamps)}}get(t,e={}){if(this._document){const n=this._document.data.field(io("DocumentSnapshot.get",t));if(n!==null)return this._userDataWriter.convertValue(n,e.serverTimestamps)}}toJSON(){if(this.metadata.hasPendingWrites)throw new V(R.FAILED_PRECONDITION,"DocumentSnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");const t=this._document,e={};return e.type=qt._jsonSchemaVersion,e.bundle="",e.bundleSource="DocumentSnapshot",e.bundleName=this._key.toString(),!t||!t.isValidDocument()||!t.isFoundDocument()?e:(this._userDataWriter.convertObjectMap(t.data.value.mapValue.fields,"previous"),e.bundle=(this._firestore,this.ref.path,"NOT SUPPORTED"),e)}}
2587function zE(r,t,e){if(An(t,qt._jsonSchema)){if(t.bundle===vm)throw new V(R.INVALID_ARGUMENT,"The provided JSON object was created in a client environment, which is not supported.");const n=vn(r._databaseId),s=nm(t.bundle,n),i=s.Wu(),o=new fu(s.getMetadata(),n);for(const f of i)o.Ga(f);const u=o.documents;if(u.length!==1)throw new V(R.INVALID_ARGUMENT,`Expected bundle data to contain 1 document, but it contains ${u.length} documents.`);const c=Ki(n,u[0].document),h=new k(K.fromString(t.bundleName));return new qt(r,new Nu(r),h,c,new ae(!1,!1),e||null)}}qt._jsonSchemaVersion="firestore/documentSnapshot/1.0",qt._jsonSchema={type:yt("string",qt._jsonSchemaVersion),bundleSource:yt("string","DocumentSnapshot"),bundleName:yt("string"),bundle:yt("string")};class is extends qt{data(t={}){return super.data(t)}}class jt{constructor(t,e,n,s){this._firestore=t,this._userDataWriter=e,this._snapshot=s,this.metadata=new ae(s.hasPendingWrites,s.fromCache),this.query=n}get docs(){const t=[];return this.forEach(e=>t.push(e)),t}get size(){return this._snapshot.docs.size}get empty(){return this.size===0}forEach(t,e){this._snapshot.docs.forEach(n=>{t.call(e,new is(this._firestore,this._userDataWriter,n.key,n,new ae(this._snapshot.mutatedKeys.has(n.key),this._snapshot.fromCache),this.query.converter))})}docChanges(t={}){const e=!!t.includeMetadataChanges;if(e&&this._snapshot.excludesMetadataChanges)throw new V(R.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===e||(this._cachedChanges=function(s,i){if(s._snapshot.oldDocs.isEmpty()){let o=0;return s._snapshot.docChanges.map(u=>{const c=new is(s._firestore,s._userDataWriter,u.doc.key,u.doc,new ae(s._snapshot.mutatedKeys.has(u.doc.key),s._snapshot.fromCache),s.query.converter);return u.doc,{type:"added",doc:c,oldIndex:-1,newIndex:o++}})}{let o=s._snapshot.oldDocs;return s._snapshot.docChanges.filter(u=>i||u.type!==3).map(u=>{const c=new is(s._firestore,s._userDataWriter,u.doc.key,u.doc,new ae(s._snapshot.mutatedKeys.has(u.doc.key),s._snapshot.fromCache),s.query.converter);let h=-1,f=-1;return u.type!==0&&(h=o.indexOf(u.doc.key),o=o.delete(u.doc.key)),u.type!==1&&(o=o.add(u.doc),f=o.indexOf(u.doc.key)),{type:$E(u.type),doc:c,oldIndex:h,newIndex:f}})}}(this,e),this._cachedChangesIncludeMetadataChanges=e),this._cachedChanges}toJSON(){if(this.metadata.hasPendingWrites)throw new V(R.FAILED_PRECONDITION,"QuerySnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");const t={};t.type=jt._jsonSchemaVersion,t.bundleSource="QuerySnapshot",t.bundleName=Mi.newId(),this._firestore._databaseId.database,this._firestore._databaseId.projectId;const e=[],n=[],s=[];return this.docs.forEach(i=>{i._document!==null&&(e.push(i._document),n.push(this._userDataWriter.convertObjectMap(i._document.data.value.mapValue.fields,"previous")),s.push(i.ref.path))}),t.bundle=(this._firestore,this.query._query,t.bundleName,"NOT SUPPORTED"),t}}function GE(r,t,e){if(An(t,jt._jsonSchema)){if(t.bundle===vm)throw new V(R.INVALID_ARGUMENT,"The provided JSON object was created in a client environment, which is not supported.");const n=vn(r._databaseId),s=nm(t.bundle,n),i=s.Wu(),o=new fu(s.getMetadata(),n);for(const p of i)o.Ga(p);if(o.queries.length!==1)throw new V(R.INVALID_ARGUMENT,`Snapshot data expected 1 query but found ${o.queries.length} queries.`);const u=Wi(o.queries[0].bundledQuery),c=o.documents;let h=new fn;c.map(p=>{const v=Ki(n,p.document);h=h.add(v)});const f=wn.fromInitialDocuments(u,h,G(),!1,!1),m=new Tt(r,e||null,u);return new jt(r,new Nu(r),m,f)}}function $E(r){switch(r){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return F(61501,{type:r})}}function KE(r,t){return r instanceof qt&&t instanceof qt?r._firestore===t._firestore&&r._key.isEqual(t._key)&&(r._document===null?t._document===null:r._document.isEqual(t._document))&&r._converter===t._converter:r instanceof jt&&t instanceof jt&&r._firestore===t._firestore&&Au(r.query,t.query)&&r.metadata.isEqual(t.metadata)&&r._snapshot.isEqual(t._snapshot)}/**
2588 * @license
2589 * Copyright 2020 Google LLC
2590 *
2591 * Licensed under the Apache License, Version 2.0 (the "License");
2592 * you may not use this file except in compliance with the License.
2593 * You may obtain a copy of the License at
2594 *
2595 *   http://www.apache.org/licenses/LICENSE-2.0
2596 *
2597 * Unless required by applicable law or agreed to in writing, software
2598 * distributed under the License is distributed on an "AS IS" BASIS,
2599 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2600 * See the License for the specific language governing permissions and
2601 * limitations under the License.
2602 */function QE(r){r=Q(r,nt);const t=Q(r.firestore,st);return tm(dt(t),r._key).then(e=>ku(t,r,e))}jt._jsonSchemaVersion="firestore/querySnapshot/1.0",jt._jsonSchema={type:yt("string",jt._jsonSchemaVersion),bundleSource:yt("string","QuerySnapshot"),bundleName:yt("string"),bundle:yt("string")};class We extends xu{constructor(t){super(),this.firestore=t}convertBytes(t){return new Ft(t)}convertReference(t){const e=this.convertDocumentKey(t,this.firestore._databaseId);return new nt(this.firestore,null,e)}}function WE(r){r=Q(r,nt);const t=Q(r.firestore,st),e=dt(t),n=new We(t);return tE(e,r._key).then(s=>new qt(t,n,r._key,s,new ae(s!==null&&s.hasLocalMutations,!0),r.converter))}function HE(r){r=Q(r,nt);const t=Q(r.firestore,st);return tm(dt(t),r._key,{source:"server"}).then(e=>ku(t,r,e))}function JE(r){r=Q(r,Tt);const t=Q(r.firestore,st),e=dt(t),n=new We(t);return Im(r._query),em(e,r._query).then(s=>new jt(t,n,r,s))}function XE(r){r=Q(r,Tt);const t=Q(r.firestore,st),e=dt(t),n=new We(t);return eE(e,r._query).then(s=>new jt(t,n,r,s))}function YE(r){r=Q(r,Tt);const t=Q(r.firestore,st),e=dt(t),n=new We(t);return em(e,r._query,{source:"server"}).then(s=>new jt(t,n,r,s))}function ZE(r,t,e){r=Q(r,nt);const n=Q(r.firestore,st),s=ao(r.converter,t,e);return Ar(n,[ro(bn(n),"setDoc",r._key,s,r.converter!==null,e).toMutation(r._key,ht.none())])}function tT(r,t,e,...n){r=Q(r,nt);const s=Q(r.firestore,st),i=bn(s);let o;return o=typeof(t=Et(t))=="string"||t instanceof Ke?Vu(i,"updateDoc",r._key,t,e,n):Pu(i,"updateDoc",r._key,t),Ar(s,[o.toMutation(r._key,ht.exists(!0))])}function eT(r){return Ar(Q(r.firestore,st),[new gr(r._key,ht.none())])}function nT(r,t){const e=Q(r.firestore,st),n=om(r),s=ao(r.converter,t);return Ar(e,[ro(bn(r.firestore),"addDoc",n._key,s,r.converter!==null,{}).toMutation(n._key,ht.exists(!1))]).then(()=>n)}function Ra(r,...t){r=Et(r);let e={includeMetadataChanges:!1,source:"default"},n=0;typeof t[n]!="object"||jn(t[n])||(e=t[n++]);const s={includeMetadataChanges:e.includeMetadataChanges,source:e.source};if(jn(t[n])){const c=t[n];t[n]=c.next?.bind(c),t[n+1]=c.error?.bind(c),t[n+2]=c.complete?.bind(c)}let i,o,u;if(r instanceof nt)o=Q(r.firestore,st),u=fr(r._key.path),i={next:c=>{t[n]&&t[n](ku(o,r,c))},error:t[n+1],complete:t[n+2]};else{const c=Q(r,Tt);o=Q(c.firestore,st),u=c._query;const h=new We(o);i={next:f=>{t[n]&&t[n](new jt(o,h,c,f))},error:t[n+1],complete:t[n+2]},Im(r._query)}return function(h,f,m,p){const v=new to(p),C=new du(f,v,m);return h.asyncQueue.enqueueAndForget(async()=>cu(await cr(h),C)),()=>{v.Nu(),h.asyncQueue.enqueueAndForget(async()=>lu(await cr(h),C))}}(dt(o),u,s,i)}function rT(r,t,...e){const n=Et(r),s=function(c){const h={bundle:"",bundleName:"",bundleSource:""},f=["bundle","bundleName","bundleSource"];for(const m of f){if(!(m in c)){h.error=`snapshotJson missing required field: ${m}`;break}const p=c[m];if(typeof p!="string"){h.error=`snapshotJson field '${m}' must be a string.`;break}if(p.length===0){h.error=`snapshotJson field '${m}' cannot be an empty string.`;break}m==="bundle"?h.bundle=p:m==="bundleName"?h.bundleName=p:m==="bundleSource"&&(h.bundleSource=p)}return h}(t);if(s.error)throw new V(R.INVALID_ARGUMENT,s.error);let i,o=0;if(typeof e[o]!="object"||jn(e[o])||(i=e[o++]),s.bundleSource==="QuerySnapshot"){let u=null;if(typeof e[o]=="object"&&jn(e[o])){const c=e[o++];u={next:c.next,error:c.error,complete:c.complete}}else u={next:e[o++],error:e[o++],complete:e[o++]};return function(h,f,m,p,v){let C,D=!1;return ba(h,f.bundle).then(()=>lm(h,f.bundleName)).then(B=>{B&&!D&&(v&&B.withConverter(v),C=Ra(B,m||{},p))}).catch(B=>(p.error&&p.error(B),()=>{})),()=>{D||(D=!0,C&&C())}}(n,s,i,u,e[o])}if(s.bundleSource==="DocumentSnapshot"){let u=null;if(typeof e[o]=="object"&&jn(e[o])){const c=e[o++];u={next:c.next,error:c.error,complete:c.complete}}else u={next:e[o++],error:e[o++],complete:e[o++]};return function(h,f,m,p,v){let C,D=!1;return ba(h,f.bundle).then(()=>
2602{if(!D){const B=new nt(h,v||null,k.fromPath(f.bundleName));C=Ra(B,m||{},p)}}).catch(B=>(p.error&&p.error(B),()=>{})),()=>{D||(D=!0,C&&C())}}(n,s,i,u,e[o])}throw new V(R.INVALID_ARGUMENT,`unsupported bundle source: ${s.bundleSource}`)}function sT(r,t){return rE(dt(r=Q(r,st)),jn(t)?t:{next:t})}function Ar(r,t){return function(n,s){const i=new Rt;return n.asyncQueue.enqueueAndForget(async()=>DI(await wu(n),s,i)),i.promise}(dt(r),t)}function ku(r,t,e){const n=e.docs.get(t._key),s=new We(r);return new qt(r,s,t._key,n,new ae(e.hasPendingWrites,e.fromCache),t.converter)}function iT(r){return bm(r,{count:Am()})}function bm(r,t){const e=Q(r.firestore,st),n=dt(e),s=ud(t,(i,o)=>new zd(o,i.aggregateType,i._internalFieldPath));return nE(n,r._query,s).then(i=>function(u,c,h){const f=new We(u);return new hm(c,f,h)}(e,r,i))}class oT{constructor(t){this.kind="memory",this._onlineComponentProvider=Be.provider,this._offlineComponentProvider=t?.garbageCollector?t.garbageCollector._offlineComponentProvider:{build:()=>new Iu(void 0)}}toJSON(){return{kind:this.kind}}}class aT{constructor(t){let e;this.kind="persistent",t?.tabManager?(t.tabManager._initialize(t),e=t.tabManager):(e=Rm(void 0),e._initialize(t)),this._onlineComponentProvider=e._onlineComponentProvider,this._offlineComponentProvider=e._offlineComponentProvider}toJSON(){return{kind:this.kind}}}class uT{constructor(){this.kind="memoryEager",this._offlineComponentProvider=ur.provider}toJSON(){return{kind:this.kind}}}class cT{constructor(t){this.kind="memoryLru",this._offlineComponentProvider={build:()=>new Iu(t)}}toJSON(){return{kind:this.kind}}}function lT(){return new uT}function hT(r){return new cT(r?.cacheSizeBytes)}function dT(r){return new oT(r)}function fT(r){return new aT(r)}class mT{constructor(t){this.forceOwnership=t,this.kind="persistentSingleTab"}toJSON(){return{kind:this.kind}}_initialize(t){this._onlineComponentProvider=Be.provider,this._offlineComponentProvider={build:e=>new Eu(e,t?.cacheSizeBytes,this.forceOwnership)}}}class gT{constructor(){this.kind="PersistentMultipleTab"}toJSON(){return{kind:this.kind}}_initialize(t){this._onlineComponentProvider=Be.provider,this._offlineComponentProvider={build:e=>new Jf(e,t?.cacheSizeBytes)}}}function Rm(r){return new mT(r?.forceOwnership)}function pT(){return new gT}/**
2603 * @license
2604 * Copyright 2022 Google LLC
2605 *
2606 * Licensed under the Apache License, Version 2.0 (the "License");
2607 * you may not use this file except in compliance with the License.
2608 * You may obtain a copy of the License at
2609 *
2610 *   http://www.apache.org/licenses/LICENSE-2.0
2611 *
2612 * Unless required by applicable law or agreed to in writing, software
2613 * distributed under the License is distributed on an "AS IS" BASIS,
2614 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2615 * See the License for the specific language governing permissions and
2616 * limitations under the License.
2617 */const _T={maxAttempts:5};/**
2618 * @license
2619 * Copyright 2020 Google LLC
2620 *
2621 * Licensed under the Apache License, Version 2.0 (the "License");
2622 * you may not use this file except in compliance with the License.
2623 * You may obtain a copy of the License at
2624 *
2625 *   http://www.apache.org/licenses/LICENSE-2.0
2626 *
2627 * Unless required by applicable law or agreed to in writing, software
2628 * distributed under the License is distributed on an "AS IS" BASIS,
2629 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2630 * See the License for the specific language governing permissions and
2631 * limitations under the License.
2632 */class Sm{constructor(t,e){this._firestore=t,this._commitHandler=e,this._mutations=[],this._committed=!1,this._dataReader=bn(t)}set(t,e,n){this._verifyNotCommitted();const s=Se(t,this._firestore),i=ao(s.converter,e,n),o=ro(this._dataReader,"WriteBatch.set",s._key,i,s.converter!==null,n);return this._mutations.push(o.toMutation(s._key,ht.none())),this}update(t,e,n,...s){this._verifyNotCommitted();const i=Se(t,this._firestore);let o;return o=typeof(e=Et(e))=="string"||e instanceof Ke?Vu(this._dataReader,"WriteBatch.update",i._key,e,n,s):Pu(this._dataReader,"WriteBatch.update",i._key,e),this._mutations.push(o.toMutation(i._key,ht.exists(!0))),this}delete(t){this._verifyNotCommitted();const e=Se(t,this._firestore);return this._mutations=this._mutations.concat(new gr(e._key,ht.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(R.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")}}function Se(r,t){if((r=Et(r)).firestore!==t)throw new V(R.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return r}/**
2633 * @license
2634 * Copyright 2020 Google LLC
2635 *
2636 * Licensed under the Apache License, Version 2.0 (the "License");
2637 * you may not use this file except in compliance with the License.
2638 * You may obtain a copy of the License at
2639 *
2640 *   http://www.apache.org/licenses/LICENSE-2.0
2641 *
2642 * Unless required by applicable law or agreed to in writing, software
2643 * distributed under the License is distributed on an "AS IS" BASIS,
2644 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2645 * See the License for the specific language governing permissions and
2646 * limitations under the License.
2647 */class yT{constructor(t,e){this._firestore=t,this._transaction=e,this._dataReader=bn(t)}get(t){const e=Se(t,this._firestore),n=new Nu(this._firestore);return this._transaction.lookup([e._key]).then(s=>{if(!s||s.length!==1)return F(24041);const i=s[0];if(i.isFoundDocument())return new Es(this._firestore,n,i.key,i,e.converter);if(i.isNoDocument())return new Es(this._firestore,n,e._key,null,e.converter);throw F(18433,{doc:i})})}set(t,e,n){const s=Se(t,this._firestore),i=ao(s.converter,e,n),o=ro(this._dataReader,"Transaction.set",s._key,i,s.converter!==null,n);return this._transaction.set(s._key,o),this}update(t,e,n,...s){const i=Se(t,this._firestore);let o;return o=typeof(e=Et(e))=="string"||e instanceof Ke?Vu(this._dataReader,"Transaction.update",i._key,e,n,s):Pu(this._dataReader,"Transaction.update",i._key,e),this._transaction.update(i._key,o),this}delete(t){const e=Se(t,this._firestore);return this._transaction.delete(e._key),this}}/**
2648 * @license
2649 * Copyright 2020 Google LLC
2650 *
2651 * Licensed under the Apache License, Version 2.0 (the "License");
2652 * you may not use this file except in compliance with the License.
2653 * You may obtain a copy of the License at
2654 *
2655 *   http://www.apache.org/licenses/LICENSE-2.0
2656 *
2657 * Unless required by applicable law or agreed to in writing, software
2658 * distributed under the License is distributed on an "AS IS" BASIS,
2659 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2660 * See the License for the specific language governing permissions and
2661 * limitations under the License.
2662 */class Pm extends yT{constructor(t,e){super(t,e),this._firestore=t}get(t){const e=Se(t,this._firestore),n=new We(this._firestore);return super.get(t).then(s=>new qt(this._firestore,n,e._key,s._document,new ae(!1,!1),e.converter))}}function IT(r,t,e){r=Q(r,st);const n={..._T,...e};return function(i){if(i.maxAttempts<1)throw new V(R.INVALID_ARGUMENT,"Max attempts must be at least 1")}(n),function(i,o,u){const c=new Rt;return i.asyncQueue.enqueueAndForget(async()=>{const h=await Zf(i);new JI(i.asyncQueue,h,u,o,c).ju()}),c.promise}(dt(r),s=>t(new Pm(r,s)),n)}/**
2663 * @license
2664 * Copyright 2020 Google LLC
2665 *
2666 * Licensed under the Apache License, Version 2.0 (the "License");
2667 * you may not use this file except in compliance with the License.
2668 * You may obtain a copy of the License at
2669 *
2670 *   http://www.apache.org/licenses/LICENSE-2.0
2671 *
2672 * Unless required by applicable law or agreed to in writing, software
2673 * distributed under the License is distributed on an "AS IS" BASIS,
2674 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2675 * See the License for the specific language governing permissions and
2676 * limitations under the License.
2677 */function ET(){return new Ds("deleteField")}function TT(){return new vu("serverTimestamp")}function wT(...r){return new bu("arrayUnion",r)}function AT(...r){return new Ru("arrayRemove",r)}function vT(r){return new Su("increment",r)}function bT(r){return new Qt(r)}/**
2678 * @license
2679 * Copyright 2020 Google LLC
2680 *
2681 * Licensed under the Apache License, Version 2.0 (the "License");
2682 * you may not use this file except in compliance with the License.
2683 * You may obtain a copy of the License at
2684 *
2685 *   http://www.apache.org/licenses/LICENSE-2.0
2686 *
2687 * Unless required by applicable law or agreed to in writing, software
2688 * distributed under the License is distributed on an "AS IS" BASIS,
2689 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2690 * See the License for the specific language governing permissions and
2691 * limitations under the License.
2692 */function RT(r){return dt(r=Q(r,st)),new Sm(r,t=>Ar(r,t))}/**
2693 * @license
2694 * Copyright 2021 Google LLC
2695 *
2696 * Licensed under the Apache License, Version 2.0 (the "License");
2697 * you may not use this file except in compliance with the License.
2698 * You may obtain a copy of the License at
2699 *
2700 *   http://www.apache.org/licenses/LICENSE-2.0
2701 *
2702 * Unless required by applicable law or agreed to in writing, software
2703 * distributed under the License is distributed on an "AS IS" BASIS,
2704 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2705 * See the License for the specific language governing permissions and
2706 * limitations under the License.
2707 */function ST(r,t){const e=dt(r=Q(r,st));if(!e._uninitializedComponentsProvider||e._uninitializedComponentsProvider._offline.kind==="memory")return $t("Cannot enable indexes when persistence is disabled"),Promise.resolve();const n=function(i){const o=typeof i=="string"?function(h){try{return JSON.parse(h)}catch(f){throw new V(R.INVALID_ARGUMENT,"Failed to parse JSON: "+f?.message)}}(i):i,u=[];if(Array.isArray(o.indexes))for(const c of o.indexes){const h=ph(c,"collectionGroup"),f=[];if(Array.isArray(c.fields))for(const m of c.fields){const p=so("setIndexConfiguration",ph(m,"fieldPath"));m.arrayConfig==="CONTAINS"?f.push(new hn(p,2)):m.order==="ASCENDING"?f.push(new hn(p,0)):m.order==="DESCENDING"&&f.push(new hn(p,1))}u.push(new Kn(Kn.UNKNOWN_ID,h,f,Qn.empty()))}return u}(t);return oE(e,n)}function ph(r,t){if(typeof r[t]!="string")throw new V(R.INVALID_ARGUMENT,"Missing string value for: "+t);return r[t]}/**
2708 * @license
2709 * Copyright 2023 Google LLC
2710 *
2711 * Licensed under the Apache License, Version 2.0 (the "License");
2712 * you may not use this file except in compliance with the License.
2713 * You may obtain a copy of the License at
2714 *
2715 *   http://www.apache.org/licenses/LICENSE-2.0
2716 *
2717 * Unless required by applicable law or agreed to in writing, software
2718 * distributed under the License is distributed on an "AS IS" BASIS,
2719 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2720 * See the License for the specific language governing permissions and
2721 * limitations under the License.
2722 */class Vm{constructor(t){this._firestore=t,this.type="PersistentCacheIndexManager"}}function PT(r){r=Q(r,st);const t=_h.get(r);if(t)return t;if(dt(r)._uninitializedComponentsProvider?._offline.kind!=="persistent")return null;const n=new Vm(r);return _h.set(r,n),n}function VT(r){Cm(r,!0)}function CT(r){Cm(r,!1)}function DT(r){uE(dt(r._firestore)).then(t=>N("deleting all persistent cache indexes succeeded")).catch(t=>$t("deleting all persistent cache indexes failed",t))}function Cm(r,t){aE(dt(r._firestore),t).then(e=>N(`setting persistent cache index auto creation isEnabled=${t} succeeded`)).catch(e=>$t(`setting persistent cache index auto creation isEnabled=${t} failed`,e))}const _h=new WeakMap;/**
2723 * @license
2724 * Copyright 2017 Google LLC
2725 *
2726 * Licensed under the Apache License, Version 2.0 (the "License");
2727 * you may not use this file except in compliance with the License.
2728 * You may obtain a copy of the License at
2729 *
2730 *   http://www.apache.org/licenses/LICENSE-2.0
2731 *
2732 * Unless required by applicable law or agreed to in writing, software
2733 * distributed under the License is distributed on an "AS IS" BASIS,
2734 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2735 * See the License for the specific language governing permissions and
2736 * limitations under the License.
2737 */function xT(r){const t=dt(Q(r.firestore,st)),e=t._onlineComponents?.datastore.serializer;return e===void 0?null:Qi(e,Nt(r._query)).ft}function NT(r,t){const e=ud(t,(i,o)=>new zd(o,i.aggregateType,i._internalFieldPath)),n=dt(Q(r.firestore,st)),s=n._onlineComponents?.datastore.serializer;return s===void 0?null:ef(s,Sd(r._query),e,!0).request}/**
2738 * @license
2739 * Copyright 2023 Google LLC
2740 *
2741 * Licensed under the Apache License, Version 2.0 (the "License");
2742 * you may not use this file except in compliance with the License.
2743 * You may obtain a copy of the License at
2744 *
2745 *   http://www.apache.org/licenses/LICENSE-2.0
2746 *
2747 * Unless required by applicable law or agreed to in writing, software
2748 * distributed under the License is distributed on an "AS IS" BASIS,
2749 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2750 * See the License for the specific language governing permissions and
2751 * limitations under the License.
2752 */class kT{constructor(){throw new Error("instances of this class should not be created")}static onExistenceFilterMismatch(t){return Mu.instance.onExistenceFilterMismatch(t)}}class Mu{constructor(){this.Mc=new Map}static get instance(){return ri||(ri=new Mu,function(e){if(da)throw new Error("a TestingHooksSpi instance is already set");da=e}(ri)),ri}lt(t){this.Mc.forEach(e=>e(t))}onExistenceFilterMismatch(t){const e=Symbol(),n=this.Mc;return n.set(e,t),()=>n.delete(e)}}let ri=null;(function(t,e=!0){(function(s){dr=s})(Cp),_i(new os("firestore",(n,{instanceIdentifier:s,options:i})=>{const o=n.getProvider("app").getImmediate(),u=new st(new Kp(n.getProvider("auth-internal")),new Hp(o,n.getProvider("app-check-internal")),function(h,f){if(!Object.prototype.hasOwnProperty.apply(h.options,["projectId"]))throw new V(R.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new ke(h.options.projectId,f)}(o,s),o);return i={useFetchStreams:e,...i},u._setSettings(i),u},"PUBLIC").setMultipleInstances(!0)),Jr(Hc,Jc,t),Jr(Hc,Jc,"esm2020")})();const $T=Object.freeze(Object.defineProperty({__proto__:null,AbstractUserDataWriter:xu,AggregateField:lr,AggregateQuerySnapshot:hm,Bytes:Ft,CACHE_SIZE_UNLIMITED:dE,CollectionReference:Ht,DocumentReference:nt,DocumentSnapshot:qt,FieldPath:Ke,FieldValue:Qe,Firestore:st,FirestoreError:V,GeoPoint:Jt,LoadBundleTask:am,PersistentCacheIndexManager:Vm,Query:Tt,QueryCompositeFilterConstraint:Sn,QueryConstraint:Tr,QueryDocumentSnapshot:is,QueryEndAtConstraint:ks,QueryFieldFilterConstraint:wr,QueryLimitConstraint:xs,QueryOrderByConstraint:oo,QuerySnapshot:jt,QueryStartAtConstraint:Ns,SnapshotMetadata:ae,Timestamp:tt,Transaction:Pm,VectorValue:Qt,WriteBatch:Sm,_AutoId:Mi,_ByteString:ft,_DatabaseId:ke,_DocumentKey:k,_EmptyAppCheckTokenProvider:Jp,_EmptyAuthCredentialsProvider:qh,_FieldPath:ct,_TestingHooks:kT,_cast:Q,_debugAssert:Gp,_internalAggregationQueryToProtoRunAggregationQueryRequest:NT,_internalQueryToProtoQueryTarget:xT,_isBase64Available:N_,_logWarn:$t,_validateIsNotUsedTogether:zh,addDoc:nT,aggregateFieldEqual:qE,aggregateQuerySnapshotEqual:jE,and:DE,arrayRemove:AT,arrayUnion:wT,average:UE,clearIndexedDbPersistence:_E,collection:cE,collectionGroup:lE,connectFirestoreEmulator:im,count:Am,deleteAllPersistentCacheIndexes:DT,deleteDoc:eT,deleteField:ET,disableNetwork:EE,disablePersistentCacheIndexAutoCreation:CT,doc:om,documentId:wE,documentSnapshotFromJSON:zE,enableIndexedDbPersistence:gE,enableMultiTabIndexedDbPersistence:pE,enableNetwork:IE,enablePersistentCacheIndexAutoCreation:VT,endAt:LE,endBefore:FE,ensureFirestoreConfigured:dt,executeWrite:Ar,getAggregateFromServer:bm,getCountFromServer:iT,getDoc:QE,getDocFromCache:WE,getDocFromServer:HE,getDocs:JE,getDocsFromCache:XE,getDocsFromServer:YE,getFirestore:mE,getPersistentCacheIndexManager:PT,increment:vT,initializeFirestore:fE,limit:NE,limitToLast:kE,loadBundle:ba,memoryEagerGarbageCollector:lT,memoryLocalCache:dT,memoryLruGarbageCollector:hT,namedQuery:lm,onSnapshot:Ra,onSnapshotResume:rT,onSnapshotsInSync:sT,or:CE,orderBy:xE,persistentLocalCache:fT,persistentMultipleTabManager:pT,persistentSingleTabManager:Rm,query:PE,queryEqual:Au,querySnapshotFromJSON:GE,refEqual:hE,runTransaction:IT,serverTimestamp:TT,setDoc:ZE,setIndexConfiguration:ST,setLogLevel:zp,snapshotEqual:KE,startAfter:OE,startAt:ME,sum:BE,terminate:TE,updateDoc:tT,vector:bT,waitForPendingWrites:yE,where:VE,writeBatch:RT},Symbol.toStringTag,{value:"Module"}));export{os as C,Sh as E,hr as F,Ph as L,Cp as S,Pa as _,MT as a,_g as b,Et as c,xe as d,zn as e,UT as f,xp as g,Sp as h,ki as i,qT as j,OT as k,BT as l,X as m,LT as n,fg as o,wh as p,jT as q,Jr as r,FT as s,_i as t,Ag as u,zT as v,mE as w,Dp as x,$T as y};

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.