@chem-po/web-demo 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/dist/assets/Color-YHDXOIA2-DWRr93aM.js +1 -0
  2. package/dist/assets/DocsRenderer-CFRXHY34-D0gfqDQU.js +575 -0
  3. package/dist/assets/ExampleItemView-C7wLqYnj.js +1 -0
  4. package/dist/assets/FirebaseList.stories-CcgPPh8J.js +5 -0
  5. package/dist/assets/MobileFrame.stories-LQM_KmWY.js +13 -0
  6. package/dist/assets/Playground.stories-BWtnuY6m.js +1 -0
  7. package/dist/assets/chunk-XP5HYGXS-BpfKkqn7.js +1 -0
  8. package/dist/assets/entry-preview-Dtem_WmJ.js +2 -0
  9. package/dist/assets/entry-preview-docs-DJtt7OkJ.js +46 -0
  10. package/dist/assets/iframe-rmaPNljy.js +211 -0
  11. package/dist/assets/index-ChEI-nsM.js +1 -0
  12. package/dist/assets/index-Ci6h_Amb.js +240 -0
  13. package/dist/assets/index-DRjF_FHU.js +9 -0
  14. package/dist/assets/index-DrFu-skq.js +6 -0
  15. package/dist/assets/index-DxqO1ZJV.js +615 -0
  16. package/dist/assets/index-FTTXbSiM.js +8 -0
  17. package/dist/assets/index-iW6a2TEn.js +24 -0
  18. package/dist/assets/index-xnLS8IQ8.js +3601 -0
  19. package/dist/assets/jsx-runtime-DiklIkkE.js +9 -0
  20. package/dist/assets/list-WXUHTQch.js +10 -0
  21. package/dist/assets/preview-B8lJiyuQ.js +34 -0
  22. package/dist/assets/preview-BWzBA1C2.js +396 -0
  23. package/dist/assets/preview-CPX9RCe3.js +1 -0
  24. package/dist/assets/preview-CvbIS5ZJ.js +1 -0
  25. package/dist/assets/preview-D6hsmN8L.js +2 -0
  26. package/dist/assets/preview-DD_OYowb.js +1 -0
  27. package/dist/assets/preview-DGUiP6tS.js +7 -0
  28. package/dist/assets/preview-DHQbi4pV.js +1 -0
  29. package/dist/assets/preview-DuTa5VuS.js +295 -0
  30. package/dist/assets/preview-ik5anPOD.js +1 -0
  31. package/dist/assets/react-18-BPkW-q1l.js +1 -0
  32. package/dist/assets/test-utils-DNRP7T0w.js +9 -0
  33. package/dist/assets/tiny-invariant-CopsF_GD.js +1 -0
  34. package/dist/favicon.svg +1 -0
  35. package/dist/icons/Soundcloud_logo.svg +53 -0
  36. package/dist/icons/description.svg +1 -0
  37. package/dist/icons/explore.svg +1 -0
  38. package/dist/icons/facebook.svg +17 -0
  39. package/dist/icons/google.svg +1 -0
  40. package/dist/icons/grid_view.svg +1 -0
  41. package/dist/icons/home.svg +1 -0
  42. package/dist/icons/image.svg +1 -0
  43. package/dist/icons/instagram.svg +1 -0
  44. package/dist/icons/list.svg +1 -0
  45. package/dist/icons/open_in_full.svg +1 -0
  46. package/dist/icons/pdf.svg +23 -0
  47. package/dist/icons/soundcloud-logo.svg +2 -0
  48. package/dist/icons/soundcloud.svg +17 -0
  49. package/dist/icons/tune.svg +1 -0
  50. package/dist/icons/twitch.svg +11 -0
  51. package/dist/icons/twitter.svg +4 -0
  52. package/dist/icons/youtube.svg +20 -0
  53. package/dist/icons/zip.svg +1 -0
  54. package/dist/iframe.html +696 -0
  55. package/dist/index.html +193 -0
  56. package/dist/index.json +1 -0
  57. package/dist/nunito-sans-bold-italic.woff2 +0 -0
  58. package/dist/nunito-sans-bold.woff2 +0 -0
  59. package/dist/nunito-sans-italic.woff2 +0 -0
  60. package/dist/nunito-sans-regular.woff2 +0 -0
  61. package/dist/project.json +1 -0
  62. package/dist/sb-addons/chromatic-com-storybook-10/manager-bundle.js +331 -0
  63. package/dist/sb-addons/chromatic-com-storybook-10/manager-bundle.js.LEGAL.txt +51 -0
  64. package/dist/sb-addons/essentials-actions-3/manager-bundle.js +3 -0
  65. package/dist/sb-addons/essentials-backgrounds-5/manager-bundle.js +12 -0
  66. package/dist/sb-addons/essentials-controls-2/manager-bundle.js +402 -0
  67. package/dist/sb-addons/essentials-docs-4/manager-bundle.js +242 -0
  68. package/dist/sb-addons/essentials-measure-8/manager-bundle.js +3 -0
  69. package/dist/sb-addons/essentials-outline-9/manager-bundle.js +3 -0
  70. package/dist/sb-addons/essentials-toolbars-7/manager-bundle.js +3 -0
  71. package/dist/sb-addons/essentials-viewport-6/manager-bundle.js +3 -0
  72. package/dist/sb-addons/interactions-11/manager-bundle.js +222 -0
  73. package/dist/sb-addons/links-1/manager-bundle.js +3 -0
  74. package/dist/sb-addons/remix-react-router-12/manager-bundle.js +7 -0
  75. package/dist/sb-addons/storybook-core-core-server-presets-0/common-manager-bundle.js +3 -0
  76. package/dist/sb-common-assets/favicon.svg +1 -0
  77. package/dist/sb-common-assets/nunito-sans-bold-italic.woff2 +0 -0
  78. package/dist/sb-common-assets/nunito-sans-bold.woff2 +0 -0
  79. package/dist/sb-common-assets/nunito-sans-italic.woff2 +0 -0
  80. package/dist/sb-common-assets/nunito-sans-regular.woff2 +0 -0
  81. package/dist/sb-manager/globals-module-info.js +1051 -0
  82. package/dist/sb-manager/globals-runtime.js +41591 -0
  83. package/dist/sb-manager/globals.js +48 -0
  84. package/dist/sb-manager/runtime.js +12048 -0
  85. package/package.json +6 -7
@@ -0,0 +1,3601 @@
1
+ import{x as zf,_ as wo,z as Ht,k as Gf,y as Wf}from"./index-DxqO1ZJV.js";import{r as nt}from"./index-DRjF_FHU.js";import{j as Kf}from"./jsx-runtime-DiklIkkE.js";const Qf=()=>{};var kc={};/**
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 hl=function(n){const e=[];let t=0;for(let r=0;r<n.length;r++){let s=n.charCodeAt(r);s<128?e[t++]=s:s<2048?(e[t++]=s>>6|192,e[t++]=s&63|128):(s&64512)===55296&&r+1<n.length&&(n.charCodeAt(r+1)&64512)===56320?(s=65536+((s&1023)<<10)+(n.charCodeAt(++r)&1023),e[t++]=s>>18|240,e[t++]=s>>12&63|128,e[t++]=s>>6&63|128,e[t++]=s&63|128):(e[t++]=s>>12|224,e[t++]=s>>6&63|128,e[t++]=s&63|128)}return e},Xf=function(n){const e=[];let t=0,r=0;for(;t<n.length;){const s=n[t++];if(s<128)e[r++]=String.fromCharCode(s);else if(s>191&&s<224){const i=n[t++];e[r++]=String.fromCharCode((s&31)<<6|i&63)}else if(s>239&&s<365){const i=n[t++],a=n[t++],c=n[t++],l=((s&7)<<18|(i&63)<<12|(a&63)<<6|c&63)-65536;e[r++]=String.fromCharCode(55296+(l>>10)),e[r++]=String.fromCharCode(56320+(l&1023))}else{const i=n[t++],a=n[t++];e[r++]=String.fromCharCode((s&15)<<12|(i&63)<<6|a&63)}}return e.join("")},dl={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:typeof atob=="function",encodeByteArray(n,e){if(!Array.isArray(n))throw Error("encodeByteArray takes an array as a parameter");this.init_();const t=e?this.byteToCharMapWebSafe_:this.byteToCharMap_,r=[];for(let s=0;s<n.length;s+=3){const i=n[s],a=s+1<n.length,c=a?n[s+1]:0,l=s+2<n.length,d=l?n[s+2]:0,f=i>>2,m=(i&3)<<4|c>>4;let E=(c&15)<<2|d>>6,R=d&63;l||(R=64,a||(E=64)),r.push(t[f],t[m],t[E],t[R])}return r.join("")},encodeString(n,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(n):this.encodeByteArray(hl(n),e)},decodeString(n,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(n):Xf(this.decodeStringToByteArray(n,e))},decodeStringToByteArray(n,e){this.init_();const t=e?this.charToByteMapWebSafe_:this.charToByteMap_,r=[];for(let s=0;s<n.length;){const i=t[n.charAt(s++)],c=s<n.length?t[n.charAt(s)]:0;++s;const d=s<n.length?t[n.charAt(s)]:64;++s;const m=s<n.length?t[n.charAt(s)]:64;if(++s,i==null||c==null||d==null||m==null)throw new Jf;const E=i<<2|c>>4;if(r.push(E),d!==64){const R=c<<4&240|d>>2;if(r.push(R),m!==64){const C=d<<6&192|m;r.push(C)}}}return r},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let n=0;n<this.ENCODED_VALS.length;n++)this.byteToCharMap_[n]=this.ENCODED_VALS.charAt(n),this.charToByteMap_[this.byteToCharMap_[n]]=n,this.byteToCharMapWebSafe_[n]=this.ENCODED_VALS_WEBSAFE.charAt(n),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[n]]=n,n>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(n)]=n,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(n)]=n)}}};class Jf extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}const Yf=function(n){const e=hl(n);return dl.encodeByteArray(e,!0)},vs=function(n){return Yf(n).replace(/\./g,"")},fl=function(n){try{return dl.decodeString(n,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};/**
17
+ * @license
18
+ * Copyright 2022 Google LLC
19
+ *
20
+ * Licensed under the Apache License, Version 2.0 (the "License");
21
+ * you may not use this file except in compliance with the License.
22
+ * You may obtain a copy of the License at
23
+ *
24
+ * http://www.apache.org/licenses/LICENSE-2.0
25
+ *
26
+ * Unless required by applicable law or agreed to in writing, software
27
+ * distributed under the License is distributed on an "AS IS" BASIS,
28
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29
+ * See the License for the specific language governing permissions and
30
+ * limitations under the License.
31
+ */function Zf(){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 ep=()=>Zf().__FIREBASE_DEFAULTS__,tp=()=>{if(typeof process>"u"||typeof kc>"u")return;const n=kc.__FIREBASE_DEFAULTS__;if(n)return JSON.parse(n)},np=()=>{if(typeof document>"u")return;let n;try{n=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch{return}const e=n&&fl(n[1]);return e&&JSON.parse(e)},zs=()=>{try{return Qf()||ep()||tp()||np()}catch(n){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${n}`);return}},pl=n=>{var e,t;return(t=(e=zs())===null||e===void 0?void 0:e.emulatorHosts)===null||t===void 0?void 0:t[n]},Ao=n=>{const e=pl(n);if(!e)return;const t=e.lastIndexOf(":");if(t<=0||t+1===e.length)throw new Error(`Invalid host ${e} with no separate hostname and port!`);const r=parseInt(e.substring(t+1),10);return e[0]==="["?[e.substring(1,t-1),r]:[e.substring(0,t),r]},ml=()=>{var n;return(n=zs())===null||n===void 0?void 0:n.config},gl=n=>{var e;return(e=zs())===null||e===void 0?void 0:e[`_${n}`]};/**
47
+ * @license
48
+ * Copyright 2017 Google LLC
49
+ *
50
+ * Licensed under the Apache License, Version 2.0 (the "License");
51
+ * you may not use this file except in compliance with the License.
52
+ * You may obtain a copy of the License at
53
+ *
54
+ * http://www.apache.org/licenses/LICENSE-2.0
55
+ *
56
+ * Unless required by applicable law or agreed to in writing, software
57
+ * distributed under the License is distributed on an "AS IS" BASIS,
58
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
59
+ * See the License for the specific language governing permissions and
60
+ * limitations under the License.
61
+ */class rp{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}wrapCallback(e){return(t,r)=>{t?this.reject(t):this.resolve(r),typeof e=="function"&&(this.promise.catch(()=>{}),e.length===1?e(t):e(t,r))}}}/**
62
+ * @license
63
+ * Copyright 2021 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 _l(n,e){if(n.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');const t={alg:"none",type:"JWT"},r=e||"demo-project",s=n.iat||0,i=n.sub||n.user_id;if(!i)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const a=Object.assign({iss:`https://securetoken.google.com/${r}`,aud:r,iat:s,exp:s+3600,auth_time:s,sub:i,user_id:i,firebase:{sign_in_provider:"custom",identities:{}}},n);return[vs(JSON.stringify(t)),vs(JSON.stringify(a)),""].join(".")}/**
77
+ * @license
78
+ * Copyright 2017 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 we(){return typeof navigator<"u"&&typeof navigator.userAgent=="string"?navigator.userAgent:""}function sp(){return typeof window<"u"&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(we())}function ip(){var n;const e=(n=zs())===null||n===void 0?void 0:n.forceEnvironment;if(e==="node")return!0;if(e==="browser")return!1;try{return Object.prototype.toString.call(global.process)==="[object process]"}catch{return!1}}function op(){return typeof navigator<"u"&&navigator.userAgent==="Cloudflare-Workers"}function ap(){const n=typeof chrome=="object"?chrome.runtime:typeof browser=="object"?browser.runtime:void 0;return typeof n=="object"&&n.id!==void 0}function cp(){return typeof navigator=="object"&&navigator.product==="ReactNative"}function up(){const n=we();return n.indexOf("MSIE ")>=0||n.indexOf("Trident/")>=0}function lp(){return!ip()&&!!navigator.userAgent&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}function hp(){try{return typeof indexedDB=="object"}catch{return!1}}function dp(){return new Promise((n,e)=>{try{let t=!0;const r="validate-browser-context-for-indexeddb-analytics-module",s=self.indexedDB.open(r);s.onsuccess=()=>{s.result.close(),t||self.indexedDB.deleteDatabase(r),n(!0)},s.onupgradeneeded=()=>{t=!1},s.onerror=()=>{var i;e(((i=s.error)===null||i===void 0?void 0:i.message)||"")}}catch(t){e(t)}})}/**
92
+ * @license
93
+ * Copyright 2017 Google LLC
94
+ *
95
+ * Licensed under the Apache License, Version 2.0 (the "License");
96
+ * you may not use this file except in compliance with the License.
97
+ * You may obtain a copy of the License at
98
+ *
99
+ * http://www.apache.org/licenses/LICENSE-2.0
100
+ *
101
+ * Unless required by applicable law or agreed to in writing, software
102
+ * distributed under the License is distributed on an "AS IS" BASIS,
103
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
104
+ * See the License for the specific language governing permissions and
105
+ * limitations under the License.
106
+ */const fp="FirebaseError";class He extends Error{constructor(e,t,r){super(t),this.code=e,this.customData=r,this.name=fp,Object.setPrototypeOf(this,He.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,Rr.prototype.create)}}class Rr{constructor(e,t,r){this.service=e,this.serviceName=t,this.errors=r}create(e,...t){const r=t[0]||{},s=`${this.service}/${e}`,i=this.errors[e],a=i?pp(i,r):"Error",c=`${this.serviceName}: ${a} (${s}).`;return new He(s,c,r)}}function pp(n,e){return n.replace(mp,(t,r)=>{const s=e[r];return s!=null?String(s):`<${r}?>`})}const mp=/\{\$([^}]+)}/g;function gp(n){for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e))return!1;return!0}function Qt(n,e){if(n===e)return!0;const t=Object.keys(n),r=Object.keys(e);for(const s of t){if(!r.includes(s))return!1;const i=n[s],a=e[s];if(Nc(i)&&Nc(a)){if(!Qt(i,a))return!1}else if(i!==a)return!1}for(const s of r)if(!t.includes(s))return!1;return!0}function Nc(n){return n!==null&&typeof n=="object"}/**
107
+ * @license
108
+ * Copyright 2017 Google LLC
109
+ *
110
+ * Licensed under the Apache License, Version 2.0 (the "License");
111
+ * you may not use this file except in compliance with the License.
112
+ * You may obtain a copy of the License at
113
+ *
114
+ * http://www.apache.org/licenses/LICENSE-2.0
115
+ *
116
+ * Unless required by applicable law or agreed to in writing, software
117
+ * distributed under the License is distributed on an "AS IS" BASIS,
118
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
119
+ * See the License for the specific language governing permissions and
120
+ * limitations under the License.
121
+ */function br(n){const e=[];for(const[t,r]of Object.entries(n))Array.isArray(r)?r.forEach(s=>{e.push(encodeURIComponent(t)+"="+encodeURIComponent(s))}):e.push(encodeURIComponent(t)+"="+encodeURIComponent(r));return e.length?"&"+e.join("&"):""}function sr(n){const e={};return n.replace(/^\?/,"").split("&").forEach(r=>{if(r){const[s,i]=r.split("=");e[decodeURIComponent(s)]=decodeURIComponent(i)}}),e}function ir(n){const e=n.indexOf("?");if(!e)return"";const t=n.indexOf("#",e);return n.substring(e,t>0?t:void 0)}function _p(n,e){const t=new yp(n,e);return t.subscribe.bind(t)}class yp{constructor(e,t){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=t,this.task.then(()=>{e(this)}).catch(r=>{this.error(r)})}next(e){this.forEachObserver(t=>{t.next(e)})}error(e){this.forEachObserver(t=>{t.error(e)}),this.close(e)}complete(){this.forEachObserver(e=>{e.complete()}),this.close()}subscribe(e,t,r){let s;if(e===void 0&&t===void 0&&r===void 0)throw new Error("Missing Observer.");Tp(e,["next","error","complete"])?s=e:s={next:e,error:t,complete:r},s.next===void 0&&(s.next=qi),s.error===void 0&&(s.error=qi),s.complete===void 0&&(s.complete=qi);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(e){this.observers===void 0||this.observers[e]===void 0||(delete this.observers[e],this.observerCount-=1,this.observerCount===0&&this.onNoObservers!==void 0&&this.onNoObservers(this))}forEachObserver(e){if(!this.finalized)for(let t=0;t<this.observers.length;t++)this.sendOne(t,e)}sendOne(e,t){this.task.then(()=>{if(this.observers!==void 0&&this.observers[e]!==void 0)try{t(this.observers[e])}catch(r){typeof console<"u"&&console.error&&console.error(r)}})}close(e){this.finalized||(this.finalized=!0,e!==void 0&&(this.finalError=e),this.task.then(()=>{this.observers=void 0,this.onNoObservers=void 0}))}}function Tp(n,e){if(typeof n!="object"||n===null)return!1;for(const t of e)if(t in n&&typeof n[t]=="function")return!0;return!1}function qi(){}/**
122
+ * @license
123
+ * Copyright 2021 Google LLC
124
+ *
125
+ * Licensed under the Apache License, Version 2.0 (the "License");
126
+ * you may not use this file except in compliance with the License.
127
+ * You may obtain a copy of the License at
128
+ *
129
+ * http://www.apache.org/licenses/LICENSE-2.0
130
+ *
131
+ * Unless required by applicable law or agreed to in writing, software
132
+ * distributed under the License is distributed on an "AS IS" BASIS,
133
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
134
+ * See the License for the specific language governing permissions and
135
+ * limitations under the License.
136
+ */function Z(n){return n&&n._delegate?n._delegate:n}class ut{constructor(e,t,r){this.name=e,this.instanceFactory=t,this.type=r,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(e){return this.instantiationMode=e,this}setMultipleInstances(e){return this.multipleInstances=e,this}setServiceProps(e){return this.serviceProps=e,this}setInstanceCreatedCallback(e){return this.onInstanceCreated=e,this}}/**
137
+ * @license
138
+ * Copyright 2019 Google LLC
139
+ *
140
+ * Licensed under the Apache License, Version 2.0 (the "License");
141
+ * you may not use this file except in compliance with the License.
142
+ * You may obtain a copy of the License at
143
+ *
144
+ * http://www.apache.org/licenses/LICENSE-2.0
145
+ *
146
+ * Unless required by applicable law or agreed to in writing, software
147
+ * distributed under the License is distributed on an "AS IS" BASIS,
148
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
149
+ * See the License for the specific language governing permissions and
150
+ * limitations under the License.
151
+ */const zt="[DEFAULT]";/**
152
+ * @license
153
+ * Copyright 2019 Google LLC
154
+ *
155
+ * Licensed under the Apache License, Version 2.0 (the "License");
156
+ * you may not use this file except in compliance with the License.
157
+ * You may obtain a copy of the License at
158
+ *
159
+ * http://www.apache.org/licenses/LICENSE-2.0
160
+ *
161
+ * Unless required by applicable law or agreed to in writing, software
162
+ * distributed under the License is distributed on an "AS IS" BASIS,
163
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
164
+ * See the License for the specific language governing permissions and
165
+ * limitations under the License.
166
+ */class Ep{constructor(e,t){this.name=e,this.container=t,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(e){const t=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(t)){const r=new rp;if(this.instancesDeferred.set(t,r),this.isInitialized(t)||this.shouldAutoInitialize())try{const s=this.getOrInitializeService({instanceIdentifier:t});s&&r.resolve(s)}catch{}}return this.instancesDeferred.get(t).promise}getImmediate(e){var t;const r=this.normalizeInstanceIdentifier(e==null?void 0:e.identifier),s=(t=e==null?void 0:e.optional)!==null&&t!==void 0?t:!1;if(this.isInitialized(r)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:r})}catch(i){if(s)return null;throw i}else{if(s)return null;throw Error(`Service ${this.name} is not available`)}}getComponent(){return this.component}setComponent(e){if(e.name!==this.name)throw Error(`Mismatching Component ${e.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=e,!!this.shouldAutoInitialize()){if(Ip(e))try{this.getOrInitializeService({instanceIdentifier:zt})}catch{}for(const[t,r]of this.instancesDeferred.entries()){const s=this.normalizeInstanceIdentifier(t);try{const i=this.getOrInitializeService({instanceIdentifier:s});r.resolve(i)}catch{}}}}clearInstance(e=zt){this.instancesDeferred.delete(e),this.instancesOptions.delete(e),this.instances.delete(e)}async delete(){const e=Array.from(this.instances.values());await Promise.all([...e.filter(t=>"INTERNAL"in t).map(t=>t.INTERNAL.delete()),...e.filter(t=>"_delete"in t).map(t=>t._delete())])}isComponentSet(){return this.component!=null}isInitialized(e=zt){return this.instances.has(e)}getOptions(e=zt){return this.instancesOptions.get(e)||{}}initialize(e={}){const{options:t={}}=e,r=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(r))throw Error(`${this.name}(${r}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const s=this.getOrInitializeService({instanceIdentifier:r,options:t});for(const[i,a]of this.instancesDeferred.entries()){const c=this.normalizeInstanceIdentifier(i);r===c&&a.resolve(s)}return s}onInit(e,t){var r;const s=this.normalizeInstanceIdentifier(t),i=(r=this.onInitCallbacks.get(s))!==null&&r!==void 0?r:new Set;i.add(e),this.onInitCallbacks.set(s,i);const a=this.instances.get(s);return a&&e(a,s),()=>{i.delete(e)}}invokeOnInitCallbacks(e,t){const r=this.onInitCallbacks.get(t);if(r)for(const s of r)try{s(e,t)}catch{}}getOrInitializeService({instanceIdentifier:e,options:t={}}){let r=this.instances.get(e);if(!r&&this.component&&(r=this.component.instanceFactory(this.container,{instanceIdentifier:vp(e),options:t}),this.instances.set(e,r),this.instancesOptions.set(e,t),this.invokeOnInitCallbacks(r,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,r)}catch{}return r||null}normalizeInstanceIdentifier(e=zt){return this.component?this.component.multipleInstances?e:zt:e}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!=="EXPLICIT"}}function vp(n){return n===zt?void 0:n}function Ip(n){return n.instantiationMode==="EAGER"}/**
167
+ * @license
168
+ * Copyright 2019 Google LLC
169
+ *
170
+ * Licensed under the Apache License, Version 2.0 (the "License");
171
+ * you may not use this file except in compliance with the License.
172
+ * You may obtain a copy of the License at
173
+ *
174
+ * http://www.apache.org/licenses/LICENSE-2.0
175
+ *
176
+ * Unless required by applicable law or agreed to in writing, software
177
+ * distributed under the License is distributed on an "AS IS" BASIS,
178
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
179
+ * See the License for the specific language governing permissions and
180
+ * limitations under the License.
181
+ */class wp{constructor(e){this.name=e,this.providers=new Map}addComponent(e){const t=this.getProvider(e.name);if(t.isComponentSet())throw new Error(`Component ${e.name} has already been registered with ${this.name}`);t.setComponent(e)}addOrOverwriteComponent(e){this.getProvider(e.name).isComponentSet()&&this.providers.delete(e.name),this.addComponent(e)}getProvider(e){if(this.providers.has(e))return this.providers.get(e);const t=new Ep(e,this);return this.providers.set(e,t),t}getProviders(){return Array.from(this.providers.values())}}/**
182
+ * @license
183
+ * Copyright 2017 Google LLC
184
+ *
185
+ * Licensed under the Apache License, Version 2.0 (the "License");
186
+ * you may not use this file except in compliance with the License.
187
+ * You may obtain a copy of the License at
188
+ *
189
+ * http://www.apache.org/licenses/LICENSE-2.0
190
+ *
191
+ * Unless required by applicable law or agreed to in writing, software
192
+ * distributed under the License is distributed on an "AS IS" BASIS,
193
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
194
+ * See the License for the specific language governing permissions and
195
+ * limitations under the License.
196
+ */var z;(function(n){n[n.DEBUG=0]="DEBUG",n[n.VERBOSE=1]="VERBOSE",n[n.INFO=2]="INFO",n[n.WARN=3]="WARN",n[n.ERROR=4]="ERROR",n[n.SILENT=5]="SILENT"})(z||(z={}));const Ap={debug:z.DEBUG,verbose:z.VERBOSE,info:z.INFO,warn:z.WARN,error:z.ERROR,silent:z.SILENT},Rp=z.INFO,bp={[z.DEBUG]:"log",[z.VERBOSE]:"log",[z.INFO]:"info",[z.WARN]:"warn",[z.ERROR]:"error"},Pp=(n,e,...t)=>{if(e<n.logLevel)return;const r=new Date().toISOString(),s=bp[e];if(s)console[s](`[${r}] ${n.name}:`,...t);else throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`)};class Ro{constructor(e){this.name=e,this._logLevel=Rp,this._logHandler=Pp,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in z))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel=typeof e=="string"?Ap[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if(typeof e!="function")throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e}get userLogHandler(){return this._userLogHandler}set userLogHandler(e){this._userLogHandler=e}debug(...e){this._userLogHandler&&this._userLogHandler(this,z.DEBUG,...e),this._logHandler(this,z.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,z.VERBOSE,...e),this._logHandler(this,z.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,z.INFO,...e),this._logHandler(this,z.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,z.WARN,...e),this._logHandler(this,z.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,z.ERROR,...e),this._logHandler(this,z.ERROR,...e)}}/**
197
+ * @license
198
+ * Copyright 2019 Google LLC
199
+ *
200
+ * Licensed under the Apache License, Version 2.0 (the "License");
201
+ * you may not use this file except in compliance with the License.
202
+ * You may obtain a copy of the License at
203
+ *
204
+ * http://www.apache.org/licenses/LICENSE-2.0
205
+ *
206
+ * Unless required by applicable law or agreed to in writing, software
207
+ * distributed under the License is distributed on an "AS IS" BASIS,
208
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
209
+ * See the License for the specific language governing permissions and
210
+ * limitations under the License.
211
+ */class Sp{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(t=>{if(Cp(t)){const r=t.getImmediate();return`${r.library}/${r.version}`}else return null}).filter(t=>t).join(" ")}}function Cp(n){const e=n.getComponent();return(e==null?void 0:e.type)==="VERSION"}const Yi="@firebase/app",Dc="0.11.4";/**
212
+ * @license
213
+ * Copyright 2019 Google LLC
214
+ *
215
+ * Licensed under the Apache License, Version 2.0 (the "License");
216
+ * you may not use this file except in compliance with the License.
217
+ * You may obtain a copy of the License at
218
+ *
219
+ * http://www.apache.org/licenses/LICENSE-2.0
220
+ *
221
+ * Unless required by applicable law or agreed to in writing, software
222
+ * distributed under the License is distributed on an "AS IS" BASIS,
223
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
224
+ * See the License for the specific language governing permissions and
225
+ * limitations under the License.
226
+ */const lt=new Ro("@firebase/app"),kp="@firebase/app-compat",Np="@firebase/analytics-compat",Dp="@firebase/analytics",Op="@firebase/app-check-compat",Vp="@firebase/app-check",Lp="@firebase/auth",Mp="@firebase/auth-compat",xp="@firebase/database",Up="@firebase/data-connect",Fp="@firebase/database-compat",Bp="@firebase/functions",qp="@firebase/functions-compat",$p="@firebase/installations",jp="@firebase/installations-compat",Hp="@firebase/messaging",zp="@firebase/messaging-compat",Gp="@firebase/performance",Wp="@firebase/performance-compat",Kp="@firebase/remote-config",Qp="@firebase/remote-config-compat",Xp="@firebase/storage",Jp="@firebase/storage-compat",Yp="@firebase/firestore",Zp="@firebase/vertexai",em="@firebase/firestore-compat",tm="firebase",nm="11.6.0";/**
227
+ * @license
228
+ * Copyright 2019 Google LLC
229
+ *
230
+ * Licensed under the Apache License, Version 2.0 (the "License");
231
+ * you may not use this file except in compliance with the License.
232
+ * You may obtain a copy of the License at
233
+ *
234
+ * http://www.apache.org/licenses/LICENSE-2.0
235
+ *
236
+ * Unless required by applicable law or agreed to in writing, software
237
+ * distributed under the License is distributed on an "AS IS" BASIS,
238
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
239
+ * See the License for the specific language governing permissions and
240
+ * limitations under the License.
241
+ */const Zi="[DEFAULT]",rm={[Yi]:"fire-core",[kp]:"fire-core-compat",[Dp]:"fire-analytics",[Np]:"fire-analytics-compat",[Vp]:"fire-app-check",[Op]:"fire-app-check-compat",[Lp]:"fire-auth",[Mp]:"fire-auth-compat",[xp]:"fire-rtdb",[Up]:"fire-data-connect",[Fp]:"fire-rtdb-compat",[Bp]:"fire-fn",[qp]:"fire-fn-compat",[$p]:"fire-iid",[jp]:"fire-iid-compat",[Hp]:"fire-fcm",[zp]:"fire-fcm-compat",[Gp]:"fire-perf",[Wp]:"fire-perf-compat",[Kp]:"fire-rc",[Qp]:"fire-rc-compat",[Xp]:"fire-gcs",[Jp]:"fire-gcs-compat",[Yp]:"fire-fst",[em]:"fire-fst-compat",[Zp]:"fire-vertex","fire-js":"fire-js",[tm]:"fire-js-all"};/**
242
+ * @license
243
+ * Copyright 2019 Google LLC
244
+ *
245
+ * Licensed under the Apache License, Version 2.0 (the "License");
246
+ * you may not use this file except in compliance with the License.
247
+ * You may obtain a copy of the License at
248
+ *
249
+ * http://www.apache.org/licenses/LICENSE-2.0
250
+ *
251
+ * Unless required by applicable law or agreed to in writing, software
252
+ * distributed under the License is distributed on an "AS IS" BASIS,
253
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
254
+ * See the License for the specific language governing permissions and
255
+ * limitations under the License.
256
+ */const Is=new Map,sm=new Map,eo=new Map;function Oc(n,e){try{n.container.addComponent(e)}catch(t){lt.debug(`Component ${e.name} failed to register with FirebaseApp ${n.name}`,t)}}function St(n){const e=n.name;if(eo.has(e))return lt.debug(`There were multiple attempts to register component ${e}.`),!1;eo.set(e,n);for(const t of Is.values())Oc(t,n);for(const t of sm.values())Oc(t,n);return!0}function Pr(n,e){const t=n.container.getProvider("heartbeat").getImmediate({optional:!0});return t&&t.triggerHeartbeat(),n.container.getProvider(e)}function Pe(n){return n==null?!1:n.settings!==void 0}/**
257
+ * @license
258
+ * Copyright 2019 Google LLC
259
+ *
260
+ * Licensed under the Apache License, Version 2.0 (the "License");
261
+ * you may not use this file except in compliance with the License.
262
+ * You may obtain a copy of the License at
263
+ *
264
+ * http://www.apache.org/licenses/LICENSE-2.0
265
+ *
266
+ * Unless required by applicable law or agreed to in writing, software
267
+ * distributed under the License is distributed on an "AS IS" BASIS,
268
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
269
+ * See the License for the specific language governing permissions and
270
+ * limitations under the License.
271
+ */const im={"no-app":"No Firebase App '{$appName}' has been created - call initializeApp() first","bad-app-name":"Illegal App name: '{$appName}'","duplicate-app":"Firebase App named '{$appName}' already exists with different options or config","app-deleted":"Firebase App named '{$appName}' already deleted","server-app-deleted":"Firebase Server App has been deleted","no-options":"Need to provide options, when not being deployed to hosting via source.","invalid-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance.","invalid-log-argument":"First argument to `onLog` must be null or a function.","idb-open":"Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.","idb-get":"Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.","idb-set":"Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.","idb-delete":"Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.","finalization-registry-not-supported":"FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.","invalid-server-app-environment":"FirebaseServerApp is not for use in browser environments."},Rt=new Rr("app","Firebase",im);/**
272
+ * @license
273
+ * Copyright 2019 Google LLC
274
+ *
275
+ * Licensed under the Apache License, Version 2.0 (the "License");
276
+ * you may not use this file except in compliance with the License.
277
+ * You may obtain a copy of the License at
278
+ *
279
+ * http://www.apache.org/licenses/LICENSE-2.0
280
+ *
281
+ * Unless required by applicable law or agreed to in writing, software
282
+ * distributed under the License is distributed on an "AS IS" BASIS,
283
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
284
+ * See the License for the specific language governing permissions and
285
+ * limitations under the License.
286
+ */class om{constructor(e,t,r){this._isDeleted=!1,this._options=Object.assign({},e),this._config=Object.assign({},t),this._name=t.name,this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled,this._container=r,this.container.addComponent(new ut("app",()=>this,"PUBLIC"))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(e){this.checkDestroyed(),this._automaticDataCollectionEnabled=e}get name(){return this.checkDestroyed(),this._name}get options(){return this.checkDestroyed(),this._options}get config(){return this.checkDestroyed(),this._config}get container(){return this._container}get isDeleted(){return this._isDeleted}set isDeleted(e){this._isDeleted=e}checkDestroyed(){if(this.isDeleted)throw Rt.create("app-deleted",{appName:this._name})}}/**
287
+ * @license
288
+ * Copyright 2019 Google LLC
289
+ *
290
+ * Licensed under the Apache License, Version 2.0 (the "License");
291
+ * you may not use this file except in compliance with the License.
292
+ * You may obtain a copy of the License at
293
+ *
294
+ * http://www.apache.org/licenses/LICENSE-2.0
295
+ *
296
+ * Unless required by applicable law or agreed to in writing, software
297
+ * distributed under the License is distributed on an "AS IS" BASIS,
298
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
299
+ * See the License for the specific language governing permissions and
300
+ * limitations under the License.
301
+ */const nn=nm;function am(n,e={}){let t=n;typeof e!="object"&&(e={name:e});const r=Object.assign({name:Zi,automaticDataCollectionEnabled:!1},e),s=r.name;if(typeof s!="string"||!s)throw Rt.create("bad-app-name",{appName:String(s)});if(t||(t=ml()),!t)throw Rt.create("no-options");const i=Is.get(s);if(i){if(Qt(t,i.options)&&Qt(r,i.config))return i;throw Rt.create("duplicate-app",{appName:s})}const a=new wp(s);for(const l of eo.values())a.addComponent(l);const c=new om(t,r,a);return Is.set(s,c),c}function Gs(n=Zi){const e=Is.get(n);if(!e&&n===Zi&&ml())return am();if(!e)throw Rt.create("no-app",{appName:n});return e}function qe(n,e,t){var r;let s=(r=rm[n])!==null&&r!==void 0?r:n;t&&(s+=`-${t}`);const i=s.match(/\s|\//),a=e.match(/\s|\//);if(i||a){const c=[`Unable to register library "${s}" with version "${e}":`];i&&c.push(`library name "${s}" contains illegal characters (whitespace or "/")`),i&&a&&c.push("and"),a&&c.push(`version name "${e}" contains illegal characters (whitespace or "/")`),lt.warn(c.join(" "));return}St(new ut(`${s}-version`,()=>({library:s,version:e}),"VERSION"))}/**
302
+ * @license
303
+ * Copyright 2021 Google LLC
304
+ *
305
+ * Licensed under the Apache License, Version 2.0 (the "License");
306
+ * you may not use this file except in compliance with the License.
307
+ * You may obtain a copy of the License at
308
+ *
309
+ * http://www.apache.org/licenses/LICENSE-2.0
310
+ *
311
+ * Unless required by applicable law or agreed to in writing, software
312
+ * distributed under the License is distributed on an "AS IS" BASIS,
313
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
314
+ * See the License for the specific language governing permissions and
315
+ * limitations under the License.
316
+ */const cm="firebase-heartbeat-database",um=1,mr="firebase-heartbeat-store";let $i=null;function yl(){return $i||($i=zf(cm,um,{upgrade:(n,e)=>{switch(e){case 0:try{n.createObjectStore(mr)}catch(t){console.warn(t)}}}}).catch(n=>{throw Rt.create("idb-open",{originalErrorMessage:n.message})})),$i}async function lm(n){try{const t=(await yl()).transaction(mr),r=await t.objectStore(mr).get(Tl(n));return await t.done,r}catch(e){if(e instanceof He)lt.warn(e.message);else{const t=Rt.create("idb-get",{originalErrorMessage:e==null?void 0:e.message});lt.warn(t.message)}}}async function Vc(n,e){try{const r=(await yl()).transaction(mr,"readwrite");await r.objectStore(mr).put(e,Tl(n)),await r.done}catch(t){if(t instanceof He)lt.warn(t.message);else{const r=Rt.create("idb-set",{originalErrorMessage:t==null?void 0:t.message});lt.warn(r.message)}}}function Tl(n){return`${n.name}!${n.options.appId}`}/**
317
+ * @license
318
+ * Copyright 2021 Google LLC
319
+ *
320
+ * Licensed under the Apache License, Version 2.0 (the "License");
321
+ * you may not use this file except in compliance with the License.
322
+ * You may obtain a copy of the License at
323
+ *
324
+ * http://www.apache.org/licenses/LICENSE-2.0
325
+ *
326
+ * Unless required by applicable law or agreed to in writing, software
327
+ * distributed under the License is distributed on an "AS IS" BASIS,
328
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
329
+ * See the License for the specific language governing permissions and
330
+ * limitations under the License.
331
+ */const hm=1024,dm=30;class fm{constructor(e){this.container=e,this._heartbeatsCache=null;const t=this.container.getProvider("app").getImmediate();this._storage=new mm(t),this._heartbeatsCachePromise=this._storage.read().then(r=>(this._heartbeatsCache=r,r))}async triggerHeartbeat(){var e,t;try{const s=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),i=Lc();if(((e=this._heartbeatsCache)===null||e===void 0?void 0:e.heartbeats)==null&&(this._heartbeatsCache=await this._heartbeatsCachePromise,((t=this._heartbeatsCache)===null||t===void 0?void 0:t.heartbeats)==null)||this._heartbeatsCache.lastSentHeartbeatDate===i||this._heartbeatsCache.heartbeats.some(a=>a.date===i))return;if(this._heartbeatsCache.heartbeats.push({date:i,agent:s}),this._heartbeatsCache.heartbeats.length>dm){const a=gm(this._heartbeatsCache.heartbeats);this._heartbeatsCache.heartbeats.splice(a,1)}return this._storage.overwrite(this._heartbeatsCache)}catch(r){lt.warn(r)}}async getHeartbeatsHeader(){var e;try{if(this._heartbeatsCache===null&&await this._heartbeatsCachePromise,((e=this._heartbeatsCache)===null||e===void 0?void 0:e.heartbeats)==null||this._heartbeatsCache.heartbeats.length===0)return"";const t=Lc(),{heartbeatsToSend:r,unsentEntries:s}=pm(this._heartbeatsCache.heartbeats),i=vs(JSON.stringify({version:2,heartbeats:r}));return this._heartbeatsCache.lastSentHeartbeatDate=t,s.length>0?(this._heartbeatsCache.heartbeats=s,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),i}catch(t){return lt.warn(t),""}}}function Lc(){return new Date().toISOString().substring(0,10)}function pm(n,e=hm){const t=[];let r=n.slice();for(const s of n){const i=t.find(a=>a.agent===s.agent);if(i){if(i.dates.push(s.date),Mc(t)>e){i.dates.pop();break}}else if(t.push({agent:s.agent,dates:[s.date]}),Mc(t)>e){t.pop();break}r=r.slice(1)}return{heartbeatsToSend:t,unsentEntries:r}}class mm{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return hp()?dp().then(()=>!0).catch(()=>!1):!1}async read(){if(await this._canUseIndexedDBPromise){const t=await lm(this.app);return t!=null&&t.heartbeats?t:{heartbeats:[]}}else return{heartbeats:[]}}async overwrite(e){var t;if(await this._canUseIndexedDBPromise){const s=await this.read();return Vc(this.app,{lastSentHeartbeatDate:(t=e.lastSentHeartbeatDate)!==null&&t!==void 0?t:s.lastSentHeartbeatDate,heartbeats:e.heartbeats})}else return}async add(e){var t;if(await this._canUseIndexedDBPromise){const s=await this.read();return Vc(this.app,{lastSentHeartbeatDate:(t=e.lastSentHeartbeatDate)!==null&&t!==void 0?t:s.lastSentHeartbeatDate,heartbeats:[...s.heartbeats,...e.heartbeats]})}else return}}function Mc(n){return vs(JSON.stringify({version:2,heartbeats:n})).length}function gm(n){if(n.length===0)return-1;let e=0,t=n[0].date;for(let r=1;r<n.length;r++)n[r].date<t&&(t=n[r].date,e=r);return e}/**
332
+ * @license
333
+ * Copyright 2019 Google LLC
334
+ *
335
+ * Licensed under the Apache License, Version 2.0 (the "License");
336
+ * you may not use this file except in compliance with the License.
337
+ * You may obtain a copy of the License at
338
+ *
339
+ * http://www.apache.org/licenses/LICENSE-2.0
340
+ *
341
+ * Unless required by applicable law or agreed to in writing, software
342
+ * distributed under the License is distributed on an "AS IS" BASIS,
343
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
344
+ * See the License for the specific language governing permissions and
345
+ * limitations under the License.
346
+ */function _m(n){St(new ut("platform-logger",e=>new Sp(e),"PRIVATE")),St(new ut("heartbeat",e=>new fm(e),"PRIVATE")),qe(Yi,Dc,n),qe(Yi,Dc,"esm2017"),qe("fire-js","")}_m("");/**
347
+ * @license
348
+ * Copyright 2017 Google LLC
349
+ *
350
+ * Licensed under the Apache License, Version 2.0 (the "License");
351
+ * you may not use this file except in compliance with the License.
352
+ * You may obtain a copy of the License at
353
+ *
354
+ * http://www.apache.org/licenses/LICENSE-2.0
355
+ *
356
+ * Unless required by applicable law or agreed to in writing, software
357
+ * distributed under the License is distributed on an "AS IS" BASIS,
358
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
359
+ * See the License for the specific language governing permissions and
360
+ * limitations under the License.
361
+ */const ym="type.googleapis.com/google.protobuf.Int64Value",Tm="type.googleapis.com/google.protobuf.UInt64Value";function El(n,e){const t={};for(const r in n)n.hasOwnProperty(r)&&(t[r]=e(n[r]));return t}function ws(n){if(n==null)return null;if(n instanceof Number&&(n=n.valueOf()),typeof n=="number"&&isFinite(n)||n===!0||n===!1||Object.prototype.toString.call(n)==="[object String]")return n;if(n instanceof Date)return n.toISOString();if(Array.isArray(n))return n.map(e=>ws(e));if(typeof n=="function"||typeof n=="object")return El(n,e=>ws(e));throw new Error("Data cannot be encoded in JSON: "+n)}function An(n){if(n==null)return n;if(n["@type"])switch(n["@type"]){case ym:case Tm:{const e=Number(n.value);if(isNaN(e))throw new Error("Data cannot be decoded from JSON: "+n);return e}default:throw new Error("Data cannot be decoded from JSON: "+n)}return Array.isArray(n)?n.map(e=>An(e)):typeof n=="function"||typeof n=="object"?El(n,e=>An(e)):n}/**
362
+ * @license
363
+ * Copyright 2020 Google LLC
364
+ *
365
+ * Licensed under the Apache License, Version 2.0 (the "License");
366
+ * you may not use this file except in compliance with the License.
367
+ * You may obtain a copy of the License at
368
+ *
369
+ * http://www.apache.org/licenses/LICENSE-2.0
370
+ *
371
+ * Unless required by applicable law or agreed to in writing, software
372
+ * distributed under the License is distributed on an "AS IS" BASIS,
373
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
374
+ * See the License for the specific language governing permissions and
375
+ * limitations under the License.
376
+ */const bo="functions";/**
377
+ * @license
378
+ * Copyright 2017 Google LLC
379
+ *
380
+ * Licensed under the Apache License, Version 2.0 (the "License");
381
+ * you may not use this file except in compliance with the License.
382
+ * You may obtain a copy of the License at
383
+ *
384
+ * http://www.apache.org/licenses/LICENSE-2.0
385
+ *
386
+ * Unless required by applicable law or agreed to in writing, software
387
+ * distributed under the License is distributed on an "AS IS" BASIS,
388
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
389
+ * See the License for the specific language governing permissions and
390
+ * limitations under the License.
391
+ */const xc={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class Ne extends He{constructor(e,t,r){super(`${bo}/${e}`,t||""),this.details=r,Object.setPrototypeOf(this,Ne.prototype)}}function Em(n){if(n>=200&&n<300)return"ok";switch(n){case 0:return"internal";case 400:return"invalid-argument";case 401:return"unauthenticated";case 403:return"permission-denied";case 404:return"not-found";case 409:return"aborted";case 429:return"resource-exhausted";case 499:return"cancelled";case 500:return"internal";case 501:return"unimplemented";case 503:return"unavailable";case 504:return"deadline-exceeded"}return"unknown"}function As(n,e){let t=Em(n),r=t,s;try{const i=e&&e.error;if(i){const a=i.status;if(typeof a=="string"){if(!xc[a])return new Ne("internal","internal");t=xc[a],r=a}const c=i.message;typeof c=="string"&&(r=c),s=i.details,s!==void 0&&(s=An(s))}}catch{}return t==="ok"?null:new Ne(t,r,s)}/**
392
+ * @license
393
+ * Copyright 2017 Google LLC
394
+ *
395
+ * Licensed under the Apache License, Version 2.0 (the "License");
396
+ * you may not use this file except in compliance with the License.
397
+ * You may obtain a copy of the License at
398
+ *
399
+ * http://www.apache.org/licenses/LICENSE-2.0
400
+ *
401
+ * Unless required by applicable law or agreed to in writing, software
402
+ * distributed under the License is distributed on an "AS IS" BASIS,
403
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
404
+ * See the License for the specific language governing permissions and
405
+ * limitations under the License.
406
+ */class vm{constructor(e,t,r,s){this.app=e,this.auth=null,this.messaging=null,this.appCheck=null,this.serverAppAppCheckToken=null,Pe(e)&&e.settings.appCheckToken&&(this.serverAppAppCheckToken=e.settings.appCheckToken),this.auth=t.getImmediate({optional:!0}),this.messaging=r.getImmediate({optional:!0}),this.auth||t.get().then(i=>this.auth=i,()=>{}),this.messaging||r.get().then(i=>this.messaging=i,()=>{}),this.appCheck||s==null||s.get().then(i=>this.appCheck=i,()=>{})}async getAuthToken(){if(this.auth)try{const e=await this.auth.getToken();return e==null?void 0:e.accessToken}catch{return}}async getMessagingToken(){if(!(!this.messaging||!("Notification"in self)||Notification.permission!=="granted"))try{return await this.messaging.getToken()}catch{return}}async getAppCheckToken(e){if(this.serverAppAppCheckToken)return this.serverAppAppCheckToken;if(this.appCheck){const t=e?await this.appCheck.getLimitedUseToken():await this.appCheck.getToken();return t.error?null:t.token}return null}async getContext(e){const t=await this.getAuthToken(),r=await this.getMessagingToken(),s=await this.getAppCheckToken(e);return{authToken:t,messagingToken:r,appCheckToken:s}}}/**
407
+ * @license
408
+ * Copyright 2017 Google LLC
409
+ *
410
+ * Licensed under the Apache License, Version 2.0 (the "License");
411
+ * you may not use this file except in compliance with the License.
412
+ * You may obtain a copy of the License at
413
+ *
414
+ * http://www.apache.org/licenses/LICENSE-2.0
415
+ *
416
+ * Unless required by applicable law or agreed to in writing, software
417
+ * distributed under the License is distributed on an "AS IS" BASIS,
418
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
419
+ * See the License for the specific language governing permissions and
420
+ * limitations under the License.
421
+ */const to="us-central1",Im=/^data: (.*?)(?:\n|$)/;function wm(n){let e=null;return{promise:new Promise((t,r)=>{e=setTimeout(()=>{r(new Ne("deadline-exceeded","deadline-exceeded"))},n)}),cancel:()=>{e&&clearTimeout(e)}}}class Am{constructor(e,t,r,s,i=to,a=(...c)=>fetch(...c)){this.app=e,this.fetchImpl=a,this.emulatorOrigin=null,this.contextProvider=new vm(e,t,r,s),this.cancelAllRequests=new Promise(c=>{this.deleteService=()=>Promise.resolve(c())});try{const c=new URL(i);this.customDomain=c.origin+(c.pathname==="/"?"":c.pathname),this.region=to}catch{this.customDomain=null,this.region=i}}_delete(){return this.deleteService()}_url(e){const t=this.app.options.projectId;return this.emulatorOrigin!==null?`${this.emulatorOrigin}/${t}/${this.region}/${e}`:this.customDomain!==null?`${this.customDomain}/${e}`:`https://${this.region}-${t}.cloudfunctions.net/${e}`}}function Rm(n,e,t){n.emulatorOrigin=`http://${e}:${t}`}function bm(n,e,t){const r=s=>Sm(n,e,s,{});return r.stream=(s,i)=>km(n,e,s,i),r}async function Pm(n,e,t,r){t["Content-Type"]="application/json";let s;try{s=await r(n,{method:"POST",body:JSON.stringify(e),headers:t})}catch{return{status:0,json:null}}let i=null;try{i=await s.json()}catch{}return{status:s.status,json:i}}async function vl(n,e){const t={},r=await n.contextProvider.getContext(e.limitedUseAppCheckTokens);return r.authToken&&(t.Authorization="Bearer "+r.authToken),r.messagingToken&&(t["Firebase-Instance-ID-Token"]=r.messagingToken),r.appCheckToken!==null&&(t["X-Firebase-AppCheck"]=r.appCheckToken),t}function Sm(n,e,t,r){const s=n._url(e);return Cm(n,s,t,r)}async function Cm(n,e,t,r){t=ws(t);const s={data:t},i=await vl(n,r),a=r.timeout||7e4,c=wm(a),l=await Promise.race([Pm(e,s,i,n.fetchImpl),c.promise,n.cancelAllRequests]);if(c.cancel(),!l)throw new Ne("cancelled","Firebase Functions instance was deleted.");const d=As(l.status,l.json);if(d)throw d;if(!l.json)throw new Ne("internal","Response is not valid JSON object.");let f=l.json.data;if(typeof f>"u"&&(f=l.json.result),typeof f>"u")throw new Ne("internal","Response is missing data field.");return{data:An(f)}}function km(n,e,t,r){const s=n._url(e);return Nm(n,s,t,r||{})}async function Nm(n,e,t,r){var s;t=ws(t);const i={data:t},a=await vl(n,r);a["Content-Type"]="application/json",a.Accept="text/event-stream";let c;try{c=await n.fetchImpl(e,{method:"POST",body:JSON.stringify(i),headers:a,signal:r==null?void 0:r.signal})}catch(R){if(R instanceof Error&&R.name==="AbortError"){const N=new Ne("cancelled","Request was cancelled.");return{data:Promise.reject(N),stream:{[Symbol.asyncIterator](){return{next(){return Promise.reject(N)}}}}}}const C=As(0,null);return{data:Promise.reject(C),stream:{[Symbol.asyncIterator](){return{next(){return Promise.reject(C)}}}}}}let l,d;const f=new Promise((R,C)=>{l=R,d=C});(s=r==null?void 0:r.signal)===null||s===void 0||s.addEventListener("abort",()=>{const R=new Ne("cancelled","Request was cancelled.");d(R)});const m=c.body.getReader(),E=Dm(m,l,d,r==null?void 0:r.signal);return{stream:{[Symbol.asyncIterator](){const R=E.getReader();return{async next(){const{value:C,done:N}=await R.read();return{value:C,done:N}},async return(){return await R.cancel(),{done:!0,value:void 0}}}}},data:f}}function Dm(n,e,t,r){const s=(a,c)=>{const l=a.match(Im);if(!l)return;const d=l[1];try{const f=JSON.parse(d);if("result"in f){e(An(f.result));return}if("message"in f){c.enqueue(An(f.message));return}if("error"in f){const m=As(0,f);c.error(m),t(m);return}}catch(f){if(f instanceof Ne){c.error(f),t(f);return}}},i=new TextDecoder;return new ReadableStream({start(a){let c="";return l();async function l(){if(r!=null&&r.aborted){const d=new Ne("cancelled","Request was cancelled");return a.error(d),t(d),Promise.resolve()}try{const{value:d,done:f}=await n.read();if(f){c.trim()&&s(c.trim(),a),a.close();return}if(r!=null&&r.aborted){const E=new Ne("cancelled","Request was cancelled");a.error(E),t(E),await n.cancel();return}c+=i.decode(d,{stream:!0});const m=c.split(`
422
+ `);c=m.pop()||"";for(const E of m)E.trim()&&s(E.trim(),a);return l()}catch(d){const f=d instanceof Ne?d:As(0,null);a.error(f),t(f)}}},cancel(){return n.cancel()}})}const Uc="@firebase/functions",Fc="0.12.3";/**
423
+ * @license
424
+ * Copyright 2019 Google LLC
425
+ *
426
+ * Licensed under the Apache License, Version 2.0 (the "License");
427
+ * you may not use this file except in compliance with the License.
428
+ * You may obtain a copy of the License at
429
+ *
430
+ * http://www.apache.org/licenses/LICENSE-2.0
431
+ *
432
+ * Unless required by applicable law or agreed to in writing, software
433
+ * distributed under the License is distributed on an "AS IS" BASIS,
434
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
435
+ * See the License for the specific language governing permissions and
436
+ * limitations under the License.
437
+ */const Om="auth-internal",Vm="app-check-internal",Lm="messaging-internal";function Mm(n){const e=(t,{instanceIdentifier:r})=>{const s=t.getProvider("app").getImmediate(),i=t.getProvider(Om),a=t.getProvider(Lm),c=t.getProvider(Vm);return new Am(s,i,a,c,r)};St(new ut(bo,e,"PUBLIC").setMultipleInstances(!0)),qe(Uc,Fc,n),qe(Uc,Fc,"esm2017")}/**
438
+ * @license
439
+ * Copyright 2020 Google LLC
440
+ *
441
+ * Licensed under the Apache License, Version 2.0 (the "License");
442
+ * you may not use this file except in compliance with the License.
443
+ * You may obtain a copy of the License at
444
+ *
445
+ * http://www.apache.org/licenses/LICENSE-2.0
446
+ *
447
+ * Unless required by applicable law or agreed to in writing, software
448
+ * distributed under the License is distributed on an "AS IS" BASIS,
449
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
450
+ * See the License for the specific language governing permissions and
451
+ * limitations under the License.
452
+ */function xm(n=Gs(),e=to){const r=Pr(Z(n),bo).getImmediate({identifier:e}),s=Ao("functions");return s&&Um(r,...s),r}function Um(n,e,t){Rm(Z(n),e,t)}function Fm(n,e,t){return bm(Z(n),e)}Mm();function Il(){return{"dependent-sdk-initialized-before-auth":"Another Firebase SDK was initialized and is trying to use Auth before Auth is initialized. Please be sure to call `initializeAuth` or `getAuth` before starting any other Firebase SDK."}}const Bm=Il,wl=new Rr("auth","Firebase",Il());/**
453
+ * @license
454
+ * Copyright 2020 Google LLC
455
+ *
456
+ * Licensed under the Apache License, Version 2.0 (the "License");
457
+ * you may not use this file except in compliance with the License.
458
+ * You may obtain a copy of the License at
459
+ *
460
+ * http://www.apache.org/licenses/LICENSE-2.0
461
+ *
462
+ * Unless required by applicable law or agreed to in writing, software
463
+ * distributed under the License is distributed on an "AS IS" BASIS,
464
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
465
+ * See the License for the specific language governing permissions and
466
+ * limitations under the License.
467
+ */const Rs=new Ro("@firebase/auth");function qm(n,...e){Rs.logLevel<=z.WARN&&Rs.warn(`Auth (${nn}): ${n}`,...e)}function hs(n,...e){Rs.logLevel<=z.ERROR&&Rs.error(`Auth (${nn}): ${n}`,...e)}/**
468
+ * @license
469
+ * Copyright 2020 Google LLC
470
+ *
471
+ * Licensed under the Apache License, Version 2.0 (the "License");
472
+ * you may not use this file except in compliance with the License.
473
+ * You may obtain a copy of the License at
474
+ *
475
+ * http://www.apache.org/licenses/LICENSE-2.0
476
+ *
477
+ * Unless required by applicable law or agreed to in writing, software
478
+ * distributed under the License is distributed on an "AS IS" BASIS,
479
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
480
+ * See the License for the specific language governing permissions and
481
+ * limitations under the License.
482
+ */function Me(n,...e){throw So(n,...e)}function $e(n,...e){return So(n,...e)}function Po(n,e,t){const r=Object.assign(Object.assign({},Bm()),{[e]:t});return new Rr("auth","Firebase",r).create(e,{appName:n.name})}function ot(n){return Po(n,"operation-not-supported-in-this-environment","Operations that alter the current user are not supported in conjunction with FirebaseServerApp")}function $m(n,e,t){const r=t;if(!(e instanceof r))throw r.name!==e.constructor.name&&Me(n,"argument-error"),Po(n,"argument-error",`Type of ${e.constructor.name} does not match expected instance.Did you pass a reference from a different Auth SDK?`)}function So(n,...e){if(typeof n!="string"){const t=e[0],r=[...e.slice(1)];return r[0]&&(r[0].appName=n.name),n._errorFactory.create(t,...r)}return wl.create(n,...e)}function x(n,e,...t){if(!n)throw So(e,...t)}function st(n){const e="INTERNAL ASSERTION FAILED: "+n;throw hs(e),new Error(e)}function ht(n,e){n||st(e)}/**
483
+ * @license
484
+ * Copyright 2020 Google LLC
485
+ *
486
+ * Licensed under the Apache License, Version 2.0 (the "License");
487
+ * you may not use this file except in compliance with the License.
488
+ * You may obtain a copy of the License at
489
+ *
490
+ * http://www.apache.org/licenses/LICENSE-2.0
491
+ *
492
+ * Unless required by applicable law or agreed to in writing, software
493
+ * distributed under the License is distributed on an "AS IS" BASIS,
494
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
495
+ * See the License for the specific language governing permissions and
496
+ * limitations under the License.
497
+ */function no(){var n;return typeof self<"u"&&((n=self.location)===null||n===void 0?void 0:n.href)||""}function jm(){return Bc()==="http:"||Bc()==="https:"}function Bc(){var n;return typeof self<"u"&&((n=self.location)===null||n===void 0?void 0:n.protocol)||null}/**
498
+ * @license
499
+ * Copyright 2020 Google LLC
500
+ *
501
+ * Licensed under the Apache License, Version 2.0 (the "License");
502
+ * you may not use this file except in compliance with the License.
503
+ * You may obtain a copy of the License at
504
+ *
505
+ * http://www.apache.org/licenses/LICENSE-2.0
506
+ *
507
+ * Unless required by applicable law or agreed to in writing, software
508
+ * distributed under the License is distributed on an "AS IS" BASIS,
509
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
510
+ * See the License for the specific language governing permissions and
511
+ * limitations under the License.
512
+ */function Hm(){return typeof navigator<"u"&&navigator&&"onLine"in navigator&&typeof navigator.onLine=="boolean"&&(jm()||ap()||"connection"in navigator)?navigator.onLine:!0}function zm(){if(typeof navigator>"u")return null;const n=navigator;return n.languages&&n.languages[0]||n.language||null}/**
513
+ * @license
514
+ * Copyright 2020 Google LLC
515
+ *
516
+ * Licensed under the Apache License, Version 2.0 (the "License");
517
+ * you may not use this file except in compliance with the License.
518
+ * You may obtain a copy of the License at
519
+ *
520
+ * http://www.apache.org/licenses/LICENSE-2.0
521
+ *
522
+ * Unless required by applicable law or agreed to in writing, software
523
+ * distributed under the License is distributed on an "AS IS" BASIS,
524
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
525
+ * See the License for the specific language governing permissions and
526
+ * limitations under the License.
527
+ */class Sr{constructor(e,t){this.shortDelay=e,this.longDelay=t,ht(t>e,"Short delay should be less than long delay!"),this.isMobile=sp()||cp()}get(){return Hm()?this.isMobile?this.longDelay:this.shortDelay:Math.min(5e3,this.shortDelay)}}/**
528
+ * @license
529
+ * Copyright 2020 Google LLC
530
+ *
531
+ * Licensed under the Apache License, Version 2.0 (the "License");
532
+ * you may not use this file except in compliance with the License.
533
+ * You may obtain a copy of the License at
534
+ *
535
+ * http://www.apache.org/licenses/LICENSE-2.0
536
+ *
537
+ * Unless required by applicable law or agreed to in writing, software
538
+ * distributed under the License is distributed on an "AS IS" BASIS,
539
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
540
+ * See the License for the specific language governing permissions and
541
+ * limitations under the License.
542
+ */function Co(n,e){ht(n.emulator,"Emulator should always be set here");const{url:t}=n.emulator;return e?`${t}${e.startsWith("/")?e.slice(1):e}`:t}/**
543
+ * @license
544
+ * Copyright 2020 Google LLC
545
+ *
546
+ * Licensed under the Apache License, Version 2.0 (the "License");
547
+ * you may not use this file except in compliance with the License.
548
+ * You may obtain a copy of the License at
549
+ *
550
+ * http://www.apache.org/licenses/LICENSE-2.0
551
+ *
552
+ * Unless required by applicable law or agreed to in writing, software
553
+ * distributed under the License is distributed on an "AS IS" BASIS,
554
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
555
+ * See the License for the specific language governing permissions and
556
+ * limitations under the License.
557
+ */class Al{static initialize(e,t,r){this.fetchImpl=e,t&&(this.headersImpl=t),r&&(this.responseImpl=r)}static fetch(){if(this.fetchImpl)return this.fetchImpl;if(typeof self<"u"&&"fetch"in self)return self.fetch;if(typeof globalThis<"u"&&globalThis.fetch)return globalThis.fetch;if(typeof fetch<"u")return fetch;st("Could not find fetch implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static headers(){if(this.headersImpl)return this.headersImpl;if(typeof self<"u"&&"Headers"in self)return self.Headers;if(typeof globalThis<"u"&&globalThis.Headers)return globalThis.Headers;if(typeof Headers<"u")return Headers;st("Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static response(){if(this.responseImpl)return this.responseImpl;if(typeof self<"u"&&"Response"in self)return self.Response;if(typeof globalThis<"u"&&globalThis.Response)return globalThis.Response;if(typeof Response<"u")return Response;st("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}}/**
558
+ * @license
559
+ * Copyright 2020 Google LLC
560
+ *
561
+ * Licensed under the Apache License, Version 2.0 (the "License");
562
+ * you may not use this file except in compliance with the License.
563
+ * You may obtain a copy of the License at
564
+ *
565
+ * http://www.apache.org/licenses/LICENSE-2.0
566
+ *
567
+ * Unless required by applicable law or agreed to in writing, software
568
+ * distributed under the License is distributed on an "AS IS" BASIS,
569
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
570
+ * See the License for the specific language governing permissions and
571
+ * limitations under the License.
572
+ */const Gm={CREDENTIAL_MISMATCH:"custom-token-mismatch",MISSING_CUSTOM_TOKEN:"internal-error",INVALID_IDENTIFIER:"invalid-email",MISSING_CONTINUE_URI:"internal-error",INVALID_PASSWORD:"wrong-password",MISSING_PASSWORD:"missing-password",INVALID_LOGIN_CREDENTIALS:"invalid-credential",EMAIL_EXISTS:"email-already-in-use",PASSWORD_LOGIN_DISABLED:"operation-not-allowed",INVALID_IDP_RESPONSE:"invalid-credential",INVALID_PENDING_TOKEN:"invalid-credential",FEDERATED_USER_ID_ALREADY_LINKED:"credential-already-in-use",MISSING_REQ_TYPE:"internal-error",EMAIL_NOT_FOUND:"user-not-found",RESET_PASSWORD_EXCEED_LIMIT:"too-many-requests",EXPIRED_OOB_CODE:"expired-action-code",INVALID_OOB_CODE:"invalid-action-code",MISSING_OOB_CODE:"internal-error",CREDENTIAL_TOO_OLD_LOGIN_AGAIN:"requires-recent-login",INVALID_ID_TOKEN:"invalid-user-token",TOKEN_EXPIRED:"user-token-expired",USER_NOT_FOUND:"user-token-expired",TOO_MANY_ATTEMPTS_TRY_LATER:"too-many-requests",PASSWORD_DOES_NOT_MEET_REQUIREMENTS:"password-does-not-meet-requirements",INVALID_CODE:"invalid-verification-code",INVALID_SESSION_INFO:"invalid-verification-id",INVALID_TEMPORARY_PROOF:"invalid-credential",MISSING_SESSION_INFO:"missing-verification-id",SESSION_EXPIRED:"code-expired",MISSING_ANDROID_PACKAGE_NAME:"missing-android-pkg-name",UNAUTHORIZED_DOMAIN:"unauthorized-continue-uri",INVALID_OAUTH_CLIENT_ID:"invalid-oauth-client-id",ADMIN_ONLY_OPERATION:"admin-restricted-operation",INVALID_MFA_PENDING_CREDENTIAL:"invalid-multi-factor-session",MFA_ENROLLMENT_NOT_FOUND:"multi-factor-info-not-found",MISSING_MFA_ENROLLMENT_ID:"missing-multi-factor-info",MISSING_MFA_PENDING_CREDENTIAL:"missing-multi-factor-session",SECOND_FACTOR_EXISTS:"second-factor-already-in-use",SECOND_FACTOR_LIMIT_EXCEEDED:"maximum-second-factor-count-exceeded",BLOCKING_FUNCTION_ERROR_RESPONSE:"internal-error",RECAPTCHA_NOT_ENABLED:"recaptcha-not-enabled",MISSING_RECAPTCHA_TOKEN:"missing-recaptcha-token",INVALID_RECAPTCHA_TOKEN:"invalid-recaptcha-token",INVALID_RECAPTCHA_ACTION:"invalid-recaptcha-action",MISSING_CLIENT_TYPE:"missing-client-type",MISSING_RECAPTCHA_VERSION:"missing-recaptcha-version",INVALID_RECAPTCHA_VERSION:"invalid-recaptcha-version",INVALID_REQ_TYPE:"invalid-req-type"};/**
573
+ * @license
574
+ * Copyright 2020 Google LLC
575
+ *
576
+ * Licensed under the Apache License, Version 2.0 (the "License");
577
+ * you may not use this file except in compliance with the License.
578
+ * You may obtain a copy of the License at
579
+ *
580
+ * http://www.apache.org/licenses/LICENSE-2.0
581
+ *
582
+ * Unless required by applicable law or agreed to in writing, software
583
+ * distributed under the License is distributed on an "AS IS" BASIS,
584
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
585
+ * See the License for the specific language governing permissions and
586
+ * limitations under the License.
587
+ */const Wm=["/v1/accounts:signInWithCustomToken","/v1/accounts:signInWithEmailLink","/v1/accounts:signInWithIdp","/v1/accounts:signInWithPassword","/v1/accounts:signInWithPhoneNumber","/v1/token"],Km=new Sr(3e4,6e4);function Lt(n,e){return n.tenantId&&!e.tenantId?Object.assign(Object.assign({},e),{tenantId:n.tenantId}):e}async function Mt(n,e,t,r,s={}){return Rl(n,s,async()=>{let i={},a={};r&&(e==="GET"?a=r:i={body:JSON.stringify(r)});const c=br(Object.assign({key:n.config.apiKey},a)).slice(1),l=await n._getAdditionalHeaders();l["Content-Type"]="application/json",n.languageCode&&(l["X-Firebase-Locale"]=n.languageCode);const d=Object.assign({method:e,headers:l},i);return op()||(d.referrerPolicy="no-referrer"),Al.fetch()(await bl(n,n.config.apiHost,t,c),d)})}async function Rl(n,e,t){n._canInitEmulator=!1;const r=Object.assign(Object.assign({},Gm),e);try{const s=new Xm(n),i=await Promise.race([t(),s.promise]);s.clearNetworkTimeout();const a=await i.json();if("needConfirmation"in a)throw rs(n,"account-exists-with-different-credential",a);if(i.ok&&!("errorMessage"in a))return a;{const c=i.ok?a.errorMessage:a.error.message,[l,d]=c.split(" : ");if(l==="FEDERATED_USER_ID_ALREADY_LINKED")throw rs(n,"credential-already-in-use",a);if(l==="EMAIL_EXISTS")throw rs(n,"email-already-in-use",a);if(l==="USER_DISABLED")throw rs(n,"user-disabled",a);const f=r[l]||l.toLowerCase().replace(/[_\s]+/g,"-");if(d)throw Po(n,f,d);Me(n,f)}}catch(s){if(s instanceof He)throw s;Me(n,"network-request-failed",{message:String(s)})}}async function Cr(n,e,t,r,s={}){const i=await Mt(n,e,t,r,s);return"mfaPendingCredential"in i&&Me(n,"multi-factor-auth-required",{_serverResponse:i}),i}async function bl(n,e,t,r){const s=`${e}${t}?${r}`,i=n,a=i.config.emulator?Co(n.config,s):`${n.config.apiScheme}://${s}`;return Wm.includes(t)&&(await i._persistenceManagerAvailable,i._getPersistenceType()==="COOKIE")?i._getPersistence()._getFinalTarget(a).toString():a}function Qm(n){switch(n){case"ENFORCE":return"ENFORCE";case"AUDIT":return"AUDIT";case"OFF":return"OFF";default:return"ENFORCEMENT_STATE_UNSPECIFIED"}}class Xm{clearNetworkTimeout(){clearTimeout(this.timer)}constructor(e){this.auth=e,this.timer=null,this.promise=new Promise((t,r)=>{this.timer=setTimeout(()=>r($e(this.auth,"network-request-failed")),Km.get())})}}function rs(n,e,t){const r={appName:n.name};t.email&&(r.email=t.email),t.phoneNumber&&(r.phoneNumber=t.phoneNumber);const s=$e(n,e,r);return s.customData._tokenResponse=t,s}function qc(n){return n!==void 0&&n.enterprise!==void 0}class Jm{constructor(e){if(this.siteKey="",this.recaptchaEnforcementState=[],e.recaptchaKey===void 0)throw new Error("recaptchaKey undefined");this.siteKey=e.recaptchaKey.split("/")[3],this.recaptchaEnforcementState=e.recaptchaEnforcementState}getProviderEnforcementState(e){if(!this.recaptchaEnforcementState||this.recaptchaEnforcementState.length===0)return null;for(const t of this.recaptchaEnforcementState)if(t.provider&&t.provider===e)return Qm(t.enforcementState);return null}isProviderEnabled(e){return this.getProviderEnforcementState(e)==="ENFORCE"||this.getProviderEnforcementState(e)==="AUDIT"}isAnyProviderEnabled(){return this.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")||this.isProviderEnabled("PHONE_PROVIDER")}}async function Ym(n,e){return Mt(n,"GET","/v2/recaptchaConfig",Lt(n,e))}/**
588
+ * @license
589
+ * Copyright 2020 Google LLC
590
+ *
591
+ * Licensed under the Apache License, Version 2.0 (the "License");
592
+ * you may not use this file except in compliance with the License.
593
+ * You may obtain a copy of the License at
594
+ *
595
+ * http://www.apache.org/licenses/LICENSE-2.0
596
+ *
597
+ * Unless required by applicable law or agreed to in writing, software
598
+ * distributed under the License is distributed on an "AS IS" BASIS,
599
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
600
+ * See the License for the specific language governing permissions and
601
+ * limitations under the License.
602
+ */async function Zm(n,e){return Mt(n,"POST","/v1/accounts:delete",e)}async function bs(n,e){return Mt(n,"POST","/v1/accounts:lookup",e)}/**
603
+ * @license
604
+ * Copyright 2020 Google LLC
605
+ *
606
+ * Licensed under the Apache License, Version 2.0 (the "License");
607
+ * you may not use this file except in compliance with the License.
608
+ * You may obtain a copy of the License at
609
+ *
610
+ * http://www.apache.org/licenses/LICENSE-2.0
611
+ *
612
+ * Unless required by applicable law or agreed to in writing, software
613
+ * distributed under the License is distributed on an "AS IS" BASIS,
614
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
615
+ * See the License for the specific language governing permissions and
616
+ * limitations under the License.
617
+ */function lr(n){if(n)try{const e=new Date(Number(n));if(!isNaN(e.getTime()))return e.toUTCString()}catch{}}async function Pl(n,e=!1){const t=Z(n),r=await t.getIdToken(e),s=ko(r);x(s&&s.exp&&s.auth_time&&s.iat,t.auth,"internal-error");const i=typeof s.firebase=="object"?s.firebase:void 0,a=i==null?void 0:i.sign_in_provider;return{claims:s,token:r,authTime:lr(ji(s.auth_time)),issuedAtTime:lr(ji(s.iat)),expirationTime:lr(ji(s.exp)),signInProvider:a||null,signInSecondFactor:(i==null?void 0:i.sign_in_second_factor)||null}}function ji(n){return Number(n)*1e3}function ko(n){const[e,t,r]=n.split(".");if(e===void 0||t===void 0||r===void 0)return hs("JWT malformed, contained fewer than 3 sections"),null;try{const s=fl(t);return s?JSON.parse(s):(hs("Failed to decode base64 JWT payload"),null)}catch(s){return hs("Caught error parsing JWT payload as JSON",s==null?void 0:s.toString()),null}}function $c(n){const e=ko(n);return x(e,"internal-error"),x(typeof e.exp<"u","internal-error"),x(typeof e.iat<"u","internal-error"),Number(e.exp)-Number(e.iat)}/**
618
+ * @license
619
+ * Copyright 2020 Google LLC
620
+ *
621
+ * Licensed under the Apache License, Version 2.0 (the "License");
622
+ * you may not use this file except in compliance with the License.
623
+ * You may obtain a copy of the License at
624
+ *
625
+ * http://www.apache.org/licenses/LICENSE-2.0
626
+ *
627
+ * Unless required by applicable law or agreed to in writing, software
628
+ * distributed under the License is distributed on an "AS IS" BASIS,
629
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
630
+ * See the License for the specific language governing permissions and
631
+ * limitations under the License.
632
+ */async function gr(n,e,t=!1){if(t)return e;try{return await e}catch(r){throw r instanceof He&&eg(r)&&n.auth.currentUser===n&&await n.auth.signOut(),r}}function eg({code:n}){return n==="auth/user-disabled"||n==="auth/user-token-expired"}/**
633
+ * @license
634
+ * Copyright 2020 Google LLC
635
+ *
636
+ * Licensed under the Apache License, Version 2.0 (the "License");
637
+ * you may not use this file except in compliance with the License.
638
+ * You may obtain a copy of the License at
639
+ *
640
+ * http://www.apache.org/licenses/LICENSE-2.0
641
+ *
642
+ * Unless required by applicable law or agreed to in writing, software
643
+ * distributed under the License is distributed on an "AS IS" BASIS,
644
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
645
+ * See the License for the specific language governing permissions and
646
+ * limitations under the License.
647
+ */class tg{constructor(e){this.user=e,this.isRunning=!1,this.timerId=null,this.errorBackoff=3e4}_start(){this.isRunning||(this.isRunning=!0,this.schedule())}_stop(){this.isRunning&&(this.isRunning=!1,this.timerId!==null&&clearTimeout(this.timerId))}getInterval(e){var t;if(e){const r=this.errorBackoff;return this.errorBackoff=Math.min(this.errorBackoff*2,96e4),r}else{this.errorBackoff=3e4;const s=((t=this.user.stsTokenManager.expirationTime)!==null&&t!==void 0?t:0)-Date.now()-3e5;return Math.max(0,s)}}schedule(e=!1){if(!this.isRunning)return;const t=this.getInterval(e);this.timerId=setTimeout(async()=>{await this.iteration()},t)}async iteration(){try{await this.user.getIdToken(!0)}catch(e){(e==null?void 0:e.code)==="auth/network-request-failed"&&this.schedule(!0);return}this.schedule()}}/**
648
+ * @license
649
+ * Copyright 2020 Google LLC
650
+ *
651
+ * Licensed under the Apache License, Version 2.0 (the "License");
652
+ * you may not use this file except in compliance with the License.
653
+ * You may obtain a copy of the License at
654
+ *
655
+ * http://www.apache.org/licenses/LICENSE-2.0
656
+ *
657
+ * Unless required by applicable law or agreed to in writing, software
658
+ * distributed under the License is distributed on an "AS IS" BASIS,
659
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
660
+ * See the License for the specific language governing permissions and
661
+ * limitations under the License.
662
+ */class ro{constructor(e,t){this.createdAt=e,this.lastLoginAt=t,this._initializeTime()}_initializeTime(){this.lastSignInTime=lr(this.lastLoginAt),this.creationTime=lr(this.createdAt)}_copy(e){this.createdAt=e.createdAt,this.lastLoginAt=e.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}/**
663
+ * @license
664
+ * Copyright 2019 Google LLC
665
+ *
666
+ * Licensed under the Apache License, Version 2.0 (the "License");
667
+ * you may not use this file except in compliance with the License.
668
+ * You may obtain a copy of the License at
669
+ *
670
+ * http://www.apache.org/licenses/LICENSE-2.0
671
+ *
672
+ * Unless required by applicable law or agreed to in writing, software
673
+ * distributed under the License is distributed on an "AS IS" BASIS,
674
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
675
+ * See the License for the specific language governing permissions and
676
+ * limitations under the License.
677
+ */async function Ps(n){var e;const t=n.auth,r=await n.getIdToken(),s=await gr(n,bs(t,{idToken:r}));x(s==null?void 0:s.users.length,t,"internal-error");const i=s.users[0];n._notifyReloadListener(i);const a=!((e=i.providerUserInfo)===null||e===void 0)&&e.length?Sl(i.providerUserInfo):[],c=rg(n.providerData,a),l=n.isAnonymous,d=!(n.email&&i.passwordHash)&&!(c!=null&&c.length),f=l?d:!1,m={uid:i.localId,displayName:i.displayName||null,photoURL:i.photoUrl||null,email:i.email||null,emailVerified:i.emailVerified||!1,phoneNumber:i.phoneNumber||null,tenantId:i.tenantId||null,providerData:c,metadata:new ro(i.createdAt,i.lastLoginAt),isAnonymous:f};Object.assign(n,m)}async function ng(n){const e=Z(n);await Ps(e),await e.auth._persistUserIfCurrent(e),e.auth._notifyListenersIfCurrent(e)}function rg(n,e){return[...n.filter(r=>!e.some(s=>s.providerId===r.providerId)),...e]}function Sl(n){return n.map(e=>{var{providerId:t}=e,r=wo(e,["providerId"]);return{providerId:t,uid:r.rawId||"",displayName:r.displayName||null,email:r.email||null,phoneNumber:r.phoneNumber||null,photoURL:r.photoUrl||null}})}/**
678
+ * @license
679
+ * Copyright 2020 Google LLC
680
+ *
681
+ * Licensed under the Apache License, Version 2.0 (the "License");
682
+ * you may not use this file except in compliance with the License.
683
+ * You may obtain a copy of the License at
684
+ *
685
+ * http://www.apache.org/licenses/LICENSE-2.0
686
+ *
687
+ * Unless required by applicable law or agreed to in writing, software
688
+ * distributed under the License is distributed on an "AS IS" BASIS,
689
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
690
+ * See the License for the specific language governing permissions and
691
+ * limitations under the License.
692
+ */async function sg(n,e){const t=await Rl(n,{},async()=>{const r=br({grant_type:"refresh_token",refresh_token:e}).slice(1),{tokenApiHost:s,apiKey:i}=n.config,a=await bl(n,s,"/v1/token",`key=${i}`),c=await n._getAdditionalHeaders();return c["Content-Type"]="application/x-www-form-urlencoded",Al.fetch()(a,{method:"POST",headers:c,body:r})});return{accessToken:t.access_token,expiresIn:t.expires_in,refreshToken:t.refresh_token}}async function ig(n,e){return Mt(n,"POST","/v2/accounts:revokeToken",Lt(n,e))}/**
693
+ * @license
694
+ * Copyright 2020 Google LLC
695
+ *
696
+ * Licensed under the Apache License, Version 2.0 (the "License");
697
+ * you may not use this file except in compliance with the License.
698
+ * You may obtain a copy of the License at
699
+ *
700
+ * http://www.apache.org/licenses/LICENSE-2.0
701
+ *
702
+ * Unless required by applicable law or agreed to in writing, software
703
+ * distributed under the License is distributed on an "AS IS" BASIS,
704
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
705
+ * See the License for the specific language governing permissions and
706
+ * limitations under the License.
707
+ */class yn{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){x(e.idToken,"internal-error"),x(typeof e.idToken<"u","internal-error"),x(typeof e.refreshToken<"u","internal-error");const t="expiresIn"in e&&typeof e.expiresIn<"u"?Number(e.expiresIn):$c(e.idToken);this.updateTokensAndExpiration(e.idToken,e.refreshToken,t)}updateFromIdToken(e){x(e.length!==0,"internal-error");const t=$c(e);this.updateTokensAndExpiration(e,null,t)}async getToken(e,t=!1){return!t&&this.accessToken&&!this.isExpired?this.accessToken:(x(this.refreshToken,e,"user-token-expired"),this.refreshToken?(await this.refresh(e,this.refreshToken),this.accessToken):null)}clearRefreshToken(){this.refreshToken=null}async refresh(e,t){const{accessToken:r,refreshToken:s,expiresIn:i}=await sg(e,t);this.updateTokensAndExpiration(r,s,Number(i))}updateTokensAndExpiration(e,t,r){this.refreshToken=t||null,this.accessToken=e||null,this.expirationTime=Date.now()+r*1e3}static fromJSON(e,t){const{refreshToken:r,accessToken:s,expirationTime:i}=t,a=new yn;return r&&(x(typeof r=="string","internal-error",{appName:e}),a.refreshToken=r),s&&(x(typeof s=="string","internal-error",{appName:e}),a.accessToken=s),i&&(x(typeof i=="number","internal-error",{appName:e}),a.expirationTime=i),a}toJSON(){return{refreshToken:this.refreshToken,accessToken:this.accessToken,expirationTime:this.expirationTime}}_assign(e){this.accessToken=e.accessToken,this.refreshToken=e.refreshToken,this.expirationTime=e.expirationTime}_clone(){return Object.assign(new yn,this.toJSON())}_performRefresh(){return st("not implemented")}}/**
708
+ * @license
709
+ * Copyright 2020 Google LLC
710
+ *
711
+ * Licensed under the Apache License, Version 2.0 (the "License");
712
+ * you may not use this file except in compliance with the License.
713
+ * You may obtain a copy of the License at
714
+ *
715
+ * http://www.apache.org/licenses/LICENSE-2.0
716
+ *
717
+ * Unless required by applicable law or agreed to in writing, software
718
+ * distributed under the License is distributed on an "AS IS" BASIS,
719
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
720
+ * See the License for the specific language governing permissions and
721
+ * limitations under the License.
722
+ */function yt(n,e){x(typeof n=="string"||typeof n>"u","internal-error",{appName:e})}class Fe{constructor(e){var{uid:t,auth:r,stsTokenManager:s}=e,i=wo(e,["uid","auth","stsTokenManager"]);this.providerId="firebase",this.proactiveRefresh=new tg(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=t,this.auth=r,this.stsTokenManager=s,this.accessToken=s.accessToken,this.displayName=i.displayName||null,this.email=i.email||null,this.emailVerified=i.emailVerified||!1,this.phoneNumber=i.phoneNumber||null,this.photoURL=i.photoURL||null,this.isAnonymous=i.isAnonymous||!1,this.tenantId=i.tenantId||null,this.providerData=i.providerData?[...i.providerData]:[],this.metadata=new ro(i.createdAt||void 0,i.lastLoginAt||void 0)}async getIdToken(e){const t=await gr(this,this.stsTokenManager.getToken(this.auth,e));return x(t,this.auth,"internal-error"),this.accessToken!==t&&(this.accessToken=t,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),t}getIdTokenResult(e){return Pl(this,e)}reload(){return ng(this)}_assign(e){this!==e&&(x(this.uid===e.uid,this.auth,"internal-error"),this.displayName=e.displayName,this.photoURL=e.photoURL,this.email=e.email,this.emailVerified=e.emailVerified,this.phoneNumber=e.phoneNumber,this.isAnonymous=e.isAnonymous,this.tenantId=e.tenantId,this.providerData=e.providerData.map(t=>Object.assign({},t)),this.metadata._copy(e.metadata),this.stsTokenManager._assign(e.stsTokenManager))}_clone(e){const t=new Fe(Object.assign(Object.assign({},this),{auth:e,stsTokenManager:this.stsTokenManager._clone()}));return t.metadata._copy(this.metadata),t}_onReload(e){x(!this.reloadListener,this.auth,"internal-error"),this.reloadListener=e,this.reloadUserInfo&&(this._notifyReloadListener(this.reloadUserInfo),this.reloadUserInfo=null)}_notifyReloadListener(e){this.reloadListener?this.reloadListener(e):this.reloadUserInfo=e}_startProactiveRefresh(){this.proactiveRefresh._start()}_stopProactiveRefresh(){this.proactiveRefresh._stop()}async _updateTokensIfNecessary(e,t=!1){let r=!1;e.idToken&&e.idToken!==this.stsTokenManager.accessToken&&(this.stsTokenManager.updateFromServerResponse(e),r=!0),t&&await Ps(this),await this.auth._persistUserIfCurrent(this),r&&this.auth._notifyListenersIfCurrent(this)}async delete(){if(Pe(this.auth.app))return Promise.reject(ot(this.auth));const e=await this.getIdToken();return await gr(this,Zm(this.auth,{idToken:e})),this.stsTokenManager.clearRefreshToken(),this.auth.signOut()}toJSON(){return Object.assign(Object.assign({uid:this.uid,email:this.email||void 0,emailVerified:this.emailVerified,displayName:this.displayName||void 0,isAnonymous:this.isAnonymous,photoURL:this.photoURL||void 0,phoneNumber:this.phoneNumber||void 0,tenantId:this.tenantId||void 0,providerData:this.providerData.map(e=>Object.assign({},e)),stsTokenManager:this.stsTokenManager.toJSON(),_redirectEventId:this._redirectEventId},this.metadata.toJSON()),{apiKey:this.auth.config.apiKey,appName:this.auth.name})}get refreshToken(){return this.stsTokenManager.refreshToken||""}static _fromJSON(e,t){var r,s,i,a,c,l,d,f;const m=(r=t.displayName)!==null&&r!==void 0?r:void 0,E=(s=t.email)!==null&&s!==void 0?s:void 0,R=(i=t.phoneNumber)!==null&&i!==void 0?i:void 0,C=(a=t.photoURL)!==null&&a!==void 0?a:void 0,N=(c=t.tenantId)!==null&&c!==void 0?c:void 0,k=(l=t._redirectEventId)!==null&&l!==void 0?l:void 0,F=(d=t.createdAt)!==null&&d!==void 0?d:void 0,$=(f=t.lastLoginAt)!==null&&f!==void 0?f:void 0,{uid:M,emailVerified:j,isAnonymous:ce,providerData:X,stsTokenManager:v}=t;x(M&&v,e,"internal-error");const g=yn.fromJSON(this.name,v);x(typeof M=="string",e,"internal-error"),yt(m,e.name),yt(E,e.name),x(typeof j=="boolean",e,"internal-error"),x(typeof ce=="boolean",e,"internal-error"),yt(R,e.name),yt(C,e.name),yt(N,e.name),yt(k,e.name),yt(F,e.name),yt($,e.name);const _=new Fe({uid:M,auth:e,email:E,emailVerified:j,displayName:m,isAnonymous:ce,photoURL:C,phoneNumber:R,tenantId:N,stsTokenManager:g,createdAt:F,lastLoginAt:$});return X&&Array.isArray(X)&&(_.providerData=X.map(T=>Object.assign({},T))),k&&(_._redirectEventId=k),_}static async _fromIdTokenResponse(e,t,r=!1){const s=new yn;s.updateFromServerResponse(t);const i=new Fe({uid:t.localId,auth:e,stsTokenManager:s,isAnonymous:r});return await Ps(i),i}static async _fromGetAccountInfoResponse(e,t,r){const s=t.users[0];x(s.localId!==void 0,"internal-error");const i=s.providerUserInfo!==void 0?Sl(s.providerUserInfo):[],a=!(s.email&&s.passwordHash)&&!(i!=null&&i.length),c=new yn;c.updateFromIdToken(r);const l=new Fe({uid:s.localId,auth:e,stsTokenManager:c,isAnonymous:a}),d={uid:s.localId,displayName:s.displayName||null,photoURL:s.photoUrl||null,email:s.email||null,emailVerified:s.emailVerified||!1,phoneNumber:s.phoneNumber||null,tenantId:s.tenantId||null,providerData:i,metadata:new ro(s.createdAt,s.lastLoginAt),isAnonymous:!(s.email&&s.passwordHash)&&!(i!=null&&i.length)};return Object.assign(l,d),l}}/**
723
+ * @license
724
+ * Copyright 2020 Google LLC
725
+ *
726
+ * Licensed under the Apache License, Version 2.0 (the "License");
727
+ * you may not use this file except in compliance with the License.
728
+ * You may obtain a copy of the License at
729
+ *
730
+ * http://www.apache.org/licenses/LICENSE-2.0
731
+ *
732
+ * Unless required by applicable law or agreed to in writing, software
733
+ * distributed under the License is distributed on an "AS IS" BASIS,
734
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
735
+ * See the License for the specific language governing permissions and
736
+ * limitations under the License.
737
+ */const jc=new Map;function it(n){ht(n instanceof Function,"Expected a class definition");let e=jc.get(n);return e?(ht(e instanceof n,"Instance stored in cache mismatched with class"),e):(e=new n,jc.set(n,e),e)}/**
738
+ * @license
739
+ * Copyright 2019 Google LLC
740
+ *
741
+ * Licensed under the Apache License, Version 2.0 (the "License");
742
+ * you may not use this file except in compliance with the License.
743
+ * You may obtain a copy of the License at
744
+ *
745
+ * http://www.apache.org/licenses/LICENSE-2.0
746
+ *
747
+ * Unless required by applicable law or agreed to in writing, software
748
+ * distributed under the License is distributed on an "AS IS" BASIS,
749
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
750
+ * See the License for the specific language governing permissions and
751
+ * limitations under the License.
752
+ */class Cl{constructor(){this.type="NONE",this.storage={}}async _isAvailable(){return!0}async _set(e,t){this.storage[e]=t}async _get(e){const t=this.storage[e];return t===void 0?null:t}async _remove(e){delete this.storage[e]}_addListener(e,t){}_removeListener(e,t){}}Cl.type="NONE";const Hc=Cl;/**
753
+ * @license
754
+ * Copyright 2019 Google LLC
755
+ *
756
+ * Licensed under the Apache License, Version 2.0 (the "License");
757
+ * you may not use this file except in compliance with the License.
758
+ * You may obtain a copy of the License at
759
+ *
760
+ * http://www.apache.org/licenses/LICENSE-2.0
761
+ *
762
+ * Unless required by applicable law or agreed to in writing, software
763
+ * distributed under the License is distributed on an "AS IS" BASIS,
764
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
765
+ * See the License for the specific language governing permissions and
766
+ * limitations under the License.
767
+ */function ds(n,e,t){return`firebase:${n}:${e}:${t}`}class Tn{constructor(e,t,r){this.persistence=e,this.auth=t,this.userKey=r;const{config:s,name:i}=this.auth;this.fullUserKey=ds(this.userKey,s.apiKey,i),this.fullPersistenceKey=ds("persistence",s.apiKey,i),this.boundEventHandler=t._onStorageEvent.bind(t),this.persistence._addListener(this.fullUserKey,this.boundEventHandler)}setCurrentUser(e){return this.persistence._set(this.fullUserKey,e.toJSON())}async getCurrentUser(){const e=await this.persistence._get(this.fullUserKey);if(!e)return null;if(typeof e=="string"){const t=await bs(this.auth,{idToken:e}).catch(()=>{});return t?Fe._fromGetAccountInfoResponse(this.auth,t,e):null}return Fe._fromJSON(this.auth,e)}removeCurrentUser(){return this.persistence._remove(this.fullUserKey)}savePersistenceForRedirect(){return this.persistence._set(this.fullPersistenceKey,this.persistence.type)}async setPersistence(e){if(this.persistence===e)return;const t=await this.getCurrentUser();if(await this.removeCurrentUser(),this.persistence=e,t)return this.setCurrentUser(t)}delete(){this.persistence._removeListener(this.fullUserKey,this.boundEventHandler)}static async create(e,t,r="authUser"){if(!t.length)return new Tn(it(Hc),e,r);const s=(await Promise.all(t.map(async d=>{if(await d._isAvailable())return d}))).filter(d=>d);let i=s[0]||it(Hc);const a=ds(r,e.config.apiKey,e.name);let c=null;for(const d of t)try{const f=await d._get(a);if(f){let m;if(typeof f=="string"){const E=await bs(e,{idToken:f}).catch(()=>{});if(!E)break;m=await Fe._fromGetAccountInfoResponse(e,E,f)}else m=Fe._fromJSON(e,f);d!==i&&(c=m),i=d;break}}catch{}const l=s.filter(d=>d._shouldAllowMigration);return!i._shouldAllowMigration||!l.length?new Tn(i,e,r):(i=l[0],c&&await i._set(a,c.toJSON()),await Promise.all(t.map(async d=>{if(d!==i)try{await d._remove(a)}catch{}})),new Tn(i,e,r))}}/**
768
+ * @license
769
+ * Copyright 2020 Google LLC
770
+ *
771
+ * Licensed under the Apache License, Version 2.0 (the "License");
772
+ * you may not use this file except in compliance with the License.
773
+ * You may obtain a copy of the License at
774
+ *
775
+ * http://www.apache.org/licenses/LICENSE-2.0
776
+ *
777
+ * Unless required by applicable law or agreed to in writing, software
778
+ * distributed under the License is distributed on an "AS IS" BASIS,
779
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
780
+ * See the License for the specific language governing permissions and
781
+ * limitations under the License.
782
+ */function zc(n){const e=n.toLowerCase();if(e.includes("opera/")||e.includes("opr/")||e.includes("opios/"))return"Opera";if(Ol(e))return"IEMobile";if(e.includes("msie")||e.includes("trident/"))return"IE";if(e.includes("edge/"))return"Edge";if(kl(e))return"Firefox";if(e.includes("silk/"))return"Silk";if(Ll(e))return"Blackberry";if(Ml(e))return"Webos";if(Nl(e))return"Safari";if((e.includes("chrome/")||Dl(e))&&!e.includes("edge/"))return"Chrome";if(Vl(e))return"Android";{const t=/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/,r=n.match(t);if((r==null?void 0:r.length)===2)return r[1]}return"Other"}function kl(n=we()){return/firefox\//i.test(n)}function Nl(n=we()){const e=n.toLowerCase();return e.includes("safari/")&&!e.includes("chrome/")&&!e.includes("crios/")&&!e.includes("android")}function Dl(n=we()){return/crios\//i.test(n)}function Ol(n=we()){return/iemobile/i.test(n)}function Vl(n=we()){return/android/i.test(n)}function Ll(n=we()){return/blackberry/i.test(n)}function Ml(n=we()){return/webos/i.test(n)}function No(n=we()){return/iphone|ipad|ipod/i.test(n)||/macintosh/i.test(n)&&/mobile/i.test(n)}function og(n=we()){var e;return No(n)&&!!(!((e=window.navigator)===null||e===void 0)&&e.standalone)}function ag(){return up()&&document.documentMode===10}function xl(n=we()){return No(n)||Vl(n)||Ml(n)||Ll(n)||/windows phone/i.test(n)||Ol(n)}/**
783
+ * @license
784
+ * Copyright 2020 Google LLC
785
+ *
786
+ * Licensed under the Apache License, Version 2.0 (the "License");
787
+ * you may not use this file except in compliance with the License.
788
+ * You may obtain a copy of the License at
789
+ *
790
+ * http://www.apache.org/licenses/LICENSE-2.0
791
+ *
792
+ * Unless required by applicable law or agreed to in writing, software
793
+ * distributed under the License is distributed on an "AS IS" BASIS,
794
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
795
+ * See the License for the specific language governing permissions and
796
+ * limitations under the License.
797
+ */function Ul(n,e=[]){let t;switch(n){case"Browser":t=zc(we());break;case"Worker":t=`${zc(we())}-${n}`;break;default:t=n}const r=e.length?e.join(","):"FirebaseCore-web";return`${t}/JsCore/${nn}/${r}`}/**
798
+ * @license
799
+ * Copyright 2022 Google LLC
800
+ *
801
+ * Licensed under the Apache License, Version 2.0 (the "License");
802
+ * you may not use this file except in compliance with the License.
803
+ * You may obtain a copy of the License at
804
+ *
805
+ * http://www.apache.org/licenses/LICENSE-2.0
806
+ *
807
+ * Unless required by applicable law or agreed to in writing, software
808
+ * distributed under the License is distributed on an "AS IS" BASIS,
809
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
810
+ * See the License for the specific language governing permissions and
811
+ * limitations under the License.
812
+ */class cg{constructor(e){this.auth=e,this.queue=[]}pushCallback(e,t){const r=i=>new Promise((a,c)=>{try{const l=e(i);a(l)}catch(l){c(l)}});r.onAbort=t,this.queue.push(r);const s=this.queue.length-1;return()=>{this.queue[s]=()=>Promise.resolve()}}async runMiddleware(e){if(this.auth.currentUser===e)return;const t=[];try{for(const r of this.queue)await r(e),r.onAbort&&t.push(r.onAbort)}catch(r){t.reverse();for(const s of t)try{s()}catch{}throw this.auth._errorFactory.create("login-blocked",{originalMessage:r==null?void 0:r.message})}}}/**
813
+ * @license
814
+ * Copyright 2023 Google LLC
815
+ *
816
+ * Licensed under the Apache License, Version 2.0 (the "License");
817
+ * you may not use this file except in compliance with the License.
818
+ * You may obtain a copy of the License at
819
+ *
820
+ * http://www.apache.org/licenses/LICENSE-2.0
821
+ *
822
+ * Unless required by applicable law or agreed to in writing, software
823
+ * distributed under the License is distributed on an "AS IS" BASIS,
824
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
825
+ * See the License for the specific language governing permissions and
826
+ * limitations under the License.
827
+ */async function ug(n,e={}){return Mt(n,"GET","/v2/passwordPolicy",Lt(n,e))}/**
828
+ * @license
829
+ * Copyright 2023 Google LLC
830
+ *
831
+ * Licensed under the Apache License, Version 2.0 (the "License");
832
+ * you may not use this file except in compliance with the License.
833
+ * You may obtain a copy of the License at
834
+ *
835
+ * http://www.apache.org/licenses/LICENSE-2.0
836
+ *
837
+ * Unless required by applicable law or agreed to in writing, software
838
+ * distributed under the License is distributed on an "AS IS" BASIS,
839
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
840
+ * See the License for the specific language governing permissions and
841
+ * limitations under the License.
842
+ */const lg=6;class hg{constructor(e){var t,r,s,i;const a=e.customStrengthOptions;this.customStrengthOptions={},this.customStrengthOptions.minPasswordLength=(t=a.minPasswordLength)!==null&&t!==void 0?t:lg,a.maxPasswordLength&&(this.customStrengthOptions.maxPasswordLength=a.maxPasswordLength),a.containsLowercaseCharacter!==void 0&&(this.customStrengthOptions.containsLowercaseLetter=a.containsLowercaseCharacter),a.containsUppercaseCharacter!==void 0&&(this.customStrengthOptions.containsUppercaseLetter=a.containsUppercaseCharacter),a.containsNumericCharacter!==void 0&&(this.customStrengthOptions.containsNumericCharacter=a.containsNumericCharacter),a.containsNonAlphanumericCharacter!==void 0&&(this.customStrengthOptions.containsNonAlphanumericCharacter=a.containsNonAlphanumericCharacter),this.enforcementState=e.enforcementState,this.enforcementState==="ENFORCEMENT_STATE_UNSPECIFIED"&&(this.enforcementState="OFF"),this.allowedNonAlphanumericCharacters=(s=(r=e.allowedNonAlphanumericCharacters)===null||r===void 0?void 0:r.join(""))!==null&&s!==void 0?s:"",this.forceUpgradeOnSignin=(i=e.forceUpgradeOnSignin)!==null&&i!==void 0?i:!1,this.schemaVersion=e.schemaVersion}validatePassword(e){var t,r,s,i,a,c;const l={isValid:!0,passwordPolicy:this};return this.validatePasswordLengthOptions(e,l),this.validatePasswordCharacterOptions(e,l),l.isValid&&(l.isValid=(t=l.meetsMinPasswordLength)!==null&&t!==void 0?t:!0),l.isValid&&(l.isValid=(r=l.meetsMaxPasswordLength)!==null&&r!==void 0?r:!0),l.isValid&&(l.isValid=(s=l.containsLowercaseLetter)!==null&&s!==void 0?s:!0),l.isValid&&(l.isValid=(i=l.containsUppercaseLetter)!==null&&i!==void 0?i:!0),l.isValid&&(l.isValid=(a=l.containsNumericCharacter)!==null&&a!==void 0?a:!0),l.isValid&&(l.isValid=(c=l.containsNonAlphanumericCharacter)!==null&&c!==void 0?c:!0),l}validatePasswordLengthOptions(e,t){const r=this.customStrengthOptions.minPasswordLength,s=this.customStrengthOptions.maxPasswordLength;r&&(t.meetsMinPasswordLength=e.length>=r),s&&(t.meetsMaxPasswordLength=e.length<=s)}validatePasswordCharacterOptions(e,t){this.updatePasswordCharacterOptionsStatuses(t,!1,!1,!1,!1);let r;for(let s=0;s<e.length;s++)r=e.charAt(s),this.updatePasswordCharacterOptionsStatuses(t,r>="a"&&r<="z",r>="A"&&r<="Z",r>="0"&&r<="9",this.allowedNonAlphanumericCharacters.includes(r))}updatePasswordCharacterOptionsStatuses(e,t,r,s,i){this.customStrengthOptions.containsLowercaseLetter&&(e.containsLowercaseLetter||(e.containsLowercaseLetter=t)),this.customStrengthOptions.containsUppercaseLetter&&(e.containsUppercaseLetter||(e.containsUppercaseLetter=r)),this.customStrengthOptions.containsNumericCharacter&&(e.containsNumericCharacter||(e.containsNumericCharacter=s)),this.customStrengthOptions.containsNonAlphanumericCharacter&&(e.containsNonAlphanumericCharacter||(e.containsNonAlphanumericCharacter=i))}}/**
843
+ * @license
844
+ * Copyright 2020 Google LLC
845
+ *
846
+ * Licensed under the Apache License, Version 2.0 (the "License");
847
+ * you may not use this file except in compliance with the License.
848
+ * You may obtain a copy of the License at
849
+ *
850
+ * http://www.apache.org/licenses/LICENSE-2.0
851
+ *
852
+ * Unless required by applicable law or agreed to in writing, software
853
+ * distributed under the License is distributed on an "AS IS" BASIS,
854
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
855
+ * See the License for the specific language governing permissions and
856
+ * limitations under the License.
857
+ */class dg{constructor(e,t,r,s){this.app=e,this.heartbeatServiceProvider=t,this.appCheckServiceProvider=r,this.config=s,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new Gc(this),this.idTokenSubscription=new Gc(this),this.beforeStateQueue=new cg(this),this.redirectUser=null,this.isProactiveRefreshEnabled=!1,this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION=1,this._canInitEmulator=!0,this._isInitialized=!1,this._deleted=!1,this._initializationPromise=null,this._popupRedirectResolver=null,this._errorFactory=wl,this._agentRecaptchaConfig=null,this._tenantRecaptchaConfigs={},this._projectPasswordPolicy=null,this._tenantPasswordPolicies={},this._resolvePersistenceManagerAvailable=void 0,this.lastNotifiedUid=void 0,this.languageCode=null,this.tenantId=null,this.settings={appVerificationDisabledForTesting:!1},this.frameworks=[],this.name=e.name,this.clientVersion=s.sdkClientVersion,this._persistenceManagerAvailable=new Promise(i=>this._resolvePersistenceManagerAvailable=i)}_initializeWithPersistence(e,t){return t&&(this._popupRedirectResolver=it(t)),this._initializationPromise=this.queue(async()=>{var r,s,i;if(!this._deleted&&(this.persistenceManager=await Tn.create(this,e),(r=this._resolvePersistenceManagerAvailable)===null||r===void 0||r.call(this),!this._deleted)){if(!((s=this._popupRedirectResolver)===null||s===void 0)&&s._shouldInitProactively)try{await this._popupRedirectResolver._initialize(this)}catch{}await this.initializeCurrentUser(t),this.lastNotifiedUid=((i=this.currentUser)===null||i===void 0?void 0:i.uid)||null,!this._deleted&&(this._isInitialized=!0)}}),this._initializationPromise}async _onStorageEvent(){if(this._deleted)return;const e=await this.assertedPersistence.getCurrentUser();if(!(!this.currentUser&&!e)){if(this.currentUser&&e&&this.currentUser.uid===e.uid){this._currentUser._assign(e),await this.currentUser.getIdToken();return}await this._updateCurrentUser(e,!0)}}async initializeCurrentUserFromIdToken(e){try{const t=await bs(this,{idToken:e}),r=await Fe._fromGetAccountInfoResponse(this,t,e);await this.directlySetCurrentUser(r)}catch(t){console.warn("FirebaseServerApp could not login user with provided authIdToken: ",t),await this.directlySetCurrentUser(null)}}async initializeCurrentUser(e){var t;if(Pe(this.app)){const a=this.app.settings.authIdToken;return a?new Promise(c=>{setTimeout(()=>this.initializeCurrentUserFromIdToken(a).then(c,c))}):this.directlySetCurrentUser(null)}const r=await this.assertedPersistence.getCurrentUser();let s=r,i=!1;if(e&&this.config.authDomain){await this.getOrInitRedirectPersistenceManager();const a=(t=this.redirectUser)===null||t===void 0?void 0:t._redirectEventId,c=s==null?void 0:s._redirectEventId,l=await this.tryRedirectSignIn(e);(!a||a===c)&&(l!=null&&l.user)&&(s=l.user,i=!0)}if(!s)return this.directlySetCurrentUser(null);if(!s._redirectEventId){if(i)try{await this.beforeStateQueue.runMiddleware(s)}catch(a){s=r,this._popupRedirectResolver._overrideRedirectResult(this,()=>Promise.reject(a))}return s?this.reloadAndSetCurrentUserOrClear(s):this.directlySetCurrentUser(null)}return x(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===s._redirectEventId?this.directlySetCurrentUser(s):this.reloadAndSetCurrentUserOrClear(s)}async tryRedirectSignIn(e){let t=null;try{t=await this._popupRedirectResolver._completeRedirectFn(this,e,!0)}catch{await this._setRedirectUser(null)}return t}async reloadAndSetCurrentUserOrClear(e){try{await Ps(e)}catch(t){if((t==null?void 0:t.code)!=="auth/network-request-failed")return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(e)}useDeviceLanguage(){this.languageCode=zm()}async _delete(){this._deleted=!0}async updateCurrentUser(e){if(Pe(this.app))return Promise.reject(ot(this));const t=e?Z(e):null;return t&&x(t.auth.config.apiKey===this.config.apiKey,this,"invalid-user-token"),this._updateCurrentUser(t&&t._clone(this))}async _updateCurrentUser(e,t=!1){if(!this._deleted)return e&&x(this.tenantId===e.tenantId,this,"tenant-id-mismatch"),t||await this.beforeStateQueue.runMiddleware(e),this.queue(async()=>{await this.directlySetCurrentUser(e),this.notifyAuthListeners()})}async signOut(){return Pe(this.app)?Promise.reject(ot(this)):(await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0))}setPersistence(e){return Pe(this.app)?Promise.reject(ot(this)):this.queue(async()=>{await this.assertedPersistence.setPersistence(it(e))})}_getRecaptchaConfig(){return this.tenantId==null?this._agentRecaptchaConfig:this._tenantRecaptchaConfigs[this.tenantId]}async validatePassword(e){this._getPasswordPolicyInternal()||await this._updatePasswordPolicy();const t=this._getPasswordPolicyInternal();return t.schemaVersion!==this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION?Promise.reject(this._errorFactory.create("unsupported-password-policy-schema-version",{})):t.validatePassword(e)}_getPasswordPolicyInternal(){return this.tenantId===null?this._projectPasswordPolicy:this._tenantPasswordPolicies[this.tenantId]}async _updatePasswordPolicy(){const e=await ug(this),t=new hg(e);this.tenantId===null?this._projectPasswordPolicy=t:this._tenantPasswordPolicies[this.tenantId]=t}_getPersistenceType(){return this.assertedPersistence.persistence.type}_getPersistence(){return this.assertedPersistence.persistence}_updateErrorMap(e){this._errorFactory=new Rr("auth","Firebase",e())}onAuthStateChanged(e,t,r){return this.registerStateListener(this.authStateSubscription,e,t,r)}beforeAuthStateChanged(e,t){return this.beforeStateQueue.pushCallback(e,t)}onIdTokenChanged(e,t,r){return this.registerStateListener(this.idTokenSubscription,e,t,r)}authStateReady(){return new Promise((e,t)=>{if(this.currentUser)e();else{const r=this.onAuthStateChanged(()=>{r(),e()},t)}})}async revokeAccessToken(e){if(this.currentUser){const t=await this.currentUser.getIdToken(),r={providerId:"apple.com",tokenType:"ACCESS_TOKEN",token:e,idToken:t};this.tenantId!=null&&(r.tenantId=this.tenantId),await ig(this,r)}}toJSON(){var e;return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:(e=this._currentUser)===null||e===void 0?void 0:e.toJSON()}}async _setRedirectUser(e,t){const r=await this.getOrInitRedirectPersistenceManager(t);return e===null?r.removeCurrentUser():r.setCurrentUser(e)}async getOrInitRedirectPersistenceManager(e){if(!this.redirectPersistenceManager){const t=e&&it(e)||this._popupRedirectResolver;x(t,this,"argument-error"),this.redirectPersistenceManager=await Tn.create(this,[it(t._redirectPersistence)],"redirectUser"),this.redirectUser=await this.redirectPersistenceManager.getCurrentUser()}return this.redirectPersistenceManager}async _redirectUserForId(e){var t,r;return this._isInitialized&&await this.queue(async()=>{}),((t=this._currentUser)===null||t===void 0?void 0:t._redirectEventId)===e?this._currentUser:((r=this.redirectUser)===null||r===void 0?void 0:r._redirectEventId)===e?this.redirectUser:null}async _persistUserIfCurrent(e){if(e===this.currentUser)return this.queue(async()=>this.directlySetCurrentUser(e))}_notifyListenersIfCurrent(e){e===this.currentUser&&this.notifyAuthListeners()}_key(){return`${this.config.authDomain}:${this.config.apiKey}:${this.name}`}_startProactiveRefresh(){this.isProactiveRefreshEnabled=!0,this.currentUser&&this._currentUser._startProactiveRefresh()}_stopProactiveRefresh(){this.isProactiveRefreshEnabled=!1,this.currentUser&&this._currentUser._stopProactiveRefresh()}get _currentUser(){return this.currentUser}notifyAuthListeners(){var e,t;if(!this._isInitialized)return;this.idTokenSubscription.next(this.currentUser);const r=(t=(e=this.currentUser)===null||e===void 0?void 0:e.uid)!==null&&t!==void 0?t:null;this.lastNotifiedUid!==r&&(this.lastNotifiedUid=r,this.authStateSubscription.next(this.currentUser))}registerStateListener(e,t,r,s){if(this._deleted)return()=>{};const i=typeof t=="function"?t:t.next.bind(t);let a=!1;const c=this._isInitialized?Promise.resolve():this._initializationPromise;if(x(c,this,"internal-error"),c.then(()=>{a||i(this.currentUser)}),typeof t=="function"){const l=e.addObserver(t,r,s);return()=>{a=!0,l()}}else{const l=e.addObserver(t);return()=>{a=!0,l()}}}async directlySetCurrentUser(e){this.currentUser&&this.currentUser!==e&&this._currentUser._stopProactiveRefresh(),e&&this.isProactiveRefreshEnabled&&e._startProactiveRefresh(),this.currentUser=e,e?await this.assertedPersistence.setCurrentUser(e):await this.assertedPersistence.removeCurrentUser()}queue(e){return this.operations=this.operations.then(e,e),this.operations}get assertedPersistence(){return x(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(e){!e||this.frameworks.includes(e)||(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=Ul(this.config.clientPlatform,this._getFrameworks()))}_getFrameworks(){return this.frameworks}async _getAdditionalHeaders(){var e;const t={"X-Client-Version":this.clientVersion};this.app.options.appId&&(t["X-Firebase-gmpid"]=this.app.options.appId);const r=await((e=this.heartbeatServiceProvider.getImmediate({optional:!0}))===null||e===void 0?void 0:e.getHeartbeatsHeader());r&&(t["X-Firebase-Client"]=r);const s=await this._getAppCheckToken();return s&&(t["X-Firebase-AppCheck"]=s),t}async _getAppCheckToken(){var e;if(Pe(this.app)&&this.app.settings.appCheckToken)return this.app.settings.appCheckToken;const t=await((e=this.appCheckServiceProvider.getImmediate({optional:!0}))===null||e===void 0?void 0:e.getToken());return t!=null&&t.error&&qm(`Error while retrieving App Check token: ${t.error}`),t==null?void 0:t.token}}function xt(n){return Z(n)}class Gc{constructor(e){this.auth=e,this.observer=null,this.addObserver=_p(t=>this.observer=t)}get next(){return x(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}/**
858
+ * @license
859
+ * Copyright 2020 Google LLC
860
+ *
861
+ * Licensed under the Apache License, Version 2.0 (the "License");
862
+ * you may not use this file except in compliance with the License.
863
+ * You may obtain a copy of the License at
864
+ *
865
+ * http://www.apache.org/licenses/LICENSE-2.0
866
+ *
867
+ * Unless required by applicable law or agreed to in writing, software
868
+ * distributed under the License is distributed on an "AS IS" BASIS,
869
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
870
+ * See the License for the specific language governing permissions and
871
+ * limitations under the License.
872
+ */let Ws={async loadJS(){throw new Error("Unable to load external scripts")},recaptchaV2Script:"",recaptchaEnterpriseScript:"",gapiScript:""};function fg(n){Ws=n}function Fl(n){return Ws.loadJS(n)}function pg(){return Ws.recaptchaEnterpriseScript}function mg(){return Ws.gapiScript}function gg(n){return`__${n}${Math.floor(Math.random()*1e6)}`}class _g{constructor(){this.enterprise=new yg}ready(e){e()}execute(e,t){return Promise.resolve("token")}render(e,t){return""}}class yg{ready(e){e()}execute(e,t){return Promise.resolve("token")}render(e,t){return""}}const Tg="recaptcha-enterprise",Bl="NO_RECAPTCHA";class Eg{constructor(e){this.type=Tg,this.auth=xt(e)}async verify(e="verify",t=!1){async function r(i){if(!t){if(i.tenantId==null&&i._agentRecaptchaConfig!=null)return i._agentRecaptchaConfig.siteKey;if(i.tenantId!=null&&i._tenantRecaptchaConfigs[i.tenantId]!==void 0)return i._tenantRecaptchaConfigs[i.tenantId].siteKey}return new Promise(async(a,c)=>{Ym(i,{clientType:"CLIENT_TYPE_WEB",version:"RECAPTCHA_ENTERPRISE"}).then(l=>{if(l.recaptchaKey===void 0)c(new Error("recaptcha Enterprise site key undefined"));else{const d=new Jm(l);return i.tenantId==null?i._agentRecaptchaConfig=d:i._tenantRecaptchaConfigs[i.tenantId]=d,a(d.siteKey)}}).catch(l=>{c(l)})})}function s(i,a,c){const l=window.grecaptcha;qc(l)?l.enterprise.ready(()=>{l.enterprise.execute(i,{action:e}).then(d=>{a(d)}).catch(()=>{a(Bl)})}):c(Error("No reCAPTCHA enterprise script loaded."))}return this.auth.settings.appVerificationDisabledForTesting?new _g().execute("siteKey",{action:"verify"}):new Promise((i,a)=>{r(this.auth).then(c=>{if(!t&&qc(window.grecaptcha))s(c,i,a);else{if(typeof window>"u"){a(new Error("RecaptchaVerifier is only supported in browser"));return}let l=pg();l.length!==0&&(l+=c),Fl(l).then(()=>{s(c,i,a)}).catch(d=>{a(d)})}}).catch(c=>{a(c)})})}}async function Wc(n,e,t,r=!1,s=!1){const i=new Eg(n);let a;if(s)a=Bl;else try{a=await i.verify(t)}catch{a=await i.verify(t,!0)}const c=Object.assign({},e);if(t==="mfaSmsEnrollment"||t==="mfaSmsSignIn"){if("phoneEnrollmentInfo"in c){const l=c.phoneEnrollmentInfo.phoneNumber,d=c.phoneEnrollmentInfo.recaptchaToken;Object.assign(c,{phoneEnrollmentInfo:{phoneNumber:l,recaptchaToken:d,captchaResponse:a,clientType:"CLIENT_TYPE_WEB",recaptchaVersion:"RECAPTCHA_ENTERPRISE"}})}else if("phoneSignInInfo"in c){const l=c.phoneSignInInfo.recaptchaToken;Object.assign(c,{phoneSignInInfo:{recaptchaToken:l,captchaResponse:a,clientType:"CLIENT_TYPE_WEB",recaptchaVersion:"RECAPTCHA_ENTERPRISE"}})}return c}return r?Object.assign(c,{captchaResp:a}):Object.assign(c,{captchaResponse:a}),Object.assign(c,{clientType:"CLIENT_TYPE_WEB"}),Object.assign(c,{recaptchaVersion:"RECAPTCHA_ENTERPRISE"}),c}async function Kc(n,e,t,r,s){var i;if(!((i=n._getRecaptchaConfig())===null||i===void 0)&&i.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")){const a=await Wc(n,e,t,t==="getOobCode");return r(n,a)}else return r(n,e).catch(async a=>{if(a.code==="auth/missing-recaptcha-token"){console.log(`${t} is protected by reCAPTCHA Enterprise for this project. Automatically triggering the reCAPTCHA flow and restarting the flow.`);const c=await Wc(n,e,t,t==="getOobCode");return r(n,c)}else return Promise.reject(a)})}/**
873
+ * @license
874
+ * Copyright 2020 Google LLC
875
+ *
876
+ * Licensed under the Apache License, Version 2.0 (the "License");
877
+ * you may not use this file except in compliance with the License.
878
+ * You may obtain a copy of the License at
879
+ *
880
+ * http://www.apache.org/licenses/LICENSE-2.0
881
+ *
882
+ * Unless required by applicable law or agreed to in writing, software
883
+ * distributed under the License is distributed on an "AS IS" BASIS,
884
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
885
+ * See the License for the specific language governing permissions and
886
+ * limitations under the License.
887
+ */function vg(n,e){const t=Pr(n,"auth");if(t.isInitialized()){const s=t.getImmediate(),i=t.getOptions();if(Qt(i,e??{}))return s;Me(s,"already-initialized")}return t.initialize({options:e})}function Ig(n,e){const t=(e==null?void 0:e.persistence)||[],r=(Array.isArray(t)?t:[t]).map(it);e!=null&&e.errorMap&&n._updateErrorMap(e.errorMap),n._initializeWithPersistence(r,e==null?void 0:e.popupRedirectResolver)}function wg(n,e,t){const r=xt(n);x(/^https?:\/\//.test(e),r,"invalid-emulator-scheme");const s=!1,i=ql(e),{host:a,port:c}=Ag(e),l=c===null?"":`:${c}`,d={url:`${i}//${a}${l}/`},f=Object.freeze({host:a,port:c,protocol:i.replace(":",""),options:Object.freeze({disableWarnings:s})});if(!r._canInitEmulator){x(r.config.emulator&&r.emulatorConfig,r,"emulator-config-failed"),x(Qt(d,r.config.emulator)&&Qt(f,r.emulatorConfig),r,"emulator-config-failed");return}r.config.emulator=d,r.emulatorConfig=f,r.settings.appVerificationDisabledForTesting=!0,Rg()}function ql(n){const e=n.indexOf(":");return e<0?"":n.substr(0,e+1)}function Ag(n){const e=ql(n),t=/(\/\/)?([^?#/]+)/.exec(n.substr(e.length));if(!t)return{host:"",port:null};const r=t[2].split("@").pop()||"",s=/^(\[[^\]]+\])(:|$)/.exec(r);if(s){const i=s[1];return{host:i,port:Qc(r.substr(i.length+1))}}else{const[i,a]=r.split(":");return{host:i,port:Qc(a)}}}function Qc(n){if(!n)return null;const e=Number(n);return isNaN(e)?null:e}function Rg(){function n(){const e=document.createElement("p"),t=e.style;e.innerText="Running in emulator mode. Do not use with production credentials.",t.position="fixed",t.width="100%",t.backgroundColor="#ffffff",t.border=".1em solid #000000",t.color="#b50000",t.bottom="0px",t.left="0px",t.margin="0px",t.zIndex="10000",t.textAlign="center",e.classList.add("firebase-emulator-warning"),document.body.appendChild(e)}typeof console<"u"&&typeof console.info=="function"&&console.info("WARNING: You are using the Auth Emulator, which is intended for local testing only. Do not use with production credentials."),typeof window<"u"&&typeof document<"u"&&(document.readyState==="loading"?window.addEventListener("DOMContentLoaded",n):n())}/**
888
+ * @license
889
+ * Copyright 2020 Google LLC
890
+ *
891
+ * Licensed under the Apache License, Version 2.0 (the "License");
892
+ * you may not use this file except in compliance with the License.
893
+ * You may obtain a copy of the License at
894
+ *
895
+ * http://www.apache.org/licenses/LICENSE-2.0
896
+ *
897
+ * Unless required by applicable law or agreed to in writing, software
898
+ * distributed under the License is distributed on an "AS IS" BASIS,
899
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
900
+ * See the License for the specific language governing permissions and
901
+ * limitations under the License.
902
+ */class Do{constructor(e,t){this.providerId=e,this.signInMethod=t}toJSON(){return st("not implemented")}_getIdTokenResponse(e){return st("not implemented")}_linkToIdToken(e,t){return st("not implemented")}_getReauthenticationResolver(e){return st("not implemented")}}async function bg(n,e){return Mt(n,"POST","/v1/accounts:signUp",e)}/**
903
+ * @license
904
+ * Copyright 2020 Google LLC
905
+ *
906
+ * Licensed under the Apache License, Version 2.0 (the "License");
907
+ * you may not use this file except in compliance with the License.
908
+ * You may obtain a copy of the License at
909
+ *
910
+ * http://www.apache.org/licenses/LICENSE-2.0
911
+ *
912
+ * Unless required by applicable law or agreed to in writing, software
913
+ * distributed under the License is distributed on an "AS IS" BASIS,
914
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
915
+ * See the License for the specific language governing permissions and
916
+ * limitations under the License.
917
+ */async function Pg(n,e){return Cr(n,"POST","/v1/accounts:signInWithPassword",Lt(n,e))}/**
918
+ * @license
919
+ * Copyright 2020 Google LLC
920
+ *
921
+ * Licensed under the Apache License, Version 2.0 (the "License");
922
+ * you may not use this file except in compliance with the License.
923
+ * You may obtain a copy of the License at
924
+ *
925
+ * http://www.apache.org/licenses/LICENSE-2.0
926
+ *
927
+ * Unless required by applicable law or agreed to in writing, software
928
+ * distributed under the License is distributed on an "AS IS" BASIS,
929
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
930
+ * See the License for the specific language governing permissions and
931
+ * limitations under the License.
932
+ */async function Sg(n,e){return Cr(n,"POST","/v1/accounts:signInWithEmailLink",Lt(n,e))}async function Cg(n,e){return Cr(n,"POST","/v1/accounts:signInWithEmailLink",Lt(n,e))}/**
933
+ * @license
934
+ * Copyright 2020 Google LLC
935
+ *
936
+ * Licensed under the Apache License, Version 2.0 (the "License");
937
+ * you may not use this file except in compliance with the License.
938
+ * You may obtain a copy of the License at
939
+ *
940
+ * http://www.apache.org/licenses/LICENSE-2.0
941
+ *
942
+ * Unless required by applicable law or agreed to in writing, software
943
+ * distributed under the License is distributed on an "AS IS" BASIS,
944
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
945
+ * See the License for the specific language governing permissions and
946
+ * limitations under the License.
947
+ */class _r extends Do{constructor(e,t,r,s=null){super("password",r),this._email=e,this._password=t,this._tenantId=s}static _fromEmailAndPassword(e,t){return new _r(e,t,"password")}static _fromEmailAndCode(e,t,r=null){return new _r(e,t,"emailLink",r)}toJSON(){return{email:this._email,password:this._password,signInMethod:this.signInMethod,tenantId:this._tenantId}}static fromJSON(e){const t=typeof e=="string"?JSON.parse(e):e;if(t!=null&&t.email&&(t!=null&&t.password)){if(t.signInMethod==="password")return this._fromEmailAndPassword(t.email,t.password);if(t.signInMethod==="emailLink")return this._fromEmailAndCode(t.email,t.password,t.tenantId)}return null}async _getIdTokenResponse(e){switch(this.signInMethod){case"password":const t={returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"};return Kc(e,t,"signInWithPassword",Pg);case"emailLink":return Sg(e,{email:this._email,oobCode:this._password});default:Me(e,"internal-error")}}async _linkToIdToken(e,t){switch(this.signInMethod){case"password":const r={idToken:t,returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"};return Kc(e,r,"signUpPassword",bg);case"emailLink":return Cg(e,{idToken:t,email:this._email,oobCode:this._password});default:Me(e,"internal-error")}}_getReauthenticationResolver(e){return this._getIdTokenResponse(e)}}/**
948
+ * @license
949
+ * Copyright 2020 Google LLC
950
+ *
951
+ * Licensed under the Apache License, Version 2.0 (the "License");
952
+ * you may not use this file except in compliance with the License.
953
+ * You may obtain a copy of the License at
954
+ *
955
+ * http://www.apache.org/licenses/LICENSE-2.0
956
+ *
957
+ * Unless required by applicable law or agreed to in writing, software
958
+ * distributed under the License is distributed on an "AS IS" BASIS,
959
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
960
+ * See the License for the specific language governing permissions and
961
+ * limitations under the License.
962
+ */async function En(n,e){return Cr(n,"POST","/v1/accounts:signInWithIdp",Lt(n,e))}/**
963
+ * @license
964
+ * Copyright 2020 Google LLC
965
+ *
966
+ * Licensed under the Apache License, Version 2.0 (the "License");
967
+ * you may not use this file except in compliance with the License.
968
+ * You may obtain a copy of the License at
969
+ *
970
+ * http://www.apache.org/licenses/LICENSE-2.0
971
+ *
972
+ * Unless required by applicable law or agreed to in writing, software
973
+ * distributed under the License is distributed on an "AS IS" BASIS,
974
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
975
+ * See the License for the specific language governing permissions and
976
+ * limitations under the License.
977
+ */const kg="http://localhost";class Xt extends Do{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(e){const t=new Xt(e.providerId,e.signInMethod);return e.idToken||e.accessToken?(e.idToken&&(t.idToken=e.idToken),e.accessToken&&(t.accessToken=e.accessToken),e.nonce&&!e.pendingToken&&(t.nonce=e.nonce),e.pendingToken&&(t.pendingToken=e.pendingToken)):e.oauthToken&&e.oauthTokenSecret?(t.accessToken=e.oauthToken,t.secret=e.oauthTokenSecret):Me("argument-error"),t}toJSON(){return{idToken:this.idToken,accessToken:this.accessToken,secret:this.secret,nonce:this.nonce,pendingToken:this.pendingToken,providerId:this.providerId,signInMethod:this.signInMethod}}static fromJSON(e){const t=typeof e=="string"?JSON.parse(e):e,{providerId:r,signInMethod:s}=t,i=wo(t,["providerId","signInMethod"]);if(!r||!s)return null;const a=new Xt(r,s);return a.idToken=i.idToken||void 0,a.accessToken=i.accessToken||void 0,a.secret=i.secret,a.nonce=i.nonce,a.pendingToken=i.pendingToken||null,a}_getIdTokenResponse(e){const t=this.buildRequest();return En(e,t)}_linkToIdToken(e,t){const r=this.buildRequest();return r.idToken=t,En(e,r)}_getReauthenticationResolver(e){const t=this.buildRequest();return t.autoCreate=!1,En(e,t)}buildRequest(){const e={requestUri:kg,returnSecureToken:!0};if(this.pendingToken)e.pendingToken=this.pendingToken;else{const t={};this.idToken&&(t.id_token=this.idToken),this.accessToken&&(t.access_token=this.accessToken),this.secret&&(t.oauth_token_secret=this.secret),t.providerId=this.providerId,this.nonce&&!this.pendingToken&&(t.nonce=this.nonce),e.postBody=br(t)}return e}}/**
978
+ * @license
979
+ * Copyright 2020 Google LLC
980
+ *
981
+ * Licensed under the Apache License, Version 2.0 (the "License");
982
+ * you may not use this file except in compliance with the License.
983
+ * You may obtain a copy of the License at
984
+ *
985
+ * http://www.apache.org/licenses/LICENSE-2.0
986
+ *
987
+ * Unless required by applicable law or agreed to in writing, software
988
+ * distributed under the License is distributed on an "AS IS" BASIS,
989
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
990
+ * See the License for the specific language governing permissions and
991
+ * limitations under the License.
992
+ */function Ng(n){switch(n){case"recoverEmail":return"RECOVER_EMAIL";case"resetPassword":return"PASSWORD_RESET";case"signIn":return"EMAIL_SIGNIN";case"verifyEmail":return"VERIFY_EMAIL";case"verifyAndChangeEmail":return"VERIFY_AND_CHANGE_EMAIL";case"revertSecondFactorAddition":return"REVERT_SECOND_FACTOR_ADDITION";default:return null}}function Dg(n){const e=sr(ir(n)).link,t=e?sr(ir(e)).deep_link_id:null,r=sr(ir(n)).deep_link_id;return(r?sr(ir(r)).link:null)||r||t||e||n}class Oo{constructor(e){var t,r,s,i,a,c;const l=sr(ir(e)),d=(t=l.apiKey)!==null&&t!==void 0?t:null,f=(r=l.oobCode)!==null&&r!==void 0?r:null,m=Ng((s=l.mode)!==null&&s!==void 0?s:null);x(d&&f&&m,"argument-error"),this.apiKey=d,this.operation=m,this.code=f,this.continueUrl=(i=l.continueUrl)!==null&&i!==void 0?i:null,this.languageCode=(a=l.languageCode)!==null&&a!==void 0?a:null,this.tenantId=(c=l.tenantId)!==null&&c!==void 0?c:null}static parseLink(e){const t=Dg(e);try{return new Oo(t)}catch{return null}}}/**
993
+ * @license
994
+ * Copyright 2020 Google LLC
995
+ *
996
+ * Licensed under the Apache License, Version 2.0 (the "License");
997
+ * you may not use this file except in compliance with the License.
998
+ * You may obtain a copy of the License at
999
+ *
1000
+ * http://www.apache.org/licenses/LICENSE-2.0
1001
+ *
1002
+ * Unless required by applicable law or agreed to in writing, software
1003
+ * distributed under the License is distributed on an "AS IS" BASIS,
1004
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1005
+ * See the License for the specific language governing permissions and
1006
+ * limitations under the License.
1007
+ */class On{constructor(){this.providerId=On.PROVIDER_ID}static credential(e,t){return _r._fromEmailAndPassword(e,t)}static credentialWithLink(e,t){const r=Oo.parseLink(t);return x(r,"argument-error"),_r._fromEmailAndCode(e,r.code,r.tenantId)}}On.PROVIDER_ID="password";On.EMAIL_PASSWORD_SIGN_IN_METHOD="password";On.EMAIL_LINK_SIGN_IN_METHOD="emailLink";/**
1008
+ * @license
1009
+ * Copyright 2020 Google LLC
1010
+ *
1011
+ * Licensed under the Apache License, Version 2.0 (the "License");
1012
+ * you may not use this file except in compliance with the License.
1013
+ * You may obtain a copy of the License at
1014
+ *
1015
+ * http://www.apache.org/licenses/LICENSE-2.0
1016
+ *
1017
+ * Unless required by applicable law or agreed to in writing, software
1018
+ * distributed under the License is distributed on an "AS IS" BASIS,
1019
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1020
+ * See the License for the specific language governing permissions and
1021
+ * limitations under the License.
1022
+ */class Vo{constructor(e){this.providerId=e,this.defaultLanguageCode=null,this.customParameters={}}setDefaultLanguage(e){this.defaultLanguageCode=e}setCustomParameters(e){return this.customParameters=e,this}getCustomParameters(){return this.customParameters}}/**
1023
+ * @license
1024
+ * Copyright 2019 Google LLC
1025
+ *
1026
+ * Licensed under the Apache License, Version 2.0 (the "License");
1027
+ * you may not use this file except in compliance with the License.
1028
+ * You may obtain a copy of the License at
1029
+ *
1030
+ * http://www.apache.org/licenses/LICENSE-2.0
1031
+ *
1032
+ * Unless required by applicable law or agreed to in writing, software
1033
+ * distributed under the License is distributed on an "AS IS" BASIS,
1034
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1035
+ * See the License for the specific language governing permissions and
1036
+ * limitations under the License.
1037
+ */class kr extends Vo{constructor(){super(...arguments),this.scopes=[]}addScope(e){return this.scopes.includes(e)||this.scopes.push(e),this}getScopes(){return[...this.scopes]}}/**
1038
+ * @license
1039
+ * Copyright 2020 Google LLC
1040
+ *
1041
+ * Licensed under the Apache License, Version 2.0 (the "License");
1042
+ * you may not use this file except in compliance with the License.
1043
+ * You may obtain a copy of the License at
1044
+ *
1045
+ * http://www.apache.org/licenses/LICENSE-2.0
1046
+ *
1047
+ * Unless required by applicable law or agreed to in writing, software
1048
+ * distributed under the License is distributed on an "AS IS" BASIS,
1049
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1050
+ * See the License for the specific language governing permissions and
1051
+ * limitations under the License.
1052
+ */class Tt extends kr{constructor(){super("facebook.com")}static credential(e){return Xt._fromParams({providerId:Tt.PROVIDER_ID,signInMethod:Tt.FACEBOOK_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return Tt.credentialFromTaggedObject(e)}static credentialFromError(e){return Tt.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return Tt.credential(e.oauthAccessToken)}catch{return null}}}Tt.FACEBOOK_SIGN_IN_METHOD="facebook.com";Tt.PROVIDER_ID="facebook.com";/**
1053
+ * @license
1054
+ * Copyright 2020 Google LLC
1055
+ *
1056
+ * Licensed under the Apache License, Version 2.0 (the "License");
1057
+ * you may not use this file except in compliance with the License.
1058
+ * You may obtain a copy of the License at
1059
+ *
1060
+ * http://www.apache.org/licenses/LICENSE-2.0
1061
+ *
1062
+ * Unless required by applicable law or agreed to in writing, software
1063
+ * distributed under the License is distributed on an "AS IS" BASIS,
1064
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1065
+ * See the License for the specific language governing permissions and
1066
+ * limitations under the License.
1067
+ */class rt extends kr{constructor(){super("google.com"),this.addScope("profile")}static credential(e,t){return Xt._fromParams({providerId:rt.PROVIDER_ID,signInMethod:rt.GOOGLE_SIGN_IN_METHOD,idToken:e,accessToken:t})}static credentialFromResult(e){return rt.credentialFromTaggedObject(e)}static credentialFromError(e){return rt.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthIdToken:t,oauthAccessToken:r}=e;if(!t&&!r)return null;try{return rt.credential(t,r)}catch{return null}}}rt.GOOGLE_SIGN_IN_METHOD="google.com";rt.PROVIDER_ID="google.com";/**
1068
+ * @license
1069
+ * Copyright 2020 Google LLC
1070
+ *
1071
+ * Licensed under the Apache License, Version 2.0 (the "License");
1072
+ * you may not use this file except in compliance with the License.
1073
+ * You may obtain a copy of the License at
1074
+ *
1075
+ * http://www.apache.org/licenses/LICENSE-2.0
1076
+ *
1077
+ * Unless required by applicable law or agreed to in writing, software
1078
+ * distributed under the License is distributed on an "AS IS" BASIS,
1079
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1080
+ * See the License for the specific language governing permissions and
1081
+ * limitations under the License.
1082
+ */class Et extends kr{constructor(){super("github.com")}static credential(e){return Xt._fromParams({providerId:Et.PROVIDER_ID,signInMethod:Et.GITHUB_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return Et.credentialFromTaggedObject(e)}static credentialFromError(e){return Et.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return Et.credential(e.oauthAccessToken)}catch{return null}}}Et.GITHUB_SIGN_IN_METHOD="github.com";Et.PROVIDER_ID="github.com";/**
1083
+ * @license
1084
+ * Copyright 2020 Google LLC
1085
+ *
1086
+ * Licensed under the Apache License, Version 2.0 (the "License");
1087
+ * you may not use this file except in compliance with the License.
1088
+ * You may obtain a copy of the License at
1089
+ *
1090
+ * http://www.apache.org/licenses/LICENSE-2.0
1091
+ *
1092
+ * Unless required by applicable law or agreed to in writing, software
1093
+ * distributed under the License is distributed on an "AS IS" BASIS,
1094
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1095
+ * See the License for the specific language governing permissions and
1096
+ * limitations under the License.
1097
+ */class vt extends kr{constructor(){super("twitter.com")}static credential(e,t){return Xt._fromParams({providerId:vt.PROVIDER_ID,signInMethod:vt.TWITTER_SIGN_IN_METHOD,oauthToken:e,oauthTokenSecret:t})}static credentialFromResult(e){return vt.credentialFromTaggedObject(e)}static credentialFromError(e){return vt.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthAccessToken:t,oauthTokenSecret:r}=e;if(!t||!r)return null;try{return vt.credential(t,r)}catch{return null}}}vt.TWITTER_SIGN_IN_METHOD="twitter.com";vt.PROVIDER_ID="twitter.com";/**
1098
+ * @license
1099
+ * Copyright 2020 Google LLC
1100
+ *
1101
+ * Licensed under the Apache License, Version 2.0 (the "License");
1102
+ * you may not use this file except in compliance with the License.
1103
+ * You may obtain a copy of the License at
1104
+ *
1105
+ * http://www.apache.org/licenses/LICENSE-2.0
1106
+ *
1107
+ * Unless required by applicable law or agreed to in writing, software
1108
+ * distributed under the License is distributed on an "AS IS" BASIS,
1109
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1110
+ * See the License for the specific language governing permissions and
1111
+ * limitations under the License.
1112
+ */class Jt{constructor(e){this.user=e.user,this.providerId=e.providerId,this._tokenResponse=e._tokenResponse,this.operationType=e.operationType}static async _fromIdTokenResponse(e,t,r,s=!1){const i=await Fe._fromIdTokenResponse(e,r,s),a=Xc(r);return new Jt({user:i,providerId:a,_tokenResponse:r,operationType:t})}static async _forOperation(e,t,r){await e._updateTokensIfNecessary(r,!0);const s=Xc(r);return new Jt({user:e,providerId:s,_tokenResponse:r,operationType:t})}}function Xc(n){return n.providerId?n.providerId:"phoneNumber"in n?"phone":null}/**
1113
+ * @license
1114
+ * Copyright 2020 Google LLC
1115
+ *
1116
+ * Licensed under the Apache License, Version 2.0 (the "License");
1117
+ * you may not use this file except in compliance with the License.
1118
+ * You may obtain a copy of the License at
1119
+ *
1120
+ * http://www.apache.org/licenses/LICENSE-2.0
1121
+ *
1122
+ * Unless required by applicable law or agreed to in writing, software
1123
+ * distributed under the License is distributed on an "AS IS" BASIS,
1124
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1125
+ * See the License for the specific language governing permissions and
1126
+ * limitations under the License.
1127
+ */class Ss extends He{constructor(e,t,r,s){var i;super(t.code,t.message),this.operationType=r,this.user=s,Object.setPrototypeOf(this,Ss.prototype),this.customData={appName:e.name,tenantId:(i=e.tenantId)!==null&&i!==void 0?i:void 0,_serverResponse:t.customData._serverResponse,operationType:r}}static _fromErrorAndOperation(e,t,r,s){return new Ss(e,t,r,s)}}function $l(n,e,t,r){return(e==="reauthenticate"?t._getReauthenticationResolver(n):t._getIdTokenResponse(n)).catch(i=>{throw i.code==="auth/multi-factor-auth-required"?Ss._fromErrorAndOperation(n,i,e,r):i})}async function Og(n,e,t=!1){const r=await gr(n,e._linkToIdToken(n.auth,await n.getIdToken()),t);return Jt._forOperation(n,"link",r)}/**
1128
+ * @license
1129
+ * Copyright 2019 Google LLC
1130
+ *
1131
+ * Licensed under the Apache License, Version 2.0 (the "License");
1132
+ * you may not use this file except in compliance with the License.
1133
+ * You may obtain a copy of the License at
1134
+ *
1135
+ * http://www.apache.org/licenses/LICENSE-2.0
1136
+ *
1137
+ * Unless required by applicable law or agreed to in writing, software
1138
+ * distributed under the License is distributed on an "AS IS" BASIS,
1139
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1140
+ * See the License for the specific language governing permissions and
1141
+ * limitations under the License.
1142
+ */async function Vg(n,e,t=!1){const{auth:r}=n;if(Pe(r.app))return Promise.reject(ot(r));const s="reauthenticate";try{const i=await gr(n,$l(r,s,e,n),t);x(i.idToken,r,"internal-error");const a=ko(i.idToken);x(a,r,"internal-error");const{sub:c}=a;return x(n.uid===c,r,"user-mismatch"),Jt._forOperation(n,s,i)}catch(i){throw(i==null?void 0:i.code)==="auth/user-not-found"&&Me(r,"user-mismatch"),i}}/**
1143
+ * @license
1144
+ * Copyright 2020 Google LLC
1145
+ *
1146
+ * Licensed under the Apache License, Version 2.0 (the "License");
1147
+ * you may not use this file except in compliance with the License.
1148
+ * You may obtain a copy of the License at
1149
+ *
1150
+ * http://www.apache.org/licenses/LICENSE-2.0
1151
+ *
1152
+ * Unless required by applicable law or agreed to in writing, software
1153
+ * distributed under the License is distributed on an "AS IS" BASIS,
1154
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1155
+ * See the License for the specific language governing permissions and
1156
+ * limitations under the License.
1157
+ */async function jl(n,e,t=!1){if(Pe(n.app))return Promise.reject(ot(n));const r="signIn",s=await $l(n,r,e),i=await Jt._fromIdTokenResponse(n,r,s);return t||await n._updateCurrentUser(i.user),i}async function Lg(n,e){return jl(xt(n),e)}/**
1158
+ * @license
1159
+ * Copyright 2020 Google LLC
1160
+ *
1161
+ * Licensed under the Apache License, Version 2.0 (the "License");
1162
+ * you may not use this file except in compliance with the License.
1163
+ * You may obtain a copy of the License at
1164
+ *
1165
+ * http://www.apache.org/licenses/LICENSE-2.0
1166
+ *
1167
+ * Unless required by applicable law or agreed to in writing, software
1168
+ * distributed under the License is distributed on an "AS IS" BASIS,
1169
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1170
+ * See the License for the specific language governing permissions and
1171
+ * limitations under the License.
1172
+ */async function Mg(n,e){return Cr(n,"POST","/v1/accounts:signInWithCustomToken",Lt(n,e))}/**
1173
+ * @license
1174
+ * Copyright 2020 Google LLC
1175
+ *
1176
+ * Licensed under the Apache License, Version 2.0 (the "License");
1177
+ * you may not use this file except in compliance with the License.
1178
+ * You may obtain a copy of the License at
1179
+ *
1180
+ * http://www.apache.org/licenses/LICENSE-2.0
1181
+ *
1182
+ * Unless required by applicable law or agreed to in writing, software
1183
+ * distributed under the License is distributed on an "AS IS" BASIS,
1184
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1185
+ * See the License for the specific language governing permissions and
1186
+ * limitations under the License.
1187
+ */async function xg(n,e){if(Pe(n.app))return Promise.reject(ot(n));const t=xt(n),r=await Mg(t,{token:e,returnSecureToken:!0}),s=await Jt._fromIdTokenResponse(t,"signIn",r);return await t._updateCurrentUser(s.user),s}/**
1188
+ * @license
1189
+ * Copyright 2020 Google LLC
1190
+ *
1191
+ * Licensed under the Apache License, Version 2.0 (the "License");
1192
+ * you may not use this file except in compliance with the License.
1193
+ * You may obtain a copy of the License at
1194
+ *
1195
+ * http://www.apache.org/licenses/LICENSE-2.0
1196
+ *
1197
+ * Unless required by applicable law or agreed to in writing, software
1198
+ * distributed under the License is distributed on an "AS IS" BASIS,
1199
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1200
+ * See the License for the specific language governing permissions and
1201
+ * limitations under the License.
1202
+ */async function Ug(n){const e=xt(n);e._getPasswordPolicyInternal()&&await e._updatePasswordPolicy()}function Fg(n,e,t){return Pe(n.app)?Promise.reject(ot(n)):Lg(Z(n),On.credential(e,t)).catch(async r=>{throw r.code==="auth/password-does-not-meet-requirements"&&Ug(n),r})}function Bg(n,e,t,r){return Z(n).onIdTokenChanged(e,t,r)}function qg(n,e,t){return Z(n).beforeAuthStateChanged(e,t)}function Hl(n,e,t,r){return Z(n).onAuthStateChanged(e,t,r)}function $g(n){return Z(n).signOut()}const Cs="__sak";/**
1203
+ * @license
1204
+ * Copyright 2019 Google LLC
1205
+ *
1206
+ * Licensed under the Apache License, Version 2.0 (the "License");
1207
+ * you may not use this file except in compliance with the License.
1208
+ * You may obtain a copy of the License at
1209
+ *
1210
+ * http://www.apache.org/licenses/LICENSE-2.0
1211
+ *
1212
+ * Unless required by applicable law or agreed to in writing, software
1213
+ * distributed under the License is distributed on an "AS IS" BASIS,
1214
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1215
+ * See the License for the specific language governing permissions and
1216
+ * limitations under the License.
1217
+ */class zl{constructor(e,t){this.storageRetriever=e,this.type=t}_isAvailable(){try{return this.storage?(this.storage.setItem(Cs,"1"),this.storage.removeItem(Cs),Promise.resolve(!0)):Promise.resolve(!1)}catch{return Promise.resolve(!1)}}_set(e,t){return this.storage.setItem(e,JSON.stringify(t)),Promise.resolve()}_get(e){const t=this.storage.getItem(e);return Promise.resolve(t?JSON.parse(t):null)}_remove(e){return this.storage.removeItem(e),Promise.resolve()}get storage(){return this.storageRetriever()}}/**
1218
+ * @license
1219
+ * Copyright 2020 Google LLC
1220
+ *
1221
+ * Licensed under the Apache License, Version 2.0 (the "License");
1222
+ * you may not use this file except in compliance with the License.
1223
+ * You may obtain a copy of the License at
1224
+ *
1225
+ * http://www.apache.org/licenses/LICENSE-2.0
1226
+ *
1227
+ * Unless required by applicable law or agreed to in writing, software
1228
+ * distributed under the License is distributed on an "AS IS" BASIS,
1229
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1230
+ * See the License for the specific language governing permissions and
1231
+ * limitations under the License.
1232
+ */const jg=1e3,Hg=10;class Gl extends zl{constructor(){super(()=>window.localStorage,"LOCAL"),this.boundEventHandler=(e,t)=>this.onStorageEvent(e,t),this.listeners={},this.localCache={},this.pollTimer=null,this.fallbackToPolling=xl(),this._shouldAllowMigration=!0}forAllChangedKeys(e){for(const t of Object.keys(this.listeners)){const r=this.storage.getItem(t),s=this.localCache[t];r!==s&&e(t,s,r)}}onStorageEvent(e,t=!1){if(!e.key){this.forAllChangedKeys((a,c,l)=>{this.notifyListeners(a,l)});return}const r=e.key;t?this.detachListener():this.stopPolling();const s=()=>{const a=this.storage.getItem(r);!t&&this.localCache[r]===a||this.notifyListeners(r,a)},i=this.storage.getItem(r);ag()&&i!==e.newValue&&e.newValue!==e.oldValue?setTimeout(s,Hg):s()}notifyListeners(e,t){this.localCache[e]=t;const r=this.listeners[e];if(r)for(const s of Array.from(r))s(t&&JSON.parse(t))}startPolling(){this.stopPolling(),this.pollTimer=setInterval(()=>{this.forAllChangedKeys((e,t,r)=>{this.onStorageEvent(new StorageEvent("storage",{key:e,oldValue:t,newValue:r}),!0)})},jg)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}attachListener(){window.addEventListener("storage",this.boundEventHandler)}detachListener(){window.removeEventListener("storage",this.boundEventHandler)}_addListener(e,t){Object.keys(this.listeners).length===0&&(this.fallbackToPolling?this.startPolling():this.attachListener()),this.listeners[e]||(this.listeners[e]=new Set,this.localCache[e]=this.storage.getItem(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),this.listeners[e].size===0&&delete this.listeners[e]),Object.keys(this.listeners).length===0&&(this.detachListener(),this.stopPolling())}async _set(e,t){await super._set(e,t),this.localCache[e]=JSON.stringify(t)}async _get(e){const t=await super._get(e);return this.localCache[e]=JSON.stringify(t),t}async _remove(e){await super._remove(e),delete this.localCache[e]}}Gl.type="LOCAL";const zg=Gl;/**
1233
+ * @license
1234
+ * Copyright 2020 Google LLC
1235
+ *
1236
+ * Licensed under the Apache License, Version 2.0 (the "License");
1237
+ * you may not use this file except in compliance with the License.
1238
+ * You may obtain a copy of the License at
1239
+ *
1240
+ * http://www.apache.org/licenses/LICENSE-2.0
1241
+ *
1242
+ * Unless required by applicable law or agreed to in writing, software
1243
+ * distributed under the License is distributed on an "AS IS" BASIS,
1244
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1245
+ * See the License for the specific language governing permissions and
1246
+ * limitations under the License.
1247
+ */class Wl extends zl{constructor(){super(()=>window.sessionStorage,"SESSION")}_addListener(e,t){}_removeListener(e,t){}}Wl.type="SESSION";const Kl=Wl;/**
1248
+ * @license
1249
+ * Copyright 2019 Google LLC
1250
+ *
1251
+ * Licensed under the Apache License, Version 2.0 (the "License");
1252
+ * you may not use this file except in compliance with the License.
1253
+ * You may obtain a copy of the License at
1254
+ *
1255
+ * http://www.apache.org/licenses/LICENSE-2.0
1256
+ *
1257
+ * Unless required by applicable law or agreed to in writing, software
1258
+ * distributed under the License is distributed on an "AS IS" BASIS,
1259
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1260
+ * See the License for the specific language governing permissions and
1261
+ * limitations under the License.
1262
+ */function Gg(n){return Promise.all(n.map(async e=>{try{return{fulfilled:!0,value:await e}}catch(t){return{fulfilled:!1,reason:t}}}))}/**
1263
+ * @license
1264
+ * Copyright 2019 Google LLC
1265
+ *
1266
+ * Licensed under the Apache License, Version 2.0 (the "License");
1267
+ * you may not use this file except in compliance with the License.
1268
+ * You may obtain a copy of the License at
1269
+ *
1270
+ * http://www.apache.org/licenses/LICENSE-2.0
1271
+ *
1272
+ * Unless required by applicable law or agreed to in writing, software
1273
+ * distributed under the License is distributed on an "AS IS" BASIS,
1274
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1275
+ * See the License for the specific language governing permissions and
1276
+ * limitations under the License.
1277
+ */class Ks{constructor(e){this.eventTarget=e,this.handlersMap={},this.boundEventHandler=this.handleEvent.bind(this)}static _getInstance(e){const t=this.receivers.find(s=>s.isListeningto(e));if(t)return t;const r=new Ks(e);return this.receivers.push(r),r}isListeningto(e){return this.eventTarget===e}async handleEvent(e){const t=e,{eventId:r,eventType:s,data:i}=t.data,a=this.handlersMap[s];if(!(a!=null&&a.size))return;t.ports[0].postMessage({status:"ack",eventId:r,eventType:s});const c=Array.from(a).map(async d=>d(t.origin,i)),l=await Gg(c);t.ports[0].postMessage({status:"done",eventId:r,eventType:s,response:l})}_subscribe(e,t){Object.keys(this.handlersMap).length===0&&this.eventTarget.addEventListener("message",this.boundEventHandler),this.handlersMap[e]||(this.handlersMap[e]=new Set),this.handlersMap[e].add(t)}_unsubscribe(e,t){this.handlersMap[e]&&t&&this.handlersMap[e].delete(t),(!t||this.handlersMap[e].size===0)&&delete this.handlersMap[e],Object.keys(this.handlersMap).length===0&&this.eventTarget.removeEventListener("message",this.boundEventHandler)}}Ks.receivers=[];/**
1278
+ * @license
1279
+ * Copyright 2020 Google LLC
1280
+ *
1281
+ * Licensed under the Apache License, Version 2.0 (the "License");
1282
+ * you may not use this file except in compliance with the License.
1283
+ * You may obtain a copy of the License at
1284
+ *
1285
+ * http://www.apache.org/licenses/LICENSE-2.0
1286
+ *
1287
+ * Unless required by applicable law or agreed to in writing, software
1288
+ * distributed under the License is distributed on an "AS IS" BASIS,
1289
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1290
+ * See the License for the specific language governing permissions and
1291
+ * limitations under the License.
1292
+ */function Lo(n="",e=10){let t="";for(let r=0;r<e;r++)t+=Math.floor(Math.random()*10);return n+t}/**
1293
+ * @license
1294
+ * Copyright 2019 Google LLC
1295
+ *
1296
+ * Licensed under the Apache License, Version 2.0 (the "License");
1297
+ * you may not use this file except in compliance with the License.
1298
+ * You may obtain a copy of the License at
1299
+ *
1300
+ * http://www.apache.org/licenses/LICENSE-2.0
1301
+ *
1302
+ * Unless required by applicable law or agreed to in writing, software
1303
+ * distributed under the License is distributed on an "AS IS" BASIS,
1304
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1305
+ * See the License for the specific language governing permissions and
1306
+ * limitations under the License.
1307
+ */class Wg{constructor(e){this.target=e,this.handlers=new Set}removeMessageHandler(e){e.messageChannel&&(e.messageChannel.port1.removeEventListener("message",e.onMessage),e.messageChannel.port1.close()),this.handlers.delete(e)}async _send(e,t,r=50){const s=typeof MessageChannel<"u"?new MessageChannel:null;if(!s)throw new Error("connection_unavailable");let i,a;return new Promise((c,l)=>{const d=Lo("",20);s.port1.start();const f=setTimeout(()=>{l(new Error("unsupported_event"))},r);a={messageChannel:s,onMessage(m){const E=m;if(E.data.eventId===d)switch(E.data.status){case"ack":clearTimeout(f),i=setTimeout(()=>{l(new Error("timeout"))},3e3);break;case"done":clearTimeout(i),c(E.data.response);break;default:clearTimeout(f),clearTimeout(i),l(new Error("invalid_response"));break}}},this.handlers.add(a),s.port1.addEventListener("message",a.onMessage),this.target.postMessage({eventType:e,eventId:d,data:t},[s.port2])}).finally(()=>{a&&this.removeMessageHandler(a)})}}/**
1308
+ * @license
1309
+ * Copyright 2020 Google LLC
1310
+ *
1311
+ * Licensed under the Apache License, Version 2.0 (the "License");
1312
+ * you may not use this file except in compliance with the License.
1313
+ * You may obtain a copy of the License at
1314
+ *
1315
+ * http://www.apache.org/licenses/LICENSE-2.0
1316
+ *
1317
+ * Unless required by applicable law or agreed to in writing, software
1318
+ * distributed under the License is distributed on an "AS IS" BASIS,
1319
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1320
+ * See the License for the specific language governing permissions and
1321
+ * limitations under the License.
1322
+ */function Ke(){return window}function Kg(n){Ke().location.href=n}/**
1323
+ * @license
1324
+ * Copyright 2020 Google LLC.
1325
+ *
1326
+ * Licensed under the Apache License, Version 2.0 (the "License");
1327
+ * you may not use this file except in compliance with the License.
1328
+ * You may obtain a copy of the License at
1329
+ *
1330
+ * http://www.apache.org/licenses/LICENSE-2.0
1331
+ *
1332
+ * Unless required by applicable law or agreed to in writing, software
1333
+ * distributed under the License is distributed on an "AS IS" BASIS,
1334
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1335
+ * See the License for the specific language governing permissions and
1336
+ * limitations under the License.
1337
+ */function Ql(){return typeof Ke().WorkerGlobalScope<"u"&&typeof Ke().importScripts=="function"}async function Qg(){if(!(navigator!=null&&navigator.serviceWorker))return null;try{return(await navigator.serviceWorker.ready).active}catch{return null}}function Xg(){var n;return((n=navigator==null?void 0:navigator.serviceWorker)===null||n===void 0?void 0:n.controller)||null}function Jg(){return Ql()?self:null}/**
1338
+ * @license
1339
+ * Copyright 2019 Google LLC
1340
+ *
1341
+ * Licensed under the Apache License, Version 2.0 (the "License");
1342
+ * you may not use this file except in compliance with the License.
1343
+ * You may obtain a copy of the License at
1344
+ *
1345
+ * http://www.apache.org/licenses/LICENSE-2.0
1346
+ *
1347
+ * Unless required by applicable law or agreed to in writing, software
1348
+ * distributed under the License is distributed on an "AS IS" BASIS,
1349
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1350
+ * See the License for the specific language governing permissions and
1351
+ * limitations under the License.
1352
+ */const Xl="firebaseLocalStorageDb",Yg=1,ks="firebaseLocalStorage",Jl="fbase_key";class Nr{constructor(e){this.request=e}toPromise(){return new Promise((e,t)=>{this.request.addEventListener("success",()=>{e(this.request.result)}),this.request.addEventListener("error",()=>{t(this.request.error)})})}}function Qs(n,e){return n.transaction([ks],e?"readwrite":"readonly").objectStore(ks)}function Zg(){const n=indexedDB.deleteDatabase(Xl);return new Nr(n).toPromise()}function so(){const n=indexedDB.open(Xl,Yg);return new Promise((e,t)=>{n.addEventListener("error",()=>{t(n.error)}),n.addEventListener("upgradeneeded",()=>{const r=n.result;try{r.createObjectStore(ks,{keyPath:Jl})}catch(s){t(s)}}),n.addEventListener("success",async()=>{const r=n.result;r.objectStoreNames.contains(ks)?e(r):(r.close(),await Zg(),e(await so()))})})}async function Jc(n,e,t){const r=Qs(n,!0).put({[Jl]:e,value:t});return new Nr(r).toPromise()}async function e_(n,e){const t=Qs(n,!1).get(e),r=await new Nr(t).toPromise();return r===void 0?null:r.value}function Yc(n,e){const t=Qs(n,!0).delete(e);return new Nr(t).toPromise()}const t_=800,n_=3;class Yl{constructor(){this.type="LOCAL",this._shouldAllowMigration=!0,this.listeners={},this.localCache={},this.pollTimer=null,this.pendingWrites=0,this.receiver=null,this.sender=null,this.serviceWorkerReceiverAvailable=!1,this.activeServiceWorker=null,this._workerInitializationPromise=this.initializeServiceWorkerMessaging().then(()=>{},()=>{})}async _openDb(){return this.db?this.db:(this.db=await so(),this.db)}async _withRetries(e){let t=0;for(;;)try{const r=await this._openDb();return await e(r)}catch(r){if(t++>n_)throw r;this.db&&(this.db.close(),this.db=void 0)}}async initializeServiceWorkerMessaging(){return Ql()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=Ks._getInstance(Jg()),this.receiver._subscribe("keyChanged",async(e,t)=>({keyProcessed:(await this._poll()).includes(t.key)})),this.receiver._subscribe("ping",async(e,t)=>["keyChanged"])}async initializeSender(){var e,t;if(this.activeServiceWorker=await Qg(),!this.activeServiceWorker)return;this.sender=new Wg(this.activeServiceWorker);const r=await this.sender._send("ping",{},800);r&&!((e=r[0])===null||e===void 0)&&e.fulfilled&&!((t=r[0])===null||t===void 0)&&t.value.includes("keyChanged")&&(this.serviceWorkerReceiverAvailable=!0)}async notifyServiceWorker(e){if(!(!this.sender||!this.activeServiceWorker||Xg()!==this.activeServiceWorker))try{await this.sender._send("keyChanged",{key:e},this.serviceWorkerReceiverAvailable?800:50)}catch{}}async _isAvailable(){try{if(!indexedDB)return!1;const e=await so();return await Jc(e,Cs,"1"),await Yc(e,Cs),!0}catch{}return!1}async _withPendingWrite(e){this.pendingWrites++;try{await e()}finally{this.pendingWrites--}}async _set(e,t){return this._withPendingWrite(async()=>(await this._withRetries(r=>Jc(r,e,t)),this.localCache[e]=t,this.notifyServiceWorker(e)))}async _get(e){const t=await this._withRetries(r=>e_(r,e));return this.localCache[e]=t,t}async _remove(e){return this._withPendingWrite(async()=>(await this._withRetries(t=>Yc(t,e)),delete this.localCache[e],this.notifyServiceWorker(e)))}async _poll(){const e=await this._withRetries(s=>{const i=Qs(s,!1).getAll();return new Nr(i).toPromise()});if(!e)return[];if(this.pendingWrites!==0)return[];const t=[],r=new Set;if(e.length!==0)for(const{fbase_key:s,value:i}of e)r.add(s),JSON.stringify(this.localCache[s])!==JSON.stringify(i)&&(this.notifyListeners(s,i),t.push(s));for(const s of Object.keys(this.localCache))this.localCache[s]&&!r.has(s)&&(this.notifyListeners(s,null),t.push(s));return t}notifyListeners(e,t){this.localCache[e]=t;const r=this.listeners[e];if(r)for(const s of Array.from(r))s(t)}startPolling(){this.stopPolling(),this.pollTimer=setInterval(async()=>this._poll(),t_)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}_addListener(e,t){Object.keys(this.listeners).length===0&&this.startPolling(),this.listeners[e]||(this.listeners[e]=new Set,this._get(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),this.listeners[e].size===0&&delete this.listeners[e]),Object.keys(this.listeners).length===0&&this.stopPolling()}}Yl.type="LOCAL";const r_=Yl;new Sr(3e4,6e4);/**
1353
+ * @license
1354
+ * Copyright 2021 Google LLC
1355
+ *
1356
+ * Licensed under the Apache License, Version 2.0 (the "License");
1357
+ * you may not use this file except in compliance with the License.
1358
+ * You may obtain a copy of the License at
1359
+ *
1360
+ * http://www.apache.org/licenses/LICENSE-2.0
1361
+ *
1362
+ * Unless required by applicable law or agreed to in writing, software
1363
+ * distributed under the License is distributed on an "AS IS" BASIS,
1364
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1365
+ * See the License for the specific language governing permissions and
1366
+ * limitations under the License.
1367
+ */function Zl(n,e){return e?it(e):(x(n._popupRedirectResolver,n,"argument-error"),n._popupRedirectResolver)}/**
1368
+ * @license
1369
+ * Copyright 2019 Google LLC
1370
+ *
1371
+ * Licensed under the Apache License, Version 2.0 (the "License");
1372
+ * you may not use this file except in compliance with the License.
1373
+ * You may obtain a copy of the License at
1374
+ *
1375
+ * http://www.apache.org/licenses/LICENSE-2.0
1376
+ *
1377
+ * Unless required by applicable law or agreed to in writing, software
1378
+ * distributed under the License is distributed on an "AS IS" BASIS,
1379
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1380
+ * See the License for the specific language governing permissions and
1381
+ * limitations under the License.
1382
+ */class Mo extends Do{constructor(e){super("custom","custom"),this.params=e}_getIdTokenResponse(e){return En(e,this._buildIdpRequest())}_linkToIdToken(e,t){return En(e,this._buildIdpRequest(t))}_getReauthenticationResolver(e){return En(e,this._buildIdpRequest())}_buildIdpRequest(e){const t={requestUri:this.params.requestUri,sessionId:this.params.sessionId,postBody:this.params.postBody,tenantId:this.params.tenantId,pendingToken:this.params.pendingToken,returnSecureToken:!0,returnIdpCredential:!0};return e&&(t.idToken=e),t}}function s_(n){return jl(n.auth,new Mo(n),n.bypassAuthState)}function i_(n){const{auth:e,user:t}=n;return x(t,e,"internal-error"),Vg(t,new Mo(n),n.bypassAuthState)}async function o_(n){const{auth:e,user:t}=n;return x(t,e,"internal-error"),Og(t,new Mo(n),n.bypassAuthState)}/**
1383
+ * @license
1384
+ * Copyright 2020 Google LLC
1385
+ *
1386
+ * Licensed under the Apache License, Version 2.0 (the "License");
1387
+ * you may not use this file except in compliance with the License.
1388
+ * You may obtain a copy of the License at
1389
+ *
1390
+ * http://www.apache.org/licenses/LICENSE-2.0
1391
+ *
1392
+ * Unless required by applicable law or agreed to in writing, software
1393
+ * distributed under the License is distributed on an "AS IS" BASIS,
1394
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1395
+ * See the License for the specific language governing permissions and
1396
+ * limitations under the License.
1397
+ */class eh{constructor(e,t,r,s,i=!1){this.auth=e,this.resolver=r,this.user=s,this.bypassAuthState=i,this.pendingPromise=null,this.eventManager=null,this.filter=Array.isArray(t)?t:[t]}execute(){return new Promise(async(e,t)=>{this.pendingPromise={resolve:e,reject:t};try{this.eventManager=await this.resolver._initialize(this.auth),await this.onExecution(),this.eventManager.registerConsumer(this)}catch(r){this.reject(r)}})}async onAuthEvent(e){const{urlResponse:t,sessionId:r,postBody:s,tenantId:i,error:a,type:c}=e;if(a){this.reject(a);return}const l={auth:this.auth,requestUri:t,sessionId:r,tenantId:i||void 0,postBody:s||void 0,user:this.user,bypassAuthState:this.bypassAuthState};try{this.resolve(await this.getIdpTask(c)(l))}catch(d){this.reject(d)}}onError(e){this.reject(e)}getIdpTask(e){switch(e){case"signInViaPopup":case"signInViaRedirect":return s_;case"linkViaPopup":case"linkViaRedirect":return o_;case"reauthViaPopup":case"reauthViaRedirect":return i_;default:Me(this.auth,"internal-error")}}resolve(e){ht(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){ht(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.reject(e),this.unregisterAndCleanUp()}unregisterAndCleanUp(){this.eventManager&&this.eventManager.unregisterConsumer(this),this.pendingPromise=null,this.cleanUp()}}/**
1398
+ * @license
1399
+ * Copyright 2020 Google LLC
1400
+ *
1401
+ * Licensed under the Apache License, Version 2.0 (the "License");
1402
+ * you may not use this file except in compliance with the License.
1403
+ * You may obtain a copy of the License at
1404
+ *
1405
+ * http://www.apache.org/licenses/LICENSE-2.0
1406
+ *
1407
+ * Unless required by applicable law or agreed to in writing, software
1408
+ * distributed under the License is distributed on an "AS IS" BASIS,
1409
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1410
+ * See the License for the specific language governing permissions and
1411
+ * limitations under the License.
1412
+ */const a_=new Sr(2e3,1e4);async function c_(n,e,t){if(Pe(n.app))return Promise.reject($e(n,"operation-not-supported-in-this-environment"));const r=xt(n);$m(n,e,Vo);const s=Zl(r,t);return new Gt(r,"signInViaPopup",e,s).executeNotNull()}class Gt extends eh{constructor(e,t,r,s,i){super(e,t,s,i),this.provider=r,this.authWindow=null,this.pollId=null,Gt.currentPopupAction&&Gt.currentPopupAction.cancel(),Gt.currentPopupAction=this}async executeNotNull(){const e=await this.execute();return x(e,this.auth,"internal-error"),e}async onExecution(){ht(this.filter.length===1,"Popup operations only handle one event");const e=Lo();this.authWindow=await this.resolver._openPopup(this.auth,this.provider,this.filter[0],e),this.authWindow.associatedEvent=e,this.resolver._originValidation(this.auth).catch(t=>{this.reject(t)}),this.resolver._isIframeWebStorageSupported(this.auth,t=>{t||this.reject($e(this.auth,"web-storage-unsupported"))}),this.pollUserCancellation()}get eventId(){var e;return((e=this.authWindow)===null||e===void 0?void 0:e.associatedEvent)||null}cancel(){this.reject($e(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,Gt.currentPopupAction=null}pollUserCancellation(){const e=()=>{var t,r;if(!((r=(t=this.authWindow)===null||t===void 0?void 0:t.window)===null||r===void 0)&&r.closed){this.pollId=window.setTimeout(()=>{this.pollId=null,this.reject($e(this.auth,"popup-closed-by-user"))},8e3);return}this.pollId=window.setTimeout(e,a_.get())};e()}}Gt.currentPopupAction=null;/**
1413
+ * @license
1414
+ * Copyright 2020 Google LLC
1415
+ *
1416
+ * Licensed under the Apache License, Version 2.0 (the "License");
1417
+ * you may not use this file except in compliance with the License.
1418
+ * You may obtain a copy of the License at
1419
+ *
1420
+ * http://www.apache.org/licenses/LICENSE-2.0
1421
+ *
1422
+ * Unless required by applicable law or agreed to in writing, software
1423
+ * distributed under the License is distributed on an "AS IS" BASIS,
1424
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1425
+ * See the License for the specific language governing permissions and
1426
+ * limitations under the License.
1427
+ */const u_="pendingRedirect",fs=new Map;class l_ extends eh{constructor(e,t,r=!1){super(e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],t,void 0,r),this.eventId=null}async execute(){let e=fs.get(this.auth._key());if(!e){try{const r=await h_(this.resolver,this.auth)?await super.execute():null;e=()=>Promise.resolve(r)}catch(t){e=()=>Promise.reject(t)}fs.set(this.auth._key(),e)}return this.bypassAuthState||fs.set(this.auth._key(),()=>Promise.resolve(null)),e()}async onAuthEvent(e){if(e.type==="signInViaRedirect")return super.onAuthEvent(e);if(e.type==="unknown"){this.resolve(null);return}if(e.eventId){const t=await this.auth._redirectUserForId(e.eventId);if(t)return this.user=t,super.onAuthEvent(e);this.resolve(null)}}async onExecution(){}cleanUp(){}}async function h_(n,e){const t=p_(e),r=f_(n);if(!await r._isAvailable())return!1;const s=await r._get(t)==="true";return await r._remove(t),s}function d_(n,e){fs.set(n._key(),e)}function f_(n){return it(n._redirectPersistence)}function p_(n){return ds(u_,n.config.apiKey,n.name)}async function m_(n,e,t=!1){if(Pe(n.app))return Promise.reject(ot(n));const r=xt(n),s=Zl(r,e),a=await new l_(r,s,t).execute();return a&&!t&&(delete a.user._redirectEventId,await r._persistUserIfCurrent(a.user),await r._setRedirectUser(null,e)),a}/**
1428
+ * @license
1429
+ * Copyright 2020 Google LLC
1430
+ *
1431
+ * Licensed under the Apache License, Version 2.0 (the "License");
1432
+ * you may not use this file except in compliance with the License.
1433
+ * You may obtain a copy of the License at
1434
+ *
1435
+ * http://www.apache.org/licenses/LICENSE-2.0
1436
+ *
1437
+ * Unless required by applicable law or agreed to in writing, software
1438
+ * distributed under the License is distributed on an "AS IS" BASIS,
1439
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1440
+ * See the License for the specific language governing permissions and
1441
+ * limitations under the License.
1442
+ */const g_=10*60*1e3;class __{constructor(e){this.auth=e,this.cachedEventUids=new Set,this.consumers=new Set,this.queuedRedirectEvent=null,this.hasHandledPotentialRedirect=!1,this.lastProcessedEventTime=Date.now()}registerConsumer(e){this.consumers.add(e),this.queuedRedirectEvent&&this.isEventForConsumer(this.queuedRedirectEvent,e)&&(this.sendToConsumer(this.queuedRedirectEvent,e),this.saveEventToCache(this.queuedRedirectEvent),this.queuedRedirectEvent=null)}unregisterConsumer(e){this.consumers.delete(e)}onEvent(e){if(this.hasEventBeenHandled(e))return!1;let t=!1;return this.consumers.forEach(r=>{this.isEventForConsumer(e,r)&&(t=!0,this.sendToConsumer(e,r),this.saveEventToCache(e))}),this.hasHandledPotentialRedirect||!y_(e)||(this.hasHandledPotentialRedirect=!0,t||(this.queuedRedirectEvent=e,t=!0)),t}sendToConsumer(e,t){var r;if(e.error&&!th(e)){const s=((r=e.error.code)===null||r===void 0?void 0:r.split("auth/")[1])||"internal-error";t.onError($e(this.auth,s))}else t.onAuthEvent(e)}isEventForConsumer(e,t){const r=t.eventId===null||!!e.eventId&&e.eventId===t.eventId;return t.filter.includes(e.type)&&r}hasEventBeenHandled(e){return Date.now()-this.lastProcessedEventTime>=g_&&this.cachedEventUids.clear(),this.cachedEventUids.has(Zc(e))}saveEventToCache(e){this.cachedEventUids.add(Zc(e)),this.lastProcessedEventTime=Date.now()}}function Zc(n){return[n.type,n.eventId,n.sessionId,n.tenantId].filter(e=>e).join("-")}function th({type:n,error:e}){return n==="unknown"&&(e==null?void 0:e.code)==="auth/no-auth-event"}function y_(n){switch(n.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return!0;case"unknown":return th(n);default:return!1}}/**
1443
+ * @license
1444
+ * Copyright 2020 Google LLC
1445
+ *
1446
+ * Licensed under the Apache License, Version 2.0 (the "License");
1447
+ * you may not use this file except in compliance with the License.
1448
+ * You may obtain a copy of the License at
1449
+ *
1450
+ * http://www.apache.org/licenses/LICENSE-2.0
1451
+ *
1452
+ * Unless required by applicable law or agreed to in writing, software
1453
+ * distributed under the License is distributed on an "AS IS" BASIS,
1454
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1455
+ * See the License for the specific language governing permissions and
1456
+ * limitations under the License.
1457
+ */async function T_(n,e={}){return Mt(n,"GET","/v1/projects",e)}/**
1458
+ * @license
1459
+ * Copyright 2020 Google LLC
1460
+ *
1461
+ * Licensed under the Apache License, Version 2.0 (the "License");
1462
+ * you may not use this file except in compliance with the License.
1463
+ * You may obtain a copy of the License at
1464
+ *
1465
+ * http://www.apache.org/licenses/LICENSE-2.0
1466
+ *
1467
+ * Unless required by applicable law or agreed to in writing, software
1468
+ * distributed under the License is distributed on an "AS IS" BASIS,
1469
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1470
+ * See the License for the specific language governing permissions and
1471
+ * limitations under the License.
1472
+ */const E_=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,v_=/^https?/;async function I_(n){if(n.config.emulator)return;const{authorizedDomains:e}=await T_(n);for(const t of e)try{if(w_(t))return}catch{}Me(n,"unauthorized-domain")}function w_(n){const e=no(),{protocol:t,hostname:r}=new URL(e);if(n.startsWith("chrome-extension://")){const a=new URL(n);return a.hostname===""&&r===""?t==="chrome-extension:"&&n.replace("chrome-extension://","")===e.replace("chrome-extension://",""):t==="chrome-extension:"&&a.hostname===r}if(!v_.test(t))return!1;if(E_.test(n))return r===n;const s=n.replace(/\./g,"\\.");return new RegExp("^(.+\\."+s+"|"+s+")$","i").test(r)}/**
1473
+ * @license
1474
+ * Copyright 2020 Google LLC.
1475
+ *
1476
+ * Licensed under the Apache License, Version 2.0 (the "License");
1477
+ * you may not use this file except in compliance with the License.
1478
+ * You may obtain a copy of the License at
1479
+ *
1480
+ * http://www.apache.org/licenses/LICENSE-2.0
1481
+ *
1482
+ * Unless required by applicable law or agreed to in writing, software
1483
+ * distributed under the License is distributed on an "AS IS" BASIS,
1484
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1485
+ * See the License for the specific language governing permissions and
1486
+ * limitations under the License.
1487
+ */const A_=new Sr(3e4,6e4);function eu(){const n=Ke().___jsl;if(n!=null&&n.H){for(const e of Object.keys(n.H))if(n.H[e].r=n.H[e].r||[],n.H[e].L=n.H[e].L||[],n.H[e].r=[...n.H[e].L],n.CP)for(let t=0;t<n.CP.length;t++)n.CP[t]=null}}function R_(n){return new Promise((e,t)=>{var r,s,i;function a(){eu(),gapi.load("gapi.iframes",{callback:()=>{e(gapi.iframes.getContext())},ontimeout:()=>{eu(),t($e(n,"network-request-failed"))},timeout:A_.get()})}if(!((s=(r=Ke().gapi)===null||r===void 0?void 0:r.iframes)===null||s===void 0)&&s.Iframe)e(gapi.iframes.getContext());else if(!((i=Ke().gapi)===null||i===void 0)&&i.load)a();else{const c=gg("iframefcb");return Ke()[c]=()=>{gapi.load?a():t($e(n,"network-request-failed"))},Fl(`${mg()}?onload=${c}`).catch(l=>t(l))}}).catch(e=>{throw ps=null,e})}let ps=null;function b_(n){return ps=ps||R_(n),ps}/**
1488
+ * @license
1489
+ * Copyright 2020 Google LLC.
1490
+ *
1491
+ * Licensed under the Apache License, Version 2.0 (the "License");
1492
+ * you may not use this file except in compliance with the License.
1493
+ * You may obtain a copy of the License at
1494
+ *
1495
+ * http://www.apache.org/licenses/LICENSE-2.0
1496
+ *
1497
+ * Unless required by applicable law or agreed to in writing, software
1498
+ * distributed under the License is distributed on an "AS IS" BASIS,
1499
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1500
+ * See the License for the specific language governing permissions and
1501
+ * limitations under the License.
1502
+ */const P_=new Sr(5e3,15e3),S_="__/auth/iframe",C_="emulator/auth/iframe",k_={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},N_=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);function D_(n){const e=n.config;x(e.authDomain,n,"auth-domain-config-required");const t=e.emulator?Co(e,C_):`https://${n.config.authDomain}/${S_}`,r={apiKey:e.apiKey,appName:n.name,v:nn},s=N_.get(n.config.apiHost);s&&(r.eid=s);const i=n._getFrameworks();return i.length&&(r.fw=i.join(",")),`${t}?${br(r).slice(1)}`}async function O_(n){const e=await b_(n),t=Ke().gapi;return x(t,n,"internal-error"),e.open({where:document.body,url:D_(n),messageHandlersFilter:t.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:k_,dontclear:!0},r=>new Promise(async(s,i)=>{await r.restyle({setHideOnLeave:!1});const a=$e(n,"network-request-failed"),c=Ke().setTimeout(()=>{i(a)},P_.get());function l(){Ke().clearTimeout(c),s(r)}r.ping(l).then(l,()=>{i(a)})}))}/**
1503
+ * @license
1504
+ * Copyright 2020 Google LLC.
1505
+ *
1506
+ * Licensed under the Apache License, Version 2.0 (the "License");
1507
+ * you may not use this file except in compliance with the License.
1508
+ * You may obtain a copy of the License at
1509
+ *
1510
+ * http://www.apache.org/licenses/LICENSE-2.0
1511
+ *
1512
+ * Unless required by applicable law or agreed to in writing, software
1513
+ * distributed under the License is distributed on an "AS IS" BASIS,
1514
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1515
+ * See the License for the specific language governing permissions and
1516
+ * limitations under the License.
1517
+ */const V_={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"},L_=500,M_=600,x_="_blank",U_="http://localhost";class tu{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch{}}}function F_(n,e,t,r=L_,s=M_){const i=Math.max((window.screen.availHeight-s)/2,0).toString(),a=Math.max((window.screen.availWidth-r)/2,0).toString();let c="";const l=Object.assign(Object.assign({},V_),{width:r.toString(),height:s.toString(),top:i,left:a}),d=we().toLowerCase();t&&(c=Dl(d)?x_:t),kl(d)&&(e=e||U_,l.scrollbars="yes");const f=Object.entries(l).reduce((E,[R,C])=>`${E}${R}=${C},`,"");if(og(d)&&c!=="_self")return B_(e||"",c),new tu(null);const m=window.open(e||"",c,f);x(m,n,"popup-blocked");try{m.focus()}catch{}return new tu(m)}function B_(n,e){const t=document.createElement("a");t.href=n,t.target=e;const r=document.createEvent("MouseEvent");r.initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,1,null),t.dispatchEvent(r)}/**
1518
+ * @license
1519
+ * Copyright 2021 Google LLC
1520
+ *
1521
+ * Licensed under the Apache License, Version 2.0 (the "License");
1522
+ * you may not use this file except in compliance with the License.
1523
+ * You may obtain a copy of the License at
1524
+ *
1525
+ * http://www.apache.org/licenses/LICENSE-2.0
1526
+ *
1527
+ * Unless required by applicable law or agreed to in writing, software
1528
+ * distributed under the License is distributed on an "AS IS" BASIS,
1529
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1530
+ * See the License for the specific language governing permissions and
1531
+ * limitations under the License.
1532
+ */const q_="__/auth/handler",$_="emulator/auth/handler",j_=encodeURIComponent("fac");async function nu(n,e,t,r,s,i){x(n.config.authDomain,n,"auth-domain-config-required"),x(n.config.apiKey,n,"invalid-api-key");const a={apiKey:n.config.apiKey,appName:n.name,authType:t,redirectUrl:r,v:nn,eventId:s};if(e instanceof Vo){e.setDefaultLanguage(n.languageCode),a.providerId=e.providerId||"",gp(e.getCustomParameters())||(a.customParameters=JSON.stringify(e.getCustomParameters()));for(const[f,m]of Object.entries({}))a[f]=m}if(e instanceof kr){const f=e.getScopes().filter(m=>m!=="");f.length>0&&(a.scopes=f.join(","))}n.tenantId&&(a.tid=n.tenantId);const c=a;for(const f of Object.keys(c))c[f]===void 0&&delete c[f];const l=await n._getAppCheckToken(),d=l?`#${j_}=${encodeURIComponent(l)}`:"";return`${H_(n)}?${br(c).slice(1)}${d}`}function H_({config:n}){return n.emulator?Co(n,$_):`https://${n.authDomain}/${q_}`}/**
1533
+ * @license
1534
+ * Copyright 2020 Google LLC
1535
+ *
1536
+ * Licensed under the Apache License, Version 2.0 (the "License");
1537
+ * you may not use this file except in compliance with the License.
1538
+ * You may obtain a copy of the License at
1539
+ *
1540
+ * http://www.apache.org/licenses/LICENSE-2.0
1541
+ *
1542
+ * Unless required by applicable law or agreed to in writing, software
1543
+ * distributed under the License is distributed on an "AS IS" BASIS,
1544
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1545
+ * See the License for the specific language governing permissions and
1546
+ * limitations under the License.
1547
+ */const Hi="webStorageSupport";class z_{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=Kl,this._completeRedirectFn=m_,this._overrideRedirectResult=d_}async _openPopup(e,t,r,s){var i;ht((i=this.eventManagers[e._key()])===null||i===void 0?void 0:i.manager,"_initialize() not called before _openPopup()");const a=await nu(e,t,r,no(),s);return F_(e,a,Lo())}async _openRedirect(e,t,r,s){await this._originValidation(e);const i=await nu(e,t,r,no(),s);return Kg(i),new Promise(()=>{})}_initialize(e){const t=e._key();if(this.eventManagers[t]){const{manager:s,promise:i}=this.eventManagers[t];return s?Promise.resolve(s):(ht(i,"If manager is not set, promise should be"),i)}const r=this.initAndGetManager(e);return this.eventManagers[t]={promise:r},r.catch(()=>{delete this.eventManagers[t]}),r}async initAndGetManager(e){const t=await O_(e),r=new __(e);return t.register("authEvent",s=>(x(s==null?void 0:s.authEvent,e,"invalid-auth-event"),{status:r.onEvent(s.authEvent)?"ACK":"ERROR"}),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[e._key()]={manager:r},this.iframes[e._key()]=t,r}_isIframeWebStorageSupported(e,t){this.iframes[e._key()].send(Hi,{type:Hi},s=>{var i;const a=(i=s==null?void 0:s[0])===null||i===void 0?void 0:i[Hi];a!==void 0&&t(!!a),Me(e,"internal-error")},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){const t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=I_(e)),this.originValidationPromises[t]}get _shouldInitProactively(){return xl()||Nl()||No()}}const G_=z_;var ru="@firebase/auth",su="1.10.0";/**
1548
+ * @license
1549
+ * Copyright 2020 Google LLC
1550
+ *
1551
+ * Licensed under the Apache License, Version 2.0 (the "License");
1552
+ * you may not use this file except in compliance with the License.
1553
+ * You may obtain a copy of the License at
1554
+ *
1555
+ * http://www.apache.org/licenses/LICENSE-2.0
1556
+ *
1557
+ * Unless required by applicable law or agreed to in writing, software
1558
+ * distributed under the License is distributed on an "AS IS" BASIS,
1559
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1560
+ * See the License for the specific language governing permissions and
1561
+ * limitations under the License.
1562
+ */class W_{constructor(e){this.auth=e,this.internalListeners=new Map}getUid(){var e;return this.assertAuthConfigured(),((e=this.auth.currentUser)===null||e===void 0?void 0:e.uid)||null}async getToken(e){return this.assertAuthConfigured(),await this.auth._initializationPromise,this.auth.currentUser?{accessToken:await this.auth.currentUser.getIdToken(e)}:null}addAuthTokenListener(e){if(this.assertAuthConfigured(),this.internalListeners.has(e))return;const t=this.auth.onIdTokenChanged(r=>{e((r==null?void 0:r.stsTokenManager.accessToken)||null)});this.internalListeners.set(e,t),this.updateProactiveRefresh()}removeAuthTokenListener(e){this.assertAuthConfigured();const t=this.internalListeners.get(e);t&&(this.internalListeners.delete(e),t(),this.updateProactiveRefresh())}assertAuthConfigured(){x(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}/**
1563
+ * @license
1564
+ * Copyright 2020 Google LLC
1565
+ *
1566
+ * Licensed under the Apache License, Version 2.0 (the "License");
1567
+ * you may not use this file except in compliance with the License.
1568
+ * You may obtain a copy of the License at
1569
+ *
1570
+ * http://www.apache.org/licenses/LICENSE-2.0
1571
+ *
1572
+ * Unless required by applicable law or agreed to in writing, software
1573
+ * distributed under the License is distributed on an "AS IS" BASIS,
1574
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1575
+ * See the License for the specific language governing permissions and
1576
+ * limitations under the License.
1577
+ */function K_(n){switch(n){case"Node":return"node";case"ReactNative":return"rn";case"Worker":return"webworker";case"Cordova":return"cordova";case"WebExtension":return"web-extension";default:return}}function Q_(n){St(new ut("auth",(e,{options:t})=>{const r=e.getProvider("app").getImmediate(),s=e.getProvider("heartbeat"),i=e.getProvider("app-check-internal"),{apiKey:a,authDomain:c}=r.options;x(a&&!a.includes(":"),"invalid-api-key",{appName:r.name});const l={apiKey:a,authDomain:c,clientPlatform:n,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:Ul(n)},d=new dg(r,s,i,l);return Ig(d,t),d},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((e,t,r)=>{e.getProvider("auth-internal").initialize()})),St(new ut("auth-internal",e=>{const t=xt(e.getProvider("auth").getImmediate());return(r=>new W_(r))(t)},"PRIVATE").setInstantiationMode("EXPLICIT")),qe(ru,su,K_(n)),qe(ru,su,"esm2017")}/**
1578
+ * @license
1579
+ * Copyright 2021 Google LLC
1580
+ *
1581
+ * Licensed under the Apache License, Version 2.0 (the "License");
1582
+ * you may not use this file except in compliance with the License.
1583
+ * You may obtain a copy of the License at
1584
+ *
1585
+ * http://www.apache.org/licenses/LICENSE-2.0
1586
+ *
1587
+ * Unless required by applicable law or agreed to in writing, software
1588
+ * distributed under the License is distributed on an "AS IS" BASIS,
1589
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1590
+ * See the License for the specific language governing permissions and
1591
+ * limitations under the License.
1592
+ */const X_=5*60,J_=gl("authIdTokenMaxAge")||X_;let iu=null;const Y_=n=>async e=>{const t=e&&await e.getIdTokenResult(),r=t&&(new Date().getTime()-Date.parse(t.issuedAtTime))/1e3;if(r&&r>J_)return;const s=t==null?void 0:t.token;iu!==s&&(iu=s,await fetch(n,{method:s?"POST":"DELETE",headers:s?{Authorization:`Bearer ${s}`}:{}}))};function Z_(n=Gs()){const e=Pr(n,"auth");if(e.isInitialized())return e.getImmediate();const t=vg(n,{popupRedirectResolver:G_,persistence:[r_,zg,Kl]}),r=gl("authTokenSyncURL");if(r&&typeof isSecureContext=="boolean"&&isSecureContext){const i=new URL(r,location.origin);if(location.origin===i.origin){const a=Y_(i.toString());qg(t,a,()=>a(t.currentUser)),Bg(t,c=>a(c))}}const s=pl("auth");return s&&wg(t,`http://${s}`),t}function ey(){var n,e;return(e=(n=document.getElementsByTagName("head"))===null||n===void 0?void 0:n[0])!==null&&e!==void 0?e:document}fg({loadJS(n){return new Promise((e,t)=>{const r=document.createElement("script");r.setAttribute("src",n),r.onload=e,r.onerror=s=>{const i=$e("internal-error");i.customData=s,t(i)},r.type="text/javascript",r.charset="UTF-8",ey().appendChild(r)})},gapiScript:"https://apis.google.com/js/api.js",recaptchaV2Script:"https://www.google.com/recaptcha/api.js",recaptchaEnterpriseScript:"https://www.google.com/recaptcha/enterprise.js?render="});Q_("Browser");var ou=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/** @license
1593
+ Copyright The Closure Library Authors.
1594
+ SPDX-License-Identifier: Apache-2.0
1595
+ */var bt,nh;(function(){var n;/** @license
1596
+
1597
+ Copyright The Closure Library Authors.
1598
+ SPDX-License-Identifier: Apache-2.0
1599
+ */function e(v,g){function _(){}_.prototype=g.prototype,v.D=g.prototype,v.prototype=new _,v.prototype.constructor=v,v.C=function(T,I,A){for(var y=Array(arguments.length-2),Ze=2;Ze<arguments.length;Ze++)y[Ze-2]=arguments[Ze];return g.prototype[I].apply(T,y)}}function t(){this.blockSize=-1}function r(){this.blockSize=-1,this.blockSize=64,this.g=Array(4),this.B=Array(this.blockSize),this.o=this.h=0,this.s()}e(r,t),r.prototype.s=function(){this.g[0]=1732584193,this.g[1]=4023233417,this.g[2]=2562383102,this.g[3]=271733878,this.o=this.h=0};function s(v,g,_){_||(_=0);var T=Array(16);if(typeof g=="string")for(var I=0;16>I;++I)T[I]=g.charCodeAt(_++)|g.charCodeAt(_++)<<8|g.charCodeAt(_++)<<16|g.charCodeAt(_++)<<24;else for(I=0;16>I;++I)T[I]=g[_++]|g[_++]<<8|g[_++]<<16|g[_++]<<24;g=v.g[0],_=v.g[1],I=v.g[2];var A=v.g[3],y=g+(A^_&(I^A))+T[0]+3614090360&4294967295;g=_+(y<<7&4294967295|y>>>25),y=A+(I^g&(_^I))+T[1]+3905402710&4294967295,A=g+(y<<12&4294967295|y>>>20),y=I+(_^A&(g^_))+T[2]+606105819&4294967295,I=A+(y<<17&4294967295|y>>>15),y=_+(g^I&(A^g))+T[3]+3250441966&4294967295,_=I+(y<<22&4294967295|y>>>10),y=g+(A^_&(I^A))+T[4]+4118548399&4294967295,g=_+(y<<7&4294967295|y>>>25),y=A+(I^g&(_^I))+T[5]+1200080426&4294967295,A=g+(y<<12&4294967295|y>>>20),y=I+(_^A&(g^_))+T[6]+2821735955&4294967295,I=A+(y<<17&4294967295|y>>>15),y=_+(g^I&(A^g))+T[7]+4249261313&4294967295,_=I+(y<<22&4294967295|y>>>10),y=g+(A^_&(I^A))+T[8]+1770035416&4294967295,g=_+(y<<7&4294967295|y>>>25),y=A+(I^g&(_^I))+T[9]+2336552879&4294967295,A=g+(y<<12&4294967295|y>>>20),y=I+(_^A&(g^_))+T[10]+4294925233&4294967295,I=A+(y<<17&4294967295|y>>>15),y=_+(g^I&(A^g))+T[11]+2304563134&4294967295,_=I+(y<<22&4294967295|y>>>10),y=g+(A^_&(I^A))+T[12]+1804603682&4294967295,g=_+(y<<7&4294967295|y>>>25),y=A+(I^g&(_^I))+T[13]+4254626195&4294967295,A=g+(y<<12&4294967295|y>>>20),y=I+(_^A&(g^_))+T[14]+2792965006&4294967295,I=A+(y<<17&4294967295|y>>>15),y=_+(g^I&(A^g))+T[15]+1236535329&4294967295,_=I+(y<<22&4294967295|y>>>10),y=g+(I^A&(_^I))+T[1]+4129170786&4294967295,g=_+(y<<5&4294967295|y>>>27),y=A+(_^I&(g^_))+T[6]+3225465664&4294967295,A=g+(y<<9&4294967295|y>>>23),y=I+(g^_&(A^g))+T[11]+643717713&4294967295,I=A+(y<<14&4294967295|y>>>18),y=_+(A^g&(I^A))+T[0]+3921069994&4294967295,_=I+(y<<20&4294967295|y>>>12),y=g+(I^A&(_^I))+T[5]+3593408605&4294967295,g=_+(y<<5&4294967295|y>>>27),y=A+(_^I&(g^_))+T[10]+38016083&4294967295,A=g+(y<<9&4294967295|y>>>23),y=I+(g^_&(A^g))+T[15]+3634488961&4294967295,I=A+(y<<14&4294967295|y>>>18),y=_+(A^g&(I^A))+T[4]+3889429448&4294967295,_=I+(y<<20&4294967295|y>>>12),y=g+(I^A&(_^I))+T[9]+568446438&4294967295,g=_+(y<<5&4294967295|y>>>27),y=A+(_^I&(g^_))+T[14]+3275163606&4294967295,A=g+(y<<9&4294967295|y>>>23),y=I+(g^_&(A^g))+T[3]+4107603335&4294967295,I=A+(y<<14&4294967295|y>>>18),y=_+(A^g&(I^A))+T[8]+1163531501&4294967295,_=I+(y<<20&4294967295|y>>>12),y=g+(I^A&(_^I))+T[13]+2850285829&4294967295,g=_+(y<<5&4294967295|y>>>27),y=A+(_^I&(g^_))+T[2]+4243563512&4294967295,A=g+(y<<9&4294967295|y>>>23),y=I+(g^_&(A^g))+T[7]+1735328473&4294967295,I=A+(y<<14&4294967295|y>>>18),y=_+(A^g&(I^A))+T[12]+2368359562&4294967295,_=I+(y<<20&4294967295|y>>>12),y=g+(_^I^A)+T[5]+4294588738&4294967295,g=_+(y<<4&4294967295|y>>>28),y=A+(g^_^I)+T[8]+2272392833&4294967295,A=g+(y<<11&4294967295|y>>>21),y=I+(A^g^_)+T[11]+1839030562&4294967295,I=A+(y<<16&4294967295|y>>>16),y=_+(I^A^g)+T[14]+4259657740&4294967295,_=I+(y<<23&4294967295|y>>>9),y=g+(_^I^A)+T[1]+2763975236&4294967295,g=_+(y<<4&4294967295|y>>>28),y=A+(g^_^I)+T[4]+1272893353&4294967295,A=g+(y<<11&4294967295|y>>>21),y=I+(A^g^_)+T[7]+4139469664&4294967295,I=A+(y<<16&4294967295|y>>>16),y=_+(I^A^g)+T[10]+3200236656&4294967295,_=I+(y<<23&4294967295|y>>>9),y=g+(_^I^A)+T[13]+681279174&4294967295,g=_+(y<<4&4294967295|y>>>28),y=A+(g^_^I)+T[0]+3936430074&4294967295,A=g+(y<<11&4294967295|y>>>21),y=I+(A^g^_)+T[3]+3572445317&4294967295,I=A+(y<<16&4294967295|y>>>16),y=_+(I^A^g)+T[6]+76029189&4294967295,_=I+(y<<23&4294967295|y>>>9),y=g+(_^I^A)+T[9]+3654602809&4294967295,g=_+(y<<4&4294967295|y>>>28),y=A+(g^_^I)+T[12]+3873151461&4294967295,A=g+(y<<11&4294967295|y>>>21),y=I+(A^g^_)+T[15]+530742520&4294967295,I=A+(y<<16&4294967295|y>>>16),y=_+(I^A^g)+T[2]+3299628645&4294967295,_=I+(y<<23&4294967295|y>>>9),y=g+(I^(_|~A))+T[0]+4096336452&4294967295,g=_+(y<<6&4294967295|y>>>26),y=A+(_^(g|~I))+T[7]+1126891415&4294967295,A=g+(y<<10&4294967295|y>>>22),y=I+(g^(A|~_))+T[14]+2878612391&4294967295,I=A+(y<<15&4294967295|y>>>17),y=_+(A^(I|~g))+T[5]+4237533241&4294967295,_=I+(y<<21&4294967295|y>>>11),y=g+(I^(_|~A))+T[12]+1700485571&4294967295,g=_+(y<<6&4294967295|y>>>26),y=A+(_^(g|~I))+T[3]+2399980690&4294967295,A=g+(y<<10&4294967295|y>>>22),y=I+(g^(A|~_))+T[10]+4293915773&4294967295,I=A+(y<<15&4294967295|y>>>17),y=_+(A^(I|~g))+T[1]+2240044497&4294967295,_=I+(y<<21&4294967295|y>>>11),y=g+(I^(_|~A))+T[8]+1873313359&4294967295,g=_+(y<<6&4294967295|y>>>26),y=A+(_^(g|~I))+T[15]+4264355552&4294967295,A=g+(y<<10&4294967295|y>>>22),y=I+(g^(A|~_))+T[6]+2734768916&4294967295,I=A+(y<<15&4294967295|y>>>17),y=_+(A^(I|~g))+T[13]+1309151649&4294967295,_=I+(y<<21&4294967295|y>>>11),y=g+(I^(_|~A))+T[4]+4149444226&4294967295,g=_+(y<<6&4294967295|y>>>26),y=A+(_^(g|~I))+T[11]+3174756917&4294967295,A=g+(y<<10&4294967295|y>>>22),y=I+(g^(A|~_))+T[2]+718787259&4294967295,I=A+(y<<15&4294967295|y>>>17),y=_+(A^(I|~g))+T[9]+3951481745&4294967295,v.g[0]=v.g[0]+g&4294967295,v.g[1]=v.g[1]+(I+(y<<21&4294967295|y>>>11))&4294967295,v.g[2]=v.g[2]+I&4294967295,v.g[3]=v.g[3]+A&4294967295}r.prototype.u=function(v,g){g===void 0&&(g=v.length);for(var _=g-this.blockSize,T=this.B,I=this.h,A=0;A<g;){if(I==0)for(;A<=_;)s(this,v,A),A+=this.blockSize;if(typeof v=="string"){for(;A<g;)if(T[I++]=v.charCodeAt(A++),I==this.blockSize){s(this,T),I=0;break}}else for(;A<g;)if(T[I++]=v[A++],I==this.blockSize){s(this,T),I=0;break}}this.h=I,this.o+=g},r.prototype.v=function(){var v=Array((56>this.h?this.blockSize:2*this.blockSize)-this.h);v[0]=128;for(var g=1;g<v.length-8;++g)v[g]=0;var _=8*this.o;for(g=v.length-8;g<v.length;++g)v[g]=_&255,_/=256;for(this.u(v),v=Array(16),g=_=0;4>g;++g)for(var T=0;32>T;T+=8)v[_++]=this.g[g]>>>T&255;return v};function i(v,g){var _=c;return Object.prototype.hasOwnProperty.call(_,v)?_[v]:_[v]=g(v)}function a(v,g){this.h=g;for(var _=[],T=!0,I=v.length-1;0<=I;I--){var A=v[I]|0;T&&A==g||(_[I]=A,T=!1)}this.g=_}var c={};function l(v){return-128<=v&&128>v?i(v,function(g){return new a([g|0],0>g?-1:0)}):new a([v|0],0>v?-1:0)}function d(v){if(isNaN(v)||!isFinite(v))return m;if(0>v)return k(d(-v));for(var g=[],_=1,T=0;v>=_;T++)g[T]=v/_|0,_*=4294967296;return new a(g,0)}function f(v,g){if(v.length==0)throw Error("number format error: empty string");if(g=g||10,2>g||36<g)throw Error("radix out of range: "+g);if(v.charAt(0)=="-")return k(f(v.substring(1),g));if(0<=v.indexOf("-"))throw Error('number format error: interior "-" character');for(var _=d(Math.pow(g,8)),T=m,I=0;I<v.length;I+=8){var A=Math.min(8,v.length-I),y=parseInt(v.substring(I,I+A),g);8>A?(A=d(Math.pow(g,A)),T=T.j(A).add(d(y))):(T=T.j(_),T=T.add(d(y)))}return T}var m=l(0),E=l(1),R=l(16777216);n=a.prototype,n.m=function(){if(N(this))return-k(this).m();for(var v=0,g=1,_=0;_<this.g.length;_++){var T=this.i(_);v+=(0<=T?T:4294967296+T)*g,g*=4294967296}return v},n.toString=function(v){if(v=v||10,2>v||36<v)throw Error("radix out of range: "+v);if(C(this))return"0";if(N(this))return"-"+k(this).toString(v);for(var g=d(Math.pow(v,6)),_=this,T="";;){var I=j(_,g).g;_=F(_,I.j(g));var A=((0<_.g.length?_.g[0]:_.h)>>>0).toString(v);if(_=I,C(_))return A+T;for(;6>A.length;)A="0"+A;T=A+T}},n.i=function(v){return 0>v?0:v<this.g.length?this.g[v]:this.h};function C(v){if(v.h!=0)return!1;for(var g=0;g<v.g.length;g++)if(v.g[g]!=0)return!1;return!0}function N(v){return v.h==-1}n.l=function(v){return v=F(this,v),N(v)?-1:C(v)?0:1};function k(v){for(var g=v.g.length,_=[],T=0;T<g;T++)_[T]=~v.g[T];return new a(_,~v.h).add(E)}n.abs=function(){return N(this)?k(this):this},n.add=function(v){for(var g=Math.max(this.g.length,v.g.length),_=[],T=0,I=0;I<=g;I++){var A=T+(this.i(I)&65535)+(v.i(I)&65535),y=(A>>>16)+(this.i(I)>>>16)+(v.i(I)>>>16);T=y>>>16,A&=65535,y&=65535,_[I]=y<<16|A}return new a(_,_[_.length-1]&-2147483648?-1:0)};function F(v,g){return v.add(k(g))}n.j=function(v){if(C(this)||C(v))return m;if(N(this))return N(v)?k(this).j(k(v)):k(k(this).j(v));if(N(v))return k(this.j(k(v)));if(0>this.l(R)&&0>v.l(R))return d(this.m()*v.m());for(var g=this.g.length+v.g.length,_=[],T=0;T<2*g;T++)_[T]=0;for(T=0;T<this.g.length;T++)for(var I=0;I<v.g.length;I++){var A=this.i(T)>>>16,y=this.i(T)&65535,Ze=v.i(I)>>>16,Fn=v.i(I)&65535;_[2*T+2*I]+=y*Fn,$(_,2*T+2*I),_[2*T+2*I+1]+=A*Fn,$(_,2*T+2*I+1),_[2*T+2*I+1]+=y*Ze,$(_,2*T+2*I+1),_[2*T+2*I+2]+=A*Ze,$(_,2*T+2*I+2)}for(T=0;T<g;T++)_[T]=_[2*T+1]<<16|_[2*T];for(T=g;T<2*g;T++)_[T]=0;return new a(_,0)};function $(v,g){for(;(v[g]&65535)!=v[g];)v[g+1]+=v[g]>>>16,v[g]&=65535,g++}function M(v,g){this.g=v,this.h=g}function j(v,g){if(C(g))throw Error("division by zero");if(C(v))return new M(m,m);if(N(v))return g=j(k(v),g),new M(k(g.g),k(g.h));if(N(g))return g=j(v,k(g)),new M(k(g.g),g.h);if(30<v.g.length){if(N(v)||N(g))throw Error("slowDivide_ only works with positive integers.");for(var _=E,T=g;0>=T.l(v);)_=ce(_),T=ce(T);var I=X(_,1),A=X(T,1);for(T=X(T,2),_=X(_,2);!C(T);){var y=A.add(T);0>=y.l(v)&&(I=I.add(_),A=y),T=X(T,1),_=X(_,1)}return g=F(v,I.j(g)),new M(I,g)}for(I=m;0<=v.l(g);){for(_=Math.max(1,Math.floor(v.m()/g.m())),T=Math.ceil(Math.log(_)/Math.LN2),T=48>=T?1:Math.pow(2,T-48),A=d(_),y=A.j(g);N(y)||0<y.l(v);)_-=T,A=d(_),y=A.j(g);C(A)&&(A=E),I=I.add(A),v=F(v,y)}return new M(I,v)}n.A=function(v){return j(this,v).h},n.and=function(v){for(var g=Math.max(this.g.length,v.g.length),_=[],T=0;T<g;T++)_[T]=this.i(T)&v.i(T);return new a(_,this.h&v.h)},n.or=function(v){for(var g=Math.max(this.g.length,v.g.length),_=[],T=0;T<g;T++)_[T]=this.i(T)|v.i(T);return new a(_,this.h|v.h)},n.xor=function(v){for(var g=Math.max(this.g.length,v.g.length),_=[],T=0;T<g;T++)_[T]=this.i(T)^v.i(T);return new a(_,this.h^v.h)};function ce(v){for(var g=v.g.length+1,_=[],T=0;T<g;T++)_[T]=v.i(T)<<1|v.i(T-1)>>>31;return new a(_,v.h)}function X(v,g){var _=g>>5;g%=32;for(var T=v.g.length-_,I=[],A=0;A<T;A++)I[A]=0<g?v.i(A+_)>>>g|v.i(A+_+1)<<32-g:v.i(A+_);return new a(I,v.h)}r.prototype.digest=r.prototype.v,r.prototype.reset=r.prototype.s,r.prototype.update=r.prototype.u,nh=r,a.prototype.add=a.prototype.add,a.prototype.multiply=a.prototype.j,a.prototype.modulo=a.prototype.A,a.prototype.compare=a.prototype.l,a.prototype.toNumber=a.prototype.m,a.prototype.toString=a.prototype.toString,a.prototype.getBits=a.prototype.i,a.fromNumber=d,a.fromString=f,bt=a}).apply(typeof ou<"u"?ou:typeof self<"u"?self:typeof window<"u"?window:{});var ss=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/** @license
1600
+ Copyright The Closure Library Authors.
1601
+ SPDX-License-Identifier: Apache-2.0
1602
+ */var rh,or,sh,ms,io,ih,oh,ah;(function(){var n,e=typeof Object.defineProperties=="function"?Object.defineProperty:function(o,u,h){return o==Array.prototype||o==Object.prototype||(o[u]=h.value),o};function t(o){o=[typeof globalThis=="object"&&globalThis,o,typeof window=="object"&&window,typeof self=="object"&&self,typeof ss=="object"&&ss];for(var u=0;u<o.length;++u){var h=o[u];if(h&&h.Math==Math)return h}throw Error("Cannot find global object")}var r=t(this);function s(o,u){if(u)e:{var h=r;o=o.split(".");for(var p=0;p<o.length-1;p++){var w=o[p];if(!(w in h))break e;h=h[w]}o=o[o.length-1],p=h[o],u=u(p),u!=p&&u!=null&&e(h,o,{configurable:!0,writable:!0,value:u})}}function i(o,u){o instanceof String&&(o+="");var h=0,p=!1,w={next:function(){if(!p&&h<o.length){var b=h++;return{value:u(b,o[b]),done:!1}}return p=!0,{done:!0,value:void 0}}};return w[Symbol.iterator]=function(){return w},w}s("Array.prototype.values",function(o){return o||function(){return i(this,function(u,h){return h})}});/** @license
1603
+
1604
+ Copyright The Closure Library Authors.
1605
+ SPDX-License-Identifier: Apache-2.0
1606
+ */var a=a||{},c=this||self;function l(o){var u=typeof o;return u=u!="object"?u:o?Array.isArray(o)?"array":u:"null",u=="array"||u=="object"&&typeof o.length=="number"}function d(o){var u=typeof o;return u=="object"&&o!=null||u=="function"}function f(o,u,h){return o.call.apply(o.bind,arguments)}function m(o,u,h){if(!o)throw Error();if(2<arguments.length){var p=Array.prototype.slice.call(arguments,2);return function(){var w=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(w,p),o.apply(u,w)}}return function(){return o.apply(u,arguments)}}function E(o,u,h){return E=Function.prototype.bind&&Function.prototype.bind.toString().indexOf("native code")!=-1?f:m,E.apply(null,arguments)}function R(o,u){var h=Array.prototype.slice.call(arguments,1);return function(){var p=h.slice();return p.push.apply(p,arguments),o.apply(this,p)}}function C(o,u){function h(){}h.prototype=u.prototype,o.aa=u.prototype,o.prototype=new h,o.prototype.constructor=o,o.Qb=function(p,w,b){for(var D=Array(arguments.length-2),J=2;J<arguments.length;J++)D[J-2]=arguments[J];return u.prototype[w].apply(p,D)}}function N(o){const u=o.length;if(0<u){const h=Array(u);for(let p=0;p<u;p++)h[p]=o[p];return h}return[]}function k(o,u){for(let h=1;h<arguments.length;h++){const p=arguments[h];if(l(p)){const w=o.length||0,b=p.length||0;o.length=w+b;for(let D=0;D<b;D++)o[w+D]=p[D]}else o.push(p)}}class F{constructor(u,h){this.i=u,this.j=h,this.h=0,this.g=null}get(){let u;return 0<this.h?(this.h--,u=this.g,this.g=u.next,u.next=null):u=this.i(),u}}function $(o){return/^[\s\xa0]*$/.test(o)}function M(){var o=c.navigator;return o&&(o=o.userAgent)?o:""}function j(o){return j[" "](o),o}j[" "]=function(){};var ce=M().indexOf("Gecko")!=-1&&!(M().toLowerCase().indexOf("webkit")!=-1&&M().indexOf("Edge")==-1)&&!(M().indexOf("Trident")!=-1||M().indexOf("MSIE")!=-1)&&M().indexOf("Edge")==-1;function X(o,u,h){for(const p in o)u.call(h,o[p],p,o)}function v(o,u){for(const h in o)u.call(void 0,o[h],h,o)}function g(o){const u={};for(const h in o)u[h]=o[h];return u}const _="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function T(o,u){let h,p;for(let w=1;w<arguments.length;w++){p=arguments[w];for(h in p)o[h]=p[h];for(let b=0;b<_.length;b++)h=_[b],Object.prototype.hasOwnProperty.call(p,h)&&(o[h]=p[h])}}function I(o){var u=1;o=o.split(":");const h=[];for(;0<u&&o.length;)h.push(o.shift()),u--;return o.length&&h.push(o.join(":")),h}function A(o){c.setTimeout(()=>{throw o},0)}function y(){var o=_i;let u=null;return o.g&&(u=o.g,o.g=o.g.next,o.g||(o.h=null),u.next=null),u}class Ze{constructor(){this.h=this.g=null}add(u,h){const p=Fn.get();p.set(u,h),this.h?this.h.next=p:this.g=p,this.h=p}}var Fn=new F(()=>new lf,o=>o.reset());class lf{constructor(){this.next=this.g=this.h=null}set(u,h){this.h=u,this.g=h,this.next=null}reset(){this.next=this.g=this.h=null}}let Bn,qn=!1,_i=new Ze,ka=()=>{const o=c.Promise.resolve(void 0);Bn=()=>{o.then(hf)}};var hf=()=>{for(var o;o=y();){try{o.h.call(o.g)}catch(h){A(h)}var u=Fn;u.j(o),100>u.h&&(u.h++,o.next=u.g,u.g=o)}qn=!1};function pt(){this.s=this.s,this.C=this.C}pt.prototype.s=!1,pt.prototype.ma=function(){this.s||(this.s=!0,this.N())},pt.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()};function ge(o,u){this.type=o,this.g=this.target=u,this.defaultPrevented=!1}ge.prototype.h=function(){this.defaultPrevented=!0};var df=function(){if(!c.addEventListener||!Object.defineProperty)return!1;var o=!1,u=Object.defineProperty({},"passive",{get:function(){o=!0}});try{const h=()=>{};c.addEventListener("test",h,u),c.removeEventListener("test",h,u)}catch{}return o}();function $n(o,u){if(ge.call(this,o?o.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,o){var h=this.type=o.type,p=o.changedTouches&&o.changedTouches.length?o.changedTouches[0]:null;if(this.target=o.target||o.srcElement,this.g=u,u=o.relatedTarget){if(ce){e:{try{j(u.nodeName);var w=!0;break e}catch{}w=!1}w||(u=null)}}else h=="mouseover"?u=o.fromElement:h=="mouseout"&&(u=o.toElement);this.relatedTarget=u,p?(this.clientX=p.clientX!==void 0?p.clientX:p.pageX,this.clientY=p.clientY!==void 0?p.clientY:p.pageY,this.screenX=p.screenX||0,this.screenY=p.screenY||0):(this.clientX=o.clientX!==void 0?o.clientX:o.pageX,this.clientY=o.clientY!==void 0?o.clientY:o.pageY,this.screenX=o.screenX||0,this.screenY=o.screenY||0),this.button=o.button,this.key=o.key||"",this.ctrlKey=o.ctrlKey,this.altKey=o.altKey,this.shiftKey=o.shiftKey,this.metaKey=o.metaKey,this.pointerId=o.pointerId||0,this.pointerType=typeof o.pointerType=="string"?o.pointerType:ff[o.pointerType]||"",this.state=o.state,this.i=o,o.defaultPrevented&&$n.aa.h.call(this)}}C($n,ge);var ff={2:"touch",3:"pen",4:"mouse"};$n.prototype.h=function(){$n.aa.h.call(this);var o=this.i;o.preventDefault?o.preventDefault():o.returnValue=!1};var Ur="closure_listenable_"+(1e6*Math.random()|0),pf=0;function mf(o,u,h,p,w){this.listener=o,this.proxy=null,this.src=u,this.type=h,this.capture=!!p,this.ha=w,this.key=++pf,this.da=this.fa=!1}function Fr(o){o.da=!0,o.listener=null,o.proxy=null,o.src=null,o.ha=null}function Br(o){this.src=o,this.g={},this.h=0}Br.prototype.add=function(o,u,h,p,w){var b=o.toString();o=this.g[b],o||(o=this.g[b]=[],this.h++);var D=Ti(o,u,p,w);return-1<D?(u=o[D],h||(u.fa=!1)):(u=new mf(u,this.src,b,!!p,w),u.fa=h,o.push(u)),u};function yi(o,u){var h=u.type;if(h in o.g){var p=o.g[h],w=Array.prototype.indexOf.call(p,u,void 0),b;(b=0<=w)&&Array.prototype.splice.call(p,w,1),b&&(Fr(u),o.g[h].length==0&&(delete o.g[h],o.h--))}}function Ti(o,u,h,p){for(var w=0;w<o.length;++w){var b=o[w];if(!b.da&&b.listener==u&&b.capture==!!h&&b.ha==p)return w}return-1}var Ei="closure_lm_"+(1e6*Math.random()|0),vi={};function Na(o,u,h,p,w){if(Array.isArray(u)){for(var b=0;b<u.length;b++)Na(o,u[b],h,p,w);return null}return h=Va(h),o&&o[Ur]?o.K(u,h,d(p)?!!p.capture:!1,w):gf(o,u,h,!1,p,w)}function gf(o,u,h,p,w,b){if(!u)throw Error("Invalid event type");var D=d(w)?!!w.capture:!!w,J=wi(o);if(J||(o[Ei]=J=new Br(o)),h=J.add(u,h,p,D,b),h.proxy)return h;if(p=_f(),h.proxy=p,p.src=o,p.listener=h,o.addEventListener)df||(w=D),w===void 0&&(w=!1),o.addEventListener(u.toString(),p,w);else if(o.attachEvent)o.attachEvent(Oa(u.toString()),p);else if(o.addListener&&o.removeListener)o.addListener(p);else throw Error("addEventListener and attachEvent are unavailable.");return h}function _f(){function o(h){return u.call(o.src,o.listener,h)}const u=yf;return o}function Da(o,u,h,p,w){if(Array.isArray(u))for(var b=0;b<u.length;b++)Da(o,u[b],h,p,w);else p=d(p)?!!p.capture:!!p,h=Va(h),o&&o[Ur]?(o=o.i,u=String(u).toString(),u in o.g&&(b=o.g[u],h=Ti(b,h,p,w),-1<h&&(Fr(b[h]),Array.prototype.splice.call(b,h,1),b.length==0&&(delete o.g[u],o.h--)))):o&&(o=wi(o))&&(u=o.g[u.toString()],o=-1,u&&(o=Ti(u,h,p,w)),(h=-1<o?u[o]:null)&&Ii(h))}function Ii(o){if(typeof o!="number"&&o&&!o.da){var u=o.src;if(u&&u[Ur])yi(u.i,o);else{var h=o.type,p=o.proxy;u.removeEventListener?u.removeEventListener(h,p,o.capture):u.detachEvent?u.detachEvent(Oa(h),p):u.addListener&&u.removeListener&&u.removeListener(p),(h=wi(u))?(yi(h,o),h.h==0&&(h.src=null,u[Ei]=null)):Fr(o)}}}function Oa(o){return o in vi?vi[o]:vi[o]="on"+o}function yf(o,u){if(o.da)o=!0;else{u=new $n(u,this);var h=o.listener,p=o.ha||o.src;o.fa&&Ii(o),o=h.call(p,u)}return o}function wi(o){return o=o[Ei],o instanceof Br?o:null}var Ai="__closure_events_fn_"+(1e9*Math.random()>>>0);function Va(o){return typeof o=="function"?o:(o[Ai]||(o[Ai]=function(u){return o.handleEvent(u)}),o[Ai])}function _e(){pt.call(this),this.i=new Br(this),this.M=this,this.F=null}C(_e,pt),_e.prototype[Ur]=!0,_e.prototype.removeEventListener=function(o,u,h,p){Da(this,o,u,h,p)};function Ae(o,u){var h,p=o.F;if(p)for(h=[];p;p=p.F)h.push(p);if(o=o.M,p=u.type||u,typeof u=="string")u=new ge(u,o);else if(u instanceof ge)u.target=u.target||o;else{var w=u;u=new ge(p,o),T(u,w)}if(w=!0,h)for(var b=h.length-1;0<=b;b--){var D=u.g=h[b];w=qr(D,p,!0,u)&&w}if(D=u.g=o,w=qr(D,p,!0,u)&&w,w=qr(D,p,!1,u)&&w,h)for(b=0;b<h.length;b++)D=u.g=h[b],w=qr(D,p,!1,u)&&w}_e.prototype.N=function(){if(_e.aa.N.call(this),this.i){var o=this.i,u;for(u in o.g){for(var h=o.g[u],p=0;p<h.length;p++)Fr(h[p]);delete o.g[u],o.h--}}this.F=null},_e.prototype.K=function(o,u,h,p){return this.i.add(String(o),u,!1,h,p)},_e.prototype.L=function(o,u,h,p){return this.i.add(String(o),u,!0,h,p)};function qr(o,u,h,p){if(u=o.i.g[String(u)],!u)return!0;u=u.concat();for(var w=!0,b=0;b<u.length;++b){var D=u[b];if(D&&!D.da&&D.capture==h){var J=D.listener,de=D.ha||D.src;D.fa&&yi(o.i,D),w=J.call(de,p)!==!1&&w}}return w&&!p.defaultPrevented}function La(o,u,h){if(typeof o=="function")h&&(o=E(o,h));else if(o&&typeof o.handleEvent=="function")o=E(o.handleEvent,o);else throw Error("Invalid listener argument");return 2147483647<Number(u)?-1:c.setTimeout(o,u||0)}function Ma(o){o.g=La(()=>{o.g=null,o.i&&(o.i=!1,Ma(o))},o.l);const u=o.h;o.h=null,o.m.apply(null,u)}class Tf extends pt{constructor(u,h){super(),this.m=u,this.l=h,this.h=null,this.i=!1,this.g=null}j(u){this.h=arguments,this.g?this.i=!0:Ma(this)}N(){super.N(),this.g&&(c.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function jn(o){pt.call(this),this.h=o,this.g={}}C(jn,pt);var xa=[];function Ua(o){X(o.g,function(u,h){this.g.hasOwnProperty(h)&&Ii(u)},o),o.g={}}jn.prototype.N=function(){jn.aa.N.call(this),Ua(this)},jn.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var Ri=c.JSON.stringify,Ef=c.JSON.parse,vf=class{stringify(o){return c.JSON.stringify(o,void 0)}parse(o){return c.JSON.parse(o,void 0)}};function bi(){}bi.prototype.h=null;function Fa(o){return o.h||(o.h=o.i())}function Ba(){}var Hn={OPEN:"a",kb:"b",Ja:"c",wb:"d"};function Pi(){ge.call(this,"d")}C(Pi,ge);function Si(){ge.call(this,"c")}C(Si,ge);var Bt={},qa=null;function $r(){return qa=qa||new _e}Bt.La="serverreachability";function $a(o){ge.call(this,Bt.La,o)}C($a,ge);function zn(o){const u=$r();Ae(u,new $a(u))}Bt.STAT_EVENT="statevent";function ja(o,u){ge.call(this,Bt.STAT_EVENT,o),this.stat=u}C(ja,ge);function Re(o){const u=$r();Ae(u,new ja(u,o))}Bt.Ma="timingevent";function Ha(o,u){ge.call(this,Bt.Ma,o),this.size=u}C(Ha,ge);function Gn(o,u){if(typeof o!="function")throw Error("Fn must not be null and must be a function");return c.setTimeout(function(){o()},u)}function Wn(){this.g=!0}Wn.prototype.xa=function(){this.g=!1};function If(o,u,h,p,w,b){o.info(function(){if(o.g)if(b)for(var D="",J=b.split("&"),de=0;de<J.length;de++){var K=J[de].split("=");if(1<K.length){var ye=K[0];K=K[1];var Te=ye.split("_");D=2<=Te.length&&Te[1]=="type"?D+(ye+"="+K+"&"):D+(ye+"=redacted&")}}else D=null;else D=b;return"XMLHTTP REQ ("+p+") [attempt "+w+"]: "+u+`
1607
+ `+h+`
1608
+ `+D})}function wf(o,u,h,p,w,b,D){o.info(function(){return"XMLHTTP RESP ("+p+") [ attempt "+w+"]: "+u+`
1609
+ `+h+`
1610
+ `+b+" "+D})}function un(o,u,h,p){o.info(function(){return"XMLHTTP TEXT ("+u+"): "+Rf(o,h)+(p?" "+p:"")})}function Af(o,u){o.info(function(){return"TIMEOUT: "+u})}Wn.prototype.info=function(){};function Rf(o,u){if(!o.g)return u;if(!u)return null;try{var h=JSON.parse(u);if(h){for(o=0;o<h.length;o++)if(Array.isArray(h[o])){var p=h[o];if(!(2>p.length)){var w=p[1];if(Array.isArray(w)&&!(1>w.length)){var b=w[0];if(b!="noop"&&b!="stop"&&b!="close")for(var D=1;D<w.length;D++)w[D]=""}}}}return Ri(h)}catch{return u}}var jr={NO_ERROR:0,gb:1,tb:2,sb:3,nb:4,rb:5,ub:6,Ia:7,TIMEOUT:8,xb:9},za={lb:"complete",Hb:"success",Ja:"error",Ia:"abort",zb:"ready",Ab:"readystatechange",TIMEOUT:"timeout",vb:"incrementaldata",yb:"progress",ob:"downloadprogress",Pb:"uploadprogress"},Ci;function Hr(){}C(Hr,bi),Hr.prototype.g=function(){return new XMLHttpRequest},Hr.prototype.i=function(){return{}},Ci=new Hr;function mt(o,u,h,p){this.j=o,this.i=u,this.l=h,this.R=p||1,this.U=new jn(this),this.I=45e3,this.H=null,this.o=!1,this.m=this.A=this.v=this.L=this.F=this.S=this.B=null,this.D=[],this.g=null,this.C=0,this.s=this.u=null,this.X=-1,this.J=!1,this.O=0,this.M=null,this.W=this.K=this.T=this.P=!1,this.h=new Ga}function Ga(){this.i=null,this.g="",this.h=!1}var Wa={},ki={};function Ni(o,u,h){o.L=1,o.v=Kr(et(u)),o.m=h,o.P=!0,Ka(o,null)}function Ka(o,u){o.F=Date.now(),zr(o),o.A=et(o.v);var h=o.A,p=o.R;Array.isArray(p)||(p=[String(p)]),cc(h.i,"t",p),o.C=0,h=o.j.J,o.h=new Ga,o.g=bc(o.j,h?u:null,!o.m),0<o.O&&(o.M=new Tf(E(o.Y,o,o.g),o.O)),u=o.U,h=o.g,p=o.ca;var w="readystatechange";Array.isArray(w)||(w&&(xa[0]=w.toString()),w=xa);for(var b=0;b<w.length;b++){var D=Na(h,w[b],p||u.handleEvent,!1,u.h||u);if(!D)break;u.g[D.key]=D}u=o.H?g(o.H):{},o.m?(o.u||(o.u="POST"),u["Content-Type"]="application/x-www-form-urlencoded",o.g.ea(o.A,o.u,o.m,u)):(o.u="GET",o.g.ea(o.A,o.u,null,u)),zn(),If(o.i,o.u,o.A,o.l,o.R,o.m)}mt.prototype.ca=function(o){o=o.target;const u=this.M;u&&tt(o)==3?u.j():this.Y(o)},mt.prototype.Y=function(o){try{if(o==this.g)e:{const Te=tt(this.g);var u=this.g.Ba();const dn=this.g.Z();if(!(3>Te)&&(Te!=3||this.g&&(this.h.h||this.g.oa()||mc(this.g)))){this.J||Te!=4||u==7||(u==8||0>=dn?zn(3):zn(2)),Di(this);var h=this.g.Z();this.X=h;t:if(Qa(this)){var p=mc(this.g);o="";var w=p.length,b=tt(this.g)==4;if(!this.h.i){if(typeof TextDecoder>"u"){qt(this),Kn(this);var D="";break t}this.h.i=new c.TextDecoder}for(u=0;u<w;u++)this.h.h=!0,o+=this.h.i.decode(p[u],{stream:!(b&&u==w-1)});p.length=0,this.h.g+=o,this.C=0,D=this.h.g}else D=this.g.oa();if(this.o=h==200,wf(this.i,this.u,this.A,this.l,this.R,Te,h),this.o){if(this.T&&!this.K){t:{if(this.g){var J,de=this.g;if((J=de.g?de.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!$(J)){var K=J;break t}}K=null}if(h=K)un(this.i,this.l,h,"Initial handshake response via X-HTTP-Initial-Response"),this.K=!0,Oi(this,h);else{this.o=!1,this.s=3,Re(12),qt(this),Kn(this);break e}}if(this.P){h=!0;let xe;for(;!this.J&&this.C<D.length;)if(xe=bf(this,D),xe==ki){Te==4&&(this.s=4,Re(14),h=!1),un(this.i,this.l,null,"[Incomplete Response]");break}else if(xe==Wa){this.s=4,Re(15),un(this.i,this.l,D,"[Invalid Chunk]"),h=!1;break}else un(this.i,this.l,xe,null),Oi(this,xe);if(Qa(this)&&this.C!=0&&(this.h.g=this.h.g.slice(this.C),this.C=0),Te!=4||D.length!=0||this.h.h||(this.s=1,Re(16),h=!1),this.o=this.o&&h,!h)un(this.i,this.l,D,"[Invalid Chunked Response]"),qt(this),Kn(this);else if(0<D.length&&!this.W){this.W=!0;var ye=this.j;ye.g==this&&ye.ba&&!ye.M&&(ye.j.info("Great, no buffering proxy detected. Bytes received: "+D.length),Fi(ye),ye.M=!0,Re(11))}}else un(this.i,this.l,D,null),Oi(this,D);Te==4&&qt(this),this.o&&!this.J&&(Te==4?Ic(this.j,this):(this.o=!1,zr(this)))}else jf(this.g),h==400&&0<D.indexOf("Unknown SID")?(this.s=3,Re(12)):(this.s=0,Re(13)),qt(this),Kn(this)}}}catch{}finally{}};function Qa(o){return o.g?o.u=="GET"&&o.L!=2&&o.j.Ca:!1}function bf(o,u){var h=o.C,p=u.indexOf(`
1611
+ `,h);return p==-1?ki:(h=Number(u.substring(h,p)),isNaN(h)?Wa:(p+=1,p+h>u.length?ki:(u=u.slice(p,p+h),o.C=p+h,u)))}mt.prototype.cancel=function(){this.J=!0,qt(this)};function zr(o){o.S=Date.now()+o.I,Xa(o,o.I)}function Xa(o,u){if(o.B!=null)throw Error("WatchDog timer not null");o.B=Gn(E(o.ba,o),u)}function Di(o){o.B&&(c.clearTimeout(o.B),o.B=null)}mt.prototype.ba=function(){this.B=null;const o=Date.now();0<=o-this.S?(Af(this.i,this.A),this.L!=2&&(zn(),Re(17)),qt(this),this.s=2,Kn(this)):Xa(this,this.S-o)};function Kn(o){o.j.G==0||o.J||Ic(o.j,o)}function qt(o){Di(o);var u=o.M;u&&typeof u.ma=="function"&&u.ma(),o.M=null,Ua(o.U),o.g&&(u=o.g,o.g=null,u.abort(),u.ma())}function Oi(o,u){try{var h=o.j;if(h.G!=0&&(h.g==o||Vi(h.h,o))){if(!o.K&&Vi(h.h,o)&&h.G==3){try{var p=h.Da.g.parse(u)}catch{p=null}if(Array.isArray(p)&&p.length==3){var w=p;if(w[0]==0){e:if(!h.u){if(h.g)if(h.g.F+3e3<o.F)es(h),Yr(h);else break e;Ui(h),Re(18)}}else h.za=w[1],0<h.za-h.T&&37500>w[2]&&h.F&&h.v==0&&!h.C&&(h.C=Gn(E(h.Za,h),6e3));if(1>=Za(h.h)&&h.ca){try{h.ca()}catch{}h.ca=void 0}}else jt(h,11)}else if((o.K||h.g==o)&&es(h),!$(u))for(w=h.Da.g.parse(u),u=0;u<w.length;u++){let K=w[u];if(h.T=K[0],K=K[1],h.G==2)if(K[0]=="c"){h.K=K[1],h.ia=K[2];const ye=K[3];ye!=null&&(h.la=ye,h.j.info("VER="+h.la));const Te=K[4];Te!=null&&(h.Aa=Te,h.j.info("SVER="+h.Aa));const dn=K[5];dn!=null&&typeof dn=="number"&&0<dn&&(p=1.5*dn,h.L=p,h.j.info("backChannelRequestTimeoutMs_="+p)),p=h;const xe=o.g;if(xe){const ns=xe.g?xe.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(ns){var b=p.h;b.g||ns.indexOf("spdy")==-1&&ns.indexOf("quic")==-1&&ns.indexOf("h2")==-1||(b.j=b.l,b.g=new Set,b.h&&(Li(b,b.h),b.h=null))}if(p.D){const Bi=xe.g?xe.g.getResponseHeader("X-HTTP-Session-Id"):null;Bi&&(p.ya=Bi,ee(p.I,p.D,Bi))}}h.G=3,h.l&&h.l.ua(),h.ba&&(h.R=Date.now()-o.F,h.j.info("Handshake RTT: "+h.R+"ms")),p=h;var D=o;if(p.qa=Rc(p,p.J?p.ia:null,p.W),D.K){ec(p.h,D);var J=D,de=p.L;de&&(J.I=de),J.B&&(Di(J),zr(J)),p.g=D}else Ec(p);0<h.i.length&&Zr(h)}else K[0]!="stop"&&K[0]!="close"||jt(h,7);else h.G==3&&(K[0]=="stop"||K[0]=="close"?K[0]=="stop"?jt(h,7):xi(h):K[0]!="noop"&&h.l&&h.l.ta(K),h.v=0)}}zn(4)}catch{}}var Pf=class{constructor(o,u){this.g=o,this.map=u}};function Ja(o){this.l=o||10,c.PerformanceNavigationTiming?(o=c.performance.getEntriesByType("navigation"),o=0<o.length&&(o[0].nextHopProtocol=="hq"||o[0].nextHopProtocol=="h2")):o=!!(c.chrome&&c.chrome.loadTimes&&c.chrome.loadTimes()&&c.chrome.loadTimes().wasFetchedViaSpdy),this.j=o?this.l:1,this.g=null,1<this.j&&(this.g=new Set),this.h=null,this.i=[]}function Ya(o){return o.h?!0:o.g?o.g.size>=o.j:!1}function Za(o){return o.h?1:o.g?o.g.size:0}function Vi(o,u){return o.h?o.h==u:o.g?o.g.has(u):!1}function Li(o,u){o.g?o.g.add(u):o.h=u}function ec(o,u){o.h&&o.h==u?o.h=null:o.g&&o.g.has(u)&&o.g.delete(u)}Ja.prototype.cancel=function(){if(this.i=tc(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&this.g.size!==0){for(const o of this.g.values())o.cancel();this.g.clear()}};function tc(o){if(o.h!=null)return o.i.concat(o.h.D);if(o.g!=null&&o.g.size!==0){let u=o.i;for(const h of o.g.values())u=u.concat(h.D);return u}return N(o.i)}function Sf(o){if(o.V&&typeof o.V=="function")return o.V();if(typeof Map<"u"&&o instanceof Map||typeof Set<"u"&&o instanceof Set)return Array.from(o.values());if(typeof o=="string")return o.split("");if(l(o)){for(var u=[],h=o.length,p=0;p<h;p++)u.push(o[p]);return u}u=[],h=0;for(p in o)u[h++]=o[p];return u}function Cf(o){if(o.na&&typeof o.na=="function")return o.na();if(!o.V||typeof o.V!="function"){if(typeof Map<"u"&&o instanceof Map)return Array.from(o.keys());if(!(typeof Set<"u"&&o instanceof Set)){if(l(o)||typeof o=="string"){var u=[];o=o.length;for(var h=0;h<o;h++)u.push(h);return u}u=[],h=0;for(const p in o)u[h++]=p;return u}}}function nc(o,u){if(o.forEach&&typeof o.forEach=="function")o.forEach(u,void 0);else if(l(o)||typeof o=="string")Array.prototype.forEach.call(o,u,void 0);else for(var h=Cf(o),p=Sf(o),w=p.length,b=0;b<w;b++)u.call(void 0,p[b],h&&h[b],o)}var rc=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function kf(o,u){if(o){o=o.split("&");for(var h=0;h<o.length;h++){var p=o[h].indexOf("="),w=null;if(0<=p){var b=o[h].substring(0,p);w=o[h].substring(p+1)}else b=o[h];u(b,w?decodeURIComponent(w.replace(/\+/g," ")):"")}}}function $t(o){if(this.g=this.o=this.j="",this.s=null,this.m=this.l="",this.h=!1,o instanceof $t){this.h=o.h,Gr(this,o.j),this.o=o.o,this.g=o.g,Wr(this,o.s),this.l=o.l;var u=o.i,h=new Jn;h.i=u.i,u.g&&(h.g=new Map(u.g),h.h=u.h),sc(this,h),this.m=o.m}else o&&(u=String(o).match(rc))?(this.h=!1,Gr(this,u[1]||"",!0),this.o=Qn(u[2]||""),this.g=Qn(u[3]||"",!0),Wr(this,u[4]),this.l=Qn(u[5]||"",!0),sc(this,u[6]||"",!0),this.m=Qn(u[7]||"")):(this.h=!1,this.i=new Jn(null,this.h))}$t.prototype.toString=function(){var o=[],u=this.j;u&&o.push(Xn(u,ic,!0),":");var h=this.g;return(h||u=="file")&&(o.push("//"),(u=this.o)&&o.push(Xn(u,ic,!0),"@"),o.push(encodeURIComponent(String(h)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),h=this.s,h!=null&&o.push(":",String(h))),(h=this.l)&&(this.g&&h.charAt(0)!="/"&&o.push("/"),o.push(Xn(h,h.charAt(0)=="/"?Of:Df,!0))),(h=this.i.toString())&&o.push("?",h),(h=this.m)&&o.push("#",Xn(h,Lf)),o.join("")};function et(o){return new $t(o)}function Gr(o,u,h){o.j=h?Qn(u,!0):u,o.j&&(o.j=o.j.replace(/:$/,""))}function Wr(o,u){if(u){if(u=Number(u),isNaN(u)||0>u)throw Error("Bad port number "+u);o.s=u}else o.s=null}function sc(o,u,h){u instanceof Jn?(o.i=u,Mf(o.i,o.h)):(h||(u=Xn(u,Vf)),o.i=new Jn(u,o.h))}function ee(o,u,h){o.i.set(u,h)}function Kr(o){return ee(o,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)),o}function Qn(o,u){return o?u?decodeURI(o.replace(/%25/g,"%2525")):decodeURIComponent(o):""}function Xn(o,u,h){return typeof o=="string"?(o=encodeURI(o).replace(u,Nf),h&&(o=o.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),o):null}function Nf(o){return o=o.charCodeAt(0),"%"+(o>>4&15).toString(16)+(o&15).toString(16)}var ic=/[#\/\?@]/g,Df=/[#\?:]/g,Of=/[#\?]/g,Vf=/[#\?@]/g,Lf=/#/g;function Jn(o,u){this.h=this.g=null,this.i=o||null,this.j=!!u}function gt(o){o.g||(o.g=new Map,o.h=0,o.i&&kf(o.i,function(u,h){o.add(decodeURIComponent(u.replace(/\+/g," ")),h)}))}n=Jn.prototype,n.add=function(o,u){gt(this),this.i=null,o=ln(this,o);var h=this.g.get(o);return h||this.g.set(o,h=[]),h.push(u),this.h+=1,this};function oc(o,u){gt(o),u=ln(o,u),o.g.has(u)&&(o.i=null,o.h-=o.g.get(u).length,o.g.delete(u))}function ac(o,u){return gt(o),u=ln(o,u),o.g.has(u)}n.forEach=function(o,u){gt(this),this.g.forEach(function(h,p){h.forEach(function(w){o.call(u,w,p,this)},this)},this)},n.na=function(){gt(this);const o=Array.from(this.g.values()),u=Array.from(this.g.keys()),h=[];for(let p=0;p<u.length;p++){const w=o[p];for(let b=0;b<w.length;b++)h.push(u[p])}return h},n.V=function(o){gt(this);let u=[];if(typeof o=="string")ac(this,o)&&(u=u.concat(this.g.get(ln(this,o))));else{o=Array.from(this.g.values());for(let h=0;h<o.length;h++)u=u.concat(o[h])}return u},n.set=function(o,u){return gt(this),this.i=null,o=ln(this,o),ac(this,o)&&(this.h-=this.g.get(o).length),this.g.set(o,[u]),this.h+=1,this},n.get=function(o,u){return o?(o=this.V(o),0<o.length?String(o[0]):u):u};function cc(o,u,h){oc(o,u),0<h.length&&(o.i=null,o.g.set(ln(o,u),N(h)),o.h+=h.length)}n.toString=function(){if(this.i)return this.i;if(!this.g)return"";const o=[],u=Array.from(this.g.keys());for(var h=0;h<u.length;h++){var p=u[h];const b=encodeURIComponent(String(p)),D=this.V(p);for(p=0;p<D.length;p++){var w=b;D[p]!==""&&(w+="="+encodeURIComponent(String(D[p]))),o.push(w)}}return this.i=o.join("&")};function ln(o,u){return u=String(u),o.j&&(u=u.toLowerCase()),u}function Mf(o,u){u&&!o.j&&(gt(o),o.i=null,o.g.forEach(function(h,p){var w=p.toLowerCase();p!=w&&(oc(this,p),cc(this,w,h))},o)),o.j=u}function xf(o,u){const h=new Wn;if(c.Image){const p=new Image;p.onload=R(_t,h,"TestLoadImage: loaded",!0,u,p),p.onerror=R(_t,h,"TestLoadImage: error",!1,u,p),p.onabort=R(_t,h,"TestLoadImage: abort",!1,u,p),p.ontimeout=R(_t,h,"TestLoadImage: timeout",!1,u,p),c.setTimeout(function(){p.ontimeout&&p.ontimeout()},1e4),p.src=o}else u(!1)}function Uf(o,u){const h=new Wn,p=new AbortController,w=setTimeout(()=>{p.abort(),_t(h,"TestPingServer: timeout",!1,u)},1e4);fetch(o,{signal:p.signal}).then(b=>{clearTimeout(w),b.ok?_t(h,"TestPingServer: ok",!0,u):_t(h,"TestPingServer: server error",!1,u)}).catch(()=>{clearTimeout(w),_t(h,"TestPingServer: error",!1,u)})}function _t(o,u,h,p,w){try{w&&(w.onload=null,w.onerror=null,w.onabort=null,w.ontimeout=null),p(h)}catch{}}function Ff(){this.g=new vf}function Bf(o,u,h){const p=h||"";try{nc(o,function(w,b){let D=w;d(w)&&(D=Ri(w)),u.push(p+b+"="+encodeURIComponent(D))})}catch(w){throw u.push(p+"type="+encodeURIComponent("_badmap")),w}}function Qr(o){this.l=o.Ub||null,this.j=o.eb||!1}C(Qr,bi),Qr.prototype.g=function(){return new Xr(this.l,this.j)},Qr.prototype.i=function(o){return function(){return o}}({});function Xr(o,u){_e.call(this),this.D=o,this.o=u,this.m=void 0,this.status=this.readyState=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.u=new Headers,this.h=null,this.B="GET",this.A="",this.g=!1,this.v=this.j=this.l=null}C(Xr,_e),n=Xr.prototype,n.open=function(o,u){if(this.readyState!=0)throw this.abort(),Error("Error reopening a connection");this.B=o,this.A=u,this.readyState=1,Zn(this)},n.send=function(o){if(this.readyState!=1)throw this.abort(),Error("need to call open() first. ");this.g=!0;const u={headers:this.u,method:this.B,credentials:this.m,cache:void 0};o&&(u.body=o),(this.D||c).fetch(new Request(this.A,u)).then(this.Sa.bind(this),this.ga.bind(this))},n.abort=function(){this.response=this.responseText="",this.u=new Headers,this.status=0,this.j&&this.j.cancel("Request was aborted.").catch(()=>{}),1<=this.readyState&&this.g&&this.readyState!=4&&(this.g=!1,Yn(this)),this.readyState=0},n.Sa=function(o){if(this.g&&(this.l=o,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=o.headers,this.readyState=2,Zn(this)),this.g&&(this.readyState=3,Zn(this),this.g)))if(this.responseType==="arraybuffer")o.arrayBuffer().then(this.Qa.bind(this),this.ga.bind(this));else if(typeof c.ReadableStream<"u"&&"body"in o){if(this.j=o.body.getReader(),this.o){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.v=new TextDecoder;uc(this)}else o.text().then(this.Ra.bind(this),this.ga.bind(this))};function uc(o){o.j.read().then(o.Pa.bind(o)).catch(o.ga.bind(o))}n.Pa=function(o){if(this.g){if(this.o&&o.value)this.response.push(o.value);else if(!this.o){var u=o.value?o.value:new Uint8Array(0);(u=this.v.decode(u,{stream:!o.done}))&&(this.response=this.responseText+=u)}o.done?Yn(this):Zn(this),this.readyState==3&&uc(this)}},n.Ra=function(o){this.g&&(this.response=this.responseText=o,Yn(this))},n.Qa=function(o){this.g&&(this.response=o,Yn(this))},n.ga=function(){this.g&&Yn(this)};function Yn(o){o.readyState=4,o.l=null,o.j=null,o.v=null,Zn(o)}n.setRequestHeader=function(o,u){this.u.append(o,u)},n.getResponseHeader=function(o){return this.h&&this.h.get(o.toLowerCase())||""},n.getAllResponseHeaders=function(){if(!this.h)return"";const o=[],u=this.h.entries();for(var h=u.next();!h.done;)h=h.value,o.push(h[0]+": "+h[1]),h=u.next();return o.join(`\r
1612
+ `)};function Zn(o){o.onreadystatechange&&o.onreadystatechange.call(o)}Object.defineProperty(Xr.prototype,"withCredentials",{get:function(){return this.m==="include"},set:function(o){this.m=o?"include":"same-origin"}});function lc(o){let u="";return X(o,function(h,p){u+=p,u+=":",u+=h,u+=`\r
1613
+ `}),u}function Mi(o,u,h){e:{for(p in h){var p=!1;break e}p=!0}p||(h=lc(h),typeof o=="string"?h!=null&&encodeURIComponent(String(h)):ee(o,u,h))}function se(o){_e.call(this),this.headers=new Map,this.o=o||null,this.h=!1,this.v=this.g=null,this.D="",this.m=0,this.l="",this.j=this.B=this.u=this.A=!1,this.I=null,this.H="",this.J=!1}C(se,_e);var qf=/^https?$/i,$f=["POST","PUT"];n=se.prototype,n.Ha=function(o){this.J=o},n.ea=function(o,u,h,p){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.D+"; newUri="+o);u=u?u.toUpperCase():"GET",this.D=o,this.l="",this.m=0,this.A=!1,this.h=!0,this.g=this.o?this.o.g():Ci.g(),this.v=this.o?Fa(this.o):Fa(Ci),this.g.onreadystatechange=E(this.Ea,this);try{this.B=!0,this.g.open(u,String(o),!0),this.B=!1}catch(b){hc(this,b);return}if(o=h||"",h=new Map(this.headers),p)if(Object.getPrototypeOf(p)===Object.prototype)for(var w in p)h.set(w,p[w]);else if(typeof p.keys=="function"&&typeof p.get=="function")for(const b of p.keys())h.set(b,p.get(b));else throw Error("Unknown input type for opt_headers: "+String(p));p=Array.from(h.keys()).find(b=>b.toLowerCase()=="content-type"),w=c.FormData&&o instanceof c.FormData,!(0<=Array.prototype.indexOf.call($f,u,void 0))||p||w||h.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");for(const[b,D]of h)this.g.setRequestHeader(b,D);this.H&&(this.g.responseType=this.H),"withCredentials"in this.g&&this.g.withCredentials!==this.J&&(this.g.withCredentials=this.J);try{pc(this),this.u=!0,this.g.send(o),this.u=!1}catch(b){hc(this,b)}};function hc(o,u){o.h=!1,o.g&&(o.j=!0,o.g.abort(),o.j=!1),o.l=u,o.m=5,dc(o),Jr(o)}function dc(o){o.A||(o.A=!0,Ae(o,"complete"),Ae(o,"error"))}n.abort=function(o){this.g&&this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1,this.m=o||7,Ae(this,"complete"),Ae(this,"abort"),Jr(this))},n.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),Jr(this,!0)),se.aa.N.call(this)},n.Ea=function(){this.s||(this.B||this.u||this.j?fc(this):this.bb())},n.bb=function(){fc(this)};function fc(o){if(o.h&&typeof a<"u"&&(!o.v[1]||tt(o)!=4||o.Z()!=2)){if(o.u&&tt(o)==4)La(o.Ea,0,o);else if(Ae(o,"readystatechange"),tt(o)==4){o.h=!1;try{const D=o.Z();e:switch(D){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var u=!0;break e;default:u=!1}var h;if(!(h=u)){var p;if(p=D===0){var w=String(o.D).match(rc)[1]||null;!w&&c.self&&c.self.location&&(w=c.self.location.protocol.slice(0,-1)),p=!qf.test(w?w.toLowerCase():"")}h=p}if(h)Ae(o,"complete"),Ae(o,"success");else{o.m=6;try{var b=2<tt(o)?o.g.statusText:""}catch{b=""}o.l=b+" ["+o.Z()+"]",dc(o)}}finally{Jr(o)}}}}function Jr(o,u){if(o.g){pc(o);const h=o.g,p=o.v[0]?()=>{}:null;o.g=null,o.v=null,u||Ae(o,"ready");try{h.onreadystatechange=p}catch{}}}function pc(o){o.I&&(c.clearTimeout(o.I),o.I=null)}n.isActive=function(){return!!this.g};function tt(o){return o.g?o.g.readyState:0}n.Z=function(){try{return 2<tt(this)?this.g.status:-1}catch{return-1}},n.oa=function(){try{return this.g?this.g.responseText:""}catch{return""}},n.Oa=function(o){if(this.g){var u=this.g.responseText;return o&&u.indexOf(o)==0&&(u=u.substring(o.length)),Ef(u)}};function mc(o){try{if(!o.g)return null;if("response"in o.g)return o.g.response;switch(o.H){case"":case"text":return o.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in o.g)return o.g.mozResponseArrayBuffer}return null}catch{return null}}function jf(o){const u={};o=(o.g&&2<=tt(o)&&o.g.getAllResponseHeaders()||"").split(`\r
1614
+ `);for(let p=0;p<o.length;p++){if($(o[p]))continue;var h=I(o[p]);const w=h[0];if(h=h[1],typeof h!="string")continue;h=h.trim();const b=u[w]||[];u[w]=b,b.push(h)}v(u,function(p){return p.join(", ")})}n.Ba=function(){return this.m},n.Ka=function(){return typeof this.l=="string"?this.l:String(this.l)};function er(o,u,h){return h&&h.internalChannelParams&&h.internalChannelParams[o]||u}function gc(o){this.Aa=0,this.i=[],this.j=new Wn,this.ia=this.qa=this.I=this.W=this.g=this.ya=this.D=this.H=this.m=this.S=this.o=null,this.Ya=this.U=0,this.Va=er("failFast",!1,o),this.F=this.C=this.u=this.s=this.l=null,this.X=!0,this.za=this.T=-1,this.Y=this.v=this.B=0,this.Ta=er("baseRetryDelayMs",5e3,o),this.cb=er("retryDelaySeedMs",1e4,o),this.Wa=er("forwardChannelMaxRetries",2,o),this.wa=er("forwardChannelRequestTimeoutMs",2e4,o),this.pa=o&&o.xmlHttpFactory||void 0,this.Xa=o&&o.Tb||void 0,this.Ca=o&&o.useFetchStreams||!1,this.L=void 0,this.J=o&&o.supportsCrossDomainXhr||!1,this.K="",this.h=new Ja(o&&o.concurrentRequestLimit),this.Da=new Ff,this.P=o&&o.fastHandshake||!1,this.O=o&&o.encodeInitMessageHeaders||!1,this.P&&this.O&&(this.O=!1),this.Ua=o&&o.Rb||!1,o&&o.xa&&this.j.xa(),o&&o.forceLongPolling&&(this.X=!1),this.ba=!this.P&&this.X&&o&&o.detectBufferingProxy||!1,this.ja=void 0,o&&o.longPollingTimeout&&0<o.longPollingTimeout&&(this.ja=o.longPollingTimeout),this.ca=void 0,this.R=0,this.M=!1,this.ka=this.A=null}n=gc.prototype,n.la=8,n.G=1,n.connect=function(o,u,h,p){Re(0),this.W=o,this.H=u||{},h&&p!==void 0&&(this.H.OSID=h,this.H.OAID=p),this.F=this.X,this.I=Rc(this,null,this.W),Zr(this)};function xi(o){if(_c(o),o.G==3){var u=o.U++,h=et(o.I);if(ee(h,"SID",o.K),ee(h,"RID",u),ee(h,"TYPE","terminate"),tr(o,h),u=new mt(o,o.j,u),u.L=2,u.v=Kr(et(h)),h=!1,c.navigator&&c.navigator.sendBeacon)try{h=c.navigator.sendBeacon(u.v.toString(),"")}catch{}!h&&c.Image&&(new Image().src=u.v,h=!0),h||(u.g=bc(u.j,null),u.g.ea(u.v)),u.F=Date.now(),zr(u)}Ac(o)}function Yr(o){o.g&&(Fi(o),o.g.cancel(),o.g=null)}function _c(o){Yr(o),o.u&&(c.clearTimeout(o.u),o.u=null),es(o),o.h.cancel(),o.s&&(typeof o.s=="number"&&c.clearTimeout(o.s),o.s=null)}function Zr(o){if(!Ya(o.h)&&!o.s){o.s=!0;var u=o.Ga;Bn||ka(),qn||(Bn(),qn=!0),_i.add(u,o),o.B=0}}function Hf(o,u){return Za(o.h)>=o.h.j-(o.s?1:0)?!1:o.s?(o.i=u.D.concat(o.i),!0):o.G==1||o.G==2||o.B>=(o.Va?0:o.Wa)?!1:(o.s=Gn(E(o.Ga,o,u),wc(o,o.B)),o.B++,!0)}n.Ga=function(o){if(this.s)if(this.s=null,this.G==1){if(!o){this.U=Math.floor(1e5*Math.random()),o=this.U++;const w=new mt(this,this.j,o);let b=this.o;if(this.S&&(b?(b=g(b),T(b,this.S)):b=this.S),this.m!==null||this.O||(w.H=b,b=null),this.P)e:{for(var u=0,h=0;h<this.i.length;h++){t:{var p=this.i[h];if("__data__"in p.map&&(p=p.map.__data__,typeof p=="string")){p=p.length;break t}p=void 0}if(p===void 0)break;if(u+=p,4096<u){u=h;break e}if(u===4096||h===this.i.length-1){u=h+1;break e}}u=1e3}else u=1e3;u=Tc(this,w,u),h=et(this.I),ee(h,"RID",o),ee(h,"CVER",22),this.D&&ee(h,"X-HTTP-Session-Id",this.D),tr(this,h),b&&(this.O?u="headers="+encodeURIComponent(String(lc(b)))+"&"+u:this.m&&Mi(h,this.m,b)),Li(this.h,w),this.Ua&&ee(h,"TYPE","init"),this.P?(ee(h,"$req",u),ee(h,"SID","null"),w.T=!0,Ni(w,h,null)):Ni(w,h,u),this.G=2}}else this.G==3&&(o?yc(this,o):this.i.length==0||Ya(this.h)||yc(this))};function yc(o,u){var h;u?h=u.l:h=o.U++;const p=et(o.I);ee(p,"SID",o.K),ee(p,"RID",h),ee(p,"AID",o.T),tr(o,p),o.m&&o.o&&Mi(p,o.m,o.o),h=new mt(o,o.j,h,o.B+1),o.m===null&&(h.H=o.o),u&&(o.i=u.D.concat(o.i)),u=Tc(o,h,1e3),h.I=Math.round(.5*o.wa)+Math.round(.5*o.wa*Math.random()),Li(o.h,h),Ni(h,p,u)}function tr(o,u){o.H&&X(o.H,function(h,p){ee(u,p,h)}),o.l&&nc({},function(h,p){ee(u,p,h)})}function Tc(o,u,h){h=Math.min(o.i.length,h);var p=o.l?E(o.l.Na,o.l,o):null;e:{var w=o.i;let b=-1;for(;;){const D=["count="+h];b==-1?0<h?(b=w[0].g,D.push("ofs="+b)):b=0:D.push("ofs="+b);let J=!0;for(let de=0;de<h;de++){let K=w[de].g;const ye=w[de].map;if(K-=b,0>K)b=Math.max(0,w[de].g-100),J=!1;else try{Bf(ye,D,"req"+K+"_")}catch{p&&p(ye)}}if(J){p=D.join("&");break e}}}return o=o.i.splice(0,h),u.D=o,p}function Ec(o){if(!o.g&&!o.u){o.Y=1;var u=o.Fa;Bn||ka(),qn||(Bn(),qn=!0),_i.add(u,o),o.v=0}}function Ui(o){return o.g||o.u||3<=o.v?!1:(o.Y++,o.u=Gn(E(o.Fa,o),wc(o,o.v)),o.v++,!0)}n.Fa=function(){if(this.u=null,vc(this),this.ba&&!(this.M||this.g==null||0>=this.R)){var o=2*this.R;this.j.info("BP detection timer enabled: "+o),this.A=Gn(E(this.ab,this),o)}},n.ab=function(){this.A&&(this.A=null,this.j.info("BP detection timeout reached."),this.j.info("Buffering proxy detected and switch to long-polling!"),this.F=!1,this.M=!0,Re(10),Yr(this),vc(this))};function Fi(o){o.A!=null&&(c.clearTimeout(o.A),o.A=null)}function vc(o){o.g=new mt(o,o.j,"rpc",o.Y),o.m===null&&(o.g.H=o.o),o.g.O=0;var u=et(o.qa);ee(u,"RID","rpc"),ee(u,"SID",o.K),ee(u,"AID",o.T),ee(u,"CI",o.F?"0":"1"),!o.F&&o.ja&&ee(u,"TO",o.ja),ee(u,"TYPE","xmlhttp"),tr(o,u),o.m&&o.o&&Mi(u,o.m,o.o),o.L&&(o.g.I=o.L);var h=o.g;o=o.ia,h.L=1,h.v=Kr(et(u)),h.m=null,h.P=!0,Ka(h,o)}n.Za=function(){this.C!=null&&(this.C=null,Yr(this),Ui(this),Re(19))};function es(o){o.C!=null&&(c.clearTimeout(o.C),o.C=null)}function Ic(o,u){var h=null;if(o.g==u){es(o),Fi(o),o.g=null;var p=2}else if(Vi(o.h,u))h=u.D,ec(o.h,u),p=1;else return;if(o.G!=0){if(u.o)if(p==1){h=u.m?u.m.length:0,u=Date.now()-u.F;var w=o.B;p=$r(),Ae(p,new Ha(p,h)),Zr(o)}else Ec(o);else if(w=u.s,w==3||w==0&&0<u.X||!(p==1&&Hf(o,u)||p==2&&Ui(o)))switch(h&&0<h.length&&(u=o.h,u.i=u.i.concat(h)),w){case 1:jt(o,5);break;case 4:jt(o,10);break;case 3:jt(o,6);break;default:jt(o,2)}}}function wc(o,u){let h=o.Ta+Math.floor(Math.random()*o.cb);return o.isActive()||(h*=2),h*u}function jt(o,u){if(o.j.info("Error code "+u),u==2){var h=E(o.fb,o),p=o.Xa;const w=!p;p=new $t(p||"//www.google.com/images/cleardot.gif"),c.location&&c.location.protocol=="http"||Gr(p,"https"),Kr(p),w?xf(p.toString(),h):Uf(p.toString(),h)}else Re(2);o.G=0,o.l&&o.l.sa(u),Ac(o),_c(o)}n.fb=function(o){o?(this.j.info("Successfully pinged google.com"),Re(2)):(this.j.info("Failed to ping google.com"),Re(1))};function Ac(o){if(o.G=0,o.ka=[],o.l){const u=tc(o.h);(u.length!=0||o.i.length!=0)&&(k(o.ka,u),k(o.ka,o.i),o.h.i.length=0,N(o.i),o.i.length=0),o.l.ra()}}function Rc(o,u,h){var p=h instanceof $t?et(h):new $t(h);if(p.g!="")u&&(p.g=u+"."+p.g),Wr(p,p.s);else{var w=c.location;p=w.protocol,u=u?u+"."+w.hostname:w.hostname,w=+w.port;var b=new $t(null);p&&Gr(b,p),u&&(b.g=u),w&&Wr(b,w),h&&(b.l=h),p=b}return h=o.D,u=o.ya,h&&u&&ee(p,h,u),ee(p,"VER",o.la),tr(o,p),p}function bc(o,u,h){if(u&&!o.J)throw Error("Can't create secondary domain capable XhrIo object.");return u=o.Ca&&!o.pa?new se(new Qr({eb:h})):new se(o.pa),u.Ha(o.J),u}n.isActive=function(){return!!this.l&&this.l.isActive(this)};function Pc(){}n=Pc.prototype,n.ua=function(){},n.ta=function(){},n.sa=function(){},n.ra=function(){},n.isActive=function(){return!0},n.Na=function(){};function ts(){}ts.prototype.g=function(o,u){return new De(o,u)};function De(o,u){_e.call(this),this.g=new gc(u),this.l=o,this.h=u&&u.messageUrlParams||null,o=u&&u.messageHeaders||null,u&&u.clientProtocolHeaderRequired&&(o?o["X-Client-Protocol"]="webchannel":o={"X-Client-Protocol":"webchannel"}),this.g.o=o,o=u&&u.initMessageHeaders||null,u&&u.messageContentType&&(o?o["X-WebChannel-Content-Type"]=u.messageContentType:o={"X-WebChannel-Content-Type":u.messageContentType}),u&&u.va&&(o?o["X-WebChannel-Client-Profile"]=u.va:o={"X-WebChannel-Client-Profile":u.va}),this.g.S=o,(o=u&&u.Sb)&&!$(o)&&(this.g.m=o),this.v=u&&u.supportsCrossDomainXhr||!1,this.u=u&&u.sendRawJson||!1,(u=u&&u.httpSessionIdParam)&&!$(u)&&(this.g.D=u,o=this.h,o!==null&&u in o&&(o=this.h,u in o&&delete o[u])),this.j=new hn(this)}C(De,_e),De.prototype.m=function(){this.g.l=this.j,this.v&&(this.g.J=!0),this.g.connect(this.l,this.h||void 0)},De.prototype.close=function(){xi(this.g)},De.prototype.o=function(o){var u=this.g;if(typeof o=="string"){var h={};h.__data__=o,o=h}else this.u&&(h={},h.__data__=Ri(o),o=h);u.i.push(new Pf(u.Ya++,o)),u.G==3&&Zr(u)},De.prototype.N=function(){this.g.l=null,delete this.j,xi(this.g),delete this.g,De.aa.N.call(this)};function Sc(o){Pi.call(this),o.__headers__&&(this.headers=o.__headers__,this.statusCode=o.__status__,delete o.__headers__,delete o.__status__);var u=o.__sm__;if(u){e:{for(const h in u){o=h;break e}o=void 0}(this.i=o)&&(o=this.i,u=u!==null&&o in u?u[o]:void 0),this.data=u}else this.data=o}C(Sc,Pi);function Cc(){Si.call(this),this.status=1}C(Cc,Si);function hn(o){this.g=o}C(hn,Pc),hn.prototype.ua=function(){Ae(this.g,"a")},hn.prototype.ta=function(o){Ae(this.g,new Sc(o))},hn.prototype.sa=function(o){Ae(this.g,new Cc)},hn.prototype.ra=function(){Ae(this.g,"b")},ts.prototype.createWebChannel=ts.prototype.g,De.prototype.send=De.prototype.o,De.prototype.open=De.prototype.m,De.prototype.close=De.prototype.close,ah=function(){return new ts},oh=function(){return $r()},ih=Bt,io={mb:0,pb:1,qb:2,Jb:3,Ob:4,Lb:5,Mb:6,Kb:7,Ib:8,Nb:9,PROXY:10,NOPROXY:11,Gb:12,Cb:13,Db:14,Bb:15,Eb:16,Fb:17,ib:18,hb:19,jb:20},jr.NO_ERROR=0,jr.TIMEOUT=8,jr.HTTP_ERROR=6,ms=jr,za.COMPLETE="complete",sh=za,Ba.EventType=Hn,Hn.OPEN="a",Hn.CLOSE="b",Hn.ERROR="c",Hn.MESSAGE="d",_e.prototype.listen=_e.prototype.K,or=Ba,se.prototype.listenOnce=se.prototype.L,se.prototype.getLastError=se.prototype.Ka,se.prototype.getLastErrorCode=se.prototype.Ba,se.prototype.getStatus=se.prototype.Z,se.prototype.getResponseJson=se.prototype.Oa,se.prototype.getResponseText=se.prototype.oa,se.prototype.send=se.prototype.ea,se.prototype.setWithCredentials=se.prototype.Ha,rh=se}).apply(typeof ss<"u"?ss:typeof self<"u"?self:typeof window<"u"?window:{});const au="@firebase/firestore",cu="4.7.10";/**
1615
+ * @license
1616
+ * Copyright 2017 Google LLC
1617
+ *
1618
+ * Licensed under the Apache License, Version 2.0 (the "License");
1619
+ * you may not use this file except in compliance with the License.
1620
+ * You may obtain a copy of the License at
1621
+ *
1622
+ * http://www.apache.org/licenses/LICENSE-2.0
1623
+ *
1624
+ * Unless required by applicable law or agreed to in writing, software
1625
+ * distributed under the License is distributed on an "AS IS" BASIS,
1626
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1627
+ * See the License for the specific language governing permissions and
1628
+ * limitations under the License.
1629
+ */class ve{constructor(e){this.uid=e}isAuthenticated(){return this.uid!=null}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(e){return e.uid===this.uid}}ve.UNAUTHENTICATED=new ve(null),ve.GOOGLE_CREDENTIALS=new ve("google-credentials-uid"),ve.FIRST_PARTY=new ve("first-party-uid"),ve.MOCK_USER=new ve("mock-user");/**
1630
+ * @license
1631
+ * Copyright 2017 Google LLC
1632
+ *
1633
+ * Licensed under the Apache License, Version 2.0 (the "License");
1634
+ * you may not use this file except in compliance with the License.
1635
+ * You may obtain a copy of the License at
1636
+ *
1637
+ * http://www.apache.org/licenses/LICENSE-2.0
1638
+ *
1639
+ * Unless required by applicable law or agreed to in writing, software
1640
+ * distributed under the License is distributed on an "AS IS" BASIS,
1641
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1642
+ * See the License for the specific language governing permissions and
1643
+ * limitations under the License.
1644
+ */let Vn="11.5.0";/**
1645
+ * @license
1646
+ * Copyright 2017 Google LLC
1647
+ *
1648
+ * Licensed under the Apache License, Version 2.0 (the "License");
1649
+ * you may not use this file except in compliance with the License.
1650
+ * You may obtain a copy of the License at
1651
+ *
1652
+ * http://www.apache.org/licenses/LICENSE-2.0
1653
+ *
1654
+ * Unless required by applicable law or agreed to in writing, software
1655
+ * distributed under the License is distributed on an "AS IS" BASIS,
1656
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1657
+ * See the License for the specific language governing permissions and
1658
+ * limitations under the License.
1659
+ */const Yt=new Ro("@firebase/firestore");function pn(){return Yt.logLevel}function V(n,...e){if(Yt.logLevel<=z.DEBUG){const t=e.map(xo);Yt.debug(`Firestore (${Vn}): ${n}`,...t)}}function dt(n,...e){if(Yt.logLevel<=z.ERROR){const t=e.map(xo);Yt.error(`Firestore (${Vn}): ${n}`,...t)}}function Rn(n,...e){if(Yt.logLevel<=z.WARN){const t=e.map(xo);Yt.warn(`Firestore (${Vn}): ${n}`,...t)}}function xo(n){if(typeof n=="string")return n;try{/**
1660
+ * @license
1661
+ * Copyright 2020 Google LLC
1662
+ *
1663
+ * Licensed under the Apache License, Version 2.0 (the "License");
1664
+ * you may not use this file except in compliance with the License.
1665
+ * You may obtain a copy of the License at
1666
+ *
1667
+ * http://www.apache.org/licenses/LICENSE-2.0
1668
+ *
1669
+ * Unless required by applicable law or agreed to in writing, software
1670
+ * distributed under the License is distributed on an "AS IS" BASIS,
1671
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1672
+ * See the License for the specific language governing permissions and
1673
+ * limitations under the License.
1674
+ */return function(t){return JSON.stringify(t)}(n)}catch{return n}}/**
1675
+ * @license
1676
+ * Copyright 2017 Google LLC
1677
+ *
1678
+ * Licensed under the Apache License, Version 2.0 (the "License");
1679
+ * you may not use this file except in compliance with the License.
1680
+ * You may obtain a copy of the License at
1681
+ *
1682
+ * http://www.apache.org/licenses/LICENSE-2.0
1683
+ *
1684
+ * Unless required by applicable law or agreed to in writing, software
1685
+ * distributed under the License is distributed on an "AS IS" BASIS,
1686
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1687
+ * See the License for the specific language governing permissions and
1688
+ * limitations under the License.
1689
+ */function U(n="Unexpected state"){const e=`FIRESTORE (${Vn}) INTERNAL ASSERTION FAILED: `+n;throw dt(e),new Error(e)}function Q(n,e){n||U()}function q(n,e){return n}/**
1690
+ * @license
1691
+ * Copyright 2017 Google LLC
1692
+ *
1693
+ * Licensed under the Apache License, Version 2.0 (the "License");
1694
+ * you may not use this file except in compliance with the License.
1695
+ * You may obtain a copy of the License at
1696
+ *
1697
+ * http://www.apache.org/licenses/LICENSE-2.0
1698
+ *
1699
+ * Unless required by applicable law or agreed to in writing, software
1700
+ * distributed under the License is distributed on an "AS IS" BASIS,
1701
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1702
+ * See the License for the specific language governing permissions and
1703
+ * limitations under the License.
1704
+ */const P={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class O extends He{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}/**
1705
+ * @license
1706
+ * Copyright 2017 Google LLC
1707
+ *
1708
+ * Licensed under the Apache License, Version 2.0 (the "License");
1709
+ * you may not use this file except in compliance with the License.
1710
+ * You may obtain a copy of the License at
1711
+ *
1712
+ * http://www.apache.org/licenses/LICENSE-2.0
1713
+ *
1714
+ * Unless required by applicable law or agreed to in writing, software
1715
+ * distributed under the License is distributed on an "AS IS" BASIS,
1716
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1717
+ * See the License for the specific language governing permissions and
1718
+ * limitations under the License.
1719
+ */class at{constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}/**
1720
+ * @license
1721
+ * Copyright 2017 Google LLC
1722
+ *
1723
+ * Licensed under the Apache License, Version 2.0 (the "License");
1724
+ * you may not use this file except in compliance with the License.
1725
+ * You may obtain a copy of the License at
1726
+ *
1727
+ * http://www.apache.org/licenses/LICENSE-2.0
1728
+ *
1729
+ * Unless required by applicable law or agreed to in writing, software
1730
+ * distributed under the License is distributed on an "AS IS" BASIS,
1731
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1732
+ * See the License for the specific language governing permissions and
1733
+ * limitations under the License.
1734
+ */class ch{constructor(e,t){this.user=t,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class ty{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable(()=>t(ve.UNAUTHENTICATED))}shutdown(){}}class ny{constructor(e){this.token=e,this.changeListener=null}getToken(){return Promise.resolve(this.token)}invalidateToken(){}start(e,t){this.changeListener=t,e.enqueueRetryable(()=>t(this.token.user))}shutdown(){this.changeListener=null}}class ry{constructor(e){this.t=e,this.currentUser=ve.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,t){Q(this.o===void 0);let r=this.i;const s=l=>this.i!==r?(r=this.i,t(l)):Promise.resolve();let i=new at;this.o=()=>{this.i++,this.currentUser=this.u(),i.resolve(),i=new at,e.enqueueRetryable(()=>s(this.currentUser))};const a=()=>{const l=i;e.enqueueRetryable(async()=>{await l.promise,await s(this.currentUser)})},c=l=>{V("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=l,this.o&&(this.auth.addAuthTokenListener(this.o),a())};this.t.onInit(l=>c(l)),setTimeout(()=>{if(!this.auth){const l=this.t.getImmediate({optional:!0});l?c(l):(V("FirebaseAuthCredentialsProvider","Auth not yet detected"),i.resolve(),i=new at)}},0),a()}getToken(){const e=this.i,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then(r=>this.i!==e?(V("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):r?(Q(typeof r.accessToken=="string"),new ch(r.accessToken,this.currentUser)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.o&&this.auth.removeAuthTokenListener(this.o),this.o=void 0}u(){const e=this.auth&&this.auth.getUid();return Q(e===null||typeof e=="string"),new ve(e)}}class sy{constructor(e,t,r){this.l=e,this.h=t,this.P=r,this.type="FirstParty",this.user=ve.FIRST_PARTY,this.T=new Map}I(){return this.P?this.P():null}get headers(){this.T.set("X-Goog-AuthUser",this.l);const e=this.I();return e&&this.T.set("Authorization",e),this.h&&this.T.set("X-Goog-Iam-Authorization-Token",this.h),this.T}}class iy{constructor(e,t,r){this.l=e,this.h=t,this.P=r}getToken(){return Promise.resolve(new sy(this.l,this.h,this.P))}start(e,t){e.enqueueRetryable(()=>t(ve.FIRST_PARTY))}shutdown(){}invalidateToken(){}}class uu{constructor(e){this.value=e,this.type="AppCheck",this.headers=new Map,e&&e.length>0&&this.headers.set("x-firebase-appcheck",this.value)}}class oy{constructor(e,t){this.A=t,this.forceRefresh=!1,this.appCheck=null,this.R=null,this.V=null,Pe(e)&&e.settings.appCheckToken&&(this.V=e.settings.appCheckToken)}start(e,t){Q(this.o===void 0);const r=i=>{i.error!=null&&V("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${i.error.message}`);const a=i.token!==this.R;return this.R=i.token,V("FirebaseAppCheckTokenProvider",`Received ${a?"new":"existing"} token.`),a?t(i.token):Promise.resolve()};this.o=i=>{e.enqueueRetryable(()=>r(i))};const s=i=>{V("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=i,this.o&&this.appCheck.addTokenListener(this.o)};this.A.onInit(i=>s(i)),setTimeout(()=>{if(!this.appCheck){const i=this.A.getImmediate({optional:!0});i?s(i):V("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}},0)}getToken(){if(this.V)return Promise.resolve(new uu(this.V));const e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then(t=>t?(Q(typeof t.token=="string"),this.R=t.token,new uu(t.token)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.o&&this.appCheck.removeTokenListener(this.o),this.o=void 0}}/**
1735
+ * @license
1736
+ * Copyright 2020 Google LLC
1737
+ *
1738
+ * Licensed under the Apache License, Version 2.0 (the "License");
1739
+ * you may not use this file except in compliance with the License.
1740
+ * You may obtain a copy of the License at
1741
+ *
1742
+ * http://www.apache.org/licenses/LICENSE-2.0
1743
+ *
1744
+ * Unless required by applicable law or agreed to in writing, software
1745
+ * distributed under the License is distributed on an "AS IS" BASIS,
1746
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1747
+ * See the License for the specific language governing permissions and
1748
+ * limitations under the License.
1749
+ */function ay(n){const e=typeof self<"u"&&(self.crypto||self.msCrypto),t=new Uint8Array(n);if(e&&typeof e.getRandomValues=="function")e.getRandomValues(t);else for(let r=0;r<n;r++)t[r]=Math.floor(256*Math.random());return t}/**
1750
+ * @license
1751
+ * Copyright 2023 Google LLC
1752
+ *
1753
+ * Licensed under the Apache License, Version 2.0 (the "License");
1754
+ * you may not use this file except in compliance with the License.
1755
+ * You may obtain a copy of the License at
1756
+ *
1757
+ * http://www.apache.org/licenses/LICENSE-2.0
1758
+ *
1759
+ * Unless required by applicable law or agreed to in writing, software
1760
+ * distributed under the License is distributed on an "AS IS" BASIS,
1761
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1762
+ * See the License for the specific language governing permissions and
1763
+ * limitations under the License.
1764
+ */function uh(){return new TextEncoder}/**
1765
+ * @license
1766
+ * Copyright 2017 Google LLC
1767
+ *
1768
+ * Licensed under the Apache License, Version 2.0 (the "License");
1769
+ * you may not use this file except in compliance with the License.
1770
+ * You may obtain a copy of the License at
1771
+ *
1772
+ * http://www.apache.org/licenses/LICENSE-2.0
1773
+ *
1774
+ * Unless required by applicable law or agreed to in writing, software
1775
+ * distributed under the License is distributed on an "AS IS" BASIS,
1776
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1777
+ * See the License for the specific language governing permissions and
1778
+ * limitations under the License.
1779
+ */class lh{static newId(){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t=62*Math.floor(4.129032258064516);let r="";for(;r.length<20;){const s=ay(40);for(let i=0;i<s.length;++i)r.length<20&&s[i]<t&&(r+=e.charAt(s[i]%62))}return r}}function H(n,e){return n<e?-1:n>e?1:0}function oo(n,e){let t=0;for(;t<n.length&&t<e.length;){const r=n.codePointAt(t),s=e.codePointAt(t);if(r!==s){if(r<128&&s<128)return H(r,s);{const i=uh(),a=cy(i.encode(lu(n,t)),i.encode(lu(e,t)));return a!==0?a:H(r,s)}}t+=r>65535?2:1}return H(n.length,e.length)}function lu(n,e){return n.codePointAt(e)>65535?n.substring(e,e+2):n.substring(e,e+1)}function cy(n,e){for(let t=0;t<n.length&&t<e.length;++t)if(n[t]!==e[t])return H(n[t],e[t]);return H(n.length,e.length)}function bn(n,e,t){return n.length===e.length&&n.every((r,s)=>t(r,e[s]))}/**
1780
+ * @license
1781
+ * Copyright 2017 Google LLC
1782
+ *
1783
+ * Licensed under the Apache License, Version 2.0 (the "License");
1784
+ * you may not use this file except in compliance with the License.
1785
+ * You may obtain a copy of the License at
1786
+ *
1787
+ * http://www.apache.org/licenses/LICENSE-2.0
1788
+ *
1789
+ * Unless required by applicable law or agreed to in writing, software
1790
+ * distributed under the License is distributed on an "AS IS" BASIS,
1791
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1792
+ * See the License for the specific language governing permissions and
1793
+ * limitations under the License.
1794
+ */const hu=-62135596800,du=1e6;class ue{static now(){return ue.fromMillis(Date.now())}static fromDate(e){return ue.fromMillis(e.getTime())}static fromMillis(e){const t=Math.floor(e/1e3),r=Math.floor((e-1e3*t)*du);return new ue(t,r)}constructor(e,t){if(this.seconds=e,this.nanoseconds=t,t<0)throw new O(P.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(t>=1e9)throw new O(P.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(e<hu)throw new O(P.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e);if(e>=253402300800)throw new O(P.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/du}_compareTo(e){return this.seconds===e.seconds?H(this.nanoseconds,e.nanoseconds):H(this.seconds,e.seconds)}isEqual(e){return e.seconds===this.seconds&&e.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{seconds:this.seconds,nanoseconds:this.nanoseconds}}valueOf(){const e=this.seconds-hu;return String(e).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}/**
1795
+ * @license
1796
+ * Copyright 2017 Google LLC
1797
+ *
1798
+ * Licensed under the Apache License, Version 2.0 (the "License");
1799
+ * you may not use this file except in compliance with the License.
1800
+ * You may obtain a copy of the License at
1801
+ *
1802
+ * http://www.apache.org/licenses/LICENSE-2.0
1803
+ *
1804
+ * Unless required by applicable law or agreed to in writing, software
1805
+ * distributed under the License is distributed on an "AS IS" BASIS,
1806
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1807
+ * See the License for the specific language governing permissions and
1808
+ * limitations under the License.
1809
+ */class B{static fromTimestamp(e){return new B(e)}static min(){return new B(new ue(0,0))}static max(){return new B(new ue(253402300799,999999999))}constructor(e){this.timestamp=e}compareTo(e){return this.timestamp._compareTo(e.timestamp)}isEqual(e){return this.timestamp.isEqual(e.timestamp)}toMicroseconds(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}toString(){return"SnapshotVersion("+this.timestamp.toString()+")"}toTimestamp(){return this.timestamp}}/**
1810
+ * @license
1811
+ * Copyright 2017 Google LLC
1812
+ *
1813
+ * Licensed under the Apache License, Version 2.0 (the "License");
1814
+ * you may not use this file except in compliance with the License.
1815
+ * You may obtain a copy of the License at
1816
+ *
1817
+ * http://www.apache.org/licenses/LICENSE-2.0
1818
+ *
1819
+ * Unless required by applicable law or agreed to in writing, software
1820
+ * distributed under the License is distributed on an "AS IS" BASIS,
1821
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1822
+ * See the License for the specific language governing permissions and
1823
+ * limitations under the License.
1824
+ */const fu="__name__";class Ge{constructor(e,t,r){t===void 0?t=0:t>e.length&&U(),r===void 0?r=e.length-t:r>e.length-t&&U(),this.segments=e,this.offset=t,this.len=r}get length(){return this.len}isEqual(e){return Ge.comparator(this,e)===0}child(e){const t=this.segments.slice(this.offset,this.limit());return e instanceof Ge?e.forEach(r=>{t.push(r)}):t.push(e),this.construct(t)}limit(){return this.offset+this.length}popFirst(e){return e=e===void 0?1:e,this.construct(this.segments,this.offset+e,this.length-e)}popLast(){return this.construct(this.segments,this.offset,this.length-1)}firstSegment(){return this.segments[this.offset]}lastSegment(){return this.get(this.length-1)}get(e){return this.segments[this.offset+e]}isEmpty(){return this.length===0}isPrefixOf(e){if(e.length<this.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}isImmediateParentOf(e){if(this.length+1!==e.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}forEach(e){for(let t=this.offset,r=this.limit();t<r;t++)e(this.segments[t])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(e,t){const r=Math.min(e.length,t.length);for(let s=0;s<r;s++){const i=Ge.compareSegments(e.get(s),t.get(s));if(i!==0)return i}return H(e.length,t.length)}static compareSegments(e,t){const r=Ge.isNumericId(e),s=Ge.isNumericId(t);return r&&!s?-1:!r&&s?1:r&&s?Ge.extractNumericId(e).compare(Ge.extractNumericId(t)):oo(e,t)}static isNumericId(e){return e.startsWith("__id")&&e.endsWith("__")}static extractNumericId(e){return bt.fromString(e.substring(4,e.length-2))}}class Y extends Ge{construct(e,t,r){return new Y(e,t,r)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...e){const t=[];for(const r of e){if(r.indexOf("//")>=0)throw new O(P.INVALID_ARGUMENT,`Invalid segment (${r}). Paths must not contain // in them.`);t.push(...r.split("/").filter(s=>s.length>0))}return new Y(t)}static emptyPath(){return new Y([])}}const uy=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class pe extends Ge{construct(e,t,r){return new pe(e,t,r)}static isValidIdentifier(e){return uy.test(e)}canonicalString(){return this.toArray().map(e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),pe.isValidIdentifier(e)||(e="`"+e+"`"),e)).join(".")}toString(){return this.canonicalString()}isKeyField(){return this.length===1&&this.get(0)===fu}static keyField(){return new pe([fu])}static fromServerFormat(e){const t=[];let r="",s=0;const i=()=>{if(r.length===0)throw new O(P.INVALID_ARGUMENT,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);t.push(r),r=""};let a=!1;for(;s<e.length;){const c=e[s];if(c==="\\"){if(s+1===e.length)throw new O(P.INVALID_ARGUMENT,"Path has trailing escape character: "+e);const l=e[s+1];if(l!=="\\"&&l!=="."&&l!=="`")throw new O(P.INVALID_ARGUMENT,"Path has invalid escape sequence: "+e);r+=l,s+=2}else c==="`"?(a=!a,s++):c!=="."||a?(r+=c,s++):(i(),s++)}if(i(),a)throw new O(P.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new pe(t)}static emptyPath(){return new pe([])}}/**
1825
+ * @license
1826
+ * Copyright 2017 Google LLC
1827
+ *
1828
+ * Licensed under the Apache License, Version 2.0 (the "License");
1829
+ * you may not use this file except in compliance with the License.
1830
+ * You may obtain a copy of the License at
1831
+ *
1832
+ * http://www.apache.org/licenses/LICENSE-2.0
1833
+ *
1834
+ * Unless required by applicable law or agreed to in writing, software
1835
+ * distributed under the License is distributed on an "AS IS" BASIS,
1836
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1837
+ * See the License for the specific language governing permissions and
1838
+ * limitations under the License.
1839
+ */class L{constructor(e){this.path=e}static fromPath(e){return new L(Y.fromString(e))}static fromName(e){return new L(Y.fromString(e).popFirst(5))}static empty(){return new L(Y.emptyPath())}get collectionGroup(){return this.path.popLast().lastSegment()}hasCollectionId(e){return this.path.length>=2&&this.path.get(this.path.length-2)===e}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(e){return e!==null&&Y.comparator(this.path,e.path)===0}toString(){return this.path.toString()}static comparator(e,t){return Y.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new L(new Y(e.slice()))}}/**
1840
+ * @license
1841
+ * Copyright 2021 Google LLC
1842
+ *
1843
+ * Licensed under the Apache License, Version 2.0 (the "License");
1844
+ * you may not use this file except in compliance with the License.
1845
+ * You may obtain a copy of the License at
1846
+ *
1847
+ * http://www.apache.org/licenses/LICENSE-2.0
1848
+ *
1849
+ * Unless required by applicable law or agreed to in writing, software
1850
+ * distributed under the License is distributed on an "AS IS" BASIS,
1851
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1852
+ * See the License for the specific language governing permissions and
1853
+ * limitations under the License.
1854
+ */const yr=-1;function ly(n,e){const t=n.toTimestamp().seconds,r=n.toTimestamp().nanoseconds+1,s=B.fromTimestamp(r===1e9?new ue(t+1,0):new ue(t,r));return new Ct(s,L.empty(),e)}function hy(n){return new Ct(n.readTime,n.key,yr)}class Ct{constructor(e,t,r){this.readTime=e,this.documentKey=t,this.largestBatchId=r}static min(){return new Ct(B.min(),L.empty(),yr)}static max(){return new Ct(B.max(),L.empty(),yr)}}function dy(n,e){let t=n.readTime.compareTo(e.readTime);return t!==0?t:(t=L.comparator(n.documentKey,e.documentKey),t!==0?t:H(n.largestBatchId,e.largestBatchId))}/**
1855
+ * @license
1856
+ * Copyright 2020 Google LLC
1857
+ *
1858
+ * Licensed under the Apache License, Version 2.0 (the "License");
1859
+ * you may not use this file except in compliance with the License.
1860
+ * You may obtain a copy of the License at
1861
+ *
1862
+ * http://www.apache.org/licenses/LICENSE-2.0
1863
+ *
1864
+ * Unless required by applicable law or agreed to in writing, software
1865
+ * distributed under the License is distributed on an "AS IS" BASIS,
1866
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1867
+ * See the License for the specific language governing permissions and
1868
+ * limitations under the License.
1869
+ */const fy="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class py{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach(e=>e())}}/**
1870
+ * @license
1871
+ * Copyright 2017 Google LLC
1872
+ *
1873
+ * Licensed under the Apache License, Version 2.0 (the "License");
1874
+ * you may not use this file except in compliance with the License.
1875
+ * You may obtain a copy of the License at
1876
+ *
1877
+ * http://www.apache.org/licenses/LICENSE-2.0
1878
+ *
1879
+ * Unless required by applicable law or agreed to in writing, software
1880
+ * distributed under the License is distributed on an "AS IS" BASIS,
1881
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1882
+ * See the License for the specific language governing permissions and
1883
+ * limitations under the License.
1884
+ */async function Ln(n){if(n.code!==P.FAILED_PRECONDITION||n.message!==fy)throw n;V("LocalStore","Unexpectedly lost primary lease")}/**
1885
+ * @license
1886
+ * Copyright 2017 Google LLC
1887
+ *
1888
+ * Licensed under the Apache License, Version 2.0 (the "License");
1889
+ * you may not use this file except in compliance with the License.
1890
+ * You may obtain a copy of the License at
1891
+ *
1892
+ * http://www.apache.org/licenses/LICENSE-2.0
1893
+ *
1894
+ * Unless required by applicable law or agreed to in writing, software
1895
+ * distributed under the License is distributed on an "AS IS" BASIS,
1896
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1897
+ * See the License for the specific language governing permissions and
1898
+ * limitations under the License.
1899
+ */class S{constructor(e){this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,e(t=>{this.isDone=!0,this.result=t,this.nextCallback&&this.nextCallback(t)},t=>{this.isDone=!0,this.error=t,this.catchCallback&&this.catchCallback(t)})}catch(e){return this.next(void 0,e)}next(e,t){return this.callbackAttached&&U(),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(t,this.error):this.wrapSuccess(e,this.result):new S((r,s)=>{this.nextCallback=i=>{this.wrapSuccess(e,i).next(r,s)},this.catchCallback=i=>{this.wrapFailure(t,i).next(r,s)}})}toPromise(){return new Promise((e,t)=>{this.next(e,t)})}wrapUserFunction(e){try{const t=e();return t instanceof S?t:S.resolve(t)}catch(t){return S.reject(t)}}wrapSuccess(e,t){return e?this.wrapUserFunction(()=>e(t)):S.resolve(t)}wrapFailure(e,t){return e?this.wrapUserFunction(()=>e(t)):S.reject(t)}static resolve(e){return new S((t,r)=>{t(e)})}static reject(e){return new S((t,r)=>{r(e)})}static waitFor(e){return new S((t,r)=>{let s=0,i=0,a=!1;e.forEach(c=>{++s,c.next(()=>{++i,a&&i===s&&t()},l=>r(l))}),a=!0,i===s&&t()})}static or(e){let t=S.resolve(!1);for(const r of e)t=t.next(s=>s?S.resolve(s):r());return t}static forEach(e,t){const r=[];return e.forEach((s,i)=>{r.push(t.call(this,s,i))}),this.waitFor(r)}static mapArray(e,t){return new S((r,s)=>{const i=e.length,a=new Array(i);let c=0;for(let l=0;l<i;l++){const d=l;t(e[d]).next(f=>{a[d]=f,++c,c===i&&r(a)},f=>s(f))}})}static doWhile(e,t){return new S((r,s)=>{const i=()=>{e()===!0?t().next(()=>{i()},s):r()};i()})}}function my(n){const e=n.match(/Android ([\d.]+)/i),t=e?e[1].split(".").slice(0,2).join("."):"-1";return Number(t)}function Mn(n){return n.name==="IndexedDbTransactionError"}/**
1900
+ * @license
1901
+ * Copyright 2018 Google LLC
1902
+ *
1903
+ * Licensed under the Apache License, Version 2.0 (the "License");
1904
+ * you may not use this file except in compliance with the License.
1905
+ * You may obtain a copy of the License at
1906
+ *
1907
+ * http://www.apache.org/licenses/LICENSE-2.0
1908
+ *
1909
+ * Unless required by applicable law or agreed to in writing, software
1910
+ * distributed under the License is distributed on an "AS IS" BASIS,
1911
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1912
+ * See the License for the specific language governing permissions and
1913
+ * limitations under the License.
1914
+ */class Xs{constructor(e,t){this.previousValue=e,t&&(t.sequenceNumberHandler=r=>this.oe(r),this._e=r=>t.writeSequenceNumber(r))}oe(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}next(){const e=++this.previousValue;return this._e&&this._e(e),e}}Xs.ae=-1;/**
1915
+ * @license
1916
+ * Copyright 2017 Google LLC
1917
+ *
1918
+ * Licensed under the Apache License, Version 2.0 (the "License");
1919
+ * you may not use this file except in compliance with the License.
1920
+ * You may obtain a copy of the License at
1921
+ *
1922
+ * http://www.apache.org/licenses/LICENSE-2.0
1923
+ *
1924
+ * Unless required by applicable law or agreed to in writing, software
1925
+ * distributed under the License is distributed on an "AS IS" BASIS,
1926
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1927
+ * See the License for the specific language governing permissions and
1928
+ * limitations under the License.
1929
+ */const Uo=-1;function Js(n){return n==null}function Ns(n){return n===0&&1/n==-1/0}function gy(n){return typeof n=="number"&&Number.isInteger(n)&&!Ns(n)&&n<=Number.MAX_SAFE_INTEGER&&n>=Number.MIN_SAFE_INTEGER}/**
1930
+ * @license
1931
+ * Copyright 2017 Google LLC
1932
+ *
1933
+ * Licensed under the Apache License, Version 2.0 (the "License");
1934
+ * you may not use this file except in compliance with the License.
1935
+ * You may obtain a copy of the License at
1936
+ *
1937
+ * http://www.apache.org/licenses/LICENSE-2.0
1938
+ *
1939
+ * Unless required by applicable law or agreed to in writing, software
1940
+ * distributed under the License is distributed on an "AS IS" BASIS,
1941
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1942
+ * See the License for the specific language governing permissions and
1943
+ * limitations under the License.
1944
+ */const hh="";function _y(n){let e="";for(let t=0;t<n.length;t++)e.length>0&&(e=pu(e)),e=yy(n.get(t),e);return pu(e)}function yy(n,e){let t=e;const r=n.length;for(let s=0;s<r;s++){const i=n.charAt(s);switch(i){case"\0":t+="";break;case hh:t+="";break;default:t+=i}}return t}function pu(n){return n+hh+""}/**
1945
+ * @license
1946
+ * Copyright 2017 Google LLC
1947
+ *
1948
+ * Licensed under the Apache License, Version 2.0 (the "License");
1949
+ * you may not use this file except in compliance with the License.
1950
+ * You may obtain a copy of the License at
1951
+ *
1952
+ * http://www.apache.org/licenses/LICENSE-2.0
1953
+ *
1954
+ * Unless required by applicable law or agreed to in writing, software
1955
+ * distributed under the License is distributed on an "AS IS" BASIS,
1956
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1957
+ * See the License for the specific language governing permissions and
1958
+ * limitations under the License.
1959
+ */function mu(n){let e=0;for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&e++;return e}function rn(n,e){for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&e(t,n[t])}function dh(n){for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e))return!1;return!0}/**
1960
+ * @license
1961
+ * Copyright 2017 Google LLC
1962
+ *
1963
+ * Licensed under the Apache License, Version 2.0 (the "License");
1964
+ * you may not use this file except in compliance with the License.
1965
+ * You may obtain a copy of the License at
1966
+ *
1967
+ * http://www.apache.org/licenses/LICENSE-2.0
1968
+ *
1969
+ * Unless required by applicable law or agreed to in writing, software
1970
+ * distributed under the License is distributed on an "AS IS" BASIS,
1971
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1972
+ * See the License for the specific language governing permissions and
1973
+ * limitations under the License.
1974
+ */class ne{constructor(e,t){this.comparator=e,this.root=t||fe.EMPTY}insert(e,t){return new ne(this.comparator,this.root.insert(e,t,this.comparator).copy(null,null,fe.BLACK,null,null))}remove(e){return new ne(this.comparator,this.root.remove(e,this.comparator).copy(null,null,fe.BLACK,null,null))}get(e){let t=this.root;for(;!t.isEmpty();){const r=this.comparator(e,t.key);if(r===0)return t.value;r<0?t=t.left:r>0&&(t=t.right)}return null}indexOf(e){let t=0,r=this.root;for(;!r.isEmpty();){const s=this.comparator(e,r.key);if(s===0)return t+r.left.size;s<0?r=r.left:(t+=r.left.size+1,r=r.right)}return-1}isEmpty(){return this.root.isEmpty()}get size(){return this.root.size}minKey(){return this.root.minKey()}maxKey(){return this.root.maxKey()}inorderTraversal(e){return this.root.inorderTraversal(e)}forEach(e){this.inorderTraversal((t,r)=>(e(t,r),!1))}toString(){const e=[];return this.inorderTraversal((t,r)=>(e.push(`${t}:${r}`),!1)),`{${e.join(", ")}}`}reverseTraversal(e){return this.root.reverseTraversal(e)}getIterator(){return new is(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new is(this.root,e,this.comparator,!1)}getReverseIterator(){return new is(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new is(this.root,e,this.comparator,!0)}}class is{constructor(e,t,r,s){this.isReverse=s,this.nodeStack=[];let i=1;for(;!e.isEmpty();)if(i=t?r(e.key,t):1,t&&s&&(i*=-1),i<0)e=this.isReverse?e.left:e.right;else{if(i===0){this.nodeStack.push(e);break}this.nodeStack.push(e),e=this.isReverse?e.right:e.left}}getNext(){let e=this.nodeStack.pop();const t={key:e.key,value:e.value};if(this.isReverse)for(e=e.left;!e.isEmpty();)this.nodeStack.push(e),e=e.right;else for(e=e.right;!e.isEmpty();)this.nodeStack.push(e),e=e.left;return t}hasNext(){return this.nodeStack.length>0}peek(){if(this.nodeStack.length===0)return null;const e=this.nodeStack[this.nodeStack.length-1];return{key:e.key,value:e.value}}}class fe{constructor(e,t,r,s,i){this.key=e,this.value=t,this.color=r??fe.RED,this.left=s??fe.EMPTY,this.right=i??fe.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,t,r,s,i){return new fe(e??this.key,t??this.value,r??this.color,s??this.left,i??this.right)}isEmpty(){return!1}inorderTraversal(e){return this.left.inorderTraversal(e)||e(this.key,this.value)||this.right.inorderTraversal(e)}reverseTraversal(e){return this.right.reverseTraversal(e)||e(this.key,this.value)||this.left.reverseTraversal(e)}min(){return this.left.isEmpty()?this:this.left.min()}minKey(){return this.min().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(e,t,r){let s=this;const i=r(e,s.key);return s=i<0?s.copy(null,null,null,s.left.insert(e,t,r),null):i===0?s.copy(null,t,null,null,null):s.copy(null,null,null,null,s.right.insert(e,t,r)),s.fixUp()}removeMin(){if(this.left.isEmpty())return fe.EMPTY;let e=this;return e.left.isRed()||e.left.left.isRed()||(e=e.moveRedLeft()),e=e.copy(null,null,null,e.left.removeMin(),null),e.fixUp()}remove(e,t){let r,s=this;if(t(e,s.key)<0)s.left.isEmpty()||s.left.isRed()||s.left.left.isRed()||(s=s.moveRedLeft()),s=s.copy(null,null,null,s.left.remove(e,t),null);else{if(s.left.isRed()&&(s=s.rotateRight()),s.right.isEmpty()||s.right.isRed()||s.right.left.isRed()||(s=s.moveRedRight()),t(e,s.key)===0){if(s.right.isEmpty())return fe.EMPTY;r=s.right.min(),s=s.copy(r.key,r.value,null,null,s.right.removeMin())}s=s.copy(null,null,null,null,s.right.remove(e,t))}return s.fixUp()}isRed(){return this.color}fixUp(){let e=this;return e.right.isRed()&&!e.left.isRed()&&(e=e.rotateLeft()),e.left.isRed()&&e.left.left.isRed()&&(e=e.rotateRight()),e.left.isRed()&&e.right.isRed()&&(e=e.colorFlip()),e}moveRedLeft(){let e=this.colorFlip();return e.right.left.isRed()&&(e=e.copy(null,null,null,null,e.right.rotateRight()),e=e.rotateLeft(),e=e.colorFlip()),e}moveRedRight(){let e=this.colorFlip();return e.left.left.isRed()&&(e=e.rotateRight(),e=e.colorFlip()),e}rotateLeft(){const e=this.copy(null,null,fe.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){const e=this.copy(null,null,fe.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip(){const e=this.left.copy(null,null,!this.left.color,null,null),t=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,t)}checkMaxDepth(){const e=this.check();return Math.pow(2,e)<=this.size+1}check(){if(this.isRed()&&this.left.isRed()||this.right.isRed())throw U();const e=this.left.check();if(e!==this.right.check())throw U();return e+(this.isRed()?0:1)}}fe.EMPTY=null,fe.RED=!0,fe.BLACK=!1;fe.EMPTY=new class{constructor(){this.size=0}get key(){throw U()}get value(){throw U()}get color(){throw U()}get left(){throw U()}get right(){throw U()}copy(e,t,r,s,i){return this}insert(e,t,r){return new fe(e,t)}remove(e,t){return this}isEmpty(){return!0}inorderTraversal(e){return!1}reverseTraversal(e){return!1}minKey(){return null}maxKey(){return null}isRed(){return!1}checkMaxDepth(){return!0}check(){return 0}};/**
1975
+ * @license
1976
+ * Copyright 2017 Google LLC
1977
+ *
1978
+ * Licensed under the Apache License, Version 2.0 (the "License");
1979
+ * you may not use this file except in compliance with the License.
1980
+ * You may obtain a copy of the License at
1981
+ *
1982
+ * http://www.apache.org/licenses/LICENSE-2.0
1983
+ *
1984
+ * Unless required by applicable law or agreed to in writing, software
1985
+ * distributed under the License is distributed on an "AS IS" BASIS,
1986
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1987
+ * See the License for the specific language governing permissions and
1988
+ * limitations under the License.
1989
+ */class le{constructor(e){this.comparator=e,this.data=new ne(this.comparator)}has(e){return this.data.get(e)!==null}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(e){return this.data.indexOf(e)}forEach(e){this.data.inorderTraversal((t,r)=>(e(t),!1))}forEachInRange(e,t){const r=this.data.getIteratorFrom(e[0]);for(;r.hasNext();){const s=r.getNext();if(this.comparator(s.key,e[1])>=0)return;t(s.key)}}forEachWhile(e,t){let r;for(r=t!==void 0?this.data.getIteratorFrom(t):this.data.getIterator();r.hasNext();)if(!e(r.getNext().key))return}firstAfterOrEqual(e){const t=this.data.getIteratorFrom(e);return t.hasNext()?t.getNext().key:null}getIterator(){return new gu(this.data.getIterator())}getIteratorFrom(e){return new gu(this.data.getIteratorFrom(e))}add(e){return this.copy(this.data.remove(e).insert(e,!0))}delete(e){return this.has(e)?this.copy(this.data.remove(e)):this}isEmpty(){return this.data.isEmpty()}unionWith(e){let t=this;return t.size<e.size&&(t=e,e=this),e.forEach(r=>{t=t.add(r)}),t}isEqual(e){if(!(e instanceof le)||this.size!==e.size)return!1;const t=this.data.getIterator(),r=e.data.getIterator();for(;t.hasNext();){const s=t.getNext().key,i=r.getNext().key;if(this.comparator(s,i)!==0)return!1}return!0}toArray(){const e=[];return this.forEach(t=>{e.push(t)}),e}toString(){const e=[];return this.forEach(t=>e.push(t)),"SortedSet("+e.toString()+")"}copy(e){const t=new le(this.comparator);return t.data=e,t}}class gu{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}/**
1990
+ * @license
1991
+ * Copyright 2020 Google LLC
1992
+ *
1993
+ * Licensed under the Apache License, Version 2.0 (the "License");
1994
+ * you may not use this file except in compliance with the License.
1995
+ * You may obtain a copy of the License at
1996
+ *
1997
+ * http://www.apache.org/licenses/LICENSE-2.0
1998
+ *
1999
+ * Unless required by applicable law or agreed to in writing, software
2000
+ * distributed under the License is distributed on an "AS IS" BASIS,
2001
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2002
+ * See the License for the specific language governing permissions and
2003
+ * limitations under the License.
2004
+ */class Be{constructor(e){this.fields=e,e.sort(pe.comparator)}static empty(){return new Be([])}unionWith(e){let t=new le(pe.comparator);for(const r of this.fields)t=t.add(r);for(const r of e)t=t.add(r);return new Be(t.toArray())}covers(e){for(const t of this.fields)if(t.isPrefixOf(e))return!0;return!1}isEqual(e){return bn(this.fields,e.fields,(t,r)=>t.isEqual(r))}}/**
2005
+ * @license
2006
+ * Copyright 2023 Google LLC
2007
+ *
2008
+ * Licensed under the Apache License, Version 2.0 (the "License");
2009
+ * you may not use this file except in compliance with the License.
2010
+ * You may obtain a copy of the License at
2011
+ *
2012
+ * http://www.apache.org/licenses/LICENSE-2.0
2013
+ *
2014
+ * Unless required by applicable law or agreed to in writing, software
2015
+ * distributed under the License is distributed on an "AS IS" BASIS,
2016
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2017
+ * See the License for the specific language governing permissions and
2018
+ * limitations under the License.
2019
+ */class fh extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}/**
2020
+ * @license
2021
+ * Copyright 2020 Google LLC
2022
+ *
2023
+ * Licensed under the Apache License, Version 2.0 (the "License");
2024
+ * you may not use this file except in compliance with the License.
2025
+ * You may obtain a copy of the License at
2026
+ *
2027
+ * http://www.apache.org/licenses/LICENSE-2.0
2028
+ *
2029
+ * Unless required by applicable law or agreed to in writing, software
2030
+ * distributed under the License is distributed on an "AS IS" BASIS,
2031
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2032
+ * See the License for the specific language governing permissions and
2033
+ * limitations under the License.
2034
+ */class me{constructor(e){this.binaryString=e}static fromBase64String(e){const t=function(s){try{return atob(s)}catch(i){throw typeof DOMException<"u"&&i instanceof DOMException?new fh("Invalid base64 string: "+i):i}}(e);return new me(t)}static fromUint8Array(e){const t=function(s){let i="";for(let a=0;a<s.length;++a)i+=String.fromCharCode(s[a]);return i}(e);return new me(t)}[Symbol.iterator](){let e=0;return{next:()=>e<this.binaryString.length?{value:this.binaryString.charCodeAt(e++),done:!1}:{value:void 0,done:!0}}}toBase64(){return function(t){return btoa(t)}(this.binaryString)}toUint8Array(){return function(t){const r=new Uint8Array(t.length);for(let s=0;s<t.length;s++)r[s]=t.charCodeAt(s);return r}(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(e){return H(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}}me.EMPTY_BYTE_STRING=new me("");const Ty=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function kt(n){if(Q(!!n),typeof n=="string"){let e=0;const t=Ty.exec(n);if(Q(!!t),t[1]){let s=t[1];s=(s+"000000000").substr(0,9),e=Number(s)}const r=new Date(n);return{seconds:Math.floor(r.getTime()/1e3),nanos:e}}return{seconds:ie(n.seconds),nanos:ie(n.nanos)}}function ie(n){return typeof n=="number"?n:typeof n=="string"?Number(n):0}function Nt(n){return typeof n=="string"?me.fromBase64String(n):me.fromUint8Array(n)}/**
2035
+ * @license
2036
+ * Copyright 2020 Google LLC
2037
+ *
2038
+ * Licensed under the Apache License, Version 2.0 (the "License");
2039
+ * you may not use this file except in compliance with the License.
2040
+ * You may obtain a copy of the License at
2041
+ *
2042
+ * http://www.apache.org/licenses/LICENSE-2.0
2043
+ *
2044
+ * Unless required by applicable law or agreed to in writing, software
2045
+ * distributed under the License is distributed on an "AS IS" BASIS,
2046
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2047
+ * See the License for the specific language governing permissions and
2048
+ * limitations under the License.
2049
+ */const ph="server_timestamp",mh="__type__",gh="__previous_value__",_h="__local_write_time__";function Ys(n){var e,t;return((t=(((e=n==null?void 0:n.mapValue)===null||e===void 0?void 0:e.fields)||{})[mh])===null||t===void 0?void 0:t.stringValue)===ph}function Zs(n){const e=n.mapValue.fields[gh];return Ys(e)?Zs(e):e}function Tr(n){const e=kt(n.mapValue.fields[_h].timestampValue);return new ue(e.seconds,e.nanos)}/**
2050
+ * @license
2051
+ * Copyright 2017 Google LLC
2052
+ *
2053
+ * Licensed under the Apache License, Version 2.0 (the "License");
2054
+ * you may not use this file except in compliance with the License.
2055
+ * You may obtain a copy of the License at
2056
+ *
2057
+ * http://www.apache.org/licenses/LICENSE-2.0
2058
+ *
2059
+ * Unless required by applicable law or agreed to in writing, software
2060
+ * distributed under the License is distributed on an "AS IS" BASIS,
2061
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2062
+ * See the License for the specific language governing permissions and
2063
+ * limitations under the License.
2064
+ */class Ey{constructor(e,t,r,s,i,a,c,l,d){this.databaseId=e,this.appId=t,this.persistenceKey=r,this.host=s,this.ssl=i,this.forceLongPolling=a,this.autoDetectLongPolling=c,this.longPollingOptions=l,this.useFetchStreams=d}}const Ds="(default)";class Er{constructor(e,t){this.projectId=e,this.database=t||Ds}static empty(){return new Er("","")}get isDefaultDatabase(){return this.database===Ds}isEqual(e){return e instanceof Er&&e.projectId===this.projectId&&e.database===this.database}}/**
2065
+ * @license
2066
+ * Copyright 2020 Google LLC
2067
+ *
2068
+ * Licensed under the Apache License, Version 2.0 (the "License");
2069
+ * you may not use this file except in compliance with the License.
2070
+ * You may obtain a copy of the License at
2071
+ *
2072
+ * http://www.apache.org/licenses/LICENSE-2.0
2073
+ *
2074
+ * Unless required by applicable law or agreed to in writing, software
2075
+ * distributed under the License is distributed on an "AS IS" BASIS,
2076
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2077
+ * See the License for the specific language governing permissions and
2078
+ * limitations under the License.
2079
+ */const yh="__type__",vy="__max__",os={mapValue:{}},Th="__vector__",Os="value";function Dt(n){return"nullValue"in n?0:"booleanValue"in n?1:"integerValue"in n||"doubleValue"in n?2:"timestampValue"in n?3:"stringValue"in n?5:"bytesValue"in n?6:"referenceValue"in n?7:"geoPointValue"in n?8:"arrayValue"in n?9:"mapValue"in n?Ys(n)?4:wy(n)?9007199254740991:Iy(n)?10:11:U()}function Ye(n,e){if(n===e)return!0;const t=Dt(n);if(t!==Dt(e))return!1;switch(t){case 0:case 9007199254740991:return!0;case 1:return n.booleanValue===e.booleanValue;case 4:return Tr(n).isEqual(Tr(e));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 a=kt(s.timestampValue),c=kt(i.timestampValue);return a.seconds===c.seconds&&a.nanos===c.nanos}(n,e);case 5:return n.stringValue===e.stringValue;case 6:return function(s,i){return Nt(s.bytesValue).isEqual(Nt(i.bytesValue))}(n,e);case 7:return n.referenceValue===e.referenceValue;case 8:return function(s,i){return ie(s.geoPointValue.latitude)===ie(i.geoPointValue.latitude)&&ie(s.geoPointValue.longitude)===ie(i.geoPointValue.longitude)}(n,e);case 2:return function(s,i){if("integerValue"in s&&"integerValue"in i)return ie(s.integerValue)===ie(i.integerValue);if("doubleValue"in s&&"doubleValue"in i){const a=ie(s.doubleValue),c=ie(i.doubleValue);return a===c?Ns(a)===Ns(c):isNaN(a)&&isNaN(c)}return!1}(n,e);case 9:return bn(n.arrayValue.values||[],e.arrayValue.values||[],Ye);case 10:case 11:return function(s,i){const a=s.mapValue.fields||{},c=i.mapValue.fields||{};if(mu(a)!==mu(c))return!1;for(const l in a)if(a.hasOwnProperty(l)&&(c[l]===void 0||!Ye(a[l],c[l])))return!1;return!0}(n,e);default:return U()}}function vr(n,e){return(n.values||[]).find(t=>Ye(t,e))!==void 0}function Pn(n,e){if(n===e)return 0;const t=Dt(n),r=Dt(e);if(t!==r)return H(t,r);switch(t){case 0:case 9007199254740991:return 0;case 1:return H(n.booleanValue,e.booleanValue);case 2:return function(i,a){const c=ie(i.integerValue||i.doubleValue),l=ie(a.integerValue||a.doubleValue);return c<l?-1:c>l?1:c===l?0:isNaN(c)?isNaN(l)?0:-1:1}(n,e);case 3:return _u(n.timestampValue,e.timestampValue);case 4:return _u(Tr(n),Tr(e));case 5:return oo(n.stringValue,e.stringValue);case 6:return function(i,a){const c=Nt(i),l=Nt(a);return c.compareTo(l)}(n.bytesValue,e.bytesValue);case 7:return function(i,a){const c=i.split("/"),l=a.split("/");for(let d=0;d<c.length&&d<l.length;d++){const f=H(c[d],l[d]);if(f!==0)return f}return H(c.length,l.length)}(n.referenceValue,e.referenceValue);case 8:return function(i,a){const c=H(ie(i.latitude),ie(a.latitude));return c!==0?c:H(ie(i.longitude),ie(a.longitude))}(n.geoPointValue,e.geoPointValue);case 9:return yu(n.arrayValue,e.arrayValue);case 10:return function(i,a){var c,l,d,f;const m=i.fields||{},E=a.fields||{},R=(c=m[Os])===null||c===void 0?void 0:c.arrayValue,C=(l=E[Os])===null||l===void 0?void 0:l.arrayValue,N=H(((d=R==null?void 0:R.values)===null||d===void 0?void 0:d.length)||0,((f=C==null?void 0:C.values)===null||f===void 0?void 0:f.length)||0);return N!==0?N:yu(R,C)}(n.mapValue,e.mapValue);case 11:return function(i,a){if(i===os.mapValue&&a===os.mapValue)return 0;if(i===os.mapValue)return 1;if(a===os.mapValue)return-1;const c=i.fields||{},l=Object.keys(c),d=a.fields||{},f=Object.keys(d);l.sort(),f.sort();for(let m=0;m<l.length&&m<f.length;++m){const E=oo(l[m],f[m]);if(E!==0)return E;const R=Pn(c[l[m]],d[f[m]]);if(R!==0)return R}return H(l.length,f.length)}(n.mapValue,e.mapValue);default:throw U()}}function _u(n,e){if(typeof n=="string"&&typeof e=="string"&&n.length===e.length)return H(n,e);const t=kt(n),r=kt(e),s=H(t.seconds,r.seconds);return s!==0?s:H(t.nanos,r.nanos)}function yu(n,e){const t=n.values||[],r=e.values||[];for(let s=0;s<t.length&&s<r.length;++s){const i=Pn(t[s],r[s]);if(i)return i}return H(t.length,r.length)}function Sn(n){return ao(n)}function ao(n){return"nullValue"in n?"null":"booleanValue"in n?""+n.booleanValue:"integerValue"in n?""+n.integerValue:"doubleValue"in n?""+n.doubleValue:"timestampValue"in n?function(t){const r=kt(t);return`time(${r.seconds},${r.nanos})`}(n.timestampValue):"stringValue"in n?n.stringValue:"bytesValue"in n?function(t){return Nt(t).toBase64()}(n.bytesValue):"referenceValue"in n?function(t){return L.fromName(t).toString()}(n.referenceValue):"geoPointValue"in n?function(t){return`geo(${t.latitude},${t.longitude})`}(n.geoPointValue):"arrayValue"in n?function(t){let r="[",s=!0;for(const i of t.values||[])s?s=!1:r+=",",r+=ao(i);return r+"]"}(n.arrayValue):"mapValue"in n?function(t){const r=Object.keys(t.fields||{}).sort();let s="{",i=!0;for(const a of r)i?i=!1:s+=",",s+=`${a}:${ao(t.fields[a])}`;return s+"}"}(n.mapValue):U()}function gs(n){switch(Dt(n)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:const e=Zs(n);return e?16+gs(e):16;case 5:return 2*n.stringValue.length;case 6:return Nt(n.bytesValue).approximateByteSize();case 7:return n.referenceValue.length;case 9:return function(r){return(r.values||[]).reduce((s,i)=>s+gs(i),0)}(n.arrayValue);case 10:case 11:return function(r){let s=0;return rn(r.fields,(i,a)=>{s+=i.length+gs(a)}),s}(n.mapValue);default:throw U()}}function Vs(n,e){return{referenceValue:`projects/${n.projectId}/databases/${n.database}/documents/${e.path.canonicalString()}`}}function co(n){return!!n&&"integerValue"in n}function Fo(n){return!!n&&"arrayValue"in n}function Tu(n){return!!n&&"nullValue"in n}function Eu(n){return!!n&&"doubleValue"in n&&isNaN(Number(n.doubleValue))}function _s(n){return!!n&&"mapValue"in n}function Iy(n){var e,t;return((t=(((e=n==null?void 0:n.mapValue)===null||e===void 0?void 0:e.fields)||{})[yh])===null||t===void 0?void 0:t.stringValue)===Th}function hr(n){if(n.geoPointValue)return{geoPointValue:Object.assign({},n.geoPointValue)};if(n.timestampValue&&typeof n.timestampValue=="object")return{timestampValue:Object.assign({},n.timestampValue)};if(n.mapValue){const e={mapValue:{fields:{}}};return rn(n.mapValue.fields,(t,r)=>e.mapValue.fields[t]=hr(r)),e}if(n.arrayValue){const e={arrayValue:{values:[]}};for(let t=0;t<(n.arrayValue.values||[]).length;++t)e.arrayValue.values[t]=hr(n.arrayValue.values[t]);return e}return Object.assign({},n)}function wy(n){return(((n.mapValue||{}).fields||{}).__type__||{}).stringValue===vy}/**
2080
+ * @license
2081
+ * Copyright 2017 Google LLC
2082
+ *
2083
+ * Licensed under the Apache License, Version 2.0 (the "License");
2084
+ * you may not use this file except in compliance with the License.
2085
+ * You may obtain a copy of the License at
2086
+ *
2087
+ * http://www.apache.org/licenses/LICENSE-2.0
2088
+ *
2089
+ * Unless required by applicable law or agreed to in writing, software
2090
+ * distributed under the License is distributed on an "AS IS" BASIS,
2091
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2092
+ * See the License for the specific language governing permissions and
2093
+ * limitations under the License.
2094
+ */class Ve{constructor(e){this.value=e}static empty(){return new Ve({mapValue:{}})}field(e){if(e.isEmpty())return this.value;{let t=this.value;for(let r=0;r<e.length-1;++r)if(t=(t.mapValue.fields||{})[e.get(r)],!_s(t))return null;return t=(t.mapValue.fields||{})[e.lastSegment()],t||null}}set(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=hr(t)}setAll(e){let t=pe.emptyPath(),r={},s=[];e.forEach((a,c)=>{if(!t.isImmediateParentOf(c)){const l=this.getFieldsMap(t);this.applyChanges(l,r,s),r={},s=[],t=c.popLast()}a?r[c.lastSegment()]=hr(a):s.push(c.lastSegment())});const i=this.getFieldsMap(t);this.applyChanges(i,r,s)}delete(e){const t=this.field(e.popLast());_s(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return Ye(this.value,e.value)}getFieldsMap(e){let t=this.value;t.mapValue.fields||(t.mapValue={fields:{}});for(let r=0;r<e.length;++r){let s=t.mapValue.fields[e.get(r)];_s(s)&&s.mapValue.fields||(s={mapValue:{fields:{}}},t.mapValue.fields[e.get(r)]=s),t=s}return t.mapValue.fields}applyChanges(e,t,r){rn(t,(s,i)=>e[s]=i);for(const s of r)delete e[s]}clone(){return new Ve(hr(this.value))}}function Eh(n){const e=[];return rn(n.fields,(t,r)=>{const s=new pe([t]);if(_s(r)){const i=Eh(r.mapValue).fields;if(i.length===0)e.push(s);else for(const a of i)e.push(s.child(a))}else e.push(s)}),new Be(e)}/**
2095
+ * @license
2096
+ * Copyright 2017 Google LLC
2097
+ *
2098
+ * Licensed under the Apache License, Version 2.0 (the "License");
2099
+ * you may not use this file except in compliance with the License.
2100
+ * You may obtain a copy of the License at
2101
+ *
2102
+ * http://www.apache.org/licenses/LICENSE-2.0
2103
+ *
2104
+ * Unless required by applicable law or agreed to in writing, software
2105
+ * distributed under the License is distributed on an "AS IS" BASIS,
2106
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2107
+ * See the License for the specific language governing permissions and
2108
+ * limitations under the License.
2109
+ */class Ie{constructor(e,t,r,s,i,a,c){this.key=e,this.documentType=t,this.version=r,this.readTime=s,this.createTime=i,this.data=a,this.documentState=c}static newInvalidDocument(e){return new Ie(e,0,B.min(),B.min(),B.min(),Ve.empty(),0)}static newFoundDocument(e,t,r,s){return new Ie(e,1,t,B.min(),r,s,0)}static newNoDocument(e,t){return new Ie(e,2,t,B.min(),B.min(),Ve.empty(),0)}static newUnknownDocument(e,t){return new Ie(e,3,t,B.min(),B.min(),Ve.empty(),2)}convertToFoundDocument(e,t){return!this.createTime.isEqual(B.min())||this.documentType!==2&&this.documentType!==0||(this.createTime=e),this.version=e,this.documentType=1,this.data=t,this.documentState=0,this}convertToNoDocument(e){return this.version=e,this.documentType=2,this.data=Ve.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=Ve.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=B.min(),this}setReadTime(e){return this.readTime=e,this}get hasLocalMutations(){return this.documentState===1}get hasCommittedMutations(){return this.documentState===2}get hasPendingWrites(){return this.hasLocalMutations||this.hasCommittedMutations}isValidDocument(){return this.documentType!==0}isFoundDocument(){return this.documentType===1}isNoDocument(){return this.documentType===2}isUnknownDocument(){return this.documentType===3}isEqual(e){return e instanceof Ie&&this.key.isEqual(e.key)&&this.version.isEqual(e.version)&&this.documentType===e.documentType&&this.documentState===e.documentState&&this.data.isEqual(e.data)}mutableCopy(){return new Ie(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}})`}}/**
2110
+ * @license
2111
+ * Copyright 2022 Google LLC
2112
+ *
2113
+ * Licensed under the Apache License, Version 2.0 (the "License");
2114
+ * you may not use this file except in compliance with the License.
2115
+ * You may obtain a copy of the License at
2116
+ *
2117
+ * http://www.apache.org/licenses/LICENSE-2.0
2118
+ *
2119
+ * Unless required by applicable law or agreed to in writing, software
2120
+ * distributed under the License is distributed on an "AS IS" BASIS,
2121
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2122
+ * See the License for the specific language governing permissions and
2123
+ * limitations under the License.
2124
+ */class Cn{constructor(e,t){this.position=e,this.inclusive=t}}function vu(n,e,t){let r=0;for(let s=0;s<n.position.length;s++){const i=e[s],a=n.position[s];if(i.field.isKeyField()?r=L.comparator(L.fromName(a.referenceValue),t.key):r=Pn(a,t.data.field(i.field)),i.dir==="desc"&&(r*=-1),r!==0)break}return r}function Iu(n,e){if(n===null)return e===null;if(e===null||n.inclusive!==e.inclusive||n.position.length!==e.position.length)return!1;for(let t=0;t<n.position.length;t++)if(!Ye(n.position[t],e.position[t]))return!1;return!0}/**
2125
+ * @license
2126
+ * Copyright 2022 Google LLC
2127
+ *
2128
+ * Licensed under the Apache License, Version 2.0 (the "License");
2129
+ * you may not use this file except in compliance with the License.
2130
+ * You may obtain a copy of the License at
2131
+ *
2132
+ * http://www.apache.org/licenses/LICENSE-2.0
2133
+ *
2134
+ * Unless required by applicable law or agreed to in writing, software
2135
+ * distributed under the License is distributed on an "AS IS" BASIS,
2136
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2137
+ * See the License for the specific language governing permissions and
2138
+ * limitations under the License.
2139
+ */class Ir{constructor(e,t="asc"){this.field=e,this.dir=t}}function Ay(n,e){return n.dir===e.dir&&n.field.isEqual(e.field)}/**
2140
+ * @license
2141
+ * Copyright 2022 Google LLC
2142
+ *
2143
+ * Licensed under the Apache License, Version 2.0 (the "License");
2144
+ * you may not use this file except in compliance with the License.
2145
+ * You may obtain a copy of the License at
2146
+ *
2147
+ * http://www.apache.org/licenses/LICENSE-2.0
2148
+ *
2149
+ * Unless required by applicable law or agreed to in writing, software
2150
+ * distributed under the License is distributed on an "AS IS" BASIS,
2151
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2152
+ * See the License for the specific language governing permissions and
2153
+ * limitations under the License.
2154
+ */class vh{}class ae extends vh{constructor(e,t,r){super(),this.field=e,this.op=t,this.value=r}static create(e,t,r){return e.isKeyField()?t==="in"||t==="not-in"?this.createKeyFieldInFilter(e,t,r):new by(e,t,r):t==="array-contains"?new Cy(e,r):t==="in"?new ky(e,r):t==="not-in"?new Ny(e,r):t==="array-contains-any"?new Dy(e,r):new ae(e,t,r)}static createKeyFieldInFilter(e,t,r){return t==="in"?new Py(e,r):new Sy(e,r)}matches(e){const t=e.data.field(this.field);return this.op==="!="?t!==null&&this.matchesComparison(Pn(t,this.value)):t!==null&&Dt(this.value)===Dt(t)&&this.matchesComparison(Pn(t,this.value))}matchesComparison(e){switch(this.op){case"<":return e<0;case"<=":return e<=0;case"==":return e===0;case"!=":return e!==0;case">":return e>0;case">=":return e>=0;default:return U()}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class je extends vh{constructor(e,t){super(),this.filters=e,this.op=t,this.ce=null}static create(e,t){return new je(e,t)}matches(e){return Ih(this)?this.filters.find(t=>!t.matches(e))===void 0:this.filters.find(t=>t.matches(e))!==void 0}getFlattenedFilters(){return this.ce!==null||(this.ce=this.filters.reduce((e,t)=>e.concat(t.getFlattenedFilters()),[])),this.ce}getFilters(){return Object.assign([],this.filters)}}function Ih(n){return n.op==="and"}function wh(n){return Ry(n)&&Ih(n)}function Ry(n){for(const e of n.filters)if(e instanceof je)return!1;return!0}function uo(n){if(n instanceof ae)return n.field.canonicalString()+n.op.toString()+Sn(n.value);if(wh(n))return n.filters.map(e=>uo(e)).join(",");{const e=n.filters.map(t=>uo(t)).join(",");return`${n.op}(${e})`}}function Ah(n,e){return n instanceof ae?function(r,s){return s instanceof ae&&r.op===s.op&&r.field.isEqual(s.field)&&Ye(r.value,s.value)}(n,e):n instanceof je?function(r,s){return s instanceof je&&r.op===s.op&&r.filters.length===s.filters.length?r.filters.reduce((i,a,c)=>i&&Ah(a,s.filters[c]),!0):!1}(n,e):void U()}function Rh(n){return n instanceof ae?function(t){return`${t.field.canonicalString()} ${t.op} ${Sn(t.value)}`}(n):n instanceof je?function(t){return t.op.toString()+" {"+t.getFilters().map(Rh).join(" ,")+"}"}(n):"Filter"}class by extends ae{constructor(e,t,r){super(e,t,r),this.key=L.fromName(r.referenceValue)}matches(e){const t=L.comparator(e.key,this.key);return this.matchesComparison(t)}}class Py extends ae{constructor(e,t){super(e,"in",t),this.keys=bh("in",t)}matches(e){return this.keys.some(t=>t.isEqual(e.key))}}class Sy extends ae{constructor(e,t){super(e,"not-in",t),this.keys=bh("not-in",t)}matches(e){return!this.keys.some(t=>t.isEqual(e.key))}}function bh(n,e){var t;return(((t=e.arrayValue)===null||t===void 0?void 0:t.values)||[]).map(r=>L.fromName(r.referenceValue))}class Cy extends ae{constructor(e,t){super(e,"array-contains",t)}matches(e){const t=e.data.field(this.field);return Fo(t)&&vr(t.arrayValue,this.value)}}class ky extends ae{constructor(e,t){super(e,"in",t)}matches(e){const t=e.data.field(this.field);return t!==null&&vr(this.value.arrayValue,t)}}class Ny extends ae{constructor(e,t){super(e,"not-in",t)}matches(e){if(vr(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const t=e.data.field(this.field);return t!==null&&!vr(this.value.arrayValue,t)}}class Dy extends ae{constructor(e,t){super(e,"array-contains-any",t)}matches(e){const t=e.data.field(this.field);return!(!Fo(t)||!t.arrayValue.values)&&t.arrayValue.values.some(r=>vr(this.value.arrayValue,r))}}/**
2155
+ * @license
2156
+ * Copyright 2019 Google LLC
2157
+ *
2158
+ * Licensed under the Apache License, Version 2.0 (the "License");
2159
+ * you may not use this file except in compliance with the License.
2160
+ * You may obtain a copy of the License at
2161
+ *
2162
+ * http://www.apache.org/licenses/LICENSE-2.0
2163
+ *
2164
+ * Unless required by applicable law or agreed to in writing, software
2165
+ * distributed under the License is distributed on an "AS IS" BASIS,
2166
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2167
+ * See the License for the specific language governing permissions and
2168
+ * limitations under the License.
2169
+ */class Oy{constructor(e,t=null,r=[],s=[],i=null,a=null,c=null){this.path=e,this.collectionGroup=t,this.orderBy=r,this.filters=s,this.limit=i,this.startAt=a,this.endAt=c,this.le=null}}function wu(n,e=null,t=[],r=[],s=null,i=null,a=null){return new Oy(n,e,t,r,s,i,a)}function Bo(n){const e=q(n);if(e.le===null){let t=e.path.canonicalString();e.collectionGroup!==null&&(t+="|cg:"+e.collectionGroup),t+="|f:",t+=e.filters.map(r=>uo(r)).join(","),t+="|ob:",t+=e.orderBy.map(r=>function(i){return i.field.canonicalString()+i.dir}(r)).join(","),Js(e.limit)||(t+="|l:",t+=e.limit),e.startAt&&(t+="|lb:",t+=e.startAt.inclusive?"b:":"a:",t+=e.startAt.position.map(r=>Sn(r)).join(",")),e.endAt&&(t+="|ub:",t+=e.endAt.inclusive?"a:":"b:",t+=e.endAt.position.map(r=>Sn(r)).join(",")),e.le=t}return e.le}function qo(n,e){if(n.limit!==e.limit||n.orderBy.length!==e.orderBy.length)return!1;for(let t=0;t<n.orderBy.length;t++)if(!Ay(n.orderBy[t],e.orderBy[t]))return!1;if(n.filters.length!==e.filters.length)return!1;for(let t=0;t<n.filters.length;t++)if(!Ah(n.filters[t],e.filters[t]))return!1;return n.collectionGroup===e.collectionGroup&&!!n.path.isEqual(e.path)&&!!Iu(n.startAt,e.startAt)&&Iu(n.endAt,e.endAt)}function lo(n){return L.isDocumentKey(n.path)&&n.collectionGroup===null&&n.filters.length===0}/**
2170
+ * @license
2171
+ * Copyright 2017 Google LLC
2172
+ *
2173
+ * Licensed under the Apache License, Version 2.0 (the "License");
2174
+ * you may not use this file except in compliance with the License.
2175
+ * You may obtain a copy of the License at
2176
+ *
2177
+ * http://www.apache.org/licenses/LICENSE-2.0
2178
+ *
2179
+ * Unless required by applicable law or agreed to in writing, software
2180
+ * distributed under the License is distributed on an "AS IS" BASIS,
2181
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2182
+ * See the License for the specific language governing permissions and
2183
+ * limitations under the License.
2184
+ */class Ut{constructor(e,t=null,r=[],s=[],i=null,a="F",c=null,l=null){this.path=e,this.collectionGroup=t,this.explicitOrderBy=r,this.filters=s,this.limit=i,this.limitType=a,this.startAt=c,this.endAt=l,this.he=null,this.Pe=null,this.Te=null,this.startAt,this.endAt}}function Vy(n,e,t,r,s,i,a,c){return new Ut(n,e,t,r,s,i,a,c)}function ei(n){return new Ut(n)}function Au(n){return n.filters.length===0&&n.limit===null&&n.startAt==null&&n.endAt==null&&(n.explicitOrderBy.length===0||n.explicitOrderBy.length===1&&n.explicitOrderBy[0].field.isKeyField())}function $o(n){return n.collectionGroup!==null}function vn(n){const e=q(n);if(e.he===null){e.he=[];const t=new Set;for(const i of e.explicitOrderBy)e.he.push(i),t.add(i.field.canonicalString());const r=e.explicitOrderBy.length>0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";(function(a){let c=new le(pe.comparator);return a.filters.forEach(l=>{l.getFlattenedFilters().forEach(d=>{d.isInequality()&&(c=c.add(d.field))})}),c})(e).forEach(i=>{t.has(i.canonicalString())||i.isKeyField()||e.he.push(new Ir(i,r))}),t.has(pe.keyField().canonicalString())||e.he.push(new Ir(pe.keyField(),r))}return e.he}function Qe(n){const e=q(n);return e.Pe||(e.Pe=Ly(e,vn(n))),e.Pe}function Ly(n,e){if(n.limitType==="F")return wu(n.path,n.collectionGroup,e,n.filters,n.limit,n.startAt,n.endAt);{e=e.map(s=>{const i=s.dir==="desc"?"asc":"desc";return new Ir(s.field,i)});const t=n.endAt?new Cn(n.endAt.position,n.endAt.inclusive):null,r=n.startAt?new Cn(n.startAt.position,n.startAt.inclusive):null;return wu(n.path,n.collectionGroup,e,n.filters,n.limit,t,r)}}function ho(n,e){const t=n.filters.concat([e]);return new Ut(n.path,n.collectionGroup,n.explicitOrderBy.slice(),t,n.limit,n.limitType,n.startAt,n.endAt)}function Ls(n,e,t){return new Ut(n.path,n.collectionGroup,n.explicitOrderBy.slice(),n.filters.slice(),e,t,n.startAt,n.endAt)}function ti(n,e){return qo(Qe(n),Qe(e))&&n.limitType===e.limitType}function Ph(n){return`${Bo(Qe(n))}|lt:${n.limitType}`}function mn(n){return`Query(target=${function(t){let r=t.path.canonicalString();return t.collectionGroup!==null&&(r+=" collectionGroup="+t.collectionGroup),t.filters.length>0&&(r+=`, filters: [${t.filters.map(s=>Rh(s)).join(", ")}]`),Js(t.limit)||(r+=", limit: "+t.limit),t.orderBy.length>0&&(r+=`, orderBy: [${t.orderBy.map(s=>function(a){return`${a.field.canonicalString()} (${a.dir})`}(s)).join(", ")}]`),t.startAt&&(r+=", startAt: ",r+=t.startAt.inclusive?"b:":"a:",r+=t.startAt.position.map(s=>Sn(s)).join(",")),t.endAt&&(r+=", endAt: ",r+=t.endAt.inclusive?"a:":"b:",r+=t.endAt.position.map(s=>Sn(s)).join(",")),`Target(${r})`}(Qe(n))}; limitType=${n.limitType})`}function ni(n,e){return e.isFoundDocument()&&function(r,s){const i=s.key.path;return r.collectionGroup!==null?s.key.hasCollectionId(r.collectionGroup)&&r.path.isPrefixOf(i):L.isDocumentKey(r.path)?r.path.isEqual(i):r.path.isImmediateParentOf(i)}(n,e)&&function(r,s){for(const i of vn(r))if(!i.field.isKeyField()&&s.data.field(i.field)===null)return!1;return!0}(n,e)&&function(r,s){for(const i of r.filters)if(!i.matches(s))return!1;return!0}(n,e)&&function(r,s){return!(r.startAt&&!function(a,c,l){const d=vu(a,c,l);return a.inclusive?d<=0:d<0}(r.startAt,vn(r),s)||r.endAt&&!function(a,c,l){const d=vu(a,c,l);return a.inclusive?d>=0:d>0}(r.endAt,vn(r),s))}(n,e)}function My(n){return n.collectionGroup||(n.path.length%2==1?n.path.lastSegment():n.path.get(n.path.length-2))}function Sh(n){return(e,t)=>{let r=!1;for(const s of vn(n)){const i=xy(s,e,t);if(i!==0)return i;r=r||s.field.isKeyField()}return 0}}function xy(n,e,t){const r=n.field.isKeyField()?L.comparator(e.key,t.key):function(i,a,c){const l=a.data.field(i),d=c.data.field(i);return l!==null&&d!==null?Pn(l,d):U()}(n.field,e,t);switch(n.dir){case"asc":return r;case"desc":return-1*r;default:return U()}}/**
2185
+ * @license
2186
+ * Copyright 2017 Google LLC
2187
+ *
2188
+ * Licensed under the Apache License, Version 2.0 (the "License");
2189
+ * you may not use this file except in compliance with the License.
2190
+ * You may obtain a copy of the License at
2191
+ *
2192
+ * http://www.apache.org/licenses/LICENSE-2.0
2193
+ *
2194
+ * Unless required by applicable law or agreed to in writing, software
2195
+ * distributed under the License is distributed on an "AS IS" BASIS,
2196
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2197
+ * See the License for the specific language governing permissions and
2198
+ * limitations under the License.
2199
+ */class sn{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.innerSize=0}get(e){const t=this.mapKeyFn(e),r=this.inner[t];if(r!==void 0){for(const[s,i]of r)if(this.equalsFn(s,e))return i}}has(e){return this.get(e)!==void 0}set(e,t){const r=this.mapKeyFn(e),s=this.inner[r];if(s===void 0)return this.inner[r]=[[e,t]],void this.innerSize++;for(let i=0;i<s.length;i++)if(this.equalsFn(s[i][0],e))return void(s[i]=[e,t]);s.push([e,t]),this.innerSize++}delete(e){const t=this.mapKeyFn(e),r=this.inner[t];if(r===void 0)return!1;for(let s=0;s<r.length;s++)if(this.equalsFn(r[s][0],e))return r.length===1?delete this.inner[t]:r.splice(s,1),this.innerSize--,!0;return!1}forEach(e){rn(this.inner,(t,r)=>{for(const[s,i]of r)e(s,i)})}isEmpty(){return dh(this.inner)}size(){return this.innerSize}}/**
2200
+ * @license
2201
+ * Copyright 2017 Google LLC
2202
+ *
2203
+ * Licensed under the Apache License, Version 2.0 (the "License");
2204
+ * you may not use this file except in compliance with the License.
2205
+ * You may obtain a copy of the License at
2206
+ *
2207
+ * http://www.apache.org/licenses/LICENSE-2.0
2208
+ *
2209
+ * Unless required by applicable law or agreed to in writing, software
2210
+ * distributed under the License is distributed on an "AS IS" BASIS,
2211
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2212
+ * See the License for the specific language governing permissions and
2213
+ * limitations under the License.
2214
+ */const Uy=new ne(L.comparator);function ft(){return Uy}const Ch=new ne(L.comparator);function ar(...n){let e=Ch;for(const t of n)e=e.insert(t.key,t);return e}function kh(n){let e=Ch;return n.forEach((t,r)=>e=e.insert(t,r.overlayedDocument)),e}function Wt(){return dr()}function Nh(){return dr()}function dr(){return new sn(n=>n.toString(),(n,e)=>n.isEqual(e))}const Fy=new ne(L.comparator),By=new le(L.comparator);function G(...n){let e=By;for(const t of n)e=e.add(t);return e}const qy=new le(H);function $y(){return qy}/**
2215
+ * @license
2216
+ * Copyright 2020 Google LLC
2217
+ *
2218
+ * Licensed under the Apache License, Version 2.0 (the "License");
2219
+ * you may not use this file except in compliance with the License.
2220
+ * You may obtain a copy of the License at
2221
+ *
2222
+ * http://www.apache.org/licenses/LICENSE-2.0
2223
+ *
2224
+ * Unless required by applicable law or agreed to in writing, software
2225
+ * distributed under the License is distributed on an "AS IS" BASIS,
2226
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2227
+ * See the License for the specific language governing permissions and
2228
+ * limitations under the License.
2229
+ */function jo(n,e){if(n.useProto3Json){if(isNaN(e))return{doubleValue:"NaN"};if(e===1/0)return{doubleValue:"Infinity"};if(e===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:Ns(e)?"-0":e}}function Dh(n){return{integerValue:""+n}}function jy(n,e){return gy(e)?Dh(e):jo(n,e)}/**
2230
+ * @license
2231
+ * Copyright 2018 Google LLC
2232
+ *
2233
+ * Licensed under the Apache License, Version 2.0 (the "License");
2234
+ * you may not use this file except in compliance with the License.
2235
+ * You may obtain a copy of the License at
2236
+ *
2237
+ * http://www.apache.org/licenses/LICENSE-2.0
2238
+ *
2239
+ * Unless required by applicable law or agreed to in writing, software
2240
+ * distributed under the License is distributed on an "AS IS" BASIS,
2241
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2242
+ * See the License for the specific language governing permissions and
2243
+ * limitations under the License.
2244
+ */class ri{constructor(){this._=void 0}}function Hy(n,e,t){return n instanceof Ms?function(s,i){const a={fields:{[mh]:{stringValue:ph},[_h]:{timestampValue:{seconds:s.seconds,nanos:s.nanoseconds}}}};return i&&Ys(i)&&(i=Zs(i)),i&&(a.fields[gh]=i),{mapValue:a}}(t,e):n instanceof wr?Vh(n,e):n instanceof Ar?Lh(n,e):function(s,i){const a=Oh(s,i),c=Ru(a)+Ru(s.Ie);return co(a)&&co(s.Ie)?Dh(c):jo(s.serializer,c)}(n,e)}function zy(n,e,t){return n instanceof wr?Vh(n,e):n instanceof Ar?Lh(n,e):t}function Oh(n,e){return n instanceof xs?function(r){return co(r)||function(i){return!!i&&"doubleValue"in i}(r)}(e)?e:{integerValue:0}:null}class Ms extends ri{}class wr extends ri{constructor(e){super(),this.elements=e}}function Vh(n,e){const t=Mh(e);for(const r of n.elements)t.some(s=>Ye(s,r))||t.push(r);return{arrayValue:{values:t}}}class Ar extends ri{constructor(e){super(),this.elements=e}}function Lh(n,e){let t=Mh(e);for(const r of n.elements)t=t.filter(s=>!Ye(s,r));return{arrayValue:{values:t}}}class xs extends ri{constructor(e,t){super(),this.serializer=e,this.Ie=t}}function Ru(n){return ie(n.integerValue||n.doubleValue)}function Mh(n){return Fo(n)&&n.arrayValue.values?n.arrayValue.values.slice():[]}function Gy(n,e){return n.field.isEqual(e.field)&&function(r,s){return r instanceof wr&&s instanceof wr||r instanceof Ar&&s instanceof Ar?bn(r.elements,s.elements,Ye):r instanceof xs&&s instanceof xs?Ye(r.Ie,s.Ie):r instanceof Ms&&s instanceof Ms}(n.transform,e.transform)}class Wy{constructor(e,t){this.version=e,this.transformResults=t}}class Xe{constructor(e,t){this.updateTime=e,this.exists=t}static none(){return new Xe}static exists(e){return new Xe(void 0,e)}static updateTime(e){return new Xe(e)}get isNone(){return this.updateTime===void 0&&this.exists===void 0}isEqual(e){return this.exists===e.exists&&(this.updateTime?!!e.updateTime&&this.updateTime.isEqual(e.updateTime):!e.updateTime)}}function ys(n,e){return n.updateTime!==void 0?e.isFoundDocument()&&e.version.isEqual(n.updateTime):n.exists===void 0||n.exists===e.isFoundDocument()}class si{}function xh(n,e){if(!n.hasLocalMutations||e&&e.fields.length===0)return null;if(e===null)return n.isNoDocument()?new Ho(n.key,Xe.none()):new Dr(n.key,n.data,Xe.none());{const t=n.data,r=Ve.empty();let s=new le(pe.comparator);for(let i of e.fields)if(!s.has(i)){let a=t.field(i);a===null&&i.length>1&&(i=i.popLast(),a=t.field(i)),a===null?r.delete(i):r.set(i,a),s=s.add(i)}return new on(n.key,r,new Be(s.toArray()),Xe.none())}}function Ky(n,e,t){n instanceof Dr?function(s,i,a){const c=s.value.clone(),l=Pu(s.fieldTransforms,i,a.transformResults);c.setAll(l),i.convertToFoundDocument(a.version,c).setHasCommittedMutations()}(n,e,t):n instanceof on?function(s,i,a){if(!ys(s.precondition,i))return void i.convertToUnknownDocument(a.version);const c=Pu(s.fieldTransforms,i,a.transformResults),l=i.data;l.setAll(Uh(s)),l.setAll(c),i.convertToFoundDocument(a.version,l).setHasCommittedMutations()}(n,e,t):function(s,i,a){i.convertToNoDocument(a.version).setHasCommittedMutations()}(0,e,t)}function fr(n,e,t,r){return n instanceof Dr?function(i,a,c,l){if(!ys(i.precondition,a))return c;const d=i.value.clone(),f=Su(i.fieldTransforms,l,a);return d.setAll(f),a.convertToFoundDocument(a.version,d).setHasLocalMutations(),null}(n,e,t,r):n instanceof on?function(i,a,c,l){if(!ys(i.precondition,a))return c;const d=Su(i.fieldTransforms,l,a),f=a.data;return f.setAll(Uh(i)),f.setAll(d),a.convertToFoundDocument(a.version,f).setHasLocalMutations(),c===null?null:c.unionWith(i.fieldMask.fields).unionWith(i.fieldTransforms.map(m=>m.field))}(n,e,t,r):function(i,a,c){return ys(i.precondition,a)?(a.convertToNoDocument(a.version).setHasLocalMutations(),null):c}(n,e,t)}function Qy(n,e){let t=null;for(const r of n.fieldTransforms){const s=e.data.field(r.field),i=Oh(r.transform,s||null);i!=null&&(t===null&&(t=Ve.empty()),t.set(r.field,i))}return t||null}function bu(n,e){return n.type===e.type&&!!n.key.isEqual(e.key)&&!!n.precondition.isEqual(e.precondition)&&!!function(r,s){return r===void 0&&s===void 0||!(!r||!s)&&bn(r,s,(i,a)=>Gy(i,a))}(n.fieldTransforms,e.fieldTransforms)&&(n.type===0?n.value.isEqual(e.value):n.type!==1||n.data.isEqual(e.data)&&n.fieldMask.isEqual(e.fieldMask))}class Dr extends si{constructor(e,t,r,s=[]){super(),this.key=e,this.value=t,this.precondition=r,this.fieldTransforms=s,this.type=0}getFieldMask(){return null}}class on extends si{constructor(e,t,r,s,i=[]){super(),this.key=e,this.data=t,this.fieldMask=r,this.precondition=s,this.fieldTransforms=i,this.type=1}getFieldMask(){return this.fieldMask}}function Uh(n){const e=new Map;return n.fieldMask.fields.forEach(t=>{if(!t.isEmpty()){const r=n.data.field(t);e.set(t,r)}}),e}function Pu(n,e,t){const r=new Map;Q(n.length===t.length);for(let s=0;s<t.length;s++){const i=n[s],a=i.transform,c=e.data.field(i.field);r.set(i.field,zy(a,c,t[s]))}return r}function Su(n,e,t){const r=new Map;for(const s of n){const i=s.transform,a=t.data.field(s.field);r.set(s.field,Hy(i,a,e))}return r}class Ho extends si{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}class Xy extends si{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}}/**
2245
+ * @license
2246
+ * Copyright 2017 Google LLC
2247
+ *
2248
+ * Licensed under the Apache License, Version 2.0 (the "License");
2249
+ * you may not use this file except in compliance with the License.
2250
+ * You may obtain a copy of the License at
2251
+ *
2252
+ * http://www.apache.org/licenses/LICENSE-2.0
2253
+ *
2254
+ * Unless required by applicable law or agreed to in writing, software
2255
+ * distributed under the License is distributed on an "AS IS" BASIS,
2256
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2257
+ * See the License for the specific language governing permissions and
2258
+ * limitations under the License.
2259
+ */class Jy{constructor(e,t,r,s){this.batchId=e,this.localWriteTime=t,this.baseMutations=r,this.mutations=s}applyToRemoteDocument(e,t){const r=t.mutationResults;for(let s=0;s<this.mutations.length;s++){const i=this.mutations[s];i.key.isEqual(e.key)&&Ky(i,e,r[s])}}applyToLocalView(e,t){for(const r of this.baseMutations)r.key.isEqual(e.key)&&(t=fr(r,e,t,this.localWriteTime));for(const r of this.mutations)r.key.isEqual(e.key)&&(t=fr(r,e,t,this.localWriteTime));return t}applyToLocalDocumentSet(e,t){const r=Nh();return this.mutations.forEach(s=>{const i=e.get(s.key),a=i.overlayedDocument;let c=this.applyToLocalView(a,i.mutatedFields);c=t.has(s.key)?null:c;const l=xh(a,c);l!==null&&r.set(s.key,l),a.isValidDocument()||a.convertToNoDocument(B.min())}),r}keys(){return this.mutations.reduce((e,t)=>e.add(t.key),G())}isEqual(e){return this.batchId===e.batchId&&bn(this.mutations,e.mutations,(t,r)=>bu(t,r))&&bn(this.baseMutations,e.baseMutations,(t,r)=>bu(t,r))}}class zo{constructor(e,t,r,s){this.batch=e,this.commitVersion=t,this.mutationResults=r,this.docVersions=s}static from(e,t,r){Q(e.mutations.length===r.length);let s=function(){return Fy}();const i=e.mutations;for(let a=0;a<i.length;a++)s=s.insert(i[a].key,r[a].version);return new zo(e,t,r,s)}}/**
2260
+ * @license
2261
+ * Copyright 2022 Google LLC
2262
+ *
2263
+ * Licensed under the Apache License, Version 2.0 (the "License");
2264
+ * you may not use this file except in compliance with the License.
2265
+ * You may obtain a copy of the License at
2266
+ *
2267
+ * http://www.apache.org/licenses/LICENSE-2.0
2268
+ *
2269
+ * Unless required by applicable law or agreed to in writing, software
2270
+ * distributed under the License is distributed on an "AS IS" BASIS,
2271
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2272
+ * See the License for the specific language governing permissions and
2273
+ * limitations under the License.
2274
+ */class Yy{constructor(e,t){this.largestBatchId=e,this.mutation=t}getKey(){return this.mutation.key}isEqual(e){return e!==null&&this.mutation===e.mutation}toString(){return`Overlay{
2275
+ largestBatchId: ${this.largestBatchId},
2276
+ mutation: ${this.mutation.toString()}
2277
+ }`}}/**
2278
+ * @license
2279
+ * Copyright 2017 Google LLC
2280
+ *
2281
+ * Licensed under the Apache License, Version 2.0 (the "License");
2282
+ * you may not use this file except in compliance with the License.
2283
+ * You may obtain a copy of the License at
2284
+ *
2285
+ * http://www.apache.org/licenses/LICENSE-2.0
2286
+ *
2287
+ * Unless required by applicable law or agreed to in writing, software
2288
+ * distributed under the License is distributed on an "AS IS" BASIS,
2289
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2290
+ * See the License for the specific language governing permissions and
2291
+ * limitations under the License.
2292
+ */class Zy{constructor(e,t){this.count=e,this.unchangedNames=t}}/**
2293
+ * @license
2294
+ * Copyright 2017 Google LLC
2295
+ *
2296
+ * Licensed under the Apache License, Version 2.0 (the "License");
2297
+ * you may not use this file except in compliance with the License.
2298
+ * You may obtain a copy of the License at
2299
+ *
2300
+ * http://www.apache.org/licenses/LICENSE-2.0
2301
+ *
2302
+ * Unless required by applicable law or agreed to in writing, software
2303
+ * distributed under the License is distributed on an "AS IS" BASIS,
2304
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2305
+ * See the License for the specific language governing permissions and
2306
+ * limitations under the License.
2307
+ */var oe,W;function eT(n){switch(n){case P.OK:return U();case P.CANCELLED:case P.UNKNOWN:case P.DEADLINE_EXCEEDED:case P.RESOURCE_EXHAUSTED:case P.INTERNAL:case P.UNAVAILABLE:case P.UNAUTHENTICATED:return!1;case P.INVALID_ARGUMENT:case P.NOT_FOUND:case P.ALREADY_EXISTS:case P.PERMISSION_DENIED:case P.FAILED_PRECONDITION:case P.ABORTED:case P.OUT_OF_RANGE:case P.UNIMPLEMENTED:case P.DATA_LOSS:return!0;default:return U()}}function Fh(n){if(n===void 0)return dt("GRPC error has no .code"),P.UNKNOWN;switch(n){case oe.OK:return P.OK;case oe.CANCELLED:return P.CANCELLED;case oe.UNKNOWN:return P.UNKNOWN;case oe.DEADLINE_EXCEEDED:return P.DEADLINE_EXCEEDED;case oe.RESOURCE_EXHAUSTED:return P.RESOURCE_EXHAUSTED;case oe.INTERNAL:return P.INTERNAL;case oe.UNAVAILABLE:return P.UNAVAILABLE;case oe.UNAUTHENTICATED:return P.UNAUTHENTICATED;case oe.INVALID_ARGUMENT:return P.INVALID_ARGUMENT;case oe.NOT_FOUND:return P.NOT_FOUND;case oe.ALREADY_EXISTS:return P.ALREADY_EXISTS;case oe.PERMISSION_DENIED:return P.PERMISSION_DENIED;case oe.FAILED_PRECONDITION:return P.FAILED_PRECONDITION;case oe.ABORTED:return P.ABORTED;case oe.OUT_OF_RANGE:return P.OUT_OF_RANGE;case oe.UNIMPLEMENTED:return P.UNIMPLEMENTED;case oe.DATA_LOSS:return P.DATA_LOSS;default:return U()}}(W=oe||(oe={}))[W.OK=0]="OK",W[W.CANCELLED=1]="CANCELLED",W[W.UNKNOWN=2]="UNKNOWN",W[W.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",W[W.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",W[W.NOT_FOUND=5]="NOT_FOUND",W[W.ALREADY_EXISTS=6]="ALREADY_EXISTS",W[W.PERMISSION_DENIED=7]="PERMISSION_DENIED",W[W.UNAUTHENTICATED=16]="UNAUTHENTICATED",W[W.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",W[W.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",W[W.ABORTED=10]="ABORTED",W[W.OUT_OF_RANGE=11]="OUT_OF_RANGE",W[W.UNIMPLEMENTED=12]="UNIMPLEMENTED",W[W.INTERNAL=13]="INTERNAL",W[W.UNAVAILABLE=14]="UNAVAILABLE",W[W.DATA_LOSS=15]="DATA_LOSS";/**
2308
+ * @license
2309
+ * Copyright 2022 Google LLC
2310
+ *
2311
+ * Licensed under the Apache License, Version 2.0 (the "License");
2312
+ * you may not use this file except in compliance with the License.
2313
+ * You may obtain a copy of the License at
2314
+ *
2315
+ * http://www.apache.org/licenses/LICENSE-2.0
2316
+ *
2317
+ * Unless required by applicable law or agreed to in writing, software
2318
+ * distributed under the License is distributed on an "AS IS" BASIS,
2319
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2320
+ * See the License for the specific language governing permissions and
2321
+ * limitations under the License.
2322
+ */const tT=new bt([4294967295,4294967295],0);function Cu(n){const e=uh().encode(n),t=new nh;return t.update(e),new Uint8Array(t.digest())}function ku(n){const e=new DataView(n.buffer),t=e.getUint32(0,!0),r=e.getUint32(4,!0),s=e.getUint32(8,!0),i=e.getUint32(12,!0);return[new bt([t,r],0),new bt([s,i],0)]}class Go{constructor(e,t,r){if(this.bitmap=e,this.padding=t,this.hashCount=r,t<0||t>=8)throw new cr(`Invalid padding: ${t}`);if(r<0)throw new cr(`Invalid hash count: ${r}`);if(e.length>0&&this.hashCount===0)throw new cr(`Invalid hash count: ${r}`);if(e.length===0&&t!==0)throw new cr(`Invalid padding when bitmap length is 0: ${t}`);this.Ee=8*e.length-t,this.de=bt.fromNumber(this.Ee)}Ae(e,t,r){let s=e.add(t.multiply(bt.fromNumber(r)));return s.compare(tT)===1&&(s=new bt([s.getBits(0),s.getBits(1)],0)),s.modulo(this.de).toNumber()}Re(e){return!!(this.bitmap[Math.floor(e/8)]&1<<e%8)}mightContain(e){if(this.Ee===0)return!1;const t=Cu(e),[r,s]=ku(t);for(let i=0;i<this.hashCount;i++){const a=this.Ae(r,s,i);if(!this.Re(a))return!1}return!0}static create(e,t,r){const s=e%8==0?0:8-e%8,i=new Uint8Array(Math.ceil(e/8)),a=new Go(i,s,t);return r.forEach(c=>a.insert(c)),a}insert(e){if(this.Ee===0)return;const t=Cu(e),[r,s]=ku(t);for(let i=0;i<this.hashCount;i++){const a=this.Ae(r,s,i);this.Ve(a)}}Ve(e){const t=Math.floor(e/8),r=e%8;this.bitmap[t]|=1<<r}}class cr extends Error{constructor(){super(...arguments),this.name="BloomFilterError"}}/**
2323
+ * @license
2324
+ * Copyright 2017 Google LLC
2325
+ *
2326
+ * Licensed under the Apache License, Version 2.0 (the "License");
2327
+ * you may not use this file except in compliance with the License.
2328
+ * You may obtain a copy of the License at
2329
+ *
2330
+ * http://www.apache.org/licenses/LICENSE-2.0
2331
+ *
2332
+ * Unless required by applicable law or agreed to in writing, software
2333
+ * distributed under the License is distributed on an "AS IS" BASIS,
2334
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2335
+ * See the License for the specific language governing permissions and
2336
+ * limitations under the License.
2337
+ */class ii{constructor(e,t,r,s,i){this.snapshotVersion=e,this.targetChanges=t,this.targetMismatches=r,this.documentUpdates=s,this.resolvedLimboDocuments=i}static createSynthesizedRemoteEventForCurrentChange(e,t,r){const s=new Map;return s.set(e,Or.createSynthesizedTargetChangeForCurrentChange(e,t,r)),new ii(B.min(),s,new ne(H),ft(),G())}}class Or{constructor(e,t,r,s,i){this.resumeToken=e,this.current=t,this.addedDocuments=r,this.modifiedDocuments=s,this.removedDocuments=i}static createSynthesizedTargetChangeForCurrentChange(e,t,r){return new Or(r,t,G(),G(),G())}}/**
2338
+ * @license
2339
+ * Copyright 2017 Google LLC
2340
+ *
2341
+ * Licensed under the Apache License, Version 2.0 (the "License");
2342
+ * you may not use this file except in compliance with the License.
2343
+ * You may obtain a copy of the License at
2344
+ *
2345
+ * http://www.apache.org/licenses/LICENSE-2.0
2346
+ *
2347
+ * Unless required by applicable law or agreed to in writing, software
2348
+ * distributed under the License is distributed on an "AS IS" BASIS,
2349
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2350
+ * See the License for the specific language governing permissions and
2351
+ * limitations under the License.
2352
+ */class Ts{constructor(e,t,r,s){this.me=e,this.removedTargetIds=t,this.key=r,this.fe=s}}class Bh{constructor(e,t){this.targetId=e,this.ge=t}}class qh{constructor(e,t,r=me.EMPTY_BYTE_STRING,s=null){this.state=e,this.targetIds=t,this.resumeToken=r,this.cause=s}}class Nu{constructor(){this.pe=0,this.ye=Du(),this.we=me.EMPTY_BYTE_STRING,this.Se=!1,this.be=!0}get current(){return this.Se}get resumeToken(){return this.we}get De(){return this.pe!==0}get ve(){return this.be}Ce(e){e.approximateByteSize()>0&&(this.be=!0,this.we=e)}Fe(){let e=G(),t=G(),r=G();return this.ye.forEach((s,i)=>{switch(i){case 0:e=e.add(s);break;case 2:t=t.add(s);break;case 1:r=r.add(s);break;default:U()}}),new Or(this.we,this.Se,e,t,r)}Me(){this.be=!1,this.ye=Du()}xe(e,t){this.be=!0,this.ye=this.ye.insert(e,t)}Oe(e){this.be=!0,this.ye=this.ye.remove(e)}Ne(){this.pe+=1}Be(){this.pe-=1,Q(this.pe>=0)}Le(){this.be=!0,this.Se=!0}}class nT{constructor(e){this.ke=e,this.qe=new Map,this.Qe=ft(),this.$e=as(),this.Ue=as(),this.Ke=new ne(H)}We(e){for(const t of e.me)e.fe&&e.fe.isFoundDocument()?this.Ge(t,e.fe):this.ze(t,e.key,e.fe);for(const t of e.removedTargetIds)this.ze(t,e.key,e.fe)}je(e){this.forEachTarget(e,t=>{const r=this.He(t);switch(e.state){case 0:this.Je(t)&&r.Ce(e.resumeToken);break;case 1:r.Be(),r.De||r.Me(),r.Ce(e.resumeToken);break;case 2:r.Be(),r.De||this.removeTarget(t);break;case 3:this.Je(t)&&(r.Le(),r.Ce(e.resumeToken));break;case 4:this.Je(t)&&(this.Ye(t),r.Ce(e.resumeToken));break;default:U()}})}forEachTarget(e,t){e.targetIds.length>0?e.targetIds.forEach(t):this.qe.forEach((r,s)=>{this.Je(s)&&t(s)})}Ze(e){const t=e.targetId,r=e.ge.count,s=this.Xe(t);if(s){const i=s.target;if(lo(i))if(r===0){const a=new L(i.path);this.ze(t,a,Ie.newNoDocument(a,B.min()))}else Q(r===1);else{const a=this.et(t);if(a!==r){const c=this.tt(e),l=c?this.nt(c,e,a):1;if(l!==0){this.Ye(t);const d=l===2?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch";this.Ke=this.Ke.insert(t,d)}}}}}tt(e){const t=e.ge.unchangedNames;if(!t||!t.bits)return null;const{bits:{bitmap:r="",padding:s=0},hashCount:i=0}=t;let a,c;try{a=Nt(r).toUint8Array()}catch(l){if(l instanceof fh)return Rn("Decoding the base64 bloom filter in existence filter failed ("+l.message+"); ignoring the bloom filter and falling back to full re-query."),null;throw l}try{c=new Go(a,s,i)}catch(l){return Rn(l instanceof cr?"BloomFilter error: ":"Applying bloom filter failed: ",l),null}return c.Ee===0?null:c}nt(e,t,r){return t.ge.count===r-this.st(e,t.targetId)?0:2}st(e,t){const r=this.ke.getRemoteKeysForTarget(t);let s=0;return r.forEach(i=>{const a=this.ke.it(),c=`projects/${a.projectId}/databases/${a.database}/documents/${i.path.canonicalString()}`;e.mightContain(c)||(this.ze(t,i,null),s++)}),s}ot(e){const t=new Map;this.qe.forEach((i,a)=>{const c=this.Xe(a);if(c){if(i.current&&lo(c.target)){const l=new L(c.target.path);this._t(l).has(a)||this.ut(a,l)||this.ze(a,l,Ie.newNoDocument(l,e))}i.ve&&(t.set(a,i.Fe()),i.Me())}});let r=G();this.Ue.forEach((i,a)=>{let c=!0;a.forEachWhile(l=>{const d=this.Xe(l);return!d||d.purpose==="TargetPurposeLimboResolution"||(c=!1,!1)}),c&&(r=r.add(i))}),this.Qe.forEach((i,a)=>a.setReadTime(e));const s=new ii(e,t,this.Ke,this.Qe,r);return this.Qe=ft(),this.$e=as(),this.Ue=as(),this.Ke=new ne(H),s}Ge(e,t){if(!this.Je(e))return;const r=this.ut(e,t.key)?2:0;this.He(e).xe(t.key,r),this.Qe=this.Qe.insert(t.key,t),this.$e=this.$e.insert(t.key,this._t(t.key).add(e)),this.Ue=this.Ue.insert(t.key,this.ct(t.key).add(e))}ze(e,t,r){if(!this.Je(e))return;const s=this.He(e);this.ut(e,t)?s.xe(t,1):s.Oe(t),this.Ue=this.Ue.insert(t,this.ct(t).delete(e)),this.Ue=this.Ue.insert(t,this.ct(t).add(e)),r&&(this.Qe=this.Qe.insert(t,r))}removeTarget(e){this.qe.delete(e)}et(e){const t=this.He(e).Fe();return this.ke.getRemoteKeysForTarget(e).size+t.addedDocuments.size-t.removedDocuments.size}Ne(e){this.He(e).Ne()}He(e){let t=this.qe.get(e);return t||(t=new Nu,this.qe.set(e,t)),t}ct(e){let t=this.Ue.get(e);return t||(t=new le(H),this.Ue=this.Ue.insert(e,t)),t}_t(e){let t=this.$e.get(e);return t||(t=new le(H),this.$e=this.$e.insert(e,t)),t}Je(e){const t=this.Xe(e)!==null;return t||V("WatchChangeAggregator","Detected inactive target",e),t}Xe(e){const t=this.qe.get(e);return t&&t.De?null:this.ke.lt(e)}Ye(e){this.qe.set(e,new Nu),this.ke.getRemoteKeysForTarget(e).forEach(t=>{this.ze(e,t,null)})}ut(e,t){return this.ke.getRemoteKeysForTarget(e).has(t)}}function as(){return new ne(L.comparator)}function Du(){return new ne(L.comparator)}const rT={asc:"ASCENDING",desc:"DESCENDING"},sT={"<":"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"},iT={and:"AND",or:"OR"};class oT{constructor(e,t){this.databaseId=e,this.useProto3Json=t}}function fo(n,e){return n.useProto3Json||Js(e)?e:{value:e}}function Us(n,e){return n.useProto3Json?`${new Date(1e3*e.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+e.nanoseconds).slice(-9)}Z`:{seconds:""+e.seconds,nanos:e.nanoseconds}}function $h(n,e){return n.useProto3Json?e.toBase64():e.toUint8Array()}function aT(n,e){return Us(n,e.toTimestamp())}function Je(n){return Q(!!n),B.fromTimestamp(function(t){const r=kt(t);return new ue(r.seconds,r.nanos)}(n))}function Wo(n,e){return po(n,e).canonicalString()}function po(n,e){const t=function(s){return new Y(["projects",s.projectId,"databases",s.database])}(n).child("documents");return e===void 0?t:t.child(e)}function jh(n){const e=Y.fromString(n);return Q(Kh(e)),e}function mo(n,e){return Wo(n.databaseId,e.path)}function zi(n,e){const t=jh(e);if(t.get(1)!==n.databaseId.projectId)throw new O(P.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+t.get(1)+" vs "+n.databaseId.projectId);if(t.get(3)!==n.databaseId.database)throw new O(P.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+t.get(3)+" vs "+n.databaseId.database);return new L(zh(t))}function Hh(n,e){return Wo(n.databaseId,e)}function cT(n){const e=jh(n);return e.length===4?Y.emptyPath():zh(e)}function go(n){return new Y(["projects",n.databaseId.projectId,"databases",n.databaseId.database]).canonicalString()}function zh(n){return Q(n.length>4&&n.get(4)==="documents"),n.popFirst(5)}function Ou(n,e,t){return{name:mo(n,e),fields:t.value.mapValue.fields}}function uT(n,e){let t;if("targetChange"in e){e.targetChange;const r=function(d){return d==="NO_CHANGE"?0:d==="ADD"?1:d==="REMOVE"?2:d==="CURRENT"?3:d==="RESET"?4:U()}(e.targetChange.targetChangeType||"NO_CHANGE"),s=e.targetChange.targetIds||[],i=function(d,f){return d.useProto3Json?(Q(f===void 0||typeof f=="string"),me.fromBase64String(f||"")):(Q(f===void 0||f instanceof Buffer||f instanceof Uint8Array),me.fromUint8Array(f||new Uint8Array))}(n,e.targetChange.resumeToken),a=e.targetChange.cause,c=a&&function(d){const f=d.code===void 0?P.UNKNOWN:Fh(d.code);return new O(f,d.message||"")}(a);t=new qh(r,s,i,c||null)}else if("documentChange"in e){e.documentChange;const r=e.documentChange;r.document,r.document.name,r.document.updateTime;const s=zi(n,r.document.name),i=Je(r.document.updateTime),a=r.document.createTime?Je(r.document.createTime):B.min(),c=new Ve({mapValue:{fields:r.document.fields}}),l=Ie.newFoundDocument(s,i,a,c),d=r.targetIds||[],f=r.removedTargetIds||[];t=new Ts(d,f,l.key,l)}else if("documentDelete"in e){e.documentDelete;const r=e.documentDelete;r.document;const s=zi(n,r.document),i=r.readTime?Je(r.readTime):B.min(),a=Ie.newNoDocument(s,i),c=r.removedTargetIds||[];t=new Ts([],c,a.key,a)}else if("documentRemove"in e){e.documentRemove;const r=e.documentRemove;r.document;const s=zi(n,r.document),i=r.removedTargetIds||[];t=new Ts([],i,s,null)}else{if(!("filter"in e))return U();{e.filter;const r=e.filter;r.targetId;const{count:s=0,unchangedNames:i}=r,a=new Zy(s,i),c=r.targetId;t=new Bh(c,a)}}return t}function lT(n,e){let t;if(e instanceof Dr)t={update:Ou(n,e.key,e.value)};else if(e instanceof Ho)t={delete:mo(n,e.key)};else if(e instanceof on)t={update:Ou(n,e.key,e.data),updateMask:TT(e.fieldMask)};else{if(!(e instanceof Xy))return U();t={verify:mo(n,e.key)}}return e.fieldTransforms.length>0&&(t.updateTransforms=e.fieldTransforms.map(r=>function(i,a){const c=a.transform;if(c instanceof Ms)return{fieldPath:a.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(c instanceof wr)return{fieldPath:a.field.canonicalString(),appendMissingElements:{values:c.elements}};if(c instanceof Ar)return{fieldPath:a.field.canonicalString(),removeAllFromArray:{values:c.elements}};if(c instanceof xs)return{fieldPath:a.field.canonicalString(),increment:c.Ie};throw U()}(0,r))),e.precondition.isNone||(t.currentDocument=function(s,i){return i.updateTime!==void 0?{updateTime:aT(s,i.updateTime)}:i.exists!==void 0?{exists:i.exists}:U()}(n,e.precondition)),t}function hT(n,e){return n&&n.length>0?(Q(e!==void 0),n.map(t=>function(s,i){let a=s.updateTime?Je(s.updateTime):Je(i);return a.isEqual(B.min())&&(a=Je(i)),new Wy(a,s.transformResults||[])}(t,e))):[]}function dT(n,e){return{documents:[Hh(n,e.path)]}}function fT(n,e){const t={structuredQuery:{}},r=e.path;let s;e.collectionGroup!==null?(s=r,t.structuredQuery.from=[{collectionId:e.collectionGroup,allDescendants:!0}]):(s=r.popLast(),t.structuredQuery.from=[{collectionId:r.lastSegment()}]),t.parent=Hh(n,s);const i=function(d){if(d.length!==0)return Wh(je.create(d,"and"))}(e.filters);i&&(t.structuredQuery.where=i);const a=function(d){if(d.length!==0)return d.map(f=>function(E){return{field:gn(E.field),direction:gT(E.dir)}}(f))}(e.orderBy);a&&(t.structuredQuery.orderBy=a);const c=fo(n,e.limit);return c!==null&&(t.structuredQuery.limit=c),e.startAt&&(t.structuredQuery.startAt=function(d){return{before:d.inclusive,values:d.position}}(e.startAt)),e.endAt&&(t.structuredQuery.endAt=function(d){return{before:!d.inclusive,values:d.position}}(e.endAt)),{ht:t,parent:s}}function pT(n){let e=cT(n.parent);const t=n.structuredQuery,r=t.from?t.from.length:0;let s=null;if(r>0){Q(r===1);const f=t.from[0];f.allDescendants?s=f.collectionId:e=e.child(f.collectionId)}let i=[];t.where&&(i=function(m){const E=Gh(m);return E instanceof je&&wh(E)?E.getFilters():[E]}(t.where));let a=[];t.orderBy&&(a=function(m){return m.map(E=>function(C){return new Ir(_n(C.field),function(k){switch(k){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(C.direction))}(E))}(t.orderBy));let c=null;t.limit&&(c=function(m){let E;return E=typeof m=="object"?m.value:m,Js(E)?null:E}(t.limit));let l=null;t.startAt&&(l=function(m){const E=!!m.before,R=m.values||[];return new Cn(R,E)}(t.startAt));let d=null;return t.endAt&&(d=function(m){const E=!m.before,R=m.values||[];return new Cn(R,E)}(t.endAt)),Vy(e,s,a,i,c,"F",l,d)}function mT(n,e){const t=function(s){switch(s){case"TargetPurposeListen":return null;case"TargetPurposeExistenceFilterMismatch":return"existence-filter-mismatch";case"TargetPurposeExistenceFilterMismatchBloom":return"existence-filter-mismatch-bloom";case"TargetPurposeLimboResolution":return"limbo-document";default:return U()}}(e.purpose);return t==null?null:{"goog-listen-tags":t}}function Gh(n){return n.unaryFilter!==void 0?function(t){switch(t.unaryFilter.op){case"IS_NAN":const r=_n(t.unaryFilter.field);return ae.create(r,"==",{doubleValue:NaN});case"IS_NULL":const s=_n(t.unaryFilter.field);return ae.create(s,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":const i=_n(t.unaryFilter.field);return ae.create(i,"!=",{doubleValue:NaN});case"IS_NOT_NULL":const a=_n(t.unaryFilter.field);return ae.create(a,"!=",{nullValue:"NULL_VALUE"});default:return U()}}(n):n.fieldFilter!==void 0?function(t){return ae.create(_n(t.fieldFilter.field),function(s){switch(s){case"EQUAL":return"==";case"NOT_EQUAL":return"!=";case"GREATER_THAN":return">";case"GREATER_THAN_OR_EQUAL":return">=";case"LESS_THAN":return"<";case"LESS_THAN_OR_EQUAL":return"<=";case"ARRAY_CONTAINS":return"array-contains";case"IN":return"in";case"NOT_IN":return"not-in";case"ARRAY_CONTAINS_ANY":return"array-contains-any";default:return U()}}(t.fieldFilter.op),t.fieldFilter.value)}(n):n.compositeFilter!==void 0?function(t){return je.create(t.compositeFilter.filters.map(r=>Gh(r)),function(s){switch(s){case"AND":return"and";case"OR":return"or";default:return U()}}(t.compositeFilter.op))}(n):U()}function gT(n){return rT[n]}function _T(n){return sT[n]}function yT(n){return iT[n]}function gn(n){return{fieldPath:n.canonicalString()}}function _n(n){return pe.fromServerFormat(n.fieldPath)}function Wh(n){return n instanceof ae?function(t){if(t.op==="=="){if(Eu(t.value))return{unaryFilter:{field:gn(t.field),op:"IS_NAN"}};if(Tu(t.value))return{unaryFilter:{field:gn(t.field),op:"IS_NULL"}}}else if(t.op==="!="){if(Eu(t.value))return{unaryFilter:{field:gn(t.field),op:"IS_NOT_NAN"}};if(Tu(t.value))return{unaryFilter:{field:gn(t.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:gn(t.field),op:_T(t.op),value:t.value}}}(n):n instanceof je?function(t){const r=t.getFilters().map(s=>Wh(s));return r.length===1?r[0]:{compositeFilter:{op:yT(t.op),filters:r}}}(n):U()}function TT(n){const e=[];return n.fields.forEach(t=>e.push(t.canonicalString())),{fieldPaths:e}}function Kh(n){return n.length>=4&&n.get(0)==="projects"&&n.get(2)==="databases"}/**
2353
+ * @license
2354
+ * Copyright 2017 Google LLC
2355
+ *
2356
+ * Licensed under the Apache License, Version 2.0 (the "License");
2357
+ * you may not use this file except in compliance with the License.
2358
+ * You may obtain a copy of the License at
2359
+ *
2360
+ * http://www.apache.org/licenses/LICENSE-2.0
2361
+ *
2362
+ * Unless required by applicable law or agreed to in writing, software
2363
+ * distributed under the License is distributed on an "AS IS" BASIS,
2364
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2365
+ * See the License for the specific language governing permissions and
2366
+ * limitations under the License.
2367
+ */class At{constructor(e,t,r,s,i=B.min(),a=B.min(),c=me.EMPTY_BYTE_STRING,l=null){this.target=e,this.targetId=t,this.purpose=r,this.sequenceNumber=s,this.snapshotVersion=i,this.lastLimboFreeSnapshotVersion=a,this.resumeToken=c,this.expectedCount=l}withSequenceNumber(e){return new At(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(e,t){return new At(this.target,this.targetId,this.purpose,this.sequenceNumber,t,this.lastLimboFreeSnapshotVersion,e,null)}withExpectedCount(e){return new At(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,e)}withLastLimboFreeSnapshotVersion(e){return new At(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken,this.expectedCount)}}/**
2368
+ * @license
2369
+ * Copyright 2017 Google LLC
2370
+ *
2371
+ * Licensed under the Apache License, Version 2.0 (the "License");
2372
+ * you may not use this file except in compliance with the License.
2373
+ * You may obtain a copy of the License at
2374
+ *
2375
+ * http://www.apache.org/licenses/LICENSE-2.0
2376
+ *
2377
+ * Unless required by applicable law or agreed to in writing, software
2378
+ * distributed under the License is distributed on an "AS IS" BASIS,
2379
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2380
+ * See the License for the specific language governing permissions and
2381
+ * limitations under the License.
2382
+ */class ET{constructor(e){this.Tt=e}}function vT(n){const e=pT({parent:n.parent,structuredQuery:n.structuredQuery});return n.limitType==="LAST"?Ls(e,e.limit,"L"):e}/**
2383
+ * @license
2384
+ * Copyright 2019 Google LLC
2385
+ *
2386
+ * Licensed under the Apache License, Version 2.0 (the "License");
2387
+ * you may not use this file except in compliance with the License.
2388
+ * You may obtain a copy of the License at
2389
+ *
2390
+ * http://www.apache.org/licenses/LICENSE-2.0
2391
+ *
2392
+ * Unless required by applicable law or agreed to in writing, software
2393
+ * distributed under the License is distributed on an "AS IS" BASIS,
2394
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2395
+ * See the License for the specific language governing permissions and
2396
+ * limitations under the License.
2397
+ */class IT{constructor(){this.Tn=new wT}addToCollectionParentIndex(e,t){return this.Tn.add(t),S.resolve()}getCollectionParents(e,t){return S.resolve(this.Tn.getEntries(t))}addFieldIndex(e,t){return S.resolve()}deleteFieldIndex(e,t){return S.resolve()}deleteAllFieldIndexes(e){return S.resolve()}createTargetIndexes(e,t){return S.resolve()}getDocumentsMatchingTarget(e,t){return S.resolve(null)}getIndexType(e,t){return S.resolve(0)}getFieldIndexes(e,t){return S.resolve([])}getNextCollectionGroupToUpdate(e){return S.resolve(null)}getMinOffset(e,t){return S.resolve(Ct.min())}getMinOffsetFromCollectionGroup(e,t){return S.resolve(Ct.min())}updateCollectionGroup(e,t,r){return S.resolve()}updateIndexEntries(e,t){return S.resolve()}}class wT{constructor(){this.index={}}add(e){const t=e.lastSegment(),r=e.popLast(),s=this.index[t]||new le(Y.comparator),i=!s.has(r);return this.index[t]=s.add(r),i}has(e){const t=e.lastSegment(),r=e.popLast(),s=this.index[t];return s&&s.has(r)}getEntries(e){return(this.index[e]||new le(Y.comparator)).toArray()}}/**
2398
+ * @license
2399
+ * Copyright 2018 Google LLC
2400
+ *
2401
+ * Licensed under the Apache License, Version 2.0 (the "License");
2402
+ * you may not use this file except in compliance with the License.
2403
+ * You may obtain a copy of the License at
2404
+ *
2405
+ * http://www.apache.org/licenses/LICENSE-2.0
2406
+ *
2407
+ * Unless required by applicable law or agreed to in writing, software
2408
+ * distributed under the License is distributed on an "AS IS" BASIS,
2409
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2410
+ * See the License for the specific language governing permissions and
2411
+ * limitations under the License.
2412
+ */const Vu={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0},Qh=41943040;class Ce{static withCacheSize(e){return new Ce(e,Ce.DEFAULT_COLLECTION_PERCENTILE,Ce.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}constructor(e,t,r){this.cacheSizeCollectionThreshold=e,this.percentileToCollect=t,this.maximumSequenceNumbersToCollect=r}}/**
2413
+ * @license
2414
+ * Copyright 2017 Google LLC
2415
+ *
2416
+ * Licensed under the Apache License, Version 2.0 (the "License");
2417
+ * you may not use this file except in compliance with the License.
2418
+ * You may obtain a copy of the License at
2419
+ *
2420
+ * http://www.apache.org/licenses/LICENSE-2.0
2421
+ *
2422
+ * Unless required by applicable law or agreed to in writing, software
2423
+ * distributed under the License is distributed on an "AS IS" BASIS,
2424
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2425
+ * See the License for the specific language governing permissions and
2426
+ * limitations under the License.
2427
+ */Ce.DEFAULT_COLLECTION_PERCENTILE=10,Ce.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,Ce.DEFAULT=new Ce(Qh,Ce.DEFAULT_COLLECTION_PERCENTILE,Ce.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),Ce.DISABLED=new Ce(-1,0,0);/**
2428
+ * @license
2429
+ * Copyright 2017 Google LLC
2430
+ *
2431
+ * Licensed under the Apache License, Version 2.0 (the "License");
2432
+ * you may not use this file except in compliance with the License.
2433
+ * You may obtain a copy of the License at
2434
+ *
2435
+ * http://www.apache.org/licenses/LICENSE-2.0
2436
+ *
2437
+ * Unless required by applicable law or agreed to in writing, software
2438
+ * distributed under the License is distributed on an "AS IS" BASIS,
2439
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2440
+ * See the License for the specific language governing permissions and
2441
+ * limitations under the License.
2442
+ */class kn{constructor(e){this.$n=e}next(){return this.$n+=2,this.$n}static Un(){return new kn(0)}static Kn(){return new kn(-1)}}/**
2443
+ * @license
2444
+ * Copyright 2020 Google LLC
2445
+ *
2446
+ * Licensed under the Apache License, Version 2.0 (the "License");
2447
+ * you may not use this file except in compliance with the License.
2448
+ * You may obtain a copy of the License at
2449
+ *
2450
+ * http://www.apache.org/licenses/LICENSE-2.0
2451
+ *
2452
+ * Unless required by applicable law or agreed to in writing, software
2453
+ * distributed under the License is distributed on an "AS IS" BASIS,
2454
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2455
+ * See the License for the specific language governing permissions and
2456
+ * limitations under the License.
2457
+ */const Lu="LruGarbageCollector",AT=1048576;function Mu([n,e],[t,r]){const s=H(n,t);return s===0?H(e,r):s}class RT{constructor(e){this.Hn=e,this.buffer=new le(Mu),this.Jn=0}Yn(){return++this.Jn}Zn(e){const t=[e,this.Yn()];if(this.buffer.size<this.Hn)this.buffer=this.buffer.add(t);else{const r=this.buffer.last();Mu(t,r)<0&&(this.buffer=this.buffer.delete(r).add(t))}}get maxValue(){return this.buffer.last()[0]}}class bT{constructor(e,t,r){this.garbageCollector=e,this.asyncQueue=t,this.localStore=r,this.Xn=null}start(){this.garbageCollector.params.cacheSizeCollectionThreshold!==-1&&this.er(6e4)}stop(){this.Xn&&(this.Xn.cancel(),this.Xn=null)}get started(){return this.Xn!==null}er(e){V(Lu,`Garbage collection scheduled in ${e}ms`),this.Xn=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",e,async()=>{this.Xn=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(t){Mn(t)?V(Lu,"Ignoring IndexedDB error during garbage collection: ",t):await Ln(t)}await this.er(3e5)})}}class PT{constructor(e,t){this.tr=e,this.params=t}calculateTargetCount(e,t){return this.tr.nr(e).next(r=>Math.floor(t/100*r))}nthSequenceNumber(e,t){if(t===0)return S.resolve(Xs.ae);const r=new RT(t);return this.tr.forEachTarget(e,s=>r.Zn(s.sequenceNumber)).next(()=>this.tr.rr(e,s=>r.Zn(s))).next(()=>r.maxValue)}removeTargets(e,t,r){return this.tr.removeTargets(e,t,r)}removeOrphanedDocuments(e,t){return this.tr.removeOrphanedDocuments(e,t)}collect(e,t){return this.params.cacheSizeCollectionThreshold===-1?(V("LruGarbageCollector","Garbage collection skipped; disabled"),S.resolve(Vu)):this.getCacheSize(e).next(r=>r<this.params.cacheSizeCollectionThreshold?(V("LruGarbageCollector",`Garbage collection skipped; Cache size ${r} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),Vu):this.ir(e,t))}getCacheSize(e){return this.tr.getCacheSize(e)}ir(e,t){let r,s,i,a,c,l,d;const f=Date.now();return this.calculateTargetCount(e,this.params.percentileToCollect).next(m=>(m>this.params.maximumSequenceNumbersToCollect?(V("LruGarbageCollector",`Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${m}`),s=this.params.maximumSequenceNumbersToCollect):s=m,a=Date.now(),this.nthSequenceNumber(e,s))).next(m=>(r=m,c=Date.now(),this.removeTargets(e,r,t))).next(m=>(i=m,l=Date.now(),this.removeOrphanedDocuments(e,r))).next(m=>(d=Date.now(),pn()<=z.DEBUG&&V("LruGarbageCollector",`LRU Garbage Collection
2458
+ Counted targets in ${a-f}ms
2459
+ Determined least recently used ${s} in `+(c-a)+`ms
2460
+ Removed ${i} targets in `+(l-c)+`ms
2461
+ Removed ${m} documents in `+(d-l)+`ms
2462
+ Total Duration: ${d-f}ms`),S.resolve({didRun:!0,sequenceNumbersCollected:s,targetsRemoved:i,documentsRemoved:m})))}}function ST(n,e){return new PT(n,e)}/**
2463
+ * @license
2464
+ * Copyright 2017 Google LLC
2465
+ *
2466
+ * Licensed under the Apache License, Version 2.0 (the "License");
2467
+ * you may not use this file except in compliance with the License.
2468
+ * You may obtain a copy of the License at
2469
+ *
2470
+ * http://www.apache.org/licenses/LICENSE-2.0
2471
+ *
2472
+ * Unless required by applicable law or agreed to in writing, software
2473
+ * distributed under the License is distributed on an "AS IS" BASIS,
2474
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2475
+ * See the License for the specific language governing permissions and
2476
+ * limitations under the License.
2477
+ */class CT{constructor(){this.changes=new sn(e=>e.toString(),(e,t)=>e.isEqual(t)),this.changesApplied=!1}addEntry(e){this.assertNotApplied(),this.changes.set(e.key,e)}removeEntry(e,t){this.assertNotApplied(),this.changes.set(e,Ie.newInvalidDocument(e).setReadTime(t))}getEntry(e,t){this.assertNotApplied();const r=this.changes.get(t);return r!==void 0?S.resolve(r):this.getFromCache(e,t)}getEntries(e,t){return this.getAllFromCache(e,t)}apply(e){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(e)}assertNotApplied(){}}/**
2478
+ * @license
2479
+ * Copyright 2017 Google LLC
2480
+ *
2481
+ * Licensed under the Apache License, Version 2.0 (the "License");
2482
+ * you may not use this file except in compliance with the License.
2483
+ * You may obtain a copy of the License at
2484
+ *
2485
+ * http://www.apache.org/licenses/LICENSE-2.0
2486
+ *
2487
+ * Unless required by applicable law or agreed to in writing, software
2488
+ * distributed under the License is distributed on an "AS IS" BASIS,
2489
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2490
+ * See the License for the specific language governing permissions and
2491
+ * limitations under the License.
2492
+ *//**
2493
+ * @license
2494
+ * Copyright 2022 Google LLC
2495
+ *
2496
+ * Licensed under the Apache License, Version 2.0 (the "License");
2497
+ * you may not use this file except in compliance with the License.
2498
+ * You may obtain a copy of the License at
2499
+ *
2500
+ * http://www.apache.org/licenses/LICENSE-2.0
2501
+ *
2502
+ * Unless required by applicable law or agreed to in writing, software
2503
+ * distributed under the License is distributed on an "AS IS" BASIS,
2504
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2505
+ * See the License for the specific language governing permissions and
2506
+ * limitations under the License.
2507
+ */class kT{constructor(e,t){this.overlayedDocument=e,this.mutatedFields=t}}/**
2508
+ * @license
2509
+ * Copyright 2017 Google LLC
2510
+ *
2511
+ * Licensed under the Apache License, Version 2.0 (the "License");
2512
+ * you may not use this file except in compliance with the License.
2513
+ * You may obtain a copy of the License at
2514
+ *
2515
+ * http://www.apache.org/licenses/LICENSE-2.0
2516
+ *
2517
+ * Unless required by applicable law or agreed to in writing, software
2518
+ * distributed under the License is distributed on an "AS IS" BASIS,
2519
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2520
+ * See the License for the specific language governing permissions and
2521
+ * limitations under the License.
2522
+ */class NT{constructor(e,t,r,s){this.remoteDocumentCache=e,this.mutationQueue=t,this.documentOverlayCache=r,this.indexManager=s}getDocument(e,t){let r=null;return this.documentOverlayCache.getOverlay(e,t).next(s=>(r=s,this.remoteDocumentCache.getEntry(e,t))).next(s=>(r!==null&&fr(r.mutation,s,Be.empty(),ue.now()),s))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next(r=>this.getLocalViewOfDocuments(e,r,G()).next(()=>r))}getLocalViewOfDocuments(e,t,r=G()){const s=Wt();return this.populateOverlays(e,s,t).next(()=>this.computeViews(e,t,s,r).next(i=>{let a=ar();return i.forEach((c,l)=>{a=a.insert(c,l.overlayedDocument)}),a}))}getOverlayedDocuments(e,t){const r=Wt();return this.populateOverlays(e,r,t).next(()=>this.computeViews(e,t,r,G()))}populateOverlays(e,t,r){const s=[];return r.forEach(i=>{t.has(i)||s.push(i)}),this.documentOverlayCache.getOverlays(e,s).next(i=>{i.forEach((a,c)=>{t.set(a,c)})})}computeViews(e,t,r,s){let i=ft();const a=dr(),c=function(){return dr()}();return t.forEach((l,d)=>{const f=r.get(d.key);s.has(d.key)&&(f===void 0||f.mutation instanceof on)?i=i.insert(d.key,d):f!==void 0?(a.set(d.key,f.mutation.getFieldMask()),fr(f.mutation,d,f.mutation.getFieldMask(),ue.now())):a.set(d.key,Be.empty())}),this.recalculateAndSaveOverlays(e,i).next(l=>(l.forEach((d,f)=>a.set(d,f)),t.forEach((d,f)=>{var m;return c.set(d,new kT(f,(m=a.get(d))!==null&&m!==void 0?m:null))}),c))}recalculateAndSaveOverlays(e,t){const r=dr();let s=new ne((a,c)=>a-c),i=G();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,t).next(a=>{for(const c of a)c.keys().forEach(l=>{const d=t.get(l);if(d===null)return;let f=r.get(l)||Be.empty();f=c.applyToLocalView(d,f),r.set(l,f);const m=(s.get(c.batchId)||G()).add(l);s=s.insert(c.batchId,m)})}).next(()=>{const a=[],c=s.getReverseIterator();for(;c.hasNext();){const l=c.getNext(),d=l.key,f=l.value,m=Nh();f.forEach(E=>{if(!i.has(E)){const R=xh(t.get(E),r.get(E));R!==null&&m.set(E,R),i=i.add(E)}}),a.push(this.documentOverlayCache.saveOverlays(e,d,m))}return S.waitFor(a)}).next(()=>r)}recalculateAndSaveOverlaysForDocumentKeys(e,t){return this.remoteDocumentCache.getEntries(e,t).next(r=>this.recalculateAndSaveOverlays(e,r))}getDocumentsMatchingQuery(e,t,r,s){return function(a){return L.isDocumentKey(a.path)&&a.collectionGroup===null&&a.filters.length===0}(t)?this.getDocumentsMatchingDocumentQuery(e,t.path):$o(t)?this.getDocumentsMatchingCollectionGroupQuery(e,t,r,s):this.getDocumentsMatchingCollectionQuery(e,t,r,s)}getNextDocuments(e,t,r,s){return this.remoteDocumentCache.getAllFromCollectionGroup(e,t,r,s).next(i=>{const a=s-i.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(e,t,r.largestBatchId,s-i.size):S.resolve(Wt());let c=yr,l=i;return a.next(d=>S.forEach(d,(f,m)=>(c<m.largestBatchId&&(c=m.largestBatchId),i.get(f)?S.resolve():this.remoteDocumentCache.getEntry(e,f).next(E=>{l=l.insert(f,E)}))).next(()=>this.populateOverlays(e,d,i)).next(()=>this.computeViews(e,l,d,G())).next(f=>({batchId:c,changes:kh(f)})))})}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new L(t)).next(r=>{let s=ar();return r.isFoundDocument()&&(s=s.insert(r.key,r)),s})}getDocumentsMatchingCollectionGroupQuery(e,t,r,s){const i=t.collectionGroup;let a=ar();return this.indexManager.getCollectionParents(e,i).next(c=>S.forEach(c,l=>{const d=function(m,E){return new Ut(E,null,m.explicitOrderBy.slice(),m.filters.slice(),m.limit,m.limitType,m.startAt,m.endAt)}(t,l.child(i));return this.getDocumentsMatchingCollectionQuery(e,d,r,s).next(f=>{f.forEach((m,E)=>{a=a.insert(m,E)})})}).next(()=>a))}getDocumentsMatchingCollectionQuery(e,t,r,s){let i;return this.documentOverlayCache.getOverlaysForCollection(e,t.path,r.largestBatchId).next(a=>(i=a,this.remoteDocumentCache.getDocumentsMatchingQuery(e,t,r,i,s))).next(a=>{i.forEach((l,d)=>{const f=d.getKey();a.get(f)===null&&(a=a.insert(f,Ie.newInvalidDocument(f)))});let c=ar();return a.forEach((l,d)=>{const f=i.get(l);f!==void 0&&fr(f.mutation,d,Be.empty(),ue.now()),ni(t,d)&&(c=c.insert(l,d))}),c})}}/**
2523
+ * @license
2524
+ * Copyright 2020 Google LLC
2525
+ *
2526
+ * Licensed under the Apache License, Version 2.0 (the "License");
2527
+ * you may not use this file except in compliance with the License.
2528
+ * You may obtain a copy of the License at
2529
+ *
2530
+ * http://www.apache.org/licenses/LICENSE-2.0
2531
+ *
2532
+ * Unless required by applicable law or agreed to in writing, software
2533
+ * distributed under the License is distributed on an "AS IS" BASIS,
2534
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2535
+ * See the License for the specific language governing permissions and
2536
+ * limitations under the License.
2537
+ */class DT{constructor(e){this.serializer=e,this.dr=new Map,this.Ar=new Map}getBundleMetadata(e,t){return S.resolve(this.dr.get(t))}saveBundleMetadata(e,t){return this.dr.set(t.id,function(s){return{id:s.id,version:s.version,createTime:Je(s.createTime)}}(t)),S.resolve()}getNamedQuery(e,t){return S.resolve(this.Ar.get(t))}saveNamedQuery(e,t){return this.Ar.set(t.name,function(s){return{name:s.name,query:vT(s.bundledQuery),readTime:Je(s.readTime)}}(t)),S.resolve()}}/**
2538
+ * @license
2539
+ * Copyright 2022 Google LLC
2540
+ *
2541
+ * Licensed under the Apache License, Version 2.0 (the "License");
2542
+ * you may not use this file except in compliance with the License.
2543
+ * You may obtain a copy of the License at
2544
+ *
2545
+ * http://www.apache.org/licenses/LICENSE-2.0
2546
+ *
2547
+ * Unless required by applicable law or agreed to in writing, software
2548
+ * distributed under the License is distributed on an "AS IS" BASIS,
2549
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2550
+ * See the License for the specific language governing permissions and
2551
+ * limitations under the License.
2552
+ */class OT{constructor(){this.overlays=new ne(L.comparator),this.Rr=new Map}getOverlay(e,t){return S.resolve(this.overlays.get(t))}getOverlays(e,t){const r=Wt();return S.forEach(t,s=>this.getOverlay(e,s).next(i=>{i!==null&&r.set(s,i)})).next(()=>r)}saveOverlays(e,t,r){return r.forEach((s,i)=>{this.Et(e,t,i)}),S.resolve()}removeOverlaysForBatchId(e,t,r){const s=this.Rr.get(r);return s!==void 0&&(s.forEach(i=>this.overlays=this.overlays.remove(i)),this.Rr.delete(r)),S.resolve()}getOverlaysForCollection(e,t,r){const s=Wt(),i=t.length+1,a=new L(t.child("")),c=this.overlays.getIteratorFrom(a);for(;c.hasNext();){const l=c.getNext().value,d=l.getKey();if(!t.isPrefixOf(d.path))break;d.path.length===i&&l.largestBatchId>r&&s.set(l.getKey(),l)}return S.resolve(s)}getOverlaysForCollectionGroup(e,t,r,s){let i=new ne((d,f)=>d-f);const a=this.overlays.getIterator();for(;a.hasNext();){const d=a.getNext().value;if(d.getKey().getCollectionGroup()===t&&d.largestBatchId>r){let f=i.get(d.largestBatchId);f===null&&(f=Wt(),i=i.insert(d.largestBatchId,f)),f.set(d.getKey(),d)}}const c=Wt(),l=i.getIterator();for(;l.hasNext()&&(l.getNext().value.forEach((d,f)=>c.set(d,f)),!(c.size()>=s)););return S.resolve(c)}Et(e,t,r){const s=this.overlays.get(r.key);if(s!==null){const a=this.Rr.get(s.largestBatchId).delete(r.key);this.Rr.set(s.largestBatchId,a)}this.overlays=this.overlays.insert(r.key,new Yy(t,r));let i=this.Rr.get(t);i===void 0&&(i=G(),this.Rr.set(t,i)),this.Rr.set(t,i.add(r.key))}}/**
2553
+ * @license
2554
+ * Copyright 2024 Google LLC
2555
+ *
2556
+ * Licensed under the Apache License, Version 2.0 (the "License");
2557
+ * you may not use this file except in compliance with the License.
2558
+ * You may obtain a copy of the License at
2559
+ *
2560
+ * http://www.apache.org/licenses/LICENSE-2.0
2561
+ *
2562
+ * Unless required by applicable law or agreed to in writing, software
2563
+ * distributed under the License is distributed on an "AS IS" BASIS,
2564
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2565
+ * See the License for the specific language governing permissions and
2566
+ * limitations under the License.
2567
+ */class VT{constructor(){this.sessionToken=me.EMPTY_BYTE_STRING}getSessionToken(e){return S.resolve(this.sessionToken)}setSessionToken(e,t){return this.sessionToken=t,S.resolve()}}/**
2568
+ * @license
2569
+ * Copyright 2017 Google LLC
2570
+ *
2571
+ * Licensed under the Apache License, Version 2.0 (the "License");
2572
+ * you may not use this file except in compliance with the License.
2573
+ * You may obtain a copy of the License at
2574
+ *
2575
+ * http://www.apache.org/licenses/LICENSE-2.0
2576
+ *
2577
+ * Unless required by applicable law or agreed to in writing, software
2578
+ * distributed under the License is distributed on an "AS IS" BASIS,
2579
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2580
+ * See the License for the specific language governing permissions and
2581
+ * limitations under the License.
2582
+ */class Ko{constructor(){this.Vr=new le(he.mr),this.gr=new le(he.pr)}isEmpty(){return this.Vr.isEmpty()}addReference(e,t){const r=new he(e,t);this.Vr=this.Vr.add(r),this.gr=this.gr.add(r)}yr(e,t){e.forEach(r=>this.addReference(r,t))}removeReference(e,t){this.wr(new he(e,t))}Sr(e,t){e.forEach(r=>this.removeReference(r,t))}br(e){const t=new L(new Y([])),r=new he(t,e),s=new he(t,e+1),i=[];return this.gr.forEachInRange([r,s],a=>{this.wr(a),i.push(a.key)}),i}Dr(){this.Vr.forEach(e=>this.wr(e))}wr(e){this.Vr=this.Vr.delete(e),this.gr=this.gr.delete(e)}vr(e){const t=new L(new Y([])),r=new he(t,e),s=new he(t,e+1);let i=G();return this.gr.forEachInRange([r,s],a=>{i=i.add(a.key)}),i}containsKey(e){const t=new he(e,0),r=this.Vr.firstAfterOrEqual(t);return r!==null&&e.isEqual(r.key)}}class he{constructor(e,t){this.key=e,this.Cr=t}static mr(e,t){return L.comparator(e.key,t.key)||H(e.Cr,t.Cr)}static pr(e,t){return H(e.Cr,t.Cr)||L.comparator(e.key,t.key)}}/**
2583
+ * @license
2584
+ * Copyright 2017 Google LLC
2585
+ *
2586
+ * Licensed under the Apache License, Version 2.0 (the "License");
2587
+ * you may not use this file except in compliance with the License.
2588
+ * You may obtain a copy of the License at
2589
+ *
2590
+ * http://www.apache.org/licenses/LICENSE-2.0
2591
+ *
2592
+ * Unless required by applicable law or agreed to in writing, software
2593
+ * distributed under the License is distributed on an "AS IS" BASIS,
2594
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2595
+ * See the License for the specific language governing permissions and
2596
+ * limitations under the License.
2597
+ */class LT{constructor(e,t){this.indexManager=e,this.referenceDelegate=t,this.mutationQueue=[],this.Fr=1,this.Mr=new le(he.mr)}checkEmpty(e){return S.resolve(this.mutationQueue.length===0)}addMutationBatch(e,t,r,s){const i=this.Fr;this.Fr++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];const a=new Jy(i,t,r,s);this.mutationQueue.push(a);for(const c of s)this.Mr=this.Mr.add(new he(c.key,i)),this.indexManager.addToCollectionParentIndex(e,c.key.path.popLast());return S.resolve(a)}lookupMutationBatch(e,t){return S.resolve(this.Or(t))}getNextMutationBatchAfterBatchId(e,t){const r=t+1,s=this.Nr(r),i=s<0?0:s;return S.resolve(this.mutationQueue.length>i?this.mutationQueue[i]:null)}getHighestUnacknowledgedBatchId(){return S.resolve(this.mutationQueue.length===0?Uo:this.Fr-1)}getAllMutationBatches(e){return S.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){const r=new he(t,0),s=new he(t,Number.POSITIVE_INFINITY),i=[];return this.Mr.forEachInRange([r,s],a=>{const c=this.Or(a.Cr);i.push(c)}),S.resolve(i)}getAllMutationBatchesAffectingDocumentKeys(e,t){let r=new le(H);return t.forEach(s=>{const i=new he(s,0),a=new he(s,Number.POSITIVE_INFINITY);this.Mr.forEachInRange([i,a],c=>{r=r.add(c.Cr)})}),S.resolve(this.Br(r))}getAllMutationBatchesAffectingQuery(e,t){const r=t.path,s=r.length+1;let i=r;L.isDocumentKey(i)||(i=i.child(""));const a=new he(new L(i),0);let c=new le(H);return this.Mr.forEachWhile(l=>{const d=l.key.path;return!!r.isPrefixOf(d)&&(d.length===s&&(c=c.add(l.Cr)),!0)},a),S.resolve(this.Br(c))}Br(e){const t=[];return e.forEach(r=>{const s=this.Or(r);s!==null&&t.push(s)}),t}removeMutationBatch(e,t){Q(this.Lr(t.batchId,"removed")===0),this.mutationQueue.shift();let r=this.Mr;return S.forEach(t.mutations,s=>{const i=new he(s.key,t.batchId);return r=r.delete(i),this.referenceDelegate.markPotentiallyOrphaned(e,s.key)}).next(()=>{this.Mr=r})}qn(e){}containsKey(e,t){const r=new he(t,0),s=this.Mr.firstAfterOrEqual(r);return S.resolve(t.isEqual(s&&s.key))}performConsistencyCheck(e){return this.mutationQueue.length,S.resolve()}Lr(e,t){return this.Nr(e)}Nr(e){return this.mutationQueue.length===0?0:e-this.mutationQueue[0].batchId}Or(e){const t=this.Nr(e);return t<0||t>=this.mutationQueue.length?null:this.mutationQueue[t]}}/**
2598
+ * @license
2599
+ * Copyright 2017 Google LLC
2600
+ *
2601
+ * Licensed under the Apache License, Version 2.0 (the "License");
2602
+ * you may not use this file except in compliance with the License.
2603
+ * You may obtain a copy of the License at
2604
+ *
2605
+ * http://www.apache.org/licenses/LICENSE-2.0
2606
+ *
2607
+ * Unless required by applicable law or agreed to in writing, software
2608
+ * distributed under the License is distributed on an "AS IS" BASIS,
2609
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2610
+ * See the License for the specific language governing permissions and
2611
+ * limitations under the License.
2612
+ */class MT{constructor(e){this.kr=e,this.docs=function(){return new ne(L.comparator)}(),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,t){const r=t.key,s=this.docs.get(r),i=s?s.size:0,a=this.kr(t);return this.docs=this.docs.insert(r,{document:t.mutableCopy(),size:a}),this.size+=a-i,this.indexManager.addToCollectionParentIndex(e,r.path.popLast())}removeEntry(e){const t=this.docs.get(e);t&&(this.docs=this.docs.remove(e),this.size-=t.size)}getEntry(e,t){const r=this.docs.get(t);return S.resolve(r?r.document.mutableCopy():Ie.newInvalidDocument(t))}getEntries(e,t){let r=ft();return t.forEach(s=>{const i=this.docs.get(s);r=r.insert(s,i?i.document.mutableCopy():Ie.newInvalidDocument(s))}),S.resolve(r)}getDocumentsMatchingQuery(e,t,r,s){let i=ft();const a=t.path,c=new L(a.child("__id-9223372036854775808__")),l=this.docs.getIteratorFrom(c);for(;l.hasNext();){const{key:d,value:{document:f}}=l.getNext();if(!a.isPrefixOf(d.path))break;d.path.length>a.length+1||dy(hy(f),r)<=0||(s.has(f.key)||ni(t,f))&&(i=i.insert(f.key,f.mutableCopy()))}return S.resolve(i)}getAllFromCollectionGroup(e,t,r,s){U()}qr(e,t){return S.forEach(this.docs,r=>t(r))}newChangeBuffer(e){return new xT(this)}getSize(e){return S.resolve(this.size)}}class xT extends CT{constructor(e){super(),this.Ir=e}applyChanges(e){const t=[];return this.changes.forEach((r,s)=>{s.isValidDocument()?t.push(this.Ir.addEntry(e,s)):this.Ir.removeEntry(r)}),S.waitFor(t)}getFromCache(e,t){return this.Ir.getEntry(e,t)}getAllFromCache(e,t){return this.Ir.getEntries(e,t)}}/**
2613
+ * @license
2614
+ * Copyright 2017 Google LLC
2615
+ *
2616
+ * Licensed under the Apache License, Version 2.0 (the "License");
2617
+ * you may not use this file except in compliance with the License.
2618
+ * You may obtain a copy of the License at
2619
+ *
2620
+ * http://www.apache.org/licenses/LICENSE-2.0
2621
+ *
2622
+ * Unless required by applicable law or agreed to in writing, software
2623
+ * distributed under the License is distributed on an "AS IS" BASIS,
2624
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2625
+ * See the License for the specific language governing permissions and
2626
+ * limitations under the License.
2627
+ */class UT{constructor(e){this.persistence=e,this.Qr=new sn(t=>Bo(t),qo),this.lastRemoteSnapshotVersion=B.min(),this.highestTargetId=0,this.$r=0,this.Ur=new Ko,this.targetCount=0,this.Kr=kn.Un()}forEachTarget(e,t){return this.Qr.forEach((r,s)=>t(s)),S.resolve()}getLastRemoteSnapshotVersion(e){return S.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return S.resolve(this.$r)}allocateTargetId(e){return this.highestTargetId=this.Kr.next(),S.resolve(this.highestTargetId)}setTargetsMetadata(e,t,r){return r&&(this.lastRemoteSnapshotVersion=r),t>this.$r&&(this.$r=t),S.resolve()}zn(e){this.Qr.set(e.target,e);const t=e.targetId;t>this.highestTargetId&&(this.Kr=new kn(t),this.highestTargetId=t),e.sequenceNumber>this.$r&&(this.$r=e.sequenceNumber)}addTargetData(e,t){return this.zn(t),this.targetCount+=1,S.resolve()}updateTargetData(e,t){return this.zn(t),S.resolve()}removeTargetData(e,t){return this.Qr.delete(t.target),this.Ur.br(t.targetId),this.targetCount-=1,S.resolve()}removeTargets(e,t,r){let s=0;const i=[];return this.Qr.forEach((a,c)=>{c.sequenceNumber<=t&&r.get(c.targetId)===null&&(this.Qr.delete(a),i.push(this.removeMatchingKeysForTargetId(e,c.targetId)),s++)}),S.waitFor(i).next(()=>s)}getTargetCount(e){return S.resolve(this.targetCount)}getTargetData(e,t){const r=this.Qr.get(t)||null;return S.resolve(r)}addMatchingKeys(e,t,r){return this.Ur.yr(t,r),S.resolve()}removeMatchingKeys(e,t,r){this.Ur.Sr(t,r);const s=this.persistence.referenceDelegate,i=[];return s&&t.forEach(a=>{i.push(s.markPotentiallyOrphaned(e,a))}),S.waitFor(i)}removeMatchingKeysForTargetId(e,t){return this.Ur.br(t),S.resolve()}getMatchingKeysForTargetId(e,t){const r=this.Ur.vr(t);return S.resolve(r)}containsKey(e,t){return S.resolve(this.Ur.containsKey(t))}}/**
2628
+ * @license
2629
+ * Copyright 2017 Google LLC
2630
+ *
2631
+ * Licensed under the Apache License, Version 2.0 (the "License");
2632
+ * you may not use this file except in compliance with the License.
2633
+ * You may obtain a copy of the License at
2634
+ *
2635
+ * http://www.apache.org/licenses/LICENSE-2.0
2636
+ *
2637
+ * Unless required by applicable law or agreed to in writing, software
2638
+ * distributed under the License is distributed on an "AS IS" BASIS,
2639
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2640
+ * See the License for the specific language governing permissions and
2641
+ * limitations under the License.
2642
+ */class Xh{constructor(e,t){this.Wr={},this.overlays={},this.Gr=new Xs(0),this.zr=!1,this.zr=!0,this.jr=new VT,this.referenceDelegate=e(this),this.Hr=new UT(this),this.indexManager=new IT,this.remoteDocumentCache=function(s){return new MT(s)}(r=>this.referenceDelegate.Jr(r)),this.serializer=new ET(t),this.Yr=new DT(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.zr=!1,Promise.resolve()}get started(){return this.zr}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let t=this.overlays[e.toKey()];return t||(t=new OT,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let r=this.Wr[e.toKey()];return r||(r=new LT(t,this.referenceDelegate),this.Wr[e.toKey()]=r),r}getGlobalsCache(){return this.jr}getTargetCache(){return this.Hr}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Yr}runTransaction(e,t,r){V("MemoryPersistence","Starting transaction:",e);const s=new FT(this.Gr.next());return this.referenceDelegate.Zr(),r(s).next(i=>this.referenceDelegate.Xr(s).next(()=>i)).toPromise().then(i=>(s.raiseOnCommittedEvent(),i))}ei(e,t){return S.or(Object.values(this.Wr).map(r=>()=>r.containsKey(e,t)))}}class FT extends py{constructor(e){super(),this.currentSequenceNumber=e}}class Qo{constructor(e){this.persistence=e,this.ti=new Ko,this.ni=null}static ri(e){return new Qo(e)}get ii(){if(this.ni)return this.ni;throw U()}addReference(e,t,r){return this.ti.addReference(r,t),this.ii.delete(r.toString()),S.resolve()}removeReference(e,t,r){return this.ti.removeReference(r,t),this.ii.add(r.toString()),S.resolve()}markPotentiallyOrphaned(e,t){return this.ii.add(t.toString()),S.resolve()}removeTarget(e,t){this.ti.br(t.targetId).forEach(s=>this.ii.add(s.toString()));const r=this.persistence.getTargetCache();return r.getMatchingKeysForTargetId(e,t.targetId).next(s=>{s.forEach(i=>this.ii.add(i.toString()))}).next(()=>r.removeTargetData(e,t))}Zr(){this.ni=new Set}Xr(e){const t=this.persistence.getRemoteDocumentCache().newChangeBuffer();return S.forEach(this.ii,r=>{const s=L.fromPath(r);return this.si(e,s).next(i=>{i||t.removeEntry(s,B.min())})}).next(()=>(this.ni=null,t.apply(e)))}updateLimboDocument(e,t){return this.si(e,t).next(r=>{r?this.ii.delete(t.toString()):this.ii.add(t.toString())})}Jr(e){return 0}si(e,t){return S.or([()=>S.resolve(this.ti.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.ei(e,t)])}}class Fs{constructor(e,t){this.persistence=e,this.oi=new sn(r=>_y(r.path),(r,s)=>r.isEqual(s)),this.garbageCollector=ST(this,t)}static ri(e,t){return new Fs(e,t)}Zr(){}Xr(e){return S.resolve()}forEachTarget(e,t){return this.persistence.getTargetCache().forEachTarget(e,t)}nr(e){const t=this.sr(e);return this.persistence.getTargetCache().getTargetCount(e).next(r=>t.next(s=>r+s))}sr(e){let t=0;return this.rr(e,r=>{t++}).next(()=>t)}rr(e,t){return S.forEach(this.oi,(r,s)=>this.ar(e,r,s).next(i=>i?S.resolve():t(s)))}removeTargets(e,t,r){return this.persistence.getTargetCache().removeTargets(e,t,r)}removeOrphanedDocuments(e,t){let r=0;const s=this.persistence.getRemoteDocumentCache(),i=s.newChangeBuffer();return s.qr(e,a=>this.ar(e,a,t).next(c=>{c||(r++,i.removeEntry(a,B.min()))})).next(()=>i.apply(e)).next(()=>r)}markPotentiallyOrphaned(e,t){return this.oi.set(t,e.currentSequenceNumber),S.resolve()}removeTarget(e,t){const r=t.withSequenceNumber(e.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(e,r)}addReference(e,t,r){return this.oi.set(r,e.currentSequenceNumber),S.resolve()}removeReference(e,t,r){return this.oi.set(r,e.currentSequenceNumber),S.resolve()}updateLimboDocument(e,t){return this.oi.set(t,e.currentSequenceNumber),S.resolve()}Jr(e){let t=e.key.toString().length;return e.isFoundDocument()&&(t+=gs(e.data.value)),t}ar(e,t,r){return S.or([()=>this.persistence.ei(e,t),()=>this.persistence.getTargetCache().containsKey(e,t),()=>{const s=this.oi.get(t);return S.resolve(s!==void 0&&s>r)}])}getCacheSize(e){return this.persistence.getRemoteDocumentCache().getSize(e)}}/**
2643
+ * @license
2644
+ * Copyright 2017 Google LLC
2645
+ *
2646
+ * Licensed under the Apache License, Version 2.0 (the "License");
2647
+ * you may not use this file except in compliance with the License.
2648
+ * You may obtain a copy of the License at
2649
+ *
2650
+ * http://www.apache.org/licenses/LICENSE-2.0
2651
+ *
2652
+ * Unless required by applicable law or agreed to in writing, software
2653
+ * distributed under the License is distributed on an "AS IS" BASIS,
2654
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2655
+ * See the License for the specific language governing permissions and
2656
+ * limitations under the License.
2657
+ */class Xo{constructor(e,t,r,s){this.targetId=e,this.fromCache=t,this.Hi=r,this.Ji=s}static Yi(e,t){let r=G(),s=G();for(const i of t.docChanges)switch(i.type){case 0:r=r.add(i.doc.key);break;case 1:s=s.add(i.doc.key)}return new Xo(e,t.fromCache,r,s)}}/**
2658
+ * @license
2659
+ * Copyright 2023 Google LLC
2660
+ *
2661
+ * Licensed under the Apache License, Version 2.0 (the "License");
2662
+ * you may not use this file except in compliance with the License.
2663
+ * You may obtain a copy of the License at
2664
+ *
2665
+ * http://www.apache.org/licenses/LICENSE-2.0
2666
+ *
2667
+ * Unless required by applicable law or agreed to in writing, software
2668
+ * distributed under the License is distributed on an "AS IS" BASIS,
2669
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2670
+ * See the License for the specific language governing permissions and
2671
+ * limitations under the License.
2672
+ */class BT{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(e){this._documentReadCount+=e}}/**
2673
+ * @license
2674
+ * Copyright 2019 Google LLC
2675
+ *
2676
+ * Licensed under the Apache License, Version 2.0 (the "License");
2677
+ * you may not use this file except in compliance with the License.
2678
+ * You may obtain a copy of the License at
2679
+ *
2680
+ * http://www.apache.org/licenses/LICENSE-2.0
2681
+ *
2682
+ * Unless required by applicable law or agreed to in writing, software
2683
+ * distributed under the License is distributed on an "AS IS" BASIS,
2684
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2685
+ * See the License for the specific language governing permissions and
2686
+ * limitations under the License.
2687
+ */class qT{constructor(){this.Zi=!1,this.Xi=!1,this.es=100,this.ts=function(){return lp()?8:my(we())>0?6:4}()}initialize(e,t){this.ns=e,this.indexManager=t,this.Zi=!0}getDocumentsMatchingQuery(e,t,r,s){const i={result:null};return this.rs(e,t).next(a=>{i.result=a}).next(()=>{if(!i.result)return this.ss(e,t,s,r).next(a=>{i.result=a})}).next(()=>{if(i.result)return;const a=new BT;return this._s(e,t,a).next(c=>{if(i.result=c,this.Xi)return this.us(e,t,a,c.size)})}).next(()=>i.result)}us(e,t,r,s){return r.documentReadCount<this.es?(pn()<=z.DEBUG&&V("QueryEngine","SDK will not create cache indexes for query:",mn(t),"since it only creates cache indexes for collection contains","more than or equal to",this.es,"documents"),S.resolve()):(pn()<=z.DEBUG&&V("QueryEngine","Query:",mn(t),"scans",r.documentReadCount,"local documents and returns",s,"documents as results."),r.documentReadCount>this.ts*s?(pn()<=z.DEBUG&&V("QueryEngine","The SDK decides to create cache indexes for query:",mn(t),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(e,Qe(t))):S.resolve())}rs(e,t){if(Au(t))return S.resolve(null);let r=Qe(t);return this.indexManager.getIndexType(e,r).next(s=>s===0?null:(t.limit!==null&&s===1&&(t=Ls(t,null,"F"),r=Qe(t)),this.indexManager.getDocumentsMatchingTarget(e,r).next(i=>{const a=G(...i);return this.ns.getDocuments(e,a).next(c=>this.indexManager.getMinOffset(e,r).next(l=>{const d=this.cs(t,c);return this.ls(t,d,a,l.readTime)?this.rs(e,Ls(t,null,"F")):this.hs(e,d,t,l)}))})))}ss(e,t,r,s){return Au(t)||s.isEqual(B.min())?S.resolve(null):this.ns.getDocuments(e,r).next(i=>{const a=this.cs(t,i);return this.ls(t,a,r,s)?S.resolve(null):(pn()<=z.DEBUG&&V("QueryEngine","Re-using previous result from %s to execute query: %s",s.toString(),mn(t)),this.hs(e,a,t,ly(s,yr)).next(c=>c))})}cs(e,t){let r=new le(Sh(e));return t.forEach((s,i)=>{ni(e,i)&&(r=r.add(i))}),r}ls(e,t,r,s){if(e.limit===null)return!1;if(r.size!==t.size)return!0;const i=e.limitType==="F"?t.last():t.first();return!!i&&(i.hasPendingWrites||i.version.compareTo(s)>0)}_s(e,t,r){return pn()<=z.DEBUG&&V("QueryEngine","Using full collection scan to execute query:",mn(t)),this.ns.getDocumentsMatchingQuery(e,t,Ct.min(),r)}hs(e,t,r,s){return this.ns.getDocumentsMatchingQuery(e,r,s).next(i=>(t.forEach(a=>{i=i.insert(a.key,a)}),i))}}/**
2688
+ * @license
2689
+ * Copyright 2020 Google LLC
2690
+ *
2691
+ * Licensed under the Apache License, Version 2.0 (the "License");
2692
+ * you may not use this file except in compliance with the License.
2693
+ * You may obtain a copy of the License at
2694
+ *
2695
+ * http://www.apache.org/licenses/LICENSE-2.0
2696
+ *
2697
+ * Unless required by applicable law or agreed to in writing, software
2698
+ * distributed under the License is distributed on an "AS IS" BASIS,
2699
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2700
+ * See the License for the specific language governing permissions and
2701
+ * limitations under the License.
2702
+ */const Jo="LocalStore",$T=3e8;class jT{constructor(e,t,r,s){this.persistence=e,this.Ps=t,this.serializer=s,this.Ts=new ne(H),this.Is=new sn(i=>Bo(i),qo),this.Es=new Map,this.ds=e.getRemoteDocumentCache(),this.Hr=e.getTargetCache(),this.Yr=e.getBundleCache(),this.As(r)}As(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new NT(this.ds,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.ds.setIndexManager(this.indexManager),this.Ps.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction("Collect garbage","readwrite-primary",t=>e.collect(t,this.Ts))}}function HT(n,e,t,r){return new jT(n,e,t,r)}async function Jh(n,e){const t=q(n);return await t.persistence.runTransaction("Handle user change","readonly",r=>{let s;return t.mutationQueue.getAllMutationBatches(r).next(i=>(s=i,t.As(e),t.mutationQueue.getAllMutationBatches(r))).next(i=>{const a=[],c=[];let l=G();for(const d of s){a.push(d.batchId);for(const f of d.mutations)l=l.add(f.key)}for(const d of i){c.push(d.batchId);for(const f of d.mutations)l=l.add(f.key)}return t.localDocuments.getDocuments(r,l).next(d=>({Rs:d,removedBatchIds:a,addedBatchIds:c}))})})}function zT(n,e){const t=q(n);return t.persistence.runTransaction("Acknowledge batch","readwrite-primary",r=>{const s=e.batch.keys(),i=t.ds.newChangeBuffer({trackRemovals:!0});return function(c,l,d,f){const m=d.batch,E=m.keys();let R=S.resolve();return E.forEach(C=>{R=R.next(()=>f.getEntry(l,C)).next(N=>{const k=d.docVersions.get(C);Q(k!==null),N.version.compareTo(k)<0&&(m.applyToRemoteDocument(N,d),N.isValidDocument()&&(N.setReadTime(d.commitVersion),f.addEntry(N)))})}),R.next(()=>c.mutationQueue.removeMutationBatch(l,m))}(t,r,e,i).next(()=>i.apply(r)).next(()=>t.mutationQueue.performConsistencyCheck(r)).next(()=>t.documentOverlayCache.removeOverlaysForBatchId(r,s,e.batch.batchId)).next(()=>t.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(r,function(c){let l=G();for(let d=0;d<c.mutationResults.length;++d)c.mutationResults[d].transformResults.length>0&&(l=l.add(c.batch.mutations[d].key));return l}(e))).next(()=>t.localDocuments.getDocuments(r,s))})}function Yh(n){const e=q(n);return e.persistence.runTransaction("Get last remote snapshot version","readonly",t=>e.Hr.getLastRemoteSnapshotVersion(t))}function GT(n,e){const t=q(n),r=e.snapshotVersion;let s=t.Ts;return t.persistence.runTransaction("Apply remote event","readwrite-primary",i=>{const a=t.ds.newChangeBuffer({trackRemovals:!0});s=t.Ts;const c=[];e.targetChanges.forEach((f,m)=>{const E=s.get(m);if(!E)return;c.push(t.Hr.removeMatchingKeys(i,f.removedDocuments,m).next(()=>t.Hr.addMatchingKeys(i,f.addedDocuments,m)));let R=E.withSequenceNumber(i.currentSequenceNumber);e.targetMismatches.get(m)!==null?R=R.withResumeToken(me.EMPTY_BYTE_STRING,B.min()).withLastLimboFreeSnapshotVersion(B.min()):f.resumeToken.approximateByteSize()>0&&(R=R.withResumeToken(f.resumeToken,r)),s=s.insert(m,R),function(N,k,F){return N.resumeToken.approximateByteSize()===0||k.snapshotVersion.toMicroseconds()-N.snapshotVersion.toMicroseconds()>=$T?!0:F.addedDocuments.size+F.modifiedDocuments.size+F.removedDocuments.size>0}(E,R,f)&&c.push(t.Hr.updateTargetData(i,R))});let l=ft(),d=G();if(e.documentUpdates.forEach(f=>{e.resolvedLimboDocuments.has(f)&&c.push(t.persistence.referenceDelegate.updateLimboDocument(i,f))}),c.push(WT(i,a,e.documentUpdates).next(f=>{l=f.Vs,d=f.fs})),!r.isEqual(B.min())){const f=t.Hr.getLastRemoteSnapshotVersion(i).next(m=>t.Hr.setTargetsMetadata(i,i.currentSequenceNumber,r));c.push(f)}return S.waitFor(c).next(()=>a.apply(i)).next(()=>t.localDocuments.getLocalViewOfDocuments(i,l,d)).next(()=>l)}).then(i=>(t.Ts=s,i))}function WT(n,e,t){let r=G(),s=G();return t.forEach(i=>r=r.add(i)),e.getEntries(n,r).next(i=>{let a=ft();return t.forEach((c,l)=>{const d=i.get(c);l.isFoundDocument()!==d.isFoundDocument()&&(s=s.add(c)),l.isNoDocument()&&l.version.isEqual(B.min())?(e.removeEntry(c,l.readTime),a=a.insert(c,l)):!d.isValidDocument()||l.version.compareTo(d.version)>0||l.version.compareTo(d.version)===0&&d.hasPendingWrites?(e.addEntry(l),a=a.insert(c,l)):V(Jo,"Ignoring outdated watch update for ",c,". Current version:",d.version," Watch version:",l.version)}),{Vs:a,fs:s}})}function KT(n,e){const t=q(n);return t.persistence.runTransaction("Get next mutation batch","readonly",r=>(e===void 0&&(e=Uo),t.mutationQueue.getNextMutationBatchAfterBatchId(r,e)))}function QT(n,e){const t=q(n);return t.persistence.runTransaction("Allocate target","readwrite",r=>{let s;return t.Hr.getTargetData(r,e).next(i=>i?(s=i,S.resolve(s)):t.Hr.allocateTargetId(r).next(a=>(s=new At(e,a,"TargetPurposeListen",r.currentSequenceNumber),t.Hr.addTargetData(r,s).next(()=>s))))}).then(r=>{const s=t.Ts.get(r.targetId);return(s===null||r.snapshotVersion.compareTo(s.snapshotVersion)>0)&&(t.Ts=t.Ts.insert(r.targetId,r),t.Is.set(e,r.targetId)),r})}async function _o(n,e,t){const r=q(n),s=r.Ts.get(e),i=t?"readwrite":"readwrite-primary";try{t||await r.persistence.runTransaction("Release target",i,a=>r.persistence.referenceDelegate.removeTarget(a,s))}catch(a){if(!Mn(a))throw a;V(Jo,`Failed to update sequence numbers for target ${e}: ${a}`)}r.Ts=r.Ts.remove(e),r.Is.delete(s.target)}function xu(n,e,t){const r=q(n);let s=B.min(),i=G();return r.persistence.runTransaction("Execute query","readwrite",a=>function(l,d,f){const m=q(l),E=m.Is.get(f);return E!==void 0?S.resolve(m.Ts.get(E)):m.Hr.getTargetData(d,f)}(r,a,Qe(e)).next(c=>{if(c)return s=c.lastLimboFreeSnapshotVersion,r.Hr.getMatchingKeysForTargetId(a,c.targetId).next(l=>{i=l})}).next(()=>r.Ps.getDocumentsMatchingQuery(a,e,t?s:B.min(),t?i:G())).next(c=>(XT(r,My(e),c),{documents:c,gs:i})))}function XT(n,e,t){let r=n.Es.get(e)||B.min();t.forEach((s,i)=>{i.readTime.compareTo(r)>0&&(r=i.readTime)}),n.Es.set(e,r)}class Uu{constructor(){this.activeTargetIds=$y()}Ds(e){this.activeTargetIds=this.activeTargetIds.add(e)}vs(e){this.activeTargetIds=this.activeTargetIds.delete(e)}bs(){const e={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(e)}}class JT{constructor(){this.ho=new Uu,this.Po={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,t,r){}addLocalQueryTarget(e,t=!0){return t&&this.ho.Ds(e),this.Po[e]||"not-current"}updateQueryState(e,t,r){this.Po[e]=t}removeLocalQueryTarget(e){this.ho.vs(e)}isLocalQueryTarget(e){return this.ho.activeTargetIds.has(e)}clearQueryState(e){delete this.Po[e]}getAllActiveQueryTargets(){return this.ho.activeTargetIds}isActiveQueryTarget(e){return this.ho.activeTargetIds.has(e)}start(){return this.ho=new Uu,Promise.resolve()}handleUserChange(e,t,r){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}}/**
2703
+ * @license
2704
+ * Copyright 2019 Google LLC
2705
+ *
2706
+ * Licensed under the Apache License, Version 2.0 (the "License");
2707
+ * you may not use this file except in compliance with the License.
2708
+ * You may obtain a copy of the License at
2709
+ *
2710
+ * http://www.apache.org/licenses/LICENSE-2.0
2711
+ *
2712
+ * Unless required by applicable law or agreed to in writing, software
2713
+ * distributed under the License is distributed on an "AS IS" BASIS,
2714
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2715
+ * See the License for the specific language governing permissions and
2716
+ * limitations under the License.
2717
+ */class YT{To(e){}shutdown(){}}/**
2718
+ * @license
2719
+ * Copyright 2019 Google LLC
2720
+ *
2721
+ * Licensed under the Apache License, Version 2.0 (the "License");
2722
+ * you may not use this file except in compliance with the License.
2723
+ * You may obtain a copy of the License at
2724
+ *
2725
+ * http://www.apache.org/licenses/LICENSE-2.0
2726
+ *
2727
+ * Unless required by applicable law or agreed to in writing, software
2728
+ * distributed under the License is distributed on an "AS IS" BASIS,
2729
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2730
+ * See the License for the specific language governing permissions and
2731
+ * limitations under the License.
2732
+ */const Fu="ConnectivityMonitor";class Bu{constructor(){this.Io=()=>this.Eo(),this.Ao=()=>this.Ro(),this.Vo=[],this.mo()}To(e){this.Vo.push(e)}shutdown(){window.removeEventListener("online",this.Io),window.removeEventListener("offline",this.Ao)}mo(){window.addEventListener("online",this.Io),window.addEventListener("offline",this.Ao)}Eo(){V(Fu,"Network connectivity changed: AVAILABLE");for(const e of this.Vo)e(0)}Ro(){V(Fu,"Network connectivity changed: UNAVAILABLE");for(const e of this.Vo)e(1)}static D(){return typeof window<"u"&&window.addEventListener!==void 0&&window.removeEventListener!==void 0}}/**
2733
+ * @license
2734
+ * Copyright 2023 Google LLC
2735
+ *
2736
+ * Licensed under the Apache License, Version 2.0 (the "License");
2737
+ * you may not use this file except in compliance with the License.
2738
+ * You may obtain a copy of the License at
2739
+ *
2740
+ * http://www.apache.org/licenses/LICENSE-2.0
2741
+ *
2742
+ * Unless required by applicable law or agreed to in writing, software
2743
+ * distributed under the License is distributed on an "AS IS" BASIS,
2744
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2745
+ * See the License for the specific language governing permissions and
2746
+ * limitations under the License.
2747
+ */let cs=null;function yo(){return cs===null?cs=function(){return 268435456+Math.round(2147483648*Math.random())}():cs++,"0x"+cs.toString(16)}/**
2748
+ * @license
2749
+ * Copyright 2020 Google LLC
2750
+ *
2751
+ * Licensed under the Apache License, Version 2.0 (the "License");
2752
+ * you may not use this file except in compliance with the License.
2753
+ * You may obtain a copy of the License at
2754
+ *
2755
+ * http://www.apache.org/licenses/LICENSE-2.0
2756
+ *
2757
+ * Unless required by applicable law or agreed to in writing, software
2758
+ * distributed under the License is distributed on an "AS IS" BASIS,
2759
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2760
+ * See the License for the specific language governing permissions and
2761
+ * limitations under the License.
2762
+ */const Gi="RestConnection",ZT={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery"};class eE{get fo(){return!1}constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;const t=e.ssl?"https":"http",r=encodeURIComponent(this.databaseId.projectId),s=encodeURIComponent(this.databaseId.database);this.po=t+"://"+e.host,this.yo=`projects/${r}/databases/${s}`,this.wo=this.databaseId.database===Ds?`project_id=${r}`:`project_id=${r}&database_id=${s}`}So(e,t,r,s,i){const a=yo(),c=this.bo(e,t.toUriEncodedString());V(Gi,`Sending RPC '${e}' ${a}:`,c,r);const l={"google-cloud-resource-prefix":this.yo,"x-goog-request-params":this.wo};return this.Do(l,s,i),this.vo(e,c,l,r).then(d=>(V(Gi,`Received RPC '${e}' ${a}: `,d),d),d=>{throw Rn(Gi,`RPC '${e}' ${a} failed with error: `,d,"url: ",c,"request:",r),d})}Co(e,t,r,s,i,a){return this.So(e,t,r,s,i)}Do(e,t,r){e["X-Goog-Api-Client"]=function(){return"gl-js/ fire/"+Vn}(),e["Content-Type"]="text/plain",this.databaseInfo.appId&&(e["X-Firebase-GMPID"]=this.databaseInfo.appId),t&&t.headers.forEach((s,i)=>e[i]=s),r&&r.headers.forEach((s,i)=>e[i]=s)}bo(e,t){const r=ZT[e];return`${this.po}/v1/${t}:${r}`}terminate(){}}/**
2763
+ * @license
2764
+ * Copyright 2017 Google LLC
2765
+ *
2766
+ * Licensed under the Apache License, Version 2.0 (the "License");
2767
+ * you may not use this file except in compliance with the License.
2768
+ * You may obtain a copy of the License at
2769
+ *
2770
+ * http://www.apache.org/licenses/LICENSE-2.0
2771
+ *
2772
+ * Unless required by applicable law or agreed to in writing, software
2773
+ * distributed under the License is distributed on an "AS IS" BASIS,
2774
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2775
+ * See the License for the specific language governing permissions and
2776
+ * limitations under the License.
2777
+ */class tE{constructor(e){this.Fo=e.Fo,this.Mo=e.Mo}xo(e){this.Oo=e}No(e){this.Bo=e}Lo(e){this.ko=e}onMessage(e){this.qo=e}close(){this.Mo()}send(e){this.Fo(e)}Qo(){this.Oo()}$o(){this.Bo()}Uo(e){this.ko(e)}Ko(e){this.qo(e)}}/**
2778
+ * @license
2779
+ * Copyright 2017 Google LLC
2780
+ *
2781
+ * Licensed under the Apache License, Version 2.0 (the "License");
2782
+ * you may not use this file except in compliance with the License.
2783
+ * You may obtain a copy of the License at
2784
+ *
2785
+ * http://www.apache.org/licenses/LICENSE-2.0
2786
+ *
2787
+ * Unless required by applicable law or agreed to in writing, software
2788
+ * distributed under the License is distributed on an "AS IS" BASIS,
2789
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2790
+ * See the License for the specific language governing permissions and
2791
+ * limitations under the License.
2792
+ */const Ee="WebChannelConnection";class nE extends eE{constructor(e){super(e),this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}vo(e,t,r,s){const i=yo();return new Promise((a,c)=>{const l=new rh;l.setWithCredentials(!0),l.listenOnce(sh.COMPLETE,()=>{try{switch(l.getLastErrorCode()){case ms.NO_ERROR:const f=l.getResponseJson();V(Ee,`XHR for RPC '${e}' ${i} received:`,JSON.stringify(f)),a(f);break;case ms.TIMEOUT:V(Ee,`RPC '${e}' ${i} timed out`),c(new O(P.DEADLINE_EXCEEDED,"Request time out"));break;case ms.HTTP_ERROR:const m=l.getStatus();if(V(Ee,`RPC '${e}' ${i} failed with status:`,m,"response text:",l.getResponseText()),m>0){let E=l.getResponseJson();Array.isArray(E)&&(E=E[0]);const R=E==null?void 0:E.error;if(R&&R.status&&R.message){const C=function(k){const F=k.toLowerCase().replace(/_/g,"-");return Object.values(P).indexOf(F)>=0?F:P.UNKNOWN}(R.status);c(new O(C,R.message))}else c(new O(P.UNKNOWN,"Server responded with status "+l.getStatus()))}else c(new O(P.UNAVAILABLE,"Connection failed."));break;default:U()}}finally{V(Ee,`RPC '${e}' ${i} completed.`)}});const d=JSON.stringify(s);V(Ee,`RPC '${e}' ${i} sending request:`,s),l.send(t,"POST",d,r,15)})}Wo(e,t,r){const s=yo(),i=[this.po,"/","google.firestore.v1.Firestore","/",e,"/channel"],a=ah(),c=oh(),l={httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:`projects/${this.databaseId.projectId}/databases/${this.databaseId.database}`},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling,detectBufferingProxy:this.autoDetectLongPolling},d=this.longPollingOptions.timeoutSeconds;d!==void 0&&(l.longPollingTimeout=Math.round(1e3*d)),this.useFetchStreams&&(l.useFetchStreams=!0),this.Do(l.initMessageHeaders,t,r),l.encodeInitMessageHeaders=!0;const f=i.join("");V(Ee,`Creating RPC '${e}' stream ${s}: ${f}`,l);const m=a.createWebChannel(f,l);let E=!1,R=!1;const C=new tE({Fo:k=>{R?V(Ee,`Not sending because RPC '${e}' stream ${s} is closed:`,k):(E||(V(Ee,`Opening RPC '${e}' stream ${s} transport.`),m.open(),E=!0),V(Ee,`RPC '${e}' stream ${s} sending:`,k),m.send(k))},Mo:()=>m.close()}),N=(k,F,$)=>{k.listen(F,M=>{try{$(M)}catch(j){setTimeout(()=>{throw j},0)}})};return N(m,or.EventType.OPEN,()=>{R||(V(Ee,`RPC '${e}' stream ${s} transport opened.`),C.Qo())}),N(m,or.EventType.CLOSE,()=>{R||(R=!0,V(Ee,`RPC '${e}' stream ${s} transport closed`),C.Uo())}),N(m,or.EventType.ERROR,k=>{R||(R=!0,Rn(Ee,`RPC '${e}' stream ${s} transport errored:`,k),C.Uo(new O(P.UNAVAILABLE,"The operation could not be completed")))}),N(m,or.EventType.MESSAGE,k=>{var F;if(!R){const $=k.data[0];Q(!!$);const M=$,j=(M==null?void 0:M.error)||((F=M[0])===null||F===void 0?void 0:F.error);if(j){V(Ee,`RPC '${e}' stream ${s} received error:`,j);const ce=j.status;let X=function(_){const T=oe[_];if(T!==void 0)return Fh(T)}(ce),v=j.message;X===void 0&&(X=P.INTERNAL,v="Unknown error status: "+ce+" with message "+j.message),R=!0,C.Uo(new O(X,v)),m.close()}else V(Ee,`RPC '${e}' stream ${s} received:`,$),C.Ko($)}}),N(c,ih.STAT_EVENT,k=>{k.stat===io.PROXY?V(Ee,`RPC '${e}' stream ${s} detected buffering proxy`):k.stat===io.NOPROXY&&V(Ee,`RPC '${e}' stream ${s} detected no buffering proxy`)}),setTimeout(()=>{C.$o()},0),C}}function Wi(){return typeof document<"u"?document:null}/**
2793
+ * @license
2794
+ * Copyright 2020 Google LLC
2795
+ *
2796
+ * Licensed under the Apache License, Version 2.0 (the "License");
2797
+ * you may not use this file except in compliance with the License.
2798
+ * You may obtain a copy of the License at
2799
+ *
2800
+ * http://www.apache.org/licenses/LICENSE-2.0
2801
+ *
2802
+ * Unless required by applicable law or agreed to in writing, software
2803
+ * distributed under the License is distributed on an "AS IS" BASIS,
2804
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2805
+ * See the License for the specific language governing permissions and
2806
+ * limitations under the License.
2807
+ */function oi(n){return new oT(n,!0)}/**
2808
+ * @license
2809
+ * Copyright 2017 Google LLC
2810
+ *
2811
+ * Licensed under the Apache License, Version 2.0 (the "License");
2812
+ * you may not use this file except in compliance with the License.
2813
+ * You may obtain a copy of the License at
2814
+ *
2815
+ * http://www.apache.org/licenses/LICENSE-2.0
2816
+ *
2817
+ * Unless required by applicable law or agreed to in writing, software
2818
+ * distributed under the License is distributed on an "AS IS" BASIS,
2819
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2820
+ * See the License for the specific language governing permissions and
2821
+ * limitations under the License.
2822
+ */class Zh{constructor(e,t,r=1e3,s=1.5,i=6e4){this.Ti=e,this.timerId=t,this.Go=r,this.zo=s,this.jo=i,this.Ho=0,this.Jo=null,this.Yo=Date.now(),this.reset()}reset(){this.Ho=0}Zo(){this.Ho=this.jo}Xo(e){this.cancel();const t=Math.floor(this.Ho+this.e_()),r=Math.max(0,Date.now()-this.Yo),s=Math.max(0,t-r);s>0&&V("ExponentialBackoff",`Backing off for ${s} ms (base delay: ${this.Ho} ms, delay with jitter: ${t} ms, last attempt: ${r} ms ago)`),this.Jo=this.Ti.enqueueAfterDelay(this.timerId,s,()=>(this.Yo=Date.now(),e())),this.Ho*=this.zo,this.Ho<this.Go&&(this.Ho=this.Go),this.Ho>this.jo&&(this.Ho=this.jo)}t_(){this.Jo!==null&&(this.Jo.skipDelay(),this.Jo=null)}cancel(){this.Jo!==null&&(this.Jo.cancel(),this.Jo=null)}e_(){return(Math.random()-.5)*this.Ho}}/**
2823
+ * @license
2824
+ * Copyright 2017 Google LLC
2825
+ *
2826
+ * Licensed under the Apache License, Version 2.0 (the "License");
2827
+ * you may not use this file except in compliance with the License.
2828
+ * You may obtain a copy of the License at
2829
+ *
2830
+ * http://www.apache.org/licenses/LICENSE-2.0
2831
+ *
2832
+ * Unless required by applicable law or agreed to in writing, software
2833
+ * distributed under the License is distributed on an "AS IS" BASIS,
2834
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2835
+ * See the License for the specific language governing permissions and
2836
+ * limitations under the License.
2837
+ */const qu="PersistentStream";class ed{constructor(e,t,r,s,i,a,c,l){this.Ti=e,this.n_=r,this.r_=s,this.connection=i,this.authCredentialsProvider=a,this.appCheckCredentialsProvider=c,this.listener=l,this.state=0,this.i_=0,this.s_=null,this.o_=null,this.stream=null,this.__=0,this.a_=new Zh(e,t)}u_(){return this.state===1||this.state===5||this.c_()}c_(){return this.state===2||this.state===3}start(){this.__=0,this.state!==4?this.auth():this.l_()}async stop(){this.u_()&&await this.close(0)}h_(){this.state=0,this.a_.reset()}P_(){this.c_()&&this.s_===null&&(this.s_=this.Ti.enqueueAfterDelay(this.n_,6e4,()=>this.T_()))}I_(e){this.E_(),this.stream.send(e)}async T_(){if(this.c_())return this.close(0)}E_(){this.s_&&(this.s_.cancel(),this.s_=null)}d_(){this.o_&&(this.o_.cancel(),this.o_=null)}async close(e,t){this.E_(),this.d_(),this.a_.cancel(),this.i_++,e!==4?this.a_.reset():t&&t.code===P.RESOURCE_EXHAUSTED?(dt(t.toString()),dt("Using maximum backoff delay to prevent overloading the backend."),this.a_.Zo()):t&&t.code===P.UNAUTHENTICATED&&this.state!==3&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),this.stream!==null&&(this.A_(),this.stream.close(),this.stream=null),this.state=e,await this.listener.Lo(t)}A_(){}auth(){this.state=1;const e=this.R_(this.i_),t=this.i_;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then(([r,s])=>{this.i_===t&&this.V_(r,s)},r=>{e(()=>{const s=new O(P.UNKNOWN,"Fetching auth token failed: "+r.message);return this.m_(s)})})}V_(e,t){const r=this.R_(this.i_);this.stream=this.f_(e,t),this.stream.xo(()=>{r(()=>this.listener.xo())}),this.stream.No(()=>{r(()=>(this.state=2,this.o_=this.Ti.enqueueAfterDelay(this.r_,1e4,()=>(this.c_()&&(this.state=3),Promise.resolve())),this.listener.No()))}),this.stream.Lo(s=>{r(()=>this.m_(s))}),this.stream.onMessage(s=>{r(()=>++this.__==1?this.g_(s):this.onNext(s))})}l_(){this.state=5,this.a_.Xo(async()=>{this.state=0,this.start()})}m_(e){return V(qu,`close with error: ${e}`),this.stream=null,this.close(4,e)}R_(e){return t=>{this.Ti.enqueueAndForget(()=>this.i_===e?t():(V(qu,"stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve()))}}}class rE extends ed{constructor(e,t,r,s,i,a){super(e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",t,r,s,a),this.serializer=i}f_(e,t){return this.connection.Wo("Listen",e,t)}g_(e){return this.onNext(e)}onNext(e){this.a_.reset();const t=uT(this.serializer,e),r=function(i){if(!("targetChange"in i))return B.min();const a=i.targetChange;return a.targetIds&&a.targetIds.length?B.min():a.readTime?Je(a.readTime):B.min()}(e);return this.listener.p_(t,r)}y_(e){const t={};t.database=go(this.serializer),t.addTarget=function(i,a){let c;const l=a.target;if(c=lo(l)?{documents:dT(i,l)}:{query:fT(i,l).ht},c.targetId=a.targetId,a.resumeToken.approximateByteSize()>0){c.resumeToken=$h(i,a.resumeToken);const d=fo(i,a.expectedCount);d!==null&&(c.expectedCount=d)}else if(a.snapshotVersion.compareTo(B.min())>0){c.readTime=Us(i,a.snapshotVersion.toTimestamp());const d=fo(i,a.expectedCount);d!==null&&(c.expectedCount=d)}return c}(this.serializer,e);const r=mT(this.serializer,e);r&&(t.labels=r),this.I_(t)}w_(e){const t={};t.database=go(this.serializer),t.removeTarget=e,this.I_(t)}}class sE extends ed{constructor(e,t,r,s,i,a){super(e,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",t,r,s,a),this.serializer=i}get S_(){return this.__>0}start(){this.lastStreamToken=void 0,super.start()}A_(){this.S_&&this.b_([])}f_(e,t){return this.connection.Wo("Write",e,t)}g_(e){return Q(!!e.streamToken),this.lastStreamToken=e.streamToken,Q(!e.writeResults||e.writeResults.length===0),this.listener.D_()}onNext(e){Q(!!e.streamToken),this.lastStreamToken=e.streamToken,this.a_.reset();const t=hT(e.writeResults,e.commitTime),r=Je(e.commitTime);return this.listener.v_(r,t)}C_(){const e={};e.database=go(this.serializer),this.I_(e)}b_(e){const t={streamToken:this.lastStreamToken,writes:e.map(r=>lT(this.serializer,r))};this.I_(t)}}/**
2838
+ * @license
2839
+ * Copyright 2017 Google LLC
2840
+ *
2841
+ * Licensed under the Apache License, Version 2.0 (the "License");
2842
+ * you may not use this file except in compliance with the License.
2843
+ * You may obtain a copy of the License at
2844
+ *
2845
+ * http://www.apache.org/licenses/LICENSE-2.0
2846
+ *
2847
+ * Unless required by applicable law or agreed to in writing, software
2848
+ * distributed under the License is distributed on an "AS IS" BASIS,
2849
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2850
+ * See the License for the specific language governing permissions and
2851
+ * limitations under the License.
2852
+ */class iE{}class oE extends iE{constructor(e,t,r,s){super(),this.authCredentials=e,this.appCheckCredentials=t,this.connection=r,this.serializer=s,this.F_=!1}M_(){if(this.F_)throw new O(P.FAILED_PRECONDITION,"The client has already been terminated.")}So(e,t,r,s){return this.M_(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([i,a])=>this.connection.So(e,po(t,r),s,i,a)).catch(i=>{throw i.name==="FirebaseError"?(i.code===P.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),i):new O(P.UNKNOWN,i.toString())})}Co(e,t,r,s,i){return this.M_(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([a,c])=>this.connection.Co(e,po(t,r),s,a,c,i)).catch(a=>{throw a.name==="FirebaseError"?(a.code===P.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),a):new O(P.UNKNOWN,a.toString())})}terminate(){this.F_=!0,this.connection.terminate()}}class aE{constructor(e,t){this.asyncQueue=e,this.onlineStateHandler=t,this.state="Unknown",this.x_=0,this.O_=null,this.N_=!0}B_(){this.x_===0&&(this.L_("Unknown"),this.O_=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,()=>(this.O_=null,this.k_("Backend didn't respond within 10 seconds."),this.L_("Offline"),Promise.resolve())))}q_(e){this.state==="Online"?this.L_("Unknown"):(this.x_++,this.x_>=1&&(this.Q_(),this.k_(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.L_("Offline")))}set(e){this.Q_(),this.x_=0,e==="Online"&&(this.N_=!1),this.L_(e)}L_(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}k_(e){const t=`Could not reach Cloud Firestore backend. ${e}
2853
+ This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.`;this.N_?(dt(t),this.N_=!1):V("OnlineStateTracker",t)}Q_(){this.O_!==null&&(this.O_.cancel(),this.O_=null)}}/**
2854
+ * @license
2855
+ * Copyright 2017 Google LLC
2856
+ *
2857
+ * Licensed under the Apache License, Version 2.0 (the "License");
2858
+ * you may not use this file except in compliance with the License.
2859
+ * You may obtain a copy of the License at
2860
+ *
2861
+ * http://www.apache.org/licenses/LICENSE-2.0
2862
+ *
2863
+ * Unless required by applicable law or agreed to in writing, software
2864
+ * distributed under the License is distributed on an "AS IS" BASIS,
2865
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2866
+ * See the License for the specific language governing permissions and
2867
+ * limitations under the License.
2868
+ */const Zt="RemoteStore";class cE{constructor(e,t,r,s,i){this.localStore=e,this.datastore=t,this.asyncQueue=r,this.remoteSyncer={},this.U_=[],this.K_=new Map,this.W_=new Set,this.G_=[],this.z_=i,this.z_.To(a=>{r.enqueueAndForget(async()=>{an(this)&&(V(Zt,"Restarting streams for network reachability change."),await async function(l){const d=q(l);d.W_.add(4),await Vr(d),d.j_.set("Unknown"),d.W_.delete(4),await ai(d)}(this))})}),this.j_=new aE(r,s)}}async function ai(n){if(an(n))for(const e of n.G_)await e(!0)}async function Vr(n){for(const e of n.G_)await e(!1)}function td(n,e){const t=q(n);t.K_.has(e.targetId)||(t.K_.set(e.targetId,e),ta(t)?ea(t):xn(t).c_()&&Zo(t,e))}function Yo(n,e){const t=q(n),r=xn(t);t.K_.delete(e),r.c_()&&nd(t,e),t.K_.size===0&&(r.c_()?r.P_():an(t)&&t.j_.set("Unknown"))}function Zo(n,e){if(n.H_.Ne(e.targetId),e.resumeToken.approximateByteSize()>0||e.snapshotVersion.compareTo(B.min())>0){const t=n.remoteSyncer.getRemoteKeysForTarget(e.targetId).size;e=e.withExpectedCount(t)}xn(n).y_(e)}function nd(n,e){n.H_.Ne(e),xn(n).w_(e)}function ea(n){n.H_=new nT({getRemoteKeysForTarget:e=>n.remoteSyncer.getRemoteKeysForTarget(e),lt:e=>n.K_.get(e)||null,it:()=>n.datastore.serializer.databaseId}),xn(n).start(),n.j_.B_()}function ta(n){return an(n)&&!xn(n).u_()&&n.K_.size>0}function an(n){return q(n).W_.size===0}function rd(n){n.H_=void 0}async function uE(n){n.j_.set("Online")}async function lE(n){n.K_.forEach((e,t)=>{Zo(n,e)})}async function hE(n,e){rd(n),ta(n)?(n.j_.q_(e),ea(n)):n.j_.set("Unknown")}async function dE(n,e,t){if(n.j_.set("Online"),e instanceof qh&&e.state===2&&e.cause)try{await async function(s,i){const a=i.cause;for(const c of i.targetIds)s.K_.has(c)&&(await s.remoteSyncer.rejectListen(c,a),s.K_.delete(c),s.H_.removeTarget(c))}(n,e)}catch(r){V(Zt,"Failed to remove targets %s: %s ",e.targetIds.join(","),r),await Bs(n,r)}else if(e instanceof Ts?n.H_.We(e):e instanceof Bh?n.H_.Ze(e):n.H_.je(e),!t.isEqual(B.min()))try{const r=await Yh(n.localStore);t.compareTo(r)>=0&&await function(i,a){const c=i.H_.ot(a);return c.targetChanges.forEach((l,d)=>{if(l.resumeToken.approximateByteSize()>0){const f=i.K_.get(d);f&&i.K_.set(d,f.withResumeToken(l.resumeToken,a))}}),c.targetMismatches.forEach((l,d)=>{const f=i.K_.get(l);if(!f)return;i.K_.set(l,f.withResumeToken(me.EMPTY_BYTE_STRING,f.snapshotVersion)),nd(i,l);const m=new At(f.target,l,d,f.sequenceNumber);Zo(i,m)}),i.remoteSyncer.applyRemoteEvent(c)}(n,t)}catch(r){V(Zt,"Failed to raise snapshot:",r),await Bs(n,r)}}async function Bs(n,e,t){if(!Mn(e))throw e;n.W_.add(1),await Vr(n),n.j_.set("Offline"),t||(t=()=>Yh(n.localStore)),n.asyncQueue.enqueueRetryable(async()=>{V(Zt,"Retrying IndexedDB access"),await t(),n.W_.delete(1),await ai(n)})}function sd(n,e){return e().catch(t=>Bs(n,t,e))}async function ci(n){const e=q(n),t=Ot(e);let r=e.U_.length>0?e.U_[e.U_.length-1].batchId:Uo;for(;fE(e);)try{const s=await KT(e.localStore,r);if(s===null){e.U_.length===0&&t.P_();break}r=s.batchId,pE(e,s)}catch(s){await Bs(e,s)}id(e)&&od(e)}function fE(n){return an(n)&&n.U_.length<10}function pE(n,e){n.U_.push(e);const t=Ot(n);t.c_()&&t.S_&&t.b_(e.mutations)}function id(n){return an(n)&&!Ot(n).u_()&&n.U_.length>0}function od(n){Ot(n).start()}async function mE(n){Ot(n).C_()}async function gE(n){const e=Ot(n);for(const t of n.U_)e.b_(t.mutations)}async function _E(n,e,t){const r=n.U_.shift(),s=zo.from(r,e,t);await sd(n,()=>n.remoteSyncer.applySuccessfulWrite(s)),await ci(n)}async function yE(n,e){e&&Ot(n).S_&&await async function(r,s){if(function(a){return eT(a)&&a!==P.ABORTED}(s.code)){const i=r.U_.shift();Ot(r).h_(),await sd(r,()=>r.remoteSyncer.rejectFailedWrite(i.batchId,s)),await ci(r)}}(n,e),id(n)&&od(n)}async function $u(n,e){const t=q(n);t.asyncQueue.verifyOperationInProgress(),V(Zt,"RemoteStore received new credentials");const r=an(t);t.W_.add(3),await Vr(t),r&&t.j_.set("Unknown"),await t.remoteSyncer.handleCredentialChange(e),t.W_.delete(3),await ai(t)}async function TE(n,e){const t=q(n);e?(t.W_.delete(2),await ai(t)):e||(t.W_.add(2),await Vr(t),t.j_.set("Unknown"))}function xn(n){return n.J_||(n.J_=function(t,r,s){const i=q(t);return i.M_(),new rE(r,i.connection,i.authCredentials,i.appCheckCredentials,i.serializer,s)}(n.datastore,n.asyncQueue,{xo:uE.bind(null,n),No:lE.bind(null,n),Lo:hE.bind(null,n),p_:dE.bind(null,n)}),n.G_.push(async e=>{e?(n.J_.h_(),ta(n)?ea(n):n.j_.set("Unknown")):(await n.J_.stop(),rd(n))})),n.J_}function Ot(n){return n.Y_||(n.Y_=function(t,r,s){const i=q(t);return i.M_(),new sE(r,i.connection,i.authCredentials,i.appCheckCredentials,i.serializer,s)}(n.datastore,n.asyncQueue,{xo:()=>Promise.resolve(),No:mE.bind(null,n),Lo:yE.bind(null,n),D_:gE.bind(null,n),v_:_E.bind(null,n)}),n.G_.push(async e=>{e?(n.Y_.h_(),await ci(n)):(await n.Y_.stop(),n.U_.length>0&&(V(Zt,`Stopping write stream with ${n.U_.length} pending writes`),n.U_=[]))})),n.Y_}/**
2869
+ * @license
2870
+ * Copyright 2017 Google LLC
2871
+ *
2872
+ * Licensed under the Apache License, Version 2.0 (the "License");
2873
+ * you may not use this file except in compliance with the License.
2874
+ * You may obtain a copy of the License at
2875
+ *
2876
+ * http://www.apache.org/licenses/LICENSE-2.0
2877
+ *
2878
+ * Unless required by applicable law or agreed to in writing, software
2879
+ * distributed under the License is distributed on an "AS IS" BASIS,
2880
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2881
+ * See the License for the specific language governing permissions and
2882
+ * limitations under the License.
2883
+ */class na{constructor(e,t,r,s,i){this.asyncQueue=e,this.timerId=t,this.targetTimeMs=r,this.op=s,this.removalCallback=i,this.deferred=new at,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch(a=>{})}get promise(){return this.deferred.promise}static createAndSchedule(e,t,r,s,i){const a=Date.now()+r,c=new na(e,t,a,s,i);return c.start(r),c}start(e){this.timerHandle=setTimeout(()=>this.handleDelayElapsed(),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){this.timerHandle!==null&&(this.clearTimeout(),this.deferred.reject(new O(P.CANCELLED,"Operation cancelled"+(e?": "+e:""))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget(()=>this.timerHandle!==null?(this.clearTimeout(),this.op().then(e=>this.deferred.resolve(e))):Promise.resolve())}clearTimeout(){this.timerHandle!==null&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}}function ra(n,e){if(dt("AsyncQueue",`${e}: ${n}`),Mn(n))return new O(P.UNAVAILABLE,`${e}: ${n}`);throw n}/**
2884
+ * @license
2885
+ * Copyright 2017 Google LLC
2886
+ *
2887
+ * Licensed under the Apache License, Version 2.0 (the "License");
2888
+ * you may not use this file except in compliance with the License.
2889
+ * You may obtain a copy of the License at
2890
+ *
2891
+ * http://www.apache.org/licenses/LICENSE-2.0
2892
+ *
2893
+ * Unless required by applicable law or agreed to in writing, software
2894
+ * distributed under the License is distributed on an "AS IS" BASIS,
2895
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2896
+ * See the License for the specific language governing permissions and
2897
+ * limitations under the License.
2898
+ */class In{static emptySet(e){return new In(e.comparator)}constructor(e){this.comparator=e?(t,r)=>e(t,r)||L.comparator(t.key,r.key):(t,r)=>L.comparator(t.key,r.key),this.keyedMap=ar(),this.sortedSet=new ne(this.comparator)}has(e){return this.keyedMap.get(e)!=null}get(e){return this.keyedMap.get(e)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(e){const t=this.keyedMap.get(e);return t?this.sortedSet.indexOf(t):-1}get size(){return this.sortedSet.size}forEach(e){this.sortedSet.inorderTraversal((t,r)=>(e(t),!1))}add(e){const t=this.delete(e.key);return t.copy(t.keyedMap.insert(e.key,e),t.sortedSet.insert(e,null))}delete(e){const t=this.get(e);return t?this.copy(this.keyedMap.remove(e),this.sortedSet.remove(t)):this}isEqual(e){if(!(e instanceof In)||this.size!==e.size)return!1;const t=this.sortedSet.getIterator(),r=e.sortedSet.getIterator();for(;t.hasNext();){const s=t.getNext().key,i=r.getNext().key;if(!s.isEqual(i))return!1}return!0}toString(){const e=[];return this.forEach(t=>{e.push(t.toString())}),e.length===0?"DocumentSet ()":`DocumentSet (
2899
+ `+e.join(`
2900
+ `)+`
2901
+ )`}copy(e,t){const r=new In;return r.comparator=this.comparator,r.keyedMap=e,r.sortedSet=t,r}}/**
2902
+ * @license
2903
+ * Copyright 2017 Google LLC
2904
+ *
2905
+ * Licensed under the Apache License, Version 2.0 (the "License");
2906
+ * you may not use this file except in compliance with the License.
2907
+ * You may obtain a copy of the License at
2908
+ *
2909
+ * http://www.apache.org/licenses/LICENSE-2.0
2910
+ *
2911
+ * Unless required by applicable law or agreed to in writing, software
2912
+ * distributed under the License is distributed on an "AS IS" BASIS,
2913
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2914
+ * See the License for the specific language governing permissions and
2915
+ * limitations under the License.
2916
+ */class ju{constructor(){this.Z_=new ne(L.comparator)}track(e){const t=e.doc.key,r=this.Z_.get(t);r?e.type!==0&&r.type===3?this.Z_=this.Z_.insert(t,e):e.type===3&&r.type!==1?this.Z_=this.Z_.insert(t,{type:r.type,doc:e.doc}):e.type===2&&r.type===2?this.Z_=this.Z_.insert(t,{type:2,doc:e.doc}):e.type===2&&r.type===0?this.Z_=this.Z_.insert(t,{type:0,doc:e.doc}):e.type===1&&r.type===0?this.Z_=this.Z_.remove(t):e.type===1&&r.type===2?this.Z_=this.Z_.insert(t,{type:1,doc:r.doc}):e.type===0&&r.type===1?this.Z_=this.Z_.insert(t,{type:2,doc:e.doc}):U():this.Z_=this.Z_.insert(t,e)}X_(){const e=[];return this.Z_.inorderTraversal((t,r)=>{e.push(r)}),e}}class Nn{constructor(e,t,r,s,i,a,c,l,d){this.query=e,this.docs=t,this.oldDocs=r,this.docChanges=s,this.mutatedKeys=i,this.fromCache=a,this.syncStateChanged=c,this.excludesMetadataChanges=l,this.hasCachedResults=d}static fromInitialDocuments(e,t,r,s,i){const a=[];return t.forEach(c=>{a.push({type:0,doc:c})}),new Nn(e,t,In.emptySet(t),a,r,s,!0,!1,i)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(e){if(!(this.fromCache===e.fromCache&&this.hasCachedResults===e.hasCachedResults&&this.syncStateChanged===e.syncStateChanged&&this.mutatedKeys.isEqual(e.mutatedKeys)&&ti(this.query,e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;const t=this.docChanges,r=e.docChanges;if(t.length!==r.length)return!1;for(let s=0;s<t.length;s++)if(t[s].type!==r[s].type||!t[s].doc.isEqual(r[s].doc))return!1;return!0}}/**
2917
+ * @license
2918
+ * Copyright 2017 Google LLC
2919
+ *
2920
+ * Licensed under the Apache License, Version 2.0 (the "License");
2921
+ * you may not use this file except in compliance with the License.
2922
+ * You may obtain a copy of the License at
2923
+ *
2924
+ * http://www.apache.org/licenses/LICENSE-2.0
2925
+ *
2926
+ * Unless required by applicable law or agreed to in writing, software
2927
+ * distributed under the License is distributed on an "AS IS" BASIS,
2928
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2929
+ * See the License for the specific language governing permissions and
2930
+ * limitations under the License.
2931
+ */class EE{constructor(){this.ea=void 0,this.ta=[]}na(){return this.ta.some(e=>e.ra())}}class vE{constructor(){this.queries=Hu(),this.onlineState="Unknown",this.ia=new Set}terminate(){(function(t,r){const s=q(t),i=s.queries;s.queries=Hu(),i.forEach((a,c)=>{for(const l of c.ta)l.onError(r)})})(this,new O(P.ABORTED,"Firestore shutting down"))}}function Hu(){return new sn(n=>Ph(n),ti)}async function sa(n,e){const t=q(n);let r=3;const s=e.query;let i=t.queries.get(s);i?!i.na()&&e.ra()&&(r=2):(i=new EE,r=e.ra()?0:1);try{switch(r){case 0:i.ea=await t.onListen(s,!0);break;case 1:i.ea=await t.onListen(s,!1);break;case 2:await t.onFirstRemoteStoreListen(s)}}catch(a){const c=ra(a,`Initialization of query '${mn(e.query)}' failed`);return void e.onError(c)}t.queries.set(s,i),i.ta.push(e),e.sa(t.onlineState),i.ea&&e.oa(i.ea)&&oa(t)}async function ia(n,e){const t=q(n),r=e.query;let s=3;const i=t.queries.get(r);if(i){const a=i.ta.indexOf(e);a>=0&&(i.ta.splice(a,1),i.ta.length===0?s=e.ra()?0:1:!i.na()&&e.ra()&&(s=2))}switch(s){case 0:return t.queries.delete(r),t.onUnlisten(r,!0);case 1:return t.queries.delete(r),t.onUnlisten(r,!1);case 2:return t.onLastRemoteStoreUnlisten(r);default:return}}function IE(n,e){const t=q(n);let r=!1;for(const s of e){const i=s.query,a=t.queries.get(i);if(a){for(const c of a.ta)c.oa(s)&&(r=!0);a.ea=s}}r&&oa(t)}function wE(n,e,t){const r=q(n),s=r.queries.get(e);if(s)for(const i of s.ta)i.onError(t);r.queries.delete(e)}function oa(n){n.ia.forEach(e=>{e.next()})}var To,zu;(zu=To||(To={}))._a="default",zu.Cache="cache";class aa{constructor(e,t,r){this.query=e,this.aa=t,this.ua=!1,this.ca=null,this.onlineState="Unknown",this.options=r||{}}oa(e){if(!this.options.includeMetadataChanges){const r=[];for(const s of e.docChanges)s.type!==3&&r.push(s);e=new Nn(e.query,e.docs,e.oldDocs,r,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let t=!1;return this.ua?this.la(e)&&(this.aa.next(e),t=!0):this.ha(e,this.onlineState)&&(this.Pa(e),t=!0),this.ca=e,t}onError(e){this.aa.error(e)}sa(e){this.onlineState=e;let t=!1;return this.ca&&!this.ua&&this.ha(this.ca,e)&&(this.Pa(this.ca),t=!0),t}ha(e,t){if(!e.fromCache||!this.ra())return!0;const r=t!=="Offline";return(!this.options.Ta||!r)&&(!e.docs.isEmpty()||e.hasCachedResults||t==="Offline")}la(e){if(e.docChanges.length>0)return!0;const t=this.ca&&this.ca.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&this.options.includeMetadataChanges===!0}Pa(e){e=Nn.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.ua=!0,this.aa.next(e)}ra(){return this.options.source!==To.Cache}}/**
2932
+ * @license
2933
+ * Copyright 2017 Google LLC
2934
+ *
2935
+ * Licensed under the Apache License, Version 2.0 (the "License");
2936
+ * you may not use this file except in compliance with the License.
2937
+ * You may obtain a copy of the License at
2938
+ *
2939
+ * http://www.apache.org/licenses/LICENSE-2.0
2940
+ *
2941
+ * Unless required by applicable law or agreed to in writing, software
2942
+ * distributed under the License is distributed on an "AS IS" BASIS,
2943
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2944
+ * See the License for the specific language governing permissions and
2945
+ * limitations under the License.
2946
+ */class ad{constructor(e){this.key=e}}class cd{constructor(e){this.key=e}}class AE{constructor(e,t){this.query=e,this.fa=t,this.ga=null,this.hasCachedResults=!1,this.current=!1,this.pa=G(),this.mutatedKeys=G(),this.ya=Sh(e),this.wa=new In(this.ya)}get Sa(){return this.fa}ba(e,t){const r=t?t.Da:new ju,s=t?t.wa:this.wa;let i=t?t.mutatedKeys:this.mutatedKeys,a=s,c=!1;const l=this.query.limitType==="F"&&s.size===this.query.limit?s.last():null,d=this.query.limitType==="L"&&s.size===this.query.limit?s.first():null;if(e.inorderTraversal((f,m)=>{const E=s.get(f),R=ni(this.query,m)?m:null,C=!!E&&this.mutatedKeys.has(E.key),N=!!R&&(R.hasLocalMutations||this.mutatedKeys.has(R.key)&&R.hasCommittedMutations);let k=!1;E&&R?E.data.isEqual(R.data)?C!==N&&(r.track({type:3,doc:R}),k=!0):this.va(E,R)||(r.track({type:2,doc:R}),k=!0,(l&&this.ya(R,l)>0||d&&this.ya(R,d)<0)&&(c=!0)):!E&&R?(r.track({type:0,doc:R}),k=!0):E&&!R&&(r.track({type:1,doc:E}),k=!0,(l||d)&&(c=!0)),k&&(R?(a=a.add(R),i=N?i.add(f):i.delete(f)):(a=a.delete(f),i=i.delete(f)))}),this.query.limit!==null)for(;a.size>this.query.limit;){const f=this.query.limitType==="F"?a.last():a.first();a=a.delete(f.key),i=i.delete(f.key),r.track({type:1,doc:f})}return{wa:a,Da:r,ls:c,mutatedKeys:i}}va(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}applyChanges(e,t,r,s){const i=this.wa;this.wa=e.wa,this.mutatedKeys=e.mutatedKeys;const a=e.Da.X_();a.sort((f,m)=>function(R,C){const N=k=>{switch(k){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return U()}};return N(R)-N(C)}(f.type,m.type)||this.ya(f.doc,m.doc)),this.Ca(r),s=s!=null&&s;const c=t&&!s?this.Fa():[],l=this.pa.size===0&&this.current&&!s?1:0,d=l!==this.ga;return this.ga=l,a.length!==0||d?{snapshot:new Nn(this.query,e.wa,i,a,e.mutatedKeys,l===0,d,!1,!!r&&r.resumeToken.approximateByteSize()>0),Ma:c}:{Ma:c}}sa(e){return this.current&&e==="Offline"?(this.current=!1,this.applyChanges({wa:this.wa,Da:new ju,mutatedKeys:this.mutatedKeys,ls:!1},!1)):{Ma:[]}}xa(e){return!this.fa.has(e)&&!!this.wa.has(e)&&!this.wa.get(e).hasLocalMutations}Ca(e){e&&(e.addedDocuments.forEach(t=>this.fa=this.fa.add(t)),e.modifiedDocuments.forEach(t=>{}),e.removedDocuments.forEach(t=>this.fa=this.fa.delete(t)),this.current=e.current)}Fa(){if(!this.current)return[];const e=this.pa;this.pa=G(),this.wa.forEach(r=>{this.xa(r.key)&&(this.pa=this.pa.add(r.key))});const t=[];return e.forEach(r=>{this.pa.has(r)||t.push(new cd(r))}),this.pa.forEach(r=>{e.has(r)||t.push(new ad(r))}),t}Oa(e){this.fa=e.gs,this.pa=G();const t=this.ba(e.documents);return this.applyChanges(t,!0)}Na(){return Nn.fromInitialDocuments(this.query,this.wa,this.mutatedKeys,this.ga===0,this.hasCachedResults)}}const ca="SyncEngine";class RE{constructor(e,t,r){this.query=e,this.targetId=t,this.view=r}}class bE{constructor(e){this.key=e,this.Ba=!1}}class PE{constructor(e,t,r,s,i,a){this.localStore=e,this.remoteStore=t,this.eventManager=r,this.sharedClientState=s,this.currentUser=i,this.maxConcurrentLimboResolutions=a,this.La={},this.ka=new sn(c=>Ph(c),ti),this.qa=new Map,this.Qa=new Set,this.$a=new ne(L.comparator),this.Ua=new Map,this.Ka=new Ko,this.Wa={},this.Ga=new Map,this.za=kn.Kn(),this.onlineState="Unknown",this.ja=void 0}get isPrimaryClient(){return this.ja===!0}}async function SE(n,e,t=!0){const r=pd(n);let s;const i=r.ka.get(e);return i?(r.sharedClientState.addLocalQueryTarget(i.targetId),s=i.view.Na()):s=await ud(r,e,t,!0),s}async function CE(n,e){const t=pd(n);await ud(t,e,!0,!1)}async function ud(n,e,t,r){const s=await QT(n.localStore,Qe(e)),i=s.targetId,a=n.sharedClientState.addLocalQueryTarget(i,t);let c;return r&&(c=await kE(n,e,i,a==="current",s.resumeToken)),n.isPrimaryClient&&t&&td(n.remoteStore,s),c}async function kE(n,e,t,r,s){n.Ha=(m,E,R)=>async function(N,k,F,$){let M=k.view.ba(F);M.ls&&(M=await xu(N.localStore,k.query,!1).then(({documents:v})=>k.view.ba(v,M)));const j=$&&$.targetChanges.get(k.targetId),ce=$&&$.targetMismatches.get(k.targetId)!=null,X=k.view.applyChanges(M,N.isPrimaryClient,j,ce);return Wu(N,k.targetId,X.Ma),X.snapshot}(n,m,E,R);const i=await xu(n.localStore,e,!0),a=new AE(e,i.gs),c=a.ba(i.documents),l=Or.createSynthesizedTargetChangeForCurrentChange(t,r&&n.onlineState!=="Offline",s),d=a.applyChanges(c,n.isPrimaryClient,l);Wu(n,t,d.Ma);const f=new RE(e,t,a);return n.ka.set(e,f),n.qa.has(t)?n.qa.get(t).push(e):n.qa.set(t,[e]),d.snapshot}async function NE(n,e,t){const r=q(n),s=r.ka.get(e),i=r.qa.get(s.targetId);if(i.length>1)return r.qa.set(s.targetId,i.filter(a=>!ti(a,e))),void r.ka.delete(e);r.isPrimaryClient?(r.sharedClientState.removeLocalQueryTarget(s.targetId),r.sharedClientState.isActiveQueryTarget(s.targetId)||await _o(r.localStore,s.targetId,!1).then(()=>{r.sharedClientState.clearQueryState(s.targetId),t&&Yo(r.remoteStore,s.targetId),Eo(r,s.targetId)}).catch(Ln)):(Eo(r,s.targetId),await _o(r.localStore,s.targetId,!0))}async function DE(n,e){const t=q(n),r=t.ka.get(e),s=t.qa.get(r.targetId);t.isPrimaryClient&&s.length===1&&(t.sharedClientState.removeLocalQueryTarget(r.targetId),Yo(t.remoteStore,r.targetId))}async function OE(n,e,t){const r=BE(n);try{const s=await function(a,c){const l=q(a),d=ue.now(),f=c.reduce((R,C)=>R.add(C.key),G());let m,E;return l.persistence.runTransaction("Locally write mutations","readwrite",R=>{let C=ft(),N=G();return l.ds.getEntries(R,f).next(k=>{C=k,C.forEach((F,$)=>{$.isValidDocument()||(N=N.add(F))})}).next(()=>l.localDocuments.getOverlayedDocuments(R,C)).next(k=>{m=k;const F=[];for(const $ of c){const M=Qy($,m.get($.key).overlayedDocument);M!=null&&F.push(new on($.key,M,Eh(M.value.mapValue),Xe.exists(!0)))}return l.mutationQueue.addMutationBatch(R,d,F,c)}).next(k=>{E=k;const F=k.applyToLocalDocumentSet(m,N);return l.documentOverlayCache.saveOverlays(R,k.batchId,F)})}).then(()=>({batchId:E.batchId,changes:kh(m)}))}(r.localStore,e);r.sharedClientState.addPendingMutation(s.batchId),function(a,c,l){let d=a.Wa[a.currentUser.toKey()];d||(d=new ne(H)),d=d.insert(c,l),a.Wa[a.currentUser.toKey()]=d}(r,s.batchId,t),await Lr(r,s.changes),await ci(r.remoteStore)}catch(s){const i=ra(s,"Failed to persist write");t.reject(i)}}async function ld(n,e){const t=q(n);try{const r=await GT(t.localStore,e);e.targetChanges.forEach((s,i)=>{const a=t.Ua.get(i);a&&(Q(s.addedDocuments.size+s.modifiedDocuments.size+s.removedDocuments.size<=1),s.addedDocuments.size>0?a.Ba=!0:s.modifiedDocuments.size>0?Q(a.Ba):s.removedDocuments.size>0&&(Q(a.Ba),a.Ba=!1))}),await Lr(t,r,e)}catch(r){await Ln(r)}}function Gu(n,e,t){const r=q(n);if(r.isPrimaryClient&&t===0||!r.isPrimaryClient&&t===1){const s=[];r.ka.forEach((i,a)=>{const c=a.view.sa(e);c.snapshot&&s.push(c.snapshot)}),function(a,c){const l=q(a);l.onlineState=c;let d=!1;l.queries.forEach((f,m)=>{for(const E of m.ta)E.sa(c)&&(d=!0)}),d&&oa(l)}(r.eventManager,e),s.length&&r.La.p_(s),r.onlineState=e,r.isPrimaryClient&&r.sharedClientState.setOnlineState(e)}}async function VE(n,e,t){const r=q(n);r.sharedClientState.updateQueryState(e,"rejected",t);const s=r.Ua.get(e),i=s&&s.key;if(i){let a=new ne(L.comparator);a=a.insert(i,Ie.newNoDocument(i,B.min()));const c=G().add(i),l=new ii(B.min(),new Map,new ne(H),a,c);await ld(r,l),r.$a=r.$a.remove(i),r.Ua.delete(e),ua(r)}else await _o(r.localStore,e,!1).then(()=>Eo(r,e,t)).catch(Ln)}async function LE(n,e){const t=q(n),r=e.batch.batchId;try{const s=await zT(t.localStore,e);dd(t,r,null),hd(t,r),t.sharedClientState.updateMutationState(r,"acknowledged"),await Lr(t,s)}catch(s){await Ln(s)}}async function ME(n,e,t){const r=q(n);try{const s=await function(a,c){const l=q(a);return l.persistence.runTransaction("Reject batch","readwrite-primary",d=>{let f;return l.mutationQueue.lookupMutationBatch(d,c).next(m=>(Q(m!==null),f=m.keys(),l.mutationQueue.removeMutationBatch(d,m))).next(()=>l.mutationQueue.performConsistencyCheck(d)).next(()=>l.documentOverlayCache.removeOverlaysForBatchId(d,f,c)).next(()=>l.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(d,f)).next(()=>l.localDocuments.getDocuments(d,f))})}(r.localStore,e);dd(r,e,t),hd(r,e),r.sharedClientState.updateMutationState(e,"rejected",t),await Lr(r,s)}catch(s){await Ln(s)}}function hd(n,e){(n.Ga.get(e)||[]).forEach(t=>{t.resolve()}),n.Ga.delete(e)}function dd(n,e,t){const r=q(n);let s=r.Wa[r.currentUser.toKey()];if(s){const i=s.get(e);i&&(t?i.reject(t):i.resolve(),s=s.remove(e)),r.Wa[r.currentUser.toKey()]=s}}function Eo(n,e,t=null){n.sharedClientState.removeLocalQueryTarget(e);for(const r of n.qa.get(e))n.ka.delete(r),t&&n.La.Ja(r,t);n.qa.delete(e),n.isPrimaryClient&&n.Ka.br(e).forEach(r=>{n.Ka.containsKey(r)||fd(n,r)})}function fd(n,e){n.Qa.delete(e.path.canonicalString());const t=n.$a.get(e);t!==null&&(Yo(n.remoteStore,t),n.$a=n.$a.remove(e),n.Ua.delete(t),ua(n))}function Wu(n,e,t){for(const r of t)r instanceof ad?(n.Ka.addReference(r.key,e),xE(n,r)):r instanceof cd?(V(ca,"Document no longer in limbo: "+r.key),n.Ka.removeReference(r.key,e),n.Ka.containsKey(r.key)||fd(n,r.key)):U()}function xE(n,e){const t=e.key,r=t.path.canonicalString();n.$a.get(t)||n.Qa.has(r)||(V(ca,"New document in limbo: "+t),n.Qa.add(r),ua(n))}function ua(n){for(;n.Qa.size>0&&n.$a.size<n.maxConcurrentLimboResolutions;){const e=n.Qa.values().next().value;n.Qa.delete(e);const t=new L(Y.fromString(e)),r=n.za.next();n.Ua.set(r,new bE(t)),n.$a=n.$a.insert(t,r),td(n.remoteStore,new At(Qe(ei(t.path)),r,"TargetPurposeLimboResolution",Xs.ae))}}async function Lr(n,e,t){const r=q(n),s=[],i=[],a=[];r.ka.isEmpty()||(r.ka.forEach((c,l)=>{a.push(r.Ha(l,e,t).then(d=>{var f;if((d||t)&&r.isPrimaryClient){const m=d?!d.fromCache:(f=t==null?void 0:t.targetChanges.get(l.targetId))===null||f===void 0?void 0:f.current;r.sharedClientState.updateQueryState(l.targetId,m?"current":"not-current")}if(d){s.push(d);const m=Xo.Yi(l.targetId,d);i.push(m)}}))}),await Promise.all(a),r.La.p_(s),await async function(l,d){const f=q(l);try{await f.persistence.runTransaction("notifyLocalViewChanges","readwrite",m=>S.forEach(d,E=>S.forEach(E.Hi,R=>f.persistence.referenceDelegate.addReference(m,E.targetId,R)).next(()=>S.forEach(E.Ji,R=>f.persistence.referenceDelegate.removeReference(m,E.targetId,R)))))}catch(m){if(!Mn(m))throw m;V(Jo,"Failed to update sequence numbers: "+m)}for(const m of d){const E=m.targetId;if(!m.fromCache){const R=f.Ts.get(E),C=R.snapshotVersion,N=R.withLastLimboFreeSnapshotVersion(C);f.Ts=f.Ts.insert(E,N)}}}(r.localStore,i))}async function UE(n,e){const t=q(n);if(!t.currentUser.isEqual(e)){V(ca,"User change. New user:",e.toKey());const r=await Jh(t.localStore,e);t.currentUser=e,function(i,a){i.Ga.forEach(c=>{c.forEach(l=>{l.reject(new O(P.CANCELLED,a))})}),i.Ga.clear()}(t,"'waitForPendingWrites' promise is rejected due to a user change."),t.sharedClientState.handleUserChange(e,r.removedBatchIds,r.addedBatchIds),await Lr(t,r.Rs)}}function FE(n,e){const t=q(n),r=t.Ua.get(e);if(r&&r.Ba)return G().add(r.key);{let s=G();const i=t.qa.get(e);if(!i)return s;for(const a of i){const c=t.ka.get(a);s=s.unionWith(c.view.Sa)}return s}}function pd(n){const e=q(n);return e.remoteStore.remoteSyncer.applyRemoteEvent=ld.bind(null,e),e.remoteStore.remoteSyncer.getRemoteKeysForTarget=FE.bind(null,e),e.remoteStore.remoteSyncer.rejectListen=VE.bind(null,e),e.La.p_=IE.bind(null,e.eventManager),e.La.Ja=wE.bind(null,e.eventManager),e}function BE(n){const e=q(n);return e.remoteStore.remoteSyncer.applySuccessfulWrite=LE.bind(null,e),e.remoteStore.remoteSyncer.rejectFailedWrite=ME.bind(null,e),e}class qs{constructor(){this.kind="memory",this.synchronizeTabs=!1}async initialize(e){this.serializer=oi(e.databaseInfo.databaseId),this.sharedClientState=this.Za(e),this.persistence=this.Xa(e),await this.persistence.start(),this.localStore=this.eu(e),this.gcScheduler=this.tu(e,this.localStore),this.indexBackfillerScheduler=this.nu(e,this.localStore)}tu(e,t){return null}nu(e,t){return null}eu(e){return HT(this.persistence,new qT,e.initialUser,this.serializer)}Xa(e){return new Xh(Qo.ri,this.serializer)}Za(e){return new JT}async terminate(){var e,t;(e=this.gcScheduler)===null||e===void 0||e.stop(),(t=this.indexBackfillerScheduler)===null||t===void 0||t.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}}qs.provider={build:()=>new qs};class qE extends qs{constructor(e){super(),this.cacheSizeBytes=e}tu(e,t){Q(this.persistence.referenceDelegate instanceof Fs);const r=this.persistence.referenceDelegate.garbageCollector;return new bT(r,e.asyncQueue,t)}Xa(e){const t=this.cacheSizeBytes!==void 0?Ce.withCacheSize(this.cacheSizeBytes):Ce.DEFAULT;return new Xh(r=>Fs.ri(r,t),this.serializer)}}class vo{async initialize(e,t){this.localStore||(this.localStore=e.localStore,this.sharedClientState=e.sharedClientState,this.datastore=this.createDatastore(t),this.remoteStore=this.createRemoteStore(t),this.eventManager=this.createEventManager(t),this.syncEngine=this.createSyncEngine(t,!e.synchronizeTabs),this.sharedClientState.onlineStateHandler=r=>Gu(this.syncEngine,r,1),this.remoteStore.remoteSyncer.handleCredentialChange=UE.bind(null,this.syncEngine),await TE(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return function(){return new vE}()}createDatastore(e){const t=oi(e.databaseInfo.databaseId),r=function(i){return new nE(i)}(e.databaseInfo);return function(i,a,c,l){return new oE(i,a,c,l)}(e.authCredentials,e.appCheckCredentials,r,t)}createRemoteStore(e){return function(r,s,i,a,c){return new cE(r,s,i,a,c)}(this.localStore,this.datastore,e.asyncQueue,t=>Gu(this.syncEngine,t,0),function(){return Bu.D()?new Bu:new YT}())}createSyncEngine(e,t){return function(s,i,a,c,l,d,f){const m=new PE(s,i,a,c,l,d);return f&&(m.ja=!0),m}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,e.initialUser,e.maxConcurrentLimboResolutions,t)}async terminate(){var e,t;await async function(s){const i=q(s);V(Zt,"RemoteStore shutting down."),i.W_.add(5),await Vr(i),i.z_.shutdown(),i.j_.set("Unknown")}(this.remoteStore),(e=this.datastore)===null||e===void 0||e.terminate(),(t=this.eventManager)===null||t===void 0||t.terminate()}}vo.provider={build:()=>new vo};/**
2947
+ * @license
2948
+ * Copyright 2020 Google LLC
2949
+ *
2950
+ * Licensed under the Apache License, Version 2.0 (the "License");
2951
+ * you may not use this file except in compliance with the License.
2952
+ * You may obtain a copy of the License at
2953
+ *
2954
+ * http://www.apache.org/licenses/LICENSE-2.0
2955
+ *
2956
+ * Unless required by applicable law or agreed to in writing, software
2957
+ * distributed under the License is distributed on an "AS IS" BASIS,
2958
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2959
+ * See the License for the specific language governing permissions and
2960
+ * limitations under the License.
2961
+ *//**
2962
+ * @license
2963
+ * Copyright 2017 Google LLC
2964
+ *
2965
+ * Licensed under the Apache License, Version 2.0 (the "License");
2966
+ * you may not use this file except in compliance with the License.
2967
+ * You may obtain a copy of the License at
2968
+ *
2969
+ * http://www.apache.org/licenses/LICENSE-2.0
2970
+ *
2971
+ * Unless required by applicable law or agreed to in writing, software
2972
+ * distributed under the License is distributed on an "AS IS" BASIS,
2973
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2974
+ * See the License for the specific language governing permissions and
2975
+ * limitations under the License.
2976
+ */class la{constructor(e){this.observer=e,this.muted=!1}next(e){this.muted||this.observer.next&&this.iu(this.observer.next,e)}error(e){this.muted||(this.observer.error?this.iu(this.observer.error,e):dt("Uncaught Error in snapshot listener:",e.toString()))}su(){this.muted=!0}iu(e,t){setTimeout(()=>{this.muted||e(t)},0)}}/**
2977
+ * @license
2978
+ * Copyright 2017 Google LLC
2979
+ *
2980
+ * Licensed under the Apache License, Version 2.0 (the "License");
2981
+ * you may not use this file except in compliance with the License.
2982
+ * You may obtain a copy of the License at
2983
+ *
2984
+ * http://www.apache.org/licenses/LICENSE-2.0
2985
+ *
2986
+ * Unless required by applicable law or agreed to in writing, software
2987
+ * distributed under the License is distributed on an "AS IS" BASIS,
2988
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2989
+ * See the License for the specific language governing permissions and
2990
+ * limitations under the License.
2991
+ */const Vt="FirestoreClient";class $E{constructor(e,t,r,s,i){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=r,this.databaseInfo=s,this.user=ve.UNAUTHENTICATED,this.clientId=lh.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=i,this.authCredentials.start(r,async a=>{V(Vt,"Received user=",a.uid),await this.authCredentialListener(a),this.user=a}),this.appCheckCredentials.start(r,a=>(V(Vt,"Received new app check token=",a),this.appCheckCredentialListener(a,this.user)))}get configuration(){return{asyncQueue:this.asyncQueue,databaseInfo:this.databaseInfo,clientId:this.clientId,authCredentials:this.authCredentials,appCheckCredentials:this.appCheckCredentials,initialUser:this.user,maxConcurrentLimboResolutions:100}}setCredentialChangeListener(e){this.authCredentialListener=e}setAppCheckTokenChangeListener(e){this.appCheckCredentialListener=e}terminate(){this.asyncQueue.enterRestrictedMode();const e=new at;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted(async()=>{try{this._onlineComponents&&await this._onlineComponents.terminate(),this._offlineComponents&&await this._offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),e.resolve()}catch(t){const r=ra(t,"Failed to shutdown persistence");e.reject(r)}}),e.promise}}async function Ki(n,e){n.asyncQueue.verifyOperationInProgress(),V(Vt,"Initializing OfflineComponentProvider");const t=n.configuration;await e.initialize(t);let r=t.initialUser;n.setCredentialChangeListener(async s=>{r.isEqual(s)||(await Jh(e.localStore,s),r=s)}),e.persistence.setDatabaseDeletedListener(()=>n.terminate()),n._offlineComponents=e}async function Ku(n,e){n.asyncQueue.verifyOperationInProgress();const t=await jE(n);V(Vt,"Initializing OnlineComponentProvider"),await e.initialize(t,n.configuration),n.setCredentialChangeListener(r=>$u(e.remoteStore,r)),n.setAppCheckTokenChangeListener((r,s)=>$u(e.remoteStore,s)),n._onlineComponents=e}async function jE(n){if(!n._offlineComponents)if(n._uninitializedComponentsProvider){V(Vt,"Using user provided OfflineComponentProvider");try{await Ki(n,n._uninitializedComponentsProvider._offline)}catch(e){const t=e;if(!function(s){return s.name==="FirebaseError"?s.code===P.FAILED_PRECONDITION||s.code===P.UNIMPLEMENTED:!(typeof DOMException<"u"&&s instanceof DOMException)||s.code===22||s.code===20||s.code===11}(t))throw t;Rn("Error using user provided cache. Falling back to memory cache: "+t),await Ki(n,new qs)}}else V(Vt,"Using default OfflineComponentProvider"),await Ki(n,new qE(void 0));return n._offlineComponents}async function md(n){return n._onlineComponents||(n._uninitializedComponentsProvider?(V(Vt,"Using user provided OnlineComponentProvider"),await Ku(n,n._uninitializedComponentsProvider._online)):(V(Vt,"Using default OnlineComponentProvider"),await Ku(n,new vo))),n._onlineComponents}function HE(n){return md(n).then(e=>e.syncEngine)}async function $s(n){const e=await md(n),t=e.eventManager;return t.onListen=SE.bind(null,e.syncEngine),t.onUnlisten=NE.bind(null,e.syncEngine),t.onFirstRemoteStoreListen=CE.bind(null,e.syncEngine),t.onLastRemoteStoreUnlisten=DE.bind(null,e.syncEngine),t}function zE(n,e,t={}){const r=new at;return n.asyncQueue.enqueueAndForget(async()=>function(i,a,c,l,d){const f=new la({next:E=>{f.su(),a.enqueueAndForget(()=>ia(i,m));const R=E.docs.has(c);!R&&E.fromCache?d.reject(new O(P.UNAVAILABLE,"Failed to get document because the client is offline.")):R&&E.fromCache&&l&&l.source==="server"?d.reject(new O(P.UNAVAILABLE,'Failed to get document from server. (However, this document does exist in the local cache. Run again without setting source to "server" to retrieve the cached document.)')):d.resolve(E)},error:E=>d.reject(E)}),m=new aa(ei(c.path),f,{includeMetadataChanges:!0,Ta:!0});return sa(i,m)}(await $s(n),n.asyncQueue,e,t,r)),r.promise}function GE(n,e,t={}){const r=new at;return n.asyncQueue.enqueueAndForget(async()=>function(i,a,c,l,d){const f=new la({next:E=>{f.su(),a.enqueueAndForget(()=>ia(i,m)),E.fromCache&&l.source==="server"?d.reject(new O(P.UNAVAILABLE,'Failed to get documents from server. (However, these documents may exist in the local cache. Run again without setting source to "server" to retrieve the cached documents.)')):d.resolve(E)},error:E=>d.reject(E)}),m=new aa(c,f,{includeMetadataChanges:!0,Ta:!0});return sa(i,m)}(await $s(n),n.asyncQueue,e,t,r)),r.promise}/**
2992
+ * @license
2993
+ * Copyright 2023 Google LLC
2994
+ *
2995
+ * Licensed under the Apache License, Version 2.0 (the "License");
2996
+ * you may not use this file except in compliance with the License.
2997
+ * You may obtain a copy of the License at
2998
+ *
2999
+ * http://www.apache.org/licenses/LICENSE-2.0
3000
+ *
3001
+ * Unless required by applicable law or agreed to in writing, software
3002
+ * distributed under the License is distributed on an "AS IS" BASIS,
3003
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3004
+ * See the License for the specific language governing permissions and
3005
+ * limitations under the License.
3006
+ */function gd(n){const e={};return n.timeoutSeconds!==void 0&&(e.timeoutSeconds=n.timeoutSeconds),e}/**
3007
+ * @license
3008
+ * Copyright 2020 Google LLC
3009
+ *
3010
+ * Licensed under the Apache License, Version 2.0 (the "License");
3011
+ * you may not use this file except in compliance with the License.
3012
+ * You may obtain a copy of the License at
3013
+ *
3014
+ * http://www.apache.org/licenses/LICENSE-2.0
3015
+ *
3016
+ * Unless required by applicable law or agreed to in writing, software
3017
+ * distributed under the License is distributed on an "AS IS" BASIS,
3018
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3019
+ * See the License for the specific language governing permissions and
3020
+ * limitations under the License.
3021
+ */const Qu=new Map;/**
3022
+ * @license
3023
+ * Copyright 2017 Google LLC
3024
+ *
3025
+ * Licensed under the Apache License, Version 2.0 (the "License");
3026
+ * you may not use this file except in compliance with the License.
3027
+ * You may obtain a copy of the License at
3028
+ *
3029
+ * http://www.apache.org/licenses/LICENSE-2.0
3030
+ *
3031
+ * Unless required by applicable law or agreed to in writing, software
3032
+ * distributed under the License is distributed on an "AS IS" BASIS,
3033
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3034
+ * See the License for the specific language governing permissions and
3035
+ * limitations under the License.
3036
+ */function ha(n,e,t){if(!t)throw new O(P.INVALID_ARGUMENT,`Function ${n}() cannot be called with an empty ${e}.`)}function WE(n,e,t,r){if(e===!0&&r===!0)throw new O(P.INVALID_ARGUMENT,`${n} and ${t} cannot be used together.`)}function Xu(n){if(!L.isDocumentKey(n))throw new O(P.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${n} has ${n.length}.`)}function Ju(n){if(L.isDocumentKey(n))throw new O(P.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${n} has ${n.length}.`)}function ui(n){if(n===void 0)return"undefined";if(n===null)return"null";if(typeof n=="string")return n.length>20&&(n=`${n.substring(0,20)}...`),JSON.stringify(n);if(typeof n=="number"||typeof n=="boolean")return""+n;if(typeof n=="object"){if(n instanceof Array)return"an array";{const e=function(r){return r.constructor?r.constructor.name:null}(n);return e?`a custom ${e} object`:"an object"}}return typeof n=="function"?"a function":U()}function Le(n,e){if("_delegate"in n&&(n=n._delegate),!(n instanceof e)){if(e.name===n.constructor.name)throw new O(P.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{const t=ui(n);throw new O(P.INVALID_ARGUMENT,`Expected type '${e.name}', but it was: ${t}`)}}return n}function _d(n,e){if(e<=0)throw new O(P.INVALID_ARGUMENT,`Function ${n}() requires a positive number, but it was: ${e}.`)}/**
3037
+ * @license
3038
+ * Copyright 2020 Google LLC
3039
+ *
3040
+ * Licensed under the Apache License, Version 2.0 (the "License");
3041
+ * you may not use this file except in compliance with the License.
3042
+ * You may obtain a copy of the License at
3043
+ *
3044
+ * http://www.apache.org/licenses/LICENSE-2.0
3045
+ *
3046
+ * Unless required by applicable law or agreed to in writing, software
3047
+ * distributed under the License is distributed on an "AS IS" BASIS,
3048
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3049
+ * See the License for the specific language governing permissions and
3050
+ * limitations under the License.
3051
+ */const yd="firestore.googleapis.com",Yu=!0;class Zu{constructor(e){var t,r;if(e.host===void 0){if(e.ssl!==void 0)throw new O(P.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host=yd,this.ssl=Yu}else this.host=e.host,this.ssl=(t=e.ssl)!==null&&t!==void 0?t:Yu;if(this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,this.localCache=e.localCache,e.cacheSizeBytes===void 0)this.cacheSizeBytes=Qh;else{if(e.cacheSizeBytes!==-1&&e.cacheSizeBytes<AT)throw new O(P.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}WE("experimentalForceLongPolling",e.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",e.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!e.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:e.experimentalAutoDetectLongPolling===void 0?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!e.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=gd((r=e.experimentalLongPollingOptions)!==null&&r!==void 0?r:{}),function(i){if(i.timeoutSeconds!==void 0){if(isNaN(i.timeoutSeconds))throw new O(P.INVALID_ARGUMENT,`invalid long polling timeout: ${i.timeoutSeconds} (must not be NaN)`);if(i.timeoutSeconds<5)throw new O(P.INVALID_ARGUMENT,`invalid long polling timeout: ${i.timeoutSeconds} (minimum allowed value is 5)`);if(i.timeoutSeconds>30)throw new O(P.INVALID_ARGUMENT,`invalid long polling timeout: ${i.timeoutSeconds} (maximum allowed value is 30)`)}}(this.experimentalLongPollingOptions),this.useFetchStreams=!!e.useFetchStreams}isEqual(e){return this.host===e.host&&this.ssl===e.ssl&&this.credentials===e.credentials&&this.cacheSizeBytes===e.cacheSizeBytes&&this.experimentalForceLongPolling===e.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===e.experimentalAutoDetectLongPolling&&function(r,s){return r.timeoutSeconds===s.timeoutSeconds}(this.experimentalLongPollingOptions,e.experimentalLongPollingOptions)&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams}}class Mr{constructor(e,t,r,s){this._authCredentials=e,this._appCheckCredentials=t,this._databaseId=r,this._app=s,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new Zu({}),this._settingsFrozen=!1,this._emulatorOptions={},this._terminateTask="notTerminated"}get app(){if(!this._app)throw new O(P.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app}get _initialized(){return this._settingsFrozen}get _terminated(){return this._terminateTask!=="notTerminated"}_setSettings(e){if(this._settingsFrozen)throw new O(P.FAILED_PRECONDITION,"Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.");this._settings=new Zu(e),this._emulatorOptions=e.emulatorOptions||{},e.credentials!==void 0&&(this._authCredentials=function(r){if(!r)return new ty;switch(r.type){case"firstParty":return new iy(r.sessionIndex||"0",r.iamToken||null,r.authTokenFactory||null);case"provider":return r.client;default:throw new O(P.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invalid credential type")}}(e.credentials))}_getSettings(){return this._settings}_getEmulatorOptions(){return this._emulatorOptions}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return this._terminateTask==="notTerminated"&&(this._terminateTask=this._terminate()),this._terminateTask}async _restart(){this._terminateTask==="notTerminated"?await this._terminate():this._terminateTask="notTerminated"}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return function(t){const r=Qu.get(t);r&&(V("ComponentProvider","Removing Datastore"),Qu.delete(t),r.terminate())}(this),Promise.resolve()}}function KE(n,e,t,r={}){var s;const i=(n=Le(n,Mr))._getSettings(),a=Object.assign(Object.assign({},i),{emulatorOptions:n._getEmulatorOptions()}),c=`${e}:${t}`;i.host!==yd&&i.host!==c&&Rn("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used.");const l=Object.assign(Object.assign({},i),{host:c,ssl:!1,emulatorOptions:r});if(!Qt(l,a)&&(n._setSettings(l),r.mockUserToken)){let d,f;if(typeof r.mockUserToken=="string")d=r.mockUserToken,f=ve.MOCK_USER;else{d=_l(r.mockUserToken,(s=n._app)===null||s===void 0?void 0:s.options.projectId);const m=r.mockUserToken.sub||r.mockUserToken.user_id;if(!m)throw new O(P.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");f=new ve(m)}n._authCredentials=new ny(new ch(d,f))}}/**
3052
+ * @license
3053
+ * Copyright 2020 Google LLC
3054
+ *
3055
+ * Licensed under the Apache License, Version 2.0 (the "License");
3056
+ * you may not use this file except in compliance with the License.
3057
+ * You may obtain a copy of the License at
3058
+ *
3059
+ * http://www.apache.org/licenses/LICENSE-2.0
3060
+ *
3061
+ * Unless required by applicable law or agreed to in writing, software
3062
+ * distributed under the License is distributed on an "AS IS" BASIS,
3063
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3064
+ * See the License for the specific language governing permissions and
3065
+ * limitations under the License.
3066
+ */class ze{constructor(e,t,r){this.converter=t,this._query=r,this.type="query",this.firestore=e}withConverter(e){return new ze(this.firestore,e,this._query)}}class Se{constructor(e,t,r){this.converter=t,this._key=r,this.type="document",this.firestore=e}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new Pt(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new Se(this.firestore,e,this._key)}}class Pt extends ze{constructor(e,t,r){super(e,t,ei(r)),this._path=r,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){const e=this._path.popLast();return e.isEmpty()?null:new Se(this.firestore,null,new L(e))}withConverter(e){return new Pt(this.firestore,e,this._path)}}function Td(n,e,...t){if(n=Z(n),ha("collection","path",e),n instanceof Mr){const r=Y.fromString(e,...t);return Ju(r),new Pt(n,null,r)}{if(!(n instanceof Se||n instanceof Pt))throw new O(P.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=n._path.child(Y.fromString(e,...t));return Ju(r),new Pt(n.firestore,null,r)}}function Ed(n,e){if(n=Le(n,Mr),ha("collectionGroup","collection id",e),e.indexOf("/")>=0)throw new O(P.INVALID_ARGUMENT,`Invalid collection ID '${e}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);return new ze(n,null,function(r){return new Ut(Y.emptyPath(),r)}(e))}function Un(n,e,...t){if(n=Z(n),arguments.length===1&&(e=lh.newId()),ha("doc","path",e),n instanceof Mr){const r=Y.fromString(e,...t);return Xu(r),new Se(n,null,new L(r))}{if(!(n instanceof Se||n instanceof Pt))throw new O(P.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=n._path.child(Y.fromString(e,...t));return Xu(r),new Se(n.firestore,n instanceof Pt?n.converter:null,new L(r))}}/**
3067
+ * @license
3068
+ * Copyright 2020 Google LLC
3069
+ *
3070
+ * Licensed under the Apache License, Version 2.0 (the "License");
3071
+ * you may not use this file except in compliance with the License.
3072
+ * You may obtain a copy of the License at
3073
+ *
3074
+ * http://www.apache.org/licenses/LICENSE-2.0
3075
+ *
3076
+ * Unless required by applicable law or agreed to in writing, software
3077
+ * distributed under the License is distributed on an "AS IS" BASIS,
3078
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3079
+ * See the License for the specific language governing permissions and
3080
+ * limitations under the License.
3081
+ */const el="AsyncQueue";class tl{constructor(e=Promise.resolve()){this.Vu=[],this.mu=!1,this.fu=[],this.gu=null,this.pu=!1,this.yu=!1,this.wu=[],this.a_=new Zh(this,"async_queue_retry"),this.Su=()=>{const r=Wi();r&&V(el,"Visibility state changed to "+r.visibilityState),this.a_.t_()},this.bu=e;const t=Wi();t&&typeof t.addEventListener=="function"&&t.addEventListener("visibilitychange",this.Su)}get isShuttingDown(){return this.mu}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.Du(),this.vu(e)}enterRestrictedMode(e){if(!this.mu){this.mu=!0,this.yu=e||!1;const t=Wi();t&&typeof t.removeEventListener=="function"&&t.removeEventListener("visibilitychange",this.Su)}}enqueue(e){if(this.Du(),this.mu)return new Promise(()=>{});const t=new at;return this.vu(()=>this.mu&&this.yu?Promise.resolve():(e().then(t.resolve,t.reject),t.promise)).then(()=>t.promise)}enqueueRetryable(e){this.enqueueAndForget(()=>(this.Vu.push(e),this.Cu()))}async Cu(){if(this.Vu.length!==0){try{await this.Vu[0](),this.Vu.shift(),this.a_.reset()}catch(e){if(!Mn(e))throw e;V(el,"Operation failed with retryable error: "+e)}this.Vu.length>0&&this.a_.Xo(()=>this.Cu())}}vu(e){const t=this.bu.then(()=>(this.pu=!0,e().catch(r=>{this.gu=r,this.pu=!1;const s=function(a){let c=a.message||"";return a.stack&&(c=a.stack.includes(a.message)?a.stack:a.message+`
3082
+ `+a.stack),c}(r);throw dt("INTERNAL UNHANDLED ERROR: ",s),r}).then(r=>(this.pu=!1,r))));return this.bu=t,t}enqueueAfterDelay(e,t,r){this.Du(),this.wu.indexOf(e)>-1&&(t=0);const s=na.createAndSchedule(this,e,t,r,i=>this.Fu(i));return this.fu.push(s),s}Du(){this.gu&&U()}verifyOperationInProgress(){}async Mu(){let e;do e=this.bu,await e;while(e!==this.bu)}xu(e){for(const t of this.fu)if(t.timerId===e)return!0;return!1}Ou(e){return this.Mu().then(()=>{this.fu.sort((t,r)=>t.targetTimeMs-r.targetTimeMs);for(const t of this.fu)if(t.skipDelay(),e!=="all"&&t.timerId===e)break;return this.Mu()})}Nu(e){this.wu.push(e)}Fu(e){const t=this.fu.indexOf(e);this.fu.splice(t,1)}}function nl(n){return function(t,r){if(typeof t!="object"||t===null)return!1;const s=t;for(const i of r)if(i in s&&typeof s[i]=="function")return!0;return!1}(n,["next","error","complete"])}class en extends Mr{constructor(e,t,r,s){super(e,t,r,s),this.type="firestore",this._queue=new tl,this._persistenceKey=(s==null?void 0:s.name)||"[DEFAULT]"}async _terminate(){if(this._firestoreClient){const e=this._firestoreClient.terminate();this._queue=new tl(e),this._firestoreClient=void 0,await e}}}function QE(n,e){const t=typeof n=="object"?n:Gs(),r=typeof n=="string"?n:Ds,s=Pr(t,"firestore").getImmediate({identifier:r});if(!s._initialized){const i=Ao("firestore");i&&KE(s,...i)}return s}function li(n){if(n._terminated)throw new O(P.FAILED_PRECONDITION,"The client has already been terminated.");return n._firestoreClient||XE(n),n._firestoreClient}function XE(n){var e,t,r;const s=n._freezeSettings(),i=function(c,l,d,f){return new Ey(c,l,d,f.host,f.ssl,f.experimentalForceLongPolling,f.experimentalAutoDetectLongPolling,gd(f.experimentalLongPollingOptions),f.useFetchStreams)}(n._databaseId,((e=n._app)===null||e===void 0?void 0:e.options.appId)||"",n._persistenceKey,s);n._componentsProvider||!((t=s.localCache)===null||t===void 0)&&t._offlineComponentProvider&&(!((r=s.localCache)===null||r===void 0)&&r._onlineComponentProvider)&&(n._componentsProvider={_offline:s.localCache._offlineComponentProvider,_online:s.localCache._onlineComponentProvider}),n._firestoreClient=new $E(n._authCredentials,n._appCheckCredentials,n._queue,i,n._componentsProvider&&function(c){const l=c==null?void 0:c._online.build();return{_offline:c==null?void 0:c._offline.build(l),_online:l}}(n._componentsProvider))}/**
3083
+ * @license
3084
+ * Copyright 2020 Google LLC
3085
+ *
3086
+ * Licensed under the Apache License, Version 2.0 (the "License");
3087
+ * you may not use this file except in compliance with the License.
3088
+ * You may obtain a copy of the License at
3089
+ *
3090
+ * http://www.apache.org/licenses/LICENSE-2.0
3091
+ *
3092
+ * Unless required by applicable law or agreed to in writing, software
3093
+ * distributed under the License is distributed on an "AS IS" BASIS,
3094
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3095
+ * See the License for the specific language governing permissions and
3096
+ * limitations under the License.
3097
+ */class Dn{constructor(e){this._byteString=e}static fromBase64String(e){try{return new Dn(me.fromBase64String(e))}catch(t){throw new O(P.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+t)}}static fromUint8Array(e){return new Dn(me.fromUint8Array(e))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(e){return this._byteString.isEqual(e._byteString)}}/**
3098
+ * @license
3099
+ * Copyright 2020 Google LLC
3100
+ *
3101
+ * Licensed under the Apache License, Version 2.0 (the "License");
3102
+ * you may not use this file except in compliance with the License.
3103
+ * You may obtain a copy of the License at
3104
+ *
3105
+ * http://www.apache.org/licenses/LICENSE-2.0
3106
+ *
3107
+ * Unless required by applicable law or agreed to in writing, software
3108
+ * distributed under the License is distributed on an "AS IS" BASIS,
3109
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3110
+ * See the License for the specific language governing permissions and
3111
+ * limitations under the License.
3112
+ */class da{constructor(...e){for(let t=0;t<e.length;++t)if(e[t].length===0)throw new O(P.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new pe(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}}/**
3113
+ * @license
3114
+ * Copyright 2020 Google LLC
3115
+ *
3116
+ * Licensed under the Apache License, Version 2.0 (the "License");
3117
+ * you may not use this file except in compliance with the License.
3118
+ * You may obtain a copy of the License at
3119
+ *
3120
+ * http://www.apache.org/licenses/LICENSE-2.0
3121
+ *
3122
+ * Unless required by applicable law or agreed to in writing, software
3123
+ * distributed under the License is distributed on an "AS IS" BASIS,
3124
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3125
+ * See the License for the specific language governing permissions and
3126
+ * limitations under the License.
3127
+ */class vd{constructor(e){this._methodName=e}}/**
3128
+ * @license
3129
+ * Copyright 2017 Google LLC
3130
+ *
3131
+ * Licensed under the Apache License, Version 2.0 (the "License");
3132
+ * you may not use this file except in compliance with the License.
3133
+ * You may obtain a copy of the License at
3134
+ *
3135
+ * http://www.apache.org/licenses/LICENSE-2.0
3136
+ *
3137
+ * Unless required by applicable law or agreed to in writing, software
3138
+ * distributed under the License is distributed on an "AS IS" BASIS,
3139
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3140
+ * See the License for the specific language governing permissions and
3141
+ * limitations under the License.
3142
+ */class fa{constructor(e,t){if(!isFinite(e)||e<-90||e>90)throw new O(P.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(t)||t<-180||t>180)throw new O(P.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+t);this._lat=e,this._long=t}get latitude(){return this._lat}get longitude(){return this._long}isEqual(e){return this._lat===e._lat&&this._long===e._long}toJSON(){return{latitude:this._lat,longitude:this._long}}_compareTo(e){return H(this._lat,e._lat)||H(this._long,e._long)}}/**
3143
+ * @license
3144
+ * Copyright 2024 Google LLC
3145
+ *
3146
+ * Licensed under the Apache License, Version 2.0 (the "License");
3147
+ * you may not use this file except in compliance with the License.
3148
+ * You may obtain a copy of the License at
3149
+ *
3150
+ * http://www.apache.org/licenses/LICENSE-2.0
3151
+ *
3152
+ * Unless required by applicable law or agreed to in writing, software
3153
+ * distributed under the License is distributed on an "AS IS" BASIS,
3154
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3155
+ * See the License for the specific language governing permissions and
3156
+ * limitations under the License.
3157
+ */class pa{constructor(e){this._values=(e||[]).map(t=>t)}toArray(){return this._values.map(e=>e)}isEqual(e){return function(r,s){if(r.length!==s.length)return!1;for(let i=0;i<r.length;++i)if(r[i]!==s[i])return!1;return!0}(this._values,e._values)}}/**
3158
+ * @license
3159
+ * Copyright 2017 Google LLC
3160
+ *
3161
+ * Licensed under the Apache License, Version 2.0 (the "License");
3162
+ * you may not use this file except in compliance with the License.
3163
+ * You may obtain a copy of the License at
3164
+ *
3165
+ * http://www.apache.org/licenses/LICENSE-2.0
3166
+ *
3167
+ * Unless required by applicable law or agreed to in writing, software
3168
+ * distributed under the License is distributed on an "AS IS" BASIS,
3169
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3170
+ * See the License for the specific language governing permissions and
3171
+ * limitations under the License.
3172
+ */const JE=/^__.*__$/;class YE{constructor(e,t,r){this.data=e,this.fieldMask=t,this.fieldTransforms=r}toMutation(e,t){return this.fieldMask!==null?new on(e,this.data,this.fieldMask,t,this.fieldTransforms):new Dr(e,this.data,t,this.fieldTransforms)}}function Id(n){switch(n){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw U()}}class ma{constructor(e,t,r,s,i,a){this.settings=e,this.databaseId=t,this.serializer=r,this.ignoreUndefinedProperties=s,i===void 0&&this.Bu(),this.fieldTransforms=i||[],this.fieldMask=a||[]}get path(){return this.settings.path}get Lu(){return this.settings.Lu}ku(e){return new ma(Object.assign(Object.assign({},this.settings),e),this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}qu(e){var t;const r=(t=this.path)===null||t===void 0?void 0:t.child(e),s=this.ku({path:r,Qu:!1});return s.$u(e),s}Uu(e){var t;const r=(t=this.path)===null||t===void 0?void 0:t.child(e),s=this.ku({path:r,Qu:!1});return s.Bu(),s}Ku(e){return this.ku({path:void 0,Qu:!0})}Wu(e){return js(e,this.settings.methodName,this.settings.Gu||!1,this.path,this.settings.zu)}contains(e){return this.fieldMask.find(t=>e.isPrefixOf(t))!==void 0||this.fieldTransforms.find(t=>e.isPrefixOf(t.field))!==void 0}Bu(){if(this.path)for(let e=0;e<this.path.length;e++)this.$u(this.path.get(e))}$u(e){if(e.length===0)throw this.Wu("Document fields must not be empty");if(Id(this.Lu)&&JE.test(e))throw this.Wu('Document fields cannot begin and end with "__"')}}class ZE{constructor(e,t,r){this.databaseId=e,this.ignoreUndefinedProperties=t,this.serializer=r||oi(e)}ju(e,t,r,s=!1){return new ma({Lu:e,methodName:t,zu:r,path:pe.emptyPath(),Qu:!1,Gu:s},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}}function ga(n){const e=n._freezeSettings(),t=oi(n._databaseId);return new ZE(n._databaseId,!!e.ignoreUndefinedProperties,t)}function ev(n,e,t,r,s,i={}){const a=n.ju(i.merge||i.mergeFields?2:0,e,t,s);bd("Data must be an object, but it was:",a,r);const c=Ad(r,a);let l,d;if(i.merge)l=new Be(a.fieldMask),d=a.fieldTransforms;else if(i.mergeFields){const f=[];for(const m of i.mergeFields){const E=tv(e,m,t);if(!a.contains(E))throw new O(P.INVALID_ARGUMENT,`Field '${E}' is specified in your field mask but missing from your input data.`);rv(f,E)||f.push(E)}l=new Be(f),d=a.fieldTransforms.filter(m=>l.covers(m.field))}else l=null,d=a.fieldTransforms;return new YE(new Ve(c),l,d)}function wd(n,e,t,r=!1){return _a(t,n.ju(r?4:3,e))}function _a(n,e){if(Rd(n=Z(n)))return bd("Unsupported field value:",e,n),Ad(n,e);if(n instanceof vd)return function(r,s){if(!Id(s.Lu))throw s.Wu(`${r._methodName}() can only be used with update() and set()`);if(!s.path)throw s.Wu(`${r._methodName}() is not currently supported inside arrays`);const i=r._toFieldTransform(s);i&&s.fieldTransforms.push(i)}(n,e),null;if(n===void 0&&e.ignoreUndefinedProperties)return null;if(e.path&&e.fieldMask.push(e.path),n instanceof Array){if(e.settings.Qu&&e.Lu!==4)throw e.Wu("Nested arrays are not supported");return function(r,s){const i=[];let a=0;for(const c of r){let l=_a(c,s.Ku(a));l==null&&(l={nullValue:"NULL_VALUE"}),i.push(l),a++}return{arrayValue:{values:i}}}(n,e)}return function(r,s){if((r=Z(r))===null)return{nullValue:"NULL_VALUE"};if(typeof r=="number")return jy(s.serializer,r);if(typeof r=="boolean")return{booleanValue:r};if(typeof r=="string")return{stringValue:r};if(r instanceof Date){const i=ue.fromDate(r);return{timestampValue:Us(s.serializer,i)}}if(r instanceof ue){const i=new ue(r.seconds,1e3*Math.floor(r.nanoseconds/1e3));return{timestampValue:Us(s.serializer,i)}}if(r instanceof fa)return{geoPointValue:{latitude:r.latitude,longitude:r.longitude}};if(r instanceof Dn)return{bytesValue:$h(s.serializer,r._byteString)};if(r instanceof Se){const i=s.databaseId,a=r.firestore._databaseId;if(!a.isEqual(i))throw s.Wu(`Document reference is for database ${a.projectId}/${a.database} but should be for database ${i.projectId}/${i.database}`);return{referenceValue:Wo(r.firestore._databaseId||s.databaseId,r._key.path)}}if(r instanceof pa)return function(a,c){return{mapValue:{fields:{[yh]:{stringValue:Th},[Os]:{arrayValue:{values:a.toArray().map(d=>{if(typeof d!="number")throw c.Wu("VectorValues must only contain numeric values.");return jo(c.serializer,d)})}}}}}}(r,s);throw s.Wu(`Unsupported field value: ${ui(r)}`)}(n,e)}function Ad(n,e){const t={};return dh(n)?e.path&&e.path.length>0&&e.fieldMask.push(e.path):rn(n,(r,s)=>{const i=_a(s,e.qu(r));i!=null&&(t[r]=i)}),{mapValue:{fields:t}}}function Rd(n){return!(typeof n!="object"||n===null||n instanceof Array||n instanceof Date||n instanceof ue||n instanceof fa||n instanceof Dn||n instanceof Se||n instanceof vd||n instanceof pa)}function bd(n,e,t){if(!Rd(t)||!function(s){return typeof s=="object"&&s!==null&&(Object.getPrototypeOf(s)===Object.prototype||Object.getPrototypeOf(s)===null)}(t)){const r=ui(t);throw r==="an object"?e.Wu(n+" a custom object"):e.Wu(n+" "+r)}}function tv(n,e,t){if((e=Z(e))instanceof da)return e._internalPath;if(typeof e=="string")return Pd(n,e);throw js("Field path arguments must be of type string or ",n,!1,void 0,t)}const nv=new RegExp("[~\\*/\\[\\]]");function Pd(n,e,t){if(e.search(nv)>=0)throw js(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`,n,!1,void 0,t);try{return new da(...e.split("."))._internalPath}catch{throw js(`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,n,!1,void 0,t)}}function js(n,e,t,r,s){const i=r&&!r.isEmpty(),a=s!==void 0;let c=`Function ${e}() called with invalid data`;t&&(c+=" (via `toFirestore()`)"),c+=". ";let l="";return(i||a)&&(l+=" (found",i&&(l+=` in field ${r}`),a&&(l+=` in document ${s}`),l+=")"),new O(P.INVALID_ARGUMENT,c+n+l)}function rv(n,e){return n.some(t=>t.isEqual(e))}/**
3173
+ * @license
3174
+ * Copyright 2020 Google LLC
3175
+ *
3176
+ * Licensed under the Apache License, Version 2.0 (the "License");
3177
+ * you may not use this file except in compliance with the License.
3178
+ * You may obtain a copy of the License at
3179
+ *
3180
+ * http://www.apache.org/licenses/LICENSE-2.0
3181
+ *
3182
+ * Unless required by applicable law or agreed to in writing, software
3183
+ * distributed under the License is distributed on an "AS IS" BASIS,
3184
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3185
+ * See the License for the specific language governing permissions and
3186
+ * limitations under the License.
3187
+ */class ya{constructor(e,t,r,s,i){this._firestore=e,this._userDataWriter=t,this._key=r,this._document=s,this._converter=i}get id(){return this._key.path.lastSegment()}get ref(){return new Se(this._firestore,this._converter,this._key)}exists(){return this._document!==null}data(){if(this._document){if(this._converter){const e=new sv(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(e)}return this._userDataWriter.convertValue(this._document.data.value)}}get(e){if(this._document){const t=this._document.data.field(hi("DocumentSnapshot.get",e));if(t!==null)return this._userDataWriter.convertValue(t)}}}class sv extends ya{data(){return super.data()}}function hi(n,e){return typeof e=="string"?Pd(n,e):e instanceof da?e._internalPath:e._delegate._internalPath}/**
3188
+ * @license
3189
+ * Copyright 2020 Google LLC
3190
+ *
3191
+ * Licensed under the Apache License, Version 2.0 (the "License");
3192
+ * you may not use this file except in compliance with the License.
3193
+ * You may obtain a copy of the License at
3194
+ *
3195
+ * http://www.apache.org/licenses/LICENSE-2.0
3196
+ *
3197
+ * Unless required by applicable law or agreed to in writing, software
3198
+ * distributed under the License is distributed on an "AS IS" BASIS,
3199
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3200
+ * See the License for the specific language governing permissions and
3201
+ * limitations under the License.
3202
+ */function Sd(n){if(n.limitType==="L"&&n.explicitOrderBy.length===0)throw new O(P.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class Ta{}class di extends Ta{}function Ue(n,e,...t){let r=[];e instanceof Ta&&r.push(e),r=r.concat(t),function(i){const a=i.filter(l=>l instanceof Ea).length,c=i.filter(l=>l instanceof fi).length;if(a>1||a>0&&c>0)throw new O(P.INVALID_ARGUMENT,"InvalidQuery. When using composite filters, you cannot use more than one filter at the top level. Consider nesting the multiple filters within an `and(...)` statement. For example: change `query(query, where(...), or(...))` to `query(query, and(where(...), or(...)))`.")}(r);for(const s of r)n=s._apply(n);return n}class fi extends di{constructor(e,t,r){super(),this._field=e,this._op=t,this._value=r,this.type="where"}static _create(e,t,r){return new fi(e,t,r)}_apply(e){const t=this._parse(e);return Dd(e._query,t),new ze(e.firestore,e.converter,ho(e._query,t))}_parse(e){const t=ga(e.firestore);return function(i,a,c,l,d,f,m){let E;if(d.isKeyField()){if(f==="array-contains"||f==="array-contains-any")throw new O(P.INVALID_ARGUMENT,`Invalid Query. You can't perform '${f}' queries on documentId().`);if(f==="in"||f==="not-in"){sl(m,f);const C=[];for(const N of m)C.push(rl(l,i,N));E={arrayValue:{values:C}}}else E=rl(l,i,m)}else f!=="in"&&f!=="not-in"&&f!=="array-contains-any"||sl(m,f),E=wd(c,a,m,f==="in"||f==="not-in");return ae.create(d,f,E)}(e._query,"where",t,e.firestore._databaseId,this._field,this._op,this._value)}}function wn(n,e,t){const r=e,s=hi("where",n);return fi._create(s,r,t)}class Ea extends Ta{constructor(e,t){super(),this.type=e,this._queryConstraints=t}static _create(e,t){return new Ea(e,t)}_parse(e){const t=this._queryConstraints.map(r=>r._parse(e)).filter(r=>r.getFilters().length>0);return t.length===1?t[0]:je.create(t,this._getOperator())}_apply(e){const t=this._parse(e);return t.getFilters().length===0?e:(function(s,i){let a=s;const c=i.getFlattenedFilters();for(const l of c)Dd(a,l),a=ho(a,l)}(e._query,t),new ze(e.firestore,e.converter,ho(e._query,t)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return this.type==="and"?"and":"or"}}class va extends di{constructor(e,t){super(),this._field=e,this._direction=t,this.type="orderBy"}static _create(e,t){return new va(e,t)}_apply(e){const t=function(s,i,a){if(s.startAt!==null)throw new O(P.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(s.endAt!==null)throw new O(P.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");return new Ir(i,a)}(e._query,this._field,this._direction);return new ze(e.firestore,e.converter,function(s,i){const a=s.explicitOrderBy.concat([i]);return new Ut(s.path,s.collectionGroup,a,s.filters.slice(),s.limit,s.limitType,s.startAt,s.endAt)}(e._query,t))}}function Cd(n,e="asc"){const t=e,r=hi("orderBy",n);return va._create(r,t)}class pi extends di{constructor(e,t,r){super(),this.type=e,this._limit=t,this._limitType=r}static _create(e,t,r){return new pi(e,t,r)}_apply(e){return new ze(e.firestore,e.converter,Ls(e._query,this._limit,this._limitType))}}function kd(n){return _d("limit",n),pi._create("limit",n,"F")}function iv(n){return _d("limitToLast",n),pi._create("limitToLast",n,"L")}class Ia extends di{constructor(e,t,r){super(),this.type=e,this._docOrFields=t,this._inclusive=r}static _create(e,t,r){return new Ia(e,t,r)}_apply(e){const t=ov(e,this.type,this._docOrFields,this._inclusive);return new ze(e.firestore,e.converter,function(s,i){return new Ut(s.path,s.collectionGroup,s.explicitOrderBy.slice(),s.filters.slice(),s.limit,s.limitType,i,s.endAt)}(e._query,t))}}function Nd(...n){return Ia._create("startAfter",n,!1)}function ov(n,e,t,r){if(t[0]=Z(t[0]),t[0]instanceof ya)return function(i,a,c,l,d){if(!l)throw new O(P.NOT_FOUND,`Can't use a DocumentSnapshot that doesn't exist for ${c}().`);const f=[];for(const m of vn(i))if(m.field.isKeyField())f.push(Vs(a,l.key));else{const E=l.data.field(m.field);if(Ys(E))throw new O(P.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(E===null){const R=m.field.canonicalString();throw new O(P.INVALID_ARGUMENT,`Invalid query. You are trying to start or end a query using a document for which the field '${R}' (used as the orderBy) does not exist.`)}f.push(E)}return new Cn(f,d)}(n._query,n.firestore._databaseId,e,t[0]._document,r);{const s=ga(n.firestore);return function(a,c,l,d,f,m){const E=a.explicitOrderBy;if(f.length>E.length)throw new O(P.INVALID_ARGUMENT,`Too many arguments provided to ${d}(). The number of arguments must be less than or equal to the number of orderBy() clauses`);const R=[];for(let C=0;C<f.length;C++){const N=f[C];if(E[C].field.isKeyField()){if(typeof N!="string")throw new O(P.INVALID_ARGUMENT,`Invalid query. Expected a string for document ID in ${d}(), but got a ${typeof N}`);if(!$o(a)&&N.indexOf("/")!==-1)throw new O(P.INVALID_ARGUMENT,`Invalid query. When querying a collection and ordering by documentId(), the value passed to ${d}() must be a plain document ID, but '${N}' contains a slash.`);const k=a.path.child(Y.fromString(N));if(!L.isDocumentKey(k))throw new O(P.INVALID_ARGUMENT,`Invalid query. When querying a collection group and ordering by documentId(), the value passed to ${d}() must result in a valid document path, but '${k}' is not because it contains an odd number of segments.`);const F=new L(k);R.push(Vs(c,F))}else{const k=wd(l,d,N);R.push(k)}}return new Cn(R,m)}(n._query,n.firestore._databaseId,s,e,t,r)}}function rl(n,e,t){if(typeof(t=Z(t))=="string"){if(t==="")throw new O(P.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!$o(e)&&t.indexOf("/")!==-1)throw new O(P.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${t}' contains a '/' character.`);const r=e.path.child(Y.fromString(t));if(!L.isDocumentKey(r))throw new O(P.INVALID_ARGUMENT,`Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${r}' is not because it has an odd number of segments (${r.length}).`);return Vs(n,new L(r))}if(t instanceof Se)return Vs(n,t._key);throw new O(P.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${ui(t)}.`)}function sl(n,e){if(!Array.isArray(n)||n.length===0)throw new O(P.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${e.toString()}' filters.`)}function Dd(n,e){const t=function(s,i){for(const a of s)for(const c of a.getFlattenedFilters())if(i.indexOf(c.op)>=0)return c.op;return null}(n.filters,function(s){switch(s){case"!=":return["!=","not-in"];case"array-contains-any":case"in":return["not-in"];case"not-in":return["array-contains-any","in","not-in","!="];default:return[]}}(e.op));if(t!==null)throw t===e.op?new O(P.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${e.op.toString()}' filter.`):new O(P.INVALID_ARGUMENT,`Invalid query. You cannot use '${e.op.toString()}' filters with '${t.toString()}' filters.`)}class av{convertValue(e,t="none"){switch(Dt(e)){case 0:return null;case 1:return e.booleanValue;case 2:return ie(e.integerValue||e.doubleValue);case 3:return this.convertTimestamp(e.timestampValue);case 4:return this.convertServerTimestamp(e,t);case 5:return e.stringValue;case 6:return this.convertBytes(Nt(e.bytesValue));case 7:return this.convertReference(e.referenceValue);case 8:return this.convertGeoPoint(e.geoPointValue);case 9:return this.convertArray(e.arrayValue,t);case 11:return this.convertObject(e.mapValue,t);case 10:return this.convertVectorValue(e.mapValue);default:throw U()}}convertObject(e,t){return this.convertObjectMap(e.fields,t)}convertObjectMap(e,t="none"){const r={};return rn(e,(s,i)=>{r[s]=this.convertValue(i,t)}),r}convertVectorValue(e){var t,r,s;const i=(s=(r=(t=e.fields)===null||t===void 0?void 0:t[Os].arrayValue)===null||r===void 0?void 0:r.values)===null||s===void 0?void 0:s.map(a=>ie(a.doubleValue));return new pa(i)}convertGeoPoint(e){return new fa(ie(e.latitude),ie(e.longitude))}convertArray(e,t){return(e.values||[]).map(r=>this.convertValue(r,t))}convertServerTimestamp(e,t){switch(t){case"previous":const r=Zs(e);return r==null?null:this.convertValue(r,t);case"estimate":return this.convertTimestamp(Tr(e));default:return null}}convertTimestamp(e){const t=kt(e);return new ue(t.seconds,t.nanos)}convertDocumentKey(e,t){const r=Y.fromString(e);Q(Kh(r));const s=new Er(r.get(1),r.get(3)),i=new L(r.popFirst(5));return s.isEqual(t)||dt(`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 (${t.projectId}/${t.database}) instead.`),i}}/**
3203
+ * @license
3204
+ * Copyright 2020 Google LLC
3205
+ *
3206
+ * Licensed under the Apache License, Version 2.0 (the "License");
3207
+ * you may not use this file except in compliance with the License.
3208
+ * You may obtain a copy of the License at
3209
+ *
3210
+ * http://www.apache.org/licenses/LICENSE-2.0
3211
+ *
3212
+ * Unless required by applicable law or agreed to in writing, software
3213
+ * distributed under the License is distributed on an "AS IS" BASIS,
3214
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3215
+ * See the License for the specific language governing permissions and
3216
+ * limitations under the License.
3217
+ */function cv(n,e,t){let r;return r=n?t&&(t.merge||t.mergeFields)?n.toFirestore(e,t):n.toFirestore(e):e,r}/**
3218
+ * @license
3219
+ * Copyright 2020 Google LLC
3220
+ *
3221
+ * Licensed under the Apache License, Version 2.0 (the "License");
3222
+ * you may not use this file except in compliance with the License.
3223
+ * You may obtain a copy of the License at
3224
+ *
3225
+ * http://www.apache.org/licenses/LICENSE-2.0
3226
+ *
3227
+ * Unless required by applicable law or agreed to in writing, software
3228
+ * distributed under the License is distributed on an "AS IS" BASIS,
3229
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3230
+ * See the License for the specific language governing permissions and
3231
+ * limitations under the License.
3232
+ */class ur{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}}class Od extends ya{constructor(e,t,r,s,i,a){super(e,t,r,s,a),this._firestore=e,this._firestoreImpl=e,this.metadata=i}exists(){return super.exists()}data(e={}){if(this._document){if(this._converter){const t=new Es(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(t,e)}return this._userDataWriter.convertValue(this._document.data.value,e.serverTimestamps)}}get(e,t={}){if(this._document){const r=this._document.data.field(hi("DocumentSnapshot.get",e));if(r!==null)return this._userDataWriter.convertValue(r,t.serverTimestamps)}}}class Es extends Od{data(e={}){return super.data(e)}}class Vd{constructor(e,t,r,s){this._firestore=e,this._userDataWriter=t,this._snapshot=s,this.metadata=new ur(s.hasPendingWrites,s.fromCache),this.query=r}get docs(){const e=[];return this.forEach(t=>e.push(t)),e}get size(){return this._snapshot.docs.size}get empty(){return this.size===0}forEach(e,t){this._snapshot.docs.forEach(r=>{e.call(t,new Es(this._firestore,this._userDataWriter,r.key,r,new ur(this._snapshot.mutatedKeys.has(r.key),this._snapshot.fromCache),this.query.converter))})}docChanges(e={}){const t=!!e.includeMetadataChanges;if(t&&this._snapshot.excludesMetadataChanges)throw new O(P.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===t||(this._cachedChanges=function(s,i){if(s._snapshot.oldDocs.isEmpty()){let a=0;return s._snapshot.docChanges.map(c=>{const l=new Es(s._firestore,s._userDataWriter,c.doc.key,c.doc,new ur(s._snapshot.mutatedKeys.has(c.doc.key),s._snapshot.fromCache),s.query.converter);return c.doc,{type:"added",doc:l,oldIndex:-1,newIndex:a++}})}{let a=s._snapshot.oldDocs;return s._snapshot.docChanges.filter(c=>i||c.type!==3).map(c=>{const l=new Es(s._firestore,s._userDataWriter,c.doc.key,c.doc,new ur(s._snapshot.mutatedKeys.has(c.doc.key),s._snapshot.fromCache),s.query.converter);let d=-1,f=-1;return c.type!==0&&(d=a.indexOf(c.doc.key),a=a.delete(c.doc.key)),c.type!==1&&(a=a.add(c.doc),f=a.indexOf(c.doc.key)),{type:uv(c.type),doc:l,oldIndex:d,newIndex:f}})}}(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}}function uv(n){switch(n){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return U()}}/**
3233
+ * @license
3234
+ * Copyright 2020 Google LLC
3235
+ *
3236
+ * Licensed under the Apache License, Version 2.0 (the "License");
3237
+ * you may not use this file except in compliance with the License.
3238
+ * You may obtain a copy of the License at
3239
+ *
3240
+ * http://www.apache.org/licenses/LICENSE-2.0
3241
+ *
3242
+ * Unless required by applicable law or agreed to in writing, software
3243
+ * distributed under the License is distributed on an "AS IS" BASIS,
3244
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3245
+ * See the License for the specific language governing permissions and
3246
+ * limitations under the License.
3247
+ */function Ld(n){n=Le(n,Se);const e=Le(n.firestore,en);return zE(li(e),n._key).then(t=>Bd(e,n,t))}class wa extends av{constructor(e){super(),this.firestore=e}convertBytes(e){return new Dn(e)}convertReference(e){const t=this.convertDocumentKey(e,this.firestore._databaseId);return new Se(this.firestore,null,t)}}function Md(n){n=Le(n,ze);const e=Le(n.firestore,en),t=li(e),r=new wa(e);return Sd(n._query),GE(t,n._query).then(s=>new Vd(e,r,n,s))}function xd(n,e,t){n=Le(n,Se);const r=Le(n.firestore,en),s=cv(n.converter,e,t);return Fd(r,[ev(ga(r),"setDoc",n._key,s,n.converter!==null,t).toMutation(n._key,Xe.none())])}function lv(n){return Fd(Le(n.firestore,en),[new Ho(n._key,Xe.none())])}function Ud(n,...e){var t,r,s;n=Z(n);let i={includeMetadataChanges:!1,source:"default"},a=0;typeof e[a]!="object"||nl(e[a])||(i=e[a],a++);const c={includeMetadataChanges:i.includeMetadataChanges,source:i.source};if(nl(e[a])){const m=e[a];e[a]=(t=m.next)===null||t===void 0?void 0:t.bind(m),e[a+1]=(r=m.error)===null||r===void 0?void 0:r.bind(m),e[a+2]=(s=m.complete)===null||s===void 0?void 0:s.bind(m)}let l,d,f;if(n instanceof Se)d=Le(n.firestore,en),f=ei(n._key.path),l={next:m=>{e[a]&&e[a](Bd(d,n,m))},error:e[a+1],complete:e[a+2]};else{const m=Le(n,ze);d=Le(m.firestore,en),f=m._query;const E=new wa(d);l={next:R=>{e[a]&&e[a](new Vd(d,E,m,R))},error:e[a+1],complete:e[a+2]},Sd(n._query)}return function(E,R,C,N){const k=new la(N),F=new aa(R,k,C);return E.asyncQueue.enqueueAndForget(async()=>sa(await $s(E),F)),()=>{k.su(),E.asyncQueue.enqueueAndForget(async()=>ia(await $s(E),F))}}(li(d),f,c,l)}function Fd(n,e){return function(r,s){const i=new at;return r.asyncQueue.enqueueAndForget(async()=>OE(await HE(r),s,i)),i.promise}(li(n),e)}function Bd(n,e,t){const r=t.docs.get(e._key),s=new wa(n);return new Od(n,s,e._key,r,new ur(t.hasPendingWrites,t.fromCache),e.converter)}(function(e,t=!0){(function(s){Vn=s})(nn),St(new ut("firestore",(r,{instanceIdentifier:s,options:i})=>{const a=r.getProvider("app").getImmediate(),c=new en(new ry(r.getProvider("auth-internal")),new oy(a,r.getProvider("app-check-internal")),function(d,f){if(!Object.prototype.hasOwnProperty.apply(d.options,["projectId"]))throw new O(P.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new Er(d.options.projectId,f)}(a,s),a);return i=Object.assign({useFetchStreams:t},i),c._setSettings(i),c},"PUBLIC").setMultipleInstances(!0)),qe(au,cu,e),qe(au,cu,"esm2017")})();/**
3248
+ * @license
3249
+ * Copyright 2017 Google LLC
3250
+ *
3251
+ * Licensed under the Apache License, Version 2.0 (the "License");
3252
+ * you may not use this file except in compliance with the License.
3253
+ * You may obtain a copy of the License at
3254
+ *
3255
+ * http://www.apache.org/licenses/LICENSE-2.0
3256
+ *
3257
+ * Unless required by applicable law or agreed to in writing, software
3258
+ * distributed under the License is distributed on an "AS IS" BASIS,
3259
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3260
+ * See the License for the specific language governing permissions and
3261
+ * limitations under the License.
3262
+ */const qd="firebasestorage.googleapis.com",$d="storageBucket",hv=2*60*1e3,dv=10*60*1e3,fv=1e3;/**
3263
+ * @license
3264
+ * Copyright 2017 Google LLC
3265
+ *
3266
+ * Licensed under the Apache License, Version 2.0 (the "License");
3267
+ * you may not use this file except in compliance with the License.
3268
+ * You may obtain a copy of the License at
3269
+ *
3270
+ * http://www.apache.org/licenses/LICENSE-2.0
3271
+ *
3272
+ * Unless required by applicable law or agreed to in writing, software
3273
+ * distributed under the License is distributed on an "AS IS" BASIS,
3274
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3275
+ * See the License for the specific language governing permissions and
3276
+ * limitations under the License.
3277
+ */class re extends He{constructor(e,t,r=0){super(Qi(e),`Firebase Storage: ${t} (${Qi(e)})`),this.status_=r,this.customData={serverResponse:null},this._baseMessage=this.message,Object.setPrototypeOf(this,re.prototype)}get status(){return this.status_}set status(e){this.status_=e}_codeEquals(e){return Qi(e)===this.code}get serverResponse(){return this.customData.serverResponse}set serverResponse(e){this.customData.serverResponse=e,this.customData.serverResponse?this.message=`${this._baseMessage}
3278
+ ${this.customData.serverResponse}`:this.message=this._baseMessage}}var te;(function(n){n.UNKNOWN="unknown",n.OBJECT_NOT_FOUND="object-not-found",n.BUCKET_NOT_FOUND="bucket-not-found",n.PROJECT_NOT_FOUND="project-not-found",n.QUOTA_EXCEEDED="quota-exceeded",n.UNAUTHENTICATED="unauthenticated",n.UNAUTHORIZED="unauthorized",n.UNAUTHORIZED_APP="unauthorized-app",n.RETRY_LIMIT_EXCEEDED="retry-limit-exceeded",n.INVALID_CHECKSUM="invalid-checksum",n.CANCELED="canceled",n.INVALID_EVENT_NAME="invalid-event-name",n.INVALID_URL="invalid-url",n.INVALID_DEFAULT_BUCKET="invalid-default-bucket",n.NO_DEFAULT_BUCKET="no-default-bucket",n.CANNOT_SLICE_BLOB="cannot-slice-blob",n.SERVER_FILE_WRONG_SIZE="server-file-wrong-size",n.NO_DOWNLOAD_URL="no-download-url",n.INVALID_ARGUMENT="invalid-argument",n.INVALID_ARGUMENT_COUNT="invalid-argument-count",n.APP_DELETED="app-deleted",n.INVALID_ROOT_OPERATION="invalid-root-operation",n.INVALID_FORMAT="invalid-format",n.INTERNAL_ERROR="internal-error",n.UNSUPPORTED_ENVIRONMENT="unsupported-environment"})(te||(te={}));function Qi(n){return"storage/"+n}function Aa(){const n="An unknown error occurred, please check the error payload for server response.";return new re(te.UNKNOWN,n)}function pv(n){return new re(te.OBJECT_NOT_FOUND,"Object '"+n+"' does not exist.")}function mv(n){return new re(te.QUOTA_EXCEEDED,"Quota for bucket '"+n+"' exceeded, please view quota on https://firebase.google.com/pricing/.")}function gv(){const n="User is not authenticated, please authenticate using Firebase Authentication and try again.";return new re(te.UNAUTHENTICATED,n)}function _v(){return new re(te.UNAUTHORIZED_APP,"This app does not have permission to access Firebase Storage on this project.")}function yv(n){return new re(te.UNAUTHORIZED,"User does not have permission to access '"+n+"'.")}function jd(){return new re(te.RETRY_LIMIT_EXCEEDED,"Max retry time for operation exceeded, please try again.")}function Hd(){return new re(te.CANCELED,"User canceled the upload/download.")}function Tv(n){return new re(te.INVALID_URL,"Invalid URL '"+n+"'.")}function Ev(n){return new re(te.INVALID_DEFAULT_BUCKET,"Invalid default bucket '"+n+"'.")}function vv(){return new re(te.NO_DEFAULT_BUCKET,"No default bucket found. Did you set the '"+$d+"' property when initializing the app?")}function zd(){return new re(te.CANNOT_SLICE_BLOB,"Cannot slice blob for upload. Please retry the upload.")}function Iv(){return new re(te.SERVER_FILE_WRONG_SIZE,"Server recorded incorrect upload file size, please retry the upload.")}function wv(){return new re(te.NO_DOWNLOAD_URL,"The given file does not have any download URLs.")}function Av(n){return new re(te.UNSUPPORTED_ENVIRONMENT,`${n} is missing. Make sure to install the required polyfills. See https://firebase.google.com/docs/web/environments-js-sdk#polyfills for more information.`)}function Io(n){return new re(te.INVALID_ARGUMENT,n)}function Gd(){return new re(te.APP_DELETED,"The Firebase app was deleted.")}function Rv(n){return new re(te.INVALID_ROOT_OPERATION,"The operation '"+n+"' cannot be performed on a root reference, create a non-root reference using child, such as .child('file.png').")}function pr(n,e){return new re(te.INVALID_FORMAT,"String does not match format '"+n+"': "+e)}function nr(n){throw new re(te.INTERNAL_ERROR,"Internal error: "+n)}/**
3279
+ * @license
3280
+ * Copyright 2017 Google LLC
3281
+ *
3282
+ * Licensed under the Apache License, Version 2.0 (the "License");
3283
+ * you may not use this file except in compliance with the License.
3284
+ * You may obtain a copy of the License at
3285
+ *
3286
+ * http://www.apache.org/licenses/LICENSE-2.0
3287
+ *
3288
+ * Unless required by applicable law or agreed to in writing, software
3289
+ * distributed under the License is distributed on an "AS IS" BASIS,
3290
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3291
+ * See the License for the specific language governing permissions and
3292
+ * limitations under the License.
3293
+ */class Oe{constructor(e,t){this.bucket=e,this.path_=t}get path(){return this.path_}get isRoot(){return this.path.length===0}fullServerUrl(){const e=encodeURIComponent;return"/b/"+e(this.bucket)+"/o/"+e(this.path)}bucketOnlyServerUrl(){return"/b/"+encodeURIComponent(this.bucket)+"/o"}static makeFromBucketSpec(e,t){let r;try{r=Oe.makeFromUrl(e,t)}catch{return new Oe(e,"")}if(r.path==="")return r;throw Ev(e)}static makeFromUrl(e,t){let r=null;const s="([A-Za-z0-9.\\-_]+)";function i(j){j.path.charAt(j.path.length-1)==="/"&&(j.path_=j.path_.slice(0,-1))}const a="(/(.*))?$",c=new RegExp("^gs://"+s+a,"i"),l={bucket:1,path:3};function d(j){j.path_=decodeURIComponent(j.path)}const f="v[A-Za-z0-9_]+",m=t.replace(/[.]/g,"\\."),E="(/([^?#]*).*)?$",R=new RegExp(`^https?://${m}/${f}/b/${s}/o${E}`,"i"),C={bucket:1,path:3},N=t===qd?"(?:storage.googleapis.com|storage.cloud.google.com)":t,k="([^?#]*)",F=new RegExp(`^https?://${N}/${s}/${k}`,"i"),M=[{regex:c,indices:l,postModify:i},{regex:R,indices:C,postModify:d},{regex:F,indices:{bucket:1,path:2},postModify:d}];for(let j=0;j<M.length;j++){const ce=M[j],X=ce.regex.exec(e);if(X){const v=X[ce.indices.bucket];let g=X[ce.indices.path];g||(g=""),r=new Oe(v,g),ce.postModify(r);break}}if(r==null)throw Tv(e);return r}}class bv{constructor(e){this.promise_=Promise.reject(e)}getPromise(){return this.promise_}cancel(e=!1){}}/**
3294
+ * @license
3295
+ * Copyright 2017 Google LLC
3296
+ *
3297
+ * Licensed under the Apache License, Version 2.0 (the "License");
3298
+ * you may not use this file except in compliance with the License.
3299
+ * You may obtain a copy of the License at
3300
+ *
3301
+ * http://www.apache.org/licenses/LICENSE-2.0
3302
+ *
3303
+ * Unless required by applicable law or agreed to in writing, software
3304
+ * distributed under the License is distributed on an "AS IS" BASIS,
3305
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3306
+ * See the License for the specific language governing permissions and
3307
+ * limitations under the License.
3308
+ */function Pv(n,e,t){let r=1,s=null,i=null,a=!1,c=0;function l(){return c===2}let d=!1;function f(...k){d||(d=!0,e.apply(null,k))}function m(k){s=setTimeout(()=>{s=null,n(R,l())},k)}function E(){i&&clearTimeout(i)}function R(k,...F){if(d){E();return}if(k){E(),f.call(null,k,...F);return}if(l()||a){E(),f.call(null,k,...F);return}r<64&&(r*=2);let M;c===1?(c=2,M=0):M=(r+Math.random())*1e3,m(M)}let C=!1;function N(k){C||(C=!0,E(),!d&&(s!==null?(k||(c=2),clearTimeout(s),m(0)):k||(c=1)))}return m(0),i=setTimeout(()=>{a=!0,N(!0)},t),N}function Sv(n){n(!1)}/**
3309
+ * @license
3310
+ * Copyright 2017 Google LLC
3311
+ *
3312
+ * Licensed under the Apache License, Version 2.0 (the "License");
3313
+ * you may not use this file except in compliance with the License.
3314
+ * You may obtain a copy of the License at
3315
+ *
3316
+ * http://www.apache.org/licenses/LICENSE-2.0
3317
+ *
3318
+ * Unless required by applicable law or agreed to in writing, software
3319
+ * distributed under the License is distributed on an "AS IS" BASIS,
3320
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3321
+ * See the License for the specific language governing permissions and
3322
+ * limitations under the License.
3323
+ */function Cv(n){return n!==void 0}function kv(n){return typeof n=="function"}function Nv(n){return typeof n=="object"&&!Array.isArray(n)}function mi(n){return typeof n=="string"||n instanceof String}function il(n){return Ra()&&n instanceof Blob}function Ra(){return typeof Blob<"u"}function ol(n,e,t,r){if(r<e)throw Io(`Invalid value for '${n}'. Expected ${e} or greater.`);if(r>t)throw Io(`Invalid value for '${n}'. Expected ${t} or less.`)}/**
3324
+ * @license
3325
+ * Copyright 2017 Google LLC
3326
+ *
3327
+ * Licensed under the Apache License, Version 2.0 (the "License");
3328
+ * you may not use this file except in compliance with the License.
3329
+ * You may obtain a copy of the License at
3330
+ *
3331
+ * http://www.apache.org/licenses/LICENSE-2.0
3332
+ *
3333
+ * Unless required by applicable law or agreed to in writing, software
3334
+ * distributed under the License is distributed on an "AS IS" BASIS,
3335
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3336
+ * See the License for the specific language governing permissions and
3337
+ * limitations under the License.
3338
+ */function cn(n,e,t){let r=e;return t==null&&(r=`https://${e}`),`${t}://${r}/v0${n}`}function Wd(n){const e=encodeURIComponent;let t="?";for(const r in n)if(n.hasOwnProperty(r)){const s=e(r)+"="+e(n[r]);t=t+s+"&"}return t=t.slice(0,-1),t}var Kt;(function(n){n[n.NO_ERROR=0]="NO_ERROR",n[n.NETWORK_ERROR=1]="NETWORK_ERROR",n[n.ABORT=2]="ABORT"})(Kt||(Kt={}));/**
3339
+ * @license
3340
+ * Copyright 2022 Google LLC
3341
+ *
3342
+ * Licensed under the Apache License, Version 2.0 (the "License");
3343
+ * you may not use this file except in compliance with the License.
3344
+ * You may obtain a copy of the License at
3345
+ *
3346
+ * http://www.apache.org/licenses/LICENSE-2.0
3347
+ *
3348
+ * Unless required by applicable law or agreed to in writing, software
3349
+ * distributed under the License is distributed on an "AS IS" BASIS,
3350
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3351
+ * See the License for the specific language governing permissions and
3352
+ * limitations under the License.
3353
+ */function Kd(n,e){const t=n>=500&&n<600,s=[408,429].indexOf(n)!==-1,i=e.indexOf(n)!==-1;return t||s||i}/**
3354
+ * @license
3355
+ * Copyright 2017 Google LLC
3356
+ *
3357
+ * Licensed under the Apache License, Version 2.0 (the "License");
3358
+ * you may not use this file except in compliance with the License.
3359
+ * You may obtain a copy of the License at
3360
+ *
3361
+ * http://www.apache.org/licenses/LICENSE-2.0
3362
+ *
3363
+ * Unless required by applicable law or agreed to in writing, software
3364
+ * distributed under the License is distributed on an "AS IS" BASIS,
3365
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3366
+ * See the License for the specific language governing permissions and
3367
+ * limitations under the License.
3368
+ */class Dv{constructor(e,t,r,s,i,a,c,l,d,f,m,E=!0){this.url_=e,this.method_=t,this.headers_=r,this.body_=s,this.successCodes_=i,this.additionalRetryCodes_=a,this.callback_=c,this.errorCallback_=l,this.timeout_=d,this.progressCallback_=f,this.connectionFactory_=m,this.retry=E,this.pendingConnection_=null,this.backoffId_=null,this.canceled_=!1,this.appDelete_=!1,this.promise_=new Promise((R,C)=>{this.resolve_=R,this.reject_=C,this.start_()})}start_(){const e=(r,s)=>{if(s){r(!1,new us(!1,null,!0));return}const i=this.connectionFactory_();this.pendingConnection_=i;const a=c=>{const l=c.loaded,d=c.lengthComputable?c.total:-1;this.progressCallback_!==null&&this.progressCallback_(l,d)};this.progressCallback_!==null&&i.addUploadProgressListener(a),i.send(this.url_,this.method_,this.body_,this.headers_).then(()=>{this.progressCallback_!==null&&i.removeUploadProgressListener(a),this.pendingConnection_=null;const c=i.getErrorCode()===Kt.NO_ERROR,l=i.getStatus();if(!c||Kd(l,this.additionalRetryCodes_)&&this.retry){const f=i.getErrorCode()===Kt.ABORT;r(!1,new us(!1,null,f));return}const d=this.successCodes_.indexOf(l)!==-1;r(!0,new us(d,i))})},t=(r,s)=>{const i=this.resolve_,a=this.reject_,c=s.connection;if(s.wasSuccessCode)try{const l=this.callback_(c,c.getResponse());Cv(l)?i(l):i()}catch(l){a(l)}else if(c!==null){const l=Aa();l.serverResponse=c.getErrorText(),this.errorCallback_?a(this.errorCallback_(c,l)):a(l)}else if(s.canceled){const l=this.appDelete_?Gd():Hd();a(l)}else{const l=jd();a(l)}};this.canceled_?t(!1,new us(!1,null,!0)):this.backoffId_=Pv(e,t,this.timeout_)}getPromise(){return this.promise_}cancel(e){this.canceled_=!0,this.appDelete_=e||!1,this.backoffId_!==null&&Sv(this.backoffId_),this.pendingConnection_!==null&&this.pendingConnection_.abort()}}class us{constructor(e,t,r){this.wasSuccessCode=e,this.connection=t,this.canceled=!!r}}function Ov(n,e){e!==null&&e.length>0&&(n.Authorization="Firebase "+e)}function Vv(n,e){n["X-Firebase-Storage-Version"]="webjs/"+(e??"AppManager")}function Lv(n,e){e&&(n["X-Firebase-GMPID"]=e)}function Mv(n,e){e!==null&&(n["X-Firebase-AppCheck"]=e)}function xv(n,e,t,r,s,i,a=!0){const c=Wd(n.urlParams),l=n.url+c,d=Object.assign({},n.headers);return Lv(d,e),Ov(d,t),Vv(d,i),Mv(d,r),new Dv(l,n.method,d,n.body,n.successCodes,n.additionalRetryCodes,n.handler,n.errorHandler,n.timeout,n.progressCallback,s,a)}/**
3369
+ * @license
3370
+ * Copyright 2017 Google LLC
3371
+ *
3372
+ * Licensed under the Apache License, Version 2.0 (the "License");
3373
+ * you may not use this file except in compliance with the License.
3374
+ * You may obtain a copy of the License at
3375
+ *
3376
+ * http://www.apache.org/licenses/LICENSE-2.0
3377
+ *
3378
+ * Unless required by applicable law or agreed to in writing, software
3379
+ * distributed under the License is distributed on an "AS IS" BASIS,
3380
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3381
+ * See the License for the specific language governing permissions and
3382
+ * limitations under the License.
3383
+ */function Uv(){return typeof BlobBuilder<"u"?BlobBuilder:typeof WebKitBlobBuilder<"u"?WebKitBlobBuilder:void 0}function Fv(...n){const e=Uv();if(e!==void 0){const t=new e;for(let r=0;r<n.length;r++)t.append(n[r]);return t.getBlob()}else{if(Ra())return new Blob(n);throw new re(te.UNSUPPORTED_ENVIRONMENT,"This browser doesn't seem to support creating Blobs")}}function Bv(n,e,t){return n.webkitSlice?n.webkitSlice(e,t):n.mozSlice?n.mozSlice(e,t):n.slice?n.slice(e,t):null}/**
3384
+ * @license
3385
+ * Copyright 2021 Google LLC
3386
+ *
3387
+ * Licensed under the Apache License, Version 2.0 (the "License");
3388
+ * you may not use this file except in compliance with the License.
3389
+ * You may obtain a copy of the License at
3390
+ *
3391
+ * http://www.apache.org/licenses/LICENSE-2.0
3392
+ *
3393
+ * Unless required by applicable law or agreed to in writing, software
3394
+ * distributed under the License is distributed on an "AS IS" BASIS,
3395
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3396
+ * See the License for the specific language governing permissions and
3397
+ * limitations under the License.
3398
+ */function qv(n){if(typeof atob>"u")throw Av("base-64");return atob(n)}/**
3399
+ * @license
3400
+ * Copyright 2017 Google LLC
3401
+ *
3402
+ * Licensed under the Apache License, Version 2.0 (the "License");
3403
+ * you may not use this file except in compliance with the License.
3404
+ * You may obtain a copy of the License at
3405
+ *
3406
+ * http://www.apache.org/licenses/LICENSE-2.0
3407
+ *
3408
+ * Unless required by applicable law or agreed to in writing, software
3409
+ * distributed under the License is distributed on an "AS IS" BASIS,
3410
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3411
+ * See the License for the specific language governing permissions and
3412
+ * limitations under the License.
3413
+ */const We={RAW:"raw",BASE64:"base64",BASE64URL:"base64url",DATA_URL:"data_url"};class Xi{constructor(e,t){this.data=e,this.contentType=t||null}}function $v(n,e){switch(n){case We.RAW:return new Xi(Qd(e));case We.BASE64:case We.BASE64URL:return new Xi(Xd(n,e));case We.DATA_URL:return new Xi(Hv(e),zv(e))}throw Aa()}function Qd(n){const e=[];for(let t=0;t<n.length;t++){let r=n.charCodeAt(t);if(r<=127)e.push(r);else if(r<=2047)e.push(192|r>>6,128|r&63);else if((r&64512)===55296)if(!(t<n.length-1&&(n.charCodeAt(t+1)&64512)===56320))e.push(239,191,189);else{const i=r,a=n.charCodeAt(++t);r=65536|(i&1023)<<10|a&1023,e.push(240|r>>18,128|r>>12&63,128|r>>6&63,128|r&63)}else(r&64512)===56320?e.push(239,191,189):e.push(224|r>>12,128|r>>6&63,128|r&63)}return new Uint8Array(e)}function jv(n){let e;try{e=decodeURIComponent(n)}catch{throw pr(We.DATA_URL,"Malformed data URL.")}return Qd(e)}function Xd(n,e){switch(n){case We.BASE64:{const s=e.indexOf("-")!==-1,i=e.indexOf("_")!==-1;if(s||i)throw pr(n,"Invalid character '"+(s?"-":"_")+"' found: is it base64url encoded?");break}case We.BASE64URL:{const s=e.indexOf("+")!==-1,i=e.indexOf("/")!==-1;if(s||i)throw pr(n,"Invalid character '"+(s?"+":"/")+"' found: is it base64 encoded?");e=e.replace(/-/g,"+").replace(/_/g,"/");break}}let t;try{t=qv(e)}catch(s){throw s.message.includes("polyfill")?s:pr(n,"Invalid character found")}const r=new Uint8Array(t.length);for(let s=0;s<t.length;s++)r[s]=t.charCodeAt(s);return r}class Jd{constructor(e){this.base64=!1,this.contentType=null;const t=e.match(/^data:([^,]+)?,/);if(t===null)throw pr(We.DATA_URL,"Must be formatted 'data:[<mediatype>][;base64],<data>");const r=t[1]||null;r!=null&&(this.base64=Gv(r,";base64"),this.contentType=this.base64?r.substring(0,r.length-7):r),this.rest=e.substring(e.indexOf(",")+1)}}function Hv(n){const e=new Jd(n);return e.base64?Xd(We.BASE64,e.rest):jv(e.rest)}function zv(n){return new Jd(n).contentType}function Gv(n,e){return n.length>=e.length?n.substring(n.length-e.length)===e:!1}/**
3414
+ * @license
3415
+ * Copyright 2017 Google LLC
3416
+ *
3417
+ * Licensed under the Apache License, Version 2.0 (the "License");
3418
+ * you may not use this file except in compliance with the License.
3419
+ * You may obtain a copy of the License at
3420
+ *
3421
+ * http://www.apache.org/licenses/LICENSE-2.0
3422
+ *
3423
+ * Unless required by applicable law or agreed to in writing, software
3424
+ * distributed under the License is distributed on an "AS IS" BASIS,
3425
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3426
+ * See the License for the specific language governing permissions and
3427
+ * limitations under the License.
3428
+ */class It{constructor(e,t){let r=0,s="";il(e)?(this.data_=e,r=e.size,s=e.type):e instanceof ArrayBuffer?(t?this.data_=new Uint8Array(e):(this.data_=new Uint8Array(e.byteLength),this.data_.set(new Uint8Array(e))),r=this.data_.length):e instanceof Uint8Array&&(t?this.data_=e:(this.data_=new Uint8Array(e.length),this.data_.set(e)),r=e.length),this.size_=r,this.type_=s}size(){return this.size_}type(){return this.type_}slice(e,t){if(il(this.data_)){const r=this.data_,s=Bv(r,e,t);return s===null?null:new It(s)}else{const r=new Uint8Array(this.data_.buffer,e,t-e);return new It(r,!0)}}static getBlob(...e){if(Ra()){const t=e.map(r=>r instanceof It?r.data_:r);return new It(Fv.apply(null,t))}else{const t=e.map(a=>mi(a)?$v(We.RAW,a).data:a.data_);let r=0;t.forEach(a=>{r+=a.byteLength});const s=new Uint8Array(r);let i=0;return t.forEach(a=>{for(let c=0;c<a.length;c++)s[i++]=a[c]}),new It(s,!0)}}uploadData(){return this.data_}}/**
3429
+ * @license
3430
+ * Copyright 2017 Google LLC
3431
+ *
3432
+ * Licensed under the Apache License, Version 2.0 (the "License");
3433
+ * you may not use this file except in compliance with the License.
3434
+ * You may obtain a copy of the License at
3435
+ *
3436
+ * http://www.apache.org/licenses/LICENSE-2.0
3437
+ *
3438
+ * Unless required by applicable law or agreed to in writing, software
3439
+ * distributed under the License is distributed on an "AS IS" BASIS,
3440
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3441
+ * See the License for the specific language governing permissions and
3442
+ * limitations under the License.
3443
+ */function Yd(n){let e;try{e=JSON.parse(n)}catch{return null}return Nv(e)?e:null}/**
3444
+ * @license
3445
+ * Copyright 2017 Google LLC
3446
+ *
3447
+ * Licensed under the Apache License, Version 2.0 (the "License");
3448
+ * you may not use this file except in compliance with the License.
3449
+ * You may obtain a copy of the License at
3450
+ *
3451
+ * http://www.apache.org/licenses/LICENSE-2.0
3452
+ *
3453
+ * Unless required by applicable law or agreed to in writing, software
3454
+ * distributed under the License is distributed on an "AS IS" BASIS,
3455
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3456
+ * See the License for the specific language governing permissions and
3457
+ * limitations under the License.
3458
+ */function Wv(n){if(n.length===0)return null;const e=n.lastIndexOf("/");return e===-1?"":n.slice(0,e)}function Kv(n,e){const t=e.split("/").filter(r=>r.length>0).join("/");return n.length===0?t:n+"/"+t}function Zd(n){const e=n.lastIndexOf("/",n.length-2);return e===-1?n:n.slice(e+1)}/**
3459
+ * @license
3460
+ * Copyright 2017 Google LLC
3461
+ *
3462
+ * Licensed under the Apache License, Version 2.0 (the "License");
3463
+ * you may not use this file except in compliance with the License.
3464
+ * You may obtain a copy of the License at
3465
+ *
3466
+ * http://www.apache.org/licenses/LICENSE-2.0
3467
+ *
3468
+ * Unless required by applicable law or agreed to in writing, software
3469
+ * distributed under the License is distributed on an "AS IS" BASIS,
3470
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3471
+ * See the License for the specific language governing permissions and
3472
+ * limitations under the License.
3473
+ */function Qv(n,e){return e}class be{constructor(e,t,r,s){this.server=e,this.local=t||e,this.writable=!!r,this.xform=s||Qv}}let ls=null;function Xv(n){return!mi(n)||n.length<2?n:Zd(n)}function ba(){if(ls)return ls;const n=[];n.push(new be("bucket")),n.push(new be("generation")),n.push(new be("metageneration")),n.push(new be("name","fullPath",!0));function e(i,a){return Xv(a)}const t=new be("name");t.xform=e,n.push(t);function r(i,a){return a!==void 0?Number(a):a}const s=new be("size");return s.xform=r,n.push(s),n.push(new be("timeCreated")),n.push(new be("updated")),n.push(new be("md5Hash",null,!0)),n.push(new be("cacheControl",null,!0)),n.push(new be("contentDisposition",null,!0)),n.push(new be("contentEncoding",null,!0)),n.push(new be("contentLanguage",null,!0)),n.push(new be("contentType",null,!0)),n.push(new be("metadata","customMetadata",!0)),ls=n,ls}function Jv(n,e){function t(){const r=n.bucket,s=n.fullPath,i=new Oe(r,s);return e._makeStorageReference(i)}Object.defineProperty(n,"ref",{get:t})}function Yv(n,e,t){const r={};r.type="file";const s=t.length;for(let i=0;i<s;i++){const a=t[i];r[a.local]=a.xform(r,e[a.server])}return Jv(r,n),r}function ef(n,e,t){const r=Yd(e);return r===null?null:Yv(n,r,t)}function Zv(n,e,t,r){const s=Yd(e);if(s===null||!mi(s.downloadTokens))return null;const i=s.downloadTokens;if(i.length===0)return null;const a=encodeURIComponent;return i.split(",").map(d=>{const f=n.bucket,m=n.fullPath,E="/b/"+a(f)+"/o/"+a(m),R=cn(E,t,r),C=Wd({alt:"media",token:d});return R+C})[0]}function tf(n,e){const t={},r=e.length;for(let s=0;s<r;s++){const i=e[s];i.writable&&(t[i.server]=n[i.local])}return JSON.stringify(t)}class Ft{constructor(e,t,r,s){this.url=e,this.method=t,this.handler=r,this.timeout=s,this.urlParams={},this.headers={},this.body=null,this.errorHandler=null,this.progressCallback=null,this.successCodes=[200],this.additionalRetryCodes=[]}}/**
3474
+ * @license
3475
+ * Copyright 2017 Google LLC
3476
+ *
3477
+ * Licensed under the Apache License, Version 2.0 (the "License");
3478
+ * you may not use this file except in compliance with the License.
3479
+ * You may obtain a copy of the License at
3480
+ *
3481
+ * http://www.apache.org/licenses/LICENSE-2.0
3482
+ *
3483
+ * Unless required by applicable law or agreed to in writing, software
3484
+ * distributed under the License is distributed on an "AS IS" BASIS,
3485
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3486
+ * See the License for the specific language governing permissions and
3487
+ * limitations under the License.
3488
+ */function ct(n){if(!n)throw Aa()}function Pa(n,e){function t(r,s){const i=ef(n,s,e);return ct(i!==null),i}return t}function eI(n,e){function t(r,s){const i=ef(n,s,e);return ct(i!==null),Zv(i,s,n.host,n._protocol)}return t}function xr(n){function e(t,r){let s;return t.getStatus()===401?t.getErrorText().includes("Firebase App Check token is invalid")?s=_v():s=gv():t.getStatus()===402?s=mv(n.bucket):t.getStatus()===403?s=yv(n.path):s=r,s.status=t.getStatus(),s.serverResponse=r.serverResponse,s}return e}function gi(n){const e=xr(n);function t(r,s){let i=e(r,s);return r.getStatus()===404&&(i=pv(n.path)),i.serverResponse=s.serverResponse,i}return t}function nf(n,e,t){const r=e.fullServerUrl(),s=cn(r,n.host,n._protocol),i="GET",a=n.maxOperationRetryTime,c=new Ft(s,i,Pa(n,t),a);return c.errorHandler=gi(e),c}function tI(n,e,t){const r=e.fullServerUrl(),s=cn(r,n.host,n._protocol)+"?alt=media",i="GET",a=n.maxOperationRetryTime,c=new Ft(s,i,(l,d)=>d,a);return c.errorHandler=gi(e),c}function nI(n,e,t){const r=e.fullServerUrl(),s=cn(r,n.host,n._protocol),i="GET",a=n.maxOperationRetryTime,c=new Ft(s,i,eI(n,t),a);return c.errorHandler=gi(e),c}function rI(n,e){const t=e.fullServerUrl(),r=cn(t,n.host,n._protocol),s="DELETE",i=n.maxOperationRetryTime;function a(l,d){}const c=new Ft(r,s,a,i);return c.successCodes=[200,204],c.errorHandler=gi(e),c}function sI(n,e){return n&&n.contentType||e&&e.type()||"application/octet-stream"}function rf(n,e,t){const r=Object.assign({},t);return r.fullPath=n.path,r.size=e.size(),r.contentType||(r.contentType=sI(null,e)),r}function iI(n,e,t,r,s){const i=e.bucketOnlyServerUrl(),a={"X-Goog-Upload-Protocol":"multipart"};function c(){let M="";for(let j=0;j<2;j++)M=M+Math.random().toString().slice(2);return M}const l=c();a["Content-Type"]="multipart/related; boundary="+l;const d=rf(e,r,s),f=tf(d,t),m="--"+l+`\r
3489
+ Content-Type: application/json; charset=utf-8\r
3490
+ \r
3491
+ `+f+`\r
3492
+ --`+l+`\r
3493
+ Content-Type: `+d.contentType+`\r
3494
+ \r
3495
+ `,E=`\r
3496
+ --`+l+"--",R=It.getBlob(m,r,E);if(R===null)throw zd();const C={name:d.fullPath},N=cn(i,n.host,n._protocol),k="POST",F=n.maxUploadRetryTime,$=new Ft(N,k,Pa(n,t),F);return $.urlParams=C,$.headers=a,$.body=R.uploadData(),$.errorHandler=xr(e),$}class Hs{constructor(e,t,r,s){this.current=e,this.total=t,this.finalized=!!r,this.metadata=s||null}}function Sa(n,e){let t=null;try{t=n.getResponseHeader("X-Goog-Upload-Status")}catch{ct(!1)}return ct(!!t&&(e||["active"]).indexOf(t)!==-1),t}function oI(n,e,t,r,s){const i=e.bucketOnlyServerUrl(),a=rf(e,r,s),c={name:a.fullPath},l=cn(i,n.host,n._protocol),d="POST",f={"X-Goog-Upload-Protocol":"resumable","X-Goog-Upload-Command":"start","X-Goog-Upload-Header-Content-Length":`${r.size()}`,"X-Goog-Upload-Header-Content-Type":a.contentType,"Content-Type":"application/json; charset=utf-8"},m=tf(a,t),E=n.maxUploadRetryTime;function R(N){Sa(N);let k;try{k=N.getResponseHeader("X-Goog-Upload-URL")}catch{ct(!1)}return ct(mi(k)),k}const C=new Ft(l,d,R,E);return C.urlParams=c,C.headers=f,C.body=m,C.errorHandler=xr(e),C}function aI(n,e,t,r){const s={"X-Goog-Upload-Command":"query"};function i(d){const f=Sa(d,["active","final"]);let m=null;try{m=d.getResponseHeader("X-Goog-Upload-Size-Received")}catch{ct(!1)}m||ct(!1);const E=Number(m);return ct(!isNaN(E)),new Hs(E,r.size(),f==="final")}const a="POST",c=n.maxUploadRetryTime,l=new Ft(t,a,i,c);return l.headers=s,l.errorHandler=xr(e),l}const al=256*1024;function cI(n,e,t,r,s,i,a,c){const l=new Hs(0,0);if(a?(l.current=a.current,l.total=a.total):(l.current=0,l.total=r.size()),r.size()!==l.total)throw Iv();const d=l.total-l.current;let f=d;s>0&&(f=Math.min(f,s));const m=l.current,E=m+f;let R="";f===0?R="finalize":d===f?R="upload, finalize":R="upload";const C={"X-Goog-Upload-Command":R,"X-Goog-Upload-Offset":`${l.current}`},N=r.slice(m,E);if(N===null)throw zd();function k(j,ce){const X=Sa(j,["active","final"]),v=l.current+f,g=r.size();let _;return X==="final"?_=Pa(e,i)(j,ce):_=null,new Hs(v,g,X==="final",_)}const F="POST",$=e.maxUploadRetryTime,M=new Ft(t,F,k,$);return M.headers=C,M.body=N.uploadData(),M.progressCallback=c||null,M.errorHandler=xr(n),M}const ke={RUNNING:"running",PAUSED:"paused",SUCCESS:"success",CANCELED:"canceled",ERROR:"error"};function Ji(n){switch(n){case"running":case"pausing":case"canceling":return ke.RUNNING;case"paused":return ke.PAUSED;case"success":return ke.SUCCESS;case"canceled":return ke.CANCELED;case"error":return ke.ERROR;default:return ke.ERROR}}/**
3497
+ * @license
3498
+ * Copyright 2017 Google LLC
3499
+ *
3500
+ * Licensed under the Apache License, Version 2.0 (the "License");
3501
+ * you may not use this file except in compliance with the License.
3502
+ * You may obtain a copy of the License at
3503
+ *
3504
+ * http://www.apache.org/licenses/LICENSE-2.0
3505
+ *
3506
+ * Unless required by applicable law or agreed to in writing, software
3507
+ * distributed under the License is distributed on an "AS IS" BASIS,
3508
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3509
+ * See the License for the specific language governing permissions and
3510
+ * limitations under the License.
3511
+ */class uI{constructor(e,t,r){if(kv(e)||t!=null||r!=null)this.next=e,this.error=t??void 0,this.complete=r??void 0;else{const i=e;this.next=i.next,this.error=i.error,this.complete=i.complete}}}/**
3512
+ * @license
3513
+ * Copyright 2017 Google LLC
3514
+ *
3515
+ * Licensed under the Apache License, Version 2.0 (the "License");
3516
+ * you may not use this file except in compliance with the License.
3517
+ * You may obtain a copy of the License at
3518
+ *
3519
+ * http://www.apache.org/licenses/LICENSE-2.0
3520
+ *
3521
+ * Unless required by applicable law or agreed to in writing, software
3522
+ * distributed under the License is distributed on an "AS IS" BASIS,
3523
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3524
+ * See the License for the specific language governing permissions and
3525
+ * limitations under the License.
3526
+ */function fn(n){return(...e)=>{Promise.resolve().then(()=>n(...e))}}class sf{constructor(){this.sent_=!1,this.xhr_=new XMLHttpRequest,this.initXhr(),this.errorCode_=Kt.NO_ERROR,this.sendPromise_=new Promise(e=>{this.xhr_.addEventListener("abort",()=>{this.errorCode_=Kt.ABORT,e()}),this.xhr_.addEventListener("error",()=>{this.errorCode_=Kt.NETWORK_ERROR,e()}),this.xhr_.addEventListener("load",()=>{e()})})}send(e,t,r,s){if(this.sent_)throw nr("cannot .send() more than once");if(this.sent_=!0,this.xhr_.open(t,e,!0),s!==void 0)for(const i in s)s.hasOwnProperty(i)&&this.xhr_.setRequestHeader(i,s[i].toString());return r!==void 0?this.xhr_.send(r):this.xhr_.send(),this.sendPromise_}getErrorCode(){if(!this.sent_)throw nr("cannot .getErrorCode() before sending");return this.errorCode_}getStatus(){if(!this.sent_)throw nr("cannot .getStatus() before sending");try{return this.xhr_.status}catch{return-1}}getResponse(){if(!this.sent_)throw nr("cannot .getResponse() before sending");return this.xhr_.response}getErrorText(){if(!this.sent_)throw nr("cannot .getErrorText() before sending");return this.xhr_.statusText}abort(){this.xhr_.abort()}getResponseHeader(e){return this.xhr_.getResponseHeader(e)}addUploadProgressListener(e){this.xhr_.upload!=null&&this.xhr_.upload.addEventListener("progress",e)}removeUploadProgressListener(e){this.xhr_.upload!=null&&this.xhr_.upload.removeEventListener("progress",e)}}class lI extends sf{initXhr(){this.xhr_.responseType="text"}}function wt(){return new lI}class hI extends sf{initXhr(){this.xhr_.responseType="blob"}}function dI(){return new hI}/**
3527
+ * @license
3528
+ * Copyright 2017 Google LLC
3529
+ *
3530
+ * Licensed under the Apache License, Version 2.0 (the "License");
3531
+ * you may not use this file except in compliance with the License.
3532
+ * You may obtain a copy of the License at
3533
+ *
3534
+ * http://www.apache.org/licenses/LICENSE-2.0
3535
+ *
3536
+ * Unless required by applicable law or agreed to in writing, software
3537
+ * distributed under the License is distributed on an "AS IS" BASIS,
3538
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3539
+ * See the License for the specific language governing permissions and
3540
+ * limitations under the License.
3541
+ */class fI{isExponentialBackoffExpired(){return this.sleepTime>this.maxSleepTime}constructor(e,t,r=null){this._transferred=0,this._needToFetchStatus=!1,this._needToFetchMetadata=!1,this._observers=[],this._error=void 0,this._uploadUrl=void 0,this._request=void 0,this._chunkMultiplier=1,this._resolve=void 0,this._reject=void 0,this._ref=e,this._blob=t,this._metadata=r,this._mappings=ba(),this._resumable=this._shouldDoResumable(this._blob),this._state="running",this._errorHandler=s=>{if(this._request=void 0,this._chunkMultiplier=1,s._codeEquals(te.CANCELED))this._needToFetchStatus=!0,this.completeTransitions_();else{const i=this.isExponentialBackoffExpired();if(Kd(s.status,[]))if(i)s=jd();else{this.sleepTime=Math.max(this.sleepTime*2,fv),this._needToFetchStatus=!0,this.completeTransitions_();return}this._error=s,this._transition("error")}},this._metadataErrorHandler=s=>{this._request=void 0,s._codeEquals(te.CANCELED)?this.completeTransitions_():(this._error=s,this._transition("error"))},this.sleepTime=0,this.maxSleepTime=this._ref.storage.maxUploadRetryTime,this._promise=new Promise((s,i)=>{this._resolve=s,this._reject=i,this._start()}),this._promise.then(null,()=>{})}_makeProgressCallback(){const e=this._transferred;return t=>this._updateProgress(e+t)}_shouldDoResumable(e){return e.size()>256*1024}_start(){this._state==="running"&&this._request===void 0&&(this._resumable?this._uploadUrl===void 0?this._createResumable():this._needToFetchStatus?this._fetchStatus():this._needToFetchMetadata?this._fetchMetadata():this.pendingTimeout=setTimeout(()=>{this.pendingTimeout=void 0,this._continueUpload()},this.sleepTime):this._oneShotUpload())}_resolveToken(e){Promise.all([this._ref.storage._getAuthToken(),this._ref.storage._getAppCheckToken()]).then(([t,r])=>{switch(this._state){case"running":e(t,r);break;case"canceling":this._transition("canceled");break;case"pausing":this._transition("paused");break}})}_createResumable(){this._resolveToken((e,t)=>{const r=oI(this._ref.storage,this._ref._location,this._mappings,this._blob,this._metadata),s=this._ref.storage._makeRequest(r,wt,e,t);this._request=s,s.getPromise().then(i=>{this._request=void 0,this._uploadUrl=i,this._needToFetchStatus=!1,this.completeTransitions_()},this._errorHandler)})}_fetchStatus(){const e=this._uploadUrl;this._resolveToken((t,r)=>{const s=aI(this._ref.storage,this._ref._location,e,this._blob),i=this._ref.storage._makeRequest(s,wt,t,r);this._request=i,i.getPromise().then(a=>{a=a,this._request=void 0,this._updateProgress(a.current),this._needToFetchStatus=!1,a.finalized&&(this._needToFetchMetadata=!0),this.completeTransitions_()},this._errorHandler)})}_continueUpload(){const e=al*this._chunkMultiplier,t=new Hs(this._transferred,this._blob.size()),r=this._uploadUrl;this._resolveToken((s,i)=>{let a;try{a=cI(this._ref._location,this._ref.storage,r,this._blob,e,this._mappings,t,this._makeProgressCallback())}catch(l){this._error=l,this._transition("error");return}const c=this._ref.storage._makeRequest(a,wt,s,i,!1);this._request=c,c.getPromise().then(l=>{this._increaseMultiplier(),this._request=void 0,this._updateProgress(l.current),l.finalized?(this._metadata=l.metadata,this._transition("success")):this.completeTransitions_()},this._errorHandler)})}_increaseMultiplier(){al*this._chunkMultiplier*2<32*1024*1024&&(this._chunkMultiplier*=2)}_fetchMetadata(){this._resolveToken((e,t)=>{const r=nf(this._ref.storage,this._ref._location,this._mappings),s=this._ref.storage._makeRequest(r,wt,e,t);this._request=s,s.getPromise().then(i=>{this._request=void 0,this._metadata=i,this._transition("success")},this._metadataErrorHandler)})}_oneShotUpload(){this._resolveToken((e,t)=>{const r=iI(this._ref.storage,this._ref._location,this._mappings,this._blob,this._metadata),s=this._ref.storage._makeRequest(r,wt,e,t);this._request=s,s.getPromise().then(i=>{this._request=void 0,this._metadata=i,this._updateProgress(this._blob.size()),this._transition("success")},this._errorHandler)})}_updateProgress(e){const t=this._transferred;this._transferred=e,this._transferred!==t&&this._notifyObservers()}_transition(e){if(this._state!==e)switch(e){case"canceling":case"pausing":this._state=e,this._request!==void 0?this._request.cancel():this.pendingTimeout&&(clearTimeout(this.pendingTimeout),this.pendingTimeout=void 0,this.completeTransitions_());break;case"running":const t=this._state==="paused";this._state=e,t&&(this._notifyObservers(),this._start());break;case"paused":this._state=e,this._notifyObservers();break;case"canceled":this._error=Hd(),this._state=e,this._notifyObservers();break;case"error":this._state=e,this._notifyObservers();break;case"success":this._state=e,this._notifyObservers();break}}completeTransitions_(){switch(this._state){case"pausing":this._transition("paused");break;case"canceling":this._transition("canceled");break;case"running":this._start();break}}get snapshot(){const e=Ji(this._state);return{bytesTransferred:this._transferred,totalBytes:this._blob.size(),state:e,metadata:this._metadata,task:this,ref:this._ref}}on(e,t,r,s){const i=new uI(t||void 0,r||void 0,s||void 0);return this._addObserver(i),()=>{this._removeObserver(i)}}then(e,t){return this._promise.then(e,t)}catch(e){return this.then(null,e)}_addObserver(e){this._observers.push(e),this._notifyObserver(e)}_removeObserver(e){const t=this._observers.indexOf(e);t!==-1&&this._observers.splice(t,1)}_notifyObservers(){this._finishPromise(),this._observers.slice().forEach(t=>{this._notifyObserver(t)})}_finishPromise(){if(this._resolve!==void 0){let e=!0;switch(Ji(this._state)){case ke.SUCCESS:fn(this._resolve.bind(null,this.snapshot))();break;case ke.CANCELED:case ke.ERROR:const t=this._reject;fn(t.bind(null,this._error))();break;default:e=!1;break}e&&(this._resolve=void 0,this._reject=void 0)}}_notifyObserver(e){switch(Ji(this._state)){case ke.RUNNING:case ke.PAUSED:e.next&&fn(e.next.bind(e,this.snapshot))();break;case ke.SUCCESS:e.complete&&fn(e.complete.bind(e))();break;case ke.CANCELED:case ke.ERROR:e.error&&fn(e.error.bind(e,this._error))();break;default:e.error&&fn(e.error.bind(e,this._error))()}}resume(){const e=this._state==="paused"||this._state==="pausing";return e&&this._transition("running"),e}pause(){const e=this._state==="running";return e&&this._transition("pausing"),e}cancel(){const e=this._state==="running"||this._state==="pausing";return e&&this._transition("canceling"),e}}/**
3542
+ * @license
3543
+ * Copyright 2019 Google LLC
3544
+ *
3545
+ * Licensed under the Apache License, Version 2.0 (the "License");
3546
+ * you may not use this file except in compliance with the License.
3547
+ * You may obtain a copy of the License at
3548
+ *
3549
+ * http://www.apache.org/licenses/LICENSE-2.0
3550
+ *
3551
+ * Unless required by applicable law or agreed to in writing, software
3552
+ * distributed under the License is distributed on an "AS IS" BASIS,
3553
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3554
+ * See the License for the specific language governing permissions and
3555
+ * limitations under the License.
3556
+ */class tn{constructor(e,t){this._service=e,t instanceof Oe?this._location=t:this._location=Oe.makeFromUrl(t,e.host)}toString(){return"gs://"+this._location.bucket+"/"+this._location.path}_newRef(e,t){return new tn(e,t)}get root(){const e=new Oe(this._location.bucket,"");return this._newRef(this._service,e)}get bucket(){return this._location.bucket}get fullPath(){return this._location.path}get name(){return Zd(this._location.path)}get storage(){return this._service}get parent(){const e=Wv(this._location.path);if(e===null)return null;const t=new Oe(this._location.bucket,e);return new tn(this._service,t)}_throwIfRoot(e){if(this._location.path==="")throw Rv(e)}}function pI(n,e){n._throwIfRoot("getBlob");const t=tI(n.storage,n._location);return n.storage.makeRequestWithTokens(t,dI).then(r=>r)}function mI(n,e,t){return n._throwIfRoot("uploadBytesResumable"),new fI(n,new It(e),t)}function gI(n){n._throwIfRoot("getMetadata");const e=nf(n.storage,n._location,ba());return n.storage.makeRequestWithTokens(e,wt)}function _I(n){n._throwIfRoot("getDownloadURL");const e=nI(n.storage,n._location,ba());return n.storage.makeRequestWithTokens(e,wt).then(t=>{if(t===null)throw wv();return t})}function yI(n){n._throwIfRoot("deleteObject");const e=rI(n.storage,n._location);return n.storage.makeRequestWithTokens(e,wt)}function TI(n,e){const t=Kv(n._location.path,e),r=new Oe(n._location.bucket,t);return new tn(n.storage,r)}/**
3557
+ * @license
3558
+ * Copyright 2017 Google LLC
3559
+ *
3560
+ * Licensed under the Apache License, Version 2.0 (the "License");
3561
+ * you may not use this file except in compliance with the License.
3562
+ * You may obtain a copy of the License at
3563
+ *
3564
+ * http://www.apache.org/licenses/LICENSE-2.0
3565
+ *
3566
+ * Unless required by applicable law or agreed to in writing, software
3567
+ * distributed under the License is distributed on an "AS IS" BASIS,
3568
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3569
+ * See the License for the specific language governing permissions and
3570
+ * limitations under the License.
3571
+ */function EI(n){return/^[A-Za-z]+:\/\//.test(n)}function vI(n,e){return new tn(n,e)}function of(n,e){if(n instanceof Ca){const t=n;if(t._bucket==null)throw vv();const r=new tn(t,t._bucket);return e!=null?of(r,e):r}else return e!==void 0?TI(n,e):n}function II(n,e){if(e&&EI(e)){if(n instanceof Ca)return vI(n,e);throw Io("To use ref(service, url), the first argument must be a Storage instance.")}else return of(n,e)}function cl(n,e){const t=e==null?void 0:e[$d];return t==null?null:Oe.makeFromBucketSpec(t,n)}function wI(n,e,t,r={}){n.host=`${e}:${t}`,n._protocol="http";const{mockUserToken:s}=r;s&&(n._overrideAuthToken=typeof s=="string"?s:_l(s,n.app.options.projectId))}class Ca{constructor(e,t,r,s,i){this.app=e,this._authProvider=t,this._appCheckProvider=r,this._url=s,this._firebaseVersion=i,this._bucket=null,this._host=qd,this._protocol="https",this._appId=null,this._deleted=!1,this._maxOperationRetryTime=hv,this._maxUploadRetryTime=dv,this._requests=new Set,s!=null?this._bucket=Oe.makeFromBucketSpec(s,this._host):this._bucket=cl(this._host,this.app.options)}get host(){return this._host}set host(e){this._host=e,this._url!=null?this._bucket=Oe.makeFromBucketSpec(this._url,e):this._bucket=cl(e,this.app.options)}get maxUploadRetryTime(){return this._maxUploadRetryTime}set maxUploadRetryTime(e){ol("time",0,Number.POSITIVE_INFINITY,e),this._maxUploadRetryTime=e}get maxOperationRetryTime(){return this._maxOperationRetryTime}set maxOperationRetryTime(e){ol("time",0,Number.POSITIVE_INFINITY,e),this._maxOperationRetryTime=e}async _getAuthToken(){if(this._overrideAuthToken)return this._overrideAuthToken;const e=this._authProvider.getImmediate({optional:!0});if(e){const t=await e.getToken();if(t!==null)return t.accessToken}return null}async _getAppCheckToken(){if(Pe(this.app)&&this.app.settings.appCheckToken)return this.app.settings.appCheckToken;const e=this._appCheckProvider.getImmediate({optional:!0});return e?(await e.getToken()).token:null}_delete(){return this._deleted||(this._deleted=!0,this._requests.forEach(e=>e.cancel()),this._requests.clear()),Promise.resolve()}_makeStorageReference(e){return new tn(this,e)}_makeRequest(e,t,r,s,i=!0){if(this._deleted)return new bv(Gd());{const a=xv(e,this._appId,r,s,t,this._firebaseVersion,i);return this._requests.add(a),a.getPromise().then(()=>this._requests.delete(a),()=>this._requests.delete(a)),a}}async makeRequestWithTokens(e,t){const[r,s]=await Promise.all([this._getAuthToken(),this._getAppCheckToken()]);return this._makeRequest(e,t,r,s).getPromise()}}const ul="@firebase/storage",ll="0.13.7";/**
3572
+ * @license
3573
+ * Copyright 2020 Google LLC
3574
+ *
3575
+ * Licensed under the Apache License, Version 2.0 (the "License");
3576
+ * you may not use this file except in compliance with the License.
3577
+ * You may obtain a copy of the License at
3578
+ *
3579
+ * http://www.apache.org/licenses/LICENSE-2.0
3580
+ *
3581
+ * Unless required by applicable law or agreed to in writing, software
3582
+ * distributed under the License is distributed on an "AS IS" BASIS,
3583
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3584
+ * See the License for the specific language governing permissions and
3585
+ * limitations under the License.
3586
+ */const af="storage";function AI(n,e,t){return n=Z(n),mI(n,e,t)}function RI(n){return n=Z(n),gI(n)}function bI(n){return n=Z(n),_I(n)}function PI(n){return n=Z(n),yI(n)}function rr(n,e){return n=Z(n),II(n,e)}function SI(n=Gs(),e){n=Z(n);const r=Pr(n,af).getImmediate({identifier:e}),s=Ao("storage");return s&&CI(r,...s),r}function CI(n,e,t,r={}){wI(n,e,t,r)}/**
3587
+ * @license
3588
+ * Copyright 2021 Google LLC
3589
+ *
3590
+ * Licensed under the Apache License, Version 2.0 (the "License");
3591
+ * you may not use this file except in compliance with the License.
3592
+ * You may obtain a copy of the License at
3593
+ *
3594
+ * http://www.apache.org/licenses/LICENSE-2.0
3595
+ *
3596
+ * Unless required by applicable law or agreed to in writing, software
3597
+ * distributed under the License is distributed on an "AS IS" BASIS,
3598
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3599
+ * See the License for the specific language governing permissions and
3600
+ * limitations under the License.
3601
+ */function kI(n,e){return n=Z(n),pI(n)}function NI(n,{instanceIdentifier:e}){const t=n.getProvider("app").getImmediate(),r=n.getProvider("auth-internal"),s=n.getProvider("app-check-internal");return new Ca(t,r,s,e,nn)}function DI(){St(new ut(af,NI,"PUBLIC").setMultipleInstances(!0)),qe(ul,ll,""),qe(ul,ll,"esm2017")}DI();var OI=new rt,VI=n=>({getCurrentUser:async()=>{let e=n.currentUser;if(!e)return null;let{claims:t}=await e.getIdTokenResult();return{...e,role:t.role}},loginWithPassword:async(e,{email:t,password:r})=>{let s=(await Fg(n,t,r)).user;if(!s)throw new Error("No user found");let{claims:i}=await s.getIdTokenResult();return{...s,role:i.role}},loginWithPopup:async()=>{let e=(await c_(n,OI)).user;if(!e)throw new Error("No user found");let{claims:t}=await e.getIdTokenResult();return{...e,role:t.role}},logout:async()=>{await $g(n)},loginWithToken:async e=>{let t=(await xg(n,e)).user;if(!t)throw new Error("No user found");let{claims:r}=await t.getIdTokenResult();return{...t,role:r.role}},subscribeToUser:e=>Hl(n,t=>{t?t.getIdTokenResult().then(r=>{let{claims:s}=r;e({...t,role:s==null?void 0:s.role})}):e(null)})}),cf=(n,e)=>{var f;let{collection:t,filters:r,limit:s,search:i,sort:a,isCollectionGroup:c,cursor:l}=e,d=c?Ed(n,t):Td(n,t);if(r&&r.forEach(({key:m,operator:E,value:R})=>{d=Ue(d,wn(m,E,R))}),a&&(d=Ue(d,Cd(a.key,a.direction))),l&&(d=Ue(d,Nd(l))),((f=i.paths)==null?void 0:f.length)&&i.query){let m=(i.query||"").trim();m&&(d=Ue(d,wn(i.paths[0].prop,">=",m),wn(i.paths[0].prop,"<=",`${m}`)))}return Ue(d,kd(s))},LI=(n,e,t)=>{var f;let{collection:r,filters:s,sort:i,isCollectionGroup:a,search:c,limit:l}=e,d=a?Ed(n,r):Td(n,r);if(s&&s.forEach(({key:m,operator:E,value:R})=>{d=Ue(d,wn(m,E,R))}),i&&(d=Ue(d,Cd(i.key,i.direction))),((f=c.paths)==null?void 0:f.length)&&c.query){let m=(c.query||"").trim();m&&(d=Ue(d,wn(c.paths[0].prop,">=",m),wn(c.paths[0].prop,"<=",`${m}`)))}return t&&(d=Ue(d,Nd(t))),d=Ue(d,kd(l)),Ue(d,iv(1))},MI=n=>(e,t,r)=>{let s=cf(n,e);return Ud(s,i=>{let a=i.docs.map(c=>c.data());t(a,i.docs[i.docs.length-1])},i=>{r({code:i.code,message:i.name,description:i.message})})},xI=n=>async e=>{let{cursor:t}=e,r=t?await Ld(Un(n,e.collection,t.id)):null,s=LI(n,e,r);return(await Md(s)).docs[0]??null},UI=n=>async e=>{let t=Fm(n,"getQueryCount"),{data:r}=await t(e);return r.count},FI=n=>async e=>{let t=Un(n,e),r=await Ld(t),s=r.data();return s?{...s,_id:r.id}:null},BI=n=>async e=>{let t=cf(n,e);return(await Md(t)).docs.map(r=>({...r.data(),_id:r.id}))},qI=n=>async(e,t)=>{let r=Un(n,e),s=Wf(Ht.getState().user,t,!0);return await xd(r,s,{merge:!0}),r.id},$I=n=>async e=>{let t=Un(n,e);await lv(t)},jI=n=>async(e,t)=>{let r=Un(n,e);await xd(r,t,{merge:!0})},HI=n=>(e,t,r)=>{let s=Un(n,e);return Ud(s,i=>{let a=i.data();t(a?{...a,_id:i.id}:null)},i=>{r({code:i.code,message:i.name,description:i.message})})},zI=(n,e)=>({subscribeToQuery:MI(n),fetchNextCursor:xI(n),fetchCount:UI(e),fetchItem:FI(n),fetchItems:BI(n),createItem:qI(n),deleteItem:$I(n),updateItem:jI(n),subscribeToItem:HI(n)}),GI=n=>({delete:async e=>{await PI(rr(n,e))},fetchObject:async e=>{let t=rr(n,e);return await kI(t)},fetchMetadata:async e=>{let t=rr(n,e);return await RI(t)},getObjectUrl:async e=>{let t=rr(n,e);return await bI(t)},upload:async(e,t,r)=>{let s=rr(n,e),i=AI(s,new Blob([t.dataUrl]));i.on("state_changed",c=>{let l=c.bytesTransferred/c.totalBytes*100;r({loaded:c.bytesTransferred,total:c.totalBytes,percent:l})});let a={filename:t.filename,type:t.type,storagePath:e};return await i.then(),a}}),JI=(n,e,t,r)=>({auth:VI(n),db:zI(e,r),storage:GI(t)}),uf=nt.createContext({app:null,auth:null,db:null,storage:null,functions:null,authProviders:[],signOut:()=>{}}),YI=({children:n,app:e,authProviders:t})=>{let[r]=nt.useState(Z_(e)),[s]=nt.useState(QE(e)),[i]=nt.useState(SI(e)),[a]=nt.useState(xm(e));nt.useEffect(()=>Hl(r,d=>{if(!d){Ht.setState({user:null,loading:!1});return}Ht.setState({loading:!0}),Pl(d).then(f=>{Ht.setState({user:{...d,role:f.claims.admin?"admin":"user"},loading:!1})})}),[r]);let c=nt.useCallback(async()=>{Ht.setState({loading:!0});try{await r.signOut(),Ht.setState({user:null,loading:!1})}catch(d){console.error(d)}finally{Ht.setState({loading:!1})}},[r]),l=nt.useMemo(()=>({app:e,auth:r,authProviders:t,db:s,storage:i,signOut:c,functions:a}),[e,r,s,i,a,c,t]);return Kf.jsx(uf.Provider,{value:l,children:n})},ZI=()=>nt.useContext(uf),ew=()=>Gf();export{YI as E,ew as H,ZI as M,SI as a,QE as b,Z_ as c,xm as g,Fm as h,am as i,qe as r,JI as u};