1import{o as $f}from"./vendor-Co-R6l_k.js";const jf=()=>{};var Oc={};/** 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 _l=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},Hf=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++],u=n[t++],l=((s&7)<<18|(i&63)<<12|(a&63)<<6|u&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("")},yl={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,u=a?n[s+1]:0,l=s+2<n.length,d=l?n[s+2]:0,f=i>>2,m=(i&3)<<4|u>>4;let _=(u&15)<<2|d>>6,S=d&63;l||(S=64,a||(_=64)),r.push(t[f],t[m],t[_],t[S])}return r.join("")},encodeString(n,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(n):this.encodeByteArray(_l(n),e)},decodeString(n,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(n):Hf(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++)],u=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||u==null||d==null||m==null)throw new zf;const _=i<<2|u>>4;if(r.push(_),d!==64){const S=u<<4&240|d>>2;if(r.push(S),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 zf extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}const Gf=function(n){const e=_l(n);return yl.encodeByteArray(e,!0)},ws=function(n){return Gf(n).replace(/\./g,"")},El=function(n){try{return yl.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, softw
26are 27 * distributed under the License is distributed on an "AS IS" BASIS, 28 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 29 * See the License for the specific language governing permissions and 30 * limitations under the License. 31 */function Wf(){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 Kf=()=>Wf().__FIREBASE_DEFAULTS__,Qf=()=>{if(typeof process>"u"||typeof Oc>"u")return;const n=Oc.__FIREBASE_DEFAULTS__;if(n)return JSON.parse(n)},Jf=()=>{if(typeof document>"u")return;let n;try{n=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch{return}const e=n&&El(n[1]);return e&&JSON.parse(e)},zs=()=>{try{return jf()||Kf()||Qf()||Jf()}catch(n){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${n}`);return}},Tl=n=>{var e,t;return(t=(e=zs())==null?void 0:e.emulatorHosts)==null?void 0:t[n]},Co=n=>{const e=Tl(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]},Il=()=>{var n;return(n=zs())==null?void 0:n.config},wl=n=>{var e;return(e=zs())==null?void 0:e[`_${n}`]};/** 47 * @license 48 * Copyright 2017 Google LLC 49 * 50 * Licensed under the Apache License, Version 2.0 (the "License"); 51 * you may not use this file except in compliance with the License. 52 * You may obtain a copy of the License at 53 * 54 * http://www.apache.org/licenses/LICENSE-2.0 55 * 56 * Unless required by applicable law or agreed to in writing, software 57 * distributed under the License is distributed on an "AS IS" BASIS, 58 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 59 * See the License for the specific language governing permissions and 60 * limitations under the License. 61 */class Yf{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}wrapCallback(e){return(t,r)=>{t?this.reject(t):this.resolve(r),typeof e=="function"&&(this.promise.catch(()=>{}),e.length===1?e(t):e(t,r))}}}/** 62 * @license 63 * Copyright 2025 Google LLC 64 * 65 * Licensed under the Apache License, Version 2.0 (the "License"); 66 * you may not use this file except in compliance with the License. 67 * You may obtain a copy of the License at 68 * 69 * http://www.apache.org/licenses/LICENSE-2.0 70 * 71 * Unless required by applicable law or agreed to in writing, software 72 * distributed under the License is distributed on an "AS IS" BASIS, 73 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 74 * See the License for the specific language governing permissions and 75 * limitations under the License. 76 */function ot(n){try{return(n.startsWith("http://")||n.startsWith("https://")?new URL(n).hostname:n).endsWith(".cloudworkstations.dev")}catch{return!1}}async function Gs(n){return(await fetch(n,{credentials:"include"})).ok}/** 77 * @license 78 * Copyright 2021 Google LLC 79 * 80 * Licensed under the Apache License, Version 2.0 (the "License"); 81 * you may not use this file except in compliance with the License. 82 * You may obtain a copy of the License at 83 * 84 * http://www.apache.org/licenses/LICENSE-2.0 85 * 86 * Unless required by applicable law or agreed to in writing, 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 vl(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={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[ws(JSON.stringify(t)),ws(JSON.stringify(a)),""].join(".")}const fr={};function Xf(){const n={prod:[],emulator:[]};for(const e of Object.keys(fr))fr[e]?n.emulator.push(e):n.prod.push(e);return n}function Zf(n){let e=document.getElementById(n),t=!1;return e||(e=document.createElement("div"),e.setAttribute("id",n),t=!0),{created:t,element:e}}let Lc=!1;function Ws(n,e){if(typeof window>"u"||typeof document>"u"||!ot(window.location.host)||fr[n]===e||fr[n]||Lc)return;fr[n]=e;function t(_){return`__firebase__banner__${_}`}const r="__firebase__banner",i=Xf().prod.length>0;function a(){const _=document.getElementById(r);_&&_.remove()}function u(_){_.style.display="flex",_.style.background="#7faaf0",_.
91style.position="fixed",_.style.bottom="5px",_.style.left="5px",_.style.padding=".5em",_.style.borderRadius="5px",_.style.alignItems="center"}function l(_,S){_.setAttribute("width","24"),_.setAttribute("id",S),_.setAttribute("height","24"),_.setAttribute("viewBox","0 0 24 24"),_.setAttribute("fill","none"),_.style.marginLeft="-6px"}function d(){const _=document.createElement("span");return _.style.cursor="pointer",_.style.marginLeft="16px",_.style.fontSize="24px",_.innerHTML=" ×",_.onclick=()=>{Lc=!0,a()},_}function f(_,S){_.setAttribute("id",S),_.innerText="Learn more",_.href="https://firebase.google.com/docs/studio/preview-apps#preview-backend",_.setAttribute("target","__blank"),_.style.paddingLeft="5px",_.style.textDecoration="underline"}function m(){const _=Zf(r),S=t("text"),C=document.getElementById(S)||document.createElement("span"),D=t("learnmore"),k=document.getElementById(D)||document.createElement("a"),q=t("preprendIcon"),F=document.getElementById(q)||document.createElementNS("http://www.w3.org/2000/svg","svg");if(_.created){const $=_.element;u($),f(k,D);const Q=d();l(F,q),$.append(F,C,k,Q),document.body.appendChild($)}i?(C.innerText="Preview backend disconnected.",F.innerHTML=`<g clip-path="url(#clip0_6013_33858)"> 92<path d="M4.8 17.6L12 5.6L19.2 17.6H4.8ZM6.91667 16.4H17.0833L12 7.93333L6.91667 16.4ZM12 15.6C12.1667 15.6 12.3056 15.5444 12.4167 15.4333C12.5389 15.3111 12.6 15.1667 12.6 15C12.6 14.8333 12.5389 14.6944 12.4167 14.5833C12.3056 14.4611 12.1667 14.4 12 14.4C11.8333 14.4 11.6889 14.4611 11.5667 14.5833C11.4556 14.6944 11.4 14.8333 11.4 15C11.4 15.1667 11.4556 15.3111 11.5667 15.4333C11.6889 15.5444 11.8333 15.6 12 15.6ZM11.4 13.6H12.6V10.4H11.4V13.6Z" fill="#212121"/> 93</g> 94<defs> 95<clipPath id="clip0_6013_33858"> 96<rect width="24" height="24" fill="white"/> 97</clipPath> 98</defs>`):(F.innerHTML=`<g clip-path="url(#clip0_6083_34804)"> 99<path d="M11.4 15.2H12.6V11.2H11.4V15.2ZM12 10C12.1667 10 12.3056 9.94444 12.4167 9.83333C12.5389 9.71111 12.6 9.56667 12.6 9.4C12.6 9.23333 12.5389 9.09444 12.4167 8.98333C12.3056 8.86111 12.1667 8.8 12 8.8C11.8333 8.8 11.6889 8.86111 11.5667 8.98333C11.4556 9.09444 11.4 9.23333 11.4 9.4C11.4 9.56667 11.4556 9.71111 11.5667 9.83333C11.6889 9.94444 11.8333 10 12 10ZM12 18.4C11.1222 18.4 10.2944 18.2333 9.51667 17.9C8.73889 17.5667 8.05556 17.1111 7.46667 16.5333C6.88889 15.9444 6.43333 15.2611 6.1 14.4833C5.76667 13.7056 5.6 12.8778 5.6 12C5.6 11.1111 5.76667 10.2833 6.1 9.51667C6.43333 8.73889 6.88889 8.06111 7.46667 7.48333C8.05556 6.89444 8.73889 6.43333 9.51667 6.1C10.2944 5.76667 11.1222 5.6 12 5.6C12.8889 5.6 13.7167 5.76667 14.4833 6.1C15.2611 6.43333 15.9389 6.89444 16.5167 7.48333C17.1056 8.06111 17.5667 8.73889 17.9 9.51667C18.2333 10.2833 18.4 11.1111 18.4 12C18.4 12.8778 18.2333 13.7056 17.9 14.4833C17.5667 15.2611 17.1056 15.9444 16.5167 16.5333C15.9389 17.1111 15.2611 17.5667 14.4833 17.9C13.7167 18.2333 12.8889 18.4 12 18.4ZM12 17.2C13.4444 17.2 14.6722 16.6944 15.6833 15.6833C16.6944 14.6722 17.2 13.4444 17.2 12C17.2 10.5556 16.6944 9.32778 15.6833 8.31667C14.6722 7.30555 13.4444 6.8 12 6.8C10.5556 6.8 9.32778 7.30555 8.31667 8.31667C7.30556 9.32778 6.8 10.5556 6.8 12C6.8 13.4444 7.30556 14.6722 8.31667 15.6833C9.32778 16.6944 10.5556 17.2 12 17.2Z" fill="#212121"/> 100</g> 101<defs> 102<clipPath id="clip0_6083_34804"> 103<rect width="24" height="24" fill="white"/> 104</clipPath> 105</defs>`,C.innerText="Preview backend running in this workspace."),C.setAttribute("id",S)}document.readyState==="loading"?window.addEventListener("DOMContentLoaded",m):m()}/** 106 * @license 107 * Copyright 2017 Google LLC 108 * 109 * Licensed under the Apache License, Version 2.0 (the "License"); 110 * you may not use this file except in compliance with the License. 111 * You may obtain a copy of the License at 112 * 113 * http://www.apache.org/licenses/LICENSE-2.0 114 * 115 * Unless required by applicable law or agreed to in writing, software 116 * distributed under the License is distributed on an "AS IS" BASIS, 117 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 118 * See the License for the specific language governing permissions and 119 * limitations under the License. 120 */function Ae(){return typeof navigator<"u"&&typeof navigator.userAgent=="string"?navigator.userAgent:""}function ep(){return typeof window<"u"&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(Ae())}function tp(){var e;const n=(e=zs())==null?void 0:e.forceEnvironment;if(n==="node")return!0;
120if(n==="browser")return!1;try{return Object.prototype.toString.call(global.process)==="[object process]"}catch{return!1}}function np(){return typeof navigator<"u"&&navigator.userAgent==="Cloudflare-Workers"}function rp(){const n=typeof chrome=="object"?chrome.runtime:typeof browser=="object"?browser.runtime:void 0;return typeof n=="object"&&n.id!==void 0}function sp(){return typeof navigator=="object"&&navigator.product==="ReactNative"}function ip(){const n=Ae();return n.indexOf("MSIE ")>=0||n.indexOf("Trident/")>=0}function op(){return!tp()&&!!navigator.userAgent&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}function ap(){try{return typeof indexedDB=="object"}catch{return!1}}function cp(){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?void 0:i.message)||"")}}catch(t){e(t)}})}/** 121 * @license 122 * Copyright 2017 Google LLC 123 * 124 * Licensed under the Apache License, Version 2.0 (the "License"); 125 * you may not use this file except in compliance with the License. 126 * You may obtain a copy of the License at 127 * 128 * http://www.apache.org/licenses/LICENSE-2.0 129 * 130 * Unless required by applicable law or agreed to in writing, software 131 * distributed under the License is distributed on an "AS IS" BASIS, 132 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 133 * See the License for the specific language governing permissions and 134 * limitations under the License. 135 */const up="FirebaseError";class ze extends Error{constructor(e,t,r){super(t),this.code=e,this.customData=r,this.name=up,Object.setPrototypeOf(this,ze.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,kr.prototype.create)}}class kr{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?lp(i,r):"Error",u=`${this.serviceName}: ${a} (${s}).`;return new ze(s,u,r)}}function lp(n,e){return n.replace(hp,(t,r)=>{const s=e[r];return s!=null?String(s):`<${r}?>`})}const hp=/\{\$([^}]+)}/g;function dp(n){for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e))return!1;return!0}function nn(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(Mc(i)&&Mc(a)){if(!nn(i,a))return!1}else if(i!==a)return!1}for(const s of r)if(!t.includes(s))return!1;return!0}function Mc(n){return n!==null&&typeof n=="object"}/** 136 * @license 137 * Copyright 2017 Google LLC 138 * 139 * Licensed under the Apache License, Version 2.0 (the "License"); 140 * you may not use this file except in compliance with the License. 141 * You may obtain a copy of the License at 142 * 143 * http://www.apache.org/licenses/LICENSE-2.0 144 * 145 * Unless required by applicable law or agreed to in writing, software 146 * distributed under the License is distributed on an "AS IS" BASIS, 147 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 148 * See the License for the specific language governing permissions and 149 * limitations under the License. 150 */function Nr(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 ar(n){const e={};return n.replace(/^\?/,"").split("&").forEach(r=>{if(r){const[s,i]=r.split("=");e[decodeURIComponent(s)]=decodeURIComponent(i)}}),e}function cr(n){const e=n.indexOf("?");if(!e)return"";const t=n.indexOf("#",e);return n.substring(e,t>0?t:void 0)}function fp(n,e){const t=new pp(n,e);return t.subscribe.bind(t)}class pp{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.");mp(e,["next","error","complete"])?s=e:s={next:e,error:t,complete:r},s.next===void 0&&(s.next=Hi),s.error===void 0&&(s.error=Hi),s.complete===void 0&&(s.complete=Hi);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(()=>
150{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 mp(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 Hi(){}/** 151 * @license 152 * Copyright 2021 Google LLC 153 * 154 * Licensed under the Apache License, Version 2.0 (the "License"); 155 * you may not use this file except in compliance with the License. 156 * You may obtain a copy of the License at 157 * 158 * http://www.apache.org/licenses/LICENSE-2.0 159 * 160 * Unless required by applicable law or agreed to in writing, software 161 * distributed under the License is distributed on an "AS IS" BASIS, 162 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 163 * See the License for the specific language governing permissions and 164 * limitations under the License. 165 */function H(n){return n&&n._delegate?n._delegate:n}class ht{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}}/** 166 * @license 167 * Copyright 2019 Google LLC 168 * 169 * Licensed under the Apache License, Version 2.0 (the "License"); 170 * you may not use this file except in compliance with the License. 171 * You may obtain a copy of the License at 172 * 173 * http://www.apache.org/licenses/LICENSE-2.0 174 * 175 * Unless required by applicable law or agreed to in writing, software 176 * distributed under the License is distributed on an "AS IS" BASIS, 177 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 178 * See the License for the specific language governing permissions and 179 * limitations under the License. 180 */const Yt="[DEFAULT]";/** 181 * @license 182 * Copyright 2019 Google LLC 183 * 184 * Licensed under the Apache License, Version 2.0 (the "License"); 185 * you may not use this file except in compliance with the License. 186 * You may obtain a copy of the License at 187 * 188 * http://www.apache.org/licenses/LICENSE-2.0 189 * 190 * Unless required by applicable law or agreed to in writing, software 191 * distributed under the License is distributed on an "AS IS" BASIS, 192 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 193 * See the License for the specific language governing permissions and 194 * limitations under the License. 195 */class gp{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 Yf;if(this.instancesDeferred.set(t,r),this.isInitialized(t)||this.shouldAutoInitialize())try{const s=this.getOrInitializeService({instanceIdentifier:t});s&&r.resolve(s)}catch{}}return this.instancesDeferred.get(t).promise}getImmediate(e){const t=this.normalizeInstanceIdentifier(e==null?void 0:e.identifier),r=(e==null?void 0:e.optional)??!1;if(this.isInitialized(t)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:t})}catch(s){if(r)return null;throw s}else{if(r)return null;throw Error(`Service ${this.name} is not available`)}}getComponent(){return this.component}setComponent(e){if(e.name!==this.name)throw Error(`Mismatching Component ${e.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=e,!!this.shouldAutoInitialize()){if(yp(e))try{this.getOrInitializeService({instanceIdentifier:Yt})}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=Yt){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=Yt){return this.instances.has(e)}getOptions(e=Yt){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 u=this.normalizeInstanceIdentifier(i);r===u&&a.resolve(s)}return s}onInit(e,t){const r=this.normalizeInstanceIdentifier(t),s=this.onInitCallbacks.get(r)??new Set;s.add(e),this.onInitCallbacks.set(r,s);const i=this.instances.get(r);return i&&e(i,r),()=>{s.delete(e)}}invokeOnInitCallbacks(e,t){const r=this.onInitCallbacks.get(t);if(r)for(const s of r)try{s(e,t)}catch{}}getOrInitializeService({instanceIdentifier:e,options:t={}}){let r=this.instances.get(e);if(!r&&this.component&&(r=this.component.instanceFactory(this.container,{instanceIdentifier:_p(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=Yt){return this.component?this.component.multipleInstances?e:Yt:e}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!=="EXPLICIT"}}function _p(n){return n===Yt?void 0:n}function yp(n){return n.instantiationMode==="EAGER"}/** 196 * @license 197 * Copyright 2019 Google LLC 198 * 199 * Licensed under the Apache License, Version 2.0 (the "License");
200 * you may not use this file except in compliance with the License. 201 * You may obtain a copy of the License at 202 * 203 * http://www.apache.org/licenses/LICENSE-2.0 204 * 205 * Unless required by applicable law or agreed to in writing, software 206 * distributed under the License is distributed on an "AS IS" BASIS, 207 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 208 * See the License for the specific language governing permissions and 209 * limitations under the License. 210 */class Ep{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 gp(e,this);return this.providers.set(e,t),t}getProviders(){return Array.from(this.providers.values())}}/** 211 * @license 212 * Copyright 2017 Google LLC 213 * 214 * Licensed under the Apache License, Version 2.0 (the "License"); 215 * you may not use this file except in compliance with the License. 216 * You may obtain a copy of the License at 217 * 218 * http://www.apache.org/licenses/LICENSE-2.0 219 * 220 * Unless required by applicable law or agreed to in writing, software 221 * distributed under the License is distributed on an "AS IS" BASIS, 222 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 223 * See the License for the specific language governing permissions and 224 * limitations under the License. 225 */var 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 Tp={debug:z.DEBUG,verbose:z.VERBOSE,info:z.INFO,warn:z.WARN,error:z.ERROR,silent:z.SILENT},Ip=z.INFO,wp={[z.DEBUG]:"log",[z.VERBOSE]:"log",[z.INFO]:"info",[z.WARN]:"warn",[z.ERROR]:"error"},vp=(n,e,...t)=>{if(e<n.logLevel)return;const r=new Date().toISOString(),s=wp[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 ko{constructor(e){this.name=e,this._logLevel=Ip,this._logHandler=vp,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"?Tp[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)}}/** 226 * @license 227 * Copyright 2019 Google LLC 228 * 229 * Licensed under the Apache License, Version 2.0 (the "License"); 230 * you may not use this file except in compliance with the License. 231 * You may obtain a copy of the License at 232 * 233 * http://www.apache.org/licenses/LICENSE-2.0 234 * 235 * Unless required by applicable law or agreed to in writing, software 236 * distributed under the License is distributed on an "AS IS" BASIS, 237 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 238 * See the License for the specific language governing permissions and 239 * limitations under the License. 240 */class Ap{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(t=>{if(Rp(t)){const r=t.getImmediate();return`${r.library}/${r.version}`}else return null}).filter(t=>t).join(" ")}}function Rp(n){const e=n.getComponent();return(e==null?void 0:e.type)==="VERSION"}const no="@firebase/app",xc="0.14.7";/** 241 * @license 242 * Copyright 2019 Google LLC 243 * 244 * Licensed under the Apache License, Version 2.0 (the "License");
245 * you may not use this file except in compliance with the License. 246 * You may obtain a copy of the License at 247 * 248 * http://www.apache.org/licenses/LICENSE-2.0 249 * 250 * Unless required by applicable law or agreed to in writing, software 251 * distributed under the License is distributed on an "AS IS" BASIS, 252 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 253 * See the License for the specific language governing permissions and 254 * limitations under the License. 255 */const dt=new ko("@firebase/app"),Sp="@firebase/app-compat",Pp="@firebase/analytics-compat",bp="@firebase/analytics",Cp="@firebase/app-check-compat",kp="@firebase/app-check",Np="@firebase/auth",Dp="@firebase/auth-compat",Vp="@firebase/database",Op="@firebase/data-connect",Lp="@firebase/database-compat",Mp="@firebase/functions",xp="@firebase/functions-compat",Up="@firebase/installations",Fp="@firebase/installations-compat",Bp="@firebase/messaging",qp="@firebase/messaging-compat",$p="@firebase/performance",jp="@firebase/performance-compat",Hp="@firebase/remote-config",zp="@firebase/remote-config-compat",Gp="@firebase/storage",Wp="@firebase/storage-compat",Kp="@firebase/firestore",Qp="@firebase/ai",Jp="@firebase/firestore-compat",Yp="firebase",Xp="12.8.0";/** 256 * @license 257 * Copyright 2019 Google LLC 258 * 259 * Licensed under the Apache License, Version 2.0 (the "License"); 260 * you may not use this file except in compliance with the License. 261 * You may obtain a copy of the License at 262 * 263 * http://www.apache.org/licenses/LICENSE-2.0 264 * 265 * Unless required by applicable law or agreed to in writing, software 266 * distributed under the License is distributed on an "AS IS" BASIS, 267 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 268 * See the License for the specific language governing permissions and 269 * limitations under the License. 270 */const ro="[DEFAULT]",Zp={[no]:"fire-core",[Sp]:"fire-core-compat",[bp]:"fire-analytics",[Pp]:"fire-analytics-compat",[kp]:"fire-app-check",[Cp]:"fire-app-check-compat",[Np]:"fire-auth",[Dp]:"fire-auth-compat",[Vp]:"fire-rtdb",[Op]:"fire-data-connect",[Lp]:"fire-rtdb-compat",[Mp]:"fire-fn",[xp]:"fire-fn-compat",[Up]:"fire-iid",[Fp]:"fire-iid-compat",[Bp]:"fire-fcm",[qp]:"fire-fcm-compat",[$p]:"fire-perf",[jp]:"fire-perf-compat",[Hp]:"fire-rc",[zp]:"fire-rc-compat",[Gp]:"fire-gcs",[Wp]:"fire-gcs-compat",[Kp]:"fire-fst",[Jp]:"fire-fst-compat",[Qp]:"fire-vertex","fire-js":"fire-js",[Yp]:"fire-js-all"};/** 271 * @license 272 * Copyright 2019 Google LLC 273 * 274 * Licensed under the Apache License, Version 2.0 (the "License"); 275 * you may not use this file except in compliance with the License. 276 * You may obtain a copy of the License at 277 * 278 * http://www.apache.org/licenses/LICENSE-2.0 279 * 280 * Unless required by applicable law or agreed to in writing, software 281 * distributed under the License is distributed on an "AS IS" BASIS, 282 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 283 * See the License for the specific language governing permissions and 284 * limitations under the License. 285 */const vs=new Map,em=new Map,so=new Map;function Uc(n,e){try{n.container.addComponent(e)}catch(t){dt.debug(`Component ${e.name} failed to register with FirebaseApp ${n.name}`,t)}}function Vt(n){const e=n.name;if(so.has(e))return dt.debug(`There were multiple attempts to register component ${e}.`),!1;so.set(e,n);for(const t of vs.values())Uc(t,n);for(const t of em.values())Uc(t,n);return!0}function Dr(n,e){const t=n.container.getProvider("heartbeat").getImmediate({optional:!0});return t&&t.triggerHeartbeat(),n.container.getProvider(e)}function ve(n){return n==null?!1:n.settings!==void 0}/** 286 * @license 287 * Copyright 2019 Google LLC 288 * 289 * Licensed under the Apache License, Version 2.0 (the "License"); 290 * you may not use this file except in compliance with the License. 291 * You may obtain a copy of the License at 292 * 293 * http://www.apache.org/licenses/LICENSE-2.0 294 * 295 * Unless required by applicable law or agreed to in writing, software 296 * distributed under the License is distributed on an "AS IS" BASIS, 297 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 298 * See the License for the specific language governing permissions and 299 * limitations under the License. 300 */const tm={"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.","invali
300d-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."},kt=new kr("app","Firebase",tm);/** 301 * @license 302 * Copyright 2019 Google LLC 303 * 304 * Licensed under the Apache License, Version 2.0 (the "License"); 305 * you may not use this file except in compliance with the License. 306 * You may obtain a copy of the License at 307 * 308 * http://www.apache.org/licenses/LICENSE-2.0 309 * 310 * Unless required by applicable law or agreed to in writing, software 311 * distributed under the License is distributed on an "AS IS" BASIS, 312 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 313 * See the License for the specific language governing permissions and 314 * limitations under the License. 315 */class nm{constructor(e,t,r){this._isDeleted=!1,this._options={...e},this._config={...t},this._name=t.name,this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled,this._container=r,this.container.addComponent(new ht("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 kt.create("app-deleted",{appName:this._name})}}/** 316 * @license 317 * Copyright 2019 Google LLC 318 * 319 * Licensed under the Apache License, Version 2.0 (the "License"); 320 * you may not use this file except in compliance with the License. 321 * You may obtain a copy of the License at 322 * 323 * http://www.apache.org/licenses/LICENSE-2.0 324 * 325 * Unless required by applicable law or agreed to in writing, software 326 * distributed under the License is distributed on an "AS IS" BASIS, 327 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 328 * See the License for the specific language governing permissions and 329 * limitations under the License. 330 */const un=Xp;function rm(n,e={}){let t=n;typeof e!="object"&&(e={name:e});const r={name:ro,automaticDataCollectionEnabled:!0,...e},s=r.name;if(typeof s!="string"||!s)throw kt.create("bad-app-name",{appName:String(s)});if(t||(t=Il()),!t)throw kt.create("no-options");const i=vs.get(s);if(i){if(nn(t,i.options)&&nn(r,i.config))return i;throw kt.create("duplicate-app",{appName:s})}const a=new Ep(s);for(const l of so.values())a.addComponent(l);const u=new nm(t,r,a);return vs.set(s,u),u}function Ks(n=ro){const e=vs.get(n);if(!e&&n===ro&&Il())return rm();if(!e)throw kt.create("no-app",{appName:n});return e}function Ue(n,e,t){let r=Zp[n]??n;t&&(r+=`-${t}`);const s=r.match(/\s|\//),i=e.match(/\s|\//);if(s||i){const a=[`Unable to register library "${r}" with version "${e}":`];s&&a.push(`library name "${r}" contains illegal characters (whitespace or "/")`),s&&i&&a.push("and"),i&&a.push(`version name "${e}" contains illegal characters (whitespace or "/")`),dt.warn(a.join(" "));return}Vt(new ht(`${r}-version`,()=>({library:r,version:e}),"VERSION"))}/** 331 * @license 332 * Copyright 2021 Google LLC 333 * 334 * Licensed under the Apache License, Version 2.0 (the "License"); 335 * you may not use this file except in compliance with the License. 336 * You may obtain a copy of the License at 337 * 338 * http://www.apache.org/licenses/LICENSE-2.0 339 * 340 * Unless required by applicable law or agreed to in writing, softw
340are 341 * distributed under the License is distributed on an "AS IS" BASIS, 342 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 343 * See the License for the specific language governing permissions and 344 * limitations under the License. 345 */const sm="firebase-heartbeat-database",im=1,Tr="firebase-heartbeat-store";let zi=null;function Al(){return zi||(zi=$f(sm,im,{upgrade:(n,e)=>{switch(e){case 0:try{n.createObjectStore(Tr)}catch(t){console.warn(t)}}}}).catch(n=>{throw kt.create("idb-open",{originalErrorMessage:n.message})})),zi}async function om(n){try{const t=(await Al()).transaction(Tr),r=await t.objectStore(Tr).get(Rl(n));return await t.done,r}catch(e){if(e instanceof ze)dt.warn(e.message);else{const t=kt.create("idb-get",{originalErrorMessage:e==null?void 0:e.message});dt.warn(t.message)}}}async function Fc(n,e){try{const r=(await Al()).transaction(Tr,"readwrite");await r.objectStore(Tr).put(e,Rl(n)),await r.done}catch(t){if(t instanceof ze)dt.warn(t.message);else{const r=kt.create("idb-set",{originalErrorMessage:t==null?void 0:t.message});dt.warn(r.message)}}}function Rl(n){return`${n.name}!${n.options.appId}`}/** 346 * @license 347 * Copyright 2021 Google LLC 348 * 349 * Licensed under the Apache License, Version 2.0 (the "License"); 350 * you may not use this file except in compliance with the License. 351 * You may obtain a copy of the License at 352 * 353 * http://www.apache.org/licenses/LICENSE-2.0 354 * 355 * Unless required by applicable law or agreed to in writing, software 356 * distributed under the License is distributed on an "AS IS" BASIS, 357 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 358 * See the License for the specific language governing permissions and 359 * limitations under the License. 360 */const am=1024,cm=30;class um{constructor(e){this.container=e,this._heartbeatsCache=null;const t=this.container.getProvider("app").getImmediate();this._storage=new hm(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=Bc();if(((e=this._heartbeatsCache)==null?void 0:e.heartbeats)==null&&(this._heartbeatsCache=await this._heartbeatsCachePromise,((t=this._heartbeatsCache)==null?void 0:t.heartbeats)==null)||this._heartbeatsCache.lastSentHeartbeatDate===i||this._heartbeatsCache.heartbeats.some(a=>a.date===i))return;if(this._heartbeatsCache.heartbeats.push({date:i,agent:s}),this._heartbeatsCache.heartbeats.length>cm){const a=dm(this._heartbeatsCache.heartbeats);this._heartbeatsCache.heartbeats.splice(a,1)}return this._storage.overwrite(this._heartbeatsCache)}catch(r){dt.warn(r)}}async getHeartbeatsHeader(){var e;try{if(this._heartbeatsCache===null&&await this._heartbeatsCachePromise,((e=this._heartbeatsCache)==null?void 0:e.heartbeats)==null||this._heartbeatsCache.heartbeats.length===0)return"";const t=Bc(),{heartbeatsToSend:r,unsentEntries:s}=lm(this._heartbeatsCache.heartbeats),i=ws(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 dt.warn(t),""}}}function Bc(){return new Date().toISOString().substring(0,10)}function lm(n,e=am){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),qc(t)>e){i.dates.pop();break}}else if(t.push({agent:s.agent,dates:[s.date]}),qc(t)>e){t.pop();break}r=r.slice(1)}return{heartbeatsToSend:t,unsentEntries:r}}class hm{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return ap()?cp().then(()=>!0).catch(()=>!1):!1}async read(){if(await this._canUseIndexedDBPromise){const t=await om(this.app);return t!=null&&t.heartbeats?t:{heartbeats:[]}}else return{heartbeats:[]}}async overwrite(e){if(await this._canUseIndexedDBPromise){const r=await this.read();return Fc(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??r.lastSentHeartbeatDate,heartbeats:e.heartbeats})}else return}async add(e){if(await this._canUseIndexedDBPromise){const r=await this.read();return Fc(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??r.lastSentHeartbeatDate,heartbeats:[...r.heartbeats,...e.heartbeats]})}else return}}function qc(n){return ws(JSON.stringify({version:2,heartbeats:n})).length}function dm(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}/** 361 * @license 362 * Copyright 2019 Google LLC 363 * 364 * Licensed under the Apache License, Version 2.0 (the "License");
365 * you may not use this file except in compliance with the License. 366 * You may obtain a copy of the License at 367 * 368 * http://www.apache.org/licenses/LICENSE-2.0 369 * 370 * Unless required by applicable law or agreed to in writing, software 371 * distributed under the License is distributed on an "AS IS" BASIS, 372 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 373 * See the License for the specific language governing permissions and 374 * limitations under the License. 375 */function fm(n){Vt(new ht("platform-logger",e=>new Ap(e),"PRIVATE")),Vt(new ht("heartbeat",e=>new um(e),"PRIVATE")),Ue(no,xc,n),Ue(no,xc,"esm2020"),Ue("fire-js","")}fm("");function Sl(){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 pm=Sl,Pl=new kr("auth","Firebase",Sl());/** 376 * @license 377 * Copyright 2020 Google LLC 378 * 379 * Licensed under the Apache License, Version 2.0 (the "License"); 380 * you may not use this file except in compliance with the License. 381 * You may obtain a copy of the License at 382 * 383 * http://www.apache.org/licenses/LICENSE-2.0 384 * 385 * Unless required by applicable law or agreed to in writing, software 386 * distributed under the License is distributed on an "AS IS" BASIS, 387 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 388 * See the License for the specific language governing permissions and 389 * limitations under the License. 390 */const As=new ko("@firebase/auth");function mm(n,...e){As.logLevel<=z.WARN&&As.warn(`Auth (${un}): ${n}`,...e)}function ds(n,...e){As.logLevel<=z.ERROR&&As.error(`Auth (${un}): ${n}`,...e)}/** 391 * @license 392 * Copyright 2020 Google LLC 393 * 394 * Licensed under the Apache License, Version 2.0 (the "License"); 395 * you may not use this file except in compliance with the License. 396 * You may obtain a copy of the License at 397 * 398 * http://www.apache.org/licenses/LICENSE-2.0 399 * 400 * Unless required by applicable law or agreed to in writing, software 401 * distributed under the License is distributed on an "AS IS" BASIS, 402 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 403 * See the License for the specific language governing permissions and 404 * limitations under the License. 405 */function Be(n,...e){throw No(n,...e)}function Ze(n,...e){return No(n,...e)}function bl(n,e,t){const r={...pm(),[e]:t};return new kr("auth","Firebase",r).create(e,{appName:n.name})}function $e(n){return bl(n,"operation-not-supported-in-this-environment","Operations that alter the current user are not supported in conjunction with FirebaseServerApp")}function No(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 Pl.create(n,...e)}function M(n,e,...t){if(!n)throw No(e,...t)}function ct(n){const e="INTERNAL ASSERTION FAILED: "+n;throw ds(e),new Error(e)}function ft(n,e){n||ct(e)}/** 406 * @license 407 * Copyright 2020 Google LLC 408 * 409 * Licensed under the Apache License, Version 2.0 (the "License"); 410 * you may not use this file except in compliance with the License. 411 * You may obtain a copy of the License at 412 * 413 * http://www.apache.org/licenses/LICENSE-2.0 414 * 415 * Unless required by applicable law or agreed to in writing, software 416 * distributed under the License is distributed on an "AS IS" BASIS, 417 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 418 * See the License for the specific language governing permissions and 419 * limitations under the License. 420 */function Rs(){var n;return typeof self<"u"&&((n=self.location)==null?void 0:n.href)||""}function gm(){return $c()==="http:"||$c()==="https:"}function $c(){var n;return typeof self<"u"&&((n=self.location)==null?void 0:n.protocol)||null}/** 421 * @license 422 * Copyright 2020 Google LLC 423 * 424 * Licensed under the Apache License, Version 2.0 (the "License"); 425 * you may not use this file except in compliance with the License. 426 * You may obtain a copy of the License at 427 * 428 * http://www.apache.org/licenses/LICENSE-2.0 429 * 430 * Unless required by applicable law or agreed to in writing, softw
430are 431 * distributed under the License is distributed on an "AS IS" BASIS, 432 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 433 * See the License for the specific language governing permissions and 434 * limitations under the License. 435 */function _m(){return typeof navigator<"u"&&navigator&&"onLine"in navigator&&typeof navigator.onLine=="boolean"&&(gm()||rp()||"connection"in navigator)?navigator.onLine:!0}function ym(){if(typeof navigator>"u")return null;const n=navigator;return n.languages&&n.languages[0]||n.language||null}/** 436 * @license 437 * Copyright 2020 Google LLC 438 * 439 * Licensed under the Apache License, Version 2.0 (the "License"); 440 * you may not use this file except in compliance with the License. 441 * You may obtain a copy of the License at 442 * 443 * http://www.apache.org/licenses/LICENSE-2.0 444 * 445 * Unless required by applicable law or agreed to in writing, software 446 * distributed under the License is distributed on an "AS IS" BASIS, 447 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 448 * See the License for the specific language governing permissions and 449 * limitations under the License. 450 */class Vr{constructor(e,t){this.shortDelay=e,this.longDelay=t,ft(t>e,"Short delay should be less than long delay!"),this.isMobile=ep()||sp()}get(){return _m()?this.isMobile?this.longDelay:this.shortDelay:Math.min(5e3,this.shortDelay)}}/** 451 * @license 452 * Copyright 2020 Google LLC 453 * 454 * Licensed under the Apache License, Version 2.0 (the "License"); 455 * you may not use this file except in compliance with the License. 456 * You may obtain a copy of the License at 457 * 458 * http://www.apache.org/licenses/LICENSE-2.0 459 * 460 * Unless required by applicable law or agreed to in writing, software 461 * distributed under the License is distributed on an "AS IS" BASIS, 462 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 463 * See the License for the specific language governing permissions and 464 * limitations under the License. 465 */function Do(n,e){ft(n.emulator,"Emulator should always be set here");const{url:t}=n.emulator;return e?`${t}${e.startsWith("/")?e.slice(1):e}`:t}/** 466 * @license 467 * Copyright 2020 Google LLC 468 * 469 * Licensed under the Apache License, Version 2.0 (the "License"); 470 * you may not use this file except in compliance with the License. 471 * You may obtain a copy of the License at 472 * 473 * http://www.apache.org/licenses/LICENSE-2.0 474 * 475 * Unless required by applicable law or agreed to in writing, software 476 * distributed under the License is distributed on an "AS IS" BASIS, 477 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 478 * See the License for the specific language governing permissions and 479 * limitations under the License. 480 */class Cl{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;ct("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;ct("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;ct("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}}/** 481 * @license 482 * Copyright 2020 Google LLC 483 * 484 * Licensed under the Apache License, Version 2.0 (the "License"); 485 * you may not use this file except in compliance with the License. 486 * You may obtain a copy of the License at 487 * 488 * http://www.apache.org/licenses/LICENSE-2.0 489 * 490 * Unless required by applicable law or agreed to in writing, softw
490are 491 * distributed under the License is distributed on an "AS IS" BASIS, 492 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 493 * See the License for the specific language governing permissions and 494 * limitations under the License. 495 */const Em={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"};/** 496 * @license 497 * Copyright 2020 Google LLC 498 * 499 * Licensed under the Apache License, Version 2.0 (the "License"); 500 * you may not use this file except in compliance with the License. 501 * You may obtain a copy of the License at 502 * 503 * http://www.apache.org/licenses/LICENSE-2.0 504 * 505 * Unless required by applicable law or agreed to in writing, software 506 * distributed under the License is distributed on an "AS IS" BASIS, 507 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 508 * See the License for the specific language governing permissions and 509 * limitations under the License. 510 */const Tm=["/v1/accounts:signInWithCustomToken","/v1/accounts:signInWithEmailLink","/v1/accounts:signInWithIdp","/v1/accounts:signInWithPassword","/v1/accounts:signInWithPhoneNumber","/v1/token"],Im=new Vr(3e4,6e4);function Ge(n,e){return n.tenantId&&!e.tenantId?{...e,tenantId:n.tenantId}:e}async function We(n,e,t,r,s={}){return kl(n,s,async()=>{let i={},a={};r&&(e==="GET"?a=r:i={body:JSON.stringify(r)});const u=Nr({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={method:e,headers:l,...i};return np()||(d.referrerPolicy="no-referrer"),n.emulatorConfig&&ot(n.emulatorConfig.host)&&(d.credentials="include"),Cl.fetch()(await Nl(n,n.config.apiHost,t,u),d)})}async function kl(n,e,t){n._canInitEmulator=!1;const r={...Em,...e};try{const s=new vm(n),i=await Promise.race([t(),s.promise]);s.clearNetworkTimeout();const a=await i.json();if("needConfirmation"in a)throw ss(n,"account-exists-with-different-credential",a);if(i.ok&&!("errorMessage"in a))return a;{const u=i.ok?a.errorMessage:a.error.message,[l,d]=u.split(" : ");if(l==="FEDERATED_USER_ID_ALREADY_LINKED")throw ss(n,"credential-already-in-use",a);if(l==="EMAIL_EXISTS")throw ss(n,"email-already-in-use",a);if(l==="USER_DISABLED")throw ss(n,"user-disabled",a);const f=r[l]||l.toLowerCase().replace(/[_\s]+/g,"-");if(d)throw bl(n,f,d);Be(n,f)}}catch(s){if(s instanceof ze)throw s;Be(n,"network-request-failed",{message:String(s)})}}async function Mn(n,e,t,r,s={}){const i=await We(n,e,t,r,s);return"mfaPendingCredential"in i&&Be(n,"multi-factor-auth-required",{_serverResponse:i}),i}async function Nl(n,e,t,r){const s=`${e}${t}?${r}`,i=n,a=i.config.emulator?Do(n.config,s):`${n.config.apiScheme}://${s}`;return Tm.includes(t)&&(await i._persistenceManagerAvailable,i._getPersistenceType()==="COOKIE")?
510i._getPersistence()._getFinalTarget(a).toString():a}function wm(n){switch(n){case"ENFORCE":return"ENFORCE";case"AUDIT":return"AUDIT";case"OFF":return"OFF";default:return"ENFORCEMENT_STATE_UNSPECIFIED"}}class vm{clearNetworkTimeout(){clearTimeout(this.timer)}constructor(e){this.auth=e,this.timer=null,this.promise=new Promise((t,r)=>{this.timer=setTimeout(()=>r(Ze(this.auth,"network-request-failed")),Im.get())})}}function ss(n,e,t){const r={appName:n.name};t.email&&(r.email=t.email),t.phoneNumber&&(r.phoneNumber=t.phoneNumber);const s=Ze(n,e,r);return s.customData._tokenResponse=t,s}function jc(n){return n!==void 0&&n.enterprise!==void 0}class Am{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 wm(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 Rm(n,e){return We(n,"GET","/v2/recaptchaConfig",Ge(n,e))}/** 511 * @license 512 * Copyright 2020 Google LLC 513 * 514 * Licensed under the Apache License, Version 2.0 (the "License"); 515 * you may not use this file except in compliance with the License. 516 * You may obtain a copy of the License at 517 * 518 * http://www.apache.org/licenses/LICENSE-2.0 519 * 520 * Unless required by applicable law or agreed to in writing, software 521 * distributed under the License is distributed on an "AS IS" BASIS, 522 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 523 * See the License for the specific language governing permissions and 524 * limitations under the License. 525 */async function Sm(n,e){return We(n,"POST","/v1/accounts:delete",e)}async function Ss(n,e){return We(n,"POST","/v1/accounts:lookup",e)}/** 526 * @license 527 * Copyright 2020 Google LLC 528 * 529 * Licensed under the Apache License, Version 2.0 (the "License"); 530 * you may not use this file except in compliance with the License. 531 * You may obtain a copy of the License at 532 * 533 * http://www.apache.org/licenses/LICENSE-2.0 534 * 535 * Unless required by applicable law or agreed to in writing, software 536 * distributed under the License is distributed on an "AS IS" BASIS, 537 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 538 * See the License for the specific language governing permissions and 539 * limitations under the License. 540 */function pr(n){if(n)try{const e=new Date(Number(n));if(!isNaN(e.getTime()))return e.toUTCString()}catch{}}async function Pm(n,e=!1){const t=H(n),r=await t.getIdToken(e),s=Vo(r);M(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:pr(Gi(s.auth_time)),issuedAtTime:pr(Gi(s.iat)),expirationTime:pr(Gi(s.exp)),signInProvider:a||null,signInSecondFactor:(i==null?void 0:i.sign_in_second_factor)||null}}function Gi(n){return Number(n)*1e3}function Vo(n){const[e,t,r]=n.split(".");if(e===void 0||t===void 0||r===void 0)return ds("JWT malformed, contained fewer than 3 sections"),null;try{const s=El(t);return s?JSON.parse(s):(ds("Failed to decode base64 JWT payload"),null)}catch(s){return ds("Caught error parsing JWT payload as JSON",s==null?void 0:s.toString()),null}}function Hc(n){const e=Vo(n);return M(e,"internal-error"),M(typeof e.exp<"u","internal-error"),M(typeof e.iat<"u","internal-error"),Number(e.exp)-Number(e.iat)}/** 541 * @license 542 * Copyright 2020 Google LLC 543 * 544 * Licensed under the Apache License, Version 2.0 (the "License"); 545 * you may not use this file except in compliance with the License. 546 * You may obtain a copy of the License at 547 * 548 * http://www.apache.org/licenses/LICENSE-2.0 549 * 550 * Unless required by applicable law or agreed to in writing, softw
550are 551 * distributed under the License is distributed on an "AS IS" BASIS, 552 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 553 * See the License for the specific language governing permissions and 554 * limitations under the License. 555 */async function bn(n,e,t=!1){if(t)return e;try{return await e}catch(r){throw r instanceof ze&&bm(r)&&n.auth.currentUser===n&&await n.auth.signOut(),r}}function bm({code:n}){return n==="auth/user-disabled"||n==="auth/user-token-expired"}/** 556 * @license 557 * Copyright 2020 Google LLC 558 * 559 * Licensed under the Apache License, Version 2.0 (the "License"); 560 * you may not use this file except in compliance with the License. 561 * You may obtain a copy of the License at 562 * 563 * http://www.apache.org/licenses/LICENSE-2.0 564 * 565 * Unless required by applicable law or agreed to in writing, software 566 * distributed under the License is distributed on an "AS IS" BASIS, 567 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 568 * See the License for the specific language governing permissions and 569 * limitations under the License. 570 */class Cm{constructor(e){this.user=e,this.isRunning=!1,this.timerId=null,this.errorBackoff=3e4}_start(){this.isRunning||(this.isRunning=!0,this.schedule())}_stop(){this.isRunning&&(this.isRunning=!1,this.timerId!==null&&clearTimeout(this.timerId))}getInterval(e){if(e){const t=this.errorBackoff;return this.errorBackoff=Math.min(this.errorBackoff*2,96e4),t}else{this.errorBackoff=3e4;const r=(this.user.stsTokenManager.expirationTime??0)-Date.now()-3e5;return Math.max(0,r)}}schedule(e=!1){if(!this.isRunning)return;const t=this.getInterval(e);this.timerId=setTimeout(async()=>{await this.iteration()},t)}async iteration(){try{await this.user.getIdToken(!0)}catch(e){(e==null?void 0:e.code)==="auth/network-request-failed"&&this.schedule(!0);return}this.schedule()}}/** 571 * @license 572 * Copyright 2020 Google LLC 573 * 574 * Licensed under the Apache License, Version 2.0 (the "License"); 575 * you may not use this file except in compliance with the License. 576 * You may obtain a copy of the License at 577 * 578 * http://www.apache.org/licenses/LICENSE-2.0 579 * 580 * Unless required by applicable law or agreed to in writing, software 581 * distributed under the License is distributed on an "AS IS" BASIS, 582 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 583 * See the License for the specific language governing permissions and 584 * limitations under the License. 585 */class io{constructor(e,t){this.createdAt=e,this.lastLoginAt=t,this._initializeTime()}_initializeTime(){this.lastSignInTime=pr(this.lastLoginAt),this.creationTime=pr(this.createdAt)}_copy(e){this.createdAt=e.createdAt,this.lastLoginAt=e.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}/** 586 * @license 587 * Copyright 2019 Google LLC 588 * 589 * Licensed under the Apache License, Version 2.0 (the "License"); 590 * you may not use this file except in compliance with the License. 591 * You may obtain a copy of the License at 592 * 593 * http://www.apache.org/licenses/LICENSE-2.0 594 * 595 * Unless required by applicable law or agreed to in writing, software 596 * distributed under the License is distributed on an "AS IS" BASIS, 597 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 598 * See the License for the specific language governing permissions and 599 * limitations under the License. 600 */async function Ps(n){var m;const e=n.auth,t=await n.getIdToken(),r=await bn(n,Ss(e,{idToken:t}));M(r==null?void 0:r.users.length,e,"internal-error");const s=r.users[0];n._notifyReloadListener(s);const i=(m=s.providerUserInfo)!=null&&m.length?Dl(s.providerUserInfo):[],a=Nm(n.providerData,i),u=n.isAnonymous,l=!(n.email&&s.passwordHash)&&!(a!=null&&a.length),d=u?l:!1,f={uid:s.localId,displayName:s.displayName||null,photoURL:s.photoUrl||null,email:s.email||null,emailVerified:s.emailVerified||!1,phoneNumber:s.phoneNumber||null,tenantId:s.tenantId||null,providerData:a,metadata:new io(s.createdAt,s.lastLoginAt),isAnonymous:d};Object.assign(n,f)}async function km(n){const e=H(n);await Ps(e),await e.auth._persistUserIfCurrent(e),e.auth._notifyListenersIfCurrent(e)}function Nm(n,e){return[...n.filter(r=>!e.some(s=>s.providerId===r.providerId)),...e]}function Dl(n){return n.map(({providerId:e,...t})=>
600({providerId:e,uid:t.rawId||"",displayName:t.displayName||null,email:t.email||null,phoneNumber:t.phoneNumber||null,photoURL:t.photoUrl||null}))}/** 601 * @license 602 * Copyright 2020 Google LLC 603 * 604 * Licensed under the Apache License, Version 2.0 (the "License"); 605 * you may not use this file except in compliance with the License. 606 * You may obtain a copy of the License at 607 * 608 * http://www.apache.org/licenses/LICENSE-2.0 609 * 610 * Unless required by applicable law or agreed to in writing, software 611 * distributed under the License is distributed on an "AS IS" BASIS, 612 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 613 * See the License for the specific language governing permissions and 614 * limitations under the License. 615 */async function Dm(n,e){const t=await kl(n,{},async()=>{const r=Nr({grant_type:"refresh_token",refresh_token:e}).slice(1),{tokenApiHost:s,apiKey:i}=n.config,a=await Nl(n,s,"/v1/token",`key=${i}`),u=await n._getAdditionalHeaders();u["Content-Type"]="application/x-www-form-urlencoded";const l={method:"POST",headers:u,body:r};return n.emulatorConfig&&ot(n.emulatorConfig.host)&&(l.credentials="include"),Cl.fetch()(a,l)});return{accessToken:t.access_token,expiresIn:t.expires_in,refreshToken:t.refresh_token}}async function Vm(n,e){return We(n,"POST","/v2/accounts:revokeToken",Ge(n,e))}/** 616 * @license 617 * Copyright 2020 Google LLC 618 * 619 * Licensed under the Apache License, Version 2.0 (the "License"); 620 * you may not use this file except in compliance with the License. 621 * You may obtain a copy of the License at 622 * 623 * http://www.apache.org/licenses/LICENSE-2.0 624 * 625 * Unless required by applicable law or agreed to in writing, software 626 * distributed under the License is distributed on an "AS IS" BASIS, 627 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 628 * See the License for the specific language governing permissions and 629 * limitations under the License. 630 */class vn{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){M(e.idToken,"internal-error"),M(typeof e.idToken<"u","internal-error"),M(typeof e.refreshToken<"u","internal-error");const t="expiresIn"in e&&typeof e.expiresIn<"u"?Number(e.expiresIn):Hc(e.idToken);this.updateTokensAndExpiration(e.idToken,e.refreshToken,t)}updateFromIdToken(e){M(e.length!==0,"internal-error");const t=Hc(e);this.updateTokensAndExpiration(e,null,t)}async getToken(e,t=!1){return!t&&this.accessToken&&!this.isExpired?this.accessToken:(M(this.refreshToken,e,"user-token-expired"),this.refreshToken?(await this.refresh(e,this.refreshToken),this.accessToken):null)}clearRefreshToken(){this.refreshToken=null}async refresh(e,t){const{accessToken:r,refreshToken:s,expiresIn:i}=await Dm(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 vn;return r&&(M(typeof r=="string","internal-error",{appName:e}),a.refreshToken=r),s&&(M(typeof s=="string","internal-error",{appName:e}),a.accessToken=s),i&&(M(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 vn,this.toJSON())}_performRefresh(){return ct("not implemented")}}/** 631 * @license 632 * Copyright 2020 Google LLC 633 * 634 * Licensed under the Apache License, Version 2.0 (the "License"); 635 * you may not use this file except in compliance with the License. 636 * You may obtain a copy of the License at 637 * 638 * http://www.apache.org/licenses/LICENSE-2.0 639 * 640 * Unless required by applicable law or agreed to in writing, software 641 * distributed under the License is distributed on an "AS IS" BASIS, 642 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 643 * See the License for the specific language governing permissions and 644 * limitations under the License. 645 */function At(n,e){M(typeof n=="string"||typeof n>"u","internal-error",{appName:e})}class qe{constructor({uid:e,auth:t,stsTokenManager:r,...s}){this.providerId="firebase",this.proactiveRefresh=new Cm(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=e,this.auth=t,this.stsTokenManager=r,this.accessToken=r.accessToken,this.displayName=s.displayName||null,this.email=s.email||null,this.emailVerified=s.emailVerified||!1,this.phoneNumber=s.phoneNumber||null,this.photoURL=s.photoURL||null,this.isAnonymous=s.isAnonymous||!1,this.tenantId=s.tenantId||null,this.providerData=s.providerData?[...s.providerData]:[],this.metadata=new io(s.createdAt||void 0,s.lastLoginAt||void 0)}async getIdToken(e){const t=await bn(this,this.stsTokenManager.getToken(this.auth,e));return M(t,this.auth,"internal-error"),this.accessToken!==t&&(this.accessToken=t,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),t}getIdTokenResult(e){return Pm(this,e)}reload(){return km(this)}_assign(e){this!==e&&(M(this.uid===e.uid,this.auth,"internal-error"),this.displayName=e.displayName,this.photoURL=e.ph
645otoURL,this.email=e.email,this.emailVerified=e.emailVerified,this.phoneNumber=e.phoneNumber,this.isAnonymous=e.isAnonymous,this.tenantId=e.tenantId,this.providerData=e.providerData.map(t=>({...t})),this.metadata._copy(e.metadata),this.stsTokenManager._assign(e.stsTokenManager))}_clone(e){const t=new qe({...this,auth:e,stsTokenManager:this.stsTokenManager._clone()});return t.metadata._copy(this.metadata),t}_onReload(e){M(!this.reloadListener,this.auth,"internal-error"),this.reloadListener=e,this.reloadUserInfo&&(this._notifyReloadListener(this.reloadUserInfo),this.reloadUserInfo=null)}_notifyReloadListener(e){this.reloadListener?this.reloadListener(e):this.reloadUserInfo=e}_startProactiveRefresh(){this.proactiveRefresh._start()}_stopProactiveRefresh(){this.proactiveRefresh._stop()}async _updateTokensIfNecessary(e,t=!1){let r=!1;e.idToken&&e.idToken!==this.stsTokenManager.accessToken&&(this.stsTokenManager.updateFromServerResponse(e),r=!0),t&&await Ps(this),await this.auth._persistUserIfCurrent(this),r&&this.auth._notifyListenersIfCurrent(this)}async delete(){if(ve(this.auth.app))return Promise.reject($e(this.auth));const e=await this.getIdToken();return await bn(this,Sm(this.auth,{idToken:e})),this.stsTokenManager.clearRefreshToken(),this.auth.signOut()}toJSON(){return{uid:this.uid,email:this.email||void 0,emailVerified:this.emailVerified,displayName:this.displayName||void 0,isAnonymous:this.isAnonymous,photoURL:this.photoURL||void 0,phoneNumber:this.phoneNumber||void 0,tenantId:this.tenantId||void 0,providerData:this.providerData.map(e=>({...e})),stsTokenManager:this.stsTokenManager.toJSON(),_redirectEventId:this._redirectEventId,...this.metadata.toJSON(),apiKey:this.auth.config.apiKey,appName:this.auth.name}}get refreshToken(){return this.stsTokenManager.refreshToken||""}static _fromJSON(e,t){const r=t.displayName??void 0,s=t.email??void 0,i=t.phoneNumber??void 0,a=t.photoURL??void 0,u=t.tenantId??void 0,l=t._redirectEventId??void 0,d=t.createdAt??void 0,f=t.lastLoginAt??void 0,{uid:m,emailVerified:_,isAnonymous:S,providerData:C,stsTokenManager:D}=t;M(m&&D,e,"internal-error");const k=vn.fromJSON(this.name,D);M(typeof m=="string",e,"internal-error"),At(r,e.name),At(s,e.name),M(typeof _=="boolean",e,"internal-error"),M(typeof S=="boolean",e,"internal-error"),At(i,e.name),At(a,e.name),At(u,e.name),At(l,e.name),At(d,e.name),At(f,e.name);const q=new qe({uid:m,auth:e,email:s,emailVerified:_,displayName:r,isAnonymous:S,photoURL:a,phoneNumber:i,tenantId:u,stsTokenManager:k,createdAt:d,lastLoginAt:f});return C&&Array.isArray(C)&&(q.providerData=C.map(F=>({...F}))),l&&(q._redirectEventId=l),q}static async _fromIdTokenResponse(e,t,r=!1){const s=new vn;s.updateFromServerResponse(t);const i=new qe({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];M(s.localId!==void 0,"internal-error");const i=s.providerUserInfo!==void 0?Dl(s.providerUserInfo):[],a=!(s.email&&s.passwordHash)&&!(i!=null&&i.length),u=new vn;u.updateFromIdToken(r);const l=new qe({uid:s.localId,auth:e,stsTokenManager:u,isAnonymous:a}),d={uid:s.localId,displayName:s.displayName||null,photoURL:s.photoUrl||null,email:s.email||null,emailVerified:s.emailVerified||!1,phoneNumber:s.phoneNumber||null,tenantId:s.tenantId||null,providerData:i,metadata:new io(s.createdAt,s.lastLoginAt),isAnonymous:!(s.email&&s.passwordHash)&&!(i!=null&&i.length)};return Object.assign(l,d),l}}/** 646 * @license 647 * Copyright 2020 Google LLC 648 * 649 * Licensed under the Apache License, Version 2.0 (the "License"); 650 * you may not use this file except in compliance with the License. 651 * You may obtain a copy of the License at 652 * 653 * http://www.apache.org/licenses/LICENSE-2.0 654 * 655 * Unless required by applicable law or agreed to in writing, software 656 * distributed under the License is distributed on an "AS IS" BASIS, 657 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 658 * See the License for the specific language governing permissions and 659 * limitations under the License. 660 */const zc=new Map;function ut(n){ft(n instanceof Function,"Expected a class definition");let e=zc.get(n);return e?(ft(e instanceof n,"Instance stored in cache mismatched with class"),e):(e=new n,zc.set(n,e),e)}/** 661 * @license 662 * Copyright 2019 Google LLC 663 * 664 * Licensed under the Apache License, Version 2.0 (the "License");
665 * you may not use this file except in compliance with the License. 666 * You may obtain a copy of the License at 667 * 668 * http://www.apache.org/licenses/LICENSE-2.0 669 * 670 * Unless required by applicable law or agreed to in writing, software 671 * distributed under the License is distributed on an "AS IS" BASIS, 672 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 673 * See the License for the specific language governing permissions and 674 * limitations under the License. 675 */class Vl{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){}}Vl.type="NONE";const Gc=Vl;/** 676 * @license 677 * Copyright 2019 Google LLC 678 * 679 * Licensed under the Apache License, Version 2.0 (the "License"); 680 * you may not use this file except in compliance with the License. 681 * You may obtain a copy of the License at 682 * 683 * http://www.apache.org/licenses/LICENSE-2.0 684 * 685 * Unless required by applicable law or agreed to in writing, software 686 * distributed under the License is distributed on an "AS IS" BASIS, 687 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 688 * See the License for the specific language governing permissions and 689 * limitations under the License. 690 */function fs(n,e,t){return`firebase:${n}:${e}:${t}`}class An{constructor(e,t,r){this.persistence=e,this.auth=t,this.userKey=r;const{config:s,name:i}=this.auth;this.fullUserKey=fs(this.userKey,s.apiKey,i),this.fullPersistenceKey=fs("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 Ss(this.auth,{idToken:e}).catch(()=>{});return t?qe._fromGetAccountInfoResponse(this.auth,t,e):null}return qe._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 An(ut(Gc),e,r);const s=(await Promise.all(t.map(async d=>{if(await d._isAvailable())return d}))).filter(d=>d);let i=s[0]||ut(Gc);const a=fs(r,e.config.apiKey,e.name);let u=null;for(const d of t)try{const f=await d._get(a);if(f){let m;if(typeof f=="string"){const _=await Ss(e,{idToken:f}).catch(()=>{});if(!_)break;m=await qe._fromGetAccountInfoResponse(e,_,f)}else m=qe._fromJSON(e,f);d!==i&&(u=m),i=d;break}}catch{}const l=s.filter(d=>d._shouldAllowMigration);return!i._shouldAllowMigration||!l.length?new An(i,e,r):(i=l[0],u&&await i._set(a,u.toJSON()),await Promise.all(t.map(async d=>{if(d!==i)try{await d._remove(a)}catch{}})),new An(i,e,r))}}/** 691 * @license 692 * Copyright 2020 Google LLC 693 * 694 * Licensed under the Apache License, Version 2.0 (the "License"); 695 * you may not use this file except in compliance with the License. 696 * You may obtain a copy of the License at 697 * 698 * http://www.apache.org/licenses/LICENSE-2.0 699 * 700 * Unless required by applicable law or agreed to in writing, software 701 * distributed under the License is distributed on an "AS IS" BASIS, 702 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 703 * See the License for the specific language governing permissions and 704 * limitations under the License. 705 */function Wc(n){const e=n.toLowerCase();if(e.includes("opera/")||e.includes("opr/")||e.includes("opios/"))return"Opera";if(xl(e))return"IEMobile";if(e.includes("msie")||e.includes("trident/"))return"IE";if(e.includes("edge/"))return"Edge";if(Ol(e))return"Firefox";if(e.includes("silk/"))return"Silk";if(Fl(e))return"Blackberry";if(Bl(e))return"Webos";if(Ll(e))return"Safari";if((e.includes("chrome/")||Ml(e))&&!e.includes("edge/"))return"Chrome";if(Ul(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 Ol(n=Ae()){return/firefox\//i.test(n)}function Ll(n=Ae()){const e=n.toLowerCase();return e.includes("safari/")&&!e.includes("chrome/")&&!e.includes("crios/")&&!e.includes("android")}function Ml(n=Ae()){return/crios\//i.test(n)}function xl(n=Ae()){return/iemobile/i.test(n)}function Ul(n=Ae()){return/android/i.test(n)}function Fl(n=Ae()){return/blackberry/i.test(n)}function Bl(n=Ae()){return/webos/i.test(n)}function Oo(n=Ae()){return/iphone|ipad|ipod/i.test(n)||/macintosh/i.test(n)&&/mobile/i.test(n)}
705function Om(n=Ae()){var e;return Oo(n)&&!!((e=window.navigator)!=null&&e.standalone)}function Lm(){return ip()&&document.documentMode===10}function ql(n=Ae()){return Oo(n)||Ul(n)||Bl(n)||Fl(n)||/windows phone/i.test(n)||xl(n)}/** 706 * @license 707 * Copyright 2020 Google LLC 708 * 709 * Licensed under the Apache License, Version 2.0 (the "License"); 710 * you may not use this file except in compliance with the License. 711 * You may obtain a copy of the License at 712 * 713 * http://www.apache.org/licenses/LICENSE-2.0 714 * 715 * Unless required by applicable law or agreed to in writing, software 716 * distributed under the License is distributed on an "AS IS" BASIS, 717 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 718 * See the License for the specific language governing permissions and 719 * limitations under the License. 720 */function $l(n,e=[]){let t;switch(n){case"Browser":t=Wc(Ae());break;case"Worker":t=`${Wc(Ae())}-${n}`;break;default:t=n}const r=e.length?e.join(","):"FirebaseCore-web";return`${t}/JsCore/${un}/${r}`}/** 721 * @license 722 * Copyright 2022 Google LLC 723 * 724 * Licensed under the Apache License, Version 2.0 (the "License"); 725 * you may not use this file except in compliance with the License. 726 * You may obtain a copy of the License at 727 * 728 * http://www.apache.org/licenses/LICENSE-2.0 729 * 730 * Unless required by applicable law or agreed to in writing, software 731 * distributed under the License is distributed on an "AS IS" BASIS, 732 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 733 * See the License for the specific language governing permissions and 734 * limitations under the License. 735 */class Mm{constructor(e){this.auth=e,this.queue=[]}pushCallback(e,t){const r=i=>new Promise((a,u)=>{try{const l=e(i);a(l)}catch(l){u(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})}}}/** 736 * @license 737 * Copyright 2023 Google LLC 738 * 739 * Licensed under the Apache License, Version 2.0 (the "License"); 740 * you may not use this file except in compliance with the License. 741 * You may obtain a copy of the License at 742 * 743 * http://www.apache.org/licenses/LICENSE-2.0 744 * 745 * Unless required by applicable law or agreed to in writing, software 746 * distributed under the License is distributed on an "AS IS" BASIS, 747 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 748 * See the License for the specific language governing permissions and 749 * limitations under the License. 750 */async function xm(n,e={}){return We(n,"GET","/v2/passwordPolicy",Ge(n,e))}/** 751 * @license 752 * Copyright 2023 Google LLC 753 * 754 * Licensed under the Apache License, Version 2.0 (the "License"); 755 * you may not use this file except in compliance with the License. 756 * You may obtain a copy of the License at 757 * 758 * http://www.apache.org/licenses/LICENSE-2.0 759 * 760 * Unless required by applicable law or agreed to in writing, software 761 * distributed under the License is distributed on an "AS IS" BASIS, 762 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 763 * See the License for the specific language governing permissions and 764 * limitations under the License. 765 */const Um=6;class Fm{constructor(e){var r;const t=e.customStrengthOptions;this.customStrengthOptions={},this.customStrengthOptions.minPasswordLength=t.minPasswordLength??Um,t.maxPasswordLength&&(this.customStrengthOptions.maxPasswordLength=t.maxPasswordLength),t.containsLowercaseCharacter!==void 0&&(this.customStrengthOptions.containsLowercaseLetter=t.containsLowercaseCharacter),t.containsUppercaseCharacter!==void 0&&(this.customStrengthOptions.containsUppercaseLetter=t.containsUppercaseCharacter),t.containsNumericCharacter!==void 0&&(this.customStrengthOptions.containsNumericCharacter=t.containsNumericCharacter),t.containsNonAlphanumericCharacter!==void 0&&(this.customStrengthOptions.containsNonAlphanumericCharacter=t.containsNonAlphanumericCharacter),this.enforcementState=e.enforcementState,this.enforcementState==="ENFORCEMENT_STATE_UNSPECIFIED"&&(this.enforcementState="OFF"),this.allowedNonAlphanumericCharacters=((r=e.allowedNonAlphanumericCharacters)==null?void 0:r.join(""))??"",this.forceUpgradeOnSignin=e.forceUpgradeOnSignin??!1,this.schemaVersion=e.schemaVersion}validatePassword(e){const t={isValid:!0,passwordPolicy:this};return this.validatePasswordLengthOptions(e,t),this.validatePasswordCharacterOptions(e,t),t.isValid&&
765(t.isValid=t.meetsMinPasswordLength??!0),t.isValid&&(t.isValid=t.meetsMaxPasswordLength??!0),t.isValid&&(t.isValid=t.containsLowercaseLetter??!0),t.isValid&&(t.isValid=t.containsUppercaseLetter??!0),t.isValid&&(t.isValid=t.containsNumericCharacter??!0),t.isValid&&(t.isValid=t.containsNonAlphanumericCharacter??!0),t}validatePasswordLengthOptions(e,t){const r=this.customStrengthOptions.minPasswordLength,s=this.customStrengthOptions.maxPasswordLength;r&&(t.meetsMinPasswordLength=e.length>=r),s&&(t.meetsMaxPasswordLength=e.length<=s)}validatePasswordCharacterOptions(e,t){this.updatePasswordCharacterOptionsStatuses(t,!1,!1,!1,!1);let r;for(let s=0;s<e.length;s++)r=e.charAt(s),this.updatePasswordCharacterOptionsStatuses(t,r>="a"&&r<="z",r>="A"&&r<="Z",r>="0"&&r<="9",this.allowedNonAlphanumericCharacters.includes(r))}updatePasswordCharacterOptionsStatuses(e,t,r,s,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))}}/** 766 * @license 767 * Copyright 2020 Google LLC 768 * 769 * Licensed under the Apache License, Version 2.0 (the "License"); 770 * you may not use this file except in compliance with the License. 771 * You may obtain a copy of the License at 772 * 773 * http://www.apache.org/licenses/LICENSE-2.0 774 * 775 * Unless required by applicable law or agreed to in writing, software 776 * distributed under the License is distributed on an "AS IS" BASIS, 777 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 778 * See the License for the specific language governing permissions and 779 * limitations under the License. 780 */class Bm{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 Kc(this),this.idTokenSubscription=new Kc(this),this.beforeStateQueue=new Mm(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=Pl,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=ut(t)),this._initializationPromise=this.queue(async()=>{var r,s,i;if(!this._deleted&&(this.persistenceManager=await An.create(this,e),(r=this._resolvePersistenceManagerAvailable)==null||r.call(this),!this._deleted)){if((s=this._popupRedirectResolver)!=null&&s._shouldInitProactively)try{await this._popupRedirectResolver._initialize(this)}catch{}await this.initializeCurrentUser(t),this.lastNotifiedUid=((i=this.currentUser)==null?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 Ss(this,{idToken:e}),r=await qe._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 i;if(ve(this.app)){const a=this.app.settings.authIdToken;return a?new Promise(u=>{setTimeout(()=>this.initializeCurrentUserFromIdToken(a).then(u,u))}):this.directlySetCurrentUser(null)}const t=await this.assertedPersistence.getCurrentUser();let r=t,s=!1;if(e&&this.config.authDomain){await this.getOrInitRedirectPersistenceManager();const a=(i=this.redirectUser)==null?void 0:i._redirectEventId,u=r==null?void 0:r._redirectEventId,l=await this.tryRedirectSignIn(e);(!a||a===u)&&(l!=null&&l.user)&&(r=l.user,s=!0)}if(!r)return this.directlySetCurrentUser(null);
780if(!r._redirectEventId){if(s)try{await this.beforeStateQueue.runMiddleware(r)}catch(a){r=t,this._popupRedirectResolver._overrideRedirectResult(this,()=>Promise.reject(a))}return r?this.reloadAndSetCurrentUserOrClear(r):this.directlySetCurrentUser(null)}return M(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===r._redirectEventId?this.directlySetCurrentUser(r):this.reloadAndSetCurrentUserOrClear(r)}async tryRedirectSignIn(e){let t=null;try{t=await this._popupRedirectResolver._completeRedirectFn(this,e,!0)}catch{await this._setRedirectUser(null)}return t}async reloadAndSetCurrentUserOrClear(e){try{await 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=ym()}async _delete(){this._deleted=!0}async updateCurrentUser(e){if(ve(this.app))return Promise.reject($e(this));const t=e?H(e):null;return t&&M(t.auth.config.apiKey===this.config.apiKey,this,"invalid-user-token"),this._updateCurrentUser(t&&t._clone(this))}async _updateCurrentUser(e,t=!1){if(!this._deleted)return e&&M(this.tenantId===e.tenantId,this,"tenant-id-mismatch"),t||await this.beforeStateQueue.runMiddleware(e),this.queue(async()=>{await this.directlySetCurrentUser(e),this.notifyAuthListeners()})}async signOut(){return ve(this.app)?Promise.reject($e(this)):(await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0))}setPersistence(e){return ve(this.app)?Promise.reject($e(this)):this.queue(async()=>{await this.assertedPersistence.setPersistence(ut(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 xm(this),t=new Fm(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 kr("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 Vm(this,r)}}toJSON(){var e;return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:(e=this._currentUser)==null?void 0:e.toJSON()}}async _setRedirectUser(e,t){const r=await this.getOrInitRedirectPersistenceManager(t);return e===null?r.removeCurrentUser():r.setCurrentUser(e)}async getOrInitRedirectPersistenceManager(e){if(!this.redirectPersistenceManager){const t=e&&ut(e)||this._popupRedirectResolver;M(t,this,"argument-error"),this.redirectPersistenceManager=await An.create(this,[ut(t._redirectPersistence)],"redirectUser"),this.redirectUser=await this.redirectPersistenceManager.getCurrentUser()}return this.redirectPersistenceManager}async _redirectUserForId(e){var t,r;return this._isInitialized&&await this.queue(async()=>{}),((t=this._currentUser)==null?void 0:t._redirectEventId)===e?this._currentUser:((r=this.redirectUser)==null?void 0:r._redirectEventId)===e?this.redirectUser:null}async _persistUserIfCurrent(e){if(e===this.currentUser)return this.queue(async()=>this.directlySetCurrentUser(e))}_notifyListenersIfCurrent(e){e===this.currentUser&&this.notifyAuthListeners()}_key(){return`${this.config.authDomain}:${this.config.apiKey}:${this.name}`}_startProactiveRefresh(){this.isProactiveRefreshEnabled=!0,this.currentUser&&this._currentUser._startProactiveRefresh()}_stopProactiveRefresh(){this.isProactiveRefreshEnabled=!1,this.currentUser&&this._currentUser._stopProactiveRefresh()}get _currentUser(){return this.currentUser}notifyAuthListeners(){var t;if(!this._isInitialized)return;this.idTokenSubscription.next(this.currentUser);const e=((t=this.currentUser)==null?void 0:t.uid)??null;this.lastNotifiedUid!==e&&(this.lastNotifiedUid=e,this.authStateSubscription.next(this.currentUser))}registerStateListener(e,t,r,s){if(this._deleted)return()=>{};const i=typeof t=="function"?t:t.next.bind(t);let a=!1;const u=this._isInitialized?Promise.resolve():this._initializationPromise;if(M(u,this,"internal-error"),u.then(()=>{a||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 M(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(e){!e||this.frameworks.includes(e)||(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=$l(this.config.clientPlatform,this._getFrameworks()))}_getFrameworks(){return this.frameworks}async _getAdditionalHeaders(){var s;const e={"X-Client-Version":this.clientVersion};this.app.options.appId&&(e["X-Firebase-gmpid"]=this.app.options.appId);const t=await((s=this.heartbeatServiceProvider.getImmediate({optional:!0}))==null?void 0:s.getHeartbeatsHeader());t&&(e["X-Firebase-Client"]=t);const r=await this._getAppCheckToken();return r&&(e["X-Firebase-AppCheck"]=r),e}async _getAppCheckToken(){var t;if(ve(this.app)&&this.app.settings.appCheckToken)return this.app.settings.appCheckToken;const e=await((t=this.appCheckServiceProvider.getImmediate({optional:!0}))==null?void 0:t.getToken());return e!=null&&e.error&&mm(`Error while retrieving App Check token: ${e.error}`),e==null?void 0:e.token}}function _t(n){return H(n)}class Kc{constructor(e){this.auth=e,this.observer=null,this.addObserver=fp(t=>this.observer=t)}get next(){return M(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}/** 781 * @license 782 * Copyright 2020 Google LLC 783 * 784 * Licensed under the Apache License, Version 2.0 (the "License");
785 * you may not use this file except in compliance with the License. 786 * You may obtain a copy of the License at 787 * 788 * http://www.apache.org/licenses/LICENSE-2.0 789 * 790 * Unless required by applicable law or agreed to in writing, software 791 * distributed under the License is distributed on an "AS IS" BASIS, 792 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 793 * See the License for the specific language governing permissions and 794 * limitations under the License. 795 */let Qs={async loadJS(){throw new Error("Unable to load external scripts")},recaptchaV2Script:"",recaptchaEnterpriseScript:"",gapiScript:""};function qm(n){Qs=n}function jl(n){return Qs.loadJS(n)}function $m(){return Qs.recaptchaEnterpriseScript}function jm(){return Qs.gapiScript}function Hm(n){return`__${n}${Math.floor(Math.random()*1e6)}`}class zm{constructor(){this.enterprise=new Gm}ready(e){e()}execute(e,t){return Promise.resolve("token")}render(e,t){return""}}class Gm{ready(e){e()}execute(e,t){return Promise.resolve("token")}render(e,t){return""}}const Wm="recaptcha-enterprise",Hl="NO_RECAPTCHA";class Km{constructor(e){this.type=Wm,this.auth=_t(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,u)=>{Rm(i,{clientType:"CLIENT_TYPE_WEB",version:"RECAPTCHA_ENTERPRISE"}).then(l=>{if(l.recaptchaKey===void 0)u(new Error("recaptcha Enterprise site key undefined"));else{const d=new Am(l);return i.tenantId==null?i._agentRecaptchaConfig=d:i._tenantRecaptchaConfigs[i.tenantId]=d,a(d.siteKey)}}).catch(l=>{u(l)})})}function s(i,a,u){const l=window.grecaptcha;jc(l)?l.enterprise.ready(()=>{l.enterprise.execute(i,{action:e}).then(d=>{a(d)}).catch(()=>{a(Hl)})}):u(Error("No reCAPTCHA enterprise script loaded."))}return this.auth.settings.appVerificationDisabledForTesting?new zm().execute("siteKey",{action:"verify"}):new Promise((i,a)=>{r(this.auth).then(u=>{if(!t&&jc(window.grecaptcha))s(u,i,a);else{if(typeof window>"u"){a(new Error("RecaptchaVerifier is only supported in browser"));return}let l=$m();l.length!==0&&(l+=u),jl(l).then(()=>{s(u,i,a)}).catch(d=>{a(d)})}}).catch(u=>{a(u)})})}}async function Qc(n,e,t,r=!1,s=!1){const i=new Km(n);let a;if(s)a=Hl;else try{a=await i.verify(t)}catch{a=await i.verify(t,!0)}const u={...e};if(t==="mfaSmsEnrollment"||t==="mfaSmsSignIn"){if("phoneEnrollmentInfo"in u){const l=u.phoneEnrollmentInfo.phoneNumber,d=u.phoneEnrollmentInfo.recaptchaToken;Object.assign(u,{phoneEnrollmentInfo:{phoneNumber:l,recaptchaToken:d,captchaResponse:a,clientType:"CLIENT_TYPE_WEB",recaptchaVersion:"RECAPTCHA_ENTERPRISE"}})}else if("phoneSignInInfo"in u){const l=u.phoneSignInInfo.recaptchaToken;Object.assign(u,{phoneSignInInfo:{recaptchaToken:l,captchaResponse:a,clientType:"CLIENT_TYPE_WEB",recaptchaVersion:"RECAPTCHA_ENTERPRISE"}})}return u}return r?Object.assign(u,{captchaResp:a}):Object.assign(u,{captchaResponse:a}),Object.assign(u,{clientType:"CLIENT_TYPE_WEB"}),Object.assign(u,{recaptchaVersion:"RECAPTCHA_ENTERPRISE"}),u}async function oo(n,e,t,r,s){var i;if((i=n._getRecaptchaConfig())!=null&&i.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")){const a=await Qc(n,e,t,t==="getOobCode");return r(n,a)}else return r(n,e).catch(async a=>{if(a.code==="auth/missing-recaptcha-token"){console.log(`${t} is protected by reCAPTCHA Enterprise for this project. Automatically triggering the reCAPTCHA flow and restarting the flow.`);const u=await Qc(n,e,t,t==="getOobCode");return r(n,u)}else return Promise.reject(a)})}/** 796 * @license 797 * Copyright 2020 Google LLC 798 * 799 * Licensed under the Apache License, Version 2.0 (the "License"); 800 * you may not use this file except in compliance with the License. 801 * You may obtain a copy of the License at 802 * 803 * http://www.apache.org/licenses/LICENSE-2.0 804 * 805 * Unless required by applicable law or agreed to in writing, software 806 * distributed under the License is distributed on an "AS IS" BASIS, 807 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 808 * See the License for the specific language governing permissions and 809 * limitations under the License. 810 */function Qm(n,e){const t=Dr(n,"auth");if(t.isInitialized()){const s=t.getImmediate(),i=t.getOptions();if(nn(i,e??{}))return s;Be(s,"already-initialized")}return t.initialize({options:e})}function Jm(n,e){const t=(e==null?void 0:e.persistence)||[],r=(Array.isArray(t)?t:[t]).map(ut);e!=null&&e.errorMap&&n._updateErrorMap(e.errorMap),n._initializeWithPersistence(r,e==null?void 0:e.popupRedirectResolver)}function Ym(n,e,t){const r=_t(n);
810M(/^https?:\/\//.test(e),r,"invalid-emulator-scheme");const s=!1,i=zl(e),{host:a,port:u}=Xm(e),l=u===null?"":`:${u}`,d={url:`${i}//${a}${l}/`},f=Object.freeze({host:a,port:u,protocol:i.replace(":",""),options:Object.freeze({disableWarnings:s})});if(!r._canInitEmulator){M(r.config.emulator&&r.emulatorConfig,r,"emulator-config-failed"),M(nn(d,r.config.emulator)&&nn(f,r.emulatorConfig),r,"emulator-config-failed");return}r.config.emulator=d,r.emulatorConfig=f,r.settings.appVerificationDisabledForTesting=!0,ot(a)?(Gs(`${i}//${a}${l}`),Ws("Auth",!0)):Zm()}function zl(n){const e=n.indexOf(":");return e<0?"":n.substr(0,e+1)}function Xm(n){const e=zl(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:Jc(r.substr(i.length+1))}}else{const[i,a]=r.split(":");return{host:i,port:Jc(a)}}}function Jc(n){if(!n)return null;const e=Number(n);return isNaN(e)?null:e}function Zm(){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())}/** 811 * @license 812 * Copyright 2020 Google LLC 813 * 814 * Licensed under the Apache License, Version 2.0 (the "License"); 815 * you may not use this file except in compliance with the License. 816 * You may obtain a copy of the License at 817 * 818 * http://www.apache.org/licenses/LICENSE-2.0 819 * 820 * Unless required by applicable law or agreed to in writing, software 821 * distributed under the License is distributed on an "AS IS" BASIS, 822 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 823 * See the License for the specific language governing permissions and 824 * limitations under the License. 825 */class Lo{constructor(e,t){this.providerId=e,this.signInMethod=t}toJSON(){return ct("not implemented")}_getIdTokenResponse(e){return ct("not implemented")}_linkToIdToken(e,t){return ct("not implemented")}_getReauthenticationResolver(e){return ct("not implemented")}}/** 826 * @license 827 * Copyright 2020 Google LLC 828 * 829 * Licensed under the Apache License, Version 2.0 (the "License"); 830 * you may not use this file except in compliance with the License. 831 * You may obtain a copy of the License at 832 * 833 * http://www.apache.org/licenses/LICENSE-2.0 834 * 835 * Unless required by applicable law or agreed to in writing, software 836 * distributed under the License is distributed on an "AS IS" BASIS, 837 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 838 * See the License for the specific language governing permissions and 839 * limitations under the License. 840 */async function Gl(n,e){return We(n,"POST","/v1/accounts:resetPassword",Ge(n,e))}async function eg(n,e){return We(n,"POST","/v1/accounts:update",e)}async function tg(n,e){return We(n,"POST","/v1/accounts:signUp",e)}async function ng(n,e){return We(n,"POST","/v1/accounts:update",Ge(n,e))}/** 841 * @license 842 * Copyright 2020 Google LLC 843 * 844 * Licensed under the Apache License, Version 2.0 (the "License"); 845 * you may not use this file except in compliance with the License. 846 * You may obtain a copy of the License at 847 * 848 * http://www.apache.org/licenses/LICENSE-2.0 849 * 850 * Unless required by applicable law or agreed to in writing, software 851 * distributed under the License is distributed on an "AS IS" BASIS, 852 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 853 * See the License for the specific language governing permissions and 854 * limitations under the License. 855 */async function rg(n,e){return Mn(n,"POST","/v1/accounts:signInWithPassword",Ge(n,e))}/** 856 * @license 857 * Copyright 2020 Google LLC 858 * 859 * Licensed under the Apache License, Version 2.0 (the "License");
860 * you may not use this file except in compliance with the License. 861 * You may obtain a copy of the License at 862 * 863 * http://www.apache.org/licenses/LICENSE-2.0 864 * 865 * Unless required by applicable law or agreed to in writing, software 866 * distributed under the License is distributed on an "AS IS" BASIS, 867 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 868 * See the License for the specific language governing permissions and 869 * limitations under the License. 870 */async function sg(n,e){return Mn(n,"POST","/v1/accounts:signInWithEmailLink",Ge(n,e))}async function ig(n,e){return Mn(n,"POST","/v1/accounts:signInWithEmailLink",Ge(n,e))}/** 871 * @license 872 * Copyright 2020 Google LLC 873 * 874 * Licensed under the Apache License, Version 2.0 (the "License"); 875 * you may not use this file except in compliance with the License. 876 * You may obtain a copy of the License at 877 * 878 * http://www.apache.org/licenses/LICENSE-2.0 879 * 880 * Unless required by applicable law or agreed to in writing, software 881 * distributed under the License is distributed on an "AS IS" BASIS, 882 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 883 * See the License for the specific language governing permissions and 884 * limitations under the License. 885 */class Ir extends Lo{constructor(e,t,r,s=null){super("password",r),this._email=e,this._password=t,this._tenantId=s}static _fromEmailAndPassword(e,t){return new Ir(e,t,"password")}static _fromEmailAndCode(e,t,r=null){return new Ir(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 oo(e,t,"signInWithPassword",rg);case"emailLink":return sg(e,{email:this._email,oobCode:this._password});default:Be(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 oo(e,r,"signUpPassword",tg);case"emailLink":return ig(e,{idToken:t,email:this._email,oobCode:this._password});default:Be(e,"internal-error")}}_getReauthenticationResolver(e){return this._getIdTokenResponse(e)}}/** 886 * @license 887 * Copyright 2020 Google LLC 888 * 889 * Licensed under the Apache License, Version 2.0 (the "License"); 890 * you may not use this file except in compliance with the License. 891 * You may obtain a copy of the License at 892 * 893 * http://www.apache.org/licenses/LICENSE-2.0 894 * 895 * Unless required by applicable law or agreed to in writing, software 896 * distributed under the License is distributed on an "AS IS" BASIS, 897 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 898 * See the License for the specific language governing permissions and 899 * limitations under the License. 900 */async function Rn(n,e){return Mn(n,"POST","/v1/accounts:signInWithIdp",Ge(n,e))}/** 901 * @license 902 * Copyright 2020 Google LLC 903 * 904 * Licensed under the Apache License, Version 2.0 (the "License"); 905 * you may not use this file except in compliance with the License. 906 * You may obtain a copy of the License at 907 * 908 * http://www.apache.org/licenses/LICENSE-2.0 909 * 910 * Unless required by applicable law or agreed to in writing, software 911 * distributed under the License is distributed on an "AS IS" BASIS, 912 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 913 * See the License for the specific language governing permissions and 914 * limitations under the License. 915 */const og="http://localhost";class rn extends Lo{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(e){const t=new rn(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&&
915(t.nonce=e.nonce),e.pendingToken&&(t.pendingToken=e.pendingToken)):e.oauthToken&&e.oauthTokenSecret?(t.accessToken=e.oauthToken,t.secret=e.oauthTokenSecret):Be("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,...i}=t;if(!r||!s)return null;const a=new rn(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 Rn(e,t)}_linkToIdToken(e,t){const r=this.buildRequest();return r.idToken=t,Rn(e,r)}_getReauthenticationResolver(e){const t=this.buildRequest();return t.autoCreate=!1,Rn(e,t)}buildRequest(){const e={requestUri:og,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=Nr(t)}return e}}/** 916 * @license 917 * Copyright 2020 Google LLC 918 * 919 * Licensed under the Apache License, Version 2.0 (the "License"); 920 * you may not use this file except in compliance with the License. 921 * You may obtain a copy of the License at 922 * 923 * http://www.apache.org/licenses/LICENSE-2.0 924 * 925 * Unless required by applicable law or agreed to in writing, software 926 * distributed under the License is distributed on an "AS IS" BASIS, 927 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 928 * See the License for the specific language governing permissions and 929 * limitations under the License. 930 */function ag(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 cg(n){const e=ar(cr(n)).link,t=e?ar(cr(e)).deep_link_id:null,r=ar(cr(n)).deep_link_id;return(r?ar(cr(r)).link:null)||r||t||e||n}class Js{constructor(e){const t=ar(cr(e)),r=t.apiKey??null,s=t.oobCode??null,i=ag(t.mode??null);M(r&&s&&i,"argument-error"),this.apiKey=r,this.operation=i,this.code=s,this.continueUrl=t.continueUrl??null,this.languageCode=t.lang??null,this.tenantId=t.tenantId??null}static parseLink(e){const t=cg(e);try{return new Js(t)}catch{return null}}}/** 931 * @license 932 * Copyright 2020 Google LLC 933 * 934 * Licensed under the Apache License, Version 2.0 (the "License"); 935 * you may not use this file except in compliance with the License. 936 * You may obtain a copy of the License at 937 * 938 * http://www.apache.org/licenses/LICENSE-2.0 939 * 940 * Unless required by applicable law or agreed to in writing, software 941 * distributed under the License is distributed on an "AS IS" BASIS, 942 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 943 * See the License for the specific language governing permissions and 944 * limitations under the License. 945 */class ln{constructor(){this.providerId=ln.PROVIDER_ID}static credential(e,t){return Ir._fromEmailAndPassword(e,t)}static credentialWithLink(e,t){const r=Js.parseLink(t);return M(r,"argument-error"),Ir._fromEmailAndCode(e,r.code,r.tenantId)}}ln.PROVIDER_ID="password";ln.EMAIL_PASSWORD_SIGN_IN_METHOD="password";ln.EMAIL_LINK_SIGN_IN_METHOD="emailLink";/** 946 * @license 947 * Copyright 2020 Google LLC 948 * 949 * Licensed under the Apache License, Version 2.0 (the "License"); 950 * you may not use this file except in compliance with the License. 951 * You may obtain a copy of the License at 952 * 953 * http://www.apache.org/licenses/LICENSE-2.0 954 * 955 * Unless required by applicable law or agreed to in writing, software 956 * distributed under the License is distributed on an "AS IS" BASIS, 957 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 958 * See the License for the specific language governing permissions and 959 * limitations under the License. 960 */class Wl{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}}/** 961 * @license 962 * Copyright 2019 Google LLC 963 * 964 * Licensed under the Apache License, Version 2.0 (the "License");
965 * you may not use this file except in compliance with the License. 966 * You may obtain a copy of the License at 967 * 968 * http://www.apache.org/licenses/LICENSE-2.0 969 * 970 * Unless required by applicable law or agreed to in writing, software 971 * distributed under the License is distributed on an "AS IS" BASIS, 972 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 973 * See the License for the specific language governing permissions and 974 * limitations under the License. 975 */class Or extends Wl{constructor(){super(...arguments),this.scopes=[]}addScope(e){return this.scopes.includes(e)||this.scopes.push(e),this}getScopes(){return[...this.scopes]}}/** 976 * @license 977 * Copyright 2020 Google LLC 978 * 979 * Licensed under the Apache License, Version 2.0 (the "License"); 980 * you may not use this file except in compliance with the License. 981 * You may obtain a copy of the License at 982 * 983 * http://www.apache.org/licenses/LICENSE-2.0 984 * 985 * Unless required by applicable law or agreed to in writing, software 986 * distributed under the License is distributed on an "AS IS" BASIS, 987 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 988 * See the License for the specific language governing permissions and 989 * limitations under the License. 990 */class Rt extends Or{constructor(){super("facebook.com")}static credential(e){return rn._fromParams({providerId:Rt.PROVIDER_ID,signInMethod:Rt.FACEBOOK_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return Rt.credentialFromTaggedObject(e)}static credentialFromError(e){return Rt.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return Rt.credential(e.oauthAccessToken)}catch{return null}}}Rt.FACEBOOK_SIGN_IN_METHOD="facebook.com";Rt.PROVIDER_ID="facebook.com";/** 991 * @license 992 * Copyright 2020 Google LLC 993 * 994 * Licensed under the Apache License, Version 2.0 (the "License"); 995 * you may not use this file except in compliance with the License. 996 * You may obtain a copy of the License at 997 * 998 * http://www.apache.org/licenses/LICENSE-2.0 999 * 1000 * Unless required by applicable law or agreed to in writing, software 1001 * distributed under the License is distributed on an "AS IS" BASIS, 1002 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1003 * See the License for the specific language governing permissions and 1004 * limitations under the License. 1005 */class St extends Or{constructor(){super("google.com"),this.addScope("profile")}static credential(e,t){return rn._fromParams({providerId:St.PROVIDER_ID,signInMethod:St.GOOGLE_SIGN_IN_METHOD,idToken:e,accessToken:t})}static credentialFromResult(e){return St.credentialFromTaggedObject(e)}static credentialFromError(e){return St.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthIdToken:t,oauthAccessToken:r}=e;if(!t&&!r)return null;try{return St.credential(t,r)}catch{return null}}}St.GOOGLE_SIGN_IN_METHOD="google.com";St.PROVIDER_ID="google.com";/** 1006 * @license 1007 * Copyright 2020 Google LLC 1008 * 1009 * Licensed under the Apache License, Version 2.0 (the "License"); 1010 * you may not use this file except in compliance with the License. 1011 * You may obtain a copy of the License at 1012 * 1013 * http://www.apache.org/licenses/LICENSE-2.0 1014 * 1015 * Unless required by applicable law or agreed to in writing, software 1016 * distributed under the License is distributed on an "AS IS" BASIS, 1017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1018 * See the License for the specific language governing permissions and 1019 * limitations under the License. 1020 */class Pt extends Or{constructor(){super("github.com")}static credential(e){return rn._fromParams({providerId:Pt.PROVIDER_ID,signInMethod:Pt.GITHUB_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return Pt.credentialFromTaggedObject(e)}static credentialFromError(e){return Pt.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return Pt.credential(e.oauthAccessToken)}catch{return null}}}Pt.GITHUB_SIGN_IN_METHOD="github.com";Pt.PROVIDER_ID="github.com";/** 1021 * @license 1022 * Copyright 2020 Google LLC 1023 * 1024 * Licensed under the Apache License, Version 2.0 (the "License");
1025 * you may not use this file except in compliance with the License. 1026 * You may obtain a copy of the License at 1027 * 1028 * http://www.apache.org/licenses/LICENSE-2.0 1029 * 1030 * Unless required by applicable law or agreed to in writing, software 1031 * distributed under the License is distributed on an "AS IS" BASIS, 1032 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1033 * See the License for the specific language governing permissions and 1034 * limitations under the License. 1035 */class bt extends Or{constructor(){super("twitter.com")}static credential(e,t){return rn._fromParams({providerId:bt.PROVIDER_ID,signInMethod:bt.TWITTER_SIGN_IN_METHOD,oauthToken:e,oauthTokenSecret:t})}static credentialFromResult(e){return bt.credentialFromTaggedObject(e)}static credentialFromError(e){return bt.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthAccessToken:t,oauthTokenSecret:r}=e;if(!t||!r)return null;try{return bt.credential(t,r)}catch{return null}}}bt.TWITTER_SIGN_IN_METHOD="twitter.com";bt.PROVIDER_ID="twitter.com";/** 1036 * @license 1037 * Copyright 2020 Google LLC 1038 * 1039 * Licensed under the Apache License, Version 2.0 (the "License"); 1040 * you may not use this file except in compliance with the License. 1041 * You may obtain a copy of the License at 1042 * 1043 * http://www.apache.org/licenses/LICENSE-2.0 1044 * 1045 * Unless required by applicable law or agreed to in writing, software 1046 * distributed under the License is distributed on an "AS IS" BASIS, 1047 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1048 * See the License for the specific language governing permissions and 1049 * limitations under the License. 1050 */async function ug(n,e){return Mn(n,"POST","/v1/accounts:signUp",Ge(n,e))}/** 1051 * @license 1052 * Copyright 2020 Google LLC 1053 * 1054 * Licensed under the Apache License, Version 2.0 (the "License"); 1055 * you may not use this file except in compliance with the License. 1056 * You may obtain a copy of the License at 1057 * 1058 * http://www.apache.org/licenses/LICENSE-2.0 1059 * 1060 * Unless required by applicable law or agreed to in writing, software 1061 * distributed under the License is distributed on an "AS IS" BASIS, 1062 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1063 * See the License for the specific language governing permissions and 1064 * limitations under the License. 1065 */class Ot{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 qe._fromIdTokenResponse(e,r,s),a=Yc(r);return new Ot({user:i,providerId:a,_tokenResponse:r,operationType:t})}static async _forOperation(e,t,r){await e._updateTokensIfNecessary(r,!0);const s=Yc(r);return new Ot({user:e,providerId:s,_tokenResponse:r,operationType:t})}}function Yc(n){return n.providerId?n.providerId:"phoneNumber"in n?"phone":null}/** 1066 * @license 1067 * Copyright 2020 Google LLC 1068 * 1069 * Licensed under the Apache License, Version 2.0 (the "License"); 1070 * you may not use this file except in compliance with the License. 1071 * You may obtain a copy of the License at 1072 * 1073 * http://www.apache.org/licenses/LICENSE-2.0 1074 * 1075 * Unless required by applicable law or agreed to in writing, software 1076 * distributed under the License is distributed on an "AS IS" BASIS, 1077 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1078 * See the License for the specific language governing permissions and 1079 * limitations under the License. 1080 */class bs extends ze{constructor(e,t,r,s){super(t.code,t.message),this.operationType=r,this.user=s,Object.setPrototypeOf(this,bs.prototype),this.customData={appName:e.name,tenantId:e.tenantId??void 0,_serverResponse:t.customData._serverResponse,operationType:r}}static _fromErrorAndOperation(e,t,r,s){return new bs(e,t,r,s)}}function Kl(n,e,t,r){return(e==="reauthenticate"?t._getReauthenticationResolver(n):t._getIdTokenResponse(n)).catch(i=>{throw i.code==="auth/multi-factor-auth-required"?bs._fromErrorAndOperation(n,i,e,r):i})}async function lg(n,e,t=!1){const r=await bn(n,e._linkToIdToken(n.auth,await n.getIdToken()),t);return Ot._forOperation(n,"link",r)}/** 1081 * @license 1082 * Copyright 2019 Google LLC 1083 * 1084 * Licensed under the Apache License, Version 2.0 (the "License");
1085 * you may not use this file except in compliance with the License. 1086 * You may obtain a copy of the License at 1087 * 1088 * http://www.apache.org/licenses/LICENSE-2.0 1089 * 1090 * Unless required by applicable law or agreed to in writing, software 1091 * distributed under the License is distributed on an "AS IS" BASIS, 1092 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1093 * See the License for the specific language governing permissions and 1094 * limitations under the License. 1095 */async function Ql(n,e,t=!1){const{auth:r}=n;if(ve(r.app))return Promise.reject($e(r));const s="reauthenticate";try{const i=await bn(n,Kl(r,s,e,n),t);M(i.idToken,r,"internal-error");const a=Vo(i.idToken);M(a,r,"internal-error");const{sub:u}=a;return M(n.uid===u,r,"user-mismatch"),Ot._forOperation(n,s,i)}catch(i){throw(i==null?void 0:i.code)==="auth/user-not-found"&&Be(r,"user-mismatch"),i}}/** 1096 * @license 1097 * Copyright 2020 Google LLC 1098 * 1099 * Licensed under the Apache License, Version 2.0 (the "License"); 1100 * you may not use this file except in compliance with the License. 1101 * You may obtain a copy of the License at 1102 * 1103 * http://www.apache.org/licenses/LICENSE-2.0 1104 * 1105 * Unless required by applicable law or agreed to in writing, software 1106 * distributed under the License is distributed on an "AS IS" BASIS, 1107 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1108 * See the License for the specific language governing permissions and 1109 * limitations under the License. 1110 */async function Jl(n,e,t=!1){if(ve(n.app))return Promise.reject($e(n));const r="signIn",s=await Kl(n,r,e),i=await Ot._fromIdTokenResponse(n,r,s);return t||await n._updateCurrentUser(i.user),i}async function Yl(n,e){return Jl(_t(n),e)}async function Vw(n,e){return Ql(H(n),e)}/** 1111 * @license 1112 * Copyright 2020 Google LLC 1113 * 1114 * Licensed under the Apache License, Version 2.0 (the "License"); 1115 * you may not use this file except in compliance with the License. 1116 * You may obtain a copy of the License at 1117 * 1118 * http://www.apache.org/licenses/LICENSE-2.0 1119 * 1120 * Unless required by applicable law or agreed to in writing, software 1121 * distributed under the License is distributed on an "AS IS" BASIS, 1122 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1123 * See the License for the specific language governing permissions and 1124 * limitations under the License. 1125 */async function hg(n,e){return Mn(n,"POST","/v1/accounts:signInWithCustomToken",Ge(n,e))}/** 1126 * @license 1127 * Copyright 2020 Google LLC 1128 * 1129 * Licensed under the Apache License, Version 2.0 (the "License"); 1130 * you may not use this file except in compliance with the License. 1131 * You may obtain a copy of the License at 1132 * 1133 * http://www.apache.org/licenses/LICENSE-2.0 1134 * 1135 * Unless required by applicable law or agreed to in writing, software 1136 * distributed under the License is distributed on an "AS IS" BASIS, 1137 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1138 * See the License for the specific language governing permissions and 1139 * limitations under the License. 1140 */async function Ow(n,e){if(ve(n.app))return Promise.reject($e(n));const t=_t(n),r=await hg(t,{token:e,returnSecureToken:!0}),s=await Ot._fromIdTokenResponse(t,"signIn",r);return await t._updateCurrentUser(s.user),s}/** 1141 * @license 1142 * Copyright 2020 Google LLC 1143 * 1144 * Licensed under the Apache License, Version 2.0 (the "License"); 1145 * you may not use this file except in compliance with the License. 1146 * You may obtain a copy of the License at 1147 * 1148 * http://www.apache.org/licenses/LICENSE-2.0 1149 * 1150 * Unless required by applicable law or agreed to in writing, software 1151 * distributed under the License is distributed on an "AS IS" BASIS, 1152 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1153 * See the License for the specific language governing permissions and 1154 * limitations under the License. 1155 */class Mo{constructor(e,t){this.factorId=e,this.uid=t.mfaEnrollmentId,this.enrollmentTime=new Date(t.enrolledAt).toUTCString(),this.displayName=t.displayName}static _fromServerResponse(e,t){return"phoneInfo"in t?xo._fromServerResponse(e,t):"totpInfo"in t?Uo._fromServerResponse(e,t):Be(e,"internal-error")}}class xo extends Mo{constructor(e){super("phone",e),this.phoneNumber=e.phoneInfo}static _fromServerResponse(e,t){return new xo(t)}}class Uo extends Mo{constructor(e){super("totp",e)}static _fromServerResponse(e,t){return new Uo(t)}}/** 1156 * @license 1157 * Copyright 2020 Google LLC 1158 * 1159 * Licensed under the Apache License, Version 2.0 (the "License");
1160 * you may not use this file except in compliance with the License. 1161 * You may obtain a copy of the License at 1162 * 1163 * http://www.apache.org/licenses/LICENSE-2.0 1164 * 1165 * Unless required by applicable law or agreed to in writing, software 1166 * distributed under the License is distributed on an "AS IS" BASIS, 1167 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1168 * See the License for the specific language governing permissions and 1169 * limitations under the License. 1170 */async function Fo(n){const e=_t(n);e._getPasswordPolicyInternal()&&await e._updatePasswordPolicy()}async function Lw(n,e,t){await Gl(H(n),{oobCode:e,newPassword:t}).catch(async r=>{throw r.code==="auth/password-does-not-meet-requirements"&&Fo(n),r})}async function Mw(n,e){await ng(H(n),{oobCode:e})}async function dg(n,e){const t=H(n),r=await Gl(t,{oobCode:e}),s=r.requestType;switch(M(s,t,"internal-error"),s){case"EMAIL_SIGNIN":break;case"VERIFY_AND_CHANGE_EMAIL":M(r.newEmail,t,"internal-error");break;case"REVERT_SECOND_FACTOR_ADDITION":M(r.mfaInfo,t,"internal-error");default:M(r.email,t,"internal-error")}let i=null;return r.mfaInfo&&(i=Mo._fromServerResponse(_t(t),r.mfaInfo)),{data:{email:(r.requestType==="VERIFY_AND_CHANGE_EMAIL"?r.newEmail:r.email)||null,previousEmail:(r.requestType==="VERIFY_AND_CHANGE_EMAIL"?r.email:r.newEmail)||null,multiFactorInfo:i},operation:s}}async function xw(n,e){const{data:t}=await dg(H(n),e);return t.email}async function Uw(n,e,t){if(ve(n.app))return Promise.reject($e(n));const r=_t(n),a=await oo(r,{returnSecureToken:!0,email:e,password:t,clientType:"CLIENT_TYPE_WEB"},"signUpPassword",ug).catch(l=>{throw l.code==="auth/password-does-not-meet-requirements"&&Fo(n),l}),u=await Ot._fromIdTokenResponse(r,"signIn",a);return await r._updateCurrentUser(u.user),u}function Fw(n,e,t){return ve(n.app)?Promise.reject($e(n)):Yl(H(n),ln.credential(e,t)).catch(async r=>{throw r.code==="auth/password-does-not-meet-requirements"&&Fo(n),r})}function Bw(n,e){const t=Js.parseLink(e);return(t==null?void 0:t.operation)==="EMAIL_SIGNIN"}async function qw(n,e,t){if(ve(n.app))return Promise.reject($e(n));const r=H(n),s=ln.credentialWithLink(e,t||Rs());return M(s._tenantId===(r.tenantId||null),r,"tenant-id-mismatch"),Yl(r,s)}function $w(n,e){return fg(H(n),null,e)}async function fg(n,e,t){const{auth:r}=n,i={idToken:await n.getIdToken(),returnSecureToken:!0};t&&(i.password=t);const a=await bn(n,eg(r,i));await n._updateTokensIfNecessary(a,!0)}function pg(n,e,t,r){return H(n).onIdTokenChanged(e,t,r)}function mg(n,e,t){return H(n).beforeAuthStateChanged(e,t)}function jw(n,e,t,r){return H(n).onAuthStateChanged(e,t,r)}function Hw(n){return H(n).signOut()}const Cs="__sak";/** 1171 * @license 1172 * Copyright 2019 Google LLC 1173 * 1174 * Licensed under the Apache License, Version 2.0 (the "License"); 1175 * you may not use this file except in compliance with the License. 1176 * You may obtain a copy of the License at 1177 * 1178 * http://www.apache.org/licenses/LICENSE-2.0 1179 * 1180 * Unless required by applicable law or agreed to in writing, software 1181 * distributed under the License is distributed on an "AS IS" BASIS, 1182 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1183 * See the License for the specific language governing permissions and 1184 * limitations under the License. 1185 */class Xl{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()}}/** 1186 * @license 1187 * Copyright 2020 Google LLC 1188 * 1189 * Licensed under the Apache License, Version 2.0 (the "License"); 1190 * you may not use this file except in compliance with the License. 1191 * You may obtain a copy of the License at 1192 * 1193 * http://www.apache.org/licenses/LICENSE-2.0 1194 * 1195 * Unless required by applicable law or agreed to in writing, softw
1195are 1196 * distributed under the License is distributed on an "AS IS" BASIS, 1197 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1198 * See the License for the specific language governing permissions and 1199 * limitations under the License. 1200 */const gg=1e3,_g=10;class Zl extends Xl{constructor(){super(()=>window.localStorage,"LOCAL"),this.boundEventHandler=(e,t)=>this.onStorageEvent(e,t),this.listeners={},this.localCache={},this.pollTimer=null,this.fallbackToPolling=ql(),this._shouldAllowMigration=!0}forAllChangedKeys(e){for(const t of Object.keys(this.listeners)){const r=this.storage.getItem(t),s=this.localCache[t];r!==s&&e(t,s,r)}}onStorageEvent(e,t=!1){if(!e.key){this.forAllChangedKeys((a,u,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);Lm()&&i!==e.newValue&&e.newValue!==e.oldValue?setTimeout(s,_g):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)})},gg)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}attachListener(){window.addEventListener("storage",this.boundEventHandler)}detachListener(){window.removeEventListener("storage",this.boundEventHandler)}_addListener(e,t){Object.keys(this.listeners).length===0&&(this.fallbackToPolling?this.startPolling():this.attachListener()),this.listeners[e]||(this.listeners[e]=new Set,this.localCache[e]=this.storage.getItem(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),this.listeners[e].size===0&&delete this.listeners[e]),Ob
1200ject.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]}}Zl.type="LOCAL";const yg=Zl;/** 1201 * @license 1202 * Copyright 2020 Google LLC 1203 * 1204 * Licensed under the Apache License, Version 2.0 (the "License"); 1205 * you may not use this file except in compliance with the License. 1206 * You may obtain a copy of the License at 1207 * 1208 * http://www.apache.org/licenses/LICENSE-2.0 1209 * 1210 * Unless required by applicable law or agreed to in writing, software 1211 * distributed under the License is distributed on an "AS IS" BASIS, 1212 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1213 * See the License for the specific language governing permissions and 1214 * limitations under the License. 1215 */class eh extends Xl{constructor(){super(()=>window.sessionStorage,"SESSION")}_addListener(e,t){}_removeListener(e,t){}}eh.type="SESSION";const th=eh;/** 1216 * @license 1217 * Copyright 2019 Google LLC 1218 * 1219 * Licensed under the Apache License, Version 2.0 (the "License"); 1220 * you may not use this file except in compliance with the License. 1221 * You may obtain a copy of the License at 1222 * 1223 * http://www.apache.org/licenses/LICENSE-2.0 1224 * 1225 * Unless required by applicable law or agreed to in writing, software 1226 * distributed under the License is distributed on an "AS IS" BASIS, 1227 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1228 * See the License for the specific language governing permissions and 1229 * limitations under the License. 1230 */function Eg(n){return Promise.all(n.map(async e=>{try{return{fulfilled:!0,value:await e}}catch(t){return{fulfilled:!1,reason:t}}}))}/** 1231 * @license 1232 * Copyright 2019 Google LLC 1233 * 1234 * Licensed under the Apache License, Version 2.0 (the "License"); 1235 * you may not use this file except in compliance with the License. 1236 * You may obtain a copy of the License at 1237 * 1238 * http://www.apache.org/licenses/LICENSE-2.0 1239 * 1240 * Unless required by applicable law or agreed to in writing, software 1241 * distributed under the License is distributed on an "AS IS" BASIS, 1242 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1243 * See the License for the specific language governing permissions and 1244 * limitations under the License. 1245 */class Ys{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 Ys(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 u=Array.from(a).map(async d=>d(t.origin,i)),l=await Eg(u);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)}}Ys.receivers=[];/** 1246 * @license 1247 * Copyright 2020 Google LLC 1248 * 1249 * Licensed under the Apache License, Version 2.0 (the "License"); 1250 * you may not use this file except in compliance with the License. 1251 * You may obtain a copy of the License at 1252 * 1253 * http://www.apache.org/licenses/LICENSE-2.0 1254 * 1255 * Unless required by applicable law or agreed to in writing, software 1256 * distributed under the License is distributed on an "AS IS" BASIS, 1257 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1258 * See the License for the specific language governing permissions and 1259 * limitations under the License. 1260 */function Bo(n="",e=10){let t="";for(let r=0;r<e;r++)t+=Math.floor(Math.random()*10);return n+t}/** 1261 * @license 1262 * Copyright 2019 Google LLC 1263 * 1264 * Licensed under the Apache License, Version 2.0 (the "License");
1265 * you may not use this file except in compliance with the License. 1266 * You may obtain a copy of the License at 1267 * 1268 * http://www.apache.org/licenses/LICENSE-2.0 1269 * 1270 * Unless required by applicable law or agreed to in writing, software 1271 * distributed under the License is distributed on an "AS IS" BASIS, 1272 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1273 * See the License for the specific language governing permissions and 1274 * limitations under the License. 1275 */class Tg{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((u,l)=>{const d=Bo("",20);s.port1.start();const f=setTimeout(()=>{l(new Error("unsupported_event"))},r);a={messageChannel:s,onMessage(m){const _=m;if(_.data.eventId===d)switch(_.data.status){case"ack":clearTimeout(f),i=setTimeout(()=>{l(new Error("timeout"))},3e3);break;case"done":clearTimeout(i),u(_.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)})}}/** 1276 * @license 1277 * Copyright 2020 Google LLC 1278 * 1279 * Licensed under the Apache License, Version 2.0 (the "License"); 1280 * you may not use this file except in compliance with the License. 1281 * You may obtain a copy of the License at 1282 * 1283 * http://www.apache.org/licenses/LICENSE-2.0 1284 * 1285 * Unless required by applicable law or agreed to in writing, software 1286 * distributed under the License is distributed on an "AS IS" BASIS, 1287 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1288 * See the License for the specific language governing permissions and 1289 * limitations under the License. 1290 */function et(){return window}function Ig(n){et().location.href=n}/** 1291 * @license 1292 * Copyright 2020 Google LLC. 1293 * 1294 * Licensed under the Apache License, Version 2.0 (the "License"); 1295 * you may not use this file except in compliance with the License. 1296 * You may obtain a copy of the License at 1297 * 1298 * http://www.apache.org/licenses/LICENSE-2.0 1299 * 1300 * Unless required by applicable law or agreed to in writing, software 1301 * distributed under the License is distributed on an "AS IS" BASIS, 1302 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1303 * See the License for the specific language governing permissions and 1304 * limitations under the License. 1305 */function nh(){return typeof et().WorkerGlobalScope<"u"&&typeof et().importScripts=="function"}async function wg(){if(!(navigator!=null&&navigator.serviceWorker))return null;try{return(await navigator.serviceWorker.ready).active}catch{return null}}function vg(){var n;return((n=navigator==null?void 0:navigator.serviceWorker)==null?void 0:n.controller)||null}function Ag(){return nh()?self:null}/** 1306 * @license 1307 * Copyright 2019 Google LLC 1308 * 1309 * Licensed under the Apache License, Version 2.0 (the "License"); 1310 * you may not use this file except in compliance with the License. 1311 * You may obtain a copy of the License at 1312 * 1313 * http://www.apache.org/licenses/LICENSE-2.0 1314 * 1315 * Unless required by applicable law or agreed to in writing, software 1316 * distributed under the License is distributed on an "AS IS" BASIS, 1317 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1318 * See the License for the specific language governing permissions and 1319 * limitations under the License. 1320 */const rh="firebaseLocalStorageDb",Rg=1,ks="firebaseLocalStorage",sh="fbase_key";class Lr{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 Xs(n,e){return n.transaction([ks],e?"readwrite":"readonly").objectStore(ks)}function Sg(){const n=indexedDB.deleteDatabase(rh);return new Lr(n).toPromise()}function ao(){const n=indexedDB.open(rh,Rg);return new Promise((e,t)=>
1320{n.addEventListener("error",()=>{t(n.error)}),n.addEventListener("upgradeneeded",()=>{const r=n.result;try{r.createObjectStore(ks,{keyPath:sh})}catch(s){t(s)}}),n.addEventListener("success",async()=>{const r=n.result;r.objectStoreNames.contains(ks)?e(r):(r.close(),await Sg(),e(await ao()))})})}async function Xc(n,e,t){const r=Xs(n,!0).put({[sh]:e,value:t});return new Lr(r).toPromise()}async function Pg(n,e){const t=Xs(n,!1).get(e),r=await new Lr(t).toPromise();return r===void 0?null:r.value}function Zc(n,e){const t=Xs(n,!0).delete(e);return new Lr(t).toPromise()}const bg=800,Cg=3;class ih{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 ao(),this.db)}async _withRetries(e){let t=0;for(;;)try{const r=await this._openDb();return await e(r)}catch(r){if(t++>Cg)throw r;this.db&&(this.db.close(),this.db=void 0)}}async initializeServiceWorkerMessaging(){return nh()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=Ys._getInstance(Ag()),this.receiver._subscribe("keyChanged",async(e,t)=>({keyProcessed:(await this._poll()).includes(t.key)})),this.receiver._subscribe("ping",async(e,t)=>["keyChanged"])}async initializeSender(){var t,r;if(this.activeServiceWorker=await wg(),!this.activeServiceWorker)return;this.sender=new Tg(this.activeServiceWorker);const e=await this.sender._send("ping",{},800);e&&(t=e[0])!=null&&t.fulfilled&&(r=e[0])!=null&&r.value.includes("keyChanged")&&(this.serviceWorkerReceiverAvailable=!0)}async notifyServiceWorker(e){if(!(!this.sender||!this.activeServiceWorker||vg()!==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 ao();return await Xc(e,Cs,"1"),await Zc(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=>Xc(r,e,t)),this.localCache[e]=t,this.notifyServiceWorker(e)))}async _get(e){const t=await this._withRetries(r=>Pg(r,e));return this.localCache[e]=t,t}async _remove(e){return this._withPendingWrite(async()=>(await this._withRetries(t=>Zc(t,e)),delete this.localCache[e],this.notifyServiceWorker(e)))}async _poll(){const e=await this._withRetries(s=>{const i=Xs(s,!1).getAll();return new Lr(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(),bg)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}_addListener(e,t){Object.keys(this.listeners).length===0&&this.startPolling(),this.listeners[e]||(this.listeners[e]=new Set,this._get(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),this.listeners[e].size===0&&delete this.listeners[e]),Ob
1320ject.keys(this.listeners).length===0&&this.stopPolling()}}ih.type="LOCAL";const kg=ih;new Vr(3e4,6e4);/** 1321 * @license 1322 * Copyright 2021 Google LLC 1323 * 1324 * Licensed under the Apache License, Version 2.0 (the "License"); 1325 * you may not use this file except in compliance with the License. 1326 * You may obtain a copy of the License at 1327 * 1328 * http://www.apache.org/licenses/LICENSE-2.0 1329 * 1330 * Unless required by applicable law or agreed to in writing, software 1331 * distributed under the License is distributed on an "AS IS" BASIS, 1332 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1333 * See the License for the specific language governing permissions and 1334 * limitations under the License. 1335 */function Ng(n,e){return e?ut(e):(M(n._popupRedirectResolver,n,"argument-error"),n._popupRedirectResolver)}/** 1336 * @license 1337 * Copyright 2019 Google LLC 1338 * 1339 * Licensed under the Apache License, Version 2.0 (the "License"); 1340 * you may not use this file except in compliance with the License. 1341 * You may obtain a copy of the License at 1342 * 1343 * http://www.apache.org/licenses/LICENSE-2.0 1344 * 1345 * Unless required by applicable law or agreed to in writing, software 1346 * distributed under the License is distributed on an "AS IS" BASIS, 1347 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1348 * See the License for the specific language governing permissions and 1349 * limitations under the License. 1350 */class qo extends Lo{constructor(e){super("custom","custom"),this.params=e}_getIdTokenResponse(e){return Rn(e,this._buildIdpRequest())}_linkToIdToken(e,t){return Rn(e,this._buildIdpRequest(t))}_getReauthenticationResolver(e){return Rn(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 Dg(n){return Jl(n.auth,new qo(n),n.bypassAuthState)}function Vg(n){const{auth:e,user:t}=n;return M(t,e,"internal-error"),Ql(t,new qo(n),n.bypassAuthState)}async function Og(n){const{auth:e,user:t}=n;return M(t,e,"internal-error"),lg(t,new qo(n),n.bypassAuthState)}/** 1351 * @license 1352 * Copyright 2020 Google LLC 1353 * 1354 * Licensed under the Apache License, Version 2.0 (the "License"); 1355 * you may not use this file except in compliance with the License. 1356 * You may obtain a copy of the License at 1357 * 1358 * http://www.apache.org/licenses/LICENSE-2.0 1359 * 1360 * Unless required by applicable law or agreed to in writing, software 1361 * distributed under the License is distributed on an "AS IS" BASIS, 1362 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1363 * See the License for the specific language governing permissions and 1364 * limitations under the License. 1365 */class oh{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:u}=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(u)(l))}catch(d){this.reject(d)}}onError(e){this.reject(e)}getIdpTask(e){switch(e){case"signInViaPopup":case"signInViaRedirect":return Dg;case"linkViaPopup":case"linkViaRedirect":return Og;case"reauthViaPopup":case"reauthViaRedirect":return Vg;default:Be(this.auth,"internal-error")}}resolve(e){ft(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){ft(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.reject(e),this.unregisterAndCleanUp()}unregisterAndCleanUp(){this.eventManager&&this.eventManager.unregisterConsumer(this),this.pendingPromise=null,this.cleanUp()}}/** 1366 * @license 1367 * Copyright 2020 Google LLC 1368 * 1369 * Licensed under the Apache License, Version 2.0 (the "License");
1370 * you may not use this file except in compliance with the License. 1371 * You may obtain a copy of the License at 1372 * 1373 * http://www.apache.org/licenses/LICENSE-2.0 1374 * 1375 * Unless required by applicable law or agreed to in writing, software 1376 * distributed under the License is distributed on an "AS IS" BASIS, 1377 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1378 * See the License for the specific language governing permissions and 1379 * limitations under the License. 1380 */const Lg=new Vr(2e3,1e4);class wn extends oh{constructor(e,t,r,s,i){super(e,t,s,i),this.provider=r,this.authWindow=null,this.pollId=null,wn.currentPopupAction&&wn.currentPopupAction.cancel(),wn.currentPopupAction=this}async executeNotNull(){const e=await this.execute();return M(e,this.auth,"internal-error"),e}async onExecution(){ft(this.filter.length===1,"Popup operations only handle one event");const e=Bo();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(Ze(this.auth,"web-storage-unsupported"))}),this.pollUserCancellation()}get eventId(){var e;return((e=this.authWindow)==null?void 0:e.associatedEvent)||null}cancel(){this.reject(Ze(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,wn.currentPopupAction=null}pollUserCancellation(){const e=()=>{var t,r;if((r=(t=this.authWindow)==null?void 0:t.window)!=null&&r.closed){this.pollId=window.setTimeout(()=>{this.pollId=null,this.reject(Ze(this.auth,"popup-closed-by-user"))},8e3);return}this.pollId=window.setTimeout(e,Lg.get())};e()}}wn.currentPopupAction=null;/** 1381 * @license 1382 * Copyright 2020 Google LLC 1383 * 1384 * Licensed under the Apache License, Version 2.0 (the "License"); 1385 * you may not use this file except in compliance with the License. 1386 * You may obtain a copy of the License at 1387 * 1388 * http://www.apache.org/licenses/LICENSE-2.0 1389 * 1390 * Unless required by applicable law or agreed to in writing, software 1391 * distributed under the License is distributed on an "AS IS" BASIS, 1392 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1393 * See the License for the specific language governing permissions and 1394 * limitations under the License. 1395 */const Mg="pendingRedirect",ps=new Map;class xg extends oh{constructor(e,t,r=!1){super(e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],t,void 0,r),this.eventId=null}async execute(){let e=ps.get(this.auth._key());if(!e){try{const r=await Ug(this.resolver,this.auth)?await super.execute():null;e=()=>Promise.resolve(r)}catch(t){e=()=>Promise.reject(t)}ps.set(this.auth._key(),e)}return this.bypassAuthState||ps.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 Ug(n,e){const t=qg(e),r=Bg(n);if(!await r._isAvailable())return!1;const s=await r._get(t)==="true";return await r._remove(t),s}function Fg(n,e){ps.set(n._key(),e)}function Bg(n){return ut(n._redirectPersistence)}function qg(n){return fs(Mg,n.config.apiKey,n.name)}async function $g(n,e,t=!1){if(ve(n.app))return Promise.reject($e(n));const r=_t(n),s=Ng(r,e),a=await new xg(r,s,t).execute();return a&&!t&&(delete a.user._redirectEventId,await r._persistUserIfCurrent(a.user),await r._setRedirectUser(null,e)),a}/** 1396 * @license 1397 * Copyright 2020 Google LLC 1398 * 1399 * Licensed under the Apache License, Version 2.0 (the "License"); 1400 * you may not use this file except in compliance with the License. 1401 * You may obtain a copy of the License at 1402 * 1403 * http://www.apache.org/licenses/LICENSE-2.0 1404 * 1405 * Unless required by applicable law or agreed to in writing, softw
1405are 1406 * distributed under the License is distributed on an "AS IS" BASIS, 1407 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1408 * See the License for the specific language governing permissions and 1409 * limitations under the License. 1410 */const jg=600*1e3;class Hg{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||!zg(e)||(this.hasHandledPotentialRedirect=!0,t||(this.queuedRedirectEvent=e,t=!0)),t}sendToConsumer(e,t){var r;if(e.error&&!ah(e)){const s=((r=e.error.code)==null?void 0:r.split("auth/")[1])||"internal-error";t.onError(Ze(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>=jg&&this.cachedEventUids.clear(),this.cachedEventUids.has(eu(e))}saveEventToCache(e){this.cachedEventUids.add(eu(e)),this.lastProcessedEventTime=Date.now()}}function eu(n){return[n.type,n.eventId,n.sessionId,n.tenantId].filter(e=>e).join("-")}function ah({type:n,error:e}){return n==="unknown"&&(e==null?void 0:e.code)==="auth/no-auth-event"}function zg(n){switch(n.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return!0;case"unknown":return ah(n);default:return!1}}/** 1411 * @license 1412 * Copyright 2020 Google LLC 1413 * 1414 * Licensed under the Apache License, Version 2.0 (the "License"); 1415 * you may not use this file except in compliance with the License. 1416 * You may obtain a copy of the License at 1417 * 1418 * http://www.apache.org/licenses/LICENSE-2.0 1419 * 1420 * Unless required by applicable law or agreed to in writing, software 1421 * distributed under the License is distributed on an "AS IS" BASIS, 1422 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1423 * See the License for the specific language governing permissions and 1424 * limitations under the License. 1425 */async function Gg(n,e={}){return We(n,"GET","/v1/projects",e)}/** 1426 * @license 1427 * Copyright 2020 Google LLC 1428 * 1429 * Licensed under the Apache License, Version 2.0 (the "License"); 1430 * you may not use this file except in compliance with the License. 1431 * You may obtain a copy of the License at 1432 * 1433 * http://www.apache.org/licenses/LICENSE-2.0 1434 * 1435 * Unless required by applicable law or agreed to in writing, software 1436 * distributed under the License is distributed on an "AS IS" BASIS, 1437 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1438 * See the License for the specific language governing permissions and 1439 * limitations under the License. 1440 */const Wg=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,Kg=/^https?/;async function Qg(n){if(n.config.emulator)return;const{authorizedDomains:e}=await Gg(n);for(const t of e)try{if(Jg(t))return}catch{}Be(n,"unauthorized-domain")}function Jg(n){const e=Rs(),{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(!Kg.test(t))return!1;if(Wg.test(n))return r===n;const s=n.replace(/\./g,"\\.");return new RegExp("^(.+\\."+s+"|"+s+")$","i").test(r)}/** 1441 * @license 1442 * Copyright 2020 Google LLC. 1443 * 1444 * Licensed under the Apache License, Version 2.0 (the "License"); 1445 * you may not use this file except in compliance with the License. 1446 * You may obtain a copy of the License at 1447 * 1448 * http://www.apache.org/licenses/LICENSE-2.0 1449 * 1450 * Unless required by applicable law or agreed to in writing, softw
1450are 1451 * distributed under the License is distributed on an "AS IS" BASIS, 1452 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1453 * See the License for the specific language governing permissions and 1454 * limitations under the License. 1455 */const Yg=new Vr(3e4,6e4);function tu(){const n=et().___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 Xg(n){return new Promise((e,t)=>{var s,i,a;function r(){tu(),gapi.load("gapi.iframes",{callback:()=>{e(gapi.iframes.getContext())},ontimeout:()=>{tu(),t(Ze(n,"network-request-failed"))},timeout:Yg.get()})}if((i=(s=et().gapi)==null?void 0:s.iframes)!=null&&i.Iframe)e(gapi.iframes.getContext());else if((a=et().gapi)!=null&&a.load)r();else{const u=Hm("iframefcb");return et()[u]=()=>{gapi.load?r():t(Ze(n,"network-request-failed"))},jl(`${jm()}?onload=${u}`).catch(l=>t(l))}}).catch(e=>{throw ms=null,e})}let ms=null;function Zg(n){return ms=ms||Xg(n),ms}/** 1456 * @license 1457 * Copyright 2020 Google LLC. 1458 * 1459 * Licensed under the Apache License, Version 2.0 (the "License"); 1460 * you may not use this file except in compliance with the License. 1461 * You may obtain a copy of the License at 1462 * 1463 * http://www.apache.org/licenses/LICENSE-2.0 1464 * 1465 * Unless required by applicable law or agreed to in writing, software 1466 * distributed under the License is distributed on an "AS IS" BASIS, 1467 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1468 * See the License for the specific language governing permissions and 1469 * limitations under the License. 1470 */const e_=new Vr(5e3,15e3),t_="__/auth/iframe",n_="emulator/auth/iframe",r_={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},s_=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);function i_(n){const e=n.config;M(e.authDomain,n,"auth-domain-config-required");const t=e.emulator?Do(e,n_):`https://${n.config.authDomain}/${t_}`,r={apiKey:e.apiKey,appName:n.name,v:un},s=s_.get(n.config.apiHost);s&&(r.eid=s);const i=n._getFrameworks();return i.length&&(r.fw=i.join(",")),`${t}?${Nr(r).slice(1)}`}async function o_(n){const e=await Zg(n),t=et().gapi;return M(t,n,"internal-error"),e.open({where:document.body,url:i_(n),messageHandlersFilter:t.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:r_,dontclear:!0},r=>new Promise(async(s,i)=>{await r.restyle({setHideOnLeave:!1});const a=Ze(n,"network-request-failed"),u=et().setTimeout(()=>{i(a)},e_.get());function l(){et().clearTimeout(u),s(r)}r.ping(l).then(l,()=>{i(a)})}))}/** 1471 * @license 1472 * Copyright 2020 Google LLC. 1473 * 1474 * Licensed under the Apache License, Version 2.0 (the "License"); 1475 * you may not use this file except in compliance with the License. 1476 * You may obtain a copy of the License at 1477 * 1478 * http://www.apache.org/licenses/LICENSE-2.0 1479 * 1480 * Unless required by applicable law or agreed to in writing, software 1481 * distributed under the License is distributed on an "AS IS" BASIS, 1482 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1483 * See the License for the specific language governing permissions and 1484 * limitations under the License. 1485 */const a_={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"},c_=500,u_=600,l_="_blank",h_="http://localhost";class nu{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch{}}}function d_(n,e,t,r=c_,s=u_){const i=Math.max((window.screen.availHeight-s)/2,0).toString(),a=Math.max((window.screen.availWidth-r)/2,0).toString();let u="";const l={...a_,width:r.toString(),height:s.toString(),top:i,left:a},d=Ae().toLowerCase();t&&(u=Ml(d)?l_:t),Ol(d)&&(e=e||h_,l.scrollbars="yes");const f=Object.entries(l).reduce((_,[S,C])=>`${_}${S}=${C},`,"");if(Om(d)&&u!=="_self")return f_(e||"",u),new nu(null);const m=window.open(e||"",u,f);M(m,n,"popup-blocked");try{m.focus()}catch{}return new nu(m)}function f_(n,e){const t=document.createElement("a");t.href=n,t.target=e;const r=document.createEvent("MouseEvent");
1485r.initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,1,null),t.dispatchEvent(r)}/** 1486 * @license 1487 * Copyright 2021 Google LLC 1488 * 1489 * Licensed under the Apache License, Version 2.0 (the "License"); 1490 * you may not use this file except in compliance with the License. 1491 * You may obtain a copy of the License at 1492 * 1493 * http://www.apache.org/licenses/LICENSE-2.0 1494 * 1495 * Unless required by applicable law or agreed to in writing, software 1496 * distributed under the License is distributed on an "AS IS" BASIS, 1497 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1498 * See the License for the specific language governing permissions and 1499 * limitations under the License. 1500 */const p_="__/auth/handler",m_="emulator/auth/handler",g_=encodeURIComponent("fac");async function ru(n,e,t,r,s,i){M(n.config.authDomain,n,"auth-domain-config-required"),M(n.config.apiKey,n,"invalid-api-key");const a={apiKey:n.config.apiKey,appName:n.name,authType:t,redirectUrl:r,v:un,eventId:s};if(e instanceof Wl){e.setDefaultLanguage(n.languageCode),a.providerId=e.providerId||"",dp(e.getCustomParameters())||(a.customParameters=JSON.stringify(e.getCustomParameters()));for(const[f,m]of Object.entries({}))a[f]=m}if(e instanceof Or){const f=e.getScopes().filter(m=>m!=="");f.length>0&&(a.scopes=f.join(","))}n.tenantId&&(a.tid=n.tenantId);const u=a;for(const f of Object.keys(u))u[f]===void 0&&delete u[f];const l=await n._getAppCheckToken(),d=l?`#${g_}=${encodeURIComponent(l)}`:"";return`${__(n)}?${Nr(u).slice(1)}${d}`}function __({config:n}){return n.emulator?Do(n,m_):`https://${n.authDomain}/${p_}`}/** 1501 * @license 1502 * Copyright 2020 Google LLC 1503 * 1504 * Licensed under the Apache License, Version 2.0 (the "License"); 1505 * you may not use this file except in compliance with the License. 1506 * You may obtain a copy of the License at 1507 * 1508 * http://www.apache.org/licenses/LICENSE-2.0 1509 * 1510 * Unless required by applicable law or agreed to in writing, software 1511 * distributed under the License is distributed on an "AS IS" BASIS, 1512 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1513 * See the License for the specific language governing permissions and 1514 * limitations under the License. 1515 */const Wi="webStorageSupport";class y_{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=th,this._completeRedirectFn=$g,this._overrideRedirectResult=Fg}async _openPopup(e,t,r,s){var a;ft((a=this.eventManagers[e._key()])==null?void 0:a.manager,"_initialize() not called before _openPopup()");const i=await ru(e,t,r,Rs(),s);return d_(e,i,Bo())}async _openRedirect(e,t,r,s){await this._originValidation(e);const i=await ru(e,t,r,Rs(),s);return Ig(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):(ft(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 Hg(e);return t.register("authEvent",s=>(M(s==null?void 0:s.authEvent,e,"invalid-auth-event"),{status:r.onEvent(s.authEvent)?"ACK":"ERROR"}),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[e._key()]={manager:r},this.iframes[e._key()]=t,r}_isIframeWebStorageSupported(e,t){this.iframes[e._key()].send(Wi,{type:Wi},s=>{var a;const i=(a=s==null?void 0:s[0])==null?void 0:a[Wi];i!==void 0&&t(!!i),Be(e,"internal-error")},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){const t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=Qg(e)),this.originValidationPromises[t]}get _shouldInitProactively(){return ql()||Ll()||Oo()}}const E_=y_;var su="@firebase/auth",iu="1.12.0";/** 1516 * @license 1517 * Copyright 2020 Google LLC 1518 * 1519 * Licensed under the Apache License, Version 2.0 (the "License"); 1520 * you may not use this file except in compliance with the License. 1521 * You may obtain a copy of the License at 1522 * 1523 * http://www.apache.org/licenses/LICENSE-2.0 1524 * 1525 * Unless required by applicable law or agreed to in writing, softw
1525are 1526 * distributed under the License is distributed on an "AS IS" BASIS, 1527 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1528 * See the License for the specific language governing permissions and 1529 * limitations under the License. 1530 */class T_{constructor(e){this.auth=e,this.internalListeners=new Map}getUid(){var e;return this.assertAuthConfigured(),((e=this.auth.currentUser)==null?void 0:e.uid)||null}async getToken(e){return this.assertAuthConfigured(),await this.auth._initializationPromise,this.auth.currentUser?{accessToken:await this.auth.currentUser.getIdToken(e)}:null}addAuthTokenListener(e){if(this.assertAuthConfigured(),this.internalListeners.has(e))return;const t=this.auth.onIdTokenChanged(r=>{e((r==null?void 0:r.stsTokenManager.accessToken)||null)});this.internalListeners.set(e,t),this.updateProactiveRefresh()}removeAuthTokenListener(e){this.assertAuthConfigured();const t=this.internalListeners.get(e);t&&(this.internalListeners.delete(e),t(),this.updateProactiveRefresh())}assertAuthConfigured(){M(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}/** 1531 * @license 1532 * Copyright 2020 Google LLC 1533 * 1534 * Licensed under the Apache License, Version 2.0 (the "License"); 1535 * you may not use this file except in compliance with the License. 1536 * You may obtain a copy of the License at 1537 * 1538 * http://www.apache.org/licenses/LICENSE-2.0 1539 * 1540 * Unless required by applicable law or agreed to in writing, software 1541 * distributed under the License is distributed on an "AS IS" BASIS, 1542 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1543 * See the License for the specific language governing permissions and 1544 * limitations under the License. 1545 */function I_(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 w_(n){Vt(new ht("auth",(e,{options:t})=>{const r=e.getProvider("app").getImmediate(),s=e.getProvider("heartbeat"),i=e.getProvider("app-check-internal"),{apiKey:a,authDomain:u}=r.options;M(a&&!a.includes(":"),"invalid-api-key",{appName:r.name});const l={apiKey:a,authDomain:u,clientPlatform:n,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:$l(n)},d=new Bm(r,s,i,l);return Jm(d,t),d},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((e,t,r)=>{e.getProvider("auth-internal").initialize()})),Vt(new ht("auth-internal",e=>{const t=_t(e.getProvider("auth").getImmediate());return(r=>new T_(r))(t)},"PRIVATE").setInstantiationMode("EXPLICIT")),Ue(su,iu,I_(n)),Ue(su,iu,"esm2020")}/** 1546 * @license 1547 * Copyright 2021 Google LLC 1548 * 1549 * Licensed under the Apache License, Version 2.0 (the "License"); 1550 * you may not use this file except in compliance with the License. 1551 * You may obtain a copy of the License at 1552 * 1553 * http://www.apache.org/licenses/LICENSE-2.0 1554 * 1555 * Unless required by applicable law or agreed to in writing, software 1556 * distributed under the License is distributed on an "AS IS" BASIS, 1557 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1558 * See the License for the specific language governing permissions and 1559 * limitations under the License. 1560 */const v_=300,A_=wl("authIdTokenMaxAge")||v_;let ou=null;const R_=n=>async e=>{const t=e&&await e.getIdTokenResult(),r=t&&(new Date().getTime()-Date.parse(t.issuedAtTime))/1e3;if(r&&r>A_)return;const s=t==null?void 0:t.token;ou!==s&&(ou=s,await fetch(n,{method:s?"POST":"DELETE",headers:s?{Authorization:`Bearer ${s}`}:{}}))};function zw(n=Ks()){const e=Dr(n,"auth");if(e.isInitialized())return e.getImmediate();const t=Qm(n,{popupRedirectResolver:E_,persistence:[kg,yg,th]}),r=wl("authTokenSyncURL");if(r&&typeof isSecureContext=="boolean"&&isSecureContext){const i=new URL(r,location.origin);if(location.origin===i.origin){const a=R_(i.toString());mg(t,a,()=>a(t.currentUser)),pg(t,u=>a(u))}}const s=Tl("auth");return s&&Ym(t,`http://${s}`),t}function S_(){var n;return((n=document.getElementsByTagName("head"))==null?void 0:n[0])??document}qm({loadJS(n){return new Promise((e,t)=>
1560{const r=document.createElement("script");r.setAttribute("src",n),r.onload=e,r.onerror=s=>{const i=Ze("internal-error");i.customData=s,t(i)},r.type="text/javascript",r.charset="UTF-8",S_().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="});w_("Browser");var P_="firebase",b_="12.8.0";/** 1561 * @license 1562 * Copyright 2020 Google LLC 1563 * 1564 * Licensed under the Apache License, Version 2.0 (the "License"); 1565 * you may not use this file except in compliance with the License. 1566 * You may obtain a copy of the License at 1567 * 1568 * http://www.apache.org/licenses/LICENSE-2.0 1569 * 1570 * Unless required by applicable law or agreed to in writing, software 1571 * distributed under the License is distributed on an "AS IS" BASIS, 1572 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1573 * See the License for the specific language governing permissions and 1574 * limitations under the License. 1575 */Ue(P_,b_,"app");var au=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/** @license 1576Copyright The Closure Library Authors. 1577SPDX-License-Identifier: Apache-2.0 1578*/var Nt,ch;(function(){var n;/** @license 1579 1580 Copyright The Closure Library Authors. 1581 SPDX-License-Identifier: Apache-2.0 1582*/function e(I,g){function E(){}E.prototype=g.prototype,I.F=g.prototype,I.prototype=new E,I.prototype.constructor=I,I.D=function(w,T,A){for(var y=Array(arguments.length-2),Ce=2;Ce<arguments.length;Ce++)y[Ce-2]=arguments[Ce];return g.prototype[T].apply(w,y)}}function t(){this.blockSize=-1}function r(){this.blockSize=-1,this.blockSize=64,this.g=Array(4),this.C=Array(this.blockSize),this.o=this.h=0,this.u()}e(r,t),r.prototype.u=function(){this.g[0]=1732584193,this.g[1]=4023233417,this.g[2]=2562383102,this.g[3]=271733878,this.o=this.h=0};function s(I,g,E){E||(E=0);const w=Array(16);if(typeof g=="string")for(var T=0;T<16;++T)w[T]=g.charCodeAt(E++)|g.charCodeAt(E++)<<8|g.charCodeAt(E++)<<16|g.charCodeAt(E++)<<24;else for(T=0;T<16;++T)w[T]=g[E++]|g[E++]<<8|g[E++]<<16|g[E++]<<24;g=I.g[0],E=I.g[1],T=I.g[2];let A=I.g[3],y;y=g+(A^E&(T^A))+w[0]+3614090360&4294967295,g=E+(y<<7&4294967295|y>>>25),y=A+(T^g&(E^T))+w[1]+3905402710&4294967295,A=g+(y<<12&4294967295|y>>>20),y=T+(E^A&(g^E))+w[2]+606105819&4294967295,T=A+(y<<17&4294967295|y>>>15),y=E+(g^T&(A^g))+w[3]+3250441966&4294967295,E=T+(y<<22&4294967295|y>>>10),y=g+(A^E&(T^A))+w[4]+4118548399&4294967295,g=E+(y<<7&4294967295|y>>>25),y=A+(T^g&(E^T))+w[5]+1200080426&4294967295,A=g+(y<<12&4294967295|y>>>20),y=T+(E^A&(g^E))+w[6]+2821735955&4294967295,T=A+(y<<17&4294967295|y>>>15),y=E+(g^T&(A^g))+w[7]+4249261313&4294967295,E=T+(y<<22&4294967295|y>>>10),y=g+(A^E&(T^A))+w[8]+1770035416&4294967295,g=E+(y<<7&4294967295|y>>>25),y=A+(T^g&(E^T))+w[9]+2336552879&4294967295,A=g+(y<<12&4294967295|y>>>20),y=T+(E^A&(g^E))+w[10]+4294925233&4294967295,T=A+(y<<17&4294967295|y>>>15),y=E+(g^T&(A^g))+w[11]+2304563134&4294967295,E=T+(y<<22&4294967295|y>>>10),y=g+(A^E&(T^A))+w[12]+1804603682&4294967295,g=E+(y<<7&4294967295|y>>>25),y=A+(T^g&(E^T))+w[13]+4254626195&4294967295,A=g+(y<<12&4294967295|y>>>20),y=T+(E^A&(g^E))+w[14]+2792965006&4294967295,T=A+(y<<17&4294967295|y>>>15),y=E+(g^T&(A^g))+w[15]+1236535329&4294967295,E=T+(y<<22&4294967295|y>>>10),y=g+(T^A&(E^T))+w[1]+4129170786&4294967295,g=E+(y<<5&4294967295|y>>>27),y=A+(E^T&(g^E))+w[6]+3225465664&4294967295,A=g+(y<<9&4294967295|y>>>23),y=T+(g^E&(A^g))+w[11]+643717713&4294967295,T=A+(y<<14&4294967295|y>>>18),y=E+(A^g&(T^A))+w[0]+3921069994&4294967295,E=T+(y<<20&4294967295|y>>>12),y=g+(T^A&(E^T))+w[5]+3593408605&4294967295,g=E+(y<<5&4294967295|y>>>27),y=A+(E^T&(g^E))+w[10]+38016083&4294967295,A=g+(y<<9&4294967295|y>>>23),y=T+(g^E&(A^g))+w[15]+3634488961&4294967295,T=A+(y<<14&4294967295|y>>>18),y=E+(A^g&(T^A))+w[4]+3889429448&4294967295,E=T+(y<<20&4294967295|y>>>12),y=g+(T^A&(E^T))+w[9]+568446438&4294967295,g=E+(y<<5&4294967295|y>>>27),y=A+(E^T&(g^E))+w[14]+3275163606&4294967295,A=g+(y<<9&4294967295|y>>>23),y=T+(g^E&(A^g))+w[3]+4107603335&4294967295,T=A+(y<<14&4294967295|y>>>18),y=E+(A^g&(T^A))+w[8]+1163531501&4294967295,E=T+(y<<20&4294967295|y>>>12),y=g+(T^A&(E^T))+w[13]+2850285829&4294967295,g=E+(y<<5&4294967295|y>>>27),y=A+(E^T&(g^E))+w[2]+4243563512&4294967295,A=g+(y<<9&4294967295|y>>>23),y=T+(g^E&(A^g))+w[7]+1735328473&4294967295,T=A+(y<<14&4294967295|y>>>18),y=E+(A^g&(T^A))+w[12]+2368359562&4294967295,E=T+(y<<20&4294967295|y>>>12),y=g+(E^T^A)+w[5]+4294588738&4294967295,g=E+(y<<4&4294967295|y>>>28),y=A+(g^E^T)+w[8]+2272392833&4294967295,A=g+(y<<11&4294967295|y>>>21),y=T+(A^g^E)+w[11]+1839030562&4294967295,T=A+(y<<16&4294967295|y>>>16),y=E+(T^A^g)+w[14]+4259657740&4294967295,E=T+(y<<23&4294967295|y>>>9),y=g+(E^T^A)+w[1]+2763975236&4294967295,g=E+(y<<4&4294967295|y>>>28),y=A+(g^E^T)+w[4]+1272893353&4294967295,A=g+(y<<11&4294967295|y>>>21),y=T+(A^g^E)+w[7]+4139469664&4294967295,T=A+(y<<16&4294967295|y>>>16),y=E+(T^A^g)+w[10]+3200236656&4294967295,E=T+(y<<23&4294967295|y>>>9),y=g+(E^T^A)+w[13]+681279174&4294967295,g=E+(y<<4&4294967295|y>>>28),y=A+(g^E^T)+w[0]+3936430074&4294967295,A=g+(y<<11&4294967295|y>>>21),y=T+(A^g^E)+w[3]+3572445317&4294967295,T=A+(y<<16&4294967295|y>>>16),y=E+(T^A^g)+w[6]+76029189&4294967295,E=T+(y<<23&4294967295|y>>>9),y=g+(E^T^A)+w[9]+3654602809&4294967295,g=E+(y<<4&4294967295|y>>>28),y=A+(g^E^T)+w[12]+3873151461&4294967295,A=g+(y<<11&4294967295|y>>>21),y=T+(A^g^E)+w[15]+530742520&4294967295,T=A+(y<<16&4294967295|y>>>16),y=E+(T^A^g)+w[2]+3299628645&4294967295,E=T+(y<<23&4294967295|y>>>9),y=g+(T^(E|~A))+w[0]+4096336452&4294967295,g=E+(y<<6&4294967295|y>>>26),y=A+(E^(g|~T))+w[7]+1126891415&4294967295,A=g+(y<<10&4294967295|y>>>22),y=T+(g^(A|~E))+w[14]+2878612391&4294967295,T=A+(y<<15&4294967295|y>>>
158217),y=E+(A^(T|~g))+w[5]+4237533241&4294967295,E=T+(y<<21&4294967295|y>>>11),y=g+(T^(E|~A))+w[12]+1700485571&4294967295,g=E+(y<<6&4294967295|y>>>26),y=A+(E^(g|~T))+w[3]+2399980690&4294967295,A=g+(y<<10&4294967295|y>>>22),y=T+(g^(A|~E))+w[10]+4293915773&4294967295,T=A+(y<<15&4294967295|y>>>17),y=E+(A^(T|~g))+w[1]+2240044497&4294967295,E=T+(y<<21&4294967295|y>>>11),y=g+(T^(E|~A))+w[8]+1873313359&4294967295,g=E+(y<<6&4294967295|y>>>26),y=A+(E^(g|~T))+w[15]+4264355552&4294967295,A=g+(y<<10&4294967295|y>>>22),y=T+(g^(A|~E))+w[6]+2734768916&4294967295,T=A+(y<<15&4294967295|y>>>17),y=E+(A^(T|~g))+w[13]+1309151649&4294967295,E=T+(y<<21&4294967295|y>>>11),y=g+(T^(E|~A))+w[4]+4149444226&4294967295,g=E+(y<<6&4294967295|y>>>26),y=A+(E^(g|~T))+w[11]+3174756917&4294967295,A=g+(y<<10&4294967295|y>>>22),y=T+(g^(A|~E))+w[2]+718787259&4294967295,T=A+(y<<15&4294967295|y>>>17),y=E+(A^(T|~g))+w[9]+3951481745&4294967295,I.g[0]=I.g[0]+g&4294967295,I.g[1]=I.g[1]+(T+(y<<21&4294967295|y>>>11))&4294967295,I.g[2]=I.g[2]+T&4294967295,I.g[3]=I.g[3]+A&4294967295}r.prototype.v=function(I,g){g===void 0&&(g=I.length);const E=g-this.blockSize,w=this.C;let T=this.h,A=0;for(;A<g;){if(T==0)for(;A<=E;)s(this,I,A),A+=this.blockSize;if(typeof I=="string"){for(;A<g;)if(w[T++]=I.charCodeAt(A++),T==this.blockSize){s(this,w),T=0;break}}else for(;A<g;)if(w[T++]=I[A++],T==this.blockSize){s(this,w),T=0;break}}this.h=T,this.o+=g},r.prototype.A=function(){var I=Array((this.h<56?this.blockSize:this.blockSize*2)-this.h);I[0]=128;for(var g=1;g<I.length-8;++g)I[g]=0;g=this.o*8;for(var E=I.length-8;E<I.length;++E)I[E]=g&255,g/=256;for(this.v(I),I=Array(16),g=0,E=0;E<4;++E)for(let w=0;w<32;w+=8)I[g++]=this.g[E]>>>w&255;return I};function i(I,g){var E=u;return Object.prototype.hasOwnProperty.call(E,I)?E[I]:E[I]=g(I)}function a(I,g){this.h=g;const E=[];let w=!0;for(let T=I.length-1;T>=0;T--){const A=I[T]|0;w&&A==g||(E[T]=A,w=!1)}this.g=E}var u={};function l(I){return-128<=I&&I<128?i(I,function(g){return new a([g|0],g<0?-1:0)}):new a([I|0],I<0?-1:0)}function d(I){if(isNaN(I)||!isFinite(I))return m;if(I<0)return k(d(-I));const g=[];let E=1;for(let w=0;I>=E;w++)g[w]=I/E|0,E*=4294967296;return new a(g,0)}function f(I,g){if(I.length==0)throw Error("number format error: empty string");if(g=g||10,g<2||36<g)throw Error("radix out of range: "+g);if(I.charAt(0)=="-")return k(f(I.substring(1),g));if(I.indexOf("-")>=0)throw Error('number format error: interior "-" character');const E=d(Math.pow(g,8));let w=m;for(let A=0;A<I.length;A+=8){var T=Math.min(8,I.length-A);const y=parseInt(I.substring(A,A+T),g);T<8?(T=d(Math.pow(g,T)),w=w.j(T).add(d(y))):(w=w.j(E),w=w.add(d(y)))}return w}var m=l(0),_=l(1),S=l(16777216);n=a.prototype,n.m=function(){if(D(this))return-k(this).m();let I=0,g=1;for(let E=0;E<this.g.length;E++){const w=this.i(E);I+=(w>=0?w:4294967296+w)*g,g*=4294967296}return I},n.toString=function(I){if(I=I||10,I<2||36<I)throw Error("radix out of range: "+I);if(C(this))return"0";if(D(this))return"-"+k(this).toString(I);const g=d(Math.pow(I,6));var E=this;let w="";for(;;){const T=Q(E,g).g;E=q(E,T.j(g));let A=((E.g.length>0?E.g[0]:E.h)>>>0).toString(I);if(E=T,C(E))return A+w;for(;A.length<6;)A="0"+A;w=A+w}},n.i=function(I){return I<0?0:I<this.g.length?this.g[I]:this.h};function C(I){if(I.h!=0)return!1;for(let g=0;g<I.g.length;g++)if(I.g[g]!=0)return!1;return!0}function D(I){return I.h==-1}n.l=function(I){return I=q(this,I),D(I)?-1:C(I)?0:1};function k(I){const g=I.g.length,E=[];for(let w=0;w<g;w++)E[w]=~I.g[w];return new a(E,~I.h).add(_)}n.abs=function(){return D(this)?k(this):this},n.add=function(I){const g=Math.max(this.g.length,I.g.length),E=[];let w=0;for(let T=0;T<=g;T++){let A=w+(this.i(T)&65535)+(I.i(T)&65535),y=(A>>>16)+(this.i(T)>>>16)+(I.i(T)>>>16);w=y>>>16,A&=65535,y&=65535,E[T]=y<<16|A}return new a(E,E[E.length-1]&-2147483648?-1:0)};function q(I,g){return I.add(k(g))}n.j=function(I){if(C(this)||C(I))return m;if(D(this))return D(I)?k(this).j(k(I)):k(k(this).j(I));if(D(I))return k(this.j(k(I)));if(this.l(S)<0&&I.l(S)<0)return d(this.m()*I.m());const g=this.g.length+I.g.length,E=[];for(var w=0;w<2*g;w++)E[w]=0;for(w=0;w<this.g.length;w++)for(let T=0;T<I.g.length;T++){const A=this.i(w)>>>16,y=this.i(w)&65535,Ce=I.i(T)>>>16,zt=I.i(T)&65535;E[2*w+2*T]+=y*zt,F(E,2*w+2*T),E[2*w+2*T+1]+=A*zt,F(E,2*w+2*T+1),E[2*w+2*T+1]+=y*Ce,F(E,2*w+2*T+1),E[2*w+2*T+2]+=A*Ce,F(E,2*w+2*T+2)}for(I=0;I<g;I++)E[I]=E[2*I+1]<<16|E[2*I];for(I=g;I<2*g;I++)E[I]=0;return new a(E,0)};function F(I,g){for(;(I[g]&65535)!=I[g];)I[g+1]+=I[g]>>>16,I[g]&=65535,g++}function $(I,g){this.g=I,this.h=g}function Q(I,g){if(C(g))throw Error("division by zero");if(C(I))return new $(m,m);if(D(I))return g=Q(k(I),g),new $(k(g.g),k(g.h));if(D(g))return g=Q(I,k(g)),new $(k(g.g),g.h);if(I.g.length>
158230){if(D(I)||D(g))throw Error("slowDivide_ only works with positive integers.");for(var E=_,w=g;w.l(I)<=0;)E=ce(E),w=ce(w);var T=ne(E,1),A=ne(w,1);for(w=ne(w,2),E=ne(E,2);!C(w);){var y=A.add(w);y.l(I)<=0&&(T=T.add(E),A=y),w=ne(w,1),E=ne(E,1)}return g=q(I,T.j(g)),new $(T,g)}for(T=m;I.l(g)>=0;){for(E=Math.max(1,Math.floor(I.m()/g.m())),w=Math.ceil(Math.log(E)/Math.LN2),w=w<=48?1:Math.pow(2,w-48),A=d(E),y=A.j(g);D(y)||y.l(I)>0;)E-=w,A=d(E),y=A.j(g);C(A)&&(A=_),T=T.add(A),I=q(I,y)}return new $(T,I)}n.B=function(I){return Q(this,I).h},n.and=function(I){const g=Math.max(this.g.length,I.g.length),E=[];for(let w=0;w<g;w++)E[w]=this.i(w)&I.i(w);return new a(E,this.h&I.h)},n.or=function(I){const g=Math.max(this.g.length,I.g.length),E=[];for(let w=0;w<g;w++)E[w]=this.i(w)|I.i(w);return new a(E,this.h|I.h)},n.xor=function(I){const g=Math.max(this.g.length,I.g.length),E=[];for(let w=0;w<g;w++)E[w]=this.i(w)^I.i(w);return new a(E,this.h^I.h)};function ce(I){const g=I.g.length+1,E=[];for(let w=0;w<g;w++)E[w]=I.i(w)<<1|I.i(w-1)>>>31;return new a(E,I.h)}function ne(I,g){const E=g>>5;g%=32;const w=I.g.length-E,T=[];for(let A=0;A<w;A++)T[A]=g>0?I.i(A+E)>>>g|I.i(A+E+1)<<32-g:I.i(A+E);return new a(T,I.h)}r.prototype.digest=r.prototype.A,r.prototype.reset=r.prototype.u,r.prototype.update=r.prototype.v,ch=r,a.prototype.add=a.prototype.add,a.prototype.multiply=a.prototype.j,a.prototype.modulo=a.prototype.B,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,Nt=a}).apply(typeof au<"u"?au:typeof self<"u"?self:typeof window<"u"?window:{});var is=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/** @license 1583Copyright The Closure Library Authors. 1584SPDX-License-Identifier: Apache-2.0 1585*/var uh,ur,lh,gs,co,hh,dh,fh;(function(){var n,e=Object.defineProperty;function t(o){o=[typeof globalThis=="object"&&globalThis,o,typeof window=="object"&&window,typeof self=="object"&&self,typeof is=="object"&&is];for(var c=0;c<o.length;++c){var h=o[c];if(h&&h.Math==Math)return h}throw Error("Cannot find global object")}var r=t(this);function s(o,c){if(c)e:{var h=r;o=o.split(".");for(var p=0;p<o.length-1;p++){var v=o[p];if(!(v in h))break e;h=h[v]}o=o[o.length-1],p=h[o],c=c(p),c!=p&&c!=null&&e(h,o,{configurable:!0,writable:!0,value:c})}}s("Symbol.dispose",function(o){return o||Symbol("Symbol.dispose")}),s("Array.prototype.values",function(o){return o||function(){return this[Symbol.iterator]()}}),s("Object.entries",function(o){return o||function(c){var h=[],p;for(p in c)Object.prototype.hasOwnProperty.call(c,p)&&h.push([p,c[p]]);return h}});/** @license 1586 1587 Copyright The Closure Library Authors. 1588 SPDX-License-Identifier: Apache-2.0 1589*/var i=i||{},a=this||self;function u(o){var c=typeof o;return c=="object"&&o!=null||c=="function"}function l(o,c,h){return o.call.apply(o.bind,arguments)}function d(o,c,h){return d=l,d.apply(null,arguments)}function f(o,c){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 m(o,c){function h(){}h.prototype=c.prototype,o.Z=c.prototype,o.prototype=new h,o.prototype.constructor=o,o.Ob=function(p,v,R){for(var N=Array(arguments.length-2),j=2;j<arguments.length;j++)N[j-2]=arguments[j];return c.prototype[v].apply(p,N)}}var _=typeof AsyncContext<"u"&&typeof AsyncContext.Snapshot=="function"?o=>o&&AsyncContext.Snapshot.wrap(o):o=>o;function S(o){const c=o.length;if(c>0){const h=Array(c);for(let p=0;p<c;p++)h[p]=o[p];return h}return[]}function C(o,c){for(let p=1;p<arguments.length;p++){const v=arguments[p];var h=typeof v;if(h=h!="object"?h:v?Array.isArray(v)?"array":h:"null",h=="array"||h=="object"&&typeof v.length=="number"){h=o.length||0;const R=v.length||0;o.length=h+R;for(let N=0;N<R;N++)o[h+N]=v[N]}else o.push(v)}}class D{constructor(c,h){this.i=c,this.j=h,this.h=0,this.g=null}get(){let c;return this.h>0?(this.h--,c=this.g,this.g=c.next,c.next=null):c=this.i(),c}}function k(o){a.setTimeout(()=>{throw o},0)}function q(){var o=I;let c=null;return o.g&&(c=o.g,o.g=o.g.next,o.g||(o.h=null),c.next=null),c}class F{constructor(){this.h=this.g=null}add(c,h){const p=$.get();p.set(c,h),this.h?this.h.next=p:this.g=p,this.h=p}}var $=new D(()=>new Q,o=>o.reset());class Q{constructor(){this.next=this.g=this.h=null}set(c,h){this.h=c,this.g=h,this.next=null}reset(){this.next=this.g=this.h=null}}let ce,ne=!1,I=new F,g=()=>{const o=Promise.resolve(void 0);ce=()=>{o.then(E)}};function E(){for(var o;o=q();){try{o.h.call(o.g)}catch(h){k(h)}var c=$;c.j(o),c.h<100&&(c.h++,o.next=c.g,c.g=o)}ne=!1}function w(){this.u=this.u,this.C=this.C}w.prototype.u=!1,w.prototype.dispose=function(){this.u||(this.u=!0,this.N())},w.prototype[Symbol.dispose]=function(){this.dispose()},w.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()};function T(o,c){this.type=o,this.g=this.target=c,this.defaultPrevented=!1}T.prototype.h=function(){this.defaultPrevented=!0};var A=(function(){if(!a.addEventListener||!Object.defineProperty)return!1;var o=!1,c=Object.defineProperty({},"passive",{get:function(){o=!0}});try{const h=()=>{};a.addEventListener("test",h,c),a.removeEventListener("test",h,c)}catch{}return o}
1589)();function y(o){return/^[\s\xa0]*$/.test(o)}function Ce(o,c){T.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&&this.init(o,c)}m(Ce,T),Ce.prototype.init=function(o,c){const h=this.type=o.type,p=o.changedTouches&&o.changedTouches.length?o.changedTouches[0]:null;this.target=o.target||o.srcElement,this.g=c,c=o.relatedTarget,c||(h=="mouseover"?c=o.fromElement:h=="mouseout"&&(c=o.toElement)),this.relatedTarget=c,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=o.pointerType,this.state=o.state,this.i=o,o.defaultPrevented&&Ce.Z.h.call(this)},Ce.prototype.h=function(){Ce.Z.h.call(this);const o=this.i;o.preventDefault?o.preventDefault():o.returnValue=!1};var zt="closure_listenable_"+(Math.random()*1e6|0),lf=0;function hf(o,c,h,p,v){this.listener=o,this.proxy=null,this.src=c,this.type=h,this.capture=!!p,this.ha=v,this.key=++lf,this.da=this.fa=!1}function jr(o){o.da=!0,o.listener=null,o.proxy=null,o.src=null,o.ha=null}function Hr(o,c,h){for(const p in o)c.call(h,o[p],p,o)}function df(o,c){for(const h in o)c.call(void 0,o[h],h,o)}function Va(o){const c={};for(const h in o)c[h]=o[h];return c}const Oa="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function La(o,c){let h,p;for(let v=1;v<arguments.length;v++){p=arguments[v];for(h in p)o[h]=p[h];for(let R=0;R<Oa.length;R++)h=Oa[R],Object.prototype.hasOwnProperty.call(p,h)&&(o[h]=p[h])}}function zr(o){this.src=o,this.g={},this.h=0}zr.prototype.add=function(o,c,h,p,v){const R=o.toString();o=this.g[R],o||(o=this.g[R]=[],this.h++);const N=Ii(o,c,p,v);return N>-1?(c=o[N],h||(c.fa=!1)):(c=new hf(c,this.src,R,!!p,v),c.fa=h,o.push(c)),c};function Ti(o,c){const h=c.type;if(h in o.g){var p=o.g[h],v=Array.prototype.indexOf.call(p,c,void 0),R;(R=v>=0)&&Array.prototype.splice.call(p,v,1),R&&(jr(c),o.g[h].length==0&&(delete o.g[h],o.h--))}}function Ii(o,c,h,p){for(let v=0;v<o.length;++v){const R=o[v];if(!R.da&&R.listener==c&&R.capture==!!h&&R.ha==p)return v}return-1}var wi="closure_lm_"+(Math.random()*1e6|0),vi={};function Ma(o,c,h,p,v){if(Array.isArray(c)){for(let R=0;R<c.length;R++)Ma(o,c[R],h,p,v);return null}return h=Fa(h),o&&o[zt]?o.J(c,h,u(p)?!!p.capture:!1,v):ff(o,c,h,!1,p,v)}function ff(o,c,h,p,v,R){if(!c)throw Error("Invalid event type");const N=u(v)?!!v.capture:!!v;let j=Ri(o);if(j||(o[wi]=j=new zr(o)),h=j.add(c,h,p,N,R),h.proxy)return h;if(p=pf(),h.proxy=p,p.src=o,p.listener=h,o.addEventListener)A||(v=N),v===void 0&&(v=!1),o.addEventListener(c.toString(),p,v);else if(o.attachEvent)o.attachEvent(Ua(c.toString()),p);else if(o.addListener&&o.removeListener)o.addListener(p);else throw Error("addEventListener and attachEvent are unavailable.");return h}function pf(){function o(h){return c.call(o.src,o.listener,h)}const c=mf;return o}function xa(o,c,h,p,v){if(Array.isArray(c))for(var R=0;R<c.length;R++)xa(o,c[R],h,p,v);else p=u(p)?!!p.capture:!!p,h=Fa(h),o&&o[zt]?(o=o.i,R=String(c).toString(),R in o.g&&(c=o.g[R],h=Ii(c,h,p,v),h>-1&&(jr(c[h]),Array.prototype.splice.call(c,h,1),c.length==0&&(delete o.g[R],o.h--)))):o&&(o=Ri(o))&&(c=o.g[c.toString()],o=-1,c&&(o=Ii(c,h,p,v)),(h=o>-1?c[o]:null)&&Ai(h))}function Ai(o){if(typeof o!="number"&&o&&!o.da){var c=o.src;if(c&&c[zt])Ti(c.i,o);else{var h=o.type,p=o.proxy;c.removeEventListener?c.removeEventListener(h,p,o.capture):c.detachEvent?c.detachEvent(Ua(h),p):c.addListener&&c.removeListener&&c.removeListener(p),(h=Ri(c))?(Ti(h,o),h.h==0&&(h.src=null,c[wi]=null)):jr(o)}}}function Ua(o){return o in vi?vi[o]:vi[o]="on"+o}function mf(o,c){if(o.da)o=!0;else{c=new Ce(c,this);const h=o.listener,p=o.ha||o.src;o.fa&&Ai(o),o=h.call(p,c)}return o}function Ri(o){return o=o[wi],o instanceof zr?o:null}var Si="__closure_events_fn_"+(Math.random()*1e9>>>0);function Fa(o){return typeof o=="function"?o:(o[Si]||(o[Si]=function(c){return o.handleEvent(c)}),o[Si])}function Ee(){w.call(this),this.i=new zr(this),this.M=this,this.G=null}m(Ee,w),Ee.prototype[zt]=!0,Ee.prototype.removeEventListener=function(o,c,h,p){xa(this,o,c,h,p)};function Re(o,c){var h,p=o.G;if(p)for(h=[];p;p=p.G)h.push(p);if(o=o.M,p=c.type||c,typeof c=="string")c=new T(c,o);else if(c instanceof T)c.target=c.target||o;else{var v=c;c=new T(p,o),La(c,v)}v=!0;let R,N;if(h)for(N=h.length-1;N>=0;N--)R=c.g=h[N],v=Gr(R,p,!0,c)&&v;if(R=c.g=o,v=Gr(R,p,!0,c)&&v,v=Gr(R,p,!1,c)&&v,h)for(N=0;N<h.length;N++)R=c.g=h[N],v=Gr(R,p,!1,c)&&v}Ee.prototype.N=function(){if(Ee.Z.N.call(this),this.i){var o=this.i;for(const c in o.g){const h=o.g[c];for(let p=0;p<h.length;p++)jr(h[p]);delete o.g[c],o.h--}}this.G=null},Ee.prototype.J=function(o,c,h,p){return this.i.add(String(o),c,!1,h,p)},Ee.prototype.K=function(o,c,h,p){return this.i.add(String(o),c,!0,h,p)};function Gr(o,c,h,p){if(c=o.i.g[String(c)],!c)return!0;c=c.concat();let v=!0;for(let R=0;R<c.length;++R){const N=c[R];if(N&&!N.da&&N.capture==h){const j=N.listener,de=N.ha||N.src;
1589N.fa&&Ti(o.i,N),v=j.call(de,p)!==!1&&v}}return v&&!p.defaultPrevented}function gf(o,c){if(typeof o!="function")if(o&&typeof o.handleEvent=="function")o=d(o.handleEvent,o);else throw Error("Invalid listener argument");return Number(c)>2147483647?-1:a.setTimeout(o,c||0)}function Ba(o){o.g=gf(()=>{o.g=null,o.i&&(o.i=!1,Ba(o))},o.l);const c=o.h;o.h=null,o.m.apply(null,c)}class _f extends w{constructor(c,h){super(),this.m=c,this.l=h,this.h=null,this.i=!1,this.g=null}j(c){this.h=arguments,this.g?this.i=!0:Ba(this)}N(){super.N(),this.g&&(a.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function jn(o){w.call(this),this.h=o,this.g={}}m(jn,w);var qa=[];function $a(o){Hr(o.g,function(c,h){this.g.hasOwnProperty(h)&&Ai(c)},o),o.g={}}jn.prototype.N=function(){jn.Z.N.call(this),$a(this)},jn.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var Pi=a.JSON.stringify,yf=a.JSON.parse,Ef=class{stringify(o){return a.JSON.stringify(o,void 0)}parse(o){return a.JSON.parse(o,void 0)}};function ja(){}function Ha(){}var Hn={OPEN:"a",hb:"b",ERROR:"c",tb:"d"};function bi(){T.call(this,"d")}m(bi,T);function Ci(){T.call(this,"c")}m(Ci,T);var Gt={},za=null;function Wr(){return za=za||new Ee}Gt.Ia="serverreachability";function Ga(o){T.call(this,Gt.Ia,o)}m(Ga,T);function zn(o){const c=Wr();Re(c,new Ga(c))}Gt.STAT_EVENT="statevent";function Wa(o,c){T.call(this,Gt.STAT_EVENT,o),this.stat=c}m(Wa,T);function Se(o){const c=Wr();Re(c,new Wa(c,o))}Gt.Ja="timingevent";function Ka(o,c){T.call(this,Gt.Ja,o),this.size=c}m(Ka,T);function Gn(o,c){if(typeof o!="function")throw Error("Fn must not be null and must be a function");return a.setTimeout(function(){o()},c)}function Wn(){this.g=!0}Wn.prototype.ua=function(){this.g=!1};function Tf(o,c,h,p,v,R){o.info(function(){if(o.g)if(R){var N="",j=R.split("&");for(let Y=0;Y<j.length;Y++){var de=j[Y].split("=");if(de.length>1){const pe=de[0];de=de[1];const Qe=pe.split("_");N=Qe.length>=2&&Qe[1]=="type"?N+(pe+"="+de+"&"):N+(pe+"=redacted&")}}}else N=null;else N=R;return"XMLHTTP REQ ("+p+") [attempt "+v+"]: "+c+` 1590`+h+` 1591`+N})}function If(o,c,h,p,v,R,N){o.info(function(){return"XMLHTTP RESP ("+p+") [ attempt "+v+"]: "+c+` 1592`+h+` 1593`+R+" "+N})}function pn(o,c,h,p){o.info(function(){return"XMLHTTP TEXT ("+c+"): "+vf(o,h)+(p?" "+p:"")})}function wf(o,c){o.info(function(){return"TIMEOUT: "+c})}Wn.prototype.info=function(){};function vf(o,c){if(!o.g)return c;if(!c)return null;try{const R=JSON.parse(c);if(R){for(o=0;o<R.length;o++)if(Array.isArray(R[o])){var h=R[o];if(!(h.length<2)){var p=h[1];if(Array.isArray(p)&&!(p.length<1)){var v=p[0];if(v!="noop"&&v!="stop"&&v!="close")for(let N=1;N<p.length;N++)p[N]=""}}}}return Pi(R)}catch{return c}}var Kr={NO_ERROR:0,cb:1,qb:2,pb:3,kb:4,ob:5,rb:6,Ga:7,TIMEOUT:8,ub:9},Qa={ib:"complete",Fb:"success",ERROR:"error",Ga:"abort",xb:"ready",yb:"readystatechange",TIMEOUT:"timeout",sb:"incrementaldata",wb:"progress",lb:"downloadprogress",Nb:"uploadprogress"},Ja;function ki(){}m(ki,ja),ki.prototype.g=function(){return new XMLHttpRequest},Ja=new ki;function Kn(o){return encodeURIComponent(String(o))}function Af(o){var c=1;o=o.split(":");const h=[];for(;c>0&&o.length;)h.push(o.shift()),c--;return o.length&&h.push(o.join(":")),h}function yt(o,c,h,p){this.j=o,this.i=c,this.l=h,this.S=p||1,this.V=new jn(this),this.H=45e3,this.J=null,this.o=!1,this.u=this.B=this.A=this.M=this.F=this.T=this.D=null,this.G=[],this.g=null,this.C=0,this.m=this.v=null,this.X=-1,this.K=!1,this.P=0,this.O=null,this.W=this.L=this.U=this.R=!1,this.h=new Ya}function Ya(){this.i=null,this.g="",this.h=!1}var Xa={},Ni={};function Di(o,c,h){o.M=1,o.A=Jr(Ke(c)),o.u=h,o.R=!0,Za(o,null)}function Za(o,c){o.F=Date.now(),Qr(o),o.B=Ke(o.A);var h=o.B,p=o.S;Array.isArray(p)||(p=[String(p)]),dc(h.i,"t",p),o.C=0,h=o.j.L,o.h=new Ya,o.g=kc(o.j,h?c:null,!o.u),o.P>0&&(o.O=new _f(d(o.Y,o,o.g),o.P)),c=o.V,h=o.g,p=o.ba;var v="readystatechange";Array.isArray(v)||(v&&(qa[0]=v.toString()),v=qa);for(let R=0;R<v.length;R++){const N=Ma(h,v[R],p||c.handleEvent,!1,c.h||c);if(!N)break;c.g[N.key]=N}c=o.J?Va(o.J):{},o.u?(o.v||(o.v="POST"),c["Content-Type"]="application/x-www-form-urlencoded",o.g.ea(o.B,o.v,o.u,c)):(o.v="GET",o.g.ea(o.B,o.v,null,c)),zn(),Tf(o.i,o.v,o.B,o.l,o.S,o.u)}yt.prototype.ba=function(o){o=o.target;const c=this.O;c&&It(o)==3?c.j():this.Y(o)}
1593,yt.prototype.Y=function(o){try{if(o==this.g)e:{const j=It(this.g),de=this.g.ya(),Y=this.g.ca();if(!(j<3)&&(j!=3||this.g&&(this.h.h||this.g.la()||Ec(this.g)))){this.K||j!=4||de==7||(de==8||Y<=0?zn(3):zn(2)),Vi(this);var c=this.g.ca();this.X=c;var h=Rf(this);if(this.o=c==200,If(this.i,this.v,this.B,this.l,this.S,j,c),this.o){if(this.U&&!this.L){t:{if(this.g){var p,v=this.g;if((p=v.g?v.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!y(p)){var R=p;break t}}R=null}if(o=R)pn(this.i,this.l,o,"Initial handshake response via X-HTTP-Initial-Response"),this.L=!0,Oi(this,o);else{this.o=!1,this.m=3,Se(12),Wt(this),Qn(this);break e}}if(this.R){o=!0;let pe;for(;!this.K&&this.C<h.length;)if(pe=Sf(this,h),pe==Ni){j==4&&(this.m=4,Se(14),o=!1),pn(this.i,this.l,null,"[Incomplete Response]");break}else if(pe==Xa){this.m=4,Se(15),pn(this.i,this.l,h,"[Invalid Chunk]"),o=!1;break}else pn(this.i,this.l,pe,null),Oi(this,pe);if(ec(this)&&this.C!=0&&(this.h.g=this.h.g.slice(this.C),this.C=0),j!=4||h.length!=0||this.h.h||(this.m=1,Se(16),o=!1),this.o=this.o&&o,!o)pn(this.i,this.l,h,"[Invalid Chunked Response]"),Wt(this),Qn(this);else if(h.length>0&&!this.W){this.W=!0;var N=this.j;N.g==this&&N.aa&&!N.P&&(N.j.info("Great, no buffering proxy detected. Bytes received: "+h.length),$i(N),N.P=!0,Se(11))}}else pn(this.i,this.l,h,null),Oi(this,h);j==4&&Wt(this),this.o&&!this.K&&(j==4?Sc(this.j,this):(this.o=!1,Qr(this)))}else Bf(this.g),c==400&&h.indexOf("Unknown SID")>0?(this.m=3,Se(12)):(this.m=0,Se(13)),Wt(this),Qn(this)}}}catch{}finally{}};function Rf(o){if(!ec(o))return o.g.la();const c=Ec(o.g);if(c==="")return"";let h="";const p=c.length,v=It(o.g)==4;if(!o.h.i){if(typeof TextDecoder>"u")return Wt(o),Qn(o),"";o.h.i=new a.TextDecoder}for(let R=0;R<p;R++)o.h.h=!0,h+=o.h.i.decode(c[R],{stream:!(v&&R==p-1)});return c.length=0,o.h.g+=h,o.C=0,o.h.g}function ec(o){return o.g?o.v=="GET"&&o.M!=2&&o.j.Aa:!1}function Sf(o,c){var h=o.C,p=c.indexOf(` 1594`,h);return p==-1?Ni:(h=Number(c.substring(h,p)),isNaN(h)?Xa:(p+=1,p+h>c.length?Ni:(c=c.slice(p,p+h),o.C=p+h,c)))}yt.prototype.cancel=function(){this.K=!0,Wt(this)};function Qr(o){o.T=Date.now()+o.H,tc(o,o.H)}function tc(o,c){if(o.D!=null)throw Error("WatchDog timer not null");o.D=Gn(d(o.aa,o),c)}function Vi(o){o.D&&(a.clearTimeout(o.D),o.D=null)}yt.prototype.aa=function(){this.D=null;const o=Date.now();o-this.T>=0?(wf(this.i,this.B),this.M!=2&&(zn(),Se(17)),Wt(this),this.m=2,Qn(this)):tc(this,this.T-o)};function Qn(o){o.j.I==0||o.K||Sc(o.j,o)}function Wt(o){Vi(o);var c=o.O;c&&typeof c.dispose=="function"&&c.dispose(),o.O=null,$a(o.V),o.g&&(c=o.g,o.g=null,c.abort(),c.dispose())}function Oi(o,c){try{var h=o.j;if(h.I!=0&&(h.g==o||Li(h.h,o))){if(!o.L&&Li(h.h,o)&&h.I==3){try{var p=h.Ba.g.parse(c)}catch{p=null}if(Array.isArray(p)&&p.length==3){var v=p;if(v[0]==0){e:if(!h.v){if(h.g)if(h.g.F+3e3<o.F)ts(h),Zr(h);else break e;qi(h),Se(18)}}else h.xa=v[1],0<h.xa-h.K&&v[2]<37500&&h.F&&h.A==0&&!h.C&&(h.C=Gn(d(h.Va,h),6e3));sc(h.h)<=1&&h.ta&&(h.ta=void 0)}else Qt(h,11)}else if((o.L||h.g==o)&&ts(h),!y(c))for(v=h.Ba.g.parse(c),c=0;c<v.length;c++){let Y=v[c];const pe=Y[0];if(!(pe<=h.K))if(h.K=pe,Y=Y[1],h.I==2)if(Y[0]=="c"){h.M=Y[1],h.ba=Y[2];const Qe=Y[3];Qe!=null&&(h.ka=Qe,h.j.info("VER="+h.ka));const Jt=Y[4];Jt!=null&&(h.za=Jt,h.j.info("SVER="+h.za));const wt=Y[5];wt!=null&&typeof wt=="number"&&wt>0&&(p=1.5*wt,h.O=p,h.j.info("backChannelRequestTimeoutMs_="+p)),p=h;const vt=o.g;if(vt){const rs=vt.g?vt.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(rs){var R=p.h;R.g||rs.indexOf("spdy")==-1&&rs.indexOf("quic")==-1&&rs.indexOf("h2")==-1||(R.j=R.l,R.g=new Set,R.h&&(Mi(R,R.h),R.h=null))}if(p.G){const ji=vt.g?vt.g.getResponseHeader("X-HTTP-Session-Id"):null;ji&&(p.wa=ji,Z(p.J,p.G,ji))}}h.I=3,h.l&&h.l.ra(),h.aa&&(h.T=Date.now()-o.F,h.j.info("Handshake RTT: "+h.T+"ms")),p=h;var N=o;if(p.na=Cc(p,p.L?p.ba:null,p.W),N.L){ic(p.h,N);var j=N,de=p.O;de&&(j.H=de),j.D&&(Vi(j),Qr(j)),p.g=N}else Ac(p);h.i.length>0&&es(h)}else Y[0]!="stop"&&Y[0]!="close"||Qt(h,7);else h.I==3&&(Y[0]=="stop"||Y[0]=="close"?Y[0]=="stop"?Qt(h,7):Bi(h):Y[0]!="noop"&&h.l&&h.l.qa(Y),h.A=0)}}zn(4)}catch{}}var Pf=class{constructor(o,c){this.g=o,this.map=c}};function nc(o){this.l=o||10,a.PerformanceNavigationTiming?(o=a.performance.getEntriesByType("navigation"),o=o.length>0&&(o[0].nextHopProtocol=="hq"||o[0].nextHopProtocol=="h2")):o=!!(a.chrome&&a.chrome.loadTimes&&a.chrome.loadTimes()&&a.chrome.loadTimes().wasFetchedViaSpdy),this.j=o?this.l:1,this.g=null,this.j>1&&(this.g=new Set),this.h=null,this.i=[]}function rc(o){return o.h?!0:o.g?o.g.size>=o.j:!1}function sc(o){return o.h?1:o.g?o.g.size:0}function Li(o,c){return o.h?o.h==c:o.g?o.g.has(c):!1}function Mi(o,c){o.g?o.g.add(c):o.h=c}function ic(o,c){o.h&&o.h==c?o.h=null:o.g&&o.g.has(c)&&o.g.delete(c)}nc.prototype.cancel=function(){if(this.i=oc(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()}};
1594function oc(o){if(o.h!=null)return o.i.concat(o.h.G);if(o.g!=null&&o.g.size!==0){let c=o.i;for(const h of o.g.values())c=c.concat(h.G);return c}return S(o.i)}var ac=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function bf(o,c){if(o){o=o.split("&");for(let h=0;h<o.length;h++){const p=o[h].indexOf("=");let v,R=null;p>=0?(v=o[h].substring(0,p),R=o[h].substring(p+1)):v=o[h],c(v,R?decodeURIComponent(R.replace(/\+/g," ")):"")}}}function Et(o){this.g=this.o=this.j="",this.u=null,this.m=this.h="",this.l=!1;let c;o instanceof Et?(this.l=o.l,Jn(this,o.j),this.o=o.o,this.g=o.g,Yn(this,o.u),this.h=o.h,xi(this,fc(o.i)),this.m=o.m):o&&(c=String(o).match(ac))?(this.l=!1,Jn(this,c[1]||"",!0),this.o=Xn(c[2]||""),this.g=Xn(c[3]||"",!0),Yn(this,c[4]),this.h=Xn(c[5]||"",!0),xi(this,c[6]||"",!0),this.m=Xn(c[7]||"")):(this.l=!1,this.i=new er(null,this.l))}Et.prototype.toString=function(){const o=[];var c=this.j;c&&o.push(Zn(c,cc,!0),":");var h=this.g;return(h||c=="file")&&(o.push("//"),(c=this.o)&&o.push(Zn(c,cc,!0),"@"),o.push(Kn(h).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),h=this.u,h!=null&&o.push(":",String(h))),(h=this.h)&&(this.g&&h.charAt(0)!="/"&&o.push("/"),o.push(Zn(h,h.charAt(0)=="/"?Nf:kf,!0))),(h=this.i.toString())&&o.push("?",h),(h=this.m)&&o.push("#",Zn(h,Vf)),o.join("")},Et.prototype.resolve=function(o){const c=Ke(this);let h=!!o.j;h?Jn(c,o.j):h=!!o.o,h?c.o=o.o:h=!!o.g,h?c.g=o.g:h=o.u!=null;var p=o.h;if(h)Yn(c,o.u);else if(h=!!o.h){if(p.charAt(0)!="/")if(this.g&&!this.h)p="/"+p;else{var v=c.h.lastIndexOf("/");v!=-1&&(p=c.h.slice(0,v+1)+p)}if(v=p,v==".."||v==".")p="";else if(v.indexOf("./")!=-1||v.indexOf("/.")!=-1){p=v.lastIndexOf("/",0)==0,v=v.split("/");const R=[];for(let N=0;N<v.length;){const j=v[N++];j=="."?p&&N==v.length&&R.push(""):j==".."?((R.length>1||R.length==1&&R[0]!="")&&R.pop(),p&&N==v.length&&R.push("")):(R.push(j),p=!0)}p=R.join("/")}else p=v}return h?c.h=p:h=o.i.toString()!=="",h?xi(c,fc(o.i)):h=!!o.m,h&&(c.m=o.m),c};function Ke(o){return new Et(o)}function Jn(o,c,h){o.j=h?Xn(c,!0):c,o.j&&(o.j=o.j.replace(/:$/,""))}function Yn(o,c){if(c){if(c=Number(c),isNaN(c)||c<0)throw Error("Bad port number "+c);o.u=c}else o.u=null}function xi(o,c,h){c instanceof er?(o.i=c,Of(o.i,o.l)):(h||(c=Zn(c,Df)),o.i=new er(c,o.l))}function Z(o,c,h){o.i.set(c,h)}function Jr(o){return Z(o,"zx",Math.floor(Math.random()*2147483648).toString(36)+Math.abs(Math.floor(Math.random()*2147483648)^Date.now()).toString(36)),o}function Xn(o,c){return o?c?decodeURI(o.replace(/%25/g,"%2525")):decodeURIComponent(o):""}function Zn(o,c,h){return typeof o=="string"?(o=encodeURI(o).replace(c,Cf),h&&(o=o.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),o):null}function Cf(o){return o=o.charCodeAt(0),"%"+(o>>4&15).toString(16)+(o&15).toString(16)}var cc=/[#\/\?@]/g,kf=/[#\?:]/g,Nf=/[#\?]/g,Df=/[#\?@]/g,Vf=/#/g;function er(o,c){this.h=this.g=null,this.i=o||null,this.j=!!c}function Kt(o){o.g||(o.g=new Map,o.h=0,o.i&&bf(o.i,function(c,h){o.add(decodeURIComponent(c.replace(/\+/g," ")),h)}))}n=er.prototype,n.add=function(o,c){Kt(this),this.i=null,o=mn(this,o);let h=this.g.get(o);return h||this.g.set(o,h=[]),h.push(c),this.h+=1,this};function uc(o,c){Kt(o),c=mn(o,c),o.g.has(c)&&(o.i=null,o.h-=o.g.get(c).length,o.g.delete(c))}function lc(o,c){return Kt(o),c=mn(o,c),o.g.has(c)}n.forEach=function(o,c){Kt(this),this.g.forEach(function(h,p){h.forEach(function(v){o.call(c,v,p,this)},this)},this)};function hc(o,c){Kt(o);let h=[];if(typeof c=="string")lc(o,c)&&(h=h.concat(o.g.get(mn(o,c))));else for(o=Array.from(o.g.values()),c=0;c<o.length;c++)h=h.concat(o[c]);return h}n.set=function(o,c){return Kt(this),this.i=null,o=mn(this,o),lc(this,o)&&(this.h-=this.g.get(o).length),this.g.set(o,[c]),this.h+=1,this},n.get=function(o,c){return o?(o=hc(this,o),o.length>0?String(o[0]):c):c};function dc(o,c,h){uc(o,c),h.length>0&&(o.i=null,o.g.set(mn(o,c),S(h)),o.h+=h.length)}n.toString=function(){if(this.i)return this.i;if(!this.g)return"";const o=[],c=Array.from(this.g.keys());for(let p=0;p<c.length;p++){var h=c[p];const v=Kn(h);h=hc(this,h);for(let R=0;R<h.length;R++){let N=v;h[R]!==""&&(N+="="+Kn(h[R])),o.push(N)}}return this.i=o.join("&")};function fc(o){const c=new er;return c.i=o.i,o.g&&(c.g=new Map(o.g),c.h=o.h),c}function mn(o,c){return c=String(c),o.j&&(c=c.toLowerCase()),c}function Of(o,c){c&&!o.j&&(Kt(o),o.i=null,o.g.forEach(function(h,p){const v=p.toLowerCase();p!=v&&(uc(this,p),dc(this,v,h))},o)),o.j=c}function Lf(o,c){const h=new Wn;if(a.Image){const p=new Image;p.onload=f(Tt,h,"TestLoadImage: loaded",!0,c,p),p.onerror=f(Tt,h,"TestLoadImage: error",!1,c,p),p.onabort=f(Tt,h,"TestLoadImage: abort",!1,c,p),p.ontimeout=f(Tt,h,"TestLoadImage: timeout",!1,c,p),a.setTimeout(function(){p.ontimeout&&p.ontimeout()},1e4),p.src=o}else c(!1)}function Mf(o,c){const h=new Wn,p=new AbortController,v=setTimeout(()=>{p.abort(),Tt(h,"TestPingServer: timeout",!1,c)},1e4);fetch(o,{signal:p.signal}).then(R=>{clearTimeout(v),R.ok?Tt(h,"TestPingServer: ok",!0,c):Tt(h,"TestPingServer: server error",!1,c)}).catch(()=>{clearTimeout(v),Tt(h,"TestPingServer: error",!1,c)})}function Tt(o,c,h,p,v){try{v&&(v.onload=null,v.onerror=null,v.onabort=null,v.ontimeout=null),p(h)}catch{}}function xf(){this.g=new Ef}function Ui(o){this.i=o.Sb||null,this.h=o.ab||!1}m(Ui,ja),Ui.prototype.g=function(){return new Yr(this.i,this.h)};function Yr(o,c){Ee.call(this),this.H=o,this.o=c,this.m=void 0,this.status=this.readyState=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.A=new Headers,this.h=null,this.F="GET",this.D="",this.g=!1,this.B=this.j=this.l=null,this.v=new AbortController}m(Yr,Ee),n=Yr.prototype,n.open=function(o,c){if(this.readyState!=0)throw this.abort(),Error("Error reopening a connection");this.F=o,this.D=c,this.readyState=1,nr(this)}
1594,n.send=function(o){if(this.readyState!=1)throw this.abort(),Error("need to call open() first. ");if(this.v.signal.aborted)throw this.abort(),Error("Request was aborted.");this.g=!0;const c={headers:this.A,method:this.F,credentials:this.m,cache:void 0,signal:this.v.signal};o&&(c.body=o),(this.H||a).fetch(new Request(this.D,c)).then(this.Pa.bind(this),this.ga.bind(this))},n.abort=function(){this.response=this.responseText="",this.A=new Headers,this.status=0,this.v.abort(),this.j&&this.j.cancel("Request was aborted.").catch(()=>{}),this.readyState>=1&&this.g&&this.readyState!=4&&(this.g=!1,tr(this)),this.readyState=0},n.Pa=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,nr(this)),this.g&&(this.readyState=3,nr(this),this.g)))if(this.responseType==="arraybuffer")o.arrayBuffer().then(this.Na.bind(this),this.ga.bind(this));else if(typeof a.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.B=new TextDecoder;pc(this)}else o.text().then(this.Oa.bind(this),this.ga.bind(this))};function pc(o){o.j.read().then(o.Ma.bind(o)).catch(o.ga.bind(o))}n.Ma=function(o){if(this.g){if(this.o&&o.value)this.response.push(o.value);else if(!this.o){var c=o.value?o.value:new Uint8Array(0);(c=this.B.decode(c,{stream:!o.done}))&&(this.response=this.responseText+=c)}o.done?tr(this):nr(this),this.readyState==3&&pc(this)}},n.Oa=function(o){this.g&&(this.response=this.responseText=o,tr(this))},n.Na=function(o){this.g&&(this.response=o,tr(this))},n.ga=function(){this.g&&tr(this)};function tr(o){o.readyState=4,o.l=null,o.j=null,o.B=null,nr(o)}n.setRequestHeader=function(o,c){this.A.append(o,c)},n.getResponseHeader=function(o){return this.h&&this.h.get(o.toLowerCase())||""},n.getAllResponseHeaders=function(){if(!this.h)return"";const o=[],c=this.h.entries();for(var h=c.next();!h.done;)h=h.value,o.push(h[0]+": "+h[1]),h=c.next();return o.join(`\r 1595`)};function nr(o){o.onreadystatechange&&o.onreadystatechange.call(o)}Object.defineProperty(Yr.prototype,"withCredentials",{get:function(){return this.m==="include"},set:function(o){this.m=o?"include":"same-origin"}});function mc(o){let c="";return Hr(o,function(h,p){c+=p,c+=":",c+=h,c+=`\r 1596`}),c}function Fi(o,c,h){e:{for(p in h){var p=!1;break e}p=!0}p||(h=mc(h),typeof o=="string"?h!=null&&Kn(h):Z(o,c,h))}function ie(o){Ee.call(this),this.headers=new Map,this.L=o||null,this.h=!1,this.g=null,this.D="",this.o=0,this.l="",this.j=this.B=this.v=this.A=!1,this.m=null,this.F="",this.H=!1}m(ie,Ee);var Uf=/^https?$/i,Ff=["POST","PUT"];n=ie.prototype,n.Fa=function(o){this.H=o},n.ea=function(o,c,h,p){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.D+"; newUri="+o);c=c?c.toUpperCase():"GET",this.D=o,this.l="",this.o=0,this.A=!1,this.h=!0,this.g=this.L?this.L.g():Ja.g(),this.g.onreadystatechange=_(d(this.Ca,this));try{this.B=!0,this.g.open(c,String(o),!0),this.B=!1}catch(R){gc(this,R);return}if(o=h||"",h=new Map(this.headers),p)if(Object.getPrototypeOf(p)===Object.prototype)for(var v in p)h.set(v,p[v]);else if(typeof p.keys=="function"&&typeof p.get=="function")for(const R of p.keys())h.set(R,p.get(R));else throw Error("Unknown input type for opt_headers: "+String(p));p=Array.from(h.keys()).find(R=>R.toLowerCase()=="content-type"),v=a.FormData&&o instanceof a.FormData,!(Array.prototype.indexOf.call(Ff,c,void 0)>=0)||p||v||h.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");for(const[R,N]of h)this.g.setRequestHeader(R,N);this.F&&(this.g.responseType=this.F),"withCredentials"in this.g&&this.g.withCredentials!==this.H&&(this.g.withCredentials=this.H);try{this.m&&(clearTimeout(this.m),this.m=null),this.v=!0,this.g.send(o),this.v=!1}catch(R){gc(this,R)}};function gc(o,c){o.h=!1,o.g&&(o.j=!0,o.g.abort(),o.j=!1),o.l=c,o.o=5,_c(o),Xr(o)}function _c(o){o.A||(o.A=!0,Re(o,"complete"),Re(o,"error"))}n.abort=function(o){this.g&&this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1,this.o=o||7,Re(this,"complete"),Re(this,"abort"),Xr(this))},n.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),Xr(this,!0)),ie.Z.N.call(this)}
1596,n.Ca=function(){this.u||(this.B||this.v||this.j?yc(this):this.Xa())},n.Xa=function(){yc(this)};function yc(o){if(o.h&&typeof i<"u"){if(o.v&&It(o)==4)setTimeout(o.Ca.bind(o),0);else if(Re(o,"readystatechange"),It(o)==4){o.h=!1;try{const R=o.ca();e:switch(R){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var c=!0;break e;default:c=!1}var h;if(!(h=c)){var p;if(p=R===0){let N=String(o.D).match(ac)[1]||null;!N&&a.self&&a.self.location&&(N=a.self.location.protocol.slice(0,-1)),p=!Uf.test(N?N.toLowerCase():"")}h=p}if(h)Re(o,"complete"),Re(o,"success");else{o.o=6;try{var v=It(o)>2?o.g.statusText:""}catch{v=""}o.l=v+" ["+o.ca()+"]",_c(o)}}finally{Xr(o)}}}}function Xr(o,c){if(o.g){o.m&&(clearTimeout(o.m),o.m=null);const h=o.g;o.g=null,c||Re(o,"ready");try{h.onreadystatechange=null}catch{}}}n.isActive=function(){return!!this.g};function It(o){return o.g?o.g.readyState:0}n.ca=function(){try{return It(this)>2?this.g.status:-1}catch{return-1}},n.la=function(){try{return this.g?this.g.responseText:""}catch{return""}},n.La=function(o){if(this.g){var c=this.g.responseText;return o&&c.indexOf(o)==0&&(c=c.substring(o.length)),yf(c)}};function Ec(o){try{if(!o.g)return null;if("response"in o.g)return o.g.response;switch(o.F){case"":case"text":return o.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in o.g)return o.g.mozResponseArrayBuffer}return null}catch{return null}}function Bf(o){const c={};o=(o.g&&It(o)>=2&&o.g.getAllResponseHeaders()||"").split(`\r 1597`);for(let p=0;p<o.length;p++){if(y(o[p]))continue;var h=Af(o[p]);const v=h[0];if(h=h[1],typeof h!="string")continue;h=h.trim();const R=c[v]||[];c[v]=R,R.push(h)}df(c,function(p){return p.join(", ")})}n.ya=function(){return this.o},n.Ha=function(){return typeof this.l=="string"?this.l:String(this.l)};function rr(o,c,h){return h&&h.internalChannelParams&&h.internalChannelParams[o]||c}function Tc(o){this.za=0,this.i=[],this.j=new Wn,this.ba=this.na=this.J=this.W=this.g=this.wa=this.G=this.H=this.u=this.U=this.o=null,this.Ya=this.V=0,this.Sa=rr("failFast",!1,o),this.F=this.C=this.v=this.m=this.l=null,this.X=!0,this.xa=this.K=-1,this.Y=this.A=this.D=0,this.Qa=rr("baseRetryDelayMs",5e3,o),this.Za=rr("retryDelaySeedMs",1e4,o),this.Ta=rr("forwardChannelMaxRetries",2,o),this.va=rr("forwardChannelRequestTimeoutMs",2e4,o),this.ma=o&&o.xmlHttpFactory||void 0,this.Ua=o&&o.Rb||void 0,this.Aa=o&&o.useFetchStreams||!1,this.O=void 0,this.L=o&&o.supportsCrossDomainXhr||!1,this.M="",this.h=new nc(o&&o.concurrentRequestLimit),this.Ba=new xf,this.S=o&&o.fastHandshake||!1,this.R=o&&o.encodeInitMessageHeaders||!1,this.S&&this.R&&(this.R=!1),this.Ra=o&&o.Pb||!1,o&&o.ua&&this.j.ua(),o&&o.forceLongPolling&&(this.X=!1),this.aa=!this.S&&this.X&&o&&o.detectBufferingProxy||!1,this.ia=void 0,o&&o.longPollingTimeout&&o.longPollingTimeout>0&&(this.ia=o.longPollingTimeout),this.ta=void 0,this.T=0,this.P=!1,this.ja=this.B=null}n=Tc.prototype,n.ka=8,n.I=1,n.connect=function(o,c,h,p){Se(0),this.W=o,this.H=c||{},h&&p!==void 0&&(this.H.OSID=h,this.H.OAID=p),this.F=this.X,this.J=Cc(this,null,this.W),es(this)};function Bi(o){if(Ic(o),o.I==3){var c=o.V++,h=Ke(o.J);if(Z(h,"SID",o.M),Z(h,"RID",c),Z(h,"TYPE","terminate"),sr(o,h),c=new yt(o,o.j,c),c.M=2,c.A=Jr(Ke(h)),h=!1,a.navigator&&a.navigator.sendBeacon)try{h=a.navigator.sendBeacon(c.A.toString(),"")}catch{}!h&&a.Image&&(new Image().src=c.A,h=!0),h||(c.g=kc(c.j,null),c.g.ea(c.A)),c.F=Date.now(),Qr(c)}bc(o)}function Zr(o){o.g&&($i(o),o.g.cancel(),o.g=null)}function Ic(o){Zr(o),o.v&&(a.clearTimeout(o.v),o.v=null),ts(o),o.h.cancel(),o.m&&(typeof o.m=="number"&&a.clearTimeout(o.m),o.m=null)}function es(o){if(!rc(o.h)&&!o.m){o.m=!0;var c=o.Ea;ce||g(),ne||(ce(),ne=!0),I.add(c,o),o.D=0}}function qf(o,c){return sc(o.h)>=o.h.j-(o.m?1:0)?!1:o.m?(o.i=c.G.concat(o.i),!0):o.I==1||o.I==2||o.D>=(o.Sa?0:o.Ta)?!1:(o.m=Gn(d(o.Ea,o,c),Pc(o,o.D)),o.D++,!0)}n.Ea=function(o){if(this.m)if(this.m=null,this.I==1){if(!o){this.V=Math.floor(Math.random()*1e5),o=this.V++;const v=new yt(this,this.j,o);let R=this.o;if(this.U&&(R?(R=Va(R),La(R,this.U)):R=this.U),this.u!==null||this.R||(v.J=R,R=null),this.S)e:{for(var c=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(c+=p,c>4096){c=h;break e}if(c===4096||h===this.i.length-1){c=h+1;break e}}c=1e3}else c=1e3;c=vc(this,v,c),h=Ke(this.J),Z(h,"RID",o),Z(h,"CVER",22),this.G&&Z(h,"X-HTTP-Session-Id",this.G),sr(this,h),R&&(this.R?c="headers="+Kn(mc(R))+"&"+c:this.u&&Fi(h,this.u,R)),Mi(this.h,v),this.Ra&&Z(h,"TYPE","init"),this.S?(Z(h,"$req",c),Z(h,"SID","null"),v.U=!0,Di(v,h,null)):Di(v,h,c),this.I=2}}else this.I==3&&(o?wc(this,o):this.i.length==0||rc(this.h)||wc(this))};function wc(o,c){var h;c?h=c.l:h=o.V++;const p=Ke(o.J);Z(p,"SID",o.M),Z(p,"RID",h),Z(p,"AID",o.K),sr(o,p),o.u&&o.o&&Fi(p,o.u,o.o),h=new yt(o,o.j,h,o.D+1),o.u===null&&(h.J=o.o),c&&(o.i=c.G.concat(o.i)),c=vc(o,h,1e3),h.H=Math.round(o.va*.5)+Math.round(o.va*.5*Math.random()),Mi(o.h,h),Di(h,p,c)}function sr(o,c){o.H&&Hr(o.H,function(h,p){Z(c,p,h)}),o.l&&Hr({},function(h,p){Z(c,p,h)})}function vc(o,c,h){h=Math.min(o.i.length,h);const p=o.l?d(o.l.Ka,o.l,o):null;e:{var v=o.i;let j=-1;for(;;){const de=["count="+h];j==-1?h>0?(j=v[0].g,de.push("ofs="+j)):j=0:de.push("ofs="+j);let Y=!0;for(let pe=0;pe<h;pe++){var R=v[pe].g;const Qe=v[pe].map;if(R-=j,R<0)j=Math.max(0,v[pe].g-100),Y=!1;else try{R="req"+R+"_"||"";try{var N=Qe instanceof Map?Qe:Object.entries(Qe);for(const[Jt,wt]of N){let vt=wt;u(wt)&&(vt=Pi(wt)),de.push(R+Jt+"="+encodeURIComponent(vt))}}catch(Jt){throw de.push(R+"type="+encodeURIComponent("_badmap")),Jt}}catch{p&&p(Qe)}}if(Y){N=de.join("&");break e}}N=void 0}return o=o.i.splice(0,h),c.G=o,N}function Ac(o){if(!o.g&&!o.v){o.Y=1;var c=o.Da;ce||g(),ne||(ce(),ne=!0),I.add(c,o),o.A=0}}function qi(o){return o.g||o.v||o.A>=3?!1:(o.Y++,o.v=Gn(d(o.Da,o),Pc(o,o.A)),o.A++,!0)}
vendor: 5,489 bytes, lines 1597-1601
1597n.Da=function(){if(this.v=null,Rc(this),this.aa&&!(this.P||this.g==null||this.T<=0)){var o=4*this.T;this.j.info("BP detection timer enabled: "+o),this.B=Gn(d(this.Wa,this),o)}},n.Wa=function(){this.B&&(this.B=null,this.j.info("BP detection timeout reached."),this.j.info("Buffering proxy detected and switch to long-polling!"),this.F=!1,this.P=!0,Se(10),Zr(this),Rc(this))};function $i(o){o.B!=null&&(a.clearTimeout(o.B),o.B=null)}function Rc(o){o.g=new yt(o,o.j,"rpc",o.Y),o.u===null&&(o.g.J=o.o),o.g.P=0;var c=Ke(o.na);Z(c,"RID","rpc"),Z(c,"SID",o.M),Z(c,"AID",o.K),Z(c,"CI",o.F?"0":"1"),!o.F&&o.ia&&Z(c,"TO",o.ia),Z(c,"TYPE","xmlhttp"),sr(o,c),o.u&&o.o&&Fi(c,o.u,o.o),o.O&&(o.g.H=o.O);var h=o.g;o=o.ba,h.M=1,h.A=Jr(Ke(c)),h.u=null,h.R=!0,Za(h,o)}n.Va=function(){this.C!=null&&(this.C=null,Zr(this),qi(this),Se(19))};function ts(o){o.C!=null&&(a.clearTimeout(o.C),o.C=null)}function Sc(o,c){var h=null;if(o.g==c){ts(o),$i(o),o.g=null;var p=2}else if(Li(o.h,c))h=c.G,ic(o.h,c),p=1;else return;if(o.I!=0){if(c.o)if(p==1){h=c.u?c.u.length:0,c=Date.now()-c.F;var v=o.D;p=Wr(),Re(p,new Ka(p,h)),es(o)}else Ac(o);else if(v=c.m,v==3||v==0&&c.X>0||!(p==1&&qf(o,c)||p==2&&qi(o)))switch(h&&h.length>0&&(c=o.h,c.i=c.i.concat(h)),v){case 1:Qt(o,5);break;case 4:Qt(o,10);break;case 3:Qt(o,6);break;default:Qt(o,2)}}}function Pc(o,c){let h=o.Qa+Math.floor(Math.random()*o.Za);return o.isActive()||(h*=2),h*c}function Qt(o,c){if(o.j.info("Error code "+c),c==2){var h=d(o.bb,o),p=o.Ua;const v=!p;p=new Et(p||"//www.google.com/images/cleardot.gif"),a.location&&a.location.protocol=="http"||Jn(p,"https"),Jr(p),v?Lf(p.toString(),h):Mf(p.toString(),h)}else Se(2);o.I=0,o.l&&o.l.pa(c),bc(o),Ic(o)}n.bb=function(o){o?(this.j.info("Successfully pinged google.com"),Se(2)):(this.j.info("Failed to ping google.com"),Se(1))};function bc(o){if(o.I=0,o.ja=[],o.l){const c=oc(o.h);(c.length!=0||o.i.length!=0)&&(C(o.ja,c),C(o.ja,o.i),o.h.i.length=0,S(o.i),o.i.length=0),o.l.oa()}}function Cc(o,c,h){var p=h instanceof Et?Ke(h):new Et(h);if(p.g!="")c&&(p.g=c+"."+p.g),Yn(p,p.u);else{var v=a.location;p=v.protocol,c=c?c+"."+v.hostname:v.hostname,v=+v.port;const R=new Et(null);p&&Jn(R,p),c&&(R.g=c),v&&Yn(R,v),h&&(R.h=h),p=R}return h=o.G,c=o.wa,h&&c&&Z(p,h,c),Z(p,"VER",o.ka),sr(o,p),p}function kc(o,c,h){if(c&&!o.L)throw Error("Can't create secondary domain capable XhrIo object.");return c=o.Aa&&!o.ma?new ie(new Ui({ab:h})):new ie(o.ma),c.Fa(o.L),c}n.isActive=function(){return!!this.l&&this.l.isActive(this)};function Nc(){}n=Nc.prototype,n.ra=function(){},n.qa=function(){},n.pa=function(){},n.oa=function(){},n.isActive=function(){return!0},n.Ka=function(){};function ns(){}ns.prototype.g=function(o,c){return new Le(o,c)};function Le(o,c){Ee.call(this),this.g=new Tc(c),this.l=o,this.h=c&&c.messageUrlParams||null,o=c&&c.messageHeaders||null,c&&c.clientProtocolHeaderRequired&&(o?o["X-Client-Protocol"]="webchannel":o={"X-Client-Protocol":"webchannel"}),this.g.o=o,o=c&&c.initMessageHeaders||null,c&&c.messageContentType&&(o?o["X-WebChannel-Content-Type"]=c.messageContentType:o={"X-WebChannel-Content-Type":c.messageContentType}),c&&c.sa&&(o?o["X-WebChannel-Client-Profile"]=c.sa:o={"X-WebChannel-Client-Profile":c.sa}),this.g.U=o,(o=c&&c.Qb)&&!y(o)&&(this.g.u=o),this.A=c&&c.supportsCrossDomainXhr||!1,this.v=c&&c.sendRawJson||!1,(c=c&&c.httpSessionIdParam)&&!y(c)&&(this.g.G=c,o=this.h,o!==null&&c in o&&(o=this.h,c in o&&delete o[c])),this.j=new gn(this)}m(Le,Ee),Le.prototype.m=function(){this.g.l=this.j,this.A&&(this.g.L=!0),this.g.connect(this.l,this.h||void 0)},Le.prototype.close=function(){Bi(this.g)},Le.prototype.o=function(o){var c=this.g;if(typeof o=="string"){var h={};h.__data__=o,o=h}else this.v&&(h={},h.__data__=Pi(o),o=h);c.i.push(new Pf(c.Ya++,o)),c.I==3&&es(c)},Le.prototype.N=function(){this.g.l=null,delete this.j,Bi(this.g),delete this.g,Le.Z.N.call(this)};function Dc(o){bi.call(this),o.__headers__&&(this.headers=o.__headers__,this.statusCode=o.__status__,delete o.__headers__,delete o.__status__);var c=o.__sm__;if(c){e:{for(const h in c){o=h;break e}o=void 0}(this.i=o)&&(o=this.i,c=c!==null&&o in c?c[o]:void 0),this.data=c}else this.data=o}m(Dc,bi);function Vc(){Ci.call(this),this.status=1}m(Vc,Ci);function gn(o){this.g=o}m(gn,Nc),gn.prototype.ra=function(){Re(this.g,"a")},gn.prototype.qa=function(o){Re(this.g,new Dc(o))},gn.prototype.pa=function(o){Re(this.g,new Vc)},gn.prototype.oa=function(){Re(this.g,"b")},ns.prototype.createWebChannel=ns.prototype.g,Le.prototype.send=Le.prototype.o,Le.prototype.open=Le.prototype.m,Le.prototype.close=Le.prototype.close,fh=function(){return new ns},dh=function(){return Wr()},hh=Gt,co={jb:0,mb:1,nb:2,Hb:3,Mb:4,Jb:5,Kb:6,Ib:7,Gb:8,Lb:9,PROXY:10,NOPROXY:11,Eb:12,Ab:13,Bb:14,zb:15,Cb:16,Db:17,fb:18,eb:19,gb:20},Kr.NO_ERROR=0,Kr.TIMEOUT=8,Kr.HTTP_ERROR=6,gs=Kr,Qa.COMPLETE="complete",lh=Qa,Ha.EventType=Hn,Hn.OPEN="a",Hn.CLOSE="b",Hn.ERROR="c",Hn.MESSAGE="d",Ee.prototype.listen=Ee.prototype.J,ur=Ha,ie.prototype.listenOnce=ie.prototype.K,ie.prototype.getLastError=ie.prototype.Ha,ie.prototype.getLastErrorCode=ie.prototype.ya,ie.prototype.getStatus=ie.prototype.ca,ie.prototype.getResponseJson=ie.prototype.La,ie.prototype.getResponseText=ie.prototype.la,ie.prototype.send=ie.prototype.ea,ie.prototype.setWithCredentials=ie.prototype.Fa,uh=ie}).apply(typeof is<"u"?is:typeof self<"u"?self:typeof window<"u"?window:{});/** 1598 * @license 1599 * Copyright 2017 Google LLC 1600 * 1601 * Licensed under the Apache License, Version 2.0 (the "License");
1602 * you may not use this file except in compliance with the License. 1603 * You may obtain a copy of the License at 1604 * 1605 * http://www.apache.org/licenses/LICENSE-2.0 1606 * 1607 * Unless required by applicable law or agreed to in writing, software 1608 * distributed under the License is distributed on an "AS IS" BASIS, 1609 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1610 * See the License for the specific language governing permissions and 1611 * limitations under the License. 1612 */class Ie{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}}Ie.UNAUTHENTICATED=new Ie(null),Ie.GOOGLE_CREDENTIALS=new Ie("google-credentials-uid"),Ie.FIRST_PARTY=new Ie("first-party-uid"),Ie.MOCK_USER=new Ie("mock-user");/** 1613 * @license 1614 * Copyright 2017 Google LLC 1615 * 1616 * Licensed under the Apache License, Version 2.0 (the "License"); 1617 * you may not use this file except in compliance with the License. 1618 * You may obtain a copy of the License at 1619 * 1620 * http://www.apache.org/licenses/LICENSE-2.0 1621 * 1622 * Unless required by applicable law or agreed to in writing, software 1623 * distributed under the License is distributed on an "AS IS" BASIS, 1624 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1625 * See the License for the specific language governing permissions and 1626 * limitations under the License. 1627 */let xn="12.8.0";function C_(n){xn=n}/** 1628 * @license 1629 * Copyright 2020 Google LLC 1630 * 1631 * Licensed under the Apache License, Version 2.0 (the "License"); 1632 * you may not use this file except in compliance with the License. 1633 * You may obtain a copy of the License at 1634 * 1635 * http://www.apache.org/licenses/LICENSE-2.0 1636 * 1637 * Unless required by applicable law or agreed to in writing, software 1638 * distributed under the License is distributed on an "AS IS" BASIS, 1639 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1640 * See the License for the specific language governing permissions and 1641 * limitations under the License. 1642 *//** 1643 * @license 1644 * Copyright 2017 Google LLC 1645 * 1646 * Licensed under the Apache License, Version 2.0 (the "License"); 1647 * you may not use this file except in compliance with the License. 1648 * You may obtain a copy of the License at 1649 * 1650 * http://www.apache.org/licenses/LICENSE-2.0 1651 * 1652 * Unless required by applicable law or agreed to in writing, software 1653 * distributed under the License is distributed on an "AS IS" BASIS, 1654 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1655 * See the License for the specific language governing permissions and 1656 * limitations under the License. 1657 */const sn=new ko("@firebase/firestore");function yn(){return sn.logLevel}function O(n,...e){if(sn.logLevel<=z.DEBUG){const t=e.map($o);sn.debug(`Firestore (${xn}): ${n}`,...t)}}function pt(n,...e){if(sn.logLevel<=z.ERROR){const t=e.map($o);sn.error(`Firestore (${xn}): ${n}`,...t)}}function Cn(n,...e){if(sn.logLevel<=z.WARN){const t=e.map($o);sn.warn(`Firestore (${xn}): ${n}`,...t)}}function $o(n){if(typeof n=="string")return n;try{return(function(t){return JSON.stringify(t)})(n)}catch{return n}}/** 1658 * @license 1659 * Copyright 2017 Google LLC 1660 * 1661 * Licensed under the Apache License, Version 2.0 (the "License"); 1662 * you may not use this file except in compliance with the License. 1663 * You may obtain a copy of the License at 1664 * 1665 * http://www.apache.org/licenses/LICENSE-2.0 1666 * 1667 * Unless required by applicable law or agreed to in writing, software 1668 * distributed under the License is distributed on an "AS IS" BASIS, 1669 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1670 * See the License for the specific language governing permissions and 1671 * limitations under the License. 1672 */function x(n,e,t){let r="Unexpected state";typeof e=="string"?r=e:t=e,ph(n,r,t)}function ph(n,e,t){let r=`FIRESTORE (${xn}) INTERNAL ASSERTION FAILED: ${e} (ID: ${n.toString(16)})`;if(t!==void 0)try{r+=" CONTEXT: "+JSON.stringify(t)}catch{r+=" CONTEXT: "+t}throw pt(r),new Error(r)}function J(n,e,t,r){let s="Unexpected state";
1672typeof t=="string"?s=t:r=t,n||ph(e,s,r)}function B(n,e){return n}/** 1673 * @license 1674 * Copyright 2017 Google LLC 1675 * 1676 * Licensed under the Apache License, Version 2.0 (the "License"); 1677 * you may not use this file except in compliance with the License. 1678 * You may obtain a copy of the License at 1679 * 1680 * http://www.apache.org/licenses/LICENSE-2.0 1681 * 1682 * Unless required by applicable law or agreed to in writing, software 1683 * distributed under the License is distributed on an "AS IS" BASIS, 1684 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1685 * See the License for the specific language governing permissions and 1686 * limitations under the License. 1687 */const P={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class V extends ze{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}/** 1688 * @license 1689 * Copyright 2017 Google LLC 1690 * 1691 * Licensed under the Apache License, Version 2.0 (the "License"); 1692 * you may not use this file except in compliance with the License. 1693 * You may obtain a copy of the License at 1694 * 1695 * http://www.apache.org/licenses/LICENSE-2.0 1696 * 1697 * Unless required by applicable law or agreed to in writing, software 1698 * distributed under the License is distributed on an "AS IS" BASIS, 1699 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1700 * See the License for the specific language governing permissions and 1701 * limitations under the License. 1702 */class lt{constructor(){this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}}/** 1703 * @license 1704 * Copyright 2017 Google LLC 1705 * 1706 * Licensed under the Apache License, Version 2.0 (the "License"); 1707 * you may not use this file except in compliance with the License. 1708 * You may obtain a copy of the License at 1709 * 1710 * http://www.apache.org/licenses/LICENSE-2.0 1711 * 1712 * Unless required by applicable law or agreed to in writing, software 1713 * distributed under the License is distributed on an "AS IS" BASIS, 1714 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1715 * See the License for the specific language governing permissions and 1716 * limitations under the License. 1717 */class mh{constructor(e,t){this.user=t,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class k_{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable((()=>t(Ie.UNAUTHENTICATED)))}shutdown(){}}class N_{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 D_{constructor(e){this.t=e,this.currentUser=Ie.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,t){J(this.o===void 0,42304);let r=this.i;const s=l=>this.i!==r?(r=this.i,t(l)):Promise.resolve();let i=new lt;this.o=()=>{this.i++,this.currentUser=this.u(),i.resolve(),i=new lt,e.enqueueRetryable((()=>s(this.currentUser)))};const a=()=>{const l=i;e.enqueueRetryable((async()=>{await l.promise,await s(this.currentUser)}))},u=l=>{O("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=l,this.o&&(this.auth.addAuthTokenListener(this.o),a())};this.t.onInit((l=>u(l))),setTimeout((()=>{if(!this.auth){const l=this.t.getImmediate({optional:!0});l?u(l):(O("FirebaseAuthCredentialsProvider","Auth not yet detected"),i.resolve(),i=new lt)}}),0),a()}getToken(){const e=this.i,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then((r=>this.i!==e?(O("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):r?(J(typeof r.accessToken=="string",31837,{l:r}),new mh(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 J(e===null||typeof e=="string",2055,{h:e}),new Ie(e)}}class V_{constructor(e,t,r){this.P=e,this.T=t,this.I=r,this.type="FirstParty",this.user=Ie.FIRST_PARTY,this.R=new Map}A(){return this.I?this.I():null}get headers(){this.R.set("X-Goog-AuthUser",this.P);const e=this.A();return e&&this.R.set("Authorization",e),this.T&&this.R.set("X-Goog-Iam-Authorization-Token",this.T),this.R}}class O_{constructor(e,t,r){this.P=e,this.T=t,this.I=r}getToken(){return Promise.resolve(new V_(this.P,this.T,this.I))}start(e,t){e.enqueueRetryable((()=>t(Ie.FIRST_PARTY)))}shutdown(){}invalidateToken(){}}class cu{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 L_{constructor(e,t){this.V=t,this.forceRefresh=!1,this.appCheck=null,this.m=null,this.p=null,ve(e)&&e.settings.appCheckToken&&(this.p=e.settings.appCheckToken)}start(e,t){J(this.o===void 0,3512);const r=i=>{i.error!=null&&O("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${i.error.message}`);const a=i.token!==this.m;return this.m=i.token,O("FirebaseAppCheckTokenProvider",`Received ${a?"new":"existing"} token.`),a?t(i.token):Promise.resolve()};this.o=i=>{e.enqueueRetryable((()=>r(i)))};const s=i=>{O("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=i,this.o&&this.appCheck.addTokenListener(this.o)};this.V.onInit((i=>s(i))),setTimeout((()=>
1717{if(!this.appCheck){const i=this.V.getImmediate({optional:!0});i?s(i):O("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}}),0)}getToken(){if(this.p)return Promise.resolve(new cu(this.p));const e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then((t=>t?(J(typeof t.token=="string",44558,{tokenResult:t}),this.m=t.token,new cu(t.token)):null)):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.o&&this.appCheck.removeTokenListener(this.o),this.o=void 0}}/** 1718 * @license 1719 * Copyright 2020 Google LLC 1720 * 1721 * Licensed under the Apache License, Version 2.0 (the "License"); 1722 * you may not use this file except in compliance with the License. 1723 * You may obtain a copy of the License at 1724 * 1725 * http://www.apache.org/licenses/LICENSE-2.0 1726 * 1727 * Unless required by applicable law or agreed to in writing, software 1728 * distributed under the License is distributed on an "AS IS" BASIS, 1729 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1730 * See the License for the specific language governing permissions and 1731 * limitations under the License. 1732 */function M_(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}/** 1733 * @license 1734 * Copyright 2017 Google LLC 1735 * 1736 * Licensed under the Apache License, Version 2.0 (the "License"); 1737 * you may not use this file except in compliance with the License. 1738 * You may obtain a copy of the License at 1739 * 1740 * http://www.apache.org/licenses/LICENSE-2.0 1741 * 1742 * Unless required by applicable law or agreed to in writing, software 1743 * distributed under the License is distributed on an "AS IS" BASIS, 1744 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1745 * See the License for the specific language governing permissions and 1746 * limitations under the License. 1747 */class jo{static newId(){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t=62*Math.floor(4.129032258064516);let r="";for(;r.length<20;){const s=M_(40);for(let i=0;i<s.length;++i)r.length<20&&s[i]<t&&(r+=e.charAt(s[i]%62))}return r}}function G(n,e){return n<e?-1:n>e?1:0}function uo(n,e){const t=Math.min(n.length,e.length);for(let r=0;r<t;r++){const s=n.charAt(r),i=e.charAt(r);if(s!==i)return Ki(s)===Ki(i)?G(s,i):Ki(s)?1:-1}return G(n.length,e.length)}const x_=55296,U_=57343;function Ki(n){const e=n.charCodeAt(0);return e>=x_&&e<=U_}function kn(n,e,t){return n.length===e.length&&n.every(((r,s)=>t(r,e[s])))}/** 1748 * @license 1749 * Copyright 2017 Google LLC 1750 * 1751 * Licensed under the Apache License, Version 2.0 (the "License"); 1752 * you may not use this file except in compliance with the License. 1753 * You may obtain a copy of the License at 1754 * 1755 * http://www.apache.org/licenses/LICENSE-2.0 1756 * 1757 * Unless required by applicable law or agreed to in writing, software 1758 * distributed under the License is distributed on an "AS IS" BASIS, 1759 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1760 * See the License for the specific language governing permissions and 1761 * limitations under the License. 1762 */const uu="__name__";class Je{constructor(e,t,r){t===void 0?t=0:t>e.length&&x(637,{offset:t,range:e.length}),r===void 0?r=e.length-t:r>e.length-t&&x(1746,{length:r,range:e.length-t}),this.segments=e,this.offset=t,this.len=r}get length(){return this.len}isEqual(e){return Je.comparator(this,e)===0}child(e){const t=this.segments.slice(this.offset,this.limit());return e instanceof Je?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=Je.compareSegments(e.get(s),t.get(s));if(i!==0)return i}return G(e.length,t.length)}static compareSegments(e,t){const r=Je.isNumericId(e),s=Je.isNumericId(t);return r&&!s?-1:!r&&s?1:r&&s?Je.extractNumericId(e).compare(Je.extractNumericId(t)):uo(e,t)}static isNumericId(e){return e.startsWith("__id")&&e.endsWith("__")}static extractNumericId(e){return Nt.fromString(e.substring(4,e.length-2))}}class X extends Je{construct(e,t,r){return new X(e,t,r)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}
1762toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...e){const t=[];for(const r of e){if(r.indexOf("//")>=0)throw new V(P.INVALID_ARGUMENT,`Invalid segment (${r}). Paths must not contain // in them.`);t.push(...r.split("/").filter((s=>s.length>0)))}return new X(t)}static emptyPath(){return new X([])}}const F_=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class _e extends Je{construct(e,t,r){return new _e(e,t,r)}static isValidIdentifier(e){return F_.test(e)}canonicalString(){return this.toArray().map((e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),_e.isValidIdentifier(e)||(e="`"+e+"`"),e))).join(".")}toString(){return this.canonicalString()}isKeyField(){return this.length===1&&this.get(0)===uu}static keyField(){return new _e([uu])}static fromServerFormat(e){const t=[];let r="",s=0;const i=()=>{if(r.length===0)throw new V(P.INVALID_ARGUMENT,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);t.push(r),r=""};let a=!1;for(;s<e.length;){const u=e[s];if(u==="\\"){if(s+1===e.length)throw new V(P.INVALID_ARGUMENT,"Path has trailing escape character: "+e);const l=e[s+1];if(l!=="\\"&&l!=="."&&l!=="`")throw new V(P.INVALID_ARGUMENT,"Path has invalid escape sequence: "+e);r+=l,s+=2}else u==="`"?(a=!a,s++):u!=="."||a?(r+=u,s++):(i(),s++)}if(i(),a)throw new V(P.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new _e(t)}static emptyPath(){return new _e([])}}/** 1763 * @license 1764 * Copyright 2017 Google LLC 1765 * 1766 * Licensed under the Apache License, Version 2.0 (the "License"); 1767 * you may not use this file except in compliance with the License. 1768 * You may obtain a copy of the License at 1769 * 1770 * http://www.apache.org/licenses/LICENSE-2.0 1771 * 1772 * Unless required by applicable law or agreed to in writing, software 1773 * distributed under the License is distributed on an "AS IS" BASIS, 1774 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1775 * See the License for the specific language governing permissions and 1776 * limitations under the License. 1777 */class L{constructor(e){this.path=e}static fromPath(e){return new L(X.fromString(e))}static fromName(e){return new L(X.fromString(e).popFirst(5))}static empty(){return new L(X.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&&X.comparator(this.path,e.path)===0}toString(){return this.path.toString()}static comparator(e,t){return X.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new L(new X(e.slice()))}}/** 1778 * @license 1779 * Copyright 2017 Google LLC 1780 * 1781 * Licensed under the Apache License, Version 2.0 (the "License"); 1782 * you may not use this file except in compliance with the License. 1783 * You may obtain a copy of the License at 1784 * 1785 * http://www.apache.org/licenses/LICENSE-2.0 1786 * 1787 * Unless required by applicable law or agreed to in writing, software 1788 * distributed under the License is distributed on an "AS IS" BASIS, 1789 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1790 * See the License for the specific language governing permissions and 1791 * limitations under the License. 1792 */function gh(n,e,t){if(!t)throw new V(P.INVALID_ARGUMENT,`Function ${n}() cannot be called with an empty ${e}.`)}function B_(n,e,t,r){if(e===!0&&r===!0)throw new V(P.INVALID_ARGUMENT,`${n} and ${t} cannot be used together.`)}function lu(n){if(!L.isDocumentKey(n))throw new V(P.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${n} has ${n.length}.`)}function hu(n){if(L.isDocumentKey(n))throw new V(P.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${n} has ${n.length}.`)}function _h(n){return typeof n=="object"&&n!==null&&(Object.getPrototypeOf(n)===Object.prototype||Object.getPrototypeOf(n)===null)}function Zs(n){if(n===void 0)return"undefined";if(n===null)return"null";if(typeof n=="string")return n.length>20&&(n=`${n.substring(0,20)}...`),JSON.stringify(n);if(typeof n=="number"||typeof n=="boolean")return""+n;if(typeof n=="object"){if(n instanceof Array)return"an array";{const e=(function(r){return r.constructor?r.constructor.name:null})(n);return e?`a custom ${e} object`:"an object"}}return typeof n=="function"?"a function":x(12329,{type:typeof n})}function Oe(n,e){if("_delegate"in n&&(n=n._delegate),!(n instanceof e)){if(e.name===n.constructor.name)throw new V(P.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{const t=Zs(n);throw new V(P.INVALID_ARGUMENT,`Expected type '${e.name}', but it was: ${t}`)}}return n}/** 1793 * @license 1794 * Copyright 2025 Google LLC 1795 * 1796 * Licensed under the Apache License, Version 2.0 (the "License");
1797 * you may not use this file except in compliance with the License. 1798 * You may obtain a copy of the License at 1799 * 1800 * http://www.apache.org/licenses/LICENSE-2.0 1801 * 1802 * Unless required by applicable law or agreed to in writing, software 1803 * distributed under the License is distributed on an "AS IS" BASIS, 1804 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1805 * See the License for the specific language governing permissions and 1806 * limitations under the License. 1807 */function he(n,e){const t={typeString:n};return e&&(t.value=e),t}function Mr(n,e){if(!_h(n))throw new V(P.INVALID_ARGUMENT,"JSON must be an object");let t;for(const r in e)if(e[r]){const s=e[r].typeString,i="value"in e[r]?{value:e[r].value}:void 0;if(!(r in n)){t=`JSON missing required field: '${r}'`;break}const a=n[r];if(s&&typeof a!==s){t=`JSON field '${r}' must be a ${s}.`;break}if(i!==void 0&&a!==i.value){t=`Expected '${r}' field to equal '${i.value}'`;break}}if(t)throw new V(P.INVALID_ARGUMENT,t);return!0}/** 1808 * @license 1809 * Copyright 2017 Google LLC 1810 * 1811 * Licensed under the Apache License, Version 2.0 (the "License"); 1812 * you may not use this file except in compliance with the License. 1813 * You may obtain a copy of the License at 1814 * 1815 * http://www.apache.org/licenses/LICENSE-2.0 1816 * 1817 * Unless required by applicable law or agreed to in writing, software 1818 * distributed under the License is distributed on an "AS IS" BASIS, 1819 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1820 * See the License for the specific language governing permissions and 1821 * limitations under the License. 1822 */const du=-62135596800,fu=1e6;class ee{static now(){return ee.fromMillis(Date.now())}static fromDate(e){return ee.fromMillis(e.getTime())}static fromMillis(e){const t=Math.floor(e/1e3),r=Math.floor((e-1e3*t)*fu);return new ee(t,r)}constructor(e,t){if(this.seconds=e,this.nanoseconds=t,t<0)throw new V(P.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(t>=1e9)throw new V(P.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(e<du)throw new V(P.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e);if(e>=253402300800)throw new V(P.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/fu}_compareTo(e){return this.seconds===e.seconds?G(this.nanoseconds,e.nanoseconds):G(this.seconds,e.seconds)}isEqual(e){return e.seconds===this.seconds&&e.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{type:ee._jsonSchemaVersion,seconds:this.seconds,nanoseconds:this.nanoseconds}}static fromJSON(e){if(Mr(e,ee._jsonSchema))return new ee(e.seconds,e.nanoseconds)}valueOf(){const e=this.seconds-du;return String(e).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}ee._jsonSchemaVersion="firestore/timestamp/1.0",ee._jsonSchema={type:he("string",ee._jsonSchemaVersion),seconds:he("number"),nanoseconds:he("number")};/** 1823 * @license 1824 * Copyright 2017 Google LLC 1825 * 1826 * Licensed under the Apache License, Version 2.0 (the "License"); 1827 * you may not use this file except in compliance with the License. 1828 * You may obtain a copy of the License at 1829 * 1830 * http://www.apache.org/licenses/LICENSE-2.0 1831 * 1832 * Unless required by applicable law or agreed to in writing, software 1833 * distributed under the License is distributed on an "AS IS" BASIS, 1834 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1835 * See the License for the specific language governing permissions and 1836 * limitations under the License. 1837 */class U{static fromTimestamp(e){return new U(e)}static min(){return new U(new ee(0,0))}static max(){return new U(new ee(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}}/** 1838 * @license 1839 * Copyright 2021 Google LLC 1840 * 1841 * Licensed under the Apache License, Version 2.0 (the "License");
1842 * you may not use this file except in compliance with the License. 1843 * You may obtain a copy of the License at 1844 * 1845 * http://www.apache.org/licenses/LICENSE-2.0 1846 * 1847 * Unless required by applicable law or agreed to in writing, software 1848 * distributed under the License is distributed on an "AS IS" BASIS, 1849 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1850 * See the License for the specific language governing permissions and 1851 * limitations under the License. 1852 */const wr=-1;function q_(n,e){const t=n.toTimestamp().seconds,r=n.toTimestamp().nanoseconds+1,s=U.fromTimestamp(r===1e9?new ee(t+1,0):new ee(t,r));return new Lt(s,L.empty(),e)}function $_(n){return new Lt(n.readTime,n.key,wr)}class Lt{constructor(e,t,r){this.readTime=e,this.documentKey=t,this.largestBatchId=r}static min(){return new Lt(U.min(),L.empty(),wr)}static max(){return new Lt(U.max(),L.empty(),wr)}}function j_(n,e){let t=n.readTime.compareTo(e.readTime);return t!==0?t:(t=L.comparator(n.documentKey,e.documentKey),t!==0?t:G(n.largestBatchId,e.largestBatchId))}/** 1853 * @license 1854 * Copyright 2020 Google LLC 1855 * 1856 * Licensed under the Apache License, Version 2.0 (the "License"); 1857 * you may not use this file except in compliance with the License. 1858 * You may obtain a copy of the License at 1859 * 1860 * http://www.apache.org/licenses/LICENSE-2.0 1861 * 1862 * Unless required by applicable law or agreed to in writing, software 1863 * distributed under the License is distributed on an "AS IS" BASIS, 1864 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1865 * See the License for the specific language governing permissions and 1866 * limitations under the License. 1867 */const H_="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class z_{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach((e=>e()))}}/** 1868 * @license 1869 * Copyright 2017 Google LLC 1870 * 1871 * Licensed under the Apache License, Version 2.0 (the "License"); 1872 * you may not use this file except in compliance with the License. 1873 * You may obtain a copy of the License at 1874 * 1875 * http://www.apache.org/licenses/LICENSE-2.0 1876 * 1877 * Unless required by applicable law or agreed to in writing, software 1878 * distributed under the License is distributed on an "AS IS" BASIS, 1879 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1880 * See the License for the specific language governing permissions and 1881 * limitations under the License. 1882 */async function Un(n){if(n.code!==P.FAILED_PRECONDITION||n.message!==H_)throw n;O("LocalStore","Unexpectedly lost primary lease")}/** 1883 * @license 1884 * Copyright 2017 Google LLC 1885 * 1886 * Licensed under the Apache License, Version 2.0 (the "License"); 1887 * you may not use this file except in compliance with the License. 1888 * You may obtain a copy of the License at 1889 * 1890 * http://www.apache.org/licenses/LICENSE-2.0 1891 * 1892 * Unless required by applicable law or agreed to in writing, software 1893 * distributed under the License is distributed on an "AS IS" BASIS, 1894 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1895 * See the License for the specific language governing permissions and 1896 * limitations under the License. 1897 */class b{constructor(e){this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,e((t=>{this.isDone=!0,this.result=t,this.nextCallback&&this.nextCallback(t)}),(t=>{this.isDone=!0,this.error=t,this.catchCallback&&this.catchCallback(t)}))}catch(e){return this.next(void 0,e)}next(e,t){return this.callbackAttached&&x(59440),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(t,this.error):this.wrapSuccess(e,this.result):new b(((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 b?t:b.resolve(t)}catch(t){return b.reject(t)}}wrapSuccess(e,t){return e?this.wrapUserFunction((()=>e(t))):b.resolve(t)}wrapFailure(e,t){return e?this.wrapUserFunction((()=>e(t))):b.reject(t)}static resolve(e){return new b(((t,r)=>{t(e)}))}static reject(e){return new b(((t,r)=>{r(e)}))}static waitFor(e){return new b(((t,r)=>{let s=0,i=0,a=!1;e.forEach((u=>{++s,u.next((()=>{++i,a&&i===s&&t()}),(l=>r(l)))})),a=!0,i===s&&t()}))}static or(e){let t=b.resolve(!1);for(const r of e)t=t.next((s=>s?b.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 b(((r,s)=>{const i=e.length,a=new Array(i);let u=0;for(let l=0;l<i;l++){const d=l;t(e[d]).next((f=>{a[d]=f,++u,u===i&&r(a)}),(f=>s(f)))}}))}static doWhile(e,t){return new b(((r,s)=>{const i=()=>{e()===!0?t().next((()=>{i()}),s):r()};i()}))}}function G_(n){const e=n.match(/Android ([\d.]+)/i),t=e?e[1].split(".").slice(0,2).join("."):"-1";return Number(t)}function Fn(n){return n.name==="IndexedDbTransactionError"}/** 1898 * @license 1899 * Copyright 2018 Google LLC 1900 * 1901 * Licensed under the Apache License, Version 2.0 (the "License");
1902 * you may not use this file except in compliance with the License. 1903 * You may obtain a copy of the License at 1904 * 1905 * http://www.apache.org/licenses/LICENSE-2.0 1906 * 1907 * Unless required by applicable law or agreed to in writing, software 1908 * distributed under the License is distributed on an "AS IS" BASIS, 1909 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1910 * See the License for the specific language governing permissions and 1911 * limitations under the License. 1912 */class ei{constructor(e,t){this.previousValue=e,t&&(t.sequenceNumberHandler=r=>this.ae(r),this.ue=r=>t.writeSequenceNumber(r))}ae(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}next(){const e=++this.previousValue;return this.ue&&this.ue(e),e}}ei.ce=-1;/** 1913 * @license 1914 * Copyright 2017 Google LLC 1915 * 1916 * Licensed under the Apache License, Version 2.0 (the "License"); 1917 * you may not use this file except in compliance with the License. 1918 * You may obtain a copy of the License at 1919 * 1920 * http://www.apache.org/licenses/LICENSE-2.0 1921 * 1922 * Unless required by applicable law or agreed to in writing, software 1923 * distributed under the License is distributed on an "AS IS" BASIS, 1924 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1925 * See the License for the specific language governing permissions and 1926 * limitations under the License. 1927 */const Ho=-1;function ti(n){return n==null}function Ns(n){return n===0&&1/n==-1/0}function W_(n){return typeof n=="number"&&Number.isInteger(n)&&!Ns(n)&&n<=Number.MAX_SAFE_INTEGER&&n>=Number.MIN_SAFE_INTEGER}/** 1928 * @license 1929 * Copyright 2017 Google LLC 1930 * 1931 * Licensed under the Apache License, Version 2.0 (the "License"); 1932 * you may not use this file except in compliance with the License. 1933 * You may obtain a copy of the License at 1934 * 1935 * http://www.apache.org/licenses/LICENSE-2.0 1936 * 1937 * Unless required by applicable law or agreed to in writing, software 1938 * distributed under the License is distributed on an "AS IS" BASIS, 1939 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1940 * See the License for the specific language governing permissions and 1941 * limitations under the License. 1942 */const yh="�";function K_(n){let e="";for(let t=0;t<n.length;t++)e.length>0&&(e=pu(e)),e=Q_(n.get(t),e);return pu(e)}function Q_(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 yh:t+="��";break;default:t+=i}}return t}function pu(n){return n+yh+"�"}/** 1943 * @license 1944 * Copyright 2017 Google LLC 1945 * 1946 * Licensed under the Apache License, Version 2.0 (the "License"); 1947 * you may not use this file except in compliance with the License. 1948 * You may obtain a copy of the License at 1949 * 1950 * http://www.apache.org/licenses/LICENSE-2.0 1951 * 1952 * Unless required by applicable law or agreed to in writing, software 1953 * distributed under the License is distributed on an "AS IS" BASIS, 1954 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1955 * See the License for the specific language governing permissions and 1956 * limitations under the License. 1957 */function mu(n){let e=0;for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&e++;return e}function qt(n,e){for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&e(t,n[t])}function Eh(n){for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e))return!1;return!0}/** 1958 * @license 1959 * Copyright 2017 Google LLC 1960 * 1961 * Licensed under the Apache License, Version 2.0 (the "License"); 1962 * you may not use this file except in compliance with the License. 1963 * You may obtain a copy of the License at 1964 * 1965 * http://www.apache.org/licenses/LICENSE-2.0 1966 * 1967 * Unless required by applicable law or agreed to in writing, software 1968 * distributed under the License is distributed on an "AS IS" BASIS, 1969 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1970 * See the License for the specific language governing permissions and 1971 * limitations under the License. 1972 */class re{constructor(e,t){this.comparator=e,this.root=t||ge.EMPTY}insert(e,t){return new re(this.comparator,this.root.insert(e,t,this.comparator).copy(null,null,ge.BLACK,null,
1972null))}remove(e){return new re(this.comparator,this.root.remove(e,this.comparator).copy(null,null,ge.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 os(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new os(this.root,e,this.comparator,!1)}getReverseIterator(){return new os(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new os(this.root,e,this.comparator,!0)}}class os{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 ge{constructor(e,t,r,s,i){this.key=e,this.value=t,this.color=r??ge.RED,this.left=s??ge.EMPTY,this.right=i??ge.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,t,r,s,i){return new ge(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 ge.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 ge.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,ge.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){const e=this.copy(null,null,ge.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip(){const e=this.left.copy(null,null,!this.left.color,null,null),t=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,t)}checkMaxDepth(){const e=this.check();return Math.pow(2,e)<=this.size+1}check(){if(this.isRed()&&this.left.isRed())throw x(43730,{key:this.key,value:this.value});if(this.right.isRed())throw x(14113,{key:this.key,value:this.value});const e=this.left.check();if(e!==this.right.check())throw x(27949);return e+(this.isRed()?0:1)}}ge.EMPTY=null,ge.RED=!0,ge.BLACK=!1;
vendor: 4,227 bytes, lines 1972-2016
1972ge.EMPTY=new class{constructor(){this.size=0}get key(){throw x(57766)}get value(){throw x(16141)}get color(){throw x(16727)}get left(){throw x(29726)}get right(){throw x(36894)}copy(e,t,r,s,i){return this}insert(e,t,r){return new ge(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}};/** 1973 * @license 1974 * Copyright 2017 Google LLC 1975 * 1976 * Licensed under the Apache License, Version 2.0 (the "License"); 1977 * you may not use this file except in compliance with the License. 1978 * You may obtain a copy of the License at 1979 * 1980 * http://www.apache.org/licenses/LICENSE-2.0 1981 * 1982 * Unless required by applicable law or agreed to in writing, software 1983 * distributed under the License is distributed on an "AS IS" BASIS, 1984 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1985 * See the License for the specific language governing permissions and 1986 * limitations under the License. 1987 */class fe{constructor(e){this.comparator=e,this.data=new re(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 fe)||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 fe(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()}}/** 1988 * @license 1989 * Copyright 2020 Google LLC 1990 * 1991 * Licensed under the Apache License, Version 2.0 (the "License"); 1992 * you may not use this file except in compliance with the License. 1993 * You may obtain a copy of the License at 1994 * 1995 * http://www.apache.org/licenses/LICENSE-2.0 1996 * 1997 * Unless required by applicable law or agreed to in writing, software 1998 * distributed under the License is distributed on an "AS IS" BASIS, 1999 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2000 * See the License for the specific language governing permissions and 2001 * limitations under the License. 2002 */class Me{constructor(e){this.fields=e,e.sort(_e.comparator)}static empty(){return new Me([])}unionWith(e){let t=new fe(_e.comparator);for(const r of this.fields)t=t.add(r);for(const r of e)t=t.add(r);return new Me(t.toArray())}covers(e){for(const t of this.fields)if(t.isPrefixOf(e))return!0;return!1}isEqual(e){return kn(this.fields,e.fields,((t,r)=>t.isEqual(r)))}}/** 2003 * @license 2004 * Copyright 2023 Google LLC 2005 * 2006 * Licensed under the Apache License, Version 2.0 (the "License"); 2007 * you may not use this file except in compliance with the License. 2008 * You may obtain a copy of the License at 2009 * 2010 * http://www.apache.org/licenses/LICENSE-2.0 2011 * 2012 * Unless required by applicable law or agreed to in writing, software 2013 * distributed under the License is distributed on an "AS IS" BASIS, 2014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2015 * See the License for the specific language governing permissions and 2016 * limitations under the License.
2017 */class Th extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}/** 2018 * @license 2019 * Copyright 2020 Google LLC 2020 * 2021 * Licensed under the Apache License, Version 2.0 (the "License"); 2022 * you may not use this file except in compliance with the License. 2023 * You may obtain a copy of the License at 2024 * 2025 * http://www.apache.org/licenses/LICENSE-2.0 2026 * 2027 * Unless required by applicable law or agreed to in writing, software 2028 * distributed under the License is distributed on an "AS IS" BASIS, 2029 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2030 * See the License for the specific language governing permissions and 2031 * limitations under the License. 2032 */class ye{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 Th("Invalid base64 string: "+i):i}})(e);return new ye(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 ye(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 G(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}}ye.EMPTY_BYTE_STRING=new ye("");const J_=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function Mt(n){if(J(!!n,39018),typeof n=="string"){let e=0;const t=J_.exec(n);if(J(!!t,46558,{timestamp:n}),t[1]){let s=t[1];s=(s+"000000000").substr(0,9),e=Number(s)}const r=new Date(n);return{seconds:Math.floor(r.getTime()/1e3),nanos:e}}return{seconds:ae(n.seconds),nanos:ae(n.nanos)}}function ae(n){return typeof n=="number"?n:typeof n=="string"?Number(n):0}function xt(n){return typeof n=="string"?ye.fromBase64String(n):ye.fromUint8Array(n)}/** 2033 * @license 2034 * Copyright 2020 Google LLC 2035 * 2036 * Licensed under the Apache License, Version 2.0 (the "License"); 2037 * you may not use this file except in compliance with the License. 2038 * You may obtain a copy of the License at 2039 * 2040 * http://www.apache.org/licenses/LICENSE-2.0 2041 * 2042 * Unless required by applicable law or agreed to in writing, software 2043 * distributed under the License is distributed on an "AS IS" BASIS, 2044 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2045 * See the License for the specific language governing permissions and 2046 * limitations under the License. 2047 */const Ih="server_timestamp",wh="__type__",vh="__previous_value__",Ah="__local_write_time__";function zo(n){var t,r;return((r=(((t=n==null?void 0:n.mapValue)==null?void 0:t.fields)||{})[wh])==null?void 0:r.stringValue)===Ih}function ni(n){const e=n.mapValue.fields[vh];return zo(e)?ni(e):e}function vr(n){const e=Mt(n.mapValue.fields[Ah].timestampValue);return new ee(e.seconds,e.nanos)}/** 2048 * @license 2049 * Copyright 2017 Google LLC 2050 * 2051 * Licensed under the Apache License, Version 2.0 (the "License"); 2052 * you may not use this file except in compliance with the License. 2053 * You may obtain a copy of the License at 2054 * 2055 * http://www.apache.org/licenses/LICENSE-2.0 2056 * 2057 * Unless required by applicable law or agreed to in writing, software 2058 * distributed under the License is distributed on an "AS IS" BASIS, 2059 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2060 * See the License for the specific language governing permissions and 2061 * limitations under the License. 2062 */class Y_{constructor(e,t,r,s,i,a,u,l,d,f,m){this.databaseId=e,this.appId=t,this.persistenceKey=r,this.host=s,this.ssl=i,this.forceLongPolling=a,this.autoDetectLongPolling=u,this.longPollingOptions=l,this.useFetchStreams=d,this.isUsingEmulator=f,this.apiKey=m}}const Ds="(default)";class Ar{constructor(e,t){this.projectId=e,this.database=t||Ds}static empty(){return new Ar("","")}get isDefaultDatabase(){return this.database===Ds}isEqual(e){return e instanceof Ar&&e.projectId===this.projectId&&e.database===this.database}}function X_(n,e){if(!Object.prototype.hasOwnProperty.apply(n.options,["projectId"]))throw new V(P.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new Ar(n.options.projectId,e)}/** 2063 * @license 2064 * Copyright 2020 Google LLC 2065 * 2066 * Licensed under the Apache License, Version 2.0 (the "License");
2067 * you may not use this file except in compliance with the License. 2068 * You may obtain a copy of the License at 2069 * 2070 * http://www.apache.org/licenses/LICENSE-2.0 2071 * 2072 * Unless required by applicable law or agreed to in writing, software 2073 * distributed under the License is distributed on an "AS IS" BASIS, 2074 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2075 * See the License for the specific language governing permissions and 2076 * limitations under the License. 2077 */const Rh="__type__",Z_="__max__",as={mapValue:{}},Sh="__vector__",Vs="value";function Ut(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?zo(n)?4:ty(n)?9007199254740991:ey(n)?10:11:x(28295,{value:n})}function it(n,e){if(n===e)return!0;const t=Ut(n);if(t!==Ut(e))return!1;switch(t){case 0:case 9007199254740991:return!0;case 1:return n.booleanValue===e.booleanValue;case 4:return vr(n).isEqual(vr(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=Mt(s.timestampValue),u=Mt(i.timestampValue);return a.seconds===u.seconds&&a.nanos===u.nanos})(n,e);case 5:return n.stringValue===e.stringValue;case 6:return(function(s,i){return xt(s.bytesValue).isEqual(xt(i.bytesValue))})(n,e);case 7:return n.referenceValue===e.referenceValue;case 8:return(function(s,i){return ae(s.geoPointValue.latitude)===ae(i.geoPointValue.latitude)&&ae(s.geoPointValue.longitude)===ae(i.geoPointValue.longitude)})(n,e);case 2:return(function(s,i){if("integerValue"in s&&"integerValue"in i)return ae(s.integerValue)===ae(i.integerValue);if("doubleValue"in s&&"doubleValue"in i){const a=ae(s.doubleValue),u=ae(i.doubleValue);return a===u?Ns(a)===Ns(u):isNaN(a)&&isNaN(u)}return!1})(n,e);case 9:return kn(n.arrayValue.values||[],e.arrayValue.values||[],it);case 10:case 11:return(function(s,i){const a=s.mapValue.fields||{},u=i.mapValue.fields||{};if(mu(a)!==mu(u))return!1;for(const l in a)if(a.hasOwnProperty(l)&&(u[l]===void 0||!it(a[l],u[l])))return!1;return!0})(n,e);default:return x(52216,{left:n})}}function Rr(n,e){return(n.values||[]).find((t=>it(t,e)))!==void 0}function Nn(n,e){if(n===e)return 0;const t=Ut(n),r=Ut(e);if(t!==r)return G(t,r);switch(t){case 0:case 9007199254740991:return 0;case 1:return G(n.booleanValue,e.booleanValue);case 2:return(function(i,a){const u=ae(i.integerValue||i.doubleValue),l=ae(a.integerValue||a.doubleValue);return u<l?-1:u>l?1:u===l?0:isNaN(u)?isNaN(l)?0:-1:1})(n,e);case 3:return _u(n.timestampValue,e.timestampValue);case 4:return _u(vr(n),vr(e));case 5:return uo(n.stringValue,e.stringValue);case 6:return(function(i,a){const u=xt(i),l=xt(a);return u.compareTo(l)})(n.bytesValue,e.bytesValue);case 7:return(function(i,a){const u=i.split("/"),l=a.split("/");for(let d=0;d<u.length&&d<l.length;d++){const f=G(u[d],l[d]);if(f!==0)return f}return G(u.length,l.length)})(n.referenceValue,e.referenceValue);case 8:return(function(i,a){const u=G(ae(i.latitude),ae(a.latitude));return u!==0?u:G(ae(i.longitude),ae(a.longitude))})(n.geoPointValue,e.geoPointValue);case 9:return yu(n.arrayValue,e.arrayValue);case 10:return(function(i,a){var _,S,C,D;const u=i.fields||{},l=a.fields||{},d=(_=u[Vs])==null?void 0:_.arrayValue,f=(S=l[Vs])==null?void 0:S.arrayValue,m=G(((C=d==null?void 0:d.values)==null?void 0:C.length)||0,((D=f==null?void 0:f.values)==null?void 0:D.length)||0);return m!==0?m:yu(d,f)})(n.mapValue,e.mapValue);case 11:return(function(i,a){if(i===as.mapValue&&a===as.mapValue)return 0;if(i===as.mapValue)return 1;if(a===as.mapValue)return-1;const u=i.fields||{},l=Object.keys(u),d=a.fields||{},f=Object.keys(d);l.sort(),f.sort();for(let m=0;m<l.length&&m<f.length;++m){const _=uo(l[m],f[m]);if(_!==0)return _;const S=Nn(u[l[m]],d[f[m]]);if(S!==0)return S}return G(l.length,f.length)})(n.mapValue,e.mapValue);default:throw x(23264,{he:t})}}function _u(n,e){if(typeof n=="string"&&typeof e=="string"&&n.length===e.length)return G(n,e);const t=Mt(n),r=Mt(e),s=G(t.seconds,r.seconds);return s!==0?s:G(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=Nn(t[s],r[s]);if(i)return i}return G(t.length,r.length)}function Dn(n){return lo(n)}function lo(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=Mt(t);return`time(${r.seconds},${r.nanos})`})(n.timestampValue):"stringValue"in n?n.stringValue:"bytesValue"in n?(function(t){return xt(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+=lo(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}:${lo(t.fields[a])}`;return s+"}"})(n.mapValue):x(61005,{value:n})}function _s(n){switch(Ut(n)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:const e=ni(n);return e?16+_s(e):16;case 5:return 2*n.stringValue.length;case 6:return xt(n.bytesValue).approximateByteSize();case 7:return n.referenceValue.length;case 9:return(function(r){return(r.values||[]).reduce(((s,i)=>s+_s(i)),0)})(n.arrayValue);case 10:case 11:return(function(r){let s=0;return qt(r.fields,((i,a)=>{s+=i.length+_s(a)})),s})(n.mapValue);default:throw x(13486,{value:n})}}function Eu(n,e){return{referenceValue:`projects/${n.projectId}/databases/${n.database}/documents/${e.path.canonicalString()}`}}function ho(n){return!!n&&"integerValue"in n}function Go(n){return!!n&&"arrayValue"in n}function Tu(n){return!!n&&"nullValue"in n}function Iu(n){return!!n&&"doubleValue"in n&&isNaN(Number(n.doubleValue))}function ys(n){return!!n&&"mapValue"in n}function ey(n){var t,r;return((r=(((t=n==null?void 0:n.mapValue)==null?void 0:t.fields)||{})[Rh])==null?void 0:r.stringValue)===Sh}function mr(n){if(n.geoPointValue)return{geoPointValue:{...n.geoPointValue}};if(n.timestampValue&&typeof n.timestampValue=="object")return{timestampValue:{...n.timestampValue}};if(n.mapValue){const e={mapValue:{fields:{}}};return qt(n.mapValue.fields,((t,r)=>e.mapValue.fields[t]=mr(r))),e}if(n.arrayValue){const e={arrayValue:{values:[]}};for(let t=0;t<(n.arrayValue.values||[]).length;++t)e.arrayValue.values[t]=mr(n.arrayValue.values[t]);return e}return{...n}}function ty(n){return(((n.mapValue||{}).fields||{}).__type__||{}).stringValue===Z_}/** 2078 * @license 2079 * Copyright 2017 Google LLC 2080 * 2081 * Licensed under the Apache License, Version 2.0 (the "License");
2082 * you may not use this file except in compliance with the License. 2083 * You may obtain a copy of the License at 2084 * 2085 * http://www.apache.org/licenses/LICENSE-2.0 2086 * 2087 * Unless required by applicable law or agreed to in writing, software 2088 * distributed under the License is distributed on an "AS IS" BASIS, 2089 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2090 * See the License for the specific language governing permissions and 2091 * limitations under the License. 2092 */class De{constructor(e){this.value=e}static empty(){return new De({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)],!ys(t))return null;return t=(t.mapValue.fields||{})[e.lastSegment()],t||null}}set(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=mr(t)}setAll(e){let t=_e.emptyPath(),r={},s=[];e.forEach(((a,u)=>{if(!t.isImmediateParentOf(u)){const l=this.getFieldsMap(t);this.applyChanges(l,r,s),r={},s=[],t=u.popLast()}a?r[u.lastSegment()]=mr(a):s.push(u.lastSegment())}));const i=this.getFieldsMap(t);this.applyChanges(i,r,s)}delete(e){const t=this.field(e.popLast());ys(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return it(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)];ys(s)&&s.mapValue.fields||(s={mapValue:{fields:{}}},t.mapValue.fields[e.get(r)]=s),t=s}return t.mapValue.fields}applyChanges(e,t,r){qt(t,((s,i)=>e[s]=i));for(const s of r)delete e[s]}clone(){return new De(mr(this.value))}}function Ph(n){const e=[];return qt(n.fields,((t,r)=>{const s=new _e([t]);if(ys(r)){const i=Ph(r.mapValue).fields;
2092if(i.length===0)e.push(s);else for(const a of i)e.push(s.child(a))}else e.push(s)})),new Me(e)}/** 2093 * @license 2094 * Copyright 2017 Google LLC 2095 * 2096 * Licensed under the Apache License, Version 2.0 (the "License"); 2097 * you may not use this file except in compliance with the License. 2098 * You may obtain a copy of the License at 2099 * 2100 * http://www.apache.org/licenses/LICENSE-2.0 2101 * 2102 * Unless required by applicable law or agreed to in writing, software 2103 * distributed under the License is distributed on an "AS IS" BASIS, 2104 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2105 * See the License for the specific language governing permissions and 2106 * limitations under the License. 2107 */class we{constructor(e,t,r,s,i,a,u){this.key=e,this.documentType=t,this.version=r,this.readTime=s,this.createTime=i,this.data=a,this.documentState=u}static newInvalidDocument(e){return new we(e,0,U.min(),U.min(),U.min(),De.empty(),0)}static newFoundDocument(e,t,r,s){return new we(e,1,t,U.min(),r,s,0)}static newNoDocument(e,t){return new we(e,2,t,U.min(),U.min(),De.empty(),0)}static newUnknownDocument(e,t){return new we(e,3,t,U.min(),U.min(),De.empty(),2)}convertToFoundDocument(e,t){return!this.createTime.isEqual(U.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=De.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=De.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=U.min(),this}setReadTime(e){return this.readTime=e,this}get hasLocalMutations(){return this.documentState===1}get hasCommittedMutations(){return this.documentState===2}get hasPendingWrites(){return this.hasLocalMutations||this.hasCommittedMutations}isValidDocument(){return this.documentType!==0}isFoundDocument(){return this.documentType===1}isNoDocument(){return this.documentType===2}isUnknownDocument(){return this.documentType===3}isEqual(e){return e instanceof we&&this.key.isEqual(e.key)&&this.version.isEqual(e.version)&&this.documentType===e.documentType&&this.documentState===e.documentState&&this.data.isEqual(e.data)}mutableCopy(){return new we(this.key,this.documentType,this.version,this.readTime,this.createTime,this.data.clone(),this.documentState)}toString(){return`Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {createTime: ${this.createTime}}), {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`}}/** 2108 * @license 2109 * Copyright 2022 Google LLC 2110 * 2111 * Licensed under the Apache License, Version 2.0 (the "License"); 2112 * you may not use this file except in compliance with the License. 2113 * You may obtain a copy of the License at 2114 * 2115 * http://www.apache.org/licenses/LICENSE-2.0 2116 * 2117 * Unless required by applicable law or agreed to in writing, software 2118 * distributed under the License is distributed on an "AS IS" BASIS, 2119 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2120 * See the License for the specific language governing permissions and 2121 * limitations under the License. 2122 */class Os{constructor(e,t){this.position=e,this.inclusive=t}}function wu(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=Nn(a,t.data.field(i.field)),i.dir==="desc"&&(r*=-1),r!==0)break}return r}function vu(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(!it(n.position[t],e.position[t]))return!1;return!0}/** 2123 * @license 2124 * Copyright 2022 Google LLC 2125 * 2126 * Licensed under the Apache License, Version 2.0 (the "License"); 2127 * you may not use this file except in compliance with the License. 2128 * You may obtain a copy of the License at 2129 * 2130 * http://www.apache.org/licenses/LICENSE-2.0 2131 * 2132 * Unless required by applicable law or agreed to in writing, softw
2132are 2133 * distributed under the License is distributed on an "AS IS" BASIS, 2134 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2135 * See the License for the specific language governing permissions and 2136 * limitations under the License. 2137 */class Sr{constructor(e,t="asc"){this.field=e,this.dir=t}}function ny(n,e){return n.dir===e.dir&&n.field.isEqual(e.field)}/** 2138 * @license 2139 * Copyright 2022 Google LLC 2140 * 2141 * Licensed under the Apache License, Version 2.0 (the "License"); 2142 * you may not use this file except in compliance with the License. 2143 * You may obtain a copy of the License at 2144 * 2145 * http://www.apache.org/licenses/LICENSE-2.0 2146 * 2147 * Unless required by applicable law or agreed to in writing, software 2148 * distributed under the License is distributed on an "AS IS" BASIS, 2149 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2150 * See the License for the specific language governing permissions and 2151 * limitations under the License. 2152 */class bh{}class le extends bh{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 sy(e,t,r):t==="array-contains"?new ay(e,r):t==="in"?new cy(e,r):t==="not-in"?new uy(e,r):t==="array-contains-any"?new ly(e,r):new le(e,t,r)}static createKeyFieldInFilter(e,t,r){return t==="in"?new iy(e,r):new oy(e,r)}matches(e){const t=e.data.field(this.field);return this.op==="!="?t!==null&&t.nullValue===void 0&&this.matchesComparison(Nn(t,this.value)):t!==null&&Ut(this.value)===Ut(t)&&this.matchesComparison(Nn(t,this.value))}matchesComparison(e){switch(this.op){case"<":return e<0;case"<=":return e<=0;case"==":return e===0;case"!=":return e!==0;case">":return e>0;case">=":return e>=0;default:return x(47266,{operator:this.op})}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class He extends bh{constructor(e,t){super(),this.filters=e,this.op=t,this.Pe=null}static create(e,t){return new He(e,t)}matches(e){return Ch(this)?this.filters.find((t=>!t.matches(e)))===void 0:this.filters.find((t=>t.matches(e)))!==void 0}getFlattenedFilters(){return this.Pe!==null||(this.Pe=this.filters.reduce(((e,t)=>e.concat(t.getFlattenedFilters())),[])),this.Pe}getFilters(){return Object.assign([],this.filters)}}function Ch(n){return n.op==="and"}function kh(n){return ry(n)&&Ch(n)}function ry(n){for(const e of n.filters)if(e instanceof He)return!1;return!0}function fo(n){if(n instanceof le)return n.field.canonicalString()+n.op.toString()+Dn(n.value);if(kh(n))return n.filters.map((e=>fo(e))).join(",");{const e=n.filters.map((t=>fo(t))).join(",");return`${n.op}(${e})`}}function Nh(n,e){return n instanceof le?(function(r,s){return s instanceof le&&r.op===s.op&&r.field.isEqual(s.field)&&it(r.value,s.value)})(n,e):n instanceof He?(function(r,s){return s instanceof He&&r.op===s.op&&r.filters.length===s.filters.length?r.filters.reduce(((i,a,u)=>i&&Nh(a,s.filters[u])),!0):!1})(n,e):void x(19439)}function Dh(n){return n instanceof le?(function(t){return`${t.field.canonicalString()} ${t.op} ${Dn(t.value)}`})(n):n instanceof He?(function(t){return t.op.toString()+" {"+t.getFilters().map(Dh).join(" ,")+"}"})(n):"Filter"}class sy extends le{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 iy extends le{constructor(e,t){super(e,"in",t),this.keys=Vh("in",t)}matches(e){return this.keys.some((t=>t.isEqual(e.key)))}}class oy extends le{constructor(e,t){super(e,"not-in",t),this.keys=Vh("not-in",t)}matches(e){return!this.keys.some((t=>t.isEqual(e.key)))}}function Vh(n,e){var t;return(((t=e.arrayValue)==null?void 0:t.values)||[]).map((r=>L.fromName(r.referenceValue)))}class ay extends le{constructor(e,t){super(e,"array-contains",t)}matches(e){const t=e.data.field(this.field);return Go(t)&&Rr(t.arrayValue,this.value)}}class cy extends le{constructor(e,t){super(e,"in",t)}matches(e){const t=e.data.field(this.field);return t!==null&&Rr(this.value.arrayValue,t)}}class uy extends le{constructor(e,t){super(e,"not-in",t)}matches(e){if(Rr(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const t=e.data.field(this.field);return t!==null&&t.nullValue===void 0&&!Rr(this.value.arrayValue,t)}}class ly extends le{constructor(e,t){super(e,"array-contains-any",t)}matches(e){const t=e.data.field(this.field);return!(!Go(t)||!t.arrayValue.values)&&t.arrayValue.values.some((r=>Rr(this.value.arrayValue,r)))}}/** 2153 * @license 2154 * Copyright 2019 Google LLC 2155 * 2156 * Licensed under the Apache License, Version 2.0 (the "License");
2157 * you may not use this file except in compliance with the License. 2158 * You may obtain a copy of the License at 2159 * 2160 * http://www.apache.org/licenses/LICENSE-2.0 2161 * 2162 * Unless required by applicable law or agreed to in writing, software 2163 * distributed under the License is distributed on an "AS IS" BASIS, 2164 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2165 * See the License for the specific language governing permissions and 2166 * limitations under the License. 2167 */class hy{constructor(e,t=null,r=[],s=[],i=null,a=null,u=null){this.path=e,this.collectionGroup=t,this.orderBy=r,this.filters=s,this.limit=i,this.startAt=a,this.endAt=u,this.Te=null}}function Au(n,e=null,t=[],r=[],s=null,i=null,a=null){return new hy(n,e,t,r,s,i,a)}function Wo(n){const e=B(n);if(e.Te===null){let t=e.path.canonicalString();e.collectionGroup!==null&&(t+="|cg:"+e.collectionGroup),t+="|f:",t+=e.filters.map((r=>fo(r))).join(","),t+="|ob:",t+=e.orderBy.map((r=>(function(i){return i.field.canonicalString()+i.dir})(r))).join(","),ti(e.limit)||(t+="|l:",t+=e.limit),e.startAt&&(t+="|lb:",t+=e.startAt.inclusive?"b:":"a:",t+=e.startAt.position.map((r=>Dn(r))).join(",")),e.endAt&&(t+="|ub:",t+=e.endAt.inclusive?"a:":"b:",t+=e.endAt.position.map((r=>Dn(r))).join(",")),e.Te=t}return e.Te}function Ko(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(!ny(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(!Nh(n.filters[t],e.filters[t]))return!1;return n.collectionGroup===e.collectionGroup&&!!n.path.isEqual(e.path)&&!!vu(n.startAt,e.startAt)&&vu(n.endAt,e.endAt)}function po(n){return L.isDocumentKey(n.path)&&n.collectionGroup===null&&n.filters.length===0}/** 2168 * @license 2169 * Copyright 2017 Google LLC 2170 * 2171 * Licensed under the Apache License, Version 2.0 (the "License"); 2172 * you may not use this file except in compliance with the License. 2173 * You may obtain a copy of the License at 2174 * 2175 * http://www.apache.org/licenses/LICENSE-2.0 2176 * 2177 * Unless required by applicable law or agreed to in writing, software 2178 * distributed under the License is distributed on an "AS IS" BASIS, 2179 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2180 * See the License for the specific language governing permissions and 2181 * limitations under the License. 2182 */class Bn{constructor(e,t=null,r=[],s=[],i=null,a="F",u=null,l=null){this.path=e,this.collectionGroup=t,this.explicitOrderBy=r,this.filters=s,this.limit=i,this.limitType=a,this.startAt=u,this.endAt=l,this.Ie=null,this.Ee=null,this.Re=null,this.startAt,this.endAt}}function dy(n,e,t,r,s,i,a,u){return new Bn(n,e,t,r,s,i,a,u)}function ri(n){return new Bn(n)}function Ru(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 fy(n){return L.isDocumentKey(n.path)&&n.collectionGroup===null&&n.filters.length===0}function Oh(n){return n.collectionGroup!==null}function gr(n){const e=B(n);if(e.Ie===null){e.Ie=[];const t=new Set;for(const i of e.explicitOrderBy)e.Ie.push(i),t.add(i.field.canonicalString());const r=e.explicitOrderBy.length>0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";(function(a){let u=new fe(_e.comparator);return a.filters.forEach((l=>{l.getFlattenedFilters().forEach((d=>{d.isInequality()&&(u=u.add(d.field))}))})),u})(e).forEach((i=>{t.has(i.canonicalString())||i.isKeyField()||e.Ie.push(new Sr(i,r))})),t.has(_e.keyField().canonicalString())||e.Ie.push(new Sr(_e.keyField(),r))}return e.Ie}function tt(n){const e=B(n);return e.Ee||(e.Ee=py(e,gr(n))),e.Ee}function py(n,e){if(n.limitType==="F")return Au(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 Sr(s.field,i)}));const t=n.endAt?new Os(n.endAt.position,n.endAt.inclusive):null,r=n.startAt?new Os(n.startAt.position,n.startAt.inclusive):null;return Au(n.path,n.collectionGroup,e,n.filters,n.limit,t,r)}}function mo(n,e){const t=n.filters.concat([e]);return new Bn(n.path,n.collectionGroup,n.explicitOrderBy.slice(),t,n.limit,n.limitType,n.startAt,n.endAt)}function my(n,e){const t=n.explicitOrderBy.concat([e]);return new Bn(n.path,n.collectionGroup,t,n.filters.slice(),n.limit,n.limitType,n.startAt,n.endAt)}function go(n,e,t){return new Bn(n.path,n.collectionGroup,n.explicitOrderBy.slice(),n.filters.slice(),e,t,n.startAt,n.endAt)}function si(n,e){return Ko(tt(n),tt(e))&&n.limitType===e.limitType}function Lh(n){return`${Wo(tt(n))}|lt:${n.limitType}`}function En(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=>Dh(s))).join(", ")}]`),ti(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=>Dn(s))).join(",")),t.endAt&&(r+=", endAt: ",r+=t.endAt.inclusive?"a:":"b:",r+=t.endAt.position.map((s=>Dn(s))).join(",")),`Target(${r})`})(tt(n))}; limitType=${n.limitType})`}
2182function ii(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 gr(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,u,l){const d=wu(a,u,l);return a.inclusive?d<=0:d<0})(r.startAt,gr(r),s)||r.endAt&&!(function(a,u,l){const d=wu(a,u,l);return a.inclusive?d>=0:d>0})(r.endAt,gr(r),s))})(n,e)}function gy(n){return n.collectionGroup||(n.path.length%2==1?n.path.lastSegment():n.path.get(n.path.length-2))}function Mh(n){return(e,t)=>{let r=!1;for(const s of gr(n)){const i=_y(s,e,t);if(i!==0)return i;r=r||s.field.isKeyField()}return 0}}function _y(n,e,t){const r=n.field.isKeyField()?L.comparator(e.key,t.key):(function(i,a,u){const l=a.data.field(i),d=u.data.field(i);return l!==null&&d!==null?Nn(l,d):x(42886)})(n.field,e,t);switch(n.dir){case"asc":return r;case"desc":return-1*r;default:return x(19790,{direction:n.dir})}}/** 2183 * @license 2184 * Copyright 2017 Google LLC 2185 * 2186 * Licensed under the Apache License, Version 2.0 (the "License"); 2187 * you may not use this file except in compliance with the License. 2188 * You may obtain a copy of the License at 2189 * 2190 * http://www.apache.org/licenses/LICENSE-2.0 2191 * 2192 * Unless required by applicable law or agreed to in writing, software 2193 * distributed under the License is distributed on an "AS IS" BASIS, 2194 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2195 * See the License for the specific language governing permissions and 2196 * limitations under the License. 2197 */class hn{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){qt(this.inner,((t,r)=>{for(const[s,i]of r)e(s,i)}))}isEmpty(){return Eh(this.inner)}size(){return this.innerSize}}/** 2198 * @license 2199 * Copyright 2017 Google LLC 2200 * 2201 * Licensed under the Apache License, Version 2.0 (the "License"); 2202 * you may not use this file except in compliance with the License. 2203 * You may obtain a copy of the License at 2204 * 2205 * http://www.apache.org/licenses/LICENSE-2.0 2206 * 2207 * Unless required by applicable law or agreed to in writing, software 2208 * distributed under the License is distributed on an "AS IS" BASIS, 2209 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2210 * See the License for the specific language governing permissions and 2211 * limitations under the License. 2212 */const yy=new re(L.comparator);function mt(){return yy}const xh=new re(L.comparator);function lr(...n){let e=xh;for(const t of n)e=e.insert(t.key,t);return e}function Uh(n){let e=xh;return n.forEach(((t,r)=>e=e.insert(t,r.overlayedDocument))),e}function Xt(){return _r()}function Fh(){return _r()}function _r(){return new hn((n=>n.toString()),((n,e)=>n.isEqual(e)))}const Ey=new re(L.comparator),Ty=new fe(L.comparator);function W(...n){let e=Ty;for(const t of n)e=e.add(t);return e}const Iy=new fe(G);function wy(){return Iy}/** 2213 * @license 2214 * Copyright 2020 Google LLC 2215 * 2216 * Licensed under the Apache License, Version 2.0 (the "License"); 2217 * you may not use this file except in compliance with the License. 2218 * You may obtain a copy of the License at 2219 * 2220 * http://www.apache.org/licenses/LICENSE-2.0 2221 * 2222 * Unless required by applicable law or agreed to in writing, software 2223 * distributed under the License is distributed on an "AS IS" BASIS, 2224 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2225 * See the License for the specific language governing permissions and 2226 * limitations under the License. 2227 */function Qo(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 Bh(n){return{integerValue:""+n}}function vy(n,e){return W_(e)?Bh(e):Qo(n,e)}/** 2228 * @license 2229 * Copyright 2018 Google LLC 2230 * 2231 * Licensed under the Apache License, Version 2.0 (the "License");
2232 * you may not use this file except in compliance with the License. 2233 * You may obtain a copy of the License at 2234 * 2235 * http://www.apache.org/licenses/LICENSE-2.0 2236 * 2237 * Unless required by applicable law or agreed to in writing, software 2238 * distributed under the License is distributed on an "AS IS" BASIS, 2239 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2240 * See the License for the specific language governing permissions and 2241 * limitations under the License. 2242 */class oi{constructor(){this._=void 0}}function Ay(n,e,t){return n instanceof Pr?(function(s,i){const a={fields:{[wh]:{stringValue:Ih},[Ah]:{timestampValue:{seconds:s.seconds,nanos:s.nanoseconds}}}};return i&&zo(i)&&(i=ni(i)),i&&(a.fields[vh]=i),{mapValue:a}})(t,e):n instanceof br?$h(n,e):n instanceof Cr?jh(n,e):(function(s,i){const a=qh(s,i),u=Su(a)+Su(s.Ae);return ho(a)&&ho(s.Ae)?Bh(u):Qo(s.serializer,u)})(n,e)}function Ry(n,e,t){return n instanceof br?$h(n,e):n instanceof Cr?jh(n,e):t}function qh(n,e){return n instanceof Ls?(function(r){return ho(r)||(function(i){return!!i&&"doubleValue"in i})(r)})(e)?e:{integerValue:0}:null}class Pr extends oi{}class br extends oi{constructor(e){super(),this.elements=e}}function $h(n,e){const t=Hh(e);for(const r of n.elements)t.some((s=>it(s,r)))||t.push(r);return{arrayValue:{values:t}}}class Cr extends oi{constructor(e){super(),this.elements=e}}function jh(n,e){let t=Hh(e);for(const r of n.elements)t=t.filter((s=>!it(s,r)));return{arrayValue:{values:t}}}class Ls extends oi{constructor(e,t){super(),this.serializer=e,this.Ae=t}}function Su(n){return ae(n.integerValue||n.doubleValue)}function Hh(n){return Go(n)&&n.arrayValue.values?n.arrayValue.values.slice():[]}/** 2243 * @license 2244 * Copyright 2017 Google LLC 2245 * 2246 * Licensed under the Apache License, Version 2.0 (the "License"); 2247 * you may not use this file except in compliance with the License. 2248 * You may obtain a copy of the License at 2249 * 2250 * http://www.apache.org/licenses/LICENSE-2.0 2251 * 2252 * Unless required by applicable law or agreed to in writing, software 2253 * distributed under the License is distributed on an "AS IS" BASIS, 2254 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2255 * See the License for the specific language governing permissions and 2256 * limitations under the License. 2257 */class Sy{constructor(e,t){this.field=e,this.transform=t}}function Py(n,e){return n.field.isEqual(e.field)&&(function(r,s){return r instanceof br&&s instanceof br||r instanceof Cr&&s instanceof Cr?kn(r.elements,s.elements,it):r instanceof Ls&&s instanceof Ls?it(r.Ae,s.Ae):r instanceof Pr&&s instanceof Pr})(n.transform,e.transform)}class by{constructor(e,t){this.version=e,this.transformResults=t}}class Fe{constructor(e,t){this.updateTime=e,this.exists=t}static none(){return new Fe}static exists(e){return new Fe(void 0,e)}static updateTime(e){return new Fe(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 Es(n,e){return n.updateTime!==void 0?e.isFoundDocument()&&e.version.isEqual(n.updateTime):n.exists===void 0||n.exists===e.isFoundDocument()}class ai{}function zh(n,e){if(!n.hasLocalMutations||e&&e.fields.length===0)return null;if(e===null)return n.isNoDocument()?new Jo(n.key,Fe.none()):new xr(n.key,n.data,Fe.none());{const t=n.data,r=De.empty();let s=new fe(_e.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 $t(n.key,r,new Me(s.toArray()),Fe.none())}}function Cy(n,e,t){n instanceof xr?(function(s,i,a){const u=s.value.clone(),l=bu(s.fieldTransforms,i,a.transformResults);u.setAll(l),i.convertToFoundDocument(a.version,u).setHasCommittedMutations()})(n,e,t):n instanceof $t?(function(s,i,a){if(!Es(s.precondition,i))return void i.convertToUnknownDocument(a.version);const u=bu(s.fieldTransforms,i,a.transformResults),l=i.data;l.setAll(Gh(s)),l.setAll(u),i.convertToFoundDocument(a.version,l).setHasCommittedMutations()})(n,e,t):(function(s,i,a){i.convertToNoDocument(a.version).setHasCommittedMutations()})(0,e,t)}function yr(n,e,t,r){return n instanceof xr?(function(i,a,u,l){if(!Es(i.precondition,a))return u;const d=i.value.clone(),f=Cu(i.fieldTransforms,l,a);return d.setAll(f),a.convertToFoundDocument(a.version,d).setHasLocalMutations(),null})(n,e,t,r):n instanceof $t?(function(i,a,u,l){if(!Es(i.precondition,a))return u;const d=Cu(i.fieldTransforms,l,a),f=a.data;return f.setAll(Gh(i)),f.setAll(d),a.convertToFoundDocument(a.version,f).setHasLocalMutations(),u===null?null:u.unionWith(i.fieldMask.fields).unionWith(i.fieldTransforms.map((m=>m.field)))})(n,e,t,r):(function(i,a,u){return Es(i.precondition,a)?(a.convertToNoDocument(a.version).setHasLocalMutations(),null):u})(n,e,t)}function ky(n,e){let t=null;for(const r of n.fieldTransforms){const s=e.data.field(r.field),i=qh(r.transform,s||null);i!=null&&(t===null&&(t=De.empty()),t.set(r.field,i))}return t||null}function Pu(n,e){return n.type===e.type&&!!n.key.isEqual(e.key)&&!!n.prec
2257ondition.isEqual(e.precondition)&&!!(function(r,s){return r===void 0&&s===void 0||!(!r||!s)&&kn(r,s,((i,a)=>Py(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 xr extends ai{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 $t extends ai{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 Gh(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 bu(n,e,t){const r=new Map;J(n.length===t.length,32656,{Ve:t.length,de:n.length});for(let s=0;s<t.length;s++){const i=n[s],a=i.transform,u=e.data.field(i.field);r.set(i.field,Ry(a,u,t[s]))}return r}function Cu(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,Ay(i,a,e))}return r}class Jo extends ai{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}class Ny extends ai{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}}/** 2258 * @license 2259 * Copyright 2017 Google LLC 2260 * 2261 * Licensed under the Apache License, Version 2.0 (the "License"); 2262 * you may not use this file except in compliance with the License. 2263 * You may obtain a copy of the License at 2264 * 2265 * http://www.apache.org/licenses/LICENSE-2.0 2266 * 2267 * Unless required by applicable law or agreed to in writing, software 2268 * distributed under the License is distributed on an "AS IS" BASIS, 2269 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2270 * See the License for the specific language governing permissions and 2271 * limitations under the License. 2272 */class Dy{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)&&Cy(i,e,r[s])}}applyToLocalView(e,t){for(const r of this.baseMutations)r.key.isEqual(e.key)&&(t=yr(r,e,t,this.localWriteTime));for(const r of this.mutations)r.key.isEqual(e.key)&&(t=yr(r,e,t,this.localWriteTime));return t}applyToLocalDocumentSet(e,t){const r=Fh();return this.mutations.forEach((s=>{const i=e.get(s.key),a=i.overlayedDocument;let u=this.applyToLocalView(a,i.mutatedFields);u=t.has(s.key)?null:u;const l=zh(a,u);l!==null&&r.set(s.key,l),a.isValidDocument()||a.convertToNoDocument(U.min())})),r}keys(){return this.mutations.reduce(((e,t)=>e.add(t.key)),W())}isEqual(e){return this.batchId===e.batchId&&kn(this.mutations,e.mutations,((t,r)=>Pu(t,r)))&&kn(this.baseMutations,e.baseMutations,((t,r)=>Pu(t,r)))}}class Yo{constructor(e,t,r,s){this.batch=e,this.commitVersion=t,this.mutationResults=r,this.docVersions=s}static from(e,t,r){J(e.mutations.length===r.length,58842,{me:e.mutations.length,fe:r.length});let s=(function(){return Ey})();const i=e.mutations;for(let a=0;a<i.length;a++)s=s.insert(i[a].key,r[a].version);return new Yo(e,t,r,s)}}/** 2273 * @license 2274 * Copyright 2022 Google LLC 2275 * 2276 * Licensed under the Apache License, Version 2.0 (the "License"); 2277 * you may not use this file except in compliance with the License. 2278 * You may obtain a copy of the License at 2279 * 2280 * http://www.apache.org/licenses/LICENSE-2.0 2281 * 2282 * Unless required by applicable law or agreed to in writing, software 2283 * distributed under the License is distributed on an "AS IS" BASIS, 2284 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2285 * See the License for the specific language governing permissions and 2286 * limitations under the License. 2287 */class Vy{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{ 2288 largestBatchId: ${this.largestBatchId}, 2289 mutation: ${this.mutation.toString()} 2290 }`}}/** 2291 * @license 2292 * Copyright 2017 Google LLC 2293 * 2294 * Licensed under the Apache License, Version 2.0 (the "License");
2295 * you may not use this file except in compliance with the License. 2296 * You may obtain a copy of the License at 2297 * 2298 * http://www.apache.org/licenses/LICENSE-2.0 2299 * 2300 * Unless required by applicable law or agreed to in writing, software 2301 * distributed under the License is distributed on an "AS IS" BASIS, 2302 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2303 * See the License for the specific language governing permissions and 2304 * limitations under the License. 2305 */class Oy{constructor(e,t){this.count=e,this.unchangedNames=t}}/** 2306 * @license 2307 * Copyright 2017 Google LLC 2308 * 2309 * Licensed under the Apache License, Version 2.0 (the "License"); 2310 * you may not use this file except in compliance with the License. 2311 * You may obtain a copy of the License at 2312 * 2313 * http://www.apache.org/licenses/LICENSE-2.0 2314 * 2315 * Unless required by applicable law or agreed to in writing, software 2316 * distributed under the License is distributed on an "AS IS" BASIS, 2317 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2318 * See the License for the specific language governing permissions and 2319 * limitations under the License. 2320 */var ue,K;function Ly(n){switch(n){case P.OK:return x(64938);case P.CANCELLED:case P.UNKNOWN:case P.DEADLINE_EXCEEDED:case P.RESOURCE_EXHAUSTED:case P.INTERNAL:case P.UNAVAILABLE:case P.UNAUTHENTICATED:return!1;case P.INVALID_ARGUMENT:case P.NOT_FOUND:case P.ALREADY_EXISTS:case P.PERMISSION_DENIED:case P.FAILED_PRECONDITION:case P.ABORTED:case P.OUT_OF_RANGE:case P.UNIMPLEMENTED:case P.DATA_LOSS:return!0;default:return x(15467,{code:n})}}function Wh(n){if(n===void 0)return pt("GRPC error has no .code"),P.UNKNOWN;switch(n){case ue.OK:return P.OK;case ue.CANCELLED:return P.CANCELLED;case ue.UNKNOWN:return P.UNKNOWN;case ue.DEADLINE_EXCEEDED:return P.DEADLINE_EXCEEDED;case ue.RESOURCE_EXHAUSTED:return P.RESOURCE_EXHAUSTED;case ue.INTERNAL:return P.INTERNAL;case ue.UNAVAILABLE:return P.UNAVAILABLE;case ue.UNAUTHENTICATED:return P.UNAUTHENTICATED;case ue.INVALID_ARGUMENT:return P.INVALID_ARGUMENT;case ue.NOT_FOUND:return P.NOT_FOUND;case ue.ALREADY_EXISTS:return P.ALREADY_EXISTS;case ue.PERMISSION_DENIED:return P.PERMISSION_DENIED;case ue.FAILED_PRECONDITION:return P.FAILED_PRECONDITION;case ue.ABORTED:return P.ABORTED;case ue.OUT_OF_RANGE:return P.OUT_OF_RANGE;case ue.UNIMPLEMENTED:return P.UNIMPLEMENTED;case ue.DATA_LOSS:return P.DATA_LOSS;default:return x(39323,{code:n})}}(K=ue||(ue={}))[K.OK=0]="OK",K[K.CANCELLED=1]="CANCELLED",K[K.UNKNOWN=2]="UNKNOWN",K[K.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",K[K.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",K[K.NOT_FOUND=5]="NOT_FOUND",K[K.ALREADY_EXISTS=6]="ALREADY_EXISTS",K[K.PERMISSION_DENIED=7]="PERMISSION_DENIED",K[K.UNAUTHENTICATED=16]="UNAUTHENTICATED",K[K.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",K[K.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",K[K.ABORTED=10]="ABORTED",K[K.OUT_OF_RANGE=11]="OUT_OF_RANGE",K[K.UNIMPLEMENTED=12]="UNIMPLEMENTED",K[K.INTERNAL=13]="INTERNAL",K[K.UNAVAILABLE=14]="UNAVAILABLE",K[K.DATA_LOSS=15]="DATA_LOSS";/** 2321 * @license 2322 * Copyright 2023 Google LLC 2323 * 2324 * Licensed under the Apache License, Version 2.0 (the "License"); 2325 * you may not use this file except in compliance with the License. 2326 * You may obtain a copy of the License at 2327 * 2328 * http://www.apache.org/licenses/LICENSE-2.0 2329 * 2330 * Unless required by applicable law or agreed to in writing, software 2331 * distributed under the License is distributed on an "AS IS" BASIS, 2332 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2333 * See the License for the specific language governing permissions and 2334 * limitations under the License. 2335 */function My(){return new TextEncoder}/** 2336 * @license 2337 * Copyright 2022 Google LLC 2338 * 2339 * Licensed under the Apache License, Version 2.0 (the "License"); 2340 * you may not use this file except in compliance with the License. 2341 * You may obtain a copy of the License at 2342 * 2343 * http://www.apache.org/licenses/LICENSE-2.0 2344 * 2345 * Unless required by applicable law or agreed to in writing, software 2346 * distributed under the License is distributed on an "AS IS" BASIS, 2347 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2348 * See the License for the specific language governing permissions and 2349 * limitations under the License. 2350 */const xy=new Nt([4294967295,4294967295],0);function ku(n){const e=My().encode(n),t=new ch;return t.update(e),new Uint8Array(t.digest())}function Nu(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);
2350return[new Nt([t,r],0),new Nt([s,i],0)]}class Xo{constructor(e,t,r){if(this.bitmap=e,this.padding=t,this.hashCount=r,t<0||t>=8)throw new hr(`Invalid padding: ${t}`);if(r<0)throw new hr(`Invalid hash count: ${r}`);if(e.length>0&&this.hashCount===0)throw new hr(`Invalid hash count: ${r}`);if(e.length===0&&t!==0)throw new hr(`Invalid padding when bitmap length is 0: ${t}`);this.ge=8*e.length-t,this.pe=Nt.fromNumber(this.ge)}ye(e,t,r){let s=e.add(t.multiply(Nt.fromNumber(r)));return s.compare(xy)===1&&(s=new Nt([s.getBits(0),s.getBits(1)],0)),s.modulo(this.pe).toNumber()}we(e){return!!(this.bitmap[Math.floor(e/8)]&1<<e%8)}mightContain(e){if(this.ge===0)return!1;const t=ku(e),[r,s]=Nu(t);for(let i=0;i<this.hashCount;i++){const a=this.ye(r,s,i);if(!this.we(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 Xo(i,s,t);return r.forEach((u=>a.insert(u))),a}insert(e){if(this.ge===0)return;const t=ku(e),[r,s]=Nu(t);for(let i=0;i<this.hashCount;i++){const a=this.ye(r,s,i);this.be(a)}}be(e){const t=Math.floor(e/8),r=e%8;this.bitmap[t]|=1<<r}}class hr extends Error{constructor(){super(...arguments),this.name="BloomFilterError"}}/** 2351 * @license 2352 * Copyright 2017 Google LLC 2353 * 2354 * Licensed under the Apache License, Version 2.0 (the "License"); 2355 * you may not use this file except in compliance with the License. 2356 * You may obtain a copy of the License at 2357 * 2358 * http://www.apache.org/licenses/LICENSE-2.0 2359 * 2360 * Unless required by applicable law or agreed to in writing, software 2361 * distributed under the License is distributed on an "AS IS" BASIS, 2362 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2363 * See the License for the specific language governing permissions and 2364 * limitations under the License. 2365 */class ci{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,Ur.createSynthesizedTargetChangeForCurrentChange(e,t,r)),new ci(U.min(),s,new re(G),mt(),W())}}class Ur{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 Ur(r,t,W(),W(),W())}}/** 2366 * @license 2367 * Copyright 2017 Google LLC 2368 * 2369 * Licensed under the Apache License, Version 2.0 (the "License"); 2370 * you may not use this file except in compliance with the License. 2371 * You may obtain a copy of the License at 2372 * 2373 * http://www.apache.org/licenses/LICENSE-2.0 2374 * 2375 * Unless required by applicable law or agreed to in writing, software 2376 * distributed under the License is distributed on an "AS IS" BASIS, 2377 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2378 * See the License for the specific language governing permissions and 2379 * limitations under the License. 2380 */class Ts{constructor(e,t,r,s){this.Se=e,this.removedTargetIds=t,this.key=r,this.De=s}}class Kh{constructor(e,t){this.targetId=e,this.Ce=t}}class Qh{constructor(e,t,r=ye.EMPTY_BYTE_STRING,s=null){this.state=e,this.targetIds=t,this.resumeToken=r,this.cause=s}}class Du{constructor(){this.ve=0,this.Fe=Vu(),this.Me=ye.EMPTY_BYTE_STRING,this.xe=!1,this.Oe=!0}get current(){return this.xe}get resumeToken(){return this.Me}get Ne(){return this.ve!==0}get Be(){return this.Oe}Le(e){e.approximateByteSize()>0&&(this.Oe=!0,this.Me=e)}ke(){let e=W(),t=W(),r=W();return this.Fe.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:x(38017,{changeType:i})}})),new Ur(this.Me,this.xe,e,t,r)}Ke(){this.Oe=!1,this.Fe=Vu()}qe(e,t){this.Oe=!0,this.Fe=this.Fe.insert(e,t)}Ue(e){this.Oe=!0,this.Fe=this.Fe.remove(e)}$e(){this.ve+=1}We(){this.ve-=1,J(this.ve>=0,3241,{ve:this.ve})}Qe(){this.Oe=!0,this.xe=!0}}class Uy{constructor(e){this.Ge=e,this.ze=new Map,this.je=mt(),this.He=cs(),this.Je=cs(),this.Ze=new re(G)}Xe(e){for(const t of e.Se)e.De&&e.De.isFoundDocument()?this.Ye(t,e.De):this.et(t,e.key,e.De);for(const t of e.removedTargetIds)this.et(t,e.key,e.De)}tt(e){this.forEachTarget(e,(t=>{const r=this.nt(t);switch(e.state){case 0:this.rt(t)&&r.Le(e.resumeToken);break;case 1:r.We(),r.Ne||r.Ke(),r.Le(e.resumeToken);break;case 2:r.We(),r.Ne||this.removeTarget(t);break;case 3:this.rt(t)&&(r.Qe(),r.Le(e.resumeToken));break;case 4:this.rt(t)&&(this.it(t),r.Le(e.resumeToken));break;default:x(56790,{state:e.state})}}))}forEachTarget(e,t){e.targetIds.length>0?e.targetIds.forEach(t):this.ze.forEach(((r,s)=>{this.rt(s)&&t(s)}))}st(e){const t=e.targetId,r=e.Ce.count,s=this.ot(t);if(s){const i=s.target;if(po(i))if(r===0){const a=new L(i.path);this.et(t,a,we.newNoDocument(a,U.min()))}else J(r===1,20013,{expectedCount:r});else{const a=this._t(t);if(a!==r){const u=this.ut(e),l=u?this.ct(u,e,a):1;if(l!==0){this.it(t);const d=l===2?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch";this.Ze=this.Ze.insert(t,d)}}}}}ut(e){const t=e.Ce.unchangedNames;if(!t||!t.bits)return null;const{bits:{bitmap:r="",padding:s=0},hashCount:i=0}=t;let a,u;try{a=xt(r).toUint8Array()}catch(l){if(l instanceof Th)return Cn("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{u=new Xo(a,s,i)}catch(l){return Cn(l instanceof hr?"BloomFilter error: ":"Applying bloom filter failed: ",l),null}return u.ge===0?null:u}ct(e,t,r){return t.Ce.count===r-this.Pt(e,t.targetId)?0:2}Pt(e,t){const r=this.Ge.getRemoteKeysForTarget(t);let s=0;return r.forEach((i=>{const a=this.Ge.ht(),u=`projects/${a.projectId}/databases/${a.database}/documents/${i.path.canonicalString()}`;e.mightContain(u)||(this.et(t,i,null),s++)})),s}Tt(e){const t=new Map;this.ze.forEach(((i,a)=>{const u=this.ot(a);if(u){if(i.current&&po(u.target)){const l=new L(u.target.path);this.It(l).has(a)||this.Et(a,l)||this.et(a,l,we.newNoDocument(l,e))}i.Be&&(t.set(a,i.ke()),i.Ke())}}));let r=W();this.Je.forEach(((i,a)=>{let u=!0;a.forEachWhile((l=>{const d=this.ot(l);return!d||d.purpose==="TargetPurposeLimboResolution"||(u=!1,!1)})),u&&(r=r.add(i))})),this.je.forEach(((i,a)=>a.setReadTime(e)));const s=new ci(e,t,this.Ze,this.je,r);return this.je=mt(),this.He=cs(),this.Je=cs(),this.Ze=new re(G),s}Ye(e,t){if(!this.rt(e))return;
2380const r=this.Et(e,t.key)?2:0;this.nt(e).qe(t.key,r),this.je=this.je.insert(t.key,t),this.He=this.He.insert(t.key,this.It(t.key).add(e)),this.Je=this.Je.insert(t.key,this.Rt(t.key).add(e))}et(e,t,r){if(!this.rt(e))return;const s=this.nt(e);this.Et(e,t)?s.qe(t,1):s.Ue(t),this.Je=this.Je.insert(t,this.Rt(t).delete(e)),this.Je=this.Je.insert(t,this.Rt(t).add(e)),r&&(this.je=this.je.insert(t,r))}removeTarget(e){this.ze.delete(e)}_t(e){const t=this.nt(e).ke();return this.Ge.getRemoteKeysForTarget(e).size+t.addedDocuments.size-t.removedDocuments.size}$e(e){this.nt(e).$e()}nt(e){let t=this.ze.get(e);return t||(t=new Du,this.ze.set(e,t)),t}Rt(e){let t=this.Je.get(e);return t||(t=new fe(G),this.Je=this.Je.insert(e,t)),t}It(e){let t=this.He.get(e);return t||(t=new fe(G),this.He=this.He.insert(e,t)),t}rt(e){const t=this.ot(e)!==null;return t||O("WatchChangeAggregator","Detected inactive target",e),t}ot(e){const t=this.ze.get(e);return t&&t.Ne?null:this.Ge.At(e)}it(e){this.ze.set(e,new Du),this.Ge.getRemoteKeysForTarget(e).forEach((t=>{this.et(e,t,null)}))}Et(e,t){return this.Ge.getRemoteKeysForTarget(e).has(t)}}function cs(){return new re(L.comparator)}function Vu(){return new re(L.comparator)}const Fy={asc:"ASCENDING",desc:"DESCENDING"},By={"<":"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"},qy={and:"AND",or:"OR"};class $y{constructor(e,t){this.databaseId=e,this.useProto3Json=t}}function _o(n,e){return n.useProto3Json||ti(e)?e:{value:e}}function Ms(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 Jh(n,e){return n.useProto3Json?e.toBase64():e.toUint8Array()}function jy(n,e){return Ms(n,e.toTimestamp())}function nt(n){return J(!!n,49232),U.fromTimestamp((function(t){const r=Mt(t);return new ee(r.seconds,r.nanos)})(n))}function Zo(n,e){return yo(n,e).canonicalString()}function yo(n,e){const t=(function(s){return new X(["projects",s.projectId,"databases",s.database])})(n).child("documents");return e===void 0?t:t.child(e)}function Yh(n){const e=X.fromString(n);return J(nd(e),10190,{key:e.toString()}),e}function Eo(n,e){return Zo(n.databaseId,e.path)}function Qi(n,e){const t=Yh(e);if(t.get(1)!==n.databaseId.projectId)throw new V(P.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+t.get(1)+" vs "+n.databaseId.projectId);if(t.get(3)!==n.databaseId.database)throw new V(P.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+t.get(3)+" vs "+n.databaseId.database);return new L(Zh(t))}function Xh(n,e){return Zo(n.databaseId,e)}function Hy(n){const e=Yh(n);return e.length===4?X.emptyPath():Zh(e)}function To(n){return new X(["projects",n.databaseId.projectId,"databases",n.databaseId.database]).canonicalString()}function Zh(n){return J(n.length>4&&n.get(4)==="documents",29091,{key:n.toString()}),n.popFirst(5)}function Ou(n,e,t){return{name:Eo(n,e),fields:t.value.mapValue.fields}}function zy(n,e){let t;if("targetChange"in e){e.targetChange;const r=(function(d){return d==="NO_CHANGE"?0:d==="ADD"?1:d==="REMOVE"?2:d==="CURRENT"?3:d==="RESET"?4:x(39313,{state:d})})(e.targetChange.targetChangeType||"NO_CHANGE"),s=e.targetChange.targetIds||[],i=(function(d,f){return d.useProto3Json?(J(f===void 0||typeof f=="string",58123),ye.fromBase64String(f||"")):(J(f===void 0||f instanceof Buffer||f instanceof Uint8Array,16193),ye.fromUint8Array(f||new Uint8Array))})(n,e.targetChange.resumeToken),a=e.targetChange.cause,u=a&&(function(d){const f=d.code===void 0?P.UNKNOWN:Wh(d.code);return new V(f,d.message||"")})(a);t=new Qh(r,s,i,u||null)}else if("documentChange"in e){e.documentChange;const r=e.documentChange;r.document,r.document.name,r.document.updateTime;const s=Qi(n,r.document.name),i=nt(r.document.updateTime),a=r.document.createTime?nt(r.document.createTime):U.min(),u=new De({mapValue:{fields:r.document.fields}}),l=we.newFoundDocument(s,i,a,u),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=Qi(n,r.document),i=r.readTime?nt(r.readTime):U.min(),a=we.newNoDocument(s,i),u=r.removedTargetIds||[];t=new Ts([],u,a.key,a)}else if("documentRemove"in e){e.documentRemove;const r=e.documentRemove;r.document;const s=Qi(n,r.document),i=r.removedTargetIds||[];t=new Ts([],i,s,null)}else{if(!("filter"in e))return x(11601,{Vt:e});{e.filter;const r=e.filter;r.targetId;const{count:s=0,unchangedNames:i}=r,a=new Oy(s,i),u=r.targetId;t=new Kh(u,a)}}return t}function Gy(n,e){let t;if(e instanceof xr)t={update:Ou(n,e.key,e.value)};else if(e instanceof Jo)t={delete:Eo(n,e.key)};else if(e instanceof $t)t={update:Ou(n,e.key,e.data),updateMask:tE(e.fieldMask)};else{if(!(e instanceof Ny))return x(16599,{dt:e.type});t={verify:Eo(n,e.key)}}return e.fieldTransforms.length>0&&(t.updateTransforms=e.fieldTransforms.map((r=>(function(i,a){const u=a.transform;if(u instanceof Pr)return{fieldPath:a.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(u instanceof br)return{fieldPath:a.field.canonicalString(),appendMissingElements:{values:u.elements}};if(u instanceof Cr)return{fieldPath:a.field.canonicalString(),removeAllFromArray:{values:u.elements}};if(u instanceof Ls)return{fieldPath:a.field.canonicalString(),increment:u.Ae};throw x(20930,{transform:a.transform})})(0,r)))),e.precondition.isNone||(t.currentDocument=(function(s,i){return i.updateTime!==void 0?{updateTime:jy(s,i.updateTime)}:i.exists!==void 0?{exists:i.exists}:x(27497)})(n,e.precondition)),t}function Wy(n,e){return n&&n.length>0?(J(e!==void 0,14353),n.map((t=>(function(s,i){let a=s.updateTime?nt(s.updateTime):nt(i);return a.isEqual(U.min())&&(a=nt(i)),new by(a,s.transformResults||[])})(t,e)))):[]}function Ky(n,e){return{documents:[Xh(n,e.path)]}}function Qy(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=Xh(n,s);const i=(function(d){if(d.length!==0)return td(He.create(d,"and"))})(e.filters);i&&(t.structuredQuery.where=i);const a=(function(d){if(d.length!==0)return d.map((f=>(function(_){return{field:Tn(_.field),direction:Xy(_.dir)}})(f)))})(e.orderBy);a&&(t.structuredQuery.orderBy=a);const u=_o(n,e.limit);return u!==null&&(t.structuredQuery.limit=u),e.startAt&&(t.structuredQuery.startAt=(function(d){return{before:d.inclusive,values:d.position}})(e.startAt)),e.endAt&&(t.structuredQuery.endAt=(function(d){return{before:!d.inclusive,values:d.position}})(e.endAt)),{ft:t,parent:s}}function Jy(n){let e=Hy(n.parent);
2380const t=n.structuredQuery,r=t.from?t.from.length:0;let s=null;if(r>0){J(r===1,65062);const f=t.from[0];f.allDescendants?s=f.collectionId:e=e.child(f.collectionId)}let i=[];t.where&&(i=(function(m){const _=ed(m);return _ instanceof He&&kh(_)?_.getFilters():[_]})(t.where));let a=[];t.orderBy&&(a=(function(m){return m.map((_=>(function(C){return new Sr(In(C.field),(function(k){switch(k){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}})(C.direction))})(_)))})(t.orderBy));let u=null;t.limit&&(u=(function(m){let _;return _=typeof m=="object"?m.value:m,ti(_)?null:_})(t.limit));let l=null;t.startAt&&(l=(function(m){const _=!!m.before,S=m.values||[];return new Os(S,_)})(t.startAt));let d=null;return t.endAt&&(d=(function(m){const _=!m.before,S=m.values||[];return new Os(S,_)})(t.endAt)),dy(e,s,a,i,u,"F",l,d)}function Yy(n,e){const t=(function(s){switch(s){case"TargetPurposeListen":return null;case"TargetPurposeExistenceFilterMismatch":return"existence-filter-mismatch";case"TargetPurposeExistenceFilterMismatchBloom":return"existence-filter-mismatch-bloom";case"TargetPurposeLimboResolution":return"limbo-document";default:return x(28987,{purpose:s})}})(e.purpose);return t==null?null:{"goog-listen-tags":t}}function ed(n){return n.unaryFilter!==void 0?(function(t){switch(t.unaryFilter.op){case"IS_NAN":const r=In(t.unaryFilter.field);return le.create(r,"==",{doubleValue:NaN});case"IS_NULL":const s=In(t.unaryFilter.field);return le.create(s,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":const i=In(t.unaryFilter.field);return le.create(i,"!=",{doubleValue:NaN});case"IS_NOT_NULL":const a=In(t.unaryFilter.field);return le.create(a,"!=",{nullValue:"NULL_VALUE"});case"OPERATOR_UNSPECIFIED":return x(61313);default:return x(60726)}})(n):n.fieldFilter!==void 0?(function(t){return le.create(In(t.fieldFilter.field),(function(s){switch(s){case"EQUAL":return"==";case"NOT_EQUAL":return"!=";case"GREATER_THAN":return">";case"GREATER_THAN_OR_EQUAL":return">=";case"LESS_THAN":return"<";case"LESS_THAN_OR_EQUAL":return"<=";case"ARRAY_CONTAINS":return"array-contains";case"IN":return"in";case"NOT_IN":return"not-in";case"ARRAY_CONTAINS_ANY":return"array-contains-any";case"OPERATOR_UNSPECIFIED":return x(58110);default:return x(50506)}})(t.fieldFilter.op),t.fieldFilter.value)})(n):n.compositeFilter!==void 0?(function(t){return He.create(t.compositeFilter.filters.map((r=>ed(r))),(function(s){switch(s){case"AND":return"and";case"OR":return"or";default:return x(1026)}})(t.compositeFilter.op))})(n):x(30097,{filter:n})}function Xy(n){return Fy[n]}function Zy(n){return By[n]}function eE(n){return qy[n]}function Tn(n){return{fieldPath:n.canonicalString()}}function In(n){return _e.fromServerFormat(n.fieldPath)}function td(n){return n instanceof le?(function(t){if(t.op==="=="){if(Iu(t.value))return{unaryFilter:{field:Tn(t.field),op:"IS_NAN"}};if(Tu(t.value))return{unaryFilter:{field:Tn(t.field),op:"IS_NULL"}}}else if(t.op==="!="){if(Iu(t.value))return{unaryFilter:{field:Tn(t.field),op:"IS_NOT_NAN"}};if(Tu(t.value))return{unaryFilter:{field:Tn(t.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:Tn(t.field),op:Zy(t.op),value:t.value}}})(n):n instanceof He?(function(t){const r=t.getFilters().map((s=>td(s)));return r.length===1?r[0]:{compositeFilter:{op:eE(t.op),filters:r}}})(n):x(54877,{filter:n})}function tE(n){const e=[];return n.fields.forEach((t=>e.push(t.canonicalString()))),{fieldPaths:e}}function nd(n){return n.length>=4&&n.get(0)==="projects"&&n.get(2)==="databases"}function rd(n){return!!n&&typeof n._toProto=="function"&&n._protoValueType==="ProtoValue"}/** 2381 * @license 2382 * Copyright 2017 Google LLC 2383 * 2384 * Licensed under the Apache License, Version 2.0 (the "License"); 2385 * you may not use this file except in compliance with the License. 2386 * You may obtain a copy of the License at 2387 * 2388 * http://www.apache.org/licenses/LICENSE-2.0 2389 * 2390 * Unless required by applicable law or agreed to in writing, software 2391 * distributed under the License is distributed on an "AS IS" BASIS, 2392 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2393 * See the License for the specific language governing permissions and 2394 * limitations under the License. 2395 */class Ct{constructor(e,t,r,s,i=U.min(),a=U.min(),u=ye.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=u,this.expectedCount=l}withSequenceNumber(e){return new Ct(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(e,t){return new Ct(this.target,this.targetId,this.purpose,this.sequenceNumber,t,this.lastLimboFreeSnapshotVersion,e,null)}withExpectedCount(e){return new Ct(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,e)}withLastLimboFreeSnapshotVersion(e){return new Ct(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken,this.expectedCount)}}/** 2396 * @license 2397 * Copyright 2017 Google LLC 2398 * 2399 * Licensed under the Apache License, Version 2.0 (the "License");
2400 * you may not use this file except in compliance with the License. 2401 * You may obtain a copy of the License at 2402 * 2403 * http://www.apache.org/licenses/LICENSE-2.0 2404 * 2405 * Unless required by applicable law or agreed to in writing, software 2406 * distributed under the License is distributed on an "AS IS" BASIS, 2407 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2408 * See the License for the specific language governing permissions and 2409 * limitations under the License. 2410 */class nE{constructor(e){this.yt=e}}function rE(n){const e=Jy({parent:n.parent,structuredQuery:n.structuredQuery});return n.limitType==="LAST"?go(e,e.limit,"L"):e}/** 2411 * @license 2412 * Copyright 2019 Google LLC 2413 * 2414 * Licensed under the Apache License, Version 2.0 (the "License"); 2415 * you may not use this file except in compliance with the License. 2416 * You may obtain a copy of the License at 2417 * 2418 * http://www.apache.org/licenses/LICENSE-2.0 2419 * 2420 * Unless required by applicable law or agreed to in writing, software 2421 * distributed under the License is distributed on an "AS IS" BASIS, 2422 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2423 * See the License for the specific language governing permissions and 2424 * limitations under the License. 2425 */class sE{constructor(){this.Sn=new iE}addToCollectionParentIndex(e,t){return this.Sn.add(t),b.resolve()}getCollectionParents(e,t){return b.resolve(this.Sn.getEntries(t))}addFieldIndex(e,t){return b.resolve()}deleteFieldIndex(e,t){return b.resolve()}deleteAllFieldIndexes(e){return b.resolve()}createTargetIndexes(e,t){return b.resolve()}getDocumentsMatchingTarget(e,t){return b.resolve(null)}getIndexType(e,t){return b.resolve(0)}getFieldIndexes(e,t){return b.resolve([])}getNextCollectionGroupToUpdate(e){return b.resolve(null)}getMinOffset(e,t){return b.resolve(Lt.min())}getMinOffsetFromCollectionGroup(e,t){return b.resolve(Lt.min())}updateCollectionGroup(e,t,r){return b.resolve()}updateIndexEntries(e,t){return b.resolve()}}class iE{constructor(){this.index={}}add(e){const t=e.lastSegment(),r=e.popLast(),s=this.index[t]||new fe(X.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 fe(X.comparator)).toArray()}}/** 2426 * @license 2427 * Copyright 2018 Google LLC 2428 * 2429 * Licensed under the Apache License, Version 2.0 (the "License"); 2430 * you may not use this file except in compliance with the License. 2431 * You may obtain a copy of the License at 2432 * 2433 * http://www.apache.org/licenses/LICENSE-2.0 2434 * 2435 * Unless required by applicable law or agreed to in writing, software 2436 * distributed under the License is distributed on an "AS IS" BASIS, 2437 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2438 * See the License for the specific language governing permissions and 2439 * limitations under the License. 2440 */const Lu={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0},sd=41943040;class ke{static withCacheSize(e){return new ke(e,ke.DEFAULT_COLLECTION_PERCENTILE,ke.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}constructor(e,t,r){this.cacheSizeCollectionThreshold=e,this.percentileToCollect=t,this.maximumSequenceNumbersToCollect=r}}/** 2441 * @license 2442 * Copyright 2017 Google LLC 2443 * 2444 * Licensed under the Apache License, Version 2.0 (the "License"); 2445 * you may not use this file except in compliance with the License. 2446 * You may obtain a copy of the License at 2447 * 2448 * http://www.apache.org/licenses/LICENSE-2.0 2449 * 2450 * Unless required by applicable law or agreed to in writing, software 2451 * distributed under the License is distributed on an "AS IS" BASIS, 2452 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2453 * See the License for the specific language governing permissions and 2454 * limitations under the License. 2455 */ke.DEFAULT_COLLECTION_PERCENTILE=10,ke.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,ke.DEFAULT=new ke(sd,ke.DEFAULT_COLLECTION_PERCENTILE,ke.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),ke.DISABLED=new ke(-1,0,0);/** 2456 * @license 2457 * Copyright 2017 Google LLC 2458 * 2459 * Licensed under the Apache License, Version 2.0 (the "License");
2460 * you may not use this file except in compliance with the License. 2461 * You may obtain a copy of the License at 2462 * 2463 * http://www.apache.org/licenses/LICENSE-2.0 2464 * 2465 * Unless required by applicable law or agreed to in writing, software 2466 * distributed under the License is distributed on an "AS IS" BASIS, 2467 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2468 * See the License for the specific language governing permissions and 2469 * limitations under the License. 2470 */class Vn{constructor(e){this.sr=e}next(){return this.sr+=2,this.sr}static _r(){return new Vn(0)}static ar(){return new Vn(-1)}}/** 2471 * @license 2472 * Copyright 2020 Google LLC 2473 * 2474 * Licensed under the Apache License, Version 2.0 (the "License"); 2475 * you may not use this file except in compliance with the License. 2476 * You may obtain a copy of the License at 2477 * 2478 * http://www.apache.org/licenses/LICENSE-2.0 2479 * 2480 * Unless required by applicable law or agreed to in writing, software 2481 * distributed under the License is distributed on an "AS IS" BASIS, 2482 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2483 * See the License for the specific language governing permissions and 2484 * limitations under the License. 2485 */const Mu="LruGarbageCollector",oE=1048576;function xu([n,e],[t,r]){const s=G(n,t);return s===0?G(e,r):s}class aE{constructor(e){this.Pr=e,this.buffer=new fe(xu),this.Tr=0}Ir(){return++this.Tr}Er(e){const t=[e,this.Ir()];if(this.buffer.size<this.Pr)this.buffer=this.buffer.add(t);else{const r=this.buffer.last();xu(t,r)<0&&(this.buffer=this.buffer.delete(r).add(t))}}get maxValue(){return this.buffer.last()[0]}}class cE{constructor(e,t,r){this.garbageCollector=e,this.asyncQueue=t,this.localStore=r,this.Rr=null}start(){this.garbageCollector.params.cacheSizeCollectionThreshold!==-1&&this.Ar(6e4)}stop(){this.Rr&&(this.Rr.cancel(),this.Rr=null)}get started(){return this.Rr!==null}Ar(e){O(Mu,`Garbage collection scheduled in ${e}ms`),this.Rr=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",e,(async()=>{this.Rr=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(t){Fn(t)?O(Mu,"Ignoring IndexedDB error during garbage collection: ",t):await Un(t)}await this.Ar(3e5)}))}}class uE{constructor(e,t){this.Vr=e,this.params=t}calculateTargetCount(e,t){return this.Vr.dr(e).next((r=>Math.floor(t/100*r)))}nthSequenceNumber(e,t){if(t===0)return b.resolve(ei.ce);const r=new aE(t);return this.Vr.forEachTarget(e,(s=>r.Er(s.sequenceNumber))).next((()=>this.Vr.mr(e,(s=>r.Er(s))))).next((()=>r.maxValue))}removeTargets(e,t,r){return this.Vr.removeTargets(e,t,r)}removeOrphanedDocuments(e,t){return this.Vr.removeOrphanedDocuments(e,t)}collect(e,t){return this.params.cacheSizeCollectionThreshold===-1?(O("LruGarbageCollector","Garbage collection skipped; disabled"),b.resolve(Lu)):this.getCacheSize(e).next((r=>r<this.params.cacheSizeCollectionThreshold?(O("LruGarbageCollector",`Garbage collection skipped; Cache size ${r} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),Lu):this.gr(e,t)))}getCacheSize(e){return this.Vr.getCacheSize(e)}gr(e,t){let r,s,i,a,u,l,d;const f=Date.now();return this.calculateTargetCount(e,this.params.percentileToCollect).next((m=>(m>this.params.maximumSequenceNumbersToCollect?(O("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,u=Date.now(),this.removeTargets(e,r,t)))).next((m=>(i=m,l=Date.now(),this.removeOrphanedDocuments(e,r)))).next((m=>(d=Date.now(),yn()<=z.DEBUG&&O("LruGarbageCollector",`LRU Garbage Collection 2486 Counted targets in ${a-f}ms 2487 Determined least recently used ${s} in `+(u-a)+`ms 2488 Removed ${i} targets in `+(l-u)+`ms 2489 Removed ${m} documents in `+(d-l)+`ms 2490Total Duration: ${d-f}ms`),b.resolve({didRun:!0,sequenceNumbersCollected:s,targetsRemoved:i,documentsRemoved:m}))))}}function lE(n,e){return new uE(n,e)}/** 2491 * @license 2492 * Copyright 2017 Google LLC 2493 * 2494 * Licensed under the Apache License, Version 2.0 (the "License");
2495 * you may not use this file except in compliance with the License. 2496 * You may obtain a copy of the License at 2497 * 2498 * http://www.apache.org/licenses/LICENSE-2.0 2499 * 2500 * Unless required by applicable law or agreed to in writing, software 2501 * distributed under the License is distributed on an "AS IS" BASIS, 2502 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2503 * See the License for the specific language governing permissions and 2504 * limitations under the License. 2505 */class hE{constructor(){this.changes=new hn((e=>e.toString()),((e,t)=>e.isEqual(t))),this.changesApplied=!1}addEntry(e){this.assertNotApplied(),this.changes.set(e.key,e)}removeEntry(e,t){this.assertNotApplied(),this.changes.set(e,we.newInvalidDocument(e).setReadTime(t))}getEntry(e,t){this.assertNotApplied();const r=this.changes.get(t);return r!==void 0?b.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(){}}/** 2506 * @license 2507 * Copyright 2017 Google LLC 2508 * 2509 * Licensed under the Apache License, Version 2.0 (the "License"); 2510 * you may not use this file except in compliance with the License. 2511 * You may obtain a copy of the License at 2512 * 2513 * http://www.apache.org/licenses/LICENSE-2.0 2514 * 2515 * Unless required by applicable law or agreed to in writing, software 2516 * distributed under the License is distributed on an "AS IS" BASIS, 2517 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2518 * See the License for the specific language governing permissions and 2519 * limitations under the License. 2520 *//** 2521 * @license 2522 * Copyright 2022 Google LLC 2523 * 2524 * Licensed under the Apache License, Version 2.0 (the "License"); 2525 * you may not use this file except in compliance with the License. 2526 * You may obtain a copy of the License at 2527 * 2528 * http://www.apache.org/licenses/LICENSE-2.0 2529 * 2530 * Unless required by applicable law or agreed to in writing, software 2531 * distributed under the License is distributed on an "AS IS" BASIS, 2532 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2533 * See the License for the specific language governing permissions and 2534 * limitations under the License. 2535 */class dE{constructor(e,t){this.overlayedDocument=e,this.mutatedFields=t}}/** 2536 * @license 2537 * Copyright 2017 Google LLC 2538 * 2539 * Licensed under the Apache License, Version 2.0 (the "License"); 2540 * you may not use this file except in compliance with the License. 2541 * You may obtain a copy of the License at 2542 * 2543 * http://www.apache.org/licenses/LICENSE-2.0 2544 * 2545 * Unless required by applicable law or agreed to in writing, software 2546 * distributed under the License is distributed on an "AS IS" BASIS, 2547 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2548 * See the License for the specific language governing permissions and 2549 * limitations under the License. 2550 */class fE{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&&yr(r.mutation,s,Me.empty(),ee.now()),s)))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next((r=>this.getLocalViewOfDocuments(e,r,W()).next((()=>r))))}getLocalViewOfDocuments(e,t,r=W()){const s=Xt();return this.populateOverlays(e,s,t).next((()=>this.computeViews(e,t,s,r).next((i=>{let a=lr();return i.forEach(((u,l)=>{a=a.insert(u,l.overlayedDocument)})),a}))))}getOverlayedDocuments(e,t){const r=Xt();return this.populateOverlays(e,r,t).next((()=>this.computeViews(e,t,r,W())))}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,u)=>{t.set(a,u)}))}))}computeViews(e,t,r,s){let i=mt();const a=_r(),u=(function(){return _r()})();return t.forEach(((l,d)=>{const f=r.get(d.key);s.has(d.key)&&(f===void 0||f.mutation instanceof $t)?i=i.insert(d.key,d):f!==void 0?(a.set(d.key,f.mutation.getFieldMask()),yr(f.mutation,d,f.mutation.getFieldMask(),ee.now())):a.set(d.key,Me.empty())})),this.recalculateAndSaveOverlays(e,i).next((l=>(l.forEach(((d,f)=>a.set(d,f))),t.forEach(((d,f)=>u.set(d,new dE(f,a.get(d)??null)))),u)))}recalculateAndSaveOverlays(e,t){const r=_r();let s=new re(((a,u)=>a-u)),i=W();
2550return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,t).next((a=>{for(const u of a)u.keys().forEach((l=>{const d=t.get(l);if(d===null)return;let f=r.get(l)||Me.empty();f=u.applyToLocalView(d,f),r.set(l,f);const m=(s.get(u.batchId)||W()).add(l);s=s.insert(u.batchId,m)}))})).next((()=>{const a=[],u=s.getReverseIterator();for(;u.hasNext();){const l=u.getNext(),d=l.key,f=l.value,m=Fh();f.forEach((_=>{if(!i.has(_)){const S=zh(t.get(_),r.get(_));S!==null&&m.set(_,S),i=i.add(_)}})),a.push(this.documentOverlayCache.saveOverlays(e,d,m))}return b.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 fy(t)?this.getDocumentsMatchingDocumentQuery(e,t.path):Oh(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):b.resolve(Xt());let u=wr,l=i;return a.next((d=>b.forEach(d,((f,m)=>(u<m.largestBatchId&&(u=m.largestBatchId),i.get(f)?b.resolve():this.remoteDocumentCache.getEntry(e,f).next((_=>{l=l.insert(f,_)}))))).next((()=>this.populateOverlays(e,d,i))).next((()=>this.computeViews(e,l,d,W()))).next((f=>({batchId:u,changes:Uh(f)})))))}))}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new L(t)).next((r=>{let s=lr();return r.isFoundDocument()&&(s=s.insert(r.key,r)),s}))}getDocumentsMatchingCollectionGroupQuery(e,t,r,s){const i=t.collectionGroup;let a=lr();return this.indexManager.getCollectionParents(e,i).next((u=>b.forEach(u,(l=>{const d=(function(m,_){return new Bn(_,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,_)=>{a=a.insert(m,_)}))}))})).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,we.newInvalidDocument(f)))}));let u=lr();return a.forEach(((l,d)=>{const f=i.get(l);f!==void 0&&yr(f.mutation,d,Me.empty(),ee.now()),ii(t,d)&&(u=u.insert(l,d))})),u}))}}/** 2551 * @license 2552 * Copyright 2020 Google LLC 2553 * 2554 * Licensed under the Apache License, Version 2.0 (the "License"); 2555 * you may not use this file except in compliance with the License. 2556 * You may obtain a copy of the License at 2557 * 2558 * http://www.apache.org/licenses/LICENSE-2.0 2559 * 2560 * Unless required by applicable law or agreed to in writing, software 2561 * distributed under the License is distributed on an "AS IS" BASIS, 2562 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2563 * See the License for the specific language governing permissions and 2564 * limitations under the License. 2565 */class pE{constructor(e){this.serializer=e,this.Nr=new Map,this.Br=new Map}getBundleMetadata(e,t){return b.resolve(this.Nr.get(t))}saveBundleMetadata(e,t){return this.Nr.set(t.id,(function(s){return{id:s.id,version:s.version,createTime:nt(s.createTime)}})(t)),b.resolve()}getNamedQuery(e,t){return b.resolve(this.Br.get(t))}saveNamedQuery(e,t){return this.Br.set(t.name,(function(s){return{name:s.name,query:rE(s.bundledQuery),readTime:nt(s.readTime)}})(t)),b.resolve()}}/** 2566 * @license 2567 * Copyright 2022 Google LLC 2568 * 2569 * Licensed under the Apache License, Version 2.0 (the "License"); 2570 * you may not use this file except in compliance with the License. 2571 * You may obtain a copy of the License at 2572 * 2573 * http://www.apache.org/licenses/LICENSE-2.0 2574 * 2575 * Unless required by applicable law or agreed to in writing, software 2576 * distributed under the License is distributed on an "AS IS" BASIS, 2577 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2578 * See the License for the specific language governing permissions and 2579 * limitations under the License. 2580 */class mE{constructor(){this.overlays=new re(L.comparator),this.Lr=new Map}getOverlay(e,t){return b.resolve(this.overlays.get(t))}getOverlays(e,t){const r=Xt();return b.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.bt(e,t,i)})),b.resolve()}removeOverlaysForBatchId(e,t,r){const s=this.Lr.get(r);return s!==void 0&&(s.forEach((i=>this.overlays=this.overlays.remove(i))),this.Lr.delete(r)),b.resolve()}getOverlaysForCollection(e,t,r){const s=Xt(),i=t.length+1,a=new L(t.child("")),u=this.overlays.getIteratorFrom(a);for(;u.hasNext();){const l=u.getNext().value,d=l.getKey();if(!t.isPrefixOf(d.path))break;d.path.length===i&&l.largestBatchId>r&&s.set(l.getKey(),l)}return b.resolve(s)}getOverlaysForCollectionGroup(e,t,r,s){let i=new re(((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);
vendor: 4,077 bytes, lines 2580-2625
2580f===null&&(f=Xt(),i=i.insert(d.largestBatchId,f)),f.set(d.getKey(),d)}}const u=Xt(),l=i.getIterator();for(;l.hasNext()&&(l.getNext().value.forEach(((d,f)=>u.set(d,f))),!(u.size()>=s)););return b.resolve(u)}bt(e,t,r){const s=this.overlays.get(r.key);if(s!==null){const a=this.Lr.get(s.largestBatchId).delete(r.key);this.Lr.set(s.largestBatchId,a)}this.overlays=this.overlays.insert(r.key,new Vy(t,r));let i=this.Lr.get(t);i===void 0&&(i=W(),this.Lr.set(t,i)),this.Lr.set(t,i.add(r.key))}}/** 2581 * @license 2582 * Copyright 2024 Google LLC 2583 * 2584 * Licensed under the Apache License, Version 2.0 (the "License"); 2585 * you may not use this file except in compliance with the License. 2586 * You may obtain a copy of the License at 2587 * 2588 * http://www.apache.org/licenses/LICENSE-2.0 2589 * 2590 * Unless required by applicable law or agreed to in writing, software 2591 * distributed under the License is distributed on an "AS IS" BASIS, 2592 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2593 * See the License for the specific language governing permissions and 2594 * limitations under the License. 2595 */class gE{constructor(){this.sessionToken=ye.EMPTY_BYTE_STRING}getSessionToken(e){return b.resolve(this.sessionToken)}setSessionToken(e,t){return this.sessionToken=t,b.resolve()}}/** 2596 * @license 2597 * Copyright 2017 Google LLC 2598 * 2599 * Licensed under the Apache License, Version 2.0 (the "License"); 2600 * you may not use this file except in compliance with the License. 2601 * You may obtain a copy of the License at 2602 * 2603 * http://www.apache.org/licenses/LICENSE-2.0 2604 * 2605 * Unless required by applicable law or agreed to in writing, software 2606 * distributed under the License is distributed on an "AS IS" BASIS, 2607 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2608 * See the License for the specific language governing permissions and 2609 * limitations under the License. 2610 */class ea{constructor(){this.kr=new fe(me.Kr),this.qr=new fe(me.Ur)}isEmpty(){return this.kr.isEmpty()}addReference(e,t){const r=new me(e,t);this.kr=this.kr.add(r),this.qr=this.qr.add(r)}$r(e,t){e.forEach((r=>this.addReference(r,t)))}removeReference(e,t){this.Wr(new me(e,t))}Qr(e,t){e.forEach((r=>this.removeReference(r,t)))}Gr(e){const t=new L(new X([])),r=new me(t,e),s=new me(t,e+1),i=[];return this.qr.forEachInRange([r,s],(a=>{this.Wr(a),i.push(a.key)})),i}zr(){this.kr.forEach((e=>this.Wr(e)))}Wr(e){this.kr=this.kr.delete(e),this.qr=this.qr.delete(e)}jr(e){const t=new L(new X([])),r=new me(t,e),s=new me(t,e+1);let i=W();return this.qr.forEachInRange([r,s],(a=>{i=i.add(a.key)})),i}containsKey(e){const t=new me(e,0),r=this.kr.firstAfterOrEqual(t);return r!==null&&e.isEqual(r.key)}}class me{constructor(e,t){this.key=e,this.Hr=t}static Kr(e,t){return L.comparator(e.key,t.key)||G(e.Hr,t.Hr)}static Ur(e,t){return G(e.Hr,t.Hr)||L.comparator(e.key,t.key)}}/** 2611 * @license 2612 * Copyright 2017 Google LLC 2613 * 2614 * Licensed under the Apache License, Version 2.0 (the "License"); 2615 * you may not use this file except in compliance with the License. 2616 * You may obtain a copy of the License at 2617 * 2618 * http://www.apache.org/licenses/LICENSE-2.0 2619 * 2620 * Unless required by applicable law or agreed to in writing, software 2621 * distributed under the License is distributed on an "AS IS" BASIS, 2622 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2623 * See the License for the specific language governing permissions and 2624 * limitations under the License. 2625 */class _E{constructor(e,t){this.indexManager=e,this.referenceDelegate=t,this.mutationQueue=[],this.Yn=1,this.Jr=new fe(me.Kr)}checkEmpty(e){return b.resolve(this.mutationQueue.length===0)}addMutationBatch(e,t,r,s){const i=this.Yn;this.Yn++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];const a=new Dy(i,t,r,s);this.mutationQueue.push(a);for(const u of s)this.Jr=this.Jr.add(new me(u.key,i)),this.indexManager.addToCollectionParentIndex(e,u.key.path.popLast());return b.resolve(a)}lookupMutationBatch(e,t){return b.resolve(this.Zr(t))}getNextMutationBatchAfterBatchId(e,t){const r=t+1,s=this.Xr(r),i=s<0?0:s;
2625return b.resolve(this.mutationQueue.length>i?this.mutationQueue[i]:null)}getHighestUnacknowledgedBatchId(){return b.resolve(this.mutationQueue.length===0?Ho:this.Yn-1)}getAllMutationBatches(e){return b.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){const r=new me(t,0),s=new me(t,Number.POSITIVE_INFINITY),i=[];return this.Jr.forEachInRange([r,s],(a=>{const u=this.Zr(a.Hr);i.push(u)})),b.resolve(i)}getAllMutationBatchesAffectingDocumentKeys(e,t){let r=new fe(G);return t.forEach((s=>{const i=new me(s,0),a=new me(s,Number.POSITIVE_INFINITY);this.Jr.forEachInRange([i,a],(u=>{r=r.add(u.Hr)}))})),b.resolve(this.Yr(r))}getAllMutationBatchesAffectingQuery(e,t){const r=t.path,s=r.length+1;let i=r;L.isDocumentKey(i)||(i=i.child(""));const a=new me(new L(i),0);let u=new fe(G);return this.Jr.forEachWhile((l=>{const d=l.key.path;return!!r.isPrefixOf(d)&&(d.length===s&&(u=u.add(l.Hr)),!0)}),a),b.resolve(this.Yr(u))}Yr(e){const t=[];return e.forEach((r=>{const s=this.Zr(r);s!==null&&t.push(s)})),t}removeMutationBatch(e,t){J(this.ei(t.batchId,"removed")===0,55003),this.mutationQueue.shift();let r=this.Jr;return b.forEach(t.mutations,(s=>{const i=new me(s.key,t.batchId);return r=r.delete(i),this.referenceDelegate.markPotentiallyOrphaned(e,s.key)})).next((()=>{this.Jr=r}))}nr(e){}containsKey(e,t){const r=new me(t,0),s=this.Jr.firstAfterOrEqual(r);return b.resolve(t.isEqual(s&&s.key))}performConsistencyCheck(e){return this.mutationQueue.length,b.resolve()}ei(e,t){return this.Xr(e)}Xr(e){return this.mutationQueue.length===0?0:e-this.mutationQueue[0].batchId}Zr(e){const t=this.Xr(e);return t<0||t>=this.mutationQueue.length?null:this.mutationQueue[t]}}/** 2626 * @license 2627 * Copyright 2017 Google LLC 2628 * 2629 * Licensed under the Apache License, Version 2.0 (the "License"); 2630 * you may not use this file except in compliance with the License. 2631 * You may obtain a copy of the License at 2632 * 2633 * http://www.apache.org/licenses/LICENSE-2.0 2634 * 2635 * Unless required by applicable law or agreed to in writing, software 2636 * distributed under the License is distributed on an "AS IS" BASIS, 2637 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2638 * See the License for the specific language governing permissions and 2639 * limitations under the License. 2640 */class yE{constructor(e){this.ti=e,this.docs=(function(){return new re(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.ti(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 b.resolve(r?r.document.mutableCopy():we.newInvalidDocument(t))}getEntries(e,t){let r=mt();return t.forEach((s=>{const i=this.docs.get(s);r=r.insert(s,i?i.document.mutableCopy():we.newInvalidDocument(s))})),b.resolve(r)}getDocumentsMatchingQuery(e,t,r,s){let i=mt();const a=t.path,u=new L(a.child("__id-9223372036854775808__")),l=this.docs.getIteratorFrom(u);for(;l.hasNext();){const{key:d,value:{document:f}}=l.getNext();if(!a.isPrefixOf(d.path))break;d.path.length>a.length+1||j_($_(f),r)<=0||(s.has(f.key)||ii(t,f))&&(i=i.insert(f.key,f.mutableCopy()))}return b.resolve(i)}getAllFromCollectionGroup(e,t,r,s){x(9500)}ni(e,t){return b.forEach(this.docs,(r=>t(r)))}newChangeBuffer(e){return new EE(this)}getSize(e){return b.resolve(this.size)}}class EE extends hE{constructor(e){super(),this.Mr=e}applyChanges(e){const t=[];
vendor: 9,116 bytes, lines 2640-2704
2640return this.changes.forEach(((r,s)=>{s.isValidDocument()?t.push(this.Mr.addEntry(e,s)):this.Mr.removeEntry(r)})),b.waitFor(t)}getFromCache(e,t){return this.Mr.getEntry(e,t)}getAllFromCache(e,t){return this.Mr.getEntries(e,t)}}/** 2641 * @license 2642 * Copyright 2017 Google LLC 2643 * 2644 * Licensed under the Apache License, Version 2.0 (the "License"); 2645 * you may not use this file except in compliance with the License. 2646 * You may obtain a copy of the License at 2647 * 2648 * http://www.apache.org/licenses/LICENSE-2.0 2649 * 2650 * Unless required by applicable law or agreed to in writing, software 2651 * distributed under the License is distributed on an "AS IS" BASIS, 2652 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2653 * See the License for the specific language governing permissions and 2654 * limitations under the License. 2655 */class TE{constructor(e){this.persistence=e,this.ri=new hn((t=>Wo(t)),Ko),this.lastRemoteSnapshotVersion=U.min(),this.highestTargetId=0,this.ii=0,this.si=new ea,this.targetCount=0,this.oi=Vn._r()}forEachTarget(e,t){return this.ri.forEach(((r,s)=>t(s))),b.resolve()}getLastRemoteSnapshotVersion(e){return b.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return b.resolve(this.ii)}allocateTargetId(e){return this.highestTargetId=this.oi.next(),b.resolve(this.highestTargetId)}setTargetsMetadata(e,t,r){return r&&(this.lastRemoteSnapshotVersion=r),t>this.ii&&(this.ii=t),b.resolve()}lr(e){this.ri.set(e.target,e);const t=e.targetId;t>this.highestTargetId&&(this.oi=new Vn(t),this.highestTargetId=t),e.sequenceNumber>this.ii&&(this.ii=e.sequenceNumber)}addTargetData(e,t){return this.lr(t),this.targetCount+=1,b.resolve()}updateTargetData(e,t){return this.lr(t),b.resolve()}removeTargetData(e,t){return this.ri.delete(t.target),this.si.Gr(t.targetId),this.targetCount-=1,b.resolve()}removeTargets(e,t,r){let s=0;const i=[];return this.ri.forEach(((a,u)=>{u.sequenceNumber<=t&&r.get(u.targetId)===null&&(this.ri.delete(a),i.push(this.removeMatchingKeysForTargetId(e,u.targetId)),s++)})),b.waitFor(i).next((()=>s))}getTargetCount(e){return b.resolve(this.targetCount)}getTargetData(e,t){const r=this.ri.get(t)||null;return b.resolve(r)}addMatchingKeys(e,t,r){return this.si.$r(t,r),b.resolve()}removeMatchingKeys(e,t,r){this.si.Qr(t,r);const s=this.persistence.referenceDelegate,i=[];return s&&t.forEach((a=>{i.push(s.markPotentiallyOrphaned(e,a))})),b.waitFor(i)}removeMatchingKeysForTargetId(e,t){return this.si.Gr(t),b.resolve()}getMatchingKeysForTargetId(e,t){const r=this.si.jr(t);return b.resolve(r)}containsKey(e,t){return b.resolve(this.si.containsKey(t))}}/** 2656 * @license 2657 * Copyright 2017 Google LLC 2658 * 2659 * Licensed under the Apache License, Version 2.0 (the "License"); 2660 * you may not use this file except in compliance with the License. 2661 * You may obtain a copy of the License at 2662 * 2663 * http://www.apache.org/licenses/LICENSE-2.0 2664 * 2665 * Unless required by applicable law or agreed to in writing, software 2666 * distributed under the License is distributed on an "AS IS" BASIS, 2667 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2668 * See the License for the specific language governing permissions and 2669 * limitations under the License. 2670 */class id{constructor(e,t){this._i={},this.overlays={},this.ai=new ei(0),this.ui=!1,this.ui=!0,this.ci=new gE,this.referenceDelegate=e(this),this.li=new TE(this),this.indexManager=new sE,this.remoteDocumentCache=(function(s){return new yE(s)})((r=>this.referenceDelegate.hi(r))),this.serializer=new nE(t),this.Pi=new pE(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.ui=!1,Promise.resolve()}get started(){return this.ui}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let t=this.overlays[e.toKey()];return t||(t=new mE,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let r=this._i[e.toKey()];return r||(r=new _E(t,this.referenceDelegate),this._i[e.toKey()]=r),r}getGlobalsCache(){return this.ci}getTargetCache(){return this.li}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Pi}runTransaction(e,t,r){O("MemoryPersistence","Starting transaction:",e);const s=new IE(this.ai.next());return this.referenceDelegate.Ti(),r(s).next((i=>this.referenceDelegate.Ii(s).next((()=>i)))).toPromise().then((i=>(s.raiseOnCommittedEvent(),i)))}Ei(e,t){return b.or(Object.values(this._i).map((r=>()=>r.containsKey(e,t))))}}class IE extends z_{constructor(e){super(),this.currentSequenceNumber=e}}class ta{constructor(e){this.persistence=e,this.Ri=new ea,this.Ai=null}static Vi(e){return new ta(e)}get di(){if(this.Ai)return this.Ai;throw x(60996)}addReference(e,t,r){return this.Ri.addReference(r,t),this.di.delete(r.toString()),b.resolve()}removeReference(e,t,r){return this.Ri.removeReference(r,t),this.di.add(r.toString()),b.resolve()}markPotentiallyOrphaned(e,t){return this.di.add(t.toString()),b.resolve()}removeTarget(e,t){this.Ri.Gr(t.targetId).forEach((s=>this.di.add(s.toString())));const r=this.persistence.getTargetCache();return r.getMatchingKeysForTargetId(e,t.targetId).next((s=>{s.forEach((i=>this.di.add(i.toString())))})).next((()=>r.removeTargetData(e,t)))}Ti(){this.Ai=new Set}Ii(e){const t=this.persistence.getRemoteDocumentCache().newChangeBuffer();return b.forEach(this.di,(r=>{const s=L.fromPath(r);return this.mi(e,s).next((i=>{i||t.removeEntry(s,U.min())}))})).next((()=>(this.Ai=null,t.apply(e))))}updateLimboDocument(e,t){return this.mi(e,t).next((r=>{r?this.di.delete(t.toString()):this.di.add(t.toString())}))}hi(e){return 0}mi(e,t){return b.or([()=>b.resolve(this.Ri.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.Ei(e,t)])}}class xs{constructor(e,t){this.persistence=e,this.fi=new hn((r=>K_(r.path)),((r,s)=>r.isEqual(s))),this.garbageCollector=lE(this,t)}static Vi(e,t){return new xs(e,t)}Ti(){}Ii(e){return b.resolve()}forEachTarget(e,t){return this.persistence.getTargetCache().forEachTarget(e,t)}dr(e){const t=this.pr(e);return this.persistence.getTargetCache().getTargetCount(e).next((r=>t.next((s=>r+s))))}pr(e){let t=0;return this.mr(e,(r=>{t++})).next((()=>t))}mr(e,t){return b.forEach(this.fi,((r,s)=>this.wr(e,r,s).next((i=>i?b.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.ni(e,(a=>this.wr(e,a,t).next((u=>{u||(r++,i.removeEntry(a,U.min()))})))).next((()=>i.apply(e))).next((()=>r))}markPotentiallyOrphaned(e,t){return this.fi.set(t,e.currentSequenceNumber),b.resolve()}removeTarget(e,t){const r=t.withSequenceNumber(e.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(e,r)}addReference(e,t,r){return this.fi.set(r,e.currentSequenceNumber),b.resolve()}removeReference(e,t,r){return this.fi.set(r,e.currentSequenceNumber),b.resolve()}updateLimboDocument(e,t){return this.fi.set(t,e.currentSequenceNumber),b.resolve()}hi(e){let t=e.key.toString().length;return e.isFoundDocument()&&(t+=_s(e.data.value)),t}wr(e,t,r){return b.or([()=>this.persistence.Ei(e,t),()=>this.persistence.getTargetCache().containsKey(e,t),()=>{const s=this.fi.get(t);return b.resolve(s!==void 0&&s>r)}])}getCacheSize(e){return this.persistence.getRemoteDocumentCache().getSize(e)}}/** 2671 * @license 2672 * Copyright 2017 Google LLC 2673 * 2674 * Licensed under the Apache License, Version 2.0 (the "License"); 2675 * you may not use this file except in compliance with the License. 2676 * You may obtain a copy of the License at 2677 * 2678 * http://www.apache.org/licenses/LICENSE-2.0 2679 * 2680 * Unless required by applicable law or agreed to in writing, software 2681 * distributed under the License is distributed on an "AS IS" BASIS, 2682 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2683 * See the License for the specific language governing permissions and 2684 * limitations under the License. 2685 */class na{constructor(e,t,r,s){this.targetId=e,this.fromCache=t,this.Ts=r,this.Is=s}static Es(e,t){let r=W(),s=W();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 na(e,t.fromCache,r,s)}}/** 2686 * @license 2687 * Copyright 2023 Google LLC 2688 * 2689 * Licensed under the Apache License, Version 2.0 (the "License"); 2690 * you may not use this file except in compliance with the License. 2691 * You may obtain a copy of the License at 2692 * 2693 * http://www.apache.org/licenses/LICENSE-2.0 2694 * 2695 * Unless required by applicable law or agreed to in writing, software 2696 * distributed under the License is distributed on an "AS IS" BASIS, 2697 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2698 * See the License for the specific language governing permissions and 2699 * limitations under the License. 2700 */class wE{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(e){this._documentReadCount+=e}}/** 2701 * @license 2702 * Copyright 2019 Google LLC 2703 * 2704 * Licensed under the Apache License, Version 2.0 (the "License");
2705 * you may not use this file except in compliance with the License. 2706 * You may obtain a copy of the License at 2707 * 2708 * http://www.apache.org/licenses/LICENSE-2.0 2709 * 2710 * Unless required by applicable law or agreed to in writing, software 2711 * distributed under the License is distributed on an "AS IS" BASIS, 2712 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2713 * See the License for the specific language governing permissions and 2714 * limitations under the License. 2715 */class vE{constructor(){this.Rs=!1,this.As=!1,this.Vs=100,this.ds=(function(){return op()?8:G_(Ae())>0?6:4})()}initialize(e,t){this.fs=e,this.indexManager=t,this.Rs=!0}getDocumentsMatchingQuery(e,t,r,s){const i={result:null};return this.gs(e,t).next((a=>{i.result=a})).next((()=>{if(!i.result)return this.ps(e,t,s,r).next((a=>{i.result=a}))})).next((()=>{if(i.result)return;const a=new wE;return this.ys(e,t,a).next((u=>{if(i.result=u,this.As)return this.ws(e,t,a,u.size)}))})).next((()=>i.result))}ws(e,t,r,s){return r.documentReadCount<this.Vs?(yn()<=z.DEBUG&&O("QueryEngine","SDK will not create cache indexes for query:",En(t),"since it only creates cache indexes for collection contains","more than or equal to",this.Vs,"documents"),b.resolve()):(yn()<=z.DEBUG&&O("QueryEngine","Query:",En(t),"scans",r.documentReadCount,"local documents and returns",s,"documents as results."),r.documentReadCount>this.ds*s?(yn()<=z.DEBUG&&O("QueryEngine","The SDK decides to create cache indexes for query:",En(t),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(e,tt(t))):b.resolve())}gs(e,t){if(Ru(t))return b.resolve(null);let r=tt(t);return this.indexManager.getIndexType(e,r).next((s=>s===0?null:(t.limit!==null&&s===1&&(t=go(t,null,"F"),r=tt(t)),this.indexManager.getDocumentsMatchingTarget(e,r).next((i=>{const a=W(...i);return this.fs.getDocuments(e,a).next((u=>this.indexManager.getMinOffset(e,r).next((l=>{const d=this.bs(t,u);return this.Ss(t,d,a,l.readTime)?this.gs(e,go(t,null,"F")):this.Ds(e,d,t,l)}))))})))))}ps(e,t,r,s){return Ru(t)||s.isEqual(U.min())?b.resolve(null):this.fs.getDocuments(e,r).next((i=>{const a=this.bs(t,i);return this.Ss(t,a,r,s)?b.resolve(null):(yn()<=z.DEBUG&&O("QueryEngine","Re-using previous result from %s to execute query: %s",s.toString(),En(t)),this.Ds(e,a,t,q_(s,wr)).next((u=>u)))}))}bs(e,t){let r=new fe(Mh(e));return t.forEach(((s,i)=>{ii(e,i)&&(r=r.add(i))})),r}Ss(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)}ys(e,t,r){return yn()<=z.DEBUG&&O("QueryEngine","Using full collection scan to execute query:",En(t)),this.fs.getDocumentsMatchingQuery(e,t,Lt.min(),r)}Ds(e,t,r,s){return this.fs.getDocumentsMatchingQuery(e,r,s).next((i=>(t.forEach((a=>{i=i.insert(a.key,a)})),i)))}}/** 2716 * @license 2717 * Copyright 2020 Google LLC 2718 * 2719 * Licensed under the Apache License, Version 2.0 (the "License"); 2720 * you may not use this file except in compliance with the License. 2721 * You may obtain a copy of the License at 2722 * 2723 * http://www.apache.org/licenses/LICENSE-2.0 2724 * 2725 * Unless required by applicable law or agreed to in writing, software 2726 * distributed under the License is distributed on an "AS IS" BASIS, 2727 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2728 * See the License for the specific language governing permissions and 2729 * limitations under the License. 2730 */const ra="LocalStore",AE=3e8;class RE{constructor(e,t,r,s){this.persistence=e,this.Cs=t,this.serializer=s,this.vs=new re(G),this.Fs=new hn((i=>Wo(i)),Ko),this.Ms=new Map,this.xs=e.getRemoteDocumentCache(),this.li=e.getTargetCache(),this.Pi=e.getBundleCache(),this.Os(r)}Os(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new fE(this.xs,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.xs.setIndexManager(this.indexManager),this.Cs.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction("Collect garbage","readwrite-primary",(t=>e.collect(t,this.vs)))}}function SE(n,e,t,r){return new RE(n,e,t,r)}async function od(n,e){const t=B(n);return await t.persistence.runTransaction("Handle user change","readonly",(r=>{let s;
2730return t.mutationQueue.getAllMutationBatches(r).next((i=>(s=i,t.Os(e),t.mutationQueue.getAllMutationBatches(r)))).next((i=>{const a=[],u=[];let l=W();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){u.push(d.batchId);for(const f of d.mutations)l=l.add(f.key)}return t.localDocuments.getDocuments(r,l).next((d=>({Ns:d,removedBatchIds:a,addedBatchIds:u})))}))}))}function PE(n,e){const t=B(n);return t.persistence.runTransaction("Acknowledge batch","readwrite-primary",(r=>{const s=e.batch.keys(),i=t.xs.newChangeBuffer({trackRemovals:!0});return(function(u,l,d,f){const m=d.batch,_=m.keys();let S=b.resolve();return _.forEach((C=>{S=S.next((()=>f.getEntry(l,C))).next((D=>{const k=d.docVersions.get(C);J(k!==null,48541),D.version.compareTo(k)<0&&(m.applyToRemoteDocument(D,d),D.isValidDocument()&&(D.setReadTime(d.commitVersion),f.addEntry(D)))}))})),S.next((()=>u.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(u){let l=W();for(let d=0;d<u.mutationResults.length;++d)u.mutationResults[d].transformResults.length>0&&(l=l.add(u.batch.mutations[d].key));return l})(e)))).next((()=>t.localDocuments.getDocuments(r,s)))}))}function ad(n){const e=B(n);return e.persistence.runTransaction("Get last remote snapshot version","readonly",(t=>e.li.getLastRemoteSnapshotVersion(t)))}function bE(n,e){const t=B(n),r=e.snapshotVersion;let s=t.vs;return t.persistence.runTransaction("Apply remote event","readwrite-primary",(i=>{const a=t.xs.newChangeBuffer({trackRemovals:!0});s=t.vs;const u=[];
2730e.targetChanges.forEach(((f,m)=>{const _=s.get(m);if(!_)return;u.push(t.li.removeMatchingKeys(i,f.removedDocuments,m).next((()=>t.li.addMatchingKeys(i,f.addedDocuments,m))));let S=_.withSequenceNumber(i.currentSequenceNumber);e.targetMismatches.get(m)!==null?S=S.withResumeToken(ye.EMPTY_BYTE_STRING,U.min()).withLastLimboFreeSnapshotVersion(U.min()):f.resumeToken.approximateByteSize()>0&&(S=S.withResumeToken(f.resumeToken,r)),s=s.insert(m,S),(function(D,k,q){return D.resumeToken.approximateByteSize()===0||k.snapshotVersion.toMicroseconds()-D.snapshotVersion.toMicroseconds()>=AE?!0:q.addedDocuments.size+q.modifiedDocuments.size+q.removedDocuments.size>0})(_,S,f)&&u.push(t.li.updateTargetData(i,S))}));let l=mt(),d=W();if(e.documentUpdates.forEach((f=>{e.resolvedLimboDocuments.has(f)&&u.push(t.persistence.referenceDelegate.updateLimboDocument(i,f))})),u.push(CE(i,a,e.documentUpdates).next((f=>{l=f.Bs,d=f.Ls}))),!r.isEqual(U.min())){const f=t.li.getLastRemoteSnapshotVersion(i).next((m=>t.li.setTargetsMetadata(i,i.currentSequenceNumber,r)));u.push(f)}return b.waitFor(u).next((()=>a.apply(i))).next((()=>t.localDocuments.getLocalViewOfDocuments(i,l,d))).next((()=>l))})).then((i=>(t.vs=s,i)))}function CE(n,e,t){let r=W(),s=W();return t.forEach((i=>r=r.add(i))),e.getEntries(n,r).next((i=>{let a=mt();return t.forEach(((u,l)=>{const d=i.get(u);l.isFoundDocument()!==d.isFoundDocument()&&(s=s.add(u)),l.isNoDocument()&&l.version.isEqual(U.min())?(e.removeEntry(u,l.readTime),a=a.insert(u,l)):!d.isValidDocument()||l.version.compareTo(d.version)>0||l.version.compareTo(d.version)===0&&d.hasPendingWrites?(e.addEntry(l),a=a.insert(u,l)):O(ra,"Ignoring outdated watch update for ",u,". Current version:",d.version," Watch version:",l.version)})),{Bs:a,Ls:s}}))}function kE(n,e){const t=B(n);return t.persistence.runTransaction("Get next mutation batch","readonly",(r=>(e===void 0&&(e=Ho),t.mutationQueue.getNextMutationBatchAfterBatchId(r,e))))}function NE(n,e){const t=B(n);return t.persistence.runTransaction("Allocate target","readwrite",(r=>{let s;return t.li.getTargetData(r,e).next((i=>i?(s=i,b.resolve(s)):t.li.allocateTargetId(r).next((a=>(s=new Ct(e,a,"TargetPurposeListen",r.currentSequenceNumber),t.li.addTargetData(r,s).next((()=>s)))))))})).then((r=>{const s=t.vs.get(r.targetId);return(s===null||r.snapshotVersion.compareTo(s.snapshotVersion)>0)&&(t.vs=t.vs.insert(r.targetId,r),t.Fs.set(e,r.targetId)),r}))}async function Io(n,e,t){const r=B(n),s=r.vs.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(!Fn(a))throw a;O(ra,`Failed to update sequence numbers for target ${e}: ${a}`)}r.vs=r.vs.remove(e),r.Fs.delete(s.target)}function Uu(n,e,t){const r=B(n);let s=U.min(),i=W();return r.persistence.runTransaction("Execute query","readwrite",(a=>(function(l,d,f){const m=B(l),_=m.Fs.get(f);return _!==void 0?b.resolve(m.vs.get(_)):m.li.getTargetData(d,f)})(r,a,tt(e)).next((u=>{if(u)return s=u.lastLimboFreeSnapshotVersion,r.li.getMatchingKeysForTargetId(a,u.targetId).next((l=>{i=l}))})).next((()=>r.Cs.getDocumentsMatchingQuery(a,e,t?s:U.min(),t?i:W()))).next((u=>(DE(r,gy(e),u),{documents:u,ks:i})))))}function DE(n,e,t){let r=n.Ms.get(e)||U.min();t.forEach(((s,i)=>{i.readTime.compareTo(r)>0&&(r=i.readTime)})),n.Ms.set(e,r)}class Fu{constructor(){this.activeTargetIds=wy()}Qs(e){this.activeTargetIds=this.activeTargetIds.add(e)}Gs(e){this.activeTargetIds=this.activeTargetIds.delete(e)}Ws(){const e={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(e)}}class VE{constructor(){this.vo=new Fu,this.Fo={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,t,r){}addLocalQueryTarget(e,t=!0){return t&&this.vo.Qs(e),this.Fo[e]||"not-current"}updateQueryState(e,t,r){this.Fo[e]=t}removeLocalQueryTarget(e){this.vo.Gs(e)}isLocalQueryTarget(e){return this.vo.activeTargetIds.has(e)}clearQueryState(e){delete this.Fo[e]}getAllActiveQueryTargets(){return this.vo.activeTargetIds}isActiveQueryTarget(e){return this.vo.activeTargetIds.has(e)}start(){return this.vo=new Fu,Promise.resolve()}handleUserChange(e,t,r){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}}/** 2731 * @license 2732 * Copyright 2019 Google LLC 2733 * 2734 * Licensed under the Apache License, Version 2.0 (the "License");
2735 * you may not use this file except in compliance with the License. 2736 * You may obtain a copy of the License at 2737 * 2738 * http://www.apache.org/licenses/LICENSE-2.0 2739 * 2740 * Unless required by applicable law or agreed to in writing, software 2741 * distributed under the License is distributed on an "AS IS" BASIS, 2742 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2743 * See the License for the specific language governing permissions and 2744 * limitations under the License. 2745 */class OE{Mo(e){}shutdown(){}}/** 2746 * @license 2747 * Copyright 2019 Google LLC 2748 * 2749 * Licensed under the Apache License, Version 2.0 (the "License"); 2750 * you may not use this file except in compliance with the License. 2751 * You may obtain a copy of the License at 2752 * 2753 * http://www.apache.org/licenses/LICENSE-2.0 2754 * 2755 * Unless required by applicable law or agreed to in writing, software 2756 * distributed under the License is distributed on an "AS IS" BASIS, 2757 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2758 * See the License for the specific language governing permissions and 2759 * limitations under the License. 2760 */const Bu="ConnectivityMonitor";class qu{constructor(){this.xo=()=>this.Oo(),this.No=()=>this.Bo(),this.Lo=[],this.ko()}Mo(e){this.Lo.push(e)}shutdown(){window.removeEventListener("online",this.xo),window.removeEventListener("offline",this.No)}ko(){window.addEventListener("online",this.xo),window.addEventListener("offline",this.No)}Oo(){O(Bu,"Network connectivity changed: AVAILABLE");for(const e of this.Lo)e(0)}Bo(){O(Bu,"Network connectivity changed: UNAVAILABLE");for(const e of this.Lo)e(1)}static v(){return typeof window<"u"&&window.addEventListener!==void 0&&window.removeEventListener!==void 0}}/** 2761 * @license 2762 * Copyright 2023 Google LLC 2763 * 2764 * Licensed under the Apache License, Version 2.0 (the "License"); 2765 * you may not use this file except in compliance with the License. 2766 * You may obtain a copy of the License at 2767 * 2768 * http://www.apache.org/licenses/LICENSE-2.0 2769 * 2770 * Unless required by applicable law or agreed to in writing, software 2771 * distributed under the License is distributed on an "AS IS" BASIS, 2772 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2773 * See the License for the specific language governing permissions and 2774 * limitations under the License. 2775 */let us=null;function wo(){return us===null?us=(function(){return 268435456+Math.round(2147483648*Math.random())})():us++,"0x"+us.toString(16)}/** 2776 * @license 2777 * Copyright 2020 Google LLC 2778 * 2779 * Licensed under the Apache License, Version 2.0 (the "License"); 2780 * you may not use this file except in compliance with the License. 2781 * You may obtain a copy of the License at 2782 * 2783 * http://www.apache.org/licenses/LICENSE-2.0 2784 * 2785 * Unless required by applicable law or agreed to in writing, software 2786 * distributed under the License is distributed on an "AS IS" BASIS, 2787 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2788 * See the License for the specific language governing permissions and 2789 * limitations under the License. 2790 */const Ji="RestConnection",LE={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery",ExecutePipeline:"executePipeline"};class ME{get Ko(){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.qo=t+"://"+e.host,this.Uo=`projects/${r}/databases/${s}`,this.$o=this.databaseId.database===Ds?`project_id=${r}`:`project_id=${r}&database_id=${s}`}Wo(e,t,r,s,i){const a=wo(),u=this.Qo(e,t.toUriEncodedString());O(Ji,`Sending RPC '${e}' ${a}:`,u,r);const l={"google-cloud-resource-prefix":this.Uo,"x-goog-request-params":this.$o};this.Go(l,s,i);const{host:d}=new URL(u),f=ot(d);return this.zo(e,u,l,r,f).then((m=>(O(Ji,`Received RPC '${e}' ${a}: `,m),m)),(m=>{throw Cn(Ji,`RPC '${e}' ${a} failed with error: `,m,"url: ",u,"request:",r),m}))}jo(e,t,r,s,i,a){return this.Wo(e,t,r,s,i)}Go(e,t,r){e["X-Goog-Api-Client"]=(function(){return"gl-js/ fire/"+xn})(),e["Content-Type"]="text/plain",this.databaseInfo.appId&&(e["X-Firebase-GMPID"]=this.databaseInfo.appId),t&&t.headers.forEac
vendor: 4,562 bytes, lines 2790-2820
2790h(((s,i)=>e[i]=s)),r&&r.headers.forEach(((s,i)=>e[i]=s))}Qo(e,t){const r=LE[e];let s=`${this.qo}/v1/${t}:${r}`;return this.databaseInfo.apiKey&&(s=`${s}?key=${encodeURIComponent(this.databaseInfo.apiKey)}`),s}terminate(){}}/** 2791 * @license 2792 * Copyright 2017 Google LLC 2793 * 2794 * Licensed under the Apache License, Version 2.0 (the "License"); 2795 * you may not use this file except in compliance with the License. 2796 * You may obtain a copy of the License at 2797 * 2798 * http://www.apache.org/licenses/LICENSE-2.0 2799 * 2800 * Unless required by applicable law or agreed to in writing, software 2801 * distributed under the License is distributed on an "AS IS" BASIS, 2802 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2803 * See the License for the specific language governing permissions and 2804 * limitations under the License. 2805 */class xE{constructor(e){this.Ho=e.Ho,this.Jo=e.Jo}Zo(e){this.Xo=e}Yo(e){this.e_=e}t_(e){this.n_=e}onMessage(e){this.r_=e}close(){this.Jo()}send(e){this.Ho(e)}i_(){this.Xo()}s_(){this.e_()}o_(e){this.n_(e)}__(e){this.r_(e)}}/** 2806 * @license 2807 * Copyright 2017 Google LLC 2808 * 2809 * Licensed under the Apache License, Version 2.0 (the "License"); 2810 * you may not use this file except in compliance with the License. 2811 * You may obtain a copy of the License at 2812 * 2813 * http://www.apache.org/licenses/LICENSE-2.0 2814 * 2815 * Unless required by applicable law or agreed to in writing, software 2816 * distributed under the License is distributed on an "AS IS" BASIS, 2817 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2818 * See the License for the specific language governing permissions and 2819 * limitations under the License. 2820 */const Te="WebChannelConnection",ir=(n,e,t)=>{n.listen(e,(r=>{try{t(r)}catch(s){setTimeout((()=>{throw s}),0)}}))};class Sn extends ME{constructor(e){super(e),this.a_=[],this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}static u_(){if(!Sn.c_){const e=dh();ir(e,hh.STAT_EVENT,(t=>{t.stat===co.PROXY?O(Te,"STAT_EVENT: detected buffering proxy"):t.stat===co.NOPROXY&&O(Te,"STAT_EVENT: detected no buffering proxy")})),Sn.c_=!0}}zo(e,t,r,s,i){const a=wo();return new Promise(((u,l)=>{const d=new uh;d.setWithCredentials(!0),d.listenOnce(lh.COMPLETE,(()=>{try{switch(d.getLastErrorCode()){case gs.NO_ERROR:const m=d.getResponseJson();O(Te,`XHR for RPC '${e}' ${a} received:`,JSON.stringify(m)),u(m);break;case gs.TIMEOUT:O(Te,`RPC '${e}' ${a} timed out`),l(new V(P.DEADLINE_EXCEEDED,"Request time out"));break;case gs.HTTP_ERROR:const _=d.getStatus();if(O(Te,`RPC '${e}' ${a} failed with status:`,_,"response text:",d.getResponseText()),_>0){let S=d.getResponseJson();Array.isArray(S)&&(S=S[0]);const C=S==null?void 0:S.error;if(C&&C.status&&C.message){const D=(function(q){const F=q.toLowerCase().replace(/_/g,"-");return Object.values(P).indexOf(F)>=0?F:P.UNKNOWN})(C.status);l(new V(D,C.message))}else l(new V(P.UNKNOWN,"Server responded with status "+d.getStatus()))}else l(new V(P.UNAVAILABLE,"Connection failed."));break;default:x(9055,{l_:e,streamId:a,h_:d.getLastErrorCode(),P_:d.getLastError()})}}finally{O(Te,`RPC '${e}' ${a} completed.`)}}));const f=JSON.stringify(s);O(Te,`RPC '${e}' ${a} sending request:`,s),d.send(t,"POST",f,r,15)}))}T_(e,t,r){const s=wo(),i=[this.qo,"/","google.firestore.v1.Firestore","/",e,"/channel"],a=this.createWebChannelTransport(),u={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},l=this.longPollingOptions.timeoutSeconds;l!==void 0&&(u.longPollingTimeout=Math.round(1e3*l)),this.useFetchStreams&&(u.useFetchStreams=!0),this.Go(u.initMessageHeaders,t,r),u.encodeInitMessageHeaders=!0;const d=i.join("");O(Te,`Creating RPC '${e}' stream ${s}: ${d}`,u);const f=a.createWebChannel(d,u);this.I_(f);let m=!1,_=!1;const S=new xE({Ho:C=>{_?O(Te,`Not sending because RPC '${e}' stream ${s} is closed:`,C):(m||(O(Te,`Opening RPC '${e}' stream ${s} transport.`),f.open(),m=!0),O(Te,`RPC '${e}' stream ${s} sending:`,C),f.send(C))},Jo:()=>f.close()});return ir(f,ur.EventType.OPEN,(()=>{_||(O(Te,`RPC '${e}' stream ${s} transport opened.`),S.i_())})),ir(f,ur.EventType.CLOSE,(()=>{_||(_=!0,O(Te,`RPC '${e}' stream ${s} transport closed`),S.o_(),this.E_(f))}
2820)),ir(f,ur.EventType.ERROR,(C=>{_||(_=!0,Cn(Te,`RPC '${e}' stream ${s} transport errored. Name:`,C.name,"Message:",C.message),S.o_(new V(P.UNAVAILABLE,"The operation could not be completed")))})),ir(f,ur.EventType.MESSAGE,(C=>{var D;if(!_){const k=C.data[0];J(!!k,16349);const q=k,F=(q==null?void 0:q.error)||((D=q[0])==null?void 0:D.error);if(F){O(Te,`RPC '${e}' stream ${s} received error:`,F);const $=F.status;let Q=(function(I){const g=ue[I];if(g!==void 0)return Wh(g)})($),ce=F.message;Q===void 0&&(Q=P.INTERNAL,ce="Unknown error status: "+$+" with message "+F.message),_=!0,S.o_(new V(Q,ce)),f.close()}else O(Te,`RPC '${e}' stream ${s} received:`,k),S.__(k)}})),Sn.u_(),setTimeout((()=>{S.s_()}),0),S}terminate(){this.a_.forEach((e=>e.close())),this.a_=[]}I_(e){this.a_.push(e)}E_(e){this.a_=this.a_.filter((t=>t===e))}Go(e,t,r){super.Go(e,t,r),this.databaseInfo.apiKey&&(e["x-goog-api-key"]=this.databaseInfo.apiKey)}createWebChannelTransport(){return fh()}}/** 2821 * @license 2822 * Copyright 2020 Google LLC 2823 * 2824 * Licensed under the Apache License, Version 2.0 (the "License"); 2825 * you may not use this file except in compliance with the License. 2826 * You may obtain a copy of the License at 2827 * 2828 * http://www.apache.org/licenses/LICENSE-2.0 2829 * 2830 * Unless required by applicable law or agreed to in writing, software 2831 * distributed under the License is distributed on an "AS IS" BASIS, 2832 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2833 * See the License for the specific language governing permissions and 2834 * limitations under the License. 2835 */function UE(n){return new Sn(n)}function Yi(){return typeof document<"u"?document:null}/** 2836 * @license 2837 * Copyright 2020 Google LLC 2838 * 2839 * Licensed under the Apache License, Version 2.0 (the "License"); 2840 * you may not use this file except in compliance with the License. 2841 * You may obtain a copy of the License at 2842 * 2843 * http://www.apache.org/licenses/LICENSE-2.0 2844 * 2845 * Unless required by applicable law or agreed to in writing, software 2846 * distributed under the License is distributed on an "AS IS" BASIS, 2847 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2848 * See the License for the specific language governing permissions and 2849 * limitations under the License. 2850 */function ui(n){return new $y(n,!0)}/** 2851 * @license 2852 * Copyright 2017 Google LLC 2853 * 2854 * Licensed under the Apache License, Version 2.0 (the "License"); 2855 * you may not use this file except in compliance with the License. 2856 * You may obtain a copy of the License at 2857 * 2858 * http://www.apache.org/licenses/LICENSE-2.0 2859 * 2860 * Unless required by applicable law or agreed to in writing, software 2861 * distributed under the License is distributed on an "AS IS" BASIS, 2862 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2863 * See the License for the specific language governing permissions and 2864 * limitations under the License. 2865 */Sn.c_=!1;class cd{constructor(e,t,r=1e3,s=1.5,i=6e4){this.Ci=e,this.timerId=t,this.R_=r,this.A_=s,this.V_=i,this.d_=0,this.m_=null,this.f_=Date.now(),this.reset()}reset(){this.d_=0}g_(){this.d_=this.V_}p_(e){this.cancel();const t=Math.floor(this.d_+this.y_()),r=Math.max(0,Date.now()-this.f_),s=Math.max(0,t-r);s>0&&O("ExponentialBackoff",`Backing off for ${s} ms (base delay: ${this.d_} ms, delay with jitter: ${t} ms, last attempt: ${r} ms ago)`),this.m_=this.Ci.enqueueAfterDelay(this.timerId,s,(()=>(this.f_=Date.now(),e()))),this.d_*=this.A_,this.d_<this.R_&&(this.d_=this.R_),this.d_>this.V_&&(this.d_=this.V_)}w_(){this.m_!==null&&(this.m_.skipDelay(),this.m_=null)}cancel(){this.m_!==null&&(this.m_.cancel(),this.m_=null)}y_(){return(Math.random()-.5)*this.d_}}/** 2866 * @license 2867 * Copyright 2017 Google LLC 2868 * 2869 * Licensed under the Apache License, Version 2.0 (the "License"); 2870 * you may not use this file except in compliance with the License. 2871 * You may obtain a copy of the License at 2872 * 2873 * http://www.apache.org/licenses/LICENSE-2.0 2874 * 2875 * Unless required by applicable law or agreed to in writing, software 2876 * distributed under the License is distributed on an "AS IS" BASIS, 2877 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2878 * See the License for the specific language governing permissions and 2879 * limitations under the License. 2880 */const $u="PersistentStream";class ud{constructor(e,t,r,s,i,a,u,l){this.Ci=e,this.b_=r,this.S_=s,this.connection=i,this.authCredentialsProvider=a,this.appCheckCredentialsProvider=u,this.listener=l,this.state=0,this.D_=0,this.C_=null,this.v_=null,this.stream=null,this.F_=0,this.M_=new cd(e,t)}x_(){return this.state===1||this.state===5||this.O_()}O_(){return this.state===2||this.state===3}start(){this.F_=0,this.state!==4?this.auth():this.N_()}async stop(){this.x_()&&await this.close(0)}B_(){this.state=0,this.M_.reset()}L_(){this.O_()&&this.C_===null&&(this.C_=this.Ci.enqueueAfterDelay(this.b_,6e4,(()=>this.k_())))}K_(e){this.q_(),this.stream.send(e)}
2880async k_(){if(this.O_())return this.close(0)}q_(){this.C_&&(this.C_.cancel(),this.C_=null)}U_(){this.v_&&(this.v_.cancel(),this.v_=null)}async close(e,t){this.q_(),this.U_(),this.M_.cancel(),this.D_++,e!==4?this.M_.reset():t&&t.code===P.RESOURCE_EXHAUSTED?(pt(t.toString()),pt("Using maximum backoff delay to prevent overloading the backend."),this.M_.g_()):t&&t.code===P.UNAUTHENTICATED&&this.state!==3&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),this.stream!==null&&(this.W_(),this.stream.close(),this.stream=null),this.state=e,await this.listener.t_(t)}W_(){}auth(){this.state=1;const e=this.Q_(this.D_),t=this.D_;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then((([r,s])=>{this.D_===t&&this.G_(r,s)}),(r=>{e((()=>{const s=new V(P.UNKNOWN,"Fetching auth token failed: "+r.message);return this.z_(s)}))}))}G_(e,t){const r=this.Q_(this.D_);this.stream=this.j_(e,t),this.stream.Zo((()=>{r((()=>this.listener.Zo()))})),this.stream.Yo((()=>{r((()=>(this.state=2,this.v_=this.Ci.enqueueAfterDelay(this.S_,1e4,(()=>(this.O_()&&(this.state=3),Promise.resolve()))),this.listener.Yo())))})),this.stream.t_((s=>{r((()=>this.z_(s)))})),this.stream.onMessage((s=>{r((()=>++this.F_==1?this.H_(s):this.onNext(s)))}))}N_(){this.state=5,this.M_.p_((async()=>{this.state=0,this.start()}))}z_(e){return O($u,`close with error: ${e}`),this.stream=null,this.close(4,e)}Q_(e){return t=>{this.Ci.enqueueAndForget((()=>this.D_===e?t():(O($u,"stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())))}}}class FE extends ud{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}j_(e,t){return this.connection.T_("Listen",e,t)}H_(e){return this.onNext(e)}onNext(e){this.M_.reset();const t=zy(this.serializer,e),r=(function(i){if(!("targetChange"in i))return U.min();const a=i.targetChange;return a.targetIds&&a.targetIds.length?U.min():a.readTime?nt(a.readTime):U.min()})(e);return this.listener.J_(t,r)}Z_(e){const t={};t.database=To(this.serializer),t.addTarget=(function(i,a){let u;const l=a.target;if(u=po(l)?{documents:Ky(i,l)}:{query:Qy(i,l).ft},u.targetId=a.targetId,a.resumeToken.approximateByteSize()>0){u.resumeToken=Jh(i,a.resumeToken);const d=_o(i,a.expectedCount);d!==null&&(u.expectedCount=d)}else if(a.snapshotVersion.compareTo(U.min())>0){u.readTime=Ms(i,a.snapshotVersion.toTimestamp());const d=_o(i,a.expectedCount);d!==null&&(u.expectedCount=d)}return u})(this.serializer,e);const r=Yy(this.serializer,e);r&&(t.labels=r),this.K_(t)}X_(e){const t={};t.database=To(this.serializer),t.removeTarget=e,this.K_(t)}}class BE extends ud{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 Y_(){return this.F_>0}start(){this.lastStreamToken=void 0,super.start()}W_(){this.Y_&&this.ea([])}j_(e,t){return this.connection.T_("Write",e,t)}H_(e){return J(!!e.streamToken,31322),this.lastStreamToken=e.streamToken,J(!e.writeResults||e.writeResults.length===0,55816),this.listener.ta()}onNext(e){J(!!e.streamToken,12678),this.lastStreamToken=e.streamToken,this.M_.reset();const t=Wy(e.writeResults,e.commitTime),r=nt(e.commitTime);return this.listener.na(r,t)}ra(){const e={};e.database=To(this.serializer),this.K_(e)}ea(e){const t={streamToken:this.lastStreamToken,writes:e.map((r=>Gy(this.serializer,r)))};this.K_(t)}}/** 2881 * @license 2882 * Copyright 2017 Google LLC 2883 * 2884 * Licensed under the Apache License, Version 2.0 (the "License"); 2885 * you may not use this file except in compliance with the License. 2886 * You may obtain a copy of the License at 2887 * 2888 * http://www.apache.org/licenses/LICENSE-2.0 2889 * 2890 * Unless required by applicable law or agreed to in writing, software 2891 * distributed under the License is distributed on an "AS IS" BASIS, 2892 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2893 * See the License for the specific language governing permissions and 2894 * limitations under the License. 2895 */class qE{}class $E extends qE{constructor(e,t,r,s){super(),this.authCredentials=e,this.appCheckCredentials=t,this.connection=r,this.serializer
2895=s,this.ia=!1}sa(){if(this.ia)throw new V(P.FAILED_PRECONDITION,"The client has already been terminated.")}Wo(e,t,r,s){return this.sa(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([i,a])=>this.connection.Wo(e,yo(t,r),s,i,a))).catch((i=>{throw i.name==="FirebaseError"?(i.code===P.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),i):new V(P.UNKNOWN,i.toString())}))}jo(e,t,r,s,i){return this.sa(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([a,u])=>this.connection.jo(e,yo(t,r),s,a,u,i))).catch((a=>{throw a.name==="FirebaseError"?(a.code===P.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),a):new V(P.UNKNOWN,a.toString())}))}terminate(){this.ia=!0,this.connection.terminate()}}function jE(n,e,t,r){return new $E(n,e,t,r)}class HE{constructor(e,t){this.asyncQueue=e,this.onlineStateHandler=t,this.state="Unknown",this.oa=0,this._a=null,this.aa=!0}ua(){this.oa===0&&(this.ca("Unknown"),this._a=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,(()=>(this._a=null,this.la("Backend didn't respond within 10 seconds."),this.ca("Offline"),Promise.resolve()))))}ha(e){this.state==="Online"?this.ca("Unknown"):(this.oa++,this.oa>=1&&(this.Pa(),this.la(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.ca("Offline")))}set(e){this.Pa(),this.oa=0,e==="Online"&&(this.aa=!1),this.ca(e)}ca(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}la(e){const t=`Could not reach Cloud Firestore backend. ${e} 2896This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.`;this.aa?(pt(t),this.aa=!1):O("OnlineStateTracker",t)}Pa(){this._a!==null&&(this._a.cancel(),this._a=null)}}/** 2897 * @license 2898 * Copyright 2017 Google LLC 2899 * 2900 * Licensed under the Apache License, Version 2.0 (the "License"); 2901 * you may not use this file except in compliance with the License. 2902 * You may obtain a copy of the License at 2903 * 2904 * http://www.apache.org/licenses/LICENSE-2.0 2905 * 2906 * Unless required by applicable law or agreed to in writing, software 2907 * distributed under the License is distributed on an "AS IS" BASIS, 2908 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2909 * See the License for the specific language governing permissions and 2910 * limitations under the License. 2911 */const on="RemoteStore";class zE{constructor(e,t,r,s,i){this.localStore=e,this.datastore=t,this.asyncQueue=r,this.remoteSyncer={},this.Ta=[],this.Ia=new Map,this.Ea=new Set,this.Ra=[],this.Aa=i,this.Aa.Mo((a=>{r.enqueueAndForget((async()=>{dn(this)&&(O(on,"Restarting streams for network reachability change."),await(async function(l){const d=B(l);d.Ea.add(4),await Fr(d),d.Va.set("Unknown"),d.Ea.delete(4),await li(d)})(this))}))})),this.Va=new HE(r,s)}}async function li(n){if(dn(n))for(const e of n.Ra)await e(!0)}async function Fr(n){for(const e of n.Ra)await e(!1)}function ld(n,e){const t=B(n);t.Ia.has(e.targetId)||(t.Ia.set(e.targetId,e),aa(t)?oa(t):qn(t).O_()&&ia(t,e))}function sa(n,e){const t=B(n),r=qn(t);t.Ia.delete(e),r.O_()&&hd(t,e),t.Ia.size===0&&(r.O_()?r.L_():dn(t)&&t.Va.set("Unknown"))}function ia(n,e){if(n.da.$e(e.targetId),e.resumeToken.approximateByteSize()>0||e.snapshotVersion.compareTo(U.min())>0){const t=n.remoteSyncer.getRemoteKeysForTarget(e.targetId).size;e=e.withExpectedCount(t)}qn(n).Z_(e)}function hd(n,e){n.da.$e(e),qn(n).X_(e)}function oa(n){n.da=new Uy({getRemoteKeysForTarget:e=>n.remoteSyncer.getRemoteKeysForTarget(e),At:e=>n.Ia.get(e)||null,ht:()=>n.datastore.serializer.databaseId}),qn(n).start(),n.Va.ua()}function aa(n){return dn(n)&&!qn(n).x_()&&n.Ia.size>0}function dn(n){return B(n).Ea.size===0}function dd(n){n.da=void 0}async function GE(n){n.Va.set("Online")}async function WE(n){n.Ia.forEach(((e,t)=>{ia(n,e)}))}async function KE(n,e){dd(n),aa(n)?(n.Va.ha(e),oa(n)):n.Va.set("Unknown")}
2911async function QE(n,e,t){if(n.Va.set("Online"),e instanceof Qh&&e.state===2&&e.cause)try{await(async function(s,i){const a=i.cause;for(const u of i.targetIds)s.Ia.has(u)&&(await s.remoteSyncer.rejectListen(u,a),s.Ia.delete(u),s.da.removeTarget(u))})(n,e)}catch(r){O(on,"Failed to remove targets %s: %s ",e.targetIds.join(","),r),await Us(n,r)}else if(e instanceof Ts?n.da.Xe(e):e instanceof Kh?n.da.st(e):n.da.tt(e),!t.isEqual(U.min()))try{const r=await ad(n.localStore);t.compareTo(r)>=0&&await(function(i,a){const u=i.da.Tt(a);return u.targetChanges.forEach(((l,d)=>{if(l.resumeToken.approximateByteSize()>0){const f=i.Ia.get(d);f&&i.Ia.set(d,f.withResumeToken(l.resumeToken,a))}})),u.targetMismatches.forEach(((l,d)=>{const f=i.Ia.get(l);if(!f)return;i.Ia.set(l,f.withResumeToken(ye.EMPTY_BYTE_STRING,f.snapshotVersion)),hd(i,l);const m=new Ct(f.target,l,d,f.sequenceNumber);ia(i,m)})),i.remoteSyncer.applyRemoteEvent(u)})(n,t)}catch(r){O(on,"Failed to raise snapshot:",r),await Us(n,r)}}async function Us(n,e,t){if(!Fn(e))throw e;n.Ea.add(1),await Fr(n),n.Va.set("Offline"),t||(t=()=>ad(n.localStore)),n.asyncQueue.enqueueRetryable((async()=>{O(on,"Retrying IndexedDB access"),await t(),n.Ea.delete(1),await li(n)}))}function fd(n,e){return e().catch((t=>Us(n,t,e)))}async function hi(n){const e=B(n),t=Ft(e);let r=e.Ta.length>0?e.Ta[e.Ta.length-1].batchId:Ho;for(;JE(e);)try{const s=await kE(e.localStore,r);if(s===null){e.Ta.length===0&&t.L_();break}r=s.batchId,YE(e,s)}catch(s){await Us(e,s)}pd(e)&&md(e)}function JE(n){return dn(n)&&n.Ta.length<10}function YE(n,e){n.Ta.push(e);const t=Ft(n);t.O_()&&t.Y_&&t.ea(e.mutations)}function pd(n){return dn(n)&&!Ft(n).x_()&&n.Ta.length>0}function md(n){Ft(n).start()}async function XE(n){Ft(n).ra()}async function ZE(n){const e=Ft(n);for(const t of n.Ta)e.ea(t.mutations)}async function eT(n,e,t){const r=n.Ta.shift(),s=Yo.from(r,e,t);await fd(n,(()=>n.remoteSyncer.applySuccessfulWrite(s))),await hi(n)}async function tT(n,e){e&&Ft(n).Y_&&await(async function(r,s){if((function(a){return Ly(a)&&a!==P.ABORTED})(s.code)){const i=r.Ta.shift();Ft(r).B_(),await fd(r,(()=>r.remoteSyncer.rejectFailedWrite(i.batchId,s))),await hi(r)}})(n,e),pd(n)&&md(n)}async function ju(n,e){const t=B(n);t.asyncQueue.verifyOperationInProgress(),O(on,"RemoteStore received new credentials");const r=dn(t);t.Ea.add(3),await Fr(t),r&&t.Va.set("Unknown"),await t.remoteSyncer.handleCredentialChange(e),t.Ea.delete(3),await li(t)}async function nT(n,e){const t=B(n);e?(t.Ea.delete(2),await li(t)):e||(t.Ea.add(2),await Fr(t),t.Va.set("Unknown"))}function qn(n){return n.ma||(n.ma=(function(t,r,s){const i=B(t);return i.sa(),new FE(r,i.connection,i.authCredentials,i.appCheckCredentials,i.serializer,s)})(n.datastore,n.asyncQueue,{Zo:GE.bind(null,n),Yo:WE.bind(null,n),t_:KE.bind(null,n),J_:QE.bind(null,n)}),n.Ra.push((async e=>{e?(n.ma.B_(),aa(n)?oa(n):n.Va.set("Unknown")):(await n.ma.stop(),dd(n))}))),n.ma}function Ft(n){return n.fa||(n.fa=(function(t,r,s){const i=B(t);return i.sa(),new BE(r,i.connection,i.authCredentials,i.appCheckCredentials,i.serializer,s)})(n.datastore,n.asyncQueue,{Zo:()=>Promise.resolve(),Yo:XE.bind(null,n),t_:tT.bind(null,n),ta:ZE.bind(null,n),na:eT.bind(null,n)}),n.Ra.push((async e=>{e?(n.fa.B_(),await hi(n)):(await n.fa.stop(),n.Ta.length>0&&(O(on,`Stopping write stream with ${n.Ta.length} pending writes`),n.Ta=[]))}))),n.fa}/** 2912 * @license 2913 * Copyright 2017 Google LLC 2914 * 2915 * Licensed under the Apache License, Version 2.0 (the "License"); 2916 * you may not use this file except in compliance with the License. 2917 * You may obtain a copy of the License at 2918 * 2919 * http://www.apache.org/licenses/LICENSE-2.0 2920 * 2921 * Unless required by applicable law or agreed to in writing, software 2922 * distributed under the License is distributed on an "AS IS" BASIS, 2923 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2924 * See the License for the specific language governing permissions and 2925 * limitations under the License. 2926 */class ca{constructor(e,t,r,s,i){this.asyncQueue=e,this.timerId=t,this.targetTimeMs=r,this.op=s,this.removalCallback=i,this.deferred=new lt,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,u=new ca(e,t,a,s,i);return u.start(r),u}start(e){this.timerHandle=setTimeout((()=>this.handleDelayElapsed()),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){this.timerHandle!==null&&(this.clearTimeout(),this.deferred.reject(new V(P.CANCELLED,"Operation cancelled"+(e?": "+e:""))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget((()=>this.timerHandle!==null?(this.clearTimeout(),this.op().then((e=>
2926this.deferred.resolve(e)))):Promise.resolve()))}clearTimeout(){this.timerHandle!==null&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}}function ua(n,e){if(pt("AsyncQueue",`${e}: ${n}`),Fn(n))return new V(P.UNAVAILABLE,`${e}: ${n}`);throw n}/** 2927 * @license 2928 * Copyright 2017 Google LLC 2929 * 2930 * Licensed under the Apache License, Version 2.0 (the "License"); 2931 * you may not use this file except in compliance with the License. 2932 * You may obtain a copy of the License at 2933 * 2934 * http://www.apache.org/licenses/LICENSE-2.0 2935 * 2936 * Unless required by applicable law or agreed to in writing, software 2937 * distributed under the License is distributed on an "AS IS" BASIS, 2938 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2939 * See the License for the specific language governing permissions and 2940 * limitations under the License. 2941 */class Pn{static emptySet(e){return new Pn(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=lr(),this.sortedSet=new re(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 Pn)||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 ( 2942 `+e.join(` 2943`)+` 2944)`}copy(e,t){const r=new Pn;return r.comparator=this.comparator,r.keyedMap=e,r.sortedSet=t,r}}/** 2945 * @license 2946 * Copyright 2017 Google LLC 2947 * 2948 * Licensed under the Apache License, Version 2.0 (the "License"); 2949 * you may not use this file except in compliance with the License. 2950 * You may obtain a copy of the License at 2951 * 2952 * http://www.apache.org/licenses/LICENSE-2.0 2953 * 2954 * Unless required by applicable law or agreed to in writing, software 2955 * distributed under the License is distributed on an "AS IS" BASIS, 2956 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2957 * See the License for the specific language governing permissions and 2958 * limitations under the License. 2959 */class Hu{constructor(){this.ga=new re(L.comparator)}track(e){const t=e.doc.key,r=this.ga.get(t);r?e.type!==0&&r.type===3?this.ga=this.ga.insert(t,e):e.type===3&&r.type!==1?this.ga=this.ga.insert(t,{type:r.type,doc:e.doc}):e.type===2&&r.type===2?this.ga=this.ga.insert(t,{type:2,doc:e.doc}):e.type===2&&r.type===0?this.ga=this.ga.insert(t,{type:0,doc:e.doc}):e.type===1&&r.type===0?this.ga=this.ga.remove(t):e.type===1&&r.type===2?this.ga=this.ga.insert(t,{type:1,doc:r.doc}):e.type===0&&r.type===1?this.ga=this.ga.insert(t,{type:2,doc:e.doc}):x(63341,{Vt:e,pa:r}):this.ga=this.ga.insert(t,e)}ya(){const e=[];return this.ga.inorderTraversal(((t,r)=>{e.push(r)})),e}}class On{constructor(e,t,r,s,i,a,u,l,d){this.query=e,this.docs=t,this.oldDocs=r,this.docChanges=s,this.mutatedKeys=i,this.fromCache=a,this.syncStateChanged=u,this.excludesMetadataChanges=l,this.hasCachedResults=d}static fromInitialDocuments(e,t,r,s,i){const a=[];return t.forEach((u=>{a.push({type:0,doc:u})})),new On(e,t,Pn.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)&&si(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}}/** 2960 * @license 2961 * Copyright 2017 Google LLC 2962 * 2963 * Licensed under the Apache License, Version 2.0 (the "License");
2964 * you may not use this file except in compliance with the License. 2965 * You may obtain a copy of the License at 2966 * 2967 * http://www.apache.org/licenses/LICENSE-2.0 2968 * 2969 * Unless required by applicable law or agreed to in writing, software 2970 * distributed under the License is distributed on an "AS IS" BASIS, 2971 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2972 * See the License for the specific language governing permissions and 2973 * limitations under the License. 2974 */class rT{constructor(){this.wa=void 0,this.ba=[]}Sa(){return this.ba.some((e=>e.Da()))}}class sT{constructor(){this.queries=zu(),this.onlineState="Unknown",this.Ca=new Set}terminate(){(function(t,r){const s=B(t),i=s.queries;s.queries=zu(),i.forEach(((a,u)=>{for(const l of u.ba)l.onError(r)}))})(this,new V(P.ABORTED,"Firestore shutting down"))}}function zu(){return new hn((n=>Lh(n)),si)}async function la(n,e){const t=B(n);let r=3;const s=e.query;let i=t.queries.get(s);i?!i.Sa()&&e.Da()&&(r=2):(i=new rT,r=e.Da()?0:1);try{switch(r){case 0:i.wa=await t.onListen(s,!0);break;case 1:i.wa=await t.onListen(s,!1);break;case 2:await t.onFirstRemoteStoreListen(s)}}catch(a){const u=ua(a,`Initialization of query '${En(e.query)}' failed`);return void e.onError(u)}t.queries.set(s,i),i.ba.push(e),e.va(t.onlineState),i.wa&&e.Fa(i.wa)&&da(t)}async function ha(n,e){const t=B(n),r=e.query;let s=3;const i=t.queries.get(r);if(i){const a=i.ba.indexOf(e);a>=0&&(i.ba.splice(a,1),i.ba.length===0?s=e.Da()?0:1:!i.Sa()&&e.Da()&&(s=2))}switch(s){case 0:return t.queries.delete(r),t.onUnlisten(r,!0);case 1:return t.queries.delete(r),t.onUnlisten(r,!1);case 2:return t.onLastRemoteStoreUnlisten(r);default:return}}function iT(n,e){const t=B(n);let r=!1;for(const s of e){const i=s.query,a=t.queries.get(i);if(a){for(const u of a.ba)u.Fa(s)&&(r=!0);a.wa=s}}r&&da(t)}function oT(n,e,t){const r=B(n),s=r.queries.get(e);if(s)for(const i of s.ba)i.onError(t);r.queries.delete(e)}function da(n){n.Ca.forEach((e=>{e.next()}))}var vo,Gu;(Gu=vo||(vo={})).Ma="default",Gu.Cache="cache";class fa{constructor(e,t,r){this.query=e,this.xa=t,this.Oa=!1,this.Na=null,this.onlineState="Unknown",this.options=r||{}}Fa(e){if(!this.options.includeMetadataChanges){const r=[];for(const s of e.docChanges)s.type!==3&&r.push(s);e=new On(e.query,e.docs,e.oldDocs,r,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let t=!1;return this.Oa?this.Ba(e)&&(this.xa.next(e),t=!0):this.La(e,this.onlineState)&&(this.ka(e),t=!0),this.Na=e,t}onError(e){this.xa.error(e)}va(e){this.onlineState=e;let t=!1;return this.Na&&!this.Oa&&this.La(this.Na,e)&&(this.ka(this.Na),t=!0),t}La(e,t){if(!e.fromCache||!this.Da())return!0;const r=t!=="Offline";return(!this.options.Ka||!r)&&(!e.docs.isEmpty()||e.hasCachedResults||t==="Offline")}Ba(e){if(e.docChanges.length>0)return!0;const t=this.Na&&this.Na.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&this.options.includeMetadataChanges===!0}ka(e){e=On.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.Oa=!0,this.xa.next(e)}Da(){return this.options.source!==vo.Cache}}/** 2975 * @license 2976 * Copyright 2017 Google LLC 2977 * 2978 * Licensed under the Apache License, Version 2.0 (the "License"); 2979 * you may not use this file except in compliance with the License. 2980 * You may obtain a copy of the License at 2981 * 2982 * http://www.apache.org/licenses/LICENSE-2.0 2983 * 2984 * Unless required by applicable law or agreed to in writing, software 2985 * distributed under the License is distributed on an "AS IS" BASIS, 2986 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2987 * See the License for the specific language governing permissions and 2988 * limitations under the License. 2989 */class gd{constructor(e){this.key=e}}class _d{constructor(e){this.key=e}}class aT{constructor(e,t){this.query=e,this.Za=t,this.Xa=null,this.hasCachedResults=!1,this.current=!1,this.Ya=W(),this.mutatedKeys=W(),this.eu=Mh(e),this.tu=new Pn(this.eu)}get nu(){return this.Za}ru(e,t){const r=t?t.iu:new Hu,s=t?t.tu:this.tu;let i=t?t.mutatedKeys:this.mutatedKeys,a=s,u=!1;const l=this.query.limitType==="F"&&s.size===this.query.limit?s.last(
2989):null,d=this.query.limitType==="L"&&s.size===this.query.limit?s.first():null;if(e.inorderTraversal(((f,m)=>{const _=s.get(f),S=ii(this.query,m)?m:null,C=!!_&&this.mutatedKeys.has(_.key),D=!!S&&(S.hasLocalMutations||this.mutatedKeys.has(S.key)&&S.hasCommittedMutations);let k=!1;_&&S?_.data.isEqual(S.data)?C!==D&&(r.track({type:3,doc:S}),k=!0):this.su(_,S)||(r.track({type:2,doc:S}),k=!0,(l&&this.eu(S,l)>0||d&&this.eu(S,d)<0)&&(u=!0)):!_&&S?(r.track({type:0,doc:S}),k=!0):_&&!S&&(r.track({type:1,doc:_}),k=!0,(l||d)&&(u=!0)),k&&(S?(a=a.add(S),i=D?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{tu:a,iu:r,Ss:u,mutatedKeys:i}}su(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}applyChanges(e,t,r,s){const i=this.tu;this.tu=e.tu,this.mutatedKeys=e.mutatedKeys;const a=e.iu.ya();a.sort(((f,m)=>(function(S,C){const D=k=>{switch(k){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return x(20277,{Vt:k})}};return D(S)-D(C)})(f.type,m.type)||this.eu(f.doc,m.doc))),this.ou(r),s=s??!1;const u=t&&!s?this._u():[],l=this.Ya.size===0&&this.current&&!s?1:0,d=l!==this.Xa;return this.Xa=l,a.length!==0||d?{snapshot:new On(this.query,e.tu,i,a,e.mutatedKeys,l===0,d,!1,!!r&&r.resumeToken.approximateByteSize()>0),au:u}:{au:u}}va(e){return this.current&&e==="Offline"?(this.current=!1,this.applyChanges({tu:this.tu,iu:new Hu,mutatedKeys:this.mutatedKeys,Ss:!1},!1)):{au:[]}}uu(e){return!this.Za.has(e)&&!!this.tu.has(e)&&!this.tu.get(e).hasLocalMutations}ou(e){e&&(e.addedDocuments.forEach((t=>this.Za=this.Za.add(t))),e.modifiedDocuments.forEach((t=>{})),e.removedDocuments.forEach((t=>this.Za=this.Za.delete(t))),this.current=e.current)}_u(){if(!this.current)return[];const e=this.Ya;this.Ya=W(),this.tu.forEach((r=>{this.uu(r.key)&&(this.Ya=this.Ya.add(r.key))}));const t=[];return e.forEach((r=>{this.Ya.has(r)||t.push(new _d(r))})),this.Ya.forEach((r=>{e.has(r)||t.push(new gd(r))})),t}cu(e){this.Za=e.ks,this.Ya=W();const t=this.ru(e.documents);return this.applyChanges(t,!0)}lu(){return On.fromInitialDocuments(this.query,this.tu,this.mutatedKeys,this.Xa===0,this.hasCachedResults)}}const pa="SyncEngine";class cT{constructor(e,t,r){this.query=e,this.targetId=t,this.view=r}}class uT{constructor(e){this.key=e,this.hu=!1}}class lT{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.Pu={},this.Tu=new hn((u=>Lh(u)),si),this.Iu=new Map,this.Eu=new Set,this.Ru=new re(L.comparator),this.Au=new Map,this.Vu=new ea,this.du={},this.mu=new Map,this.fu=Vn.ar(),this.onlineState="Unknown",this.gu=void 0}get isPrimaryClient(){return this.gu===!0}}async function hT(n,e,t=!0){const r=vd(n);let s;const i=r.Tu.get(e);return i?(r.sharedClientState.addLocalQueryTarget(i.targetId),s=i.view.lu()):s=await yd(r,e,t,!0),s}async function dT(n,e){const t=vd(n);await yd(t,e,!0,!1)}async function yd(n,e,t,r){const s=await NE(n.localStore,tt(e)),i=s.targetId,a=n.sharedClientState.addLocalQueryTarget(i,t);let u;return r&&(u=await fT(n,e,i,a==="current",s.resumeToken)),n.isPrimaryClient&&t&&ld(n.remoteStore,s),u}async function fT(n,e,t,r,s){n.pu=(m,_,S)=>(async function(D,k,q,F){let $=k.view.ru(q);$.Ss&&($=await Uu(D.localStore,k.query,!1).then((({documents:I})=>k.view.ru(I,$))));const Q=F&&F.targetChanges.get(k.targetId),ce=F&&F.targetMismatches.get(k.targetId)!=null,ne=k.view.applyChanges($,D.isPrimaryClient,Q,ce);return Ku(D,k.targetId,ne.au),ne.snapshot})(n,m,_,S);const i=await Uu(n.localStore,e,!0),a=new aT(e,i.ks),u=a.ru(i.documents),l=Ur.createSynthesizedTargetChangeForCurrentChange(t,r&&n.onlineState!=="Offline",s),d=a.applyChanges(u,n.isPrimaryClient,l);Ku(n,t,d.au);const f=new cT(e,t,a);return n.Tu.set(e,f),n.Iu.has(t)?n.Iu.get(t).push(e):n.Iu.set(t,[e]),d.snapshot}async function pT(n,e,t){const r=B(n),s=r.Tu.get(e),i=r.Iu.get(s.targetId);if(i.length>1)return r.Iu.set(s.targetId,i.filter((a=>!si(a,e)))),void r.Tu.delete(e);
2989r.isPrimaryClient?(r.sharedClientState.removeLocalQueryTarget(s.targetId),r.sharedClientState.isActiveQueryTarget(s.targetId)||await Io(r.localStore,s.targetId,!1).then((()=>{r.sharedClientState.clearQueryState(s.targetId),t&&sa(r.remoteStore,s.targetId),Ao(r,s.targetId)})).catch(Un)):(Ao(r,s.targetId),await Io(r.localStore,s.targetId,!0))}async function mT(n,e){const t=B(n),r=t.Tu.get(e),s=t.Iu.get(r.targetId);t.isPrimaryClient&&s.length===1&&(t.sharedClientState.removeLocalQueryTarget(r.targetId),sa(t.remoteStore,r.targetId))}async function gT(n,e,t){const r=vT(n);try{const s=await(function(a,u){const l=B(a),d=ee.now(),f=u.reduce(((S,C)=>S.add(C.key)),W());let m,_;return l.persistence.runTransaction("Locally write mutations","readwrite",(S=>{let C=mt(),D=W();return l.xs.getEntries(S,f).next((k=>{C=k,C.forEach(((q,F)=>{F.isValidDocument()||(D=D.add(q))}))})).next((()=>l.localDocuments.getOverlayedDocuments(S,C))).next((k=>{m=k;const q=[];for(const F of u){const $=ky(F,m.get(F.key).overlayedDocument);$!=null&&q.push(new $t(F.key,$,Ph($.value.mapValue),Fe.exists(!0)))}return l.mutationQueue.addMutationBatch(S,d,q,u)})).next((k=>{_=k;const q=k.applyToLocalDocumentSet(m,D);return l.documentOverlayCache.saveOverlays(S,k.batchId,q)}))})).then((()=>({batchId:_.batchId,changes:Uh(m)})))})(r.localStore,e);r.sharedClientState.addPendingMutation(s.batchId),(function(a,u,l){let d=a.du[a.currentUser.toKey()];d||(d=new re(G)),d=d.insert(u,l),a.du[a.currentUser.toKey()]=d})(r,s.batchId,t),await Br(r,s.changes),await hi(r.remoteStore)}catch(s){const i=ua(s,"Failed to persist write");t.reject(i)}}async function Ed(n,e){const t=B(n);try{const r=await bE(t.localStore,e);
2989e.targetChanges.forEach(((s,i)=>{const a=t.Au.get(i);a&&(J(s.addedDocuments.size+s.modifiedDocuments.size+s.removedDocuments.size<=1,22616),s.addedDocuments.size>0?a.hu=!0:s.modifiedDocuments.size>0?J(a.hu,14607):s.removedDocuments.size>0&&(J(a.hu,42227),a.hu=!1))})),await Br(t,r,e)}catch(r){await Un(r)}}function Wu(n,e,t){const r=B(n);if(r.isPrimaryClient&&t===0||!r.isPrimaryClient&&t===1){const s=[];r.Tu.forEach(((i,a)=>{const u=a.view.va(e);u.snapshot&&s.push(u.snapshot)})),(function(a,u){const l=B(a);l.onlineState=u;let d=!1;l.queries.forEach(((f,m)=>{for(const _ of m.ba)_.va(u)&&(d=!0)})),d&&da(l)})(r.eventManager,e),s.length&&r.Pu.J_(s),r.onlineState=e,r.isPrimaryClient&&r.sharedClientState.setOnlineState(e)}}async function _T(n,e,t){const r=B(n);r.sharedClientState.updateQueryState(e,"rejected",t);const s=r.Au.get(e),i=s&&s.key;if(i){let a=new re(L.comparator);a=a.insert(i,we.newNoDocument(i,U.min()));const u=W().add(i),l=new ci(U.min(),new Map,new re(G),a,u);await Ed(r,l),r.Ru=r.Ru.remove(i),r.Au.delete(e),ma(r)}else await Io(r.localStore,e,!1).then((()=>Ao(r,e,t))).catch(Un)}async function yT(n,e){const t=B(n),r=e.batch.batchId;try{const s=await PE(t.localStore,e);Id(t,r,null),Td(t,r),t.sharedClientState.updateMutationState(r,"acknowledged"),await Br(t,s)}catch(s){await Un(s)}}async function ET(n,e,t){const r=B(n);try{const s=await(function(a,u){const l=B(a);return l.persistence.runTransaction("Reject batch","readwrite-primary",(d=>{let f;return l.mutationQueue.lookupMutationBatch(d,u).next((m=>(J(m!==null,37113),f=m.keys(),l.mutationQueue.removeMutationBatch(d,m)))).next((()=>l.mutationQueue.performConsistencyCheck(d))).next((()=>l.documentOverlayCache.removeOverlaysForBatchId(d,f,u))).next((()=>l.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(d,f))).next((()=>l.localDocuments.getDocuments(d,f)))}))})(r.localStore,e);Id(r,e,t),Td(r,e),r.sharedClientState.updateMutationState(e,"rejected",t),await Br(r,s)}catch(s){await Un(s)}}function Td(n,e){(n.mu.get(e)||[]).forEach((t=>{t.resolve()})),n.mu.delete(e)}function Id(n,e,t){const r=B(n);let s=r.du[r.currentUser.toKey()];if(s){const i=s.get(e);i&&(t?i.reject(t):i.resolve(),s=s.remove(e)),r.du[r.currentUser.toKey()]=s}}function Ao(n,e,t=null){n.sharedClientState.removeLocalQueryTarget(e);for(const r of n.Iu.get(e))n.Tu.delete(r),t&&n.Pu.yu(r,t);n.Iu.delete(e),n.isPrimaryClient&&n.Vu.Gr(e).forEach((r=>{n.Vu.containsKey(r)||wd(n,r)}))}function wd(n,e){n.Eu.delete(e.path.canonicalString());const t=n.Ru.get(e);t!==null&&(sa(n.remoteStore,t),n.Ru=n.Ru.remove(e),n.Au.delete(t),ma(n))}function Ku(n,e,t){for(const r of t)r instanceof gd?(n.Vu.addReference(r.key,e),TT(n,r)):r instanceof _d?(O(pa,"Document no longer in limbo: "+r.key),n.Vu.removeReference(r.key,e),n.Vu.containsKey(r.key)||wd(n,r.key)):x(19791,{wu:r})}function TT(n,e){const t=e.key,r=t.path.canonicalString();n.Ru.get(t)||n.Eu.has(r)||(O(pa,"New document in limbo: "+t),n.Eu.add(r),ma(n))}function ma(n){for(;n.Eu.size>0&&n.Ru.size<n.maxConcurrentLimboResolutions;){const e=n.Eu.values().next().value;n.Eu.delete(e);const t=new L(X.fromString(e)),r=n.fu.next();n.Au.set(r,new uT(t)),n.Ru=n.Ru.insert(t,r),ld(n.remoteStore,new Ct(tt(ri(t.path)),r,"TargetPurposeLimboResolution",ei.ce))}}async function Br(n,e,t){const r=B(n),s=[],i=[],a=[];r.Tu.isEmpty()||(r.Tu.forEach(((u,l)=>{a.push(r.pu(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?void 0:f.current;
2989r.sharedClientState.updateQueryState(l.targetId,m?"current":"not-current")}if(d){s.push(d);const m=na.Es(l.targetId,d);i.push(m)}})))})),await Promise.all(a),r.Pu.J_(s),await(async function(l,d){const f=B(l);try{await f.persistence.runTransaction("notifyLocalViewChanges","readwrite",(m=>b.forEach(d,(_=>b.forEach(_.Ts,(S=>f.persistence.referenceDelegate.addReference(m,_.targetId,S))).next((()=>b.forEach(_.Is,(S=>f.persistence.referenceDelegate.removeReference(m,_.targetId,S)))))))))}catch(m){if(!Fn(m))throw m;O(ra,"Failed to update sequence numbers: "+m)}for(const m of d){const _=m.targetId;if(!m.fromCache){const S=f.vs.get(_),C=S.snapshotVersion,D=S.withLastLimboFreeSnapshotVersion(C);f.vs=f.vs.insert(_,D)}}})(r.localStore,i))}async function IT(n,e){const t=B(n);if(!t.currentUser.isEqual(e)){O(pa,"User change. New user:",e.toKey());const r=await od(t.localStore,e);t.currentUser=e,(function(i,a){i.mu.forEach((u=>{u.forEach((l=>{l.reject(new V(P.CANCELLED,a))}))})),i.mu.clear()})(t,"'waitForPendingWrites' promise is rejected due to a user change."),t.sharedClientState.handleUserChange(e,r.removedBatchIds,r.addedBatchIds),await Br(t,r.Ns)}}function wT(n,e){const t=B(n),r=t.Au.get(e);if(r&&r.hu)return W().add(r.key);{let s=W();const i=t.Iu.get(e);if(!i)return s;for(const a of i){const u=t.Tu.get(a);s=s.unionWith(u.view.nu)}return s}}function vd(n){const e=B(n);return e.remoteStore.remoteSyncer.applyRemoteEvent=Ed.bind(null,e),e.remoteStore.remoteSyncer.getRemoteKeysForTarget=wT.bind(null,e),e.remoteStore.remoteSyncer.rejectListen=_T.bind(null,e),e.Pu.J_=iT.bind(null,e.eventManager),e.Pu.yu=oT.bind(null,e.eventManager),e}function vT(n){const e=B(n);return e.remoteStore.remoteSyncer.applySuccessfulWrite=yT.bind(null,e),e.remoteStore.remoteSyncer.rejectFailedWrite=ET.bind(null,e),e}class Fs{constructor(){this.kind="memory",this.synchronizeTabs=!1}async initialize(e){this.serializer=ui(e.databaseInfo.databaseId),this.sharedClientState=this.Du(e),this.persistence=this.Cu(e),await this.persistence.start(),this.localStore=this.vu(e),this.gcScheduler=this.Fu(e,this.localStore),this.indexBackfillerScheduler=this.Mu(e,this.localStore)}Fu(e,t){return null}Mu(e,t){return null}vu(e){return SE(this.persistence,new vE,e.initialUser,this.serializer)}Cu(e){return new id(ta.Vi,this.serializer)}Du(e){return new VE}async terminate(){var e,t;(e=this.gcScheduler)==null||e.stop(),(t=this.indexBackfillerScheduler)==null||t.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}}Fs.provider={build:()=>new Fs};class AT extends Fs{constructor(e){super(),this.cacheSizeBytes=e}Fu(e,t){J(this.persistence.referenceDelegate instanceof xs,46915);const r=this.persistence.referenceDelegate.garbageCollector;return new cE(r,e.asyncQueue,t)}Cu(e){const t=this.cacheSizeBytes!==void 0?ke.withCacheSize(this.cacheSizeBytes):ke.DEFAULT;return new id((r=>xs.Vi(r,t)),this.serializer)}}class Ro{async initialize(e,t){this.localStore||(this.localStore=e.localStore,this.sharedClientState=e.sharedClientState,this.datastore=this.createDatastore(t),this.remoteStore=this.createRemoteStore(t),this.eventManager=this.createEventManager(t),this.syncEngine=this.createSyncEngine(t,!e.synchronizeTabs),this.sharedClientState.onlineStateHandler=r=>Wu(this.syncEngine,r,1),this.remoteStore.remoteSyncer.handleCredentialChange=IT.bind(null,this.syncEngine),await nT(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return(function(){return new sT})()}createDatastore(e){const t=ui(e.databaseInfo.databaseId),r=UE(e.databaseInfo);return jE(e.authCredentials,e.appCheckCredentials,r,t)}createRemoteStore(e){return(function(r,s,i,a,u){return new zE(r,s,i,a,u)})(this.localStore,this.datastore,e.asyncQueue,(t=>Wu(this.syncEngine,t,0)),(function(){return qu.v()?new qu:new OE})())}createSyncEngine(e,t){return(function(s,i,a,u,l,d,f){const m=new lT(s,i,a,u,l,d);return f&&(m.gu=!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=B(s);O(on,"RemoteStore shutting down."),i.Ea.add(5),await Fr(i),i.Aa.shutdown(),i.V
2989a.set("Unknown")})(this.remoteStore),(e=this.datastore)==null||e.terminate(),(t=this.eventManager)==null||t.terminate()}}Ro.provider={build:()=>new Ro};/** 2990 * @license 2991 * Copyright 2020 Google LLC 2992 * 2993 * Licensed under the Apache License, Version 2.0 (the "License"); 2994 * you may not use this file except in compliance with the License. 2995 * You may obtain a copy of the License at 2996 * 2997 * http://www.apache.org/licenses/LICENSE-2.0 2998 * 2999 * Unless required by applicable law or agreed to in writing, software 3000 * distributed under the License is distributed on an "AS IS" BASIS, 3001 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3002 * See the License for the specific language governing permissions and 3003 * limitations under the License. 3004 *//** 3005 * @license 3006 * Copyright 2017 Google LLC 3007 * 3008 * Licensed under the Apache License, Version 2.0 (the "License"); 3009 * you may not use this file except in compliance with the License. 3010 * You may obtain a copy of the License at 3011 * 3012 * http://www.apache.org/licenses/LICENSE-2.0 3013 * 3014 * Unless required by applicable law or agreed to in writing, software 3015 * distributed under the License is distributed on an "AS IS" BASIS, 3016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3017 * See the License for the specific language governing permissions and 3018 * limitations under the License. 3019 */class ga{constructor(e){this.observer=e,this.muted=!1}next(e){this.muted||this.observer.next&&this.Ou(this.observer.next,e)}error(e){this.muted||(this.observer.error?this.Ou(this.observer.error,e):pt("Uncaught Error in snapshot listener:",e.toString()))}Nu(){this.muted=!0}Ou(e,t){setTimeout((()=>{this.muted||e(t)}),0)}}/** 3020 * @license 3021 * Copyright 2017 Google LLC 3022 * 3023 * Licensed under the Apache License, Version 2.0 (the "License"); 3024 * you may not use this file except in compliance with the License. 3025 * You may obtain a copy of the License at 3026 * 3027 * http://www.apache.org/licenses/LICENSE-2.0 3028 * 3029 * Unless required by applicable law or agreed to in writing, software 3030 * distributed under the License is distributed on an "AS IS" BASIS, 3031 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3032 * See the License for the specific language governing permissions and 3033 * limitations under the License. 3034 */const Bt="FirestoreClient";class RT{constructor(e,t,r,s,i){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=r,this._databaseInfo=s,this.user=Ie.UNAUTHENTICATED,this.clientId=jo.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=i,this.authCredentials.start(r,(async a=>{O(Bt,"Received user=",a.uid),await this.authCredentialListener(a),this.user=a})),this.appCheckCredentials.start(r,(a=>(O(Bt,"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 lt;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=ua(t,"Failed to shutdown persistence");e.reject(r)}})),e.promise}}async function Xi(n,e){n.asyncQueue.verifyOperationInProgress(),O(Bt,"Initializing OfflineComponentProvider");const t=n.configuration;await e.initialize(t);let r=t.initialUser;n.setCredentialChangeListener((async s=>{r.isEqual(s)||(await od(e.localStore,s),r=s)})),e.persistence.setDatabaseDeletedListener((()=>n.terminate())),n._offlineComponents=e}async function Qu(n,e){n.asyncQueue.verifyOperationInProgress();const t=await ST(n);O(Bt,"Initializing OnlineComponentProvider"),await e.initialize(t,n.configuration),n.setCredentialChangeListener((r=>ju(e.remoteStore,r))),n.setAppCheckTokenChangeListener(((r,s)=>ju(e.remoteStore,s))),n._onlineComponents=e}async function ST(n){if(!n._offlineComponents)if(n._uninitializedComponentsProvider){O(Bt,"Using user provided OfflineComponentProvider");try{await Xi(n,n._uninitializedComponentsProvider._offline)}catch(e){const t=e;if(!(function(s){return s.name==="FirebaseError"?s.code===P.FAILED_PRECONDITION||s.code===P.UNIMPLEMENT
3034ED:!(typeof DOMException<"u"&&s instanceof DOMException)||s.code===22||s.code===20||s.code===11})(t))throw t;Cn("Error using user provided cache. Falling back to memory cache: "+t),await Xi(n,new Fs)}}else O(Bt,"Using default OfflineComponentProvider"),await Xi(n,new AT(void 0));return n._offlineComponents}async function Ad(n){return n._onlineComponents||(n._uninitializedComponentsProvider?(O(Bt,"Using user provided OnlineComponentProvider"),await Qu(n,n._uninitializedComponentsProvider._online)):(O(Bt,"Using default OnlineComponentProvider"),await Qu(n,new Ro))),n._onlineComponents}function PT(n){return Ad(n).then((e=>e.syncEngine))}async function Bs(n){const e=await Ad(n),t=e.eventManager;return t.onListen=hT.bind(null,e.syncEngine),t.onUnlisten=pT.bind(null,e.syncEngine),t.onFirstRemoteStoreListen=dT.bind(null,e.syncEngine),t.onLastRemoteStoreUnlisten=mT.bind(null,e.syncEngine),t}function bT(n,e,t,r){const s=new ga(r),i=new fa(e,s,t);return n.asyncQueue.enqueueAndForget((async()=>la(await Bs(n),i))),()=>{s.Nu(),n.asyncQueue.enqueueAndForget((async()=>ha(await Bs(n),i)))}}function CT(n,e,t={}){const r=new lt;return n.asyncQueue.enqueueAndForget((async()=>(function(i,a,u,l,d){const f=new ga({next:_=>{f.Nu(),a.enqueueAndForget((()=>ha(i,m)));const S=_.docs.has(u);!S&&_.fromCache?d.reject(new V(P.UNAVAILABLE,"Failed to get document because the client is offline.")):S&&_.fromCache&&l&&l.source==="server"?d.reject(new V(P.UNAVAILABLE,'Failed to get document from server. (However, this document does exist in the local cache. Run again without setting source to "server" to retrieve the cached document.)')):d.resolve(_)},error:_=>d.reject(_)}),m=new fa(ri(u.path),f,{includeMetadataChanges:!0,Ka:!0});return la(i,m)})(await Bs(n),n.asyncQueue,e,t,r))),r.promise}function kT(n,e,t={}){const r=new lt;return n.asyncQueue.enqueueAndForget((async()=>(function(i,a,u,l,d){const f=new ga({next:_=>{f.Nu(),a.enqueueAndForget((()=>ha(i,m))),_.fromCache&&l.source==="server"?d.reject(new V(P.UNAVAILABLE,'Failed to get documents from server. (However, these documents may exist in the local cache. Run again without setting source to "server" to retrieve the cached documents.)')):d.resolve(_)},error:_=>d.reject(_)}),m=new fa(u,f,{includeMetadataChanges:!0,Ka:!0});return la(i,m)})(await Bs(n),n.asyncQueue,e,t,r))),r.promise}function NT(n,e){const t=new lt;return n.asyncQueue.enqueueAndForget((async()=>gT(await PT(n),e,t))),t.promise}/** 3035 * @license 3036 * Copyright 2023 Google LLC 3037 * 3038 * Licensed under the Apache License, Version 2.0 (the "License"); 3039 * you may not use this file except in compliance with the License. 3040 * You may obtain a copy of the License at 3041 * 3042 * http://www.apache.org/licenses/LICENSE-2.0 3043 * 3044 * Unless required by applicable law or agreed to in writing, software 3045 * distributed under the License is distributed on an "AS IS" BASIS, 3046 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3047 * See the License for the specific language governing permissions and 3048 * limitations under the License. 3049 */function Rd(n){const e={};return n.timeoutSeconds!==void 0&&(e.timeoutSeconds=n.timeoutSeconds),e}/** 3050 * @license 3051 * Copyright 2020 Google LLC 3052 * 3053 * Licensed under the Apache License, Version 2.0 (the "License"); 3054 * you may not use this file except in compliance with the License. 3055 * You may obtain a copy of the License at 3056 * 3057 * http://www.apache.org/licenses/LICENSE-2.0 3058 * 3059 * Unless required by applicable law or agreed to in writing, software 3060 * distributed under the License is distributed on an "AS IS" BASIS, 3061 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3062 * See the License for the specific language governing permissions and 3063 * limitations under the License. 3064 */const DT="ComponentProvider",Ju=new Map;function VT(n,e,t,r,s){return new Y_(n,e,t,s.host,s.ssl,s.experimentalForceLongPolling,s.experimentalAutoDetectLongPolling,Rd(s.experimentalLongPollingOptions),s.useFetchStreams,s.isUsingEmulator,r)}/** 3065 * @license 3066 * Copyright 2020 Google LLC 3067 * 3068 * Licensed under the Apache License, Version 2.0 (the "License");
3069 * you may not use this file except in compliance with the License. 3070 * You may obtain a copy of the License at 3071 * 3072 * http://www.apache.org/licenses/LICENSE-2.0 3073 * 3074 * Unless required by applicable law or agreed to in writing, software 3075 * distributed under the License is distributed on an "AS IS" BASIS, 3076 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3077 * See the License for the specific language governing permissions and 3078 * limitations under the License. 3079 */const Sd="firestore.googleapis.com",Yu=!0;class Xu{constructor(e){if(e.host===void 0){if(e.ssl!==void 0)throw new V(P.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host=Sd,this.ssl=Yu}else this.host=e.host,this.ssl=e.ssl??Yu;if(this.isUsingEmulator=e.emulatorOptions!==void 0,this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,this.localCache=e.localCache,e.cacheSizeBytes===void 0)this.cacheSizeBytes=sd;else{if(e.cacheSizeBytes!==-1&&e.cacheSizeBytes<oE)throw new V(P.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}B_("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=Rd(e.experimentalLongPollingOptions??{}),(function(r){if(r.timeoutSeconds!==void 0){if(isNaN(r.timeoutSeconds))throw new V(P.INVALID_ARGUMENT,`invalid long polling timeout: ${r.timeoutSeconds} (must not be NaN)`);if(r.timeoutSeconds<5)throw new V(P.INVALID_ARGUMENT,`invalid long polling timeout: ${r.timeoutSeconds} (minimum allowed value is 5)`);if(r.timeoutSeconds>30)throw new V(P.INVALID_ARGUMENT,`invalid long polling timeout: ${r.timeoutSeconds} (maximum allowed value is 30)`)}})(this.experimentalLongPollingOptions),this.useFetchStreams=!!e.useFetchStreams}isEqual(e){return this.host===e.host&&this.ssl===e.ssl&&this.credentials===e.credentials&&this.cacheSizeBytes===e.cacheSizeBytes&&this.experimentalForceLongPolling===e.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===e.experimentalAutoDetectLongPolling&&(function(r,s){return r.timeoutSeconds===s.timeoutSeconds})(this.experimentalLongPollingOptions,e.experimentalLongPollingOptions)&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams}}class di{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 Xu({}),this._settingsFrozen=!1,this._emulatorOptions={},this._terminateTask="notTerminated"}get app(){if(!this._app)throw new V(P.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app}get _initialized(){return this._settingsFrozen}get _terminated(){return this._terminateTask!=="notTerminated"}_setSettings(e){if(this._settingsFrozen)throw new V(P.FAILED_PRECONDITION,"Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.");this._settings=new Xu(e),this._emulatorOptions=e.emulatorOptions||{},e.credentials!==void 0&&(this._authCredentials=(function(r){if(!r)return new k_;switch(r.type){case"firstParty":return new O_(r.sessionIndex||"0",r.iamToken||null,r.authTokenFactory||null);case"provider":return r.client;default:throw new V(P.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invalid credential type")}})(e.credentials))}_getSettings(){return this._settings}_getEmulatorOptions(){return this._emulatorOptions}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return this._terminateTask==="notTerminated"&&(this._terminateTask=this._terminate()),this._terminateTask}async _restart(){this._terminateTask==="notTerminated"?await this._terminate():this._terminateTask="notTerminated"}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return(function(t){const r=Ju.get(t);r&&(O(DT,"Removing Datastore"),Ju.delete(t),r.terminate())})(this),Promise.resolve()}}function OT(n,e,t,r={}){var d;n=Oe(n,di);const s=ot(e),i=n._getSettings(),a={...i,emulatorOptions:n._getEmulatorOptions()},u=`${e}:${t}`;s&&(Gs(`https://${u}`),Ws("Firestore",!0)),i.host!==Sd&&i.host!==u&&Cn("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used.");const l={...i,host:u,ssl:s,emulatorOptions:r};if(!nn(l,a)&&(n._setSettings(l),r.mockUserToken)){let f,m;if(typeof r.mockUserToken=="string")f=r.mockUserToken,m=Ie.MOCK_USER;else{f=vl(r.mockUserToken,(d=n._app)==null?void 0:d.options.projectId);const _=r.mockUserToken.sub||r.mockUserToken.user_id;if(!_)throw new V(P.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");m=new Ie(_)}n._authCredentials=new N_(new mh(f,m))}}/** 3080 * @license 3081 * Copyright 2020 Google LLC 3082 * 3083 * Licensed under the Apache License, Version 2.0 (the "License");
3084 * you may not use this file except in compliance with the License. 3085 * You may obtain a copy of the License at 3086 * 3087 * http://www.apache.org/licenses/LICENSE-2.0 3088 * 3089 * Unless required by applicable law or agreed to in writing, software 3090 * distributed under the License is distributed on an "AS IS" BASIS, 3091 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3092 * See the License for the specific language governing permissions and 3093 * limitations under the License. 3094 */class jt{constructor(e,t,r){this.converter=t,this._query=r,this.type="query",this.firestore=e}withConverter(e){return new jt(this.firestore,e,this._query)}}class oe{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 Dt(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new oe(this.firestore,e,this._key)}toJSON(){return{type:oe._jsonSchemaVersion,referencePath:this._key.toString()}}static fromJSON(e,t,r){if(Mr(t,oe._jsonSchema))return new oe(e,r||null,new L(X.fromString(t.referencePath)))}}oe._jsonSchemaVersion="firestore/documentReference/1.0",oe._jsonSchema={type:he("string",oe._jsonSchemaVersion),referencePath:he("string")};class Dt extends jt{constructor(e,t,r){super(e,t,ri(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 oe(this.firestore,null,new L(e))}withConverter(e){return new Dt(this.firestore,e,this._path)}}function Ww(n,e,...t){if(n=H(n),gh("collection","path",e),n instanceof di){const r=X.fromString(e,...t);return hu(r),new Dt(n,null,r)}{if(!(n instanceof oe||n instanceof Dt))throw new V(P.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=n._path.child(X.fromString(e,...t));return hu(r),new Dt(n.firestore,null,r)}}function LT(n,e,...t){if(n=H(n),arguments.length===1&&(e=jo.newId()),gh("doc","path",e),n instanceof di){const r=X.fromString(e,...t);return lu(r),new oe(n,null,new L(r))}{if(!(n instanceof oe||n instanceof Dt))throw new V(P.INVALID_ARGUMENT,"Expected first argument to doc() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=n._path.child(X.fromString(e,...t));return lu(r),new oe(n.firestore,n instanceof Dt?n.converter:null,new L(r))}}/** 3095 * @license 3096 * Copyright 2020 Google LLC 3097 * 3098 * Licensed under the Apache License, Version 2.0 (the "License"); 3099 * you may not use this file except in compliance with the License. 3100 * You may obtain a copy of the License at 3101 * 3102 * http://www.apache.org/licenses/LICENSE-2.0 3103 * 3104 * Unless required by applicable law or agreed to in writing, software 3105 * distributed under the License is distributed on an "AS IS" BASIS, 3106 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3107 * See the License for the specific language governing permissions and 3108 * limitations under the License. 3109 */const Zu="AsyncQueue";class el{constructor(e=Promise.resolve()){this.Yu=[],this.ec=!1,this.tc=[],this.nc=null,this.rc=!1,this.sc=!1,this.oc=[],this.M_=new cd(this,"async_queue_retry"),this._c=()=>{const r=Yi();r&&O(Zu,"Visibility state changed to "+r.visibilityState),this.M_.w_()},this.ac=e;const t=Yi();t&&typeof t.addEventListener=="function"&&t.addEventListener("visibilitychange",this._c)}get isShuttingDown(){return this.ec}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.uc(),this.cc(e)}enterRestrictedMode(e){if(!this.ec){this.ec=!0,this.sc=e||!1;const t=Yi();t&&typeof t.removeEventListener=="function"&&t.removeEventListener("visibilitychange",this._c)}}enqueue(e){if(this.uc(),this.ec)return new Promise((()=>{}));const t=new lt;return this.cc((()=>this.ec&&this.sc?Promise.resolve():(e().then(t.resolve,t.reject),t.promise))).then((()=>t.promise))}enqueueRetryable(e){this.enqueueAndForget((()=>(this.Yu.push(e),this.lc())))}async lc(){if(this.Yu.length!==0){try{await this.Yu[0](),this.Yu.shift(),this.M_.reset()}catch(e){if(!Fn(e))throw e;O(Zu,"Operation failed with retryable error: "+e)}this.Yu.length>0&&this.M_.p_((()=>this.lc()))}}cc(e){const t=this.ac.then((()=>(this.rc=!0,e().catch((r=>{throw this.nc=r,this.rc=!1,pt("INTERNAL UNHANDLED ERROR: ",tl(r)),r})).then((r=>(this.rc=!1,r))))));return this.ac=t,t}enqueueAfterDelay(e,t,r){this.uc(),this.oc.indexOf(e)>-1&&(t=0);const s=ca.createAndSchedule(this,e,t,r,(i=>this.hc(i)));return this.tc.push(s),s}uc(){this.nc&&x(47125,{Pc:tl(this.nc)})}verifyOperationInProgress(){}async Tc(){let e;do e=this.ac,await e;while(e!==this.ac)}Ic(e){for(const t of this.tc)if(t.timerId===e)return!0;return!1}Ec(e){return this.Tc().then((()=>{this.tc.sort(((t,r)=>t.targetTimeMs-r.targetTimeMs));for(const t of this.tc)if(t.skipDelay(),e!=="all"&&t.timerId===e)break;return this.Tc()}))}Rc(e){this.oc.push(e)}hc(e){const t=this.tc.indexOf(e);this.tc.splice(t,1)}}function tl(n){let e=n.message||"";return n.stack&&(e=n.stack.includes(n.message)?n.stack:n.message+` 3110`+n.stack),e}class gt extends di{constructor(e,t,r,s){super(e,t,r,s),this.type="firestore",this._queue=new el,this._persistenceKey=(s==null?void 0:s.name)||"[DEFAULT]"}async _terminate(){if(this._firestoreClient){const e=this._firestoreClient.terminate();this._queue=new el(e),this._firestoreClient=void 0,await e}}}function Kw(n,e){const t=typeof n=="object"?n:Ks(),r=typeof n=="string"?n:Ds,s=Dr(t,"firestore").getImmediate({identifier:r});if(!s._initialized){const i=Co("firestore");i&&OT(s,...i)}return s}
3110function fi(n){if(n._terminated)throw new V(P.FAILED_PRECONDITION,"The client has already been terminated.");return n._firestoreClient||MT(n),n._firestoreClient}function MT(n){var r,s,i,a;const e=n._freezeSettings(),t=VT(n._databaseId,((r=n._app)==null?void 0:r.options.appId)||"",n._persistenceKey,(s=n._app)==null?void 0:s.options.apiKey,e);n._componentsProvider||(i=e.localCache)!=null&&i._offlineComponentProvider&&((a=e.localCache)!=null&&a._onlineComponentProvider)&&(n._componentsProvider={_offline:e.localCache._offlineComponentProvider,_online:e.localCache._onlineComponentProvider}),n._firestoreClient=new RT(n._authCredentials,n._appCheckCredentials,n._queue,t,n._componentsProvider&&(function(l){const d=l==null?void 0:l._online.build();return{_offline:l==null?void 0:l._offline.build(d),_online:d}})(n._componentsProvider))}/** 3111 * @license 3112 * Copyright 2020 Google LLC 3113 * 3114 * Licensed under the Apache License, Version 2.0 (the "License"); 3115 * you may not use this file except in compliance with the License. 3116 * You may obtain a copy of the License at 3117 * 3118 * http://www.apache.org/licenses/LICENSE-2.0 3119 * 3120 * Unless required by applicable law or agreed to in writing, software 3121 * distributed under the License is distributed on an "AS IS" BASIS, 3122 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3123 * See the License for the specific language governing permissions and 3124 * limitations under the License. 3125 */class xe{constructor(e){this._byteString=e}static fromBase64String(e){try{return new xe(ye.fromBase64String(e))}catch(t){throw new V(P.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+t)}}static fromUint8Array(e){return new xe(ye.fromUint8Array(e))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(e){return this._byteString.isEqual(e._byteString)}toJSON(){return{type:xe._jsonSchemaVersion,bytes:this.toBase64()}}static fromJSON(e){if(Mr(e,xe._jsonSchema))return xe.fromBase64String(e.bytes)}}xe._jsonSchemaVersion="firestore/bytes/1.0",xe._jsonSchema={type:he("string",xe._jsonSchemaVersion),bytes:he("string")};/** 3126 * @license 3127 * Copyright 2020 Google LLC 3128 * 3129 * Licensed under the Apache License, Version 2.0 (the "License"); 3130 * you may not use this file except in compliance with the License. 3131 * You may obtain a copy of the License at 3132 * 3133 * http://www.apache.org/licenses/LICENSE-2.0 3134 * 3135 * Unless required by applicable law or agreed to in writing, software 3136 * distributed under the License is distributed on an "AS IS" BASIS, 3137 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3138 * See the License for the specific language governing permissions and 3139 * limitations under the License. 3140 */class _a{constructor(...e){for(let t=0;t<e.length;++t)if(e[t].length===0)throw new V(P.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new _e(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}}/** 3141 * @license 3142 * Copyright 2020 Google LLC 3143 * 3144 * Licensed under the Apache License, Version 2.0 (the "License"); 3145 * you may not use this file except in compliance with the License. 3146 * You may obtain a copy of the License at 3147 * 3148 * http://www.apache.org/licenses/LICENSE-2.0 3149 * 3150 * Unless required by applicable law or agreed to in writing, software 3151 * distributed under the License is distributed on an "AS IS" BASIS, 3152 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3153 * See the License for the specific language governing permissions and 3154 * limitations under the License. 3155 */class pi{constructor(e){this._methodName=e}}/** 3156 * @license 3157 * Copyright 2017 Google LLC 3158 * 3159 * Licensed under the Apache License, Version 2.0 (the "License"); 3160 * you may not use this file except in compliance with the License. 3161 * You may obtain a copy of the License at 3162 * 3163 * http://www.apache.org/licenses/LICENSE-2.0 3164 * 3165 * Unless required by applicable law or agreed to in writing, software 3166 * distributed under the License is distributed on an "AS IS" BASIS, 3167 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3168 * See the License for the specific language governing permissions and 3169 * limitations under the License. 3170 */class rt{constructor(e,t){if(!isFinite(e)||e<-90||e>90)throw new V(P.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(t)||t<-180||t>180)throw new V(P.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+t);this._lat=e,this._long=t}get latitude(){return this._lat}get longitude(){return this._long}isEqual(e){return this._lat===e._lat&&this._long===e._long}_compareTo(e){return G(this._lat,e._lat)||G(this._long,e._long)}toJSON(){return{latitude:this._lat,longitude:this._long,type:rt._jsonSchemaVersion}}static fromJSON(e){if(Mr(e,rt._jsonSchema))return new rt(e.latitude,e.longitude)}}rt._jsonSchemaVersion="firestore/geoPoint/1.0",rt._jsonSchema={type:he("string",rt._jsonSchemaVersion),latitude:he("number"),longitude:he("number")};/** 3171 * @license 3172 * Copyright 2024 Google LLC 3173 * 3174 * Licensed under the Apache License, Version 2.0 (the "License");
3175 * you may not use this file except in compliance with the License. 3176 * You may obtain a copy of the License at 3177 * 3178 * http://www.apache.org/licenses/LICENSE-2.0 3179 * 3180 * Unless required by applicable law or agreed to in writing, software 3181 * distributed under the License is distributed on an "AS IS" BASIS, 3182 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3183 * See the License for the specific language governing permissions and 3184 * limitations under the License. 3185 */class je{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)}toJSON(){return{type:je._jsonSchemaVersion,vectorValues:this._values}}static fromJSON(e){if(Mr(e,je._jsonSchema)){if(Array.isArray(e.vectorValues)&&e.vectorValues.every((t=>typeof t=="number")))return new je(e.vectorValues);throw new V(P.INVALID_ARGUMENT,"Expected 'vectorValues' field to be a number array")}}}je._jsonSchemaVersion="firestore/vectorValue/1.0",je._jsonSchema={type:he("string",je._jsonSchemaVersion),vectorValues:he("object")};/** 3186 * @license 3187 * Copyright 2017 Google LLC 3188 * 3189 * Licensed under the Apache License, Version 2.0 (the "License"); 3190 * you may not use this file except in compliance with the License. 3191 * You may obtain a copy of the License at 3192 * 3193 * http://www.apache.org/licenses/LICENSE-2.0 3194 * 3195 * Unless required by applicable law or agreed to in writing, software 3196 * distributed under the License is distributed on an "AS IS" BASIS, 3197 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3198 * See the License for the specific language governing permissions and 3199 * limitations under the License. 3200 */const xT=/^__.*__$/;class UT{constructor(e,t,r){this.data=e,this.fieldMask=t,this.fieldTransforms=r}toMutation(e,t){return this.fieldMask!==null?new $t(e,this.data,this.fieldMask,t,this.fieldTransforms):new xr(e,this.data,t,this.fieldTransforms)}}class Pd{constructor(e,t,r){this.data=e,this.fieldMask=t,this.fieldTransforms=r}toMutation(e,t){return new $t(e,this.data,this.fieldMask,t,this.fieldTransforms)}}function bd(n){switch(n){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw x(40011,{dataSource:n})}}class ya{constructor(e,t,r,s,i,a){this.settings=e,this.databaseId=t,this.serializer=r,this.ignoreUndefinedProperties=s,i===void 0&&this.validatePath(),this.fieldTransforms=i||[],this.fieldMask=a||[]}get path(){return this.settings.path}get dataSource(){return this.settings.dataSource}contextWith(e){return new ya({...this.settings,...e},this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}childContextForField(e){var s;const t=(s=this.path)==null?void 0:s.child(e),r=this.contextWith({path:t,arrayElement:!1});return r.validatePathSegment(e),r}childContextForFieldPath(e){var s;const t=(s=this.path)==null?void 0:s.child(e),r=this.contextWith({path:t,arrayElement:!1});return r.validatePath(),r}childContextForArray(e){return this.contextWith({path:void 0,arrayElement:!0})}createError(e){return qs(e,this.settings.methodName,this.settings.hasConverter||!1,this.path,this.settings.targetDoc)}contains(e){return this.fieldMask.find((t=>e.isPrefixOf(t)))!==void 0||this.fieldTransforms.find((t=>e.isPrefixOf(t.field)))!==void 0}validatePath(){if(this.path)for(let e=0;e<this.path.length;e++)this.validatePathSegment(this.path.get(e))}validatePathSegment(e){if(e.length===0)throw this.createError("Document fields must not be empty");if(bd(this.dataSource)&&xT.test(e))throw this.createError('Document fields cannot begin and end with "__"')}}class FT{constructor(e,t,r){this.databaseId=e,this.ignoreUndefinedProperties=t,this.serializer=r||ui(e)}createContext(e,t,r,s=!1){return new ya({dataSource:e,methodName:t,targetDoc:r,path:_e.emptyPath(),arrayElement:!1,hasConverter:s},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}}function mi(n){const e=n._freezeSettings(),t=ui(n._databaseId);return new FT(n._databaseId,!!e.ignoreUndefinedProperties,t)}function Cd(n,e,t,r,s,i={}){const a=n.createContext(i.merge||i.mergeFields?2:0,e,t,s);Ta("Data must be an object, but it was:",a,r);const u=kd(r,a);let l,d;if(i.merge)l=new Me(a.fieldMask),d=a.fieldTransforms;else if(i.mergeFields){const f=[];for(const m of i.mergeFields){const _=an(e,m,t);if(!a.contains(_))throw new V(P.INVALID_ARGUMENT,`Field '${_}' is specified in your field mask but missing from your input data.`);Vd(f,_)||f.push(_)}l=new Me(f),d=a.fieldTransforms.filter((m=>l.covers(m.field)))}else l=null,d=a.fieldTransforms;return new UT(new De(u),l,d)}class qr extends pi{_toFieldTransform(e){if(e.dataSource!==2)throw e.dataSource===1?e.createError(`${this._methodName}() can only appear at the top level of your update data`):e.createError(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return e.fieldMask.push(e.path),null}isEqual(e){return e instanceof qr}}class Ea extends pi{_toFieldTransform(e){return new Sy(e.path,new Pr)}isEqual(e){return e instanceof Ea}}function BT(n,e,t,r){const s=n.createContext(1,e,t);Ta("Data must be an object, but it was:",s,r);const i=[],a=De.empty();qt(r,((l,d)=>{const f=Dd(e,l,t);d=H(d);const m=s.childContextForFieldPath(f);if(d instanceof qr)i.push(f);else{const _=$r(d,m);_!=null&&(i.push(f),a.set(f,_))}}));const u=new Me(i);return new Pd(a,u,s.fieldTransforms)}function qT(n,e,t,r,s,i){const a=n.createContext(1,e,t),u=[an(e,r,t)],l=[s];if(i.length%2!=0)throw new V(P.INVALID_ARGUMENT,`Function ${e}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let _=0;_<i.length;_+=2)u.push(an(e,i[_])),l.push(i[_+1]);const d=[],f=De.empty();for(let _=u.length-1;_>=0;--_)if(!Vd(d,u[_])){const S=u[_];let C=l[_];C=H(C);const D=a.childContextForFieldPath(S);if(C instanceof qr)d.push(S);
3200else{const k=$r(C,D);k!=null&&(d.push(S),f.set(S,k))}}const m=new Me(d);return new Pd(f,m,a.fieldTransforms)}function $T(n,e,t,r=!1){return $r(t,n.createContext(r?4:3,e))}function $r(n,e){if(Nd(n=H(n)))return Ta("Unsupported field value:",e,n),kd(n,e);if(n instanceof pi)return(function(r,s){if(!bd(s.dataSource))throw s.createError(`${r._methodName}() can only be used with update() and set()`);if(!s.path)throw s.createError(`${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.arrayElement&&e.dataSource!==4)throw e.createError("Nested arrays are not supported");return(function(r,s){const i=[];let a=0;for(const u of r){let l=$r(u,s.childContextForArray(a));l==null&&(l={nullValue:"NULL_VALUE"}),i.push(l),a++}return{arrayValue:{values:i}}})(n,e)}return(function(r,s){if((r=H(r))===null)return{nullValue:"NULL_VALUE"};if(typeof r=="number")return vy(s.serializer,r);if(typeof r=="boolean")return{booleanValue:r};if(typeof r=="string")return{stringValue:r};if(r instanceof Date){const i=ee.fromDate(r);return{timestampValue:Ms(s.serializer,i)}}if(r instanceof ee){const i=new ee(r.seconds,1e3*Math.floor(r.nanoseconds/1e3));return{timestampValue:Ms(s.serializer,i)}}if(r instanceof rt)return{geoPointValue:{latitude:r.latitude,longitude:r.longitude}};if(r instanceof xe)return{bytesValue:Jh(s.serializer,r._byteString)};if(r instanceof oe){const i=s.databaseId,a=r.firestore._databaseId;if(!a.isEqual(i))throw s.createError(`Document reference is for database ${a.projectId}/${a.database} but should be for database ${i.projectId}/${i.database}`);return{referenceValue:Zo(r.firestore._databaseId||s.databaseId,r._key.path)}}if(r instanceof je)return(function(a,u){const l=a instanceof je?a.toArray():a;return{mapValue:{fields:{[Rh]:{stringValue:Sh},[Vs]:{arrayValue:{values:l.map((f=>{if(typeof f!="number")throw u.createError("VectorValues must only contain numeric values.");return Qo(u.serializer,f)}))}}}}}})(r,s);if(rd(r))return r._toProto(s.serializer);throw s.createError(`Unsupported field value: ${Zs(r)}`)})(n,e)}function kd(n,e){const t={};return Eh(n)?e.path&&e.path.length>0&&e.fieldMask.push(e.path):qt(n,((r,s)=>{const i=$r(s,e.childContextForField(r));i!=null&&(t[r]=i)})),{mapValue:{fields:t}}}function Nd(n){return!(typeof n!="object"||n===null||n instanceof Array||n instanceof Date||n instanceof ee||n instanceof rt||n instanceof xe||n instanceof oe||n instanceof pi||n instanceof je||rd(n))}function Ta(n,e,t){if(!Nd(t)||!_h(t)){const r=Zs(t);throw r==="an object"?e.createError(n+" a custom object"):e.createError(n+" "+r)}}function an(n,e,t){if((e=H(e))instanceof _a)return e._internalPath;if(typeof e=="string")return Dd(n,e);throw qs("Field path arguments must be of type string or ",n,!1,void 0,t)}const jT=new RegExp("[~\\*/\\[\\]]");function Dd(n,e,t){if(e.search(jT)>=0)throw qs(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`,n,!1,void 0,t);try{return new _a(...e.split("."))._internalPath}catch{throw qs(`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,n,!1,void 0,t)}}function qs(n,e,t,r,s){const i=r&&!r.isEmpty(),a=s!==void 0;let u=`Function ${e}() called with invalid data`;t&&(u+=" (via `toFirestore()`)"),u+=". ";let l="";return(i||a)&&(l+=" (found",i&&(l+=` in field ${r}`),a&&(l+=` in document ${s}`),l+=")"),new V(P.INVALID_ARGUMENT,u+n+l)}function Vd(n,e){return n.some((t=>t.isEqual(e)))}/** 3201 * @license 3202 * Copyright 2020 Google LLC 3203 * 3204 * Licensed under the Apache License, Version 2.0 (the "License"); 3205 * you may not use this file except in compliance with the License. 3206 * You may obtain a copy of the License at 3207 * 3208 * http://www.apache.org/licenses/LICENSE-2.0 3209 * 3210 * Unless required by applicable law or agreed to in writing, software 3211 * distributed under the License is distributed on an "AS IS" BASIS, 3212 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3213 * See the License for the specific language governing permissions and 3214 * limitations under the License. 3215 */class HT{convertValue(e,t="none"){switch(Ut(e)){case 0:return null;case 1:return e.booleanValue;case 2:return ae(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(xt(e.bytesValue));case 7:return this.convertReference(e.referenceValue);case 8:return this.convertGeoPoint(e.geoPointValue);case 9:return this.convertArray(e.arrayValue,t);case 11:return this.convertObject(e.mapValue,t);case 10:return this.convertVectorValue(e.mapValue);default:throw x(62114,{value:e})}}convertObject(e,t){return this.convertObjectMap(e.fields,t)}convertObjectMap(e,t="none"){const r={};return qt(e,((s,i)=>{r[s]=this.convertValue(i,t)})),r}convertVectorValue(e){var r,s,i;const t=(i=(s=(r=e.fields)==null?void 0:r[Vs].arrayValue)==null?void 0:s.values)==null?void 0:i.map((a=>ae(a.doubleValue)));return new je(t)}convertGeoPoint(e){return new rt(ae(e.latitude),ae(e.longitude))}convertArray(e,t){return(e.values||[]).map((r=>this.convertValue(r,t)))}convertServerTimestamp(e,t){switch(t){case"previous":const r=ni(e);return r==null?null:this.convertValue(r,t);case"estimate":return this.convertTimestamp(vr(e));default:return null}}convertTimestamp(e){const t=Mt(e);return new ee(t.seconds,t.nanos)}convertDocumentKey(e,t){const r=X.fromString(e);J(nd(r),9688,{name:e});const s=new Ar(r.get(1),r.get(3)),i=new L(r.popFirst(5));return s.isEqual(t)||pt(`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}}/** 3216 * @license 3217 * Copyright 2024 Google LLC 3218 * 3219 * Licensed under the Apache License, Version 2.0 (the "License");
3220 * you may not use this file except in compliance with the License. 3221 * You may obtain a copy of the License at 3222 * 3223 * http://www.apache.org/licenses/LICENSE-2.0 3224 * 3225 * Unless required by applicable law or agreed to in writing, software 3226 * distributed under the License is distributed on an "AS IS" BASIS, 3227 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3228 * See the License for the specific language governing permissions and 3229 * limitations under the License. 3230 */class Ia extends HT{constructor(e){super(),this.firestore=e}convertBytes(e){return new xe(e)}convertReference(e){const t=this.convertDocumentKey(e,this.firestore._databaseId);return new oe(this.firestore,null,t)}}/** 3231 * @license 3232 * Copyright 2020 Google LLC 3233 * 3234 * Licensed under the Apache License, Version 2.0 (the "License"); 3235 * you may not use this file except in compliance with the License. 3236 * You may obtain a copy of the License at 3237 * 3238 * http://www.apache.org/licenses/LICENSE-2.0 3239 * 3240 * Unless required by applicable law or agreed to in writing, software 3241 * distributed under the License is distributed on an "AS IS" BASIS, 3242 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3243 * See the License for the specific language governing permissions and 3244 * limitations under the License. 3245 */function Qw(){return new qr("deleteField")}function Jw(){return new Ea("serverTimestamp")}const nl="@firebase/firestore",rl="4.10.0";/** 3246 * @license 3247 * Copyright 2017 Google LLC 3248 * 3249 * Licensed under the Apache License, Version 2.0 (the "License"); 3250 * you may not use this file except in compliance with the License. 3251 * You may obtain a copy of the License at 3252 * 3253 * http://www.apache.org/licenses/LICENSE-2.0 3254 * 3255 * Unless required by applicable law or agreed to in writing, software 3256 * distributed under the License is distributed on an "AS IS" BASIS, 3257 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3258 * See the License for the specific language governing permissions and 3259 * limitations under the License. 3260 */function sl(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"])}/** 3261 * @license 3262 * Copyright 2020 Google LLC 3263 * 3264 * Licensed under the Apache License, Version 2.0 (the "License"); 3265 * you may not use this file except in compliance with the License. 3266 * You may obtain a copy of the License at 3267 * 3268 * http://www.apache.org/licenses/LICENSE-2.0 3269 * 3270 * Unless required by applicable law or agreed to in writing, software 3271 * distributed under the License is distributed on an "AS IS" BASIS, 3272 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3273 * See the License for the specific language governing permissions and 3274 * limitations under the License. 3275 */class Od{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 oe(this._firestore,this._converter,this._key)}exists(){return this._document!==null}data(){if(this._document){if(this._converter){const e=new zT(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(e)}return this._userDataWriter.convertValue(this._document.data.value)}}_fieldsProto(){var e;return((e=this._document)==null?void 0:e.data.clone().value.mapValue.fields)??void 0}get(e){if(this._document){const t=this._document.data.field(an("DocumentSnapshot.get",e));if(t!==null)return this._userDataWriter.convertValue(t)}}}class zT extends Od{data(){return super.data()}}/** 3276 * @license 3277 * Copyright 2020 Google LLC 3278 * 3279 * Licensed under the Apache License, Version 2.0 (the "License"); 3280 * you may not use this file except in compliance with the License. 3281 * You may obtain a copy of the License at 3282 * 3283 * http://www.apache.org/licenses/LICENSE-2.0 3284 * 3285 * Unless required by applicable law or agreed to in writing, software 3286 * distributed under the License is distributed on an "AS IS" BASIS, 3287 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3288 * See the License for the specific language governing permissions and 3289 * limitations under the License. 3290 */function Ld(n){if(n.limitType==="L"&&n.explicitOrderBy.length===0)throw new V(P.UNIMPLEMENT
3290ED,"limitToLast() queries require specifying at least one orderBy() clause")}class wa{}class Md extends wa{}function Yw(n,e,...t){let r=[];e instanceof wa&&r.push(e),r=r.concat(t),(function(i){const a=i.filter((l=>l instanceof va)).length,u=i.filter((l=>l instanceof gi)).length;if(a>1||a>0&&u>0)throw new V(P.INVALID_ARGUMENT,"InvalidQuery. When using composite filters, you cannot use more than one filter at the top level. Consider nesting the multiple filters within an `and(...)` statement. For example: change `query(query, where(...), or(...))` to `query(query, and(where(...), or(...)))`.")})(r);for(const s of r)n=s._apply(n);return n}class gi extends Md{constructor(e,t,r){super(),this._field=e,this._op=t,this._value=r,this.type="where"}static _create(e,t,r){return new gi(e,t,r)}_apply(e){const t=this._parse(e);return xd(e._query,t),new jt(e.firestore,e.converter,mo(e._query,t))}_parse(e){const t=mi(e.firestore);return(function(i,a,u,l,d,f,m){let _;if(d.isKeyField()){if(f==="array-contains"||f==="array-contains-any")throw new V(P.INVALID_ARGUMENT,`Invalid Query. You can't perform '${f}' queries on documentId().`);if(f==="in"||f==="not-in"){ol(m,f);const C=[];for(const D of m)C.push(il(l,i,D));_={arrayValue:{values:C}}}else _=il(l,i,m)}else f!=="in"&&f!=="not-in"&&f!=="array-contains-any"||ol(m,f),_=$T(u,a,m,f==="in"||f==="not-in");return le.create(d,f,_)})(e._query,"where",t,e.firestore._databaseId,this._field,this._op,this._value)}}function Xw(n,e,t){const r=e,s=an("where",n);return gi._create(s,r,t)}class va extends wa{constructor(e,t){super(),this.type=e,this._queryConstraints=t}static _create(e,t){return new va(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]:He.create(t,this._getOperator())}_apply(e){const t=this._parse(e);return t.getFilters().length===0?e:((function(s,i){let a=s;const u=i.getFlattenedFilters();for(const l of u)xd(a,l),a=mo(a,l)})(e._query,t),new jt(e.firestore,e.converter,mo(e._query,t)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return this.type==="and"?"and":"or"}}class Aa extends Md{constructor(e,t){super(),this._field=e,this._direction=t,this.type="orderBy"}static _create(e,t){return new Aa(e,t)}_apply(e){const t=(function(s,i,a){if(s.startAt!==null)throw new V(P.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(s.endAt!==null)throw new V(P.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");return new Sr(i,a)})(e._query,this._field,this._direction);return new jt(e.firestore,e.converter,my(e._query,t))}}function Zw(n,e="asc"){const t=e,r=an("orderBy",n);return Aa._create(r,t)}function il(n,e,t){if(typeof(t=H(t))=="string"){if(t==="")throw new V(P.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!Oh(e)&&t.indexOf("/")!==-1)throw new V(P.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${t}' contains a '/' character.`);const r=e.path.child(X.fromString(t));if(!L.isDocumentKey(r))throw new V(P.INVALID_ARGUMENT,`Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${r}' is not because it has an odd number of segments (${r.length}).`);return Eu(n,new L(r))}if(t instanceof oe)return Eu(n,t._key);throw new V(P.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${Zs(t)}.`)}function ol(n,e){if(!Array.isArray(n)||n.length===0)throw new V(P.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${e.toString()}' filters.`)}function xd(n,e){const t=(function(s,i){for(const a of s)for(const u of a.getFlattenedFilters())if(i.indexOf(u.op)>=0)return u.op;return null})(n.filters,(function(s){switch(s){case"!=":return["!=","not-in"];case"array-contains-any":case"in":return["not-in"];case"not-in":return["array-contains-any","in","not-in","!="];default:return[]}})(e.op));if(t!==null)throw t===e.op?new V(P.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${e.op.toString()}' filter.`):new V(P.INVALID_ARGUMENT,`Invalid query. You cannot use '${e.op.toString()}' filters with '${t.toString()}' filters.`)}function Ud(n,e,t){let r;return r=n?t&&(t.merge||t.mergeFields)?n.toFirestore(e,t):n.toFirestore(e):e,r}class dr{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}}class Zt extends Od{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 Is(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(an("DocumentSnapshot.get",e));if(r!==null)return this._userDataWriter.convertValue(r,t.serverTimestamps)}}toJSON(){if(this.metadata.hasPendingWrites)throw new V(P.FAILED_PRECONDITION,"DocumentSnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");const e=this._document,t={};return t.type=Zt._jsonSchemaVersion,t.bundle="",t.bundleSource="DocumentSnapshot",t.bundleName=this._key.toString(),!e||!e.isValidDocument()||!e.isFoundDocument()?t:(this._userDataWriter.convertObjectMap(e.data.value.mapValue.fields,"previous"),t.bundle=(this._firestore,this.ref.path,"NOT SUPPORTED"),t)}}Zt._jsonSchemaVersion="firestore/documentSnapshot/1.0",Zt._jsonSchema={type:he("string",Zt._jsonSchemaVersion),bundleSource:he("string","DocumentSnapshot"),bundleName:he("string"),bundle:he("string")};class Is extends Zt{data(e={}){return super.data(e)}}class en{constructor(e,t,r,s){this._firestore=e,this._userDataWriter=t,this._snapshot=s,this.metadata=new dr(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 Is(this._firestore,this._userDataWriter,r.key,r,new dr(this._snapshot.mutatedKeys.has(r.key),this._snapshot.fromCache),this.query.converter))}))}docChanges(e={}){const t=!!e.includeMetadataChanges;if(t&&this._snapshot.excludesMetadataChanges)throw new V(P.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===t||(this._cachedChanges=(function(s,i){if
3290(s._snapshot.oldDocs.isEmpty()){let a=0;return s._snapshot.docChanges.map((u=>{const l=new Is(s._firestore,s._userDataWriter,u.doc.key,u.doc,new dr(s._snapshot.mutatedKeys.has(u.doc.key),s._snapshot.fromCache),s.query.converter);return u.doc,{type:"added",doc:l,oldIndex:-1,newIndex:a++}}))}{let a=s._snapshot.oldDocs;return s._snapshot.docChanges.filter((u=>i||u.type!==3)).map((u=>{const l=new Is(s._firestore,s._userDataWriter,u.doc.key,u.doc,new dr(s._snapshot.mutatedKeys.has(u.doc.key),s._snapshot.fromCache),s.query.converter);let d=-1,f=-1;return u.type!==0&&(d=a.indexOf(u.doc.key),a=a.delete(u.doc.key)),u.type!==1&&(a=a.add(u.doc),f=a.indexOf(u.doc.key)),{type:GT(u.type),doc:l,oldIndex:d,newIndex:f}}))}})(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}toJSON(){if(this.metadata.hasPendingWrites)throw new V(P.FAILED_PRECONDITION,"QuerySnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");const e={};e.type=en._jsonSchemaVersion,e.bundleSource="QuerySnapshot",e.bundleName=jo.newId(),this._firestore._databaseId.database,this._firestore._databaseId.projectId;const t=[],r=[],s=[];return this.docs.forEach((i=>{i._document!==null&&(t.push(i._document),r.push(this._userDataWriter.convertObjectMap(i._document.data.value.mapValue.fields,"previous")),s.push(i.ref.path))})),e.bundle=(this._firestore,this.query._query,e.bundleName,"NOT SUPPORTED"),e}}function GT(n){switch(n){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return x(61501,{type:n})}}/** 3291 * @license 3292 * Copyright 2022 Google LLC 3293 * 3294 * Licensed under the Apache License, Version 2.0 (the "License"); 3295 * you may not use this file except in compliance with the License. 3296 * You may obtain a copy of the License at 3297 * 3298 * http://www.apache.org/licenses/LICENSE-2.0 3299 * 3300 * Unless required by applicable law or agreed to in writing, software 3301 * distributed under the License is distributed on an "AS IS" BASIS, 3302 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3303 * See the License for the specific language governing permissions and 3304 * limitations under the License. 3305 */en._jsonSchemaVersion="firestore/querySnapshot/1.0",en._jsonSchema={type:he("string",en._jsonSchemaVersion),bundleSource:he("string","QuerySnapshot"),bundleName:he("string"),bundle:he("string")};/** 3306 * @license 3307 * Copyright 2020 Google LLC 3308 * 3309 * Licensed under the Apache License, Version 2.0 (the "License"); 3310 * you may not use this file except in compliance with the License. 3311 * You may obtain a copy of the License at 3312 * 3313 * http://www.apache.org/licenses/LICENSE-2.0 3314 * 3315 * Unless required by applicable law or agreed to in writing, software 3316 * distributed under the License is distributed on an "AS IS" BASIS, 3317 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3318 * See the License for the specific language governing permissions and 3319 * limitations under the License. 3320 */function ev(n){n=Oe(n,oe);const e=Oe(n.firestore,gt),t=fi(e);return CT(t,n._key).then((r=>Fd(e,n,r)))}function tv(n){n=Oe(n,jt);const e=Oe(n.firestore,gt),t=fi(e),r=new Ia(e);return Ld(n._query),kT(t,n._query).then((s=>new en(e,r,n,s)))}function nv(n,e,t){n=Oe(n,oe);const r=Oe(n.firestore,gt),s=Ud(n.converter,e,t),i=mi(r);return _i(r,[Cd(i,"setDoc",n._key,s,n.converter!==null,t).toMutation(n._key,Fe.none())])}function rv(n,e,t,...r){n=Oe(n,oe);const s=Oe(n.firestore,gt),i=mi(s);let a;return a=typeof(e=H(e))=="string"||e instanceof _a?qT(i,"updateDoc",n._key,e,t,r):BT(i,"updateDoc",n._key,e),_i(s,[a.toMutation(n._key,Fe.exists(!0))])}function sv(n){return _i(Oe(n.firestore,gt),[new Jo(n._key,Fe.none())])}function iv(n,e){const t=Oe(n.firestore,gt),r=LT(n),s=Ud(n.converter,e),i=mi(n.firestore);return _i(t,[Cd(i,"addDoc",r._key,s,n.converter!==null,{}).toMutation(r._key,Fe.exists(!1))]).then((()=>r))}function ov(n,...e){var d,f,m;n=H(n);let t={includeMetadataChanges:!1,source:"default"},r=0;typeof e[r]!="object"||sl(e[r])||(t=e[r++]);const s={includeMetadataChanges:t.includeMetadataChanges,source:t.source};if(sl(e[r])){const _=e[r];e[r]=(d=_.next)==null?void 0:d.bind(_),e[r+1]=(f=_.error)==null?void 0:f.bind(_),e[r+2]=(m=_.complete)==null?void 0:m.bind(_)}let i,a,u;if(n instanceof oe)a=Oe(n.firestore,gt),u=ri(n._key.path),i={next:_=>{e[r]&&e[r](Fd(a,n,_))},error:e[r+1],complete:e[r+2]};else{const _=Oe(n,jt);a=Oe(_.firestore,gt),u=_._query;const S=new Ia(a);i={next:C=>{e[r]&&e[r](new en(a,S,_,C))},error:e[r+1],complete:e[r+2]},Ld(n._query)}const l=fi(a);return bT(l,u,s,i)}function _i(n,e){const t=fi(n);return NT(t,e)}function Fd(n,e,t){const r=t.docs.get(e._key),s=new Ia(n);return new Zt(n,s,e._key,r,new dr(t.hasPendingWrites,t.fromCache),e.converter)}(function(e,t=!0){C_(un),Vt(new ht("firestore",((r,{instanceIdentifier:s,options:i})=>{const a=r.getProvider("app").getImmediate(),u=new gt(new D_(r.getProvider("auth-internal")),new L_(a,r.getProvider("app-check-internal")),X_(a,s),a);return i={useFetchStreams:t,...i},u._setSettings(i),u}),"PUBLIC").setMultipleInstances(!0)),Ue(nl,rl,e),Ue(nl,rl,"esm2020")})();/** 3321 * @license 3322 * Copyright 2017 Google LLC 3323 * 3324 * Licensed under the Apache License, Version 2.0 (the "License");
3325 * you may not use this file except in compliance with the License. 3326 * You may obtain a copy of the License at 3327 * 3328 * http://www.apache.org/licenses/LICENSE-2.0 3329 * 3330 * Unless required by applicable law or agreed to in writing, software 3331 * distributed under the License is distributed on an "AS IS" BASIS, 3332 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3333 * See the License for the specific language governing permissions and 3334 * limitations under the License. 3335 */const Bd="firebasestorage.googleapis.com",qd="storageBucket",WT=120*1e3,KT=600*1e3,QT=1e3;/** 3336 * @license 3337 * Copyright 2017 Google LLC 3338 * 3339 * Licensed under the Apache License, Version 2.0 (the "License"); 3340 * you may not use this file except in compliance with the License. 3341 * You may obtain a copy of the License at 3342 * 3343 * http://www.apache.org/licenses/LICENSE-2.0 3344 * 3345 * Unless required by applicable law or agreed to in writing, software 3346 * distributed under the License is distributed on an "AS IS" BASIS, 3347 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3348 * See the License for the specific language governing permissions and 3349 * limitations under the License. 3350 */class se extends ze{constructor(e,t,r=0){super(Zi(e),`Firebase Storage: ${t} (${Zi(e)})`),this.status_=r,this.customData={serverResponse:null},this._baseMessage=this.message,Object.setPrototypeOf(this,se.prototype)}get status(){return this.status_}set status(e){this.status_=e}_codeEquals(e){return Zi(e)===this.code}get serverResponse(){return this.customData.serverResponse}set serverResponse(e){this.customData.serverResponse=e,this.customData.serverResponse?this.message=`${this._baseMessage} 3351${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 Zi(n){return"storage/"+n}function Ra(){const n="An unknown error occurred, please check the error payload for server response.";return new se(te.UNKNOWN,n)}function JT(n){return new se(te.OBJECT_NOT_FOUND,"Object '"+n+"' does not exist.")}function YT(n){return new se(te.QUOTA_EXCEEDED,"Quota for bucket '"+n+"' exceeded, please view quota on https://firebase.google.com/pricing/.")}function XT(){const n="User is not authenticated, please authenticate using Firebase Authentication and try again.";return new se(te.UNAUTHENTICATED,n)}function ZT(){return new se(te.UNAUTHORIZED_APP,"This app does not have permission to access Firebase Storage on this project.")}function eI(n){return new se(te.UNAUTHORIZED,"User does not have permission to access '"+n+"'.")}function $d(){return new se(te.RETRY_LIMIT_EXCEEDED,"Max retry time for operation exceeded, please try again.")}function jd(){return new se(te.CANCELED,"User canceled the upload/download.")}function tI(n){return new se(te.INVALID_URL,"Invalid URL '"+n+"'.")}function nI(n){return new se(te.INVALID_DEFAULT_BUCKET,"Invalid default bucket '"+n+"'.")}function rI(){return new se(te.NO_DEFAULT_BUCKET,"No default bucket found. Did you set the '"+qd+"' property when initializing the app?")}function Hd(){return new se(te.CANNOT_SLICE_BLOB,"Cannot slice blob for upload. Please retry the upload.")}function sI(){return new se(te.SERVER_FILE_WRONG_SIZE,"Server recorded incorrect upload file size, please retry the upload.")}function iI(){return new se(te.NO_DOWNLOAD_URL,"The given file does not have any download URLs.")}function oI(n){return new se(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 So(n){return new se(te.INVALID_ARGUMENT,n)}function zd(){return new se(te.APP_DELETED,"The Firebase app was deleted.")}function aI(n){return new se(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 Er(n,e){return new se(te.INVALID_FORMAT,"String does not match format '"+n+"': "+e)}function or(n){throw new se(te.INTERNAL_ERROR,"Internal error: "+n)}/** 3352 * @license 3353 * Copyright 2017 Google LLC 3354 * 3355 * Licensed under the Apache License, Version 2.0 (the "License");
3356 * you may not use this file except in compliance with the License. 3357 * You may obtain a copy of the License at 3358 * 3359 * http://www.apache.org/licenses/LICENSE-2.0 3360 * 3361 * Unless required by applicable law or agreed to in writing, software 3362 * distributed under the License is distributed on an "AS IS" BASIS, 3363 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3364 * See the License for the specific language governing permissions and 3365 * limitations under the License. 3366 */class be{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=be.makeFromUrl(e,t)}catch{return new be(e,"")}if(r.path==="")return r;throw nI(e)}static makeFromUrl(e,t){let r=null;const s="([A-Za-z0-9.\\-_]+)";function i(Q){Q.path.charAt(Q.path.length-1)==="/"&&(Q.path_=Q.path_.slice(0,-1))}const a="(/(.*))?$",u=new RegExp("^gs://"+s+a,"i"),l={bucket:1,path:3};function d(Q){Q.path_=decodeURIComponent(Q.path)}const f="v[A-Za-z0-9_]+",m=t.replace(/[.]/g,"\\."),_="(/([^?#]*).*)?$",S=new RegExp(`^https?://${m}/${f}/b/${s}/o${_}`,"i"),C={bucket:1,path:3},D=t===Bd?"(?:storage.googleapis.com|storage.cloud.google.com)":t,k="([^?#]*)",q=new RegExp(`^https?://${D}/${s}/${k}`,"i"),$=[{regex:u,indices:l,postModify:i},{regex:S,indices:C,postModify:d},{regex:q,indices:{bucket:1,path:2},postModify:d}];for(let Q=0;Q<$.length;Q++){const ce=$[Q],ne=ce.regex.exec(e);if(ne){const I=ne[ce.indices.bucket];let g=ne[ce.indices.path];g||(g=""),r=new be(I,g),ce.postModify(r);break}}if(r==null)throw tI(e);return r}}class cI{constructor(e){this.promise_=Promise.reject(e)}getPromise(){return this.promise_}cancel(e=!1){}}/** 3367 * @license 3368 * Copyright 2017 Google LLC 3369 * 3370 * Licensed under the Apache License, Version 2.0 (the "License"); 3371 * you may not use this file except in compliance with the License. 3372 * You may obtain a copy of the License at 3373 * 3374 * http://www.apache.org/licenses/LICENSE-2.0 3375 * 3376 * Unless required by applicable law or agreed to in writing, software 3377 * distributed under the License is distributed on an "AS IS" BASIS, 3378 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3379 * See the License for the specific language governing permissions and 3380 * limitations under the License. 3381 */function uI(n,e,t){let r=1,s=null,i=null,a=!1,u=0;function l(){return u===2}let d=!1;function f(...k){d||(d=!0,e.apply(null,k))}function m(k){s=setTimeout(()=>{s=null,n(S,l())},k)}function _(){i&&clearTimeout(i)}function S(k,...q){if(d){_();return}if(k){_(),f.call(null,k,...q);return}if(l()||a){_(),f.call(null,k,...q);return}r<64&&(r*=2);let $;u===1?(u=2,$=0):$=(r+Math.random())*1e3,m($)}let C=!1;function D(k){C||(C=!0,_(),!d&&(s!==null?(k||(u=2),clearTimeout(s),m(0)):k||(u=1)))}return m(0),i=setTimeout(()=>{a=!0,D(!0)},t),D}function lI(n){n(!1)}/** 3382 * @license 3383 * Copyright 2017 Google LLC 3384 * 3385 * Licensed under the Apache License, Version 2.0 (the "License"); 3386 * you may not use this file except in compliance with the License. 3387 * You may obtain a copy of the License at 3388 * 3389 * http://www.apache.org/licenses/LICENSE-2.0 3390 * 3391 * Unless required by applicable law or agreed to in writing, software 3392 * distributed under the License is distributed on an "AS IS" BASIS, 3393 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3394 * See the License for the specific language governing permissions and 3395 * limitations under the License. 3396 */function hI(n){return n!==void 0}function dI(n){return typeof n=="function"}function fI(n){return typeof n=="object"&&!Array.isArray(n)}function yi(n){return typeof n=="string"||n instanceof String}function al(n){return Sa()&&n instanceof Blob}function Sa(){return typeof Blob<"u"}function Po(n,e,t,r){if(r<e)throw So(`Invalid value for '${n}'. Expected ${e} or greater.`);if(r>t)throw So(`Invalid value for '${n}'. Expected ${t} or less.`)}/** 3397 * @license 3398 * Copyright 2017 Google LLC 3399 * 3400 * Licensed under the Apache License, Version 2.0 (the "License");
3401 * you may not use this file except in compliance with the License. 3402 * You may obtain a copy of the License at 3403 * 3404 * http://www.apache.org/licenses/LICENSE-2.0 3405 * 3406 * Unless required by applicable law or agreed to in writing, software 3407 * distributed under the License is distributed on an "AS IS" BASIS, 3408 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3409 * See the License for the specific language governing permissions and 3410 * limitations under the License. 3411 */function fn(n,e,t){let r=e;return t==null&&(r=`https://${e}`),`${t}://${r}/v0${n}`}function Gd(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 tn;(function(n){n[n.NO_ERROR=0]="NO_ERROR",n[n.NETWORK_ERROR=1]="NETWORK_ERROR",n[n.ABORT=2]="ABORT"})(tn||(tn={}));/** 3412 * @license 3413 * Copyright 2022 Google LLC 3414 * 3415 * Licensed under the Apache License, Version 2.0 (the "License"); 3416 * you may not use this file except in compliance with the License. 3417 * You may obtain a copy of the License at 3418 * 3419 * http://www.apache.org/licenses/LICENSE-2.0 3420 * 3421 * Unless required by applicable law or agreed to in writing, software 3422 * distributed under the License is distributed on an "AS IS" BASIS, 3423 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3424 * See the License for the specific language governing permissions and 3425 * limitations under the License. 3426 */function Wd(n,e){const t=n>=500&&n<600,s=[408,429].indexOf(n)!==-1,i=e.indexOf(n)!==-1;return t||s||i}/** 3427 * @license 3428 * Copyright 2017 Google LLC 3429 * 3430 * Licensed under the Apache License, Version 2.0 (the "License"); 3431 * you may not use this file except in compliance with the License. 3432 * You may obtain a copy of the License at 3433 * 3434 * http://www.apache.org/licenses/LICENSE-2.0 3435 * 3436 * Unless required by applicable law or agreed to in writing, software 3437 * distributed under the License is distributed on an "AS IS" BASIS, 3438 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3439 * See the License for the specific language governing permissions and 3440 * limitations under the License. 3441 */class pI{constructor(e,t,r,s,i,a,u,l,d,f,m,_=!0,S=!1){this.url_=e,this.method_=t,this.headers_=r,this.body_=s,this.successCodes_=i,this.additionalRetryCodes_=a,this.callback_=u,this.errorCallback_=l,this.timeout_=d,this.progressCallback_=f,this.connectionFactory_=m,this.retry=_,this.isUsingEmulator=S,this.pendingConnection_=null,this.backoffId_=null,this.canceled_=!1,this.appDelete_=!1,this.promise_=new Promise((C,D)=>{this.resolve_=C,this.reject_=D,this.start_()})}start_(){const e=(r,s)=>{if(s){r(!1,new ls(!1,null,!0));return}const i=this.connectionFactory_();this.pendingConnection_=i;const a=u=>{const l=u.loaded,d=u.lengthComputable?u.total:-1;this.progressCallback_!==null&&this.progressCallback_(l,d)};this.progressCallback_!==null&&i.addUploadProgressListener(a),i.send(this.url_,this.method_,this.isUsingEmulator,this.body_,this.headers_).then(()=>{this.progressCallback_!==null&&i.removeUploadProgressListener(a),this.pendingConnection_=null;const u=i.getErrorCode()===tn.NO_ERROR,l=i.getStatus();if(!u||Wd(l,this.additionalRetryCodes_)&&this.retry){const f=i.getErrorCode()===tn.ABORT;r(!1,new ls(!1,null,f));return}const d=this.successCodes_.indexOf(l)!==-1;r(!0,new ls(d,i))})},t=(r,s)=>{const i=this.resolve_,a=this.reject_,u=s.connection;if(s.wasSuccessCode)try{const l=this.callback_(u,u.getResponse());hI(l)?i(l):i()}catch(l){a(l)}else if(u!==null){const l=Ra();l.serverResponse=u.getErrorText(),this.errorCallback_?a(this.errorCallback_(u,l)):a(l)}else if(s.canceled){const l=this.appDelete_?zd():jd();a(l)}else{const l=$d();a(l)}};this.canceled_?t(!1,new ls(!1,null,!0)):this.backoffId_=uI(e,t,this.timeout_)}getPromise(){return this.promise_}cancel(e){this.canceled_=!0,this.appDelete_=e||!1,this.backoffId_!==null&&lI(this.backoffId_),this.pendingConnection_!==null&&this.pendingConnection_.abort()}}class ls{constructor(e,t,r){this.wasSuccessCode=e,this.connection=t,this.canceled=!!r}}function mI(n,e){e!==null&&e.length>0&&(n.Authorization="Firebase "+e)}function gI(n,e){n["X-Firebase-Storage-Version"]="webjs/"+(e??"AppManager")}function _I(n,e){e&&(n["X-Firebase-GMPID"]=e)}function yI(n,e){e!==null&&(n["X-Firebase-AppCheck"]=e)}
3441function EI(n,e,t,r,s,i,a=!0,u=!1){const l=Gd(n.urlParams),d=n.url+l,f=Object.assign({},n.headers);return _I(f,e),mI(f,t),gI(f,i),yI(f,r),new pI(d,n.method,f,n.body,n.successCodes,n.additionalRetryCodes,n.handler,n.errorHandler,n.timeout,n.progressCallback,s,a,u)}/** 3442 * @license 3443 * Copyright 2017 Google LLC 3444 * 3445 * Licensed under the Apache License, Version 2.0 (the "License"); 3446 * you may not use this file except in compliance with the License. 3447 * You may obtain a copy of the License at 3448 * 3449 * http://www.apache.org/licenses/LICENSE-2.0 3450 * 3451 * Unless required by applicable law or agreed to in writing, software 3452 * distributed under the License is distributed on an "AS IS" BASIS, 3453 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3454 * See the License for the specific language governing permissions and 3455 * limitations under the License. 3456 */function TI(){return typeof BlobBuilder<"u"?BlobBuilder:typeof WebKitBlobBuilder<"u"?WebKitBlobBuilder:void 0}function II(...n){const e=TI();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(Sa())return new Blob(n);throw new se(te.UNSUPPORTED_ENVIRONMENT,"This browser doesn't seem to support creating Blobs")}}function wI(n,e,t){return n.webkitSlice?n.webkitSlice(e,t):n.mozSlice?n.mozSlice(e,t):n.slice?n.slice(e,t):null}/** 3457 * @license 3458 * Copyright 2021 Google LLC 3459 * 3460 * Licensed under the Apache License, Version 2.0 (the "License"); 3461 * you may not use this file except in compliance with the License. 3462 * You may obtain a copy of the License at 3463 * 3464 * http://www.apache.org/licenses/LICENSE-2.0 3465 * 3466 * Unless required by applicable law or agreed to in writing, software 3467 * distributed under the License is distributed on an "AS IS" BASIS, 3468 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3469 * See the License for the specific language governing permissions and 3470 * limitations under the License. 3471 */function vI(n){if(typeof atob>"u")throw oI("base-64");return atob(n)}/** 3472 * @license 3473 * Copyright 2017 Google LLC 3474 * 3475 * Licensed under the Apache License, Version 2.0 (the "License"); 3476 * you may not use this file except in compliance with the License. 3477 * You may obtain a copy of the License at 3478 * 3479 * http://www.apache.org/licenses/LICENSE-2.0 3480 * 3481 * Unless required by applicable law or agreed to in writing, software 3482 * distributed under the License is distributed on an "AS IS" BASIS, 3483 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3484 * See the License for the specific language governing permissions and 3485 * limitations under the License. 3486 */const Xe={RAW:"raw",BASE64:"base64",BASE64URL:"base64url",DATA_URL:"data_url"};class eo{constructor(e,t){this.data=e,this.contentType=t||null}}function AI(n,e){switch(n){case Xe.RAW:return new eo(Kd(e));case Xe.BASE64:case Xe.BASE64URL:return new eo(Qd(n,e));case Xe.DATA_URL:return new eo(SI(e),PI(e))}throw Ra()}function Kd(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 RI(n){let e;try{e=decodeURIComponent(n)}catch{throw Er(Xe.DATA_URL,"Malformed data URL.")}return Kd(e)}function Qd(n,e){switch(n){case Xe.BASE64:{const s=e.indexOf("-")!==-1,i=e.indexOf("_")!==-1;if(s||i)throw Er(n,"Invalid character '"+(s?"-":"_")+"' found: is it base64url encoded?");break}case Xe.BASE64URL:{const s=e.indexOf("+")!==-1,i=e.indexOf("/")!==-1;if(s||i)throw Er(n,"Invalid character '"+(s?"+":"/")+"' found: is it base64 encoded?");e=e.replace(/-/g,"+").replace(/_/g,"/");break}}let t;try{t=vI(e)}catch(s){throw s.message.includes("polyfill")?s:Er(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 Er(Xe.DATA_URL,"Must be formatted 'data:[<mediatype>][;base64],<data>");const r=t[1]||null;r!=null&&(this.base64=bI(r,";base64"),this.contentType=this.base64?r.substring(0,r.length-7):r),this.rest=e.substring(e.indexOf(",")+1)}}function SI(n){const e=new Jd(n);return e.base64?Qd(Xe.BASE64,e.rest):RI(e.rest)}function PI(n){return new Jd(n).contentType}function bI(n,e){return n.length>=e.length?n.substring(n.length-e.length)===e:!1}/** 3487 * @license 3488 * Copyright 2017 Google LLC 3489 * 3490 * Licensed under the Apache License, Version 2.0 (the "License");
3491 * you may not use this file except in compliance with the License. 3492 * You may obtain a copy of the License at 3493 * 3494 * http://www.apache.org/licenses/LICENSE-2.0 3495 * 3496 * Unless required by applicable law or agreed to in writing, software 3497 * distributed under the License is distributed on an "AS IS" BASIS, 3498 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3499 * See the License for the specific language governing permissions and 3500 * limitations under the License. 3501 */class at{constructor(e,t){let r=0,s="";al(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(al(this.data_)){const r=this.data_,s=wI(r,e,t);return s===null?null:new at(s)}else{const r=new Uint8Array(this.data_.buffer,e,t-e);return new at(r,!0)}}static getBlob(...e){if(Sa()){const t=e.map(r=>r instanceof at?r.data_:r);return new at(II.apply(null,t))}else{const t=e.map(a=>yi(a)?AI(Xe.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 u=0;u<a.length;u++)s[i++]=a[u]}),new at(s,!0)}}uploadData(){return this.data_}}/** 3502 * @license 3503 * Copyright 2017 Google LLC 3504 * 3505 * Licensed under the Apache License, Version 2.0 (the "License"); 3506 * you may not use this file except in compliance with the License. 3507 * You may obtain a copy of the License at 3508 * 3509 * http://www.apache.org/licenses/LICENSE-2.0 3510 * 3511 * Unless required by applicable law or agreed to in writing, software 3512 * distributed under the License is distributed on an "AS IS" BASIS, 3513 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3514 * See the License for the specific language governing permissions and 3515 * limitations under the License. 3516 */function Pa(n){let e;try{e=JSON.parse(n)}catch{return null}return fI(e)?e:null}/** 3517 * @license 3518 * Copyright 2017 Google LLC 3519 * 3520 * Licensed under the Apache License, Version 2.0 (the "License"); 3521 * you may not use this file except in compliance with the License. 3522 * You may obtain a copy of the License at 3523 * 3524 * http://www.apache.org/licenses/LICENSE-2.0 3525 * 3526 * Unless required by applicable law or agreed to in writing, software 3527 * distributed under the License is distributed on an "AS IS" BASIS, 3528 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3529 * See the License for the specific language governing permissions and 3530 * limitations under the License. 3531 */function CI(n){if(n.length===0)return null;const e=n.lastIndexOf("/");return e===-1?"":n.slice(0,e)}function kI(n,e){const t=e.split("/").filter(r=>r.length>0).join("/");return n.length===0?t:n+"/"+t}function Yd(n){const e=n.lastIndexOf("/",n.length-2);return e===-1?n:n.slice(e+1)}/** 3532 * @license 3533 * Copyright 2017 Google LLC 3534 * 3535 * Licensed under the Apache License, Version 2.0 (the "License"); 3536 * you may not use this file except in compliance with the License. 3537 * You may obtain a copy of the License at 3538 * 3539 * http://www.apache.org/licenses/LICENSE-2.0 3540 * 3541 * Unless required by applicable law or agreed to in writing, software 3542 * distributed under the License is distributed on an "AS IS" BASIS, 3543 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3544 * See the License for the specific language governing permissions and 3545 * limitations under the License. 3546 */function NI(n,e){return e}class Pe{constructor(e,t,r,s){this.server=e,this.local=t||e,this.writable=!!r,this.xform=s||NI}}let hs=null;function DI(n){return!yi(n)||n.length<2?n:Yd(n)}function Ei(){if(hs)return hs;const n=[];n.push(new Pe("bucket")),n.push(new Pe("generation")),n.push(new Pe("metageneration")),n.push(new Pe("name","fullPath",!0));function e(i,a){return DI(a)}const t=new Pe("name");t.xform=e,n.push(t);function r(i,a){return a!==void 0?Number(a):a}const s=new Pe("size");
3546return s.xform=r,n.push(s),n.push(new Pe("timeCreated")),n.push(new Pe("updated")),n.push(new Pe("md5Hash",null,!0)),n.push(new Pe("cacheControl",null,!0)),n.push(new Pe("contentDisposition",null,!0)),n.push(new Pe("contentEncoding",null,!0)),n.push(new Pe("contentLanguage",null,!0)),n.push(new Pe("contentType",null,!0)),n.push(new Pe("metadata","customMetadata",!0)),hs=n,hs}function VI(n,e){function t(){const r=n.bucket,s=n.fullPath,i=new be(r,s);return e._makeStorageReference(i)}Object.defineProperty(n,"ref",{get:t})}function OI(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 VI(r,n),r}function Xd(n,e,t){const r=Pa(e);return r===null?null:OI(n,r,t)}function LI(n,e,t,r){const s=Pa(e);if(s===null||!yi(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,_="/b/"+a(f)+"/o/"+a(m),S=fn(_,t,r),C=Gd({alt:"media",token:d});return S+C})[0]}function Zd(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)}/** 3547 * @license 3548 * Copyright 2019 Google LLC 3549 * 3550 * Licensed under the Apache License, Version 2.0 (the "License"); 3551 * you may not use this file except in compliance with the License. 3552 * You may obtain a copy of the License at 3553 * 3554 * http://www.apache.org/licenses/LICENSE-2.0 3555 * 3556 * Unless required by applicable law or agreed to in writing, software 3557 * distributed under the License is distributed on an "AS IS" BASIS, 3558 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3559 * See the License for the specific language governing permissions and 3560 * limitations under the License. 3561 */const cl="prefixes",ul="items";function MI(n,e,t){const r={prefixes:[],items:[],nextPageToken:t.nextPageToken};if(t[cl])for(const s of t[cl]){const i=s.replace(/\/$/,""),a=n._makeStorageReference(new be(e,i));r.prefixes.push(a)}if(t[ul])for(const s of t[ul]){const i=n._makeStorageReference(new be(e,s.name));r.items.push(i)}return r}function xI(n,e,t){const r=Pa(t);return r===null?null:MI(n,e,r)}class Ht{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=[]}}/** 3562 * @license 3563 * Copyright 2017 Google LLC 3564 * 3565 * Licensed under the Apache License, Version 2.0 (the "License"); 3566 * you may not use this file except in compliance with the License. 3567 * You may obtain a copy of the License at 3568 * 3569 * http://www.apache.org/licenses/LICENSE-2.0 3570 * 3571 * Unless required by applicable law or agreed to in writing, software 3572 * distributed under the License is distributed on an "AS IS" BASIS, 3573 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3574 * See the License for the specific language governing permissions and 3575 * limitations under the License. 3576 */function st(n){if(!n)throw Ra()}function ba(n,e){function t(r,s){const i=Xd(n,s,e);return st(i!==null),i}return t}function UI(n,e){function t(r,s){const i=xI(n,e,s);return st(i!==null),i}return t}function FI(n,e){function t(r,s){const i=Xd(n,s,e);return st(i!==null),LI(i,s,n.host,n._protocol)}return t}function $n(n){function e(t,r){let s;return t.getStatus()===401?t.getErrorText().includes("Firebase App Check token is invalid")?s=ZT():s=XT():t.getStatus()===402?s=YT(n.bucket):t.getStatus()===403?s=eI(n.path):s=r,s.status=t.getStatus(),s.serverResponse=r.serverResponse,s}return e}function Ca(n){const e=$n(n);function t(r,s){let i=e(r,s);return r.getStatus()===404&&(i=JT(n.path)),i.serverResponse=s.serverResponse,i}return t}function ef(n,e,t){const r=e.fullServerUrl(),s=fn(r,n.host,n._protocol),i="GET",a=n.maxOperationRetryTime,u=new Ht(s,i,ba(n,t),a);return u.errorHandler=Ca(e),u}function BI(n,e,t,r,s){const i={};e.isRoot?i.prefix="":i.prefix=e.path+"/",t.length>0&&(i.delimiter=t),r&&(i.pageToken=r),s&&(i.maxResults=s);const a=e.bucketOnlyServerUrl(),u=fn(a,n.host,n._protocol),l="GET",d=n.maxOperationRetryTime,f=new Ht(u,l,UI(n,e.bucket),d);
3576return f.urlParams=i,f.errorHandler=$n(e),f}function qI(n,e,t){const r=e.fullServerUrl(),s=fn(r,n.host,n._protocol),i="GET",a=n.maxOperationRetryTime,u=new Ht(s,i,FI(n,t),a);return u.errorHandler=Ca(e),u}function $I(n,e){const t=e.fullServerUrl(),r=fn(t,n.host,n._protocol),s="DELETE",i=n.maxOperationRetryTime;function a(l,d){}const u=new Ht(r,s,a,i);return u.successCodes=[200,204],u.errorHandler=Ca(e),u}function jI(n,e){return n&&n.contentType||e&&e.type()||"application/octet-stream"}function tf(n,e,t){const r=Object.assign({},t);return r.fullPath=n.path,r.size=e.size(),r.contentType||(r.contentType=jI(null,e)),r}function nf(n,e,t,r,s){const i=e.bucketOnlyServerUrl(),a={"X-Goog-Upload-Protocol":"multipart"};function u(){let $="";for(let Q=0;Q<2;Q++)$=$+Math.random().toString().slice(2);return $}const l=u();a["Content-Type"]="multipart/related; boundary="+l;const d=tf(e,r,s),f=Zd(d,t),m="--"+l+`\r 3577Content-Type: application/json; charset=utf-8\r 3578\r 3579`+f+`\r 3580--`+l+`\r 3581Content-Type: `+d.contentType+`\r 3582\r 3583`,_=`\r 3584--`+l+"--",S=at.getBlob(m,r,_);if(S===null)throw Hd();const C={name:d.fullPath},D=fn(i,n.host,n._protocol),k="POST",q=n.maxUploadRetryTime,F=new Ht(D,k,ba(n,t),q);
3584return F.urlParams=C,F.headers=a,F.body=S.uploadData(),F.errorHandler=$n(e),F}class $s{constructor(e,t,r,s){this.current=e,this.total=t,this.finalized=!!r,this.metadata=s||null}}function ka(n,e){let t=null;try{t=n.getResponseHeader("X-Goog-Upload-Status")}catch{st(!1)}return st(!!t&&(e||["active"]).indexOf(t)!==-1),t}function HI(n,e,t,r,s){const i=e.bucketOnlyServerUrl(),a=tf(e,r,s),u={name:a.fullPath},l=fn(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=Zd(a,t),_=n.maxUploadRetryTime;function S(D){ka(D);let k;try{k=D.getResponseHeader("X-Goog-Upload-URL")}catch{st(!1)}return st(yi(k)),k}const C=new Ht(l,d,S,_);return C.urlParams=u,C.headers=f,C.body=m,C.errorHandler=$n(e),C}function zI(n,e,t,r){const s={"X-Goog-Upload-Command":"query"};function i(d){const f=ka(d,["active","final"]);let m=null;try{m=d.getResponseHeader("X-Goog-Upload-Size-Received")}catch{st(!1)}m||st(!1);const _=Number(m);return st(!isNaN(_)),new $s(_,r.size(),f==="final")}
3584const a="POST",u=n.maxUploadRetryTime,l=new Ht(t,a,i,u);return l.headers=s,l.errorHandler=$n(e),l}const ll=256*1024;function GI(n,e,t,r,s,i,a,u){const l=new $s(0,0);if(a?(l.current=a.current,l.total=a.total):(l.current=0,l.total=r.size()),r.size()!==l.total)throw sI();const d=l.total-l.current;let f=d;s>0&&(f=Math.min(f,s));const m=l.current,_=m+f;let S="";f===0?S="finalize":d===f?S="upload, finalize":S="upload";const C={"X-Goog-Upload-Command":S,"X-Goog-Upload-Offset":`${l.current}`},D=r.slice(m,_);if(D===null)throw Hd();function k(Q,ce){const ne=ka(Q,["active","final"]),I=l.current+f,g=r.size();let E;return ne==="final"?E=ba(e,i)(Q,ce):E=null,new $s(I,g,ne==="final",E)}const q="POST",F=e.maxUploadRetryTime,$=new Ht(t,q,k,F);return $.headers=C,$.body=D.uploadData(),$.progressCallback=u||null,$.errorHandler=$n(n),$}const Ne={RUNNING:"running",PAUSED:"paused",SUCCESS:"success",CANCELED:"canceled",ERROR:"error"};function to(n){switch(n){case"running":case"pausing":case"canceling":return Ne.RUNNING;case"paused":return Ne.PAUSED;case"success":return Ne.SUCCESS;case"canceled":return Ne.CANCELED;case"error":return Ne.ERROR;default:return Ne.ERROR}}/** 3585 * @license 3586 * Copyright 2017 Google LLC 3587 * 3588 * Licensed under the Apache License, Version 2.0 (the "License"); 3589 * you may not use this file except in compliance with the License. 3590 * You may obtain a copy of the License at 3591 * 3592 * http://www.apache.org/licenses/LICENSE-2.0 3593 * 3594 * Unless required by applicable law or agreed to in writing, software 3595 * distributed under the License is distributed on an "AS IS" BASIS, 3596 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3597 * See the License for the specific language governing permissions and 3598 * limitations under the License. 3599 */class WI{constructor(e,t,r){if(dI(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}}}/** 3600 * @license 3601 * Copyright 2017 Google LLC 3602 * 3603 * Licensed under the Apache License, Version 2.0 (the "License"); 3604 * you may not use this file except in compliance with the License. 3605 * You may obtain a copy of the License at 3606 * 3607 * http://www.apache.org/licenses/LICENSE-2.0 3608 * 3609 * Unless required by applicable law or agreed to in writing, software 3610 * distributed under the License is distributed on an "AS IS" BASIS, 3611 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3612 * See the License for the specific language governing permissions and 3613 * limitations under the License. 3614 */function _n(n){return(...e)=>{Promise.resolve().then(()=>n(...e))}}class KI{constructor(){this.sent_=!1,this.xhr_=new XMLHttpRequest,this.initXhr(),this.errorCode_=tn.NO_ERROR,this.sendPromise_=new Promise(e=>{this.xhr_.addEventListener("abort",()=>{this.errorCode_=tn.ABORT,e()}),this.xhr_.addEventListener("error",()=>{this.errorCode_=tn.NETWORK_ERROR,e()}),this.xhr_.addEventListener("load",()=>{e()})})}send(e,t,r,s,i){if(this.sent_)throw or("cannot .send() more than once");if(ot(e)&&r&&(this.xhr_.withCredentials=!0),this.sent_=!0,this.xhr_.open(t,e,!0),i!==void 0)for(const a in i)i.hasOwnProperty(a)&&this.xhr_.setRequestHeader(a,i[a].toString());return s!==void 0?this.xhr_.send(s):this.xhr_.send(),this.sendPromise_}getErrorCode(){if(!this.sent_)throw or("cannot .getErrorCode() before sending");return this.errorCode_}getStatus(){if(!this.sent_)throw or("cannot .getStatus() before sending");try{return this.xhr_.status}catch{return-1}}getResponse(){if(!this.sent_)throw or("cannot .getResponse() before sending");return this.xhr_.response}getErrorText(){if(!this.sent_)throw or("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 QI extends KI{initXhr(){this.xhr_.responseType="text"}}function Ye(){return new QI}/** 3615 * @license 3616 * Copyright 2017 Google LLC 3617 * 3618 * Licensed under the Apache License, Version 2.0 (the "License");
3619 * you may not use this file except in compliance with the License. 3620 * You may obtain a copy of the License at 3621 * 3622 * http://www.apache.org/licenses/LICENSE-2.0 3623 * 3624 * Unless required by applicable law or agreed to in writing, software 3625 * distributed under the License is distributed on an "AS IS" BASIS, 3626 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3627 * See the License for the specific language governing permissions and 3628 * limitations under the License. 3629 */class JI{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=Ei(),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(Wd(s.status,[]))if(i)s=$d();else{this.sleepTime=Math.max(this.sleepTime*2,QT),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=HI(this._ref.storage,this._ref._location,this._mappings,this._blob,this._metadata),s=this._ref.storage._makeRequest(r,Ye,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=zI(this._ref.storage,this._ref._location,e,this._blob),i=this._ref.storage._makeRequest(s,Ye,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=ll*this._chunkMultiplier,t=new $s(this._transferred,this._blob.size()),r=this._uploadUrl;this._resolveToken((s,i)=>{let a;try{a=GI(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 u=this._ref.storage._makeRequest(a,Ye,s,i,!1);this._request=u,u.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(){ll*this._chunkMultiplier*2<32*1024*1024&&(this._chunkMultiplier*=2)}_fetchMetadata(){this._resolveToken((e,t)=>{const r=ef(this._ref.storage,this._ref._location,this._mappings),s=this._ref.storage._makeRequest(r,Ye,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=nf(this._ref.storage,this._ref._location,this._mappings,this._blob,this._metadata),s=this._ref.storage._makeRequest
3629(r,Ye,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=jd(),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=to(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 WI(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(to(this._state)){case Ne.SUCCESS:_n(this._resolve.bind(null,this.snapshot))();break;case Ne.CANCELED:case Ne.ERROR:const t=this._reject;_n(t.bind(null,this._error))();break;default:e=!1;break}e&&(this._resolve=void 0,this._reject=void 0)}}_notifyObserver(e){switch(to(this._state)){case Ne.RUNNING:case Ne.PAUSED:e.next&&_n(e.next.bind(e,this.snapshot))();break;case Ne.SUCCESS:e.complete&&_n(e.complete.bind(e))();break;case Ne.CANCELED:case Ne.ERROR:e.error&&_n(e.error.bind(e,this._error))();break;default:e.error&&_n(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}}/** 3630 * @license 3631 * Copyright 2019 Google LLC 3632 * 3633 * Licensed under the Apache License, Version 2.0 (the "License"); 3634 * you may not use this file except in compliance with the License. 3635 * You may obtain a copy of the License at 3636 * 3637 * http://www.apache.org/licenses/LICENSE-2.0 3638 * 3639 * Unless required by applicable law or agreed to in writing, software 3640 * distributed under the License is distributed on an "AS IS" BASIS, 3641 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3642 * See the License for the specific language governing permissions and 3643 * limitations under the License. 3644 */class cn{constructor(e,t){this._service=e,t instanceof be?this._location=t:this._location=be.makeFromUrl(t,e.host)}toString(){return"gs://"+this._location.bucket+"/"+this._location.path}_newRef(e,t){return new cn(e,t)}get root(){const e=new be(this._location.bucket,"");return this._newRef(this._service,e)}get bucket(){return this._location.bucket}get fullPath(){return this._location.path}get name(){return Yd(this._location.path)}get storage(){return this._service}get parent(){const e=CI(this._location.path);if(e===null)return null;const t=new be(this._location.bucket,e);return new cn(this._service,t)}_throwIfRoot(e){if(this._location.path==="")throw aI(e)}}function YI(n,e,t){n._throwIfRoot("uploadBytes");const r=nf(n.storage,n._location,Ei(),new at(e,!0),t);return n.storage.makeRequestWithTokens(r,Ye).then(s=>({metadata:s,ref:n}))}function XI(n,e,t){return n._throwIfRoot("uploadBytesResumable"),new JI(n,new at(e),t)}function ZI(n){const e={prefixes:[],items:[]};return rf(n,e).then(()=>e)}async function rf(n,e,t){const s=await ew(n,{pageToken:t});e.prefixes.push(...s.prefixes),e.items.push(...s.items),s.nextPageToken!=null&&await rf(n,e,s.nextPageToken)}function ew(n,e){e!=null&&typeof e.maxResults=="number"&&Po("options.maxResults",1,1e3,e.maxResults);const t=e||{},r=BI(n.storage,n._location,"/",t.pageToken,t.maxResults);return n.storage.makeRequestWithTokens(r,Ye)}function tw(n){n._throwIfRoot("getMetadata");const e=ef(n.storage,n._location,Ei());return n.storage.makeRequestWithTokens(e,Ye)}function nw(n){n._throwIfRoot("getDownloadURL");const e=qI(n.storage,n._location,Ei());return n.storage.makeRequestWithTokens(e,Ye).then(t=>{if(t===null)throw iI();return t})}function rw(n){n._throwIfRoot("deleteObject");const e=$I(n.storage,n._location);return n.storage.makeRequestWithTokens(e,Ye)}function sw(n,e){const t=kI(n._location.path,e),r=new be(n._location.bucket,t);return new cn(n.storage,r)}/** 3645 * @license 3646 * Copyright 2017 Google LLC 3647 * 3648 * Licensed under the Apache License, Version 2.0 (the "License");
3649 * you may not use this file except in compliance with the License. 3650 * You may obtain a copy of the License at 3651 * 3652 * http://www.apache.org/licenses/LICENSE-2.0 3653 * 3654 * Unless required by applicable law or agreed to in writing, software 3655 * distributed under the License is distributed on an "AS IS" BASIS, 3656 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3657 * See the License for the specific language governing permissions and 3658 * limitations under the License. 3659 */function iw(n){return/^[A-Za-z]+:\/\//.test(n)}function ow(n,e){return new cn(n,e)}function sf(n,e){if(n instanceof Na){const t=n;if(t._bucket==null)throw rI();const r=new cn(t,t._bucket);return e!=null?sf(r,e):r}else return e!==void 0?sw(n,e):n}function aw(n,e){if(e&&iw(e)){if(n instanceof Na)return ow(n,e);throw So("To use ref(service, url), the first argument must be a Storage instance.")}else return sf(n,e)}function hl(n,e){const t=e==null?void 0:e[qd];return t==null?null:be.makeFromBucketSpec(t,n)}function cw(n,e,t,r={}){n.host=`${e}:${t}`;const s=ot(e);s&&(Gs(`https://${n.host}/b`),Ws("Storage",!0)),n._isUsingEmulator=!0,n._protocol=s?"https":"http";const{mockUserToken:i}=r;i&&(n._overrideAuthToken=typeof i=="string"?i:vl(i,n.app.options.projectId))}class Na{constructor(e,t,r,s,i,a=!1){this.app=e,this._authProvider=t,this._appCheckProvider=r,this._url=s,this._firebaseVersion=i,this._isUsingEmulator=a,this._bucket=null,this._host=Bd,this._protocol="https",this._appId=null,this._deleted=!1,this._maxOperationRetryTime=WT,this._maxUploadRetryTime=KT,this._requests=new Set,s!=null?this._bucket=be.makeFromBucketSpec(s,this._host):this._bucket=hl(this._host,this.app.options)}get host(){return this._host}set host(e){this._host=e,this._url!=null?this._bucket=be.makeFromBucketSpec(this._url,e):this._bucket=hl(e,this.app.options)}get maxUploadRetryTime(){return this._maxUploadRetryTime}set maxUploadRetryTime(e){Po("time",0,Number.POSITIVE_INFINITY,e),this._maxUploadRetryTime=e}get maxOperationRetryTime(){return this._maxOperationRetryTime}set maxOperationRetryTime(e){Po("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(ve(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 cn(this,e)}_makeRequest(e,t,r,s,i=!0){if(this._deleted)return new cI(zd());{const a=EI(e,this._appId,r,s,t,this._firebaseVersion,i,this._isUsingEmulator);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 dl="@firebase/storage",fl="0.14.0";/** 3660 * @license 3661 * Copyright 2020 Google LLC 3662 * 3663 * Licensed under the Apache License, Version 2.0 (the "License"); 3664 * you may not use this file except in compliance with the License. 3665 * You may obtain a copy of the License at 3666 * 3667 * http://www.apache.org/licenses/LICENSE-2.0 3668 * 3669 * Unless required by applicable law or agreed to in writing, software 3670 * distributed under the License is distributed on an "AS IS" BASIS, 3671 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3672 * See the License for the specific language governing permissions and 3673 * limitations under the License. 3674 */const of="storage";function av(n,e,t){return n=H(n),YI(n,e,t)}function cv(n,e,t){return n=H(n),XI(n,e,t)}function uv(n){return n=H(n),tw(n)}function lv(n){return n=H(n),ZI(n)}function hv(n){return n=H(n),nw(n)}function dv(n){return n=H(n),rw(n)}function fv(n,e){return n=H(n),aw(n,e)}function pv(n=Ks(),e){n=H(n);const r=Dr(n,of).getImmediate({identifier:e}),s=Co("storage");return s&&uw(r,...s),r}function uw(n,e,t,r={}){cw(n,e,t,r)}function lw(n,{instanceIdentifier:e}){const t=n.getProvider("app").getImmediate(),r=n.getProvider("auth-internal"),s=n.getProvider("app-check-internal");return new Na(t,r,s,e,un)}function hw(){Vt(new ht(of,lw,"PUBLIC").setMultipleInstances(!0)),Ue(dl,fl,""),Ue(dl,fl,"esm2020")}hw();/** 3675 * @license 3676 * Copyright 2017 Google LLC 3677 * 3678 * Licensed under the Apache License, Version 2.0 (the "License");
3679 * you may not use this file except in compliance with the License. 3680 * You may obtain a copy of the License at 3681 * 3682 * http://www.apache.org/licenses/LICENSE-2.0 3683 * 3684 * Unless required by applicable law or agreed to in writing, software 3685 * distributed under the License is distributed on an "AS IS" BASIS, 3686 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3687 * See the License for the specific language governing permissions and 3688 * limitations under the License. 3689 */const dw="type.googleapis.com/google.protobuf.Int64Value",fw="type.googleapis.com/google.protobuf.UInt64Value";function af(n,e){const t={};for(const r in n)n.hasOwnProperty(r)&&(t[r]=e(n[r]));return t}function js(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=>js(e));if(typeof n=="function"||typeof n=="object")return af(n,e=>js(e));throw new Error("Data cannot be encoded in JSON: "+n)}function Ln(n){if(n==null)return n;if(n["@type"])switch(n["@type"]){case dw:case fw:{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=>Ln(e)):typeof n=="function"||typeof n=="object"?af(n,e=>Ln(e)):n}/** 3690 * @license 3691 * Copyright 2020 Google LLC 3692 * 3693 * Licensed under the Apache License, Version 2.0 (the "License"); 3694 * you may not use this file except in compliance with the License. 3695 * You may obtain a copy of the License at 3696 * 3697 * http://www.apache.org/licenses/LICENSE-2.0 3698 * 3699 * Unless required by applicable law or agreed to in writing, software 3700 * distributed under the License is distributed on an "AS IS" BASIS, 3701 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3702 * See the License for the specific language governing permissions and 3703 * limitations under the License. 3704 */const Da="functions";/** 3705 * @license 3706 * Copyright 2017 Google LLC 3707 * 3708 * Licensed under the Apache License, Version 2.0 (the "License"); 3709 * you may not use this file except in compliance with the License. 3710 * You may obtain a copy of the License at 3711 * 3712 * http://www.apache.org/licenses/LICENSE-2.0 3713 * 3714 * Unless required by applicable law or agreed to in writing, software 3715 * distributed under the License is distributed on an "AS IS" BASIS, 3716 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3717 * See the License for the specific language governing permissions and 3718 * limitations under the License. 3719 */const pl={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 Ve extends ze{constructor(e,t,r){super(`${Da}/${e}`,t||""),this.details=r,Object.setPrototypeOf(this,Ve.prototype)}}function pw(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 Hs(n,e){let t=pw(n),r=t,s;try{const i=e&&e.error;if(i){const a=i.status;if(typeof a=="string"){if(!pl[a])return new Ve("internal","internal");t=pl[a],r=a}const u=i.message;typeof u=="string"&&(r=u),s=i.details,s!==void 0&&(s=Ln(s))}}catch{}return t==="ok"?null:new Ve(t,r,s)}/** 3720 * @license 3721 * Copyright 2017 Google LLC 3722 * 3723 * Licensed under the Apache License, Version 2.0 (the "License");
3724 * you may not use this file except in compliance with the License. 3725 * You may obtain a copy of the License at 3726 * 3727 * http://www.apache.org/licenses/LICENSE-2.0 3728 * 3729 * Unless required by applicable law or agreed to in writing, software 3730 * distributed under the License is distributed on an "AS IS" BASIS, 3731 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3732 * See the License for the specific language governing permissions and 3733 * limitations under the License. 3734 */class mw{constructor(e,t,r,s){this.app=e,this.auth=null,this.messaging=null,this.appCheck=null,this.serverAppAppCheckToken=null,ve(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}}}/** 3735 * @license 3736 * Copyright 2017 Google LLC 3737 * 3738 * Licensed under the Apache License, Version 2.0 (the "License"); 3739 * you may not use this file except in compliance with the License. 3740 * You may obtain a copy of the License at 3741 * 3742 * http://www.apache.org/licenses/LICENSE-2.0 3743 * 3744 * Unless required by applicable law or agreed to in writing, software 3745 * distributed under the License is distributed on an "AS IS" BASIS, 3746 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3747 * See the License for the specific language governing permissions and 3748 * limitations under the License. 3749 */const bo="us-central1",gw=/^data: (.*?)(?:\n|$)/;function _w(n){let e=null;return{promise:new Promise((t,r)=>{e=setTimeout(()=>{r(new Ve("deadline-exceeded","deadline-exceeded"))},n)}),cancel:()=>{e&&clearTimeout(e)}}}class yw{constructor(e,t,r,s,i=bo,a=(...u)=>fetch(...u)){this.app=e,this.fetchImpl=a,this.emulatorOrigin=null,this.contextProvider=new mw(e,t,r,s),this.cancelAllRequests=new Promise(u=>{this.deleteService=()=>Promise.resolve(u())});try{const u=new URL(i);this.customDomain=u.origin+(u.pathname==="/"?"":u.pathname),this.region=bo}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 Ew(n,e,t){const r=ot(e);n.emulatorOrigin=`http${r?"s":""}://${e}:${t}`,r&&(Gs(n.emulatorOrigin+"/backends"),Ws("Functions",!0))}function Tw(n,e,t){const r=s=>ww(n,e,s,{});return r.stream=(s,i)=>Aw(n,e,s,i),r}function cf(n){return n.emulatorOrigin&&ot(n.emulatorOrigin)?"include":void 0}async function Iw(n,e,t,r,s){t["Content-Type"]="application/json";let i;try{i=await r(n,{method:"POST",body:JSON.stringify(e),headers:t,credentials:cf(s)})}catch{return{status:0,json:null}}let a=null;try{a=await i.json()}catch{}return{status:i.status,json:a}}async function uf(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 ww(n,e,t,r){const s=n._url(e);return vw(n,s,t,r)}async function vw(n,e,t,r){t=js(t);const s={data:t},i=await uf(n,r),a=r.timeout||7e4,u=_w(a),l=await Promise.race([Iw(e,s,i,n.fetchImpl,n),u.promise,n.cancelAllRequests]);if(u.cancel(),!l)throw new Ve("cancelled","Firebase Functions instance was deleted.");const d=Hs(l.status,l.json);if(d)throw d;
3749if(!l.json)throw new Ve("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 Ve("internal","Response is missing data field.");return{data:Ln(f)}}function Aw(n,e,t,r){const s=n._url(e);return Rw(n,s,t,r||{})}async function Rw(n,e,t,r){var _;t=js(t);const s={data:t},i=await uf(n,r);i["Content-Type"]="application/json",i.Accept="text/event-stream";let a;try{a=await n.fetchImpl(e,{method:"POST",body:JSON.stringify(s),headers:i,signal:r==null?void 0:r.signal,credentials:cf(n)})}catch(S){if(S instanceof Error&&S.name==="AbortError"){const D=new Ve("cancelled","Request was cancelled.");return{data:Promise.reject(D),stream:{[Symbol.asyncIterator](){return{next(){return Promise.reject(D)}}}}}}const C=Hs(0,null);return{data:Promise.reject(C),stream:{[Symbol.asyncIterator](){return{next(){return Promise.reject(C)}}}}}}let u,l;const d=new Promise((S,C)=>{u=S,l=C});(_=r==null?void 0:r.signal)==null||_.addEventListener("abort",()=>{const S=new Ve("cancelled","Request was cancelled.");l(S)});const f=a.body.getReader(),m=Sw(f,u,l,r==null?void 0:r.signal);return{stream:{[Symbol.asyncIterator](){const S=m.getReader();return{async next(){const{value:C,done:D}=await S.read();return{value:C,done:D}},async return(){return await S.cancel(),{done:!0,value:void 0}}}}},data:d}}function Sw(n,e,t,r){const s=(a,u)=>{const l=a.match(gw);if(!l)return;const d=l[1];try{const f=JSON.parse(d);if("result"in f){e(Ln(f.result));return}if("message"in f){u.enqueue(Ln(f.message));return}if("error"in f){const m=Hs(0,f);u.error(m),t(m);return}}catch(f){if(f instanceof Ve){u.error(f),t(f);return}}},i=new TextDecoder;return new ReadableStream({start(a){let u="";return l();async function l(){if(r!=null&&r.aborted){const d=new Ve("cancelled","Request was cancelled");return a.error(d),t(d),Promise.resolve()}try{const{value:d,done:f}=await n.read();if(f){u.trim()&&s(u.trim(),a),a.close();return}if(r!=null&&r.aborted){const _=new Ve("cancelled","Request was cancelled");a.error(_),t(_),await n.cancel();return}u+=i.decode(d,{stream:!0});const m=u.split(` 3750`);u=m.pop()||"";for(const _ of m)_.trim()&&s(_.trim(),a);return l()}catch(d){const f=d instanceof Ve?d:Hs(0,null);a.error(f),t(f)}}},cancel(){return n.cancel()}})}const ml="@firebase/functions",gl="0.13.1";/** 3751 * @license 3752 * Copyright 2019 Google LLC 3753 * 3754 * Licensed under the Apache License, Version 2.0 (the "License"); 3755 * you may not use this file except in compliance with the License. 3756 * You may obtain a copy of the License at 3757 * 3758 * http://www.apache.org/licenses/LICENSE-2.0 3759 * 3760 * Unless required by applicable law or agreed to in writing, software 3761 * distributed under the License is distributed on an "AS IS" BASIS, 3762 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3763 * See the License for the specific language governing permissions and 3764 * limitations under the License. 3765 */const Pw="auth-internal",bw="app-check-internal",Cw="messaging-internal";function kw(n){const e=(t,{instanceIdentifier:r})=>{const s=t.getProvider("app").getImmediate(),i=t.getProvider(Pw),a=t.getProvider(Cw),u=t.getProvider(bw);return new yw(s,i,a,u,r)};Vt(new ht(Da,e,"PUBLIC").setMultipleInstances(!0)),Ue(ml,gl,n),Ue(ml,gl,"esm2020")}/** 3766 * @license 3767 * Copyright 2020 Google LLC 3768 * 3769 * Licensed under the Apache License, Version 2.0 (the "License"); 3770 * you may not use this file except in compliance with the License. 3771 * You may obtain a copy of the License at 3772 * 3773 * http://www.apache.org/licenses/LICENSE-2.0 3774 * 3775 * Unless required by applicable law or agreed to in writing, software 3776 * distributed under the License is distributed on an "AS IS" BASIS, 3777 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3778 * See the License for the specific language governing permissions and 3779 * limitations under the License. 3780 */function mv(n=Ks(),e=bo){const r=Dr(H(n),Da).getImmediate({identifier:e}),s=Co("functions");return s&&Nw(r,...s),r}function Nw(n,e,t){Ew(H(n),e,t)}function gv(n,e,t){return Tw(H(n),e)}kw();export{Mw as A,qw as B,Lw as C,ov as D,ln as E,Zw as F,Jw as G,iv as H,fv as I,av as J,hv as K,dv as L,uv as M,lv as N,cv as O,Qw as P,ee as T,Kw as a,pv as b,mv as c,Nw as d,LT as e,ev as f,zw as g,Ww as h,rm as i,tv as j,sv as k,Hw as l,Ow as m,gv as n,jw as o,Fw as p,Yw as q,Uw as r,nv as s,Vw as t,rv as u,$w as v,Xw as w,Bw as x,xw as y,dg as z};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.