1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2888],{1683:function(e,t,n){"use strict";n.d(t,{BH:function(){return _},LL:function(){return B},ZR:function(){return j},zI:function(){return V},tV:function(){return h},L:function(){return c},$s:function(){return Y},Sg:function(){return T},ne:function(){return W},vZ:function(){return function e(t,n){if(t===n)return!0;let r=Object.keys(t),i=Object.keys(n);for(let s of r){if(!i.includes(s))return!1;let r=t[s],o=n[s];if($(r)&&$(o)){if(!e(r,o))return!1}else if(r!==o)return!1}for(let e of i)if(!r.includes(e))return!1;return!0}},pd:function(){return H},aH:function(){return w},q4:function(){return y},P0:function(){return v},Pz:function(){return b},Rd:function(){return d},m9:function(){return J},z$:function(){return k},ru:function(){return O},Xx:function(){return I},L_:function(){return N},xb:function(){return z},w1:function(){return P},hl:function(){return F},uI:function(){return A},b$:function(){return D},G6:function(){return L},WO:function(){return M},Uo:function(){return E},xO:function(){return K},zd:function(){return G},dp:function(){return x},eu:function(){return U}});let r=()=>void 0;var i=n(3454);let s=function(e){let t=[],n=0;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);i<128?t[n++]=i:(i<2048?t[n++]=i>>6|192:((64512&i)==55296&&r+1<e.length&&(64512&e.charCodeAt(r+1))==56320?(i=65536+((1023&i)<<10)+(1023&e.charCodeAt(++r)),t[n++]=i>>18|240,t[n++]=i>>12&63|128):t[n++]=i>>12|224,t[n++]=i>>6&63|128),t[n++]=63&i|128)}return t},o=function(e){let t=[],n=0,r=0;for(;n<e.length;){let i=e[n++];if(i<128)t[r++]=String.fromCharCode(i);else if(i>191&&i<224){let s=e[n++];t[r++]=String.fromCharCode((31&i)<<6|63&s)}else if(i>239&&i<365){let s=((7&i)<<18|(63&e[n++])<<12|(63&e[n++])<<6|63&e[n++])-65536;t[r++]=String.fromCharCode(55296+(s>>10)),t[r++]=String.fromCharCode(56320+(1023&s))}else{let s=e[n++],o=e[n++];t[r++]=String.fromCharCode((15&i)<<12|(63&s)<<6|63&o)}}return t.join("")},a={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:"function"==typeof atob,encodeByteArray(e,t){if(!Array.isArray(e))throw Error("encodeByteArray takes an array as a parameter");this.init_();let n=t?this.byteToCharMapWebSafe_:this.byteToCharMap_,r=[];for(let t=0;t<e.length;t+=3){let i=e[t],s=t+1<e.length,o=s?e[t+1]:0,a=t+2<e.length,l=a?e[t+2]:0,u=i>>2,c=(3&i)<<4|o>>4,h=(15&o)<<2|l>>6,d=63&l;a||(d=64,s||(h=64)),r.push(n[u],n[c],n[h],n[d])}return r.join("")},encodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?btoa(e):this.encodeByteArray(s(e),t)},decodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?atob(e):o(this.decodeStringToByteArray(e,t))},decodeStringToByteArray(e,t){this.init_();let n=t?this.charToByteMapWebSafe_:this.charToByteMap_,r=[];for(let t=0;t<e.length;){let i=n[e.charAt(t++)],s=t<e.length?n[e.charAt(t)]:0,o=++t<e.length?n[e.charAt(t)]:64,a=++t<e.length?n[e.charAt(t)]:64;if(++t,null==i||null==s||null==o||null==a)throw new l;let u=i<<2|s>>4;if(r.push(u),64!==o){let e=s<<4&240|o>>2;if(r.push(e),64!==a){let e=o<<6&192|a;r.push(e)}}}return r},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let e=0;e<this.ENCODED_VALS.length;e++)this.byteToCharMap_[e]=this.ENCODED_VALS.charAt(e),this.charToByteMap_[this.byteToCharMap_[e]]=e,this.byteToCharMapWebSafe_[e]=this.ENCODED_VALS_WEBSAFE.charAt(e),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[e]]=e,e>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(e)]=e,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(e)]=e)}}};class l extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}let u=function(e){let t=s(e);return a.encodeByteArray(t,!0)},c=function(e){return u(e).replace(/\./g,"")},h=function(e){try{return a.decodeString(e,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};function d(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==n.g)return n.g;throw Error("Unable to locate global object.")}let f=()=>d().__FIREBASE_DEFAULTS__,p=()=>
1{if(void 0===i||void 0===i.env)return;let e=i.env.__FIREBASE_DEFAULTS__;if(e)return JSON.parse(e)},m=()=>{let e;if("undefined"==typeof document)return;try{e=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch(e){return}let t=e&&h(e[1]);return t&&JSON.parse(t)},g=()=>{try{return r()||f()||p()||m()}catch(e){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${e}`);return}},y=e=>{var t,n;return null===(n=null===(t=g())||void 0===t?void 0:t.emulatorHosts)||void 0===n?void 0:n[e]},v=e=>{let t=y(e);if(!t)return;let n=t.lastIndexOf(":");if(n<=0||n+1===t.length)throw Error(`Invalid host ${t} with no separate hostname and port!`);let r=parseInt(t.substring(n+1),10);return"["===t[0]?[t.substring(1,n-1),r]:[t.substring(0,n),r]},w=()=>{var e;return null===(e=g())||void 0===e?void 0:e.config},b=e=>{var t;return null===(t=g())||void 0===t?void 0:t[`_${e}`]};class _{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}wrapCallback(e){return(t,n)=>{t?this.reject(t):this.resolve(n),"function"==typeof e&&(this.promise.catch(()=>{}),1===e.length?e(t):e(t,n))}}}function I(e){return e.endsWith(".cloudworkstations.dev")}async function E(e){return(await fetch(e,{credentials:"include"})).ok}function T(e,t){if(e.uid)throw Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');let n=t||"demo-project",r=e.iat||0,i=e.sub||e.user_id;if(!i)throw Error("mockUserToken must contain 'sub' or 'user_id' field!");let s=Object.assign({iss:`https://securetoken.google.com/${n}`,aud:n,iat:r,exp:r+3600,auth_time:r,sub:i,user_id:i,firebase:{sign_in_provider:"custom",identities:{}}},e);return[c(JSON.stringify({alg:"none",type:"JWT"})),c(JSON.stringify(s)),""].join(".")}let S={},C=!1;function x(e,t){if("undefined"==typeof window||"undefined"==typeof document||!I(window.location.host)||S[e]===t||S[e]||C)return;function n(e){return`__firebase__banner__${e}`}S[e]=t;let r="__firebase__banner",i=function(){let e={prod:[],emulator:[]};for(let t of Object.keys(S))S[t]?e.emulator.push(t):e.prod.push(t);return e}().prod.length>0;function s(){let e,t;let s=(e=document.getElementById(r),t=!1,e||((e=document.createElement("div")).setAttribute("id",r),t=!0),{created:t,element:e}),o=n("text"),a=document.getElementById(o)||document.createElement("span"),l=n("learnmore"),u=document.getElementById(l)||document.createElement("a"),c=n("preprendIcon"),h=document.getElementById(c)||document.createElementNS("http://www.w3.org/2000/svg","svg");if(s.created){let e=s.element;e.style.display="flex",e.style.background="#7faaf0",e.style.position="fixed",e.style.bottom="5px",e.style.left="5px",e.style.padding=".5em",e.style.borderRadius="5px",e.style.alignItems="center",u.setAttribute("id",l),u.innerText="Learn more",u.href="https://firebase.google.com/docs/studio/preview-apps#preview-backend",u.setAttribute("target","__blank"),u.style.paddingLeft="5px",u.style.textDecoration="underline";let t=function(){let e=document.createElement("span");return e.style.cursor="pointer",e.style.marginLeft="16px",e.style.fontSize="24px",e.innerHTML=" ×",e.onclick=()=>{C=!0,function(){let e=document.getElementById(r);e&&e.remove()}()},e}();h.setAttribute("width","24"),h.setAttribute("id",c),h.setAttribute("height","24"),h.setAttribute("viewBox","0 0 24 24"),h.setAttribute("fill","none"),h.style.marginLeft="-6px",e.append(h,a,u,t),document.body.appendChild(e)}i?(a.innerText="Preview backend disconnected.",h.innerHTML=`<g clip-path="url(#clip0_6013_33858)"> 2<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"/> 3</g> 4<defs> 5<clipPath id="clip0_6013_33858"> 6<rect width="24" height="24" fill="white"/> 7</clipPath> 8</defs>`):(h.innerHTML=`<g clip-path="url(#clip0_6083_34804)"> 9<path d="M11.4 15.2H12.6V11.2H11.4V15.2ZM12 10C12.1667 10 12.3056 9.94444
912.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"/> 10</g> 11<defs> 12<clipPath id="clip0_6083_34804"> 13<rect width="24" height="24" fill="white"/> 14</clipPath> 15</defs>`,a.innerText="Preview backend running in this workspace."),a.setAttribute("id",o)}"loading"===document.readyState?window.addEventListener("DOMContentLoaded",s):s()}function k(){return"undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:""}function A(){return"undefined"!=typeof window&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(k())}function R(){var e;let t=null===(e=g())||void 0===e?void 0:e.forceEnvironment;if("node"===t)return!0;if("browser"===t)return!1;try{return"[object process]"===Object.prototype.toString.call(n.g.process)}catch(e){return!1}}function N(){return"undefined"!=typeof navigator&&"Cloudflare-Workers"===navigator.userAgent}function O(){let e="object"==typeof chrome?chrome.runtime:"object"==typeof browser?browser.runtime:void 0;return"object"==typeof e&&void 0!==e.id}function D(){return"object"==typeof navigator&&"ReactNative"===navigator.product}function P(){let e=k();return e.indexOf("MSIE ")>=0||e.indexOf("Trident/")>=0}function L(){return!R()&&!!navigator.userAgent&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}function M(){return!R()&&!!navigator.userAgent&&(navigator.userAgent.includes("Safari")||navigator.userAgent.includes("WebKit"))&&!navigator.userAgent.includes("Chrome")}function F(){try{return"object"==typeof indexedDB}catch(e){return!1}}function U(){return new Promise((e,t)=>{try{let n=!0,r="validate-browser-context-for-indexeddb-analytics-module",i=self.indexedDB.open(r);i.onsuccess=()=>{i.result.close(),n||self.indexedDB.deleteDatabase(r),e(!0)},i.onupgradeneeded=()=>{n=!1},i.onerror=()=>{var e;t((null===(e=i.error)||void 0===e?void 0:e.message)||"")}}catch(e){t(e)}})}function V(){return"undefined"!=typeof navigator&&!!navigator.cookieEnabled}class j extends Error{constructor(e,t,n){super(t),this.code=e,this.customData=n,this.name="FirebaseError",Object.setPrototypeOf(this,j.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,B.prototype.create)}}class B{constructor(e,t,n){this.service=e,this.serviceName=t,this.errors=n}create(e,...t){let n=t[0]||{},r=`${this.service}/${e}`,i=this.errors[e],s=i?i.replace(q,(e,t)=>{let r=n[t];return null!=r?String(r):`<${t}?>`}):"Error",o=`${this.serviceName}: ${s} (${r}).`;return new j(r,o,n)}}let q=/\{\$([^}]+)}/g;function z(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}function $(e){return null!==e&&"object"==typeof e}function K(e){let t=[];for(let[n,r]of Object.entries(e))Array.isArray(r)?r.forEach(e=>{t.push(encodeURIComponent(n)+"="+encodeURIComponent(e))}):t.push(encodeURIComponent(n)+"="+encodeURIComponent(r));return t.length?"&"+t.join("&"):""}function G(e){let t={};
15return e.replace(/^\?/,"").split("&").forEach(e=>{if(e){let[n,r]=e.split("=");t[decodeURIComponent(n)]=decodeURIComponent(r)}}),t}function H(e){let t=e.indexOf("?");if(!t)return"";let n=e.indexOf("#",t);return e.substring(t,n>0?n:void 0)}function W(e,t){let n=new Q(e,t);return n.subscribe.bind(n)}class Q{constructor(e,t){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=t,this.task.then(()=>{e(this)}).catch(e=>{this.error(e)})}next(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,n){let r;if(void 0===e&&void 0===t&&void 0===n)throw Error("Missing Observer.");void 0===(r=!function(e,t){if("object"!=typeof e||null===e)return!1;for(let n of t)if(n in e&&"function"==typeof e[n])return!0;return!1}(e,["next","error","complete"])?{next:e,error:t,complete:n}:e).next&&(r.next=X),void 0===r.error&&(r.error=X),void 0===r.complete&&(r.complete=X);let i=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(()=>{try{this.finalError?r.error(this.finalError):r.complete()}catch(e){}}),this.observers.push(r),i}unsubscribeOne(e){void 0!==this.observers&&void 0!==this.observers[e]&&(delete this.observers[e],this.observerCount-=1,0===this.observerCount&&void 0!==this.onNoObservers&&this.onNoObservers(this))}forEachObserver(e){if(!this.finalized)for(let t=0;t<this.observers.length;t++)this.sendOne(t,e)}sendOne(e,t){this.task.then(()=>{if(void 0!==this.observers&&void 0!==this.observers[e])try{t(this.observers[e])}catch(e){"undefined"!=typeof console&&console.error&&console.error(e)}})}close(e){this.finalized||(this.finalized=!0,void 0!==e&&(this.finalError=e),this.task.then(()=>{this.observers=void 0,this.onNoObservers=void 0}))}}function X(){}function Y(e,t=1e3,n=2){let r=t*Math.pow(n,e);return Math.min(144e5,r+Math.round(.5*r*(Math.random()-.5)*2))}function J(e){return e&&e._delegate?e._delegate:e}},3454:function(e,t,n){"use strict";var r,i;e.exports=(null==(r=n.g.process)?void 0:r.env)&&"object"==typeof(null==(i=n.g.process)?void 0:i.env)?n.g.process:n(7663)},6840:function(e,t,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/_app",function(){return n(6031)}])},1134:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(7294);let i=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),s=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.filter((e,t,n)=>!!e&&n.indexOf(e)===t).join(" ")};var o={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let a=(0,r.forwardRef)((e,t)=>{let{color:n="currentColor",size:i=24,strokeWidth:a=2,absoluteStrokeWidth:l,className:u="",children:c,iconNode:h,...d}=e;return(0,r.createElement)("svg",{ref:t,...o,width:i,height:i,stroke:n,strokeWidth:l?24*Number(a)/Number(i):a,className:s("lucide",u),...d},[...h.map(e=>{let[t,n]=e;return(0,r.createElement)(t,n)}),...Array.isArray(c)?c:[c]])}),l=(e,t)=>{let n=(0,r.forwardRef)((n,o)=>{let{className:l,...u}=n;return(0,r.createElement)(a,{ref:o,iconNode:t,className:s("lucide-".concat(i(e)),l),...u})});return n.displayName="".concat(e),n}},7918:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(1134).Z)("Bell",[["path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9",key:"1qo2s2"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}]])},2190:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(1134).Z)("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]])},8199:function(e,t){"use strict";var n,r,i,s;Object.defineProperty(t,"__esModule",{value:!0}),function(e,t){for(var n in t)Object.defineProperty(e,n,{enumerable:!0,get:t[n]})}(t,{ACTION_FAST_REFRESH:function(){return h},ACTION_NAVIGATE:function(){return a},ACTION_PREFETCH:function(){return c},ACTION_REFRESH:function(){return o},ACTION_RESTORE:function(){return l},ACTION_SERVER_ACTION:function(){return d},ACTION_SERVER_PATCH:function(){return u},PrefetchCacheEntryStatus:function(){return r},PrefetchKind:function(){return n},isThenable:function(){return f}});let o="refresh",a="navigate",l="restore",u="server-patch",c="prefetch",h="fast-refresh",d="server-action";function f(e){return e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof e.then}(i=n||(n={})).AUTO="auto",i.FULL="full",i.TEMPORARY="temporary",(s=r||(r={})).fresh="fresh",s.reusable="reusable",s.expired="expired",s.stale="stale",("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esMo
15dule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},7195:function(e,t,n){"use strict";function r(e,t,n,r){return!1}Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"getDomainLocale",{enumerable:!0,get:function(){return r}}),n(8337),("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},8342:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return b}});let r=n(8754),i=n(5893),s=r._(n(7294)),o=n(6075),a=n(3955),l=n(8041),u=n(9903),c=n(5490),h=n(1928),d=n(257),f=n(4229),p=n(7195),m=n(9470),g=n(8199),y=new Set;function v(e,t,n,r,i,s){if(s||(0,a.isLocalURL)(t)){if(!r.bypassPrefetchedCheck){let i=t+"%"+n+"%"+(void 0!==r.locale?r.locale:"locale"in e?e.locale:void 0);if(y.has(i))return;y.add(i)}(async()=>s?e.prefetch(t,i):e.prefetch(t,n,r))().catch(e=>{})}}function w(e){return"string"==typeof e?e:(0,l.formatUrl)(e)}let b=s.default.forwardRef(function(e,t){let n,r;let{href:l,as:y,children:b,prefetch:_=null,passHref:I,replace:E,shallow:T,scroll:S,locale:C,onClick:x,onMouseEnter:k,onTouchStart:A,legacyBehavior:R=!1,...N}=e;n=b,R&&("string"==typeof n||"number"==typeof n)&&(n=(0,i.jsx)("a",{children:n}));let O=s.default.useContext(h.RouterContext),D=s.default.useContext(d.AppRouterContext),P=null!=O?O:D,L=!O,M=!1!==_,F=null===_?g.PrefetchKind.AUTO:g.PrefetchKind.FULL,{href:U,as:V}=s.default.useMemo(()=>{if(!O){let e=w(l);return{href:e,as:y?w(y):e}}let[e,t]=(0,o.resolveHref)(O,l,!0);return{href:e,as:y?(0,o.resolveHref)(O,y):t||e}},[O,l,y]),j=s.default.useRef(U),B=s.default.useRef(V);R&&(r=s.default.Children.only(n));let q=R?r&&"object"==typeof r&&r.ref:t,[z,$,K]=(0,f.useIntersection)({rootMargin:"200px"}),G=s.default.useCallback(e=>{(B.current!==V||j.current!==U)&&(K(),B.current=V,j.current=U),z(e),q&&("function"==typeof q?q(e):"object"==typeof q&&(q.current=e))},[V,q,U,K,z]);s.default.useEffect(()=>{P&&$&&M&&v(P,U,V,{locale:C},{kind:F},L)},[V,U,$,C,M,null==O?void 0:O.locale,P,L,F]);let H={ref:G,onClick(e){R||"function"!=typeof x||x(e),R&&r.props&&"function"==typeof r.props.onClick&&r.props.onClick(e),P&&!e.defaultPrevented&&function(e,t,n,r,i,o,l,u,c){let{nodeName:h}=e.currentTarget;if("A"===h.toUpperCase()&&(function(e){let t=e.currentTarget.getAttribute("target");return t&&"_self"!==t||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||e.nativeEvent&&2===e.nativeEvent.which}(e)||!c&&!(0,a.isLocalURL)(n)))return;e.preventDefault();let d=()=>{let e=null==l||l;"beforePopState"in t?t[i?"replace":"push"](n,r,{shallow:o,locale:u,scroll:e}):t[i?"replace":"push"](r||n,{scroll:e})};c?s.default.startTransition(d):d()}(e,P,U,V,E,T,S,C,L)},onMouseEnter(e){R||"function"!=typeof k||k(e),R&&r.props&&"function"==typeof r.props.onMouseEnter&&r.props.onMouseEnter(e),P&&(M||!L)&&v(P,U,V,{locale:C,priority:!0,bypassPrefetchedCheck:!0},{kind:F},L)},onTouchStart:function(e){R||"function"!=typeof A||A(e),R&&r.props&&"function"==typeof r.props.onTouchStart&&r.props.onTouchStart(e),P&&(M||!L)&&v(P,U,V,{locale:C,priority:!0,bypassPrefetchedCheck:!0},{kind:F},L)}};if((0,u.isAbsoluteUrl)(V))H.href=V;else if(!R||I||"a"===r.type&&!("href"in r.props)){let e=void 0!==C?C:null==O?void 0:O.locale,t=(null==O?void 0:O.isLocaleDomain)&&(0,p.getDomainLocale)(V,e,null==O?void 0:O.locales,null==O?void 0:O.domainLocales);H.href=t||(0,m.addBasePath)((0,c.addLocale)(V,e,null==O?void 0:O.defaultLocale))}return R?s.default.cloneElement(r,H):(0,i.jsx)("a",{...N,...H,children:n})});("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},4229:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"useIntersection",{enumerable:!0,get:function(){return l}});let r=n(7294),i=n(4474),s="function"==typeof IntersectionObserver,o=new Map,a=[];function l(e){let{rootRef:t,rootMargin:n,disabled:l}=e,u=l||!s,[c,h]=(0,r.useState)(!1),d=(0,r.useRef)(null),f=(0,r.useCallback)(e=>{d.current=e},[]);return(0,r.useEffect)(()=>
15{if(s){if(u||c)return;let e=d.current;if(e&&e.tagName)return function(e,t,n){let{id:r,observer:i,elements:s}=function(e){let t;let n={root:e.root||null,margin:e.rootMargin||""},r=a.find(e=>e.root===n.root&&e.margin===n.margin);if(r&&(t=o.get(r)))return t;let i=new Map;return t={id:n,observer:new IntersectionObserver(e=>{e.forEach(e=>{let t=i.get(e.target),n=e.isIntersecting||e.intersectionRatio>0;t&&n&&t(n)})},e),elements:i},a.push(n),o.set(n,t),t}(n);return s.set(e,t),i.observe(e),function(){if(s.delete(e),i.unobserve(e),0===s.size){i.disconnect(),o.delete(r);let e=a.findIndex(e=>e.root===r.root&&e.margin===r.margin);e>-1&&a.splice(e,1)}}}(e,e=>e&&h(e),{root:null==t?void 0:t.current,rootMargin:n})}else if(!c){let e=(0,i.requestIdleCallback)(()=>h(!0));return()=>(0,i.cancelIdleCallback)(e)}},[u,n,t,c,d.current]),[f,c,(0,r.useCallback)(()=>{h(!1)},[])]}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},2602:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e,t){for(var n in t)Object.defineProperty(e,n,{enumerable:!0,get:t[n]})}(t,{default:function(){return a},noSSR:function(){return o}});let r=n(8754);n(5893),n(7294);let i=r._(n(5491));function s(e){return{default:(null==e?void 0:e.default)||e}}function o(e,t){return delete t.webpack,delete t.modules,e(t)}function a(e,t){let n=i.default,r={loading:e=>{let{error:t,isLoading:n,pastDelay:r}=e;return null}};e instanceof Promise?r.loader=()=>e:"function"==typeof e?r.loader=e:"object"==typeof e&&(r={...r,...e});let a=(r={...r,...t}).loader;return(r.loadableGenerated&&(r={...r,...r.loadableGenerated},delete r.loadableGenerated),"boolean"!=typeof r.ssr||r.ssr)?n({...r,loader:()=>null!=a?a().then(s):Promise.resolve(s(()=>null))}):(delete r.webpack,delete r.modules,o(n,r))}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},1159:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"LoadableContext",{enumerable:!0,get:function(){return r}});let r=n(8754)._(n(7294)).default.createContext(null)},5491:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return d}});let r=n(8754)._(n(7294)),i=n(1159),s=[],o=[],a=!1;function l(e){let t=e(),n={loading:!0,loaded:null,error:null};return n.promise=t.then(e=>(n.loading=!1,n.loaded=e,e)).catch(e=>{throw n.loading=!1,n.error=e,e}),n}class u{promise(){return this._res.promise}retry(){this._clearTimeouts(),this._res=this._loadFn(this._opts.loader),this._state={pastDelay:!1,timedOut:!1};let{_res:e,_opts:t}=this;e.loading&&("number"==typeof t.delay&&(0===t.delay?this._state.pastDelay=!0:this._delay=setTimeout(()=>{this._update({pastDelay:!0})},t.delay)),"number"==typeof t.timeout&&(this._timeout=setTimeout(()=>{this._update({timedOut:!0})},t.timeout))),this._res.promise.then(()=>{this._update({}),this._clearTimeouts()}).catch(e=>{this._update({}),this._clearTimeouts()}),this._update({})}_update(e){this._state={...this._state,error:this._res.error,loaded:this._res.loaded,loading:this._res.loading,...e},this._callbacks.forEach(e=>e())}_clearTimeouts(){clearTimeout(this._delay),clearTimeout(this._timeout)}getCurrentValue(){return this._state}subscribe(e){return this._callbacks.add(e),()=>{this._callbacks.delete(e)}}constructor(e,t){this._loadFn=e,this._opts=t,this._callbacks=new Set,this._delay=null,this._timeout=null,this.retry()}}function c(e){return function(e,t){let n=Object.assign({loader:null,loading:null,delay:200,timeout:null,webpack:null,modules:null},t),s=null;function l(){if(!s){let t=new u(e,n);s={getCurrentValue:t.getCurrentValue.bind(t),subscribe:t.subscribe.bind(t),retry:t.retry.bind(t),promise:t.promise.bind(t)}}return s.promise()}if(!a){let e=n.webpack?n.webpack():n.modules;e&&o.push(t=>{for(let n of e)if(t.includes(n))return l()})}function c(e,t){!function(){l();let e=r.default.useContext(i.LoadableContext);
15e&&Array.isArray(n.modules)&&n.modules.forEach(t=>{e(t)})}();let o=r.default.useSyncExternalStore(s.subscribe,s.getCurrentValue,s.getCurrentValue);return r.default.useImperativeHandle(t,()=>({retry:s.retry}),[]),r.default.useMemo(()=>{var t;return o.loading||o.error?r.default.createElement(n.loading,{isLoading:o.loading,pastDelay:o.pastDelay,timedOut:o.timedOut,error:o.error,retry:s.retry}):o.loaded?r.default.createElement((t=o.loaded)&&t.default?t.default:t,e):null},[e,o])}return c.preload=()=>l(),c.displayName="LoadableComponent",r.default.forwardRef(c)}(l,e)}function h(e,t){let n=[];for(;e.length;){let r=e.pop();n.push(r(t))}return Promise.all(n).then(()=>{if(e.length)return h(e,t)})}c.preloadAll=()=>new Promise((e,t)=>{h(s).then(e,t)}),c.preloadReady=e=>(void 0===e&&(e=[]),new Promise(t=>{let n=()=>(a=!0,t());h(o,e).then(n,n)})),window.__NEXT_PRELOADREADY=c.preloadReady;let d=c},7443:function(e,t,n){"use strict";var r=n(3454);n(1479);var i=n(7294),s=i&&"object"==typeof i&&"default"in i?i:{default:i},o=void 0!==r&&r.env&&!0,a=function(e){return"[object String]"===Object.prototype.toString.call(e)},l=function(){function e(e){var t=void 0===e?{}:e,n=t.name,r=void 0===n?"stylesheet":n,i=t.optimizeForSpeed,s=void 0===i?o:i;u(a(r),"`name` must be a string"),this._name=r,this._deletedRulePlaceholder="#"+r+"-deleted-rule____{}",u("boolean"==typeof s,"`optimizeForSpeed` must be a boolean"),this._optimizeForSpeed=s,this._serverSheet=void 0,this._tags=[],this._injected=!1,this._rulesCount=0;var l=document.querySelector('meta[property="csp-nonce"]');this._nonce=l?l.getAttribute("content"):null}var t=e.prototype;return t.setOptimizeForSpeed=function(e){u("boolean"==typeof e,"`setOptimizeForSpeed` accepts a boolean"),u(0===this._rulesCount,"optimizeForSpeed cannot be when rules have already been inserted"),this.flush(),this._optimizeForSpeed=e,this.inject()},t.isOptimizeForSpeed=function(){return this._optimizeForSpeed},t.inject=function(){var e=this;if(u(!this._injected,"sheet already injected"),this._injected=!0,this._optimizeForSpeed){this._tags[0]=this.makeStyleTag(this._name),this._optimizeForSpeed="insertRule"in this.getSheet(),this._optimizeForSpeed||(o||console.warn("StyleSheet: optimizeForSpeed mode not supported falling back to standard mode."),this.flush(),this._injected=!0);return}this._serverSheet={cssRules:[],insertRule:function(t,n){return"number"==typeof n?e._serverSheet.cssRules[n]={cssText:t}:e._serverSheet.cssRules.push({cssText:t}),n},deleteRule:function(t){e._serverSheet.cssRules[t]=null}}},t.getSheetForTag=function(e){if(e.sheet)return e.sheet;for(var t=0;t<document.styleSheets.length;t++)if(document.styleSheets[t].ownerNode===e)return document.styleSheets[t]},t.getSheet=function(){return this.getSheetForTag(this._tags[this._tags.length-1])},t.insertRule=function(e,t){if(u(a(e),"`insertRule` accepts only strings"),this._optimizeForSpeed){var n=this.getSheet();"number"!=typeof t&&(t=n.cssRules.length);try{n.insertRule(e,t)}catch(t){return o||console.warn("StyleSheet: illegal rule: \n\n"+e+"\n\nSee https://stackoverflow.com/q/20007992 for more info"),-1}}else{var r=this._tags[t];this._tags.push(this.makeStyleTag(this._name,e,r))}return this._rulesCount++},t.replaceRule=function(e,t){if(this._optimizeForSpeed){var n=this.getSheet();if(t.trim()||(t=this._deletedRulePlaceholder),!n.cssRules[e])return e;n.deleteRule(e);try{n.insertRule(t,e)}catch(r){o||console.warn("StyleSheet: illegal rule: \n\n"+t+"\n\nSee https://stackoverflow.com/q/20007992 for more info"),n.insertRule(this._deletedRulePlaceholder,e)}}else{var r=this._tags[e];u(r,"old rule at index `"+e+"` not found"),r.textContent=t}return e},t.deleteRule=function(e){if(this._optimizeForSpeed)this.replaceRule(e,"");else{var t=this._tags[e];u(t,"rule at index `"+e+"` not found"),t.parentNode.removeChild(t),this._tags[e]=null}},t.flush=function(){this._injected=!1,this._rulesCount=0,this._tags.forEac
15h(function(e){return e&&e.parentNode.removeChild(e)}),this._tags=[]},t.cssRules=function(){var e=this;return this._tags.reduce(function(t,n){return n?t=t.concat(Array.prototype.map.call(e.getSheetForTag(n).cssRules,function(t){return t.cssText===e._deletedRulePlaceholder?null:t})):t.push(null),t},[])},t.makeStyleTag=function(e,t,n){t&&u(a(t),"makeStyleTag accepts only strings as second parameter");var r=document.createElement("style");this._nonce&&r.setAttribute("nonce",this._nonce),r.type="text/css",r.setAttribute("data-"+e,""),t&&r.appendChild(document.createTextNode(t));var i=document.head||document.getElementsByTagName("head")[0];return n?i.insertBefore(r,n):i.appendChild(r),r},function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(e.prototype,[{key:"length",get:function(){return this._rulesCount}}]),e}();function u(e,t){if(!e)throw Error("StyleSheet: "+t+".")}var c=function(e){for(var t=5381,n=e.length;n;)t=33*t^e.charCodeAt(--n);return t>>>0},h={};function d(e,t){if(!t)return"jsx-"+e;var n=String(t),r=e+n;return h[r]||(h[r]="jsx-"+c(e+"-"+n)),h[r]}function f(e,t){var n=e+t;return h[n]||(h[n]=t.replace(/__jsx-style-dynamic-selector/g,e)),h[n]}var p=function(){function e(e){var t=void 0===e?{}:e,n=t.styleSheet,r=void 0===n?null:n,i=t.optimizeForSpeed,s=void 0!==i&&i;this._sheet=r||new l({name:"styled-jsx",optimizeForSpeed:s}),this._sheet.inject(),r&&"boolean"==typeof s&&(this._sheet.setOptimizeForSpeed(s),this._optimizeForSpeed=this._sheet.isOptimizeForSpeed()),this._fromServer=void 0,this._indices={},this._instancesCounts={}}var t=e.prototype;return t.add=function(e){var t=this;void 0===this._optimizeForSpeed&&(this._optimizeForSpeed=Array.isArray(e.children),this._sheet.setOptimizeForSpeed(this._optimizeForSpeed),this._optimizeForSpeed=this._sheet.isOptimizeForSpeed()),this._fromServer||(this._fromServer=this.selectFromServer(),this._instancesCounts=Object.keys(this._fromServer).reduce(function(e,t){return e[t]=0,e},{}));var n=this.getIdAndRules(e),r=n.styleId,i=n.rules;if(r in this._instancesCounts){this._instancesCounts[r]+=1;return}var s=i.map(function(e){return t._sheet.insertRule(e)}).filter(function(e){return -1!==e});this._indices[r]=s,this._instancesCounts[r]=1},t.remove=function(e){var t=this,n=this.getIdAndRules(e).styleId;if(function(e,t){if(!e)throw Error("StyleSheetRegistry: "+t+".")}(n in this._instancesCounts,"styleId: `"+n+"` not found"),this._instancesCounts[n]-=1,this._instancesCounts[n]<1){var r=this._fromServer&&this._fromServer[n];r?(r.parentNode.removeChild(r),delete this._fromServer[n]):(this._indices[n].forEach(function(e){return t._sheet.deleteRule(e)}),delete this._indices[n]),delete this._instancesCounts[n]}},t.update=function(e,t){this.add(t),this.remove(e)},t.flush=function(){this._sheet.flush(),this._sheet.inject(),this._fromServer=void 0,this._indices={},this._instancesCounts={}},t.cssRules=function(){var e=this,t=this._fromServer?Object.keys(this._fromServer).map(function(t){return[t,e._fromServer[t]]}):[],n=this._sheet.cssRules();return t.concat(Object.keys(this._indices).map(function(t){return[t,e._indices[t].map(function(e){return n[e].cssText}).join(e._optimizeForSpeed?"":"\n")]}).filter(function(e){return!!e[1]}))},t.styles=function(e){var t,n;return t=this.cssRules(),void 0===(n=e)&&(n={}),t.map(function(e){var t=e[0],r=e[1];return s.default.createElement("style",{id:"__"+t,key:"__"+t,nonce:n.nonce?n.nonce:void 0,dangerouslySetInnerHTML:{__html:r}})})},t.getIdAndRules=function(e){var t=e.children,n=e.dynamic,r=e.id;if(n){var i=d(r,n);return{styleId:i,rules:Array.isArray(t)?t.map(function(e){return f(i,e)}):[f(i,t)]}}return{styleId:d(r),rules:Array.isArray(t)?t:[t]}},t.selectFromServer=function(){return Array.prototype.slice.call(document.querySelectorAll('[id^="__jsx-"]')).reduce(function(e,t){return e[t.id.slice(2)]=t,e},{})},e}(),m=i.createContext(null);m.displayName="StyleSheetContext";var g=s.default.useInsertionEffect||s.default.useLayoutEffect,y=new p;function v(e){var t=y||i.useContext(m);return t&&g(function(){return t.add(e),function(){t.remove(e)}},[e.id,String(e.dynamic)]),null}v.dynamic=function(e){return e.map(function(e){return d(e[0],e[1])}).join(" ")},t.style=v},645:function(e,t,n){"use strict";e.exports=n(7443).style},7166:function(e,t,n){"use strict";var r=n(5893),i=n(7294);class s extends i.Component{static getDerivedStateFromError(e){return{hasError:!0,error:e,errorInfo:null}}componentDidCatch(e,t){console.error("ErrorBoundary caught an error:",e,t);try{console.error("Error details:",{message:e.message,stack:e.stack,componentStack:t.componentStack,userAgent:navigator.userAgent})}catch(e){console.error("Failed to log error:",e)}this.setState({error:e,errorInfo:t})}render(){return this.state.hasError?this.props.fallback?this.props.fallback:(0,r.jsx)("div",{className:"min-h-screen bg-gray-900 flex items-center justify-center p-4",children:(0,r.jsxs)("div",{className:"max-w-md w-full bg-gray-800 rounded-lg shadow-xl p-6 space-y-4",children:[(0,r.jsx)("div",{className:"flex items-center justify-center w-16 h-16 bg-red-500/20 rounded-full mx-auto",children:(0,r.jsx)("svg",{className:"w-8 h-8 text-red-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsx)("h1",{className:"text-2xl font-bold text-white mb-2",children:"Oops! Something went wrong"}),(0,r.jsx)("p",{className:"text-gray-400 text-sm mb-4",children:"We encountered an unexpected error. This has been logged and we'll look into it."})]}),!1,(0,r.jsxs)("div",{className:"flex flex-col sm:flex-row gap-3",children:[(0,r.jsx)("button",{onClick:this.handleReload,className:"flex-1 bg-blue-600 hover:bg-blue-700 text-white font-medium py-2 px-4 roun
15ded-lg transition-colors",children:"Reload Page"}),(0,r.jsx)("button",{onClick:this.handleGoHome,className:"flex-1 bg-gray-700 hover:bg-gray-600 text-white font-medium py-2 px-4 rounded-lg transition-colors",children:"Go to Home"})]}),(0,r.jsx)("p",{className:"text-xs text-gray-500 text-center mt-4",children:"If this problem persists, please try clearing your browser cache or contact support."})]})}):this.props.children}constructor(...e){super(...e),this.state={hasError:!1,error:null,errorInfo:null},this.handleReload=()=>{window.location.reload()},this.handleGoHome=()=>{window.location.href="/"}}}t.Z=s},2515:function(e,t,n){"use strict";n.d(t,{L_:function(){return l},aC:function(){return i},dl:function(){return r},r_:function(){return o},tR:function(){return a}});let r={appNotifications:!0,followerAlerts:!0,creatorActivity:!0,reviewLikes:!0,reviewComments:!0,commentReplies:!0,commentReactions:!0,discussionComments:!0,discussionVotes:!0,playlistCollaboratorInvites:!0,playlistCollaboratorActivity:!0,playlistSubscriberUpdates:!0,streamingAlerts:!0,actorAlerts:!0},i=[{title:"Social",description:"Followers, creators you follow, and community updates",items:[{key:"appNotifications",label:"App Notifications",helper:"Enable or disable all in-app notifications"},{key:"followerAlerts",label:"New Followers",helper:"Be notified when someone new follows you"},{key:"creatorActivity",label:"Creators You Follow",helper:"When people you follow publish new playlists, reviews, or discussions"}]},{title:"Reviews & Comments",description:"Control interactions on your reviews and comments",items:[{key:"reviewLikes",label:"Review Likes",helper:"Likes on any review you shared"},{key:"reviewComments",label:"Review Comments",helper:"New comments directly on your reviews"},{key:"commentReplies",label:"Replies To Your Comments",helper:"Someone responds to a comment you left"},{key:"commentReactions",label:"Comment Reactions",helper:"Likes or dislikes on comments you made"}]},{title:"Discussions",description:"Stay informed about conversations you started",items:[{key:"discussionComments",label:"Discussion Comments",helper:"New comments on discussions you opened"},{key:"discussionVotes",label:"Discussion Likes",helper:"When someone upvotes your discussion"}]},{title:"Playlists",description:"Collaboration invites and playlist updates",items:[{key:"playlistCollaboratorInvites",label:"Collaboration Invites",helper:"When someone adds you to collaborate on a playlist"},{key:"playlistCollaboratorActivity",label:"Collaboration Updates",helper:"A collaborator adds new titles to your playlist"},{key:"playlistSubscriberUpdates",label:"Saved Playlist Updates",helper:"Playlists you subscribed to get a new movie"}]},{title:"Alerts",description:"Watchlist bells, streaming availability, and actor alerts",items:[{key:"streamingAlerts",label:"Streaming Availability",helper:"Content you follow becomes available to stream"},{key:"actorAlerts",label:"Actor Alerts",helper:"Actors you track join a new release"}]}],s={follow:"followerAlerts",like:"reviewLikes",review_comment:"reviewComments",comment_reply:"commentReplies",comment_reaction:"commentReactions",discussion_comment:"discussionComments",discussion_vote:"discussionVotes",playlist_collaboration:"playlistCollaboratorInvites",playlist_update:"playlistCollaboratorActivity",playlist_new_movie:"playlistSubscriberUpdates",streaming_available:"streamingAlerts",actor_new_movie:"actorAlerts",creator_review:"creatorActivity",creator_playlist:"creatorActivity",creator_discussion:"creatorActivity",review:"creatorActivity",comment:"playlistCollaboratorActivity"};function o(e){return e?{...r,...e,appNotifications:"boolean"==typeof e.appNotifications?e.appNotifications:r.appNotifications}:{...r}}function a(e){var t;return null!==(t=s[e])&&void 0!==t?t:null}function l(e,t){return!!e.appNotifications&&!!e[t]}},6247:function(e,t,n){"use strict";n.d(t,{Vf:function(){return i},WJ:function(){return s},mf:function(){return r}});let r=864e5,i=14,s=12096e5},588:function(e,t,n){"use strict";n.d(t,{H:function(){return b},a:function(){return w}});var r=n(5893),i=n(7294),s=n(4830),o=n(109),a=n(5626),l=n(6247),u=n(251
155),c=n(425);let h=n(3454).env.NEXT_PUBLIC_RECAPTCHA_SITE_KEY;async function d(e){var t;if(!h)return null;let n=null===(t=window.grecaptcha)||void 0===t?void 0:t.enterprise;if(!n)return console.warn("reCAPTCHA Enterprise is not available yet."),null;await new Promise(e=>{try{n.ready(()=>e())}catch(t){console.error("reCAPTCHA ready() failed",t),e()}});try{return await n.execute(h,{action:e})}catch(e){return console.error("reCAPTCHA execute failed",e),null}}var f=n(3454);let p=e=>{let t={...e};return Object.keys(t).forEach(e=>{void 0===t[e]&&delete t[e]}),t},m="pendingDisplayName",g=e=>{try{window.sessionStorage.setItem(m,e)}catch(e){}},y=()=>{try{let e=window.sessionStorage.getItem(m);if(e)return window.sessionStorage.removeItem(m),e}catch(e){}return null},v=(0,i.createContext)(void 0);function w(){let e=(0,i.useContext)(v);if(void 0===e)throw Error("useAuth must be used within an AuthProvider");return e}function b(e){let{children:t}=e,[h,m]=(0,i.useState)(null),[w,b]=(0,i.useState)(null),[_,I]=(0,i.useState)(!0),E=!!f.env.NEXT_PUBLIC_RECAPTCHA_SITE_KEY,T=["localhost","127.0.0.1","::1"].includes(window.location.hostname),S=async e=>{if(!E||T)return;let t=await d(e);if(!t)throw Error("Unable to verify you are human. Please refresh and try again.");let n=await fetch("/api/security/recaptcha/verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:t,action:e})});if(!(await n.json()).success)throw Error("Verification failed. Please try again.")},C=e=>{if(!e)return"free";let t=e.planInfo||void 0;if((0,c.be)(e).active)return"pro";if((null==t?void 0:t.tier)==="pro"){var n;let e=(0,c.eq)(null!==(n=t.currentPeriodEnd)&&void 0!==n?n:null);return e&&Date.now()<e?"pro":"free"}return t?"free":"pro"===e.plan?"pro":"free"};(0,i.useEffect)(()=>{console.log("\uD83D\uDD25 AuthProvider: Setting up onAuthStateChanged");let e=setTimeout(()=>{console.warn("â ï¸ AuthProvider: Auth initialization timeout (10s), forcing loading=false"),I(!1)},1e4);try{let t=null,r=(0,s.Aj)(a.I8,async r=>{if(console.log("\uD83D\uDD25 AuthProvider: onAuthStateChanged fired",{hasUser:!!r}),clearTimeout(e),b(r),t){try{t()}catch(e){}t=null}if(r){let e=(0,o.doc)(a.db,"users",r.uid),i=await (0,o.getDoc)(e);if(i.exists()){let r=i.data();r.savedPlaylists||(r.savedPlaylists=[],await (0,o.setDoc)(e,p(r)));let s=i.exists()?i.data():null;m(s);let a=C(s);"pro"===a&&(t=(await Promise.resolve().then(n.bind(n,109))).onSnapshot(e,e=>{e.exists()?m(e.data()):m(null)}))}else{let i=(y()||r.displayName||"Anonymous").trim(),s=new Date,a=new Date(s.getTime()+l.WJ),c={uid:r.uid,displayName:i,email:r.email||"",bio:"",createdAt:s,followers:[],following:[],savedPlaylists:[],plan:"pro",planInfo:{tier:"pro",status:"trial",trialEndsAt:a,currentPeriodEnd:null,provider:null,hasUsedTrial:!0},socials:{facebook:"",instagram:"",telegram:"",x:"",twitter:"",tiktok:"",youtube:""},preferences:{preferredGenres:[],notificationSettings:{...u.dl},privacy:{profileVisibility:"public",showActivity:!0,showPlaylists:!0}}};r.photoURL&&(c.photoURL=r.photoURL);let h=p({...c,displayNameLower:i.toLowerCase()});await (0,o.setDoc)(e,h),t=(await Promise.resolve().then(n.bind(n,109))).onSnapshot(e,e=>{e.exists()?m(e.data()):m(null)})}}else m(null);I(!1)});return()=>{clearTimeout(e);try{r()}catch(e){}if(t)try{t()}catch(e){}}}catch(t){console.error("â AuthProvider: Error setting up auth listener",t),clearTimeout(e),I(!1)}},[]);let x=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"login";try{await S("login"===e?"GOOGLE_LOGIN":"GOOGLE_REGISTER");let t=new s.hJ;await (0,s.rh)(a.I8,t)}catch(e){throw console.error("Error signing in with Google:",e),e}},k=async(e,t)=>{try{await S("LOGIN"),await (0,s.e5)(a.I8,e,t)}catch(e){switch(console.error("Error signing in with email:",e),e.code){case"auth/user-not-found":throw Error("No account found with this email address.");case"auth/wrong-password":throw Error("Incorrect password. Please try again.");case"auth/invalid-email":throw Error("Please enter a valid email address.");case"auth/user-disabled":throw Error("This account has been disabled. Contact support.");case"auth/too-many-requests":throw Error("Too many failed attempts. Please try again later.");
15case"auth/operation-not-allowed":throw Error("Email/password sign-in is currently disabled. Please use Google sign-in or contact support.");default:throw Error("Login failed. Please check your credentials.")}}},A=async(e,t,n)=>{try{await S("REGISTER");let r=n.trim();r&&g(r);let{user:i}=await (0,s.Xb)(a.I8,e,t);await (0,s.ck)(i,{displayName:r})}catch(e){switch(console.error("Error creating account:",e),e.code){case"auth/email-already-in-use":throw Error("An account with this email already exists.");case"auth/invalid-email":throw Error("Please enter a valid email address.");case"auth/weak-password":throw Error("Password should be at least 6 characters long.");case"auth/operation-not-allowed":throw Error("Email/password registration is currently disabled. Please use Google sign-in or contact support.");default:throw Error("Account creation failed. Please try again.")}}},R=async e=>{try{await S("RESET_PASSWORD");let t=window.location.origin;await (0,s.LS)(a.I8,e,{url:"".concat(t,"/reset-password"),handleCodeInApp:!0})}catch(e){switch(console.error("Error sending password reset email:",e),e.code){case"auth/user-not-found":throw Error("No account found with this email address.");case"auth/invalid-email":throw Error("Please enter a valid email address.");case"auth/too-many-requests":throw Error("Too many attempts. Please try again later.");default:throw Error("Could not send reset email. Please try again.")}}},N=async()=>{try{await (0,s.w7)(a.I8)}catch(e){throw console.error("Error signing out:",e),e}},O=async e=>{if(!h)throw Error("No user logged in");try{let t={...h,...e},n=p({...t,displayNameLower:t.displayName.toLowerCase()});await (0,o.setDoc)((0,o.doc)(a.db,"users",h.uid),n),m(t)}catch(e){throw console.error("Error updating user profile:",e),e}},D=C(h);return(0,r.jsx)(v.Provider,{value:{user:h,firebaseUser:w,loading:_,signInWithGoogle:x,signInWithEmail:k,signUpWithEmail:A,resetPassword:R,signOut:N,updateUserProfile:O,effectivePlan:D,features:{taste:"pro"===D,forYou:"pro"===D,forMe:"pro"===D,predictionBadges:"pro"===D,sharedPicks:"pro"===D}},children:t})}},3700:function(e,t,n){"use strict";n.d(t,{f:function(){return u},q:function(){return l}});var r=n(5893),i=n(7294),s=n(5152);let o=n.n(s)()(()=>n.e(3116).then(n.bind(n,3116)).then(e=>e.AuthModalManager),{loadableGenerated:{webpack:()=>[3116]},ssr:!1}),a=(0,i.createContext)(void 0);function l(e){let{children:t}=e,[n,s]=(0,i.useState)({isOpen:!1,mode:"login"}),l=(0,i.useCallback)(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"login";s({isOpen:!0,mode:e})},[]),u=(0,i.useCallback)(()=>{s(e=>({...e,isOpen:!1}))},[]);return(0,r.jsxs)(a.Provider,{value:{openAuthModal:l,closeAuthModal:u},children:[t,(0,r.jsx)(o,{isOpen:n.isOpen,onClose:u,initialMode:n.mode})]})}function u(){let e=(0,i.useContext)(a);if(void 0===e)throw Error("useAuthModal must be used within an AuthModalProvider");return e}},8758:function(e,t,n){"use strict";n.d(t,{M:function(){return l},p:function(){return u}});var r=n(5893),i=n(7294),s=n(5152);let o=n.n(s)()(()=>n.e(4894).then(n.bind(n,4894)).then(e=>e.ConfirmationModal),{loadableGenerated:{webpack:()=>[4894]},ssr:!1}),a=(0,i.createContext)(void 0);function l(e){let{children:t}=e,[n,s]=(0,i.useState)(!1),[l,u]=(0,i.useState)(!1),[c,h]=(0,i.useState)({title:"",message:""}),[d,f]=(0,i.useState)(null),p=(0,i.useCallback)(e=>(h(e),s(!0),u(!1),new Promise(e=>{f(()=>e)})),[]),m=(0,i.useCallback)(async()=>{u(!0);try{c.onConfirm&&await c.onConfirm(),d&&(d(!0),f(null))}catch(e){console.error("Confirmation action failed:",e),d&&(d(!1),f(null))}finally{s(!1),u(!1)}},[d,c.onConfirm]),g=(0,i.useCallback)(()=>{d&&(d(!1),f(null)),s(!1),u(!1)},[d]);return(0,r.jsxs)(a.Provider,{value:{showConfirmation:p},children:[t,(0,r.jsx)(o,{isOpen:n,onClose:g,onConfirm:m,title:c.title,message:c.message,confirmText:c.confirmText,cancelText:c.cancelText,type:c.type,isLoading:l})]})}function u(){let e=(0,i.useContext)(a);if(void 0===e)throw Error("useConfirmation must be used within a ConfirmationProvider");return e}},437:function(e,t,n){"use strict";n.d(t,{c:function(){return i}});var r=n(7294);function i(){let[e,t]=(0,r.useState)(1);return(0,r.useEffect)(()=>
15{if("undefined"!=typeof document)try{let n=localStorage.getItem("uiScale");if(n){let e=parseFloat(n),r=!isNaN(e)&&e>0?e:1;t(r),document.documentElement.style.fontSize="".concat(16*r,"px");return}let r=window.innerWidth>=1024,i=1;if(r){var e;let t=window.innerWidth,n=Math.max(.5,Math.min(3,window.devicePixelRatio||1)),r=window.outerWidth&&(null===(e=window.screen)||void 0===e?void 0:e.width)?window.outerWidth/window.screen.width:1;i=t<=1366?.85:t<=1440?.875:t<1600?.92:1,n>=1.5?i-=.03:n<=.9&&(i+=.03),r>1.2?i-=.03:r<.9&&(i+=.03),i=Math.max(.85,Math.min(1.05,parseFloat(i.toFixed(2))))}t(i),localStorage.setItem("uiScale",i.toString()),document.documentElement.style.fontSize="".concat(16*i,"px")}catch(e){document.documentElement.style.fontSize="16px",t(1)}},[]),{scale:e,setScale:e=>{let n=Math.max(.85,Math.min(1.25,e));t(n);try{localStorage.setItem("uiScale",n.toString())}catch(e){}document.documentElement.style.fontSize="".concat(16*n,"px")}}}},5626:function(e,t,n){"use strict";let r,i,s,o,a;n.d(t,{I8:function(){return ta},db:function(){return a},LP:function(){return tr},Gb:function(){return tn},Fw:function(){return tu},ps:function(){return ti},tO:function(){return tl}});var l,u,c,h,d=n(2238);(0,d.KN)("firebase","11.9.1","app");var f=n(4830),p=n(109),m=n(6650),g=n(3333),y=n(1683),v=n(8463),w=n(6531);let b="@firebase/installations",_="0.6.17",I=`w:${_}`,E="FIS_v2",T=new y.LL("installations","Installations",{"missing-app-config-values":'Missing App configuration value: "{$valueName}"',"not-registered":"Firebase Installation is not registered.","installation-not-found":"Firebase Installation not found.","request-failed":'{$requestName} request failed with error "{$serverCode} {$serverStatus}: {$serverMessage}"',"app-offline":"Could not process request. Application offline.","delete-pending-registration":"Can't delete installation while there is a pending registration request."});function S(e){return e instanceof y.ZR&&e.code.includes("request-failed")}function C({projectId:e}){return`https://firebaseinstallations.googleapis.com/v1/projects/${e}/installations`}function x(e){return{token:e.token,requestStatus:2,expiresIn:Number(e.expiresIn.replace("s","000")),creationTime:Date.now()}}async function k(e,t){let n=(await t.json()).error;return T.create("request-failed",{requestName:e,serverCode:n.code,serverMessage:n.message,serverStatus:n.status})}function A({apiKey:e}){return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":e})}async function R(e){let t=await e();return t.status>=500&&t.status<600?e():t}async function N({appConfig:e,heartbeatServiceProvider:t},{fid:n}){let r=C(e),i=A(e),s=t.getImmediate({optional:!0});if(s){let e=await s.getHeartbeatsHeader();e&&i.append("x-firebase-client",e)}let o={method:"POST",headers:i,body:JSON.stringify({fid:n,authVersion:E,appId:e.appId,sdkVersion:I})},a=await R(()=>fetch(r,o));if(a.ok){let e=await a.json();return{fid:e.fid||n,registrationStatus:2,refreshToken:e.refreshToken,authToken:x(e.authToken)}}throw await k("Create Installation",a)}function O(e){return new Promise(t=>{setTimeout(t,e)})}let D=/^[cdef][\w-]{21}$/;function P(e){return`${e.appName}!${e.appId}`}let L=new Map;function M(e,t){let n=P(e);F(n,t),function(e,t){let n=(!U&&"BroadcastChannel"in self&&((U=new BroadcastChannel("[Firebase] FID Change")).onmessage=e=>{F(e.data.key,e.data.fid)}),U);n&&n.postMessage({key:e,fid:t}),0===L.size&&U&&(U.close(),U=null)}(n,t)}function F(e,t){let n=L.get(e);if(n)for(let e of n)e(t)}let U=null,V="firebase-installations-store",j=null;function B(){return j||(j=(0,w.X3)("firebase-installations-database",1,{upgrade:(e,t)=>{0===t&&e.createObjectStore(V)}})),j}async function q(e,t){let n=P(e),r=(await B()).transaction(V,"readwrite"),i=r.objectStore(V),s=await i.get(n);return await i.put(t,n),await r.done,s&&s.fid===t.fid||M(e,t.fid),t}async function z(e){let t=P(e),n=(await B()).transaction(V,"readwrite");await n.objectStore(V).delete(t),await n.done}async function $(e,t){let n=P(e),r=(await B()).transaction(V,"readwrite"),i=r.objectStore(V),s=await i.get(n),o=t(s);return void 0===o?await i.delete(n):await i.put(o,n),await r.done,o&&(!s||s.fid!==o.fid)&&M(e,o.fid),o}async function K(e){let t;let n=await $(e.appConfig,n=>{let r=function(e,t){if(0===t.registrationStatus){if(!navigator.onLine)return{installationEntry:t,registrationPromise:Promise.reject(T.create("app-offline"))};let n={fid:t.fid,registrationStatus:1,registrationTime:Date.now()},r=G(e,n);return{installationEntry:n,registrationPromise:r}}return 1===t.registrationStatus?{installationEntry:t,registrationPromise:H(e)}:{installationEntry:t}}(e,Q(n||{fid:function(){try{let e=new Uint8Array(17);(self.crypto||self.msCrypto).getRandomValues(e),e[0]=112+e[0]%16;let t=btoa(String.fromCharCode(...e)).replace(/\+/g,"-").replace(/\//g,"_").substr(0,22);return D.test(t)?t:""}catch(e){return""}}(),registrationStatus:0}));return t=r.registrationPromise,r.installationEntry});return""===n.fid?{installationEntry:await t}:{installationEntry:n,registrationPromise:t}}async function G(e,t){try{let n=await N(e,t);return q(e.appConfig,n)}catch(n){throw S(n)&&409===n.customData.serverCode?await z(e.appConfig):await q(e.appConfig,{fid:t.fid,registrationStatus:0}),n}}async function H(e){let t=await W(e.appConfig);for(;1===t.registrationStatus;)await O(100),t=await W(e.appConfig);if(0===t.registrationStatus){let{installationEntry:t,registrationPromise:n}=await K(e);return n||t}return t}function W(e){return $(e,e=>
15{if(!e)throw T.create("installation-not-found");return Q(e)})}function Q(e){return 1===e.registrationStatus&&e.registrationTime+1e4<Date.now()?{fid:e.fid,registrationStatus:0}:e}async function X({appConfig:e,heartbeatServiceProvider:t},n){let r=function(e,{fid:t}){return`${C(e)}/${t}/authTokens:generate`}(e,n),i=function(e,{refreshToken:t}){let n=A(e);return n.append("Authorization",`${E} ${t}`),n}(e,n),s=t.getImmediate({optional:!0});if(s){let e=await s.getHeartbeatsHeader();e&&i.append("x-firebase-client",e)}let o={method:"POST",headers:i,body:JSON.stringify({installation:{sdkVersion:I,appId:e.appId}})},a=await R(()=>fetch(r,o));if(a.ok)return x(await a.json());throw await k("Generate Auth Token",a)}async function Y(e,t=!1){let n;let r=await $(e.appConfig,r=>{var i;if(!et(r))throw T.create("not-registered");let s=r.authToken;if(!t&&2===(i=s).requestStatus&&!function(e){let t=Date.now();return t<e.creationTime||e.creationTime+e.expiresIn<t+36e5}(i))return r;if(1===s.requestStatus)return n=J(e,t),r;{if(!navigator.onLine)throw T.create("app-offline");let t=function(e){let t={requestStatus:1,requestTime:Date.now()};return Object.assign(Object.assign({},e),{authToken:t})}(r);return n=ee(e,t),t}});return n?await n:r.authToken}async function J(e,t){let n=await Z(e.appConfig);for(;1===n.authToken.requestStatus;)await O(100),n=await Z(e.appConfig);let r=n.authToken;return 0===r.requestStatus?Y(e,t):r}function Z(e){return $(e,e=>{var t;if(!et(e))throw T.create("not-registered");return 1===(t=e.authToken).requestStatus&&t.requestTime+1e4<Date.now()?Object.assign(Object.assign({},e),{authToken:{requestStatus:0}}):e})}async function ee(e,t){try{let n=await X(e,t),r=Object.assign(Object.assign({},t),{authToken:n});return await q(e.appConfig,r),n}catch(n){if(S(n)&&(401===n.customData.serverCode||404===n.customData.serverCode))await z(e.appConfig);else{let n=Object.assign(Object.assign({},t),{authToken:{requestStatus:0}});await q(e.appConfig,n)}throw n}}function et(e){return void 0!==e&&2===e.registrationStatus}async function en(e){let{installationEntry:t,registrationPromise:n}=await K(e);return n?n.catch(console.error):Y(e).catch(console.error),t.fid}async function er(e,t=!1){return await ei(e),(await Y(e,t)).token}async function ei(e){let{registrationPromise:t}=await K(e);t&&await t}function es(e){return T.create("missing-app-config-values",{valueName:e})}let eo="installations";(0,d.Xd)(new v.wA(eo,e=>{let t=e.getProvider("app").getImmediate(),n=function(e){if(!e||!e.options)throw es("App Configuration");if(!e.name)throw es("App Name");for(let t of["projectId","apiKey","appId"])if(!e.options[t])throw es(t);return{appName:e.name,projectId:e.options.projectId,apiKey:e.options.apiKey,appId:e.options.appId}}(t),r=(0,d.qX)(t,"heartbeat");return{app:t,appConfig:n,heartbeatServiceProvider:r,_delete:()=>Promise.resolve()}},"PUBLIC")),(0,d.Xd)(new v.wA("installations-internal",e=>{let t=e.getProvider("app").getImmediate(),n=(0,d.qX)(t,eo).getImmediate();return{getId:()=>en(n),getToken:e=>er(n,e)}},"PRIVATE")),(0,d.KN)(b,_),(0,d.KN)(b,_,"esm2017");let ea="analytics",el="https://www.googletagmanager.com/gtag/js",eu=new g.Yd("@firebase/analytics"),ec=new y.LL("analytics","Analytics",{"already-exists":"A Firebase Analytics instance with the appId {$id} already exists. Only one Firebase Analytics instance can be created for each appId.","already-initialized":"initializeAnalytics() cannot be called again with different options than those it was initially called with. It can be called again with the same options to return the existing instance, or getAnalytics() can be used to get a reference to the already-initialized instance.","already-initialized-settings":"Firebase Analytics has already been initialized.settings() must be called before initializing any Analytics instanceor it will have no effect.","interop-component-reg-failed":"Firebase Analytics Interop Component failed to instantiate: {$reason}","invalid-analytics-context":"Firebase Analytics is not supported in this environment. Wrap initialization of analytics in analytics.isSupported() to prevent initialization in unsupported environments. Details: {$errorInfo}","indexeddb-unavailable":"IndexedDB unavailable or restricted in this environment. Wrap initialization of analytics in analytics.isSupported() to prevent initialization in unsupported environments. Details: {$errorInfo}","fetch-throttle":"The config fetch request timed out while in an exponential backoff state. Unix timestamp in milliseconds when fetch request throttling ends: {$throttleEndTimeMillis}.","config-fetch-failed":"Dynamic config fetch failed: [{$httpStatus}] {$responseMessage}","no-api-key":'The "apiKey" field is empty in the local Firebase config. Firebase Analytics requires this field tocontain a valid API key.',"no-app-id":'The "appId" field is empty in the local Firebase config. Firebase Analytics requires this field tocontain a valid app ID.',"no-client-id":'The "client_id" field is empty.',"invali
15d-gtag-resource":"Trusted Types detected an invalid gtag resource: {$gtagURL}."});function eh(e){if(!e.startsWith(el)){let t=ec.create("invalid-gtag-resource",{gtagURL:e});return eu.warn(t.message),""}return e}function ed(e){return Promise.all(e.map(e=>e.catch(e=>e)))}async function ef(e,t,n,r,i,s){let o=r[i];try{if(o)await t[o];else{let e=(await ed(n)).find(e=>e.measurementId===i);e&&await t[e.appId]}}catch(e){eu.error(e)}e("config",i,s)}async function ep(e,t,n,r,i){try{let s=[];if(i&&i.send_to){let e=i.send_to;Array.isArray(e)||(e=[e]);let r=await ed(n);for(let n of e){let e=r.find(e=>e.measurementId===n),i=e&&t[e.appId];if(i)s.push(i);else{s=[];break}}}0===s.length&&(s=Object.values(t)),await Promise.all(s),e("event",r,i||{})}catch(e){eu.error(e)}}class em{constructor(e={},t=1e3){this.throttleMetadata=e,this.intervalMillis=t}getThrottleMetadata(e){return this.throttleMetadata[e]}setThrottleMetadata(e,t){this.throttleMetadata[e]=t}deleteThrottleMetadata(e){delete this.throttleMetadata[e]}}let eg=new em;async function ey(e){var t;let{appId:n,apiKey:r}=e,i={method:"GET",headers:new Headers({Accept:"application/json","x-goog-api-key":r})},s="https://firebase.googleapis.com/v1alpha/projects/-/apps/{app-id}/webConfig".replace("{app-id}",n),o=await fetch(s,i);if(200!==o.status&&304!==o.status){let e="";try{let n=await o.json();(null===(t=n.error)||void 0===t?void 0:t.message)&&(e=n.error.message)}catch(e){}throw ec.create("config-fetch-failed",{httpStatus:o.status,responseMessage:e})}return o.json()}async function ev(e,t=eg,n){let{appId:r,apiKey:i,measurementId:s}=e.options;if(!r)throw ec.create("no-app-id");if(!i){if(s)return{measurementId:s,appId:r};throw ec.create("no-api-key")}let o=t.getThrottleMetadata(r)||{backoffCount:0,throttleEndTimeMillis:Date.now()},a=new eb;return setTimeout(async()=>{a.abort()},void 0!==n?n:6e4),ew({appId:r,apiKey:i,measurementId:s},o,a,t)}async function ew(e,{throttleEndTimeMillis:t,backoffCount:n},r,i=eg){var s;let{appId:o,measurementId:a}=e;try{await new Promise((e,n)=>{let i=setTimeout(e,Math.max(t-Date.now(),0));r.addEventListener(()=>{clearTimeout(i),n(ec.create("fetch-throttle",{throttleEndTimeMillis:t}))})})}catch(e){if(a)return eu.warn(`Timed out fetching this Firebase app's measurement ID from the server. Falling back to the measurement ID ${a} provided in the "measurementId" field in the local Firebase config. [${null==e?void 0:e.message}]`),{appId:o,measurementId:a};throw e}try{let t=await ey(e);return i.deleteThrottleMetadata(o),t}catch(u){if(!function(e){if(!(e instanceof y.ZR)||!e.customData)return!1;let t=Number(e.customData.httpStatus);return 429===t||500===t||503===t||504===t}(u)){if(i.deleteThrottleMetadata(o),a)return eu.warn(`Failed to fetch this Firebase app's measurement ID from the server. Falling back to the measurement ID ${a} provided in the "measurementId" field in the local Firebase config. [${null==u?void 0:u.message}]`),{appId:o,measurementId:a};throw u}let t=503===Number(null===(s=null==u?void 0:u.customData)||void 0===s?void 0:s.httpStatus)?(0,y.$s)(n,i.intervalMillis,30):(0,y.$s)(n,i.intervalMillis),l={throttleEndTimeMillis:Date.now()+t,backoffCount:n+1};return i.setThrottleMetadata(o,l),eu.debug(`Calling attemptFetch again in ${t} millis`),ew(e,l,r,i)}}class eb{constructor(){this.listeners=[]}addEventListener(e){this.listeners.push(e)}abort(){this.listeners.forEach(e=>e())}}async function e_(e,t,n,r,i){if(i&&i.global){e("event",n,r);return}{let i=await t;e("event",n,Object.assign(Object.assign({},r),{send_to:i}))}}async function eI(){if(!(0,y.hl)())return eu.warn(ec.create("indexeddb-unavailable",{errorInfo:"IndexedDB is not available in this environment."}).message),!1;try{await (0,y.eu)()}catch(e){return eu.warn(ec.create("indexeddb-unavailable",{errorInfo:null==e?void 0:e.toString()}).message),!1}return!0}async function eE(e,t,n,s,o,a,l){var u;let c=ev(e);c.then(t=>{n[t.measurementId]=t.appId,e.options.measurementId&&t.measurementId!==e.options.measurementId&&eu.warn(`The measurement ID in the local Firebase config (${e.options.measurementId}) does not match the measurement ID fetched from the server (${t.measurementId}). To ensure analytics events are always sent to the correct Analytics property, update the measurement ID field in the local config or remove it from the local config.`)}).catch(e=>eu.error(e)),t.push(c);let h=eI().then(e=>e?s.getId():void 0),[d,f]=await Promise.all([c,h]);!function(e){for(let t of Object.values(window.document.getElementsByTagName("script")))if(t.src&&t.src.includes(el)&&t.src.includes(e))return t;return null}(a)&&function(e,t){var n,r;let i;let s=(n="firebase-js-sdk-policy",r={createScriptURL:eh},window.trustedTypes&&(i=window.trustedTypes.createPolicy(n,r)),i),o=document.createElement("script"),a=`${el}?l=${e}
15&id=${t}`;o.src=s?null==s?void 0:s.createScriptURL(a):a,o.async=!0,document.head.appendChild(o)}(a,d.measurementId),i&&(o("consent","default",i),i=void 0),o("js",new Date);let p=null!==(u=null==l?void 0:l.config)&&void 0!==u?u:{};return p.origin="firebase",p.update=!0,null!=f&&(p.firebase_id=f),o("config",d.measurementId,p),r&&(o("set",r),r=void 0),d.measurementId}class eT{constructor(e){this.app=e}_delete(){return delete eS[this.app.options.appId],Promise.resolve()}}let eS={},eC=[],ex={},ek="dataLayer",eA=!1,eR="@firebase/analytics",eN="0.10.16";(0,d.Xd)(new v.wA(ea,(e,{options:t})=>(function(e,t,n){!function(){let e=[];if((0,y.ru)()&&e.push("This is a browser extension environment."),(0,y.zI)()||e.push("Cookies are not available."),e.length>0){let t=e.map((e,t)=>`(${t+1}) ${e}`).join(" "),n=ec.create("invalid-analytics-context",{errorInfo:t});eu.warn(n.message)}}();let r=e.options.appId;if(!r)throw ec.create("no-app-id");if(!e.options.apiKey){if(e.options.measurementId)eu.warn(`The "apiKey" field is empty in the local Firebase config. This is needed to fetch the latest measurement ID for this Firebase app. Falling back to the measurement ID ${e.options.measurementId} provided in the "measurementId" field in the local Firebase config.`);else throw ec.create("no-api-key")}if(null!=eS[r])throw ec.create("already-exists",{id:r});if(!eA){var i,a;let e,t;e=[],Array.isArray(window[ek])?e=window[ek]:window[ek]=e;let{wrappedGtag:n,gtagCore:r}=(i="gtag",t=function(...e){window[ek].push(arguments)},window[i]&&"function"==typeof window[i]&&(t=window[i]),window[i]=(a=t,async function(e,...t){try{if("event"===e){let[e,n]=t;await ep(a,eS,eC,e,n)}else if("config"===e){let[e,n]=t;await ef(a,eS,eC,ex,e,n)}else if("consent"===e){let[e,n]=t;a("consent",e,n)}else if("get"===e){let[e,n,r]=t;a("get",e,n,r)}else if("set"===e){let[e]=t;a("set",e)}else a(e,...t)}catch(e){eu.error(e)}}),{gtagCore:t,wrappedGtag:window[i]});o=n,s=r,eA=!0}return eS[r]=eE(e,eC,ex,t,s,ek,n),new eT(e)})(e.getProvider("app").getImmediate(),e.getProvider("installations-internal").getImmediate(),t),"PUBLIC")),(0,d.Xd)(new v.wA("analytics-internal",function(e){try{let t=e.getProvider(ea).getImmediate();return{logEvent:(e,n,r)=>{var i;return i=t,void(i=(0,y.m9)(i),e_(o,eS[i.app.options.appId],e,n,r).catch(e=>eu.error(e)))}}}catch(e){throw ec.create("interop-component-reg-failed",{reason:e})}},"PRIVATE")),(0,d.KN)(eR,eN),(0,d.KN)(eR,eN,"esm2017");let eO="BDOU99-h67HcA6JeFXHbSNMu7e2yNNu3RzoMj8TM4W88jITfq7ZmPvIM1Iv-4_l2LxQcYwhqby2xGpWwzjfAnG4",eD="google.c.a.c_id";function eP(e){return btoa(String.fromCharCode(...new Uint8Array(e))).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}(l=c||(c={}))[l.DATA_MESSAGE=1]="DATA_MESSAGE",l[l.DISPLAY_NOTIFICATION=3]="DISPLAY_NOTIFICATION",(u=h||(h={})).PUSH_RECEIVED="push-received",u.NOTIFICATION_CLICKED="notification-clicked";let eL="fcm_token_details_db",eM="fcm_token_object_Store";async function eF(e){if("databases"in indexedDB&&!(await indexedDB.databases()).map(e=>e.name).includes(eL))return null;let t=null;return(await (0,w.X3)(eL,5,{upgrade:async(n,r,i,s)=>{var o;if(r<2||!n.objectStoreNames.contains(eM))return;let a=s.objectStore(eM),l=await a.index("fcmSenderId").get(e);if(await a.clear(),l){if(2===r){if(!l.auth||!l.p256dh||!l.endpoint)return;t={token:l.fcmToken,createTime:null!==(o=l.createTime)&&void 0!==o?o:Date.now(),subscriptionOptions:{auth:l.auth,p256dh:l.p256dh,endpoint:l.endpoint,swScope:l.swScope,vapidKey:"string"==typeof l.vapidKey?l.vapidKey:eP(l.vapidKey)}}}else 3===r?t={token:l.fcmToken,createTime:l.createTime,subscriptionOptions:{auth:eP(l.auth),p256dh:eP(l.p256dh),endpoint:l.endpoint,swScope:l.swScope,vapidKey:eP(l.vapidKey)}}:4===r&&(t={token:l.fcmToken,createTime:l.createTime,subscriptionOptions:{auth:eP(l.auth),p256dh:eP(l.p256dh),endpoint:l.endpoint,swScope:l.swScope,vapidKey:eP(l.vapidKey)}})}}})).close(),await (0,w.Lj)(eL),await (0,w.Lj)("fcm_vapid_details_db"),await (0,w.Lj)("undefined"),!function(e){if(!e||!e.subscriptionOptions)return!1;let{subscriptionOptions:t}=e;return"number"==typeof e.createTime&&e.createTime>0&&"string"==typeof e.token&&e.token.length>0&&"string"==typeof t.auth&&t.auth.length>0&&"string"==typeof t.p256dh&&t.p256dh.length>0&&"string"==typeof t.endpoint&&t.endpoint.length>0&&"string"==typeof t.swScope&&t.swScope.length>0&&"string"==typeof t.vapidKey&&t.vapidKey.length>0}(t)?null:t}let eU="firebase-messaging-store",eV=null;function ej(){return eV||(eV=(0,w.X3)("firebase-messaging-database",1,{upgrade:(e,t)=>{0===t&&e.createObjectStore(eU)}})),eV}async function eB(e){let t=function({appConfig:e}){return e.appId}(e),n=await ej(),r=await n.transaction(eU).objectStore(eU).get(t);if(r)return r;{let t=await eF(e.appConfig.senderId);if(t)return await eq(e,t),t}}async function eq(e,t){let n=function({appConfig:e}){return e.appId}(e),r=(await ej()).transaction(eU,"readwrite");return await r.objectStore(eU).put(t,n),await r.done,t}let ez=new y.LL("messaging","Messaging",{"missing-app-config-values":'Missing App configuration value: "{$valueName}"',"only-available-in-window":"This method is available in a Window context.","only-available-in-sw":"This method is available in a service worker context.","permission-default":"The notification permission was not granted and dismissed instead.","permission-blocked":"The notification permission was not granted and blocked instead.","unsupported-browser":"This browser doesn't support the API's required to use the Firebase SDK.","indexed-db-unsupported":"This browser doesn't support indexedDb.open() (ex. Safari iFrame, Firefox Private Browsing, etc)","failed-service-worker-registration":"We are unable to register the default service worker. {$browserErrorMessage}","token-subscribe-failed":"A problem occurred while subscribing the user to FCM: {$errorInfo}","token-subscribe-no-token":"FCM returned no token when subscribing the user to push.","token-unsubscribe-failed":"A problem occurred while unsubscribing the user from FCM: {$errorInfo}","token-update-failed":"A problem occurred while updating the user from FCM: {$errorInfo}","token-update-no-token":"FCM returned no token when updating the user to push.","use-sw-after-get-token":"The useServiceWorker() method may only be called once and must be called before calling getToken() to ensure your service worker is used.","invali
15d-sw-registration":"The input to useServiceWorker() must be a ServiceWorkerRegistration.","invalid-bg-handler":"The input to setBackgroundMessageHandler() must be a function.","invalid-vapid-key":"The public VAPID key must be a string.","use-vapid-key-after-get-token":"The usePublicVapidKey() method may only be called once and must be called before calling getToken() to ensure your VAPID key is used."});async function e$(e,t){let n;let r={method:"POST",headers:await eW(e),body:JSON.stringify(eQ(t))};try{let t=await fetch(eH(e.appConfig),r);n=await t.json()}catch(e){throw ez.create("token-subscribe-failed",{errorInfo:null==e?void 0:e.toString()})}if(n.error){let e=n.error.message;throw ez.create("token-subscribe-failed",{errorInfo:e})}if(!n.token)throw ez.create("token-subscribe-no-token");return n.token}async function eK(e,t){let n;let r={method:"PATCH",headers:await eW(e),body:JSON.stringify(eQ(t.subscriptionOptions))};try{let i=await fetch(`${eH(e.appConfig)}/${t.token}`,r);n=await i.json()}catch(e){throw ez.create("token-update-failed",{errorInfo:null==e?void 0:e.toString()})}if(n.error){let e=n.error.message;throw ez.create("token-update-failed",{errorInfo:e})}if(!n.token)throw ez.create("token-update-no-token");return n.token}async function eG(e,t){let n=await eW(e);try{let r=await fetch(`${eH(e.appConfig)}/${t}`,{method:"DELETE",headers:n}),i=await r.json();if(i.error){let e=i.error.message;throw ez.create("token-unsubscribe-failed",{errorInfo:e})}}catch(e){throw ez.create("token-unsubscribe-failed",{errorInfo:null==e?void 0:e.toString()})}}function eH({projectId:e}){return`https://fcmregistrations.googleapis.com/v1/projects/${e}/registrations`}async function eW({appConfig:e,installations:t}){let n=await t.getToken();return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":e.apiKey,"x-goog-firebase-installations-auth":`FIS ${n}`})}function eQ({p256dh:e,auth:t,endpoint:n,vapidKey:r}){let i={web:{endpoint:n,auth:t,p256dh:e}};return r!==eO&&(i.web.applicationPubKey=r),i}async function eX(e){let t=await eZ(e.swRegistration,e.vapidKey),n={vapidKey:e.vapidKey,swScope:e.swRegistration.scope,endpoint:t.endpoint,auth:eP(t.getKey("auth")),p256dh:eP(t.getKey("p256dh"))},r=await eB(e.firebaseDependencies);if(!r)return eJ(e.firebaseDependencies,n);if(function(e,t){let n=t.vapidKey===e.vapidKey,r=t.endpoint===e.endpoint,i=t.auth===e.auth,s=t.p256dh===e.p256dh;return n&&r&&i&&s}(r.subscriptionOptions,n))return Date.now()>=r.createTime+6048e5?eY(e,{token:r.token,createTime:Date.now(),subscriptionOptions:n}):r.token;try{await eG(e.firebaseDependencies,r.token)}catch(e){console.warn(e)}return eJ(e.firebaseDependencies,n)}async function eY(e,t){try{let n=await eK(e.firebaseDependencies,t),r=Object.assign(Object.assign({},t),{token:n,createTime:Date.now()});return await eq(e.firebaseDependencies,r),n}catch(e){throw e}}async function eJ(e,t){let n={token:await e$(e,t),createTime:Date.now(),subscriptionOptions:t};return await eq(e,n),n.token}async function eZ(e,t){return await e.pushManager.getSubscription()||e.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:function(e){let t="=".repeat((4-e.length%4)%4),n=atob((e+t).replace(/\-/g,"+").replace(/_/g,"/")),r=new Uint8Array(n.length);for(let e=0;e<n.length;++e)r[e]=n.charCodeAt(e);return r}(t)})}function e0(e){let t={from:e.from,collapseKey:e.collapse_key,messageId:e.fcmMessageId};return function(e,t){if(!t.notification)return;e.notification={};let n=t.notification.title;n&&(e.notification.title=n);let r=t.notification.body;r&&(e.notification.body=r);let i=t.notification.image;i&&(e.notification.image=i);let s=t.notification.icon;s&&(e.notification.icon=s)}(t,e),e.data&&(t.data=e.data),function(e,t){var n,r,i,s,o;if(!t.fcmOptions&&!(null===(n=t.notification)||void 0===n?void 0:n.click_action))return;e.fcmOptions={};let a=null!==(i=null===(r=t.fcmOptions)||void 0===r?void 0:r.link)&&void 0!==i?i:null===(s=t.notification)||void 0===s?void 0:s.click_action;a&&(e.fcmOptions.link=a);let l=null===(o=t.fcmOptions)||void 0===o?void 0:o.analytics_label;l&&(e.fcmOptions.analyticsLabel=l)}(t,e),t}function e1(e){return ez.create("missing-app-config-values",{valueName:e})}!function(e,t){let n=[];for(let r=0;r<e.length;r++)n.push(e.charAt(r)),r<t.length&&n.push(t.charAt(r));n.join("")}("AzSCbw63g1R0nCw85jG8","Iaya3yLKwmgvh7cF0q4");class e2{constructor(e,t,n){this.deliveryMetricsExportedToBigQueryEnabled=!1,this.onBackgroun
15dMessageHandler=null,this.onMessageHandler=null,this.logEvents=[],this.isLogServiceStarted=!1;let r=function(e){if(!e||!e.options)throw e1("App Configuration Object");if(!e.name)throw e1("App Name");let{options:t}=e;for(let e of["projectId","apiKey","appId","messagingSenderId"])if(!t[e])throw e1(e);return{appName:e.name,projectId:t.projectId,apiKey:t.apiKey,appId:t.appId,senderId:t.messagingSenderId}}(e);this.firebaseDependencies={app:e,appConfig:r,installations:t,analyticsProvider:n}}_delete(){return Promise.resolve()}}async function e4(e){try{e.swRegistration=await navigator.serviceWorker.register("/firebase-messaging-sw.js",{scope:"/firebase-cloud-messaging-push-scope"}),e.swRegistration.update().catch(()=>{}),await e6(e.swRegistration)}catch(e){throw ez.create("failed-service-worker-registration",{browserErrorMessage:null==e?void 0:e.message})}}async function e6(e){return new Promise((t,n)=>{let r=setTimeout(()=>n(Error("Service worker not registered after 10000 ms")),1e4),i=e.installing||e.waiting;e.active?(clearTimeout(r),t()):i?i.onstatechange=e=>{var n;(null===(n=e.target)||void 0===n?void 0:n.state)==="activated"&&(i.onstatechange=null,clearTimeout(r),t())}:(clearTimeout(r),n(Error("No incoming service worker found.")))})}async function e5(e,t){if(t||e.swRegistration||await e4(e),t||!e.swRegistration){if(!(t instanceof ServiceWorkerRegistration))throw ez.create("invalid-sw-registration");e.swRegistration=t}}async function e9(e,t){t?e.vapidKey=t:e.vapidKey||(e.vapidKey=eO)}async function e3(e,t){if(!navigator)throw ez.create("only-available-in-window");if("default"===Notification.permission&&await Notification.requestPermission(),"granted"!==Notification.permission)throw ez.create("permission-blocked");return await e9(e,null==t?void 0:t.vapidKey),await e5(e,null==t?void 0:t.serviceWorkerRegistration),eX(e)}async function e8(e,t,n){let r=function(e){switch(e){case h.NOTIFICATION_CLICKED:return"notification_open";case h.PUSH_RECEIVED:return"notification_foreground";default:throw Error()}}(t);(await e.firebaseDependencies.analyticsProvider.get()).logEvent(r,{message_id:n[eD],message_name:n["google.c.a.c_l"],message_time:n["google.c.a.ts"],message_device_time:Math.floor(Date.now()/1e3)})}async function e7(e,t){let n=t.data;if(!n.isFirebaseMessaging)return;e.onMessageHandler&&n.messageType===h.PUSH_RECEIVED&&("function"==typeof e.onMessageHandler?e.onMessageHandler(e0(n)):e.onMessageHandler.next(e0(n)));let r=n.data;"object"==typeof r&&r&&eD in r&&"1"===r["google.c.a.e"]&&await e8(e,n.messageType,r)}let te="@firebase/messaging",tt="0.12.21";async function tn(){try{await (0,y.eu)()}catch(e){return!1}return"undefined"!=typeof window&&(0,y.hl)()&&(0,y.zI)()&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window&&"fetch"in window&&ServiceWorkerRegistration.prototype.hasOwnProperty("showNotification")&&PushSubscription.prototype.hasOwnProperty("getKey")}async function tr(e,t){return e3(e=(0,y.m9)(e),t)}function ti(e,t){return function(e,t){if(!navigator)throw ez.create("only-available-in-window");return e.onMessageHandler=t,()=>{e.onMessageHandler=null}}(e=(0,y.m9)(e),t)}(0,d.Xd)(new v.wA("messaging",e=>{let t=new e2(e.getProvider("app").getImmediate(),e.getProvider("installations-internal").getImmediate(),e.getProvider("analytics-internal"));return navigator.serviceWorker.addEventListener("message",e=>e7(t,e)),t},"PUBLIC")),(0,d.Xd)(new v.wA("messaging-internal",e=>{let t=e.getProvider("messaging").getImmediate();return{getToken:e=>e3(t,e)}},"PRIVATE")),(0,d.KN)(te,tt),(0,d.KN)(te,tt,"esm2017");let ts={apiKey:"AIzaSyDPL68XGvdvvlupjkyjBXypOUjwgXTeQUY",authDomain:"finest-bb0c3.firebaseapp.com",projectId:"finest-bb0c3",storageBucket:"finest-bb0c3.firebasestorage.app",messagingSenderId:"243821766126",appId:"1:243821766126:web:b69a437ef229fee239daff",measurementId:"G-X00ZYBV75D"};{let e=Object.entries(ts).filter(e=>{let[,t]=e;return!t}).map(e=>{let[t]=e;return t});e.length>0?console.error("\uD83D\uDD25â Firebase config missing keys:",e):console.log("\uD83D\uDD25â
Firebase config loaded")}let to=(0,d.C6)().length?(0,d.Mq)():(0,d.ZF)(ts),ta=(0,f.v0)(to);{let e=globalThis;e.__WHATCHLY_DB__||(e.__WHATCHLY_DB__=(0,p.initializeFirestore)(to,{localCache:(0,p.persistentLocalCache)({tabManager:(0,p.persistentMultipleTabManager)()})})),a=e.__WHATCHLY_DB__}let tl=(0,m.cF)(to);!function(e=(0,d.Mq)()){e=(0,y.m9)(e);let t=(0,d.qX)(e,ea);t.isInitialized()?t.getImmediate():function(e,t={}){let n=(0,d.qX)(e,ea);if(n.isInitialized()){let e=n.getImmediate();
15if((0,y.vZ)(t,n.getOptions()))return e;throw ec.create("already-initialized")}return n.initialize({options:t})}(e)}(to);let tu=function(e=(0,d.Mq)()){return tn().then(e=>{if(!e)throw ez.create("unsupported-browser")},e=>{throw ez.create("indexed-db-unsupported")}),(0,d.qX)((0,y.m9)(e),"messaging").getImmediate()}(to)},425:function(e,t,n){"use strict";n.d(t,{be:function(){return o},eq:function(){return i}});var r=n(6247);let i=e=>{if(null==e)return null;if(e instanceof Date)return e.getTime();if("number"==typeof e)return e;if("string"==typeof e){let t=Date.parse(e);return Number.isNaN(t)?null:t}if("object"==typeof e){if("function"==typeof e.toDate){let t=e.toDate();return t instanceof Date?t.getTime():null}if("number"==typeof e.seconds)return 1e3*e.seconds}return null},s=e=>{var t,n,s,o;if(!e)return null;let a=i(null!==(n=null===(t=e.planInfo)||void 0===t?void 0:t.trialEndsAt)&&void 0!==n?n:null),l=i(null!==(s=e.createdAt)&&void 0!==s?s:null),u=l?l+r.WJ:null;return a&&u?Math.min(a,u):null!==(o=null!=a?a:u)&&void 0!==o?o:null},o=e=>{var t;let n=s(e),i=Date.now(),o="trial"===(null==e?void 0:null===(t=e.planInfo)||void 0===t?void 0:t.status)&&!!n&&i<n,a=o&&n?Math.max(0,Math.ceil((n-i)/r.mf)):0;return{active:o,daysLeft:a,endMs:n,endDate:n?new Date(n):null,totalDays:r.Vf}}},6031:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return q},reportWebVitals:function(){return B}});var r=n(5893);n(1575);var i=n(588),s=n(3700),o=n(8758),a=n(8767),l=n(6501),u=n(7294),c=n(9008),h=n.n(c),d=n(7166),f=()=>{let[e,t]=(0,u.useState)({}),[n,i]=(0,u.useState)(!1);return((0,u.useEffect)(()=>{let e=()=>{var e;t({screenWidth:window.screen.width,screenHeight:window.screen.height,screenAvailWidth:window.screen.availWidth,screenAvailHeight:window.screen.availHeight,windowWidth:window.innerWidth,windowHeight:window.innerHeight,windowOuterWidth:window.outerWidth,windowOuterHeight:window.outerHeight,devicePixelRatio:window.devicePixelRatio,calculatedZoom:Math.round(window.outerWidth/window.screen.width*100),viewportMeta:null===(e=document.querySelector('meta[name="viewport"]'))||void 0===e?void 0:e.getAttribute("content"),htmlZoom:getComputedStyle(document.documentElement).zoom,bodyZoom:getComputedStyle(document.body).zoom,htmlTransform:getComputedStyle(document.documentElement).transform,bodyTransform:getComputedStyle(document.body).transform,userAgent:navigator.userAgent,platform:navigator.platform,colorDepth:window.screen.colorDepth,pixelDepth:window.screen.pixelDepth})};e(),window.addEventListener("resize",e);let n=e=>{e.ctrlKey&&e.altKey&&"d"===e.key&&i(e=>!e)};return window.addEventListener("keydown",n),()=>{window.removeEventListener("resize",e),window.removeEventListener("keydown",n)}},[]),n)?(0,r.jsxs)("div",{className:"fixed top-4 right-4 z-[10000] bg-black/90 text-white text-xs p-4 rounded-lg max-w-sm max-h-96 overflow-y-auto font-mono",children:[(0,r.jsxs)("div",{className:"flex justify-between items-center mb-2",children:[(0,r.jsx)("h3",{className:"font-bold",children:"Display Debug Info"}),(0,r.jsx)("button",{onClick:()=>i(!1),className:"text-red-400 hover:text-red-300",children:"\xd7"})]}),(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("div",{className:"border-b border-gray-600 pb-1 mb-2",children:(0,r.jsx)("strong",{children:"Screen:"})}),(0,r.jsxs)("div",{children:["Width: ",e.screenWidth,"px"]}),(0,r.jsxs)("div",{children:["Height: ",e.screenHeight,"px"]}),(0,r.jsxs)("div",{children:["Available: ",e.screenAvailWidth,"\xd7",e.screenAvailHeight]}),(0,r.jsx)("div",{className:"border-b border-gray-600 pb-1 mb-2 mt-3",children:(0,r.jsx)("strong",{children:"Window:"})}),(0,r.jsxs)("div",{children:["Inner: ",e.windowWidth,"\xd7",e.windowHeight]}),(0,r.jsxs)("div",{children:["Outer: ",e.windowOuterWidth,"\xd7",e.windowOuterHeight]}),(0,r.jsx)("div",{className:"border-b border-gray-600 pb-1 mb-2 mt-3",children:(0,r.jsx)("strong",{children:"Scaling:"})}),(0,r.jsxs)("div",{children:["Device Pixel Ratio: ",e.devicePixelRatio]}),(0,r.jsxs)("div",{children:["Calculated Zoom: ",e.calculatedZoom,"%"]}),(0,r.jsxs)("div",{children:["HTML Zoom: ",e.htmlZoom]}),(0,r.jsxs)("div",{children:["Body Zoom: ",e.bodyZoom]}),(0,r.jsx)("div",{className:"border-b border-gray-600 pb-1 mb-2 mt-3",children:(0,r.jsx)("strong",{children:"Transforms:"})}),(0,r.jsxs)("div",{children:["HTML: ",e.htmlTransform]}),(0,r.jsxs)("div",{children:["Body: ",e.bodyTransform]}),(0,r.jsx)("div",{className:"border-b border-gray-600 pb-1 mb-2 mt-3",children:(0,r.jsx)("strong",{children:"Display:"})}),(0,r.jsxs)("div",{children:["Color Depth: ",e.colorDepth]}),(0,r.jsxs)("div",{children:["Pixel Depth: ",e.pixelDepth]}),(0,r.jsx)("div",{className:"border-b border-gray-600 pb-1 mb-2 mt-3",children:(0,r.jsx)("strong",{children:"System:"})}),(0,r.jsxs)("div",{children:["Platform: ",e.platform]}),(0,r.jsxs)("div",{children:["UA: ",e.userAgent]}),(0,r.jsx)("div",{className:"mt-3 text-xs text-gray-400",children:"Press Ctrl+Alt+D to toggle"})]})]}):null},p=n(645),m=n.n(p),g=n(1163);function y(){if("undefined"==typeof navigator)return!1;try{let e=navigator.userAgent.toLowerCase();return e.includes("tv")||e.includes("smarttv")||e.includes("googletv")||e.includes("mibox")||e.includes("firetv")||e.includes("viera")||e.includes("netcast")||e.includes("crkey")||e.includes("web0s")}catch(e){return console.debug("Error detecting TV browser:",e),!1}}
15function v(){try{return"Notification"in window&&"serviceWorker"in navigator&&!y()}catch(e){return console.debug("Error checking notification support:",e),!1}}function w(){let e=(0,g.useRouter)(),[t,n]=(0,u.useState)(null),[i,s]=(0,u.useState)(!1),[o,a]=(0,u.useState)(!1),[l,c]=(0,u.useState)(!1),h="/"===e.pathname,d=y()||!function(){try{return"serviceWorker"in navigator&&!y()&&!function(){if("undefined"==typeof navigator)return!1;try{let e=navigator.userAgent.toLowerCase();return e.includes("mibrowser")||e.includes("ucbrowser")||e.includes("oppo")||e.includes("vivo")||y()}catch(e){return console.debug("Error detecting limited browser:",e),!1}}()}catch(e){return console.debug("Error checking PWA support:",e),!1}}();(0,u.useEffect)(()=>{try{if(d)return;let e=navigator.userAgent.toLowerCase();if(e.includes("tv")||e.includes("smarttv")||e.includes("googletv")||e.includes("mibox")||e.includes("firetv")){console.log("\uD83D\uDCFA TV browser detected - skipping install prompt");return}let t=(()=>{try{return window.matchMedia&&window.matchMedia("(display-mode: standalone)").matches||!0===navigator.standalone||window.location.search.includes("source=pwa")}catch(e){return console.debug("Error checking install status:",e),!1}})();if(a(t),t){console.log("\uD83C\uDF89 App is running as installed PWA - hiding install prompt");return}let r=localStorage.getItem("installPromptDismissed"),i=r?parseInt(r):0,o=Date.now()-864e5;if(!r||i<o){let e=setTimeout(()=>{s(!0)},5e3),t=e=>{try{e.preventDefault(),n(e),s(!0)}catch(e){console.debug("Error handling install prompt:",e)}},r=()=>{a(!0),s(!1),console.log("â
PWA was installed - hiding prompt")};try{window.addEventListener("beforeinstallprompt",t),window.addEventListener("appinstalled",r)}catch(e){console.debug("Error adding install prompt listeners:",e)}return()=>{clearTimeout(e);try{window.removeEventListener("beforeinstallprompt",t),window.removeEventListener("appinstalled",r)}catch(e){console.debug("Error removing install prompt listeners:",e)}}}}catch(e){console.error("InstallPrompt error:",e),c(!0)}},[d]);let f=async()=>{try{if(t){await t.prompt();let{outcome:e}=await t.userChoice;"accepted"===e&&console.log("User accepted the install prompt"),n(null),s(!1)}else{let e=/iPad|iPhone|iPod/.test(navigator.userAgent),t=/Android/.test(navigator.userAgent),n="";n=e?'To install:\n1. Tap the Share button (square with arrow)\n2. Tap "Add to Home Screen"\n3. Tap "Add"':t?'To install:\n1. Tap the menu (â®) in the top-right\n2. Tap "Install app" or "Add to Home screen"':"To install:\nLook for the install icon (+) in your browser's address bar",alert(n)}}catch(e){console.error("Error handling install click:",e),s(!1)}};return d||!h||o||!i||l?null:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"jsx-dbfa1ded297df405 fixed bottom-6 right-2 sm:right-10 z-[9999] animate-bounce-gentle",children:(0,r.jsxs)("div",{className:"jsx-dbfa1ded297df405 relative group flex flex-col items-center",children:[(0,r.jsx)("div",{className:"jsx-dbfa1ded297df405 mb-2 sm:mb-3 pointer-events-none",children:(0,r.jsxs)("div",{className:"jsx-dbfa1ded297df405 bg-gray-900 text-white text-xs sm:text-sm font-semibold px-3 py-1.5 sm:px-4 sm:py-2 rounded-lg shadow-xl whitespace-nowrap border border-white/10",children:["Install Whatchly",(0,r.jsx)("div",{className:"jsx-dbfa1ded297df405 absolute top-full left-1/2 -translate-x-1/2 w-0 h-0 border-l-4 border-r-4 border-t-4 border-l-transparent border-r-transparent border-t-gray-900"})]})}),(0,r.jsxs)("button",{onClick:f,"aria-label":"Install Whatchly",className:"jsx-dbfa1ded297df405 relative group",children:[(0,r.jsxs)("div",{className:"jsx-dbfa1ded297df405 relative bg-gradient-to-br from-yellow-400 via-amber-500 to-orange-500 p-2 sm:p-3 rounded-xl sm:rounded-2xl shadow-2xl active:shadow-yellow-400/60 sm:group-hover:shadow-yellow-400/60 transition-all duration-300 active:scale-95 sm:group-hover:scale-105 overflow-hidden",children:[(0,r.jsx)("div",{className:"jsx-dbfa1ded297df405 relative w-12 h-12 sm:w-14 sm:h-14",children:(0,r.jsx)("img",{src:"/icon-96x96.png",alt:"Whatchly",className:"jsx-dbfa1ded297df405 w-full h-full rounded-lg sm:rounded-xl drop-shadow-lg transform transition-transform duration-300 sm:group-hover:scale-95"})}),(0,r.jsx)("div",{className:"jsx-dbfa1ded297df405 hidden sm:block absolute inset-0 bg-gradient-to-tr from-transparent via-white/30 to-transparent -translate-x-full group-hover:translate-x-full transition-transform duration-700 ease-out"}),(0,r.jsx)("div",{className:"jsx-dbfa1ded297df405 hidden sm:block absolute inset-0 rounded-2xl border-2 border-white/50 opacity-0 group-hover:opacity-100 group-hover:scale-110 transition-all duration-500"})]}),(0,r.jsx)("div",{className:"jsx-dbfa1ded297df405 hidden sm:block absolute inset-0 rounded-2xl bg-gradient-to-br from-yellow-300 to-amber-400 opacity-0 group-hover:opacity-40 blur-2xl transition-all duration-500 -z-10"})]})]})}),(0,r.jsx)(m(),{id:"dbfa1ded297df405",children:"@-webkit-keyframes bounce-gentle{0%,100%{-webkit-transform:translatey(0);transform:translatey(0)}50%{-webkit-transform:translatey(-10px);transform:translatey(-10px)}}@-moz-keyframes bounce-gentle{0%,100%{-moz-transform:translatey(0);transform:translatey(0)}50%{-moz-transform:translatey(-10px);transform:translatey(-10px)}}@-o-keyframes bounce-gentle{0%,100%{-o-transform:translatey(0);transform:translatey(0)}50%{-o-transform:translatey(-10px);transform:translatey(-10px)}}@keyframes bounce-gentle{0%,100%{-webkit-transform:translatey(0);-moz-transform:translatey(0);-o-transform:translatey(0);transform:translatey(0)}50%{-webkit-transform:translatey(-10px);-moz-transform:translatey(-10px);-o-transform:translatey(-10px);transform:translatey(-10px)}}.animate-bounce-gentle.jsx-dbfa1ded297df405{-webkit-animation:bounce-gentle 2s ease-in-out infinite;-moz-animation:bounce-gentle 2s ease-in-out infinite;-o-animation:bounce-gentle 2s ease-in-out infinite;animation:bounce-gentle 2s ease-in-out infinite}"})]})}var b=n(7918),_=n(2190),I=n(5626),E=n(109);let T=!1;function S(e){let{onPermissionChange:t}=e,{user:n}=(0,i.a)(),{requestPermissionAndGetToken:s}=function(e){let[t,n]=(0,u.useState)(null),[r,i]=(0,u.useState)("default"),[s,o]=(0,u.useState)(!1),[a,l]=(0,u.useState)(null);(0,u.useEffect)(()=>
15{if(I.Fw&&v())try{i(Notification.permission)}catch(e){console.debug("Error checking notification permission:",e)}},[]);let c=async(e,t)=>{try{let n=(0,E.doc)(I.db,"users",e);(await (0,E.getDoc)(n)).exists()?await (0,E.updateDoc)(n,{fcmTokens:{[t]:{createdAt:new Date,lastUsed:new Date,userAgent:navigator.userAgent}}}):await (0,E.setDoc)(n,{fcmTokens:{[t]:{createdAt:new Date,lastUsed:new Date,userAgent:navigator.userAgent}}},{merge:!0}),console.log("â
FCM token saved to Firestore")}catch(e){console.error("Error saving FCM token:",e)}};return{fcmToken:t,permission:r,isLoading:s,error:a,requestPermissionAndGetToken:async()=>{if(!I.Fw||!e)return console.warn("FCM not supported or user not logged in"),null;try{let r;if(o(!0),l(null),!await (0,I.Gb)())throw Error("FCM is not supported in this browser");let s=await Notification.requestPermission();if(i(s),"granted"!==s)return console.log("Notification permission denied"),null;if("serviceWorker"in navigator){var t;(r=null!==(t=await navigator.serviceWorker.getRegistration("/"))&&void 0!==t?t:void 0)||(r=await navigator.serviceWorker.register("/firebase-messaging-sw.js",{scope:"/"}))}let a=await (0,I.LP)(I.Fw,{vapidKey:"BHNNM5In9hDLUEqvCbzkCtxZkWWVxN85BzG2NNQ7szYNNdpVR_lRVhfHdQb1pMWO5l7mkyCOp5WP7DfqDpucDSI",serviceWorkerRegistration:r});if(a)return console.log("â
FCM Token obtained:",a),n(a),await c(e,a),a;throw Error("No FCM token available")}catch(e){return console.error("Error getting FCM token:",e),l(e instanceof Error?e.message:"Unknown error"),null}finally{o(!1)}},removeFCMToken:async(e,t)=>{try{let n=(0,E.doc)(I.db,"users",e);await (0,E.updateDoc)(n,{["fcmTokens.".concat(t)]:null}),console.log("â
FCM token removed")}catch(e){console.error("Error removing FCM token:",e)}}}}(null==n?void 0:n.uid),[o,a]=(0,u.useState)(!1),[l,c]=(0,u.useState)("default"),[h,d]=(0,u.useState)(!1),[f,p]=(0,u.useState)(!1),m=(0,u.useRef)(!1),g=y()||!v();(0,u.useEffect)(()=>{try{if(g||!("Notification"in window))return;let e=navigator.userAgent.toLowerCase();if(e.includes("tv")||e.includes("smarttv")||e.includes("googletv")||e.includes("mibox")||e.includes("firetv")){console.log("\uD83D\uDCFA TV browser detected - skipping notification prompt");return}let t=Notification.permission;if(c(t),"default"!==t)return;let n=localStorage.getItem("notificationPromptDismissed");if(n){let e=parseInt(n),t=Date.now()-2592e5;if(e>t)return}let r=setTimeout(()=>{a(!0)},3e4);return()=>clearTimeout(r)}catch(e){console.error("NotificationPermissionPrompt error:",e)}},[g]);let w=async()=>{if(m.current||h||T||f){console.log("Test notification already shown or in progress, skipping...");return}try{m.current=!0,p(!0),d(!0),T=!0,await s()?(c("granted"),a(!1),console.log("â
FCM Push n
15otifications enabled - will work even when app is closed!"),setTimeout(async()=>{try{if("serviceWorker"in navigator&&navigator.serviceWorker.controller){let e=await navigator.serviceWorker.ready,t=await e.getNotifications({tag:"notification-enabled"});console.log("Closing ".concat(t.length," existing notifications...")),t.forEach(e=>e.close()),console.log("Showing ONE new notification via service worker..."),await e.showNotification("Notifications Enabled! \uD83C\uDF89",{body:"You'll receive updates about new likes, follows, and playlist updates!",icon:"/icon-192x192.png",badge:"/icon-96x96.png",tag:"notification-enabled",silent:!1})}else"Notification"in window&&"granted"===Notification.permission&&(console.log("Showing ONE new notification via Notification API..."),new Notification("Notifications Enabled! \uD83C\uDF89",{body:"You'll receive updates about new likes, follows, and playlist updates!",icon:"/icon-192x192.png",badge:"/icon-96x96.png",tag:"notification-enabled",silent:!1}))}catch(e){console.warn("Could not show test notification:",e)}finally{p(!1)}},300),null==t||t("granted")):(c("denied"),null==t||t("denied"),m.current=!1,d(!1),T=!1,p(!1))}catch(e){console.error("Error requesting FCM notification permission:",e),m.current=!1,d(!1),T=!1,p(!1)}};return g||!o||"default"!==l?null:(0,r.jsx)("div",{className:"fixed top-20 left-1/2 -translate-x-1/2 z-[9998] w-[calc(100%-2rem)] max-w-md animate-slide-down",children:(0,r.jsx)("div",{className:"bg-slate-900/95 backdrop-blur-xl rounded-2xl shadow-2xl p-3 sm:p-4 border border-white/20",children:(0,r.jsxs)("div",{className:"flex items-start gap-2 sm:gap-3",children:[(0,r.jsx)("div",{className:"flex-shrink-0 w-8 h-8 sm:w-10 sm:h-10 bg-gradient-to-r from-yellow-400 to-amber-500 rounded-full flex items-center justify-center shadow-lg shadow-yellow-400/25",children:(0,r.jsx)(b.Z,{className:"w-4 h-4 sm:w-5 sm:h-5 text-black"})}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("h3",{className:"text-white font-bold text-sm sm:text-base mb-1 leading-tight",children:"Stay Updated! \uD83D\uDD14"}),(0,r.jsx)("p",{className:"text-gray-300 text-xs sm:text-sm leading-snug sm:leading-relaxed",children:"Get notified about new likes, follows, and playlist updates!"}),(0,r.jsxs)("div",{className:"flex gap-2 mt-2 sm:mt-3",children:[(0,r.jsx)("button",{onClick:w,disabled:f,className:"flex-1 bg-gradient-to-r from-yellow-400 to-amber-500 text-black font-semibold text-xs sm:text-sm px-3 sm:px-4 py-2 rounded-lg hover:from-yellow-300 hover:to-amber-400 transition-all duration-200 shadow-lg hover:shadow-yellow-400/25 active:scale-95 whitespace-nowrap ".concat(f?"opacity-50 cursor-not-allowed":""),children:f?"Enabling...":"Enable"}),(0,r.jsx)("button",{onClick:()=>{a(!1),localStorage.setItem("notificationPromptDismissed",Date.now().toString())},disabled:f,className:"px-2 sm:px-3 py-2 text-gray-400 hover:text-white hover:bg-white/10 rounded-lg transition-colors duration-200 flex-shrink-0 disabled:opacity-50 disabled:cursor-not-allowed","aria-label":"Dismiss",children:(0,r.jsx)(_.Z,{className:"w-4 h-4"})})]})]})]})})})}let C=(0,n(1134).Z)("Cookie",[["path",{d:"M12 2a10 10 0 1 0 10 10 4 4 0 0 1-5-5 4 4 0 0 1-5-5",key:"laymnq"}],["path",{d:"M8.5 8.5v.01",key:"ue8clq"}],["path",{d:"M16 15.5v.01",key:"14dtrp"}],["path",{d:"M12 12v.01",key:"u5ubse"}],["path",{d:"M11 17v.01",key:"1hyl5a"}],["path",{d:"M7 14v.01",key:"uct60s"}]]);var x=n(1664),k=n.n(x);function A(){let[e,t]=(0,u.useState)(!1);(0,u.useEffect)(()=>{if(!localStorage.getItem("cookieConsent")){let e=setTimeout(()=>{t(!0)},1e3);return()=>clearTimeout(e)}},[]);let n=()=>{localStorage.setItem("cookieConsent","declined"),localStorage.setItem("cookieConsentDate",new Date().toISOString());try{var e,n,r;null===(e=(n=window).gtag)||void 0===e||e.call(n,"consent","update",{analytics_storage:"denied",ad_storage:"denied",ad_user_data:"denied",ad_personalization:"denied",functionality_storage:"granted",security_storage:"granted"}),null===(r=window.dataLayer)||void 0===r||r.push({event:"cookie_consent_update",status:"declined"})}catch(e){}t(!1)};return e?(0,r.jsx)("div",{className:"fixed bottom-0 left-0 right-0 z-[9998] p-4 animate-slide-up",children:(0,r.jsx)("div",{className:"max-w-6xl mx-auto",children:(0,r.jsx)("div",{className:"bg-slate-900/95 backdrop-blur-xl rounded-2xl shadow-2xl border border-white/20 p-4 sm:p-6",children:(0,r.jsxs)("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-4",children:[(0,r.jsx)("div",{className:"flex-shrink-0",children:(0,r.jsx)("div",{className:"w-12 h-12 bg-gradient-to-r from-yellow-400 to-amber-500 rounded-full flex items-center justify-center shadow-lg shadow-yellow-400/25",children:(0,r.jsx)(C,{className:"w-6 h-6 text-black"})})}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("h3",{className:"text-white font-bold text-base sm:text-lg mb-2",children:"\uD83C\uDF6A We V
15alue Your Privacy"}),(0,r.jsxs)("p",{className:"text-gray-300 text-sm leading-relaxed",children:['We use cookies to enhance your experience, analyze site traffic, and personalize content. By clicking "Accept All", you consent to our use of cookies.'," ",(0,r.jsx)(k(),{href:"/privacy",className:"text-yellow-400 hover:text-yellow-300 underline transition-colors",children:"Learn more"})]})]}),(0,r.jsxs)("div",{className:"flex flex-col sm:flex-row gap-2 w-full sm:w-auto",children:[(0,r.jsx)("button",{onClick:()=>{localStorage.setItem("cookieConsent","accepted"),localStorage.setItem("cookieConsentDate",new Date().toISOString());try{var e,n,r;null===(e=(n=window).gtag)||void 0===e||e.call(n,"consent","update",{analytics_storage:"granted",ad_storage:"denied",ad_user_data:"denied",ad_personalization:"denied",functionality_storage:"granted",security_storage:"granted"}),null===(r=window.dataLayer)||void 0===r||r.push({event:"cookie_consent_update",status:"accepted"})}catch(e){}t(!1)},className:"bg-gradient-to-r from-yellow-400 to-amber-500 text-black font-semibold text-sm px-6 py-2.5 rounded-lg hover:from-yellow-300 hover:to-amber-400 transition-all duration-200 shadow-lg hover:shadow-yellow-400/25 active:scale-95 whitespace-nowrap",children:"Accept All"}),(0,r.jsx)("button",{onClick:n,className:"bg-white/10 text-gray-300 font-medium text-sm px-6 py-2.5 rounded-lg hover:bg-white/20 hover:text-white transition-all duration-200 whitespace-nowrap",children:"Decline"}),(0,r.jsx)("button",{onClick:n,className:"sm:ml-2 p-2.5 text-gray-400 hover:text-white hover:bg-white/10 rounded-lg transition-colors duration-200","aria-label":"Close",children:(0,r.jsx)(_.Z,{className:"w-5 h-5"})})]})]})})})}):null}var R=n(437),N=n(3454),O=()=>{window.va||(window.va=function(...e){(window.vaq=window.vaq||[]).push(e)})};function D(){return"undefined"!=typeof window}function P(){return"production"}function L(){return"development"===((D()?window.vam:P())||"production")}function M(e){return(0,u.useEffect)(()=>{var t;e.beforeSend&&(null==(t=window.va)||t.call(window,"beforeSend",e.beforeSend))},[e.beforeSend]),(0,u.useEffect)(()=>{!function(e={debug:!0}){var t;if(!D())return;(function(e="auto"){if("auto"===e){window.vam=P();return}window.vam=e})(e.mode),O(),e.beforeSend&&(null==(t=window.va)||t.call(window,"beforeSend",e.beforeSend));let n=e.scriptSrc?e.scriptSrc:L()?"https://va.vercel-scripts.com/v1/script.debug.js":e.basePath?`${e.basePath}/insights/script.js`:"/_vercel/insights/script.js";if(document.head.querySelector(`script[src*="${n}"]`))return;let r=document.createElement("script");r.src=n,r.defer=!0,r.dataset.sdkn="@vercel/analytics"+(e.framework?`/${e.framework}`:""),r.dataset.sdkv="1.5.0",e.disableAutoTrack&&(r.dataset.disableAutoTrack="1"),e.endpoint?r.dataset.endpoint=e.endpoint:e.basePath&&(r.dataset.endpoint=`${e.basePath}/insights`),e.dsn&&(r.dataset.dsn=e.dsn),r.onerror=()=>{let e=L()?"Please check if any ad blockers are enabled and try again.":"Be sure to enable Web Analytics for your project and deploy again. See https://vercel.com/docs/analytics/quickstart for more information.";console.log(`[Vercel Web Analytics] Failed to load script from ${n}. ${e}`)},L()&&!1===e.debug&&(r.dataset.debug="false"),document.head.appendChild(r)}({framework:e.framework||"react",basePath:e.basePath??function(){if(void 0!==N&&void 0!==N.env)return N.env.REACT_APP_VERCEL_OBSERVABILITY_BASEPATH}(),...void 0!==e.route&&{disableAutoTrack:!0},...e})},[]),(0,u.useEffect)(()=>{e.route&&e.path&&function({route:e,path:t}){var n;null==(n=window.va)||n.call(window,"pageview",{route:e,path:t})}({route:e.route,path:e.path})},[e.route,e.path]),null}let F=!1,U=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n]};var V=n(3454);function j(e){let{t}=e,n=(0,u.useRef)(null),[i,s]=(0,u.useState)(0),[o,a]=(0,u.useState)(!1),c=e=>{null!=e&&(n.current=e,a(!0))},h=e=>{null!=n.current&&null!=e&&s(e-n.current)},d=()=>{a(!1),Math.abs(i)>64?l.Am.dismiss(t.id):s(0)},f=e=>{var t,n;null===(t=(n=e.currentTarget).releasePointerCapture)||void 0===t||t.call(n,e.pointerId),d()};return(0,r.jsx)("div",{onTouchStart:e=>{var t,n;return c(null!==(n=null===(t=e.touches[0])||void 0===t?void 0:t.clientX)&&void 0!==n?n:null)},onTouchMove:e=>{var t,n;return h(null!==(n=null===(t=e.touches[0])||void 0===t?void 0:t.clientX)&&void 0!==n?n:null)},onTouchEnd:d,onTouchCancel:d,onPointerDown:e=>{var t,n;
15("mouse"!==e.pointerType||1===e.buttons)&&(null===(t=(n=e.currentTarget).setPointerCapture)||void 0===t||t.call(n,e.pointerId),c(e.clientX))},onPointerMove:e=>h(e.clientX),onPointerUp:f,onPointerCancel:f,style:{transform:"translateX(".concat(i,"px)"),opacity:1-Math.min(.5,Math.abs(i)/160),transition:o?"none":"transform 150ms ease, opacity 150ms ease",touchAction:"pan-y",willChange:"transform, opacity",pointerEvents:"auto"},children:(0,r.jsx)(l.$x,{toast:t})})}function B(e){try{var t,n;if("true"!==V.env.NEXT_PUBLIC_ENABLE_VITALS)return;null===(t=(n=navigator).sendBeacon)||void 0===t||t.call(n,"/api/vitals",JSON.stringify(e))}catch(e){}}function q(e){let{Component:t,pageProps:n}=e,c=(0,g.useRouter)(),[p]=(0,u.useState)(()=>new a.QueryClient({defaultOptions:{queries:{staleTime:3e5,cacheTime:18e5,refetchOnWindowFocus:!1,refetchOnReconnect:!0,refetchOnMount:!1,retry:1}}}));(0,R.c)(),(0,u.useEffect)(()=>{if(!("ontouchstart"in window)||y())return;let e=0,t=0,n=n=>{try{let r=n.target;if(!r||r.closest(".allow-refresh")||r.closest("[data-drag-handle]")||r.closest('[role="dialog"]')||r.closest(".modal-content")||r.closest(".draggable")||r.closest(".overflow-y-auto")||r.closest(".overflow-auto")||r.closest(".custom-scrollbar")||1!==n.touches.length)return;let i=n.touches[0],s=r,o=0;for(;s&&s!==document.body;){if(s.scrollTop>0||s.scrollHeight>s.clientHeight){o=s.scrollTop;break}s=s.parentElement}if(o||(o=window.pageYOffset||document.documentElement.scrollTop),"touchstart"===n.type)e=i.clientY,t=o;else if("touchmove"===n.type){let r=i.clientY-e;if(0===t&&r>5)return n.preventDefault(),!1}}catch(e){console.debug("Pull-to-refresh prevention error:",e)}};try{document.addEventListener("touchstart",n,{passive:!1}),document.addEventListener("touchmove",n,{passive:!1}),document.body&&(document.body.style.overscrollBehaviorY="contain"),document.documentElement&&(document.documentElement.style.overscrollBehaviorY="contain")}catch(e){console.debug("Failed to add pull-to-refresh prevention:",e)}return()=>{try{document.removeEventListener("touchstart",n),document.removeEventListener("touchmove",n)}catch(e){console.debug("Cleanup error:",e)}}},[]);let[m,v]=(0,u.useState)(!1);return(0,u.useEffect)(()=>{let e=window.matchMedia("(max-width: 640px)"),t=()=>v(e.matches);return(t(),e.addEventListener)?(e.addEventListener("change",t),()=>e.removeEventListener("change",t)):(e.addListener(t),()=>e.removeListener(t))},[]),(0,u.useEffect)(()=>{try{var e,t;let n=localStorage.getItem("cookieConsent");null===(e=(t=window).gtag)||void 0===e||e.call(t,"consent","update",{analytics_storage:"accepted"===n?"granted":"denied",ad_storage:"denied",ad_user_data:"denied",ad_personalization:"denied",functionality_storage:"granted",security_storage:"granted"})}catch(e){}},[]),(0,u.useEffect)(()=>{let e=e=>{try{window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:"page_view",page_path:e,page_location:window.location.href,page_title:document.title})}catch(e){}};return e(window.location.pathname+window.location.search),c.events.on("routeChangeComplete",e),()=>{c.events.off("routeChangeComplete",e)}},[c.events]),(0,u.useEffect)(()=>{"serviceWorker"in navigator&&(async()=>{try{var e,t;let n=await navigator.serviceWorker.getRegistration("/");if(null==n?void 0:null===(t=n.active)||void 0===t?void 0:null===(e=t.scriptURL)||void 0===e?void 0:e.includes("firebase-messaging-sw.js"))return;await navigator.serviceWorker.register("/firebase-messaging-sw.js",{scope:"/"})}catch(e){console.warn("Service worker registration failed:",e)}})()},[]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(h(),{children:[(0,r.jsx)("meta",{name:"viewport",content:"width=device-width, initial-scale=1, maximum-scale=1, viewport-fit=cover, user-scalable=no"}),(0,r.jsx)("meta",{name:"format-detection",content:"telephone=no"}),(0,r.jsx)("meta",{name:"mobile-web-app-capable",content:"yes"}),(0,r.jsx)("link",{rel:"manifest",href:"/manifest.json"}),(0,r.jsx)("link",{rel:"icon",type:"image/svg+xml",href:"/icon.svg"}),(0,r.jsx)("link",{rel:"apple-touch-icon",href:"/apple-touch-icon.png"}),(0,r.jsx)("meta",{name:"application-name",content:"Whatchly"}),(0,r.jsx)("meta",{name:"apple-mobile-web-app-capable",content:"yes"}),(0,r.jsx)("meta",{name:"apple-mobile-web-app-status-bar-style",content:"black-translucent"}),(0,r.jsx)("meta",{name:"apple-mobile-web-app-title",content:"Whatchly"}),(0,r.jsx)("meta",{name:"mobile-web-app-capable",content:"yes"}),(0,r.jsx)("meta",{name:"theme-color",content:"#000000"})]}),(0,r.jsx)(d.Z,{children:(0,r.jsx)(a.QueryClientProvider,{client:p,children:(0,r.jsx)(i.H,{children:(0,r.jsx)(s.q,{children:(0,r.jsxs)(o.M,{children:[(0,r.jsx)(f,{}),(0,r.jsx)(w,{}),(0,r.jsx)(S,{}),(0,r.jsx)(A,{}),(0,r.jsxs)("div",{className:"min-h-screen bg-cosmic text-white",children:[(0,r.jsx)(t,{...n}
15),"true"===V.env.NEXT_PUBLIC_ENABLE_ANALYTICS?(0,r.jsx)(M,{}):null,!m&&(0,r.jsx)(l.x7,{position:"top-right",containerStyle:{zIndex:1e6},toastOptions:{duration:4e3,style:{background:"rgb(12, 18, 34)",color:"#ffffff",border:"1px solid rgba(75, 85, 99, 0.3)",borderRadius:"16px",padding:"16px 20px",fontSize:"14px",fontWeight:"500",boxShadow:"0 10px 25px -5px rgba(0, 0, 0, 0.25), 0 10px 10px -5px rgba(0, 0, 0, 0.04)",backdropFilter:"blur(8px)",maxWidth:"400px"},success:{style:{background:"rgb(12, 18, 34)",border:"1px solid rgba(34, 197, 94, 0.3)",color:"#ffffff"},iconTheme:{primary:"#22c55e",secondary:"#ffffff"}},error:{style:{background:"rgb(12, 18, 34)",border:"1px solid rgba(239, 68, 68, 0.3)",color:"#ffffff"},iconTheme:{primary:"#ef4444",secondary:"#ffffff"}},loading:{style:{background:"rgb(12, 18, 34)",border:"1px solid rgba(251, 191, 36, 0.3)",color:"#ffffff"},iconTheme:{primary:"#fbbf24",secondary:"#ffffff"}}},children:e=>(0,r.jsx)(j,{t:e})})]})]})})})})})]})}F||(["log","info","debug","warn","error"].forEach(e=>{try{let t=Object.getOwnPropertyDescriptor(console,e);(null==t?void 0:t.writable)?Reflect.set(console,e,U):Object.defineProperty(console,e,{configurable:!0,value:U})}catch(t){try{Reflect.set(console,e,U)}catch(e){}}}),F=!0)},1876:function(e){!function(){var t={675:function(e,t){"use strict";t.byteLength=function(e){var t=l(e),n=t[0],r=t[1];return(n+r)*3/4-r},t.toByteArray=function(e){var t,n,s=l(e),o=s[0],a=s[1],u=new i((o+a)*3/4-a),c=0,h=a>0?o-4:o;for(n=0;n<h;n+=4)t=r[e.charCodeAt(n)]<<18|r[e.charCodeAt(n+1)]<<12|r[e.charCodeAt(n+2)]<<6|r[e.charCodeAt(n+3)],u[c++]=t>>16&255,u[c++]=t>>8&255,u[c++]=255&t;return 2===a&&(t=r[e.charCodeAt(n)]<<2|r[e.charCodeAt(n+1)]>>4,u[c++]=255&t),1===a&&(t=r[e.charCodeAt(n)]<<10|r[e.charCodeAt(n+1)]<<4|r[e.charCodeAt(n+2)]>>2,u[c++]=t>>8&255,u[c++]=255&t),u},t.fromByteArray=function(e){for(var t,r=e.length,i=r%3,s=[],o=0,a=r-i;o<a;o+=16383)s.push(function(e,t,r){for(var i,s=[],o=t;o<r;o+=3)s.push(n[(i=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(255&e[o+2]))>>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return s.join("")}(e,o,o+16383>a?a:o+16383));return 1===i?s.push(n[(t=e[r-1])>>2]+n[t<<4&63]+"=="):2===i&&s.push(n[(t=(e[r-2]<<8)+e[r-1])>>10]+n[t>>4&63]+n[t<<2&63]+"="),s.join("")};for(var n=[],r=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,a=s.length;o<a;++o)n[o]=s[o],r[s.charCodeAt(o)]=o;function l(e){var t=e.length;if(t%4>0)throw Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");-1===n&&(n=t);var r=n===t?0:4-n%4;return[n,r]}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},72:function(e,t,n){"use strict";var r=n(675),i=n(783),s="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;function o(e){if(e>2147483647)throw RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return Object.setPrototypeOf(t,a.prototype),t}function a(e,t,n){if("number"==typeof e){if("string"==typeof t)throw TypeError('The "string" argument must be of type string. Received type number');return c(e)}return l(e,t,n)}function l(e,t,n){if("string"==typeof e)return function(e,t){if(("string"!=typeof t||""===t)&&(t="utf8"),!a.isEncoding(t))throw TypeError("Unknown encoding: "+t);var n=0|f(e,t),r=o(n),i=r.write(e,t);return i!==n&&(r=r.slice(0,i)),r}(e,t);if(ArrayBuffer.isView(e))return h(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(A(e,ArrayBuffer)||e&&A(e.buffer,ArrayBuffer)||"undefined"!=typeof SharedArrayBuffer&&(A(e,SharedArrayBuffer)||e&&A(e.buffer,SharedArrayBuffer)))return function(e,t,n){var r;if(t<0||e.byteLength<t)throw RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(n||0))throw RangeError('"length" is outside of buffer bounds');return Object.setPrototypeOf(r=void 0===t&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,t):new Uint8Array(e,t,n),a.prototype),r}(e,t,n);if("number"==typeof e)throw TypeError('The "value" argument must not be of type number. Received type number');var r=e.valueOf&&e.valueOf();if(null!=r&&r!==e)return a.from(r,t,n);var i=function(e){if(a.isBuffer(e)){var t,n=0|d(e.length),r=o(n);return 0===r.length||e.copy(r,0,0,n),r}return void 0!==e.length?"number"!=typeof e.length||(t=e.length)!=t?o(0):h(e):"Buffer"===e.type&&Array.isArray(e.data)?h(e.data):void 0}(e);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return a.from(e[Symbol.toPrimitive]("string"),t,n);throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function u(e){if("number"!=typeof e)throw TypeError('"size" argument must be of type number');
15if(e<0)throw RangeError('The value "'+e+'" is invalid for option "size"')}function c(e){return u(e),o(e<0?0:0|d(e))}function h(e){for(var t=e.length<0?0:0|d(e.length),n=o(t),r=0;r<t;r+=1)n[r]=255&e[r];return n}function d(e){if(e>=2147483647)throw RangeError("Attempt to allocate Buffer larger than maximum size: 0x7fffffff bytes");return 0|e}function f(e,t){if(a.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||A(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var n=e.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===n)return 0;for(var i=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return S(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return x(e).length;default:if(i)return r?-1:S(e).length;t=(""+t).toLowerCase(),i=!0}}function p(e,t,n){var i,s,o=!1;if((void 0===t||t<0)&&(t=0),t>this.length||((void 0===n||n>this.length)&&(n=this.length),n<=0||(n>>>=0)<=(t>>>=0)))return"";for(e||(e="utf8");;)switch(e){case"hex":return function(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var i="",s=t;s<n;++s)i+=R[e[s]];return i}(this,t,n);case"utf8":case"utf-8":return v(this,t,n);case"ascii":return function(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(127&e[i]);return r}(this,t,n);case"latin1":case"binary":return function(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}(this,t,n);case"base64":return i=t,s=n,0===i&&s===this.length?r.fromByteArray(this):r.fromByteArray(this.slice(i,s));case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return function(e,t,n){for(var r=e.slice(t,n),i="",s=0;s<r.length;s+=2)i+=String.fromCharCode(r[s]+256*r[s+1]);return i}(this,t,n);default:if(o)throw TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),o=!0}}function m(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function g(e,t,n,r,i){var s;if(0===e.length)return -1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),(s=n=+n)!=s&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return -1;n=e.length-1}else if(n<0){if(!i)return -1;n=0}if("string"==typeof t&&(t=a.from(t,r)),a.isBuffer(t))return 0===t.length?-1:y(e,t,n,r,i);if("number"==typeof t)return(t&=255,"function"==typeof Uint8Array.prototype.indexOf)?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):y(e,[t],n,r,i);throw TypeError("val must be string, number or Buffer")}function y(e,t,n,r,i){var s,o=1,a=e.length,l=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return -1;o=2,a/=2,l/=2,n/=2}function u(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(i){var c=-1;for(s=n;s<a;s++)if(u(e,s)===u(t,-1===c?0:s-c)){if(-1===c&&(c=s),s-c+1===l)return c*o}else -1!==c&&(s-=s-c),c=-1}else for(n+l>a&&(n=a-l),s=n;s>=0;s--){for(var h=!0,d=0;d<l;d++)if(u(e,s+d)!==u(t,d)){h=!1;break}if(h)return s}return -1}function v(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;i<n;){var s,o,a,l,u=e[i],c=null,h=u>239?4:u>223?3:u>191?2:1;if(i+h<=n)switch(h){case 1:u<128&&(c=u);break;case 2:(192&(s=e[i+1]))==128&&(l=(31&u)<<6|63&s)>127&&(c=l);break;case 3:s=e[i+1],o=e[i+2],(192&s)==128&&(192&o)==128&&(l=(15&u)<<12|(63&s)<<6|63&o)>2047&&(l<55296||l>57343)&&(c=l);break;case 4:s=e[i+1],o=e[i+2],a=e[i+3],(192&s)==128&&(192&o)==128&&(192&a)==128&&(l=(15&u)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&l<1114112&&(c=l)}null===c?(c=65533,h=1):c>65535&&(c-=65536,r.push(c>>>10&1023|55296),c=56320|1023&c),r.push(c),i+=h}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);for(var n="",r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=4096));return n}(r)}function w(e,t,n){if(e%1!=0||e<0)throw RangeError("offset is not uint");if(e+t>n)throw RangeError("Trying to access beyond buffer length")}function b(e,t,n,r,i,s){if(!a.isBuffer(e))throw TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<s)throw RangeError('"value" argument is out of bounds');if(n+r>e.length)throw RangeError("Index out of range")}function _(e,t,n,r,i,s){if(n+r>e.length||n<0)throw RangeError("Index out of range")}
vendor: 12,113 bytes, line 15
15function I(e,t,n,r,s){return t=+t,n>>>=0,s||_(e,t,n,4,34028234663852886e22,-34028234663852886e22),i.write(e,t,n,r,23,4),n+4}function E(e,t,n,r,s){return t=+t,n>>>=0,s||_(e,t,n,8,17976931348623157e292,-17976931348623157e292),i.write(e,t,n,r,52,8),n+8}t.Buffer=a,t.SlowBuffer=function(e){return+e!=e&&(e=0),a.alloc(+e)},t.INSPECT_MAX_BYTES=50,t.kMaxLength=2147483647,a.TYPED_ARRAY_SUPPORT=function(){try{var e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return!1}}(),a.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}}),a.poolSize=8192,a.from=function(e,t,n){return l(e,t,n)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array),a.alloc=function(e,t,n){return(u(e),e<=0)?o(e):void 0!==t?"string"==typeof n?o(e).fill(t,n):o(e).fill(t):o(e)},a.allocUnsafe=function(e){return c(e)},a.allocUnsafeSlow=function(e){return c(e)},a.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==a.prototype},a.compare=function(e,t){if(A(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),A(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(e)||!a.isBuffer(t))throw TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var n=e.length,r=t.length,i=0,s=Math.min(n,r);i<s;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:r<n?1:0},a.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(e,t){if(!Array.isArray(e))throw TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return a.alloc(0);if(void 0===t)for(n=0,t=0;n<e.length;++n)t+=e[n].length;var n,r=a.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){var s=e[n];if(A(s,Uint8Array)&&(s=a.from(s)),!a.isBuffer(s))throw TypeError('"list" argument must be an Array of Buffers');s.copy(r,i),i+=s.length}return r},a.byteLength=f,a.prototype._isBuffer=!0,a.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)m(this,t,t+1);return this},a.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)m(this,t,t+3),m(this,t+1,t+2);return this},a.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)m(this,t,t+7),m(this,t+1,t+6),m(this,t+2,t+5),m(this,t+3,t+4);return this},a.prototype.toString=function(){var e=this.length;return 0===e?"":0==arguments.length?v(this,0,e):p.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(e){if(!a.isBuffer(e))throw TypeError("Argument must be a Buffer");return this===e||0===a.compare(this,e)},a.prototype.inspect=function(){var e="",n=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(e+=" ... "),"<Buffer "+e+">"},s&&(a.prototype[s]=a.prototype.inspect),a.prototype.compare=function(e,t,n,r,i){if(A(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(e))throw TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw RangeError("out of range index");if(r>=i&&t>=n)return 0;if(r>=i)return -1;if(t>=n)return 1;if(t>>>=0,n>>>=0,r>>>=0,i>>>=0,this===e)return 0;for(var s=i-r,o=n-t,l=Math.min(s,o),u=this.slice(r,i),c=e.slice(t,n),h=0;h<l;++h)if(u[h]!==c[h]){s=u[h],o=c[h];break}return s<o?-1:o<s?1:0},a.prototype.includes=function(e,t,n){return -1!==this.indexOf(e,t,n)},a.prototype.indexOf=function(e,t,n){return g(this,e,t,n,!0)},a.prototype.lastIndexOf=function(e,t,n){return g(this,e,t,n,!1)},a.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else if(isFinite(t))t>>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0);else throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var i,s,o,a,l,u,c,h,d,f,p,m,g=this.length-t;if((void 0===n||n>g)&&(n=g),e.length>0&&(n<0||t<0)||t>this.length)throw RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var y=!1;;)switch(r){case"hex":return function(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?(r=Number(r))>i&&(r=i):r=i;var s=t.length;r>s/2&&(r=s/2);for(var o=0;o<r;++o){var a=parseInt(t.substr(2*o,2),16);if(a!=a)break;e[n+o]=a}return o}(this,e,t,n);case"utf8":case"utf-8":return l=t,u=n,k(S(e,this.length-l),this,l,u);case"ascii":return c=t,h=n,k(C(e),this,c,h);case"latin1":case"binary":return i=this,s=e,o=t,a=n,k(C(s),i,o,a);case"base64":return d=t,f=n,k(x(e),this,d,f);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return p=t,m=n,k(function(e,t){for(var n,r,i=[],s=0;s<e.length&&!((t-=2)<0);++s)r=(n=e.charCodeAt(s))>>8,i.push(n%256),i.push(r);return i}(e,this.length-p),this,p,m);default:if(y)throw TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),y=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},a.prototype.slice=function(e,t){var n=this.length;e=~~e,t=void 0===t?n:~~t,e<0?(e+=n)<0&&(e=0):e>n&&(e=n),t<0?(t+=n)<0&&(t=0):t>n&&(t=n),t<e&&(t=e);var r=this.subarray(e,t);return Object.setPrototypeOf(r,a.prototype),r},a.prototype.readUIntLE=function(e,t,n){e>>>=0,t>>>=0,n||w(e,t,this.length);for(var r=this[e],i=1,s=0;++s<t&&(i*=256);)r+=this[e+s]*i;return r},a.prototype.readUIntBE=function(e,t,n){e>>>=0,t>>>=0,n||w(e,t,this.length);for(var r=this[e+--t],i=1;t>0&&(i*=256);)r+=this[e+--t]*i;return r},a.prototype.readUInt8=function(e,t){return e>>>=0,t||w(e,1,this.length),this[e]},a.prototype.readUInt16LE=function(e,t){return e>>>=0,t||w(e,2,this.length),this[e]|this[e+1]<<8},a.prototype.readUInt16BE=function(e,t){return e>>>=0,t||w(e,2,this.length),this[e]<<8|this[e+1]},a.prototype.readUInt32LE=function(e,t){return e>>>=0,t||w(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},a.prototype.readUInt32BE=function(e,t){return e>>>=0,t||w(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},a.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||w(e,t,this.length);for(var r=this[e],i=1,s=0;++s<t&&(i*=256);)r+=this[e+s]*i;return r>=(i*=128)&&(r-=Math.pow(2,8*t)),r},a.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||w(e,t,this.length);for(var r=t,i=1,s=this[e+--r];r>0&&(i*=256);)s+=this[e+--r]*i;return s>=(i*=128)&&(s-=Math.pow(2,8*t)),s},a.prototype.readInt8=function(e,t){return(e>>>=0,t||w(e,1,this.length),128&this[e])?-((255-this[e]+1)*1):this[e]},a.prototype.readInt16LE=function(e,t){e>>>=0,t||w(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},a.prototype.readInt16BE=function(e,t){e>>>=0,t||w(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},a.prototype.readInt32LE=function(e,t){return e>>>=0,t||w(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},a.prototype.readInt32BE=function(e,t){return e>>>=0,t||w(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},a.prototype.readFloatLE=function(e,t){return e>>>=0,t||w(e,4,this.length),i.read(this,e,!0,23,4)},a.prototype.readFloatBE=function(e,t){return e>>>=0,t||w(e,4,this.length),i.read(this,e,!1,23,4)},a.prototype.readDoubleLE=function(e,t){return e>>>=0,t||w(e,8,this.length),i.read(this,e,!0,52,8)},a.prototype.readDoubleBE=function(e,t){return e>>>=0,t||w(e,8,this.length),i.read(this,e,!1,52,8)},a.prototype.writeUIntLE=function(e,t,n,r){if(e=+e,t>>>=0,n>>>=0,!r){var i=Math.pow(2,8*n)-1;b(this,e,t,n,i,0)}var s=1,o=0;for(this[t]=255&e;++o<n&&(s*=256);)this[t+o]=e/s&255;return t+n},a.prototype.writeUIntBE=function(e,t,n,r){if(e=+e,t>>>=0,n>>>=0,!r){var i=Math.pow(2,8*n)-1;b(this,e,t,n,i,0)}var s=n-1,o=1;for(this[t+s]=255&e;--s>=0&&(o*=256);)this[t+s]=e/o&255;return t+n},a.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||b(this,e,t,1,255,0),this[t]=255&e,t+1},a.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||b(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},a.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||b(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},a.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||b(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},a.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||b(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},a.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t>>>=0,!r){var i=Math.pow(2,8*n-1);b(this,e,t,n,i-1,-i)}var s=0,o=1,a=0;for(this[t]=255&e;++s<n&&(o*=256);)e<0&&0===a&&0!==this[t+s-1]&&(a=1),this[t+s]=(e/o>>0)-a&255;return t+n},a.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t>>>=0,!r){var i=Math.pow(2,8*n-1);b(this,e,t,n,i-1,-i)}var s=n-1,o=1,a=0;for(this[t+s]=255&e;--s>=0&&(o*=256);)e<0&&0===a&&0!==this[t+s+1]&&(a=1),this[t+s]=(e/o>>0)-a&255;return t+n},a.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||b(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},a.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||b(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},a.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||b(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},a.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||b(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},a.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||b(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},a.prototype.writeFloatLE=function(e,t,n){return I(this,e,t,!0,n)},a.prototype.writeFloatBE=function(e,t,n){return I(this,e,t,!1,n)},a.prototype.writeDoubleLE=function(e,t,n){return E(this,e,t,!0,n)},a.prototype.writeDoubleBE=function(e,t,n){return E(this,e,t,!1,n)},a.prototype.copy=function(e,t,n,r){if(!a.isBuffer(e))throw TypeError("argument should be a Buffer");if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n||0===e.length||0===this.length)return 0;if(t<0)throw RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw RangeError("Index out of range");if(r<0)throw RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var i=r-n;if(this===e&&"function"==typeof Uint8Array.prototype.copyWithin)this.copyWithin(t,n,r);else if(this===e&&n<t&&t<r)for(var s=i-1;s>=0;--s)e[s+t]=this[s+n];else Uint8Array.prototype.set.call(e,this.subarray(n,r),t);return i},a.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),void 0!==r&&"string"!=typeof r)throw TypeError("encoding must be a string");if("string"==typeof r&&!a.isEncoding(r))throw TypeError("Unknown encoding: "+r);if(1===e.length){var i,s=e.charCodeAt(0);("utf8"===r&&s<128||"latin1"===r)&&(e=s)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(t<0||this.length<t||this.length<n)throw RangeError("Out of range index");if(n<=t)return this;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(i=t;i<n;++i)this[i]=e;else{var o=a.isBuffer(e)?e:a.from(e,r),l=o.length;
15if(0===l)throw TypeError('The value "'+e+'" is invalid for argument "value"');for(i=0;i<n-t;++i)this[i+t]=o[i%l]}return this};var T=/[^+/0-9A-Za-z-_]/g;function S(e,t){t=t||1/0;for(var n,r=e.length,i=null,s=[],o=0;o<r;++o){if((n=e.charCodeAt(o))>55295&&n<57344){if(!i){if(n>56319||o+1===r){(t-=3)>-1&&s.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&s.push(239,191,189),i=n;continue}n=(i-55296<<10|n-56320)+65536}else i&&(t-=3)>-1&&s.push(239,191,189);if(i=null,n<128){if((t-=1)<0)break;s.push(n)}else if(n<2048){if((t-=2)<0)break;s.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;s.push(n>>12|224,n>>6&63|128,63&n|128)}else if(n<1114112){if((t-=4)<0)break;s.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}else throw Error("Invalid code point")}return s}function C(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}function x(e){return r.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(T,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function k(e,t,n,r){for(var i=0;i<r&&!(i+n>=t.length)&&!(i>=e.length);++i)t[i+n]=e[i];return i}function A(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}var R=function(){for(var e="0123456789abcdef",t=Array(256),n=0;n<16;++n)for(var r=16*n,i=0;i<16;++i)t[r+i]=e[n]+e[i];return t}()},783:function(e,t){t.read=function(e,t,n,r,i){var s,o,a=8*i-r-1,l=(1<<a)-1,u=l>>1,c=-7,h=n?i-1:0,d=n?-1:1,f=e[t+h];for(h+=d,s=f&(1<<-c)-1,f>>=-c,c+=a;c>0;s=256*s+e[t+h],h+=d,c-=8);for(o=s&(1<<-c)-1,s>>=-c,c+=r;c>0;o=256*o+e[t+h],h+=d,c-=8);if(0===s)s=1-u;else{if(s===l)return o?NaN:1/0*(f?-1:1);o+=Math.pow(2,r),s-=u}return(f?-1:1)*o*Math.pow(2,s-r)},t.write=function(e,t,n,r,i,s){var o,a,l,u=8*s-i-1,c=(1<<u)-1,h=c>>1,d=23===i?5960464477539062e-23:0,f=r?0:s-1,p=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(isNaN(t=Math.abs(t))||t===1/0?(a=isNaN(t)?1:0,o=c):(o=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-o))<1&&(o--,l*=2),o+h>=1?t+=d/l:t+=d*Math.pow(2,1-h),t*l>=2&&(o++,l/=2),o+h>=c?(a=0,o=c):o+h>=1?(a=(t*l-1)*Math.pow(2,i),o+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,i),o=0));i>=8;e[n+f]=255&a,f+=p,a/=256,i-=8);for(o=o<<i|a,u+=i;u>0;e[n+f]=255&o,f+=p,o/=256,u-=8);e[n+f-p]|=128*m}}},n={};function r(e){var i=n[e];if(void 0!==i)return i.exports;var s=n[e]={exports:{}},o=!0;try{t[e](s,s.exports,r),o=!1}finally{o&&delete n[e]}return s.exports}r.ab="//";var i=r(72);e.exports=i}()},1479:function(){},1575:function(){},7663:function(e){!function(){var t={229:function(e){var t,n,r,i=e.exports={};function s(){throw Error("setTimeout has not been defined")}function o(){throw Error("clearTimeout has not been defined")}function a(e){if(t===setTimeout)return setTimeout(e,0);if((t===s||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(n){try{return t.call(null,e,0)}catch(n){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:s}catch(e){t=s}try{n="function"==typeof clearTimeout?clearTimeout:o}catch(e){n=o}}();var l=[],u=!1,c=-1;function h(){u&&r&&(u=!1,r.length?l=r.concat(l):c=-1,l.length&&d())}function d(){if(!u){var e=a(h);u=!0;for(var t=l.length;t;){for(r=l,l=[];++c<t;)r&&r[c].run();c=-1,t=l.length}r=null,u=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===o||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function f(e,t){this.fun=e,this.array=t}function p(){}i.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];l.push(new f(e,t)),1!==l.length||u||a(d)},f.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=p,i.addListener=p,i.once=p,i.off=p,i.removeListener=p,i.removeAllListeners=p,i.emit=p,i.prependListener=p,i.prependOnceListener=p,i.listeners=function(e){return[]},i.binding=function(e){throw Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw Error("process.chdir is not supported")},i.umask=function(){return 0}}},n={};function r(e){var i=n[e];if(void 0!==i)return i.exports;var s=n[e]={exports:{}},o=!0;try{t[e](s,s.exports,r),o=!1}finally{o&&delete n[e]}return s.exports}r.ab="//";var i=r(229);e.exports=i}()},5152:function(e,t,n){e.exports=n(2602)},9008:function(e,t,n){e.exports=n(3867)},1664:function(e,t,n){e.exports=n(8342)},1163:function(e,t,n){e.exports=n(3079)},9852:function(e,t,n){"use strict";n.d(t,{j:function(){return o}});var r=n(5068),i=n(2943),s=n(2288),o=new(function(e){function t(){var t;return(t=e.call(this)||this).setup=function(e){var t;if(!s.sk&&(null==(t=window)?void 0:t.addEventListener)){var n=function(){return e()};return window.addEventListener("visibilitychange",n,!1),window.addEventListener("focus",n,!1),function(){window.removeEventListener("visibilitychange",n),window.removeEventListener("focus",n)}}},t}(0,r.Z)(t,e);var n=t.prototype;return n.onSubscribe=function(){this.cleanup||this.setEventListener(this.setup)},n.onUnsubscribe=function(){if(!this.hasListeners()){var e;null==(e=this.cleanup)||e.call(this),this.cleanup=void 0}},n.setEventListener=function(e){var t,n=this;this.setup=e,null==(t=this.cleanup)||t.call(this),this.cleanup=e(function(e){"boolean"==typeof e?n.setFocused(e):n.onFocus()})},n.setFocused=function(e){this.focused=e,e&&this.onFocus()}
15,n.onFocus=function(){this.listeners.forEach(function(e){e()})},n.isFocused=function(){return"boolean"==typeof this.focused?this.focused:"undefined"==typeof document||[void 0,"visible","prerender"].includes(document.visibilityState)},t}(i.l))},6747:function(e,t,n){"use strict";n.d(t,{QueryClient:function(){return r.S}});var r=n(9043),i=n(6755);n.o(i,"QueryClientProvider")&&n.d(t,{QueryClientProvider:function(){return i.QueryClientProvider}}),n.o(i,"useMutation")&&n.d(t,{useMutation:function(){return i.useMutation}}),n.o(i,"useQuery")&&n.d(t,{useQuery:function(){return i.useQuery}}),n.o(i,"useQueryClient")&&n.d(t,{useQueryClient:function(){return i.useQueryClient}})},1909:function(e,t,n){"use strict";n.d(t,{E:function(){return s},j:function(){return i}});var r=console;function i(){return r}function s(e){r=e}},1262:function(e,t,n){"use strict";n.d(t,{R:function(){return u},m:function(){return l}});var r=n(7462),i=n(1909),s=n(101),o=n(1216),a=n(2288),l=function(){function e(e){this.options=(0,r.Z)({},e.defaultOptions,e.options),this.mutationId=e.mutationId,this.mutationCache=e.mutationCache,this.observers=[],this.state=e.state||u(),this.meta=e.meta}var t=e.prototype;return t.setState=function(e){this.dispatch({type:"setState",state:e})},t.addObserver=function(e){-1===this.observers.indexOf(e)&&this.observers.push(e)},t.removeObserver=function(e){this.observers=this.observers.filter(function(t){return t!==e})},t.cancel=function(){return this.retryer?(this.retryer.cancel(),this.retryer.promise.then(a.ZT).catch(a.ZT)):Promise.resolve()},t.continue=function(){return this.retryer?(this.retryer.continue(),this.retryer.promise):this.execute()},t.execute=function(){var e,t=this,n="loading"===this.state.status,r=Promise.resolve();return n||(this.dispatch({type:"loading",variables:this.options.variables}),r=r.then(function(){null==t.mutationCache.config.onMutate||t.mutationCache.config.onMutate(t.state.variables,t)}).then(function(){return null==t.options.onMutate?void 0:t.options.onMutate(t.state.variables)}).then(function(e){e!==t.state.context&&t.dispatch({type:"loading",context:e,variables:t.state.variables})})),r.then(function(){return t.executeMutation()}).then(function(n){e=n,null==t.mutationCache.config.onSuccess||t.mutationCache.config.onSuccess(e,t.state.variables,t.state.context,t)}).then(function(){return null==t.options.onSuccess?void 0:t.options.onSuccess(e,t.state.variables,t.state.context)}).then(function(){return null==t.options.onSettled?void 0:t.options.onSettled(e,null,t.state.variables,t.state.context)}).then(function(){return t.dispatch({type:"success",data:e}),e}).catch(function(e){return null==t.mutationCache.config.onError||t.mutationCache.config.onError(e,t.state.variables,t.state.context,t),(0,i.j)().error(e),Promise.resolve().then(function(){return null==t.options.onError?void 0:t.options.onError(e,t.state.variables,t.state.context)}).then(function(){return null==t.options.onSettled?void 0:t.options.onSettled(void 0,e,t.state.variables,t.state.context)}).then(function(){throw t.dispatch({type:"error",error:e}),e})})},t.executeMutation=function(){var e,t=this;return this.retryer=new o.m4({fn:function(){return t.options.mutationFn?t.options.mutationFn(t.state.variables):Promise.reject("No mutationFn found")},onFail:function(){t.dispatch({type:"failed"})},onPause:function(){t.dispatch({type:"pause"})},onContinue:function(){t.dispatch({type:"continue"})},retry:null!=(e=this.options.retry)?e:0,retryDelay:this.options.retryDelay}),this.retryer.promise},t.dispatch=function(e){var t=this;this.state=function(e,t){switch(t.type){case"failed":return(0,r.Z)({},e,{failureCount:e.failureCount+1});case"pause":return(0,r.Z)({},e,{isPaused:!0});case"continue":return(0,r.Z)({},e,{isPaused:!1});case"loading":return(0,r.Z)({},e,{context:t.context,data:void 0,error:null,isPaused:!1,status:"loading",variables:t.variables});case"success":return(0,r.Z)({},e,{data:t.data,error:null,status:"success",isPaused:!1});case"error":return(0,r.Z)({},e,{data:void 0,error:t.error,failureCount:e.failureCount+1,isPaused:!1,status:"error"});case"setState":return(0,r.Z)({},e,t.state);default:return e}}
15(this.state,e),s.V.batch(function(){t.observers.forEach(function(t){t.onMutationUpdate(e)}),t.mutationCache.notify(t)})},e}();function u(){return{context:void 0,data:void 0,error:null,failureCount:0,isPaused:!1,status:"idle",variables:void 0}}},101:function(e,t,n){"use strict";n.d(t,{V:function(){return i}});var r=n(2288),i=new(function(){function e(){this.queue=[],this.transactions=0,this.notifyFn=function(e){e()},this.batchNotifyFn=function(e){e()}}var t=e.prototype;return t.batch=function(e){var t;this.transactions++;try{t=e()}finally{this.transactions--,this.transactions||this.flush()}return t},t.schedule=function(e){var t=this;this.transactions?this.queue.push(e):(0,r.A4)(function(){t.notifyFn(e)})},t.batchCalls=function(e){var t=this;return function(){for(var n=arguments.length,r=Array(n),i=0;i<n;i++)r[i]=arguments[i];t.schedule(function(){e.apply(void 0,r)})}},t.flush=function(){var e=this,t=this.queue;this.queue=[],t.length&&(0,r.A4)(function(){e.batchNotifyFn(function(){t.forEach(function(t){e.notifyFn(t)})})})},t.setNotifyFunction=function(e){this.notifyFn=e},t.setBatchNotifyFunction=function(e){this.batchNotifyFn=e},e}())},68:function(e,t,n){"use strict";n.d(t,{N:function(){return o}});var r=n(5068),i=n(2943),s=n(2288),o=new(function(e){function t(){var t;return(t=e.call(this)||this).setup=function(e){var t;if(!s.sk&&(null==(t=window)?void 0:t.addEventListener)){var n=function(){return e()};return window.addEventListener("online",n,!1),window.addEventListener("offline",n,!1),function(){window.removeEventListener("online",n),window.removeEventListener("offline",n)}}},t}(0,r.Z)(t,e);var n=t.prototype;return n.onSubscribe=function(){this.cleanup||this.setEventListener(this.setup)},n.onUnsubscribe=function(){if(!this.hasListeners()){var e;null==(e=this.cleanup)||e.call(this),this.cleanup=void 0}},n.setEventListener=function(e){var t,n=this;this.setup=e,null==(t=this.cleanup)||t.call(this),this.cleanup=e(function(e){"boolean"==typeof e?n.setOnline(e):n.onOnline()})},n.setOnline=function(e){this.online=e,e&&this.onOnline()},n.onOnline=function(){this.listeners.forEach(function(e){e()})},n.isOnline=function(){return"boolean"==typeof this.online?this.online:"undefined"==typeof navigator||void 0===navigator.onLine||navigator.onLine},t}(i.l))},9043:function(e,t,n){"use strict";n.d(t,{S:function(){return y}});var r=n(7462),i=n(2288),s=n(5068),o=n(101),a=n(1909),l=n(1216),u=function(){function e(e){this.abortSignalConsumed=!1,this.hadObservers=!1,this.defaultOptions=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.cache=e.cache,this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.initialState=e.state||this.getDefaultState(this.options),this.state=this.initialState,this.meta=e.meta,this.scheduleGc()}var t=e.prototype;return t.setOptions=function(e){var t;this.options=(0,r.Z)({},this.defaultOptions,e),this.meta=null==e?void 0:e.meta,this.cacheTime=Math.max(this.cacheTime||0,null!=(t=this.options.cacheTime)?t:3e5)},t.setDefaultOptions=function(e){this.defaultOptions=e},t.scheduleGc=function(){var e=this;this.clearGcTimeout(),(0,i.PN)(this.cacheTime)&&(this.gcTimeout=setTimeout(function(){e.optionalRemove()},this.cacheTime))},t.clearGcTimeout=function(){this.gcTimeout&&(clearTimeout(this.gcTimeout),this.gcTimeout=void 0)},t.optionalRemove=function(){!this.observers.length&&(this.state.isFetching?this.hadObservers&&this.scheduleGc():this.cache.remove(this))},t.setData=function(e,t){var n,r,s=this.state.data,o=(0,i.SE)(e,s);return(null==(n=(r=this.options).isDataEqual)?void 0:n.call(r,s,o))?o=s:!1!==this.options.structuralSharing&&(o=(0,i.Q$)(s,o)),this.dispatch({data:o,type:"success",dataUpdatedAt:null==t?void 0:t.updatedAt}),o},t.setState=function(e,t){this.dispatch({type:"setState",state:e,setStateOptions:t})},t.cancel=function(e){var t,n=this.promise;return null==(t=this.retryer)||t.cancel(e),n?n.then(i.ZT).catch(i.ZT):Promise.resolve()},t.destroy=function(){this.clearGcTimeout(),this.cancel({silent:!0})},t.reset=function(){this.destroy(),this.setState(this.initialState)},t.isActive=function(){return this.observers.some(function(e){return!1!==e.options.enabled})},t.isFetching=function(){return this.state.isFetching},t.isStale=function(){return this.state.isInvalidated||!this.state.dataUpdatedAt||this.observers.some(function(e){return e.getCurrentResult().isStale})},t.isStaleByTime=function(e){return void 0===e&&(e=0),this.state.isInvalidated||!this.state.dataUpdatedAt||!(0,i.Kp)(this.state.dataUpdatedAt,e)},t.onFocus=function(){var e,t=this.observers.find(function(e){return e.shouldFetchOnWindowFocus()});t&&t.refetch(),null==(e=this.retryer)||e.continue()},t.onOnline=function(){var e,t=this.observers.find(function(e){return e.shouldFetchOnReconnect()});t&&t.refetch(),null==(e=this.retryer)||e.continue()},t.addObserver=function(e){-1===this.observers.indexOf(e)&&(this.observers.push(e),this.hadObservers=!0,this.clearGcTimeout(),this.cache.notify({type:"observerAdded",query:this,observer:e}))},t.removeObserver=function(e){-1!==this.observers.indexOf(e)&&(this.observers=this.observers.filter(function(t){return t!==e}),this.observers.length||(this.retryer&&(this.retryer.isTransportCancelable||this.abort
15SignalConsumed?this.retryer.cancel({revert:!0}):this.retryer.cancelRetry()),this.cacheTime?this.scheduleGc():this.cache.remove(this)),this.cache.notify({type:"observerRemoved",query:this,observer:e}))},t.getObserversCount=function(){return this.observers.length},t.invalidate=function(){this.state.isInvalidated||this.dispatch({type:"invalidate"})},t.fetch=function(e,t){var n,r,s,o,u,c,h=this;if(this.state.isFetching){if(this.state.dataUpdatedAt&&(null==t?void 0:t.cancelRefetch))this.cancel({silent:!0});else if(this.promise)return null==(n=this.retryer)||n.continueRetry(),this.promise}if(e&&this.setOptions(e),!this.options.queryFn){var d=this.observers.find(function(e){return e.options.queryFn});d&&this.setOptions(d.options)}var f=(0,i.mc)(this.queryKey),p=(0,i.G9)(),m={queryKey:f,pageParam:void 0,meta:this.meta};Object.defineProperty(m,"signal",{enumerable:!0,get:function(){if(p)return h.abortSignalConsumed=!0,p.signal}});var g={fetchOptions:t,options:this.options,queryKey:f,state:this.state,fetchFn:function(){return h.options.queryFn?(h.abortSignalConsumed=!1,h.options.queryFn(m)):Promise.reject("Missing queryFn")},meta:this.meta};return(null==(o=this.options.behavior)?void 0:o.onFetch)&&(null==(r=this.options.behavior)||r.onFetch(g)),this.revertState=this.state,this.state.isFetching&&this.state.fetchMeta===(null==(u=g.fetchOptions)?void 0:u.meta)||this.dispatch({type:"fetch",meta:null==(s=g.fetchOptions)?void 0:s.meta}),this.retryer=new l.m4({fn:g.fetchFn,abort:null==p?void 0:null==(c=p.abort)?void 0:c.bind(p),onSuccess:function(e){h.setData(e),null==h.cache.config.onSuccess||h.cache.config.onSuccess(e,h),0===h.cacheTime&&h.optionalRemove()},onError:function(e){(0,l.DV)(e)&&e.silent||h.dispatch({type:"error",error:e}),(0,l.DV)(e)||(null==h.cache.config.onError||h.cache.config.onError(e,h),(0,a.j)().error(e)),0===h.cacheTime&&h.optionalRemove()},onFail:function(){h.dispatch({type:"failed"})},onPause:function(){h.dispatch({type:"pause"})},onContinue:function(){h.dispatch({type:"continue"})},retry:g.options.retry,retryDelay:g.options.retryDelay}),this.promise=this.retryer.promise,this.promise},t.dispatch=function(e){var t=this;this.state=this.reducer(this.state,e),o.V.batch(function(){t.observers.forEach(function(t){t.onQueryUpdate(e)}),t.cache.notify({query:t,type:"queryUpdated",action:e})})},t.getDefaultState=function(e){var t="function"==typeof e.initialData?e.initialData():e.initialData,n=void 0!==e.initialData?"function"==typeof e.initialDataUpdatedAt?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0,r=void 0!==t;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?null!=n?n:Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchMeta:null,isFetching:!1,isInvalidated:!1,isPaused:!1,status:r?"success":"idle"}},t.reducer=function(e,t){var n,i;switch(t.type){case"failed":return(0,r.Z)({},e,{fetchFailureCount:e.fetchFailureCount+1});case"pause":return(0,r.Z)({},e,{isPaused:!0});case"continue":return(0,r.Z)({},e,{isPaused:!1});case"fetch":return(0,r.Z)({},e,{fetchFailureCount:0,fetchMeta:null!=(n=t.meta)?n:null,isFetching:!0,isPaused:!1},!e.dataUpdatedAt&&{error:null,status:"loading"});case"success":return(0,r.Z)({},e,{data:t.data,dataUpdateCount:e.dataUpdateCount+1,dataUpdatedAt:null!=(i=t.dataUpdatedAt)?i:Date.now(),error:null,fetchFailureCount:0,isFetching:!1,isInvalidated:!1,isPaused:!1,status:"success"});case"error":var s=t.error;if((0,l.DV)(s)&&s.revert&&this.revertState)return(0,r.Z)({},this.revertState);return(0,r.Z)({},e,{error:s,errorUpdateCount:e.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:e.fetchFailureCount+1,isFetching:!1,isPaused:!1,status:"error"});case"invalidate":return(0,r.Z)({},e,{isInvalidated:!0});case"setState":return(0,r.Z)({},e,t.state);default:return e}},e}(),c=n(2943),h=function(e){function t(t){var n;return(n=e.call(this)||this).config=t||{},n.queries=[],n.queriesMap={},n}(0,s.Z)(t,e);var n=t.prototype;return n.build=function(e,t,n){var r,s=t.queryKey,o=null!=(r=t.queryHash)?r:(0,i.Rm)(s,t),a=this.get(o);return a||(a=new u({cache:this,queryKey:s,queryHash:o,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(s),meta:t.meta}),this.add(a)),a},n.add=function(e){this.queriesMap[e.queryHash]||(this.queriesMap[e.queryHash]=e,this.queries.push(e),this.notify({type:"queryAdded",query:e}))},n.remove=function(e){var t=this.queriesMap[e.queryHash];t&&(e.destroy(),this.queries=this.queries.filter(function(t){return t!==e}),t===e&&delete this.queriesMap[e.queryHash],this.notify({type:"queryRemoved",query:e}))},n.clear=function(){var e=this;
15o.V.batch(function(){e.queries.forEach(function(t){e.remove(t)})})},n.get=function(e){return this.queriesMap[e]},n.getAll=function(){return this.queries},n.find=function(e,t){var n=(0,i.I6)(e,t)[0];return void 0===n.exact&&(n.exact=!0),this.queries.find(function(e){return(0,i._x)(n,e)})},n.findAll=function(e,t){var n=(0,i.I6)(e,t)[0];return Object.keys(n).length>0?this.queries.filter(function(e){return(0,i._x)(n,e)}):this.queries},n.notify=function(e){var t=this;o.V.batch(function(){t.listeners.forEach(function(t){t(e)})})},n.onFocus=function(){var e=this;o.V.batch(function(){e.queries.forEach(function(e){e.onFocus()})})},n.onOnline=function(){var e=this;o.V.batch(function(){e.queries.forEach(function(e){e.onOnline()})})},t}(c.l),d=n(1262),f=function(e){function t(t){var n;return(n=e.call(this)||this).config=t||{},n.mutations=[],n.mutationId=0,n}(0,s.Z)(t,e);var n=t.prototype;return n.build=function(e,t,n){var r=new d.m({mutationCache:this,mutationId:++this.mutationId,options:e.defaultMutationOptions(t),state:n,defaultOptions:t.mutationKey?e.getMutationDefaults(t.mutationKey):void 0,meta:t.meta});return this.add(r),r},n.add=function(e){this.mutations.push(e),this.notify(e)},n.remove=function(e){this.mutations=this.mutations.filter(function(t){return t!==e}),e.cancel(),this.notify(e)},n.clear=function(){var e=this;o.V.batch(function(){e.mutations.forEach(function(t){e.remove(t)})})},n.getAll=function(){return this.mutations},n.find=function(e){return void 0===e.exact&&(e.exact=!0),this.mutations.find(function(t){return(0,i.X7)(e,t)})},n.findAll=function(e){return this.mutations.filter(function(t){return(0,i.X7)(e,t)})},n.notify=function(e){var t=this;o.V.batch(function(){t.listeners.forEach(function(t){t(e)})})},n.onFocus=function(){this.resumePausedMutations()},n.onOnline=function(){this.resumePausedMutations()},n.resumePausedMutations=function(){var e=this.mutations.filter(function(e){return e.state.isPau
15sed});return o.V.batch(function(){return e.reduce(function(e,t){return e.then(function(){return t.continue().catch(i.ZT)})},Promise.resolve())})},t}(c.l),p=n(9852),m=n(68);function g(e,t){return null==e.getNextPageParam?void 0:e.getNextPageParam(t[t.length-1],t)}var y=function(){function e(e){void 0===e&&(e={}),this.queryCache=e.queryCache||new h,this.mutationCache=e.mutationCache||new f,this.defaultOptions=e.defaultOptions||{},this.queryDefaults=[],this.mutationDefaults=[]}var t=e.prototype;return t.mount=function(){var e=this;this.unsubscribeFocus=p.j.subscribe(function(){p.j.isFocused()&&m.N.isOnline()&&(e.mutationCache.onFocus(),e.queryCache.onFocus())}),this.unsubscribeOnline=m.N.subscribe(function(){p.j.isFocused()&&m.N.isOnline()&&(e.mutationCache.onOnline(),e.queryCache.onOnline())})},t.unmount=function(){var e,t;null==(e=this.unsubscribeFocus)||e.call(this),null==(t=this.unsubscribeOnline)||t.call(this)},t.isFetching=function(e,t){var n=(0,i.I6)(e,t)[0];return n.fetching=!0,this.queryCache.findAll(n).length},t.isMutating=function(e){return this.mutationCache.findAll((0,r.Z)({},e,{fetching:!0})).length},t.getQueryData=function(e,t){var n;return null==(n=this.queryCache.find(e,t))?void 0:n.state.data},t.getQueriesData=function(e){return this.getQueryCache().findAll(e).map(function(e){return[e.queryKey,e.state.data]})},t.setQueryData=function(e,t,n){var r=(0,i._v)(e),s=this.defaultQueryOptions(r);return this.queryCache.build(this,s).setData(t,n)},t.setQueriesData=function(e,t,n){var r=this;return o.V.batch(function(){return r.getQueryCache().findAll(e).map(function(e){var i=e.queryKey;return[i,r.setQueryData(i,t,n)]})})},t.getQueryState=function(e,t){var n;return null==(n=this.queryCache.find(e,t))?void 0:n.state},t.removeQueries=function(e,t){var n=(0,i.I6)(e,t)[0],r=this.queryCache;o.V.batch(function(){r.findAll(n).forEach(function(e){r.remove(e)})})},t.resetQueries=function(e,t,n){var s=this,a=(0,i.I6)(e,t,n),l=a[0],u=a[1],c=this.queryCache,h=(0,r.Z)({},l,{active:!0});return o.V.batch(function(){return c.findAll(l).forEach(function(e){e.reset()}),s.refetchQueries(h,u)})},t.cancelQueries=function(e,t,n){var r=this,s=(0,i.I6)(e,t,n),a=s[0],l=s[1],u=void 0===l?{}:l;return void 0===u.revert&&(u.revert=!0),Promise.all(o.V.batch(function(){return r.queryCache.findAll(a).map(function(e){return e.cancel(u)})})).then(i.ZT).catch(i.ZT)},t.invalidateQueries=function(e,t,n){var s,a,l,u=this,c=(0,i.I6)(e,t,n),h=c[0],d=c[1],f=(0,r.Z)({},h,{active:null==(s=null!=(a=h.refetchActive)?a:h.active)||s,inactive:null!=(l=h.refetchInactive)&&l});return o.V.batch(function(){return u.queryCache.findAll(h).forEach(function(e){e.invalidate()}),u.refetchQueries(f,d)})},t.refetchQueries=function(e,t,n){var s=this,a=(0,i.I6)(e,t,n),l=a[0],u=a[1],c=Promise.all(o.V.batch(function(){return s.queryCache.findAll(l).map(function(e){return e.fetch(void 0,(0,r.Z)({},u,{meta:{refetchPage:null==l?void 0:l.refetchPage}}))})})).then(i.ZT);return(null==u?void 0:u.throwOnError)||(c=c.catch(i.ZT)),c},t.fetchQuery=function(e,t,n){var r=(0,i._v)(e,t,n),s=this.defaultQueryOptions(r);void 0===s.retry&&(s.retry=!1);var o=this.queryCache.build(this,s);return o.isStaleByTime(s.staleTime)?o.fetch(s):Promise.resolve(o.state.data)},t.prefetchQuery=function(e,t,n){return this.fetchQuery(e,t,n).then(i.ZT).catch(i.ZT)},t.fetchInfiniteQuery=function(e,t,n){var r=(0,i._v)(e,t,n);return r.behavior={onFetch:function(e){e.fetchFn=function(){var t,n,r,s,o,a,u,c=null==(t=e.fetchOptions)?void 0:null==(n=t.meta)?void 0:n.refetchPage,h=null==(r=e.fetchOptions)?void 0:null==(s=r.meta)?void 0:s.fetchMore,d=null==h?void 0:h.pageParam,f=(null==h?void 0:h.direction)==="forward",p=(null==h?void 0:h.direction)==="backward",m=(null==(o=e.state.data)?void 0:o.pages)||[],y=(null==(a=e.state.data)?void 0:a.pageParams)||[],v=(0,i.G9)(),w=null==v?void 0:v.signal,b=y,_=!1,I=e.options.queryFn||function(){return Promise.reject("Missing queryFn")},E=function(e,t,n,r){return b=r?[t].concat(b):[].concat(b,[t]),r?[n].concat(e):[].concat(e,[n])},T=function(t,n,r,i){if(_)return Promise.reject("Cancelled");if(void 0===r&&!n&&t.length)return Promise.resolve(t);var s=I({queryKey:e.queryKey,signal:w,pageParam:r,meta:e.meta}),o=Promise.resolve(s).then(function(e){return E(t,r,e,i)});return(0,l.LE)(s)&&(o.cancel=s.cancel),o};if(m.length){if(f){var S=void 0!==d,C=S?d:g(e.options,m);u=T(m,S,C)}else if(p){var x,k=void 0!==d,A=k?d:null==(x=e.options).getPreviousPageParam?void 0:x.getPreviousPageParam(m[0],m);u=T(m,k,A,!0)}else!function(){b=[];var t=void 0===e.options.getNextPageParam;u=!c||!m[0]||c(m[0],0,m)?T([],t,y[0]):Promise.resolve(E([],y[0],m[0]));for(var n=function(n){u=u.then(function(r){if(!c||!m[n]||c(m[n],n,m)){var i=t?y[n]:g(e.options,r);return T(r,t,i)}return Promise.resolve(E(r,y[n],m[n]))})},r=1;r<m.length;r++)n(r)}()}else u=T([]);var R=u.then(function(e){return{pages:e,pageParams:b}});return R.cancel=function(){_=!0,null==v||v.abort(),(0,l.LE)(u)&&u.cancel()},R}}},this.fetchQuery(r)},t.prefetchInfiniteQuery=function(e,t,n){return this.fetchInfiniteQuery(e,t,n).then(i.ZT).catch(i.ZT)},t.cancelMutations=function(){var e=this;return Promise.all(o.V.batch(function(){return e.mutationCache.getAll().map(function(e){return e.cancel()})})).then(i.ZT).catch(i.ZT)},t.resumePausedMutations=function(){return this.getMutationCache().resumePausedMutations()},t.executeMutation=function(e){return this.mutationCache.build(this,e).execute()},t.getQueryCache=function(){return this.queryCache},t.getMutationCache=function(){return this.mutationCache},t.getDefaultOptions=function(){return this.defaultOptions},t.setDefaultOptions=function(e){this.defaultOptions=e},t.setQueryDefaults=function(e,t){var n=this.queryDefaults.find(function(t){return(0,i.yF)(e)===(0,i.yF)(t.queryKey)});n?n.defaultOptions=t:this.queryDefaults.push({queryKey:e,defaultOptions:t})},t.getQueryDefaults=function(e){var t;return e?null==(t=this.queryDefaults.find(function(t){return(0,i.to)(e,t.queryKey)}))?void 0:t.defaultOptions:void 0},t.setMutationDefaults=function(e,t){var n=this.mutationDefaults.find(function(t){return(0,i.yF)(e)===(0,i.yF)(t.mutationKey)});n?n.defaultOptions=t:this.mutationDefaults.push({mutationKey:e,defaultOptions:t})},t.getMutationDefaults=function(e){var t;return e?null==(t=this.mutationDefaults.find(function(t){return(0,i.to)(e,t.mutationKey)}))?void 0:t.defaultOptions:void 0},t.defaultQueryOptions=function(e){if(null==e?void 0:e._defaulted)return e;var t=(0,r.Z)({},this.defaultOptions.queries,this.getQueryDefaults(null==e?void 0:e.queryKey),e,{_defaulted:!0});return!t.queryHash&&t.queryKey&&(t.queryHash=(0,i.Rm)(t.queryKey,t)),t},t.defaultQueryObserverOptions=function(e){return this.defaultQueryOptions(e)},t.defaultMutationOptions=function(e){return(null==e?void 0:e._defaulted)?e:(0,r.Z)({},this.defaultOptions.mutations,this.getMutationDefaults(null==e?void 0:e.mutationKey),e,{_defaulted:!0})},t.clear=function(){this.queryCache.clear(),this.mutationCache.clear()},e}()},1216:function(e,t,n){"use strict";n.d(t,{DV:function(){return u},LE:function(){return a},m4:function(){return c}});var r=n(9852),i=n(68),s=n(2288);function o(e){return Math.min(1e3*Math.pow(2,e),3e4)}function a(e){return"function"==typeof(null==e?void 0:e.cancel)}var l=function(e){this.revert=null==e?void 0:e.revert,this.silent=null==e?void 0:e.silent};function u(e){return e instanceof l}var c=function(e){var t,n,u,c,h=this,d=!1;this.abort=e.abort,this.cancel=function(e){return null==t?void 0:t(e)},this.cancelRetry=function(){d=!0},this.continueRetry=function(){d=!1},this.continue=function(){return null==n?void 0:n()},this.failureCount=0,this.isPaused=!1,this.isResolved=!1,this.isTransportCancelable=!1,this.promise=new Promise(function(e,t){u=e,c=t});var f=function(t){h.isResolved||(h.isResolved=!0,null==e.onSuccess||e.onSuccess(t),null==n||n(),u(t))},p=function(t){h.isResolved||(h.isResolved=!0,null==e.onError||e.onError(t),null==n||n(),c(t))};!function u(){var c;if(!h.isResolved){try{c=e.fn()}catch(e){c=Promise.reject(e)}t=function(e){if(!h.isResolved&&(p(new l(e)),null==h.abort||h.abort(),a(c)))try{c.cancel()}catch(e){}},h.isTransportCancelable=a(c),Promise.resolve(c).then(f).catch(function(t){if(!h.isResolved){var a,l,c=null!=(a=e.retry)?a:3,f=null!=(l=e.retryDelay)?l:o,m="function"==typeof f?f(h.failureCount,t):f,g=!0===c||"number"==typeof c&&h.failureCount<c||"function"==typeof c&&c(h.failureCount,t);if(d||!g){p(t);return}h.failureCount++,null==e.onFail||e.onFail(h.failureCount,t),(0,s.Gh)(m).then(function(){if(!r.j.isFocused()||!i.N.isOnline())return new Promise(function(t){n=t,h.isPaused=!0,null==e.onPause||e.onPause()}).then(function(){n=void 0,h.isPaused=!1,null==e.onContinue||e.onContinue()})}).then(function(){d?p(t):u()})}})}}()}},2943:function(e,t,n){"use strict";n.d(t,{l:function(){return r}});var r=function(){function e(){this.listeners=[]}var t=e.prototype;return t.subscribe=function(e){var t=this,n=e||function(){};return this.listeners.push(n),this.onSubscribe(),function(){t.listeners=t.listeners.filter(function(e){return e!==n}),t.onUnsubscribe()}},t.hasListeners=function(){return this.listeners.length>0},t.onSubscribe=function(){},t.onUnsubscribe=function(){},e}()},6755:function(){},2288:function(e,t,n){"use strict";n.d(t,{A4:function(){return E},G9:function(){return T},Gh:function(){return I},I6:function(){return d},Kp:function(){return u},PN:function(){return a},Q$:function(){return function e(t,n){if(t===n)return t;var r=Array.isArray(t)&&Array.isArray(n);if(r||w(t)&&w(n)){for(var i=r?t.length:Object.keys(t).length,s=r?n:Object.keys(n),o=s.length,a=r?[]:{},l=0,u=0;u<o;u++){var c=r?u:s[u];a[c]=e(t[c],n[c]),a[c]===t[c]&&l++}return i===o&&l===i?t:a}return n}},Rm:function(){return m},SE:function(){return o},VS:function(){return v},X7:function(){return p},ZT:function(){return s},_v:function(){return c},_x:function(){return f},lV:function(){return h},mc:function(){return l},sk:function(){return i},to:function(){return y},yF:function(){return g}});var r=n(7462),i="undefined"==typeof window;function s(){}function o(e,t){return"function"==typeof e?e(t):e}function a(e){return"number"==typeof e&&e>=0&&e!==1/0}function l(e){return Array.isArray(e)?e:[e]}function u(e,t){return Math.max(e+(t||0)-Date.now(),0)}
15function c(e,t,n){return _(e)?"function"==typeof t?(0,r.Z)({},n,{queryKey:e,queryFn:t}):(0,r.Z)({},t,{queryKey:e}):e}function h(e,t,n){return _(e)?"function"==typeof t?(0,r.Z)({},n,{mutationKey:e,mutationFn:t}):(0,r.Z)({},t,{mutationKey:e}):"function"==typeof e?(0,r.Z)({},t,{mutationFn:e}):(0,r.Z)({},e)}function d(e,t,n){return _(e)?[(0,r.Z)({},t,{queryKey:e}),n]:[e||{},t]}function f(e,t){var n=e.active,r=e.exact,i=e.fetching,s=e.inactive,o=e.predicate,a=e.queryKey,l=e.stale;if(_(a)){if(r){if(t.queryHash!==m(a,t.options))return!1}else if(!y(t.queryKey,a))return!1}var u=!0===n&&!0===s||null==n&&null==s?"all":!1===n&&!1===s?"none":(null!=n?n:!s)?"active":"inactive";if("none"===u)return!1;if("all"!==u){var c=t.isActive();if("active"===u&&!c||"inactive"===u&&c)return!1}return("boolean"!=typeof l||t.isStale()===l)&&("boolean"!=typeof i||t.isFetching()===i)&&(!o||!!o(t))}function p(e,t){var n=e.exact,r=e.fetching,i=e.predicate,s=e.mutationKey;if(_(s)){if(!t.options.mutationKey)return!1;if(n){if(g(t.options.mutationKey)!==g(s))return!1}else if(!y(t.options.mutationKey,s))return!1}return("boolean"!=typeof r||"loading"===t.state.status===r)&&(!i||!!i(t))}function m(e,t){return((null==t?void 0:t.queryKeyHashFn)||g)(e)}function g(e){return JSON.stringify(l(e),function(e,t){return w(t)?Object.keys(t).sort().reduce(function(e,n){return e[n]=t[n],e},{}):t})}function y(e,t){return function e(t,n){return t===n||typeof t==typeof n&&!!t&&!!n&&"object"==typeof t&&"object"==typeof n&&!Object.keys(n).some(function(r){return!e(t[r],n[r])})}(l(e),l(t))}function v(e,t){if(e&&!t||t&&!e)return!1;for(var n in e)if(e[n]!==t[n])return!1;return!0}function w(e){if(!b(e))return!1;var t=e.constructor;if(void 0===t)return!0;var n=t.prototype;return!!(b(n)&&n.hasOwnProperty("isPrototypeOf"))}function b(e){return"[object Object]"===Object.prototype.toString.call(e)}function _(e){return"string"==typeof e||Array.isArray(e)}function I(e){return new Promise(function(t){setTimeout(t,e)})}function E(e){Promise.resolve().then(e).catch(function(e){return setTimeout(function(){throw e})})}function T(){if("function"==typeof AbortController)return new AbortController}},8767:function(e,t,n){"use strict";n.d(t,{QueryClient:function(){return r.QueryClient},QueryClientProvider:function(){return i.QueryClientProvider},useMutation:function(){return i.useMutation},useQuery:function(){return i.useQuery},useQueryClient:function(){return i.useQueryClient}});var r=n(6747);n.o(r,"QueryClientProvider")&&n.d(t,{QueryClientProvider:function(){return r.QueryClientProvider}}),n.o(r,"useMutation")&&n.d(t,{useMutation:function(){return r.useMutation}}),n.o(r,"useQuery")&&n.d(t,{useQuery:function(){return r.useQuery}}),n.o(r,"useQueryClient")&&n.d(t,{useQueryClient:function(){return r.useQueryClient}});var i=n(8073)},8073:function(e,t,n){"use strict";n.d(t,{QueryClientProvider:function(){return f},useMutation:function(){return _},useQuery:function(){return R},useQueryClient:function(){return d}});var r,i=n(101),s=n(3935).unstable_batchedUpdates;i.V.setBatchNotifyFunction(s);var o=n(1909),a=console;(0,o.E)(a);var l=n(7294),u=l.createContext(void 0),c=l.createContext(!1);function h(e){return e&&"undefined"!=typeof window?(window.ReactQueryClientContext||(window.ReactQueryClientContext=u),window.ReactQueryClientContext):u}var d=function(){var e=l.useContext(h(l.useContext(c)));if(!e)throw Error("No QueryClient set, use QueryClientProvider to set one");return e},f=function(e){var t=e.client,n=e.contextSharing,r=void 0!==n&&n,i=e.children;l.useEffect(function(){return t.mount(),function(){t.unmount()}},[t]);var s=h(r);return l.createElement(c.Provider,{value:r},l.createElement(s.Provider,{value:t},i))},p=n(7462),m=n(2288),g=n(5068),y=n(1262),v=n(2943),w=function(e){function t(t,n){var r;return(r=e.call(this)||this).client=t,r.setOptions(n),r.bindMethods(),r.updateResult(),r}(0,g.Z)(t,e);var n=t.prototype;return n.bindMethods=function(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)},n.setOptions=function(e){this.options=this.client.defaultMutationOptions(e)},n.onUnsubscribe=function(){if(!this.listeners.length){var e;null==(e=this.currentMutation)||e.removeObserver(this)}},n.onMutationUpdate=function(e){this.updateResult();var t={listeners:!0};"success"===e.type?t.onSuccess=!0:"error"===e.type&&(t.onError=!0),this.notify(t)},n.getCurrentResult=function(){return this.currentResult},n.reset=function(){this.currentMutation=void 0,this.updateResult(),this.notify({listeners:!0})},n.mutate=function(e,t){return this.mutateOptions=t,this.currentMutation&&this.currentMutation.removeObserver(this),this.currentMutation=this.client.getMutationCache().build(this.client,(0,p.Z)({},this.options,{variables:void 0!==e?e:this.options.variables})),this.currentMutation.addObserver(this),this.currentMutation.execute()},n.updateResult=function(){var e=this.currentMutation?this.currentMutation.state:(0,y.R)(),t=(0,p.Z)({},e,{isLoading:"loading"===e.status,isSuccess:"success"===e.status,isError:"error"===e.status,isIdle:"idle"===e.status,mutate:this.mutate,reset:this.reset});this.currentResult=t},n.notify=function(e){var t=this;i.V.batch(function(){t.mutateOptions&&(e.onSuccess?(null==t.mutateOptions.onSuccess||t.mutateOptions.onSuccess(t.currentResult.data,t.currentResult.variables,t.currentResult.context),null==t.mutateOptions.onSettled||t.mutateOptions.onSettled(t.currentResult.data,null,t.currentResult.variables,t.currentResult.context)):e.onError&&(null==t.mutateOptions.onError||t.mutateOptions.onError(t.currentResult.error,t.currentResult.variables,t.currentResult.context),null==t.mutateOptions.onSettled||t.mutateOptions.onSettled(void 0,t.currentResult.error,t.currentResult.variables,t.currentResult.context))),e.listeners&&t.listeners.forEac
15h(function(e){e(t.currentResult)})})},t}(v.l);function b(e,t,n){return"function"==typeof t?t.apply(void 0,n):"boolean"==typeof t?t:!!e}function _(e,t,n){var r=l.useRef(!1),s=l.useState(0)[1],o=(0,m.lV)(e,t,n),a=d(),u=l.useRef();u.current?u.current.setOptions(o):u.current=new w(a,o);var c=u.current.getCurrentResult();l.useEffect(function(){r.current=!0;var e=u.current.subscribe(i.V.batchCalls(function(){r.current&&s(function(e){return e+1})}));return function(){r.current=!1,e()}},[]);var h=l.useCallback(function(e,t){u.current.mutate(e,t).catch(m.ZT)},[]);if(c.error&&b(void 0,u.current.options.useErrorBoundary,[c.error]))throw c.error;return(0,p.Z)({},c,{mutate:h,mutateAsync:c.mutate})}var I=n(9852),E=n(1216),T=function(e){function t(t,n){var r;return(r=e.call(this)||this).client=t,r.options=n,r.trackedProps=[],r.selectError=null,r.bindMethods(),r.setOptions(n),r}(0,g.Z)(t,e);var n=t.prototype;return n.bindMethods=function(){this.remove=this.remove.bind(this),this.refetch=this.refetch.bind(this)},n.onSubscribe=function(){1===this.listeners.length&&(this.currentQuery.addObserver(this),S(this.currentQuery,this.options)&&this.executeFetch(),this.updateTimers())},n.onUnsubscribe=function(){this.listeners.length||this.destroy()},n.shouldFetchOnReconnect=function(){return C(this.currentQuery,this.options,this.options.refetchOnReconnect)},n.shouldFetchOnWindowFocus=function(){return C(this.currentQuery,this.options,this.options.refetchOnWindowFocus)},n.destroy=function(){this.listeners=[],this.clearTimers(),this.currentQuery.removeObserver(this)},n.setOptions=function(e,t){var n=this.options,r=this.currentQuery;if(this.options=this.client.defaultQueryObserverOptions(e),void 0!==this.options.enabled&&"boolean"!=typeof this.options.enabled)throw Error("Expected enabled to be a boolean");this.options.queryKey||(this.options.queryKey=n.queryKey),this.updateQuery();var i=this.hasListeners();i&&x(this.currentQuery,r,this.options,n)&&this.executeFetch(),this.updateResult(t),i&&(this.currentQuery!==r||this.options.enabled!==n.enabled||this.options.staleTime!==n.staleTime)&&this.updateStaleTimeout();var s=this.computeRefetchInterval();i&&(this.currentQuery!==r||this.options.enabled!==n.enabled||s!==this.currentRefetchInterval)&&this.updateRefetchInterval(s)},n.getOptimisticResult=function(e){var t=this.client.defaultQueryObserverOptions(e),n=this.client.getQueryCache().build(this.client,t);return this.createResult(n,t)},n.getCurrentResult=function(){return this.currentResult},n.trackResult=function(e,t){var n=this,r={},i=function(e){n.trackedProps.includes(e)||n.trackedProps.push(e)};return Object.keys(e).forEach(function(t){Object.defineProperty(r,t,{configurable:!1,enumerable:!0,get:function(){return i(t),e[t]}})}),(t.useErrorBoundary||t.suspense)&&i("error"),r},n.getNextResult=function(e){var t=this;return new Promise(function(n,r){var i=t.subscribe(function(t){t.isFetching||(i(),t.isError&&(null==e?void 0:e.throwOnError)?r(t.error):n(t))})})},n.getCurrentQuery=function(){return this.currentQuery},n.remove=function(){this.client.getQueryCache().remove(this.currentQuery)},n.refetch=function(e){return this.fetch((0,p.Z)({},e,{meta:{refetchPage:null==e?void 0:e.refetchPage}}))},n.fetchOptimistic=function(e){var t=this,n=this.client.defaultQueryObserverOptions(e),r=this.client.getQueryCache().build(this.client,n);return r.fetch().then(function(){return t.createResult(r,n)})},n.fetch=function(e){var t=this;return this.executeFetch(e).then(function(){return t.updateResult(),t.currentResult})},n.executeFetch=function(e){this.updateQuery();var t=this.currentQuery.fetch(this.options,e);return(null==e?void 0:e.throwOnError)||(t=t.catch(m.ZT)),t},n.updateStaleTimeout=function(){var e=this;if(this.clearStaleTimeout(),!m.sk&&!this.currentResult.isStale&&(0,m.PN)(this.options.staleTime)){var t=(0,m.Kp)(this.currentResult.dataUpdatedAt,this.options.staleTime);this.staleTimeoutId=setTimeout(function(){e.currentResult.isStale||e.updateResult()},t+1)}},n.computeRefetchInterval=function(){var e;return"function"==typeof this.options.refetchInterval?this.options.refetchInterval(this.currentResult.data,this.currentQuery):null!=(e=this.options.refetchInterval)&&e},n.updateRefetchInterval=function(e){var t=this;this.clearRefetchInterval(),this.currentRefetchInterval=e,!m.sk&&!1!==this.options.enabled&&(0,m.PN)(this.currentRefetchInterval)&&0!==this.currentRefetchInterval&&(this.refetchIntervalId=setInterval(function(){(t.options.refetchIntervalInBackgroun
15d||I.j.isFocused())&&t.executeFetch()},this.currentRefetchInterval))},n.updateTimers=function(){this.updateStaleTimeout(),this.updateRefetchInterval(this.computeRefetchInterval())},n.clearTimers=function(){this.clearStaleTimeout(),this.clearRefetchInterval()},n.clearStaleTimeout=function(){this.staleTimeoutId&&(clearTimeout(this.staleTimeoutId),this.staleTimeoutId=void 0)},n.clearRefetchInterval=function(){this.refetchIntervalId&&(clearInterval(this.refetchIntervalId),this.refetchIntervalId=void 0)},n.createResult=function(e,t){var n,r,i=this.currentQuery,s=this.options,a=this.currentResult,l=this.currentResultState,u=this.currentResultOptions,c=e!==i,h=c?e.state:this.currentQueryInitialState,d=c?this.currentResult:this.previousQueryResult,f=e.state,p=f.dataUpdatedAt,g=f.error,y=f.errorUpdatedAt,v=f.isFetching,w=f.status,b=!1,_=!1;if(t.optimisticResults){var I=this.hasListeners(),E=!I&&S(e,t),T=I&&x(e,i,t,s);(E||T)&&(v=!0,p||(w="loading"))}if(t.keepPreviousData&&!f.dataUpdateCount&&(null==d?void 0:d.isSuccess)&&"error"!==w)n=d.data,p=d.dataUpdatedAt,w=d.status,b=!0;else if(t.select&&void 0!==f.data){if(a&&f.data===(null==l?void 0:l.data)&&t.select===this.selectFn)n=this.selectResult;else try{this.selectFn=t.select,n=t.select(f.data),!1!==t.structuralSharing&&(n=(0,m.Q$)(null==a?void 0:a.data,n)),this.selectResult=n,this.selectError=null}catch(e){(0,o.j)().error(e),this.selectError=e}}else n=f.data;if(void 0!==t.placeholderData&&void 0===n&&("loading"===w||"idle"===w)){if((null==a?void 0:a.isPlaceholderData)&&t.placeholderData===(null==u?void 0:u.placeholderData))r=a.data;else if(r="function"==typeof t.placeholderData?t.placeholderData():t.placeholderData,t.select&&void 0!==r)try{r=t.select(r),!1!==t.structuralSharing&&(r=(0,m.Q$)(null==a?void 0:a.data,r)),this.selectError=null}catch(e){(0,o.j)().error(e),this.selectError=e}void 0!==r&&(w="success",n=r,_=!0)}return this.selectError&&(g=this.selectError,n=this.selectResult,y=Date.now(),w="error"),{status:w,isLoading:"loading"===w,isSuccess:"success"===w,isError:"error"===w,isIdle:"idle"===w,data:n,dataUpdatedAt:p,error:g,errorUpdatedAt:y,failureCount:f.fetchFailureCount,errorUpdateCount:f.errorUpdateCount,isFetched:f.dataUpdateCount>0||f.errorUpdateCount>0,isFetchedAfterMount:f.dataUpdateCount>h.dataUpdateCount||f.errorUpdateCount>h.errorUpdateCount,isFetching:v,isRefetching:v&&"loading"!==w,isLoadingError:"error"===w&&0===f.dataUpdatedAt,isPlaceholderData:_,isPreviousData:b,isRefetchError:"error"===w&&0!==f.dataUpdatedAt,isStale:k(e,t),refetch:this.refetch,remove:this.remove}},n.shouldNotifyListeners=function(e,t){if(!t)return!0;var n=this.options,r=n.notifyOnChangeProps,i=n.notifyOnChangePropsExclusions;if(!r&&!i||"tracked"===r&&!this.trackedProps.length)return!0;var s="tracked"===r?this.trackedProps:r;return Object.keys(e).some(function(n){var r=e[n]!==t[n],o=null==s?void 0:s.some(function(e){return e===n}),a=null==i?void 0:i.some(function(e){return e===n});return r&&!a&&(!s||o)})},n.updateResult=function(e){var t=this.currentResult;if(this.currentResult=this.createResult(this.currentQuery,this.options),this.currentResultState=this.currentQuery.state,this.currentResultOptions=this.options,!(0,m.VS)(this.currentResult,t)){var n={cache:!0};(null==e?void 0:e.listeners)!==!1&&this.shouldNotifyListeners(this.currentResult,t)&&(n.listeners=!0),this.notify((0,p.Z)({},n,e))}},n.updateQuery=function(){var e=this.client.getQueryCache().build(this.client,this.options);if(e!==this.currentQuery){var t=this.currentQuery;this.currentQuery=e,this.currentQueryInitialState=e.state,this.previousQueryResult=this.currentResult,this.hasListeners()&&(null==t||t.removeObserver(this),e.addObserver(this))}},n.onQueryUpdate=function(e){var t={};"success"===e.type?t.onSuccess=!0:"error"!==e.type||(0,E.DV)(e.error)||(t.onError=!0),this.updateResult(t),this.hasListeners()&&this.updateTimers()},n.notify=function(e){var t=this;i.V.batch(function(){e.onSuccess?(null==t.options.onSuccess||t.options.onSuccess(t.currentResult.data),null==t.options.onSettled||t.options.onSettled(t.currentResult.data,null)):e.onError&&(null==t.options.onError||t.options.onError(t.currentResult.error),null==t.options.onSettled||t.options.onSettled(void 0,t.currentResult.error)),e.listeners&&t.listeners.forEac
15h(function(e){e(t.currentResult)}),e.cache&&t.client.getQueryCache().notify({query:t.currentQuery,type:"observerResultsUpdated"})})},t}(v.l);function S(e,t){return!1!==t.enabled&&!e.state.dataUpdatedAt&&!("error"===e.state.status&&!1===t.retryOnMount)||e.state.dataUpdatedAt>0&&C(e,t,t.refetchOnMount)}function C(e,t,n){if(!1!==t.enabled){var r="function"==typeof n?n(e):n;return"always"===r||!1!==r&&k(e,t)}return!1}function x(e,t,n,r){return!1!==n.enabled&&(e!==t||!1===r.enabled)&&(!n.suspense||"error"!==e.state.status)&&k(e,n)}function k(e,t){return e.isStaleByTime(t.staleTime)}var A=l.createContext((r=!1,{clearReset:function(){r=!1},reset:function(){r=!0},isReset:function(){return r}}));function R(e,t,n){return function(e,t){var n=l.useRef(!1),r=l.useState(0)[1],s=d(),o=l.useContext(A),a=s.defaultQueryObserverOptions(e);a.optimisticResults=!0,a.onError&&(a.onError=i.V.batchCalls(a.onError)),a.onSuccess&&(a.onSuccess=i.V.batchCalls(a.onSuccess)),a.onSettled&&(a.onSettled=i.V.batchCalls(a.onSettled)),a.suspense&&("number"!=typeof a.staleTime&&(a.staleTime=1e3),0===a.cacheTime&&(a.cacheTime=1)),(a.suspense||a.useErrorBoundary)&&!o.isReset()&&(a.retryOnMount=!1);var u=l.useState(function(){return new t(s,a)})[0],c=u.getOptimisticResult(a);if(l.useEffect(function(){n.current=!0,o.clearReset();var e=u.subscribe(i.V.batchCalls(function(){n.current&&r(function(e){return e+1})}));return u.updateResult(),function(){n.current=!1,e()}},[o,u]),l.useEffect(function(){u.setOptions(a,{listeners:!1})},[a,u]),a.suspense&&c.isLoading)throw u.fetchOptimistic(a).then(function(e){var t=e.data;null==a.onSuccess||a.onSuccess(t),null==a.onSettled||a.onSettled(t,null)}).catch(function(e){o.clearReset(),null==a.onError||a.onError(e),null==a.onSettled||a.onSettled(void 0,e)});if(c.isError&&!o.isReset()&&!c.isFetching&&b(a.suspense,a.useErrorBoundary,[c.error,u.getCurrentQuery()]))throw c.error;return"tracked"===a.notifyOnChangeProps&&(c=u.trackResult(c,a)),c}((0,m._v)(e,t,n),T)}},7462:function(e,t,n){"use strict";function r(){return(r=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(null,arguments)}n.d(t,{Z:function(){return r}})},5068:function(e,t,n){"use strict";function r(e,t){return(r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function i(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,r(e,t)}n.d(t,{Z:function(){return i}})},2238:function(e,t,n){"use strict";n.d(t,{C6:function(){return C},Jn:function(){return E},KN:function(){return x},Mq:function(){return S},Xd:function(){return y},ZF:function(){return T},qX:function(){return v},rh:function(){return b},wN:function(){return w}});var r=n(8463),i=n(3333),s=n(1683),o=n(6531);class a{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(e=>{if(!function(e){let t=e.getComponent();return(null==t?void 0:t.type)==="VERSION"}(e))return null;{let t=e.getImmediate();return`${t.library}/${t.version}`}}).filter(e=>e).join(" ")}}let l="@firebase/app",u="0.13.1",c=new i.Yd("@firebase/app"),h="[DEFAULT]",d={[l]:"fire-core","@firebase/app-compat":"fire-core-compat","@firebase/analytics":"fire-analytics","@firebase/analytics-compat":"fire-analytics-compat","@firebase/app-check":"fire-app-check","@firebase/app-check-compat":"fire-app-check-compat","@firebase/auth":"fire-auth","@firebase/auth-compat":"fire-auth-compat","@firebase/database":"fire-rtdb","@firebase/data-connect":"fire-data-connect","@firebase/database-compat":"fire-rtdb-compat","@firebase/functions":"fire-fn","@firebase/functions-compat":"fire-fn-compat","@firebase/installations":"fire-iid","@firebase/installations-compat":"fire-iid-compat","@firebase/messaging":"fire-fcm","@firebase/messaging-compat":"fire-fcm-compat","@firebase/performance":"fire-perf","@firebase/performance-compat":"fire-perf-compat","@firebase/remote-config":"fire-rc","@firebase/remote-config-compat":"fire-rc-compat","@firebase/storage":"fire-gcs","@firebase/storage-compat":"fire-gcs-compat","@firebase/firestore":"fire-fst","@firebase/firestore-compat":"fire-fst-compat","@firebase/ai":"fire-vertex","fire-js":"fire-js",firebase:"fire-js-all"},f=new Map,p=new Map,m=new Map;function g(e,t){try{e.container.addComponent(t)}catch(n){c.debug(`Component ${t.name} failed to register with FirebaseApp ${e.name}`,n)}}function y(e){let t=e.name;if(m.has(t))return c.debug(`There were multiple attempts to register component ${t}.`),!1;
15for(let n of(m.set(t,e),f.values()))g(n,e);for(let t of p.values())g(t,e);return!0}function v(e,t){let n=e.container.getProvider("heartbeat").getImmediate({optional:!0});return n&&n.triggerHeartbeat(),e.container.getProvider(t)}function w(e,t,n=h){v(e,t).clearInstance(n)}function b(e){return null!=e&&void 0!==e.settings}let _=new s.LL("app","Firebase",{"no-app":"No Firebase App '{$appName}' has been created - call initializeApp() first","bad-app-name":"Illegal App name: '{$appName}'","duplicate-app":"Firebase App named '{$appName}' already exists with different options or config","app-deleted":"Firebase App named '{$appName}' already deleted","server-app-deleted":"Firebase Server App has been deleted","no-options":"Need to provide options, when not being deployed to hosting via source.","invalid-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance.","invalid-log-argument":"First argument to `onLog` must be null or a function.","idb-open":"Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.","idb-get":"Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.","idb-set":"Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.","idb-delete":"Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.","finalization-registry-not-supported":"FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.","invalid-server-app-environment":"FirebaseServerApp is not for use in browser environments."});class I{constructor(e,t,n){this._isDeleted=!1,this._options=Object.assign({},e),this._config=Object.assign({},t),this._name=t.name,this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled,this._container=n,this.container.addComponent(new r.wA("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 _.create("app-deleted",{appName:this._name})}}let E="11.9.0";function T(e,t={}){let n=e;"object"!=typeof t&&(t={name:t});let i=Object.assign({name:h,automaticDataCollectionEnabled:!0},t),o=i.name;if("string"!=typeof o||!o)throw _.create("bad-app-name",{appName:String(o)});if(n||(n=(0,s.aH)()),!n)throw _.create("no-options");let a=f.get(o);if(a){if((0,s.vZ)(n,a.options)&&(0,s.vZ)(i,a.config))return a;throw _.create("duplicate-app",{appName:o})}let l=new r.H0(o);for(let e of m.values())l.addComponent(e);let u=new I(n,i,l);return f.set(o,u),u}function S(e=h){let t=f.get(e);if(!t&&e===h&&(0,s.aH)())return T();if(!t)throw _.create("no-app",{appName:e});return t}function C(){return Array.from(f.values())}function x(e,t,n){var i;let s=null!==(i=d[e])&&void 0!==i?i:e;n&&(s+=`-${n}`);let o=s.match(/\s|\//),a=t.match(/\s|\//);if(o||a){let e=[`Unable to register library "${s}" with version "${t}":`];o&&e.push(`library name "${s}" contains illegal characters (whitespace or "/")`),o&&a&&e.push("and"),a&&e.push(`version name "${t}" contains illegal characters (whitespace or "/")`),c.warn(e.join(" "));return}y(new r.wA(`${s}-version`,()=>({library:s,version:t}),"VERSION"))}let k="firebase-heartbeat-store",A=null;function R(){return A||(A=(0,o.X3)("firebase-heartbeat-database",1,{upgrade:(e,t)=>{if(0===t)try{e.createObjectStore(k)}catch(e){console.warn(e)}}}).catch(e=>{throw _.create("idb-open",{originalErrorMessage:e.message})})),A}async function N(e){try{let t=(await R()).transaction(k),n=await t.objectStore(k).get(D(e));return await t.done,n}catch(e){if(e instanceof s.ZR)c.warn(e.message);else{let t=_.create("idb-get",{originalErrorMessage:null==e?void 0:e.message});c.warn(t.message)}}}async function O(e,t){try{let n=(await R()).transaction(k,"readwrite"),r=n.objectStore(k);await r.put(t,D(e)),await n.done}catch(e){if(e instanceof s.ZR)c.warn(e.message);else{let t=_.create("idb-set",{originalErrorMessage:null==e?void 0:e.message});c.warn(t.message)}}}function D(e){return`${e.name}!${e.options.appId}`}class P{constructor(e){this.container=e,this._heartbeatsCache=null;let t=this.container.getProvider("app").getImmediate();this._storage=new M(t),this._heartbeatsCachePromise=this._storage.read().then(e=>(this._heartbeatsCache=e,e))}async triggerHeartbeat(){var e,t;try{let n=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),r=L();if((null===(e=this._heartbeatsCache)||void 0===e?void 0:e.heartbeats)==null&&(this._heartbeatsCache=await this._heartbeatsCachePromise,(null===(t=this._heartbeatsCache)||void 0===t?void 0:t.heartbeats)==null)||this._heartbeatsCache.lastSentHeartbeatDate===r||this._heartbeatsCache.heartbeats.some(e=>e.date===r))return;if(this._heartbeatsCache.heartbeats.push({date:r,agent:n}),this._heartbeatsCache.heartbeats.length>30){let e=function(e){if(0===e.length)return -1;let t=0,n=e[0].date;for(let r=1;r<e.length;r++)e[r].date<n&&(n=e[r].date,t=r);return t}(this._heartbeatsCache.heartbeats);this._heartbeatsCache.heartbeats.splice(e,1)}return this._storage.overwrite(this._heartbeatsCache)}catch(e){c.warn(e)}}async getHeartbeatsHeader(){var e;try{if(null===this._heartbeatsCache&&await this._heartbeatsCachePromise,(null===(e=this._heartbeatsCache)||void 0===e?void 0:e.heartbeats)==null||0===this._heartbeatsCache.heartbeats.length)return"";let t=L(),{heartbeatsToSend:n,unsentEntries:r}=function(e,t=1024){let n=[],r=e.slice();for(let i of e){let e=n.find(e=>e.agent===i.agent);if(e){if(e.dates.push(i.date),F(n)>t){e.dates.pop();break}}else if(n.push({agent:i.agent,dates:[i.date]}),F(n)>t){n.pop();break}r=r.slice(1)}return{heartbeatsToSend:n,unsentEntries:r}}(this._heartbeatsCache.heartbeats),i=(0,s.L)(JSON.stringify({version:2,heartbeats:n}));return this._heartbeatsCache.lastSentHeartbeatDate=t,r.length>0?(this._heartbeatsCache.heartbeats=r,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),i}catch(e){return c.warn(e),""}}}function L(){return new Date().toISOString().substring(0,10)}class M{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return!!(0,s.hl)()&&(0,s.eu)().then(()=>!0).catch(()=>!1)}async read(){if(!await this._canUseIndexedDBPromise)return{heartbeats:[]};{let e=await N(this.app);return(null==e?void 0:e.heartbeats)?e:{heartbeats:[]}}}async overwrite(e){var t;if(await this._canUseIndexedDBPromise){let n=await this.read();return O(this.app,{lastSentHeartbeatDate:null!==(t=e.lastSentHeartbeatDate)&&void 0!==t?t:n.lastSentHeartbeatDate,heartbeats:e.heartbeats})}}async add(e){var t;if(await this._canUseIndexedDBPromise){let n=await this.read();return O(this.app,{lastSentHeartbeatDate:null!==(t=e.lastSentHeartbeatDate)&&void 0!==t?t:n.lastSentHeartbeatDate,heartbeats:[...n.heartbeats,...e.heartbeats]})}}}function F(e){return(0,s.L)(JSON.stringify({version:2,heartbeats:e})).length}y(new r.wA("platform-logger",e=>new a(e),"PRIVATE")),y(new r.wA("heartbeat",e=>new P(e),"PRIVATE")),x(l,u,""),x(l,u,"esm2017"),x("fire-js","")},8463:function(e,t,n){"use strict";n.d(t,{H0:function(){return a},wA:function(){return i}});var r=n(1683);class i{constructor(e,t,n){this.name=e,this.instanceFactory=t,this.type=n,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(e){return this.instantiationMode=e,this}setMultipleInstances(e){return this.multipleInstances=e,this}setServiceProps(e){return this.serviceProps=e,this}setInstanceCreatedCallback(e){return this.onInstanceCreated=e,this}}let s="[DEFAULT]";class o{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){let t=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(t)){let e=new r.BH;if(this.instancesDeferred.set(t,e),this.isInitialized(t)||this.shouldAutoInitialize())try{let n=this.getOrInitializeService({instanceIdentifier:t});n&&e.resolve(n)}catch(e){}}return this.instancesDeferred.get(t).promise}getImmediate(e){var t;let n=this.normalizeInstanceIdentifier(null==e?void 0:e.identifier),r=null!==(t=null==e?void 0:e.optional)&&void 0!==t&&t;if(this.isInitialized(n)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:n})}catch(e){if(r)return null;throw e}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("EAGER"===e.instantiationMode)try{this.getOrInitializeService({instanceIdentifier:s})}catch(e){}for(let[e,t]of this.instancesDeferred.entries()){let n=this.normalizeInstanceIdentifier(e);try{let e=this.getOrInitializeService({instanceIdentifier:n});t.resolve(e)}catch(e){}}}}clearInstance(e=s){this.instancesDeferred.delete(e),this.instancesOptions.delete(e),this.instances.delete(e)}async delete(){let e=Array.from(this.instances.values());await Promise.all([...e.filter(e=>"INTERNAL"in e).map(e=>e.INTERNAL.delete()),...e.filter(e=>"_delete"in e).map(e=>e._delete())])}isComponentSet(){return null!=this.component}isInitialized(e=s){return this.instances.has(e)}getOptions(e=s){return this.instancesOptions.get(e)||{}}initialize(e={}){let{options:t={}}=e,n=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(n))throw Error(`${this.name}(${n}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);let r=this.getOrInitializeService({instanceIdentifier:n,options:t});for(let[e,t]of this.instancesDeferred.entries())n===this.normalizeInstanceIdentifier(e)&&t.resolve(r);return r}onInit(e,t){var n;let r=this.normalizeInstanceIdentifier(t),i=null!==(n=this.onInitCallbacks.get(r))&&void 0!==n?n:new Set;i.add(e),this.onInitCallbacks.set(r,i);let s=this.instances.get(r);return s&&e(s,r),()=>{i.delete(e)}}invokeOnInitCallbacks(e,t){let n=this.onInitCallbacks.get(t);if(n)for(let r of n)try{r(e,t)}catch(e){}}getOrInitializeService({instanceIdentifier:e,options:t={}}){let n=this.instances.get(e);if(!n&&this.component&&(n=this.component.instanceFactory(this.container,{instanceIdentifier:e===s?void 0:e,options:t}),this.instances.set(e,n),this.instancesOptions.set(e,t),this.invokeOnInitCallbacks(n,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,n)}catch(e){}return n||null}normalizeInstanceIdentifier(e=s){return this.component?this.component.multipleInstances?e:s:e}shouldAutoInitialize(){return!!this.component&&"EXPLICIT"!==this.component.instantiationMode}}class a{constructor(e){this.name=e,this.providers=new Map}addComponent(e){let t=this.getProvider(e.name);if(t.isComponentSet())throw 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);let t=new o(e,this);return this.providers.set(e,t),t}getProviders(){return Array.from(this.providers.values())}}},3333:function(e,t,n){"use strict";var r,i;n.d(t,{Yd:function(){return c},in:function(){return r}});let s=[];(i=r||(r={}))[i.DEBUG=0]="DEBUG",i[i.VERBOSE=1]="VERBOSE",i[i.INFO=2]="INFO",i[i.WARN=3]="WARN",i[i.ERROR=4]="ERROR",i[i.SILENT=5]="SILENT";let o={debug:r.DEBUG,verbose:r.VERBOSE,info:r.INFO,warn:r.WARN,error:r.ERROR,silent:r.SILENT},a=r.INFO,l={[r.DEBUG]:"log",[r.VERBOSE]:"log",[r.INFO]:"info",[r.WARN]:"warn",[r.ERROR]:"error"},u=(e,t,...n)=>{if(t<e.logLevel)return;let r=new Date().toISOString(),i=l[t];if(i)console[i](`[${r}] ${e.name}:`,...n);
15else throw Error(`Attempted to log a message with an invalid logType (value: ${t})`)};class c{constructor(e){this.name=e,this._logLevel=a,this._logHandler=u,this._userLogHandler=null,s.push(this)}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in r))throw TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel="string"==typeof e?o[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if("function"!=typeof e)throw 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,r.DEBUG,...e),this._logHandler(this,r.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,r.VERBOSE,...e),this._logHandler(this,r.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,r.INFO,...e),this._logHandler(this,r.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,r.WARN,...e),this._logHandler(this,r.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,r.ERROR,...e),this._logHandler(this,r.ERROR,...e)}}},4830:function(e,t,n){"use strict";n.d(t,{hJ:function(){return e4},LG:function(){return tc},Xb:function(){return tf},v0:function(){return nN},Aj:function(){return ty},LS:function(){return tu},e5:function(){return tp},rh:function(){return t1},w7:function(){return tv},ck:function(){return tg},TX:function(){return td}});var r,i=n(2238),s=n(1683),o=n(3333);function a(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&0>t.indexOf(r)&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)0>t.indexOf(r[i])&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}"function"==typeof SuppressedError&&SuppressedError;var l=n(8463);function u(){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."}}let c=new s.LL("auth","Firebase",u()),h=new o.Yd("@firebase/auth");function d(e,...t){h.logLevel<=o.in.ERROR&&h.error(`Auth (${i.Jn}): ${e}`,...t)}function f(e,...t){throw y(e,...t)}function p(e,...t){return y(e,...t)}function m(e,t,n){let r=Object.assign(Object.assign({},u()),{[t]:n});return new s.LL("auth","Firebase",r).create(t,{appName:e.name})}function g(e){return m(e,"operation-not-supported-in-this-environment","Operations that alter the current user are not supported in conjunction with FirebaseServerApp")}function y(e,...t){if("string"!=typeof e){let n=t[0],r=[...t.slice(1)];return r[0]&&(r[0].appName=e.name),e._errorFactory.create(n,...r)}return c.create(e,...t)}function v(e,t,...n){if(!e)throw y(t,...n)}function w(e){let t="INTERNAL ASSERTION FAILED: "+e;throw d(t),Error(t)}function b(){var e;return"undefined"!=typeof self&&(null===(e=self.location)||void 0===e?void 0:e.href)||""}function _(){var e;return"undefined"!=typeof self&&(null===(e=self.location)||void 0===e?void 0:e.protocol)||null}class I{constructor(e,t){var n;this.shortDelay=e,this.longDelay=t,n="Short delay should be less than long delay!",t>e||w(n),this.isMobile=(0,s.uI)()||(0,s.b$)()}get(){return!("undefined"!=typeof navigator&&navigator&&"onLine"in navigator&&"boolean"==typeof navigator.onLine&&("http:"===_()||"https:"===_()||(0,s.ru)()||"connection"in navigator))||navigator.onLine?this.isMobile?this.longDelay:this.shortDelay:Math.min(5e3,this.shortDelay)}}function E(e,t){var n,r;n=e.emulator,r="Emulator should always be set here",n||w(r);let{url:i}=e.emulator;return t?`${i}${t.startsWith("/")?t.slice(1):t}`:i}class T{static initialize(e,t,n){this.fetchImpl=e,t&&(this.headersImpl=t),n&&(this.responseImpl=n)}static fetch(){return this.fetchImpl?this.fetchImpl:"undefined"!=typeof self&&"fetch"in self?self.fetch:"undefined"!=typeof globalThis&&globalThis.fetch?globalThis.fetch:"undefined"!=typeof fetch?fetch:void w("Could not find fetch implementation, make sure you call FetchProvi
15der.initialize() with an appropriate polyfill")}static headers(){return this.headersImpl?this.headersImpl:"undefined"!=typeof self&&"Headers"in self?self.Headers:"undefined"!=typeof globalThis&&globalThis.Headers?globalThis.Headers:"undefined"!=typeof Headers?Headers:void w("Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static response(){return this.responseImpl?this.responseImpl:"undefined"!=typeof self&&"Response"in self?self.Response:"undefined"!=typeof globalThis&&globalThis.Response?globalThis.Response:"undefined"!=typeof Response?Response:void w("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}}let S={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"},C=["/v1/accounts:signInWithCustomToken","/v1/accounts:signInWithEmailLink","/v1/accounts:signInWithIdp","/v1/accounts:signInWithPassword","/v1/accounts:signInWithPhoneNumber","/v1/token"],x=new I(3e4,6e4);function k(e,t){return e.tenantId&&!t.tenantId?Object.assign(Object.assign({},t),{tenantId:e.tenantId}):t}async function A(e,t,n,r,i={}){return R(e,i,async()=>{let i={},o={};r&&("GET"===t?o=r:i={body:JSON.stringify(r)});let a=(0,s.xO)(Object.assign({key:e.config.apiKey},o)).slice(1),l=await e._getAdditionalHeaders();l["Content-Type"]="application/json",e.languageCode&&(l["X-Firebase-Locale"]=e.languageCode);let u=Object.assign({method:t,headers:l},i);return(0,s.L_)()||(u.referrerPolicy="no-referrer"),e.emulatorConfig&&(0,s.Xx)(e.emulatorConfig.host)&&(u.credentials="include"),T.fetch()(await O(e,e.config.apiHost,n,a),u)})}async function R(e,t,n){e._canInitEmulator=!1;let r=Object.assign(Object.assign({},S),t);try{let t=new D(e),i=await Promise.race([n(),t.promise]);t.clearNetworkTimeout();let s=await i.json();if("needConfirmation"in s)throw P(e,"account-exists-with-different-credential",s);if(i.ok&&!("errorMessage"in s))return s;{let[t,n]=(i.ok?s.errorMessage:s.error.message).split(" : ");if("FEDERATED_USER_ID_ALREADY_LINKED"===t)throw P(e,"credential-already-in-use",s);if("EMAIL_EXISTS"===t)throw P(e,"email-already-in-use",s);if("USER_DISABLED"===t)throw P(e,"user-disabled",s);let o=r[t]||t.toLowerCase().replace(/[_\s]+/g,"-");if(n)throw m(e,o,n);f(e,o)}}catch(t){if(t instanceof s.ZR)throw t;f(e,"network-request-failed",{message:String(t)})}}async function N(e,t,n,r,i={}){let s=await A(e,t,n,r,i);return"mfaPendingCredential"in s&&f(e,"multi-factor-auth-required",{_serverResponse:s}),s}async function O(e,t,n,r){let i=`${t}${n}?${r}`,s=e.config.emulator?E(e.config,i):`${e.config.apiScheme}://${i}`;return C.includes(n)&&(await e._persistenceManagerAvailable,"COOKIE"===e._getPersistenceType())?e._getPersistence()._getFinalTarget(s).toString():s}class D{clearNetworkTimeout(){clearTimeout(this.timer)}constructor(e){this.auth=e,this.timer=null,this.promise=new Promise((e,t)=>
15{this.timer=setTimeout(()=>t(p(this.auth,"network-request-failed")),x.get())})}}function P(e,t,n){let r={appName:e.name};n.email&&(r.email=n.email),n.phoneNumber&&(r.phoneNumber=n.phoneNumber);let i=p(e,t,r);return i.customData._tokenResponse=n,i}function L(e){return void 0!==e&&void 0!==e.enterprise}class M{constructor(e){if(this.siteKey="",this.recaptchaEnforcementState=[],void 0===e.recaptchaKey)throw Error("recaptchaKey undefined");this.siteKey=e.recaptchaKey.split("/")[3],this.recaptchaEnforcementState=e.recaptchaEnforcementState}getProviderEnforcementState(e){if(!this.recaptchaEnforcementState||0===this.recaptchaEnforcementState.length)return null;for(let t of this.recaptchaEnforcementState)if(t.provider&&t.provider===e)return function(e){switch(e){case"ENFORCE":return"ENFORCE";case"AUDIT":return"AUDIT";case"OFF":return"OFF";default:return"ENFORCEMENT_STATE_UNSPECIFIED"}}(t.enforcementState);return null}isProviderEnabled(e){return"ENFORCE"===this.getProviderEnforcementState(e)||"AUDIT"===this.getProviderEnforcementState(e)}isAnyProviderEnabled(){return this.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")||this.isProviderEnabled("PHONE_PROVIDER")}}async function F(e,t){return A(e,"GET","/v2/recaptchaConfig",k(e,t))}async function U(e,t){return A(e,"POST","/v1/accounts:delete",t)}async function V(e,t){return A(e,"POST","/v1/accounts:lookup",t)}function j(e){if(e)try{let t=new Date(Number(e));if(!isNaN(t.getTime()))return t.toUTCString()}catch(e){}}async function B(e,t=!1){let n=(0,s.m9)(e),r=await n.getIdToken(t),i=z(r);v(i&&i.exp&&i.auth_time&&i.iat,n.auth,"internal-error");let o="object"==typeof i.firebase?i.firebase:void 0,a=null==o?void 0:o.sign_in_provider;return{claims:i,token:r,authTime:j(q(i.auth_time)),issuedAtTime:j(q(i.iat)),expirationTime:j(q(i.exp)),signInProvider:a||null,signInSecondFactor:(null==o?void 0:o.sign_in_second_factor)||null}}function q(e){return 1e3*Number(e)}function z(e){let[t,n,r]=e.split(".");if(void 0===t||void 0===n||void 0===r)return d("JWT malformed, contained fewer than 3 sections"),null;try{let e=(0,s.tV)(n);if(!e)return d("Failed to decode base64 JWT payload"),null;return JSON.parse(e)}catch(e){return d("Caught error parsing JWT payload as JSON",null==e?void 0:e.toString()),null}}function $(e){let t=z(e);return v(t,"internal-error"),v(void 0!==t.exp,"internal-error"),v(void 0!==t.iat,"internal-error"),Number(t.exp)-Number(t.iat)}async function K(e,t,n=!1){if(n)return t;try{return await t}catch(t){throw t instanceof s.ZR&&function({code:e}){return"auth/user-disabled"===e||"auth/user-token-expired"===e}(t)&&e.auth.currentUser===e&&await e.auth.signOut(),t}}class G{constructor(e){this.user=e,this.isRunning=!1,this.timerId=null,this.errorBackoff=3e4}_start(){this.isRunning||(this.isRunning=!0,this.schedule())}_stop(){this.isRunning&&(this.isRunning=!1,null!==this.timerId&&clearTimeout(this.timerId))}getInterval(e){var t;if(!e)return this.errorBackoff=3e4,Math.max(0,(null!==(t=this.user.stsTokenManager.expirationTime)&&void 0!==t?t:0)-Date.now()-3e5);{let e=this.errorBackoff;return this.errorBackoff=Math.min(2*this.errorBackoff,96e4),e}}schedule(e=!1){if(!this.isRunning)return;let t=this.getInterval(e);this.timerId=setTimeout(async()=>{await this.iteration()},t)}async iteration(){try{await this.user.getIdToken(!0)}catch(e){(null==e?void 0:e.code)==="auth/network-request-failed"&&this.schedule(!0);return}this.schedule()}}class H{constructor(e,t){this.createdAt=e,this.lastLoginAt=t,this._initializeTime()}_initializeTime(){this.lastSignInTime=j(this.lastLoginAt),this.creationTime=j(this.createdAt)}_copy(e){this.createdAt=e.createdAt,this.lastLoginAt=e.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}async function W(e){var t;let n=e.auth,r=await e.getIdToken(),i=await K(e,V(n,{idToken:r}));v(null==i?void 0:i.users.length,n,"internal-error");let s=i.users[0];e._notifyReloadListener(s);let o=(null===(t=s.providerUserInfo)||void 0===t?void 0:t.length)?X(s.providerUserInfo):[],a=[...e.providerData.filter(e=>!o.some(t=>t.providerId===e.providerId)),...o],l=e.isAnonymous,u=!(e.email&&s.passwordHash)&&!(null==a?void 0:a.length);Object.assign(e,{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 H(s.createdAt,s.lastLoginAt),isAnonymous:!!l&&u})}async function Q(e){let t=(0,s.m9)(e);await W(t),await t.auth._persistUserIfCurrent(t),t.auth._notifyListenersIfCurrent(t)}function X(e){return e.map(e=>{var{providerId:t}=e,n=a(e,["providerId"]);
15return{providerId:t,uid:n.rawId||"",displayName:n.displayName||null,email:n.email||null,phoneNumber:n.phoneNumber||null,photoURL:n.photoUrl||null}})}async function Y(e,t){let n=await R(e,{},async()=>{let n=(0,s.xO)({grant_type:"refresh_token",refresh_token:t}).slice(1),{tokenApiHost:r,apiKey:i}=e.config,o=await O(e,r,"/v1/token",`key=${i}`),a=await e._getAdditionalHeaders();a["Content-Type"]="application/x-www-form-urlencoded";let l={method:"POST",headers:a,body:n};return e.emulatorConfig&&(0,s.Xx)(e.emulatorConfig.host)&&(l.credentials="include"),T.fetch()(o,l)});return{accessToken:n.access_token,expiresIn:n.expires_in,refreshToken:n.refresh_token}}async function J(e,t){return A(e,"POST","/v2/accounts:revokeToken",k(e,t))}class Z{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){v(e.idToken,"internal-error"),v(void 0!==e.idToken,"internal-error"),v(void 0!==e.refreshToken,"internal-error");let t="expiresIn"in e&&void 0!==e.expiresIn?Number(e.expiresIn):$(e.idToken);this.updateTokensAndExpiration(e.idToken,e.refreshToken,t)}updateFromIdToken(e){v(0!==e.length,"internal-error");let t=$(e);this.updateTokensAndExpiration(e,null,t)}async getToken(e,t=!1){return t||!this.accessToken||this.isExpired?(v(this.refreshToken,e,"user-token-expired"),this.refreshToken)?(await this.refresh(e,this.refreshToken),this.accessToken):null:this.accessToken}clearRefreshToken(){this.refreshToken=null}async refresh(e,t){let{accessToken:n,refreshToken:r,expiresIn:i}=await Y(e,t);this.updateTokensAndExpiration(n,r,Number(i))}updateTokensAndExpiration(e,t,n){this.refreshToken=t||null,this.accessToken=e||null,this.expirationTime=Date.now()+1e3*n}static fromJSON(e,t){let{refreshToken:n,accessToken:r,expirationTime:i}=t,s=new Z;return n&&(v("string"==typeof n,"internal-error",{appName:e}),s.refreshToken=n),r&&(v("string"==typeof r,"internal-error",{appName:e}),s.accessToken=r),i&&(v("number"==typeof i,"internal-error",{appName:e}),s.expirationTime=i),s}toJSON(){return{refreshToken:this.refreshToken,accessToken:this.accessToken,expirationTime:this.expirationTime}}_assign(e){this.accessToken=e.accessToken,this.refreshToken=e.refreshToken,this.expirationTime=e.expirationTime}_clone(){return Object.assign(new Z,this.toJSON())}_performRefresh(){return w("not implemented")}}function ee(e,t){v("string"==typeof e||void 0===e,"internal-error",{appName:t})}class et{constructor(e){var{uid:t,auth:n,stsTokenManager:r}=e,i=a(e,["uid","auth","stsTokenManager"]);this.providerId="firebase",this.proactiveRefresh=new G(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=t,this.auth=n,this.stsTokenManager=r,this.accessToken=r.accessToken,this.displayName=i.displayName||null,this.email=i.email||null,this.emailVerified=i.emailVerified||!1,this.phoneNumber=i.phoneNumber||null,this.photoURL=i.photoURL||null,this.isAnonymous=i.isAnonymous||!1,this.tenantId=i.tenantId||null,this.providerData=i.providerData?[...i.providerData]:[],this.metadata=new H(i.createdAt||void 0,i.lastLoginAt||void 0)}async getIdToken(e){let t=await K(this,this.stsTokenManager.getToken(this.auth,e));return v(t,this.auth,"internal-error"),this.accessToken!==t&&(this.accessToken=t,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),t}getIdTokenResult(e){return B(this,e)}reload(){return Q(this)}_assign(e){this!==e&&(v(this.uid===e.uid,this.auth,"internal-error"),this.displayName=e.displayName,this.photoURL=e.photoURL,this.email=e.email,this.emailVerified=e.emailVerified,this.phoneNumber=e.phoneNumber,this.isAnonymous=e.isAnonymous,this.tenantId=e.tenantId,this.providerData=e.providerData.map(e=>Object.assign({},e)),this.metadata._copy(e.metadata),this.stsTokenManager._assign(e.stsTokenManager))}_clone(e){let t=new et(Object.assign(Object.assign({},this),{auth:e,stsTokenManager:this.stsTokenManager._clone()}));return t.metadata._copy(this.metadata),t}_onReload(e){v(!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 n=!1;e.idToken&&e.idToken!==this.stsTokenManager.accessToken&&(this.stsTokenManager.updateFromServerResponse(e),n=!0),t&&await W(this),await this.auth._persistUserIfCurrent(this),n&&this.auth._notifyListenersIfCurrent(this)}async delete(){if((0,i.rh)(this.auth.app))return Promise.reject(g(this.auth));let e=await this.getIdToken();return await K(this,U(this.auth,{idToken:e})),this.stsTokenManager.clearRefreshToken(),this.auth.signOut()}toJSON(){return Object.assign(Object.assign({uid:this.uid,email:this.email||void 0,emailVerified:this.emailVerified,displayName:this.displayName||void 0,isA
15nonymous:this.isAnonymous,photoURL:this.photoURL||void 0,phoneNumber:this.phoneNumber||void 0,tenantId:this.tenantId||void 0,providerData:this.providerData.map(e=>Object.assign({},e)),stsTokenManager:this.stsTokenManager.toJSON(),_redirectEventId:this._redirectEventId},this.metadata.toJSON()),{apiKey:this.auth.config.apiKey,appName:this.auth.name})}get refreshToken(){return this.stsTokenManager.refreshToken||""}static _fromJSON(e,t){var n,r,i,s,o,a,l,u;let c=null!==(n=t.displayName)&&void 0!==n?n:void 0,h=null!==(r=t.email)&&void 0!==r?r:void 0,d=null!==(i=t.phoneNumber)&&void 0!==i?i:void 0,f=null!==(s=t.photoURL)&&void 0!==s?s:void 0,p=null!==(o=t.tenantId)&&void 0!==o?o:void 0,m=null!==(a=t._redirectEventId)&&void 0!==a?a:void 0,g=null!==(l=t.createdAt)&&void 0!==l?l:void 0,y=null!==(u=t.lastLoginAt)&&void 0!==u?u:void 0,{uid:w,emailVerified:b,isAnonymous:_,providerData:I,stsTokenManager:E}=t;v(w&&E,e,"internal-error");let T=Z.fromJSON(this.name,E);v("string"==typeof w,e,"internal-error"),ee(c,e.name),ee(h,e.name),v("boolean"==typeof b,e,"internal-error"),v("boolean"==typeof _,e,"internal-error"),ee(d,e.name),ee(f,e.name),ee(p,e.name),ee(m,e.name),ee(g,e.name),ee(y,e.name);let S=new et({uid:w,auth:e,email:h,emailVerified:b,displayName:c,isAnonymous:_,photoURL:f,phoneNumber:d,tenantId:p,stsTokenManager:T,createdAt:g,lastLoginAt:y});return I&&Array.isArray(I)&&(S.providerData=I.map(e=>Object.assign({},e))),m&&(S._redirectEventId=m),S}static async _fromIdTokenResponse(e,t,n=!1){let r=new Z;r.updateFromServerResponse(t);let i=new et({uid:t.localId,auth:e,stsTokenManager:r,isAnonymous:n});return await W(i),i}static async _fromGetAccountInfoResponse(e,t,n){let r=t.users[0];v(void 0!==r.localId,"internal-error");let i=void 0!==r.providerUserInfo?X(r.providerUserInfo):[],s=!(r.email&&r.passwordHash)&&!(null==i?void 0:i.length),o=new Z;o.updateFromIdToken(n);let a=new et({uid:r.localId,auth:e,stsTokenManager:o,isAnonymous:s});return Object.assign(a,{uid:r.localId,displayName:r.displayName||null,photoURL:r.photoUrl||null,email:r.email||null,emailVerified:r.emailVerified||!1,phoneNumber:r.phoneNumber||null,tenantId:r.tenantId||null,providerData:i,metadata:new H(r.createdAt,r.lastLoginAt),isAnonymous:!(r.email&&r.passwordHash)&&!(null==i?void 0:i.length)}),a}}let en=new Map;function er(e){var t,n;t="Expected a class definition",e instanceof Function||w(t);let r=en.get(e);return r?(n="Instance stored in cache mismatched with class",r instanceof e||w(n)):(r=new e,en.set(e,r)),r}class ei{constructor(){this.type="NONE",this.storage={}}async _isAvailable(){return!0}async _set(e,t){this.storage[e]=t}async _get(e){let t=this.storage[e];return void 0===t?null:t}async _remove(e){delete this.storage[e]}_addListener(e,t){}_removeListener(e,t){}}
15function es(e,t,n){return`firebase:${e}:${t}:${n}`}ei.type="NONE";class eo{constructor(e,t,n){this.persistence=e,this.auth=t,this.userKey=n;let{config:r,name:i}=this.auth;this.fullUserKey=es(this.userKey,r.apiKey,i),this.fullPersistenceKey=es("persistence",r.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(){let e=await this.persistence._get(this.fullUserKey);if(!e)return null;if("string"==typeof e){let t=await V(this.auth,{idToken:e}).catch(()=>void 0);return t?et._fromGetAccountInfoResponse(this.auth,t,e):null}return et._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;let 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,n="authUser"){if(!t.length)return new eo(er(ei),e,n);let r=(await Promise.all(t.map(async e=>{if(await e._isAvailable())return e}))).filter(e=>e),i=r[0]||er(ei),s=es(n,e.config.apiKey,e.name),o=null;for(let n of t)try{let t=await n._get(s);if(t){let r;if("string"==typeof t){let n=await V(e,{idToken:t}).catch(()=>void 0);if(!n)break;r=await et._fromGetAccountInfoResponse(e,n,t)}else r=et._fromJSON(e,t);n!==i&&(o=r),i=n;break}}catch(e){}let a=r.filter(e=>e._shouldAllowMigration);return i._shouldAllowMigration&&a.length&&(i=a[0],o&&await i._set(s,o.toJSON()),await Promise.all(t.map(async e=>{if(e!==i)try{await e._remove(s)}catch(e){}}))),new eo(i,e,n)}}function ea(e){let t=e.toLowerCase();if(t.includes("opera/")||t.includes("opr/")||t.includes("opios/"))return"Opera";if(eh(t))return"IEMobile";if(t.includes("msie")||t.includes("trident/"))return"IE";{if(t.includes("edge/"))return"Edge";if(el(t))return"Firefox";if(t.includes("silk/"))return"Silk";if(ef(t))return"Blackberry";if(ep(t))return"Webos";if(eu(t))return"Safari";if((t.includes("chrome/")||ec(t))&&!t.includes("edge/"))return"Chrome";if(ed(t))return"Android";let n=e.match(/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/);if((null==n?void 0:n.length)===2)return n[1]}return"Other"}function el(e=(0,s.z$)()){return/firefox\//i.test(e)}function eu(e=(0,s.z$)()){let t=e.toLowerCase();return t.includes("safari/")&&!t.includes("chrome/")&&!t.includes("crios/")&&!t.includes("android")}function ec(e=(0,s.z$)()){return/crios\//i.test(e)}function eh(e=(0,s.z$)()){return/iemobile/i.test(e)}function ed(e=(0,s.z$)()){return/android/i.test(e)}function ef(e=(0,s.z$)()){return/blackberry/i.test(e)}function ep(e=(0,s.z$)()){return/webos/i.test(e)}function em(e=(0,s.z$)()){return/iphone|ipad|ipod/i.test(e)||/macintosh/i.test(e)&&/mobile/i.test(e)}function eg(e=(0,s.z$)()){return em(e)||ed(e)||ep(e)||ef(e)||/windows phone/i.test(e)||eh(e)}function ey(e,t=[]){let n;switch(e){case"Browser":n=ea((0,s.z$)());break;case"Worker":n=`${ea((0,s.z$)())}-${e}`;break;default:n=e}let r=t.length?t.join(","):"FirebaseCore-web";return`${n}/JsCore/${i.Jn}/${r}`}class ev{constructor(e){this.auth=e,this.queue=[]}pushCallback(e,t){let n=t=>new Promise((n,r)=>{try{let r=e(t);n(r)}catch(e){r(e)}});n.onAbort=t,this.queue.push(n);let r=this.queue.length-1;return()=>{this.queue[r]=()=>Promise.resolve()}}async runMiddleware(e){if(this.auth.currentUser===e)return;let t=[];try{for(let n of this.queue)await n(e),n.onAbort&&t.push(n.onAbort)}catch(e){for(let e of(t.reverse(),t))try{e()}catch(e){}throw this.auth._errorFactory.create("login-blocked",{originalMessage:null==e?void 0:e.message})}}}async function ew(e,t={}){return A(e,"GET","/v2/passwordPolicy",k(e,t))}class eb{constructor(e){var t,n,r,i;let s=e.customStrengthOptions;this.customStrengthOptions={},this.customStrengthOptions.minPasswordLength=null!==(t=s.minPasswordLength)&&void 0!==t?t:6,s.maxPasswordLength&&(this.customStrengthOptions.maxPasswordLength=s.maxPasswordLength),void 0!==s.containsLowercaseCharacter&&(this.customStrengthOptions.containsLowercaseLetter=s.containsLowercaseCharacter),void 0!==s.containsUppercaseCharacter&&(this.customStrengthOptions.containsUppercaseLetter=s.containsUppercaseCharacter),void 0!==s.containsNumericCharacter&&(this.customStrengthOptions.containsNumericCharacter=s.containsNumericCharacter),void 0!==s.containsNonAlphanumericCharacter&&(this.customStrengthOptions.containsNonAlphanumericCharacter=s.containsNonAlphanumericCharacter),this.enforcementState=e.enforcementState,"ENFORCEMENT_STATE_UNSPECIFIED"===this.enforcementState&&(this.enforcementState="OFF"),this.allowedNonAlphanumericCharacters=null!==(r=null===(n=e.allowedNonAlphanumericCharacters)||void 0===n?void 0:n.join(""))&&void 0!==r?r:"",this.forceUpgradeOnSignin=null!==(i=e.forceUpgradeOnSignin)&&void 0!==i&&i,this.schemaVersion=e.schemaVersion}validatePassword(e){var t,n,r,i,s,o;let a={isValid:!0,passwordPolicy:this};return this.validatePasswordLengthOptions(e,a),this.validatePasswordCharacterOptions(e,a),a.isValid&&
15(a.isValid=null===(t=a.meetsMinPasswordLength)||void 0===t||t),a.isValid&&(a.isValid=null===(n=a.meetsMaxPasswordLength)||void 0===n||n),a.isValid&&(a.isValid=null===(r=a.containsLowercaseLetter)||void 0===r||r),a.isValid&&(a.isValid=null===(i=a.containsUppercaseLetter)||void 0===i||i),a.isValid&&(a.isValid=null===(s=a.containsNumericCharacter)||void 0===s||s),a.isValid&&(a.isValid=null===(o=a.containsNonAlphanumericCharacter)||void 0===o||o),a}validatePasswordLengthOptions(e,t){let n=this.customStrengthOptions.minPasswordLength,r=this.customStrengthOptions.maxPasswordLength;n&&(t.meetsMinPasswordLength=e.length>=n),r&&(t.meetsMaxPasswordLength=e.length<=r)}validatePasswordCharacterOptions(e,t){let n;this.updatePasswordCharacterOptionsStatuses(t,!1,!1,!1,!1);for(let r=0;r<e.length;r++)n=e.charAt(r),this.updatePasswordCharacterOptionsStatuses(t,n>="a"&&n<="z",n>="A"&&n<="Z",n>="0"&&n<="9",this.allowedNonAlphanumericCharacters.includes(n))}updatePasswordCharacterOptionsStatuses(e,t,n,r,i){this.customStrengthOptions.containsLowercaseLetter&&(e.containsLowercaseLetter||(e.containsLowercaseLetter=t)),this.customStrengthOptions.containsUppercaseLetter&&(e.containsUppercaseLetter||(e.containsUppercaseLetter=n)),this.customStrengthOptions.containsNumericCharacter&&(e.containsNumericCharacter||(e.containsNumericCharacter=r)),this.customStrengthOptions.containsNonAlphanumericCharacter&&(e.containsNonAlphanumericCharacter||(e.containsNonAlphanumericCharacter=i))}}class e_{constructor(e,t,n,r){this.app=e,this.heartbeatServiceProvider=t,this.appCheckServiceProvider=n,this.config=r,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new eE(this),this.idTokenSubscription=new eE(this),this.beforeStateQueue=new ev(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=c,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=r.sdkClientVersion,this._persistenceManagerAvailable=new Promise(e=>this._resolvePersistenceManagerAvailable=e)}_initializeWithPersistence(e,t){return t&&(this._popupRedirectResolver=er(t)),this._initializationPromise=this.queue(async()=>{var n,r,i;if(!this._deleted&&(this.persistenceManager=await eo.create(this,e),null===(n=this._resolvePersistenceManagerAvailable)||void 0===n||n.call(this),!this._deleted)){if(null===(r=this._popupRedirectResolver)||void 0===r?void 0:r._shouldInitProactively)try{await this._popupRedirectResolver._initialize(this)}catch(e){}await this.initializeCurrentUser(t),this.lastNotifiedUid=(null===(i=this.currentUser)||void 0===i?void 0:i.uid)||null,this._deleted||(this._isInitialized=!0)}}),this._initializationPromise}async _onStorageEvent(){if(this._deleted)return;let 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{let t=await V(this,{idToken:e}),n=await et._fromGetAccountInfoResponse(this,t,e);await this.directlySetCurrentUser(n)}catch(e){console.warn("FirebaseServerApp could not login user with provided authIdToken: ",e),await this.directlySetCurrentUser(null)}}async initializeCurrentUser(e){var t;if((0,i.rh)(this.app)){let e=this.app.settings.authIdToken;return e?new Promise(t=>{setTimeout(()=>this.initializeCurrentUserFromIdToken(e).then(t,t))}):this.directlySetCurrentUser(null)}let n=await this.assertedPersistence.getCurrentUser(),r=n,s=!1;if(e&&this.config.authDomain){await this.getOrInitRedirectPersistenceManager();let n=null===(t=this.redirectUser)||void 0===t?void 0:t._redirectEventId,i=null==r?void 0:r._redirectEventId,o=await this.tryRedirectSignIn(e);(!n||n===i)&&(null==o?void 0:o.user)&&(r=o.user,s=!0)}if(!r)return this.directlySetCurrentUser(null);
15if(!r._redirectEventId){if(s)try{await this.beforeStateQueue.runMiddleware(r)}catch(e){r=n,this._popupRedirectResolver._overrideRedirectResult(this,()=>Promise.reject(e))}return r?this.reloadAndSetCurrentUserOrClear(r):this.directlySetCurrentUser(null)}return(v(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(e){await this._setRedirectUser(null)}return t}async reloadAndSetCurrentUserOrClear(e){try{await W(e)}catch(e){if((null==e?void 0:e.code)!=="auth/network-request-failed")return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(e)}useDeviceLanguage(){this.languageCode=function(){if("undefined"==typeof navigator)return null;let e=navigator;return e.languages&&e.languages[0]||e.language||null}()}async _delete(){this._deleted=!0}async updateCurrentUser(e){if((0,i.rh)(this.app))return Promise.reject(g(this));let t=e?(0,s.m9)(e):null;return t&&v(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&&v(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(0,i.rh)(this.app)?Promise.reject(g(this)):(await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0))}setPersistence(e){return(0,i.rh)(this.app)?Promise.reject(g(this)):this.queue(async()=>{await this.assertedPersistence.setPersistence(er(e))})}_getRecaptchaConfig(){return null==this.tenantId?this._agentRecaptchaConfig:this._tenantRecaptchaConfigs[this.tenantId]}async validatePassword(e){this._getPasswordPolicyInternal()||await this._updatePasswordPolicy();let t=this._getPasswordPolicyInternal();return t.schemaVersion!==this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION?Promise.reject(this._errorFactory.create("unsupported-password-policy-schema-version",{})):t.validatePassword(e)}_getPasswordPolicyInternal(){return null===this.tenantId?this._projectPasswordPolicy:this._tenantPasswordPolicies[this.tenantId]}async _updatePasswordPolicy(){let e=new eb(await ew(this));null===this.tenantId?this._projectPasswordPolicy=e:this._tenantPasswordPolicies[this.tenantId]=e}_getPersistenceType(){return this.assertedPersistence.persistence.type}_getPersistence(){return this.assertedPersistence.persistence}_updateErrorMap(e){this._errorFactory=new s.LL("auth","Firebase",e())}onAuthStateChanged(e,t,n){return this.registerStateListener(this.authStateSubscription,e,t,n)}beforeAuthStateChanged(e,t){return this.beforeStateQueue.pushCallback(e,t)}onIdTokenChanged(e,t,n){return this.registerStateListener(this.idTokenSubscription,e,t,n)}authStateReady(){return new Promise((e,t)=>{if(this.currentUser)e();else{let n=this.onAuthStateChanged(()=>{n(),e()},t)}})}async revokeAccessToken(e){if(this.currentUser){let t={providerId:"apple.com",tokenType:"ACCESS_TOKEN",token:e,idToken:await this.currentUser.getIdToken()};null!=this.tenantId&&(t.tenantId=this.tenantId),await J(this,t)}}toJSON(){var e;return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:null===(e=this._currentUser)||void 0===e?void 0:e.toJSON()}}async _setRedirectUser(e,t){let n=await this.getOrInitRedirectPersistenceManager(t);return null===e?n.removeCurrentUser():n.setCurrentUser(e)}async getOrInitRedirectPersistenceManager(e){if(!this.redirectPersistenceManager){let t=e&&er(e)||this._popupRedirectResolver;v(t,this,"argument-error"),this.redirectPersistenceManager=await eo.create(this,[er(t._redirectPersistence)],"redirectUser"),this.redirectUser=await this.redirectPersistenceManager.getCurrentUser()}return this.redirectPersistenceManager}async _redirectUserForId(e){var t,n;return(this._isInitialized&&await this.queue(async()=>{}),(null===(t=this._currentUser)||void 0===t?void 0:t._redirectEventId)===e)?this._currentUser:(null===(n=this.redirectUser)||void 0===n?void 0:n._redirectEventId)===e?this.redirectUser:null}async _persistUserIfCurrent(e){if(e===this.currentUser)return this.queue(async()=>this.directlySetCurrentUser(e))}_notifyListenersIfCurrent(e){e===this.currentUser&&this.notifyAuthListeners()}_key(){return`${this.config.authDomain}:${this.config.apiKey}:${this.name}`}_startProactiveRefresh(){this.isProactiveRefreshEnabled=!0,this.currentUser&&this._currentUser._startProactiveRefresh()}_stopProactiveRefresh(){this.isProactiveRefreshEnabled=!1,this.currentUser&&this._currentUser._stopProactiveRefresh()}get _currentUser(){return this.currentUser}notifyAuthListeners(){var e,t;if(!this._isInitialized)return;this.idTokenSubscription.next(this.currentUser);let n=null!==(t=null===(e=this.currentUser)||void 0===e?void 0:e.uid)&&void 0!==t?t:null;this.lastNotifiedUid!==n&&(this.lastNotifiedUid=n,this.authStateSubscription.next(this.currentUser))}registerStateListener(e,t,n,r){if(this._deleted)return()=>{};let i="function"==typeof t?t:t.next.bind(t),s=!1,o=this._isInitialized?Promise.resolve():this._initializationPromise;if(v(o,this,"internal-error"),o.then(()=>{s||i(this.currentUser)}),"function"==typeof t){let i=e.addObserver(t,n,r);return()=>{s=!0,i()}}{let n=e.addObserver(t);return()=>{s=!0,n()}}}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 v(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(e){!e||this.frameworks.includes(e)||(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=ey(this.config.clientPlatform,this._getFrameworks()))}_getFrameworks(){return this.frameworks}async _getAdditionalHeaders(){var e;let t={"X-Client-Version":this.clientVersion};this.app.options.appId&&(t["X-Firebase-gmpid"]=this.app.options.appId);let n=await (null===(e=this.heartbeatServiceProvider.getImmediate({optional:!0}))||void 0===e?void 0:e.getHeartbeatsHeader());n&&(t["X-Firebase-Client"]=n);let r=await this._getAppCheckToken();return r&&(t["X-Firebase-AppCheck"]=r),t}async _getAppCheckToken(){var e;if((0,i.rh)(this.app)&&this.app.settings.appCheckToken)return this.app.settings.appCheckToken;let t=await (null===(e=this.appCheckServiceProvider.getImmediate({optional:!0}))||void 0===e?void 0:e.getToken());return(null==t?void 0:t.error)&&function(e,...t){h.logLevel<=o.in.WARN&&h.warn(`Auth (${i.Jn}): ${e}`,...t)}(`Error while retrieving App Check token: ${t.error}`),null==t?void 0:t.token}}function eI(e){return(0,s.m9)(e)}class eE{constructor(e){this.auth=e,this.observer=null,this.addObserver=(0,s.ne)(e=>this.observer=e)}get next(){return v(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}let eT={async loadJS(){throw Error("Unable to load external scripts")},recaptchaV2Script:"",recaptchaEnterpriseScript:"",gapiScript:""};function eS(e){return`__${e}${Math.floor(1e6*Math.random())}`}class eC{constructor(){this.enterprise=new ex}ready(e){e()}execute(e,t){return Promise.resolve("token")}render(e,t){return""}}class ex{ready(e){e()}execute(e,t){return Promise.resolve("token")}render(e,t){return""}}let ek="NO_RECAPTCHA";class eA{constructor(e){this.type="recaptcha-enterprise",this.auth=eI(e)}async verify(e="verify",t=!1){async function n(e){if(!t){if(null==e.tenantId&&null!=e._agentRecaptchaConfig)return e._agentRecaptchaConfig.siteKey;if(null!=e.tenantId&&void 0!==e._tenantRecaptchaConfigs[e.tenantId])return e._tenantRecaptchaConfigs[e.tenantId].siteKey}return new Promise(async(t,n)=>
15{F(e,{clientType:"CLIENT_TYPE_WEB",version:"RECAPTCHA_ENTERPRISE"}).then(r=>{if(void 0===r.recaptchaKey)n(Error("recaptcha Enterprise site key undefined"));else{let n=new M(r);return null==e.tenantId?e._agentRecaptchaConfig=n:e._tenantRecaptchaConfigs[e.tenantId]=n,t(n.siteKey)}}).catch(e=>{n(e)})})}function r(t,n,r){let i=window.grecaptcha;L(i)?i.enterprise.ready(()=>{i.enterprise.execute(t,{action:e}).then(e=>{n(e)}).catch(()=>{n(ek)})}):r(Error("No reCAPTCHA enterprise script loaded."))}return this.auth.settings.appVerificationDisabledForTesting?new eC().execute("siteKey",{action:"verify"}):new Promise((e,i)=>{n(this.auth).then(n=>{if(!t&&L(window.grecaptcha))r(n,e,i);else{var s;if("undefined"==typeof window){i(Error("RecaptchaVerifier is only supported in browser"));return}let t=eT.recaptchaEnterpriseScript;0!==t.length&&(t+=n),(s=t,eT.loadJS(s)).then(()=>{r(n,e,i)}).catch(e=>{i(e)})}}).catch(e=>{i(e)})})}}async function eR(e,t,n,r=!1,i=!1){let s;let o=new eA(e);if(i)s=ek;else try{s=await o.verify(n)}catch(e){s=await o.verify(n,!0)}let a=Object.assign({},t);if("mfaSmsEnrollment"===n||"mfaSmsSignIn"===n){if("phoneEnrollmentInfo"in a){let e=a.phoneEnrollmentInfo.phoneNumber,t=a.phoneEnrollmentInfo.recaptchaToken;Object.assign(a,{phoneEnrollmentInfo:{phoneNumber:e,recaptchaToken:t,captchaResponse:s,clientType:"CLIENT_TYPE_WEB",recaptchaVersion:"RECAPTCHA_ENTERPRISE"}})}else if("phoneSignInInfo"in a){let e=a.phoneSignInInfo.recaptchaToken;Object.assign(a,{phoneSignInInfo:{recaptchaToken:e,captchaResponse:s,clientType:"CLIENT_TYPE_WEB",recaptchaVersion:"RECAPTCHA_ENTERPRISE"}})}return a}return r?Object.assign(a,{captchaResp:s}):Object.assign(a,{captchaResponse:s}),Object.assign(a,{clientType:"CLIENT_TYPE_WEB"}),Object.assign(a,{recaptchaVersion:"RECAPTCHA_ENTERPRISE"}),a}async function eN(e,t,n,r,i){var s,o;if("EMAIL_PASSWORD_PROVIDER"===i){if(null===(s=e._getRecaptchaConfig())||void 0===s||!s.isProviderEnabled("EMAIL_PASSWORD_PROVIDER"))return r(e,t).catch(async i=>{if("auth/missing-recaptcha-token"!==i.code)return Promise.reject(i);{console.log(`${n} is protected by reCAPTCHA Enterprise for this project. Automatically triggering the reCAPTCHA flow and restarting the flow.`);let i=await eR(e,t,n,"getOobCode"===n);return r(e,i)}});{let i=await eR(e,t,n,"getOobCode"===n);return r(e,i)}}if("PHONE_PROVIDER"!==i)return Promise.reject(i+" provider is not supported.");if(null===(o=e._getRecaptchaConfig())||void 0===o?void 0:o.isProviderEnabled("PHONE_PROVIDER")){let i=await eR(e,t,n);return r(e,i).catch(async i=>{var s;if((null===(s=e._getRecaptchaConfig())||void 0===s?void 0:s.getProviderEnforcementState("PHONE_PROVIDER"))==="AUDIT"&&("auth/missing-recaptcha-token"===i.code||"auth/invalid-app-credential"===i.code)){console.log(`Failed to verify with reCAPTCHA Enterprise. Automatically triggering the reCAPTCHA v2 flow to complete the ${n} flow.`);let i=await eR(e,t,n,!1,!0);return r(e,i)}return Promise.reject(i)})}{let i=await eR(e,t,n,!1,!0);return r(e,i)}}async function eO(e){let t=eI(e),n=new M(await F(t,{clientType:"CLIENT_TYPE_WEB",version:"RECAPTCHA_ENTERPRISE"}));null==t.tenantId?t._agentRecaptchaConfig=n:t._tenantRecaptchaConfigs[t.tenantId]=n,n.isAnyProviderEnabled()&&new eA(t).verify()}function eD(e){let t=e.indexOf(":");return t<0?"":e.substr(0,t+1)}function eP(e){if(!e)return null;let t=Number(e);return isNaN(t)?null:t}class eL{constructor(e,t){this.providerId=e,this.signInMethod=t}toJSON(){return w("not implemented")}_getIdTokenResponse(e){return w("not implemented")}_linkToIdToken(e,t){return w("not implemented")}_getReauthenticationResolver(e){return w("not implemented")}}async function eM(e,t){return A(e,"POST","/v1/accounts:resetPassword",k(e,t))}async function eF(e,t){return A(e,"POST","/v1/accounts:signUp",t)}async function eU(e,t){return N(e,"POST","/v1/accounts:signInWithPassword",k(e,t))}async function eV(e,t){return A(e,"POST","/v1/accounts:sendOobCode",k(e,t))}async function ej(e,t){return eV(e,t)}async function eB(e,t){return N(e,"POST","/v1/accounts:signInWithEmailLink",k(e,t))}async function eq(e,t){return N(e,"POST","/v1/accounts:signInWithEmailLink",k(e,t))}class ez extends eL{constructor(e,t,n,r=null){super("password",n),this._email=e,this._password=t,this._tenantId=r}static _fromEmailAndPassword(e,t){return new ez(e,t,"password")}static _fromEmailAndCode(e,t,n=null){return new ez(e,t,"emailLink",n)}toJSON(){return{email:this._email,password:this._password,signInMethod:this.signInMethod,tenantId:this._tenantId}}static fromJSON(e){let t="string"==typeof e?JSON.parse(e):e;if((null==t?void 0:t.email)&&(null==t?void 0:t.password)){if("password"===t.signInMethod)return this._fromEmailAndPassword(t.email,t.password);if("emailLink"===t.signInMethod)return this._fromEmailAndCode(t.email,t.password,t.tenantId)}return null}async _getIdTokenResponse(e){switch(this.signInMethod){case"password":return eN(e,{returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"},"signInWithPassword",eU,"EMAIL_PASSWORD_PROVIDER");case"emailLink":return eB(e,{email:this._email,oobCode:this._password});default:f(e,"internal-error")}}async _linkToIdToken(e,t){switch(this.signInMethod){case"password":return eN(e,{idToken:t,returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"},"signUpPassword",eF,"EMAIL_PASSWORD_PROVIDER");case"emailLink":return eq(e,{idToken:t,email:this._email,oobCode:this._password});default:f(e,"internal-error")}}_getReauthenticationResolver(e){return this._getIdTokenResponse(e)}}async function e$(e,t){return N(e,"POST","/v1/accounts:signInWithIdp",k(e,t))}class eK extends eL{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(e){let t=new eK(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&&
15(t.nonce=e.nonce),e.pendingToken&&(t.pendingToken=e.pendingToken)):e.oauthToken&&e.oauthTokenSecret?(t.accessToken=e.oauthToken,t.secret=e.oauthTokenSecret):f("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){let t="string"==typeof e?JSON.parse(e):e,{providerId:n,signInMethod:r}=t,i=a(t,["providerId","signInMethod"]);if(!n||!r)return null;let s=new eK(n,r);return s.idToken=i.idToken||void 0,s.accessToken=i.accessToken||void 0,s.secret=i.secret,s.nonce=i.nonce,s.pendingToken=i.pendingToken||null,s}_getIdTokenResponse(e){return e$(e,this.buildRequest())}_linkToIdToken(e,t){let n=this.buildRequest();return n.idToken=t,e$(e,n)}_getReauthenticationResolver(e){let t=this.buildRequest();return t.autoCreate=!1,e$(e,t)}buildRequest(){let e={requestUri:"http://localhost",returnSecureToken:!0};if(this.pendingToken)e.pendingToken=this.pendingToken;else{let 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=(0,s.xO)(t)}return e}}async function eG(e,t){return A(e,"POST","/v1/accounts:sendVerificationCode",k(e,t))}async function eH(e,t){return N(e,"POST","/v1/accounts:signInWithPhoneNumber",k(e,t))}async function eW(e,t){let n=await N(e,"POST","/v1/accounts:signInWithPhoneNumber",k(e,t));if(n.temporaryProof)throw P(e,"account-exists-with-different-credential",n);return n}let eQ={USER_NOT_FOUND:"user-not-found"};async function eX(e,t){return N(e,"POST","/v1/accounts:signInWithPhoneNumber",k(e,Object.assign(Object.assign({},t),{operation:"REAUTH"})),eQ)}class eY extends eL{constructor(e){super("phone","phone"),this.params=e}static _fromVerification(e,t){return new eY({verificationId:e,verificationCode:t})}static _fromTokenResponse(e,t){return new eY({phoneNumber:e,temporaryProof:t})}_getIdTokenResponse(e){return eH(e,this._makeVerificationRequest())}_linkToIdToken(e,t){return eW(e,Object.assign({idToken:t},this._makeVerificationRequest()))}_getReauthenticationResolver(e){return eX(e,this._makeVerificationRequest())}_makeVerificationRequest(){let{temporaryProof:e,phoneNumber:t,verificationId:n,verificationCode:r}=this.params;return e&&t?{temporaryProof:e,phoneNumber:t}:{sessionInfo:n,code:r}}toJSON(){let e={providerId:this.providerId};return this.params.phoneNumber&&(e.phoneNumber=this.params.phoneNumber),this.params.temporaryProof&&(e.temporaryProof=this.params.temporaryProof),this.params.verificationCode&&(e.verificationCode=this.params.verificationCode),this.params.verificationId&&(e.verificationId=this.params.verificationId),e}static fromJSON(e){"string"==typeof e&&(e=JSON.parse(e));let{verificationId:t,verificationCode:n,phoneNumber:r,temporaryProof:i}=e;return n||t||r||i?new eY({verificationId:t,verificationCode:n,phoneNumber:r,temporaryProof:i}):null}}class eJ{constructor(e){var t,n,r,i,o,a;let l=(0,s.zd)((0,s.pd)(e)),u=null!==(t=l.apiKey)&&void 0!==t?t:null,c=null!==(n=l.oobCode)&&void 0!==n?n:null,h=function(e){switch(e){case"recoverEmail":return"RECOVER_EMAIL";case"resetPassword":return"PASSWORD_RESET";case"signIn":return"EMAIL_SIGNIN";case"verifyEmail":return"VERIFY_EMAIL";case"verifyAndChangeEmail":return"VERIFY_AND_CHANGE_EMAIL";case"revertSecondFactorAddition":return"REVERT_SECOND_FACTOR_ADDITION";default:return null}}(null!==(r=l.mode)&&void 0!==r?r:null);v(u&&c&&h,"argument-error"),this.apiKey=u,this.operation=h,this.code=c,this.continueUrl=null!==(i=l.continueUrl)&&void 0!==i?i:null,this.languageCode=null!==(o=l.lang)&&void 0!==o?o:null,this.tenantId=null!==(a=l.tenantId)&&void 0!==a?a:null}static parseLink(e){let t=function(e){let t=(0,s.zd)((0,s.pd)(e)).link,n=t?(0,s.zd)((0,s.pd)(t)).deep_link_id:null,r=(0,s.zd)((0,s.pd)(e)).deep_link_id;return(r?(0,s.zd)((0,s.pd)(r)).link:null)||r||n||t||e}(e);try{return new eJ(t)}catch(e){return null}}}class eZ{constructor(){this.providerId=eZ.PROVIDER_ID}static credential(e,t){return ez._fromEmailAndPassword(e,t)}static credentialWithLink(e,t){let n=eJ.parseLink(t);return v(n,"argument-error"),ez._fromEmailAndCode(e,n.code,n.tenantId)}}eZ.PROVIDER_ID="password",eZ.EMAIL_PASSWORD_SIGN_IN_METHOD="password",eZ.EMAIL_LINK_SIGN_IN_METHOD="emailLink";class e0{constructor(e){this.providerId=e,this.defaultLanguageCode=null,this.customParameters={}}setDefaultLanguage(e){this.defaultLanguageCode=e}setCustomParameters(e){return this.customParameters=e,this}getCustomParameters(){return this.customParameters}}class e1 extends e0{constructor(){super(...arguments),this.scopes=[]}addScope(e){return this.scopes.includes(e)||this.scopes.push(e),this}getScopes(){return[...this.scopes]}}class e2 extends e1{constructor(){super("facebook.com")}static credential(e){return eK._fromParams({providerId:e2.PROVIDER_ID,signInMethod:e2.FACEBOOK_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return e2.credentialFromTaggedObject(e)}static credentialFromError(e){return e2.credentialFromTaggedObject(e.customData||{})}
15static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return e2.credential(e.oauthAccessToken)}catch(e){return null}}}e2.FACEBOOK_SIGN_IN_METHOD="facebook.com",e2.PROVIDER_ID="facebook.com";class e4 extends e1{constructor(){super("google.com"),this.addScope("profile")}static credential(e,t){return eK._fromParams({providerId:e4.PROVIDER_ID,signInMethod:e4.GOOGLE_SIGN_IN_METHOD,idToken:e,accessToken:t})}static credentialFromResult(e){return e4.credentialFromTaggedObject(e)}static credentialFromError(e){return e4.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;let{oauthIdToken:t,oauthAccessToken:n}=e;if(!t&&!n)return null;try{return e4.credential(t,n)}catch(e){return null}}}e4.GOOGLE_SIGN_IN_METHOD="google.com",e4.PROVIDER_ID="google.com";class e6 extends e1{constructor(){super("github.com")}static credential(e){return eK._fromParams({providerId:e6.PROVIDER_ID,signInMethod:e6.GITHUB_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return e6.credentialFromTaggedObject(e)}static credentialFromError(e){return e6.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return e6.credential(e.oauthAccessToken)}catch(e){return null}}}e6.GITHUB_SIGN_IN_METHOD="github.com",e6.PROVIDER_ID="github.com";class e5 extends e1{constructor(){super("twitter.com")}static credential(e,t){return eK._fromParams({providerId:e5.PROVIDER_ID,signInMethod:e5.TWITTER_SIGN_IN_METHOD,oauthToken:e,oauthTokenSecret:t})}static credentialFromResult(e){return e5.credentialFromTaggedObject(e)}static credentialFromError(e){return e5.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;let{oauthAccessToken:t,oauthTokenSecret:n}=e;if(!t||!n)return null;try{return e5.credential(t,n)}catch(e){return null}}}async function e9(e,t){return N(e,"POST","/v1/accounts:signUp",k(e,t))}e5.TWITTER_SIGN_IN_METHOD="twitter.com",e5.PROVIDER_ID="twitter.com";class e3{constructor(e){this.user=e.user,this.providerId=e.providerId,this._tokenResponse=e._tokenResponse,this.operationType=e.operationType}static async _fromIdTokenResponse(e,t,n,r=!1){return new e3({user:await et._fromIdTokenResponse(e,n,r),providerId:e8(n),_tokenResponse:n,operationType:t})}static async _forOperation(e,t,n){return await e._updateTokensIfNecessary(n,!0),new e3({user:e,providerId:e8(n),_tokenResponse:n,operationType:t})}}function e8(e){return e.providerId?e.providerId:"phoneNumber"in e?"phone":null}class e7 extends s.ZR{constructor(e,t,n,r){var i;super(t.code,t.message),this.operationType=n,this.user=r,Object.setPrototypeOf(this,e7.prototype),this.customData={appName:e.name,tenantId:null!==(i=e.tenantId)&&void 0!==i?i:void 0,_serverResponse:t.customData._serverResponse,operationType:n}}static _fromErrorAndOperation(e,t,n,r){return new e7(e,t,n,r)}}function te(e,t,n,r){return("reauthenticate"===t?n._getReauthenticationResolver(e):n._getIdTokenResponse(e)).catch(n=>{if("auth/multi-factor-auth-required"===n.code)throw e7._fromErrorAndOperation(e,n,t,r);throw n})}async function tt(e,t,n=!1){let r=await K(e,t._linkToIdToken(e.auth,await e.getIdToken()),n);return e3._forOperation(e,"link",r)}async function tn(e,t,n=!1){let{auth:r}=e;if((0,i.rh)(r.app))return Promise.reject(g(r));let s="reauthenticate";try{let i=await K(e,te(r,s,t,e),n);v(i.idToken,r,"internal-error");let o=z(i.idToken);v(o,r,"internal-error");let{sub:a}=o;return v(e.uid===a,r,"user-mismatch"),e3._forOperation(e,s,i)}catch(e){throw(null==e?void 0:e.code)==="auth/user-not-found"&&f(r,"user-mismatch"),e}}async function tr(e,t,n=!1){if((0,i.rh)(e.app))return Promise.reject(g(e));let r="signIn",s=await te(e,r,t),o=await e3._fromIdTokenResponse(e,r,s);return n||await e._updateCurrentUser(o.user),o}async function ti(e,t){return tr(eI(e),t)}class ts{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?to._fromServerResponse(e,t):"totpInfo"in t?ta._fromServerResponse(e,t):f(e,"internal-error")}}class to extends ts{constructor(e){super("phone",e),this.phoneNumber=e.phoneInfo}static _fromServerResponse(e,t){return new to(t)}}class ta extends ts{constructor(e){super("totp",e)}static _fromServerResponse(e,t){return new ta(t)}}async function tl(e){let t=eI(e);t._getPasswordPolicyInternal()&&await t._updatePasswordPolicy()}async function tu(e,t,n){let r=eI(e),i={requestType:"PASSWORD_RESET",email:t,clientType:"CLIENT_TYPE_WEB"};if(n){var s;v((null===(s=n.url)||void 0===s?void 0:s.length)>
150,r,"invalid-continue-uri"),v(void 0===n.dynamicLinkDomain||n.dynamicLinkDomain.length>0,r,"invalid-dynamic-link-domain"),v(void 0===n.linkDomain||n.linkDomain.length>0,r,"invalid-hosting-link-domain"),i.continueUrl=n.url,i.dynamicLinkDomain=n.dynamicLinkDomain,i.linkDomain=n.linkDomain,i.canHandleCodeInApp=n.handleCodeInApp,n.iOS&&(v(n.iOS.bundleId.length>0,r,"missing-ios-bundle-id"),i.iOSBundleId=n.iOS.bundleId),n.android&&(v(n.android.packageName.length>0,r,"missing-android-pkg-name"),i.androidInstallApp=n.android.installApp,i.androidMinimumVersionCode=n.android.minimumVersion,i.androidPackageName=n.android.packageName)}await eN(r,i,"getOobCode",ej,"EMAIL_PASSWORD_PROVIDER")}async function tc(e,t,n){await eM((0,s.m9)(e),{oobCode:t,newPassword:n}).catch(async t=>{throw"auth/password-does-not-meet-requirements"===t.code&&tl(e),t})}async function th(e,t){let n=(0,s.m9)(e),r=await eM(n,{oobCode:t}),i=r.requestType;switch(v(i,n,"internal-error"),i){case"EMAIL_SIGNIN":break;case"VERIFY_AND_CHANGE_EMAIL":v(r.newEmail,n,"internal-error");break;case"REVERT_SECOND_FACTOR_ADDITION":v(r.mfaInfo,n,"internal-error");default:v(r.email,n,"internal-error")}let o=null;return r.mfaInfo&&(o=ts._fromServerResponse(eI(n),r.mfaInfo)),{data:{email:("VERIFY_AND_CHANGE_EMAIL"===r.requestType?r.newEmail:r.email)||null,previousEmail:("VERIFY_AND_CHANGE_EMAIL"===r.requestType?r.email:r.newEmail)||null,multiFactorInfo:o},operation:i}}async function td(e,t){let{data:n}=await th((0,s.m9)(e),t);return n.email}async function tf(e,t,n){if((0,i.rh)(e.app))return Promise.reject(g(e));let r=eI(e),s=eN(r,{returnSecureToken:!0,email:t,password:n,clientType:"CLIENT_TYPE_WEB"},"signUpPassword",e9,"EMAIL_PASSWORD_PROVIDER"),o=await s.catch(t=>{throw"auth/password-does-not-meet-requirements"===t.code&&tl(e),t}),a=await e3._fromIdTokenResponse(r,"signIn",o);return await r._updateCurrentUser(a.user),a}function tp(e,t,n){return(0,i.rh)(e.app)?Promise.reject(g(e)):ti((0,s.m9)(e),eZ.credential(t,n)).catch(async t=>{throw"auth/password-does-not-meet-requirements"===t.code&&tl(e),t})}async function tm(e,t){return A(e,"POST","/v1/accounts:update",t)}async function tg(e,{displayName:t,photoURL:n}){if(void 0===t&&void 0===n)return;let r=(0,s.m9)(e),i=await r.getIdToken(),o=await K(r,tm(r.auth,{idToken:i,displayName:t,photoUrl:n,returnSecureToken:!0}));r.displayName=o.displayName||null,r.photoURL=o.photoUrl||null;let a=r.providerData.find(({providerId:e})=>"password"===e);a&&(a.displayName=r.displayName,a.photoURL=r.photoURL),await r._updateTokensIfNecessary(o)}function ty(e,t,n,r){return(0,s.m9)(e).onAuthStateChanged(t,n,r)}function tv(e){return(0,s.m9)(e).signOut()}function tw(e,t){return A(e,"POST","/v2/accounts/mfaEnrollment:start",k(e,t))}new WeakMap;let tb="__sak";class t_{constructor(e,t){this.storageRetriever=e,this.type=t}_isAvailable(){try{if(!this.storage)return Promise.resolve(!1);return this.storage.setItem(tb,"1"),this.storage.removeItem(tb),Promise.resolve(!0)}catch(e){return Promise.resolve(!1)}}_set(e,t){return this.storage.setItem(e,JSON.stringify(t)),Promise.resolve()}_get(e){let t=this.storage.getItem(e);return Promise.resolve(t?JSON.parse(t):null)}_remove(e){return this.storage.removeItem(e),Promise.resolve()}get storage(){return this.storageRetriever()}}class tI extends t_{constructor(){super(()=>window.localStorage,"LOCAL"),this.boundEventHandler=(e,t)=>this.onStorageEvent(e,t),this.listeners={},this.localCache={},this.pollTimer=null,this.fallbackToPolling=eg(),this._shouldAllowMigration=!0}forAllChangedKeys(e){for(let t of Object.keys(this.listeners)){let n=this.storage.getItem(t),r=this.localCache[t];n!==r&&e(t,r,n)}}onStorageEvent(e,t=!1){if(!e.key){this.forAllChangedKeys((e,t,n)=>{this.notifyListeners(e,n)});return}let n=e.key;t?this.detachListener():this.stopPolling();let r=()=>{let e=this.storage.getItem(n);(t||this.localCache[n]!==e)&&this.notifyListeners(n,e)},i=this.storage.getItem(n);(0,s.w1)()&&10===document.documentMode&&i!==e.newValue&&e.newValue!==e.oldValue?setTimeout(r,10):r()}notifyListeners(e,t){this.localCache[e]=t;let n=this.listeners[e];if(n)for(let e of Array.from(n))e(t?JSON.parse(t):t)}startPolling(){this.stopPolling(),this.pollTimer=setInterval(()=>{this.forAllChangedKeys((e,t,n)=>{this.onStorageEvent(new StorageEvent("storage",{key:e,oldValue:t,newValue:n}),!0)})},1e3)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}attachListener(){window.addEventListener("storage",this.boundEventHandler)}detachListener(){window.removeEventListener("storage",this.boundEventHandler)}_addListener(e,t){0===Object.keys(this.listeners).length&&(this.fallbackToPolling?this.startPolling():this.attachListener()),this.listeners[e]||(this.listeners[e]=new Set,this.localCache[e]=this.storage.getItem(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),0===this.listeners[e].size&&delete this.listeners[e]),0===Object.keys(this.listeners).length&&(this.detachListener(),this.stopPolling())}async _set(e,t){await super._set(e,t),this.localCache[e]=JSON.stringify(t)}async _get(e){let t=await super._get(e);return this.localCache[e]=JSON.stringify(t),t}async _remove(e){await super._remove(e),delete this.localCache[e]}}function tE(e){var t,n;let r=e.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),i=RegExp(`${r}=([^;]+)`);return null!==(n=null===(t=document.cookie.match(i))||void 0===t?void 0:t[1])&&void 0!==n?n:null}function tT(e){let t="http:"===window.location.protocol;return`${t?"__dev_":"__HOST-"}FIREBASE_${e.split(":")[3]}`}tI.type="LOCAL";class tS{constructor(){this.type="COOKIE",this.listenerUnsubscribes=new Map}_getFinalTarget(e){let t=new URL(`${window.location.origin}/__cookies__`);return t.searchParams.set("finalTarget",e),t}async _isAvailable(){var e;return!!("boolean"!=typeof isSecureContext||isSecureContext)&&"undefined"!=typeof navigator&&"undefined"!=typeof document&&(null===(e=navigator.cookieEnabled)||void 0===e||e)}async _set(e,t){}async _get(e){if(!this._isAvailable())return null;let t=tT(e);if(window.cookieStore){let e=await window.cookieStore.get(t);return null==e?void 0:e.value}return tE(t)}async _remove(e){if(!this._isAvailable()||!await this._get(e))return;let t=tT(e);document.cookie=`${t}=;Max-Age=34560000;Partitioned;Secure;SameSite=Strict;Path=/;
15Priority=High`,await fetch("/__cookies__",{method:"DELETE"}).catch(()=>void 0)}_addListener(e,t){if(!this._isAvailable())return;let n=tT(e);if(window.cookieStore){let e=e=>{let r=e.changed.find(e=>e.name===n);r&&t(r.value),e.deleted.find(e=>e.name===n)&&t(null)};return this.listenerUnsubscribes.set(t,()=>window.cookieStore.removeEventListener("change",e)),window.cookieStore.addEventListener("change",e)}let r=tE(n),i=setInterval(()=>{let e=tE(n);e!==r&&(t(e),r=e)},1e3);this.listenerUnsubscribes.set(t,()=>clearInterval(i))}_removeListener(e,t){let n=this.listenerUnsubscribes.get(t);n&&(n(),this.listenerUnsubscribes.delete(t))}}tS.type="COOKIE";class tC extends t_{constructor(){super(()=>window.sessionStorage,"SESSION")}_addListener(e,t){}_removeListener(e,t){}}tC.type="SESSION";class tx{constructor(e){this.eventTarget=e,this.handlersMap={},this.boundEventHandler=this.handleEvent.bind(this)}static _getInstance(e){let t=this.receivers.find(t=>t.isListeningto(e));if(t)return t;let n=new tx(e);return this.receivers.push(n),n}isListeningto(e){return this.eventTarget===e}async handleEvent(e){let{eventId:t,eventType:n,data:r}=e.data,i=this.handlersMap[n];if(!(null==i?void 0:i.size))return;e.ports[0].postMessage({status:"ack",eventId:t,eventType:n});let s=Array.from(i).map(async t=>t(e.origin,r)),o=await Promise.all(s.map(async e=>{try{let t=await e;return{fulfilled:!0,value:t}}catch(e){return{fulfilled:!1,reason:e}}}));e.ports[0].postMessage({status:"done",eventId:t,eventType:n,response:o})}_subscribe(e,t){0===Object.keys(this.handlersMap).length&&this.eventTarget.addEventListener("message",this.boundEventHandler),this.handlersMap[e]||(this.handlersMap[e]=new Set),this.handlersMap[e].add(t)}_unsubscribe(e,t){this.handlersMap[e]&&t&&this.handlersMap[e].delete(t),t&&0!==this.handlersMap[e].size||delete this.handlersMap[e],0===Object.keys(this.handlersMap).length&&this.eventTarget.removeEventListener("message",this.boundEventHandler)}}function tk(e="",t=10){let n="";for(let e=0;e<t;e++)n+=Math.floor(10*Math.random());return e+n}tx.receivers=[];class tA{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,n=50){let r,i;let s="undefined"!=typeof MessageChannel?new MessageChannel:null;if(!s)throw Error("connection_unavailable");return new Promise((o,a)=>{let l=tk("",20);s.port1.start();let u=setTimeout(()=>{a(Error("unsupported_event"))},n);i={messageChannel:s,onMessage(e){if(e.data.eventId===l)switch(e.data.status){case"ack":clearTimeout(u),r=setTimeout(()=>{a(Error("timeout"))},3e3);break;case"done":clearTimeout(r),o(e.data.response);break;default:clearTimeout(u),clearTimeout(r),a(Error("invalid_response"))}}},this.handlers.add(i),s.port1.addEventListener("message",i.onMessage),this.target.postMessage({eventType:e,eventId:l,data:t},[s.port2])}).finally(()=>{i&&this.removeMessageHandler(i)})}}function tR(){return window}function tN(){return void 0!==tR().WorkerGlobalScope&&"function"==typeof tR().importScripts}async function tO(){if(!(null==navigator?void 0:navigator.serviceWorker))return null;try{return(await navigator.serviceWorker.ready).active}catch(e){return null}}let tD="firebaseLocalStorageDb",tP="firebaseLocalStorage",tL="fbase_key";class tM{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 tF(e,t){return e.transaction([tP],t?"readwrite":"readonly").objectStore(tP)}function tU(){let e=indexedDB.open(tD,1);return new Promise((t,n)=>{e.addEventListener("error",()=>{n(e.error)}),e.addEventListener("upgradeneeded",()=>{let t=e.result;try{t.createObjectStore(tP,{keyPath:tL})}catch(e){n(e)}}),e.addEventListener("success",async()=>{let n=e.result;n.objectStoreNames.contains(tP)?t(n):(n.close(),await new tM(indexedDB.deleteDatabase(tD)).toPromise(),t(await tU()))})})}async function tV(e,t,n){return new tM(tF(e,!0).put({[tL]:t,value:n})).toPromise()}async function tj(e,t){let n=tF(e,!1).get(t),r=await new tM(n).toPromise();return void 0===r?null:r.value}function tB(e,t){return new tM(tF(e,!0).delete(t)).toPromise()}class tq{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=await tU()),this.db}async _withRetries(e){let t=0;for(;;)try{let t=await this._openDb();return await e(t)}catch(e){if(t++>3)throw e;this.db&&(this.db.close(),this.db=void 0)}}async initializeServiceWorkerMessaging(){return tN()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=tx._getInstance(tN()?self:null),this.receiver._subscribe("keyChanged",async(e,t)=>({keyProcessed:(await this._poll()).includes(t.key)})),this.receiver._subscribe("ping",async(e,t)=>["keyChanged"])}async initializeSender(){var e,t;if(this.activeServiceWorker=await tO(),!this.activeServiceWorker)return;this.sender=new tA(this.activeServiceWorker);let n=await this.sender._send("ping",{},800);n&&(null===(e=n[0])||void 0===e?void 0:e.fulfilled)&&(null===(t=n[0])||void 0===t?void 0:t.value.includes("keyChanged"))&&(this.serviceWorkerReceiverAvailable=!0)}async notifyServiceWorker(e){var t;if(this.sender&&this.activeServiceWorker&&((null===(t=null==navigator?void 0:navigator.serviceWorker)||void 0===t?void 0:t.controller)||null)===this.activeServiceWorker)try{await this.sender._send("keyChanged",{key:e},this.serviceWorkerReceiverAvailable?800:50)}catch(e){}}async _isAvailable(){try{if(!indexedDB)return!1;let e=await tU();return await tV(e,tb,"1"),await tB(e,tb),!0}catch(e){}return!1}async _withPendingWrite(e){this.pendingWrites++;try{await e()}finally{this.pendingWrites--}}async _set(e,t){return this._withPendingWrite(async()=>(await this._withRetries(n=>tV(n,e,t)),this.localCache[e]=t,this.notifyServiceWorker(e)))}async _get(e){let t=await this._withRetries(t=>tj(t,e));return this.localCache[e]=t,t}async _remove(e){return this._withPendingWrite(async()=>(await this._withRetries(t=>tB(t,e)),delete this.localCache[e],this.notifyServiceWorker(e)))}async _poll(){let e=await this._withRetries(e=>new tM(tF(e,!1).getAll()).toPromise());if(!e||0!==this.pendingWrites)return[];let t=[],n=new Set;if(0!==e.length)for(let{fbase_key:r,value:i}of e)n.add(r),JSON.stringify(this.localCache[r])!==JSON.stringify(i)&&(this.notifyListeners(r,i),t.push(r));for(let e of Object.keys(this.localCache))this.localCache[e]&&!n.has(e)&&(this.notifyListeners(e,null),t.push(e));return t}notifyListeners(e,t){this.localCache[e]=t;let n=this.listeners[e];if(n)for(let e of Array.from(n))e(t)}startPolling(){this.stopPolling(),this.pollTimer=setInterval(async()=>this._poll(),800)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}_addListener(e,t){0===Object.keys(this.listeners).length&&this.startPolling(),this.listeners[e]||(this.listeners[e]=new Set,this._get(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),0===this.listeners[e].size&&delete this.listeners[e]),0===Object.keys(this.listeners).length&&this.stopPolling()}}function tz(e,t){return A(e,"POST","/v2/accounts/mfaSignIn:start",k(e,t))}tq.type="LOCAL",eS("rcb"),new I(3e4,6e4);let t$="recaptcha";async function tK(e,t,n){var r;if(!e._getRecaptchaConfig())try{await eO(e)}catch(e){console.log("Failed to initialize reCAPTCHA Enterprise config. Triggering the reCAPTCHA v2 verification.")}try{let i;if(i="string"==typeof t?{phoneNumber:t}
15:t,"session"in i){let t=i.session;if("phoneNumber"in i){v("enroll"===t.type,e,"internal-error");let r={idToken:t.credential,phoneEnrollmentInfo:{phoneNumber:i.phoneNumber,clientType:"CLIENT_TYPE_WEB"}},s=async(e,t)=>{if(t.phoneEnrollmentInfo.captchaResponse===ek){v((null==n?void 0:n.type)===t$,e,"argument-error");let r=await tG(e,t,n);return tw(e,r)}return tw(e,t)},o=eN(e,r,"mfaSmsEnrollment",s,"PHONE_PROVIDER");return(await o.catch(e=>Promise.reject(e))).phoneSessionInfo.sessionInfo}{v("signin"===t.type,e,"internal-error");let s=(null===(r=i.multiFactorHint)||void 0===r?void 0:r.uid)||i.multiFactorUid;v(s,e,"missing-multi-factor-info");let o={mfaPendingCredential:t.credential,mfaEnrollmentId:s,phoneSignInInfo:{clientType:"CLIENT_TYPE_WEB"}},a=async(e,t)=>{if(t.phoneSignInInfo.captchaResponse===ek){v((null==n?void 0:n.type)===t$,e,"argument-error");let r=await tG(e,t,n);return tz(e,r)}return tz(e,t)},l=eN(e,o,"mfaSmsSignIn",a,"PHONE_PROVIDER");return(await l.catch(e=>Promise.reject(e))).phoneResponseInfo.sessionInfo}}{let t={phoneNumber:i.phoneNumber,clientType:"CLIENT_TYPE_WEB"},r=async(e,t)=>{if(t.captchaResponse===ek){v((null==n?void 0:n.type)===t$,e,"argument-error");let r=await tG(e,t,n);return eG(e,r)}return eG(e,t)},s=eN(e,t,"sendVerificationCode",r,"PHONE_PROVIDER");return(await s.catch(e=>Promise.reject(e))).sessionInfo}}finally{null==n||n._reset()}}async function tG(e,t,n){v(n.type===t$,e,"argument-error");let r=await n.verify();v("string"==typeof r,e,"argument-error");let i=Object.assign({},t);if("phoneEnrollmentInfo"in i){let e=i.phoneEnrollmentInfo.phoneNumber,t=i.phoneEnrollmentInfo.captchaResponse,n=i.phoneEnrollmentInfo.clientType,s=i.phoneEnrollmentInfo.recaptchaVersion;return Object.assign(i,{phoneEnrollmentInfo:{phoneNumber:e,recaptchaToken:r,captchaResponse:t,clientType:n,recaptchaVersion:s}}),i}if(!("phoneSignInInfo"in i))return Object.assign(i,{recaptchaToken:r}),i;{let e=i.phoneSignInInfo.captchaResponse,t=i.phoneSignInInfo.clientType,n=i.phoneSignInInfo.recaptchaVersion;return Object.assign(i,{phoneSignInInfo:{recaptchaToken:r,captchaResponse:e,clientType:t,recaptchaVersion:n}}),i}}class tH{constructor(e){this.providerId=tH.PROVIDER_ID,this.auth=eI(e)}verifyPhoneNumber(e,t){return tK(this.auth,e,(0,s.m9)(t))}static credential(e,t){return eY._fromVerification(e,t)}static credentialFromResult(e){return tH.credentialFromTaggedObject(e)}static credentialFromError(e){return tH.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;let{phoneNumber:t,temporaryProof:n}=e;return t&&n?eY._fromTokenResponse(t,n):null}}function tW(e,t){return t?er(t):(v(e._popupRedirectResolver,e,"argument-error"),e._popupRedirectResolver)}tH.PROVIDER_ID="phone",tH.PHONE_SIGN_IN_METHOD="phone";class tQ extends eL{constructor(e){super("custom","custom"),this.params=e}_getIdTokenResponse(e){return e$(e,this._buildIdpRequest())}_linkToIdToken(e,t){return e$(e,this._buildIdpRequest(t))}_getReauthenticationResolver(e){return e$(e,this._buildIdpRequest())}_buildIdpRequest(e){let 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 tX(e){return tr(e.auth,new tQ(e),e.bypassAuthState)}function tY(e){let{auth:t,user:n}=e;return v(n,t,"internal-error"),tn(n,new tQ(e),e.bypassAuthState)}async function tJ(e){let{auth:t,user:n}=e;return v(n,t,"internal-error"),tt(n,new tQ(e),e.bypassAuthState)}class tZ{constructor(e,t,n,r,i=!1){this.auth=e,this.resolver=n,this.user=r,this.bypassAuthState=i,this.pendingPromise=null,this.eventManager=null,this.filter=Array.isArray(t)?t:[t]}execute(){return new Promise(async(e,t)=>{this.pendingPromise={resolve:e,reject:t};try{this.eventManager=await this.resolver._initialize(this.auth),await this.onExecution(),this.eventManager.registerConsumer(this)}catch(e){this.reject(e)}})}async onAuthEvent(e){let{urlResponse:t,sessionId:n,postBody:r,tenantId:i,error:s,type:o}=e;if(s){this.reject(s);return}let a={auth:this.auth,requestUri:t,sessionId:n,tenantId:i||void 0,postBody:r||void 0,user:this.user,bypassAuthState:this.bypassAuthState};try{this.resolve(await this.getIdpTask(o)(a))}catch(e){this.reject(e)}}onError(e){this.reject(e)}getIdpTask(e){switch(e){case"signInViaPopup":case"signInViaRedirect":return tX;case"linkViaPopup":case"linkViaRedirect":return tJ;case"reauthViaPopup":case"reauthViaRedirect":return tY;default:f(this.auth,"internal-error")}}resolve(e){var t,n;t=this.pendingPromise,n="Pending promise was never set",t||w(n),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){var t,n;t=this.pendingPromise,n="Pending promise was never set",t||w(n),this.pendingPromise.reject(e),this.unregisterAndCleanUp()}unregisterAndCleanUp(){this.eventManager&&this.eventManager.unregisterConsumer(this),this.pendingPromise=null,this.cleanUp()}}let t0=new I(2e3,1e4);
15async function t1(e,t,n){if((0,i.rh)(e.app))return Promise.reject(p(e,"operation-not-supported-in-this-environment"));let r=eI(e);!function(e,t,n){if(!(t instanceof n))throw n.name!==t.constructor.name&&f(e,"argument-error"),m(e,"argument-error",`Type of ${t.constructor.name} does not match expected instance.Did you pass a reference from a different Auth SDK?`)}(e,t,e0);let s=tW(r,n);return new t2(r,"signInViaPopup",t,s).executeNotNull()}class t2 extends tZ{constructor(e,t,n,r,i){super(e,t,r,i),this.provider=n,this.authWindow=null,this.pollId=null,t2.currentPopupAction&&t2.currentPopupAction.cancel(),t2.currentPopupAction=this}async executeNotNull(){let e=await this.execute();return v(e,this.auth,"internal-error"),e}async onExecution(){var e,t;e=1===this.filter.length,t="Popup operations only handle one event",e||w(t);let n=tk();this.authWindow=await this.resolver._openPopup(this.auth,this.provider,this.filter[0],n),this.authWindow.associatedEvent=n,this.resolver._originValidation(this.auth).catch(e=>{this.reject(e)}),this.resolver._isIframeWebStorageSupported(this.auth,e=>{e||this.reject(p(this.auth,"web-storage-unsupported"))}),this.pollUserCancellation()}get eventId(){var e;return(null===(e=this.authWindow)||void 0===e?void 0:e.associatedEvent)||null}cancel(){this.reject(p(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,t2.currentPopupAction=null}pollUserCancellation(){let e=()=>{var t,n;if(null===(n=null===(t=this.authWindow)||void 0===t?void 0:t.window)||void 0===n?void 0:n.closed){this.pollId=window.setTimeout(()=>{this.pollId=null,this.reject(p(this.auth,"popup-closed-by-user"))},8e3);return}this.pollId=window.setTimeout(e,t0.get())};e()}}t2.currentPopupAction=null;let t4=new Map;class t6 extends tZ{constructor(e,t,n=!1){super(e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],t,void 0,n),this.eventId=null}async execute(){let e=t4.get(this.auth._key());if(!e){try{let t=await t5(this.resolver,this.auth)?await super.execute():null;e=()=>Promise.resolve(t)}catch(t){e=()=>Promise.reject(t)}t4.set(this.auth._key(),e)}return this.bypassAuthState||t4.set(this.auth._key(),()=>Promise.resolve(null)),e()}async onAuthEvent(e){if("signInViaRedirect"===e.type)return super.onAuthEvent(e);if("unknown"===e.type){this.resolve(null);return}if(e.eventId){let t=await this.auth._redirectUserForId(e.eventId);if(t)return this.user=t,super.onAuthEvent(e);this.resolve(null)}}async onExecution(){}cleanUp(){}}async function t5(e,t){let n=es("pendingRedirect",t.config.apiKey,t.name),r=er(e._redirectPersistence);if(!await r._isAvailable())return!1;let i=await r._get(n)==="true";return await r._remove(n),i}function t9(e,t){t4.set(e._key(),t)}async function t3(e,t,n=!1){if((0,i.rh)(e.app))return Promise.reject(g(e));let r=eI(e),s=tW(r,t),o=new t6(r,s,n),a=await o.execute();return a&&!n&&(delete a.user._redirectEventId,await r._persistUserIfCurrent(a.user),await r._setRedirectUser(null,t)),a}class t8{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(n=>{this.isEventForConsumer(e,n)&&(t=!0,this.sendToConsumer(e,n),this.saveEventToCache(e))}),this.hasHandledPotentialRedirect||!function(e){switch(e.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return!0;case"unknown":return ne(e);default:return!1}}(e)||(this.hasHandledPotentialRedirect=!0,t||(this.queuedRedirectEvent=e,t=!0)),t}sendToConsumer(e,t){var n;if(e.error&&!ne(e)){let r=(null===(n=e.error.code)||void 0===n?void 0:n.split("auth/")[1])||"internal-error";t.onError(p(this.auth,r))}else t.onAuthEvent(e)}isEventForConsumer(e,t){let n=null===t.eventId||!!e.eventId&&e.eventId===t.eventId;return t.filter.includes(e.type)&&n}hasEventBeenHandled(e){return Date.now()-this.lastProcessedEventTime>=6e5&&this.cachedEventUids.clear(),this.cachedEventUids.has(t7(e))}saveEventToCache(e){this.cachedEventUids.add(t7(e)),this.lastProcessedEventTime=
15Date.now()}}function t7(e){return[e.type,e.eventId,e.sessionId,e.tenantId].filter(e=>e).join("-")}function ne({type:e,error:t}){return"unknown"===e&&(null==t?void 0:t.code)==="auth/no-auth-event"}async function nt(e,t={}){return A(e,"GET","/v1/projects",t)}let nn=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,nr=/^https?/;async function ni(e){if(e.config.emulator)return;let{authorizedDomains:t}=await nt(e);for(let e of t)try{if(function(e){let t=b(),{protocol:n,hostname:r}=new URL(t);if(e.startsWith("chrome-extension://")){let i=new URL(e);return""===i.hostname&&""===r?"chrome-extension:"===n&&e.replace("chrome-extension://","")===t.replace("chrome-extension://",""):"chrome-extension:"===n&&i.hostname===r}if(!nr.test(n))return!1;if(nn.test(e))return r===e;let i=e.replace(/\./g,"\\.");return RegExp("^(.+\\."+i+"|"+i+")$","i").test(r)}(e))return}catch(e){}f(e,"unauthorized-domain")}let ns=new I(3e4,6e4);function no(){let e=tR().___jsl;if(null==e?void 0:e.H){for(let t of Object.keys(e.H))if(e.H[t].r=e.H[t].r||[],e.H[t].L=e.H[t].L||[],e.H[t].r=[...e.H[t].L],e.CP)for(let t=0;t<e.CP.length;t++)e.CP[t]=null}}let na=null,nl=new I(5e3,15e3),nu={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},nc=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);async function nh(e){let t=await (na=na||new Promise((t,n)=>{var r,i,s,o;function a(){no(),gapi.load("gapi.iframes",{callback:()=>{t(gapi.iframes.getContext())},ontimeout:()=>{no(),n(p(e,"network-request-failed"))},timeout:ns.get()})}if(null===(i=null===(r=tR().gapi)||void 0===r?void 0:r.iframes)||void 0===i?void 0:i.Iframe)t(gapi.iframes.getContext());else if(null===(s=tR().gapi)||void 0===s?void 0:s.load)a();else{let t=eS("iframefcb");return tR()[t]=()=>{gapi.load?a():n(p(e,"network-request-failed"))},(o=`${eT.gapiScript}?onload=${t}`,eT.loadJS(o)).catch(e=>n(e))}}).catch(e=>{throw na=null,e})),n=tR().gapi;return v(n,e,"internal-error"),t.open({where:document.body,url:function(e){let t=e.config;v(t.authDomain,e,"auth-domain-config-required");let n=t.emulator?E(t,"emulator/auth/iframe"):`https://${e.config.authDomain}/__/auth/iframe`,r={apiKey:t.apiKey,appName:e.name,v:i.Jn},o=nc.get(e.config.apiHost);o&&(r.eid=o);let a=e._getFrameworks();return a.length&&(r.fw=a.join(",")),`${n}?${(0,s.xO)(r).slice(1)}`}(e),messageHandlersFilter:n.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:nu,dontclear:!0},t=>new Promise(async(n,r)=>{await t.restyle({setHideOnLeave:!1});let i=p(e,"network-request-failed"),s=tR().setTimeout(()=>{r(i)},nl.get());function o(){tR().clearTimeout(s),n(t)}t.ping(o).then(o,()=>{r(i)})}))}let nd={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"};class nf{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch(e){}}}let np=encodeURIComponent("fac");async function nm(e,t,n,r,o,a){v(e.config.authDomain,e,"auth-domain-config-required"),v(e.config.apiKey,e,"invalid-api-key");let l={apiKey:e.config.apiKey,appName:e.name,authType:n,redirectUrl:r,v:i.Jn,eventId:o};if(t instanceof e0)for(let[n,r]of(t.setDefaultLanguage(e.languageCode),l.providerId=t.providerId||"",(0,s.xb)(t.getCustomParameters())||(l.customParameters=JSON.stringify(t.getCustomParameters())),Object.entries(a||{})))l[n]=r;if(t instanceof e1){let e=t.getScopes().filter(e=>""!==e);e.length>0&&(l.scopes=e.join(","))}for(let t of(e.tenantId&&(l.tid=e.tenantId),Object.keys(l)))void 0===l[t]&&delete l[t];let u=await e._getAppCheckToken(),c=u?`#${np}=${encodeURIComponent(u)}`:"";return`${function({config:e}){return e.emulator?E(e,"emulator/auth/handler"):`https://${e.authDomain}/__/auth/handler`}(e)}?${(0,s.xO)(l).slice(1)}${c}`}let ng="webStorageSupport";class ny{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=tC,this._completeRedirectFn=t3,this._overrideRedirectResult=t9}async _openPopup(e,t,n,r){var i,o,a;o=null===(i=this.eventManagers[e._key()])||void 0===i?void 0:i.manager,a="_initialize() not called before _openPopup()",o||w(a);let l=await nm(e,t,n,b(),r);return function(e,t,n,r=500,i=600){let o=Math.max((window.screen.availHeight-i)/2,0).toString(),a=Math.max((window.screen.availWi
15dth-r)/2,0).toString(),l="",u=Object.assign(Object.assign({},nd),{width:r.toString(),height:i.toString(),top:o,left:a}),c=(0,s.z$)().toLowerCase();n&&(l=ec(c)?"_blank":n),el(c)&&(t=t||"http://localhost",u.scrollbars="yes");let h=Object.entries(u).reduce((e,[t,n])=>`${e}${t}=${n},`,"");if(function(e=(0,s.z$)()){var t;return em(e)&&!!(null===(t=window.navigator)||void 0===t?void 0:t.standalone)}(c)&&"_self"!==l)return function(e,t){let n=document.createElement("a");n.href=e,n.target=t;let r=document.createEvent("MouseEvent");r.initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,1,null),n.dispatchEvent(r)}(t||"",l),new nf(null);let d=window.open(t||"",l,h);v(d,e,"popup-blocked");try{d.focus()}catch(e){}return new nf(d)}(e,l,tk())}async _openRedirect(e,t,n,r){var i;return await this._originValidation(e),i=await nm(e,t,n,b(),r),tR().location.href=i,new Promise(()=>{})}_initialize(e){let t=e._key();if(this.eventManagers[t]){var n;let{manager:e,promise:r}=this.eventManagers[t];return e?Promise.resolve(e):(n="If manager is not set, promise should be",r||w(n),r)}let r=this.initAndGetManager(e);return this.eventManagers[t]={promise:r},r.catch(()=>{delete this.eventManagers[t]}),r}async initAndGetManager(e){let t=await nh(e),n=new t8(e);return t.register("authEvent",t=>(v(null==t?void 0:t.authEvent,e,"invalid-auth-event"),{status:n.onEvent(t.authEvent)?"ACK":"ERROR"}),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[e._key()]={manager:n},this.iframes[e._key()]=t,n}_isIframeWebStorageSupported(e,t){this.iframes[e._key()].send(ng,{type:ng},n=>{var r;let i=null===(r=null==n?void 0:n[0])||void 0===r?void 0:r[ng];void 0!==i&&t(!!i),f(e,"internal-error")},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){let t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=ni(e)),this.originValidationPromises[t]}get _shouldInitProactively(){return eg()||eu()||em()}}class nv{constructor(e){this.factorId=e}_process(e,t,n){switch(t.type){case"enroll":return this._finalizeEnroll(e,t.credential,n);case"signin":return this._finalizeSignIn(e,t.credential);default:return w("unexpected MultiFactorSessionType")}}}class nw extends nv{constructor(e){super("phone"),this.credential=e}static _fromCredential(e){return new nw(e)}_finalizeEnroll(e,t,n){return A(e,"POST","/v2/accounts/mfaEnrollment:finalize",k(e,{idToken:t,displayName:n,phoneVerificationInfo:this.credential._makeVerificationRequest()}))}_finalizeSignIn(e,t){return A(e,"POST","/v2/accounts/mfaSignIn:finalize",k(e,{mfaPendingCredential:t,phoneVerificationInfo:this.credential._makeVerificationRequest()}))}}class nb{constructor(){}static assertion(e){return nw._fromCredential(e)}}nb.FACTOR_ID="phone";class n_{static assertionForEnrollment(e,t){return nI._fromSecret(e,t)}static assertionForSignIn(e,t){return nI._fromEnrollmentId(e,t)}static async generateSecret(e){var t,n;v(void 0!==(null===(t=e.user)||void 0===t?void 0:t.auth),"internal-error");let r=await A(n=e.user.auth,"POST","/v2/accounts/mfaEnrollment:start",k(n,{idToken:e.credential,totpEnrollmentInfo:{}}));return nE._fromStartTotpMfaEnrollmentResponse(r,e.user.auth)}}n_.FACTOR_ID="totp";class nI extends nv{constructor(e,t,n){super("totp"),this.otp=e,this.enrollmentId=t,this.secret=n}static _fromSecret(e,t){return new nI(t,void 0,e)}static _fromEnrollmentId(e,t){return new nI(t,e)}async _finalizeEnroll(e,t,n){return v(void 0!==this.secret,e,"argument-error"),A(e,"POST","/v2/accounts/mfaEnrollment:finalize",k(e,{idToken:t,displayName:n,totpVerificationInfo:this.secret._makeTotpVerificationInfo(this.otp)}))}async _finalizeSignIn(e,t){v(void 0!==this.enrollmentId&&void 0!==this.otp,e,"argument-error");let n={verificationCode:this.otp};return A(e,"POST","/v2/accounts/mfaSignIn:finalize",k(e,{mfaPendingCredential:t,mfaEnrollmentId:this.enrollmentId,totpVerificationInfo:n}))}}class nE{constructor(e,t,n,r,i,s,o){this.sessionInfo=s,this.auth=o,this.secretKey=e,this.hashingAlgorithm=t,this.codeLength=n,this.codeIntervalSeconds=r,this.enrollmentCompletionDeadline=i}static _fromStartTotpMfaEnrollmentResponse(e,t){return new nE(e.totpSessionInfo.sharedSecretKey,e.totpSessionInfo.hashingAlgorithm,e.totpSessionInfo.verificationCodeLength,e.totpSessionInfo.peri
15odSec,new Date(e.totpSessionInfo.finalizeEnrollmentTime).toUTCString(),e.totpSessionInfo.sessionInfo,t)}_makeTotpVerificationInfo(e){return{sessionInfo:this.sessionInfo,verificationCode:e}}generateQrCodeUrl(e,t){var n;let r=!1;return(nT(e)||nT(t))&&(r=!0),r&&(nT(e)&&(e=(null===(n=this.auth.currentUser)||void 0===n?void 0:n.email)||"unknownuser"),nT(t)&&(t=this.auth.name)),`otpauth://totp/${t}:${e}?secret=${this.secretKey}&issuer=${t}&algorithm=${this.hashingAlgorithm}&digits=${this.codeLength}`}}function nT(e){return void 0===e||(null==e?void 0:e.length)===0}var nS="@firebase/auth",nC="1.10.7";class nx{constructor(e){this.auth=e,this.internalListeners=new Map}getUid(){var e;return this.assertAuthConfigured(),(null===(e=this.auth.currentUser)||void 0===e?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;let t=this.auth.onIdTokenChanged(t=>{e((null==t?void 0:t.stsTokenManager.accessToken)||null)});this.internalListeners.set(e,t),this.updateProactiveRefresh()}removeAuthTokenListener(e){this.assertAuthConfigured();let t=this.internalListeners.get(e);t&&(this.internalListeners.delete(e),t(),this.updateProactiveRefresh())}assertAuthConfigured(){v(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}let nk=(0,s.Pz)("authIdTokenMaxAge")||300,nA=null,nR=e=>async t=>{let n=t&&await t.getIdTokenResult(),r=n&&(new Date().getTime()-Date.parse(n.issuedAtTime))/1e3;if(r&&r>nk)return;let i=null==n?void 0:n.token;nA!==i&&(nA=i,await fetch(e,{method:i?"POST":"DELETE",headers:i?{Authorization:`Bearer ${i}`}:{}}))};function nN(e=(0,i.Mq)()){let t=(0,i.qX)(e,"auth");if(t.isInitialized())return t.getImmediate();let n=function(e,t){let n=(0,i.qX)(e,"auth");if(n.isInitialized()){let e=n.getImmediate(),r=n.getOptions();if((0,s.vZ)(r,null!=t?t:{}))return e;f(e,"already-initialized")}return n.initialize({options:t})}(e,{popupRedirectResolver:ny,persistence:[tq,tI,tC]}
15),r=(0,s.Pz)("authTokenSyncURL");if(r&&"boolean"==typeof isSecureContext&&isSecureContext){let e=new URL(r,location.origin);if(location.origin===e.origin){var o,a;let t=nR(e.toString());o=()=>t(n.currentUser),(0,s.m9)(n).beforeAuthStateChanged(t,o),a=e=>t(e),(0,s.m9)(n).onIdTokenChanged(a,void 0,void 0)}}let l=(0,s.q4)("auth");return l&&function(e,t,n){let r=eI(e);v(/^https?:\/\//.test(t),r,"invalid-emulator-scheme");let i=eD(t),{host:o,port:a}=function(e){let t=eD(e),n=/(\/\/)?([^?#/]+)/.exec(e.substr(t.length));if(!n)return{host:"",port:null};let r=n[2].split("@").pop()||"",i=/^(\[[^\]]+\])(:|$)/.exec(r);if(i){let e=i[1];return{host:e,port:eP(r.substr(e.length+1))}}{let[e,t]=r.split(":");return{host:e,port:eP(t)}}}(t),l=null===a?"":`:${a}`,u={url:`${i}//${o}${l}/`},c=Object.freeze({host:o,port:a,protocol:i.replace(":",""),options:Object.freeze({disableWarnings:!1})});if(!r._canInitEmulator){v(r.config.emulator&&r.emulatorConfig,r,"emulator-config-failed"),v((0,s.vZ)(u,r.config.emulator)&&(0,s.vZ)(c,r.emulatorConfig),r,"emulator-config-failed");return}r.config.emulator=u,r.emulatorConfig=c,r.settings.appVerificationDisabledForTesting=!0,(0,s.Xx)(o)?((0,s.Uo)(`${i}//${o}${l}`),(0,s.dp)("Auth",!0)):function(){function e(){let 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)}"undefined"!=typeof console&&"function"==typeof console.info&&console.info("WARNING: You are using the Auth Emulator, which is intended for local testing only. Do not use with production credentials."),"undefined"!=typeof window&&"undefined"!=typeof document&&("loading"===document.readyState?window.addEventListener("DOMContentLoaded",e):e())}()}(n,`http://${l}`),n}eT={loadJS:e=>new Promise((t,n)=>{var r,i;let s=document.createElement("script");s.setAttribute("src",e),s.onload=t,s.onerror=e=>{let t=p("internal-error");t.customData=e,n(t)},s.type="text/javascript",s.charset="UTF-8",(null!==(i=null===(r=document.getElementsByTagName("head"))||void 0===r?void 0:r[0])&&void 0!==i?i:document).appendChild(s)}),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="},r="Browser",(0,i.Xd)(new l.wA("auth",(e,{options:t})=>{let n=e.getProvider("app").getImmediate(),i=e.getProvider("heartbeat"),s=e.getProvider("app-check-internal"),{apiKey:o,authDomain:a}=n.options;v(o&&!o.includes(":"),"invalid-api-key",{appName:n.name});let l=new e_(n,i,s,{apiKey:o,authDomain:a,clientPlatform:r,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:ey(r)});return function(e,t){let n=(null==t?void 0:t.persistence)||[],r=(Array.isArray(n)?n:[n]).map(er);(null==t?void 0:t.errorMap)&&e._updateErrorMap(t.errorMap),e._initializeWithPersistence(r,null==t?void 0:t.popupRedirectResolver)}(l,t),l},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((e,t,n)=>{e.getProvider("auth-internal").initialize()})),(0,i.Xd)(new l.wA("auth-internal",e=>new nx(eI(e.getProvider("auth").getImmediate())),"PRIVATE").setInstantiationMode("EXPLICIT")),(0,i.KN)(nS,nC,function(e){switch(e){case"Node":return"node";case"ReactNative":return"rn";case"Worker":return"webworker";case"Cordova":return"cordova";case"WebExtension":return"web-extension";default:return}}(r)),(0,i.KN)(nS,nC,"esm2017")},109:function(e,t,n){"use strict";n.r(t),n.d(t,{AbstractUserDataWriter:function(){return ci},AggregateField:function(){return uo},AggregateQuerySnapshot:function(){return ua},Bytes:function(){return ul},CACHE_SIZE_UNLIMITED:function(){return l0},CollectionReference:function(){return lz},DocumentReference:function(){return lq},DocumentSnapshot:function(){return cf},FieldPath:function(){return uu},FieldValue:function(){return uh},Firestore:function(){return l1},FirestoreError:function(){return z},GeoPoint:function(){return ud},LoadBundleTask:function(){return lZ},PersistentCacheIndexManager:function(){return c3},Query:function(){return lB},QueryCompositeFilterConstraint:function(){return uQ},QueryConstraint:function(){return uK},QueryDocumentSnapshot:function(){return cp},QueryEndAtConstraint:function(){return u9},QueryFieldFilterConstraint:function(){return uH},QueryLimitConstraint:function(){return u0},QueryOrderByConstraint:function(){return uJ}
15,QuerySnapshot:function(){return cm},QueryStartAtConstraint:function(){return u4},SnapshotMetadata:function(){return cd},Timestamp:function(){return eo},Transaction:function(){return cX},VectorValue:function(){return uf},WriteBatch:function(){return cH},_AutoId:function(){return et},_ByteString:function(){return tZ},_DatabaseId:function(){return nr},_DocumentKey:function(){return ef},_EmptyAppCheckTokenProvider:function(){return Z},_EmptyAuthCredentialsProvider:function(){return G},_FieldPath:function(){return ed},_TestingHooks:function(){return ho},_cast:function(){return lL},_debugAssert:function(){return B},_internalAggregationQueryToProtoRunAggregationQueryRequest:function(){return hs},_internalQueryToProtoQueryTarget:function(){return hi},_isBase64Available:function(){return tJ},_logWarn:function(){return M},_validateIsNotUsedTogether:function(){return lN},addDoc:function(){return cx},aggregateFieldEqual:function(){return cc},aggregateQuerySnapshotEqual:function(){return ch},and:function(){return uY},arrayRemove:function(){return c1},arrayUnion:function(){return c0},average:function(){return cl},clearIndexedDbPersistence:function(){return l7},collection:function(){return l$},collectionGroup:function(){return lK},connectFirestoreEmulator:function(){return lj},count:function(){return cu},deleteAllPersistentCacheIndexes:function(){return ht},deleteDoc:function(){return cC},deleteField:function(){return cJ},disableNetwork:function(){return un},disablePersistentCacheIndexAutoCreation:function(){return he},doc:function(){return lG},documentId:function(){return uc},enableIndexedDbPersistence:function(){return l9},enableMultiTabIndexedDbPersistence:function(){return l3},enableNetwork:function(){return ut},enablePersistentCacheIndexAutoCreation:function(){return c7},endAt:function(){return u8},endBefore:function(){return u3},ensureFirestoreConfigured:function(){return l6},executeWrite:function(){return cR},getAggregateFromServer:function(){return cD},getCountFromServer:function(){return cO},getDoc:function(){return cy},getDocFromCache:function(){return cw},getDocFromServer:function(){return cb},getDocs:function(){return c_},getDocsFromCache:function(){return cI},getDocsFromServer:function(){return cE},getFirestore:function(){return l4},getPersistentCacheIndexManager:function(){return c8},increment:function(){return c2},initializeFirestore:function(){return l2},limit:function(){return u1},limitToLast:function(){return u2},loadBundle:function(){return ui},memoryEagerGarbageCollector:function(){return cU},memoryLocalCache:function(){return cj},memoryLruGarbageCollector:function(){return cV},namedQuery:function(){return us},onSnapshot:function(){return ck},onSnapshotsInSync:function(){return cA},or:function(){return uX},orderBy:function(){return uZ},persistentLocalCache:function(){return cB},persistentMultipleTabManager:function(){return cK},persistentSingleTabManager:function(){return c$},query:function(){return uG},queryEqual:function(){return lW},refEqual:function(){return lH},runTransaction:function(){return cY},serverTimestamp:function(){return cZ},setDoc:function(){return cT},setIndexConfiguration:function(){return c5},setLogLevel:function(){return D},snapshotEqual:function(){return cg},startAfter:function(){return u5},startAt:function(){return u6},sum:function(){return ca},terminate:function(){return ur},updateDoc:function(){return cS},vector:function(){return c4},waitForPendingWrites:function(){return ue},where:function(){return uW},writeBatch:function(){return c6}});var r,i,s,o,a,l,u,c,h,d,f,p,m,g,y=n(2238),v=n(8463),w=n(3333),b=n(1683),_="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},I={};(function(){function e(){this.blockSize=-1,this.blockSize=64,this.g=[,,,,],this.B=Array(this.blockSize),this.o=this.h=0,this.s()}function t(e,t,n){n||(n=0);var r=Array(16);if("string"==typeof t)for(var i=0;16>i;++i)r[i]=t.charCodeAt(n++)|t.charCodeAt(n++)<<8|t.charCodeAt(n++)<<16|t.charCodeAt(n++)<<24;else for(i=0;16>i;++i)r[i]=t[n++]|t[n++]<<8|t[n++]<<16|t[n++]<<24;t=e.g[0],n=e.g[1],i=e.g[2];var s=e.g[3],o=t+(s^n&(i^s))+r[0]+3614090360&4294967295;o=s+(i^(t=n+(o<<7&4294967295|o>>>25))&(n^i))+r[1]+3905402710&4294967295,o=i+(n^(s=t+(o<<12&4294967295|o>>>20))&(t^n))+r[2]+606105819&4294967295,o=n+(t^(i=s+(o<<17&4294967295|o>>>15))&(s^t))+r[3]+3250441966&4294967295,o=t+(s^(n=i+(o<<22&4294967295|o>>>10))&(i^s))+r[4]+4118548399&4294967295,o=s+(i^(t=n+(o<<7&4294967295|o>>>25))&(n^i))+r[5]+1200080426&4294967295,o=i+(n^(s=t+(o<<12&4294967295|o>>>20))&(t^n))+r[6]+2821735955&4294967295,o=n+(t^(i=s+(o<<17&4294967295|o>>>15))&(s^t))+r[7]+4249261313&4294967295,o=t+(s^(n=i+(o<<22&4294967295|o>>>10))&(i^s))+r[8]+1770035416&4294967295,o=s+(i^(t=n+(o<<7&4294967295|o>>>25))&(n^i))+r[9]+2336552879&4294967295,o=i+(n^(s=t+(o<<12&4294967295|o>>>20))&(t^n))+r[10]+4294925233&4294967295,o=n+(t^(i=s+(o<<17&4294967295|o>>>15))&(s^t))+r[11]+2304563134&4294967295,o=t+(s^(n=i+(o<<22&4294967295|o>>>10))&(i^s))+r[12]+1804603682&4294967295,o=s+(i^(t=n+(o<<7&4294967295|o>>>25))&(n^i))+r[13]+4254626195&4294967295,o=i+(n^(s=t+(o<<12&4294967295|o>>>20))&(t^n))+r[14]+2792965006&4294967295,o=n+(t^(i=s+(o<<17&4294967295|o>>>15))&(s^t))+r[15]+1236535329&4294967295,n=i+(o<<22&4294967295|o>>>10),o=t+(i^s&(n^i))+r[1]+4129170786&4294967295,t=n+(o<<5&4294967295|o>>>27),o=s+(n^i&(t^n))+r[6]+3225465664&4294967295,s=t+(o<<9&4294967295|o>>>23),o=i+(t^n&(s^t))+r[11]+643717713&4294967295,i=s+(o<<14&4294967295|o>>>18),o=n+(s^t&(i^s))+r[0]+3921069994&4294967295,n=i+(o<<20&4294967295|o>>>12),o=t+(i^s&(n^i))+r[5]+3593408605&4294967295,t=n+(o<<5&4294967295|o>>>27),o=s+(n^i&(t^n))+r[10]+38016083&4294967295,s=t+(o<<9&4294967295|o>>>23),o=i+(t^n&(s^t))+r[15]+3634488961&4294967295,i=s+(o<<14&4294967295|o>>>18),o=n+(s^t&(i^s))+r[4]+3889429448&4294967295,n=i+(o<<20&4294967295|o>>>12),o=t+(i^s&(n^i))+r[9]+568446438&4294967295,t=n+(o<<5&4294967295|o>>>27),o=s+(n^i&(t^n))+r[14]+3275163606&4294967295,s=t+(o<<9&4294967295|o>>>23),o=i+(t^n&(s^t))+r[3]+4107603335&4294967295,i=s+(o<<14&4294967295|o>>>18),o=n+(s^t&(i^s))+r[8]+1163531501&4294967295,n=i+(o<<20&4294967295|o>>>12),o=t+(i^s&(n^i))+r[13]+2850285829&4294967295,t=n+(o<<5&4294967295|o>>>27),o=s+(n^i&(t^n))+r[2]+4243563512&4294967295,s=t+(o<<9&4294967295|o>>>23),o=i+(t^n&(s^t))+r[7]+1735328473&4294967295,i=s+(o<<14&4294967295|o>>>18),o=n+(s^t&(i^s))+r[12]+2368359562&4294967295,o=t+((n=i+(o<<20&4294967295|o>>>12))^i^s)+r[5]+4294588738&4294967295,o=s+((t=n+(o<<4&4294967295|o>>>28))^n^i)+r[8]+2272392833&4294967295,o=i+((s=t+(o<<11&4294967295|o>>>21))^t^n)+r[11]+1839030562&4294967295,o=n+((i=s+(o<<16&4294967295|o>>>16))^s^t)+r[14]+4259657740&4294967295,o=t+((n=i+(o<<23&4294967295|o>>>9))^i^s)+r[1]+2763975236&4294967295,o=s+((t=n+(o<<4&4294967295|o>>>28))^n^i)+r[4]+1272893353&4294967295,o=i+((s=t+(o<<11&4294967295|o>>>21))^t^n)+r[7]+4139469664&4294967295,o=n+((i=s+(o<<16&4294967295|o>>>16))^s^t)+r[10]+3200236656&4294967295,o=t+((n=i+(o<<23&4294967295|o>>>9))^i^s)+r[13]+681279174&4294967295,o=s+((t=n+(o<<4&4294967295|o>>>28))^n^i)+r[0]+3936430074&4294967295,o=i+((s=t+(o<<11&4294967295|o>>>21))^t^n)+r[3]+3572445317&4294967295,o=n+((i=s+(o<<16&4294967295|o>>>16))^s^t)+r[6]+76029189&4294967295,o=t+((n=i+(o<<23&4294967295|o>>>9))^i^s)+r[9]+3654602809&4294967295,o=s+((t=n+(o<<4&4294967295|o>>>28))^n^i)+r[12]+3873151461&4294967295,o=i+((s=t+(o<<11&4294967295|o>>>21))^t^n)+r[15]+530742520&4294967295,o=n+((i=s+(o<<16&4294967295|o>>>16))^s^t)+r[2]+3299628645&4294967295,n=i+(o<<23&4294967295|o>>>9),o=t+(i^(n|~s))+r[0]+4096336452&4294967295,t=n+(o<<6&4294967295|o>>>26),o=s+(n^(t|~i))+r[7]+1126891415&4294967295,s=t+(o<<10&4294967295|o>>>22),o=i+(t^(s|~n))+r[14]+2878612391&4294967295,i=s+(o<<15&4294967295|o>>>17),o=n+(s^(i|~t))+r[5]+4237533241&4294967295,n=i+(o<<21&4294967295|o>>>11),o=t+(i^(n|~s))+r[12]+1700485571&4294967295,t=n+(o<<6&4294967295|o>>>26),o=s+(n^(t|~i))+r[3]+2399980690&4294967295,s=t+(o<<10&4294967295|o>>>22),o=i+(t^(s|~n))+r[10]+4293915773&4294967295,i=s+(o<<15&4294967295|o>>>17),o=n+(s^(i|~t))+r[1]+2240044497&4294967295,n=i+(o<<21&4294967295|o>>>11),o=t+(i^(n|~s))+r[8]+1873313359&4294967295,t=n+(o<<6&4294967295|o>>>26),o=s+(n^(t|~i))+r[15]+4264355552&4294967295,s=t+(o<<10&4294967295|o>>>22),o=i+(t^(s|~n))+r[6]+2734768916&4294967295,i=s+(o<<15&4294967295|o>>>17),o=n+(s^(i|~t))+r[13]+1309151649&4294967295,n=i+(o<<21&4294967295|o>>>11),o=t+(i^(n|~s))+r[4]+4149444226&4294967295,t=n+(o<<6&4294967295|o>>>
1526),o=s+(n^(t|~i))+r[11]+3174756917&4294967295,s=t+(o<<10&4294967295|o>>>22),o=i+(t^(s|~n))+r[2]+718787259&4294967295,i=s+(o<<15&4294967295|o>>>17),o=n+(s^(i|~t))+r[9]+3951481745&4294967295,e.g[0]=e.g[0]+t&4294967295,e.g[1]=e.g[1]+(i+(o<<21&4294967295|o>>>11))&4294967295,e.g[2]=e.g[2]+i&4294967295,e.g[3]=e.g[3]+s&4294967295}function n(e,t){this.h=t;for(var n=[],r=!0,i=e.length-1;0<=i;i--){var s=0|e[i];r&&s==t||(n[i]=s,r=!1)}this.g=n}!function(e,t){function n(){}n.prototype=t.prototype,e.D=t.prototype,e.prototype=new n,e.prototype.constructor=e,e.C=function(e,n,r){for(var i=Array(arguments.length-2),s=2;s<arguments.length;s++)i[s-2]=arguments[s];return t.prototype[n].apply(e,i)}}(e,function(){this.blockSize=-1}),e.prototype.s=function(){this.g[0]=1732584193,this.g[1]=4023233417,this.g[2]=2562383102,this.g[3]=271733878,this.o=this.h=0},e.prototype.u=function(e,n){void 0===n&&(n=e.length);for(var r=n-this.blockSize,i=this.B,s=this.h,o=0;o<n;){if(0==s)for(;o<=r;)t(this,e,o),o+=this.blockSize;if("string"==typeof e){for(;o<n;)if(i[s++]=e.charCodeAt(o++),s==this.blockSize){t(this,i),s=0;break}}else for(;o<n;)if(i[s++]=e[o++],s==this.blockSize){t(this,i),s=0;break}}this.h=s,this.o+=n},e.prototype.v=function(){var e=Array((56>this.h?this.blockSize:2*this.blockSize)-this.h);e[0]=128;for(var t=1;t<e.length-8;++t)e[t]=0;var n=8*this.o;for(t=e.length-8;t<e.length;++t)e[t]=255&n,n/=256;for(this.u(e),e=Array(16),t=n=0;4>t;++t)for(var r=0;32>r;r+=8)e[n++]=this.g[t]>>>r&255;return e};var s,o={};function a(e){var t;return -128<=e&&128>e?(t=function(e){return new n([0|e],0>e?-1:0)},Object.prototype.hasOwnProperty.call(o,e)?o[e]:o[e]=t(e)):new n([0|e],0>e?-1:0)}function l(e){if(isNaN(e)||!isFinite(e))return u;if(0>e)return p(l(-e));for(var t=[],r=1,i=0;e>=r;i++)t[i]=e/r|0,r*=4294967296;return new n(t,0)}var u=a(0),c=a(1),h=a(16777216);function d(e){if(0!=e.h)return!1;for(var t=0;t<e.g.length;t++)if(0!=e.g[t])return!1;return!0}function f(e){return -1==e.h}function p(e){for(var t=e.g.length,r=[],i=0;i<t;i++)r[i]=~e.g[i];return new n(r,~e.h).add(c)}function m(e,t){return e.add(p(t))}function g(e,t){for(;(65535&e[t])!=e[t];)e[t+1]+=e[t]>>>16,e[t]&=65535,t++}function y(e,t){this.g=e,this.h=t}function v(e,t){if(d(t))throw Error("division by zero");if(d(e))return new y(u,u);if(f(e))return t=v(p(e),t),new y(p(t.g),p(t.h));if(f(t))return t=v(e,p(t)),new y(p(t.g),t.h);if(30<e.g.length){if(f(e)||f(t))throw Error("slowDivide_ only works with positive integers.");for(var n=c,r=t;0>=r.l(e);)n=w(n),r=w(r);var i=b(n,1),s=b(r,1);for(r=b(r,2),n=b(n,2);!d(r);){var o=s.add(r);0>=o.l(e)&&(i=i.add(n),s=o),r=b(r,1),n=b(n,1)}return t=m(e,i.j(t)),new y(i,t)}for(i=u;0<=e.l(t);){for(r=48>=(r=Math.ceil(Math.log(n=Math.max(1,Math.floor(e.m()/t.m())))/Math.LN2))?1:Math.pow(2,r-48),o=(s=l(n)).j(t);f(o)||0<o.l(e);)n-=r,o=(s=l(n)).j(t);d(s)&&(s=c),i=i.add(s),e=m(e,o)}return new y(i,e)}function w(e){for(var t=e.g.length+1,r=[],i=0;i<t;i++)r[i]=e.i(i)<<1|e.i(i-1)>>>31;return new n(r,e.h)}function b(e,t){var r=t>>5;t%=32;for(var i=e.g.length-r,s=[],o=0;o<i;o++)s[o]=0<t?e.i(o+r)>>>t|e.i(o+r+1)<<32-t:e.i(o+r);return new n(s,e.h)}(s=n.prototype).m=function(){if(f(this))return-p(this).m();for(var e=0,t=1,n=0;n<this.g.length;n++){var r=this.i(n);e+=(0<=r?r:4294967296+r)*t,t*=4294967296}return e},s.toString=function(e){if(2>(e=e||10)||36<e)throw Error("radix out of range: "+e);if(d(this))return"0";if(f(this))return"-"+p(this).toString(e);for(var t=l(Math.pow(e,6)),n=this,r="";;){var i=v(n,t).g,s=((0<(n=m(n,i.j(t))).g.length?n.g[0]:n.h)>>>0).toString(e);if(d(n=i))return s+r;for(;6>s.length;)s="0"+s;r=s+r}},s.i=function(e){return 0>e?0:e<this.g.length?this.g[e]:this.h},s.l=function(e){return f(e=m(this,e))?-1:d(e)?0:1},s.abs=function(){return f(this)?p(this):this},s.add=function(e){for(var t=Math.max(this.g.length,e.g.length),r=[],i=0,s=0;s<=t;s++){var o=i+(65535&this.i(s))+(65535&e.i(s)),a=(o>>>16)+(this.i(s)>>>16)+(e.i(s)>>>16);i=a>>>16,o&=65535,a&=65535,r[s]=a<<16|o}return new n(r,-2147483648&r[r.length-1]?-1:0)},s.j=function(e){if(d(this)||d(e))return u;if(f(this))return f(e)?p(this).j(p(e)):p(p(this).j(e));if(f(e))return p(this.j(p(e)));if(0>this.l(h)&&0>e.l(h))return l(this.m()*e.m());for(var t=this.g.length+e.g.length,r=[],i=0;i<2*t;i++)r[i]=0;for(i=0;i<this.g.length;i++)for(var s=0;s<e.g.length;s++){var o=this.i(i)>>>16,a=65535&this.i(i),c=e.i(s)>>>16,m=65535&e.i(s);r[2*i+2*s]+=a*m,g(r,2*i+2*s),r[2*i+2*s+1]+=o*m,g(r,2*i+2*s+1),r[2*i+2*s+1]+=a*c,g(r,2*i+2*s+1),r[2*i+2*s+2]+=o*c,g(r,2*i+2*s+2)}for(i=0;i<t;i++)r[i]=r[2*i+1]<<16|r[2*i];for(i=t;i<2*t;i++)r[i]=0;return new n(r,0)},s.A=function(e){return v(this,e).h},s.and=function(e){for(var t=Math.max(this.g.length,e.g.length),r=[],i=0;i<t;i++)r[i]=this.i(i)&e.i(i);return new n(r,this.h&e.h)},s.or=function(e){for(var t=Math.max(this.g.length,e.g.length),r=[],i=0;i<t;i++)r[i]=this.i(i)|e.i(i);return new n(r,this.h|e.h)},s.xor=function(e){for(var t=Math.max(this.g.length,e.g.length),r=[],i=0;i<t;i++)r[i]=this.i(i)^e.i(i);return new n(r,this.h^e.h)},e.prototype.digest=e.prototype.v,e.prototype.reset=e.prototype.s,e.prototype.update=e.prototype.u,i=I.Md5=e,n.prototype.add=n.prototype.add,n.prototype.multiply=n.prototype.j,n.prototype.modulo=n.prototype.A,n.prototype.compare=n.prototype.l,n.prototype.toNumber=n.prototype.m,n.prototype.toString=n.prototype.toString,n.prototype.getBits=n.prototype.i,n.fromNumber=l,n.fromString=function e(t,n){if(0==t.length)throw Error("number format error: empty string");if(2>(n=n||10)||36<n)throw Error("radix out of range: "+n);
15if("-"==t.charAt(0))return p(e(t.substring(1),n));if(0<=t.indexOf("-"))throw Error('number format error: interior "-" character');for(var r=l(Math.pow(n,8)),i=u,s=0;s<t.length;s+=8){var o=Math.min(8,t.length-s),a=parseInt(t.substring(s,s+o),n);8>o?(o=l(Math.pow(n,o)),i=i.j(o).add(l(a))):i=(i=i.j(r)).add(l(a))}return i},r=I.Integer=n}).apply(void 0!==_?_:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{});var E="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},T={};(function(){var e,t,n,r="function"==typeof Object.defineProperties?Object.defineProperty:function(e,t,n){return e==Array.prototype||e==Object.prototype||(e[t]=n.value),e},i=function(e){e=["object"==typeof globalThis&&globalThis,e,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof E&&E];for(var t=0;t<e.length;++t){var n=e[t];if(n&&n.Math==Math)return n}throw Error("Cannot find global object")}(this);!function(e,t){if(t)e:{var n=i;e=e.split(".");for(var s=0;s<e.length-1;s++){var o=e[s];if(!(o in n))break e;n=n[o]}(t=t(s=n[e=e[e.length-1]]))!=s&&null!=t&&r(n,e,{configurable:!0,writable:!0,value:t})}}("Array.prototype.values",function(e){return e||function(){var e,t,n,r,i;return e=this,t=function(e,t){return t},e instanceof String&&(e+=""),n=0,r=!1,(i={next:function(){if(!r&&n<e.length){var i=n++;return{value:t(i,e[i]),done:!1}}return r=!0,{done:!0,value:void 0}}})[Symbol.iterator]=function(){return i},i}});var f=f||{},p=this||self;function m(e){var t=typeof e;return"array"==(t="object"!=t?t:e?Array.isArray(e)?"array":t:"null")||"object"==t&&"number"==typeof e.length}function g(e){var t=typeof e;return"object"==t&&null!=e||"function"==t}function y(e,t,n){return e.call.apply(e.bind,arguments)}function v(e,t,n){if(!e)throw Error();if(2<arguments.length){var r=Array.prototype.slice.call(arguments,2);return function(){var n=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(n,r),e.apply(t,n)}}return function(){return e.apply(t,arguments)}}function w(e,t,n){return(w=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?y:v).apply(null,arguments)}function b(e,t){var n=Array.prototype.slice.call(arguments,1);return function(){var t=n.slice();return t.push.apply(t,arguments),e.apply(this,t)}}function _(e,t){function n(){}n.prototype=t.prototype,e.aa=t.prototype,e.prototype=new n,e.prototype.constructor=e,e.Qb=function(e,n,r){for(var i=Array(arguments.length-2),s=2;s<arguments.length;s++)i[s-2]=arguments[s];return t.prototype[n].apply(e,i)}}function I(e){let t=e.length;if(0<t){let n=Array(t);for(let r=0;r<t;r++)n[r]=e[r];return n}return[]}function S(e,t){for(let t=1;t<arguments.length;t++){let n=arguments[t];if(m(n)){let t=e.length||0,r=n.length||0;e.length=t+r;for(let i=0;i<r;i++)e[t+i]=n[i]}else e.push(n)}}class C{constructor(e,t){this.i=e,this.j=t,this.h=0,this.g=null}get(){let e;return 0<this.h?(this.h--,e=this.g,this.g=e.next,e.next=null):e=this.i(),e}}function x(e){return/^[\s\xa0]*$/.test(e)}function k(){var e=p.navigator;return e&&(e=e.userAgent)?e:""}function A(e){return A[" "](e),e}A[" "]=function(){};var R=-1!=k().indexOf("Gecko")&&!(-1!=k().toLowerCase().indexOf("webkit")&&-1==k().indexOf("Edge"))&&!(-1!=k().indexOf("Trident")||-1!=k().indexOf("MSIE"))&&-1==k().indexOf("Edge");function N(e,t,n){for(let r in e)t.call(n,e[r],r,e)}function O(e){let t={};for(let n in e)t[n]=e[n];return t}let D="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function P(e,t){let n,r;for(let t=1;t<arguments.length;t++){for(n in r=arguments[t])e[n]=r[n];for(let t=0;t<D.length;t++)n=D[t],Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}}class L{constructor(){this.h=this.g=null}add(e,t){let n=M.get();n.set(e,t),this.h?this.h.next=n:this.g=n,this.h=n}}var M=new C(()=>new F,e=>e.reset());class F{constructor(){this.next=this.g=this.h=null}set(e,t){this.h=e,this.g=t,this.next=null}reset(){this.next=this.g=this.h=null}}let U,V=!1,j=new L,B=()=>{let e=p.Promise.resolve(void 0);U=()=>{e.then(q)}};var q=()=>{let e;for(var t;e=null,j.g&&(e=j.g,j.g=j.g.next,j.g||(j.h=null),e.next=null),t=e;){try{t.h.call(t.g)}catch(e){!function(e){p.setTimeout(()=>{throw e},0)}(e)}M.j(t),100>M.h&&(M.h++,t.next=M.g,M.g=t)}V=!1};function z(){this.s=this.s,this.C=this.C}function $(e,t){this.type=e,this.g=this.target=t,this.defaultPrevented=!1}z.prototype.s=!1,z.prototype.ma=function(){this.s||(this.s=!0,this.N())},z.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()},$.prototype.h=function(){this.defaultPrevented=!0};var K=function(){if(!p.addEventListener||!Object.defineProperty)return!1;var e=!1,t=Object.defineProperty({},"passive",{get:function(){e=!0}});try{let e=()=>{};p.addEventListener("test",e,t),p.removeEventListener("test",e,t)}catch(e){}return e}();function G(e,t){if($.call(this,e?e.type:""),this.relatedTarget=this.g=this.target=null,this.button=this.screenY=this.screenX=this.clientY=this.clientX=0,this.key="",this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.state=null,this.pointerId=0,this.pointerType="",this.i=null,e){var n=this.type=e.type,r=e.changedTouches&&e.changedTouches.length?e.changedTouches[0]:null;if(this.target=e.target||e.srcElement,this.g=t,t=e.relatedTarget){if(R){e:{try{A(t.nodeName);var i=!0;break e}catch(e){}i=!1}i||(t=null)}}
15else"mouseover"==n?t=e.fromElement:"mouseout"==n&&(t=e.toElement);this.relatedTarget=t,r?(this.clientX=void 0!==r.clientX?r.clientX:r.pageX,this.clientY=void 0!==r.clientY?r.clientY:r.pageY,this.screenX=r.screenX||0,this.screenY=r.screenY||0):(this.clientX=void 0!==e.clientX?e.clientX:e.pageX,this.clientY=void 0!==e.clientY?e.clientY:e.pageY,this.screenX=e.screenX||0,this.screenY=e.screenY||0),this.button=e.button,this.key=e.key||"",this.ctrlKey=e.ctrlKey,this.altKey=e.altKey,this.shiftKey=e.shiftKey,this.metaKey=e.metaKey,this.pointerId=e.pointerId||0,this.pointerType="string"==typeof e.pointerType?e.pointerType:H[e.pointerType]||"",this.state=e.state,this.i=e,e.defaultPrevented&&G.aa.h.call(this)}}_(G,$);var H={2:"touch",3:"pen",4:"mouse"};G.prototype.h=function(){G.aa.h.call(this);var e=this.i;e.preventDefault?e.preventDefault():e.returnValue=!1};var W="closure_listenable_"+(1e6*Math.random()|0),Q=0;function X(e,t,n,r,i){this.listener=e,this.proxy=null,this.src=t,this.type=n,this.capture=!!r,this.ha=i,this.key=++Q,this.da=this.fa=!1}function Y(e){e.da=!0,e.listener=null,e.proxy=null,e.src=null,e.ha=null}function J(e){this.src=e,this.g={},this.h=0}function Z(e,t){var n=t.type;if(n in e.g){var r,i=e.g[n],s=Array.prototype.indexOf.call(i,t,void 0);(r=0<=s)&&Array.prototype.splice.call(i,s,1),r&&(Y(t),0==e.g[n].length&&(delete e.g[n],e.h--))}}function ee(e,t,n,r){for(var i=0;i<e.length;++i){var s=e[i];if(!s.da&&s.listener==t&&!!n==s.capture&&s.ha==r)return i}return -1}J.prototype.add=function(e,t,n,r,i){var s=e.toString();(e=this.g[s])||(e=this.g[s]=[],this.h++);var o=ee(e,t,r,i);return -1<o?(t=e[o],n||(t.fa=!1)):((t=new X(t,this.src,s,!!r,i)).fa=n,e.push(t)),t};var et="closure_lm_"+(1e6*Math.random()|0),en={};function er(e,t,n,r,i,s){if(!t)throw Error("Invalid event type");var o=g(i)?!!i.capture:!!i,a=ea(e);if(a||(e[et]=a=new J(e)),(n=a.add(t,n,r,o,s)).proxy)return n;if(r=function e(t){return eo.call(e.src,e.listener,t)},n.proxy=r,r.src=e,r.listener=n,e.addEventListener)K||(i=o),void 0===i&&(i=!1),e.addEventListener(t.toString(),r,i);else if(e.attachEvent)e.attachEvent(es(t.toString()),r);else if(e.addListener&&e.removeListener)e.addListener(r);else throw Error("addEventListener and attachEvent are unavailable.");return n}function ei(e){if("number"!=typeof e&&e&&!e.da){var t=e.src;if(t&&t[W])Z(t.i,e);else{var n=e.type,r=e.proxy;t.removeEventListener?t.removeEventListener(n,r,e.capture):t.detachEvent?t.detachEvent(es(n),r):t.addListener&&t.removeListener&&t.removeListener(r),(n=ea(t))?(Z(n,e),0==n.h&&(n.src=null,t[et]=null)):Y(e)}}}function es(e){return e in en?en[e]:en[e]="on"+e}function eo(e,t){if(e.da)e=!0;else{t=new G(t,this);var n=e.listener,r=e.ha||e.src;e.fa&&ei(e),e=n.call(r,t)}return e}function ea(e){return(e=e[et])instanceof J?e:null}var el="__closure_events_fn_"+(1e9*Math.random()>>>0);function eu(e){return"function"==typeof e?e:(e[el]||(e[el]=function(t){return e.handleEvent(t)}),e[el])}function ec(){z.call(this),this.i=new J(this),this.M=this,this.F=null}function eh(e,t){var n,r=e.F;if(r)for(n=[];r;r=r.F)n.push(r);if(e=e.M,r=t.type||t,"string"==typeof t)t=new $(t,e);else if(t instanceof $)t.target=t.target||e;else{var i=t;P(t=new $(r,e),i)}if(i=!0,n)for(var s=n.length-1;0<=s;s--){var o=t.g=n[s];i=ed(o,r,!0,t)&&i}if(i=ed(o=t.g=e,r,!0,t)&&i,i=ed(o,r,!1,t)&&i,n)for(s=0;s<n.length;s++)i=ed(o=t.g=n[s],r,!1,t)&&i}function ed(e,t,n,r){if(!(t=e.i.g[String(t)]))return!0;t=t.concat();for(var i=!0,s=0;s<t.length;++s){var o=t[s];if(o&&!o.da&&o.capture==n){var a=o.listener,l=o.ha||o.src;o.fa&&Z(e.i,o),i=!1!==a.call(l,r)&&i}}return i&&!r.defaultPrevented}function ef(e,t,n){if("function"==typeof e)n&&(e=w(e,n));else if(e&&"function"==typeof e.handleEvent)e=w(e.handleEvent,e);else throw Error("Invalid listener argument");return 2147483647<Number(t)?-1:p.setTimeout(e,t||0)}_(ec,z),ec.prototype[W]=!0,ec.prototype.removeEventListener=function(e,t,n,r){!function e(t,n,r,i,s){if(Array.isArray(n))for(var o=0;o<n.length;o++)e(t,n[o],r,i,s);else(i=g(i)?!!i.capture:!!i,r=eu(r),t&&t[W])?(t=t.i,(n=String(n).toString())in t.g&&-1<(r=ee(o=t.g[n],r,i,s))&&(Y(o[r]),Array.prototype.splice.call(o,r,1),0==o.length&&(delete t.g[n],t.h--))):t&&(t=ea(t))&&(n=t.g[n.toString()],t=-1,n&&(t=ee(n,r,i,s)),(r=-1<t?n[t]:null)&&ei(r))}(this,e,t,n,r)},ec.prototype.N=function(){if(ec.aa.N.call(this),this.i){var e,t=this.i;for(e in t.g){for(var n=t.g[e],r=0;r<n.length;r++)Y(n[r]);delete t.g[e],t.h--}}this.F=null},ec.prototype.K=function(e,t,n,r){return this.i.add(String(e),t,!1,n,r)},ec.prototype.L=function(e,t,n,r){return this.i.add(String(e),t,!0,n,r)};class ep extends z{constructor(e,t){super(),this.m=e,this.l=t,this.h=null,this.i=!1,this.g=null}j(e){this.h=arguments,this.g?this.i=!0:function e(t){t.g=ef(()=>{t.g=null,t.i&&(t.i=!1,e(t))},t.l);let n=t.h;t.h=null,t.m.apply(null,n)}(this)}N(){super.N(),this.g&&(p.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function em(e){z.call(this),this.h=e,this.g={}}_(em,z);var eg=[];function ey(e){N(e.g,function(e,t){this.g.hasOwnProperty(t)&&ei(e)},e),e.g={}}em.prototype.N=function(){em.aa.N.call(this),ey(this)},em.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var ev=p.JSON.stringify,ew=p.JSON.parse,eb=class{stringify(e){return p.JSON.stringify(e,void 0)}parse(e){return p.JSON.parse(e,void 0)}};function e_(){}function eI(e){return e.h||(e.h=e.i())}function eE(){}e_.prototype.h=null;var eT={OPEN:"a",kb:"b",Ja:"c",wb:"d"};function eS(){$.call(this,"d")}function eC(){$.call(this,"c")}_(eS,$),_(eC,$);var ex={},ek=null;function eA(){return ek=ek||new ec}function eR(e){$.call(this,ex.La,e)}function eN(e){let t=eA();eh(t,new eR(t))}function eO(e,t){$.call(this,ex.STAT_EVENT,e),this.stat=t}function eD(e){let t=eA();eh(t,new eO(t,e))}function eP(e,t){$.call(this,ex.Ma,e),this.size=t}function eL(e,t){if("function"!=typeof e)throw Error("Fn must not be null and must be a function");return p.setTimeout(function(){e()},t)}function eM(){this.g=!0}function eF(e,t,n,r){e.info(function(){return"XMLHTTP TEXT ("+t+"): "+function(e,t){if(!e.g)return t;if(!t)return null;try{var n=JSON.parse(t);if(n){for(e=0;e<n.length;e++)if(Array.isArray(n[e])){var r=n[e];if(!(2>r.length)){var i=r[1];if(Array.isArray(i)&&!(1>i.length)){var s=i[0];if("noop"!=s&&"stop"!=s&&"close"!=s)for(var o=1;o<i.length;o++)i[o]=""}}}}return ev(n)}catch(e){return t}}(e,n)+(r?" "+r:"")})}ex.La="serverreachability",_(eR,$),ex.STAT_EVENT="statevent",_(eO,$),ex.Ma="timingevent",_(eP,$),eM.prototype.xa=function(){this.g=!1},eM.prototype.info=function(){};var eU={NO_ERROR:0,gb:1,tb:2,sb:3,nb:4,rb:5,ub:6,Ia:7,TIMEOUT:8,xb:9},eV={lb:"complete",Hb:"success",Ja:"error",Ia:"abort",zb:"ready",Ab:"readystatechange",TIMEOUT:"timeout",vb:"incrementaldata",yb:"progress",ob:"downloadprogress",Pb:"uploadprogress"};function ej(){}function eB(e,t,n,r){this.j=e,this.i=t,this.l=n,this.R=r||1,this.U=new em(this),this.I=45e3,this.H=null,this.o=!1,this.m=this.A=this.v=this.L=this.F=this.S=this.B=null,this.D=[],this.g=null,this.C=0,this.s=this.u=null,this.X=-1,this.J=!1,this.O=0,this.M=null,this.W=this.K=this.T=this.P=!1,this.h=new eq}function eq(){this.i=null,this.g="",this.h=!1}_(ej,e_),ej.prototype.g=function(){return new XMLHttpRequest},ej.prototype.i=function(){return{}},t=new ej;var ez={},e$={};
15function eK(e,t,n){e.L=1,e.v=to(tt(t)),e.m=n,e.P=!0,eG(e,null)}function eG(e,t){e.F=Date.now(),eW(e),e.A=tt(e.v);var n=e.A,r=e.R;Array.isArray(r)||(r=[String(r)]),tw(n.i,"t",r),e.C=0,n=e.j.J,e.h=new eq,e.g=t5(e.j,n?t:null,!e.m),0<e.O&&(e.M=new ep(w(e.Y,e,e.g),e.O)),t=e.U,n=e.g,r=e.ca;var i="readystatechange";Array.isArray(i)||(i&&(eg[0]=i.toString()),i=eg);for(var s=0;s<i.length;s++){var o=function e(t,n,r,i,s){if(i&&i.once)return function e(t,n,r,i,s){if(Array.isArray(n)){for(var o=0;o<n.length;o++)e(t,n[o],r,i,s);return null}return r=eu(r),t&&t[W]?t.L(n,r,g(i)?!!i.capture:!!i,s):er(t,n,r,!0,i,s)}(t,n,r,i,s);if(Array.isArray(n)){for(var o=0;o<n.length;o++)e(t,n[o],r,i,s);return null}return r=eu(r),t&&t[W]?t.K(n,r,g(i)?!!i.capture:!!i,s):er(t,n,r,!1,i,s)}(n,i[s],r||t.handleEvent,!1,t.h||t);if(!o)break;t.g[o.key]=o}t=e.H?O(e.H):{},e.m?(e.u||(e.u="POST"),t["Content-Type"]="application/x-www-form-urlencoded",e.g.ea(e.A,e.u,e.m,t)):(e.u="GET",e.g.ea(e.A,e.u,null,t)),eN(),function(e,t,n,r,i,s){e.info(function(){if(e.g){if(s)for(var o="",a=s.split("&"),l=0;l<a.length;l++){var u=a[l].split("=");if(1<u.length){var c=u[0];u=u[1];var h=c.split("_");o=2<=h.length&&"type"==h[1]?o+(c+"=")+u+"&":o+(c+"=redacted&")}}else o=null}else o=s;return"XMLHTTP REQ ("+r+") [attempt "+i+"]: "+t+"\n"+n+"\n"+o})}(e.i,e.u,e.A,e.l,e.R,e.m)}function eH(e){return!!e.g&&"GET"==e.u&&2!=e.L&&e.j.Ca}function eW(e){e.S=Date.now()+e.I,eQ(e,e.I)}function eQ(e,t){if(null!=e.B)throw Error("WatchDog timer not null");e.B=eL(w(e.ba,e),t)}function eX(e){e.B&&(p.clearTimeout(e.B),e.B=null)}function eY(e){0==e.j.G||e.J||t0(e.j,e)}function eJ(e){eX(e);var t=e.M;t&&"function"==typeof t.ma&&t.ma(),e.M=null,ey(e.U),e.g&&(t=e.g,e.g=null,t.abort(),t.ma())}function eZ(e,t){try{var n=e.j;if(0!=n.G&&(n.g==e||e6(n.h,e))){if(!e.K&&e6(n.h,e)&&3==n.G){try{var r=n.Da.g.parse(t)}catch(e){r=null}if(Array.isArray(r)&&3==r.length){var i=r;if(0==i[0]){e:if(!n.u){if(n.g){if(n.g.F+3e3<e.F)tZ(n),tz(n);else break e}tX(n),eD(18)}}else n.za=i[1],0<n.za-n.T&&37500>i[2]&&n.F&&0==n.v&&!n.C&&(n.C=eL(w(n.Za,n),6e3));if(1>=e4(n.h)&&n.ca){try{n.ca()}catch(e){}n.ca=void 0}}else t2(n,11)}else if((e.K||n.g==e)&&tZ(n),!x(t))for(i=n.Da.g.parse(t),t=0;t<i.length;t++){let a=i[t];if(n.T=a[0],a=a[1],2==n.G){if("c"==a[0]){n.K=a[1],n.ia=a[2];let t=a[3];null!=t&&(n.la=t,n.j.info("VER="+n.la));let i=a[4];null!=i&&(n.Aa=i,n.j.info("SVER="+n.Aa));let l=a[5];null!=l&&"number"==typeof l&&0<l&&(r=1.5*l,n.L=r,n.j.info("backChannelRequestTimeoutMs_="+r)),r=n;let u=e.g;if(u){let e=u.g?u.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(e){var s=r.h;s.g||-1==e.indexOf("spdy")&&-1==e.indexOf("quic")&&-1==e.indexOf("h2")||(s.j=s.l,s.g=new Set,s.h&&(e5(s,s.h),s.h=null))}if(r.D){let e=u.g?u.g.getResponseHeader("X-HTTP-Session-Id"):null;e&&(r.ya=e,ts(r.I,r.D,e))}}if(n.G=3,n.l&&n.l.ua(),n.ba&&(n.R=Date.now()-e.F,n.j.info("Handshake RTT: "+n.R+"ms")),(r=n).qa=t6(r,r.J?r.ia:null,r.W),e.K){e9(r.h,e);var o=r.L;o&&(e.I=o),e.B&&(eX(e),eW(e)),r.g=e}else tQ(r);0<n.i.length&&tK(n)}else"stop"!=a[0]&&"close"!=a[0]||t2(n,7)}else 3==n.G&&("stop"==a[0]||"close"==a[0]?"stop"==a[0]?t2(n,7):tq(n):"noop"!=a[0]&&n.l&&n.l.ta(a),n.v=0)}}eN(4)}catch(e){}}eB.prototype.ca=function(e){e=e.target;let t=this.M;t&&3==tU(e)?t.j():this.Y(e)},eB.prototype.Y=function(e){try{if(e==this.g)e:{let h=tU(this.g);var t=this.g.Ba();let d=this.g.Z();if(!(3>h)&&(3!=h||this.g&&(this.h.h||this.g.oa()||tV(this.g)))){this.J||4!=h||7==t||(8==t||0>=d?eN(3):eN(2)),eX(this);var n=this.g.Z();this.X=n;t:if(eH(this)){var r=tV(this.g);e="";var i=r.length,s=4==tU(this.g);if(!this.h.i){if("undefined"==typeof TextDecoder){eJ(this),eY(this);var o="";break t}this.h.i=new p.TextDecoder}for(t=0;t<i;t++)this.h.h=!0,e+=this.h.i.decode(r[t],{stream:!(s&&t==i-1)});r.length=0,this.h.g+=e,this.C=0,o=this.h.g}else o=this.g.oa();if(this.o=200==n,function(e,t,n,r,i,s,o){e.info(function(){return"XMLHTTP RESP ("+r+") [ attempt "+i+"]: "+t+"\n"+n+"\n"+s+" "+o})}(this.i,this.u,this.A,this.l,this.R,h,n),this.o){if(this.T&&!this.K){t:{if(this.g){var a,l=this.g;if((a=l.g?l.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!x(a)){var u=a;break t}}u=null}if(n=u)eF(this.i,this.l,n,"Initial handshake response via X-HTTP-Initial-Response"),this.K=!0,eZ(this,n);else{this.o=!1,this.s=3,eD(12),eJ(this),eY(this);break e}}if(this.P){let e;for(n=!0;!this.J&&this.C<o.length;)if((e=function(e,t){var n=e.C,r=t.indexOf("\n",n);return -1==r?e$:isNaN(n=Number(t.substring(n,r)))?ez:(r+=1)+n>t.length?e$:(t=t.slice(r,r+n),e.C=r+n,t)}(this,o))==e$){4==h&&(this.s=4,eD(14),n=!1),eF(this.i,this.l,null,"[Incomplete Response]");break}else if(e==ez){this.s=4,eD(15),eF(this.i,this.l,o,"[Invalid Chunk]"),n=!1;break}else eF(this.i,this.l,e,null),eZ(this,e);if(eH(this)&&0!=this.C&&(this.h.g=this.h.g.slice(this.C),this.C=0),4!=h||0!=o.length||this.h.h||(this.s=1,eD(16),n=!1),this.o=this.o&&n,n){if(0<o.length&&!this.W){this.W=!0;var c=this.j;c.g==this&&c.ba&&!c.M&&(c.j.info("Great, no buffering proxy detected. Bytes received: "+o.length),tY(c),c.M=!0,eD(11))}}else eF(this.i,this.l,o,"[Invalid Chunked Response]"),eJ(this),eY(this)}else eF(this.i,this.l,o,null),eZ(this,o);4==h&&eJ(this),this.o&&!this.J&&(4==h?t0(this.j,this):(this.o=!1,eW(this)))}else(function(e){let t={};e=(e.g&&2<=tU(e)&&e.g.getAllResponseHeaders()||"").split("\r\n");for(let r=0;r<e.length;r++){if(x(e[r]))continue;var n=function(e){var t=1;e=e.split(":");let n=[];for(;0<t&&e.length;)n.push(e.shift()),t--;return e.length&&n.push(e.join(":")),n}(e[r]);let i=n[0];if("string"!=typeof(n=n[1]))continue;n=n.trim();let s=t[i]||[];t[i]=s,s.push(n)}!function(e,t){for(let n in e)t.call(void 0,e[n],n,e)}(t,function(e){return e.join(", ")})})(this.g),400==n&&0<o.indexOf("Unknown SID")?(this.s=3,eD(12)):(this.s=0,eD(13)),eJ(this),eY(this)}}}catch(e){}finally{}},eB.prototype.cancel=function(){this.J=!0,eJ(this)},eB.prototype.ba=function(){this.B=null;let e=Date.now();0<=e-this.S?(function(e,t){e.info(function(){return"TIMEOUT: "+t})}(this.i,this.A),2!=this.L&&(eN(),eD(17)),eJ(this),this.s=2,eY(this)):eQ(this,this.S-e)};var e0=class{constructor(e,t){this.g=e,this.map=t}};function e1(e){this.l=e||10,e=p.PerformanceNavigationTiming?0<(e=p.performance.getEntriesByType("navigation")).length&&("hq"==e[0].nextHopProtocol||"h2"==e[0].nextHopProtocol):!!(p.chrome&&p.chrome.loadTimes&&p.chrome.loadTimes()&&p.chrome.loadTimes().wasFetchedViaSpdy),this.j=e?this.l:1,this.g=null,1<this.j&&(this.g=new Set),this.h=null,this.i=[]}function e2(e){return!!e.h||!!e.g&&e.g.size>=e.j}function e4(e){return e.h?1:e.g?e.g.size:0}function e6(e,t){return e.h?e.h==t:!!e.g&&e.g.has(t)}function e5(e,t){e.g?e.g.add(t):e.h=t}function e9(e,t){e.h&&e.h==t?e.h=null:e.g&&e.g.has(t)&&e.g.delete(t)}function e3(e){if(null!=e.h)return e.i.concat(e.h.D);if(null!=e.g&&0!==e.g.size){let t=e.i;for(let n of e.g.values())t=t.concat(n.D);return t}return I(e.i)}function e8(e,t){if(e.forEach&&"function"==typeof e.forEach)e.forEach(t,void 0);else if(m(e)||"string"==typeof e)Array.prototype.forEach.call(e,t,void 0);else for(var n=function(e){if(e.na&&"function"==typeof e.na)return e.na();if(!e.V||"function"!=typeof e.V){if("undefined"!=typeof Map&&e instanceof Map)return Array.from(e.keys());if(!("undefined"!=typeof Set&&e instanceof Set)){if(m(e)||"string"==typeof e){var t=[];e=e.length;for(var n=0;n<e;n++)t.push(n);return t}for(let r in t=[],n=0,e)t[n++]=r;return t}}}(e),r=function(e){if(e.V&&"function"==typeof e.V)return e.V();if("undefined"!=typeof Map&&e instanceof Map||"undefined"!=typeof Set&&e instanceof Set)return Array.from(e.values());if("string"==typeof e)return e.split("");
15if(m(e)){for(var t=[],n=e.length,r=0;r<n;r++)t.push(e[r]);return t}for(r in t=[],n=0,e)t[n++]=e[r];return t}(e),i=r.length,s=0;s<i;s++)t.call(void 0,r[s],n&&n[s],e)}e1.prototype.cancel=function(){if(this.i=e3(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&0!==this.g.size){for(let e of this.g.values())e.cancel();this.g.clear()}};var e7=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function te(e){if(this.g=this.o=this.j="",this.s=null,this.m=this.l="",this.h=!1,e instanceof te){this.h=e.h,tn(this,e.j),this.o=e.o,this.g=e.g,tr(this,e.s),this.l=e.l;var t=e.i,n=new tm;n.i=t.i,t.g&&(n.g=new Map(t.g),n.h=t.h),ti(this,n),this.m=e.m}else e&&(t=String(e).match(e7))?(this.h=!1,tn(this,t[1]||"",!0),this.o=ta(t[2]||""),this.g=ta(t[3]||"",!0),tr(this,t[4]),this.l=ta(t[5]||"",!0),ti(this,t[6]||"",!0),this.m=ta(t[7]||"")):(this.h=!1,this.i=new tm(null,this.h))}function tt(e){return new te(e)}function tn(e,t,n){e.j=n?ta(t,!0):t,e.j&&(e.j=e.j.replace(/:$/,""))}function tr(e,t){if(t){if(isNaN(t=Number(t))||0>t)throw Error("Bad port number "+t);e.s=t}else e.s=null}function ti(e,t,n){var r,i;t instanceof tm?(e.i=t,r=e.i,(i=e.h)&&!r.j&&(tg(r),r.i=null,r.g.forEach(function(e,t){var n=t.toLowerCase();t!=n&&(ty(this,t),tw(this,n,e))},r)),r.j=i):(n||(t=tl(t,tf)),e.i=new tm(t,e.h))}function ts(e,t,n){e.i.set(t,n)}function to(e){return ts(e,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)),e}function ta(e,t){return e?t?decodeURI(e.replace(/%25/g,"%2525")):decodeURIComponent(e):""}function tl(e,t,n){return"string"==typeof e?(e=encodeURI(e).replace(t,tu),n&&(e=e.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),e):null}function tu(e){return"%"+((e=e.charCodeAt(0))>>4&15).toString(16)+(15&e).toString(16)}te.prototype.toString=function(){var e=[],t=this.j;t&&e.push(tl(t,tc,!0),":");var n=this.g;return(n||"file"==t)&&(e.push("//"),(t=this.o)&&e.push(tl(t,tc,!0),"@"),e.push(encodeURIComponent(String(n)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),null!=(n=this.s)&&e.push(":",String(n))),(n=this.l)&&(this.g&&"/"!=n.charAt(0)&&e.push("/"),e.push(tl(n,"/"==n.charAt(0)?td:th,!0))),(n=this.i.toString())&&e.push("?",n),(n=this.m)&&e.push("#",tl(n,tp)),e.join("")};var tc=/[#\/\?@]/g,th=/[#\?:]/g,td=/[#\?]/g,tf=/[#\?@]/g,tp=/#/g;function tm(e,t){this.h=this.g=null,this.i=e||null,this.j=!!t}function tg(e){e.g||(e.g=new Map,e.h=0,e.i&&function(e,t){if(e){e=e.split("&");for(var n=0;n<e.length;n++){var r=e[n].indexOf("="),i=null;if(0<=r){var s=e[n].substring(0,r);i=e[n].substring(r+1)}else s=e[n];t(s,i?decodeURIComponent(i.replace(/\+/g," ")):"")}}}(e.i,function(t,n){e.add(decodeURIComponent(t.replace(/\+/g," ")),n)}))}function ty(e,t){tg(e),t=tb(e,t),e.g.has(t)&&(e.i=null,e.h-=e.g.get(t).length,e.g.delete(t))}function tv(e,t){return tg(e),t=tb(e,t),e.g.has(t)}function tw(e,t,n){ty(e,t),0<n.length&&(e.i=null,e.g.set(tb(e,t),I(n)),e.h+=n.length)}function tb(e,t){return t=String(t),e.j&&(t=t.toLowerCase()),t}function t_(e,t,n,r,i){try{i&&(i.onload=null,i.onerror=null,i.onabort=null,i.ontimeout=null),r(n)}catch(e){}}function tI(){this.g=new eb}function tE(e){this.l=e.Ub||null,this.j=e.eb||!1}function tT(e,t){ec.call(this),this.D=e,this.o=t,this.m=void 0,this.status=this.readyState=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.u=new Headers,this.h=null,this.B="GET",this.A="",this.g=!1,this.v=this.j=this.l=null}function tS(e){e.j.read().then(e.Pa.bind(e)).catch(e.ga.bind(e))}function tC(e){e.readyState=4,e.l=null,e.j=null,e.v=null,tx(e)}function tx(e){e.onreadystatechange&&e.onreadystatechange.call(e)}function tk(e){let t="";return N(e,function(e,n){t+=n+":"+e+"\r\n"}),t}function tA(e,t,n){e:{for(r in n){var r=!1;break e}r=!0}r||(n=tk(n),"string"==typeof e?null!=n&&encodeURIComponent(String(n)):ts(e,t,n))}function tR(e){ec.call(this),this.headers=new Map,this.o=e||null,this.h=!1,this.v=this.g=null,this.D="",this.m=0,this.l="",this.j=this.B=this.u=this.A=!1,this.I=null,this.H="",this.J=!1}(n=tm.prototype).add=function(e,t){tg(this),this.i=null,e=tb(this,e);var n=this.g.get(e);return n||this.g.set(e,n=[]),n.push(t),this.h+=1,this}
15,n.forEach=function(e,t){tg(this),this.g.forEach(function(n,r){n.forEach(function(n){e.call(t,n,r,this)},this)},this)},n.na=function(){tg(this);let e=Array.from(this.g.values()),t=Array.from(this.g.keys()),n=[];for(let r=0;r<t.length;r++){let i=e[r];for(let e=0;e<i.length;e++)n.push(t[r])}return n},n.V=function(e){tg(this);let t=[];if("string"==typeof e)tv(this,e)&&(t=t.concat(this.g.get(tb(this,e))));else{e=Array.from(this.g.values());for(let n=0;n<e.length;n++)t=t.concat(e[n])}return t},n.set=function(e,t){return tg(this),this.i=null,tv(this,e=tb(this,e))&&(this.h-=this.g.get(e).length),this.g.set(e,[t]),this.h+=1,this},n.get=function(e,t){return e&&0<(e=this.V(e)).length?String(e[0]):t},n.toString=function(){if(this.i)return this.i;if(!this.g)return"";let e=[],t=Array.from(this.g.keys());for(var n=0;n<t.length;n++){var r=t[n];let s=encodeURIComponent(String(r)),o=this.V(r);for(r=0;r<o.length;r++){var i=s;""!==o[r]&&(i+="="+encodeURIComponent(String(o[r]))),e.push(i)}}return this.i=e.join("&")},_(tE,e_),tE.prototype.g=function(){return new tT(this.l,this.j)},tE.prototype.i=(e={},function(){return e}),_(tT,ec),(n=tT.prototype).open=function(e,t){if(0!=this.readyState)throw this.abort(),Error("Error reopening a connection");this.B=e,this.A=t,this.readyState=1,tx(this)},n.send=function(e){if(1!=this.readyState)throw this.abort(),Error("need to call open() first. ");this.g=!0;let t={headers:this.u,method:this.B,credentials:this.m,cache:void 0};e&&(t.body=e),(this.D||p).fetch(new Request(this.A,t)).then(this.Sa.bind(this),this.ga.bind(this))},n.abort=function(){this.response=this.responseText="",this.u=new Headers,this.status=0,this.j&&this.j.cancel("Request was aborted.").catch(()=>{}),1<=this.readyState&&this.g&&4!=this.readyState&&(this.g=!1,tC(this)),this.readyState=0},n.Sa=function(e){if(this.g&&(this.l=e,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=e.headers,this.readyState=2,tx(this)),this.g&&(this.readyState=3,tx(this),this.g))){if("arraybuffer"===this.responseType)e.arrayBuffer().then(this.Qa.bind(this),this.ga.bind(this));else if(void 0!==p.ReadableStream&&"body"in e){if(this.j=e.body.getReader(),this.o){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.v=new TextDecoder;tS(this)}else e.text().then(this.Ra.bind(this),this.ga.bind(this))}},n.Pa=function(e){if(this.g){if(this.o&&e.value)this.response.push(e.value);else if(!this.o){var t=e.value?e.value:new Uint8Array(0);(t=this.v.decode(t,{stream:!e.done}))&&(this.response=this.responseText+=t)}e.done?tC(this):tx(this),3==this.readyState&&tS(this)}},n.Ra=function(e){this.g&&(this.response=this.responseText=e,tC(this))},n.Qa=function(e){this.g&&(this.response=e,tC(this))},n.ga=function(){this.g&&tC(this)},n.setRequestHeader=function(e,t){this.u.append(e,t)},n.getResponseHeader=function(e){return this.h&&this.h.get(e.toLowerCase())||""},n.getAllResponseHeaders=function(){if(!this.h)return"";let e=[],t=this.h.entries();for(var n=t.next();!n.done;)e.push((n=n.value)[0]+": "+n[1]),n=t.next();return e.join("\r\n")},Object.defineProperty(tT.prototype,"withCredentials",{get:function(){return"include"===this.m},set:function(e){this.m=e?"include":"same-origin"}}),_(tR,ec);var tN=/^https?$/i,tO=["POST","PUT"];function tD(e,t){e.h=!1,e.g&&(e.j=!0,e.g.abort(),e.j=!1),e.l=t,e.m=5,tP(e),tM(e)}function tP(e){e.A||(e.A=!0,eh(e,"complete"),eh(e,"error"))}function tL(e){if(e.h&&void 0!==f&&(!e.v[1]||4!=tU(e)||2!=e.Z())){if(e.u&&4==tU(e))ef(e.Ea,0,e);else if(eh(e,"readystatechange"),4==tU(e)){e.h=!1;try{let o=e.Z();switch(o){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var t,n,r=!0;break;default:r=!1}if(!(t=r)){if(n=0===o){var i=String(e.D).match(e7)[1]||null;!i&&p.self&&p.self.location&&(i=p.self.location.protocol.slice(0,-1)),n=!tN.test(i?i.toLowerCase():"")}t=n}if(t)eh(e,"complete"),eh(e,"success");else{e.m=6;try{var s=2<tU(e)?e.g.statusText:""}catch(e){s=""}e.l=s+" ["+e.Z()+"]",tP(e)}}finally{tM(e)}}}}function tM(e,t){if(e.g){tF(e);let n=e.g,r=e.v[0]?()=>{}:null;e.g=null,e.v=null,t||eh(e,"ready");try{n.onreadystatechange=r}catch(e){}}}function tF(e){e.I&&(p.clearTimeout(e.I),e.I=null)}function tU(e){return e.g?e.g.readyState:0}function tV(e){try{if(!e.g)return null;if("response"in e.g)return e.g.response;switch(e.H){case"":case"text":return e.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in e.g)return e.g.mozResponseArrayBuffer}return null}catch(e){return null}}
15function tj(e,t,n){return n&&n.internalChannelParams&&n.internalChannelParams[e]||t}function tB(e){this.Aa=0,this.i=[],this.j=new eM,this.ia=this.qa=this.I=this.W=this.g=this.ya=this.D=this.H=this.m=this.S=this.o=null,this.Ya=this.U=0,this.Va=tj("failFast",!1,e),this.F=this.C=this.u=this.s=this.l=null,this.X=!0,this.za=this.T=-1,this.Y=this.v=this.B=0,this.Ta=tj("baseRetryDelayMs",5e3,e),this.cb=tj("retryDelaySeedMs",1e4,e),this.Wa=tj("forwardChannelMaxRetries",2,e),this.wa=tj("forwardChannelRequestTimeoutMs",2e4,e),this.pa=e&&e.xmlHttpFactory||void 0,this.Xa=e&&e.Tb||void 0,this.Ca=e&&e.useFetchStreams||!1,this.L=void 0,this.J=e&&e.supportsCrossDomainXhr||!1,this.K="",this.h=new e1(e&&e.concurrentRequestLimit),this.Da=new tI,this.P=e&&e.fastHandshake||!1,this.O=e&&e.encodeInitMessageHeaders||!1,this.P&&this.O&&(this.O=!1),this.Ua=e&&e.Rb||!1,e&&e.xa&&this.j.xa(),e&&e.forceLongPolling&&(this.X=!1),this.ba=!this.P&&this.X&&e&&e.detectBufferingProxy||!1,this.ja=void 0,e&&e.longPollingTimeout&&0<e.longPollingTimeout&&(this.ja=e.longPollingTimeout),this.ca=void 0,this.R=0,this.M=!1,this.ka=this.A=null}function tq(e){if(t$(e),3==e.G){var t=e.U++,n=tt(e.I);if(ts(n,"SID",e.K),ts(n,"RID",t),ts(n,"TYPE","terminate"),tH(e,n),(t=new eB(e,e.j,t)).L=2,t.v=to(tt(n)),n=!1,p.navigator&&p.navigator.sendBeacon)try{n=p.navigator.sendBeacon(t.v.toString(),"")}catch(e){}!n&&p.Image&&((new Image).src=t.v,n=!0),n||(t.g=t5(t.j,null),t.g.ea(t.v)),t.F=Date.now(),eW(t)}t4(e)}function tz(e){e.g&&(tY(e),e.g.cancel(),e.g=null)}function t$(e){tz(e),e.u&&(p.clearTimeout(e.u),e.u=null),tZ(e),e.h.cancel(),e.s&&("number"==typeof e.s&&p.clearTimeout(e.s),e.s=null)}function tK(e){if(!e2(e.h)&&!e.s){e.s=!0;var t=e.Ga;U||B(),V||(U(),V=!0),j.add(t,e),e.B=0}}function tG(e,t){var n;n=t?t.l:e.U++;let r=tt(e.I);ts(r,"SID",e.K),ts(r,"RID",n),ts(r,"AID",e.T),tH(e,r),e.m&&e.o&&tA(r,e.m,e.o),n=new eB(e,e.j,n,e.B+1),null===e.m&&(n.H=e.o),t&&(e.i=t.D.concat(e.i)),t=tW(e,n,1e3),n.I=Math.round(.5*e.wa)+Math.round(.5*e.wa*Math.random()),e5(e.h,n),eK(n,r,t)}function tH(e,t){e.H&&N(e.H,function(e,n){ts(t,n,e)}),e.l&&e8({},function(e,n){ts(t,n,e)})}function tW(e,t,n){n=Math.min(e.i.length,n);var r=e.l?w(e.l.Na,e.l,e):null;e:{var i=e.i;let t=-1;for(;;){let e=["count="+n];-1==t?0<n?(t=i[0].g,e.push("ofs="+t)):t=0:e.push("ofs="+t);let s=!0;for(let o=0;o<n;o++){let n=i[o].g,a=i[o].map;if(0>(n-=t))t=Math.max(0,i[o].g-100),s=!1;else try{!function(e,t,n){let r=n||"";try{e8(e,function(e,n){let i=e;g(e)&&(i=ev(e)),t.push(r+n+"="+encodeURIComponent(i))})}catch(e){throw t.push(r+"type="+encodeURIComponent("_badmap")),e}}(a,e,"req"+n+"_")}catch(e){r&&r(a)}}if(s){r=e.join("&");break e}}}return e=e.i.splice(0,n),t.D=e,r}function tQ(e){if(!e.g&&!e.u){e.Y=1;var t=e.Fa;U||B(),V||(U(),V=!0),j.add(t,e),e.v=0}}function tX(e){return!e.g&&!e.u&&!(3<=e.v)&&(e.Y++,e.u=eL(w(e.Fa,e),t1(e,e.v)),e.v++,!0)}function tY(e){null!=e.A&&(p.clearTimeout(e.A),e.A=null)}function tJ(e){e.g=new eB(e,e.j,"rpc",e.Y),null===e.m&&(e.g.H=e.o),e.g.O=0;var t=tt(e.qa);ts(t,"RID","rpc"),ts(t,"SID",e.K),ts(t,"AID",e.T),ts(t,"CI",e.F?"0":"1"),!e.F&&e.ja&&ts(t,"TO",e.ja),ts(t,"TYPE","xmlhttp"),tH(e,t),e.m&&e.o&&tA(t,e.m,e.o),e.L&&(e.g.I=e.L);var n=e.g;e=e.ia,n.L=1,n.v=to(tt(t)),n.m=null,n.P=!0,eG(n,e)}function tZ(e){null!=e.C&&(p.clearTimeout(e.C),e.C=null)}function t0(e,t){var n=null;if(e.g==t){tZ(e),tY(e),e.g=null;var r=2}else{if(!e6(e.h,t))return;n=t.D,e9(e.h,t),r=1}if(0!=e.G){if(t.o){if(1==r){n=t.m?t.m.length:0,t=Date.now()-t.F;var i,s=e.B;eh(r=eA(),new eP(r,n)),tK(e)}else tQ(e)}else if(3==(s=t.s)||0==s&&0<t.X||!(1==r&&(i=t,!(e4(e.h)>=e.h.j-(e.s?1:0))&&(e.s?(e.i=i.D.concat(e.i),!0):1!=e.G&&2!=e.G&&!(e.B>=(e.Va?0:e.Wa))&&(e.s=eL(w(e.Ga,e,i),t1(e,e.B)),e.B++,!0)))||2==r&&tX(e)))switch(n&&0<n.length&&((t=e.h).i=t.i.concat(n)),s){case 1:t2(e,5);break;case 4:t2(e,10);break;case 3:t2(e,6);break;default:t2(e,2)}}}function t1(e,t){let n=e.Ta+Math.floor(Math.random()*e.cb);return e.isActive()||(n*=2),n*t}function t2(e,t){if(e.j.info("Error code "+t),2==t){var n=w(e.fb,e),r=e.Xa;let t=!r;r=new te(r||"//www.google.com/images/cleardot.gif"),p.location&&"http"==p.location.protocol||tn(r,"https"),to(r),t?function(e,t){let n=new eM;if(p.Image){let r=new Image;r.onload=b(t_,n,"TestLoadImage: loaded",!0,t,r),r.onerror=b(t_,n,"TestLoadImage: error",!1,t,r),r.onabort=b(t_,n,"TestLoadImage: abort",!1,t,r),r.ontimeout=b(t_,n,"TestLoadImage: timeout",!1,t,r),p.setTimeout(function(){r.ontimeout&&r.ontimeout()},1e4),r.src=e}else t(!1)}(r.toString(),n):function(e,t){let n=new eM,r=new AbortController,i=setTimeout(()=>{r.abort(),t_(n,"TestPingServer: timeout",!1,t)},1e4);fetch(e,{signal:r.signal}).then(e=>{clearTimeout(i),e.ok?t_(n,"TestPingServer: ok",!0,t):t_(n,"TestPingServer: server error",!1,t)}).catch(()=>{clearTimeout(i),t_(n,"TestPingServer: error",!1,t)})}(r.toString(),n)}else eD(2);e.G=0,e.l&&e.l.sa(t),t4(e),t$(e)}function t4(e){if(e.G=0,e.ka=[],e.l){let t=e3(e.h);
15(0!=t.length||0!=e.i.length)&&(S(e.ka,t),S(e.ka,e.i),e.h.i.length=0,I(e.i),e.i.length=0),e.l.ra()}}function t6(e,t,n){var r=n instanceof te?tt(n):new te(n);if(""!=r.g)t&&(r.g=t+"."+r.g),tr(r,r.s);else{var i=p.location;r=i.protocol,t=t?t+"."+i.hostname:i.hostname,i=+i.port;var s=new te(null);r&&tn(s,r),t&&(s.g=t),i&&tr(s,i),n&&(s.l=n),r=s}return n=e.D,t=e.ya,n&&t&&ts(r,n,t),ts(r,"VER",e.la),tH(e,r),r}function t5(e,t,n){if(t&&!e.J)throw Error("Can't create secondary domain capable XhrIo object.");return(t=new tR(e.Ca&&!e.pa?new tE({eb:n}):e.pa)).Ha(e.J),t}function t9(){}function t3(){}function t8(e,t){ec.call(this),this.g=new tB(t),this.l=e,this.h=t&&t.messageUrlParams||null,e=t&&t.messageHeaders||null,t&&t.clientProtocolHeaderRequired&&(e?e["X-Client-Protocol"]="webchannel":e={"X-Client-Protocol":"webchannel"}),this.g.o=e,e=t&&t.initMessageHeaders||null,t&&t.messageContentType&&(e?e["X-WebChannel-Content-Type"]=t.messageContentType:e={"X-WebChannel-Content-Type":t.messageContentType}),t&&t.va&&(e?e["X-WebChannel-Client-Profile"]=t.va:e={"X-WebChannel-Client-Profile":t.va}),this.g.S=e,(e=t&&t.Sb)&&!x(e)&&(this.g.m=e),this.v=t&&t.supportsCrossDomainXhr||!1,this.u=t&&t.sendRawJson||!1,(t=t&&t.httpSessionIdParam)&&!x(t)&&(this.g.D=t,null!==(e=this.h)&&t in e&&t in(e=this.h)&&delete e[t]),this.j=new nt(this)}function t7(e){eS.call(this),e.__headers__&&(this.headers=e.__headers__,this.statusCode=e.__status__,delete e.__headers__,delete e.__status__);var t=e.__sm__;if(t){e:{for(let n in t){e=n;break e}e=void 0}(this.i=e)&&(e=this.i,t=null!==t&&e in t?t[e]:void 0),this.data=t}else this.data=e}function ne(){eC.call(this),this.status=1}function nt(e){this.g=e}(n=tR.prototype).Ha=function(e){this.J=e},n.ea=function(e,n,r,i){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.D+"; newUri="+e);n=n?n.toUpperCase():"GET",this.D=e,this.l="",this.m=0,this.A=!1,this.h=!0,this.g=this.o?this.o.g():t.g(),this.v=this.o?eI(this.o):eI(t),this.g.onreadystatechange=w(this.Ea,this);try{this.B=!0,this.g.open(n,String(e),!0),this.B=!1}catch(e){tD(this,e);return}if(e=r||"",r=new Map(this.headers),i){if(Object.getPrototypeOf(i)===Object.prototype)for(var s in i)r.set(s,i[s]);else if("function"==typeof i.keys&&"function"==typeof i.get)for(let e of i.keys())r.set(e,i.get(e));else throw Error("Unknown input type for opt_headers: "+String(i))}for(let[t,o]of(i=Array.from(r.keys()).find(e=>"content-type"==e.toLowerCase()),s=p.FormData&&e instanceof p.FormData,!(0<=Array.prototype.indexOf.call(tO,n,void 0))||i||s||r.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8"),r))this.g.setRequestHeader(t,o);this.H&&(this.g.responseType=this.H),"withCredentials"in this.g&&this.g.withCredentials!==this.J&&(this.g.withCredentials=this.J);try{tF(this),this.u=!0,this.g.send(e),this.u=!1}catch(e){tD(this,e)}},n.abort=function(e){this.g&&this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1,this.m=e||7,eh(this,"complete"),eh(this,"abort"),tM(this))},n.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),tM(this,!0)),tR.aa.N.call(this)},n.Ea=function(){this.s||(this.B||this.u||this.j?tL(this):this.bb())},n.bb=function(){tL(this)},n.isActive=function(){return!!this.g},n.Z=function(){try{return 2<tU(this)?this.g.status:-1}catch(e){return -1}},n.oa=function(){try{return this.g?this.g.responseText:""}catch(e){return""}},n.Oa=function(e){if(this.g){var t=this.g.responseText;return e&&0==t.indexOf(e)&&(t=t.substring(e.length)),ew(t)}},n.Ba=function(){return this.m},n.Ka=function(){return"string"==typeof this.l?this.l:String(this.l)},(n=tB.prototype).la=8,n.G=1,n.connect=function(e,t,n,r){eD(0),this.W=e,this.H=t||{},n&&void 0!==r&&(this.H.OSID=n,this.H.OAID=r),this.F=this.X,this.I=t6(this,null,this.W),tK(this)},n.Ga=function(e){if(this.s){if(this.s=null,1==this.G){if(!e){this.U=Math.floor(1e5*Math.random()),e=this.U++;let i=new eB(this,this.j,e),s=this.o;if(this.S&&(s?P(s=O(s),this.S):s=this.S),null!==this.m||this.O||(i.H=s,s=null),this.P)e:{for(var t=0,n=0;n<this.i.length;n++){t:{var r=this.i[n];if("__data__"in r.map&&"string"==typeof(r=r.map.__data__)){r=r.length;break t}r=void 0}if(void 0===r)break;
15if(4096<(t+=r)){t=n;break e}if(4096===t||n===this.i.length-1){t=n+1;break e}}t=1e3}else t=1e3;t=tW(this,i,t),ts(n=tt(this.I),"RID",e),ts(n,"CVER",22),this.D&&ts(n,"X-HTTP-Session-Id",this.D),tH(this,n),s&&(this.O?t="headers="+encodeURIComponent(String(tk(s)))+"&"+t:this.m&&tA(n,this.m,s)),e5(this.h,i),this.Ua&&ts(n,"TYPE","init"),this.P?(ts(n,"$req",t),ts(n,"SID","null"),i.T=!0,eK(i,n,null)):eK(i,n,t),this.G=2}}else 3==this.G&&(e?tG(this,e):0==this.i.length||e2(this.h)||tG(this))}},n.Fa=function(){if(this.u=null,tJ(this),this.ba&&!(this.M||null==this.g||0>=this.R)){var e=2*this.R;this.j.info("BP detection timer enabled: "+e),this.A=eL(w(this.ab,this),e)}},n.ab=function(){this.A&&(this.A=null,this.j.info("BP detection timeout reached."),this.j.info("Buffering proxy detected and switch to long-polling!"),this.F=!1,this.M=!0,eD(10),tz(this),tJ(this))},n.Za=function(){null!=this.C&&(this.C=null,tz(this),tX(this),eD(19))},n.fb=function(e){e?(this.j.info("Successfully pinged google.com"),eD(2)):(this.j.info("Failed to ping google.com"),eD(1))},n.isActive=function(){return!!this.l&&this.l.isActive(this)},(n=t9.prototype).ua=function(){},n.ta=function(){},n.sa=function(){},n.ra=function(){},n.isActive=function(){return!0},n.Na=function(){},t3.prototype.g=function(e,t){return new t8(e,t)},_(t8,ec),t8.prototype.m=function(){this.g.l=this.j,this.v&&(this.g.J=!0),this.g.connect(this.l,this.h||void 0)},t8.prototype.close=function(){tq(this.g)},t8.prototype.o=function(e){var t=this.g;if("string"==typeof e){var n={};n.__data__=e,e=n}else this.u&&((n={}).__data__=ev(e),e=n);t.i.push(new e0(t.Ya++,e)),3==t.G&&tK(t)},t8.prototype.N=function(){this.g.l=null,delete this.j,tq(this.g),delete this.g,t8.aa.N.call(this)},_(t7,eS),_(ne,eC),_(nt,t9),nt.prototype.ua=function(){eh(this.g,"a")},nt.prototype.ta=function(e){eh(this.g,new t7(e))},nt.prototype.sa=function(e){eh(this.g,new ne)},nt.prototype.ra=function(){eh(this.g,"b")},t3.prototype.createWebChannel=t3.prototype.g,t8.prototype.send=t8.prototype.o,t8.prototype.open=t8.prototype.m,t8.prototype.close=t8.prototype.close,d=T.createWebChannelTransport=function(){return new t3},h=T.getStatEventTarget=function(){return eA()},c=T.Event=ex,u=T.Stat={mb:0,pb:1,qb:2,Jb:3,Ob:4,Lb:5,Mb:6,Kb:7,Ib:8,Nb:9,PROXY:10,NOPROXY:11,Gb:12,Cb:13,Db:14,Bb:15,Eb:16,Fb:17,ib:18,hb:19,jb:20},eU.NO_ERROR=0,eU.TIMEOUT=8,eU.HTTP_ERROR=6,l=T.ErrorCode=eU,eV.COMPLETE="complete",a=T.EventType=eV,eE.EventType=eT,eT.OPEN="a",eT.CLOSE="b",eT.ERROR="c",eT.MESSAGE="d",ec.prototype.listen=ec.prototype.K,o=T.WebChannel=eE,T.FetchXmlHttpFactory=tE,tR.prototype.listenOnce=tR.prototype.L,tR.prototype.getLastError=tR.prototype.Ka,tR.prototype.getLastErrorCode=tR.prototype.Ba,tR.prototype.getStatus=tR.prototype.Z,tR.prototype.getResponseJson=tR.prototype.Oa,tR.prototype.getResponseText=tR.prototype.oa,tR.prototype.send=tR.prototype.ea,tR.prototype.setWithCredentials=tR.prototype.Ha,s=T.XhrIo=tR}).apply(void 0!==E?E:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{});var S=n(3454),C=n(1876).Buffer;let x="@firebase/firestore",k="4.7.17";class A{constructor(e){this.uid=e}isAuthenticated(){return null!=this.uid}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(e){return e.uid===this.uid}}A.UNAUTHENTICATED=new A(null),A.GOOGLE_CREDENTIALS=new A("google-credentials-uid"),A.FIRST_PARTY=new A("first-party-uid"),A.MOCK_USER=new A("mock-user");let R="11.9.0",N=new w.Yd("@firebase/firestore");function O(){return N.logLevel}function D(e){N.setLogLevel(e)}function P(e,...t){if(N.logLevel<=w.in.DEBUG){let n=t.map(F);N.debug(`Firestore (${R}): ${e}`,...n)}}function L(e,...t){if(N.logLevel<=w.in.ERROR){let n=t.map(F);N.error(`Firestore (${R}): ${e}`,...n)}}function M(e,...t){if(N.logLevel<=w.in.WARN){let n=t.map(F);N.warn(`Firestore (${R}): ${e}`,...n)}}function F(e){if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(t){return e}}function U(e,t,n){let r="Unexpected state";"string"==typeof t?r=t:n=t,V(e,r,n)}function V(e,t,n){let r=`FIRESTORE (${R}) INTERNAL ASSERTION FAILED: ${t} (ID: ${e.toString(16)})`;if(void 0!==n)try{r+=" CONTEXT: "+JSON.stringify(n)}catch(e){r+=" CONTEXT: "+n}throw L(r),Error(r)}function j(e,t,n,r){let i="Unexpected state";"string"==typeof n?i=n:r=n,e||V(t,i,r)}function B(e,t){e||U(57014,t)}let q={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENT
15ED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class z extends b.ZR{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}class ${constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}class K{constructor(e,t){this.user=t,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class G{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable(()=>t(A.UNAUTHENTICATED))}shutdown(){}}class H{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 W{constructor(e){this.t=e,this.currentUser=A.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,t){j(void 0===this.o,42304);let n=this.i,r=e=>this.i!==n?(n=this.i,t(e)):Promise.resolve(),i=new $;this.o=()=>{this.i++,this.currentUser=this.u(),i.resolve(),i=new $,e.enqueueRetryable(()=>r(this.currentUser))};let s=()=>{let t=i;e.enqueueRetryable(async()=>{await t.promise,await r(this.currentUser)})},o=e=>{P("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=e,this.o&&(this.auth.addAuthTokenListener(this.o),s())};this.t.onInit(e=>o(e)),setTimeout(()=>{if(!this.auth){let e=this.t.getImmediate({optional:!0});e?o(e):(P("FirebaseAuthCredentialsProvider","Auth not yet detected"),i.resolve(),i=new $)}},0),s()}getToken(){let e=this.i,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then(t=>this.i!==e?(P("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):t?(j("string"==typeof t.accessToken,31837,{l:t}),new K(t.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(){let e=this.auth&&this.auth.getUid();return j(null===e||"string"==typeof e,2055,{h:e}),new A(e)}}class Q{constructor(e,t,n){this.P=e,this.T=t,this.I=n,this.type="FirstParty",this.user=A.FIRST_PARTY,this.A=new Map}R(){return this.I?this.I():null}get headers(){this.A.set("X-Goog-AuthUser",this.P);let e=this.R();return e&&this.A.set("Authorization",e),this.T&&this.A.set("X-Goog-Iam-Authorization-Token",this.T),this.A}}class X{constructor(e,t,n){this.P=e,this.T=t,this.I=n}getToken(){return Promise.resolve(new Q(this.P,this.T,this.I))}start(e,t){e.enqueueRetryable(()=>t(A.FIRST_PARTY))}shutdown(){}invalidateToken(){}}class Y{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 J{constructor(e,t){this.V=t,this.forceRefresh=!1,this.appCheck=null,this.m=null,this.p=null,(0,y.rh)(e)&&e.settings.appCheckToken&&(this.p=e.settings.appCheckToken)}start(e,t){j(void 0===this.o,3512);let n=e=>{null!=e.error&&P("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${e.error.message}`);let n=e.token!==this.m;return this.m=e.token,P("FirebaseAppCheckTokenProvider",`Received ${n?"new":"existing"} token.`),n?t(e.token):Promise.resolve()};this.o=t=>{e.enqueueRetryable(()=>n(t))};let r=e=>{P("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=e,this.o&&this.appCheck.addTokenListener(this.o)};this.V.onInit(e=>r(e)),setTimeout(()=>{if(!this.appCheck){let e=this.V.getImmediate({optional:!0});e?r(e):P("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}},0)}getToken(){if(this.p)return Promise.resolve(new Y(this.p));let e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then(e=>e?(j("string"==typeof e.token,44558,{tokenResult:e}),this.m=e.token,new Y(e.token)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.o&&this.appCheck.removeTokenListener(this.o),this.o=void 0}}class Z{getToken(){return Promise.resolve(new Y(""))}invalidateToken(){}start(e,t){}shutdown(){}}function ee(){return new TextEncoder}class et{static newId(){let e=62*Math.floor(256/62),t="";for(;t.length<20;){let n=function(e){let t="undefined"!=typeof self&&(self.crypto||self.msCrypto),n=new Uint8Array(40);if(t&&"function"==typeof t.getRandomValues)t.getRandomValues(n);else for(let e=0;e<40;
15e++)n[e]=Math.floor(256*Math.random());return n}(0);for(let r=0;r<n.length;++r)t.length<20&&n[r]<e&&(t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(n[r]%62))}return t}}function en(e,t){return e<t?-1:e>t?1:0}function er(e,t){let n=0;for(;n<e.length&&n<t.length;){let r=e.codePointAt(n),i=t.codePointAt(n);if(r!==i){if(r<128&&i<128)return en(r,i);{let s=ee(),o=function(e,t){for(let n=0;n<e.length&&n<t.length;++n)if(e[n]!==t[n])return en(e[n],t[n]);return en(e.length,t.length)}(s.encode(ei(e,n)),s.encode(ei(t,n)));return 0!==o?o:en(r,i)}}n+=r>65535?2:1}return en(e.length,t.length)}function ei(e,t){return e.codePointAt(t)>65535?e.substring(t,t+2):e.substring(t,t+1)}function es(e,t,n){return e.length===t.length&&e.every((e,r)=>n(e,t[r]))}class eo{static now(){return eo.fromMillis(Date.now())}static fromDate(e){return eo.fromMillis(e.getTime())}static fromMillis(e){let t=Math.floor(e/1e3);return new eo(t,Math.floor((e-1e3*t)*1e6))}constructor(e,t){if(this.seconds=e,this.nanoseconds=t,t<0||t>=1e9)throw new z(q.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(e<-62135596800||e>=253402300800)throw new z(q.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/1e6}_compareTo(e){return this.seconds===e.seconds?en(this.nanoseconds,e.nanoseconds):en(this.seconds,e.seconds)}isEqual(e){return e.seconds===this.seconds&&e.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{seconds:this.seconds,nanoseconds:this.nanoseconds}}valueOf(){return String(this.seconds- -62135596800).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}class ea{static fromTimestamp(e){return new ea(e)}static min(){return new ea(new eo(0,0))}static max(){return new ea(new eo(253402300799,999999999))}constructor(e){this.timestamp=e}compareTo(e){return this.timestamp._compareTo(e.timestamp)}isEqual(e){return this.timestamp.isEqual(e.timestamp)}toMicroseconds(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}toString(){return"SnapshotVersion("+this.timestamp.toString()+")"}toTimestamp(){return this.timestamp}}let el="__name__";class eu{constructor(e,t,n){void 0===t?t=0:t>e.length&&U(637,{offset:t,range:e.length}),void 0===n?n=e.length-t:n>e.length-t&&U(1746,{length:n,range:e.length-t}),this.segments=e,this.offset=t,this.len=n}get length(){return this.len}isEqual(e){return 0===eu.comparator(this,e)}child(e){let t=this.segments.slice(this.offset,this.limit());return e instanceof eu?e.forEach(e=>{t.push(e)}):t.push(e),this.construct(t)}limit(){return this.offset+this.length}popFirst(e){return e=void 0===e?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 0===this.length}isPrefixOf(e){if(e.length<this.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}isImmediateParentOf(e){if(this.length+1!==e.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}forEach(e){for(let t=this.offset,n=this.limit();t<n;t++)e(this.segments[t])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++){let n=eu.compareSegments(e.get(r),t.get(r));if(0!==n)return n}return en(e.length,t.length)}static compareSegments(e,t){let n=eu.isNumericId(e),r=eu.isNumericId(t);return n&&!r?-1:!n&&r?1:n&&r?eu.extractNumericId(e).compare(eu.extractNumericId(t)):er(e,t)}static isNumericId(e){return e.startsWith("__id")&&e.endsWith("__")}static extractNumericId(e){return r.fromString(e.substring(4,e.length-2))}}class ec extends eu{construct(e,t,n){return new ec(e,t,n)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}
15toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...e){let t=[];for(let n of e){if(n.indexOf("//")>=0)throw new z(q.INVALID_ARGUMENT,`Invalid segment (${n}). Paths must not contain // in them.`);t.push(...n.split("/").filter(e=>e.length>0))}return new ec(t)}static emptyPath(){return new ec([])}}let eh=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class ed extends eu{construct(e,t,n){return new ed(e,t,n)}static isValidIdentifier(e){return eh.test(e)}canonicalString(){return this.toArray().map(e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),ed.isValidIdentifier(e)||(e="`"+e+"`"),e)).join(".")}toString(){return this.canonicalString()}isKeyField(){return 1===this.length&&this.get(0)===el}static keyField(){return new ed([el])}static fromServerFormat(e){let t=[],n="",r=0,i=()=>{if(0===n.length)throw new z(q.INVALID_ARGUMENT,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);t.push(n),n=""},s=!1;for(;r<e.length;){let t=e[r];if("\\"===t){if(r+1===e.length)throw new z(q.INVALID_ARGUMENT,"Path has trailing escape character: "+e);let t=e[r+1];if("\\"!==t&&"."!==t&&"`"!==t)throw new z(q.INVALID_ARGUMENT,"Path has invalid escape sequence: "+e);n+=t,r+=2}else"`"===t?s=!s:"."!==t||s?n+=t:i(),r++}if(i(),s)throw new z(q.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new ed(t)}static emptyPath(){return new ed([])}}class ef{constructor(e){this.path=e}static fromPath(e){return new ef(ec.fromString(e))}static fromName(e){return new ef(ec.fromString(e).popFirst(5))}static empty(){return new ef(ec.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 null!==e&&0===ec.comparator(this.path,e.path)}toString(){return this.path.toString()}static comparator(e,t){return ec.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new ef(new ec(e.slice()))}}class ep{constructor(e,t,n,r){this.indexId=e,this.collectionGroup=t,this.fields=n,this.indexState=r}}function em(e){return e.fields.find(e=>2===e.kind)}function eg(e){return e.fields.filter(e=>2!==e.kind)}function ey(e,t){let n=en(e.collectionGroup,t.collectionGroup);if(0!==n)return n;for(let r=0;r<Math.min(e.fields.length,t.fields.length);++r)if(0!==(n=function(e,t){let n=ed.comparator(e.fieldPath,t.fieldPath);return 0!==n?n:en(e.kind,t.kind)}(e.fields[r],t.fields[r])))return n;return en(e.fields.length,t.fields.length)}ep.UNKNOWN_ID=-1;class ev{constructor(e,t){this.fieldPath=e,this.kind=t}}class ew{constructor(e,t){this.sequenceNumber=e,this.offset=t}static empty(){return new ew(0,eI.min())}}function eb(e,t){let n=e.toTimestamp().seconds,r=e.toTimestamp().nanoseconds+1;return new eI(ea.fromTimestamp(1e9===r?new eo(n+1,0):new eo(n,r)),ef.empty(),t)}function e_(e){return new eI(e.readTime,e.key,-1)}class eI{constructor(e,t,n){this.readTime=e,this.documentKey=t,this.largestBatchId=n}static min(){return new eI(ea.min(),ef.empty(),-1)}static max(){return new eI(ea.max(),ef.empty(),-1)}}function eE(e,t){let n=e.readTime.compareTo(t.readTime);return 0!==n?n:0!==(n=ef.comparator(e.documentKey,t.documentKey))?n:en(e.largestBatchId,t.largestBatchId)}let eT="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class eS{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach(e=>e())}}async function eC(e){if(e.code!==q.FAILED_PRECONDITION||e.message!==eT)throw e;P("LocalStore","Unexpectedly lost primary lease")}class ex{constructor(e){this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,e(e=>{this.isDone=!0,this.result=e,this.nextCallback&&this.nextCallback(e)},e=>{this.isDone=!0,this.error=e,this.catchCallback&&this.catchCallback(e)})}catch(e){return this.next(void 0,e)}next(e,t){return this.callbackAttached&&U(59440),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(t,this.error):this.wrapSuccess(e,this.result):new ex((n,r)=>{this.nextCallback=t=>{this.wrapSuccess(e,t).next(n,r)},this.catchCallback=e=>{this.wrapFailure(t,e).next(n,r)}})}toPromise(){return new Promise((e,t)=>
15{this.next(e,t)})}wrapUserFunction(e){try{let t=e();return t instanceof ex?t:ex.resolve(t)}catch(e){return ex.reject(e)}}wrapSuccess(e,t){return e?this.wrapUserFunction(()=>e(t)):ex.resolve(t)}wrapFailure(e,t){return e?this.wrapUserFunction(()=>e(t)):ex.reject(t)}static resolve(e){return new ex((t,n)=>{t(e)})}static reject(e){return new ex((t,n)=>{n(e)})}static waitFor(e){return new ex((t,n)=>{let r=0,i=0,s=!1;e.forEach(e=>{++r,e.next(()=>{++i,s&&i===r&&t()},e=>n(e))}),s=!0,i===r&&t()})}static or(e){let t=ex.resolve(!1);for(let n of e)t=t.next(e=>e?ex.resolve(e):n());return t}static forEach(e,t){let n=[];return e.forEach((e,r)=>{n.push(t.call(this,e,r))}),this.waitFor(n)}static mapArray(e,t){return new ex((n,r)=>{let i=e.length,s=Array(i),o=0;for(let a=0;a<i;a++){let l=a;t(e[l]).next(e=>{s[l]=e,++o===i&&n(s)},e=>r(e))}})}static doWhile(e,t){return new ex((n,r)=>{let i=()=>{!0===e()?t().next(()=>{i()},r):n()};i()})}}let ek="SimpleDb";class eA{static open(e,t,n,r){try{return new eA(t,e.transaction(r,n))}catch(e){throw new eD(t,e)}}constructor(e,t){this.action=e,this.transaction=t,this.aborted=!1,this.S=new $,this.transaction.oncomplete=()=>{this.S.resolve()},this.transaction.onabort=()=>{t.error?this.S.reject(new eD(e,t.error)):this.S.resolve()},this.transaction.onerror=t=>{let n=eU(t.target.error);this.S.reject(new eD(e,n))}}get D(){return this.S.promise}abort(e){e&&this.S.reject(e),this.aborted||(P(ek,"Aborting transaction:",e?e.message:"Client-initiated abort"),this.aborted=!0,this.transaction.abort())}v(){let e=this.transaction;this.aborted||"function"!=typeof e.commit||e.commit()}store(e){return new eL(this.transaction.objectStore(e))}}class eR{static delete(e){return P(ek,"Removing database:",e),eM((0,b.Rd)().indexedDB.deleteDatabase(e)).toPromise()}static C(){if(!(0,b.hl)())return!1;if(eR.F())return!0;let e=(0,b.z$)(),t=eR.M(e),n=eN(e);return!(e.indexOf("MSIE ")>0||e.indexOf("Trident/")>0||e.indexOf("Edge/")>0||0<t&&t<10||0<n&&n<4.5)}static F(){var e;return void 0!==S&&"YES"===(null===(e=S.__PRIVATE_env)||void 0===e?void 0:e.O)}static N(e,t){return e.store(t)}static M(e){let t=e.match(/i(?:phone|pad|pod) os ([\d_]+)/i);return Number(t?t[1].split("_").slice(0,2).join("."):"-1")}constructor(e,t,n){this.name=e,this.version=t,this.B=n,this.L=null,12.2===eR.M((0,b.z$)())&&L("Firestore persistence suffers from a bug in iOS 12.2 Safari that may cause your app to stop working. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.")}async k(e){return this.db||(P(ek,"Opening database:",this.name),this.db=await new Promise((t,n)=>{let r=indexedDB.open(this.name,this.version);r.onsuccess=e=>{t(e.target.result)},r.onblocked=()=>{n(new eD(e,"Cannot upgrade IndexedDB schema while another tab is open. Close all tabs that access Firestore and reload this page to proceed."))},r.onerror=t=>{let r=t.target.error;"VersionError"===r.name?n(new z(q.FAILED_PRECONDITION,"A newer version of the Firestore SDK was previously used and so the persisted data is not compatible with the version of the SDK you are now using. The SDK will operate with persistence disabled. If you need persistence, please re-upgrade to a newer version of the SDK or else clear the persisted IndexedDB data for your app to start fresh.")):"InvalidStateError"===r.name?n(new z(q.FAILED_PRECONDITION,"Unable to open an IndexedDB connection. This could be due to running in a private browsing session on a browser whose private browsing sessions do not support IndexedDB: "+r)):n(new eD(e,r))},r.onupgradeneeded=e=>{P(ek,'Database "'+this.name+'" requires upgrade from version:',e.oldVersion);let t=e.target.result;if(null!==this.L&&this.L!==e.oldVersion)throw Error(`refusing to open IndexedDB database due to potential corruption of the IndexedDB database data; this corruption could be caused by clicking the "clear site data" button in a web browser; try reloading the web page to re-initialize the IndexedDB database: lastClosedDbVersion=${this.L}, event.oldVersion=${e.oldVersion}, event.newVersion=${e.newVersion}, db.version=${t.version}`);this.B.q(t,r.transaction,e.oldVersion,this.version).next(()=>{P(ek,"Database upgrade to version "+this.version+" complete")}
15)}}),this.db.addEventListener("close",e=>{let t=e.target;this.L=t.version},{passive:!0})),this.$&&(this.db.onversionchange=e=>this.$(e)),this.db}U(e){this.$=e,this.db&&(this.db.onversionchange=t=>e(t))}async runTransaction(e,t,n,r){let i="readonly"===t,s=0;for(;;){++s;try{this.db=await this.k(e);let t=eA.open(this.db,e,i?"readonly":"readwrite",n),s=r(t).next(e=>(t.v(),e)).catch(e=>(t.abort(e),ex.reject(e))).toPromise();return s.catch(()=>{}),await t.D,s}catch(t){let e="FirebaseError"!==t.name&&s<3;if(P(ek,"Transaction failed with error:",t.message,"Retrying:",e),this.close(),!e)return Promise.reject(t)}}}close(){this.db&&this.db.close(),this.db=void 0}}function eN(e){let t=e.match(/Android ([\d.]+)/i);return Number(t?t[1].split(".").slice(0,2).join("."):"-1")}class eO{constructor(e){this.K=e,this.W=!1,this.G=null}get isDone(){return this.W}get j(){return this.G}set cursor(e){this.K=e}done(){this.W=!0}H(e){this.G=e}delete(){return eM(this.K.delete())}}class eD extends z{constructor(e,t){super(q.UNAVAILABLE,`IndexedDB transaction '${e}' failed: ${t}`),this.name="IndexedDbTransactionError"}}function eP(e){return"IndexedDbTransactionError"===e.name}class eL{constructor(e){this.store=e}put(e,t){let n;return void 0!==t?(P(ek,"PUT",this.store.name,e,t),n=this.store.put(t,e)):(P(ek,"PUT",this.store.name,"<auto-key>",e),n=this.store.put(e)),eM(n)}add(e){return P(ek,"ADD",this.store.name,e,e),eM(this.store.add(e))}get(e){return eM(this.store.get(e)).next(t=>(void 0===t&&(t=null),P(ek,"GET",this.store.name,e,t),t))}delete(e){return P(ek,"DELETE",this.store.name,e),eM(this.store.delete(e))}count(){return P(ek,"COUNT",this.store.name),eM(this.store.count())}J(e,t){let n=this.options(e,t),r=n.index?this.store.index(n.index):this.store;if("function"==typeof r.getAll){let e=r.getAll(n.range);return new ex((t,n)=>{e.onerror=e=>{n(e.target.error)},e.onsuccess=e=>{t(e.target.result)}})}{let e=this.cursor(n),t=[];return this.Y(e,(e,n)=>{t.push(n)}).next(()=>t)}}Z(e,t){let n=this.store.getAll(e,null===t?void 0:t);return new ex((e,t)=>{n.onerror=e=>{t(e.target.error)},n.onsuccess=t=>{e(t.target.result)}})}X(e,t){P(ek,"DELETE ALL",this.store.name);let n=this.options(e,t);n.ee=!1;let r=this.cursor(n);return this.Y(r,(e,t,n)=>n.delete())}te(e,t){let n;t?n=e:(n={},t=e);let r=this.cursor(n);return this.Y(r,t)}ne(e){let t=this.cursor({});return new ex((n,r)=>{t.onerror=e=>{r(eU(e.target.error))},t.onsuccess=t=>{let r=t.target.result;r?e(r.primaryKey,r.value).next(e=>{e?r.continue():n()}):n()}})}Y(e,t){let n=[];return new ex((r,i)=>{e.onerror=e=>{i(e.target.error)},e.onsuccess=e=>{let i=e.target.result;if(!i)return void r();let s=new eO(i),o=t(i.primaryKey,i.value,s);if(o instanceof ex){let e=o.catch(e=>(s.done(),ex.reject(e)));n.push(e)}s.isDone?r():null===s.j?i.continue():i.continue(s.j)}}).next(()=>ex.waitFor(n))}options(e,t){let n;return void 0!==e&&("string"==typeof e?n=e:t=e),{index:n,range:t}}cursor(e){let t="next";if(e.reverse&&(t="prev"),e.index){let n=this.store.index(e.index);return e.ee?n.openKeyCursor(e.range,t):n.openCursor(e.range,t)}return this.store.openCursor(e.range,t)}}function eM(e){return new ex((t,n)=>{e.onsuccess=e=>{t(e.target.result)},e.onerror=e=>{n(eU(e.target.error))}})}let eF=!1;function eU(e){let t=eR.M((0,b.z$)());if(t>=12.2&&t<13){let t="An internal error was encountered in the Indexed Database server";if(e.message.indexOf(t)>=0){let e=new z("internal",`IOS_INDEXEDDB_BUG1: IndexedDb has thrown '${t}'. This is likely due to an unavoidable bug in iOS. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.`);return eF||(eF=!0,setTimeout(()=>{throw e},0)),e}}return e}let eV="IndexBackfiller";class ej{constructor(e,t){this.asyncQueue=e,this.re=t,this.task=null}start(){this.ie(15e3)}stop(){this.task&&(this.task.cancel(),this.task=null)}get started(){return null!==this.task}ie(e){P(eV,`Scheduled in ${e}ms`),this.task=this.asyncQueue.enqueueAfterDelay("index_backfill",e,async()=>{this.task=null;try{let e=await this.re.se();P(eV,`Documents written: ${e}`)}catch(e){eP(e)?P(eV,"Ignoring IndexedDB error during index backfill: ",e):await eC(e)}await this.ie(6e4)})}}class eB{constructor(e,t){this.localStore=e,this.persistence=t}async se(e=50){return this.persistence.runTransaction("Backfill Indexes","readwrite-primary",t=>this.oe(t,e))}oe(e,t){let n=new Set,r=t,i=!0;
15return ex.doWhile(()=>!0===i&&r>0,()=>this.localStore.indexManager.getNextCollectionGroupToUpdate(e).next(t=>{if(null!==t&&!n.has(t))return P(eV,`Processing collection: ${t}`),this._e(e,t,r).next(e=>{r-=e,n.add(t)});i=!1})).next(()=>t-r)}_e(e,t,n){return this.localStore.indexManager.getMinOffsetFromCollectionGroup(e,t).next(r=>this.localStore.localDocuments.getNextDocuments(e,t,r,n).next(n=>{let i=n.changes;return this.localStore.indexManager.updateIndexEntries(e,i).next(()=>this.ae(r,n)).next(n=>(P(eV,`Updating offset: ${n}`),this.localStore.indexManager.updateCollectionGroup(e,t,n))).next(()=>i.size)}))}ae(e,t){let n=e;return t.changes.forEach((e,t)=>{let r=e_(t);eE(r,n)>0&&(n=r)}),new eI(n.readTime,n.documentKey,Math.max(t.batchId,e.largestBatchId))}}class eq{constructor(e,t){this.previousValue=e,t&&(t.sequenceNumberHandler=e=>this.ue(e),this.ce=e=>t.writeSequenceNumber(e))}ue(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}next(){let e=++this.previousValue;return this.ce&&this.ce(e),e}}function ez(e){return null==e}function e$(e){return 0===e&&1/e==-1/0}function eK(e){return"number"==typeof e&&Number.isInteger(e)&&!e$(e)&&e<=Number.MAX_SAFE_INTEGER&&e>=Number.MIN_SAFE_INTEGER}function eG(e){let t="";for(let n=0;n<e.length;n++)t.length>0&&(t+="\x01\x01"),t=function(e,t){let n=t,r=e.length;for(let t=0;t<r;t++){let r=e.charAt(t);switch(r){case"\0":n+="\x01\x10";break;case"\x01":n+="\x01\x11";break;default:n+=r}}return n}(e.get(n),t);return t+"\x01\x01"}function eH(e){let t=e.length;if(j(t>=2,64408,{path:e}),2===t)return j("\x01"===e.charAt(0)&&"\x01"===e.charAt(1),56145,{path:e}),ec.emptyPath();let n=t-2,r=[],i="";for(let s=0;s<t;){let t=e.indexOf("\x01",s);switch((t<0||t>n)&&U(50515,{path:e}),e.charAt(t+1)){case"\x01":let o;let a=e.substring(s,t);0===i.length?o=a:(i+=a,o=i,i=""),r.push(o);break;case"\x10":i+=e.substring(s,t)+"\0";break;case"\x11":i+=e.substring(s,t+1);break;default:U(61167,{path:e})}s=t+2}return new ec(r)}eq.le=-1;let eW="remoteDocuments",eQ="owner",eX="owner",eY="mutationQueues",eJ="mutations",eZ="batchId",e0="userMutationsIndex",e1=["userId","batchId"],e2={},e4="documentMutations",e6="remoteDocumentsV14",e5=["prefixPath","collectionGroup","readTime","documentId"],e9="documentKeyIndex",e3=["prefixPath","collectionGroup","documentId"],e8="collectionGroupIndex",e7=["collectionGroup","readTime","prefixPath","documentId"],te="remoteDocumentGlobal",tt="remoteDocumentGlobalKey",tn="targets",tr="queryTargetsIndex",ti=["canonicalId","targetId"],ts="targetDocuments",to=["targetId","path"],ta="documentTargetsIndex",tl=["path","targetId"],tu="targetGlobalKey",tc="targetGlobal",th="collectionParents",td=["collectionId","parent"],tf="clientMetadata",tp="bundles",tm="namedQueries",tg="indexConfiguration",ty="collectionGroupIndex",tv="indexState",tw=["indexId","uid"],tb="sequenceNumberIndex",t_=["uid","sequenceNumber"],tI="indexEntries",tE=["indexId","uid","arrayValue","directionalValue","orderedDocumentKey","documentKey"],tT="documentKeyIndex",tS=["indexId","uid","orderedDocumentKey"],tC="documentOverlays",tx=["userId","collectionPath","documentId"],tk="collectionPathOverlayIndex",tA=["userId","collectionPath","largestBatchId"],tR="collectionGroupOverlayIndex",tN=["userId","collectionGroup","largestBatchId"],tO="globals",tD=[eY,eJ,e4,eW,tn,eQ,tc,ts,tf,te,th,tp,tm],tP=[...tD,tC],tL=[eY,eJ,e4,e6,tn,eQ,tc,ts,tf,te,th,tp,tm,tC],tM=[...tL,tg,tv,tI],tF=[...tM,tO];class tU extends eS{constructor(e,t){super(),this.he=e,this.currentSequenceNumber=t}}function tV(e,t){return eR.N(e.he,t)}function tj(e){let t=0;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}function tB(e,t){for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t(n,e[n])}function tq(e,t){let n=[];for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.push(t(e[r],r,e));return n}function tz(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}class t${constructor(e,t){this.comparator=e,this.root=t||tG.EMPTY}insert(e,t){return new t$(this.comparator,this.root.insert(e,t,this.comparator).copy(null,null,tG.BLACK,null,
15null))}remove(e){return new t$(this.comparator,this.root.remove(e,this.comparator).copy(null,null,tG.BLACK,null,null))}get(e){let t=this.root;for(;!t.isEmpty();){let n=this.comparator(e,t.key);if(0===n)return t.value;n<0?t=t.left:n>0&&(t=t.right)}return null}indexOf(e){let t=0,n=this.root;for(;!n.isEmpty();){let r=this.comparator(e,n.key);if(0===r)return t+n.left.size;r<0?n=n.left:(t+=n.left.size+1,n=n.right)}return -1}isEmpty(){return this.root.isEmpty()}get size(){return this.root.size}minKey(){return this.root.minKey()}maxKey(){return this.root.maxKey()}inorderTraversal(e){return this.root.inorderTraversal(e)}forEach(e){this.inorderTraversal((t,n)=>(e(t,n),!1))}toString(){let e=[];return this.inorderTraversal((t,n)=>(e.push(`${t}:${n}`),!1)),`{${e.join(", ")}}`}reverseTraversal(e){return this.root.reverseTraversal(e)}getIterator(){return new tK(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new tK(this.root,e,this.comparator,!1)}getReverseIterator(){return new tK(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new tK(this.root,e,this.comparator,!0)}}class tK{constructor(e,t,n,r){this.isReverse=r,this.nodeStack=[];let i=1;for(;!e.isEmpty();)if(i=t?n(e.key,t):1,t&&r&&(i*=-1),i<0)e=this.isReverse?e.left:e.right;else{if(0===i){this.nodeStack.push(e);break}this.nodeStack.push(e),e=this.isReverse?e.right:e.left}}getNext(){let e=this.nodeStack.pop(),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(0===this.nodeStack.length)return null;let e=this.nodeStack[this.nodeStack.length-1];return{key:e.key,value:e.value}}}class tG{constructor(e,t,n,r,i){this.key=e,this.value=t,this.color=null!=n?n:tG.RED,this.left=null!=r?r:tG.EMPTY,this.right=null!=i?i:tG.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,t,n,r,i){return new tG(null!=e?e:this.key,null!=t?t:this.value,null!=n?n:this.color,null!=r?r:this.left,null!=i?i:this.right)}isEmpty(){return!1}inorderTraversal(e){return this.left.inorderTraversal(e)||e(this.key,this.value)||this.right.inorderTraversal(e)}reverseTraversal(e){return this.right.reverseTraversal(e)||e(this.key,this.value)||this.left.reverseTraversal(e)}min(){return this.left.isEmpty()?this:this.left.min()}minKey(){return this.min().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(e,t,n){let r=this,i=n(e,r.key);return(r=i<0?r.copy(null,null,null,r.left.insert(e,t,n),null):0===i?r.copy(null,t,null,null,null):r.copy(null,null,null,null,r.right.insert(e,t,n))).fixUp()}removeMin(){if(this.left.isEmpty())return tG.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)).fixUp()}remove(e,t){let n,r=this;if(0>t(e,r.key))r.left.isEmpty()||r.left.isRed()||r.left.left.isRed()||(r=r.moveRedLeft()),r=r.copy(null,null,null,r.left.remove(e,t),null);else{if(r.left.isRed()&&(r=r.rotateRight()),r.right.isEmpty()||r.right.isRed()||r.right.left.isRed()||(r=r.moveRedRight()),0===t(e,r.key)){if(r.right.isEmpty())return tG.EMPTY;n=r.right.min(),r=r.copy(n.key,n.value,null,null,r.right.removeMin())}r=r.copy(null,null,null,null,r.right.remove(e,t))}return r.fixUp()}isRed(){return this.color}fixUp(){let e=this;return e.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=(e=e.copy(null,null,null,null,e.right.rotateRight())).rotateLeft()).colorFlip()),e}moveRedRight(){let e=this.colorFlip();return e.left.left.isRed()&&(e=(e=e.rotateRight()).colorFlip()),e}rotateLeft(){let e=this.copy(null,null,tG.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){let e=this.copy(null,null,tG.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip(){let 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(){return Math.pow(2,this.check())<=this.size+1}check(){if(this.isRed()&&this.left.isRed())throw U(43730,{key:this.key,value:this.value});if(this.right.isRed())throw U(14113,{key:this.key,value:this.value});let e=this.left.check();if(e!==this.right.check())throw U(27949);return e+(this.isRed()?0:1)}}
15tG.EMPTY=null,tG.RED=!0,tG.BLACK=!1,tG.EMPTY=new class{constructor(){this.size=0}get key(){throw U(57766)}get value(){throw U(16141)}get color(){throw U(16727)}get left(){throw U(29726)}get right(){throw U(36894)}copy(e,t,n,r,i){return this}insert(e,t,n){return new tG(e,t)}remove(e,t){return this}isEmpty(){return!0}inorderTraversal(e){return!1}reverseTraversal(e){return!1}minKey(){return null}maxKey(){return null}isRed(){return!1}checkMaxDepth(){return!0}check(){return 0}};class tH{constructor(e){this.comparator=e,this.data=new t$(this.comparator)}has(e){return null!==this.data.get(e)}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(e){return this.data.indexOf(e)}forEach(e){this.data.inorderTraversal((t,n)=>(e(t),!1))}forEachInRange(e,t){let n=this.data.getIteratorFrom(e[0]);for(;n.hasNext();){let r=n.getNext();if(this.comparator(r.key,e[1])>=0)return;t(r.key)}}forEachWhile(e,t){let n;for(n=void 0!==t?this.data.getIteratorFrom(t):this.data.getIterator();n.hasNext();)if(!e(n.getNext().key))return}firstAfterOrEqual(e){let t=this.data.getIteratorFrom(e);return t.hasNext()?t.getNext().key:null}getIterator(){return new tW(this.data.getIterator())}getIteratorFrom(e){return new tW(this.data.getIteratorFrom(e))}add(e){return this.copy(this.data.remove(e).insert(e,!0))}delete(e){return this.has(e)?this.copy(this.data.remove(e)):this}isEmpty(){return this.data.isEmpty()}unionWith(e){let t=this;return t.size<e.size&&(t=e,e=this),e.forEach(e=>{t=t.add(e)}),t}isEqual(e){if(!(e instanceof tH)||this.size!==e.size)return!1;let t=this.data.getIterator(),n=e.data.getIterator();for(;t.hasNext();){let e=t.getNext().key,r=n.getNext().key;if(0!==this.comparator(e,r))return!1}return!0}toArray(){let e=[];return this.forEach(t=>{e.push(t)}),e}toString(){let e=[];return this.forEach(t=>e.push(t)),"SortedSet("+e.toString()+")"}copy(e){let t=new tH(this.comparator);return t.data=e,t}}class tW{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}function tQ(e){return e.hasNext()?e.getNext():void 0}class tX{constructor(e){this.fields=e,e.sort(ed.comparator)}static empty(){return new tX([])}unionWith(e){let t=new tH(ed.comparator);for(let e of this.fields)t=t.add(e);for(let n of e)t=t.add(n);return new tX(t.toArray())}covers(e){for(let t of this.fields)if(t.isPrefixOf(e))return!0;return!1}isEqual(e){return es(this.fields,e.fields,(e,t)=>e.isEqual(t))}}class tY extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}function tJ(){return"undefined"!=typeof atob}class tZ{constructor(e){this.binaryString=e}static fromBase64String(e){return new tZ(function(e){try{return atob(e)}catch(e){throw"undefined"!=typeof DOMException&&e instanceof DOMException?new tY("Invalid base64 string: "+e):e}}(e))}static fromUint8Array(e){return new tZ(function(e){let t="";for(let n=0;n<e.length;++n)t+=String.fromCharCode(e[n]);return t}(e))}[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 btoa(this.binaryString)}toUint8Array(){return function(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(e){return en(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}}tZ.EMPTY_BYTE_STRING=new tZ("");let t0=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function t1(e){if(j(!!e,39018),"string"==typeof e){let t=0,n=t0.exec(e);if(j(!!n,46558,{timestamp:e}),n[1]){let e=n[1];t=Number(e=(e+"000000000").substr(0,9))}return{seconds:Math.floor(new Date(e).getTime()/1e3),nanos:t}}return{seconds:t2(e.seconds),nanos:t2(e.nanos)}}function t2(e){return"number"==typeof e?e:"string"==typeof e?Number(e):0}function t4(e){return"string"==typeof e?tZ.fromBase64String(e):tZ.fromUint8Array(e)}let t6="server_timestamp",t5="__type__",t9="__previous_value__",t3="__local_write_time__";function t8(e){var t,n;return(null===(n=((null===(t=null==e?void 0:e.mapValue)||void 0===t?void 0:t.fields)||{})[t5])||void 0===n?void 0:n.stringValue)===t6}function t7(e){let t=e.mapValue.fields[t9];return t8(t)?t7(t):t}function ne(e){let t=t1(e.mapValue.fields[t3].timestampValue);return new eo(t.seconds,t.nanos)}class nt{constructor(e,t,n,r,i,s,o,a,l,u){this.databaseId=e,this.appId=t,this.persistenceKey=n,this.host=r,this.ssl=i,this.forceLongPolling=s,this.autoDetectLongPolling=o,this.longPollingOptions=a,this.useFetchStreams=l,this.isUsingEmulator=u}}let nn="(default)";class nr{constructor(e,t){this.projectId=e,this.database=t||nn}static empty(){return new nr("","")}get isDefaultDatabase(){return this.database===nn}isEqual(e){return e instanceof nr&&e.projectId===this.projectId&&e.database===this.database}}let ni="__type__",ns="__max__",no={mapValue:{fields:{__type__:{stringValue:ns}}}},na="__vector__",nl="value",nu={nullValue:"NULL_VALUE"};function nc(e){return"nullValue"in e?0:"booleanValue"in e?1:"integerValue"in e||"doubleValue"in e?2:"timestampValue"in e?3:"stringValue"in e?5:"bytesValue"in e?6:"referenceValue"in e?7:"geoPointValue"in e?8:"arrayValue"in e?9:"mapValue"in e?t8(e)?4:nS(e)?9007199254740991:nE(e)?10:11:U(28295,{value:e})}function nh(e,t){if(e===t)return!0;let n=nc(e);if(n!==nc(t))return!1;switch(n){case 0:case 9007199254740991:return!0;case 1:return e.booleanValue===t.booleanValue;case 4:return ne(e).isEqual(ne(t));case 3:return function(e,t){if("string"==typeof e.timestampValue&&"string"==typeof t.timestampValue&&e.timestampValue.length===t.timestampValue.length)return e.timestampValue===t.timestampValue;let n=t1(e.timestampValue),r=t1(t.timestampValue);return n.seconds===r.seconds&&n.nanos===r.nanos}(e,t);case 5:return e.stringValue===t.stringValue;case 6:return t4(e.bytesValue).isEqual(t4(t.bytesValue));case 7:return e.referenceValue===t.referenceValue;case 8:return t2(e.geoPointValue.latitude)===t2(t.geoPointValue.latitude)&&t2(e.geoPointValue.longitude)===t2(t.geoPointValue.longitude);case 2:return function(e,t){if("integerValue"in e&&"integerValue"in t)return t2(e.integerValue)===t2(t.integerValue);if("doubleValue"in e&&"doubleValue"in t){let n=t2(e.doubleValue),r=t2(t.doubleValue);return n===r?e$(n)===e$(r):isNaN(n)&&isNaN(r)}return!1}(e,t);case 9:return es(e.arrayValue.values||[],t.arrayValue.values||[],nh);case 10:case 11:return function(e,t){let n=e.mapValue.fields||{},r=t.mapValue.fields||{};if(tj(n)!==tj(r))return!1;for(let e in n)if(n.hasOwnProperty(e)&&(void 0===r[e]||!nh(n[e],r[e])))return!1;return!0}(e,t);default:return U(52216,{left:e})}}
15function nd(e,t){return void 0!==(e.values||[]).find(e=>nh(e,t))}function nf(e,t){if(e===t)return 0;let n=nc(e),r=nc(t);if(n!==r)return en(n,r);switch(n){case 0:case 9007199254740991:return 0;case 1:return en(e.booleanValue,t.booleanValue);case 2:return function(e,t){let n=t2(e.integerValue||e.doubleValue),r=t2(t.integerValue||t.doubleValue);return n<r?-1:n>r?1:n===r?0:isNaN(n)?isNaN(r)?0:-1:1}(e,t);case 3:return np(e.timestampValue,t.timestampValue);case 4:return np(ne(e),ne(t));case 5:return er(e.stringValue,t.stringValue);case 6:return function(e,t){let n=t4(e),r=t4(t);return n.compareTo(r)}(e.bytesValue,t.bytesValue);case 7:return function(e,t){let n=e.split("/"),r=t.split("/");for(let e=0;e<n.length&&e<r.length;e++){let t=en(n[e],r[e]);if(0!==t)return t}return en(n.length,r.length)}(e.referenceValue,t.referenceValue);case 8:return function(e,t){let n=en(t2(e.latitude),t2(t.latitude));return 0!==n?n:en(t2(e.longitude),t2(t.longitude))}(e.geoPointValue,t.geoPointValue);case 9:return nm(e.arrayValue,t.arrayValue);case 10:return function(e,t){var n,r,i,s;let o=e.fields||{},a=t.fields||{},l=null===(n=o[nl])||void 0===n?void 0:n.arrayValue,u=null===(r=a[nl])||void 0===r?void 0:r.arrayValue,c=en((null===(i=null==l?void 0:l.values)||void 0===i?void 0:i.length)||0,(null===(s=null==u?void 0:u.values)||void 0===s?void 0:s.length)||0);return 0!==c?c:nm(l,u)}(e.mapValue,t.mapValue);case 11:return function(e,t){if(e===no.mapValue&&t===no.mapValue)return 0;if(e===no.mapValue)return 1;if(t===no.mapValue)return -1;let n=e.fields||{},r=Object.keys(n),i=t.fields||{},s=Object.keys(i);r.sort(),s.sort();for(let e=0;e<r.length&&e<s.length;++e){let t=er(r[e],s[e]);if(0!==t)return t;let o=nf(n[r[e]],i[s[e]]);if(0!==o)return o}return en(r.length,s.length)}(e.mapValue,t.mapValue);default:throw U(23264,{Pe:n})}}function np(e,t){if("string"==typeof e&&"string"==typeof t&&e.length===t.length)return en(e,t);let n=t1(e),r=t1(t),i=en(n.seconds,r.seconds);return 0!==i?i:en(n.nanos,r.nanos)}function nm(e,t){let n=e.values||[],r=t.values||[];for(let e=0;e<n.length&&e<r.length;++e){let t=nf(n[e],r[e]);if(t)return t}return en(n.length,r.length)}function ng(e){var t,n;return"nullValue"in e?"null":"booleanValue"in e?""+e.booleanValue:"integerValue"in e?""+e.integerValue:"doubleValue"in e?""+e.doubleValue:"timestampValue"in e?function(e){let t=t1(e);return`time(${t.seconds},${t.nanos})`}(e.timestampValue):"stringValue"in e?e.stringValue:"bytesValue"in e?t4(e.bytesValue).toBase64():"referenceValue"in e?(t=e.referenceValue,ef.fromName(t).toString()):"geoPointValue"in e?(n=e.geoPointValue,`geo(${n.latitude},${n.longitude})`):"arrayValue"in e?function(e){let t="[",n=!0;for(let r of e.values||[])n?n=!1:t+=",",t+=ng(r);return t+"]"}(e.arrayValue):"mapValue"in e?function(e){let t=Object.keys(e.fields||{}).sort(),n="{",r=!0;for(let i of t)r?r=!1:n+=",",n+=`${i}:${ng(e.fields[i])}`;return n+"}"}(e.mapValue):U(61005,{value:e})}function ny(e,t){return{referenceValue:`projects/${e.projectId}/databases/${e.database}/documents/${t.path.canonicalString()}`}}function nv(e){return!!e&&"integerValue"in e}function nw(e){return!!e&&"arrayValue"in e}function nb(e){return!!e&&"nullValue"in e}function n_(e){return!!e&&"doubleValue"in e&&isNaN(Number(e.doubleValue))}function nI(e){return!!e&&"mapValue"in e}function nE(e){var t,n;return(null===(n=((null===(t=null==e?void 0:e.mapValue)||void 0===t?void 0:t.fields)||{})[ni])||void 0===n?void 0:n.stringValue)===na}function nT(e){if(e.geoPointValue)return{geoPointValue:Object.assign({},e.geoPointValue)};if(e.timestampValue&&"object"==typeof e.timestampValue)return{timestampValue:Object.assign({},e.timestampValue)};if(e.mapValue){let t={mapValue:{fields:{}}};return tB(e.mapValue.fields,(e,n)=>t.mapValue.fields[e]=nT(n)),t}if(e.arrayValue){let t={arrayValue:{values:[]}};for(let n=0;n<(e.arrayValue.values||[]).length;++n)t.arrayValue.values[n]=nT(e.arrayValue.values[n]);return t}return Object.assign({},e)}function nS(e){return(((e.mapValue||{}).fields||{}).__type__||{}).stringValue===ns}let nC={mapValue:{fields:{[ni]:{stringValue:na},[nl]:{arrayValue:{}}}}};function nx(e,t){let n=nf(e.value,t.value);return 0!==n?n:e.inclusive&&!t.inclusive?-1:!e.inclusive&&t.inclusive?1:0}function nk(e,t){let n=nf(e.value,t.value);return 0!==n?n:e.inclusive&&!t.inclusive?1:!e.inclusive&&t.inclusive?-1:0}class nA{constructor(e){this.value=e}static empty(){return new nA({mapValue:{}})}field(e){if(e.isEmpty())return this.value;{let t=this.value;for(let n=0;n<e.length-1;++n)if(!nI(t=(t.mapValue.fields||{})[e.get(n)]))return null;return(t=(t.mapValue.fields||{})[e.lastSegment()])||null}}set(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=nT(t)}setAll(e){let t=ed.emptyPath(),n={},r=[];e.forEach((e,i)=>{if(!t.isImmediateParentOf(i)){let e=this.getFieldsMap(t);this.applyChanges(e,n,r),n={},r=[],t=i.popLast()}e?n[i.lastSegment()]=nT(e):r.push(i.lastSegment())});let i=this.getFieldsMap(t);this.applyChanges(i,n,r)}delete(e){let t=this.field(e.popLast());nI(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return nh(this.value,e.value)}getFieldsMap(e){let t=this.value;t.mapValue.fields||(t.mapValue={fields:{}});for(let n=0;n<e.length;++n){let r=t.mapValue.fields[e.get(n)];nI(r)&&r.mapValue.fields||(r={mapValue:{fields:{}}},t.mapValue.fields[e.get(n)]=r),t=r}return t.mapValue.fields}
15applyChanges(e,t,n){for(let r of(tB(t,(t,n)=>e[t]=n),n))delete e[r]}clone(){return new nA(nT(this.value))}}class nR{constructor(e,t,n,r,i,s,o){this.key=e,this.documentType=t,this.version=n,this.readTime=r,this.createTime=i,this.data=s,this.documentState=o}static newInvalidDocument(e){return new nR(e,0,ea.min(),ea.min(),ea.min(),nA.empty(),0)}static newFoundDocument(e,t,n,r){return new nR(e,1,t,ea.min(),n,r,0)}static newNoDocument(e,t){return new nR(e,2,t,ea.min(),ea.min(),nA.empty(),0)}static newUnknownDocument(e,t){return new nR(e,3,t,ea.min(),ea.min(),nA.empty(),2)}convertToFoundDocument(e,t){return this.createTime.isEqual(ea.min())&&(2===this.documentType||0===this.documentType)&&(this.createTime=e),this.version=e,this.documentType=1,this.data=t,this.documentState=0,this}convertToNoDocument(e){return this.version=e,this.documentType=2,this.data=nA.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=nA.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=ea.min(),this}setReadTime(e){return this.readTime=e,this}get hasLocalMutations(){return 1===this.documentState}get hasCommittedMutations(){return 2===this.documentState}get hasPendingWrites(){return this.hasLocalMutations||this.hasCommittedMutations}isValidDocument(){return 0!==this.documentType}isFoundDocument(){return 1===this.documentType}isNoDocument(){return 2===this.documentType}isUnknownDocument(){return 3===this.documentType}isEqual(e){return e instanceof nR&&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 nR(this.key,this.documentType,this.version,this.readTime,this.createTime,this.data.clone(),this.documentState)}toString(){return`Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {createTime: ${this.createTime}}), {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`}}class nN{constructor(e,t){this.position=e,this.inclusive=t}}function nO(e,t,n){let r=0;for(let i=0;i<e.position.length;i++){let s=t[i],o=e.position[i];if(r=s.field.isKeyField()?ef.comparator(ef.fromName(o.referenceValue),n.key):nf(o,n.data.field(s.field)),"desc"===s.dir&&(r*=-1),0!==r)break}return r}function nD(e,t){if(null===e)return null===t;if(null===t||e.inclusive!==t.inclusive||e.position.length!==t.position.length)return!1;for(let n=0;n<e.position.length;n++)if(!nh(e.position[n],t.position[n]))return!1;return!0}class nP{constructor(e,t="asc"){this.field=e,this.dir=t}}class nL{}class nM extends nL{constructor(e,t,n){super(),this.field=e,this.op=t,this.value=n}static create(e,t,n){return e.isKeyField()?"in"===t||"not-in"===t?this.createKeyFieldInFilter(e,t,n):new nz(e,t,n):"array-contains"===t?new nH(e,n):"in"===t?new nW(e,n):"not-in"===t?new nQ(e,n):"array-contains-any"===t?new nX(e,n):new nM(e,t,n)}static createKeyFieldInFilter(e,t,n){return"in"===t?new n$(e,n):new nK(e,n)}matches(e){let t=e.data.field(this.field);return"!="===this.op?null!==t&&void 0===t.nullValue&&this.matchesComparison(nf(t,this.value)):null!==t&&nc(this.value)===nc(t)&&this.matchesComparison(nf(t,this.value))}matchesComparison(e){switch(this.op){case"<":return e<0;case"<=":return e<=0;case"==":return 0===e;case"!=":return 0!==e;case">":return e>0;case">=":return e>=0;default:return U(47266,{operator:this.op})}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class nF extends nL{constructor(e,t){super(),this.filters=e,this.op=t,this.Te=null}static create(e,t){return new nF(e,t)}matches(e){return nU(this)?void 0===this.filters.find(t=>!t.matches(e)):void 0!==this.filters.find(t=>t.matches(e))}getFlattenedFilters(){return null!==this.Te||(this.Te=this.filters.reduce((e,t)=>e.concat(t.getFlattenedFilters()),[])),this.Te}getFilters(){return Object.assign([],this.filters)}}function nU(e){return"and"===e.op}function nV(e){return"or"===e.op}function nj(e){return nB(e)&&nU(e)}function nB(e){for(let t of e.filters)if(t instanceof nF)return!1;return!0}function nq(e,t){let n=e.filters.concat(t);return nF.create(n,e.op)}class nz extends nM{constructor(e,t,n){super(e,t,n),this.key=ef.fromName(n.referenceValue)}matches(e){let t=ef.comparator(e.key,this.key);return this.matchesComparison(t)}}class n$ extends nM{constructor(e,t){super(e,"in",t),this.keys=nG("in",t)}matches(e){return this.keys.some(t=>t.isEqual(e.key))}}class nK extends nM{constructor(e,t){super(e,"not-in",t),this.keys=nG("not-in",t)}matches(e){return!this.keys.some(t=>t.isEqual(e.key))}}function nG(e,t){var n;return((null===(n=t.arrayValue)||void 0===n?void 0:n.values)||[]).map(e=>ef.fromName(e.referenceValue))}class nH extends nM{constructor(e,t){super(e,"array-contains",t)}matches(e){let t=e.data.field(this.field);return nw(t)&&nd(t.arrayValue,this.value)}}class nW extends nM{constructor(e,t){super(e,"in",t)}matches(e){let t=e.data.field(this.field);return null!==t&&nd(this.value.arrayValue,t)}}class nQ extends nM{constructor(e,t){super(e,"not-in",t)}matches(e){if(nd(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;let t=e.data.field(this.field);return null!==t&&void 0===t.nullValue&&!nd(this.value.arrayValue,t)}}class nX extends nM{constructor(e,t){super(e,"array-contains-any",t)}matches(e){let t=e.data.field(this.field);return!(!nw(t)||!t.arrayValue.values)&&t.arrayValue.values.some(e=>nd(this.value.arrayValue,e))}}class nY{constructor(e,t=null,n=[],r=[],i=null,s=null,o=null){this.path=e,this.collectionGroup=t,this.orderBy=n,this.filters=r,this.limit=i,this.startAt=s,this.endAt=o,this.Ie=null}}function nJ(e,t=null,n=[],r=[],i=null,s=null,o=null){return new nY(e,t,n,r,i,s,o)}function nZ(e){if(null===e.Ie){let t=e.path.canonicalString();null!==e.collectionGroup&&(t+="|cg:"+e.collectionGroup),t+="|f:"+e.filters.map(e=>(function e(t){if(t instanceof nM)return t.field.canonicalString()+t.op.toString()+ng(t.value);if(nj(t))return t.filters.map(t=>e(t)).join(",");{let n=t.filters.map(t=>e(t)).join(",");return`${t.op}(${n})`}})(e)).join(",")+"|ob:"+e.orderBy.map(e=>e.field.canonicalString()+e.dir).join(","),ez(e.limit)||(t+="|l:"+e.limit),e.startAt&&(t+="|lb:"+(e.startAt.inclusive?"b:":"a:")+e.startAt.position.map(e=>ng(e)).join(",")),e.endAt&&(t+="|ub:"+(e.endAt.inclusive?"a:":"b:")+e.endAt.position.map(e=>ng(e)).join(",")),e.Ie=t}return e.Ie}function n0(e,t){if(e.limit!==t.limit||e.orderBy.length!==t.orderBy.length)return!1;for(let i=0;i<e.orderBy.length;i++){var n,r;if(n=e.orderBy[i],r=t.orderBy[i],!(n.dir===r.dir&&n.field.isEqual(r.field)))return!1}if(e.filters.length!==t.filters.length)return!1;for(let n=0;n<e.filters.length;n++)if(!function e(t,n){return t instanceof nM?n instanceof nM&&t.op===n.op&&t.field.isEqual(n.field)&&nh(t.value,n.value):t instanceof nF?n instanceof nF&&t.op===n.op&&t.filters.length===n.filters.length&&t.filters.reduce((t,r,i)=>t&&e(r,n.filters[i]),!0):void U(19439)}(e.filters[n],t.filters[n]))return!1;return e.collectionGroup===t.collectionGroup&&!!e.path.isEqual(t.path)&&!!nD(e.startAt,t.startAt)&&nD(e.endAt,t.endAt)}function n1(e){return ef.isDocumentKey(e.path)&&null===e.collectionGroup&&0===e.filters.length}function n2(e,t){return e.filters.filter(e=>e instanceof nM&&e.field.isEqual(t))}function n4(e,t,n){let r=nu,i=!0;for(let n of n2(e,t)){let e=nu,t=!0;switch(n.op){case"<":case"<=":var s;
15e="nullValue"in(s=n.value)?nu:"booleanValue"in s?{booleanValue:!1}:"integerValue"in s||"doubleValue"in s?{doubleValue:NaN}:"timestampValue"in s?{timestampValue:{seconds:Number.MIN_SAFE_INTEGER}}:"stringValue"in s?{stringValue:""}:"bytesValue"in s?{bytesValue:""}:"referenceValue"in s?ny(nr.empty(),ef.empty()):"geoPointValue"in s?{geoPointValue:{latitude:-90,longitude:-180}}:"arrayValue"in s?{arrayValue:{}}:"mapValue"in s?nE(s)?nC:{mapValue:{}}:U(35942,{value:s});break;case"==":case"in":case">=":e=n.value;break;case">":e=n.value,t=!1;break;case"!=":case"not-in":e=nu}0>nx({value:r,inclusive:i},{value:e,inclusive:t})&&(r=e,i=t)}if(null!==n){for(let s=0;s<e.orderBy.length;++s)if(e.orderBy[s].field.isEqual(t)){let e=n.position[s];0>nx({value:r,inclusive:i},{value:e,inclusive:n.inclusive})&&(r=e,i=n.inclusive);break}}return{value:r,inclusive:i}}function n6(e,t,n){let r=no,i=!0;for(let n of n2(e,t)){let e=no,t=!0;switch(n.op){case">=":case">":var s;e="nullValue"in(s=n.value)?{booleanValue:!1}:"booleanValue"in s?{doubleValue:NaN}:"integerValue"in s||"doubleValue"in s?{timestampValue:{seconds:Number.MIN_SAFE_INTEGER}}:"timestampValue"in s?{stringValue:""}:"stringValue"in s?{bytesValue:""}:"bytesValue"in s?ny(nr.empty(),ef.empty()):"referenceValue"in s?{geoPointValue:{latitude:-90,longitude:-180}}:"geoPointValue"in s?{arrayValue:{}}:"arrayValue"in s?nC:"mapValue"in s?nE(s)?{mapValue:{}}:no:U(61959,{value:s}),t=!1;break;case"==":case"in":case"<=":e=n.value;break;case"<":e=n.value,t=!1;break;case"!=":case"not-in":e=no}nk({value:r,inclusive:i},{value:e,inclusive:t})>0&&(r=e,i=t)}if(null!==n){for(let s=0;s<e.orderBy.length;++s)if(e.orderBy[s].field.isEqual(t)){let e=n.position[s];nk({value:r,inclusive:i},{value:e,inclusive:n.inclusive})>0&&(r=e,i=n.inclusive);break}}return{value:r,inclusive:i}}class n5{constructor(e,t=null,n=[],r=[],i=null,s="F",o=null,a=null){this.path=e,this.collectionGroup=t,this.explicitOrderBy=n,this.filters=r,this.limit=i,this.limitType=s,this.startAt=o,this.endAt=a,this.Ee=null,this.de=null,this.Ae=null,this.startAt,this.endAt}}function n9(e){return new n5(e)}function n3(e){return 0===e.filters.length&&null===e.limit&&null==e.startAt&&null==e.endAt&&(0===e.explicitOrderBy.length||1===e.explicitOrderBy.length&&e.explicitOrderBy[0].field.isKeyField())}function n8(e){return null!==e.collectionGroup}function n7(e){if(null===e.Ee){let t;e.Ee=[];let n=new Set;for(let t of e.explicitOrderBy)e.Ee.push(t),n.add(t.field.canonicalString());let r=e.explicitOrderBy.length>0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";(t=new tH(ed.comparator),e.filters.forEach(e=>{e.getFlattenedFilters().forEach(e=>{e.isInequality()&&(t=t.add(e.field))})}),t).forEach(t=>{n.has(t.canonicalString())||t.isKeyField()||e.Ee.push(new nP(t,r))}),n.has(ed.keyField().canonicalString())||e.Ee.push(new nP(ed.keyField(),r))}return e.Ee}function re(e){return e.de||(e.de=rn(e,n7(e))),e.de}function rt(e){return e.Ae||(e.Ae=rn(e,e.explicitOrderBy)),e.Ae}function rn(e,t){if("F"===e.limitType)return nJ(e.path,e.collectionGroup,t,e.filters,e.limit,e.startAt,e.endAt);{t=t.map(e=>{let t="desc"===e.dir?"asc":"desc";return new nP(e.field,t)});let n=e.endAt?new nN(e.endAt.position,e.endAt.inclusive):null,r=e.startAt?new nN(e.startAt.position,e.startAt.inclusive):null;return nJ(e.path,e.collectionGroup,t,e.filters,e.limit,n,r)}}function rr(e,t){let n=e.filters.concat([t]);return new n5(e.path,e.collectionGroup,e.explicitOrderBy.slice(),n,e.limit,e.limitType,e.startAt,e.endAt)}function ri(e,t,n){return new n5(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),t,n,e.startAt,e.endAt)}function rs(e,t){return n0(re(e),re(t))&&e.limitType===t.limitType}function ro(e){return`${nZ(re(e))}|lt:${e.limitType}`}function ra(e){var t;let n;return`Query(target=${n=(t=re(e)).path.canonicalString(),null!==t.collectionGroup&&(n+=" collectionGroup="+t.collectionGroup),t.filters.length>0&&(n+=`, filters: [${t.filters.map(e=>(function e(t){return t instanceof nM?`${t.field.canonicalString()} ${t.op} ${ng(t.value)}`:t instanceof nF?t.op.toString()+" {"+t.getFilters().map(e).join(" ,")+"}":"Filter"})(e)).join(", ")}]`),ez(t.limit)||(n+=", limit: "+t.limit),t.orderBy.length>0&&(n+=`, orderBy: [${t.orderBy.map(e=>`${e.field.canonicalString()} (${e.dir})`).join(", ")}]`),t.startAt&&(n+=", startAt: "+(t.startAt.inclusive?"b:":"a:")+t.startAt.position.map(e=>ng(e)).join(",")),t.endAt&&(n+=", endAt: "+(t.endAt.inclusive?"a:":"b:")+t.endAt.position.map(e=>ng(e)).join(",")),`Target(${n})`}; limitType=${e.limitType})`}function rl(e,t){return t.isFoundDocument()&&function(e,t){let n=t.key.path;return null!==e.collectionGroup?t.key.hasCollectionId(e.collectionGroup)&&e.path.isPrefixOf(n):ef.isDocumentKey(e.path)?e.path.isEqual(n):e.path.isImmediateParentOf(n)}(e,t)&&function(e,t){for(let n of n7(e))if(!n.field.isKeyField()&&null===t.data.field(n.field))return!1;return!0}(e,t)&&function(e,t){for(let n of e.filters)if(!n.matches(t))return!1;return!0}(e,t)&&(!e.startAt||!!function(e,t,n){let r=nO(e,t,n);return e.inclusive?r<=0:r<0}(e.startAt,n7(e),t))&&(!e.endAt||!!function(e,t,n){let r=nO(e,t,n);return e.inclusive?r>=0:r>0}(e.endAt,n7(e),t))}function ru(e){return e.collectionGroup||(e.path.length%2==1?e.path.lastSegment():e.path.get(e.path.length-2))}function rc(e){return(t,n)=>{let r=!1;for(let i of n7(e)){let e=function(e,t,n){let r=e.field.isKeyField()?ef.comparator(t.key,n.key):function(e,t,n){let r=t.data.field(e),i=n.data.field(e);return null!==r&&null!==i?nf(r,i):U(42886)}(e.field,t,n);switch(e.dir){case"asc":return r;case"desc":return -1*r;default:return U(19790,{direction:e.dir})}}(i,t,n);if(0!==e)return e;r=r||i.field.isKeyField()}return 0}}class rh{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.innerSize=0}get(e){let t=this.mapKeyFn(e),n=this.inner[t];if(void 0!==n){for(let[t,r]of n)if(this.equalsFn(t,e))return r}}has(e){return void 0!==this.get(e)}set(e,t){let n=this.mapKeyFn(e),r=this.inner[n];if(void 0===r)return this.inner[n]=[[e,t]],void this.innerSize++;for(let n=0;n<r.length;n++)if(this.equalsFn(r[n][0],e))return void(r[n]=[e,t]);
15r.push([e,t]),this.innerSize++}delete(e){let t=this.mapKeyFn(e),n=this.inner[t];if(void 0===n)return!1;for(let r=0;r<n.length;r++)if(this.equalsFn(n[r][0],e))return 1===n.length?delete this.inner[t]:n.splice(r,1),this.innerSize--,!0;return!1}forEach(e){tB(this.inner,(t,n)=>{for(let[t,r]of n)e(t,r)})}isEmpty(){return tz(this.inner)}size(){return this.innerSize}}let rd=new t$(ef.comparator),rf=new t$(ef.comparator);function rp(...e){let t=rf;for(let n of e)t=t.insert(n.key,n);return t}function rm(e){let t=rf;return e.forEach((e,n)=>t=t.insert(e,n.overlayedDocument)),t}function rg(){return new rh(e=>e.toString(),(e,t)=>e.isEqual(t))}let ry=new t$(ef.comparator),rv=new tH(ef.comparator);function rw(...e){let t=rv;for(let n of e)t=t.add(n);return t}let rb=new tH(en);function r_(e,t){if(e.useProto3Json){if(isNaN(t))return{doubleValue:"NaN"};if(t===1/0)return{doubleValue:"Infinity"};if(t===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:e$(t)?"-0":t}}function rI(e){return{integerValue:""+e}}function rE(e,t){return eK(t)?rI(t):r_(e,t)}class rT{constructor(){this._=void 0}}function rS(e,t){return e instanceof rN?nv(t)||t&&"doubleValue"in t?t:{integerValue:0}:null}class rC extends rT{}class rx extends rT{constructor(e){super(),this.elements=e}}function rk(e,t){let n=rD(t);for(let t of e.elements)n.some(e=>nh(e,t))||n.push(t);return{arrayValue:{values:n}}}class rA extends rT{constructor(e){super(),this.elements=e}}function rR(e,t){let n=rD(t);for(let t of e.elements)n=n.filter(e=>!nh(e,t));return{arrayValue:{values:n}}}class rN extends rT{constructor(e,t){super(),this.serializer=e,this.Re=t}}function rO(e){return t2(e.integerValue||e.doubleValue)}function rD(e){return nw(e)&&e.arrayValue.values?e.arrayValue.values.slice():[]}class rP{constructor(e,t){this.field=e,this.transform=t}}class rL{constructor(e,t){this.version=e,this.transformResults=t}}class rM{constructor(e,t){this.updateTime=e,this.exists=t}static none(){return new rM}static exists(e){return new rM(void 0,e)}static updateTime(e){return new rM(e)}get isNone(){return void 0===this.updateTime&&void 0===this.exists}isEqual(e){return this.exists===e.exists&&(this.updateTime?!!e.updateTime&&this.updateTime.isEqual(e.updateTime):!e.updateTime)}}function rF(e,t){return void 0!==e.updateTime?t.isFoundDocument()&&t.version.isEqual(e.updateTime):void 0===e.exists||e.exists===t.isFoundDocument()}class rU{}function rV(e,t){if(!e.hasLocalMutations||t&&0===t.fields.length)return null;if(null===t)return e.isNoDocument()?new rH(e.key,rM.none()):new rq(e.key,e.data,rM.none());{let n=e.data,r=nA.empty(),i=new tH(ed.comparator);for(let e of t.fields)if(!i.has(e)){let t=n.field(e);null===t&&e.length>1&&(e=e.popLast(),t=n.field(e)),null===t?r.delete(e):r.set(e,t),i=i.add(e)}return new rz(e.key,r,new tX(i.toArray()),rM.none())}}function rj(e,t,n,r){return e instanceof rq?function(e,t,n,r){if(!rF(e.precondition,t))return n;let i=e.value.clone(),s=rG(e.fieldTransforms,r,t);return i.setAll(s),t.convertToFoundDocument(t.version,i).setHasLocalMutations(),null}(e,t,n,r):e instanceof rz?function(e,t,n,r){if(!rF(e.precondition,t))return n;let i=rG(e.fieldTransforms,r,t),s=t.data;return(s.setAll(r$(e)),s.setAll(i),t.convertToFoundDocument(t.version,s).setHasLocalMutations(),null===n)?null:n.unionWith(e.fieldMask.fields).unionWith(e.fieldTransforms.map(e=>e.field))}(e,t,n,r):rF(e.precondition,t)?(t.convertToNoDocument(t.version).setHasLocalMutations(),null):n}function rB(e,t){var n,r;return e.type===t.type&&!!e.key.isEqual(t.key)&&!!e.precondition.isEqual(t.precondition)&&(n=e.fieldTransforms,r=t.fieldTransforms,!!(void 0===n&&void 0===r||!(!n||!r)&&es(n,r,(e,t)=>{var n,r;return e.field.isEqual(t.field)&&(n=e.transform,r=t.transform,n instanceof rx&&r instanceof rx||n instanceof rA&&r instanceof rA?es(n.elements,r.elements,nh):n instanceof rN&&r instanceof rN?nh(n.Re,r.Re):n instanceof rC&&r instanceof rC)}
15)))&&(0===e.type?e.value.isEqual(t.value):1!==e.type||e.data.isEqual(t.data)&&e.fieldMask.isEqual(t.fieldMask))}class rq extends rU{constructor(e,t,n,r=[]){super(),this.key=e,this.value=t,this.precondition=n,this.fieldTransforms=r,this.type=0}getFieldMask(){return null}}class rz extends rU{constructor(e,t,n,r,i=[]){super(),this.key=e,this.data=t,this.fieldMask=n,this.precondition=r,this.fieldTransforms=i,this.type=1}getFieldMask(){return this.fieldMask}}function r$(e){let t=new Map;return e.fieldMask.fields.forEach(n=>{if(!n.isEmpty()){let r=e.data.field(n);t.set(n,r)}}),t}function rK(e,t,n){let r=new Map;j(e.length===n.length,32656,{Ve:n.length,me:e.length});for(let s=0;s<n.length;s++){var i;let o=e[s],a=o.transform,l=t.data.field(o.field);r.set(o.field,(i=n[s],a instanceof rx?rk(a,l):a instanceof rA?rR(a,l):i))}return r}function rG(e,t,n){let r=new Map;for(let i of e){let e=i.transform,s=n.data.field(i.field);r.set(i.field,e instanceof rC?function(e,t){let n={fields:{[t5]:{stringValue:t6},[t3]:{timestampValue:{seconds:e.seconds,nanos:e.nanoseconds}}}};return t&&t8(t)&&(t=t7(t)),t&&(n.fields[t9]=t),{mapValue:n}}(t,s):e instanceof rx?rk(e,s):e instanceof rA?rR(e,s):function(e,t){let n=rS(e,t),r=rO(n)+rO(e.Re);return nv(n)&&nv(e.Re)?rI(r):r_(e.serializer,r)}(e,s))}return r}class rH extends rU{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}class rW extends rU{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}}class rQ{constructor(e,t,n,r){this.batchId=e,this.localWriteTime=t,this.baseMutations=n,this.mutations=r}applyToRemoteDocument(e,t){let n=t.mutationResults;for(let t=0;t<this.mutations.length;t++){let i=this.mutations[t];if(i.key.isEqual(e.key)){var r;r=n[t],i instanceof rq?function(e,t,n){let r=e.value.clone(),i=rK(e.fieldTransforms,t,n.transformResults);r.setAll(i),t.convertToFoundDocument(n.version,r).setHasCommittedMutations()}(i,e,r):i instanceof rz?function(e,t,n){if(!rF(e.precondition,t))return void t.convertToUnknownDocument(n.version);let r=rK(e.fieldTransforms,t,n.transformResults),i=t.data;i.setAll(r$(e)),i.setAll(r),t.convertToFoundDocument(n.version,i).setHasCommittedMutations()}(i,e,r):function(e,t,n){t.convertToNoDocument(n.version).setHasCommittedMutations()}(0,e,r)}}}applyToLocalView(e,t){for(let n of this.baseMutations)n.key.isEqual(e.key)&&(t=rj(n,e,t,this.localWriteTime));for(let n of this.mutations)n.key.isEqual(e.key)&&(t=rj(n,e,t,this.localWriteTime));return t}applyToLocalDocumentSet(e,t){let n=rg();return this.mutations.forEach(r=>{let i=e.get(r.key),s=i.overlayedDocument,o=this.applyToLocalView(s,i.mutatedFields),a=rV(s,o=t.has(r.key)?null:o);null!==a&&n.set(r.key,a),s.isValidDocument()||s.convertToNoDocument(ea.min())}),n}keys(){return this.mutations.reduce((e,t)=>e.add(t.key),rw())}isEqual(e){return this.batchId===e.batchId&&es(this.mutations,e.mutations,(e,t)=>rB(e,t))&&es(this.baseMutations,e.baseMutations,(e,t)=>rB(e,t))}}class rX{constructor(e,t,n,r){this.batch=e,this.commitVersion=t,this.mutationResults=n,this.docVersions=r}static from(e,t,n){j(e.mutations.length===n.length,58842,{fe:e.mutations.length,ge:n.length});let r=ry,i=e.mutations;for(let e=0;e<i.length;e++)r=r.insert(i[e].key,n[e].version);return new rX(e,t,n,r)}}class rY{constructor(e,t){this.largestBatchId=e,this.mutation=t}getKey(){return this.mutation.key}isEqual(e){return null!==e&&this.mutation===e.mutation}toString(){return`Overlay{ 16 largestBatchId: ${this.largestBatchId}, 17 mutation: ${this.mutation.toString()} 18 }`}}class rJ{constructor(e,t,n){this.alias=e,this.aggregateType=t,this.fieldPath=n}}class rZ{constructor(e,t){this.count=e,this.unchangedNames=t}}function r0(e){switch(e){case q.OK:return U(64938);case q.CANCELLED:case q.UNKNOWN:case q.DEADLINE_EXCEEDED:case q.RESOURCE_EXHAUSTED:case q.INTERNAL:case q.UNAVAILABLE:case q.UNAUTHENTICATED:return!1;case q.INVALID_ARGUMENT:case q.NOT_FOUND:case q.ALREADY_EXISTS:case q.PERMISSION_DENIED:case q.FAILED_PRECONDITION:case q.ABORTED:case q.OUT_OF_RANGE:case q.UNIMPLEMENT
18ED:case q.DATA_LOSS:return!0;default:return U(15467,{code:e})}}function r1(e){if(void 0===e)return L("GRPC error has no .code"),q.UNKNOWN;switch(e){case f.OK:return q.OK;case f.CANCELLED:return q.CANCELLED;case f.UNKNOWN:return q.UNKNOWN;case f.DEADLINE_EXCEEDED:return q.DEADLINE_EXCEEDED;case f.RESOURCE_EXHAUSTED:return q.RESOURCE_EXHAUSTED;case f.INTERNAL:return q.INTERNAL;case f.UNAVAILABLE:return q.UNAVAILABLE;case f.UNAUTHENTICATED:return q.UNAUTHENTICATED;case f.INVALID_ARGUMENT:return q.INVALID_ARGUMENT;case f.NOT_FOUND:return q.NOT_FOUND;case f.ALREADY_EXISTS:return q.ALREADY_EXISTS;case f.PERMISSION_DENIED:return q.PERMISSION_DENIED;case f.FAILED_PRECONDITION:return q.FAILED_PRECONDITION;case f.ABORTED:return q.ABORTED;case f.OUT_OF_RANGE:return q.OUT_OF_RANGE;case f.UNIMPLEMENTED:return q.UNIMPLEMENTED;case f.DATA_LOSS:return q.DATA_LOSS;default:return U(39323,{code:e})}}(p=f||(f={}))[p.OK=0]="OK",p[p.CANCELLED=1]="CANCELLED",p[p.UNKNOWN=2]="UNKNOWN",p[p.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",p[p.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",p[p.NOT_FOUND=5]="NOT_FOUND",p[p.ALREADY_EXISTS=6]="ALREADY_EXISTS",p[p.PERMISSION_DENIED=7]="PERMISSION_DENIED",p[p.UNAUTHENTICATED=16]="UNAUTHENTICATED",p[p.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",p[p.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",p[p.ABORTED=10]="ABORTED",p[p.OUT_OF_RANGE=11]="OUT_OF_RANGE",p[p.UNIMPLEMENTED=12]="UNIMPLEMENTED",p[p.INTERNAL=13]="INTERNAL",p[p.UNAVAILABLE=14]="UNAVAILABLE",p[p.DATA_LOSS=15]="DATA_LOSS";let r2=null,r4=new r([4294967295,4294967295],0);function r6(e){let t=ee().encode(e),n=new i;return n.update(t),new Uint8Array(n.digest())}function r5(e){let t=new DataView(e.buffer),n=t.getUint32(0,!0),i=t.getUint32(4,!0),s=t.getUint32(8,!0),o=t.getUint32(12,!0);return[new r([n,i],0),new r([s,o],0)]}class r9{constructor(e,t,n){if(this.bitmap=e,this.padding=t,this.hashCount=n,t<0||t>=8)throw new r3(`Invalid padding: ${t}`);if(n<0||e.length>0&&0===this.hashCount)throw new r3(`Invalid hash count: ${n}`);if(0===e.length&&0!==t)throw new r3(`Invalid padding when bitmap length is 0: ${t}`);this.pe=8*e.length-t,this.ye=r.fromNumber(this.pe)}we(e,t,n){let i=e.add(t.multiply(r.fromNumber(n)));return 1===i.compare(r4)&&(i=new r([i.getBits(0),i.getBits(1)],0)),i.modulo(this.ye).toNumber()}be(e){return!!(this.bitmap[Math.floor(e/8)]&1<<e%8)}mightContain(e){if(0===this.pe)return!1;let[t,n]=r5(r6(e));for(let e=0;e<this.hashCount;e++){let r=this.we(t,n,e);if(!this.be(r))return!1}return!0}static create(e,t,n){let r=new r9(new Uint8Array(Math.ceil(e/8)),e%8==0?0:8-e%8,t);return n.forEach(e=>r.insert(e)),r}insert(e){if(0===this.pe)return;let[t,n]=r5(r6(e));for(let e=0;e<this.hashCount;e++){let r=this.we(t,n,e);this.Se(r)}}Se(e){this.bitmap[Math.floor(e/8)]|=1<<e%8}}class r3 extends Error{constructor(){super(...arguments),this.name="BloomFilterError"}}class r8{constructor(e,t,n,r,i){this.snapshotVersion=e,this.targetChanges=t,this.targetMismatches=n,this.documentUpdates=r,this.resolvedLimboDocuments=i}static createSynthesizedRemoteEventForCurrentChange(e,t,n){let r=new Map;return r.set(e,r7.createSynthesizedTargetChangeForCurrentChange(e,t,n)),new r8(ea.min(),r,new t$(en),rd,rw())}}class r7{constructor(e,t,n,r,i){this.resumeToken=e,this.current=t,this.addedDocuments=n,this.modifiedDocuments=r,this.removedDocuments=i}static createSynthesizedTargetChangeForCurrentChange(e,t,n){return new r7(n,t,rw(),rw(),rw())}}class ie{constructor(e,t,n,r){this.De=e,this.removedTargetIds=t,this.key=n,this.ve=r}}class it{constructor(e,t){this.targetId=e,this.Ce=t}}class ir{constructor(e,t,n=tZ.EMPTY_BYTE_STRING,r=null){this.state=e,this.targetIds=t,this.resumeToken=n,this.cause=r}}class ii{constructor(){this.Fe=0,this.Me=ia(),this.xe=tZ.EMPTY_BYTE_STRING,this.Oe=!1,this.Ne=!0}get current(){return this.Oe}get resumeToken(){return this.xe}get Be(){return 0!==this.Fe}get Le(){return this.Ne}ke(e){e.approximateByteSize()>0&&(this.Ne=!0,this.xe=e)}qe(){let e=rw(),t=rw(),n=rw();return this.Me.forEach((r,i)=>{switch(i){case 0:e=e.add(r);break;case 2:t=t.add(r);break;case 1:n=n.add(r);break;default:U(38017,{changeType:i})}}),new r7(this.xe,this.Oe,e,t,n)}Qe(){this.Ne=!1,this.Me=ia()}$e(e,t){this.Ne=!0,this.Me=this.Me.insert(e,t)}Ue(e){this.Ne=!0,this.Me=this.Me.remove(e)}Ke(){this.Fe+=1}We(){this.Fe-=1,j(this.Fe>=0,3241,{Fe:this.Fe})}Ge(){this.Ne=!0,this.Oe=!0}}class is{constructor(e){this.ze=e,this.je=new Map,this.He=rd,this.Je=io(),this.Ye=io(),this.Ze=new t$(en)}Xe(e){for(let t of e.De)e.ve&&e.ve.isFoundDocument()?this.et(t,e.ve):this.tt(t,e.key,e.ve);for(let t of e.removedTargetIds)this.tt(t,e.key,e.ve)}nt(e){this.forEachTarget(e,t=>{let n=this.rt(t);switch(e.state){case 0:this.it(t)&&n.ke(e.resumeToken);break;case 1:n.We(),n.Be||n.Qe(),n.ke(e.resumeToken);break;case 2:n.We(),n.Be||this.removeTarget(t);break;case 3:this.it(t)&&(n.Ge(),n.ke(e.resumeToken));break;case 4:this.it(t)&&(this.st(t),n.ke(e.resumeToken));break;
18default:U(56790,{state:e.state})}})}forEachTarget(e,t){e.targetIds.length>0?e.targetIds.forEach(t):this.je.forEach((e,n)=>{this.it(n)&&t(n)})}ot(e){let t=e.targetId,n=e.Ce.count,r=this._t(t);if(r){let i=r.target;if(n1(i)){if(0===n){let e=new ef(i.path);this.tt(t,e,nR.newNoDocument(e,ea.min()))}else j(1===n,20013,{expectedCount:n})}else{let r=this.ut(t);if(r!==n){let n=this.ct(e),i=n?this.lt(n,e,r):1;0!==i&&(this.st(t),this.Ze=this.Ze.insert(t,2===i?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch")),null==r2||r2.ht(function(e,t,n,r,i){var s,o,a,l,u,c;let h={localCacheCount:e,existenceFilterCount:t.count,databaseId:n.database,projectId:n.projectId},d=t.unchangedNames;return d&&(h.bloomFilter={applied:0===i,hashCount:null!==(s=null==d?void 0:d.hashCount)&&void 0!==s?s:0,bitmapLength:null!==(l=null===(a=null===(o=null==d?void 0:d.bits)||void 0===o?void 0:o.bitmap)||void 0===a?void 0:a.length)&&void 0!==l?l:0,padding:null!==(c=null===(u=null==d?void 0:d.bits)||void 0===u?void 0:u.padding)&&void 0!==c?c:0,mightContain:e=>{var t;return null!==(t=null==r?void 0:r.mightContain(e))&&void 0!==t&&t}}),h}(r,e.Ce,this.ze.Pt(),n,i))}}}}ct(e){let t,n;let r=e.Ce.unchangedNames;if(!r||!r.bits)return null;let{bits:{bitmap:i="",padding:s=0},hashCount:o=0}=r;try{t=t4(i).toUint8Array()}catch(e){if(e instanceof tY)return M("Decoding the base64 bloom filter in existence filter failed ("+e.message+"); ignoring the bloom filter and falling back to full re-query."),null;throw e}try{n=new r9(t,s,o)}catch(e){return M(e instanceof r3?"BloomFilter error: ":"Applying bloom filter failed: ",e),null}return 0===n.pe?null:n}lt(e,t,n){return t.Ce.count===n-this.Tt(e,t.targetId)?0:2}Tt(e,t){let n=this.ze.getRemoteKeysForTarget(t),r=0;return n.forEach(n=>{let i=this.ze.Pt(),s=`projects/${i.projectId}/databases/${i.database}/documents/${n.path.canonicalString()}`;e.mightContain(s)||(this.tt(t,n,null),r++)}),r}It(e){let t=new Map;this.je.forEach((n,r)=>{let i=this._t(r);if(i){if(n.current&&n1(i.target)){let t=new ef(i.target.path);this.Et(t).has(r)||this.dt(r,t)||this.tt(r,t,nR.newNoDocument(t,e))}n.Le&&(t.set(r,n.qe()),n.Qe())}});let n=rw();this.Ye.forEach((e,t)=>{let r=!0;t.forEachWhile(e=>{let t=this._t(e);return!t||"TargetPurposeLimboResolution"===t.purpose||(r=!1,!1)}),r&&(n=n.add(e))}),this.He.forEach((t,n)=>n.setReadTime(e));let r=new r8(e,t,this.Ze,this.He,n);return this.He=rd,this.Je=io(),this.Ye=io(),this.Ze=new t$(en),r}et(e,t){if(!this.it(e))return;let n=this.dt(e,t.key)?2:0;this.rt(e).$e(t.key,n),this.He=this.He.insert(t.key,t),this.Je=this.Je.insert(t.key,this.Et(t.key).add(e)),this.Ye=this.Ye.insert(t.key,this.At(t.key).add(e))}tt(e,t,n){if(!this.it(e))return;let r=this.rt(e);this.dt(e,t)?r.$e(t,1):r.Ue(t),this.Ye=this.Ye.insert(t,this.At(t).delete(e)),this.Ye=this.Ye.insert(t,this.At(t).add(e)),n&&(this.He=this.He.insert(t,n))}removeTarget(e){this.je.delete(e)}ut(e){let t=this.rt(e).qe();return this.ze.getRemoteKeysForTarget(e).size+t.addedDocuments.size-t.removedDocuments.size}Ke(e){this.rt(e).Ke()}rt(e){let t=this.je.get(e);return t||(t=new ii,this.je.set(e,t)),t}At(e){let t=this.Ye.get(e);return t||(t=new tH(en),this.Ye=this.Ye.insert(e,t)),t}Et(e){let t=this.Je.get(e);return t||(t=new tH(en),this.Je=this.Je.insert(e,t)),t}it(e){let t=null!==this._t(e);return t||P("WatchChangeAggregator","Detected inactive target",e),t}_t(e){let t=this.je.get(e);return t&&t.Be?null:this.ze.Rt(e)}st(e){this.je.set(e,new ii),this.ze.getRemoteKeysForTarget(e).forEach(t=>{this.tt(e,t,null)})}dt(e,t){return this.ze.getRemoteKeysForTarget(e).has(t)}}function io(){return new t$(ef.comparator)}function ia(){return new t$(ef.comparator)}let il={asc:"ASCENDING",desc:"DESCENDING"},iu={"<":"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"},ic={and:"AND",or:"OR"};class ih{constructor(e,t){this.databaseId=e,this.useProto3Json=t}}function id(e,t){return e.useProto3Json||ez(t)?t:{value:t}}function ip(e,t){return e.useProto3Json?`${new Date(1e3*t.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+t.nanoseconds).slice(-9)}Z`:{seconds:""+t.seconds,nanos:t.nanoseconds}}function im(e,t){return e.useProto3Json?t.toBase64():t.toUint8Array()}function ig(e){return j(!!e,49232),ea.fromTimestamp(function(e){let t=t1(e);return new eo(t.seconds,t.nanos)}(e))}function iy(e,t){return iv(e,t).canonicalString()}function iv(e,t){let n=new ec(["projects",e.projectId,"databases",e.database]).child("documents");return void 0===t?n:n.child(t)}function iw(e){let t=ec.fromString(e);return j(iM(t),10190,{key:t.toString()}),t}function ib(e,t){return iy(e.databaseId,t.path)}function i_(e,t){let n=iw(t);if(n.get(1)!==e.databaseId.projectId)throw new z(q.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+n.get(1)+" vs "+e.databaseId.projectId);if(n.get(3)!==e.databaseId.database)throw new z(q.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+n.get(3)+" vs "+e.databaseId.database);return new ef(iS(n))}function iI(e,t){return iy(e.databaseId,t)}function iE(e){let t=iw(e);return 4===t.length?ec.emptyPath():iS(t)}function iT(e){return new ec(["projects",e.databaseId.projectId,"databases",e.databaseId.database]).canonicalString()}function iS(e){return j(e.length>4&&"documents"===e.get(4),29091,{key:e.toString()}),e.popFirst(5)}function iC(e,t,n){return{name:ib(e,t),fields:n.value.mapValue.fields}}function ix(e,t,n){let r=i_(e,t.name),i=ig(t.updateTime),s=t.createTime?ig(t.createTime):ea.min(),o=new nA({mapValue:{fields:t.fields}}),a=nR.newFoundDocument(r,i,s,o);return n&&a.setHasCommittedMutations(),n?a.setHasCommittedMutations():a}function ik(e,t){var n;let r;if(t instanceof rq)r={update:iC(e,t.key,t.value)};
18else if(t instanceof rH)r={delete:ib(e,t.key)};else if(t instanceof rz)r={update:iC(e,t.key,t.data),updateMask:function(e){let t=[];return e.fields.forEach(e=>t.push(e.canonicalString())),{fieldPaths:t}}(t.fieldMask)};else{if(!(t instanceof rW))return U(16599,{ft:t.type});r={verify:ib(e,t.key)}}return t.fieldTransforms.length>0&&(r.updateTransforms=t.fieldTransforms.map(e=>(function(e,t){let n=t.transform;if(n instanceof rC)return{fieldPath:t.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(n instanceof rx)return{fieldPath:t.field.canonicalString(),appendMissingElements:{values:n.elements}};if(n instanceof rA)return{fieldPath:t.field.canonicalString(),removeAllFromArray:{values:n.elements}};if(n instanceof rN)return{fieldPath:t.field.canonicalString(),increment:n.Re};throw U(20930,{transform:t.transform})})(0,e))),t.precondition.isNone||(r.currentDocument=void 0!==(n=t.precondition).updateTime?{updateTime:ip(e,n.updateTime.toTimestamp())}:void 0!==n.exists?{exists:n.exists}:U(27497)),r}function iA(e,t){var n;let r=t.currentDocument?void 0!==(n=t.currentDocument).updateTime?rM.updateTime(ig(n.updateTime)):void 0!==n.exists?rM.exists(n.exists):rM.none():rM.none(),i=t.updateTransforms?t.updateTransforms.map(t=>{let n;return n=null,"setToServerValue"in t?(j("REQUEST_TIME"===t.setToServerValue,16630,{proto:t}),n=new rC):"appendMissingElements"in t?n=new rx(t.appendMissingElements.values||[]):"removeAllFromArray"in t?n=new rA(t.removeAllFromArray.values||[]):"increment"in t?n=new rN(e,t.increment):U(16584,{proto:t}),new rP(ed.fromServerFormat(t.fieldPath),n)}):[];if(t.update){t.update.name;let n=i_(e,t.update.name),s=new nA({mapValue:{fields:t.update.fields}});return t.updateMask?new rz(n,s,new tX((t.updateMask.fieldPaths||[]).map(e=>ed.fromServerFormat(e))),r,i):new rq(n,s,r,i)}return t.delete?new rH(i_(e,t.delete),r):t.verify?new rW(i_(e,t.verify),r):U(1463,{proto:t})}function iR(e,t){return{documents:[iI(e,t.path)]}}function iN(e,t){var n,r;let i;let s={structuredQuery:{}},o=t.path;null!==t.collectionGroup?(i=o,s.structuredQuery.from=[{collectionId:t.collectionGroup,allDescendants:!0}]):(i=o.popLast(),s.structuredQuery.from=[{collectionId:o.lastSegment()}]),s.parent=iI(e,i);let a=function(e){if(0!==e.length)return function e(t){return t instanceof nM?function(e){if("=="===e.op){if(n_(e.value))return{unaryFilter:{field:iP(e.field),op:"IS_NAN"}};if(nb(e.value))return{unaryFilter:{field:iP(e.field),op:"IS_NULL"}}}else if("!="===e.op){if(n_(e.value))return{unaryFilter:{field:iP(e.field),op:"IS_NOT_NAN"}};if(nb(e.value))return{unaryFilter:{field:iP(e.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:iP(e.field),op:iu[e.op],value:e.value}}}(t):t instanceof nF?function(t){let n=t.getFilters().map(t=>e(t));return 1===n.length?n[0]:{compositeFilter:{op:ic[t.op],filters:n}}}(t):U(54877,{filter:t})}(nF.create(e,"and"))}(t.filters);a&&(s.structuredQuery.where=a);let l=function(e){if(0!==e.length)return e.map(e=>({field:iP(e.field),direction:il[e.dir]}))}(t.orderBy);l&&(s.structuredQuery.orderBy=l);let u=id(e,t.limit);return null!==u&&(s.structuredQuery.limit=u),t.startAt&&(s.structuredQuery.startAt={before:(n=t.startAt).inclusive,values:n.position}),t.endAt&&(s.structuredQuery.endAt={before:!(r=t.endAt).inclusive,values:r.position}),{gt:s,parent:i}}function iO(e,t,n,r){let{gt:i,parent:s}=iN(e,t),o={},a=[],l=0;return n.forEach(e=>{let t=r?e.alias:"aggregate_"+l++;o[t]=e.alias,"count"===e.aggregateType?a.push({alias:t,count:{}}):"avg"===e.aggregateType?a.push({alias:t,avg:{field:iP(e.fieldPath)}}):"sum"===e.aggregateType&&a.push({alias:t,sum:{field:iP(e.fieldPath)}})}),{request:{structuredAggregationQuery:{aggregations:a,structuredQuery:i.structuredQuery},parent:i.parent},yt:o,parent:s}}function iD(e){var t;let n,r=iE(e.parent),i=e.structuredQuery,s=i.from?i.from.length:0,o=null;if(s>0){j(1===s,65062);let e=i.from[0];e.allDescendants?o=e.collectionId:r=r.child(e.collectionId)}let a=[];i.where&&(a=function(e){let t=function e(t){return void 0!==t.unaryFilter?function(e){switch(e.unaryFilter.op){case"IS_NAN":let t=iL(e.unaryFilter.field);return nM.create(t,"==",{doubleValue:NaN});case"IS_NULL":let n=iL(e.unaryFilter.field);return nM.create(n,"==",{nullValue:"NULL_VALUE"});
18case"IS_NOT_NAN":let r=iL(e.unaryFilter.field);return nM.create(r,"!=",{doubleValue:NaN});case"IS_NOT_NULL":let i=iL(e.unaryFilter.field);return nM.create(i,"!=",{nullValue:"NULL_VALUE"});case"OPERATOR_UNSPECIFIED":return U(61313);default:return U(60726)}}(t):void 0!==t.fieldFilter?nM.create(iL(t.fieldFilter.field),function(e){switch(e){case"EQUAL":return"==";case"NOT_EQUAL":return"!=";case"GREATER_THAN":return">";case"GREATER_THAN_OR_EQUAL":return">=";case"LESS_THAN":return"<";case"LESS_THAN_OR_EQUAL":return"<=";case"ARRAY_CONTAINS":return"array-contains";case"IN":return"in";case"NOT_IN":return"not-in";case"ARRAY_CONTAINS_ANY":return"array-contains-any";case"OPERATOR_UNSPECIFIED":return U(58110);default:return U(50506)}}(t.fieldFilter.op),t.fieldFilter.value):void 0!==t.compositeFilter?nF.create(t.compositeFilter.filters.map(t=>e(t)),function(e){switch(e){case"AND":return"and";case"OR":return"or";default:return U(1026)}}(t.compositeFilter.op)):U(30097,{filter:t})}(e);return t instanceof nF&&nj(t)?t.getFilters():[t]}(i.where));let l=[];i.orderBy&&(l=i.orderBy.map(e=>new nP(iL(e.field),function(e){switch(e){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(e.direction))));let u=null;i.limit&&(u=ez(n="object"==typeof(t=i.limit)?t.value:t)?null:n);let c=null;i.startAt&&(c=function(e){let t=!!e.before;return new nN(e.values||[],t)}(i.startAt));let h=null;return i.endAt&&(h=function(e){let t=!e.before;return new nN(e.values||[],t)}(i.endAt)),new n5(r,o,l,a,u,"F",c,h)}function iP(e){return{fieldPath:e.canonicalString()}}function iL(e){return ed.fromServerFormat(e.fieldPath)}function iM(e){return e.length>=4&&"projects"===e.get(0)&&"databases"===e.get(2)}class iF{constructor(e,t,n,r,i=ea.min(),s=ea.min(),o=tZ.EMPTY_BYTE_STRING,a=null){this.target=e,this.targetId=t,this.purpose=n,this.sequenceNumber=r,this.snapshotVersion=i,this.lastLimboFreeSnapshotVersion=s,this.resumeToken=o,this.expectedCount=a}withSequenceNumber(e){return new iF(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(e,t){return new iF(this.target,this.targetId,this.purpose,this.sequenceNumber,t,this.lastLimboFreeSnapshotVersion,e,null)}withExpectedCount(e){return new iF(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,e)}withLastLimboFreeSnapshotVersion(e){return new iF(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken,this.expectedCount)}}class iU{constructor(e){this.wt=e}}function iV(e,t){let n=t.key,r={prefixPath:n.getCollectionPath().popLast().toArray(),collectionGroup:n.collectionGroup,documentId:n.path.lastSegment(),readTime:ij(t.readTime),hasCommittedMutations:t.hasCommittedMutations};if(t.isFoundDocument()){var i;r.document={name:ib(i=e.wt,t.key),fields:t.data.value.mapValue.fields,updateTime:ip(i,t.version.toTimestamp()),createTime:ip(i,t.createTime.toTimestamp())}}else if(t.isNoDocument())r.noDocument={path:n.path.toArray(),readTime:iB(t.version)};else{if(!t.isUnknownDocument())return U(57904,{document:t});r.unknownDocument={path:n.path.toArray(),version:iB(t.version)}}return r}function ij(e){let t=e.toTimestamp();return[t.seconds,t.nanoseconds]}function iB(e){let t=e.toTimestamp();return{seconds:t.seconds,nanoseconds:t.nanoseconds}}function iq(e){let t=new eo(e.seconds,e.nanoseconds);return ea.fromTimestamp(t)}function iz(e,t){let n=(t.baseMutations||[]).map(t=>iA(e.wt,t));for(let e=0;e<t.mutations.length-1;++e){let n=t.mutations[e];if(e+1<t.mutations.length&&void 0!==t.mutations[e+1].transform){let r=t.mutations[e+1];n.updateTransforms=r.transform.fieldTransforms,t.mutations.splice(e+1,1),++e}}let r=t.mutations.map(t=>iA(e.wt,t)),i=eo.fromMillis(t.localWriteTimeMs);return new rQ(t.batchId,i,n,r)}function i$(e){let t=iq(e.readTime),n=void 0!==e.lastLimboFreeSnapshotVersion?iq(e.lastLimboFreeSnapshotVersion):ea.min();return new iF(void 0!==e.query.documents?function(e){let t=e.documents.length;return j(1===t,1966,{count:t}),re(n9(iE(e.documents[0])))}(e.query):re(iD(e.query)),e.targetId,"TargetPurposeListen",e.lastListenSequenceNumber,t,n,tZ.fromBase64String(e.resumeToken))}function iK(e,t){let n;let r=iB(t.snapshotVersion),i=iB(t.lastLimboFreeSnapshotVersion);n=n1(t.target)?iR(e.wt,t.target):iN(e.wt,t.target).gt;let s=t.resumeToken.toBase64();return{targetId:t.targetId,canonicalId:nZ(t.target),readTime:r,resumeToken:s,lastListenSequenceNumber:t.sequenceNumber,lastLimboFreeSnapshotVersion:i,query:n}}function iG(e){let t=iD({parent:e.parent,structuredQuery:e.structuredQuery});return"LAST"===e.limitType?ri(t,t.limit,"L"):t}function iH(e,t){return new rY(t.largestBatchId,iA(e.wt,t.overlayMutation))}function iW(e,t){let n=t.path.lastSegment();return[e,eG(t.path.popLast()),n]}function iQ(e,t,n,r){return{indexId:e,uid:t,sequenceNumber:n,readTime:iB(r.readTime),documentKey:eG(r.documentKey.path),largestBatchId:r.largestBatchId}}class iX{getBundleMetadata(e,t){return tV(e,tp).get(t).next(e=>{if(e)return{id:e.bundleId,createTime:iq(e.createTime),version:e.version}})}saveBundleMetadata(e,t){return tV(e,tp).put({bundleId:t.id,createTime:iB(ig(t.createTime)),version:t.version})}getNamedQuery(e,t){return tV(e,tm).get(t).next(e=>{if(e)return{name:e.name,query:iG(e.bundledQuery),readTime:iq(e.readTime)}})}saveNamedQuery(e,t){return tV(e,tm).put({name:t.name,readTime:iB(ig(t.readTime)),bundledQuery:t.bundledQuery})}}
18class iY{constructor(e,t){this.serializer=e,this.userId=t}static bt(e,t){return new iY(e,t.uid||"")}getOverlay(e,t){return tV(e,tC).get(iW(this.userId,t)).next(e=>e?iH(this.serializer,e):null)}getOverlays(e,t){let n=rg();return ex.forEach(t,t=>this.getOverlay(e,t).next(e=>{null!==e&&n.set(t,e)})).next(()=>n)}saveOverlays(e,t,n){let r=[];return n.forEach((n,i)=>{let s=new rY(t,i);r.push(this.St(e,s))}),ex.waitFor(r)}removeOverlaysForBatchId(e,t,n){let r=new Set;t.forEach(e=>r.add(eG(e.getCollectionPath())));let i=[];return r.forEach(t=>{let r=IDBKeyRange.bound([this.userId,t,n],[this.userId,t,n+1],!1,!0);i.push(tV(e,tC).X(tk,r))}),ex.waitFor(i)}getOverlaysForCollection(e,t,n){let r=rg(),i=eG(t),s=IDBKeyRange.bound([this.userId,i,n],[this.userId,i,Number.POSITIVE_INFINITY],!0);return tV(e,tC).J(tk,s).next(e=>{for(let t of e){let e=iH(this.serializer,t);r.set(e.getKey(),e)}return r})}getOverlaysForCollectionGroup(e,t,n,r){let i;let s=rg(),o=IDBKeyRange.bound([this.userId,t,n],[this.userId,t,Number.POSITIVE_INFINITY],!0);return tV(e,tC).te({index:tR,range:o},(e,t,n)=>{let o=iH(this.serializer,t);s.size()<r||o.largestBatchId===i?(s.set(o.getKey(),o),i=o.largestBatchId):n.done()}).next(()=>s)}St(e,t){return tV(e,tC).put(function(e,t,n){let[r,i,s]=iW(t,n.mutation.key);return{userId:t,collectionPath:i,documentId:s,collectionGroup:n.mutation.key.getCollectionGroup(),largestBatchId:n.largestBatchId,overlayMutation:ik(e.wt,n.mutation)}}(this.serializer,this.userId,t))}}class iJ{Dt(e){return tV(e,tO)}getSessionToken(e){return this.Dt(e).get("sessionToken").next(e=>{let t=null==e?void 0:e.value;return t?tZ.fromUint8Array(t):tZ.EMPTY_BYTE_STRING})}setSessionToken(e,t){return this.Dt(e).put({name:"sessionToken",value:t.toUint8Array()})}}class iZ{constructor(){}vt(e,t){this.Ct(e,t),t.Ft()}Ct(e,t){if("nullValue"in e)this.Mt(t,5);else if("booleanValue"in e)this.Mt(t,10),t.xt(e.booleanValue?1:0);else if("integerValue"in e)this.Mt(t,15),t.xt(t2(e.integerValue));else if("doubleValue"in e){let n=t2(e.doubleValue);isNaN(n)?this.Mt(t,13):(this.Mt(t,15),e$(n)?t.xt(0):t.xt(n))}else if("timestampValue"in e){let n=e.timestampValue;this.Mt(t,20),"string"==typeof n&&(n=t1(n)),t.Ot(`${n.seconds||""}`),t.xt(n.nanos||0)}else if("stringValue"in e)this.Nt(e.stringValue,t),this.Bt(t);else if("bytesValue"in e)this.Mt(t,30),t.Lt(t4(e.bytesValue)),this.Bt(t);else if("referenceValue"in e)this.kt(e.referenceValue,t);else if("geoPointValue"in e){let n=e.geoPointValue;this.Mt(t,45),t.xt(n.latitude||0),t.xt(n.longitude||0)}else"mapValue"in e?nS(e)?this.Mt(t,Number.MAX_SAFE_INTEGER):nE(e)?this.qt(e.mapValue,t):(this.Qt(e.mapValue,t),this.Bt(t)):"arrayValue"in e?(this.$t(e.arrayValue,t),this.Bt(t)):U(19022,{Ut:e})}Nt(e,t){this.Mt(t,25),this.Kt(e,t)}Kt(e,t){t.Ot(e)}Qt(e,t){let n=e.fields||{};for(let e of(this.Mt(t,55),Object.keys(n)))this.Nt(e,t),this.Ct(n[e],t)}qt(e,t){var n,r;let i=e.fields||{};this.Mt(t,53);let s=(null===(r=null===(n=i[nl].arrayValue)||void 0===n?void 0:n.values)||void 0===r?void 0:r.length)||0;this.Mt(t,15),t.xt(t2(s)),this.Nt(nl,t),this.Ct(i[nl],t)}$t(e,t){let n=e.values||[];for(let e of(this.Mt(t,50),n))this.Ct(e,t)}kt(e,t){this.Mt(t,37),ef.fromName(e).path.forEach(e=>{this.Mt(t,60),this.Kt(e,t)})}Mt(e,t){e.xt(t)}Bt(e){e.xt(2)}}function i0(e){return Math.ceil((64-function(e){let t=0;for(let n=0;n<8;++n){let r=function(e){if(0===e)return 8;let t=0;return e>>4||(t+=4,e<<=4),e>>6||(t+=2,e<<=2),e>>7||(t+=1),t}(255&e[n]);if(t+=r,8!==r)break}return t}(e))/8)}iZ.Wt=new iZ;class i1{constructor(){this.buffer=new Uint8Array(1024),this.position=0}Gt(e){let t=e[Symbol.iterator](),n=t.next();for(;!n.done;)this.zt(n.value),n=t.next();this.jt()}Ht(e){let t=e[Symbol.iterator](),n=t.next();for(;!n.done;)this.Jt(n.value),n=t.next();this.Yt()}Zt(e){for(let t of e){let e=t.charCodeAt(0);if(e<128)this.zt(e);else if(e<2048)this.zt(960|e>>>6),this.zt(128|63&e);else if(t<"\ud800"||"\udbff"<t)this.zt(480|e>>>12),this.zt(128|63&e>>>6),this.zt(128|63&e);else{let e=t.codePointAt(0);this.zt(240|e>>>18),this.zt(128|63&e>>>12),this.zt(128|63&e>>>6),this.zt(128|63&e)}}this.jt()}Xt(e){for(let t of e){let e=t.charCodeAt(0);if(e<128)this.Jt(e);else if(e<2048)this.Jt(960|e>>>6),this.Jt(128|63&e);else if(t<"\ud800"||"\udbff"<t)this.Jt(480|e>>>12),this.Jt(128|63&e>>>6),this.Jt(128|63&e);else{let e=t.codePointAt(0);this.Jt(240|e>>>18),this.Jt(128|63&e>>>12),this.Jt(128|63&e>>>6),this.Jt(128|63&e)}}this.Yt()}en(e){let t=this.tn(e),n=i0(t);this.nn(1+n),this.buffer[this.position++]=255&n;for(let e=t.length-n;e<t.length;++e)this.buffer[this.position++]=255&t[e]}rn(e){let t=this.tn(e),n=i0(t);this.nn(1+n),this.buffer[this.position++]=~(255&n);for(let e=t.length-n;e<t.length;++e)this.buffer[this.position++]=~(255&t[e])}sn(){this._n(255),this._n(255)}an(){this.un(255),this.un(255)}reset(){this.position=0}seed(e){this.nn(e.length),this.buffer.set(e,this.position),this.position+=e.length}cn(){return this.buffer.slice(0,this.position)}tn(e){let t=function(e){let t=new DataView(new ArrayBuffer(8));return t.setFloat64(0,e,!1),new Uint8Array(t.buffer)}(e),n=!!(128&t[0]);t[0]^=n?255:128;for(let e=1;e<t.length;++e)t[e]^=n?255:0;return t}zt(e){let t=255&e;0===t?(this._n(0),this._n(255)):255===t?(this._n(255),this._n(0)):this._n(t)}Jt(e){let t=255&e;0===t?(this.un(0),this.un(255)):255===t?(this.un(255),this.un(0)):this.un(e)}jt(){this._n(0),this._n(1)}Yt(){this.un(0),this.un(1)}_n(e){this.nn(1),this.buffer[this.position++]=e}un(e){this.nn(1),this.buffer[this.position++]=~e}nn(e){let t=e+this.position;if(t<=this.buffer.length)return;let n=2*this.buffer.length;n<t&&(n=t);let r=new Uint8Array(n);r.set(this.buffer),this.buffer=r}}class i2{constructor(e){this.ln=e}Lt(e){this.ln.Gt(e)}Ot(e){this.ln.Zt(e)}xt(e){this.ln.en(e)}Ft(){this.ln.sn()}}class i4{constructor(e){this.ln=e}Lt(e){this.ln.Ht(e)}Ot(e){this.ln.Xt(e)}xt(e){this.ln.rn(e)}Ft(){this.ln.an()}}class i6{constructor(){this.ln=new i1,this.hn=new i2(this.ln),this.Pn=new i4(this.ln)}seed(e){this.ln.seed(e)}Tn(e){return 0===e?this.hn:this.Pn}cn(){return this.ln.cn()}reset(){this.ln.reset()}}class i5{constructor(e,t,n,r){this.In=e,this.En=t,this.dn=n,this.An=r}Rn(){let e=this.An.length,t=0===e||255===this.An[e-1]?e+1:e,n=new Uint8Array(t);return n.set(this.An,0),t!==e?n.set([0],this.An.length):++n[n.length-1],new i5(this.In,this.En,this.dn,n)}Vn(e,t,n){return{indexId:this.In,uid:e,arrayValue:i8(this.dn),directionalValue:i8(this.An),orderedDocumentKey:i8(t),documentKey:n.path.toArray()}}mn(e,t,n){let r=this.Vn(e,t,n);return[r.indexId,r.uid,r.arrayValue,r.directionalValue,r.orderedDocumentKey,r.documentKey]}}function i9(e,t){let n=e.In-t.In;return 0!==n?n:0!==(n=i3(e.dn,t.dn))?n:0!==(n=i3(e.An,t.An))?n:ef.comparator(e.En,t.En)}function i3(e,t){for(let n=0;n<e.length&&n<t.length;++n){let r=e[n]-t[n];if(0!==r)return r}return e.length-t.length}function i8(e){return(0,b.WO)()?function(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return t}(e):e}function i7(e){return"string"!=typeof e?e:function(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}(e)}class se{constructor(e){for(let t of(this.fn=new tH((e,t)=>ed.comparator(e.field,t.field)),this.collectionId=null!=e.collectionGroup?e.collectionGroup:e.path.lastSegment(),this.gn=e.orderBy,this.pn=[],e.filters))t.isInequality()?this.fn=this.fn.add(t):this.pn.push(t)}get yn(){return this.fn.size>1}wn(e){if(j(e.collectionGroup===this.collectionId,49279),this.yn)return!1;let t=em(e);
18if(void 0!==t&&!this.bn(t))return!1;let n=eg(e),r=new Set,i=0,s=0;for(;i<n.length&&this.bn(n[i]);++i)r=r.add(n[i].fieldPath.canonicalString());if(i===n.length)return!0;if(this.fn.size>0){let e=this.fn.getIterator().getNext();if(!r.has(e.field.canonicalString())){let t=n[i];if(!this.Sn(e,t)||!this.Dn(this.gn[s++],t))return!1}++i}for(;i<n.length;++i){let e=n[i];if(s>=this.gn.length||!this.Dn(this.gn[s++],e))return!1}return!0}vn(){if(this.yn)return null;let e=new tH(ed.comparator),t=[];for(let n of this.pn)if(!n.field.isKeyField()){if("array-contains"===n.op||"array-contains-any"===n.op)t.push(new ev(n.field,2));else{if(e.has(n.field))continue;e=e.add(n.field),t.push(new ev(n.field,0))}}for(let n of this.gn)n.field.isKeyField()||e.has(n.field)||(e=e.add(n.field),t.push(new ev(n.field,"asc"===n.dir?0:1)));return new ep(ep.UNKNOWN_ID,this.collectionId,t,ew.empty())}bn(e){for(let t of this.pn)if(this.Sn(t,e))return!0;return!1}Sn(e,t){if(void 0===e||!e.field.isEqual(t.fieldPath))return!1;let n="array-contains"===e.op||"array-contains-any"===e.op;return 2===t.kind===n}Dn(e,t){return!!e.field.isEqual(t.fieldPath)&&(0===t.kind&&"asc"===e.dir||1===t.kind&&"desc"===e.dir)}}function st(e){return e instanceof nM}function sn(e){return e instanceof nF&&nj(e)}function sr(e){return st(e)||sn(e)||function(e){if(e instanceof nF&&nV(e)){for(let t of e.getFilters())if(!st(t)&&!sn(t))return!1;return!0}return!1}(e)}function si(e,t){return j(e instanceof nM||e instanceof nF,38388),j(t instanceof nM||t instanceof nF,25473),so(e instanceof nM?t instanceof nM?nF.create([e,t],"and"):ss(e,t):t instanceof nM?ss(t,e):function(e,t){if(j(e.filters.length>0&&t.filters.length>0,48005),nU(e)&&nU(t))return nq(e,t.getFilters());let n=nV(e)?e:t,r=nV(e)?t:e,i=n.filters.map(e=>si(e,r));return nF.create(i,"or")}(e,t))}function ss(e,t){if(nU(t))return nq(t,e.getFilters());{let n=t.filters.map(t=>si(e,t));return nF.create(n,"or")}}function so(e){if(j(e instanceof nM||e instanceof nF,11850),e instanceof nM)return e;let t=e.getFilters();if(1===t.length)return so(t[0]);if(nB(e))return e;let n=t.map(e=>so(e)),r=[];return n.forEach(t=>{t instanceof nM?r.push(t):t instanceof nF&&(t.op===e.op?r.push(...t.filters):r.push(t))}),1===r.length?r[0]:nF.create(r,e.op)}class sa{constructor(){this.Cn=new sl}addToCollectionParentIndex(e,t){return this.Cn.add(t),ex.resolve()}getCollectionParents(e,t){return ex.resolve(this.Cn.getEntries(t))}addFieldIndex(e,t){return ex.resolve()}deleteFieldIndex(e,t){return ex.resolve()}deleteAllFieldIndexes(e){return ex.resolve()}createTargetIndexes(e,t){return ex.resolve()}getDocumentsMatchingTarget(e,t){return ex.resolve(null)}getIndexType(e,t){return ex.resolve(0)}getFieldIndexes(e,t){return ex.resolve([])}getNextCollectionGroupToUpdate(e){return ex.resolve(null)}getMinOffset(e,t){return ex.resolve(eI.min())}getMinOffsetFromCollectionGroup(e,t){return ex.resolve(eI.min())}updateCollectionGroup(e,t,n){return ex.resolve()}updateIndexEntries(e,t){return ex.resolve()}}class sl{constructor(){this.index={}}add(e){let t=e.lastSegment(),n=e.popLast(),r=this.index[t]||new tH(ec.comparator),i=!r.has(n);return this.index[t]=r.add(n),i}has(e){let t=e.lastSegment(),n=e.popLast(),r=this.index[t];return r&&r.has(n)}getEntries(e){return(this.index[e]||new tH(ec.comparator)).toArray()}}let su="IndexedDbIndexManager",sc=new Uint8Array(0);class sh{constructor(e,t){this.databaseId=t,this.Fn=new sl,this.Mn=new rh(e=>nZ(e),(e,t)=>n0(e,t)),this.uid=e.uid||""}addToCollectionParentIndex(e,t){if(!this.Fn.has(t)){let n=t.lastSegment(),r=t.popLast();e.addOnCommittedListener(()=>{this.Fn.add(t)});let i={collectionId:n,parent:eG(r)};return tV(e,th).put(i)}return ex.resolve()}getCollectionParents(e,t){let n=[],r=IDBKeyRange.bound([t,""],[t+"\0",""],!1,!0);return tV(e,th).J(r).next(e=>{for(let r of e){if(r.collectionId!==t)break;n.push(eH(r.parent))}return n})}addFieldIndex(e,t){let n=tV(e,tg),r={indexId:t.indexId,collectionGroup:t.collectionGroup,fields:t.fields.map(e=>[e.fieldPath.canonicalString(),e.kind])};delete r.indexId;let i=n.add(r);if(t.indexState){let n=tV(e,tv);return i.next(e=>{n.put(iQ(e,this.uid,t.indexState.sequenceNumber,t.indexState.offset))})}return i.next()}deleteFieldIndex(e,t){let n=tV(e,tg),r=tV(e,tv),i=tV(e,tI);return n.delete(t.indexId).next(()=>r.delete(IDBKeyRange.bound([t.indexId],[t.indexId+1],!1,!0))).next(()=>i.delete(IDBKeyRange.bound([t.indexId],[t.indexId+1],!1,!0)))}deleteAllFieldIndexes(e){let t=tV(e,tg),n=tV(e,tI),r=tV(e,tv);return t.X().next(()=>n.X()).next(()=>r.X())}createTargetIndexes(e,t){return ex.forEach(this.xn(t),t=>this.getIndexType(e,t).next(n=>{if(0===n||1===n){let n=new se(t).vn();if(null!=n)return this.addFieldIndex(e,n)}}))}getDocumentsMatchingTarget(e,t){let n=tV(e,tI),r=!0,i=new Map;return ex.forEach(this.xn(t),t=>this.On(e,t).next(e=>{r&&(r=!!e),i.set(t,e)})).next(()=>{if(r){let e=rw(),r=[];return ex.forEach(i,(i,s)=>{P(su,`Using index id=${i.indexId}|cg=${i.collectionGroup}|f=${i.fields.map(e=>`${e.fieldPath}:${e.kind}`).join(",")} to execute ${nZ(t)}`);let o=function(e,t){let n=em(t);if(void 0===n)return null;for(let t of n2(e,n.fieldPath))switch(t.op){case"array-contains-any":return t.value.arrayValue.values||[];case"array-contains":return[t.value]}return null}(s,i),a=function(e,t){let n=new Map;for(let r of eg(t))for(let t of n2(e,r.fieldPath))switch(t.op){case"==":case"in":n.set(r.fieldPath.canonicalString(),t.value);break;case"not-in":case"!=":return n.set(r.fieldPath.canonicalString(),t.value),Array.from(n.values())}return null}(s,i),l=function(e,t){let n=[],r=!0;for(let i of eg(t)){let t=0===i.kind?n4(e,i.fieldPath,e.startAt):n6(e,i.fieldPath,e.startAt);n.push(t.value),r&&(r=t.inclusive)}return new nN(n,r)}(s,i),u=function(e,t){let n=[],r=!0;for(let i of eg(t)){let t=0===i.kind?n6(e,i.fieldPath,e.endAt):n4(e,i.fieldPath,e.endAt);n.push(t.value),r&&(r=t.inclusive)}return new nN(n,r)}(s,i),c=this.Nn(i,s,l),h=this.Nn(i,s,u),d=this.Bn(i,s,a),f=this.Ln(i.indexId,o,c,l.inclusive,h,u.inclusive,d);return ex.forEach(f,i=>n.Z(i,t.limit).next(t=>{t.forEach(t=>{let n=ef.fromSegments(t.documentKey);e.has(n)||(e=e.add(n),r.push(n))})}))}).next(()=>r)}return ex.resolve(null)})}xn(e){let t=this.Mn.get(e);return t||(t=0===e.filters.length?[e]:(function(e){if(0===e.getFilters().length)return[];let t=function e(t){if(j(t instanceof nM||t instanceof nF,34018),t instanceof nM)return t;if(1===t.filters.length)return e(t.filters[0]);let n=t.filters.map(t=>e(t)),r=nF.create(n,t.op);return sr(r=so(r))?r:(j(r instanceof nF,64498),j(nU(r),40251),j(r.filters.length>1,57927),r.filters.reduce((e,t)=>
18si(e,t)))}(function e(t){var n,r;if(j(t instanceof nM||t instanceof nF,20012),t instanceof nM){if(t instanceof nW){let e=(null===(r=null===(n=t.value.arrayValue)||void 0===n?void 0:n.values)||void 0===r?void 0:r.map(e=>nM.create(t.field,"==",e)))||[];return nF.create(e,"or")}return t}let i=t.filters.map(t=>e(t));return nF.create(i,t.op)}(e));return j(sr(t),7391),st(t)||sn(t)?[t]:t.getFilters()})(nF.create(e.filters,"and")).map(t=>nJ(e.path,e.collectionGroup,e.orderBy,t.getFilters(),e.limit,e.startAt,e.endAt)),this.Mn.set(e,t)),t}Ln(e,t,n,r,i,s,o){let a=(null!=t?t.length:1)*Math.max(n.length,i.length),l=a/(null!=t?t.length:1),u=[];for(let c=0;c<a;++c){let a=t?this.kn(t[c/l]):sc,h=this.qn(e,a,n[c%l],r),d=this.Qn(e,a,i[c%l],s),f=o.map(t=>this.qn(e,a,t,!0));u.push(...this.createRange(h,d,f))}return u}qn(e,t,n,r){let i=new i5(e,ef.empty(),t,n);return r?i:i.Rn()}Qn(e,t,n,r){let i=new i5(e,ef.empty(),t,n);return r?i.Rn():i}On(e,t){let n=new se(t),r=null!=t.collectionGroup?t.collectionGroup:t.path.lastSegment();return this.getFieldIndexes(e,r).next(e=>{let t=null;for(let r of e)n.wn(r)&&(!t||r.fields.length>t.fields.length)&&(t=r);return t})}getIndexType(e,t){let n=2,r=this.xn(t);return ex.forEach(r,t=>this.On(e,t).next(e=>{e?0!==n&&e.fields.length<function(e){let t=new tH(ed.comparator),n=!1;for(let r of e.filters)for(let e of r.getFlattenedFilters())e.field.isKeyField()||("array-contains"===e.op||"array-contains-any"===e.op?n=!0:t=t.add(e.field));for(let n of e.orderBy)n.field.isKeyField()||(t=t.add(n.field));return t.size+(n?1:0)}(t)&&(n=1):n=0})).next(()=>null!==t.limit&&r.length>1&&2===n?1:n)}$n(e,t){let n=new i6;for(let r of eg(e)){let e=t.data.field(r.fieldPath);if(null==e)return null;let i=n.Tn(r.kind);iZ.Wt.vt(e,i)}return n.cn()}kn(e){let t=new i6;return iZ.Wt.vt(e,t.Tn(0)),t.cn()}Un(e,t){let n=new i6;return iZ.Wt.vt(ny(this.databaseId,t),n.Tn(function(e){let t=eg(e);return 0===t.length?0:t[t.length-1].kind}(e))),n.cn()}Bn(e,t,n){if(null===n)return[];let r=[];r.push(new i6);let i=0;for(let s of eg(e)){let e=n[i++];for(let n of r)if(this.Kn(t,s.fieldPath)&&nw(e))r=this.Wn(r,s,e);else{let t=n.Tn(s.kind);iZ.Wt.vt(e,t)}}return this.Gn(r)}Nn(e,t,n){return this.Bn(e,t,n.position)}Gn(e){let t=[];for(let n=0;n<e.length;++n)t[n]=e[n].cn();return t}Wn(e,t,n){let r=[...e],i=[];for(let e of n.arrayValue.values||[])for(let n of r){let r=new i6;r.seed(n.cn()),iZ.Wt.vt(e,r.Tn(t.kind)),i.push(r)}return i}Kn(e,t){return!!e.filters.find(e=>e instanceof nM&&e.field.isEqual(t)&&("in"===e.op||"not-in"===e.op))}getFieldIndexes(e,t){let n=tV(e,tg),r=tV(e,tv);return(t?n.J(ty,IDBKeyRange.bound(t,t)):n.J()).next(e=>{let t=[];return ex.forEach(e,e=>r.get([e.indexId,this.uid]).next(n=>{t.push(function(e,t){let n=t?new ew(t.sequenceNumber,new eI(iq(t.readTime),new ef(eH(t.documentKey)),t.largestBatchId)):ew.empty(),r=e.fields.map(([e,t])=>new ev(ed.fromServerFormat(e),t));return new ep(e.indexId,e.collectionGroup,r,n)}(e,n))})).next(()=>t)})}getNextCollectionGroupToUpdate(e){return this.getFieldIndexes(e).next(e=>0===e.length?null:(e.sort((e,t)=>{let n=e.indexState.sequenceNumber-t.indexState.sequenceNumber;return 0!==n?n:en(e.collectionGroup,t.collectionGroup)}),e[0].collectionGroup))}updateCollectionGroup(e,t,n){let r=tV(e,tg),i=tV(e,tv);return this.zn(e).next(e=>r.J(ty,IDBKeyRange.bound(t,t)).next(t=>ex.forEach(t,t=>i.put(iQ(t.indexId,this.uid,e,n)))))}updateIndexEntries(e,t){let n=new Map;return ex.forEach(t,(t,r)=>{let i=n.get(t.collectionGroup);return(i?ex.resolve(i):this.getFieldIndexes(e,t.collectionGroup)).next(i=>(n.set(t.collectionGroup,i),ex.forEach(i,n=>this.jn(e,t,n).next(t=>{let i=this.Hn(r,n);return t.isEqual(i)?ex.resolve():this.Jn(e,r,n,t,i)}))))})}Yn(e,t,n,r){return tV(e,tI).put(r.Vn(this.uid,this.Un(n,t.key),t.key))}Zn(e,t,n,r){return tV(e,tI).delete(r.mn(this.uid,this.Un(n,t.key),t.key))}jn(e,t,n){let r=tV(e,tI),i=new tH(i9);return r.te({index:tT,range:IDBKeyRange.only([n.indexId,this.uid,i8(this.Un(n,t))])},(e,r)=>{i=i.add(new i5(n.indexId,t,i7(r.arrayValue),i7(r.directionalValue)))}).next(()=>i)}Hn(e,t){let n=new tH(i9),r=this.$n(t,e);if(null==r)return n;let i=em(t);if(null!=i){let s=e.data.field(i.fieldPath);if(nw(s))for(let i of s.arrayValue.values||[])n=n.add(new i5(t.indexId,e.key,this.kn(i),r))}else n=n.add(new i5(t.indexId,e.key,sc,r));return n}Jn(e,t,n,r,i){P(su,"Updating index entries for document '%s'",t.key);let s=[];return function(e,t,n,r,i){let s=e.getIterator(),o=t.getIterator(),a=tQ(s),l=tQ(o);for(;a||l;){let e=!1,t=!1;if(a&&l){let r=n(a,l);r<0?t=!0:r>0&&(e=!0)}else null!=a?t=!0:e=!0;e?(r(l),l=tQ(o)):t?(i(a),a=tQ(s)):(a=tQ(s),l=tQ(o))}}(r,i,i9,r=>{s.push(this.Yn(e,t,n,r))},r=>{s.push(this.Zn(e,t,n,r))}),ex.waitFor(s)}zn(e){let t=1;return tV(e,tv).te({index:tb,reverse:!0,range:IDBKeyRange.upperBound([this.uid,Number.MAX_SAFE_INTEGER])},(e,n,r)=>{r.done(),t=n.sequenceNumber+1}
18).next(()=>t)}createRange(e,t,n){n=n.sort((e,t)=>i9(e,t)).filter((e,t,n)=>!t||0!==i9(e,n[t-1]));let r=[];for(let i of(r.push(e),n)){let n=i9(i,e),s=i9(i,t);if(0===n)r[0]=e.Rn();else if(n>0&&s<0)r.push(i),r.push(i.Rn());else if(s>0)break}r.push(t);let i=[];for(let e=0;e<r.length;e+=2){if(this.Xn(r[e],r[e+1]))return[];let t=r[e].mn(this.uid,sc,ef.empty()),n=r[e+1].mn(this.uid,sc,ef.empty());i.push(IDBKeyRange.bound(t,n))}return i}Xn(e,t){return i9(e,t)>0}getMinOffsetFromCollectionGroup(e,t){return this.getFieldIndexes(e,t).next(sd)}getMinOffset(e,t){return ex.mapArray(this.xn(t),t=>this.On(e,t).next(e=>e||U(44426))).next(sd)}}function sd(e){j(0!==e.length,28825);let t=e[0].indexState.offset,n=t.largestBatchId;for(let r=1;r<e.length;r++){let i=e[r].indexState.offset;0>eE(i,t)&&(t=i),n<i.largestBatchId&&(n=i.largestBatchId)}return new eI(t.readTime,t.documentKey,n)}let sf={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0};class sp{static withCacheSize(e){return new sp(e,sp.DEFAULT_COLLECTION_PERCENTILE,sp.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}constructor(e,t,n){this.cacheSizeCollectionThreshold=e,this.percentileToCollect=t,this.maximumSequenceNumbersToCollect=n}}function sm(e,t,n){let r=e.store(eJ),i=e.store(e4),s=[],o=IDBKeyRange.only(n.batchId),a=0,l=r.te({range:o},(e,t,n)=>(a++,n.delete()));s.push(l.next(()=>{j(1===a,47070,{batchId:n.batchId})}));let u=[];for(let e of n.mutations){var c,h;let r=(c=e.key.path,h=n.batchId,[t,eG(c),h]);s.push(i.delete(r)),u.push(e.key)}return ex.waitFor(s).next(()=>u)}function sg(e){let t;if(!e)return 0;if(e.document)t=e.document;else if(e.unknownDocument)t=e.unknownDocument;else{if(!e.noDocument)throw U(14731);t=e.noDocument}return JSON.stringify(t).length}sp.DEFAULT_COLLECTION_PERCENTILE=10,sp.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,sp.DEFAULT=new sp(41943040,sp.DEFAULT_COLLECTION_PERCENTILE,sp.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),sp.DISABLED=new sp(-1,0,0);class sy{constructor(e,t,n,r){this.userId=e,this.serializer=t,this.indexManager=n,this.referenceDelegate=r,this.er={}}static bt(e,t,n,r){return j(""!==e.uid,64387),new sy(e.isAuthenticated()?e.uid:"",t,n,r)}checkEmpty(e){let t=!0,n=IDBKeyRange.bound([this.userId,Number.NEGATIVE_INFINITY],[this.userId,Number.POSITIVE_INFINITY]);return sw(e).te({index:e0,range:n},(e,n,r)=>{t=!1,r.done()}).next(()=>t)}addMutationBatch(e,t,n,r){let i=tV(e,e4),s=sw(e);return s.add({}).next(o=>{j("number"==typeof o,49019);let a=new rQ(o,t,n,r),l=function(e,t,n){let r=n.baseMutations.map(t=>ik(e.wt,t)),i=n.mutations.map(t=>ik(e.wt,t));return{userId:t,batchId:n.batchId,localWriteTimeMs:n.localWriteTime.toMillis(),baseMutations:r,mutations:i}}(this.serializer,this.userId,a),u=[],c=new tH((e,t)=>en(e.canonicalString(),t.canonicalString()));for(let e of r){let t=[this.userId,eG(e.key.path),o];c=c.add(e.key.path.popLast()),u.push(s.put(l)),u.push(i.put(t,e2))}return c.forEach(t=>{u.push(this.indexManager.addToCollectionParentIndex(e,t))}),e.addOnCommittedListener(()=>{this.er[o]=a.keys()}),ex.waitFor(u).next(()=>a)})}lookupMutationBatch(e,t){return sw(e).get(t).next(e=>e?(j(e.userId===this.userId,48,"Unexpected user for mutation batch",{userId:e.userId,batchId:t}),iz(this.serializer,e)):null)}tr(e,t){return this.er[t]?ex.resolve(this.er[t]):this.lookupMutationBatch(e,t).next(e=>{if(e){let n=e.keys();return this.er[t]=n,n}return null})}getNextMutationBatchAfterBatchId(e,t){let n=t+1,r=IDBKeyRange.lowerBound([this.userId,n]),i=null;return sw(e).te({index:e0,range:r},(e,t,r)=>{t.userId===this.userId&&(j(t.batchId>=n,47524,{nr:n}),i=iz(this.serializer,t)),r.done()}).next(()=>i)}getHighestUnacknowledgedBatchId(e){let t=IDBKeyRange.upperBound([this.userId,Number.POSITIVE_INFINITY]),n=-1;return sw(e).te({index:e0,range:t,reverse:!0},(e,t,r)=>{n=t.batchId,r.done()}).next(()=>n)}getAllMutationBatches(e){let t=IDBKeyRange.bound([this.userId,-1],[this.userId,Number.POSITIVE_INFINITY]);return sw(e).J(e0,t).next(e=>e.map(e=>iz(this.serializer,e)))}getAllMutationBatchesAffectingDocumentKey(e,t){let n=[this.userId,eG(t.path)],r=IDBKeyRange.lowerBound(n),i=[];return tV(e,e4).te({range:r},(n,r,s)=>{let[o,a,l]=n,u=eH(a);if(o===this.userId&&t.path.isEqual(u))return sw(e).get(l).next(e=>{if(!e)throw U(61480,{rr:n,batchId:l});j(e.userId===this.userId,10503,"Unexpected user for mutation batch",{userId:e.userId,batchId:l}),i.push(iz(this.serializer,e))});s.done()}).next(()=>i)}getAllMutationBatchesAffectingDocumentKeys(e,t){let n=new tH(en),r=[];return t.forEach(t=>{let i=[this.userId,eG(t.path)],s=IDBKeyRange.lowerBound(i),o=tV(e,e4).te({range:s},(e,r,i)=>{let[s,o,a]=e,l=eH(o);s===this.userId&&t.path.isEqual(l)?n=n.add(a):i.done()});r.push(o)}),ex.waitFor(r).next(()=>this.ir(e,n))}getAllMutationBatchesAffectingQuery(e,t){let n=t.path,r=n.length+1,i=[this.userId,eG(n)],s=IDBKeyRange.lowerBound(i),o=new tH(en);return tV(e,e4).te({range:s},(e,t,i)=>{let[s,a,l]=e,u=eH(a);s===this.userId&&n.isPrefixOf(u)?u.length===r&&(o=o.add(l)):i.done()}).next(()=>this.ir(e,o))}ir(e,t){let n=[],r=[];return t.forEach(t=>{r.push(sw(e).get(t).next(e=>{if(null===e)throw U(35274,{batchId:t});j(e.userId===this.userId,9748,"Unexpected user for mutation batch",{userId:e.userId,batchId:t}),n.push(iz(this.serializer,e))}))}),ex.waitFor(r).next(()=>n)}removeMutationBatch(e,t){return sm(e.he,this.userId,t).next(n=>(e.addOnCommittedListener(()=>{this.sr(t.batchId)}),ex.forEach(n,t=>this.referenceDelegate.markPotentiallyOrphaned(e,t))))}sr(e){delete this.er[e]}performConsistencyCheck(e){return this.checkEmpty(e).next(t=>
18{if(!t)return ex.resolve();let n=IDBKeyRange.lowerBound([this.userId]),r=[];return tV(e,e4).te({range:n},(e,t,n)=>{if(e[0]===this.userId){let t=eH(e[1]);r.push(t)}else n.done()}).next(()=>{j(0===r.length,56720,{_r:r.map(e=>e.canonicalString())})})})}containsKey(e,t){return sv(e,this.userId,t)}ar(e){return tV(e,eY).get(this.userId).next(e=>e||{userId:this.userId,lastAcknowledgedBatchId:-1,lastStreamToken:""})}}function sv(e,t,n){let r=[t,eG(n.path)],i=r[1],s=IDBKeyRange.lowerBound(r),o=!1;return tV(e,e4).te({range:s,ee:!0},(e,n,r)=>{let[s,a,l]=e;s===t&&a===i&&(o=!0),r.done()}).next(()=>o)}function sw(e){return tV(e,eJ)}class sb{constructor(e){this.ur=e}next(){return this.ur+=2,this.ur}static cr(){return new sb(0)}static lr(){return new sb(-1)}}class s_{constructor(e,t){this.referenceDelegate=e,this.serializer=t}allocateTargetId(e){return this.hr(e).next(t=>{let n=new sb(t.highestTargetId);return t.highestTargetId=n.next(),this.Pr(e,t).next(()=>t.highestTargetId)})}getLastRemoteSnapshotVersion(e){return this.hr(e).next(e=>ea.fromTimestamp(new eo(e.lastRemoteSnapshotVersion.seconds,e.lastRemoteSnapshotVersion.nanoseconds)))}getHighestSequenceNumber(e){return this.hr(e).next(e=>e.highestListenSequenceNumber)}setTargetsMetadata(e,t,n){return this.hr(e).next(r=>(r.highestListenSequenceNumber=t,n&&(r.lastRemoteSnapshotVersion=n.toTimestamp()),t>r.highestListenSequenceNumber&&(r.highestListenSequenceNumber=t),this.Pr(e,r)))}addTargetData(e,t){return this.Tr(e,t).next(()=>this.hr(e).next(n=>(n.targetCount+=1,this.Ir(t,n),this.Pr(e,n))))}updateTargetData(e,t){return this.Tr(e,t)}removeTargetData(e,t){return this.removeMatchingKeysForTargetId(e,t.targetId).next(()=>tV(e,tn).delete(t.targetId)).next(()=>this.hr(e)).next(t=>(j(t.targetCount>0,8065),t.targetCount-=1,this.Pr(e,t)))}removeTargets(e,t,n){let r=0,i=[];return tV(e,tn).te((s,o)=>{let a=i$(o);a.sequenceNumber<=t&&null===n.get(a.targetId)&&(r++,i.push(this.removeTargetData(e,a)))}).next(()=>ex.waitFor(i)).next(()=>r)}forEachTarget(e,t){return tV(e,tn).te((e,n)=>{t(i$(n))})}hr(e){return tV(e,tc).get(tu).next(e=>(j(null!==e,2888),e))}Pr(e,t){return tV(e,tc).put(tu,t)}Tr(e,t){return tV(e,tn).put(iK(this.serializer,t))}Ir(e,t){let n=!1;return e.targetId>t.highestTargetId&&(t.highestTargetId=e.targetId,n=!0),e.sequenceNumber>t.highestListenSequenceNumber&&(t.highestListenSequenceNumber=e.sequenceNumber,n=!0),n}getTargetCount(e){return this.hr(e).next(e=>e.targetCount)}getTargetData(e,t){let n=nZ(t),r=IDBKeyRange.bound([n,Number.NEGATIVE_INFINITY],[n,Number.POSITIVE_INFINITY]),i=null;return tV(e,tn).te({range:r,index:tr},(e,n,r)=>{let s=i$(n);n0(t,s.target)&&(i=s,r.done())}).next(()=>i)}addMatchingKeys(e,t,n){let r=[],i=sI(e);return t.forEach(t=>{let s=eG(t.path);r.push(i.put({targetId:n,path:s})),r.push(this.referenceDelegate.addReference(e,n,t))}),ex.waitFor(r)}removeMatchingKeys(e,t,n){let r=sI(e);return ex.forEach(t,t=>{let i=eG(t.path);return ex.waitFor([r.delete([n,i]),this.referenceDelegate.removeReference(e,n,t)])})}removeMatchingKeysForTargetId(e,t){let n=sI(e),r=IDBKeyRange.bound([t],[t+1],!1,!0);return n.delete(r)}getMatchingKeysForTargetId(e,t){let n=IDBKeyRange.bound([t],[t+1],!1,!0),r=sI(e),i=rw();return r.te({range:n,ee:!0},(e,t,n)=>{let r=new ef(eH(e[1]));i=i.add(r)}).next(()=>i)}containsKey(e,t){let n=eG(t.path),r=IDBKeyRange.bound([n],[n+"\0"],!1,!0),i=0;return sI(e).te({index:ta,ee:!0,range:r},([e,t],n,r)=>{0!==e&&(i++,r.done())}).next(()=>i>0)}Rt(e,t){return tV(e,tn).get(t).next(e=>e?i$(e):null)}}function sI(e){return tV(e,ts)}let sE="LruGarbageCollector";function sT([e,t],[n,r]){let i=en(e,n);return 0===i?en(t,r):i}class sS{constructor(e){this.Er=e,this.buffer=new tH(sT),this.dr=0}Ar(){return++this.dr}Rr(e){let t=[e,this.Ar()];if(this.buffer.size<this.Er)this.buffer=this.buffer.add(t);else{let e=this.buffer.last();0>sT(t,e)&&(this.buffer=this.buffer.delete(e).add(t))}}get maxValue(){return this.buffer.last()[0]}}class sC{constructor(e,t,n){this.garbageCollector=e,this.asyncQueue=t,this.localStore=n,this.Vr=null}start(){-1!==this.garbageCollector.params.cacheSizeCollectionThreshold&&this.mr(6e4)}stop(){this.Vr&&(this.Vr.cancel(),this.Vr=null)}get started(){return null!==this.Vr}mr(e){P(sE,`Garbage collection scheduled in ${e}ms`),this.Vr=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",e,async()=>{this.Vr=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(e){eP(e)?P(sE,"Ignoring IndexedDB error during garbage collection: ",e):await eC(e)}await this.mr(3e5)})}}class sx{constructor(e,t){this.gr=e,this.params=t}calculateTargetCount(e,t){return this.gr.pr(e).next(e=>Math.floor(t/100*e))}nthSequenceNumber(e,t){if(0===t)return ex.resolve(eq.le);let n=new sS(t);return this.gr.forEachTarget(e,e=>n.Rr(e.sequenceNumber)).next(()=>this.gr.yr(e,e=>n.Rr(e))).next(()=>n.maxValue)}removeTargets(e,t,n){return this.gr.removeTargets(e,t,n)}removeOrphanedDocuments(e,t){return this.gr.removeOrphanedDocuments(e,t)}collect(e,t){return -1===this.params.cacheSizeCollectionThreshold?(P("LruGarbageCollector","Garbage collection skipped; disabled"),ex.resolve(sf)):this.getCacheSize(e).next(n=>n<this.params.cacheSizeCollectionThreshold?(P("LruGarbageCollector",`Garbage collection skipped; Cache size ${n} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),sf):this.wr(e,t))}getCacheSize(e){return this.gr.getCacheSize(e)}wr(e,t){let n,r,i,s,o,a,l;let u=Date.now();return this.calculateTargetCount(e,this.params.percentileToCollect).next(t=>(t>this.params.maximumSequenceNumbersToCollect?(P("LruGarbageCollector",`C
18apping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${t}`),r=this.params.maximumSequenceNumbersToCollect):r=t,s=Date.now(),this.nthSequenceNumber(e,r))).next(r=>(n=r,o=Date.now(),this.removeTargets(e,n,t))).next(t=>(i=t,a=Date.now(),this.removeOrphanedDocuments(e,n))).next(e=>(l=Date.now(),O()<=w.in.DEBUG&&P("LruGarbageCollector",`LRU Garbage Collection 19 Counted targets in ${s-u}ms 20 Determined least recently used ${r} in `+(o-s)+"ms\n"+` Removed ${i} targets in `+(a-o)+"ms\n"+` Removed ${e} documents in `+(l-a)+"ms\n"+`Total Duration: ${l-u}ms`),ex.resolve({didRun:!0,sequenceNumbersCollected:r,targetsRemoved:i,documentsRemoved:e})))}}class sk{constructor(e,t){this.db=e,this.garbageCollector=new sx(this,t)}pr(e){let t=this.br(e);return this.db.getTargetCache().getTargetCount(e).next(e=>t.next(t=>e+t))}br(e){let t=0;return this.yr(e,e=>{t++}).next(()=>t)}forEachTarget(e,t){return this.db.getTargetCache().forEachTarget(e,t)}yr(e,t){return this.Sr(e,(e,n)=>t(n))}addReference(e,t,n){return sA(e,n)}removeReference(e,t,n){return sA(e,n)}removeTargets(e,t,n){return this.db.getTargetCache().removeTargets(e,t,n)}markPotentiallyOrphaned(e,t){return sA(e,t)}Dr(e,t){let n;return n=!1,tV(e,eY).ne(r=>sv(e,r,t).next(e=>(e&&(n=!0),ex.resolve(!e)))).next(()=>n)}removeOrphanedDocuments(e,t){let n=this.db.getRemoteDocumentCache().newChangeBuffer(),r=[],i=0;return this.Sr(e,(s,o)=>{if(o<=t){let t=this.Dr(e,s).next(t=>{if(!t)return i++,n.getEntry(e,s).next(()=>(n.removeEntry(s,ea.min()),sI(e).delete([0,eG(s.path)])))});r.push(t)}}).next(()=>ex.waitFor(r)).next(()=>n.apply(e)).next(()=>i)}removeTarget(e,t){let n=t.withSequenceNumber(e.currentSequenceNumber);return this.db.getTargetCache().updateTargetData(e,n)}updateLimboDocument(e,t){return sA(e,t)}Sr(e,t){let n=sI(e),r,i=eq.le;return n.te({index:ta},([e,n],{path:s,sequenceNumber:o})=>{0===e?(i!==eq.le&&t(new ef(eH(r)),i),i=o,r=s):i=eq.le}).next(()=>{i!==eq.le&&t(new ef(eH(r)),i)})}getCacheSize(e){return this.db.getRemoteDocumentCache().getSize(e)}}function sA(e,t){var n;return sI(e).put((n=e.currentSequenceNumber,{targetId:0,path:eG(t.path),sequenceNumber:n}))}class sR{constructor(){this.changes=new rh(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,nR.newInvalidDocument(e).setReadTime(t))}getEntry(e,t){this.assertNotApplied();let n=this.changes.get(t);return void 0!==n?ex.resolve(n):this.getFromCache(e,t)}getEntries(e,t){return this.getAllFromCache(e,t)}apply(e){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(e)}assertNotApplied(){}}class sN{constructor(e){this.serializer=e}setIndexManager(e){this.indexManager=e}addEntry(e,t,n){return tV(e,e6).put(n)}removeEntry(e,t,n){return tV(e,e6).delete(function(e,t){let n=e.path.toArray();return[n.slice(0,n.length-2),n[n.length-2],ij(t),n[n.length-1]]}(t,n))}updateMetadata(e,t){return this.getMetadata(e).next(n=>(n.byteSize+=t,this.vr(e,n)))}getEntry(e,t){let n=nR.newInvalidDocument(t);return tV(e,e6).te({index:e9,range:IDBKeyRange.only(sD(t))},(e,r)=>{n=this.Cr(t,r)}).next(()=>n)}Fr(e,t){let n={size:0,document:nR.newInvalidDocument(t)};return tV(e,e6).te({index:e9,range:IDBKeyRange.only(sD(t))},(e,r)=>{n={document:this.Cr(t,r),size:sg(r)}}).next(()=>n)}getEntries(e,t){let n=rd;return this.Mr(e,t,(e,t)=>{let r=this.Cr(e,t);n=n.insert(e,r)}).next(()=>n)}Or(e,t){let n=rd,r=new t$(ef.comparator);return this.Mr(e,t,(e,t)=>{let i=this.Cr(e,t);n=n.insert(e,i),r=r.insert(e,sg(t))}).next(()=>({documents:n,Nr:r}))}Mr(e,t,n){if(t.isEmpty())return ex.resolve();let r=new tH(sL);t.forEach(e=>r=r.add(e));let i=IDBKeyRange.bound(sD(r.first()),sD(r.last())),s=r.getIterator(),o=s.getNext();return tV(e,e6).te({index:e9,range:i},(e,t,r)=>{let i=ef.fromSegments([...t.prefixPath,t.collectionGroup,t.documentId]);for(;o&&0>sL(o,i);)n(o,null),o=s.getNext();o&&o.isEqual(i)&&(n(o,t),o=s.hasNext()?s.getNext():null),o?r.H(sD(o)):r.done()}).next(()=>{for(;o;)n(o,null),o=s.hasNext()?s.getNext():null})}getDocumentsMatchingQuery(e,t,n,r,i){let s=t.path,o=[s.popLast().toArray(),s.lastSegment(),ij(n.readTime),n.documentKey.path.isEmpty()?"":n.documentKey.path.lastSegment()],a=[s.popLast().toArray(),s.lastSegment(),[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],""];return tV(e,e6).J(IDBKeyRange.bound(o,a,!0)).next(e=>{null==i||i.incrementDocumentReadCount(e.length);let n=rd;for(let i of e){let e=this.Cr(ef.fromSegments(i.prefixPath.concat(i.collectionGroup,i.documentId)),i);
20e.isFoundDocument()&&(rl(t,e)||r.has(e.key))&&(n=n.insert(e.key,e))}return n})}getAllFromCollectionGroup(e,t,n,r){let i=rd,s=sP(t,n),o=sP(t,eI.max());return tV(e,e6).te({index:e8,range:IDBKeyRange.bound(s,o,!0)},(e,t,n)=>{let s=this.Cr(ef.fromSegments(t.prefixPath.concat(t.collectionGroup,t.documentId)),t);(i=i.insert(s.key,s)).size===r&&n.done()}).next(()=>i)}newChangeBuffer(e){return new sO(this,!!e&&e.trackRemovals)}getSize(e){return this.getMetadata(e).next(e=>e.byteSize)}getMetadata(e){return tV(e,te).get(tt).next(e=>(j(!!e,20021),e))}vr(e,t){return tV(e,te).put(tt,t)}Cr(e,t){if(t){let e=function(e,t){let n;if(t.document)n=ix(e.wt,t.document,!!t.hasCommittedMutations);else if(t.noDocument){let e=ef.fromSegments(t.noDocument.path),r=iq(t.noDocument.readTime);n=nR.newNoDocument(e,r),t.hasCommittedMutations&&n.setHasCommittedMutations()}else{if(!t.unknownDocument)return U(56709);{let e=ef.fromSegments(t.unknownDocument.path),r=iq(t.unknownDocument.version);n=nR.newUnknownDocument(e,r)}}return t.readTime&&n.setReadTime(function(e){let t=new eo(e[0],e[1]);return ea.fromTimestamp(t)}(t.readTime)),n}(this.serializer,t);if(!(e.isNoDocument()&&e.version.isEqual(ea.min())))return e}return nR.newInvalidDocument(e)}}class sO extends sR{constructor(e,t){super(),this.Br=e,this.trackRemovals=t,this.Lr=new rh(e=>e.toString(),(e,t)=>e.isEqual(t))}applyChanges(e){let t=[],n=0,r=new tH((e,t)=>en(e.canonicalString(),t.canonicalString()));
20return this.changes.forEach((i,s)=>{let o=this.Lr.get(i);if(t.push(this.Br.removeEntry(e,i,o.readTime)),s.isValidDocument()){let a=iV(this.Br.serializer,s);r=r.add(i.path.popLast());let l=sg(a);n+=l-o.size,t.push(this.Br.addEntry(e,i,a))}else if(n-=o.size,this.trackRemovals){let n=iV(this.Br.serializer,s.convertToNoDocument(ea.min()));t.push(this.Br.addEntry(e,i,n))}}),r.forEach(n=>{t.push(this.Br.indexManager.addToCollectionParentIndex(e,n))}),t.push(this.Br.updateMetadata(e,n)),ex.waitFor(t)}getFromCache(e,t){return this.Br.Fr(e,t).next(e=>(this.Lr.set(t,{size:e.size,readTime:e.document.readTime}),e.document))}getAllFromCache(e,t){return this.Br.Or(e,t).next(({documents:e,Nr:t})=>(t.forEach((t,n)=>{this.Lr.set(t,{size:n,readTime:e.get(t).readTime})}),e))}}function sD(e){let t=e.path.toArray();return[t.slice(0,t.length-2),t[t.length-2],t[t.length-1]]}function sP(e,t){let n=t.documentKey.path.toArray();return[e,ij(t.readTime),n.slice(0,n.length-2),n.length>0?n[n.length-1]:""]}function sL(e,t){let n=e.path.toArray(),r=t.path.toArray(),i=0;for(let e=0;e<n.length-2&&e<r.length-2;++e)if(i=en(n[e],r[e]))return i;return(i=en(n.length,r.length))||(i=en(n[n.length-2],r[r.length-2]))||en(n[n.length-1],r[r.length-1])}class sM{constructor(e,t){this.overlayedDocument=e,this.mutatedFields=t}}class sF{constructor(e,t,n,r){this.remoteDocumentCache=e,this.mutationQueue=t,this.documentOverlayCache=n,this.indexManager=r}getDocument(e,t){let n=null;return this.documentOverlayCache.getOverlay(e,t).next(r=>(n=r,this.remoteDocumentCache.getEntry(e,t))).next(e=>(null!==n&&rj(n.mutation,e,tX.empty(),eo.now()),e))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next(t=>this.getLocalViewOfDocuments(e,t,rw()).next(()=>t))}getLocalViewOfDocuments(e,t,n=rw()){let r=rg();return this.populateOverlays(e,r,t).next(()=>this.computeViews(e,t,r,n).next(e=>{let t=rp();return e.forEach((e,n)=>{t=t.insert(e,n.overlayedDocument)}),t}))}getOverlayedDocuments(e,t){let n=rg();return this.populateOverlays(e,n,t).next(()=>this.computeViews(e,t,n,rw()))}populateOverlays(e,t,n){let r=[];return n.forEach(e=>{t.has(e)||r.push(e)}),this.documentOverlayCache.getOverlays(e,r).next(e=>{e.forEach((e,n)=>{t.set(e,n)})})}computeViews(e,t,n,r){let i=rd,s=rg(),o=rg();return t.forEach((e,t)=>{let o=n.get(t.key);r.has(t.key)&&(void 0===o||o.mutation instanceof rz)?i=i.insert(t.key,t):void 0!==o?(s.set(t.key,o.mutation.getFieldMask()),rj(o.mutation,t,o.mutation.getFieldMask(),eo.now())):s.set(t.key,tX.empty())}),this.recalculateAndSaveOverlays(e,i).next(e=>(e.forEach((e,t)=>s.set(e,t)),t.forEach((e,t)=>{var n;return o.set(e,new sM(t,null!==(n=s.get(e))&&void 0!==n?n:null))}),o))}recalculateAndSaveOverlays(e,t){let n=rg(),r=new t$((e,t)=>e-t),i=rw();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,t).next(e=>{for(let i of e)i.keys().forEach(e=>{let s=t.get(e);if(null===s)return;let o=n.get(e)||tX.empty();o=i.applyToLocalView(s,o),n.set(e,o);let a=(r.get(i.batchId)||rw()).add(e);r=r.insert(i.batchId,a)})}).next(()=>{let s=[],o=r.getReverseIterator();for(;o.hasNext();){let r=o.getNext(),a=r.key,l=r.value,u=rg();l.forEach(e=>{if(!i.has(e)){let r=rV(t.get(e),n.get(e));null!==r&&u.set(e,r),i=i.add(e)}}),s.push(this.documentOverlayCache.saveOverlays(e,a,u))}return ex.waitFor(s)}).next(()=>n)}recalculateAndSaveOverlaysForDocumentKeys(e,t){return this.remoteDocumentCache.getEntries(e,t).next(t=>this.recalculateAndSaveOverlays(e,t))}getDocumentsMatchingQuery(e,t,n,r){return ef.isDocumentKey(t.path)&&null===t.collectionGroup&&0===t.filters.length?this.getDocumentsMatchingDocumentQuery(e,t.path):n8(t)?this.getDocumentsMatchingCollectionGroupQuery(e,t,n,r):this.getDocumentsMatchingCollectionQuery(e,t,n,r)}getNextDocuments(e,t,n,r){return this.remoteDocumentCache.getAllFromCollectionGroup(e,t,n,r).next(i=>{let s=r-i.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(e,t,n.largestBatchId,r-i.size):ex.resolve(rg()),o=-1,a=i;return s.next(t=>ex.forEach(t,(t,n)=>(o<n.largestBatchId&&(o=n.largestBatchId),i.get(t)?ex.resolve():this.remoteDocumentCache.getEntry(e,t).next(e=>{a=a.insert(t,e)}))).next(()=>this.populateOverlays(e,t,i)).next(()=>this.computeViews(e,a,t,rw())).next(e=>({batchId:o,changes:rm(e)}
vendor: 4,103 bytes, line 20
20)))})}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new ef(t)).next(e=>{let t=rp();return e.isFoundDocument()&&(t=t.insert(e.key,e)),t})}getDocumentsMatchingCollectionGroupQuery(e,t,n,r){let i=t.collectionGroup,s=rp();return this.indexManager.getCollectionParents(e,i).next(o=>ex.forEach(o,o=>{let a=new n5(o.child(i),null,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,t.startAt,t.endAt);return this.getDocumentsMatchingCollectionQuery(e,a,n,r).next(e=>{e.forEach((e,t)=>{s=s.insert(e,t)})})}).next(()=>s))}getDocumentsMatchingCollectionQuery(e,t,n,r){let i;return this.documentOverlayCache.getOverlaysForCollection(e,t.path,n.largestBatchId).next(s=>(i=s,this.remoteDocumentCache.getDocumentsMatchingQuery(e,t,n,i,r))).next(e=>{i.forEach((t,n)=>{let r=n.getKey();null===e.get(r)&&(e=e.insert(r,nR.newInvalidDocument(r)))});let n=rp();return e.forEach((e,r)=>{let s=i.get(e);void 0!==s&&rj(s.mutation,r,tX.empty(),eo.now()),rl(t,r)&&(n=n.insert(e,r))}),n})}}class sU{constructor(e){this.serializer=e,this.kr=new Map,this.qr=new Map}getBundleMetadata(e,t){return ex.resolve(this.kr.get(t))}saveBundleMetadata(e,t){return this.kr.set(t.id,{id:t.id,version:t.version,createTime:ig(t.createTime)}),ex.resolve()}getNamedQuery(e,t){return ex.resolve(this.qr.get(t))}saveNamedQuery(e,t){return this.qr.set(t.name,{name:t.name,query:iG(t.bundledQuery),readTime:ig(t.readTime)}),ex.resolve()}}class sV{constructor(){this.overlays=new t$(ef.comparator),this.Qr=new Map}getOverlay(e,t){return ex.resolve(this.overlays.get(t))}getOverlays(e,t){let n=rg();return ex.forEach(t,t=>this.getOverlay(e,t).next(e=>{null!==e&&n.set(t,e)})).next(()=>n)}saveOverlays(e,t,n){return n.forEach((n,r)=>{this.St(e,t,r)}),ex.resolve()}removeOverlaysForBatchId(e,t,n){let r=this.Qr.get(n);return void 0!==r&&(r.forEach(e=>this.overlays=this.overlays.remove(e)),this.Qr.delete(n)),ex.resolve()}getOverlaysForCollection(e,t,n){let r=rg(),i=t.length+1,s=new ef(t.child("")),o=this.overlays.getIteratorFrom(s);for(;o.hasNext();){let e=o.getNext().value,s=e.getKey();if(!t.isPrefixOf(s.path))break;s.path.length===i&&e.largestBatchId>n&&r.set(e.getKey(),e)}return ex.resolve(r)}getOverlaysForCollectionGroup(e,t,n,r){let i=new t$((e,t)=>e-t),s=this.overlays.getIterator();for(;s.hasNext();){let e=s.getNext().value;if(e.getKey().getCollectionGroup()===t&&e.largestBatchId>n){let t=i.get(e.largestBatchId);null===t&&(t=rg(),i=i.insert(e.largestBatchId,t)),t.set(e.getKey(),e)}}let o=rg(),a=i.getIterator();for(;a.hasNext()&&(a.getNext().value.forEach((e,t)=>o.set(e,t)),!(o.size()>=r)););return ex.resolve(o)}St(e,t,n){let r=this.overlays.get(n.key);if(null!==r){let e=this.Qr.get(r.largestBatchId).delete(n.key);this.Qr.set(r.largestBatchId,e)}this.overlays=this.overlays.insert(n.key,new rY(t,n));let i=this.Qr.get(t);void 0===i&&(i=rw(),this.Qr.set(t,i)),this.Qr.set(t,i.add(n.key))}}class sj{constructor(){this.sessionToken=tZ.EMPTY_BYTE_STRING}getSessionToken(e){return ex.resolve(this.sessionToken)}setSessionToken(e,t){return this.sessionToken=t,ex.resolve()}}class sB{constructor(){this.$r=new tH(sq.Ur),this.Kr=new tH(sq.Wr)}isEmpty(){return this.$r.isEmpty()}addReference(e,t){let n=new sq(e,t);this.$r=this.$r.add(n),this.Kr=this.Kr.add(n)}Gr(e,t){e.forEach(e=>this.addReference(e,t))}removeReference(e,t){this.zr(new sq(e,t))}jr(e,t){e.forEach(e=>this.removeReference(e,t))}Hr(e){let t=new ef(new ec([])),n=new sq(t,e),r=new sq(t,e+1),i=[];return this.Kr.forEachInRange([n,r],e=>{this.zr(e),i.push(e.key)}),i}Jr(){this.$r.forEach(e=>this.zr(e))}zr(e){this.$r=this.$r.delete(e),this.Kr=this.Kr.delete(e)}Yr(e){let t=new ef(new ec([])),n=new sq(t,e),r=new sq(t,e+1),i=rw();return this.Kr.forEachInRange([n,r],e=>{i=i.add(e.key)}),i}containsKey(e){let t=new sq(e,0),n=this.$r.firstAfterOrEqual(t);return null!==n&&e.isEqual(n.key)}}class sq{constructor(e,t){this.key=e,this.Zr=t}static Ur(e,t){return ef.comparator(e.key,t.key)||en(e.Zr,t.Zr)}static Wr(e,t){return en(e.Zr,t.Zr)||ef.comparator(e.key,t.key)}}class sz{constructor(e,t){this.indexManager=e,this.referenceDelegate=t,this.mutation
20Queue=[],this.nr=1,this.Xr=new tH(sq.Ur)}checkEmpty(e){return ex.resolve(0===this.mutationQueue.length)}addMutationBatch(e,t,n,r){let i=this.nr;this.nr++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];let s=new rQ(i,t,n,r);for(let t of(this.mutationQueue.push(s),r))this.Xr=this.Xr.add(new sq(t.key,i)),this.indexManager.addToCollectionParentIndex(e,t.key.path.popLast());return ex.resolve(s)}lookupMutationBatch(e,t){return ex.resolve(this.ei(t))}getNextMutationBatchAfterBatchId(e,t){let n=this.ti(t+1),r=n<0?0:n;return ex.resolve(this.mutationQueue.length>r?this.mutationQueue[r]:null)}getHighestUnacknowledgedBatchId(){return ex.resolve(0===this.mutationQueue.length?-1:this.nr-1)}getAllMutationBatches(e){return ex.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){let n=new sq(t,0),r=new sq(t,Number.POSITIVE_INFINITY),i=[];return this.Xr.forEachInRange([n,r],e=>{let t=this.ei(e.Zr);i.push(t)}),ex.resolve(i)}getAllMutationBatchesAffectingDocumentKeys(e,t){let n=new tH(en);return t.forEach(e=>{let t=new sq(e,0),r=new sq(e,Number.POSITIVE_INFINITY);this.Xr.forEachInRange([t,r],e=>{n=n.add(e.Zr)})}),ex.resolve(this.ni(n))}getAllMutationBatchesAffectingQuery(e,t){let n=t.path,r=n.length+1,i=n;ef.isDocumentKey(i)||(i=i.child(""));let s=new sq(new ef(i),0),o=new tH(en);return this.Xr.forEachWhile(e=>{let t=e.key.path;return!!n.isPrefixOf(t)&&(t.length===r&&(o=o.add(e.Zr)),!0)},s),ex.resolve(this.ni(o))}ni(e){let t=[];return e.forEach(e=>{let n=this.ei(e);null!==n&&t.push(n)}),t}removeMutationBatch(e,t){j(0===this.ri(t.batchId,"removed"),55003),this.mutationQueue.shift();let n=this.Xr;return ex.forEach(t.mutations,r=>{let i=new sq(r.key,t.batchId);return n=n.delete(i),this.referenceDelegate.markPotentiallyOrphaned(e,r.key)}).next(()=>{this.Xr=n})}sr(e){}containsKey(e,t){let n=new sq(t,0),r=this.Xr.firstAfterOrEqual(n);return ex.resolve(t.isEqual(r&&r.key))}performConsistencyCheck(e){return this.mutationQueue.length,ex.resolve()}ri(e,t){return this.ti(e)}ti(e){return 0===this.mutationQueue.length?0:e-this.mutationQueue[0].batchId}ei(e){let t=this.ti(e);return t<0||t>=this.mutationQueue.length?null:this.mutationQueue[t]}}class s${constructor(e){this.ii=e,this.docs=new t$(ef.comparator),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,t){let n=t.key,r=this.docs.get(n),i=r?r.size:0,s=this.ii(t);return this.docs=this.docs.insert(n,{document:t.mutableCopy(),size:s}),this.size+=s-i,this.indexManager.addToCollectionParentIndex(e,n.path.popLast())}removeEntry(e){let t=this.docs.get(e);t&&(this.docs=this.docs.remove(e),this.size-=t.size)}getEntry(e,t){let n=this.docs.get(t);return ex.resolve(n?n.document.mutableCopy():nR.newInvalidDocument(t))}getEntries(e,t){let n=rd;return t.forEach(e=>{let t=this.docs.get(e);n=n.insert(e,t?t.document.mutableCopy():nR.newInvalidDocument(e))}),ex.resolve(n)}getDocumentsMatchingQuery(e,t,n,r){let i=rd,s=t.path,o=new ef(s.child("__id-9223372036854775808__")),a=this.docs.getIteratorFrom(o);for(;a.hasNext();){let{key:e,value:{document:o}}=a.getNext();if(!s.isPrefixOf(e.path))break;e.path.length>s.length+1||0>=eE(e_(o),n)||(r.has(o.key)||rl(t,o))&&(i=i.insert(o.key,o.mutableCopy()))}return ex.resolve(i)}getAllFromCollectionGroup(e,t,n,r){U(9500)}si(e,t){return ex.forEach(this.docs,e=>t(e))}newChangeBuffer(e){return new sK(this)}getSize(e){return ex.resolve(this.size)}}class sK extends sR{constructor(e){super(),this.Br=e}applyChanges(e){let t=[];
vendor: 4,735 bytes, line 20
20return this.changes.forEach((n,r)=>{r.isValidDocument()?t.push(this.Br.addEntry(e,r)):this.Br.removeEntry(n)}),ex.waitFor(t)}getFromCache(e,t){return this.Br.getEntry(e,t)}getAllFromCache(e,t){return this.Br.getEntries(e,t)}}class sG{constructor(e){this.persistence=e,this.oi=new rh(e=>nZ(e),n0),this.lastRemoteSnapshotVersion=ea.min(),this.highestTargetId=0,this._i=0,this.ai=new sB,this.targetCount=0,this.ui=sb.cr()}forEachTarget(e,t){return this.oi.forEach((e,n)=>t(n)),ex.resolve()}getLastRemoteSnapshotVersion(e){return ex.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return ex.resolve(this._i)}allocateTargetId(e){return this.highestTargetId=this.ui.next(),ex.resolve(this.highestTargetId)}setTargetsMetadata(e,t,n){return n&&(this.lastRemoteSnapshotVersion=n),t>this._i&&(this._i=t),ex.resolve()}Tr(e){this.oi.set(e.target,e);let t=e.targetId;t>this.highestTargetId&&(this.ui=new sb(t),this.highestTargetId=t),e.sequenceNumber>this._i&&(this._i=e.sequenceNumber)}addTargetData(e,t){return this.Tr(t),this.targetCount+=1,ex.resolve()}updateTargetData(e,t){return this.Tr(t),ex.resolve()}removeTargetData(e,t){return this.oi.delete(t.target),this.ai.Hr(t.targetId),this.targetCount-=1,ex.resolve()}removeTargets(e,t,n){let r=0,i=[];return this.oi.forEach((s,o)=>{o.sequenceNumber<=t&&null===n.get(o.targetId)&&(this.oi.delete(s),i.push(this.removeMatchingKeysForTargetId(e,o.targetId)),r++)}),ex.waitFor(i).next(()=>r)}getTargetCount(e){return ex.resolve(this.targetCount)}getTargetData(e,t){let n=this.oi.get(t)||null;return ex.resolve(n)}addMatchingKeys(e,t,n){return this.ai.Gr(t,n),ex.resolve()}removeMatchingKeys(e,t,n){this.ai.jr(t,n);let r=this.persistence.referenceDelegate,i=[];return r&&t.forEach(t=>{i.push(r.markPotentiallyOrphaned(e,t))}),ex.waitFor(i)}removeMatchingKeysForTargetId(e,t){return this.ai.Hr(t),ex.resolve()}getMatchingKeysForTargetId(e,t){let n=this.ai.Yr(t);return ex.resolve(n)}containsKey(e,t){return ex.resolve(this.ai.containsKey(t))}}class sH{constructor(e,t){this.ci={},this.overlays={},this.li=new eq(0),this.hi=!1,this.hi=!0,this.Pi=new sj,this.referenceDelegate=e(this),this.Ti=new sG(this),this.indexManager=new sa,this.remoteDocumentCache=new s$(e=>this.referenceDelegate.Ii(e)),this.serializer=new iU(t),this.Ei=new sU(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.hi=!1,Promise.resolve()}get started(){return this.hi}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let t=this.overlays[e.toKey()];return t||(t=new sV,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let n=this.ci[e.toKey()];return n||(n=new sz(t,this.referenceDelegate),this.ci[e.toKey()]=n),n}getGlobalsCache(){return this.Pi}getTargetCache(){return this.Ti}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Ei}runTransaction(e,t,n){P("MemoryPersistence","Starting transaction:",e);let r=new sW(this.li.next());return this.referenceDelegate.di(),n(r).next(e=>this.referenceDelegate.Ai(r).next(()=>e)).toPromise().then(e=>(r.raiseOnCommittedEvent(),e))}Ri(e,t){return ex.or(Object.values(this.ci).map(n=>()=>n.containsKey(e,t)))}}class sW extends eS{constructor(e){super(),this.currentSequenceNumber=e}}class sQ{constructor(e){this.persistence=e,this.Vi=new sB,this.mi=null}static fi(e){return new sQ(e)}get gi(){if(this.mi)return this.mi;throw U(60996)}addReference(e,t,n){return this.Vi.addReference(n,t),this.gi.delete(n.toString()),ex.resolve()}removeReference(e,t,n){return this.Vi.removeReference(n,t),this.gi.add(n.toString()),ex.resolve()}markPotentiallyOrphaned(e,t){return this.gi.add(t.toString()),ex.resolve()}removeTarget(e,t){this.Vi.Hr(t.targetId).forEach(e=>this.gi.add(e.toString()));let n=this.persistence.getTargetCache();return n.getMatchingKeysForTargetId(e,t.targetId).next(e=>{e.forEach(e=>this.gi.add(e.toString()))}).next(()=>n.removeTargetData(e,t))}di(){this.mi=new Set}Ai(e){let t=this.persistence.getRemoteDocumentCache().newChangeBuffer();return ex.forEach(this.gi,n=>{let r=ef.fromPath(n);return this.pi(e,r).next(e=>{e||t.removeEntry(r,ea.min())})}).next(()=>(this.mi=null,t.apply(e)))}updateLimboDocument(e,t){return this.pi(e,t).next(e=>{e?this.gi.delete(t.toString()):this.gi.add(t.toString())})}Ii(e){return 0}pi(e,t){return ex.or([()=>ex.resolve(this.Vi.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.Ri(e,t)])}}class sX{constructor(e,t){this.persistence=e,this.yi=new rh(e=>eG(e.path),(e,t)=>e.isEqual(t)),this.garbageCollector=new sx(this,t)}static fi(e,t){return new sX(e,t)}di(){}Ai(e){return ex.resolve()}forEachTarget(e,t){return this.persistence.getTargetCache().forEac
20hTarget(e,t)}pr(e){let t=this.br(e);return this.persistence.getTargetCache().getTargetCount(e).next(e=>t.next(t=>e+t))}br(e){let t=0;return this.yr(e,e=>{t++}).next(()=>t)}yr(e,t){return ex.forEach(this.yi,(n,r)=>this.Dr(e,n,r).next(e=>e?ex.resolve():t(r)))}removeTargets(e,t,n){return this.persistence.getTargetCache().removeTargets(e,t,n)}removeOrphanedDocuments(e,t){let n=0,r=this.persistence.getRemoteDocumentCache(),i=r.newChangeBuffer();return r.si(e,r=>this.Dr(e,r,t).next(e=>{e||(n++,i.removeEntry(r,ea.min()))})).next(()=>i.apply(e)).next(()=>n)}markPotentiallyOrphaned(e,t){return this.yi.set(t,e.currentSequenceNumber),ex.resolve()}removeTarget(e,t){let n=t.withSequenceNumber(e.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(e,n)}addReference(e,t,n){return this.yi.set(n,e.currentSequenceNumber),ex.resolve()}removeReference(e,t,n){return this.yi.set(n,e.currentSequenceNumber),ex.resolve()}updateLimboDocument(e,t){return this.yi.set(t,e.currentSequenceNumber),ex.resolve()}Ii(e){let t=e.key.toString().length;return e.isFoundDocument()&&(t+=function e(t){switch(nc(t)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:let n=t7(t);return n?16+e(n):16;case 5:return 2*t.stringValue.length;case 6:return t4(t.bytesValue).approximateByteSize();case 7:return t.referenceValue.length;case 9:return(t.arrayValue.values||[]).reduce((t,n)=>t+e(n),0);case 10:case 11:var r;let i;return r=t.mapValue,i=0,tB(r.fields,(t,n)=>{i+=t.length+e(n)}),i;default:throw U(13486,{value:t})}}(e.data.value)),t}Dr(e,t,n){return ex.or([()=>this.persistence.Ri(e,t),()=>this.persistence.getTargetCache().containsKey(e,t),()=>{let e=this.yi.get(t);return ex.resolve(void 0!==e&&e>n)}])}getCacheSize(e){return this.persistence.getRemoteDocumentCache().getSize(e)}}class sY{constructor(e){this.serializer=e}q(e,t,n,r){let i=new eA("createOrUpgrade",t);n<1&&r>=1&&(!function(e){e.createObjectStore(eQ)}(e),e.createObjectStore(eY,{keyPath:"userId"}),e.createObjectStore(eJ,{keyPath:eZ,autoIncrement:!0}).createIndex(e0,e1,{unique:!0}),e.createObjectStore(e4),sJ(e),function(e){e.createObjectStore(eW)}(e));let s=ex.resolve();return n<3&&r>=3&&(0!==n&&(e.deleteObjectStore(ts),e.deleteObjectStore(tn),e.deleteObjectStore(tc),sJ(e)),s=s.next(()=>(function(e){let t=e.store(tc),n={highestTargetId:0,highestListenSequenceNumber:0,lastRemoteSnapshotVersion:ea.min().toTimestamp(),targetCount:0};return t.put(tu,n)})(i))),n<4&&r>=4&&(0!==n&&(s=s.next(()=>i.store(eJ).J().next(t=>{e.deleteObjectStore(eJ),e.createObjectStore(eJ,{keyPath:eZ,autoIncrement:!0}).createIndex(e0,e1,{unique:!0});let n=i.store(eJ),r=t.map(e=>n.put(e));return ex.waitFor(r)}))),s=s.next(()=>{!function(e){e.createObjectStore(tf,{keyPath:"clientId"})}(e)})),n<5&&r>=5&&(s=s.next(()=>this.wi(i))),n<6&&r>=6&&(s=s.next(()=>((function(e){e.createObjectStore(te)})(e),this.bi(i)))),n<7&&r>=7&&(s=s.next(()=>this.Si(i))),n<8&&r>=8&&(s=s.next(()=>this.Di(e,i))),n<9&&r>=9&&(s=s.next(()=>{e.objectStoreNames.contains("remoteDocumentChanges")&&e.deleteObjectStore("remoteDocumentChanges")})),n<10&&r>=10&&(s=s.next(()=>this.Ci(i))),n<11&&r>=11&&(s=s.next(()=>{(function(e){e.createObjectStore(tp,{keyPath:"bundleId"})})(e),function(e){e.createObjectStore(tm,{keyPath:"name"})}(e)})),n<12&&r>=12&&(s=s.next(()=>{!function(e){let t=e.createObjectStore(tC,{keyPath:tx});t.createIndex(tk,tA,{unique:!1}),t.createIndex(tR,tN,{unique:!1})}(e)})),n<13&&r>=13&&(s=s.next(()=>(function(e){let t=e.createObjectStore(e6,{keyPath:e5});t.createIndex(e9,e3),t.createIndex(e8,e7)})(e)).next(()=>this.Fi(e,i)).next(()=>e.deleteObjectStore(eW))),n<14&&r>=14&&(s=s.next(()=>this.Mi(e,i))),n<15&&r>=15&&(s=s.next(()=>{e.createObjectStore(tg,{keyPath:"indexId",autoIncrement:!0}).createIndex(ty,"collectionGroup",{unique:!1}),e.createObjectStore(tv,{keyPath:tw}).createIndex(tb,t_,{unique:!1}),e.createObjectStore(tI,{keyPath:tE}).createIndex(tT,tS,{unique:!1})})),n<16&&r>=16&&(s=s.next(()=>{t.objectStore(tv).clear()}).next(()=>{t.objectStore(tI).clear()})),n<17&&r>=17&&(s=s.next(()=>{!function(e){e.createObjectStore(tO,{keyPath:"name"})}(e)})),n<18&&r>=18&&(0,b.WO)()&&(s=s.next(()=>{t.objectStore(tv).clear()}).next(()=>{t.objectStore(tI).clear()}
20)),s}bi(e){let t=0;return e.store(eW).te((e,n)=>{t+=sg(n)}).next(()=>{let n={byteSize:t};return e.store(te).put(tt,n)})}wi(e){let t=e.store(eY),n=e.store(eJ);return t.J().next(t=>ex.forEach(t,t=>{let r=IDBKeyRange.bound([t.userId,-1],[t.userId,t.lastAcknowledgedBatchId]);return n.J(e0,r).next(n=>ex.forEach(n,n=>{j(n.userId===t.userId,18650,"Cannot process batch from unexpected user",{batchId:n.batchId});let r=iz(this.serializer,n);return sm(e,t.userId,r).next(()=>{})}))}))}Si(e){let t=e.store(ts),n=e.store(eW);return e.store(tc).get(tu).next(e=>{let r=[];return n.te((n,i)=>{let s=new ec(n),o=[0,eG(s)];r.push(t.get(o).next(n=>n?ex.resolve():t.put({targetId:0,path:eG(s),sequenceNumber:e.highestListenSequenceNumber})))}).next(()=>ex.waitFor(r))})}Di(e,t){e.createObjectStore(th,{keyPath:td});let n=t.store(th),r=new sl,i=e=>{if(r.add(e)){let t=e.lastSegment(),r=e.popLast();return n.put({collectionId:t,parent:eG(r)})}};return t.store(eW).te({ee:!0},(e,t)=>i(new ec(e).popLast())).next(()=>t.store(e4).te({ee:!0},([e,t,n],r)=>i(eH(t).popLast())))}Ci(e){let t=e.store(tn);return t.te((e,n)=>{let r=i$(n),i=iK(this.serializer,r);return t.put(i)})}Fi(e,t){let n=t.store(eW),r=[];return n.te((e,n)=>{let i=t.store(e6),s=(n.document?new ef(ec.fromString(n.document.name).popFirst(5)):n.noDocument?ef.fromSegments(n.noDocument.path):n.unknownDocument?ef.fromSegments(n.unknownDocument.path):U(36783)).path.toArray(),o={prefixPath:s.slice(0,s.length-2),collectionGroup:s[s.length-2],documentId:s[s.length-1],readTime:n.readTime||[0,0],unknownDocument:n.unknownDocument,noDocument:n.noDocument,document:n.document,hasCommittedMutations:!!n.hasCommittedMutations};r.push(i.put(o))}).next(()=>ex.waitFor(r))}Mi(e,t){let n=t.store(eJ),r=new sN(this.serializer),i=new sH(sQ.fi,this.serializer.wt);return n.J().next(e=>{let n=new Map;return e.forEach(e=>{var t;let r=null!==(t=n.get(e.userId))&&void 0!==t?t:rw();iz(this.serializer,e).keys().forEach(e=>r=r.add(e)),n.set(e.userId,r)}),ex.forEach(n,(e,n)=>{let s=new A(n),o=iY.bt(this.serializer,s),a=i.getIndexManager(s);return new sF(r,sy.bt(s,this.serializer,a,i.referenceDelegate),o,a).recalculateAndSaveOverlaysForDocumentKeys(new tU(t,eq.le),e).next()})})}}function sJ(e){e.createObjectStore(ts,{keyPath:to}).createIndex(ta,tl,{unique:!0}),e.createObjectStore(tn,{keyPath:"targetId"}).createIndex(tr,ti,{unique:!0}),e.createObjectStore(tc)}let sZ="IndexedDbPersistence",s0="Failed to obtain exclusive access to the persistence layer. To allow shared access, multi-tab synchronization has to be enabled in all tabs. If you are using `experimentalForceOwningTab:true`, make sure that only one tab has persistence enabled at any given time.",s1="main";class s2{constructor(e,t,n,r,i,s,o,a,l,u,c=18){if(this.allowTabSynchronization=e,this.persistenceKey=t,this.clientId=n,this.xi=i,this.window=s,this.document=o,this.Oi=l,this.Ni=u,this.Bi=c,this.li=null,this.hi=!1,this.isPrimary=!1,this.networkEnabled=!0,this.Li=null,this.inForeground=!1,this.ki=null,this.qi=null,this.Qi=Number.NEGATIVE_INFINITY,this.$i=e=>Promise.resolve(),!s2.C())throw new z(q.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");this.referenceDelegate=new sk(this,r),this.Ui=t+s1,this.serializer=new iU(a),this.Ki=new eR(this.Ui,this.Bi,new sY(this.serializer)),this.Pi=new iJ,this.Ti=new s_(this.referenceDelegate,this.serializer),this.remoteDocumentCache=new sN(this.serializer),this.Ei=new iX,this.window&&this.window.localStorage?this.Wi=this.window.localStorage:(this.Wi=null,!1===u&&L(sZ,"LocalStorage is unavailable. As a result, persistence may not work reliably. In particular enablePersistence() could fail immediately after refreshing the page."))}start(){return this.Gi().then(()=>{if(!this.isPrimary&&!this.allowTabSynchronization)throw new z(q.FAILED_PRECONDITION,s0);return this.zi(),this.ji(),this.Hi(),this.runTransaction("getHighestListenSequenceNumber","readonly",e=>this.Ti.getHighestSequenceNumber(e))}).then(e=>{this.li=new eq(e,this.Oi)}).then(()=>{this.hi=!0}).catch(e=>(this.Ki&&this.Ki.close(),Promise.reject(e)))}Ji(e){return this.$i=async t=>{if(this.started)return e(t)},e(this.isPrimary)}setDatabaseDeletedListener(e){this.Ki.U(async t=>{null===t.newVersion&&await e()})}setNetworkEnabled(e){this.networkEnabled!==e&&(this.networkEnabled=e,this.xi.enqueueAndForget(async()=>{this.started&&await this.Gi()}))}Gi(){return this.runTransaction("updateClientMetadataAndTryBecomePrimary","readwrite",e=>tV(e,tf).put({clientId:this.clientId,updateTimeMs:Date.now(),networkEnabled:this.networkEnabled,inForeground:this.inForeground}).next(()=>{if(this.isPrimary)return this.Yi(e).next(e=>{e||(this.isPrimary=!1,this.xi.enqueueRetryable(()=>this.$i(!1)))})}).next(()=>this.Zi(e)).next(t=>this.isPrimary&&!t?this.Xi(e).next(()=>!1):!!t&&this.es(e).next(()=>!0))).catch(e=>{if(eP(e))return P(sZ,"Failed to extend owner lease: ",e),this.isPrimary;if(!this.allowTabSynchronization)throw e;return P(sZ,"Releasing owner lease after error during lease refresh",e),!1}).then(e=>{this.isPrimary!==e&&this.xi.enqueueRetryable(()=>this.$i(e)),this.isPrimary=e})}Yi(e){return tV(e,eQ).get(eX).next(e=>ex.resolve(this.ts(e)))}ns(e){return tV(e,tf).delete(this.clientId)}async rs(){if(this.isPrimary&&!this.ss(this.Qi,18e5)){this.Qi=Date.now();let e=await this.runTransaction("maybeGarbageCollectMultiClientState","readwrite-primary",e=>{let t=tV(e,tf);return t.J().next(e=>{let n=this._s(e,18e5),r=e.filter(e=>-1===n.indexOf(e));return ex.forEach(r,e=>t.delete(e.clientId)).next(()=>r)})}).catch(()=>[]);if(this.Wi)for(let t of e)this.Wi.removeItem(this.us(t.clientId))}}Hi(){this.qi=this.xi.enqueueAfterDelay("client_metadata_refresh",4e3,()=>this.Gi().then(()=>this.rs()).then(()=>this.Hi()))}ts(e){return!!e&&e.ownerId===this.clientId}Zi(e){return this.Ni?ex.resolve(!0):tV(e,eQ).get(eX).next(t=>
20{if(null!==t&&this.ss(t.leaseTimestampMs,5e3)&&!this.cs(t.ownerId)){if(this.ts(t)&&this.networkEnabled)return!0;if(!this.ts(t)){if(!t.allowTabSynchronization)throw new z(q.FAILED_PRECONDITION,s0);return!1}}return!(!this.networkEnabled||!this.inForeground)||tV(e,tf).J().next(e=>void 0===this._s(e,5e3).find(e=>{if(this.clientId!==e.clientId){let t=!this.networkEnabled&&e.networkEnabled,n=!this.inForeground&&e.inForeground,r=this.networkEnabled===e.networkEnabled;if(t||n&&r)return!0}return!1}))}).next(e=>(this.isPrimary!==e&&P(sZ,`Client ${e?"is":"is not"} eligible for a primary lease.`),e))}async shutdown(){this.hi=!1,this.ls(),this.qi&&(this.qi.cancel(),this.qi=null),this.hs(),this.Ps(),await this.Ki.runTransaction("shutdown","readwrite",[eQ,tf],e=>{let t=new tU(e,eq.le);return this.Xi(t).next(()=>this.ns(t))}),this.Ki.close(),this.Ts()}_s(e,t){return e.filter(e=>this.ss(e.updateTimeMs,t)&&!this.cs(e.clientId))}Is(){return this.runTransaction("getActiveClients","readonly",e=>tV(e,tf).J().next(e=>this._s(e,18e5).map(e=>e.clientId)))}get started(){return this.hi}getGlobalsCache(){return this.Pi}getMutationQueue(e,t){return sy.bt(e,this.serializer,t,this.referenceDelegate)}getTargetCache(){return this.Ti}getRemoteDocumentCache(){return this.remoteDocumentCache}getIndexManager(e){return new sh(e,this.serializer.wt.databaseId)}getDocumentOverlayCache(e){return iY.bt(this.serializer,e)}getBundleCache(){return this.Ei}runTransaction(e,t,n){var r;let i;P(sZ,"Starting transaction:",e);let s=18===(r=this.Bi)?tF:17===r?tF:16===r?tM:15===r?tM:14===r?tL:13===r?tL:12===r?tP:11===r?tD:void U(60245);return this.Ki.runTransaction(e,"readonly"===t?"readonly":"readwrite",s,r=>(i=new tU(r,this.li?this.li.next():eq.le),"readwrite-primary"===t?this.Yi(i).next(e=>!!e||this.Zi(i)).next(t=>{if(!t)throw L(`Failed to obtain primary lease for action '${e}'.`),this.isPrimary=!1,this.xi.enqueueRetryable(()=>this.$i(!1)),new z(q.FAILED_PRECONDITION,eT);return n(i)}).next(e=>this.es(i).next(()=>e)):this.Es(i).next(()=>n(i)))).then(e=>(i.raiseOnCommittedEvent(),e))}Es(e){return tV(e,eQ).get(eX).next(e=>{if(null!==e&&this.ss(e.leaseTimestampMs,5e3)&&!this.cs(e.ownerId)&&!this.ts(e)&&!(this.Ni||this.allowTabSynchronization&&e.allowTabSynchronization))throw new z(q.FAILED_PRECONDITION,s0)})}es(e){let t={ownerId:this.clientId,allowTabSynchronization:this.allowTabSynchronization,leaseTimestampMs:Date.now()};return tV(e,eQ).put(eX,t)}static C(){return eR.C()}Xi(e){let t=tV(e,eQ);return t.get(eX).next(e=>this.ts(e)?(P(sZ,"Releasing primary lease."),t.delete(eX)):ex.resolve())}ss(e,t){let n=Date.now();return!(e<n-t)&&(!(e>n)||(L(`Detected an update time that is in the future: ${e} > ${n}`),!1))}zi(){null!==this.document&&"function"==typeof this.document.addEventListener&&(this.ki=()=>{this.xi.enqueueAndForget(()=>(this.inForeground="visible"===this.document.visibilityState,this.Gi()))},this.document.addEventListener("visibilitychange",this.ki),this.inForeground="visible"===this.document.visibilityState)}hs(){this.ki&&(this.document.removeEventListener("visibilitychange",this.ki),this.ki=null)}ji(){var e;"function"==typeof(null===(e=this.window)||void 0===e?void 0:e.addEventListener)&&(this.Li=()=>{this.ls();let e=/(?:Version|Mobile)\/1[456]/;(0,b.G6)()&&(navigator.appVersion.match(e)||navigator.userAgent.match(e))&&this.xi.enterRestrictedMode(!0),this.xi.enqueueAndForget(()=>this.shutdown())},this.window.addEventListener("pagehide",this.Li))}Ps(){this.Li&&(this.window.removeEventListener("pagehide",this.Li),this.Li=null)}cs(e){var t;try{let n=null!==(null===(t=this.Wi)||void 0===t?void 0:t.getItem(this.us(e)));return P(sZ,`Client '${e}' ${n?"is":"is not"} zombied in LocalStorage`),n}catch(e){return L(sZ,"Failed to get zombied client id.",e),!1}}ls(){if(this.Wi)try{this.Wi.setItem(this.us(this.clientId),String(Date.now()))}catch(e){L("Failed to set zombie client id.",e)}}Ts(){if(this.Wi)try{this.Wi.removeItem(this.us(this.clientId))}catch(e){}}us(e){return`firestore_zombie_${this.persistenceKey}_${e}`}}function s4(e,t){let n=e.projectId;return e.isDefaultDatabase||(n+="."+e.database),"firestore/"+t+"/"+n+"/"}class s6{constructor(e,t,n,r){this.targetId=e,this.fromCache=t,this.ds=n,this.As=r}static Rs(e,t){let n=rw(),r=rw();for(let e of t.docChanges)switch(e.type){case 0:n=n.add(e.doc.key);break;case 1:r=r.add(e.doc.key)}return new s6(e,t.fromCache,n,r)}}class s5{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(e){this._documentReadCount+=e}}class s9{constructor(){this.Vs=!1,this.fs=!1,this.gs=100,this.ps=(0,b.G6)()?8:eN((0,b.z$)())>0?6:4}initialize(e,t){this.ys=e,this.indexManager=t,this.Vs=!0}getDocumentsMatchingQuery(e,t,n,r){let i={result:null};return this.ws(e,t).next(e=>{i.result=e}).next(()=>{if(!i.result)return this.bs(e,t,r,n).next(e=>{i.result=e})}).next(()=>{if(i.result)return;let n=new s5;return this.Ss(e,t,n).next(r=>{if(i.result=r,this.fs)return this.Ds(e,t,n,r.size)})}).next(()=>i.result)}Ds(e,t,n,r){return n.documentReadCount<this.gs?(O()<=w.in.DEBUG&&P("QueryEngine","SDK will not create cache indexes for query:",ra(t),"since it only creates cache indexes for collection contains","more than or equal to",this.gs,"documents"),ex.resolve()):(O()<=w.in.DEBUG&&P("QueryEngine","Query:",ra(t),"scans",n.documentReadCount,"local documents and returns",r,"documents as results."),n.documentReadCount>this.ps*r?(O()<=w.in.DEBUG&&P("QueryEngine","The SDK decides to create cache indexes for query:",ra(t),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(e,re(t))):ex.resolve())}ws(e,t){if(n3(t))return ex.resolve(null);let n=re(t);return this.indexManager.getIndexType(e,n).next(r=>0===r?null:(null!==t.limit&&1===r&&(n=re(t=ri(t,null,"F"))),this.indexManager.getDocumentsMatchingTarget(e,n).next(r=>{let i=rw(...r);return this.ys.getDocuments(e,i).next(r=>this.indexManager.getMinOffset(e,n).next(n=>{let s=this.vs(t,r);return this.Cs(t,s,i,n.readTime)?this.ws(e,ri(t,null,"F")):this.Fs(e,s,t,n)}))})))}bs(e,t,n,r){return n3(t)||r.isEqual(ea.min())?ex.resolve(null):this.ys.getDocuments(e,n).next(i=>{let s=this.vs(t,i);return this.Cs(t,s,n,r)?ex.resolve(null):(O()<=w.in.DEBUG&&P("QueryEngine","Re-using previous result from %s to execute query: %s",r.toString(),ra(t)),this.Fs(e,s,t,eb(r,-1)).next(e=>e))})}vs(e,t){let n=new tH(rc(e));return t.forEach((t,r)=>{rl(e,r)&&(n=n.add(r))}),n}Cs(e,t,n,r){if(null===e.limit)return!1;if(n.size!==t.size)return!0;let i="F"===e.limitType?t.last():t.first();return!!i&&(i.hasPendingWrites||i.version.compareTo(r)>0)}Ss(e,t,n){return O()<=w.in.DEBUG&&P("QueryEngine","Using full collection scan to execute query:",ra(t)),this.ys.getDocumentsMatchingQuery(e,t,eI.min(),n)}Fs(e,t,n,r){return this.ys.getDocumentsMatchingQuery(e,n,r).next(e=>(t.forEach(t=>{e=e.insert(t.key,t)}),e))}}let s3="LocalStore";class s8{constructor(e,t,n,r){this.persistence=e,this.Ms=t,this.serializer
20=r,this.xs=new t$(en),this.Os=new rh(e=>nZ(e),n0),this.Ns=new Map,this.Bs=e.getRemoteDocumentCache(),this.Ti=e.getTargetCache(),this.Ei=e.getBundleCache(),this.Ls(n)}Ls(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new sF(this.Bs,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.Bs.setIndexManager(this.indexManager),this.Ms.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction("Collect garbage","readwrite-primary",t=>e.collect(t,this.xs))}}async function s7(e,t){return await e.persistence.runTransaction("Handle user change","readonly",n=>{let r;return e.mutationQueue.getAllMutationBatches(n).next(i=>(r=i,e.Ls(t),e.mutationQueue.getAllMutationBatches(n))).next(t=>{let i=[],s=[],o=rw();for(let e of r)for(let t of(i.push(e.batchId),e.mutations))o=o.add(t.key);for(let e of t)for(let t of(s.push(e.batchId),e.mutations))o=o.add(t.key);return e.localDocuments.getDocuments(n,o).next(e=>({ks:e,removedBatchIds:i,addedBatchIds:s}))})})}function oe(e){return e.persistence.runTransaction("Get last remote snapshot version","readonly",t=>e.Ti.getLastRemoteSnapshotVersion(t))}function ot(e,t,n){let r=rw(),i=rw();return n.forEach(e=>r=r.add(e)),t.getEntries(e,r).next(e=>{let r=rd;return n.forEach((n,s)=>{let o=e.get(n);s.isFoundDocument()!==o.isFoundDocument()&&(i=i.add(n)),s.isNoDocument()&&s.version.isEqual(ea.min())?(t.removeEntry(n,s.readTime),r=r.insert(n,s)):!o.isValidDocument()||s.version.compareTo(o.version)>0||0===s.version.compareTo(o.version)&&o.hasPendingWrites?(t.addEntry(s),r=r.insert(n,s)):P(s3,"Ignoring outdated watch update for ",n,". Current version:",o.version," Watch version:",s.version)}),{qs:r,Qs:i}})}function on(e,t){return e.persistence.runTransaction("Allocate target","readwrite",n=>{let r;return e.Ti.getTargetData(n,t).next(i=>i?(r=i,ex.resolve(r)):e.Ti.allocateTargetId(n).next(i=>(r=new iF(t,i,"TargetPurposeListen",n.currentSequenceNumber),e.Ti.addTargetData(n,r).next(()=>r))))}).then(n=>{let r=e.xs.get(n.targetId);return(null===r||n.snapshotVersion.compareTo(r.snapshotVersion)>0)&&(e.xs=e.xs.insert(n.targetId,n),e.Os.set(t,n.targetId)),n})}async function or(e,t,n){let r=e.xs.get(t);try{n||await e.persistence.runTransaction("Release target",n?"readwrite":"readwrite-primary",t=>e.persistence.referenceDelegate.removeTarget(t,r))}catch(e){if(!eP(e))throw e;P(s3,`Failed to update sequence numbers for target ${t}: ${e}`)}e.xs=e.xs.remove(t),e.Os.delete(r.target)}function oi(e,t,n){let r=ea.min(),i=rw();return e.persistence.runTransaction("Execute query","readwrite",s=>(function(e,t,n){let r=e.Os.get(n);return void 0!==r?ex.resolve(e.xs.get(r)):e.Ti.getTargetData(t,n)})(e,s,re(t)).next(t=>{if(t)return r=t.lastLimboFreeSnapshotVersion,e.Ti.getMatchingKeysForTargetId(s,t.targetId).next(e=>{i=e})}).next(()=>e.Ms.getDocumentsMatchingQuery(s,t,n?r:ea.min(),n?i:rw())).next(n=>(oa(e,ru(t),n),{documents:n,$s:i})))}function os(e,t){let n=e.Ti,r=e.xs.get(t);return r?Promise.resolve(r.target):e.persistence.runTransaction("Get target data","readonly",e=>n.Rt(e,t).next(e=>e?e.target:null))}function oo(e,t){let n=e.Ns.get(t)||ea.min();return e.persistence.runTransaction("Get new document changes","readonly",r=>e.Bs.getAllFromCollectionGroup(r,t,eb(n,-1),Number.MAX_SAFE_INTEGER)).then(n=>(oa(e,t,n),n))}function oa(e,t,n){let r=e.Ns.get(t)||ea.min();n.forEach((e,t)=>{t.readTime.compareTo(r)>0&&(r=t.readTime)}),e.Ns.set(t,r)}async function ol(e,t,n,r){let i=rw(),s=rd;for(let e of n){let n=t.Us(e.metadata.name);e.document&&(i=i.add(n));let r=t.Ks(e);r.setReadTime(t.Ws(e.metadata.readTime)),s=s.insert(n,r)}let o=e.Bs.newChangeBuffer({trackRemovals:!0}),a=await on(e,re(n9(ec.fromString(`__bundle__/docs/${r}`))));return e.persistence.runTransaction("Apply bundle documents","readwrite",t=>ot(t,o,s).next(e=>(o.apply(t),e)).next(n=>e.Ti.removeMatchingKeysForTargetId(t,a.targetId).next(()=>e.Ti.addMatchingKeys(t,i,a.targetId)).next(()=>e.localDocuments.getLocalViewOfDocuments(t,n.qs,n.Qs)).next(()=>n.qs)))}async function ou(e,t,n=rw()){let r=await on(e,re(iG(t.bundledQuery)));return e.persistence.runTransaction("Save named query","readwrite",i=>{let s=ig(t.readTime);if(r.snapshotVersion.compareTo(s)>=0)return e.Ei.saveNamedQuery(i,t);let o=r.withResumeToken(tZ.EMPTY_BYTE_STRING,s);return e.xs=e.xs.insert(o.targetId,o),e.Ti.updateTargetData(i,o).next(()=>e.Ti.removeMatchingKeysForTargetId(i,r.targetId)).next(()=>e.Ti.addMatchingKeys(i,n,r.targetId)).next(()=>e.Ei.saveNamedQuery(i,t))})}let oc="firestore_clients";function oh(e,t){return`${oc}_${e}_${t}`}let od="firestore_mutations";function of(e,t,n){let r=`${od}_${e}_${n}`;return t.isAuthenticated()&&(r+=`_${t.uid}`),r}let op="firestore_targets";function om(e,t){return`${op}_${e}_${t}`}
20let og="SharedClientState";class oy{constructor(e,t,n,r){this.user=e,this.batchId=t,this.state=n,this.error=r}static Gs(e,t,n){let r=JSON.parse(n),i,s="object"==typeof r&&-1!==["pending","acknowledged","rejected"].indexOf(r.state)&&(void 0===r.error||"object"==typeof r.error);return s&&r.error&&(s="string"==typeof r.error.message&&"string"==typeof r.error.code)&&(i=new z(r.error.code,r.error.message)),s?new oy(e,t,r.state,i):(L(og,`Failed to parse mutation state for ID '${t}': ${n}`),null)}zs(){let e={state:this.state,updateTimeMs:Date.now()};return this.error&&(e.error={code:this.error.code,message:this.error.message}),JSON.stringify(e)}}class ov{constructor(e,t,n){this.targetId=e,this.state=t,this.error=n}static Gs(e,t){let n=JSON.parse(t),r,i="object"==typeof n&&-1!==["not-current","current","rejected"].indexOf(n.state)&&(void 0===n.error||"object"==typeof n.error);return i&&n.error&&(i="string"==typeof n.error.message&&"string"==typeof n.error.code)&&(r=new z(n.error.code,n.error.message)),i?new ov(e,n.state,r):(L(og,`Failed to parse target state for ID '${e}': ${t}`),null)}zs(){let e={state:this.state,updateTimeMs:Date.now()};return this.error&&(e.error={code:this.error.code,message:this.error.message}),JSON.stringify(e)}}class ow{constructor(e,t){this.clientId=e,this.activeTargetIds=t}static Gs(e,t){let n=JSON.parse(t),r="object"==typeof n&&n.activeTargetIds instanceof Array,i=rb;for(let e=0;r&&e<n.activeTargetIds.length;++e)r=eK(n.activeTargetIds[e]),i=i.add(n.activeTargetIds[e]);return r?new ow(e,i):(L(og,`Failed to parse client data for instance '${e}': ${t}`),null)}}class ob{constructor(e,t){this.clientId=e,this.onlineState=t}static Gs(e){let t=JSON.parse(e);return"object"==typeof t&&-1!==["Unknown","Online","Offline"].indexOf(t.onlineState)&&"string"==typeof t.clientId?new ob(t.clientId,t.onlineState):(L(og,`Failed to parse online state: ${e}`),null)}}class o_{constructor(){this.activeTargetIds=rb}js(e){this.activeTargetIds=this.activeTargetIds.add(e)}Hs(e){this.activeTargetIds=this.activeTargetIds.delete(e)}zs(){return JSON.stringify({activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()})}}class oI{constructor(e,t,n,r,i){var s,o,a;this.window=e,this.xi=t,this.persistenceKey=n,this.Js=r,this.syncEngine=null,this.onlineStateHandler=null,this.sequenceNumberHandler=null,this.Ys=this.Zs.bind(this),this.Xs=new t$(en),this.started=!1,this.eo=[];let l=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");this.storage=this.window.localStorage,this.currentUser=i,this.no=oh(this.persistenceKey,this.Js),this.ro=(s=this.persistenceKey,`firestore_sequence_number_${s}`),this.Xs=this.Xs.insert(this.Js,new o_),this.io=RegExp(`^${oc}_${l}_([^_]*)$`),this.so=RegExp(`^${od}_${l}_(\\d+)(?:_(.*))?$`),this.oo=RegExp(`^${op}_${l}_(\\d+)$`),this._o=(o=this.persistenceKey,`firestore_online_state_${o}`),this.ao=(a=this.persistenceKey,`firestore_bundle_loaded_v2_${a}`),this.window.addEventListener("storage",this.Ys)}static C(e){return!(!e||!e.localStorage)}async start(){for(let e of(await this.syncEngine.Is())){if(e===this.Js)continue;let t=this.getItem(oh(this.persistenceKey,e));if(t){let n=ow.Gs(e,t);n&&(this.Xs=this.Xs.insert(n.clientId,n))}}this.uo();let e=this.storage.getItem(this._o);if(e){let t=this.co(e);t&&this.lo(t)}for(let e of this.eo)this.Zs(e);this.eo=[],this.window.addEventListener("pagehide",()=>this.shutdown()),this.started=!0}writeSequenceNumber(e){this.setItem(this.ro,JSON.stringify(e))}getAllActiveQueryTargets(){return this.ho(this.Xs)}isActiveQueryTarget(e){let t=!1;return this.Xs.forEach((n,r)=>{r.activeTargetIds.has(e)&&(t=!0)}),t}addPendingMutation(e){this.Po(e,"pending")}updateMutationState(e,t,n){this.Po(e,t,n),this.To(e)}addLocalQueryTarget(e,t=!0){let n="not-current";if(this.isActiveQueryTarget(e)){let t=this.storage.getItem(om(this.persistenceKey,e));if(t){let r=ov.Gs(e,t);r&&(n=r.state)}}return t&&this.Io.js(e),this.uo(),n}removeLocalQueryTarget(e){this.Io.Hs(e),this.uo()}isLocalQueryTarget(e){return this.Io.activeTargetIds.has(e)}clearQueryState(e){this.removeItem(om(this.persistenceKey,e))}updateQueryState(e,t,n){this.Eo(e,t,n)}
20handleUserChange(e,t,n){t.forEach(e=>{this.To(e)}),this.currentUser=e,n.forEach(e=>{this.addPendingMutation(e)})}setOnlineState(e){this.Ao(e)}notifyBundleLoaded(e){this.Ro(e)}shutdown(){this.started&&(this.window.removeEventListener("storage",this.Ys),this.removeItem(this.no),this.started=!1)}getItem(e){let t=this.storage.getItem(e);return P(og,"READ",e,t),t}setItem(e,t){P(og,"SET",e,t),this.storage.setItem(e,t)}removeItem(e){P(og,"REMOVE",e),this.storage.removeItem(e)}Zs(e){if(e.storageArea===this.storage){if(P(og,"EVENT",e.key,e.newValue),e.key===this.no)return void L("Received WebStorage notification for local change. Another client might have garbage-collected our state");this.xi.enqueueRetryable(async()=>{if(this.started){if(null!==e.key){if(this.io.test(e.key)){if(null==e.newValue){let t=this.Vo(e.key);return this.mo(t,null)}{let t=this.fo(e.key,e.newValue);if(t)return this.mo(t.clientId,t)}}else if(this.so.test(e.key)){if(null!==e.newValue){let t=this.po(e.key,e.newValue);if(t)return this.yo(t)}}else if(this.oo.test(e.key)){if(null!==e.newValue){let t=this.wo(e.key,e.newValue);if(t)return this.bo(t)}}else if(e.key===this._o){if(null!==e.newValue){let t=this.co(e.newValue);if(t)return this.lo(t)}}else if(e.key===this.ro){let t=function(e){let t=eq.le;if(null!=e)try{let n=JSON.parse(e);j("number"==typeof n,30636,{So:e}),t=n}catch(e){L(og,"Failed to read sequence number from WebStorage",e)}return t}(e.newValue);t!==eq.le&&this.sequenceNumberHandler(t)}else if(e.key===this.ao){let t=this.Do(e.newValue);await Promise.all(t.map(e=>this.syncEngine.vo(e)))}}}else this.eo.push(e)})}}get Io(){return this.Xs.get(this.Js)}uo(){this.setItem(this.no,this.Io.zs())}Po(e,t,n){let r=new oy(this.currentUser,e,t,n),i=of(this.persistenceKey,this.currentUser,e);this.setItem(i,r.zs())}To(e){let t=of(this.persistenceKey,this.currentUser,e);this.removeItem(t)}Ao(e){let t={clientId:this.Js,onlineState:e};this.storage.setItem(this._o,JSON.stringify(t))}Eo(e,t,n){let r=om(this.persistenceKey,e),i=new ov(e,t,n);this.setItem(r,i.zs())}Ro(e){let t=JSON.stringify(Array.from(e));this.setItem(this.ao,t)}Vo(e){let t=this.io.exec(e);return t?t[1]:null}fo(e,t){let n=this.Vo(e);return ow.Gs(n,t)}po(e,t){let n=this.so.exec(e),r=Number(n[1]),i=void 0!==n[2]?n[2]:null;return oy.Gs(new A(i),r,t)}wo(e,t){let n=Number(this.oo.exec(e)[1]);return ov.Gs(n,t)}co(e){return ob.Gs(e)}Do(e){return JSON.parse(e)}async yo(e){if(e.user.uid===this.currentUser.uid)return this.syncEngine.Co(e.batchId,e.state,e.error);P(og,`Ignoring mutation for non-active user ${e.user.uid}`)}bo(e){return this.syncEngine.Fo(e.targetId,e.state,e.error)}mo(e,t){let n=t?this.Xs.insert(e,t):this.Xs.remove(e),r=this.ho(this.Xs),i=this.ho(n),s=[],o=[];return i.forEach(e=>{r.has(e)||s.push(e)}),r.forEach(e=>{i.has(e)||o.push(e)}),this.syncEngine.Mo(s,o).then(()=>{this.Xs=n})}lo(e){this.Xs.get(e.clientId)&&this.onlineStateHandler(e.onlineState)}ho(e){let t=rb;return e.forEach((e,n)=>{t=t.unionWith(n.activeTargetIds)}),t}}class oE{constructor(){this.xo=new o_,this.Oo={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,t,n){}addLocalQueryTarget(e,t=!0){return t&&this.xo.js(e),this.Oo[e]||"not-current"}updateQueryState(e,t,n){this.Oo[e]=t}removeLocalQueryTarget(e){this.xo.Hs(e)}isLocalQueryTarget(e){return this.xo.activeTargetIds.has(e)}clearQueryState(e){delete this.Oo[e]}getAllActiveQueryTargets(){return this.xo.activeTargetIds}isActiveQueryTarget(e){return this.xo.activeTargetIds.has(e)}start(){return this.xo=new o_,Promise.resolve()}handleUserChange(e,t,n){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}}class oT{No(e){}shutdown(){}}let oS="ConnectivityMonitor";class oC{constructor(){this.Bo=()=>this.Lo(),this.ko=()=>this.qo(),this.Qo=[],this.$o()}No(e){this.Qo.push(e)}shutdown(){window.removeEventListener("online",this.Bo),window.removeEventListener("offline",this.ko)}$o(){window.addEventListener("online",this.Bo),window.addEventListener("offline",this.ko)}Lo(){for(let e of(P(oS,"Network connectivity changed: AVAILABLE"),this.Qo))e(0)}qo(){for(let e of(P(oS,"Network connectivity changed: UNAVAILABLE"),this.Qo))e(1)}static C(){return"undefined"!=typeof window&&void 0!==window.addEventListener&&void 0!==window.removeEventListener}}let ox=null;function ok(){return null===ox?ox=268435456+Math.round(2147483648*Math.random()):ox++,"0x"+ox.toString(16)}let oA="RestConnection",oR={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregation
20Query:"runAggregationQuery"};class oN{get Uo(){return!1}constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;let t=e.ssl?"https":"http",n=encodeURIComponent(this.databaseId.projectId),r=encodeURIComponent(this.databaseId.database);this.Ko=t+"://"+e.host,this.Wo=`projects/${n}/databases/${r}`,this.Go=this.databaseId.database===nn?`project_id=${n}`:`project_id=${n}&database_id=${r}`}zo(e,t,n,r,i){let s=ok(),o=this.jo(e,t.toUriEncodedString());P(oA,`Sending RPC '${e}' ${s}:`,o,n);let a={"google-cloud-resource-prefix":this.Wo,"x-goog-request-params":this.Go};this.Ho(a,r,i);let{host:l}=new URL(o),u=(0,b.Xx)(l);return this.Jo(e,o,a,n,u).then(t=>(P(oA,`Received RPC '${e}' ${s}: `,t),t),t=>{throw M(oA,`RPC '${e}' ${s} failed with error: `,t,"url: ",o,"request:",n),t})}Yo(e,t,n,r,i,s){return this.zo(e,t,n,r,i)}Ho(e,t,n){e["X-Goog-Api-Client"]="gl-js/ fire/"+R,e["Content-Type"]="text/plain",this.databaseInfo.appId&&(e["X-Firebase-GMPID"]=this.databaseInfo.appId),t&&t.headers.forEach((t,n)=>e[n]=t),n&&n.headers.forEach((t,n)=>e[n]=t)}jo(e,t){let n=oR[e];return`${this.Ko}/v1/${t}:${n}`}terminate(){}}class oO{constructor(e){this.Zo=e.Zo,this.Xo=e.Xo}e_(e){this.t_=e}n_(e){this.r_=e}i_(e){this.s_=e}onMessage(e){this.o_=e}close(){this.Xo()}send(e){this.Zo(e)}__(){this.t_()}a_(){this.r_()}u_(e){this.s_(e)}c_(e){this.o_(e)}}let oD="WebChannelConnection";class oP extends oN{constructor(e){super(e),this.l_=[],this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}Jo(e,t,n,r,i){let o=ok();return new Promise((i,u)=>{let c=new s;c.setWithCredentials(!0),c.listenOnce(a.COMPLETE,()=>{try{switch(c.getLastErrorCode()){case l.NO_ERROR:let t=c.getResponseJson();P(oD,`XHR for RPC '${e}' ${o} received:`,JSON.stringify(t)),i(t);break;case l.TIMEOUT:P(oD,`RPC '${e}' ${o} timed out`),u(new z(q.DEADLINE_EXCEEDED,"Request time out"));break;case l.HTTP_ERROR:let n=c.getStatus();if(P(oD,`RPC '${e}' ${o} failed with status:`,n,"response text:",c.getResponseText()),n>0){let e=c.getResponseJson();Array.isArray(e)&&(e=e[0]);let t=null==e?void 0:e.error;if(t&&t.status&&t.message){let e=function(e){let t=e.toLowerCase().replace(/_/g,"-");return Object.values(q).indexOf(t)>=0?t:q.UNKNOWN}(t.status);u(new z(e,t.message))}else u(new z(q.UNKNOWN,"Server responded with status "+c.getStatus()))}else u(new z(q.UNAVAILABLE,"Connection failed."));break;default:U(9055,{h_:e,streamId:o,P_:c.getLastErrorCode(),T_:c.getLastError()})}}finally{P(oD,`RPC '${e}' ${o} completed.`)}});let h=JSON.stringify(r);P(oD,`RPC '${e}' ${o} sending request:`,r),c.send(t,"POST",h,n,15)})}I_(e,t,n){let r=ok(),i=[this.Ko,"/","google.firestore.v1.Firestore","/",e,"/channel"],s=d(),a=h(),l={httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:`projects/${this.databaseId.projectId}/databases/${this.databaseId.database}`},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling,detectBufferingProxy:this.autoDetectLongPolling},p=this.longPollingOptions.timeoutSeconds;void 0!==p&&(l.longPollingTimeout=Math.round(1e3*p)),this.useFetchStreams&&(l.useFetchStreams=!0),this.Ho(l.initMessageHeaders,t,n),l.encodeInitMessageHeaders=!0;let m=i.join("");P(oD,`Creating RPC '${e}' stream ${r}: ${m}`,l);let g=s.createWebChannel(m,l);this.E_(g);let y=!1,v=!1,w=new oO({Zo:t=>{v?P(oD,`Not sending because RPC '${e}' stream ${r} is closed:`,t):(y||(P(oD,`Opening RPC '${e}' stream ${r} transport.`),g.open(),y=!0),P(oD,`RPC '${e}' stream ${r} sending:`,t),g.send(t))},Xo:()=>g.close()}),b=(e,t,n)=>{e.listen(t,e=>{try{n(e)}catch(e){setTimeout(()=>{throw e},0)}})};return b(g,o.EventType.OPEN,()=>{v||(P(oD,`RPC '${e}' stream ${r} transport opened.`),w.__())}),b(g,o.EventType.CLOSE,()=>{v||(v=!0,P(oD,`RPC '${e}' stream ${r} transport closed`),w.u_(),this.d_(g))}),b(g,o.EventType.ERROR,t=>{v||(v=!0,M(oD,`RPC '${e}' stream ${r} transport errored. Name:`,t.name,"Message:",t.message),w.u_(new z(q.UNAVAILABLE,"The operation could not be completed")))}),b(g,o.EventType.MESSAGE,t=>{var n;if(!v){let i=t.data[0];j(!!i,16349);let s=(null==i?void 0:i.error)||(null===(n=i[0])||void 0===n?void 0:n.error);if(s){P(oD,`RPC '${e}' stream ${r} received error:`,s);let t=s.status,n=function(e){let t=f[e];if(void 0!==t)return r1(t)}(t),i=s.message;void 0===n&&(n=q.INTERNAL,i="Unknown error status: "+t+" with message "+s.message),v=!0,w.u_(new z(n,i)),g.close()}else P(oD,`RPC '${e}' stream ${r} received:`,i),w.c_(i)}}),b(a,c.STAT_EVENT,t=>{t.stat===u.PROXY?P(oD,`RPC '${e}' stream ${r} detected buffering proxy`):t.stat===u.NOPROXY&&P(oD,`RPC '${e}' stream ${r} detected no buffering proxy`)}),setTimeout(()=>{w.a_()},0),w}
20terminate(){this.l_.forEach(e=>e.close()),this.l_=[]}E_(e){this.l_.push(e)}d_(e){this.l_=this.l_.filter(t=>t===e)}}function oL(){return"undefined"!=typeof window?window:null}function oM(){return"undefined"!=typeof document?document:null}function oF(e){return new ih(e,!0)}class oU{constructor(e,t,n=1e3,r=1.5,i=6e4){this.xi=e,this.timerId=t,this.A_=n,this.R_=r,this.V_=i,this.m_=0,this.f_=null,this.g_=Date.now(),this.reset()}reset(){this.m_=0}p_(){this.m_=this.V_}y_(e){this.cancel();let t=Math.floor(this.m_+this.w_()),n=Math.max(0,Date.now()-this.g_),r=Math.max(0,t-n);r>0&&P("ExponentialBackoff",`Backing off for ${r} ms (base delay: ${this.m_} ms, delay with jitter: ${t} ms, last attempt: ${n} ms ago)`),this.f_=this.xi.enqueueAfterDelay(this.timerId,r,()=>(this.g_=Date.now(),e())),this.m_*=this.R_,this.m_<this.A_&&(this.m_=this.A_),this.m_>this.V_&&(this.m_=this.V_)}b_(){null!==this.f_&&(this.f_.skipDelay(),this.f_=null)}cancel(){null!==this.f_&&(this.f_.cancel(),this.f_=null)}w_(){return(Math.random()-.5)*this.m_}}let oV="PersistentStream";class oj{constructor(e,t,n,r,i,s,o,a){this.xi=e,this.S_=n,this.D_=r,this.connection=i,this.authCredentialsProvider=s,this.appCheckCredentialsProvider=o,this.listener=a,this.state=0,this.v_=0,this.C_=null,this.F_=null,this.stream=null,this.M_=0,this.x_=new oU(e,t)}O_(){return 1===this.state||5===this.state||this.N_()}N_(){return 2===this.state||3===this.state}start(){this.M_=0,4!==this.state?this.auth():this.B_()}async stop(){this.O_()&&await this.close(0)}L_(){this.state=0,this.x_.reset()}k_(){this.N_()&&null===this.C_&&(this.C_=this.xi.enqueueAfterDelay(this.S_,6e4,()=>this.q_()))}Q_(e){this.U_(),this.stream.send(e)}async q_(){if(this.N_())return this.close(0)}U_(){this.C_&&(this.C_.cancel(),this.C_=null)}K_(){this.F_&&(this.F_.cancel(),this.F_=null)}async close(e,t){this.U_(),this.K_(),this.x_.cancel(),this.v_++,4!==e?this.x_.reset():t&&t.code===q.RESOURCE_EXHAUSTED?(L(t.toString()),L("Using maximum backoff delay to prevent overloading the backend."),this.x_.p_()):t&&t.code===q.UNAUTHENTICATED&&3!==this.state&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),null!==this.stream&&(this.W_(),this.stream.close(),this.stream=null),this.state=e,await this.listener.i_(t)}W_(){}auth(){this.state=1;let e=this.G_(this.v_),t=this.v_;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then(([e,n])=>{this.v_===t&&this.z_(e,n)},t=>{e(()=>{let e=new z(q.UNKNOWN,"Fetching auth token failed: "+t.message);return this.j_(e)})})}z_(e,t){let n=this.G_(this.v_);this.stream=this.H_(e,t),this.stream.e_(()=>{n(()=>this.listener.e_())}),this.stream.n_(()=>{n(()=>(this.state=2,this.F_=this.xi.enqueueAfterDelay(this.D_,1e4,()=>(this.N_()&&(this.state=3),Promise.resolve())),this.listener.n_()))}),this.stream.i_(e=>{n(()=>this.j_(e))}),this.stream.onMessage(e=>{n(()=>1==++this.M_?this.J_(e):this.onNext(e))})}B_(){this.state=5,this.x_.y_(async()=>{this.state=0,this.start()})}j_(e){return P(oV,`close with error: ${e}`),this.stream=null,this.close(4,e)}G_(e){return t=>{this.xi.enqueueAndForget(()=>this.v_===e?t():(P(oV,"stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve()))}}}class oB extends oj{constructor(e,t,n,r,i,s){super(e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",t,n,r,s),this.serializer=i}H_(e,t){return this.connection.I_("Listen",e,t)}J_(e){return this.onNext(e)}onNext(e){this.x_.reset();let t=function(e,t){let n;if("targetChange"in t){var r,i;t.targetChange;let s="NO_CHANGE"===(r=t.targetChange.targetChangeType||"NO_CHANGE")?0:"ADD"===r?1:"REMOVE"===r?2:"CURRENT"===r?3:"RESET"===r?4:U(39313,{state:r}),o=t.targetChange.targetIds||[],a=(i=t.targetChange.resumeToken,e.useProto3Json?(j(void 0===i||"string"==typeof i,58123),tZ.fromBase64String(i||"")):(j(void 0===i||i instanceof C||i instanceof Uint8Array,16193),tZ.fromUint8Array(i||new Uint8Array))),l=t.targetChange.cause;n=new ir(s,o,a,l&&new z(void 0===l.code?q.UNKNOWN:r1(l.code),l.message||"")||null)}else if("documentChange"in t){t.documentChange;let r=t.documentChange;r.document,r.document.name,r.document.updateTime;let i=i_(e,r.document.name),s=ig(r.document.updateTime),o=r.document.createTime?ig(r.document.createTime):ea.min(),a=new nA({mapValue:{fields:r.document.fields}}),l=nR.newFoundDocument(i,s,o,a);n=new ie(r.targetIds||[],r.removedTargetIds||[],l.key,l)}else if("documentDelete"in t){t.documentDelete;let r=t.documentDelete;r.document;let i=i_(e,r.document),s=r.readTime?ig(r.readTime):ea.min(),o=nR.newNoDocument(i,s);n=new ie([],r.removedTargetIds||[],o.key,o)}else if("documentRemove"in t){t.documentRemove;let r=t.documentRemove;r.document;let i=i_(e,r.document);n=new ie([],r.removedTargetIds||[],i,null)}else{if(!("filter"in t))return U(11601,{Vt:t});{t.filter;let e=t.filter;e.targetId;
20let{count:r=0,unchangedNames:i}=e,s=new rZ(r,i);n=new it(e.targetId,s)}}return n}(this.serializer,e),n=function(e){if(!("targetChange"in e))return ea.min();let t=e.targetChange;return t.targetIds&&t.targetIds.length?ea.min():t.readTime?ig(t.readTime):ea.min()}(e);return this.listener.Y_(t,n)}Z_(e){let t={};t.database=iT(this.serializer),t.addTarget=function(e,t){let n;let r=t.target;if((n=n1(r)?{documents:iR(e,r)}:{query:iN(e,r).gt}).targetId=t.targetId,t.resumeToken.approximateByteSize()>0){n.resumeToken=im(e,t.resumeToken);let r=id(e,t.expectedCount);null!==r&&(n.expectedCount=r)}else if(t.snapshotVersion.compareTo(ea.min())>0){n.readTime=ip(e,t.snapshotVersion.toTimestamp());let r=id(e,t.expectedCount);null!==r&&(n.expectedCount=r)}return n}(this.serializer,e);let n=function(e,t){let n=function(e){switch(e){case"TargetPurposeListen":return null;case"TargetPurposeExistenceFilterMismatch":return"existence-filter-mismatch";case"TargetPurposeExistenceFilterMismatchBloom":return"existence-filter-mismatch-bloom";case"TargetPurposeLimboResolution":return"limbo-document";default:return U(28987,{purpose:e})}}(t.purpose);return null==n?null:{"goog-listen-tags":n}}(this.serializer,e);n&&(t.labels=n),this.Q_(t)}X_(e){let t={};t.database=iT(this.serializer),t.removeTarget=e,this.Q_(t)}}class oq extends oj{constructor(e,t,n,r,i,s){super(e,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",t,n,r,s),this.serializer=i}get ea(){return this.M_>0}start(){this.lastStreamToken=void 0,super.start()}W_(){this.ea&&this.ta([])}H_(e,t){return this.connection.I_("Write",e,t)}J_(e){return j(!!e.streamToken,31322),this.lastStreamToken=e.streamToken,j(!e.writeResults||0===e.writeResults.length,55816),this.listener.na()}onNext(e){var t,n;j(!!e.streamToken,12678),this.lastStreamToken=e.streamToken,this.x_.reset();let r=(t=e.writeResults,n=e.commitTime,t&&t.length>0?(j(void 0!==n,14353),t.map(e=>{let t;return(t=e.updateTime?ig(e.updateTime):ig(n)).isEqual(ea.min())&&(t=ig(n)),new rL(t,e.transformResults||[])})):[]),i=ig(e.commitTime);return this.listener.ra(i,r)}ia(){let e={};e.database=iT(this.serializer),this.Q_(e)}ta(e){let t={streamToken:this.lastStreamToken,writes:e.map(e=>ik(this.serializer,e))};this.Q_(t)}}class oz{}class o$ extends oz{constructor(e,t,n,r){super(),this.authCredentials=e,this.appCheckCredentials=t,this.connection=n,this.serializer=r,this.sa=!1}oa(){if(this.sa)throw new z(q.FAILED_PRECONDITION,"The client has already been terminated.")}zo(e,t,n,r){return this.oa(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([i,s])=>this.connection.zo(e,iv(t,n),r,i,s)).catch(e=>{throw"FirebaseError"===e.name?(e.code===q.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new z(q.UNKNOWN,e.toString())})}Yo(e,t,n,r,i){return this.oa(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([s,o])=>this.connection.Yo(e,iv(t,n),r,s,o,i)).catch(e=>{throw"FirebaseError"===e.name?(e.code===q.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new z(q.UNKNOWN,e.toString())})}terminate(){this.sa=!0,this.connection.terminate()}}class oK{constructor(e,t){this.asyncQueue=e,this.onlineStateHandler=t,this.state="Unknown",this._a=0,this.aa=null,this.ua=!0}ca(){0===this._a&&(this.la("Unknown"),this.aa=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,()=>(this.aa=null,this.ha("Backend didn't respond within 10 seconds."),this.la("Offline"),Promise.resolve())))}Pa(e){"Online"===this.state?this.la("Unknown"):(this._a++,this._a>=1&&(this.Ta(),this.ha(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.la("Offline")))}set(e){this.Ta(),this._a=0,"Online"===e&&(this.ua=!1),this.la(e)}la(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}ha(e){let t=`Could not reach Cloud Firestore backend. ${e} 21This 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.ua?(L(t),this.ua=!1):P("OnlineStateTracker",t)}Ta(){null!==this.aa&&(this.aa.cancel(),this.aa=null)}}let oG="RemoteStore";class oH{constructor(e,t,n,r,i){this.localStore=e,this.datastore=t,this.asyncQueue=n,this.remoteSyncer={},this.Ia=[],this.Ea=new Map,this.da=new Set,this.Aa=[],this.Ra=i,this.Ra.No(e=>{n.enqueueAndForget(async()=>
21{o2(this)&&(P(oG,"Restarting streams for network reachability change."),await async function(e){e.da.add(4),await oQ(e),e.Va.set("Unknown"),e.da.delete(4),await oW(e)}(this))})}),this.Va=new oK(n,r)}}async function oW(e){if(o2(e))for(let t of e.Aa)await t(!0)}async function oQ(e){for(let t of e.Aa)await t(!1)}function oX(e,t){e.Ea.has(t.targetId)||(e.Ea.set(t.targetId,t),o1(e)?o0(e):al(e).N_()&&oJ(e,t))}function oY(e,t){let n=al(e);e.Ea.delete(t),n.N_()&&oZ(e,t),0===e.Ea.size&&(n.N_()?n.k_():o2(e)&&e.Va.set("Unknown"))}function oJ(e,t){if(e.ma.Ke(t.targetId),t.resumeToken.approximateByteSize()>0||t.snapshotVersion.compareTo(ea.min())>0){let n=e.remoteSyncer.getRemoteKeysForTarget(t.targetId).size;t=t.withExpectedCount(n)}al(e).Z_(t)}function oZ(e,t){e.ma.Ke(t),al(e).X_(t)}function o0(e){e.ma=new is({getRemoteKeysForTarget:t=>e.remoteSyncer.getRemoteKeysForTarget(t),Rt:t=>e.Ea.get(t)||null,Pt:()=>e.datastore.serializer.databaseId}),al(e).start(),e.Va.ca()}function o1(e){return o2(e)&&!al(e).O_()&&e.Ea.size>0}function o2(e){return 0===e.da.size}async function o4(e){e.Va.set("Online")}async function o6(e){e.Ea.forEach((t,n)=>{oJ(e,t)})}async function o5(e,t){e.ma=void 0,o1(e)?(e.Va.Pa(t),o0(e)):e.Va.set("Unknown")}async function o9(e,t,n){if(e.Va.set("Online"),t instanceof ir&&2===t.state&&t.cause)try{await async function(e,t){let n=t.cause;for(let r of t.targetIds)e.Ea.has(r)&&(await e.remoteSyncer.rejectListen(r,n),e.Ea.delete(r),e.ma.removeTarget(r))}(e,t)}catch(n){P(oG,"Failed to remove targets %s: %s ",t.targetIds.join(","),n),await o3(e,n)}else if(t instanceof ie?e.ma.Xe(t):t instanceof it?e.ma.ot(t):e.ma.nt(t),!n.isEqual(ea.min()))try{let t=await oe(e.localStore);n.compareTo(t)>=0&&await function(e,t){let n=e.ma.It(t);
21return n.targetChanges.forEach((n,r)=>{if(n.resumeToken.approximateByteSize()>0){let i=e.Ea.get(r);i&&e.Ea.set(r,i.withResumeToken(n.resumeToken,t))}}),n.targetMismatches.forEach((t,n)=>{let r=e.Ea.get(t);if(!r)return;e.Ea.set(t,r.withResumeToken(tZ.EMPTY_BYTE_STRING,r.snapshotVersion)),oZ(e,t);let i=new iF(r.target,t,n,r.sequenceNumber);oJ(e,i)}),e.remoteSyncer.applyRemoteEvent(n)}(e,n)}catch(t){P(oG,"Failed to raise snapshot:",t),await o3(e,t)}}async function o3(e,t,n){if(!eP(t))throw t;e.da.add(1),await oQ(e),e.Va.set("Offline"),n||(n=()=>oe(e.localStore)),e.asyncQueue.enqueueRetryable(async()=>{P(oG,"Retrying IndexedDB access"),await n(),e.da.delete(1),await oW(e)})}function o8(e,t){return t().catch(n=>o3(e,n,t))}async function o7(e){let t=au(e),n=e.Ia.length>0?e.Ia[e.Ia.length-1].batchId:-1;for(;o2(e)&&e.Ia.length<10;)try{let r=await function(e,t){return e.persistence.runTransaction("Get next mutation batch","readonly",n=>(void 0===t&&(t=-1),e.mutationQueue.getNextMutationBatchAfterBatchId(n,t)))}(e.localStore,n);if(null===r){0===e.Ia.length&&t.k_();break}n=r.batchId,function(e,t){e.Ia.push(t);let n=au(e);n.N_()&&n.ea&&n.ta(t.mutations)}(e,r)}catch(t){await o3(e,t)}ae(e)&&at(e)}function ae(e){return o2(e)&&!au(e).O_()&&e.Ia.length>0}function at(e){au(e).start()}async function an(e){au(e).ia()}async function ar(e){let t=au(e);for(let n of e.Ia)t.ta(n.mutations)}async function ai(e,t,n){let r=e.Ia.shift(),i=rX.from(r,t,n);await o8(e,()=>e.remoteSyncer.applySuccessfulWrite(i)),await o7(e)}async function as(e,t){t&&au(e).ea&&await async function(e,t){var n;if(r0(n=t.code)&&n!==q.ABORTED){let n=e.Ia.shift();au(e).L_(),await o8(e,()=>e.remoteSyncer.rejectFailedWrite(n.batchId,t)),await o7(e)}}(e,t),ae(e)&&at(e)}async function ao(e,t){e.asyncQueue.verifyOperationInProgress(),P(oG,"RemoteStore received new credentials");let n=o2(e);e.da.add(3),await oQ(e),n&&e.Va.set("Unknown"),await e.remoteSyncer.handleCredentialChange(t),e.da.delete(3),await oW(e)}async function aa(e,t){t?(e.da.delete(2),await oW(e)):t||(e.da.add(2),await oQ(e),e.Va.set("Unknown"))}function al(e){var t,n,r;return e.fa||(e.fa=(t=e.datastore,n=e.asyncQueue,r={e_:o4.bind(null,e),n_:o6.bind(null,e),i_:o5.bind(null,e),Y_:o9.bind(null,e)},t.oa(),new oB(n,t.connection,t.authCredentials,t.appCheckCredentials,t.serializer,r)),e.Aa.push(async t=>{t?(e.fa.L_(),o1(e)?o0(e):e.Va.set("Unknown")):(await e.fa.stop(),e.ma=void 0)})),e.fa}function au(e){var t,n,r;return e.ga||(e.ga=(t=e.datastore,n=e.asyncQueue,r={e_:()=>Promise.resolve(),n_:an.bind(null,e),i_:as.bind(null,e),na:ar.bind(null,e),ra:ai.bind(null,e)},t.oa(),new oq(n,t.connection,t.authCredentials,t.appCheckCredentials,t.serializer,r)),e.Aa.push(async t=>{t?(e.ga.L_(),await o7(e)):(await e.ga.stop(),e.Ia.length>0&&(P(oG,`Stopping write stream with ${e.Ia.length} pending writes`),e.Ia=[]))})),e.ga}class ac{constructor(e,t,n,r,i){this.asyncQueue=e,this.timerId=t,this.targetTimeMs=n,this.op=r,this.removalCallback=i,this.deferred=new $,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch(e=>{})}get promise(){return this.deferred.promise}static createAndSchedule(e,t,n,r,i){let s=new ac(e,t,Date.now()+n,r,i);return s.start(n),s}start(e){this.timerHandle=setTimeout(()=>this.handleDelayElapsed(),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){null!==this.timerHandle&&(this.clearTimeout(),this.deferred.reject(new z(q.CANCELLED,"Operation cancelled"+(e?": "+e:""))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget(()=>null!==this.timerHandle?(this.clearTimeout(),this.op().then(e=>this.deferred.resolve(e))):Promise.resolve())}clearTimeout(){null!==this.timerHandle&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}}function ah(e,t){if(L("AsyncQueue",`${t}: ${e}`),eP(e))return new z(q.UNAVAILABLE,`${t}: ${e}`);throw e}class ad{static emptySet(e){return new ad(e.comparator)}constructor(e){this.comparator=e?(t,n)=>e(t,n)||ef.comparator(t.key,n.key):(e,t)=>ef.comparator(e.key,t.key),this.keyedMap=rp(),this.sortedSet=new t$(this.comparator)}has(e){return null!=this.keyedMap.get(e)}get(e){return this.keyedMap.get(e)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(e){let t=this.keyedMap.get(e);return t?this.sortedSet.indexOf(t):-1}get size(){return this.sortedSet.size}forEach(e){this.sortedSet.inorderTraversal((t,n)=>(e(t),!1))}add(e){let t=this.delete(e.key);return t.copy(t.keyedMap.insert(e.key,e),t.sortedSet.insert(e,null))}delete(e){let t=this.get(e);return t?this.copy(this.keyedMap.remove(e),this.sortedSet.remove(t)):this}isEqual(e){if(!(e instanceof ad)||this.size!==e.size)return!1;let t=this.sortedSet.getIterator(),n=e.sortedSet.getIterator();for(;t.hasNext();){let e=t.getNext().key,r=n.getNext().key;if(!e.isEqual(r))return!1}return!0}toString(){let e=[];return this.forEach(t=>{e.push(t.toString())}),0===e.length?"DocumentSet ()":"DocumentSet (\n "+e.join(" \n")+"\n)"}copy(e,t){let n=new ad;return n.comparator=this.comparator,n.keyedMap=e,n.sortedSet=t,n}}class af{constructor(){this.pa=new t$(ef.comparator)}track(e){let t=e.doc.key,n=this.pa.get(t);n?0!==e.type&&3===n.type?this.pa=this.pa.insert(t,e):3===e.type&&1!==n.type?this.pa=this.pa.insert(t,{type:n.type,doc:e.doc}):2===e.type&&2===n.type?this.pa=this.pa.insert(t,{type:2,doc:e.doc}):2===e.type&&0===n.type?this.pa=this.pa.insert(t,{type:0,doc:e.doc}):1===e.type&&0===n.type?this.pa=this.pa.remove(t):1===e.type&&2===n.type?this.pa=this.pa.insert(t,{type:1,doc:n.doc}):0===e.type&&1===n.type?this.pa=this.pa.insert(t,{type:2,doc:e.doc}):U(63341,{Vt:e,ya:n}):this.pa=this.pa.insert(t,e)}wa(){let e=[];return this.pa.inorderTraversal((t,n)=>{e.push(n)}),e}}class ap{constructor(e,t,n,r,i,s,o,a,l){this.query=e,this.docs=t,this.oldDocs=n,this.docChanges=r,this.mutatedKeys=i,this.fromCache=s,this.syncStateChanged=o,this.excludesMetadataChanges=a,this.hasCachedResults=l}static fromInitialDocuments(e,t,n,r,i){let s=[];
21return t.forEach(e=>{s.push({type:0,doc:e})}),new ap(e,t,ad.emptySet(t),s,n,r,!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)&&rs(this.query,e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;let t=this.docChanges,n=e.docChanges;if(t.length!==n.length)return!1;for(let e=0;e<t.length;e++)if(t[e].type!==n[e].type||!t[e].doc.isEqual(n[e].doc))return!1;return!0}}class am{constructor(){this.ba=void 0,this.Sa=[]}Da(){return this.Sa.some(e=>e.va())}}class ag{constructor(){this.queries=ay(),this.onlineState="Unknown",this.Ca=new Set}terminate(){!function(e,t){let n=e.queries;e.queries=ay(),n.forEach((e,n)=>{for(let e of n.Sa)e.onError(t)})}(this,new z(q.ABORTED,"Firestore shutting down"))}}function ay(){return new rh(e=>ro(e),rs)}async function av(e,t){let n=3,r=t.query,i=e.queries.get(r);i?!i.Da()&&t.va()&&(n=2):(i=new am,n=t.va()?0:1);try{switch(n){case 0:i.ba=await e.onListen(r,!0);break;case 1:i.ba=await e.onListen(r,!1);break;case 2:await e.onFirstRemoteStoreListen(r)}}catch(n){let e=ah(n,`Initialization of query '${ra(t.query)}' failed`);return void t.onError(e)}e.queries.set(r,i),i.Sa.push(t),t.Fa(e.onlineState),i.ba&&t.Ma(i.ba)&&aI(e)}async function aw(e,t){let n=t.query,r=3,i=e.queries.get(n);if(i){let e=i.Sa.indexOf(t);e>=0&&(i.Sa.splice(e,1),0===i.Sa.length?r=t.va()?0:1:!i.Da()&&t.va()&&(r=2))}switch(r){case 0:return e.queries.delete(n),e.onUnlisten(n,!0);case 1:return e.queries.delete(n),e.onUnlisten(n,!1);case 2:return e.onLastRemoteStoreUnlisten(n);default:return}}function ab(e,t){let n=!1;for(let r of t){let t=r.query,i=e.queries.get(t);if(i){for(let e of i.Sa)e.Ma(r)&&(n=!0);i.ba=r}}n&&aI(e)}function a_(e,t,n){let r=e.queries.get(t);if(r)for(let e of r.Sa)e.onError(n);e.queries.delete(t)}function aI(e){e.Ca.forEach(e=>{e.next()})}(g=m||(m={})).xa="default",g.Cache="cache";class aE{constructor(e,t,n){this.query=e,this.Oa=t,this.Na=!1,this.Ba=null,this.onlineState="Unknown",this.options=n||{}}Ma(e){if(!this.options.includeMetadataChanges){let t=[];for(let n of e.docChanges)3!==n.type&&t.push(n);e=new ap(e.query,e.docs,e.oldDocs,t,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let t=!1;return this.Na?this.La(e)&&(this.Oa.next(e),t=!0):this.ka(e,this.onlineState)&&(this.qa(e),t=!0),this.Ba=e,t}onError(e){this.Oa.error(e)}Fa(e){this.onlineState=e;let t=!1;return this.Ba&&!this.Na&&this.ka(this.Ba,e)&&(this.qa(this.Ba),t=!0),t}ka(e,t){return!(e.fromCache&&this.va())||(!this.options.Qa||!("Offline"!==t))&&(!e.docs.isEmpty()||e.hasCachedResults||"Offline"===t)}La(e){if(e.docChanges.length>0)return!0;let t=this.Ba&&this.Ba.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&!0===this.options.includeMetadataChanges}qa(e){e=ap.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.Na=!0,this.Oa.next(e)}va(){return this.options.source!==m.Cache}}class aT{constructor(e,t){this.$a=e,this.byteLength=t}Ua(){return"metadata"in this.$a}}class aS{constructor(e){this.serializer=e}Us(e){return i_(this.serializer,e)}Ks(e){return e.metadata.exists?ix(this.serializer,e.document,!1):nR.newNoDocument(this.Us(e.metadata.name),this.Ws(e.metadata.readTime))}Ws(e){return ig(e)}}class aC{constructor(e,t,n){this.Ka=e,this.localStore=t,this.serializer=n,this.queries=[],this.documents=[],this.collectionGroups=new Set,this.progress=ax(e)}Wa(e){this.progress.bytesLoaded+=e.byteLength;let t=this.progress.documentsLoaded;if(e.$a.namedQuery)this.queries.push(e.$a.namedQuery);else if(e.$a.documentMetadata){this.documents.push({metadata:e.$a.documentMetadata}),e.$a.documentMetadata.exists||++t;let n=ec.fromString(e.$a.documentMetadata.name);this.collectionGroups.add(n.get(n.length-2))}else e.$a.document&&(this.documents[this.documents.length-1].document=e.$a.document,++t);return t!==this.progress.documentsLoaded?(this.progress.documentsLoaded=t,Object.assign({},this.progress)):null}Ga(e){let t=new Map,n=new aS(this.serializer);for(let r of e)if(r.metadata.queries){let e=n.Us(r.metadata.name);for(let n of r.metadata.queries){let r=(t.get(n)||rw()).add(e);t.set(n,r)}}return t}async complete(){let e=await ol(this.localStore,new aS(this.serializer),this.documents,this.Ka.id),t=this.Ga(this.documents);
21for(let e of this.queries)await ou(this.localStore,e,t.get(e.name));return this.progress.taskState="Success",{progress:this.progress,za:this.collectionGroups,ja:e}}}function ax(e){return{taskState:"Running",documentsLoaded:0,bytesLoaded:0,totalDocuments:e.totalDocuments,totalBytes:e.totalBytes}}class ak{constructor(e){this.key=e}}class aA{constructor(e){this.key=e}}class aR{constructor(e,t){this.query=e,this.Ha=t,this.Ja=null,this.hasCachedResults=!1,this.current=!1,this.Ya=rw(),this.mutatedKeys=rw(),this.Za=rc(e),this.Xa=new ad(this.Za)}get eu(){return this.Ha}tu(e,t){let n=t?t.nu:new af,r=t?t.Xa:this.Xa,i=t?t.mutatedKeys:this.mutatedKeys,s=r,o=!1,a="F"===this.query.limitType&&r.size===this.query.limit?r.last():null,l="L"===this.query.limitType&&r.size===this.query.limit?r.first():null;if(e.inorderTraversal((e,t)=>{let u=r.get(e),c=rl(this.query,t)?t:null,h=!!u&&this.mutatedKeys.has(u.key),d=!!c&&(c.hasLocalMutations||this.mutatedKeys.has(c.key)&&c.hasCommittedMutations),f=!1;u&&c?u.data.isEqual(c.data)?h!==d&&(n.track({type:3,doc:c}),f=!0):this.ru(u,c)||(n.track({type:2,doc:c}),f=!0,(a&&this.Za(c,a)>0||l&&0>this.Za(c,l))&&(o=!0)):!u&&c?(n.track({type:0,doc:c}),f=!0):u&&!c&&(n.track({type:1,doc:u}),f=!0,(a||l)&&(o=!0)),f&&(c?(s=s.add(c),i=d?i.add(e):i.delete(e)):(s=s.delete(e),i=i.delete(e)))}),null!==this.query.limit)for(;s.size>this.query.limit;){let e="F"===this.query.limitType?s.last():s.first();s=s.delete(e.key),i=i.delete(e.key),n.track({type:1,doc:e})}return{Xa:s,nu:n,Cs:o,mutatedKeys:i}}ru(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}applyChanges(e,t,n,r){let i=this.Xa;this.Xa=e.Xa,this.mutatedKeys=e.mutatedKeys;let s=e.nu.wa();s.sort((e,t)=>(function(e,t){let n=e=>{switch(e){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return U(20277,{Vt:e})}};return n(e)-n(t)})(e.type,t.type)||this.Za(e.doc,t.doc)),this.iu(n),r=null!=r&&r;let o=t&&!r?this.su():[],a=0===this.Ya.size&&this.current&&!r?1:0,l=a!==this.Ja;return(this.Ja=a,0!==s.length||l)?{snapshot:new ap(this.query,e.Xa,i,s,e.mutatedKeys,0===a,l,!1,!!n&&n.resumeToken.approximateByteSize()>0),ou:o}:{ou:o}}Fa(e){return this.current&&"Offline"===e?(this.current=!1,this.applyChanges({Xa:this.Xa,nu:new af,mutatedKeys:this.mutatedKeys,Cs:!1},!1)):{ou:[]}}_u(e){return!this.Ha.has(e)&&!!this.Xa.has(e)&&!this.Xa.get(e).hasLocalMutations}iu(e){e&&(e.addedDocuments.forEach(e=>this.Ha=this.Ha.add(e)),e.modifiedDocuments.forEach(e=>{}),e.removedDocuments.forEach(e=>this.Ha=this.Ha.delete(e)),this.current=e.current)}su(){if(!this.current)return[];let e=this.Ya;this.Ya=rw(),this.Xa.forEach(e=>{this._u(e.key)&&(this.Ya=this.Ya.add(e.key))});let t=[];return e.forEach(e=>{this.Ya.has(e)||t.push(new aA(e))}),this.Ya.forEach(n=>{e.has(n)||t.push(new ak(n))}),t}au(e){this.Ha=e.$s,this.Ya=rw();let t=this.tu(e.documents);return this.applyChanges(t,!0)}uu(){return ap.fromInitialDocuments(this.query,this.Xa,this.mutatedKeys,0===this.Ja,this.hasCachedResults)}}let aN="SyncEngine";class aO{constructor(e,t,n){this.query=e,this.targetId=t,this.view=n}}class aD{constructor(e){this.key=e,this.cu=!1}}class aP{constructor(e,t,n,r,i,s){this.localStore=e,this.remoteStore=t,this.eventManager=n,this.sharedClientState=r,this.currentUser=i,this.maxConcurrentLimboResolutions=s,this.lu={},this.hu=new rh(e=>ro(e),rs),this.Pu=new Map,this.Tu=new Set,this.Iu=new t$(ef.comparator),this.Eu=new Map,this.du=new sB,this.Au={},this.Ru=new Map,this.Vu=sb.lr(),this.onlineState="Unknown",this.mu=void 0}get isPrimaryClient(){return!0===this.mu}}async function aL(e,t,n=!0){let r;let i=ln(e),s=i.hu.get(t);return s?(i.sharedClientState.addLocalQueryTarget(s.targetId),r=s.view.uu()):r=await aF(i,t,n,!0),r}async function aM(e,t){let n=ln(e);await aF(n,t,!0,!1)}async function aF(e,t,n,r){let i;
21let s=await on(e.localStore,re(t)),o=s.targetId,a=e.sharedClientState.addLocalQueryTarget(o,n);return r&&(i=await aU(e,t,o,"current"===a,s.resumeToken)),e.isPrimaryClient&&n&&oX(e.remoteStore,s),i}async function aU(e,t,n,r,i){e.fu=(t,n,r)=>(async function(e,t,n,r){let i=t.view.tu(n);i.Cs&&(i=await oi(e.localStore,t.query,!1).then(({documents:e})=>t.view.tu(e,i)));let s=r&&r.targetChanges.get(t.targetId),o=r&&null!=r.targetMismatches.get(t.targetId),a=t.view.applyChanges(i,e.isPrimaryClient,s,o);return aJ(e,t.targetId,a.ou),a.snapshot})(e,t,n,r);let s=await oi(e.localStore,t,!0),o=new aR(t,s.$s),a=o.tu(s.documents),l=r7.createSynthesizedTargetChangeForCurrentChange(n,r&&"Offline"!==e.onlineState,i),u=o.applyChanges(a,e.isPrimaryClient,l);aJ(e,n,u.ou);let c=new aO(t,n,o);return e.hu.set(t,c),e.Pu.has(n)?e.Pu.get(n).push(t):e.Pu.set(n,[t]),u.snapshot}async function aV(e,t,n){let r=e.hu.get(t),i=e.Pu.get(r.targetId);if(i.length>1)return e.Pu.set(r.targetId,i.filter(e=>!rs(e,t))),void e.hu.delete(t);e.isPrimaryClient?(e.sharedClientState.removeLocalQueryTarget(r.targetId),e.sharedClientState.isActiveQueryTarget(r.targetId)||await or(e.localStore,r.targetId,!1).then(()=>{e.sharedClientState.clearQueryState(r.targetId),n&&oY(e.remoteStore,r.targetId),aX(e,r.targetId)}).catch(eC)):(aX(e,r.targetId),await or(e.localStore,r.targetId,!0))}async function aj(e,t){let n=e.hu.get(t),r=e.Pu.get(n.targetId);e.isPrimaryClient&&1===r.length&&(e.sharedClientState.removeLocalQueryTarget(n.targetId),oY(e.remoteStore,n.targetId))}
21async function aB(e,t,n){let r=lr(e);try{var i;let e;let s=await function(e,t){let n,r;let i=eo.now(),s=t.reduce((e,t)=>e.add(t.key),rw());return e.persistence.runTransaction("Locally write mutations","readwrite",o=>{let a=rd,l=rw();return e.Bs.getEntries(o,s).next(e=>{(a=e).forEach((e,t)=>{t.isValidDocument()||(l=l.add(e))})}).next(()=>e.localDocuments.getOverlayedDocuments(o,a)).next(r=>{n=r;let s=[];for(let e of t){let t=function(e,t){let n=null;for(let r of e.fieldTransforms){let e=t.data.field(r.field),i=rS(r.transform,e||null);null!=i&&(null===n&&(n=nA.empty()),n.set(r.field,i))}return n||null}(e,n.get(e.key).overlayedDocument);null!=t&&s.push(new rz(e.key,t,function e(t){let n=[];return tB(t.fields,(t,r)=>{let i=new ed([t]);if(nI(r)){let t=e(r.mapValue).fields;if(0===t.length)n.push(i);else for(let e of t)n.push(i.child(e))}else n.push(i)}),new tX(n)}(t.value.mapValue),rM.exists(!0)))}return e.mutationQueue.addMutationBatch(o,i,s,t)}).next(t=>{r=t;let i=t.applyToLocalDocumentSet(n,l);return e.documentOverlayCache.saveOverlays(o,t.batchId,i)})}).then(()=>({batchId:r.batchId,changes:rm(n)}))}(r.localStore,t);r.sharedClientState.addPendingMutation(s.batchId),i=s.batchId,(e=r.Au[r.currentUser.toKey()])||(e=new t$(en)),e=e.insert(i,n),r.Au[r.currentUser.toKey()]=e,await a0(r,s.changes),await o7(r.remoteStore)}catch(t){let e=ah(t,"Failed to persist write");n.reject(e)}}async function aq(e,t){try{let n=await function(e,t){let n=t.snapshotVersion,r=e.xs;return e.persistence.runTransaction("Apply remote event","readwrite-primary",i=>{let s=e.Bs.newChangeBuffer({trackRemovals:!0});r=e.xs;let o=[];
21t.targetChanges.forEach((s,a)=>{var l;let u=r.get(a);if(!u)return;o.push(e.Ti.removeMatchingKeys(i,s.removedDocuments,a).next(()=>e.Ti.addMatchingKeys(i,s.addedDocuments,a)));let c=u.withSequenceNumber(i.currentSequenceNumber);null!==t.targetMismatches.get(a)?c=c.withResumeToken(tZ.EMPTY_BYTE_STRING,ea.min()).withLastLimboFreeSnapshotVersion(ea.min()):s.resumeToken.approximateByteSize()>0&&(c=c.withResumeToken(s.resumeToken,n)),r=r.insert(a,c),l=c,(0===u.resumeToken.approximateByteSize()||l.snapshotVersion.toMicroseconds()-u.snapshotVersion.toMicroseconds()>=3e8||s.addedDocuments.size+s.modifiedDocuments.size+s.removedDocuments.size>0)&&o.push(e.Ti.updateTargetData(i,c))});let a=rd,l=rw();if(t.documentUpdates.forEach(n=>{t.resolvedLimboDocuments.has(n)&&o.push(e.persistence.referenceDelegate.updateLimboDocument(i,n))}),o.push(ot(i,s,t.documentUpdates).next(e=>{a=e.qs,l=e.Qs})),!n.isEqual(ea.min())){let t=e.Ti.getLastRemoteSnapshotVersion(i).next(t=>e.Ti.setTargetsMetadata(i,i.currentSequenceNumber,n));o.push(t)}return ex.waitFor(o).next(()=>s.apply(i)).next(()=>e.localDocuments.getLocalViewOfDocuments(i,a,l)).next(()=>a)}).then(t=>(e.xs=r,t))}(e.localStore,t);
21t.targetChanges.forEach((t,n)=>{let r=e.Eu.get(n);r&&(j(t.addedDocuments.size+t.modifiedDocuments.size+t.removedDocuments.size<=1,22616),t.addedDocuments.size>0?r.cu=!0:t.modifiedDocuments.size>0?j(r.cu,14607):t.removedDocuments.size>0&&(j(r.cu,42227),r.cu=!1))}),await a0(e,n,t)}catch(e){await eC(e)}}function az(e,t,n){var r;if(e.isPrimaryClient&&0===n||!e.isPrimaryClient&&1===n){let n;let i=[];e.hu.forEach((e,n)=>{let r=n.view.Fa(t);r.snapshot&&i.push(r.snapshot)}),(r=e.eventManager).onlineState=t,n=!1,r.queries.forEach((e,r)=>{for(let e of r.Sa)e.Fa(t)&&(n=!0)}),n&&aI(r),i.length&&e.lu.Y_(i),e.onlineState=t,e.isPrimaryClient&&e.sharedClientState.setOnlineState(t)}}async function a$(e,t,n){e.sharedClientState.updateQueryState(t,"rejected",n);let r=e.Eu.get(t),i=r&&r.key;if(i){let n=new t$(ef.comparator);n=n.insert(i,nR.newNoDocument(i,ea.min()));let r=rw().add(i),s=new r8(ea.min(),new Map,new t$(en),n,r);await aq(e,s),e.Iu=e.Iu.remove(i),e.Eu.delete(t),aZ(e)}else await or(e.localStore,t,!1).then(()=>aX(e,t,n)).catch(eC)}async function aK(e,t){var n;let r=t.batch.batchId;try{let i=await (n=e.localStore).persistence.runTransaction("Acknowledge batch","readwrite-primary",e=>{let r=t.batch.keys(),i=n.Bs.newChangeBuffer({trackRemovals:!0});return(function(e,t,n,r){let i=n.batch,s=i.keys(),o=ex.resolve();return s.forEach(e=>{o=o.next(()=>r.getEntry(t,e)).next(t=>{let s=n.docVersions.get(e);j(null!==s,48541),0>t.version.compareTo(s)&&(i.applyToRemoteDocument(t,n),t.isValidDocument()&&(t.setReadTime(n.commitVersion),r.addEntry(t)))})}),o.next(()=>e.mutationQueue.removeMutationBatch(t,i))})(n,e,t,i).next(()=>i.apply(e)).next(()=>n.mutationQueue.performConsistencyCheck(e)).next(()=>n.documentOverlayCache.removeOverlaysForBatchId(e,r,t.batch.batchId)).next(()=>n.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(e,function(e){let t=rw();for(let n=0;n<e.mutationResults.length;++n)e.mutationResults[n].transformResults.length>0&&(t=t.add(e.batch.mutations[n].key));return t}(t))).next(()=>n.localDocuments.getDocuments(e,r))});aQ(e,r,null),aW(e,r),e.sharedClientState.updateMutationState(r,"acknowledged"),await a0(e,i)}catch(e){await eC(e)}}async function aG(e,t,n){var r;try{let i=await (r=e.localStore).persistence.runTransaction("Reject batch","readwrite-primary",e=>{let n;return r.mutationQueue.lookupMutationBatch(e,t).next(t=>(j(null!==t,37113),n=t.keys(),r.mutationQueue.removeMutationBatch(e,t))).next(()=>r.mutationQueue.performConsistencyCheck(e)).next(()=>r.documentOverlayCache.removeOverlaysForBatchId(e,n,t)).next(()=>r.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(e,n)).next(()=>r.localDocuments.getDocuments(e,n))});aQ(e,t,n),aW(e,t),e.sharedClientState.updateMutationState(t,"rejected",n),await a0(e,i)}catch(e){await eC(e)}}async function aH(e,t){var n;o2(e.remoteStore)||P(aN,"The network is disabled. The task returned by 'awaitPendingWrites()' will not complete until the network is enabled.");try{let r=await (n=e.localStore).persistence.runTransaction("Get highest unacknowledged batch id","readonly",e=>n.mutationQueue.getHighestUnacknowledgedBatchId(e));if(-1===r)return void t.resolve();let i=e.Ru.get(r)||[];i.push(t),e.Ru.set(r,i)}catch(n){let e=ah(n,"Initialization of waitForPendingWrites() operation failed");t.reject(e)}}function aW(e,t){(e.Ru.get(t)||[]).forEach(e=>{e.resolve()}),e.Ru.delete(t)}function aQ(e,t,n){let r=e.Au[e.currentUser.toKey()];if(r){let i=r.get(t);i&&(n?i.reject(n):i.resolve(),r=r.remove(t)),e.Au[e.currentUser.toKey()]=r}}function aX(e,t,n=null){for(let r of(e.sharedClientState.removeLocalQueryTarget(t),e.Pu.get(t)))e.hu.delete(r),n&&e.lu.gu(r,n);e.Pu.delete(t),e.isPrimaryClient&&e.du.Hr(t).forEach(t=>{e.du.containsKey(t)||aY(e,t)})}function aY(e,t){e.Tu.delete(t.path.canonicalString());let n=e.Iu.get(t);null!==n&&(oY(e.remoteStore,n),e.Iu=e.Iu.remove(t),e.Eu.delete(n),aZ(e))}function aJ(e,t,n){for(let r of n)r instanceof ak?(e.du.addReference(r.key,t),function(e,t){let n=t.key,r=n.path.canonicalString();e.Iu.get(n)||e.Tu.has(r)||(P(aN,"New document in limbo: "+n),e.Tu.add(r),aZ(e))}
21(e,r)):r instanceof aA?(P(aN,"Document no longer in limbo: "+r.key),e.du.removeReference(r.key,t),e.du.containsKey(r.key)||aY(e,r.key)):U(19791,{pu:r})}function aZ(e){for(;e.Tu.size>0&&e.Iu.size<e.maxConcurrentLimboResolutions;){let t=e.Tu.values().next().value;e.Tu.delete(t);let n=new ef(ec.fromString(t)),r=e.Vu.next();e.Eu.set(r,new aD(n)),e.Iu=e.Iu.insert(n,r),oX(e.remoteStore,new iF(re(n9(n.path)),r,"TargetPurposeLimboResolution",eq.le))}}async function a0(e,t,n){let r=[],i=[],s=[];e.hu.isEmpty()||(e.hu.forEach((o,a)=>{s.push(e.fu(a,t,n).then(t=>{var s;if((t||n)&&e.isPrimaryClient){let r=t?!t.fromCache:null===(s=null==n?void 0:n.targetChanges.get(a.targetId))||void 0===s?void 0:s.current;e.sharedClientState.updateQueryState(a.targetId,r?"current":"not-current")}if(t){r.push(t);let e=s6.Rs(a.targetId,t);i.push(e)}}))}),await Promise.all(s),e.lu.Y_(r),await async function(e,t){try{await e.persistence.runTransaction("notifyLocalViewChanges","readwrite",n=>ex.forEach(t,t=>ex.forEach(t.ds,r=>e.persistence.referenceDelegate.addReference(n,t.targetId,r)).next(()=>ex.forEach(t.As,r=>e.persistence.referenceDelegate.removeReference(n,t.targetId,r)))))}catch(e){if(!eP(e))throw e;P(s3,"Failed to update sequence numbers: "+e)}for(let n of t){let t=n.targetId;if(!n.fromCache){let n=e.xs.get(t),r=n.snapshotVersion,i=n.withLastLimboFreeSnapshotVersion(r);e.xs=e.xs.insert(t,i)}}}(e.localStore,i))}async function a1(e,t){var n;if(!e.currentUser.isEqual(t)){P(aN,"User change. New user:",t.toKey());let r=await s7(e.localStore,t);e.currentUser=t,n="'waitForPendingWrites' promise is rejected due to a user change.",e.Ru.forEach(e=>{e.forEach(e=>{e.reject(new z(q.CANCELLED,n))})}),e.Ru.clear(),e.sharedClientState.handleUserChange(t,r.removedBatchIds,r.addedBatchIds),await a0(e,r.ks)}}function a2(e,t){let n=e.Eu.get(t);if(n&&n.cu)return rw().add(n.key);{let n=rw(),r=e.Pu.get(t);if(!r)return n;for(let t of r){let r=e.hu.get(t);n=n.unionWith(r.view.eu)}return n}}async function a4(e,t){let n=await oi(e.localStore,t.query,!0),r=t.view.au(n);return e.isPrimaryClient&&aJ(e,t.targetId,r.ou),r}async function a6(e,t){return oo(e.localStore,t).then(t=>a0(e,t))}async function a5(e,t,n,r){let i=await function(e,t){let n=e.mutationQueue;return e.persistence.runTransaction("Lookup mutation documents","readonly",r=>n.tr(r,t).next(t=>t?e.localDocuments.getDocuments(r,t):ex.resolve(null)))}(e.localStore,t);null!==i?("pending"===n?await o7(e.remoteStore):"acknowledged"===n||"rejected"===n?(aQ(e,t,r||null),aW(e,t),function(e,t){e.mutationQueue.sr(t)}(e.localStore,t)):U(6720,"Unknown batchState",{yu:n}),await a0(e,i)):P(aN,"Cannot apply mutation batch with id: "+t)}async function a9(e,t){if(ln(e),lr(e),!0===t&&!0!==e.mu){let t=e.sharedClientState.getAllActiveQueryTargets(),n=await a3(e,t.toArray());for(let t of(e.mu=!0,await aa(e.remoteStore,!0),n))oX(e.remoteStore,t)}else if(!1===t&&!1!==e.mu){let t=[],n=Promise.resolve();e.Pu.forEach((r,i)=>{e.sharedClientState.isLocalQueryTarget(i)?t.push(i):n=n.then(()=>(aX(e,i),or(e.localStore,i,!0))),oY(e.remoteStore,i)}),await n,await a3(e,t),e.Eu.forEach((t,n)=>{oY(e.remoteStore,n)}),e.du.Jr(),e.Eu=new Map,e.Iu=new t$(ef.comparator),e.mu=!1,await aa(e.remoteStore,!1)}}async function a3(e,t,n){let r=[],i=[];for(let n of t){let t;let s=e.Pu.get(n);if(s&&0!==s.length)for(let n of(t=await on(e.localStore,re(s[0])),s)){let t=e.hu.get(n),r=await a4(e,t);r.snapshot&&i.push(r.snapshot)}else{let r=await os(e.localStore,n);t=await on(e.localStore,r),await aU(e,a8(r),n,!1,t.resumeToken)}r.push(t)}return e.lu.Y_(i),r}function a8(e){var t,n,r,i;return t=e.path,n=e.collectionGroup,r=e.orderBy,i=e.filters,new n5(t,n,r,i,e.limit,"F",e.startAt,e.endAt)}function a7(e){return e.localStore.persistence.Is()}async function le(e,t,n,r){if(e.mu)return void P(aN,"Ignoring unexpected query state notification.");let i=e.Pu.get(t);if(i&&i.length>0)switch(n){case"current":case"not-current":{let r=await oo(e.localStore,ru(i[0])),s=r8.createSynthesizedRemoteEventForCurrentChange(t,"current"===n,tZ.EMPTY_BYTE_STRING);await a0(e,r,s);break}case"rejected":await or(e.localStore,t,!0),aX(e,t,r);break;default:U(64155,n)}}async function lt(e,t,n){let r=ln(e);
21if(r.mu){for(let e of t){if(r.Pu.has(e)&&r.sharedClientState.isActiveQueryTarget(e)){P(aN,"Adding an already active target "+e);continue}let t=await os(r.localStore,e),n=await on(r.localStore,t);await aU(r,a8(t),n.targetId,!1,n.resumeToken),oX(r.remoteStore,n)}for(let e of n)r.Pu.has(e)&&await or(r.localStore,e,!1).then(()=>{oY(r.remoteStore,e),aX(r,e)}).catch(eC)}}function ln(e){return e.remoteStore.remoteSyncer.applyRemoteEvent=aq.bind(null,e),e.remoteStore.remoteSyncer.getRemoteKeysForTarget=a2.bind(null,e),e.remoteStore.remoteSyncer.rejectListen=a$.bind(null,e),e.lu.Y_=ab.bind(null,e.eventManager),e.lu.gu=a_.bind(null,e.eventManager),e}function lr(e){return e.remoteStore.remoteSyncer.applySuccessfulWrite=aK.bind(null,e),e.remoteStore.remoteSyncer.rejectFailedWrite=aG.bind(null,e),e}class li{constructor(){this.kind="memory",this.synchronizeTabs=!1}async initialize(e){this.serializer=oF(e.databaseInfo.databaseId),this.sharedClientState=this.bu(e),this.persistence=this.Su(e),await this.persistence.start(),this.localStore=this.Du(e),this.gcScheduler=this.vu(e,this.localStore),this.indexBackfillerScheduler=this.Cu(e,this.localStore)}vu(e,t){return null}Cu(e,t){return null}Du(e){var t;return t=this.persistence,new s8(t,new s9,e.initialUser,this.serializer)}Su(e){return new sH(sQ.fi,this.serializer)}bu(e){return new oE}async terminate(){var e,t;null===(e=this.gcScheduler)||void 0===e||e.stop(),null===(t=this.indexBackfillerScheduler)||void 0===t||t.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}}li.provider={build:()=>new li};class ls extends li{constructor(e){super(),this.cacheSizeBytes=e}vu(e,t){return j(this.persistence.referenceDelegate instanceof sX,46915),new sC(this.persistence.referenceDelegate.garbageCollector,e.asyncQueue,t)}Su(e){let t=void 0!==this.cacheSizeBytes?sp.withCacheSize(this.cacheSizeBytes):sp.DEFAULT;return new sH(e=>sX.fi(e,t),this.serializer)}}class lo extends li{constructor(e,t,n){super(),this.Fu=e,this.cacheSizeBytes=t,this.forceOwnership=n,this.kind="persistent",this.synchronizeTabs=!1}async initialize(e){await super.initialize(e),await this.Fu.initialize(this,e),await lr(this.Fu.syncEngine),await o7(this.Fu.remoteStore),await this.persistence.Ji(()=>(this.gcScheduler&&!this.gcScheduler.started&&this.gcScheduler.start(),this.indexBackfillerScheduler&&!this.indexBackfillerScheduler.started&&this.indexBackfillerScheduler.start(),Promise.resolve()))}Du(e){var t;return t=this.persistence,new s8(t,new s9,e.initialUser,this.serializer)}vu(e,t){return new sC(this.persistence.referenceDelegate.garbageCollector,e.asyncQueue,t)}Cu(e,t){let n=new eB(t,this.persistence);return new ej(e.asyncQueue,n)}Su(e){let t=s4(e.databaseInfo.databaseId,e.databaseInfo.persistenceKey),n=void 0!==this.cacheSizeBytes?sp.withCacheSize(this.cacheSizeBytes):sp.DEFAULT;return new s2(this.synchronizeTabs,t,e.clientId,n,e.asyncQueue,oL(),oM(),this.serializer,this.sharedClientState,!!this.forceOwnership)}bu(e){return new oE}}class la extends lo{constructor(e,t){super(e,t,!1),this.Fu=e,this.cacheSizeBytes=t,this.synchronizeTabs=!0}async initialize(e){await super.initialize(e);let t=this.Fu.syncEngine;this.sharedClientState instanceof oI&&(this.sharedClientState.syncEngine={Co:a5.bind(null,t),Fo:le.bind(null,t),Mo:lt.bind(null,t),Is:a7.bind(null,t),vo:a6.bind(null,t)},await this.sharedClientState.start()),await this.persistence.Ji(async e=>{await a9(this.Fu.syncEngine,e),this.gcScheduler&&(e&&!this.gcScheduler.started?this.gcScheduler.start():e||this.gcScheduler.stop()),this.indexBackfillerScheduler&&(e&&!this.indexBackfillerScheduler.started?this.indexBackfillerScheduler.start():e||this.indexBackfillerScheduler.stop())})}bu(e){let t=oL();if(!oI.C(t))throw new z(q.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");let n=s4(e.databaseInfo.databaseId,e.databaseInfo.persistenceKey);return new oI(t,e.asyncQueue,n,e.clientId,e.initialUser)}}class ll{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.sharedCl
21ientState.onlineStateHandler=e=>az(this.syncEngine,e,1),this.remoteStore.remoteSyncer.handleCredentialChange=a1.bind(null,this.syncEngine),await aa(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return new ag}createDatastore(e){let t=oF(e.databaseInfo.databaseId),n=new oP(e.databaseInfo);return new o$(e.authCredentials,e.appCheckCredentials,n,t)}createRemoteStore(e){var t;return t=this.localStore,new oH(t,this.datastore,e.asyncQueue,e=>az(this.syncEngine,e,0),oC.C()?new oC:new oT)}createSyncEngine(e,t){return function(e,t,n,r,i,s,o){let a=new aP(e,t,n,r,i,s);return o&&(a.mu=!0),a}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,e.initialUser,e.maxConcurrentLimboResolutions,t)}async terminate(){var e,t;await async function(e){P(oG,"RemoteStore shutting down."),e.da.add(5),await oQ(e),e.Ra.shutdown(),e.Va.set("Unknown")}(this.remoteStore),null===(e=this.datastore)||void 0===e||e.terminate(),null===(t=this.eventManager)||void 0===t||t.terminate()}}function lu(e,t=10240){let n=0;return{async read(){if(n<e.byteLength){let r={value:e.slice(n,n+t),done:!1};return n+=t,r}return{done:!0}},async cancel(){},releaseLock(){},closed:Promise.resolve()}}ll.provider={build:()=>new ll};class lc{constructor(e){this.observer=e,this.muted=!1}next(e){this.muted||this.observer.next&&this.Mu(this.observer.next,e)}error(e){this.muted||(this.observer.error?this.Mu(this.observer.error,e):L("Uncaught Error in snapshot listener:",e.toString()))}xu(){this.muted=!0}Mu(e,t){setTimeout(()=>{this.muted||e(t)},0)}}class lh{constructor(e,t){this.Ou=e,this.serializer=t,this.metadata=new $,this.buffer=new Uint8Array,this.Nu=new TextDecoder("utf-8"),this.Bu().then(e=>{e&&e.Ua()?this.metadata.resolve(e.$a.metadata):this.metadata.reject(Error(`The first element of the bundle is not a metadata, it is 22 ${JSON.stringify(null==e?void 0:e.$a)}`))},e=>this.metadata.reject(e))}close(){return this.Ou.cancel()}async getMetadata(){return this.metadata.promise}async wu(){return await this.getMetadata(),this.Bu()}async Bu(){let e=await this.Lu();if(null===e)return null;let t=this.Nu.decode(e),n=Number(t);return isNaN(n)&&this.ku(`length string (${t}) is not valid number`),new aT(JSON.parse(await this.qu(n)),e.length+n)}Qu(){return this.buffer.findIndex(e=>123===e)}async Lu(){for(;0>this.Qu()&&!await this.$u(););if(0===this.buffer.length)return null;let e=this.Qu();e<0&&this.ku("Reached the end of bundle when a length string is expected.");let t=this.buffer.slice(0,e);return this.buffer=this.buffer.slice(e),t}async qu(e){for(;this.buffer.length<e;)await this.$u()&&this.ku("Reached the end of bundle when more is expected.");let t=this.Nu.decode(this.buffer.slice(0,e));return this.buffer=this.buffer.slice(e),t}ku(e){throw this.Ou.cancel(),Error(`Invalid bundle format: ${e}`)}async $u(){let e=await this.Ou.read();if(!e.done){let t=new Uint8Array(this.buffer.length+e.value.length);t.set(this.buffer),t.set(e.value,this.buffer.length),this.buffer=t}return e.done}}class ld{constructor(e){this.datastore=e,this.readVersions=new Map,this.mutations=[],this.committed=!1,this.lastTransactionError=null,this.writtenDocs=new Set}async lookup(e){if(this.ensureCommitNotCalled(),this.mutations.length>0)throw this.lastTransactionError=new z(q.INVALID_ARGUMENT,"Firestore transactions require all reads to be executed before all writes."),this.lastTransactionError;let t=await async function(e,t){let n={documents:t.map(t=>ib(e.serializer,t))},r=await e.Yo("BatchGetDocuments",e.serializer.databaseId,ec.emptyPath(),n,t.length),i=new Map;r.forEach(t=>{var n;let r=(n=e.serializer,"found"in t?function(e,t){j(!!t.found,43571),t.found.name,t.found.updateTime;let n=i_(e,t.found.name),r=ig(t.found.updateTime),i=t.found.createTime?ig(t.found.createTime):ea.min(),s=new nA({mapValue:{fields:t.found.fields}});return nR.newFoundDocument(n,r,i,s)}(n,t):"missing"in t?function(e,t){j(!!t.missing,3894),j(!!t.readTime,22933);let n=i_(e,t.missing),r=ig(t.readTime);return nR.newNoDocument(n,r)}(n,t):U(7234,{result:t}));i.set(r.key.toString(),r)});let s=[];
22return t.forEach(e=>{let t=i.get(e.toString());j(!!t,55234,{key:e}),s.push(t)}),s}(this.datastore,e);return t.forEach(e=>this.recordVersion(e)),t}set(e,t){this.write(t.toMutation(e,this.precondition(e))),this.writtenDocs.add(e.toString())}update(e,t){try{this.write(t.toMutation(e,this.preconditionForUpdate(e)))}catch(e){this.lastTransactionError=e}this.writtenDocs.add(e.toString())}delete(e){this.write(new rH(e,this.precondition(e))),this.writtenDocs.add(e.toString())}async commit(){if(this.ensureCommitNotCalled(),this.lastTransactionError)throw this.lastTransactionError;let e=this.readVersions;this.mutations.forEach(t=>{e.delete(t.key.toString())}),e.forEach((e,t)=>{let n=ef.fromPath(t);this.mutations.push(new rW(n,this.precondition(n)))}),await async function(e,t){let n={writes:t.map(t=>ik(e.serializer,t))};await e.zo("Commit",e.serializer.databaseId,ec.emptyPath(),n)}(this.datastore,this.mutations),this.committed=!0}recordVersion(e){let t;if(e.isFoundDocument())t=e.version;else{if(!e.isNoDocument())throw U(50498,{Uu:e.constructor.name});t=ea.min()}let n=this.readVersions.get(e.key.toString());if(n){if(!t.isEqual(n))throw new z(q.ABORTED,"Document version changed between two reads.")}else this.readVersions.set(e.key.toString(),t)}precondition(e){let t=this.readVersions.get(e.toString());return!this.writtenDocs.has(e.toString())&&t?t.isEqual(ea.min())?rM.exists(!1):rM.updateTime(t):rM.none()}preconditionForUpdate(e){let t=this.readVersions.get(e.toString());if(!this.writtenDocs.has(e.toString())&&t){if(t.isEqual(ea.min()))throw new z(q.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return rM.updateTime(t)}return rM.exists(!0)}write(e){this.ensureCommitNotCalled(),this.mutations.push(e)}ensureCommitNotCalled(){}}class lf{constructor(e,t,n,r,i){this.asyncQueue=e,this.datastore=t,this.options=n,this.updateFunction=r,this.deferred=i,this.Ku=n.maxAttempts,this.x_=new oU(this.asyncQueue,"transaction_retry")}Wu(){this.Ku-=1,this.Gu()}Gu(){this.x_.y_(async()=>{let e=new ld(this.datastore),t=this.zu(e);t&&t.then(t=>{this.asyncQueue.enqueueAndForget(()=>e.commit().then(()=>{this.deferred.resolve(t)}).catch(e=>{this.ju(e)}))}).catch(e=>{this.ju(e)})})}zu(e){try{let t=this.updateFunction(e);return!ez(t)&&t.catch&&t.then?t:(this.deferred.reject(Error("Transaction callback must return a Promise")),null)}catch(e){return this.deferred.reject(e),null}}ju(e){this.Ku>0&&this.Hu(e)?(this.Ku-=1,this.asyncQueue.enqueueAndForget(()=>(this.Gu(),Promise.resolve()))):this.deferred.reject(e)}Hu(e){if("FirebaseError"===e.name){let t=e.code;return"aborted"===t||"failed-precondition"===t||"already-exists"===t||!r0(t)}return!1}}let lp="FirestoreClient";class lm{constructor(e,t,n,r,i){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=n,this.databaseInfo=r,this.user=A.UNAUTHENTICATED,this.clientId=et.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=i,this.authCredentials.start(n,async e=>{P(lp,"Received user=",e.uid),await this.authCredentialListener(e),this.user=e}),this.appCheckCredentials.start(n,e=>(P(lp,"Received new app check token=",e),this.appCheckCredentialListener(e,this.user)))}get configuration(){return{asyncQueue:this.asyncQueue,databaseInfo:this.databaseInfo,clientId:this.clientId,authCredentials:this.authCredentials,appCheckCredentials:this.appCheckCredentials,initialUser:this.user,maxConcurrentLimboResolutions:100}}setCredentialChangeListener(e){this.authCredentialListener=e}setAppCheckTokenChangeListener(e){this.appCheckCredentialListener=e}terminate(){this.asyncQueue.enterRestrictedMode();let e=new $;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(n){let t=ah(n,"Failed to shutdown persistence");e.reject(t)}}),e.promise}}async function lg(e,t){e.asyncQueue.verifyOperationInProgress(),P(lp,"Initializing OfflineComponentProvider");let n=e.configuration;await t.initialize(n);let r=n.initialUser;e.setCredentialChangeListener(async e=>{r.isEqual(e)||(await s7(t.localStore,e),r=e)}),t.persistence.setDatabaseDeletedListener(()=>e.terminate()),e._offlineComponents=t}async function ly(e,t){e.asyncQueue.verifyOperationInProgress();let n=await lv(e);P(lp,"Initializing OnlineComponentProvider"),await t.initialize(n,e.configuration),e.setCredentialChangeListener(e=>ao(t.remoteStore,e)),e.setAppCheckTokenChangeListener((e,n)=>ao(t.remoteStore,n)),e._onlineComponents=t}
22async function lv(e){if(!e._offlineComponents){if(e._uninitializedComponentsProvider){P(lp,"Using user provided OfflineComponentProvider");try{await lg(e,e._uninitializedComponentsProvider._offline)}catch(t){if(!("FirebaseError"===t.name?t.code===q.FAILED_PRECONDITION||t.code===q.UNIMPLEMENTED:!("undefined"!=typeof DOMException&&t instanceof DOMException)||22===t.code||20===t.code||11===t.code))throw t;M("Error using user provided cache. Falling back to memory cache: "+t),await lg(e,new li)}}else P(lp,"Using default OfflineComponentProvider"),await lg(e,new ls(void 0))}return e._offlineComponents}async function lw(e){return e._onlineComponents||(e._uninitializedComponentsProvider?(P(lp,"Using user provided OnlineComponentProvider"),await ly(e,e._uninitializedComponentsProvider._online)):(P(lp,"Using default OnlineComponentProvider"),await ly(e,new ll))),e._onlineComponents}function lb(e){return lv(e).then(e=>e.persistence)}function l_(e){return lv(e).then(e=>e.localStore)}function lI(e){return lw(e).then(e=>e.remoteStore)}function lE(e){return lw(e).then(e=>e.syncEngine)}function lT(e){return lw(e).then(e=>e.datastore)}async function lS(e){let t=await lw(e),n=t.eventManager;return n.onListen=aL.bind(null,t.syncEngine),n.onUnlisten=aV.bind(null,t.syncEngine),n.onFirstRemoteStoreListen=aM.bind(null,t.syncEngine),n.onLastRemoteStoreUnlisten=aj.bind(null,t.syncEngine),n}function lC(e,t,n={}){let r=new $;return e.asyncQueue.enqueueAndForget(async()=>(function(e,t,n,r,i){let s=new lc({next:a=>{s.xu(),t.enqueueAndForget(()=>aw(e,o));let l=a.docs.has(n);!l&&a.fromCache?i.reject(new z(q.UNAVAILABLE,"Failed to get document because the client is offline.")):l&&a.fromCache&&r&&"server"===r.source?i.reject(new z(q.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.)')):i.resolve(a)},error:e=>i.reject(e)}),o=new aE(n9(n.path),s,{includeMetadataChanges:!0,Qa:!0});return av(e,o)})(await lS(e),e.asyncQueue,t,n,r)),r.promise}function lx(e,t,n={}){let r=new $;return e.asyncQueue.enqueueAndForget(async()=>(function(e,t,n,r,i){let s=new lc({next:n=>{s.xu(),t.enqueueAndForget(()=>aw(e,o)),n.fromCache&&"server"===r.source?i.reject(new z(q.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.)')):i.resolve(n)},error:e=>i.reject(e)}),o=new aE(n,s,{includeMetadataChanges:!0,Qa:!0});return av(e,o)})(await lS(e),e.asyncQueue,t,n,r)),r.promise}function lk(e){let t={};return void 0!==e.timeoutSeconds&&(t.timeoutSeconds=e.timeoutSeconds),t}let lA=new Map;function lR(e,t,n){if(!n)throw new z(q.INVALID_ARGUMENT,`Function ${e}() cannot be called with an empty ${t}.`)}function lN(e,t,n,r){if(!0===t&&!0===r)throw new z(q.INVALID_ARGUMENT,`${e} and ${n} cannot be used together.`)}function lO(e){if(!ef.isDocumentKey(e))throw new z(q.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${e} has ${e.length}.`)}function lD(e){if(ef.isDocumentKey(e))throw new z(q.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${e} has ${e.length}.`)}function lP(e){if(void 0===e)return"undefined";if(null===e)return"null";if("string"==typeof e)return e.length>20&&(e=`${e.substring(0,20)}...`),JSON.stringify(e);if("number"==typeof e||"boolean"==typeof e)return""+e;if("object"==typeof e){if(e instanceof Array)return"an array";{var t;let n=(t=e).constructor?t.constructor.name:null;return n?`a custom ${n} object`:"an object"}}return"function"==typeof e?"a function":U(12329,{type:typeof e})}function lL(e,t){if("_delegate"in e&&(e=e._delegate),!(e instanceof t)){if(t.name===e.constructor.name)throw new z(q.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{let n=lP(e);throw new z(q.INVALID_ARGUMENT,`Expected type '${t.name}', but it was: ${n}`)}}return e}function lM(e,t){if(t<=0)throw new z(q.INVALID_ARGUMENT,`Function ${e}() requires a positive number, but it was: ${t}.`)}let lF="firestore.googleapis.com";class lU{constructor(e){var t,n;if(void 0===e.host){if(void 0!==e.ssl)throw new z(q.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host=lF,this.ssl=!0}else this.host=e.host,this.ssl=null===(t=e.ssl)||void 0===t||t;if(this.isUsingEmulator=void 0!==e.emulatorOptions,this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,this.localCache=e.localCache,void 0===e.cacheSizeBytes)this.cacheSizeBytes=41943040;else{if(-1!==e.cacheSizeBytes&&e.cacheSizeBytes<1048576)throw new z(q.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}lN("experimentalForceLongPolling",e.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",e.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!e.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:void 0===e.experimentalAutoDetectLongPolling?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!e.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=lk(null!==(n=e.experimentalLongPollingOptions)&&void 0!==n?n:{}),function(e){if(void 0!==e.timeoutSeconds){if(isNaN(e.timeoutSeconds))throw new z(q.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (must not be NaN)`);if(e.timeoutSeconds<5)throw new z(q.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (minimum allowed value is 5)`);if(e.timeoutSeconds>30)throw new z(q.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (maximum allowed value is 30)`)}}(this.experimentalLongPollingOptions),this.useFetchStreams=!!e.useFetchStreams}isEqual(e){var t,n;return this.host===e.host&&this.ssl===e.ssl&&this.credentials===e.credentials&&this.cacheSizeBytes===e.cacheSizeBytes&&this.experimentalForceLongPolling===e.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===e.experimentalAutoDetectLongPolling&&(t=this.experimentalLongPollingOptions,n=e.experimentalLongPollingOptions,t.timeoutSeconds===n.timeoutSeconds)&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams}}class lV{constructor(e,t,n,r){this._authCredentials=e,this._appCheckCredentials=t,this._databaseId=n,this._app=r,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new lU({}),this._settingsFrozen=!1,this._emulatorOptions={},this._terminateTask="notTerminated"}get app(){if(!this._app)throw new z(q.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"notTerminated"!==this._terminateTask}_setSettings(e){if(this._settingsFrozen)throw new z(q.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 lU(e),this._emulatorOptions=e.emulatorOptions||{},void 0!==e.credentials&&(this._authCredentials=function(e){if(!e)return new G;switch(e.type){case"firstParty":return new X(e.sessionIndex||"0",e.iamToken||null,e.authTokenFactory||null);case"provider":return e.client;default:throw new z(q.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invali
22d credential type")}}(e.credentials))}_getSettings(){return this._settings}_getEmulatorOptions(){return this._emulatorOptions}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return"notTerminated"===this._terminateTask&&(this._terminateTask=this._terminate()),this._terminateTask}async _restart(){"notTerminated"===this._terminateTask?await this._terminate():this._terminateTask="notTerminated"}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return function(e){let t=lA.get(e);t&&(P("ComponentProvider","Removing Datastore"),lA.delete(e),t.terminate())}(this),Promise.resolve()}}function lj(e,t,n,r={}){var i;e=lL(e,lV);let s=(0,b.Xx)(t),o=e._getSettings(),a=Object.assign(Object.assign({},o),{emulatorOptions:e._getEmulatorOptions()}),l=`${t}:${n}`;s&&((0,b.Uo)(`https://${l}`),(0,b.dp)("Firestore",!0)),o.host!==lF&&o.host!==l&&M("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used.");let u=Object.assign(Object.assign({},o),{host:l,ssl:s,emulatorOptions:r});if(!(0,b.vZ)(u,a)&&(e._setSettings(u),r.mockUserToken)){let t,n;if("string"==typeof r.mockUserToken)t=r.mockUserToken,n=A.MOCK_USER;else{t=(0,b.Sg)(r.mockUserToken,null===(i=e._app)||void 0===i?void 0:i.options.projectId);let s=r.mockUserToken.sub||r.mockUserToken.user_id;if(!s)throw new z(q.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");n=new A(s)}e._authCredentials=new H(new K(t,n))}}class lB{constructor(e,t,n){this.converter=t,this._query=n,this.type="query",this.firestore=e}withConverter(e){return new lB(this.firestore,e,this._query)}}class lq{constructor(e,t,n){this.converter=t,this._key=n,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 lz(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new lq(this.firestore,e,this._key)}}class lz extends lB{constructor(e,t,n){super(e,t,n9(n)),this._path=n,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){let e=this._path.popLast();return e.isEmpty()?null:new lq(this.firestore,null,new ef(e))}withConverter(e){return new lz(this.firestore,e,this._path)}}function l$(e,t,...n){if(e=(0,b.m9)(e),lR("collection","path",t),e instanceof lV){let r=ec.fromString(t,...n);return lD(r),new lz(e,null,r)}{if(!(e instanceof lq||e instanceof lz))throw new z(q.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");let r=e._path.child(ec.fromString(t,...n));return lD(r),new lz(e.firestore,null,r)}}function lK(e,t){if(e=lL(e,lV),lR("collectionGroup","collection id",t),t.indexOf("/")>=0)throw new z(q.INVALID_ARGUMENT,`Invalid collection ID '${t}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);return new lB(e,null,new n5(ec.emptyPath(),t))}function lG(e,t,...n){if(e=(0,b.m9)(e),1==arguments.length&&(t=et.newId()),lR("doc","path",t),e instanceof lV){let r=ec.fromString(t,...n);return lO(r),new lq(e,null,new ef(r))}{if(!(e instanceof lq||e instanceof lz))throw new z(q.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");let r=e._path.child(ec.fromString(t,...n));return lO(r),new lq(e.firestore,e instanceof lz?e.converter:null,new ef(r))}}function lH(e,t){return e=(0,b.m9)(e),t=(0,b.m9)(t),(e instanceof lq||e instanceof lz)&&(t instanceof lq||t instanceof lz)&&e.firestore===t.firestore&&e.path===t.path&&e.converter===t.converter}function lW(e,t){return e=(0,b.m9)(e),t=(0,b.m9)(t),e instanceof lB&&t instanceof lB&&e.firestore===t.firestore&&rs(e._query,t._query)&&e.converter===t.converter}let lQ="AsyncQueue";class lX{constructor(e=Promise.resolve()){this.Ju=[],this.Yu=!1,this.Zu=[],this.Xu=null,this.ec=!1,this.tc=!1,this.nc=[],this.x_=new oU(this,"async_queue_retry"),this.rc=()=>{let e=oM();e&&P(lQ,"Visibility state changed to "+e.visibilityState),this.x_.b_()},this.sc=e;let t=oM();t&&"function"==typeof t.addEventListener&&t.addEventListener("visibilitychange",this.rc)}get isShuttingDown(){return this.Yu}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.oc(),this._c(e)}enterRestrictedMode(e){if(!this.Yu){this.Yu=!0,this.tc=e||!1;
22let t=oM();t&&"function"==typeof t.removeEventListener&&t.removeEventListener("visibilitychange",this.rc)}}enqueue(e){if(this.oc(),this.Yu)return new Promise(()=>{});let t=new $;return this._c(()=>this.Yu&&this.tc?Promise.resolve():(e().then(t.resolve,t.reject),t.promise)).then(()=>t.promise)}enqueueRetryable(e){this.enqueueAndForget(()=>(this.Ju.push(e),this.ac()))}async ac(){if(0!==this.Ju.length){try{await this.Ju[0](),this.Ju.shift(),this.x_.reset()}catch(e){if(!eP(e))throw e;P(lQ,"Operation failed with retryable error: "+e)}this.Ju.length>0&&this.x_.y_(()=>this.ac())}}_c(e){let t=this.sc.then(()=>(this.ec=!0,e().catch(e=>{throw this.Xu=e,this.ec=!1,L("INTERNAL UNHANDLED ERROR: ",lY(e)),e}).then(e=>(this.ec=!1,e))));return this.sc=t,t}enqueueAfterDelay(e,t,n){this.oc(),this.nc.indexOf(e)>-1&&(t=0);let r=ac.createAndSchedule(this,e,t,n,e=>this.uc(e));return this.Zu.push(r),r}oc(){this.Xu&&U(47125,{cc:lY(this.Xu)})}verifyOperationInProgress(){}async lc(){let e;do e=this.sc,await e;while(e!==this.sc)}hc(e){for(let t of this.Zu)if(t.timerId===e)return!0;return!1}Pc(e){return this.lc().then(()=>{for(let t of(this.Zu.sort((e,t)=>e.targetTimeMs-t.targetTimeMs),this.Zu))if(t.skipDelay(),"all"!==e&&t.timerId===e)break;return this.lc()})}Tc(e){this.nc.push(e)}uc(e){let t=this.Zu.indexOf(e);this.Zu.splice(t,1)}}function lY(e){let t=e.message||"";return e.stack&&(t=e.stack.includes(e.message)?e.stack:e.message+"\n"+e.stack),t}function lJ(e){return function(e,t){if("object"!=typeof e||null===e)return!1;for(let n of t)if(n in e&&"function"==typeof e[n])return!0;return!1}(e,["next","error","complete"])}class lZ{constructor(){this._progressObserver={},this._taskCompletionResolver=new $,this._lastProgress={taskState:"Running",totalBytes:0,totalDocuments:0,bytesLoaded:0,documentsLoaded:0}}onProgress(e,t,n){this._progressObserver={next:e,error:t,complete:n}}catch(e){return this._taskCompletionResolver.promise.catch(e)}then(e,t){return this._taskCompletionResolver.promise.then(e,t)}_completeWith(e){this._updateProgress(e),this._progressObserver.complete&&this._progressObserver.complete(),this._taskCompletionResolver.resolve(e)}_failWith(e){this._lastProgress.taskState="Error",this._progressObserver.next&&this._progressObserver.next(this._lastProgress),this._progressObserver.error&&this._progressObserver.error(e),this._taskCompletionResolver.reject(e)}_updateProgress(e){this._lastProgress=e,this._progressObserver.next&&this._progressObserver.next(e)}}let l0=-1;class l1 extends lV{constructor(e,t,n,r){super(e,t,n,r),this.type="firestore",this._queue=new lX,this._persistenceKey=(null==r?void 0:r.name)||"[DEFAULT]"}async _terminate(){if(this._firestoreClient){let e=this._firestoreClient.terminate();this._queue=new lX(e),this._firestoreClient=void 0,await e}}}function l2(e,t,n){n||(n=nn);let r=(0,y.qX)(e,"firestore");if(r.isInitialized(n)){let e=r.getImmediate({identifier:n}),i=r.getOptions(n);if((0,b.vZ)(i,t))return e;throw new z(q.FAILED_PRECONDITION,"initializeFirestore() has already been called with different options. To avoid this error, call initializeFirestore() with the same options as when it was originally called, or call getFirestore() to return the already initialized instance.")}if(void 0!==t.cacheSizeBytes&&void 0!==t.localCache)throw new z(q.INVALID_ARGUMENT,"cache and cacheSizeBytes cannot be specified at the same time as cacheSizeBytes willbe deprecated. Instead, specify the cache size in the cache object");if(void 0!==t.cacheSizeBytes&&-1!==t.cacheSizeBytes&&t.cacheSizeBytes<1048576)throw new z(q.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");return t.host&&(0,b.Xx)(t.host)&&(0,b.Uo)(t.host),r.initialize({options:t,instanceIdentifier:n})}function l4(e,t){let n="object"==typeof e?e:(0,y.Mq)(),r="string"==typeof e?e:t||nn,i=(0,y.qX)(n,"firestore").getImmediate({identifier:r});if(!i._initialized){let e=(0,b.P0)("firestore");e&&lj(i,...e)}return i}function l6(e){if(e._terminated)throw new z(q.FAILED_PRECONDITION,"The client has already been terminated.");return e._firestoreClient||l5(e),e._firestoreClient}function l5(e){var t,n,r,i;let s=e._freezeSettings(),o=(i=e._databaseId,new nt(i,(null===(t=e._app)||void 0===t?void 0:t.options.appId)||"",e._persistenceKey,s.host,s.ssl,s.experimentalForceLongPolling,s.experimentalAutoDetectLongPolling,lk(s.experimentalLongPollingOptions),s.useFetchStreams,s.isUsingEmulator));e._componentsProvider||(null===(n=s.localCache)||void 0===n?void 0:n._offlineComponentProvider)&&(null===(r=s.localCache)||void 0===r?void 0:r._onlineComponentProvider)&&(e._componentsProvider={_offline:s.localCache._offlineComponentProvider,_online:s.localCache._onlineComponentProvider}),e._firestoreClient=new lm(e._authCredentials,e._appCheckCredentials,e._queue,o,e._componentsProvider&&function(e){let t=null==e?void 0:e._online.build();return{_offline:null==e?void 0:e._offline.build(t),_online:t}}(e._componentsProvider))}function l9(e,t){M("enableIndexedDbPersistence() will be deprecated
22in the future, you can use `FirestoreSettings.cache` instead.");let n=e._freezeSettings();return l8(e,ll.provider,{build:e=>new lo(e,n.cacheSizeBytes,null==t?void 0:t.forceOwnership)}),Promise.resolve()}async function l3(e){M("enableMultiTabIndexedDbPersistence() will be deprecated in the future, you can use `FirestoreSettings.cache` instead.");let t=e._freezeSettings();l8(e,ll.provider,{build:e=>new la(e,t.cacheSizeBytes)})}function l8(e,t,n){if((e=lL(e,l1))._firestoreClient||e._terminated)throw new z(q.FAILED_PRECONDITION,"Firestore has already been started and persistence can no longer be enabled. You can only enable persistence before calling any other methods on a Firestore object.");if(e._componentsProvider||e._getSettings().localCache)throw new z(q.FAILED_PRECONDITION,"SDK cache is already specified.");e._componentsProvider={_online:t,_offline:n},l5(e)}function l7(e){if(e._initialized&&!e._terminated)throw new z(q.FAILED_PRECONDITION,"Persistence can only be cleared before a Firestore instance is initialized or after it is terminated.");let t=new $;return e._queue.enqueueAndForgetEvenWhileRestricted(async()=>{try{await async function(e){if(!eR.C())return Promise.resolve();await eR.delete(e+s1)}(s4(e._databaseId,e._persistenceKey)),t.resolve()}catch(e){t.reject(e)}}),t.promise}function ue(e){return function(e){let t=new $;return e.asyncQueue.enqueueAndForget(async()=>aH(await lE(e),t)),t.promise}(l6(e=lL(e,l1)))}function ut(e){var t;return(t=l6(e=lL(e,l1))).asyncQueue.enqueue(async()=>{let e=await lb(t),n=await lI(t);return e.setNetworkEnabled(!0),n.da.delete(0),oW(n)})}function un(e){var t;return(t=l6(e=lL(e,l1))).asyncQueue.enqueue(async()=>{let e=await lb(t),n=await lI(t);return e.setNetworkEnabled(!1),async function(e){e.da.add(0),await oQ(e),e.Va.set("Offline")}(n)})}function ur(e){return(0,y.wN)(e.app,"firestore",e._databaseId.database),e._delete()}function ui(e,t){let n=l6(e=lL(e,l1)),r=new lZ;return function(e,t,n,r){var i;let s=(i=oF(t),new lh(function(e,t){if(e instanceof Uint8Array)return lu(e,void 0);if(e instanceof ArrayBuffer)return lu(new Uint8Array(e),void 0);if(e instanceof ReadableStream)return e.getReader();throw Error("Source of `toByteStreamReader` has to be a ArrayBuffer or ReadableStream")}("string"==typeof n?ee().encode(n):n),i));e.asyncQueue.enqueueAndForget(async()=>{!function(e,t,n){(async function(e,t,n){try{var r;let i=await t.getMetadata();if(await function(e,t){let n=ig(t.createTime);return e.persistence.runTransaction("hasNewerBundle","readonly",n=>e.Ei.getBundleMetadata(n,t.id)).then(e=>!!e&&e.createTime.compareTo(n)>=0)}(e.localStore,i))return await t.close(),n._completeWith({taskState:"Success",documentsLoaded:i.totalDocuments,bytesLoaded:i.totalBytes,totalDocuments:i.totalDocuments,totalBytes:i.totalBytes}),Promise.resolve(new Set);n._updateProgress(ax(i));let s=new aC(i,e.localStore,t.serializer),o=await t.wu();for(;o;){let e=await s.Wa(o);e&&n._updateProgress(e),o=await t.wu()}let a=await s.complete();return await a0(e,a.ja,void 0),await (r=e.localStore).persistence.runTransaction("Save bundle","readwrite",e=>r.Ei.saveBundleMetadata(e,i)),n._completeWith(a.progress),Promise.resolve(a.za)}catch(e){return M(aN,`Loading bundle failed with ${e}`),n._failWith(e),Promise.resolve(new Set)}})(e,t,n).then(t=>{e.sharedClientState.notifyBundleLoaded(t)})}(await lE(e),s,r)})}(n,e._databaseId,t,r),r}function us(e,t){var n;return(n=l6(e=lL(e,l1))).asyncQueue.enqueue(async()=>{var e;return(e=await l_(n)).persistence.runTransaction("Get named query","readonly",n=>e.Ei.getNamedQuery(n,t))}).then(t=>t?new lB(e,null,t.query):null)}class uo{constructor(e="count",t){this._internalFieldPath=t,this.type="AggregateField",this.aggregateType=e}}class ua{constructor(e,t,n){this._userDataWriter=t,this._data=n,this.type="AggregateQuerySnapshot",this.query=e}data(){return this._userDataWriter.convertObjectMap(this._data)}}class ul{constructor(e){this._byteString=e}static fromBase64String(e){try{return new ul(tZ.fromBase64String(e))}catch(e){throw new z(q.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+e)}}static fromUint8Array(e){return new ul(tZ.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)}}class uu{constructor(...e){for(let t=0;t<e.length;++t)if(0===e[t].length)throw new z(q.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new ed(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}}function uc(){return new uu(el)}class uh{constructor(e){this._methodName=e}}class ud{constructor(e,t){if(!isFinite(e)||e<-90||e>90)throw new z(q.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(t)||t<-180||t>180)throw new z(q.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+t);this._lat=e,this._long=t}get latitude(){return this._lat}get longitude(){return this._long}isEqual(e){return this._lat===e._lat&&this._long===e._long}toJSON(){return{latitude:this._lat,longitude:this._long}}_compareTo(e){return en(this._lat,e._lat)||en(this._long,e._long)}}class uf{constructor(e){this._values=(e||[]).map(e=>e)}toArray(){return this._values.map(e=>e)}isEqual(e){return function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0}(this._values,e._values)}}let up=/^__.*__$/;class um{constructor(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}toMutation(e,t){return null!==this.fieldMask?new rz(e,this.data,this.fieldMask,t,this.fieldTransforms):new rq(e,this.data,t,this.fieldTransforms)}}class ug{constructor(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}toMutation(e,t){return new rz(e,this.data,this.fieldMask,t,this.fieldTransforms)}}function uy(e){switch(e){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw U(40011,{Ic:e})}}class uv{constructor(e,t,n,r,i,s){this.settings=e,this.databaseId=t,this.serializer
22=n,this.ignoreUndefinedProperties=r,void 0===i&&this.Ec(),this.fieldTransforms=i||[],this.fieldMask=s||[]}get path(){return this.settings.path}get Ic(){return this.settings.Ic}dc(e){return new uv(Object.assign(Object.assign({},this.settings),e),this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}Ac(e){var t;let n=null===(t=this.path)||void 0===t?void 0:t.child(e),r=this.dc({path:n,Rc:!1});return r.Vc(e),r}mc(e){var t;let n=null===(t=this.path)||void 0===t?void 0:t.child(e),r=this.dc({path:n,Rc:!1});return r.Ec(),r}fc(e){return this.dc({path:void 0,Rc:!0})}gc(e){return uU(e,this.settings.methodName,this.settings.yc||!1,this.path,this.settings.wc)}contains(e){return void 0!==this.fieldMask.find(t=>e.isPrefixOf(t))||void 0!==this.fieldTransforms.find(t=>e.isPrefixOf(t.field))}Ec(){if(this.path)for(let e=0;e<this.path.length;e++)this.Vc(this.path.get(e))}Vc(e){if(0===e.length)throw this.gc("Document fields must not be empty");if(uy(this.Ic)&&up.test(e))throw this.gc('Document fields cannot begin and end with "__"')}}class uw{constructor(e,t,n){this.databaseId=e,this.ignoreUndefinedProperties=t,this.serializer=n||oF(e)}bc(e,t,n,r=!1){return new uv({Ic:e,methodName:t,wc:n,path:ed.emptyPath(),Rc:!1,yc:r},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}}function ub(e){let t=e._freezeSettings(),n=oF(e._databaseId);return new uw(e._databaseId,!!t.ignoreUndefinedProperties,n)}function u_(e,t,n,r,i,s={}){let o,a;let l=e.bc(s.merge||s.mergeFields?2:0,t,n,i);uP("Data must be an object, but it was:",l,r);let u=uO(r,l);if(s.merge)o=new tX(l.fieldMask),a=l.fieldTransforms;else if(s.mergeFields){let e=[];for(let r of s.mergeFields){let i=uL(t,r,n);if(!l.contains(i))throw new z(q.INVALID_ARGUMENT,`Field '${i}' is specified in your field mask but missing from your input data.`);uV(e,i)||e.push(i)}o=new tX(e),a=l.fieldTransforms.filter(e=>o.covers(e.field))}else o=null,a=l.fieldTransforms;return new um(new nA(u),o,a)}class uI extends uh{_toFieldTransform(e){if(2!==e.Ic)throw 1===e.Ic?e.gc(`${this._methodName}() can only appear at the top level of your update data`):e.gc(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return e.fieldMask.push(e.path),null}isEqual(e){return e instanceof uI}}function uE(e,t,n){return new uv({Ic:3,wc:t.settings.wc,methodName:e._methodName,Rc:n},t.databaseId,t.serializer,t.ignoreUndefinedProperties)}class uT extends uh{_toFieldTransform(e){return new rP(e.path,new rC)}isEqual(e){return e instanceof uT}}class uS extends uh{constructor(e,t){super(e),this.Sc=t}_toFieldTransform(e){let t=uE(this,e,!0),n=new rx(this.Sc.map(e=>uN(e,t)));return new rP(e.path,n)}isEqual(e){return e instanceof uS&&(0,b.vZ)(this.Sc,e.Sc)}}class uC extends uh{constructor(e,t){super(e),this.Sc=t}_toFieldTransform(e){let t=uE(this,e,!0),n=new rA(this.Sc.map(e=>uN(e,t)));return new rP(e.path,n)}isEqual(e){return e instanceof uC&&(0,b.vZ)(this.Sc,e.Sc)}}class ux extends uh{constructor(e,t){super(e),this.Dc=t}_toFieldTransform(e){let t=new rN(e.serializer,rE(e.serializer,this.Dc));return new rP(e.path,t)}isEqual(e){return e instanceof ux&&this.Dc===e.Dc}}function uk(e,t,n,r){let i=e.bc(1,t,n);uP("Data must be an object, but it was:",i,r);let s=[],o=nA.empty();return tB(r,(e,r)=>{let a=uF(t,e,n);r=(0,b.m9)(r);let l=i.mc(a);if(r instanceof uI)s.push(a);else{let e=uN(r,l);null!=e&&(s.push(a),o.set(a,e))}}),new ug(o,new tX(s),i.fieldTransforms)}function uA(e,t,n,r,i,s){let o=e.bc(1,t,n),a=[uL(t,r,n)],l=[i];if(s.length%2!=0)throw new z(q.INVALID_ARGUMENT,`Function ${t}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let e=0;e<s.length;e+=2)a.push(uL(t,s[e])),l.push(s[e+1]);let u=[],c=nA.empty();for(let e=a.length-1;e>=0;--e)if(!uV(u,a[e])){let t=a[e],n=l[e];n=(0,b.m9)(n);let r=o.mc(t);if(n instanceof uI)u.push(t);else{let e=uN(n,r);null!=e&&(u.push(t),c.set(t,e))}}return new ug(c,new tX(u),o.fieldTransforms)}function uR(e,t,n,r=!1){return uN(n,e.bc(r?4:3,t))}function uN(e,t){if(uD(e=(0,b.m9)(e)))return uP("Unsupported field value:",t,e),uO(e,t);if(e instanceof uh)return function(e,t){if(!uy(t.Ic))throw t.gc(`${e._methodName}
22() can only be used with update() and set()`);if(!t.path)throw t.gc(`${e._methodName}() is not currently supported inside arrays`);let n=e._toFieldTransform(t);n&&t.fieldTransforms.push(n)}(e,t),null;if(void 0===e&&t.ignoreUndefinedProperties)return null;if(t.path&&t.fieldMask.push(t.path),e instanceof Array){if(t.settings.Rc&&4!==t.Ic)throw t.gc("Nested arrays are not supported");return function(e,t){let n=[],r=0;for(let i of e){let e=uN(i,t.fc(r));null==e&&(e={nullValue:"NULL_VALUE"}),n.push(e),r++}return{arrayValue:{values:n}}}(e,t)}return function(e,t){if(null===(e=(0,b.m9)(e)))return{nullValue:"NULL_VALUE"};if("number"==typeof e)return rE(t.serializer,e);if("boolean"==typeof e)return{booleanValue:e};if("string"==typeof e)return{stringValue:e};if(e instanceof Date){let n=eo.fromDate(e);return{timestampValue:ip(t.serializer,n)}}if(e instanceof eo){let n=new eo(e.seconds,1e3*Math.floor(e.nanoseconds/1e3));return{timestampValue:ip(t.serializer,n)}}if(e instanceof ud)return{geoPointValue:{latitude:e.latitude,longitude:e.longitude}};if(e instanceof ul)return{bytesValue:im(t.serializer,e._byteString)};if(e instanceof lq){let n=t.databaseId,r=e.firestore._databaseId;if(!r.isEqual(n))throw t.gc(`Document reference is for database ${r.projectId}/${r.database} but should be for database ${n.projectId}/${n.database}`);return{referenceValue:iy(e.firestore._databaseId||t.databaseId,e._key.path)}}if(e instanceof uf)return{mapValue:{fields:{[ni]:{stringValue:na},[nl]:{arrayValue:{values:e.toArray().map(e=>{if("number"!=typeof e)throw t.gc("VectorValues must only contain numeric values.");return r_(t.serializer,e)})}}}}};throw t.gc(`Unsupported field value: ${lP(e)}`)}(e,t)}function uO(e,t){let n={};return tz(e)?t.path&&t.path.length>0&&t.fieldMask.push(t.path):tB(e,(e,r)=>{let i=uN(r,t.Ac(e));null!=i&&(n[e]=i)}),{mapValue:{fields:n}}}function uD(e){return!("object"!=typeof e||null===e||e instanceof Array||e instanceof Date||e instanceof eo||e instanceof ud||e instanceof ul||e instanceof lq||e instanceof uh||e instanceof uf)}function uP(e,t,n){if(!uD(n)||!("object"==typeof n&&null!==n&&(Object.getPrototypeOf(n)===Object.prototype||null===Object.getPrototypeOf(n)))){let r=lP(n);throw"an object"===r?t.gc(e+" a custom object"):t.gc(e+" "+r)}}function uL(e,t,n){if((t=(0,b.m9)(t))instanceof uu)return t._internalPath;if("string"==typeof t)return uF(e,t);throw uU("Field path arguments must be of type string or ",e,!1,void 0,n)}let uM=RegExp("[~\\*/\\[\\]]");function uF(e,t,n){if(t.search(uM)>=0)throw uU(`Invalid field path (${t}). Paths must not contain '~', '*', '/', '[', or ']'`,e,!1,void 0,n);try{return new uu(...t.split("."))._internalPath}catch(r){throw uU(`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,e,!1,void 0,n)}}function uU(e,t,n,r,i){let s=r&&!r.isEmpty(),o=void 0!==i,a=`Function ${t}() called with invalid data`;n&&(a+=" (via `toFirestore()`)"),a+=". ";let l="";return(s||o)&&(l+=" (found",s&&(l+=` in field ${r}`),o&&(l+=` in document ${i}`),l+=")"),new z(q.INVALID_ARGUMENT,a+e+l)}function uV(e,t){return e.some(e=>e.isEqual(t))}class uj{constructor(e,t,n,r,i){this._firestore=e,this._userDataWriter=t,this._key=n,this._document=r,this._converter=i}get id(){return this._key.path.lastSegment()}get ref(){return new lq(this._firestore,this._converter,this._key)}exists(){return null!==this._document}data(){if(this._document){if(this._converter){let e=new uB(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(e)}return this._userDataWriter.convertValue(this._document.data.value)}}get(e){if(this._document){let t=this._document.data.field(uq("DocumentSnapshot.get",e));if(null!==t)return this._userDataWriter.convertValue(t)}}}class uB extends uj{data(){return super.data()}}function uq(e,t){return"string"==typeof t?uF(e,t):t instanceof uu?t._internalPath:t._delegate._internalPath}function uz(e){if("L"===e.limitType&&0===e.explicitOrderBy.length)throw new z(q.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class u${}class uK extends u${}function uG(e,t,...n){let r=[];for(let i of(t instanceof u$&&r.push(t),function(e){let t=e.filter(e=>e instanceof uQ).length,n=e.filter(e=>e instanceof uH).length;if(t>1||t>0&&n>0)throw new z(q.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=r.concat(n)),r))e=i._apply(e);return e}class uH extends uK{constructor(e,t,n){super(),this._field=e,this._op=t,this._value=n,this.type="where"}static _create(e,t,n){return new uH(e,t,n)}_apply(e){let t=this._parse(e);return cn(e._query,t),new lB(e.firestore,e.converter,rr(e._query,t))}_parse(e){let t=ub(e.firestore);return function(e,t,n,r,i,s,o){let a;
22if(i.isKeyField()){if("array-contains"===s||"array-contains-any"===s)throw new z(q.INVALID_ARGUMENT,`Invalid Query. You can't perform '${s}' queries on documentId().`);if("in"===s||"not-in"===s){ct(o,s);let t=[];for(let n of o)t.push(ce(r,e,n));a={arrayValue:{values:t}}}else a=ce(r,e,o)}else"in"!==s&&"not-in"!==s&&"array-contains-any"!==s||ct(o,s),a=uR(n,t,o,"in"===s||"not-in"===s);return nM.create(i,s,a)}(e._query,"where",t,e.firestore._databaseId,this._field,this._op,this._value)}}function uW(e,t,n){let r=uq("where",e);return uH._create(r,t,n)}class uQ extends u${constructor(e,t){super(),this.type=e,this._queryConstraints=t}static _create(e,t){return new uQ(e,t)}_parse(e){let t=this._queryConstraints.map(t=>t._parse(e)).filter(e=>e.getFilters().length>0);return 1===t.length?t[0]:nF.create(t,this._getOperator())}_apply(e){let t=this._parse(e);return 0===t.getFilters().length?e:(function(e,t){let n=e;for(let e of t.getFlattenedFilters())cn(n,e),n=rr(n,e)}(e._query,t),new lB(e.firestore,e.converter,rr(e._query,t)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return"and"===this.type?"and":"or"}}function uX(...e){return e.forEach(e=>cr("or",e)),uQ._create("or",e)}function uY(...e){return e.forEach(e=>cr("and",e)),uQ._create("and",e)}class uJ extends uK{constructor(e,t){super(),this._field=e,this._direction=t,this.type="orderBy"}static _create(e,t){return new uJ(e,t)}_apply(e){let t=function(e,t,n){if(null!==e.startAt)throw new z(q.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(null!==e.endAt)throw new z(q.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");return new nP(t,n)}(e._query,this._field,this._direction);return new lB(e.firestore,e.converter,function(e,t){let n=e.explicitOrderBy.concat([t]);return new n5(e.path,e.collectionGroup,n,e.filters.slice(),e.limit,e.limitType,e.startAt,e.endAt)}(e._query,t))}}function uZ(e,t="asc"){let n=uq("orderBy",e);return uJ._create(n,t)}class u0 extends uK{constructor(e,t,n){super(),this.type=e,this._limit=t,this._limitType=n}static _create(e,t,n){return new u0(e,t,n)}_apply(e){return new lB(e.firestore,e.converter,ri(e._query,this._limit,this._limitType))}}function u1(e){return lM("limit",e),u0._create("limit",e,"F")}function u2(e){return lM("limitToLast",e),u0._create("limitToLast",e,"L")}class u4 extends uK{constructor(e,t,n){super(),this.type=e,this._docOrFields=t,this._inclusive=n}static _create(e,t,n){return new u4(e,t,n)}_apply(e){var t;let n=u7(e,this.type,this._docOrFields,this._inclusive);return new lB(e.firestore,e.converter,new n5((t=e._query).path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,n,t.endAt))}}function u6(...e){return u4._create("startAt",e,!0)}function u5(...e){return u4._create("startAfter",e,!1)}class u9 extends uK{constructor(e,t,n){super(),this.type=e,this._docOrFields=t,this._inclusive=n}static _create(e,t,n){return new u9(e,t,n)}_apply(e){var t;let n=u7(e,this.type,this._docOrFields,this._inclusive);return new lB(e.firestore,e.converter,new n5((t=e._query).path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,t.startAt,n))}}function u3(...e){return u9._create("endBefore",e,!1)}function u8(...e){return u9._create("endAt",e,!0)}function u7(e,t,n,r){if(n[0]=(0,b.m9)(n[0]),n[0]instanceof uj)return function(e,t,n,r,i){if(!r)throw new z(q.NOT_FOUND,`Can't use a DocumentSnapshot that doesn't exist for ${n}().`);let s=[];for(let n of n7(e))if(n.field.isKeyField())s.push(ny(t,r.key));else{let e=r.data.field(n.field);if(t8(e))throw new z(q.INVALID_ARGUMENT,'Invalid query. You are trying to start or end a query using a document for which the field "'+n.field+'" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');if(null===e){let e=n.field.canonicalString();throw new z(q.INVALID_ARGUMENT,`Invalid query. You are trying to start or end a query using a document for which the field '${e}' (used as the orderBy) does not exist.`)}s.push(e)}return new nN(s,i)}(e._query,e.firestore._databaseId,t,n[0]._document,r);{let i=ub(e.firestore);return function(e,t,n,r,i,s){let o=e.explicitOrderBy;if(i.length>o.length)throw new z(q.INVALID_ARGUMENT,`Too many arguments provided to ${r}(). The number of arguments must be less than or equal to the number of orderBy() clauses`);let a=[];for(let s=0;s<i.length;s++){let l=i[s];
22if(o[s].field.isKeyField()){if("string"!=typeof l)throw new z(q.INVALID_ARGUMENT,`Invalid query. Expected a string for document ID in ${r}(), but got a ${typeof l}`);if(!n8(e)&&-1!==l.indexOf("/"))throw new z(q.INVALID_ARGUMENT,`Invalid query. When querying a collection and ordering by documentId(), the value passed to ${r}() must be a plain document ID, but '${l}' contains a slash.`);let n=e.path.child(ec.fromString(l));if(!ef.isDocumentKey(n))throw new z(q.INVALID_ARGUMENT,`Invalid query. When querying a collection group and ordering by documentId(), the value passed to ${r}() must result in a valid document path, but '${n}' is not because it contains an odd number of segments.`);let i=new ef(n);a.push(ny(t,i))}else{let e=uR(n,r,l);a.push(e)}}return new nN(a,s)}(e._query,e.firestore._databaseId,i,t,n,r)}}function ce(e,t,n){if("string"==typeof(n=(0,b.m9)(n))){if(""===n)throw new z(q.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!n8(t)&&-1!==n.indexOf("/"))throw new z(q.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${n}' contains a '/' character.`);let r=t.path.child(ec.fromString(n));if(!ef.isDocumentKey(r))throw new z(q.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 ny(e,new ef(r))}if(n instanceof lq)return ny(e,n._key);throw new z(q.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${lP(n)}.`)}function ct(e,t){if(!Array.isArray(e)||0===e.length)throw new z(q.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${t.toString()}' filters.`)}function cn(e,t){let n=function(e,t){for(let n of e)for(let e of n.getFlattenedFilters())if(t.indexOf(e.op)>=0)return e.op;return null}(e.filters,function(e){switch(e){case"!=":return["!=","not-in"];case"array-contains-any":case"in":return["not-in"];case"not-in":return["array-contains-any","in","not-in","!="];default:return[]}}(t.op));if(null!==n)throw n===t.op?new z(q.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${t.op.toString()}' filter.`):new z(q.INVALID_ARGUMENT,`Invalid query. You cannot use '${t.op.toString()}' filters with '${n.toString()}' filters.`)}function cr(e,t){if(!(t instanceof uH||t instanceof uQ))throw new z(q.INVALID_ARGUMENT,`Function ${e}() requires AppliableConstraints created with a call to 'where(...)', 'or(...)', or 'and(...)'.`)}class ci{convertValue(e,t="none"){switch(nc(e)){case 0:return null;case 1:return e.booleanValue;case 2:return t2(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(t4(e.bytesValue));case 7:return this.convertReference(e.referenceValue);case 8:return this.convertGeoPoint(e.geoPointValue);case 9:return this.convertArray(e.arrayValue,t);case 11:return this.convertObject(e.mapValue,t);case 10:return this.convertVectorValue(e.mapValue);default:throw U(62114,{value:e})}}convertObject(e,t){return this.convertObjectMap(e.fields,t)}convertObjectMap(e,t="none"){let n={};return tB(e,(e,r)=>{n[e]=this.convertValue(r,t)}),n}convertVectorValue(e){var t,n,r;return new uf(null===(r=null===(n=null===(t=e.fields)||void 0===t?void 0:t[nl].arrayValue)||void 0===n?void 0:n.values)||void 0===r?void 0:r.map(e=>t2(e.doubleValue)))}convertGeoPoint(e){return new ud(t2(e.latitude),t2(e.longitude))}convertArray(e,t){return(e.values||[]).map(e=>this.convertValue(e,t))}convertServerTimestamp(e,t){switch(t){case"previous":let n=t7(e);return null==n?null:this.convertValue(n,t);case"estimate":return this.convertTimestamp(ne(e));default:return null}}convertTimestamp(e){let t=t1(e);return new eo(t.seconds,t.nanos)}convertDocumentKey(e,t){let n=ec.fromString(e);j(iM(n),9688,{name:e});let r=new nr(n.get(1),n.get(3)),i=new ef(n.popFirst(5));return r.isEqual(t)||L(`Document ${i} contains a document reference within a different database (${r.projectId}/${r.database}) which is not supported. It will be treated as a reference in the current database (${t.projectId}/${t.database}) instead.`),i}}function cs(e,t,n){return e?n&&(n.merge||n.mergeFields)?e.toFirestore(t,n):e.toFirestore(t):t}class co extends ci{constructor(e){super(),this.firestore=e}convertBytes(e){return new ul(e)}convertReference(e){let t=this.convertDocumentKey(e,this.firestore._databaseId);
22return new lq(this.firestore,null,t)}}function ca(e){return new uo("sum",uL("sum",e))}function cl(e){return new uo("avg",uL("average",e))}function cu(){return new uo("count")}function cc(e,t){var n,r;return e instanceof uo&&t instanceof uo&&e.aggregateType===t.aggregateType&&(null===(n=e._internalFieldPath)||void 0===n?void 0:n.canonicalString())===(null===(r=t._internalFieldPath)||void 0===r?void 0:r.canonicalString())}function ch(e,t){return lW(e.query,t.query)&&(0,b.vZ)(e.data(),t.data())}class cd{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}}class cf extends uj{constructor(e,t,n,r,i,s){super(e,t,n,r,s),this._firestore=e,this._firestoreImpl=e,this.metadata=i}exists(){return super.exists()}data(e={}){if(this._document){if(this._converter){let t=new cp(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){let n=this._document.data.field(uq("DocumentSnapshot.get",e));if(null!==n)return this._userDataWriter.convertValue(n,t.serverTimestamps)}}}class cp extends cf{data(e={}){return super.data(e)}}class cm{constructor(e,t,n,r){this._firestore=e,this._userDataWriter=t,this._snapshot=r,this.metadata=new cd(r.hasPendingWrites,r.fromCache),this.query=n}get docs(){let e=[];return this.forEach(t=>e.push(t)),e}get size(){return this._snapshot.docs.size}get empty(){return 0===this.size}forEach(e,t){this._snapshot.docs.forEach(n=>{e.call(t,new cp(this._firestore,this._userDataWriter,n.key,n,new cd(this._snapshot.mutatedKeys.has(n.key),this._snapshot.fromCache),this.query.converter))})}docChanges(e={}){let t=!!e.includeMetadataChanges;if(t&&this._snapshot.excludesMetadataChanges)throw new z(q.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(e,t){if(e._snapshot.oldDocs.isEmpty()){let t=0;return e._snapshot.docChanges.map(n=>{let r=new cp(e._firestore,e._userDataWriter,n.doc.key,n.doc,new cd(e._snapshot.mutatedKeys.has(n.doc.key),e._snapshot.fromCache),e.query.converter);return n.doc,{type:"added",doc:r,oldIndex:-1,newIndex:t++}})}{let n=e._snapshot.oldDocs;return e._snapshot.docChanges.filter(e=>t||3!==e.type).map(t=>{let r=new cp(e._firestore,e._userDataWriter,t.doc.key,t.doc,new cd(e._snapshot.mutatedKeys.has(t.doc.key),e._snapshot.fromCache),e.query.converter),i=-1,s=-1;return 0!==t.type&&(i=n.indexOf(t.doc.key),n=n.delete(t.doc.key)),1!==t.type&&(s=(n=n.add(t.doc)).indexOf(t.doc.key)),{type:function(e){switch(e){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return U(61501,{type:e})}}(t.type),doc:r,oldIndex:i,newIndex:s}})}}(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}}function cg(e,t){return e instanceof cf&&t instanceof cf?e._firestore===t._firestore&&e._key.isEqual(t._key)&&(null===e._document?null===t._document:e._document.isEqual(t._document))&&e._converter===t._converter:e instanceof cm&&t instanceof cm&&e._firestore===t._firestore&&lW(e.query,t.query)&&e.metadata.isEqual(t.metadata)&&e._snapshot.isEqual(t._snapshot)}function cy(e){e=lL(e,lq);let t=lL(e.firestore,l1);return lC(l6(t),e._key).then(n=>cN(t,e,n))}class cv extends ci{constructor(e){super(),this.firestore=e}convertBytes(e){return new ul(e)}convertReference(e){let t=this.convertDocumentKey(e,this.firestore._databaseId);return new lq(this.firestore,null,t)}}function cw(e){e=lL(e,lq);let t=lL(e.firestore,l1),n=l6(t),r=new cv(t);return(function(e,t){let n=new $;return e.asyncQueue.enqueueAndForget(async()=>(async function(e,t,n){try{let r=await e.persistence.runTransaction("read document","readonly",n=>e.localDocuments.getDocument(n,t));r.isFoundDocument()?n.resolve(r):r.isNoDocument()?n.resolve(null):n.reject(new z(q.UNAVAILABLE,"Failed to get document from cache. (However, this document may exist on the server. Run again without setting 'source' in the GetOptions to attempt to retrieve the document from the server.)"))}catch(r){let e=ah(r,`Failed to get document '${t} from cache`);n.reject(e)}})(await l_(e),t,n)),n.promise})(n,e._key).then(n=>new cf(t,r,e._key,n,new cd(null!==n&&n.hasLocalMutations,!0),e.converter))}function cb(e){e=lL(e,lq);let t=lL(e.firestore,l1);return lC(l6(t),e._key,{source:"server"}).then(n=>cN(t,e,n))}function c_(e){e=lL(e,lB);let t=lL(e.firestore,l1),n=l6(t),r=new cv(t);return uz(e._query),lx(n,e._query).then(n=>new cm(t,r,e,n))}function cI(e){e=lL(e,lB);let t=lL(e.firestore,l1),n=l6(t),r=new cv(t);return(function(e,t){let n=new $;return e.asyncQueue.enqueueAndForget(async()=>(async function(e,t,n){try{let r=await oi(e,t,!0),i=new aR(t,r.$s),s=i.tu(r.documents),o=i.applyChanges(s,
22!1);n.resolve(o.snapshot)}catch(r){let e=ah(r,`Failed to execute query '${t} against cache`);n.reject(e)}})(await l_(e),t,n)),n.promise})(n,e._query).then(n=>new cm(t,r,e,n))}function cE(e){e=lL(e,lB);let t=lL(e.firestore,l1),n=l6(t),r=new cv(t);return lx(n,e._query,{source:"server"}).then(n=>new cm(t,r,e,n))}function cT(e,t,n){e=lL(e,lq);let r=lL(e.firestore,l1),i=cs(e.converter,t,n);return cR(r,[u_(ub(r),"setDoc",e._key,i,null!==e.converter,n).toMutation(e._key,rM.none())])}function cS(e,t,n,...r){e=lL(e,lq);let i=lL(e.firestore,l1),s=ub(i);return cR(i,[("string"==typeof(t=(0,b.m9)(t))||t instanceof uu?uA(s,"updateDoc",e._key,t,n,r):uk(s,"updateDoc",e._key,t)).toMutation(e._key,rM.exists(!0))])}function cC(e){return cR(lL(e.firestore,l1),[new rH(e._key,rM.none())])}function cx(e,t){let n=lL(e.firestore,l1),r=lG(e),i=cs(e.converter,t);return cR(n,[u_(ub(e.firestore),"addDoc",r._key,i,null!==e.converter,{}).toMutation(r._key,rM.exists(!1))]).then(()=>r)}function ck(e,...t){var n,r,i;let s,o,a;e=(0,b.m9)(e);let l={includeMetadataChanges:!1,source:"default"},u=0;"object"!=typeof t[0]||lJ(t[u])||(l=t[u],u++);let c={includeMetadataChanges:l.includeMetadataChanges,source:l.source};if(lJ(t[u])){let e=t[u];t[u]=null===(n=e.next)||void 0===n?void 0:n.bind(e),t[u+1]=null===(r=e.error)||void 0===r?void 0:r.bind(e),t[u+2]=null===(i=e.complete)||void 0===i?void 0:i.bind(e)}if(e instanceof lq)o=lL(e.firestore,l1),a=n9(e._key.path),s={next:n=>{t[u]&&t[u](cN(o,e,n))},error:t[u+1],complete:t[u+2]};else{let n=lL(e,lB);o=lL(n.firestore,l1),a=n._query;let r=new cv(o);s={next:e=>{t[u]&&t[u](new cm(o,r,n,e))},error:t[u+1],complete:t[u+2]},uz(e._query)}return function(e,t,n,r){let i=new lc(r),s=new aE(t,i,n);return e.asyncQueue.enqueueAndForget(async()=>av(await lS(e),s)),()=>{i.xu(),e.asyncQueue.enqueueAndForget(async()=>aw(await lS(e),s))}}(l6(o),a,c,s)}function cA(e,t){return function(e,t){let n=new lc(t);return e.asyncQueue.enqueueAndForget(async()=>{(await lS(e)).Ca.add(n),n.next()}),()=>{n.xu(),e.asyncQueue.enqueueAndForget(async()=>(function(e,t){e.Ca.delete(t)})(await lS(e),n))}}(l6(e=lL(e,l1)),lJ(t)?t:{next:t})}function cR(e,t){return function(e,t){let n=new $;return e.asyncQueue.enqueueAndForget(async()=>aB(await lE(e),t,n)),n.promise}(l6(e),t)}function cN(e,t,n){let r=n.docs.get(t._key),i=new cv(e);return new cf(e,i,t._key,r,new cd(n.hasPendingWrites,n.fromCache),t.converter)}function cO(e){return cD(e,{count:cu()})}function cD(e,t){let n=lL(e.firestore,l1),r=l6(n),i=tq(t,(e,t)=>new rJ(t,e.aggregateType,e._internalFieldPath));return(function(e,t,n){let r=new $;return e.asyncQueue.enqueueAndForget(async()=>{try{let i=await lT(e);r.resolve(async function(e,t,n){var r;let{request:i,yt:s,parent:o}=iO(e.serializer,rt(t),n);e.connection.Uo||delete i.parent;let a=(await e.Yo("RunAggregationQuery",e.serializer.databaseId,o,i,1)).filter(e=>!!e.result);j(1===a.length,64727);let l=null===(r=a[0].result)||void 0===r?void 0:r.aggregateFields;return Object.keys(l).reduce((e,t)=>(e[s[t]]=l[t],e),{})}(i,t,n))}catch(e){r.reject(e)}}),r.promise})(r,e._query,i).then(t=>new ua(e,new cv(n),t))}class cP{constructor(e){this.kind="memory",this._onlineComponentProvider=ll.provider,(null==e?void 0:e.garbageCollector)?this._offlineComponentProvider=e.garbageCollector._offlineComponentProvider:this._offlineComponentProvider={build:()=>new ls(void 0)}}toJSON(){return{kind:this.kind}}}class cL{constructor(e){let t;this.kind="persistent",(null==e?void 0:e.tabManager)?(e.tabManager._initialize(e),t=e.tabManager):(t=c$(void 0))._initialize(e),this._onlineComponentProvider=t._onlineComponentProvider,this._offlineComponentProvider=t._offlineComponentProvider}toJSON(){return{kind:this.kind}}}class cM{constructor(){this.kind="memoryEager",this._offlineComponentProvider=li.provider}toJSON(){return{kind:this.kind}}}class cF{constructor(e){this.kind="memoryLru",this._offlineComponentProvider={build:()=>new ls(e)}}toJSON(){return{kind:this.kind}}}function cU(){return new cM}function cV(e){return new cF(null==e?void 0:e.cacheSizeBytes)}function cj(e){return new cP(e)}function cB(e){return new cL(e)}class cq{constructor(e){this.forceOwnership=e,this.kind="persistentSingleTab"}toJSON(){return{kind:this.kind}}_initialize(e){this._onlineComponentProvider=ll.provider,this._offlineComponentProvider={build:t=>new lo(t,null==e?void 0:e.cacheSizeBytes,this.forceOwnership)}}}class cz{constructor(){this.kind="PersistentMultipleTab"}toJSON(){return{kind:this.kind}}_initialize(e){this._onlineComponentProvider=ll.provider,this._offlineComponentProvider={build:t=>new la(t,null==e?void 0:e.cacheSizeBytes)}}}function c$(e){return new cq(null==e?void 0:e.forceOwnership)}function cK(){return new cz}let cG={maxAttempts:5};class cH{constructor(e,t){this._firestore=e,this._commitHandler=t,this._mutations=[],this._committed=!1,this._dataReader=ub(e)}set(e,t,n){this._verifyNotCommitted();let r=cW(e,this._firestore),i=cs(r.converter,t,n),s=u_(this._dataReader,"WriteBatch.set",r._key,i,null!==r.converter,n);return this._mutations.push(s.toMutation(r._key,rM.none())),this}update(e,t,n,...r){let i;this._verifyNotCommitted();let s=cW(e,this._firestore);return i="string"==typeof(t=(0,b.m9)(t))||t instanceof uu?uA(this._dataReader,"WriteBatch.update",s._key,t,n,r):uk(this._dataReader,"WriteBatch.update",s._key,t),this._mutations.push(i.toMutation(s._key,rM.exists(!0))),this}delete(e){this._verifyNotCommitted();let t=cW(e,this._firestore);return this._mutations=this._mutations.concat(new rH(t._key,rM.none())),this}commit(){return this._verifyNotCommitted(),this._committed=!0,this._mutations.length>0?this._commitHandler(this._mutations):Promise.resolve()}_verifyNotCommitted(){if(this._committed)throw new z(q.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")}}function cW(e,t){if((e=(0,b.m9)(e)).firestore!==t)throw new z(q.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return e}class cQ{constructor(e,t){this._firestore=e,this._transaction=t,this._dataReader=ub(e)}get(e){let t=cW(e,this._firestore),n=new co(this._firestore);return this._transaction.lookup([t._key]).then(e=>{if(!e||1!==e.length)return U(24041);let r=e[0];
22if(r.isFoundDocument())return new uj(this._firestore,n,r.key,r,t.converter);if(r.isNoDocument())return new uj(this._firestore,n,t._key,null,t.converter);throw U(18433,{doc:r})})}set(e,t,n){let r=cW(e,this._firestore),i=cs(r.converter,t,n),s=u_(this._dataReader,"Transaction.set",r._key,i,null!==r.converter,n);return this._transaction.set(r._key,s),this}update(e,t,n,...r){let i;let s=cW(e,this._firestore);return i="string"==typeof(t=(0,b.m9)(t))||t instanceof uu?uA(this._dataReader,"Transaction.update",s._key,t,n,r):uk(this._dataReader,"Transaction.update",s._key,t),this._transaction.update(s._key,i),this}delete(e){let t=cW(e,this._firestore);return this._transaction.delete(t._key),this}}class cX extends cQ{constructor(e,t){super(e,t),this._firestore=e}get(e){let t=cW(e,this._firestore),n=new cv(this._firestore);return super.get(e).then(e=>new cf(this._firestore,n,t._key,e._document,new cd(!1,!1),t.converter))}}function cY(e,t,n){e=lL(e,l1);let r=Object.assign(Object.assign({},cG),n);return!function(e){if(e.maxAttempts<1)throw new z(q.INVALID_ARGUMENT,"Max attempts must be at least 1")}(r),function(e,t,n){let r=new $;return e.asyncQueue.enqueueAndForget(async()=>{let i=await lT(e);new lf(e.asyncQueue,i,n,t,r).Wu()}),r.promise}(l6(e),n=>t(new cX(e,n)),r)}function cJ(){return new uI("deleteField")}function cZ(){return new uT("serverTimestamp")}function c0(...e){return new uS("arrayUnion",e)}function c1(...e){return new uC("arrayRemove",e)}function c2(e){return new ux("increment",e)}function c4(e){return new uf(e)}function c6(e){return l6(e=lL(e,l1)),new cH(e,t=>cR(e,t))}function c5(e,t){let n=l6(e=lL(e,l1));if(!n._uninitializedComponentsProvider||"memory"===n._uninitializedComponentsProvider._offline.kind)return M("Cannot enable indexes when persistence is disabled"),Promise.resolve();let r=function(e){let t="string"==typeof e?function(e){try{return JSON.parse(e)}catch(e){throw new z(q.INVALID_ARGUMENT,"Failed to parse JSON: "+(null==e?void 0:e.message))}}(e):e,n=[];if(Array.isArray(t.indexes))for(let e of t.indexes){let t=c9(e,"collectionGroup"),r=[];if(Array.isArray(e.fields))for(let t of e.fields){let e=uF("setIndexConfiguration",c9(t,"fieldPath"));"CONTAINS"===t.arrayConfig?r.push(new ev(e,2)):"ASCENDING"===t.order?r.push(new ev(e,0)):"DESCENDING"===t.order&&r.push(new ev(e,1))}n.push(new ep(ep.UNKNOWN_ID,t,r,ew.empty()))}return n}(t);return n.asyncQueue.enqueue(async()=>(async function(e,t){let n=e.indexManager,r=[];return e.persistence.runTransaction("Configure indexes","readwrite",e=>n.getFieldIndexes(e).next(i=>(function(e,t,n,r,i){t=[...t],(e=[...e]).sort(n),t.sort(n);let s=e.length,o=t.length,a=0,l=0;for(;a<o&&l<s;){let s=n(e[l],t[a]);s<0?i(e[l++]):s>0?r(t[a++]):(a++,l++)}for(;a<o;)r(t[a++]);for(;l<s;)i(e[l++])})(i,t,ey,t=>{r.push(n.addFieldIndex(e,t))},t=>{r.push(n.deleteFieldIndex(e,t))})).next(()=>ex.waitFor(r)))})(await l_(n),r))}function c9(e,t){if("string"!=typeof e[t])throw new z(q.INVALID_ARGUMENT,"Missing string value for: "+t);return e[t]}class c3{constructor(e){this._firestore=e,this.type="PersistentCacheIndexManager"}}function c8(e){var t;e=lL(e,l1);let n=hr.get(e);if(n)return n;if("persistent"!==(null===(t=l6(e)._uninitializedComponentsProvider)||void 0===t?void 0:t._offline.kind))return null;let r=new c3(e);return hr.set(e,r),r}function c7(e){hn(e,!0)}function he(e){hn(e,!1)}function ht(e){var t;(t=l6(e._firestore)).asyncQueue.enqueue(async()=>(function(e){let t=e.indexManager;return e.persistence.runTransaction("Delete All Indexes","readwrite",e=>t.deleteAllFieldIndexes(e))})(await l_(t))).then(e=>P("deleting all persistent cache indexes succeeded")).catch(e=>M("deleting all persistent cache indexes failed",e))}function hn(e,t){var n;(n=l6(e._firestore)).asyncQueue.enqueue(async()=>{(await l_(n)).Ms.fs=t}).then(e=>P(`setting persistent cache index auto creation isEnabled=${t} succeeded`)).catch(e=>M(`setting persistent cache index auto creation isEnabled=${t} failed`,e))}let hr=new WeakMap;function hi(e){var t;let n=null===(t=l6(lL(e.firestore,l1))._onlineComponents)||void 0===t?void 0:t.datastore.serializer;return void 0===n?null:iN(n,re(e._query)).gt}function hs(e,t){var n;let r=tq(t,(e,t)=>new rJ(t,e.aggregateType,e._internalFieldPath)),i=null===(n=l6(lL(e.firestore,l1))._onlineComponents)||void 0===n?void 0:n.datastore.serializer;return void 0===i?null:iO(i,rt(e._query),r,!0).request}class ho{constructor(){throw Error("instances of this class should not be created")}static onExistenceFilterMismatch(e){return ha.instance.onExistenceFilterMismatch(e)}}class ha{constructor(){this.vc=new Map}static get instance(){return hl||function(e){if(r2)throw Error("a TestingHooksSpi instance is already set");r2=e}(hl=new ha),hl}
22ht(e){this.vc.forEach(t=>t(e))}onExistenceFilterMismatch(e){let t=Symbol(),n=this.vc;return n.set(t,e),()=>n.delete(t)}}let hl=null;!function(e,t=!0){R=y.Jn,(0,y.Xd)(new v.wA("firestore",(e,{instanceIdentifier:n,options:r})=>{let i=e.getProvider("app").getImmediate(),s=new l1(new W(e.getProvider("auth-internal")),new J(i,e.getProvider("app-check-internal")),function(e,t){if(!Object.prototype.hasOwnProperty.apply(e.options,["projectId"]))throw new z(q.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new nr(e.options.projectId,t)}(i,n),i);return r=Object.assign({useFetchStreams:t},r),s._setSettings(r),s},"PUBLIC").setMultipleInstances(!0)),(0,y.KN)(x,k,void 0),(0,y.KN)(x,k,"esm2017")}()},6650:function(e,t,n){"use strict";n.d(t,{Jt:function(){return ey},cF:function(){return ew},iH:function(){return ev},B0:function(){return eg}});var r,i,s,o,a=n(2238),l=n(1683),u=n(8463);let c="firebasestorage.googleapis.com",h="storageBucket";class d extends l.ZR{constructor(e,t,n=0){super(f(e),`Firebase Storage: ${t} (${f(e)})`),this.status_=n,this.customData={serverResponse:null},this._baseMessage=this.message,Object.setPrototypeOf(this,d.prototype)}get status(){return this.status_}set status(e){this.status_=e}_codeEquals(e){return f(e)===this.code}get serverResponse(){return this.customData.serverResponse}set serverResponse(e){this.customData.serverResponse=e,this.customData.serverResponse?this.message=`${this._baseMessage} 23${this.customData.serverResponse}`:this.message=this._baseMessage}}function f(e){return"storage/"+e}function p(){return new d(s.UNKNOWN,"An unknown error occurred, please check the error payload for server response.")}function m(){return new d(s.RETRY_LIMIT_EXCEEDED,"Max retry time for operation exceeded, please try again.")}function g(){return new d(s.CANCELED,"User canceled the upload/download.")}function y(){return new d(s.CANNOT_SLICE_BLOB,"Cannot slice blob for upload. Please retry the upload.")}function v(e){return new d(s.INVALID_ARGUMENT,e)}function w(){return new d(s.APP_DELETED,"The Firebase app was deleted.")}function b(e,t){return new d(s.INVALID_FORMAT,"String does not match format '"+e+"': "+t)}function _(e){throw new d(s.INTERNAL_ERROR,"Internal error: "+e)}(r=s||(s={})).UNKNOWN="unknown",r.OBJECT_NOT_FOUND="object-not-found",r.BUCKET_NOT_FOUND="bucket-not-found",r.PROJECT_NOT_FOUND="project-not-found",r.QUOTA_EXCEEDED="quota-exceeded",r.UNAUTHENTICATED="unauthenticated",r.UNAUTHORIZED="unauthorized",r.UNAUTHORIZED_APP="unauthorized-app",r.RETRY_LIMIT_EXCEEDED="retry-limit-exceeded",r.INVALID_CHECKSUM="invalid-checksum",r.CANCELED="canceled",r.INVALID_EVENT_NAME="invalid-event-name",r.INVALID_URL="invalid-url",r.INVALID_DEFAULT_BUCKET="invalid-default-bucket",r.NO_DEFAULT_BUCKET="no-default-bucket",r.CANNOT_SLICE_BLOB="cannot-slice-blob",r.SERVER_FILE_WRONG_SIZE="server-file-wrong-size",r.NO_DOWNLOAD_URL="no-download-url",r.INVALID_ARGUMENT="invalid-argument",r.INVALID_ARGUMENT_COUNT="invalid-argument-count",r.APP_DELETED="app-deleted",r.INVALID_ROOT_OPERATION="invalid-root-operation",r.INVALID_FORMAT="invalid-format",r.INTERNAL_ERROR="internal-error",r.UNSUPPORTED_ENVIRONMENT="unsupported-environment";class I{constructor(e,t){this.bucket=e,this.path_=t}get path(){return this.path_}get isRoot(){return 0===this.path.length}fullServerUrl(){let e=encodeURIComponent;return"/b/"+e(this.bucket)+"/o/"+e(this.path)}bucketOnlyServerUrl(){return"/b/"+encodeURIComponent(this.bucket)+"/o"}static makeFromBucketSpec(e,t){let n;try{n=I.makeFromUrl(e,t)}catch(t){return new I(e,"")}if(""===n.path)return n;throw new d(s.INVALID_DEFAULT_BUCKET,"Invalid default bucket '"+e+"'.")}static makeFromUrl(e,t){let n=null,r="([A-Za-z0-9.\\-_]+)",i=RegExp("^gs://"+r+"(/(.*))?$","i");function o(e){e.path_=decodeURIComponent(e.path)}let a=t.replace(/[.]/g,"\\."),l=[{regex:i,indices:{bucket:1,path:3},postModify:function(e){"/"===e.path.charAt(e.path.length-1)&&(e.path_=e.path_.slice(0,-1))}},{regex:RegExp(`^https?://${a}/v[A-Za-z0-9_]+/b/${r}/o(/([^?#]*).*)?$`,"i"),indices:{bucket:1,path:3},postModify:o},{regex:RegExp(`^https?://${t===c?"(?:storage.googleapis.com|storage.cloud.google.com)":t}/${r}/([^?#]*)`,"i"),indices:{bucket:1,path:2},postModify:o}];for(let t=0;t<l.length;t++){let r=l[t],i=r.regex.exec(e);if(i){let e=i[r.indices.bucket],t=i[r.indices.path];t||(t=""),n=new I(e,t),r.postModify(n);break}}if(null==n)throw new d(s.INVALID_URL,"Invalid URL '"+e+"'.");return n}}class E{constructor(e){this.promise_=Promise.reject(e)}getPromise(){return this.promise_}cancel(e=!1){}}function T(e){return"string"==typeof e||e instanceof String}function S(e){return C()&&e instanceof Blob}function C(){return"undefined"!=typeof Blob}function x(e,t,n,r){if(r<t)throw v(`Invalid value for '${e}'. Expected ${t} or greater.`);if(r>n)throw v(`Invalid value for '${e}'. Expected ${n} or less.`)}
23function k(e,t,n){let r=t;return null==n&&(r=`https://${t}`),`${n}://${r}/v0${e}`}function A(e){let t=encodeURIComponent,n="?";for(let r in e)e.hasOwnProperty(r)&&(n=n+(t(r)+"=")+t(e[r])+"&");return n.slice(0,-1)}function R(e,t){let n=e>=500&&e<600,r=-1!==[408,429].indexOf(e),i=-1!==t.indexOf(e);return n||r||i}(i=o||(o={}))[i.NO_ERROR=0]="NO_ERROR",i[i.NETWORK_ERROR=1]="NETWORK_ERROR",i[i.ABORT=2]="ABORT";class N{constructor(e,t,n,r,i,s,o,a,l,u,c,h=!0,d=!1){this.url_=e,this.method_=t,this.headers_=n,this.body_=r,this.successCodes_=i,this.additionalRetryCodes_=s,this.callback_=o,this.errorCallback_=a,this.timeout_=l,this.progressCallback_=u,this.connectionFactory_=c,this.retry=h,this.isUsingEmulator=d,this.pendingConnection_=null,this.backoffId_=null,this.canceled_=!1,this.appDelete_=!1,this.promise_=new Promise((e,t)=>{this.resolve_=e,this.reject_=t,this.start_()})}start_(){let e=(e,t)=>{let n=this.resolve_,r=this.reject_,i=t.connection;if(t.wasSuccessCode)try{let e=this.callback_(i,i.getResponse());void 0!==e?n(e):n()}catch(e){r(e)}else if(null!==i){let e=p();e.serverResponse=i.getErrorText(),r(this.errorCallback_?this.errorCallback_(i,e):e)}else r(t.canceled?this.appDelete_?w():g():m())};this.canceled_?e(!1,new O(!1,null,!0)):this.backoffId_=function(e,t,n){let r=1,i=null,s=null,o=!1,a=0,l=!1;function u(...e){l||(l=!0,t.apply(null,e))}function c(t){i=setTimeout(()=>{i=null,e(d,2===a)},t)}function h(){s&&clearTimeout(s)}function d(e,...t){let n;if(l){h();return}if(e||2===a||o){h(),u.call(null,e,...t);return}r<64&&(r*=2),1===a?(a=2,n=0):n=(r+Math.random())*1e3,c(n)}let f=!1;function p(e){!f&&(f=!0,h(),!l&&(null!==i?(e||(a=2),clearTimeout(i),c(0)):e||(a=1)))}return c(0),s=setTimeout(()=>{o=!0,p(!0)},n),p}((e,t)=>{if(t){e(!1,new O(!1,null,!0));return}let n=this.connectionFactory_();this.pendingConnection_=n;let r=e=>{let t=e.loaded,n=e.lengthComputable?e.total:-1;null!==this.progressCallback_&&this.progressCallback_(t,n)};null!==this.progressCallback_&&n.addUploadProgressListener(r),n.send(this.url_,this.method_,this.isUsingEmulator,this.body_,this.headers_).then(()=>{null!==this.progressCallback_&&n.removeUploadProgressListener(r),this.pendingConnection_=null;let t=n.getErrorCode()===o.NO_ERROR,i=n.getStatus();if(!t||R(i,this.additionalRetryCodes_)&&this.retry){e(!1,new O(!1,null,n.getErrorCode()===o.ABORT));return}e(!0,new O(-1!==this.successCodes_.indexOf(i),n))})},e,this.timeout_)}getPromise(){return this.promise_}cancel(e){this.canceled_=!0,this.appDelete_=e||!1,null!==this.backoffId_&&(0,this.backoffId_)(!1),null!==this.pendingConnection_&&this.pendingConnection_.abort()}}class O{constructor(e,t,n){this.wasSuccessCode=e,this.connection=t,this.canceled=!!n}}function D(...e){let t="undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof WebKitBlobBuilder?WebKitBlobBuilder:void 0;if(void 0!==t){let n=new t;for(let t=0;t<e.length;t++)n.append(e[t]);return n.getBlob()}if(C())return new Blob(e);throw new d(s.UNSUPPORTED_ENVIRONMENT,"This browser doesn't seem to support creating Blobs")}let P={RAW:"raw",BASE64:"base64",BASE64URL:"base64url",DATA_URL:"data_url"};class L{constructor(e,t){this.data=e,this.contentType=t||null}}function M(e){let t=[];for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);r<=127?t.push(r):r<=2047?t.push(192|r>>6,128|63&r):(64512&r)==55296?n<e.length-1&&(64512&e.charCodeAt(n+1))==56320?(r=65536|(1023&r)<<10|1023&e.charCodeAt(++n),t.push(240|r>>18,128|r>>12&63,128|r>>6&63,128|63&r)):t.push(239,191,189):(64512&r)==56320?t.push(239,191,189):t.push(224|r>>12,128|r>>6&63,128|63&r)}return new Uint8Array(t)}function F(e,t){let n;switch(e){case P.BASE64:{let n=-1!==t.indexOf("-"),r=-1!==t.indexOf("_");if(n||r)throw b(e,"Invalid character '"+(n?"-":"_")+"' found: is it base64url encoded?");break}case P.BASE64URL:{let n=-1!==t.indexOf("+"),r=-1!==t.indexOf("/");if(n||r)throw b(e,"Invalid character '"+(n?"+":"/")+"' found: is it base64 encoded?");t=t.replace(/-/g,"+").replace(/_/g,"/")}}try{n=function(e){if("undefined"==typeof atob)throw new d(s.UNSUPPORTED_ENVIRONMENT,"base-64 is missing. Make sure to install the required polyfills. See https://firebase.google.com/docs/web/environments-js-sdk#polyfills for more information.");return atob(e)}(t)}
23catch(t){if(t.message.includes("polyfill"))throw t;throw b(e,"Invalid character found")}let r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r}class U{constructor(e){var t;this.base64=!1,this.contentType=null;let n=e.match(/^data:([^,]+)?,/);if(null===n)throw b(P.DATA_URL,"Must be formatted 'data:[<mediatype>][;base64],<data>");let r=n[1]||null;null!=r&&(this.base64=(t=";base64",r.length>=t.length&&r.substring(r.length-t.length)===t),this.contentType=this.base64?r.substring(0,r.length-7):r),this.rest=e.substring(e.indexOf(",")+1)}}class V{constructor(e,t){let n=0,r="";S(e)?(this.data_=e,n=e.size,r=e.type):e instanceof ArrayBuffer?(t?this.data_=new Uint8Array(e):(this.data_=new Uint8Array(e.byteLength),this.data_.set(new Uint8Array(e))),n=this.data_.length):e instanceof Uint8Array&&(t?this.data_=e:(this.data_=new Uint8Array(e.length),this.data_.set(e)),n=e.length),this.size_=n,this.type_=r}size(){return this.size_}type(){return this.type_}slice(e,t){if(!S(this.data_))return new V(new Uint8Array(this.data_.buffer,e,t-e),!0);{var n;let r=(n=this.data_).webkitSlice?n.webkitSlice(e,t):n.mozSlice?n.mozSlice(e,t):n.slice?n.slice(e,t):null;return null===r?null:new V(r)}}static getBlob(...e){if(C()){let t=e.map(e=>e instanceof V?e.data_:e);return new V(D.apply(null,t))}{let t=e.map(e=>T(e)?function(e,t){switch(e){case P.RAW:return new L(M(t));case P.BASE64:case P.BASE64URL:return new L(F(e,t));case P.DATA_URL:return new L(function(e){let t=new U(e);return t.base64?F(P.BASE64,t.rest):function(e){let t;try{t=decodeURIComponent(e)}catch(e){throw b(P.DATA_URL,"Malformed data URL.")}return M(t)}(t.rest)}(t),new U(t).contentType)}throw p()}(P.RAW,e).data:e.data_),n=0;t.forEach(e=>{n+=e.byteLength});let r=new Uint8Array(n),i=0;return t.forEach(e=>{for(let t=0;t<e.length;t++)r[i++]=e[t]}),new V(r,!0)}}uploadData(){return this.data_}}function j(e){var t;let n;try{n=JSON.parse(e)}catch(e){return null}return"object"!=typeof(t=n)||Array.isArray(t)?null:n}function B(e){let t=e.lastIndexOf("/",e.length-2);return -1===t?e:e.slice(t+1)}function q(e,t){return t}class z{constructor(e,t,n,r){this.server=e,this.local=t||e,this.writable=!!n,this.xform=r||q}}let $=null;function K(){if($)return $;let e=[];e.push(new z("bucket")),e.push(new z("generation")),e.push(new z("metageneration")),e.push(new z("name","fullPath",!0));let t=new z("name");t.xform=function(e,t){return!T(t)||t.length<2?t:B(t)},e.push(t);let n=new z("size");return n.xform=function(e,t){return void 0!==t?Number(t):t},e.push(n),e.push(new z("timeCreated")),e.push(new z("updated")),e.push(new z("md5Hash",null,!0)),e.push(new z("cacheControl",null,!0)),e.push(new z("contentDisposition",null,!0)),e.push(new z("contentEncoding",null,!0)),e.push(new z("contentLanguage",null,!0)),e.push(new z("contentType",null,!0)),e.push(new z("metadata","customMetadata",!0)),$=e}function G(e,t,n){let r=j(t);return null===r?null:function(e,t,n){let r={};r.type="file";let i=n.length;for(let e=0;e<i;e++){let i=n[e];r[i.local]=i.xform(r,t[i.server])}return Object.defineProperty(r,"ref",{get:function(){let t=new I(r.bucket,r.fullPath);return e._makeStorageReference(t)}}),r}(e,r,n)}function H(e,t){let n={},r=t.length;for(let i=0;i<r;i++){let r=t[i];r.writable&&(n[r.server]=e[r.local])}return JSON.stringify(n)}class W{constructor(e,t,n,r){this.url=e,this.method=t,this.handler=n,this.timeout=r,this.urlParams={},this.headers={},this.body=null,this.errorHandler=null,this.progressCallback=null,this.successCodes=[200],this.additionalRetryCodes=[]}}function Q(e){if(!e)throw p()}function X(e,t){return function(n,r){let i=G(e,r,t);return Q(null!==i),i}}function Y(e){return function(t,n){var r,i;let o;return 401===t.getStatus()?o=t.getErrorText().includes("Firebase App Check token is invalid")?new d(s.UNAUTHORIZED_APP,"This app does not have permission to access Firebase Storage on this project."):new d(s.UNAUTHENTICATED,"User is not authenticated, please authenticate using Firebase Authentication and try again."):402===t.getStatus()?(r=e.bucket,o=new d(s.QUOTA_EXCEEDED,"Quota for bucket '"+r+"' exceeded, please view quota on https://firebase.google.com/pricing/.")):403===t.getStatus()?(i=e.path,o=new d(s.UNAUTHORIZED,"User does not have permission to access '"+i+"'.")):o=n,o.status=t.getStatus(),o.serverResponse=n.serverResponse,o}}function J(e){let t=Y(e);return function(n,r){let i=t(n,r);
23if(404===n.getStatus()){var o;o=e.path,i=new d(s.OBJECT_NOT_FOUND,"Object '"+o+"' does not exist.")}return i.serverResponse=r.serverResponse,i}}function Z(e,t,n){let r=Object.assign({},n);return r.fullPath=e.path,r.size=t.size(),!r.contentType&&(r.contentType=t&&t.type()||"application/octet-stream"),r}class ee{constructor(e,t,n,r){this.current=e,this.total=t,this.finalized=!!n,this.metadata=r||null}}function et(e,t){let n=null;try{n=e.getResponseHeader("X-Goog-Upload-Status")}catch(e){Q(!1)}return Q(!!n&&-1!==(t||["active"]).indexOf(n)),n}let en={RUNNING:"running",PAUSED:"paused",SUCCESS:"success",CANCELED:"canceled",ERROR:"error"};function er(e){switch(e){case"running":case"pausing":case"canceling":return en.RUNNING;case"paused":return en.PAUSED;case"success":return en.SUCCESS;case"canceled":return en.CANCELED;default:return en.ERROR}}class ei{constructor(e,t,n){"function"==typeof e||null!=t||null!=n?(this.next=e,this.error=null!=t?t:void 0,this.complete=null!=n?n:void 0):(this.next=e.next,this.error=e.error,this.complete=e.complete)}}function es(e){return(...t)=>{Promise.resolve().then(()=>e(...t))}}class eo{constructor(){this.sent_=!1,this.xhr_=new XMLHttpRequest,this.initXhr(),this.errorCode_=o.NO_ERROR,this.sendPromise_=new Promise(e=>{this.xhr_.addEventListener("abort",()=>{this.errorCode_=o.ABORT,e()}),this.xhr_.addEventListener("error",()=>{this.errorCode_=o.NETWORK_ERROR,e()}),this.xhr_.addEventListener("load",()=>{e()})})}send(e,t,n,r,i){if(this.sent_)throw _("cannot .send() more than once");if((0,l.Xx)(e)&&n&&(this.xhr_.withCredentials=!0),this.sent_=!0,this.xhr_.open(t,e,!0),void 0!==i)for(let e in i)i.hasOwnProperty(e)&&this.xhr_.setRequestHeader(e,i[e].toString());return void 0!==r?this.xhr_.send(r):this.xhr_.send(),this.sendPromise_}getErrorCode(){if(!this.sent_)throw _("cannot .getErrorCode() before sending");return this.errorCode_}getStatus(){if(!this.sent_)throw _("cannot .getStatus() before sending");try{return this.xhr_.status}catch(e){return -1}}getResponse(){if(!this.sent_)throw _("cannot .getResponse() before sending");return this.xhr_.response}getErrorText(){if(!this.sent_)throw _("cannot .getErrorText() before sending");return this.xhr_.statusText}abort(){this.xhr_.abort()}getResponseHeader(e){return this.xhr_.getResponseHeader(e)}addUploadProgressListener(e){null!=this.xhr_.upload&&this.xhr_.upload.addEventListener("progress",e)}removeUploadProgressListener(e){null!=this.xhr_.upload&&this.xhr_.upload.removeEventListener("progress",e)}}class ea extends eo{initXhr(){this.xhr_.responseType="text"}}function el(){return new ea}class eu{isExponentialBackoffExpired(){return this.sleepTime>this.maxSleepTime}constructor(e,t,n=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=n,this._mappings=K(),this._resumable=this._shouldDoResumable(this._blob),this._state="running",this._errorHandler=e=>{if(this._request=void 0,this._chunkMultiplier=1,e._codeEquals(s.CANCELED))this._needToFetchStatus=!0,this.completeTransitions_();else{let t=this.isExponentialBackoffExpired();if(R(e.status,[])){if(t)e=m();else{this.sleepTime=Math.max(2*this.sleepTime,1e3),this._needToFetchStatus=!0,this.completeTransitions_();return}}this._error=e,this._transition("error")}},this._metadataErrorHandler=e=>{this._request=void 0,e._codeEquals(s.CANCELED)?this.completeTransitions_():(this._error=e,this._transition("error"))},this.sleepTime=0,this.maxSleepTime=this._ref.storage.maxUploadRetryTime,this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t,this._start()}),this._promise.then(null,()=>{})}_makeProgressCallback(){let e=this._transferred;return t=>this._updateProgress(e+t)}_shouldDoResumable(e){return e.size()>262144}_start(){"running"===this._state&&void 0===this._request&&(this._resumable?void 0===this._uploadUrl?this._createResumable():this._needToFetchStatus?this._fetchStatus():this._needToFetchMetadata?this._fetchMetadata():this.pendingTimeout=setTimeout(()=>{this.pendingTimeout=void 0,this._continueUpload()},this.sleepTime):this._oneShotUpload())}_resolveToken(e){Promise.all([this._ref.storage._getAuthToken(),this._ref.storage._getAppCheckToken()]).then(([t,n])=>{switch(this._state){case"running":e(t,n);break;case"canceling":this._transition("canceled");break;case"pausing":this._transition("paused")}})}_createResumable(){this._resolveToken((e,t)=>{let n=function(e,t,n,r,i){let s=t.bucketOnlyServerUrl(),o=Z(t,r,i),a={name:o.fullPath},l=k(s,e.host,e._protocol),u={"X-Goog-Upload-Protocol":"resumable","X-Goog-Upload-Command":"start","X-Goog-Upload-Header-Content-Length":`${r.size()}`,"X-Goog-Upload-Header-Content-Type":o.contentType,"Content-Type":"application/json; charset=utf-8"},c=H(o,n),h=new W(l,"POST",function(e){let t;et(e);try{t=e.getResponseHeader("X-Goog-Upload-URL")}catch(e){Q(!1)}return Q(T(t)),t},e.maxUploadRetryTime);
23return h.urlParams=a,h.headers=u,h.body=c,h.errorHandler=Y(t),h}(this._ref.storage,this._ref._location,this._mappings,this._blob,this._metadata),r=this._ref.storage._makeRequest(n,el,e,t);this._request=r,r.getPromise().then(e=>{this._request=void 0,this._uploadUrl=e,this._needToFetchStatus=!1,this.completeTransitions_()},this._errorHandler)})}_fetchStatus(){let e=this._uploadUrl;this._resolveToken((t,n)=>{let r=function(e,t,n,r){let i=new W(n,"POST",function(e){let t=et(e,["active","final"]),n=null;try{n=e.getResponseHeader("X-Goog-Upload-Size-Received")}catch(e){Q(!1)}n||Q(!1);let i=Number(n);return Q(!isNaN(i)),new ee(i,r.size(),"final"===t)},e.maxUploadRetryTime);return i.headers={"X-Goog-Upload-Command":"query"},i.errorHandler=Y(t),i}(this._ref.storage,this._ref._location,e,this._blob),i=this._ref.storage._makeRequest(r,el,t,n);this._request=i,i.getPromise().then(e=>{this._request=void 0,this._updateProgress(e.current),this._needToFetchStatus=!1,e.finalized&&(this._needToFetchMetadata=!0),this.completeTransitions_()},this._errorHandler)})}_continueUpload(){let e=262144*this._chunkMultiplier,t=new ee(this._transferred,this._blob.size()),n=this._uploadUrl;this._resolveToken((r,i)=>{let o;try{o=function(e,t,n,r,i,o,a,l){let u=new ee(0,0);if(a?(u.current=a.current,u.total=a.total):(u.current=0,u.total=r.size()),r.size()!==u.total)throw new d(s.SERVER_FILE_WRONG_SIZE,"Server recorded incorrect upload file size, please retry the upload.");let c=u.total-u.current,h=c;i>0&&(h=Math.min(h,i));let f=u.current,p=f+h,m={"X-Goog-Upload-Command":0===h?"finalize":c===h?"upload, finalize":"upload","X-Goog-Upload-Offset":`${u.current}`},g=r.slice(f,p);if(null===g)throw y();let v=new W(n,"POST",function(e,n){let i;let s=et(e,["active","final"]),a=u.current+h,l=r.size();return i="final"===s?X(t,o)(e,n):null,new ee(a,l,"final"===s,i)},t.maxUploadRetryTime);return v.headers=m,v.body=g.uploadData(),v.progressCallback=l||null,v.errorHandler=Y(e),v}(this._ref._location,this._ref.storage,n,this._blob,e,this._mappings,t,this._makeProgressCallback())}catch(e){this._error=e,this._transition("error");return}let a=this._ref.storage._makeRequest(o,el,r,i,!1);this._request=a,a.getPromise().then(e=>{this._increaseMultiplier(),this._request=void 0,this._updateProgress(e.current),e.finalized?(this._metadata=e.metadata,this._transition("success")):this.completeTransitions_()},this._errorHandler)})}_increaseMultiplier(){262144*this._chunkMultiplier*2<33554432&&(this._chunkMultiplier*=2)}_fetchMetadata(){this._resolveToken((e,t)=>{let n=function(e,t,n){let r=k(t.fullServerUrl(),e.host,e._protocol),i=e.maxOperationRetryTime,s=new W(r,"GET",X(e,n),i);return s.errorHandler=J(t),s}(this._ref.storage,this._ref._location,this._mappings),r=this._ref.storage._makeRequest(n,el,e,t);this._request=r,r.getPromise().then(e=>{this._request=void 0,this._metadata=e,this._transition("success")},this._metadataErrorHandler)})}_oneShotUpload(){this._resolveToken((e,t)=>{let n=function(e,t,n,r,i){let s=t.bucketOnlyServerUrl(),o={"X-Goog-Upload-Protocol":"multipart"},a=function(){let e="";for(let t=0;t<2;t++)e+=Math.random().toString().slice(2);return e}();o["Content-Type"]="multipart/related; boundary="+a;let l=Z(t,r,i),u="--"+a+"\r\nContent-Type: application/json; charset=utf-8\r\n\r\n"+H(l,n)+"\r\n--"+a+"\r\nContent-Type: "+l.contentType+"\r\n\r\n",c=V.getBlob(u,r,"\r\n--"+a+"--");if(null===c)throw y();let h={name:l.fullPath},d=k(s,e.host,e._protocol),f=e.maxUploadRetryTime,p=new W(d,"POST",X(e,n),f);return p.urlParams=h,p.headers=o,p.body=c.uploadData(),p.errorHandler=Y(t),p}(this._ref.storage,this._ref._location,this._mappings,this._blob,this._metadata),r=this._ref.storage._makeRequest(n,el,e,t);this._request=r,r.getPromise().then(e=>{this._request=void 0,this._metadata=e,this._updateProgress(this._blob.size()),this._transition("success")},this._errorHandler)})}_updateProgress(e){let t=this._transferred;this._transferred=e,this._transferred!==t&&this._notifyObservers()}_transition(e){if(this._state!==e)switch(e){case"canceling":case"pausing":this._state=e,void 0!==this._request?this._request.cancel():this.pendingTimeout&&(clearTimeout(this.pendingTimeout),this.pendingTimeout=void 0,this.completeTransitions_());break;case"running":let t="paused"===this._state;this._state=e,t&&(this._notifyObservers(),this._start());break;case"paused":case"error":case"success":this._state=e,this._notifyObservers();break;case"canceled":this._error=g(),this._state=e,this._notifyObservers()}}completeTransitions_(){switch(this._state){case"pausing":this._transition("paused");break;case"canceling":this._transition("canceled");break;case"running":this._start()}}get snapshot(){let e=er(this._state);return{bytesTransferred:this._transferred,totalBytes:this._blob.size(),state:e,metadata:this._metadata,task:this,ref:this._ref}}on(e,t,n,r){let i=new ei(t||void 0,n||void 0,r||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){let t=this._observers.indexOf(e);-1!==t&&this._observers.splice(t,1)}_notifyObservers(){this._finishPromise(),this._observers.slice().forEac
23h(e=>{this._notifyObserver(e)})}_finishPromise(){if(void 0!==this._resolve){let e=!0;switch(er(this._state)){case en.SUCCESS:es(this._resolve.bind(null,this.snapshot))();break;case en.CANCELED:case en.ERROR:es(this._reject.bind(null,this._error))();break;default:e=!1}e&&(this._resolve=void 0,this._reject=void 0)}}_notifyObserver(e){switch(er(this._state)){case en.RUNNING:case en.PAUSED:e.next&&es(e.next.bind(e,this.snapshot))();break;case en.SUCCESS:e.complete&&es(e.complete.bind(e))();break;case en.CANCELED:case en.ERROR:default:e.error&&es(e.error.bind(e,this._error))()}}resume(){let e="paused"===this._state||"pausing"===this._state;return e&&this._transition("running"),e}pause(){let e="running"===this._state;return e&&this._transition("pausing"),e}cancel(){let e="running"===this._state||"pausing"===this._state;return e&&this._transition("canceling"),e}}class ec{constructor(e,t){this._service=e,t instanceof I?this._location=t:this._location=I.makeFromUrl(t,e.host)}toString(){return"gs://"+this._location.bucket+"/"+this._location.path}_newRef(e,t){return new ec(e,t)}get root(){let e=new I(this._location.bucket,"");return this._newRef(this._service,e)}get bucket(){return this._location.bucket}get fullPath(){return this._location.path}get name(){return B(this._location.path)}get storage(){return this._service}get parent(){let e=function(e){if(0===e.length)return null;let t=e.lastIndexOf("/");return -1===t?"":e.slice(0,t)}(this._location.path);if(null===e)return null;let t=new I(this._location.bucket,e);return new ec(this._service,t)}_throwIfRoot(e){if(""===this._location.path)throw new d(s.INVALID_ROOT_OPERATION,"The operation '"+e+"' cannot be performed on a root reference, create a non-root reference using child, such as .child('file.png').")}}function eh(e,t){let n=null==t?void 0:t[h];return null==n?null:I.makeFromBucketSpec(n,e)}class ed{constructor(e,t,n,r,i,s=!1){this.app=e,this._authProvider=t,this._appCheckProvider=n,this._url=r,this._firebaseVersion=i,this._isUsingEmulator=s,this._bucket=null,this._host=c,this._protocol="https",this._appId=null,this._deleted=!1,this._maxOperationRetryTime=12e4,this._maxUploadRetryTime=6e5,this._requests=new Set,null!=r?this._bucket=I.makeFromBucketSpec(r,this._host):this._bucket=eh(this._host,this.app.options)}get host(){return this._host}set host(e){this._host=e,null!=this._url?this._bucket=I.makeFromBucketSpec(this._url,e):this._bucket=eh(e,this.app.options)}get maxUploadRetryTime(){return this._maxUploadRetryTime}set maxUploadRetryTime(e){x("time",0,Number.POSITIVE_INFINITY,e),this._maxUploadRetryTime=e}get maxOperationRetryTime(){return this._maxOperationRetryTime}set maxOperationRetryTime(e){x("time",0,Number.POSITIVE_INFINITY,e),this._maxOperationRetryTime=e}async _getAuthToken(){if(this._overrideAuthToken)return this._overrideAuthToken;let e=this._authProvider.getImmediate({optional:!0});if(e){let t=await e.getToken();if(null!==t)return t.accessToken}return null}async _getAppCheckToken(){if((0,a.rh)(this.app)&&this.app.settings.appCheckToken)return this.app.settings.appCheckToken;let 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 ec(this,e)}_makeRequest(e,t,n,r,i=!0){if(this._deleted)return new E(w());{let s=function(e,t,n,r,i,s,o=!0,a=!1){let l=A(e.urlParams),u=e.url+l,c=Object.assign({},e.headers);return t&&(c["X-Firebase-GMPID"]=t),null!==n&&n.length>0&&(c.Authorization="Firebase "+n),c["X-Firebase-Storage-Version"]="webjs/"+(null!=s?s:"AppManager"),null!==r&&(c["X-Firebase-AppCheck"]=r),new N(u,e.method,c,e.body,e.successCodes,e.additionalRetryCodes,e.handler,e.errorHandler,e.timeout,e.progressCallback,i,o,a)}(e,this._appId,n,r,t,this._firebaseVersion,i,this._isUsingEmulator);return this._requests.add(s),s.getPromise().then(()=>this._requests.delete(s),()=>this._requests.delete(s)),s}}async makeRequestWithTokens(e,t){let[n,r]=await Promise.all([this._getAuthToken(),this._getAppCheckToken()]);
23return this._makeRequest(e,t,n,r).getPromise()}}let ef="@firebase/storage",ep="0.13.13",em="storage";function eg(e,t,n){var r;return(r=e=(0,l.m9)(e))._throwIfRoot("uploadBytesResumable"),new eu(r,new V(t),n)}function ey(e){return function(e){e._throwIfRoot("getDownloadURL");let t=function(e,t,n){let r=new W(k(t.fullServerUrl(),e.host,e._protocol),"GET",function(t,r){let i=G(e,r,n);return Q(null!==i),function(e,t,n,r){let i=j(t);if(null===i||!T(i.downloadTokens))return null;let s=i.downloadTokens;if(0===s.length)return null;let o=encodeURIComponent;return s.split(",").map(t=>{let i=e.bucket,s=e.fullPath;return k("/b/"+o(i)+"/o/"+o(s),n,r)+A({alt:"media",token:t})})[0]}(i,r,e.host,e._protocol)},e.maxOperationRetryTime);return r.errorHandler=J(t),r}(e.storage,e._location,K());return e.storage.makeRequestWithTokens(t,el).then(e=>{if(null===e)throw new d(s.NO_DOWNLOAD_URL,"The given file does not have any download URLs.");return e})}(e=(0,l.m9)(e))}function ev(e,t){return function(e,t){if(!(t&&/^[A-Za-z]+:\/\//.test(t)))return function e(t,n){if(t instanceof ed){if(null==t._bucket)throw new d(s.NO_DEFAULT_BUCKET,"No default bucket found. Did you set the '"+h+"' property when initializing the app?");let r=new ec(t,t._bucket);return null!=n?e(r,n):r}return void 0!==n?function(e,t){let n=function(e,t){let n=t.split("/").filter(e=>e.length>0).join("/");return 0===e.length?n:e+"/"+n}(e._location.path,t),r=new I(e._location.bucket,n);return new ec(e.storage,r)}(t,n):t}(e,t);if(e instanceof ed)return new ec(e,t);throw v("To use ref(service, url), the first argument must be a Storage instance.")}(e=(0,l.m9)(e),t)}function ew(e=(0,a.Mq)(),t){e=(0,l.m9)(e);let n=(0,a.qX)(e,em).getImmediate({identifier:t}),r=(0,l.P0)("storage");return r&&function(e,t,n,r={}){!function(e,t,n,r={}){e.host=`${t}:${n}`;let i=(0,l.Xx)(t);i&&((0,l.Uo)(`https://${e.host}/b`),(0,l.dp)("Storage",!0)),e._isUsingEmulator=!0,e._protocol=i?"https":"http";let{mockUserToken:s}=r;s&&(e._overrideAuthToken="string"==typeof s?s:(0,l.Sg)(s,e.app.options.projectId))}(e,t,n,r)}(n,...r),n}(0,a.Xd)(new u.wA(em,function(e,{instanceIdentifier:t}){return new ed(e.getProvider("app").getImmediate(),e.getProvider("auth-internal"),e.getProvider("app-check-internal"),t,a.Jn)},"PUBLIC").setMultipleInstances(!0)),(0,a.KN)(ef,ep,""),(0,a.KN)(ef,ep,"esm2017")},6531:function(e,t,n){"use strict";let r,i,s;n.d(t,{Lj:function(){return g},X3:function(){return m}});let o=(e,t)=>t.some(t=>e instanceof t),a=new WeakMap,l=new WeakMap,u=new WeakMap,c=new WeakMap,h=new WeakMap,d={get(e,t,n){if(e instanceof IDBTransaction){if("done"===t)return l.get(e);if("objectStoreNames"===t)return e.objectStoreNames||u.get(e);if("store"===t)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return f(e[t])},set:(e,t,n)=>(e[t]=n,!0),has:(e,t)=>e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e};function f(e){var t;if(e instanceof IDBRequest)return function(e){let t=new Promise((t,n)=>{let r=()=>{e.removeEventListener("success",i),e.removeEventListener("error",s)},i=()=>{t(f(e.result)),r()},s=()=>{n(e.error),r()};e.addEventListener("success",i),e.addEventListener("error",s)});return t.then(t=>{t instanceof IDBCursor&&a.set(t,e)}).catch(()=>{}),h.set(t,e),t}(e);if(c.has(e))return c.get(e);let n="function"==typeof(t=e)?t!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?(i||(i=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(t)?function(...e){return t.apply(p(this),e),f(a.get(this))}:function(...e){return f(t.apply(p(this),e))}:function(e,...n){let r=t.call(p(this),e,...n);return u.set(r,e.sort?e.sort():[e]),f(r)}:(t instanceof IDBTransaction&&function(e){if(l.has(e))return;let t=new Promise((t,n)=>{let r=()=>{e.removeEventListener("complete",i),e.removeEventListener("error",s),e.removeEventListener("abort",s)},i=()=>{t(),r()},s=()=>{n(e.error||new DOMException("AbortError","AbortError")),r()};e.addEventListener("complete",i),e.addEventListener("error",s),e.addEventListener("abort",s)});l.set(e,t)}(t),o(t,r||(r=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])))?new Proxy(t,d):t;return n!==e&&(c.set(e,n),h.set(n,e)),n}let p=e=>h.get(e);function m(e,t,{blocked:n,upgrade:r,blocking:i,terminated:s}={}){let o=indexedDB.open(e,t),a=f(o);return r&&o.addEventListener("upgradeneeded",e=>{r(f(o.result),e.oldVersion,e.newVersion,f(o.transaction),e)}),n&&o.addEventListener("blocked",e=>n(e.oldVersion,e.newVersion,e)),a.then(e=>{s&&e.addEventListener("close",()=>s()),i&&e.addEventListener("versionchange",e=>i(e.oldVersion,e.newVersion,e))}).catch(()=>{}),a}function g(e,{blocked:t}={}){let n=indexedDB.deleteDatabase(e);return t&&n.addEventListener("blocked",e=>t(e.oldVersion,e)),f(n).then(()=>void 0)}let y=["get","getKey","getAll","getAllKeys","count"],v=["put","add","delete","clear"],w=new Map;function b(e,t){if(!(e instanceof IDBDatabase&&!(t in e)&&"string"==typeof t))return;if(w.get(t))return w.get(t);let n=t.replace(/FromIndex$/,""),r=t!==n,i=v.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!(i||y.includes(n)))return;let s=async function(e,...t){let s=this.transaction(e,i?"readwrite":"readonly"),o=s.store;
23return r&&(o=o.index(t.shift())),(await Promise.all([o[n](...t),i&&s.done]))[0]};return w.set(t,s),s}d={...s=d,get:(e,t,n)=>b(e,t)||s.get(e,t,n),has:(e,t)=>!!b(e,t)||s.has(e,t)}},6501:function(e,t,n){"use strict";let r,i;n.d(t,{$x:function(){return ea},x7:function(){return eh},ZP:function(){return ed},Am:function(){return L}});var s,o=n(7294);let a={data:""},l=e=>"object"==typeof window?((e?e.querySelector("#_goober"):window._goober)||Object.assign((e||document.head).appendChild(document.createElement("style")),{innerHTML:" ",id:"_goober"})).firstChild:e||a,u=/(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g,c=/\/\*[^]*?\*\/| +/g,h=/\n+/g,d=(e,t)=>{let n="",r="",i="";for(let s in e){let o=e[s];"@"==s[0]?"i"==s[1]?n=s+" "+o+";":r+="f"==s[1]?d(o,s):s+"{"+d(o,"k"==s[1]?"":t)+"}":"object"==typeof o?r+=d(o,t?t.replace(/([^,])+/g,e=>s.replace(/([^,]*:\S+\([^)]*\))|([^,])+/g,t=>/&/.test(t)?t.replace(/&/g,e):e?e+" "+t:t)):s):null!=o&&(s=/^--/.test(s)?s:s.replace(/[A-Z]/g,"-$&").toLowerCase(),i+=d.p?d.p(s,o):s+":"+o+";")}return n+(t&&i?t+"{"+i+"}":i)+r},f={},p=e=>{if("object"==typeof e){let t="";for(let n in e)t+=n+p(e[n]);return t}return e},m=(e,t,n,r,i)=>{var s;let o=p(e),a=f[o]||(f[o]=(e=>{let t=0,n=11;for(;t<e.length;)n=101*n+e.charCodeAt(t++)>>>0;return"go"+n})(o));if(!f[a]){let t=o!==e?e:(e=>{let t,n,r=[{}];for(;t=u.exec(e.replace(c,""));)t[4]?r.shift():t[3]?(n=t[3].replace(h," ").trim(),r.unshift(r[0][n]=r[0][n]||{})):r[0][t[1]]=t[2].replace(h," ").trim();return r[0]})(e);f[a]=d(i?{["@keyframes "+a]:t}:t,n?"":"."+a)}let l=n&&f.g?f.g:null;return n&&(f.g=f[a]),s=f[a],l?t.data=t.data.replace(l,s):-1===t.data.indexOf(s)&&(t.data=r?s+t.data:t.data+s),a},g=(e,t,n)=>e.reduce((e,r,i)=>{let s=t[i];if(s&&s.call){let e=s(n),t=e&&e.props&&e.props.className||/^go/.test(e)&&e;s=t?"."+t:e&&"object"==typeof e?e.props?"":d(e,""):!1===e?"":e}return e+r+(null==s?"":s)},"");function y(e){let t=this||{},n=e.call?e(t.p):e;return m(n.unshift?n.raw?g(n,[].slice.call(arguments,1),t.p):n.reduce((e,n)=>Object.assign(e,n&&n.call?n(t.p):n),{}):n,l(t.target),t.g,t.o,t.k)}y.bind({g:1});let v,w,b,_=y.bind({k:1});function I(e,t){let n=this||{};return function(){let r=arguments;function i(s,o){let a=Object.assign({},s),l=a.className||i.className;n.p=Object.assign({theme:w&&w()},a),n.o=/ *go\d+/.test(l),a.className=y.apply(n,r)+(l?" "+l:""),t&&(a.ref=o);let u=e;return e[0]&&(u=a.as||e,delete a.as),b&&u[0]&&b(a),v(u,a)}return t?t(i):i}}var E=e=>"function"==typeof e,T=(e,t)=>E(e)?e(t):e,S=(r=0,()=>(++r).toString()),C=()=>{if(void 0===i&&"u">typeof window){let e=matchMedia("(prefers-reduced-motion: reduce)");i=!e||e.matches}return i},x=(e,t)=>{switch(t.type){case 0:return{...e,toasts:[t.toast,...e.toasts].slice(0,20)};case 1:return{...e,toasts:e.toasts.map(e=>e.id===t.toast.id?{...e,...t.toast}:e)};case 2:let{toast:n}=t;return x(e,{type:e.toasts.find(e=>e.id===n.id)?1:0,toast:n});case 3:let{toastId:r}=t;return{...e,toasts:e.toasts.map(e=>e.id===r||void 0===r?{...e,dismissed:!0,visible:!1}:e)};case 4:return void 0===t.toastId?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(e=>e.id!==t.toastId)};case 5:return{...e,pausedAt:t.time};case 6:let i=t.time-(e.pausedAt||0);return{...e,pausedAt:void 0,toasts:e.toasts.map(e=>({...e,pauseDuration:e.pauseDuration+i}))}}},k=[],A={toasts:[],pausedAt:void 0},R=e=>{A=x(A,e),k.forEach(e=>{e(A)})},N={blank:4e3,error:4e3,success:2e3,loading:1/0,custom:4e3},O=(e={})=>{let[t,n]=(0,o.useState)(A),r=(0,o.useRef)(A);(0,o.useEffect)(()=>(r.current!==A&&n(A),k.push(n),()=>{let e=k.indexOf(n);e>-1&&k.splice(e,1)}),[]);let i=t.toasts.map(t=>{var n,r,i;return{...e,...e[t.type],...t,removeDelay:t.removeDelay||(null==(n=e[t.type])?void 0:n.removeDelay)||(null==e?void 0:e.removeDelay),duration:t.duration||(null==(r=e[t.type])?void 0:r.duration)||(null==e?void 0:e.duration)||N[t.type],style:{...e.style,...null==(i=e[t.type])?void 0:i.style,...t.style}}});return{...t,toasts:i}},D=(e,t="blank",n)=>({createdAt:Date.now(),visible:!0,dismissed:!1,type:t,ariaProps:{role:"status","aria-live":"polite"},message:e,pauseDuration:0,...n,id:(null==n?void 0:n.id)||S()}),P=e=>(t,n)=>{let r=D(t,e,n);return R({type:2,toast:r}),r.id},L=(e,t)=>P("blank")(e,t);L.error=P("error"),L.success=P("success"),L.loading=P("loading"),L.custom=P("custom"),L.dismiss=e=>{R({type:3,toastId:e})},L.remove=e=>R({type:4,toastId:e}),L.promise=(e,t,n)=>{let r=L.loading(t.loading,{...n,...null==n?void 0:n.loading});return"function"==typeof e&&(e=e()),e.then(e=>{let i=t.success?T(t.success,e):void 0;return i?L.success(i,{id:r,...n,...null==n?void 0:n.success}):L.dismiss(r),e}).catch(e=>{let i=t.error?T(t.error,e):void 0;i?L.error(i,{id:r,...n,...null==n?void 0:n.error}):L.dismiss(r)}),e};var M=(e,t)=>{R({type:1,toast:{id:e,height:t}})},F=()=>{R({type:5,time:Date.now()})},U=new Map,V=1e3,j=(e,t=V)=>{if(U.has(e))return;let n=setTimeout(()=>{U.delete(e),R({type:4,toastId:e})},t);U.set(e,n)},B=e=>{let{toasts:t,pausedAt:n}=O(e);(0,o.useEffect)(()=>
23{if(n)return;let e=Date.now(),r=t.map(t=>{if(t.duration===1/0)return;let n=(t.duration||0)+t.pauseDuration-(e-t.createdAt);if(n<0){t.visible&&L.dismiss(t.id);return}return setTimeout(()=>L.dismiss(t.id),n)});return()=>{r.forEach(e=>e&&clearTimeout(e))}},[t,n]);let r=(0,o.useCallback)(()=>{n&&R({type:6,time:Date.now()})},[n]),i=(0,o.useCallback)((e,n)=>{let{reverseOrder:r=!1,gutter:i=8,defaultPosition:s}=n||{},o=t.filter(t=>(t.position||s)===(e.position||s)&&t.height),a=o.findIndex(t=>t.id===e.id),l=o.filter((e,t)=>t<a&&e.visible).length;return o.filter(e=>e.visible).slice(...r?[l+1]:[0,l]).reduce((e,t)=>e+(t.height||0)+i,0)},[t]);return(0,o.useEffect)(()=>{t.forEach(e=>{if(e.dismissed)j(e.id,e.removeDelay);else{let t=U.get(e.id);t&&(clearTimeout(t),U.delete(e.id))}})},[t]),{toasts:t,handlers:{updateHeight:M,startPause:F,endPause:r,calculateOffset:i}}},q=_` 24from { 25 transform: scale(0) rotate(45deg); 26 opacity: 0; 27} 28to { 29 transform: scale(1) rotate(45deg); 30 opacity: 1; 31}`,z=_` 32from { 33 transform: scale(0); 34 opacity: 0; 35} 36to { 37 transform: scale(1); 38 opacity: 1; 39}`,$=_` 40from { 41 transform: scale(0) rotate(90deg); 42 opacity: 0; 43} 44to { 45 transform: scale(1) rotate(90deg); 46 opacity: 1; 47}`,K=I("div")` 48 width: 20px; 49 opacity: 0; 50 height: 20px; 51 border-radius: 10px; 52 background: ${e=>e.primary||"#ff4b4b"}; 53 position: relative; 54 transform: rotate(45deg); 55 56 animation: ${q} 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) 57 forwards; 58 animation-delay: 100ms; 59 60 &:after, 61 &:before { 62 content: ''; 63 animation: ${z} 0.15s ease-out forwards; 64 animation-delay: 150ms; 65 position: absolute; 66 border-radius: 3px; 67 opacity: 0; 68 background: ${e=>e.secondary||"#fff"}; 69 bottom: 9px; 70 left: 4px; 71 height: 2px; 72 width: 12px; 73 } 74 75 &:before { 76 animation: ${$} 0.15s ease-out forwards; 77 animation-delay: 180ms; 78 transform: rotate(90deg); 79 } 80`,G=_` 81 from { 82 transform: rotate(0deg); 83 } 84 to { 85 transform: rotate(360deg); 86 } 87`,H=I("div")` 88 width: 12px; 89 height: 12px; 90 box-sizing: border-box; 91 border: 2px solid; 92 border-radius: 100%; 93 border-color: ${e=>e.secondary||"#e0e0e0"}; 94 border-right-color: ${e=>e.primary||"#616161"}; 95 animation: ${G} 1s linear infinite; 96`,W=_` 97from { 98 transform: scale(0) rotate(45deg); 99 opacity: 0; 100} 101to { 102 transform: scale(1) rotate(45deg); 103 opacity: 1; 104}`,Q=_` 1050% { 106 height: 0; 107 width: 0; 108 opacity: 0; 109} 11040% { 111 height: 0; 112 width: 6px; 113 opacity: 1; 114} 115100% { 116 opacity: 1; 117 height: 10px; 118}`,X=I("div")` 119 width: 20px; 120 opacity: 0; 121 height: 20px; 122 border-radius: 10px; 123 background: ${e=>e.primary||"#61d345"}; 124 position: relative; 125 transform: rotate(45deg); 126 127 animation: ${W} 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) 128 forwards; 129 animation-delay: 100ms; 130 &:after { 131 content: ''; 132 box-sizing: border-box; 133 animation: ${Q} 0.2s ease-out forwards; 134 opacity: 0; 135 animation-delay: 200ms; 136 position: absolute; 137 border-right: 2px solid; 138 border-bottom: 2px solid; 139 border-color: ${e=>e.secondary||"#fff"}; 140 bottom: 6px; 141 left: 6px; 142 height: 10px; 143 width: 6px; 144 } 145`,Y=I("div")` 146 position: absolute; 147`,J=I("div")` 148 position: relative; 149 display: flex; 150 justify-content: center; 151 align-items: center; 152 min-width: 20px; 153 min-height: 20px; 154`,Z=_` 155from { 156 transform: scale(0.6); 157 opacity: 0.4; 158} 159to { 160 transform: scale(1); 161 opacity: 1; 162}`,ee=I("div")` 163 position: relative; 164 transform: scale(0.6); 165 opacity: 0.4; 166 min-width: 20px; 167 animation: ${Z} 0.3s 0.12s cubic-bezier(0.175, 0.885, 0.32, 1.275) 168 forwards; 169`,et=({toast:e})=>{let{icon:t,type:n,iconTheme:r}=e;return void 0!==t?"string"==typeof t?o.createElement(ee,null,t):t:"blank"===n?null:o.createElement(J,null,o.createElement(H,{...r}),"loading"!==n&&o.createElement(Y,null,"error"===n?o.createElement(K,{...r}):o.createElement(X,{...r})))},en=e=>` 1700% {transform: translate3d(0,${-200*e}%,0) scale(.6); opacity:.5;} 171100% {transform: translate3d(0,0,0) scale(1); opacity:1;} 172`,er=e=>` 1730% {transform: translate3d(0,0,-1px) scale(1); opacity:1;} 174100% {transform: translate3d(0,${-150*e}%,-1px) scale(.6); opacity:0;} 175`,ei=I("div")` 176 display: flex; 177 align-items: center; 178 background: #fff; 179 color: #363636; 180 line-height: 1.3; 181 will-change: transform; 182 box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1), 0 3px 3px rgba(0, 0, 0, 0.05); 183 max-width: 350px; 184 pointer-events: auto; 185 padding: 8px 10px; 186 border-radius: 8px; 187`,es=I("div")` 188 display: flex; 189 justify-content: center; 190 margin: 4px 10px; 191 color: inherit; 192 flex: 1 1 auto; 193 white-space: pre-line; 194`,eo=(e,t)=>{let n=e.includes("top")?1:-1,[r,i]=C()?["0%{opacity:0;} 100%{opacity:1;}","0%{opacity:1;} 100%{opacity:0;}"]:[en(n),er(n)];return{animation:t?`${_(r)} 0.35s cubic-bezier(.21,1.02,.73,1) forwards`:`${_(i)} 0.4s forwards cubic-bezier(.06,.71,.55,1)`}},ea=o.memo(({toast:e,position:t,style:n,children:r})=>
194{let i=e.height?eo(e.position||t||"top-center",e.visible):{opacity:0},s=o.createElement(et,{toast:e}),a=o.createElement(es,{...e.ariaProps},T(e.message,e));return o.createElement(ei,{className:e.className,style:{...i,...n,...e.style}},"function"==typeof r?r({icon:s,message:a}):o.createElement(o.Fragment,null,s,a))});s=o.createElement,d.p=void 0,v=s,w=void 0,b=void 0;var el=({id:e,className:t,style:n,onHeightUpdate:r,children:i})=>{let s=o.useCallback(t=>{if(t){let n=()=>{r(e,t.getBoundingClientRect().height)};n(),new MutationObserver(n).observe(t,{subtree:!0,childList:!0,characterData:!0})}},[e,r]);return o.createElement("div",{ref:s,className:t,style:n},i)},eu=(e,t)=>{let n=e.includes("top"),r=e.includes("center")?{justifyContent:"center"}:e.includes("right")?{justifyContent:"flex-end"}:{};return{left:0,right:0,display:"flex",position:"absolute",transition:C()?void 0:"all 230ms cubic-bezier(.21,1.02,.73,1)",transform:`translateY(${t*(n?1:-1)}px)`,...n?{top:0}:{bottom:0},...r}},ec=y` 195 z-index: 9999; 196 > * { 197 pointer-events: auto; 198 } 199`,eh=({reverseOrder:e,position:t="top-center",toastOptions:n,gutter:r,children:i,containerStyle:s,containerClassName:a})=>{let{toasts:l,handlers:u}=B(n);return o.createElement("div",{id:"_rht_toaster",style:{position:"fixed",zIndex:9999,top:16,left:16,right:16,bottom:16,pointerEvents:"none",...s},className:a,onMouseEnter:u.startPause,onMouseLeave:u.endPause},l.map(n=>{let s=n.position||t,a=eu(s,u.calculateOffset(n,{reverseOrder:e,gutter:r,defaultPosition:t}));return o.createElement(el,{id:n.id,key:n.id,onHeightUpdate:u.updateHeight,className:n.visible?ec:"",style:a},"custom"===n.type?T(n.message,n):i?i(n):o.createElement(ea,{toast:n,position:s}))}))},ed=L}},function(e){var t=function(t){return e(e.s=t)};e.O(0,[9774,179],function(){return t(6840),t(3079)}),_N_E=e.O()}]);
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.